diff --git a/README.md b/README.md index 2b14a86..13f2cd0 100644 --- a/README.md +++ b/README.md @@ -194,7 +194,7 @@ This type-checks with `tsc --noEmit` (strict) and bundles with esbuild. Fonts ar ### Brand -`scripts/sync-brand.sh` copies the tokens, `lucio-morph.js`, the favicon and the chop from `../LUCIO_ip` (or `$LUCIO_IP_DIR`) into `web/brand/`, stripping comments. The copies are committed; rebuild the front-end afterwards. +`scripts/sync-brand.sh` copies the tokens, `lucio-morph.js`, `lucio-loaders.js`, the favicon and the chop from `../lucioIP` (or `$LUCIO_IP_DIR`) into `web/brand/`, stripping comments. The copies are committed; rebuild the front-end afterwards. ## Output layout diff --git a/docs/DESIGN.md b/docs/DESIGN.md index 3b56c19..b6c7fc9 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -97,18 +97,19 @@ Served by the daemon in serve mode, and in export mode on `server.listen` (nothi 4. Final level: highest level up to the needed one whose visible-tile bytes ÷ throughput ≤ (budget − elapsed) × 0.8. If it is 2+ levels above the probe, fetch one intermediate level first. 5. Fetch only visible tiles, centre outwards, `concurrency` at a time; each tile fades in over the lower layer as it decodes. 6. Deadline `budget_ms` (3000): abort unfinished upgrades and keep what is on screen. +7. Top-up (album viewer, un-zoomed, only when steps 3–5 finished inside the deadline; never with Save-Data or on 2g/3g): each level batch also measures throughput (bytes ÷ wall time). If the final level stopped short of the needed one, fetch the needed level when its bytes ÷ throughput ≤ 6 s. Then, on a capable device (≥ 4 cores, `deviceMemory` ≥ 4 GB where reported) with throughput ≥ 1.5 MB/s, fetch one level above the needed one when it fits in 4 s and its decoded visible pixels stay under 35 % of the tile cache; it is drawn downscaled with high-quality smoothing. These fetches run at prefetch priority, show no loader and stop when the photo is left or zoomed. Moving to another photo aborts that photo's requests. Prefetch the next photo's seed and probe level and, for multi-slide photos, the next slide's tiles. Decoded tiles live in an LRU cache capped at about 250 MB on desktop and 120 MB on phones. Decode with `createImageBitmap` (in a worker where supported). The canvas is always viewport-sized. Pixel density capped at `max_dpr` (2). ## Screens -Album index: full-width strips, 8 px apart on phones, 16 px on desktop. Header with the Lucio wordmark (Guoliang → Lucio morph on hover, the only animation on this screen); footer with the chop. Closed strip 32:6 showing the `collapsed_focus_y` band of the 32:9 cover, height `min(100vw*6/32, 28vh)`; open 32:9, height `min(100vw*9/32, 62vh)`; the cover is drawn cover-fit, never stretched (under the height caps a very wide screen crops top and bottom). Desktop: hover opens. Touch: the strip nearest the vertical centre opens while scrolling; tap enters. On open the height animates 240 ms, then the title fades in (light-on): mono date line, then the title in Bricolage Grotesque, bottom-left. Covers use the tile loader; closed strips load only the visible band; only strips near the viewport load. +Album index: full-width strips, 8 px apart on phones, 16 px on desktop. Header with the Lucio wordmark (Guoliang → Lucio morph on hover, the only animation on this screen); footer with the LUCIO loader in smoke (bottom-right; the plain SVG loader without WebGL; the chop until the script runs). Closed strip 32:6 showing the `collapsed_focus_y` band of the 32:9 cover, height `min(100vw*6/32, 28vh)`; open 32:9, height `min(100vw*9/32, 62vh)`; the cover is drawn cover-fit, never stretched (under the height caps a very wide screen crops top and bottom). Desktop: hover opens. Touch: the strip nearest the vertical centre opens while scrolling; tap enters. On open the height animates 240 ms, then the title fades in (light-on): mono date line, then the title in Bricolage Grotesque, bottom-left. Covers use the tile loader; closed strips load only the visible band; only strips near the viewport load. -Album viewer: one photo at a time, contained in the viewport (fills height or width, never stretched), centred on graphite. Swipe right-to-left, ←/→, click-and-drag; one pointer-events handler for mouse and touch with flick velocity and rubber-band ends; Home/End; Esc returns to the index. `slides: N`: the photo is scaled so a 1/N-wide section fits the viewport; moving between its slides is a continuous pan. `/a//#7` opens photo 7. End card: chop, "— Lucio", the next album's strip. Reduced motion: crossfades. +Album viewer: one photo at a time, contained in the viewport (fills height or width, never stretched), centred on graphite. Swipe right-to-left, ←/→, click-and-drag; one pointer-events handler for mouse and touch with flick velocity and rubber-band ends; Home/End; Esc returns to the index. `slides: N`: the photo is scaled so a 1/N-wide section fits the viewport; moving between its slides is a continuous pan. `/a//#7` opens photo 7. End card: the LUCIO loader in smoke, "— Lucio", the next album's strip. Reduced motion: crossfades. Captions: hidden by default; shown while the pointer is in the bottom 20% of the photo; click or tap pins/unpins; `i` toggles. A tap is < 10 px movement and < 300 ms. Panel: mono line `03 / 12 · Z8 · 24-70 f/2.8 · 35mm · f/8 · 1/250 · ISO 64` (EXIF only when `show_exif`), then the caption in IBM Plex Sans over a graphite fade. Captions are real DOM text. -Lucio brand (source of truth: ../LUCIO_ip): graphite #111114 ground, paper #F3F1EC text, beam #FFF3CF only on focus and a thin progress line, steel for secondary text, cinnabar only in the chop. Bricolage Grotesque display, IBM Plex Sans body, IBM Plex Mono eyebrows (uppercase, +0.08em). Fonts self-hosted woff2, nothing from Google. If a photo has nothing sharp after 400 ms, the L→U→C→I→O loader (LucioMorph.loader) appears on the right edge, vertically centred, inset ≥ 32 px. One animated element per screen. Motion: 120 ms hover, 240 ms reveals, 900 ms light-on with cubic-bezier(0.16, 1, 0.3, 1). Brand files are copied from LUCIO_ip by `scripts/sync-brand.sh`. +Lucio brand (source of truth: ../lucioIP): graphite #111114 ground, paper #F3F1EC text, beam #FFF3CF only on focus and a thin progress line, steel for secondary text, cinnabar only in the chop. Bricolage Grotesque display, IBM Plex Sans body, IBM Plex Mono eyebrows (uppercase, +0.08em). Fonts self-hosted woff2, nothing from Google. If a photo has nothing sharp after 400 ms, the L→U→C→I→O loader (LucioMorph.loader) appears on the right edge, vertically centred, inset ≥ 32 px. One animated element per screen. Motion: 120 ms hover, 240 ms reveals, 900 ms light-on with cubic-bezier(0.16, 1, 0.3, 1). Brand files are copied from lucioIP by `scripts/sync-brand.sh`. ## Discouraging saves diff --git a/internal/site/static/app.js b/internal/site/static/app.js index 0ec070f..8bbeb01 100644 --- a/internal/site/static/app.js +++ b/internal/site/static/app.js @@ -1 +1,279 @@ -"use strict";(()=>{(function(n){let t={from:"Guoliang",to:"Lucio",letters:[{ch:"G",kind:"keep",shared:"M8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50",fullA:"M80.00 8.50L58.00 8.50L22.00 8.50A13.50 13.50 0 0 0 8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50A13.50 13.50 0 0 0 71.50 78.00L71.50 56.00L41.50 56.00",fullB:"M8.50 0.00L8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50L80.00 91.50",out:[{d:"M80.00 8.50L58.00 8.50L22.00 8.50A13.50 13.50 0 0 0 8.50 22.00",P:79.21,j:"end"},{d:"M58.00 91.50A13.50 13.50 0 0 0 71.50 78.00L71.50 56.00L41.50 56.00",P:73.21,j:"start"}],in:[{d:"M8.50 22.00L8.50 0.00",P:22,j:"start"},{d:"M58.00 91.50L80.00 91.50",P:22,j:"start"}],x0:0,x1:0,dot:null},{ch:"u",kind:"keep",shared:"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00",fullA:"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00",fullB:"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00",out:[],in:[],x0:88.8,x1:88,dot:null},{ch:"o",kind:"keep",shared:"M38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",fullA:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",fullB:"M60.00 46.50L38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50L60.00 91.50",out:[{d:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50",P:60.41,j:"both"}],in:[{d:"M38.00 46.50L60.00 46.50",P:22,j:"start"},{d:"M38.00 91.50L60.00 91.50",P:22,j:"start"}],x0:159,x1:158.2,dot:null},{ch:"l",kind:"fade",d:"M8.50 0.00L8.50 100.00",x0:230.8,x1:230.8,dot:null},{ch:"i",kind:"keep",shared:"M8.50 38.00L8.50 100.00",fullA:"M8.50 38.00L8.50 100.00",fullB:"M8.50 38.00L8.50 100.00",out:[],in:[],x0:262.8,x1:227.9,dot:[0,14,17]},{ch:"a",kind:"fade",d:"M38.00 91.50L51.50 91.50L51.50 78.00L51.50 60.00L51.50 46.50L38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",x0:291.6,x1:291.6,dot:null},{ch:"n",kind:"fade",d:"M51.50 100.00L51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00L8.50 100.00",x0:362.7,x1:362.7,dot:null},{ch:"g",kind:"keep",shared:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",fullA:"M0.00 127.50L38.00 127.50A13.50 13.50 0 0 0 51.50 114.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00",fullB:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",out:[{d:"M51.50 60.00L51.50 114.00A13.50 13.50 0 0 1 38.00 127.50L0.00 127.50",P:113.21,j:"start"}],in:[],x0:432.9,x1:256.7,dot:null}],pad:17,vbw:526.9,vbh:170,stroke:17,raysT:"translate(0.000 22.727) scale(0.7727)"},e="M47.6 70.7L71.9 61.1L71.1 58.2L45.2 62.0ZM44.9 61.5L61.2 40.9L59.1 38.8L38.5 55.1ZM38.0 54.8L41.8 28.9L38.9 28.1L29.3 52.4Z",i="http://www.w3.org/2000/svg",s=(u,y)=>{let d=document.createElementNS(i,u);for(let v in y)d.setAttribute(v,y[v]);return d},r=()=>n.matchMedia&&n.matchMedia("(prefers-reduced-motion: reduce)").matches,o=u=>Math.max(0,Math.min(1,u)),a=u=>u*u*(3-2*u),h=.5;function l(u,y){let d=0,v=0,f=null,M=0;function A(L){let x=(L-M)/y;M=L,d=dp(1),reverse:()=>p(0),toggle:()=>p(v?0:1),set:L=>{cancelAnimationFrame(f),f=null,v=d=L,u(d)},stop:()=>{cancelAnimationFrame(f),f=null},get t(){return d}}}function c(u,y,d,v){let f=o(v)*y;if(u.style.visibility=f<.05?"hidden":"visible",d==="both"){let M=f/2;u.setAttribute("stroke-dasharray",M.toFixed(2)+" "+Math.max(0,y-2*M).toFixed(2)+" "+M.toFixed(2)),u.setAttribute("stroke-dashoffset","0")}else d==="end"?(u.setAttribute("stroke-dasharray",f.toFixed(2)+" "+(2*y+20).toFixed(2)),u.setAttribute("stroke-dashoffset",(-(y-f)).toFixed(2))):(u.setAttribute("stroke-dasharray",f.toFixed(2)+" "+(2*y+20).toFixed(2)),u.setAttribute("stroke-dashoffset","0"))}function g(u,y={}){let d=Object.assign({trigger:"hover",color:"currentColor",rays:"#FFF3CF",duration:450,autoDelay:1800},y),v=s("svg",{viewBox:"0 0 "+t.vbw+" "+t.vbh,role:"img","aria-label":"Guoliang Chen, Lucio"});v.style.display="block",v.style.width="100%",v.style.height="auto";let f=s("g",{transform:"translate("+t.pad+" "+t.pad+")",fill:"none",stroke:d.color,"stroke-width":t.stroke,"stroke-linejoin":"miter","stroke-linecap":"butt"});v.appendChild(f);let M=t.letters.map(x=>{let k=s("g",{transform:"translate("+x.x0+" 0)"});f.appendChild(k);let S=Object.assign({g:k,outEls:[],inEls:[]},x);if(x.kind==="fade")S.fadeEl=s("path",{d:x.d}),k.appendChild(S.fadeEl);else{S.fullA=s("path",{d:x.fullA}),k.appendChild(S.fullA),S.fullB=s("path",{d:x.fullB}),k.appendChild(S.fullB),x.shared&&k.appendChild(s("path",{d:x.shared}));for(let E of x.out){let T=s("path",{d:E.d});k.appendChild(T),S.outEls.push([T,E])}for(let E of x.in){let T=s("path",{d:E.d});k.appendChild(T),S.inEls.push([T,E])}}return x.dot&&(S.dotEl=s("rect",{x:x.dot[0],y:x.dot[1],width:x.dot[2],height:x.dot[2],rx:x.dot[2]*.22,fill:d.color,stroke:"none"}),k.appendChild(S.dotEl)),S}),A=s("path",{d:e,fill:d.rays,stroke:"none",opacity:0});f.appendChild(A),u.appendChild(v);function p(x){let k=a(o(x/h)),S=a(o((x-h)/(1-h)));for(let E of M){if(E.kind==="fade")E.fadeEl.setAttribute("opacity",(1-k).toFixed(3)),E.dotEl&&E.dotEl.setAttribute("opacity",(1-k).toFixed(3));else{for(let[T,P]of E.outEls)c(T,P.P,P.j,1-k);for(let[T,P]of E.inEls)c(T,P.P,P.j,k);E.fullA.style.visibility=k<=.001?"visible":"hidden",E.fullB.style.visibility=k>=.999?"visible":"hidden"}E.g.setAttribute("transform","translate("+(E.x0+(E.x1-E.x0)*S).toFixed(2)+" 0)")}A.setAttribute("transform","translate("+(M[0].x0+(M[0].x1-M[0].x0)*S).toFixed(2)+" 0) "+t.raysT),A.setAttribute("opacity",o((x-.8)/.2).toFixed(3))}let L=l(p,d.duration);return p(0),d.trigger==="hover"&&(u.addEventListener("mouseenter",L.play),u.addEventListener("mouseleave",L.reverse),u.addEventListener("focus",L.play),u.addEventListener("blur",L.reverse)),d.trigger==="click"&&u.addEventListener("click",L.toggle),d.trigger==="auto"&&setInterval(L.toggle,d.autoDelay+d.duration),Object.assign(L,{svg:v})}let b={C:[0,.75],L:[.25,.75],U:[.25,1],I:[.75,1],O:[.75,1.75]};function m(u,y,d){let v=y/2,f=d-v,M=v+f,A=f*Math.SQRT1_2,p=x=>x.toFixed(3);return{d:"M"+p(u-M+A)+" "+p(M-A)+"A"+p(f)+" "+p(f)+" 0 0 0 "+p(u-M)+" "+p(v)+"H"+p(M)+"A"+p(f)+" "+p(f)+" 0 0 0 "+p(v)+" "+p(M)+"V"+p(u-M)+"A"+p(f)+" "+p(f)+" 0 0 0 "+p(M)+" "+p(u-v)+"H"+p(u-M)+"A"+p(f)+" "+p(f)+" 0 0 0 "+p(u-v)+" "+p(u-M)+"V"+p(M)+"A"+p(f)+" "+p(f)+" 0 0 0 "+p(u-M+A)+" "+p(M-A)+"Z",P:4*(u-2*M)+2*Math.PI*f}}function w(u,y={}){let d=Object.assign({sequence:"LUCIO",color:"#F3F1EC",track:"#26262D",rays:"#FFF3CF",hold:480,morph:640,size:96,stroke:.17,radius:.22},y),v=120,f=v*d.stroke,M=v*d.radius,A=m(v,f,M),p=s("svg",{viewBox:"0 0 "+v+" "+v,width:d.size,height:d.size,role:"img","aria-label":"Loading"});d.track&&p.appendChild(s("path",{d:A.d,fill:"none",stroke:d.track,"stroke-width":f}));let L=s("path",{d:A.d,fill:"none",stroke:d.color,"stroke-width":f,"stroke-linecap":"butt"}),x=f/22,k=s("path",{d:e,fill:d.rays,transform:"translate("+(f-22*x).toFixed(3)+" "+(v-f-78*x).toFixed(3)+") scale("+x.toFixed(4)+")",opacity:0});p.appendChild(L),p.appendChild(k);let S=(R,D)=>{let C=Math.min(1,Math.max(0,D-R))*A.P;L.setAttribute("stroke-dasharray",C.toFixed(3)+" "+Math.max(0,A.P-C).toFixed(3)),L.setAttribute("stroke-dashoffset",(-R*A.P).toFixed(3))},E=(R,D)=>{let[C,j]=b[D];for(let q=-1;q<6;q++)if(C+q>=R[0]-1e-6&&j+q>=R[1]-1e-6)return[C+q,j+q];return[C,j]},T=d.sequence.split(""),P=0,I=b[T[0]].slice(),Lt,kt,Yt=!1;S(I[0],I[1]),k.setAttribute("opacity",T[0]==="L"?1:0);function Xt(){if(Yt)return;let R=(P+1)%T.length,D=E(I,T[R]),C=I.slice(),j=T[P]==="L",q=T[R]==="L",Bt=()=>{I=D;let Q=Math.floor(I[0]);I[0]-=Q,I[1]-=Q,P=R,S(I[0],I[1]),k.setAttribute("opacity",q?1:0),kt=setTimeout(Xt,d.hold)};if(r()){Bt();return}let Le=performance.now(),_t=Q=>{let H=Math.min(1,(Q-Le)/d.morph),jt=H<.5?4*H*H*H:1-Math.pow(-2*H+2,3)/2;S(C[0]+(D[0]-C[0])*jt,C[1]+(D[1]-C[1])*jt),k.setAttribute("opacity",q?Math.max(0,(H-.6)/.4).toFixed(3):j?Math.max(0,1-H*2.5).toFixed(3):0),H<1?Lt=requestAnimationFrame(_t):Bt()};Lt=requestAnimationFrame(_t)}return kt=setTimeout(Xt,d.hold),u.appendChild(p),{svg:p,stop:()=>{Yt=!0,cancelAnimationFrame(Lt),clearTimeout(kt)}}}n.LucioMorph={wordmark:g,loader:w}})(window);var O={graphite:"#111114",graphite3:"#26262D",paper:"#F3F1EC",beam:"#FFF3CF"};function Et(){return window.LucioMorph??null}function K(n,t){let e=Et();if(!e)return null;let i=document.createElement("span");i.className="wordmark-svg",i.setAttribute("aria-hidden","true"),n.appendChild(i);let s=e.wordmark(i,{trigger:"manual",color:O.paper,rays:O.beam});return s.svg.setAttribute("aria-hidden","true"),s.svg.removeAttribute("role"),t||s.set(1),n.classList.add("has-svg"),s}function Vt(){let n=document.getElementById("chop-template");if(!(n instanceof HTMLTemplateElement))return null;let t=n.content.firstElementChild;return t?t.cloneNode(!0):null}function ke(n){let t=n.seed+"|"+n.level+"|"+n.x+"|"+n.y,e=2166136261;for(let i=0;i>>0;return e}function Ee(n,t){let e=new Array(n);for(let r=0;r{i=i+1831565813|0;let r=Math.imul(i^i>>>15,1|i);return r=r+Math.imul(r^r>>>7,61|r)^r,((r^r>>>14)>>>0)/4294967296};for(let r=n-1;r>0;r--){let o=Math.floor(s()*(r+1)),a=e[r];e[r]=e[o],e[o]=a}return e}function Zt(n,t,e,i,s){n.drawImage(t,0,0);let r=s.cell,o=Math.floor(e/r),a=Math.floor(i/r);if(o<2||a<2)return;let h=o*a,l=Ee(h,ke(s));for(let c=0;c"u"||e==="")return;let i=(navigator.hardwareConcurrency??2)>=4?2:1;for(let s=0;sthis.onReply(a.data,o),r.onerror=()=>this.dropWorker(o),this.workers.push(r)}catch{break}}request(t,e,i,s,r){return s.aborted?Promise.reject(new z):new Promise((o,a)=>{let h=this.byId.get(t);h?i{c.waiters.delete(l)&&(a(new z),c.waiters.size===0&&setTimeout(()=>{c.waiters.size===0&&this.byKey.get(c.key)===c&&this.cancel(c)},0))},{once:!0}),this.pump()})}cancelAll(){for(let t of[...this.byKey.values()]){let e=[...t.waiters];t.waiters.clear();for(let i of e)i.reject(new z);this.cancel(t)}}cancel(t){if(this.forget(t),!t.running){let e=this.queue.indexOf(t);e>=0&&this.queue.splice(e,1);return}t.running=!1,this.running--,t.controller?t.controller.abort():t.worker>=0&&this.workers[t.worker]&&this.workers[t.worker].postMessage({type:"abort",key:t.key}),this.pump()}forget(t){this.byId.get(t.id)===t&&this.byId.delete(t.id),this.byKey.delete(t.key)}pump(){for(;this.running0;){let t=0;for(let i=1;i0&&(!t.scramble||this.workersUnscramble)){let i=e[this.nextWorker++%e.length];t.worker=i,this.workers[i].postMessage({type:"fetch",key:t.key,url:t.url,scramble:t.scramble});return}this.runOnMainThread(t)}runOnMainThread(t){t.worker=-1,t.controller=new AbortController,this.fetchOnMainThread(t,t.controller.signal)}liveWorkers(){let t=[];return this.workers.forEach((e,i)=>{e&&t.push(i)}),t}dropWorker(t){let e=this.workers[t];if(e){e.terminate(),delete this.workers[t];for(let i of this.byKey.values())i.running&&i.worker===t&&this.runOnMainThread(i)}}async fetchOnMainThread(t,e){let i=performance.now();try{let s=await fetch(t.url,{signal:e,credentials:"same-origin"});if(!s.ok)throw new Error("HTTP "+s.status);let r=await s.blob(),o=performance.now()-i,a=await At(r);t.scramble&&(a=await Se(a,t.scramble)),this.onReply({key:t.key,ok:!0,bitmap:a,bytes:r.size,ms:o},-1)}catch(s){this.onReply({key:t.key,ok:!1,bytes:0,ms:0,error:String(s)},-1)}}onReply(t,e){let i=this.byKey.get(t.key);if(!i||!i.running||i.worker!==e){t.bitmap&&N(t.bitmap);return}if(!t.ok&&e>=0&&(t.error==="unsupported-bitmap"||t.error==="unsupported-offscreen")){t.error==="unsupported-bitmap"?this.dropWorker(e):(this.workersUnscramble=!1,this.runOnMainThread(i));return}i.running=!1,this.running--,this.forget(i);let s=[...i.waiters];if(i.waiters.clear(),t.ok&&t.bitmap){let r={bitmap:t.bitmap,bytes:t.bytes,ms:t.ms};for(let o of s)o.resolve(r);s.length===0&&N(t.bitmap)}else{let r=new Error(t.error??"tile failed");for(let o of s)o.reject(r)}this.pump()}};var Gt=1024*1024;function Ae(){let n=navigator.deviceMemory;if(typeof n=="number"&&n<=4)return!0;let t=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,e=Math.min(screen.width,screen.height);return t&&e<=820}function Jt(){return Ae()?120*Gt:250*Gt}var et=class{constructor(t){this.budget=t;this.entries=new Map;this.used=0}get(t){let e=this.entries.get(t);return e&&(this.entries.delete(t),this.entries.set(t,e)),e}has(t){return this.entries.has(t)}put(t,e){let i=this.entries.get(t);if(i){i.bitmap!==e&&N(e);return}let s=e.width*e.height*4;this.entries.set(t,{bitmap:e,bytes:s,at:performance.now()}),this.used+=s,this.trim(this.budget)}trim(t){for(;this.used>t&&this.entries.size>0;){let e=this.entries.keys().next();if(e.done)return;let i=this.entries.get(e.value);this.entries.delete(e.value),i&&(this.used-=i.bytes,N(i.bitmap))}}};var Qt="luphoto.entropy";var Te=Math.cos(Math.PI/6),Pe=100,Ce=10,Tt=class{constructor(){this.path=0;this.turns=0;this.cells=0;this.gestures=0;this.scrolls=0;this.keys=0;this.seen=new Uint32Array(128);this.lastX=0;this.lastY=0;this.hasLast=!1;this.segX=0;this.segY=0;this.prevX=0;this.prevY=0;this.hasPrev=!1;this.touchId=-1;this.touchX=0;this.touchY=0;this.touchMoved=!1;this.lastScroll=-1/0;this.memory=null;this.load();let t={passive:!0,capture:!0};addEventListener("pointermove",e=>this.onMove(e),t),addEventListener("pointerdown",e=>this.onDown(e),t),addEventListener("pointerup",e=>this.onUp(e),t),addEventListener("pointercancel",e=>this.onCancel(e),t),addEventListener("wheel",e=>this.onScroll(e),t),addEventListener("scroll",e=>this.onScroll(e),t),addEventListener("keydown",e=>this.onKey(e),t),addEventListener("pagehide",()=>this.save()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.save()})}onMove(t){if(!t.isTrusted)return;let e=t.clientX,i=t.clientY;if(t.pointerType!=="mouse"){t.pointerId===this.touchId&&!this.touchMoved&&Math.abs(e-this.touchX)+Math.abs(i-this.touchY)>Ce&&(this.touchMoved=!0);return}let s=((e>>3)*73856093^(i>>3)*19349663)&4095,r=1<<(s&31);if(this.seen[s>>>5]&r||(this.seen[s>>>5]|=r,this.cells++),!this.hasLast){this.lastX=e,this.lastY=i,this.hasLast=!0;return}let o=e-this.lastX,a=i-this.lastY;if(this.lastX=e,this.lastY=i,o===0&&a===0)return;this.path+=Math.sqrt(o*o+a*a),this.segX+=o,this.segY+=a;let h=Math.sqrt(this.segX*this.segX+this.segY*this.segY);if(!(h<8)){if(this.hasPrev){let l=Math.sqrt(this.prevX*this.prevX+this.prevY*this.prevY);(this.segX*this.prevX+this.segY*this.prevY)/(h*l)=Pe&&(this.lastScroll=t.timeStamp,this.scrolls++)}onKey(t){t.isTrusted&&!t.repeat&&this.keys++}score(){let e=Math.min(25,this.path/120)+Math.min(35,this.turns*2.5)+Math.min(20,this.cells/6)+Math.min(45,this.gestures*8)+Math.min(15,this.scrolls*1.5)+Math.min(20,this.keys*2);return this.save(),Math.min(100,Math.round(e))}load(){let t=null;try{let i=sessionStorage.getItem(Qt);t=i?JSON.parse(i):null}catch{t=this.memory}if(!t)return;let e=i=>typeof i=="number"&&Number.isFinite(i)&&i>0?i:0;this.path=e(t.p),this.turns=e(t.t),this.cells=e(t.c),this.gestures=e(t.g),this.scrolls=e(t.s),this.keys=e(t.k)}save(){let t={p:Math.round(this.path),t:this.turns,c:this.cells,g:this.gestures,s:this.scrolls,k:this.keys};this.memory=t;try{sessionStorage.setItem(Qt,JSON.stringify(t))}catch{return}}},Pt=null;function Ct(){Pt??(Pt=new Tt)}function it(){return Ct(),Pt?Pt.score():0}var Ie=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Rt=new Int32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function $t(n,t){for(let e=t;e<64;e++){let i=n[e-15],s=n[e-2],r=(i>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,o=(s>>>17|s<<15)^(s>>>19|s<<13)^s>>>10;n[e]=n[e-16]+r+n[e-7]+o|0}}function qt(n,t,e,i){let s=n[0],r=n[1],o=n[2],a=n[3],h=n[4],l=n[5],c=n[6],g=n[7];for(let b=e;b>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&l^~h&c)+Ie[b]+t[b]|0,w=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&r^s&o^r&o)|0;g=c,c=l,l=h,h=a+m|0,a=o,o=r,r=s,s=m+w|0}n[0]=s,n[1]=r,n[2]=o,n[3]=a,n[4]=h,n[5]=l,n[6]=c,n[7]=g}var It=new Int32Array(64),zt=new Int32Array(8),F=new Int32Array(8);function ze(n,t=new Uint8Array(32)){F.set(Rt);let e=n.length,i=Math.ceil((e+9)/64);for(let s=0;s=r+56){let g=l-r-56;c=g<3?0:g===3?e>>>29&255:e*8>>>(7-g)*8&255}a=a<<8|c}It[o]=a}$t(It,16),zt.set(F),qt(zt,It,0,64);for(let o=0;o<8;o++)F[o]=F[o]+zt[o]|0}for(let s=0;s<8;s++)t[s*4]=F[s]>>>24,t[s*4+1]=F[s]>>>16&255,t[s*4+2]=F[s]>>>8&255,t[s*4+3]=F[s]&255;return t}var ot=4294967296,nt=class{constructor(t,e){this.w=new Int32Array(64);this.mid=new Int32Array(8);this.s=new Int32Array(8);let i=this.w;for(let s=0;s<8;s++)i[s]=t.charCodeAt(s*4)<<24|t.charCodeAt(s*4+1)<<16|t.charCodeAt(s*4+2)<<8|t.charCodeAt(s*4+3);i[10]=-2147483648,i[15]=320,this.mid.set(Rt),qt(this.mid,i,0,8),this.shift=32-Math.max(1,Math.min(32,e))}run(t,e,i){let s=this.w,r=this.s,o=this.mid,a=this.shift,h=Rt[0];s[8]=t|0;for(let l=e;l>>a))return l;return-1}},st="luphoto-sealed-1",rt=12;function at(n){let t=new Uint8Array(n.length>>>1);for(let e=0;e>>24,i[45]=o>>>16&255,i[46]=o>>>8&255,i[47]=o&255,ze(i,s);let h=Math.min(32,r.length-a);for(let l=0;l=0&&i<=Re}catch{return!1}}async function Z(n){let t=await fetch("/k",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!t.ok)throw new Y(t.status,Number(t.headers.get("Retry-After"))||0);return await t.json()}function Nt(n){return new Promise(t=>{let e=new nt(n.token,n.bits),i=0,s=0,r=()=>{let o=Math.min(ot,s+He),a=e.run(i,s,o);if(a>=0){t(i*ot+a);return}s=o,s>=ot&&(i++,s=0),setTimeout(r,0)};setTimeout(r,0)})}function De(n,t){return n.token.length!==32||!(n.bits>=1&&n.bits<=32)?Promise.reject(new Error("puzzle")):typeof Worker>"u"||!t?Nt(n):new Promise((e,i)=>{let s;try{s=new Worker(t)}catch{e(Nt(n));return}s.onmessage=r=>{let o=r.data.pow;typeof o=="number"&&(s.terminate(),o<0?i(new Error("puzzle")):e(o))},s.onerror=()=>{s.terminate(),e(Nt(n))},s.postMessage({type:"pow",token:n.token,bits:n.bits})})}var ht=null;function Wt(n,t,e,i){if(ht)return ht.then(()=>null);let s=new Promise(r=>{let o=()=>{},a=new Promise(c=>{o=c}),h=new Ut(()=>{o(),h.wait()},i?()=>r(null):null);(async()=>{let c=await n;for(;c.challenge;){let g=c.challenge,b=De(g,e);await a,c=await t({token:g.token,nonce:await b})}return c})().then(c=>{h.dismiss(),r(c)},()=>{h.fail(),r(null)})});return ht=s,s.then(()=>{ht=null}),s}function dt(n,t,e){n.addEventListener("click",i=>{let s=t();if(i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||!s)return;if(e.score()>=e.minEntropy()||lt()){ie(s);return}i.preventDefault();let r=n.href,o=()=>({build:e.build,album:s,photos:[],context:"nav",entropy:e.score()});Wt(Z(o()),a=>Z({...o(),challenge:a}),e.workerUrl,!0).then(a=>{a&&(a.pass&&ct(a.pass),ie(s),location.assign(r))})})}function Ke(n,t){try{n.setPointerCapture(t)}catch{return}}var Ut=class{constructor(t,e){this.onHeld=t;this.onCancel=e;this.inert=[];this.start=0;this.frame=0;this.holding=!1;this.finished=!1;this.gone=!1;this.onEscape=t=>{t.key==="Escape"&&!this.gone&&(t.preventDefault(),t.stopPropagation(),this.dismiss(),this.onCancel?.())};this.restore=document.activeElement;let i=document.createElement("div");i.className="gate",i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-labelledby","gate-line");let s=document.createElement("div");s.className="gate-card";let r=document.createElement("p");r.className="gate-eyebrow",r.textContent="Photos \xB7 Lucio";let o=document.createElement("p");o.className="gate-line",o.id="gate-line",o.textContent=Ne;let a=document.createElement("button");a.type="button",a.className="gate-hold",a.setAttribute("aria-label","Hold to see the photos"),a.setAttribute("aria-describedby","gate-status");let h=document.createElementNS(ee,"svg");h.setAttribute("viewBox","0 0 64 64"),h.setAttribute("aria-hidden","true"),h.setAttribute("focusable","false");let l=(b,m)=>{let w=document.createElementNS(ee,"circle");return w.setAttribute("class",b),w.setAttribute("cx","32"),w.setAttribute("cy","32"),w.setAttribute("r",m),w},c=l("gate-ring","28");c.setAttribute("pathLength","100"),h.append(l("gate-track","28"),c,l("gate-dot","6")),a.appendChild(h);let g=document.createElement("p");g.className="visually-hidden",g.id="gate-status",g.setAttribute("aria-live","polite"),s.append(r,o,a,g),i.appendChild(s),this.root=i,this.button=a,this.ring=c,this.status=g,this.text=o;for(let b of Array.from(document.body.children))b.hasAttribute("inert")||(b.setAttribute("inert",""),this.inert.push(b));document.body.appendChild(i),document.documentElement.classList.add("has-gate"),this.bind(),a.focus({preventScroll:!0})}bind(){let t=this.button;t.addEventListener("pointerdown",e=>{e.pointerType==="mouse"&&e.button!==0||(e.preventDefault(),Ke(t,e.pointerId),this.press())});for(let e of["pointerup","pointercancel","lostpointercapture"])t.addEventListener(e,()=>this.release());t.addEventListener("keydown",e=>{(e.key===" "||e.key==="Enter")&&(e.preventDefault(),e.repeat||this.press())}),t.addEventListener("keyup",e=>{(e.key===" "||e.key==="Enter")&&(e.preventDefault(),this.release())}),t.addEventListener("blur",()=>this.release()),t.addEventListener("click",e=>e.preventDefault()),t.addEventListener("contextmenu",e=>e.preventDefault()),this.root.addEventListener("transitionend",e=>{e.target===this.root&&this.root.classList.contains("is-leaving")&&this.root.remove()}),this.onCancel&&document.addEventListener("keydown",this.onEscape,!0)}setProgress(t){this.ring.style.setProperty("stroke-dashoffset",String(100-Math.max(0,Math.min(1,t))*100))}press(){if(this.holding||this.finished)return;this.holding=!0,this.start=performance.now(),this.button.classList.add("is-pressed"),this.status.textContent="Keep holding";let t=e=>{if(!this.holding)return;let i=(e-this.start)/qe;if(this.setProgress(i),i>=1){this.holding=!1,this.finished=!0,this.frame=0,this.button.classList.remove("is-pressed"),this.onHeld();return}this.frame=requestAnimationFrame(t)};this.frame=requestAnimationFrame(t)}release(){this.holding&&(this.holding=!1,cancelAnimationFrame(this.frame),this.frame=0,this.button.classList.remove("is-pressed"),this.setProgress(0),this.status.textContent="")}wait(){this.root.classList.add("is-waiting"),this.setProgress(.28),this.status.textContent="One moment"}fail(){this.root.classList.remove("is-waiting"),this.finished=!0,this.setProgress(0),this.button.disabled=!0,this.text.textContent="Something went wrong. Reload the page to try again.",this.status.textContent=this.text.textContent}dismiss(){if(this.gone)return;this.gone=!0,document.removeEventListener("keydown",this.onEscape,!0),cancelAnimationFrame(this.frame);let t=this.root.contains(document.activeElement);for(let e of this.inert)e.removeAttribute("inert");document.documentElement.classList.remove("has-gate"),this.root.classList.add("is-leaving"),window.setTimeout(()=>this.root.remove(),400),t&&(this.restore instanceof HTMLElement&&this.restore!==document.body&&this.restore.isConnected?this.restore:document.querySelector("main"))?.focus({preventScroll:!0})}};var Ue=400,X=class{constructor(t,e=()=>!0){this.canShow=e;this.handle=null;this.loader=null;this.timer=0;this.hideTimer=0;this.visible=!1;this.element=document.createElement("div"),this.element.className="busy",this.element.setAttribute("role","status"),this.element.setAttribute("aria-label","Loading"),t.appendChild(this.element)}watch(t){if(t===this.loader){this.update(t);return}this.loader=t,clearTimeout(this.timer),this.timer=0,this.hide(),this.update(t)}update(t){if(!t||t!==this.loader)return;let e=t.status;if(!e.active||e.sharp){clearTimeout(this.timer),this.timer=0,this.hide();return}if(!this.visible&&this.timer===0){let i=Math.max(0,Ue-(performance.now()-e.started));this.timer=window.setTimeout(()=>this.check(),i)}}check(){this.timer=0;let t=this.loader;if(!(!t||!t.status.active||t.status.sharp)){if(!this.canShow()){this.timer=window.setTimeout(()=>this.check(),100);return}this.show()}}show(){if(!this.visible){if(clearTimeout(this.hideTimer),this.visible=!0,!this.handle){let t=Et();t&&(this.handle=t.loader(this.element,{size:56,color:O.paper,track:O.graphite3,rays:O.beam}),this.handle.svg.setAttribute("aria-hidden","true"))}this.element.classList.add("is-visible")}}hide(){this.visible&&(this.visible=!1,this.element.classList.remove("is-visible"),clearTimeout(this.hideTimer),this.hideTimer=window.setTimeout(()=>{!this.visible&&this.handle&&(this.handle.stop(),this.handle.svg.remove(),this.handle=null)},300))}},ut=class{constructor(t){this.loader=null;this.shown=!1;this.value=-1;this.element=document.createElement("div"),this.element.className="progress",this.element.setAttribute("aria-hidden","true"),t.appendChild(this.element)}watch(t){this.loader=t,this.value=-1,this.update(t)}update(t){if(!t||t!==this.loader)return;let e=t.status,i=e.active&&!e.sharp&&e.planned>0,s=e.planned>0?Math.min(1,e.done/e.planned):0;i!==this.shown&&(this.shown=i,this.element.classList.toggle("is-visible",i));let r=Math.round(s*1e3)/1e3;r!==this.value&&(this.value=r,this.element.style.transform="scaleX("+(i?r:1)+")")}};function pt(n,t,e){let i=t*e;for(let s=0;s=i)return s;return n.levels.length-1}function G(n,t){let e=n.tile_size,i=Math.max(0,t.u0*n.width),s=Math.min(n.width,t.u1*n.width),r=Math.max(0,t.v0*n.height),o=Math.min(n.height,t.v1*n.height);return s<=i||o<=r?null:{x0:Math.min(n.cols-1,Math.floor(i/e)),x1:Math.min(n.cols-1,Math.ceil(s/e)-1),y0:Math.min(n.rows-1,Math.floor(r/e)),y1:Math.min(n.rows-1,Math.ceil(o/e)-1)}}function re(n,t,e){let i=n.levels[t],s=i.tile_size,r=G(i,e);if(!r)return[];let o=(e.u0+e.u1)/2*i.width,a=(e.v0+e.v1)/2*i.height,h=[];for(let l=r.y0;l<=r.y1;l++)for(let c=r.x0;c<=r.x1;c++){let g=(c*s+Math.min((c+1)*s,i.width))/2,b=(l*s+Math.min((l+1)*s,i.height))/2;h.push({level:t,x:c,y:l,index:l*i.cols+c,distance:(g-o)**2+(b-a)**2})}return h.sort((l,c)=>l.distance-c.distance),h.map(({level:l,x:c,y:g,index:b})=>({level:l,x:c,y:g,index:b}))}function ne(n,t,e,i,s,r){let o=n.tile_size,a=Math.round(i+t*o*r),h=Math.round(i+Math.min((t+1)*o,n.width)*r),l=Math.round(s+e*o*r),c=Math.round(s+Math.min((e+1)*o,n.height)*r);return h<=a||c<=l?null:{dx:a,dy:l,dw:h-a,dh:c-l}}function oe(n,t,e,i,s,r,o,a){let h=e.tile_size,l=e.overlap??0,c=i*h,g=Math.min((i+1)*h,e.width),b=s*h,m=Math.min((s+1)*h,e.height),w=i>0?c-l:0,u=s>0?b-l:0,y=Math.round(r+c*a),d=Math.round(r+g*a),v=Math.round(o+b*a),f=Math.round(o+m*a);if(d<=y||f<=v)return;let M=Math.max(w,(y-r)/a),A=Math.min(w+t.width,(d-r)/a),p=Math.max(u,(v-o)/a),L=Math.min(u+t.height,(f-o)/a);A<=M||L<=p||n.drawImage(t,M-w,p-u,A-M,L-p,y,v,d-y,f-v)}var ae="luphoto.throughput";function he(){try{let n=Number(sessionStorage.getItem(ae));return Number.isFinite(n)&&n>0?n:null}catch{return null}}function le(){return he()??1e3}function ce(n){let t=he(),e=t===null?n:t*(1-.5)+n*.5;try{sessionStorage.setItem(ae,String(e))}catch{return e}return e}var U=180,de=400,We=2e3,W=16,Ot="j:";function Oe(n,t){return new Promise((e,i)=>{if(t.aborted){i(new z);return}let s=setTimeout(()=>{t.removeEventListener("abort",r),e()},n),r=()=>{clearTimeout(s),i(new z)};t.addEventListener("abort",r,{once:!0})})}function Ye(n,t,e){return t.aborted?Promise.resolve(e):new Promise(i=>{let s=()=>i(e);t.addEventListener("abort",s,{once:!0}),n.then(r=>{t.removeEventListener("abort",s),i(r)})})}var ue=3,mt=4,B=class{constructor(t,e,i){this.pyramid=t;this.poolUrl=e;this.env=i;this.seedImage=null;this.seedPromise=null;this.seedAt=0;this.pool=null;this.sealed="";this.poolPromise=null;this.poolRetryAt=0;this.opened=null;this.ids=null;this.triedKey=null;this.jumbleLevel=-1;this.jumble=[];this.settling=!1;this.session=null;this.prefetchController=null;this.finalLevel=-1;this.targetLevel=-1;this.status={active:!1,started:0,planned:0,done:0,sharp:!1}}get stalled(){return!this.opened&&!this.settling}tileUrl(t){let e=this.env.tiles;return e.path+this.pyramid.hash+"/"+t+"."+e.format}ensurePool(){return this.pool?Promise.resolve(!0):(this.poolPromise||(this.poolPromise=fetch(this.poolUrl,{credentials:"same-origin"}).then(t=>t.ok?t.json():Promise.reject(new Error("pool"))).then(t=>{let e=this.pyramid.levels;if(!Array.isArray(t.levels)||t.levels.length!==e.length||typeof t.sealed!="string")throw new Error("pool");for(let i=0;i(this.poolPromise=null,this.poolRetryAt=performance.now()+We,!1))),this.poolPromise)}open(){if(this.opened)return!0;let t=this.env.keys.key(this.pyramid.hash),e=this.pool;if(!t||!e||t===this.triedKey)return!1;this.triedKey=t;let i=te(t,this.sealed),s=null;if(i)try{s=JSON.parse(new TextDecoder().decode(i))}catch{s=null}let r=this.pyramid.levels;if(!s||!Array.isArray(s.levels)||s.levels.length!==r.length)return!1;let o=[];for(let a=0;a=0&&b=this.poolRetryAt&&this.ensurePool();return}this.opened||this.open()}ensureSeed(){return this.opened?(this.seedPromise||(this.seedPromise=this.decodeSeed().then(()=>{this.seedAt=performance.now(),this.env.requestDraw()},()=>{})),this.seedPromise):Promise.resolve()}async decodeSeed(){let t=this.opened?.seed;if(!t)return;let e=await At(new Blob([Ht(t)],{type:"image/"+this.env.tiles.format})),i=document.createElement("canvas");i.width=e.width*mt,i.height=e.height*mt;let s=i.getContext("2d");if(!s){this.seedImage=e;return}s.imageSmoothingEnabled=!0,s.imageSmoothingQuality="high","filter"in s&&(s.filter="blur("+mt*.75+"px)");let r=mt*2;s.drawImage(e,-r,-r,i.width+r*2,i.height+r*2),N(e),this.seedImage=i}async request(t,e,i,s,r){let o=this.tileUrl(e),a;try{a=await this.env.scheduler.request(t,o,i,s,r)}catch(h){if(s.aborted||h instanceof z)throw h;await Oe(de+Math.random()*de,s),a=await this.env.scheduler.request(t,o,i,s,r)}return this.env.cache.put(t,a.bitmap),this.env.requestDraw(),a}fetchTile(t,e,i){let s=this.ids,r=this.opened;if(!s||!r)return Promise.reject(new z);let o=s[t.level][t.index],a=this.env.tiles,h=a.cell??64,l=a.scrambled&&r.scramble&&this.pyramid.levels[t.level].tile_size>=2*h?{seed:r.scramble,level:t.level,x:t.x,y:t.y,cell:h}:void 0;return this.request(o,o,e,i,l)}fetchJumble(t,e,i){return this.request(Ot+t,t,e,i)}uncached(t,e){let i=this.ids;return i?re(this.pyramid,t,e).filter(s=>!this.env.cache.has(i[t][s.index])):[]}uncachedBytes(t,e){let i=this.opened?.levels[t].bytes??[],s=0;for(let r of this.uncached(t,e))s+=i[r.index]??0;return s}chooseJumble(t,e){let i=this.pool;if(!i)return[];if(this.jumbleLevel<0){let s=this.probeLevel(t,e),r=this.pyramid.levels[s].cols*this.pyramid.levels[s].rows,o=i[s].length/W,a=new Array(r);for(let h=0;h!this.env.cache.has(Ot+s))}probeLevel(t,e){return Math.max(0,pt(this.pyramid,t.displayWidth,e)-ue)}notify(){this.env.onStatus?.(this)}track(t,e){return this.status.planned+=t.length,this.notify(),Promise.allSettled(t.map(i=>i().finally(()=>{this.session===e&&(this.status.done++,this.notify())})))}start(t,e,i){this.stopSession();let s=new AbortController;this.session=s,this.targetLevel=-1,this.status.active=!0,this.status.started=performance.now(),this.status.planned=0,this.status.done=0,this.status.sharp=!1,this.notify(),this.run(t,e,s).then(()=>{this.session===s&&(this.session=null,this.status.active=!1,this.notify()),(!s.signal.aborted||s.signal.reason==="deadline")&&i()})}async run(t,e,i){let s=i.signal,r=performance.now(),o=this.env.settings.budgetMs,a=setTimeout(()=>i.abort("deadline"),o);try{let h=await Ye(this.ensurePool(),s,!1);if(s.aborted||h&&!this.open()&&(this.settling=!0,await this.env.keys.settle(this.pyramid.hash,s),this.settling=!1,s.aborted))return;if(!h||!this.open()){let y=this.chooseJumble(t,e);await this.track(y.map(d=>()=>this.fetchJumble(d,tt,s)),i);return}if(await this.ensureSeed(),s.aborted)return;let l=pt(this.pyramid,t.displayWidth,e),c=Math.max(0,l-ue),g=this.uncached(c,t).slice(0,2);if(g.length>0){let y=await this.track(g.map(f=>()=>this.fetchTile(f,tt,s)),i),d=0,v=0;for(let f of y)f.status==="fulfilled"&&(d+=f.value.bytes,v=Math.max(v,f.value.ms));d>0&&v>0&&ce(d/v)}if(s.aborted)return;this.finalLevel=Math.max(this.finalLevel,c);let b=le(),m=o-(performance.now()-r),w=c;for(let y=l;y>c;y--)if(this.uncachedBytes(y,t)/b<=m*.8){w=y;break}let u=[];w-c>=2&&u.push(Math.floor((c+w)/2)),w>c&&u.push(w),this.finalLevel=w,this.targetLevel=w,this.env.requestDraw();for(let y of u)if(await this.track(this.uncached(y,t).map(d=>()=>this.fetchTile(d,tt,s)),i),s.aborted)return}finally{clearTimeout(a)}}prefetchProbe(t,e){let s=this.resetPrefetch().signal;this.ensurePool().then(async r=>{if(!(s.aborted||!r||!this.open())&&(await this.ensureSeed(),!s.aborted))for(let o of this.uncached(this.probeLevel(t,e),t))this.fetchTile(o,St,s).catch(()=>{})})}prefetchLevel(t,e){if(e<0||!this.opened)return;let i=this.resetPrefetch().signal;for(let s of this.uncached(e,t))this.fetchTile(s,St,i).catch(()=>{})}resetPrefetch(){return this.prefetchController?.abort(),this.prefetchController=new AbortController,this.prefetchController}stopPrefetch(){this.prefetchController?.abort(),this.prefetchController=null}stopSession(){this.session&&(this.session.abort("superseded"),this.session=null,this.status.active=!1,this.notify())}stop(){this.stopSession(),this.stopPrefetch()}drawJumble(t,e){if(this.jumbleLevel<0)return!1;let{g:i,originX:s,originY:r,width:o,now:a}=t,h=this.pyramid.levels[this.jumbleLevel],l=G(h,e);if(!l)return!1;let c=o/h.width,g=this.env.cache,b=!1;i.imageSmoothingEnabled=!0,i.imageSmoothingQuality="medium";for(let m=l.y0;m<=l.y1;m++)for(let w=l.x0;w<=l.x1;w++){let u=g.get(Ot+this.jumble[m*h.cols+w]),y=u?ne(h,w,m,s,r,c):null;if(!u||!y)continue;let d=a-u.at;d=0&&v<0;p--){let L=G(u[p],m);if(!L)continue;let x=!0;for(let k=L.y0;k<=L.y1&&x;k++)for(let S=L.x0;S<=L.x1;S++){let E=w.get(y[p][k*u[p].cols+S]);if(!E||t.now-E.at=0&&p=0?Math.min(this.targetLevel,d):d,A=y!==null&&v>=M;if(A!==this.status.sharp&&(this.status.sharp=A,queueMicrotask(()=>this.notify())),!y)return f;for(let p=Math.max(0,v);p<=d;p++){let L=u[p],x=G(L,m);if(!x)continue;let k=r/L.width;e.imageSmoothingEnabled=!0,e.imageSmoothingQuality=k<1?"high":"medium";for(let S=x.y0;S<=x.y1;S++)for(let E=x.x0;E<=x.x1;E++){let T=w.get(y[p][S*L.cols+E]);if(!T)continue;let P=t.now-T.at;Pthis.requestDraw(),onStatus:()=>this.onStatus(this)})}get isOpen(){return this.expanded}get isNear(){return this.near}layout(t){let e=this.cover,i=Math.max(t.width/e.width,t.open/e.height),s=e.width*i,r=e.height*i,o=(t.open-r)/2,a=o+this.focusY*r,h=Math.max(0,Math.min(t.open-t.closed,a-t.closed/2)),l=this.geometry;this.geometry={width:t.width,closed:t.closed,open:t.open,dpr:t.dpr,coverWidth:s,coverHeight:r,x:(t.width-s)/2,y:o,band:h},this.canvas&&(this.sizeCanvas(this.canvasOpen),this.drawNow()),this.near&&l&&(l.width!==t.width||l.closed!==t.closed||l.open!==t.open||l.dpr!==t.dpr)&&this.startSession()}attach(){if(this.canvas)return;let t=document.createElement("canvas");t.className="strip-canvas",t.setAttribute("aria-hidden","true");let e=t.getContext("2d",{alpha:!1});e&&(this.canvas=t,this.g=e,this.element.prepend(t),this.sizeCanvas(this.expanded),this.drawNow())}detach(){this.canvas&&(cancelAnimationFrame(this.frame),this.frame=0,this.canvas.width=0,this.canvas.height=0,this.canvas.remove(),this.canvas=null,this.g=null)}setNear(t){t!==this.near&&(this.near=t,t?this.startSession():this.loader.stop())}setOpen(t){if(t===this.expanded)return;this.expanded=t,this.element.classList.toggle("is-open",t),clearTimeout(this.settleTimer);let e=this.geometry,i=this.canvas;t?i&&this.canvasOpen?(i.style.transition="",i.style.transform="translate3d(0,0,0)"):i&&e&&(this.sizeCanvas(!0),i.style.transition="none",i.style.transform="translate3d(0,"+-e.band+"px,0)",this.drawNow(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.expanded&&this.canvas===i&&(i.style.transition="",i.style.transform="translate3d(0,0,0)")})})):i&&e&&(i.style.transition="",i.style.transform="translate3d(0,"+-e.band+"px,0)",this.settleTimer=window.setTimeout(()=>{!this.expanded&&this.canvas===i&&(this.sizeCanvas(!1),this.drawNow())},Xe)),this.near&&this.startSession()}sizeCanvas(t){let e=this.canvas,i=this.geometry;if(!e||!i)return;this.canvasOpen=t;let s=t?i.open:i.closed,r=Math.max(1,Math.round(i.width*i.dpr)),o=Math.max(1,Math.round(s*i.dpr));(e.width!==r||e.height!==o)&&(e.width=r,e.height=o),e.style.height=s+"px",t||(e.style.transition="none",e.style.transform="translate3d(0,0,0)")}view(){let t=this.geometry;if(!t)return null;let e=this.expanded?0:t.band,i=this.expanded?t.open:t.closed;return{displayWidth:t.coverWidth,u0:Math.max(0,-t.x/t.coverWidth),u1:Math.min(1,(t.width-t.x)/t.coverWidth),v0:Math.max(0,(e-t.y)/t.coverHeight),v1:Math.min(1,(e+i-t.y)/t.coverHeight)}}startSession(){let t=this.view();!t||!this.geometry||this.loader.start(t,this.geometry.dpr,()=>{})}requestDraw(){this.frame===0&&this.canvas&&(this.frame=requestAnimationFrame(t=>{this.frame=0,this.draw(t)&&this.requestDraw()}))}drawNow(){this.draw(performance.now())&&this.requestDraw()}draw(t){let e=this.g,i=this.canvas,s=this.geometry;if(!e||!i||!s)return!1;e.setTransform(1,0,0,1,0,0),e.globalAlpha=1,e.fillStyle="#111114",e.fillRect(0,0,i.width,i.height);let r=this.canvasOpen?0:-s.band;return this.loader.draw({g:e,originX:s.x*s.dpr,originY:(s.y+r)*s.dpr,width:s.coverWidth*s.dpr,height:s.coverHeight*s.dpr,canvasWidth:i.width,canvasHeight:i.height,displayWidth:s.coverWidth,dpr:s.dpr,now:t})}};function pe(n){let t=n.dataset,e=(i,s)=>{let r=Number(i);return Number.isFinite(r)&&r>0?r:s};return{page:t.page??"",build:t.build??"",slug:t.album??"",manifestUrl:t.manifest??"",indexUrl:t.index??"",workerUrl:t.worker??"",budgetMs:e(t.budgetMs,3e3),maxDpr:e(t.maxDpr,2),concurrency:Math.max(1,Math.round(e(t.concurrency,6))),blockContextMenu:t.blockContextMenu!=="false",gate:t.gate==="off"?"off":"server",minEntropy:t.minEntropy&&Number.isFinite(Number(t.minEntropy))?Number(t.minEntropy):20}}function J(n,t,e){return"/a/"+encodeURIComponent(t)+"/p/"+e+"."+n+".json"}var Be=24,ft=class{constructor(t,e,i,s){this.root=t;this.settings=i;this.env=s;this.strips=[];this.onScreen=new Set;this.inView=new Set;this.suspended=!1;this.wordmark=null;this.opened=null;this.scrollFrame=0;this.sizeKey="";let r=Array.from(t.querySelectorAll("a.strip")),o=new Map(e.albums.map(h=>[h.slug,h]));for(let h of r){let l=o.get(h.dataset.slug??"");!l||!l.cover||this.strips.push(new _(h,l.cover,l.collapsed_focus_y??.5,J(e.build,l.slug,l.cover.hash),s,c=>this.onStripStatus(c)))}this.hoverMode=matchMedia("(hover: hover) and (pointer: fine)");let a=document.querySelector(".site-header .wordmark");if(this.indicator=new X(document.body,()=>!this.wordmarkMoving()),a){this.wordmark=K(a,!0);let h=()=>{this.wordmark&&!this.indicator.visible&&this.wordmark.play()},l=()=>this.wordmark?.reverse();a.addEventListener("mouseenter",h),a.addEventListener("mouseleave",l),a.addEventListener("focus",h),a.addEventListener("blur",l)}document.documentElement.classList.add("has-strips"),this.measure(),this.observe(),this.bind()}suspend(t){if(!this.suspended){this.suspended=!0;for(let e of this.strips)e.loader.stop(),t&&e.detach();this.env.scheduler.cancelAll(),this.env.cache.trim(t?0:this.env.cache.budget/4)}}resume(){if(this.suspended){this.suspended=!1;for(let t of this.strips)this.inView.has(t)&&t.attach(),t.isNear&&t.startSession()}}wordmarkMoving(){let t=this.wordmark?.t??0;return t>0&&t<1}measure(){let t=this.root.clientWidth||window.innerWidth,e=window.innerHeight,i=Math.round(Math.min(t*6/32,e*.28)),s=Math.round(Math.min(t*9/32,e*.62)),r=Math.min(window.devicePixelRatio||1,this.settings.maxDpr),o=t+"x"+i+"x"+s+"@"+r;if(o!==this.sizeKey){this.sizeKey=o,this.root.style.setProperty("--strip-closed",i+"px"),this.root.style.setProperty("--strip-open",s+"px");for(let a of this.strips)a.layout({width:t,closed:i,open:s,dpr:r})}}observe(){let t=new Map(this.strips.map(r=>[r.element,r])),e=new IntersectionObserver(r=>{for(let o of r)t.get(o.target)?.setNear(o.isIntersecting)},{rootMargin:"100% 0px"}),i=new IntersectionObserver(r=>{for(let o of r){let a=t.get(o.target);a&&(o.isIntersecting?(this.inView.add(a),this.suspended||a.attach()):(this.inView.delete(a),a.detach()))}},{rootMargin:"25% 0px"}),s=new IntersectionObserver(r=>{for(let o of r){let a=t.get(o.target);a&&(o.isIntersecting?this.onScreen.add(a):this.onScreen.delete(a))}this.watchFirst(),this.scheduleCentre()});for(let r of this.strips)e.observe(r.element),i.observe(r.element),s.observe(r.element)}watchFirst(){let t=this.strips.find(e=>this.onScreen.has(e))??null;this.indicator.watch(t?t.loader:null)}onStripStatus(t){this.indicator.update(t.loader)}bind(){for(let t of this.strips){let e=t.element;e.addEventListener("mouseenter",()=>{this.hoverMode.matches&&this.open(t)}),e.addEventListener("mouseleave",()=>{this.hoverMode.matches&&this.opened===t&&this.open(null)}),e.addEventListener("focus",()=>this.open(t)),e.addEventListener("blur",()=>{this.opened===t&&!this.hoverMode.matches?this.scheduleCentre():this.opened===t&&this.open(null)}),e.addEventListener("dragstart",i=>i.preventDefault()),this.settings.blockContextMenu&&e.addEventListener("contextmenu",i=>i.preventDefault())}window.addEventListener("scroll",()=>this.scheduleCentre(),{passive:!0}),new ResizeObserver(()=>{this.measure(),this.scheduleCentre()}).observe(this.root)}open(t){t!==this.opened&&(this.opened?.setOpen(!1),this.opened=t,t?.setOpen(!0))}scheduleCentre(){this.hoverMode.matches||this.scrollFrame!==0||(this.scrollFrame=requestAnimationFrame(()=>{this.scrollFrame=0,this.pickCentre()}))}pickCentre(){if(this.hoverMode.matches)return;let t=window.innerHeight/2,e=null,i=1/0,s=1/0;for(let r of this.onScreen){let o=r.element.getBoundingClientRect(),a=Math.abs(o.top+o.height/2-t);at,settle:()=>Promise.resolve()}}var _e=8,je=400,Ve=2e3,me=/^[0-9a-f]{64}$/,vt=class{constructor(t,e,i,s){this.gate=t;this.slug=e;this.context=i;this.workerUrl=s;this.keys=new Map;this.inflight=new Set;this.waiters=new Set;this.listeners=[];this.queue=[];this.busy=!1;this.blocked=!1;this.failed=!1;this.pausedUntil=0;this.page="";if(this.server=t.mode!=="off",!this.server)for(let[r,o]of Object.entries(t.keys??{}))me.test(o)&&this.keys.set(r,at(o))}onKeys(t){this.listeners.push(t)}key(t){return this.keys.get(t)??null}has(t){return this.keys.has(t)}want(t,e){if(!this.server||t.every(s=>this.keys.has(s)||this.inflight.has(s)))return;let i=s=>!this.keys.has(s)&&!this.inflight.has(s);this.queue=Array.from(new Set(t.concat(e))).filter(i),this.pump()}settle(t,e){return new Promise(i=>{if(this.keys.has(t)||this.blocked||this.failed||e.aborted){i();return}let s=()=>{clearTimeout(o),this.waiters.delete(r),e.removeEventListener("abort",s),i()},r=()=>{(this.keys.has(t)||this.blocked||this.failed)&&s()},o=window.setTimeout(s,je);this.waiters.add(r),e.addEventListener("abort",s,{once:!0})})}wake(){for(let t of Array.from(this.waiters))t()}body(t,e){let i={build:this.gate.build,album:this.slug,photos:t,context:this.context,entropy:it()};return e&&(i.pass=e),this.page&&(i.page=this.page),i}pump(){if(this.busy||this.blocked||this.failed||this.queue.length===0||performance.now(){this.queue=Array.from(new Set(e.concat(this.queue))).filter(i=>!this.keys.has(i)&&!this.inflight.has(i)),this.pump()},t)}async send(t){this.busy=!0;for(let s of t)this.inflight.add(s);let e=[],i=0;try{let s=lt(),r=await Z(this.body(t,s));if(this.absorb(r,s),r.challenge){this.blocked=!0,this.wake();let o=await Wt(Promise.resolve(r),a=>Z({...this.body(t,""),challenge:a}),this.workerUrl,!1);this.blocked=!1,o?this.absorb(o,""):this.failed=!0}}catch(s){s instanceof Y&&s.status===429?(i=Math.max(1,s.retryAfter)*1e3,e=t):s instanceof Y&&s.status>=400&&s.status<500?this.failed=!0:(i=Ve,e=t)}finally{for(let s of t)this.inflight.delete(s);this.busy=!1,this.wake()}i>0?this.pause(i,e.filter(s=>!this.keys.has(s))):this.pump()}absorb(t,e){t.stale&&e&<()===e&&ct(null),t.pass&&ct(t.pass),t.page&&(this.page=t.page);let i=[];for(let[s,r]of Object.entries(t.keys??{}))me.test(r)&&!this.keys.has(s)&&(this.keys.set(s,at(r)),i.push(s));if(i.length>0){this.wake();for(let s of this.listeners)s(i)}}};var Ze=/[㐀-鿿豈-﫿]/;function bt(n,t){Ze.test(t)?n.lang="zh":n.removeAttribute("lang")}function fe(n){return n<10?"0"+n:String(n)}function Ge(n){let t=(n.model??"").trim(),e=(n.make??"").trim(),i=e.split(/\s+/)[0]??"";i&&t.toLowerCase().startsWith(i.toLowerCase()+" ")&&(t=t.slice(i.length+1).trim());let s=/^([A-Za-z]{1,3}) (\d+[A-Za-z0-9]*)$/.exec(t);return s&&(t=s[1]+s[2]),t||e}function Je(n){let t=/(\d+(?:\.\d+)?(?:-\d+(?:\.\d+)?)?)\s*mm\s*(?:F|f\/?)\s*([\d.]+(?:-[\d.]+)?)/.exec(n);return t?t[1]+" f/"+t[2]:n.trim()}function yt(n){return String(Math.round(n*10)/10)}function Qe(n){let t=n.trim();if(t.includes("/")||t.endsWith("s"))return t;let e=Number(t);if(!Number.isFinite(e)||e<=0)return t;if(e>=1)return yt(e)+"s";let i=1/e;return i<10&&Math.abs(i-Math.round(i))>.05?"1/"+yt(i):"1/"+Math.round(i)}function $e(n,t,e,i){let s=[fe(n+1)+" / "+fe(t)],r=e.exif;if(i&&r){let o=Ge(r);o&&s.push(o),r.lens&&s.push(Je(r.lens)),r.focal_length&&s.push(yt(r.focal_length)+"mm"),r.f_number&&s.push("f/"+yt(r.f_number)),r.exposure&&s.push(Qe(r.exposure)),r.iso&&s.push("ISO "+r.iso)}return s.join(" \xB7 ")}function ti(n,t){n.textContent="",t.split(/\r?\n/).forEach((e,i)=>{i>0&&n.appendChild(document.createElement("br"));let s=e.split("*"),r=(s.length-1)%2===0;s.forEach((o,a)=>{let h=a%2===1;if(h&&(r||a!==s.length-1)){let l=document.createElement("em");l.textContent=o,n.appendChild(l)}else n.appendChild(document.createTextNode((h?"*":"")+o))})})}var wt=class{constructor(t){this.visible=!1;this.placement="";this.element=document.createElement("section"),this.element.className="caption",this.element.setAttribute("aria-label","Caption"),this.meta=document.createElement("p"),this.meta.className="caption-meta",this.title=document.createElement("h2"),this.title.className="caption-title",this.text=document.createElement("p"),this.text.className="caption-text",this.element.append(this.meta,this.title,this.text),t.appendChild(this.element)}set(t,e,i,s){this.meta.textContent=$e(e,i,t,s),this.title.textContent=t.title??"",this.title.hidden=!t.title,bt(this.title,t.title??""),ti(this.text,t.caption??""),this.text.hidden=!t.caption,bt(this.text,t.caption??"")}show(t){t!==this.visible&&(this.visible=t,this.element.classList.toggle("is-visible",t))}place(t,e,i){let s=Math.round(t)+","+Math.round(e)+","+Math.round(i);if(s===this.placement)return;this.placement=s;let r=this.element.style;r.width=Math.round(e)+"px",r.transform="translate3d("+Math.round(t)+"px,"+-Math.round(i)+"px,0)"}};var xt=24,ve=10,ei=300,ii=.35,ge=.35,si=.2,ri=2500,ni=120,oi=16,ai=.002,hi=.01;function li(n,t,e,i){let s=3*n,r=3*(e-n)-s,o=1-s-r,a=3*t,h=3*(i-t)-a,l=1-a-h,c=m=>((o*m+r)*m+s)*m,g=m=>((l*m+h)*m+a)*m,b=m=>(3*o*m+2*r)*m+s;return m=>{if(m<=0)return 0;if(m>=1)return 1;let w=m;for(let d=0;d<8;d++){let v=c(w)-m,f=b(w);if(Math.abs(v)<1e-5)return g(w);if(Math.abs(f)<1e-6)break;w-=v/f}let u=0,y=1;w=m;for(let d=0;d<24;d++){let v=c(w);if(Math.abs(v-m)<1e-5)break;vthis.onKeys(h)),o&&dt(this.nextLink,()=>this.nextSlug,o),this.bind(),this.activate(-1),this.requestDraw(),this.wake(),this.loadNextAlbum()}buildEndCard(){let t=document.createElement("section");t.className="end-card",t.setAttribute("aria-label","End of album");let e=document.createElement("a");e.className="next-album",e.href="/";let i=document.createElement("span");i.className="next-strip";let s=document.createElement("span");s.className="next-text";let r=document.createElement("span");r.className="next-eyebrow",r.textContent="All albums";let o=document.createElement("span");o.className="next-title",s.append(r,o),i.appendChild(s),e.appendChild(i);let a=document.createElement("div");a.className="signoff";let h=Vt();h&&a.appendChild(h);let l=document.createElement("p");return l.className="signature",l.textContent="\u2014 Lucio",a.appendChild(l),t.append(e,a),t}loader(t){let e=this.loaders[t];if(!e){let i=this.manifest.photos[t];e=new B(i,J(this.manifest.build,this.manifest.slug,i.hash),{...this.env,requestDraw:()=>this.requestDraw(),onStatus:s=>{this.indicator.update(s),this.progress.update(s)}}),this.loaders[t]=e}return e}measure(){let t=this.stage.getBoundingClientRect();this.vw=Math.max(1,t.width),this.vh=Math.max(1,t.height),this.ox=t.left,this.oy=t.top,this.dpr=Math.min(window.devicePixelRatio||1,this.settings.maxDpr);let e=Math.max(1,Math.round(this.vw*this.dpr)),i=Math.max(1,Math.round(this.vh*this.dpr));(this.canvas.width!==e||this.canvas.height!==i)&&(this.canvas.width=e,this.canvas.height=i),this.layouts=[],this.stops=[];let s=0;this.manifest.photos.forEach((r,o)=>{let a=Math.max(1,r.slides||1),h=Math.min(this.vw/(r.width/a),this.vh/r.height),l=r.width*h,c=r.height*h,g=l/a,b=s+xt/2+(this.vw-g)/2;this.layouts.push({scale:h,width:l,height:c,section:g,slides:a,start:s,left:b,top:(this.vh-c)/2});for(let m=0;m{this.pointerId===null&&document.body.classList.add("is-idle")},ri)}stopForHash(){let t=/^#(\d+)$/.exec(location.hash);if(!t)return 0;let e=Math.min(this.manifest.photos.length,Math.max(1,Number(t[1])))-1,i=this.stops.findIndex(s=>s.photo===e);return i<0?0:i}bind(){let t=this.stage;t.addEventListener("pointerdown",e=>this.onPointerDown(e)),t.addEventListener("pointermove",e=>this.onPointerMove(e)),t.addEventListener("pointerup",e=>this.onPointerUp(e,!1)),t.addEventListener("pointercancel",e=>this.onPointerUp(e,!0)),t.addEventListener("pointerleave",e=>{e.pointerType==="mouse"&&this.pointerId===null&&(this.hover=!1,this.updateCaption())}),t.addEventListener("wheel",e=>this.onWheel(e),{passive:!1}),t.addEventListener("gesturestart",e=>{e.preventDefault(),this.gestureZoom=this.zoom}),t.addEventListener("gesturechange",e=>this.onGesture(e)),t.addEventListener("gestureend",e=>e.preventDefault()),t.addEventListener("dragstart",e=>e.preventDefault()),t.addEventListener("selectstart",e=>e.preventDefault()),this.settings.blockContextMenu&&t.addEventListener("contextmenu",e=>e.preventDefault()),window.addEventListener("keydown",e=>this.onKey(e)),window.addEventListener("hashchange",()=>{let e=this.stopForHash();this.stops[e].photo!==this.stops[this.current].photo?this.jump(e):this.clearZoom()&&(this.startSession(),this.updateCaption())}),new ResizeObserver(()=>this.onResize()).observe(t),this.fade.addEventListener("transitionend",()=>{this.fade.style.opacity==="0"&&(this.fade.width=1,this.fade.height=1)})}onResize(){let t=this.vw+"x"+this.vh+"@"+this.dpr;this.measure(),t!==this.vw+"x"+this.vh+"@"+this.dpr&&(this.clearZoom(),this.tween=null,this.camera=this.stops[this.current].camera,this.requestDraw(),clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout(()=>this.startSession(),200))}onKey(t){if(t.altKey||t.ctrlKey||t.metaKey)return;this.wake();let e=t.target;if(!(e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)))){switch(t.key){case"ArrowRight":this.go(this.current+1);break;case"ArrowLeft":this.go(this.current-1);break;case"Home":this.go(0);break;case"End":this.go(this.stops.length-2);break;case"Escape":this.zoomPhoto>=0?this.go(this.current):location.assign("/");break;case"i":case"I":this.pinned=!this.pinned,this.updateCaption();break;default:return}t.preventDefault()}}onPointerDown(t){if(!(t.pointerType==="mouse"&&t.button!==0)){if(this.pointerId!==null){this.secondId===null&&t.pointerType!=="mouse"&&this.pointerType!=="mouse"&&!this.stale&&(this.zoomPhoto>=0||!this.dragging&&this.enterZoom())&&(this.secondId=t.pointerId,this.bx=t.clientX,this.by=t.clientY,this.pinching=!0,this.dragging=!0,this.stage.setPointerCapture(t.pointerId));return}t.target.closest("a, button")||(this.pointerId=t.pointerId,this.pointerType=t.pointerType,this.dragging=!1,this.stale=!1,this.downX=t.clientX,this.downY=t.clientY,this.ax=t.clientX,this.ay=t.clientY,this.downT=t.timeStamp,this.tween=null,this.downCamera=this.camera,this.samples=[{t:t.timeStamp,x:t.clientX}],this.stage.setPointerCapture(t.pointerId))}}onPointerMove(t){if(t.pointerType==="mouse"&&this.wake(),this.pointerId===null){t.pointerType==="mouse"&&(this.hover=this.inCaptionZone(t.clientX,t.clientY),this.updateCaption());return}if(this.pinching&&(t.pointerId===this.pointerId||t.pointerId===this.secondId)){this.pinchMove(t.pointerId,t.clientX,t.clientY);return}if(t.pointerId!==this.pointerId||this.stale)return;let e=t.clientX-this.downX,i=t.clientY-this.downY;if(!this.dragging&&Math.hypot(e,i)>=ve&&(this.dragging=!0,this.stage.classList.add("is-dragging"),this.updateCaption()),!this.dragging){this.ax=t.clientX,this.ay=t.clientY;return}if(this.zoomPhoto>=0){this.zx+=t.clientX-this.ax,this.zy+=t.clientY-this.ay,this.ax=t.clientX,this.ay=t.clientY,this.settleZoom();return}for(this.samples.push({t:t.timeStamp,x:t.clientX});this.samples.length>2&&t.timeStamp-this.samples[0].t>100;)this.samples.shift();this.camera=this.rubber(this.downCamera-e),this.requestDraw()}onPointerUp(t,e){if(this.pinching&&(t.pointerId===this.pointerId||t.pointerId===this.secondId)){this.endPinch(t.pointerId);return}if(t.pointerId!==this.pointerId)return;this.stage.hasPointerCapture(t.pointerId)&&this.stage.releasePointerCapture(t.pointerId),this.pointerId=null;let i=this.dragging;if(this.dragging=!1,this.stage.classList.remove("is-dragging"),this.stale){this.stale=!1;return}let s=Math.hypot(t.clientX-this.downX,t.clientY-this.downY);if(!e&&!i&&s=0)return;let r=0,o=this.samples[0],a=this.samples[this.samples.length-1];o&&a&&a.t>o.t&&t.timeStamp-a.t<100&&(r=(a.x-o.x)/(a.t-o.t));let h=this.nearestStop(this.camera);if(!e&&Math.abs(r)>ii)if(r<0){let l=this.stops.findIndex(c=>c.camera>this.camera+1);h=l<0?this.stops.length-1:l}else{let l=0;this.stops.forEach((c,g)=>{c.camera=0)return;let i=this.photoRect(e.photo);t.clientX>=i.left&&t.clientX<=i.right&&t.clientY>=i.top&&t.clientY<=i.bottom&&(this.pinned=!this.pinned,this.updateCaption())}onWheel(t){if(t.preventDefault(),this.pinching||this.dragging&&this.zoomPhoto<0)return;let e=t.deltaY;if(t.deltaMode===1?e*=oi:t.deltaMode===2&&(e*=this.vh),e===0)return;let i=Math.max(-1,Math.min(1,e*(t.ctrlKey?hi:ai))),s=t.clientX-this.ox,r=t.clientY-this.oy;this.zoomTo(this.zoom*Math.exp(-i),s,r,s,r)}onGesture(t){if(t.preventDefault(),this.pointerId!==null||!t.scale)return;let e=(t.clientX??this.ox+this.vw/2)-this.ox,i=(t.clientY??this.oy+this.vh/2)-this.oy;this.zoomTo(this.gestureZoom*t.scale,e,i,e,i)}pinchMove(t,e,i){let s=(this.ax+this.bx)/2-this.ox,r=(this.ay+this.by)/2-this.oy,o=Math.hypot(this.ax-this.bx,this.ay-this.by);t===this.pointerId?(this.ax=e,this.ay=i):(this.bx=e,this.by=i);let a=Math.hypot(this.ax-this.bx,this.ay-this.by),h=o>1&&a>1?this.zoom*a/o:this.zoom;this.zoomTo(h,s,r,(this.ax+this.bx)/2-this.ox,(this.ay+this.by)/2-this.oy)}endPinch(t){this.stage.hasPointerCapture(t)&&this.stage.releasePointerCapture(t),t===this.pointerId&&(this.pointerId=this.secondId,this.ax=this.bx,this.ay=this.by),this.secondId=null,this.pinching=!1,this.dragging=!0,this.zoomPhoto>=0&&this.settleZoom()}enterZoom(){let t=this.stops[this.current];if(t.photo<0||this.suspended)return!1;let e=this.layouts[t.photo],i=this.manifest.photos[t.photo].width/(window.devicePixelRatio||1)/e.width;return i<=1.001?!1:(this.tween=null,this.camera=t.camera,this.zoomPhoto=t.photo,this.zoomMax=i,this.zoom=1,this.zx=e.left-(this.camera-this.vw/2),this.zy=e.top,this.slackX=this.zx-this.clampAxis(this.zx,e.width,this.vw,0),this.slackY=this.zy-this.clampAxis(this.zy,e.height,this.vh,0),this.updateCaption(),!0)}zoomTo(t,e,i,s,r){if(this.zoomPhoto<0&&(t<=1||!this.enterZoom()))return;let o=Math.max(1,Math.min(this.zoomMax,t)),a=o/this.zoom;this.zx=s-(e-this.zx)*a,this.zy=r-(i-this.zy)*a,this.zoom=o,this.settleZoom()}settleZoom(){let t=this.layouts[this.zoomPhoto];if(this.zx=this.clampAxis(this.zx,t.width*this.zoom,this.vw,this.slackX),this.zy=this.clampAxis(this.zy,t.height*this.zoom,this.vh,this.slackY),this.requestDraw(),this.zoom<=1&&!this.pinching){this.camera=t.left+this.vw/2-this.zx,this.go(this.nearestStop(this.camera));return}clearTimeout(this.zoomTimer),this.zoomTimer=window.setTimeout(()=>this.startZoomSession(),ni)}clampAxis(t,e,i,s){let r=(i-e)/2,o=Math.min(i-e,r),a=Math.max(0,r),h=s*Math.max(0,2-this.zoom);return h>0?a+=h:o+=h,Math.min(a,Math.max(o,t))}clearZoom(){return this.zoomPhoto<0?!1:(this.zoomPhoto=-1,this.zoom=1,this.gestureZoom=1,clearTimeout(this.zoomTimer),this.zoomTimer=0,this.pointerId!==null&&(this.stale=!0,this.pinching=!1,this.secondId=null),this.requestDraw(),!0)}levelDpr(){return this.zoomPhoto>=0&&this.zoom>=this.zoomMax*.999?Math.max(this.dpr,window.devicePixelRatio||1):this.dpr}startZoomSession(){if(this.zoomTimer=0,this.suspended||this.zoomPhoto<0)return;let t=this.layouts[this.zoomPhoto],e=t.width*this.zoom,i=t.height*this.zoom,s=Math.max(0,this.zx),r=Math.min(this.vw,this.zx+e),o=Math.max(0,this.zy),a=Math.min(this.vh,this.zy+i);r<=s||a<=o||this.loader(this.zoomPhoto).start({displayWidth:e,u0:(s-this.zx)/e,u1:(r-this.zx)/e,v0:(o-this.zy)/i,v1:(a-this.zy)/i},this.levelDpr(),()=>{})}rubber(t){let e=this.stops[0].camera,i=this.stops[this.stops.length-1].camera;return ti?i+(t-i)*ge:t}nearestStop(t){let e=0;return this.stops.forEach((i,s)=>{Math.abs(i.camera-t){this.current=e,this.camera=r});else{let o=Math.abs(r-this.camera);o>.5?this.tween={from:this.camera,to:r,start:performance.now(),duration:240+200*Math.min(1,o/this.vw)}:this.camera=r,this.current=e}e!==i?this.activate(i):(s&&this.startSession(),this.updateCaption()),this.requestDraw()}jump(t){let e=this.current;this.clearZoom(),this.tween=null,this.crossfade(()=>{this.current=t,this.camera=this.stops[t].camera}),this.activate(e),this.requestDraw()}crossfade(t){let e=this.fade;(e.width!==this.canvas.width||e.height!==this.canvas.height)&&(e.width=this.canvas.width,e.height=this.canvas.height);let i=e.getContext("2d");i&&i.drawImage(this.canvas,0,0),e.style.transition="none",e.style.opacity="1",t(),this.render(performance.now()),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transition="",e.style.opacity="0"})})}activate(t){let e=this.stops[this.current],i=t>=0?this.stops[t]:null;if(i&&i.photo>=0&&i.photo!==e.photo&&this.loaders[i.photo]?.stop(),this.loaders.forEach((s,r)=>{s&&r!==e.photo&&r!==e.photo+1&&s.stopPrefetch()}),e.photo<0&&(this.indicator.watch(null),this.progress.watch(null)),this.describe(e.photo,t>=0),e.photo>=0){let s=this.manifest.photos[e.photo];this.caption.set(s,e.photo,this.manifest.photos.length,this.manifest.show_exif),(t>=0||location.hash!=="")&&location.hash!=="#"+(e.photo+1)&&history.replaceState(history.state,"","#"+(e.photo+1))}this.wantKeys(),e.photo>=0&&this.startSession(),this.syncNextStrip(),this.updateCaption()}describe(t,e){let i=this.manifest.photos.length,s;if(t<0){let r=this.nextLink.querySelector(".next-title")?.textContent??"";s="End of album."+(r?" Next album: "+r+".":"")}else{let r=this.manifest.photos[t],o=r.alt||r.title||"";s="Photo "+(t+1)+" of "+i+(o?": "+o:"")}this.canvas.setAttribute("aria-label",s),clearTimeout(this.announceTimer),e&&(this.announceTimer=window.setTimeout(()=>{this.announcer.textContent=s},500))}suspend(t){if(!this.suspended){this.suspended=!0,this.tween=null;for(let e of this.loaders)e?.stop();this.nextStrip?.loader.stop(),this.env.scheduler.cancelAll(),this.env.cache.trim(t?0:this.env.cache.budget/4),t&&(this.nextStrip?.detach(),this.canvas.width=1,this.canvas.height=1,this.fade.width=1,this.fade.height=1)}}resume(){this.suspended&&(this.suspended=!1,this.clearZoom(),this.canvas.width=0,this.measure(),this.camera=this.stops[this.current].camera,this.syncNextStrip(),this.startSession(),this.requestDraw())}wantKeys(){let t=this.manifest.photos,e=this.stops[this.current],i=e.photo<0?t.length-1:e.photo,s=r=>{let o=[];for(let a of r){let h=i+a;h>=0&&hr>=0&&r=0?i(this.zoomPhoto)&&this.loader(this.zoomPhoto).stalled&&this.startZoomSession():s.photo>=0&&i(s.photo)&&this.loader(s.photo).stalled?this.startSession():s.photo>=0&&i(s.photo+1)&&!this.loader(s.photo).status.active&&this.prefetchAround(this.current),this.requestDraw()}startSession(){let t=this.stops[this.current];if(t.photo<0)return;let e=this.current,i=this.loader(t.photo);i.start(this.viewAt(t),this.dpr,()=>{this.current===e&&this.prefetchAround(e)}),this.indicator.watch(i),this.progress.watch(i)}prefetchAround(t){let e=this.stops[t],i=this.stops[t+1];if(!(!i||i.photo<0)){if(i.photo===e.photo){let s=this.loader(e.photo);s.prefetchLevel(this.viewAt(i),s.finalLevel);let r=this.stops.find(o=>o.photo===e.photo+1);r&&this.loader(r.photo).prefetchProbe(this.viewAt(r),this.dpr);return}this.loader(i.photo).prefetchProbe(this.viewAt(i),this.dpr)}}viewAt(t){let e=this.layouts[t.photo],i=t.camera-this.vw/2,s=Math.max(i,e.left),r=Math.min(i+this.vw,e.left+e.width),o=Math.max(0,e.top),a=Math.min(this.vh,e.top+e.height);return{displayWidth:e.width,u0:(s-e.left)/e.width,u1:(r-e.left)/e.width,v0:(o-e.top)/e.height,v1:(a-e.top)/e.height}}photoRect(t){let e=this.layouts[t],i=e.left-(this.camera-this.vw/2);return{left:Math.max(0,i),right:Math.min(this.vw,i+e.width),top:Math.max(0,e.top),bottom:Math.min(this.vh,e.top+e.height)}}inCaptionZone(t,e){let i=this.stops[this.current];if(i.photo<0)return!1;let s=this.stage.getBoundingClientRect(),r=t-s.left,o=e-s.top,a=this.layouts[i.photo],h=this.photoRect(i.photo),l=a.top+a.height*(1-si);return r>=h.left&&r<=h.right&&o>=l&&o<=h.bottom}updateCaption(){let t=this.stops[this.current],e=t.photo>=0&&this.zoomPhoto<0&&!this.dragging&&(this.pinned||this.hover);if(e){let i=this.photoRect(t.photo);this.caption.place(i.left,i.right-i.left,this.vh-i.bottom)}this.caption.show(e),document.body.classList.toggle("has-caption",e)}loadNextAlbum(){this.indexRequested||!this.settings.indexUrl||(this.indexRequested=!0,fetch(this.settings.indexUrl,{credentials:"same-origin"}).then(t=>t.ok?t.json():Promise.reject(new Error("index"))).then(t=>this.showNextAlbum(t)).catch(()=>{this.indexRequested=!1}))}showNextAlbum(t){let e=t.albums;if(e.length===0)return;let i=e.findIndex(a=>a.slug===this.manifest.slug),s=e[(i+1)%e.length];if(!s||s.slug===this.manifest.slug)return;this.nextLink.href="/a/"+encodeURIComponent(s.slug)+"/",this.nextSlug=s.slug;let r=this.nextLink.querySelector(".next-eyebrow"),o=this.nextLink.querySelector(".next-title");r&&(r.textContent="Next album"+(s.date?" \xB7 "+s.date:"")),o&&(o.textContent=s.title,bt(o,s.title)),s.cover&&(this.nextStrip=new _(this.nextFrame,s.cover,s.collapsed_focus_y??.5,J(t.build,s.slug,s.cover.hash),{...this.env,keys:gt(t.gate.cover),tiles:t.tiles},()=>{}),this.nextLink.classList.add("has-strip"),this.layoutNextStrip(),this.syncNextStrip())}requestDraw(){this.frame===0&&(this.frame=requestAnimationFrame(t=>{this.frame=0,this.render(t)}))}render(t){let e=!1;if(this.tween){let b=Math.min(1,(t-this.tween.start)/this.tween.duration);this.camera=this.tween.from+(this.tween.to-this.tween.from)*ci(b),b>=1?(this.tween=null,this.updateCaption()):e=!0}let i=this.g,s=this.canvas.width,r=this.canvas.height;i.setTransform(1,0,0,1,0,0),i.globalAlpha=1,i.fillStyle="#111114",i.fillRect(0,0,s,r);let o=this.camera-this.vw/2,a=o+this.vw,h=this.dpr,l=this.stops[this.current].photo,c=Math.max(0,(l<0?this.layouts.length-1:l)-2),g=this.zoomPhoto>=0?-1:Math.min(this.layouts.length-1,(l<0?this.layouts.length-1:l)+2);if(this.zoomPhoto>=0){let b=this.layouts[this.zoomPhoto],m=b.width*this.zoom;this.loader(this.zoomPhoto).draw({g:i,originX:this.zx*h,originY:this.zy*h,width:m*h,height:b.height*this.zoom*h,canvasWidth:s,canvasHeight:r,displayWidth:m,dpr:this.levelDpr(),now:t})&&(e=!0)}for(let b=c;b<=g;b++){let m=this.layouts[b];m.left+m.widtha||this.loader(b).draw({g:i,originX:(m.left-o)*h,originY:m.top*h,width:m.width*h,height:m.height*h,canvasWidth:s,canvasHeight:r,displayWidth:m.width,dpr:h,now:t})&&(e=!0)}this.endCard.style.transform="translate3d("+Math.round(this.endLeft-o)+"px,0,0)",this.caption.element.classList.contains("is-visible")&&this.tween&&this.updateCaption(),e&&this.requestDraw()}};async function ye(n){let t=await fetch(n,{credentials:"same-origin"});if(!t.ok)throw new Error(n+" "+t.status);return await t.json()}function we(n){return{scheduler:new $(n.concurrency,n.workerUrl),cache:new et(Jt())}}function xe(n,t){return n.gate==="off"?null:{build:n.build,workerUrl:n.workerUrl,minEntropy:t,score:it}}async function di(n,t,e){let i=await ye(t.manifestUrl);if(i.photos.length===0)return;let s=new vt(i.gate,i.slug,e?"nav":"land",t.workerUrl),{scheduler:r,cache:o}=we(t);document.documentElement.classList.add("has-viewer");let a=i.gate.min_entropy??t.minEntropy;Me(new Mt(n,i,t,{scheduler:r,cache:o,settings:t,keys:s,tiles:i.tiles},s,xe(t,()=>a)))}async function ui(n,t,e){let i=await ye(t.indexUrl);if(typeof i.gate.min_entropy=="number"&&e(i.gate.min_entropy),i.albums.length===0)return;let{scheduler:s,cache:r}=we(t);Me(new ft(n,i,t,{scheduler:s,cache:r,settings:t,keys:gt(i.gate.cover),tiles:i.tiles}))}function Me(n){document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?n.suspend(!1):n.resume()}),window.addEventListener("pagehide",()=>n.suspend(!0)),window.addEventListener("pageshow",t=>{t.persisted&&n.resume()})}function pi(){document.documentElement.classList.remove("has-viewer"),document.querySelector(".load-error")?.removeAttribute("hidden")}function be(){Ct();let n=pe(document.body);if(n.page==="album"){let t=document.getElementById("stage");t&&di(t,n,se(n.slug)).catch(pi)}else if(n.page==="notfound"){let t=document.querySelector(".site-header .wordmark");t&&K(t,!1)}else if(n.page==="index"){let t=document.getElementById("strips");if(t){let e=n.minEntropy,i=xe(n,()=>e);if(i)for(let s of Array.from(t.querySelectorAll("a.strip")))dt(s,()=>s.dataset.slug??"",i);ui(t,n,s=>{e=s}).catch(()=>{document.documentElement.classList.remove("has-strips");let s=document.querySelector(".site-header .wordmark");s&&!s.classList.contains("has-svg")&&K(s,!1)})}}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",be,{once:!0}):be();})(); +"use strict";(()=>{(function(n){let e={from:"Guoliang",to:"Lucio",letters:[{ch:"G",kind:"keep",shared:"M8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50",fullA:"M80.00 8.50L58.00 8.50L22.00 8.50A13.50 13.50 0 0 0 8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50A13.50 13.50 0 0 0 71.50 78.00L71.50 56.00L41.50 56.00",fullB:"M8.50 0.00L8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50L80.00 91.50",out:[{d:"M80.00 8.50L58.00 8.50L22.00 8.50A13.50 13.50 0 0 0 8.50 22.00",P:79.21,j:"end"},{d:"M58.00 91.50A13.50 13.50 0 0 0 71.50 78.00L71.50 56.00L41.50 56.00",P:73.21,j:"start"}],in:[{d:"M8.50 22.00L8.50 0.00",P:22,j:"start"},{d:"M58.00 91.50L80.00 91.50",P:22,j:"start"}],x0:0,x1:0,dot:null},{ch:"u",kind:"keep",shared:"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00",fullA:"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00",fullB:"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00",out:[],in:[],x0:88.8,x1:88,dot:null},{ch:"o",kind:"keep",shared:"M38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",fullA:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",fullB:"M60.00 46.50L38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50L60.00 91.50",out:[{d:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50",P:60.41,j:"both"}],in:[{d:"M38.00 46.50L60.00 46.50",P:22,j:"start"},{d:"M38.00 91.50L60.00 91.50",P:22,j:"start"}],x0:159,x1:158.2,dot:null},{ch:"l",kind:"fade",d:"M8.50 0.00L8.50 100.00",x0:230.8,x1:230.8,dot:null},{ch:"i",kind:"keep",shared:"M8.50 38.00L8.50 100.00",fullA:"M8.50 38.00L8.50 100.00",fullB:"M8.50 38.00L8.50 100.00",out:[],in:[],x0:262.8,x1:227.9,dot:[0,14,17]},{ch:"a",kind:"fade",d:"M38.00 91.50L51.50 91.50L51.50 78.00L51.50 60.00L51.50 46.50L38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",x0:291.6,x1:291.6,dot:null},{ch:"n",kind:"fade",d:"M51.50 100.00L51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00L8.50 100.00",x0:362.7,x1:362.7,dot:null},{ch:"g",kind:"keep",shared:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",fullA:"M0.00 127.50L38.00 127.50A13.50 13.50 0 0 0 51.50 114.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00",fullB:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",out:[{d:"M51.50 60.00L51.50 114.00A13.50 13.50 0 0 1 38.00 127.50L0.00 127.50",P:113.21,j:"start"}],in:[],x0:432.9,x1:256.7,dot:null}],pad:17,vbw:526.9,vbh:170,stroke:17,raysT:"translate(0.000 22.727) scale(0.7727)"},t="M47.6 70.7L71.9 61.1L71.1 58.2L45.2 62.0ZM44.9 61.5L61.2 40.9L59.1 38.8L38.5 55.1ZM38.0 54.8L41.8 28.9L38.9 28.1L29.3 52.4Z",i="http://www.w3.org/2000/svg",s=(v,E)=>{let p=document.createElementNS(i,v);for(let y in E)p.setAttribute(y,E[y]);return p},r=()=>n.matchMedia&&n.matchMedia("(prefers-reduced-motion: reduce)").matches,o=v=>Math.max(0,Math.min(1,v)),a=v=>v*v*(3-2*v),l=.5;function h(v,E){let p=0,y=0,x=null,M=0;function F(T){let A=(T-M)/E;M=T,p=pw(1),reverse:()=>w(0),toggle:()=>w(y?0:1),set:T=>{cancelAnimationFrame(x),x=null,y=p=T,v(p)},stop:()=>{cancelAnimationFrame(x),x=null},get t(){return p}}}function c(v,E,p,y){let x=o(y)*E;if(v.style.visibility=x<.05?"hidden":"visible",p==="both"){let M=x/2;v.setAttribute("stroke-dasharray",M.toFixed(2)+" "+Math.max(0,E-2*M).toFixed(2)+" "+M.toFixed(2)),v.setAttribute("stroke-dashoffset","0")}else p==="end"?(v.setAttribute("stroke-dasharray",x.toFixed(2)+" "+(2*E+20).toFixed(2)),v.setAttribute("stroke-dashoffset",(-(E-x)).toFixed(2))):(v.setAttribute("stroke-dasharray",x.toFixed(2)+" "+(2*E+20).toFixed(2)),v.setAttribute("stroke-dashoffset","0"))}function f(v,E={}){let p=Object.assign({trigger:"hover",color:"currentColor",rays:"#FFF3CF",duration:450,autoDelay:1800},E),y=s("svg",{viewBox:"0 0 "+e.vbw+" "+e.vbh,role:"img","aria-label":"Guoliang Chen, Lucio"});y.style.display="block",y.style.width="100%",y.style.height="auto";let x=s("g",{transform:"translate("+e.pad+" "+e.pad+")",fill:"none",stroke:p.color,"stroke-width":e.stroke,"stroke-linejoin":"miter","stroke-linecap":"butt"});y.appendChild(x);let M=e.letters.map(A=>{let P=s("g",{transform:"translate("+A.x0+" 0)"});x.appendChild(P);let N=Object.assign({g:P,outEls:[],inEls:[]},A);if(A.kind==="fade")N.fadeEl=s("path",{d:A.d}),P.appendChild(N.fadeEl);else{N.fullA=s("path",{d:A.fullA}),P.appendChild(N.fullA),N.fullB=s("path",{d:A.fullB}),P.appendChild(N.fullB),A.shared&&P.appendChild(s("path",{d:A.shared}));for(let C of A.out){let R=s("path",{d:C.d});P.appendChild(R),N.outEls.push([R,C])}for(let C of A.in){let R=s("path",{d:C.d});P.appendChild(R),N.inEls.push([R,C])}}return A.dot&&(N.dotEl=s("rect",{x:A.dot[0],y:A.dot[1],width:A.dot[2],height:A.dot[2],rx:A.dot[2]*.22,fill:p.color,stroke:"none"}),P.appendChild(N.dotEl)),N}),F=s("path",{d:t,fill:p.rays,stroke:"none",opacity:0});x.appendChild(F),v.appendChild(y);function w(A){let P=a(o(A/l)),N=a(o((A-l)/(1-l)));for(let C of M){if(C.kind==="fade")C.fadeEl.setAttribute("opacity",(1-P).toFixed(3)),C.dotEl&&C.dotEl.setAttribute("opacity",(1-P).toFixed(3));else{for(let[R,_]of C.outEls)c(R,_.P,_.j,1-P);for(let[R,_]of C.inEls)c(R,_.P,_.j,P);C.fullA.style.visibility=P<=.001?"visible":"hidden",C.fullB.style.visibility=P>=.999?"visible":"hidden"}C.g.setAttribute("transform","translate("+(C.x0+(C.x1-C.x0)*N).toFixed(2)+" 0)")}F.setAttribute("transform","translate("+(M[0].x0+(M[0].x1-M[0].x0)*N).toFixed(2)+" 0) "+e.raysT),F.setAttribute("opacity",o((A-.8)/.2).toFixed(3))}let T=h(w,p.duration);return w(0),p.trigger==="hover"&&(v.addEventListener("mouseenter",T.play),v.addEventListener("mouseleave",T.reverse),v.addEventListener("focus",T.play),v.addEventListener("blur",T.reverse)),p.trigger==="click"&&v.addEventListener("click",T.toggle),p.trigger==="auto"&&setInterval(T.toggle,p.autoDelay+p.duration),Object.assign(T,{svg:y})}let b={C:[0,.75],L:[.25,.75],U:[.25,1],I:[.75,1],O:[.75,1.75]};function g(v,E,p){let y=E/2,x=p-y,M=y+x,F=x*Math.SQRT1_2,w=A=>A.toFixed(3);return{d:"M"+w(v-M+F)+" "+w(M-F)+"A"+w(x)+" "+w(x)+" 0 0 0 "+w(v-M)+" "+w(y)+"H"+w(M)+"A"+w(x)+" "+w(x)+" 0 0 0 "+w(y)+" "+w(M)+"V"+w(v-M)+"A"+w(x)+" "+w(x)+" 0 0 0 "+w(M)+" "+w(v-y)+"H"+w(v-M)+"A"+w(x)+" "+w(x)+" 0 0 0 "+w(v-y)+" "+w(v-M)+"V"+w(M)+"A"+w(x)+" "+w(x)+" 0 0 0 "+w(v-M+F)+" "+w(M-F)+"Z",P:4*(v-2*M)+2*Math.PI*x}}function L(v,E={}){let p=Object.assign({sequence:"LUCIO",color:"#F3F1EC",track:"#26262D",rays:"#FFF3CF",hold:480,morph:640,size:96,stroke:.17,radius:.22},E),y=120,x=y*p.stroke,M=y*p.radius,F=g(y,x,M),w=s("svg",{viewBox:"0 0 "+y+" "+y,width:p.size,height:p.size,role:"img","aria-label":"Loading"});p.track&&w.appendChild(s("path",{d:F.d,fill:"none",stroke:p.track,"stroke-width":x}));let T=s("path",{d:F.d,fill:"none",stroke:p.color,"stroke-width":x,"stroke-linecap":"butt"}),A=x/22,P=s("path",{d:t,fill:p.rays,transform:"translate("+(x-22*A).toFixed(3)+" "+(y-x-78*A).toFixed(3)+") scale("+A.toFixed(4)+")",opacity:0});w.appendChild(T),w.appendChild(P);let N=(m,S)=>{let z=Math.min(1,Math.max(0,S-m))*F.P;T.setAttribute("stroke-dasharray",z.toFixed(3)+" "+Math.max(0,F.P-z).toFixed(3)),T.setAttribute("stroke-dashoffset",(-m*F.P).toFixed(3))},C=(m,S)=>{let[z,d]=b[S];for(let H=-1;H<6;H++)if(z+H>=m[0]-1e-6&&d+H>=m[1]-1e-6)return[z+H,d+H];return[z,d]},R=p.sequence.split(""),_=0,O=b[R[0]].slice(),$,Q,pe=!1;N(O[0],O[1]),P.setAttribute("opacity",R[0]==="L"?1:0);function oe(){if(pe)return;let m=(_+1)%R.length,S=C(O,R[m]),z=O.slice(),d=R[_]==="L",H=R[m]==="L",D=()=>{O=S;let U=Math.floor(O[0]);O[0]-=U,O[1]-=U,_=m,N(O[0],O[1]),P.setAttribute("opacity",H?1:0),Q=setTimeout(oe,p.hold)};if(r()){D();return}let u=performance.now(),X=U=>{let q=Math.min(1,(U-u)/p.morph),I=q<.5?4*q*q*q:1-Math.pow(-2*q+2,3)/2;N(z[0]+(S[0]-z[0])*I,z[1]+(S[1]-z[1])*I),P.setAttribute("opacity",H?Math.max(0,(q-.6)/.4).toFixed(3):d?Math.max(0,1-q*2.5).toFixed(3):0),q<1?$=requestAnimationFrame(X):D()};$=requestAnimationFrame(X)}return Q=setTimeout(oe,p.hold),v.appendChild(w),{svg:w,stop:()=>{pe=!0,cancelAnimationFrame($),clearTimeout(Q)}}}n.LucioMorph={wordmark:f,loader:L}})(window);(function(n){let s=33.599999999999994,r=2*s,o=Math.PI/2*16.2,a=4*(r+o),l=a/4,h=96,c=64,f=10.2*.85;function b(m){m=((m-o/2)%a+a)%a;let S=(z,d,H)=>[z+16.2*Math.cos(H),d+16.2*Math.sin(H)];return m abs(p.y)) p.x = sign(p.x) * (H + 1e-3); else p.y = sign(p.y) * (H + 1e-3); } + float s; + if (p.x > H && p.y > H) s = SL + atan(p.y - H, p.x - H) * CR; + else if (p.x < -H && p.y > H) s = 2. * SL + CL + (atan(p.y - H, p.x + H) - HPI) * CR; + else if (p.x < -H && p.y < -H) s = 3. * SL + 2. * CL + atan(-(p.y + H), -(p.x + H)) * CR; + else if (p.x > H && p.y < -H) s = 4. * SL + 3. * CL + (atan(p.y + H, p.x - H) + HPI) * CR; + else if (p.x > H) s = p.y + H; + else if (p.y > H) s = SL + CL + (H - p.x); + else if (p.x < -H) s = 2. * SL + 2. * CL + (H - p.y); + else s = 3. * SL + 3. * CL + (p.x + H); + return mod(s + CL * 0.5, PER); +} +float hash11(float n) { return fract(sin(n * 127.1 + 11.7) * 43758.5453); } +float hash12(vec2 p) { vec3 p3 = fract(vec3(p.xyx) * .1031); p3 += dot(p3, p3.yzx + 33.33); return fract((p3.x + p3.y) * p3.z); } +vec2 hash22(vec2 p) { vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973)); p3 += dot(p3, p3.yzx + 33.33); return fract((p3.xx + p3.yz) * p3.zy); } +// simplex noise 3D (Ashima Arts / Stefan Gustavson, MIT) +vec3 mod289(vec3 x) { return x - floor(x * (1. / 289.)) * 289.; } +vec4 mod289(vec4 x) { return x - floor(x * (1. / 289.)) * 289.; } +vec4 permute(vec4 x) { return mod289(((x * 34.) + 1.) * x); } +vec4 taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; } +float snoise(vec3 v) { + const vec2 C = vec2(1. / 6., 1. / 3.); const vec4 D = vec4(0., .5, 1., 2.); + vec3 i = floor(v + dot(v, C.yyy)); vec3 x0 = v - i + dot(i, C.xxx); + vec3 g = step(x0.yzx, x0.xyz); vec3 l = 1. - g; vec3 i1 = min(g.xyz, l.zxy); vec3 i2 = max(g.xyz, l.zxy); + vec3 x1 = x0 - i1 + C.xxx; vec3 x2 = x0 - i2 + C.yyy; vec3 x3 = x0 - D.yyy; + i = mod289(i); + vec4 p = permute(permute(permute(i.z + vec4(0., i1.z, i2.z, 1.)) + i.y + vec4(0., i1.y, i2.y, 1.)) + i.x + vec4(0., i1.x, i2.x, 1.)); + float n_ = 0.142857142857; vec3 ns = n_ * D.wyz - D.xzx; + vec4 j = p - 49. * floor(p * ns.z * ns.z); + vec4 x_ = floor(j * ns.z); vec4 y_ = floor(j - 7. * x_); + vec4 x = x_ * ns.x + ns.yyyy; vec4 y = y_ * ns.x + ns.yyyy; vec4 h = 1. - abs(x) - abs(y); + vec4 b0 = vec4(x.xy, y.xy); vec4 b1 = vec4(x.zw, y.zw); + vec4 s0 = floor(b0) * 2. + 1.; vec4 s1 = floor(b1) * 2. + 1.; vec4 sh = -step(h, vec4(0.)); + vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww; + vec3 p0 = vec3(a0.xy, h.x); vec3 p1 = vec3(a0.zw, h.y); vec3 p2 = vec3(a1.xy, h.z); vec3 p3 = vec3(a1.zw, h.w); + vec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3))); + p0 *= norm.x; p1 *= norm.y; p2 *= norm.z; p3 *= norm.w; + vec4 m = max(.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.); m = m * m; + return 42. * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3))); +} +// premultiplied "over": c with coverage a goes on top of dst +void over(inout vec4 dst, vec3 c, float a) { a = clamp(a, 0., 1.); dst = vec4(c * a, a) + dst * (1. - a); } +vec2 frag() { return (gl_FragCoord.xy - 0.5 * uRes) * uPx; } +`,L=` +uniform float uHead, uLen, uSurge, uMid, uFlowA, uFlowB, uFlowW; +uniform sampler2D uWet; // how recently each stretch of pipe was under water, 1 = now +const float RI = 0.84; // bore radius / outer radius: the rest is glass wall +const float MEN = 0.55; // meniscus depth, fraction of bore radius +// x: coverage, y: distance behind the head along the pipe, z: distance inside the nearest meniscus +vec3 slug(float s, float vi) { + float rel = mod(uHead - s + 24., PER) - 24.; + float gap = PER - uLen, full = 1. - smoothstep(0.3, 1.5, gap); // O: the two ends meet and the ring closes + float c = sqrt(max(0., 1. - vi * vi)); + float m = MEN * HW * RI * smoothstep(0., 30., gap); + float front = m * c * (1. - 0.4 * uSurge); // concave: the water climbs the wall ahead of the centre + float back = uLen + m * (1. - c) * (1. + 0.4 * uSurge); + float dIn = mix(min(rel - front, back - rel), 60., full); + return vec3(clamp(dIn / uPx + 0.5, 0., 1.), rel, dIn); +} +// noise laid on a circle, so the texture wraps the loop without a seam +float ringNoise(float s, float vi, float freq, float z) { + float a = 6.2831853 * s / PER, R = PER / 6.2831853 * freq; + return snoise(vec3(R * cos(a) + uTime * 0.3, R * sin(a) - uTime * 0.2, vi * 1.25 + z)); +} +float flowTex(float s, float vi, float z) { + return 0.5 + 0.5 * (0.6 * ringNoise(s, vi, 0.06, z) + 0.28 * ringNoise(s, vi * 1.8, 0.13, z + 3.1) + 0.12 * ringNoise(s, vi * 3.6, 0.27, z + 7.7)); +} +void main() { + vec2 p = frag(); + vec4 o = vec4(0.); + // contact shadow thrown down-left, and the light the water focuses into it + vec2 so = -L2 * 5.5; + vec2 ps = p - so; + float dsh = sdRB(ps); + float sr = abs(dsh) / HW; // glass passes most light: the shadow is darkest under the walls + o.a = (1. - smoothstep(-4., 10., abs(dsh) - HW)) * mix(0.05, 0.2, uDark) + exp(-pow((sr - 0.95) / 0.35, 2.)) * mix(0.08, 0.06, uDark); + { + vec3 Ws = slug(pathS(ps), clamp(dsh / (HW * RI), -1., 1.)); + float cz = exp(-pow((dsh / HW + 0.2) / 0.3, 2.)) * Ws.x; + o.rgb += mix(uColor, vec3(1.), 0.25) * cz * mix(0.45, 0.12, uDark); + } + float dc = sdRB(p); + float v = dc / HW; + float tube = clamp((HW - abs(dc)) / uPx + 0.5, 0., 1.); + if (tube <= 0.) { gl_FragColor = o; return; } + vec2 n2 = normalize(p - clamp(p, -H, H) + 1e-4); + vec2 t2 = vec2(-n2.y, n2.x); + float s = pathS(p); + float vc = clamp(v, -1., 1.); + vec3 N = vec3(n2 * vc, sqrt(max(0., 1. - vc * vc))); + vec3 Ld = normalize(vec3(L2 * 0.78, 0.62)); + vec3 Hh = normalize(Ld + vec3(0., 0., 1.)); + vec3 gTint = mix(vec3(0.42, 0.50, 0.53), vec3(0.78, 0.88, 0.92), uDark); + vec3 hiC = vec3(1.0, 0.985, 0.95); + // glass: the walls are thicker to the eye near the silhouette + float gl = 2. * (sqrt(max(0., 1. - vc * vc)) - sqrt(max(0., RI * RI - vc * vc))); + float gA = 1. - exp(-gl * 0.42); + over(o, gTint, gA * 0.3 * tube); + float vi = clamp(v / RI, -1., 1.); + float bore = clamp((RI * HW - abs(dc)) / uPx + 0.5, 0., 1.); + vec3 W = slug(s, vi); + float cov = W.x * bore; + vec2 hl = vec2(dot(L2, -t2), dot(L2, n2)); // light direction in the slug's local frame + vec3 wetC = mix(uColor, vec3(1.), 0.35); + // where the water has just left: a film on the walls and beads that drain away + float wet = texture2D(uWet, vec2(s / PER, 0.5)).r * (1. - W.x); + if (wet > 0.01 && bore > 0.) { + over(o, wetC, wet * 0.22 * smoothstep(0.5, 0.95, abs(vi)) * bore); + float cs = PER / 110.; + float gx = floor(s / cs), gy = floor((vi + 1.) * 2.); + for (int a = -1; a <= 1; a++) for (int b = -1; b <= 1; b++) { + vec2 cell = vec2(gx + float(a), gy + float(b)); + if (cell.y < 0. || cell.y > 3.) continue; + vec2 hc = vec2(mod(cell.x, 110.), cell.y); + vec2 h = hash22(hc); + float h3 = hash12(hc.yx + 17.); + float pres = smoothstep(h3, h3 + 0.3, wet * 1.2) * step(0.45, hash12(hc + 3.7)); + if (pres <= 0.01) continue; + vec2 c = vec2((cell.x + h.x) * cs, clamp(-1. + (cell.y + h.y) * 0.5, -0.88, 0.88)); + float r = mix(0.35, 1.3, h.x * h.y) * sqrt(pres); + vec2 dl = vec2(s - c.x, (vi - c.y) * RI * HW); + float d = length(dl) - r; + float fill = clamp(-d / uPx + 0.5, 0., 1.) * bore; + over(o, wetC * 0.75, fill * 0.45); + over(o, uColor * 0.4, exp(-pow(d / 0.25, 2.)) * 0.35 * bore); + over(o, hiC, exp(-pow(length(dl - vec2(-hl.x, hl.y) * r * 0.45) / (0.28 * r + 0.08), 2.)) * 0.85 * bore); + } + } + if (cov > 0.) { + float th = sqrt(max(0., 1. - vi * vi)); + float kv = 1. + 0.4 * (1. - 2. * vi * vi); // the centre runs ahead of the walls + float tex = mix(flowTex(s - kv * uFlowA, vi, 0.), flowTex(s - kv * uFlowB, vi, 7.3), uFlowW); + float side = dot(n2 * vi, L2); + vec3 wc = mix(mix(uColor, vec3(1.), 0.55), uColor, smoothstep(0.05, 0.9, th)); // Beer-Lambert: thicker is deeper + wc *= 1. - 0.55 * smoothstep(0.62, 1.0, abs(vi)); // total internal reflection at the wall + wc += mix(uColor, vec3(1.), 0.65) * exp(-pow((side + 0.42) / 0.17, 2.)) * 0.42; // caustic on the far wall + wc *= 0.8 + 0.4 * tex; + float spA = smoothstep(0.62, 0.9, ringNoise(s - kv * uFlowA, vi * 4., 0.45, 11.)); + float spB = smoothstep(0.62, 0.9, ringNoise(s - kv * uFlowB, vi * 4., 0.45, 19.)); + wc += 0.25 * mix(spA, spB, uFlowW); + wc *= 1. - 0.6 * exp(-pow(W.z / 1.1, 2.)); // meniscus: dark refracted band + wc += 0.5 * exp(-pow((W.z - 2.1) / 0.7, 2.)) * mix(uColor, vec3(1.), 0.75); // and its bright inner lip + over(o, wc, (0.58 + 0.34 * th + 0.2 * exp(-pow(W.z / 1.5, 2.))) * cov); + // entrained bubbles ride the flow; they only move when the water does + float full = 1. - smoothstep(0.3, 1.5, PER - uLen); + for (int i = 0; i < 12; i++) { + float fi = float(i); + float bv = (hash11(fi + 1.3) * 2. - 1.) * 0.62; + float br = mix(0.5, 1.9, hash11(fi + 7.9) * hash11(fi + 3.1)); + float bk = 1. + 0.35 * (1. - 2. * bv * bv) + 0.2 * (hash11(fi + 4.4) - 0.5); + float bs = mod(hash11(fi + 9.2) * PER + bk * uMid, PER); + float bx = mod(uHead - bs + 24., PER) - 24.; + float fade = mix(smoothstep(4., 9., bx) * smoothstep(uLen, uLen - 9., bx), 1., full); + vec2 dl = vec2(W.y - bx, (vi - bv) * RI * HW); + dl.x -= PER * floor(dl.x / PER + 0.5); + float d = length(dl) - br; + if (d < 1.2 && fade > 0.) { + float f = fade * cov; + over(o, mix(wc, vec3(1.), 0.5), clamp(-d / uPx + 0.5, 0., 1.) * 0.3 * f); + over(o, wc * 0.3, exp(-pow(d / 0.28, 2.)) * 0.6 * f); + over(o, hiC, exp(-pow(length(dl - hl * br * 0.42) / (0.22 * br + 0.12), 2.)) * 0.9 * f); + } + } + } + // front wall, reflections + over(o, gTint, gA * 0.3 * tube); + float ndh = max(dot(N, Hh), 0.); + float spec = pow(ndh, 110.) * 0.95 + pow(ndh, 14.) * 0.09; + spec += pow(max(dot(vec3(-N.xy, N.z), Hh), 0.), 70.) * 0.28; // the back inner surface + float fres = pow(1. - N.z, 3.) * mix(0.12, 0.3, uDark); + float wl = exp(-pow((abs(v) - RI) * HW / 0.3, 2.)) * 0.2; // bore wall seen edge-on + over(o, hiC, (spec + fres + wl) * tube); + over(o, gTint * 0.55, exp(-pow((abs(v) - 1.) * HW / 0.45, 2.)) * mix(0.45, 0.1, uDark) * tube); + gl_FragColor = o; +}`,v=` +uniform vec4 uPuff[${c}]; // one puff per stretch of the frame: centre xy, radius, weight +const float W0 = ${f.toFixed(4)}; +float fbm(vec3 p) { float f = 0., a = 0.55; for (int i = 0; i < 4; i++) { f += a * snoise(p); p = p * 2.03 + vec3(1.7, 9.2, 3.1); a *= 0.42; } return f; } +vec2 warpAt(vec2 p) { vec3 np = vec3(p * 0.022, uTime * 0.12); return vec2(snoise(np), snoise(np + vec3(19.1, 7.3, 3.7))); } +// x: density, y: mean growth of the puffs here (released smoke has grown) +vec2 puffs(vec2 p, vec2 warp) { + float D = 0., G = 0.; + for (int i = 0; i < ${c}; i++) { + vec4 f = uPuff[i]; + float grow = f.z - W0; + vec2 q = p - warp * (1.5 + 0.6 * grow) - f.xy; // turbulence displaces older smoke further (kept below folding) + float g = f.w * exp(-dot(q, q) / (f.z * f.z)); + D += g; G += g * grow; + } + return vec2(D, G / max(D, 1e-5)); +} +void main() { + vec2 p = frag(); + vec2 wp = warpAt(p); + vec2 P = puffs(p, wp); + float ext = min(0.5 * uRes.x * uPx - abs(p.x), 0.5 * uRes.y * uPx - abs(p.y)); + P.x *= smoothstep(0., 16., ext); + if (P.x < 0.004) { gl_FragColor = vec4(0.); return; } + // billows: domain-warped noise evolving in place, eaten away as the smoke ages + vec2 pw = p - wp * (1.5 + 0.6 * P.y); + vec3 dp = vec3(pw * 0.035, uTime * 0.16); + vec2 q = vec2(snoise(dp), snoise(dp + vec3(5.2, 1.3, 2.8))); + float n = fbm(vec3(pw * 0.045 + 1.1 * q, uTime * 0.2 + 3.)); + float bil = smoothstep(-0.7, 0.55, n + 0.1 - 0.04 * P.y); + float d = P.x * (0.5 + 0.75 * bil); + // light from the upper right: shade by how much smoke lies toward it + vec2 pl = p + L2 * 7.; + float dl = puffs(pl, warpAt(pl)).x; + float lit = clamp(mix(0.55, 0.85, uDark) - (dl - P.x) * mix(1.3, 0.9, uDark), 0., 1.) * (0.88 + 0.16 * bil); + float a = 1. - exp(-d * 1.9); + vec3 shade = uColor * mix(vec3(0.62, 0.64, 0.70), vec3(0.50, 0.53, 0.60), uDark); + vec3 c = mix(shade, uColor, clamp(lit, 0., 1.)); + c += uColor * 0.18 * (1. - a) * lit; // thin wisps let light through + gl_FragColor = vec4(min(c, vec3(1.)) * a, a); +}`,E=` +uniform float uSegA, uLen, uMix, uMove, uHum, uTR; +uniform vec3 uColA, uColB; +uniform vec2 uPts[${h}]; +vec3 emit(float s) { + float x = mod(s - uSegA, PER); // distance ahead of the tail + float din = x <= uLen ? min(x, uLen - x) : -min(x - uLen, PER - x); + din = mix(din, 1e3, step(PER - 0.5, uLen)); + float on = smoothstep(-0.6, 0.6, din); + float strike = uMove * exp(-max(uLen - x, 0.) / 18.) * on; // the end being struck stutters while it runs + float fl = mix(1., 0.15 + 0.85 * step(0.3, hash12(vec2(floor(x / 6.), floor(uTime * 30.)))), strike); + float after = uMove * exp(-mod(uSegA - s, PER) / 10.) * (1. - on) * 0.6; // the tail lets go with an afterglow + vec3 col = mix(uColB, uColA, uMix); + return (col * (on * fl * (1. + 0.6 * strike) + after) + vec3(0.35) * strike * fl) * uHum; +} +void main() { + vec2 p = frag(); + float dc = sdRB(p), d = abs(dc), s = pathS(p); + vec3 e = emit(s); + // light spilling onto the wall: integrated over the whole tube so every lit stretch contributes + vec3 g = vec3(0.); + for (int i = 0; i < ${h}; i++) { + vec2 dv = p - uPts[i]; + float r2 = dot(dv, dv); + g += emit((float(i) + 0.5) * (PER / ${h}.)) * (exp(-r2 / 60.) + 0.35 * exp(-r2 / 420.)); + } + g *= (PER / ${h}.) / 40.; + float vt = clamp(dc / uTR, -1., 1.); + float tm = clamp((uTR - d) / uPx + 0.5, 0., 1.); + float I = max(max(e.r, e.g), e.b); + float core = exp(-vt * vt * 3.2); + vec3 tubeL = e * (0.4 + 0.85 * core) + vec3(1.) * I * pow(core, 4.) * 0.55; // white-hot centre, saturated rim + vec3 nearL = e * exp(-max(d - uTR * 0.8, 0.) / 1.2) * 0.6; + vec3 L = g + nearL * (1. - tm) + tubeL * tm; + vec3 mapped = 1. - exp(-L * 1.25); + // the glass itself, visible where it is dark + vec2 n2 = normalize(p - clamp(p, -H, H) + 1e-4); + vec3 N = vec3(n2 * vt, sqrt(max(0., 1. - vt * vt))); + vec3 Hh = normalize(normalize(vec3(L2 * 0.78, 0.62)) + vec3(0., 0., 1.)); + vec3 gTint = mix(vec3(0.22, 0.24, 0.27), vec3(0.62, 0.66, 0.72), uDark); + vec4 o = vec4(0.); + over(o, gTint, tm * (0.14 + 0.35 * pow(1. - N.z, 2.)) * (1. - clamp(I, 0., 1.) * 0.6)); + if (uDark > 0.5) o.rgb += mapped; + else { // on paper light can't add; lay the hue down instead, keeping it saturated + vec3 Lc = g + nearL * (1. - tm) + e * (0.4 + 0.85 * core) * tm; + float m = max(max(Lc.r, Lc.g), Lc.b); + over(o, Lc / max(m, 1e-3), (1. - exp(-m * 1.4)) * mix(0.85, 1., tm)); + over(o, vec3(1.), pow(core, 4.) * min(I, 1.) * 0.6 * tm); + } + over(o, vec3(1.), pow(max(dot(N, Hh), 0.), 60.) * 0.5 * tm); + gl_FragColor = o; +}`,p={water:L,smoke:v,neon:E},y={water:1.3,smoke:1.9,neon:1.8},x={water:{color:"#2FA8FF"},smoke:{color:"#F5F5F2"},neon:{colors:["#FF2E88","#2EF0FF","#FFB020","#7CFF4F","#9B5CFF"],tube:.58}},M={sequence:"LUCIO",hold:.7,morph:.45,speed:1,size:96},F=m=>{let S=m.replace("#",""),z=S.length===3?S.split("").map(d=>d+d).join(""):S;return[0,2,4].map(d=>parseInt(z.slice(d,d+2),16)/255)},w=()=>n.matchMedia&&n.matchMedia("(prefers-reduced-motion: reduce)").matches,T=m=>m<.5?4*m*m*m:1-Math.pow(-2*m+2,3)/2,A=m=>m-Math.floor(m),P=m=>A(Math.sin(m*127.1+11.7)*43758.5453),N=(m,S,z)=>{let d=Math.min(1,Math.max(0,(z-m)/(S-m)));return d*d*(3-2*d)};function C(m){for(let S=m;S&&S.nodeType===1;S=S.parentElement){let z=getComputedStyle(S).backgroundColor.match(/[\d.]+/g);if(z&&(z.length<4||+z[3]>.5))return(.2126*z[0]+.7152*z[1]+.0722*z[2])/255<.5}return!!(n.matchMedia&&n.matchMedia("(prefers-color-scheme: dark)").matches)}let R={C:[0,.75],L:[.25,.75],U:[.25,1],I:[.75,1],O:[.75,1.75]};function _(m){let S=()=>{let X=(m.sequence||"LUCIO").toUpperCase().split("").filter(U=>R[U]);return X.length?X:["O"]},z=(X,U)=>{let[q,I]=R[U];for(let j=-1;j<6;j++)if(q+j>=X[0]-1e-6&&I+j>=X[1]-1e-6)return[q+j,I+j];return[q,I]},d={i:0,j:0,seg:R[S()[0]].slice(),u:1,f:1,moving:!1,travel:0,vHead:0},H=d.seg,D=d.seg,u=0;return d.step=X=>{let U=d.seg.slice();if(u+=X,!d.moving&&u>=m.hold){let q=S();d.j=(d.i+1)%q.length,H=d.seg.slice(),D=z(d.seg,q[d.j]),d.moving=!0,u-=m.hold}if(d.moving){let q=w()?0:m.morph;d.f=q>0?Math.min(1,u/q):1,d.u=T(d.f),d.seg=[H[0]+(D[0]-H[0])*d.u,H[1]+(D[1]-H[1])*d.u],d.f>=1&&(d.moving=!1,d.i=d.j,u=0)}else d.f=1,d.u=1;if(d.travel+=(d.seg[0]-U[0]+(d.seg[1]-U[1]))/2*a,d.vHead=X>0?(d.seg[1]-U[1])*a/X:0,!d.moving){let q=Math.floor(d.seg[0]);d.seg[0]-=q,d.seg[1]-=q}},d.units=()=>({a:a*(d.seg[0]+.25),len:Math.min(a,(d.seg[1]-d.seg[0])*a)}),d.reset=()=>{d.i=d.j=0,d.seg=R[S()[0]].slice(),d.moving=!1,u=0},d}let O=new Set,$=0,Q=0;function pe(m){let S=Q?Math.min(.1,(m-Q)/1e3):0;Q=m;for(let z of O)z.frame(S);$=O.size?requestAnimationFrame(pe):0,$||(Q=0)}function oe(m,S,z){let d=Object.assign({},M,x[m],z||{}),H=document.createElement("div");H.className="lucio-fx lucio-fx-"+m,H.setAttribute("role","img"),H.setAttribute("aria-label","Loading"),H.style.cssText="position:relative;display:inline-block;vertical-align:middle;flex:none";let D=document.createElement("canvas");D.style.cssText="position:absolute;pointer-events:none",H.appendChild(D),S.appendChild(H);let u=D.getContext("webgl",{premultipliedAlpha:!0,alpha:!0,antialias:!1});if(!u)return console.warn("LucioLoaders: WebGL unavailable"),null;let X=(k,K)=>{let W=u.createShader(k);if(u.shaderSource(W,K),u.compileShader(W),!u.getShaderParameter(W,u.COMPILE_STATUS))throw new Error(m+": "+u.getShaderInfoLog(W));return W},U=u.createProgram();if(u.attachShader(U,X(u.VERTEX_SHADER,"attribute vec2 a; void main(){ gl_Position = vec4(a, 0., 1.); }")),u.attachShader(U,X(u.FRAGMENT_SHADER,g+p[m])),u.linkProgram(U),!u.getProgramParameter(U,u.LINK_STATUS))throw new Error(m+": "+u.getProgramInfoLog(U));u.useProgram(U),u.bindBuffer(u.ARRAY_BUFFER,u.createBuffer()),u.bufferData(u.ARRAY_BUFFER,new Float32Array([-1,-1,3,-1,-1,3]),u.STATIC_DRAW),u.enableVertexAttribArray(0),u.vertexAttribPointer(0,2,u.FLOAT,!1,0,0);let q={},I=k=>k in q?q[k]:q[k]=u.getUniformLocation(U,k);if(m==="neon"){let k=[];for(let K=0;K{if(W>=a-.5)return 1e3;let G=((k-K)%a+a)%a;return G<=W?Math.min(G,W-G):-Math.min(G-W,a-G)},ie=0,Ge=d.theme==="light"?!1:d.theme==="dark"?!0:C(S),Zt=0,bt=!0,xe=n.IntersectionObserver?new IntersectionObserver(k=>{bt=k[0].isIntersecting}):null;xe&&xe.observe(H);function yt(k){d.size=k;let K=Math.min(n.devicePixelRatio||1,2),W=k*y[m];H.style.width=H.style.height=k+"px",D.style.width=D.style.height=W+"px",D.style.left=D.style.top=-(W-k)/2+"px",D.width=D.height=Math.round(W*K),u.viewport(0,0,D.width,D.height),u.uniform2f(I("uRes"),D.width,D.height),u.uniform1f(I("uPx"),120/(k*D.width/W))}yt(d.size);function xt(k){if((d.theme==="auto"||!d.theme)&&++Zt%30===0&&(Ge=C(S)),!bt)return;k*=d.speed,ie+=k*(w()?.35:1),Y.step(k);let{a:K,len:W}=Y.units();if(u.uniform1f(I("uTime"),ie),u.uniform1f(I("uDark"),Ge?1:0),m==="water"){let le=A(Y.travel/70),B=A(Y.travel/70+.5);u.uniform3fv(I("uColor"),F(d.color)),u.uniform1f(I("uHead"),K+W),u.uniform1f(I("uLen"),W),u.uniform1f(I("uSurge"),Math.min(1,Math.max(0,Y.vHead/700))),u.uniform1f(I("uMid"),Y.travel),u.uniform1f(I("uFlowA"),le*70),u.uniform1f(I("uFlowB"),B*70),u.uniform1f(I("uFlowW"),1-Math.abs(2*B-1));for(let Z=0;Z-2&&(mt[Z]=ie),ft[Z]=Math.round(255*Math.exp(-(ie-mt[Z])/1.1));u.texImage2D(u.TEXTURE_2D,0,u.LUMINANCE,j,1,0,u.LUMINANCE,u.UNSIGNED_BYTE,ft)}else if(m==="smoke"){u.uniform3fv(I("uColor"),F(d.color));let G=1-Math.exp(-k*20),le=Math.exp(-k*4.2);for(let B=0;B=ae[B]?(ae[B]+=(Ve-ae[B])*G,ye[B]*=Math.exp(-k*8)):(ae[B]=Math.max(Ve,ae[B]*le),ye[B]+=k);let Ze=f+10*ye[B],[Jt,$t]=b(Z);vt.set([Jt,$t+9*ye[B],Ze,ae[B]*(f*1.6/(Ze+.6*f))*(a/c)/(1.7725*Ze)],B*4)}u.uniform4fv(I("uPuff[0]"),vt)}else{let G=d.colors.map(F),le=G.length;u.uniform1f(I("uTR"),10.2*d.tube),u.uniform1f(I("uHum"),.975+.025*Math.sin(ie*46)*Math.sin(ie*7.3)+(P(Math.floor(ie*9))>.985?-.2:0)),u.uniform1f(I("uSegA"),K),u.uniform1f(I("uLen"),W),u.uniform3fv(I("uColB"),G[Y.i%le]),u.uniform3fv(I("uColA"),G[(Y.moving?Y.j:Y.i)%le]),u.uniform1f(I("uMix"),Y.moving?N(.05,.35,Y.f):1),u.uniform1f(I("uMove"),Y.moving?Math.sin(Math.PI*Y.f):0)}u.drawArrays(u.TRIANGLES,0,3)}let wt={frame:xt};return O.add(wt),$||($=requestAnimationFrame(pe)),{el:H,canvas:D,tick:xt,setColor(k){d.color=k,m==="neon"&&(d.colors=[k])},setColors(k){d.colors=k.slice()},setTiming({hold:k,morph:K}){k!=null&&(d.hold=k),K!=null&&(d.morph=K)},setSequence(k){d.sequence=k,Y.reset()},setSpeed(k){d.speed=k},setSize:yt,setTheme(k){d.theme=k,Ge=k==="light"?!1:k==="dark"?!0:C(S)},stop(){O.delete(wt),xe&&xe.disconnect(),H.remove();let k=u.getExtension("WEBGL_lose_context");k&&k.loseContext()}}}n.LucioLoaders={water:(m,S)=>oe("water",m,S),smoke:(m,S)=>oe("smoke",m,S),neon:(m,S)=>oe("neon",m,S),geometry:{HB:49.8,CR:16.2,HW:10.2,PER:a,pathP:b,LET:R}}})(window);var J={graphite:"#111114",graphite3:"#26262D",paper:"#F3F1EC",beam:"#FFF3CF",smoke:"#F5F5F2"};function we(){return window.LucioMorph??null}function se(n,e){let t=we();if(!t)return null;let i=document.createElement("span");i.className="wordmark-svg",i.setAttribute("aria-hidden","true"),n.appendChild(i);let s=t.wordmark(i,{trigger:"manual",color:J.paper,rays:J.beam});return s.svg.setAttribute("aria-hidden","true"),s.svg.removeAttribute("role"),e||s.set(1),n.classList.add("has-svg"),s}var Qt=44;function Mt(n){return Math.round(n.getBoundingClientRect().width)||Qt}function me(n){if(n.dataset.mounted==="1")return;let e=Mt(n),t=window.LucioLoaders,i=Array.from(n.childNodes);n.replaceChildren();let s=null;try{s=t?t.smoke(n,{size:e,theme:"dark",color:J.smoke}):null}catch{s=null}if(s){s.el.removeAttribute("role"),s.el.removeAttribute("aria-label");let r=s;if(typeof ResizeObserver=="function"){let o=e;new ResizeObserver(()=>{let a=Mt(n);a!==o&&(o=a,r.setSize(a))}).observe(n)}}else{n.replaceChildren();let r=we();if(r){let o=r.loader(n,{size:e,color:J.paper,track:null,rays:J.beam}).svg;o.setAttribute("aria-hidden","true"),o.style.width="100%",o.style.height="auto"}else n.append(...i)}n.dataset.mounted="1"}function ei(n){let e=n.seed+"|"+n.level+"|"+n.x+"|"+n.y,t=2166136261;for(let i=0;i>>0;return t}function ti(n,e){let t=new Array(n);for(let r=0;r{i=i+1831565813|0;let r=Math.imul(i^i>>>15,1|i);return r=r+Math.imul(r^r>>>7,61|r)^r,((r^r>>>14)>>>0)/4294967296};for(let r=n-1;r>0;r--){let o=Math.floor(s()*(r+1)),a=t[r];t[r]=t[o],t[o]=a}return t}function Lt(n,e,t,i,s){n.drawImage(e,0,0);let r=s.cell,o=Math.floor(t/r),a=Math.floor(i/r);if(o<2||a<2)return;let l=o*a,h=ti(l,ei(s));for(let c=0;c"u"||t==="")return;let i=(navigator.hardwareConcurrency??2)>=4?2:1;for(let s=0;sthis.onReply(a.data,o),r.onerror=()=>this.dropWorker(o),this.workers.push(r)}catch{break}}request(e,t,i,s,r){return s.aborted?Promise.reject(new V):new Promise((o,a)=>{let l=this.byId.get(e);l?i{c.waiters.delete(h)&&(a(new V),c.waiters.size===0&&setTimeout(()=>{c.waiters.size===0&&this.byKey.get(c.key)===c&&this.cancel(c)},0))},{once:!0}),this.pump()})}cancelAll(){for(let e of[...this.byKey.values()]){let t=[...e.waiters];e.waiters.clear();for(let i of t)i.reject(new V);this.cancel(e)}}cancel(e){if(this.forget(e),!e.running){let t=this.queue.indexOf(e);t>=0&&this.queue.splice(t,1);return}e.running=!1,this.running--,e.controller?e.controller.abort():e.worker>=0&&this.workers[e.worker]&&this.workers[e.worker].postMessage({type:"abort",key:e.key}),this.pump()}forget(e){this.byId.get(e.id)===e&&this.byId.delete(e.id),this.byKey.delete(e.key)}pump(){for(;this.running0;){let e=0;for(let i=1;i0&&(!e.scramble||this.workersUnscramble)){let i=t[this.nextWorker++%t.length];e.worker=i,this.workers[i].postMessage({type:"fetch",key:e.key,url:e.url,scramble:e.scramble});return}this.runOnMainThread(e)}runOnMainThread(e){e.worker=-1,e.controller=new AbortController,this.fetchOnMainThread(e,e.controller.signal)}liveWorkers(){let e=[];return this.workers.forEach((t,i)=>{t&&e.push(i)}),e}dropWorker(e){let t=this.workers[e];if(t){t.terminate(),delete this.workers[e];for(let i of this.byKey.values())i.running&&i.worker===e&&this.runOnMainThread(i)}}async fetchOnMainThread(e,t){let i=performance.now();try{let s=await fetch(e.url,{signal:t,credentials:"same-origin"});if(!s.ok)throw new Error("HTTP "+s.status);let r=await s.blob(),o=performance.now()-i,a=await Je(r);e.scramble&&(a=await ii(a,e.scramble)),this.onReply({key:e.key,ok:!0,bitmap:a,bytes:r.size,ms:o},-1)}catch(s){this.onReply({key:e.key,ok:!1,bytes:0,ms:0,error:String(s)},-1)}}onReply(e,t){let i=this.byKey.get(e.key);if(!i||!i.running||i.worker!==t){e.bitmap&&ee(e.bitmap);return}if(!e.ok&&t>=0&&(e.error==="unsupported-bitmap"||e.error==="unsupported-offscreen")){e.error==="unsupported-bitmap"?this.dropWorker(t):(this.workersUnscramble=!1,this.runOnMainThread(i));return}i.running=!1,this.running--,this.forget(i);let s=[...i.waiters];if(i.waiters.clear(),e.ok&&e.bitmap){let r={bitmap:e.bitmap,bytes:e.bytes,ms:e.ms};for(let o of s)o.resolve(r);s.length===0&&ee(e.bitmap)}else{let r=new Error(e.error??"tile failed");for(let o of s)o.reject(r)}this.pump()}};var kt=1024*1024;function si(){let n=navigator.deviceMemory;if(typeof n=="number"&&n<=4)return!0;let e=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,t=Math.min(screen.width,screen.height);return e&&t<=820}function Et(){return si()?120*kt:250*kt}var Ee=class{constructor(e){this.budget=e;this.entries=new Map;this.used=0}get(e){let t=this.entries.get(e);return t&&(this.entries.delete(e),this.entries.set(e,t)),t}has(e){return this.entries.has(e)}put(e,t){let i=this.entries.get(e);if(i){i.bitmap!==t&&ee(t);return}let s=t.width*t.height*4;this.entries.set(e,{bitmap:t,bytes:s,at:performance.now()}),this.used+=s,this.trim(this.budget)}trim(e){for(;this.used>e&&this.entries.size>0;){let t=this.entries.keys().next();if(t.done)return;let i=this.entries.get(t.value);this.entries.delete(t.value),i&&(this.used-=i.bytes,ee(i.bitmap))}}};var At="luphoto.entropy";var ri=Math.cos(Math.PI/6),ni=100,oi=10,$e=class{constructor(){this.path=0;this.turns=0;this.cells=0;this.gestures=0;this.scrolls=0;this.keys=0;this.seen=new Uint32Array(128);this.lastX=0;this.lastY=0;this.hasLast=!1;this.segX=0;this.segY=0;this.prevX=0;this.prevY=0;this.hasPrev=!1;this.touchId=-1;this.touchX=0;this.touchY=0;this.touchMoved=!1;this.lastScroll=-1/0;this.memory=null;this.load();let e={passive:!0,capture:!0};addEventListener("pointermove",t=>this.onMove(t),e),addEventListener("pointerdown",t=>this.onDown(t),e),addEventListener("pointerup",t=>this.onUp(t),e),addEventListener("pointercancel",t=>this.onCancel(t),e),addEventListener("wheel",t=>this.onScroll(t),e),addEventListener("scroll",t=>this.onScroll(t),e),addEventListener("keydown",t=>this.onKey(t),e),addEventListener("pagehide",()=>this.save()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.save()})}onMove(e){if(!e.isTrusted)return;let t=e.clientX,i=e.clientY;if(e.pointerType!=="mouse"){e.pointerId===this.touchId&&!this.touchMoved&&Math.abs(t-this.touchX)+Math.abs(i-this.touchY)>oi&&(this.touchMoved=!0);return}let s=((t>>3)*73856093^(i>>3)*19349663)&4095,r=1<<(s&31);if(this.seen[s>>>5]&r||(this.seen[s>>>5]|=r,this.cells++),!this.hasLast){this.lastX=t,this.lastY=i,this.hasLast=!0;return}let o=t-this.lastX,a=i-this.lastY;if(this.lastX=t,this.lastY=i,o===0&&a===0)return;this.path+=Math.sqrt(o*o+a*a),this.segX+=o,this.segY+=a;let l=Math.sqrt(this.segX*this.segX+this.segY*this.segY);if(!(l<8)){if(this.hasPrev){let h=Math.sqrt(this.prevX*this.prevX+this.prevY*this.prevY);(this.segX*this.prevX+this.segY*this.prevY)/(l*h)=ni&&(this.lastScroll=e.timeStamp,this.scrolls++)}onKey(e){e.isTrusted&&!e.repeat&&this.keys++}score(){let t=Math.min(25,this.path/120)+Math.min(35,this.turns*2.5)+Math.min(20,this.cells/6)+Math.min(45,this.gestures*8)+Math.min(15,this.scrolls*1.5)+Math.min(20,this.keys*2);return this.save(),Math.min(100,Math.round(t))}load(){let e=null;try{let i=sessionStorage.getItem(At);e=i?JSON.parse(i):null}catch{e=this.memory}if(!e)return;let t=i=>typeof i=="number"&&Number.isFinite(i)&&i>0?i:0;this.path=t(e.p),this.turns=t(e.t),this.cells=t(e.c),this.gestures=t(e.g),this.scrolls=t(e.s),this.keys=t(e.k)}save(){let e={p:Math.round(this.path),t:this.turns,c:this.cells,g:this.gestures,s:this.scrolls,k:this.keys};this.memory=e;try{sessionStorage.setItem(At,JSON.stringify(e))}catch{return}}},Qe=null;function et(){Qe??(Qe=new $e)}function Ae(){return et(),Qe?Qe.score():0}var ai=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),st=new Int32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function St(n,e){for(let t=e;t<64;t++){let i=n[t-15],s=n[t-2],r=(i>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,o=(s>>>17|s<<15)^(s>>>19|s<<13)^s>>>10;n[t]=n[t-16]+r+n[t-7]+o|0}}function rt(n,e,t,i){let s=n[0],r=n[1],o=n[2],a=n[3],l=n[4],h=n[5],c=n[6],f=n[7];for(let b=t;b>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7))+(l&h^~l&c)+ai[b]+e[b]|0,L=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&r^s&o^r&o)|0;f=c,c=h,h=l,l=a+g|0,a=o,o=r,r=s,s=g+L|0}n[0]=s,n[1]=r,n[2]=o,n[3]=a,n[4]=l,n[5]=h,n[6]=c,n[7]=f}var tt=new Int32Array(64),it=new Int32Array(8),te=new Int32Array(8);function li(n,e=new Uint8Array(32)){te.set(st);let t=n.length,i=Math.ceil((t+9)/64);for(let s=0;s=r+56){let f=h-r-56;c=f<3?0:f===3?t>>>29&255:t*8>>>(7-f)*8&255}a=a<<8|c}tt[o]=a}St(tt,16),it.set(te),rt(it,tt,0,64);for(let o=0;o<8;o++)te[o]=te[o]+it[o]|0}for(let s=0;s<8;s++)e[s*4]=te[s]>>>24,e[s*4+1]=te[s]>>>16&255,e[s*4+2]=te[s]>>>8&255,e[s*4+3]=te[s]&255;return e}var Ce=4294967296,Pe=class{constructor(e,t){this.w=new Int32Array(64);this.mid=new Int32Array(8);this.s=new Int32Array(8);let i=this.w;for(let s=0;s<8;s++)i[s]=e.charCodeAt(s*4)<<24|e.charCodeAt(s*4+1)<<16|e.charCodeAt(s*4+2)<<8|e.charCodeAt(s*4+3);i[10]=-2147483648,i[15]=320,this.mid.set(st),rt(this.mid,i,0,8),this.shift=32-Math.max(1,Math.min(32,t))}run(e,t,i){let s=this.w,r=this.s,o=this.mid,a=this.shift,l=st[0];s[8]=e|0;for(let h=t;h>>a))return h;return-1}},Se="luphoto-sealed-1",Te=12;function Ie(n){let e=new Uint8Array(n.length>>>1);for(let t=0;t>>24,i[45]=o>>>16&255,i[46]=o>>>8&255,i[47]=o&255,li(i,s);let l=Math.min(32,r.length-a);for(let h=0;h=0&&i<=hi}catch{return!1}}async function ve(n){let e=await fetch("/k",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!e.ok)throw new he(e.status,Number(e.headers.get("Retry-After"))||0);return await e.json()}function ot(n){return new Promise(e=>{let t=new Pe(n.token,n.bits),i=0,s=0,r=()=>{let o=Math.min(Ce,s+ui),a=t.run(i,s,o);if(a>=0){e(i*Ce+a);return}s=o,s>=Ce&&(i++,s=0),setTimeout(r,0)};setTimeout(r,0)})}function mi(n,e){return n.token.length!==32||!(n.bits>=1&&n.bits<=32)?Promise.reject(new Error("puzzle")):typeof Worker>"u"||!e?ot(n):new Promise((t,i)=>{let s;try{s=new Worker(e)}catch{t(ot(n));return}s.onmessage=r=>{let o=r.data.pow;typeof o=="number"&&(s.terminate(),o<0?i(new Error("puzzle")):t(o))},s.onerror=()=>{s.terminate(),t(ot(n))},s.postMessage({type:"pow",token:n.token,bits:n.bits})})}var Re=null;function ut(n,e,t,i){if(Re)return Re.then(()=>null);let s=new Promise(r=>{let o=()=>{},a=new Promise(c=>{o=c}),l=new ct(()=>{o(),l.wait()},i?()=>r(null):null);(async()=>{let c=await n;for(;c.challenge;){let f=c.challenge,b=mi(f,t);await a,c=await e({token:f.token,nonce:await b})}return c})().then(c=>{l.dismiss(),r(c)},()=>{l.fail(),r(null)})});return Re=s,s.then(()=>{Re=null}),s}function Fe(n,e,t){n.addEventListener("click",i=>{let s=e();if(i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||!s)return;if(t.score()>=t.minEntropy()||ze()){Ct(s);return}i.preventDefault();let r=n.href,o=()=>({build:t.build,album:s,photos:[],context:"nav",entropy:t.score()});ut(ve(o()),a=>ve({...o(),challenge:a}),t.workerUrl,!0).then(a=>{a&&(a.pass&&He(a.pass),Ct(s),location.assign(r))})})}function fi(n,e){try{n.setPointerCapture(e)}catch{return}}var ct=class{constructor(e,t){this.onHeld=e;this.onCancel=t;this.inert=[];this.start=0;this.frame=0;this.holding=!1;this.finished=!1;this.gone=!1;this.onEscape=e=>{e.key==="Escape"&&!this.gone&&(e.preventDefault(),e.stopPropagation(),this.dismiss(),this.onCancel?.())};this.restore=document.activeElement;let i=document.createElement("div");i.className="gate",i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-labelledby","gate-line");let s=document.createElement("div");s.className="gate-card";let r=document.createElement("p");r.className="gate-eyebrow",r.textContent="Photos \xB7 Lucio";let o=document.createElement("p");o.className="gate-line",o.id="gate-line",o.textContent=di;let a=document.createElement("button");a.type="button",a.className="gate-hold",a.setAttribute("aria-label","Hold to see the photos"),a.setAttribute("aria-describedby","gate-status");let l=document.createElementNS(Pt,"svg");l.setAttribute("viewBox","0 0 64 64"),l.setAttribute("aria-hidden","true"),l.setAttribute("focusable","false");let h=(b,g)=>{let L=document.createElementNS(Pt,"circle");return L.setAttribute("class",b),L.setAttribute("cx","32"),L.setAttribute("cy","32"),L.setAttribute("r",g),L},c=h("gate-ring","28");c.setAttribute("pathLength","100"),l.append(h("gate-track","28"),c,h("gate-dot","6")),a.appendChild(l);let f=document.createElement("p");f.className="visually-hidden",f.id="gate-status",f.setAttribute("aria-live","polite"),s.append(r,o,a,f),i.appendChild(s),this.root=i,this.button=a,this.ring=c,this.status=f,this.text=o;for(let b of Array.from(document.body.children))b.hasAttribute("inert")||(b.setAttribute("inert",""),this.inert.push(b));document.body.appendChild(i),document.documentElement.classList.add("has-gate"),this.bind(),a.focus({preventScroll:!0})}bind(){let e=this.button;e.addEventListener("pointerdown",t=>{t.pointerType==="mouse"&&t.button!==0||(t.preventDefault(),fi(e,t.pointerId),this.press())});for(let t of["pointerup","pointercancel","lostpointercapture"])e.addEventListener(t,()=>this.release());e.addEventListener("keydown",t=>{(t.key===" "||t.key==="Enter")&&(t.preventDefault(),t.repeat||this.press())}),e.addEventListener("keyup",t=>{(t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.release())}),e.addEventListener("blur",()=>this.release()),e.addEventListener("click",t=>t.preventDefault()),e.addEventListener("contextmenu",t=>t.preventDefault()),this.root.addEventListener("transitionend",t=>{t.target===this.root&&this.root.classList.contains("is-leaving")&&this.root.remove()}),this.onCancel&&document.addEventListener("keydown",this.onEscape,!0)}setProgress(e){this.ring.style.setProperty("stroke-dashoffset",String(100-Math.max(0,Math.min(1,e))*100))}press(){if(this.holding||this.finished)return;this.holding=!0,this.start=performance.now(),this.button.classList.add("is-pressed"),this.status.textContent="Keep holding";let e=t=>{if(!this.holding)return;let i=(t-this.start)/ci;if(this.setProgress(i),i>=1){this.holding=!1,this.finished=!0,this.frame=0,this.button.classList.remove("is-pressed"),this.onHeld();return}this.frame=requestAnimationFrame(e)};this.frame=requestAnimationFrame(e)}release(){this.holding&&(this.holding=!1,cancelAnimationFrame(this.frame),this.frame=0,this.button.classList.remove("is-pressed"),this.setProgress(0),this.status.textContent="")}wait(){this.root.classList.add("is-waiting"),this.setProgress(.28),this.status.textContent="One moment"}fail(){this.root.classList.remove("is-waiting"),this.finished=!0,this.setProgress(0),this.button.disabled=!0,this.text.textContent="Something went wrong. Reload the page to try again.",this.status.textContent=this.text.textContent}dismiss(){if(this.gone)return;this.gone=!0,document.removeEventListener("keydown",this.onEscape,!0),cancelAnimationFrame(this.frame);let e=this.root.contains(document.activeElement);for(let t of this.inert)t.removeAttribute("inert");document.documentElement.classList.remove("has-gate"),this.root.classList.add("is-leaving"),window.setTimeout(()=>this.root.remove(),400),e&&(this.restore instanceof HTMLElement&&this.restore!==document.body&&this.restore.isConnected?this.restore:document.querySelector("main"))?.focus({preventScroll:!0})}};var vi=400,ce=class{constructor(e,t=()=>!0){this.canShow=t;this.handle=null;this.loader=null;this.timer=0;this.hideTimer=0;this.visible=!1;this.element=document.createElement("div"),this.element.className="busy",this.element.setAttribute("role","status"),this.element.setAttribute("aria-label","Loading"),e.appendChild(this.element)}watch(e){if(e===this.loader){this.update(e);return}this.loader=e,clearTimeout(this.timer),this.timer=0,this.hide(),this.update(e)}update(e){if(!e||e!==this.loader)return;let t=e.status;if(!t.active||t.sharp){clearTimeout(this.timer),this.timer=0,this.hide();return}if(!this.visible&&this.timer===0){let i=Math.max(0,vi-(performance.now()-t.started));this.timer=window.setTimeout(()=>this.check(),i)}}check(){this.timer=0;let e=this.loader;if(!(!e||!e.status.active||e.status.sharp)){if(!this.canShow()){this.timer=window.setTimeout(()=>this.check(),100);return}this.show()}}show(){if(!this.visible){if(clearTimeout(this.hideTimer),this.visible=!0,!this.handle){let e=we();e&&(this.handle=e.loader(this.element,{size:56,color:J.paper,track:J.graphite3,rays:J.beam}),this.handle.svg.setAttribute("aria-hidden","true"))}this.element.classList.add("is-visible")}}hide(){this.visible&&(this.visible=!1,this.element.classList.remove("is-visible"),clearTimeout(this.hideTimer),this.hideTimer=window.setTimeout(()=>{!this.visible&&this.handle&&(this.handle.stop(),this.handle.svg.remove(),this.handle=null)},300))}},Ne=class{constructor(e){this.loader=null;this.shown=!1;this.value=-1;this.element=document.createElement("div"),this.element.className="progress",this.element.setAttribute("aria-hidden","true"),e.appendChild(this.element)}watch(e){this.loader=e,this.value=-1,this.update(e)}update(e){if(!e||e!==this.loader)return;let t=e.status,i=t.active&&!t.sharp&&t.planned>0,s=t.planned>0?Math.min(1,t.done/t.planned):0;i!==this.shown&&(this.shown=i,this.element.classList.toggle("is-visible",i));let r=Math.round(s*1e3)/1e3;r!==this.value&&(this.value=r,this.element.style.transform="scaleX("+(i?r:1)+")")}};function qe(n,e,t){let i=e*t;for(let s=0;s=i)return s;return n.levels.length-1}function ge(n,e){let t=n.tile_size,i=Math.max(0,e.u0*n.width),s=Math.min(n.width,e.u1*n.width),r=Math.max(0,e.v0*n.height),o=Math.min(n.height,e.v1*n.height);return s<=i||o<=r?null:{x0:Math.min(n.cols-1,Math.floor(i/t)),x1:Math.min(n.cols-1,Math.ceil(s/t)-1),y0:Math.min(n.rows-1,Math.floor(r/t)),y1:Math.min(n.rows-1,Math.ceil(o/t)-1)}}function Rt(n,e,t){let i=n.levels[e],s=i.tile_size,r=ge(i,t);if(!r)return[];let o=(t.u0+t.u1)/2*i.width,a=(t.v0+t.v1)/2*i.height,l=[];for(let h=r.y0;h<=r.y1;h++)for(let c=r.x0;c<=r.x1;c++){let f=(c*s+Math.min((c+1)*s,i.width))/2,b=(h*s+Math.min((h+1)*s,i.height))/2;l.push({level:e,x:c,y:h,index:h*i.cols+c,distance:(f-o)**2+(b-a)**2})}return l.sort((h,c)=>h.distance-c.distance),l.map(({level:h,x:c,y:f,index:b})=>({level:h,x:c,y:f,index:b}))}function zt(n,e,t,i,s,r){let o=n.tile_size,a=Math.round(i+e*o*r),l=Math.round(i+Math.min((e+1)*o,n.width)*r),h=Math.round(s+t*o*r),c=Math.round(s+Math.min((t+1)*o,n.height)*r);return l<=a||c<=h?null:{dx:a,dy:h,dw:l-a,dh:c-h}}function Ht(n,e,t,i,s,r,o,a){let l=t.tile_size,h=t.overlap??0,c=i*l,f=Math.min((i+1)*l,t.width),b=s*l,g=Math.min((s+1)*l,t.height),L=i>0?c-h:0,v=s>0?b-h:0,E=Math.round(r+c*a),p=Math.round(r+f*a),y=Math.round(o+b*a),x=Math.round(o+g*a);if(p<=E||x<=y)return;let M=Math.max(L,(E-r)/a),F=Math.min(L+e.width,(p-r)/a),w=Math.max(v,(y-o)/a),T=Math.min(v+e.height,(x-o)/a);F<=M||T<=w||n.drawImage(e,M-L,w-v,F-M,T-w,E,y,p-E,x-y)}var Ft="luphoto.throughput";function Nt(){try{let n=Number(sessionStorage.getItem(Ft));return Number.isFinite(n)&&n>0?n:null}catch{return null}}function dt(){return Nt()??1e3}function De(n){let e=Nt(),t=e===null?n:e*(1-.5)+n*.5;try{sessionStorage.setItem(Ft,String(t))}catch{return t}return t}var re=180,qt=400,gi=2e3,ne=16,pt="j:";function bi(n,e){return new Promise((t,i)=>{if(e.aborted){i(new V);return}let s=setTimeout(()=>{e.removeEventListener("abort",r),t()},n),r=()=>{clearTimeout(s),i(new V)};e.addEventListener("abort",r,{once:!0})})}function yi(n,e,t){return e.aborted?Promise.resolve(t):new Promise(i=>{let s=()=>i(t);e.addEventListener("abort",s,{once:!0}),n.then(r=>{e.removeEventListener("abort",s),i(r)})})}var Dt=3,We=4,xi=6e3,wi=4e3,Mi=1500,Li=.35;function ki(){let n=navigator.connection;return!!n&&(n.saveData===!0||/2g|3g/.test(n.effectiveType??""))}function Ei(){let n=navigator;return(n.hardwareConcurrency??4)<4?!1:typeof n.deviceMemory!="number"||n.deviceMemory>=4}function Wt(n,e){let t=0;for(let i of n)i.status==="fulfilled"&&(t+=i.value.bytes);return t>0&&e>0?t/e:0}var ue=class{constructor(e,t,i){this.pyramid=e;this.poolUrl=t;this.env=i;this.seedImage=null;this.seedPromise=null;this.seedAt=0;this.pool=null;this.sealed="";this.poolPromise=null;this.poolRetryAt=0;this.opened=null;this.ids=null;this.triedKey=null;this.jumbleLevel=-1;this.jumble=[];this.settling=!1;this.session=null;this.prefetchController=null;this.enhancer=null;this.enhanceLevel=-1;this.finalLevel=-1;this.targetLevel=-1;this.status={active:!1,started:0,planned:0,done:0,sharp:!1}}get stalled(){return!this.opened&&!this.settling}tileUrl(e){let t=this.env.tiles;return t.path+this.pyramid.hash+"/"+e+"."+t.format}ensurePool(){return this.pool?Promise.resolve(!0):(this.poolPromise||(this.poolPromise=fetch(this.poolUrl,{credentials:"same-origin"}).then(e=>e.ok?e.json():Promise.reject(new Error("pool"))).then(e=>{let t=this.pyramid.levels;if(!Array.isArray(e.levels)||e.levels.length!==t.length||typeof e.sealed!="string")throw new Error("pool");for(let i=0;i(this.poolPromise=null,this.poolRetryAt=performance.now()+gi,!1))),this.poolPromise)}open(){if(this.opened)return!0;let e=this.env.keys.key(this.pyramid.hash),t=this.pool;if(!e||!t||e===this.triedKey)return!1;this.triedKey=e;let i=Tt(e,this.sealed),s=null;if(i)try{s=JSON.parse(new TextDecoder().decode(i))}catch{s=null}let r=this.pyramid.levels;if(!s||!Array.isArray(s.levels)||s.levels.length!==r.length)return!1;let o=[];for(let a=0;a=0&&b=this.poolRetryAt&&this.ensurePool();return}this.opened||this.open()}ensureSeed(){return this.opened?(this.seedPromise||(this.seedPromise=this.decodeSeed().then(()=>{this.seedAt=performance.now(),this.env.requestDraw()},()=>{})),this.seedPromise):Promise.resolve()}async decodeSeed(){let e=this.opened?.seed;if(!e)return;let t=await Je(new Blob([nt(e)],{type:"image/"+this.env.tiles.format})),i=document.createElement("canvas");i.width=t.width*We,i.height=t.height*We;let s=i.getContext("2d");if(!s){this.seedImage=t;return}s.imageSmoothingEnabled=!0,s.imageSmoothingQuality="high","filter"in s&&(s.filter="blur("+We*.75+"px)");let r=We*2;s.drawImage(t,-r,-r,i.width+r*2,i.height+r*2),ee(t),this.seedImage=i}async request(e,t,i,s,r){let o=this.tileUrl(t),a;try{a=await this.env.scheduler.request(e,o,i,s,r)}catch(l){if(s.aborted||l instanceof V)throw l;await bi(qt+Math.random()*qt,s),a=await this.env.scheduler.request(e,o,i,s,r)}return this.env.cache.put(e,a.bitmap),this.env.requestDraw(),a}fetchTile(e,t,i){let s=this.ids,r=this.opened;if(!s||!r)return Promise.reject(new V);let o=s[e.level][e.index],a=this.env.tiles,l=a.cell??64,h=a.scrambled&&r.scramble&&this.pyramid.levels[e.level].tile_size>=2*l?{seed:r.scramble,level:e.level,x:e.x,y:e.y,cell:l}:void 0;return this.request(o,o,t,i,h)}fetchJumble(e,t,i){return this.request(pt+e,e,t,i)}uncached(e,t){let i=this.ids;return i?Rt(this.pyramid,e,t).filter(s=>!this.env.cache.has(i[e][s.index])):[]}uncachedBytes(e,t){let i=this.opened?.levels[e].bytes??[],s=0;for(let r of this.uncached(e,t))s+=i[r.index]??0;return s}chooseJumble(e,t){let i=this.pool;if(!i)return[];if(this.jumbleLevel<0){let s=this.probeLevel(e,t),r=this.pyramid.levels[s].cols*this.pyramid.levels[s].rows,o=i[s].length/ne,a=new Array(r);for(let l=0;l!this.env.cache.has(pt+s))}probeLevel(e,t){return Math.max(0,qe(this.pyramid,e.displayWidth,t)-Dt)}notify(){this.env.onStatus?.(this)}track(e,t){return this.status.planned+=e.length,this.notify(),Promise.allSettled(e.map(i=>i().finally(()=>{this.session===t&&(this.status.done++,this.notify())})))}start(e,t,i,s=!1){this.stopSession();let r=new AbortController;this.session=r,this.targetLevel=-1,this.status.active=!0,this.status.started=performance.now(),this.status.planned=0,this.status.done=0,this.status.sharp=!1,this.notify(),this.run(e,t,r).then(o=>{let a=this.session===r;a&&(this.session=null,this.status.active=!1,this.notify()),(!r.signal.aborted||r.signal.reason==="deadline")&&i(),s&&a&&o&&!r.signal.aborted&&this.enhance(e,o)})}async run(e,t,i){let s=i.signal,r=performance.now(),o=this.env.settings.budgetMs,a=setTimeout(()=>i.abort("deadline"),o);try{let l=await yi(this.ensurePool(),s,!1);if(s.aborted||l&&!this.open()&&(this.settling=!0,await this.env.keys.settle(this.pyramid.hash,s),this.settling=!1,s.aborted))return null;if(!l||!this.open()){let p=this.chooseJumble(e,t);return await this.track(p.map(y=>()=>this.fetchJumble(y,Le,s)),i),null}if(await this.ensureSeed(),s.aborted)return null;let h=qe(this.pyramid,e.displayWidth,t),c=Math.max(0,h-Dt),f=this.uncached(c,e).slice(0,2);if(f.length>0){let p=await this.track(f.map(M=>()=>this.fetchTile(M,Le,s)),i),y=0,x=0;for(let M of p)M.status==="fulfilled"&&(y+=M.value.bytes,x=Math.max(x,M.value.ms));y>0&&x>0&&De(y/x)}if(s.aborted)return null;this.finalLevel=Math.max(this.finalLevel,c);let b=dt(),g=o-(performance.now()-r),L=c;for(let p=h;p>c;p--)if(this.uncachedBytes(p,e)/b<=g*.8){L=p;break}let v=[];L-c>=2&&v.push(Math.floor((c+L)/2)),L>c&&v.push(L),this.finalLevel=L,this.targetLevel=L,this.env.requestDraw();let E=0;for(let p of v){let y=this.uncached(p,e),x=performance.now(),M=await this.track(y.map(w=>()=>this.fetchTile(w,Le,s)),i);if(s.aborted)return null;let F=y.length>=2?Wt(M,performance.now()-x):0;F>0&&(E=De(F))}return{needed:h,final:L,throughput:E||dt()}}finally{clearTimeout(a)}}async enhance(e,t){if(!this.opened||ki())return;let i=this.pyramid.levels,{needed:s}=t,r=Ei()?Math.min(i.length-1,s+1):s;if(t.final>=r)return;this.enhancer?.abort();let o=new AbortController;this.enhancer=o;let a=o.signal,l=this.env.cache.budget*Li,h=t.throughput,c=0;for(let f=Math.max(t.final+1,s);f<=r;f++){let b=f>s;if(b){let p=i[f],y=p.width*(e.u1-e.u0)*p.height*(e.v1-e.v0)*4;if(hl)break}if(c+=this.uncachedBytes(f,e)/h,c>(b?wi:xi))break;b&&(this.enhanceLevel=Math.max(this.enhanceLevel,f));let g=this.uncached(f,e),L=performance.now(),v=await Promise.allSettled(g.map(p=>this.fetchTile(p,ke,a)));if(a.aborted)return;let E=g.length>=2?Wt(v,performance.now()-L):0;E>0&&(h=De(E)),b||(this.finalLevel=Math.max(this.finalLevel,f))}this.enhancer===o&&(this.enhancer=null)}prefetchProbe(e,t){let s=this.resetPrefetch().signal;this.ensurePool().then(async r=>{if(!(s.aborted||!r||!this.open())&&(await this.ensureSeed(),!s.aborted))for(let o of this.uncached(this.probeLevel(e,t),e))this.fetchTile(o,ke,s).catch(()=>{})})}prefetchLevel(e,t){if(t<0||!this.opened)return;let i=this.resetPrefetch().signal;for(let s of this.uncached(t,e))this.fetchTile(s,ke,i).catch(()=>{})}resetPrefetch(){return this.prefetchController?.abort(),this.prefetchController=new AbortController,this.prefetchController}stopPrefetch(){this.prefetchController?.abort(),this.prefetchController=null}stopSession(){this.enhancer?.abort(),this.enhancer=null,this.session&&(this.session.abort("superseded"),this.session=null,this.status.active=!1,this.notify())}stop(){this.stopSession(),this.stopPrefetch()}drawJumble(e,t){if(this.jumbleLevel<0)return!1;let{g:i,originX:s,originY:r,width:o,now:a}=e,l=this.pyramid.levels[this.jumbleLevel],h=ge(l,t);if(!h)return!1;let c=o/l.width,f=this.env.cache,b=!1;i.imageSmoothingEnabled=!0,i.imageSmoothingQuality="medium";for(let g=h.y0;g<=h.y1;g++)for(let L=h.x0;L<=h.x1;L++){let v=f.get(pt+this.jumble[g*l.cols+L]),E=v?zt(l,L,g,s,r,c):null;if(!v||!E)continue;let p=a-v.at;p=0&&x<0;T--){let A=ge(v[T],g);if(!A)continue;let P=!0;for(let N=A.y0;N<=A.y1&&P;N++)for(let C=A.x0;C<=A.x1;C++){let R=L.get(E[T][N*v[T].cols+C]);if(!R||e.now-R.at=0&&T=0?Math.min(this.targetLevel,p):p,w=E!==null&&x>=F;if(w!==this.status.sharp&&(this.status.sharp=w,queueMicrotask(()=>this.notify())),!E)return M;for(let T=Math.max(0,x);T<=y;T++){let A=v[T],P=ge(A,g);if(!P)continue;let N=r/A.width;t.imageSmoothingEnabled=!0,t.imageSmoothingQuality=N<1?"high":"medium";for(let C=P.y0;C<=P.y1;C++)for(let R=P.x0;R<=P.x1;R++){let _=L.get(E[T][C*A.cols+R]);if(!_)continue;let O=e.now-_.at;Othis.requestDraw(),onStatus:()=>this.onStatus(this)})}get isOpen(){return this.expanded}get isNear(){return this.near}layout(e){let t=this.cover,i=Math.max(e.width/t.width,e.open/t.height),s=t.width*i,r=t.height*i,o=(e.open-r)/2,a=o+this.focusY*r,l=Math.max(0,Math.min(e.open-e.closed,a-e.closed/2)),h=this.geometry;this.geometry={width:e.width,closed:e.closed,open:e.open,dpr:e.dpr,coverWidth:s,coverHeight:r,x:(e.width-s)/2,y:o,band:l},this.canvas&&(this.sizeCanvas(this.canvasOpen),this.drawNow()),this.near&&h&&(h.width!==e.width||h.closed!==e.closed||h.open!==e.open||h.dpr!==e.dpr)&&this.startSession()}attach(){if(this.canvas)return;let e=document.createElement("canvas");e.className="strip-canvas",e.setAttribute("aria-hidden","true");let t=e.getContext("2d",{alpha:!1});t&&(this.canvas=e,this.g=t,this.element.prepend(e),this.sizeCanvas(this.expanded),this.drawNow())}detach(){this.canvas&&(cancelAnimationFrame(this.frame),this.frame=0,this.canvas.width=0,this.canvas.height=0,this.canvas.remove(),this.canvas=null,this.g=null)}setNear(e){e!==this.near&&(this.near=e,e?this.startSession():this.loader.stop())}setOpen(e){if(e===this.expanded)return;this.expanded=e,this.element.classList.toggle("is-open",e),clearTimeout(this.settleTimer);let t=this.geometry,i=this.canvas;e?i&&this.canvasOpen?(i.style.transition="",i.style.transform="translate3d(0,0,0)"):i&&t&&(this.sizeCanvas(!0),i.style.transition="none",i.style.transform="translate3d(0,"+-t.band+"px,0)",this.drawNow(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.expanded&&this.canvas===i&&(i.style.transition="",i.style.transform="translate3d(0,0,0)")})})):i&&t&&(i.style.transition="",i.style.transform="translate3d(0,"+-t.band+"px,0)",this.settleTimer=window.setTimeout(()=>{!this.expanded&&this.canvas===i&&(this.sizeCanvas(!1),this.drawNow())},Ai)),this.near&&this.startSession()}sizeCanvas(e){let t=this.canvas,i=this.geometry;if(!t||!i)return;this.canvasOpen=e;let s=e?i.open:i.closed,r=Math.max(1,Math.round(i.width*i.dpr)),o=Math.max(1,Math.round(s*i.dpr));(t.width!==r||t.height!==o)&&(t.width=r,t.height=o),t.style.height=s+"px",e||(t.style.transition="none",t.style.transform="translate3d(0,0,0)")}view(){let e=this.geometry;if(!e)return null;let t=this.expanded?0:e.band,i=this.expanded?e.open:e.closed;return{displayWidth:e.coverWidth,u0:Math.max(0,-e.x/e.coverWidth),u1:Math.min(1,(e.width-e.x)/e.coverWidth),v0:Math.max(0,(t-e.y)/e.coverHeight),v1:Math.min(1,(t+i-e.y)/e.coverHeight)}}startSession(){let e=this.view();!e||!this.geometry||this.loader.start(e,this.geometry.dpr,()=>{})}requestDraw(){this.frame===0&&this.canvas&&(this.frame=requestAnimationFrame(e=>{this.frame=0,this.draw(e)&&this.requestDraw()}))}drawNow(){this.draw(performance.now())&&this.requestDraw()}draw(e){let t=this.g,i=this.canvas,s=this.geometry;if(!t||!i||!s)return!1;t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.fillStyle="#111114",t.fillRect(0,0,i.width,i.height);let r=this.canvasOpen?0:-s.band;return this.loader.draw({g:t,originX:s.x*s.dpr,originY:(s.y+r)*s.dpr,width:s.coverWidth*s.dpr,height:s.coverHeight*s.dpr,canvasWidth:i.width,canvasHeight:i.height,displayWidth:s.coverWidth,dpr:s.dpr,now:e})}};function Ut(n){let e=n.dataset,t=(i,s)=>{let r=Number(i);return Number.isFinite(r)&&r>0?r:s};return{page:e.page??"",build:e.build??"",slug:e.album??"",manifestUrl:e.manifest??"",indexUrl:e.index??"",workerUrl:e.worker??"",budgetMs:t(e.budgetMs,3e3),maxDpr:t(e.maxDpr,2),concurrency:Math.max(1,Math.round(t(e.concurrency,6))),blockContextMenu:e.blockContextMenu!=="false",gate:e.gate==="off"?"off":"server",minEntropy:e.minEntropy&&Number.isFinite(Number(e.minEntropy))?Number(e.minEntropy):20}}function be(n,e,t){return"/a/"+encodeURIComponent(e)+"/p/"+t+"."+n+".json"}var Si=24,Ue=class{constructor(e,t,i,s){this.root=e;this.settings=i;this.env=s;this.strips=[];this.onScreen=new Set;this.inView=new Set;this.suspended=!1;this.wordmark=null;this.opened=null;this.scrollFrame=0;this.sizeKey="";let r=Array.from(e.querySelectorAll("a.strip")),o=new Map(t.albums.map(l=>[l.slug,l]));for(let l of r){let h=o.get(l.dataset.slug??"");!h||!h.cover||this.strips.push(new de(l,h.cover,h.collapsed_focus_y??.5,be(t.build,h.slug,h.cover.hash),s,c=>this.onStripStatus(c)))}this.hoverMode=matchMedia("(hover: hover) and (pointer: fine)");let a=document.querySelector(".site-header .wordmark");if(this.indicator=new ce(document.body,()=>!this.wordmarkMoving()),a){this.wordmark=se(a,!0);let l=()=>{this.wordmark&&!this.indicator.visible&&this.wordmark.play()},h=()=>this.wordmark?.reverse();a.addEventListener("mouseenter",l),a.addEventListener("mouseleave",h),a.addEventListener("focus",l),a.addEventListener("blur",h)}document.documentElement.classList.add("has-strips"),this.measure(),this.observe(),this.bind()}suspend(e){if(!this.suspended){this.suspended=!0;for(let t of this.strips)t.loader.stop(),e&&t.detach();this.env.scheduler.cancelAll(),this.env.cache.trim(e?0:this.env.cache.budget/4)}}resume(){if(this.suspended){this.suspended=!1;for(let e of this.strips)this.inView.has(e)&&e.attach(),e.isNear&&e.startSession()}}wordmarkMoving(){let e=this.wordmark?.t??0;return e>0&&e<1}measure(){let e=this.root.clientWidth||window.innerWidth,t=window.innerHeight,i=Math.round(Math.min(e*6/32,t*.28)),s=Math.round(Math.min(e*9/32,t*.62)),r=Math.min(window.devicePixelRatio||1,this.settings.maxDpr),o=e+"x"+i+"x"+s+"@"+r;if(o!==this.sizeKey){this.sizeKey=o,this.root.style.setProperty("--strip-closed",i+"px"),this.root.style.setProperty("--strip-open",s+"px");for(let a of this.strips)a.layout({width:e,closed:i,open:s,dpr:r})}}observe(){let e=new Map(this.strips.map(r=>[r.element,r])),t=new IntersectionObserver(r=>{for(let o of r)e.get(o.target)?.setNear(o.isIntersecting)},{rootMargin:"100% 0px"}),i=new IntersectionObserver(r=>{for(let o of r){let a=e.get(o.target);a&&(o.isIntersecting?(this.inView.add(a),this.suspended||a.attach()):(this.inView.delete(a),a.detach()))}},{rootMargin:"25% 0px"}),s=new IntersectionObserver(r=>{for(let o of r){let a=e.get(o.target);a&&(o.isIntersecting?this.onScreen.add(a):this.onScreen.delete(a))}this.watchFirst(),this.scheduleCentre()});for(let r of this.strips)t.observe(r.element),i.observe(r.element),s.observe(r.element)}watchFirst(){let e=this.strips.find(t=>this.onScreen.has(t))??null;this.indicator.watch(e?e.loader:null)}onStripStatus(e){this.indicator.update(e.loader)}bind(){for(let e of this.strips){let t=e.element;t.addEventListener("mouseenter",()=>{this.hoverMode.matches&&this.open(e)}),t.addEventListener("mouseleave",()=>{this.hoverMode.matches&&this.opened===e&&this.open(null)}),t.addEventListener("focus",()=>this.open(e)),t.addEventListener("blur",()=>{this.opened===e&&!this.hoverMode.matches?this.scheduleCentre():this.opened===e&&this.open(null)}),t.addEventListener("dragstart",i=>i.preventDefault()),this.settings.blockContextMenu&&t.addEventListener("contextmenu",i=>i.preventDefault())}window.addEventListener("scroll",()=>this.scheduleCentre(),{passive:!0}),new ResizeObserver(()=>{this.measure(),this.scheduleCentre()}).observe(this.root)}open(e){e!==this.opened&&(this.opened?.setOpen(!1),this.opened=e,e?.setOpen(!0))}scheduleCentre(){this.hoverMode.matches||this.scrollFrame!==0||(this.scrollFrame=requestAnimationFrame(()=>{this.scrollFrame=0,this.pickCentre()}))}pickCentre(){if(this.hoverMode.matches)return;let e=window.innerHeight/2,t=null,i=1/0,s=1/0;for(let r of this.onScreen){let o=r.element.getBoundingClientRect(),a=Math.abs(o.top+o.height/2-e);ae,settle:()=>Promise.resolve()}}var Ti=8,Pi=400,Ci=2e3,Ot=/^[0-9a-f]{64}$/,Oe=class{constructor(e,t,i,s){this.gate=e;this.slug=t;this.context=i;this.workerUrl=s;this.keys=new Map;this.inflight=new Set;this.waiters=new Set;this.listeners=[];this.queue=[];this.busy=!1;this.blocked=!1;this.failed=!1;this.pausedUntil=0;this.page="";if(this.server=e.mode!=="off",!this.server)for(let[r,o]of Object.entries(e.keys??{}))Ot.test(o)&&this.keys.set(r,Ie(o))}onKeys(e){this.listeners.push(e)}key(e){return this.keys.get(e)??null}has(e){return this.keys.has(e)}want(e,t){if(!this.server||e.every(s=>this.keys.has(s)||this.inflight.has(s)))return;let i=s=>!this.keys.has(s)&&!this.inflight.has(s);this.queue=Array.from(new Set(e.concat(t))).filter(i),this.pump()}settle(e,t){return new Promise(i=>{if(this.keys.has(e)||this.blocked||this.failed||t.aborted){i();return}let s=()=>{clearTimeout(o),this.waiters.delete(r),t.removeEventListener("abort",s),i()},r=()=>{(this.keys.has(e)||this.blocked||this.failed)&&s()},o=window.setTimeout(s,Pi);this.waiters.add(r),t.addEventListener("abort",s,{once:!0})})}wake(){for(let e of Array.from(this.waiters))e()}body(e,t){let i={build:this.gate.build,album:this.slug,photos:e,context:this.context,entropy:Ae()};return t&&(i.pass=t),this.page&&(i.page=this.page),i}pump(){if(this.busy||this.blocked||this.failed||this.queue.length===0||performance.now(){this.queue=Array.from(new Set(t.concat(this.queue))).filter(i=>!this.keys.has(i)&&!this.inflight.has(i)),this.pump()},e)}async send(e){this.busy=!0;for(let s of e)this.inflight.add(s);let t=[],i=0;try{let s=ze(),r=await ve(this.body(e,s));if(this.absorb(r,s),r.challenge){this.blocked=!0,this.wake();let o=await ut(Promise.resolve(r),a=>ve({...this.body(e,""),challenge:a}),this.workerUrl,!1);this.blocked=!1,o?this.absorb(o,""):this.failed=!0}}catch(s){s instanceof he&&s.status===429?(i=Math.max(1,s.retryAfter)*1e3,t=e):s instanceof he&&s.status>=400&&s.status<500?this.failed=!0:(i=Ci,t=e)}finally{for(let s of e)this.inflight.delete(s);this.busy=!1,this.wake()}i>0?this.pause(i,t.filter(s=>!this.keys.has(s))):this.pump()}absorb(e,t){e.stale&&t&&ze()===t&&He(null),e.pass&&He(e.pass),e.page&&(this.page=e.page);let i=[];for(let[s,r]of Object.entries(e.keys??{}))Ot.test(r)&&!this.keys.has(s)&&(this.keys.set(s,Ie(r)),i.push(s));if(i.length>0){this.wake();for(let s of this.listeners)s(i)}}};var Ii=/[㐀-鿿豈-﫿]/;function Be(n,e){Ii.test(e)?n.lang="zh":n.removeAttribute("lang")}function Kt(n){return n<10?"0"+n:String(n)}function Ri(n){let e=(n.model??"").trim(),t=(n.make??"").trim(),i=t.split(/\s+/)[0]??"";i&&e.toLowerCase().startsWith(i.toLowerCase()+" ")&&(e=e.slice(i.length+1).trim());let s=/^([A-Za-z]{1,3}) (\d+[A-Za-z0-9]*)$/.exec(e);return s&&(e=s[1]+s[2]),e||t}function zi(n){let e=/(\d+(?:\.\d+)?(?:-\d+(?:\.\d+)?)?)\s*mm\s*(?:F|f\/?)\s*([\d.]+(?:-[\d.]+)?)/.exec(n);return e?e[1]+" f/"+e[2]:n.trim()}function _e(n){return String(Math.round(n*10)/10)}function Hi(n){let e=n.trim();if(e.includes("/")||e.endsWith("s"))return e;let t=Number(e);if(!Number.isFinite(t)||t<=0)return e;if(t>=1)return _e(t)+"s";let i=1/t;return i<10&&Math.abs(i-Math.round(i))>.05?"1/"+_e(i):"1/"+Math.round(i)}function Fi(n,e,t,i){let s=[Kt(n+1)+" / "+Kt(e)],r=t.exif;if(i&&r){let o=Ri(r);o&&s.push(o),r.lens&&s.push(zi(r.lens)),r.focal_length&&s.push(_e(r.focal_length)+"mm"),r.f_number&&s.push("f/"+_e(r.f_number)),r.exposure&&s.push(Hi(r.exposure)),r.iso&&s.push("ISO "+r.iso)}return s.join(" \xB7 ")}function Ni(n,e){n.textContent="",e.split(/\r?\n/).forEach((t,i)=>{i>0&&n.appendChild(document.createElement("br"));let s=t.split("*"),r=(s.length-1)%2===0;s.forEach((o,a)=>{let l=a%2===1;if(l&&(r||a!==s.length-1)){let h=document.createElement("em");h.textContent=o,n.appendChild(h)}else n.appendChild(document.createTextNode((l?"*":"")+o))})})}var Xe=class{constructor(e){this.visible=!1;this.placement="";this.element=document.createElement("section"),this.element.className="caption",this.element.setAttribute("aria-label","Caption"),this.meta=document.createElement("p"),this.meta.className="caption-meta",this.title=document.createElement("h2"),this.title.className="caption-title",this.text=document.createElement("p"),this.text.className="caption-text",this.element.append(this.meta,this.title,this.text),e.appendChild(this.element)}set(e,t,i,s){this.meta.textContent=Fi(t,i,e,s),this.title.textContent=e.title??"",this.title.hidden=!e.title,Be(this.title,e.title??""),Ni(this.text,e.caption??""),this.text.hidden=!e.caption,Be(this.text,e.caption??"")}show(e){e!==this.visible&&(this.visible=e,this.element.classList.toggle("is-visible",e))}place(e,t,i){let s=Math.round(e)+","+Math.round(t)+","+Math.round(i);if(s===this.placement)return;this.placement=s;let r=this.element.style;r.width=Math.round(t)+"px",r.transform="translate3d("+Math.round(e)+"px,"+-Math.round(i)+"px,0)"}};var Ye=24,Bt=10,qi=300,Di=.35,_t=.35,Wi=.2,Ui=2500,Oi=120,Ki=16,Bi=.002,_i=.01;function Xi(n,e,t,i){let s=3*n,r=3*(t-n)-s,o=1-s-r,a=3*e,l=3*(i-e)-a,h=1-a-l,c=g=>((o*g+r)*g+s)*g,f=g=>((h*g+l)*g+a)*g,b=g=>(3*o*g+2*r)*g+s;return g=>{if(g<=0)return 0;if(g>=1)return 1;let L=g;for(let p=0;p<8;p++){let y=c(L)-g,x=b(L);if(Math.abs(y)<1e-5)return f(L);if(Math.abs(x)<1e-6)break;L-=y/x}let v=0,E=1;L=g;for(let p=0;p<24;p++){let y=c(L);if(Math.abs(y-g)<1e-5)break;ythis.onKeys(l)),o&&Fe(this.nextLink,()=>this.nextSlug,o),this.bind(),this.activate(-1),this.requestDraw(),this.wake(),this.loadNextAlbum()}buildEndCard(){let e=document.createElement("section");e.className="end-card",e.setAttribute("aria-label","End of album");let t=document.createElement("a");t.className="next-album",t.href="/";let i=document.createElement("span");i.className="next-strip";let s=document.createElement("span");s.className="next-text";let r=document.createElement("span");r.className="next-eyebrow",r.textContent="All albums";let o=document.createElement("span");o.className="next-title",s.append(r,o),i.appendChild(s),t.appendChild(i);let a=document.createElement("div");a.className="signoff",a.appendChild(this.signoffMark);let l=document.createElement("p");return l.className="signature",l.textContent="\u2014 Lucio",a.appendChild(l),e.append(t,a),e}loader(e){let t=this.loaders[e];if(!t){let i=this.manifest.photos[e];t=new ue(i,be(this.manifest.build,this.manifest.slug,i.hash),{...this.env,requestDraw:()=>this.requestDraw(),onStatus:s=>{this.indicator.update(s),this.progress.update(s)}}),this.loaders[e]=t}return t}measure(){let e=this.stage.getBoundingClientRect();this.vw=Math.max(1,e.width),this.vh=Math.max(1,e.height),this.ox=e.left,this.oy=e.top,this.dpr=Math.min(window.devicePixelRatio||1,this.settings.maxDpr);let t=Math.max(1,Math.round(this.vw*this.dpr)),i=Math.max(1,Math.round(this.vh*this.dpr));(this.canvas.width!==t||this.canvas.height!==i)&&(this.canvas.width=t,this.canvas.height=i),this.layouts=[],this.stops=[];let s=0;this.manifest.photos.forEach((r,o)=>{let a=Math.max(1,r.slides||1),l=Math.min(this.vw/(r.width/a),this.vh/r.height),h=r.width*l,c=r.height*l,f=h/a,b=s+Ye/2+(this.vw-f)/2;this.layouts.push({scale:l,width:h,height:c,section:f,slides:a,start:s,left:b,top:(this.vh-c)/2});for(let g=0;g{this.pointerId===null&&document.body.classList.add("is-idle")},Ui)}stopForHash(){let e=/^#(\d+)$/.exec(location.hash);if(!e)return 0;let t=Math.min(this.manifest.photos.length,Math.max(1,Number(e[1])))-1,i=this.stops.findIndex(s=>s.photo===t);return i<0?0:i}bind(){let e=this.stage;e.addEventListener("pointerdown",t=>this.onPointerDown(t)),e.addEventListener("pointermove",t=>this.onPointerMove(t)),e.addEventListener("pointerup",t=>this.onPointerUp(t,!1)),e.addEventListener("pointercancel",t=>this.onPointerUp(t,!0)),e.addEventListener("pointerleave",t=>{t.pointerType==="mouse"&&this.pointerId===null&&(this.hover=!1,this.updateCaption())}),e.addEventListener("wheel",t=>this.onWheel(t),{passive:!1}),e.addEventListener("gesturestart",t=>{t.preventDefault(),this.gestureZoom=this.zoom}),e.addEventListener("gesturechange",t=>this.onGesture(t)),e.addEventListener("gestureend",t=>t.preventDefault()),e.addEventListener("dragstart",t=>t.preventDefault()),e.addEventListener("selectstart",t=>t.preventDefault()),this.settings.blockContextMenu&&e.addEventListener("contextmenu",t=>t.preventDefault()),window.addEventListener("keydown",t=>this.onKey(t)),window.addEventListener("hashchange",()=>{let t=this.stopForHash();this.stops[t].photo!==this.stops[this.current].photo?this.jump(t):this.clearZoom()&&(this.startSession(),this.updateCaption())}),new ResizeObserver(()=>this.onResize()).observe(e),this.fade.addEventListener("transitionend",()=>{this.fade.style.opacity==="0"&&(this.fade.width=1,this.fade.height=1)})}onResize(){let e=this.vw+"x"+this.vh+"@"+this.dpr;this.measure(),e!==this.vw+"x"+this.vh+"@"+this.dpr&&(this.clearZoom(),this.tween=null,this.camera=this.stops[this.current].camera,this.requestDraw(),clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout(()=>this.startSession(),200))}onKey(e){if(e.altKey||e.ctrlKey||e.metaKey)return;this.wake();let t=e.target;if(!(t&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)))){switch(e.key){case"ArrowRight":this.go(this.current+1);break;case"ArrowLeft":this.go(this.current-1);break;case"Home":this.go(0);break;case"End":this.go(this.stops.length-2);break;case"Escape":this.zoomPhoto>=0?this.go(this.current):location.assign("/");break;case"i":case"I":this.pinned=!this.pinned,this.updateCaption();break;default:return}e.preventDefault()}}onPointerDown(e){if(!(e.pointerType==="mouse"&&e.button!==0)){if(this.pointerId!==null){this.secondId===null&&e.pointerType!=="mouse"&&this.pointerType!=="mouse"&&!this.stale&&(this.zoomPhoto>=0||!this.dragging&&this.enterZoom())&&(this.secondId=e.pointerId,this.bx=e.clientX,this.by=e.clientY,this.pinching=!0,this.dragging=!0,this.stage.setPointerCapture(e.pointerId));return}e.target.closest("a, button")||(this.pointerId=e.pointerId,this.pointerType=e.pointerType,this.dragging=!1,this.stale=!1,this.downX=e.clientX,this.downY=e.clientY,this.ax=e.clientX,this.ay=e.clientY,this.downT=e.timeStamp,this.tween=null,this.downCamera=this.camera,this.samples=[{t:e.timeStamp,x:e.clientX}],this.stage.setPointerCapture(e.pointerId))}}onPointerMove(e){if(e.pointerType==="mouse"&&this.wake(),this.pointerId===null){e.pointerType==="mouse"&&(this.hover=this.inCaptionZone(e.clientX,e.clientY),this.updateCaption());return}if(this.pinching&&(e.pointerId===this.pointerId||e.pointerId===this.secondId)){this.pinchMove(e.pointerId,e.clientX,e.clientY);return}if(e.pointerId!==this.pointerId||this.stale)return;let t=e.clientX-this.downX,i=e.clientY-this.downY;if(!this.dragging&&Math.hypot(t,i)>=Bt&&(this.dragging=!0,this.stage.classList.add("is-dragging"),this.updateCaption()),!this.dragging){this.ax=e.clientX,this.ay=e.clientY;return}if(this.zoomPhoto>=0){this.zx+=e.clientX-this.ax,this.zy+=e.clientY-this.ay,this.ax=e.clientX,this.ay=e.clientY,this.settleZoom();return}for(this.samples.push({t:e.timeStamp,x:e.clientX});this.samples.length>2&&e.timeStamp-this.samples[0].t>100;)this.samples.shift();this.camera=this.rubber(this.downCamera-t),this.requestDraw()}onPointerUp(e,t){if(this.pinching&&(e.pointerId===this.pointerId||e.pointerId===this.secondId)){this.endPinch(e.pointerId);return}if(e.pointerId!==this.pointerId)return;this.stage.hasPointerCapture(e.pointerId)&&this.stage.releasePointerCapture(e.pointerId),this.pointerId=null;let i=this.dragging;if(this.dragging=!1,this.stage.classList.remove("is-dragging"),this.stale){this.stale=!1;return}let s=Math.hypot(e.clientX-this.downX,e.clientY-this.downY);if(!t&&!i&&s=0)return;let r=0,o=this.samples[0],a=this.samples[this.samples.length-1];o&&a&&a.t>o.t&&e.timeStamp-a.t<100&&(r=(a.x-o.x)/(a.t-o.t));let l=this.nearestStop(this.camera);if(!t&&Math.abs(r)>Di)if(r<0){let h=this.stops.findIndex(c=>c.camera>this.camera+1);l=h<0?this.stops.length-1:h}else{let h=0;this.stops.forEach((c,f)=>{c.camera=0)return;let i=this.photoRect(t.photo);e.clientX>=i.left&&e.clientX<=i.right&&e.clientY>=i.top&&e.clientY<=i.bottom&&(this.pinned=!this.pinned,this.updateCaption())}onWheel(e){if(e.preventDefault(),this.pinching||this.dragging&&this.zoomPhoto<0)return;let t=e.deltaY;if(e.deltaMode===1?t*=Ki:e.deltaMode===2&&(t*=this.vh),t===0)return;let i=Math.max(-1,Math.min(1,t*(e.ctrlKey?_i:Bi))),s=e.clientX-this.ox,r=e.clientY-this.oy;this.zoomTo(this.zoom*Math.exp(-i),s,r,s,r)}onGesture(e){if(e.preventDefault(),this.pointerId!==null||!e.scale)return;let t=(e.clientX??this.ox+this.vw/2)-this.ox,i=(e.clientY??this.oy+this.vh/2)-this.oy;this.zoomTo(this.gestureZoom*e.scale,t,i,t,i)}pinchMove(e,t,i){let s=(this.ax+this.bx)/2-this.ox,r=(this.ay+this.by)/2-this.oy,o=Math.hypot(this.ax-this.bx,this.ay-this.by);e===this.pointerId?(this.ax=t,this.ay=i):(this.bx=t,this.by=i);let a=Math.hypot(this.ax-this.bx,this.ay-this.by),l=o>1&&a>1?this.zoom*a/o:this.zoom;this.zoomTo(l,s,r,(this.ax+this.bx)/2-this.ox,(this.ay+this.by)/2-this.oy)}endPinch(e){this.stage.hasPointerCapture(e)&&this.stage.releasePointerCapture(e),e===this.pointerId&&(this.pointerId=this.secondId,this.ax=this.bx,this.ay=this.by),this.secondId=null,this.pinching=!1,this.dragging=!0,this.zoomPhoto>=0&&this.settleZoom()}enterZoom(){let e=this.stops[this.current];if(e.photo<0||this.suspended)return!1;let t=this.layouts[e.photo],i=this.manifest.photos[e.photo].width/(window.devicePixelRatio||1)/t.width;return i<=1.001?!1:(this.tween=null,this.camera=e.camera,this.zoomPhoto=e.photo,this.zoomMax=i,this.zoom=1,this.zx=t.left-(this.camera-this.vw/2),this.zy=t.top,this.slackX=this.zx-this.clampAxis(this.zx,t.width,this.vw,0),this.slackY=this.zy-this.clampAxis(this.zy,t.height,this.vh,0),this.updateCaption(),!0)}zoomTo(e,t,i,s,r){if(this.zoomPhoto<0&&(e<=1||!this.enterZoom()))return;let o=Math.max(1,Math.min(this.zoomMax,e)),a=o/this.zoom;this.zx=s-(t-this.zx)*a,this.zy=r-(i-this.zy)*a,this.zoom=o,this.settleZoom()}settleZoom(){let e=this.layouts[this.zoomPhoto];if(this.zx=this.clampAxis(this.zx,e.width*this.zoom,this.vw,this.slackX),this.zy=this.clampAxis(this.zy,e.height*this.zoom,this.vh,this.slackY),this.requestDraw(),this.zoom<=1&&!this.pinching){this.camera=e.left+this.vw/2-this.zx,this.go(this.nearestStop(this.camera));return}clearTimeout(this.zoomTimer),this.zoomTimer=window.setTimeout(()=>this.startZoomSession(),Oi)}clampAxis(e,t,i,s){let r=(i-t)/2,o=Math.min(i-t,r),a=Math.max(0,r),l=s*Math.max(0,2-this.zoom);return l>0?a+=l:o+=l,Math.min(a,Math.max(o,e))}clearZoom(){return this.zoomPhoto<0?!1:(this.zoomPhoto=-1,this.zoom=1,this.gestureZoom=1,clearTimeout(this.zoomTimer),this.zoomTimer=0,this.pointerId!==null&&(this.stale=!0,this.pinching=!1,this.secondId=null),this.requestDraw(),!0)}levelDpr(){return this.zoomPhoto>=0&&this.zoom>=this.zoomMax*.999?Math.max(this.dpr,window.devicePixelRatio||1):this.dpr}startZoomSession(){if(this.zoomTimer=0,this.suspended||this.zoomPhoto<0)return;let e=this.layouts[this.zoomPhoto],t=e.width*this.zoom,i=e.height*this.zoom,s=Math.max(0,this.zx),r=Math.min(this.vw,this.zx+t),o=Math.max(0,this.zy),a=Math.min(this.vh,this.zy+i);r<=s||a<=o||this.loader(this.zoomPhoto).start({displayWidth:t,u0:(s-this.zx)/t,u1:(r-this.zx)/t,v0:(o-this.zy)/i,v1:(a-this.zy)/i},this.levelDpr(),()=>{})}rubber(e){let t=this.stops[0].camera,i=this.stops[this.stops.length-1].camera;return ei?i+(e-i)*_t:e}nearestStop(e){let t=0;return this.stops.forEach((i,s)=>{Math.abs(i.camera-e){this.current=t,this.camera=r});else{let o=Math.abs(r-this.camera);o>.5?this.tween={from:this.camera,to:r,start:performance.now(),duration:240+200*Math.min(1,o/this.vw)}:this.camera=r,this.current=t}t!==i?this.activate(i):(s&&this.startSession(),this.updateCaption()),this.requestDraw()}jump(e){let t=this.current;this.clearZoom(),this.tween=null,this.crossfade(()=>{this.current=e,this.camera=this.stops[e].camera}),this.activate(t),this.requestDraw()}crossfade(e){let t=this.fade;(t.width!==this.canvas.width||t.height!==this.canvas.height)&&(t.width=this.canvas.width,t.height=this.canvas.height);let i=t.getContext("2d");i&&i.drawImage(this.canvas,0,0),t.style.transition="none",t.style.opacity="1",e(),this.render(performance.now()),requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.transition="",t.style.opacity="0"})})}activate(e){let t=this.stops[this.current],i=e>=0?this.stops[e]:null;if(i&&i.photo>=0&&i.photo!==t.photo&&this.loaders[i.photo]?.stop(),this.loaders.forEach((s,r)=>{s&&r!==t.photo&&r!==t.photo+1&&s.stopPrefetch()}),t.photo<0&&(this.indicator.watch(null),this.progress.watch(null)),this.describe(t.photo,e>=0),t.photo>=0){let s=this.manifest.photos[t.photo];this.caption.set(s,t.photo,this.manifest.photos.length,this.manifest.show_exif),(e>=0||location.hash!=="")&&location.hash!=="#"+(t.photo+1)&&history.replaceState(history.state,"","#"+(t.photo+1))}this.wantKeys(),t.photo>=0&&this.startSession(),(t.photo<0||t.photo===this.manifest.photos.length-1)&&me(this.signoffMark),this.syncNextStrip(),this.updateCaption()}describe(e,t){let i=this.manifest.photos.length,s;if(e<0){let r=this.nextLink.querySelector(".next-title")?.textContent??"";s="End of album."+(r?" Next album: "+r+".":"")}else{let r=this.manifest.photos[e],o=r.alt||r.title||"";s="Photo "+(e+1)+" of "+i+(o?": "+o:"")}this.canvas.setAttribute("aria-label",s),clearTimeout(this.announceTimer),t&&(this.announceTimer=window.setTimeout(()=>{this.announcer.textContent=s},500))}suspend(e){if(!this.suspended){this.suspended=!0,this.tween=null;for(let t of this.loaders)t?.stop();this.nextStrip?.loader.stop(),this.env.scheduler.cancelAll(),this.env.cache.trim(e?0:this.env.cache.budget/4),e&&(this.nextStrip?.detach(),this.canvas.width=1,this.canvas.height=1,this.fade.width=1,this.fade.height=1)}}resume(){this.suspended&&(this.suspended=!1,this.clearZoom(),this.canvas.width=0,this.measure(),this.camera=this.stops[this.current].camera,this.syncNextStrip(),this.startSession(),this.requestDraw())}wantKeys(){let e=this.manifest.photos,t=this.stops[this.current],i=t.photo<0?e.length-1:t.photo,s=r=>{let o=[];for(let a of r){let l=i+a;l>=0&&lr>=0&&r=0?i(this.zoomPhoto)&&this.loader(this.zoomPhoto).stalled&&this.startZoomSession():s.photo>=0&&i(s.photo)&&this.loader(s.photo).stalled?this.startSession():s.photo>=0&&i(s.photo+1)&&!this.loader(s.photo).status.active&&this.prefetchAround(this.current),this.requestDraw()}startSession(){let e=this.stops[this.current];if(e.photo<0)return;let t=this.current,i=this.loader(e.photo);i.start(this.viewAt(e),this.dpr,()=>{this.current===t&&this.prefetchAround(t)},!0),this.indicator.watch(i),this.progress.watch(i)}prefetchAround(e){let t=this.stops[e],i=this.stops[e+1];if(!(!i||i.photo<0)){if(i.photo===t.photo){let s=this.loader(t.photo);s.prefetchLevel(this.viewAt(i),s.finalLevel);let r=this.stops.find(o=>o.photo===t.photo+1);r&&this.loader(r.photo).prefetchProbe(this.viewAt(r),this.dpr);return}this.loader(i.photo).prefetchProbe(this.viewAt(i),this.dpr)}}viewAt(e){let t=this.layouts[e.photo],i=e.camera-this.vw/2,s=Math.max(i,t.left),r=Math.min(i+this.vw,t.left+t.width),o=Math.max(0,t.top),a=Math.min(this.vh,t.top+t.height);return{displayWidth:t.width,u0:(s-t.left)/t.width,u1:(r-t.left)/t.width,v0:(o-t.top)/t.height,v1:(a-t.top)/t.height}}photoRect(e){let t=this.layouts[e],i=t.left-(this.camera-this.vw/2);return{left:Math.max(0,i),right:Math.min(this.vw,i+t.width),top:Math.max(0,t.top),bottom:Math.min(this.vh,t.top+t.height)}}inCaptionZone(e,t){let i=this.stops[this.current];if(i.photo<0)return!1;let s=this.stage.getBoundingClientRect(),r=e-s.left,o=t-s.top,a=this.layouts[i.photo],l=this.photoRect(i.photo),h=a.top+a.height*(1-Wi);return r>=l.left&&r<=l.right&&o>=h&&o<=l.bottom}updateCaption(){let e=this.stops[this.current],t=e.photo>=0&&this.zoomPhoto<0&&!this.dragging&&(this.pinned||this.hover);if(t){let i=this.photoRect(e.photo);this.caption.place(i.left,i.right-i.left,this.vh-i.bottom)}this.caption.show(t),document.body.classList.toggle("has-caption",t)}loadNextAlbum(){this.indexRequested||!this.settings.indexUrl||(this.indexRequested=!0,fetch(this.settings.indexUrl,{credentials:"same-origin"}).then(e=>e.ok?e.json():Promise.reject(new Error("index"))).then(e=>this.showNextAlbum(e)).catch(()=>{this.indexRequested=!1}))}showNextAlbum(e){let t=e.albums;if(t.length===0)return;let i=t.findIndex(a=>a.slug===this.manifest.slug),s=t[(i+1)%t.length];if(!s||s.slug===this.manifest.slug)return;this.nextLink.href="/a/"+encodeURIComponent(s.slug)+"/",this.nextSlug=s.slug;let r=this.nextLink.querySelector(".next-eyebrow"),o=this.nextLink.querySelector(".next-title");r&&(r.textContent="Next album"+(s.date?" \xB7 "+s.date:"")),o&&(o.textContent=s.title,Be(o,s.title)),s.cover&&(this.nextStrip=new de(this.nextFrame,s.cover,s.collapsed_focus_y??.5,be(e.build,s.slug,s.cover.hash),{...this.env,keys:Ke(e.gate.cover),tiles:e.tiles},()=>{}),this.nextLink.classList.add("has-strip"),this.layoutNextStrip(),this.syncNextStrip())}requestDraw(){this.frame===0&&(this.frame=requestAnimationFrame(e=>{this.frame=0,this.render(e)}))}render(e){let t=!1;if(this.tween){let b=Math.min(1,(e-this.tween.start)/this.tween.duration);this.camera=this.tween.from+(this.tween.to-this.tween.from)*Yi(b),b>=1?(this.tween=null,this.updateCaption()):t=!0}let i=this.g,s=this.canvas.width,r=this.canvas.height;i.setTransform(1,0,0,1,0,0),i.globalAlpha=1,i.fillStyle="#111114",i.fillRect(0,0,s,r);let o=this.camera-this.vw/2,a=o+this.vw,l=this.dpr,h=this.stops[this.current].photo,c=Math.max(0,(h<0?this.layouts.length-1:h)-2),f=this.zoomPhoto>=0?-1:Math.min(this.layouts.length-1,(h<0?this.layouts.length-1:h)+2);if(this.zoomPhoto>=0){let b=this.layouts[this.zoomPhoto],g=b.width*this.zoom;this.loader(this.zoomPhoto).draw({g:i,originX:this.zx*l,originY:this.zy*l,width:g*l,height:b.height*this.zoom*l,canvasWidth:s,canvasHeight:r,displayWidth:g,dpr:this.levelDpr(),now:e})&&(t=!0)}for(let b=c;b<=f;b++){let g=this.layouts[b];g.left+g.widtha||this.loader(b).draw({g:i,originX:(g.left-o)*l,originY:g.top*l,width:g.width*l,height:g.height*l,canvasWidth:s,canvasHeight:r,displayWidth:g.width,dpr:l,now:e})&&(t=!0)}this.endCard.style.transform="translate3d("+Math.round(this.endLeft-o)+"px,0,0)",this.caption.element.classList.contains("is-visible")&&this.tween&&this.updateCaption(),t&&this.requestDraw()}};async function Yt(n){let e=await fetch(n,{credentials:"same-origin"});if(!e.ok)throw new Error(n+" "+e.status);return await e.json()}function jt(n){return{scheduler:new Me(n.concurrency,n.workerUrl),cache:new Ee(Et())}}function Gt(n,e){return n.gate==="off"?null:{build:n.build,workerUrl:n.workerUrl,minEntropy:e,score:Ae}}async function ji(n,e,t){let i=await Yt(e.manifestUrl);if(i.photos.length===0)return;let s=new Oe(i.gate,i.slug,t?"nav":"land",e.workerUrl),{scheduler:r,cache:o}=jt(e);document.documentElement.classList.add("has-viewer");let a=i.gate.min_entropy??e.minEntropy;Vt(new je(n,i,e,{scheduler:r,cache:o,settings:e,keys:s,tiles:i.tiles},s,Gt(e,()=>a)))}async function Gi(n,e,t){let i=await Yt(e.indexUrl);if(typeof i.gate.min_entropy=="number"&&t(i.gate.min_entropy),i.albums.length===0)return;let{scheduler:s,cache:r}=jt(e);Vt(new Ue(n,i,e,{scheduler:s,cache:r,settings:e,keys:Ke(i.gate.cover),tiles:i.tiles}))}function Vt(n){document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?n.suspend(!1):n.resume()}),window.addEventListener("pagehide",()=>n.suspend(!0)),window.addEventListener("pageshow",e=>{e.persisted&&n.resume()})}function Vi(){document.documentElement.classList.remove("has-viewer"),document.querySelector(".load-error")?.removeAttribute("hidden")}function Zi(){let n=Array.from(document.querySelectorAll(".site-footer .chop"));if(n.length===0)return;if(typeof IntersectionObserver!="function"){n.forEach(me);return}let e=new IntersectionObserver(t=>{for(let i of t)i.isIntersecting&&(e.unobserve(i.target),me(i.target))},{rootMargin:"200px"});n.forEach(t=>e.observe(t))}function Xt(){et(),Zi();let n=Ut(document.body);if(n.page==="album"){let e=document.getElementById("stage");e&&ji(e,n,It(n.slug)).catch(Vi)}else if(n.page==="notfound"){let e=document.querySelector(".site-header .wordmark");e&&se(e,!1)}else if(n.page==="index"){let e=document.getElementById("strips");if(e){let t=n.minEntropy,i=Gt(n,()=>t);if(i)for(let s of Array.from(e.querySelectorAll("a.strip")))Fe(s,()=>s.dataset.slug??"",i);Gi(e,n,s=>{t=s}).catch(()=>{document.documentElement.classList.remove("has-strips");let s=document.querySelector(".site-header .wordmark");s&&!s.classList.contains("has-svg")&&se(s,!1)})}}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Xt,{once:!0}):Xt();})(); diff --git a/internal/site/templates/album.html b/internal/site/templates/album.html index 9daebdc..0c9b048 100644 --- a/internal/site/templates/album.html +++ b/internal/site/templates/album.html @@ -16,6 +16,5 @@

