From aaf7cafdf9f9696471d4322c3303d4839712ea4d Mon Sep 17 00:00:00 2001 From: Lucio Chen Date: Wed, 4 Nov 2026 20:56:12 -0800 Subject: [PATCH] Viewer zoom and sharper tiles Mouse wheel, trackpad and two-finger pinch zoom in the album viewer, up to one image pixel per device pixel; drag pans while zoomed and only the visible tiles of the needed level are loaded. Default WebP quality raised to top 90, mid 88, low 88, with smart_subsample for WebP tiles and the seed. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- docs/DESIGN.md | 4 +- internal/config/config.go | 2 +- internal/process/processor.go | 6 +- internal/process/pyramid.go | 6 +- internal/process/vips.go | 5 +- internal/site/static/app.js | 2 +- packaging/config.toml | 2 +- web/src/viewer.ts | 291 +++++++++++++++++++++++++++++++++- 9 files changed, 302 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 236df1f..fe463c9 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Unknown fields are errors, so typos are caught. | `images.tile_size` | `512` | Tile edge in pixels. | | `images.overlap` | `1` | Tile overlap in pixels. | | `images.format` | `"webp"` | `"webp"` or `"avif"` (AVIF needs a libheif AV1 encoder). | -| `images.quality` | `{ top = 82, mid = 85, low = 88 }` | Top two levels, levels above 1100 px, levels up to 1100 px. | +| `images.quality` | `{ top = 90, mid = 88, low = 88 }` | Top two levels, levels above 1100 px, levels up to 1100 px. | | `images.min_levels` | `6` | Minimum pyramid depth. | | `images.seed_px` | `48` | Long edge of the blurred placeholder. | | `images.tile_names` | `"hashed"` | Only `"hashed"` in v1. | diff --git a/docs/DESIGN.md b/docs/DESIGN.md index ed3b724..9892ccb 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -54,7 +54,7 @@ uploads (rsync/SFTP) -> /srv/luphoto/albums -> watcher (debounce) -> processor ( 1. Autorotate by EXIF orientation, convert to sRGB from the embedded profile. 2. Read camera, lens, focal length, aperture, shutter, ISO and date into the manifest. Drop everything else, including GPS. Tiles carry no metadata. 3. Pyramid: tiles 512 px, 1 px overlap; each level halves the previous one until the long edge is under 100 px. Level 0 is the smallest. -4. WebP by default (AVIF optional). Quality per level: `top` for the top two levels, `low` for levels whose long edge is at most 1100 px, `mid` otherwise. +4. WebP by default (AVIF optional); WebP tiles and the seed are saved with `smart_subsample` so chroma stays sharp. Quality per level: `top` for the top two levels, `low` for levels whose long edge is at most 1100 px, `mid` otherwise. 5. Seed: a 48 px (long edge) WebP, base64 inside the album manifest. 6. No resolution cap: the full-resolution level is stored; the loader never fetches beyond screen size × max_dpr. 7. Tile paths: `/t//.webp`. photo-hash = first 16 hex of SHA-256 over the original bytes + a processing-settings fingerprint. tile-id = first 16 hex of HMAC-SHA-256(site key, photo-hash|level|x|y). The site key is generated once and kept in the state folder. On disk and in developer tools the tiles are an unordered pile of patches; only the manifest maps them back. @@ -106,7 +106,7 @@ cache = "/var/cache/luphoto" tile_size = 512 overlap = 1 format = "webp" -quality = { top = 82, mid = 85, low = 88 } +quality = { top = 90, mid = 88, low = 88 } min_levels = 6 seed_px = 48 tile_names = "hashed" diff --git a/internal/config/config.go b/internal/config/config.go index 4bc1a3b..30a0a6c 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -105,7 +105,7 @@ func Defaults() Config { TileSize: 512, Overlap: 1, Format: "webp", - Quality: Quality{Top: 82, Mid: 85, Low: 88}, + Quality: Quality{Top: 90, Mid: 88, Low: 88}, MinLevels: 6, SeedPx: 48, TileNames: "hashed", diff --git a/internal/process/processor.go b/internal/process/processor.go index c380877..a20e5c5 100644 --- a/internal/process/processor.go +++ b/internal/process/processor.go @@ -113,11 +113,15 @@ func New(ctx context.Context, cfg *config.Config) (*Processor, error) { } img := cfg.Images keySum := sha256.Sum256(key) + format := img.Format + if format == "webp" { + format += "+smart_subsample" + } fingerprint := strings.Join([]string{ processorVersion, "tile=" + strconv.Itoa(img.TileSize), "overlap=" + strconv.Itoa(img.Overlap), - "format=" + img.Format, + "format=" + format, fmt.Sprintf("q=%d,%d,%d", img.Quality.Top, img.Quality.Mid, img.Quality.Low), "min_levels=" + strconv.Itoa(img.MinLevels), "seed=" + strconv.Itoa(img.SeedPx), diff --git a/internal/process/pyramid.go b/internal/process/pyramid.go index fac2331..2a096bc 100644 --- a/internal/process/pyramid.go +++ b/internal/process/pyramid.go @@ -107,7 +107,7 @@ func (p *Processor) renderOG(ctx context.Context, job *Job) (*Record, error) { } final := filepath.Join(p.OGDir, job.Hash+".jpg") tmp := fsutil.TempName(final) + ".jpg" - if err := p.vips.Run(ctx, "thumbnail", prepared, tmp+p.vips.SaveOptions(OGQuality), + if err := p.vips.Run(ctx, "thumbnail", prepared, tmp+p.vips.SaveOptions("jpeg", OGQuality), strconv.Itoa(OGWidth), "--height", strconv.Itoa(OGHeight), "--crop", "centre"); err != nil { _ = os.Remove(tmp) return nil, err @@ -323,7 +323,7 @@ func (p *Processor) resize(ctx context.Context, src, dst string, from, to [2]int func (p *Processor) seed(ctx context.Context, src, work string) (string, error) { out := filepath.Join(work, "seed."+p.images.Format) - if err := p.vips.Run(ctx, "thumbnail", src, out+p.vips.SaveOptions(p.images.Quality.Low), + if err := p.vips.Run(ctx, "thumbnail", src, out+p.vips.SaveOptions(p.images.Format, p.images.Quality.Low), strconv.Itoa(p.images.SeedPx), "--height", strconv.Itoa(p.images.SeedPx)); err != nil { return "", fmt.Errorf("seed: %w", err) } @@ -373,7 +373,7 @@ func (p *Processor) cutLevel(ctx context.Context, hash, src, stage string, level "--depth", "one", "--tile-size", strconv.Itoa(p.images.TileSize), "--overlap", strconv.Itoa(p.Overlap()), - "--suffix", ext+p.vips.SaveOptions(quality)); err != nil { + "--suffix", ext+p.vips.SaveOptions(p.images.Format, quality)); err != nil { return Level{}, err } dir, err := levelDir(base + "_files") diff --git a/internal/process/vips.go b/internal/process/vips.go index 916c9f5..5bee0a3 100644 --- a/internal/process/vips.go +++ b/internal/process/vips.go @@ -99,7 +99,10 @@ func (v *Vips) Run(ctx context.Context, args ...string) error { return nil } -func (v *Vips) SaveOptions(quality int) string { +func (v *Vips) SaveOptions(format string, quality int) string { + if format == "webp" { + return "[Q=" + strconv.Itoa(quality) + ",smart_subsample=true," + v.Strip + "]" + } return "[Q=" + strconv.Itoa(quality) + "," + v.Strip + "]" } diff --git a/internal/site/static/app.js b/internal/site/static/app.js index 263f811..20df0e8 100644 --- a/internal/site/static/app.js +++ b/internal/site/static/app.js @@ -1 +1 @@ -"use strict";(()=>{(function(r){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=(c,w)=>{let d=document.createElementNS(i,c);for(let u in w)d.setAttribute(u,w[u]);return d},n=()=>r.matchMedia&&r.matchMedia("(prefers-reduced-motion: reduce)").matches,o=c=>Math.max(0,Math.min(1,c)),a=c=>c*c*(3-2*c),l=.5;function h(c,w){let d=0,u=0,p=null,g=0;function A(y){let b=(y-g)/w;g=y,d=dv(1),reverse:()=>v(0),toggle:()=>v(u?0:1),set:y=>{cancelAnimationFrame(p),p=null,u=d=y,c(d)},stop:()=>{cancelAnimationFrame(p),p=null},get t(){return d}}}function m(c,w,d,u){let p=o(u)*w;if(c.style.visibility=p<.05?"hidden":"visible",d==="both"){let g=p/2;c.setAttribute("stroke-dasharray",g.toFixed(2)+" "+Math.max(0,w-2*g).toFixed(2)+" "+g.toFixed(2)),c.setAttribute("stroke-dashoffset","0")}else d==="end"?(c.setAttribute("stroke-dasharray",p.toFixed(2)+" "+(2*w+20).toFixed(2)),c.setAttribute("stroke-dashoffset",(-(w-p)).toFixed(2))):(c.setAttribute("stroke-dasharray",p.toFixed(2)+" "+(2*w+20).toFixed(2)),c.setAttribute("stroke-dashoffset","0"))}function M(c,w={}){let d=Object.assign({trigger:"hover",color:"currentColor",rays:"#FFF3CF",duration:450,autoDelay:1800},w),u=s("svg",{viewBox:"0 0 "+t.vbw+" "+t.vbh,role:"img","aria-label":"Guoliang Chen, Lucio"});u.style.display="block",u.style.width="100%",u.style.height="auto";let p=s("g",{transform:"translate("+t.pad+" "+t.pad+")",fill:"none",stroke:d.color,"stroke-width":t.stroke,"stroke-linejoin":"miter","stroke-linecap":"butt"});u.appendChild(p);let g=t.letters.map(b=>{let x=s("g",{transform:"translate("+b.x0+" 0)"});p.appendChild(x);let k=Object.assign({g:x,outEls:[],inEls:[]},b);if(b.kind==="fade")k.fadeEl=s("path",{d:b.d}),x.appendChild(k.fadeEl);else{k.fullA=s("path",{d:b.fullA}),x.appendChild(k.fullA),k.fullB=s("path",{d:b.fullB}),x.appendChild(k.fullB),b.shared&&x.appendChild(s("path",{d:b.shared}));for(let E of b.out){let S=s("path",{d:E.d});x.appendChild(S),k.outEls.push([S,E])}for(let E of b.in){let S=s("path",{d:E.d});x.appendChild(S),k.inEls.push([S,E])}}return b.dot&&(k.dotEl=s("rect",{x:b.dot[0],y:b.dot[1],width:b.dot[2],height:b.dot[2],rx:b.dot[2]*.22,fill:d.color,stroke:"none"}),x.appendChild(k.dotEl)),k}),A=s("path",{d:e,fill:d.rays,stroke:"none",opacity:0});p.appendChild(A),c.appendChild(u);function v(b){let x=a(o(b/l)),k=a(o((b-l)/(1-l)));for(let E of g){if(E.kind==="fade")E.fadeEl.setAttribute("opacity",(1-x).toFixed(3)),E.dotEl&&E.dotEl.setAttribute("opacity",(1-x).toFixed(3));else{for(let[S,C]of E.outEls)m(S,C.P,C.j,1-x);for(let[S,C]of E.inEls)m(S,C.P,C.j,x);E.fullA.style.visibility=x<=.001?"visible":"hidden",E.fullB.style.visibility=x>=.999?"visible":"hidden"}E.g.setAttribute("transform","translate("+(E.x0+(E.x1-E.x0)*k).toFixed(2)+" 0)")}A.setAttribute("transform","translate("+(g[0].x0+(g[0].x1-g[0].x0)*k).toFixed(2)+" 0) "+t.raysT),A.setAttribute("opacity",o((b-.8)/.2).toFixed(3))}let y=h(v,d.duration);return v(0),d.trigger==="hover"&&(c.addEventListener("mouseenter",y.play),c.addEventListener("mouseleave",y.reverse),c.addEventListener("focus",y.play),c.addEventListener("blur",y.reverse)),d.trigger==="click"&&c.addEventListener("click",y.toggle),d.trigger==="auto"&&setInterval(y.toggle,d.autoDelay+d.duration),Object.assign(y,{svg:u})}let L={C:[0,.75],L:[.25,.75],U:[.25,1],I:[.75,1],O:[.75,1.75]};function f(c,w,d){let u=w/2,p=d-u,g=u+p,A=p*Math.SQRT1_2,v=b=>b.toFixed(3);return{d:"M"+v(c-g+A)+" "+v(g-A)+"A"+v(p)+" "+v(p)+" 0 0 0 "+v(c-g)+" "+v(u)+"H"+v(g)+"A"+v(p)+" "+v(p)+" 0 0 0 "+v(u)+" "+v(g)+"V"+v(c-g)+"A"+v(p)+" "+v(p)+" 0 0 0 "+v(g)+" "+v(c-u)+"H"+v(c-g)+"A"+v(p)+" "+v(p)+" 0 0 0 "+v(c-u)+" "+v(c-g)+"V"+v(g)+"A"+v(p)+" "+v(p)+" 0 0 0 "+v(c-g+A)+" "+v(g-A)+"Z",P:4*(c-2*g)+2*Math.PI*p}}function T(c,w={}){let d=Object.assign({sequence:"LUCIO",color:"#F3F1EC",track:"#26262D",rays:"#FFF3CF",hold:480,morph:640,size:96,stroke:.17,radius:.22},w),u=120,p=u*d.stroke,g=u*d.radius,A=f(u,p,g),v=s("svg",{viewBox:"0 0 "+u+" "+u,width:d.size,height:d.size,role:"img","aria-label":"Loading"});d.track&&v.appendChild(s("path",{d:A.d,fill:"none",stroke:d.track,"stroke-width":p}));let y=s("path",{d:A.d,fill:"none",stroke:d.color,"stroke-width":p,"stroke-linecap":"butt"}),b=p/22,x=s("path",{d:e,fill:d.rays,transform:"translate("+(p-22*b).toFixed(3)+" "+(u-p-78*b).toFixed(3)+") scale("+b.toFixed(4)+")",opacity:0});v.appendChild(y),v.appendChild(x);let k=(R,D)=>{let I=Math.min(1,Math.max(0,D-R))*A.P;y.setAttribute("stroke-dasharray",I.toFixed(3)+" "+Math.max(0,A.P-I).toFixed(3)),y.setAttribute("stroke-dashoffset",(-R*A.P).toFixed(3))},E=(R,D)=>{let[I,_]=L[D];for(let F=-1;F<6;F++)if(I+F>=R[0]-1e-6&&_+F>=R[1]-1e-6)return[I+F,_+F];return[I,_]},S=d.sequence.split(""),C=0,P=L[S[0]].slice(),st,nt,lt=!1;k(P[0],P[1]),x.setAttribute("opacity",S[0]==="L"?1:0);function dt(){if(lt)return;let R=(C+1)%S.length,D=E(P,S[R]),I=P.slice(),_=S[C]==="L",F=S[R]==="L",ct=()=>{P=D;let Y=Math.floor(P[0]);P[0]-=Y,P[1]-=Y,C=R,k(P[0],P[1]),x.setAttribute("opacity",F?1:0),nt=setTimeout(dt,d.hold)};if(n()){ct();return}let qt=performance.now(),ut=Y=>{let q=Math.min(1,(Y-qt)/d.morph),mt=q<.5?4*q*q*q:1-Math.pow(-2*q+2,3)/2;k(I[0]+(D[0]-I[0])*mt,I[1]+(D[1]-I[1])*mt),x.setAttribute("opacity",F?Math.max(0,(q-.6)/.4).toFixed(3):_?Math.max(0,1-q*2.5).toFixed(3):0),q<1?st=requestAnimationFrame(ut):ct()};st=requestAnimationFrame(ut)}return nt=setTimeout(dt,d.hold),c.appendChild(v),{svg:v,stop:()=>{lt=!0,cancelAnimationFrame(st),clearTimeout(nt)}}}r.LucioMorph={wordmark:M,loader:T}})(window);var O={graphite:"#111114",graphite3:"#26262D",paper:"#F3F1EC",beam:"#FFF3CF"};function rt(){return window.LucioMorph??null}function W(r,t){let e=rt();if(!e)return null;let i=document.createElement("span");i.className="wordmark-svg",i.setAttribute("aria-hidden","true"),r.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),r.classList.add("has-svg"),s}function pt(){let r=document.getElementById("chop-template");if(!(r instanceof HTMLTemplateElement))return null;let t=r.content.firstElementChild;return t?t.cloneNode(!0):null}function Nt(r){let t=r.seed+"|"+r.level+"|"+r.x+"|"+r.y,e=2166136261;for(let i=0;i>>0;return e}function Dt(r,t){let e=new Array(r);for(let n=0;n{i=i+1831565813|0;let n=Math.imul(i^i>>>15,1|i);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296};for(let n=r-1;n>0;n--){let o=Math.floor(s()*(n+1)),a=e[n];e[n]=e[o],e[o]=a}return e}function ft(r,t,e,i,s){r.drawImage(t,0,0);let n=s.cell,o=Math.floor(e/n),a=Math.floor(i/n),l=o*a;if(l<2)return;let h=Dt(l,Nt(s));for(let m=0;m"u"||e==="")return;let i=(navigator.hardwareConcurrency??2)>=4?2:1;for(let s=0;sthis.onReply(a.data,o),n.onerror=()=>this.dropWorker(o),this.workers.push(n)}catch{break}}request(t,e,i,s,n){return s.aborted?Promise.reject(new H):new Promise((o,a)=>{let l=this.byId.get(t);l?i{m.waiters.delete(h)&&(a(new H),m.waiters.size===0&&setTimeout(()=>{m.waiters.size===0&&this.byKey.get(m.key)===m&&this.cancel(m)},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 H);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 n=await s.blob(),o=performance.now()-i,a=await at(n);t.scramble&&(a=await Wt(a,t.scramble)),this.onReply({key:t.key,ok:!0,bitmap:a,bytes:n.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 n={bitmap:t.bitmap,bytes:t.bytes,ms:t.ms};for(let o of s)o.resolve(n);s.length===0&&N(t.bitmap)}else{let n=new Error(t.error??"tile failed");for(let o of s)o.reject(n)}this.pump()}};var bt=1024*1024;function Ot(){let r=navigator.deviceMemory;if(typeof r=="number"&&r<=4)return!0;let t=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,e=Math.min(screen.width,screen.height);return t&&e<=820}function gt(){return Ot()?120*bt:250*bt}var X=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 Bt=400,B=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,Bt-(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=rt();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))}},z=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 n=Math.round(s*1e3)/1e3;n!==this.value&&(this.value=n,this.element.style.transform="scaleX("+(i?n:1)+")")}};function J(r,t,e){let i=t*e;for(let s=0;s=i)return s;return r.levels.length-1}function Z(r,t,e){let i=Math.max(0,t.u0*r.width),s=Math.min(r.width,t.u1*r.width),n=Math.max(0,t.v0*r.height),o=Math.min(r.height,t.v1*r.height);return s<=i||o<=n?null:{x0:Math.min(r.cols-1,Math.floor(i/e)),x1:Math.min(r.cols-1,Math.ceil(s/e)-1),y0:Math.min(r.rows-1,Math.floor(n/e)),y1:Math.min(r.rows-1,Math.ceil(o/e)-1)}}function yt(r,t,e,i){let s=r.levels[t],n=Z(s,e,i);if(!n)return[];let o=(e.u0+e.u1)/2*s.width,a=(e.v0+e.v1)/2*s.height,l=[];for(let h=n.y0;h<=n.y1;h++)for(let m=n.x0;m<=n.x1;m++){let M=(m*i+Math.min((m+1)*i,s.width))/2,L=(h*i+Math.min((h+1)*i,s.height))/2;l.push({level:t,x:m,y:h,index:h*s.cols+m,distance:(M-o)**2+(L-a)**2})}return l.sort((h,m)=>h.distance-m.distance),l.map(({level:h,x:m,y:M,index:L})=>({level:h,x:m,y:M,index:L}))}function wt(r,t,e,i,s,n,o,a,l,h){let m=i*n,M=Math.min((i+1)*n,e.width),L=s*n,f=Math.min((s+1)*n,e.height),T=i>0?m-o:0,c=s>0?L-o:0,w=Math.round(a+m*h),d=Math.round(a+M*h),u=Math.round(l+L*h),p=Math.round(l+f*h);if(d<=w||p<=u)return;let g=Math.max(T,(w-a)/h),A=Math.min(T+t.width,(d-a)/h),v=Math.max(c,(u-l)/h),y=Math.min(c+t.height,(p-l)/h);A<=g||y<=v||r.drawImage(t,g-T,v-c,A-g,y-v,w,u,d-w,p-u)}var xt="luphoto.throughput";function Mt(){try{let r=Number(sessionStorage.getItem(xt));return Number.isFinite(r)&&r>0?r:null}catch{return null}}function Lt(){return Mt()??1e3}function Et(r){let t=Mt(),e=t===null?r:t*(1-.5)+r*.5;try{sessionStorage.setItem(xt,String(e))}catch{return e}return e}var ht=180,Tt=400;function Ut(r,t){return new Promise((e,i)=>{if(t.aborted){i(new H);return}let s=setTimeout(()=>{t.removeEventListener("abort",n),e()},r),n=()=>{clearTimeout(s),i(new H)};t.addEventListener("abort",n,{once:!0})})}var kt=3,G=4,U=class{constructor(t,e){this.pyramid=t;this.env=e;this.seedImage=null;this.seedPromise=null;this.session=null;this.prefetchController=null;this.finalLevel=-1;this.targetLevel=-1;this.status={active:!1,started:0,planned:0,done:0,sharp:!1}}tileUrl(t){let e=this.env.tiles;return e.path+this.pyramid.hash+"/"+t+"."+e.format}ensureSeed(){return this.seedPromise||(this.seedPromise=this.decodeSeed().then(()=>this.env.requestDraw(),()=>{})),this.seedPromise}async decodeSeed(){if(!this.pyramid.seed)return;let t=atob(this.pyramid.seed),e=new Uint8Array(t.length);for(let a=0;a!this.env.cache.has(i[s.index]))}uncachedBytes(t,e){let i=this.pyramid.levels[t].bytes,s=0;for(let n of this.uncached(t,e))s+=i[n.index];return s}fetchAll(t,e,i){return Promise.allSettled(t.map(s=>this.fetchTile(s,e,i)))}probeLevel(t,e){return Math.max(0,J(this.pyramid,t.displayWidth,e)-kt)}notify(){this.env.onStatus?.(this)}track(t,e,i){return this.status.planned+=t.length,this.notify(),Promise.allSettled(t.map(s=>this.fetchTile(s,vt,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,n=performance.now(),o=this.env.settings.budgetMs,a=setTimeout(()=>i.abort("deadline"),o);try{if(await this.ensureSeed(),s.aborted)return;let l=J(this.pyramid,t.displayWidth,e),h=Math.max(0,l-kt),m=this.uncached(h,t).slice(0,2);if(m.length>0){let c=await this.track(m,i,s),w=0,d=0;for(let u of c)u.status==="fulfilled"&&(w+=u.value.bytes,d=Math.max(d,u.value.ms));w>0&&d>0&&Et(w/d)}if(s.aborted)return;this.finalLevel=Math.max(this.finalLevel,h);let M=Lt(),L=o-(performance.now()-n),f=h;for(let c=l;c>h;c--)if(this.uncachedBytes(c,t)/M<=L*.8){f=c;break}let T=[];f-h>=2&&T.push(Math.floor((h+f)/2)),f>h&&T.push(f),this.finalLevel=f,this.targetLevel=f,this.env.requestDraw();for(let c of T)if(await this.track(this.uncached(c,t),i,s),s.aborted)return}finally{clearTimeout(a)}}prefetchProbe(t,e){let i=this.resetPrefetch();this.ensureSeed().then(()=>{i.signal.aborted||this.fetchAll(this.uncached(this.probeLevel(t,e),t),ot,i.signal)})}prefetchLevel(t,e){if(e<0)return;let i=this.resetPrefetch();this.fetchAll(this.uncached(e,t),ot,i.signal)}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()}draw(t){let{g:e,originX:i,originY:s,width:n,height:o,canvasWidth:a,canvasHeight:l}=t,h=Math.max(0,i),m=Math.max(0,s),M=Math.min(a,i+n),L=Math.min(l,s+o);if(M<=h||L<=m)return!1;this.seedPromise||this.ensureSeed();let f={displayWidth:t.displayWidth,u0:(h-i)/n,u1:(M-i)/n,v0:(m-s)/o,v1:(L-s)/o},T=this.env.tiles.tile_size,c=this.env.tiles.overlap,w=this.env.cache,d=this.pyramid.levels,u=J(this.pyramid,t.displayWidth,t.dpr),p=-1;for(let y=u;y>=0&&p<0;y--){let b=Z(d[y],f,T);if(!b)continue;let x=!0;for(let k=b.y0;k<=b.y1&&x;k++)for(let E=b.x0;E<=b.x1;E++){let S=w.get(d[y].tiles[k*d[y].cols+E]);if(!S||t.now-S.at=0?Math.min(this.targetLevel,u):u,A=p>=g;A!==this.status.sharp&&(this.status.sharp=A,queueMicrotask(()=>this.notify()));let v=!1;for(let y=Math.max(0,p);y<=u;y++){let b=d[y],x=Z(b,f,T);if(!x)continue;let k=n/b.width;e.imageSmoothingEnabled=!0,e.imageSmoothingQuality=k<1?"high":"medium";for(let E=x.y0;E<=x.y1;E++)for(let S=x.x0;S<=x.x1;S++){let C=w.get(b.tiles[E*b.cols+S]);if(!C)continue;let P=t.now-C.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,n=e.height*i,o=(t.open-n)/2,a=o+this.focusY*n,l=Math.max(0,Math.min(t.open-t.closed,a-t.closed/2)),h=this.geometry;this.geometry={width:t.width,closed:t.closed,open:t.open,dpr:t.dpr,coverWidth:s,coverHeight:n,x:(t.width-s)/2,y:o,band:l},this.canvas&&(this.sizeCanvas(this.canvasOpen),this.drawNow()),this.near&&h&&(h.width!==t.width||h.closed!==t.closed||h.open!==t.open||h.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())},Vt)),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,n=Math.max(1,Math.round(i.width*i.dpr)),o=Math.max(1,Math.round(s*i.dpr));(e.width!==n||e.height!==o)&&(e.width=n,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 n=this.canvasOpen?0:-s.band;return this.loader.draw({g:e,originX:s.x*s.dpr,originY:(s.y+n)*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})}};var _t=24,j=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 n=Array.from(t.querySelectorAll("a.strip")),o=new Map(e.albums.map(l=>[l.slug,l]));for(let l of n){let h=o.get(l.dataset.slug??"");!h||!h.cover||this.strips.push(new V(l,h.cover,h.collapsed_focus_y??.5,s,m=>this.onStripStatus(m)))}this.hoverMode=matchMedia("(hover: hover) and (pointer: fine)");let a=document.querySelector(".site-header .wordmark");if(this.indicator=new B(document.body,()=>!this.wordmarkMoving()),a){this.wordmark=W(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(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)),n=Math.min(window.devicePixelRatio||1,this.settings.maxDpr),o=t+"x"+i+"x"+s+"@"+n;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:n})}}observe(){let t=new Map(this.strips.map(n=>[n.element,n])),e=new IntersectionObserver(n=>{for(let o of n)t.get(o.target)?.setNear(o.isIntersecting)},{rootMargin:"100% 0px"}),i=new IntersectionObserver(n=>{for(let o of n){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(n=>{for(let o of n){let a=t.get(o.target);a&&(o.isIntersecting?this.onScreen.add(a):this.onScreen.delete(a))}this.watchFirst(),this.scheduleCentre()});for(let n of this.strips)e.observe(n.element),i.observe(n.element),s.observe(n.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 n of this.onScreen){let o=n.element.getBoundingClientRect(),a=Math.abs(o.top+o.height/2-t);a{let n=Number(i);return Number.isFinite(n)&&n>0?n: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"}}var Yt=/[㐀-鿿豈-﫿]/;function Q(r,t){Yt.test(t)?r.lang="zh":r.removeAttribute("lang")}function At(r){return r<10?"0"+r:String(r)}function Kt(r){let t=(r.model??"").trim(),e=(r.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 Xt(r){let t=/(\d+(?:\.\d+)?(?:-\d+(?:\.\d+)?)?)\s*mm\s*(?:F|f\/?)\s*([\d.]+(?:-[\d.]+)?)/.exec(r);return t?t[1]+" f/"+t[2]:r.trim()}function $(r){return String(Math.round(r*10)/10)}function zt(r){let t=r.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 $(e)+"s";let i=1/e;return i<10&&Math.abs(i-Math.round(i))>.05?"1/"+$(i):"1/"+Math.round(i)}function Jt(r,t,e,i){let s=[At(r+1)+" / "+At(t)],n=e.exif;if(i&&n){let o=Kt(n);o&&s.push(o),n.lens&&s.push(Xt(n.lens)),n.focal_length&&s.push($(n.focal_length)+"mm"),n.f_number&&s.push("f/"+$(n.f_number)),n.exposure&&s.push(zt(n.exposure)),n.iso&&s.push("ISO "+n.iso)}return s.join(" \xB7 ")}function Zt(r,t){r.textContent="",t.split(/\r?\n/).forEach((e,i)=>{i>0&&r.appendChild(document.createElement("br"));let s=e.split("*"),n=(s.length-1)%2===0;s.forEach((o,a)=>{let l=a%2===1;if(l&&(n||a!==s.length-1)){let h=document.createElement("em");h.textContent=o,r.appendChild(h)}else r.appendChild(document.createTextNode((l?"*":"")+o))})})}var tt=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=Jt(e,i,t,s),this.title.textContent=t.title??"",this.title.hidden=!t.title,Q(this.title,t.title??""),Zt(this.text,t.caption??""),this.text.hidden=!t.caption,Q(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 n=this.element.style;n.width=Math.round(e)+"px",n.transform="translate3d("+Math.round(t)+"px,"+-Math.round(i)+"px,0)"}};var et=24,Ct=10,Gt=300,jt=.35,Pt=.35,Qt=.2,$t=2500;function te(r,t,e,i){let s=3*r,n=3*(e-r)-s,o=1-s-n,a=3*t,l=3*(i-t)-a,h=1-a-l,m=f=>((o*f+n)*f+s)*f,M=f=>((h*f+l)*f+a)*f,L=f=>(3*o*f+2*n)*f+s;return f=>{if(f<=0)return 0;if(f>=1)return 1;let T=f;for(let d=0;d<8;d++){let u=m(T)-f,p=L(T);if(Math.abs(u)<1e-5)return M(T);if(Math.abs(p)<1e-6)break;T-=u/p}let c=0,w=1;T=f;for(let d=0;d<24;d++){let u=m(T);if(Math.abs(u-f)<1e-5)break;uthis.requestDraw(),onStatus:i=>{this.indicator.update(i),this.progress.update(i)}}),this.loaders[t]=e),e}measure(){let t=this.stage.getBoundingClientRect();this.vw=Math.max(1,t.width),this.vh=Math.max(1,t.height),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((n,o)=>{let a=Math.max(1,n.slides||1),l=Math.min(this.vw/(n.width/a),this.vh/n.height),h=n.width*l,m=n.height*l,M=h/a,L=s+et/2+(this.vw-M)/2;this.layouts.push({scale:l,width:h,height:m,section:M,slides:a,start:s,left:L,top:(this.vh-m)/2});for(let f=0;f{this.pointerId===null&&document.body.classList.add("is-idle")},$t)}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("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)}),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.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":location.assign("/");break;case"i":case"I":this.pinned=!this.pinned,this.updateCaption();break;default:return}t.preventDefault()}}onPointerDown(t){this.pointerId!==null||t.pointerType==="mouse"&&t.button!==0||t.target.closest("a, button")||(this.pointerId=t.pointerId,this.pointerType=t.pointerType,this.dragging=!1,this.downX=t.clientX,this.downY=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(t.pointerId!==this.pointerId)return;let e=t.clientX-this.downX,i=t.clientY-this.downY;if(!this.dragging&&Math.hypot(e,i)>=Ct&&(this.dragging=!0,this.stage.classList.add("is-dragging"),this.updateCaption()),!!this.dragging){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(t.pointerId!==this.pointerId)return;this.stage.hasPointerCapture(t.pointerId)&&this.stage.releasePointerCapture(t.pointerId),this.pointerId=null;let i=this.dragging;this.dragging=!1,this.stage.classList.remove("is-dragging");let s=Math.hypot(t.clientX-this.downX,t.clientY-this.downY);if(!e&&!i&&so.t&&t.timeStamp-a.t<100&&(n=(a.x-o.x)/(a.t-o.t));let l=this.nearestStop(this.camera);if(!e&&Math.abs(n)>jt)if(n<0){let h=this.stops.findIndex(m=>m.camera>this.camera+1);l=h<0?this.stops.length-1:h}else{let h=0;this.stops.forEach((m,M)=>{m.camera=i.left&&t.clientX<=i.right&&t.clientY>=i.top&&t.clientY<=i.bottom&&(this.pinned=!this.pinned,this.updateCaption())}rubber(t){let e=this.stops[0].camera,i=this.stops[this.stops.length-1].camera;return ti?i+(t-i)*Pt:t}nearestStop(t){let e=0;return this.stops.forEach((i,s)=>{Math.abs(i.camera-t){this.current=e,this.camera=s});else{let n=Math.abs(s-this.camera);n>.5?this.tween={from:this.camera,to:s,start:performance.now(),duration:240+200*Math.min(1,n/this.vw)}:this.camera=s,this.current=e}e!==i?this.activate(i):this.updateCaption(),this.requestDraw()}jump(t){let e=this.current;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,n)=>{s&&n!==e.photo&&n!==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.startSession()}this.syncNextStrip(),this.updateCaption()}describe(t,e){let i=this.manifest.photos.length,s;if(t<0){let n=this.nextLink.querySelector(".next-title")?.textContent??"";s="End of album."+(n?" Next album: "+n+".":"")}else{let n=this.manifest.photos[t],o=n.alt||n.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.canvas.width=0,this.measure(),this.camera=this.stops[this.current].camera,this.syncNextStrip(),this.startSession(),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 n=this.stops.find(o=>o.photo===e.photo+1);n&&this.loader(n.photo).prefetchProbe(this.viewAt(n),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),n=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:(n-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(),n=t-s.left,o=e-s.top,a=this.layouts[i.photo],l=this.photoRect(i.photo),h=a.top+a.height*(1-Qt);return n>=l.left&&n<=l.right&&o>=h&&o<=l.bottom}updateCaption(){let t=this.stops[this.current],e=t.photo>=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)+"/";let n=this.nextLink.querySelector(".next-eyebrow"),o=this.nextLink.querySelector(".next-title");n&&(n.textContent="Next album"+(s.date?" \xB7 "+s.date:"")),o&&(o.textContent=s.title,Q(o,s.title)),s.cover&&(this.nextStrip=new V(this.nextFrame,s.cover,s.collapsed_focus_y??.5,{...this.env,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 L=Math.min(1,(t-this.tween.start)/this.tween.duration);this.camera=this.tween.from+(this.tween.to-this.tween.from)*ee(L),L>=1?(this.tween=null,this.updateCaption()):e=!0}let i=this.g,s=this.canvas.width,n=this.canvas.height;i.setTransform(1,0,0,1,0,0),i.globalAlpha=1,i.fillStyle="#111114",i.fillRect(0,0,s,n);let o=this.camera-this.vw/2,a=o+this.vw,l=this.dpr,h=this.stops[this.current].photo,m=Math.max(0,(h<0?this.layouts.length-1:h)-2),M=Math.min(this.layouts.length-1,(h<0?this.layouts.length-1:h)+2);for(let L=m;L<=M;L++){let f=this.layouts[L];f.left+f.widtha||this.loader(L).draw({g:i,originX:(f.left-o)*l,originY:f.top*l,width:f.width*l,height:f.height*l,canvasWidth:s,canvasHeight:n,displayWidth:f.width,dpr:l,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 Rt(r){let t=await fetch(r,{credentials:"same-origin"});if(!t.ok)throw new Error(r+" "+t.status);return await t.json()}function Ft(r){return{scheduler:new K(r.concurrency,r.workerUrl),cache:new X(gt())}}async function ie(r,t){let e=await Rt(t.manifestUrl);if(e.photos.length===0)return;let{scheduler:i,cache:s}=Ft(t);document.documentElement.classList.add("has-viewer"),Ht(new it(r,e,t,{scheduler:i,cache:s,settings:t,tiles:e.tiles}))}async function se(r,t){let e=await Rt(t.indexUrl),{scheduler:i,cache:s}=Ft(t);Ht(new j(r,e,t,{scheduler:i,cache:s,settings:t,tiles:e.tiles}))}function Ht(r){document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?r.suspend(!1):r.resume()}),window.addEventListener("pagehide",()=>r.suspend(!0)),window.addEventListener("pageshow",t=>{t.persisted&&r.resume()})}function ne(){document.documentElement.classList.remove("has-viewer"),document.querySelector(".load-error")?.removeAttribute("hidden")}function It(){let r=St(document.body);if(r.page==="album"){let t=document.getElementById("stage");t&&ie(t,r).catch(()=>ne())}else if(r.page==="notfound"){let t=document.querySelector(".site-header .wordmark");t&&W(t,!1)}else if(r.page==="index"){let t=document.getElementById("strips");t&&se(t,r).catch(()=>{document.documentElement.classList.remove("has-strips");let e=document.querySelector(".site-header .wordmark");e&&!e.classList.contains("has-svg")&&W(e,!1)})}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",It,{once:!0}):It();})(); +"use strict";(()=>{(function(r){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=(d,x)=>{let c=document.createElementNS(i,d);for(let u in x)c.setAttribute(u,x[u]);return c},n=()=>r.matchMedia&&r.matchMedia("(prefers-reduced-motion: reduce)").matches,o=d=>Math.max(0,Math.min(1,d)),a=d=>d*d*(3-2*d),h=.5;function l(d,x){let c=0,u=0,f=null,g=0;function A(y){let b=(y-g)/x;g=y,c=cv(1),reverse:()=>v(0),toggle:()=>v(u?0:1),set:y=>{cancelAnimationFrame(f),f=null,u=c=y,d(c)},stop:()=>{cancelAnimationFrame(f),f=null},get t(){return c}}}function m(d,x,c,u){let f=o(u)*x;if(d.style.visibility=f<.05?"hidden":"visible",c==="both"){let g=f/2;d.setAttribute("stroke-dasharray",g.toFixed(2)+" "+Math.max(0,x-2*g).toFixed(2)+" "+g.toFixed(2)),d.setAttribute("stroke-dashoffset","0")}else c==="end"?(d.setAttribute("stroke-dasharray",f.toFixed(2)+" "+(2*x+20).toFixed(2)),d.setAttribute("stroke-dashoffset",(-(x-f)).toFixed(2))):(d.setAttribute("stroke-dasharray",f.toFixed(2)+" "+(2*x+20).toFixed(2)),d.setAttribute("stroke-dashoffset","0"))}function L(d,x={}){let c=Object.assign({trigger:"hover",color:"currentColor",rays:"#FFF3CF",duration:450,autoDelay:1800},x),u=s("svg",{viewBox:"0 0 "+t.vbw+" "+t.vbh,role:"img","aria-label":"Guoliang Chen, Lucio"});u.style.display="block",u.style.width="100%",u.style.height="auto";let f=s("g",{transform:"translate("+t.pad+" "+t.pad+")",fill:"none",stroke:c.color,"stroke-width":t.stroke,"stroke-linejoin":"miter","stroke-linecap":"butt"});u.appendChild(f);let g=t.letters.map(b=>{let M=s("g",{transform:"translate("+b.x0+" 0)"});f.appendChild(M);let k=Object.assign({g:M,outEls:[],inEls:[]},b);if(b.kind==="fade")k.fadeEl=s("path",{d:b.d}),M.appendChild(k.fadeEl);else{k.fullA=s("path",{d:b.fullA}),M.appendChild(k.fullA),k.fullB=s("path",{d:b.fullB}),M.appendChild(k.fullB),b.shared&&M.appendChild(s("path",{d:b.shared}));for(let T of b.out){let S=s("path",{d:T.d});M.appendChild(S),k.outEls.push([S,T])}for(let T of b.in){let S=s("path",{d:T.d});M.appendChild(S),k.inEls.push([S,T])}}return b.dot&&(k.dotEl=s("rect",{x:b.dot[0],y:b.dot[1],width:b.dot[2],height:b.dot[2],rx:b.dot[2]*.22,fill:c.color,stroke:"none"}),M.appendChild(k.dotEl)),k}),A=s("path",{d:e,fill:c.rays,stroke:"none",opacity:0});f.appendChild(A),d.appendChild(u);function v(b){let M=a(o(b/h)),k=a(o((b-h)/(1-h)));for(let T of g){if(T.kind==="fade")T.fadeEl.setAttribute("opacity",(1-M).toFixed(3)),T.dotEl&&T.dotEl.setAttribute("opacity",(1-M).toFixed(3));else{for(let[S,C]of T.outEls)m(S,C.P,C.j,1-M);for(let[S,C]of T.inEls)m(S,C.P,C.j,M);T.fullA.style.visibility=M<=.001?"visible":"hidden",T.fullB.style.visibility=M>=.999?"visible":"hidden"}T.g.setAttribute("transform","translate("+(T.x0+(T.x1-T.x0)*k).toFixed(2)+" 0)")}A.setAttribute("transform","translate("+(g[0].x0+(g[0].x1-g[0].x0)*k).toFixed(2)+" 0) "+t.raysT),A.setAttribute("opacity",o((b-.8)/.2).toFixed(3))}let y=l(v,c.duration);return v(0),c.trigger==="hover"&&(d.addEventListener("mouseenter",y.play),d.addEventListener("mouseleave",y.reverse),d.addEventListener("focus",y.play),d.addEventListener("blur",y.reverse)),c.trigger==="click"&&d.addEventListener("click",y.toggle),c.trigger==="auto"&&setInterval(y.toggle,c.autoDelay+c.duration),Object.assign(y,{svg:u})}let w={C:[0,.75],L:[.25,.75],U:[.25,1],I:[.75,1],O:[.75,1.75]};function p(d,x,c){let u=x/2,f=c-u,g=u+f,A=f*Math.SQRT1_2,v=b=>b.toFixed(3);return{d:"M"+v(d-g+A)+" "+v(g-A)+"A"+v(f)+" "+v(f)+" 0 0 0 "+v(d-g)+" "+v(u)+"H"+v(g)+"A"+v(f)+" "+v(f)+" 0 0 0 "+v(u)+" "+v(g)+"V"+v(d-g)+"A"+v(f)+" "+v(f)+" 0 0 0 "+v(g)+" "+v(d-u)+"H"+v(d-g)+"A"+v(f)+" "+v(f)+" 0 0 0 "+v(d-u)+" "+v(d-g)+"V"+v(g)+"A"+v(f)+" "+v(f)+" 0 0 0 "+v(d-g+A)+" "+v(g-A)+"Z",P:4*(d-2*g)+2*Math.PI*f}}function E(d,x={}){let c=Object.assign({sequence:"LUCIO",color:"#F3F1EC",track:"#26262D",rays:"#FFF3CF",hold:480,morph:640,size:96,stroke:.17,radius:.22},x),u=120,f=u*c.stroke,g=u*c.radius,A=p(u,f,g),v=s("svg",{viewBox:"0 0 "+u+" "+u,width:c.size,height:c.size,role:"img","aria-label":"Loading"});c.track&&v.appendChild(s("path",{d:A.d,fill:"none",stroke:c.track,"stroke-width":f}));let y=s("path",{d:A.d,fill:"none",stroke:c.color,"stroke-width":f,"stroke-linecap":"butt"}),b=f/22,M=s("path",{d:e,fill:c.rays,transform:"translate("+(f-22*b).toFixed(3)+" "+(u-f-78*b).toFixed(3)+") scale("+b.toFixed(4)+")",opacity:0});v.appendChild(y),v.appendChild(M);let k=(z,N)=>{let I=Math.min(1,Math.max(0,N-z))*A.P;y.setAttribute("stroke-dasharray",I.toFixed(3)+" "+Math.max(0,A.P-I).toFixed(3)),y.setAttribute("stroke-dashoffset",(-z*A.P).toFixed(3))},T=(z,N)=>{let[I,X]=w[N];for(let R=-1;R<6;R++)if(I+R>=z[0]-1e-6&&X+R>=z[1]-1e-6)return[I+R,X+R];return[I,X]},S=c.sequence.split(""),C=0,P=w[S[0]].slice(),st,nt,lt=!1;k(P[0],P[1]),M.setAttribute("opacity",S[0]==="L"?1:0);function ct(){if(lt)return;let z=(C+1)%S.length,N=T(P,S[z]),I=P.slice(),X=S[C]==="L",R=S[z]==="L",dt=()=>{P=N;let U=Math.floor(P[0]);P[0]-=U,P[1]-=U,C=z,k(P[0],P[1]),M.setAttribute("opacity",R?1:0),nt=setTimeout(ct,c.hold)};if(n()){dt();return}let Ht=performance.now(),ut=U=>{let H=Math.min(1,(U-Ht)/c.morph),mt=H<.5?4*H*H*H:1-Math.pow(-2*H+2,3)/2;k(I[0]+(N[0]-I[0])*mt,I[1]+(N[1]-I[1])*mt),M.setAttribute("opacity",R?Math.max(0,(H-.6)/.4).toFixed(3):X?Math.max(0,1-H*2.5).toFixed(3):0),H<1?st=requestAnimationFrame(ut):dt()};st=requestAnimationFrame(ut)}return nt=setTimeout(ct,c.hold),d.appendChild(v),{svg:v,stop:()=>{lt=!0,cancelAnimationFrame(st),clearTimeout(nt)}}}r.LucioMorph={wordmark:L,loader:E}})(window);var W={graphite:"#111114",graphite3:"#26262D",paper:"#F3F1EC",beam:"#FFF3CF"};function rt(){return window.LucioMorph??null}function D(r,t){let e=rt();if(!e)return null;let i=document.createElement("span");i.className="wordmark-svg",i.setAttribute("aria-hidden","true"),r.appendChild(i);let s=e.wordmark(i,{trigger:"manual",color:W.paper,rays:W.beam});return s.svg.setAttribute("aria-hidden","true"),s.svg.removeAttribute("role"),t||s.set(1),r.classList.add("has-svg"),s}function pt(){let r=document.getElementById("chop-template");if(!(r instanceof HTMLTemplateElement))return null;let t=r.content.firstElementChild;return t?t.cloneNode(!0):null}function qt(r){let t=r.seed+"|"+r.level+"|"+r.x+"|"+r.y,e=2166136261;for(let i=0;i>>0;return e}function Nt(r,t){let e=new Array(r);for(let n=0;n{i=i+1831565813|0;let n=Math.imul(i^i>>>15,1|i);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296};for(let n=r-1;n>0;n--){let o=Math.floor(s()*(n+1)),a=e[n];e[n]=e[o],e[o]=a}return e}function ft(r,t,e,i,s){r.drawImage(t,0,0);let n=s.cell,o=Math.floor(e/n),a=Math.floor(i/n),h=o*a;if(h<2)return;let l=Nt(h,qt(s));for(let m=0;m"u"||e==="")return;let i=(navigator.hardwareConcurrency??2)>=4?2:1;for(let s=0;sthis.onReply(a.data,o),n.onerror=()=>this.dropWorker(o),this.workers.push(n)}catch{break}}request(t,e,i,s,n){return s.aborted?Promise.reject(new F):new Promise((o,a)=>{let h=this.byId.get(t);h?i{m.waiters.delete(l)&&(a(new F),m.waiters.size===0&&setTimeout(()=>{m.waiters.size===0&&this.byKey.get(m.key)===m&&this.cancel(m)},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 F);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 n=await s.blob(),o=performance.now()-i,a=await at(n);t.scramble&&(a=await Dt(a,t.scramble)),this.onReply({key:t.key,ok:!0,bitmap:a,bytes:n.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&&q(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 n={bitmap:t.bitmap,bytes:t.bytes,ms:t.ms};for(let o of s)o.resolve(n);s.length===0&&q(t.bitmap)}else{let n=new Error(t.error??"tile failed");for(let o of s)o.reject(n)}this.pump()}};var bt=1024*1024;function Wt(){let r=navigator.deviceMemory;if(typeof r=="number"&&r<=4)return!0;let t=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,e=Math.min(screen.width,screen.height);return t&&e<=820}function gt(){return Wt()?120*bt:250*bt}var V=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&&q(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,q(i.bitmap))}}};var Ot=400,O=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,Ot-(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=rt();t&&(this.handle=t.loader(this.element,{size:56,color:W.paper,track:W.graphite3,rays:W.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))}},_=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 n=Math.round(s*1e3)/1e3;n!==this.value&&(this.value=n,this.element.style.transform="scaleX("+(i?n:1)+")")}};function K(r,t,e){let i=t*e;for(let s=0;s=i)return s;return r.levels.length-1}function G(r,t,e){let i=Math.max(0,t.u0*r.width),s=Math.min(r.width,t.u1*r.width),n=Math.max(0,t.v0*r.height),o=Math.min(r.height,t.v1*r.height);return s<=i||o<=n?null:{x0:Math.min(r.cols-1,Math.floor(i/e)),x1:Math.min(r.cols-1,Math.ceil(s/e)-1),y0:Math.min(r.rows-1,Math.floor(n/e)),y1:Math.min(r.rows-1,Math.ceil(o/e)-1)}}function yt(r,t,e,i){let s=r.levels[t],n=G(s,e,i);if(!n)return[];let o=(e.u0+e.u1)/2*s.width,a=(e.v0+e.v1)/2*s.height,h=[];for(let l=n.y0;l<=n.y1;l++)for(let m=n.x0;m<=n.x1;m++){let L=(m*i+Math.min((m+1)*i,s.width))/2,w=(l*i+Math.min((l+1)*i,s.height))/2;h.push({level:t,x:m,y:l,index:l*s.cols+m,distance:(L-o)**2+(w-a)**2})}return h.sort((l,m)=>l.distance-m.distance),h.map(({level:l,x:m,y:L,index:w})=>({level:l,x:m,y:L,index:w}))}function wt(r,t,e,i,s,n,o,a,h,l){let m=i*n,L=Math.min((i+1)*n,e.width),w=s*n,p=Math.min((s+1)*n,e.height),E=i>0?m-o:0,d=s>0?w-o:0,x=Math.round(a+m*l),c=Math.round(a+L*l),u=Math.round(h+w*l),f=Math.round(h+p*l);if(c<=x||f<=u)return;let g=Math.max(E,(x-a)/l),A=Math.min(E+t.width,(c-a)/l),v=Math.max(d,(u-h)/l),y=Math.min(d+t.height,(f-h)/l);A<=g||y<=v||r.drawImage(t,g-E,v-d,A-g,y-v,x,u,c-x,f-u)}var xt="luphoto.throughput";function Mt(){try{let r=Number(sessionStorage.getItem(xt));return Number.isFinite(r)&&r>0?r:null}catch{return null}}function Lt(){return Mt()??1e3}function Tt(r){let t=Mt(),e=t===null?r:t*(1-.5)+r*.5;try{sessionStorage.setItem(xt,String(e))}catch{return e}return e}var ht=180,Et=400;function Bt(r,t){return new Promise((e,i)=>{if(t.aborted){i(new F);return}let s=setTimeout(()=>{t.removeEventListener("abort",n),e()},r),n=()=>{clearTimeout(s),i(new F)};t.addEventListener("abort",n,{once:!0})})}var kt=3,J=4,B=class{constructor(t,e){this.pyramid=t;this.env=e;this.seedImage=null;this.seedPromise=null;this.session=null;this.prefetchController=null;this.finalLevel=-1;this.targetLevel=-1;this.status={active:!1,started:0,planned:0,done:0,sharp:!1}}tileUrl(t){let e=this.env.tiles;return e.path+this.pyramid.hash+"/"+t+"."+e.format}ensureSeed(){return this.seedPromise||(this.seedPromise=this.decodeSeed().then(()=>this.env.requestDraw(),()=>{})),this.seedPromise}async decodeSeed(){if(!this.pyramid.seed)return;let t=atob(this.pyramid.seed),e=new Uint8Array(t.length);for(let a=0;a!this.env.cache.has(i[s.index]))}uncachedBytes(t,e){let i=this.pyramid.levels[t].bytes,s=0;for(let n of this.uncached(t,e))s+=i[n.index];return s}fetchAll(t,e,i){return Promise.allSettled(t.map(s=>this.fetchTile(s,e,i)))}probeLevel(t,e){return Math.max(0,K(this.pyramid,t.displayWidth,e)-kt)}notify(){this.env.onStatus?.(this)}track(t,e,i){return this.status.planned+=t.length,this.notify(),Promise.allSettled(t.map(s=>this.fetchTile(s,vt,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,n=performance.now(),o=this.env.settings.budgetMs,a=setTimeout(()=>i.abort("deadline"),o);try{if(await this.ensureSeed(),s.aborted)return;let h=K(this.pyramid,t.displayWidth,e),l=Math.max(0,h-kt),m=this.uncached(l,t).slice(0,2);if(m.length>0){let d=await this.track(m,i,s),x=0,c=0;for(let u of d)u.status==="fulfilled"&&(x+=u.value.bytes,c=Math.max(c,u.value.ms));x>0&&c>0&&Tt(x/c)}if(s.aborted)return;this.finalLevel=Math.max(this.finalLevel,l);let L=Lt(),w=o-(performance.now()-n),p=l;for(let d=h;d>l;d--)if(this.uncachedBytes(d,t)/L<=w*.8){p=d;break}let E=[];p-l>=2&&E.push(Math.floor((l+p)/2)),p>l&&E.push(p),this.finalLevel=p,this.targetLevel=p,this.env.requestDraw();for(let d of E)if(await this.track(this.uncached(d,t),i,s),s.aborted)return}finally{clearTimeout(a)}}prefetchProbe(t,e){let i=this.resetPrefetch();this.ensureSeed().then(()=>{i.signal.aborted||this.fetchAll(this.uncached(this.probeLevel(t,e),t),ot,i.signal)})}prefetchLevel(t,e){if(e<0)return;let i=this.resetPrefetch();this.fetchAll(this.uncached(e,t),ot,i.signal)}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()}draw(t){let{g:e,originX:i,originY:s,width:n,height:o,canvasWidth:a,canvasHeight:h}=t,l=Math.max(0,i),m=Math.max(0,s),L=Math.min(a,i+n),w=Math.min(h,s+o);if(L<=l||w<=m)return!1;this.seedPromise||this.ensureSeed();let p={displayWidth:t.displayWidth,u0:(l-i)/n,u1:(L-i)/n,v0:(m-s)/o,v1:(w-s)/o},E=this.env.tiles.tile_size,d=this.env.tiles.overlap,x=this.env.cache,c=this.pyramid.levels,u=K(this.pyramid,t.displayWidth,t.dpr),f=-1;for(let y=u;y>=0&&f<0;y--){let b=G(c[y],p,E);if(!b)continue;let M=!0;for(let k=b.y0;k<=b.y1&&M;k++)for(let T=b.x0;T<=b.x1;T++){let S=x.get(c[y].tiles[k*c[y].cols+T]);if(!S||t.now-S.at=0?Math.min(this.targetLevel,u):u,A=f>=g;A!==this.status.sharp&&(this.status.sharp=A,queueMicrotask(()=>this.notify()));let v=!1;for(let y=Math.max(0,f);y<=u;y++){let b=c[y],M=G(b,p,E);if(!M)continue;let k=n/b.width;e.imageSmoothingEnabled=!0,e.imageSmoothingQuality=k<1?"high":"medium";for(let T=M.y0;T<=M.y1;T++)for(let S=M.x0;S<=M.x1;S++){let C=x.get(b.tiles[T*b.cols+S]);if(!C)continue;let P=t.now-C.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,n=e.height*i,o=(t.open-n)/2,a=o+this.focusY*n,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:n,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())},Yt)),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,n=Math.max(1,Math.round(i.width*i.dpr)),o=Math.max(1,Math.round(s*i.dpr));(e.width!==n||e.height!==o)&&(e.width=n,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 n=this.canvasOpen?0:-s.band;return this.loader.draw({g:e,originX:s.x*s.dpr,originY:(s.y+n)*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})}};var Xt=24,j=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 n=Array.from(t.querySelectorAll("a.strip")),o=new Map(e.albums.map(h=>[h.slug,h]));for(let h of n){let l=o.get(h.dataset.slug??"");!l||!l.cover||this.strips.push(new Y(h,l.cover,l.collapsed_focus_y??.5,s,m=>this.onStripStatus(m)))}this.hoverMode=matchMedia("(hover: hover) and (pointer: fine)");let a=document.querySelector(".site-header .wordmark");if(this.indicator=new O(document.body,()=>!this.wordmarkMoving()),a){this.wordmark=D(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)),n=Math.min(window.devicePixelRatio||1,this.settings.maxDpr),o=t+"x"+i+"x"+s+"@"+n;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:n})}}observe(){let t=new Map(this.strips.map(n=>[n.element,n])),e=new IntersectionObserver(n=>{for(let o of n)t.get(o.target)?.setNear(o.isIntersecting)},{rootMargin:"100% 0px"}),i=new IntersectionObserver(n=>{for(let o of n){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(n=>{for(let o of n){let a=t.get(o.target);a&&(o.isIntersecting?this.onScreen.add(a):this.onScreen.delete(a))}this.watchFirst(),this.scheduleCentre()});for(let n of this.strips)e.observe(n.element),i.observe(n.element),s.observe(n.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 n of this.onScreen){let o=n.element.getBoundingClientRect(),a=Math.abs(o.top+o.height/2-t);a{let n=Number(i);return Number.isFinite(n)&&n>0?n: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"}}var Ut=/[㐀-鿿豈-﫿]/;function Q(r,t){Ut.test(t)?r.lang="zh":r.removeAttribute("lang")}function At(r){return r<10?"0"+r:String(r)}function Zt(r){let t=(r.model??"").trim(),e=(r.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 Vt(r){let t=/(\d+(?:\.\d+)?(?:-\d+(?:\.\d+)?)?)\s*mm\s*(?:F|f\/?)\s*([\d.]+(?:-[\d.]+)?)/.exec(r);return t?t[1]+" f/"+t[2]:r.trim()}function $(r){return String(Math.round(r*10)/10)}function _t(r){let t=r.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 $(e)+"s";let i=1/e;return i<10&&Math.abs(i-Math.round(i))>.05?"1/"+$(i):"1/"+Math.round(i)}function Kt(r,t,e,i){let s=[At(r+1)+" / "+At(t)],n=e.exif;if(i&&n){let o=Zt(n);o&&s.push(o),n.lens&&s.push(Vt(n.lens)),n.focal_length&&s.push($(n.focal_length)+"mm"),n.f_number&&s.push("f/"+$(n.f_number)),n.exposure&&s.push(_t(n.exposure)),n.iso&&s.push("ISO "+n.iso)}return s.join(" \xB7 ")}function Gt(r,t){r.textContent="",t.split(/\r?\n/).forEach((e,i)=>{i>0&&r.appendChild(document.createElement("br"));let s=e.split("*"),n=(s.length-1)%2===0;s.forEach((o,a)=>{let h=a%2===1;if(h&&(n||a!==s.length-1)){let l=document.createElement("em");l.textContent=o,r.appendChild(l)}else r.appendChild(document.createTextNode((h?"*":"")+o))})})}var tt=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=Kt(e,i,t,s),this.title.textContent=t.title??"",this.title.hidden=!t.title,Q(this.title,t.title??""),Gt(this.text,t.caption??""),this.text.hidden=!t.caption,Q(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 n=this.element.style;n.width=Math.round(e)+"px",n.transform="translate3d("+Math.round(t)+"px,"+-Math.round(i)+"px,0)"}};var et=24,Ct=10,Jt=300,jt=.35,Pt=.35,Qt=.2,$t=2500,te=120,ee=16,ie=.002,se=.01;function ne(r,t,e,i){let s=3*r,n=3*(e-r)-s,o=1-s-n,a=3*t,h=3*(i-t)-a,l=1-a-h,m=p=>((o*p+n)*p+s)*p,L=p=>((l*p+h)*p+a)*p,w=p=>(3*o*p+2*n)*p+s;return p=>{if(p<=0)return 0;if(p>=1)return 1;let E=p;for(let c=0;c<8;c++){let u=m(E)-p,f=w(E);if(Math.abs(u)<1e-5)return L(E);if(Math.abs(f)<1e-6)break;E-=u/f}let d=0,x=1;E=p;for(let c=0;c<24;c++){let u=m(E);if(Math.abs(u-p)<1e-5)break;uthis.requestDraw(),onStatus:i=>{this.indicator.update(i),this.progress.update(i)}}),this.loaders[t]=e),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((n,o)=>{let a=Math.max(1,n.slides||1),h=Math.min(this.vw/(n.width/a),this.vh/n.height),l=n.width*h,m=n.height*h,L=l/a,w=s+et/2+(this.vw-L)/2;this.layouts.push({scale:h,width:l,height:m,section:L,slides:a,start:s,left:w,top:(this.vh-m)/2});for(let p=0;p{this.pointerId===null&&document.body.classList.add("is-idle")},$t)}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)>=Ct&&(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 n=0,o=this.samples[0],a=this.samples[this.samples.length-1];o&&a&&a.t>o.t&&t.timeStamp-a.t<100&&(n=(a.x-o.x)/(a.t-o.t));let h=this.nearestStop(this.camera);if(!e&&Math.abs(n)>jt)if(n<0){let l=this.stops.findIndex(m=>m.camera>this.camera+1);h=l<0?this.stops.length-1:l}else{let l=0;this.stops.forEach((m,L)=>{m.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*=ee:t.deltaMode===2&&(e*=this.vh),e===0)return;let i=Math.max(-1,Math.min(1,e*(t.ctrlKey?se:ie))),s=t.clientX-this.ox,n=t.clientY-this.oy;this.zoomTo(this.zoom*Math.exp(-i),s,n,s,n)}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,n=(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,n,(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,n){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=n-(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(),te)}clampAxis(t,e,i,s){let n=(i-e)/2,o=Math.min(i-e,n),a=Math.max(0,n),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),n=Math.min(this.vw,this.zx+e),o=Math.max(0,this.zy),a=Math.min(this.vh,this.zy+i);n<=s||a<=o||this.loader(this.zoomPhoto).start({displayWidth:e,u0:(s-this.zx)/e,u1:(n-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)*Pt:t}nearestStop(t){let e=0;return this.stops.forEach((i,s)=>{Math.abs(i.camera-t){this.current=e,this.camera=n});else{let o=Math.abs(n-this.camera);o>.5?this.tween={from:this.camera,to:n,start:performance.now(),duration:240+200*Math.min(1,o/this.vw)}:this.camera=n,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,n)=>{s&&n!==e.photo&&n!==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.startSession()}this.syncNextStrip(),this.updateCaption()}describe(t,e){let i=this.manifest.photos.length,s;if(t<0){let n=this.nextLink.querySelector(".next-title")?.textContent??"";s="End of album."+(n?" Next album: "+n+".":"")}else{let n=this.manifest.photos[t],o=n.alt||n.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())}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 n=this.stops.find(o=>o.photo===e.photo+1);n&&this.loader(n.photo).prefetchProbe(this.viewAt(n),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),n=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:(n-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(),n=t-s.left,o=e-s.top,a=this.layouts[i.photo],h=this.photoRect(i.photo),l=a.top+a.height*(1-Qt);return n>=h.left&&n<=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)+"/";let n=this.nextLink.querySelector(".next-eyebrow"),o=this.nextLink.querySelector(".next-title");n&&(n.textContent="Next album"+(s.date?" \xB7 "+s.date:"")),o&&(o.textContent=s.title,Q(o,s.title)),s.cover&&(this.nextStrip=new Y(this.nextFrame,s.cover,s.collapsed_focus_y??.5,{...this.env,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 w=Math.min(1,(t-this.tween.start)/this.tween.duration);this.camera=this.tween.from+(this.tween.to-this.tween.from)*re(w),w>=1?(this.tween=null,this.updateCaption()):e=!0}let i=this.g,s=this.canvas.width,n=this.canvas.height;i.setTransform(1,0,0,1,0,0),i.globalAlpha=1,i.fillStyle="#111114",i.fillRect(0,0,s,n);let o=this.camera-this.vw/2,a=o+this.vw,h=this.dpr,l=this.stops[this.current].photo,m=Math.max(0,(l<0?this.layouts.length-1:l)-2),L=this.zoomPhoto>=0?-1:Math.min(this.layouts.length-1,(l<0?this.layouts.length-1:l)+2);if(this.zoomPhoto>=0){let w=this.layouts[this.zoomPhoto],p=w.width*this.zoom;this.loader(this.zoomPhoto).draw({g:i,originX:this.zx*h,originY:this.zy*h,width:p*h,height:w.height*this.zoom*h,canvasWidth:s,canvasHeight:n,displayWidth:p,dpr:this.levelDpr(),now:t})&&(e=!0)}for(let w=m;w<=L;w++){let p=this.layouts[w];p.left+p.widtha||this.loader(w).draw({g:i,originX:(p.left-o)*h,originY:p.top*h,width:p.width*h,height:p.height*h,canvasWidth:s,canvasHeight:n,displayWidth:p.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 zt(r){let t=await fetch(r,{credentials:"same-origin"});if(!t.ok)throw new Error(r+" "+t.status);return await t.json()}function Rt(r){return{scheduler:new Z(r.concurrency,r.workerUrl),cache:new V(gt())}}async function oe(r,t){let e=await zt(t.manifestUrl);if(e.photos.length===0)return;let{scheduler:i,cache:s}=Rt(t);document.documentElement.classList.add("has-viewer"),Ft(new it(r,e,t,{scheduler:i,cache:s,settings:t,tiles:e.tiles}))}async function ae(r,t){let e=await zt(t.indexUrl),{scheduler:i,cache:s}=Rt(t);Ft(new j(r,e,t,{scheduler:i,cache:s,settings:t,tiles:e.tiles}))}function Ft(r){document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?r.suspend(!1):r.resume()}),window.addEventListener("pagehide",()=>r.suspend(!0)),window.addEventListener("pageshow",t=>{t.persisted&&r.resume()})}function he(){document.documentElement.classList.remove("has-viewer"),document.querySelector(".load-error")?.removeAttribute("hidden")}function It(){let r=St(document.body);if(r.page==="album"){let t=document.getElementById("stage");t&&oe(t,r).catch(()=>he())}else if(r.page==="notfound"){let t=document.querySelector(".site-header .wordmark");t&&D(t,!1)}else if(r.page==="index"){let t=document.getElementById("strips");t&&ae(t,r).catch(()=>{document.documentElement.classList.remove("has-strips");let e=document.querySelector(".site-header .wordmark");e&&!e.classList.contains("has-svg")&&D(e,!1)})}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",It,{once:!0}):It();})(); diff --git a/packaging/config.toml b/packaging/config.toml index 2a66986..2b6402b 100644 --- a/packaging/config.toml +++ b/packaging/config.toml @@ -12,7 +12,7 @@ cache = "/var/cache/luphoto" tile_size = 512 overlap = 1 format = "webp" -quality = { top = 82, mid = 85, low = 88 } +quality = { top = 90, mid = 88, low = 88 } min_levels = 6 seed_px = 48 tile_names = "hashed" diff --git a/web/src/viewer.ts b/web/src/viewer.ts index 30f9c69..2914cd4 100644 --- a/web/src/viewer.ts +++ b/web/src/viewer.ts @@ -42,6 +42,10 @@ const flickSpeed = 0.35; const rubberBand = 0.35; const captionZone = 0.2; const idleMs = 2500; +const zoomSettleMs = 120; +const wheelLine = 16; +const wheelRate = 0.002; +const pinchWheelRate = 0.01; function cubicBezier(x1: number, y1: number, x2: number, y2: number): (t: number) => number { const cx = 3 * x1; @@ -133,6 +137,24 @@ export class Viewer { private pinned = false; private resizeTimer = 0; private indexRequested = false; + private ox = 0; + private oy = 0; + private secondId: number | null = null; + private ax = 0; + private ay = 0; + private bx = 0; + private by = 0; + private pinching = false; + private stale = false; + private zoom = 1; + private zoomMax = 1; + private zoomPhoto = -1; + private zx = 0; + private zy = 0; + private slackX = 0; + private slackY = 0; + private zoomTimer = 0; + private gestureZoom = 1; constructor( private readonly stage: HTMLElement, @@ -235,6 +257,8 @@ export class Viewer { const rect = this.stage.getBoundingClientRect(); this.vw = Math.max(1, rect.width); this.vh = Math.max(1, rect.height); + this.ox = rect.left; + this.oy = rect.top; this.dpr = Math.min(window.devicePixelRatio || 1, this.settings.maxDpr); const cw = Math.max(1, Math.round(this.vw * this.dpr)); const ch = Math.max(1, Math.round(this.vh * this.dpr)); @@ -322,6 +346,13 @@ export class Viewer { this.updateCaption(); } }); + stage.addEventListener("wheel", (e) => this.onWheel(e), { passive: false }); + stage.addEventListener("gesturestart", (e) => { + e.preventDefault(); + this.gestureZoom = this.zoom; + }); + stage.addEventListener("gesturechange", (e) => this.onGesture(e as Event & { scale?: number; clientX?: number; clientY?: number })); + stage.addEventListener("gestureend", (e) => e.preventDefault()); stage.addEventListener("dragstart", (e) => e.preventDefault()); stage.addEventListener("selectstart", (e) => e.preventDefault()); if (this.settings.blockContextMenu) { @@ -332,6 +363,9 @@ export class Viewer { const target = this.stopForHash(); if (this.stops[target].photo !== this.stops[this.current].photo) { this.jump(target); + } else if (this.clearZoom()) { + this.startSession(); + this.updateCaption(); } }); new ResizeObserver(() => this.onResize()).observe(stage); @@ -349,6 +383,7 @@ export class Viewer { if (before === this.vw + "x" + this.vh + "@" + this.dpr) { return; } + this.clearZoom(); this.tween = null; this.camera = this.stops[this.current].camera; this.requestDraw(); @@ -379,7 +414,11 @@ export class Viewer { this.go(this.stops.length - 2); break; case "Escape": - location.assign("/"); + if (this.zoomPhoto >= 0) { + this.go(this.current); + } else { + location.assign("/"); + } break; case "i": case "I": @@ -393,7 +432,24 @@ export class Viewer { } private onPointerDown(e: PointerEvent): void { - if (this.pointerId !== null || (e.pointerType === "mouse" && e.button !== 0)) { + if (e.pointerType === "mouse" && e.button !== 0) { + return; + } + if (this.pointerId !== null) { + if ( + 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 = true; + this.dragging = true; + this.stage.setPointerCapture(e.pointerId); + } return; } if ((e.target as Element).closest("a, button")) { @@ -402,8 +458,11 @@ export class Viewer { this.pointerId = e.pointerId; this.pointerType = e.pointerType; this.dragging = false; + this.stale = false; 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; @@ -422,7 +481,11 @@ export class Viewer { } return; } - if (e.pointerId !== this.pointerId) { + 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; } const dx = e.clientX - this.downX; @@ -433,6 +496,16 @@ export class Viewer { this.updateCaption(); } if (!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; } this.samples.push({ t: e.timeStamp, x: e.clientX }); @@ -444,6 +517,10 @@ export class Viewer { } private onPointerUp(e: PointerEvent, cancelled: boolean): void { + if (this.pinching && (e.pointerId === this.pointerId || e.pointerId === this.secondId)) { + this.endPinch(e.pointerId); + return; + } if (e.pointerId !== this.pointerId) { return; } @@ -454,12 +531,16 @@ export class Viewer { const wasDragging = this.dragging; this.dragging = false; this.stage.classList.remove("is-dragging"); + if (this.stale) { + this.stale = false; + return; + } const moved = Math.hypot(e.clientX - this.downX, e.clientY - this.downY); if (!cancelled && !wasDragging && moved < tapDistance && e.timeStamp - this.downT < tapMs) { this.onTap(e); return; } - if (!wasDragging) { + if (!wasDragging || this.zoomPhoto >= 0) { return; } let velocity = 0; @@ -491,7 +572,7 @@ export class Viewer { private onTap(e: PointerEvent): void { const stop = this.stops[this.current]; - if (stop.photo < 0) { + if (stop.photo < 0 || this.zoomPhoto >= 0) { return; } const rect = this.photoRect(stop.photo); @@ -501,6 +582,178 @@ export class Viewer { } } + private onWheel(e: WheelEvent): void { + e.preventDefault(); + if (this.pinching || (this.dragging && this.zoomPhoto < 0)) { + return; + } + let delta = e.deltaY; + if (e.deltaMode === 1) { + delta *= wheelLine; + } else if (e.deltaMode === 2) { + delta *= this.vh; + } + if (delta === 0) { + return; + } + const step = Math.max(-1, Math.min(1, delta * (e.ctrlKey ? pinchWheelRate : wheelRate))); + const x = e.clientX - this.ox; + const y = e.clientY - this.oy; + this.zoomTo(this.zoom * Math.exp(-step), x, y, x, y); + } + + private onGesture(e: Event & { scale?: number; clientX?: number; clientY?: number }): void { + e.preventDefault(); + if (this.pointerId !== null || !e.scale) { + return; + } + const x = (e.clientX ?? this.ox + this.vw / 2) - this.ox; + const y = (e.clientY ?? this.oy + this.vh / 2) - this.oy; + this.zoomTo(this.gestureZoom * e.scale, x, y, x, y); + } + + private pinchMove(id: number, x: number, y: number): void { + const px = (this.ax + this.bx) / 2 - this.ox; + const py = (this.ay + this.by) / 2 - this.oy; + const before = Math.hypot(this.ax - this.bx, this.ay - this.by); + if (id === this.pointerId) { + this.ax = x; + this.ay = y; + } else { + this.bx = x; + this.by = y; + } + const after = Math.hypot(this.ax - this.bx, this.ay - this.by); + const target = before > 1 && after > 1 ? (this.zoom * after) / before : this.zoom; + this.zoomTo(target, px, py, (this.ax + this.bx) / 2 - this.ox, (this.ay + this.by) / 2 - this.oy); + } + + private endPinch(id: number): void { + if (this.stage.hasPointerCapture(id)) { + this.stage.releasePointerCapture(id); + } + if (id === this.pointerId) { + this.pointerId = this.secondId; + this.ax = this.bx; + this.ay = this.by; + } + this.secondId = null; + this.pinching = false; + this.dragging = true; + if (this.zoomPhoto >= 0) { + this.settleZoom(); + } + } + + private enterZoom(): boolean { + const stop = this.stops[this.current]; + if (stop.photo < 0 || this.suspended) { + return false; + } + const layout = this.layouts[stop.photo]; + const max = this.manifest.photos[stop.photo].width / (window.devicePixelRatio || 1) / layout.width; + if (max <= 1.001) { + return false; + } + this.tween = null; + this.camera = stop.camera; + this.zoomPhoto = stop.photo; + this.zoomMax = max; + this.zoom = 1; + this.zx = layout.left - (this.camera - this.vw / 2); + this.zy = layout.top; + this.slackX = this.zx - this.clampAxis(this.zx, layout.width, this.vw, 0); + this.slackY = this.zy - this.clampAxis(this.zy, layout.height, this.vh, 0); + this.updateCaption(); + return true; + } + + private zoomTo(target: number, px: number, py: number, qx: number, qy: number): void { + if (this.zoomPhoto < 0 && (target <= 1 || !this.enterZoom())) { + return; + } + const zoom = Math.max(1, Math.min(this.zoomMax, target)); + const f = zoom / this.zoom; + this.zx = qx - (px - this.zx) * f; + this.zy = qy - (py - this.zy) * f; + this.zoom = zoom; + this.settleZoom(); + } + + private settleZoom(): void { + const layout = this.layouts[this.zoomPhoto]; + this.zx = this.clampAxis(this.zx, layout.width * this.zoom, this.vw, this.slackX); + this.zy = this.clampAxis(this.zy, layout.height * this.zoom, this.vh, this.slackY); + this.requestDraw(); + if (this.zoom <= 1 && !this.pinching) { + this.camera = layout.left + this.vw / 2 - this.zx; + this.go(this.nearestStop(this.camera)); + return; + } + clearTimeout(this.zoomTimer); + this.zoomTimer = window.setTimeout(() => this.startZoomSession(), zoomSettleMs); + } + + private clampAxis(position: number, size: number, view: number, slack: number): number { + const centre = (view - size) / 2; + let lo = Math.min(view - size, centre); + let hi = Math.max(0, centre); + const extra = slack * Math.max(0, 2 - this.zoom); + if (extra > 0) { + hi += extra; + } else { + lo += extra; + } + return Math.min(hi, Math.max(lo, position)); + } + + private clearZoom(): boolean { + if (this.zoomPhoto < 0) { + return false; + } + this.zoomPhoto = -1; + this.zoom = 1; + this.gestureZoom = 1; + clearTimeout(this.zoomTimer); + this.zoomTimer = 0; + if (this.pointerId !== null) { + this.stale = true; + this.pinching = false; + this.secondId = null; + } + this.requestDraw(); + return true; + } + + private levelDpr(): number { + if (this.zoomPhoto >= 0 && this.zoom >= this.zoomMax * 0.999) { + return Math.max(this.dpr, window.devicePixelRatio || 1); + } + return this.dpr; + } + + private startZoomSession(): void { + this.zoomTimer = 0; + if (this.suspended || this.zoomPhoto < 0) { + return; + } + const layout = this.layouts[this.zoomPhoto]; + const w = layout.width * this.zoom; + const h = layout.height * this.zoom; + const a = Math.max(0, this.zx); + const b = Math.min(this.vw, this.zx + w); + const c = Math.max(0, this.zy); + const d = Math.min(this.vh, this.zy + h); + if (b <= a || d <= c) { + return; + } + this.loader(this.zoomPhoto).start( + { displayWidth: w, u0: (a - this.zx) / w, u1: (b - this.zx) / w, v0: (c - this.zy) / h, v1: (d - this.zy) / h }, + this.levelDpr(), + () => undefined, + ); + } + private rubber(camera: number): number { const min = this.stops[0].camera; const max = this.stops[this.stops.length - 1].camera; @@ -526,6 +779,7 @@ export class Viewer { private go(index: number): void { const target = Math.max(0, Math.min(this.stops.length - 1, index)); const previous = this.current; + const unzoomed = this.clearZoom(); const to = this.stops[target].camera; if (this.reducedMotion.matches) { this.crossfade(() => { @@ -549,6 +803,9 @@ export class Viewer { if (target !== previous) { this.activate(previous); } else { + if (unzoomed) { + this.startSession(); + } this.updateCaption(); } this.requestDraw(); @@ -556,6 +813,7 @@ export class Viewer { private jump(index: number): void { const previous = this.current; + this.clearZoom(); this.tween = null; this.crossfade(() => { this.current = index; @@ -661,6 +919,7 @@ export class Viewer { return; } this.suspended = false; + this.clearZoom(); this.canvas.width = 0; this.measure(); this.camera = this.stops[this.current].camera; @@ -746,7 +1005,7 @@ export class Viewer { private updateCaption(): void { const stop = this.stops[this.current]; - const visible = stop.photo >= 0 && !this.dragging && (this.pinned || this.hover); + const visible = stop.photo >= 0 && this.zoomPhoto < 0 && !this.dragging && (this.pinned || this.hover); if (visible) { const rect = this.photoRect(stop.photo); this.caption.place(rect.left, rect.right - rect.left, this.vh - rect.bottom); @@ -835,7 +1094,25 @@ export class Viewer { const dpr = this.dpr; const near = this.stops[this.current].photo; const from = Math.max(0, (near < 0 ? this.layouts.length - 1 : near) - 2); - const to = Math.min(this.layouts.length - 1, (near < 0 ? this.layouts.length - 1 : near) + 2); + const to = this.zoomPhoto >= 0 ? -1 : Math.min(this.layouts.length - 1, (near < 0 ? this.layouts.length - 1 : near) + 2); + if (this.zoomPhoto >= 0) { + const layout = this.layouts[this.zoomPhoto]; + const w = layout.width * this.zoom; + if (this.loader(this.zoomPhoto).draw({ + g, + originX: this.zx * dpr, + originY: this.zy * dpr, + width: w * dpr, + height: layout.height * this.zoom * dpr, + canvasWidth: cw, + canvasHeight: ch, + displayWidth: w, + dpr: this.levelDpr(), + now, + })) { + again = true; + } + } for (let i = from; i <= to; i++) { const layout = this.layouts[i]; if (layout.left + layout.width < left || layout.left > right) {