dsh-ccx 0.8.9 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/LICENSE +21 -21
  2. package/NOTICE +23 -23
  3. package/README.md +151 -143
  4. package/assets/icon.svg +27 -27
  5. package/cordis.patch.yml +16 -16
  6. package/lib/client.js +1481 -2244
  7. package/lib/index.js +716 -449
  8. package/lib/vendor/code-codex/ascii-tiles.js +145 -0
  9. package/lib/vendor/code-codex/aurora-ionosphere.js +7 -6
  10. package/lib/vendor/code-codex/black-hole.js +10 -7
  11. package/lib/vendor/code-codex/blinking-squares.js +6 -13
  12. package/lib/vendor/code-codex/cloud-train.js +9 -8
  13. package/lib/vendor/code-codex/galleries.json +100 -100
  14. package/lib/vendor/code-codex/glow-horizon.js +1 -1
  15. package/lib/vendor/code-codex/heavenly-cloud.js +5 -4
  16. package/lib/vendor/code-codex/milky-way.js +3 -2
  17. package/lib/vendor/code-codex/mountain.js +5 -4
  18. package/lib/vendor/code-codex/particle-image.js +435 -14
  19. package/lib/vendor/code-codex/pixel-sculpt.js +85 -5
  20. package/lib/vendor/code-codex/scene-defaults.json +94 -1
  21. package/lib/vendor/code-codex/scene-schemas.json +1008 -0
  22. package/lib/vendor/code-codex/shallow-ocean-thumbnails.json +12 -0
  23. package/lib/vendor/code-codex/shallow-ocean.js +5094 -0
  24. package/lib/vendor/code-codex/spectral-drape.js +172 -0
  25. package/package.json +70 -59
  26. package/src/client/api.ts +90 -0
  27. package/src/client/background/layer.ts +187 -0
  28. package/src/client/background/pixel-sculpt.ts +167 -0
  29. package/src/client/background/scene-runner.ts +317 -0
  30. package/src/client/background/shallow-ocean.ts +344 -0
  31. package/src/client/background/vendor-loader.ts +297 -0
  32. package/src/client/background/wallpaper.ts +87 -0
  33. package/src/client/index.ts +247 -0
  34. package/src/client/surfaces/corner-patch.ts +100 -0
  35. package/src/client/surfaces/surface-css.ts +155 -0
  36. package/src/client/ui/draft.ts +105 -0
  37. package/src/client/ui/icons.ts +47 -0
  38. package/src/client/ui/panel.ts +1524 -0
  39. package/src/client/ui/shallow-ocean-panel.ts +376 -0
  40. package/src/client/ui/styles.ts +1471 -0
  41. package/src/host/fence.ts +78 -0
  42. package/src/host/index.ts +26 -0
  43. package/src/host/routes.ts +367 -0
  44. package/src/host/storage.ts +109 -0
  45. package/src/host/window-chrome.ts +53 -0
  46. package/src/shared/constants.ts +239 -0
  47. package/src/shared/sanitize.ts +110 -0
  48. package/src/shared/types.ts +145 -0
  49. package/tsconfig.json +16 -0
@@ -257,7 +257,7 @@ Nothing in this notice limits rights granted directly by an applicable license,
257
257
 
258
258
 
259
259
  */