All albums

- diff --git a/scripts/sync-brand.sh b/scripts/sync-brand.sh index 4ad3217..9a6f8fd 100644 --- a/scripts/sync-brand.sh +++ b/scripts/sync-brand.sh @@ -3,10 +3,10 @@ set -euo pipefail scripts_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" repo_dir="$(dirname "$scripts_dir")" -brand_dir="${LUCIO_IP_DIR:-$repo_dir/../LUCIO_ip}" +brand_dir="${LUCIO_IP_DIR:-$repo_dir/../lucioIP}" out_dir="$repo_dir/web/brand" -for required in tokens/tokens.css motion/lucio-morph.js logo/favicon.svg logo/lucio-chop-chen.svg; do +for required in tokens/tokens.css motion/lucio-morph.js motion/lucio-loaders.js logo/favicon.svg logo/lucio-chop-chen.svg; do if [ ! -f "$brand_dir/$required" ]; then echo "sync-brand: $brand_dir/$required not found (set LUCIO_IP_DIR)" >&2 exit 1 @@ -33,7 +33,8 @@ strip_svg() { } > "$out_dir/tokens.css" strip_js < "$brand_dir/motion/lucio-morph.js" > "$out_dir/lucio-morph.js" +strip_js < "$brand_dir/motion/lucio-loaders.js" > "$out_dir/lucio-loaders.js" strip_svg < "$brand_dir/logo/favicon.svg" > "$out_dir/favicon.svg" strip_svg < "$brand_dir/logo/lucio-chop-chen.svg" > "$out_dir/lucio-chop-chen.svg" -echo "sync-brand: copied tokens.css, lucio-morph.js, favicon.svg, lucio-chop-chen.svg from $brand_dir into $out_dir" +echo "sync-brand: copied tokens.css, lucio-morph.js, lucio-loaders.js, favicon.svg, lucio-chop-chen.svg from $brand_dir into $out_dir" diff --git a/web/brand/lucio-loaders.js b/web/brand/lucio-loaders.js new file mode 100644 index 0000000..8e491e4 --- /dev/null +++ b/web/brand/lucio-loaders.js @@ -0,0 +1,468 @@ +(function (global) { + const HB = 49.8, CR = 16.2, HW = 10.2, H = HB - CR, SL = 2 * H, CL = Math.PI / 2 * CR, PER = 4 * (SL + CL), Q = PER / 4; + const NPTS = 96, NPUFF = 64, W0 = HW * 0.85; + function pathP(s) { + s = (((s - CL / 2) % PER) + PER) % PER; + const arc = (cx, cy, a) => [cx + CR * Math.cos(a), cy + CR * Math.sin(a)]; + if (s < SL) return [HB, -H + s]; s -= SL; + if (s < CL) return arc(H, H, s / CR); s -= CL; + if (s < SL) return [H - s, HB]; s -= SL; + if (s < CL) return arc(-H, H, Math.PI / 2 + s / CR); s -= CL; + if (s < SL) return [-HB, H - s]; s -= SL; + if (s < CL) return arc(-H, -H, Math.PI + s / CR); s -= CL; + if (s < SL) return [-H + s, -HB]; s -= SL; + return arc(H, -H, -Math.PI / 2 + s / CR); + } + const PRELUDE = ` +precision highp float; +uniform vec2 uRes; +uniform float uPx, uTime, uDark; +uniform vec3 uColor; +#define PI 3.14159265 +#define HPI 1.5707963 +const float HB = ${HB.toFixed(4)}, CR = ${CR.toFixed(4)}, HW = ${HW.toFixed(4)}, H = ${H.toFixed(4)}; +const float SL = ${SL.toFixed(4)}, CL = ${CL.toFixed(4)}, PER = ${PER.toFixed(4)}, Q = ${Q.toFixed(4)}; +const vec2 L2 = vec2(0.6608, 0.7506); // the brand's one light: from the upper right +float sdRB(vec2 p) { vec2 q = abs(p) - vec2(H); return length(max(q, 0.)) + min(max(q.x, q.y), 0.) - CR; } +// arc length of the nearest centreline point, CCW, 0 at the bottom-right corner's 45-degree point +float pathS(vec2 p) { + if (abs(p.x) <= H && abs(p.y) <= H) { if (abs(p.x) > abs(p.y)) p.x = sign(p.x) * (H + 1e-3); else p.y = sign(p.y) * (H + 1e-3); } + float s; + if (p.x > H && p.y > H) s = SL + atan(p.y - H, p.x - H) * CR; + else if (p.x < -H && p.y > H) s = 2. * SL + CL + (atan(p.y - H, p.x + H) - HPI) * CR; + else if (p.x < -H && p.y < -H) s = 3. * SL + 2. * CL + atan(-(p.y + H), -(p.x + H)) * CR; + else if (p.x > H && p.y < -H) s = 4. * SL + 3. * CL + (atan(p.y + H, p.x - H) + HPI) * CR; + else if (p.x > H) s = p.y + H; + else if (p.y > H) s = SL + CL + (H - p.x); + else if (p.x < -H) s = 2. * SL + 2. * CL + (H - p.y); + else s = 3. * SL + 3. * CL + (p.x + H); + return mod(s + CL * 0.5, PER); +} +float hash11(float n) { return fract(sin(n * 127.1 + 11.7) * 43758.5453); } +float hash12(vec2 p) { vec3 p3 = fract(vec3(p.xyx) * .1031); p3 += dot(p3, p3.yzx + 33.33); return fract((p3.x + p3.y) * p3.z); } +vec2 hash22(vec2 p) { vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973)); p3 += dot(p3, p3.yzx + 33.33); return fract((p3.xx + p3.yz) * p3.zy); } +// simplex noise 3D (Ashima Arts / Stefan Gustavson, MIT) +vec3 mod289(vec3 x) { return x - floor(x * (1. / 289.)) * 289.; } +vec4 mod289(vec4 x) { return x - floor(x * (1. / 289.)) * 289.; } +vec4 permute(vec4 x) { return mod289(((x * 34.) + 1.) * x); } +vec4 taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; } +float snoise(vec3 v) { + const vec2 C = vec2(1. / 6., 1. / 3.); const vec4 D = vec4(0., .5, 1., 2.); + vec3 i = floor(v + dot(v, C.yyy)); vec3 x0 = v - i + dot(i, C.xxx); + vec3 g = step(x0.yzx, x0.xyz); vec3 l = 1. - g; vec3 i1 = min(g.xyz, l.zxy); vec3 i2 = max(g.xyz, l.zxy); + vec3 x1 = x0 - i1 + C.xxx; vec3 x2 = x0 - i2 + C.yyy; vec3 x3 = x0 - D.yyy; + i = mod289(i); + vec4 p = permute(permute(permute(i.z + vec4(0., i1.z, i2.z, 1.)) + i.y + vec4(0., i1.y, i2.y, 1.)) + i.x + vec4(0., i1.x, i2.x, 1.)); + float n_ = 0.142857142857; vec3 ns = n_ * D.wyz - D.xzx; + vec4 j = p - 49. * floor(p * ns.z * ns.z); + vec4 x_ = floor(j * ns.z); vec4 y_ = floor(j - 7. * x_); + vec4 x = x_ * ns.x + ns.yyyy; vec4 y = y_ * ns.x + ns.yyyy; vec4 h = 1. - abs(x) - abs(y); + vec4 b0 = vec4(x.xy, y.xy); vec4 b1 = vec4(x.zw, y.zw); + vec4 s0 = floor(b0) * 2. + 1.; vec4 s1 = floor(b1) * 2. + 1.; vec4 sh = -step(h, vec4(0.)); + vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww; + vec3 p0 = vec3(a0.xy, h.x); vec3 p1 = vec3(a0.zw, h.y); vec3 p2 = vec3(a1.xy, h.z); vec3 p3 = vec3(a1.zw, h.w); + vec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3))); + p0 *= norm.x; p1 *= norm.y; p2 *= norm.z; p3 *= norm.w; + vec4 m = max(.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.); m = m * m; + return 42. * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3))); +} +// premultiplied "over": c with coverage a goes on top of dst +void over(inout vec4 dst, vec3 c, float a) { a = clamp(a, 0., 1.); dst = vec4(c * a, a) + dst * (1. - a); } +vec2 frag() { return (gl_FragCoord.xy - 0.5 * uRes) * uPx; } +`; + const WATER = ` +uniform float uHead, uLen, uSurge, uMid, uFlowA, uFlowB, uFlowW; +uniform sampler2D uWet; // how recently each stretch of pipe was under water, 1 = now +const float RI = 0.84; // bore radius / outer radius: the rest is glass wall +const float MEN = 0.55; // meniscus depth, fraction of bore radius +// x: coverage, y: distance behind the head along the pipe, z: distance inside the nearest meniscus +vec3 slug(float s, float vi) { + float rel = mod(uHead - s + 24., PER) - 24.; + float gap = PER - uLen, full = 1. - smoothstep(0.3, 1.5, gap); // O: the two ends meet and the ring closes + float c = sqrt(max(0., 1. - vi * vi)); + float m = MEN * HW * RI * smoothstep(0., 30., gap); + float front = m * c * (1. - 0.4 * uSurge); // concave: the water climbs the wall ahead of the centre + float back = uLen + m * (1. - c) * (1. + 0.4 * uSurge); + float dIn = mix(min(rel - front, back - rel), 60., full); + return vec3(clamp(dIn / uPx + 0.5, 0., 1.), rel, dIn); +} +// noise laid on a circle, so the texture wraps the loop without a seam +float ringNoise(float s, float vi, float freq, float z) { + float a = 6.2831853 * s / PER, R = PER / 6.2831853 * freq; + return snoise(vec3(R * cos(a) + uTime * 0.3, R * sin(a) - uTime * 0.2, vi * 1.25 + z)); +} +float flowTex(float s, float vi, float z) { + return 0.5 + 0.5 * (0.6 * ringNoise(s, vi, 0.06, z) + 0.28 * ringNoise(s, vi * 1.8, 0.13, z + 3.1) + 0.12 * ringNoise(s, vi * 3.6, 0.27, z + 7.7)); +} +void main() { + vec2 p = frag(); + vec4 o = vec4(0.); + // contact shadow thrown down-left, and the light the water focuses into it + vec2 so = -L2 * 5.5; + vec2 ps = p - so; + float dsh = sdRB(ps); + float sr = abs(dsh) / HW; // glass passes most light: the shadow is darkest under the walls + o.a = (1. - smoothstep(-4., 10., abs(dsh) - HW)) * mix(0.05, 0.2, uDark) + exp(-pow((sr - 0.95) / 0.35, 2.)) * mix(0.08, 0.06, uDark); + { + vec3 Ws = slug(pathS(ps), clamp(dsh / (HW * RI), -1., 1.)); + float cz = exp(-pow((dsh / HW + 0.2) / 0.3, 2.)) * Ws.x; + o.rgb += mix(uColor, vec3(1.), 0.25) * cz * mix(0.45, 0.12, uDark); + } + float dc = sdRB(p); + float v = dc / HW; + float tube = clamp((HW - abs(dc)) / uPx + 0.5, 0., 1.); + if (tube <= 0.) { gl_FragColor = o; return; } + vec2 n2 = normalize(p - clamp(p, -H, H) + 1e-4); + vec2 t2 = vec2(-n2.y, n2.x); + float s = pathS(p); + float vc = clamp(v, -1., 1.); + vec3 N = vec3(n2 * vc, sqrt(max(0., 1. - vc * vc))); + vec3 Ld = normalize(vec3(L2 * 0.78, 0.62)); + vec3 Hh = normalize(Ld + vec3(0., 0., 1.)); + vec3 gTint = mix(vec3(0.42, 0.50, 0.53), vec3(0.78, 0.88, 0.92), uDark); + vec3 hiC = vec3(1.0, 0.985, 0.95); + // glass: the walls are thicker to the eye near the silhouette + float gl = 2. * (sqrt(max(0., 1. - vc * vc)) - sqrt(max(0., RI * RI - vc * vc))); + float gA = 1. - exp(-gl * 0.42); + over(o, gTint, gA * 0.3 * tube); + float vi = clamp(v / RI, -1., 1.); + float bore = clamp((RI * HW - abs(dc)) / uPx + 0.5, 0., 1.); + vec3 W = slug(s, vi); + float cov = W.x * bore; + vec2 hl = vec2(dot(L2, -t2), dot(L2, n2)); // light direction in the slug's local frame + vec3 wetC = mix(uColor, vec3(1.), 0.35); + // where the water has just left: a film on the walls and beads that drain away + float wet = texture2D(uWet, vec2(s / PER, 0.5)).r * (1. - W.x); + if (wet > 0.01 && bore > 0.) { + over(o, wetC, wet * 0.22 * smoothstep(0.5, 0.95, abs(vi)) * bore); + float cs = PER / 110.; + float gx = floor(s / cs), gy = floor((vi + 1.) * 2.); + for (int a = -1; a <= 1; a++) for (int b = -1; b <= 1; b++) { + vec2 cell = vec2(gx + float(a), gy + float(b)); + if (cell.y < 0. || cell.y > 3.) continue; + vec2 hc = vec2(mod(cell.x, 110.), cell.y); + vec2 h = hash22(hc); + float h3 = hash12(hc.yx + 17.); + float pres = smoothstep(h3, h3 + 0.3, wet * 1.2) * step(0.45, hash12(hc + 3.7)); + if (pres <= 0.01) continue; + vec2 c = vec2((cell.x + h.x) * cs, clamp(-1. + (cell.y + h.y) * 0.5, -0.88, 0.88)); + float r = mix(0.35, 1.3, h.x * h.y) * sqrt(pres); + vec2 dl = vec2(s - c.x, (vi - c.y) * RI * HW); + float d = length(dl) - r; + float fill = clamp(-d / uPx + 0.5, 0., 1.) * bore; + over(o, wetC * 0.75, fill * 0.45); + over(o, uColor * 0.4, exp(-pow(d / 0.25, 2.)) * 0.35 * bore); + over(o, hiC, exp(-pow(length(dl - vec2(-hl.x, hl.y) * r * 0.45) / (0.28 * r + 0.08), 2.)) * 0.85 * bore); + } + } + if (cov > 0.) { + float th = sqrt(max(0., 1. - vi * vi)); + float kv = 1. + 0.4 * (1. - 2. * vi * vi); // the centre runs ahead of the walls + float tex = mix(flowTex(s - kv * uFlowA, vi, 0.), flowTex(s - kv * uFlowB, vi, 7.3), uFlowW); + float side = dot(n2 * vi, L2); + vec3 wc = mix(mix(uColor, vec3(1.), 0.55), uColor, smoothstep(0.05, 0.9, th)); // Beer-Lambert: thicker is deeper + wc *= 1. - 0.55 * smoothstep(0.62, 1.0, abs(vi)); // total internal reflection at the wall + wc += mix(uColor, vec3(1.), 0.65) * exp(-pow((side + 0.42) / 0.17, 2.)) * 0.42; // caustic on the far wall + wc *= 0.8 + 0.4 * tex; + float spA = smoothstep(0.62, 0.9, ringNoise(s - kv * uFlowA, vi * 4., 0.45, 11.)); + float spB = smoothstep(0.62, 0.9, ringNoise(s - kv * uFlowB, vi * 4., 0.45, 19.)); + wc += 0.25 * mix(spA, spB, uFlowW); + wc *= 1. - 0.6 * exp(-pow(W.z / 1.1, 2.)); // meniscus: dark refracted band + wc += 0.5 * exp(-pow((W.z - 2.1) / 0.7, 2.)) * mix(uColor, vec3(1.), 0.75); // and its bright inner lip + over(o, wc, (0.58 + 0.34 * th + 0.2 * exp(-pow(W.z / 1.5, 2.))) * cov); + // entrained bubbles ride the flow; they only move when the water does + float full = 1. - smoothstep(0.3, 1.5, PER - uLen); + for (int i = 0; i < 12; i++) { + float fi = float(i); + float bv = (hash11(fi + 1.3) * 2. - 1.) * 0.62; + float br = mix(0.5, 1.9, hash11(fi + 7.9) * hash11(fi + 3.1)); + float bk = 1. + 0.35 * (1. - 2. * bv * bv) + 0.2 * (hash11(fi + 4.4) - 0.5); + float bs = mod(hash11(fi + 9.2) * PER + bk * uMid, PER); + float bx = mod(uHead - bs + 24., PER) - 24.; + float fade = mix(smoothstep(4., 9., bx) * smoothstep(uLen, uLen - 9., bx), 1., full); + vec2 dl = vec2(W.y - bx, (vi - bv) * RI * HW); + dl.x -= PER * floor(dl.x / PER + 0.5); + float d = length(dl) - br; + if (d < 1.2 && fade > 0.) { + float f = fade * cov; + over(o, mix(wc, vec3(1.), 0.5), clamp(-d / uPx + 0.5, 0., 1.) * 0.3 * f); + over(o, wc * 0.3, exp(-pow(d / 0.28, 2.)) * 0.6 * f); + over(o, hiC, exp(-pow(length(dl - hl * br * 0.42) / (0.22 * br + 0.12), 2.)) * 0.9 * f); + } + } + } + // front wall, reflections + over(o, gTint, gA * 0.3 * tube); + float ndh = max(dot(N, Hh), 0.); + float spec = pow(ndh, 110.) * 0.95 + pow(ndh, 14.) * 0.09; + spec += pow(max(dot(vec3(-N.xy, N.z), Hh), 0.), 70.) * 0.28; // the back inner surface + float fres = pow(1. - N.z, 3.) * mix(0.12, 0.3, uDark); + float wl = exp(-pow((abs(v) - RI) * HW / 0.3, 2.)) * 0.2; // bore wall seen edge-on + over(o, hiC, (spec + fres + wl) * tube); + over(o, gTint * 0.55, exp(-pow((abs(v) - 1.) * HW / 0.45, 2.)) * mix(0.45, 0.1, uDark) * tube); + gl_FragColor = o; +}`; + const SMOKE = ` +uniform vec4 uPuff[${NPUFF}]; // one puff per stretch of the frame: centre xy, radius, weight +const float W0 = ${W0.toFixed(4)}; +float fbm(vec3 p) { float f = 0., a = 0.55; for (int i = 0; i < 4; i++) { f += a * snoise(p); p = p * 2.03 + vec3(1.7, 9.2, 3.1); a *= 0.42; } return f; } +vec2 warpAt(vec2 p) { vec3 np = vec3(p * 0.022, uTime * 0.12); return vec2(snoise(np), snoise(np + vec3(19.1, 7.3, 3.7))); } +// x: density, y: mean growth of the puffs here (released smoke has grown) +vec2 puffs(vec2 p, vec2 warp) { + float D = 0., G = 0.; + for (int i = 0; i < ${NPUFF}; i++) { + vec4 f = uPuff[i]; + float grow = f.z - W0; + vec2 q = p - warp * (1.5 + 0.6 * grow) - f.xy; // turbulence displaces older smoke further (kept below folding) + float g = f.w * exp(-dot(q, q) / (f.z * f.z)); + D += g; G += g * grow; + } + return vec2(D, G / max(D, 1e-5)); +} +void main() { + vec2 p = frag(); + vec2 wp = warpAt(p); + vec2 P = puffs(p, wp); + float ext = min(0.5 * uRes.x * uPx - abs(p.x), 0.5 * uRes.y * uPx - abs(p.y)); + P.x *= smoothstep(0., 16., ext); + if (P.x < 0.004) { gl_FragColor = vec4(0.); return; } + // billows: domain-warped noise evolving in place, eaten away as the smoke ages + vec2 pw = p - wp * (1.5 + 0.6 * P.y); + vec3 dp = vec3(pw * 0.035, uTime * 0.16); + vec2 q = vec2(snoise(dp), snoise(dp + vec3(5.2, 1.3, 2.8))); + float n = fbm(vec3(pw * 0.045 + 1.1 * q, uTime * 0.2 + 3.)); + float bil = smoothstep(-0.7, 0.55, n + 0.1 - 0.04 * P.y); + float d = P.x * (0.5 + 0.75 * bil); + // light from the upper right: shade by how much smoke lies toward it + vec2 pl = p + L2 * 7.; + float dl = puffs(pl, warpAt(pl)).x; + float lit = clamp(mix(0.55, 0.85, uDark) - (dl - P.x) * mix(1.3, 0.9, uDark), 0., 1.) * (0.88 + 0.16 * bil); + float a = 1. - exp(-d * 1.9); + vec3 shade = uColor * mix(vec3(0.62, 0.64, 0.70), vec3(0.50, 0.53, 0.60), uDark); + vec3 c = mix(shade, uColor, clamp(lit, 0., 1.)); + c += uColor * 0.18 * (1. - a) * lit; // thin wisps let light through + gl_FragColor = vec4(min(c, vec3(1.)) * a, a); +}`; + const NEON = ` +uniform float uSegA, uLen, uMix, uMove, uHum, uTR; +uniform vec3 uColA, uColB; +uniform vec2 uPts[${NPTS}]; +vec3 emit(float s) { + float x = mod(s - uSegA, PER); // distance ahead of the tail + float din = x <= uLen ? min(x, uLen - x) : -min(x - uLen, PER - x); + din = mix(din, 1e3, step(PER - 0.5, uLen)); + float on = smoothstep(-0.6, 0.6, din); + float strike = uMove * exp(-max(uLen - x, 0.) / 18.) * on; // the end being struck stutters while it runs + float fl = mix(1., 0.15 + 0.85 * step(0.3, hash12(vec2(floor(x / 6.), floor(uTime * 30.)))), strike); + float after = uMove * exp(-mod(uSegA - s, PER) / 10.) * (1. - on) * 0.6; // the tail lets go with an afterglow + vec3 col = mix(uColB, uColA, uMix); + return (col * (on * fl * (1. + 0.6 * strike) + after) + vec3(0.35) * strike * fl) * uHum; +} +void main() { + vec2 p = frag(); + float dc = sdRB(p), d = abs(dc), s = pathS(p); + vec3 e = emit(s); + // light spilling onto the wall: integrated over the whole tube so every lit stretch contributes + vec3 g = vec3(0.); + for (int i = 0; i < ${NPTS}; i++) { + vec2 dv = p - uPts[i]; + float r2 = dot(dv, dv); + g += emit((float(i) + 0.5) * (PER / ${NPTS}.)) * (exp(-r2 / 60.) + 0.35 * exp(-r2 / 420.)); + } + g *= (PER / ${NPTS}.) / 40.; + float vt = clamp(dc / uTR, -1., 1.); + float tm = clamp((uTR - d) / uPx + 0.5, 0., 1.); + float I = max(max(e.r, e.g), e.b); + float core = exp(-vt * vt * 3.2); + vec3 tubeL = e * (0.4 + 0.85 * core) + vec3(1.) * I * pow(core, 4.) * 0.55; // white-hot centre, saturated rim + vec3 nearL = e * exp(-max(d - uTR * 0.8, 0.) / 1.2) * 0.6; + vec3 L = g + nearL * (1. - tm) + tubeL * tm; + vec3 mapped = 1. - exp(-L * 1.25); + // the glass itself, visible where it is dark + vec2 n2 = normalize(p - clamp(p, -H, H) + 1e-4); + vec3 N = vec3(n2 * vt, sqrt(max(0., 1. - vt * vt))); + vec3 Hh = normalize(normalize(vec3(L2 * 0.78, 0.62)) + vec3(0., 0., 1.)); + vec3 gTint = mix(vec3(0.22, 0.24, 0.27), vec3(0.62, 0.66, 0.72), uDark); + vec4 o = vec4(0.); + over(o, gTint, tm * (0.14 + 0.35 * pow(1. - N.z, 2.)) * (1. - clamp(I, 0., 1.) * 0.6)); + if (uDark > 0.5) o.rgb += mapped; + else { // on paper light can't add; lay the hue down instead, keeping it saturated + vec3 Lc = g + nearL * (1. - tm) + e * (0.4 + 0.85 * core) * tm; + float m = max(max(Lc.r, Lc.g), Lc.b); + over(o, Lc / max(m, 1e-3), (1. - exp(-m * 1.4)) * mix(0.85, 1., tm)); + over(o, vec3(1.), pow(core, 4.) * min(I, 1.) * 0.6 * tm); + } + over(o, vec3(1.), pow(max(dot(N, Hh), 0.), 60.) * 0.5 * tm); + gl_FragColor = o; +}`; + const SRC = { water: WATER, smoke: SMOKE, neon: NEON }; + const PAD = { water: 1.3, smoke: 1.9, neon: 1.8 }; + const DEFAULTS = { + water: { color: "#2FA8FF" }, + smoke: { color: "#F5F5F2" }, + neon: { colors: ["#FF2E88", "#2EF0FF", "#FFB020", "#7CFF4F", "#9B5CFF"], tube: 0.58 }, + }; + const COMMON = { sequence: "LUCIO", hold: 0.7, morph: 0.45, speed: 1, size: 96 }; + const rgb = hex => { const h = hex.replace("#", ""), f = h.length === 3 ? h.split("").map(c => c + c).join("") : h; return [0, 2, 4].map(i => parseInt(f.slice(i, i + 2), 16) / 255); }; + const reduced = () => global.matchMedia && global.matchMedia("(prefers-reduced-motion: reduce)").matches; + const ease = f => f < 0.5 ? 4 * f * f * f : 1 - Math.pow(-2 * f + 2, 3) / 2; + const fract = x => x - Math.floor(x); + const hash = n => fract(Math.sin(n * 127.1 + 11.7) * 43758.5453); + const smooth = (a, b, x) => { const k = Math.min(1, Math.max(0, (x - a) / (b - a))); return k * k * (3 - 2 * k); }; + function bgIsDark(el) { + for (let n = el; n && n.nodeType === 1; n = n.parentElement) { + const m = getComputedStyle(n).backgroundColor.match(/[\d.]+/g); + if (m && (m.length < 4 || +m[3] > 0.5)) return (0.2126 * m[0] + 0.7152 * m[1] + 0.0722 * m[2]) / 255 < 0.5; + } + return !!(global.matchMedia && global.matchMedia("(prefers-color-scheme: dark)").matches); + } + const LET = { C: [0, .75], L: [.25, .75], U: [.25, 1], I: [.75, 1], O: [.75, 1.75] }; + function speller(o) { + const seq = () => { const s = (o.sequence || "LUCIO").toUpperCase().split("").filter(c => LET[c]); return s.length ? s : ["O"]; }; + const target = (cur, ch) => { const [s2, e2] = LET[ch]; for (let q = -1; q < 6; q++) { if (s2 + q >= cur[0] - 1e-6 && e2 + q >= cur[1] - 1e-6) return [s2 + q, e2 + q]; } return [s2, e2]; }; + const st = { i: 0, j: 0, seg: LET[seq()[0]].slice(), u: 1, f: 1, moving: false, travel: 0, vHead: 0 }; + let from = st.seg, to = st.seg, timer = 0; + st.step = dt => { + const before = st.seg.slice(); + timer += dt; + if (!st.moving && timer >= o.hold) { + const s = seq(); st.j = (st.i + 1) % s.length; from = st.seg.slice(); to = target(st.seg, s[st.j]); + st.moving = true; timer -= o.hold; + } + if (st.moving) { + const dur = reduced() ? 0 : o.morph; + st.f = dur > 0 ? Math.min(1, timer / dur) : 1; st.u = ease(st.f); + st.seg = [from[0] + (to[0] - from[0]) * st.u, from[1] + (to[1] - from[1]) * st.u]; + if (st.f >= 1) { st.moving = false; st.i = st.j; timer = 0; } + } else { st.f = 1; st.u = 1; } + st.travel += ((st.seg[0] - before[0]) + (st.seg[1] - before[1])) / 2 * PER; + st.vHead = dt > 0 ? (st.seg[1] - before[1]) * PER / dt : 0; + if (!st.moving) { const n = Math.floor(st.seg[0]); st.seg[0] -= n; st.seg[1] -= n; } + }; + st.units = () => ({ a: PER * (st.seg[0] + 0.25), len: Math.min(PER, (st.seg[1] - st.seg[0]) * PER) }); + st.reset = () => { st.i = st.j = 0; st.seg = LET[seq()[0]].slice(); st.moving = false; timer = 0; }; + return st; + } + const live = new Set(); + let raf = 0, last = 0; + function loop(now) { + const dt = last ? Math.min(0.1, (now - last) / 1000) : 0; last = now; + for (const inst of live) inst.frame(dt); + raf = live.size ? requestAnimationFrame(loop) : 0; + if (!raf) last = 0; + } + function create(kind, container, opts) { + const o = Object.assign({}, COMMON, DEFAULTS[kind], opts || {}); + const wrap = document.createElement("div"); + wrap.className = "lucio-fx lucio-fx-" + kind; + wrap.setAttribute("role", "img"); wrap.setAttribute("aria-label", "Loading"); + wrap.style.cssText = "position:relative;display:inline-block;vertical-align:middle;flex:none"; + const canvas = document.createElement("canvas"); + canvas.style.cssText = "position:absolute;pointer-events:none"; + wrap.appendChild(canvas); container.appendChild(wrap); + const gl = canvas.getContext("webgl", { premultipliedAlpha: true, alpha: true, antialias: false }); + if (!gl) { console.warn("LucioLoaders: WebGL unavailable"); return null; } + const sh = (type, src) => { const s = gl.createShader(type); gl.shaderSource(s, src); gl.compileShader(s); if (!gl.getShaderParameter(s, gl.COMPILE_STATUS)) throw new Error(kind + ": " + gl.getShaderInfoLog(s)); return s; }; + const prog = gl.createProgram(); + gl.attachShader(prog, sh(gl.VERTEX_SHADER, "attribute vec2 a; void main(){ gl_Position = vec4(a, 0., 1.); }")); + gl.attachShader(prog, sh(gl.FRAGMENT_SHADER, PRELUDE + SRC[kind])); + gl.linkProgram(prog); + if (!gl.getProgramParameter(prog, gl.LINK_STATUS)) throw new Error(kind + ": " + gl.getProgramInfoLog(prog)); + gl.useProgram(prog); + gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer()); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW); + gl.enableVertexAttribArray(0); gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0); + const U = {}; const u = n => n in U ? U[n] : (U[n] = gl.getUniformLocation(prog, n)); + if (kind === "neon") { const pts = []; for (let i = 0; i < NPTS; i++) pts.push(...pathP((i + 0.5) * PER / NPTS)); gl.uniform2fv(u("uPts[0]"), new Float32Array(pts)); } + const BINS = 64, wetAt = new Float32Array(BINS).fill(-1e3), wetTex = new Uint8Array(BINS); + if (kind === "water") { + gl.bindTexture(gl.TEXTURE_2D, gl.createTexture()); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.uniform1i(u("uWet"), 0); + } + const puff = new Float32Array(NPUFF * 4), pDen = new Float32Array(NPUFF), pAge = new Float32Array(NPUFF); + const sp = speller(o); + const inside = (s, a, len) => { if (len >= PER - 0.5) return 1e3; const x = ((s - a) % PER + PER) % PER; return x <= len ? Math.min(x, len - x) : -Math.min(x - len, PER - x); }; + let t = 0, dark = o.theme === "light" ? false : o.theme === "dark" ? true : bgIsDark(container), frames = 0, visible = true; + const io = global.IntersectionObserver ? new IntersectionObserver(es => { visible = es[0].isIntersecting; }) : null; + if (io) io.observe(wrap); + function setSize(px) { + o.size = px; + const dpr = Math.min(global.devicePixelRatio || 1, 2), c = px * PAD[kind]; + wrap.style.width = wrap.style.height = px + "px"; + canvas.style.width = canvas.style.height = c + "px"; + canvas.style.left = canvas.style.top = (-(c - px) / 2) + "px"; + canvas.width = canvas.height = Math.round(c * dpr); + gl.viewport(0, 0, canvas.width, canvas.height); + gl.uniform2f(u("uRes"), canvas.width, canvas.height); + gl.uniform1f(u("uPx"), 120 / (px * canvas.width / c)); + } + setSize(o.size); + function frame(dt) { + if (o.theme === "auto" || !o.theme) { if (++frames % 30 === 0) dark = bgIsDark(container); } + if (!visible) return; + dt *= o.speed; + t += dt * (reduced() ? 0.35 : 1); + sp.step(dt); + const { a, len } = sp.units(); + gl.uniform1f(u("uTime"), t); + gl.uniform1f(u("uDark"), dark ? 1 : 0); + if (kind === "water") { + const Df = 70, pa = fract(sp.travel / Df), pb = fract(sp.travel / Df + 0.5); + gl.uniform3fv(u("uColor"), rgb(o.color)); + gl.uniform1f(u("uHead"), a + len); gl.uniform1f(u("uLen"), len); + gl.uniform1f(u("uSurge"), Math.min(1, Math.max(0, sp.vHead / 700))); + gl.uniform1f(u("uMid"), sp.travel); + gl.uniform1f(u("uFlowA"), pa * Df); gl.uniform1f(u("uFlowB"), pb * Df); + gl.uniform1f(u("uFlowW"), 1 - Math.abs(2 * pb - 1)); + for (let i = 0; i < BINS; i++) { + if (inside((i + 0.5) * PER / BINS, a, len) > -2) wetAt[i] = t; + wetTex[i] = Math.round(255 * Math.exp(-(t - wetAt[i]) / 1.1)); + } + gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, BINS, 1, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, wetTex); + } else if (kind === "smoke") { + gl.uniform3fv(u("uColor"), rgb(o.color)); + const kIn = 1 - Math.exp(-dt * 20), kOut = Math.exp(-dt * 4.2); + for (let i = 0; i < NPUFF; i++) { + const s = (i + 0.5) * PER / NPUFF, cover = smooth(-6, 6, inside(s, a, len)); + if (cover >= pDen[i]) { pDen[i] += (cover - pDen[i]) * kIn; pAge[i] *= Math.exp(-dt * 8); } + else { pDen[i] = Math.max(cover, pDen[i] * kOut); pAge[i] += dt; } + const w = W0 + 10 * pAge[i], [x, y] = pathP(s); + puff.set([x, y + 9 * pAge[i], w, pDen[i] * (W0 * 1.6 / (w + 0.6 * W0)) * (PER / NPUFF) / (1.7725 * w)], i * 4); + } + gl.uniform4fv(u("uPuff[0]"), puff); + } else { + const pal = o.colors.map(rgb), n = pal.length; + gl.uniform1f(u("uTR"), HW * o.tube); + gl.uniform1f(u("uHum"), 0.975 + 0.025 * Math.sin(t * 46) * Math.sin(t * 7.3) + (hash(Math.floor(t * 9)) > 0.985 ? -0.2 : 0)); + gl.uniform1f(u("uSegA"), a); gl.uniform1f(u("uLen"), len); + gl.uniform3fv(u("uColB"), pal[sp.i % n]); gl.uniform3fv(u("uColA"), pal[(sp.moving ? sp.j : sp.i) % n]); + gl.uniform1f(u("uMix"), sp.moving ? smooth(0.05, 0.35, sp.f) : 1); + gl.uniform1f(u("uMove"), sp.moving ? Math.sin(Math.PI * sp.f) : 0); + } + gl.drawArrays(gl.TRIANGLES, 0, 3); + } + const inst = { frame }; + live.add(inst); + if (!raf) raf = requestAnimationFrame(loop); + return { + el: wrap, canvas, + tick: frame, + setColor(c) { o.color = c; if (kind === "neon") o.colors = [c]; }, + setColors(cs) { o.colors = cs.slice(); }, + setTiming({ hold, morph }) { if (hold != null) o.hold = hold; if (morph != null) o.morph = morph; }, + setSequence(seq) { o.sequence = seq; sp.reset(); }, + setSpeed(s) { o.speed = s; }, + setSize, + setTheme(th) { o.theme = th; dark = th === "light" ? false : th === "dark" ? true : bgIsDark(container); }, + stop() { live.delete(inst); if (io) io.disconnect(); wrap.remove(); const ext = gl.getExtension("WEBGL_lose_context"); if (ext) ext.loseContext(); }, + }; + } + global.LucioLoaders = { + water: (el, opts) => create("water", el, opts), + smoke: (el, opts) => create("smoke", el, opts), + neon: (el, opts) => create("neon", el, opts), + geometry: { HB, CR, HW, PER, pathP, LET }, + }; +})(window); diff --git a/web/src/app.ts b/web/src/app.ts index f5632b3..82af90c 100644 --- a/web/src/app.ts +++ b/web/src/app.ts @@ -1,4 +1,4 @@ -import { mountWordmark } from "./brand"; +import { mountSignoffMark, mountWordmark } from "./brand"; import { TileCache, cacheBudget } from "./cache"; import { entropyScore, startEntropy } from "./entropy"; import { guardLink, takeNav, type GuardOptions } from "./gate"; @@ -79,8 +79,32 @@ function showLoadError(): void { document.querySelector(".load-error")?.removeAttribute("hidden"); } +function mountFooterMarks(): void { + const holders = Array.from(document.querySelectorAll(".site-footer .chop")); + if (holders.length === 0) { + return; + } + if (typeof IntersectionObserver !== "function") { + holders.forEach(mountSignoffMark); + return; + } + const observer = new IntersectionObserver( + (entries) => { + for (const entry of entries) { + if (entry.isIntersecting) { + observer.unobserve(entry.target); + mountSignoffMark(entry.target as HTMLElement); + } + } + }, + { rootMargin: "200px" }, + ); + holders.forEach((holder) => observer.observe(holder)); +} + function boot(): void { startEntropy(); + mountFooterMarks(); const settings = readSettings(document.body); if (settings.page === "album") { const stage = document.getElementById("stage"); diff --git a/web/src/brand.ts b/web/src/brand.ts index a07e5ac..98e1651 100644 --- a/web/src/brand.ts +++ b/web/src/brand.ts @@ -1,4 +1,5 @@ import "../brand/lucio-morph.js"; +import "../brand/lucio-loaders.js"; export interface MorphHandle { play(): void; @@ -25,7 +26,7 @@ export interface WordmarkOptions { export interface LoaderOptions { size?: number; color?: string; - track?: string; + track?: string | null; rays?: string; hold?: number; morph?: number; @@ -36,11 +37,28 @@ interface LucioMorphApi { loader(container: Element, options?: LoaderOptions): LoaderHandle; } +interface SmokeOptions { + size?: number; + color?: string; + theme?: "dark" | "light" | "auto"; +} + +interface SmokeHandle { + el: HTMLElement; + setSize(px: number): void; + stop(): void; +} + +interface LucioLoadersApi { + smoke(container: Element, options?: SmokeOptions): SmokeHandle | null; +} + export const palette = { graphite: "#111114", graphite3: "#26262D", paper: "#F3F1EC", beam: "#FFF3CF", + smoke: "#F5F5F2", }; export function lucioMorph(): LucioMorphApi | null { @@ -67,11 +85,53 @@ export function mountWordmark(link: HTMLElement, animated: boolean): MorphHandle return handle; } -export function cloneChop(): HTMLElement | null { - const template = document.getElementById("chop-template"); - if (!(template instanceof HTMLTemplateElement)) { - return null; +const fallbackMarkSize = 44; + +function markSize(holder: HTMLElement): number { + return Math.round(holder.getBoundingClientRect().width) || fallbackMarkSize; +} + +// The sign-off mark: the LUCIO loader in smoke, or the plain SVG loader where WebGL is unavailable. +// Replaces whatever the holder contains (the server-rendered chop) once it can draw. +export function mountSignoffMark(holder: HTMLElement): void { + if (holder.dataset.mounted === "1") { + return; } - const node = template.content.firstElementChild; - return node ? (node.cloneNode(true) as HTMLElement) : null; + const size = markSize(holder); + const loaders = (window as unknown as { LucioLoaders?: LucioLoadersApi }).LucioLoaders; + const fallback = Array.from(holder.childNodes); + holder.replaceChildren(); + let smoke: SmokeHandle | null = null; + try { + smoke = loaders ? loaders.smoke(holder, { size, theme: "dark", color: palette.smoke }) : null; + } catch { + smoke = null; + } + if (smoke) { + smoke.el.removeAttribute("role"); + smoke.el.removeAttribute("aria-label"); + const handle = smoke; + if (typeof ResizeObserver === "function") { + let last = size; + new ResizeObserver(() => { + const next = markSize(holder); + if (next !== last) { + last = next; + handle.setSize(next); + } + }).observe(holder); + } + } else { + holder.replaceChildren(); + const api = lucioMorph(); + if (api) { + const svg = api.loader(holder, { size, color: palette.paper, track: null, rays: palette.beam }).svg; + svg.setAttribute("aria-hidden", "true"); + svg.style.width = "100%"; + svg.style.height = "auto"; + } else { + holder.append(...fallback); + } + } + holder.dataset.mounted = "1"; } diff --git a/web/src/loader.ts b/web/src/loader.ts index 2c293ba..0ffe1c9 100644 --- a/web/src/loader.ts +++ b/web/src/loader.ts @@ -65,6 +65,46 @@ function until(promise: Promise, signal: AbortSignal, fallback: T): Promis const probeStep = 3; const seedUpscale = 4; +const fillBudgetMs = 6000; +const enhanceBudgetMs = 4000; +const goodThroughput = 1500; +const enhanceMemoryShare = 0.35; + +interface Outcome { + needed: number; + final: number; + throughput: number; +} + +interface NetworkHints { + saveData?: boolean; + effectiveType?: string; +} + +type HintedNavigator = Navigator & { connection?: NetworkHints; deviceMemory?: number }; + +function saveData(): boolean { + const connection = (navigator as HintedNavigator).connection; + return !!connection && (connection.saveData === true || /2g|3g/.test(connection.effectiveType ?? "")); +} + +function capableDevice(): boolean { + const nav = navigator as HintedNavigator; + if ((nav.hardwareConcurrency ?? 4) < 4) { + return false; + } + return typeof nav.deviceMemory !== "number" || nav.deviceMemory >= 4; +} + +function batchRate(results: PromiseSettledResult[], ms: number): number { + let bytes = 0; + for (const result of results) { + if (result.status === "fulfilled") { + bytes += result.value.bytes; + } + } + return bytes > 0 && ms > 0 ? bytes / ms : 0; +} export interface DrawTarget { g: CanvasRenderingContext2D; @@ -95,6 +135,8 @@ export class PhotoLoader { private settling = false; private session: AbortController | null = null; private prefetchController: AbortController | null = null; + private enhancer: AbortController | null = null; + private enhanceLevel = -1; finalLevel = -1; private targetLevel = -1; readonly status: LoadStatus = { active: false, started: 0, planned: 0, done: 0, sharp: false }; @@ -342,7 +384,7 @@ export class PhotoLoader { ); } - start(view: View, dpr: number, onSettled: () => void): void { + start(view: View, dpr: number, onSettled: () => void, enhance = false): void { this.stopSession(); const controller = new AbortController(); this.session = controller; @@ -353,8 +395,9 @@ export class PhotoLoader { this.status.done = 0; this.status.sharp = false; this.notify(); - void this.run(view, dpr, controller).then(() => { - if (this.session === controller) { + void this.run(view, dpr, controller).then((outcome) => { + const current = this.session === controller; + if (current) { this.session = null; this.status.active = false; this.notify(); @@ -362,10 +405,13 @@ export class PhotoLoader { if (!controller.signal.aborted || controller.signal.reason === "deadline") { onSettled(); } + if (enhance && current && outcome && !controller.signal.aborted) { + void this.enhance(view, outcome); + } }); } - private async run(view: View, dpr: number, controller: AbortController): Promise { + private async run(view: View, dpr: number, controller: AbortController): Promise { const signal = controller.signal; const started = performance.now(); const budget = this.env.settings.budgetMs; @@ -373,14 +419,14 @@ export class PhotoLoader { try { const ready = await until(this.ensurePool(), signal, false); if (signal.aborted) { - return; + return null; } if (ready && !this.open()) { this.settling = true; await this.env.keys.settle(this.pyramid.hash, signal); this.settling = false; if (signal.aborted) { - return; + return null; } } if (!ready || !this.open()) { @@ -389,11 +435,11 @@ export class PhotoLoader { ids.map((id) => () => this.fetchJumble(id, PRIORITY_CURRENT, signal)), controller, ); - return; + return null; } await this.ensureSeed(); if (signal.aborted) { - return; + return null; } const needed = neededLevel(this.pyramid, view.displayWidth, dpr); const probe = Math.max(0, needed - probeStep); @@ -416,7 +462,7 @@ export class PhotoLoader { } } if (signal.aborted) { - return; + return null; } this.finalLevel = Math.max(this.finalLevel, probe); const throughput = currentThroughput(); @@ -438,20 +484,80 @@ export class PhotoLoader { this.finalLevel = final; this.targetLevel = final; this.env.requestDraw(); + let measured = 0; for (const level of plan) { - await this.track( - this.uncached(level, view).map((tile) => () => this.fetchTile(tile, PRIORITY_CURRENT, signal)), + const tiles = this.uncached(level, view); + const at = performance.now(); + const results = await this.track( + tiles.map((tile) => () => this.fetchTile(tile, PRIORITY_CURRENT, signal)), controller, ); if (signal.aborted) { - return; + return null; + } + const rate = tiles.length >= 2 ? batchRate(results, performance.now() - at) : 0; + if (rate > 0) { + measured = recordThroughput(rate); } } + return { needed, final, throughput: measured || currentThroughput() }; } finally { clearTimeout(timer); } } + private async enhance(view: View, outcome: Outcome): Promise { + if (!this.opened || saveData()) { + return; + } + const levels = this.pyramid.levels; + const { needed } = outcome; + const top = capableDevice() ? Math.min(levels.length - 1, needed + 1) : needed; + if (outcome.final >= top) { + return; + } + this.enhancer?.abort(); + const controller = new AbortController(); + this.enhancer = controller; + const signal = controller.signal; + const memory = this.env.cache.budget * enhanceMemoryShare; + let throughput = outcome.throughput; + let spent = 0; + for (let level = Math.max(outcome.final + 1, needed); level <= top; level++) { + const extra = level > needed; + if (extra) { + const info = levels[level]; + const decoded = info.width * (view.u1 - view.u0) * info.height * (view.v1 - view.v0) * 4; + if (throughput < goodThroughput || decoded > memory) { + break; + } + } + spent += this.uncachedBytes(level, view) / throughput; + if (spent > (extra ? enhanceBudgetMs : fillBudgetMs)) { + break; + } + if (extra) { + this.enhanceLevel = Math.max(this.enhanceLevel, level); + } + const tiles = this.uncached(level, view); + const at = performance.now(); + const results = await Promise.allSettled(tiles.map((tile) => this.fetchTile(tile, PRIORITY_PREFETCH, signal))); + if (signal.aborted) { + return; + } + const rate = tiles.length >= 2 ? batchRate(results, performance.now() - at) : 0; + if (rate > 0) { + throughput = recordThroughput(rate); + } + if (!extra) { + this.finalLevel = Math.max(this.finalLevel, level); + } + } + if (this.enhancer === controller) { + this.enhancer = null; + } + } + prefetchProbe(view: View, dpr: number): void { const controller = this.resetPrefetch(); const signal = controller.signal; @@ -490,6 +596,8 @@ export class PhotoLoader { } stopSession(): void { + this.enhancer?.abort(); + this.enhancer = null; if (this.session) { this.session.abort("superseded"); this.session = null; @@ -558,9 +666,10 @@ export class PhotoLoader { const levels = this.pyramid.levels; const ids = this.ids; const needed = neededLevel(this.pyramid, target.displayWidth, target.dpr); + const topLevel = Math.max(needed, Math.min(this.enhanceLevel, needed + 1)); let base = -1; - for (let l = needed; ids && l >= 0 && base < 0; l--) { + for (let l = topLevel; ids && l >= 0 && base < 0; l--) { const range = tileRange(levels[l], view); if (!range) { continue; @@ -611,7 +720,7 @@ export class PhotoLoader { return animating; } - for (let l = Math.max(0, base); l <= needed; l++) { + for (let l = Math.max(0, base); l <= topLevel; l++) { const level = levels[l]; const range = tileRange(level, view); if (!range) { diff --git a/web/src/viewer.ts b/web/src/viewer.ts index 908598c..13078e3 100644 --- a/web/src/viewer.ts +++ b/web/src/viewer.ts @@ -1,4 +1,4 @@ -import { cloneChop, mountWordmark } from "./brand"; +import { mountSignoffMark, mountWordmark } from "./brand"; import { CaptionPanel, setLang } from "./caption"; import type { View } from "./geometry"; import { guardLink, type GuardOptions } from "./gate"; @@ -110,6 +110,7 @@ export class Viewer { private readonly indicator: BusyIndicator; private readonly progress: ProgressLine; private readonly homeMark: HTMLElement | null; + private readonly signoffMark: HTMLElement; private nextStrip: Strip | null = null; private nextSlug = ""; private idleTimer = 0; @@ -184,6 +185,9 @@ export class Viewer { throw new Error("canvas 2d unavailable"); } this.g = g; + this.signoffMark = document.createElement("span"); + this.signoffMark.className = "chop"; + this.signoffMark.setAttribute("aria-hidden", "true"); this.endCard = this.buildEndCard(); this.nextLink = this.endCard.querySelector("a.next-album") as HTMLAnchorElement; this.nextFrame = this.endCard.querySelector(".next-strip") as HTMLElement; @@ -234,10 +238,7 @@ export class Viewer { next.appendChild(frame); const signoff = document.createElement("div"); signoff.className = "signoff"; - const chop = cloneChop(); - if (chop) { - signoff.appendChild(chop); - } + signoff.appendChild(this.signoffMark); const signature = document.createElement("p"); signature.className = "signature"; signature.textContent = "— Lucio"; @@ -882,6 +883,9 @@ export class Viewer { if (stop.photo >= 0) { this.startSession(); } + if (stop.photo < 0 || stop.photo === this.manifest.photos.length - 1) { + mountSignoffMark(this.signoffMark); + } this.syncNextStrip(); this.updateCaption(); } @@ -984,11 +988,16 @@ export class Viewer { } const index = this.current; const loader = this.loader(stop.photo); - loader.start(this.viewAt(stop), this.dpr, () => { - if (this.current === index) { - this.prefetchAround(index); - } - }); + loader.start( + this.viewAt(stop), + this.dpr, + () => { + if (this.current === index) { + this.prefetchAround(index); + } + }, + true, + ); this.indicator.watch(loader); this.progress.watch(loader); }