260
- (()=>{var Ke=/(token|cookie|password|secret|credential|authorization|apikey)/i,je=/^(content|text|body|prompt|messages|title|filename|name|raw|data|database64|commandline|sessionid|accountid|threadid|projectid)$|(?:path|url|uri)$/i;function Q(o){return o.slice(0,8e3).replace(/\b[A-Za-z][A-Za-z0-9+.-]*:\/\/[^\s"'<>]+/g,r=>{try{let n=new URL(r);if(["127.0.0.1","localhost","[::1]"].includes(n.hostname)&&!n.username&&!n.password&&["/json/version","/json/list","/"].includes(n.pathname))return`${n.origin}${n.pathname}`}catch{}return"[url]"}).replace(/(?:\b[A-Za-z]:[\\/]|\\\\|\/(?:Users|home|tmp|var|etc|opt|mnt)\/|~\/)[^\r\n"'<>]*/g,"[path]").replace(/\b(?:Bearer\s+\S+|(?:authorization|password|secret|(?:access[_-]?|refresh[_-]?)?token|api[_-]?key|cookie)\s*[:=]\s*[^,;\r\n]+)/gi,"[credential]").replace(/\bsk-[A-Za-z0-9_-]{8,}|\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g,"[credential]").replace(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,"[email]").slice(0,4e3)+(o.length>8e3?" [truncated]":"")}function Pe(o){let e=256,r=new WeakSet,n=(t,i)=>{if(--e<0||i>6)return"[truncated]";if(typeof t=="string")return Q(t);if(t===null||typeof t=="boolean"||typeof t=="number")return t;if(typeof t!="object")return"[unsupported]";if(r.has(t))return"[circular]";if(r.add(t),t instanceof Error)return{name:Q(t.name),message:Q(t.message)};if(Array.isArray(t))return t.slice(0,128).map(u=>n(u,i+1));let s=Object.create(null);for(let[u,a]of Object.entries(t).slice(0,128)){let h=u.replace(/[^a-z0-9]/gi,"");s[Q(u).slice(0,160)]=Ke.test(h)||je.test(h)?"[redacted]":n(a,i+1)}return s};try{return n(o,0)}catch{return{redactionFailed:!0}}}var $e=Symbol.for("code-codex:runtime-events:v1"),Ze=window,de=Ze[$e]??={events:[],dropped:0};function $(o,e,r,n={}){let t={source:Q(o).slice(0,160),action:Q(e).slice(0,160),outcome:Q(r).slice(0,160),details:{...Pe(n),observedAt:Date.now(),documentElapsedMs:Math.round(performance.now())}},i=new TextEncoder().encode(JSON.stringify(t)).length;i>7e3&&(t.details={truncated:!0,originalBytes:i,observedAt:Date.now(),documentElapsedMs:Math.round(performance.now())}),de.events.push(t),de.events.length>1e3&&(de.events.splice(0,200),de.dropped+=200)}var Je=Symbol.for("code-codex:background-startup-hold:v1");function ge(){let o=window;return o[Je]??={active:!1,layers:new Set,next:-1,pending:new Map,painted:new WeakSet,openings:new WeakMap}}function Qe(o){return o.closest("[data-code-codex-particle-layer]")}function et(o,e){e.native=requestAnimationFrame(r=>{let n=ge();e.native=void 0,n.pending.has(o)&&(n.active&&n.painted.has(e.layer)||(n.pending.delete(o),n.active&&(n.painted.add(e.layer),n.layers.add(e.layer),$("background-opening","initial frame","prepared")),e.callback(r)))})}function ve(o,e){let r=Qe(o);if(!r)return requestAnimationFrame(e);let n=ge(),t=n.next--,i={layer:r,callback:e};return n.pending.set(t,i),et(t,i),t}function oe(o){if(o>=0){cancelAnimationFrame(o);return}let e=ge(),r=e.pending.get(o);r?.native!==void 0&&cancelAnimationFrame(r.native),e.pending.delete(o)}var Ht=Object.freeze({distance:24,elevation:-5.5,azimuth:0,orbitSpeed:0,roll:-20,fov:42,diskInner:3,diskOuter:15,diskThickness:.26,diskDensity:1,brightness:1,spinSpeed:.06,grain:.48,doppler:.35,hotColor:"#FFF3DE",midColor:"#FF9838",coolColor:"#8E3A0B",starBrightness:0,glow:1,exposure:.9,vignette:.28,steps:200,resolution:.4,maxDpr:1,paused:!1}),Gt=Object.freeze({variant:"bottom",inertialWheel:!0,openingDuration:2,wheelSensitivity:1,wheelDownIntensity:.4,wheelUpIntensity:.8,wheelTravelScale:1,wheelDownDistance:100,wheelUpDistance:20,wheelUpTrailDistance:18,wheelUpTrailStrength:1.15,wheelUpStiffness:180,wheelUpDamping:48,wheelReleaseDelay:70,wheelUpReleaseDelay:80,maxReleaseVelocity:2.4,returnStiffness:180,returnDamping:14,initialStretch:1.8,initialBlur:0,rimColor:"#FFFFFF",violetColor:"#A558FB",blueColor:"#4922E5",shadowColor:"#000000"}),Wt=Object.freeze({low:Object.freeze({steps:56,resolutionScale:.56,maxDpr:1}),medium:Object.freeze({steps:76,resolutionScale:.72,maxDpr:1.25}),high:Object.freeze({steps:100,resolutionScale:.86,maxDpr:1.5})}),Vt=Object.freeze({quality:"high",speed:.72,intensity:1.15,turbulence:1,radius:3,colorShift:0,pointerInfluence:.45,introDuration:2.2,introFeather:.22,paused:!1}),Xt=Object.freeze({low:Object.freeze({steps:32,rayScale:.72,maxDpr:1.1,minAdaptiveScale:.92,noiseAtlasSize:512}),medium:Object.freeze({steps:50,rayScale:.76,maxDpr:1.25,minAdaptiveScale:.9,noiseAtlasSize:768}),high:Object.freeze({steps:72,rayScale:.82,maxDpr:1.4,minAdaptiveScale:.9,noiseAtlasSize:1024})}),qt=Object.freeze({hue:0,saturation:1,quality:"medium",speed:1,intensity:1,curtainScale:.5,turbulence:.58,glow:.72,starDensity:.56,introDuration:2.4,introFeather:.16,introStart:-.22,introEnd:1.32,introSkyEnd:.48,introStarStart:.34,paused:!1});function re(o,e,r,n){let t=typeof o=="number"?o:Number(o);return Number.isFinite(t)?Math.min(r,Math.max(e,t)):n}var Yt=Object.freeze({top:{axis:"y",enter:-100,rest:-50},bottom:{axis:"y",enter:100,rest:50},left:{axis:"x",enter:100,rest:50},right:{axis:"x",enter:-100,rest:-50}});var Kt=Object.freeze({quality:"medium",speed:.35,amplitude:1,frequency:1,zoom:1,rotation:0,exposure:1,timeOffset:5.07,introDuration:2.8,introFeather:.18,introAngle:32,introZoom:.16,introEnabled:!0,paused:!1,colors:Object.freeze(["#d81159","#8f2d56","#218380","#fbb13c","#73d2de"])});var jt=Object.freeze([.72,.46]),$t=Math.PI/180;var tt="code-codex:particle-image-background:v1",rt="code-codex-particle-image-background",nt=1,fe="images",ot=900,we=3e4,ie=4096,ne=40,Fe=1,Ue=.12,Oe=Fe+Ue,he=Oe/ne,me=1/64,Ee=.18,it=.1,Re=40,at=400,st=3.2/5.2,lt=1.4/5.2,Ne=.6,ae=.08,se=4.7438645,ut=.0015,ct=.005,dt=.05,ht=.2,ee=Object.freeze({x1:.42,y1:0,x2:.58,y2:1,nodes:Object.freeze([])}),mt=32,j=1e-4,I=Object.freeze({particleCount:56e4,particleSize:1.8,particleOpacity:.96,speed:.7,noiseScale:1e-4,noiseStrength:.005,damping:.9919,ambientCycle:80,selectedImageIds:Object.freeze([]),activeImageId:null,autoSwitch:!0,imageDurationSeconds:2,morphIntervalSeconds:2.5,morphCurve:ee,imageOpacity:1,showSourceImage:!0,backgroundColor:"#000000",cursorStrength:Re,cursorInteraction:!0,dprCap:1.5,introEnabled:!0,introDuration:4,introSpread:1}),le=Object.freeze({positionX:50,positionY:50,zoom:1});function ke(o){let e=Math.min(Math.max(o,0),Re),r=e*6.25,n=Math.max(e/.64,0),t=Math.max(n/15.625,1),i=Math.max(n/31.25,1),s=Math.max(o/Re,1),u=Math.pow(Math.max(n,1),.45)*Math.pow(t,.28)*Math.pow(i,.32)*Math.pow(s,.45),a=Math.pow(Math.max(n,1),.35)*Math.pow(t,.18)*Math.pow(i,.22)*Math.pow(s,.35),h=4*(n<1?n:Math.pow(Math.max(n,1),.55))*Math.pow(t,.3)*Math.pow(i,.34)*s,d=Math.pow(Math.max(n,1),.12)*Math.pow(t,.16)*Math.pow(i,.2);return{baseStrength:e,cursorScale:r,strengthRatio:n,extendedStrength:t,extremeStrength:i,overdrive:s,highStrengthScale:u,stepStrengthScale:a,strength:h,wakeLengthScale:d,squareRootStrength:Math.sqrt(Math.max(h,0))}}function Z(o,e=0){return re(o,0,1,e)}function ze(o){let e=Array.isArray(o)?{nodes:o}:o&&typeof o=="object"?o:ee,r=Z(e.x1,ee.x1),n=Z(e.y1,ee.y1),t=Z(e.x2,ee.x2),i=Z(e.y2,ee.y2);r>t&&([r,t]=[t,r]),n>i&&([n,i]=[i,n]);let s=[],u=Array.isArray(e.nodes)?e.nodes:[];for(let c of u){let l,m;if(Array.isArray(c))l=c[0],m=c[1];else if(c&&typeof c=="object"){let b=c;l=b.time??b.x,m=b.progress??b.y}else continue;let f=Number(l),p=Number(m);!Number.isFinite(f)||!Number.isFinite(p)||s.push({time:Z(f),progress:Z(p)})}s.sort((c,l)=>c.time-l.time||c.progress-l.progress);let a=[],h=0,d=0;for(let c of s)if(!(c.time<=j||c.time>=1-j||c.progress<=j||c.progress>=1-j||c.time<=h+j||c.progress<=d+j)&&(a.push(c),h=c.time,d=c.progress,a.length>=mt))break;return{x1:r,y1:n,x2:t,y2:i,nodes:a}}function ft(o){return{x1:o.x1,y1:o.y1,x2:o.x2,y2:o.y2,nodes:o.nodes.map(e=>({time:e.time,progress:e.progress}))}}function ye(o,e,r){let n=1-o;return 3*n*n*o*e+3*n*o*o*r+o*o*o}function be(o,e,r){let n=1-o;return 3*n*n*e+6*n*o*(r-e)+3*o*o*(1-r)}function Ie(o,e,r,n){if(!(r>0))return 0;let t=((2*o+e)*r-o*n)/Math.max(o+e,j);return!Number.isFinite(t)||t<=0||r*n<=0?0:Math.min(t,3*r)}var De=new WeakMap;function pt(o){let e=De.get(o);if(e)return e;let r=[{time:0,progress:0},...o.nodes,{time:1,progress:1}],n=[],t=[];for(let u=0;u<r.length-1;u+=1){let a=r[u],h=r[u+1];if(!a||!h)continue;let d=Math.max(h.time-a.time,j);n.push(d),t.push(Math.max(0,h.progress-a.progress)/d)}let i=new Array(r.length).fill(0);if(t.length===1)i[0]=t[0]??0,i[1]=t[0]??0;else if(t.length>1){let u=t[0]??0,a=t[1]??u,h=o.x1>j?o.y1/o.x1:Number.NaN,d=1-o.x2,c=d>j?(1-o.y2)/d:Number.NaN;i[0]=Number.isFinite(h)?Math.min(Math.max(0,h),3*u):Ie(n[0]??1,n[1]??1,u,a);for(let b=1;b<r.length-1;b+=1){let S=t[b-1]??0,A=t[b]??0;if(S<=0||A<=0){i[b]=0;continue}let x=n[b-1]??1,E=n[b]??1,D=2*E+x,R=E+2*x;i[b]=(D+R)/(D/S+R/A)}let l=t.length-1,m=r.length-1,f=t[l]??0,p=t[l-1]??f;i[m]=Number.isFinite(c)?Math.min(Math.max(0,c),3*f):Ie(n[l]??1,n[l-1]??1,f,p)}let s={anchors:r,spans:n,slopes:i};return De.set(o,s),s}function gt(o,e=ee){let r=Z(o);if(r<=0)return{value:0,slope:0,parameter:0};if(r>=1)return{value:1,slope:0,parameter:1};if(e.nodes.length){let{anchors:d,spans:c,slopes:l}=pt(e),m=0;for(;m<c.length-1&&r>(d[m+1]?.time??1);)m+=1;let f=d[m]??d[0]??{time:0,progress:0},p=d[m+1]??d.at(-1)??{time:1,progress:1},b=c[m]??1,S=Math.min(1,Math.max(0,(r-f.time)/b)),A=S*S,x=A*S,E=2*x-3*A+1,D=x-2*A+S,R=-2*x+3*A,U=x-A,M=l[m]??0,H=l[m+1]??0,P=Math.min(p.progress,Math.max(f.progress,E*f.progress+D*b*M+R*p.progress+U*b*H)),z=(6*A-6*S)*f.progress/b+(3*A-4*S+1)*M+(-6*A+6*S)*p.progress/b+(3*A-2*S)*H;return{value:Z(P),slope:Math.min(8,Math.max(0,Number.isFinite(z)?z:0)),parameter:S}}let n=r;for(let d=0;d<5;d+=1){let c=ye(n,e.x1,e.x2)-r,l=be(n,e.x1,e.x2);if(Math.abs(c)<1e-5||Math.abs(l)<1e-5)break;n=Math.min(1,Math.max(0,n-c/l))}let t=0,i=1;for(let d=0;d<8;d+=1){let c=ye(n,e.x1,e.x2);if(Math.abs(c-r)<1e-5)break;c<r?t=n:i=n,n=.5*(t+i)}let s=Z(ye(n,e.y1,e.y2)),u=be(n,e.x1,e.x2),a=be(n,e.y1,e.y2),h=u>1e-5?Math.min(8,Math.max(0,a/u)):0;return{value:s,slope:h,parameter:n}}function Ae(o){return Math.round(re(o,1e4,2e6,I.particleCount)/1e4)*1e4}function q(o,e,r,n,t,i){let s=re(o,e,r,t),u=e+Math.round((s-e)/n)*n;return Number(Math.min(r,Math.max(e,u)).toFixed(i))}function ue(o){let e=o&&typeof o=="object"?o:{};return{positionX:q(e.positionX,0,100,1,le.positionX,0),positionY:q(e.positionY,0,100,1,le.positionY,0),zoom:q(e.zoom,.25,4,.05,le.zoom,2)}}function Ce(o,e){let r=ue(e),n=`${r.positionX}% ${r.positionY}%`;o.style.setProperty("object-position",n,"important"),o.style.setProperty("transform-origin",n,"important"),o.style.setProperty("transform",`scale(${r.zoom})`,"important")}function vt(o){return typeof o=="string"&&/^#[0-9a-f]{6}$/i.test(o)?o.toLocaleLowerCase():I.backgroundColor}function yt(o){let e=o&&typeof o=="object"?o:{},r=Array.isArray(e.selectedImageIds)?[...new Set(e.selectedImageIds.filter(n=>typeof n=="string"&&n.length<=128))]:[];return{particleCount:Ae(e.particleCount),particleSize:q(e.particleSize,.5,4,.1,I.particleSize,1),particleOpacity:q(e.particleOpacity,.1,1,.01,I.particleOpacity,2),speed:q(e.speed,0,2,.05,I.speed,2),noiseScale:q(e.noiseScale,1e-4,.002,1e-4,I.noiseScale,4),noiseStrength:q(e.noiseStrength,0,.15,.005,I.noiseStrength,3),damping:q(e.damping,.8,.9999,1e-4,I.damping,4),ambientCycle:q(e.ambientCycle,40,500,10,I.ambientCycle,0),selectedImageIds:r,activeImageId:typeof e.activeImageId=="string"&&e.activeImageId.length<=128?e.activeImageId:null,autoSwitch:typeof e.autoSwitch=="boolean"?e.autoSwitch:I.autoSwitch,imageDurationSeconds:Math.round(re(e.imageDurationSeconds,1,60,I.imageDurationSeconds)),morphIntervalSeconds:Math.round(re(e.morphIntervalSeconds,1,12,I.morphIntervalSeconds)*10)/10,morphCurve:ze(e.morphCurve),imageOpacity:Math.round(re(e.imageOpacity,0,1,I.imageOpacity)*100)/100,showSourceImage:typeof e.showSourceImage=="boolean"?e.showSourceImage:I.showSourceImage,backgroundColor:vt(e.backgroundColor),cursorStrength:q(e.cursorStrength,0,at,.01,I.cursorStrength,2),cursorInteraction:typeof e.cursorInteraction=="boolean"?e.cursorInteraction:I.cursorInteraction,dprCap:q(e.dprCap,1,2,.25,I.dprCap,2),introEnabled:typeof e.introEnabled=="boolean"?e.introEnabled:I.introEnabled,introDuration:q(e.introDuration,.5,12,.1,I.introDuration,1),introSpread:q(e.introSpread,.2,2,.05,I.introSpread,2)}}function bt(){try{return yt(JSON.parse(localStorage.getItem(tt)||"{}"))}catch{return{...I}}}function xe(o){let e=Math.sin(o*91.317)*47453.5453;return e-Math.floor(e)}function Se(o){let e=o>>>0;return e^=e>>>16,e=Math.imul(e,2146121005),e^=e>>>15,e=Math.imul(e,2221713035),e^=e>>>16,e>>>0}function xt(){let o=globalThis,e=n=>{let t=Math.sin(n*91.317)*47453.5453;return t-Math.floor(t)},r=n=>{let t=n>>>0;return t^=t>>>16,t=Math.imul(t,2146121005),t^=t>>>15,t=Math.imul(t,2221713035),t^=t>>>16,t>>>0};o.addEventListener("message",n=>{(async()=>{let t=n.data,i=Number(t.jobId),s=String(t.imageId||""),u=t.source,a=Number(t.targetCount),h;try{if(!(u instanceof Blob))throw new Error("The image source is invalid");if(typeof createImageBitmap!="function"||typeof OffscreenCanvas!="function")throw new Error("Background image preparation is unavailable");h=await createImageBitmap(u);let d=h.width,c=h.height;if(!d||!c||d>16384||c>16384)throw new Error("The image dimensions are unsupported");let m=Math.min(1,900/Math.max(d,c)),f=Math.max(1,Math.round(d*m)),p=Math.max(1,Math.round(c*m)),b=new OffscreenCanvas(f,p),S=b.getContext("2d",{willReadFrequently:!0});if(!S||typeof b.convertToBlob!="function")throw new Error("The image preparation canvas is unavailable");S.clearRect(0,0,f,p),S.drawImage(h,0,0,f,p);let A=S.getImageData(0,0,f,p),x=A.data,E=r(f^p<<16),D=0;for(let y=0;y<x.length;y+=4){let F=x[y]??0,V=x[y+1]??0,O=x[y+2]??0,_=x[y+3]??0,v=Math.round(F*.2126+V*.7152+O*.0722);x[y]=v,x[y+1]=v,x[y+2]=v;let w=y>>>2;(w&3)===0&&(E=r(E^v^_<<8^Math.imul(w+1,2654435761))),_>=24&&(D+=1)}if(!D)throw new Error("The image contains no visible pixels");S.putImageData(A,0,0);let R=await b.convertToBlob({type:"image/png"}),U=f*p,M=new Uint32Array(U),H=new Uint8Array(U),P=0;for(let y=0;y<p;y+=1){let F=y*f,V=Math.max(0,y-1)*f,O=Math.min(p-1,y+1)*f;for(let _=0;_<f;_+=1){let v=F+_,w=v*4,L=x[w+3]??0;if(L>=24){let Y=x[(F+Math.max(0,_-1))*4]??0,N=x[(F+Math.min(f-1,_+1))*4]??0,W=x[(V+_)*4]??0,J=x[(O+_)*4]??0,te=(x[w]??0)/255,X=Math.min(1,(Math.abs(N-Y)+Math.abs(J-W))/510);P+=Math.round(L/255*(Math.pow(te,.9)*144+X*112)),H[v]=Math.max(x[w]??0,Math.round(X*96))}M[v]=P}}if(!P)for(let y=0;y<U;y+=1)(x[y*4+3]??0)>=24&&(P+=1,H[y]=Math.max(x[y*4]??0,96)),M[y]=P;if(!P)throw new Error("The image contains no visible pixels");let z=4096,G=new Uint32Array(z+1),K=0,g=M.length-1;for(let y=0;y<=z;y+=1){let F=P*y/z;for(;K<g&&(M[K]??0)<=F;)K+=1;G[y]=K}let T=Math.min(2e6,Math.max(1e4,Math.round(a/1e4)*1e4)),C=new Float32Array(T*2),B=new Uint8Array(T*4),k=new Float32Array(T);for(let y=0;y<T;y+=1){let F=(r(y^E)+.5)/4294967296,V=F*P,O=Math.min(z-1,Math.floor(F*z)),_=G[O]??0,v=G[O+1]??_;for(;_<v;){let te=_+v>>>1;(M[te]??0)<=V?_=te+1:v=te}let w=_,L=w%f,Y=Math.floor(w/f),N=y*2,W=y*4;C[N]=Math.max(0,Math.min(1,(L+.5+(e(y+.17)-.5)*.82)/f)),C[N+1]=Math.max(0,Math.min(1,(Y+.5+(e(y+7.31)-.5)*.82)/p));let J=H[w]??0;B[W]=J,B[W+1]=J,B[W+2]=J,B[W+3]=x[w*4+3]??0,k[y]=e(y+19.73)}o.postMessage({type:"prepared",jobId:i,prepared:{imageId:s,targetCount:T,width:f,height:p,naturalWidth:d,naturalHeight:c,processedBlob:R,normalizedHomes:C,colors:B,seeds:k}},[C.buffer,B.buffer,k.buffer])}catch(d){o.postMessage({type:"error",jobId:i,message:d instanceof Error?d.message:String(d)},[])}finally{h?.close()}})()})}async function St(o,e,r,n){let t=()=>{if(n.aborted)throw new DOMException("Image preparation was cancelled","AbortError")},i=async()=>{await new Promise(u=>window.setTimeout(u,0)),t()};t();let s=await createImageBitmap(e);try{t();let u=s.width,a=s.height;if(!u||!a||u>16384||a>16384)throw new Error("The image dimensions are unsupported");let h=Math.min(1,ot/Math.max(u,a)),d=Math.max(1,Math.round(u*h)),c=Math.max(1,Math.round(a*h)),l=document.createElement("canvas");l.width=d,l.height=c;let m=l.getContext("2d",{willReadFrequently:!0});if(!m)throw new Error("The image preparation canvas is unavailable");m.drawImage(s,0,0,d,c);let f=m.getImageData(0,0,d,c),p=f.data,b=Se(d^c<<16),S=0;for(let g=0;g<p.length;g+=4){let T=p[g+3]??0,C=Math.round((p[g]??0)*.2126+(p[g+1]??0)*.7152+(p[g+2]??0)*.0722);p[g]=C,p[g+1]=C,p[g+2]=C;let B=g>>>2;(B&3)===0&&(b=Se(b^C^T<<8^Math.imul(B+1,2654435761))),T>=24&&(S+=1),(g&524287)===524284&&await i()}if(!S)throw new Error("The image contains no visible pixels");m.putImageData(f,0,0);let A=await new Promise((g,T)=>{l.toBlob(C=>C?g(C):T(new Error("The processed image could not be created")),"image/png")});t();let x=d*c,E=new Uint32Array(x),D=new Uint8Array(x),R=0;for(let g=0;g<c;g+=1){let T=g*d,C=Math.max(0,g-1)*d,B=Math.min(c-1,g+1)*d;for(let k=0;k<d;k+=1){let y=T+k,F=y*4,V=p[F+3]??0;if(V>=24){let O=Math.min(1,(Math.abs((p[(T+Math.min(d-1,k+1))*4]??0)-(p[(T+Math.max(0,k-1))*4]??0))+Math.abs((p[(B+k)*4]??0)-(p[(C+k)*4]??0)))/510),_=(p[F]??0)/255;R+=Math.round(V/255*(Math.pow(_,.9)*144+O*112)),D[y]=Math.max(p[F]??0,Math.round(O*96))}E[y]=R}(g&63)===63&&await i()}if(!R)for(let g=0;g<x;g+=1)(p[g*4+3]??0)>=24&&(R+=1,D[g]=Math.max(p[g*4]??0,96)),E[g]=R,(g&131071)===131071&&await i();if(!R)throw new Error("The image contains no visible pixels");let U=new Uint32Array(ie+1),M=0,H=E.length-1;for(let g=0;g<=ie;g+=1){let T=R*g/ie;for(;M<H&&(E[M]??0)<=T;)M+=1;U[g]=M}let P=Ae(r),z=new Float32Array(P*2),G=new Uint8Array(P*4),K=new Float32Array(P);for(let g=0;g<P;g+=1){let T=(Se(g^b)+.5)/4294967296,C=T*R,B=Math.min(ie-1,Math.floor(T*ie)),k=U[B]??0,y=U[B+1]??k;for(;k<y;){let w=k+y>>>1;(E[w]??0)<=C?k=w+1:y=w}let F=k%d,V=Math.floor(k/d),O=g*2,_=g*4;z[O]=Math.max(0,Math.min(1,(F+.5+(xe(g+.17)-.5)*.82)/d)),z[O+1]=Math.max(0,Math.min(1,(V+.5+(xe(g+7.31)-.5)*.82)/c));let v=D[k]??0;G[_]=v,G[_+1]=v,G[_+2]=v,G[_+3]=p[k*4+3]??0,K[g]=xe(g+19.73),(g&32767)===32767&&await i()}return t(),{imageId:o,targetCount:P,width:d,height:c,naturalWidth:u,naturalHeight:a,processedBlob:A,normalizedHomes:z,colors:G,seeds:K}}finally{s.close()}}var Te=class{#o;#e;#w=1;constructor(){this.#o=this.#W()}prepare(e,r){let n=Ae(r),t=[e.id,e.createdAt,e.size,e.type,n].join(":");if(this.#e?.key===t)return this.#e.promise;this.invalidate();let i=new AbortController,s=()=>{},a=(this.#o?this.#V(e,n,d=>{s=d}):Promise.reject(new Error("Worker preprocessing is unavailable"))).catch(d=>{if(d instanceof DOMException&&d.name==="AbortError")throw d;if(i.signal.aborted)throw new DOMException("Image preparation was cancelled","AbortError");return St(e.id,e.blob,n,i.signal)}),h={key:t,imageId:e.id,promise:a,cancel:()=>{i.abort(),s()}};return this.#e=h,a.catch(()=>{this.#e===h&&(this.#e=void 0)}),a}prewarm(e,r){this.prepare(e,r).catch(n=>{n instanceof DOMException&&n.name==="AbortError"||console.warn("Code-Codex could not pre-process the next particle image",n)})}invalidate(e){let r=this.#e;!r||e&&r.imageId!==e||(this.#e=void 0,r.cancel())}dispose(){this.invalidate(),this.#o&&URL.revokeObjectURL(this.#o),this.#o=null}#W(){if(typeof Worker!="function"||typeof OffscreenCanvas!="function"||typeof createImageBitmap!="function"||typeof URL.createObjectURL!="function")return null;try{return URL.createObjectURL(new Blob([`(${xt.toString()})();`],{type:"text/javascript"}))}catch{return null}}#V(e,r,n){let t=this.#o;if(!t)return Promise.reject(new Error("Worker preprocessing is unavailable"));let i=this.#w++;return new Promise((s,u)=>{let a=!1,h,d=0,c=l=>{a||(a=!0,window.clearTimeout(d),h.terminate(),"value"in l?s(l.value):u(l.error))};try{h=new Worker(t,{name:"code-codex-particle-image"})}catch(l){this.#i(),u(l);return}n(()=>c({error:new DOMException("Image preparation was cancelled","AbortError")})),h.addEventListener("message",l=>{let m=l.data&&typeof l.data=="object"?l.data:{};if(Number(m.jobId)===i){if(m.type==="prepared"){let f=m.prepared;this.#t(f,e.id,r)?c({value:f}):c({error:new Error("The prepared particle image is invalid")});return}c({error:new Error(typeof m.message=="string"?m.message:"Image preparation failed")})}}),h.addEventListener("error",l=>{l.preventDefault(),this.#i(),c({error:new Error(l.message||"Image preparation worker failed")})},{once:!0}),h.addEventListener("messageerror",()=>{this.#i(),c({error:new Error("Image preparation worker returned unreadable data")})},{once:!0}),d=window.setTimeout(()=>{this.#i(),c({error:new DOMException("Image preparation timed out","TimeoutError")})},we),h.postMessage({jobId:i,imageId:e.id,source:e.blob,targetCount:r})})}#i(){this.#o&&URL.revokeObjectURL(this.#o),this.#o=null}#t(e,r,n){if(!e||typeof e!="object")return!1;let t=e;return t.imageId===r&&t.targetCount===n&&Number.isInteger(t.width)&&Number(t.width)>0&&Number.isInteger(t.height)&&Number(t.height)>0&&Number(t.naturalWidth)>0&&Number(t.naturalHeight)>0&&t.processedBlob instanceof Blob&&t.normalizedHomes instanceof Float32Array&&t.normalizedHomes.length===n*2&&t.colors instanceof Uint8Array&&t.colors.length===n*4&&t.seeds instanceof Float32Array&&t.seeds.length===n}},wt=`
260
+ (()=>{var me=class{constructor(e){this.report=e;this.signal=this.#n.signal}#r=!1;#e=new Set;signal;#n=new AbortController;get disposed(){return this.#r}own(e){let n=!0,t=()=>{n&&(n=!1,this.#e.delete(t),e())};return this.#r?t():this.#e.add(t),t}listen(e,n,t,r){return this.#r?()=>{}:(e.addEventListener(n,t,r),this.own(()=>e.removeEventListener(n,t,r)))}dispose(){if(!this.#r){this.#r=!0,this.#n.abort();for(let e of[...this.#e].reverse())try{e()}catch(n){try{this.report(n)}catch{}}}}};function Ue(i){let e=0,n=0,t=0,r=(o,a)=>{if(++n>8192||a>10)throw Error("BG_ASSET_SHAPE: Visual asset structure exceeds its budget.");if(ArrayBuffer.isView(o)){if((o instanceof Float32Array||o instanceof Float64Array)&&!o.every(Number.isFinite))throw Error("BG_ASSET_NUMBER: Prepared visual numbers must be finite.");if(e+=o.byteLength,e>32*1024*1024)throw Error("BG_ASSET_SIZE: Prepared visual assets exceed 32 MiB.");return o}if(Array.isArray(o))return o.map(s=>r(s,a+1));if(o&&typeof o=="object"&&[Object.prototype,null].includes(Object.getPrototypeOf(o))){let s={};for(let[h,u]of Object.entries(o)){if(ie({[h]:null}),t+=new TextEncoder().encode(h).length+4,t>65536)throw Error("BG_ASSET_METADATA: Visual asset metadata exceeds 64 KiB.");s[h]=r(u,a+1)}return s}let c=ie(o);if(t+=new TextEncoder().encode(JSON.stringify(c)).length,t>65536)throw Error("BG_ASSET_METADATA: Visual asset metadata exceeds 64 KiB.");return c};return r(i,0)}function ie(i){let e=0,n=(r,o)=>{if(++e>4096||o>8)throw Error("BG_STATE_LIMIT: Visual state exceeds the bounded schema.");if(r===null||typeof r=="boolean")return r;if(typeof r=="number"){if(!Number.isFinite(r))throw Error("BG_STATE_NUMBER: Visual numbers must be finite.");return r}if(typeof r=="string"){if(r.length>1024)throw Error("BG_STATE_STRING: Visual strings must be bounded.");return r}if(Array.isArray(r))return r.map(a=>n(a,o+1));if(r&&typeof r=="object"&&[Object.prototype,null].includes(Object.getPrototypeOf(r))){let a={};for(let[c,s]of Object.entries(r)){if(/^(?:__proto__|constructor|prototype|token|accessToken|refreshToken|authorization|cookie|bridge|conversation|history|source|url|path)$/i.test(c))throw Error("BG_STATE_FIELD: Visual state contains an unsupported field.");s!==void 0&&(a[c]=n(s,o+1))}return a}throw Error("BG_STATE_TYPE: Visual state must contain serializable visual values.")},t=n(i,0);if(new TextEncoder().encode(JSON.stringify(t)).length>65536)throw Error("BG_STATE_SIZE: Visual state exceeds the message budget.");return t}function Ee(i,e){if(![i.width,i.height,i.left,i.top,e].every(Number.isFinite)||i.width<0||i.height<0)throw Error("BG_VIEWPORT_INVALID: Invalid visual dimensions.");let n=Math.max(1,Math.min(8192,i.width)),t=Math.max(1,Math.min(8192,i.height)),r=Math.min(3,Math.max(.5,e),Math.sqrt(16777216/(n*t)));return{width:n,height:t,left:i.left,top:i.top,dpr:r}}var at=/(token|cookie|password|secret|credential|authorization|apikey)/i,st=/^(content|text|body|prompt|messages|title|filename|name|raw|data|database64|commandline|sessionid|accountid|threadid|projectid)$|(?:path|url|uri)$/i;function ee(i){return i.slice(0,8e3).replace(/\b[A-Za-z][A-Za-z0-9+.-]*:\/\/[^\s"'<>]+/g,n=>{try{let t=new URL(n);if(["127.0.0.1","localhost","[::1]"].includes(t.hostname)&&!t.username&&!t.password&&["/json/version","/json/list","/"].includes(t.pathname))return`${t.origin}${t.pathname}`}catch{}return"[url]"}).replace(/(?:\b[A-Za-z]:[\\/]|\\\\|\/(?:Users|home|tmp|var|etc|opt|mnt)\/|~\/)[^\r\n"'<>]*/g,"[path]").replace(/\b(?:Bearer\s+\S+|(?:authorization|password|secret|(?:access[_-]?|refresh[_-]?)?token|api[_-]?key|cookie)\s*[:=]\s*[^,;\r\n]+)/gi,"[credential]").replace(/\bsk-[A-Za-z0-9_-]{8,}|\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g,"[credential]").replace(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,"[email]").slice(0,4e3)+(i.length>8e3?" [truncated]":"")}function Ne(i){let e=256,n=new WeakSet,t=(r,o)=>{if(--e<0||o>6)return"[truncated]";if(typeof r=="string")return ee(r);if(r===null||typeof r=="boolean"||typeof r=="number")return r;if(typeof r!="object")return"[unsupported]";if(n.has(r))return"[circular]";if(n.add(r),r instanceof Error)return{name:ee(r.name),message:ee(r.message)};if(Array.isArray(r))return r.slice(0,128).map(c=>t(c,o+1));let a=Object.create(null);for(let[c,s]of Object.entries(r).slice(0,128)){let h=c.replace(/[^a-z0-9]/gi,"");a[ee(c).slice(0,160)]=at.test(h)||st.test(h)?"[redacted]":t(s,o+1)}return a};try{return t(i,0)}catch{return{redactionFailed:!0}}}var lt=Symbol.for("code-codex:runtime-events:v1"),ct=window,fe=ct[lt]??={events:[],dropped:0};function Y(i,e,n,t={}){let r={source:ee(i).slice(0,160),action:ee(e).slice(0,160),outcome:ee(n).slice(0,160),details:{...Ne(t),observedAt:Date.now(),documentElapsedMs:Math.round(performance.now())}},o=new TextEncoder().encode(JSON.stringify(r)).length;o>7e3&&(r.details={truncated:!0,originalBytes:o,observedAt:Date.now(),documentElapsedMs:Math.round(performance.now())}),fe.events.push(r),fe.events.length>1e3&&(fe.events.splice(0,200),fe.dropped+=200)}var ut=Symbol.for("code-codex:background-startup-hold:v1");function pe(){let i=window;return i[ut]??={active:!1,layers:new Set,next:-1,pending:new Map,painted:new WeakSet,openings:new WeakMap}}function ze(i){return i.closest("[data-code-codex-particle-layer]")}function ge(i){return!!ze(i)&&pe().active}function dt(i,e){e.native=requestAnimationFrame(n=>{let t=pe();e.native=void 0,t.pending.has(i)&&(t.active&&t.painted.has(e.layer)||(t.pending.delete(i),t.active&&(t.painted.add(e.layer),t.layers.add(e.layer),Y("background-opening","initial frame","prepared")),e.callback(n)))})}function Re(i,e){let n=ze(i);if(!n)return requestAnimationFrame(e);let t=pe(),r=t.next--,o={layer:n,callback:e};return t.pending.set(r,o),dt(r,o),r}function oe(i){if(i>=0){cancelAnimationFrame(i);return}let e=pe(),n=e.pending.get(i);n?.native!==void 0&&cancelAnimationFrame(n.native),e.pending.delete(i)}var Te=()=>{let i=window;return i[Symbol.for("code-codex:background-isolation:v1")]??=new Map},ye=class{constructor(e,n,t,r,o,a=()=>{},c={}){this.host=t;this.onError=a;if(typeof Worker!="function"||typeof r.transferControlToOffscreen!="function")throw Error("BG_BACKEND_UNAVAILABLE: Independent background rendering is unavailable.");let s=ie(o),h=Ee(t.getBoundingClientRect(),devicePixelRatio||1);this.#i={id:e,mode:"worker",phase:"preparing",frames:0,pending:0},Te().set(this,this.#i),this.#n=new me(m=>Y("background","resource release","failed",{id:e,error:String(m)})),this.ready=this.firstFrame=new Promise((m,g)=>{this.#r=m,this.#e=g}),this.ready.catch(()=>{}),this.#E=h;let u=URL.createObjectURL(new Blob([n],{type:"text/javascript"}));this.#n.own(()=>URL.revokeObjectURL(u));try{this.#R=new Worker(u,{name:"code-codex-background-"+e})}catch(m){throw this.#n.dispose(),Te().delete(this),m}let d=this.#R,l=setTimeout(()=>this.#h("BG_FIRST_FRAME_TIMEOUT: The background did not produce a first frame within 15 seconds."),15e3);this.#n.own(()=>clearTimeout(l)),this.#n.listen(r,"webglcontextlost",m=>{m.preventDefault(),this.#h("BG_WORKER_CONTEXT_LOST: The transferred background graphics context was lost. Enable the background again to retry.")}),this.#n.listen(d,"error",m=>this.#h("BG_WORKER_ERROR: "+m.message)),this.#n.listen(d,"messageerror",()=>this.#h("BG_WORKER_PROTOCOL: The background response could not be decoded.")),this.#n.listen(d,"message",m=>{let g=m.data;if(!(this.#b||g?.v!==1||g.session!==this.#w)){if(g.type==="failed"){this.#h("BG_WORKER_RENDER_FAILED: "+String(g.message).slice(0,1500));return}if(g.type==="first-frame"&&!this.#u&&(this.#u=!0,this.#i.frames=g.frames??1,clearTimeout(l),this.#i.phase="running",this.#r(),this.#m(),Y("background","isolated first frame","ready",{id:e,backend:"worker"})),g.type==="sample"&&Number.isSafeInteger(g.frames)&&(this.#i.frames=g.frames),g.type==="event"&&typeof g.event=="string"&&this.kernelEvent(g.event,g.value),g.type==="result"&&Number.isSafeInteger(g.callId)){let y=this.#v.get(g.callId);y&&(clearTimeout(y.timer),this.#v.delete(g.callId),g.error?y.reject(Error("BG_KERNEL_FAILED: "+String(g.error))):y.resolve(g.value))}g.type==="ack"&&g.seq===this.#t&&(clearTimeout(this.#x),this.#x=void 0,this.#t=0,this.#i.pending=0,this.#f())}});let f=new ResizeObserver(()=>{let m=Ee(this.host.getBoundingClientRect(),devicePixelRatio||1);JSON.stringify(m)!==JSON.stringify(this.#E)&&(this.#E=m,this.#d({viewport:m}))});f.observe(t),this.#n.own(()=>f.disconnect());let p=new IntersectionObserver(m=>{this.#D=m[0]?.isIntersecting??!0,this.#m()});p.observe(t),this.#n.own(()=>p.disconnect());let v=matchMedia("(prefers-reduced-motion: reduce)");this.#n.listen(v,"change",()=>this.#d({reduced:v.matches})),this.#n.listen(document,"visibilitychange",()=>this.#m()),this.#n.listen(window,"code-codex:background-hold-changed",()=>this.#m()),this.#n.listen(window,"pagehide",()=>this.dispose());let w=m=>{if(!this.#u||this.#b||c.interactive===!1||!["pointerup","pointercancel"].includes(m.type)&&m.composedPath().some(T=>T instanceof Element&&T.matches('button,a,input,textarea,select,[contenteditable],dialog,[role="menu"],[role="menubar"],[popover]')))return;let g=m,y=this.#E;if(m instanceof PointerEvent&&!["pointermove","pointerleave","pointerup","pointercancel"].includes(m.type)&&(g.clientX<y.left||g.clientX>y.left+y.width||g.clientY<y.top||g.clientY>y.top+y.height))return;let R={type:m.type};if(m instanceof PointerEvent)Object.assign(R,{clientX:g.clientX,clientY:g.clientY,pointerId:g.pointerId,button:g.button,buttons:g.buttons,isPrimary:g.isPrimary,pointerType:g.pointerType});else if(m instanceof WheelEvent){let T=this.#o.find(E=>E.type==="state"&&E.input?.type==="wheel");if(T){let E=T.input;E.deltaX=Math.max(-1e4,Math.min(1e4,E.deltaX+m.deltaX)),E.deltaY=Math.max(-1e4,Math.min(1e4,E.deltaY+m.deltaY));return}Object.assign(R,{deltaX:m.deltaX,deltaY:m.deltaY,deltaMode:m.deltaMode,clientX:m.clientX,clientY:m.clientY})}else m instanceof KeyboardEvent&&Object.assign(R,{repeat:m.repeat,isComposing:m.isComposing,altKey:m.altKey,ctrlKey:m.ctrlKey,metaKey:m.metaKey,shiftKey:m.shiftKey,key:"",code:""});m.type==="pointermove"?((g.clientX<y.left||g.clientX>y.left+y.width||g.clientY<y.top||g.clientY>y.top+y.height)&&(R.type="pointerleave"),this.#d({input:R})):this.#o.length<8?(this.#o.push({type:"state",input:R}),this.#f()):this.#h("BG_INPUT_QUEUE_FULL: Background input exceeded the bounded discrete-event queue.")};for(let m of["pointermove","pointerleave","pointerdown","pointerup","pointercancel","wheel","keydown"])this.#n.listen(window,m,w,{passive:!0});try{let m=r.transferControlToOffscreen();d.postMessage({v:1,session:this.#w,type:"init",canvas:m,settings:s,viewport:this.#E,reduced:v.matches,held:ge(t)},[m])}catch(m){this.#h("BG_CANVAS_TRANSFER: "+String(m))}}ready;firstFrame;#r;#e;#n;#R;#w=crypto.randomUUID();#c=0;#t=0;#a;#o=[];#v=new Map;#k=0;#u=!1;#b=!1;#D=!0;#E;#x;#i;get diagnostics(){return{...this.#i}}setSettings(e){this.#d({settings:ie(e)})}updateSettings(e){this.setSettings(e)}replay(){if(!this.#b){if(this.#o.length>=8)throw Error("BG_COMMAND_QUEUE_FULL: Wait for the pending visual command.");this.#o.push({type:"replay"}),this.#f()}}kernelEvent(e,n){}activityChanged(e){}call(e,n=[],t=3e4){if(this.#b)return Promise.reject(Error("BG_KERNEL_DISPOSED: The visual worker has been retired."));if(this.#v.size>=8||this.#o.length>=8)return Promise.reject(Error("BG_COMMAND_QUEUE_FULL: Wait for the pending visual command."));let r=Ue(n),o=++this.#k,a=new Promise((c,s)=>{let h=setTimeout(()=>{this.#v.delete(o),s(Error("BG_KERNEL_TIMEOUT: The visual command did not confirm completion. It was not replayed."))},t);this.#v.set(o,{resolve:c,reject:s,timer:h})});return this.#o.push({type:"call",method:e,args:r,callId:o}),this.#f(),a}resumeOpening(){this.replay()}#m=()=>{let e=!document.hidden&&this.#D&&(!this.#u||!ge(this.host));this.#d({visible:e}),this.activityChanged(e)};#d(e){this.#b||(this.#a={...this.#a,...e},this.#f())}#f(){if(this.#b||this.#t)return;let e;if(this.#a&&["settings","viewport","visible","reduced"].some(n=>n in this.#a)){let{input:n,...t}=this.#a;e={type:"state",...t},this.#a=n?{input:n}:void 0}else if(this.#o.length)e=this.#o.shift();else if(this.#a)e={type:"state",...this.#a},this.#a=void 0;else return;this.#t=++this.#c,this.#i.pending=1;try{this.#R.postMessage({v:1,session:this.#w,seq:this.#t,...e})}catch(n){this.#h("BG_WORKER_SEND_FAILED: "+String(n));return}this.#x=setTimeout(()=>this.#h("BG_WORKER_ACK_TIMEOUT: The visual worker stopped acknowledging bounded updates."),5e3)}#h(e){if(!this.#b){this.#i.phase="failed",this.#i.error=e,this.#e(Error(e)),Y("background","visual worker","failed",{id:this.#i.id,session:this.#w,sequence:this.#c,pending:this.#t,message:e});try{this.onError(e)}finally{this.dispose()}}}dispose(){if(this.#b)return;this.#b=!0,this.#n.dispose(),clearTimeout(this.#x),this.#a=void 0,this.#o=[],this.#u||this.#e(new DOMException("Background preparation was cancelled.","AbortError"));for(let c of this.#v.values())clearTimeout(c.timer),c.reject(new DOMException("Background command was cancelled.","AbortError"));this.#v.clear();let e=this.#R,n=this.#w,t=++this.#c;this.#i.phase="disposing";let r=!1,o=()=>{r||(r=!0,clearTimeout(a),e.terminate(),Te().delete(this))},a=setTimeout(()=>{Y("background","worker disposal","unconfirmed",{id:this.#i.id,timeoutMs:1500}),o()},1500);e.addEventListener("message",c=>{c.data?.session===n&&c.data?.type==="disposed"&&o()});try{e.postMessage({v:1,session:n,seq:t,type:"dispose"})}catch{o()}}};var be=class extends ye{constructor(n,t,r,o,a,c=()=>{}){super("particle-image",n,t.parentElement??t,t,o,s=>{s&&r(s)});this.transition=a;this.opening=c;this.#n=o,this.#e=o.introEnabled&&!matchMedia("(prefers-reduced-motion: reduce)").matches?0:1}#r=0;#e=1;#n;get count(){return this.#r}get openingProgress(){return this.#e}get openingRemainingSeconds(){return Math.max(0,(1-this.#e)*this.#n.introDuration)}setRenderSettings(n){let t=this.#n;this.#n=n,!n.introEnabled||matchMedia("(prefers-reduced-motion: reduce)").matches?this.#e=1:t.introEnabled||(this.#e=0),this.setSettings(n)}setPreparedImage(n,t){return this.#r=n.targetCount,this.call("setPreparedImage",[{width:n.width,height:n.height,targetCount:n.targetCount,normalizedHomes:n.normalizedHomes,colors:n.colors,seeds:n.seeds},t])}renderPreparedFrame(){return this.count>0}replayOpening(){this.#e=this.#n.introEnabled&&!matchMedia("(prefers-reduced-motion: reduce)").matches?0:1,this.replay()}setImageTransform(n){this.call("setImageTransform",[n]).catch(t=>this.report(t))}setPaused(n){this.call("setPaused",[n]).catch(t=>this.report(t))}resize=()=>{this.call("resize").catch(n=>this.report(n))};kernelEvent(n,t){n==="particle-transition"&&this.transition(t.progress,t.complete),n==="particle-opening"&&(this.#e=this.#n.introEnabled&&!matchMedia("(prefers-reduced-motion: reduce)").matches?t.progress:1,this.opening(this.#e))}report(n){n instanceof DOMException&&n.name==="AbortError"||console.error("BG_PARTICLE_COMMAND_FAILED",n)}};var ur=Object.freeze({distance:24,elevation:-5.5,azimuth:0,orbitSpeed:0,roll:-20,fov:42,diskInner:3,diskOuter:15,diskThickness:.26,diskDensity:1,brightness:1,spinSpeed:.06,grain:.48,doppler:.35,hotColor:"#FFF3DE",midColor:"#FF9838",coolColor:"#8E3A0B",starBrightness:0,glow:1,exposure:.9,vignette:.28,steps:200,resolution:.4,maxDpr:1,paused:!1}),dr=Object.freeze({variant:"bottom",inertialWheel:!0,openingDuration:2,wheelSensitivity:1,wheelDownIntensity:.4,wheelUpIntensity:.8,wheelTravelScale:1,wheelDownDistance:100,wheelUpDistance:20,wheelUpTrailDistance:18,wheelUpTrailStrength:1.15,wheelUpStiffness:180,wheelUpDamping:48,wheelReleaseDelay:70,wheelUpReleaseDelay:80,maxReleaseVelocity:2.4,returnStiffness:180,returnDamping:14,initialStretch:1.8,initialBlur:0,rimColor:"#FFFFFF",violetColor:"#A558FB",blueColor:"#4922E5",shadowColor:"#000000"}),hr=Object.freeze({low:Object.freeze({steps:56,resolutionScale:.56,maxDpr:1}),medium:Object.freeze({steps:76,resolutionScale:.72,maxDpr:1.25}),high:Object.freeze({steps:100,resolutionScale:.86,maxDpr:1.5})}),mr=Object.freeze({quality:"high",speed:.72,intensity:1.15,turbulence:1,radius:3,colorShift:0,pointerInfluence:.45,introDuration:2.2,introFeather:.22,paused:!1}),fr=Object.freeze({low:Object.freeze({steps:32,rayScale:.72,maxDpr:1.1,minAdaptiveScale:.92,noiseAtlasSize:512}),medium:Object.freeze({steps:50,rayScale:.76,maxDpr:1.25,minAdaptiveScale:.9,noiseAtlasSize:768}),high:Object.freeze({steps:72,rayScale:.82,maxDpr:1.4,minAdaptiveScale:.9,noiseAtlasSize:1024})}),pr=Object.freeze({hue:0,saturation:1,quality:"medium",speed:1,intensity:1,curtainScale:.5,turbulence:.58,glow:.72,starDensity:.56,introDuration:2.4,introFeather:.16,introStart:-.22,introEnd:1.32,introSkyEnd:.48,introStarStart:.34,paused:!1});function re(i,e,n,t){let r=typeof i=="number"?i:Number(i);return Number.isFinite(r)?Math.min(n,Math.max(e,r)):t}var gr=Object.freeze({top:{axis:"y",enter:-100,rest:-50},bottom:{axis:"y",enter:100,rest:50},left:{axis:"x",enter:100,rest:50},right:{axis:"x",enter:-100,rest:-50}});var vr=Object.freeze({quality:"medium",speed:.35,amplitude:1,frequency:1,zoom:1,rotation:0,exposure:1,timeOffset:5.07,introDuration:2.8,introFeather:.18,introAngle:32,introZoom:.16,introEnabled:!0,paused:!1,colors:Object.freeze(["#d81159","#8f2d56","#218380","#fbb13c","#73d2de"])});var yr=Object.freeze([.72,.46]),br=Math.PI/180;var ht="code-codex:particle-image-background:v1",mt="code-codex-particle-image-background",ft=1,we="images",pt=900,Pe=3e4,ae=4096,ne=40,Ye=1,je=.12,Ke=Ye+je,xe=Ke/ne,Se=1/64,De=.18,gt=.1,Ie=40,vt=400,yt=3.2/5.2,bt=1.4/5.2,$e=.6,se=.08,le=4.7438645,xt=.0015,St=.005,wt=.05,Et=.2,te=Object.freeze({x1:.42,y1:0,x2:.58,y2:1,nodes:Object.freeze([])}),Rt=32,Z=1e-4,D=Object.freeze({particleCount:56e4,particleSize:1.8,particleOpacity:.96,speed:.7,noiseScale:1e-4,noiseStrength:.005,damping:.9919,ambientCycle:80,selectedImageIds:Object.freeze([]),activeImageId:null,autoSwitch:!0,imageDurationSeconds:2,morphIntervalSeconds:2.5,morphCurve:te,imageOpacity:1,showSourceImage:!0,backgroundColor:"#000000",cursorStrength:Ie,cursorInteraction:!0,dprCap:1.5,introEnabled:!0,introDuration:4,introSpread:1}),ce=Object.freeze({positionX:50,positionY:50,zoom:1});function Ge(i){let e=Math.min(Math.max(i,0),Ie),n=e*6.25,t=Math.max(e/.64,0),r=Math.max(t/15.625,1),o=Math.max(t/31.25,1),a=Math.max(i/Ie,1),c=Math.pow(Math.max(t,1),.45)*Math.pow(r,.28)*Math.pow(o,.32)*Math.pow(a,.45),s=Math.pow(Math.max(t,1),.35)*Math.pow(r,.18)*Math.pow(o,.22)*Math.pow(a,.35),h=4*(t<1?t:Math.pow(Math.max(t,1),.55))*Math.pow(r,.3)*Math.pow(o,.34)*a,u=Math.pow(Math.max(t,1),.12)*Math.pow(r,.16)*Math.pow(o,.2);return{baseStrength:e,cursorScale:n,strengthRatio:t,extendedStrength:r,extremeStrength:o,overdrive:a,highStrengthScale:c,stepStrengthScale:s,strength:h,wakeLengthScale:u,squareRootStrength:Math.sqrt(Math.max(h,0))}}function J(i,e=0){return re(i,0,1,e)}function Ze(i){let e=Array.isArray(i)?{nodes:i}:i&&typeof i=="object"?i:te,n=J(e.x1,te.x1),t=J(e.y1,te.y1),r=J(e.x2,te.x2),o=J(e.y2,te.y2);n>r&&([n,r]=[r,n]),t>o&&([t,o]=[o,t]);let a=[],c=Array.isArray(e.nodes)?e.nodes:[];for(let d of c){let l,f;if(Array.isArray(d))l=d[0],f=d[1];else if(d&&typeof d=="object"){let w=d;l=w.time??w.x,f=w.progress??w.y}else continue;let p=Number(l),v=Number(f);!Number.isFinite(p)||!Number.isFinite(v)||a.push({time:J(p),progress:J(v)})}a.sort((d,l)=>d.time-l.time||d.progress-l.progress);let s=[],h=0,u=0;for(let d of a)if(!(d.time<=Z||d.time>=1-Z||d.progress<=Z||d.progress>=1-Z||d.time<=h+Z||d.progress<=u+Z)&&(s.push(d),h=d.time,u=d.progress,s.length>=Rt))break;return{x1:n,y1:t,x2:r,y2:o,nodes:s}}function Tt(i){return{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,nodes:i.nodes.map(e=>({time:e.time,progress:e.progress}))}}function Ae(i,e,n){let t=1-i;return 3*t*t*i*e+3*t*i*i*n+i*i*i}function _e(i,e,n){let t=1-i;return 3*t*t*e+6*t*i*(n-e)+3*i*i*(1-n)}function He(i,e,n,t){if(!(n>0))return 0;let r=((2*i+e)*n-i*t)/Math.max(i+e,Z);return!Number.isFinite(r)||r<=0||n*t<=0?0:Math.min(r,3*n)}var Ve=new WeakMap;function At(i){let e=Ve.get(i);if(e)return e;let n=[{time:0,progress:0},...i.nodes,{time:1,progress:1}],t=[],r=[];for(let c=0;c<n.length-1;c+=1){let s=n[c],h=n[c+1];if(!s||!h)continue;let u=Math.max(h.time-s.time,Z);t.push(u),r.push(Math.max(0,h.progress-s.progress)/u)}let o=new Array(n.length).fill(0);if(r.length===1)o[0]=r[0]??0,o[1]=r[0]??0;else if(r.length>1){let c=r[0]??0,s=r[1]??c,h=i.x1>Z?i.y1/i.x1:Number.NaN,u=1-i.x2,d=u>Z?(1-i.y2)/u:Number.NaN;o[0]=Number.isFinite(h)?Math.min(Math.max(0,h),3*c):He(t[0]??1,t[1]??1,c,s);for(let w=1;w<n.length-1;w+=1){let m=r[w-1]??0,g=r[w]??0;if(m<=0||g<=0){o[w]=0;continue}let y=t[w-1]??1,R=t[w]??1,T=2*R+y,E=R+2*y;o[w]=(T+E)/(T/m+E/g)}let l=r.length-1,f=n.length-1,p=r[l]??0,v=r[l-1]??p;o[f]=Number.isFinite(d)?Math.min(Math.max(0,d),3*p):He(t[l]??1,t[l-1]??1,p,v)}let a={anchors:n,spans:t,slopes:o};return Ve.set(i,a),a}function _t(i,e=te){let n=J(i);if(n<=0)return{value:0,slope:0,parameter:0};if(n>=1)return{value:1,slope:0,parameter:1};if(e.nodes.length){let{anchors:u,spans:d,slopes:l}=At(e),f=0;for(;f<d.length-1&&n>(u[f+1]?.time??1);)f+=1;let p=u[f]??u[0]??{time:0,progress:0},v=u[f+1]??u.at(-1)??{time:1,progress:1},w=d[f]??1,m=Math.min(1,Math.max(0,(n-p.time)/w)),g=m*m,y=g*m,R=2*y-3*g+1,T=y-2*g+m,E=-2*y+3*g,U=y-g,k=l[f]??0,H=l[f+1]??0,I=Math.min(v.progress,Math.max(p.progress,R*p.progress+T*w*k+E*v.progress+U*w*H)),C=(6*g-6*m)*p.progress/w+(3*g-4*m+1)*k+(-6*g+6*m)*v.progress/w+(3*g-2*m)*H;return{value:J(I),slope:Math.min(8,Math.max(0,Number.isFinite(C)?C:0)),parameter:m}}let t=n;for(let u=0;u<5;u+=1){let d=Ae(t,e.x1,e.x2)-n,l=_e(t,e.x1,e.x2);if(Math.abs(d)<1e-5||Math.abs(l)<1e-5)break;t=Math.min(1,Math.max(0,t-d/l))}let r=0,o=1;for(let u=0;u<8;u+=1){let d=Ae(t,e.x1,e.x2);if(Math.abs(d-n)<1e-5)break;d<n?r=t:o=t,t=.5*(r+o)}let a=J(Ae(t,e.y1,e.y2)),c=_e(t,e.x1,e.x2),s=_e(t,e.y1,e.y2),h=c>1e-5?Math.min(8,Math.max(0,s/c)):0;return{value:a,slope:h,parameter:t}}function Be(i){return Math.round(re(i,1e4,2e6,D.particleCount)/1e4)*1e4}function j(i,e,n,t,r,o){let a=re(i,e,n,r),c=e+Math.round((a-e)/t)*t;return Number(Math.min(n,Math.max(e,c)).toFixed(o))}function de(i){let e=i&&typeof i=="object"?i:{};return{positionX:j(e.positionX,0,100,1,ce.positionX,0),positionY:j(e.positionY,0,100,1,ce.positionY,0),zoom:j(e.zoom,.25,4,.05,ce.zoom,2)}}function We(i,e){let n=de(e),t=`${n.positionX}% ${n.positionY}%`;i.style.setProperty("object-position",t,"important"),i.style.setProperty("transform-origin",t,"important"),i.style.setProperty("transform",`scale(${n.zoom})`,"important")}function Mt(i){return typeof i=="string"&&/^#[0-9a-f]{6}$/i.test(i)?i.toLocaleLowerCase():D.backgroundColor}function kt(i){let e=i&&typeof i=="object"?i:{},n=Array.isArray(e.selectedImageIds)?[...new Set(e.selectedImageIds.filter(t=>typeof t=="string"&&t.length<=128))]:[];return{particleCount:Be(e.particleCount),particleSize:j(e.particleSize,.5,4,.1,D.particleSize,1),particleOpacity:j(e.particleOpacity,.1,1,.01,D.particleOpacity,2),speed:j(e.speed,0,2,.05,D.speed,2),noiseScale:j(e.noiseScale,1e-4,.002,1e-4,D.noiseScale,4),noiseStrength:j(e.noiseStrength,0,.15,.005,D.noiseStrength,3),damping:j(e.damping,.8,.9999,1e-4,D.damping,4),ambientCycle:j(e.ambientCycle,40,500,10,D.ambientCycle,0),selectedImageIds:n,activeImageId:typeof e.activeImageId=="string"&&e.activeImageId.length<=128?e.activeImageId:null,autoSwitch:typeof e.autoSwitch=="boolean"?e.autoSwitch:D.autoSwitch,imageDurationSeconds:Math.round(re(e.imageDurationSeconds,1,60,D.imageDurationSeconds)),morphIntervalSeconds:Math.round(re(e.morphIntervalSeconds,1,12,D.morphIntervalSeconds)*10)/10,morphCurve:Ze(e.morphCurve),imageOpacity:Math.round(re(e.imageOpacity,0,1,D.imageOpacity)*100)/100,showSourceImage:typeof e.showSourceImage=="boolean"?e.showSourceImage:D.showSourceImage,backgroundColor:Mt(e.backgroundColor),cursorStrength:j(e.cursorStrength,0,vt,.01,D.cursorStrength,2),cursorInteraction:typeof e.cursorInteraction=="boolean"?e.cursorInteraction:D.cursorInteraction,dprCap:j(e.dprCap,1,2,.25,D.dprCap,2),introEnabled:typeof e.introEnabled=="boolean"?e.introEnabled:D.introEnabled,introDuration:j(e.introDuration,.5,12,.1,D.introDuration,1),introSpread:j(e.introSpread,.2,2,.05,D.introSpread,2)}}function Pt(){try{return kt(JSON.parse(localStorage.getItem(ht)||"{}"))}catch{return{...D}}}function Me(i){let e=Math.sin(i*91.317)*47453.5453;return e-Math.floor(e)}function ke(i){let e=i>>>0;return e^=e>>>16,e=Math.imul(e,2146121005),e^=e>>>15,e=Math.imul(e,2221713035),e^=e>>>16,e>>>0}function Dt(){let i=globalThis,e=t=>{let r=Math.sin(t*91.317)*47453.5453;return r-Math.floor(r)},n=t=>{let r=t>>>0;return r^=r>>>16,r=Math.imul(r,2146121005),r^=r>>>15,r=Math.imul(r,2221713035),r^=r>>>16,r>>>0};i.addEventListener("message",t=>{(async()=>{let r=t.data,o=Number(r.jobId),a=String(r.imageId||""),c=r.source,s=Number(r.targetCount),h;try{if(!(c instanceof Blob))throw new Error("The image source is invalid");if(typeof createImageBitmap!="function"||typeof OffscreenCanvas!="function")throw new Error("Background image preparation is unavailable");h=await createImageBitmap(c);let u=h.width,d=h.height;if(!u||!d||u>16384||d>16384)throw new Error("The image dimensions are unsupported");let f=Math.min(1,900/Math.max(u,d)),p=Math.max(1,Math.round(u*f)),v=Math.max(1,Math.round(d*f)),w=new OffscreenCanvas(p,v),m=w.getContext("2d",{willReadFrequently:!0});if(!m||typeof w.convertToBlob!="function")throw new Error("The image preparation canvas is unavailable");m.clearRect(0,0,p,v),m.drawImage(h,0,0,p,v);let g=m.getImageData(0,0,p,v),y=g.data,R=n(p^v<<16),T=0;for(let x=0;x<y.length;x+=4){let N=y[x]??0,q=y[x+1]??0,G=y[x+2]??0,A=y[x+3]??0,O=Math.round(N*.2126+q*.7152+G*.0722);y[x]=O,y[x+1]=O,y[x+2]=O;let S=x>>>2;(S&3)===0&&(R=n(R^O^A<<8^Math.imul(S+1,2654435761))),A>=24&&(T+=1)}if(!T)throw new Error("The image contains no visible pixels");m.putImageData(g,0,0);let E=await w.convertToBlob({type:"image/png"}),U=p*v,k=new Uint32Array(U),H=new Uint8Array(U),I=0;for(let x=0;x<v;x+=1){let N=x*p,q=Math.max(0,x-1)*p,G=Math.min(v-1,x+1)*p;for(let A=0;A<p;A+=1){let O=N+A,S=O*4,F=y[S+3]??0;if(F>=24){let L=y[(N+Math.max(0,A-1))*4]??0,X=y[(N+Math.min(p-1,A+1))*4]??0,B=y[(q+A)*4]??0,W=y[(G+A)*4]??0,Q=(y[S]??0)/255,he=Math.min(1,(Math.abs(X-L)+Math.abs(W-B))/510);I+=Math.round(F/255*(Math.pow(Q,.9)*144+he*112)),H[O]=Math.max(y[S]??0,Math.round(he*96))}k[O]=I}}if(!I)for(let x=0;x<U;x+=1)(y[x*4+3]??0)>=24&&(I+=1,H[x]=Math.max(y[x*4]??0,96)),k[x]=I;if(!I)throw new Error("The image contains no visible pixels");let C=4096,V=new Uint32Array(C+1),K=0,b=k.length-1;for(let x=0;x<=C;x+=1){let N=I*x/C;for(;K<b&&(k[K]??0)<=N;)K+=1;V[x]=K}let _=Math.min(2e6,Math.max(1e4,Math.round(s/1e4)*1e4)),P=new Float32Array(_*2),z=new Uint8Array(_*4),M=new Float32Array(_);for(let x=0;x<_;x+=1){let N=(n(x^R)+.5)/4294967296,q=N*I,G=Math.min(C-1,Math.floor(N*C)),A=V[G]??0,O=V[G+1]??A;for(;A<O;){let Q=A+O>>>1;(k[Q]??0)<=q?A=Q+1:O=Q}let S=A,F=S%p,L=Math.floor(S/p),X=x*2,B=x*4;P[X]=Math.max(0,Math.min(1,(F+.5+(e(x+.17)-.5)*.82)/p)),P[X+1]=Math.max(0,Math.min(1,(L+.5+(e(x+7.31)-.5)*.82)/v));let W=H[S]??0;z[B]=W,z[B+1]=W,z[B+2]=W,z[B+3]=y[S*4+3]??0,M[x]=e(x+19.73)}i.postMessage({type:"prepared",jobId:o,prepared:{imageId:a,targetCount:_,width:p,height:v,naturalWidth:u,naturalHeight:d,processedBlob:E,normalizedHomes:P,colors:z,seeds:M}},[P.buffer,z.buffer,M.buffer])}catch(u){i.postMessage({type:"error",jobId:o,message:u instanceof Error?u.message:String(u)},[])}finally{h?.close()}})()})}async function It(i,e,n,t){let r=()=>{if(t.aborted)throw new DOMException("Image preparation was cancelled","AbortError")},o=async()=>{await new Promise(c=>window.setTimeout(c,0)),r()};r();let a=await createImageBitmap(e);try{r();let c=a.width,s=a.height;if(!c||!s||c>16384||s>16384)throw new Error("The image dimensions are unsupported");let h=Math.min(1,pt/Math.max(c,s)),u=Math.max(1,Math.round(c*h)),d=Math.max(1,Math.round(s*h)),l=document.createElement("canvas");l.width=u,l.height=d;let f=l.getContext("2d",{willReadFrequently:!0});if(!f)throw new Error("The image preparation canvas is unavailable");f.drawImage(a,0,0,u,d);let p=f.getImageData(0,0,u,d),v=p.data,w=ke(u^d<<16),m=0;for(let b=0;b<v.length;b+=4){let _=v[b+3]??0,P=Math.round((v[b]??0)*.2126+(v[b+1]??0)*.7152+(v[b+2]??0)*.0722);v[b]=P,v[b+1]=P,v[b+2]=P;let z=b>>>2;(z&3)===0&&(w=ke(w^P^_<<8^Math.imul(z+1,2654435761))),_>=24&&(m+=1),(b&524287)===524284&&await o()}if(!m)throw new Error("The image contains no visible pixels");f.putImageData(p,0,0);let g=await new Promise((b,_)=>{l.toBlob(P=>P?b(P):_(new Error("The processed image could not be created")),"image/png")});r();let y=u*d,R=new Uint32Array(y),T=new Uint8Array(y),E=0;for(let b=0;b<d;b+=1){let _=b*u,P=Math.max(0,b-1)*u,z=Math.min(d-1,b+1)*u;for(let M=0;M<u;M+=1){let x=_+M,N=x*4,q=v[N+3]??0;if(q>=24){let G=Math.min(1,(Math.abs((v[(_+Math.min(u-1,M+1))*4]??0)-(v[(_+Math.max(0,M-1))*4]??0))+Math.abs((v[(z+M)*4]??0)-(v[(P+M)*4]??0)))/510),A=(v[N]??0)/255;E+=Math.round(q/255*(Math.pow(A,.9)*144+G*112)),T[x]=Math.max(v[N]??0,Math.round(G*96))}R[x]=E}(b&63)===63&&await o()}if(!E)for(let b=0;b<y;b+=1)(v[b*4+3]??0)>=24&&(E+=1,T[b]=Math.max(v[b*4]??0,96)),R[b]=E,(b&131071)===131071&&await o();if(!E)throw new Error("The image contains no visible pixels");let U=new Uint32Array(ae+1),k=0,H=R.length-1;for(let b=0;b<=ae;b+=1){let _=E*b/ae;for(;k<H&&(R[k]??0)<=_;)k+=1;U[b]=k}let I=Be(n),C=new Float32Array(I*2),V=new Uint8Array(I*4),K=new Float32Array(I);for(let b=0;b<I;b+=1){let _=(ke(b^w)+.5)/4294967296,P=_*E,z=Math.min(ae-1,Math.floor(_*ae)),M=U[z]??0,x=U[z+1]??M;for(;M<x;){let S=M+x>>>1;(R[S]??0)<=P?M=S+1:x=S}let N=M%u,q=Math.floor(M/u),G=b*2,A=b*4;C[G]=Math.max(0,Math.min(1,(N+.5+(Me(b+.17)-.5)*.82)/u)),C[G+1]=Math.max(0,Math.min(1,(q+.5+(Me(b+7.31)-.5)*.82)/d));let O=T[M]??0;V[A]=O,V[A+1]=O,V[A+2]=O,V[A+3]=v[M*4+3]??0,K[b]=Me(b+19.73),(b&32767)===32767&&await o()}return r(),{imageId:i,targetCount:I,width:u,height:d,naturalWidth:c,naturalHeight:s,processedBlob:g,normalizedHomes:C,colors:V,seeds:K}}finally{a.close()}}var Ce=class{#r;#e;#n=1;constructor(){this.#r=this.#R()}prepare(e,n){let t=Be(n),r=[e.id,e.createdAt,e.size,e.type,t].join(":");if(this.#e?.key===r)return this.#e.promise;this.invalidate();let o=new AbortController,a=()=>{},s=(this.#r?this.#w(e,t,u=>{a=u}):Promise.reject(new Error("Worker preprocessing is unavailable"))).catch(u=>{if(u instanceof DOMException&&u.name==="AbortError")throw u;if(o.signal.aborted)throw new DOMException("Image preparation was cancelled","AbortError");return It(e.id,e.blob,t,o.signal)}),h={key:r,imageId:e.id,promise:s,cancel:()=>{o.abort(),a()}};return this.#e=h,s.catch(()=>{this.#e===h&&(this.#e=void 0)}),s}prewarm(e,n){this.prepare(e,n).catch(t=>{t instanceof DOMException&&t.name==="AbortError"||console.warn("Code-Codex could not pre-process the next particle image",t)})}invalidate(e){let n=this.#e;!n||e&&n.imageId!==e||(this.#e=void 0,n.cancel())}dispose(){this.invalidate(),this.#r&&URL.revokeObjectURL(this.#r),this.#r=null}#R(){if(typeof Worker!="function"||typeof OffscreenCanvas!="function"||typeof createImageBitmap!="function"||typeof URL.createObjectURL!="function")return null;try{return URL.createObjectURL(new Blob([`(${Dt.toString()})();`],{type:"text/javascript"}))}catch{return null}}#w(e,n,t){let r=this.#r;if(!r)return Promise.reject(new Error("Worker preprocessing is unavailable"));let o=this.#n++;return new Promise((a,c)=>{let s=!1,h,u=0,d=l=>{s||(s=!0,window.clearTimeout(u),h.terminate(),"value"in l?a(l.value):c(l.error))};try{h=new Worker(r,{name:"code-codex-particle-image"})}catch(l){this.#c(),c(l);return}t(()=>d({error:new DOMException("Image preparation was cancelled","AbortError")})),h.addEventListener("message",l=>{let f=l.data&&typeof l.data=="object"?l.data:{};if(Number(f.jobId)===o){if(f.type==="prepared"){let p=f.prepared;this.#t(p,e.id,n)?d({value:p}):d({error:new Error("The prepared particle image is invalid")});return}d({error:new Error(typeof f.message=="string"?f.message:"Image preparation failed")})}}),h.addEventListener("error",l=>{l.preventDefault(),this.#c(),d({error:new Error(l.message||"Image preparation worker failed")})},{once:!0}),h.addEventListener("messageerror",()=>{this.#c(),d({error:new Error("Image preparation worker returned unreadable data")})},{once:!0}),u=window.setTimeout(()=>{this.#c(),d({error:new DOMException("Image preparation timed out","TimeoutError")})},Pe),h.postMessage({jobId:o,imageId:e.id,source:e.blob,targetCount:n})})}#c(){this.#r&&URL.revokeObjectURL(this.#r),this.#r=null}#t(e,n,t){if(!e||typeof e!="object")return!1;let r=e;return r.imageId===n&&r.targetCount===t&&Number.isInteger(r.width)&&Number(r.width)>0&&Number.isInteger(r.height)&&Number(r.height)>0&&Number(r.naturalWidth)>0&&Number(r.naturalHeight)>0&&r.processedBlob instanceof Blob&&r.normalizedHomes instanceof Float32Array&&r.normalizedHomes.length===t*2&&r.colors instanceof Uint8Array&&r.colors.length===t*4&&r.seeds instanceof Float32Array&&r.seeds.length===t}},Ct=`
261
261
  precision highp float;
262
262
  attribute vec2 a_previousHome;
263
263
  attribute vec2 a_home;
@@ -273,6 +273,7 @@ Nothing in this notice limits rights granted directly by an applicable license,
273
273
  uniform float u_pointerCount;
274
274
  uniform float u_time;
275
275
  uniform float u_introProgress;
276
+ uniform float u_introReveal;
276
277
  uniform float u_introSpread;
277
278
  uniform float u_transitionElapsed;
278
279
  uniform float u_transitionNearResponse;
@@ -365,7 +366,7 @@ Nothing in this notice limits rights granted directly by an applicable license,
365
366
  float travelTime = abs(decayRate) > 0.00001
366
367
  ? (decay - 1.0) / decayRate
367
368
  : dt;
368
- float stepBudget = maximumStep * max(dt / ${me.toFixed(6)}, 0.25);
369
+ float stepBudget = maximumStep * max(dt / ${Se.toFixed(6)}, 0.25);
369
370
  position += softLimit(gasVelocity * travelTime, stepBudget);
370
371
  gasVelocity = softLimit(gasVelocity * decay, maximumVelocity);
371
372
  }
@@ -384,7 +385,7 @@ Nothing in this notice limits rights granted directly by an applicable license,
384
385
  float maximumStep,
385
386
  float influenceRadius
386
387
  ) {
387
- float dt = clamp(elapsed, 0.0, ${Ee.toFixed(2)});
388
+ float dt = clamp(elapsed, 0.0, ${De.toFixed(2)});
388
389
  if (dt <= 0.00001) return;
389
390
  vec2 cursorStep = cursorEnd - cursorStart;
390
391
  float cursorDistance = length(cursorStep);
@@ -499,7 +500,7 @@ Nothing in this notice limits rights granted directly by an applicable license,
499
500
 
500
501
  vec2 particleStep = 0.5 * (oldVelocity + nextVelocity) * dt;
501
502
  float stepBudget = maximumStep
502
- * max(dt / ${me.toFixed(6)}, 0.25);
503
+ * max(dt / ${Se.toFixed(6)}, 0.25);
503
504
  position += softLimit(particleStep, stepBudget);
504
505
  gasVelocity = nextVelocity;
505
506
  previousTangent = tangent;
@@ -514,15 +515,15 @@ Nothing in this notice limits rights granted directly by an applicable license,
514
515
  vec2 transitionDelta = targetHome - a_previousHome;
515
516
  float transitionDistance = length(transitionDelta);
516
517
  float transitionDistanceReference = max(
517
- length(u_resolution) * ${Ne.toFixed(2)},
518
+ length(u_resolution) * ${$e.toFixed(2)},
518
519
  80.0
519
520
  );
520
521
  float transitionDistanceFactor = smoother01(
521
522
  transitionDistance / transitionDistanceReference
522
523
  );
523
524
  float transitionVariation = mix(
524
- ${(1-ae).toFixed(2)},
525
- ${(1+ae).toFixed(2)},
525
+ ${(1-se).toFixed(2)},
526
+ ${(1+se).toFixed(2)},
526
527
  a_seed
527
528
  );
528
529
  float transitionResponse = mix(
@@ -536,7 +537,7 @@ Nothing in this notice limits rights granted directly by an applicable license,
536
537
  * u_transitionStagger
537
538
  * (1.0 - carriedVelocity);
538
539
  float springElapsed = max(transitionElapsed - transitionDelay, 0.0);
539
- float transitionOmega = ${se.toFixed(7)}
540
+ float transitionOmega = ${le.toFixed(7)}
540
541
  / max(transitionResponse, 0.10);
541
542
  float transitionSpringTime = transitionOmega * springElapsed;
542
543
  float transitionDecay = exp(-transitionSpringTime);
@@ -561,9 +562,9 @@ Nothing in this notice limits rights granted directly by an applicable license,
561
562
  );
562
563
  }
563
564
 
564
- float lifetime = ${Fe.toFixed(2)}
565
+ float lifetime = ${Ye.toFixed(2)}
565
566
  + (hash(a_seed * 53.17 + 7.9) * 2.0 - 1.0)
566
- * ${Ue.toFixed(2)};
567
+ * ${je.toFixed(2)};
567
568
  float age = mod(u_time + a_seed * lifetime, lifetime);
568
569
  float fadeIn = smoother01(age / 0.18);
569
570
  float fadeOut = 1.0 - smoother01((age - (lifetime - 0.18)) / 0.18);
@@ -585,7 +586,7 @@ Nothing in this notice limits rights granted directly by an applicable license,
585
586
  ) * radiusVariation * 0.50;
586
587
  float motionReferenceRadius = influenceRadius / 1.5;
587
588
  float maximumVelocity = clamp(
588
- motionReferenceRadius * 0.42 / ${me.toFixed(6)},
589
+ motionReferenceRadius * 0.42 / ${Se.toFixed(6)},
589
590
  180.0,
590
591
  340.0
591
592
  ) * u_cursorStrengthScales.x;
@@ -663,9 +664,9 @@ Nothing in this notice limits rights granted directly by an applicable license,
663
664
  vec2 clip = vec2(position.x / u_resolution.x * 2.0 - 1.0, 1.0 - position.y / u_resolution.y * 2.0);
664
665
  gl_Position = vec4(clip, 0.0, 1.0);
665
666
  gl_PointSize = max(1.0, u_particleSize * u_dpr);
666
- v_color = vec4(imageColor.rgb, imageColor.a * u_particleOpacity * lifecycleAlpha * openingAlpha);
667
+ v_color = vec4(imageColor.rgb, imageColor.a * u_particleOpacity * lifecycleAlpha * openingAlpha * u_introReveal);
667
668
  }
668
- `,Et=`
669
+ `,Lt=`
669
670
  precision mediump float;
670
671
  varying vec4 v_color;
671
672
  void main() {
@@ -675,4 +676,424 @@ Nothing in this notice limits rights granted directly by an applicable license,
675
676
  if (coverage <= 0.001) discard;
676
677
  gl_FragColor = vec4(v_color.rgb, v_color.a * coverage);
677
678
  }
678
- `;function Le(o,e,r){let n=o.createShader(e);if(!n)throw new Error("WebGL could not create a particle shader");if(o.shaderSource(n,r),o.compileShader(n),!o.getShaderParameter(n,o.COMPILE_STATUS)){let t=o.getShaderInfoLog(n)||"Particle shader compilation failed";throw o.deleteShader(n),new Error(t)}return n}function Rt(o){let e=Le(o,o.VERTEX_SHADER,wt),r=Le(o,o.FRAGMENT_SHADER,Et),n=o.createProgram();if(!n)throw new Error("WebGL could not create the particle program");if(o.attachShader(n,e),o.attachShader(n,r),o.linkProgram(n),!o.getProgramParameter(n,o.LINK_STATUS)){let t=o.getProgramInfoLog(n)||"Particle shader linking failed";throw o.deleteProgram(n),o.deleteShader(e),o.deleteShader(r),new Error(t)}return{program:n,vertexShader:e,fragmentShader:r}}function pe(o){let e=Math.min(1,Math.max(0,o));return e*e*e*(e*(e*6-15)+10)}function Be(o,e){let n=se/Math.max(e,.1)*Math.max(0,o);return Math.min(1,Math.max(0,1-(1+n)*Math.exp(-n)))}function Tt(o){return pe((o-.6)/.4)}var ce=class{#o;#e;#w;#W;#V;#i;#t;#c;#a=[];#T=new Float32Array(ne*4);#A=new Float32Array(ne*4);#m=window.matchMedia("(prefers-reduced-motion: reduce)");#pe;#X;#q;#_=0;#s=1;#f=new Float32Array(0);#p=new Float32Array(0);#g=new Float32Array(0);#E=new Uint8Array(0);#M=new Uint8Array(0);#B=new Float32Array(0);#F=1;#U=1;#v={...le};#l=0;#P=1;#k=1;#ie=1;#y=12.4;#b=performance.now();#ge=0;#R=I.morphIntervalSeconds;#ve=I.morphIntervalSeconds;#ye=ft(ee);#Y=Number.NaN;#O;#ae=I.morphIntervalSeconds;#se=0;#le=0;#h=!1;#K=0;#N;#be=0;#n;#j;#ue=!0;#z=!0;#ce=!0;#$=!0;#Z=!0;#J=!0;#I=!0;#Q=!0;#de=!0;#x=0;#d=!1;#u=!1;#he;#ee;constructor(e,r,n,t,i=()=>{}){this.#o=e,this.#pe=r,this.#n=n,this.#j=ke(n.cursorStrength),this.#X=t,this.#q=i;let s=e.getContext("webgl",{alpha:!0,antialias:!1,depth:!1,stencil:!1,premultipliedAlpha:!1,powerPreference:"high-performance"});if(!s)throw new Error("WebGL is unavailable");this.#e=s;let u=Rt(s);this.#w=u.program,this.#W=u.vertexShader,this.#V=u.fragmentShader,this.#i={previousHome:this.#D("a_previousHome"),home:this.#D("a_home"),previousVelocity:this.#D("a_previousVelocity"),previousColor:this.#D("a_previousColor"),color:this.#D("a_color"),seed:this.#D("a_seed")},this.#t={resolution:this.#r("u_resolution"),layout:this.#r("u_layout"),pointerSegments:this.#r("u_pointerSegments[0]"),pointerMotion:this.#r("u_pointerMotion[0]"),pointerCount:this.#r("u_pointerCount"),time:this.#r("u_time"),introProgress:this.#r("u_introProgress"),introSpread:this.#r("u_introSpread"),transitionElapsed:this.#r("u_transitionElapsed"),transitionNearResponse:this.#r("u_transitionNearResponse"),transitionFarResponse:this.#r("u_transitionFarResponse"),transitionStagger:this.#r("u_transitionStagger"),transitionActive:this.#r("u_transitionActive"),dpr:this.#r("u_dpr"),particleSize:this.#r("u_particleSize"),particleOpacity:this.#r("u_particleOpacity"),speed:this.#r("u_speed"),noiseScale:this.#r("u_noiseScale"),noiseStrength:this.#r("u_noiseStrength"),dampingRate:this.#r("u_dampingRate"),ambientCycle:this.#r("u_ambientCycle"),cursorStrength:this.#r("u_cursorStrength"),cursorStrengthScales:this.#r("u_cursorStrengthScales"),cursorStrengthDerived:this.#r("u_cursorStrengthDerived")},this.#c={previousHome:this.#C(),home:this.#C(),previousVelocity:this.#C(),previousColor:this.#C(),color:this.#C(),seed:this.#C()},s.useProgram(this.#w),s.enable(s.BLEND),s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),s.disable(s.DEPTH_TEST),s.clearColor(0,0,0,0),this.#Me(),this.resize(),typeof ResizeObserver=="function"&&(this.#he=new ResizeObserver(this.resize),this.#he.observe(e)),window.addEventListener("resize",this.resize,{passive:!0}),window.addEventListener("pointermove",this.#Re,{capture:!0,passive:!0}),window.addEventListener("blur",this.#H,{passive:!0}),document.addEventListener("visibilitychange",this.#Te),this.#m.addEventListener("change",this.#Ae),e.addEventListener("webglcontextlost",this.#_e),this.#u=document.hidden||this.#m.matches,this.#G()}get count(){return this.#l}get openingProgress(){return this.#s}get openingRemainingSeconds(){return this.#s<1?Math.max(0,this.#n.introDuration-this.#_):0}replayOpening(){this.#d||!this.#l||(this.#_=0,this.#s=this.#n.introEnabled&&!this.#m.matches?0:1,this.#me("replayed"),this.#b=performance.now(),this.#H(),this.#S(this.#b,!1),this.#G())}setRenderSettings(e){if(this.#d)return;let r=this.#n,n=e.dprCap!==r.dprCap,t=r.cursorInteraction&&!e.cursorInteraction,i=e.morphIntervalSeconds!==r.morphIntervalSeconds;if((e.particleSize!==r.particleSize||e.particleOpacity!==r.particleOpacity||e.speed!==r.speed||e.noiseScale!==r.noiseScale||e.noiseStrength!==r.noiseStrength||e.damping!==r.damping||e.ambientCycle!==r.ambientCycle||e.cursorStrength!==r.cursorStrength)&&(this.#ce=!0),e.cursorStrength!==r.cursorStrength&&(this.#j=ke(e.cursorStrength),this.#de=!0),this.#n=e,e.introEnabled?r.introEnabled?this.#s<1&&e.introDuration!==r.introDuration&&(this.#_=this.#s*e.introDuration):this.replayOpening():(this.#s=1,this.#q(1)),this.#h||(this.#R=e.morphIntervalSeconds,i&&(this.#$=!0)),t){this.#ee=void 0;let s=this.#a.at(-1);s&&(s.sealed=!0)}n?this.resize():this.#u&&this.#S(performance.now(),!1)}setPreparedImage(e,r){if(this.#d)return Promise.resolve(!1);let n=performance.now(),t=this.#l===0;this.#u||(this.#y=this.#fe(n)),this.#b=n;let i=++this.#be;this.#we();let s=this.#l===e.targetCount&&this.#l>0&&!this.#m.matches&&this.#Ie();this.#p=e.normalizedHomes,this.#M=e.colors,this.#B=e.seeds,this.#F=e.width,this.#U=e.height,this.#v=ue(r),this.#l=e.targetCount,t&&(this.#_=0,this.#s=this.#n.introEnabled&&!this.#m.matches?0:1,this.#me("started")),this.#R=this.#n.morphIntervalSeconds,this.#z=!0,s||(this.#f=new Float32Array(e.targetCount*2),this.#g=new Float32Array(e.targetCount*2),this.#E=new Uint8Array(e.targetCount*4),this.#Se(this.#f),this.#E.set(this.#M)),this.#ae=s?this.#De():this.#R,s||(this.#se=0,this.#le=0),this.#L(this.#c.previousHome,this.#f),this.#L(this.#c.home,this.#p),this.#L(this.#c.previousVelocity,this.#g),this.#L(this.#c.previousColor,this.#E),this.#L(this.#c.color,this.#M),this.#L(this.#c.seed,this.#B);let u=this.#Le(s,i);return(this.#u||!s)&&this.#S(performance.now(),!1),u}renderPreparedFrame(){return this.#d||this.#l<=0||this.#e.isContextLost()?!1:(this.#S(performance.now(),!1),this.#e.flush(),!0)}resumeOpening(){this.#d||this.replayOpening()}#me(e){$("particle-image","particle gathering",e,{normalBackground:!!this.#o.closest("[data-code-codex-particle-layer]"),durationSeconds:this.#n.introDuration,spread:this.#n.introSpread,enabled:this.#n.introEnabled,reducedMotion:this.#m.matches,progress:this.#s})}setImageTransform(e){if(this.#d)return;let r=ue(e);r.positionX===this.#v.positionX&&r.positionY===this.#v.positionY&&r.zoom===this.#v.zoom||(this.#v=r,this.#z=!0,this.#u&&this.#S(performance.now(),!1))}setPaused(e){this.#u=e||document.hidden||this.#m.matches,this.#b=performance.now(),this.#u&&this.#h&&this.#Ee(),this.#u?this.#S(performance.now(),!1):this.#G()}resize=()=>{if(this.#d)return;let e=this.#o.getBoundingClientRect(),r=Math.max(1,e.width),n=Math.max(1,e.height),t=Math.min(this.#n.dprCap,Math.max(1,window.devicePixelRatio||1)),i=r!==this.#P||n!==this.#k,s=t!==this.#ie;this.#P=r,this.#k=n,this.#ie=t,(i||s)&&(this.#ue=!0),i&&(this.#z=!0);let u=Math.max(1,Math.round(r*t)),a=Math.max(1,Math.round(n*t)),h=this.#o.width!==u||this.#o.height!==a;this.#o.width!==u&&(this.#o.width=u),this.#o.height!==a&&(this.#o.height=a),h&&this.#e.viewport(0,0,u,a),this.#u&&this.#S(performance.now(),!1)};dispose(){if(!this.#d){this.#d=!0,this.#we(),oe(this.#x),this.#x=0,window.removeEventListener("resize",this.resize),this.#he?.disconnect(),window.removeEventListener("pointermove",this.#Re,!0),window.removeEventListener("blur",this.#H),document.removeEventListener("visibilitychange",this.#Te),this.#m.removeEventListener("change",this.#Ae),this.#o.removeEventListener("webglcontextlost",this.#_e);for(let e of Object.values(this.#c))this.#e.deleteBuffer(e);this.#e.deleteProgram(this.#w),this.#e.deleteShader(this.#W),this.#e.deleteShader(this.#V),this.#e.getExtension("WEBGL_lose_context")?.loseContext(),this.#a.length=0}}#D(e){let r=this.#e.getAttribLocation(this.#w,e);if(r<0)throw new Error(`Particle shader attribute ${e} is unavailable`);return r}#r(e){let r=this.#e.getUniformLocation(this.#w,e);if(!r)throw new Error(`Particle shader uniform ${e} is unavailable`);return r}#C(){let e=this.#e.createBuffer();if(!e)throw new Error("WebGL could not create a particle buffer");return e}#L(e,r){this.#e.bindBuffer(this.#e.ARRAY_BUFFER,e),this.#e.bufferData(this.#e.ARRAY_BUFFER,r,this.#e.STATIC_DRAW)}#Me(){let e=this.#e;e.bindBuffer(e.ARRAY_BUFFER,this.#c.previousHome),e.enableVertexAttribArray(this.#i.previousHome),e.vertexAttribPointer(this.#i.previousHome,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.#c.home),e.enableVertexAttribArray(this.#i.home),e.vertexAttribPointer(this.#i.home,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.#c.previousVelocity),e.enableVertexAttribArray(this.#i.previousVelocity),e.vertexAttribPointer(this.#i.previousVelocity,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.#c.previousColor),e.enableVertexAttribArray(this.#i.previousColor),e.vertexAttribPointer(this.#i.previousColor,4,e.UNSIGNED_BYTE,!0,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.#c.color),e.enableVertexAttribArray(this.#i.color),e.vertexAttribPointer(this.#i.color,4,e.UNSIGNED_BYTE,!0,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.#c.seed),e.enableVertexAttribArray(this.#i.seed),e.vertexAttribPointer(this.#i.seed,1,e.FLOAT,!1,0,0)}#te(e,r){let n=Math.min(this.#P/Math.max(1,e),this.#k/Math.max(1,r)),t=e*n*this.#v.zoom,i=r*n*this.#v.zoom;return[(this.#P-t)*this.#v.positionX/100,(this.#k-i)*this.#v.positionY/100,t,i]}#re(){return this.#R*st}#ne(){return this.#R*lt}#Pe(){let e=Math.max(this.#ae,.1),r=se/e,n=Math.max(0,this.#le),t=Math.max(1,this.#se),i=Math.min(ut,dt/t),s=Math.min(ct,ht/t),u=d=>{let c=r*d,l=Math.exp(-c),m=(1+(1+n)*c)*l,f=r*(n+(1+n)*c)*l;return m<=i&&f<=s},a=0,h=e;for(let d=0;d<18&&!u(h);d+=1)h*=1.5;for(let d=0;d<24;d+=1){let c=.5*(a+h);u(c)?h=c:a=c}return Math.max(.1,this.#ne()+h)}#oe(){if(this.#O&&this.#Y===this.#y)return this.#O;let e=Math.max(.1,this.#ve),r=Math.max(0,this.#y-this.#ge),n=this.#h?Math.min(1,r/e):1,t=gt(n,this.#ye),i={rawProgress:n,elapsed:t.value*e};return this.#Y=this.#y,this.#O=i,i}#ke(){return this.#h?Be(this.#oe().elapsed-this.#ne()*.35,this.#ae):1}#xe(e,r){let n=Math.max(Math.hypot(this.#P,this.#k)*Ne,80),t=pe(e/n),i=1-ae+r*ae*2;return(this.#re()+t*(this.#R-this.#re()))*i}#Se(e){if(e.length!==this.#p.length)return!1;let[r,n,t,i]=this.#te(this.#F,this.#U);for(let s=0;s<this.#l;s+=1){let u=s*2;e[u]=r+(this.#p[u]??0)*t,e[u+1]=n+(this.#p[u+1]??0)*i}return!0}#Ie(){if(!this.#l||this.#f.length!==this.#p.length||this.#g.length!==this.#p.length||this.#E.length!==this.#M.length)return!1;if(!this.#h)return this.#Se(this.#f)?(this.#g.fill(0),this.#E.set(this.#M),!0):!1;let e=this.#oe().elapsed,r=this.#ne(),[n,t,i,s]=this.#te(this.#F,this.#U);for(let u=0;u<this.#l;u+=1){let a=u*2,h=this.#f[a]??0,d=this.#f[a+1]??0,c=n+(this.#p[a]??0)*i,l=t+(this.#p[a+1]??0)*s,m=Math.hypot(c-h,l-d),f=this.#xe(m,this.#B[u]??0),p=h-c,b=d-l,S=this.#g[a]??0,A=this.#g[a+1]??0,x=Math.hypot(S,A)>=.01,E=this.#B[u]??0,D=x?0:E*E*r,R=Math.max(0,e-D),U=Be(R,f),M=se/f,H=Math.exp(-M*R),P=S+M*p,z=A+M*b;this.#f[a]=c+(p+P*R)*H,this.#f[a+1]=l+(b+z*R)*H,this.#g[a]=0,this.#g[a+1]=0;let G=pe((U-.18)/.82),K=1-G,g=u*4;for(let T=0;T<4;T+=1){let C=g+T;this.#E[C]=Math.round((this.#E[C]??0)*K+(this.#M[C]??0)*G)}}return!0}#De(){let[e,r,n,t]=this.#te(this.#F,this.#U),i=this.#re()*(1-ae),s=0,u=0;for(let a=0;a<this.#l;a+=1){let h=a*2,d=e+(this.#p[h]??0)*n,c=r+(this.#p[h+1]??0)*t,l=Math.hypot(d-(this.#f[h]??0),c-(this.#f[h+1]??0));u=Math.max(u,l);let m=this.#xe(l,this.#B[a]??0);i=Math.max(i,m);let f=Math.hypot(this.#g[h]??0,this.#g[h+1]??0),p=se/m;s=Math.max(s,f/(p*Math.max(l,1)))}return this.#se=u,this.#le=s,i}#Ce(){return this.#h?this.#oe().rawProgress>=1:!0}#we(){let e=this.#N;this.#N=void 0,this.#K=0,e?.(!1)}#Le(e,r){return this.#ge=this.#y,this.#ye=ze(this.#n.morphCurve),this.#ve=this.#Pe(),this.#Y=Number.NaN,this.#O=void 0,this.#h=e,this.#$=!0,this.#Z=!0,this.#J=!0,this.#X(e?0:1,!e),e?new Promise(n=>{this.#K=r,this.#N=n}):Promise.resolve(!0)}#Ee(){if(!this.#h)return;this.#h=!1,this.#Y=Number.NaN,this.#O=void 0,this.#Z=!0,this.#J=!0,this.#X(1,!0);let e=this.#N,r=this.#K;this.#N=void 0,this.#K=0,e?.(r===this.#be&&!this.#d)}#fe(e=performance.now()){if(this.#u)return this.#y;let r=Math.min(it,Math.max(0,(e-this.#b)/1e3));return this.#y+r}#Re=e=>{if(this.#d||this.#u||!this.#n.cursorInteraction||!e.isPrimary)return;let r=this.#o.getBoundingClientRect(),n=e.clientX-r.left,t=e.clientY-r.top;if(n<0||t<0||n>r.width||t>r.height){this.#H();return}let i=this.#fe(),s=this.#ee;if(this.#ee={x:n,y:t,at:i},!s)return;let u=this.#a.length,a=this.#a.at(-1),h=i-s.at,d=n-s.x,c=t-s.y;if(h<=.001||h>Ee){a&&(a.sealed=!0);return}let l=Math.hypot(d,c)/h;if(l<1.5){a&&i-a.startedAt>=he&&(a.sealed=!0);return}a&&!a.sealed&&i-a.startedAt>he*1.5&&(a.sealed=!0);let m=d/h,f=c/h,{cursorScale:p,overdrive:b,highStrengthScale:S}=this.#j,A=5200*S,x=p>0?Math.min(A,l*(1.04+.14*p)*Math.sqrt(b)):0,E=m/l*x,D=f/l*x,R=a&&i-a.createdAt<=Ee?a:void 0,U=R?R.velocityX*.28+E*.72:E,M=R?R.velocityY*.28+D*.72:D;a&&!a.sealed?(a.endX=n,a.endY=t,a.velocityX=U,a.velocityY=M,a.createdAt=i,a.duration=Math.max(.001,i-a.startedAt),a.sealed=a.duration>=he):this.#a.push({startX:s.x,startY:s.y,endX:n,endY:t,velocityX:U,velocityY:M,startedAt:s.at,createdAt:i,duration:h,sealed:h>=he}),this.#a.length>ne&&this.#a.shift(),this.#I=!0,this.#a.length!==u&&(this.#Q=!0)};#H=()=>{this.#ee=void 0;let e=this.#a.at(-1);e&&(e.sealed=!0)};#Te=()=>{if(document.hidden){oe(this.#x),this.#x=0,this.#H(),this.#b=performance.now();return}this.#b=performance.now(),!this.#u&&!this.#m.matches&&this.#G()};#Ae=()=>{this.#m.matches&&(this.#s=1,this.#q(1)),this.setPaused(this.#m.matches)};#_e=e=>{e.preventDefault(),oe(this.#x),this.#x=0,this.#pe("The particle renderer lost its WebGL context. Disable and re-enable the plugin.")};#G(){this.#d||this.#u||document.hidden||this.#x||(this.#x=ve(this.#o,e=>{this.#x=0,this.#S(e,!0)}))}#S(e,r){if(this.#d)return;let n=this.#s<1;this.#l&&!this.#u&&!document.hidden&&this.#s<1&&(this.#_+=Math.min(.1,Math.max(0,(e-this.#b)/1e3)),this.#s=Math.min(1,this.#_/this.#n.introDuration)),this.#u||(this.#y=this.#fe(e)),this.#b=e;let t=this.#e,i=!1;if(t.clear(t.COLOR_BUFFER_BIT),this.#l>0){let s=this.#y;for(this.#h&&(this.#X(this.#ke(),!1),i=this.#Ce());this.#a.length&&s-(this.#a[0]?.createdAt??s)>Oe;)this.#a.shift(),this.#I=!0,this.#Q=!0;let u=this.#a.length;this.#I&&this.#T.fill(0),u>0&&this.#A.fill(0);for(let a=0;a<this.#a.length;a+=1){let h=this.#a[a];if(!h)continue;let d=a*4;this.#I&&(this.#T[d]=h.startX,this.#T[d+1]=h.startY,this.#T[d+2]=h.endX,this.#T[d+3]=h.endY),this.#A[d]=h.velocityX,this.#A[d+1]=h.velocityY,this.#A[d+2]=Math.max(0,s-h.createdAt),this.#A[d+3]=Math.max(.001,h.duration)}if(this.#ue&&(t.uniform2f(this.#t.resolution,this.#P,this.#k),t.uniform1f(this.#t.dpr,this.#ie),this.#ue=!1),this.#z){let a=this.#te(this.#F,this.#U);t.uniform4f(this.#t.layout,a[0],a[1],a[2],a[3]),this.#z=!1}if(this.#I&&(u>0&&t.uniform4fv(this.#t.pointerSegments,this.#T),this.#I=!1),this.#Q&&(t.uniform1f(this.#t.pointerCount,u),this.#Q=!1),u>0&&t.uniform4fv(this.#t.pointerMotion,this.#A),t.uniform1f(this.#t.time,s),t.uniform1f(this.#t.introProgress,this.#s),t.uniform1f(this.#t.introSpread,this.#n.introSpread),(this.#h||this.#J)&&(t.uniform1f(this.#t.transitionElapsed,this.#oe().elapsed),this.#J=!1),this.#$&&(t.uniform1f(this.#t.transitionNearResponse,this.#re()),t.uniform1f(this.#t.transitionFarResponse,this.#R),t.uniform1f(this.#t.transitionStagger,this.#ne()),this.#$=!1),this.#Z&&(t.uniform1f(this.#t.transitionActive,this.#h?1:0),this.#Z=!1),this.#ce){t.uniform1f(this.#t.particleSize,this.#n.particleSize),t.uniform1f(this.#t.particleOpacity,this.#n.particleOpacity),t.uniform1f(this.#t.speed,this.#n.speed),t.uniform1f(this.#t.noiseScale,this.#n.noiseScale),t.uniform1f(this.#t.noiseStrength,this.#n.noiseStrength);let a=Math.min(.9999,Math.max(.8,this.#n.damping));t.uniform1f(this.#t.dampingRate,Math.log(a)/me),t.uniform1f(this.#t.ambientCycle,this.#n.ambientCycle),t.uniform1f(this.#t.cursorStrength,this.#n.cursorStrength),this.#ce=!1}if(this.#de){let a=this.#j;t.uniform3f(this.#t.cursorStrengthScales,a.highStrengthScale,a.stepStrengthScale,a.strength),t.uniform2f(this.#t.cursorStrengthDerived,a.wakeLengthScale,a.squareRootStrength),this.#de=!1}t.drawArrays(t.POINTS,0,this.#l)}i&&this.#Ee(),this.#l&&this.#q(this.#s),n&&this.#s===1&&this.#me("completed"),r&&this.#G()}};function At(o,e=!1){return new Promise((r,n)=>{if(!("indexedDB"in window)){n(new Error("IndexedDB is unavailable"));return}let t=indexedDB.open(rt,nt),i=!1;t.addEventListener("upgradeneeded",()=>{if(e){i=!0,t.transaction?.abort(),n(new Error("Add/select an image in Particle Image Background before using it as the startup source."));return}let s=t.result;s.objectStoreNames.contains(fe)||s.createObjectStore(fe,{keyPath:"id"})}),t.addEventListener("success",()=>{let s=t.result;if(i){s.close();return}i=!0,s.addEventListener("versionchange",()=>{s.close(),o()},{once:!0}),r(s)}),t.addEventListener("blocked",()=>{i||(i=!0,n(new Error("The image library database is blocked")))},{once:!0}),t.addEventListener("error",()=>{i||(i=!0,n(t.error??new Error("The image library database could not be opened")))},{once:!0})})}function _t(o){return new Promise((e,r)=>{let n=o.transaction(fe,"readonly").objectStore(fe).getAll();n.addEventListener("success",()=>{let t=Array.isArray(n.result)?n.result.filter(i=>{if(!i||typeof i!="object")return!1;let s=i;return typeof s.id=="string"&&typeof s.name=="string"&&typeof s.type=="string"&&typeof s.size=="number"&&typeof s.createdAt=="number"&&s.blob instanceof Blob&&s.thumbnail instanceof Blob}).map(i=>({...i,...ue(i)})):[];e(t)}),n.addEventListener("error",()=>r(n.error??new Error("Saved particle images could not be read")),{once:!0})})}function He(o,e){let r=bt(),n=document.createElement("div");n.dataset.codeCodexStartupParticleImage="v1",n.setAttribute("aria-hidden","true"),Object.assign(n.style,{position:"absolute",inset:"0",overflow:"hidden",backgroundColor:r.backgroundColor,pointerEvents:"none"});let t=document.createElement("img"),i=document.createElement("img");t.className="code-codex-particle-source-previous",i.className="code-codex-particle-source-current";for(let v of[t,i])v.alt="",Object.assign(v.style,{position:"absolute",inset:"0",width:"100%",height:"100%",objectFit:"contain",opacity:"0",transition:"none",pointerEvents:"none"});let s=document.createElement("canvas");s.className="code-codex-particle-canvas",Object.assign(s.style,{position:"absolute",inset:"0",width:"100%",height:"100%"}),n.append(t,i,s),o.append(n);let u=window.matchMedia("(prefers-reduced-motion: reduce)"),a=new Te,h=new Set,d,c,l=[],m=[],f,p,b,S={...le},A=!1,x=1,E=!1,D=!1,R=!1,U=0,M,H=0,P=0,z,G,K=new Promise((v,w)=>{z=v,G=w});K.catch(()=>{});function g(v){!v||!h.delete(v)||URL.revokeObjectURL(v)}function T(){window.clearTimeout(H),H=0}function C(){if(!E){E=!0,T(),window.clearTimeout(P),cancelAnimationFrame(U),M?.(),M=void 0,a.dispose(),c?.dispose(),c=void 0,d?.close(),d=void 0,document.removeEventListener("visibilitychange",V),u.removeEventListener("change",V),i.removeAttribute("src"),t.removeAttribute("src");for(let v of[...h])g(v);n.remove(),D||(D=!0,G(new DOMException("Particle startup source was disposed","AbortError")))}}function B(v){if(E)return;let w=v instanceof Error?v.message:String(v),L=new Error(`Particle Image startup source: ${w}`);D||(D=!0,G(L)),C(),e(L.message)}function k(v,w){if(E)return;x=v;let L=r.showSourceImage?r.imageOpacity*Tt(c?.openingProgress??1):0;if(!A){i.style.opacity=String(L),t.style.opacity="0";return}let Y=pe(Math.min(1,Math.max(0,v))),N=L*Y,W=1-N;t.style.opacity=String(W>Number.EPSILON?Math.min(1,Math.max(0,L*(1-Y)/W)):0),i.style.opacity=String(N),w&&(A=!1,x=1,g(b),b=void 0,t.removeAttribute("src"),t.style.opacity="0",i.style.opacity=String(L))}function y(){let v=f?m.indexOf(f):-1,w=m[(v+1+m.length)%m.length];return l.find(L=>L.id===w)}function F(){if(T(),E||R||!r.autoSwitch||document.hidden||u.matches||m.length<2)return;let v=y();!v||v.id===f||(a.prewarm(v,r.particleCount),H=window.setTimeout(()=>{if(H=0,!(E||document.hidden||u.matches)){if((c?.openingRemainingSeconds??0)>0){F();return}_(v).catch(B)}},(r.imageDurationSeconds+(c?.openingRemainingSeconds??0))*1e3))}function V(){document.hidden||u.matches?T():F()}function O(){if(E)throw new DOMException("Particle startup source was disposed","AbortError")}async function _(v){O(),R=!0,T(),P=window.setTimeout(()=>{B(new Error("Image preparation timed out. Choose a smaller or valid image in Particle Image Background."))},we);try{let w;try{w=await a.prepare(v,r.particleCount)}catch(X){if(X instanceof DOMException&&X.name==="AbortError")throw X;let Ye=X instanceof Error?X.message:String(X);throw new Error(`The saved particle image could not be prepared (${Ye}). Select a valid image in Particle Image Background.`,{cause:X})}O();let L=URL.createObjectURL(w.processedBlob);h.add(L);let Y=new Image;Y.src=L;try{await Y.decode()}catch(X){throw g(L),new Error("The saved image could not be decoded. Select a valid image in Particle Image Background.",{cause:X})}finally{Y.removeAttribute("src")}O();let N=ue(v),W=!!(p&&c&&c.count===w.targetCount&&!u.matches),J=p;g(b),b=W?J:void 0,b?(t.src=b,Ce(t,S)):(t.removeAttribute("src"),g(J)),p=L,S=N,i.src=L,Ce(i,N),A=W,k(W?0:1,!W);let te=await c?.setPreparedImage(w,N);if(O(),!te||!c?.renderPreparedFrame())throw new Error("The particle renderer did not present the saved image.");f=v.id,D||(await new Promise(X=>{M=X,U=requestAnimationFrame(()=>{U=requestAnimationFrame(()=>{U=0,M=void 0,X()})})}),O(),n.dataset.codeCodexStartupParticleReady="true",D=!0,z())}finally{window.clearTimeout(P),P=0,R=!1,F()}}return document.addEventListener("visibilitychange",V),u.addEventListener("change",V),P=window.setTimeout(()=>{B(new Error("The saved image library did not become ready. Reopen Particle Image Background and select an image."))},we),(async()=>{if(!r.activeImageId&&!r.selectedImageIds.length)throw new Error("Add/select an image in Particle Image Background before using it as the startup source.");let v=await At(()=>{B(new Error("The saved image library changed. Reopen the startup preview."))},!0);if(E){v.close();return}d=v,l=(await _t(v)).sort((N,W)=>N.createdAt-W.createdAt).slice(0,32),O();let w=new Set(l.map(N=>N.id));m=r.selectedImageIds.filter(N=>w.has(N));let L=r.activeImageId&&w.has(r.activeImageId)?r.activeImageId:m[0],Y=l.find(N=>N.id===L);if(!Y)throw new Error("Add/select an image in Particle Image Background before using it as the startup source.");c=new ce(s,B,r,k,()=>k(x,!1)),window.clearTimeout(P),await _(Y)})().catch(B),{ready:K,dispose:C}}var Mt=Symbol.for("code-codex:default-galleries:v1"),_e="__codeCodex_default_media_v1__",Me=new Map;function Ge(o,e){let r=atob(o),n=new Uint8Array(r.length);for(let t=0;t<r.length;t++)n[t]=r.charCodeAt(t);return new Blob([n],{type:e})}async function We(o){let e=await crypto.subtle.digest("SHA-256",await o.arrayBuffer());return Array.from(new Uint8Array(e),r=>r.toString(16).padStart(2,"0")).join("")}function Ve(o){let e=Me.get(o);if(e)return e;$("default-media","import","started",{id:o});let r=Pt(o).catch(n=>{throw $("default-media","import","failed",{id:o,reason:String(n)}),n}).finally(()=>Me.delete(o));return Me.set(o,r),r}async function Pt(o){let r=window[Mt]?.get(o);if(!r)return;if(r.images.size!==r.count)throw new Error(`Default images for ${o} are incomplete. Download the plugin again.`);let n=o==="particle-image"?"code-codex-particle-image-background":"code-codex-pixel-sculpt",t=await new Promise((i,s)=>{let u=indexedDB.open(n,1),a=!1;u.onupgradeneeded=()=>{u.result.objectStoreNames.contains("images")||u.result.createObjectStore("images",{keyPath:"id"})},u.onsuccess=()=>{a?u.result.close():i(u.result)},u.onerror=()=>s(u.error??new Error("Default image storage is unavailable")),u.onblocked=()=>{a=!0,s(new Error("Close the other window using this image library and retry."))}});try{let i=(l,m=!1)=>new Promise((f,p)=>{let b=m?t.transaction(l).objectStore(l).getAll():t.transaction(l).objectStore(l).get(_e);b.onsuccess=()=>f(b.result),b.onerror=()=>p(b.error)}),s=await i("images");if(s&&s.version>=r.version){$("default-media","import","already initialized",{id:o,count:r.count,version:r.version});return}let u=(await i("images",!0)).filter(l=>l.file instanceof Blob||l.blob instanceof Blob),a=new Set;for(let l of u){let m=l.file??l.blob;l.sha256?a.add(l.sha256):m instanceof Blob&&[...r.images.values()].some(f=>f.size===m.size)&&a.add(await We(m))}let h=new Set(u.map(l=>l.id)),d=u.reduce((l,m)=>l+(m.file?.size??m.blob?.size??0),0),c=[];for(let l of[...r.images.values()].sort((m,f)=>(m.createdAt??0)-(f.createdAt??0))){if(a.has(l.sha256)||h.has(l.id))continue;if(u.length+c.length>=32||d+l.size>256*1024*1024)throw new Error("There is not enough image-library capacity for the default images. Remove some images and retry.");let m=Ge(l.data,l.type);if(m.size!==l.size||await We(m)!==l.sha256)throw new Error(`Default image ${l.name} failed verification.`);d+=m.size,c.push(o==="pixel-sculpt"?{id:l.id,file:new File([m],l.name,{type:l.type}),order:l.order,sha256:l.sha256}:{id:l.id,name:l.name,type:l.type,size:l.size,createdAt:l.createdAt??c.length+1,blob:m,thumbnail:Ge(l.thumbnail??l.data,l.type),positionX:l.positionX,positionY:l.positionY,zoom:l.zoom,sha256:l.sha256})}if(await new Promise((l,m)=>{let f=t.transaction("images","readwrite"),p=f.objectStore("images"),b=p.get(_e);b.onsuccess=()=>{if(!(b.result?.version>=r.version)){for(let S of c)f.objectStore("images").add(S);p.put({id:_e,version:r.version,count:r.count})}},f.oncomplete=()=>l(),f.onerror=()=>m(f.error),f.onabort=()=>m(f.error??new Error("Default image import was cancelled"))}),o==="particle-image"&&u.length===0&&c.length){let l="code-codex:particle-image-background:v1",m={};try{m=JSON.parse(localStorage.getItem(l)??"{}")??{}}catch{}m.selectedImageIds?.length||(m.selectedImageIds=c.map(f=>f.id),m.activeImageId=c[0]?.id,localStorage.setItem(l,JSON.stringify(m)))}$("default-media","import","passed",{id:o,count:r.count,added:c.length,existing:u.length,version:r.version})}finally{t.close()}}var Xe=window,qe=Symbol.for("code-codex:background-modules:v1"),kt=Xe[qe]??(Xe[qe]=new Map),It=()=>Ve("particle-image");kt.set("particle-image",{id:"particle-image",api:1,version:"1.0.3",prepareDefaults:It,exports:{ParticleImageRenderer:ce},startup(o,e){let r,n=!1,t=Promise.resolve().then(()=>{if(n)throw new Error("Startup background preparation was canceled");return r=He(o,e),r.ready});return t.catch(()=>{}),{ready:t,dispose(){n=!0,r?.dispose()}}}});})();
679
+ `;function qe(i,e,n){let t=i.createShader(e);if(!t)throw new Error("WebGL could not create a particle shader");if(i.shaderSource(t,n),i.compileShader(t),!i.getShaderParameter(t,i.COMPILE_STATUS)){let r=i.getShaderInfoLog(t)||"Particle shader compilation failed";throw i.deleteShader(t),new Error(r)}return t}function Bt(i){let e=qe(i,i.VERTEX_SHADER,Ct),n=qe(i,i.FRAGMENT_SHADER,Lt),t=i.createProgram();if(!t)throw new Error("WebGL could not create the particle program");if(i.attachShader(t,e),i.attachShader(t,n),i.linkProgram(t),!i.getProgramParameter(t,i.LINK_STATUS)){let r=i.getProgramInfoLog(t)||"Particle shader linking failed";throw i.deleteProgram(t),i.deleteShader(e),i.deleteShader(n),new Error(r)}return{program:t,vertexShader:e,fragmentShader:n}}function ue(i){let e=Math.min(1,Math.max(0,i));return e*e*e*(e*(e*6-15)+10)}function Xe(i,e){let t=le/Math.max(e,.1)*Math.max(0,i);return Math.min(1,Math.max(0,1-(1+t)*Math.exp(-t)))}function Ft(i){return ue((i-.6)/.4)}var Le=class{#r;#e;#n;#R;#w;#c;#t;#a;#o=[];#v=new Float32Array(ne*4);#k=new Float32Array(ne*4);#u=window.matchMedia("(prefers-reduced-motion: reduce)");#b;#D;#E;#x=0;#i=1;#m=new Float32Array(0);#d=new Float32Array(0);#f=new Float32Array(0);#h=new Uint8Array(0);#C=new Uint8Array(0);#z=new Float32Array(0);#G=1;#H=1;#T={...ce};#p=0;#L=1;#B=1;#ae=1;#A=12.4;#_=performance.now();#ge=0;#I=D.morphIntervalSeconds;#ve=D.morphIntervalSeconds;#ye=Tt(te);#j=Number.NaN;#V;#se=D.morphIntervalSeconds;#le=0;#ce=0;#S=!1;#K=0;#W;#be=0;#l;#$;#ue=!0;#q=!0;#de=!0;#Z=!0;#J=!0;#Q=!0;#F=!0;#ee=!0;#he=!0;#M=0;#y=!1;#g=!1;#me;#te;constructor(e,n,t,r,o=()=>{}){this.#r=e,this.#b=n,this.#l=t,this.#$=Ge(t.cursorStrength),this.#D=r,this.#E=o;let a=e.getContext("webgl",{alpha:!0,antialias:!1,depth:!1,stencil:!1,premultipliedAlpha:!1,powerPreference:"high-performance"});if(!a)throw new Error("WebGL is unavailable");this.#e=a;let c=Bt(a);this.#n=c.program,this.#R=c.vertexShader,this.#w=c.fragmentShader,this.#c={previousHome:this.#O("a_previousHome"),home:this.#O("a_home"),previousVelocity:this.#O("a_previousVelocity"),previousColor:this.#O("a_previousColor"),color:this.#O("a_color"),seed:this.#O("a_seed")},this.#t={resolution:this.#s("u_resolution"),layout:this.#s("u_layout"),pointerSegments:this.#s("u_pointerSegments[0]"),pointerMotion:this.#s("u_pointerMotion[0]"),pointerCount:this.#s("u_pointerCount"),time:this.#s("u_time"),introProgress:this.#s("u_introProgress"),introReveal:this.#s("u_introReveal"),introSpread:this.#s("u_introSpread"),transitionElapsed:this.#s("u_transitionElapsed"),transitionNearResponse:this.#s("u_transitionNearResponse"),transitionFarResponse:this.#s("u_transitionFarResponse"),transitionStagger:this.#s("u_transitionStagger"),transitionActive:this.#s("u_transitionActive"),dpr:this.#s("u_dpr"),particleSize:this.#s("u_particleSize"),particleOpacity:this.#s("u_particleOpacity"),speed:this.#s("u_speed"),noiseScale:this.#s("u_noiseScale"),noiseStrength:this.#s("u_noiseStrength"),dampingRate:this.#s("u_dampingRate"),ambientCycle:this.#s("u_ambientCycle"),cursorStrength:this.#s("u_cursorStrength"),cursorStrengthScales:this.#s("u_cursorStrengthScales"),cursorStrengthDerived:this.#s("u_cursorStrengthDerived")},this.#a={previousHome:this.#U(),home:this.#U(),previousVelocity:this.#U(),previousColor:this.#U(),color:this.#U(),seed:this.#U()},a.useProgram(this.#n),a.enable(a.BLEND),a.blendFunc(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA),a.disable(a.DEPTH_TEST),a.clearColor(0,0,0,0),this.#Me(),this.resize(),typeof ResizeObserver=="function"&&(this.#me=new ResizeObserver(this.resize),this.#me.observe(e)),window.addEventListener("resize",this.resize,{passive:!0}),window.addEventListener("pointermove",this.#Re,{capture:!0,passive:!0}),window.addEventListener("blur",this.#X,{passive:!0}),document.addEventListener("visibilitychange",this.#Te),this.#u.addEventListener("change",this.#Ae),e.addEventListener("webglcontextlost",this.#_e),this.#g=document.hidden||this.#u.matches,this.#Y()}get count(){return this.#p}get openingProgress(){return this.#i}get openingRemainingSeconds(){return this.#i<1?Math.max(0,this.#l.introDuration+.35-this.#x):0}replayOpening(){this.#y||!this.#p||(this.#x=0,this.#i=this.#l.introEnabled&&!this.#u.matches?0:1,this.#fe("replayed"),this.#_=performance.now(),this.#X(),this.#P(this.#_,!1),this.#Y())}setRenderSettings(e){if(this.#y)return;let n=this.#l,t=e.dprCap!==n.dprCap,r=n.cursorInteraction&&!e.cursorInteraction,o=e.morphIntervalSeconds!==n.morphIntervalSeconds;if((e.particleSize!==n.particleSize||e.particleOpacity!==n.particleOpacity||e.speed!==n.speed||e.noiseScale!==n.noiseScale||e.noiseStrength!==n.noiseStrength||e.damping!==n.damping||e.ambientCycle!==n.ambientCycle||e.cursorStrength!==n.cursorStrength)&&(this.#de=!0),e.cursorStrength!==n.cursorStrength&&(this.#$=Ge(e.cursorStrength),this.#he=!0),this.#l=e,e.introEnabled?n.introEnabled?this.#i<1&&e.introDuration!==n.introDuration&&(this.#x=this.#i*e.introDuration):this.replayOpening():(this.#i=1,this.#E(1)),this.#S||(this.#I=e.morphIntervalSeconds,o&&(this.#Z=!0)),r){this.#te=void 0;let a=this.#o.at(-1);a&&(a.sealed=!0)}t?this.resize():this.#g&&this.#P(performance.now(),!1)}setPreparedImage(e,n){if(this.#y)return Promise.resolve(!1);let t=performance.now(),r=this.#p===0;this.#g||(this.#A=this.#pe(t)),this.#_=t;let o=++this.#be;this.#we();let a=this.#p===e.targetCount&&this.#p>0&&!this.#u.matches&&this.#De();this.#d=e.normalizedHomes,this.#C=e.colors,this.#z=e.seeds,this.#G=e.width,this.#H=e.height,this.#T=de(n),this.#p=e.targetCount,r&&(this.#x=0,this.#i=this.#l.introEnabled&&!this.#u.matches?0:1,this.#fe("started")),this.#I=this.#l.morphIntervalSeconds,this.#q=!0,a||(this.#m=new Float32Array(e.targetCount*2),this.#f=new Float32Array(e.targetCount*2),this.#h=new Uint8Array(e.targetCount*4),this.#Se(this.#m),this.#h.set(this.#C)),this.#se=a?this.#Ie():this.#I,a||(this.#le=0,this.#ce=0),this.#N(this.#a.previousHome,this.#m),this.#N(this.#a.home,this.#d),this.#N(this.#a.previousVelocity,this.#f),this.#N(this.#a.previousColor,this.#h),this.#N(this.#a.color,this.#C),this.#N(this.#a.seed,this.#z);let c=this.#Le(a,o);return(this.#g||!a)&&this.#P(performance.now(),!1),c}renderPreparedFrame(){return this.#y||this.#p<=0||this.#e.isContextLost()?!1:(this.#P(performance.now(),!1),this.#e.flush(),!0)}resumeOpening(){this.#y||this.replayOpening()}#fe(e){Y("particle-image","particle gathering",e,{normalBackground:!!this.#r.closest("[data-code-codex-particle-layer]"),durationSeconds:this.#l.introDuration,spread:this.#l.introSpread,enabled:this.#l.introEnabled,reducedMotion:this.#u.matches,progress:this.#i})}setImageTransform(e){if(this.#y)return;let n=de(e);n.positionX===this.#T.positionX&&n.positionY===this.#T.positionY&&n.zoom===this.#T.zoom||(this.#T=n,this.#q=!0,this.#g&&this.#P(performance.now(),!1))}setPaused(e){this.#g=e||document.hidden||this.#u.matches,this.#_=performance.now(),this.#g&&this.#S&&this.#Ee(),this.#g?this.#P(performance.now(),!1):this.#Y()}resize=()=>{if(this.#y)return;let e=this.#r.getBoundingClientRect(),n=Math.max(1,e.width),t=Math.max(1,e.height),r=Math.min(this.#l.dprCap,Math.max(1,window.devicePixelRatio||1)),o=n!==this.#L||t!==this.#B,a=r!==this.#ae;this.#L=n,this.#B=t,this.#ae=r,(o||a)&&(this.#ue=!0),o&&(this.#q=!0);let c=Math.max(1,Math.round(n*r)),s=Math.max(1,Math.round(t*r)),h=this.#r.width!==c||this.#r.height!==s;this.#r.width!==c&&(this.#r.width=c),this.#r.height!==s&&(this.#r.height=s),h&&this.#e.viewport(0,0,c,s),this.#g&&this.#P(performance.now(),!1)};dispose(){if(!this.#y){this.#y=!0,this.#we(),oe(this.#M),this.#M=0,window.removeEventListener("resize",this.resize),this.#me?.disconnect(),window.removeEventListener("pointermove",this.#Re,!0),window.removeEventListener("blur",this.#X),document.removeEventListener("visibilitychange",this.#Te),this.#u.removeEventListener("change",this.#Ae),this.#r.removeEventListener("webglcontextlost",this.#_e);for(let e of Object.values(this.#a))this.#e.deleteBuffer(e);this.#e.deleteProgram(this.#n),this.#e.deleteShader(this.#R),this.#e.deleteShader(this.#w),this.#e.getExtension("WEBGL_lose_context")?.loseContext(),this.#o.length=0}}#O(e){let n=this.#e.getAttribLocation(this.#n,e);if(n<0)throw new Error(`Particle shader attribute ${e} is unavailable`);return n}#s(e){let n=this.#e.getUniformLocation(this.#n,e);if(!n)throw new Error(`Particle shader uniform ${e} is unavailable`);return n}#U(){let e=this.#e.createBuffer();if(!e)throw new Error("WebGL could not create a particle buffer");return e}#N(e,n){this.#e.bindBuffer(this.#e.ARRAY_BUFFER,e),this.#e.bufferData(this.#e.ARRAY_BUFFER,n,this.#e.STATIC_DRAW)}#Me(){let e=this.#e;e.bindBuffer(e.ARRAY_BUFFER,this.#a.previousHome),e.enableVertexAttribArray(this.#c.previousHome),e.vertexAttribPointer(this.#c.previousHome,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.#a.home),e.enableVertexAttribArray(this.#c.home),e.vertexAttribPointer(this.#c.home,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.#a.previousVelocity),e.enableVertexAttribArray(this.#c.previousVelocity),e.vertexAttribPointer(this.#c.previousVelocity,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.#a.previousColor),e.enableVertexAttribArray(this.#c.previousColor),e.vertexAttribPointer(this.#c.previousColor,4,e.UNSIGNED_BYTE,!0,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.#a.color),e.enableVertexAttribArray(this.#c.color),e.vertexAttribPointer(this.#c.color,4,e.UNSIGNED_BYTE,!0,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.#a.seed),e.enableVertexAttribArray(this.#c.seed),e.vertexAttribPointer(this.#c.seed,1,e.FLOAT,!1,0,0)}#re(e,n){let t=Math.min(this.#L/Math.max(1,e),this.#B/Math.max(1,n)),r=e*t*this.#T.zoom,o=n*t*this.#T.zoom;return[(this.#L-r)*this.#T.positionX/100,(this.#B-o)*this.#T.positionY/100,r,o]}#ne(){return this.#I*yt}#ie(){return this.#I*bt}#ke(){let e=Math.max(this.#se,.1),n=le/e,t=Math.max(0,this.#ce),r=Math.max(1,this.#le),o=Math.min(xt,wt/r),a=Math.min(St,Et/r),c=u=>{let d=n*u,l=Math.exp(-d),f=(1+(1+t)*d)*l,p=n*(t+(1+t)*d)*l;return f<=o&&p<=a},s=0,h=e;for(let u=0;u<18&&!c(h);u+=1)h*=1.5;for(let u=0;u<24;u+=1){let d=.5*(s+h);c(d)?h=d:s=d}return Math.max(.1,this.#ie()+h)}#oe(){if(this.#V&&this.#j===this.#A)return this.#V;let e=Math.max(.1,this.#ve),n=Math.max(0,this.#A-this.#ge),t=this.#S?Math.min(1,n/e):1,r=_t(t,this.#ye),o={rawProgress:t,elapsed:r.value*e};return this.#j=this.#A,this.#V=o,o}#Pe(){return this.#S?Xe(this.#oe().elapsed-this.#ie()*.35,this.#se):1}#xe(e,n){let t=Math.max(Math.hypot(this.#L,this.#B)*$e,80),r=ue(e/t),o=1-se+n*se*2;return(this.#ne()+r*(this.#I-this.#ne()))*o}#Se(e){if(e.length!==this.#d.length)return!1;let[n,t,r,o]=this.#re(this.#G,this.#H);for(let a=0;a<this.#p;a+=1){let c=a*2;e[c]=n+(this.#d[c]??0)*r,e[c+1]=t+(this.#d[c+1]??0)*o}return!0}#De(){if(!this.#p||this.#m.length!==this.#d.length||this.#f.length!==this.#d.length||this.#h.length!==this.#C.length)return!1;if(!this.#S)return this.#Se(this.#m)?(this.#f.fill(0),this.#h.set(this.#C),!0):!1;let e=this.#oe().elapsed,n=this.#ie(),[t,r,o,a]=this.#re(this.#G,this.#H);for(let c=0;c<this.#p;c+=1){let s=c*2,h=this.#m[s]??0,u=this.#m[s+1]??0,d=t+(this.#d[s]??0)*o,l=r+(this.#d[s+1]??0)*a,f=Math.hypot(d-h,l-u),p=this.#xe(f,this.#z[c]??0),v=h-d,w=u-l,m=this.#f[s]??0,g=this.#f[s+1]??0,y=Math.hypot(m,g)>=.01,R=this.#z[c]??0,T=y?0:R*R*n,E=Math.max(0,e-T),U=Xe(E,p),k=le/p,H=Math.exp(-k*E),I=m+k*v,C=g+k*w;this.#m[s]=d+(v+I*E)*H,this.#m[s+1]=l+(w+C*E)*H,this.#f[s]=0,this.#f[s+1]=0;let V=ue((U-.18)/.82),K=1-V,b=c*4;for(let _=0;_<4;_+=1){let P=b+_;this.#h[P]=Math.round((this.#h[P]??0)*K+(this.#C[P]??0)*V)}}return!0}#Ie(){let[e,n,t,r]=this.#re(this.#G,this.#H),o=this.#ne()*(1-se),a=0,c=0;for(let s=0;s<this.#p;s+=1){let h=s*2,u=e+(this.#d[h]??0)*t,d=n+(this.#d[h+1]??0)*r,l=Math.hypot(u-(this.#m[h]??0),d-(this.#m[h+1]??0));c=Math.max(c,l);let f=this.#xe(l,this.#z[s]??0);o=Math.max(o,f);let p=Math.hypot(this.#f[h]??0,this.#f[h+1]??0),v=le/f;a=Math.max(a,p/(v*Math.max(l,1)))}return this.#le=c,this.#ce=a,o}#Ce(){return this.#S?this.#oe().rawProgress>=1:!0}#we(){let e=this.#W;this.#W=void 0,this.#K=0,e?.(!1)}#Le(e,n){return this.#ge=this.#A,this.#ye=Ze(this.#l.morphCurve),this.#ve=this.#ke(),this.#j=Number.NaN,this.#V=void 0,this.#S=e,this.#Z=!0,this.#J=!0,this.#Q=!0,this.#D(e?0:1,!e),e?new Promise(t=>{this.#K=n,this.#W=t}):Promise.resolve(!0)}#Ee(){if(!this.#S)return;this.#S=!1,this.#j=Number.NaN,this.#V=void 0,this.#J=!0,this.#Q=!0,this.#D(1,!0);let e=this.#W,n=this.#K;this.#W=void 0,this.#K=0,e?.(n===this.#be&&!this.#y)}#pe(e=performance.now()){if(this.#g)return this.#A;let n=Math.min(gt,Math.max(0,(e-this.#_)/1e3));return this.#A+n}#Re=e=>{if(this.#y||this.#g||!this.#l.cursorInteraction||!e.isPrimary)return;let n=this.#r.getBoundingClientRect(),t=e.clientX-n.left,r=e.clientY-n.top;if(t<0||r<0||t>n.width||r>n.height){this.#X();return}let o=this.#pe(),a=this.#te;if(this.#te={x:t,y:r,at:o},!a)return;let c=this.#o.length,s=this.#o.at(-1),h=o-a.at,u=t-a.x,d=r-a.y;if(h<=.001||h>De){s&&(s.sealed=!0);return}let l=Math.hypot(u,d)/h;if(l<1.5){s&&o-s.startedAt>=xe&&(s.sealed=!0);return}s&&!s.sealed&&o-s.startedAt>xe*1.5&&(s.sealed=!0);let f=u/h,p=d/h,{cursorScale:v,overdrive:w,highStrengthScale:m}=this.#$,g=5200*m,y=v>0?Math.min(g,l*(1.04+.14*v)*Math.sqrt(w)):0,R=f/l*y,T=p/l*y,E=s&&o-s.createdAt<=De?s:void 0,U=E?E.velocityX*.28+R*.72:R,k=E?E.velocityY*.28+T*.72:T;s&&!s.sealed?(s.endX=t,s.endY=r,s.velocityX=U,s.velocityY=k,s.createdAt=o,s.duration=Math.max(.001,o-s.startedAt),s.sealed=s.duration>=xe):this.#o.push({startX:a.x,startY:a.y,endX:t,endY:r,velocityX:U,velocityY:k,startedAt:a.at,createdAt:o,duration:h,sealed:h>=xe}),this.#o.length>ne&&this.#o.shift(),this.#F=!0,this.#o.length!==c&&(this.#ee=!0)};#X=()=>{this.#te=void 0;let e=this.#o.at(-1);e&&(e.sealed=!0)};#Te=()=>{if(document.hidden){oe(this.#M),this.#M=0,this.#X(),this.#_=performance.now();return}this.#_=performance.now(),!this.#g&&!this.#u.matches&&this.#Y()};#Ae=()=>{this.#u.matches&&(this.#i=1,this.#E(1)),this.setPaused(this.#u.matches)};#_e=e=>{e.preventDefault(),oe(this.#M),this.#M=0,this.#b("The particle renderer lost its WebGL context. Disable and re-enable the plugin.")};#Y(){this.#y||this.#g||document.hidden||this.#M||(this.#M=Re(this.#r,e=>{this.#M=0,this.#P(e,!0)}))}#P(e,n){if(this.#y)return;let t=this.#i<1;this.#p&&!this.#g&&!document.hidden&&this.#i<1&&(this.#x+=Math.min(.1,Math.max(0,(e-this.#_)/1e3)),this.#i=Math.min(1,Math.max(0,(this.#x-.35)/this.#l.introDuration))),this.#g||(this.#A=this.#pe(e)),this.#_=e;let r=this.#e,o=!1;if(r.clear(r.COLOR_BUFFER_BIT),this.#p>0){let a=this.#A;for(this.#S&&(this.#D(this.#Pe(),!1),o=this.#Ce());this.#o.length&&a-(this.#o[0]?.createdAt??a)>Ke;)this.#o.shift(),this.#F=!0,this.#ee=!0;let c=this.#o.length;this.#F&&this.#v.fill(0),c>0&&this.#k.fill(0);for(let s=0;s<this.#o.length;s+=1){let h=this.#o[s];if(!h)continue;let u=s*4;this.#F&&(this.#v[u]=h.startX,this.#v[u+1]=h.startY,this.#v[u+2]=h.endX,this.#v[u+3]=h.endY),this.#k[u]=h.velocityX,this.#k[u+1]=h.velocityY,this.#k[u+2]=Math.max(0,a-h.createdAt),this.#k[u+3]=Math.max(.001,h.duration)}if(this.#ue&&(r.uniform2f(this.#t.resolution,this.#L,this.#B),r.uniform1f(this.#t.dpr,this.#ae),this.#ue=!1),this.#q){let s=this.#re(this.#G,this.#H);r.uniform4f(this.#t.layout,s[0],s[1],s[2],s[3]),this.#q=!1}if(this.#F&&(c>0&&r.uniform4fv(this.#t.pointerSegments,this.#v),this.#F=!1),this.#ee&&(r.uniform1f(this.#t.pointerCount,c),this.#ee=!1),c>0&&r.uniform4fv(this.#t.pointerMotion,this.#k),r.uniform1f(this.#t.time,a),r.uniform1f(this.#t.introProgress,this.#i),r.uniform1f(this.#t.introReveal,this.#i<1?ue(this.#x/.35):1),r.uniform1f(this.#t.introSpread,this.#l.introSpread),(this.#S||this.#Q)&&(r.uniform1f(this.#t.transitionElapsed,this.#oe().elapsed),this.#Q=!1),this.#Z&&(r.uniform1f(this.#t.transitionNearResponse,this.#ne()),r.uniform1f(this.#t.transitionFarResponse,this.#I),r.uniform1f(this.#t.transitionStagger,this.#ie()),this.#Z=!1),this.#J&&(r.uniform1f(this.#t.transitionActive,this.#S?1:0),this.#J=!1),this.#de){r.uniform1f(this.#t.particleSize,this.#l.particleSize),r.uniform1f(this.#t.particleOpacity,this.#l.particleOpacity),r.uniform1f(this.#t.speed,this.#l.speed),r.uniform1f(this.#t.noiseScale,this.#l.noiseScale),r.uniform1f(this.#t.noiseStrength,this.#l.noiseStrength);let s=Math.min(.9999,Math.max(.8,this.#l.damping));r.uniform1f(this.#t.dampingRate,Math.log(s)/Se),r.uniform1f(this.#t.ambientCycle,this.#l.ambientCycle),r.uniform1f(this.#t.cursorStrength,this.#l.cursorStrength),this.#de=!1}if(this.#he){let s=this.#$;r.uniform3f(this.#t.cursorStrengthScales,s.highStrengthScale,s.stepStrengthScale,s.strength),r.uniform2f(this.#t.cursorStrengthDerived,s.wakeLengthScale,s.squareRootStrength),this.#he=!1}r.drawArrays(r.POINTS,0,this.#p)}o&&this.#Ee(),this.#p&&this.#E(this.#i),t&&this.#i===1&&this.#fe("completed"),n&&this.#Y()}};function Ot(i,e=!1){return new Promise((n,t)=>{if(!("indexedDB"in window)){t(new Error("IndexedDB is unavailable"));return}let r=indexedDB.open(mt,ft),o=!1;r.addEventListener("upgradeneeded",()=>{if(e){o=!0,r.transaction?.abort(),t(new Error("Add/select an image in Particle Image Background before using it as the startup source."));return}let a=r.result;a.objectStoreNames.contains(we)||a.createObjectStore(we,{keyPath:"id"})}),r.addEventListener("success",()=>{let a=r.result;if(o){a.close();return}o=!0,a.addEventListener("versionchange",()=>{a.close(),i()},{once:!0}),n(a)}),r.addEventListener("blocked",()=>{o||(o=!0,t(new Error("The image library database is blocked")))},{once:!0}),r.addEventListener("error",()=>{o||(o=!0,t(r.error??new Error("The image library database could not be opened")))},{once:!0})})}function Ut(i){return new Promise((e,n)=>{let t=i.transaction(we,"readonly").objectStore(we).getAll();t.addEventListener("success",()=>{let r=Array.isArray(t.result)?t.result.filter(o=>{if(!o||typeof o!="object")return!1;let a=o;return typeof a.id=="string"&&typeof a.name=="string"&&typeof a.type=="string"&&typeof a.size=="number"&&typeof a.createdAt=="number"&&a.blob instanceof Blob&&a.thumbnail instanceof Blob}).map(o=>({...o,...de(o)})):[];e(r)}),t.addEventListener("error",()=>n(t.error??new Error("Saved particle images could not be read")),{once:!0})})}function Je(i,e,n=Le){let t=Pt(),r=document.createElement("div");r.dataset.codeCodexStartupParticleImage="v1",r.setAttribute("aria-hidden","true"),Object.assign(r.style,{position:"absolute",inset:"0",overflow:"hidden",backgroundColor:t.backgroundColor,pointerEvents:"none"});let o=document.createElement("img"),a=document.createElement("img");o.className="code-codex-particle-source-previous",a.className="code-codex-particle-source-current";for(let S of[o,a])S.alt="",Object.assign(S.style,{position:"absolute",inset:"0",width:"100%",height:"100%",objectFit:"contain",opacity:"0",transition:"none",pointerEvents:"none"});let c=document.createElement("canvas");c.className="code-codex-particle-canvas",Object.assign(c.style,{position:"absolute",inset:"0",width:"100%",height:"100%"}),r.append(o,a,c),i.append(r);let s=window.matchMedia("(prefers-reduced-motion: reduce)"),h=new Ce,u=new Set,d,l,f=[],p=[],v,w,m,g={...ce},y=!1,R=1,T=!1,E=!1,U=!1,k=0,H,I=0,C=0,V,K,b=new Promise((S,F)=>{V=S,K=F});b.catch(()=>{});function _(S){!S||!u.delete(S)||URL.revokeObjectURL(S)}function P(){window.clearTimeout(I),I=0}function z(){if(!T){T=!0,P(),window.clearTimeout(C),cancelAnimationFrame(k),H?.(),H=void 0,h.dispose(),l?.dispose(),l=void 0,d?.close(),d=void 0,document.removeEventListener("visibilitychange",G),s.removeEventListener("change",G),a.removeAttribute("src"),o.removeAttribute("src");for(let S of[...u])_(S);r.remove(),E||(E=!0,K(new DOMException("Particle startup source was disposed","AbortError")))}}function M(S){if(T)return;let F=S instanceof Error?S.message:String(S),L=new Error(`Particle Image startup source: ${F}`);E||(E=!0,K(L)),z(),e(L.message)}function x(S,F){if(T)return;R=S;let L=t.showSourceImage?t.imageOpacity*Ft(l?.openingProgress??1):0;if(!y){a.style.opacity=String(L),o.style.opacity="0";return}let X=ue(Math.min(1,Math.max(0,S))),B=L*X,W=1-B;o.style.opacity=String(W>Number.EPSILON?Math.min(1,Math.max(0,L*(1-X)/W)):0),a.style.opacity=String(B),F&&(y=!1,R=1,_(m),m=void 0,o.removeAttribute("src"),o.style.opacity="0",a.style.opacity=String(L))}function N(){let S=v?p.indexOf(v):-1,F=p[(S+1+p.length)%p.length];return f.find(L=>L.id===F)}function q(){if(P(),T||U||!t.autoSwitch||document.hidden||s.matches||p.length<2)return;let S=N();!S||S.id===v||(h.prewarm(S,t.particleCount),I=window.setTimeout(()=>{if(I=0,!(T||document.hidden||s.matches)){if((l?.openingRemainingSeconds??0)>0){q();return}O(S).catch(M)}},(t.imageDurationSeconds+(l?.openingRemainingSeconds??0))*1e3))}function G(){document.hidden||s.matches?P():q()}function A(){if(T)throw new DOMException("Particle startup source was disposed","AbortError")}async function O(S){A(),U=!0,P(),C=window.setTimeout(()=>{M(new Error("Image preparation timed out. Choose a smaller or valid image in Particle Image Background."))},Pe);try{let F;try{F=await h.prepare(S,t.particleCount)}catch($){if($ instanceof DOMException&&$.name==="AbortError")throw $;let ot=$ instanceof Error?$.message:String($);throw new Error(`The saved particle image could not be prepared (${ot}). Select a valid image in Particle Image Background.`,{cause:$})}A();let L=URL.createObjectURL(F.processedBlob);u.add(L);let X=new Image;X.src=L;try{await X.decode()}catch($){throw _(L),new Error("The saved image could not be decoded. Select a valid image in Particle Image Background.",{cause:$})}finally{X.removeAttribute("src")}A();let B=de(S),W=!!(w&&l&&l.count===F.targetCount&&!s.matches),Q=w;_(m),m=W?Q:void 0,m?(o.src=m,We(o,g)):(o.removeAttribute("src"),_(Q)),w=L,g=B,a.src=L,We(a,B),y=W,x(W?0:1,!W);let he=await l?.setPreparedImage(F,B);if(A(),!he||!l?.renderPreparedFrame())throw new Error("The particle renderer did not present the saved image.");v=S.id,E||(await new Promise($=>{H=$,k=requestAnimationFrame(()=>{k=requestAnimationFrame(()=>{k=0,H=void 0,$()})})}),A(),r.dataset.codeCodexStartupParticleReady="true",E=!0,V())}finally{window.clearTimeout(C),C=0,U=!1,q()}}return document.addEventListener("visibilitychange",G),s.addEventListener("change",G),C=window.setTimeout(()=>{M(new Error("The saved image library did not become ready. Reopen Particle Image Background and select an image."))},Pe),(async()=>{if(!t.activeImageId&&!t.selectedImageIds.length)throw new Error("Add/select an image in Particle Image Background before using it as the startup source.");let S=await Ot(()=>{M(new Error("The saved image library changed. Reopen the startup preview."))},!0);if(T){S.close();return}d=S,f=(await Ut(S)).sort((B,W)=>B.createdAt-W.createdAt).slice(0,32),A();let F=new Set(f.map(B=>B.id));p=t.selectedImageIds.filter(B=>F.has(B));let L=t.activeImageId&&F.has(t.activeImageId)?t.activeImageId:p[0],X=f.find(B=>B.id===L);if(!X)throw new Error("Add/select an image in Particle Image Background before using it as the startup source.");l=new n(c,M,t,x,()=>x(R,!1)),window.clearTimeout(C),await O(X)})().catch(M),{ready:b,dispose:z}}var Nt=Symbol.for("code-codex:default-galleries:v1"),Fe="__codeCodex_default_media_v1__",Oe=new Map;function Qe(i,e){let n=atob(i),t=new Uint8Array(n.length);for(let r=0;r<n.length;r++)t[r]=n.charCodeAt(r);return new Blob([t],{type:e})}async function et(i){let e=await crypto.subtle.digest("SHA-256",await i.arrayBuffer());return Array.from(new Uint8Array(e),n=>n.toString(16).padStart(2,"0")).join("")}function tt(i){let e=Oe.get(i);if(e)return e;Y("default-media","import","started",{id:i});let n=zt(i).catch(t=>{throw Y("default-media","import","failed",{id:i,reason:String(t)}),t}).finally(()=>Oe.delete(i));return Oe.set(i,n),n}async function zt(i){let n=window[Nt]?.get(i);if(!n)return;if(n.images.size!==n.count)throw new Error(`Default images for ${i} are incomplete. Download the plugin again.`);let t=i==="particle-image"?"code-codex-particle-image-background":"code-codex-pixel-sculpt",r=await new Promise((o,a)=>{let c=indexedDB.open(t,1),s=!1;c.onupgradeneeded=()=>{c.result.objectStoreNames.contains("images")||c.result.createObjectStore("images",{keyPath:"id"})},c.onsuccess=()=>{s?c.result.close():o(c.result)},c.onerror=()=>a(c.error??new Error("Default image storage is unavailable")),c.onblocked=()=>{s=!0,a(new Error("Close the other window using this image library and retry."))}});try{let o=(l,f=!1)=>new Promise((p,v)=>{let w=f?r.transaction(l).objectStore(l).getAll():r.transaction(l).objectStore(l).get(Fe);w.onsuccess=()=>p(w.result),w.onerror=()=>v(w.error)}),a=await o("images");if(a&&a.version>=n.version){Y("default-media","import","already initialized",{id:i,count:n.count,version:n.version});return}let c=(await o("images",!0)).filter(l=>l.file instanceof Blob||l.blob instanceof Blob),s=new Set;for(let l of c){let f=l.file??l.blob;l.sha256?s.add(l.sha256):f instanceof Blob&&[...n.images.values()].some(p=>p.size===f.size)&&s.add(await et(f))}let h=new Set(c.map(l=>l.id)),u=c.reduce((l,f)=>l+(f.file?.size??f.blob?.size??0),0),d=[];for(let l of[...n.images.values()].sort((f,p)=>(f.createdAt??0)-(p.createdAt??0))){if(s.has(l.sha256)||h.has(l.id))continue;if(c.length+d.length>=32||u+l.size>256*1024*1024)throw new Error("There is not enough image-library capacity for the default images. Remove some images and retry.");let f=Qe(l.data,l.type);if(f.size!==l.size||await et(f)!==l.sha256)throw new Error(`Default image ${l.name} failed verification.`);u+=f.size,d.push(i==="pixel-sculpt"?{id:l.id,file:new File([f],l.name,{type:l.type}),order:l.order,sha256:l.sha256}:{id:l.id,name:l.name,type:l.type,size:l.size,createdAt:l.createdAt??d.length+1,blob:f,thumbnail:Qe(l.thumbnail??l.data,l.type),positionX:l.positionX,positionY:l.positionY,zoom:l.zoom,sha256:l.sha256})}if(await new Promise((l,f)=>{let p=r.transaction("images","readwrite"),v=p.objectStore("images"),w=v.get(Fe);w.onsuccess=()=>{if(!(w.result?.version>=n.version)){for(let m of d)p.objectStore("images").add(m);v.put({id:Fe,version:n.version,count:n.count})}},p.oncomplete=()=>l(),p.onerror=()=>f(p.error),p.onabort=()=>f(p.error??new Error("Default image import was cancelled"))}),i==="particle-image"&&c.length===0&&d.length){let l="code-codex:particle-image-background:v1",f={};try{f=JSON.parse(localStorage.getItem(l)??"{}")??{}}catch{}f.selectedImageIds?.length||(f.selectedImageIds=d.map(p=>p.id),f.activeImageId=d[0]?.id,localStorage.setItem(l,JSON.stringify(f)))}Y("default-media","import","passed",{id:i,count:n.count,added:d.length,existing:c.length,version:n.version})}finally{r.close()}}var rt=class extends be{constructor(i,e,n,t,r){super(`"use strict";(()=>{globalThis.window=globalThis;function ge(o,e,n){let t=globalThis,r=e,i=!0,s=!1,l=new Set,a=new Set,u=new EventTarget,c=Object.assign(new EventTarget,{matches:!1,media:"(prefers-reduced-motion: reduce)"}),d=()=>({...r,x:r.left,y:r.top,right:r.left+r.width,bottom:r.top+r.height,toJSON(){return this}}),m=Object.assign(new EventTarget,{getBoundingClientRect:d,closest:()=>null,style:{setProperty(){},removeProperty(){}},dataset:{},contains:()=>!1}),p=new Map,v={},x=new Proxy(o,{get(h,f){if(f==="getBoundingClientRect")return d;if(f==="clientWidth"||f==="offsetWidth")return r.width;if(f==="clientHeight"||f==="offsetHeight")return r.height;if(f==="closest")return()=>null;if(f==="parentElement")return m;if(f==="setPointerCapture"||f==="releasePointerCapture"||f==="replaceWith")return()=>{};if(f==="style")return m.style;if(f==="dataset")return v;if(f==="getContext")return(E,S)=>{if(p.has(E))return p.get(E);let P=h.getContext(E,S);if(!P)return null;let w=null,k=new Map,F=new Proxy(P,{get(T,R){let N=Reflect.get(T,R,T);return typeof N!="function"?N:(k.has(R)||k.set(R,(...O)=>{let H=Reflect.apply(N,T,O);return R==="bindFramebuffer"&&(O[0]===T.FRAMEBUFFER||O[0]===T.DRAW_FRAMEBUFFER)&&(w=O[1]),(R==="drawArrays"||R==="drawElements"||R==="drawArraysInstanced"||R==="drawElementsInstanced")&&w===null&&n(),H}),k.get(R))}});return p.set(E,F),F};let b=Reflect.get(h,f,h);return typeof b=="function"?b.bind(h):b},set(h,f,b){return Reflect.set(h,f,b,h)}});Object.defineProperties(m,{clientWidth:{get:()=>r.width},clientHeight:{get:()=>r.height}});let g=Object.assign(u,{get hidden(){return!i},get visibilityState(){return i?"visible":"hidden"}});Object.defineProperties(g,{hidden:{get:()=>!i},visibilityState:{get:()=>i?"visible":"hidden"}}),t.window=t,t.document=g,t.matchMedia=()=>c,t.Element=class extends EventTarget{},Object.defineProperties(t,{innerWidth:{configurable:!0,get:()=>r.width},innerHeight:{configurable:!0,get:()=>r.height},devicePixelRatio:{configurable:!0,get:()=>r.dpr}}),t.ResizeObserver=class{constructor(h){this.callback=h;l.add(this)}observe(){this.callback([{target:m,contentRect:d()}])}disconnect(){l.delete(this)}},t.IntersectionObserver=class{constructor(h){this.callback=h;a.add(this)}observe(){this.callback([{target:m,isIntersecting:i,intersectionRatio:i?1:0}])}disconnect(){a.delete(this)}};let y=(h,f)=>{let b=new Event(h);for(let[E,S]of Object.entries(f))Object.defineProperty(b,E,{value:S});return b};return{host:m,canvas:x,viewport(h){r=h;for(let f of l)f.callback([{target:m,contentRect:d()}]);t.dispatchEvent(new Event("resize"))},visibility(h){if(i!==h){i=h,u.dispatchEvent(new Event("visibilitychange"));for(let f of a)f.callback([{target:m,isIntersecting:h,intersectionRatio:h?1:0}])}},motion(h){s!==h&&(s=h,c.matches=h,c.dispatchEvent(new Event("change")))},input(h,f){t.dispatchEvent(y(h,f)),m.dispatchEvent(y(h,f)),o.dispatchEvent(y(h,f))},dispose(){l.clear(),a.clear();for(let h of p.values())try{h.getExtension("WEBGL_lose_context")?.loseContext()}catch{}p.clear()}}}function X(o){let e=0,n=0,t=0,r=(i,s)=>{if(++n>8192||s>10)throw Error("BG_ASSET_SHAPE: Visual asset structure exceeds its budget.");if(ArrayBuffer.isView(i)){if((i instanceof Float32Array||i instanceof Float64Array)&&!i.every(Number.isFinite))throw Error("BG_ASSET_NUMBER: Prepared visual numbers must be finite.");if(e+=i.byteLength,e>32*1024*1024)throw Error("BG_ASSET_SIZE: Prepared visual assets exceed 32 MiB.");return i}if(Array.isArray(i))return i.map(a=>r(a,s+1));if(i&&typeof i=="object"&&[Object.prototype,null].includes(Object.getPrototypeOf(i))){let a={};for(let[u,c]of Object.entries(i)){if(U({[u]:null}),t+=new TextEncoder().encode(u).length+4,t>65536)throw Error("BG_ASSET_METADATA: Visual asset metadata exceeds 64 KiB.");a[u]=r(c,s+1)}return a}let l=U(i);if(t+=new TextEncoder().encode(JSON.stringify(l)).length,t>65536)throw Error("BG_ASSET_METADATA: Visual asset metadata exceeds 64 KiB.");return l};return r(o,0)}function U(o){let e=0,n=(r,i)=>{if(++e>4096||i>8)throw Error("BG_STATE_LIMIT: Visual state exceeds the bounded schema.");if(r===null||typeof r=="boolean")return r;if(typeof r=="number"){if(!Number.isFinite(r))throw Error("BG_STATE_NUMBER: Visual numbers must be finite.");return r}if(typeof r=="string"){if(r.length>1024)throw Error("BG_STATE_STRING: Visual strings must be bounded.");return r}if(Array.isArray(r))return r.map(s=>n(s,i+1));if(r&&typeof r=="object"&&[Object.prototype,null].includes(Object.getPrototypeOf(r))){let s={};for(let[l,a]of Object.entries(r)){if(/^(?:__proto__|constructor|prototype|token|accessToken|refreshToken|authorization|cookie|bridge|conversation|history|source|url|path)$/i.test(l))throw Error("BG_STATE_FIELD: Visual state contains an unsupported field.");a!==void 0&&(s[l]=n(a,i+1))}return s}throw Error("BG_STATE_TYPE: Visual state must contain serializable visual values.")},t=n(o,0);if(new TextEncoder().encode(JSON.stringify(t)).length>65536)throw Error("BG_STATE_SIZE: Visual state exceeds the message budget.");return t}function te(o,e){if(![o.width,o.height,o.left,o.top,e].every(Number.isFinite)||o.width<0||o.height<0)throw Error("BG_VIEWPORT_INVALID: Invalid visual dimensions.");let n=Math.max(1,Math.min(8192,o.width)),t=Math.max(1,Math.min(8192,o.height)),r=Math.min(3,Math.max(.5,e),Math.sqrt(16777216/(n*t)));return{width:n,height:t,left:o.left,top:o.top,dpr:r}}var ve=()=>{};function ye(o){ve=o}function re(o,e){ve(o,e)}var Be=/(token|cookie|password|secret|credential|authorization|apikey)/i,Fe=/^(content|text|body|prompt|messages|title|filename|name|raw|data|database64|commandline|sessionid|accountid|threadid|projectid)$|(?:path|url|uri)$/i;function C(o){return o.slice(0,8e3).replace(/\\b[A-Za-z][A-Za-z0-9+.-]*:\\/\\/[^\\s"'<>]+/g,n=>{try{let t=new URL(n);if(["127.0.0.1","localhost","[::1]"].includes(t.hostname)&&!t.username&&!t.password&&["/json/version","/json/list","/"].includes(t.pathname))return\`\${t.origin}\${t.pathname}\`}catch{}return"[url]"}).replace(/(?:\\b[A-Za-z]:[\\\\/]|\\\\\\\\|\\/(?:Users|home|tmp|var|etc|opt|mnt)\\/|~\\/)[^\\r\\n"'<>]*/g,"[path]").replace(/\\b(?:Bearer\\s+\\S+|(?:authorization|password|secret|(?:access[_-]?|refresh[_-]?)?token|api[_-]?key|cookie)\\s*[:=]\\s*[^,;\\r\\n]+)/gi,"[credential]").replace(/\\bsk-[A-Za-z0-9_-]{8,}|\\beyJ[A-Za-z0-9_-]{8,}\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+/g,"[credential]").replace(/\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}\\b/g,"[email]").slice(0,4e3)+(o.length>8e3?" [truncated]":"")}function be(o){let e=256,n=new WeakSet,t=(r,i)=>{if(--e<0||i>6)return"[truncated]";if(typeof r=="string")return C(r);if(r===null||typeof r=="boolean"||typeof r=="number")return r;if(typeof r!="object")return"[unsupported]";if(n.has(r))return"[circular]";if(n.add(r),r instanceof Error)return{name:C(r.name),message:C(r.message)};if(Array.isArray(r))return r.slice(0,128).map(l=>t(l,i+1));let s=Object.create(null);for(let[l,a]of Object.entries(r).slice(0,128)){let u=l.replace(/[^a-z0-9]/gi,"");s[C(l).slice(0,160)]=Be.test(u)||Fe.test(u)?"[redacted]":t(a,i+1)}return s};try{return t(o,0)}catch{return{redactionFailed:!0}}}var Oe=Symbol.for("code-codex:runtime-events:v1"),Ue=window,q=Ue[Oe]??={events:[],dropped:0};function Y(o,e,n,t={}){let r={source:C(o).slice(0,160),action:C(e).slice(0,160),outcome:C(n).slice(0,160),details:{...be(t),observedAt:Date.now(),documentElapsedMs:Math.round(performance.now())}},i=new TextEncoder().encode(JSON.stringify(r)).length;i>7e3&&(r.details={truncated:!0,originalBytes:i,observedAt:Date.now(),documentElapsedMs:Math.round(performance.now())}),q.events.push(r),q.events.length>1e3&&(q.events.splice(0,200),q.dropped+=200)}var Ne=Symbol.for("code-codex:background-startup-hold:v1");function ne(){let o=window;return o[Ne]??={active:!1,layers:new Set,next:-1,pending:new Map,painted:new WeakSet,openings:new WeakMap}}function He(o){return o.closest("[data-code-codex-particle-layer]")}function ze(o,e){e.native=requestAnimationFrame(n=>{let t=ne();e.native=void 0,t.pending.has(o)&&(t.active&&t.painted.has(e.layer)||(t.pending.delete(o),t.active&&(t.painted.add(e.layer),t.layers.add(e.layer),Y("background-opening","initial frame","prepared")),e.callback(n)))})}function oe(o,e){let n=He(o);if(!n)return requestAnimationFrame(e);let t=ne(),r=t.next--,i={layer:n,callback:e};return t.pending.set(r,i),ze(r,i),r}function z(o){if(o>=0){cancelAnimationFrame(o);return}let e=ne(),n=e.pending.get(o);n?.native!==void 0&&cancelAnimationFrame(n.native),e.pending.delete(o)}var Et=Object.freeze({distance:24,elevation:-5.5,azimuth:0,orbitSpeed:0,roll:-20,fov:42,diskInner:3,diskOuter:15,diskThickness:.26,diskDensity:1,brightness:1,spinSpeed:.06,grain:.48,doppler:.35,hotColor:"#FFF3DE",midColor:"#FF9838",coolColor:"#8E3A0B",starBrightness:0,glow:1,exposure:.9,vignette:.28,steps:200,resolution:.4,maxDpr:1,paused:!1}),wt=Object.freeze({variant:"bottom",inertialWheel:!0,openingDuration:2,wheelSensitivity:1,wheelDownIntensity:.4,wheelUpIntensity:.8,wheelTravelScale:1,wheelDownDistance:100,wheelUpDistance:20,wheelUpTrailDistance:18,wheelUpTrailStrength:1.15,wheelUpStiffness:180,wheelUpDamping:48,wheelReleaseDelay:70,wheelUpReleaseDelay:80,maxReleaseVelocity:2.4,returnStiffness:180,returnDamping:14,initialStretch:1.8,initialBlur:0,rimColor:"#FFFFFF",violetColor:"#A558FB",blueColor:"#4922E5",shadowColor:"#000000"}),Rt=Object.freeze({low:Object.freeze({steps:56,resolutionScale:.56,maxDpr:1}),medium:Object.freeze({steps:76,resolutionScale:.72,maxDpr:1.25}),high:Object.freeze({steps:100,resolutionScale:.86,maxDpr:1.5})}),Tt=Object.freeze({quality:"high",speed:.72,intensity:1.15,turbulence:1,radius:3,colorShift:0,pointerInfluence:.45,introDuration:2.2,introFeather:.22,paused:!1}),At=Object.freeze({low:Object.freeze({steps:32,rayScale:.72,maxDpr:1.1,minAdaptiveScale:.92,noiseAtlasSize:512}),medium:Object.freeze({steps:50,rayScale:.76,maxDpr:1.25,minAdaptiveScale:.9,noiseAtlasSize:768}),high:Object.freeze({steps:72,rayScale:.82,maxDpr:1.4,minAdaptiveScale:.9,noiseAtlasSize:1024})}),_t=Object.freeze({hue:0,saturation:1,quality:"medium",speed:1,intensity:1,curtainScale:.5,turbulence:.58,glow:.72,starDensity:.56,introDuration:2.4,introFeather:.16,introStart:-.22,introEnd:1.32,introSkyEnd:.48,introStarStart:.34,paused:!1});function ie(o,e,n,t){let r=typeof o=="number"?o:Number(o);return Number.isFinite(r)?Math.min(n,Math.max(e,r)):t}var Mt=Object.freeze({top:{axis:"y",enter:-100,rest:-50},bottom:{axis:"y",enter:100,rest:50},left:{axis:"x",enter:100,rest:50},right:{axis:"x",enter:-100,rest:-50}});var Pt=Object.freeze({quality:"medium",speed:.35,amplitude:1,frequency:1,zoom:1,rotation:0,exposure:1,timeOffset:5.07,introDuration:2.8,introFeather:.18,introAngle:32,introZoom:.16,introEnabled:!0,paused:!1,colors:Object.freeze(["#d81159","#8f2d56","#218380","#fbb13c","#73d2de"])});var kt=Object.freeze([.72,.46]),It=Math.PI/180;var L=40,Ae=1,_e=.12,Me=Ae+_e,K=Me/L,j=1/64,de=.18,Ge=.1,he=40;var We=3.2/5.2,Ve=1.4/5.2,Pe=.6,G=.08,W=4.7438645,Xe=.0015,qe=.005,Ye=.05,Ke=.2,D=Object.freeze({x1:.42,y1:0,x2:.58,y2:1,nodes:Object.freeze([])}),je=32,A=1e-4,ae=Object.freeze({particleCount:56e4,particleSize:1.8,particleOpacity:.96,speed:.7,noiseScale:1e-4,noiseStrength:.005,damping:.9919,ambientCycle:80,selectedImageIds:Object.freeze([]),activeImageId:null,autoSwitch:!0,imageDurationSeconds:2,morphIntervalSeconds:2.5,morphCurve:D,imageOpacity:1,showSourceImage:!0,backgroundColor:"#000000",cursorStrength:he,cursorInteraction:!0,dprCap:1.5,introEnabled:!0,introDuration:4,introSpread:1}),$=Object.freeze({positionX:50,positionY:50,zoom:1});function xe(o){let e=Math.min(Math.max(o,0),he),n=e*6.25,t=Math.max(e/.64,0),r=Math.max(t/15.625,1),i=Math.max(t/31.25,1),s=Math.max(o/he,1),l=Math.pow(Math.max(t,1),.45)*Math.pow(r,.28)*Math.pow(i,.32)*Math.pow(s,.45),a=Math.pow(Math.max(t,1),.35)*Math.pow(r,.18)*Math.pow(i,.22)*Math.pow(s,.35),u=4*(t<1?t:Math.pow(Math.max(t,1),.55))*Math.pow(r,.3)*Math.pow(i,.34)*s,c=Math.pow(Math.max(t,1),.12)*Math.pow(r,.16)*Math.pow(i,.2);return{baseStrength:e,cursorScale:n,strengthRatio:t,extendedStrength:r,extremeStrength:i,overdrive:s,highStrengthScale:l,stepStrengthScale:a,strength:u,wakeLengthScale:c,squareRootStrength:Math.sqrt(Math.max(u,0))}}function I(o,e=0){return ie(o,0,1,e)}function $e(o){let e=Array.isArray(o)?{nodes:o}:o&&typeof o=="object"?o:D,n=I(e.x1,D.x1),t=I(e.y1,D.y1),r=I(e.x2,D.x2),i=I(e.y2,D.y2);n>r&&([n,r]=[r,n]),t>i&&([t,i]=[i,t]);let s=[],l=Array.isArray(e.nodes)?e.nodes:[];for(let d of l){let m,p;if(Array.isArray(d))m=d[0],p=d[1];else if(d&&typeof d=="object"){let g=d;m=g.time??g.x,p=g.progress??g.y}else continue;let v=Number(m),x=Number(p);!Number.isFinite(v)||!Number.isFinite(x)||s.push({time:I(v),progress:I(x)})}s.sort((d,m)=>d.time-m.time||d.progress-m.progress);let a=[],u=0,c=0;for(let d of s)if(!(d.time<=A||d.time>=1-A||d.progress<=A||d.progress>=1-A||d.time<=u+A||d.progress<=c+A)&&(a.push(d),u=d.time,c=d.progress,a.length>=je))break;return{x1:n,y1:t,x2:r,y2:i,nodes:a}}function Ze(o){return{x1:o.x1,y1:o.y1,x2:o.x2,y2:o.y2,nodes:o.nodes.map(e=>({time:e.time,progress:e.progress}))}}function se(o,e,n){let t=1-o;return 3*t*t*o*e+3*t*o*o*n+o*o*o}function le(o,e,n){let t=1-o;return 3*t*t*e+6*t*o*(n-e)+3*o*o*(1-n)}function Se(o,e,n,t){if(!(n>0))return 0;let r=((2*o+e)*n-o*t)/Math.max(o+e,A);return!Number.isFinite(r)||r<=0||n*t<=0?0:Math.min(r,3*n)}var Ee=new WeakMap;function Je(o){let e=Ee.get(o);if(e)return e;let n=[{time:0,progress:0},...o.nodes,{time:1,progress:1}],t=[],r=[];for(let l=0;l<n.length-1;l+=1){let a=n[l],u=n[l+1];if(!a||!u)continue;let c=Math.max(u.time-a.time,A);t.push(c),r.push(Math.max(0,u.progress-a.progress)/c)}let i=new Array(n.length).fill(0);if(r.length===1)i[0]=r[0]??0,i[1]=r[0]??0;else if(r.length>1){let l=r[0]??0,a=r[1]??l,u=o.x1>A?o.y1/o.x1:Number.NaN,c=1-o.x2,d=c>A?(1-o.y2)/c:Number.NaN;i[0]=Number.isFinite(u)?Math.min(Math.max(0,u),3*l):Se(t[0]??1,t[1]??1,l,a);for(let g=1;g<n.length-1;g+=1){let y=r[g-1]??0,h=r[g]??0;if(y<=0||h<=0){i[g]=0;continue}let f=t[g-1]??1,b=t[g]??1,E=2*b+f,S=b+2*f;i[g]=(E+S)/(E/y+S/h)}let m=r.length-1,p=n.length-1,v=r[m]??0,x=r[m-1]??v;i[p]=Number.isFinite(d)?Math.min(Math.max(0,d),3*v):Se(t[m]??1,t[m-1]??1,v,x)}let s={anchors:n,spans:t,slopes:i};return Ee.set(o,s),s}function Qe(o,e=D){let n=I(o);if(n<=0)return{value:0,slope:0,parameter:0};if(n>=1)return{value:1,slope:0,parameter:1};if(e.nodes.length){let{anchors:c,spans:d,slopes:m}=Je(e),p=0;for(;p<d.length-1&&n>(c[p+1]?.time??1);)p+=1;let v=c[p]??c[0]??{time:0,progress:0},x=c[p+1]??c.at(-1)??{time:1,progress:1},g=d[p]??1,y=Math.min(1,Math.max(0,(n-v.time)/g)),h=y*y,f=h*y,b=2*f-3*h+1,E=f-2*h+y,S=-2*f+3*h,P=f-h,w=m[p]??0,k=m[p+1]??0,F=Math.min(x.progress,Math.max(v.progress,b*v.progress+E*g*w+S*x.progress+P*g*k)),T=(6*h-6*y)*v.progress/g+(3*h-4*y+1)*w+(-6*h+6*y)*x.progress/g+(3*h-2*y)*k;return{value:I(F),slope:Math.min(8,Math.max(0,Number.isFinite(T)?T:0)),parameter:y}}let t=n;for(let c=0;c<5;c+=1){let d=se(t,e.x1,e.x2)-n,m=le(t,e.x1,e.x2);if(Math.abs(d)<1e-5||Math.abs(m)<1e-5)break;t=Math.min(1,Math.max(0,t-d/m))}let r=0,i=1;for(let c=0;c<8;c+=1){let d=se(t,e.x1,e.x2);if(Math.abs(d-n)<1e-5)break;d<n?r=t:i=t,t=.5*(r+i)}let s=I(se(t,e.y1,e.y2)),l=le(t,e.x1,e.x2),a=le(t,e.y1,e.y2),u=l>1e-5?Math.min(8,Math.max(0,a/l)):0;return{value:s,slope:u,parameter:t}}function ue(o,e,n,t,r,i){let s=ie(o,e,n,r),l=e+Math.round((s-e)/t)*t;return Number(Math.min(n,Math.max(e,l)).toFixed(i))}function we(o){let e=o&&typeof o=="object"?o:{};return{positionX:ue(e.positionX,0,100,1,$.positionX,0),positionY:ue(e.positionY,0,100,1,$.positionY,0),zoom:ue(e.zoom,.25,4,.05,$.zoom,2)}}var et=\`
680
+ precision highp float;
681
+ attribute vec2 a_previousHome;
682
+ attribute vec2 a_home;
683
+ attribute vec2 a_previousVelocity;
684
+ attribute vec4 a_previousColor;
685
+ attribute vec4 a_color;
686
+ attribute float a_seed;
687
+
688
+ uniform vec2 u_resolution;
689
+ uniform vec4 u_layout;
690
+ uniform vec4 u_pointerSegments[\${L}];
691
+ uniform vec4 u_pointerMotion[\${L}];
692
+ uniform float u_pointerCount;
693
+ uniform float u_time;
694
+ uniform float u_introProgress;
695
+ uniform float u_introReveal;
696
+ uniform float u_introSpread;
697
+ uniform float u_transitionElapsed;
698
+ uniform float u_transitionNearResponse;
699
+ uniform float u_transitionFarResponse;
700
+ uniform float u_transitionStagger;
701
+ uniform float u_transitionActive;
702
+ uniform float u_dpr;
703
+ uniform float u_particleSize;
704
+ uniform float u_particleOpacity;
705
+ uniform float u_speed;
706
+ uniform float u_noiseScale;
707
+ uniform float u_noiseStrength;
708
+ // log(damping) / fixed simulation step, precomputed once when settings change.
709
+ uniform float u_dampingRate;
710
+ uniform float u_ambientCycle;
711
+ uniform float u_cursorStrength;
712
+ // x/y/z = highStrengthScale/stepStrengthScale/strength.
713
+ uniform vec3 u_cursorStrengthScales;
714
+ // x/y = wakeLengthScale/squareRootStrength; both are invariant per draw.
715
+ uniform vec2 u_cursorStrengthDerived;
716
+
717
+ varying vec4 v_color;
718
+
719
+ float hash(float value) {
720
+ return fract(sin(value * 91.317) * 47453.5453);
721
+ }
722
+
723
+ float smoother01(float value) {
724
+ float t = clamp(value, 0.0, 1.0);
725
+ return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
726
+ }
727
+
728
+ vec2 softLimit(vec2 value, float maximum) {
729
+ float maximumSquared = max(maximum * maximum, 0.0001);
730
+ return value * inversesqrt(1.0 + dot(value, value) / maximumSquared);
731
+ }
732
+
733
+ vec2 ambientFlow(float sampleTime, vec2 homePosition) {
734
+ float seedAngle = a_seed * 6.2831853;
735
+ float flowTime = sampleTime * u_speed * 200.0 / max(u_ambientCycle, 1.0);
736
+ float spatial = max(u_noiseScale, 0.00001) * 6.2831853;
737
+ float waveA = sin(homePosition.y * spatial + flowTime * 0.63 + seedAngle);
738
+ float waveB = cos(homePosition.x * spatial * 1.37 - flowTime * 0.48 + seedAngle * 0.71);
739
+ float angle = waveA * 2.3 + waveB * 1.7 + seedAngle;
740
+ float breathing = 0.58 + 0.42 * sin(flowTime * 0.82 + seedAngle * 2.0);
741
+ return vec2(cos(angle), sin(angle)) * u_noiseStrength * 520.0 * breathing;
742
+ }
743
+
744
+ float directionalWakeGain(vec2 position, vec2 cursorStart, vec2 cursorEnd, float radius) {
745
+ vec2 cursorStep = cursorEnd - cursorStart;
746
+ float cursorDistance = length(cursorStep);
747
+ if (cursorDistance < 0.001) return 0.0;
748
+ vec2 tangent = cursorStep / cursorDistance;
749
+ vec2 normal = vec2(-tangent.y, tangent.x);
750
+ vec2 fromCursor = position - cursorEnd;
751
+ float trailDistance = -dot(fromCursor, tangent);
752
+ float lateralOffset = dot(fromCursor, normal);
753
+ float wakeLength = radius * 4.5;
754
+ float wakeProgress = clamp(trailDistance / max(wakeLength, 1.0), 0.0, 1.0);
755
+ float wakeEndWidth = radius * 2.35 * sqrt(1.0 / 0.40);
756
+ float wakeWidthSquared = mix(radius * radius, wakeEndWidth * wakeEndWidth, wakeProgress);
757
+ float wakeProgressSquared = wakeProgress * wakeProgress;
758
+ float wakeMetric = lateralOffset * lateralOffset / max(wakeWidthSquared, 1.0)
759
+ + wakeProgressSquared * wakeProgressSquared;
760
+ float rearBase = max(0.0, 1.0 - wakeMetric);
761
+ float rearSupport = rearBase * rearBase * rearBase;
762
+ float frontDistance = max(-trailDistance, 0.0);
763
+ float frontLength = radius * 0.72;
764
+ float frontMetric = frontDistance * frontDistance / max(frontLength * frontLength, 1.0)
765
+ + lateralOffset * lateralOffset / max(radius * radius, 1.0);
766
+ float frontBase = max(0.0, 1.0 - frontMetric);
767
+ float frontSupport = frontBase * frontBase * frontBase;
768
+ float support = mix(frontSupport, rearSupport, step(0.0, trailDistance));
769
+ float coreAxial = 1.0 - smoother01(abs(trailDistance) / max(radius * 0.82, 1.0));
770
+ float coreLateral = 1.0 - smoother01(abs(lateralOffset) / max(radius * 0.28, 1.0));
771
+ return support * (1.10 + 2.90 * coreAxial * coreLateral);
772
+ }
773
+
774
+ void coastGas(
775
+ inout vec2 position,
776
+ inout vec2 gasVelocity,
777
+ float elapsed,
778
+ float maximumVelocity,
779
+ float maximumStep
780
+ ) {
781
+ float dt = max(elapsed, 0.0);
782
+ if (dt <= 0.00001) return;
783
+ float decayRate = u_dampingRate;
784
+ float decay = exp(decayRate * dt);
785
+ float travelTime = abs(decayRate) > 0.00001
786
+ ? (decay - 1.0) / decayRate
787
+ : dt;
788
+ float stepBudget = maximumStep * max(dt / \${j.toFixed(6)}, 0.25);
789
+ position += softLimit(gasVelocity * travelTime, stepBudget);
790
+ gasVelocity = softLimit(gasVelocity * decay, maximumVelocity);
791
+ }
792
+
793
+ void stirGas(
794
+ inout vec2 position,
795
+ inout vec2 gasVelocity,
796
+ inout vec2 previousTangent,
797
+ inout float hasTangent,
798
+ vec2 cursorStart,
799
+ vec2 cursorEnd,
800
+ vec2 filteredVelocity,
801
+ float elapsed,
802
+ float segmentPhase,
803
+ float maximumVelocity,
804
+ float maximumStep,
805
+ float influenceRadius
806
+ ) {
807
+ float dt = clamp(elapsed, 0.0, \${de.toFixed(2)});
808
+ if (dt <= 0.00001) return;
809
+ vec2 cursorStep = cursorEnd - cursorStart;
810
+ float cursorDistance = length(cursorStep);
811
+ float moving = step(0.001, cursorDistance) * step(0.0001, u_cursorStrength);
812
+ if (moving < 0.5) {
813
+ coastGas(position, gasVelocity, dt, maximumVelocity, maximumStep);
814
+ return;
815
+ }
816
+
817
+ vec2 tangent = cursorStep / max(cursorDistance, 0.001);
818
+ vec2 normal = vec2(-tangent.y, tangent.x);
819
+ float influence = clamp(
820
+ directionalWakeGain(position, cursorStart, cursorEnd, influenceRadius) * 0.25,
821
+ 0.0,
822
+ 1.0
823
+ );
824
+ vec2 cursorVelocity = cursorStep / dt;
825
+ vec2 driverVelocity = mix(cursorVelocity, filteredVelocity, 0.28);
826
+ driverVelocity = softLimit(driverVelocity, 2200.0 * max(maximumVelocity / 340.0, 1.0));
827
+ float driverSpeed = length(driverVelocity);
828
+
829
+ float cursorLengthSquared = dot(cursorStep, cursorStep);
830
+ float along = clamp(
831
+ dot(position - cursorStart, cursorStep) / max(cursorLengthSquared, 0.0001),
832
+ 0.0,
833
+ 1.0
834
+ );
835
+ vec2 closestCursor = cursorStart + cursorStep * along;
836
+ vec2 radial = position - closestCursor;
837
+ float radialLength = length(radial);
838
+ vec2 radialDirection = radial / max(radialLength, 0.001);
839
+ vec2 swirlDirection = vec2(-radialDirection.y, radialDirection.x);
840
+
841
+ float turn = hasTangent
842
+ * (previousTangent.x * tangent.y - previousTangent.y * tangent.x);
843
+ float directionAlignment = dot(previousTangent, tangent);
844
+ float reversal = hasTangent * step(directionAlignment, -0.4);
845
+ float seededVariation = hash(a_seed * 71.17 + segmentPhase * 13.31) * 2.0 - 1.0;
846
+ float curlEnvelope = influence * (1.0 - influence);
847
+
848
+ vec2 oldVelocity = gasVelocity;
849
+ float decay = exp(u_dampingRate * dt);
850
+ vec2 nextVelocity = oldVelocity * decay;
851
+ float flowResponse = 1.0 - exp(-5.2 * influence * u_cursorStrengthScales.z * dt);
852
+ nextVelocity = mix(nextVelocity, driverVelocity, flowResponse);
853
+ nextVelocity *= mix(1.0, 0.76, reversal * influence);
854
+ nextVelocity += normal * driverSpeed
855
+ * (0.85 * turn * curlEnvelope * u_cursorStrengthScales.z) * dt;
856
+ nextVelocity += swirlDirection * driverSpeed
857
+ * (0.48 * turn * curlEnvelope * u_cursorStrengthScales.z) * dt;
858
+ nextVelocity += normal * driverSpeed
859
+ * (0.025 * seededVariation * curlEnvelope * u_cursorStrengthScales.z) * dt;
860
+
861
+ float segmentEnergy = smoother01(
862
+ cursorDistance / max(influenceRadius * 0.55, 1.0)
863
+ );
864
+ vec2 fromCursorEnd = position - cursorEnd;
865
+ float signedTrailDistance = -dot(fromCursorEnd, tangent);
866
+ float downstream = max(signedTrailDistance, 0.0);
867
+ float upstream = max(-signedTrailDistance, 0.0);
868
+ float lateralOffset = dot(fromCursorEnd, normal);
869
+ float speedEnergy = smoother01(driverSpeed / 1500.0);
870
+ float wakeLength = influenceRadius
871
+ * mix(4.5, 10.0, speedEnergy)
872
+ * u_cursorStrengthDerived.x;
873
+ float wakeProgress = clamp(downstream / max(wakeLength, 1.0), 0.0, 1.0);
874
+ float originalEndScale = mix(2.15, 2.65, speedEnergy);
875
+ float wakeStartSquared = influenceRadius * influenceRadius;
876
+ float wakeEndSquared = wakeStartSquared
877
+ + wakeStartSquared * (originalEndScale * originalEndScale - 1.0) / 0.40;
878
+ float wakeWidthSquared = mix(
879
+ wakeStartSquared,
880
+ wakeEndSquared,
881
+ wakeProgress
882
+ );
883
+ float wakeWidth = sqrt(max(wakeWidthSquared, 1.0));
884
+ float wakeProgressSquared = wakeProgress * wakeProgress;
885
+ float wakeMetric = lateralOffset * lateralOffset / max(wakeWidthSquared, 1.0)
886
+ + wakeProgressSquared * wakeProgressSquared;
887
+ float rearBase = max(0.0, 1.0 - wakeMetric);
888
+ float rearSupport = rearBase * rearBase * rearBase;
889
+ float frontLength = influenceRadius * 0.75;
890
+ float frontMetric = upstream * upstream / max(frontLength * frontLength, 1.0)
891
+ + lateralOffset * lateralOffset / max(influenceRadius * influenceRadius, 1.0);
892
+ float frontBase = max(0.0, 1.0 - frontMetric);
893
+ float frontSupport = frontBase * frontBase * frontBase;
894
+ float wakeGain = segmentEnergy * mix(frontSupport, rearSupport, step(0.0, signedTrailDistance));
895
+ float side = sign(lateralOffset);
896
+ vec2 entrainmentDirection = -normal * side;
897
+ float entrainmentGain = smoother01(abs(lateralOffset) / max(wakeWidth, 1.0));
898
+ vec2 wakeVelocity = driverVelocity * (0.24 * wakeGain);
899
+ wakeVelocity += entrainmentDirection * driverSpeed
900
+ * (0.11 * wakeGain * entrainmentGain);
901
+ wakeVelocity += normal * driverSpeed * (0.18 * turn * wakeGain);
902
+
903
+ vec2 segmentCenter = 0.5 * (cursorStart + cursorEnd);
904
+ vec2 farOffset = position - segmentCenter;
905
+ float farDistance = length(farOffset);
906
+ vec2 farDirection = farOffset / max(farDistance, 0.001);
907
+ float alignment = dot(tangent, farDirection);
908
+ vec2 dipoleDirection = 2.0 * alignment * farDirection - tangent;
909
+ float pressureStart = smoother01(
910
+ (farDistance / max(influenceRadius, 1.0) - 1.15) / 0.85
911
+ );
912
+ float pressureDistance = farDistance / max(influenceRadius * 4.5, 1.0);
913
+ float pressureGain = segmentEnergy * pressureStart
914
+ / (1.0 + pressureDistance * pressureDistance);
915
+ vec2 pressureVelocity = dipoleDirection * driverSpeed * (0.018 * pressureGain);
916
+ float inducedResponse = 1.0 - exp(-1.15 * u_cursorStrengthDerived.y * dt);
917
+ nextVelocity += (wakeVelocity + pressureVelocity) * inducedResponse;
918
+ nextVelocity = softLimit(nextVelocity, maximumVelocity);
919
+
920
+ vec2 particleStep = 0.5 * (oldVelocity + nextVelocity) * dt;
921
+ float stepBudget = maximumStep
922
+ * max(dt / \${j.toFixed(6)}, 0.25);
923
+ position += softLimit(particleStep, stepBudget);
924
+ gasVelocity = nextVelocity;
925
+ previousTangent = tangent;
926
+ hasTangent = 1.0;
927
+ }
928
+
929
+ void main() {
930
+ vec2 targetHome = u_layout.xy + a_home * u_layout.zw;
931
+ vec2 home = targetHome;
932
+ vec4 imageColor = a_color;
933
+ if (u_transitionActive > 0.5) {
934
+ vec2 transitionDelta = targetHome - a_previousHome;
935
+ float transitionDistance = length(transitionDelta);
936
+ float transitionDistanceReference = max(
937
+ length(u_resolution) * \${Pe.toFixed(2)},
938
+ 80.0
939
+ );
940
+ float transitionDistanceFactor = smoother01(
941
+ transitionDistance / transitionDistanceReference
942
+ );
943
+ float transitionVariation = mix(
944
+ \${(1-G).toFixed(2)},
945
+ \${(1+G).toFixed(2)},
946
+ a_seed
947
+ );
948
+ float transitionResponse = mix(
949
+ u_transitionNearResponse,
950
+ u_transitionFarResponse,
951
+ transitionDistanceFactor
952
+ ) * transitionVariation;
953
+ float transitionElapsed = max(u_transitionElapsed, 0.0);
954
+ float carriedVelocity = step(0.01, length(a_previousVelocity));
955
+ float transitionDelay = a_seed * a_seed
956
+ * u_transitionStagger
957
+ * (1.0 - carriedVelocity);
958
+ float springElapsed = max(transitionElapsed - transitionDelay, 0.0);
959
+ float transitionOmega = \${W.toFixed(7)}
960
+ / max(transitionResponse, 0.10);
961
+ float transitionSpringTime = transitionOmega * springElapsed;
962
+ float transitionDecay = exp(-transitionSpringTime);
963
+ float transitionProgress = clamp(
964
+ 1.0 - (1.0 + transitionSpringTime) * transitionDecay,
965
+ 0.0,
966
+ 1.0
967
+ );
968
+ vec2 displacement = a_previousHome - targetHome;
969
+ vec2 velocityTerm = a_previousVelocity
970
+ + transitionOmega * displacement;
971
+ home = targetHome + (
972
+ displacement + velocityTerm * springElapsed
973
+ ) * transitionDecay;
974
+ float transitionColorProgress = smoother01(
975
+ (transitionProgress - 0.18) / 0.82
976
+ );
977
+ imageColor = mix(
978
+ a_previousColor,
979
+ a_color,
980
+ transitionColorProgress
981
+ );
982
+ }
983
+
984
+ float lifetime = \${Ae.toFixed(2)}
985
+ + (hash(a_seed * 53.17 + 7.9) * 2.0 - 1.0)
986
+ * \${_e.toFixed(2)};
987
+ float age = mod(u_time + a_seed * lifetime, lifetime);
988
+ float fadeIn = smoother01(age / 0.18);
989
+ float fadeOut = 1.0 - smoother01((age - (lifetime - 0.18)) / 0.18);
990
+ float lifeAlpha = fadeIn * fadeOut;
991
+ float birthTime = u_time - age;
992
+ vec2 ambientAtBirth = ambientFlow(birthTime, home);
993
+ vec2 position = home + ambientAtBirth;
994
+ vec2 gasVelocity = vec2(0.0);
995
+ vec2 previousTangent = vec2(1.0, 0.0);
996
+ float hasTangent = 0.0;
997
+ float integratedAge = 0.0;
998
+
999
+ if (u_pointerCount > 0.5 && u_cursorStrength > 0.0001) {
1000
+ float radiusVariation = mix(0.90, 1.10, hash(a_seed * 43.71 + 2.19));
1001
+ float influenceRadius = clamp(
1002
+ min(u_resolution.x, u_resolution.y) * 0.16,
1003
+ 95.0,
1004
+ 175.0
1005
+ ) * radiusVariation * 0.50;
1006
+ float motionReferenceRadius = influenceRadius / 1.5;
1007
+ float maximumVelocity = clamp(
1008
+ motionReferenceRadius * 0.42 / \${j.toFixed(6)},
1009
+ 180.0,
1010
+ 340.0
1011
+ ) * u_cursorStrengthScales.x;
1012
+ float maximumStep = clamp(motionReferenceRadius * 0.42, 8.0, 20.0)
1013
+ * u_cursorStrengthScales.y;
1014
+
1015
+ for (int index = 0; index < \${L}; index += 1) {
1016
+ if (float(index) >= u_pointerCount) break;
1017
+ vec4 motion = u_pointerMotion[index];
1018
+ float segmentAge = motion.z;
1019
+ if (segmentAge > age) continue;
1020
+ vec4 segment = u_pointerSegments[index];
1021
+ float segmentDuration = max(motion.w, 0.0001);
1022
+ float segmentEndAge = clamp(age - segmentAge, 0.0, age);
1023
+ float segmentStartAge = max(0.0, segmentEndAge - segmentDuration);
1024
+ coastGas(
1025
+ position,
1026
+ gasVelocity,
1027
+ max(segmentStartAge - integratedAge, 0.0),
1028
+ maximumVelocity,
1029
+ maximumStep
1030
+ );
1031
+ float activeStartAge = max(integratedAge, segmentStartAge);
1032
+ float activeDuration = max(segmentEndAge - activeStartAge, 0.0);
1033
+ if (activeDuration > 0.00001) {
1034
+ float activeFraction = clamp(activeDuration / segmentDuration, 0.0, 1.0);
1035
+ vec2 activeCursorStart = mix(segment.zw, segment.xy, activeFraction);
1036
+ stirGas(
1037
+ position,
1038
+ gasVelocity,
1039
+ previousTangent,
1040
+ hasTangent,
1041
+ activeCursorStart,
1042
+ segment.zw,
1043
+ motion.xy,
1044
+ activeDuration,
1045
+ float(index),
1046
+ maximumVelocity,
1047
+ maximumStep,
1048
+ influenceRadius
1049
+ );
1050
+ }
1051
+ integratedAge = max(integratedAge, segmentEndAge);
1052
+ }
1053
+
1054
+ coastGas(
1055
+ position,
1056
+ gasVelocity,
1057
+ max(age - integratedAge, 0.0),
1058
+ maximumVelocity,
1059
+ maximumStep
1060
+ );
1061
+ }
1062
+ vec2 ambientNow = ambientFlow(u_time, home);
1063
+ position += ambientNow - ambientAtBirth;
1064
+ vec2 restingPosition = home + ambientNow;
1065
+ float disturbed = smoothstep(0.75, 3.0, length(position - restingPosition));
1066
+ float lifecycleAlpha = mix(1.0, lifeAlpha, disturbed);
1067
+ // A dispersed image-coloured cloud contracts into the photograph. At one,
1068
+ // bypass every opening term to preserve the original steady-state rendering.
1069
+ float openingAlpha = 1.0;
1070
+ if (u_introProgress < 1.0) {
1071
+ float delay = hash(a_seed * 71.3 + 4.7) * 0.22;
1072
+ float localProgress = smoother01((u_introProgress - delay) / (1.0 - delay));
1073
+ float remaining = 1.0 - localProgress;
1074
+ float angle = hash(a_seed * 39.7 + 8.1) * 6.2831853;
1075
+ float radius = (0.18 + 0.72 * sqrt(hash(a_seed * 23.9 + 1.3)))
1076
+ * min(u_resolution.x, u_resolution.y) * u_introSpread;
1077
+ vec2 cloud = u_resolution * 0.5 + vec2(cos(angle), sin(angle)) * radius;
1078
+ vec2 tangent = vec2(-sin(angle), cos(angle));
1079
+ position = mix(position, cloud, remaining)
1080
+ + tangent * radius * sin(localProgress * 3.14159265) * remaining * 0.24;
1081
+ openingAlpha = mix(0.35, 1.0, smoother01(u_introProgress / 0.65));
1082
+ }
1083
+ vec2 clip = vec2(position.x / u_resolution.x * 2.0 - 1.0, 1.0 - position.y / u_resolution.y * 2.0);
1084
+ gl_Position = vec4(clip, 0.0, 1.0);
1085
+ gl_PointSize = max(1.0, u_particleSize * u_dpr);
1086
+ v_color = vec4(imageColor.rgb, imageColor.a * u_particleOpacity * lifecycleAlpha * openingAlpha * u_introReveal);
1087
+ }
1088
+ \`,tt=\`
1089
+ precision mediump float;
1090
+ varying vec4 v_color;
1091
+ void main() {
1092
+ vec2 centred = gl_PointCoord - vec2(0.5);
1093
+ float distanceFromCentre = length(centred);
1094
+ float coverage = 1.0 - smoothstep(0.28, 0.5, distanceFromCentre);
1095
+ if (coverage <= 0.001) discard;
1096
+ gl_FragColor = vec4(v_color.rgb, v_color.a * coverage);
1097
+ }
1098
+ \`;function Re(o,e,n){let t=o.createShader(e);if(!t)throw new Error("WebGL could not create a particle shader");if(o.shaderSource(t,n),o.compileShader(t),!o.getShaderParameter(t,o.COMPILE_STATUS)){let r=o.getShaderInfoLog(t)||"Particle shader compilation failed";throw o.deleteShader(t),new Error(r)}return t}function rt(o){let e=Re(o,o.VERTEX_SHADER,et),n=Re(o,o.FRAGMENT_SHADER,tt),t=o.createProgram();if(!t)throw new Error("WebGL could not create the particle program");if(o.attachShader(t,e),o.attachShader(t,n),o.linkProgram(t),!o.getProgramParameter(t,o.LINK_STATUS)){let r=o.getProgramInfoLog(t)||"Particle shader linking failed";throw o.deleteProgram(t),o.deleteShader(e),o.deleteShader(n),new Error(r)}return{program:t,vertexShader:e,fragmentShader:n}}function ce(o){let e=Math.min(1,Math.max(0,o));return e*e*e*(e*(e*6-15)+10)}function Te(o,e){let t=W/Math.max(e,.1)*Math.max(0,o);return Math.min(1,Math.max(0,1-(1+t)*Math.exp(-t)))}var Z=class{#d;#n;#L;#me;#fe;#u;#e;#l;#i=[];#T=new Float32Array(L*4);#A=new Float32Array(L*4);#m=window.matchMedia("(prefers-reduced-motion: reduce)");#pe;#W;#V;#E=0;#o=1;#f=new Float32Array(0);#p=new Float32Array(0);#g=new Float32Array(0);#w=new Uint8Array(0);#_=new Uint8Array(0);#B=new Float32Array(0);#F=1;#O=1;#v={...$};#a=0;#M=1;#P=1;#ne=1;#y=12.4;#b=performance.now();#ge=0;#R=ae.morphIntervalSeconds;#ve=ae.morphIntervalSeconds;#ye=Ze(D);#X=Number.NaN;#U;#oe=ae.morphIntervalSeconds;#ie=0;#ae=0;#h=!1;#q=0;#N;#be=0;#r;#Y;#se=!0;#H=!0;#le=!0;#K=!0;#j=!0;#$=!0;#k=!0;#Z=!0;#ue=!0;#x=0;#c=!1;#s=!1;#ce;#J;constructor(e,n,t,r,i=()=>{}){this.#d=e,this.#pe=n,this.#r=t,this.#Y=xe(t.cursorStrength),this.#W=r,this.#V=i;let s=e.getContext("webgl",{alpha:!0,antialias:!1,depth:!1,stencil:!1,premultipliedAlpha:!1,powerPreference:"high-performance"});if(!s)throw new Error("WebGL is unavailable");this.#n=s;let l=rt(s);this.#L=l.program,this.#me=l.vertexShader,this.#fe=l.fragmentShader,this.#u={previousHome:this.#I("a_previousHome"),home:this.#I("a_home"),previousVelocity:this.#I("a_previousVelocity"),previousColor:this.#I("a_previousColor"),color:this.#I("a_color"),seed:this.#I("a_seed")},this.#e={resolution:this.#t("u_resolution"),layout:this.#t("u_layout"),pointerSegments:this.#t("u_pointerSegments[0]"),pointerMotion:this.#t("u_pointerMotion[0]"),pointerCount:this.#t("u_pointerCount"),time:this.#t("u_time"),introProgress:this.#t("u_introProgress"),introReveal:this.#t("u_introReveal"),introSpread:this.#t("u_introSpread"),transitionElapsed:this.#t("u_transitionElapsed"),transitionNearResponse:this.#t("u_transitionNearResponse"),transitionFarResponse:this.#t("u_transitionFarResponse"),transitionStagger:this.#t("u_transitionStagger"),transitionActive:this.#t("u_transitionActive"),dpr:this.#t("u_dpr"),particleSize:this.#t("u_particleSize"),particleOpacity:this.#t("u_particleOpacity"),speed:this.#t("u_speed"),noiseScale:this.#t("u_noiseScale"),noiseStrength:this.#t("u_noiseStrength"),dampingRate:this.#t("u_dampingRate"),ambientCycle:this.#t("u_ambientCycle"),cursorStrength:this.#t("u_cursorStrength"),cursorStrengthScales:this.#t("u_cursorStrengthScales"),cursorStrengthDerived:this.#t("u_cursorStrengthDerived")},this.#l={previousHome:this.#C(),home:this.#C(),previousVelocity:this.#C(),previousColor:this.#C(),color:this.#C(),seed:this.#C()},s.useProgram(this.#L),s.enable(s.BLEND),s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),s.disable(s.DEPTH_TEST),s.clearColor(0,0,0,0),this.#Me(),this.resize(),typeof ResizeObserver=="function"&&(this.#ce=new ResizeObserver(this.resize),this.#ce.observe(e)),window.addEventListener("resize",this.resize,{passive:!0}),window.addEventListener("pointermove",this.#Re,{capture:!0,passive:!0}),window.addEventListener("blur",this.#z,{passive:!0}),document.addEventListener("visibilitychange",this.#Te),this.#m.addEventListener("change",this.#Ae),e.addEventListener("webglcontextlost",this.#_e),this.#s=document.hidden||this.#m.matches,this.#G()}get count(){return this.#a}get openingProgress(){return this.#o}get openingRemainingSeconds(){return this.#o<1?Math.max(0,this.#r.introDuration+.35-this.#E):0}replayOpening(){this.#c||!this.#a||(this.#E=0,this.#o=this.#r.introEnabled&&!this.#m.matches?0:1,this.#de("replayed"),this.#b=performance.now(),this.#z(),this.#S(this.#b,!1),this.#G())}setRenderSettings(e){if(this.#c)return;let n=this.#r,t=e.dprCap!==n.dprCap,r=n.cursorInteraction&&!e.cursorInteraction,i=e.morphIntervalSeconds!==n.morphIntervalSeconds;if((e.particleSize!==n.particleSize||e.particleOpacity!==n.particleOpacity||e.speed!==n.speed||e.noiseScale!==n.noiseScale||e.noiseStrength!==n.noiseStrength||e.damping!==n.damping||e.ambientCycle!==n.ambientCycle||e.cursorStrength!==n.cursorStrength)&&(this.#le=!0),e.cursorStrength!==n.cursorStrength&&(this.#Y=xe(e.cursorStrength),this.#ue=!0),this.#r=e,e.introEnabled?n.introEnabled?this.#o<1&&e.introDuration!==n.introDuration&&(this.#E=this.#o*e.introDuration):this.replayOpening():(this.#o=1,this.#V(1)),this.#h||(this.#R=e.morphIntervalSeconds,i&&(this.#K=!0)),r){this.#J=void 0;let s=this.#i.at(-1);s&&(s.sealed=!0)}t?this.resize():this.#s&&this.#S(performance.now(),!1)}setPreparedImage(e,n){if(this.#c)return Promise.resolve(!1);let t=performance.now(),r=this.#a===0;this.#s||(this.#y=this.#he(t)),this.#b=t;let i=++this.#be;this.#Ee();let s=this.#a===e.targetCount&&this.#a>0&&!this.#m.matches&&this.#Ie();this.#p=e.normalizedHomes,this.#_=e.colors,this.#B=e.seeds,this.#F=e.width,this.#O=e.height,this.#v=we(n),this.#a=e.targetCount,r&&(this.#E=0,this.#o=this.#r.introEnabled&&!this.#m.matches?0:1,this.#de("started")),this.#R=this.#r.morphIntervalSeconds,this.#H=!0,s||(this.#f=new Float32Array(e.targetCount*2),this.#g=new Float32Array(e.targetCount*2),this.#w=new Uint8Array(e.targetCount*4),this.#Se(this.#f),this.#w.set(this.#_)),this.#oe=s?this.#Ce():this.#R,s||(this.#ie=0,this.#ae=0),this.#D(this.#l.previousHome,this.#f),this.#D(this.#l.home,this.#p),this.#D(this.#l.previousVelocity,this.#g),this.#D(this.#l.previousColor,this.#w),this.#D(this.#l.color,this.#_),this.#D(this.#l.seed,this.#B);let l=this.#Le(s,i);return(this.#s||!s)&&this.#S(performance.now(),!1),l}renderPreparedFrame(){return this.#c||this.#a<=0||this.#n.isContextLost()?!1:(this.#S(performance.now(),!1),this.#n.flush(),!0)}resumeOpening(){this.#c||this.replayOpening()}#de(e){Y("particle-image","particle gathering",e,{normalBackground:!!this.#d.closest("[data-code-codex-particle-layer]"),durationSeconds:this.#r.introDuration,spread:this.#r.introSpread,enabled:this.#r.introEnabled,reducedMotion:this.#m.matches,progress:this.#o})}setImageTransform(e){if(this.#c)return;let n=we(e);n.positionX===this.#v.positionX&&n.positionY===this.#v.positionY&&n.zoom===this.#v.zoom||(this.#v=n,this.#H=!0,this.#s&&this.#S(performance.now(),!1))}setPaused(e){this.#s=e||document.hidden||this.#m.matches,this.#b=performance.now(),this.#s&&this.#h&&this.#we(),this.#s?this.#S(performance.now(),!1):this.#G()}resize=()=>{if(this.#c)return;let e=this.#d.getBoundingClientRect(),n=Math.max(1,e.width),t=Math.max(1,e.height),r=Math.min(this.#r.dprCap,Math.max(1,window.devicePixelRatio||1)),i=n!==this.#M||t!==this.#P,s=r!==this.#ne;this.#M=n,this.#P=t,this.#ne=r,(i||s)&&(this.#se=!0),i&&(this.#H=!0);let l=Math.max(1,Math.round(n*r)),a=Math.max(1,Math.round(t*r)),u=this.#d.width!==l||this.#d.height!==a;this.#d.width!==l&&(this.#d.width=l),this.#d.height!==a&&(this.#d.height=a),u&&this.#n.viewport(0,0,l,a),this.#s&&this.#S(performance.now(),!1)};dispose(){if(!this.#c){this.#c=!0,this.#Ee(),z(this.#x),this.#x=0,window.removeEventListener("resize",this.resize),this.#ce?.disconnect(),window.removeEventListener("pointermove",this.#Re,!0),window.removeEventListener("blur",this.#z),document.removeEventListener("visibilitychange",this.#Te),this.#m.removeEventListener("change",this.#Ae),this.#d.removeEventListener("webglcontextlost",this.#_e);for(let e of Object.values(this.#l))this.#n.deleteBuffer(e);this.#n.deleteProgram(this.#L),this.#n.deleteShader(this.#me),this.#n.deleteShader(this.#fe),this.#n.getExtension("WEBGL_lose_context")?.loseContext(),this.#i.length=0}}#I(e){let n=this.#n.getAttribLocation(this.#L,e);if(n<0)throw new Error(\`Particle shader attribute \${e} is unavailable\`);return n}#t(e){let n=this.#n.getUniformLocation(this.#L,e);if(!n)throw new Error(\`Particle shader uniform \${e} is unavailable\`);return n}#C(){let e=this.#n.createBuffer();if(!e)throw new Error("WebGL could not create a particle buffer");return e}#D(e,n){this.#n.bindBuffer(this.#n.ARRAY_BUFFER,e),this.#n.bufferData(this.#n.ARRAY_BUFFER,n,this.#n.STATIC_DRAW)}#Me(){let e=this.#n;e.bindBuffer(e.ARRAY_BUFFER,this.#l.previousHome),e.enableVertexAttribArray(this.#u.previousHome),e.vertexAttribPointer(this.#u.previousHome,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.#l.home),e.enableVertexAttribArray(this.#u.home),e.vertexAttribPointer(this.#u.home,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.#l.previousVelocity),e.enableVertexAttribArray(this.#u.previousVelocity),e.vertexAttribPointer(this.#u.previousVelocity,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.#l.previousColor),e.enableVertexAttribArray(this.#u.previousColor),e.vertexAttribPointer(this.#u.previousColor,4,e.UNSIGNED_BYTE,!0,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.#l.color),e.enableVertexAttribArray(this.#u.color),e.vertexAttribPointer(this.#u.color,4,e.UNSIGNED_BYTE,!0,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.#l.seed),e.enableVertexAttribArray(this.#u.seed),e.vertexAttribPointer(this.#u.seed,1,e.FLOAT,!1,0,0)}#Q(e,n){let t=Math.min(this.#M/Math.max(1,e),this.#P/Math.max(1,n)),r=e*t*this.#v.zoom,i=n*t*this.#v.zoom;return[(this.#M-r)*this.#v.positionX/100,(this.#P-i)*this.#v.positionY/100,r,i]}#ee(){return this.#R*We}#te(){return this.#R*Ve}#Pe(){let e=Math.max(this.#oe,.1),n=W/e,t=Math.max(0,this.#ae),r=Math.max(1,this.#ie),i=Math.min(Xe,Ye/r),s=Math.min(qe,Ke/r),l=c=>{let d=n*c,m=Math.exp(-d),p=(1+(1+t)*d)*m,v=n*(t+(1+t)*d)*m;return p<=i&&v<=s},a=0,u=e;for(let c=0;c<18&&!l(u);c+=1)u*=1.5;for(let c=0;c<24;c+=1){let d=.5*(a+u);l(d)?u=d:a=d}return Math.max(.1,this.#te()+u)}#re(){if(this.#U&&this.#X===this.#y)return this.#U;let e=Math.max(.1,this.#ve),n=Math.max(0,this.#y-this.#ge),t=this.#h?Math.min(1,n/e):1,r=Qe(t,this.#ye),i={rawProgress:t,elapsed:r.value*e};return this.#X=this.#y,this.#U=i,i}#ke(){return this.#h?Te(this.#re().elapsed-this.#te()*.35,this.#oe):1}#xe(e,n){let t=Math.max(Math.hypot(this.#M,this.#P)*Pe,80),r=ce(e/t),i=1-G+n*G*2;return(this.#ee()+r*(this.#R-this.#ee()))*i}#Se(e){if(e.length!==this.#p.length)return!1;let[n,t,r,i]=this.#Q(this.#F,this.#O);for(let s=0;s<this.#a;s+=1){let l=s*2;e[l]=n+(this.#p[l]??0)*r,e[l+1]=t+(this.#p[l+1]??0)*i}return!0}#Ie(){if(!this.#a||this.#f.length!==this.#p.length||this.#g.length!==this.#p.length||this.#w.length!==this.#_.length)return!1;if(!this.#h)return this.#Se(this.#f)?(this.#g.fill(0),this.#w.set(this.#_),!0):!1;let e=this.#re().elapsed,n=this.#te(),[t,r,i,s]=this.#Q(this.#F,this.#O);for(let l=0;l<this.#a;l+=1){let a=l*2,u=this.#f[a]??0,c=this.#f[a+1]??0,d=t+(this.#p[a]??0)*i,m=r+(this.#p[a+1]??0)*s,p=Math.hypot(d-u,m-c),v=this.#xe(p,this.#B[l]??0),x=u-d,g=c-m,y=this.#g[a]??0,h=this.#g[a+1]??0,f=Math.hypot(y,h)>=.01,b=this.#B[l]??0,E=f?0:b*b*n,S=Math.max(0,e-E),P=Te(S,v),w=W/v,k=Math.exp(-w*S),F=y+w*x,T=h+w*g;this.#f[a]=d+(x+F*S)*k,this.#f[a+1]=m+(g+T*S)*k,this.#g[a]=0,this.#g[a+1]=0;let R=ce((P-.18)/.82),N=1-R,O=l*4;for(let H=0;H<4;H+=1){let ee=O+H;this.#w[ee]=Math.round((this.#w[ee]??0)*N+(this.#_[ee]??0)*R)}}return!0}#Ce(){let[e,n,t,r]=this.#Q(this.#F,this.#O),i=this.#ee()*(1-G),s=0,l=0;for(let a=0;a<this.#a;a+=1){let u=a*2,c=e+(this.#p[u]??0)*t,d=n+(this.#p[u+1]??0)*r,m=Math.hypot(c-(this.#f[u]??0),d-(this.#f[u+1]??0));l=Math.max(l,m);let p=this.#xe(m,this.#B[a]??0);i=Math.max(i,p);let v=Math.hypot(this.#g[u]??0,this.#g[u+1]??0),x=W/p;s=Math.max(s,v/(x*Math.max(m,1)))}return this.#ie=l,this.#ae=s,i}#De(){return this.#h?this.#re().rawProgress>=1:!0}#Ee(){let e=this.#N;this.#N=void 0,this.#q=0,e?.(!1)}#Le(e,n){return this.#ge=this.#y,this.#ye=$e(this.#r.morphCurve),this.#ve=this.#Pe(),this.#X=Number.NaN,this.#U=void 0,this.#h=e,this.#K=!0,this.#j=!0,this.#$=!0,this.#W(e?0:1,!e),e?new Promise(t=>{this.#q=n,this.#N=t}):Promise.resolve(!0)}#we(){if(!this.#h)return;this.#h=!1,this.#X=Number.NaN,this.#U=void 0,this.#j=!0,this.#$=!0,this.#W(1,!0);let e=this.#N,n=this.#q;this.#N=void 0,this.#q=0,e?.(n===this.#be&&!this.#c)}#he(e=performance.now()){if(this.#s)return this.#y;let n=Math.min(Ge,Math.max(0,(e-this.#b)/1e3));return this.#y+n}#Re=e=>{if(this.#c||this.#s||!this.#r.cursorInteraction||!e.isPrimary)return;let n=this.#d.getBoundingClientRect(),t=e.clientX-n.left,r=e.clientY-n.top;if(t<0||r<0||t>n.width||r>n.height){this.#z();return}let i=this.#he(),s=this.#J;if(this.#J={x:t,y:r,at:i},!s)return;let l=this.#i.length,a=this.#i.at(-1),u=i-s.at,c=t-s.x,d=r-s.y;if(u<=.001||u>de){a&&(a.sealed=!0);return}let m=Math.hypot(c,d)/u;if(m<1.5){a&&i-a.startedAt>=K&&(a.sealed=!0);return}a&&!a.sealed&&i-a.startedAt>K*1.5&&(a.sealed=!0);let p=c/u,v=d/u,{cursorScale:x,overdrive:g,highStrengthScale:y}=this.#Y,h=5200*y,f=x>0?Math.min(h,m*(1.04+.14*x)*Math.sqrt(g)):0,b=p/m*f,E=v/m*f,S=a&&i-a.createdAt<=de?a:void 0,P=S?S.velocityX*.28+b*.72:b,w=S?S.velocityY*.28+E*.72:E;a&&!a.sealed?(a.endX=t,a.endY=r,a.velocityX=P,a.velocityY=w,a.createdAt=i,a.duration=Math.max(.001,i-a.startedAt),a.sealed=a.duration>=K):this.#i.push({startX:s.x,startY:s.y,endX:t,endY:r,velocityX:P,velocityY:w,startedAt:s.at,createdAt:i,duration:u,sealed:u>=K}),this.#i.length>L&&this.#i.shift(),this.#k=!0,this.#i.length!==l&&(this.#Z=!0)};#z=()=>{this.#J=void 0;let e=this.#i.at(-1);e&&(e.sealed=!0)};#Te=()=>{if(document.hidden){z(this.#x),this.#x=0,this.#z(),this.#b=performance.now();return}this.#b=performance.now(),!this.#s&&!this.#m.matches&&this.#G()};#Ae=()=>{this.#m.matches&&(this.#o=1,this.#V(1)),this.setPaused(this.#m.matches)};#_e=e=>{e.preventDefault(),z(this.#x),this.#x=0,this.#pe("The particle renderer lost its WebGL context. Disable and re-enable the plugin.")};#G(){this.#c||this.#s||document.hidden||this.#x||(this.#x=oe(this.#d,e=>{this.#x=0,this.#S(e,!0)}))}#S(e,n){if(this.#c)return;let t=this.#o<1;this.#a&&!this.#s&&!document.hidden&&this.#o<1&&(this.#E+=Math.min(.1,Math.max(0,(e-this.#b)/1e3)),this.#o=Math.min(1,Math.max(0,(this.#E-.35)/this.#r.introDuration))),this.#s||(this.#y=this.#he(e)),this.#b=e;let r=this.#n,i=!1;if(r.clear(r.COLOR_BUFFER_BIT),this.#a>0){let s=this.#y;for(this.#h&&(this.#W(this.#ke(),!1),i=this.#De());this.#i.length&&s-(this.#i[0]?.createdAt??s)>Me;)this.#i.shift(),this.#k=!0,this.#Z=!0;let l=this.#i.length;this.#k&&this.#T.fill(0),l>0&&this.#A.fill(0);for(let a=0;a<this.#i.length;a+=1){let u=this.#i[a];if(!u)continue;let c=a*4;this.#k&&(this.#T[c]=u.startX,this.#T[c+1]=u.startY,this.#T[c+2]=u.endX,this.#T[c+3]=u.endY),this.#A[c]=u.velocityX,this.#A[c+1]=u.velocityY,this.#A[c+2]=Math.max(0,s-u.createdAt),this.#A[c+3]=Math.max(.001,u.duration)}if(this.#se&&(r.uniform2f(this.#e.resolution,this.#M,this.#P),r.uniform1f(this.#e.dpr,this.#ne),this.#se=!1),this.#H){let a=this.#Q(this.#F,this.#O);r.uniform4f(this.#e.layout,a[0],a[1],a[2],a[3]),this.#H=!1}if(this.#k&&(l>0&&r.uniform4fv(this.#e.pointerSegments,this.#T),this.#k=!1),this.#Z&&(r.uniform1f(this.#e.pointerCount,l),this.#Z=!1),l>0&&r.uniform4fv(this.#e.pointerMotion,this.#A),r.uniform1f(this.#e.time,s),r.uniform1f(this.#e.introProgress,this.#o),r.uniform1f(this.#e.introReveal,this.#o<1?ce(this.#E/.35):1),r.uniform1f(this.#e.introSpread,this.#r.introSpread),(this.#h||this.#$)&&(r.uniform1f(this.#e.transitionElapsed,this.#re().elapsed),this.#$=!1),this.#K&&(r.uniform1f(this.#e.transitionNearResponse,this.#ee()),r.uniform1f(this.#e.transitionFarResponse,this.#R),r.uniform1f(this.#e.transitionStagger,this.#te()),this.#K=!1),this.#j&&(r.uniform1f(this.#e.transitionActive,this.#h?1:0),this.#j=!1),this.#le){r.uniform1f(this.#e.particleSize,this.#r.particleSize),r.uniform1f(this.#e.particleOpacity,this.#r.particleOpacity),r.uniform1f(this.#e.speed,this.#r.speed),r.uniform1f(this.#e.noiseScale,this.#r.noiseScale),r.uniform1f(this.#e.noiseStrength,this.#r.noiseStrength);let a=Math.min(.9999,Math.max(.8,this.#r.damping));r.uniform1f(this.#e.dampingRate,Math.log(a)/j),r.uniform1f(this.#e.ambientCycle,this.#r.ambientCycle),r.uniform1f(this.#e.cursorStrength,this.#r.cursorStrength),this.#le=!1}if(this.#ue){let a=this.#Y;r.uniform3f(this.#e.cursorStrengthScales,a.highStrengthScale,a.stepStrengthScale,a.strength),r.uniform2f(this.#e.cursorStrengthDerived,a.wakeLengthScale,a.squareRootStrength),this.#ue=!1}r.drawArrays(r.POINTS,0,this.#a)}i&&this.#we(),this.#a&&this.#V(this.#o),t&&this.#o===1&&this.#de("completed"),n&&this.#G()}};var me=["setPreparedImage","setImageTransform","setPaused","resize"];function fe(o,e,n,t){let r=new Z(e,t,n,(i,s)=>re("particle-transition",{progress:i,complete:s}),i=>re("particle-opening",{progress:i}));return{setSettings(i){r.setRenderSettings(i)},setPreparedImage(i,s){return r.setPreparedImage(i,s)},setImageTransform(i){r.setImageTransform(i)},setPaused(i){r.setPaused(i)},resize(){r.resize()},replay(){r.replayOpening()},dispose(){r.dispose()}}}var V=globalThis,J="",ke=0,Ie=!1,B,_,pe=0,Ce=!1,De=0,M=(o,e={})=>V.postMessage({v:1,session:J,type:o,...e}),Q=o=>M("failed",{code:"BG_WORKER_RENDER_FAILED",message:String(o instanceof Error?o.message:o).slice(0,1500)});V.addEventListener("error",o=>Q(o.error??o.message));V.addEventListener("unhandledrejection",o=>Q(o.reason));V.addEventListener("message",o=>{let e=o.data;if(!(Ie||!e||e.v!==1||typeof e.session!="string"))try{if(e.type==="init"){if(J||!(e.canvas instanceof OffscreenCanvas)||e.session.length>100)throw Error("BG_INIT_INVALID: Invalid or duplicate background initialization.");J=e.session,ye((t,r)=>M("event",{event:t,value:X(r)}));let n=te(e.viewport,e.viewport.dpr);_=ge(e.canvas,n,()=>{pe++,Ce||(Ce=!0,M("first-frame",{frames:pe}),e.held===!0&&queueMicrotask(()=>_?.visibility(!1)));let t=performance.now();t-De>=1e3&&(De=t,M("sample",{frames:pe,at:t}))}),_.motion(e.reduced===!0),B=fe(_.host,_.canvas,U(e.settings),t=>{t&&Q(t)});return}if(e.session!==J||!Number.isSafeInteger(e.seq)||e.seq<=ke)return;if(ke=e.seq,e.type==="state"){if(e.settings!==void 0){let n=U(e.settings);B.setSettings?B.setSettings(n):B.updateSettings?.(n)}if(e.viewport&&_?.viewport(te(e.viewport,e.viewport.dpr)),typeof e.reduced=="boolean"&&_?.motion(e.reduced),typeof e.visible=="boolean"&&_?.visibility(e.visible),e.input){let{type:n,...t}=e.input;if(!["pointermove","pointerdown","pointerup","pointercancel","pointerleave","wheel","keydown"].includes(n))throw Error("BG_INPUT_METHOD: Unsupported background input.");_?.input(n,U(t))}M("ack",{seq:e.seq});return}if(e.type==="replay"){B.replay?.(),M("ack",{seq:e.seq});return}if(e.type==="call"){if(typeof e.method!="string"||!me.includes(e.method)||!Array.isArray(e.args)||e.args.length>8||!Number.isSafeInteger(e.callId))throw Error("BG_KERNEL_COMMAND: The visual kernel command is not supported.");let n=X(e.args);M("ack",{seq:e.seq}),Promise.resolve().then(()=>B[e.method](...n)).then(t=>M("result",{callId:e.callId,value:X(t??null)}),t=>M("result",{callId:e.callId,error:String(t).slice(0,1500)}));return}if(e.type==="dispose"){Ie=!0;try{B?.dispose()}finally{_?.dispose(),M("disposed"),setTimeout(()=>V.close(),0)}return}throw Error("BG_WORKER_METHOD: Unsupported background command.")}catch(n){Q(n)}});})();
1099
+ `,i,e,n,t,r)}},nt=window,it=Symbol.for("code-codex:background-modules:v1"),Gt=nt[it]??(nt[it]=new Map),Ht=()=>tt("particle-image");Gt.set("particle-image",{id:"particle-image",api:1,version:"1.0.5",prepareDefaults:Ht,exports:{ParticleImageRenderer:rt},startup(i,e){let n,t=!1,r=Promise.resolve().then(()=>{if(t)throw new Error("Startup background preparation was canceled");return n=Je(i,e,rt),n.ready});return r.catch(()=>{}),{ready:r,dispose(){t=!0,n?.dispose()}}}});})();