@descix/frqtl-web 0.6.0-p4.1 → 0.6.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.
- package/CLAUDE.md +15 -11
- package/README.md +26 -6
- package/dist/artifact/double-slit.html +2 -2
- package/dist/dist-manifest.json +61 -60
- package/dist/experiments/empty/index.html +22 -7
- package/dist/frqtl/compat/providers/wasm-engine.js +3 -4
- package/dist/frqtl/compat/renderer/providers/p5-provider.js +1 -1
- package/dist/frqtl/objects/FrqtlApp.js +5 -5
- package/dist/frqtl/objects/RecipeContext.js +106 -1
- package/dist/frqtl/objects/constants/WallBehaviors.js +1 -1
- package/dist/frqtl/objects/instruments/capture.js +1 -24
- package/dist/frqtl/objects/instruments/hosted-eyes.js +17 -1
- package/dist/frqtl/objects/objects/makeControlsForObject.js +5 -5
- package/dist/frqtl/objects/record/Record.js +25 -5
- package/dist/frqtl/objects/schema/engine-scopes.js +2 -2
- package/dist/frqtl/objects/schema/scopes.js +2 -2
- package/dist/frqtl/objects/setup/_worldInit.js +1 -2
- package/dist/frqtl/objects/setup/setupBlackbodySubstrate.js +1 -2
- package/dist/frqtl/parts/CameraControls.js +8 -0
- package/dist/frqtl/parts/DetectorWall.js +1 -1
- package/dist/frqtl/parts/GraphingDetectorWall.js +7 -7
- package/dist/frqtl/parts/LargeObject.js +2 -2
- package/dist/frqtl/parts/LiveChart.js +2 -2
- package/dist/frqtl/parts/LogicGate.js +3 -3
- package/dist/frqtl/parts/OvenBox.js +1 -1
- package/dist/frqtl/parts/PointSource.js +1 -1
- package/dist/frqtl/parts/SlitLightSource.js +1 -1
- package/dist/frqtl/parts/SlitScreen.js +1 -1
- package/dist/frqtl/parts/SphereEmitter.js +12 -12
- package/dist/frqtl/parts/Trace.js +1 -1
- package/dist/frqtl/parts/Tunnel.js +11 -11
- package/dist/frqtl/parts/Wall.js +20 -10
- package/dist/frqtl/scenes/circuit-sat.js +1 -0
- package/dist/frqtl/scenes/dse-one-emitter.js +32 -34
- package/dist/frqtl/scenes/dse-two-emitters.js +33 -34
- package/dist/frqtl/scenes/mirror-route.js +96 -79
- package/dist/frqtl-web.min.js +54 -54
- package/dist/sdk.html +2 -2
- package/dist/shim/bundle/index.js +6 -0
- package/dist/shim/controls/index.js +1 -1
- package/dist/shim/engine/artifact-shell.js +1 -1
- package/dist/shim/engine/router.js +3 -3
- package/dist/shim/host/host-view.js +228 -0
- package/dist/shim/host/index.js +18 -0
- package/dist/shim/index.js +2 -4
- package/dist/shim/notebook/kernel.js +1 -1
- package/dist/shim/notebook/setup-builder.js +2 -2
- package/dist/shim/package.json +1 -0
- package/dist/shim/page-params/index.js +2 -30
- package/dist/shim/project/fork.js +293 -0
- package/dist/shim/project/identity.js +3 -1
- package/dist/shim/project/link.js +43 -3
- package/dist/shim/project/parts-writer.js +62 -5
- package/dist/shim/project/read-text.js +43 -0
- package/dist/shim/project/specifiers.js +104 -15
- package/dist/shim/registry/exhibits.js +15 -34
- package/dist/shim/registry/index.js +2 -2
- package/dist/shim/registry/scene-roster.js +35 -0
- package/dist/shim/registry/scene-source.js +6 -36
- package/dist/shim/registry/walkthrough.js +2 -3
- package/dist/shim/render-state/apply.js +66 -31
- package/dist/shim/render-state/index.js +6 -2
- package/dist/shim/runtime/index.js +4 -4
- package/llms.txt +9 -7
- package/package.json +20 -2
- package/dist/frqtl/experiments/_shared/fx-experiment.js +0 -449
- package/dist/js/models/flamingo-draco.glb +0 -0
- package/dist/js/models/flamingo.glb +0 -0
- package/dist/shim/registry/experiments.js +0 -215
package/dist/frqtl-web.min.js
CHANGED
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
var FRQTL=(()=>{var
|
|
2
|
-
`),ue.style.whiteSpace="pre-line",ue.style.color=se.state==="grabbed"?"#ffcc66":"rgba(240,240,240,0.95)",ue.style.display="block"}}o(te,"renderAimLabel");var ye=[],xe=[],Ue=null,Ce=null;function _e(se,ge,jt){var ut=i.createElement("div");ut.setAttribute("data-role","camera-joystick"),ut.setAttribute("data-stick",se==="left"?"move":"look"),ut.style.cssText="position:absolute;bottom:16px;"+(se==="left"?"left:16px;":"right:16px;")+"width:96px;height:96px;border-radius:50%;background:rgba(20,30,38,0.55);border:1px solid rgba(126,200,227,0.5);touch-action:none;z-index:40;box-sizing:border-box;user-select:none;-webkit-user-select:none;cursor:grab;";var Ht=i.createElement("div");Ht.textContent=ge,Ht.style.cssText="position:absolute;top:4px;left:0;right:0;text-align:center;color:rgba(126,200,227,0.85);font:10px sans-serif;pointer-events:none;";var _t=i.createElement("div");_t.setAttribute("data-role","camera-joystick-knob"),_t.style.cssText="position:absolute;left:50%;top:50%;width:34px;height:34px;margin:-17px 0 0 -17px;border-radius:50%;background:rgba(126,200,227,0.85);pointer-events:none;transition:transform 0.06s linear;",ut.appendChild(Ht),ut.appendChild(_t);var ct=48,ot=null;function Yr(fr){var er=ut.getBoundingClientRect(),no=er.left+er.width/2,na=er.top+er.height/2,ia=fr.clientX-no,io=fr.clientY-na,cn=Zn(ia/ct,-1,1),kn=Zn(-io/ct,-1,1);jt.x=cn,jt.y=kn,_t.style.transform="translate("+cn*(ct-17)+"px,"+-kn*(ct-17)+"px)",N()}o(Yr,"setFromEvent");var Kt=null,cr=null;function pi(){i&&i.removeEventListener&&(Kt&&i.removeEventListener("pointermove",Kt),cr&&(i.removeEventListener("pointerup",cr),i.removeEventListener("pointercancel",cr))),Kt=null,cr=null}o(pi,"detachDoc");function mi(){if(ut.releasePointerCapture&&ot!==null)try{ut.releasePointerCapture(ot)}catch{}ot=null,jt.x=0,jt.y=0,_t.style.transform="translate(0px,0px)",ut.style.cursor="grab",pi()}return o(mi,"release"),ut.addEventListener("pointerdown",function(fr){if(ot=fr.pointerId,ut.style.cursor="grabbing",ve(),ut.setPointerCapture)try{ut.setPointerCapture(fr.pointerId)}catch{}Kt=o(function(er){ot===er.pointerId&&Yr(er)},"onDocMove"),cr=o(function(er){ot===er.pointerId&&mi()},"onDocUp"),i&&i.addEventListener&&(i.addEventListener("pointermove",Kt),i.addEventListener("pointerup",cr),i.addEventListener("pointercancel",cr)),Yr(fr),fr.preventDefault&&fr.preventDefault()}),xe.push(function(){mi()}),ut}if(o(_e,"makePad"),b&&i&&t){var Ve=i.defaultView&&i.defaultView.getComputedStyle?i.defaultView.getComputedStyle(t).position:t.style.position;(Ve==="static"||!Ve)&&(Ue=t.style.position||"",t.style.position="relative"),y=i.createElement("div"),y.setAttribute("data-role","camera-controls"),y.style.cssText="position:absolute;inset:0;pointer-events:none;z-index:39;";var wt=_e("left","MOVE",O),Vt=_e("right","LOOK",S);wt.style.pointerEvents="auto",Vt.style.pointerEvents="auto",y.appendChild(wt),y.appendChild(Vt),t.appendChild(y),ye=[wt,Vt],e&&typeof e.addAimListener=="function"&&(ue=X(),y.appendChild(ue),L=e.addAimListener(te),te()),c>0&&(Ce=o(function(se){var ge=n.getOrbit(),jt=Zn(ge.distance+(se.deltaY>0?1:-1)*c,h,g);n.setOrbit({distance:jt}),D(),w(),se.preventDefault&&se.preventDefault()},"onWheel"),t.addEventListener("wheel",Ce,{passive:!1}))}w();var Gt={mounted:!0,dispose:o(function(){t&&t.__frqtlCameraHandle===Gt&&(t.__frqtlCameraHandle=null),Y!==null&&(J(Y),Y=null);for(var se=0;se<xe.length;se++)try{xe[se]()}catch{}xe=[],p&&m&&m.removeEventListener&&(m.removeEventListener("keydown",ne),m.removeEventListener("keyup",oe)),de&&t&&t.removeEventListener&&t.removeEventListener("pointerdown",de,!0),$!==null&&t&&($===!1?t.removeAttribute&&t.removeAttribute("tabindex"):t.setAttribute&&t.setAttribute("tabindex",$)),Ce&&t&&t.removeEventListener&&t.removeEventListener("wheel",Ce),L&&(L(),L=null),ue=null,y&&y.parentNode&&y.parentNode.removeChild(y),Ue!==null&&t&&(t.style.position=Ue),ye=[],y=null},"dispose"),getState:o(function(){return n.getOrbit()},"getState"),setState:o(function(se){n.setOrbit(se),w()},"setState"),sync:o(function(){w()},"sync")};return t&&(t.__frqtlCameraHandle=Gt),Gt}function Ed(e){var t=e&&e.tagName;return!!e&&(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable===!0)}function Sd(e,t){return Ed(e&&e.target)||!!(t&&Ed(t.activeElement))}var Ps,Bu=ce(()=>{va();o(Zn,"clamp");o(Iy,"noopHandle");o(Py,"attach");o(Ed,"_isEditable");o(Sd,"isTypingTarget");Ps={attach:Py,isTypingTarget:Sd}});var Wu={};Oe(Wu,{CameraPath:()=>ya});function vr(e){throw new Error("[CameraPath] "+e+" (FAIL-LOUD.)")}function Fs(e,t){if(typeof e=="number"&&isFinite(e))return e;vr(t+" must be a finite number, got "+String(e))}function Fy(e,t,r,n){var i=n/2,a=((t-e)%n+n+i)%n-i;return e+a*r}function kd(e,t,r){return e+(t-e)*r}function Ny(e,t,r){for(var n={},i=Ad(e,t),a=0;a<i.length;a++){var s=i[a],l=e[s],u=t[s];typeof l=="number"&&typeof u=="number"?n[s]=kd(l,u,r):n[s]=u===void 0?l:u}return n}function Ns(e,t,r,n){(!Array.isArray(e)||!e.length)&&vr("poseAt needs at least one waypoint");var i=e[0],a=e[e.length-1],s=Fs(t,"tick");if(r&&e.length>1){var l=a.atTick-i.atTick;l>0&&(s=i.atTick+((s-i.atTick)%l+l)%l)}if(s<=i.atTick)return wo(i.pose);if(s>=a.atTick)return wo(a.pose);for(var u=0;u<e.length-1&&e[u+1].atTick<=s;)u++;for(var f=e[u],c=e[u+1],h=c.atTick-f.atTick,g=h>0?(s-f.atTick)/h:0,p={},m=Ad(f.pose,c.pose),b=0;b<m.length;b++){var y=m[b],w=f.pose[y],O=c.pose[y];if(w===void 0){p[y]=Ms(O);continue}if(O===void 0){p[y]=Ms(w);continue}if(y==="target"){if(w===null&&O===null){p[y]=null;continue}(w===null||O===null)&&vr("cannot interpolate `target` between null (scene centre) and a concrete point across the segment at ticks "+f.atTick+"\u2192"+c.atTick+" \u2014 declare target on both waypoints or neither"),p[y]=Ny(w,O,g);continue}if(typeof w=="number"&&typeof O=="number"){var S=n?n[y]:void 0;p[y]=typeof S=="number"&&S>0?Fy(w,O,g,S):kd(w,O,g);continue}p[y]=Ms(O)}return p}function Ad(e,t){var r=Object.create(null),n=[];return[e,t].forEach(function(i){i&&Object.keys(i).forEach(function(a){r[a]||(r[a]=1,n.push(a))})}),n}function Ms(e){return e&&typeof e=="object"?JSON.parse(JSON.stringify(e)):e}function wo(e){var t={};return e&&Object.keys(e).forEach(function(r){t[r]=Ms(e[r])}),t}function My(e,t){(!e||typeof e.addTickListener!="function")&&vr("attach needs an FrqtlApp with a per-tick listener fan-out");var r=e.cameraControl;r||vr("this renderer exposes NO camera pose control (runner.cameraControl is null), so a declared camera path cannot fly. A UI widget may hide on an absent capability; a programmatic instrument must not silently do nothing \u2014 a golden or a corpus row built on a camera path that never moved is fabricated evidence"),t=t||{};var n=t.waypoints;(!Array.isArray(n)||!n.length)&&vr("attach needs at least one waypoint: [{ atTick, pose }]");for(var i={},a=r.poseFields||[],s=0;s<a.length;s++)i[a[s].name]=!0;for(var l=Object.keys(i),u={},f=0;f<a.length;f++){var c=a[f].constraint;c&&typeof c.wrap=="number"&&c.wrap>0&&(u[a[f].name]=c.wrap)}for(var h=n.slice().sort(function(X,te){return X.atTick-te.atTick}),g=0;g<h.length;g++){var p=h[g];(!p||typeof p!="object")&&vr("waypoint "+g+" is not an object"),Fs(p.atTick,"waypoint "+g+" atTick"),(!p.pose||typeof p.pose!="object")&&vr("waypoint "+g+" has no pose bag");var m=Object.keys(p.pose);m.length||vr("waypoint "+g+" has an EMPTY pose bag");for(var b=0;b<m.length;b++){var y=m[b];l.length&&!i[y]&&vr("waypoint "+g+' names pose field "'+y+'", which this camera does NOT declare. Declared axes: ['+l.join(", ")+"]. Read cameraControl.poseFields rather than assuming a mode \u2014 a silently skipped axis is a camera path that does not fly");var w=p.pose[y];if(typeof w=="number"&&Fs(w,"waypoint "+g+" "+y),y==="target"&&w!==null&&w!==void 0){(typeof w.x!="number"||typeof w.y!="number")&&vr("waypoint "+g+" target must be {x,y} (2D) or {x,y,z} (3D), or null");for(var O=Object.keys(w),c=0;c<O.length;c++)typeof w[O[c]]=="number"&&Fs(w[O[c]],"waypoint "+g+" target."+O[c])}}if(g>0){var S=h[g-1].pose,A="target"in S,C="target"in p.pose;A&&C&&S.target===null!=(p.pose.target===null)&&vr("the segment at ticks "+h[g-1].atTick+"\u2192"+p.atTick+" mixes target:null (the scene centre) with a concrete point \u2014 that interpolation is undefined. Declare target on both waypoints or neither")}}var R=!!t.loop,Q=typeof t.anchorTick=="number"&&isFinite(t.anchorTick)?t.anchorTick:null,Y=null,H=typeof t.waypointTimeoutMs=="number"?t.waypointTimeoutMs:1e4,q=0,T=[],J=null,D=-1,K=!1;function N(X){B(Ns(h,X,R,u))}o(N,"_applyAt");function B(X){r.setOrbit(X),typeof e.repaint=="function"&&e.repaint()}o(B,"_applyPose");function ne(X){for(var te=0;te<h.length;te++)if(h[te].atTick<=X&&te>D){D=te;for(var ye={tick:h[te].atTick,index:te,pose:wo(h[te].pose)},xe=[],Ue=0;Ue<T.length;Ue++)try{var Ce=T[Ue](ye);Ce&&typeof Ce.then=="function"&&xe.push(Ce)}catch(_e){ue("onWaypoint callback threw",_e)}xe.length&&oe(xe,ye)}}o(ne,"_notifyWaypoints");function oe(X,te,ye){typeof e.suspendTicks!="function"&&vr("this runner exposes no suspendTicks()/resumeTicks(), so an async onWaypoint handler cannot be guaranteed to observe waypoint "+te.index+". Upgrade the runner, or use only synchronous handlers"),e.suspendTicks(),q+=1;var xe=!1,Ue=o(function(){xe||(xe=!0,q-=1,e.resumeTicks(),typeof ye=="function"&&ye())},"release"),Ce=null;H>0&&typeof setTimeout=="function"&&(Ce=setTimeout(function(){xe||(ue("an onWaypoint handler for waypoint "+te.index+" did not settle within "+H+"ms \u2014 releasing the tick clock so the sim does not stay frozen. That capture is NOT waypoint-exact",new Error("waypoint handler timeout")),Ue())},H));var _e=o(function(Ve){if(Ce!==null&&typeof clearTimeout=="function"&&clearTimeout(Ce),Ve)for(var wt=0;wt<Ve.length;wt++)Ve[wt]&&Ve[wt].status==="rejected"&&ue("onWaypoint callback rejected",Ve[wt].reason);Ue()},"settle");typeof Promise.allSettled=="function"?Promise.allSettled(X).then(_e,function(Ve){ue("waypoint hold failed",Ve),Ue()}):Promise.all(X.map(function(Ve){return Ve.then(null,function(){})})).then(function(){_e(null)},function(){Ue()})}o(oe,"_holdUntilSettled");function $(X){return X&&X.universeData&&typeof X.universeData.tick=="number"?X.universeData.tick:null}o($,"_universeTick");function de(X){if(!K){var te=D+1;te>=h.length||h[te].atTick>X||(K=!0,ve(te,X))}}o(de,"_drainDue");function ve(X,te){D=X,B(Ns(h,h[X].atTick,R,u));for(var ye={tick:h[X].atTick,index:X,pose:wo(h[X].pose)},xe=[],Ue=0;Ue<T.length;Ue++)try{var Ce=T[Ue](ye);Ce&&typeof Ce.then=="function"&&xe.push(Ce)}catch(Ve){ue("onWaypoint callback threw",Ve)}var _e=o(function(){var Ve=D+1;Ve<h.length&&h[Ve].atTick<=te?ve(Ve,te):(K=!1,N(te))},"cont");xe.length?oe(xe,ye,_e):_e()}o(ve,"_fireWaypoint");function ue(X,te){typeof console<"u"&&console.error&&console.error("[CameraPath] "+X+":",te)}o(ue,"_surface");function L(X){var te=$(X);if(te!==null){Y===null&&(Y=Q!==null?Q:te);var ye=te-Y;K||N(ye),de(ye)}}o(L,"onTick");var ee={get running(){return!!J},start:o(function(){if(!J){var X=e._lastTickData,te=$(X);Y===null&&(Y=Q!==null?Q:te===null?0:te),J=e.addTickListener(L),te!==null&&L(X)}},"start"),get anchorTick(){return Y},stop:o(function(){for(J&&(J(),J=null),K=!1,D=-1,Y=null;q>0;)q-=1,typeof e.resumeTicks=="function"&&e.resumeTicks()},"stop"),dispose:o(function(){ee.stop(),T=[]},"dispose"),poseAt:o(function(X){return Ns(h,X,R,u)},"poseAt"),onWaypoint:o(function(X){return typeof X!="function"&&vr("onWaypoint needs a function"),T.push(X),function(){var te=T.indexOf(X);te!==-1&&T.splice(te,1)}},"onWaypoint"),get waypoints(){return h.map(function(X){return{atTick:X.atTick,pose:wo(X.pose)}})}};return ee}var ya,Us=ce(()=>{o(vr,"_fail");o(Fs,"_finite");o(Fy,"_lerpAngle");o(kd,"_lerp");o(Ny,"_lerpPoint");o(Ns,"poseAt");o(Ad,"_poseKeys");o(Ms,"_copyValue");o(wo,"_copyPose");o(My,"attach");ya={attach:My,poseAt:Ns}});var zs={};Oe(zs,{CollisionActions:()=>st});var st,$r=ce(()=>{st={COUNT:"COUNT",MARK:"MARK",DETECT:"DETECT",LOG:"LOG",ABSORB:"ABSORB",BOUNCE:"BOUNCE",BLOCK:"BLOCK"}});var Vs={};Oe(Vs,{CollisionTypes:()=>Ee});var Ee,Ut=ce(()=>{Ee={NONE:"NONE",BOUNCE:"BOUNCE",RANDOM_X:"RANDOM_X",RANDOM_Y:"RANDOM_Y",RANDOM_XY:"RANDOM_XY",MOMENTUM_BASED:"MOMENTUM_BASED",WALL:"WALL"}});var yr={};Oe(yr,{BIN_OPS:()=>Vy,Bin:()=>Qy,CMP_OPS:()=>qy,Cmp:()=>Xy,Cond:()=>Zy,FN_NAMES:()=>By,Fn:()=>$y,HANDLE_FRAME:()=>Gy,HANDLE_SELF:()=>Hy,HANDLE_UNIVERSE:()=>Ky,Lit:()=>Yy,NODE_KINDS:()=>Uy,OP_KINDS:()=>zy,Ref:()=>Jy,StrLit:()=>eb,TRIGGERS:()=>Wy});function Yy(e){return{kind:"Lit",value:e}}function Jy(e,t){return{kind:"Ref",handle:e,prop:t}}function Qy(e,t,r){return{kind:"Bin",op:e,a:t,b:r}}function Xy(e,t,r){return{kind:"Cmp",op:e,a:t,b:r}}function Zy(e,t,r){return{kind:"Cond",test:e,then:t,else:r}}function $y(e,t){return{kind:"Fn",name:e,args:t}}function eb(e){return{kind:"StrLit",value:e}}var Uy,zy,Vy,qy,By,Wy,Gy,Hy,Ky,ba=ce(()=>{Uy=Object.freeze(["Lit","Ref","Bin","Cmp","Cond","Fn","StrLit"]),zy=Object.freeze(["set"]),Vy=Object.freeze(["+","-","*","/"]),qy=Object.freeze(["<",">","=="]),By=Object.freeze(["min","max","floor","random","intersects"]),Wy=Object.freeze(["collision","tick"]),Gy=0,Hy=1,Ky=2;o(Yy,"Lit");o(Jy,"Ref");o(Qy,"Bin");o(Xy,"Cmp");o(Zy,"Cond");o($y,"Fn");o(eb,"StrLit")});var Bs={};Oe(Bs,{aabbHalfExtentsFromObb:()=>Ku,regionFromObb:()=>Hu,resolveSlabFace:()=>wa});function wa(e){e=e||{};var t=+e.w,r=+e.h,n=typeof e.orientationDeg=="number"&&isFinite(e.orientationDeg)?e.orientationDeg:0,i=typeof e.pitchDeg=="number"&&isFinite(e.pitchDeg)?e.pitchDeg:0;if(Math.abs(i)>Gu){if(i<-90||i>90)throw new Error("[SlabFace] pitchDeg must be within [-90, 90]; got "+i);var a=typeof e.d=="number"&&isFinite(e.d)&&e.d>0?e.d:0;if(!(a>0))throw new Error("[SlabFace] a PITCHED plate requires a real z-depth (3D wall) \u2014 pitchDeg "+i+" with d="+e.d+". Give the wall a z/depth first.");var s=(n%360+360)%360,l=(90+s)%360,u=l*qs,f=i*qs,c={x:Math.cos(u),y:Math.sin(u),z:0},h={x:-Math.sin(u),y:Math.cos(u)},g={x:h.x*Math.cos(f),y:h.y*Math.cos(f),z:Math.sin(f)},p={x:c.y*g.z-c.z*g.y,y:c.z*g.x-c.x*g.z,z:c.x*g.y-c.y*g.x},m=t/2,b=r/2,y=a/2,w=typeof e.cx=="number"&&isFinite(e.cx)?e.cx:0,O=typeof e.cy=="number"&&isFinite(e.cy)?e.cy:0,S=typeof e.z=="number"&&isFinite(e.z)?e.z:0;return{isCardinal:!1,pitched:!0,reflectBaseDeg:l,obb:null,plate3:{cx:w,cy:O,cz:S,n:g,u:c,v:p,hw:m,hh:b,hz:y,aabb:{hx:Math.abs(g.x)*m+Math.abs(c.x)*b+Math.abs(p.x)*y,hy:Math.abs(g.y)*m+Math.abs(c.y)*b+Math.abs(p.y)*y,hz:Math.abs(g.z)*m+Math.abs(c.z)*b+Math.abs(p.z)*y}}}}var A=(n%360+360)%360,C=A%90,R=C<Gu||90-C<Gu,Q=(90+A)%360,Y=null;if(!R){var H=typeof e.cx=="number"&&isFinite(e.cx)?e.cx:0,q=typeof e.cy=="number"&&isFinite(e.cy)?e.cy:0,T=typeof e.z=="number"&&isFinite(e.z)?e.z:0,J=typeof e.d=="number"&&isFinite(e.d)&&e.d>0?e.d:0,D=A*qs,K=Q*qs,N={x:Math.cos(K),y:Math.sin(K)},B={x:-N.y,y:N.x};Y={cx:H,cy:q,cz:T,hw:t/2,hh:r/2,hz:J/2,theta:D,faceDir:N,normal:B}}return{isCardinal:R,reflectBaseDeg:Q,obb:Y}}function Hu(e){return e?{kind:"obb",theta:e.theta,hw:e.hw,hh:e.hh,hz:e.hz}:null}function Ku(e){if(!e)return null;var t=Math.abs(Math.cos(e.theta)),r=Math.abs(Math.sin(e.theta));return{hx:e.hw*t+e.hh*r,hy:e.hw*r+e.hh*t,hz:e.hz}}var Gu,qs,Yu=ce(()=>{Gu=1e-9,qs=Math.PI/180;o(wa,"resolveSlabFace");o(Hu,"regionFromObb");o(Ku,"aabbHalfExtentsFromObb")});var ar={};Oe(ar,{RENDER_INTENT_KEYS:()=>_o,RENDER_INTENT_VALUES:()=>Ws,SECTION_KEYS:()=>tb,assertRenderIntentConformance:()=>ib,normalizeDataBubble:()=>Ju,normalizeDetection:()=>rb,normalizeRenderIntent:()=>nb});function Ju(e){return e==null?{detection:null,string_map:null}:{detection:e.detection!==null&&e.detection!==void 0?e.detection:null,string_map:e.string_map!==null&&e.string_map!==void 0&&typeof e.string_map=="object"?e.string_map:null,ext:e.ext!==void 0?e.ext:void 0}}function rb(e){return e?{detector_name:e.detector_name!==null&&e.detector_name!==void 0?String(e.detector_name):null}:{detector_name:null}}function nb(e){var t={};if(!e||typeof e!="object")return t;for(var r=0;r<_o.length;r++){var n=_o[r];e[n]!==void 0&&e[n]!==null&&(t[n]=String(e[n]))}return t}function ib(e){if(e)for(var t=0;t<_o.length;t++){var r=_o[t],n=Ws[r];if(n&&e[r]!==void 0&&n.indexOf(e[r])===-1)throw new Error('render-intent conformance: key "'+r+'" has invalid value "'+e[r]+'"; allowed: '+n.join("|"))}}var tb,_o,Ws,Ln=ce(()=>{tb=["detection","string_map"];o(Ju,"normalizeDataBubble");o(rb,"normalizeDetection");_o=["render.color","render.outline","render.shape","render.colorScheme","render.mesh","render.meshScale","render.meshRotation"],Ws={"render.shape":["ball","box","circle","cube","sphere"],"render.colorScheme":["roygbiv","warmcool"],"render.outline":["true","false"]};o(nb,"normalizeRenderIntent");o(ib,"assertRenderIntentConformance")});function ab(e){if(typeof e=="string"){var t={};return t[Qu]=e,t}if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("[Tagger] tags must be a plain object {key: value} or a bare string (shorthand for {"+Qu+": value}); got "+(Array.isArray(e)?"an array":typeof e)+".");for(var r={},n=Object.keys(e),i=0;i<n.length;i++){var a=n[i];if(typeof a!="string"||a.length===0)throw new TypeError("[Tagger] tag key must be a non-empty string; got "+JSON.stringify(a)+".");var s=e[a];s!=null&&(r[a]=String(s))}return r}function Gs(e){for(var t=yr,r=ab(e),n=[],i=Object.keys(r),a=0;a<i.length;a++)n.push({set:t.HANDLE_FRAME+".data."+i[a],to:t.StrLit(r[i[a]])});return n}function ob(e){if(!e)return{};var t=Ju(e.data),r=t.string_map;if(!r||typeof r!="object")return{};for(var n={},i=Object.keys(r),a=0;a<i.length;a++)r[i[a]]!==null&&r[i[a]]!==void 0&&(n[i[a]]=r[i[a]]);return n}function Td(e,t){var r=t??Qu,n=ob(e);return n[r]!==void 0?n[r]:null}var Qu,Xu=ce(()=>{ba();Ln();Qu="detector_name";o(ab,"normalizeTags");o(Gs,"tagOps");o(ob,"readTags");o(Td,"readTag")});var xo={};Oe(xo,{applyProgramTrigger:()=>gn,buildAngledReflectOps:()=>jd,buildConstrainedRandomOps:()=>Fd,buildDecoherenceOps:()=>Nd,buildEjectOps:()=>In,buildFaceExitEjectOps:()=>$u,buildIncidenceReflectOps:()=>Rd,buildIncidenceReflectOps3D:()=>Dd,buildOmniRandomOps:()=>Pd,buildReflectOps:()=>Ks,buildSwapReflectOps:()=>Ld,buildTiltedReflectGuardTrigger:()=>Id,buildTriggerExpr:()=>$n,buildVelocityFlipOp:()=>Zu,compileActions:()=>_a,compileWallV2:()=>ec});function $n(e,t,r,n,i,a,s,l,u){var f=u("intersects",[i(r),i(n)]);if(!t)return f;var c;if(e==="left")c=s(">",a(r,"left"),a(n,"right"));else if(e==="right")c=s("<",a(r,"right"),a(n,"left"));else if(e==="top")c=s(">",a(r,"top"),a(n,"bottom"));else if(e==="bottom")c=s("<",a(r,"bottom"),a(n,"top"));else return f;return l(f,i(1),c)}function gn(e,t){return e.trigger=t,e}function In(e,t,r,n,i,a,s,l,u){if(e==="left")return[{set:t+".left",to:a("-",a("-",i(r,"left"),i(t,"w")),n(1))}];if(e==="right")return[{set:t+".left",to:a("+",i(r,"right"),n(1))}];if(e==="top")return[{set:t+".top",to:a("-",a("-",i(r,"top"),i(t,"h")),n(1))}];if(e==="bottom")return[{set:t+".top",to:a("+",i(r,"bottom"),n(1))}];if(e==="near")return[{set:t+".z",to:a("-",a("-",i(r,"near"),a("*",i(t,"w"),n(.5))),n(1))}];if(e==="far")return[{set:t+".z",to:a("+",a("+",i(r,"far"),a("*",i(t,"w"),n(.5))),n(1))}];if(e==="closest"){let _e=function(Ve){return u("max",[Ve,a("-",n(0),Ve)])};o(_e,"Abs");var f=_e(a("-",i(r,"left"),i(t,"left"))),c=_e(a("-",i(r,"right"),i(t,"left"))),h=_e(a("-",i(r,"top"),i(t,"top"))),g=_e(a("-",i(r,"bottom"),i(t,"top"))),p=_e(a("-",i(r,"left"),i(t,"left"))),m=_e(a("-",i(r,"right"),i(t,"left"))),b=_e(a("-",i(r,"top"),i(t,"top"))),y=_e(a("-",i(r,"bottom"),i(t,"top"))),w=_e(a("-",i(r,"left"),i(t,"left"))),O=_e(a("-",i(r,"right"),i(t,"left"))),S=_e(a("-",i(r,"top"),i(t,"top"))),A=_e(a("-",i(r,"bottom"),i(t,"top"))),C=a("-",a("-",i(r,"left"),i(t,"w")),n(1)),R=a("+",i(r,"right"),n(1)),Q=a("-",a("-",i(r,"top"),i(t,"h")),n(1)),Y=a("+",i(r,"bottom"),n(1)),H=u("min",[f,c]),q=u("min",[h,g]),T=s("<",H,q),J=l(s("<",m,p),R,C),D={set:t+".left",to:l(T,J,i(t,"left"))},K=l(s("<",A,S),Y,Q),N=u("min",[w,O]),B=u("min",[S,A]),ne=s("<",N,B),oe={set:t+".top",to:l(ne,i(t,"top"),K)};return[D,oe]}else if(e==="closest3d"){let _e=function(ot){return u("max",[ot,a("-",n(0),ot)])},Ve=function(){return _e(a("-",i(r,"left"),i(t,"left")))},wt=function(){return _e(a("-",i(r,"right"),i(t,"left")))},Vt=function(){return _e(a("-",i(r,"top"),i(t,"top")))},Gt=function(){return _e(a("-",i(r,"bottom"),i(t,"top")))},se=function(){return _e(a("-",i(r,"near"),i(t,"near")))},ge=function(){return _e(a("-",i(r,"far"),i(t,"near")))},jt=function(){return u("min",[Ve(),wt()])},ut=function(){return u("min",[Vt(),Gt()])},Ht=function(){return u("min",[se(),ge()])},_t=function(){return l(s("<",ut(),jt()),n(0),l(s("<",Ht(),jt()),n(0),n(1)))},ct=function(){return l(s("<",Ht(),ut()),n(0),n(1))};o(_e,"Abs3"),o(Ve,"dL"),o(wt,"dR"),o(Vt,"dT"),o(Gt,"dB"),o(se,"dN"),o(ge,"dF"),o(jt,"minH"),o(ut,"minV"),o(Ht,"minZ"),o(_t,"isH"),o(ct,"vGivenNotH");var $=a("-",a("-",i(r,"left"),i(t,"w")),n(1)),de=a("+",i(r,"right"),n(1)),ve=a("-",a("-",i(r,"top"),i(t,"h")),n(1)),ue=a("+",i(r,"bottom"),n(1)),L=a("-",a("-",i(r,"near"),a("*",i(t,"w"),n(.5))),n(1)),ee=a("+",a("+",i(r,"far"),a("*",i(t,"w"),n(.5))),n(1)),X=l(s("<",wt(),Ve()),de,$),te=l(s("<",Gt(),Vt()),ue,ve),ye=l(s("<",ge(),se()),ee,L),xe={set:t+".left",to:l(_t(),X,i(t,"left"))},Ue={set:t+".top",to:l(l(_t(),n(0),ct()),te,i(t,"top"))},Ce={set:t+".z",to:l(l(_t(),n(0),l(ct(),n(0),n(1))),ye,i(t,"z"))};return[xe,Ue,Ce]}return null}function Zu(e,t,r,n,i){var a=e?e.split("_")[0]:"";return a==="LEFT"||a==="RIGHT"?{set:t+".vx",to:i("-",r(0),n(t,"vx"))}:a==="TOP"||a==="BOTTOM"?{set:t+".vy",to:i("-",r(0),n(t,"vy"))}:a==="NEAR"||a==="FAR"?{set:t+".vz",to:i("-",r(0),n(t,"vz"))}:null}function Rd(e,t,r,n,i,a,s,l){function u(H){return s(H,r(0),r(1))}o(u,"NOT");function f(H,q){return s(H,r(1),q)}o(f,"OR");function c(H,q){return s(H,q,r(0))}o(c,"AND");function h(H,q){return s(a(">",H,q),r(0),r(1))}o(h,"LE");function g(H,q){return s(a("<",H,q),r(0),r(1))}o(g,"GE");function p(){return i("*",n(e,"w"),r(.5))}o(p,"halfW");function m(){return i("*",n(e,"h"),r(.5))}o(m,"halfH");function b(){return i("+",n(e,"prev_x"),p())}o(b,"prevRight");function y(){return i("-",n(e,"prev_x"),p())}o(y,"prevLeft");function w(){return i("+",n(e,"prev_y"),m())}o(w,"prevBottom");function O(){return i("-",n(e,"prev_y"),m())}o(O,"prevTop");function S(){return f(h(b(),n(t,"left")),g(y(),n(t,"right")))}o(S,"wasOutsideX");function A(){return f(h(w(),n(t,"top")),g(O(),n(t,"bottom")))}o(A,"wasOutsideY");function C(){return i("-",l("min",[n(e,"right"),n(t,"right")]),l("max",[n(e,"left"),n(t,"left")]))}o(C,"penX");function R(){return i("-",l("min",[n(e,"bottom"),n(t,"bottom")]),l("max",[n(e,"top"),n(t,"top")]))}o(R,"penY");var Q=c(S(),f(u(A()),g(C(),R()))),Y=c(A(),f(u(S()),g(R(),C())));return[{set:e+".vx",to:s(Q,i("-",r(0),n(e,"vx")),n(e,"vx"))},{set:e+".vy",to:s(Y,i("-",r(0),n(e,"vy")),n(e,"vy"))}]}function Dd(e,t,r,n,i,a,s,l){function u(N){return s(N,r(0),r(1))}o(u,"NOT");function f(N,B){return s(N,r(1),B)}o(f,"OR");function c(N,B){return s(N,B,r(0))}o(c,"AND");function h(N,B){return s(a(">",N,B),r(0),r(1))}o(h,"LE");function g(N,B){return s(a("<",N,B),r(0),r(1))}o(g,"GE");function p(){return i("*",n(e,"w"),r(.5))}o(p,"halfW");function m(){return i("*",n(e,"h"),r(.5))}o(m,"halfH");function b(){return i("*",n(e,"w"),r(.5))}o(b,"halfD");function y(){return i("+",n(e,"prev_x"),p())}o(y,"prevRight");function w(){return i("-",n(e,"prev_x"),p())}o(w,"prevLeft");function O(){return i("+",n(e,"prev_y"),m())}o(O,"prevBottom");function S(){return i("-",n(e,"prev_y"),m())}o(S,"prevTop");function A(){return i("+",n(e,"prev_z"),b())}o(A,"prevFar");function C(){return i("-",n(e,"prev_z"),b())}o(C,"prevNear");function R(){return f(h(y(),n(t,"left")),g(w(),n(t,"right")))}o(R,"wasOutsideX");function Q(){return f(h(O(),n(t,"top")),g(S(),n(t,"bottom")))}o(Q,"wasOutsideY");function Y(){return f(h(A(),n(t,"near")),g(C(),n(t,"far")))}o(Y,"wasOutsideZ");function H(){return i("-",l("min",[n(e,"right"),n(t,"right")]),l("max",[n(e,"left"),n(t,"left")]))}o(H,"penX");function q(){return i("-",l("min",[n(e,"bottom"),n(t,"bottom")]),l("max",[n(e,"top"),n(t,"top")]))}o(q,"penY");function T(){return i("-",l("min",[n(e,"far"),n(t,"far")]),l("max",[n(e,"near"),n(t,"near")]))}o(T,"penZ");var J=c(R(),c(f(u(Q()),g(H(),q())),f(u(Y()),g(H(),T())))),D=c(Q(),c(f(u(R()),g(q(),H())),f(u(Y()),g(q(),T())))),K=c(Y(),c(f(u(R()),g(T(),H())),f(u(Q()),g(T(),q()))));return[{set:e+".vx",to:s(J,i("-",r(0),n(e,"vx")),n(e,"vx"))},{set:e+".vy",to:s(D,i("-",r(0),n(e,"vy")),n(e,"vy"))},{set:e+".vz",to:s(K,i("-",r(0),n(e,"vz")),n(e,"vz"))}]}function jd(e,t,r,n,i){var a=t*Math.PI/180,s=Math.cos(2*a),l=Math.sin(2*a);return[{set:e+".vx",to:i("+",i("*",r(s),n(e,"vx")),i("*",r(l),n(e,"vy")))},{set:e+".vy",to:i("-",i("*",r(l/s),n(e,"vx")),i("*",r(1/s),n(e,"vy")))}]}function Ld(e,t,r,n,i){var a=Math.round(Math.sin(2*t*Math.PI/180)),s=[{set:e+".vx",to:i("+",n(e,"vx"),n(e,"vy"))},{set:e+".vy",to:i("-",n(e,"vx"),n(e,"vy"))},{set:e+".vx",to:i("-",n(e,"vx"),n(e,"vy"))}];return a<0&&(s.push({set:e+".vx",to:i("-",r(0),n(e,"vx"))}),s.push({set:e+".vy",to:i("-",r(0),n(e,"vy"))})),s}function Ks(e,t,r,n,i,a,s,l,u,f){var c=typeof e=="number"&&isFinite(e)?e:0,h=(c%360+360)%360,g=1e-9,p=h%90,m=wa({orientationDeg:h});if(m.isCardinal)return f?Dd(t,r,n,i,a,s,l,u):Rd(t,r,n,i,a,s,l,u);var b=m.reflectBaseDeg;return Math.abs(p-45)<g?Ld(t,b,n,i,a):jd(t,b,n,i,a)}function Id(e,t,r,n,i,a,s,l,u,f,c){function h(R,Q){return u(R,Q,i(0))}o(h,"AND");function g(R,Q){return u(R,i(1),Q)}o(g,"OR");function p(R,Q){return s("+",s("*",i(e.x),s("-",a(r,R),a(n,"cx"))),s("*",i(e.y),s("-",a(r,Q),a(n,"cy"))))}o(p,"S");var m=s("+",s("*",i(e.x),a(r,"vx")),s("*",i(e.y),a(r,"vy"))),b=c?u(l("<",m,i(0)),i(0),i(1)):l(">",m,i(0)),y=c?u(l(">",m,i(0)),i(0),i(1)):l("<",m,i(0)),w=h(l("<",p("prev_x","prev_y"),i(-t)),h(l(">",p("x","y"),i(-t)),b)),O=h(l(">",p("prev_x","prev_y"),i(t)),h(l("<",p("x","y"),i(t)),y)),S=g(w,O);if(c){let R=function(Y,H){return u(l("<",Y,H),i(0),i(1))},Q=function(Y,H){return u(l(">",Y,H),i(0),i(1))};o(R,"GE"),o(Q,"LE");var A=h(l("<",a(r,"prev_z"),a(n,"near")),h(R(a(r,"z"),a(n,"near")),l(">",a(r,"vz"),i(0)))),C=h(l(">",a(r,"prev_z"),a(n,"far")),h(Q(a(r,"z"),a(n,"far")),l("<",a(r,"vz"),i(0))));S=g(S,g(A,C))}return u(f("intersects",[i(r),i(n)]),S,i(0))}function $u(e,t,r,n,i,a,s,l,u,f){function c(y,w){return s("+",s("*",i(e.x),s("-",a(r,y),a(n,"cx"))),s("*",i(e.y),s("-",a(r,w),a(n,"cy"))))}o(c,"S");var h=s("+",s("*",i(e.x),a(r,"vx")),s("*",i(e.y),a(r,"vy"))),g=s("+",i(t+1),s("*",a(r,"w"),i(.5))),p=f?u(l("<",c("prev_x","prev_y"),i(0)),i(-1),i(1)):u(l("<",h,i(0)),i(1),i(-1)),m=s("*",p,g);function b(){return s("-",m,c("prev_x","prev_y"))}return o(b,"delta"),[{set:r+".x",to:s("+",a(r,"prev_x"),s("*",b(),i(e.x)))},{set:r+".y",to:s("+",a(r,"prev_y"),s("*",b(),i(e.y)))}]}function sb(e,t,r,n,i,a,s,l,u){function f(){return s("+",s("*",i(e.x),s("-",a(r,"prev_x"),a(n,"cx"))),s("*",i(e.y),s("-",a(r,"prev_y"),a(n,"cy"))))}o(f,"S_prev");function c(){return u(l("<",f(),i(-t)),i(1),l(">",f(),i(t)))}o(c,"xprev");function h(){return u(l("<",a(r,"prev_z"),a(n,"near")),i(1),l(">",a(r,"prev_z"),a(n,"far")))}o(h,"zOutPrev");function g(){return u(c(),i(0),h())}return o(g,"zclass"),{xprev:c,zclass:g}}function lb(e,t,r,n,i,a,s){function l(){return i("*",i("+",n(t,"near"),n(t,"far")),r(.5))}o(l,"cz");function u(){return i("*",i("-",n(t,"far"),n(t,"near")),r(.5))}o(u,"hz");var f=i("+",i("+",u(),i("*",n(e,"w"),r(.5))),r(1)),c=s(a("<",n(e,"prev_z"),l()),r(-1),r(1));return{set:e+".z",to:i("+",l(),i("*",c,f))}}function Hs(e,t,r,n,i){return e.map(function(a){var s=a.set.slice((r+".").length);return{set:a.set,to:i(t(),a.to,n(r,s))}})}function ub(e,t,r,n,i){for(var a=[{k:"vx",c:e.x},{k:"vy",c:e.y},{k:"vz",c:e.z}],s=1e-9,l=[],u=0;u<3;u++)Math.abs(a[u].c*a[u].c-.5)<s&&l.push(u);function f(){return i("+",i("+",i("*",r(e.x),n(t,"vx")),i("*",r(e.y),n(t,"vy"))),i("*",r(e.z),n(t,"vz")))}if(o(f,"nDotV"),l.length===2){var c=a[l[0]].k,h=a[l[1]].k,g=Math.sign(a[l[0]].c)*Math.sign(a[l[1]].c),p=[{set:t+"."+c,to:i("+",n(t,c),n(t,h))},{set:t+"."+h,to:i("-",n(t,c),n(t,h))},{set:t+"."+c,to:i("-",n(t,c),n(t,h))}];return g>0&&(p.push({set:t+"."+c,to:i("-",r(0),n(t,c))}),p.push({set:t+"."+h,to:i("-",r(0),n(t,h))})),p}var m=[0,1,2].sort(function(Y,H){return Math.abs(a[Y].c)-Math.abs(a[H].c)}),b=m[0],y=[m[1],m[2]].sort(function(Y,H){return Math.abs(a[H].c*a[H].c-.5)-Math.abs(a[Y].c*a[Y].c-.5)}),w=y[0],O=y[1],S=a[b].c,A=a[O].c,C=a[w].c,R=1/(1-2*S*S),Q=1/(1-2*S*S-2*A*A);return[{set:t+"."+a[b].k,to:i("-",n(t,a[b].k),i("*",r(2*S),f()))},{set:t+"."+a[O].k,to:i("-",n(t,a[O].k),i("*",r(2*A*R),f()))},{set:t+"."+a[w].k,to:i("-",n(t,a[w].k),i("*",r(2*C*Q),f()))}]}function cb(e,t,r,n,i,a,s,l,u){var f=e.n,c=e.u,h=e.v,g=e.hw,p=e.hh,m=e.hz;function b(q,T){return l(q,T,n(0))}o(b,"AND");function y(q,T){return l(q,n(1),T)}o(y,"OR");function w(q,T){return l(s("<",q,T),n(0),n(1))}o(w,"GE");function O(q,T){return l(s(">",q,T),n(0),n(1))}o(O,"LE");function S(q){return u("max",[q,a("-",n(0),q)])}o(S,"Abs");function A(){return a("*",a("+",i(r,"near"),i(r,"far")),n(.5))}o(A,"CZ");function C(q,T,J,D){return a("+",a("+",a("*",n(q.x),a("-",i(t,T),i(r,"cx"))),a("*",n(q.y),a("-",i(t,J),i(r,"cy")))),a("*",n(q.z),a("-",i(t,D),A())))}o(C,"DOT");var R=a("+",a("+",a("*",n(f.x),i(t,"vx")),a("*",n(f.y),i(t,"vy"))),a("*",n(f.z),i(t,"vz"))),Q=b(s("<",C(f,"prev_x","prev_y","prev_z"),n(-g)),b(w(C(f,"x","y","z"),n(-g)),w(R,n(0)))),Y=b(s(">",C(f,"prev_x","prev_y","prev_z"),n(g)),b(O(C(f,"x","y","z"),n(g)),O(R,n(0)))),H=b(s("<",S(C(c,"x","y","z")),n(p)),s("<",S(C(h,"x","y","z")),n(m)));return l(u("intersects",[n(t),n(r)]),b(H,y(Q,Y)),n(0))}function fb(e,t,r,n,i,a,s,l){var u=e.n,f=e.hw;function c(){return a("*",a("+",i(r,"near"),i(r,"far")),n(.5))}o(c,"CZ");function h(){return a("+",a("+",a("*",n(u.x),a("-",i(t,"prev_x"),i(r,"cx"))),a("*",n(u.y),a("-",i(t,"prev_y"),i(r,"cy")))),a("*",n(u.z),a("-",i(t,"prev_z"),c())))}o(h,"SPrev");var g=a("+",n(f+1),a("*",i(t,"w"),n(.5)));function p(){return a("*",l(s("<",h(),n(0)),n(-1),n(1)),g)}o(p,"T");function m(){return a("-",p(),h())}return o(m,"delta"),[{set:t+".x",to:a("+",i(t,"prev_x"),a("*",m(),n(u.x)))},{set:t+".y",to:a("+",i(t,"prev_y"),a("*",m(),n(u.y)))},{set:t+".z",to:a("+",i(t,"prev_z"),a("*",m(),n(u.z)))}]}function Pd(e,t,r,n){return[{set:e+".vx",to:r("-",r("*",n("random",[]),t(2)),t(1))},{set:e+".vy",to:r("-",r("*",n("random",[]),t(2)),t(1))}]}function Fd(e,t,r,n,i,a,s,l,u){return[{set:e+".vx",to:u("random",[])},{set:e+".vy",to:l("+",a(r),l("*",l("-",a(i),a(r)),s(e,"vx")))},{set:e+".vx",to:l("+",a(t),l("*",l("-",a(n),a(t)),s(e,"vx")))}]}function Nd(e,t,r,n,i){return[{set:e+".local_time",to:t(0)},{set:e+".charge",to:n(r("<",i("random",[]),t(.5)),t(0),t(1))}]}function Ti(e,t){throw new Error("[actionCompiler] cannot compile CollisionAction "+JSON.stringify(e)+": "+t+". Nothing is left uncompiled \u2014 the engine has no action dispatch, so an op-program is the only way a behaviour can run.")}function _a(e,t,r,n){for(var i=yr,a=i.Lit,s=i.Ref,l=i.Bin,u=i.Cmp,f=i.Cond,c=i.Fn,h=i.HANDLE_FRAME,g=i.HANDLE_SELF,p=[],m=!1,b=e||[],y=0;y<b.length;y++){var w=b[y];if(w==="ABSORB")p.push({set:h+".is_alive",to:a(0)});else if(w==="COUNT")p.push({set:g+".count",to:l("+",s(g,"count"),a(1))});else if(w==="MARK"||w==="DETECT"){var O=t||"";p=p.concat(Gs(O))}else if(w==="BLOCK"){r||Ti(w,"it needs an eject face: pass a reposition of left|right|top|bottom|near|far|closest, or build the wall with V2 compileWallV2({behavior:'block', reposition})");var S=In(r,h,g,a,s,l,u,f,c);S||Ti(w,'reposition "'+r+'" is not an eject face (left|right|top|bottom|near|far|closest|closest3d)');for(var A=0;A<S.length;A++)p.push(S[A])}else if(w==="BOUNCE"){r||Ti(w,"it needs an eject face: pass a reposition of left|right|top|bottom|near|far|closest, or build the wall with V2 compileWallV2({behavior:'bounce', bounceDirection:'reflect', reposition})");var C=In(r,h,g,a,s,l,u,f,c),R=Zu(t||"",h,a,s,l);if(!C&&!R&&Ti(w,'neither reposition "'+r+'" nor the LO name "'+(t||"")+'" names a face to bounce off'),C)for(var Q=0;Q<C.length;Q++)p.push(C[Q]);R&&p.push(R)}else w==="LOG"?Ti(w,"there is no logging op and no native dispatch to fall back to; read the collided frames from TickData.objects[handle].frames instead (compileWallV2({behavior:'nothing', hooks:['count']}) collects them)"):w==="RECOLOR"?Ti(w,"the engine owns no colour; stamp render.color as a tag instead \u2014 compileWallV2({..., hooks:['recolor'], color:[r,g,b]})"):w==="KILL"?p.push({set:h+".is_alive",to:a(0)}):Ti(w,"it is not a CollisionAction this compiler knows (ABSORB|COUNT|MARK|DETECT|BLOCK|BOUNCE|KILL) \u2014 check the spelling, or use the V2 wall vocabulary via compileWallV2({behavior, bounceDirection, hooks})")}var Y=n||"NONE";if(Y==="RANDOM_X")p.push({set:h+".vx",to:l("-",l("*",c("random",[]),a(2)),a(1))}),p.push({set:h+".vy",to:a(1)});else if(Y==="RANDOM_Y")p.push({set:h+".vy",to:l("-",l("*",c("random",[]),a(2)),a(1))}),p.push({set:h+".vx",to:a(1)}),p.push({set:h+".local_time",to:a(0)}),p.push({set:h+".charge",to:f(u("<",c("random",[]),a(.5)),a(0),a(1))});else if(Y==="RANDOM_XY")p.push({set:h+".vx",to:c("random",[])}),p.push({set:h+".vy",to:l("-",l("*",c("random",[]),a(2)),a(1))}),p.push({set:h+".local_time",to:a(0)}),p.push({set:h+".charge",to:f(u("<",c("random",[]),a(.5)),a(0),a(1))});else if(Y==="MOMENTUM_BASED")p.push({set:h+".x",to:s(h,"prev_x")}),p.push({set:h+".y",to:s(h,"prev_y")});else if(Y==="WALL"){if(r){var H=In(r,h,g,a,s,l,u,f,c);if(H){for(var q=0;q<H.length;q++)p.push(H[q]);m=!0}}}else if(Y==="BOUNCE"){var T=b.indexOf("BOUNCE")>=0;if(!T&&r){var J=In(r,h,g,a,s,l,u,f,c),D=Zu(t||"",h,a,s,l);if(J)for(var K=0;K<J.length;K++)p.push(J[K]);D&&p.push(D)}}var N=p.length>0?{on:"collision",ops:p}:null;if(N!==null){var B=$n(r||null,m,h,g,a,s,u,f,c);gn(N,B)}return{program:N}}function hb(e){if(!Array.isArray(e)||e.length<3)return null;function t(s){return s=Math.round(Number(s)),isNaN(s)?null:Math.max(0,Math.min(255,s))}o(t,"_b");var r=t(e[0]),n=t(e[1]),i=t(e[2]);if(r===null||n===null||i===null)return null;var a=e.length>=4?t(e[3]):255;return a===null&&(a=255),r+","+n+","+i+","+a}function ec(e){var t=yr,r=t.Lit,n=t.Ref,i=t.Bin,a=t.Cmp,s=t.Cond,l=t.Fn,u=t.HANDLE_FRAME,f=t.HANDLE_SELF;e=e||{};var c=e.behavior||"nothing",h=e.reposition||"closest",g=e.is3D===!0;g&&h==="closest"&&(h="closest3d");var p=Array.isArray(e.hooks)?e.hooks:[],m=!1,b=null,y=[],w=c==="bounce"&&e.bounceDirection!=="random"?wa({orientationDeg:e.orientationDeg,w:e.slabW,h:e.slabH,pitchDeg:e.pitchDeg,d:e.slabD}):null,O=!!(w&&w.pitched);if(O&&!g)throw new Error("[actionCompiler] pitchDeg requires a 3D wall (a real z/depth) \u2014 a 2D wall has no z axis to pitch into.");var S=!!(w&&!w.isCardinal&&!O);if(c==="bounce")if(O)y=y.concat(fb(w.plate3,u,f,r,n,i,a,s)),y=y.concat(ub(w.plate3.n,u,r,n,i));else if(S){var A=w.obb&&isFinite(w.obb.hw)?w.obb.hw:0;if(g){var C=sb(w.obb.normal,A,u,f,r,n,i,a,s),R=$u(w.obb.normal,A,u,f,r,n,i,a,s,!0);y=y.concat(Hs(R,C.xprev,u,n,s)),y=y.concat(Hs([lb(u,f,r,n,i,a,s)],C.zclass,u,n,s)),y=y.concat(Hs(Ks(e.orientationDeg,u,f,r,n,i,a,s,l,g),C.xprev,u,n,s)),y=y.concat(Hs([{set:u+".vz",to:i("-",r(0),n(u,"vz"))}],C.zclass,u,n,s))}else y=y.concat($u(w.obb.normal,A,u,f,r,n,i,a,s)),y=y.concat(Ks(e.orientationDeg,u,f,r,n,i,a,s,l,g))}else{for(var Q=In(h,u,f,r,n,i,a,s,l)||[],Y=0;Y<Q.length;Y++)y.push(Q[Y]);if(e.bounceDirection==="random"){var H=e.angleConstraint;if(Array.isArray(H)&&H.length===2&&isFinite(H[0])&&isFinite(H[1])&&Math.abs(H[1]-H[0])<360){var q=typeof e.orientationDeg=="number"?e.orientationDeg:0,T=(q+H[0])*Math.PI/180,J=(q+H[1])*Math.PI/180;y=y.concat(Fd(u,Math.cos(T),Math.sin(T),Math.cos(J),Math.sin(J),r,n,i,l))}else y=y.concat(Pd(u,r,i,l));e.decoherence===!0&&(y=y.concat(Nd(u,r,a,s,l)))}else y=y.concat(Ks(e.orientationDeg,u,f,r,n,i,a,s,l,g))}else if(c==="block")for(var D=In(h,u,f,r,n,i,a,s,l)||[],K=0;K<D.length;K++)y.push(D[K]);else if(c==="absorb"){var N=typeof e.capacity=="number"&&e.capacity>0?e.capacity:64;y.push({set:u+".is_alive",to:r(0)}),m=!0,b={capacity:N},e.emissivity!==void 0&&e.emissivity!==null&&(b.emissivity=e.emissivity)}else c==="destroy"&&y.push({set:u+".is_alive",to:r(0)});if(p.indexOf("mark")!==-1&&(y=y.concat(Gs(e.markTag||""))),p.indexOf("count")!==-1&&(y.push({set:f+".count",to:i("+",n(f,"count"),r(1))}),m=!0),p.indexOf("recolor")!==-1){var B=hb(e.color);B&&(y=y.concat(Gs({"render.color":B})))}var ne=y.length>0?{on:"collision",ops:y}:null;if(ne!==null)if(O)gn(ne,cb(w.plate3,u,f,r,n,i,a,s,l));else if(S){var oe=w.obb&&isFinite(w.obb.hw)?w.obb.hw:0;gn(ne,Id(w.obb.normal,oe,u,f,r,n,i,a,s,l,g))}else gn(ne,$n(h,!1,u,f,r,n,a,s,l));return{program:ne,collectCollided:m,radiation:b}}var xa=ce(()=>{ba();Yu();Xu();o($n,"_buildTriggerExpr");o(gn,"_applyProgramTrigger");o(In,"_buildEjectOps");o(Zu,"_buildVelocityFlipOp");o(Rd,"_buildIncidenceReflectOps");o(Dd,"_buildIncidenceReflectOps3D");o(jd,"_buildAngledReflectOps");o(Ld,"_buildSwapReflectOps");o(Ks,"_buildReflectOps");o(Id,"_buildTiltedReflectGuardTrigger");o($u,"_buildFaceExitEjectOps");o(sb,"_tilted3DGates");o(lb,"_buildZFaceExitEjectOp");o(Hs,"_gateOps");o(ub,"_buildPitchedReflectOps");o(cb,"_buildPitchedGuardTrigger");o(fb,"_buildPitchedExitEjectOps");o(Pd,"_buildOmniRandomOps");o(Fd,"_buildConstrainedRandomOps");o(Nd,"_buildDecoherenceOps");o(Ti,"_uncompilable");o(_a,"compileActions");o(hb,"_rgbaCsv");o(ec,"compileWallV2")});var tc={};Oe(tc,{Rectangle:()=>lt});function lt(e,t,r,n,i,a){a===void 0&&(a=!0),this.is_centered=a,this.data=i||null,this.w=r,this.h=n,a?(this._x=e,this._y=t,this._left=e-r/2,this._right=e+r/2,this._top=t-n/2,this._bottom=t+n/2):(this._x=e+r/2,this._y=t+n/2,this._left=e,this._right=e+r,this._top=t,this._bottom=t+n),this.r=r/2}var Oo=ce(()=>{o(lt,"Rectangle");Object.defineProperty(lt.prototype,"x",{get:o(function(){return this._x},"get"),set:o(function(e){this._x=e,this._left=e-this.w/2,this._right=e+this.w/2},"set")});Object.defineProperty(lt.prototype,"y",{get:o(function(){return this._y},"get"),set:o(function(e){this._y=e,this._top=e-this.h/2,this._bottom=e+this.h/2},"set")});Object.defineProperty(lt.prototype,"left",{get:o(function(){return this._left},"get"),set:o(function(e){this._left=e,this._x=e+this.w/2,this._right=e+this.w},"set")});Object.defineProperty(lt.prototype,"right",{get:o(function(){return this._right},"get"),set:o(function(e){this._right=e,this._x=e-this.w/2,this._left=e-this.w},"set")});Object.defineProperty(lt.prototype,"top",{get:o(function(){return this._top},"get"),set:o(function(e){this._top=e,this._y=e+this.h/2,this._bottom=e+this.h},"set")});Object.defineProperty(lt.prototype,"bottom",{get:o(function(){return this._bottom},"get"),set:o(function(e){this._bottom=e,this._y=e-this.h/2,this._top=e-this.h},"set")});Object.defineProperty(lt.prototype,"area",{get:o(function(){return this.w*this.h},"get")});lt.prototype.contains=function(e){return this.left<=e.left&&this.right>=e.right&&this.top<=e.top&&this.bottom>=e.bottom};lt.prototype.intersects=function(e){return this.left<=e.right&&this.right>=e.left&&this.top<=e.bottom&&this.bottom>=e.top};lt.prototype.overlaps=function(e){if(!this.intersects(e))return null;var t=Math.max(this.left,e.left),r=Math.min(this.right,e.right),n=Math.max(this.top,e.top),i=Math.min(this.bottom,e.bottom);return new lt(t,n,r-t,i-n,null,!1)};lt.prototype.eject=function(e,t,r){if(this.overlaps(e)){var n=e.left,i=e.top;switch(t){case"top":i=this.top-e.h-1;break;case"bottom":i=this.bottom+1;break;case"left":n=this.left-e.w-1;break;case"right":n=this.right+1;break;default:var a=Math.abs(this.left-e.left),s=Math.abs(this.right-e.left),l=Math.abs(this.top-e.top),u=Math.abs(this.bottom-e.top),f=Math.min(a,s,l,u);f===a?n=r?this.left+1:this.left-e.w-1:f===s?n=r?this.right-e.w-1:this.right+1:f===l?i=r?this.top+1:this.top-e.h-1:i=r?this.bottom-e.h-1:this.bottom+1}e.top=i,e.left=n}};lt.prototype.xDistanceFrom=function(e){return this.left<=e.rect.x&&e.rect.x<=this.right?0:Math.min(Math.abs(e.rect.x-this.left),Math.abs(e.rect.x-this.right))};lt.prototype.yDistanceFrom=function(e){return this.top<=e.rect.y&&e.rect.y<=this.bottom?0:Math.min(Math.abs(e.rect.y-this.top),Math.abs(e.rect.y-this.bottom))};lt.prototype.sqDistanceFrom=function(e){var t=this.xDistanceFrom(e),r=this.yDistanceFrom(e);return t*t+r*r};lt.prototype.distanceFrom=function(e){return Math.sqrt(this.sqDistanceFrom(e))};lt.prototype.toString=function(){return"Rectangle(x: "+this._x+", y: "+this._y+", w: "+this.w+", h: "+this.h+", left: "+this._left+", right: "+this._right+", top: "+this._top+", bottom: "+this._bottom+", is_centered: "+this.is_centered+")"}});var ti={};Oe(ti,{FIELD_ENVELOPE_KEYS:()=>db,FIELD_TYPES:()=>Fn,UX_DRAGGABLE_MODES:()=>Eo,UX_ENVELOPE_KEYS:()=>pb,UX_HANDLE_ZONES:()=>Js,UX_SHELL_RENDER:()=>nc,normalizeFieldDescriptor:()=>Nn,normalizeUx:()=>Oa});function Ys(e){return typeof e=="string"&&e.length>0}function rc(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ei(e,t){throw new Error('[lib/shim/field-descriptor] normalizeFieldDescriptor(name="'+String(e)+'"): '+t+" (FAIL-LOUD \u2014 throw-or-apply, never silently dropped/defaulted-around.)")}function Nn(e){if(!e||typeof e!="object")throw new Error("[lib/shim/field-descriptor] normalizeFieldDescriptor requires a field descriptor object; got "+(e===null?"null":typeof e)+". (FAIL-LOUD.)");var t=e.name;Ys(t)||ei(t,'"name" must be a non-empty string.');var r=e.type;Fn.indexOf(r)===-1&&ei(t,'"type" must be one of ['+Fn.join(", ")+']; got "'+String(r)+'".'),Ys(e.description)||ei(t,'"description" must be a non-empty string.'),e.unit!==void 0&&!Ys(e.unit)&&ei(t,'"unit", when present, must be a non-empty string.'),e.constraint!==void 0&&!rc(e.constraint)&&ei(t,'"constraint", when present, must be a plain object.'),e.engineVisible!==void 0&&typeof e.engineVisible!="boolean"&&ei(t,'"engineVisible", when present, must be a boolean.'),e.widgetHint!==void 0&&!Ys(e.widgetHint)&&ei(t,'"widgetHint", when present, must be a non-empty string.'),e.widgetConfig!==void 0&&!rc(e.widgetConfig)&&ei(t,'"widgetConfig", when present, must be a plain object.');var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n.name=t,n.type=r,n}function Pn(e){throw new Error("[lib/shim/field-descriptor] normalizeUx: "+e+" (FAIL-LOUD \u2014 throw-or-apply, never silently dropped/defaulted-around.)")}function Oa(e){var t={resizable:!0,draggable:{"2d":!0},handles:Js.slice(),shellRender:"design"};if(e==null)return t;if((typeof e!="object"||Array.isArray(e))&&Pn("a ux block must be a plain object; got "+(Array.isArray(e)?"array":typeof e)+"."),Object.keys(Md).forEach(function(s){e[s]!==void 0&&Pn('"'+s+'" is DELETED \u2014 '+Md[s]+".")}),e.resizable!==void 0&&(typeof e.resizable!="boolean"&&Pn('"resizable" must be a boolean.'),t.resizable=e.resizable),e.draggable!==void 0){rc(e.draggable)||Pn('"draggable" must be a { "2d" } object.'),Object.keys(e.draggable).forEach(function(s){Eo.indexOf(s)===-1&&Pn('"draggable.'+s+'" is not a draggable mode (['+Eo.join(", ")+"]) \u2014 a 3D scene never cursor-drags.")});for(var r={"2d":!0},n=0;n<Eo.length;n++){var i=Eo[n];e.draggable[i]!==void 0&&(typeof e.draggable[i]!="boolean"&&Pn('"draggable.'+i+'" must be a boolean.'),r[i]=e.draggable[i])}t.draggable=r}if(e.handles!==void 0){Array.isArray(e.handles)||Pn('"handles" must be an array of zone names.');for(var a=0;a<e.handles.length;a++)Js.indexOf(e.handles[a])===-1&&Pn('"handles" entry "'+String(e.handles[a])+'" is not a member of UX_HANDLE_ZONES (['+Js.join(", ")+"]).");t.handles=e.handles.slice()}else e.resizable===!1&&(t.handles=["move"]);return e.shellRender!==void 0&&(nc.indexOf(e.shellRender)===-1&&Pn('"shellRender" must be one of ['+nc.join(", ")+']; got "'+String(e.shellRender)+'".'),t.shellRender=e.shellRender),t}var Fn,db,Js,Eo,nc,pb,Md,Ci=ce(()=>{Fn=Object.freeze(["number","boolean","string","enum","enum-set","rgb","rect","rect-array","readonly","forbidden","object","writable"]),db=Object.freeze(["name","type","constraint","unit","description","engineVisible","widgetHint","widgetConfig","default"]);o(Ys,"_isStr");o(rc,"_isPlainObject");o(ei,"_fail");o(Nn,"normalizeFieldDescriptor");Js=Object.freeze(["move","scale-tl","scale-tr","scale-bl","scale-br","scale-t","scale-b","scale-l","scale-r"]),Eo=Object.freeze(["2d"]),nc=Object.freeze(["design","run","never"]),pb=Object.freeze(["resizable","draggable","handles","shellRender"]),Md=Object.freeze({inspectorSections:"the Inspector shows a DECLARED object through its own descriptor (no per-role section list)"});o(Pn,"_uxFail");o(Oa,"normalizeUx")});function Qs(e,t){if(!t||typeof t!="object"||!Array.isArray(t.fields))throw new TypeError('[lib/frqtl/objects/schema] descriptor "'+e+'" must be an object with a fields array (and a description). (FAIL-LOUD.)');for(var r=Fn,n=t.fields,i=0;i<n.length;i++){var a=n[i].type;if(r.indexOf(a)===-1)throw new Error('[lib/frqtl/objects/schema] descriptor "'+e+'" field "'+n[i].name+'" has type "'+a+`" \u2014 not a member of lib/shim/field-descriptor's FIELD_TYPES ([`+r.join(", ")+"]). (FAIL-LOUD \u2014 the field-type vocabulary is shared; add the type at the ONE owner, lib/shim/field-descriptor/index.js, never here.)")}if(t.ux!==void 0)try{Oa(t.ux)}catch(s){throw new Error('[lib/frqtl/objects/schema] descriptor "'+e+'" has an invalid ux block: '+s.message)}return t}var ic=ce(()=>{Ci();o(Qs,"validateDescriptor")});var Ud,zd,Vd,qd=ce(()=>{Ln();Ud={kind:"Frame",description:"Any simulation frame (leaf or composite). Provides writable access to engine-core properties via getFrameProperty/setFrameProperty. Leaf frames (is_leaf=true) are the fundamental quanta; composite frames are parent nodes in the Frame hierarchy. The Frame Axiom: everything is a Frame \u2014 there is no separate particle class. Position/velocity/mass writes bypass move() by design (user override); the engine's CA rules reconcile topology and wavelength on the next tick. Topology (parent/children) is engine-owned and FORBIDDEN from user writes.",fields:[{name:"x",type:"writable",engineVisible:!0,unit:"px",description:"Frame center X position (physics pixels). Write repositions the frame directly, bypassing move() \u2014 user override. The engine does not clamp; caller is responsible for placing within bounds. Children that escape their parent rect are released next tick by releaseEscapedChildren."},{name:"y",type:"writable",engineVisible:!0,description:"Frame center Y position (physics pixels). Write repositions the frame directly, bypassing move() \u2014 user override."},{name:"z",type:"writable",engineVisible:!0,description:"Frame center Z position (depth, physics pixels). Default 0.0 when active_axes.z is false (2D mode). Bite 3 (ws-3d-discrete-walk): set by the 3D emitter; moved by the independent z yo-yo coin when active_axes.z is true. Cube edge = w (spec \xA711 \u2014 no separate d field; cubes only)."},{name:"left",type:"writable",engineVisible:!0,description:"Frame left edge (physics pixels). Write repositions the frame by its left edge (mirrors lo._eject otherRect.left = newLeft). Bit-identical to the native WALL eject \u2014 used in \xA710.3 eject-expression programs. Setting left also updates right; center x is derived."},{name:"top",type:"writable",engineVisible:!0,description:"Frame top edge (physics pixels). Write repositions the frame by its top edge (mirrors lo._eject otherRect.top = newTop). Bit-identical to the native WALL eject \u2014 used in \xA710.3 eject-expression programs. Setting top also updates bottom; center y is derived."},{name:"vx",type:"writable",engineVisible:!0,unit:"px/tick",description:"X velocity / momentum (pixels/tick). Positive = rightward, negative = leftward. The 1px/tick speed limit still applies on the next move() call; excess accumulates back into vx."},{name:"vy",type:"writable",engineVisible:!0,description:"Y velocity / momentum (pixels/tick). Positive = downward (screen coords), negative = upward."},{name:"vz",type:"writable",engineVisible:!0,description:"Z velocity / momentum (pixels/tick). Default 0.0 when active_axes.z is false (2D mode). When active_axes.z is true, the yo-yo z coin adds/subtracts to vz each tick for the transverse axes (spec \xA73 / D5/D10). The Euclidean L2 walk probs include vz: D = sqrt(vx\xB2+vy\xB2+vz\xB2)."},{name:"mass",type:"writable",engineVisible:!0,description:"Pixel occupancy count. Feeds setWavelength() on the next tick (FrameStore.set_wavelength). Higher mass \u2192 shorter wavelength \u2192 higher frequency (E=mc\xB2 analog, invariant 6)."},{name:"charge",type:"writable",engineVisible:!0,description:'Charge polarity: "POSITIVE" or "NEGATIVE" (canonical SCREAMING_SNAKE). Determines wave phase (sine vs cosine random walk) and bonding attraction/repulsion. Wire format: provider translates to engine-native (JS: 0/1; Rust: Charge enum).'},{name:"is_alive",type:"writable",engineVisible:!0,description:"Liveness flag. Setting false kills the frame: it is excluded from physics next tick and GC'd at end-of-tick. Equivalent to killFrame(id) but accessed uniformly. Children of a killed composite are orphaned (not recursively killed) \u2014 topology is reconciled by garbageCollectDeadParents."},{name:"is_stationary",type:"writable",engineVisible:!0,description:"Pins the frame in place: move() is skipped when true. Existing per-frame flag (FrameStore.is_stationary). Used in bespoke experiments to freeze specific frames while others evolve."},{name:"wrap",type:"writable",engineVisible:!0,description:"Toroidal boundary for this individual frame. When true the frame wraps at the canvas edges instead of escaping or bouncing. Overrides the universe-level wrap setting for this frame."},{name:"speed_prob",type:"writable",engineVisible:!0,description:'Per-frame OVERRIDE of the leaf longitudinal "speed probability" \u2014 the probability the frame takes its along-momentum step this tick (frame.rs move_frame leaf gate). Sentinel -1.0 (default; any negative resets to it) = derive from fullness (mass/capacity). When >= 0.0 it overrides the gate so user space can set the move-probability independent of mass \u2014 e.g. red vs blue light sharing a speed while differing in momentum/wavelength. Does NOT change the orthogonal wavelength.'},{name:"local_time",type:"writable",constraint:{integer:!0},engineVisible:!0,description:"Per-frame wave-phase counter (integer ticks; frame.rs local_time). Drives the spin/coin-flip via local_time % wavelength. Incremented each tick; reset to 0 on collision/reset. Op-programs that reproduce the native reset() (e.g. compiled RANDOM_* collision behavior) write 0 here. CANONICAL home for the writable-prop contract \u2014 both engines mirror this descriptor; neither hand-lists it (schema-mirror-drift fix)."},{name:"data",type:"writable",engineVisible:!0,dataBubbleSchema:ar,description:"The per-frame data bubble: { detection, render, ext }. Sub-shape is owned by lib/shim/frame-data (SECTION_KEYS + normalizeDataBubble). detection \u2014 written by engine MARK/DETECT primitives (detector_name). render \u2014 written by sugar (emitter stamps data.render.color); renderer reads. ext \u2014 developer-extensible; JS-only (not cross-engine assertable). NEVER enumerate the section keys here \u2014 always resolve from FrameDataSchema."},{name:"fullness",type:"readonly",engineVisible:!0,description:"Derived: mass / capacity (0.0\u20131.0). Used by the renderer for color mapping and by detectors for density measurement. Not directly writable \u2014 set mass to change fullness indirectly."},{name:"capacity",type:"readonly",engineVisible:!0,unit:"px\xB2",description:"Derived: rect.w * rect.h (physics pixels). Fixed at frame creation; determined by the frame's bounding rect size."},{name:"child_count",type:"readonly",engineVisible:!0,description:"Number of direct children in this frame's hierarchy (0 for leaf frames). Per-tick result; changes as promote/merge/release rules run."},{name:"collided_id",type:"readonly",engineVisible:!0,description:"ID of the other frame this frame collided with in the last tick, or -1/null if no collision occurred. Per-tick result from the Phase C collide pass."},{name:"r",type:"readonly",engineVisible:!0,description:"Radius cache: max(rect.w, rect.h) / 2. Used in proximity checks and rendering. Derived from rect size."},{name:"w",type:"readonly",engineVisible:!0,description:"Frame width in physics pixels (fixed at creation, derived from rect.w). Read in op-program scope for eject geometry: set frame.left = self.left - frame.w - 1. For leaf quanta this is 1."},{name:"h",type:"readonly",engineVisible:!0,description:"Frame height in physics pixels (fixed at creation, derived from rect.h). Read in op-program scope for eject geometry: set frame.top = self.top - frame.h - 1. For leaf quanta this is 1."},{name:"layer",type:"readonly",engineVisible:!0,description:"Dimension layer membership (u32). Assigned at frame creation; engine-managed \u2014 changes only when the frame is promoted to a higher dimension. User writes are REJECTED (use the promote/detach structural primitives)."},{name:"prev_x",type:"readonly",engineVisible:!0,description:`Derived (scope-read): frame CENTER X before this tick's move() (physics pixels). Readable in op-program scope as Ref(0,"prev_x") \u2014 the compiled MOMENTUM_BASED behavior restores pre-move position via set 0.x = prev_x. Read-only \u2014 write THROWS (engine-owned per-tick snapshot, saved by Frame::move).`},{name:"prev_y",type:"readonly",engineVisible:!0,description:`Derived (scope-read): frame CENTER Y before this tick's move() (physics pixels). Readable in op-program scope as Ref(0,"prev_y"). Read-only \u2014 write THROWS (engine-owned per-tick snapshot, saved by Frame::move).`},{name:"prev_z",type:"readonly",engineVisible:!0,description:"Derived (scope-read): frame CENTER Z before this tick's move() (physics pixels). Default 0.0 when active_axes.z is false. Bite 3 (ws-3d-discrete-walk): saved by Frame::move_frame alongside prev_x/prev_y. Read-only \u2014 write THROWS (engine-owned per-tick snapshot)."},{name:"parent",type:"forbidden",engineVisible:!1,description:"FORBIDDEN \u2014 engine-owned topology. The parent link is managed exclusively by the engine's promote/detach/GC rules. Any write attempt FAIL-LOUDs with a TypeError. To move a frame: write its x/y position and let the engine reconcile topology (releaseEscapedChildren drops children outside their parent rect next tick)."},{name:"children",type:"forbidden",engineVisible:!1,description:"FORBIDDEN \u2014 engine-owned topology. The children list is managed exclusively by the engine's promote/attach/detach rules. Any write attempt FAIL-LOUDs with a TypeError."}]},zd={kind:"Universe",description:"The top-level simulation universe. Most properties are read-only state accessible from op-programs via HANDLE_UNIVERSE (2) in the expression scope; a small number of universe-wide physics constants (currently: wavelengthScale) are writable through the validated setUniverseProperty accessor. THROW-OR-APPLY: any write to an unknown or readonly field FAIL-LOUDs with TypeError \u2014 there is no bind-local property list anywhere in the stack.",fields:[{name:"tick",type:"readonly",engineVisible:!0,description:'Current tick count (u64). Increments once per doTick() call. Available in op-program scope via Ref(HANDLE_UNIVERSE, "tick"). Write THROWS \u2014 tick is engine-owned and monotonically increasing.'},{name:"activeQuanta",type:"readonly",engineVisible:!0,description:'Number of currently alive leaf quanta (usize). Derived by counting is_alive=true frames in the fundamental dimension. Available in op-program scope via Ref(HANDLE_UNIVERSE, "activeQuanta"). Write THROWS \u2014 this is a derived aggregate, not a writable property.'},{name:"wavelengthScale",type:"number",constraint:{min:1,integer:!0},widgetHint:"slider",widgetConfig:{max:32,step:1},engineVisible:!0,description:"Layer 1 \u2014 universe-wide oscillation-wavelength scale: `wavelength = floor((capacity/mass) * wavelengthScale)`, minimum 4 (Core Axioms \xA76B). Every Frame in the universe shares this one multiplier. Layer 2 \u2014 physics behavior: this is Wave Interference's and Double-Slit's primary knob \u2014 raising it stretches every Frame's transverse oscillation period, widening fringe/interference spacing without changing any Frame's mass or capacity."}]},Vd={kind:"Dimension",description:'A scale layer in the simulation (a "dimension" in FRQTL terminology). Each dimension is a spatial index (QuadTree) that organises frames at one scale. Properties are readonly \u2014 the engine manages dimensional structure. THROW-OR-APPLY: any write attempt FAIL-LOUDs with TypeError.',fields:[{name:"layer",type:"readonly",engineVisible:!0,description:"Dimension layer index (u32). Assigned at creation (add_dimension / addDimension). 0 = fundamental (leaf-quanta layer). Higher values = higher scales. Engine-owned \u2014 write THROWS (topology is engine-derived)."},{name:"frame_count",type:"readonly",engineVisible:!0,description:"Number of frames currently in this dimension (usize). Changes each tick as frames are added, promoted, or GC'd. Derived from the dimension's frame list length \u2014 not user-writable."}]}});function oc(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array(length "+e.length+")":typeof e}function sc(e){var t;try{t=JSON.stringify(e)}catch{t=String(e)}return t===void 0&&(t=String(e)),t.length>60?t.slice(0,60)+"\u2026":t}function br(e,t,r,n){throw new TypeError("[lib/frqtl/objects/schema] normalizeValue: "+(e||"<kind>")+"."+(t&&t.name?t.name:"<field>")+' is declared type "'+(t&&t.type)+'" and expects '+r+"; got "+oc(n)+" "+sc(n)+". (FAIL-LOUD \u2014 throw-or-apply, never a silently accepted wrong type.)")}function Ri(e){return typeof e=="number"&&isFinite(e)}function Ot(e){if(!Object.prototype.hasOwnProperty.call(Ea,e))throw new TypeError("[lib/frqtl/objects/schema] rectTupleText("+sc(e)+"): a rect tuple has "+Object.keys(Ea).join(" or ")+" elements. (FAIL-LOUD.)");return"["+Ea[e].join(", ")+"]"}function gb(e){var t=e.constraint&&e.constraint.values||null;if(!t||typeof t!="object")return null;var r=Object.keys(t);if(r.length===0)return null;for(var n=r.slice(),i=0;i<r.length;i++)n.indexOf(t[r[i]])===-1&&n.push(t[r[i]]);return n}function Bd(e,t,r){var n=gb(e);return n?(n.indexOf(t)===-1&&br(r,e,"one of ["+n.join(", ")+"]",t),t):(typeof t!="string"&&typeof t!="number"&&br(r,e,"a string or number (this field declares no constraint.values vocabulary to check against)",t),t)}function Wd(e,t,r,n){return(!Array.isArray(t)||t.length!==4&&t.length!==6||!t.every(Ri))&&br(r,e,n,t),t.slice()}function Gd(e,t){var r=t||"worldRect(r)";function n(a){throw new TypeError("[lib/frqtl/objects/schema] "+r+": "+a+"; got "+oc(e)+" "+sc(e)+". A world rect is { left, top, w, h } (or the "+Ot(4)+" / "+Ot(6)+" tuple) with positive w and h, written ONCE by the co-init call \u2014 EGPTUniverse.create({ rect }) \u2190 new FrqtlApp({ canvasW, canvasH }) / exp.createCanvas(w, h, cfg). There is no default world size. (FAIL-LOUD.)")}o(n,"fail"),(e==null||typeof e!="object")&&n("no world rect");var i;return Array.isArray(e)?((e.length!==4&&e.length!==6||!e.every(Ri))&&n("a rect tuple must be 4 or 6 finite numbers"),i=e.length===4?{left:e[0],top:e[1],w:e[2],h:e[3]}:{left:e[0],top:e[1],z:e[2],w:e[3],h:e[4],d:e[5]}):(i={w:e.w,h:e.h},["left","top","z","d"].forEach(function(a){e[a]===void 0||e[a]===null||(Ri(e[a])||n('"'+a+'" must be a finite number'),i[a]=e[a])})),(!Ri(i.w)||!(i.w>0))&&n("w must be a positive finite number"),(!Ri(i.h)||!(i.h>0))&&n("h must be a positive finite number"),i}function Hd(e,t,r){if(!e||typeof e!="object"||typeof e.type!="string")throw new TypeError('[lib/frqtl/objects/schema] normalizeValue requires a field descriptor carrying a "type"; got '+oc(e)+". (FAIL-LOUD.)");if(!Object.prototype.hasOwnProperty.call(ac,e.type))throw new TypeError('[lib/frqtl/objects/schema] normalizeValue: field "'+e.name+'" declares type "'+e.type+'", which has no normalizer row. Field types are owned by lib/shim/field-descriptor (FIELD_TYPES) \u2014 add the type THERE and a row in VALUE_NORMALIZERS here. (FAIL-LOUD.)');var n=ac[e.type];return e.type==="readonly"||e.type==="forbidden"?n(e,t,r):t==null?t:n(e,t,r)}var Ea,ac,Kd,Di=ce(()=>{o(oc,"_describeValue");o(sc,"_previewValue");o(br,"_valueFail");o(Ri,"_isFiniteNumber");Ea=Object.freeze({4:Object.freeze(["left","top","w","h"]),6:Object.freeze(["left","top","z","w","h","d"])});o(Ot,"rectTupleText");o(gb,"_enumMembers");o(Bd,"_normalizeEnumMember");o(Wd,"_normalizeRectTuple");o(Gd,"worldRect");ac={number:o(function(e,t,r){Ri(t)||br(r,e,"a finite number (a numeric STRING is not a number \u2014 parse it at the caller)",t);var n=e.constraint||{},i=n.integer===!0?Math.round(t):t;return typeof n.min=="number"&&i<n.min&&br(r,e,"a value >= the declared min "+n.min,t),typeof n.max=="number"&&i>n.max&&br(r,e,"a value <= the declared max "+n.max,t),i},"number"),boolean:o(function(e,t,r){if(t===!0||t===1)return!0;if(t===!1||t===0)return!1;br(r,e,"true, false, 0 or 1",t)},"boolean"),string:o(function(e,t,r){return typeof t!="string"&&br(r,e,"a string",t),t},"string"),enum:o(function(e,t,r){return Bd(e,t,r)},"enum"),"enum-set":o(function(e,t,r){Array.isArray(t)||br(r,e,"an array of declared members",t);for(var n=0;n<t.length;n++)Bd(e,t[n],r);return t.slice()},"enum-set"),rgb:o(function(e,t,r){return(!Array.isArray(t)||t.length!==3||!t.every(Ri))&&br(r,e,'an array of exactly 3 finite numbers [r, g, b] (a CSV "r,g,b,a" string is the frame-data render wire, not this field \u2014 convert at lib/shim/frame-data before the write)',t),t.slice()},"rgb"),rect:o(function(e,t,r){return Wd(e,t,r,"an array of 4 finite numbers "+Ot(4)+" or the 6-element explicit z/depth form "+Ot(6))},"rect"),"rect-array":o(function(e,t,r){Array.isArray(t)||br(r,e,"an array of rect tuples",t);for(var n=[],i=0;i<t.length;i++)n.push(Wd(e,t[i],r,"every entry to be an array of 4 finite numbers "+Ot(4)+" (or 6, "+Ot(6)+"); entry "+i+" is not"));return n},"rect-array"),readonly:o(function(e,t,r){br(r,e,"NO write at all \u2014 a readonly field is derived/computed and inspectable only",t)},"readonly"),forbidden:o(function(e,t,r){br(r,e,"NO write at all \u2014 this property is engine-owned topology",t)},"forbidden"),object:o(function(e,t,r){return typeof t!="object"&&br(r,e,"a structured object (arrays included)",t),t},"object"),writable:o(function(e,t){return t},"writable")};o(Hd,"normalizeValue");Kd=Object.freeze(Object.keys(ac))});function Xs(){var e=Ws["render.shape"],t={};if(Array.isArray(e))for(var r=0;r<e.length;r++)t[e[r]]=e[r];return t}var vb,yb,bb,en,Zs=ce(()=>{qd();ic();Di();Ln();Ut();$r();o(Xs,"shapeValuesMap");vb={kind:"particle",description:'A leaf frame (is_leaf=true) \u2014 the fundamental quantum of the simulation. Particles are not directly placeable; they are emitted by QuantumEmitter, PointSource, and other emitter objects. Every "particle" IS a Frame: the Frame Axiom states there is no separate particle class. Leaf frames have mass = capacity (engine invariant).',fields:[{name:"x",type:"readonly",engineVisible:!0,description:"Current X position (physics pixels)"},{name:"y",type:"readonly",engineVisible:!0,description:"Current Y position (physics pixels)"},{name:"vx",type:"readonly",engineVisible:!0,description:"Current X momentum (pixels/tick). Accumulates when the 1px/tick speed limit is exceeded."},{name:"vy",type:"readonly",engineVisible:!0,description:"Current Y momentum (pixels/tick). Accumulates when the 1px/tick speed limit is exceeded."},{name:"mass",type:"readonly",engineVisible:!0,description:"Pixel occupancy count (Frame Axiom: leaf mass = capacity). Mass drives wavelength: higher mass \u2192 shorter wavelength \u2192 higher frequency."},{name:"wavelength",type:"readonly",engineVisible:!0,description:"floor(capacity/mass * WAVELENGTH_CONSTANT), minimum 4 (engine invariant 6). Controls the probabilistic coin-flip that creates wave behavior."}]},yb={kind:"backdrop",description:"A render-only background image or color fill. Created as a LargeObject with NONE collision type and no actions, so it is invisible to the physics engine. Use it for scene backgrounds, lab diagrams, or any decoration that should never interact with particles.",fields:[{name:"rect",type:"rect",engineVisible:!1,description:"Bounding rectangle for the backdrop image or fill (render-only). Typically matches the full canvas rect."},{name:"visible",type:"boolean",engineVisible:!1,description:"Whether the backdrop is rendered (render-only). Toggling false hides the background."},{name:"color",type:"rgb",engineVisible:!1,description:"Fallback fill color [r, g, b] used when no image is provided (render-only)."},{name:"alpha",type:"number",constraint:{min:0,max:255,integer:!0},engineVisible:!1,widgetHint:"slider",description:"Render opacity 0-255 (render-only)"}]},bb={kind:"LargeObject",description:"A rectangular engine-registered boundary object (wall, detector, barrier). The engine evaluates particle collisions against every registered LargeObject each tick and applies the configured collision_type + actions to matching particles.",fields:[{name:"rect",type:"rect",engineVisible:!0,unit:"px",description:"Bounding rectangle in physics pixels "+Ot(4)+". FRQTL-MAINT (2026-07-01): may also carry explicit z/depth "+Ot(6)+" \u2014 WASM-only, MIRRORS the engine's Rectangle::from_top_left argument order. Omitting z/d is back-compat: the engine defaults z=0, d=w (bit-identical to the pre-fix hardcoded behavior \u2014 see #61)."},{name:"region",type:"object",engineVisible:!0,internal:!0,description:'SWEPT-OBB narrow-phase collision region (circulation \xA72): { kind:"obb", theta(radians), hw, hh, hz } produced by the SlabFace authority for a rotated wall, or null (default) = the byte-identical AABB path. Convention-free geometry (theta in the engine frame, never raw orientationDeg). The engine narrow-phase filters candidates by a SWEPT prev\u2192now segment-vs-OBB test ahead of BOTH the op-program trigger and the collided-frame collection, so a tilted mirror collides AT its drawn face (not the AABB entry plane). WASM-only.'},{name:"collision_type",type:"enum",constraint:{values:Ee},engineVisible:!1,description:"SUGAR-INPUT (compiled to an op-program at registration; engine has no collision_type dispatch). NONE = pass-through; BOUNCE = reverse momentum; WALL = stop; RANDOM_X/Y/XY = randomise that velocity component; MOMENTUM_BASED = redirect proportional to incoming momentum."},{name:"actions",type:"enum-set",constraint:{values:st},engineVisible:!1,description:"SUGAR-INPUT (compiled to an op-program at registration; engine has no action dispatch). ABSORB = remove the particle; COUNT = increment hit counter; MARK = flag the particle (writes string_map.detector_name = loName); DETECT = record the detection event (same as MARK); LOG = emit a log entry; BOUNCE = apply bounce momentum; BLOCK = stop the particle."},{name:"name",type:"string",engineVisible:!1,description:"Human-readable identifier for this object (display/debug only; not engine-visible after construction)"},{name:"reposition",type:"enum",constraint:{values:{top:"top",bottom:"bottom",left:"left",right:"right",closest:"closest"}},engineVisible:!0,description:`Eject direction when a quantum is found overlapping this object's rect. "closest" ejects toward the nearest edge; the cardinal values force a specific side.`},{name:"search_padding",type:"number",constraint:{min:0,integer:!0},engineVisible:!1,description:"DEPRECATED / IGNORED. The engine no longer reads this; the collision search rect now expands by the dimension's mb_w. Retained only as a reserved positional constructor placeholder."},{name:"color",type:"rgb",engineVisible:!1,description:"Render color [r, g, b] 0-255 each. Affects only the drawn appearance; engine collision is unaffected."},{name:"alpha",type:"number",constraint:{min:0,max:255,integer:!0},engineVisible:!1,widgetHint:"slider",description:"Render opacity 0-255 (render-only). 0 = fully transparent, 255 = fully opaque."},{name:"visible",type:"boolean",engineVisible:!1,description:"Whether the object is drawn (render-only). Setting false hides the visual; engine collision detection remains active."},{name:"shellRender",type:"enum",constraint:{values:{design:"design",run:"run",never:"never"}},engineVisible:!1,description:`When this object's visual shell renders (render-only): design = only while authoring (Bite-4b marker default); run = always visible (the "red light bulb" opt-in); never = hidden. Generalizes the design-only marker suppression at the single _visibleLargeObjects authority; engine collision is unaffected.`},{name:"drawAsCircle",type:"boolean",engineVisible:!1,description:"Render as a circle inscribed in the bounding rect instead of a rectangle (render-only)."},{name:"shellShape",type:"enum",constraint:{values:Xs()},engineVisible:!1,description:`Render shape of this object's visual shell (render-only): ball|box|circle|cube|sphere. For a SphereEmitter this is the shape of the emitter's outer LO frame (the "red light bulb" orb vs a box). Honored by the provider draw layer (capability-based, zero engine change); absent/omitted falls back to drawAsCircle. cube/sphere degrade to box/ball in 2D.`},{name:"layer",type:"number",constraint:{min:0,integer:!0},engineVisible:!0,description:"Dimension layer this object is scoped to (0 = fundamental/lowest; null = all layers). Selects which Dimension passes this object participates in (observed_dimensions=[layer]; null = all). Candidates come from that dimension's frame list."},{name:"count",type:"number",constraint:{min:0,integer:!0},engineVisible:!0,description:"Writable integer counter (SLICE 3, binding item 2). Incremented via op-program: set self.count = self.count + 1. Routed through setObjectProperty like any property \u2014 NOT an interpreter special-case. Default 0; reset only by an explicit op or by user code. Mirrors the count field in the Rust LargeObjectSpec (universe.rs)."},{name:"program",type:"object",engineVisible:!0,internal:!0,description:'Op-program attached to this LO (\xA710.3 SLICE 3). Shape: { on: "collision"|"tick", ops: [{ set: "<handle>.<prop>", to: ExprAST }] }. on:"collision" \u2014 runs once per overlapping frame per tick, BEFORE ABSORB. on:"tick" \u2014 runs once per LO per tick (Phase A). null clears the program. Written via updateObjectProperty(handle, "LargeObject", "program", prog) \u2014 used by \xA710.3 L3 to attach eject op-programs to oven walls after registration.'},{name:"left",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.left (left edge in physics pixels). Read-only in scope; rect is the writable authority."},{name:"right",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.right (right edge = rect.left + rect.w). Read-only in scope."},{name:"top",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.top (top edge in physics pixels). Read-only in scope."},{name:"bottom",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.bottom (bottom edge = rect.top + rect.h). Read-only in scope."},{name:"cx",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.x (center X = rect.left + rect.w/2). Read-only in scope."},{name:"cy",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.y (center Y = rect.top + rect.h/2). Read-only in scope."},{name:"w",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.w (width in physics pixels). Read-only in scope."},{name:"h",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.h (height in physics pixels). Read-only in scope."},{name:"x",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.x (center X, alias for cx). Read-only; rect is the writable authority."},{name:"y",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.y (center Y, alias for cy). Read-only; rect is the writable authority."},{name:"near",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.near (near z-face = rect.z - rect.d/2 in centered terms, or the literal z corner in corner-mode registration). Read-only in scope; rect is the writable authority. WASM-only."},{name:"far",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.far (far z-face = rect.near + rect.d). Read-only in scope. WASM-only."},{name:"d",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.d (depth in physics pixels). Read-only in scope. WASM-only."},{name:"cz",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.z (center Z). Read-only in scope. WASM-only."}]},en=Object.freeze({particle:vb,backdrop:yb,Frame:Ud,Universe:zd,Dimension:Vd,LargeObject:bb});Object.keys(en).forEach(function(e){Qs(e,en[e])})});function qt(e){throw new Error("[kinds] "+e+" (FAIL-LOUD.)")}function at(e,t){typeof e!="function"&&qt("registerKind(Class, row): Class must be the part's class (got "+typeof e+").");let r=e.name;r||qt("registerKind: the class is anonymous \u2014 the kind name IS the class name, so a kind's class must be named."),(!t||typeof t!="object")&&qt("registerKind("+r+", row): row must be an object {"+lc.join(", ")+"}."),Object.prototype.hasOwnProperty.call(t,"name")&&qt("registerKind("+r+"): a row carries no `name` \u2014 the kind name IS the class name ("+r+"). To register under another name, rename the class.");for(let a of Object.keys(t))lc.indexOf(a)===-1&&qt("registerKind("+r+'): unknown row key "'+a+'" \u2014 a row carries '+lc.join(", ")+".");(typeof t.from!="string"||!t.from)&&qt("registerKind("+r+"): `from` is required \u2014 the defining module's own URL (from: import.meta.url).");try{new URL(t.from)}catch{qt("registerKind("+r+"): `from` must be a URL (import.meta.url), got "+JSON.stringify(t.from)+".")}let n=Object.prototype.hasOwnProperty.call(en,r)?en[r]:null;n&&t.descriptor!==n&&qt("registerKind("+r+', \u2026): "'+r+'" is a SCOPE descriptor row (schema/scopes.js SCOPE_DESCRIPTORS) \u2014 a scope is not a kind, and one name has one owner. Rename the class, or register the scope row itself by reference (descriptor: SCOPE_DESCRIPTORS.'+r+") ("+t.from+")."),Mn.has(r)&&qt('kind "'+r+'" is already registered by '+Mn.get(r).from+"; "+t.from+" registers it again \u2014 rename the class in the copy.");let i=t.descriptor;if((!i||typeof i!="object")&&qt("registerKind("+r+"): `descriptor` is required."),!n&&wb(i)){let a={};for(let s of Object.keys(i))s!=="kind"&&(a[s]=i[s]);i=a}if(!n&&Object.prototype.hasOwnProperty.call(i,"kind")&&qt("registerKind("+r+"): the descriptor carries a `kind` \u2014 the registry stamps it from the class name; a typed copy is a second derivation of the same fact. Delete the descriptor's kind line."),Qs(r,i),t.defaults!==void 0&&(t.defaults===null||typeof t.defaults!="object"||Array.isArray(t.defaults))&&qt("registerKind("+r+"): `defaults` must be a props object when given."),t.build!==void 0&&typeof t.build!="function"&&qt("registerKind("+r+"): `build` must be a function (props, ctx) \u2192 part when given."),t.palette!==void 0){let a=t.palette;(!a||typeof a!="object")&&qt("registerKind("+r+"): `palette` must be {"+uc.join(", ")+"}.");for(let s of Object.keys(a))uc.indexOf(s)===-1&&qt("registerKind("+r+'): unknown palette key "'+s+'" \u2014 '+uc.join(", ")+".");for(let s of["displayName","category","iconHint"])(typeof a[s]!="string"||!a[s])&&qt("registerKind("+r+"): palette."+s+" must be a non-empty string.");(typeof a.rank!="number"||!Number.isInteger(a.rank)||a.rank<0)&&qt("registerKind("+r+"): palette.rank must be a non-negative integer (the palette order).")}return n||Object.defineProperty(i,"kind",{value:r,enumerable:!0,writable:!1,configurable:!1}),Mn.set(r,Object.freeze({name:r,Class:e,from:t.from,descriptor:cc(i),defaults:t.defaults===void 0?void 0:cc(Object.assign({},t.defaults)),build:t.build,palette:t.palette?Object.freeze(Object.assign({},t.palette)):void 0})),e}function wb(e){for(let t of Mn.values())if(t.descriptor===e)return!0;return!1}function cc(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null&&!Array.isArray(e))return e;Object.freeze(e);for(let r of Object.keys(e))cc(e[r]);return e}function $s(e){return'kind "'+e+`" is not registered in this realm \u2014 import the module that defines it; published parts: '@descix/frqtl-web/parts'`}function ka(e){let t=Mn.get(e);if(!t)throw new Error("[kinds] "+$s(e)+". (FAIL-LOUD.)");return t.Class}function Xt(e){if(typeof e=="string")return Mn.get(e)||null;if(typeof e=="function"){let t=Mn.get(e.name);return t&&t.Class===e?t:null}return null}function Aa(){return Array.from(Mn.keys())}function Yd(){return Array.from(Mn.values()).filter(function(e){return!!e.palette}).sort(function(e,t){return e.palette.rank-t.palette.rank})}var lc,uc,Mn,Et=ce(()=>{ic();Zs();lc=Object.freeze(["from","descriptor","defaults","build","palette"]),uc=Object.freeze(["displayName","category","iconHint","rank"]),Mn=new Map;o(qt,"_fail");o(at,"registerKind");o(wb,"_isRegisteredDescriptor");o(cc,"_deepFreeze");o($s,"unregisteredKindMessage");o(ka,"kindNamed");o(Xt,"kindOf");o(Aa,"registeredKinds");o(Yd,"placeableKinds")});var hc={};Oe(hc,{LargeObject:()=>Se});function xb(e,t,r,n){if(typeof lt!="function")return{left:e,top:t,w:r,h:n};var i=new lt(e,t,r,n,null,!1);return Object.defineProperty(i,"toJSON",{value:o(function(){return{left:this.left,top:this.top,w:this.w,h:this.h}},"value"),enumerable:!1}),i}function Jd(e){return e?Array.isArray(e)?e:e.left!==void 0?e.z!==void 0||e.d!==void 0?[e.left,e.top,e.z!==void 0?e.z:0,e.w,e.h,e.d!==void 0?e.d:e.w]:[e.left,e.top,e.w,e.h]:e.x!==void 0&&e.width!==void 0?[e.x,e.y,e.width,e.height]:e:null}function Se(e,t,r,n,i,a,s,l,u,f){n=n||[],i=i||"",a=a||"closest",s=s||null,l=l!==void 0?l:1,u=u||[120,120,120],f=f||!1,this.universe=e,this._schemaKind="LargeObject";var c=Jd(t);this.rect=c.length===6?{left:c[0],top:c[1],z:c[2],w:c[3],h:c[4],d:c[5]}:xb(c[0],c[1],c[2],c[3]),this.color=u,this.alpha=255,this.visible=!0,this.drawAsCircle=!1,this.name=i,this.collision_type=r,this.reposition=a,this.search_padding=l,this.collect_collided=f,this.layer=Array.isArray(s)&&s.length===1?s[0]:null;var h=_a,g=h(n,i,a,r),p=g.program,m=p!==null?fc.NONE:r;this.actions=n.slice(),this.program=p;var b={rect:c,name:i,observed_dimensions:s||[]};p!==null&&(b.program=p),f&&(b.collect_collided=!0),this.handle=e.registerLargeObject(b),Array.isArray(e.largeObjects)||(e.largeObjects=[]),e.largeObjects.push(this)}var fc,_b,wr=ce(()=>{Rt();Ut();$r();xa();Oo();Et();Zs();fc=Ee;_b=st;o(xb,"_makeLoRect");o(Jd,"rectToArray");o(Se,"LargeObject");Se.prototype.setRect=function(e){var t=typeof this.rect.z=="number";if(!Array.isArray(e)||e.length!==(t?6:4)||!e.every(function(n){return typeof n=="number"&&isFinite(n)}))throw new TypeError('[LargeObject.setRect] "'+this.name+'" is a '+(t?"z-capable":"2D")+" LO and takes "+(t?"[l,t,z,w,h,d]":"[l,t,w,h]")+" of finite numbers; got "+JSON.stringify(e)+". (FAIL-LOUD.)");var r=this.rect;return t?(r.left=e[0],r.top=e[1],r.z=e[2],r.w=e[3],r.h=e[4],r.d=e[5]):(r.w=e[2],r.h=e[3],r.left=e[0],r.top=e[1]),this.universe&&typeof this.universe.updateObjectProperty=="function"&&this.universe.updateObjectProperty(this.handle,"LargeObject","rect",e.slice()),this};Se.prototype.setCollisionType=function(e){this.collision_type=e,this.universe.setLargeObjectCollisionType(this.handle,e)};Se.prototype.setActive=function(e){this.universe.setLargeObjectActive(this.handle,e)};Se.prototype.recompileActions=function(e){e=e||{};var t=e.collisionType!==void 0?e.collisionType:this.collision_type,r=e.actions!==void 0?e.actions:this.actions,n=_a,i=n(r,this.name,this.reposition,t),a=t;i.program!==null&&(a=fc.NONE),this.collision_type=t,this.actions=r.slice(),this.program=i.program,this.universe&&typeof this.universe.updateObjectProperty=="function"&&this.universe.updateObjectProperty(this.handle,"LargeObject","program",i.program)};Se.prototype.dispose=function(){if(!this._disposed){if(this._disposed=!0,this.universe&&typeof this.universe.unregisterLargeObject=="function")this.universe.unregisterLargeObject(this.handle);else if(this.universe&&Array.isArray(this.universe.largeObjects)){var e=this.universe.largeObjects.indexOf(this);e!==-1&&this.universe.largeObjects.splice(e,1)}}};Se.rectToArray=Jd;at(Se,{from:new URL("frqtl/parts/LargeObject.js",He()).href,descriptor:en.LargeObject,defaults:{collision_type:"BOUNCE",actions:[],reposition:"closest",search_padding:1,color:[120,120,120]},build:o(function(e,t,r){var n=r,i=e.rect&&e.rect.w||70,a=e.rect&&e.rect.h||70,s=e.rect&&e.rect.left!=null?e.rect.left:Math.round(t.x-i/2),l=e.rect&&e.rect.top!=null?e.rect.top:Math.round(t.y-a/2),u=e.collision_type||"RANDOM_XY",f=e.actions||[],c=e.name||"block "+(t.runner.largeObjects.length+1),h=e.reposition||"closest",g=e.color||[210,90,90],p=e.layer!=null?[e.layer]:null,m=new n(t.runner.universe,[s,l,i,a],u,f,c,h,p,1,g);return e.alpha!=null&&(m.alpha=e.alpha),e.visible!=null&&(m.visible=e.visible),e.drawAsCircle!=null&&(m.drawAsCircle=e.drawAsCircle),m._schemaKind=r.name,m},"build")})});function gc(e){var t={};return Object.keys(e).forEach(function(r){t[r]=r}),t}function Xd(e){e=e||{};var t=e.collisionBehavior||"nothing";if(!dc[t])throw new Error('[WallBehaviors] unknown collisionBehavior "'+t+'" \u2014 must be one of ['+Object.keys(dc).join(", ")+"].");if(t==="bounce"&&e.bounceDirection&&!pc[e.bounceDirection])throw new Error('[WallBehaviors] unknown bounceDirection "'+e.bounceDirection+'" \u2014 must be one of ['+Object.keys(pc).join(", ")+"].");var r=Array.isArray(e.hooks)?e.hooks:[];r.forEach(function(i){if(!mc[i])throw new Error('[WallBehaviors] unknown hook "'+i+'" \u2014 must be one of ['+Object.keys(mc).join(", ")+"].")});var n=ec({behavior:t,bounceDirection:e.bounceDirection||"reflect",angleConstraint:e.angleConstraint,orientationDeg:e.orientationDeg,decoherence:e.decoherence,hooks:r,markTag:e.markTag,color:e.color,capacity:e.capacity,emissivity:e.emissivity,reposition:e.reposition||"closest",is3D:e.is3D===!0,slabW:e.slabW,slabH:e.slabH,pitchDeg:e.pitchDeg,slabD:e.slabD});return{program:n.program,collectCollided:n.collectCollided,radiation:n.radiation,behavior:t,hooks:r.slice()}}function Zd(e){var t=Qd[e];if(!t)throw new Error('[WallBehaviors] unknown wall preset "'+e+'" \u2014 must be one of ['+Object.keys(Qd).join(", ")+"].");var r={};return Object.keys(t).forEach(function(n){n!=="label"&&(r[n]=Array.isArray(t[n])?t[n].slice():t[n])}),r}function vc(){return gc(dc)}function yc(){return gc(pc)}function bc(){return gc(mc)}var dc,pc,mc,Qd,el=ce(()=>{Ut();$r();xa();dc={nothing:"nothing",block:"block",bounce:"bounce",absorb:"absorb",destroy:"destroy"},pc={reflect:"reflect",random:"random"},mc={mark:st.MARK,count:st.COUNT,recolor:"recolor"};o(gc,"_valuesMap");o(Xd,"resolveWallSpec");Qd={mirror:{label:"Mirror",collisionBehavior:"bounce",bounceDirection:"reflect"},brick:{label:"Brick Wall",collisionBehavior:"bounce",bounceDirection:"random",decoherence:!1},"detector-screen":{label:"Detector Screen",collisionBehavior:"destroy",hooks:["count"],countFilter:"any"},"transparent-probe":{label:"Transparent Probe",collisionBehavior:"nothing",hooks:["mark","count"]},wall:{label:"Wall",collisionBehavior:"block"}};o(Zd,"expandWallPreset");o(vc,"wallBehaviorV2ValuesMap");o(yc,"bounceDirectionValuesMap");o(bc,"wallHookValuesMap")});var xc={};Oe(xc,{DEFAULT_EMISSIVITY:()=>rp,attachAbsorberBackingFrame:()=>wc,buildAbsorbRadiationTickFn:()=>_c,deriveBackingLevel:()=>np});function $d(e,t){var r=Number(e);if(!isFinite(r)||r<=0||r>1)throw new Error("["+t+"] emissivity must be a fullness fraction in (0, 1] \u2014 got "+JSON.stringify(e)+". Above 1 is a move gate above 1; 0 is refused because the emitted-mass law floors at 1 cell and could not honour it.");return r}function np(e,t){for(var r=Math.max(1,Number(t)||1),n=1;n<=64;n++)if(e.levelCapacity(n)>=r)return n;throw new Error("[deriveBackingLevel] no leaf level up to 64 reaches the requested absorb capacity "+r+" on this universe's active axes.")}function Eb(e){if(Array.isArray(e))return e.length===6?[e[0]+e[3]/2,e[1]+e[4]/2]:[e[0]+e[2]/2,e[1]+e[3]/2];var t=e.left!==void 0?e.left:e._left,r=e.top!==void 0?e.top:e._top;return[t+e.w/2,r+e.h/2]}function ep(e){var t=Eb(e),r;if(Array.isArray(e))r=e.length===6?e[0]+e[3]:e[0]+e[2];else{var n=e.left!==void 0?e.left:e._left;r=n+e.w}return[r,t[1]]}function tl(e,t,r){e.set(t,(e.get(t)||0)+r)}function tp(e){var t=[];return e.forEach(function(r,n){t.push(n)}),t.sort(function(r,n){return r-n}),t}function wc(e,t,r,n){var i=np(e,n),a=e.levelCapacity(i),s=e.getLargeObjectFrameId(t),l=e.getFrameQuantumId(s);return e.setFrameProperty(l,"mass",1),{backingFrameHandle:s,backingQid:l,level:i,capacity:a}}function _c(e){var t=e.universe,r=e.loHandle,n=e.backingQid,i=e.capacity,a=e.rect,s=e.exit||ep(a),l=1,u=0,f=0,c=l,h=e.emissivity===void 0||e.emissivity===null?rp:$d(e.emissivity,"buildAbsorbRadiationTickFn"),g=new Map,p=new Map,m=new Map;function b(O){typeof e.loActiveSetter=="function"?e.loActiveSetter(O):t&&typeof t.setLargeObjectActive=="function"&&t.setLargeObjectActive(r,O)}o(b,"setActive");function y(){var O=tp(m).filter(function(R){return(m.get(R)||0)>0});if(O.length===0)return null;if(O.length===1)return O[0];var S=0,A;for(A=0;A<O.length;A++)S+=m.get(O[A]);var C=(typeof t.random=="function"?t.random():Math.random())*S;for(A=0;A<O.length;A++)if(C-=m.get(O[A]),C<0)return O[A];return O[O.length-1]}o(y,"pickEmissionLayer");var w=o(function(S){var A=S&&S.objects?S:t&&t._lastTickData?t._lastTickData:null,C=A&&A.objects&&A.objects[r],R=t.getFrameProperty(n,"mass"),Q=R;if(C&&Array.isArray(C.frames))for(var Y=0;Y<C.frames.length;Y++){var H=C.frames[Y];if(!(!H||H.isAlive!==!1||typeof H.mass!="number")){var q=i-R;if(q<=0)break;var T=Math.min(H.mass,q);T<=0||(R+=T,u+=T,tl(g,H.layer,T),tl(m,H.layer,T))}}if(R!==Q&&t.setFrameProperty(n,"mass",R),R>c&&(c=R),b(R<i),R-l>0){var J=typeof t.random=="function"?t.random():Math.random();if(J<1/i){var D=y();if(D!==null){var K=m.get(D),N=Math.min(Math.max(1,Math.round(h*t.levelCapacity(D))),K),B=l+(c-l)/2;if(R-N>=B){var ne=Math.pow(2,D)/2,oe=t.makeLeafFrame(s[0]+ne+1,s[1]-ne,D,null,1,0,!0,0,null);t.injectFrame(oe);var $=t.getFrameQuantumId(oe);t.setFrameProperty($,"mass",N),t.setFrameProperty(n,"mass",R-N),f+=N,tl(p,D,N),tl(m,D,-N)}}}}},"absorbRadiationTick");return w.stats=function(){var O=t.getFrameProperty(n,"mass")-l,S=new Map;g.forEach(function(C,R){S.set(R,!0)}),p.forEach(function(C,R){S.set(R,!0)});var A=tp(S).map(function(C){return{layer:C,absorbed:g.get(C)||0,radiated:p.get(C)||0,stored:m.get(C)||0}});return{stored:O,absorbedTotal:u,radiatedTotal:f,byLayer:A}},w.emissivity=function(){return h},w.setEmissivity=function(O){return h=$d(O,"setEmissivity"),h},w.setRect=function(O){e.exit||(s=ep(O))},w}var rp,ip=ce(()=>{rp=.5;o($d,"_validEmissivity");o(np,"deriveBackingLevel");o(Eb,"_rectCenter");o(ep,"_rectRightExit");o(tl,"_bump");o(tp,"_layersAscending");o(wc,"attachAbsorberBackingFrame");o(_c,"buildAbsorbRadiationTickFn")});var Li={};Oe(Li,{drawnCenter:()=>ji,drawnVolume:()=>Ac,firstHit:()=>Tc,hasZ:()=>vn,rayIntersect:()=>sp,rectAtCenter:()=>Sb,snapCenter:()=>Cc,snapRectPosition:()=>kb,volumeContains:()=>lp,zExtent:()=>Sc});function vn(e){return typeof e.z=="number"}function ji(e){var t=vn(e)?e.z+(typeof e.d=="number"?e.d:e.w)/2:0;return[e.left+e.w/2,e.top+e.h/2,t]}function Sb(e,t){var r=typeof t[2]=="number"?t[2]:0;if(vn(e)){var n=kc(e);return[t[0]-e.w/2,t[1]-e.h/2,r-n/2,e.w,e.h,n]}if(r!==0)throw new RangeError("[LoDrawnCenter.rectAtCenter] a z-less rect sits at z-centre 0 and cannot be placed at z = "+r+" \u2014 place it at cz 0, or give the rect an explicit z. (FAIL-LOUD.)");return[t[0]-e.w/2,t[1]-e.h/2,e.w,e.h]}function Sc(e){return kc(e)}function kc(e){return vn(e)?typeof e.d=="number"?e.d:e.w:0}function Ac(e){if(e&&e.rect){var t=e.rect;return{kind:"box",center:ji(t),half:[t.w/2,t.h/2,kc(t)/2],yawDeg:typeof e.orientationDeg=="number"?e.orientationDeg:0,pitchDeg:typeof e.pitchDeg=="number"?e.pitchDeg:0}}if(e&&Array.isArray(e.center)&&typeof e.radius=="number"){var r=e.center;return{kind:"sphere",center:[r[0],r[1],typeof r[2]=="number"?r[2]:0],radius:e.radius}}throw new TypeError("[LoDrawnCenter.drawnVolume] needs {rect} (an LO) or {center, radius} (a centre-only target); got "+JSON.stringify(e)+". (FAIL-LOUD.)")}function Oc(e,t){var r=e.yawDeg*ap,n=e.pitchDeg*ap,i=Math.cos(r),a=Math.sin(r),s=Math.cos(n),l=Math.sin(n);return[i*s*t[0]+a*s*t[1]-l*t[2],-a*t[0]+i*t[1],i*l*t[0]+a*l*t[1]+s*t[2]]}function Ec(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}function sp(e,t,r,n){var i=typeof n=="number"?n:0;if(r.kind==="sphere"){var a=r.radius+i,s=Ec(e,r.center),l=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],u=2*(s[0]*t[0]+s[1]*t[1]+s[2]*t[2]),f=s[0]*s[0]+s[1]*s[1]+s[2]*s[2]-a*a,c=u*u-4*l*f;if(!(l>0)||c<0)return null;var h=Math.sqrt(c),g=(-u-h)/(2*l),p=(-u+h)/(2*l);return p<0?null:g>0?g:0}if(r.kind==="box"){for(var m=Oc(r,Ec(e,r.center)),b=Oc(r,t),y=-1/0,w=1/0,O=0;O<3;O++){var S=r.half[O]+i;if(Math.abs(b[O])<1e-12){if(m[O]<-S||m[O]>S)return null;continue}var A=(-S-m[O])/b[O],C=(S-m[O])/b[O];if(A>C){var R=A;A=C,C=R}if(A>y&&(y=A),C<w&&(w=C),y>w)return null}return w<0?null:y>0?y:0}throw new TypeError("[LoDrawnCenter.rayIntersect] unknown volume kind "+String(r&&r.kind)+" \u2014 volumes come from drawnVolume(). (FAIL-LOUD.)")}function lp(e,t,r){var n=typeof r=="number"?r:0,i=Ec(t,e.center);if(e.kind==="sphere"){var a=e.radius+n;return i[0]*i[0]+i[1]*i[1]+i[2]*i[2]<=a*a+1e-9}for(var s=Oc(e,i),l=0;l<3;l++)if(Math.abs(s[l])>e.half[l]+n+1e-9)return!1;return!0}function op(e,t){if(e.kind==="sphere"){var r=e.radius+t;return r*r*r*4.18879}return 8*(e.half[0]+t)*(e.half[1]+t)*(e.half[2]+t)}function Tc(e,t,r,n){for(var i=typeof n=="number"?n:0,a=[],s=0;s<r.length;s++){var l=sp(e,t,r[s],i);l!==null&&a.push({index:s,t:l})}if(!a.length)return null;a.sort(function(m,b){return m.t-b.t});for(var u=a[0],f=1;f<a.length;f++){var c=a[f],h=r[u.index],g=r[c.index],p=[e[0]+t[0]*c.t,e[1]+t[1]*c.t,e[2]+t[2]*c.t];lp(h,p,i)&&op(g,i)<op(h,i)&&(u=c)}return u}function up(e,t,r){if(!Array.isArray(e)||r.indexOf(e.length)===-1||!e.every(function(n){return typeof n=="number"&&isFinite(n)}))throw new TypeError("[LoDrawnCenter."+t+"] "+r.join(" or ")+" finite numbers; got "+JSON.stringify(e)+". (FAIL-LOUD.)")}function kb(e){up(e,"snapRectPosition",[4,6]);var t=e.length===6?3:2;return e.map(function(r,n){return n<t?Math.round(r):r})}function Cc(e){return up(e,"snapCenter",[2,3]),e.map(function(t){return Math.round(t)})}var ap,So=ce(()=>{o(vn,"hasZ");o(ji,"drawnCenter");o(Sb,"rectAtCenter");ap=Math.PI/180;o(Sc,"zExtent");o(kc,"_zExtent");o(Ac,"drawnVolume");o(Oc,"_toLocal");o(Ec,"_sub");o(sp,"rayIntersect");o(lp,"volumeContains");o(op,"_size");o(Tc,"firstHit");o(up,"_finiteTuple");o(kb,"snapRectPosition");o(Cc,"snapCenter")});function rl(e){var t=Xt(e);return t?t.descriptor:Object.prototype.hasOwnProperty.call(en,e)?en[e]:null}function Rc(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Rc);if(ArrayBuffer.isView(e))return Array.from(e);var t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)return e;var r={};return Object.keys(e).forEach(function(n){r[n]=Rc(e[n])}),r}var ko,Ta,Ao,To,Ke,Un=ce(()=>{Ut();$r();el();Ln();Ci();Di();So();Zs();Et();o(rl,"_descriptor");if(Array.isArray(Fn)){for(ko=Kd,Ta=Fn,Ao=0;Ao<Ta.length;Ao++)if(ko.indexOf(Ta[Ao])===-1)throw new Error('[lib/frqtl/objects/schema] field type "'+Ta[Ao]+`" is declared in lib/shim/field-descriptor's FIELD_TYPES but has no row in valueNormalizer.js's VALUE_NORMALIZERS \u2014 every declared type must state how a written value is normalized/rejected. (FAIL-LOUD.)`);for(To=0;To<ko.length;To++)if(Ta.indexOf(ko[To])===-1)throw new Error('[lib/frqtl/objects/schema] valueNormalizer.js declares a row for "'+ko[To]+`", which is not a member of lib/shim/field-descriptor's FIELD_TYPES ([`+Ta.join(", ")+"]). The type vocabulary has ONE owner. (FAIL-LOUD.)")}o(Rc,"_plainCopy");Ke={get:o(function(e){return rl(e)},"get"),kinds:o(function(){var e=Aa();return e.concat(Object.keys(en).filter(function(t){return e.indexOf(t)===-1}))},"kinds"),ux:o(function(e){var t=rl(e),r=t?t.ux:void 0;return typeof Oa=="function"?Oa(r):{resizable:!0,draggable:{"2d":!0},handles:null,shellRender:"design"}},"ux"),placeableCatalog:o(function(){return Yd().map(function(e){return{kind:e.name,displayName:e.palette.displayName,description:e.descriptor.description,category:e.palette.category,iconHint:e.palette.iconHint,defaultProps:e.defaults}})},"placeableCatalog"),captureProps:o(function(e,t){var r=rl(t);if(!r||!Array.isArray(r.fields))throw new Error('[ObjectSchema] captureProps(obj, "'+t+'"): no descriptor for kind "'+t+`" in this realm \u2014 a capture reads the kind's declared fields, never the object's own keys. (FAIL-LOUD.)`);for(var n={},i=0;i<r.fields.length;i++){var a=r.fields[i];if(a.writeOnly!==!0){var s=e[a.name];if(s!==void 0){if(a.type==="rect"&&s&&typeof s=="object"&&!Array.isArray(s)){var l=vn(s)?6:4,u=Ea[l].map(function(f){return f==="d"?Sc(s):s[f]});if(u.every(function(f){return typeof f=="number"})){n[a.name]=u;continue}}n[a.name]=Rc(s)}}}return n},"captureProps"),derivedReads:o(function(e){var t=rl(e);if(!t||!Array.isArray(t.fields))throw new Error('[ObjectSchema] derivedReads("'+e+'"): no descriptor for kind "'+e+'". (FAIL-LOUD.)');return t.fields.filter(function(r){return!!r.derivedFrom}).map(function(r){return{name:r.name,field:r.derivedFrom.field,tuple:r.derivedFrom.tuple,key:r.derivedFrom.key}})},"derivedReads"),defaultPropsFor:o(function(e){var t=Xt(e);return t&&t.defaults?t.defaults:{}},"defaultPropsFor"),normalizeValue:Hd,worldRect:Gd,RECT_TUPLE:Ea,rectTupleText:Ot,FIELD_TYPES:Fn,CollisionTypes:Ee,CollisionActions:st,FrameDataSchema:ar,FieldDescriptorSchema:ti}});var Lc={};Oe(Lc,{Wall:()=>we});function jc(e,t,r){if(!Bs)return{region:null,broadRect:e};var n=Ca(e),i=Ii(e),a=wa({w:n.w,h:n.h,orientationDeg:t,d:i,pitchDeg:r});if(a.pitched){var s=a.plate3,l=Ca(e),u=e[0]+l.w/2,f=e[1]+l.h/2,c=e[2],h=e[5],g=c+h/2;return{region:null,broadRect:[u-s.aabb.hx,f-s.aabb.hy,g-s.aabb.hz,2*s.aabb.hx,2*s.aabb.hy,2*s.aabb.hz],trueW:l.w,trueH:l.h}}var p=Hu(a.obb);if(!p)return{region:null,broadRect:e};var m=Ku(a.obb),b=Array.isArray(e)&&e.length===6,y=e[0],w=e[1],O=y+n.w/2,S=w+n.h/2,A;if(b){var C=e[2],R=e[5];A=[O-m.hx,S-m.hy,C,2*m.hx,2*m.hy,R]}else A=[O-m.hx,S-m.hy,2*m.hx,2*m.hy];return{region:p,broadRect:A,trueW:n.w,trueH:n.h}}function Ab(e){if(e.rect&&!Array.isArray(e.rect)&&e.rect.left!==void 0&&e.rect.w!==void 0){var t=e.rect,r=t.z!==void 0||t.d!==void 0?[t.left,t.top,t.z!==void 0?t.z:0,t.w,t.h,t.d!==void 0?t.d:t.w]:[t.left,t.top,t.w,t.h];e=Object.assign({},e,{rect:r})}if(e.rect){if(Array.isArray(e.rect)&&e.rect.length===4&&(e.depth!==void 0||e.z!==void 0)){var n=e.rect;return[n[0],n[1],e.z!==void 0?e.z:0,n[2],n[3],e.depth!==void 0?e.depth:n[2]]}return e.rect}return e.z!==void 0||e.d!==void 0||e.depth!==void 0?[e.left,e.top,e.z!==void 0?e.z:0,e.w,e.h,e.depth!==void 0?e.depth:e.d!==void 0?e.d:e.w]:[e.left,e.top,e.w,e.h]}function Ca(e){return Array.isArray(e)&&e.length===6?{w:e[3],h:e[4]}:Array.isArray(e)?{w:e[2],h:e[3]}:{w:e.w,h:e.h}}function Tb(e){return Array.isArray(e)&&e.length===6&&typeof e[5]=="number"&&e[5]>0}function Ii(e){return Array.isArray(e)&&e.length===6?e[5]:0}function Cb(e,t,r){var n=r.collisionBehavior;e.collisionBehavior=n,e.bounceDirection=r.bounceDirection||(n==="bounce"?"reflect":void 0),e.angleConstraint=r.angleConstraint,e.decoherence=!!r.decoherence,e.hooks=Array.isArray(r.hooks)?r.hooks.slice():[],e.markTag=r.markTag,e.countFilter=r.countFilter,e.capacity=typeof r.capacity=="number"?r.capacity:64,e.emissivity=typeof r.emissivity=="number"?r.emissivity:void 0,e.orientationDeg=typeof r.orientationDeg=="number"?r.orientationDeg:0,e.pitchDeg=typeof r.pitchDeg=="number"?r.pitchDeg:0;var i=Ab(r),a=r.name||"wall";e.name=a;var s=Tb(i),l=r.reposition||(s?"closest3d":"closest"),u=r.layer,f=u!=null?[u]:null,c=Ca(i),h=Dc({collisionBehavior:n,bounceDirection:e.bounceDirection,angleConstraint:e.angleConstraint,decoherence:e.decoherence,hooks:e.hooks,markTag:e.markTag,capacity:e.capacity,emissivity:e.emissivity,color:r.color,orientationDeg:e.orientationDeg,reposition:l,is3D:s,slabW:c.w,slabH:c.h,pitchDeg:e.pitchDeg,slabD:Ii(i)}),g=r.collectCollided!==void 0?!!r.collectCollided:!!h.collectCollided;e._collectCollided=g,e._radiation=h.radiation,e._trueRect=i;var p=jc(i,e.orientationDeg,e.pitchDeg);e.lo=new Se(t,i,"NONE",[],a,l,f,1,r.color,g),e.lo._owner=e,e.lo.orientationDeg=e.orientationDeg,e.pitchDeg&&(e.lo.pitchDeg=e.pitchDeg),s&&(e.lo.depth=Ii(i)),e.is3D=s,h.program&&t&&typeof t.updateObjectProperty=="function"&&t.updateObjectProperty(e.lo.handle,"LargeObject","program",h.program),e.lo.program=h.program||null,e._program=e.lo.program;var m=p.region;if(t&&typeof t.updateObjectProperty=="function"&&(t.updateObjectProperty(e.lo.handle,"LargeObject","region",m),p.broadRect!==i&&t.updateObjectProperty(e.lo.handle,"LargeObject","rect",p.broadRect)),e.lo.region=m,r.alpha!==void 0&&(e.lo.alpha=r.alpha),r.visible!==void 0&&(e.lo.visible=r.visible),r.shellShape!==void 0&&(e.lo.shellShape=r.shellShape),e._radiationTickFn=null,e._backing=null,n==="absorb"&&xc){var b=wc(t,e.lo.handle,i,e.capacity);e._backing=b;var y=_c({universe:t,loHandle:e.lo.handle,backingQid:b.backingQid,capacity:b.capacity,rect:i,emissivity:h.radiation&&h.radiation.emissivity});e._radiationTickFn=y,e.emissivity=y.emissivity(),t&&Array.isArray(t.experimentTickFunctions)&&t.experimentTickFunctions.push(y)}e._combined=new Map,e._grid=new Map,e._total=0,e._lastTickData=void 0}function we(e,t){if(t=t||{},this.universe=e,this._schemaKind="Wall",t.preset){var r=cp(t.preset),n={};Object.keys(t).forEach(function(i){i!=="preset"&&(n[i]=t[i])}),Object.keys(r).forEach(function(i){n[i]===void 0&&(n[i]=r[i])}),t=n}if(t.wallBehavior!==void 0)throw new Error("[Wall] `wallBehavior` is deleted \u2014 use `collisionBehavior`: block \u2192 collisionBehavior:'block'; reflect \u2192 collisionBehavior:'bounce', bounceDirection:'reflect'; absorb (plain kill) \u2192 collisionBehavior:'destroy'; detect \u2192 collisionBehavior:'destroy', hooks:['count'] (= preset 'detector-screen'). Note collisionBehavior:'absorb' is the RADIATING absorber, NOT the old plain kill.");if(t.collisionType!==void 0)throw new Error("[Wall] the `collisionType` override is deleted \u2014 a wall's collision mechanics ARE its compiled op-program (collisionBehavior + bounceDirection + hooks).");if(t.collisionBehavior===void 0)throw new Error("[Wall] `collisionBehavior` is REQUIRED \u2014 one of nothing|block|bounce|absorb|destroy (or pass a `preset`).");return Cb(this,e,t)}var Dc,cp,Rb,yn=ce(()=>{Rt();wr();el();Ut();ip();Yu();Et();Di();Un();el();Dc=Xd;cp=Zd;o(jc,"_slabGeometryForWall");o(Ab,"_rectFromOpts");o(Ca,"_rectWH");o(Tb,"_rectIs3D");o(Ii,"_rectDepth");o(Cb,"_constructV2");o(we,"Wall");Object.defineProperty(we.prototype,"rect",{get:o(function(){return this.lo?this.lo.rect:void 0},"get")});Object.defineProperty(we.prototype,"handle",{get:o(function(){return this.lo?this.lo.handle:void 0},"get")});Object.defineProperty(we.prototype,"color",{get:o(function(){return this.lo?this.lo.color:void 0},"get")});Object.defineProperty(we.prototype,"alpha",{get:o(function(){return this.lo?this.lo.alpha:void 0},"get")});Object.defineProperty(we.prototype,"visible",{get:o(function(){return this.lo?this.lo.visible:void 0},"get")});Object.defineProperty(we.prototype,"layer",{get:o(function(){return this.lo?this.lo.layer:void 0},"get")});Object.defineProperty(we.prototype,"reposition",{get:o(function(){return this.lo?this.lo.reposition:void 0},"get")});Object.defineProperty(we.prototype,"shellShape",{get:o(function(){return this.lo?this.lo.shellShape:void 0},"get")});Object.defineProperty(we.prototype,"depth",{get:o(function(){return this.lo&&this.lo.rect&&typeof this.lo.rect.d=="number"?this.lo.rect.d:0},"get")});Object.defineProperty(we.prototype,"z",{get:o(function(){return this.lo&&this.lo.rect&&typeof this.lo.rect.z=="number"?this.lo.rect.z:0},"get")});we.prototype.getOrientation=function(){return typeof this.orientationDeg=="number"?this.orientationDeg:0};we.prototype.setOrientation=function(e){if(this.collisionBehavior===void 0)throw new Error("[Wall.setOrientation] this wall has no collisionBehavior, so it has no compiled op-program to re-aim \u2014 a Wall is built only through the v2 lexicon (new Wall(universe, { collisionBehavior | preset })); an object without one was not built by Wall. (FAIL-LOUD.)");var t=(e%360+360)%360;return this.setV2Prop("orientationDeg",t),this};we.prototype.setRect=function(e){if(!Array.isArray(e)||e.length!==4&&e.length!==6||!e.every(function(f){return typeof f=="number"&&isFinite(f)}))throw new TypeError("[Wall.setRect] rect must be [l,t,w,h] or [l,t,z,w,h,d] of finite numbers; got "+JSON.stringify(e)+". (FAIL-LOUD.)");var t=this._trueRect,r=Array.isArray(t)&&t.length===6,n;if(e.length===6){if(!r)throw new Error('[Wall.setRect] "'+this.name+`" was built without a z-slab; a 6-element rect would give it one, but a wall's 3D-ness is compiled into its op-program at construction. Remove + re-add it with z/depth. (FAIL-LOUD.)`);n=e.slice()}else n=r?[e[0],e[1],t[2],e[2],e[3],t[5]]:e.slice();var i=Ca(t),a=Ca(n),s=i.w!==a.w||i.h!==a.h||Ii(t)!==Ii(n);s&&this.assertOwnsProgram(),this._trueRect=n;var l=this.lo.rect;if(l.w=a.w,l.h=a.h,r&&(l.z=n[2],l.d=n[5]),l.left=n[0],l.top=n[1],this.is3D&&(this.lo.depth=Ii(n)),s)this._rebake();else if(this.universe&&typeof this.universe.updateObjectProperty=="function"){var u=jc(n,this.orientationDeg,this.pitchDeg);this.universe.updateObjectProperty(this.lo.handle,"LargeObject","rect",u.broadRect)}return this._radiationTickFn&&this._radiationTickFn.setRect(n),this};we.prototype.setPitch=function(e){return this.setV2Prop("pitchDeg",e),this};we.prototype.setV2Prop=function(e,t){if(e==="emissivity"){if(this.collisionBehavior!=="absorb"||!this._radiationTickFn)throw new Error('[Wall.setV2Prop] emissivity is a RADIATOR knob and this wall is not an ABSORB wall (collisionBehavior "'+this.collisionBehavior+'").');return this.emissivity=this._radiationTickFn.setEmissivity(t),this}return this._rebake(e,t)};we.prototype._rebake=function(e,t){this.assertOwnsProgram();var r=e==="collisionBehavior"?t:this.collisionBehavior,n=this.collisionBehavior==="absorb",i=r==="absorb";if(n!==i)throw new Error("[Wall.setV2Prop] cannot live-switch "+(i?"INTO":"out of")+" the radiating ABSORB behavior \u2014 its backing frame + radiation tick-fn are attached at construction. Remove + re-add the wall as absorb.");var a=e==="hooks"?Array.isArray(t)?t.slice():[]:this.hooks,s=Ca(this._trueRect),l=Dc({collisionBehavior:r,bounceDirection:e==="bounceDirection"?t:this.bounceDirection,angleConstraint:this.angleConstraint,decoherence:e==="decoherence"?!!t:this.decoherence,hooks:a,markTag:e==="markTag"?t:this.markTag,capacity:e==="capacity"?t:this.capacity,orientationDeg:e==="orientationDeg"?t:this.orientationDeg,pitchDeg:e==="pitchDeg"?t:this.pitchDeg,slabD:Ii(this._trueRect),reposition:this.lo.reposition,is3D:this.is3D===!0,slabW:s.w,slabH:s.h});if(l.collectCollided&&!this._collectCollided)throw new Error("[Wall.setV2Prop] cannot live-enable collection (mark/count) on a wall not registered to collect_collided \u2014 construct it with the hook, or remove + re-add it.");e==="hooks"?this.hooks=a:e==="decoherence"?this.decoherence=!!t:e!==void 0&&(this[e]=t),e==="orientationDeg"&&this.lo&&(this.lo.orientationDeg=t),e==="pitchDeg"&&this.lo&&(this.lo.pitchDeg=t),this.universe&&typeof this.universe.updateObjectProperty=="function"&&this.universe.updateObjectProperty(this.lo.handle,"LargeObject","program",l.program||null),this.lo.program=l.program||null;var u=jc(this._trueRect,this.orientationDeg,this.pitchDeg);return this.universe&&typeof this.universe.updateObjectProperty=="function"&&(this.universe.updateObjectProperty(this.lo.handle,"LargeObject","region",u.region),this.universe.updateObjectProperty(this.lo.handle,"LargeObject","rect",u.broadRect)),this.lo.region=u.region,this._program=this.lo.program,this};we.prototype.assertOwnsProgram=function(){if(this.lo&&this.lo.program!==this._program)throw new Error('[Wall] "'+this.name+'": its LargeObject carries an op-program another part pushed ('+(this._owner?"owned by "+(this._owner.name||"its composite"):"not baked by this wall")+"). Re-baking it here would silently replace that part's physics \u2014 the owning part must re-apply it. (FAIL-LOUD.)")};we.prototype.getCollisionHistogram=function(e){var t=Array.isArray(this.hooks)&&this.hooks.indexOf("count")!==-1;if(!t)throw new Error('[Wall.getCollisionHistogram] this wall does not COUNT (collisionBehavior "'+this.collisionBehavior+'", hooks '+JSON.stringify(this.hooks||[])+") \u2014 only a wall carrying the `count` hook collects collided frames (preset 'detector-screen' for a counting screen, 'transparent-probe' for a pass-through population probe).");if(e!=null&&e===this._lastTickData)throw new Error("[Wall.getCollisionHistogram] called twice with the SAME TickData object \u2014 each tick must be consumed exactly once. Call universe.doTick() again first.");this._lastTickData=e;for(var r=this.lo.handle,n=e&&e.objects&&e.objects[r]&&Array.isArray(e.objects[r].frames)?e.objects[r].frames:[],i=0;i<n.length;i++){var a=n[i],s;a.rect&&a.rect.top!=null?s=Math.floor(a.rect.top):a.y!=null?s=Math.floor(a.y):s=0;var l=a.z!=null?Math.floor(a.z):0;this._combined.set(s,(this._combined.get(s)||0)+1),we.gridAdd(this._grid,s,l),this._total++}return{combined:this._combined,grid:this._grid,total:this._total}};we.gridAdd=function(e,t,r){var n=e.get(t);n||(n=new Map,e.set(t,n)),n.set(r,(n.get(r)||0)+1)};we.deriveMarginalY=function(e){var t=new Map;return e.forEach(function(r,n){var i=0;r.forEach(function(a){i+=a}),t.set(n,i)}),t};we.prototype.getLiveCount=function(e){var t=Array.isArray(this.hooks)&&this.hooks.indexOf("count")!==-1;if(!t)throw new Error('[Wall.getLiveCount] this wall does not COUNT (collisionBehavior "'+this.collisionBehavior+'", hooks '+JSON.stringify(this.hooks||[])+") \u2014 only a wall carrying the `count` hook collects collided frames (preset 'detector-screen' for a counting screen, 'transparent-probe' for a pass-through population probe).");if(e!=null){var r=this.lo.handle,n=e.objects&&e.objects[r];this._liveCount=n&&Array.isArray(n.frames)?n.frames.length:0}return this._liveCount||0};we.prototype.getAbsorbStats=function(){if(this.collisionBehavior!=="absorb"||!this._radiationTickFn)throw new Error('[Wall.getAbsorbStats] this wall is not an ABSORB wall (collisionBehavior "'+this.collisionBehavior+'").');return this._radiationTickFn.stats()};we.prototype.dispose=function(){if(!this._disposed){this._disposed=!0;var e=this.universe;if(this._radiationTickFn&&e&&Array.isArray(e.experimentTickFunctions)){var t=e.experimentTickFunctions.indexOf(this._radiationTickFn);t!==-1&&e.experimentTickFunctions.splice(t,1)}this.lo&&typeof this.lo.dispose=="function"&&this.lo.dispose()}};we.prototype.resetHistogram=function(){this._combined=new Map,this._grid=new Map,this._total=0};Rb={description:"A rectangular wall/boundary with a single collision behavior: nothing (pass through), block (stop at the surface), bounce (turn around), absorb (kill + tally + radiate), or destroy (plain kill) \u2014 plus the composable mark/count/recolor hooks. The first-class palette face over a LargeObject + actionCompiler op-program \u2014 the ONE wall primitive the composites (SlitScreen, DetectorWall) build on. Zero physics of its own.",ux:{resizable:!0,draggable:{"2d":!0},shellRender:"run"},fields:[{name:"rect",type:"rect",engineVisible:!0,unit:"px",live:!0,description:"Bounding rectangle in physics pixels "+Ot(4)+", or the explicit z/depth form "+Ot(6)+" \u2014 WASM 3D. The wall's collision search region. Live-editable (drag/resize); routed to the inner LargeObject engine handle."},{name:"orientationDeg",type:"number",constraint:{min:0,max:360},engineVisible:!1,live:!0,widgetHint:"slider",description:"Wall orientation in degrees (default 0; visible always) = the mirror SURFACE angle. A live edit recompiles the op-program: a bounce/reflect mirror bakes the ORIENTATION-AWARE reflection law (standard optics \u2014 a surface at \u03B8 deflects a beam by 2\u03B8, so 45\xB0 turns a +x beam to +y), and a constrained-random wall re-aims its scatter cone. The renderer draws the shell rotated to this angle. Also the LOOK-drive rotation target."},{name:"pitchDeg",type:"number",constraint:{min:-90,max:90},engineVisible:!1,live:!0,widgetHint:"slider",visibleWhen:{field:"depth",truthy:!0},description:"Up/down tilt (degrees, -90..90) about the plate's own long axis \u2014 the second mirror rotation axis (3D walls only). A live edit recompiles the true 3-space reflection about the tipped plate normal: the reflected beam gains a z-component and always leaves on the incident side (never through the mirror). 0 = the flat in-plane mirror (vz passes through)."},{name:"depth",type:"readonly",derivedFrom:{field:"rect",tuple:6,key:"d"},unit:"px",engineVisible:!1,description:"The wall's z-slab depth (z-extent) in physics pixels \u2014 0 for a flat 2D wall. Derived from the 6-element rect "+Ot(6)+"; a real depth makes the wall a 3D slab (six-face reflect/eject, box render). Edit via the rect field."},{name:"z",type:"readonly",derivedFrom:{field:"rect",tuple:6,key:"z"},unit:"px",engineVisible:!1,description:"The wall's z placement (near-face \u2026 far-face CENTER) in physics pixels (0 for a 2D wall). Derived from the 6-element rect. Edit via the rect field."},{name:"collisionBehavior",type:"enum",constraint:{values:vc?vc():{}},engineVisible:!1,live:!0,description:"The wall's collision BEHAVIOR (compiled to an op-program; the engine has no wall dispatch): nothing = pass-through; block = STOP the particle at the surface (reposition to the closest position outside the wall, velocity kept \u2014 it parks at the face instead of turning around); bounce = a motion response (see bounceDirection); absorb = tally the colliders' mass into the wall's REAL backing frame + radiate (conserving); destroy = remove the particle. Hooks (mark/count) compose with any behavior."},{name:"bounceDirection",type:"enum",constraint:{values:yc?yc():{}},engineVisible:!1,live:!0,visibleWhen:{field:"collisionBehavior",equals:"bounce"},description:"How a BOUNCE redirects the particle: reflect = invert the velocity on the axis of incidence (a mirror); random = redraw the exit direction (omni by default, or constrained to a cone about the wall's INITIAL orientation). Only shown for bounce."},{name:"decoherence",type:"boolean",engineVisible:!1,live:!0,visibleWhen:[{field:"collisionBehavior",equals:"bounce"},{field:"bounceDirection",equals:"random"}],description:"When a random BOUNCE also resets the wave phase (local_time=0) + re-rolls the charge sign (an independent decoherence toggle). Off by default (direction-only). Only shown for a random bounce."},{name:"hooks",type:"enum-set",constraint:{values:bc?bc():{}},engineVisible:!1,live:!0,description:"Composable statistics hooks (any behavior): mark = stamp a user string on each collided frame (engine-transparent); count = tally collisions (filterable by mark). The counting screen is destroy + count."},{name:"markTag",type:"string",engineVisible:!1,visibleWhen:{field:"hooks",includes:"mark"},description:"The user string MARK stamps into each collided frame's string_map (only shown when the mark hook is active)."},{name:"countFilter",type:"string",engineVisible:!1,visibleWhen:{field:"hooks",includes:"count"},description:'Restrict COUNT to frames carrying a specific mark ("any" = count all). Applied by the between-tick stats reader (only shown when the count hook is active).'},{name:"capacity",type:"number",constraint:{min:1,integer:!0},engineVisible:!1,live:!0,visibleWhen:{field:"collisionBehavior",equals:"absorb"},description:"ABSORB mass ceiling (snapped to a leaf level the engine can actually size \u2014 the capacity law runs over the ACTIVE AXES) AND the 1/capacity per-tick radiation probability. How much it holds and how often it gives some back. Only shown for absorb."},{name:"emissivity",type:"number",constraint:{min:.01,max:1},engineVisible:!1,live:!0,visibleWhen:{field:"collisionBehavior",equals:"absorb"},description:"ABSORB radiating efficiency \u2014 the FULLNESS of each re-emitted leaf, as a fraction in (0,1] of that layer's cell capacity (default 0.5). A colour knob, not bookkeeping: fullness IS the move gate and sets the wavelength, so 1.0 re-emits at light speed with the shortest \u03BB and 0.5 at half the step rate with twice the \u03BB. The emitted leaf's SCALE is not a knob \u2014 the wall re-emits at the layer it soaked from. Only shown for absorb."},{name:"name",type:"string",engineVisible:!1,description:"Human-readable identifier (display/debug only)."},{name:"color",type:"rgb",engineVisible:!1,live:!0,description:"Render color [r, g, b] 0-255 (render-only; engine collision unaffected)."},{name:"alpha",type:"number",constraint:{min:0,max:255,integer:!0},engineVisible:!1,live:!0,widgetHint:"slider",description:"Render opacity 0-255 (render-only). 0 = fully transparent, 255 = fully opaque \u2014 a transparent wall still collides, it simply stops obstructing the view."},{name:"visible",type:"boolean",engineVisible:!1,live:!0,description:"Whether the wall is drawn (render-only; collision detection stays active)."},{name:"layer",type:"number",constraint:{min:0,integer:!0},engineVisible:!0,description:"Dimension layer this wall is scoped to (0 = fundamental; null = all layers)."},{name:"shellShape",type:"enum",constraint:{values:Xs()},engineVisible:!1,live:!0,description:"Render shape hint of the wall's visual shell (ball|box|circle|cube|sphere; render-only). cube/sphere degrade to box/ball in 2D; absent falls back to a rect."}]};at(we,{from:new URL("frqtl/parts/Wall.js",He()).href,descriptor:Rb,defaults:{preset:"wall",w:12,h:120,color:[150,150,160]},palette:{displayName:"Wall",category:"boundary",iconHint:"wall",rank:1},build:o(function(e,t,r){var n=r,i={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(i[a]=e[a]);if(i.rect==null&&i.left==null){var s=i.w!=null?i.w:12,l=i.h!=null?i.h:120;i.left=Math.round(t.x-s/2),i.top=Math.round(t.y-l/2),i.w=s,i.h=l}var u=t.runner&&t.runner.universe;if(t.fromPalette&&u&&u.activeAxes&&u.activeAxes.z&&i.z===void 0&&i.d===void 0&&i.depth===void 0&&!(i.rect&&(Array.isArray(i.rect)?i.rect.length===6:i.rect.z!==void 0||i.rect.d!==void 0))){var f=t.runner&&t.runner.worldBounds;if(!f||typeof f.near!="number"||typeof f.d!="number")throw new Error('[ObjectFactory] create("Wall"): a 3D palette drop derives its z-slab from the scene bounds (runner.worldBounds \u2014 the TickData boundary_rect ferry / init-time initBounds read-back), but the runner publishes none. (FAIL-LOUD \u2014 a depth-less wall in a 3D scene is the z-leak this default repairs.)');i.z=f.near,i.depth=f.d}t.fromPalette&&i.name==null&&(i.name="wall "+(t.runner.largeObjects.length+1));var c=new n(t.runner.universe,i);return c._schemaKind=r.name,c},"build")})});var Pc={};Oe(Pc,{DetectorWall:()=>bn});function bn(e,t,r,n,i,a,s,l,u,f){f=f||{};var c=f.depth!==void 0&&f.depth!==null?f.depth:null;this.universe=e,this._schemaKind="DetectorWall";var h=Ke.worldRect(t,"DetectorWall canvasRect"),g=h.w,p=h.h;if(r=r??g-20,n=n??0,i!=null&&i!==Ee.NONE)throw new Error('[DetectorWall] the wallCollisionType override is retired ("'+i+`") \u2014 the counting atom is Wall{collisionBehavior:'destroy', hooks:['count']} and its mechanics are the compiled op-program. Pass NONE (or omit the argument).`);a=a||[120,120,120],s=s??p,l=l??20,u=u||"detector_wall"+Math.floor(Math.random()*1e6),this.wallX=r,this._wallHeight=s,this.depth=c;var m=c!==null?[r,n,-c/2,l,s,c]:[r,n,l,s];this.name=u,this._innerWall=new we(e,{rect:m,collisionBehavior:"destroy",hooks:["count"],name:u,color:a}),this.detector_wall=this._innerWall.lo,this._innerWall._owner=this,this.detector_wall.rect.d!==void 0&&(this.detector_wall.shape="box",this.detector_wall.depth=this.detector_wall.rect.d),this._combined=new Map,this._slit1=new Map,this._slit2=new Map,this._total=0,this._slit1Total=0,this._slit2Total=0,this._grid=new Map,this._gridSlit1=new Map,this._gridSlit2=new Map,this._lastTickData=void 0}function Ic(e,t,r){we.gridAdd(e,t,r)}var Db,Fc=ce(()=>{Rt();wr();Ut();$r();yn();Xu();Un();Et();o(bn,"DetectorWall");o(Ic,"_gridAdd");bn.deriveMarginalY=function(e){return we.deriveMarginalY(e)};Object.defineProperty(bn.prototype,"x",{get:o(function(){return this.wallX},"get"),set:o(function(e){this.wallX=e},"set")});bn.prototype.getCollisionHistogram=function(e){if(e!=null&&e===this._lastTickData)throw new Error("[DetectorWall] getCollisionHistogram() called twice with the SAME TickData object \u2014 each tick must be consumed exactly once, or its collisions are counted twice. Call universe.doTick() again before re-consuming.");this._lastTickData=e;for(var t=this.detector_wall.handle,r=e&&e.objects&&e.objects[t]&&Array.isArray(e.objects[t].frames)?e.objects[t].frames:[],n=0;n<r.length;n++){var i=r[n],a;i.rect&&i.rect.top!=null?a=Math.floor(i.rect.top):i.y!=null?a=Math.floor(i.y):a=0;var s=i.z!=null?Math.floor(i.z):0,l=Td(i)||null;this._combined.set(a,(this._combined.get(a)||0)+1),this._total++,l==="slit2"?(this._slit2.set(a,(this._slit2.get(a)||0)+1),this._slit2Total++):l==="slit1"&&(this._slit1.set(a,(this._slit1.get(a)||0)+1),this._slit1Total++),Ic(this._grid,a,s),l==="slit2"?Ic(this._gridSlit2,a,s):l==="slit1"&&Ic(this._gridSlit1,a,s)}return{combined:this._combined,slit1:this._slit1,slit2:this._slit2,total:this._total,slit1Total:this._slit1Total,slit2Total:this._slit2Total,grid:this._grid,gridSlit1:this._gridSlit1,gridSlit2:this._gridSlit2}};bn.prototype.dispose=function(){this._innerWall.dispose()};bn.prototype.resetHistogram=function(){this._combined=new Map,this._slit1=new Map,this._slit2=new Map,this._total=0,this._slit1Total=0,this._slit2Total=0,this._grid=new Map,this._gridSlit1=new Map,this._gridSlit2=new Map};Db={description:"A detector/absorber screen that counts and removes particles on contact. Used as the observation screen in quantum experiments (e.g. double-slit). Wraps a single LargeObject with COUNT+ABSORB actions. Accumulates a collision histogram (y-position \u2192 count) for interference pattern analysis.",fields:[{name:"wallX",type:"number",constraint:{integer:!0},engineVisible:!0,description:"Left edge X position (physics pixels)"},{name:"wallY",type:"number",constraint:{integer:!0},engineVisible:!0,description:"Top edge Y position (physics pixels)"},{name:"wallCollisionType",type:"enum",constraint:{values:Ee},engineVisible:!0,description:"Collision type for the detector wall. Default NONE \u2014 absorption is via the ABSORB action in its actions list, not the collision type."},{name:"wallColor",type:"rgb",engineVisible:!1,description:"Render color [r, g, b] of the detector wall"},{name:"wallHeight",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Height of the detector wall (physics pixels). Typically the full canvas height."},{name:"wallWidth",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Width/thickness of the detector wall (physics pixels). Default 20."},{name:"wallName",type:"string",engineVisible:!1,description:"Identifier string for this detector (display/debug only; not engine-visible after construction)."}]};at(bn,{from:new URL("frqtl/parts/DetectorWall.js",He()).href,descriptor:Db,defaults:{wallX:180,wallY:0,wallCollisionType:"NONE",wallColor:[120,120,120],wallHeight:200,wallWidth:20},build:o(function(e,t,r){var n=r,i=Ke.worldRect(t.runner.canvas_rect,'ObjectFactory create("DetectorWall") runner.canvas_rect'),a=i.w,s=i.h,l=new n(t.runner.universe,{w:a,h:s},e.wallX!=null?e.wallX:Math.round(t.x),e.wallY!=null?e.wallY:0,e.wallCollisionType||"NONE",e.wallColor||[120,200,120],e.wallHeight||s,e.wallWidth||20,e.wallName||"detector "+Date.now());if(!l.detector_wall)throw new Error('[ObjectFactory] create("DetectorWall"): the DetectorWall was constructed but exposes no `detector_wall` (the registered inner LargeObject this kind hands back) \u2014 nothing placeable was built. (FAIL-LOUD.)');return l._schemaKind=r.name,l},"build")})});var nl={};Oe(nl,{installRpcResponder:()=>Lb,makeChannelRpc:()=>jb,makeInAppRpc:()=>Nc,makeWindowPostMessageChannel:()=>Ib});function Nc(e){if(typeof e!="function")throw new Error("[shim/rpc] makeInAppRpc requires a dispatch function. (FAIL-LOUD.)");return{call:o(function(t,r){try{return Promise.resolve(e(t,r))}catch(n){return Promise.reject(n)}},"call"),dispose:o(function(){},"dispose")}}function jb(e,t){if(t=t||{},!e||typeof e.post!="function"||typeof e.subscribe!="function")throw new Error("[shim/rpc] makeChannelRpc requires a channel with post/subscribe. (FAIL-LOUD.)");var r=t.tag;if(!r)throw new Error("[shim/rpc] makeChannelRpc requires opts.tag (a unique namespace so multiple RPC users sharing one postMessage bus never collide). (FAIL-LOUD.)");var n=typeof t.callTimeoutMs=="number"&&t.callTimeoutMs>0?t.callTimeoutMs:3e3,i=Object.create(null),a=0,s=e.subscribe(function(l){if(!(!l||l.__rpcTag!==r||l.type!=="rpc:result")){var u=i[l.reqId];u&&(delete i[l.reqId],l.error?u.reject(new Error("[shim/rpc] remote: "+l.error)):u.resolve(l.value))}});return{call:o(function(l,u){return new Promise(function(f,c){var h=++a,g=setTimeout(function(){i[h]&&(delete i[h],c(new Error('[shim/rpc] "'+l+'" timed out after '+n+'ms (tag "'+r+'"). No responder installed on the other side? (installRpcResponder)')))},n);i[h]={resolve:o(function(p){clearTimeout(g),f(p)},"resolve"),reject:o(function(p){clearTimeout(g),c(p)},"reject")},e.post({__rpcTag:r,type:"rpc:call",reqId:h,fn:l,args:u})})},"call"),dispose:o(function(){typeof s=="function"&&s()},"dispose")}}function Lb(e,t,r){if(r=r||{},!e||typeof e.post!="function"||typeof e.subscribe!="function")throw new Error("[shim/rpc] installRpcResponder requires a channel with post/subscribe. (FAIL-LOUD.)");if(typeof t!="function")throw new Error("[shim/rpc] installRpcResponder requires a dispatch function. (FAIL-LOUD.)");var n=r.tag;if(!n)throw new Error("[shim/rpc] installRpcResponder requires opts.tag. (FAIL-LOUD.)");return e.subscribe(function(i){if(!(!i||i.__rpcTag!==n||i.type!=="rpc:call")){var a=i.reqId;Promise.resolve().then(function(){return t(i.fn,i.args)}).then(function(s){e.post({__rpcTag:n,type:"rpc:result",reqId:a,value:s})},function(s){e.post({__rpcTag:n,type:"rpc:result",reqId:a,error:s&&s.message?s.message:String(s)})})}})}function Ib(e,t){t=t||{};var r=t.selfWindow||(typeof window<"u"?window:null);if(!e)throw new Error("[shim/rpc] makeWindowPostMessageChannel requires targetWindow. (FAIL-LOUD.)");if(!r)throw new Error("[shim/rpc] makeWindowPostMessageChannel requires a self window (pass opts.selfWindow outside a browser). (FAIL-LOUD.)");return{post:o(function(n){e.postMessage(n,"*")},"post"),subscribe:o(function(n){var i=o(function(a){a.source===e&&n(a.data)},"listener");return r.addEventListener("message",i),function(){r.removeEventListener("message",i)}},"subscribe")}}var fp=ce(()=>{o(Nc,"makeInAppRpc");o(jb,"makeChannelRpc");o(Lb,"installRpcResponder");o(Ib,"makeWindowPostMessageChannel")});function tn(e){return typeof e=="function"}function ri(e){return typeof e=="number"&&isFinite(e)}function _r(e){return typeof e=="string"&&e.length>0}function Pi(e){return Array.isArray(e)}function Hb(e){return typeof e=="boolean"}function Re(e,t,r){throw new Error('[lib/shim/controls] normalizeControlDescriptor(id="'+String(e)+'", kind="'+String(t)+'"): '+r+" (FAIL-LOUD \u2014 throw-or-apply, never silently dropped/defaulted-around).")}function Kb(e,t,r){(!r||typeof r!="object")&&Re(e,t,'"bind" must be an object {'+Uc.join(", ")+"} when present.");for(var n=0;n<Uc.length;n++){var i=Uc[n];_r(r[i])||Re(e,t,'"bind.'+i+'" must be a non-empty string.')}}function Co(e,t,r){var n=r.onChange!==void 0,i=r.bind!==void 0;!n&&!i&&Re(e,t,'"onChange" or "bind" is required \u2014 at least ONE write path must be declared (a control with neither is a dead control). Supply onChange (a function) and/or bind ({object,prop}).'),n&&!tn(r.onChange)&&Re(e,t,'"onChange", when present, must be a function(value)->void.'),i&&Kb(e,t,r.bind)}function Yb(e,t){_r(t.label)||Re(e,"scalar",'"label" must be a non-empty string.'),ri(t.min)||Re(e,"scalar",'"min" must be a finite number.'),ri(t.max)||Re(e,"scalar",'"max" must be a finite number.'),ri(t.step)||Re(e,"scalar",'"step" must be a finite number.'),(typeof t.value!="number"||!isFinite(t.value))&&Re(e,"scalar",'"value" must be a finite number.'),tn(t.fmt)||Re(e,"scalar",'"fmt" must be a function(value)->string.'),Co(e,"scalar",t)}function Jb(e,t){_r(t.label)||Re(e,"enum",'"label" must be a non-empty string.'),(!Pi(t.values)||t.values.length===0||!t.values.every(_r))&&Re(e,"enum",'"values" must be a non-empty array of non-empty strings.'),_r(t.value)||Re(e,"enum",'"value" must be a non-empty string.'),t.values.indexOf(t.value)===-1&&Re(e,"enum",'"value" ("'+t.value+'") must be a member of "values" (['+t.values.join(", ")+"]) \u2014 enum is select-ONE from a closed candidate set."),tn(t.fmt)||Re(e,"enum",'"fmt" must be a function(value)->string.'),Co(e,"enum",t)}function Qb(e,t){_r(t.label)||Re(e,"flags",'"label" must be a non-empty string.'),(!Pi(t.values)||t.values.length===0||!t.values.every(_r))&&Re(e,"flags",'"values" must be a non-empty array of non-empty strings.'),(!Pi(t.value)||!t.value.every(_r))&&Re(e,"flags",'"value" must be an array of non-empty strings (may be empty \u2014 zero flags set).');for(var r=0;r<t.value.length;r++)t.values.indexOf(t.value[r])===-1&&Re(e,"flags",'"value['+r+']" ("'+t.value[r]+'") must be a member of "values" (['+t.values.join(", ")+"]) \u2014 flags is a SUBSET of the closed candidate set.");tn(t.fmt)||Re(e,"flags",'"fmt" must be a function(value)->string.'),Co(e,"flags",t)}function zc(e,t,r,n){ri(r)||Pi(r)&&r.length===n&&r.every(ri)||Re(e,"vector",'"'+t+'" must be a finite number (shared across every component) or an array of '+n+' finite number(s) (one per component of "value") \u2014 got '+JSON.stringify(r)+".")}function Xb(e,t){_r(t.label)||Re(e,"vector",'"label" must be a non-empty string.'),(!Pi(t.value)||t.value.length===0||!t.value.every(ri))&&Re(e,"vector",'"value" must be a non-empty array of finite numbers.'),zc(e,"min",t.min,t.value.length),zc(e,"max",t.max,t.value.length),zc(e,"step",t.step,t.value.length),tn(t.fmt)||Re(e,"vector",'"fmt" must be a function(value)->string.'),Co(e,"vector",t)}function Zb(e,t){_r(t.label)||Re(e,"text",'"label" must be a non-empty string.'),typeof t.value!="string"&&Re(e,"text",`"value" must be a string (a text control's value; may be empty).`),tn(t.fmt)||Re(e,"text",'"fmt" must be a function(value)->string.'),Co(e,"text",t)}function $b(e,t){_r(t.label)||Re(e,"action",'"label" must be a non-empty string.'),(!_r(t.action)||il.indexOf(t.action)===-1)&&Re(e,"action",'"action" must be one of ['+il.join(", ")+"]; got "+JSON.stringify(t.action)+"."),t.bind!==void 0&&Re(e,"action",'an action descriptor must NOT declare "bind" \u2014 an action is a VERB, not a property read/write pair (a get() of "'+t.action+'" is meaningless). Execution is objects-side, by action NAME.')}function e0(e,t,r){(!r||typeof r!="object"||Pi(r))&&Re(e,t,'"place" must be an object {'+Mc.join(", ")+"} when present.");for(var n=0;n<Mc.length;n++){var i=Mc[n],a=r[i];if(i==="anchor"){a!==void 0&&dp.indexOf(a)===-1&&Re(e,t,'"place.anchor" must be one of ['+dp.join(", ")+"] when present; got "+JSON.stringify(a)+".");continue}(!ri(a)||a<0||a>1)&&Re(e,t,'"place.'+i+'" must be a number in [0,1] \u2014 a FRACTION of the canvas (resize-stable), not a pixel offset; got '+JSON.stringify(a)+".")}}function t0(e,t){(!Pi(t.presets)||!t.presets.every(_r))&&Re(e,"camera",'"presets" must be an array of non-empty strings.'),tn(t.setOrbit)||Re(e,"camera",'"setOrbit" must be a function(spec)->void.'),tn(t.getOrbit)||Re(e,"camera",'"getOrbit" must be a function()->{azimuth,elevation,distance}.'),tn(t.setPreset)||Re(e,"camera",'"setPreset" must be a function(name)->void.')}function r0(e,t){Hb(t.enabled)||Re(e,"loop",'"enabled" must be a boolean.'),(!ri(t.ticks)||t.ticks<=0)&&Re(e,"loop",'"ticks" must be a positive finite number.'),tn(t.setEnabled)||Re(e,"loop",'"setEnabled" must be a function(boolean)->void.'),tn(t.setTicks)||Re(e,"loop",'"setTicks" must be a function(number)->void.')}function mp(e){if(!e||typeof e!="object")throw new Error("[lib/shim/controls] normalizeControlDescriptor requires a descriptor object; got "+(e===null?"null":typeof e)+". (FAIL-LOUD.)");var t=e.kind;if(hp.indexOf(t)===-1)throw new Error('[lib/shim/controls] normalizeControlDescriptor: unknown kind "'+String(t)+'" (expect one of ['+hp.join(", ")+"]). (FAIL-LOUD.)");var r=e.id;_r(r)||Re(r,t,'"id" must be a non-empty string (every kind requires one \u2014 the registry addressing key).');var n=e.channel;n!==void 0&&pp.indexOf(n)===-1&&Re(r,t,'"channel" must be one of ['+pp.join(", ")+'] when present; got "'+String(n)+'".'),e.widget!==void 0&&al.indexOf(e.widget)===-1&&Re(r,t,'"widget" must be one of ['+al.join(", ")+"] when present; got "+JSON.stringify(e.widget)+'. (widget is kind-ORTHOGONAL \u2014 a toggle is a scalar 0/1 with widget:"toggle", never a new kind.)'),e.place!==void 0&&e0(r,t,e.place),n0[t](r,e);var i={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(i[a]=e[a]);return i.kind=t,i.id=r,n===void 0?i.channel=Nb.indexOf(t)!==-1?Fb:void 0:i.channel=n,e.place!==void 0&&(i.place={x:e.place.x,y:e.place.y,anchor:e.place.anchor!==void 0?e.place.anchor:Pb}),i}var hp,il,Mc,dp,Pb,al,pp,Fb,Nb,Mb,Ub,zb,Vb,qb,Bb,Wb,Gb,pE,Uc,n0,ol=ce(()=>{hp=Object.freeze(["scalar","camera","loop","enum","flags","vector","text","action"]),il=Object.freeze(["pause","resume","toggle","restart"]),Mc=Object.freeze(["x","y","anchor"]),dp=Object.freeze(["top-left","top-right","bottom-left","bottom-right"]),Pb="top-left",al=Object.freeze(["slider","toggle","checkbox","text","button"]),pp=Object.freeze(["physics","render"]),Fb="physics",Nb=Object.freeze(["scalar","enum","flags","vector","text"]),Mb=Object.freeze(["label","min","max","step","value","fmt","onChange"]),Ub=Object.freeze(["presets","setOrbit","getOrbit","setPreset"]),zb=Object.freeze(["enabled","ticks","setEnabled","setTicks"]),Vb=Object.freeze(["label","values","value","fmt","onChange"]),qb=Object.freeze(["label","values","value","fmt","onChange"]),Bb=Object.freeze(["label","value","min","max","step","fmt","onChange"]),Wb=Object.freeze(["label","value","fmt","onChange"]),Gb=Object.freeze(["label","action"]),pE=Object.freeze({scalar:Mb,camera:Ub,loop:zb,enum:Vb,flags:qb,vector:Bb,text:Wb,action:Gb}),Uc=Object.freeze(["object","prop"]);o(tn,"_isFn");o(ri,"_isNum");o(_r,"_isStr");o(Pi,"_isArr");o(Hb,"_isBool");o(Re,"_fail");o(Kb,"_validateBind");o(Co,"_validateWriteAuthority");o(Yb,"_validateScalar");o(Jb,"_validateEnum");o(Qb,"_validateFlags");o(zc,"_validateVectorBound");o(Xb,"_validateVector");o(Zb,"_validateText");o($b,"_validateAction");o(e0,"_validatePlace");o(t0,"_validateCamera");o(r0,"_validateLoop");n0={scalar:Yb,camera:t0,loop:r0,enum:Jb,flags:Qb,vector:Xb,text:Zb,action:$b};o(mp,"normalizeControlDescriptor")});function i0(e,t){if(t=t||{},!e)throw new Error("[frqtl-control-slider] mount requires a host element. (FAIL-LOUD.)");var r,n;if(t.descriptor){var i=t.descriptor;if(!i.id||typeof i.min!="number"||typeof i.max!="number"||typeof i.step!="number")throw new Error("[frqtl-control-slider] mount({descriptor}) requires a normalized scalar descriptor with id/min/max/step. (FAIL-LOUD.)");if(typeof i.onChange!="function"&&i.bind)throw new Error('[frqtl-control-slider] mount({descriptor}) was given a bind-only descriptor (id "'+i.id+`", no onChange) \u2014 the standalone opts.descriptor path has no bind-execution context and cannot write it. Use frqtl-controls-panel.js's mount() instead, or mount this widget via opts.initial + opts.onInput with onInput calling the panel's dispatch/RPC. (FAIL-LOUD \u2014 never a silent no-op on drag.)`);r={id:i.id,label:i.label,min:i.min,max:i.max,step:i.step,value:i.value,valueText:typeof i.fmt=="function"?i.fmt(i.value):String(i.value)},n=o(function(c){return i.value=c,typeof i.onChange=="function"&&i.onChange(c),{value:c,valueText:typeof i.fmt=="function"?i.fmt(c):String(c)}},"onInput")}else{if(!t.initial||typeof t.onInput!="function")throw new Error("[frqtl-control-slider] mount requires EITHER opts.descriptor OR BOTH opts.initial and opts.onInput. (FAIL-LOUD.)");r=t.initial,n=t.onInput}var a=document.createElement("div");a.className="frqtl-control-slider-row",a.style.cssText="display:flex;align-items:center;gap:8px;margin:4px 0;font:12px sans-serif;color:#ccc;";var s=document.createElement("span");s.textContent=r.label+":",s.style.cssText="min-width:56px;";var l=document.createElement("input");l.type="range",l.min=r.min,l.max=r.max,l.step=r.step,l.value=r.value,l.setAttribute("data-frqtl-control-id",r.id);var u=document.createElement("span");u.textContent=r.valueText,u.style.cssText="min-width:32px;text-align:right;color:#ffb450;",l.addEventListener("input",function(){var c=parseFloat(l.value);Promise.resolve(n(c)).then(function(h){h&&h.valueText!==void 0&&(u.textContent=h.valueText)}).catch(function(h){u.textContent="ERR",typeof console<"u"&&console.error&&console.error("[frqtl-control-slider] onInput failed:",h)})}),a.appendChild(s),a.appendChild(l),a.appendChild(u),e.appendChild(a);var f=t.descriptor&&typeof t.descriptor.fmt=="function"?t.descriptor.fmt:function(c){return String(c)};return{dispose:o(function(){a.parentNode&&a.parentNode.removeChild(a)},"dispose"),setValue:o(function(c,h){l.value=c,u.textContent=h!==void 0?h:f(c)},"setValue")}}var gp,vp=ce(()=>{o(i0,"mount");gp={mount:i0}});function bp(e){var t=al;if(e&&e.widget){if(t.indexOf(e.widget)===-1)throw new Error('[frqtl-control-widgets] unknown widget "'+e.widget+'" on control "'+(e.id||"?")+'" \u2014 must be one of ['+t.join(", ")+"]. (FAIL-LOUD.)");return e.widget}return e&&yp[e.kind]||"slider"}function qc(){var e=document.createElement("div");return e.className="frqtl-control-widget-row",e.style.cssText="display:flex;align-items:center;gap:8px;margin:4px 0;font:12px sans-serif;color:#ccc;",e}function wp(e){var t=document.createElement("span");return t.textContent=e,t.style.cssText="min-width:56px;",t}function Bc(e,t,r){Promise.resolve(e).then(t).catch(function(n){r&&r(n),typeof console<"u"&&console.error&&console.error("[frqtl-control-widgets] control dispatch failed:",n)})}function a0(e,t,r,n){var i=qc(),a=document.createElement("input");a.type="checkbox",a.checked=!!Number(t.value),a.setAttribute("data-frqtl-control-id",t.id),n&&(a.style.cssText="width:16px;height:16px;accent-color:#ffb450;");var s=document.createElement("span");return s.textContent=t.valueText!==void 0?t.valueText:String(t.value),s.style.cssText="min-width:32px;text-align:right;color:#ffb450;",a.addEventListener("change",function(){Bc(r(a.checked?1:0),function(l){l&&l.valueText!==void 0&&(s.textContent=l.valueText)},function(){s.textContent="ERR"})}),i.appendChild(wp(t.label+":")),i.appendChild(a),i.appendChild(s),e.appendChild(i),{dispose:o(function(){i.parentNode&&i.parentNode.removeChild(i)},"dispose"),setValue:o(function(l,u){a.checked=!!Number(l),s.textContent=u!==void 0?u:String(l)},"setValue")}}function o0(e,t,r){var n=qc(),i=document.createElement("input");return i.type="text",i.value=t.value!==void 0&&t.value!==null?String(t.value):"",i.setAttribute("data-frqtl-control-id",t.id),i.style.cssText="flex:1;min-width:80px;background:#1b2330;color:#ddd;border:1px solid #33405a;border-radius:3px;padding:2px 4px;font:12px sans-serif;",i.addEventListener("change",function(){Bc(r(i.value),function(){})}),n.appendChild(wp(t.label+":")),n.appendChild(i),e.appendChild(n),{dispose:o(function(){n.parentNode&&n.parentNode.removeChild(n)},"dispose"),setValue:o(function(a){i.value=a==null?"":String(a)},"setValue")}}function s0(e,t,r){var n=qc(),i=document.createElement("button");return i.type="button",i.textContent=t.label,i.setAttribute("data-frqtl-control-id",t.id),i.setAttribute("data-frqtl-control-action",t.action||""),i.style.cssText="background:#26324a;color:#e6edf7;border:1px solid #3d4d6b;border-radius:3px;padding:3px 10px;font:12px sans-serif;cursor:pointer;",i.addEventListener("click",function(){Bc(r(t.action),function(){})}),n.appendChild(i),e.appendChild(n),{dispose:o(function(){n.parentNode&&n.parentNode.removeChild(n)},"dispose"),setValue:o(function(){},"setValue")}}function l0(e,t){if(t=t||{},!e)throw new Error("[frqtl-control-widgets] mountWidget requires a host element. (FAIL-LOUD.)");var r=t.initial;if(!r)throw new Error("[frqtl-control-widgets] mountWidget requires opts.initial. (FAIL-LOUD.)");var n=bp(r);if(n==="button"){if(typeof t.onAction!="function")throw new Error('[frqtl-control-widgets] the "button" widget (control "'+r.id+'") requires opts.onAction. (FAIL-LOUD \u2014 never a dead button.)');return s0(e,r,t.onAction)}if(typeof t.onInput!="function")throw new Error('[frqtl-control-widgets] the "'+n+'" widget (control "'+r.id+'") requires opts.onInput. (FAIL-LOUD.)');if(n==="slider")return gp.mount(e,{initial:r,onInput:t.onInput});if(n==="toggle"||n==="checkbox")return a0(e,r,t.onInput,n==="toggle");if(n==="text")return o0(e,r,t.onInput);throw new Error('[frqtl-control-widgets] no renderer for widget "'+n+'". (FAIL-LOUD.)')}var yp,sl,Wc=ce(()=>{ol();vp();yp=Object.freeze({scalar:"slider",text:"text",action:"button"});o(bp,"resolveWidget");o(qc,"_row");o(wp,"_label");o(Bc,"_settle");o(a0,"_mountToggle");o(o0,"_mountText");o(s0,"_mountButton");o(l0,"mountWidget");sl={WIDGET_BY_KIND:yp,resolveWidget:bp,mountWidget:l0}});function u0(e,t,r){if(!e||typeof e!="object"||typeof e.prop!="string"||!e.prop||typeof e.object!="string"||!e.object)throw new Error("[controlBind] resolveBind requires bind = {object, prop} (both non-empty strings) \u2014 got "+JSON.stringify(e)+". (FAIL-LOUD \u2014 this should already have been caught by lib/shim/controls at normalize time; resolveBind re-checks defensively, never as the primary gate.)");t=t||{};var n=r||"physics";if(n==="render")return{set:o(function(f){if(!t.runner)throw new Error('[controlBind] render-channel bind on prop "'+e.prop+'" requires ctx.runner (an FrqtlApp). (FAIL-LOUD.)');t.runner.setRenderOption(e.prop,f)},"set"),get:o(function(){if(t.runner)return t.runner.getRenderOption(e.prop)},"get")};if(e.object==="universe")return{set:o(function(f){if(!t.runner||typeof t.runner.setUniverseProperty!="function")throw new Error('[controlBind] universe bind on "'+e.prop+'" requires ctx.runner (an FrqtlApp with setUniverseProperty). (FAIL-LOUD.)');t.runner.setUniverseProperty(e.prop,f)},"set"),get:o(function(){if(!t.runner||typeof t.runner.getUniverseProperty!="function")throw new Error('[controlBind] universe bind on "'+e.prop+'" requires ctx.runner (an FrqtlApp with getUniverseProperty). (FAIL-LOUD.)');return t.runner.getUniverseProperty(e.prop)},"get")};if(!t.registry||typeof t.registry.getObject!="function"||typeof t.registry.getObjectKind!="function")throw new Error('[controlBind] physics-channel bind on "'+e.object+"."+e.prop+'" requires ctx.registry (a makeControlRegistry() instance with getObject/getObjectKind). (FAIL-LOUD.)');var i=t.registry.getObject(e.object),a=t.registry.getObjectKind(e.object);if(a==="Frame"){var s=i;return{set:o(function(f){if(!t.universe||typeof t.universe.setFrameProperty!="function")throw new Error('[controlBind] Frame bind on "'+e.object+"."+e.prop+'" requires ctx.universe (setFrameProperty). (FAIL-LOUD.)');t.universe.setFrameProperty(s,e.prop,f)},"set"),get:o(function(){if(!t.universe||typeof t.universe.getFrameProperty!="function")throw new Error('[controlBind] Frame bind on "'+e.object+"."+e.prop+'" requires ctx.universe (getFrameProperty). (FAIL-LOUD.)');return t.universe.getFrameProperty(s,e.prop)},"get")}}if(a==="LargeObject"||a==="backdrop"){var l=i,u=i&&typeof i=="object"&&i.handle!==void 0?i.handle:i;return{set:o(function(f){if(!t.runner||typeof t.runner.updateObjectProperty!="function")throw new Error('[controlBind] LargeObject bind on "'+e.object+"."+e.prop+'" requires ctx.runner (an FrqtlApp with updateObjectProperty). (FAIL-LOUD.)');t.runner.updateObjectProperty(l,e.prop,f)},"set"),get:o(function(){if(typeof t.readSnapshot=="function")return t.readSnapshot(u,a,e.prop)},"get")}}throw new Error('[controlBind] bind.object "'+e.object+'" resolved to kind "'+a+`" \u2014 bind execution only supports {Frame, LargeObject, backdrop} (updateObjectProperty's own WASM-ABI dispatch has no real branch for any other kind \u2014 it would validate then silently no-op, which this file refuses to do). (FAIL-LOUD.)`)}var Gc,_p=ce(()=>{o(u0,"resolveBind");Gc={resolveBind:u0}});function c0(e,t){var r=il;if(r.indexOf(e)===-1)throw new Error('[controlAction] unknown action "'+String(e)+'" \u2014 must be one of ['+r.join(", ")+"] (the closed vocabulary owned by lib/shim/controls). (FAIL-LOUD.)");var n=xp[e],i=t&&t.runner;if(!i)throw new Error('[controlAction] resolveAction("'+e+'") requires ctx.runner (the live FrqtlApp). (FAIL-LOUD \u2014 never a silently dead button.)');if(typeof i[n]!="function")throw new Error('[controlAction] resolveAction("'+e+'"): the runner has no "'+n+'" method \u2014 the action vocabulary and the runner surface have drifted. (FAIL-LOUD.)');return{run:o(function(){return i[n]()},"run")}}var xp,Op,Ep=ce(()=>{ol();xp=Object.freeze({pause:"stop",resume:"start",toggle:"toggle",restart:"restart"});o(c0,"resolveAction");Op={resolveAction:c0,ACTION_METHODS:xp}});var Kc={};Oe(Kc,{FrqtlControlsPanel:()=>wn});function Hc(e,t,r){if(r=r||[],t==="listControls"){var n=r[0],i=e.getControls(n),a=e._controlBindCtx;return i.map(function(R){if(R.bind&&a){var Q=Gc;try{var Y=Q.resolveBind(R.bind,a,R.channel).get();Y!==void 0&&(R.value=Y)}catch(q){typeof console<"u"&&console.warn&&console.warn('[frqtl-controls-panel] listControls: live refresh failed for "'+R.id+'" (kept cached value):',q)}}var H={id:R.id,label:R.label,min:R.min,max:R.max,step:R.step,value:R.value,valueText:typeof R.fmt=="function"?R.fmt(R.value):String(R.value)};return R.kind!==void 0&&(H.kind=R.kind),R.widget!==void 0&&(H.widget=R.widget),R.action!==void 0&&(H.action=R.action),R.values!==void 0&&(H.values=R.values),R.place!==void 0&&(H.place=R.place),H})}if(t==="runControlAction"){for(var s=r[0],l=r[1],u=e.getControls(s),f=null,c=0;c<u.length;c++)if(u[c].id===l){f=u[c];break}if(!f)throw new Error('[frqtl-controls-panel] runControlAction: unknown control id "'+l+'" in "'+s+'" (registered: ['+u.map(function(R){return R.id}).join(", ")+"]). (FAIL-LOUD.)");if(f.kind!=="action")throw new Error('[frqtl-controls-panel] runControlAction("'+l+'"): descriptor kind is "'+f.kind+'", not "action". (FAIL-LOUD.)');var h=e._controlBindCtx||{},g=Op.resolveAction(f.action,{runner:h.runner}).run();return{action:f.action,done:Promise.resolve(g)}}if(t==="setControlValue"){for(var p=r[0],m=r[1],b=r[2],y=e.getControls(p),w=null,O=0;O<y.length;O++)if(y[O].id===m){w=y[O];break}if(!w)throw new Error('[frqtl-controls-panel] setControlValue: unknown control id "'+m+'" in "'+p+'" (registered: ['+y.map(function(R){return R.id}).join(", ")+"]). (FAIL-LOUD.)");if(w.value=b,typeof w.onChange=="function")w.onChange(b);else if(w.bind){var S=e._controlBindCtx||{},A=Gc,C=A.resolveBind(w.bind,S,w.channel);C.set(b)}else throw new Error('[frqtl-controls-panel] setControlValue("'+m+'" in "'+p+'"): descriptor has neither "onChange" nor "bind" \u2014 this should be structurally impossible post-normalize (lib/shim/controls requires at least one). (FAIL-LOUD \u2014 never a silent no-op.)');return{value:b,valueText:typeof w.fmt=="function"?w.fmt(b):String(b)}}throw new Error('[frqtl-controls-panel] unrecognized verb "'+String(t)+'" (expected "listControls", "setControlValue" or "runControlAction"). (FAIL-LOUD.)')}function f0(){return kp}function h0(e,t){if(t=t||{},!e||typeof e.getControls!="function")throw new Error("[frqtl-controls-panel] exposeRegistry requires a makeControlRegistry() instance (missing getControls). (FAIL-LOUD.)");if(kp=e,e._controlBindCtx={registry:e,universe:t.universe,runner:t.runner,readSnapshot:t.readSnapshot},t.crossFrame!==!1&&!(typeof document>"u")){var r=document.defaultView;if(!(!r||!r.parent||r.parent===r)){var n=nl,i=n.makeWindowPostMessageChannel(r.parent,{selfWindow:r});n.installRpcResponder(i,function(a,s){return Hc(e,a,s)},{tag:Sp})}}}function d0(e){return Nc(function(t,r){return Hc(e,t,r)})}function p0(e,t){if(!e||!e.contentWindow)throw new Error('[frqtl-controls-panel] mount({mode:"iframe"}) requires opts.frame \u2014 an <iframe> element with a live contentWindow. (FAIL-LOUD \u2014 missing transport.)');var r=nl,n=r.makeWindowPostMessageChannel(e.contentWindow),i={tag:Sp};return typeof t=="number"&&t>0&&(i.callTimeoutMs=t),r.makeChannelRpc(n,i)}function m0(e,t){if(t=t||{},!e)throw new Error("[frqtl-controls-panel] mount requires a host element. (FAIL-LOUD.)");if(!t.name)throw new Error("[frqtl-controls-panel] mount requires opts.name (the registry instance name registered via exposeRegistry). (FAIL-LOUD.)");var r;if(t.mode==="in-app"){if(!t.registry)throw new Error('[frqtl-controls-panel] mount({mode:"in-app"}) requires opts.registry (the SAME registry instance exposeRegistry() was called with). (FAIL-LOUD.)');r=d0(t.registry)}else if(t.mode==="iframe")r=p0(t.frame,t.callTimeoutMs);else throw new Error('[frqtl-controls-panel] mount: opts.mode must be "in-app" or "iframe"; got '+JSON.stringify(t.mode)+". (FAIL-LOUD.)");var n=t.name;e.classList.add("frqtl-controls-panel");function i(s){e.innerHTML="";var l=sl;s.forEach(function(u){l.mountWidget(e,{initial:u,onInput:o(function(f){return r.call("setControlValue",[n,u.id,f])},"onInput"),onAction:o(function(){return r.call("runControlAction",[n,u.id])},"onAction")})})}o(i,"renderRows");var a=r.call("listControls",[n]).then(function(s){i(s)}).catch(function(s){throw e.textContent='[frqtl-controls-panel] failed to load "'+n+'": '+(s&&s.message?s.message:String(s)),typeof console<"u"&&console.error&&console.error(s),s});return{ready:a,dispose:o(function(){r.dispose(),e.innerHTML=""},"dispose")}}var Sp,kp,wn,Ra=ce(()=>{fp();Wc();_p();Ep();Sp="frqtl-controls-panel";o(Hc,"_dispatchControlsCall");kp=null;o(f0,"exposedRegistry");o(h0,"exposeRegistry");o(d0,"_buildInAppHandle");o(p0,"_buildIframeHandle");o(m0,"mount");wn={exposeRegistry:h0,exposedRegistry:f0,mount:m0,dispatch:Hc}});function g0(e){return typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16)}function v0(e){if(e=e||{},!e.name)throw new Error("[frqtl-control-sync] makeControlSync requires opts.name. (FAIL-LOUD.)");var t=e.trigger!==void 0?e.trigger:"manual";if(Yc.indexOf(t)===-1)throw new Error("[frqtl-control-sync] opts.trigger must be one of ["+Yc.join(", ")+"]; got "+JSON.stringify(t)+". (FAIL-LOUD.)");var r=!!e.registry,n=!!e.handle;if(r===n)throw new Error("[frqtl-control-sync] makeControlSync requires EXACTLY ONE of opts.registry (in-app pull) or opts.handle (remote RPC pull); got "+(r?"both":"neither")+". (FAIL-LOUD.)");var i=e.name,a=Object.create(null),s=Object.create(null),l=null,u=!1;function f(){return r?Promise.resolve(wn.dispatch(e.registry,"listControls",[i])):e.handle.call("listControls",[i])}o(f,"_rawPull");function c(y,w){if(!y||typeof y!="string")throw new Error("[frqtl-control-sync] register requires a non-empty string id. (FAIL-LOUD.)");if(!w||typeof w.setValue!="function")throw new Error('[frqtl-control-sync] register("'+y+`") requires a widget exposing setValue(value, valueText?) (frqtl-control-slider.js's mount() return). (FAIL-LOUD.)`);return(a[y]=a[y]||[]).push(w),o(function(){var S=a[y];if(S){var A=S.indexOf(w);A!==-1&&S.splice(A,1)}},"unregister")}o(c,"register");function h(){return f().then(function(y){u||y.forEach(function(w){var O=a[w.id];!O||!O.length||s[w.id]!==w.value&&(s[w.id]=w.value,O.forEach(function(S){S.setValue(w.value,w.valueText)}))})})}o(h,"pull");var g=typeof e.devWarnMs=="number"?e.devWarnMs:3e3,p=null;(t==="tick"||t==="pause")&&(p=setTimeout(function(){p=null,typeof console<"u"&&console.warn&&console.warn('[frqtl-control-sync] trigger:"'+t+'" was declared for "'+i+'" but notify("'+t+'") was never called within '+g+"ms \u2014 did the page forget its one-line `sync.notify('"+t+"')` call (inside its own onTick or pause handler)? (DEV-WARN \u2014 an un-notified sync is inert, not broken.)")},g));function m(y){t!=="manual"&&y===t&&(p&&(clearTimeout(p),p=null),l===null&&(l=g0(function(){l=null,!u&&h()})))}o(m,"notify");function b(){u=!0,p&&(clearTimeout(p),p=null),a=Object.create(null)}return o(b,"dispose"),{register:c,pull:h,notify:m,dispose:b}}var Yc,Ap,Tp=ce(()=>{Ra();Yc=Object.freeze(["manual","tick","pause"]);o(g0,"_raf");o(v0,"makeControlSync");Ap={makeControlSync:v0,SYNC_TRIGGERS:Yc}});var Jc={};Oe(Jc,{FrqtlControlOverlay:()=>ll});function y0(e,t){var r=t.x*100+"%",n=t.y*100+"%",i=t.anchor||"top-left";e.style.position="absolute",i==="top-left"&&(e.style.left=r,e.style.top=n),i==="top-right"&&(e.style.right=r,e.style.top=n),i==="bottom-left"&&(e.style.left=r,e.style.bottom=n),i==="bottom-right"&&(e.style.right=r,e.style.bottom=n)}function b0(e,t){if(t=t||{},!e||typeof e.addControlChrome!="function"||!("controlHost"in e))throw new Error("[frqtl-control-overlay] mount(runner, opts) takes the scene's RUNNER \u2014 the overlay mounts through its one door, runner.controlHost (a scene never names a DOM id). (FAIL-LOUD.)");var r=e.controlHost;if(!r)throw new Error("[frqtl-control-overlay] runner.controlHost is null \u2014 the scene canvas is not mounted and no hosting pane set a host (check runner.controlHost before mounting). (FAIL-LOUD.)");if(!t.registry||typeof t.registry.getControls!="function")throw new Error("[frqtl-control-overlay] mount requires opts.registry \u2014 the SAME makeControlRegistry() instance the page exposed. (FAIL-LOUD.)");if(!t.name)throw new Error("[frqtl-control-overlay] mount requires opts.name (the registry instance name the controls were registered under). (FAIL-LOUD.)");var n=wn,i=sl,a=t.registry,s=t.name,l=r.ownerDocument,u=l.createElement("div");u.className="frqtl-control-overlay",u.setAttribute("data-role","frqtl-control-overlay"),u.style.cssText="position:absolute;pointer-events:none;z-index:12;";var f=r.style.position;(!f||f==="static")&&(r.style.position="relative"),r.appendChild(u);function c(){var S=typeof r.querySelector=="function"?r.querySelector("canvas"):null;S?(u.style.left=S.offsetLeft+"px",u.style.top=S.offsetTop+"px",u.style.width=S.offsetWidth+"px",u.style.height=S.offsetHeight+"px"):(u.style.left="0",u.style.top="0",u.style.width="100%",u.style.height="100%")}o(c,"sizeToCanvas"),c();var h=o(function(){c()},"onResize"),g=typeof document<"u"?document.defaultView:null;g&&g.addEventListener("resize",h);var p=Ap.makeControlSync({name:s,registry:a,trigger:"manual"}),m=[];function b(){m.forEach(function(S){S.widget.dispose(),S.cell.parentNode&&S.cell.parentNode.removeChild(S.cell)}),m=[]}o(b,"clear");function y(){b(),c();var S=n.dispatch(a,"listControls",[s]);return S.forEach(function(A){if(A.place){var C=l.createElement("div");C.className="frqtl-control-overlay-cell",C.setAttribute("data-frqtl-overlay-control",A.id),C.style.cssText="pointer-events:auto;background:rgba(12,18,28,0.72);border:1px solid #33405a;border-radius:4px;padding:2px 8px;backdrop-filter:blur(2px);",y0(C,A.place),u.appendChild(C);var R=i.mountWidget(C,{initial:A,onInput:o(function(Q){return n.dispatch(a,"setControlValue",[s,A.id,Q])},"onInput"),onAction:o(function(){var Q=n.dispatch(a,"runControlAction",[s,A.id]);return p.pull(),Q},"onAction")});p.register(A.id,R),m.push({id:A.id,widget:R,cell:C})}}),m.map(function(A){return A.id})}o(y,"refresh");var w=y(),O=e.addControlChrome({rehost:o(function(S){S!==r&&(O(),u.parentNode&&u.parentNode.removeChild(u),r.style.position=f,r=S,l=S.ownerDocument,f=S.style.position,(!f||f==="static")&&(S.style.position="relative"),S.appendChild(u),c())},"rehost")});return{controls:w,refresh:y,sync:o(function(){return p.pull()},"sync"),dispose:o(function(){b(),p.dispose(),g&&g.removeEventListener("resize",h),u.parentNode&&u.parentNode.removeChild(u),r.style.position=f},"dispose")}}var ll,Qc=ce(()=>{Ra();Wc();Tp();o(y0,"_applyPlace");o(b0,"mount");ll={mount:b0}});var Io={};Oe(Io,{FILTER_TICKS_PER_SECOND:()=>Rp,RENDERER_PROVIDER_OPTIONAL:()=>ul,RENDERER_PROVIDER_REQUIRED:()=>Ro,SCENE_SURFACE_ATTR:()=>cl,filterTime:()=>Lo,requireMountHost:()=>jo,requireProviderSize:()=>zn,requireSceneSurface:()=>w0,validateRendererProvider:()=>Do});function Do(e){var t=e!==null&&(typeof e=="object"||typeof e=="function");if(!t)return{ok:!1,missing:Ro.slice(),capabilities:[]};var r=Ro.filter(function(i){return typeof e[i]!="function"}),n=ul.filter(function(i){return typeof e[i]=="function"});return{ok:r.length===0,missing:r,capabilities:n}}function Cp(e){return typeof e=="number"&&isFinite(e)&&e>0}function zn(e,t,r){if(!(Cp(t)&&Cp(r)))throw new Error(e+": width and height must be positive finite numbers (got width="+String(t)+", height="+String(r)+"). They are the runner's physics rect (runner.canvas_rect), handed over by FrqtlApp.createCanvas as provider.init({width, height}) and written once by the scene's exp.createCanvas(w, h, cfg) / exp.createScene(w, h, d, cfg). A provider has no default size; the display size is the host element's CSS box, never a provider argument.")}function jo(e,t){var r=typeof t=="string"&&t.length>0,n=typeof document<"u"&&document!==null&&typeof document.getElementById=="function",i=r&&n?document.getElementById(t):null;if(i)return i;var a=r?n?JSON.stringify(t)+", which names no element in the page":JSON.stringify(t)+", and there is no document":typeof t=="string"?'""':String(t);throw new Error(e+": canvasParentId is required and must name an element in the page (got "+a+"). The runner hands it as init({ parentEl }) from new FrqtlApp({ canvasParentId }) / new RecipeContext({ canvasParentId }). There is no default mount: a canvas appended to document.body is a canvas the layout never placed. (FAIL-LOUD.)")}function w0(e,t){var r=t!==null&&typeof t=="object"&&typeof t.tagName=="string"&&t.tagName.toUpperCase()==="CANVAS"&&typeof t.setAttribute=="function"&&typeof t.getContext=="function";if(r)return t;var n=t==null?String(t):typeof t=="object"&&typeof t.tagName=="string"?"<"+t.tagName.toLowerCase()+">":typeof t=="object"&&t.elt!==void 0?"a p5.Element (return its .elt)":typeof t;throw new Error(e+": provider.init(opts) must RETURN its drawing surface as an HTMLCanvasElement (got "+n+"). The runner stamps "+cl+" on it so the scene surface is declared, never guessed among the document's canvases (RENDERER_CONTRACT \xA71, init row; owner: lib/frqtl/compat/renderer/renderer-provider-contract.js).")}function Lo(e){var t=e&&e.universeData&&e.universeData.tick;if(typeof t=="number"&&isFinite(t)&&t>=0)return t/Rp;throw new Error("filterTime: the TickData being rendered must carry universeData.tick (got "+String(t)+"). uTime is simulation time at the rendered tick, never the wall clock (owner: lib/frqtl/compat/renderer/renderer-provider-contract.js). (FAIL-LOUD.)")}var Ro,ul,cl,Rp,ni=ce(()=>{Ro=["init","setSize","start","stop","destroy","renderTick","filter","removeFilter","raw"],ul=["renderCapabilities","getCameraControl","screenToWorld","captureStill","projection"];o(Do,"validateRendererProvider");o(Cp,"_isPositiveFinite");o(zn,"requireProviderSize");o(jo,"requireMountHost");cl="data-frqtl-scene-surface";o(w0,"requireSceneSurface");Rp=60;o(Lo,"filterTime")});var sr={};Oe(sr,{RENDER_STAGES:()=>ii,RUNTIME_MUTATION_SURFACES:()=>O0,SCENE_BOUND_KEYS:()=>_0,SCENE_KEYS:()=>Xc,SCENE_SURFACE_ATTR:()=>cl,SCHEMA_VERSION:()=>Fi,STAGE_FORMATS:()=>jp,STILL_BAG_KEYS:()=>Pp,STILL_DERIVED_KEYS:()=>Ip,STILL_KEYS:()=>Lp,STILL_PAYLOAD_KEYS:()=>Fp,STILL_PROVENANCE_KEYS:()=>x0,assertSceneBound:()=>$c,assertSourceSha256:()=>fl,assertStage:()=>Fo,canonicalizeScene:()=>Vp,deepPlainCopy:()=>Zc,finalStage:()=>tf,normalizeScene:()=>A0,normalizeStill:()=>rf,sceneHash:()=>T0,snapshotPayload:()=>zp,stageNotTappableError:()=>S0,upstreamStages:()=>Np});function E0(e){return ii.indexOf(e)!==-1}function tf(){return ii[ii.length-1]}function Np(e){return Fo(e),ii.slice(0,ii.indexOf(e))}function Fo(e){if(!E0(e))throw new Error("[RenderStages] unknown stage "+JSON.stringify(e)+" \u2014 the canonical pipeline is ["+ii.join(", ")+"]. The stage argument is REQUIRED on the tap mechanism (a default is the convenience's job, not the mechanism's). (FAIL-LOUD.)");return e}function S0(e,t){return new Error("[RenderStages] stage "+JSON.stringify(e)+" is known, but not tappable by "+(t||"the active provider")+". Known stages: ["+ii.join(", ")+"]. A tap executor is added when a real caller for it appears \u2014 never a null image or an empty bag in the meantime. (FAIL-LOUD.)")}function or(e){throw new Error("[RenderStages.normalizeStill] "+e+" (FAIL-LOUD.)")}function Mp(e){return typeof e=="number"&&isFinite(e)&&e>0&&Math.floor(e)===e}function Dp(e,t){return Mp(e)||or(t+" must be a positive integer, got "+String(e)),e}function k0(e){for(var t=[],r=Object.create(null),n=e,i=!0;n&&n!==Object.prototype&&n!==Array.prototype;){for(var a=Object.getOwnPropertyNames(n),s=0;s<a.length;s++){var l=a[s];if(!(l==="constructor"||r[l])){var u=Object.getOwnPropertyDescriptor(n,l);(u.get||i||typeof u.value!="function")&&(r[l]=!0,t.push(l))}}n=Object.getPrototypeOf(n),i=!1}return t}function Up(e){return e&&typeof e=="object"&&typeof e.BYTES_PER_ELEMENT=="number"&&typeof e.length=="number"&&typeof e.constructor=="function"}function Po(e,t){if(e==null)return null;var r=typeof e;if(r==="number"||r==="string"||r==="boolean")return e;if(r==="function"&&or("the payload carries a FUNCTION at "+t+" \u2014 a still record must be plain, serialization-safe data"),r!=="object"&&or("the payload carries an unsupported "+r+" at "+t),Up(e))return new e.constructor(e);if(Array.isArray(e)){for(var n=new Array(e.length),i=0;i<e.length;i++)n[i]=Po(e[i],t+"["+i+"]");return n}for(var a={},s=k0(e),l=0;l<s.length;l++){var u=s[l],f;try{f=e[u]}catch{continue}a[u]=Po(f,t+"."+u)}return a}function Zc(e){return Po(e,"value")}function zp(e,t){if(t==="framedata")return Po(e,"data");if(Up(e))return new e.constructor(e);if(Array.isArray(e))return Po(e,"data");or("format "+JSON.stringify(t)+" expects an indexed buffer payload, got "+String(e))}function Da(e){throw new Error("[RenderStages.normalizeScene] "+e+" (FAIL-LOUD.)")}function $c(e,t){return Mp(e)||Da(t+" must be a positive integer (a physics bound, init-fixed), got "+String(e)),e}function fl(e){return e==null?null:((typeof e!="string"||!/^[0-9a-f]{64}$/.test(e))&&Da("sourceSha256 must be null or a project identity (64 lowercase hex characters, lib/shim/project/identity.js projectIdentity), got "+String(e)),e)}function A0(e){return(!e||typeof e!="object")&&Da("expected a partial scene bag object, got "+String(e)),e.v!==void 0&&e.v!==null&&e.v!==Fi&&Da("v "+String(e.v)+" disagrees with the contract version "+Fi+" \u2014 the normalizer is the version authority, `v` is never caller-supplied"),(typeof e.seed!="number"||!isFinite(e.seed))&&Da('seed must be a finite number \u2014 it is half of the regeneration triple (code, seed, tick), and a null seed downgrades "regenerate" to "trust the raster", got '+String(e.seed)),{v:Fi,seed:e.seed,sourceRef:e.sourceRef===void 0||e.sourceRef===null?null:String(e.sourceRef),sourceSha256:fl(e.sourceSha256),build:e.build&&typeof e.build=="object"?Zc(e.build):null,physicsW:$c(e.physicsW,"physicsW"),physicsH:$c(e.physicsH,"physicsH"),projection:e.projection&&typeof e.projection=="object"?Zc(e.projection):null}}function ef(e){if(e==null)return"null";var t=typeof e;if(t==="number"||t==="boolean")return String(e);if(t==="string")return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(ef).join(",")+"]";var r=Object.keys(e).sort();return"{"+r.map(function(n){return JSON.stringify(n)+":"+ef(e[n])}).join(",")+"}"}function Vp(e){(!e||typeof e!="object")&&Da("canonicalizeScene expects a record object, got "+String(e));for(var t=[],r=0;r<Xc.length;r++){var n=Xc[r];t.push(JSON.stringify(n)+":"+ef(e[n]))}return"{"+t.join(",")+"}"}function T0(e){var t=Vp(e),r=typeof crypto<"u"?crypto.subtle:null;if(!r||typeof r.digest!="function")return Promise.reject(new Error("[RenderStages.sceneHash] crypto.subtle.digest is unavailable \u2014 the scene identity is a content hash and there is no fallback hashing path by design (two hashing authorities would mint two identities for one scene). (FAIL-LOUD.)"));var n=new TextEncoder().encode(t);return Promise.resolve(r.digest("SHA-256",n)).then(function(i){for(var a=new Uint8Array(i),s="",l=0;l<a.length;l++)s+=(a[l]<16?"0":"")+a[l].toString(16);return"sha256:"+s})}function rf(e){(!e||typeof e!="object")&&or("expected a partial bag object, got "+String(e));var t=Fo(e.stage),r=jp[t];e.format!==void 0&&e.format!==null&&e.format!==r&&or("format "+JSON.stringify(e.format)+" does not match stage "+JSON.stringify(t)+"'s declared format "+JSON.stringify(r));var n=e.data;n==null&&or("stage "+JSON.stringify(t)+" returned no `data` payload"),typeof n.length!="number"&&or("`data` must be an indexed payload (Array / Uint8Array / Uint8ClampedArray), got "+String(n)),n.length===0&&or("stage "+JSON.stringify(t)+" returned an EMPTY `data` payload \u2014 never a blank still: a measurement or golden built on an empty capture is fabricated evidence"),e.v!==void 0&&e.v!==null&&e.v!==Fi&&or("v "+String(e.v)+" disagrees with the contract version "+Fi+" \u2014 the normalizer is the version authority, `v` is never caller-supplied"),(typeof e.scene!="string"||!e.scene)&&or("scene must be the content hash of the SceneRecord this still belongs to \u2014 a still without a scene id is unmoored: it cannot be verified against, or regenerated from, anything. Got "+String(e.scene)),(typeof e.tick!="number"||!isFinite(e.tick)||e.tick<0)&&or("tick must be a finite non-negative number (the dispatcher stamps it from the live TickData \u2014 the tick-equality assertion is what co-registers a multi-channel corpus row), got "+String(e.tick));var i=e.filtersApplied;Array.isArray(i)||or("filtersApplied must be an ARRAY of filter names in the order they ran (the provider's ordered _filters list is the one authority), got "+String(i));var a=e.filterTime===void 0?null:e.filterTime;(i.length>0?!(typeof a=="number"&&isFinite(a)):a!==null)&&or("filterTime must be the finite uTime the filter passes drew with when filtersApplied is non-empty, and null when it is empty (filtersApplied "+JSON.stringify(i)+", filterTime "+String(a)+") \u2014 the provider reports it (RendererProviderContract.filterTime of the rendered tick)");var s=Np(t);if(e.composedOf!==void 0&&e.composedOf!==null){var l=e.composedOf,u=Array.isArray(l)&&l.length===s.length&&l.every(function(f,c){return f===s[c]});u||or("composedOf is DERIVED from RENDER_STAGES ("+JSON.stringify(s)+") and is never caller-supplied; got "+JSON.stringify(l))}return{v:Fi,scene:e.scene,stage:t,tick:e.tick,format:r,data:zp(n,r),width:Dp(e.width,"width"),height:Dp(e.height,"height"),cssWidth:typeof e.cssWidth=="number"?e.cssWidth:null,cssHeight:typeof e.cssHeight=="number"?e.cssHeight:null,filtersApplied:i.slice(),renderBaseCanvas:typeof e.renderBaseCanvas=="boolean"?e.renderBaseCanvas:null,filterTime:a,pose:e.pose!==void 0&&e.pose!==null?e.pose:null,fieldOpts:e.fieldOpts&&typeof e.fieldOpts=="object"?e.fieldOpts:null,composedOf:s,renderOptions:e.renderOptions&&typeof e.renderOptions=="object"?e.renderOptions:{}}}var ii,jp,Fi,Xc,_0,Lp,Ip,Pp,Fp,x0,O0,ja=ce(()=>{ni();ii=["tick","field","scene","composite"],jp={tick:"framedata",field:"r8",scene:"rgba8",composite:"rgba8"},Fi=4,Xc=["v","seed","sourceRef","sourceSha256","build","physicsW","physicsH","projection"],_0=["physicsW","physicsH"],Lp=["v","scene","stage","format","tick","data","width","height","cssWidth","cssHeight","pose","filtersApplied","renderBaseCanvas","filterTime","renderOptions","fieldOpts"],Ip=["composedOf"],Pp=Lp.concat(Ip),Fp=["data","width","height"],x0=Pp.filter(function(e){return Fp.indexOf(e)===-1}),O0={"cameraControl.setOrbit/look/move/setPreset":["pose"],"setFilterActive / provider.filter / removeFilter":["filtersApplied","filterTime"],setRenderOption:["renderOptions","renderBaseCanvas"],"canvas resize (setSize)":["width","height","cssWidth","cssHeight"],"FieldBuilder options at the field tap":["fieldOpts"]};o(E0,"_isStageKnown");o(tf,"finalStage");o(Np,"upstreamStages");o(Fo,"assertStage");o(S0,"stageNotTappableError");o(or,"_fail");o(Mp,"_isPosInt");o(Dp,"_posInt");o(k0,"_readableKeys");o(Up,"_isTypedArray");o(Po,"_deepPlainClone");o(Zc,"deepPlainCopy");o(zp,"snapshotPayload");o(Da,"_failScene");o($c,"assertSceneBound");o(fl,"assertSourceSha256");o(A0,"normalizeScene");o(ef,"_stableEncode");o(Vp,"canonicalizeScene");o(T0,"sceneHash");o(rf,"normalizeStill")});var La={};Oe(La,{ENCODED_KEYS:()=>Bp,ENCODERS:()=>dl,ENVELOPE_VERSION:()=>nf,bytesToBase64:()=>R0,stillEnvelope:()=>D0,videoEnvelope:()=>af});function It(e){throw new Error("[capture-envelope] "+e+" (FAIL-LOUD.)")}function C0(e,t){return typeof e!="boolean"&&It(t+" must be an explicit boolean, got "+String(e)+" \u2014 it is never defaulted, because a fabricated completeness claim is the exact failure the recorder's own bound reporting exists to prevent"),e}function hl(e,t){return(typeof e!="number"||!isFinite(e)||e<=0||e%1!==0)&&It(t+" must be a positive whole number, got "+String(e)),e}function Wp(e,t,r){return(typeof e!="string"||!e)&&It(t+" must be a non-empty string"+(r?" \u2014 "+r:"")+", got "+String(e)),e}function Gp(e,t){(!e||typeof e!="object")&&It("`encoded` must be an object carrying the transportable bytes");for(var r={},n=Bp[t],i=0;i<n.length;i++){var a=n[i];a==="encoder"?r.encoder=e.encoder===void 0?null:e.encoder:a==="bytes"?((typeof e.bytes!="string"||!e.bytes)&&It("encoded.bytes must be a non-empty base64 string \u2014 the envelope carries TRANSPORTABLE bytes; an rgba8 payload does not cross a boundary and the still already holds it"),r.bytes=e.bytes):r[a]=Wp(e[a],"encoded."+a)}if(r.mime.indexOf(qp[t])!==0&&It("encoded.mime "+JSON.stringify(r.mime)+" is not a "+qp[t]+"* type"),r.encoder!==null){Object.prototype.hasOwnProperty.call(dl,r.encoder)||It("unknown encoder "+JSON.stringify(r.encoder)+" \u2014 known: "+Object.keys(dl).join(", "));var s=dl[r.encoder];s.kind!==t&&It("encoder "+JSON.stringify(r.encoder)+" produces a "+s.kind+", not a "+t),s.mime!==r.mime&&It("encoder "+JSON.stringify(r.encoder)+" produces "+JSON.stringify(s.mime)+", but encoded.mime says "+JSON.stringify(r.mime))}return r}function R0(e){(!e||typeof e.BYTES_PER_ELEMENT!="number")&&It("bytesToBase64 expects a typed array, got "+String(e)),typeof btoa!="function"&&It("bytesToBase64 needs a global btoa (every browser, and node >= 16)");for(var t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r="",n=0;n<t.length;n+=32768)r+=String.fromCharCode.apply(null,t.subarray(n,n+32768));return btoa(r)}function D0(e){(!e||typeof e!="object")&&It("expected an object, got "+String(e));var t=rf(e.still),r=Gp(e.encoded,"still");return{kind:"still",v:nf,still:t,encoded:r}}function af(e){(!e||typeof e!="object")&&It("expected an object, got "+String(e));var t=e.track;(!t||typeof t!="object")&&It("`track` (the sidecar manifest) is REQUIRED \u2014 without it the bytes are an unlabelled movie"),Wp(t.scene,"track.scene","a sequence without a scene id is unmoored exactly as a still without one is");var r=Fo(t.stage),n=hl(t.width,"track.width"),i=hl(t.height,"track.height"),a=hl(t.ticksPerFrame,"track.ticksPerFrame"),s=hl(t.fps,"track.fps"),l=t.frames;(!Array.isArray(l)||l.length===0)&&It("track.frames must be a non-empty array of {i, tick, pose} \u2014 an empty manifest over real bytes is a measurement built on nothing");for(var u=0;u<l.length;u++){var f=l[u];if((!f||typeof f!="object")&&It("track.frames["+u+"] must be an object"),f.i!==u&&It("track.frames["+u+"].i is "+String(f.i)+" \u2014 frame indices must be contiguous from 0, or the map from bytes to state is guesswork"),(typeof f.tick!="number"||!isFinite(f.tick)||f.tick%1!==0)&&It("track.frames["+u+"].tick must be a whole number, got "+String(f.tick)),u>0){var c=f.tick-l[u-1].tick;c!==a&&It("track.frames["+u+"] is "+c+" ticks after its predecessor, but track.ticksPerFrame declares "+a+" \u2014 a manifest whose label disagrees with its data is worse than none, because it is believed")}}var h=Gp(e.encoded,"video");return{kind:"video",v:nf,track:{scene:t.scene,stage:r,width:n,height:i,ticksPerFrame:a,fps:s,firstTick:l[0].tick,lastTick:l[l.length-1].tick,frames:l.map(function(g){return{i:g.i,tick:g.tick,pose:g.pose===void 0?null:g.pose}})},encoded:h,truncated:C0(e.truncated,"truncated")}}var nf,Bp,qp,dl,pl=ce(()=>{ja();nf=1,Bp={still:["mime","bytes","encoder"],video:["mime","bytes","encoder","codec","muxer"]},qp={still:"image/",video:"video/"},dl={"FrqtlVision.toPNG":{kind:"still",mime:"image/png"},"FrqtlVision.toDataURL":{kind:"still",mime:"image/png"},"FrqtlVision.record":{kind:"video",mime:"video/mp4"}};o(It,"_fail");o(C0,"_requireBool");o(hl,"_requirePosInt");o(Wp,"_requireNonEmptyString");o(Gp,"_normalizeEncoded");o(R0,"bytesToBase64");o(D0,"stillEnvelope");o(af,"videoEnvelope")});function j0(e){var t=sr;if(!e||typeof e!="object")throw new Error("[FrqtlCaptureHost] expected a capture-host object, got "+String(e)+". (FAIL-LOUD.)");if(e.kind!==of)throw new Error("[FrqtlCaptureHost] this object is not a "+JSON.stringify(of)+" (its kind is "+JSON.stringify(e.kind)+"). A capture host is a DISTINCT stage-executor kind, not a RendererProvider: a provider returns raw pixels and lets the local dispatcher stamp provenance, which a remote executor cannot honestly do \u2014 it holds no tick, no pose, no filter order. A host returns a bag already normalized by the dispatcher that DOES hold them. (FAIL-LOUD.)");if(!Array.isArray(e.stages)||e.stages.length===0)throw new Error("[FrqtlCaptureHost] `stages` must be a non-empty array of stage names this host executes remotely \u2014 ["+t.RENDER_STAGES.join(", ")+"]. (FAIL-LOUD.)");for(var r=0;r<e.stages.length;r++)t.assertStage(e.stages[r]);["identity","capture","record","dispose"].forEach(function(i){if(typeof e[i]!="function")throw new Error("[FrqtlCaptureHost] a capture host must implement "+i+"() \u2014 the KIND is {kind, stages, identity(), capture(stage), record(opts), dispose()}. (FAIL-LOUD.)")});var n=e.identity();if(!n||typeof n!="object")throw new Error("[FrqtlCaptureHost] identity() must return the page-resolved {build, projection} bag SYNCHRONOUSLY (resolved once during the host's own open()); got "+String(n)+". Without it the node-side scene identity carries nulls where the page carries real values, and every hosted row splits into a second scene. (FAIL-LOUD.)");return e}function N0(e){if(!e||typeof e.attach!="function")throw new TypeError("[FrqtlCaptureHost] registerRecorder(recorder): expected the FrqtlVision face (attach(runner) \u2192 handle). (FAIL-LOUD.)");if(No&&No!==e)throw new Error("[FrqtlCaptureHost] a second recorder registered in this realm \u2014 FrqtlVision loaded under two module URLs (one module, one URL). (FAIL-LOUD.)");No=e}function M0(){if(!No)throw new Error("[FrqtlCaptureHost] no recorder registered in this realm \u2014 import FrqtlVision (import { FrqtlVision } from '@descix/frqtl-web/parts'); the boot imports the parts barrel. (FAIL-LOUD.)");return No}function U0(e,t){sf[e]=t}function z0(e){return sf[e]||null}function V0(e){delete sf[e]}function q0(e){var t=sr;if(!e||typeof e!="object"||!e.bag)throw new Error("[FrqtlCaptureHost.decodeStillEnvelope] expected a capture envelope {bag, encoding, ctor, payload}, got "+String(e)+". (FAIL-LOUD.)");var r;if(e.encoding==="base64"){if(typeof Buffer>"u"||typeof Buffer.from!="function")throw new Error("[FrqtlCaptureHost.decodeStillEnvelope] base64 payloads are decoded with Node's Buffer \u2014 the node half of the boundary runs in Node by definition. (FAIL-LOUD.)");var n=typeof globalThis<"u"?globalThis[e.ctor]:null;if(typeof n!="function"||typeof n.BYTES_PER_ELEMENT!="number")throw new Error("[FrqtlCaptureHost.decodeStillEnvelope] the envelope declares payload type "+JSON.stringify(e.ctor)+", which is not a typed-array constructor here. The payload TYPE is ferried from the page, never mapped from the format \u2014 a local table would be a hand mirror. (FAIL-LOUD.)");r=new n(Buffer.from(e.payload,"base64"))}else if(e.encoding==="plain")r=e.payload;else throw new Error("[FrqtlCaptureHost.decodeStillEnvelope] unknown payload encoding "+JSON.stringify(e.encoding)+" \u2014 the ENCODING SIDE declares it (base64 for a typed buffer, plain for JSON-safe data) and this side obeys. (FAIL-LOUD.)");var i={};for(var a in e.bag)i[a]=e.bag[a];return i.data=r,t.normalizeStill(i)}function B0(e,t){for(var r=sr,n=[],i=0;i<r.SCENE_KEYS.length;i++){var a=r.SCENE_KEYS[i],s=r.canonicalizeScene(Hp(a,e)),l=r.canonicalizeScene(Hp(a,t));s!==l&&n.push(a)}return n}function Hp(e,t){var r={};return r[e]=t?t[e]:void 0,r}function W0(e,t,r){if(!r||typeof r!="object")throw new Error("[FrqtlCaptureHost] the host returned no still for stage "+JSON.stringify(t)+". (FAIL-LOUD \u2014 never a null still.)");if(r.stage!==t)throw new Error("[FrqtlCaptureHost] asked the host for stage "+JSON.stringify(t)+" and it returned stage "+JSON.stringify(r.stage)+". (FAIL-LOUD.)");if(r.scene!==e)throw new Error("[FrqtlCaptureHost] SCENE IDENTITY MISMATCH: the hosted page stamped "+JSON.stringify(r.scene)+" but this process computed "+JSON.stringify(e)+" for the same scene. The two are supposed to be equal BY CONSTRUCTION (host attachment extends the node identity with the page-resolved build/projection), so a mismatch means the page is no longer running the scene this handle was opened for. The still is REFUSED rather than filed against the wrong header. (FAIL-LOUD.)");return r}function G0(e,t){if(!t||typeof t!="object"||t.kind!=="video")throw new Error("[FrqtlCaptureHost] the host returned no video envelope (got "+String(t&&t.kind)+"). (FAIL-LOUD \u2014 never a null recording.)");var r=af({track:t.track,encoded:t.encoded,truncated:t.truncated});if(r.track.scene!==e)throw new Error("[FrqtlCaptureHost] SCENE IDENTITY MISMATCH: the hosted page recorded scene "+JSON.stringify(r.track.scene)+" but this process computed "+JSON.stringify(e)+" for the same scene. The recording is REFUSED rather than filed against the wrong header. (FAIL-LOUD.)");return r}var of,L0,I0,P0,F0,No,sf,Ia,lf=ce(()=>{ja();pl();of="capture-host";o(j0,"assertCaptureHost");L0=o(async function(e){var t=window.FrqtlPage&&window.FrqtlPage.runner;if(!t)throw new Error("[FrqtlCaptureHost/in-page] no FrqtlPage.runner on this page \u2014 the host booted something that is not a running FRQTL stack. (FAIL-LOUD.)");if(!e||!e.modules||typeof e.modules.captureEnvelope!="string")throw new Error("[FrqtlCaptureHost/in-page] no CaptureEnvelope module URL (args.modules.captureEnvelope) \u2014 the ONE transport encoder (lib/shim/render/capture-envelope.js) is imported from the page, never re-encoded by a copy. (FAIL-LOUD.)");var r=await import(e.modules.captureEnvelope),n=await t.capture(e.stage),i=n.data,a={};for(var s in n)s!=="data"&&(a[s]=n[s]);return i&&typeof i.BYTES_PER_ELEMENT=="number"?{bag:a,encoding:"base64",ctor:i.constructor.name,payload:r.bytesToBase64(i)}:{bag:a,encoding:"plain",ctor:null,payload:i}},"IN_PAGE_CAPTURE"),I0=o(async function(e){var t=window.FrqtlPage&&window.FrqtlPage.runner;if(!t)throw new Error("[FrqtlCaptureHost/in-page] no FrqtlPage.runner on this page \u2014 the host booted something that is not a running FRQTL stack. (FAIL-LOUD.)");var r=(await import(e.modules.captureHost)).FrqtlCaptureHost,n=new AbortController,i={};for(var a in e.opts)i[a]=e.opts[a];i.signal=n.signal;var s=r.recorder().attach(t).record(i);return s.then(null,function(){}),r.parkRecording(e.id,{pending:s,controller:n}),e.id},"IN_PAGE_RECORD_BEGIN"),P0=o(async function(e){var t=(await import(e.modules.captureHost)).FrqtlCaptureHost,r=t.parkedRecording(e.id);if(!r)throw new Error("[FrqtlCaptureHost/in-page] no recording parked under id "+e.id+". (FAIL-LOUD.)");var n=o(function(){t.forgetRecording(e.id)},"forget");return r.pending.then(function(i){return n(),i},function(i){throw n(),i})},"IN_PAGE_RECORD_END"),F0=o(async function(e){var t=(await import(e.modules.captureHost)).FrqtlCaptureHost,r=t.parkedRecording(e.id);return r?(r.controller.abort(),!0):!1},"IN_PAGE_RECORD_ABORT"),No=null;o(N0,"registerRecorder");o(M0,"recorder");sf=Object.create(null);o(U0,"parkRecording");o(z0,"parkedRecording");o(V0,"forgetRecording");o(q0,"decodeStillEnvelope");o(B0,"diffSceneRecords");o(Hp,"_one");o(W0,"verifyStill");o(G0,"verifyVideo");Ia={CAPTURE_HOST_KIND:of,assertCaptureHost:j0,IN_PAGE_CAPTURE:L0,IN_PAGE_RECORD_BEGIN:I0,IN_PAGE_RECORD_END:P0,IN_PAGE_RECORD_ABORT:F0,decodeStillEnvelope:q0,diffSceneRecords:B0,verifyStill:W0,verifyVideo:G0,registerRecorder:N0,recorder:M0,parkRecording:U0,parkedRecording:z0,forgetRecording:V0}});function Fa(e){return new URL(e,H0).href}function Y0(e){if(ml.has(e))return ml.get(e);let t=new Promise(function(r,n){let i=document.createElement("script");i.async=!1,i.src=e,i.onload=function(){r()},i.onerror=function(){ml.delete(e),i.parentNode&&i.parentNode.removeChild(i);let a=new Error("[vendor] classic script failed to load: "+e);a.src=e,n(a)},(document.head||document.body).appendChild(i)});return ml.set(e,t),t}function Kp(e,t){if(!Array.isArray(e))return Promise.reject(new TypeError("[vendor] loadClassicScripts(urls): urls must be an array of URLs (got "+typeof e+")"));let r=t&&t.onLoaded;if(r!==void 0&&typeof r!="function")return Promise.reject(new TypeError("[vendor] loadClassicScripts: opts.onLoaded must be a function when given"));let n=e.map(function(i){return Y0(i).then(function(){r&&r(i)})});return Promise.all(n).then(function(){})}function uf(){let e=globalThis.THREE;if(!e)throw new Error("[vendor] three.js is not loaded \u2014 boot the three renderer (bootRealm({ renderer: 'three' })) before constructing a three provider. (FAIL-LOUD.)");return e}function cf(){return Fa("three-loaders")}function Yp(e){let t=!!(e&&e.meshLoaders);if(!Pa){let r=Fa("three.min.js"),n=fetch(r).then(function(i){if(!i.ok)throw new Error("[vendor] three.js failed to load: HTTP "+i.status+" "+r);return i.text()}).then(function(i){return new Function("define","require","module","exports",i+`
|
|
3
|
-
//# sourceURL=`+r)(),uf()});Pa=n,n.catch(function(){Pa===n&&(Pa=null)})}return t?Pa.then(function(r){let n=cf();return Kp([n+"/GLTFLoader.js",n+"/DRACOLoader.js"]).then(function(){if(typeof r.GLTFLoader>"u"||typeof r.DRACOLoader>"u")throw new Error("[vendor] the mesh loaders loaded but THREE.GLTFLoader/DRACOLoader are undefined ("+n+") \u2014 run scripts/vendor-three-loaders.mjs to populate the vendored dir. (FAIL-LOUD.)");return r})}):Pa}function Jp(e){let t=!!(e&&e.p5),r=e&&e.onSetup,n=e&&e.setup;if(n!==void 0&&typeof n!="function")return Promise.reject(new TypeError("[vendor] runSketch: opts.setup must be the page's setup function. (FAIL-LOUD.)"));if(typeof n!="function"&&!t)return Promise.reject(new Error("[vendor] runSketch: the page passes no setup() to run on this renderer. (FAIL-LOUD.)"));let i=o(function(){let a=n.apply(this,arguments);return r&&r(),a},"hooked");return t?(typeof n=="function"&&(globalThis.setup=i),Kp([Fa("p5.min.js")])):(i(),Promise.resolve())}function Qp(){globalThis.draw=function(){}}function Xp(){typeof globalThis.loop=="function"&&globalThis.loop()}var H0,K0,ml,Pa,Na=ce(()=>{Rt();H0=new URL("../assets/vendor/",new URL("frqtl/compat/vendor.js",He()).href),K0=Object.freeze(["setup","draw"]);o(Fa,"vendorUrl");ml=new Map;o(Y0,"_one");o(Kp,"loadClassicScripts");Pa=null;o(uf,"three");o(cf,"meshLoadersBase");o(Yp,"loadThree");o(Jp,"runSketch");o(Qp,"suppressP5Draw");o(Xp,"resumeP5Loop")});function Mo(e){return e&&ff.get(e)||null}function hf(e,t){t?ff.set(e,t):ff.delete(e)}var ff,df=ce(()=>{ff=new WeakMap;o(Mo,"openRecordOf");o(hf,"_setOpenRecord")});var mf={};Oe(mf,{FrqtlVision:()=>Mi});function pf(e){return e.STAGE_FORMATS[e.finalStage()]}function $p(e,t,r){if(!e||typeof e!="object")throw new Error("[FrqtlVision."+r+"] expected a still record, got "+String(e)+".");var n=pf(t);if(e.format!==n)throw new Error("[FrqtlVision."+r+"] this record's format is "+JSON.stringify(e.format)+", not "+JSON.stringify(n)+" \u2014 stage "+JSON.stringify(e.stage)+" carries NUMBERS (read still.data), not an image. Encoding it as a PNG would produce a plausible-looking picture of nothing. (FAIL-LOUD.)")}function em(e){var t=sr;if($p(e,t,"toDataURL"),typeof document>"u")throw new Error("[FrqtlVision.toDataURL] no DOM: a data URL is encoded through a scratch canvas, so this is the BROWSER encoder. In node call FrqtlVision.toPNG(still) for PNG bytes (or eyes.saveStill(still, path) to write them straight to a file) \u2014 same picture, same record, the encoder for THIS host. (FAIL-LOUD.)");var r=document.createElement("canvas");r.width=e.width,r.height=e.height;var n=r.getContext("2d");if(!n||typeof n.putImageData!="function")throw new Error("[FrqtlVision.toDataURL] the scratch canvas has no 2D context. (FAIL-LOUD.)");var i=n.createImageData(e.width,e.height);return i.data.set(e.data),n.putImageData(i,0,0),r.toDataURL("image/png")}function tm(e){var t=sr;$p(e,t,"toPNG");var r=typeof process<"u"&&process.getBuiltinModule?process.getBuiltinModule("node:zlib"):null;if(!r||typeof Buffer>"u")throw new Error("[FrqtlVision.toPNG] this is the NODE encoder (zlib + Buffer) and neither is available here. In a browser call FrqtlVision.toDataURL(still) \u2014 same picture, same record, the encoder for THIS host. (FAIL-LOUD.)");for(var n=e.width,i=e.height,a=Buffer.from(e.data.buffer,e.data.byteOffset,e.data.length),s=n*4+1,l=Buffer.alloc(i*s),u=0;u<i;u++)l[u*s]=0,a.copy(l,u*s+1,u*n*4,(u+1)*n*4);function f(g){for(var p,m=4294967295,b=0;b<g.length;b++){p=(m^g[b])&255;for(var y=0;y<8;y++)p=p&1?3988292384^p>>>1:p>>>1;m=m>>>8^p}return(m^4294967295)>>>0}o(f,"crc32");function c(g,p){var m=Buffer.alloc(4);m.writeUInt32BE(p.length);var b=Buffer.concat([Buffer.from(g,"ascii"),p]),y=Buffer.alloc(4);return y.writeUInt32BE(f(b)),Buffer.concat([m,b,y])}o(c,"chunk");var h=Buffer.alloc(13);return h.writeUInt32BE(n,0),h.writeUInt32BE(i,4),h[8]=8,h[9]=6,Buffer.concat([Buffer.from([137,80,78,71,13,10,26,10]),c("IHDR",h),c("IDAT",r.deflateSync(l,{level:9})),c("IEND",Buffer.alloc(0))])}function Pt(e,t){throw new Error("[FrqtlVision."+e+"] "+t+" (FAIL-LOUD.)")}function Ni(e,t,r){return(typeof e!="number"||!isFinite(e)||e<=0||e%1!==0)&&Pt(r,t+" must be a positive whole number, got "+String(e)),e}function gl(e,t,r,n){for(var i=Object.keys(e),a=0;a<i.length;a++)t.indexOf(i[a])===-1&&Pt(n,r+" has no option "+JSON.stringify(i[a])+" \u2014 declared: "+t.join(", "))}function rm(e,t,r){var n=r.who;typeof e.addTickListener!="function"&&Pt(n,"needs the runner's per-tick listener fan-out (runner.addTickListener) \u2014 the cadence is counted in TICKS, and nothing else can count them. A node-side capture instrument has no clock of its own: record inside the page that runs the world (eyes.vision.record from @descix/frqtl-node/eyes)");var i=t.STAGE_FORMATS[r.stage]===pf(t);i&&(typeof e.suspendTicks!="function"||typeof e.resumeTicks!="function"||typeof e.repaint!="function")&&Pt(n,"a "+JSON.stringify(r.stage)+" sample needs the capture hold (runner.suspendTicks/repaint/resumeTicks): a capture from the tick listener must see its tick COMPOSITED before the readback, and on a batching or fps-capped loop only a held clock plus a forced draw guarantees that");var a=0,s=0,l=null,u=!1,f=null;function c(g){if(l===null)return l={scene:g.scene,width:g.width,height:g.height},g;if(g.scene!==l.scene)throw new Error("[FrqtlVision."+n+"] the scene changed mid-sequence ("+JSON.stringify(l.scene)+" \u2192 "+JSON.stringify(g.scene)+" at tick "+g.tick+"): a sequence spans exactly ONE scene record. Start a new one. (FAIL-LOUD.)");if(g.width!==l.width||g.height!==l.height)throw new Error("[FrqtlVision."+n+"] the "+g.stage+" size changed mid-sequence ("+l.width+"x"+l.height+" \u2192 "+g.width+"x"+g.height+" at tick "+g.tick+"): a sequence has constant dimensions (an encoder cannot hold a resize). Start a new one. (FAIL-LOUD.)");return g}o(c,"continuity");function h(){if(!u&&(a+=1,(a-1)%r.everyTicks===0&&r.admit(s))){var g=s;s+=1;var p;if(i){e.suspendTicks();try{e.repaint()}catch(y){p=Promise.reject(y)}}if(!p)try{p=Promise.resolve(e.capture(r.stage))}catch(y){p=Promise.reject(y)}var m=Promise.resolve(r.onStill(p.then(c),g));if(i){var b=o(function(){e.resumeTicks()},"release");m.then(b,b)}}}return o(h,"onTick"),f=e.addTickListener(h),{stop:o(function(){u||(u=!0,f&&(f(),f=null))},"stop")}}function J0(e,t,r){var n="getStream";(!r||typeof r!="object")&&Pt(n,"expected {stage?, everyTicks}, got "+String(r)),gl(r,["stage","everyTicks"],"getStream",n);var i=Ni(r.everyTicks,"everyTicks",n),a=r.stage===void 0?t.finalStage():t.assertStage(r.stage),s={};return s[Symbol.asyncIterator]=function(){var l=[],u=null,f=!1,c=rm(e,t,{who:n,stage:a,everyTicks:i,admit:o(function(){return!f},"admit"),onStill:o(function(g){if(g.then(null,function(){}),l.push(g),u){var p=u;u=null,p()}return g},"onStill")});function h(){f=!0,c.stop(),l.length=0}return o(h,"end"),{next:o(function(){if(l.length)return l.shift().then(function(p){return{value:p,done:!1}},function(p){throw h(),p});if(f)return Promise.resolve({value:void 0,done:!0});var g=this;return new Promise(function(p){u=p}).then(function(){return g.next()})},"next"),return:o(function(){if(h(),u){var g=u;u=null,g()}return Promise.resolve({value:void 0,done:!0})},"return")}},s}function Z0(e,t){var r="record";(!t||typeof t!="object")&&Pt(r,"expected {everyTicks, stopAt, maxFrames, fps, stage?, bitrate?, keyFrameInterval?, signal?}, got "+String(t)),gl(t,Q0,"record",r);var n={everyTicks:Ni(t.everyTicks,"everyTicks (the capture cadence in TICKS \u2014 there is no wall-clock cadence)",r),maxFrames:Ni(t.maxFrames,"maxFrames (the memory bound; hitting it reports truncated:true)",r),fps:Ni(t.fps,"fps (the PLAYBACK rate \u2014 it has no physical meaning)",r),stage:t.stage===void 0?e.finalStage():e.assertStage(t.stage),bitrate:t.bitrate===void 0?null:Ni(t.bitrate,"bitrate (bits per second)",r),keyFrameInterval:t.keyFrameInterval===void 0?1:Ni(t.keyFrameInterval,"keyFrameInterval (frames)",r),stopAt:null,signal:null};if(t.signal!==void 0){var i=t.signal;(!i||typeof i.aborted!="boolean"||typeof i.addEventListener!="function")&&Pt(r,"signal must be an AbortSignal (new AbortController().signal) \u2014 it is how a recording stops before its stopAt; got "+String(i)),n.signal=i}e.STAGE_FORMATS[n.stage]!==pf(e)&&Pt(r,"stage "+JSON.stringify(n.stage)+" carries NUMBERS (format "+JSON.stringify(e.STAGE_FORMATS[n.stage])+"), not an image \u2014 a video of it would be a plausible-looking movie of nothing. Read the numbers with getStream({stage: "+JSON.stringify(n.stage)+", everyTicks})");var a=t.stopAt;(!a||typeof a!="object")&&Pt(r,"stopAt is REQUIRED \u2014 exactly one of {tick: T}, {ticks: K}, {path: {waypoints, loop?, waypointTimeoutMs?}}. A recording with no honest stop is stopped by its bound, which is how a cap silently becomes the length of every video");var s=Object.keys(a);return gl(a,Zp,"stopAt",r),s.length!==1&&Pt(r,"stopAt names exactly ONE form, got ["+s.join(", ")+"] \u2014 declared: "+Zp.join(", ")),s[0]==="tick"?((typeof a.tick!="number"||!isFinite(a.tick)||a.tick<0||a.tick%1!==0)&&Pt(r,"stopAt.tick is an absolute tick (a non-negative whole number), got "+String(a.tick)),n.stopAt={tick:a.tick}):s[0]==="ticks"?n.stopAt={ticks:Ni(a.ticks,"stopAt.ticks (ticks after the first capture)",r)}:((!a.path||typeof a.path!="object")&&Pt(r,"stopAt.path must be {waypoints, loop?, waypointTimeoutMs?}"),gl(a.path,X0,"stopAt.path",r),n.stopAt={path:a.path}),n}function $0(){return Promise.all([import(Fa("mediabunny.min.mjs")),fetch(Fa("mediabunny.PINNED.json")).then(function(e){return e.ok||Pt("record","the encoder pin mediabunny.PINNED.json did not load (HTTP "+e.status+")"),e.json()})]).then(function(e){var t=e[1];return(!t||typeof t.version!="string"||!t.version)&&Pt("record","mediabunny.PINNED.json carries no version \u2014 the muxer label is ferried from the pin, never typed here"),{MB:e[0],pin:t}})}function ew(e,t,r){var n=Z0(t,r),i=La,a=typeof e.captureHost=="function"?e.captureHost():null;if(a){var s=Promise.resolve(a.record(r));return Promise.all([e.sceneRecord(),s]).then(function(q){return Ia.verifyVideo(q[0].scene,q[1])})}typeof document>"u"&&Pt("record","no DOM and no capture host: video is encoded with WebCodecs where the picture is, i.e. in a page. From node use the hosted eyes \u2014 openHostedEyes from @descix/frqtl-node/eyes, then eyes.vision.record(opts), which runs this SAME record inside the hosted page"),typeof VideoEncoder>"u"&&Pt("record","this page has no WebCodecs VideoEncoder (it needs a secure context: https or localhost). The encoder is not optional \u2014 there is no second path");var l=Mo(e),u=l?l._clipFor(n):null,f=null;if(n.stopAt.path)try{f=ya.attach(e,{waypoints:n.stopAt.path.waypoints,loop:!!n.stopAt.path.loop,waypointTimeoutMs:n.stopAt.path.waypointTimeoutMs})}catch(q){throw u&&u.drop(),q}var c=[],h=[],g=!1,p=!1,m=null,b=n.stopAt.tick!==void 0?n.stopAt.tick:null,y=null,w=null,O=null,S=null,A=$0().then(function(q){var T=q.MB,J=new T.BufferTarget,D=new T.Output({format:new T.Mp4OutputFormat({fastStart:"in-memory"}),target:J}),K=new T.VideoSampleSource({codec:"avc",bitrate:n.bitrate===null?T.QUALITY_HIGH:n.bitrate,keyFrameInterval:n.keyFrameInterval});return D.addVideoTrack(K,{frameRate:n.fps}),D.start().then(function(){return{MB:T,pin:q.pin,target:J,output:D,source:K}})}),C=A,R,Q=new Promise(function(q,T){R={resolve:q,reject:T}});function Y(q){q&&!m&&(m=q),!p&&(p=!0,y&&y.stop(),f&&(f.dispose(),f=null),w&&(n.signal.removeEventListener("abort",w),w=null),Promise.all(h).then(function(){if(m)throw m;return c.length||Pt("record","the recording stopped before a single still was captured \u2014 nothing to encode. Is the runner advancing ticks?"),u&&u.check(c.length),C}).then(function(T){return T.output.finalize().then(function(){return T.output.getMimeType()}).then(function(J){var D=String(J).split(";"),K=D[0].trim(),N=/codecs="([^"]+)"/.exec(J);return N||Pt("record","the muxer reported no codec string ("+JSON.stringify(J)+") \u2014 encoded.codec REPORTS what was produced and is never assumed"),i.videoEnvelope({track:{scene:S,stage:n.stage,width:O.width,height:O.height,ticksPerFrame:n.everyTicks,fps:n.fps,frames:c},encoded:{mime:K,bytes:i.bytesToBase64(new Uint8Array(T.target.buffer)),encoder:"FrqtlVision.record",codec:N[1],muxer:"mediabunny@"+T.pin.version},truncated:g})})}).then(function(T){u&&u.end(T),R.resolve(T)},function(T){u&&u.drop(),A.then(function(J){return J.output.cancel()}).then(null,function(){}),R.reject(T)}))}if(o(Y,"close"),A.then(null,function(q){Y(q)}),y=rm(e,t,{who:"record",stage:n.stage,everyTicks:n.everyTicks,admit:o(function(q){return p?!1:q>=n.maxFrames?(g=!0,Y(null),!1):!0},"admit"),onStill:o(function(q,T){u&&u.sample(T);var J=q.then(function(D){T===0&&(S=D.scene,O={width:D.width,height:D.height},n.stopAt.ticks!==void 0&&(b=D.tick+n.stopAt.ticks),b!==null&&D.tick>b&&Pt("record","stopAt.tick "+b+" is already in the past \u2014 the first capture is tick "+D.tick)),c[T]={i:T,tick:D.tick,pose:D.pose},C=C.then(function(K){var N=new K.MB.VideoSample(D.data,{format:"RGBA",codedWidth:D.width,codedHeight:D.height,timestamp:T/n.fps,duration:1/n.fps});return Promise.resolve(K.source.add(N)).then(function(){return N.close(),K},function(B){throw N.close(),B})}),C.then(null,function(K){Y(K)}),b!==null&&D.tick+n.everyTicks>b&&Y(null)},function(D){Y(D)});return h.push(J),J},"onStill")}),n.signal){if(w=o(function(){g=!0,Y(null)},"onAbort"),n.signal.aborted)return w(),Q;n.signal.addEventListener("abort",w,{once:!0})}try{if(f){var H=f.waypoints.length-1;f.onWaypoint(function(q){q.index===H&&Y(null)}),f.start()}}catch(q){Y(q)}return Q}function tw(e){if(!e||typeof e.capture!="function"||typeof e.captureStill!="function"||typeof e.sceneRecord!="function")throw new Error("[FrqtlVision.attach] needs an FrqtlApp exposing capture(stage), captureStill() and sceneRecord() (the RENDER_STAGES tap contract). (FAIL-LOUD.)");var t=sr;return{stages:t.RENDER_STAGES.slice(),finalStage:t.finalStage,getScene:o(function(){return e.sceneRecord()},"getScene"),getStill:o(function(r){return r===void 0?e.captureStill():e.capture(r)},"getStill"),getStream:o(function(r){return J0(e,t,r)},"getStream"),record:o(function(r){try{return ew(e,t,r)}catch(n){return Promise.reject(n)}},"record"),toDataURL:em,toPNG:tm}}var Q0,Zp,X0,Mi,vl=ce(()=>{ja();pl();Us();lf();Na();df();o(pf,"_rgba8Format");o($p,"_assertImageable");o(em,"toDataURL");o(tm,"toPNG");o(Pt,"_fail");o(Ni,"_requirePosInt");o(gl,"_assertKnownKeys");o(rm,"_sample");o(J0,"_getStream");Q0=["everyTicks","stopAt","maxFrames","fps","stage","bitrate","keyFrameInterval","signal"],Zp=["tick","ticks","path"],X0=["waypoints","loop","waypointTimeoutMs"];o(Z0,"_normalizeRecord");o($0,"_loadEncoder");o(ew,"_record");o(tw,"attach");Mi={attach:tw,toDataURL:em,toPNG:tm};Ia.registerRecorder(Mi)});var gf={};Oe(gf,{HEAT_STOPS:()=>Uo,heatColor:()=>rw,heatRgb:()=>nm});function nm(e){var t=Number(e);isFinite(t)||(t=0);var r=t<0?0:t>1?1:t,n=r*(Uo.length-1),i=Math.min(Uo.length-2,Math.floor(n)),a=n-i,s=Uo[i],l=Uo[i+1];return[Math.round(s[0]+(l[0]-s[0])*a),Math.round(s[1]+(l[1]-s[1])*a),Math.round(s[2]+(l[2]-s[2])*a)]}function rw(e){var t=nm(e);return"rgb("+t[0]+","+t[1]+","+t[2]+")"}var Uo,im=ce(()=>{Uo=Object.freeze([Object.freeze([12,24,70]),Object.freeze([20,130,190]),Object.freeze([40,190,120]),Object.freeze([235,210,60]),Object.freeze([235,70,45])]);o(nm,"heatRgb");o(rw,"heatColor")});var bf={};Oe(bf,{GraphingDetectorWall:()=>Ft});function yf(e,t){var r,n,i=0,a=0;Array.isArray(e)?e.length>=6?(r=e[1],i=e[2],n=e[4],a=e[5]):(r=e[1],n=e[3]):e&&(r=e.top,n=e.h,typeof e.z=="number"&&(i=e.z),typeof e.d=="number"&&(a=e.d)),r=Number(r)||0,n=Math.max(1,Number(n)||1),a=Math.max(0,Number(a)||0);var s=typeof t=="number"&&t>0?t:12,l=Math.min(1,nw/Math.max(n,a||1));return{top:r,height:n,z0:i,depth:a,binPx:s,canvasW:a>0?Math.max(1,Math.round(a*l)):iw,canvasH:Math.max(1,Math.round(n*l))}}function yl(e,t,r){return t+Math.floor((Number(e)-t)/r)*r}function om(e,t,r){var n=e.binPx,i=e.canvasH/e.height,a=yl(t,e.top,n),s={x:0,y:(a-e.top)*i,w:e.canvasW,h:n*i};if(e.depth>0){var l=e.canvasW/e.depth,u=yl(r,e.z0,n);s.x=(u-e.z0)*l,s.w=n*l}return s}function sm(e,t){var r=[],n=0;if(!e||typeof e.forEach!="function")return{cells:r,maxV:n};var i=t.binPx,a=new Map;return e.forEach(function(s,l){if(!(!s||typeof s.forEach!="function")){var u=yl(l,t.top,i);s.forEach(function(f,c){var h=t.depth>0?yl(c,t.z0,i):t.z0,g=u+","+h;a.set(g,(a.get(g)||0)+(Number(f)||0))})}}),a.forEach(function(s,l){var u=l.split(",");s>n&&(n=s),r.push({y:Number(u[0]),z:Number(u[1]),v:s})}),{cells:r,maxV:n}}function lm(e,t,r,n){n=n||{};var i=gf,a=i.heatColor,s=i.heatRgb(0),l=typeof n.heatBase=="number"?n.heatBase:.35;e.clearRect(0,0,t.canvasW,t.canvasH),e.fillStyle="rgba("+s[0]+","+s[1]+","+s[2]+","+l+")",e.fillRect(0,0,t.canvasW,t.canvasH);for(var u=sm(r,t),f=0;f<u.cells.length;f++){var c=u.cells[f],h=om(t,c.y,c.z);e.fillStyle=a(u.maxV>0?c.v/u.maxV:0),e.fillRect(h.x,h.y,h.w,h.h)}return u.cells.length}function vf(e,t){return typeof e=="number"&&isFinite(e)?e:t}function Ft(e,t){if(t=t||{},t.preset===void 0&&t.collisionBehavior===void 0){var r={};Object.keys(t).forEach(function(a){r[a]=t[a]}),r.preset="detector-screen",t=r}we.call(this,e,t),this._schemaKind="GraphingDetectorWall",this.binPx=vf(t.binPx,12),this.refreshMs=vf(t.refreshMs,100),this.heatBase=vf(t.heatBase,.35);var n=Array.isArray(this.hooks)&&this.hooks.indexOf("count")!==-1;if(!n)throw new Error('[GraphingDetectorWall] this wall does not COUNT (collisionBehavior "'+this.collisionBehavior+'", hooks '+JSON.stringify(this.hooks||[])+') \u2014 a graphing detector needs the count hook (the "detector-screen" preset supplies it), or it would paint an eternally empty grid. (FAIL-LOUD.)');this._faceSpec=yf(this._trueRect,this.binPx),this._canvas=this._makeCanvas(t.makeCanvas),this.lo.liveCanvas=this._canvas,this._lastPaintMs=0,this._paintedBins=0,this._drainedTickData=void 0;var i=this;this._paintTickFn=o(function(s){i._tick(s)},"graphingDetectorWallTick"),e&&Array.isArray(e.experimentTickFunctions)&&e.experimentTickFunctions.push(this._paintTickFn)}var nw,iw,am,aw,wf=ce(()=>{Rt();yn();im();Et();nw=512,iw=64;o(yf,"faceSpec");o(yl,"binStart");o(om,"heatCellRect");o(sm,"binGrid");o(lm,"paintHeatmap");o(vf,"_num");o(Ft,"GraphingDetectorWall");Ft.prototype=Object.create(we?we.prototype:Object.prototype);Ft.prototype.constructor=Ft;Ft.prototype._makeCanvas=function(e){var t=this._faceSpec;if(typeof e=="function")return e(t.canvasW,t.canvasH);if(typeof document<"u"&&document.createElement){var r=document.createElement("canvas");return r.width=t.canvasW,r.height=t.canvasH,r}return null};Ft.prototype.setRect=function(e){we.prototype.setRect.call(this,e),this._faceSpec=yf(this._trueRect,this.binPx);var t=this._canvas;return t&&(t.width!==this._faceSpec.canvasW||t.height!==this._faceSpec.canvasH)&&(t.width=this._faceSpec.canvasW,t.height=this._faceSpec.canvasH),this.repaintHeatmap(),this};Ft.prototype.heatCanvas=function(){return this._canvas};Ft.prototype.paintedBins=function(){return this._paintedBins};Ft.prototype._tick=function(e){var t=e&&e.objects?e:this.universe&&this.universe._lastTickData?this.universe._lastTickData:null;t&&t!==this._drainedTickData&&(this._drainedTickData=t,this.getCollisionHistogram(t));var r=typeof Date<"u"?Date.now():0;this.refreshMs>0&&r-this._lastPaintMs<this.refreshMs||(this._lastPaintMs=r,this.repaintHeatmap())};Ft.prototype.repaintHeatmap=function(){if(!this._canvas||typeof this._canvas.getContext!="function")return 0;var e=this._canvas.getContext("2d");if(!e)return 0;var t=this.getCollisionHistogram();return this._paintedBins=lm(e,this._faceSpec,t&&t.grid,{heatBase:this.heatBase}),this._paintedBins};Ft.prototype.dispose=function(){if(this._paintTickFn&&this.universe&&Array.isArray(this.universe.experimentTickFunctions)){var e=this.universe.experimentTickFunctions.indexOf(this._paintTickFn);e!==-1&&this.universe.experimentTickFunctions.splice(e,1),this._paintTickFn=null}we&&we.prototype.dispose&&we.prototype.dispose.call(this)};Ft.faceSpec=yf;Ft.heatCellRect=om;Ft.binGrid=sm;Ft.paintHeatmap=lm;am=Xt(we).descriptor,aw={description:"A counting detector screen that draws its OWN hit heatmap on its faces: collisions are binned over the wall face (y\xD7z) and painted as colour cells exactly where they landed \u2014 the wall is the axis, so there are no chart axes, labels or margins in the scene. Extends Wall (defaults to the detector-screen preset: destroy + count); zero physics of its own.",ux:am.ux,fields:am.fields.concat([{name:"binPx",type:"number",constraint:{min:1,integer:!0},engineVisible:!1,unit:"px",widgetHint:"slider",description:"Face bin size in physics pixels (default 12) \u2014 the heatmap cell pitch. Smaller resolves finer structure but each cell holds fewer hits (noisier); larger smooths. The SAME binning the DOM topology chart applies to the same grid."},{name:"refreshMs",type:"number",constraint:{min:0,integer:!0},engineVisible:!1,unit:"ms",description:"Heatmap repaint throttle in milliseconds (default 100). Hit accumulation is per-tick and never throttled \u2014 only the repaint is gated, so no counts are lost."},{name:"heatBase",type:"number",constraint:{min:0,max:1},engineVisible:!1,widgetHint:"slider",description:"Opacity (0..1, default 0.35) of the heat ramp's ZERO colour washed UNDER the cells, so an un-hit face still reads as a solid plate and intensity rises monotonically from empty through every bin. Render-only."}])};at(Ft,{from:new URL("frqtl/parts/GraphingDetectorWall.js",He()).href,descriptor:aw,defaults:{w:20,h:200,binPx:12,refreshMs:100,heatBase:.35,color:[120,200,120]},palette:{displayName:"Graphing Detector Wall",category:"measurement",iconHint:"detector",rank:3},build:o(function(e,t,r){var n=r,i={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(i[a]=e[a]);if(i.rect==null&&i.left==null){var s=i.w!=null?i.w:20,l=i.h!=null?i.h:200;i.left=Math.round(t.x-s/2),i.top=Math.round(t.y-l/2),i.w=s,i.h=l}var u=new n(t.runner.universe,i);return u._schemaKind=r.name,u},"build")})});var _f,Vn,um=ce(()=>{_f={exports:{}};(function(e,t,r){(function(n,i){typeof t=="object"&&typeof e<"u"?e.exports=i():typeof r=="function"&&r.amd?r(i):n.chroma=i()})(this,function(){"use strict";for(var n=function(d,v,_){return v===void 0&&(v=0),_===void 0&&(_=1),d<v?v:_<d?_:d},i={},a=0,s=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];a<s.length;a+=1){var l=s[a];i["[object "+l+"]"]=l.toLowerCase()}var u=o(function(d){return i[Object.prototype.toString.call(d)]||"object"},"Y"),f=Math.PI,c={clip_rgb:o(function(d){d._clipped=!1,d._unclipped=d.slice(0);for(var v=0;v<=3;v++)v<3?((d[v]<0||255<d[v])&&(d._clipped=!0),d[v]=n(d[v],0,255)):v===3&&(d[v]=n(d[v],0,1));return d},"clip_rgb"),limit:n,type:u,unpack:o(function(d,v){return v===void 0&&(v=null),3<=d.length?Array.prototype.slice.call(d):u(d[0])=="object"&&v?v.split("").filter(function(_){return d[0][_]!==void 0}).map(function(_){return d[0][_]}):d[0]},"unpack"),last:o(function(d){if(d.length<2)return null;var v=d.length-1;return u(d[v])=="string"?d[v].toLowerCase():null},"last"),PI:f,TWOPI:2*f,PITHIRD:f/3,DEG2RAD:f/180,RAD2DEG:180/f},h={format:{},autodetect:[]},g=c.last,p=c.clip_rgb,m=c.type,b=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];if(m(d[0])==="object"&&d[0].constructor&&d[0].constructor===this.constructor)return d[0];var _=g(d),k=!1;if(!_){k=!0,h.sorted||(h.autodetect=h.autodetect.sort(function(V,Z){return Z.p-V.p}),h.sorted=!0);for(var I=0,F=h.autodetect;I<F.length;I+=1){var j=F[I];if(_=j.test.apply(j,d))break}}if(!h.format[_])throw new Error("unknown format: "+d);var M=h.format[_].apply(null,k?d:d.slice(0,-1));this._rgb=p(M),this._rgb.length===3&&this._rgb.push(1)},"u");b.prototype.toString=function(){return m(this.hex)=="function"?this.hex():"["+this._rgb.join(",")+"]"};var y=b,w=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];return new(Function.prototype.bind.apply(w.Color,[null].concat(d)))},"h");w.Color=y,w.version="2.1.0";var O=w,S=c.unpack,A=Math.max,C=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _=S(d,"rgb"),k=_[0],I=_[1],F=_[2],j=1-A(k/=255,A(I/=255,F/=255)),M=j<1?1/(1-j):0;return[(1-k-j)*M,(1-I-j)*M,(1-F-j)*M,j]},"p"),R=c.unpack,Q=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _=(d=R(d,"cmyk"))[0],k=d[1],I=d[2],F=d[3],j=4<d.length?d[4]:1;return F===1?[0,0,0,j]:[1<=_?0:255*(1-_)*(1-F),1<=k?0:255*(1-k)*(1-F),1<=I?0:255*(1-I)*(1-F),j]},"v"),Y=c.unpack,H=c.type;y.prototype.cmyk=function(){return C(this._rgb)},O.cmyk=function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(d,["cmyk"])))},h.format.cmyk=Q,h.autodetect.push({p:2,test:o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];if(d=Y(d,"cmyk"),H(d)==="array"&&d.length===4)return"cmyk"},"test")});var q=c.unpack,T=c.last,J=o(function(d){return Math.round(100*d)/100},"M"),D=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _=q(d,"hsla"),k=T(d)||"lsa";return _[0]=J(_[0]||0),_[1]=J(100*_[1])+"%",_[2]=J(100*_[2])+"%",k==="hsla"||3<_.length&&_[3]<1?(_[3]=3<_.length?_[3]:1,k="hsla"):_.length=3,k+"("+_.join(",")+")"},"N"),K=c.unpack,N=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _=(d=K(d,"rgba"))[0],k=d[1],I=d[2];_/=255,k/=255,I/=255;var F,j,M=Math.min(_,k,I),V=Math.max(_,k,I),Z=(V+M)/2;return V===M?(F=0,j=Number.NaN):F=Z<.5?(V-M)/(V+M):(V-M)/(2-V-M),_==V?j=(k-I)/(V-M):k==V?j=2+(I-_)/(V-M):I==V&&(j=4+(_-k)/(V-M)),(j*=60)<0&&(j+=360),3<d.length&&d[3]!==void 0?[j,F,Z,d[3]]:[j,F,Z]},"E"),B=c.unpack,ne=c.last,oe=Math.round,$=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _=B(d,"rgba"),k=ne(d)||"rgb";return k.substr(0,3)=="hsl"?D(N(_),k):(_[0]=oe(_[0]),_[1]=oe(_[1]),_[2]=oe(_[2]),(k==="rgba"||3<_.length&&_[3]<1)&&(_[3]=3<_.length?_[3]:1,k="rgba"),k+"("+_.slice(0,k==="rgb"?3:4).join(",")+")")},"j"),de=c.unpack,ve=Math.round,ue=o(function(){for(var d,v=[],_=arguments.length;_--;)v[_]=arguments[_];var k,I,F,j=(v=de(v,"hsl"))[0],M=v[1],V=v[2];if(M===0)k=I=F=255*V;else{var Z=[0,0,0],le=[0,0,0],ae=V<.5?V*(1+M):V+M-V*M,be=2*V-ae,he=j/360;Z[0]=he+1/3,Z[1]=he,Z[2]=he-1/3;for(var Te=0;Te<3;Te++)Z[Te]<0&&(Z[Te]+=1),1<Z[Te]&&(Z[Te]-=1),6*Z[Te]<1?le[Te]=be+6*(ae-be)*Z[Te]:2*Z[Te]<1?le[Te]=ae:3*Z[Te]<2?le[Te]=be+(ae-be)*(2/3-Z[Te])*6:le[Te]=be;k=(d=[ve(255*le[0]),ve(255*le[1]),ve(255*le[2])])[0],I=d[1],F=d[2]}return 3<v.length?[k,I,F,v[3]]:[k,I,F,1]},"L"),L=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,ee=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,X=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,te=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,ye=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,xe=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,Ue=Math.round,Ce=o(function(d){var v;if(d=d.toLowerCase().trim(),h.format.named)try{return h.format.named(d)}catch{}if(v=d.match(L)){for(var _=v.slice(1,4),k=0;k<3;k++)_[k]=+_[k];return _[3]=1,_}if(v=d.match(ee)){for(var I=v.slice(1,5),F=0;F<4;F++)I[F]=+I[F];return I}if(v=d.match(X)){for(var j=v.slice(1,4),M=0;M<3;M++)j[M]=Ue(2.55*j[M]);return j[3]=1,j}if(v=d.match(te)){for(var V=v.slice(1,5),Z=0;Z<3;Z++)V[Z]=Ue(2.55*V[Z]);return V[3]=+V[3],V}if(v=d.match(ye)){var le=v.slice(1,4);le[1]*=.01,le[2]*=.01;var ae=ue(le);return ae[3]=1,ae}if(v=d.match(xe)){var be=v.slice(1,4);be[1]*=.01,be[2]*=.01;var he=ue(be);return he[3]=+v[4],he}},"z");Ce.test=function(d){return L.test(d)||ee.test(d)||X.test(d)||te.test(d)||ye.test(d)||xe.test(d)};var _e=Ce,Ve=c.type;y.prototype.css=function(d){return $(this._rgb,d)},O.css=function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(d,["css"])))},h.format.css=_e,h.autodetect.push({p:5,test:o(function(d){for(var v=[],_=arguments.length-1;0<_--;)v[_]=arguments[_+1];if(!v.length&&Ve(d)==="string"&&_e.test(d))return"css"},"test")});var wt=c.unpack;h.format.gl=function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _=wt(d,"rgba");return _[0]*=255,_[1]*=255,_[2]*=255,_},O.gl=function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(d,["gl"])))},y.prototype.gl=function(){var d=this._rgb;return[d[0]/255,d[1]/255,d[2]/255,d[3]]};var Vt=c.unpack,Gt=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _,k=Vt(d,"rgb"),I=k[0],F=k[1],j=k[2],M=Math.min(I,F,j),V=Math.max(I,F,j),Z=V-M,le=100*Z/255,ae=M/(255-Z)*100;return Z===0?_=Number.NaN:(I===V&&(_=(F-j)/Z),F===V&&(_=2+(j-I)/Z),j===V&&(_=4+(I-F)/Z),(_*=60)<0&&(_+=360)),[_,le,ae]},"X"),se=c.unpack,ge=Math.floor,jt=o(function(){for(var d,v,_,k,I,F,j=[],M=arguments.length;M--;)j[M]=arguments[M];var V,Z,le,ae=(j=se(j,"hcg"))[0],be=j[1],he=j[2];he*=255;var Te=255*be;if(be===0)V=Z=le=he;else{ae===360&&(ae=0),360<ae&&(ae-=360),ae<0&&(ae+=360);var et=ge(ae/=60),Ge=ae-et,ft=he*(1-be),ht=ft+Te*(1-Ge),Ct=ft+Te*Ge,ir=ft+Te;switch(et){case 0:V=(d=[ir,Ct,ft])[0],Z=d[1],le=d[2];break;case 1:V=(v=[ht,ir,ft])[0],Z=v[1],le=v[2];break;case 2:V=(_=[ft,ir,Ct])[0],Z=_[1],le=_[2];break;case 3:V=(k=[ft,ht,ir])[0],Z=k[1],le=k[2];break;case 4:V=(I=[Ct,ft,ir])[0],Z=I[1],le=I[2];break;case 5:V=(F=[ir,ft,ht])[0],Z=F[1],le=F[2]}}return[V,Z,le,3<j.length?j[3]:1]},"K"),ut=c.unpack,Ht=c.type;y.prototype.hcg=function(){return Gt(this._rgb)},O.hcg=function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(d,["hcg"])))},h.format.hcg=jt,h.autodetect.push({p:1,test:o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];if(d=ut(d,"hcg"),Ht(d)==="array"&&d.length===3)return"hcg"},"test")});var _t=c.unpack,ct=c.last,ot=Math.round,Yr=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _=_t(d,"rgba"),k=_[0],I=_[1],F=_[2],j=_[3],M=ct(d)||"auto";j===void 0&&(j=1),M==="auto"&&(M=j<1?"rgba":"rgb");var V="000000"+((k=ot(k))<<16|(I=ot(I))<<8|(F=ot(F))).toString(16);V=V.substr(V.length-6);var Z="0"+ot(255*j).toString(16);switch(Z=Z.substr(Z.length-2),M.toLowerCase()){case"rgba":return"#"+V+Z;case"argb":return"#"+Z+V;default:return"#"+V}},"tr"),Kt=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,cr=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,pi=o(function(d){if(d.match(Kt)){d.length!==4&&d.length!==7||(d=d.substr(1)),d.length===3&&(d=(d=d.split(""))[0]+d[0]+d[1]+d[1]+d[2]+d[2]);var v=parseInt(d,16);return[v>>16,v>>8&255,255&v,1]}if(d.match(cr)){d.length!==5&&d.length!==9||(d=d.substr(1)),d.length===4&&(d=(d=d.split(""))[0]+d[0]+d[1]+d[1]+d[2]+d[2]+d[3]+d[3]);var _=parseInt(d,16);return[_>>24&255,_>>16&255,_>>8&255,Math.round((255&_)/255*100)/100]}throw new Error("unknown hex color: "+d)},"or"),mi=c.type;y.prototype.hex=function(d){return Yr(this._rgb,d)},O.hex=function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(d,["hex"])))},h.format.hex=pi,h.autodetect.push({p:4,test:o(function(d){for(var v=[],_=arguments.length-1;0<_--;)v[_]=arguments[_+1];if(!v.length&&mi(d)==="string"&&0<=[3,4,5,6,7,8,9].indexOf(d.length))return"hex"},"test")});var fr=c.unpack,er=c.TWOPI,no=Math.min,na=Math.sqrt,ia=Math.acos,io=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _,k=fr(d,"rgb"),I=k[0],F=k[1],j=k[2],M=no(I/=255,F/=255,j/=255),V=(I+F+j)/3,Z=0<V?1-M/V:0;return Z===0?_=NaN:(_=(I-F+(I-j))/2,_/=na((I-F)*(I-F)+(I-j)*(F-j)),_=ia(_),F<j&&(_=er-_),_/=er),[360*_,Z,V]},"sr"),cn=c.unpack,kn=c.limit,Ir=c.TWOPI,ao=c.PITHIRD,fn=Math.cos,yu=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _,k,I,F=(d=cn(d,"hsi"))[0],j=d[1],M=d[2];return isNaN(F)&&(F=0),isNaN(j)&&(j=0),360<F&&(F-=360),F<0&&(F+=360),(F/=360)<1/3?k=1-((I=(1-j)/3)+(_=(1+j*fn(Ir*F)/fn(ao-Ir*F))/3)):F<2/3?I=1-((_=(1-j)/3)+(k=(1+j*fn(Ir*(F-=1/3))/fn(ao-Ir*F))/3)):_=1-((k=(1-j)/3)+(I=(1+j*fn(Ir*(F-=2/3))/fn(ao-Ir*F))/3)),[255*(_=kn(M*_*3)),255*(k=kn(M*k*3)),255*(I=kn(M*I*3)),3<d.length?d[3]:1]},"yr"),bu=c.unpack,ms=c.type;y.prototype.hsi=function(){return io(this._rgb)},O.hsi=function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(d,["hsi"])))},h.format.hsi=yu,h.autodetect.push({p:2,test:o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];if(d=bu(d,"hsi"),ms(d)==="array"&&d.length===3)return"hsi"},"test")});var oo=c.unpack,so=c.type;y.prototype.hsl=function(){return N(this._rgb)},O.hsl=function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(d,["hsl"])))},h.format.hsl=ue,h.autodetect.push({p:2,test:o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];if(d=oo(d,"hsl"),so(d)==="array"&&d.length===3)return"hsl"},"test")});var gs=c.unpack,vs=Math.min,wu=Math.max,_u=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _,k,I,F=(d=gs(d,"rgb"))[0],j=d[1],M=d[2],V=vs(F,j,M),Z=wu(F,j,M),le=Z-V;return I=Z/255,Z===0?(_=Number.NaN,k=0):(k=le/Z,F===Z&&(_=(j-M)/le),j===Z&&(_=2+(M-F)/le),M===Z&&(_=4+(F-j)/le),(_*=60)<0&&(_+=360)),[_,k,I]},"Er"),xu=c.unpack,Ou=Math.floor,Eu=o(function(){for(var d,v,_,k,I,F,j=[],M=arguments.length;M--;)j[M]=arguments[M];var V,Z,le,ae=(j=xu(j,"hsv"))[0],be=j[1],he=j[2];if(he*=255,be===0)V=Z=le=he;else{ae===360&&(ae=0),360<ae&&(ae-=360),ae<0&&(ae+=360);var Te=Ou(ae/=60),et=ae-Te,Ge=he*(1-be),ft=he*(1-be*et),ht=he*(1-be*(1-et));switch(Te){case 0:V=(d=[he,ht,Ge])[0],Z=d[1],le=d[2];break;case 1:V=(v=[ft,he,Ge])[0],Z=v[1],le=v[2];break;case 2:V=(_=[Ge,he,ht])[0],Z=_[1],le=_[2];break;case 3:V=(k=[Ge,ft,he])[0],Z=k[1],le=k[2];break;case 4:V=(I=[ht,Ge,he])[0],Z=I[1],le=I[2];break;case 5:V=(F=[he,Ge,ft])[0],Z=F[1],le=F[2]}}return[V,Z,le,3<j.length?j[3]:1]},"Or"),Su=c.unpack,ku=c.type;y.prototype.hsv=function(){return _u(this._rgb)},O.hsv=function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(d,["hsv"])))},h.format.hsv=Eu,h.autodetect.push({p:2,test:o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];if(d=Su(d,"hsv"),ku(d)==="array"&&d.length===3)return"hsv"},"test")});var aa=18,ys=.95047,gi=1,Kn=1.08883,oa=.137931034,bs=.206896552,lo=.12841855,sa=.008856452,Au=c.unpack,ws=Math.pow,uo=o(function(d){return(d/=255)<=.04045?d/12.92:ws((d+.055)/1.055,2.4)},"zr"),la=o(function(d){return sa<d?ws(d,1/3):d/lo+oa},"Tr"),Tu=o(function(d,v,_){return d=uo(d),v=uo(v),_=uo(_),[la((.4124564*d+.3575761*v+.1804375*_)/ys),la((.2126729*d+.7151522*v+.072175*_)/gi),la((.0193339*d+.119192*v+.9503041*_)/Kn)]},"Ur"),E=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _=Au(d,"rgb"),k=_[0],I=_[1],F=_[2],j=Tu(k,I,F),M=j[0],V=j[1],Z=116*V-16;return[Z<0?0:Z,500*(M-V),200*(V-j[2])]},"Vr"),P=c.unpack,z=Math.pow,G=o(function(d){return 255*(d<=.00304?12.92*d:1.055*z(d,1/2.4)-.055)},"Hr"),U=o(function(d){return bs<d?d*d*d:lo*(d-oa)},"Jr"),fe=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _,k,I,F=(d=P(d,"lab"))[0],j=d[1],M=d[2];return k=(F+16)/116,_=isNaN(j)?k:k+j/500,I=isNaN(M)?k:k-M/200,k=gi*U(k),_=ys*U(_),I=Kn*U(I),[G(3.2404542*_-1.5371385*k-.4985314*I),G(-.969266*_+1.8760108*k+.041556*I),G(.0556434*_-.2040259*k+1.0572252*I),3<d.length?d[3]:1]},"Kr"),re=c.unpack,Be=c.type;y.prototype.lab=function(){return E(this._rgb)},O.lab=function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(d,["lab"])))},h.format.lab=fe,h.autodetect.push({p:2,test:o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];if(d=re(d,"lab"),Be(d)==="array"&&d.length===3)return"lab"},"test")});var rt=c.unpack,Ne=c.RAD2DEG,Fe=Math.sqrt,nt=Math.atan2,We=Math.round,Ie=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _=rt(d,"lab"),k=_[0],I=_[1],F=_[2],j=Fe(I*I+F*F),M=(nt(F,I)*Ne+360)%360;return We(1e4*j)===0&&(M=Number.NaN),[k,j,M]},"fe"),kt=c.unpack,Pe=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _=kt(d,"rgb"),k=_[0],I=_[1],F=_[2],j=E(k,I,F),M=j[0],V=j[1],Z=j[2];return Ie(M,V,Z)},"ue"),it=c.unpack,xt=c.DEG2RAD,hr=Math.sin,Yt=Math.cos,Tt=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _=it(d,"lch"),k=_[0],I=_[1],F=_[2];return isNaN(F)&&(F=0),[k,Yt(F*=xt)*I,hr(F)*I]},"de"),hn=c.unpack,Pr=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _=(d=hn(d,"lch"))[0],k=d[1],I=d[2],F=Tt(_,k,I),j=F[0],M=F[1],V=F[2],Z=fe(j,M,V);return[Z[0],Z[1],Z[2],3<d.length?d[3]:1]},"be"),Jr=c.unpack,dr=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _=Jr(d,"hcl").reverse();return Pr.apply(void 0,_)},"ge"),Cr=c.unpack,Fr=c.type;y.prototype.lch=function(){return Pe(this._rgb)},y.prototype.hcl=function(){return Pe(this._rgb).reverse()},O.lch=function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(d,["lch"])))},O.hcl=function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(d,["hcl"])))},h.format.lch=Pr,h.format.hcl=dr,["lch","hcl"].forEach(function(d){return h.autodetect.push({p:2,test:o(function(){for(var v=[],_=arguments.length;_--;)v[_]=arguments[_];if(v=Cr(v,d),Fr(v)==="array"&&v.length===3)return d},"test")})});var gt={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflower:"#6495ed",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},An=c.type;y.prototype.name=function(){for(var d=Yr(this._rgb,"rgb"),v=0,_=Object.keys(gt);v<_.length;v+=1){var k=_[v];if(gt[k]===d)return k.toLowerCase()}return d},h.format.named=function(d){if(d=d.toLowerCase(),gt[d])return pi(gt[d]);throw new Error("unknown color name: "+d)},h.autodetect.push({p:5,test:o(function(d){for(var v=[],_=arguments.length-1;0<_--;)v[_]=arguments[_+1];if(!v.length&&An(d)==="string"&>[d.toLowerCase()])return"named"},"test")});var Nr=c.unpack,vi=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _=Nr(d,"rgb");return(_[0]<<16)+(_[1]<<8)+_[2]},"Me"),Jt=c.type,dn=o(function(d){if(Jt(d)=="number"&&0<=d&&d<=16777215)return[d>>16,d>>8&255,255&d,1];throw new Error("unknown num color: "+d)},"_e"),yi=c.type;y.prototype.num=function(){return vi(this._rgb)},O.num=function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(d,["num"])))},h.format.num=dn,h.autodetect.push({p:5,test:o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];if(d.length===1&&yi(d[0])==="number"&&0<=d[0]&&d[0]<=16777215)return"num"},"test")});var Rr=c.unpack,Tn=c.type,_s=Math.round;y.prototype.rgb=function(d){return d===void 0&&(d=!0),d===!1?this._rgb.slice(0,3):this._rgb.slice(0,3).map(_s)},y.prototype.rgba=function(d){return d===void 0&&(d=!0),this._rgb.slice(0,4).map(function(v,_){return _<3?d===!1?v:_s(v):v})},O.rgb=function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(d,["rgb"])))},h.format.rgb=function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];var _=Rr(d,"rgba");return _[3]===void 0&&(_[3]=1),_},h.autodetect.push({p:3,test:o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];if(d=Rr(d,"rgba"),Tn(d)==="array"&&(d.length===3||d.length===4&&Tn(d[3])=="number"&&0<=d[3]&&d[3]<=1))return"rgb"},"test")});var bi=Math.log,xs=o(function(d){var v,_,k,I=d/100;return k=I<66?(v=255,_=-155.25485562709179-.44596950469579133*(_=I-2)+104.49216199393888*bi(_),I<20?0:.8274096064007395*(k=I-10)-254.76935184120902+115.67994401066147*bi(k)):(v=351.97690566805693+.114206453784165*(v=I-55)-40.25366309332127*bi(v),_=325.4494125711974+.07943456536662342*(_=I-50)-28.0852963507957*bi(_),255),[v,_,k,1]},"Oe"),Os=c.unpack,Cu=Math.round,Es=o(function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];for(var _,k=Os(d,"rgb"),I=k[0],F=k[2],j=1e3,M=4e4;.4<M-j;){var V=xs(_=.5*(M+j));V[2]/V[0]>=F/I?M=_:j=_}return Cu(_)},"qe");y.prototype.temp=y.prototype.kelvin=y.prototype.temperature=function(){return Es(this._rgb)},O.temp=O.kelvin=O.temperature=function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(d,["temp"])))},h.format.temp=h.format.kelvin=h.format.temperature=xs;var Ru=c.type;y.prototype.alpha=function(d,v){return v===void 0&&(v=!1),d!==void 0&&Ru(d)==="number"?v?(this._rgb[3]=d,this):new y([this._rgb[0],this._rgb[1],this._rgb[2],d],"rgb"):this._rgb[3]},y.prototype.clipped=function(){return this._rgb._clipped||!1},y.prototype.darken=function(d){d===void 0&&(d=1);var v=this.lab();return v[0]-=aa*d,new y(v,"lab").alpha(this.alpha(),!0)},y.prototype.brighten=function(d){return d===void 0&&(d=1),this.darken(-d)},y.prototype.darker=y.prototype.darken,y.prototype.brighter=y.prototype.brighten,y.prototype.get=function(d){var v=d.split("."),_=v[0],k=v[1],I=this[_]();if(k){var F=_.indexOf(k);if(-1<F)return I[F];throw new Error("unknown channel "+k+" in mode "+_)}return I};var Du=c.type,Ss=Math.pow;y.prototype.luminance=function(d){if(d===void 0||Du(d)!=="number")return wi.apply(void 0,this._rgb.slice(0,3));if(d===0)return new y([0,0,0,this._rgb[3]],"rgb");if(d===1)return new y([255,255,255,this._rgb[3]],"rgb");var v=this.luminance(),_=20,k=o(function(F,j){var M=F.interpolate(j,.5,"rgb"),V=M.luminance();return Math.abs(d-V)<1e-7||!_--?M:d<V?k(F,M):k(M,j)},"o"),I=(d<v?k(new y([0,0,0]),this):k(this,new y([255,255,255]))).rgb();return new y(I.concat([this._rgb[3]]))};var wi=o(function(d,v,_){return .2126*(d=Cn(d))+.7152*(v=Cn(v))+.0722*(_=Cn(_))},"Be"),Cn=o(function(d){return(d/=255)<=.03928?d/12.92:Ss((d+.055)/1.055,2.4)},"Ce"),Mt={},tr=c.type,Qr=o(function(d,v,_){_===void 0&&(_=.5);for(var k=[],I=arguments.length-3;0<I--;)k[I]=arguments[I+3];var F=k[0]||"lrgb";if(Mt[F]||k.length||(F=Object.keys(Mt)[0]),!Mt[F])throw new Error("interpolation mode "+F+" is not defined");return tr(d)!=="object"&&(d=new y(d)),tr(v)!=="object"&&(v=new y(v)),Mt[F](d,v,_).alpha(d.alpha()+_*(v.alpha()-d.alpha()))},"$e");y.prototype.mix=y.prototype.interpolate=function(d,v){v===void 0&&(v=.5);for(var _=[],k=arguments.length-2;0<k--;)_[k]=arguments[k+2];return Qr.apply(void 0,[this,d,v].concat(_))},y.prototype.premultiply=function(d){d===void 0&&(d=!1);var v=this._rgb,_=v[3];return d?(this._rgb=[v[0]*_,v[1]*_,v[2]*_,_],this):new y([v[0]*_,v[1]*_,v[2]*_,_],"rgb")},y.prototype.saturate=function(d){d===void 0&&(d=1);var v=this.lch();return v[1]+=aa*d,v[1]<0&&(v[1]=0),new y(v,"lch").alpha(this.alpha(),!0)},y.prototype.desaturate=function(d){return d===void 0&&(d=1),this.saturate(-d)};var pn=c.type;y.prototype.set=function(d,v,_){_===void 0&&(_=!1);var k=d.split("."),I=k[0],F=k[1],j=this[I]();if(F){var M=I.indexOf(F);if(-1<M){if(pn(v)=="string")switch(v.charAt(0)){case"+":case"-":j[M]+=+v;break;case"*":j[M]*=+v.substr(1);break;case"/":j[M]/=+v.substr(1);break;default:j[M]=+v}else{if(pn(v)!=="number")throw new Error("unsupported value for Color.set");j[M]=v}var V=new y(j,I);return _?(this._rgb=V._rgb,this):V}throw new Error("unknown channel "+F+" in mode "+I)}return j},Mt.rgb=function(d,v,_){var k=d._rgb,I=v._rgb;return new y(k[0]+_*(I[0]-k[0]),k[1]+_*(I[1]-k[1]),k[2]+_*(I[2]-k[2]),"rgb")};var Xr=Math.sqrt,Dr=Math.pow;Mt.lrgb=function(d,v,_){var k=d._rgb,I=k[0],F=k[1],j=k[2],M=v._rgb,V=M[0],Z=M[1],le=M[2];return new y(Xr(Dr(I,2)*(1-_)+Dr(V,2)*_),Xr(Dr(F,2)*(1-_)+Dr(Z,2)*_),Xr(Dr(j,2)*(1-_)+Dr(le,2)*_),"rgb")},Mt.lab=function(d,v,_){var k=d.lab(),I=v.lab();return new y(k[0]+_*(I[0]-k[0]),k[1]+_*(I[1]-k[1]),k[2]+_*(I[2]-k[2]),"lab")};var Rn=o(function(d,v,_,k){var I,F,j,M,V,Z,le,ae,be,he,Te,et;return k==="hsl"?(j=d.hsl(),M=v.hsl()):k==="hsv"?(j=d.hsv(),M=v.hsv()):k==="hcg"?(j=d.hcg(),M=v.hcg()):k==="hsi"?(j=d.hsi(),M=v.hsi()):k!=="lch"&&k!=="hcl"||(k="hcl",j=d.hcl(),M=v.hcl()),k.substr(0,1)==="h"&&(V=(I=j)[0],le=I[1],be=I[2],Z=(F=M)[0],ae=F[1],he=F[2]),isNaN(V)||isNaN(Z)?isNaN(V)?isNaN(Z)?et=Number.NaN:(et=Z,be!=1&&be!=0||k=="hsv"||(Te=ae)):(et=V,he!=1&&he!=0||k=="hsv"||(Te=le)):et=V+_*(V<Z&&180<Z-V?Z-(V+360):Z<V&&180<V-Z?Z+360-V:Z-V),Te===void 0&&(Te=le+_*(ae-le)),new y([et,Te,be+_*(he-be)],k)},"Ue"),ua=o(function(d,v,_){return Rn(d,v,_,"lch")},"Ve");Mt.lch=ua,Mt.hcl=ua,Mt.num=function(d,v,_){var k=d.num(),I=v.num();return new y(k+_*(I-k),"num")},Mt.hcg=function(d,v,_){return Rn(d,v,_,"hcg")},Mt.hsi=function(d,v,_){return Rn(d,v,_,"hsi")},Mt.hsl=function(d,v,_){return Rn(d,v,_,"hsl")},Mt.hsv=function(d,v,_){return Rn(d,v,_,"hsv")};var ju=c.clip_rgb,Yn=Math.pow,co=Math.sqrt,Jn=Math.PI,_i=Math.cos,xi=Math.sin,ks=Math.atan2,Oi=o(function(d,v){for(var _=d.length,k=[0,0,0,0],I=0;I<d.length;I++){var F=d[I],j=v[I]/_,M=F._rgb;k[0]+=Yn(M[0],2)*j,k[1]+=Yn(M[1],2)*j,k[2]+=Yn(M[2],2)*j,k[3]+=M[3]*j}return k[0]=co(k[0]),k[1]=co(k[1]),k[2]=co(k[2]),.9999999<k[3]&&(k[3]=1),new y(ju(k))},"rn"),Zr=c.type,jr=Math.pow,pr=o(function(d){var v="rgb",_=O("#ccc"),k=0,I=[0,1],F=[],j=[0,0],M=!1,V=[],Z=!1,le=0,ae=1,be=!1,he={},Te=!0,et=1,Ge=o(function(ie){if((ie=ie||["#fff","#000"])&&Zr(ie)==="string"&&O.brewer&&O.brewer[ie.toLowerCase()]&&(ie=O.brewer[ie.toLowerCase()]),Zr(ie)==="array"){ie.length===1&&(ie=[ie[0],ie[0]]),ie=ie.slice(0);for(var je=0;je<ie.length;je++)ie[je]=O(ie[je]);for(var Ye=F.length=0;Ye<ie.length;Ye++)F.push(Ye/(ie.length-1))}return ir(),V=ie},"a"),ft=o(function(ie){return ie},"w"),ht=o(function(ie){return ie},"k"),Ct=o(function(ie,je){var Ye,Je;if(je==null&&(je=!1),isNaN(ie)||ie===null)return _;je?Je=ie:Je=M&&2<M.length?(function(Lt){if(M==null)return 0;for(var pt=M.length-1,Xe=0;Xe<pt&&Lt>=M[Xe];)Xe++;return Xe-1})(ie)/(M.length-2):ae!==le?(ie-le)/(ae-le):1,Je=ht(Je),je||(Je=ft(Je)),et!==1&&(Je=jr(Je,et)),Je=j[0]+Je*(1-j[0]-j[1]),Je=Math.min(1,Math.max(0,Je));var zr=Math.floor(1e4*Je);if(Te&&he[zr])Ye=he[zr];else{if(Zr(V)==="array")for(var dt=0;dt<F.length;dt++){var vt=F[dt];if(Je<=vt){Ye=V[dt];break}if(vt<=Je&&dt===F.length-1){Ye=V[dt];break}if(vt<Je&&Je<F[dt+1]){Je=(Je-vt)/(F[dt+1]-vt),Ye=O.interpolate(V[dt],V[dt+1],Je,v);break}}else Zr(V)==="function"&&(Ye=V(Je));Te&&(he[zr]=Ye)}return Ye},"M"),ir=o(function(){return he={}},"f");Ge(d);var ze=o(function(ie){var je=O(Ct(ie));return Z&&je[Z]?je[Z]():je},"N");return ze.classes=function(ie){if(ie==null)return M;if(Zr(ie)==="array")I=[(M=ie)[0],ie[ie.length-1]];else{var je=O.analyze(I);M=ie===0?[je.min,je.max]:O.limits(je,"e",ie)}return ze},ze.domain=function(ie){if(!arguments.length)return I;le=ie[0],ae=ie[ie.length-1],F=[];var je=V.length;if(ie.length===je&&le!==ae)for(var Ye=0,Je=Array.from(ie);Ye<Je.length;Ye+=1){var zr=Je[Ye];F.push((zr-le)/(ae-le))}else{for(var dt=0;dt<je;dt++)F.push(dt/(je-1));if(2<ie.length){var vt=ie.map(function(pt,Xe){return Xe/(ie.length-1)}),Lt=ie.map(function(pt){return(pt-le)/(ae-le)});Lt.every(function(pt,Xe){return vt[Xe]===pt})||(ht=o(function(pt){if(pt<=0||1<=pt)return pt;for(var Xe=0;pt>=Lt[Xe+1];)Xe++;var gr=(pt-Lt[Xe])/(Lt[Xe+1]-Lt[Xe]);return vt[Xe]+gr*(vt[Xe+1]-vt[Xe])},"k"))}}return I=[le,ae],ze},ze.mode=function(ie){return arguments.length?(v=ie,ir(),ze):v},ze.range=function(ie,je){return Ge(ie),ze},ze.out=function(ie){return Z=ie,ze},ze.spread=function(ie){return arguments.length?(k=ie,ze):k},ze.correctLightness=function(ie){return ie==null&&(ie=!0),be=ie,ir(),ft=be?function(je){for(var Ye=Ct(0,!0).lab()[0],Je=Ct(1,!0).lab()[0],zr=Je<Ye,dt=Ct(je,!0).lab()[0],vt=Ye+(Je-Ye)*je,Lt=dt-vt,pt=0,Xe=1,gr=20;.01<Math.abs(Lt)&&0<gr--;)zr&&(Lt*=-1),je+=Lt<0?.5*(Xe-(pt=je)):.5*(pt-(Xe=je)),dt=Ct(je,!0).lab()[0],Lt=dt-vt;return je}:function(je){return je},ze},ze.padding=function(ie){return ie!=null?(Zr(ie)==="number"&&(ie=[ie,ie]),j=ie,ze):j},ze.colors=function(ie,je){arguments.length<2&&(je="hex");var Ye=[];if(arguments.length===0)Ye=V.slice(0);else if(ie===1)Ye=[ze(.5)];else if(1<ie){var Je=I[0],zr=I[1]-Je;Ye=(function(Xe,gr,pa){for(var Si=[],jn=Xe<gr,ma=pa?jn?gr+1:gr-1:gr,mn=Xe;jn?mn<ma:ma<mn;jn?mn++:mn--)Si.push(mn);return Si})(0,ie,!1).map(function(Xe){return ze(Je+Xe/(ie-1)*zr)})}else{d=[];var dt=[];if(M&&2<M.length)for(var vt=1,Lt=M.length,pt=1<=Lt;pt?vt<Lt:Lt<vt;pt?vt++:vt--)dt.push(.5*(M[vt-1]+M[vt]));else dt=I;Ye=dt.map(function(Xe){return ze(Xe)})}return O[je]&&(Ye=Ye.map(function(Xe){return Xe[je]()})),Ye},ze.cache=function(ie){return ie!=null?(Te=ie,ze):Te},ze.gamma=function(ie){return ie!=null?(et=ie,ze):et},ze.nodata=function(ie){return ie!=null?(_=O(ie),ze):_},ze},"tn"),De=o(function(d){var v,_,k,I,F,j,M;if((d=d.map(function(ae){return new y(ae)})).length===2)v=d.map(function(ae){return ae.lab()}),F=v[0],j=v[1],I=o(function(ae){var be=[0,1,2].map(function(he){return F[he]+ae*(j[he]-F[he])});return new y(be,"lab")},"a");else if(d.length===3)_=d.map(function(ae){return ae.lab()}),F=_[0],j=_[1],M=_[2],I=o(function(ae){var be=[0,1,2].map(function(he){return(1-ae)*(1-ae)*F[he]+2*(1-ae)*ae*j[he]+ae*ae*M[he]});return new y(be,"lab")},"a");else if(d.length===4){var V;k=d.map(function(ae){return ae.lab()}),F=k[0],j=k[1],M=k[2],V=k[3],I=o(function(ae){var be=[0,1,2].map(function(he){return(1-ae)*(1-ae)*(1-ae)*F[he]+3*(1-ae)*(1-ae)*ae*j[he]+3*(1-ae)*ae*ae*M[he]+ae*ae*ae*V[he]});return new y(be,"lab")},"a")}else if(d.length===5){var Z=De(d.slice(0,3)),le=De(d.slice(2,5));I=o(function(ae){return ae<.5?Z(2*ae):le(2*(ae-.5))},"a")}return I},"an"),rr=o(function(d,v,_){if(!rr[_])throw new Error("unknown blend mode "+_);return rr[_](d,v)},"fn"),Mr=o(function(d){return function(v,_){var k=O(_).rgb(),I=O(v).rgb();return O.rgb(d(k,I))}},"on"),Ur=o(function(d){return function(v,_){var k=[];return k[0]=d(v[0],_[0]),k[1]=d(v[1],_[1]),k[2]=d(v[2],_[2]),k}},"un");rr.normal=Mr(Ur(function(d){return d})),rr.multiply=Mr(Ur(function(d,v){return d*v/255})),rr.screen=Mr(Ur(function(d,v){return 255*(1-(1-d/255)*(1-v/255))})),rr.overlay=Mr(Ur(function(d,v){return v<128?2*d*v/255:255*(1-2*(1-d/255)*(1-v/255))})),rr.darken=Mr(Ur(function(d,v){return v<d?v:d})),rr.lighten=Mr(Ur(function(d,v){return v<d?d:v})),rr.dodge=Mr(Ur(function(d,v){return d===255||255<(d=v/255*255/(1-d/255))?255:d})),rr.burn=Mr(Ur(function(d,v){return 255*(1-(1-v/255)/(d/255))}));for(var Ei=rr,Qt=c.type,nr=c.clip_rgb,mr=c.TWOPI,ca=Math.pow,As=Math.sin,Ts=Math.cos,Qn=Math.floor,fo=Math.random,Dn=Math.log,ho=Math.pow,fa=Math.floor,po=Math.abs,Cs=function(d,v){v===void 0&&(v=null);var _={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0};return u(d)==="object"&&(d=Object.values(d)),d.forEach(function(k){v&&u(k)==="object"&&(k=k[v]),k==null||isNaN(k)||(_.values.push(k),_.sum+=k,k<_.min&&(_.min=k),k>_.max&&(_.max=k),_.count+=1)}),_.domain=[_.min,_.max],_.limits=function(k,I){return Rs(_,k,I)},_},Rs=function(d,v,_){v===void 0&&(v="equal"),_===void 0&&(_=7),u(d)=="array"&&(d=Cs(d));var k=d.min,I=d.max,F=d.values.sort(function(Mu,Uu){return Mu-Uu});if(_===1)return[k,I];var j=[];if(v.substr(0,1)==="c"&&(j.push(k),j.push(I)),v.substr(0,1)==="e"){j.push(k);for(var M=1;M<_;M++)j.push(k+M/_*(I-k));j.push(I)}else if(v.substr(0,1)==="l"){if(k<=0)throw new Error("Logarithmic scales are only possible for values > 0");var V=Math.LOG10E*Dn(k),Z=Math.LOG10E*Dn(I);j.push(k);for(var le=1;le<_;le++)j.push(ho(10,V+le/_*(Z-V)));j.push(I)}else if(v.substr(0,1)==="q"){j.push(k);for(var ae=1;ae<_;ae++){var be=(F.length-1)*ae/_,he=fa(be);if(he===be)j.push(F[he]);else{var Te=be-he;j.push(F[he]*(1-Te)+F[he+1]*Te)}}j.push(I)}else if(v.substr(0,1)==="k"){var et,Ge=F.length,ft=new Array(Ge),ht=new Array(_),Ct=!0,ir=0,ze=null;(ze=[]).push(k);for(var ie=1;ie<_;ie++)ze.push(k+ie/_*(I-k));for(ze.push(I);Ct;){for(var je=0;je<_;je++)ht[je]=0;for(var Ye=0;Ye<Ge;Ye++)for(var Je=F[Ye],zr=Number.MAX_VALUE,dt=void 0,vt=0;vt<_;vt++){var Lt=po(ze[vt]-Je);Lt<zr&&(zr=Lt,dt=vt),ht[dt]++,ft[Ye]=dt}for(var pt=new Array(_),Xe=0;Xe<_;Xe++)pt[Xe]=null;for(var gr=0;gr<Ge;gr++)pt[et=ft[gr]]===null?pt[et]=F[gr]:pt[et]+=F[gr];for(var pa=0;pa<_;pa++)pt[pa]*=1/ht[pa];Ct=!1;for(var Si=0;Si<_;Si++)if(pt[Si]!==ze[Si]){Ct=!0;break}ze=pt,200<++ir&&(Ct=!1)}for(var jn={},ma=0;ma<_;ma++)jn[ma]=[];for(var mn=0;mn<Ge;mn++)jn[et=ft[mn]].push(F[mn]);for(var ki=[],go=0;go<_;go++)ki.push(jn[go][0]),ki.push(jn[go][jn[go].length-1]);ki=ki.sort(function(Mu,Uu){return Mu-Uu}),j.push(ki[0]);for(var Fu=1;Fu<ki.length;Fu+=2){var Nu=ki[Fu];isNaN(Nu)||j.indexOf(Nu)!==-1||j.push(Nu)}}return j},Ds={analyze:Cs,limits:Rs},ha=Math.sqrt,Lu=Math.atan2,da=Math.abs,js=Math.cos,mo=Math.PI,Iu={cool:o(function(){return pr([O.hsl(180,1,.9),O.hsl(250,.7,.4)])},"cool"),hot:o(function(){return pr(["#000","#f00","#ff0","#fff"]).mode("rgb")},"hot")},Xn={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},Pu=0,_d=Object.keys(Xn);Pu<_d.length;Pu+=1){var xd=_d[Pu];Xn[xd.toLowerCase()]=Xn[xd]}var ky=Xn;return O.average=function(d,v,_){v===void 0&&(v="lrgb"),_===void 0&&(_=null);var k=d.length;_||(_=Array.from(new Array(k)).map(function(){return 1}));var I=k/_.reduce(function(et,Ge){return et+Ge});if(_.forEach(function(et,Ge){_[Ge]*=I}),d=d.map(function(et){return new y(et)}),v==="lrgb")return Oi(d,_);for(var F=d.shift(),j=F.get(v),M=[],V=0,Z=0,le=0;le<j.length;le++)if(j[le]=(j[le]||0)*_[0],M.push(isNaN(j[le])?0:_[0]),v.charAt(le)==="h"&&!isNaN(j[le])){var ae=j[le]/180*Jn;V+=_i(ae)*_[0],Z+=xi(ae)*_[0]}var be=F.alpha()*_[0];d.forEach(function(et,Ge){var ft=et.get(v);be+=et.alpha()*_[Ge+1];for(var ht=0;ht<j.length;ht++)if(!isNaN(ft[ht]))if(M[ht]+=_[Ge+1],v.charAt(ht)==="h"){var Ct=ft[ht]/180*Jn;V+=_i(Ct)*_[Ge+1],Z+=xi(Ct)*_[Ge+1]}else j[ht]+=ft[ht]*_[Ge+1]});for(var he=0;he<j.length;he++)if(v.charAt(he)==="h"){for(var Te=ks(Z/M[he],V/M[he])/Jn*180;Te<0;)Te+=360;for(;360<=Te;)Te-=360;j[he]=Te}else j[he]=j[he]/M[he];return be/=k,new y(j,v).alpha(.99999<be?1:be,!0)},O.bezier=function(d){var v=De(d);return v.scale=function(){return pr(v)},v},O.blend=Ei,O.cubehelix=function(d,v,_,k,I){d===void 0&&(d=300),v===void 0&&(v=-1.5),_===void 0&&(_=1),k===void 0&&(k=1),I===void 0&&(I=[0,1]);var F,j=0;Qt(I)==="array"?F=I[1]-I[0]:(F=0,I=[I,I]);var M=o(function(V){var Z=mr*((d+120)/360+v*V),le=ca(I[0]+F*V,k),ae=(j!==0?_[0]+V*j:_)*le*(1-le)/2,be=Ts(Z),he=As(Z);return O(nr([255*(le+ae*(-.14861*be+1.78277*he)),255*(le+ae*(-.29227*be-.90649*he)),255*(le+ae*(1.97294*be)),1]))},"e");return M.start=function(V){return V==null?d:(d=V,M)},M.rotations=function(V){return V==null?v:(v=V,M)},M.gamma=function(V){return V==null?k:(k=V,M)},M.hue=function(V){return V==null?_:(Qt(_=V)==="array"?(j=_[1]-_[0])==0&&(_=_[1]):j=0,M)},M.lightness=function(V){return V==null?I:(F=Qt(V)==="array"?(I=V)[1]-V[0]:(I=[V,V],0),M)},M.scale=function(){return O.scale(M)},M.hue(_),M},O.mix=O.interpolate=Qr,O.random=function(){for(var d="#",v=0;v<6;v++)d+="0123456789abcdef".charAt(Qn(16*fo()));return new y(d,"hex")},O.scale=pr,O.analyze=Ds.analyze,O.contrast=function(d,v){d=new y(d),v=new y(v);var _=d.luminance(),k=v.luminance();return k<_?(_+.05)/(k+.05):(k+.05)/(_+.05)},O.deltaE=function(d,v,_,k){_===void 0&&(_=1),k===void 0&&(k=1),d=new y(d),v=new y(v);for(var I=Array.from(d.lab()),F=I[0],j=I[1],M=I[2],V=Array.from(v.lab()),Z=V[0],le=V[1],ae=V[2],be=ha(j*j+M*M),he=ha(le*le+ae*ae),Te=F<16?.511:.040975*F/(1+.01765*F),et=.0638*be/(1+.0131*be)+.638,Ge=be<1e-6?0:180*Lu(M,j)/mo;Ge<0;)Ge+=360;for(;360<=Ge;)Ge-=360;var ft=164<=Ge&&Ge<=345?.56+da(.2*js(mo*(Ge+168)/180)):.36+da(.4*js(mo*(Ge+35)/180)),ht=be*be*be*be,Ct=ha(ht/(ht+1900)),ir=et*(Ct*ft+1-Ct),ze=be-he,ie=j-le,je=M-ae,Ye=(F-Z)/(_*Te),Je=ze/(k*et);return ha(Ye*Ye+Je*Je+(ie*ie+je*je-ze*ze)/(ir*ir))},O.distance=function(d,v,_){_===void 0&&(_="lab"),d=new y(d),v=new y(v);var k=d.get(_),I=v.get(_),F=0;for(var j in k){var M=(k[j]||0)-(I[j]||0);F+=M*M}return Math.sqrt(F)},O.limits=Ds.limits,O.valid=function(){for(var d=[],v=arguments.length;v--;)d[v]=arguments[v];try{return new(Function.prototype.bind.apply(y,[null].concat(d))),!0}catch{return!1}},O.scales=Iu,O.colors=gt,O.brewer=ky,O})}).call(void 0,_f,_f.exports,void 0);Vn=_f.exports});var xf={};Oe(xf,{LightColor:()=>xn});function ow(e){for(var t=Object.keys(_n),r=t[t.length-1],n=0;n<t.length;n++)if(e<=_n[t[n]]){r=t[n];break}if(r===t[0]){var i=Vn(r).rgb();return[Math.round(i[0]),Math.round(i[1]),Math.round(i[2])]}var a=t.indexOf(r),s=t[a-1],l=(e-_n[s])/(_n[r]-_n[s]),u=Vn.mix(s,r,isNaN(l)?0:l),f=u.rgb();return[Math.round(f[0]),Math.round(f[1]),Math.round(f[2])]}function sw(e){for(var t=Math.max(0,Math.min(1,e)),r=Ui[0],n=Ui[Ui.length-1],i=0;i<Ui.length-1;i++)if(t<=Ui[i+1].threshold){r=Ui[i],n=Ui[i+1];break}var a=n.threshold-r.threshold,s=a>0?(t-r.threshold)/a:0,l=Vn.mix(Vn.rgb(r.rgb),Vn.rgb(n.rgb),s),u=l.rgb();return[Math.round(u[0]),Math.round(u[1]),Math.round(u[2])]}function lw(e,t){var r=Math.max(0,Math.min(1,e)),n=t!=null?Math.max(0,Math.min(1,t)):.35;return n+r*(1-n)}function fm(e){return sw(e)}function uw(e){var t=Math.max(0,Math.min(1,e)),r=Vn.mix(Vn.rgb(cm[0].rgb),Vn.rgb(cm[1].rgb),t),n=r.rgb();return[Math.round(n[0]),Math.round(n[1]),Math.round(n[2])]}function hm(e){return uw(e)}function cw(e,t){return e==="roygbiv"?fm(t):e==="greyscale"?hm(t):dm(t)}function dm(e){return ow(e)}function fw(e){for(var t=Object.keys(_n),r=0;r<t.length;r++)if(e<=_n[t[r]])return t[r];return"pink"}function hw(e){return _n[e]!==void 0?_n[e]:.5}var _n,Ui,cm,xn,Ma=ce(()=>{um();_n={red:.1,orange:.2,yellow:.3,green:.4,cyan:.5,blue:.6,indigo:.7,violet:.8,pink:.9},Ui=[{threshold:0,name:"red",rgb:[255,0,0]},{threshold:1/6,name:"orange",rgb:[255,127,0]},{threshold:2/6,name:"yellow",rgb:[255,255,0]},{threshold:3/6,name:"green",rgb:[0,200,0]},{threshold:4/6,name:"blue",rgb:[0,0,255]},{threshold:5/6,name:"indigo",rgb:[75,0,130]},{threshold:1,name:"violet",rgb:[148,0,211]}];o(ow,"_chromaWarmcool");o(sw,"_chromaRoygbiv");o(lw,"getAlphaFromIntensity");o(fm,"getRgbColorFromFrequency");cm=[{threshold:0,name:"greyscale-dark",rgb:[60,60,60]},{threshold:1,name:"greyscale-light",rgb:[235,235,235]}];o(uw,"_chromaGreyscale");o(hm,"getRgbColorFromGreyscale");o(cw,"getRgbBySchemeName");o(dm,"getRgbColorFromFullness");o(fw,"getColorNameFor");o(hw,"getFullnessForColorName");xn={fullnessColorMap:_n,getRgbColorFromFullness:dm,getRgbColorFromFrequency:fm,getRgbColorFromGreyscale:hm,getRgbBySchemeName:cw,getAlphaFromIntensity:lw,getColorNameFor:fw,getFullnessForColorName:hw}});var Of={};Oe(Of,{LiveChart:()=>zi});function pm(e){return!!e&&(typeof e.getCollisionHistogram=="function"||typeof e.getAbsorbStats=="function"||typeof e.getLiveCount=="function")}function dw(e,t){if(!e||typeof e.getObjectByName!="function")throw new Error("[ObjectFactory] a named LiveChart source resolves through runner.getObjectByName (the declared-object registry); this runner has none. (FAIL-LOUD.)");return e.getObjectByName(t,pm)}var zi,pw,Ef=ce(()=>{Rt();wr();Ut();Di();Et();zi=class{static{o(this,"LiveChart")}constructor(){throw new Error("[LiveChart] LiveChart is a kind token \u2014 declare it with exp.addObject(LiveChart, props) (or exp.addObject('LiveChart', props)); its build returns the chart. (FAIL-LOUD.)")}};o(pm,"_isChartSource");o(dw,"_resolveHistogramSource");pw={description:"An in-scene live chart panel that plots a counting Wall's running y\u2192count histogram (getCollisionHistogram) as the sim runs. A render-only LargeObject (NONE collision, zero physics) \u2014 the Chart.js chart renders to an offscreen canvas and is composited into the scene as a texture/image, so it moves and scales with the scene. Point it at a detect/count Wall; a non-counting source fails loud.",ux:{resizable:!0,draggable:{"2d":!0},shellRender:"run"},fields:[{name:"rect",type:"rect",engineVisible:!1,unit:"px",description:"Placement + size of the chart panel in physics pixels "+Ot(4)+". Render-only \u2014 never a collision region."},{name:"source",type:"string",engineVisible:!1,description:"Name of the source Wall that feeds this chart (a direct wall handle is also accepted at construction). For projector detectorHistogram: a detect/count wall (getCollisionHistogram). For projector absorberStats: an ABSORB wall (getAbsorbStats). For projector liveCount: a count-hook wall (getLiveCount). A source lacking the projector's read method fails loud at wire time."},{name:"projector",type:"enum",constraint:{values:{detectorHistogram:"detectorHistogram",absorberStats:"absorberStats",liveCount:"liveCount",detectorSurface:"detectorSurface"}},engineVisible:!1,description:"The blessed live-chart projector to poll (default detectorHistogram). detectorHistogram = a counting Wall's y\u2192count column-profile (fringes); absorberStats = an ABSORB Wall's {stored,absorbed,radiated} mass ledger; liveCount = a counting Wall's per-tick collided-frame count (a full-area background wall's live population); detectorSurface = the SAME counting Wall's hits binned over its FACE (y\xD7z) and drawn as a topology heightfield \u2014 the 3D instrument, where a detector is a plane and the fringes read as ridges. One vocabulary, owned by live-chart-controller's LIVE_CHART_PROJECTORS."},{name:"series",type:"enum",constraint:{values:{bar:"bar",line:"line"}},engineVisible:!1,description:"Chart series kind: bar (default, a histogram) or line."},{name:"orientation",type:"enum",constraint:{values:{0:"0",90:"90"}},engineVisible:!1,live:!0,description:"Chart orientation in degrees. 0 = standard vertical bars (bins along x). 90 = the GYM detector-histogram presentation: HORIZONTAL bars stacked along y (Chart.js indexAxis:y, y-axis reversed to run top-down) so a detector column-profile aligns SPATIALLY with the vertical detector wall beside it. Default: 90 for a detectorHistogram chart (detector-aligned), 0 otherwise. Live-editable in the Inspector."},{name:"label",type:"string",engineVisible:!1,description:"Dataset label shown in the chart legend (default = the source name)."},{name:"refreshMs",type:"number",constraint:{min:16,integer:!0},engineVisible:!1,unit:"ms",description:"Redraw cadence in ms (default 100 \u2192 ~10 fps). Caps Chart.js redraw cost regardless of tick rate; accumulation still runs EVERY tick (no dropped counts)."},{name:"visible",type:"boolean",engineVisible:!1,live:!0,description:"Whether the chart panel is rendered (render-only)."},{name:"alpha",type:"number",constraint:{min:0,max:255,integer:!0},engineVisible:!1,live:!0,widgetHint:"slider",description:"Render opacity 0-255 (render-only)."}]};at(zi,{from:new URL("frqtl/parts/LiveChart.js",He()).href,descriptor:pw,defaults:{w:200,h:140,projector:"detectorHistogram",series:"bar",refreshMs:100,color:[30,40,55]},palette:{displayName:"Live Chart",category:"measurement",iconHint:"chart",rank:4},build:o(function(e,t,r){var n=Se,i=Ee,a=e.rect,s,l,u,f;Array.isArray(a)?a.length>=6?(u=a[0],f=a[1],s=a[3],l=a[4]):(u=a[0],f=a[1],s=a[2],l=a[3]):a&&a.left!=null?(u=a.left,f=a.top,s=a.w,l=a.h):(s=e.w||200,l=e.h||140,u=Math.round(t.x-s/2),f=Math.round(t.y-l/2));var c=e.name||"livechart "+(t.runner.largeObjects.length+1),h=e.color||[30,40,55],g=new n(t.runner.universe,[u,f,s,l],i.NONE,[],c,"closest",null,1,h);e.alpha!=null&&(g.alpha=e.alpha),e.visible!=null&&(g.visible=e.visible),g._schemaKind=r.name;var p=e.source,m=null,b=null;if(p&&typeof p=="object"&&pm(p))m=p,b=typeof p.name=="string"?p.name:null;else if(typeof p=="string"&&p){if(b=p,m=dw(t.runner,p),!m)throw new Error('[ObjectFactory] LiveChart source wall "'+p+'" not found among the registered objects \u2014 a LiveChart must be pointed at an already-added counting/absorbing Wall (by name or handle). (FAIL-LOUD.)')}else if(p!=null)throw new Error("[ObjectFactory] LiveChart `source` must be a Wall handle (exposing getCollisionHistogram or getAbsorbStats) or its name string; got "+typeof p+". (FAIL-LOUD.)");var y=e.projector||"detectorHistogram",w;return e.orientation===90||e.orientation==="90"?w=90:e.orientation===0||e.orientation==="0"?w=0:w=y==="detectorHistogram"?90:0,g.orientation=String(w),g.chartSpec={source:b,sourceHandle:m,projector:y,kind:e.series==="line"?"line":"bar",label:e.label||b||"detector",refreshMs:typeof e.refreshMs=="number"?e.refreshMs:100,orientation:w},g.source=b,g.projector=y,g.series=g.chartSpec.kind,g.label=g.chartSpec.label,g.refreshMs=g.chartSpec.refreshMs,g.liveCanvas=null,g},"build")})});var bl={};Oe(bl,{BEHAVIORS:()=>mw,LEGACY_VARIANT_MAP:()=>Sf,applyLinerScatter:()=>kf,buildLinerProgram:()=>gm,resolveLegacyVariant:()=>mm});function mm(e){if(e==null)return null;if(!Object.prototype.hasOwnProperty.call(Sf,e))throw new Error("[slitLinerScatter] unknown slitScatter legacy variant: "+e);return Sf[e]}function gm(e,t,r,n,i,a,s,l,u){var f=r.Lit,c=r.Bin,h=r.Cond,g=r.Cmp,p=r.Fn,m=r.Ref,b=r.HANDLE_FRAME,y=r.HANDLE_SELF,w=o(function(){return c("-",c("*",p("random",[]),f(2)),f(1))},"randomSigned"),O=o(function(){return h(g("<",p("random",[]),f(.5)),f(0),f(1))},"chargeDraw"),S,A,C;if(e==="ejectY"||e==="ejectYReflect")S=n(l,b,y,f,m,c,g,h,p)||[],A=e==="ejectYReflect"?[{set:b+".vy",to:c("*",m(b,"vy"),f(-1))}]:[],C=!1;else if(e==="randomXY"){var R=i(["BLOCK"],a,s,Ee.NONE);S=R.program?R.program.ops:[],A=[{set:b+".vx",to:p("random",[])},{set:b+".vy",to:w()}],u&&A.push({set:b+".vz",to:w()}),C=!0}else if(e==="symmetric"){var Q=i(["BLOCK"],a,s,Ee.NONE);S=Q.program?Q.program.ops:[],A=[{set:b+".vx",to:w()},{set:b+".vy",to:w()}],u&&A.push({set:b+".vz",to:w()}),C=!0}else if(e==="bounce"){var Y=i(["BLOCK"],a,s,Ee.NONE);S=Y.program?Y.program.ops:[],A=[{set:b+".vy",to:c("*",m(b,"vy"),f(-1))}],C=!1}else throw new Error("[slitLinerScatter] unknown behavior: "+e);var H=S.concat(A);return t&&(H=H.concat([{set:b+".local_time",to:f(0)}])),C&&(H=H.concat([{set:b+".charge",to:O()}])),H}function kf(e,t,r,n){n=n||{};var i;if(n.behavior!==void 0?i={behavior:n.behavior,resetLocalTime:!!n.resetLocalTime}:i=mm(n.slitScatter),i!==null){var a=yr,s=gm(i.behavior,i.resetLocalTime,a,In,_a,e.name,e.reposition,r,!!n.hasRealDepth),l={on:"collision",ops:s},u=$n(e.reposition||null,!1,a.HANDLE_FRAME,a.HANDLE_SELF,a.Lit,a.Ref,a.Cmp,a.Cond,a.Fn);gn(l,u),e.program=l,t&&typeof t.updateObjectProperty=="function"&&t.updateObjectProperty(e.handle,"LargeObject","program",l)}}var mw,Sf,Af=ce(()=>{xa();ba();Ut();mw=["randomXY","symmetric","bounce","ejectY","ejectYReflect"],Sf={current:null,noreset:{behavior:"randomXY",resetLocalTime:!1},symmetric:{behavior:"symmetric",resetLocalTime:!0},combined:{behavior:"symmetric",resetLocalTime:!1},bounce:{behavior:"bounce",resetLocalTime:!1},ejectY:{behavior:"ejectY",resetLocalTime:!1},ejectYReflect:{behavior:"ejectYReflect",resetLocalTime:!1}};o(mm,"resolveLegacyVariant");o(gm,"buildLinerProgram");o(kf,"applyLinerScatter")});function vm(e,t){t=t||{};var r=t.wallHandles||[],n=t.angleRad;if(typeof n!="number"||!isFinite(n))throw new Error("[directedRedirectProgram] spec.angleRad must be a finite number (radians).");var i=t.spreadRad!==void 0&&t.spreadRad!==null?t.spreadRad:0,a=t.polarSpreadRad!==void 0&&t.polarSpreadRad!==null?t.polarSpreadRad:0,s=t.speed!==void 0?t.speed:null;return o(function(u){if(!(!u||!u.objects))for(var f=0;f<r.length;f++){var c=u.objects[r[f]];if(!(!c||!Array.isArray(c.frames)))for(var h=c.frames,g=0;g<h.length;g++){var p=h[g],m=n;i&&(m+=(e.random()*2-1)*i);var b=s!==null?s:Math.sqrt(p.vx*p.vx+p.vy*p.vy)||1,y=0;a&&(y=(e.random()*2-1)*a);var w=Math.cos(m)*Math.cos(y)*b,O=Math.sin(m)*Math.cos(y)*b,S=Math.sin(y)*b;e.setFrameProperty(p.id,"vx",w),e.setFrameProperty(p.id,"vy",O),a&&e.setFrameProperty(p.id,"vz",S)}}},"applyRedirect")}var ym=ce(()=>{"use strict";o(vm,"buildRedirectApplier")});function vw(e,t){if(Math.abs(e.length-t.length)>2)return 99;var r=[],n=[],i,a;for(a=0;a<=t.length;a++)r[a]=a;for(i=1;i<=e.length;i++){for(n[0]=i,a=1;a<=t.length;a++)n[a]=Math.min(r[a]+1,n[a-1]+1,r[a-1]+(e.charAt(i-1)===t.charAt(a-1)?0:1));r=n.slice()}return r[t.length]}function yw(e,t){for(var r=null,n=3,i=e.toLowerCase(),a=0;a<t.length;a++){var s=vw(i,String(t[a]).toLowerCase());s<n&&(n=s,r=t[a])}return r}function Ua(e,t,r){if(t==null)return{};if(typeof t!="object"||Array.isArray(t))throw new Error("["+e+"] options must be a plain object, got "+(Array.isArray(t)?"an array":typeof t)+". Legal keys: "+r.slice().sort().join(", ")+".");for(var n=r.slice().sort(),i=Object.keys(t),a=0;a<i.length;a++)if(r.indexOf(i[a])===-1){var s=yw(i[a],r);throw new Error("["+e+"] unknown option '"+i[a]+"'"+(s?" \u2014 did you mean '"+s+"'?":"")+" This factory reads NONE of the keys it does not declare, so an unrecognized one would have silently resolved to a default and run a DIFFERENT experiment than you asked for. Legal options: "+n.join(", ")+".")}return t}function zo(e,t){return Ke.worldRect(t,e)}var Tf=ce(()=>{Un();o(vw,"_editDistance");o(yw,"_suggest");o(Ua,"assertSetupOptions");o(zo,"requireWorldRect")});function Cf(e){var t=Math.pow(2,e);return t*t}var bw,bS,bm=ce(()=>{"use strict";bw={wavelength:{default:null,desc:"Per-frame wavelength override (Engine Invariant #6 mass=max(1,capacity/wavelength)). null = engine default (mass=capacity)."},charge:{default:null,desc:"Per-frame charge override (0=Positive,1=Negative). null = random draw per quantum."},velocityProfile:{default:"beam",enum:["beam","spray"],desc:"'beam' = collimated single-direction (orientationRad+speed, vy=vz=0); 'spray' = biased random fan (spraySpec)."},speed:{default:1,desc:"'beam' profile only: speed magnitude."},orientationRad:{default:0,desc:"'beam' profile only: direction, radians (0 = +X)."},spraySpec:{default:{vxMin:.2,vxRange:.6,vyMin:.1,vyRange:.7},desc:"'spray' profile only: vx=vxMin+random()*vxRange, vy=vyMin+random()*vyRange (setupTunnelLab.js's original literal fan)."},entranceBias:{default:"center",enum:["center","top"],desc:"'center' = bore Y-centreline (LightSource.js's convention); 'top' = bunched 2px from the TOP wall (setupTunnelLab.js's original biased-entry/uniformization-demo shape)."},zIsotropy:{default:!0,desc:"When real depth is armed AND velocityProfile='spray': draw vz=(random()*2-1)*spraySpec.vyRange (SAME half-range as vy) for a 3D-symmetric fan. 'beam' stays vy=vz=0 regardless (deliberate collimation)."},level:{default:null,desc:"makeLeafFrame's level override (rarely used)."},mass:{default:void 0,desc:"Post-placement mass override via setFrameProperty. undefined = no override."},density:{default:5,desc:"Quanta hand-placed per burst."},rate:{default:10,desc:"Ticks between bursts (everyNTicks cadence)."},active:{default:!0,desc:"Master on/off for the recurring source."}},bS=Object.keys(bw);o(Cf,"capacityAtDimension")});function _w(){return Rf.map(function(e){return e.key}).join(", ")}function _m(e,t,r){Object.keys(t).forEach(function(a){if(Object.prototype.hasOwnProperty.call(wm,a))throw new Error(e+": '"+a+"' is not a world-cfg key \u2014 "+wm[a]+". (FAIL-LOUD: one declaration per fact.)")});var n=r?r.constructor:null,i=n&&n.RETIRED_CONFIG_KEYS&&typeof n.RETIRED_CONFIG_KEYS=="object"?n.RETIRED_CONFIG_KEYS:null;Object.keys(t).forEach(function(a){var s=Rf.some(function(u){return u.key===a});if(!s){var l=e+": unknown option '"+a+"'. Legal options: "+_w()+".";throw i&&Object.prototype.hasOwnProperty.call(i,a)&&(l+=" That name is RETIRED at the engine \u2014 '"+a+"' "+i[a]+". Note this is the RECIPE vocabulary, not the engine option list: migrate to one of the legal options above."),new Error(l)}})}function xw(e){if(arguments.length>1)throw new Error("FrqtlWorldInit.initArgs(cfg) takes no rect \u2014 the world rect is written ONCE, by EGPTUniverse.create({ rect, seed, \u2026 }), and universe.init(fundamentalDimension, options) reads it. (FAIL-LOUD.)");e=e||{},_m("FrqtlWorldInit.initArgs(cfg)",e,null);var t=e.dimension!==void 0?e.dimension:2,r={wavelengthScale:e.wavelengthScale!==void 0?e.wavelengthScale:8,noEscape:e.bonding!==void 0?e.bonding:!1,frameGenMode:e.frames!==void 0&&e.frames?"topDown":"groundUp"};return e.stepping!==void 0&&e.stepping!==null&&(r.stepping=e.stepping),[t,r]}function Ow(e,t){e&&e.iframeIntervalSeconds!==void 0&&e.iframeIntervalSeconds!==null&&(t.iframe_interval_seconds=e.iframeIntervalSeconds)}var Rf,wm,wl,Df=ce(()=>{Rf=[{key:"dimension",effect:"the fundamental (base) dimension layer \u2014 universe.init()'s 1st argument. default 2."},{key:"wavelengthScale",effect:"\u2192 universe.init options.wavelengthScale \u2014 the GLOBAL \u03BB multiplier. default 8."},{key:"interQuantumCollisions",effect:"ACCEPTED BUT INERT \u2014 it fed a removed positional slot the engine never read."},{key:"bonding",effect:"\u2192 universe.init options.noEscape (the names do NOT line up 1:1). default false."},{key:"frames",effect:"BOOLEAN \u2192 universe.init options.frameGenMode: true \u2192 'topDown', false \u2192 'groundUp'. default false."},{key:"stepping",effect:"'fixed' | 'average' \u2014 the wave-walk sampler, ferried VERBATIM (never validated or defaulted here). Omitted \u21D2 the engine's default."},{key:"iframeIntervalSeconds",effect:"the parent-generation interval (s) \u2014 applied through the universe's own PRE-INIT setter (`universe.iframe_interval_seconds`) by applyPreInit(), immediately before universe.init; the engine freezes it at init. Omitted \u21D2 untouched (the engine's default)."}];o(_w,"_initCfgKeyList");wm={activeAxes:"the axes are the method: exp.createCanvas(w, h, cfg) is 2D, exp.createScene(w, h, d, cfg) is 3D",depth:"the depth is exp.createScene(w, h, d, cfg)'s d",canvasW:"the size is the co-init call's w, h (exp.createCanvas(w, h, cfg) / exp.createScene(w, h, d, cfg))",canvasH:"the size is the co-init call's w, h (exp.createCanvas(w, h, cfg) / exp.createScene(w, h, d, cfg))",stage:"the size is the co-init call's w, h (exp.createCanvas(w, h, cfg) / exp.createScene(w, h, d, cfg))"};o(_m,"assertInitCfg");o(xw,"initArgs");o(Ow,"applyPreInit");wl={INIT_CFG:Rf,assertInitCfg:_m,initArgs:xw,applyPreInit:Ow}});function Vi(e,t,r){return Math.max(t,Math.min(r,e))}function xm(e){e=Ua("setupSphereEmitter3D.worldCfg",e,Om);var t=e.fundamentalWaveLength!==void 0?e.fundamentalWaveLength:64,r={dimension:e.fundamentalDimension!==void 0?e.fundamentalDimension:0,wavelengthScale:Math.max(1,Math.floor(t/4))};return e.stepping!==void 0&&e.stepping!==null&&(r.stepping=e.stepping),r}function Ew(){return wl.initArgs}function Sw(e,t){var r=Ew()(xm(t));r[1].activeAxes={x:!0,y:!0,z:!(t&&t.is2D)},e.init.apply(e,r)}function kw(e){var t=e.fundamentalDimension;if(typeof t!="number"||!isFinite(t)||t<0||Math.floor(t)!==t)throw new Error("setupSphereEmitter3D: the universe did not report its fundamental dimension (universe.fundamentalDimension = "+String(t)+"). An emitter that declares no fundamentalDimension/leafDimension mints at the world's own layer, read from EGPTUniverse.fundamentalDimension on an init'd world.");return t}function xr(e,t){if(t=t||{},Sm.indexOf("skipInit")!==-1&&"skipInit"in t)throw new Error("setupSphereEmitter3D: 'skipInit' is DELETED. This factory constructs a PART and never inits the world \u2014 the SKETCH does, once, before any part: setupSphereEmitter3D.initWorld(universe, opts). Remove skipInit; a second emitter on an already-init'd universe needs no flag.");t=Ua("setupSphereEmitter3D",t,jf);var r=e.universe_rect;zo("setupSphereEmitter3D universe.universe_rect",r);var n=!!t.is2D,i=t.fundamentalDimension!==void 0||t.leafDimension!==void 0,a=t.fundamentalDimension!==void 0?t.fundamentalDimension:i?0:kw(e),s=t.leafDimension!==void 0?t.leafDimension:a,l=Cf(s);s!==a&&e.addDimension(s);var u=Math.floor(r.w/2),f=Math.floor(r.h/2),c,h,g;o((function(ee,X){Array.isArray(ee)?(c=Math.round(ee[0]),h=Math.round(ee[1]),g=ee.length>2&&ee[2]!=null?Math.round(ee[2]):0):Array.isArray(X)?(c=u+Math.round(X[0]),h=f+Math.round(X[1]),g=X.length>2&&X[2]!=null?Math.round(X[2]):0):(c=u,h=f,g=0)}),"resolveCenter")(t.center,t.offset);var p={R:t.R!==void 0?t.R:24,emissionBoxSide:0,mode:t.mode!==void 0?t.mode:"ball",preset:t.preset!==void 0?t.preset:"spherical",burstSize:0,wavelength:t.wavelength!==void 0&&t.wavelength!==null?Vi(t.wavelength,1,l):null,chargeMode:t.chargeMode==="random"||t.chargeMode==="negative"||t.chargeMode==="positive"?t.chargeMode:"positive",emissionShell:t.emissionShell==="surface"?"surface":"volume",innerR:t.innerR!==void 0?Math.max(0,Math.round(t.innerR)):0,renderColor:Array.isArray(t.renderColor)?t.renderColor.slice():null,renderShape:typeof t.renderShape=="string"&&t.renderShape?t.renderShape:null,orientationDeg:typeof t.orientationDeg=="number"?t.orientationDeg:0,active:!0},m=10,b=20,y=1;p.emissionBoxSide=Vi(t.emissionBoxSide!==void 0?t.emissionBoxSide:p.preset==="particle-walk"?m:0,0,p.R),p.burstSize=t.burstSize!==void 0?t.burstSize:p.preset==="particle-walk"?b:40;var w=t.emissionBox||null,O=t.sourceShape!==void 0?t.sourceShape:null;function S(L){return Vi(L,0,p.R)}o(S,"clampBox");function A(){if(w){p.emissionBox={x:S(w.x!==void 0?w.x:0),y:S(w.y!==void 0?w.y:0),z:S(w.z!==void 0?w.z:0)},p.sourceShape=O||"box";return}if(p.preset==="particle-walk")p.emissionBox={x:0,y:S(p.emissionBoxSide),z:0},p.sourceShape=O||"box";else{var L=S(p.emissionBoxSide);p.emissionBox={x:L,y:L,z:L},p.sourceShape=O||"box"}}o(A,"deriveSourceShape"),A();var C=t.emitEveryTicks!==void 0?t.emitEveryTicks:p.preset==="particle-walk"?y:6,R={vx:[0,0],vy:[0,0],vz:[0,0]};function Q(L,ee){if(L==="laser"){var X=Math.max(1,Math.round(ee*.15)),te=[Math.round(ee*.6),ee];n?(R.vx=te,R.vy=[-X,X],R.vz=[0,0]):(R.vx=[-X,X],R.vy=[-X,X],R.vz=te)}else L==="hemisphere"?(R.vx=[0,ee],R.vy=[-ee,ee],R.vz=[-ee,ee]):L==="drum"?(R.vx=[-ee,ee],R.vy=[-ee,ee],R.vz=[0,0]):L==="particle-walk"?(R.vx=[ee,ee],R.vy=[0,0],R.vz=[0,0]):(R.vx=[-ee,ee],R.vy=[-ee,ee],R.vz=[-ee,ee])}o(Q,"applyPreset"),Q(p.preset,p.R);function Y(L){var ee=p.orientationDeg||0;if(!ee)return L;var X=ee*Math.PI/180,te=Math.cos(X),ye=Math.sin(X);return[Math.round(L[0]*te-L[1]*ye),Math.round(L[0]*ye+L[1]*te),L[2]]}o(Y,"rotateVelocity2D");function H(){return Y(q())}o(H,"sampleVelocity");function q(){for(var L=p.R,ee=p.preset==="laser"||p.preset==="particle-walk",X=500,te=0,ye=0,xe=0,Ue=0;Ue<X;Ue++){te=Math.round(R.vx[0]+e.random()*(R.vx[1]-R.vx[0])),ye=Math.round(R.vy[0]+e.random()*(R.vy[1]-R.vy[0])),xe=n?0:Math.round(R.vz[0]+e.random()*(R.vz[1]-R.vz[0]));var Ce=te*te+ye*ye+xe*xe;if(Ce!==0){if(ee)return[te,ye,xe];if(p.mode==="shell"){var _e=.9*L;if(Ce<=L*L&&Ce>=_e*_e)return[te,ye,xe]}else if(Ce<=L*L)return[te,ye,xe]}}return[te,ye,xe]}o(q,"sampleVelocityCore");function T(){return p.chargeMode==="random"?e.random()<.5?0:1:p.chargeMode==="negative"?1:0}o(T,"sampleCharge");function J(L){return L<=0?0:-L/2+e.random()*L}o(J,"sampleOffsetAxis");function D(L){var ee=L/2;if(ee<=0)return[0,0];for(var X=200,te=0;te<X;te++){var ye=-ee+e.random()*2*ee,xe=-ee+e.random()*2*ee;if(ye*ye+xe*xe<=ee*ee)return[ye,xe]}return[0,0]}o(D,"sampleDiskOffsetYZ");function K(L,ee){if(ee<=0)return[0,0,0];var X=L[0],te=L[1],ye=n?0:L[2],xe=Math.sqrt(X*X+te*te+ye*ye);if(xe<1e-9)return[0,0,0];var Ue=ee/xe;return[Math.round(X*Ue),Math.round(te*Ue),n?0:Math.round(ye*Ue)]}o(K,"shellOffsetFromVelocity");function N(){var L=p.emissionBox,ee=J(L.x);if(p.sourceShape==="disk"){var X=D(Math.max(L.y,L.z));return[ee,X[0],n?0:X[1]]}var te=J(L.y),ye=n?0:J(L.z);return[ee,te,ye]}o(N,"sampleSourcePosition");function B(){var L,ee,X,te;if(p.emissionShell==="surface"){L=H();var ye=K(L,p.innerR);ee=ye[0],X=ye[1],te=ye[2]}else{var xe=N();ee=xe[0],X=xe[1],te=xe[2],L=H()}var Ue=T(),Ce=c+ee,_e=h+X,Ve=g+te,wt=e.makeLeafFrame(Ce,_e,s,p.wavelength,L[0],L[1],!1,Ue,p.renderColor,p.renderShape);if(wt!==null){e.injectFrame(wt);var Vt=e.getFrameQuantumId(wt);e.setFrameProperty(Vt,"z",Ve),e.setFrameProperty(Vt,"vz",L[2]),e.setFrameProperty(Vt,"vx",L[0]),e.setFrameProperty(Vt,"vy",L[1])}}o(B,"emitOneLeaf");function ne(){for(var L=0;L<p.burstSize;L++)B()}o(ne,"emitBurst");var oe=0,$=o(function(){p.active&&oe%C===0&&ne(),oe++},"_tickFn");e.experimentTickFunctions.push($);var de=null;function ve(){var L=de.rect.w;de.setRect([c-L/2,h-L/2,g-L/2,L,L,L])}o(ve,"placeMarker");var ue={setR:o(function(L){p.R=L,p.emissionBoxSide=Vi(p.emissionBoxSide,0,p.R),Q(p.preset,p.R),A()},"setR"),getR:o(function(){return p.R},"getR"),setEmissionBoxSide:o(function(L){p.emissionBoxSide=Vi(L,0,p.R),A()},"setEmissionBoxSide"),getEmissionBoxSide:o(function(){return p.emissionBoxSide},"getEmissionBoxSide"),getEmissionBox:o(function(){return{x:p.emissionBox.x,y:p.emissionBox.y,z:p.emissionBox.z}},"getEmissionBox"),getSourceShape:o(function(){return p.sourceShape},"getSourceShape"),setMode:o(function(L){p.mode=L==="shell"?"shell":"ball"},"setMode"),getMode:o(function(){return p.mode},"getMode"),setPreset:o(function(L){p.preset=L,Q(L,p.R),A()},"setPreset"),getPreset:o(function(){return p.preset},"getPreset"),setAxisRange:o(function(L,ee,X){R[L]=[ee,X]},"setAxisRange"),getAxisRange:o(function(L){return R[L].slice()},"getAxisRange"),setBurstSize:o(function(L){p.burstSize=Math.max(1,Math.round(L))},"setBurstSize"),getBurstSize:o(function(){return p.burstSize},"getBurstSize"),setEmitEveryTicks:o(function(L){C=Math.max(1,Math.round(L))},"setEmitEveryTicks"),getEmitEveryTicks:o(function(){return C},"getEmitEveryTicks"),setActive:o(function(L){p.active=!!L},"setActive"),getIs2D:o(function(){return n},"getIs2D"),setCenter:o(function(L,ee,X){c=Math.round(L),h=Math.round(ee),X!=null&&(g=Math.round(X)),de&&ve()},"setCenter"),attachMarker:o(function(L){if(!L||!L.rect||typeof L.rect.z!="number")throw new TypeError("[setupSphereEmitter3D.attachMarker] the marker must be a z-capable LO (constructed with a 6-element rect) \u2014 it follows the centre in x, y AND z. (FAIL-LOUD.)");de=L,ve()},"attachMarker"),getCenter:o(function(){return[c,h,g]},"getCenter"),setChargeMode:o(function(L){p.chargeMode=L==="random"||L==="negative"||L==="positive"?L:p.chargeMode},"setChargeMode"),getChargeMode:o(function(){return p.chargeMode},"getChargeMode"),setEmissionShell:o(function(L){p.emissionShell=L==="surface"?"surface":"volume"},"setEmissionShell"),getEmissionShell:o(function(){return p.emissionShell},"getEmissionShell"),setInnerR:o(function(L){p.innerR=Math.max(0,Math.round(L))},"setInnerR"),getInnerR:o(function(){return p.innerR},"getInnerR"),setWavelength:o(function(L){p.wavelength=Vi(Math.round(L),1,l)},"setWavelength"),getWavelength:o(function(){return p.wavelength!==null?p.wavelength:1},"getWavelength"),getMaxWavelength:o(function(){return l},"getMaxWavelength"),getFundamentalDimension:o(function(){return a},"getFundamentalDimension"),getLeafDimension:o(function(){return s},"getLeafDimension"),setLeafDimension:o(function(L){var ee=Math.max(0,Math.round(L));return ee===s||(ee!==a&&typeof e.addDimension=="function"&&e.addDimension(ee),s=ee,l=Cf(s),p.wavelength!==null&&(p.wavelength=Vi(p.wavelength,1,l))),s},"setLeafDimension"),setRenderColor:o(function(L){p.renderColor=Array.isArray(L)?L.slice():null},"setRenderColor"),getRenderColor:o(function(){return p.renderColor?p.renderColor.slice():null},"getRenderColor"),setRenderShape:o(function(L){p.renderShape=typeof L=="string"&&L?L:null},"setRenderShape"),getRenderShape:o(function(){return p.renderShape||null},"getRenderShape"),setOrientation:o(function(L){var ee=typeof L=="number"&&isFinite(L)?L:0;p.orientationDeg=(ee%360+360)%360},"setOrientation"),getOrientation:o(function(){return p.orientationDeg||0},"getOrientation"),dispose:o(function(){var L=e.experimentTickFunctions.indexOf($);L!==-1&&e.experimentTickFunctions.splice(L,1)},"dispose")};return ue.controls=[{id:"R",label:"R (radius / blockiness)",min:2,max:40,step:1,value:p.R,fmt:o(function(L){return String(L)},"fmt"),get:o(function(){return ue.getR()},"get"),onChange:o(function(L){ue.setR(L)},"onChange")},{id:"emissionBoxSide",label:"emission box",min:0,max:40,step:1,value:p.emissionBoxSide,maxRef:"R",fmt:o(function(L){return String(L)},"fmt"),get:o(function(){return ue.getEmissionBoxSide()},"get"),onChange:o(function(L){ue.setEmissionBoxSide(L)},"onChange")},{id:"preset",label:"preset",kind:"select",options:Em.slice(),value:p.preset,fmt:o(function(L){return String(L)},"fmt"),get:o(function(){return ue.getPreset()},"get"),onChange:o(function(L){ue.setPreset(L)},"onChange")},{id:"mode",label:"mode",kind:"select",options:["ball","shell"],value:p.mode,fmt:o(function(L){return String(L)},"fmt"),get:o(function(){return ue.getMode()},"get"),onChange:o(function(L){ue.setMode(L)},"onChange")},{id:"burstSize",label:"burst size",min:1,max:200,step:1,value:p.burstSize,fmt:o(function(L){return String(L)},"fmt"),get:o(function(){return ue.getBurstSize()},"get"),onChange:o(function(L){ue.setBurstSize(L)},"onChange")},{id:"emitEveryTicks",label:"rate (ticks/burst)",min:1,max:30,step:1,value:C,fmt:o(function(L){return String(L)},"fmt"),get:o(function(){return ue.getEmitEveryTicks()},"get"),onChange:o(function(L){ue.setEmitEveryTicks(L)},"onChange")},{id:"wavelength",label:"wavelength/mass (\u03BB, capacity="+l+")",min:1,max:l,step:1,value:ue.getWavelength(),fmt:o(function(L){return String(L)},"fmt"),get:o(function(){return ue.getWavelength()},"get"),onChange:o(function(L){ue.setWavelength(L)},"onChange")}],{sphereEmitterControl:ue,largeObjects:[],dispose:o(function(){ue.dispose()},"dispose")}}var jf,Om,Em,Sm,_l=ce(()=>{Tf();bm();Df();o(Vi,"clamp");o(xm,"worldCfg");o(Ew,"_worldInitArgs");o(Sw,"initWorld");jf=["R","burstSize","center","chargeMode","emissionBox","emissionBoxSide","emissionShell","emitEveryTicks","fundamentalDimension","fundamentalWaveLength","innerR","is2D","leafDimension","mode","offset","orientationDeg","preset","renderColor","renderShape","sourceShape","stepping","wavelength"],Om=jf.concat(["emissionCap","gateCounter"]),Em=["spherical","hemisphere","laser","drum","particle-walk"],Sm=["skipInit"];o(kw,"_worldFundamentalDimension");o(xr,"setupSphereEmitter3D");xr.WAVELENGTH_DEMO_DIMENSION=2;xr.worldCfg=xm;xr.initWorld=Sw;xr.OPTIONS=jf;xr.PRESETS=Em;xr.SKETCH_OPTIONS=Om;xr.RETIRED_OPTIONS=Sm});function Aw(e){return e=Ua("setupTunnelPointExit.sceneSpec",e,Cm),Tm(e,zo("setupTunnelPointExit.sceneSpec canvasW/canvasH",{w:e.canvasW,h:e.canvasH}))}function Tm(e,t){var r=t.w,n=t.h,i=e.tunnelLength!==void 0?e.tunnelLength:240,a=e.bore!==void 0?e.bore:40,s=e.wallThickness!==void 0?e.wallThickness:10,l=e.wavelengthScale!==void 0?e.wavelengthScale:16,u=e.exitRecenter!==void 0?!!e.exitRecenter:!0,f=!!e.exitPhaseReset,c=e.burstSize!==void 0?e.burstSize:6,h=e.emitEveryTicks!==void 0?e.emitEveryTicks:1,g=Math.round(r*.08),p=Math.round(n/2),m=p-Math.round(a/2),b=g+Math.max(2,Math.round(s/2));return{emitter:{preset:"hemisphere",is2D:!0,center:[b,p],emissionBoxSide:0,chargeMode:"random",fundamentalDimension:km,wavelength:Am,fundamentalWaveLength:4*l,burstSize:c,emitEveryTicks:h},tunnel:{left:g,top:m,length:i,bore:a,wallThickness:s,axis:"x",mode:"directed",exitCollapse:!0,exitRecenter:u,exitPhaseReset:f,name:"point_exit_tunnel",color:[90,120,200]},geom:{left:g,top:m,midY:p,bore:a,exitX:g+i,tunnelLength:i,wavelengthScale:l,effectiveWavelength:Math.floor(xl*l)}}}function ai(e,t){t=Ua("setupTunnelPointExit",t,Lf);var r=Tm(t,zo("setupTunnelPointExit universe.universe_rect",e.universe_rect)),n=r.geom.tunnelLength,i=r.geom.bore,a=r.geom.wavelengthScale,s=r.geom.midY,l=r.geom.exitX,u=t.active!==void 0?!!t.active:!0,f=xr,c=ka("Tunnel");f.initWorld(e,r.emitter);var h=f(e,r.emitter),g=h.sphereEmitterControl;g.setActive(u);var p=new c(e,r.tunnel);e.wavelengthScale=a;var m={setWavelengthScale:o(function(b){var y=Math.max(1,Math.round(b));return a=y,e.wavelengthScale=y,y},"setWavelengthScale"),getWavelengthScale:o(function(){return a},"getWavelengthScale"),getEffectiveWavelength:o(function(){return Math.floor(xl*a)},"getEffectiveWavelength"),setExitPhaseReset:o(function(b){return p.setExitPhaseReset(b)},"setExitPhaseReset"),getExitPhaseReset:o(function(){return!!p.exitPhaseReset},"getExitPhaseReset"),setExitRecenter:o(function(b){return p.setExitRecenter(b)},"setExitRecenter"),getExitRecenter:o(function(){return!!p.exitRecenter},"getExitRecenter"),isExitGateArmed:o(function(){return p.isExitGateArmed()},"isExitGateArmed"),setActive:o(function(b){g.setActive(!!b)},"setActive"),getTunnelLength:o(function(){return n},"getTunnelLength"),getBore:o(function(){return i},"getBore"),getExitX:o(function(){return l},"getExitX"),getMidY:o(function(){return s},"getMidY")};return m.controls=[{id:"wavelengthScale",label:"\u03BB scale (eff \u03BB = 16 \xD7 scale)",min:1,max:24,step:1,value:a,fmt:o(function(b){return String(b)+" (eff \u03BB "+Math.floor(xl*b)+"px)"},"fmt"),get:o(function(){return m.getWavelengthScale()},"get"),onChange:o(function(b){m.setWavelengthScale(b)},"onChange")},{id:"exitRecenter",label:"recenter at exit",kind:"checkbox",value:r.tunnel.exitRecenter,fmt:o(function(b){return b?"on":"off"},"fmt"),get:o(function(){return m.getExitRecenter()},"get"),onChange:o(function(b){m.setExitRecenter(b)},"onChange")},{id:"exitPhaseReset",label:"phase reset at exit",kind:"checkbox",value:r.tunnel.exitPhaseReset,fmt:o(function(b){return b?"on":"off"},"fmt"),get:o(function(){return m.getExitPhaseReset()},"get"),onChange:o(function(b){m.setExitPhaseReset(b)},"onChange")},{id:"tunnelLength",label:"tunnel length (rebuild)",min:60,max:420,step:20,value:n,rebuild:!0,fmt:o(function(b){return String(b)+"px"},"fmt"),get:o(function(){return m.getTunnelLength()},"get"),onChange:o(function(){},"onChange")}],{tunnel:p,emitterControl:g,pointExitControl:m,largeObjects:p.largeObjects,dispose:o(function(){h&&typeof h.dispose=="function"&&h.dispose(),p&&typeof p.dispose=="function"&&p.dispose()},"dispose")}}var km,Am,xl,Lf,Cm,Rm=ce(()=>{Tf();_l();Et();km=2,Am=32,xl=16;o(Aw,"sceneSpec");o(Tm,"_sceneGeometry");Lf=["active","bore","burstSize","emitEveryTicks","exitPhaseReset","exitRecenter","tunnelLength","wallThickness","wavelengthScale"],Cm=Lf.concat(["canvasH","canvasW"]);o(ai,"setupTunnelPointExit");ai.sceneSpec=Aw;ai.FUNDAMENTAL_DIMENSION=km;ai.LEAF_WAVELENGTH_ARG=Am;ai.CAPACITY_OVER_MASS=xl;ai.OPTIONS=Lf;ai.SCENE_SPEC_OPTIONS=Cm});var If={};Oe(If,{Tunnel:()=>yt});function jm(e){return vn(e)}function Lm(e,t,r,n,i,a,s,l){var u={};if(a==="x"?(u.rectA=[e,t-i,r,i],u.rectB=[e,t+n,r,i],u.innerRect=[e,t,r,n],u.gateRect=[e+r-Ol,t,Ol,n],u.midCoord=t+n/2):(u.rectA=[e-i,t,i,r],u.rectB=[e+n,t,i,r],u.innerRect=[e,t,n,r],u.gateRect=[e,t+r-Ol,n,Ol],u.midCoord=e+n/2),l!==null){var f=o(function(c){return[c[0],c[1],s,c[2],c[3],l]},"zs");u.rectA6=f(u.rectA),u.rectB6=f(u.rectB),u.gateRect6=f(u.gateRect),u.innerRect=f(u.innerRect)}return u}function yt(e,t){t=t||{},this.universe=e,this._schemaKind="Tunnel";var r=t.left,n=t.top,i=t.length,a=t.bore;if(!(i>0)||!(a>0))throw new Error("[Tunnel] opts.length and opts.bore must both be positive numbers.");var s=t.wallThickness!==void 0&&t.wallThickness!==null?t.wallThickness:10,l=t.axis==="y"?"y":"x",u=t.depth!==void 0&&t.depth!==null,f=t.z!==void 0&&t.z!==null?t.z:0,c=u?t.depth:null,h=t.color||[90,120,200],g=t.name||"tunnel",p=t.mode!==void 0&&t.mode!==null?t.mode:Dm;if(El.indexOf(p)===-1)throw new Error('[Tunnel] unknown mode "'+p+'". Expected: '+El.join(" | "));var m=p===Sl,b=typeof t.directedAngle=="number"?t.directedAngle:l==="y"?90:0,y=typeof t.redirectSpread=="number"?t.redirectSpread:90,w=typeof t.polarSpread=="number"?t.polarSpread:0,O=!!t.exitCollapse,S=t.exitRecenter!==void 0?!!t.exitRecenter:!0,A=!!t.exitPhaseReset;if((A||t.exitRecenter!==void 0)&&!O)throw new Error("[Tunnel] exitPhaseReset / exitRecenter require exitCollapse \u2014 both are ops on the exit gate, and without the gate there is nothing to carry them. (FAIL-LOUD.)");if((m||O)&&e&&e.withInterQuantumCollisions===!0)throw new Error('[Tunnel] mode:"directed" / exitCollapse require withInterQuantumCollisions:false (the fast path). With inter-quantum collisions ON the collapse point becomes a one-frame-per-tick serializer: the frustration pass reverts the collapse write and KILLS contended quanta, so the scene measures contention rather than the point source. (FAIL-LOUD.)');this.left=r,this.top=n,this.length=i,this.bore=a,this.wallThickness=s,this.axis=l,this.color=h,this.name=g,this.mode=p,m&&(this.directedAngle=b,this.redirectSpread=y,this.polarSpread=w),O&&(this.exitCollapse=!0,this.exitRecenter=S,this.exitPhaseReset=A),u&&(this.z=f,this.depth=c);var C=Lm(r,n,i,a,s,l,f,c),R=C.rectA,Q=C.rectB,Y=this;function H(ee,X){var te={rect:ee,collisionBehavior:m?"nothing":"bounce",name:g+X,color:h};return m&&(te.collectCollided=!0),t.wallOpacity!==void 0&&(te.alpha=t.wallOpacity),c!==null&&(te.z=f,te.depth=c),new we(Y.universe,te)}if(o(H,"mkWall"),this.wallA=H(R,"_A"),this.wallB=H(Q,"_B"),this.walls=[this.wallA,this.wallB],this.largeObjects=[this.wallA.lo,this.wallB.lo],this.innerRect=C.innerRect,this.exitGate=null,this._exitGateMid=null,O){var q=yr,T=$n,J=gn,D=C.gateRect,K=C.midCoord,N=l==="x"?"top":"left",B=l==="x"?"h":"w";this._exitGateMid=K,this._exitPinProp=N,this._exitSizeProp=B;var ne={rect:D,collisionBehavior:"nothing",collectCollided:!0,visible:!1,name:g+"_exitgate",color:h};c!==null&&(ne.z=f,ne.depth=c);var oe=we;this.exitGate=new oe(this.universe,ne),this.exitRecenter=S,this.exitPhaseReset=A,this._applyExitGateProgram(),this.walls.push(this.exitGate),this.largeObjects.push(this.exitGate.lo)}if(this.applyRedirect=null,this._unsubRedirect=null,m){var $=bl,de=vm,ve=l==="y"?"right":"bottom",ue=l==="y"?"left":"top";$.applyLinerScatter(this.wallA.lo,e,ve,{behavior:"ejectY",resetLocalTime:!1}),$.applyLinerScatter(this.wallB.lo,e,ue,{behavior:"ejectY",resetLocalTime:!1}),this.applyRedirect=de(e,{wallHandles:[this.wallA.lo.handle,this.wallB.lo.handle],angleRad:b*Math.PI/180,spreadRad:y*Math.PI/180,speed:null,polarSpreadRad:w*Math.PI/180})}for(var L=0;L<this.walls.length;L++)this.walls[L]._owner=this}var Dm,Sl,El,Ol,Tw,Vo=ce(()=>{Rt();yn();Af();ym();ba();xa();wr();So();Et();Rm();Dm="mirror",Sl="directed",El=[Dm,Sl],Ol=2;o(jm,"_hasZ");o(Lm,"_geometry");o(yt,"Tunnel");Object.defineProperty(yt.prototype,"rect",{get:o(function(){for(var e=1/0,t=1/0,r=-1/0,n=-1/0,i=1/0,a=-1/0,s=!1,l=0;l<this.walls.length;l++){var u=this.walls[l]&&this.walls[l].rect;if(u&&(e=Math.min(e,u.left),t=Math.min(t,u.top),r=Math.max(r,u.left+u.w),n=Math.max(n,u.top+u.h),jm(u))){s=!0;var f=typeof u.d=="number"?u.d:u.w;i=Math.min(i,u.z),a=Math.max(a,u.z+f)}}if(!(!(e<r)||!(t<n))){var c={left:e,top:t,w:r-e,h:n-t};return s&&(c.z=i,c.d=a-i),c}},"get")});yt.prototype._applyExitGateProgram=function(){if(!this.exitGate)return null;var e=yr,t=e.HANDLE_FRAME,r=[];this.exitRecenter&&r.push({set:t+"."+this._exitPinProp,to:e.Bin("-",e.Lit(this._exitGateMid),e.Bin("*",e.Ref(t,this._exitSizeProp),e.Lit(.5)))}),this.exitPhaseReset&&r.push({set:t+".local_time",to:e.Lit(0)});var n=null;return r.length&&(n={on:"collision",ops:r},gn(n,$n(this.exitGate.lo.reposition||null,!1,e.HANDLE_FRAME,e.HANDLE_SELF,e.Lit,e.Ref,e.Cmp,e.Cond,e.Fn))),this.exitGate.lo.program=n,this.universe&&typeof this.universe.updateObjectProperty=="function"&&this.universe.updateObjectProperty(this.exitGate.lo.handle,"LargeObject","program",n),n};yt.prototype.applyProp=function(e,t){var r=yt.LIVE_PROPS[e];if(!r)return!1;if(typeof this[r]!="function")throw new Error('[Tunnel] live prop "'+e+'" is routed to '+r+"() but that setter does not exist. (FAIL-LOUD.)");return this[r](t),!0};yt.LIVE_PROPS={exitRecenter:"setExitRecenter",exitPhaseReset:"setExitPhaseReset",rect:"setRect",left:"setLeft",top:"setTop"};yt.prototype.setRect=function(e){if(!Array.isArray(e)||e.length!==4&&e.length!==6||!e.every(function(O){return typeof O=="number"&&isFinite(O)}))throw new TypeError("[Tunnel.setRect] rect must be the envelope [l,t,w,h] or [l,t,z,w,h,d] of finite numbers; got "+JSON.stringify(e)+". (FAIL-LOUD.)");var t=this.rect,r=jm(t);if(e.length===6&&!r)throw new Error('[Tunnel.setRect] "'+this.name+'" is a flat corridor (built without a depth); a 6-element rect would give it one, but its 3D-ness is compiled into its walls at construction. (FAIL-LOUD.)');var n=e[0],i=e[1],a=e.length===6?e[3]:e[2],s=e.length===6?e[4]:e[3],l=e.length===6?e[2]:r?t.z:null,u=e.length===6?e[5]:r?t.d:null,f=this.wallThickness,c=this.axis,h=a!==t.w||s!==t.h||r&&u!==t.d,g=this.length,p=this.bore;if(h){if(g=c==="x"?a:s,p=(c==="x"?s:a)-2*f,!(g>0)||!(p>0))throw new Error("[Tunnel.setRect] the envelope "+JSON.stringify(e)+" leaves no bore inside two "+f+"px walls. (FAIL-LOUD.)");for(var m=0;m<this.walls.length;m++)this.walls[m].assertOwnsProgram()}var b=c==="x"?n:n+f,y=c==="x"?i+f:i,w=Lm(b,y,g,p,f,c,r?l:0,r?u:null);return this.wallA.setRect(r?w.rectA6:w.rectA),this.wallB.setRect(r?w.rectB6:w.rectB),this.left=b,this.top=y,this.length=g,this.bore=p,r&&(this.z=l,this.depth=u),this.innerRect=w.innerRect,this.exitGate&&(this.exitGate.setRect(r?w.gateRect6:w.gateRect),this._exitGateMid=w.midCoord,this._applyExitGateProgram()),this};yt.prototype.setLeft=function(e){var t=this.rect;return this.setRect([t.left+(e-this.left),t.top,t.w,t.h])};yt.prototype.setTop=function(e){var t=this.rect;return this.setRect([t.left,t.top+(e-this.top),t.w,t.h])};yt.prototype.isExitGateArmed=function(){return!!(this.exitGate&&this.exitGate.lo.program&&this.exitGate.lo.program.ops&&this.exitGate.lo.program.ops.length>0)};yt.prototype.setExitRecenter=function(e){if(!this.exitGate)return!1;var t=!!e;return this.exitRecenter===t||(this.exitRecenter=t,this._applyExitGateProgram()),t};yt.prototype.setExitPhaseReset=function(e){if(!this.exitGate)return!1;var t=!!e;return this.exitPhaseReset===t||(this.exitPhaseReset=t,this._applyExitGateProgram()),t};yt.prototype.applyRedirectIfActive=function(e){this.mode===Sl&&this.applyRedirect&&this.applyRedirect(e)};yt.prototype.attachToRunner=function(e){if(this.mode!==Sl||this._unsubRedirect)return this._unsubRedirect;if(!e||typeof e.addTickListener!="function")return null;var t=this;return this._unsubRedirect=e.addTickListener(function(r){t.applyRedirectIfActive(r)}),this._unsubRedirect};yt.prototype.dispose=function(){if(!this._disposed){this._disposed=!0,this._unsubRedirect&&(this._unsubRedirect(),this._unsubRedirect=null);for(var e=0;e<this.walls.length;e++)this.walls[e]&&typeof this.walls[e].dispose=="function"&&this.walls[e].dispose()}};yt.MODES=El;yt.pointExitSpec=o(function(t){return ai.sceneSpec(t)},"pointExitSpec");Tw={description:"A corridor built from TWO parallel MIRROR walls (guarded bounce) a `bore` apart \u2014 a waveguide / light-pipe. A beam travelling down the bore reflects off the two facing mirrors and stays collimated (no random scatter, no leak through the walls). The group is the single author-surface entity; the two mirror Walls it composes carry its `_owner` up-link. Zero physics of its own.",ux:{resizable:!0,draggable:{"2d":!0},shellRender:"run"},fields:[{name:"rect",type:"rect",engineVisible:!1,live:!0,writeOnly:!0,description:"WRITE-ONLY reposition ADAPTER: the corridor ENVELOPE (both mirrors and the exit gate). A rect write \u2014 the 2D drag, the SPACE carry \u2014 moves the whole Tunnel through Tunnel.setRect (a same-size write is a translation; a resize re-derives length/bore). Its read getter derives the envelope from the members; captureProps SKIPS it via writeOnly:true, so left/top/length/bore stay the captured position authority."},{name:"left",type:"number",constraint:{integer:!0},engineVisible:!0,live:!0,unit:"px",description:"Bore (aperture) left X position (physics pixels). For an X-axis tunnel this is the corridor mouth."},{name:"top",type:"number",constraint:{integer:!0},engineVisible:!0,live:!0,unit:"px",description:"Bore (aperture) top Y position (physics pixels)."},{name:"length",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Corridor travel-axis extent (physics pixels) \u2014 X extent for an X-axis tunnel, Y for a Y-axis tunnel. The mirrors span this length."},{name:"bore",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Clear aperture \u2014 the gap between the two mirror inner faces (physics pixels). The beam passes through the bore; a wider bore lets more through with less collimation."},{name:"wallThickness",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Thickness of each mirror wall in physics pixels (default 10)."},{name:"axis",type:"enum",constraint:{values:{x:"x",y:"y"}},engineVisible:!0,description:"Corridor travel axis: x = horizontal (two wide mirrors above+below the bore; a +x beam reflects its vy); y = vertical (two tall mirrors left+right; a +y beam reflects its vx)."},{name:"z",type:"number",constraint:{integer:!0},engineVisible:!0,unit:"px",description:"Near-face Z of the corridor z-slab (physics pixels). Paired with `depth`: both mirror walls are built as 6-element-rect z-slabs, so the corridor is a real 3D tube whose z-faces also reflect. Inert without `depth` (a flat 2D corridor)."},{name:"depth",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Z extent of the corridor z-slab (physics pixels). OMIT for a flat 2D corridor (the mirror walls stay 4-element rects, unconstrained in z). Supplying it makes each mirror a z-slab spanning z .. z+depth \u2014 the corridor a real tube in space."},{name:"color",type:"rgb",engineVisible:!1,live:!0,description:"Render color [r, g, b] for both mirror walls (render-only). A live edit fans out to both mirrors (the `_owner` fan-out in updateObjectProperty)."},{name:"mode",type:"enum",constraint:{values:Object.fromEntries(El.map(function(e){return[e,e]}))},engineVisible:!0,live:!1,description:"Collision mode. mirror (default) = the guarded-bounce waveguide: a beam reflects off the two facing mirrors and stays collimated. directed = the tunnel acts as a semi-circular EMITTER: each wall hit ejects the quantum back into the bore and re-emits it in a uniformly random FORWARD direction within 180\xB0 of the corridor axis. Construction-level (collection is a registration-time engine flag)."},{name:"directedAngle",type:"number",constraint:{min:0,max:360},engineVisible:!0,live:!1,unit:"deg",visibleWhen:{field:"mode",equals:"directed"},description:"Centre of the forward re-emission fan, in degrees. Omitted = DERIVED from `axis` (0 = +x for an x corridor, 90 = +y for a y one), i.e. the corridor's own travel direction. Set 180/270 for a corridor fed from the far end. The tunnel BODY stays axis-aligned; this aims the re-emission only."},{name:"redirectSpread",type:"number",constraint:{min:0,max:180},engineVisible:!0,live:!1,unit:"deg",visibleWhen:{field:"mode",equals:"directed"},description:"Half-width of the forward fan, in degrees (default 90 = a full 180\xB0 forward fan). The exit azimuth is drawn UNIFORMLY in directedAngle \xB1 this. 0 collapses to a perfectly collimated re-emission along directedAngle."},{name:"exitCollapse",type:"boolean",engineVisible:!0,live:!1,description:"Point-exit gate. Adds a third LargeObject spanning the last 2 columns of the bore at the output mouth; every crossing quantum is pinned to the bore mid-line, so the mouth emits as a one-pixel POINT SOURCE (the self-interference geometry). Composes with either mode. Requires withInterQuantumCollisions:false \u2014 FAIL-LOUD otherwise, because with collisions ON the collapse pixel serializes and kills quanta."},{name:"exitRecenter",type:"boolean",engineVisible:!1,live:!0,visibleWhen:{field:"exitCollapse",truthy:!0},description:'Pin every quantum crossing the exit gate to the bore mid-line \u2014 the point-source collapse. DEFAULT ON. Turning it OFF leaves the exit spatially unchanged, which is what separates "does the point source matter?" from "does coherence matter?" (exitPhaseReset) \u2014 while recentering was mandatory the two were confounded. With BOTH off the gate carries no program at all and stays registered only as an inert collector. LIVE (next collision).'},{name:"exitPhaseReset",type:"boolean",engineVisible:!1,live:!0,visibleWhen:{field:"exitCollapse",truthy:!0},description:"Re-phase-lock the ensemble at the exit gate (appends `set local_time = 0` to the gate program). Default OFF \u2014 a deliberate coherence choice, not a ratified behavior. Whether banding needs it is \u03BB-dependent: at long effective \u03BB the exit is already ~90% phase-aligned and bands survive with it OFF; at short \u03BB the exit is phase-flat and the fan reads smooth OFF, banded ON. PHASE ONLY \u2014 never the decoherence bundle (whose second op redraws charge). LIVE (next collision)."},{name:"polarSpread",type:"number",constraint:{min:0,max:90},engineVisible:!0,live:!1,unit:"deg",visibleWhen:{field:"mode",equals:"directed"},description:"Half-width of the OUT-OF-PLANE (polar) fan, in degrees. 0 (default, even on a 3D corridor) keeps the re-emission in the XY plane \u2014 the angle-uniform case. A non-zero value draws the polar angle uniformly in phi, which over-weights the pole: it is polar-uniform, NOT solid-angle-uniform on the hemisphere."}]};at(yt,{from:new URL("frqtl/parts/Tunnel.js",He()).href,descriptor:Tw,defaults:{length:80,bore:24,wallThickness:10,axis:"x",color:[90,120,200]},palette:{displayName:"Mirror Tunnel",category:"composite",iconHint:"tunnel",rank:2},build:o(function(e,t,r){var n=r,i={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(i[a]=e[a]);var s=i.length!=null?i.length:80,l=i.bore!=null?i.bore:24;i.left==null&&(i.left=Math.round(t.x-s/2)),i.top==null&&(i.top=Math.round(t.y-l/2)),i.length=s,i.bore=l;var u=new n(t.runner.universe,i);return u._schemaKind=r.name,typeof u.attachToRunner=="function"&&u.attachToRunner(t.runner),u},"build")})});var Ff={};Oe(Ff,{Trace:()=>zt});function kl(e,t){var r=t[0]-e[0],n=t[1]-e[1];if(r!==0==(n!==0))throw new Error("[Trace] path leg "+JSON.stringify(e)+"->"+JSON.stringify(t)+" is not cardinal. A Trace routes on the x/y grid only: a diagonal corridor was measured NOT to conduct (G ~ 0.04 vs 1.01 on-axis). Insert a waypoint. (FAIL-LOUD.)");return r>0?{ux:1,uy:0,deg:0,axis:"x"}:r<0?{ux:-1,uy:0,deg:180,axis:"x"}:n>0?{ux:0,uy:1,deg:90,axis:"y"}:{ux:0,uy:-1,deg:270,axis:"y"}}function zt(e,t){t=t||{},this.universe=e,this._schemaKind="Trace";var r=t.path;if(!Array.isArray(r)||r.length<2)throw new Error("[Trace] opts.path must be an array of 2+ [x,y] waypoints. (FAIL-LOUD.)");var n=t.bore!==void 0&&t.bore!==null?t.bore:3,i=t.wallThickness!==void 0&&t.wallThickness!==null?t.wallThickness:6;if(!(n>0)||!(i>0))throw new Error("[Trace] bore and wallThickness must both be positive. (FAIL-LOUD.)");var a=typeof t.cornerSpread=="number"?t.cornerSpread:5,s=t.color||[90,120,200],l=t.name||"trace",u=t.groundGap!==void 0?t.groundGap:4,f=typeof t.cornerSize=="number"?t.cornerSize:Math.max(n,12);this.path=r.map(function(ve){return[ve[0],ve[1]]}),this.bore=n,this.wallThickness=i,this.cornerSpread=a,this.cornerSize=f,this.color=s,this.name=l;var c=yt,h=we;this.segments=[],this.junctions=[],this.caps=[],this.ground=null,this.largeObjects=[],this.walls=[];var g=n/2,p,m,b;for(p=0;p<r.length-1;p++){m=kl(r[p],r[p+1]);var y=f/2,w=p===0?0:y,O=p===r.length-2?0:y,S=r[p][0]+m.ux*w,A=r[p][1]+m.uy*w,C=r[p+1][0]-m.ux*O,R=r[p+1][1]-m.uy*O,Q=(C-S)*m.ux+(R-A)*m.uy;if(Q<=0)throw new Error("[Trace] leg "+p+" is shorter than the corner cells it must join (length "+Q+" after trimming for bore "+n+"). Space the waypoints at least one bore apart. (FAIL-LOUD.)");var Y=new c(e,m.axis==="x"?{left:Math.min(S,C),top:A-g,length:Q,bore:n,wallThickness:i,axis:"x",mode:"mirror",name:l+"_run"+p,color:s}:{left:S-g,top:Math.min(A,R),length:Q,bore:n,wallThickness:i,axis:"y",mode:"mirror",name:l+"_run"+p,color:s});this.segments.push(Y)}for(p=1;p<r.length-1;p++){if(b=kl(r[p-1],r[p]),m=kl(r[p],r[p+1]),m.axis===b.axis)throw new Error("[Trace] waypoint "+p+" does not turn (both legs run on the "+m.axis+" axis). Merge the collinear legs. (FAIL-LOUD.)");var H=r[p][0],q=r[p][1],T=f/2,J=new c(e,{left:H-T,top:q-T,length:f,bore:f,wallThickness:i,axis:m.axis,mode:"directed",directedAngle:m.deg,redirectSpread:a,name:l+"_corner"+p,color:s});this.junctions.push(J);var D=f+2*i,K=m.axis==="y"?[H-T-i,m.uy>0?q-T-i:q+T,D,i]:[m.ux>0?H-T-i:H+T,q-T-i,i,D];this.caps.push(new h(e,{rect:K,collisionBehavior:"bounce",bounceDirection:"reflect",name:(m.axis==="y"?"TOP_":"LEFT_")+l+"_cap"+p,color:s}))}this.inPort=[r[0][0],r[0][1]],this.outPort=[r[r.length-1][0],r[r.length-1][1]];var N=kl(r[r.length-2],r[r.length-1]);if(this.outDirection=N.deg,t.ground){var B=n+2*i,ne=this.outPort[0]+N.ux*u,oe=this.outPort[1]+N.uy*u;this.ground=new h(e,{rect:N.axis==="x"?[N.ux>0?ne:ne-4,oe-B/2,4,B]:[ne-B/2,N.uy>0?oe:oe-4,B,4],collisionBehavior:"destroy",hooks:["count"],name:l+"_ground",color:[60,60,255]})}var $=[];this.segments.forEach(function(ve){$=$.concat(ve.walls)}),this.junctions.forEach(function(ve){$=$.concat(ve.walls)}),$=$.concat(this.caps),this.ground&&$.push(this.ground),this.walls=$;var de=this;$.forEach(function(ve){ve&&ve.lo&&de.largeObjects.push(ve.lo)}),this.segments.concat(this.junctions,this.caps,this.ground?[this.ground]:[]).forEach(function(ve){ve&&(ve._owner=de)}),this._rawDelivered=0,this._window=[],this._unsub=null,this._disposed=!1}var Pf,Al=ce(()=>{Vo();yn();Pf=2;o(kl,"_dir");o(zt,"Trace");zt.prototype.onTick=function(e){for(var t=0;t<this.junctions.length;t++)this.junctions[t].applyRedirectIfActive(e);if(this.ground){var r=this.ground.getCollisionHistogram(e).total;this._window.push(r),this._window.length>251&&this._window.shift(),this._rawDelivered=r}};zt.prototype.attachToRunner=function(e){if(this._unsub||!e||typeof e.addTickListener!="function")return this._unsub||null;var t=this;return this._unsub=e.addTickListener(function(r){t.onTick(r)}),this._unsub};zt.prototype.getDelivered=function(){if(!this.ground)throw new Error("[Trace.getDelivered] this Trace has no ground terminal (construct with `ground:true`). (FAIL-LOUD.)");return this._rawDelivered/Pf};zt.prototype.getCurrent=function(){if(this._window.length<2)return 0;var e=this._window.length-1;return(this._window[e]-this._window[0])/Pf/e};zt.prototype.dispose=function(){if(!this._disposed){this._disposed=!0,this._unsub&&(this._unsub(),this._unsub=null);var e=this.segments.concat(this.junctions);e.forEach(function(t){t&&typeof t.dispose=="function"&&t.dispose()}),this.caps.forEach(function(t){t&&typeof t.dispose=="function"&&t.dispose()}),this.ground&&typeof this.ground.dispose=="function"&&this.ground.dispose()}};zt.lanePitch=function(e,t){return e+2*t};zt.GEOMETRIES=[{bore:3,wallThickness:3,pitch:9,crosstalk:.0098,note:"densest independent lane"},{bore:2,wallThickness:6,pitch:14,crosstalk:0,note:"narrow bore, thick insulation"},{bore:1,wallThickness:10,pitch:21,crosstalk:0,note:"smallest bore that conducts"},{bore:12,wallThickness:6,pitch:24,crosstalk:0,note:"roomy \u2014 the only bore that TURNS well"}];zt.CORNER_THROUGHPUT={0:.935,5:.951,10:.92,20:.881,45:.76,90:.59};zt.CORNER_MECHANISMS={mirrorElbow:{G:.738,sd:.011,part:"Wall{collisionBehavior:'bounce', bounceDirection:'reflect'}"},directedJunction:{G:.951,sd:.005,part:"Tunnel{mode:'directed'}"}};zt.GROUND_COUNTS_PER_ARRIVAL=Pf});var Nf={};Oe(Nf,{SphereEmitter:()=>Le});function Le(e,t){if(this._schemaKind="SphereEmitter",Array.isArray(e)?this._center=e.slice():e&&typeof e=="object"&&t===void 0?(t=e,this._center=null):this._center=null,this._opts=t&&typeof t=="object"?t:{},this._control=null,this._setupResult=null,this.universe=null,this._active=!0,this._emissionCap=void 0,this._gateCounter=void 0,this._gateTickFn=null,this._runner=null,this._opts.emissionCap!=null&&(this._emissionCap=Pm(this._opts.emissionCap),typeof this._opts.gateCounter!="string"||!this._opts.gateCounter))throw new Error(`[SphereEmitter] emissionCap requires gateCounter \u2014 the NAME of the counting Wall (collisionBehavior "nothing" + count hook) whose getLiveCount() is the cap's population authority. An unresolved gate silently running uncapped is the FAIL-LOUD violation this contract closes.`);if(this._opts.gateCounter!=null){if(typeof this._opts.gateCounter!="string"||!this._opts.gateCounter)throw new Error("[SphereEmitter] gateCounter must be a non-empty string (the counting Wall's name).");this._gateCounter=this._opts.gateCounter}}function Pm(e){if(typeof e!="number"||!isFinite(e)||e<1||Math.floor(e)!==e)throw new Error("[SphereEmitter] emissionCap must be an integer >= 1; got "+JSON.stringify(e)+". (Throw-or-apply \u2014 never a silently ignored cap.)");return e}function Fm(e){if(!e._control)throw new Error("[SphereEmitter] not added yet \u2014 call .addTo(universe) before driving the emitter.");return e._control}function Or(e){return{get:o(function(){return this._control?e(this._control,this):void 0},"get")}}var Im,Cw,qo=ce(()=>{Rt();_l();Et();wr();Ut();Im=["emissionCap","gateCounter"];o(Le,"SphereEmitter");o(Pm,"_validateEmissionCap");Le.prototype.addTo=function(e){if(this._control)throw new Error("[SphereEmitter] addTo() called twice \u2014 one SphereEmitter maps to one live emitter. Construct a new SphereEmitter for a second source.");var t=xr,r={};for(var n in this._opts)Object.prototype.hasOwnProperty.call(this._opts,n)&&Im.indexOf(n)===-1&&(r[n]=this._opts[n]);Array.isArray(this._center)&&(r.center=this._center.slice());var i=t(e,r);this.universe=e,this._setupResult=i,this._control=i.sphereEmitterControl;var a=this._control,s=this;return Object.keys(a).forEach(function(l){typeof a[l]=="function"&&typeof s[l]>"u"&&(s[l]=function(){return a[l].apply(a,arguments)})}),this._emissionCap!=null&&this._installEmissionGate(e),this};Le.prototype._installEmissionGate=function(e){var t=this,r=null,n=o(function(a){var s=t._emissionCap;if(s!=null){if(!r){var l=t._runner;if(!l||typeof l.getObjectByName!="function")throw new Error('[SphereEmitter] emissionCap gate cannot resolve gateCounter "'+t._gateCounter+'" \u2014 no runner with getObjectByName() is attached (construct via ObjectFactory/addObject, which threads the runner). FAIL-LOUD, never a silent uncapped run.');var u=l.getObjectByName(t._gateCounter);if(!u)throw new Error('[SphereEmitter] emissionCap gate: gateCounter "'+t._gateCounter+`" names no live object on the runner \u2014 place a counting Wall (collisionBehavior "nothing" + hooks ['count']) with that name. FAIL-LOUD, never a silent uncapped run.`);if(typeof u.getLiveCount!="function")throw new Error('[SphereEmitter] emissionCap gate: "'+t._gateCounter+'" is not a counting Wall (no getLiveCount). FAIL-LOUD, never a silent uncapped run.');r=u}var f=a&&a.experimentTickFunctions?a:t.universe,c=r.getLiveCount(f?f._lastTickData:null);t.setActive(c<s)}},"emissionGateTick");n._emissionGate=!0,e.experimentTickFunctions.push(n),this._gateTickFn=n};o(Fm,"_requireLive");Le.prototype.setCenter=function(e,t,r){var n=Fm(this);return Array.isArray(e)?n.setCenter(e[0],e[1],e.length>2?e[2]:void 0):n.setCenter(e,t,r),this};Le.prototype.setActive=function(e){var t=Fm(this);return this._active=!!e,t.setActive(this._active),this};Le.prototype.setEmissionCap=function(e){return this._emissionCap=e==null?void 0:Pm(e),this};Le.prototype.dispose=function(){if(this._gateTickFn&&this.universe&&Array.isArray(this.universe.experimentTickFunctions)){var e=this.universe.experimentTickFunctions.indexOf(this._gateTickFn);e!==-1&&this.universe.experimentTickFunctions.splice(e,1)}this._gateTickFn=null,this._control&&this._control.dispose(),this._marker&&typeof this._marker.dispose=="function"&&this._marker.dispose()};Le.prototype.attachMarker=function(e){if(!e||typeof e!="object")throw new TypeError("[SphereEmitter.attachMarker] needs the marker LargeObject. (FAIL-LOUD.)");if(this._marker)throw new Error("[SphereEmitter.attachMarker] this emitter already owns a marker \u2014 one emitter, one marker. (FAIL-LOUD.)");if(this._marker=e,e._owner=this,!this._control)throw new Error("[SphereEmitter.attachMarker] addTo() first \u2014 the marker follows the live control's centre write. (FAIL-LOUD.)");return this._control.attachMarker(e),this};Object.defineProperty(Le.prototype,"center",{get:o(function(){return this._control?this._control.getCenter():this._center?this._center.slice():null},"get")});Object.defineProperty(Le.prototype,"active",{get:o(function(){return this._active},"get")});Object.defineProperty(Le.prototype,"control",{get:o(function(){return this._control},"get")});Object.defineProperty(Le.prototype,"controls",{get:o(function(){return this._control?this._control.controls:null},"get")});o(Or,"_liveGetter");Object.defineProperty(Le.prototype,"rect",{get:o(function(){var e=this._control&&typeof this._control.getCenter=="function"?this._control.getCenter():null;if(!(!Array.isArray(e)||typeof e[0]!="number"||typeof e[1]!="number")){var t=Le.MARKER_D,r=typeof e[2]=="number"?e[2]:0;return{left:e[0]-t/2,top:e[1]-t/2,z:r-t/2,w:t,h:t,d:t}}},"get")});Object.defineProperty(Le.prototype,"preset",Or(function(e){return e.getPreset()}));Object.defineProperty(Le.prototype,"chargeMode",Or(function(e){return e.getChargeMode()}));Object.defineProperty(Le.prototype,"burstSize",Or(function(e){return e.getBurstSize()}));Object.defineProperty(Le.prototype,"emitEveryTicks",Or(function(e){return e.getEmitEveryTicks()}));Object.defineProperty(Le.prototype,"wavelength",Or(function(e){return e.getWavelength()}));Object.defineProperty(Le.prototype,"emissionShell",Or(function(e){return e.getEmissionShell()}));Object.defineProperty(Le.prototype,"innerR",Or(function(e){return e.getInnerR()}));Object.defineProperty(Le.prototype,"renderColor",Or(function(e){return e.getRenderColor()}));Object.defineProperty(Le.prototype,"renderShape",Or(function(e){return e.getRenderShape()}));Object.defineProperty(Le.prototype,"fundamentalDimension",Or(function(e){return e.getFundamentalDimension()}));Object.defineProperty(Le.prototype,"leafDimension",Or(function(e){return e.getLeafDimension()}));Object.defineProperty(Le.prototype,"is2D",Or(function(e){return e.getIs2D()}));Object.defineProperty(Le.prototype,"orientationDeg",Or(function(e){return e.getOrientation()}));Object.defineProperty(Le.prototype,"emissionBox",Or(function(e){return e.getEmissionBox()}));Object.defineProperty(Le.prototype,"emissionCap",{get:o(function(){return this._emissionCap},"get")});Object.defineProperty(Le.prototype,"gateCounter",{get:o(function(){return this._gateCounter},"get")});Object.defineProperty(Le.prototype,"fundamentalWaveLength",{get:o(function(){return this._opts&&this._opts.fundamentalWaveLength!==void 0?this._opts.fundamentalWaveLength:64},"get")});Le.prototype.applyProp=function(e,t){var r=this._control;if(!r)return this;switch(e){case"rect":Array.isArray(t)&&t.length===6?r.setCenter(t[0]+t[3]/2,t[1]+t[4]/2,t[2]+t[5]/2):Array.isArray(t)&&t.length===4&&r.setCenter(t[0]+t[2]/2,t[1]+t[3]/2);break;case"center":Array.isArray(t)&&r.setCenter(t[0],t[1],t.length>2?t[2]:void 0);break;case"preset":r.setPreset(t);break;case"chargeMode":r.setChargeMode(t);break;case"burstSize":r.setBurstSize(t);break;case"emitEveryTicks":r.setEmitEveryTicks(t);break;case"wavelength":r.setWavelength(t);break;case"emissionShell":r.setEmissionShell(t);break;case"innerR":r.setInnerR(t);break;case"renderColor":r.setRenderColor(t);break;case"renderShape":r.setRenderShape(t);break;case"leafDimension":r.setLeafDimension(t);break;case"orientationDeg":r.setOrientation(t);break;case"emissionCap":this.setEmissionCap(t);break;case"gateCounter":break;case"fundamentalWaveLength":case"fundamentalDimension":case"is2D":case"emissionBox":break;default:break}return this};Le.FACADE_OPTIONS=Im;Le.MARKER_D=24;Le.worldCfg=o(function(t){return xr.worldCfg(t)},"worldCfg");Cw={description:'A spherical/omni "sun" emitter \u2014 uniform-direction ball-rejected emission (preset spherical/laser/drum/particle-walk). The manipulable palette face over the setupSphereEmitter3D setup factory: pure sugar (a NONE-collision visual marker + a host emit tick-fn), zero physics of its own. Drag the marker to move the emission center live; edit burst/rate/wavelength/charge/preset/shell live; dimension/is2D are boot-level (reload).',ux:{resizable:!1,draggable:{"2d":!0},handles:["move"],shellRender:"design"},fields:[{name:"rect",type:"rect",engineVisible:!1,live:!0,writeOnly:!0,description:"WRITE-ONLY reposition ADAPTER (drag handle). A rect write \u2014 from the visual marker's coupled-move or a rect edit \u2014 maps rect-CENTER \u2192 the emission center (control.setCenter). Its READ getter DERIVES a fresh rect from `center` (PR-1 item iii, for the Design bbox); captureProps SKIPS it via writeOnly:true so `center` stays the single captured position authority. Inspector seeds the vector control from `center` via a FIELD_VALUE_OVERRIDE."},{name:"center",type:"object",engineVisible:!1,live:!1,description:"Emission SOURCE POSITION in absolute canvas px as [x,y,z] (the captured position authority \u2014 codegen round-trips this, not rect). Edited live via the rect adapter / the visual marker drag; shown read-only here."},{name:"preset",type:"enum",constraint:{values:{spherical:"spherical",hemisphere:"hemisphere",laser:"laser",drum:"drum","particle-walk":"particle-walk"}},engineVisible:!1,live:!0,description:"Velocity-range preset: spherical (full ball / the sun), hemisphere (the SAME ball-rejected sampler with the forward axis halved to [0,R] \u2014 180\xB0 forward emission, aimed by orientationDeg), laser (collimated beam), drum (z=0 disk), particle-walk (deterministic +X drift). LIVE (next burst)."},{name:"chargeMode",type:"enum",constraint:{values:{positive:"positive",negative:"negative",random:"random"}},engineVisible:!1,live:!0,description:"Per-emitted-leaf charge: positive (0), negative (1), or random (per-leaf \xB1, the braiding that makes self-interference structure). LIVE (affects the next leaf)."},{name:"burstSize",type:"number",constraint:{min:1,integer:!0},engineVisible:!1,live:!0,description:"Leaves emitted per burst (flux). LIVE (affects the next burst)."},{name:"emitEveryTicks",type:"number",constraint:{min:1,integer:!0},engineVisible:!1,live:!0,unit:"ticks",description:"Ticks between bursts (sustained-emission cadence). LIVE (affects the next burst)."},{name:"emissionCap",type:"number",label:"Population Limit",constraint:{min:1,integer:!0},widgetConfig:{max:12800,step:1},engineVisible:!1,live:!0,description:"Self-throttle target: the emitter deactivates when the live population measured by gateCounter reaches this value and reactivates when it drops below. null/omitted = uncapped (byte-identical to today). LIVE (next tick). Zero physics (SU1) \u2014 pure emission regulation, like the blackbody thermostat."},{name:"gateCounter",type:"string",engineVisible:!1,live:!1,visibleWhen:{field:"emissionCap",present:!0},description:`The NAME of the counting Wall (collisionBehavior:"nothing" + count hook) whose getLiveCount() is this cap's population authority. Resolved lazily by name at tick time (construction-order independent). FAIL-LOUD if absent once emissionCap is set.`},{name:"wavelength",type:"number",constraint:{min:1,integer:!0},engineVisible:!1,live:!0,description:"Per-leaf wavelength arg \u2192 mass=max(1,capacity/wavelength), hence the transverse oscillation period (CLAUDE.md \xA76 fork). A NO-OP until fundamentalDimension is raised (capacity 1 saturates mass). LIVE (affects the next leaf)."},{name:"emissionShell",type:"enum",constraint:{values:{volume:"volume",surface:"surface"}},engineVisible:!1,live:!0,description:"Emission start topology: volume (seed within the box) or surface (velocity-aligned ring launch at innerR \u2014 empty center, sharp bands). LIVE (affects the next leaf)."},{name:"innerR",type:"number",constraint:{min:0,integer:!0},engineVisible:!1,live:!0,unit:"px",description:"Shell radius for emissionShell:surface (0 collapses to the center point; ignored in volume mode). LIVE (affects the next leaf)."},{name:"renderColor",type:"rgb",engineVisible:!1,live:!0,description:"Per-leaf render color override [r,g,b] (render-intent data, zero physics); null = colorless (scheme-driven fullness\u2192ROYGBIV). LIVE (affects the next leaf)."},{name:"renderShape",type:"enum",constraint:{values:{ball:"ball",box:"box",circle:"circle",cube:"cube",sphere:"sphere"}},engineVisible:!1,live:!0,description:`Per-leaf render.shape override (render-intent data, zero physics) \u2014 peer of renderColor. Stamped into string_map['render.shape'] on each emitted leaf via the provider render-intent MERGE seam. Overrides the render-level "Default Shape" (setRenderOption). null/omitted = fall back to the default. LIVE (affects the next leaf).`},{name:"orientationDeg",type:"number",constraint:{min:0,max:360},engineVisible:!1,live:!0,widgetHint:"slider",description:"Emitter orientation in degrees (default 0). The velocity sampler rotates each emitted (vx,vy) by this angle (M5: affects the NEXT leaf), so spinning a constrained/laser emitter sweeps its beam (pulsar); an omni emitter is unaffected. LIVE via control.setOrientation; the LOOK-drive rotation target."},{name:"fundamentalWaveLength",type:"number",constraint:{min:1,integer:!0},engineVisible:!1,live:!1,description:"Init-time wavelengthScale seed (waveLengthMultiplier=floor(fwl/4)); boot-level (set at universe.init \u2014 reload to change). Captured for round-trip."},{name:"fundamentalDimension",type:"number",constraint:{min:0,integer:!0},engineVisible:!1,live:!1,description:"The universe base dimension this emitter inits at; boot-level (reload to change). Raises leaf capacity so the wavelength knob gains leverage. Captured for round-trip."},{name:"leafDimension",type:"number",constraint:{min:0,integer:!0},engineVisible:!1,live:!0,label:"Emit Dimension",widgetHint:"dimension-select",description:"The per-emitter dimension leaves are born at (default = fundamentalDimension). LIVE (host-side addDimension + closure flip; next emitted leaf). A leaf born ABOVE the fundamental is move-gated (Invariant 6A) \u2014 slower/larger/redder, the per-dimension observable. A value BELOW the current fundamental self-lowers the floor universe-globally (a one-way ratchet). Captured for round-trip."},{name:"is2D",type:"boolean",engineVisible:!1,live:!1,description:"Whether the z-axis is inactive (2D disk of directions vs 3D ball); boot-level (set at init via activeAxes \u2014 reload to change). Captured for round-trip."},{name:"emissionBox",type:"object",engineVisible:!1,live:!1,description:"Derived per-axis emission-position box {x,y,z} (subsumes the scalar emissionBoxSide input). Captured for round-trip; frozen when re-passed on reload."}]};at(Le,{from:new URL("frqtl/parts/SphereEmitter.js",He()).href,descriptor:Cw,defaults:{preset:"spherical",is2D:!0},palette:{displayName:"Sphere Emitter",category:"emitter",iconHint:"emitter",rank:0},build:o(function(e,t,r){var n=r,i={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&a!=="name"&&(i[a]=e[a]);t.fromPalette&&i.center==null&&i.offset==null&&typeof t.x=="number"&&typeof t.y=="number"&&(i.center=[t.x,t.y]);var s=new n(i);s._schemaKind=r.name;var l=Se,u=Ee;s._runner=t.runner,s.addTo(t.runner.universe);var f=typeof s.getCenter=="function"?s.getCenter():[t.x,t.y,0],c=n.MARKER_D,h=typeof f[2]=="number"?f[2]:0,g=[Math.round(f[0]-c/2),Math.round(f[1]-c/2),h-c/2,c,c,c];s.name=e.name||"sphere emitter "+t.runner.largeObjects.length;var p=new l(t.runner.universe,g,u.NONE,[],s.name,"closest",null,1,[240,200,80]);return p.drawAsCircle=!0,p.alpha=255,p.shellRender="design",p.shellShape="circle",p._schemaKind="LargeObject",p._designMarker=!0,s.attachMarker(p),s},"build")})});var Mf={};Oe(Mf,{LogicGate:()=>Me});function Me(e,t){t=t||{},this.universe=e,this._schemaKind="LogicGate";var r=yt,n=we,i=zt,a=Le,s=String(t.logic||"").toUpperCase();if(!qn[s])throw new Error("[LogicGate] opts.logic must be one of "+Object.keys(qn).join(", ")+" \u2014 got "+JSON.stringify(t.logic)+". (FAIL-LOUD.)");var l=t.axis||"x";if(l!=="x")throw new Error('[LogicGate] only axis "x" (+x flow) is built and MEASURED. A rotated gate would be an unmeasured part wearing a measured datasheet. Rotate the layout instead. (FAIL-LOUD.)');var u=t.left,f=t.top;if(typeof u!="number"||typeof f!="number")throw new Error("[LogicGate] opts.left and opts.top are required (px). (FAIL-LOUD.)");var c=t.bore!==void 0&&t.bore!==null?t.bore:3,h=t.wallThickness!==void 0&&t.wallThickness!==null?t.wallThickness:6;if(!(c>0)||!(h>0))throw new Error("[LogicGate] bore and wallThickness must both be positive. (FAIL-LOUD.)");var g=t.length!==void 0?t.length:48;if(g<Me.MIN_LENGTH)throw new Error("[LogicGate] opts.length "+g+" is below the measured minimum "+Me.MIN_LENGTH+"px (the supply inlet and the shunt valve would overlap). (FAIL-LOUD.)");var p=t.supplyVoltage!==void 0?t.supplyVoltage:6;this._pinnedHigh=t.thresholdHigh!==void 0,this._pinnedLow=t.thresholdLow!==void 0;var m=this._pinnedHigh?t.thresholdHigh:Me.THRESHOLD_HIGH_FRACTION*p,b=this._pinnedLow?t.thresholdLow:Me.THRESHOLD_LOW_FRACTION*p;if(!(b<m))throw new Error("[LogicGate] thresholdLow ("+b+") must be BELOW thresholdHigh ("+m+") \u2014 the gap IS the hysteresis. (FAIL-LOUD.)");var y=t.name||"gate",w=t.color||[200,170,70],O=i.lanePitch(c,h);this.logic=s,this.left=u,this.top=f,this.bore=c,this.wallThickness=h,this.length=g,this.pitch=O,this.supplyVoltage=p,this.thresholdHigh=m,this.thresholdLow=b,this.windowTicks=t.windowTicks!==void 0?t.windowTicks:20,this.name=y,this.color=w;var S=f+O/2,A=f+O*1.5,C=f+O*2.5;this.inPortA=[u,S],this.inPortB=[u,C],this.outPort=[u+g,A],this.footprint=[u,f,g,O*3];var R=Me.TERMINAL_THICKNESS;this.terminals=[new n(e,{rect:[u,S-O/2,R,O],collisionBehavior:"destroy",hooks:["count"],name:y+"_inA",color:[60,60,255]}),new n(e,{rect:[u,C-O/2,R,O],collisionBehavior:"destroy",hooks:["count"],name:y+"_inB",color:[60,60,255]})],this.channel=new r(e,{left:u,top:A-c/2,length:g,bore:c,wallThickness:h,axis:"x",mode:"mirror",name:y+"_channel",color:w}),this.supplyCap=new n(e,{rect:[u,A-O/2,R,O],collisionBehavior:"destroy",name:y+"_cap",color:[70,70,90]}),this.valve=new n(e,{rect:[u+g-Me.VALVE_INSET,A-O/2,R,O],collisionBehavior:"destroy",name:y+"_valve",color:[220,90,90]}),this.supply=new a([u+Me.SUPPLY_INSET,A],{preset:"laser",is2D:!0,R:24,orientationDeg:0,emissionBoxSide:0,fundamentalDimension:0,burstSize:Math.max(1,p),emitEveryTicks:1,chargeMode:"random",renderColor:[255,120,60]}).addTo(e);var Q=this.terminals.concat(this.channel.walls,[this.supplyCap,this.valve]);this.walls=Q,this.largeObjects=[];var Y=this;Q.forEach(function(H){H&&H.lo&&Y.largeObjects.push(H.lo)}),this.terminals.concat([this.channel,this.supplyCap,this.valve,this.supply]).forEach(function(H){H&&(H._owner=Y)}),this._counts=[[],[]],this._current=[0,0],this._states=[!1,!1],this._out=null,this._unsub=null,this._disposed=!1,this._applyOutput(qn[s](!1,!1))}var qn,Rw,Uf=ce(()=>{Rt();Vo();yn();Al();qo();Et();qn={AND:o(function(e,t){return e&&t},"AND"),OR:o(function(e,t){return e||t},"OR"),XOR:o(function(e,t){return e!==t},"XOR"),NAND:o(function(e,t){return!(e&&t)},"NAND"),NOR:o(function(e,t){return!(e||t)},"NOR"),XNOR:o(function(e,t){return e===t},"XNOR")};o(Me,"LogicGate");Me.TERMINAL_THICKNESS=4;Me.SUPPLY_INSET=8;Me.VALVE_INSET=8;Me.MIN_LENGTH=Me.SUPPLY_INSET+Me.VALVE_INSET+Me.TERMINAL_THICKNESS;Me.THRESHOLD_HIGH_FRACTION=.5;Me.THRESHOLD_LOW_FRACTION=.25;Me.TRUTH=qn;Me.LOGICS=Object.keys(qn);Me.MEASURED={inputGain:1.011,inputGainSpread:.024,outputLevelFraction:1.001,outputLevelSd:.036,outputLowLevel:0,noiseCoefficient:.75,thresholdMarginSd:{4:5.67,6:7.21,8:8.87},reliableLowMarginSd:4,gateLatencyTicks:8,flightPxPerTick:1,levelRestorationSd:.018,chatterTransitions:0};Me.MINIMAL={bore:3,wallThickness:3,length:20,w:20,h:27,area:540};Me.prototype.onTick=function(e){for(var t=zt,r=t.GROUND_COUNTS_PER_ARRIVAL,n=0;n<2;n++){var i=this.terminals[n].getCollisionHistogram(e).total,a=this._counts[n];a.push(i),a.length>this.windowTicks+1&&a.shift();var s=a.length-1;this._current[n]=s>0?(a[s]-a[0])/r/s:0,this._states[n]&&this._current[n]<this.thresholdLow?this._states[n]=!1:!this._states[n]&&this._current[n]>=this.thresholdHigh&&(this._states[n]=!0)}this._applyOutput(qn[this.logic](this._states[0],this._states[1]))};Me.prototype._applyOutput=function(e){e!==this._out&&(this._out=e,this.valve.lo.setActive(!e))};Me.prototype.attachToRunner=function(e){if(this._unsub||!e||typeof e.addTickListener!="function")return this._unsub||null;var t=this;return this._unsub=e.addTickListener(function(r){t.onTick(r)}),this._unsub};Me.prototype.getState=function(){return{a:this._states[0],b:this._states[1],out:!!this._out,currentA:this._current[0],currentB:this._current[1]}};Me.prototype.getOutputLevel=function(){return this._out?this.supplyVoltage:0};Me.prototype.setSupplyVoltage=function(e){return this.supplyVoltage=Math.max(0,Math.round(e)),this.supply.setBurstSize(Math.max(1,this.supplyVoltage)),this.supply.setActive(this.supplyVoltage>0),this._pinnedHigh||(this.thresholdHigh=Me.THRESHOLD_HIGH_FRACTION*this.supplyVoltage),this._pinnedLow||(this.thresholdLow=Me.THRESHOLD_LOW_FRACTION*this.supplyVoltage),this.supplyVoltage};Me.prototype.getSupplyVoltage=function(){return this.supplyVoltage};Me.prototype.setLogic=function(e){var t=String(e||"").toUpperCase();if(!qn[t])throw new Error("[LogicGate.setLogic] unknown logic "+JSON.stringify(e)+" \u2014 expected one of "+Me.LOGICS.join(", ")+". (FAIL-LOUD.)");return this.logic=t,this._applyOutput(qn[t](this._states[0],this._states[1])),t};Me.prototype.getLogic=function(){return this.logic};Me.prototype.footprintArea=function(){return this.footprint[2]*this.footprint[3]};Me.prototype.dispose=function(){this._disposed||(this._disposed=!0,this._unsub&&(this._unsub(),this._unsub=null),this.terminals.forEach(function(e){e.dispose()}),this.channel.dispose(),this.supplyCap.dispose(),this.valve.dispose(),this.supply&&typeof this.supply.dispose=="function"&&this.supply.dispose())};Me.cellSize=function(e,t,r){var n=zt,i=n.lanePitch(e,t),a=r!==void 0?r:48;return{w:a,h:i*3,pitch:i,area:a*i*3}};Rw={description:"A powered logic gate assembled from stock: two counting-Wall ammeter terminals sense the current arriving on two input lanes, a comparator with hysteresis thresholds them into booleans, and one shunt valve either lets the gate's own supply rail reach the outlet or dumps it. Because the output is the gate's OWN rail, its HIGH level is independent of the input levels, so gates cascade without per-stage retuning. Zero physics of its own.",ux:{resizable:!1,draggable:{"2d":!0},shellRender:"run"},fields:[{name:"logic",type:"enum",constraint:{values:Object.fromEntries(Object.keys(qn).map(function(e){return[e,e]}))},engineVisible:!1,live:!0,description:"The comparator row applied to the two sensed inputs. DATA, not geometry: every row builds the identical hardware and differs only in this function, so an inverting gate (NAND/NOR/XNOR) costs exactly what a non-inverting one costs here \u2014 unlike silicon."},{name:"left",type:"number",constraint:{integer:!0},engineVisible:!0,unit:"px",description:"Gate cell left X position (physics pixels). The two input terminal faces and the output-channel inlet all sit on this edge."},{name:"top",type:"number",constraint:{integer:!0},engineVisible:!0,unit:"px",description:"Gate cell top Y position (physics pixels). Input A rides the first lane, the powered output the middle lane, input B the third."},{name:"bore",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Lane aperture in physics pixels \u2014 the same bore the Traces wired to this gate should use. Sets the lane pitch (bore + 2 x wallThickness) and therefore the whole cell height."},{name:"wallThickness",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Lane insulation in physics pixels. This is the knob that sets the shrink floor: too thin and the channel mirrors go transparent, which reads as a dead gate rather than a noisy one."},{name:"length",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Output-channel X extent in physics pixels \u2014 the cell width. The measured floor is 20px (below that the supply inlet and the shunt valve overlap)."},{name:"supplyVoltage",type:"number",constraint:{min:0,integer:!0},engineVisible:!1,live:!0,unit:"quanta/tick",description:"The supply rail: emitter burst per tick, and therefore the gate's HIGH output level in quanta per tick. Raising it raises the output level and (unless the thresholds are pinned) the switching thresholds with it, so the gate stays correctly biased at any rail."},{name:"thresholdHigh",type:"number",constraint:{min:0},engineVisible:!1,live:!0,unit:"quanta/tick",description:"Input current at or above which an input is called HIGH. Defaults to half the rail. Because the sensed current is a counting process, an input must sit several standard deviations clear of this value to be reliably read \u2014 see the part datasheet for the measured margin."},{name:"thresholdLow",type:"number",constraint:{min:0},engineVisible:!1,live:!0,unit:"quanta/tick",description:"Input current below which a HIGH input reverts to LOW. Defaults to a quarter of the rail. The gap up to thresholdHigh IS the hysteresis \u2014 it is what stops an input sitting near its threshold from chattering on shot noise."},{name:"windowTicks",type:"number",constraint:{min:1,integer:!0},engineVisible:!1,live:!0,unit:"ticks",description:"Sliding window over which the input current is averaged. It sets BOTH the sense noise (which falls as 1/sqrt(window)) and half the switching delay \u2014 a longer window is a steadier, slower gate."},{name:"color",type:"rgb",engineVisible:!1,live:!0,description:"Render color [r, g, b] for the output-channel mirrors (render-only). A live edit fans out to both mirrors via the `_owner` fan-out in updateObjectProperty."}]};at(Me,{from:new URL("frqtl/parts/LogicGate.js",He()).href,descriptor:Rw,defaults:{logic:"AND",bore:3,wallThickness:3,length:20,supplyVoltage:6,windowTicks:20,color:[200,170,70]},palette:{displayName:"Logic Gate",category:"circuit",iconHint:"gate",rank:5},build:o(function(e,t,r){var n=r,i=Object.assign({},e),a=i.bore!=null?i.bore:3,s=i.wallThickness!=null?i.wallThickness:3,l=i.length!=null?i.length:20;i.left==null&&(i.left=Math.round(t.x-l/2)),i.top==null&&(i.top=Math.round(t.y-1.5*(a+2*s))),i.bore=a,i.wallThickness=s,i.length=l;var u=new n(t.runner.universe,i);return u._schemaKind=r.name,typeof u.attachToRunner=="function"&&u.attachToRunner(t.runner),u},"build")})});function qi(e,t){t=t||{},this.universe=e,this._schemaKind="Box";var r=t.left,n=t.top,i=t.width,a=t.height,s=t.wallThickness||10,l=t.collisionType||Ee.BOUNCE,u=t.actions||[],f=t.color||[120,120,120],c=t.slit||null,h=r-s,g=n-s,p=i+2*s,m=a+2*s;this.walls=[],this.innerRect={left:r,top:n,w:i,h:a},this.outerRect={left:h,top:g,w:p,h:m},this.wallThickness=s,this.walls.push(new Se(e,[h,g,p,s],l,u,"TOP","bottom",null,1,f)),this.walls.push(new Se(e,[h,g+m-s,p,s],l,u,"BOTTOM","top",null,1,f)),c&&c.wall==="left"?this._createSlittedWall(e,"left",h,g,m,s,c.height,l,u,f):this.walls.push(new Se(e,[h,g,s,m],l,u,"LEFT","right",null,1,f)),c&&c.wall==="right"?this._createSlittedWall(e,"right",h+p-s,g,m,s,c.height,l,u,f):this.walls.push(new Se(e,[h+p-s,g,s,m],l,u,"RIGHT","left",null,1,f));for(var b=0;b<this.walls.length;b++)this.walls[b]._owner=this}var Dw,Nm=ce(()=>{Rt();wr();Ut();$r();Et();o(qi,"Box");qi.prototype._createSlittedWall=function(e,t,r,n,i,a,s,l,u,f){var c=(i-s)/2,h=t==="left"?"right":"left",g=t.toUpperCase();this.walls.push(new Se(e,[r,n,a,c],l,u,g+"_T",h,null,1,f)),this.walls.push(new Se(e,[r,n+i-c-1,a,c],l,u,g+"_B",h,null,1,f))};qi.prototype.setCollisionType=function(e){for(var t=0;t<this.walls.length;t++)this.walls[t].setCollisionType(e)};qi.prototype.setActive=function(e){for(var t=0;t<this.walls.length;t++)this.walls[t].setActive(e)};qi.prototype.dispose=function(){for(var e=0;e<this.walls.length;e++)this.walls[e].dispose()};Dw={description:"A rectangular enclosure built from 4 LargeObject walls (top, bottom, left, right). Any wall can optionally have a slit opening. Used to confine particles, build cavities, or create directed channels. Inner dimensions define the open cavity; walls extend outward by wallThickness.",fields:[{name:"left",type:"number",constraint:{integer:!0},engineVisible:!0,description:"Inner box left X position (physics pixels). The outer wall begins at left - wallThickness."},{name:"top",type:"number",constraint:{integer:!0},engineVisible:!0,description:"Inner box top Y position (physics pixels). The outer wall begins at top - wallThickness."},{name:"width",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Inner box width (physics pixels). Outer width = width + 2 * wallThickness."},{name:"height",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Inner box height (physics pixels). Outer height = height + 2 * wallThickness."},{name:"wallThickness",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Thickness of each wall in physics pixels (default 10). Walls extend outward from the inner box."},{name:"collisionType",type:"enum",constraint:{values:Ee},engineVisible:!0,description:"Collision type applied to all four walls (e.g. BOUNCE confines particles inside)."},{name:"actions",type:"enum-set",constraint:{values:st},engineVisible:!0,description:"Actions applied on collision for all four walls (e.g. [BOUNCE, ABSORB])."},{name:"color",type:"rgb",engineVisible:!1,live:!0,description:"Render color [r, g, b] for all four walls (render-only). A live edit fans out to every wall the group owns (the `_owner` fan-out in updateObjectProperty)."}]};at(qi,{from:new URL("frqtl/objects/objects/Box.js",He()).href,descriptor:Dw,defaults:{left:60,top:60,width:80,height:80,wallThickness:10,collisionType:"BOUNCE",actions:[],color:[120,120,120]},build:o(function(e,t,r){var n=r,i=new n(t.runner.universe,Object.assign({left:e.left!=null?e.left:Math.round(t.x-40),top:e.top!=null?e.top:Math.round(t.y-40),width:80,height:80,wallThickness:10,collisionType:"BOUNCE",actions:[],color:[120,120,120]},e));return i._schemaKind=r.name,i},"build")})});function jw(e,t){for(var r=t.burstSize,n=0;n<r&&t.remainingQuanta>0;n++)for(var i=t.sourceRects,a=0;a<i.length&&t.remainingQuanta>0;a++){var s=i[a],l=s[0]+e.random()*s[2],u=s[1]+e.random()*s[3],f=t.vx,c=t.vy,h=null;if(t.randomDirection)if(t.zIsotropy){var g=e.random()*2*Math.PI,p=e.random()*2-1,m=Math.sqrt(Math.max(0,1-p*p)),b=Math.sqrt(f*f+c*c)||1;f=Math.cos(g)*m*b,c=Math.sin(g)*m*b,h=p*b}else{var y=e.random()*2*Math.PI,w=Math.sqrt(f*f+c*c)||1;f=Math.cos(y)*w,c=Math.sin(y)*w}var O;t.charge===null||t.charge===void 0?O=e.random()<.5?0:1:O=t.charge==="Positive"||t.charge==="POSITIVE"?0:1;var S=t.fundamentalDim!=null?t.fundamentalDim:null,A=e.makeLeafFrame(l,u,S,t.wavelength!==null&&t.wavelength!==void 0?t.wavelength:0,f,c,!!t.wrap,O,t.color||null,t.renderShape!=null&&t.renderShape!==""?t.renderShape:null,t.renderOutline!=null?t.renderOutline:null);if(A!==null){e.injectFrame(A);var C=t.zMin!==null&&t.zMin!==void 0;if(C||h!==null){var R=e.getFrameQuantumId(A);if(C){var Q=t.zDepth!==null&&t.zDepth!==void 0?t.zDepth:0,Y=t.zMin+(Q>0?e.random()*Q:0);e.setFrameProperty(R,"z",Y)}h!==null&&e.setFrameProperty(R,"vz",h)}t.remainingQuanta--}}}function Tl(e,t){return function(){return t.tombstoned||!t.active?[]:t.remainingDelay>0?(t.remainingDelay--,[]):t.remainingQuanta<=0?[]:t.everyNTicks!==null&&t.everyNTicks!==void 0&&t.everyNTicks>1&&(t._rateCounter=(t._rateCounter||0)+1,t._rateCounter%t.everyNTicks!==0)?[]:(jw(e,t),[])}}var zf=ce(()=>{"use strict";o(jw,"_fireBurst");o(Tl,"buildEmitterTickFn")});var Bo,Vf=ce(()=>{Bo=Object.freeze({DetectorWall:"Wall{ collisionBehavior:'destroy', hooks:['count'] } (preset 'detector-screen')",SlitScreen:"Wall{ collisionBehavior:'destroy' } slabs + Tunnel{ mode:'directed', exitCollapse }",DSEWall:"Wall{ collisionBehavior:'destroy' } slabs + one Tunnel{ mode:'directed' } per passage",SlitLightSource:"SphereEmitter{ preset:'laser' }",QuantumEmitter:"SphereEmitter",PointSource:"SphereEmitter{ preset:'drum' | 'spherical' }",DirectedTunnel:"Tunnel{ mode:'directed' }",LightSource:"SphereEmitter{ preset:'hemisphere' | 'laser' } + Tunnel",Tube:"Tunnel (with Wall end caps)",ChamberEmitter:"SphereEmitter + Tunnel (with Wall end caps)",Gun:"Tunnel + SphereEmitter, composed at the sketch level",Bullet:"Wall{ collisionBehavior:'bounce' } moved by a sketch tick-fn through setRect",Box:"four Wall{ collisionBehavior:'block' } slabs",OvenBox:"Wall{ collisionBehavior:'absorb' } + SphereEmitter{ emissionCap, gateCounter }",CircuitGate:"LogicGate (the stock V2 gate: Wall{'destroy',['count']} input ammeters + Tunnel{'mirror'} channel + SphereEmitter rail + Wall{'destroy'} shunt valve)",CircuitProbe:"Wall preset 'transparent-probe'",LeafField:"(archived \u2014 no V2 successor)",EgptFractal:"(archived \u2014 no V2 successor)"})});function qf(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(qf);var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=qf(e[r]));return t}function Lw(e,t){var r=qf(Ke.defaultPropsFor(e));return Object.assign({},r,t||{})}function Iw(e){if(e!=="SphereEmitter")return[];var t=[],r=xr,n=Le;return r.OPTIONS&&(t=t.concat(r.OPTIONS)),r.RETIRED_OPTIONS&&(t=t.concat(r.RETIRED_OPTIONS)),n.FACADE_OPTIONS&&(t=t.concat(n.FACADE_OPTIONS)),t}function Pw(e,t){if(t){var r=Ke.get(e);if(!(!r||!r.fields)){var n={};r.fields.forEach(function(s){n[s.name]=!0}),Object.keys(Ke.defaultPropsFor(e)).forEach(function(s){n[s]=!0}),Um.forEach(function(s){n[s]=!0}),Iw(e).forEach(function(s){n[s]=!0});var i=Object.keys(t).filter(function(s){return!n[s]});if(i.length){var a=r.fields.map(function(s){return s.name}).sort();throw new Error('[ObjectFactory] create("'+e+'"): unknown prop key'+(i.length>1?"s":"")+" "+i.map(function(s){return'"'+s+'"'}).join(", ")+'. The builder reads only declared props, so this would have been merged in, read by nobody, and the object built with ITS OWN default \u2014 a different scene than the one you wrote, with no signal. "'+e+'" declares: '+a.join(", ")+". Construction adapters: "+Um.slice().sort().join(", ")+".")}}}}function Fw(e,t){if(t){var r=Ke.get(e);if(!(!r||!r.fields)){var n=r.fields.filter(function(a){return a.writeOnly===!0&&t[a.name]!==void 0});if(n.length){var i=r.fields.filter(function(a){return!a.writeOnly}).map(function(a){return a.name});throw new Error('[ObjectFactory] create("'+e+'"): "'+n[0].name+'" is a write-only reposition adapter (it moves a built '+e+"), not a construction key. Declare the position with the fields the part is built from: "+i.join(", ")+". (FAIL-LOUD.)")}}}}function Cl(e,t){return e.declared.filter(function(r){return r._schemaKind===t}).length}var Um,Bf,Rl=ce(()=>{Un();Et();_l();qo();Vf();o(qf,"_deepCopy");o(Lw,"_mergeProps");Um=["x","y","w","h","left","top","rect","layer","name","preset","_wavelength","_optColor","_emergentPhysics"];o(Iw,"_forwardedVocabulary");o(Pw,"_assertPropKeys");o(Fw,"_refuseWriteOnlyKeys");o(Cl,"declaredCount");Bf={create:o(function(e,t,r){if(!r||!r.runner)throw new Error('[ObjectFactory] create("'+e+'"): ctx.runner is required \u2014 pass { runner, x, y }.');if(typeof e=="function"){if(!Xt(e))throw new Error("[ObjectFactory] create: the class "+(e.name||"(anonymous)")+" is not a registered kind in this realm \u2014 "+$s(e.name||"?")+". (FAIL-LOUD.)");e=e.name}var n=Xt(e);if(!n){var i='[ObjectFactory] create: unknown kind "'+e+'". Registered kinds: '+Bf.kinds().slice().sort().join(", ")+". The "+$s(e)+".";throw Object.prototype.hasOwnProperty.call(Bo,e)&&(i+=' "'+e+'" is a retired V1 part, not a published part \u2014 compose '+Bo[e]+" instead."),new Error(i+" (FAIL-LOUD.)")}if(typeof n.build!="function")throw new Error('[ObjectFactory] create: kind "'+e+'" registers a descriptor only \u2014 it is not constructed by ObjectFactory; construct it with new '+e+"(\u2026) ("+n.from+"). (FAIL-LOUD.)");Pw(e,t),Fw(e,t);var a=Lw(e,t),s=r.runner,l=new Set(s.largeObjects),u=s.universe&&Array.isArray(s.universe.experimentTickFunctions)?s.universe.experimentTickFunctions:null,f=new Set(u||[]),c=n.build(a,r,n.Class);if(c===null||typeof c!="object")throw new Error('[ObjectFactory] create("'+e+'"): the builder returned '+(c===null?"null":typeof c)+", not a handle. Every kind returns the object it built or throws naming what is missing \u2014 a non-handle here is a part silently absent from the scene. (FAIL-LOUD.)");if(typeof s.declare!="function")throw new Error('[ObjectFactory] create("'+e+'"): ctx.runner has no declare() \u2014 the runner (FrqtlApp) owns the declared-object registry every created part is recorded in. (FAIL-LOUD.)');var h=s.largeObjects.filter(function(m){return!l.has(m)});if(!h.length)throw new Error('[ObjectFactory] create("'+e+'"): the build put nothing in the world \u2014 every part draws at least one LO, so a part with none is silently absent from the scene. (FAIL-LOUD.)');var g=s.universe&&Array.isArray(s.universe.experimentTickFunctions)?s.universe.experimentTickFunctions:[],p=g.filter(function(m){return!f.has(m)});return s.declare(c,h,p,{kind:e}),c},"create"),list:o(function(){return Ke.placeableCatalog()},"list"),kinds:o(function(){return Aa().filter(function(e){return typeof Xt(e).build=="function"})},"kinds")}});function Uw(e){if(e==null)return"random";if(typeof e=="string"){var t=e.toUpperCase();if(t==="POSITIVE"||e==="Positive"||e==="+")return"positive";if(t==="NEGATIVE"||e==="Negative"||e==="-")return"negative"}return e===0?"positive":e===1?"negative":"random"}function zw(e){return e==="positive"?"POSITIVE":e==="negative"?"NEGATIVE":null}function Wo(e,t){return String(e)+":"+String(!!t)}function Dt(e,t,r,n,i,a,s,l,u,f,c,h){i=i!==void 0?i:1,a===void 0&&(a=null),s=s!==void 0?s:!0,l=l!==void 0?l:!1,u=u!==void 0?u:1/0,f=f!==void 0?f:0,c=c!==void 0?c:!1,h=h||{};var g=h.wavelength!==void 0?h.wavelength:null,p=h.zMin!==void 0?h.zMin:null,m=h.zDepth!==void 0?h.zDepth:null,b=!!h.zIsotropy;this.universe=e,this._schemaKind="QuantumEmitter",this.vx=r,this.vy=n,this.burst_size=i,this.auto_fire=s,this.colorOverride=null,this.renderShape=null,this.renderOutline=null,this.wavelength=g,this.quantum_limit=u===1/0?null:u,this.delay=f,this.wrap=c,this.source_rects=(t||[]).map(function(y){return Nw(y)}),this._chargeMode=Uw(a),this._random_direction=!!l,this._specTemplate={source_rects:this.source_rects,vx:r,vy:n,burst_size:i,auto_fire:s,quantum_limit:this.quantum_limit,delay:f,wrap:c,wavelength:g,zMin:p,zDepth:m,zIsotropy:b},this._emitterMap={},this._ensureAndActivate(this._chargeMode,this._random_direction),this.handle=this._primaryHandle()}var Nw,Mw,Vw,zm=ce(()=>{Rt();wr();zf();Et();Ut();Di();Rl();Nw=Se.rectToArray,Mw=Tl;o(Uw,"_chargeToMode");o(zw,"_modeToCharge");o(Wo,"_handleKey");o(Dt,"QuantumEmitter");Dt.prototype._ensureHandle=function(e,t){var r=Wo(e,t);if(this._emitterMap[r]!==void 0)return this._emitterMap[r];var n=this._specTemplate,i={sourceRects:(n.source_rects||[]).map(function(s){return Array.isArray(s)?s:[s.left,s.top,s.w,s.h]}),vx:n.vx||0,vy:n.vy||0,burstSize:n.burst_size||1,charge:e,randomDirection:!!t,quantumLimit:n.quantum_limit!==void 0&&n.quantum_limit!==null?n.quantum_limit:1/0,remainingQuanta:n.quantum_limit!==void 0&&n.quantum_limit!==null?n.quantum_limit:1/0,delay:n.delay||0,remainingDelay:n.delay||0,active:n.auto_fire!==void 0?n.auto_fire:!0,tombstoned:!1,color:this.colorOverride||null,renderShape:this.renderShape||null,renderOutline:this.renderOutline!=null?this.renderOutline:null,wrap:!!n.wrap,wavelength:n.wavelength||null,fundamentalDim:null,zMin:n.zMin!==void 0&&n.zMin!==null?n.zMin:null,zDepth:n.zDepth!==void 0&&n.zDepth!==null?n.zDepth:null,zIsotropy:!!n.zIsotropy},a=Mw(this.universe,i);return a._emState=i,this.universe.experimentTickFunctions.push(a),this._emitterMap[r]=i,i};Dt.prototype._ensureAndActivate=function(e,t){var r=!!t,n=this,i=[];e==="both"?(i.push({charge:"POSITIVE",rd:r}),i.push({charge:"NEGATIVE",rd:r})):i.push({charge:zw(e),rd:r});for(var a=0;a<i.length;a++)n._ensureHandle(i[a].charge,i[a].rd);for(var s={},l=0;l<i.length;l++)s[Wo(i[l].charge,i[l].rd)]=!0;for(var u=Object.keys(n._emitterMap),f=0;f<u.length;f++){var c=u[f];n._emitterMap[c].active=!!s[c]}};Dt.prototype._primaryHandle=function(){var e=this._random_direction,t=this._chargeMode,r;if((t==="both"||t==="positive")&&(r=Wo("POSITIVE",e),this._emitterMap[r]!==void 0))return this._emitterMap[r];if(t==="negative"&&(r=Wo("NEGATIVE",e),this._emitterMap[r]!==void 0))return this._emitterMap[r];if(r=Wo(null,e),this._emitterMap[r]!==void 0)return this._emitterMap[r];var n=Object.keys(this._emitterMap);return n.length>0?this._emitterMap[n[0]]:null};Dt.prototype.forEachHandle=function(e){for(var t=Object.keys(this._emitterMap),r=0;r<t.length;r++)e(this._emitterMap[t[r]])};Dt.prototype._activeHandles=function(){for(var e=Object.keys(this._emitterMap),t=[],r=0;r<e.length;r++){var n=this._emitterMap[e[r]];n.active&&t.push(n)}return t};Object.defineProperty(Dt.prototype,"chargeMode",{get:o(function(){return this._chargeMode},"get"),set:o(function(e){var t={random:!0,positive:!0,negative:!0,both:!0};if(!t[e])throw new TypeError('[QuantumEmitter] Invalid chargeMode "'+e+'". Expected: random | positive | negative | both');this._chargeMode=e,this._ensureAndActivate(e,this._random_direction),this.handle=this._primaryHandle()},"set"),enumerable:!0,configurable:!0});Object.defineProperty(Dt.prototype,"random_direction",{get:o(function(){return this._random_direction},"get"),set:o(function(e){var t=!!e;this._random_direction=t,this._ensureAndActivate(this._chargeMode,t),this.handle=this._primaryHandle()},"set"),enumerable:!0,configurable:!0});Dt.prototype.setActive=function(e){this.auto_fire=e;var t=this;if(e)this._ensureAndActivate(this._chargeMode,this._random_direction);else for(var r=Object.keys(this._emitterMap),n=0;n<r.length;n++)t._emitterMap[r[n]].active=!1};Dt.prototype.setVelocity=function(e,t){this.vx=e,this.vy=t,this._specTemplate.vx=e,this._specTemplate.vy=t;for(var r=Object.keys(this._emitterMap),n=0;n<r.length;n++)this._emitterMap[r[n]].vx=e,this._emitterMap[r[n]].vy=t};Dt.prototype.setBurstSize=function(e){this.burst_size=e,this._specTemplate.burst_size=e;for(var t=Object.keys(this._emitterMap),r=0;r<t.length;r++)this._emitterMap[t[r]].burstSize=e};Dt.prototype.setWavelength=function(e){this.wavelength=e,this._specTemplate.wavelength=e;for(var t=Object.keys(this._emitterMap),r=0;r<t.length;r++)this._emitterMap[t[r]].wavelength=e};Dt.prototype.setSourceRect=function(e){var t=e&&e.slice?e.slice():e;this._marker&&this._marker.setRect([t[0],t[1],t[2],t[3]]),this.source_rects=[t],this._specTemplate.source_rects=this.source_rects;for(var r=Object.keys(this._emitterMap),n=0;n<r.length;n++)this._emitterMap[r[n]].sourceRects=[t.slice()]};Dt.prototype.dispose=function(){if(!this._disposed){this._disposed=!0;for(var e=Object.keys(this._emitterMap),t=[],r=0;r<e.length;r++){var n=this._emitterMap[e[r]];n.tombstoned=!0,n.active=!1,t.push(n)}if(this.universe&&Array.isArray(this.universe.experimentTickFunctions))for(var i=this.universe.experimentTickFunctions,a=i.length-1;a>=0;a--)i[a]._emState&&t.indexOf(i[a]._emState)!==-1&&i.splice(a,1);this._marker&&typeof this._marker.dispose=="function"&&this._marker.dispose()}};Dt.prototype.attachMarker=function(e){if(!e||typeof e!="object")throw new TypeError("[QuantumEmitter.attachMarker] needs the marker LargeObject. (FAIL-LOUD.)");if(this._marker)throw new Error("[QuantumEmitter.attachMarker] this emitter already owns a marker. (FAIL-LOUD.)");return this._marker=e,e._owner=this,this};Vw={description:'A particle emitter that fires leaf quanta (particles) from one or more source rectangles. Supports directed or random emission, charge polarity, burst-size (amperage), and velocity (voltage direction). The chargeMode/random_direction sugar layer composes multiple underlying engine handles to implement "both" charge and random direction without engine changes.',fields:[{name:"rect",type:"rect",engineVisible:!0,description:"Canonical bounding rect "+Ot(4)+" \u2014 repositions the single emission source rect. Routed through QuantumEmitter.setSourceRect() (mutates emState.sourceRects directly \u2014 the RETIRED provider ABI updateEmitterSourceRects no longer exists post-G-EMIT-2). The emitter moves its own marker."},{name:"source_rects",type:"rect-array",engineVisible:!0,description:"Emission regions as array of "+Ot(4)+" rects"},{name:"vx",type:"number",constraint:{integer:!1},engineVisible:!0,unit:"px/tick",description:"Initial X velocity of emitted particles (pixels/tick). Positive = rightward, negative = leftward."},{name:"vy",type:"number",constraint:{integer:!1},engineVisible:!0,unit:"px/tick",description:"Initial Y velocity of emitted particles (pixels/tick). Positive = downward (screen coords), negative = upward."},{name:"burst_size",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Number of particles fired per burst (amperage). Higher values produce more particles per tick; lower values reduce flux."},{name:"auto_fire",type:"boolean",engineVisible:!0,description:"Whether the emitter fires automatically every tick. false = must be triggered manually (e.g. by a tick function or the inspector)."},{name:"quantum_limit",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Maximum total quanta to emit (null/Infinity = unlimited). The emitter auto-deactivates after reaching this count."},{name:"delay",type:"number",constraint:{min:0,integer:!0},engineVisible:!0,unit:"ticks",description:"Ticks between bursts. 0 = fire every tick; N = fire once every N+1 ticks."},{name:"wrap",type:"boolean",engineVisible:!0,description:"Wrap emitted particles at canvas boundaries instead of letting them escape."},{name:"colorOverride",type:"rgb",engineVisible:!1,description:"Override render color for emitted particles [r, g, b] (render-only; stored on the emitter wrapper)"},{name:"chargeMode",type:"enum",constraint:{values:{random:"random",positive:"positive",negative:"negative",both:"both"}},engineVisible:!1,description:"Charge mode (user-facing sugar): random = null charge, positive, negative, or both (two co-located emitters). Composes underlying emitter handle-programs by toggling their active flag \u2014 no engine ABI change. Use this instead of the raw charge param."},{name:"random_direction",type:"boolean",engineVisible:!1,description:"Randomize emission direction each burst (sugar layer). Registers a new underlying handle with rd=true \u2014 no engine ABI change."},{name:"layer",type:"number",constraint:{min:0,integer:!0},engineVisible:!1,description:"Dimension layer this emitter targets (0 = fundamental; null = default). Emitted particles are placed in this layer. Stored on the emitter wrapper; no engine ABI change required."}]};at(Dt,{from:new URL("frqtl/objects/objects/QuantumEmitter.js",He()).href,descriptor:Vw,defaults:{source_rects:[[50,95,10,10]],vx:1,vy:0,burst_size:1,chargeMode:"random",auto_fire:!0,random_direction:!1,quantum_limit:null,delay:0,wrap:!1},build:o(function(e,t,r){var n=r,i=Se,a=Ee,s=20,l=20,u;if(e.rect)u=[e.rect.left||0,e.rect.top||0,e.rect.w||s,e.rect.h||l];else if(e.source_rects&&e.source_rects.length){var f=e.source_rects[0];u=f.slice?f.slice():f}else u=[Math.round(t.x-s/2),Math.round(t.y-l/2),s,l];var c=new n(t.runner.universe,[u.slice?u.slice():u],e.vx!=null?e.vx:1,e.vy!=null?e.vy:0,e.burst_size!=null?e.burst_size:1,null,e.auto_fire!=null?e.auto_fire:!0,e.random_direction!=null?e.random_direction:!1,e.quantum_limit!=null?e.quantum_limit:1/0,e.delay!=null?e.delay:0,e.wrap||!1);c._schemaKind=r.name,e.chargeMode&&(c.chargeMode=e.chargeMode),e.colorOverride&&(c.colorOverride=e.colorOverride);var h=e.layer!=null?[e.layer]:null,g=e.name||"emitter "+Cl(t.runner,"QuantumEmitter");c.name=g;var p=new i(t.runner.universe,[u[0],u[1],u[2]||s,u[3]||l],a.NONE,[],g,"closest",h,1,e.color||[80,200,80]);return p.drawAsCircle=!0,p._schemaKind="LargeObject",c.attachMarker(p),c},"build")})});var Wf={};Oe(Wf,{OvenBox:()=>Bn});function qw(e,t,r){var n=yr,i=n.Lit,a=n.Ref,s=n.Bin,l=n.Cmp,u=n.Cond,f=n.Fn,c=n.HANDLE_FRAME,h=n.HANDLE_SELF,g=[],p=xo,m=p.buildEjectOps(e,c,h,i,a,s,l,u,f);if(!m)return null;for(var b=0;b<m.length;b++)g.push(m[b]);if(r){var y=p.buildVelocityFlipOp(t,c,i,a,s);y&&g.push(y)}if(g.length===0)return null;var w=xo,O=w.buildTriggerExpr(e,!0,c,h,i,a,l,u,f),S={on:"collision",ops:g};return w.applyProgramTrigger(S,O),S}function Bn(e,t){t=t||{},this.universe=e,this._schemaKind="OvenBox",this.name=t.name||"oven",this.temperature=t.temperature||300;var r=t.wallThickness||10,n=t.slitHeight||60,i=t.slitWall||"right",a=t.layer3!==void 0?t.layer3:!0,s=a&&(t.layer4!==void 0?t.layer4:!0);this.box=new qi(e,{left:t.left,top:t.top,width:t.width,height:t.height,wallThickness:r,collisionType:Ee.NONE,actions:[],color:t.color||[120,120,120],slit:{wall:i,height:n}}),this.walls=this.box.walls;var l=t.left,u=t.top,f=t.width,c=t.height;if(a)for(var h=0;h<this.walls.length;h++){var g=this.walls[h],p=qw(g.reposition,g.name,s);p&&e.updateObjectProperty(g.handle,"LargeObject","program",p)}var m=l-r,b=u-r,y=f+2*r,w=c+2*r;this.emitters=[],this.emitters.push(new Dt(e,[[m+r+4,b+2,1,w-4]],1,0,1,null,!1,!1,1/0,0)),this.emitters.push(new Dt(e,[[m+y-r-4,b+2,1,w-4]],-1,0,1,null,!1,!1,1/0,0)),this.emitters.push(new Dt(e,[[m+2*r+2,b+r+5,y-2*r-4,1]],0,1,1,null,!1,!1,1/0,0)),this.emitters.push(new Dt(e,[[m+2*r+2,b+w-r-2,y-2*r-4,1]],0,-1,1,null,!1,!1,1/0,0)),this.box._owner=this;for(var O=0;O<this.emitters.length;O++)this.emitters[O]._owner=this;var S=t.countSource||"active-quanta";if(this._countSource=S,this.ovenHandle=null,this._counterWall=null,S==="oven-rect"){var A=new we(e,{rect:[l,u,f,c],collisionBehavior:"nothing",visible:!1,name:"oven_counter"});A._owner=this,this._counterWall=A;var C=yr,R=C.Lit,Q=C.Ref,Y=C.Bin,H=C.Fn,q=C.HANDLE_FRAME,T=C.HANDLE_SELF,J=xo,D=J.buildTriggerExpr(null,!1,q,T,R,Q,function(B,ne,oe){return{kind:"Cmp",op:B,a:ne,b:oe}},function(B,ne,oe){return{kind:"Cond",test:B,then:ne,else:oe}},H),K={on:"collision",ops:[{set:T+".count",to:Y("+",Q(T,"count"),R(1))}]};J.applyProgramTrigger(K,D),A.lo.program=K,e&&typeof e.updateObjectProperty=="function"&&e.updateObjectProperty(A.lo.handle,"LargeObject","program",K),this.ovenHandle=A.lo.handle;var N=this;this.thermostatStep=function(B){e.updateObjectProperty(N.ovenHandle,"LargeObject","count",0);var ne=0;B&&B.objects&&B.objects[N.ovenHandle]!==void 0&&(ne=B.objects[N.ovenHandle].count||0);var oe=0;ne<N.temperature&&(oe=Math.max(1,Math.floor((N.temperature-ne)/N.emitters.length)));for(var $=0;$<N.emitters.length;$++)oe>0&&N.emitters[$].setBurstSize(oe),N.emitters[$].setActive(oe>0)}}}var Bw,Gf=ce(()=>{Rt();Nm();zm();wr();Ut();$r();yn();ba();xa();Et();o(qw,"makeEjectProgram");o(Bn,"OvenBox");Bn.prototype.getTemperatureTickFunction=function(){if(this._countSource==="oven-rect")throw new Error("[OvenBox] getTemperatureTickFunction() is not applicable when countSource='oven-rect'. Use thermostatStep(tickData) instead \u2014 call it after every doTick() in your harness.");var e=this;return function(){var t=typeof e.universe.activeQuanta=="function"?e.universe.activeQuanta():e.universe.activeQuanta,r=Math.floor(e.temperature-t);if(r<=0){for(var n=0;n<e.emitters.length;n++)e.emitters[n].setActive(!1);return[]}for(var i=Math.max(1,Math.floor(r/e.emitters.length)),n=0;n<e.emitters.length;n++)e.emitters[n].setBurstSize(i),e.emitters[n].setActive(!0);return[]}};Bn.prototype.setTemperature=function(e){this.temperature=e};Bn.prototype.getTemperature=function(){return this.temperature};Bn.prototype.dispose=function(){for(var e=0;e<this.emitters.length;e++)this.emitters[e].dispose();this.box.dispose(),this._counterWall&&this._counterWall.dispose()};Bw={description:"A thermostat-controlled cavity for blackbody radiation experiments. Builds a Box with a slit on one wall and installs 4 inward-firing wall emitters (top, bottom, left, right). A tick function adjusts emitter burst sizes to maintain the target quanta count (temperature). Demonstrates how energy equilibrium emerges from local emitter control rather than a global energy equation.",fields:[{name:"left",type:"number",constraint:{integer:!0},engineVisible:!0,description:"Inner box left X position (physics pixels)."},{name:"top",type:"number",constraint:{integer:!0},engineVisible:!0,description:"Inner box top Y position (physics pixels)."},{name:"width",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Inner box width (physics pixels)."},{name:"height",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Inner box height (physics pixels)."},{name:"wallThickness",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Wall thickness in physics pixels (default 10)."},{name:"temperature",type:"number",constraint:{min:1,integer:!0},engineVisible:!1,widgetConfig:{max:3e3,step:50},description:'Target quanta count inside the cavity (the "temperature"). The thermostat tick function increases emission until this count is reached, then stops all emitters. Higher = more particles = higher "temperature".'},{name:"slitHeight",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Height of the slit opening on the exit wall (physics pixels, default 60). Particles leak through this slit to the outside for blackbody spectrum measurement."},{name:"color",type:"rgb",engineVisible:!1,live:!0,description:"Render color [r, g, b] for the box walls (render-only). A live edit fans out to every wall the group owns (the `_owner` fan-out in updateObjectProperty)."}]};at(Bn,{from:new URL("frqtl/parts/OvenBox.js",He()).href,descriptor:Bw,defaults:{left:60,top:40,width:100,height:120,wallThickness:10,temperature:300,slitHeight:60,color:[120,120,120]},build:o(function(e,t,r){var n=r,i=new n(t.runner.universe,Object.assign({left:e.left!=null?e.left:Math.round(t.x-50),top:e.top!=null?e.top:Math.round(t.y-60),width:100,height:120,wallThickness:10,temperature:300,slitHeight:60,color:[120,120,120]},e));return i._schemaKind=r.name,i},"build")})});var Hf={};Oe(Hf,{PointSource:()=>Bt});function Ww(e){if(e==null)return"random";if(typeof e=="string"){var t=e.toUpperCase();if(t==="POSITIVE"||e==="Positive"||e==="+")return"positive";if(t==="NEGATIVE"||e==="Negative"||e==="-")return"negative"}return e===0?"positive":e===1?"negative":"random"}function qm(e){return e==="positive"?"POSITIVE":e==="negative"?"NEGATIVE":null}function Go(e,t){return String(e)+":"+String(!!t)}function Gw(e,t){var r=[];if(t!=null)for(var n=Math.max(t,e),i=n;i>=t;i-=2)r.push(i);else r.push(e);return r}function Bt(e,t,r,n,i,a,s,l,u,f,c){a===void 0&&(a=null),s=s!==void 0?s:!0,l=l!==void 0?l:1/0,u=u!==void 0?u:0,f=f!==void 0?f:5,c=c||{};var h=c.emergentPhysics||!1,g=c.minRadius!==void 0?c.minRadius:null,p=c.color||null,m=c.wavelength||null,b=c.zMin!==void 0?c.zMin:null,y=c.zDepth!==void 0?c.zDepth:null;this.universe=e,this._schemaKind="PointSource",this.x=t,this.y=r,this.diameter=n,this.speed=i,this.angle_increment=f,this.auto_fire=s,this.colorOverride=p||null,this.renderShape=null,this.renderOutline=null,this._chargeMode=Ww(a),this._random_direction=!1,this._emergentPhysics=h,this._color=p,this._wavelength=m,this._quantum_limit=l,this._delay=u,this._zMin=b,this._zDepth=y,this._radii=Gw(n/2,g),this._handleGroups={},this._ensureAndActivate(this._chargeMode,this._random_direction),this.emitterHandles=this._activeHandles()}var Vm,Hw,Dl=ce(()=>{Rt();zf();Et();wr();Ut();Di();Rl();Vm=Tl;o(Ww,"_chargeToMode");o(qm,"_modeToCharge");o(Go,"_groupKey");o(Gw,"_buildRadii");o(Bt,"PointSource");Bt.prototype._ensureGroup=function(e,t){var r=Go(e,t);if(this._handleGroups[r]!==void 0)return this._handleGroups[r];for(var n=[],i=this.universe,a=this.x,s=this.y,l=this.angle_increment,u=Math.floor(360/l),f=this._emergentPhysics,c=this._color,h=this.renderShape,g=this.renderOutline,p=this._wavelength,m=this._quantum_limit,b=this._delay,y=this._radii,w=!!t,O=this.auto_fire,S=this._zMin,A=this._zDepth,C=0;C<y.length;C++)for(var R=y[C],Q=0;Q<u;Q++){var Y=Q*l,H=Y*Math.PI/180,q=a+R*Math.cos(H),T=s+R*Math.sin(H),J,D;f?(J=0,D=0):(J=R*Math.cos(H),D=R*Math.sin(H));var K=[Math.round(q),Math.round(T),1,1],N={sourceRects:[K],vx:J,vy:D,burstSize:1,charge:e,randomDirection:w,quantumLimit:m===1/0||m==null?1/0:m,remainingQuanta:m===1/0||m==null?1/0:m,delay:b||0,remainingDelay:b||0,active:O,tombstoned:!1,color:c||null,renderShape:h||null,renderOutline:g??null,wrap:!1,wavelength:p||null,fundamentalDim:null,zMin:S,zDepth:A},B=Vm(i,N);B._emState=N,i.experimentTickFunctions.push(B),n.push(N)}return this._handleGroups[r]=n,n};Bt.prototype._ensureAndActivate=function(e,t){var r=!!t,n=this,i=[];e==="both"?(i.push({charge:"POSITIVE",rd:r}),i.push({charge:"NEGATIVE",rd:r})):i.push({charge:qm(e),rd:r});for(var a=0;a<i.length;a++)n._ensureGroup(i[a].charge,i[a].rd);for(var s={},l=0;l<i.length;l++)s[Go(i[l].charge,i[l].rd)]=!0;for(var u=Object.keys(n._handleGroups),f=0;f<u.length;f++)for(var c=u[f],h=n._handleGroups[c],g=!!s[c],p=0;p<h.length;p++)h[p].active=g};Bt.prototype._activeHandles=function(){var e=this._chargeMode,t=this._random_direction,r=[],n={};e==="both"?(n[Go("POSITIVE",t)]=!0,n[Go("NEGATIVE",t)]=!0):n[Go(qm(e),t)]=!0;for(var i=Object.keys(this._handleGroups),a=0;a<i.length;a++)if(n[i[a]])for(var s=this._handleGroups[i[a]],l=0;l<s.length;l++)r.push(s[l]);return r};Bt.prototype.forEachHandle=function(e){for(var t=Object.keys(this._handleGroups),r=0;r<t.length;r++)for(var n=this._handleGroups[t[r]],i=0;i<n.length;i++)e(n[i])};Object.defineProperty(Bt.prototype,"chargeMode",{get:o(function(){return this._chargeMode},"get"),set:o(function(e){var t={random:!0,positive:!0,negative:!0,both:!0};if(!t[e])throw new TypeError('[PointSource] Invalid chargeMode "'+e+'". Expected: random | positive | negative | both');this._chargeMode=e,this._ensureAndActivate(e,this._random_direction),this.emitterHandles=this._activeHandles()},"set"),enumerable:!0,configurable:!0});Object.defineProperty(Bt.prototype,"random_direction",{get:o(function(){return this._random_direction},"get"),set:o(function(e){var t=!!e;this._random_direction=t,this._ensureAndActivate(this._chargeMode,t),this.emitterHandles=this._activeHandles()},"set"),enumerable:!0,configurable:!0});Bt.prototype.setActive=function(e){this.auto_fire=e;var t=this;if(e)this._ensureAndActivate(this._chargeMode,this._random_direction);else for(var r=Object.keys(t._handleGroups),n=0;n<r.length;n++)for(var i=t._handleGroups[r[n]],a=0;a<i.length;a++)i[a].active=!1};Bt.prototype.repositionToRect=function(e,t,r,n,i){var a=i||this.universe,s=e+r/2,l=t+n/2,u=this.diameter/2,f=this.angle_increment,c=Math.floor(360/f);this.x=s,this.y=l,this._marker&&this._marker.setRect([Math.round(s-this.diameter/2),Math.round(l-this.diameter/2),this.diameter,this.diameter]);for(var h=[],g=0;g<c;g++){var p=g*f,m=p*Math.PI/180,b=Math.round(s+u*Math.cos(m)),y=Math.round(l+u*Math.sin(m));h.push([b,y,1,1])}for(var w=Object.keys(this._handleGroups),O=0;O<w.length;O++)for(var S=this._handleGroups[w[O]],A=0;A<S.length;A++){var C=A%c;S[A].sourceRects=[h[C]]}};Bt.prototype.dispose=function(){if(!this._disposed){this._disposed=!0;for(var e=[],t=Object.keys(this._handleGroups),r=0;r<t.length;r++)for(var n=this._handleGroups[t[r]],i=0;i<n.length;i++)n[i].tombstoned=!0,n[i].active=!1,e.push(n[i]);if(this.universe&&Array.isArray(this.universe.experimentTickFunctions))for(var a=this.universe.experimentTickFunctions,s=a.length-1;s>=0;s--)a[s]._emState&&e.indexOf(a[s]._emState)!==-1&&a.splice(s,1);this._marker&&typeof this._marker.dispose=="function"&&this._marker.dispose()}};Bt.prototype.attachMarker=function(e){if(!e||typeof e!="object")throw new TypeError("[PointSource.attachMarker] needs the marker LargeObject. (FAIL-LOUD.)");if(this._marker)throw new Error("[PointSource.attachMarker] this emitter already owns a marker. (FAIL-LOUD.)");return this._marker=e,e._owner=this,this};Hw={description:"A radial point emitter that fires particles outward from the surface of a circle at regular angular intervals. Each angle gets its own engine emitter handle so the angular pattern is deterministic. Produces wave fronts, interference patterns, and Big Bang-style expansions depending on configuration.",fields:[{name:"rect",type:"rect",engineVisible:!0,description:"Canonical bounding rect "+Ot(4)+" \u2014 repositions center (cx=left+w/2, cy=top+h/2) and recomputes all angle source rects (one-path via repositionToRect)"},{name:"x",type:"number",constraint:{integer:!0},engineVisible:!0,description:"Center X of the point source (physics pixels)"},{name:"y",type:"number",constraint:{integer:!0},engineVisible:!0,description:"Center Y of the point source (physics pixels)"},{name:"diameter",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Diameter of the emission circle (physics pixels)"},{name:"speed",type:"number",constraint:{min:0,integer:!1},engineVisible:!0,unit:"px/tick",description:"Velocity magnitude for emitted particles (pixels/tick)"},{name:"auto_fire",type:"boolean",engineVisible:!0,description:"Whether all angle emitters fire automatically"},{name:"quantum_limit",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Max quanta per angle emitter (null = Infinity)"},{name:"delay",type:"number",constraint:{min:0,integer:!0},engineVisible:!0,description:"Ticks between bursts for each angle emitter"},{name:"angle_increment",type:"number",constraint:{min:1,max:360,integer:!1},engineVisible:!0,description:"Degrees between emission angles. Fewer degrees = more angles = denser wave front. 5\xB0 gives 72 directions; 10\xB0 gives 36; 45\xB0 gives 8 (coarser)."},{name:"colorOverride",type:"rgb",engineVisible:!1,description:"Override render color for emitted particles [r, g, b] (render-only; stored on the emitter wrapper)."},{name:"chargeMode",type:"enum",constraint:{values:{random:"random",positive:"positive",negative:"negative",both:"both"}},engineVisible:!1,description:'High-level charge mode (sugar layer). "both" creates two per-angle handle groups (POSITIVE + NEGATIVE), doubling the emission count. Toggles the handle active flag \u2014 no engine ABI change.'},{name:"random_direction",type:"boolean",engineVisible:!1,description:"Whether emitted particles have randomized direction (sugar layer). PointSource normally uses directed emission; enabling this registers a new handle group with rd=true."},{name:"layer",type:"number",constraint:{min:0,integer:!0},engineVisible:!1,description:"Dimension layer this emitter targets (0 = fundamental; null = default). Stored on the emitter wrapper; no engine ABI change required."}]};at(Bt,{from:new URL("frqtl/parts/PointSource.js",He()).href,descriptor:Hw,defaults:{x:50,y:100,diameter:16,speed:1,chargeMode:"random",auto_fire:!0,quantum_limit:null,delay:0,angle_increment:10},build:o(function(e,t,r){var n=r,i=Se,a=Ee,s=e.x!=null?e.x:Math.round(t.x),l=e.y!=null?e.y:Math.round(t.y),u=e.diameter||16,f=new n(t.runner.universe,s,l,u,e.speed!=null?e.speed:1,null,e.auto_fire!=null?e.auto_fire:!0,e.quantum_limit!=null?e.quantum_limit:1/0,e.delay!=null?e.delay:0,e.angle_increment||10,{wavelength:e._wavelength!=null?e._wavelength:null,color:e._optColor||null,emergentPhysics:e._emergentPhysics||!1});f._schemaKind=r.name,e.chargeMode&&(f.chargeMode=e.chargeMode),e.colorOverride&&(f.colorOverride=e.colorOverride);var c=Math.round(s-u/2),h=Math.round(l-u/2),g=u,p=u,m=e.name||"source "+Cl(t.runner,"PointSource");f.name=m;var b=new i(t.runner.universe,[c,h,g,p],a.NONE,[],m,"closest",null,1,[0,0,0]);return b.drawAsCircle=!0,b._schemaKind="LargeObject",f.attachMarker(b),f},"build")})});var Kf={};Oe(Kf,{SlitLightSource:()=>oi});function oi(e,t,r,n,i,a){r=r!==void 0?r:10,n=n!==void 0?n:1/0,i=i!==void 0?i:1,a=a||{};var s=a.depth!==void 0&&a.depth!==null?a.depth:null,l=s!==null?-s/2:null,u=s!==null?s:null;this.universe=e,this._schemaKind="SlitLightSource";var f=16,c=20,h=t.slit_wall_gap_top+t.slit_wall_gap_height/2,g=null,p=1,m=a.color!==void 0?a.color:null;this.lightSource=new Bt(e,c,h,f,p,g,!0,n,i,r,{color:m,wavelength:t.wavelength,zMin:l,zDepth:u}),this.lightSource._owner=this}var Kw,Yf=ce(()=>{Rt();Dl();Et();Vf();o(oi,"SlitLightSource");oi.prototype.getTickFunction=function(){return function(){}};oi.prototype.setActive=function(e){this.lightSource.setActive(e)};Object.defineProperty(oi.prototype,"chargeMode",{get:o(function(){return this.lightSource.chargeMode},"get"),set:o(function(e){this.lightSource.chargeMode=e},"set"),enumerable:!0,configurable:!0});Kw={description:"A radial light source for the double-slit experiment. Wraps a PointSource positioned equidistant between the two slits (at the inter-slit gap center), so particles reach both openings with equal path length. Emits in all directions; the slit screen selects which particles pass through.",fields:[{name:"angle_increment",type:"number",constraint:{min:1,max:360,integer:!1},engineVisible:!0,description:"Degrees between emission angles (fewer degrees = more angles = denser wave front). 10\xB0 gives 36 directions, the double-slit experiment default."},{name:"quantum_limit",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Max quanta per angle emitter (null/Infinity = unlimited). Limits total particle count for performance control."},{name:"delay",type:"number",constraint:{min:0,integer:!0},engineVisible:!0,description:"Ticks between bursts for each angle emitter. 1 = emit every other tick (default for the double-slit source)."}]};at(oi,{from:new URL("frqtl/parts/SlitLightSource.js",He()).href,descriptor:Kw,defaults:{angle_increment:10,quantum_limit:null,delay:1},build:o(function(){throw new Error('[ObjectFactory] create("SlitLightSource"): a SlitLightSource requires a paired SlitScreen and cannot be constructed independently \u2014 build it through its setup factory (setupDoubleSlit), or compose '+Bo.SlitLightSource+". (FAIL-LOUD.)")},"build")})});var Jf={};Oe(Jf,{SlitScreen:()=>Bi});function si(e,t,r,n){kf(e,r,n,{slitScatter:t})}function Bi(e,t,r,n,i,a,s,l,u,f,c,h){this.universe=e,this._schemaKind="SlitScreen",this.wavelength=i,this.depth=f??null,this.linerScatter=h||"current",this.slit_height=l!==void 0?l:Math.floor(i*.8),this.slit_wall_gap_height=u!==void 0?u:Math.floor(i*.8),this.slit_group_height=this.slit_height+this.slit_wall_gap_height+this.slit_height,this.slit_group_center_y=n/2,this.slit1_top=this.slit_group_center_y-this.slit_group_height/2,this.slit_wall_gap_top=this.slit1_top+this.slit_height,this.slit2_bottom=this.slit_group_center_y+this.slit_group_height/2,this.slit2_top=this.slit2_bottom-this.slit_height,this.slit_group_left=t,this.slit_width=r,this.bottom_wall_height=n-this.slit2_bottom,this.hole_depth=c??this.slit_height;var g=a?[st.ABSORB]:[st.BLOCK],p=Ee.NONE,m=a?"destroy":"block",b=e;function y($,de,ve){return new we(b,{rect:$,collisionBehavior:m,name:de,color:ve}).lo}o(y,"_wallLO");var w=[st.MARK],O=Ee.NONE,S=[0,0,0,0],A=[0,0,0,0];s===1&&(w.push(st.DETECT),O=Ee.RANDOM_XY),s===2&&(w.push(st.DETECT),S=[0,0,255],A=[0,0,255]);var C=Math.min(10,Math.floor(this.slit_height*.2)),R=this.depth;if(R===null){let $=function(de,ve,ue,L){return[de,ve,ue,L]};o($,"rect3"),this.wall1=y($(this.slit_group_left,0,this.slit_width,this.slit1_top-1),"wall1",[255,0,0]),this.slit1=new Se(e,$(this.slit_group_left,this.slit1_top,this.slit_width,this.slit_height-1),O,w,"slit1","closest",null,1,S),this.wall2=y($(this.slit_group_left,this.slit_wall_gap_top,this.slit_width,this.slit_wall_gap_height-1),"wall2",[128,0,0]),this.slit2=new Se(e,$(this.slit_group_left,this.slit2_top,this.slit_width,this.slit_height-1),O,w,"slit2","closest",null,1,A),this.wall3=y($(this.slit_group_left,this.slit2_bottom,this.slit_width,this.bottom_wall_height-1),"wall3",[255,0,0]);var Q=new Se(e,$(this.slit_group_left,this.slit1_top,this.slit_width,C),Ee.RANDOM_XY,[st.BLOCK],"slit1_liner_top","closest",null,1,[0,0,255]);si(Q,this.linerScatter,e,"bottom");var Y=new Se(e,$(this.slit_group_left,this.slit1_top+this.slit_height-C,this.slit_width,C),Ee.RANDOM_XY,[st.BLOCK],"slit1_liner_bottom","closest",null,1,[0,0,255]);si(Y,this.linerScatter,e,"top");var H=new Se(e,$(this.slit_group_left,this.slit2_top,this.slit_width,C),Ee.RANDOM_XY,[st.BLOCK],"slit2_liner_top","closest",null,1,[0,0,255]);si(H,this.linerScatter,e,"bottom");var q=new Se(e,$(this.slit_group_left,this.slit2_top+this.slit_height-C,this.slit_width,C),Ee.RANDOM_XY,[st.BLOCK],"slit2_liner_bottom","closest",null,1,[0,0,255]);si(q,this.linerScatter,e,"top"),this.walls=[this.wall1,this.slit1,this.wall2,this.slit2,this.wall3,Q,Y,H,q]}else{let $=function(X,te,ye,xe){return[X,te,T,ye,xe,R]},de=function(X,te,ye,xe,Ue,Ce){return[X,te,Ue,ye,xe,Ce]};o($,"zSlab"),o(de,"zBand");var T=-R/2,J=-this.hole_depth/2,D=this.hole_depth,K=J+D,N=J-T,B=R/2-K;this.wall1=y($(this.slit_group_left,0,this.slit_width,this.slit1_top-1),"wall1",[255,0,0]),this.slit1_near=new Se(e,de(this.slit_group_left,this.slit1_top,this.slit_width,this.slit_height-1,T,N),Ee.NONE,g,"slit1_near","closest",null,1,[200,60,60]),this.slit1=new Se(e,de(this.slit_group_left,this.slit1_top,this.slit_width,this.slit_height-1,J,D),O,w,"slit1","closest",null,1,S),this.slit1_far=new Se(e,de(this.slit_group_left,this.slit1_top,this.slit_width,this.slit_height-1,K,B),Ee.NONE,g,"slit1_far","closest",null,1,[200,60,60]),this.wall2=y($(this.slit_group_left,this.slit_wall_gap_top,this.slit_width,this.slit_wall_gap_height-1),"wall2",[128,0,0]),this.slit2_near=new Se(e,de(this.slit_group_left,this.slit2_top,this.slit_width,this.slit_height-1,T,N),Ee.NONE,g,"slit2_near","closest",null,1,[200,60,60]),this.slit2=new Se(e,de(this.slit_group_left,this.slit2_top,this.slit_width,this.slit_height-1,J,D),O,w,"slit2","closest",null,1,A),this.slit2_far=new Se(e,de(this.slit_group_left,this.slit2_top,this.slit_width,this.slit_height-1,K,B),Ee.NONE,g,"slit2_far","closest",null,1,[200,60,60]),this.wall3=y($(this.slit_group_left,this.slit2_bottom,this.slit_width,this.bottom_wall_height-1),"wall3",[255,0,0]);var Q=new Se(e,de(this.slit_group_left,this.slit1_top,this.slit_width,C,J,D),Ee.RANDOM_XY,[st.BLOCK],"slit1_liner_top","closest",null,1,[0,0,255]);si(Q,this.linerScatter,e,"bottom");var Y=new Se(e,de(this.slit_group_left,this.slit1_top+this.slit_height-C,this.slit_width,C,J,D),Ee.RANDOM_XY,[st.BLOCK],"slit1_liner_bottom","closest",null,1,[0,0,255]);si(Y,this.linerScatter,e,"top");var H=new Se(e,de(this.slit_group_left,this.slit2_top,this.slit_width,C,J,D),Ee.RANDOM_XY,[st.BLOCK],"slit2_liner_top","closest",null,1,[0,0,255]);si(H,this.linerScatter,e,"bottom");var q=new Se(e,de(this.slit_group_left,this.slit2_top+this.slit_height-C,this.slit_width,C,J,D),Ee.RANDOM_XY,[st.BLOCK],"slit2_liner_bottom","closest",null,1,[0,0,255]);si(q,this.linerScatter,e,"top"),this.walls=[this.wall1,this.slit1_near,this.slit1,this.slit1_far,this.wall2,this.slit2_near,this.slit2,this.slit2_far,this.wall3,Q,Y,H,q]}for(var ne=0;ne<this.walls.length;ne++)this.walls[ne].rect.d!==void 0&&(this.walls[ne].shape="box",this.walls[ne].depth=this.walls[ne].rect.d);for(var oe=0;oe<this.walls.length;oe++)this.walls[oe]._owner=this}var Yw,Qf=ce(()=>{Rt();wr();Ut();$r();Af();yn();Et();Un();o(si,"_applyLinerScatter");o(Bi,"SlitScreen");Bi.prototype.dispose=function(){for(var e=0;e<this.walls.length;e++)this.walls[e].dispose()};Bi.prototype.updateGapHeight=function(e,t){if(this.depth!==null)return!1;if(!t||typeof t.updateObjectProperty!="function")throw new Error("[SlitScreen.updateGapHeight] requires a runner exposing updateObjectProperty(lo, prop, value).");var r=this.slit_group_center_y*2;this.slit_wall_gap_height=e,this.slit_group_height=this.slit_height+this.slit_wall_gap_height+this.slit_height,this.slit1_top=this.slit_group_center_y-this.slit_group_height/2,this.slit_wall_gap_top=this.slit1_top+this.slit_height,this.slit2_bottom=this.slit_group_center_y+this.slit_group_height/2,this.slit2_top=this.slit2_bottom-this.slit_height,this.bottom_wall_height=r-this.slit2_bottom;var n=Math.min(10,Math.floor(this.slit_height*.2)),i=this.slit_group_left,a=this.slit_width;function s(y,w){for(var O=0;O<y.length;O++)if(y[O].name===w)return y[O];return null}o(s,"findWall");var l=s(this.walls,"wall1");l&&t.updateObjectProperty(l,"rect",[i,0,a,this.slit1_top-1]);var u=s(this.walls,"slit1");u&&t.updateObjectProperty(u,"rect",[i,this.slit1_top,a,this.slit_height-1]);var f=s(this.walls,"wall2");f&&t.updateObjectProperty(f,"rect",[i,this.slit_wall_gap_top,a,this.slit_wall_gap_height-1]);var c=s(this.walls,"slit2");c&&t.updateObjectProperty(c,"rect",[i,this.slit2_top,a,this.slit_height-1]);var h=s(this.walls,"wall3");h&&t.updateObjectProperty(h,"rect",[i,this.slit2_bottom,a,this.bottom_wall_height-1]);var g=s(this.walls,"slit1_liner_top");g&&t.updateObjectProperty(g,"rect",[i,this.slit1_top,a,n]);var p=s(this.walls,"slit1_liner_bottom");p&&t.updateObjectProperty(p,"rect",[i,this.slit1_top+this.slit_height-n,a,n]);var m=s(this.walls,"slit2_liner_top");m&&t.updateObjectProperty(m,"rect",[i,this.slit2_top,a,n]);var b=s(this.walls,"slit2_liner_bottom");return b&&t.updateObjectProperty(b,"rect",[i,this.slit2_top+this.slit_height-n,a,n]),!0};Yw={description:"A double-slit barrier that produces quantum interference. Creates 9 sub-LargeObjects: wall1 (above slit1), slit1, wall2 (between slits), slit2, wall3 (below slit2), and 4 edge-diffraction liners (slit1_liner_top/bottom, slit2_liner_top/bottom). The group is the single author-surface entity; slit geometry is derived from the wavelength so the interference fringe spacing is automatically correct for the particle wavelength.",fields:[{name:"slit_group_left",type:"number",constraint:{integer:!0},engineVisible:!0,description:"X position of the slit barrier left edge (physics pixels). Moving this repositions the entire slit assembly."},{name:"slit_width",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Width/thickness of the slit screen (physics pixels). Thicker screens affect diffraction character."},{name:"wavelength",type:"number",constraint:{min:4,integer:!0},engineVisible:!0,description:"Wavelength driving slit and gap sizing. Default slit height = floor(wavelength * 0.8); inter-slit gap = same. Engine invariant 6: minimum wavelength is 4."},{name:"slit_height",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Height of each slit opening (physics pixels). Narrower slits increase diffraction spread; wider slits reduce it."},{name:"slit_wall_gap_height",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Height of the wall segment between the two slits (physics pixels). Larger gap \u2192 tighter interference fringes on the screen."},{name:"absorbAtSlitWall",type:"boolean",engineVisible:!0,description:"If true, wall segments use ABSORB (particles disappear on contact). If false, walls use BLOCK. Absorbing walls eliminate back-scatter and produce cleaner interference patterns."},{name:"detectAtSlits",type:"enum",constraint:{values:{NONE:0,DETECT_RANDOM_XY:1,DETECT_MARK:2}},engineVisible:!0,description:"Slit detection mode: 0 = no detection (coherent, wave-like pattern); 1 = DETECT+RANDOM_XY (which-path measurement collapses the wavefunction); 2 = DETECT+MARK (which-path marker via string_map.detector_name)."}]};at(Bi,{from:new URL("frqtl/parts/SlitScreen.js",He()).href,descriptor:Yw,defaults:{slit_group_left:100,slit_width:8,wavelength:20,slit_height:16,slit_wall_gap_height:16,absorbAtSlitWall:!0,detectAtSlits:0},build:o(function(e,t,r){var n=r,i=Ke.worldRect(t.runner.canvas_rect,'ObjectFactory create("SlitScreen") runner.canvas_rect').h,a=new n(t.runner.universe,e.slit_group_left!=null?e.slit_group_left:Math.round(t.x),e.slit_width||8,i,e.wavelength||20,e.absorbAtSlitWall!=null?e.absorbAtSlitWall:!0,e.detectAtSlits!=null?e.detectAtSlits:0,e.slit_height,e.slit_wall_gap_height);return a._schemaKind=r.name,a},"build")})});var jl={};Oe(jl,{CameraControls:()=>Ps,CameraPath:()=>ya,CollisionActions:()=>st,CollisionTypes:()=>Ee,DetectorWall:()=>bn,FrqtlControlOverlay:()=>ll,FrqtlControlsPanel:()=>wn,FrqtlVision:()=>Mi,GraphingDetectorWall:()=>Ft,LargeObject:()=>Se,LightColor:()=>xn,LiveChart:()=>zi,LogicGate:()=>Me,OvenBox:()=>Bn,PointSource:()=>Bt,Rectangle:()=>lt,SlitLightSource:()=>oi,SlitScreen:()=>Bi,SphereEmitter:()=>Le,Trace:()=>zt,Tunnel:()=>yt,Wall:()=>we});var Ll=ce(()=>{Bu();Us();$r();Ut();Fc();Qc();Ra();vl();wf();wr();Ma();Ef();Uf();Gf();Dl();Oo();Yf();Qf();qo();Al();Vo();yn()});var eO={};Oe(eO,{CameraControls:()=>Ps,CameraPath:()=>ya,CaptureEnvelope:()=>La,CollisionActions:()=>st,CollisionTypes:()=>Ee,DetectorWall:()=>bn,FieldBuilder:()=>Er,FrqtlCapture:()=>Nl,FrqtlControlOverlay:()=>ll,FrqtlControlsPanel:()=>wn,FrqtlVision:()=>Mi,GraphingDetectorWall:()=>Ft,LargeObject:()=>Se,LightColor:()=>xn,LiveChart:()=>zi,LogicGate:()=>Me,OvenBox:()=>Bn,PointSource:()=>Bt,RENDERER_PROVIDER_OPTIONAL:()=>ul,RENDERER_PROVIDER_REQUIRED:()=>Ro,Rectangle:()=>lt,RenderStages:()=>sr,SlitLightSource:()=>oi,SlitScreen:()=>Bi,SphereEmitter:()=>Le,Trace:()=>zt,Tunnel:()=>yt,Wall:()=>we,bootProject:()=>$1,bootRecipe:()=>gy,bootScene:()=>xy,engine:()=>Hi,engineState:()=>Ho,modules:()=>Sy,validateRendererProvider:()=>Do});Rt();Ll();var oh={};Oe(oh,{JS_ARCHIVED_MSG:()=>ng,bootEngine:()=>ah,engine:()=>Hi,engineState:()=>Ho,refuseRetiredDoors:()=>Fl});Un();Ma();Oo();var Jw=Object.freeze({POSITIVE:0,NEGATIVE:1});function Hm(e,t,r,n,i,a,s,l,u,f,c,h,g,p){this.tick=e,this.id=t,this.layer=r,this.rect=n,this.fullness=i,this.isAlive=a,this.childCount=s,this.mass=l,this.collidedId=u,this.vx=f,this.vy=c,this.z=h??0,this.vz=g??0,this.data=p??null}o(Hm,"FrameData");function Km(e,t,r,n){this.tick=e,this.layer=t,this.frameCount=r,this.boundaryRect=n}o(Km,"DimensionData");function Ym(e,t,r){this.tick=e,this.dimensionCount=t,this.boundaryRect=r}o(Ym,"UniverseData");function Pl(e){this.universeData=e,this.dimensionData=[],this.frameData=[]}o(Pl,"TickData");Pl.prototype.addDimensionData=function(e){this.dimensionData.push(e)};Pl.prototype.addFrameData=function(e){this.frameData.push(e)};function eh(e){return e.z!==void 0||e.d!==void 0?[e.left,e.top,e.z!==void 0?e.z:0,e.w,e.h,e.d!==void 0?e.d:e.w]:[e.left,e.top,e.w,e.h]}o(eh,"_rectSpecToArray");var Wi=[{key:"rect",required:!0,unit:"Rectangle (px)",effect:"REQUIRED \u2014 the ONE world-rect declaration; there is no world without it. init(fundamentalDimension, options) reads it and takes no rect. A leaf that leaves this rect is gone (the boundary is the only engine-side sink)."},{key:"seed",def:42,unit:"integer",effect:"THE deterministic RNG stream. Same seed + same ops \u21D2 bit-identical run."},{key:"fps",def:60,unit:"frames/second",effect:"the nominal tick rate the engine config records. Does not change physics per tick (1 tick = 1 time quantum, always)."},{key:"iframeIntervalSeconds",def:1,unit:"seconds",effect:"how often Phase B (STRUCTURE \u2014 build higher dimensions from the fundamental quadtree) runs. 1/60 = every tick (emergent composites appear immediately); 1 = once a second."},{key:"withInterQuantumCollisions",def:!1,unit:"boolean",effect:"false = leaves pass through each other (the fast path). true = leaf-leaf collision resolution (superlinear in alive-count \u2014 this is what makes a medium resistive)."},{key:"withBonding",def:!1,unit:"boolean",effect:"false = no bonding pass. true = collided leaves may bond into composites."},{key:"frameGenMode",def:"groundUp",unit:"'groundUp' | 'topDown'",effect:"how PARENT frames are generated. 'groundUp' = bottom-up, by actual collisions between the smallest frames (collision-based promotion, wave-walk). 'topDown' = by how many frames an area can parent (density clustering, brownian ON, collisions off). init() takes its own frameGenMode and does NOT inherit this one."},{key:"minMBFillRate",def:.1,unit:"fraction of capacity (0..1)",effect:"the minimum fullness a merged/promoted composite must reach to survive."},{key:"wavelengthScale",def:1,unit:"multiplier",effect:"the GLOBAL multiplier on every frame per-frame (capacity/mass) wavelength: lambda_eff = (capacity/mass) * wavelengthScale. Raising it widens fringes. init() re-reads this."},{key:"liveQuantaCap",def:3e5,unit:"leaf quanta | false",effect:"the WASM preview cap: once this many leaf quanta are alive, every further leaf add (makeLeafFrame) is skipped (returns null) until the count falls below it; the debug console is warned once per universe. The default is the preview limit set for this release: a value above it throws. false = uncapped."}],th=[{key:"wavelengthScale",def:1,unit:"multiplier",effect:"universe-wide multiplier on every frame's (capacity/mass) wavelength ratio: lambda_eff = (capacity/mass) * wavelengthScale. Raising it widens fringes. (The retired spelling 'wavelengthConstant' THROWS \u2014 see _RETIRED_CONFIG_KEYS.)"},{key:"frameGenMode",def:"groundUp",unit:"'groundUp' | 'topDown'",effect:"how PARENT frames are generated. 'groundUp' = bottom-up, by actual collisions between the smallest frames (promotion, wave-walk). 'topDown' = by how many frames an area can parent (density clustering, brownian ON, no collisions). init() does NOT inherit create()'s frameGenMode \u2014 the create()-time key is a pre-init record only. (The retired bool 'emergentPhysics' THROWS with the VALUE mapping.)"},{key:"brownianMotion",def:void 0,unit:"boolean",effect:"true = brownian random walk \xB7 false = wave-walk (particle walk). Rides the CONFIG BAG (brownian_motion) as the caller's REQUEST; the ENGINE resolves it at construction and JS reads the answer back, so nothing is inherited from a previous init. Omitted \u21D2 null \u21D2 the Rust unwrap_or is the ONE default authority. frameGenMode:'topDown' REQUIRES it: an explicit brownianMotion:false alongside topDown THROWS (the engine coerces it back to true, so accepting the false would be a lie). (The INVERTED alias 'noObserverFrame' is DELETED and THROWS.)"},{key:"noEscape",def:!1,unit:"boolean",effect:"true = children hard-trapped inside the parent rect."},{key:"activeAxes",def:void 0,unit:"{x,y,z} boolean bag",effect:"the 1D/2D/3D selector \u2014 which axes the base-walk + yo-yo coins fire on. Omitted \u21D2 the WASM serde default {x:true,y:true,z:false}, which keeps every existing 2D experiment byte-identical. capacity()/wavelength scale as the product over active axes."},{key:"depth",def:void 0,unit:"pixels",effect:"explicit world z-extent, DECOUPLED from width. Omitted \u21D2 width (a CUBE), so a square 2D scene is byte-identical to the historic coupling. The z-range is CENTERED [-depth/2, depth/2]."},{key:"stepping",def:"fixed",unit:"'fixed' | 'average'",effect:"the wave-walk STEPPING SAMPLER. Both realize the same mean step (1 px/tick along the momentum vector) and differ in the VARIANCE about it. 'fixed' walks a deterministic error accumulator, so along-ray deviation stays bounded below 1 px forever; 'average' draws a per-axis Bernoulli coin, so it random-walks along the ray (Var = (L1/L2 - 1) px^2/tick \u2014 zero on-axis, 0.414 at 45 degrees) and the 2nd/3rd-order interference rings wash out OFF-axis while staying crisp on-axis. Axis-aligned and stationary frames are BIT-IDENTICAL under both. SET ONCE at init \u2014 there is no runtime setter and no live property (a mid-run flip would splice two samplers into one trajectory)."}],za={groundUp:"GroundUp",topDown:"TopDown"};function Qw(){return Object.keys(za).map(function(e){return"'"+e+"'"}).join(" | ")}o(Qw,"_frameGenModeNames");function Jm(e,t){if(!Object.prototype.hasOwnProperty.call(za,t))throw new Error(e+": frameGenMode must be "+Qw()+" (got "+JSON.stringify(t)+"). 'groundUp' = parents form from actual collisions between the smallest frames; 'topDown' = parents form from how many frames an area can parent (density clustering).");return t}o(Jm,"_assertFrameGenMode");function Xw(e){for(var t=Object.keys(za),r=0;r<t.length;r++)if(za[t[r]]===e)return t[r];throw new Error("EGPTUniverse: the engine reported an unknown frame_gen_mode '"+e+"'. Legal wire names: "+t.map(function(n){return za[n]}).join(", ")+".")}o(Xw,"_frameGenModeFromWire");var Gi={iframe_interval_seconds:"renamed to 'iframeIntervalSeconds'",universe_rect:"renamed to 'rect'",wavelength_constant:"renamed to 'wavelengthScale'",wavelengthConstant:"renamed to 'wavelengthScale'",lowest_dimension:"is RETIRED, and it is NOT a rename. The base (fundamental) scale layer is the FIRST ARGUMENT of init(fundamentalDimension, options) \u2014 pass it there: universe.init(2). create() does not carry it.",lowestDimension:"is RETIRED, and it was INERT: create() recorded it and init() never read it, so create({lowestDimension: 2}) silently ran a dimension-0 world. The base (fundamental) scale layer is the FIRST ARGUMENT of init(fundamentalDimension, options) \u2014 pass it there: universe.init(2).",withFrames:"deleted \u2014 it was inert (the WASM engine always has frames). Remove it.",noObserverFrame:"is DELETED \u2014 it is NOT a rename. It was the INVERTED alias of 'brownianMotion': noObserverFrame:TRUE meant brownianMotion:FALSE (the wave-walk), and noObserverFrame:false meant nothing at all \u2014 it landed on the engine default, which is already brownianMotion:false. So OMIT the key: dropping it is exactly what every caller of it was asking for. Only if you want the random walk instead, pass brownianMotion:true",emergentPhysics:"is RETIRED \u2014 it is now 'frameGenMode', an ENUM, not a boolean. Migrate the VALUE, not just the name: emergentPhysics:true becomes frameGenMode:'topDown' (parent frames are generated by how many frames an area can parent \u2014 density clustering), and emergentPhysics:false becomes frameGenMode:'groundUp' (parent frames are generated by actual collisions between the smallest frames \u2014 the default)"};function Qm(e,t){Object.keys(t).forEach(function(r){if(Object.prototype.hasOwnProperty.call(Gi,r))throw new Error(e+": '"+r+"' "+Gi[r]+".")})}o(Qm,"_assertNoRetiredKeys");function Xf(){return Wi.map(function(e){return e.key}).join(", ")}o(Xf,"_configKeyList");function Zw(){return th.map(function(e){return e.key}).join(", ")}o(Zw,"_initOptionKeyList");function Xm(e,t,r,n){Object.keys(t).forEach(function(i){var a=r.some(function(s){return s.key===i});if(!a)throw new Error(e+": unknown key '"+i+"'. Valid keys: "+n+".")})}o(Xm,"_assertNoUnknownKeys");var Zm={};function ke(e,t){if(t!==Zm)throw new Error("new EGPTUniverse(...) is not the construction path. Build a universe with the ONE construction authority: EGPTUniverse.create(config) \u2014 e.g. EGPTUniverse.create({ rect: { left: 0, top: 0, w: 600, h: 400 }, seed: 42 }). Reach it as engine().EGPTUniverse.create (lib/frqtl/compat/engine.js). Keys + defaults: EGPTUniverse.CONFIG ("+Xf()+").");var r=e;this._params={fps:r.fps,iframe_interval_seconds:r.iframeIntervalSeconds,withInterQuantumCollisions:!!r.withInterQuantumCollisions,withBonding:!!r.withBonding,frameGenMode:r.frameGenMode,minMBFillRate:r.minMBFillRate,wavelength_scale:r.wavelengthScale,seed:r.seed,liveQuantaCap:r.liveQuantaCap},this._capTick=null,this._capAlive=0,this._capAdmitted=0,this._capWarned=!1,this._wasm=null,this.tick=0,this._universeRect=r.rect,this._withInterQuantumCollisions=!!r.withInterQuantumCollisions,this._brownianMotion=!1,this._wavelengthScale=r.wavelengthScale,this._frameGenMode=r.frameGenMode,this.experimentTickFunctions=[],this._loHandles=[],this.largeObjects=[]}o(ke,"EGPTUniverse");ke.CONFIG=Wi;ke.INIT_OPTIONS=th;ke.RETIRED_CONFIG_KEYS=Gi;function $w(e){return!!e&&typeof e=="object"&&e.is_centered!==void 0&&e._left!==void 0}o($w,"_isRectangle");function e_(e){if(!rh)throw new Error("EGPTUniverse.create(config): the engine is not booted \u2014 boot it through a door first: await bootEngine(loader) (lib/frqtl/compat/engine.js), which the boot module (experiments/_shared/boot.js) and the node door call for you. (FAIL-LOUD.)");if(e===void 0&&(e={}),e===null||typeof e!="object"||Array.isArray(e))throw new Error("EGPTUniverse.create(config): takes ONE config bag, e.g. EGPTUniverse.create({ rect: rect, seed: 42 }). The positional argument list (fps, iframeInterval, \u2026) and the two-argument (canvasRect, opts) factory are both DELETED \u2014 name the keys you mean: "+Xf()+".");Qm("EGPTUniverse.create(config)",e),Xm("EGPTUniverse.create(config)",e,Wi,Xf());var t={};if(Wi.forEach(function(i){t[i.key]=e[i.key]!==void 0&&e[i.key]!==null?e[i.key]:i.def}),Jm("EGPTUniverse.create(config)",t.frameGenMode),t_(t.liveQuantaCap),t.rect===void 0||t.rect===null)throw new Error("EGPTUniverse.create(config): `rect` is REQUIRED \u2014 there is no world without it (got "+String(t.rect)+"). "+eg+" Then universe.init(fundamentalDimension, options) reads it. (FAIL-LOUD.)");if(!$w(t.rect)){var r=t.rect;if(typeof r!="object"||Array.isArray(r))throw new Error("EGPTUniverse.create(config): `rect` must be a Rectangle or a bounds literal { left, top, w, h } \u2014 got "+JSON.stringify(r)+".");var n=lt;if(!n)throw new Error("EGPTUniverse.create(config): `rect` was given as a bounds literal but the Rectangle class is not loaded. Load parts/Rectangle.js (the ENGINE boot phase does this in the browser; the compat shim does it in Node), or pass a Rectangle instance.");t.rect=new n(r.left!==void 0?r.left:r.x||0,r.top!==void 0?r.top:r.y||0,r.w,r.h,null,!1)}return r_(t.rect),new ke(t,Zm)}o(e_,"createUniverse");function $m(){for(var e=0;e<Wi.length;e++)if(Wi[e].key==="liveQuantaCap")return Wi[e];throw new Error("[wasm-engine] UNIVERSE_CONFIG has no liveQuantaCap row.")}o($m,"_liveQuantaCapRow");function t_(e){var t=$m().def;if(e!==!1&&!(typeof e=="number"&&Number.isInteger(e)&&e>0&&e<=t))throw new Error("EGPTUniverse.create(config): liveQuantaCap must be false (uncapped) or a positive integer no larger than "+t+" (the release ceiling, EGPTUniverse.CONFIG row 'liveQuantaCap') \u2014 got "+(typeof e=="string"?JSON.stringify(e):String(e))+".")}o(t_,"_assertLiveQuantaCap");function Bm(e){return typeof e=="number"&&isFinite(e)&&e>0}o(Bm,"_isPositiveFiniteDimension");var eg="The world rect is written ONCE by the co-init call \u2014 EGPTUniverse.create({ rect }) \u2190 new FrqtlApp({ canvasW, canvasH }) / exp.createCanvas(w, h, cfg). There is no default world size.";function r_(e){if(!(Bm(e.w)&&Bm(e.h)))throw new Error("EGPTUniverse.create(config): rect w and h must be positive finite numbers (got w="+Wm(e.w)+", h="+Wm(e.h)+"). "+eg+" (FAIL-LOUD.)")}o(r_,"_requireWorldDimensions");function Wm(e){return typeof e=="string"?JSON.stringify(e)+" (a string)":String(e)}o(Wm,"_describeDimension");ke.create=e_;Object.defineProperty(ke.prototype,"brownianMotion",{get:o(function(){return this._wasm?this._wasm.brownian_motion():this._brownianMotion},"get"),set:o(function(e){this._brownianMotion=e,this._wasm&&this._wasm.set_brownian_motion(e)},"set")});Object.defineProperty(ke.prototype,"withInterQuantumCollisions",{get:o(function(){return this._withInterQuantumCollisions},"get"),set:o(function(e){this._withInterQuantumCollisions=e,this._wasm&&this._wasm.set_with_inter_quantum_collisions(e)},"set")});Object.defineProperty(ke.prototype,"activeQuanta",{get:o(function(){return this._wasm?this._wasm.active_quanta():0},"get")});Object.defineProperty(ke.prototype,"liveQuantaCap",{get:o(function(){return this._params.liveQuantaCap},"get")});Object.defineProperty(ke.prototype,"universe_rect",{get:o(function(){return this._universeRect},"get"),set:o(function(){throw new Error("EGPTUniverse: 'universe_rect' is read-only \u2014 its one writer is EGPTUniverse.create({ rect, seed, \u2026 }); universe.init(fundamentalDimension, options) reads it. (FAIL-LOUD: one declaration per fact.)")},"set")});Object.defineProperty(ke.prototype,"initDimension",{get:o(function(){return this._ensureInit(),this._initDimension},"get"),set:o(function(){throw new Error("EGPTUniverse: 'initDimension' is read-only \u2014 its one writer is universe.init(fundamentalDimension, options).")},"set")});Object.defineProperty(ke.prototype,"fundamentalDimension",{get:o(function(){return this._ensureInit(),this._wasm.fundamental_dimension()},"get"),set:o(function(){throw new Error("EGPTUniverse: 'fundamentalDimension' is read-only \u2014 the world's base layer is set by init() and lowered only by universe.addDimension(layer).")},"set")});Object.defineProperty(ke.prototype,"wavelengthScale",{get:o(function(){return this._wasm?this._wasm.wavelength_scale():this._wavelengthScale},"get"),set:o(function(e){this._wavelengthScale=e,this._wasm&&this._wasm.set_wavelength_scale(e)},"set")});Object.defineProperty(ke.prototype,"frameGenMode",{get:o(function(){return this._wasm?Xw(this._wasm.frame_gen_mode()):this._frameGenMode},"get"),set:o(function(e){throw new Error("EGPTUniverse: 'frameGenMode' is SET ONCE, at construction \u2014 there is no runtime setter (the engine holds the mode, and a mid-run flip would splice two frame-generation regimes into one run). Pass it where the world is built: universe.init(dim, { frameGenMode: "+JSON.stringify(e)+" }), or EGPTUniverse.create({ frameGenMode: \u2026 }) before init.")},"set")});Object.defineProperty(ke.prototype,"emergentPhysics",{get:o(function(){throw new Error("EGPTUniverse: 'emergentPhysics' "+Gi.emergentPhysics+".")},"get"),set:o(function(){throw new Error("EGPTUniverse: 'emergentPhysics' "+Gi.emergentPhysics+".")},"set")});Object.defineProperty(ke.prototype,"wavelengthConstant",{get:o(function(){throw new Error("EGPTUniverse: 'wavelengthConstant' "+Gi.wavelengthConstant+".")},"get"),set:o(function(){throw new Error("EGPTUniverse: 'wavelengthConstant' "+Gi.wavelengthConstant+".")},"set")});Object.defineProperty(ke.prototype,"iframe_interval_seconds",{get:o(function(){return this._params.iframe_interval_seconds},"get"),set:o(function(e){this._params.iframe_interval_seconds=e},"set")});ke.prototype._ensureInit=function(){if(!this._wasm)throw new Error("EGPTUniverse.init() must be called before any simulation methods.")};var Gm="EGPTUniverse.init(fundamentalDimension, options) takes NO rect \u2014 the world rect is written ONCE, by EGPTUniverse.create({ rect, seed, \u2026 }), and init reads it (universe.universe_rect). Call e.g. universe.init(0, { wavelengthScale: 1 }). (FAIL-LOUD.)";ke.prototype.init=function(e,t){if(e!==null&&typeof e=="object"||arguments.length>2)throw new Error("EGPTUniverse.init(): the rect argument is DELETED. "+Gm);if(e==null)throw new Error("EGPTUniverse.init(): the fundamental dimension is required. "+Gm);var r=this.universe_rect;if(t=t===void 0?{}:t,t===null||typeof t!="object"||Array.isArray(t))throw new Error("EGPTUniverse.init(): the second argument must be a plain options object, e.g. init(dim, { wavelengthScale: 1, noEscape: false, frameGenMode: 'groundUp' }).");Qm("EGPTUniverse.init()",t);var n={};n.isGreedy="the 'isGreedy' option has been removed (it was inert). Delete it.",n.emergentDimensions="the 'emergentDimensions' option is DELETED. The frame-generation regime is now the enum frameGenMode: 'topDown' (what a truthy emergentDimensions asked for) | 'groundUp' (the default).",Object.keys(n).forEach(function(S){if(S in t)throw new Error("EGPTUniverse.init(): "+n[S])}),Xm("EGPTUniverse.init()",t,th,Zw());var i=t.wavelengthScale,a=t.stepping,s=t.noEscape,l=t.frameGenMode,u=t.brownianMotion,f=l==null?"groundUp":Jm("EGPTUniverse.init()",l),c=f==="topDown";if(a!=null&&a!=="fixed"&&a!=="average")throw new Error("EGPTUniverse.init(): stepping must be 'fixed' or 'average' (got "+JSON.stringify(a)+"). 'fixed' = deterministic accumulator walk (default, bounded along-ray error); 'average' = per-axis Bernoulli walk (the historic sampler).");var h=t.activeAxes;if(h!=null&&(typeof h!="object"||Array.isArray(h)||typeof h.x!="boolean"||typeof h.y!="boolean"||typeof h.z!="boolean"))throw new Error("EGPTUniverse.init(): activeAxes must be a plain object { x:boolean, y:boolean, z:boolean }, e.g. { x:true, y:false, z:false } for a 1D walk.");var g=za[f],p=this._params.withInterQuantumCollisions;if(c&&(p=!1),c&&u!==void 0&&u!==null&&!u)throw new Error("EGPTUniverse.init(): frameGenMode:'topDown' requires brownian motion, so an explicit brownianMotion:false contradicts it \u2014 top-down frame generation IS the brownian regime and the engine coerces brownian_motion = true unconditionally, so the false would be silently discarded. Choose one: drop brownianMotion (topDown supplies it), or use frameGenMode:'groundUp' if you want the wave-walk. brownianMotion:true with topDown is redundant but consistent, and is allowed.");var m;u!=null&&(m=!!u);var b=i??1,y={fps:this._params.fps,iframe_interval_seconds:this._params.iframe_interval_seconds,with_inter_quantum_collisions:p,with_bonding:this._params.withBonding,frame_gen_mode:g,brownian_motion:m===void 0?null:m,min_fill_rate:this._params.minMBFillRate,universe_rect:[r.left,r.top,r.w,r.h],wavelength_scale:b,fundamental_dimension:e,seed:this._params.seed};h!=null&&(y.active_axes={x:h.x,y:h.y,z:h.z}),a!=null&&(y.stepping=a),this.activeAxes=y.active_axes?{x:y.active_axes.x,y:y.active_axes.y,z:y.active_axes.z}:{x:!0,y:!0,z:!1};var w=t.depth!==void 0&&t.depth!==null?t.depth:r&&r.d!==void 0&&r.d!==null&&r.d!==r.w?r.d:void 0;if(w!==void 0){if(typeof w!="number"||!(w>0))throw new Error("EGPTUniverse.init(): depth must be a positive number (the world z-extent).");y.depth=w}var O=w!==void 0?w:r.w;this.initBounds=$f([r.left+r.w/2,r.top+r.h/2,0,r.w,r.h,O]),this.largeObjects.length=0,this._loHandles.length=0,this._wasm=new rh(y),this._initDimension=e,rn=this,this._capTick=null,this._withInterQuantumCollisions&&this._wasm.set_with_inter_quantum_collisions(this._withInterQuantumCollisions),s&&this._wasm.set_no_escape(!0)};ke.prototype.addDimension=function(e){return this._ensureInit(),this._wasm.add_dimension(e),i_(e,this._wasm)};ke.prototype.registerLargeObject=function(e){this._ensureInit();var t=Object.assign({},e);e.rect&&!Array.isArray(e.rect)&&e.rect.left!==void 0&&(t.rect=eh(e.rect));var r=t.program;delete t.program;var n=this._wasm.register_large_object(t);return this._loHandles.push(n),r!=null&&typeof this._wasm.set_large_object_program_json=="function"&&this._wasm.set_large_object_program_json(n,JSON.stringify(r)),n};ke.prototype.doTick=function(){this._ensureInit();for(var e=0;e<this.experimentTickFunctions.length;e++){var t=this.experimentTickFunctions[e],r=t(this);if(Array.isArray(r)&&r.length>0)throw new TypeError("[doTick] experimentTickFunctions["+e+"] returned an array of "+r.length+" frames. Returning frames to be injected is no longer supported \u2014 it could not express a frame's layer. Mint and inject explicitly instead: universe.makeLeafFrame(left, top, level, ...) then universe.injectFrame(handle), and return nothing.")}var n=this._wasm.do_tick();this.tick=Number(this._wasm.tick());var i=this._wrapTickData(n);return this._lastTickData=i,i};ke.prototype.random=function(){return this._ensureInit(),this._wasm.random()};function tg(e,t,r){if(!(!e||!t||t<=0||!r)&&typeof e.set_frame_property=="function"){var n=null;if(typeof e.get_frame_property=="function")try{var i=e.get_frame_property(t,"data");typeof i=="string"&&i.length?n=JSON.parse(i):i&&typeof i=="object"&&(n=i)}catch{n=null}(!n||typeof n!="object")&&(n={});var a=n.string_map&&typeof n.string_map=="object"?n.string_map:{};for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&r[s]!=null&&(a[s]=String(r[s]));n.string_map=a;try{e.set_frame_property(t,"data",JSON.stringify(n))}catch{}}}o(tg,"_stampRenderIntentMerge");ke.prototype.makeLeafFrame=function(e,t,r,n,i,a,s,l,u,f,c){if(this._ensureInit(),!this._admitLeaf())return null;var h=r??this.fundamentalDimension,g=l??-1,p=this._wasm.make_leaf_frame(e,t,h,n??0,i,a,!!s,g),m=null;if(u&&(m=m||{},m["render.color"]=[u[0],u[1],u[2],u[3]!==void 0?u[3]:255].join(",")),f!=null&&f!==""&&(m=m||{},m["render.shape"]=String(f)),c!=null&&c!==""&&(m=m||{},m["render.outline"]=c===!0||c==="true"?"true":"false"),m&&typeof this._wasm.get_frame_quantum_id=="function"){var b=this._wasm.get_frame_quantum_id(p);b>0&&tg(this._wasm,b,m)}return p};ke.prototype._admitLeaf=function(){var e=this._params.liveQuantaCap;if(e===!1)return!0;if(this._capTick!==this.tick){var t=this._wasm.active_quanta();if(typeof t!="number"||!isFinite(t))throw new Error("[EGPTUniverse] liveQuantaCap cannot read the alive count: active_quanta() returned "+String(t)+", not a finite number.");this._capTick=this.tick,this._capAlive=t,this._capAdmitted=0}if(this._capAlive+this._capAdmitted>=e){if(!this._capWarned){this._capWarned=!0;var r=$m().def.toLocaleString("en-US");console.warn("[EGPTUniverse] liveQuantaCap: "+e.toLocaleString("en-US")+" leaf quanta are alive \u2014 further leaf frames are skipped until the count falls below it. This version of the engine is a limited preview release capped at "+r+" live quanta.")}return!1}return this._capAdmitted++,!0};ke.prototype.levelCapacity=function(e){if(this._ensureInit(),typeof this._wasm.level_capacity!="function")throw new Error("[EGPTUniverse.levelCapacity] the engine does not publish the capacity law (level_capacity). Rebuild the engine (make wasm / make wasm-node).");return this._wasm.level_capacity(e)};ke.prototype.injectFrame=function(e){this._ensureInit(),e!==null&&this._wasm.inject_frame(e)};ke.prototype.getFrameQuantumId=function(e){return this._ensureInit(),e===null?0:typeof this._wasm.get_frame_quantum_id=="function"?this._wasm.get_frame_quantum_id(e):e};ke.prototype.setLargeObjectFrame=function(e,t){if(this._ensureInit(),t===null)throw new Error("[EGPTUniverse.setLargeObjectFrame] the backing frame is null \u2014 the leaf add was refused by liveQuantaCap ("+this._params.liveQuantaCap+" live quanta). A LargeObject needs a real backing frame.");this._wasm.set_large_object_property(e,"frame_id",JSON.stringify(t))};ke.prototype.getLargeObjectFrameId=function(e){return this._ensureInit(),this._wasm.get_large_object_frame_id(e)};var Zf={LargeObject:{rect:o(function(e,t,r){var n=Array.isArray(r)?r:eh(r);e._wasm.set_large_object_property(t,"rect",JSON.stringify(n))},"rect"),layer:o(function(e,t,r){e._wasm.set_large_object_property(t,"layer",JSON.stringify(r??null))},"layer"),count:o(function(e,t,r){e._wasm.set_large_object_property(t,"count",JSON.stringify(Math.trunc(r)))},"count"),program:o(function(e,t,r){if(typeof e._wasm.set_large_object_program_json=="function"){var n=r!=null?JSON.stringify(r):"null";e._wasm.set_large_object_program_json(t,n)}},"program"),region:o(function(e,t,r){var n=r!=null?JSON.stringify(r):"null";e._wasm.set_large_object_property(t,"region",n)},"region")}};Zf.backdrop=Zf.LargeObject;var n_={reposition:!0};ke.prototype.updateObjectProperty=function(e,t,r,n){this._ensureInit();var i=Ke,a=null,s=i.get(t);if(!s)throw new TypeError('[updateObjectProperty] Unknown object kind "'+t+'"');for(var l=0;l<s.fields.length;l++)if(s.fields[l].name===r){a=s.fields[l];break}if(!a)throw new TypeError('[updateObjectProperty] Property "'+r+'" is not in the schema for kind "'+t+'"');if(a.type==="readonly")throw new TypeError('[updateObjectProperty] Property "'+r+'" is readonly for kind "'+t+'"');if(a.engineVisible){var u=Zf[t];if(u&&Object.prototype.hasOwnProperty.call(u,r)){u[r](this,e,n);return}if(!Object.prototype.hasOwnProperty.call(n_,r)){for(var f=u?Object.keys(u):[],c=[],h=i.get(t),g=0;g<h.fields.length;g++)h.fields[g].engineVisible&&h.fields[g].type!=="readonly"&&c.push(h.fields[g].name);throw new TypeError('[updateObjectProperty] Property "'+r+'" is engine-visible for kind "'+t+'" but no WASM ABI routes it \u2014 the write would be silently discarded. '+(f.length?'This provider routes for "'+t+'": '+f.join(", ")+".":'This provider has NO engine dispatch for kind "'+t+'" at all.')+' The schema declares these engine-visible fields for "'+t+'": '+(c.length?c.join(", "):"(none)")+". Either add the ABI, or apply the write at the JS layer (the object's own setter) and return before delegating to universe.updateObjectProperty.")}}};ke.prototype.setLargeObjectCollisionType=function(e,t){typeof console<"u"&&console.warn("[wasm-engine] setLargeObjectCollisionType("+e+", "+JSON.stringify(t)+") called after G2 deletion \u2014 no-op. Compile velocity behavior into an op-program at registration time instead.")};ke.prototype.setLargeObjectActive=function(e,t){this._ensureInit(),this._wasm.set_large_object_property(e,"active",JSON.stringify(!!t))};ke.prototype.updateLargeObjectRect=function(e,t){this._ensureInit();var r=Array.isArray(t)?t:eh(t);typeof this._wasm.set_large_object_property=="function"&&this._wasm.set_large_object_property(e,"rect",JSON.stringify(r))};ke.prototype.queryRect=function(e,t,r,n){return this._ensureInit(),this._wasm.query_rect(e,t,r,n)};ke.prototype.setLargeObjectCount=function(e,t){this._ensureInit(),this._wasm.set_large_object_property(e,"count",JSON.stringify(Math.trunc(t)))};ke.prototype.queryRectFrames=function(e,t,r,n){this._ensureInit();var i=this._wasm.query_rect_frames(e,t,r,n);if(!i)return[];var a;try{a=JSON.parse(i)}catch{return[]}if(!Array.isArray(a)||a.length===0)return[];for(var s=[],l=0;l<a.length;l++)s.push(Il(a[l],this.tick));return s};ke.prototype.queryObbFrames=function(e,t,r,n,i,a,s){if(this._ensureInit(),typeof this._wasm.query_obb_frames!="function")throw new Error("[queryObbFrames] the active WASM binary predates the swept-OBB ABI (query_obb_frames). Rebuild the engine (make wasm / make wasm-node).");var l=this._wasm.query_obb_frames(e,t,r,n,i,a,s);if(!l)return[];var u;try{u=JSON.parse(l)}catch{return[]}if(!Array.isArray(u)||u.length===0)return[];for(var f=[],c=0;c<u.length;c++)f.push(Il(u[c],this.tick));return f};ke.prototype.injectMutations=function(e){if(this._ensureInit(),!Array.isArray(e))throw new TypeError("[injectMutations] batch must be an array, got: "+typeof e);for(var t=Ke.get("Frame"),r=0;r<e.length;r++){var n=e[r];if(n===null||typeof n!="object"||typeof n.id!="number"||typeof n.prop!="string"||!("value"in n))throw new TypeError("[injectMutations] Malformed entry at index "+r+": expected { id: number, prop: string, value: * }, got "+JSON.stringify(n));for(var i=null,a=0;a<t.fields.length;a++)if(t.fields[a].name===n.prop){i=t.fields[a];break}if(!i)throw new TypeError('[injectMutations] Unknown property "'+n.prop+'" for kind "Frame" (entry index '+r+"). Valid properties: "+t.fields.map(function(c){return c.name}).join(", "));if(i.type==="forbidden")throw new TypeError('[injectMutations] Property "'+n.prop+'" is engine-owned topology \u2014 forbidden (entry index '+r+"). Set position (x/y) and let the engine reconcile topology next tick.");if(i.type==="readonly")throw new TypeError('[injectMutations] Property "'+n.prop+'" is read-only (entry index '+r+"). Use a writable property to change it indirectly.")}for(var s=[],l=0;l<e.length;l++){var u=e[l],f=u.value;u.prop==="charge"?f==="POSITIVE"||f==="Positive"?f=0:(f==="NEGATIVE"||f==="Negative")&&(f=1):u.prop==="data"&&(f=f??null),s.push({id:u.id,prop:u.prop,value:f})}this._wasm.inject_mutations(JSON.stringify(s))};ke.prototype.killFrame=function(e){this._ensureInit(),this._wasm.kill_frame(e)};ke.prototype.getFramePosition=function(e){this._ensureInit();var t=this._wasm.get_frame_position(e);return t.length===2?{x:t[0],y:t[1]}:null};ke.prototype.getFrameProperty=function(e,t){this._ensureInit();for(var r=Ke.get("Frame"),n=null,i=0;i<r.fields.length;i++)if(r.fields[i].name===t){n=r.fields[i];break}if(!n)throw new TypeError('[getFrameProperty] Unknown property "'+t+'" for kind "Frame". Valid properties: '+r.fields.map(function(s){return s.name}).join(", "));var a=this._wasm.get_frame_property(e,t);if(a==null)return null;if(typeof a=="string")try{return JSON.parse(a)}catch{return a}return a};ke.prototype.setFrameProperty=function(e,t,r){this._ensureInit();for(var n=Ke.get("Frame"),i=null,a=0;a<n.fields.length;a++)if(n.fields[a].name===t){i=n.fields[a];break}if(!i)throw new TypeError('[setFrameProperty] Unknown property "'+t+'" for kind "Frame". Valid properties: '+n.fields.map(function(u){return u.name}).join(", "));if(i.type==="forbidden")throw new TypeError('[setFrameProperty] Property "'+t+'" is engine-owned topology \u2014 structure is engine-derived. Set position and let the next tick reconcile.');if(i.type==="readonly")throw new TypeError('[setFrameProperty] Property "'+t+'" is read-only (derived: '+t+").");var s=r;if(t==="charge"){if(r==="POSITIVE"||r==="Positive")s=0;else if(r==="NEGATIVE"||r==="Negative")s=1;else if(typeof r!="number")throw new TypeError("[setFrameProperty] Invalid charge value: "+JSON.stringify(r)+'. Use "POSITIVE" or "NEGATIVE".')}var l=s==null?"null":JSON.stringify(s);this._wasm.set_frame_property(e,t,l)};function Il(e,t){var r=new lt(e.x!=null?e.x:0,e.y!=null?e.y:0,e.w!=null?e.w:1,e.h!=null?e.h:1,null,!0),n=e.data!==void 0&&e.data!==null?e.data:null;if(n&&n.string_map instanceof Map){var i={};n.string_map.forEach(function(a,s){i[s]=a}),n=Object.assign({},n,{string_map:i})}return new Hm(e.tick!=null?e.tick:t,e.id!=null?e.id:0,e.layer!=null?e.layer:0,r,e.fullness!=null?e.fullness:0,e.is_alive!==!1,e.child_count!=null?e.child_count:0,e.mass!=null?e.mass:1,e.collided_id!=null?e.collided_id:-1,e.vx!=null?e.vx:0,e.vy!=null?e.vy:0,e.z!=null?e.z:0,e.vz!=null?e.vz:0,n)}o(Il,"_wrapRawFrame");function $f(e){if(!Array.isArray(e)||e.length!==6)throw new Error("wasm-engine: TickData boundary_rect must be the engine's 6-tuple (x, y, z, w, h, d) \u2014 got "+JSON.stringify(e)+". The world bounds are owned by the engine (tick_data.rs UniverseData/DimensionData::boundary_rect); the shim ferries them and never re-derives them from the JS-side config rect.");var t=e[0],r=e[1],n=e[2],i=e[3],a=e[4],s=e[5];return{x:t,y:r,z:n,w:i,h:a,d:s,left:t-i/2,right:t+i/2,top:r-a/2,bottom:r+a/2,near:n-s/2,far:n+s/2,r:i/2}}o($f,"_wrapBoundaryRect");ke.prototype._wrapTickData=function(e){var t=new Ym(e.universe!=null?e.universe.tick:this.tick,e.universe!=null?e.universe.dimension_count:0,$f(e.universe&&e.universe.boundary_rect)),r=new Pl(t);if(e.dimensions)for(var n=0;n<e.dimensions.length;n++){var i=e.dimensions[n];r.addDimensionData(new Km(i.tick!=null?i.tick:this.tick,i.layer!=null?i.layer:0,i.frame_count!=null?i.frame_count:0,$f(i.boundary_rect)))}if(e.frames)for(var a=0;a<e.frames.length;a++)r.addFrameData(Il(e.frames[a],this.tick));if(e.objects&&Array.isArray(e.objects)&&e.objects.length>0){r.objects||(r.objects=[]);for(var s=this.tick,l=0;l<e.objects.length;l++){var u=e.objects[l];r.objects.push({handle:u.handle!=null?u.handle:l,count:u.count!=null?Number(u.count):0,frames:Array.isArray(u.frames)?u.frames.map(function(f){return Il(f,s)}):[]})}}return r};ke.prototype.unregisterLargeObject=function(e){this._ensureInit(),this._wasm.unregister_large_object(e);for(var t=this.largeObjects.length-1;t>=0;t--)this.largeObjects[t]&&this.largeObjects[t].handle===e&&this.largeObjects.splice(t,1);var r=this._loHandles.indexOf(e);r!==-1&&this._loHandles.splice(r,1)};ke.prototype.unwrappedLargeObjectHandles=function(){var e=Object.create(null),t;for(t=0;t<this.largeObjects.length;t++)this.largeObjects[t]&&(e[this.largeObjects[t].handle]=!0);var r=[];for(t=0;t<this._loHandles.length;t++)e[this._loHandles[t]]||r.push(this._loHandles[t]);return r};function mt(){this.is_alive=!1,this.is_leaf=!1,this.children=[],this.mass=0,this.layer=0,this.rect=null,this.name=null,this._isBoundaryNull=!0}o(mt,"BoundaryFrame");mt.prototype.insert=function(e){return rn&&this._handle!==void 0&&e&&e._handle!==void 0?rn._wasm.insert_into_frame(this._handle,e._handle):(console.log("[shim] Frame.insert: missing handle(s) or no active WASM universe \u2014 returning null"),null)};mt.prototype.addPoints=function(e){return console.log("[shim] Frame.addPoints not implemented in WASM engine \u2014 returning null"),null};mt.prototype.move=function(e,t){return console.log("[shim] Frame.move not implemented in WASM engine \u2014 returning null"),null};mt.prototype.compress=function(){return console.log("[shim] Frame.compress not implemented in WASM engine \u2014 returning null"),null};mt.prototype.reinit=function(){return console.log("[shim] Frame.reinit not implemented in WASM engine \u2014 returning null"),null};mt.prototype.kill=function(){return console.log("[shim] Frame.kill not implemented in WASM engine \u2014 returning null"),null};mt.prototype.reset=function(){return console.log("[shim] Frame.reset not implemented in WASM engine \u2014 returning null"),null};mt.prototype.toFrameData=function(){return console.log("[shim] Frame.toFrameData not implemented in WASM engine \u2014 returning null"),null};mt.prototype.checkCollision=function(){return console.log("[shim] Frame.checkCollision not implemented in WASM engine \u2014 returning null"),null};mt.prototype.collide=function(){return console.log("[shim] Frame.collide not implemented in WASM engine \u2014 returning null"),null};mt.prototype.merge=function(){return console.log("[shim] Frame.merge not implemented in WASM engine \u2014 returning null"),null};mt.prototype.bond=function(){return console.log("[shim] Frame.bond not implemented in WASM engine \u2014 returning null"),null};mt.prototype.bounce=function(){return console.log("[shim] Frame.bounce not implemented in WASM engine \u2014 returning null"),null};mt.prototype.boundary_check=function(){return console.log("[shim] Frame.boundary_check not implemented in WASM engine \u2014 returning null"),null};mt.prototype.setWavelength=function(){return console.log("[shim] Frame.setWavelength not implemented in WASM engine \u2014 returning null"),null};mt.makeLeafFrame=function(e,t,r,n,i,a,s,l,u,f){if(!rn){console.log("[shim] Frame.makeLeafFrame: no active WASM universe \u2014 returning null");var c=new mt;return c.layer=r||0,c}var h=rn.makeLeafFrame(e,t,r,n,i,a,s,l);if(h===null){var g=new mt;return g.layer=r||0,g}var p=new mt;return p._handle=h,p.layer=r||0,p.is_leaf=!0,p.is_alive=!0,p._isBoundaryNull=!1,p};function i_(e,t){var r=Math.pow(2,e),n=r,i=!1,a={layer:e,mb_w:r,mb_h:n,frames:[],addFrame:o(function(s){var l=t||rn&&rn._wasm;if(l&&s&&s._handle!==void 0){l.add_frame_to_dimension(e,s._handle);return}return console.log("[shim] Dimension.addFrame: missing handle or no active WASM universe \u2014 returning null"),null},"addFrame"),createFrameFromRect:o(function(s,l,u,f,c,h,g){var p=t||rn&&rn._wasm;if(p&&s){var m=(l||[]).map(function(A){return A&&A._handle!==void 0?A._handle:0}),b=[s.left||0,s.top||0,s.w||r,s.h||n],y=4294967295,w=p.create_frame_from_rect(e,b,m,u||0,f||0,c!==!1,!!h);if(w>=y)return console.log("[shim] Dimension.createFrameFromRect: Rust returned INVALID \u2014 returning sentinel"),new mt;var O=new mt;if(O._handle=w,O.layer=e,O.is_alive=!0,O._isBoundaryNull=!1,g&&typeof p.get_frame_quantum_id=="function"){var S=p.get_frame_quantum_id(w);S>0&&tg(p,S,g)}return O}return console.log("[shim] Dimension.createFrameFromRect: no active WASM universe \u2014 returning sentinel"),new mt},"createFrameFromRect"),createParentFrame:o(function(s,l){var u=t||rn&&rn._wasm;if(u&&s&&s._handle!==void 0&&l&&l._handle!==void 0){var f=4294967295,c=u.create_parent_frame(e,s._handle,l._handle);if(c>=f)return console.log("[shim] Dimension.createParentFrame: Rust returned INVALID \u2014 returning sentinel"),new mt;var h=new mt;return h._handle=c,h.layer=e,h.is_alive=!0,h._isBoundaryNull=!1,h}return console.log("[shim] Dimension.createParentFrame: missing handle(s) or no active WASM universe \u2014 returning null"),new mt},"createParentFrame"),handleStructurePromotion:o(function(s,l){return console.log("[shim] Dimension.handleStructurePromotion not implemented in WASM engine \u2014 returning null"),null},"handleStructurePromotion"),generateFrames:o(function(s){return console.log("[shim] Dimension.generateFrames not implemented in WASM engine \u2014 returning null"),null},"generateFrames"),addPointsFromQuadTree:o(function(s){return console.log("[shim] Dimension.addPointsFromQuadTree not implemented in WASM engine \u2014 returning null"),null},"addPointsFromQuadTree"),releasePoints:o(function(s){return console.log("[shim] Dimension.releasePoints not implemented in WASM engine \u2014 returning null"),null},"releasePoints"),reset:o(function(){return console.log("[shim] Dimension.reset not implemented in WASM engine \u2014 returning null"),null},"reset"),update:o(function(s,l){return console.log("[shim] Dimension.update not implemented in WASM engine \u2014 returning null"),null},"update"),collectFrameData:o(function(s){return console.log("[shim] Dimension.collectFrameData not implemented in WASM engine \u2014 returning null"),null},"collectFrameData"),getMassForColor:o(function(s){return console.log("[shim] Dimension.getMassForColor not implemented in WASM engine \u2014 returning null"),null},"getMassForColor"),getWavelengthForColor:o(function(s){return console.log("[shim] Dimension.getWavelengthForColor not implemented in WASM engine \u2014 returning null"),null},"getWavelengthForColor"),alignMBtoDimGrid:o(function(s){return console.log("[shim] Dimension.alignMBtoDimGrid not implemented in WASM engine \u2014 returning null"),null},"alignMBtoDimGrid"),getQtreeFromFrames:o(function(){return console.log("[shim] Dimension.getQtreeFromFrames not implemented in WASM engine \u2014 returning null"),null},"getQtreeFromFrames")};return Object.defineProperty(a,"isHidden",{get:o(function(){return i},"get"),set:o(function(s){i=s},"set"),enumerable:!0,configurable:!0}),a}o(i_,"_makeBoundaryDimension");var rh=null,rn=null;function rg(e){if(!e)throw new Error("[wasm-engine] WasmUniverse constructor is required.");return rh=e,{backend:"wasm",Rectangle:lt,EGPTUniverse:ke,Frame:mt,TickData:Pl,FrameData:Hm,DimensionData:Km,UniverseData:Ym,LightColor:xn,Charge:Jw,createUniverse:o(function(){throw new Error("handle.createUniverse(canvasRect, opts) is DELETED \u2014 it was a second construction convention with divergent defaults (seed 0, not 42). Use the ONE construction authority: handle.EGPTUniverse.create({ rect: canvasRect, seed: \u2026 }). `rect` accepts the same { left, top, w, h } literal.")},"createUniverse")}}o(rg,"makeProvider");var ng="[engine] JS reference engine archived \u2014 FRQTL is WASM-only. Remove ?engine=js / --engine js / EGPT_ENGINE=js; the only FRQTL physics engine is the compiled Rust/WASM engine (frqtl/crates/egpt_engine \u2192 fat/pkg-web).";function Fl(e,t){let r=t;if(!r||typeof r!="object")throw new TypeError("[engine] refuseRetiredDoors(bag, table): the owner's table of retired names is required. (FAIL-LOUD.)");for(let n of Object.keys(r)){if(typeof r[n]!="string"||!r[n])throw new TypeError('[engine] refuseRetiredDoors: the retirement message for "'+n+`" must be a non-empty string (it is the replacement's one home). (FAIL-LOUD.)`);let i=Object.getOwnPropertyDescriptor(e,n);if(i&&!i.configurable)throw new Error('[engine] this page already holds a global "'+n+'" (a `var` or function declaration in a classic script), and that name is a retired FRQTL door: '+r[n]+" Keep the page's own binding off the global object \u2014 declare it inside a function or a block (const/let), or import it from the ES module doors. (FAIL-LOUD.)");Object.defineProperty(e,n,{enumerable:!1,configurable:!1,get:o(function(){throw new Error(r[n])},"get"),set:o(function(){throw new Error(r[n])},"set")})}return e}o(Fl,"refuseRetiredDoors");var nh=null,Va=null,ih=null,qa="unbooted";function ah(e,t){if(!e||typeof e.load!="function"||typeof e.env!="string")throw new TypeError("[engine] bootEngine(loader): loader must be a WASM loader \u2014 browserWasmLoader (compat/providers/wasm-load-browser.js) or nodeWasmLoader (compat/providers/wasm-load-node.js). (FAIL-LOUD.)");if(Va){if(e!==nh)throw new Error('[engine] bootEngine: this realm already booted its engine with the "'+nh.env+'" loader \u2014 one engine per realm; a second loader is refused. (FAIL-LOUD.)');return Va}nh=e;let r=t&&t.engine;return r!=null&&r!=="wasm"?(qa="failed",Va=Promise.reject(new Error(ng+' (requested engine="'+r+'")')),Va):(qa="booting",Va=e.load().then(function(n){let i=rg(n.WasmUniverse);return i.env=e.env,ih=i,qa="booted",i},function(n){throw qa="failed",n}),Va)}o(ah,"bootEngine");function Hi(){if(ih)return ih;throw new Error("[engine] the engine is not booted (state: "+qa+") \u2014 boot it through a door first: await bootEngine(loader) (lib/frqtl/compat/engine.js), which the boot module (experiments/_shared/boot.js) and the node door call for you. (FAIL-LOUD.)")}o(Hi,"engine");function Ho(){return qa}o(Ho,"engineState");ja();ni();var Ba={w:300,h:200,radius:2,gain:4,blur:!0};function a_(e,t){zn("FieldBuilder.buildHeightField(frameData, Object.assign({}, FIELD_OPTS, { canvasW, canvasH })) opts.canvasW/canvasH",t&&t.canvasW,t&&t.canvasH);var r=t.canvasW,n=t.canvasH,i=t.w||Ba.w,a=t.h||Ba.h,s=t.radius!==void 0?t.radius:Ba.radius,l=t.gain!==void 0?t.gain:Ba.gain,u=t.blur!==void 0?t.blur:Ba.blur,f=s*s,c=new Float32Array(i*a);if(e)for(var h=i/r,g=a/n,p=0;p<e.length;p++){var m=e[p],b=m.rect.x*h,y=m.rect.y*g,w=Math.round(b)|0,O=Math.round(y)|0,S=m.fullness||0;if(!(S<=0))for(var A=Math.max(0,w-s),C=Math.min(i-1,w+s),R=Math.max(0,O-s),Q=Math.min(a-1,O+s),Y=R;Y<=Q;Y++)for(var H=Y-O,q=A;q<=C;q++){var T=q-w,J=T*T+H*H;if(!(J>f)){var D=1-J/f;c[Y*i+q]+=S*D}}}for(var K=new Uint8Array(i*a),N=0;N<c.length;N++){var B=Math.round(c[N]*l*255);K[N]=B>255?255:B}if(u&&i>2&&a>2){var ne=new Uint8Array(i*a),oe,$,de,ve,ue,L;for(oe=0;oe<a;oe++){var ee=oe*i;for(ne[ee]=K[ee],ne[ee+i-1]=K[ee+i-1],$=1;$<i-1;$++)de=ee+$,ve=K[de-1],ue=K[de],L=K[de+1],ne[de]=ve+2*ue+L+2>>2}for($=0;$<i;$++)K[$]=ne[$],K[(a-1)*i+$]=ne[(a-1)*i+$];for(oe=1;oe<a-1;oe++)for($=0;$<i;$++)ve=ne[(oe-1)*i+$],ue=ne[oe*i+$],L=ne[(oe+1)*i+$],K[oe*i+$]=ve+2*ue+L+2>>2}return K}o(a_,"buildHeightField");var Er={FIELD_OPTS:Ba,buildHeightField:a_};lf();Rt();var o_=new URL("../../../fat/pkg-web/egpt_wasm.js",new URL("frqtl/compat/providers/wasm-load-browser.js",He()).href).href,ig=null;async function s_(e){let t=typeof crypto<"u"?crypto.subtle:null;if(!t||typeof t.digest!="function")return null;let r=new Uint8Array(await t.digest("SHA-256",e)),n="";for(let i=0;i<r.length;i++)n+=(r[i]<16?"0":"")+r[i].toString(16);return n}o(s_,"_sha256Hex");function ag(){return ig}o(ag,"loadedWasmSha256");async function l_(e){let t=e||o_,r;try{r=await import(t)}catch(a){throw new Error("[wasm-load-browser] the WASM package glue did not load from "+t+" ("+(a&&a.message?a.message:String(a))+`).
|
|
1
|
+
var FRQTL=(()=>{var Xs=Object.defineProperty;var nb=Object.getOwnPropertyDescriptor;var ab=Object.getOwnPropertyNames;var ob=Object.prototype.hasOwnProperty;var o=(e,t)=>Xs(e,"name",{value:t,configurable:!0});var ue=(e,t)=>()=>(e&&(t=e(e=0)),t);var ge=(e,t)=>{for(var r in t)Xs(e,r,{get:t[r],enumerable:!0})},sb=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ab(t))!ob.call(e,n)&&n!==r&&Xs(e,n,{get:()=>t[n],enumerable:!(i=nb(t,n))||i.enumerable});return e};var lb=e=>sb(Xs({},"__esModule",{value:!0}),e);function ze(){return cb}var cb,At=ue(()=>{cb=new URL("../../",new URL("frqtl/compat/package-root.js",new URL(".",document.currentScript.src)).href).href;o(ze,"packageRoot")});var Pn={};ge(Pn,{ANGULAR_FIELDS:()=>Zs,POINT_FIELDS:()=>gu,hasAngularPose:()=>So,makePoseNotice:()=>Ao,normalizeOrbitPatch:()=>ko,normalizePoint:()=>ad});function So(e){if(e==null)return!1;var t=e.poseFields;if(!Array.isArray(t))throw new Error("camera pose: the camera handle publishes no `poseFields` array, so whether it has angular axes cannot be read \u2014 every getCameraControl() handle declares its axes (RENDERER_CONTRACT \xA71a.2). (FAIL-LOUD.)");for(var r=0;r<t.length;r++)if(t[r]&&Zs.indexOf(t[r].name)!==-1)return!0;return!1}function mu(e,t){throw new Error("camera pose: `"+e+"` must be a POINT \u2014 either {x, y, z} or [x, y, z] (z optional, defaults to 0), with finite numbers, or null to re-centre. Got "+ub(t)+". Throw-or-apply: a malformed point is never silently reset and never silently clamped. (FAIL-LOUD.)")}function ub(e){if(Array.isArray(e))return"an array of length "+e.length+" ("+e.join(", ")+")";if(e===null)return"null";if(typeof e=="object"){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return"an object {"+t.join(", ")+"}"}return typeof e+" "+String(e)}function Oa(e){return typeof e=="number"&&isFinite(e)?e:null}function ad(e,t){if(e==null)return null;var r,i,n;return Array.isArray(e)?(e.length!==2&&e.length!==3&&mu(t,e),r=Oa(e[0]),i=Oa(e[1]),n=e.length===3?Oa(e[2]):0):typeof e=="object"?(r=Oa(e.x),i=Oa(e.y),n=e.z===void 0||e.z===null?0:Oa(e.z)):mu(t,e),(r===null||i===null||n===null)&&mu(t,e),{x:r,y:i,z:n}}function ko(e){if(!e||typeof e!="object")return e;var t={},r;for(r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);for(var i=0;i<gu.length;i++){var n=gu[i];n in e&&(t[n]=ad(e[n],n))}return t}function Ao(){var e=[];return{add:o(function(t){if(typeof t!="function")throw new TypeError("[OrbitBag] addPoseListener(fn) needs a function, got "+String(t)+". (FAIL-LOUD.)");return e.indexOf(t)===-1&&e.push(t),function(){var r=e.indexOf(t);r!==-1&&e.splice(r,1)}},"add"),notify:o(function(t){for(var r=e.slice(),i=0;i<r.length;i++)r[i](t)},"notify")}}var gu,Zs,Ea=ue(()=>{gu=["target"],Zs=["azimuth","elevation","roll"];o(So,"hasAngularPose");o(mu,"_reject");o(ub,"_describe");o(Oa,"_finiteOrNull");o(ad,"normalizePoint");o(ko,"normalizeOrbitPatch");o(Ao,"makePoseNotice")});var vu={};ge(vu,{CameraControls:()=>$s});function nn(e,t,r){return e<t?t:e>r?r:e}function fb(){return{mounted:!1,dispose:o(function(){},"dispose"),getState:o(function(){return null},"getState"),setState:o(function(){},"setState"),sync:o(function(){},"sync")}}function hb(e,t,r){r=r||{};var i=e&&e.cameraControl?e.cameraControl:null;if(!So(i))return fb();if(typeof i.setOrbit!="function"||typeof i.getOrbit!="function")throw new Error("[CameraControls] the camera declares angular axes but its handle has no setOrbit()/getOrbit() \u2014 every getCameraControl() handle sets and reads its pose (RENDERER_CONTRACT \xA71a.2). (FAIL-LOUD.)");if(t&&t.__frqtlCameraHandle&&t.__frqtlCameraHandle.mounted)return t.__frqtlCameraHandle;if(e.__frqtlCameraHandle&&e.__frqtlCameraHandle.mounted)return e.__frqtlCameraHandle;var n=t&&t.ownerDocument?t.ownerDocument:typeof document<"u"?document:null,a=typeof r.lookSpeed=="number"?r.lookSpeed:90,s=typeof r.moveRate=="number"?r.moveRate:.6,l=typeof r.dollySpeed=="number"?r.dollySpeed:900,c=typeof i.move=="function",f=typeof i.look=="function",u=typeof r.wheelStep=="number"?r.wheelStep:60,h=typeof r.minDistance=="number"?r.minDistance:20,g=typeof r.maxDistance=="number"?r.maxDistance:12e3,d=r.keyboard!==!1,m=r.keyboardTarget||(n?n.defaultView:null),b=r.joysticks!==!1;r.initialOrbit&&i.setOrbit(r.initialOrbit);var y=null;function w(){var se=i.getOrbit();if(y)for(var ve in se)Object.prototype.hasOwnProperty.call(se,ve)&&typeof se[ve]=="number"&&y.setAttribute("data-cam-"+ve.toLowerCase(),String(Math.round(se[ve]*100)/100));return se}o(w,"publishState");var x={x:0,y:0},S={x:0,y:0},A={};function T(){var se=0,ve=0;return A.KeyA&&(se-=1),A.KeyD&&(se+=1),A.KeyW&&(ve+=1),A.KeyS&&(ve-=1),{x:se,y:ve}}o(T,"keyMove");function j(){var se=0,ve=0;return A.ArrowLeft&&(se-=1),A.ArrowRight&&(se+=1),A.ArrowUp&&(ve+=1),A.ArrowDown&&(ve-=1),{x:se,y:ve}}o(j,"keyLook");function Q(){if(x.x||x.y||S.x||S.y)return!0;for(var se in A)if(A[se])return!0;return!1}o(Q,"anyInputActive");var Y=null,H=0,V=typeof performance<"u"&&performance.now?function(){return performance.now()}:function(){return Date.now()},C=typeof requestAnimationFrame=="function"?requestAnimationFrame:function(se){return setTimeout(function(){se(V())},16)},J=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:clearTimeout;function R(){e&&!e.isRunning&&typeof e.repaint=="function"&&e.repaint()}o(R,"paintIfStopped");function K(se){Y=null;var ve=(se-H)/1e3;H=se,ve<=0&&(ve=.016),ve>.1&&(ve=.1);var Lt=T(),ct=j(),Kt=nn(S.x+ct.x,-1,1),Et=nn(S.y+ct.y,-1,1),ut=nn(x.x+Lt.x,-1,1),ot=nn(x.y+Lt.y,-1,1),Qr=i.getOrbit();if(f&&(Kt||Et)&&i.look({spin:Kt*a*ve,pitch:Et*a*ve}),ut||ot)if(c){var Yt=Math.max(Qr.distance,1)*s*ve;i.move({forward:ot*Yt,strafe:ut*Yt})}else ot&&i.setOrbit({distance:nn(Qr.distance-ot*l*ve,h,g)});(Kt||Et||ut||ot)&&R(),w(),Q()&&N()}o(K,"frame");function N(){Y===null&&(H=V(),Y=C(K))}o(N,"scheduleFrame");var B={ArrowLeft:1,ArrowRight:1,ArrowUp:1,ArrowDown:1,KeyW:1,KeyA:1,KeyS:1,KeyD:1};function ie(se){var ve=se.code||se.key;if(!((ve==="Space"||B[ve])&&sd(se,n))){if(ve==="Space"){if(!e||typeof e.grabToggle!="function"||!e.isAimArmed()||(se.preventDefault&&se.preventDefault(),se.repeat))return;e.grabToggle(),R();return}B[ve]&&(A[ve]=!0,se.preventDefault&&se.preventDefault(),N())}}o(ie,"onKeyDown");function oe(se){var ve=se.code||se.key;B[ve]&&(A[ve]=!1)}o(oe,"onKeyUp"),d&&m&&m.addEventListener&&(m.addEventListener("keydown",ie),m.addEventListener("keyup",oe));var $=null,pe=null;function ye(){if(t&&typeof t.focus=="function")try{t.focus({preventScroll:!0})}catch{try{t.focus()}catch{}}}o(ye,"focusMount"),d&&t&&t.addEventListener&&((typeof t.tabIndex!="number"||t.tabIndex<0)&&($=t.getAttribute&&t.hasAttribute&&t.hasAttribute("tabindex")?t.getAttribute("tabindex"):!1,t.tabIndex=-1,t.style&&(t.style.outline="none")),pe=o(function(){ye()},"onMountPointerDown"),t.addEventListener("pointerdown",pe,!0),ye());var ce=null,L=null,ee={roaming:o(function(){return"ROAMING \u2014 aim the reticle at an object"},"roaming"),"grab-ready":o(function(se){return"GRAB-READY "+(se.hover||"object")+" \u2014 press SPACE to grab"},"grab-ready"),grabbed:o(function(se){return"GRABBED "+(se.grabbed||"object")+" \u2014 move the world to place it, SPACE to release"},"grabbed")};function X(){var se=n.createElement("div");return se.setAttribute("data-role","aim-state"),se.style.cssText="position:absolute;left:50%;transform:translateX(-50%);bottom:118px;display:none;max-width:70%;padding:4px 8px;border-radius:4px;background:rgba(20,30,38,0.8);border:1px solid rgba(255,170,0,0.7);color:rgba(240,240,240,0.95);pointer-events:none;z-index:40;font:11px sans-serif;line-height:1.45;text-align:center;",se}o(X,"makeAimLabel");function te(){if(ce){var se=e.getAimState();if(ce.setAttribute("data-aim-state",se.state),ce.setAttribute("data-aim-target",se.grabbed||se.hover||""),ce.setAttribute("data-aim-edge",se.atEdge?"true":"false"),ce.setAttribute("data-aim-heading-held",se.headingHeld?"true":"false"),ce.setAttribute("data-aim-z-held",se.zHeld?"true":"false"),se.state==="off"){ce.style.display="none",ce.textContent="";return}var ve=[ee[se.state](se)];se.atEdge&&ve.push("AT WORLD EDGE \u2014 held at the universe boundary"),se.headingHeld&&ve.push("HEADING HELD \u2014 it points along the depth axis"),se.zHeld&&ve.push("Z HELD \u2014 a flat (z-less) wall stays on the z = 0 plane"),se.error&&ve.push("NOT HELD: "+se.error),ce.textContent=ve.join(`
|
|
2
|
+
`),ce.style.whiteSpace="pre-line",ce.style.color=se.state==="grabbed"?"#ffcc66":"rgba(240,240,240,0.95)",ce.style.display="block"}}o(te,"renderAimLabel");var be=[],Oe=[],Ue=null,Ce=null;function xe(se,ve,Lt){var ct=n.createElement("div");ct.setAttribute("data-role","camera-joystick"),ct.setAttribute("data-stick",se==="left"?"move":"look"),ct.style.cssText="position:absolute;bottom:16px;"+(se==="left"?"left:16px;":"right:16px;")+"width:96px;height:96px;border-radius:50%;background:rgba(20,30,38,0.55);border:1px solid rgba(126,200,227,0.5);touch-action:none;z-index:40;box-sizing:border-box;user-select:none;-webkit-user-select:none;cursor:grab;";var Kt=n.createElement("div");Kt.textContent=ve,Kt.style.cssText="position:absolute;top:4px;left:0;right:0;text-align:center;color:rgba(126,200,227,0.85);font:10px sans-serif;pointer-events:none;";var Et=n.createElement("div");Et.setAttribute("data-role","camera-joystick-knob"),Et.style.cssText="position:absolute;left:50%;top:50%;width:34px;height:34px;margin:-17px 0 0 -17px;border-radius:50%;background:rgba(126,200,227,0.85);pointer-events:none;transition:transform 0.06s linear;",ct.appendChild(Kt),ct.appendChild(Et);var ut=48,ot=null;function Qr(pr){var tr=ct.getBoundingClientRect(),fo=tr.left+tr.width/2,ua=tr.top+tr.height/2,fa=pr.clientX-fo,ho=pr.clientY-ua,fi=nn(fa/ut,-1,1),Ci=nn(-ho/ut,-1,1);Lt.x=fi,Lt.y=Ci,Et.style.transform="translate("+fi*(ut-17)+"px,"+-Ci*(ut-17)+"px)",N()}o(Qr,"setFromEvent");var Yt=null,hr=null;function _n(){n&&n.removeEventListener&&(Yt&&n.removeEventListener("pointermove",Yt),hr&&(n.removeEventListener("pointerup",hr),n.removeEventListener("pointercancel",hr))),Yt=null,hr=null}o(_n,"detachDoc");function xn(){if(ct.releasePointerCapture&&ot!==null)try{ct.releasePointerCapture(ot)}catch{}ot=null,Lt.x=0,Lt.y=0,Et.style.transform="translate(0px,0px)",ct.style.cursor="grab",_n()}return o(xn,"release"),ct.addEventListener("pointerdown",function(pr){if(ot=pr.pointerId,ct.style.cursor="grabbing",ye(),ct.setPointerCapture)try{ct.setPointerCapture(pr.pointerId)}catch{}Yt=o(function(tr){ot===tr.pointerId&&Qr(tr)},"onDocMove"),hr=o(function(tr){ot===tr.pointerId&&xn()},"onDocUp"),n&&n.addEventListener&&(n.addEventListener("pointermove",Yt),n.addEventListener("pointerup",hr),n.addEventListener("pointercancel",hr)),Qr(pr),pr.preventDefault&&pr.preventDefault()}),Oe.push(function(){xn()}),ct}if(o(xe,"makePad"),b&&n&&t){var Ve=n.defaultView&&n.defaultView.getComputedStyle?n.defaultView.getComputedStyle(t).position:t.style.position;(Ve==="static"||!Ve)&&(Ue=t.style.position||"",t.style.position="relative"),y=n.createElement("div"),y.setAttribute("data-role","camera-controls"),y.style.cssText="position:absolute;inset:0;pointer-events:none;z-index:39;";var Ot=xe("left","MOVE",x),Wt=xe("right","LOOK",S);Ot.style.pointerEvents="auto",Wt.style.pointerEvents="auto",y.appendChild(Ot),y.appendChild(Wt),t.appendChild(y),be=[Ot,Wt],e&&typeof e.addAimListener=="function"&&(ce=X(),y.appendChild(ce),L=e.addAimListener(te),te()),u>0&&(Ce=o(function(se){var ve=i.getOrbit(),Lt=nn(ve.distance+(se.deltaY>0?1:-1)*u,h,g);i.setOrbit({distance:Lt}),R(),w(),se.preventDefault&&se.preventDefault()},"onWheel"),t.addEventListener("wheel",Ce,{passive:!1}))}w();var zt={mounted:!0,dispose:o(function(){t&&t.__frqtlCameraHandle===zt&&(t.__frqtlCameraHandle=null),e.__frqtlCameraHandle===zt&&(e.__frqtlCameraHandle=null),Y!==null&&(J(Y),Y=null);for(var se=0;se<Oe.length;se++)try{Oe[se]()}catch{}Oe=[],d&&m&&m.removeEventListener&&(m.removeEventListener("keydown",ie),m.removeEventListener("keyup",oe)),pe&&t&&t.removeEventListener&&t.removeEventListener("pointerdown",pe,!0),$!==null&&t&&($===!1?t.removeAttribute&&t.removeAttribute("tabindex"):t.setAttribute&&t.setAttribute("tabindex",$)),Ce&&t&&t.removeEventListener&&t.removeEventListener("wheel",Ce),L&&(L(),L=null),ce=null,y&&y.parentNode&&y.parentNode.removeChild(y),Ue!==null&&t&&(t.style.position=Ue),be=[],y=null},"dispose"),getState:o(function(){return i.getOrbit()},"getState"),setState:o(function(se){i.setOrbit(se),w()},"setState"),sync:o(function(){w()},"sync")};return t&&(t.__frqtlCameraHandle=zt),e.__frqtlCameraHandle=zt,zt}function od(e){var t=e&&e.tagName;return!!e&&(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable===!0)}function sd(e,t){return od(e&&e.target)||!!(t&&od(t.activeElement))}var $s,yu=ue(()=>{Ea();o(nn,"clamp");o(fb,"noopHandle");o(hb,"attach");o(od,"_isEditable");o(sd,"isTypingTarget");$s={attach:hb,isTypingTarget:sd}});var bu={};ge(bu,{CameraPath:()=>Sa});function br(e){throw new Error("[CameraPath] "+e+" (FAIL-LOUD.)")}function el(e,t){if(typeof e=="number"&&isFinite(e))return e;br(t+" must be a finite number, got "+String(e))}function pb(e,t,r,i){var n=i/2,a=((t-e)%i+i+n)%i-n;return e+a*r}function ld(e,t,r){return e+(t-e)*r}function db(e,t,r){for(var i={},n=cd(e,t),a=0;a<n.length;a++){var s=n[a],l=e[s],c=t[s];typeof l=="number"&&typeof c=="number"?i[s]=ld(l,c,r):i[s]=c===void 0?l:c}return i}function tl(e,t,r,i){(!Array.isArray(e)||!e.length)&&br("poseAt needs at least one waypoint");var n=e[0],a=e[e.length-1],s=el(t,"tick");if(r&&e.length>1){var l=a.atTick-n.atTick;l>0&&(s=n.atTick+((s-n.atTick)%l+l)%l)}if(s<=n.atTick)return To(n.pose);if(s>=a.atTick)return To(a.pose);for(var c=0;c<e.length-1&&e[c+1].atTick<=s;)c++;for(var f=e[c],u=e[c+1],h=u.atTick-f.atTick,g=h>0?(s-f.atTick)/h:0,d={},m=cd(f.pose,u.pose),b=0;b<m.length;b++){var y=m[b],w=f.pose[y],x=u.pose[y];if(w===void 0){d[y]=rl(x);continue}if(x===void 0){d[y]=rl(w);continue}if(y==="target"){if(w===null&&x===null){d[y]=null;continue}(w===null||x===null)&&br("cannot interpolate `target` between null (scene centre) and a concrete point across the segment at ticks "+f.atTick+"\u2192"+u.atTick+" \u2014 declare target on both waypoints or neither"),d[y]=db(w,x,g);continue}if(typeof w=="number"&&typeof x=="number"){var S=i?i[y]:void 0;d[y]=typeof S=="number"&&S>0?pb(w,x,g,S):ld(w,x,g);continue}d[y]=rl(x)}return d}function cd(e,t){var r=Object.create(null),i=[];return[e,t].forEach(function(n){n&&Object.keys(n).forEach(function(a){r[a]||(r[a]=1,i.push(a))})}),i}function rl(e){return e&&typeof e=="object"?JSON.parse(JSON.stringify(e)):e}function To(e){var t={};return e&&Object.keys(e).forEach(function(r){t[r]=rl(e[r])}),t}function mb(e,t){(!e||typeof e.addTickListener!="function")&&br("attach needs an FrqtlApp with a per-tick listener fan-out");var r=e.cameraControl;r||br("this renderer exposes NO camera pose control (runner.cameraControl is null), so a declared camera path cannot fly. A UI widget may hide on an absent capability; a programmatic instrument must not silently do nothing \u2014 a golden or a corpus row built on a camera path that never moved is fabricated evidence"),t=t||{};var i=t.waypoints;(!Array.isArray(i)||!i.length)&&br("attach needs at least one waypoint: [{ atTick, pose }]");for(var n={},a=r.poseFields||[],s=0;s<a.length;s++)n[a[s].name]=!0;for(var l=Object.keys(n),c={},f=0;f<a.length;f++){var u=a[f].constraint;u&&typeof u.wrap=="number"&&u.wrap>0&&(c[a[f].name]=u.wrap)}for(var h=i.slice().sort(function(X,te){return X.atTick-te.atTick}),g=0;g<h.length;g++){var d=h[g];(!d||typeof d!="object")&&br("waypoint "+g+" is not an object"),el(d.atTick,"waypoint "+g+" atTick"),(!d.pose||typeof d.pose!="object")&&br("waypoint "+g+" has no pose bag");var m=Object.keys(d.pose);m.length||br("waypoint "+g+" has an EMPTY pose bag");for(var b=0;b<m.length;b++){var y=m[b];l.length&&!n[y]&&br("waypoint "+g+' names pose field "'+y+'", which this camera does NOT declare. Declared axes: ['+l.join(", ")+"]. Read cameraControl.poseFields rather than assuming a mode \u2014 a silently skipped axis is a camera path that does not fly");var w=d.pose[y];if(typeof w=="number"&&el(w,"waypoint "+g+" "+y),y==="target"&&w!==null&&w!==void 0){(typeof w.x!="number"||typeof w.y!="number")&&br("waypoint "+g+" target must be {x,y} (2D) or {x,y,z} (3D), or null");for(var x=Object.keys(w),u=0;u<x.length;u++)typeof w[x[u]]=="number"&&el(w[x[u]],"waypoint "+g+" target."+x[u])}}if(g>0){var S=h[g-1].pose,A="target"in S,T="target"in d.pose;A&&T&&S.target===null!=(d.pose.target===null)&&br("the segment at ticks "+h[g-1].atTick+"\u2192"+d.atTick+" mixes target:null (the scene centre) with a concrete point \u2014 that interpolation is undefined. Declare target on both waypoints or neither")}}var j=!!t.loop,Q=typeof t.anchorTick=="number"&&isFinite(t.anchorTick)?t.anchorTick:null,Y=null,H=typeof t.waypointTimeoutMs=="number"?t.waypointTimeoutMs:1e4,V=0,C=[],J=null,R=-1,K=!1;function N(X){B(tl(h,X,j,c))}o(N,"_applyAt");function B(X){r.setOrbit(X),typeof e.repaint=="function"&&e.repaint()}o(B,"_applyPose");function ie(X){for(var te=0;te<h.length;te++)if(h[te].atTick<=X&&te>R){R=te;for(var be={tick:h[te].atTick,index:te,pose:To(h[te].pose)},Oe=[],Ue=0;Ue<C.length;Ue++)try{var Ce=C[Ue](be);Ce&&typeof Ce.then=="function"&&Oe.push(Ce)}catch(xe){ce("onWaypoint callback threw",xe)}Oe.length&&oe(Oe,be)}}o(ie,"_notifyWaypoints");function oe(X,te,be){typeof e.suspendTicks!="function"&&br("this runner exposes no suspendTicks()/resumeTicks(), so an async onWaypoint handler cannot be guaranteed to observe waypoint "+te.index+". Upgrade the runner, or use only synchronous handlers"),e.suspendTicks(),V+=1;var Oe=!1,Ue=o(function(){Oe||(Oe=!0,V-=1,e.resumeTicks(),typeof be=="function"&&be())},"release"),Ce=null;H>0&&typeof setTimeout=="function"&&(Ce=setTimeout(function(){Oe||(ce("an onWaypoint handler for waypoint "+te.index+" did not settle within "+H+"ms \u2014 releasing the tick clock so the sim does not stay frozen. That capture is NOT waypoint-exact",new Error("waypoint handler timeout")),Ue())},H));var xe=o(function(Ve){if(Ce!==null&&typeof clearTimeout=="function"&&clearTimeout(Ce),Ve)for(var Ot=0;Ot<Ve.length;Ot++)Ve[Ot]&&Ve[Ot].status==="rejected"&&ce("onWaypoint callback rejected",Ve[Ot].reason);Ue()},"settle");typeof Promise.allSettled=="function"?Promise.allSettled(X).then(xe,function(Ve){ce("waypoint hold failed",Ve),Ue()}):Promise.all(X.map(function(Ve){return Ve.then(null,function(){})})).then(function(){xe(null)},function(){Ue()})}o(oe,"_holdUntilSettled");function $(X){return X&&X.universeData&&typeof X.universeData.tick=="number"?X.universeData.tick:null}o($,"_universeTick");function pe(X){if(!K){var te=R+1;te>=h.length||h[te].atTick>X||(K=!0,ye(te,X))}}o(pe,"_drainDue");function ye(X,te){R=X,B(tl(h,h[X].atTick,j,c));for(var be={tick:h[X].atTick,index:X,pose:To(h[X].pose)},Oe=[],Ue=0;Ue<C.length;Ue++)try{var Ce=C[Ue](be);Ce&&typeof Ce.then=="function"&&Oe.push(Ce)}catch(Ve){ce("onWaypoint callback threw",Ve)}var xe=o(function(){var Ve=R+1;Ve<h.length&&h[Ve].atTick<=te?ye(Ve,te):(K=!1,N(te))},"cont");Oe.length?oe(Oe,be,xe):xe()}o(ye,"_fireWaypoint");function ce(X,te){typeof console<"u"&&console.error&&console.error("[CameraPath] "+X+":",te)}o(ce,"_surface");function L(X){var te=$(X);if(te!==null){Y===null&&(Y=Q!==null?Q:te);var be=te-Y;K||N(be),pe(be)}}o(L,"onTick");var ee={get running(){return!!J},start:o(function(){if(!J){var X=e._lastTickData,te=$(X);Y===null&&(Y=Q!==null?Q:te===null?0:te),J=e.addTickListener(L),te!==null&&L(X)}},"start"),get anchorTick(){return Y},stop:o(function(){for(J&&(J(),J=null),K=!1,R=-1,Y=null;V>0;)V-=1,typeof e.resumeTicks=="function"&&e.resumeTicks()},"stop"),dispose:o(function(){ee.stop(),C=[]},"dispose"),poseAt:o(function(X){return tl(h,X,j,c)},"poseAt"),onWaypoint:o(function(X){return typeof X!="function"&&br("onWaypoint needs a function"),C.push(X),function(){var te=C.indexOf(X);te!==-1&&C.splice(te,1)}},"onWaypoint"),get waypoints(){return h.map(function(X){return{atTick:X.atTick,pose:To(X.pose)}})}};return ee}var Sa,il=ue(()=>{o(br,"_fail");o(el,"_finite");o(pb,"_lerpAngle");o(ld,"_lerp");o(db,"_lerpPoint");o(tl,"poseAt");o(cd,"_poseKeys");o(rl,"_copyValue");o(To,"_copyPose");o(mb,"attach");Sa={attach:mb,poseAt:tl}});var nl={};ge(nl,{CollisionActions:()=>st});var st,ti=ue(()=>{st={COUNT:"COUNT",MARK:"MARK",DETECT:"DETECT",LOG:"LOG",ABSORB:"ABSORB",BOUNCE:"BOUNCE",BLOCK:"BLOCK"}});var al={};ge(al,{CollisionTypes:()=>Ee});var Ee,Vt=ue(()=>{Ee={NONE:"NONE",BOUNCE:"BOUNCE",RANDOM_X:"RANDOM_X",RANDOM_Y:"RANDOM_Y",RANDOM_XY:"RANDOM_XY",MOMENTUM_BASED:"MOMENTUM_BASED",WALL:"WALL"}});var Zt={};ge(Zt,{BIN_OPS:()=>yb,Bin:()=>Ab,CMP_OPS:()=>bb,Cmp:()=>Tb,Cond:()=>Cb,FN_NAMES:()=>wb,Fn:()=>jb,HANDLE_FRAME:()=>xb,HANDLE_SELF:()=>Ob,HANDLE_UNIVERSE:()=>Eb,Lit:()=>Sb,NODE_KINDS:()=>gb,OP_KINDS:()=>vb,Ref:()=>kb,StrLit:()=>Rb,TRIGGERS:()=>_b});function Sb(e){return{kind:"Lit",value:e}}function kb(e,t){return{kind:"Ref",handle:e,prop:t}}function Ab(e,t,r){return{kind:"Bin",op:e,a:t,b:r}}function Tb(e,t,r){return{kind:"Cmp",op:e,a:t,b:r}}function Cb(e,t,r){return{kind:"Cond",test:e,then:t,else:r}}function jb(e,t){return{kind:"Fn",name:e,args:t}}function Rb(e){return{kind:"StrLit",value:e}}var gb,vb,yb,bb,wb,_b,xb,Ob,Eb,In=ue(()=>{gb=Object.freeze(["Lit","Ref","Bin","Cmp","Cond","Fn","StrLit"]),vb=Object.freeze(["set"]),yb=Object.freeze(["+","-","*","/"]),bb=Object.freeze(["<",">","=="]),wb=Object.freeze(["min","max","floor","random","intersects"]),_b=Object.freeze(["collision","tick"]),xb=0,Ob=1,Eb=2;o(Sb,"Lit");o(kb,"Ref");o(Ab,"Bin");o(Tb,"Cmp");o(Cb,"Cond");o(jb,"Fn");o(Rb,"StrLit")});var Aa={};ge(Aa,{aabbHalfExtentsFromObb:()=>xu,regionFromObb:()=>_u,resolveSlabFace:()=>ka});function ka(e){e=e||{};var t=+e.w,r=+e.h,i=typeof e.orientationDeg=="number"&&isFinite(e.orientationDeg)?e.orientationDeg:0,n=typeof e.pitchDeg=="number"&&isFinite(e.pitchDeg)?e.pitchDeg:0;if(Math.abs(n)>wu){if(n<-90||n>90)throw new Error("[SlabFace] pitchDeg must be within [-90, 90]; got "+n);var a=typeof e.d=="number"&&isFinite(e.d)&&e.d>0?e.d:0;if(!(a>0))throw new Error("[SlabFace] a PITCHED plate requires a real z-depth (3D wall) \u2014 pitchDeg "+n+" with d="+e.d+". Give the wall a z/depth first.");var s=(i%360+360)%360,l=(90+s)%360,c=l*ol,f=n*ol,u={x:Math.cos(c),y:Math.sin(c),z:0},h={x:-Math.sin(c),y:Math.cos(c)},g={x:h.x*Math.cos(f),y:h.y*Math.cos(f),z:Math.sin(f)},d={x:u.y*g.z-u.z*g.y,y:u.z*g.x-u.x*g.z,z:u.x*g.y-u.y*g.x},m=t/2,b=r/2,y=a/2,w=typeof e.cx=="number"&&isFinite(e.cx)?e.cx:0,x=typeof e.cy=="number"&&isFinite(e.cy)?e.cy:0,S=typeof e.z=="number"&&isFinite(e.z)?e.z:0;return{isCardinal:!1,pitched:!0,reflectBaseDeg:l,obb:null,plate3:{cx:w,cy:x,cz:S,n:g,u,v:d,hw:m,hh:b,hz:y,aabb:{hx:Math.abs(g.x)*m+Math.abs(u.x)*b+Math.abs(d.x)*y,hy:Math.abs(g.y)*m+Math.abs(u.y)*b+Math.abs(d.y)*y,hz:Math.abs(g.z)*m+Math.abs(u.z)*b+Math.abs(d.z)*y}}}}var A=(i%360+360)%360,T=A%90,j=T<wu||90-T<wu,Q=(90+A)%360,Y=null;if(!j){var H=typeof e.cx=="number"&&isFinite(e.cx)?e.cx:0,V=typeof e.cy=="number"&&isFinite(e.cy)?e.cy:0,C=typeof e.z=="number"&&isFinite(e.z)?e.z:0,J=typeof e.d=="number"&&isFinite(e.d)&&e.d>0?e.d:0,R=A*ol,K=Q*ol,N={x:Math.cos(K),y:Math.sin(K)},B={x:-N.y,y:N.x};Y={cx:H,cy:V,cz:C,hw:t/2,hh:r/2,hz:J/2,theta:R,faceDir:N,normal:B}}return{isCardinal:j,reflectBaseDeg:Q,obb:Y}}function _u(e){return e?{kind:"obb",theta:e.theta,hw:e.hw,hh:e.hh,hz:e.hz}:null}function xu(e){if(!e)return null;var t=Math.abs(Math.cos(e.theta)),r=Math.abs(Math.sin(e.theta));return{hx:e.hw*t+e.hh*r,hy:e.hw*r+e.hh*t,hz:e.hz}}var wu,ol,sl=ue(()=>{wu=1e-9,ol=Math.PI/180;o(ka,"resolveSlabFace");o(_u,"regionFromObb");o(xu,"aabbHalfExtentsFromObb")});var or={};ge(or,{RENDER_INTENT_KEYS:()=>Co,RENDER_INTENT_VALUES:()=>ll,SECTION_KEYS:()=>Db,assertRenderIntentConformance:()=>Ib,normalizeDataBubble:()=>Ou,normalizeDetection:()=>Lb,normalizeRenderIntent:()=>Pb});function Ou(e){return e==null?{detection:null,string_map:null}:{detection:e.detection!==null&&e.detection!==void 0?e.detection:null,string_map:e.string_map!==null&&e.string_map!==void 0&&typeof e.string_map=="object"?e.string_map:null,ext:e.ext!==void 0?e.ext:void 0}}function Lb(e){return e?{detector_name:e.detector_name!==null&&e.detector_name!==void 0?String(e.detector_name):null}:{detector_name:null}}function Pb(e){var t={};if(!e||typeof e!="object")return t;for(var r=0;r<Co.length;r++){var i=Co[r];e[i]!==void 0&&e[i]!==null&&(t[i]=String(e[i]))}return t}function Ib(e){if(e)for(var t=0;t<Co.length;t++){var r=Co[t],i=ll[r];if(i&&e[r]!==void 0&&i.indexOf(e[r])===-1)throw new Error('render-intent conformance: key "'+r+'" has invalid value "'+e[r]+'"; allowed: '+i.join("|"))}}var Db,Co,ll,Fi=ue(()=>{Db=["detection","string_map"];o(Ou,"normalizeDataBubble");o(Lb,"normalizeDetection");Co=["render.color","render.outline","render.shape","render.colorScheme","render.mesh","render.meshScale","render.meshRotation"],ll={"render.shape":["ball","box","circle","cube","sphere"],"render.colorScheme":["roygbiv","warmcool"],"render.outline":["true","false"]};o(Pb,"normalizeRenderIntent");o(Ib,"assertRenderIntentConformance")});var Ro={};ge(Ro,{MARK_KEY:()=>cl,normalizeTags:()=>Eu,readTag:()=>Su,readTags:()=>ud,stamp:()=>Fb,tagOps:()=>jo});function Eu(e){if(typeof e=="string"){var t={};return t[cl]=e,t}if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("[Tagger] tags must be a plain object {key: value} or a bare string (shorthand for {"+cl+": value}); got "+(Array.isArray(e)?"an array":typeof e)+".");for(var r={},i=Object.keys(e),n=0;n<i.length;n++){var a=i[n];if(typeof a!="string"||a.length===0)throw new TypeError("[Tagger] tag key must be a non-empty string; got "+JSON.stringify(a)+".");var s=e[a];s!=null&&(r[a]=String(s))}return r}function jo(e){for(var t=Zt,r=Eu(e),i=[],n=Object.keys(r),a=0;a<n.length;a++)i.push({set:t.HANDLE_FRAME+".data."+n[a],to:t.StrLit(r[n[a]])});return i}function Fb(e,t,r){if(!e||typeof e.setFrameProperty!="function")throw new TypeError("[Tagger.stamp] needs a universe with setFrameProperty (the host write lane). Got "+(e&&typeof e)+".");var i=Eu(r),n=Object.keys(i);if(n.length===0)return 0;var a=null;typeof e.getFrameProperty=="function"&&(a=e.getFrameProperty(t,"data")),(!a||typeof a!="object")&&(a={});for(var s=a.string_map&&typeof a.string_map=="object"?a.string_map:{},l=0;l<n.length;l++)s[n[l]]=i[n[l]];return a.string_map=s,e.setFrameProperty(t,"data",a),n.length}function ud(e){if(!e)return{};var t=Ou(e.data),r=t.string_map;if(!r||typeof r!="object")return{};for(var i={},n=Object.keys(r),a=0;a<n.length;a++)r[n[a]]!==null&&r[n[a]]!==void 0&&(i[n[a]]=r[n[a]]);return i}function Su(e,t){var r=t??cl,i=ud(e);return i[r]!==void 0?i[r]:null}var cl,ul=ue(()=>{In();Fi();cl="detector_name";o(Eu,"normalizeTags");o(jo,"tagOps");o(Fb,"stamp");o(ud,"readTags");o(Su,"readTag")});var Nn={};ge(Nn,{applyProgramTrigger:()=>vi,buildAngledReflectOps:()=>pd,buildConstrainedRandomOps:()=>vd,buildDecoherenceOps:()=>yd,buildEjectOps:()=>Ni,buildFaceExitEjectOps:()=>Au,buildIncidenceReflectOps:()=>fd,buildIncidenceReflectOps3D:()=>hd,buildOmniRandomOps:()=>gd,buildReflectOps:()=>hl,buildSwapReflectOps:()=>dd,buildTiltedReflectGuardTrigger:()=>md,buildTriggerExpr:()=>an,buildVelocityFlipOp:()=>ku,compileActions:()=>Ta,compileWallV2:()=>Tu});function an(e,t,r,i,n,a,s,l,c){var f=c("intersects",[n(r),n(i)]);if(!t)return f;var u;if(e==="left")u=s(">",a(r,"left"),a(i,"right"));else if(e==="right")u=s("<",a(r,"right"),a(i,"left"));else if(e==="top")u=s(">",a(r,"top"),a(i,"bottom"));else if(e==="bottom")u=s("<",a(r,"bottom"),a(i,"top"));else return f;return l(f,n(1),u)}function vi(e,t){return e.trigger=t,e}function Ni(e,t,r,i,n,a,s,l,c){if(e==="left")return[{set:t+".left",to:a("-",a("-",n(r,"left"),n(t,"w")),i(1))}];if(e==="right")return[{set:t+".left",to:a("+",n(r,"right"),i(1))}];if(e==="top")return[{set:t+".top",to:a("-",a("-",n(r,"top"),n(t,"h")),i(1))}];if(e==="bottom")return[{set:t+".top",to:a("+",n(r,"bottom"),i(1))}];if(e==="near")return[{set:t+".z",to:a("-",a("-",n(r,"near"),a("*",n(t,"w"),i(.5))),i(1))}];if(e==="far")return[{set:t+".z",to:a("+",a("+",n(r,"far"),a("*",n(t,"w"),i(.5))),i(1))}];if(e==="closest"){let xe=function(Ve){return c("max",[Ve,a("-",i(0),Ve)])};o(xe,"Abs");var f=xe(a("-",n(r,"left"),n(t,"left"))),u=xe(a("-",n(r,"right"),n(t,"left"))),h=xe(a("-",n(r,"top"),n(t,"top"))),g=xe(a("-",n(r,"bottom"),n(t,"top"))),d=xe(a("-",n(r,"left"),n(t,"left"))),m=xe(a("-",n(r,"right"),n(t,"left"))),b=xe(a("-",n(r,"top"),n(t,"top"))),y=xe(a("-",n(r,"bottom"),n(t,"top"))),w=xe(a("-",n(r,"left"),n(t,"left"))),x=xe(a("-",n(r,"right"),n(t,"left"))),S=xe(a("-",n(r,"top"),n(t,"top"))),A=xe(a("-",n(r,"bottom"),n(t,"top"))),T=a("-",a("-",n(r,"left"),n(t,"w")),i(1)),j=a("+",n(r,"right"),i(1)),Q=a("-",a("-",n(r,"top"),n(t,"h")),i(1)),Y=a("+",n(r,"bottom"),i(1)),H=c("min",[f,u]),V=c("min",[h,g]),C=s("<",H,V),J=l(s("<",m,d),j,T),R={set:t+".left",to:l(C,J,n(t,"left"))},K=l(s("<",A,S),Y,Q),N=c("min",[w,x]),B=c("min",[S,A]),ie=s("<",N,B),oe={set:t+".top",to:l(ie,n(t,"top"),K)};return[R,oe]}else if(e==="closest3d"){let xe=function(ot){return c("max",[ot,a("-",i(0),ot)])},Ve=function(){return xe(a("-",n(r,"left"),n(t,"left")))},Ot=function(){return xe(a("-",n(r,"right"),n(t,"left")))},Wt=function(){return xe(a("-",n(r,"top"),n(t,"top")))},zt=function(){return xe(a("-",n(r,"bottom"),n(t,"top")))},se=function(){return xe(a("-",n(r,"near"),n(t,"near")))},ve=function(){return xe(a("-",n(r,"far"),n(t,"near")))},Lt=function(){return c("min",[Ve(),Ot()])},ct=function(){return c("min",[Wt(),zt()])},Kt=function(){return c("min",[se(),ve()])},Et=function(){return l(s("<",ct(),Lt()),i(0),l(s("<",Kt(),Lt()),i(0),i(1)))},ut=function(){return l(s("<",Kt(),ct()),i(0),i(1))};o(xe,"Abs3"),o(Ve,"dL"),o(Ot,"dR"),o(Wt,"dT"),o(zt,"dB"),o(se,"dN"),o(ve,"dF"),o(Lt,"minH"),o(ct,"minV"),o(Kt,"minZ"),o(Et,"isH"),o(ut,"vGivenNotH");var $=a("-",a("-",n(r,"left"),n(t,"w")),i(1)),pe=a("+",n(r,"right"),i(1)),ye=a("-",a("-",n(r,"top"),n(t,"h")),i(1)),ce=a("+",n(r,"bottom"),i(1)),L=a("-",a("-",n(r,"near"),a("*",n(t,"w"),i(.5))),i(1)),ee=a("+",a("+",n(r,"far"),a("*",n(t,"w"),i(.5))),i(1)),X=l(s("<",Ot(),Ve()),pe,$),te=l(s("<",zt(),Wt()),ce,ye),be=l(s("<",ve(),se()),ee,L),Oe={set:t+".left",to:l(Et(),X,n(t,"left"))},Ue={set:t+".top",to:l(l(Et(),i(0),ut()),te,n(t,"top"))},Ce={set:t+".z",to:l(l(Et(),i(0),l(ut(),i(0),i(1))),be,n(t,"z"))};return[Oe,Ue,Ce]}return null}function ku(e,t,r,i,n){var a=e?e.split("_")[0]:"";return a==="LEFT"||a==="RIGHT"?{set:t+".vx",to:n("-",r(0),i(t,"vx"))}:a==="TOP"||a==="BOTTOM"?{set:t+".vy",to:n("-",r(0),i(t,"vy"))}:a==="NEAR"||a==="FAR"?{set:t+".vz",to:n("-",r(0),i(t,"vz"))}:null}function fd(e,t,r,i,n,a,s,l){function c(H){return s(H,r(0),r(1))}o(c,"NOT");function f(H,V){return s(H,r(1),V)}o(f,"OR");function u(H,V){return s(H,V,r(0))}o(u,"AND");function h(H,V){return s(a(">",H,V),r(0),r(1))}o(h,"LE");function g(H,V){return s(a("<",H,V),r(0),r(1))}o(g,"GE");function d(){return n("*",i(e,"w"),r(.5))}o(d,"halfW");function m(){return n("*",i(e,"h"),r(.5))}o(m,"halfH");function b(){return n("+",i(e,"prev_x"),d())}o(b,"prevRight");function y(){return n("-",i(e,"prev_x"),d())}o(y,"prevLeft");function w(){return n("+",i(e,"prev_y"),m())}o(w,"prevBottom");function x(){return n("-",i(e,"prev_y"),m())}o(x,"prevTop");function S(){return f(h(b(),i(t,"left")),g(y(),i(t,"right")))}o(S,"wasOutsideX");function A(){return f(h(w(),i(t,"top")),g(x(),i(t,"bottom")))}o(A,"wasOutsideY");function T(){return n("-",l("min",[i(e,"right"),i(t,"right")]),l("max",[i(e,"left"),i(t,"left")]))}o(T,"penX");function j(){return n("-",l("min",[i(e,"bottom"),i(t,"bottom")]),l("max",[i(e,"top"),i(t,"top")]))}o(j,"penY");var Q=u(S(),f(c(A()),g(T(),j()))),Y=u(A(),f(c(S()),g(j(),T())));return[{set:e+".vx",to:s(Q,n("-",r(0),i(e,"vx")),i(e,"vx"))},{set:e+".vy",to:s(Y,n("-",r(0),i(e,"vy")),i(e,"vy"))}]}function hd(e,t,r,i,n,a,s,l){function c(N){return s(N,r(0),r(1))}o(c,"NOT");function f(N,B){return s(N,r(1),B)}o(f,"OR");function u(N,B){return s(N,B,r(0))}o(u,"AND");function h(N,B){return s(a(">",N,B),r(0),r(1))}o(h,"LE");function g(N,B){return s(a("<",N,B),r(0),r(1))}o(g,"GE");function d(){return n("*",i(e,"w"),r(.5))}o(d,"halfW");function m(){return n("*",i(e,"h"),r(.5))}o(m,"halfH");function b(){return n("*",i(e,"w"),r(.5))}o(b,"halfD");function y(){return n("+",i(e,"prev_x"),d())}o(y,"prevRight");function w(){return n("-",i(e,"prev_x"),d())}o(w,"prevLeft");function x(){return n("+",i(e,"prev_y"),m())}o(x,"prevBottom");function S(){return n("-",i(e,"prev_y"),m())}o(S,"prevTop");function A(){return n("+",i(e,"prev_z"),b())}o(A,"prevFar");function T(){return n("-",i(e,"prev_z"),b())}o(T,"prevNear");function j(){return f(h(y(),i(t,"left")),g(w(),i(t,"right")))}o(j,"wasOutsideX");function Q(){return f(h(x(),i(t,"top")),g(S(),i(t,"bottom")))}o(Q,"wasOutsideY");function Y(){return f(h(A(),i(t,"near")),g(T(),i(t,"far")))}o(Y,"wasOutsideZ");function H(){return n("-",l("min",[i(e,"right"),i(t,"right")]),l("max",[i(e,"left"),i(t,"left")]))}o(H,"penX");function V(){return n("-",l("min",[i(e,"bottom"),i(t,"bottom")]),l("max",[i(e,"top"),i(t,"top")]))}o(V,"penY");function C(){return n("-",l("min",[i(e,"far"),i(t,"far")]),l("max",[i(e,"near"),i(t,"near")]))}o(C,"penZ");var J=u(j(),u(f(c(Q()),g(H(),V())),f(c(Y()),g(H(),C())))),R=u(Q(),u(f(c(j()),g(V(),H())),f(c(Y()),g(V(),C())))),K=u(Y(),u(f(c(j()),g(C(),H())),f(c(Q()),g(C(),V()))));return[{set:e+".vx",to:s(J,n("-",r(0),i(e,"vx")),i(e,"vx"))},{set:e+".vy",to:s(R,n("-",r(0),i(e,"vy")),i(e,"vy"))},{set:e+".vz",to:s(K,n("-",r(0),i(e,"vz")),i(e,"vz"))}]}function pd(e,t,r,i,n){var a=t*Math.PI/180,s=Math.cos(2*a),l=Math.sin(2*a);return[{set:e+".vx",to:n("+",n("*",r(s),i(e,"vx")),n("*",r(l),i(e,"vy")))},{set:e+".vy",to:n("-",n("*",r(l/s),i(e,"vx")),n("*",r(1/s),i(e,"vy")))}]}function dd(e,t,r,i,n){var a=Math.round(Math.sin(2*t*Math.PI/180)),s=[{set:e+".vx",to:n("+",i(e,"vx"),i(e,"vy"))},{set:e+".vy",to:n("-",i(e,"vx"),i(e,"vy"))},{set:e+".vx",to:n("-",i(e,"vx"),i(e,"vy"))}];return a<0&&(s.push({set:e+".vx",to:n("-",r(0),i(e,"vx"))}),s.push({set:e+".vy",to:n("-",r(0),i(e,"vy"))})),s}function hl(e,t,r,i,n,a,s,l,c,f){var u=typeof e=="number"&&isFinite(e)?e:0,h=(u%360+360)%360,g=1e-9,d=h%90,m=ka({orientationDeg:h});if(m.isCardinal)return f?hd(t,r,i,n,a,s,l,c):fd(t,r,i,n,a,s,l,c);var b=m.reflectBaseDeg;return Math.abs(d-45)<g?dd(t,b,i,n,a):pd(t,b,i,n,a)}function md(e,t,r,i,n,a,s,l,c,f,u){function h(j,Q){return c(j,Q,n(0))}o(h,"AND");function g(j,Q){return c(j,n(1),Q)}o(g,"OR");function d(j,Q){return s("+",s("*",n(e.x),s("-",a(r,j),a(i,"cx"))),s("*",n(e.y),s("-",a(r,Q),a(i,"cy"))))}o(d,"S");var m=s("+",s("*",n(e.x),a(r,"vx")),s("*",n(e.y),a(r,"vy"))),b=u?c(l("<",m,n(0)),n(0),n(1)):l(">",m,n(0)),y=u?c(l(">",m,n(0)),n(0),n(1)):l("<",m,n(0)),w=h(l("<",d("prev_x","prev_y"),n(-t)),h(l(">",d("x","y"),n(-t)),b)),x=h(l(">",d("prev_x","prev_y"),n(t)),h(l("<",d("x","y"),n(t)),y)),S=g(w,x);if(u){let j=function(Y,H){return c(l("<",Y,H),n(0),n(1))},Q=function(Y,H){return c(l(">",Y,H),n(0),n(1))};o(j,"GE"),o(Q,"LE");var A=h(l("<",a(r,"prev_z"),a(i,"near")),h(j(a(r,"z"),a(i,"near")),l(">",a(r,"vz"),n(0)))),T=h(l(">",a(r,"prev_z"),a(i,"far")),h(Q(a(r,"z"),a(i,"far")),l("<",a(r,"vz"),n(0))));S=g(S,g(A,T))}return c(f("intersects",[n(r),n(i)]),S,n(0))}function Au(e,t,r,i,n,a,s,l,c,f){function u(y,w){return s("+",s("*",n(e.x),s("-",a(r,y),a(i,"cx"))),s("*",n(e.y),s("-",a(r,w),a(i,"cy"))))}o(u,"S");var h=s("+",s("*",n(e.x),a(r,"vx")),s("*",n(e.y),a(r,"vy"))),g=s("+",n(t+1),s("*",a(r,"w"),n(.5))),d=f?c(l("<",u("prev_x","prev_y"),n(0)),n(-1),n(1)):c(l("<",h,n(0)),n(1),n(-1)),m=s("*",d,g);function b(){return s("-",m,u("prev_x","prev_y"))}return o(b,"delta"),[{set:r+".x",to:s("+",a(r,"prev_x"),s("*",b(),n(e.x)))},{set:r+".y",to:s("+",a(r,"prev_y"),s("*",b(),n(e.y)))}]}function Nb(e,t,r,i,n,a,s,l,c){function f(){return s("+",s("*",n(e.x),s("-",a(r,"prev_x"),a(i,"cx"))),s("*",n(e.y),s("-",a(r,"prev_y"),a(i,"cy"))))}o(f,"S_prev");function u(){return c(l("<",f(),n(-t)),n(1),l(">",f(),n(t)))}o(u,"xprev");function h(){return c(l("<",a(r,"prev_z"),a(i,"near")),n(1),l(">",a(r,"prev_z"),a(i,"far")))}o(h,"zOutPrev");function g(){return c(u(),n(0),h())}return o(g,"zclass"),{xprev:u,zclass:g}}function Mb(e,t,r,i,n,a,s){function l(){return n("*",n("+",i(t,"near"),i(t,"far")),r(.5))}o(l,"cz");function c(){return n("*",n("-",i(t,"far"),i(t,"near")),r(.5))}o(c,"hz");var f=n("+",n("+",c(),n("*",i(e,"w"),r(.5))),r(1)),u=s(a("<",i(e,"prev_z"),l()),r(-1),r(1));return{set:e+".z",to:n("+",l(),n("*",u,f))}}function fl(e,t,r,i,n){return e.map(function(a){var s=a.set.slice((r+".").length);return{set:a.set,to:n(t(),a.to,i(r,s))}})}function Ub(e,t,r,i,n){for(var a=[{k:"vx",c:e.x},{k:"vy",c:e.y},{k:"vz",c:e.z}],s=1e-9,l=[],c=0;c<3;c++)Math.abs(a[c].c*a[c].c-.5)<s&&l.push(c);function f(){return n("+",n("+",n("*",r(e.x),i(t,"vx")),n("*",r(e.y),i(t,"vy"))),n("*",r(e.z),i(t,"vz")))}if(o(f,"nDotV"),l.length===2){var u=a[l[0]].k,h=a[l[1]].k,g=Math.sign(a[l[0]].c)*Math.sign(a[l[1]].c),d=[{set:t+"."+u,to:n("+",i(t,u),i(t,h))},{set:t+"."+h,to:n("-",i(t,u),i(t,h))},{set:t+"."+u,to:n("-",i(t,u),i(t,h))}];return g>0&&(d.push({set:t+"."+u,to:n("-",r(0),i(t,u))}),d.push({set:t+"."+h,to:n("-",r(0),i(t,h))})),d}var m=[0,1,2].sort(function(Y,H){return Math.abs(a[Y].c)-Math.abs(a[H].c)}),b=m[0],y=[m[1],m[2]].sort(function(Y,H){return Math.abs(a[H].c*a[H].c-.5)-Math.abs(a[Y].c*a[Y].c-.5)}),w=y[0],x=y[1],S=a[b].c,A=a[x].c,T=a[w].c,j=1/(1-2*S*S),Q=1/(1-2*S*S-2*A*A);return[{set:t+"."+a[b].k,to:n("-",i(t,a[b].k),n("*",r(2*S),f()))},{set:t+"."+a[x].k,to:n("-",i(t,a[x].k),n("*",r(2*A*j),f()))},{set:t+"."+a[w].k,to:n("-",i(t,a[w].k),n("*",r(2*T*Q),f()))}]}function zb(e,t,r,i,n,a,s,l,c){var f=e.n,u=e.u,h=e.v,g=e.hw,d=e.hh,m=e.hz;function b(V,C){return l(V,C,i(0))}o(b,"AND");function y(V,C){return l(V,i(1),C)}o(y,"OR");function w(V,C){return l(s("<",V,C),i(0),i(1))}o(w,"GE");function x(V,C){return l(s(">",V,C),i(0),i(1))}o(x,"LE");function S(V){return c("max",[V,a("-",i(0),V)])}o(S,"Abs");function A(){return a("*",a("+",n(r,"near"),n(r,"far")),i(.5))}o(A,"CZ");function T(V,C,J,R){return a("+",a("+",a("*",i(V.x),a("-",n(t,C),n(r,"cx"))),a("*",i(V.y),a("-",n(t,J),n(r,"cy")))),a("*",i(V.z),a("-",n(t,R),A())))}o(T,"DOT");var j=a("+",a("+",a("*",i(f.x),n(t,"vx")),a("*",i(f.y),n(t,"vy"))),a("*",i(f.z),n(t,"vz"))),Q=b(s("<",T(f,"prev_x","prev_y","prev_z"),i(-g)),b(w(T(f,"x","y","z"),i(-g)),w(j,i(0)))),Y=b(s(">",T(f,"prev_x","prev_y","prev_z"),i(g)),b(x(T(f,"x","y","z"),i(g)),x(j,i(0)))),H=b(s("<",S(T(u,"x","y","z")),i(d)),s("<",S(T(h,"x","y","z")),i(m)));return l(c("intersects",[i(t),i(r)]),b(H,y(Q,Y)),i(0))}function qb(e,t,r,i,n,a,s,l){var c=e.n,f=e.hw;function u(){return a("*",a("+",n(r,"near"),n(r,"far")),i(.5))}o(u,"CZ");function h(){return a("+",a("+",a("*",i(c.x),a("-",n(t,"prev_x"),n(r,"cx"))),a("*",i(c.y),a("-",n(t,"prev_y"),n(r,"cy")))),a("*",i(c.z),a("-",n(t,"prev_z"),u())))}o(h,"SPrev");var g=a("+",i(f+1),a("*",n(t,"w"),i(.5)));function d(){return a("*",l(s("<",h(),i(0)),i(-1),i(1)),g)}o(d,"T");function m(){return a("-",d(),h())}return o(m,"delta"),[{set:t+".x",to:a("+",n(t,"prev_x"),a("*",m(),i(c.x)))},{set:t+".y",to:a("+",n(t,"prev_y"),a("*",m(),i(c.y)))},{set:t+".z",to:a("+",n(t,"prev_z"),a("*",m(),i(c.z)))}]}function gd(e,t,r,i){return[{set:e+".vx",to:r("-",r("*",i("random",[]),t(2)),t(1))},{set:e+".vy",to:r("-",r("*",i("random",[]),t(2)),t(1))}]}function vd(e,t,r,i,n,a,s,l,c){return[{set:e+".vx",to:c("random",[])},{set:e+".vy",to:l("+",a(r),l("*",l("-",a(n),a(r)),s(e,"vx")))},{set:e+".vx",to:l("+",a(t),l("*",l("-",a(i),a(t)),s(e,"vx")))}]}function yd(e,t,r,i,n){return[{set:e+".local_time",to:t(0)},{set:e+".charge",to:i(r("<",n("random",[]),t(.5)),t(0),t(1))}]}function Fn(e,t){throw new Error("[actionCompiler] cannot compile CollisionAction "+JSON.stringify(e)+": "+t+". Nothing is left uncompiled \u2014 the engine has no action dispatch, so an op-program is the only way a behaviour can run.")}function Ta(e,t,r,i){for(var n=Zt,a=n.Lit,s=n.Ref,l=n.Bin,c=n.Cmp,f=n.Cond,u=n.Fn,h=n.HANDLE_FRAME,g=n.HANDLE_SELF,d=[],m=!1,b=e||[],y=0;y<b.length;y++){var w=b[y];if(w==="ABSORB")d.push({set:h+".is_alive",to:a(0)});else if(w==="COUNT")d.push({set:g+".count",to:l("+",s(g,"count"),a(1))});else if(w==="MARK"||w==="DETECT"){var x=t||"";d=d.concat(jo(x))}else if(w==="BLOCK"){r||Fn(w,"it needs an eject face: pass a reposition of left|right|top|bottom|near|far|closest, or build the wall with V2 compileWallV2({behavior:'block', reposition})");var S=Ni(r,h,g,a,s,l,c,f,u);S||Fn(w,'reposition "'+r+'" is not an eject face (left|right|top|bottom|near|far|closest|closest3d)');for(var A=0;A<S.length;A++)d.push(S[A])}else if(w==="BOUNCE"){r||Fn(w,"it needs an eject face: pass a reposition of left|right|top|bottom|near|far|closest, or build the wall with V2 compileWallV2({behavior:'bounce', bounceDirection:'reflect', reposition})");var T=Ni(r,h,g,a,s,l,c,f,u),j=ku(t||"",h,a,s,l);if(!T&&!j&&Fn(w,'neither reposition "'+r+'" nor the LO name "'+(t||"")+'" names a face to bounce off'),T)for(var Q=0;Q<T.length;Q++)d.push(T[Q]);j&&d.push(j)}else w==="LOG"?Fn(w,"there is no logging op and no native dispatch to fall back to; read the collided frames from TickData.objects[handle].frames instead (compileWallV2({behavior:'nothing', hooks:['count']}) collects them)"):w==="RECOLOR"?Fn(w,"the engine owns no colour; stamp render.color as a tag instead \u2014 compileWallV2({..., hooks:['recolor'], color:[r,g,b]})"):w==="KILL"?d.push({set:h+".is_alive",to:a(0)}):Fn(w,"it is not a CollisionAction this compiler knows (ABSORB|COUNT|MARK|DETECT|BLOCK|BOUNCE|KILL) \u2014 check the spelling, or use the V2 wall vocabulary via compileWallV2({behavior, bounceDirection, hooks})")}var Y=i||"NONE";if(Y==="RANDOM_X")d.push({set:h+".vx",to:l("-",l("*",u("random",[]),a(2)),a(1))}),d.push({set:h+".vy",to:a(1)});else if(Y==="RANDOM_Y")d.push({set:h+".vy",to:l("-",l("*",u("random",[]),a(2)),a(1))}),d.push({set:h+".vx",to:a(1)}),d.push({set:h+".local_time",to:a(0)}),d.push({set:h+".charge",to:f(c("<",u("random",[]),a(.5)),a(0),a(1))});else if(Y==="RANDOM_XY")d.push({set:h+".vx",to:u("random",[])}),d.push({set:h+".vy",to:l("-",l("*",u("random",[]),a(2)),a(1))}),d.push({set:h+".local_time",to:a(0)}),d.push({set:h+".charge",to:f(c("<",u("random",[]),a(.5)),a(0),a(1))});else if(Y==="MOMENTUM_BASED")d.push({set:h+".x",to:s(h,"prev_x")}),d.push({set:h+".y",to:s(h,"prev_y")});else if(Y==="WALL"){if(r){var H=Ni(r,h,g,a,s,l,c,f,u);if(H){for(var V=0;V<H.length;V++)d.push(H[V]);m=!0}}}else if(Y==="BOUNCE"){var C=b.indexOf("BOUNCE")>=0;if(!C&&r){var J=Ni(r,h,g,a,s,l,c,f,u),R=ku(t||"",h,a,s,l);if(J)for(var K=0;K<J.length;K++)d.push(J[K]);R&&d.push(R)}}var N=d.length>0?{on:"collision",ops:d}:null;if(N!==null){var B=an(r||null,m,h,g,a,s,c,f,u);vi(N,B)}return{program:N}}function Vb(e){if(!Array.isArray(e)||e.length<3)return null;function t(s){return s=Math.round(Number(s)),isNaN(s)?null:Math.max(0,Math.min(255,s))}o(t,"_b");var r=t(e[0]),i=t(e[1]),n=t(e[2]);if(r===null||i===null||n===null)return null;var a=e.length>=4?t(e[3]):255;return a===null&&(a=255),r+","+i+","+n+","+a}function Tu(e){var t=Zt,r=t.Lit,i=t.Ref,n=t.Bin,a=t.Cmp,s=t.Cond,l=t.Fn,c=t.HANDLE_FRAME,f=t.HANDLE_SELF;e=e||{};var u=e.behavior||"nothing",h=e.reposition||"closest",g=e.is3D===!0;g&&h==="closest"&&(h="closest3d");var d=Array.isArray(e.hooks)?e.hooks:[],m=!1,b=null,y=[],w=u==="bounce"&&e.bounceDirection!=="random"?ka({orientationDeg:e.orientationDeg,w:e.slabW,h:e.slabH,pitchDeg:e.pitchDeg,d:e.slabD}):null,x=!!(w&&w.pitched);if(x&&!g)throw new Error("[actionCompiler] pitchDeg requires a 3D wall (a real z/depth) \u2014 a 2D wall has no z axis to pitch into.");var S=!!(w&&!w.isCardinal&&!x);if(u==="bounce")if(x)y=y.concat(qb(w.plate3,c,f,r,i,n,a,s)),y=y.concat(Ub(w.plate3.n,c,r,i,n));else if(S){var A=w.obb&&isFinite(w.obb.hw)?w.obb.hw:0;if(g){var T=Nb(w.obb.normal,A,c,f,r,i,n,a,s),j=Au(w.obb.normal,A,c,f,r,i,n,a,s,!0);y=y.concat(fl(j,T.xprev,c,i,s)),y=y.concat(fl([Mb(c,f,r,i,n,a,s)],T.zclass,c,i,s)),y=y.concat(fl(hl(e.orientationDeg,c,f,r,i,n,a,s,l,g),T.xprev,c,i,s)),y=y.concat(fl([{set:c+".vz",to:n("-",r(0),i(c,"vz"))}],T.zclass,c,i,s))}else y=y.concat(Au(w.obb.normal,A,c,f,r,i,n,a,s)),y=y.concat(hl(e.orientationDeg,c,f,r,i,n,a,s,l,g))}else{for(var Q=Ni(h,c,f,r,i,n,a,s,l)||[],Y=0;Y<Q.length;Y++)y.push(Q[Y]);if(e.bounceDirection==="random"){var H=e.angleConstraint;if(Array.isArray(H)&&H.length===2&&isFinite(H[0])&&isFinite(H[1])&&Math.abs(H[1]-H[0])<360){var V=typeof e.orientationDeg=="number"?e.orientationDeg:0,C=(V+H[0])*Math.PI/180,J=(V+H[1])*Math.PI/180;y=y.concat(vd(c,Math.cos(C),Math.sin(C),Math.cos(J),Math.sin(J),r,i,n,l))}else y=y.concat(gd(c,r,n,l));e.decoherence===!0&&(y=y.concat(yd(c,r,a,s,l)))}else y=y.concat(hl(e.orientationDeg,c,f,r,i,n,a,s,l,g))}else if(u==="block")for(var R=Ni(h,c,f,r,i,n,a,s,l)||[],K=0;K<R.length;K++)y.push(R[K]);else if(u==="absorb"){var N=typeof e.capacity=="number"&&e.capacity>0?e.capacity:64;y.push({set:c+".is_alive",to:r(0)}),m=!0,b={capacity:N},e.emissivity!==void 0&&e.emissivity!==null&&(b.emissivity=e.emissivity)}else u==="destroy"&&y.push({set:c+".is_alive",to:r(0)});if(d.indexOf("mark")!==-1&&(y=y.concat(jo(e.markTag||""))),d.indexOf("count")!==-1&&(y.push({set:f+".count",to:n("+",i(f,"count"),r(1))}),m=!0),d.indexOf("recolor")!==-1){var B=Vb(e.color);B&&(y=y.concat(jo({"render.color":B})))}var ie=y.length>0?{on:"collision",ops:y}:null;if(ie!==null)if(x)vi(ie,zb(w.plate3,c,f,r,i,n,a,s,l));else if(S){var oe=w.obb&&isFinite(w.obb.hw)?w.obb.hw:0;vi(ie,md(w.obb.normal,oe,c,f,r,i,n,a,s,l,g))}else vi(ie,an(h,!1,c,f,r,i,a,s,l));return{program:ie,collectCollided:m,radiation:b}}var Mn=ue(()=>{In();sl();ul();o(an,"_buildTriggerExpr");o(vi,"_applyProgramTrigger");o(Ni,"_buildEjectOps");o(ku,"_buildVelocityFlipOp");o(fd,"_buildIncidenceReflectOps");o(hd,"_buildIncidenceReflectOps3D");o(pd,"_buildAngledReflectOps");o(dd,"_buildSwapReflectOps");o(hl,"_buildReflectOps");o(md,"_buildTiltedReflectGuardTrigger");o(Au,"_buildFaceExitEjectOps");o(Nb,"_tilted3DGates");o(Mb,"_buildZFaceExitEjectOp");o(fl,"_gateOps");o(Ub,"_buildPitchedReflectOps");o(zb,"_buildPitchedGuardTrigger");o(qb,"_buildPitchedExitEjectOps");o(gd,"_buildOmniRandomOps");o(vd,"_buildConstrainedRandomOps");o(yd,"_buildDecoherenceOps");o(Fn,"_uncompilable");o(Ta,"compileActions");o(Vb,"_rgbaCsv");o(Tu,"compileWallV2")});var Cu={};ge(Cu,{Rectangle:()=>lt});function lt(e,t,r,i,n,a){a===void 0&&(a=!0),this.is_centered=a,this.data=n||null,this.w=r,this.h=i,a?(this._x=e,this._y=t,this._left=e-r/2,this._right=e+r/2,this._top=t-i/2,this._bottom=t+i/2):(this._x=e+r/2,this._y=t+i/2,this._left=e,this._right=e+r,this._top=t,this._bottom=t+i),this.r=r/2}var Do=ue(()=>{o(lt,"Rectangle");Object.defineProperty(lt.prototype,"x",{get:o(function(){return this._x},"get"),set:o(function(e){this._x=e,this._left=e-this.w/2,this._right=e+this.w/2},"set")});Object.defineProperty(lt.prototype,"y",{get:o(function(){return this._y},"get"),set:o(function(e){this._y=e,this._top=e-this.h/2,this._bottom=e+this.h/2},"set")});Object.defineProperty(lt.prototype,"left",{get:o(function(){return this._left},"get"),set:o(function(e){this._left=e,this._x=e+this.w/2,this._right=e+this.w},"set")});Object.defineProperty(lt.prototype,"right",{get:o(function(){return this._right},"get"),set:o(function(e){this._right=e,this._x=e-this.w/2,this._left=e-this.w},"set")});Object.defineProperty(lt.prototype,"top",{get:o(function(){return this._top},"get"),set:o(function(e){this._top=e,this._y=e+this.h/2,this._bottom=e+this.h},"set")});Object.defineProperty(lt.prototype,"bottom",{get:o(function(){return this._bottom},"get"),set:o(function(e){this._bottom=e,this._y=e-this.h/2,this._top=e-this.h},"set")});Object.defineProperty(lt.prototype,"area",{get:o(function(){return this.w*this.h},"get")});lt.prototype.contains=function(e){return this.left<=e.left&&this.right>=e.right&&this.top<=e.top&&this.bottom>=e.bottom};lt.prototype.intersects=function(e){return this.left<=e.right&&this.right>=e.left&&this.top<=e.bottom&&this.bottom>=e.top};lt.prototype.overlaps=function(e){if(!this.intersects(e))return null;var t=Math.max(this.left,e.left),r=Math.min(this.right,e.right),i=Math.max(this.top,e.top),n=Math.min(this.bottom,e.bottom);return new lt(t,i,r-t,n-i,null,!1)};lt.prototype.eject=function(e,t,r){if(this.overlaps(e)){var i=e.left,n=e.top;switch(t){case"top":n=this.top-e.h-1;break;case"bottom":n=this.bottom+1;break;case"left":i=this.left-e.w-1;break;case"right":i=this.right+1;break;default:var a=Math.abs(this.left-e.left),s=Math.abs(this.right-e.left),l=Math.abs(this.top-e.top),c=Math.abs(this.bottom-e.top),f=Math.min(a,s,l,c);f===a?i=r?this.left+1:this.left-e.w-1:f===s?i=r?this.right-e.w-1:this.right+1:f===l?n=r?this.top+1:this.top-e.h-1:n=r?this.bottom-e.h-1:this.bottom+1}e.top=n,e.left=i}};lt.prototype.xDistanceFrom=function(e){return this.left<=e.rect.x&&e.rect.x<=this.right?0:Math.min(Math.abs(e.rect.x-this.left),Math.abs(e.rect.x-this.right))};lt.prototype.yDistanceFrom=function(e){return this.top<=e.rect.y&&e.rect.y<=this.bottom?0:Math.min(Math.abs(e.rect.y-this.top),Math.abs(e.rect.y-this.bottom))};lt.prototype.sqDistanceFrom=function(e){var t=this.xDistanceFrom(e),r=this.yDistanceFrom(e);return t*t+r*r};lt.prototype.distanceFrom=function(e){return Math.sqrt(this.sqDistanceFrom(e))};lt.prototype.toString=function(){return"Rectangle(x: "+this._x+", y: "+this._y+", w: "+this.w+", h: "+this.h+", left: "+this._left+", right: "+this._right+", top: "+this._top+", bottom: "+this._bottom+", is_centered: "+this.is_centered+")"}});var sn={};ge(sn,{FIELD_ENVELOPE_KEYS:()=>Bb,FIELD_TYPES:()=>Ui,UX_DRAGGABLE_MODES:()=>Lo,UX_ENVELOPE_KEYS:()=>Wb,UX_HANDLE_ZONES:()=>dl,UX_SHELL_RENDER:()=>Ru,normalizeFieldDescriptor:()=>zi,normalizeUx:()=>Ca});function pl(e){return typeof e=="string"&&e.length>0}function ju(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function on(e,t){throw new Error('[lib/shim/field-descriptor] normalizeFieldDescriptor(name="'+String(e)+'"): '+t+" (FAIL-LOUD \u2014 throw-or-apply, never silently dropped/defaulted-around.)")}function zi(e){if(!e||typeof e!="object")throw new Error("[lib/shim/field-descriptor] normalizeFieldDescriptor requires a field descriptor object; got "+(e===null?"null":typeof e)+". (FAIL-LOUD.)");var t=e.name;pl(t)||on(t,'"name" must be a non-empty string.');var r=e.type;Ui.indexOf(r)===-1&&on(t,'"type" must be one of ['+Ui.join(", ")+']; got "'+String(r)+'".'),pl(e.description)||on(t,'"description" must be a non-empty string.'),e.unit!==void 0&&!pl(e.unit)&&on(t,'"unit", when present, must be a non-empty string.'),e.constraint!==void 0&&!ju(e.constraint)&&on(t,'"constraint", when present, must be a plain object.'),e.engineVisible!==void 0&&typeof e.engineVisible!="boolean"&&on(t,'"engineVisible", when present, must be a boolean.'),e.widgetHint!==void 0&&!pl(e.widgetHint)&&on(t,'"widgetHint", when present, must be a non-empty string.'),e.widgetConfig!==void 0&&!ju(e.widgetConfig)&&on(t,'"widgetConfig", when present, must be a plain object.');var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(i[n]=e[n]);return i.name=t,i.type=r,i}function Mi(e){throw new Error("[lib/shim/field-descriptor] normalizeUx: "+e+" (FAIL-LOUD \u2014 throw-or-apply, never silently dropped/defaulted-around.)")}function Ca(e){var t={resizable:!0,draggable:{"2d":!0},handles:dl.slice(),shellRender:"design"};if(e==null)return t;if((typeof e!="object"||Array.isArray(e))&&Mi("a ux block must be a plain object; got "+(Array.isArray(e)?"array":typeof e)+"."),Object.keys(bd).forEach(function(s){e[s]!==void 0&&Mi('"'+s+'" is DELETED \u2014 '+bd[s]+".")}),e.resizable!==void 0&&(typeof e.resizable!="boolean"&&Mi('"resizable" must be a boolean.'),t.resizable=e.resizable),e.draggable!==void 0){ju(e.draggable)||Mi('"draggable" must be a { "2d" } object.'),Object.keys(e.draggable).forEach(function(s){Lo.indexOf(s)===-1&&Mi('"draggable.'+s+'" is not a draggable mode (['+Lo.join(", ")+"]) \u2014 a 3D scene never cursor-drags.")});for(var r={"2d":!0},i=0;i<Lo.length;i++){var n=Lo[i];e.draggable[n]!==void 0&&(typeof e.draggable[n]!="boolean"&&Mi('"draggable.'+n+'" must be a boolean.'),r[n]=e.draggable[n])}t.draggable=r}if(e.handles!==void 0){Array.isArray(e.handles)||Mi('"handles" must be an array of zone names.');for(var a=0;a<e.handles.length;a++)dl.indexOf(e.handles[a])===-1&&Mi('"handles" entry "'+String(e.handles[a])+'" is not a member of UX_HANDLE_ZONES (['+dl.join(", ")+"]).");t.handles=e.handles.slice()}else e.resizable===!1&&(t.handles=["move"]);return e.shellRender!==void 0&&(Ru.indexOf(e.shellRender)===-1&&Mi('"shellRender" must be one of ['+Ru.join(", ")+']; got "'+String(e.shellRender)+'".'),t.shellRender=e.shellRender),t}var Ui,Bb,dl,Lo,Ru,Wb,bd,Un=ue(()=>{Ui=Object.freeze(["number","boolean","string","enum","enum-set","rgb","rect","rect-array","readonly","forbidden","object","writable"]),Bb=Object.freeze(["name","type","constraint","unit","description","engineVisible","widgetHint","widgetConfig","default"]);o(pl,"_isStr");o(ju,"_isPlainObject");o(on,"_fail");o(zi,"normalizeFieldDescriptor");dl=Object.freeze(["move","scale-tl","scale-tr","scale-bl","scale-br","scale-t","scale-b","scale-l","scale-r"]),Lo=Object.freeze(["2d"]),Ru=Object.freeze(["design","run","never"]),Wb=Object.freeze(["resizable","draggable","handles","shellRender"]),bd=Object.freeze({inspectorSections:"the Inspector shows a DECLARED object through its own descriptor (no per-role section list)"});o(Mi,"_uxFail");o(Ca,"normalizeUx")});function ml(e,t){if(!t||typeof t!="object"||!Array.isArray(t.fields))throw new TypeError('[lib/frqtl/objects/schema] descriptor "'+e+'" must be an object with a fields array (and a description). (FAIL-LOUD.)');for(var r=Ui,i=t.fields,n=0;n<i.length;n++){var a=i[n].type;if(r.indexOf(a)===-1)throw new Error('[lib/frqtl/objects/schema] descriptor "'+e+'" field "'+i[n].name+'" has type "'+a+`" \u2014 not a member of lib/shim/field-descriptor's FIELD_TYPES ([`+r.join(", ")+"]). (FAIL-LOUD \u2014 the field-type vocabulary is shared; add the type at the ONE owner, lib/shim/field-descriptor/index.js, never here.)")}if(t.ux!==void 0)try{Ca(t.ux)}catch(s){throw new Error('[lib/frqtl/objects/schema] descriptor "'+e+'" has an invalid ux block: '+s.message)}return t}var Du=ue(()=>{Un();o(ml,"validateDescriptor")});var wd,_d,xd,Od=ue(()=>{Fi();wd={kind:"Frame",description:"Any simulation frame (leaf or composite). Provides writable access to engine-core properties via getFrameProperty/setFrameProperty. Leaf frames (is_leaf=true) are the fundamental quanta; composite frames are parent nodes in the Frame hierarchy. The Frame Axiom: everything is a Frame \u2014 there is no separate particle class. Position/velocity/mass writes bypass move() by design (user override); the engine's CA rules reconcile topology and wavelength on the next tick. Topology (parent/children) is engine-owned and FORBIDDEN from user writes.",fields:[{name:"x",type:"writable",engineVisible:!0,unit:"px",description:"Frame center X position (physics pixels). Write repositions the frame directly, bypassing move() \u2014 user override. The engine does not clamp; caller is responsible for placing within bounds. Children that escape their parent rect are released next tick by releaseEscapedChildren."},{name:"y",type:"writable",engineVisible:!0,description:"Frame center Y position (physics pixels). Write repositions the frame directly, bypassing move() \u2014 user override."},{name:"z",type:"writable",engineVisible:!0,description:"Frame center Z position (depth, physics pixels). Default 0.0 when active_axes.z is false (2D mode). Set by the 3D emitter; moved by the independent z yo-yo coin when active_axes.z is true. Cube edge = w (spec \xA711 \u2014 no separate d field; cubes only)."},{name:"left",type:"writable",engineVisible:!0,description:"Frame left edge (physics pixels). Write repositions the frame by its left edge (mirrors lo._eject otherRect.left = newLeft). Bit-identical to the native WALL eject \u2014 used in \xA710.3 eject-expression programs. Setting left also updates right; center x is derived."},{name:"top",type:"writable",engineVisible:!0,description:"Frame top edge (physics pixels). Write repositions the frame by its top edge (mirrors lo._eject otherRect.top = newTop). Bit-identical to the native WALL eject \u2014 used in \xA710.3 eject-expression programs. Setting top also updates bottom; center y is derived."},{name:"vx",type:"writable",engineVisible:!0,unit:"px/tick",description:"X velocity / momentum (pixels/tick). Positive = rightward, negative = leftward. The 1px/tick speed limit still applies on the next move() call; excess accumulates back into vx."},{name:"vy",type:"writable",engineVisible:!0,description:"Y velocity / momentum (pixels/tick). Positive = downward (screen coords), negative = upward."},{name:"vz",type:"writable",engineVisible:!0,description:"Z velocity / momentum (pixels/tick). Default 0.0 when active_axes.z is false (2D mode). When active_axes.z is true, the yo-yo z coin adds/subtracts to vz each tick for the transverse axes (spec \xA73 / D5/D10). The Euclidean L2 walk probs include vz: D = sqrt(vx\xB2+vy\xB2+vz\xB2)."},{name:"mass",type:"writable",engineVisible:!0,description:"Pixel occupancy count. Feeds setWavelength() on the next tick (FrameStore.set_wavelength). Higher mass \u2192 shorter wavelength \u2192 higher frequency (E=mc\xB2 analog, invariant 6)."},{name:"charge",type:"writable",engineVisible:!0,description:'Charge polarity: "POSITIVE" or "NEGATIVE" (canonical SCREAMING_SNAKE). Determines wave phase (sine vs cosine random walk) and bonding attraction/repulsion. Wire format: provider translates to engine-native (JS: 0/1; Rust: Charge enum).'},{name:"is_alive",type:"writable",engineVisible:!0,description:"Liveness flag. Setting false kills the frame: it is excluded from physics next tick and GC'd at end-of-tick. Equivalent to killFrame(id) but accessed uniformly. Children of a killed composite are orphaned (not recursively killed) \u2014 topology is reconciled by garbageCollectDeadParents."},{name:"is_stationary",type:"writable",engineVisible:!0,description:"Pins the frame in place: move() is skipped when true. Existing per-frame flag (FrameStore.is_stationary). Used in bespoke experiments to freeze specific frames while others evolve."},{name:"wrap",type:"writable",engineVisible:!0,description:"Toroidal boundary for this individual frame. When true the frame wraps at the canvas edges instead of escaping or bouncing. Overrides the universe-level wrap setting for this frame."},{name:"speed_prob",type:"writable",engineVisible:!0,description:'Per-frame OVERRIDE of the leaf longitudinal "speed probability" \u2014 the probability the frame takes its along-momentum step this tick (frame.rs move_frame leaf gate). Sentinel -1.0 (default; any negative resets to it) = derive from fullness (mass/capacity). When >= 0.0 it overrides the gate so user space can set the move-probability independent of mass \u2014 e.g. red vs blue light sharing a speed while differing in momentum/wavelength. Does NOT change the orthogonal wavelength.'},{name:"local_time",type:"writable",constraint:{integer:!0},engineVisible:!0,description:"Per-frame wave-phase counter (integer ticks; frame.rs local_time). Drives the spin/coin-flip via local_time % wavelength. Incremented each tick; reset to 0 on collision/reset. Op-programs that reproduce the native reset() (e.g. compiled RANDOM_* collision behavior) write 0 here. CANONICAL home for the writable-prop contract \u2014 both engines mirror this descriptor; neither hand-lists it (schema-mirror-drift fix)."},{name:"data",type:"writable",engineVisible:!0,dataBubbleSchema:or,description:"The per-frame data bubble: { detection, render, ext }. Sub-shape is owned by lib/shim/frame-data (SECTION_KEYS + normalizeDataBubble). detection \u2014 written by engine MARK/DETECT primitives (detector_name). render \u2014 written by sugar (emitter stamps data.render.color); renderer reads. ext \u2014 developer-extensible; JS-only (not cross-engine assertable). NEVER enumerate the section keys here \u2014 always resolve from FrameDataSchema."},{name:"fullness",type:"readonly",engineVisible:!0,description:"Derived: mass / capacity (0.0\u20131.0). Used by the renderer for color mapping and by detectors for density measurement. Not directly writable \u2014 set mass to change fullness indirectly."},{name:"capacity",type:"readonly",engineVisible:!0,unit:"px\xB2",description:"Derived: rect.w * rect.h (physics pixels). Fixed at frame creation; determined by the frame's bounding rect size."},{name:"child_count",type:"readonly",engineVisible:!0,description:"Number of direct children in this frame's hierarchy (0 for leaf frames). Per-tick result; changes as promote/merge/release rules run."},{name:"collided_id",type:"readonly",engineVisible:!0,description:"ID of the other frame this frame collided with in the last tick, or -1/null if no collision occurred. Per-tick result from the Phase C collide pass."},{name:"r",type:"readonly",engineVisible:!0,description:"Radius cache: max(rect.w, rect.h) / 2. Used in proximity checks and rendering. Derived from rect size."},{name:"w",type:"readonly",engineVisible:!0,description:"Frame width in physics pixels (fixed at creation, derived from rect.w). Read in op-program scope for eject geometry: set frame.left = self.left - frame.w - 1. For leaf quanta this is 1."},{name:"h",type:"readonly",engineVisible:!0,description:"Frame height in physics pixels (fixed at creation, derived from rect.h). Read in op-program scope for eject geometry: set frame.top = self.top - frame.h - 1. For leaf quanta this is 1."},{name:"layer",type:"readonly",engineVisible:!0,description:"Dimension layer membership (u32). Assigned at frame creation; engine-managed \u2014 changes only when the frame is promoted to a higher dimension. User writes are REJECTED (use the promote/detach structural primitives)."},{name:"prev_x",type:"readonly",engineVisible:!0,description:`Derived (scope-read): frame CENTER X before this tick's move() (physics pixels). Readable in op-program scope as Ref(0,"prev_x") \u2014 the compiled MOMENTUM_BASED behavior restores pre-move position via set 0.x = prev_x. Read-only \u2014 write THROWS (engine-owned per-tick snapshot, saved by Frame::move).`},{name:"prev_y",type:"readonly",engineVisible:!0,description:`Derived (scope-read): frame CENTER Y before this tick's move() (physics pixels). Readable in op-program scope as Ref(0,"prev_y"). Read-only \u2014 write THROWS (engine-owned per-tick snapshot, saved by Frame::move).`},{name:"prev_z",type:"readonly",engineVisible:!0,description:"Derived (scope-read): frame CENTER Z before this tick's move() (physics pixels). Default 0.0 when active_axes.z is false. Saved by Frame::move_frame alongside prev_x/prev_y. Read-only \u2014 write THROWS (engine-owned per-tick snapshot)."},{name:"parent",type:"forbidden",engineVisible:!1,description:"FORBIDDEN \u2014 engine-owned topology. The parent link is managed exclusively by the engine's promote/detach/GC rules. Any write attempt FAIL-LOUDs with a TypeError. To move a frame: write its x/y position and let the engine reconcile topology (releaseEscapedChildren drops children outside their parent rect next tick)."},{name:"children",type:"forbidden",engineVisible:!1,description:"FORBIDDEN \u2014 engine-owned topology. The children list is managed exclusively by the engine's promote/attach/detach rules. Any write attempt FAIL-LOUDs with a TypeError."}]},_d={kind:"Universe",description:"The top-level simulation universe. Most properties are read-only state accessible from op-programs via HANDLE_UNIVERSE (2) in the expression scope; a small number of universe-wide physics constants (currently: wavelengthScale) are writable through the validated setUniverseProperty accessor. THROW-OR-APPLY: any write to an unknown or readonly field FAIL-LOUDs with TypeError \u2014 there is no bind-local property list anywhere in the stack.",fields:[{name:"tick",type:"readonly",engineVisible:!0,description:'Current tick count (u64). Increments once per doTick() call. Available in op-program scope via Ref(HANDLE_UNIVERSE, "tick"). Write THROWS \u2014 tick is engine-owned and monotonically increasing.'},{name:"activeQuanta",type:"readonly",engineVisible:!0,description:'Number of currently alive leaf quanta (usize). Derived by counting is_alive=true frames in the fundamental dimension. Available in op-program scope via Ref(HANDLE_UNIVERSE, "activeQuanta"). Write THROWS \u2014 this is a derived aggregate, not a writable property.'},{name:"wavelengthScale",type:"number",constraint:{min:1,integer:!0},widgetHint:"slider",widgetConfig:{max:32,step:1},engineVisible:!0,description:"Layer 1 \u2014 universe-wide oscillation-wavelength scale: `wavelength = floor((capacity/mass) * wavelengthScale)`, minimum 4 (Core Axioms \xA76B). Every Frame in the universe shares this one multiplier. Layer 2 \u2014 physics behavior: this is Wave Interference's and Double-Slit's primary knob \u2014 raising it stretches every Frame's transverse oscillation period, widening fringe/interference spacing without changing any Frame's mass or capacity."}]},xd={kind:"Dimension",description:'A scale layer in the simulation (a "dimension" in FRQTL terminology). Each dimension is a spatial index (QuadTree) that organises frames at one scale. Properties are readonly \u2014 the engine manages dimensional structure. THROW-OR-APPLY: any write attempt FAIL-LOUDs with TypeError.',fields:[{name:"layer",type:"readonly",engineVisible:!0,description:"Dimension layer index (u32). Assigned at creation (add_dimension / addDimension). 0 = fundamental (leaf-quanta layer). Higher values = higher scales. Engine-owned \u2014 write THROWS (topology is engine-derived)."},{name:"frame_count",type:"readonly",engineVisible:!0,description:"Number of frames currently in this dimension (usize). Changes each tick as frames are added, promoted, or GC'd. Derived from the dimension's frame list length \u2014 not user-writable."}]}});var qi={};ge(qi,{RECT_TUPLE:()=>qn,TYPES:()=>Mu,normalizeValue:()=>Nu,rectTupleText:()=>bt,worldRect:()=>Fu});function Pu(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array(length "+e.length+")":typeof e}function Iu(e){var t;try{t=JSON.stringify(e)}catch{t=String(e)}return t===void 0&&(t=String(e)),t.length>60?t.slice(0,60)+"\u2026":t}function wr(e,t,r,i){throw new TypeError("[lib/frqtl/objects/schema] normalizeValue: "+(e||"<kind>")+"."+(t&&t.name?t.name:"<field>")+' is declared type "'+(t&&t.type)+'" and expects '+r+"; got "+Pu(i)+" "+Iu(i)+". (FAIL-LOUD \u2014 throw-or-apply, never a silently accepted wrong type.)")}function zn(e){return typeof e=="number"&&isFinite(e)}function bt(e){if(!Object.prototype.hasOwnProperty.call(qn,e))throw new TypeError("[lib/frqtl/objects/schema] rectTupleText("+Iu(e)+"): a rect tuple has "+Object.keys(qn).join(" or ")+" elements. (FAIL-LOUD.)");return"["+qn[e].join(", ")+"]"}function Hb(e){var t=e.constraint&&e.constraint.values||null;if(!t||typeof t!="object")return null;var r=Object.keys(t);if(r.length===0)return null;for(var i=r.slice(),n=0;n<r.length;n++)i.indexOf(t[r[n]])===-1&&i.push(t[r[n]]);return i}function Ed(e,t,r){var i=Hb(e);return i?(i.indexOf(t)===-1&&wr(r,e,"one of ["+i.join(", ")+"]",t),t):(typeof t!="string"&&typeof t!="number"&&wr(r,e,"a string or number (this field declares no constraint.values vocabulary to check against)",t),t)}function Sd(e,t,r,i){return(!Array.isArray(t)||t.length!==4&&t.length!==6||!t.every(zn))&&wr(r,e,i,t),t.slice()}function Fu(e,t){var r=t||"worldRect(r)";function i(a){throw new TypeError("[lib/frqtl/objects/schema] "+r+": "+a+"; got "+Pu(e)+" "+Iu(e)+". A world rect is { left, top, w, h } (or the "+bt(4)+" / "+bt(6)+" tuple) with positive w and h, written ONCE by the co-init call \u2014 EGPTUniverse.create({ rect }) \u2190 new FrqtlApp({ canvasW, canvasH }) / exp.createCanvas(w, h, cfg). There is no default world size. (FAIL-LOUD.)")}o(i,"fail"),(e==null||typeof e!="object")&&i("no world rect");var n;return Array.isArray(e)?((e.length!==4&&e.length!==6||!e.every(zn))&&i("a rect tuple must be 4 or 6 finite numbers"),n=e.length===4?{left:e[0],top:e[1],w:e[2],h:e[3]}:{left:e[0],top:e[1],z:e[2],w:e[3],h:e[4],d:e[5]}):(n={w:e.w,h:e.h},["left","top","z","d"].forEach(function(a){e[a]===void 0||e[a]===null||(zn(e[a])||i('"'+a+'" must be a finite number'),n[a]=e[a])})),(!zn(n.w)||!(n.w>0))&&i("w must be a positive finite number"),(!zn(n.h)||!(n.h>0))&&i("h must be a positive finite number"),n}function Nu(e,t,r){if(!e||typeof e!="object"||typeof e.type!="string")throw new TypeError('[lib/frqtl/objects/schema] normalizeValue requires a field descriptor carrying a "type"; got '+Pu(e)+". (FAIL-LOUD.)");if(!Object.prototype.hasOwnProperty.call(Lu,e.type))throw new TypeError('[lib/frqtl/objects/schema] normalizeValue: field "'+e.name+'" declares type "'+e.type+'", which has no normalizer row. Field types are owned by lib/shim/field-descriptor (FIELD_TYPES) \u2014 add the type THERE and a row in VALUE_NORMALIZERS here. (FAIL-LOUD.)');var i=Lu[e.type];return e.type==="readonly"||e.type==="forbidden"?i(e,t,r):t==null?t:i(e,t,r)}var qn,Lu,Mu,ln=ue(()=>{o(Pu,"_describeValue");o(Iu,"_previewValue");o(wr,"_valueFail");o(zn,"_isFiniteNumber");qn=Object.freeze({4:Object.freeze(["left","top","w","h"]),6:Object.freeze(["left","top","z","w","h","d"])});o(bt,"rectTupleText");o(Hb,"_enumMembers");o(Ed,"_normalizeEnumMember");o(Sd,"_normalizeRectTuple");o(Fu,"worldRect");Lu={number:o(function(e,t,r){zn(t)||wr(r,e,"a finite number (a numeric STRING is not a number \u2014 parse it at the caller)",t);var i=e.constraint||{},n=i.integer===!0?Math.round(t):t;return typeof i.min=="number"&&n<i.min&&wr(r,e,"a value >= the declared min "+i.min,t),typeof i.max=="number"&&n>i.max&&wr(r,e,"a value <= the declared max "+i.max,t),n},"number"),boolean:o(function(e,t,r){if(t===!0||t===1)return!0;if(t===!1||t===0)return!1;wr(r,e,"true, false, 0 or 1",t)},"boolean"),string:o(function(e,t,r){return typeof t!="string"&&wr(r,e,"a string",t),t},"string"),enum:o(function(e,t,r){return Ed(e,t,r)},"enum"),"enum-set":o(function(e,t,r){Array.isArray(t)||wr(r,e,"an array of declared members",t);for(var i=0;i<t.length;i++)Ed(e,t[i],r);return t.slice()},"enum-set"),rgb:o(function(e,t,r){return(!Array.isArray(t)||t.length!==3||!t.every(zn))&&wr(r,e,'an array of exactly 3 finite numbers [r, g, b] (a CSV "r,g,b,a" string is the frame-data render wire, not this field \u2014 convert at lib/shim/frame-data before the write)',t),t.slice()},"rgb"),rect:o(function(e,t,r){return Sd(e,t,r,"an array of 4 finite numbers "+bt(4)+" or the 6-element explicit z/depth form "+bt(6))},"rect"),"rect-array":o(function(e,t,r){Array.isArray(t)||wr(r,e,"an array of rect tuples",t);for(var i=[],n=0;n<t.length;n++)i.push(Sd(e,t[n],r,"every entry to be an array of 4 finite numbers "+bt(4)+" (or 6, "+bt(6)+"); entry "+n+" is not"));return i},"rect-array"),readonly:o(function(e,t,r){wr(r,e,"NO write at all \u2014 a readonly field is derived/computed and inspectable only",t)},"readonly"),forbidden:o(function(e,t,r){wr(r,e,"NO write at all \u2014 this property is engine-owned topology",t)},"forbidden"),object:o(function(e,t,r){return typeof t!="object"&&wr(r,e,"a structured object (arrays included)",t),t},"object"),writable:o(function(e,t){return t},"writable")};o(Nu,"normalizeValue");Mu=Object.freeze(Object.keys(Lu))});function Po(){var e=ll["render.shape"],t={};if(Array.isArray(e))for(var r=0;r<e.length;r++)t[e[r]]=e[r];return t}var Kb,Yb,Jb,ri,gl=ue(()=>{Od();Du();ln();Fi();Vt();ti();o(Po,"shapeValuesMap");Kb={kind:"particle",description:'A leaf frame (is_leaf=true) \u2014 the fundamental quantum of the simulation. Particles are not directly placeable; they are emitted by QuantumEmitter, PointSource, and other emitter objects. Every "particle" IS a Frame: the Frame Axiom states there is no separate particle class. Leaf frames have mass = capacity (engine invariant).',fields:[{name:"x",type:"readonly",engineVisible:!0,description:"Current X position (physics pixels)"},{name:"y",type:"readonly",engineVisible:!0,description:"Current Y position (physics pixels)"},{name:"vx",type:"readonly",engineVisible:!0,description:"Current X momentum (pixels/tick). Accumulates when the 1px/tick speed limit is exceeded."},{name:"vy",type:"readonly",engineVisible:!0,description:"Current Y momentum (pixels/tick). Accumulates when the 1px/tick speed limit is exceeded."},{name:"mass",type:"readonly",engineVisible:!0,description:"Pixel occupancy count (Frame Axiom: leaf mass = capacity). Mass drives wavelength: higher mass \u2192 shorter wavelength \u2192 higher frequency."},{name:"wavelength",type:"readonly",engineVisible:!0,description:"floor(capacity/mass * WAVELENGTH_CONSTANT), minimum 4 (engine invariant 6). Controls the probabilistic coin-flip that creates wave behavior."}]},Yb={kind:"backdrop",description:"A render-only background image or color fill. Created as a LargeObject with NONE collision type and no actions, so it is invisible to the physics engine. Use it for scene backgrounds, lab diagrams, or any decoration that should never interact with particles.",fields:[{name:"rect",type:"rect",engineVisible:!1,description:"Bounding rectangle for the backdrop image or fill (render-only). Typically matches the full canvas rect."},{name:"visible",type:"boolean",engineVisible:!1,description:"Whether the backdrop is rendered (render-only). Toggling false hides the background."},{name:"color",type:"rgb",engineVisible:!1,description:"Fallback fill color [r, g, b] used when no image is provided (render-only)."},{name:"alpha",type:"number",constraint:{min:0,max:255,integer:!0},engineVisible:!1,widgetHint:"slider",description:"Render opacity 0-255 (render-only)"}]},Jb={kind:"LargeObject",description:"A rectangular engine-registered boundary object (wall, detector, barrier). The engine evaluates particle collisions against every registered LargeObject each tick and applies the configured collision_type + actions to matching particles.",fields:[{name:"rect",type:"rect",engineVisible:!0,unit:"px",description:"Bounding rectangle in physics pixels "+bt(4)+". FRQTL-MAINT (2026-07-01): may also carry explicit z/depth "+bt(6)+" \u2014 WASM-only, MIRRORS the engine's Rectangle::from_top_left argument order. Omitting z/d is back-compat: the engine defaults z=0, d=w (bit-identical to the pre-fix hardcoded behavior \u2014 see #61)."},{name:"region",type:"object",engineVisible:!0,internal:!0,description:'SWEPT-OBB narrow-phase collision region (circulation \xA72): { kind:"obb", theta(radians), hw, hh, hz } produced by the SlabFace authority for a rotated wall, or null (default) = the byte-identical AABB path. Convention-free geometry (theta in the engine frame, never raw orientationDeg). The engine narrow-phase filters candidates by a SWEPT prev\u2192now segment-vs-OBB test ahead of BOTH the op-program trigger and the collided-frame collection, so a tilted mirror collides AT its drawn face (not the AABB entry plane). WASM-only.'},{name:"collision_type",type:"enum",constraint:{values:Ee},engineVisible:!1,description:"SUGAR-INPUT (compiled to an op-program at registration; engine has no collision_type dispatch). NONE = pass-through; BOUNCE = reverse momentum; WALL = stop; RANDOM_X/Y/XY = randomise that velocity component; MOMENTUM_BASED = redirect proportional to incoming momentum."},{name:"actions",type:"enum-set",constraint:{values:st},engineVisible:!1,description:"SUGAR-INPUT (compiled to an op-program at registration; engine has no action dispatch). ABSORB = remove the particle; COUNT = increment hit counter; MARK = flag the particle (writes string_map.detector_name = loName); DETECT = record the detection event (same as MARK); LOG = emit a log entry; BOUNCE = apply bounce momentum; BLOCK = stop the particle."},{name:"name",type:"string",engineVisible:!1,description:"Human-readable identifier for this object (display/debug only; not engine-visible after construction)"},{name:"reposition",type:"enum",constraint:{values:{top:"top",bottom:"bottom",left:"left",right:"right",closest:"closest"}},engineVisible:!0,description:`Eject direction when a quantum is found overlapping this object's rect. "closest" ejects toward the nearest edge; the cardinal values force a specific side.`},{name:"search_padding",type:"number",constraint:{min:0,integer:!0},engineVisible:!1,description:"DEPRECATED / IGNORED. The engine no longer reads this; the collision search rect now expands by the dimension's mb_w. Retained only as a reserved positional constructor placeholder."},{name:"color",type:"rgb",engineVisible:!1,description:"Render color [r, g, b] 0-255 each. Affects only the drawn appearance; engine collision is unaffected."},{name:"alpha",type:"number",constraint:{min:0,max:255,integer:!0},engineVisible:!1,widgetHint:"slider",description:"Render opacity 0-255 (render-only). 0 = fully transparent, 255 = fully opaque."},{name:"visible",type:"boolean",engineVisible:!1,description:"Whether the object is drawn (render-only). Setting false hides the visual; engine collision detection remains active."},{name:"shellRender",type:"enum",constraint:{values:{design:"design",run:"run",never:"never"}},engineVisible:!1,description:`When this object's visual shell renders (render-only): design = only while authoring (the marker default); run = always visible (the "red light bulb" opt-in); never = hidden. Generalizes the design-only marker suppression at the single _visibleLargeObjects authority; engine collision is unaffected.`},{name:"drawAsCircle",type:"boolean",engineVisible:!1,description:"Render as a circle inscribed in the bounding rect instead of a rectangle (render-only)."},{name:"shellShape",type:"enum",constraint:{values:Po()},engineVisible:!1,description:`Render shape of this object's visual shell (render-only): ball|box|circle|cube|sphere. For a SphereEmitter this is the shape of the emitter's outer LO frame (the "red light bulb" orb vs a box). Honored by the provider draw layer (capability-based, zero engine change); absent/omitted falls back to drawAsCircle. cube/sphere degrade to box/ball in 2D.`},{name:"layer",type:"number",constraint:{min:0,integer:!0},engineVisible:!0,description:"Dimension layer this object is scoped to (0 = fundamental/lowest; null = all layers). Selects which Dimension passes this object participates in (observed_dimensions=[layer]; null = all). Candidates come from that dimension's frame list."},{name:"count",type:"number",constraint:{min:0,integer:!0},engineVisible:!0,description:"Writable integer counter (SLICE 3, binding item 2). Incremented via op-program: set self.count = self.count + 1. Routed through setObjectProperty like any property \u2014 NOT an interpreter special-case. Default 0; reset only by an explicit op or by user code. Mirrors the count field in the Rust LargeObjectSpec (universe.rs)."},{name:"program",type:"object",engineVisible:!0,internal:!0,description:'Op-program attached to this LO (\xA710.3 SLICE 3). Shape: { on: "collision"|"tick", ops: [{ set: "<handle>.<prop>", to: ExprAST }] }. on:"collision" \u2014 runs once per overlapping frame per tick, BEFORE ABSORB. on:"tick" \u2014 runs once per LO per tick (Phase A). null clears the program. Written via updateObjectProperty(handle, "LargeObject", "program", prog) \u2014 used by \xA710.3 L3 to attach eject op-programs to oven walls after registration.'},{name:"left",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.left (left edge in physics pixels). Read-only in scope; rect is the writable authority."},{name:"right",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.right (right edge = rect.left + rect.w). Read-only in scope."},{name:"top",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.top (top edge in physics pixels). Read-only in scope."},{name:"bottom",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.bottom (bottom edge = rect.top + rect.h). Read-only in scope."},{name:"cx",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.x (center X = rect.left + rect.w/2). Read-only in scope."},{name:"cy",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.y (center Y = rect.top + rect.h/2). Read-only in scope."},{name:"w",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.w (width in physics pixels). Read-only in scope."},{name:"h",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.h (height in physics pixels). Read-only in scope."},{name:"x",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.x (center X, alias for cx). Read-only; rect is the writable authority."},{name:"y",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.y (center Y, alias for cy). Read-only; rect is the writable authority."},{name:"near",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.near (near z-face = rect.z - rect.d/2 in centered terms, or the literal z corner in corner-mode registration). Read-only in scope; rect is the writable authority. WASM-only."},{name:"far",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.far (far z-face = rect.near + rect.d). Read-only in scope. WASM-only."},{name:"d",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.d (depth in physics pixels). Read-only in scope. WASM-only."},{name:"cz",type:"readonly",internal:!0,engineVisible:!0,description:"Derived: rect.z (center Z). Read-only in scope. WASM-only."}]},ri=Object.freeze({particle:Kb,backdrop:Yb,Frame:wd,Universe:_d,Dimension:xd,LargeObject:Jb});Object.keys(ri).forEach(function(e){ml(e,ri[e])})});function Gt(e){throw new Error("[kinds] "+e+" (FAIL-LOUD.)")}function at(e,t){typeof e!="function"&&Gt("registerKind(Class, row): Class must be the part's class (got "+typeof e+").");let r=e.name;r||Gt("registerKind: the class is anonymous \u2014 the kind name IS the class name, so a kind's class must be named."),(!t||typeof t!="object")&&Gt("registerKind("+r+", row): row must be an object {"+Uu.join(", ")+"}."),Object.prototype.hasOwnProperty.call(t,"name")&&Gt("registerKind("+r+"): a row carries no `name` \u2014 the kind name IS the class name ("+r+"). To register under another name, rename the class.");for(let a of Object.keys(t))Uu.indexOf(a)===-1&&Gt("registerKind("+r+'): unknown row key "'+a+'" \u2014 a row carries '+Uu.join(", ")+".");(typeof t.from!="string"||!t.from)&&Gt("registerKind("+r+"): `from` is required \u2014 the defining module's own URL (from: import.meta.url).");try{new URL(t.from)}catch{Gt("registerKind("+r+"): `from` must be a URL (import.meta.url), got "+JSON.stringify(t.from)+".")}let i=Object.prototype.hasOwnProperty.call(ri,r)?ri[r]:null;i&&t.descriptor!==i&&Gt("registerKind("+r+', \u2026): "'+r+'" is a SCOPE descriptor row (schema/scopes.js SCOPE_DESCRIPTORS) \u2014 a scope is not a kind, and one name has one owner. Rename the class, or register the scope row itself by reference (descriptor: SCOPE_DESCRIPTORS.'+r+") ("+t.from+")."),Vi.has(r)&&Gt('kind "'+r+'" is already registered by '+Vi.get(r).from+"; "+t.from+" registers it again \u2014 rename the class in the copy.");let n=t.descriptor;if((!n||typeof n!="object")&&Gt("registerKind("+r+"): `descriptor` is required."),!i&&Qb(n)){let a={};for(let s of Object.keys(n))s!=="kind"&&(a[s]=n[s]);n=a}if(!i&&Object.prototype.hasOwnProperty.call(n,"kind")&&Gt("registerKind("+r+"): the descriptor carries a `kind` \u2014 the registry stamps it from the class name; a typed copy is a second derivation of the same fact. Delete the descriptor's kind line."),ml(r,n),t.defaults!==void 0&&(t.defaults===null||typeof t.defaults!="object"||Array.isArray(t.defaults))&&Gt("registerKind("+r+"): `defaults` must be a props object when given."),t.build!==void 0&&typeof t.build!="function"&&Gt("registerKind("+r+"): `build` must be a function (props, ctx) \u2192 part when given."),t.palette!==void 0){let a=t.palette;(!a||typeof a!="object")&&Gt("registerKind("+r+"): `palette` must be {"+zu.join(", ")+"}.");for(let s of Object.keys(a))zu.indexOf(s)===-1&&Gt("registerKind("+r+'): unknown palette key "'+s+'" \u2014 '+zu.join(", ")+".");for(let s of["displayName","category","iconHint"])(typeof a[s]!="string"||!a[s])&&Gt("registerKind("+r+"): palette."+s+" must be a non-empty string.");(typeof a.rank!="number"||!Number.isInteger(a.rank)||a.rank<0)&&Gt("registerKind("+r+"): palette.rank must be a non-negative integer (the palette order).")}return i||Object.defineProperty(n,"kind",{value:r,enumerable:!0,writable:!1,configurable:!1}),Vi.set(r,Object.freeze({name:r,Class:e,from:t.from,descriptor:qu(n),defaults:t.defaults===void 0?void 0:qu(Object.assign({},t.defaults)),build:t.build,palette:t.palette?Object.freeze(Object.assign({},t.palette)):void 0})),e}function Qb(e){for(let t of Vi.values())if(t.descriptor===e)return!0;return!1}function qu(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null&&!Array.isArray(e))return e;Object.freeze(e);for(let r of Object.keys(e))qu(e[r]);return e}function vl(e){return'kind "'+e+`" is not registered in this realm \u2014 import the module that defines it; published parts: '@descix/frqtl-web/parts'`}function ja(e){let t=Vi.get(e);if(!t)throw new Error("[kinds] "+vl(e)+". (FAIL-LOUD.)");return t.Class}function Dt(e){if(typeof e=="string")return Vi.get(e)||null;if(typeof e=="function"){let t=Vi.get(e.name);return t&&t.Class===e?t:null}return null}function Ra(){return Array.from(Vi.keys())}function kd(){return Array.from(Vi.values()).filter(function(e){return!!e.palette}).sort(function(e,t){return e.palette.rank-t.palette.rank})}var Uu,zu,Vi,xt=ue(()=>{Du();gl();Uu=Object.freeze(["from","descriptor","defaults","build","palette"]),zu=Object.freeze(["displayName","category","iconHint","rank"]),Vi=new Map;o(Gt,"_fail");o(at,"registerKind");o(Qb,"_isRegisteredDescriptor");o(qu,"_deepFreeze");o(vl,"unregisteredKindMessage");o(ja,"kindNamed");o(Dt,"kindOf");o(Ra,"registeredKinds");o(kd,"placeableKinds")});var Bu={};ge(Bu,{LargeObject:()=>Se});function Zb(e,t,r,i){if(typeof lt!="function")return{left:e,top:t,w:r,h:i};var n=new lt(e,t,r,i,null,!1);return Object.defineProperty(n,"toJSON",{value:o(function(){return{left:this.left,top:this.top,w:this.w,h:this.h}},"value"),enumerable:!1}),n}function Ad(e){return e?Array.isArray(e)?e:e.left!==void 0?e.z!==void 0||e.d!==void 0?[e.left,e.top,e.z!==void 0?e.z:0,e.w,e.h,e.d!==void 0?e.d:e.w]:[e.left,e.top,e.w,e.h]:e.x!==void 0&&e.width!==void 0?[e.x,e.y,e.width,e.height]:e:null}function Se(e,t,r,i,n,a,s,l,c,f){i=i||[],n=n||"",a=a||"closest",s=s||null,l=l!==void 0?l:1,c=c||[120,120,120],f=f||!1,this.universe=e,this._schemaKind=this.constructor.name;var u=Ad(t);this.rect=u.length===6?{left:u[0],top:u[1],z:u[2],w:u[3],h:u[4],d:u[5]}:Zb(u[0],u[1],u[2],u[3]),this.color=c,this.alpha=255,this.visible=!0,this.drawAsCircle=!1,this.name=n,this.collision_type=r,this.reposition=a,this.search_padding=l,this.collect_collided=f,this.layer=Array.isArray(s)&&s.length===1?s[0]:null;var h=Ta,g=h(i,n,a,r),d=g.program,m=d!==null?Vu.NONE:r;this.actions=i.slice(),this.program=d;var b={rect:u,name:n,observed_dimensions:s||[]};d!==null&&(b.program=d),f&&(b.collect_collided=!0),this.handle=e.registerLargeObject(b),Array.isArray(e.largeObjects)||(e.largeObjects=[]),e.largeObjects.push(this)}var Vu,Xb,_r=ue(()=>{At();Vt();ti();Mn();Do();xt();gl();Vu=Ee;Xb=st;o(Zb,"_makeLoRect");o(Ad,"rectToArray");o(Se,"LargeObject");Se.prototype.setRect=function(e){var t=typeof this.rect.z=="number";if(!Array.isArray(e)||e.length!==(t?6:4)||!e.every(function(i){return typeof i=="number"&&isFinite(i)}))throw new TypeError('[LargeObject.setRect] "'+this.name+'" is a '+(t?"z-capable":"2D")+" LO and takes "+(t?"[l,t,z,w,h,d]":"[l,t,w,h]")+" of finite numbers; got "+JSON.stringify(e)+". (FAIL-LOUD.)");var r=this.rect;return t?(r.left=e[0],r.top=e[1],r.z=e[2],r.w=e[3],r.h=e[4],r.d=e[5]):(r.w=e[2],r.h=e[3],r.left=e[0],r.top=e[1]),this.universe&&typeof this.universe.updateObjectProperty=="function"&&this.universe.updateObjectProperty(this.handle,"LargeObject","rect",e.slice()),this};Se.prototype.setCollisionType=function(e){this.collision_type=e,this.universe.setLargeObjectCollisionType(this.handle,e)};Se.prototype.setActive=function(e){this.universe.setLargeObjectActive(this.handle,e)};Se.prototype.recompileActions=function(e){e=e||{};var t=e.collisionType!==void 0?e.collisionType:this.collision_type,r=e.actions!==void 0?e.actions:this.actions,i=Ta,n=i(r,this.name,this.reposition,t),a=t;n.program!==null&&(a=Vu.NONE),this.collision_type=t,this.actions=r.slice(),this.program=n.program,this.universe&&typeof this.universe.updateObjectProperty=="function"&&this.universe.updateObjectProperty(this.handle,"LargeObject","program",n.program)};Se.prototype.dispose=function(){if(!this._disposed){if(this._disposed=!0,this.universe&&typeof this.universe.unregisterLargeObject=="function")this.universe.unregisterLargeObject(this.handle);else if(this.universe&&Array.isArray(this.universe.largeObjects)){var e=this.universe.largeObjects.indexOf(this);e!==-1&&this.universe.largeObjects.splice(e,1)}}};Se.rectToArray=Ad;at(Se,{from:new URL("frqtl/parts/LargeObject.js",ze()).href,descriptor:ri.LargeObject,defaults:{collision_type:"BOUNCE",actions:[],reposition:"closest",search_padding:1,color:[120,120,120]},build:o(function(e,t,r){var i=r,n=e.rect&&e.rect.w||70,a=e.rect&&e.rect.h||70,s=e.rect&&e.rect.left!=null?e.rect.left:Math.round(t.x-n/2),l=e.rect&&e.rect.top!=null?e.rect.top:Math.round(t.y-a/2),c=e.collision_type||"RANDOM_XY",f=e.actions||[],u=e.name||"block "+(t.runner.largeObjects.length+1),h=e.reposition||"closest",g=e.color||[210,90,90],d=e.layer!=null?[e.layer]:null,m=new i(t.runner.universe,[s,l,n,a],c,f,u,h,d,1,g);return e.alpha!=null&&(m.alpha=e.alpha),e.visible!=null&&(m.visible=e.visible),e.drawAsCircle!=null&&(m.drawAsCircle=e.drawAsCircle),m._schemaKind=r.name,m},"build")})});var El={};ge(El,{BOUNCE_DIRECTIONS:()=>bl,WALL_BEHAVIORS:()=>yl,WALL_HOOKS:()=>wl,WALL_PRESETS:()=>Wu,bounceDirectionValuesMap:()=>xl,expandWallPreset:()=>Ku,resolveWallSpec:()=>Hu,wallBehaviorV2ValuesMap:()=>_l,wallHookValuesMap:()=>Ol});function Gu(e){var t={};return Object.keys(e).forEach(function(r){t[r]=r}),t}function Hu(e){e=e||{};var t=e.collisionBehavior||"nothing";if(!yl[t])throw new Error('[WallBehaviors] unknown collisionBehavior "'+t+'" \u2014 must be one of ['+Object.keys(yl).join(", ")+"].");if(t==="bounce"&&e.bounceDirection&&!bl[e.bounceDirection])throw new Error('[WallBehaviors] unknown bounceDirection "'+e.bounceDirection+'" \u2014 must be one of ['+Object.keys(bl).join(", ")+"].");var r=Array.isArray(e.hooks)?e.hooks:[];r.forEach(function(n){if(!wl[n])throw new Error('[WallBehaviors] unknown hook "'+n+'" \u2014 must be one of ['+Object.keys(wl).join(", ")+"].")});var i=Tu({behavior:t,bounceDirection:e.bounceDirection||"reflect",angleConstraint:e.angleConstraint,orientationDeg:e.orientationDeg,decoherence:e.decoherence,hooks:r,markTag:e.markTag,color:e.color,capacity:e.capacity,emissivity:e.emissivity,reposition:e.reposition||"closest",is3D:e.is3D===!0,slabW:e.slabW,slabH:e.slabH,pitchDeg:e.pitchDeg,slabD:e.slabD});return{program:i.program,collectCollided:i.collectCollided,radiation:i.radiation,behavior:t,hooks:r.slice()}}function Ku(e){var t=Wu[e];if(!t)throw new Error('[WallBehaviors] unknown wall preset "'+e+'" \u2014 must be one of ['+Object.keys(Wu).join(", ")+"].");var r={};return Object.keys(t).forEach(function(i){i!=="label"&&(r[i]=Array.isArray(t[i])?t[i].slice():t[i])}),r}function _l(){return Gu(yl)}function xl(){return Gu(bl)}function Ol(){return Gu(wl)}var yl,bl,wl,Wu,Io=ue(()=>{Vt();ti();Mn();yl={nothing:"nothing",block:"block",bounce:"bounce",absorb:"absorb",destroy:"destroy"},bl={reflect:"reflect",random:"random"},wl={mark:st.MARK,count:st.COUNT,recolor:"recolor"};o(Gu,"_valuesMap");o(Hu,"resolveWallSpec");Wu={mirror:{label:"Mirror",collisionBehavior:"bounce",bounceDirection:"reflect"},brick:{label:"Brick Wall",collisionBehavior:"bounce",bounceDirection:"random",decoherence:!1},"detector-screen":{label:"Detector Screen",collisionBehavior:"destroy",hooks:["count"],countFilter:"any"},"transparent-probe":{label:"Transparent Probe",collisionBehavior:"nothing",hooks:["mark","count"]},wall:{label:"Wall",collisionBehavior:"block"}};o(Ku,"expandWallPreset");o(_l,"wallBehaviorV2ValuesMap");o(xl,"bounceDirectionValuesMap");o(Ol,"wallHookValuesMap")});var Fo={};ge(Fo,{DEFAULT_EMISSIVITY:()=>Rd,attachAbsorberBackingFrame:()=>Yu,buildAbsorbRadiationTickFn:()=>Ju,deriveBackingLevel:()=>Dd});function Td(e,t){var r=Number(e);if(!isFinite(r)||r<=0||r>1)throw new Error("["+t+"] emissivity must be a fullness fraction in (0, 1] \u2014 got "+JSON.stringify(e)+". Above 1 is a move gate above 1; 0 is refused because the emitted-mass law floors at 1 cell and could not honour it.");return r}function Dd(e,t){for(var r=Math.max(1,Number(t)||1),i=1;i<=64;i++)if(e.levelCapacity(i)>=r)return i;throw new Error("[deriveBackingLevel] no leaf level up to 64 reaches the requested absorb capacity "+r+" on this universe's active axes.")}function $b(e){if(Array.isArray(e))return e.length===6?[e[0]+e[3]/2,e[1]+e[4]/2]:[e[0]+e[2]/2,e[1]+e[3]/2];var t=e.left!==void 0?e.left:e._left,r=e.top!==void 0?e.top:e._top;return[t+e.w/2,r+e.h/2]}function Cd(e){var t=$b(e),r;if(Array.isArray(e))r=e.length===6?e[0]+e[3]:e[0]+e[2];else{var i=e.left!==void 0?e.left:e._left;r=i+e.w}return[r,t[1]]}function Sl(e,t,r){e.set(t,(e.get(t)||0)+r)}function jd(e){var t=[];return e.forEach(function(r,i){t.push(i)}),t.sort(function(r,i){return r-i}),t}function Yu(e,t,r,i){var n=Dd(e,i),a=e.levelCapacity(n),s=e.getLargeObjectFrameId(t),l=e.getFrameQuantumId(s);return e.setFrameProperty(l,"mass",1),{backingFrameHandle:s,backingQid:l,level:n,capacity:a}}function Ju(e){var t=e.universe,r=e.loHandle,i=e.backingQid,n=e.capacity,a=e.rect,s=e.exit||Cd(a),l=1,c=0,f=0,u=l,h=e.emissivity===void 0||e.emissivity===null?Rd:Td(e.emissivity,"buildAbsorbRadiationTickFn"),g=new Map,d=new Map,m=new Map;function b(x){typeof e.loActiveSetter=="function"?e.loActiveSetter(x):t&&typeof t.setLargeObjectActive=="function"&&t.setLargeObjectActive(r,x)}o(b,"setActive");function y(){var x=jd(m).filter(function(j){return(m.get(j)||0)>0});if(x.length===0)return null;if(x.length===1)return x[0];var S=0,A;for(A=0;A<x.length;A++)S+=m.get(x[A]);var T=(typeof t.random=="function"?t.random():Math.random())*S;for(A=0;A<x.length;A++)if(T-=m.get(x[A]),T<0)return x[A];return x[x.length-1]}o(y,"pickEmissionLayer");var w=o(function(S){var A=S&&S.objects?S:t&&t._lastTickData?t._lastTickData:null,T=A&&A.objects&&A.objects[r],j=t.getFrameProperty(i,"mass"),Q=j;if(T&&Array.isArray(T.frames))for(var Y=0;Y<T.frames.length;Y++){var H=T.frames[Y];if(!(!H||H.isAlive!==!1||typeof H.mass!="number")){var V=n-j;if(V<=0)break;var C=Math.min(H.mass,V);C<=0||(j+=C,c+=C,Sl(g,H.layer,C),Sl(m,H.layer,C))}}if(j!==Q&&t.setFrameProperty(i,"mass",j),j>u&&(u=j),b(j<n),j-l>0){var J=typeof t.random=="function"?t.random():Math.random();if(J<1/n){var R=y();if(R!==null){var K=m.get(R),N=Math.min(Math.max(1,Math.round(h*t.levelCapacity(R))),K),B=l+(u-l)/2;if(j-N>=B){var ie=Math.pow(2,R)/2,oe=t.makeLeafFrame(s[0]+ie+1,s[1]-ie,R,null,1,0,!0,0,null);t.injectFrame(oe);var $=t.getFrameQuantumId(oe);t.setFrameProperty($,"mass",N),t.setFrameProperty(i,"mass",j-N),f+=N,Sl(d,R,N),Sl(m,R,-N)}}}}},"absorbRadiationTick");return w.stats=function(){var x=t.getFrameProperty(i,"mass")-l,S=new Map;g.forEach(function(T,j){S.set(j,!0)}),d.forEach(function(T,j){S.set(j,!0)});var A=jd(S).map(function(T){return{layer:T,absorbed:g.get(T)||0,radiated:d.get(T)||0,stored:m.get(T)||0}});return{stored:x,absorbedTotal:c,radiatedTotal:f,byLayer:A}},w.emissivity=function(){return h},w.setEmissivity=function(x){return h=Td(x,"setEmissivity"),h},w.setRect=function(x){e.exit||(s=Cd(x))},w}var Rd,Qu=ue(()=>{Rd=.5;o(Td,"_validEmissivity");o(Dd,"deriveBackingLevel");o($b,"_rectCenter");o(Cd,"_rectRightExit");o(Sl,"_bump");o(jd,"_layersAscending");o(Yu,"attachAbsorberBackingFrame");o(Ju,"buildAbsorbRadiationTickFn")});var Bi={};ge(Bi,{drawnCenter:()=>Vn,drawnVolume:()=>tf,firstHit:()=>rf,hasZ:()=>yi,rayIntersect:()=>Id,rectAtCenter:()=>e0,snapCenter:()=>nf,snapRectPosition:()=>t0,volumeContains:()=>Fd,zExtent:()=>$u});function yi(e){return typeof e.z=="number"}function Vn(e){var t=yi(e)?e.z+(typeof e.d=="number"?e.d:e.w)/2:0;return[e.left+e.w/2,e.top+e.h/2,t]}function e0(e,t){var r=typeof t[2]=="number"?t[2]:0;if(yi(e)){var i=ef(e);return[t[0]-e.w/2,t[1]-e.h/2,r-i/2,e.w,e.h,i]}if(r!==0)throw new RangeError("[LoDrawnCenter.rectAtCenter] a z-less rect sits at z-centre 0 and cannot be placed at z = "+r+" \u2014 place it at cz 0, or give the rect an explicit z. (FAIL-LOUD.)");return[t[0]-e.w/2,t[1]-e.h/2,e.w,e.h]}function $u(e){return ef(e)}function ef(e){return yi(e)?typeof e.d=="number"?e.d:e.w:0}function tf(e){if(e&&e.rect){var t=e.rect;return{kind:"box",center:Vn(t),half:[t.w/2,t.h/2,ef(t)/2],yawDeg:typeof e.orientationDeg=="number"?e.orientationDeg:0,pitchDeg:typeof e.pitchDeg=="number"?e.pitchDeg:0}}if(e&&Array.isArray(e.center)&&typeof e.radius=="number"){var r=e.center;return{kind:"sphere",center:[r[0],r[1],typeof r[2]=="number"?r[2]:0],radius:e.radius}}throw new TypeError("[LoDrawnCenter.drawnVolume] needs {rect} (an LO) or {center, radius} (a centre-only target); got "+JSON.stringify(e)+". (FAIL-LOUD.)")}function Xu(e,t){var r=e.yawDeg*Ld,i=e.pitchDeg*Ld,n=Math.cos(r),a=Math.sin(r),s=Math.cos(i),l=Math.sin(i);return[n*s*t[0]+a*s*t[1]-l*t[2],-a*t[0]+n*t[1],n*l*t[0]+a*l*t[1]+s*t[2]]}function Zu(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}function Id(e,t,r,i){var n=typeof i=="number"?i:0;if(r.kind==="sphere"){var a=r.radius+n,s=Zu(e,r.center),l=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],c=2*(s[0]*t[0]+s[1]*t[1]+s[2]*t[2]),f=s[0]*s[0]+s[1]*s[1]+s[2]*s[2]-a*a,u=c*c-4*l*f;if(!(l>0)||u<0)return null;var h=Math.sqrt(u),g=(-c-h)/(2*l),d=(-c+h)/(2*l);return d<0?null:g>0?g:0}if(r.kind==="box"){for(var m=Xu(r,Zu(e,r.center)),b=Xu(r,t),y=-1/0,w=1/0,x=0;x<3;x++){var S=r.half[x]+n;if(Math.abs(b[x])<1e-12){if(m[x]<-S||m[x]>S)return null;continue}var A=(-S-m[x])/b[x],T=(S-m[x])/b[x];if(A>T){var j=A;A=T,T=j}if(A>y&&(y=A),T<w&&(w=T),y>w)return null}return w<0?null:y>0?y:0}throw new TypeError("[LoDrawnCenter.rayIntersect] unknown volume kind "+String(r&&r.kind)+" \u2014 volumes come from drawnVolume(). (FAIL-LOUD.)")}function Fd(e,t,r){var i=typeof r=="number"?r:0,n=Zu(t,e.center);if(e.kind==="sphere"){var a=e.radius+i;return n[0]*n[0]+n[1]*n[1]+n[2]*n[2]<=a*a+1e-9}for(var s=Xu(e,n),l=0;l<3;l++)if(Math.abs(s[l])>e.half[l]+i+1e-9)return!1;return!0}function Pd(e,t){if(e.kind==="sphere"){var r=e.radius+t;return r*r*r*4.18879}return 8*(e.half[0]+t)*(e.half[1]+t)*(e.half[2]+t)}function rf(e,t,r,i){for(var n=typeof i=="number"?i:0,a=[],s=0;s<r.length;s++){var l=Id(e,t,r[s],n);l!==null&&a.push({index:s,t:l})}if(!a.length)return null;a.sort(function(m,b){return m.t-b.t});for(var c=a[0],f=1;f<a.length;f++){var u=a[f],h=r[c.index],g=r[u.index],d=[e[0]+t[0]*u.t,e[1]+t[1]*u.t,e[2]+t[2]*u.t];Fd(h,d,n)&&Pd(g,n)<Pd(h,n)&&(c=u)}return c}function Nd(e,t,r){if(!Array.isArray(e)||r.indexOf(e.length)===-1||!e.every(function(i){return typeof i=="number"&&isFinite(i)}))throw new TypeError("[LoDrawnCenter."+t+"] "+r.join(" or ")+" finite numbers; got "+JSON.stringify(e)+". (FAIL-LOUD.)")}function t0(e){Nd(e,"snapRectPosition",[4,6]);var t=e.length===6?3:2;return e.map(function(r,i){return i<t?Math.round(r):r})}function nf(e){return Nd(e,"snapCenter",[2,3]),e.map(function(t){return Math.round(t)})}var Ld,Da=ue(()=>{o(yi,"hasZ");o(Vn,"drawnCenter");o(e0,"rectAtCenter");Ld=Math.PI/180;o($u,"zExtent");o(ef,"_zExtent");o(tf,"drawnVolume");o(Xu,"_toLocal");o(Zu,"_sub");o(Id,"rayIntersect");o(Fd,"volumeContains");o(Pd,"_size");o(rf,"firstHit");o(Nd,"_finiteTuple");o(t0,"snapRectPosition");o(nf,"snapCenter")});var of={};ge(of,{ObjectSchema:()=>Be,shapeValuesMap:()=>Po});function kl(e){var t=Dt(e);return t?t.descriptor:Object.prototype.hasOwnProperty.call(ri,e)?ri[e]:null}function af(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(af);if(ArrayBuffer.isView(e))return Array.from(e);var t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)return e;var r={};return Object.keys(e).forEach(function(i){r[i]=af(e[i])}),r}var No,La,Mo,Uo,Be,bi=ue(()=>{Vt();ti();Io();Fi();Un();ln();Da();gl();xt();o(kl,"_descriptor");if(Array.isArray(Ui)){for(No=Mu,La=Ui,Mo=0;Mo<La.length;Mo++)if(No.indexOf(La[Mo])===-1)throw new Error('[lib/frqtl/objects/schema] field type "'+La[Mo]+`" is declared in lib/shim/field-descriptor's FIELD_TYPES but has no row in valueNormalizer.js's VALUE_NORMALIZERS \u2014 every declared type must state how a written value is normalized/rejected. (FAIL-LOUD.)`);for(Uo=0;Uo<No.length;Uo++)if(La.indexOf(No[Uo])===-1)throw new Error('[lib/frqtl/objects/schema] valueNormalizer.js declares a row for "'+No[Uo]+`", which is not a member of lib/shim/field-descriptor's FIELD_TYPES ([`+La.join(", ")+"]). The type vocabulary has ONE owner. (FAIL-LOUD.)")}o(af,"_plainCopy");Be={get:o(function(e){return kl(e)},"get"),kinds:o(function(){var e=Ra();return e.concat(Object.keys(ri).filter(function(t){return e.indexOf(t)===-1}))},"kinds"),ux:o(function(e){var t=kl(e),r=t?t.ux:void 0;return typeof Ca=="function"?Ca(r):{resizable:!0,draggable:{"2d":!0},handles:null,shellRender:"design"}},"ux"),placeableCatalog:o(function(){return kd().map(function(e){return{kind:e.name,displayName:e.palette.displayName,description:e.descriptor.description,category:e.palette.category,iconHint:e.palette.iconHint,defaultProps:e.defaults}})},"placeableCatalog"),captureProps:o(function(e,t){var r=kl(t);if(!r||!Array.isArray(r.fields))throw new Error('[ObjectSchema] captureProps(obj, "'+t+'"): no descriptor for kind "'+t+`" in this realm \u2014 a capture reads the kind's declared fields, never the object's own keys. (FAIL-LOUD.)`);for(var i={},n=0;n<r.fields.length;n++){var a=r.fields[n];if(a.writeOnly!==!0){var s=e[a.name];if(s!==void 0){if(a.type==="rect"&&s&&typeof s=="object"&&!Array.isArray(s)){var l=yi(s)?6:4,c=qn[l].map(function(f){return f==="d"?$u(s):s[f]});if(c.every(function(f){return typeof f=="number"})){i[a.name]=c;continue}}i[a.name]=af(s)}}}return i},"captureProps"),derivedReads:o(function(e){var t=kl(e);if(!t||!Array.isArray(t.fields))throw new Error('[ObjectSchema] derivedReads("'+e+'"): no descriptor for kind "'+e+'". (FAIL-LOUD.)');return t.fields.filter(function(r){return!!r.derivedFrom}).map(function(r){return{name:r.name,field:r.derivedFrom.field,tuple:r.derivedFrom.tuple,key:r.derivedFrom.key}})},"derivedReads"),defaultPropsFor:o(function(e){var t=Dt(e);return t&&t.defaults?t.defaults:{}},"defaultPropsFor"),normalizeValue:Nu,worldRect:Fu,RECT_TUPLE:qn,rectTupleText:bt,FIELD_TYPES:Ui,CollisionTypes:Ee,CollisionActions:st,FrameDataSchema:or,FieldDescriptorSchema:sn}});var cf={};ge(cf,{Wall:()=>_e});function lf(e,t,r){if(!Aa)return{region:null,broadRect:e};var i=Pa(e),n=Bn(e),a=ka({w:i.w,h:i.h,orientationDeg:t,d:n,pitchDeg:r});if(a.pitched){var s=a.plate3,l=Pa(e),c=e[0]+l.w/2,f=e[1]+l.h/2,u=e[2],h=e[5],g=u+h/2;return{region:null,broadRect:[c-s.aabb.hx,f-s.aabb.hy,g-s.aabb.hz,2*s.aabb.hx,2*s.aabb.hy,2*s.aabb.hz],trueW:l.w,trueH:l.h}}var d=_u(a.obb);if(!d)return{region:null,broadRect:e};var m=xu(a.obb),b=Array.isArray(e)&&e.length===6,y=e[0],w=e[1],x=y+i.w/2,S=w+i.h/2,A;if(b){var T=e[2],j=e[5];A=[x-m.hx,S-m.hy,T,2*m.hx,2*m.hy,j]}else A=[x-m.hx,S-m.hy,2*m.hx,2*m.hy];return{region:d,broadRect:A,trueW:i.w,trueH:i.h}}function r0(e){var t=["z","d","depth"].filter(function(a){return e[a]!==void 0});if(t.length&&e.rect&&(Array.isArray(e.rect)?e.rect.length===6:e.rect.z!==void 0||e.rect.d!==void 0))throw new Error("[Wall] rect is already the z/depth form "+bt(6)+" and the props also give "+t.join(", ")+" \u2014 write the z-slab ONE way: the 6-element rect, or a 4-element rect beside z/depth. (FAIL-LOUD.)");if(e.rect&&!Array.isArray(e.rect)&&e.rect.left!==void 0&&e.rect.w!==void 0){var r=e.rect,i=r.z!==void 0||r.d!==void 0?[r.left,r.top,r.z!==void 0?r.z:0,r.w,r.h,r.d!==void 0?r.d:r.w]:[r.left,r.top,r.w,r.h];e=Object.assign({},e,{rect:i})}if(e.rect){if(Array.isArray(e.rect)&&e.rect.length===4&&(e.depth!==void 0||e.z!==void 0)){var n=e.rect;return[n[0],n[1],e.z!==void 0?e.z:0,n[2],n[3],e.depth!==void 0?e.depth:n[2]]}return e.rect}return e.z!==void 0||e.d!==void 0||e.depth!==void 0?[e.left,e.top,e.z!==void 0?e.z:0,e.w,e.h,e.depth!==void 0?e.depth:e.d!==void 0?e.d:e.w]:[e.left,e.top,e.w,e.h]}function Pa(e){return Array.isArray(e)&&e.length===6?{w:e[3],h:e[4]}:Array.isArray(e)?{w:e[2],h:e[3]}:{w:e.w,h:e.h}}function i0(e){return Array.isArray(e)&&e.length===6&&typeof e[5]=="number"&&e[5]>0}function Bn(e){return Array.isArray(e)&&e.length===6?e[5]:0}function n0(e,t,r){var i=r.collisionBehavior;e.collisionBehavior=i,e.bounceDirection=r.bounceDirection||(i==="bounce"?"reflect":void 0),e.angleConstraint=r.angleConstraint,e.decoherence=!!r.decoherence,e.hooks=Array.isArray(r.hooks)?r.hooks.slice():[],e.markTag=r.markTag,e.countFilter=r.countFilter,e.capacity=typeof r.capacity=="number"?r.capacity:64,e.emissivity=typeof r.emissivity=="number"?r.emissivity:void 0,e.orientationDeg=typeof r.orientationDeg=="number"?r.orientationDeg:0,e.pitchDeg=typeof r.pitchDeg=="number"?r.pitchDeg:0;var n=r0(r),a=r.name||"wall";e.name=a;var s=i0(n),l=r.reposition||(s?"closest3d":"closest"),c=r.layer,f=c!=null?[c]:null,u=Pa(n),h=sf({collisionBehavior:i,bounceDirection:e.bounceDirection,angleConstraint:e.angleConstraint,decoherence:e.decoherence,hooks:e.hooks,markTag:e.markTag,capacity:e.capacity,emissivity:e.emissivity,color:r.color,orientationDeg:e.orientationDeg,reposition:l,is3D:s,slabW:u.w,slabH:u.h,pitchDeg:e.pitchDeg,slabD:Bn(n)}),g=r.collectCollided!==void 0?!!r.collectCollided:!!h.collectCollided;e._collectCollided=g,e._radiation=h.radiation,e._trueRect=n;var d=lf(n,e.orientationDeg,e.pitchDeg);e.lo=new Se(t,n,"NONE",[],a,l,f,1,r.color,g),e.lo._owner=e,e.lo.orientationDeg=e.orientationDeg,e.pitchDeg&&(e.lo.pitchDeg=e.pitchDeg),s&&(e.lo.depth=Bn(n)),e.is3D=s,h.program&&t&&typeof t.updateObjectProperty=="function"&&t.updateObjectProperty(e.lo.handle,"LargeObject","program",h.program),e.lo.program=h.program||null,e._program=e.lo.program;var m=d.region;if(t&&typeof t.updateObjectProperty=="function"&&(t.updateObjectProperty(e.lo.handle,"LargeObject","region",m),d.broadRect!==n&&t.updateObjectProperty(e.lo.handle,"LargeObject","rect",d.broadRect)),e.lo.region=m,r.alpha!==void 0&&(e.lo.alpha=r.alpha),r.visible!==void 0&&(e.lo.visible=r.visible),r.shellShape!==void 0&&(e.lo.shellShape=r.shellShape),e._radiationTickFn=null,e._backing=null,i==="absorb"&&Fo){var b=Yu(t,e.lo.handle,n,e.capacity);e._backing=b;var y=Ju({universe:t,loHandle:e.lo.handle,backingQid:b.backingQid,capacity:b.capacity,rect:n,emissivity:h.radiation&&h.radiation.emissivity});e._radiationTickFn=y,e.emissivity=y.emissivity(),t&&Array.isArray(t.experimentTickFunctions)&&t.experimentTickFunctions.push(y)}e._combined=new Map,e._grid=new Map,e._total=0,e._lastTickData=void 0}function _e(e,t){if(t=t||{},this.universe=e,this._schemaKind=this.constructor.name,t.preset){var r=Md(t.preset),i={};Object.keys(t).forEach(function(n){n!=="preset"&&(i[n]=t[n])}),Object.keys(r).forEach(function(n){i[n]===void 0&&(i[n]=r[n])}),t=i}if(t.wallBehavior!==void 0)throw new Error("[Wall] `wallBehavior` is deleted \u2014 use `collisionBehavior`: block \u2192 collisionBehavior:'block'; reflect \u2192 collisionBehavior:'bounce', bounceDirection:'reflect'; absorb (plain kill) \u2192 collisionBehavior:'destroy'; detect \u2192 collisionBehavior:'destroy', hooks:['count'] (= preset 'detector-screen'). Note collisionBehavior:'absorb' is the RADIATING absorber, NOT the old plain kill.");if(t.collisionType!==void 0)throw new Error("[Wall] the `collisionType` override is deleted \u2014 a wall's collision mechanics ARE its compiled op-program (collisionBehavior + bounceDirection + hooks).");if(t.collisionBehavior===void 0)throw new Error("[Wall] `collisionBehavior` is REQUIRED \u2014 one of nothing|block|bounce|absorb|destroy (or pass a `preset`).");return n0(this,e,t)}var sf,Md,a0,wi=ue(()=>{At();_r();Io();Vt();Qu();sl();xt();ln();bi();Io();sf=Hu;Md=Ku;o(lf,"_slabGeometryForWall");o(r0,"_rectFromOpts");o(Pa,"_rectWH");o(i0,"_rectIs3D");o(Bn,"_rectDepth");o(n0,"_constructV2");o(_e,"Wall");Object.defineProperty(_e.prototype,"rect",{get:o(function(){return this.lo?this.lo.rect:void 0},"get")});Object.defineProperty(_e.prototype,"handle",{get:o(function(){return this.lo?this.lo.handle:void 0},"get")});Object.defineProperty(_e.prototype,"color",{get:o(function(){return this.lo?this.lo.color:void 0},"get")});Object.defineProperty(_e.prototype,"alpha",{get:o(function(){return this.lo?this.lo.alpha:void 0},"get")});Object.defineProperty(_e.prototype,"visible",{get:o(function(){return this.lo?this.lo.visible:void 0},"get")});Object.defineProperty(_e.prototype,"layer",{get:o(function(){return this.lo?this.lo.layer:void 0},"get")});Object.defineProperty(_e.prototype,"reposition",{get:o(function(){return this.lo?this.lo.reposition:void 0},"get")});Object.defineProperty(_e.prototype,"shellShape",{get:o(function(){return this.lo?this.lo.shellShape:void 0},"get")});Object.defineProperty(_e.prototype,"depth",{get:o(function(){return this.lo&&this.lo.rect&&typeof this.lo.rect.d=="number"?this.lo.rect.d:0},"get")});Object.defineProperty(_e.prototype,"z",{get:o(function(){return this.lo&&this.lo.rect&&typeof this.lo.rect.z=="number"?this.lo.rect.z:0},"get")});_e.prototype.getOrientation=function(){return typeof this.orientationDeg=="number"?this.orientationDeg:0};_e.prototype.setOrientation=function(e){if(this.collisionBehavior===void 0)throw new Error("[Wall.setOrientation] this wall has no collisionBehavior, so it has no compiled op-program to re-aim \u2014 a Wall is built only through the v2 lexicon (new Wall(universe, { collisionBehavior | preset })); an object without one was not built by Wall. (FAIL-LOUD.)");var t=(e%360+360)%360;return this.setV2Prop("orientationDeg",t),this};_e.prototype.setRect=function(e){if(!Array.isArray(e)||e.length!==4&&e.length!==6||!e.every(function(f){return typeof f=="number"&&isFinite(f)}))throw new TypeError("[Wall.setRect] rect must be [l,t,w,h] or [l,t,z,w,h,d] of finite numbers; got "+JSON.stringify(e)+". (FAIL-LOUD.)");var t=this._trueRect,r=Array.isArray(t)&&t.length===6,i;if(e.length===6){if(!r)throw new Error('[Wall.setRect] "'+this.name+`" was built without a z-slab; a 6-element rect would give it one, but a wall's 3D-ness is compiled into its op-program at construction. Remove + re-add it with z/depth. (FAIL-LOUD.)`);i=e.slice()}else i=r?[e[0],e[1],t[2],e[2],e[3],t[5]]:e.slice();var n=Pa(t),a=Pa(i),s=n.w!==a.w||n.h!==a.h||Bn(t)!==Bn(i);s&&this.assertOwnsProgram(),this._trueRect=i;var l=this.lo.rect;if(l.w=a.w,l.h=a.h,r&&(l.z=i[2],l.d=i[5]),l.left=i[0],l.top=i[1],this.is3D&&(this.lo.depth=Bn(i)),s)this._rebake();else if(this.universe&&typeof this.universe.updateObjectProperty=="function"){var c=lf(i,this.orientationDeg,this.pitchDeg);this.universe.updateObjectProperty(this.lo.handle,"LargeObject","rect",c.broadRect)}return this._radiationTickFn&&this._radiationTickFn.setRect(i),this};_e.prototype.setPitch=function(e){return this.setV2Prop("pitchDeg",e),this};_e.prototype.setV2Prop=function(e,t){if(e==="emissivity"){if(this.collisionBehavior!=="absorb"||!this._radiationTickFn)throw new Error('[Wall.setV2Prop] emissivity is a RADIATOR knob and this wall is not an ABSORB wall (collisionBehavior "'+this.collisionBehavior+'").');return this.emissivity=this._radiationTickFn.setEmissivity(t),this}return this._rebake(e,t)};_e.prototype._rebake=function(e,t){this.assertOwnsProgram();var r=e==="collisionBehavior"?t:this.collisionBehavior,i=this.collisionBehavior==="absorb",n=r==="absorb";if(i!==n)throw new Error("[Wall.setV2Prop] cannot live-switch "+(n?"INTO":"out of")+" the radiating ABSORB behavior \u2014 its backing frame + radiation tick-fn are attached at construction. Remove + re-add the wall as absorb.");var a=e==="hooks"?Array.isArray(t)?t.slice():[]:this.hooks,s=Pa(this._trueRect),l=sf({collisionBehavior:r,bounceDirection:e==="bounceDirection"?t:this.bounceDirection,angleConstraint:this.angleConstraint,decoherence:e==="decoherence"?!!t:this.decoherence,hooks:a,markTag:e==="markTag"?t:this.markTag,capacity:e==="capacity"?t:this.capacity,orientationDeg:e==="orientationDeg"?t:this.orientationDeg,pitchDeg:e==="pitchDeg"?t:this.pitchDeg,slabD:Bn(this._trueRect),reposition:this.lo.reposition,is3D:this.is3D===!0,slabW:s.w,slabH:s.h});if(l.collectCollided&&!this._collectCollided)throw new Error("[Wall.setV2Prop] cannot live-enable collection (mark/count) on a wall not registered to collect_collided \u2014 construct it with the hook, or remove + re-add it.");e==="hooks"?this.hooks=a:e==="decoherence"?this.decoherence=!!t:e!==void 0&&(this[e]=t),e==="orientationDeg"&&this.lo&&(this.lo.orientationDeg=t),e==="pitchDeg"&&this.lo&&(this.lo.pitchDeg=t),this.universe&&typeof this.universe.updateObjectProperty=="function"&&this.universe.updateObjectProperty(this.lo.handle,"LargeObject","program",l.program||null),this.lo.program=l.program||null;var c=lf(this._trueRect,this.orientationDeg,this.pitchDeg);return this.universe&&typeof this.universe.updateObjectProperty=="function"&&(this.universe.updateObjectProperty(this.lo.handle,"LargeObject","region",c.region),this.universe.updateObjectProperty(this.lo.handle,"LargeObject","rect",c.broadRect)),this.lo.region=c.region,this._program=this.lo.program,this};_e.prototype.assertOwnsProgram=function(){if(this.lo&&this.lo.program!==this._program)throw new Error('[Wall] "'+this.name+'": its LargeObject carries an op-program another part pushed ('+(this._owner?"owned by "+(this._owner.name||"its composite"):"not baked by this wall")+"). Re-baking it here would silently replace that part's physics \u2014 the owning part must re-apply it. (FAIL-LOUD.)")};_e.prototype.getCollisionHistogram=function(e){var t=Array.isArray(this.hooks)&&this.hooks.indexOf("count")!==-1;if(!t)throw new Error('[Wall.getCollisionHistogram] this wall does not COUNT (collisionBehavior "'+this.collisionBehavior+'", hooks '+JSON.stringify(this.hooks||[])+") \u2014 only a wall carrying the `count` hook collects collided frames (preset 'detector-screen' for a counting screen, 'transparent-probe' for a pass-through population probe).");if(e!=null&&e===this._lastTickData)throw new Error("[Wall.getCollisionHistogram] called twice with the SAME TickData object \u2014 each tick must be consumed exactly once. Call universe.doTick() again first.");this._lastTickData=e;for(var r=this.lo.handle,i=e&&e.objects&&e.objects[r]&&Array.isArray(e.objects[r].frames)?e.objects[r].frames:[],n=0;n<i.length;n++){var a=i[n],s;a.rect&&a.rect.top!=null?s=Math.floor(a.rect.top):a.y!=null?s=Math.floor(a.y):s=0;var l=a.z!=null?Math.floor(a.z):0;this._combined.set(s,(this._combined.get(s)||0)+1),_e.gridAdd(this._grid,s,l),this._total++}return{combined:this._combined,grid:this._grid,total:this._total}};_e.gridAdd=function(e,t,r){var i=e.get(t);i||(i=new Map,e.set(t,i)),i.set(r,(i.get(r)||0)+1)};_e.deriveMarginalY=function(e){var t=new Map;return e.forEach(function(r,i){var n=0;r.forEach(function(a){n+=a}),t.set(i,n)}),t};_e.prototype.getLiveCount=function(e){var t=Array.isArray(this.hooks)&&this.hooks.indexOf("count")!==-1;if(!t)throw new Error('[Wall.getLiveCount] this wall does not COUNT (collisionBehavior "'+this.collisionBehavior+'", hooks '+JSON.stringify(this.hooks||[])+") \u2014 only a wall carrying the `count` hook collects collided frames (preset 'detector-screen' for a counting screen, 'transparent-probe' for a pass-through population probe).");if(e!=null){var r=this.lo.handle,i=e.objects&&e.objects[r];this._liveCount=i&&Array.isArray(i.frames)?i.frames.length:0}return this._liveCount||0};_e.prototype.getAbsorbStats=function(){if(this.collisionBehavior!=="absorb"||!this._radiationTickFn)throw new Error('[Wall.getAbsorbStats] this wall is not an ABSORB wall (collisionBehavior "'+this.collisionBehavior+'").');return this._radiationTickFn.stats()};_e.prototype.dispose=function(){if(!this._disposed){this._disposed=!0;var e=this.universe;if(this._radiationTickFn&&e&&Array.isArray(e.experimentTickFunctions)){var t=e.experimentTickFunctions.indexOf(this._radiationTickFn);t!==-1&&e.experimentTickFunctions.splice(t,1)}this.lo&&typeof this.lo.dispose=="function"&&this.lo.dispose()}};_e.prototype.resetHistogram=function(){this._combined=new Map,this._grid=new Map,this._total=0};a0={description:"A rectangular wall/boundary with a single collision behavior: nothing (pass through), block (stop at the surface), bounce (turn around), absorb (kill + tally + radiate), or destroy (plain kill) \u2014 plus the composable mark/count/recolor hooks. The first-class palette face over a LargeObject + actionCompiler op-program \u2014 the ONE wall primitive the composites (SlitScreen, DetectorWall) build on. Zero physics of its own.",ux:{resizable:!0,draggable:{"2d":!0},shellRender:"run"},fields:[{name:"rect",type:"rect",engineVisible:!0,unit:"px",live:!0,description:"Bounding rectangle in physics pixels "+bt(4)+", or the explicit z/depth form "+bt(6)+" \u2014 WASM 3D. The wall's collision search region. Live-editable (drag/resize); routed to the inner LargeObject engine handle."},{name:"orientationDeg",type:"number",constraint:{min:0,max:360},engineVisible:!1,live:!0,widgetHint:"slider",description:"Wall orientation in degrees (default 0; visible always) = the mirror SURFACE angle. A live edit recompiles the op-program: a bounce/reflect mirror bakes the ORIENTATION-AWARE reflection law (standard optics \u2014 a surface at \u03B8 deflects a beam by 2\u03B8, so 45\xB0 turns a +x beam to +y), and a constrained-random wall re-aims its scatter cone. The renderer draws the shell rotated to this angle. Also the LOOK-drive rotation target."},{name:"pitchDeg",type:"number",constraint:{min:-90,max:90},engineVisible:!1,live:!0,widgetHint:"slider",visibleWhen:{field:"depth",truthy:!0},description:"Up/down tilt (degrees, -90..90) about the plate's own long axis \u2014 the second mirror rotation axis (3D walls only). A live edit recompiles the true 3-space reflection about the tipped plate normal: the reflected beam gains a z-component and always leaves on the incident side (never through the mirror). 0 = the flat in-plane mirror (vz passes through)."},{name:"depth",type:"readonly",derivedFrom:{field:"rect",tuple:6,key:"d"},unit:"px",engineVisible:!1,description:"The wall's z-slab depth (z-extent) in physics pixels \u2014 0 for a flat 2D wall. Derived from the 6-element rect "+bt(6)+"; a real depth makes the wall a 3D slab (six-face reflect/eject, box render). Edit via the rect field."},{name:"z",type:"readonly",derivedFrom:{field:"rect",tuple:6,key:"z"},unit:"px",engineVisible:!1,description:"The wall's z placement (near-face \u2026 far-face CENTER) in physics pixels (0 for a 2D wall). Derived from the 6-element rect. Edit via the rect field."},{name:"collisionBehavior",type:"enum",constraint:{values:_l?_l():{}},engineVisible:!1,live:!0,description:"The wall's collision BEHAVIOR (compiled to an op-program; the engine has no wall dispatch): nothing = pass-through; block = STOP the particle at the surface (reposition to the closest position outside the wall, velocity kept \u2014 it parks at the face instead of turning around); bounce = a motion response (see bounceDirection); absorb = tally the colliders' mass into the wall's REAL backing frame + radiate (conserving); destroy = remove the particle. Hooks (mark/count) compose with any behavior."},{name:"bounceDirection",type:"enum",constraint:{values:xl?xl():{}},engineVisible:!1,live:!0,visibleWhen:{field:"collisionBehavior",equals:"bounce"},description:"How a BOUNCE redirects the particle: reflect = invert the velocity on the axis of incidence (a mirror); random = redraw the exit direction (omni by default, or constrained to a cone about the wall's INITIAL orientation). Only shown for bounce."},{name:"decoherence",type:"boolean",engineVisible:!1,live:!0,visibleWhen:[{field:"collisionBehavior",equals:"bounce"},{field:"bounceDirection",equals:"random"}],description:"When a random BOUNCE also resets the wave phase (local_time=0) + re-rolls the charge sign (an independent decoherence toggle). Off by default (direction-only). Only shown for a random bounce."},{name:"hooks",type:"enum-set",constraint:{values:Ol?Ol():{}},engineVisible:!1,live:!0,description:"Composable statistics hooks (any behavior): mark = stamp a user string on each collided frame (engine-transparent); count = tally collisions (filterable by mark). The counting screen is destroy + count."},{name:"markTag",type:"string",engineVisible:!1,visibleWhen:{field:"hooks",includes:"mark"},description:"The user string MARK stamps into each collided frame's string_map (only shown when the mark hook is active)."},{name:"countFilter",type:"string",engineVisible:!1,visibleWhen:{field:"hooks",includes:"count"},description:'Restrict COUNT to frames carrying a specific mark ("any" = count all). Applied by the between-tick stats reader (only shown when the count hook is active).'},{name:"capacity",type:"number",constraint:{min:1,integer:!0},engineVisible:!1,live:!0,visibleWhen:{field:"collisionBehavior",equals:"absorb"},description:"ABSORB mass ceiling (snapped to a leaf level the engine can actually size \u2014 the capacity law runs over the ACTIVE AXES) AND the 1/capacity per-tick radiation probability. How much it holds and how often it gives some back. Only shown for absorb."},{name:"emissivity",type:"number",constraint:{min:.01,max:1},engineVisible:!1,live:!0,visibleWhen:{field:"collisionBehavior",equals:"absorb"},description:"ABSORB radiating efficiency \u2014 the FULLNESS of each re-emitted leaf, as a fraction in (0,1] of that layer's cell capacity (default 0.5). A colour knob, not bookkeeping: fullness IS the move gate and sets the wavelength, so 1.0 re-emits at light speed with the shortest \u03BB and 0.5 at half the step rate with twice the \u03BB. The emitted leaf's SCALE is not a knob \u2014 the wall re-emits at the layer it soaked from. Only shown for absorb."},{name:"name",type:"string",engineVisible:!1,description:"Human-readable identifier (display/debug only)."},{name:"color",type:"rgb",engineVisible:!1,live:!0,description:"Render color [r, g, b] 0-255 (render-only; engine collision unaffected)."},{name:"alpha",type:"number",constraint:{min:0,max:255,integer:!0},engineVisible:!1,live:!0,widgetHint:"slider",description:"Render opacity 0-255 (render-only). 0 = fully transparent, 255 = fully opaque \u2014 a transparent wall still collides, it simply stops obstructing the view."},{name:"visible",type:"boolean",engineVisible:!1,live:!0,description:"Whether the wall is drawn (render-only; collision detection stays active)."},{name:"layer",type:"number",constraint:{min:0,integer:!0},engineVisible:!0,description:"Dimension layer this wall is scoped to (0 = fundamental; null = all layers)."},{name:"shellShape",type:"enum",constraint:{values:Po()},engineVisible:!1,live:!0,description:"Render shape hint of the wall's visual shell (ball|box|circle|cube|sphere; render-only). cube/sphere degrade to box/ball in 2D; absent falls back to a rect."}]};at(_e,{from:new URL("frqtl/parts/Wall.js",ze()).href,descriptor:a0,defaults:{preset:"wall",w:12,h:120,color:[150,150,160]},palette:{displayName:"Wall",category:"boundary",iconHint:"wall",rank:1},build:o(function(e,t,r){var i=r,n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a]);if(n.rect==null&&n.left==null){var s=n.w!=null?n.w:12,l=n.h!=null?n.h:120;n.left=Math.round(t.x-s/2),n.top=Math.round(t.y-l/2),n.w=s,n.h=l}var c=t.runner&&t.runner.universe;if(t.fromPalette&&c&&c.activeAxes&&c.activeAxes.z&&n.z===void 0&&n.d===void 0&&n.depth===void 0&&!(n.rect&&(Array.isArray(n.rect)?n.rect.length===6:n.rect.z!==void 0||n.rect.d!==void 0))){var f=t.runner&&t.runner.worldBounds;if(!f||typeof f.near!="number"||typeof f.d!="number")throw new Error('[ObjectFactory] create("Wall"): a 3D palette drop derives its z-slab from the scene bounds (runner.worldBounds \u2014 the TickData boundary_rect ferry / init-time initBounds read-back), but the runner publishes none. (FAIL-LOUD \u2014 a depth-less wall in a 3D scene is the z-leak this default repairs.)');n.z=f.near,n.depth=f.d}t.fromPalette&&n.name==null&&(n.name="wall "+(t.runner.largeObjects.length+1));var u=new i(t.runner.universe,n);return u._schemaKind=r.name,u},"build")})});var ff={};ge(ff,{DetectorWall:()=>_i});function _i(e,t,r,i,n,a,s,l,c,f){f=f||{};var u=f.depth!==void 0&&f.depth!==null?f.depth:null;this.universe=e,this._schemaKind=this.constructor.name;var h=Be.worldRect(t,"DetectorWall canvasRect"),g=h.w,d=h.h;if(r=r??g-20,i=i??0,n!=null&&n!==Ee.NONE)throw new Error('[DetectorWall] the wallCollisionType override is retired ("'+n+`") \u2014 the counting atom is Wall{collisionBehavior:'destroy', hooks:['count']} and its mechanics are the compiled op-program. Pass NONE (or omit the argument).`);a=a||[120,120,120],s=s??d,l=l??20,c=c||"detector_wall"+Math.floor(Math.random()*1e6),this.wallX=r,this._wallHeight=s,this.depth=u;var m=u!==null?[r,i,-u/2,l,s,u]:[r,i,l,s];this.name=c,this._innerWall=new _e(e,{rect:m,collisionBehavior:"destroy",hooks:["count"],name:c,color:a}),this.detector_wall=this._innerWall.lo,this._innerWall._owner=this,this.detector_wall.rect.d!==void 0&&(this.detector_wall.shape="box",this.detector_wall.depth=this.detector_wall.rect.d),this._combined=new Map,this._slit1=new Map,this._slit2=new Map,this._total=0,this._slit1Total=0,this._slit2Total=0,this._grid=new Map,this._gridSlit1=new Map,this._gridSlit2=new Map,this._lastTickData=void 0}function uf(e,t,r){_e.gridAdd(e,t,r)}var o0,hf=ue(()=>{At();_r();Vt();ti();wi();ul();bi();xt();o(_i,"DetectorWall");o(uf,"_gridAdd");_i.deriveMarginalY=function(e){return _e.deriveMarginalY(e)};Object.defineProperty(_i.prototype,"x",{get:o(function(){return this.wallX},"get"),set:o(function(e){this.wallX=e},"set")});_i.prototype.getCollisionHistogram=function(e){if(e!=null&&e===this._lastTickData)throw new Error("[DetectorWall] getCollisionHistogram() called twice with the SAME TickData object \u2014 each tick must be consumed exactly once, or its collisions are counted twice. Call universe.doTick() again before re-consuming.");this._lastTickData=e;for(var t=this.detector_wall.handle,r=e&&e.objects&&e.objects[t]&&Array.isArray(e.objects[t].frames)?e.objects[t].frames:[],i=0;i<r.length;i++){var n=r[i],a;n.rect&&n.rect.top!=null?a=Math.floor(n.rect.top):n.y!=null?a=Math.floor(n.y):a=0;var s=n.z!=null?Math.floor(n.z):0,l=Su(n)||null;this._combined.set(a,(this._combined.get(a)||0)+1),this._total++,l==="slit2"?(this._slit2.set(a,(this._slit2.get(a)||0)+1),this._slit2Total++):l==="slit1"&&(this._slit1.set(a,(this._slit1.get(a)||0)+1),this._slit1Total++),uf(this._grid,a,s),l==="slit2"?uf(this._gridSlit2,a,s):l==="slit1"&&uf(this._gridSlit1,a,s)}return{combined:this._combined,slit1:this._slit1,slit2:this._slit2,total:this._total,slit1Total:this._slit1Total,slit2Total:this._slit2Total,grid:this._grid,gridSlit1:this._gridSlit1,gridSlit2:this._gridSlit2}};_i.prototype.dispose=function(){this._innerWall.dispose()};_i.prototype.resetHistogram=function(){this._combined=new Map,this._slit1=new Map,this._slit2=new Map,this._total=0,this._slit1Total=0,this._slit2Total=0,this._grid=new Map,this._gridSlit1=new Map,this._gridSlit2=new Map};o0={description:"A detector/absorber screen that counts and removes particles on contact. Used as the observation screen in quantum experiments (e.g. double-slit). Wraps a single LargeObject with COUNT+ABSORB actions. Accumulates a collision histogram (y-position \u2192 count) for interference pattern analysis.",fields:[{name:"wallX",type:"number",constraint:{integer:!0},engineVisible:!0,description:"Left edge X position (physics pixels)"},{name:"wallY",type:"number",constraint:{integer:!0},engineVisible:!0,description:"Top edge Y position (physics pixels)"},{name:"wallCollisionType",type:"enum",constraint:{values:Ee},engineVisible:!0,description:"Collision type for the detector wall. Default NONE \u2014 absorption is via the ABSORB action in its actions list, not the collision type."},{name:"wallColor",type:"rgb",engineVisible:!1,description:"Render color [r, g, b] of the detector wall"},{name:"wallHeight",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Height of the detector wall (physics pixels). Typically the full canvas height."},{name:"wallWidth",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Width/thickness of the detector wall (physics pixels). Default 20."},{name:"wallName",type:"string",engineVisible:!1,description:"Identifier string for this detector (display/debug only; not engine-visible after construction)."}]};at(_i,{from:new URL("frqtl/parts/DetectorWall.js",ze()).href,descriptor:o0,defaults:{wallX:180,wallY:0,wallCollisionType:"NONE",wallColor:[120,120,120],wallHeight:200,wallWidth:20},build:o(function(e,t,r){var i=r,n=Be.worldRect(t.runner.canvas_rect,'ObjectFactory create("DetectorWall") runner.canvas_rect'),a=n.w,s=n.h,l=new i(t.runner.universe,{w:a,h:s},e.wallX!=null?e.wallX:Math.round(t.x),e.wallY!=null?e.wallY:0,e.wallCollisionType||"NONE",e.wallColor||[120,200,120],e.wallHeight||s,e.wallWidth||20,e.wallName||"detector "+Date.now());if(!l.detector_wall)throw new Error('[ObjectFactory] create("DetectorWall"): the DetectorWall was constructed but exposes no `detector_wall` (the registered inner LargeObject this kind hands back) \u2014 nothing placeable was built. (FAIL-LOUD.)');return l._schemaKind=r.name,l},"build")})});var Al={};ge(Al,{installRpcResponder:()=>l0,makeChannelRpc:()=>s0,makeInAppRpc:()=>pf,makeWindowPostMessageChannel:()=>c0});function pf(e){if(typeof e!="function")throw new Error("[shim/rpc] makeInAppRpc requires a dispatch function. (FAIL-LOUD.)");return{call:o(function(t,r){try{return Promise.resolve(e(t,r))}catch(i){return Promise.reject(i)}},"call"),dispose:o(function(){},"dispose")}}function s0(e,t){if(t=t||{},!e||typeof e.post!="function"||typeof e.subscribe!="function")throw new Error("[shim/rpc] makeChannelRpc requires a channel with post/subscribe. (FAIL-LOUD.)");var r=t.tag;if(!r)throw new Error("[shim/rpc] makeChannelRpc requires opts.tag (a unique namespace so multiple RPC users sharing one postMessage bus never collide). (FAIL-LOUD.)");var i=typeof t.callTimeoutMs=="number"&&t.callTimeoutMs>0?t.callTimeoutMs:3e3,n=Object.create(null),a=0,s=e.subscribe(function(l){if(!(!l||l.__rpcTag!==r||l.type!=="rpc:result")){var c=n[l.reqId];c&&(delete n[l.reqId],l.error?c.reject(new Error("[shim/rpc] remote: "+l.error)):c.resolve(l.value))}});return{call:o(function(l,c){return new Promise(function(f,u){var h=++a,g=setTimeout(function(){n[h]&&(delete n[h],u(new Error('[shim/rpc] "'+l+'" timed out after '+i+'ms (tag "'+r+'"). No responder installed on the other side? (installRpcResponder)')))},i);n[h]={resolve:o(function(d){clearTimeout(g),f(d)},"resolve"),reject:o(function(d){clearTimeout(g),u(d)},"reject")},e.post({__rpcTag:r,type:"rpc:call",reqId:h,fn:l,args:c})})},"call"),dispose:o(function(){typeof s=="function"&&s()},"dispose")}}function l0(e,t,r){if(r=r||{},!e||typeof e.post!="function"||typeof e.subscribe!="function")throw new Error("[shim/rpc] installRpcResponder requires a channel with post/subscribe. (FAIL-LOUD.)");if(typeof t!="function")throw new Error("[shim/rpc] installRpcResponder requires a dispatch function. (FAIL-LOUD.)");var i=r.tag;if(!i)throw new Error("[shim/rpc] installRpcResponder requires opts.tag. (FAIL-LOUD.)");return e.subscribe(function(n){if(!(!n||n.__rpcTag!==i||n.type!=="rpc:call")){var a=n.reqId;Promise.resolve().then(function(){return t(n.fn,n.args)}).then(function(s){e.post({__rpcTag:i,type:"rpc:result",reqId:a,value:s})},function(s){e.post({__rpcTag:i,type:"rpc:result",reqId:a,error:s&&s.message?s.message:String(s)})})}})}function c0(e,t){t=t||{};var r=t.selfWindow||(typeof window<"u"?window:null);if(!e)throw new Error("[shim/rpc] makeWindowPostMessageChannel requires targetWindow. (FAIL-LOUD.)");if(!r)throw new Error("[shim/rpc] makeWindowPostMessageChannel requires a self window (pass opts.selfWindow outside a browser). (FAIL-LOUD.)");return{post:o(function(i){e.postMessage(i,"*")},"post"),subscribe:o(function(i){var n=o(function(a){a.source===e&&i(a.data)},"listener");return r.addEventListener("message",n),function(){r.removeEventListener("message",n)}},"subscribe")}}var Ud=ue(()=>{o(pf,"makeInAppRpc");o(s0,"makeChannelRpc");o(l0,"installRpcResponder");o(c0,"makeWindowPostMessageChannel")});function ii(e){return typeof e=="function"}function cn(e){return typeof e=="number"&&isFinite(e)}function xr(e){return typeof e=="string"&&e.length>0}function Wn(e){return Array.isArray(e)}function _0(e){return typeof e=="boolean"}function je(e,t,r){throw new Error('[lib/shim/controls] normalizeControlDescriptor(id="'+String(e)+'", kind="'+String(t)+'"): '+r+" (FAIL-LOUD \u2014 throw-or-apply, never silently dropped/defaulted-around).")}function x0(e,t,r){(!r||typeof r!="object")&&je(e,t,'"bind" must be an object {'+mf.join(", ")+"} when present.");for(var i=0;i<mf.length;i++){var n=mf[i];xr(r[n])||je(e,t,'"bind.'+n+'" must be a non-empty string.')}}function zo(e,t,r){var i=r.onChange!==void 0,n=r.bind!==void 0;!i&&!n&&je(e,t,'"onChange" or "bind" is required \u2014 at least ONE write path must be declared (a control with neither is a dead control). Supply onChange (a function) and/or bind ({object,prop}).'),i&&!ii(r.onChange)&&je(e,t,'"onChange", when present, must be a function(value)->void.'),n&&x0(e,t,r.bind)}function O0(e,t){xr(t.label)||je(e,"scalar",'"label" must be a non-empty string.'),cn(t.min)||je(e,"scalar",'"min" must be a finite number.'),cn(t.max)||je(e,"scalar",'"max" must be a finite number.'),cn(t.step)||je(e,"scalar",'"step" must be a finite number.'),(typeof t.value!="number"||!isFinite(t.value))&&je(e,"scalar",'"value" must be a finite number.'),ii(t.fmt)||je(e,"scalar",'"fmt" must be a function(value)->string.'),zo(e,"scalar",t)}function E0(e,t){xr(t.label)||je(e,"enum",'"label" must be a non-empty string.'),(!Wn(t.values)||t.values.length===0||!t.values.every(xr))&&je(e,"enum",'"values" must be a non-empty array of non-empty strings.'),xr(t.value)||je(e,"enum",'"value" must be a non-empty string.'),t.values.indexOf(t.value)===-1&&je(e,"enum",'"value" ("'+t.value+'") must be a member of "values" (['+t.values.join(", ")+"]) \u2014 enum is select-ONE from a closed candidate set."),ii(t.fmt)||je(e,"enum",'"fmt" must be a function(value)->string.'),zo(e,"enum",t)}function S0(e,t){xr(t.label)||je(e,"flags",'"label" must be a non-empty string.'),(!Wn(t.values)||t.values.length===0||!t.values.every(xr))&&je(e,"flags",'"values" must be a non-empty array of non-empty strings.'),(!Wn(t.value)||!t.value.every(xr))&&je(e,"flags",'"value" must be an array of non-empty strings (may be empty \u2014 zero flags set).');for(var r=0;r<t.value.length;r++)t.values.indexOf(t.value[r])===-1&&je(e,"flags",'"value['+r+']" ("'+t.value[r]+'") must be a member of "values" (['+t.values.join(", ")+"]) \u2014 flags is a SUBSET of the closed candidate set.");ii(t.fmt)||je(e,"flags",'"fmt" must be a function(value)->string.'),zo(e,"flags",t)}function gf(e,t,r,i){cn(r)||Wn(r)&&r.length===i&&r.every(cn)||je(e,"vector",'"'+t+'" must be a finite number (shared across every component) or an array of '+i+' finite number(s) (one per component of "value") \u2014 got '+JSON.stringify(r)+".")}function k0(e,t){xr(t.label)||je(e,"vector",'"label" must be a non-empty string.'),(!Wn(t.value)||t.value.length===0||!t.value.every(cn))&&je(e,"vector",'"value" must be a non-empty array of finite numbers.'),gf(e,"min",t.min,t.value.length),gf(e,"max",t.max,t.value.length),gf(e,"step",t.step,t.value.length),ii(t.fmt)||je(e,"vector",'"fmt" must be a function(value)->string.'),zo(e,"vector",t)}function A0(e,t){xr(t.label)||je(e,"text",'"label" must be a non-empty string.'),typeof t.value!="string"&&je(e,"text",`"value" must be a string (a text control's value; may be empty).`),ii(t.fmt)||je(e,"text",'"fmt" must be a function(value)->string.'),zo(e,"text",t)}function T0(e,t){xr(t.label)||je(e,"action",'"label" must be a non-empty string.'),(!xr(t.action)||Tl.indexOf(t.action)===-1)&&je(e,"action",'"action" must be one of ['+Tl.join(", ")+"]; got "+JSON.stringify(t.action)+"."),t.bind!==void 0&&je(e,"action",'an action descriptor must NOT declare "bind" \u2014 an action is a VERB, not a property read/write pair (a get() of "'+t.action+'" is meaningless). Execution is objects-side, by action NAME.')}function C0(e,t,r){(!r||typeof r!="object"||Wn(r))&&je(e,t,'"place" must be an object {'+df.join(", ")+"} when present.");for(var i=0;i<df.length;i++){var n=df[i],a=r[n];if(n==="anchor"){a!==void 0&&qd.indexOf(a)===-1&&je(e,t,'"place.anchor" must be one of ['+qd.join(", ")+"] when present; got "+JSON.stringify(a)+".");continue}(!cn(a)||a<0||a>1)&&je(e,t,'"place.'+n+'" must be a number in [0,1] \u2014 a FRACTION of the canvas (resize-stable), not a pixel offset; got '+JSON.stringify(a)+".")}}function j0(e,t){(!Wn(t.presets)||!t.presets.every(xr))&&je(e,"camera",'"presets" must be an array of non-empty strings.'),ii(t.setOrbit)||je(e,"camera",'"setOrbit" must be a function(spec)->void.'),ii(t.getOrbit)||je(e,"camera",'"getOrbit" must be a function()->{azimuth,elevation,distance}.'),ii(t.setPreset)||je(e,"camera",'"setPreset" must be a function(name)->void.')}function R0(e,t){_0(t.enabled)||je(e,"loop",'"enabled" must be a boolean.'),(!cn(t.ticks)||t.ticks<=0)&&je(e,"loop",'"ticks" must be a positive finite number.'),ii(t.setEnabled)||je(e,"loop",'"setEnabled" must be a function(boolean)->void.'),ii(t.setTicks)||je(e,"loop",'"setTicks" must be a function(number)->void.')}function Bd(e){if(!e||typeof e!="object")throw new Error("[lib/shim/controls] normalizeControlDescriptor requires a descriptor object; got "+(e===null?"null":typeof e)+". (FAIL-LOUD.)");var t=e.kind;if(zd.indexOf(t)===-1)throw new Error('[lib/shim/controls] normalizeControlDescriptor: unknown kind "'+String(t)+'" (expect one of ['+zd.join(", ")+"]). (FAIL-LOUD.)");var r=e.id;xr(r)||je(r,t,'"id" must be a non-empty string (every kind requires one \u2014 the registry addressing key).');var i=e.channel;i!==void 0&&Vd.indexOf(i)===-1&&je(r,t,'"channel" must be one of ['+Vd.join(", ")+'] when present; got "'+String(i)+'".'),e.widget!==void 0&&Cl.indexOf(e.widget)===-1&&je(r,t,'"widget" must be one of ['+Cl.join(", ")+"] when present; got "+JSON.stringify(e.widget)+'. (widget is kind-ORTHOGONAL \u2014 a toggle is a scalar 0/1 with widget:"toggle", never a new kind.)'),e.place!==void 0&&C0(r,t,e.place),D0[t](r,e);var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a]);return n.kind=t,n.id=r,i===void 0?n.channel=h0.indexOf(t)!==-1?f0:void 0:n.channel=i,e.place!==void 0&&(n.place={x:e.place.x,y:e.place.y,anchor:e.place.anchor!==void 0?e.place.anchor:u0}),n}var zd,Tl,df,qd,u0,Cl,Vd,f0,h0,p0,d0,m0,g0,v0,y0,b0,w0,KE,mf,D0,jl=ue(()=>{zd=Object.freeze(["scalar","camera","loop","enum","flags","vector","text","action"]),Tl=Object.freeze(["pause","resume","toggle","restart"]),df=Object.freeze(["x","y","anchor"]),qd=Object.freeze(["top-left","top-right","bottom-left","bottom-right"]),u0="top-left",Cl=Object.freeze(["slider","toggle","checkbox","text","button"]),Vd=Object.freeze(["physics","render"]),f0="physics",h0=Object.freeze(["scalar","enum","flags","vector","text"]),p0=Object.freeze(["label","min","max","step","value","fmt","onChange"]),d0=Object.freeze(["presets","setOrbit","getOrbit","setPreset"]),m0=Object.freeze(["enabled","ticks","setEnabled","setTicks"]),g0=Object.freeze(["label","values","value","fmt","onChange"]),v0=Object.freeze(["label","values","value","fmt","onChange"]),y0=Object.freeze(["label","value","min","max","step","fmt","onChange"]),b0=Object.freeze(["label","value","fmt","onChange"]),w0=Object.freeze(["label","action"]),KE=Object.freeze({scalar:p0,camera:d0,loop:m0,enum:g0,flags:v0,vector:y0,text:b0,action:w0}),mf=Object.freeze(["object","prop"]);o(ii,"_isFn");o(cn,"_isNum");o(xr,"_isStr");o(Wn,"_isArr");o(_0,"_isBool");o(je,"_fail");o(x0,"_validateBind");o(zo,"_validateWriteAuthority");o(O0,"_validateScalar");o(E0,"_validateEnum");o(S0,"_validateFlags");o(gf,"_validateVectorBound");o(k0,"_validateVector");o(A0,"_validateText");o(T0,"_validateAction");o(C0,"_validatePlace");o(j0,"_validateCamera");o(R0,"_validateLoop");D0={scalar:O0,camera:j0,loop:R0,enum:E0,flags:S0,vector:k0,text:A0,action:T0};o(Bd,"normalizeControlDescriptor")});function L0(e,t){if(t=t||{},!e)throw new Error("[frqtl-control-slider] mount requires a host element. (FAIL-LOUD.)");var r,i;if(t.descriptor){var n=t.descriptor;if(!n.id||typeof n.min!="number"||typeof n.max!="number"||typeof n.step!="number")throw new Error("[frqtl-control-slider] mount({descriptor}) requires a normalized scalar descriptor with id/min/max/step. (FAIL-LOUD.)");if(typeof n.onChange!="function"&&n.bind)throw new Error('[frqtl-control-slider] mount({descriptor}) was given a bind-only descriptor (id "'+n.id+`", no onChange) \u2014 the standalone opts.descriptor path has no bind-execution context and cannot write it. Use frqtl-controls-panel.js's mount() instead, or mount this widget via opts.initial + opts.onInput with onInput calling the panel's dispatch/RPC. (FAIL-LOUD \u2014 never a silent no-op on drag.)`);r={id:n.id,label:n.label,min:n.min,max:n.max,step:n.step,value:n.value,valueText:typeof n.fmt=="function"?n.fmt(n.value):String(n.value)},i=o(function(u){return n.value=u,typeof n.onChange=="function"&&n.onChange(u),{value:u,valueText:typeof n.fmt=="function"?n.fmt(u):String(u)}},"onInput")}else{if(!t.initial||typeof t.onInput!="function")throw new Error("[frqtl-control-slider] mount requires EITHER opts.descriptor OR BOTH opts.initial and opts.onInput. (FAIL-LOUD.)");r=t.initial,i=t.onInput}var a=document.createElement("div");a.className="frqtl-control-slider-row",a.style.cssText="display:flex;align-items:center;gap:8px;margin:4px 0;font:12px sans-serif;color:#ccc;";var s=document.createElement("span");s.textContent=r.label+":",s.style.cssText="min-width:56px;";var l=document.createElement("input");l.type="range",l.min=r.min,l.max=r.max,l.step=r.step,l.value=r.value,l.setAttribute("data-frqtl-control-id",r.id);var c=document.createElement("span");c.textContent=r.valueText,c.style.cssText="min-width:32px;text-align:right;color:#ffb450;",l.addEventListener("input",function(){var u=parseFloat(l.value);Promise.resolve(i(u)).then(function(h){h&&h.valueText!==void 0&&(c.textContent=h.valueText)}).catch(function(h){c.textContent="ERR",typeof console<"u"&&console.error&&console.error("[frqtl-control-slider] onInput failed:",h)})}),a.appendChild(s),a.appendChild(l),a.appendChild(c),e.appendChild(a);var f=t.descriptor&&typeof t.descriptor.fmt=="function"?t.descriptor.fmt:function(u){return String(u)};return{dispose:o(function(){a.parentNode&&a.parentNode.removeChild(a)},"dispose"),setValue:o(function(u,h){l.value=u,c.textContent=h!==void 0?h:f(u)},"setValue")}}var Wd,Gd=ue(()=>{o(L0,"mount");Wd={mount:L0}});function Kd(e){var t=Cl;if(e&&e.widget){if(t.indexOf(e.widget)===-1)throw new Error('[frqtl-control-widgets] unknown widget "'+e.widget+'" on control "'+(e.id||"?")+'" \u2014 must be one of ['+t.join(", ")+"]. (FAIL-LOUD.)");return e.widget}return e&&Hd[e.kind]||"slider"}function yf(){var e=document.createElement("div");return e.className="frqtl-control-widget-row",e.style.cssText="display:flex;align-items:center;gap:8px;margin:4px 0;font:12px sans-serif;color:#ccc;",e}function Yd(e){var t=document.createElement("span");return t.textContent=e,t.style.cssText="min-width:56px;",t}function bf(e,t,r){Promise.resolve(e).then(t).catch(function(i){r&&r(i),typeof console<"u"&&console.error&&console.error("[frqtl-control-widgets] control dispatch failed:",i)})}function P0(e,t,r,i){var n=yf(),a=document.createElement("input");a.type="checkbox",a.checked=!!Number(t.value),a.setAttribute("data-frqtl-control-id",t.id),i&&(a.style.cssText="width:16px;height:16px;accent-color:#ffb450;");var s=document.createElement("span");return s.textContent=t.valueText!==void 0?t.valueText:String(t.value),s.style.cssText="min-width:32px;text-align:right;color:#ffb450;",a.addEventListener("change",function(){bf(r(a.checked?1:0),function(l){l&&l.valueText!==void 0&&(s.textContent=l.valueText)},function(){s.textContent="ERR"})}),n.appendChild(Yd(t.label+":")),n.appendChild(a),n.appendChild(s),e.appendChild(n),{dispose:o(function(){n.parentNode&&n.parentNode.removeChild(n)},"dispose"),setValue:o(function(l,c){a.checked=!!Number(l),s.textContent=c!==void 0?c:String(l)},"setValue")}}function I0(e,t,r){var i=yf(),n=document.createElement("input");return n.type="text",n.value=t.value!==void 0&&t.value!==null?String(t.value):"",n.setAttribute("data-frqtl-control-id",t.id),n.style.cssText="flex:1;min-width:80px;background:#1b2330;color:#ddd;border:1px solid #33405a;border-radius:3px;padding:2px 4px;font:12px sans-serif;",n.addEventListener("change",function(){bf(r(n.value),function(){})}),i.appendChild(Yd(t.label+":")),i.appendChild(n),e.appendChild(i),{dispose:o(function(){i.parentNode&&i.parentNode.removeChild(i)},"dispose"),setValue:o(function(a){n.value=a==null?"":String(a)},"setValue")}}function F0(e,t,r){var i=yf(),n=document.createElement("button");return n.type="button",n.textContent=t.label,n.setAttribute("data-frqtl-control-id",t.id),n.setAttribute("data-frqtl-control-action",t.action||""),n.style.cssText="background:#26324a;color:#e6edf7;border:1px solid #3d4d6b;border-radius:3px;padding:3px 10px;font:12px sans-serif;cursor:pointer;",n.addEventListener("click",function(){bf(r(t.action),function(){})}),i.appendChild(n),e.appendChild(i),{dispose:o(function(){i.parentNode&&i.parentNode.removeChild(i)},"dispose"),setValue:o(function(){},"setValue")}}function N0(e,t){if(t=t||{},!e)throw new Error("[frqtl-control-widgets] mountWidget requires a host element. (FAIL-LOUD.)");var r=t.initial;if(!r)throw new Error("[frqtl-control-widgets] mountWidget requires opts.initial. (FAIL-LOUD.)");var i=Kd(r);if(i==="button"){if(typeof t.onAction!="function")throw new Error('[frqtl-control-widgets] the "button" widget (control "'+r.id+'") requires opts.onAction. (FAIL-LOUD \u2014 never a dead button.)');return F0(e,r,t.onAction)}if(typeof t.onInput!="function")throw new Error('[frqtl-control-widgets] the "'+i+'" widget (control "'+r.id+'") requires opts.onInput. (FAIL-LOUD.)');if(i==="slider")return Wd.mount(e,{initial:r,onInput:t.onInput});if(i==="toggle"||i==="checkbox")return P0(e,r,t.onInput,i==="toggle");if(i==="text")return I0(e,r,t.onInput);throw new Error('[frqtl-control-widgets] no renderer for widget "'+i+'". (FAIL-LOUD.)')}var Hd,Rl,wf=ue(()=>{jl();Gd();Hd=Object.freeze({scalar:"slider",text:"text",action:"button"});o(Kd,"resolveWidget");o(yf,"_row");o(Yd,"_label");o(bf,"_settle");o(P0,"_mountToggle");o(I0,"_mountText");o(F0,"_mountButton");o(N0,"mountWidget");Rl={WIDGET_BY_KIND:Hd,resolveWidget:Kd,mountWidget:N0}});function M0(e,t,r){if(!e||typeof e!="object"||typeof e.prop!="string"||!e.prop||typeof e.object!="string"||!e.object)throw new Error("[controlBind] resolveBind requires bind = {object, prop} (both non-empty strings) \u2014 got "+JSON.stringify(e)+". (FAIL-LOUD \u2014 this should already have been caught by lib/shim/controls at normalize time; resolveBind re-checks defensively, never as the primary gate.)");t=t||{};var i=r||"physics";if(i==="render")return{set:o(function(f){if(!t.runner)throw new Error('[controlBind] render-channel bind on prop "'+e.prop+'" requires ctx.runner (an FrqtlApp). (FAIL-LOUD.)');t.runner.setRenderOption(e.prop,f)},"set"),get:o(function(){if(t.runner)return t.runner.getRenderOption(e.prop)},"get")};if(e.object==="universe")return{set:o(function(f){if(!t.runner||typeof t.runner.setUniverseProperty!="function")throw new Error('[controlBind] universe bind on "'+e.prop+'" requires ctx.runner (an FrqtlApp with setUniverseProperty). (FAIL-LOUD.)');t.runner.setUniverseProperty(e.prop,f)},"set"),get:o(function(){if(!t.runner||typeof t.runner.getUniverseProperty!="function")throw new Error('[controlBind] universe bind on "'+e.prop+'" requires ctx.runner (an FrqtlApp with getUniverseProperty). (FAIL-LOUD.)');return t.runner.getUniverseProperty(e.prop)},"get")};if(!t.registry||typeof t.registry.getObject!="function"||typeof t.registry.getObjectKind!="function")throw new Error('[controlBind] physics-channel bind on "'+e.object+"."+e.prop+'" requires ctx.registry (a makeControlRegistry() instance with getObject/getObjectKind). (FAIL-LOUD.)');var n=t.registry.getObject(e.object),a=t.registry.getObjectKind(e.object);if(a==="Frame"){var s=n;return{set:o(function(f){if(!t.universe||typeof t.universe.setFrameProperty!="function")throw new Error('[controlBind] Frame bind on "'+e.object+"."+e.prop+'" requires ctx.universe (setFrameProperty). (FAIL-LOUD.)');t.universe.setFrameProperty(s,e.prop,f)},"set"),get:o(function(){if(!t.universe||typeof t.universe.getFrameProperty!="function")throw new Error('[controlBind] Frame bind on "'+e.object+"."+e.prop+'" requires ctx.universe (getFrameProperty). (FAIL-LOUD.)');return t.universe.getFrameProperty(s,e.prop)},"get")}}if(a==="LargeObject"||a==="backdrop"){var l=n,c=n&&typeof n=="object"&&n.handle!==void 0?n.handle:n;return{set:o(function(f){if(!t.runner||typeof t.runner.updateObjectProperty!="function")throw new Error('[controlBind] LargeObject bind on "'+e.object+"."+e.prop+'" requires ctx.runner (an FrqtlApp with updateObjectProperty). (FAIL-LOUD.)');t.runner.updateObjectProperty(l,e.prop,f)},"set"),get:o(function(){if(typeof t.readSnapshot=="function")return t.readSnapshot(c,a,e.prop)},"get")}}throw new Error('[controlBind] bind.object "'+e.object+'" resolved to kind "'+a+`" \u2014 bind execution only supports {Frame, LargeObject, backdrop} (updateObjectProperty's own WASM-ABI dispatch has no real branch for any other kind \u2014 it would validate then silently no-op, which this file refuses to do). (FAIL-LOUD.)`)}var _f,Jd=ue(()=>{o(M0,"resolveBind");_f={resolveBind:M0}});function U0(e,t){var r=Tl;if(r.indexOf(e)===-1)throw new Error('[controlAction] unknown action "'+String(e)+'" \u2014 must be one of ['+r.join(", ")+"] (the closed vocabulary owned by lib/shim/controls). (FAIL-LOUD.)");var i=Qd[e],n=t&&t.runner;if(!n)throw new Error('[controlAction] resolveAction("'+e+'") requires ctx.runner (the live FrqtlApp). (FAIL-LOUD \u2014 never a silently dead button.)');if(typeof n[i]!="function")throw new Error('[controlAction] resolveAction("'+e+'"): the runner has no "'+i+'" method \u2014 the action vocabulary and the runner surface have drifted. (FAIL-LOUD.)');return{run:o(function(){return n[i]()},"run")}}var Qd,Xd,Zd=ue(()=>{jl();Qd=Object.freeze({pause:"stop",resume:"start",toggle:"toggle",restart:"restart"});o(U0,"resolveAction");Xd={resolveAction:U0,ACTION_METHODS:Qd}});var Of={};ge(Of,{FrqtlControlsPanel:()=>xi});function xf(e,t,r){if(r=r||[],t==="listControls"){var i=r[0],n=e.getControls(i),a=e._controlBindCtx;return n.map(function(j){if(j.bind&&a){var Q=_f;try{var Y=Q.resolveBind(j.bind,a,j.channel).get();Y!==void 0&&(j.value=Y)}catch(V){typeof console<"u"&&console.warn&&console.warn('[frqtl-controls-panel] listControls: live refresh failed for "'+j.id+'" (kept cached value):',V)}}var H={id:j.id,label:j.label,min:j.min,max:j.max,step:j.step,value:j.value,valueText:typeof j.fmt=="function"?j.fmt(j.value):String(j.value)};return j.kind!==void 0&&(H.kind=j.kind),j.widget!==void 0&&(H.widget=j.widget),j.action!==void 0&&(H.action=j.action),j.values!==void 0&&(H.values=j.values),j.place!==void 0&&(H.place=j.place),H})}if(t==="runControlAction"){for(var s=r[0],l=r[1],c=e.getControls(s),f=null,u=0;u<c.length;u++)if(c[u].id===l){f=c[u];break}if(!f)throw new Error('[frqtl-controls-panel] runControlAction: unknown control id "'+l+'" in "'+s+'" (registered: ['+c.map(function(j){return j.id}).join(", ")+"]). (FAIL-LOUD.)");if(f.kind!=="action")throw new Error('[frqtl-controls-panel] runControlAction("'+l+'"): descriptor kind is "'+f.kind+'", not "action". (FAIL-LOUD.)');var h=e._controlBindCtx||{},g=Xd.resolveAction(f.action,{runner:h.runner}).run();return{action:f.action,done:Promise.resolve(g)}}if(t==="setControlValue"){for(var d=r[0],m=r[1],b=r[2],y=e.getControls(d),w=null,x=0;x<y.length;x++)if(y[x].id===m){w=y[x];break}if(!w)throw new Error('[frqtl-controls-panel] setControlValue: unknown control id "'+m+'" in "'+d+'" (registered: ['+y.map(function(j){return j.id}).join(", ")+"]). (FAIL-LOUD.)");if(w.value=b,typeof w.onChange=="function")w.onChange(b);else if(w.bind){var S=e._controlBindCtx||{},A=_f,T=A.resolveBind(w.bind,S,w.channel);T.set(b)}else throw new Error('[frqtl-controls-panel] setControlValue("'+m+'" in "'+d+'"): descriptor has neither "onChange" nor "bind" \u2014 this should be structurally impossible post-normalize (lib/shim/controls requires at least one). (FAIL-LOUD \u2014 never a silent no-op.)');return{value:b,valueText:typeof w.fmt=="function"?w.fmt(b):String(b)}}throw new Error('[frqtl-controls-panel] unrecognized verb "'+String(t)+'" (expected "listControls", "setControlValue" or "runControlAction"). (FAIL-LOUD.)')}function z0(){return em}function q0(e,t){if(t=t||{},!e||typeof e.getControls!="function")throw new Error("[frqtl-controls-panel] exposeRegistry requires a makeControlRegistry() instance (missing getControls). (FAIL-LOUD.)");if(em=e,e._controlBindCtx={registry:e,universe:t.universe,runner:t.runner,readSnapshot:t.readSnapshot},t.crossFrame!==!1&&!(typeof document>"u")){var r=document.defaultView;if(!(!r||!r.parent||r.parent===r)){var i=Al,n=i.makeWindowPostMessageChannel(r.parent,{selfWindow:r});i.installRpcResponder(n,function(a,s){return xf(e,a,s)},{tag:$d})}}}function V0(e){return pf(function(t,r){return xf(e,t,r)})}function B0(e,t){if(!e||!e.contentWindow)throw new Error('[frqtl-controls-panel] mount({mode:"iframe"}) requires opts.frame \u2014 an <iframe> element with a live contentWindow. (FAIL-LOUD \u2014 missing transport.)');var r=Al,i=r.makeWindowPostMessageChannel(e.contentWindow),n={tag:$d};return typeof t=="number"&&t>0&&(n.callTimeoutMs=t),r.makeChannelRpc(i,n)}function W0(e,t){if(t=t||{},!e)throw new Error("[frqtl-controls-panel] mount requires a host element. (FAIL-LOUD.)");if(!t.name)throw new Error("[frqtl-controls-panel] mount requires opts.name (the registry instance name registered via exposeRegistry). (FAIL-LOUD.)");var r;if(t.mode==="in-app"){if(!t.registry)throw new Error('[frqtl-controls-panel] mount({mode:"in-app"}) requires opts.registry (the SAME registry instance exposeRegistry() was called with). (FAIL-LOUD.)');r=V0(t.registry)}else if(t.mode==="iframe")r=B0(t.frame,t.callTimeoutMs);else throw new Error('[frqtl-controls-panel] mount: opts.mode must be "in-app" or "iframe"; got '+JSON.stringify(t.mode)+". (FAIL-LOUD.)");var i=t.name;e.classList.add("frqtl-controls-panel");function n(s){e.innerHTML="";var l=Rl;s.forEach(function(c){l.mountWidget(e,{initial:c,onInput:o(function(f){return r.call("setControlValue",[i,c.id,f])},"onInput"),onAction:o(function(){return r.call("runControlAction",[i,c.id])},"onAction")})})}o(n,"renderRows");var a=r.call("listControls",[i]).then(function(s){n(s)}).catch(function(s){throw e.textContent='[frqtl-controls-panel] failed to load "'+i+'": '+(s&&s.message?s.message:String(s)),typeof console<"u"&&console.error&&console.error(s),s});return{ready:a,dispose:o(function(){r.dispose(),e.innerHTML=""},"dispose")}}var $d,em,xi,Ia=ue(()=>{Ud();wf();Jd();Zd();$d="frqtl-controls-panel";o(xf,"_dispatchControlsCall");em=null;o(z0,"exposedRegistry");o(q0,"exposeRegistry");o(V0,"_buildInAppHandle");o(B0,"_buildIframeHandle");o(W0,"mount");xi={exposeRegistry:q0,exposedRegistry:z0,mount:W0,dispatch:xf}});function G0(e){return typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16)}function H0(e){if(e=e||{},!e.name)throw new Error("[frqtl-control-sync] makeControlSync requires opts.name. (FAIL-LOUD.)");var t=e.trigger!==void 0?e.trigger:"manual";if(Ef.indexOf(t)===-1)throw new Error("[frqtl-control-sync] opts.trigger must be one of ["+Ef.join(", ")+"]; got "+JSON.stringify(t)+". (FAIL-LOUD.)");var r=!!e.registry,i=!!e.handle;if(r===i)throw new Error("[frqtl-control-sync] makeControlSync requires EXACTLY ONE of opts.registry (in-app pull) or opts.handle (remote RPC pull); got "+(r?"both":"neither")+". (FAIL-LOUD.)");var n=e.name,a=Object.create(null),s=Object.create(null),l=null,c=!1;function f(){return r?Promise.resolve(xi.dispatch(e.registry,"listControls",[n])):e.handle.call("listControls",[n])}o(f,"_rawPull");function u(y,w){if(!y||typeof y!="string")throw new Error("[frqtl-control-sync] register requires a non-empty string id. (FAIL-LOUD.)");if(!w||typeof w.setValue!="function")throw new Error('[frqtl-control-sync] register("'+y+`") requires a widget exposing setValue(value, valueText?) (frqtl-control-slider.js's mount() return). (FAIL-LOUD.)`);return(a[y]=a[y]||[]).push(w),o(function(){var S=a[y];if(S){var A=S.indexOf(w);A!==-1&&S.splice(A,1)}},"unregister")}o(u,"register");function h(){return f().then(function(y){c||y.forEach(function(w){var x=a[w.id];!x||!x.length||s[w.id]!==w.value&&(s[w.id]=w.value,x.forEach(function(S){S.setValue(w.value,w.valueText)}))})})}o(h,"pull");var g=typeof e.devWarnMs=="number"?e.devWarnMs:3e3,d=null;(t==="tick"||t==="pause")&&(d=setTimeout(function(){d=null,typeof console<"u"&&console.warn&&console.warn('[frqtl-control-sync] trigger:"'+t+'" was declared for "'+n+'" but notify("'+t+'") was never called within '+g+"ms \u2014 did the page forget its one-line `sync.notify('"+t+"')` call (inside its own onTick or pause handler)? (DEV-WARN \u2014 an un-notified sync is inert, not broken.)")},g));function m(y){t!=="manual"&&y===t&&(d&&(clearTimeout(d),d=null),l===null&&(l=G0(function(){l=null,!c&&h()})))}o(m,"notify");function b(){c=!0,d&&(clearTimeout(d),d=null),a=Object.create(null)}return o(b,"dispose"),{register:u,pull:h,notify:m,dispose:b}}var Ef,tm,rm=ue(()=>{Ia();Ef=Object.freeze(["manual","tick","pause"]);o(G0,"_raf");o(H0,"makeControlSync");tm={makeControlSync:H0,SYNC_TRIGGERS:Ef}});var Sf={};ge(Sf,{FrqtlControlOverlay:()=>Dl});function K0(e,t){var r=t.x*100+"%",i=t.y*100+"%",n=t.anchor||"top-left";e.style.position="absolute",n==="top-left"&&(e.style.left=r,e.style.top=i),n==="top-right"&&(e.style.right=r,e.style.top=i),n==="bottom-left"&&(e.style.left=r,e.style.bottom=i),n==="bottom-right"&&(e.style.right=r,e.style.bottom=i)}function Y0(e,t){if(t=t||{},!e||typeof e.addControlChrome!="function"||!("controlHost"in e))throw new Error("[frqtl-control-overlay] mount(runner, opts) takes the scene's RUNNER \u2014 the overlay mounts through its one door, runner.controlHost (a scene never names a DOM id). (FAIL-LOUD.)");var r=e.controlHost;if(!r)throw new Error("[frqtl-control-overlay] runner.controlHost is null \u2014 the scene canvas is not mounted and no hosting pane set a host (check runner.controlHost before mounting). (FAIL-LOUD.)");if(!t.registry||typeof t.registry.getControls!="function")throw new Error("[frqtl-control-overlay] mount requires opts.registry \u2014 the SAME makeControlRegistry() instance the page exposed. (FAIL-LOUD.)");if(!t.name)throw new Error("[frqtl-control-overlay] mount requires opts.name (the registry instance name the controls were registered under). (FAIL-LOUD.)");var i=xi,n=Rl,a=t.registry,s=t.name,l=r.ownerDocument,c=l.createElement("div");c.className="frqtl-control-overlay",c.setAttribute("data-role","frqtl-control-overlay"),c.style.cssText="position:absolute;pointer-events:none;z-index:12;";var f=r.style.position;(!f||f==="static")&&(r.style.position="relative"),r.appendChild(c);function u(){var S=typeof r.querySelector=="function"?r.querySelector("canvas"):null;S?(c.style.left=S.offsetLeft+"px",c.style.top=S.offsetTop+"px",c.style.width=S.offsetWidth+"px",c.style.height=S.offsetHeight+"px"):(c.style.left="0",c.style.top="0",c.style.width="100%",c.style.height="100%")}o(u,"sizeToCanvas"),u();var h=o(function(){u()},"onResize"),g=typeof document<"u"?document.defaultView:null;g&&g.addEventListener("resize",h);var d=tm.makeControlSync({name:s,registry:a,trigger:"manual"}),m=[];function b(){m.forEach(function(S){S.widget.dispose(),S.cell.parentNode&&S.cell.parentNode.removeChild(S.cell)}),m=[]}o(b,"clear");function y(){b(),u();var S=i.dispatch(a,"listControls",[s]);return S.forEach(function(A){if(A.place){var T=l.createElement("div");T.className="frqtl-control-overlay-cell",T.setAttribute("data-frqtl-overlay-control",A.id),T.style.cssText="pointer-events:auto;background:rgba(12,18,28,0.72);border:1px solid #33405a;border-radius:4px;padding:2px 8px;backdrop-filter:blur(2px);",K0(T,A.place),c.appendChild(T);var j=n.mountWidget(T,{initial:A,onInput:o(function(Q){return i.dispatch(a,"setControlValue",[s,A.id,Q])},"onInput"),onAction:o(function(){var Q=i.dispatch(a,"runControlAction",[s,A.id]);return d.pull(),Q},"onAction")});d.register(A.id,j),m.push({id:A.id,widget:j,cell:T})}}),m.map(function(A){return A.id})}o(y,"refresh");var w=y(),x=e.addControlChrome({rehost:o(function(S){S!==r&&(x(),c.parentNode&&c.parentNode.removeChild(c),r.style.position=f,r=S,l=S.ownerDocument,f=S.style.position,(!f||f==="static")&&(S.style.position="relative"),S.appendChild(c),u())},"rehost")});return{controls:w,refresh:y,sync:o(function(){return d.pull()},"sync"),dispose:o(function(){b(),d.dispose(),g&&g.removeEventListener("resize",h),c.parentNode&&c.parentNode.removeChild(c),r.style.position=f},"dispose")}}var Dl,kf=ue(()=>{Ia();wf();rm();o(K0,"_applyPlace");o(Y0,"mount");Dl={mount:Y0}});var Go={};ge(Go,{FILTER_TICKS_PER_SECOND:()=>nm,RENDERER_PROVIDER_OPTIONAL:()=>Ll,RENDERER_PROVIDER_REQUIRED:()=>qo,SCENE_SURFACE_ATTR:()=>Pl,filterTime:()=>Wo,requireMountHost:()=>Bo,requireProviderSize:()=>Wi,requireSceneSurface:()=>J0,validateRendererProvider:()=>Vo});function Vo(e){var t=e!==null&&(typeof e=="object"||typeof e=="function");if(!t)return{ok:!1,missing:qo.slice(),capabilities:[]};var r=qo.filter(function(n){return typeof e[n]!="function"}),i=Ll.filter(function(n){return typeof e[n]=="function"});return{ok:r.length===0,missing:r,capabilities:i}}function im(e){return typeof e=="number"&&isFinite(e)&&e>0}function Wi(e,t,r){if(!(im(t)&&im(r)))throw new Error(e+": width and height must be positive finite numbers (got width="+String(t)+", height="+String(r)+"). They are the runner's physics rect (runner.canvas_rect), handed over by FrqtlApp.createCanvas as provider.init({width, height}) and written once by the scene's exp.createCanvas(w, h, cfg) / exp.createScene(w, h, d, cfg). A provider has no default size; the display size is the host element's CSS box, never a provider argument.")}function Bo(e,t){var r=typeof t=="string"&&t.length>0,i=typeof document<"u"&&document!==null&&typeof document.getElementById=="function",n=r&&i?document.getElementById(t):null;if(n)return n;var a=r?i?JSON.stringify(t)+", which names no element in the page":JSON.stringify(t)+", and there is no document":typeof t=="string"?'""':String(t);throw new Error(e+": canvasParentId is required and must name an element in the page (got "+a+"). The runner hands it as init({ parentEl }) from new FrqtlApp({ canvasParentId }) / new RecipeContext({ canvasParentId }). There is no default mount: a canvas appended to document.body is a canvas the layout never placed. (FAIL-LOUD.)")}function J0(e,t){var r=t!==null&&typeof t=="object"&&typeof t.tagName=="string"&&t.tagName.toUpperCase()==="CANVAS"&&typeof t.setAttribute=="function"&&typeof t.getContext=="function";if(r)return t;var i=t==null?String(t):typeof t=="object"&&typeof t.tagName=="string"?"<"+t.tagName.toLowerCase()+">":typeof t=="object"&&t.elt!==void 0?"a p5.Element (return its .elt)":typeof t;throw new Error(e+": provider.init(opts) must RETURN its drawing surface as an HTMLCanvasElement (got "+i+"). The runner stamps "+Pl+" on it so the scene surface is declared, never guessed among the document's canvases (RENDERER_CONTRACT \xA71, init row; owner: lib/frqtl/compat/renderer/renderer-provider-contract.js).")}function Wo(e){var t=e&&e.universeData&&e.universeData.tick;if(typeof t=="number"&&isFinite(t)&&t>=0)return t/nm;throw new Error("filterTime: the TickData being rendered must carry universeData.tick (got "+String(t)+"). uTime is simulation time at the rendered tick, never the wall clock (owner: lib/frqtl/compat/renderer/renderer-provider-contract.js). (FAIL-LOUD.)")}var qo,Ll,Pl,nm,un=ue(()=>{qo=["init","setSize","start","stop","destroy","renderTick","filter","removeFilter","raw"],Ll=["renderCapabilities","getCameraControl","screenToWorld","captureStill","projection"];o(Vo,"validateRendererProvider");o(im,"_isPositiveFinite");o(Wi,"requireProviderSize");o(Bo,"requireMountHost");Pl="data-frqtl-scene-surface";o(J0,"requireSceneSurface");nm=60;o(Wo,"filterTime")});var lr={};ge(lr,{RENDER_STAGES:()=>fn,RUNTIME_MUTATION_SURFACES:()=>Z0,SCENE_BOUND_KEYS:()=>Q0,SCENE_KEYS:()=>Af,SCENE_SURFACE_ATTR:()=>Pl,SCHEMA_VERSION:()=>Gn,STAGE_FORMATS:()=>om,STILL_BAG_KEYS:()=>cm,STILL_DERIVED_KEYS:()=>lm,STILL_KEYS:()=>sm,STILL_PAYLOAD_KEYS:()=>um,STILL_PROVENANCE_KEYS:()=>X0,assertSceneBound:()=>Cf,assertSourceSha256:()=>Il,assertStage:()=>Ko,canonicalizeScene:()=>mm,deepPlainCopy:()=>Tf,finalStage:()=>Rf,normalizeScene:()=>rw,normalizeStill:()=>Df,sceneHash:()=>iw,snapshotPayload:()=>dm,stageNotTappableError:()=>ew,upstreamStages:()=>fm});function $0(e){return fn.indexOf(e)!==-1}function Rf(){return fn[fn.length-1]}function fm(e){return Ko(e),fn.slice(0,fn.indexOf(e))}function Ko(e){if(!$0(e))throw new Error("[RenderStages] unknown stage "+JSON.stringify(e)+" \u2014 the canonical pipeline is ["+fn.join(", ")+"]. The stage argument is REQUIRED on the tap mechanism (a default is the convenience's job, not the mechanism's). (FAIL-LOUD.)");return e}function ew(e,t){return new Error("[RenderStages] stage "+JSON.stringify(e)+" is known, but not tappable by "+(t||"the active provider")+". Known stages: ["+fn.join(", ")+"]. A tap executor is added when a real caller for it appears \u2014 never a null image or an empty bag in the meantime. (FAIL-LOUD.)")}function sr(e){throw new Error("[RenderStages.normalizeStill] "+e+" (FAIL-LOUD.)")}function hm(e){return typeof e=="number"&&isFinite(e)&&e>0&&Math.floor(e)===e}function am(e,t){return hm(e)||sr(t+" must be a positive integer, got "+String(e)),e}function tw(e){for(var t=[],r=Object.create(null),i=e,n=!0;i&&i!==Object.prototype&&i!==Array.prototype;){for(var a=Object.getOwnPropertyNames(i),s=0;s<a.length;s++){var l=a[s];if(!(l==="constructor"||r[l])){var c=Object.getOwnPropertyDescriptor(i,l);(c.get||n||typeof c.value!="function")&&(r[l]=!0,t.push(l))}}i=Object.getPrototypeOf(i),n=!1}return t}function pm(e){return e&&typeof e=="object"&&typeof e.BYTES_PER_ELEMENT=="number"&&typeof e.length=="number"&&typeof e.constructor=="function"}function Ho(e,t){if(e==null)return null;var r=typeof e;if(r==="number"||r==="string"||r==="boolean")return e;if(r==="function"&&sr("the payload carries a FUNCTION at "+t+" \u2014 a still record must be plain, serialization-safe data"),r!=="object"&&sr("the payload carries an unsupported "+r+" at "+t),pm(e))return new e.constructor(e);if(Array.isArray(e)){for(var i=new Array(e.length),n=0;n<e.length;n++)i[n]=Ho(e[n],t+"["+n+"]");return i}for(var a={},s=tw(e),l=0;l<s.length;l++){var c=s[l],f;try{f=e[c]}catch{continue}a[c]=Ho(f,t+"."+c)}return a}function Tf(e){return Ho(e,"value")}function dm(e,t){if(t==="framedata")return Ho(e,"data");if(pm(e))return new e.constructor(e);if(Array.isArray(e))return Ho(e,"data");sr("format "+JSON.stringify(t)+" expects an indexed buffer payload, got "+String(e))}function Fa(e){throw new Error("[RenderStages.normalizeScene] "+e+" (FAIL-LOUD.)")}function Cf(e,t){return hm(e)||Fa(t+" must be a positive integer (a physics bound, init-fixed), got "+String(e)),e}function Il(e){return e==null?null:((typeof e!="string"||!/^[0-9a-f]{64}$/.test(e))&&Fa("sourceSha256 must be null or a project identity (64 lowercase hex characters, lib/shim/project/identity.js projectIdentity), got "+String(e)),e)}function rw(e){return(!e||typeof e!="object")&&Fa("expected a partial scene bag object, got "+String(e)),e.v!==void 0&&e.v!==null&&e.v!==Gn&&Fa("v "+String(e.v)+" disagrees with the contract version "+Gn+" \u2014 the normalizer is the version authority, `v` is never caller-supplied"),(typeof e.seed!="number"||!isFinite(e.seed))&&Fa('seed must be a finite number \u2014 it is half of the regeneration triple (code, seed, tick), and a null seed downgrades "regenerate" to "trust the raster", got '+String(e.seed)),{v:Gn,seed:e.seed,sourceRef:e.sourceRef===void 0||e.sourceRef===null?null:String(e.sourceRef),sourceSha256:Il(e.sourceSha256),build:e.build&&typeof e.build=="object"?Tf(e.build):null,physicsW:Cf(e.physicsW,"physicsW"),physicsH:Cf(e.physicsH,"physicsH"),projection:e.projection&&typeof e.projection=="object"?Tf(e.projection):null}}function jf(e){if(e==null)return"null";var t=typeof e;if(t==="number"||t==="boolean")return String(e);if(t==="string")return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(jf).join(",")+"]";var r=Object.keys(e).sort();return"{"+r.map(function(i){return JSON.stringify(i)+":"+jf(e[i])}).join(",")+"}"}function mm(e){(!e||typeof e!="object")&&Fa("canonicalizeScene expects a record object, got "+String(e));for(var t=[],r=0;r<Af.length;r++){var i=Af[r];t.push(JSON.stringify(i)+":"+jf(e[i]))}return"{"+t.join(",")+"}"}function iw(e){var t=mm(e),r=typeof crypto<"u"?crypto.subtle:null;if(!r||typeof r.digest!="function")return Promise.reject(new Error("[RenderStages.sceneHash] crypto.subtle.digest is unavailable \u2014 the scene identity is a content hash and there is no fallback hashing path by design (two hashing authorities would mint two identities for one scene). (FAIL-LOUD.)"));var i=new TextEncoder().encode(t);return Promise.resolve(r.digest("SHA-256",i)).then(function(n){for(var a=new Uint8Array(n),s="",l=0;l<a.length;l++)s+=(a[l]<16?"0":"")+a[l].toString(16);return"sha256:"+s})}function Df(e){(!e||typeof e!="object")&&sr("expected a partial bag object, got "+String(e));var t=Ko(e.stage),r=om[t];e.format!==void 0&&e.format!==null&&e.format!==r&&sr("format "+JSON.stringify(e.format)+" does not match stage "+JSON.stringify(t)+"'s declared format "+JSON.stringify(r));var i=e.data;i==null&&sr("stage "+JSON.stringify(t)+" returned no `data` payload"),typeof i.length!="number"&&sr("`data` must be an indexed payload (Array / Uint8Array / Uint8ClampedArray), got "+String(i)),i.length===0&&sr("stage "+JSON.stringify(t)+" returned an EMPTY `data` payload \u2014 never a blank still: a measurement or golden built on an empty capture is fabricated evidence"),e.v!==void 0&&e.v!==null&&e.v!==Gn&&sr("v "+String(e.v)+" disagrees with the contract version "+Gn+" \u2014 the normalizer is the version authority, `v` is never caller-supplied"),(typeof e.scene!="string"||!e.scene)&&sr("scene must be the content hash of the SceneRecord this still belongs to \u2014 a still without a scene id is unmoored: it cannot be verified against, or regenerated from, anything. Got "+String(e.scene)),(typeof e.tick!="number"||!isFinite(e.tick)||e.tick<0)&&sr("tick must be a finite non-negative number (the dispatcher stamps it from the live TickData \u2014 the tick-equality assertion is what co-registers a multi-channel corpus row), got "+String(e.tick));var n=e.filtersApplied;Array.isArray(n)||sr("filtersApplied must be an ARRAY of filter names in the order they ran (the provider's ordered _filters list is the one authority), got "+String(n));var a=e.filterTime===void 0?null:e.filterTime;(n.length>0?!(typeof a=="number"&&isFinite(a)):a!==null)&&sr("filterTime must be the finite uTime the filter passes drew with when filtersApplied is non-empty, and null when it is empty (filtersApplied "+JSON.stringify(n)+", filterTime "+String(a)+") \u2014 the provider reports it (RendererProviderContract.filterTime of the rendered tick)");var s=fm(t);if(e.composedOf!==void 0&&e.composedOf!==null){var l=e.composedOf,c=Array.isArray(l)&&l.length===s.length&&l.every(function(f,u){return f===s[u]});c||sr("composedOf is DERIVED from RENDER_STAGES ("+JSON.stringify(s)+") and is never caller-supplied; got "+JSON.stringify(l))}return{v:Gn,scene:e.scene,stage:t,tick:e.tick,format:r,data:dm(i,r),width:am(e.width,"width"),height:am(e.height,"height"),cssWidth:typeof e.cssWidth=="number"?e.cssWidth:null,cssHeight:typeof e.cssHeight=="number"?e.cssHeight:null,filtersApplied:n.slice(),renderBaseCanvas:typeof e.renderBaseCanvas=="boolean"?e.renderBaseCanvas:null,filterTime:a,pose:e.pose!==void 0&&e.pose!==null?e.pose:null,fieldOpts:e.fieldOpts&&typeof e.fieldOpts=="object"?e.fieldOpts:null,composedOf:s,renderOptions:e.renderOptions&&typeof e.renderOptions=="object"?e.renderOptions:{}}}var fn,om,Gn,Af,Q0,sm,lm,cm,um,X0,Z0,Na=ue(()=>{un();fn=["tick","field","scene","composite"],om={tick:"framedata",field:"r8",scene:"rgba8",composite:"rgba8"},Gn=4,Af=["v","seed","sourceRef","sourceSha256","build","physicsW","physicsH","projection"],Q0=["physicsW","physicsH"],sm=["v","scene","stage","format","tick","data","width","height","cssWidth","cssHeight","pose","filtersApplied","renderBaseCanvas","filterTime","renderOptions","fieldOpts"],lm=["composedOf"],cm=sm.concat(lm),um=["data","width","height"],X0=cm.filter(function(e){return um.indexOf(e)===-1}),Z0={"cameraControl.setOrbit/look/move/setPreset":["pose"],"setFilterActive / provider.filter / removeFilter":["filtersApplied","filterTime"],setRenderOption:["renderOptions","renderBaseCanvas"],"canvas resize (setSize)":["width","height","cssWidth","cssHeight"],"FieldBuilder options at the field tap":["fieldOpts"]};o($0,"_isStageKnown");o(Rf,"finalStage");o(fm,"upstreamStages");o(Ko,"assertStage");o(ew,"stageNotTappableError");o(sr,"_fail");o(hm,"_isPosInt");o(am,"_posInt");o(tw,"_readableKeys");o(pm,"_isTypedArray");o(Ho,"_deepPlainClone");o(Tf,"deepPlainCopy");o(dm,"snapshotPayload");o(Fa,"_failScene");o(Cf,"assertSceneBound");o(Il,"assertSourceSha256");o(rw,"normalizeScene");o(jf,"_stableEncode");o(mm,"canonicalizeScene");o(iw,"sceneHash");o(Df,"normalizeStill")});var Ma={};ge(Ma,{ENCODED_KEYS:()=>vm,ENCODERS:()=>Nl,ENVELOPE_VERSION:()=>Lf,bytesToBase64:()=>aw,stillEnvelope:()=>ow,videoEnvelope:()=>Pf});function It(e){throw new Error("[capture-envelope] "+e+" (FAIL-LOUD.)")}function nw(e,t){return typeof e!="boolean"&&It(t+" must be an explicit boolean, got "+String(e)+" \u2014 it is never defaulted, because a fabricated completeness claim is the exact failure the recorder's own bound reporting exists to prevent"),e}function Fl(e,t){return(typeof e!="number"||!isFinite(e)||e<=0||e%1!==0)&&It(t+" must be a positive whole number, got "+String(e)),e}function ym(e,t,r){return(typeof e!="string"||!e)&&It(t+" must be a non-empty string"+(r?" \u2014 "+r:"")+", got "+String(e)),e}function bm(e,t){(!e||typeof e!="object")&&It("`encoded` must be an object carrying the transportable bytes");for(var r={},i=vm[t],n=0;n<i.length;n++){var a=i[n];a==="encoder"?r.encoder=e.encoder===void 0?null:e.encoder:a==="bytes"?((typeof e.bytes!="string"||!e.bytes)&&It("encoded.bytes must be a non-empty base64 string \u2014 the envelope carries TRANSPORTABLE bytes; an rgba8 payload does not cross a boundary and the still already holds it"),r.bytes=e.bytes):r[a]=ym(e[a],"encoded."+a)}if(r.mime.indexOf(gm[t])!==0&&It("encoded.mime "+JSON.stringify(r.mime)+" is not a "+gm[t]+"* type"),r.encoder!==null){Object.prototype.hasOwnProperty.call(Nl,r.encoder)||It("unknown encoder "+JSON.stringify(r.encoder)+" \u2014 known: "+Object.keys(Nl).join(", "));var s=Nl[r.encoder];s.kind!==t&&It("encoder "+JSON.stringify(r.encoder)+" produces a "+s.kind+", not a "+t),s.mime!==r.mime&&It("encoder "+JSON.stringify(r.encoder)+" produces "+JSON.stringify(s.mime)+", but encoded.mime says "+JSON.stringify(r.mime))}return r}function aw(e){(!e||typeof e.BYTES_PER_ELEMENT!="number")&&It("bytesToBase64 expects a typed array, got "+String(e)),typeof btoa!="function"&&It("bytesToBase64 needs a global btoa (every browser, and node >= 16)");for(var t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r="",i=0;i<t.length;i+=32768)r+=String.fromCharCode.apply(null,t.subarray(i,i+32768));return btoa(r)}function ow(e){(!e||typeof e!="object")&&It("expected an object, got "+String(e));var t=Df(e.still),r=bm(e.encoded,"still");return{kind:"still",v:Lf,still:t,encoded:r}}function Pf(e){(!e||typeof e!="object")&&It("expected an object, got "+String(e));var t=e.track;(!t||typeof t!="object")&&It("`track` (the sidecar manifest) is REQUIRED \u2014 without it the bytes are an unlabelled movie"),ym(t.scene,"track.scene","a sequence without a scene id is unmoored exactly as a still without one is");var r=Ko(t.stage),i=Fl(t.width,"track.width"),n=Fl(t.height,"track.height"),a=Fl(t.ticksPerFrame,"track.ticksPerFrame"),s=Fl(t.fps,"track.fps"),l=t.frames;(!Array.isArray(l)||l.length===0)&&It("track.frames must be a non-empty array of {i, tick, pose} \u2014 an empty manifest over real bytes is a measurement built on nothing");for(var c=0;c<l.length;c++){var f=l[c];if((!f||typeof f!="object")&&It("track.frames["+c+"] must be an object"),f.i!==c&&It("track.frames["+c+"].i is "+String(f.i)+" \u2014 frame indices must be contiguous from 0, or the map from bytes to state is guesswork"),(typeof f.tick!="number"||!isFinite(f.tick)||f.tick%1!==0)&&It("track.frames["+c+"].tick must be a whole number, got "+String(f.tick)),c>0){var u=f.tick-l[c-1].tick;u!==a&&It("track.frames["+c+"] is "+u+" ticks after its predecessor, but track.ticksPerFrame declares "+a+" \u2014 a manifest whose label disagrees with its data is worse than none, because it is believed")}}var h=bm(e.encoded,"video");return{kind:"video",v:Lf,track:{scene:t.scene,stage:r,width:i,height:n,ticksPerFrame:a,fps:s,firstTick:l[0].tick,lastTick:l[l.length-1].tick,frames:l.map(function(g){return{i:g.i,tick:g.tick,pose:g.pose===void 0?null:g.pose}})},encoded:h,truncated:nw(e.truncated,"truncated")}}var Lf,vm,gm,Nl,Ml=ue(()=>{Na();Lf=1,vm={still:["mime","bytes","encoder"],video:["mime","bytes","encoder","codec","muxer"]},gm={still:"image/",video:"video/"},Nl={"FrqtlVision.toPNG":{kind:"still",mime:"image/png"},"FrqtlVision.toDataURL":{kind:"still",mime:"image/png"},"FrqtlVision.record":{kind:"video",mime:"video/mp4"}};o(It,"_fail");o(nw,"_requireBool");o(Fl,"_requirePosInt");o(ym,"_requireNonEmptyString");o(bm,"_normalizeEncoded");o(aw,"bytesToBase64");o(ow,"stillEnvelope");o(Pf,"videoEnvelope")});function sw(e){var t=lr;if(!e||typeof e!="object")throw new Error("[FrqtlCaptureHost] expected a capture-host object, got "+String(e)+". (FAIL-LOUD.)");if(e.kind!==If)throw new Error("[FrqtlCaptureHost] this object is not a "+JSON.stringify(If)+" (its kind is "+JSON.stringify(e.kind)+"). A capture host is a DISTINCT stage-executor kind, not a RendererProvider: a provider returns raw pixels and lets the local dispatcher stamp provenance, which a remote executor cannot honestly do \u2014 it holds no tick, no pose, no filter order. A host returns a bag already normalized by the dispatcher that DOES hold them. (FAIL-LOUD.)");if(!Array.isArray(e.stages)||e.stages.length===0)throw new Error("[FrqtlCaptureHost] `stages` must be a non-empty array of stage names this host executes remotely \u2014 ["+t.RENDER_STAGES.join(", ")+"]. (FAIL-LOUD.)");for(var r=0;r<e.stages.length;r++)t.assertStage(e.stages[r]);["identity","capture","record","dispose"].forEach(function(n){if(typeof e[n]!="function")throw new Error("[FrqtlCaptureHost] a capture host must implement "+n+"() \u2014 the KIND is {kind, stages, identity(), capture(stage), record(opts), dispose()}. (FAIL-LOUD.)")});var i=e.identity();if(!i||typeof i!="object")throw new Error("[FrqtlCaptureHost] identity() must return the page-resolved {build, projection} bag SYNCHRONOUSLY (resolved once during the host's own open()); got "+String(i)+". Without it the node-side scene identity carries nulls where the page carries real values, and every hosted row splits into a second scene. (FAIL-LOUD.)");return e}function hw(e){if(!e||typeof e.attach!="function")throw new TypeError("[FrqtlCaptureHost] registerRecorder(recorder): expected the FrqtlVision face (attach(runner) \u2192 handle). (FAIL-LOUD.)");if(Yo&&Yo!==e)throw new Error("[FrqtlCaptureHost] a second recorder registered in this realm \u2014 FrqtlVision loaded under two module URLs (one module, one URL). (FAIL-LOUD.)");Yo=e}function pw(){if(!Yo)throw new Error("[FrqtlCaptureHost] no recorder registered in this realm \u2014 import FrqtlVision (import { FrqtlVision } from '@descix/frqtl-web/parts'); the boot imports the parts barrel. (FAIL-LOUD.)");return Yo}function dw(e,t){Ff[e]=t}function mw(e){return Ff[e]||null}function gw(e){delete Ff[e]}function vw(e){var t=lr;if(!e||typeof e!="object"||!e.bag)throw new Error("[FrqtlCaptureHost.decodeStillEnvelope] expected a capture envelope {bag, encoding, ctor, payload}, got "+String(e)+". (FAIL-LOUD.)");var r;if(e.encoding==="base64"){if(typeof Buffer>"u"||typeof Buffer.from!="function")throw new Error("[FrqtlCaptureHost.decodeStillEnvelope] base64 payloads are decoded with Node's Buffer \u2014 the node half of the boundary runs in Node by definition. (FAIL-LOUD.)");var i=typeof globalThis<"u"?globalThis[e.ctor]:null;if(typeof i!="function"||typeof i.BYTES_PER_ELEMENT!="number")throw new Error("[FrqtlCaptureHost.decodeStillEnvelope] the envelope declares payload type "+JSON.stringify(e.ctor)+", which is not a typed-array constructor here. The payload TYPE is ferried from the page, never mapped from the format \u2014 a local table would be a hand mirror. (FAIL-LOUD.)");r=new i(Buffer.from(e.payload,"base64"))}else if(e.encoding==="plain")r=e.payload;else throw new Error("[FrqtlCaptureHost.decodeStillEnvelope] unknown payload encoding "+JSON.stringify(e.encoding)+" \u2014 the ENCODING SIDE declares it (base64 for a typed buffer, plain for JSON-safe data) and this side obeys. (FAIL-LOUD.)");var n={};for(var a in e.bag)n[a]=e.bag[a];return n.data=r,t.normalizeStill(n)}function yw(e,t){for(var r=lr,i=[],n=0;n<r.SCENE_KEYS.length;n++){var a=r.SCENE_KEYS[n],s=r.canonicalizeScene(wm(a,e)),l=r.canonicalizeScene(wm(a,t));s!==l&&i.push(a)}return i}function wm(e,t){var r={};return r[e]=t?t[e]:void 0,r}function bw(e,t,r){if(!r||typeof r!="object")throw new Error("[FrqtlCaptureHost] the host returned no still for stage "+JSON.stringify(t)+". (FAIL-LOUD \u2014 never a null still.)");if(r.stage!==t)throw new Error("[FrqtlCaptureHost] asked the host for stage "+JSON.stringify(t)+" and it returned stage "+JSON.stringify(r.stage)+". (FAIL-LOUD.)");if(r.scene!==e)throw new Error("[FrqtlCaptureHost] SCENE IDENTITY MISMATCH: the hosted page stamped "+JSON.stringify(r.scene)+" but this process computed "+JSON.stringify(e)+" for the same scene. The two are supposed to be equal BY CONSTRUCTION (host attachment extends the node identity with the page-resolved build/projection), so a mismatch means the page is no longer running the scene this handle was opened for. The still is REFUSED rather than filed against the wrong header. (FAIL-LOUD.)");return r}function ww(e,t){if(!t||typeof t!="object"||t.kind!=="video")throw new Error("[FrqtlCaptureHost] the host returned no video envelope (got "+String(t&&t.kind)+"). (FAIL-LOUD \u2014 never a null recording.)");var r=Pf({track:t.track,encoded:t.encoded,truncated:t.truncated});if(r.track.scene!==e)throw new Error("[FrqtlCaptureHost] SCENE IDENTITY MISMATCH: the hosted page recorded scene "+JSON.stringify(r.track.scene)+" but this process computed "+JSON.stringify(e)+" for the same scene. The recording is REFUSED rather than filed against the wrong header. (FAIL-LOUD.)");return r}var If,lw,cw,uw,fw,Yo,Ff,Ua,Nf=ue(()=>{Na();Ml();If="capture-host";o(sw,"assertCaptureHost");lw=o(async function(e){var t=window.FrqtlPage&&window.FrqtlPage.runner;if(!t)throw new Error("[FrqtlCaptureHost/in-page] no FrqtlPage.runner on this page \u2014 the host booted something that is not a running FRQTL stack. (FAIL-LOUD.)");if(!e||!e.modules||typeof e.modules.captureEnvelope!="string")throw new Error("[FrqtlCaptureHost/in-page] no CaptureEnvelope module URL (args.modules.captureEnvelope) \u2014 the ONE transport encoder (lib/shim/render/capture-envelope.js) is imported from the page, never re-encoded by a copy. (FAIL-LOUD.)");var r=await import(e.modules.captureEnvelope),i=await t.capture(e.stage),n=i.data,a={};for(var s in i)s!=="data"&&(a[s]=i[s]);return n&&typeof n.BYTES_PER_ELEMENT=="number"?{bag:a,encoding:"base64",ctor:n.constructor.name,payload:r.bytesToBase64(n)}:{bag:a,encoding:"plain",ctor:null,payload:n}},"IN_PAGE_CAPTURE"),cw=o(async function(e){var t=window.FrqtlPage&&window.FrqtlPage.runner;if(!t)throw new Error("[FrqtlCaptureHost/in-page] no FrqtlPage.runner on this page \u2014 the host booted something that is not a running FRQTL stack. (FAIL-LOUD.)");var r=(await import(e.modules.captureHost)).FrqtlCaptureHost,i=new AbortController,n={};for(var a in e.opts)n[a]=e.opts[a];n.signal=i.signal;var s=r.recorder().attach(t).record(n);return s.then(null,function(){}),r.parkRecording(e.id,{pending:s,controller:i}),e.id},"IN_PAGE_RECORD_BEGIN"),uw=o(async function(e){var t=(await import(e.modules.captureHost)).FrqtlCaptureHost,r=t.parkedRecording(e.id);if(!r)throw new Error("[FrqtlCaptureHost/in-page] no recording parked under id "+e.id+". (FAIL-LOUD.)");var i=o(function(){t.forgetRecording(e.id)},"forget");return r.pending.then(function(n){return i(),n},function(n){throw i(),n})},"IN_PAGE_RECORD_END"),fw=o(async function(e){var t=(await import(e.modules.captureHost)).FrqtlCaptureHost,r=t.parkedRecording(e.id);return r?(r.controller.abort(),!0):!1},"IN_PAGE_RECORD_ABORT"),Yo=null;o(hw,"registerRecorder");o(pw,"recorder");Ff=Object.create(null);o(dw,"parkRecording");o(mw,"parkedRecording");o(gw,"forgetRecording");o(vw,"decodeStillEnvelope");o(yw,"diffSceneRecords");o(wm,"_one");o(bw,"verifyStill");o(ww,"verifyVideo");Ua={CAPTURE_HOST_KIND:If,assertCaptureHost:sw,IN_PAGE_CAPTURE:lw,IN_PAGE_RECORD_BEGIN:cw,IN_PAGE_RECORD_END:uw,IN_PAGE_RECORD_ABORT:fw,decodeStillEnvelope:vw,diffSceneRecords:yw,verifyStill:bw,verifyVideo:ww,registerRecorder:hw,recorder:pw,parkRecording:dw,parkedRecording:mw,forgetRecording:gw}});function qa(e){return new URL(e,_w).href}function Ow(e){if(Ul.has(e))return Ul.get(e);let t=new Promise(function(r,i){let n=document.createElement("script");n.async=!1,n.src=e,n.onload=function(){r()},n.onerror=function(){Ul.delete(e),n.parentNode&&n.parentNode.removeChild(n);let a=new Error("[vendor] classic script failed to load: "+e);a.src=e,i(a)},(document.head||document.body).appendChild(n)});return Ul.set(e,t),t}function _m(e,t){if(!Array.isArray(e))return Promise.reject(new TypeError("[vendor] loadClassicScripts(urls): urls must be an array of URLs (got "+typeof e+")"));let r=t&&t.onLoaded;if(r!==void 0&&typeof r!="function")return Promise.reject(new TypeError("[vendor] loadClassicScripts: opts.onLoaded must be a function when given"));let i=e.map(function(n){return Ow(n).then(function(){r&&r(n)})});return Promise.all(i).then(function(){})}function Mf(){let e=globalThis.THREE;if(!e)throw new Error("[vendor] three.js is not loaded \u2014 boot the three renderer (bootRealm({ renderer: 'three' })) before constructing a three provider. (FAIL-LOUD.)");return e}function Uf(){return qa("three-loaders")}function xm(e){let t=!!(e&&e.meshLoaders);if(!za){let r=qa("three.min.js"),i=fetch(r).then(function(n){if(!n.ok)throw new Error("[vendor] three.js failed to load: HTTP "+n.status+" "+r);return n.text()}).then(function(n){return new Function("define","require","module","exports",n+`
|
|
3
|
+
//# sourceURL=`+r)(),Mf()});za=i,i.catch(function(){za===i&&(za=null)})}return t?za.then(function(r){let i=Uf();return _m([i+"/GLTFLoader.js",i+"/DRACOLoader.js"]).then(function(){if(typeof r.GLTFLoader>"u"||typeof r.DRACOLoader>"u")throw new Error("[vendor] the mesh loaders loaded but THREE.GLTFLoader/DRACOLoader are undefined ("+i+") \u2014 run scripts/vendor-three-loaders.mjs to populate the vendored dir. (FAIL-LOUD.)");return r})}):za}function Om(e){let t=!!(e&&e.p5),r=e&&e.onSetup,i=e&&e.setup;if(i!==void 0&&typeof i!="function")return Promise.reject(new TypeError("[vendor] runSketch: opts.setup must be the page's setup function. (FAIL-LOUD.)"));if(typeof i!="function"&&!t)return Promise.reject(new Error("[vendor] runSketch: the page passes no setup() to run on this renderer. (FAIL-LOUD.)"));let n=o(function(){let a=i.apply(this,arguments);return r&&r(),a},"hooked");return t?(typeof i=="function"&&(globalThis.setup=n),_m([qa("p5.min.js")])):(n(),Promise.resolve())}function Em(){globalThis.draw=function(){}}function Sm(){typeof globalThis.loop=="function"&&globalThis.loop()}var _w,xw,Ul,za,Va=ue(()=>{At();_w=new URL("../assets/vendor/",new URL("frqtl/compat/vendor.js",ze()).href),xw=Object.freeze(["setup","draw"]);o(qa,"vendorUrl");Ul=new Map;o(Ow,"_one");o(_m,"loadClassicScripts");za=null;o(Mf,"three");o(Uf,"meshLoadersBase");o(xm,"loadThree");o(Om,"runSketch");o(Em,"suppressP5Draw");o(Sm,"resumeP5Loop")});function Jo(e){return e&&zf.get(e)||null}function qf(e,t){t?zf.set(e,t):zf.delete(e)}var zf,Vf=ue(()=>{zf=new WeakMap;o(Jo,"openRecordOf");o(qf,"_setOpenRecord")});var Wf={};ge(Wf,{FrqtlVision:()=>Kn});function Bf(e){return e.STAGE_FORMATS[e.finalStage()]}function Am(e,t,r){if(!e||typeof e!="object")throw new Error("[FrqtlVision."+r+"] expected a still record, got "+String(e)+".");var i=Bf(t);if(e.format!==i)throw new Error("[FrqtlVision."+r+"] this record's format is "+JSON.stringify(e.format)+", not "+JSON.stringify(i)+" \u2014 stage "+JSON.stringify(e.stage)+" carries NUMBERS (read still.data), not an image. Encoding it as a PNG would produce a plausible-looking picture of nothing. (FAIL-LOUD.)")}function Tm(e){var t=lr;if(Am(e,t,"toDataURL"),typeof document>"u")throw new Error("[FrqtlVision.toDataURL] no DOM: a data URL is encoded through a scratch canvas, so this is the BROWSER encoder. In node call FrqtlVision.toPNG(still) for PNG bytes (or eyes.saveStill(still, path) to write them straight to a file) \u2014 same picture, same record, the encoder for THIS host. (FAIL-LOUD.)");var r=document.createElement("canvas");r.width=e.width,r.height=e.height;var i=r.getContext("2d");if(!i||typeof i.putImageData!="function")throw new Error("[FrqtlVision.toDataURL] the scratch canvas has no 2D context. (FAIL-LOUD.)");var n=i.createImageData(e.width,e.height);return n.data.set(e.data),i.putImageData(n,0,0),r.toDataURL("image/png")}function Cm(e){var t=lr;Am(e,t,"toPNG");var r=typeof process<"u"&&process.getBuiltinModule?process.getBuiltinModule("node:zlib"):null;if(!r||typeof Buffer>"u")throw new Error("[FrqtlVision.toPNG] this is the NODE encoder (zlib + Buffer) and neither is available here. In a browser call FrqtlVision.toDataURL(still) \u2014 same picture, same record, the encoder for THIS host. (FAIL-LOUD.)");for(var i=e.width,n=e.height,a=Buffer.from(e.data.buffer,e.data.byteOffset,e.data.length),s=i*4+1,l=Buffer.alloc(n*s),c=0;c<n;c++)l[c*s]=0,a.copy(l,c*s+1,c*i*4,(c+1)*i*4);function f(g){for(var d,m=4294967295,b=0;b<g.length;b++){d=(m^g[b])&255;for(var y=0;y<8;y++)d=d&1?3988292384^d>>>1:d>>>1;m=m>>>8^d}return(m^4294967295)>>>0}o(f,"crc32");function u(g,d){var m=Buffer.alloc(4);m.writeUInt32BE(d.length);var b=Buffer.concat([Buffer.from(g,"ascii"),d]),y=Buffer.alloc(4);return y.writeUInt32BE(f(b)),Buffer.concat([m,b,y])}o(u,"chunk");var h=Buffer.alloc(13);return h.writeUInt32BE(i,0),h.writeUInt32BE(n,4),h[8]=8,h[9]=6,Buffer.concat([Buffer.from([137,80,78,71,13,10,26,10]),u("IHDR",h),u("IDAT",r.deflateSync(l,{level:9})),u("IEND",Buffer.alloc(0))])}function Ft(e,t){throw new Error("[FrqtlVision."+e+"] "+t+" (FAIL-LOUD.)")}function Hn(e,t,r){return(typeof e!="number"||!isFinite(e)||e<=0||e%1!==0)&&Ft(r,t+" must be a positive whole number, got "+String(e)),e}function zl(e,t,r,i){for(var n=Object.keys(e),a=0;a<n.length;a++)t.indexOf(n[a])===-1&&Ft(i,r+" has no option "+JSON.stringify(n[a])+" \u2014 declared: "+t.join(", "))}function jm(e,t,r){var i=r.who;typeof e.addTickListener!="function"&&Ft(i,"needs the runner's per-tick listener fan-out (runner.addTickListener) \u2014 the cadence is counted in TICKS, and nothing else can count them. A node-side capture instrument has no clock of its own: record inside the page that runs the world (eyes.vision.record from @descix/frqtl-node/eyes)");var n=t.STAGE_FORMATS[r.stage]===Bf(t);n&&(typeof e.suspendTicks!="function"||typeof e.resumeTicks!="function"||typeof e.repaint!="function")&&Ft(i,"a "+JSON.stringify(r.stage)+" sample needs the capture hold (runner.suspendTicks/repaint/resumeTicks): a capture from the tick listener must see its tick COMPOSITED before the readback, and on a batching or fps-capped loop only a held clock plus a forced draw guarantees that");var a=0,s=0,l=null,c=!1,f=null;function u(g){if(l===null)return l={scene:g.scene,width:g.width,height:g.height},g;if(g.scene!==l.scene)throw new Error("[FrqtlVision."+i+"] the scene changed mid-sequence ("+JSON.stringify(l.scene)+" \u2192 "+JSON.stringify(g.scene)+" at tick "+g.tick+"): a sequence spans exactly ONE scene record. Start a new one. (FAIL-LOUD.)");if(g.width!==l.width||g.height!==l.height)throw new Error("[FrqtlVision."+i+"] the "+g.stage+" size changed mid-sequence ("+l.width+"x"+l.height+" \u2192 "+g.width+"x"+g.height+" at tick "+g.tick+"): a sequence has constant dimensions (an encoder cannot hold a resize). Start a new one. (FAIL-LOUD.)");return g}o(u,"continuity");function h(){if(!c&&(a+=1,(a-1)%r.everyTicks===0&&r.admit(s))){var g=s;s+=1;var d;if(n){e.suspendTicks();try{e.repaint()}catch(y){d=Promise.reject(y)}}if(!d)try{d=Promise.resolve(e.capture(r.stage))}catch(y){d=Promise.reject(y)}var m=Promise.resolve(r.onStill(d.then(u),g));if(n){var b=o(function(){e.resumeTicks()},"release");m.then(b,b)}}}return o(h,"onTick"),f=e.addTickListener(h),{stop:o(function(){c||(c=!0,f&&(f(),f=null))},"stop")}}function Ew(e,t,r){var i="getStream";(!r||typeof r!="object")&&Ft(i,"expected {stage?, everyTicks}, got "+String(r)),zl(r,["stage","everyTicks"],"getStream",i);var n=Hn(r.everyTicks,"everyTicks",i),a=r.stage===void 0?t.finalStage():t.assertStage(r.stage),s={};return s[Symbol.asyncIterator]=function(){var l=[],c=null,f=!1,u=jm(e,t,{who:i,stage:a,everyTicks:n,admit:o(function(){return!f},"admit"),onStill:o(function(g){if(g.then(null,function(){}),l.push(g),c){var d=c;c=null,d()}return g},"onStill")});function h(){f=!0,u.stop(),l.length=0}return o(h,"end"),{next:o(function(){if(l.length)return l.shift().then(function(d){return{value:d,done:!1}},function(d){throw h(),d});if(f)return Promise.resolve({value:void 0,done:!0});var g=this;return new Promise(function(d){c=d}).then(function(){return g.next()})},"next"),return:o(function(){if(h(),c){var g=c;c=null,g()}return Promise.resolve({value:void 0,done:!0})},"return")}},s}function Aw(e,t){var r="record";(!t||typeof t!="object")&&Ft(r,"expected {everyTicks, stopAt, maxFrames, fps, stage?, bitrate?, keyFrameInterval?, signal?}, got "+String(t)),zl(t,Sw,"record",r);var i={everyTicks:Hn(t.everyTicks,"everyTicks (the capture cadence in TICKS \u2014 there is no wall-clock cadence)",r),maxFrames:Hn(t.maxFrames,"maxFrames (the memory bound; hitting it reports truncated:true)",r),fps:Hn(t.fps,"fps (the PLAYBACK rate \u2014 it has no physical meaning)",r),stage:t.stage===void 0?e.finalStage():e.assertStage(t.stage),bitrate:t.bitrate===void 0?null:Hn(t.bitrate,"bitrate (bits per second)",r),keyFrameInterval:t.keyFrameInterval===void 0?1:Hn(t.keyFrameInterval,"keyFrameInterval (frames)",r),stopAt:null,signal:null};if(t.signal!==void 0){var n=t.signal;(!n||typeof n.aborted!="boolean"||typeof n.addEventListener!="function")&&Ft(r,"signal must be an AbortSignal (new AbortController().signal) \u2014 it is how a recording stops before its stopAt; got "+String(n)),i.signal=n}e.STAGE_FORMATS[i.stage]!==Bf(e)&&Ft(r,"stage "+JSON.stringify(i.stage)+" carries NUMBERS (format "+JSON.stringify(e.STAGE_FORMATS[i.stage])+"), not an image \u2014 a video of it would be a plausible-looking movie of nothing. Read the numbers with getStream({stage: "+JSON.stringify(i.stage)+", everyTicks})");var a=t.stopAt;(!a||typeof a!="object")&&Ft(r,"stopAt is REQUIRED \u2014 exactly one of {tick: T}, {ticks: K}, {path: {waypoints, loop?, waypointTimeoutMs?}}. A recording with no honest stop is stopped by its bound, which is how a cap silently becomes the length of every video");var s=Object.keys(a);return zl(a,km,"stopAt",r),s.length!==1&&Ft(r,"stopAt names exactly ONE form, got ["+s.join(", ")+"] \u2014 declared: "+km.join(", ")),s[0]==="tick"?((typeof a.tick!="number"||!isFinite(a.tick)||a.tick<0||a.tick%1!==0)&&Ft(r,"stopAt.tick is an absolute tick (a non-negative whole number), got "+String(a.tick)),i.stopAt={tick:a.tick}):s[0]==="ticks"?i.stopAt={ticks:Hn(a.ticks,"stopAt.ticks (ticks after the first capture)",r)}:((!a.path||typeof a.path!="object")&&Ft(r,"stopAt.path must be {waypoints, loop?, waypointTimeoutMs?}"),zl(a.path,kw,"stopAt.path",r),i.stopAt={path:a.path}),i}function Tw(){return Promise.all([import(qa("mediabunny.min.mjs")),fetch(qa("mediabunny.PINNED.json")).then(function(e){return e.ok||Ft("record","the encoder pin mediabunny.PINNED.json did not load (HTTP "+e.status+")"),e.json()})]).then(function(e){var t=e[1];return(!t||typeof t.version!="string"||!t.version)&&Ft("record","mediabunny.PINNED.json carries no version \u2014 the muxer label is ferried from the pin, never typed here"),{MB:e[0],pin:t}})}function Cw(e,t,r){var i=Aw(t,r),n=Ma,a=typeof e.captureHost=="function"?e.captureHost():null;if(a){var s=Promise.resolve(a.record(r));return Promise.all([e.sceneRecord(),s]).then(function(V){return Ua.verifyVideo(V[0].scene,V[1])})}typeof document>"u"&&Ft("record","no DOM and no capture host: video is encoded with WebCodecs where the picture is, i.e. in a page. From node use the hosted eyes \u2014 openHostedEyes from @descix/frqtl-node/eyes, then eyes.vision.record(opts), which runs this SAME record inside the hosted page"),typeof VideoEncoder>"u"&&Ft("record","this page has no WebCodecs VideoEncoder (it needs a secure context: https or localhost). The encoder is not optional \u2014 there is no second path");var l=Jo(e),c=l?l._clipFor(i):null,f=null;if(i.stopAt.path)try{f=Sa.attach(e,{waypoints:i.stopAt.path.waypoints,loop:!!i.stopAt.path.loop,waypointTimeoutMs:i.stopAt.path.waypointTimeoutMs})}catch(V){throw c&&c.drop(),V}var u=[],h=[],g=!1,d=!1,m=null,b=i.stopAt.tick!==void 0?i.stopAt.tick:null,y=null,w=null,x=null,S=null,A=Tw().then(function(V){var C=V.MB,J=new C.BufferTarget,R=new C.Output({format:new C.Mp4OutputFormat({fastStart:"in-memory"}),target:J}),K=new C.VideoSampleSource({codec:"avc",bitrate:i.bitrate===null?C.QUALITY_HIGH:i.bitrate,keyFrameInterval:i.keyFrameInterval});return R.addVideoTrack(K,{frameRate:i.fps}),R.start().then(function(){return{MB:C,pin:V.pin,target:J,output:R,source:K}})}),T=A,j,Q=new Promise(function(V,C){j={resolve:V,reject:C}});function Y(V){V&&!m&&(m=V),!d&&(d=!0,y&&y.stop(),f&&(f.dispose(),f=null),w&&(i.signal.removeEventListener("abort",w),w=null),Promise.all(h).then(function(){if(m)throw m;return u.length||Ft("record","the recording stopped before a single still was captured \u2014 nothing to encode. Is the runner advancing ticks?"),c&&c.check(u.length),T}).then(function(C){return C.output.finalize().then(function(){return C.output.getMimeType()}).then(function(J){var R=String(J).split(";"),K=R[0].trim(),N=/codecs="([^"]+)"/.exec(J);return N||Ft("record","the muxer reported no codec string ("+JSON.stringify(J)+") \u2014 encoded.codec REPORTS what was produced and is never assumed"),n.videoEnvelope({track:{scene:S,stage:i.stage,width:x.width,height:x.height,ticksPerFrame:i.everyTicks,fps:i.fps,frames:u},encoded:{mime:K,bytes:n.bytesToBase64(new Uint8Array(C.target.buffer)),encoder:"FrqtlVision.record",codec:N[1],muxer:"mediabunny@"+C.pin.version},truncated:g})})}).then(function(C){c&&c.end(C),j.resolve(C)},function(C){c&&c.drop(),A.then(function(J){return J.output.cancel()}).then(null,function(){}),j.reject(C)}))}if(o(Y,"close"),A.then(null,function(V){Y(V)}),y=jm(e,t,{who:"record",stage:i.stage,everyTicks:i.everyTicks,admit:o(function(V){return d?!1:V>=i.maxFrames?(g=!0,Y(null),!1):!0},"admit"),onStill:o(function(V,C){c&&c.sample(C);var J=V.then(function(R){C===0&&(S=R.scene,x={width:R.width,height:R.height},i.stopAt.ticks!==void 0&&(b=R.tick+i.stopAt.ticks),b!==null&&R.tick>b&&Ft("record","stopAt.tick "+b+" is already in the past \u2014 the first capture is tick "+R.tick)),u[C]={i:C,tick:R.tick,pose:R.pose},T=T.then(function(K){var N=new K.MB.VideoSample(R.data,{format:"RGBA",codedWidth:R.width,codedHeight:R.height,timestamp:C/i.fps,duration:1/i.fps});return Promise.resolve(K.source.add(N)).then(function(){return N.close(),K},function(B){throw N.close(),B})}),T.then(null,function(K){Y(K)}),b!==null&&R.tick+i.everyTicks>b&&Y(null)},function(R){Y(R)});return h.push(J),J},"onStill")}),i.signal){if(w=o(function(){g=!0,Y(null)},"onAbort"),i.signal.aborted)return w(),Q;i.signal.addEventListener("abort",w,{once:!0})}try{if(f){var H=f.waypoints.length-1;f.onWaypoint(function(V){V.index===H&&Y(null)}),f.start()}}catch(V){Y(V)}return Q}function jw(e){if(!e||typeof e.capture!="function"||typeof e.captureStill!="function"||typeof e.sceneRecord!="function")throw new Error("[FrqtlVision.attach] needs an FrqtlApp exposing capture(stage), captureStill() and sceneRecord() (the RENDER_STAGES tap contract). (FAIL-LOUD.)");var t=lr;return{stages:t.RENDER_STAGES.slice(),finalStage:t.finalStage,getScene:o(function(){return e.sceneRecord()},"getScene"),getStill:o(function(r){return r===void 0?e.captureStill():e.capture(r)},"getStill"),getStream:o(function(r){return Ew(e,t,r)},"getStream"),record:o(function(r){try{return Cw(e,t,r)}catch(i){return Promise.reject(i)}},"record"),toDataURL:Tm,toPNG:Cm}}var Sw,km,kw,Kn,ql=ue(()=>{Na();Ml();il();Nf();Va();Vf();o(Bf,"_rgba8Format");o(Am,"_assertImageable");o(Tm,"toDataURL");o(Cm,"toPNG");o(Ft,"_fail");o(Hn,"_requirePosInt");o(zl,"_assertKnownKeys");o(jm,"_sample");o(Ew,"_getStream");Sw=["everyTicks","stopAt","maxFrames","fps","stage","bitrate","keyFrameInterval","signal"],km=["tick","ticks","path"],kw=["waypoints","loop","waypointTimeoutMs"];o(Aw,"_normalizeRecord");o(Tw,"_loadEncoder");o(Cw,"_record");o(jw,"attach");Kn={attach:jw,toDataURL:Tm,toPNG:Cm};Ua.registerRecorder(Kn)});var Xo={};ge(Xo,{HEAT_STOPS:()=>Qo,heatColor:()=>Rw,heatRgb:()=>Rm});function Rm(e){var t=Number(e);isFinite(t)||(t=0);var r=t<0?0:t>1?1:t,i=r*(Qo.length-1),n=Math.min(Qo.length-2,Math.floor(i)),a=i-n,s=Qo[n],l=Qo[n+1];return[Math.round(s[0]+(l[0]-s[0])*a),Math.round(s[1]+(l[1]-s[1])*a),Math.round(s[2]+(l[2]-s[2])*a)]}function Rw(e){var t=Rm(e);return"rgb("+t[0]+","+t[1]+","+t[2]+")"}var Qo,Gf=ue(()=>{Qo=Object.freeze([Object.freeze([12,24,70]),Object.freeze([20,130,190]),Object.freeze([40,190,120]),Object.freeze([235,210,60]),Object.freeze([235,70,45])]);o(Rm,"heatRgb");o(Rw,"heatColor")});var Yf={};ge(Yf,{GraphingDetectorWall:()=>Nt});function Kf(e,t){var r,i,n=0,a=0;Array.isArray(e)?e.length>=6?(r=e[1],n=e[2],i=e[4],a=e[5]):(r=e[1],i=e[3]):e&&(r=e.top,i=e.h,typeof e.z=="number"&&(n=e.z),typeof e.d=="number"&&(a=e.d)),r=Number(r)||0,i=Math.max(1,Number(i)||1),a=Math.max(0,Number(a)||0);var s=typeof t=="number"&&t>0?t:12,l=Math.min(1,Dw/Math.max(i,a||1));return{top:r,height:i,z0:n,depth:a,binPx:s,canvasW:a>0?Math.max(1,Math.round(a*l)):Lw,canvasH:Math.max(1,Math.round(i*l))}}function Vl(e,t,r){return t+Math.floor((Number(e)-t)/r)*r}function Lm(e,t,r){var i=e.binPx,n=e.canvasH/e.height,a=Vl(t,e.top,i),s={x:0,y:(a-e.top)*n,w:e.canvasW,h:i*n};if(e.depth>0){var l=e.canvasW/e.depth,c=Vl(r,e.z0,i);s.x=(c-e.z0)*l,s.w=i*l}return s}function Pm(e,t){var r=[],i=0;if(!e||typeof e.forEach!="function")return{cells:r,maxV:i};var n=t.binPx,a=new Map;return e.forEach(function(s,l){if(!(!s||typeof s.forEach!="function")){var c=Vl(l,t.top,n);s.forEach(function(f,u){var h=t.depth>0?Vl(u,t.z0,n):t.z0,g=c+","+h;a.set(g,(a.get(g)||0)+(Number(f)||0))})}}),a.forEach(function(s,l){var c=l.split(",");s>i&&(i=s),r.push({y:Number(c[0]),z:Number(c[1]),v:s})}),{cells:r,maxV:i}}function Im(e,t,r,i){i=i||{};var n=Xo,a=n.heatColor,s=n.heatRgb(0),l=typeof i.heatBase=="number"?i.heatBase:.35;e.clearRect(0,0,t.canvasW,t.canvasH),e.fillStyle="rgba("+s[0]+","+s[1]+","+s[2]+","+l+")",e.fillRect(0,0,t.canvasW,t.canvasH);for(var c=Pm(r,t),f=0;f<c.cells.length;f++){var u=c.cells[f],h=Lm(t,u.y,u.z);e.fillStyle=a(c.maxV>0?u.v/c.maxV:0),e.fillRect(h.x,h.y,h.w,h.h)}return c.cells.length}function Hf(e,t){return typeof e=="number"&&isFinite(e)?e:t}function Nt(e,t){if(t=t||{},t.preset===void 0&&t.collisionBehavior===void 0){var r={};Object.keys(t).forEach(function(a){r[a]=t[a]}),r.preset="detector-screen",t=r}_e.call(this,e,t),this._schemaKind=this.constructor.name,this.binPx=Hf(t.binPx,12),this.refreshMs=Hf(t.refreshMs,100),this.heatBase=Hf(t.heatBase,.35);var i=Array.isArray(this.hooks)&&this.hooks.indexOf("count")!==-1;if(!i)throw new Error('[GraphingDetectorWall] this wall does not COUNT (collisionBehavior "'+this.collisionBehavior+'", hooks '+JSON.stringify(this.hooks||[])+') \u2014 a graphing detector needs the count hook (the "detector-screen" preset supplies it), or it would paint an eternally empty grid. (FAIL-LOUD.)');this._faceSpec=Kf(this._trueRect,this.binPx),this._canvas=this._makeCanvas(t.makeCanvas),this.lo.liveCanvas=this._canvas,this._lastPaintMs=0,this._paintedBins=0,this._drainedTickData=void 0;var n=this;this._paintTickFn=o(function(s){n._tick(s)},"graphingDetectorWallTick"),e&&Array.isArray(e.experimentTickFunctions)&&e.experimentTickFunctions.push(this._paintTickFn)}var Dw,Lw,Dm,Pw,Jf=ue(()=>{At();wi();Gf();xt();Dw=512,Lw=64;o(Kf,"faceSpec");o(Vl,"binStart");o(Lm,"heatCellRect");o(Pm,"binGrid");o(Im,"paintHeatmap");o(Hf,"_num");o(Nt,"GraphingDetectorWall");Nt.prototype=Object.create(_e?_e.prototype:Object.prototype);Nt.prototype.constructor=Nt;Nt.prototype._makeCanvas=function(e){var t=this._faceSpec;if(typeof e=="function")return e(t.canvasW,t.canvasH);if(typeof document<"u"&&document.createElement){var r=document.createElement("canvas");return r.width=t.canvasW,r.height=t.canvasH,r}return null};Nt.prototype.setRect=function(e){_e.prototype.setRect.call(this,e),this._faceSpec=Kf(this._trueRect,this.binPx);var t=this._canvas;return t&&(t.width!==this._faceSpec.canvasW||t.height!==this._faceSpec.canvasH)&&(t.width=this._faceSpec.canvasW,t.height=this._faceSpec.canvasH),this.repaintHeatmap(),this};Nt.prototype.heatCanvas=function(){return this._canvas};Nt.prototype.paintedBins=function(){return this._paintedBins};Nt.prototype._tick=function(e){var t=e&&e.objects?e:this.universe&&this.universe._lastTickData?this.universe._lastTickData:null;t&&t!==this._drainedTickData&&(this._drainedTickData=t,this.getCollisionHistogram(t));var r=typeof Date<"u"?Date.now():0;this.refreshMs>0&&r-this._lastPaintMs<this.refreshMs||(this._lastPaintMs=r,this.repaintHeatmap())};Nt.prototype.repaintHeatmap=function(){if(!this._canvas||typeof this._canvas.getContext!="function")return 0;var e=this._canvas.getContext("2d");if(!e)return 0;var t=this.getCollisionHistogram();return this._paintedBins=Im(e,this._faceSpec,t&&t.grid,{heatBase:this.heatBase}),this._paintedBins};Nt.prototype.dispose=function(){if(this._paintTickFn&&this.universe&&Array.isArray(this.universe.experimentTickFunctions)){var e=this.universe.experimentTickFunctions.indexOf(this._paintTickFn);e!==-1&&this.universe.experimentTickFunctions.splice(e,1),this._paintTickFn=null}_e&&_e.prototype.dispose&&_e.prototype.dispose.call(this)};Nt.faceSpec=Kf;Nt.heatCellRect=Lm;Nt.binGrid=Pm;Nt.paintHeatmap=Im;Dm=Dt(_e).descriptor,Pw={description:"A counting detector screen that draws its OWN hit heatmap on its faces: collisions are binned over the wall face (y\xD7z) and painted as colour cells exactly where they landed \u2014 the wall is the axis, so there are no chart axes, labels or margins in the scene. Extends Wall (defaults to the detector-screen preset: destroy + count); zero physics of its own.",ux:Dm.ux,fields:Dm.fields.concat([{name:"binPx",type:"number",constraint:{min:1,integer:!0},engineVisible:!1,unit:"px",widgetHint:"slider",description:"Face bin size in physics pixels (default 12) \u2014 the heatmap cell pitch. Smaller resolves finer structure but each cell holds fewer hits (noisier); larger smooths. The SAME binning the DOM topology chart applies to the same grid."},{name:"refreshMs",type:"number",constraint:{min:0,integer:!0},engineVisible:!1,unit:"ms",description:"Heatmap repaint throttle in milliseconds (default 100). Hit accumulation is per-tick and never throttled \u2014 only the repaint is gated, so no counts are lost."},{name:"heatBase",type:"number",constraint:{min:0,max:1},engineVisible:!1,widgetHint:"slider",description:"Opacity (0..1, default 0.35) of the heat ramp's ZERO colour washed UNDER the cells, so an un-hit face still reads as a solid plate and intensity rises monotonically from empty through every bin. Render-only."}])};at(Nt,{from:new URL("frqtl/parts/GraphingDetectorWall.js",ze()).href,descriptor:Pw,defaults:{w:20,h:200,binPx:12,refreshMs:100,heatBase:.35,color:[120,200,120]},palette:{displayName:"Graphing Detector Wall",category:"measurement",iconHint:"detector",rank:3},build:o(function(e,t,r){var i=r,n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a]);if(n.rect==null&&n.left==null){var s=n.w!=null?n.w:20,l=n.h!=null?n.h:200;n.left=Math.round(t.x-s/2),n.top=Math.round(t.y-l/2),n.w=s,n.h=l}var c=new i(t.runner.universe,n);return c._schemaKind=r.name,c},"build")})});var Qf,Gi,Fm=ue(()=>{Qf={exports:{}};(function(e,t,r){(function(i,n){typeof t=="object"&&typeof e<"u"?e.exports=n():typeof r=="function"&&r.amd?r(n):i.chroma=n()})(this,function(){"use strict";for(var i=function(p,v,_){return v===void 0&&(v=0),_===void 0&&(_=1),p<v?v:_<p?_:p},n={},a=0,s=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];a<s.length;a+=1){var l=s[a];n["[object "+l+"]"]=l.toLowerCase()}var c=o(function(p){return n[Object.prototype.toString.call(p)]||"object"},"Y"),f=Math.PI,u={clip_rgb:o(function(p){p._clipped=!1,p._unclipped=p.slice(0);for(var v=0;v<=3;v++)v<3?((p[v]<0||255<p[v])&&(p._clipped=!0),p[v]=i(p[v],0,255)):v===3&&(p[v]=i(p[v],0,1));return p},"clip_rgb"),limit:i,type:c,unpack:o(function(p,v){return v===void 0&&(v=null),3<=p.length?Array.prototype.slice.call(p):c(p[0])=="object"&&v?v.split("").filter(function(_){return p[0][_]!==void 0}).map(function(_){return p[0][_]}):p[0]},"unpack"),last:o(function(p){if(p.length<2)return null;var v=p.length-1;return c(p[v])=="string"?p[v].toLowerCase():null},"last"),PI:f,TWOPI:2*f,PITHIRD:f/3,DEG2RAD:f/180,RAD2DEG:180/f},h={format:{},autodetect:[]},g=u.last,d=u.clip_rgb,m=u.type,b=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];if(m(p[0])==="object"&&p[0].constructor&&p[0].constructor===this.constructor)return p[0];var _=g(p),k=!1;if(!_){k=!0,h.sorted||(h.autodetect=h.autodetect.sort(function(q,Z){return Z.p-q.p}),h.sorted=!0);for(var P=0,F=h.autodetect;P<F.length;P+=1){var D=F[P];if(_=D.test.apply(D,p))break}}if(!h.format[_])throw new Error("unknown format: "+p);var M=h.format[_].apply(null,k?p:p.slice(0,-1));this._rgb=d(M),this._rgb.length===3&&this._rgb.push(1)},"u");b.prototype.toString=function(){return m(this.hex)=="function"?this.hex():"["+this._rgb.join(",")+"]"};var y=b,w=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];return new(Function.prototype.bind.apply(w.Color,[null].concat(p)))},"h");w.Color=y,w.version="2.1.0";var x=w,S=u.unpack,A=Math.max,T=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _=S(p,"rgb"),k=_[0],P=_[1],F=_[2],D=1-A(k/=255,A(P/=255,F/=255)),M=D<1?1/(1-D):0;return[(1-k-D)*M,(1-P-D)*M,(1-F-D)*M,D]},"p"),j=u.unpack,Q=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _=(p=j(p,"cmyk"))[0],k=p[1],P=p[2],F=p[3],D=4<p.length?p[4]:1;return F===1?[0,0,0,D]:[1<=_?0:255*(1-_)*(1-F),1<=k?0:255*(1-k)*(1-F),1<=P?0:255*(1-P)*(1-F),D]},"v"),Y=u.unpack,H=u.type;y.prototype.cmyk=function(){return T(this._rgb)},x.cmyk=function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(p,["cmyk"])))},h.format.cmyk=Q,h.autodetect.push({p:2,test:o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];if(p=Y(p,"cmyk"),H(p)==="array"&&p.length===4)return"cmyk"},"test")});var V=u.unpack,C=u.last,J=o(function(p){return Math.round(100*p)/100},"M"),R=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _=V(p,"hsla"),k=C(p)||"lsa";return _[0]=J(_[0]||0),_[1]=J(100*_[1])+"%",_[2]=J(100*_[2])+"%",k==="hsla"||3<_.length&&_[3]<1?(_[3]=3<_.length?_[3]:1,k="hsla"):_.length=3,k+"("+_.join(",")+")"},"N"),K=u.unpack,N=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _=(p=K(p,"rgba"))[0],k=p[1],P=p[2];_/=255,k/=255,P/=255;var F,D,M=Math.min(_,k,P),q=Math.max(_,k,P),Z=(q+M)/2;return q===M?(F=0,D=Number.NaN):F=Z<.5?(q-M)/(q+M):(q-M)/(2-q-M),_==q?D=(k-P)/(q-M):k==q?D=2+(P-_)/(q-M):P==q&&(D=4+(_-k)/(q-M)),(D*=60)<0&&(D+=360),3<p.length&&p[3]!==void 0?[D,F,Z,p[3]]:[D,F,Z]},"E"),B=u.unpack,ie=u.last,oe=Math.round,$=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _=B(p,"rgba"),k=ie(p)||"rgb";return k.substr(0,3)=="hsl"?R(N(_),k):(_[0]=oe(_[0]),_[1]=oe(_[1]),_[2]=oe(_[2]),(k==="rgba"||3<_.length&&_[3]<1)&&(_[3]=3<_.length?_[3]:1,k="rgba"),k+"("+_.slice(0,k==="rgb"?3:4).join(",")+")")},"j"),pe=u.unpack,ye=Math.round,ce=o(function(){for(var p,v=[],_=arguments.length;_--;)v[_]=arguments[_];var k,P,F,D=(v=pe(v,"hsl"))[0],M=v[1],q=v[2];if(M===0)k=P=F=255*q;else{var Z=[0,0,0],le=[0,0,0],ae=q<.5?q*(1+M):q+M-q*M,we=2*q-ae,he=D/360;Z[0]=he+1/3,Z[1]=he,Z[2]=he-1/3;for(var Te=0;Te<3;Te++)Z[Te]<0&&(Z[Te]+=1),1<Z[Te]&&(Z[Te]-=1),6*Z[Te]<1?le[Te]=we+6*(ae-we)*Z[Te]:2*Z[Te]<1?le[Te]=ae:3*Z[Te]<2?le[Te]=we+(ae-we)*(2/3-Z[Te])*6:le[Te]=we;k=(p=[ye(255*le[0]),ye(255*le[1]),ye(255*le[2])])[0],P=p[1],F=p[2]}return 3<v.length?[k,P,F,v[3]]:[k,P,F,1]},"L"),L=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,ee=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,X=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,te=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,be=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,Oe=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,Ue=Math.round,Ce=o(function(p){var v;if(p=p.toLowerCase().trim(),h.format.named)try{return h.format.named(p)}catch{}if(v=p.match(L)){for(var _=v.slice(1,4),k=0;k<3;k++)_[k]=+_[k];return _[3]=1,_}if(v=p.match(ee)){for(var P=v.slice(1,5),F=0;F<4;F++)P[F]=+P[F];return P}if(v=p.match(X)){for(var D=v.slice(1,4),M=0;M<3;M++)D[M]=Ue(2.55*D[M]);return D[3]=1,D}if(v=p.match(te)){for(var q=v.slice(1,5),Z=0;Z<3;Z++)q[Z]=Ue(2.55*q[Z]);return q[3]=+q[3],q}if(v=p.match(be)){var le=v.slice(1,4);le[1]*=.01,le[2]*=.01;var ae=ce(le);return ae[3]=1,ae}if(v=p.match(Oe)){var we=v.slice(1,4);we[1]*=.01,we[2]*=.01;var he=ce(we);return he[3]=+v[4],he}},"z");Ce.test=function(p){return L.test(p)||ee.test(p)||X.test(p)||te.test(p)||be.test(p)||Oe.test(p)};var xe=Ce,Ve=u.type;y.prototype.css=function(p){return $(this._rgb,p)},x.css=function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(p,["css"])))},h.format.css=xe,h.autodetect.push({p:5,test:o(function(p){for(var v=[],_=arguments.length-1;0<_--;)v[_]=arguments[_+1];if(!v.length&&Ve(p)==="string"&&xe.test(p))return"css"},"test")});var Ot=u.unpack;h.format.gl=function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _=Ot(p,"rgba");return _[0]*=255,_[1]*=255,_[2]*=255,_},x.gl=function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(p,["gl"])))},y.prototype.gl=function(){var p=this._rgb;return[p[0]/255,p[1]/255,p[2]/255,p[3]]};var Wt=u.unpack,zt=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _,k=Wt(p,"rgb"),P=k[0],F=k[1],D=k[2],M=Math.min(P,F,D),q=Math.max(P,F,D),Z=q-M,le=100*Z/255,ae=M/(255-Z)*100;return Z===0?_=Number.NaN:(P===q&&(_=(F-D)/Z),F===q&&(_=2+(D-P)/Z),D===q&&(_=4+(P-F)/Z),(_*=60)<0&&(_+=360)),[_,le,ae]},"X"),se=u.unpack,ve=Math.floor,Lt=o(function(){for(var p,v,_,k,P,F,D=[],M=arguments.length;M--;)D[M]=arguments[M];var q,Z,le,ae=(D=se(D,"hcg"))[0],we=D[1],he=D[2];he*=255;var Te=255*we;if(we===0)q=Z=le=he;else{ae===360&&(ae=0),360<ae&&(ae-=360),ae<0&&(ae+=360);var et=ve(ae/=60),Ke=ae-et,ft=he*(1-we),ht=ft+Te*(1-Ke),Rt=ft+Te*Ke,ar=ft+Te;switch(et){case 0:q=(p=[ar,Rt,ft])[0],Z=p[1],le=p[2];break;case 1:q=(v=[ht,ar,ft])[0],Z=v[1],le=v[2];break;case 2:q=(_=[ft,ar,Rt])[0],Z=_[1],le=_[2];break;case 3:q=(k=[ft,ht,ar])[0],Z=k[1],le=k[2];break;case 4:q=(P=[Rt,ft,ar])[0],Z=P[1],le=P[2];break;case 5:q=(F=[ar,ft,ht])[0],Z=F[1],le=F[2]}}return[q,Z,le,3<D.length?D[3]:1]},"K"),ct=u.unpack,Kt=u.type;y.prototype.hcg=function(){return zt(this._rgb)},x.hcg=function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(p,["hcg"])))},h.format.hcg=Lt,h.autodetect.push({p:1,test:o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];if(p=ct(p,"hcg"),Kt(p)==="array"&&p.length===3)return"hcg"},"test")});var Et=u.unpack,ut=u.last,ot=Math.round,Qr=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _=Et(p,"rgba"),k=_[0],P=_[1],F=_[2],D=_[3],M=ut(p)||"auto";D===void 0&&(D=1),M==="auto"&&(M=D<1?"rgba":"rgb");var q="000000"+((k=ot(k))<<16|(P=ot(P))<<8|(F=ot(F))).toString(16);q=q.substr(q.length-6);var Z="0"+ot(255*D).toString(16);switch(Z=Z.substr(Z.length-2),M.toLowerCase()){case"rgba":return"#"+q+Z;case"argb":return"#"+Z+q;default:return"#"+q}},"tr"),Yt=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,hr=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,_n=o(function(p){if(p.match(Yt)){p.length!==4&&p.length!==7||(p=p.substr(1)),p.length===3&&(p=(p=p.split(""))[0]+p[0]+p[1]+p[1]+p[2]+p[2]);var v=parseInt(p,16);return[v>>16,v>>8&255,255&v,1]}if(p.match(hr)){p.length!==5&&p.length!==9||(p=p.substr(1)),p.length===4&&(p=(p=p.split(""))[0]+p[0]+p[1]+p[1]+p[2]+p[2]+p[3]+p[3]);var _=parseInt(p,16);return[_>>24&255,_>>16&255,_>>8&255,Math.round((255&_)/255*100)/100]}throw new Error("unknown hex color: "+p)},"or"),xn=u.type;y.prototype.hex=function(p){return Qr(this._rgb,p)},x.hex=function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(p,["hex"])))},h.format.hex=_n,h.autodetect.push({p:4,test:o(function(p){for(var v=[],_=arguments.length-1;0<_--;)v[_]=arguments[_+1];if(!v.length&&xn(p)==="string"&&0<=[3,4,5,6,7,8,9].indexOf(p.length))return"hex"},"test")});var pr=u.unpack,tr=u.TWOPI,fo=Math.min,ua=Math.sqrt,fa=Math.acos,ho=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _,k=pr(p,"rgb"),P=k[0],F=k[1],D=k[2],M=fo(P/=255,F/=255,D/=255),q=(P+F+D)/3,Z=0<q?1-M/q:0;return Z===0?_=NaN:(_=(P-F+(P-D))/2,_/=ua((P-F)*(P-F)+(P-D)*(F-D)),_=fa(_),F<D&&(_=tr-_),_/=tr),[360*_,Z,q]},"sr"),fi=u.unpack,Ci=u.limit,Fr=u.TWOPI,po=u.PITHIRD,hi=Math.cos,Kc=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _,k,P,F=(p=fi(p,"hsi"))[0],D=p[1],M=p[2];return isNaN(F)&&(F=0),isNaN(D)&&(D=0),360<F&&(F-=360),F<0&&(F+=360),(F/=360)<1/3?k=1-((P=(1-D)/3)+(_=(1+D*hi(Fr*F)/hi(po-Fr*F))/3)):F<2/3?P=1-((_=(1-D)/3)+(k=(1+D*hi(Fr*(F-=1/3))/hi(po-Fr*F))/3)):_=1-((k=(1-D)/3)+(P=(1+D*hi(Fr*(F-=2/3))/hi(po-Fr*F))/3)),[255*(_=Ci(M*_*3)),255*(k=Ci(M*k*3)),255*(P=Ci(M*P*3)),3<p.length?p[3]:1]},"yr"),Yc=u.unpack,Ls=u.type;y.prototype.hsi=function(){return ho(this._rgb)},x.hsi=function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(p,["hsi"])))},h.format.hsi=Kc,h.autodetect.push({p:2,test:o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];if(p=Yc(p,"hsi"),Ls(p)==="array"&&p.length===3)return"hsi"},"test")});var mo=u.unpack,go=u.type;y.prototype.hsl=function(){return N(this._rgb)},x.hsl=function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(p,["hsl"])))},h.format.hsl=ce,h.autodetect.push({p:2,test:o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];if(p=mo(p,"hsl"),go(p)==="array"&&p.length===3)return"hsl"},"test")});var Ps=u.unpack,Is=Math.min,Jc=Math.max,Qc=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _,k,P,F=(p=Ps(p,"rgb"))[0],D=p[1],M=p[2],q=Is(F,D,M),Z=Jc(F,D,M),le=Z-q;return P=Z/255,Z===0?(_=Number.NaN,k=0):(k=le/Z,F===Z&&(_=(D-M)/le),D===Z&&(_=2+(M-F)/le),M===Z&&(_=4+(F-D)/le),(_*=60)<0&&(_+=360)),[_,k,P]},"Er"),Xc=u.unpack,Zc=Math.floor,$c=o(function(){for(var p,v,_,k,P,F,D=[],M=arguments.length;M--;)D[M]=arguments[M];var q,Z,le,ae=(D=Xc(D,"hsv"))[0],we=D[1],he=D[2];if(he*=255,we===0)q=Z=le=he;else{ae===360&&(ae=0),360<ae&&(ae-=360),ae<0&&(ae+=360);var Te=Zc(ae/=60),et=ae-Te,Ke=he*(1-we),ft=he*(1-we*et),ht=he*(1-we*(1-et));switch(Te){case 0:q=(p=[he,ht,Ke])[0],Z=p[1],le=p[2];break;case 1:q=(v=[ft,he,Ke])[0],Z=v[1],le=v[2];break;case 2:q=(_=[Ke,he,ht])[0],Z=_[1],le=_[2];break;case 3:q=(k=[Ke,ft,he])[0],Z=k[1],le=k[2];break;case 4:q=(P=[ht,Ke,he])[0],Z=P[1],le=P[2];break;case 5:q=(F=[he,Ke,ft])[0],Z=F[1],le=F[2]}}return[q,Z,le,3<D.length?D[3]:1]},"Or"),eu=u.unpack,tu=u.type;y.prototype.hsv=function(){return Qc(this._rgb)},x.hsv=function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(p,["hsv"])))},h.format.hsv=$c,h.autodetect.push({p:2,test:o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];if(p=eu(p,"hsv"),tu(p)==="array"&&p.length===3)return"hsv"},"test")});var ha=18,Fs=.95047,On=1,Zi=1.08883,pa=.137931034,Ns=.206896552,vo=.12841855,da=.008856452,ru=u.unpack,Ms=Math.pow,yo=o(function(p){return(p/=255)<=.04045?p/12.92:Ms((p+.055)/1.055,2.4)},"zr"),ma=o(function(p){return da<p?Ms(p,1/3):p/vo+pa},"Tr"),iu=o(function(p,v,_){return p=yo(p),v=yo(v),_=yo(_),[ma((.4124564*p+.3575761*v+.1804375*_)/Fs),ma((.2126729*p+.7151522*v+.072175*_)/On),ma((.0193339*p+.119192*v+.9503041*_)/Zi)]},"Ur"),E=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _=ru(p,"rgb"),k=_[0],P=_[1],F=_[2],D=iu(k,P,F),M=D[0],q=D[1],Z=116*q-16;return[Z<0?0:Z,500*(M-q),200*(q-D[2])]},"Vr"),I=u.unpack,z=Math.pow,G=o(function(p){return 255*(p<=.00304?12.92*p:1.055*z(p,1/2.4)-.055)},"Hr"),U=o(function(p){return Ns<p?p*p*p:vo*(p-pa)},"Jr"),fe=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _,k,P,F=(p=I(p,"lab"))[0],D=p[1],M=p[2];return k=(F+16)/116,_=isNaN(D)?k:k+D/500,P=isNaN(M)?k:k-M/200,k=On*U(k),_=Fs*U(_),P=Zi*U(P),[G(3.2404542*_-1.5371385*k-.4985314*P),G(-.969266*_+1.8760108*k+.041556*P),G(.0556434*_-.2040259*k+1.0572252*P),3<p.length?p[3]:1]},"Kr"),re=u.unpack,Ge=u.type;y.prototype.lab=function(){return E(this._rgb)},x.lab=function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(p,["lab"])))},h.format.lab=fe,h.autodetect.push({p:2,test:o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];if(p=re(p,"lab"),Ge(p)==="array"&&p.length===3)return"lab"},"test")});var rt=u.unpack,Ne=u.RAD2DEG,Fe=Math.sqrt,it=Math.atan2,He=Math.round,Pe=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _=rt(p,"lab"),k=_[0],P=_[1],F=_[2],D=Fe(P*P+F*F),M=(it(F,P)*Ne+360)%360;return He(1e4*D)===0&&(M=Number.NaN),[k,D,M]},"fe"),kt=u.unpack,Ie=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _=kt(p,"rgb"),k=_[0],P=_[1],F=_[2],D=E(k,P,F),M=D[0],q=D[1],Z=D[2];return Pe(M,q,Z)},"ue"),nt=u.unpack,St=u.DEG2RAD,dr=Math.sin,Jt=Math.cos,jt=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _=nt(p,"lch"),k=_[0],P=_[1],F=_[2];return isNaN(F)&&(F=0),[k,Jt(F*=St)*P,dr(F)*P]},"de"),pi=u.unpack,Nr=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _=(p=pi(p,"lch"))[0],k=p[1],P=p[2],F=jt(_,k,P),D=F[0],M=F[1],q=F[2],Z=fe(D,M,q);return[Z[0],Z[1],Z[2],3<p.length?p[3]:1]},"be"),Xr=u.unpack,mr=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _=Xr(p,"hcl").reverse();return Nr.apply(void 0,_)},"ge"),jr=u.unpack,Mr=u.type;y.prototype.lch=function(){return Ie(this._rgb)},y.prototype.hcl=function(){return Ie(this._rgb).reverse()},x.lch=function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(p,["lch"])))},x.hcl=function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(p,["hcl"])))},h.format.lch=Nr,h.format.hcl=mr,["lch","hcl"].forEach(function(p){return h.autodetect.push({p:2,test:o(function(){for(var v=[],_=arguments.length;_--;)v[_]=arguments[_];if(v=jr(v,p),Mr(v)==="array"&&v.length===3)return p},"test")})});var gt={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflower:"#6495ed",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},ji=u.type;y.prototype.name=function(){for(var p=Qr(this._rgb,"rgb"),v=0,_=Object.keys(gt);v<_.length;v+=1){var k=_[v];if(gt[k]===p)return k.toLowerCase()}return p},h.format.named=function(p){if(p=p.toLowerCase(),gt[p])return _n(gt[p]);throw new Error("unknown color name: "+p)},h.autodetect.push({p:5,test:o(function(p){for(var v=[],_=arguments.length-1;0<_--;)v[_]=arguments[_+1];if(!v.length&&ji(p)==="string"&>[p.toLowerCase()])return"named"},"test")});var Ur=u.unpack,En=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _=Ur(p,"rgb");return(_[0]<<16)+(_[1]<<8)+_[2]},"Me"),Qt=u.type,di=o(function(p){if(Qt(p)=="number"&&0<=p&&p<=16777215)return[p>>16,p>>8&255,255&p,1];throw new Error("unknown num color: "+p)},"_e"),Sn=u.type;y.prototype.num=function(){return En(this._rgb)},x.num=function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(p,["num"])))},h.format.num=di,h.autodetect.push({p:5,test:o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];if(p.length===1&&Sn(p[0])==="number"&&0<=p[0]&&p[0]<=16777215)return"num"},"test")});var Rr=u.unpack,Ri=u.type,Us=Math.round;y.prototype.rgb=function(p){return p===void 0&&(p=!0),p===!1?this._rgb.slice(0,3):this._rgb.slice(0,3).map(Us)},y.prototype.rgba=function(p){return p===void 0&&(p=!0),this._rgb.slice(0,4).map(function(v,_){return _<3?p===!1?v:Us(v):v})},x.rgb=function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(p,["rgb"])))},h.format.rgb=function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];var _=Rr(p,"rgba");return _[3]===void 0&&(_[3]=1),_},h.autodetect.push({p:3,test:o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];if(p=Rr(p,"rgba"),Ri(p)==="array"&&(p.length===3||p.length===4&&Ri(p[3])=="number"&&0<=p[3]&&p[3]<=1))return"rgb"},"test")});var kn=Math.log,zs=o(function(p){var v,_,k,P=p/100;return k=P<66?(v=255,_=-155.25485562709179-.44596950469579133*(_=P-2)+104.49216199393888*kn(_),P<20?0:.8274096064007395*(k=P-10)-254.76935184120902+115.67994401066147*kn(k)):(v=351.97690566805693+.114206453784165*(v=P-55)-40.25366309332127*kn(v),_=325.4494125711974+.07943456536662342*(_=P-50)-28.0852963507957*kn(_),255),[v,_,k,1]},"Oe"),qs=u.unpack,nu=Math.round,Vs=o(function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];for(var _,k=qs(p,"rgb"),P=k[0],F=k[2],D=1e3,M=4e4;.4<M-D;){var q=zs(_=.5*(M+D));q[2]/q[0]>=F/P?M=_:D=_}return nu(_)},"qe");y.prototype.temp=y.prototype.kelvin=y.prototype.temperature=function(){return Vs(this._rgb)},x.temp=x.kelvin=x.temperature=function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];return new(Function.prototype.bind.apply(y,[null].concat(p,["temp"])))},h.format.temp=h.format.kelvin=h.format.temperature=zs;var au=u.type;y.prototype.alpha=function(p,v){return v===void 0&&(v=!1),p!==void 0&&au(p)==="number"?v?(this._rgb[3]=p,this):new y([this._rgb[0],this._rgb[1],this._rgb[2],p],"rgb"):this._rgb[3]},y.prototype.clipped=function(){return this._rgb._clipped||!1},y.prototype.darken=function(p){p===void 0&&(p=1);var v=this.lab();return v[0]-=ha*p,new y(v,"lab").alpha(this.alpha(),!0)},y.prototype.brighten=function(p){return p===void 0&&(p=1),this.darken(-p)},y.prototype.darker=y.prototype.darken,y.prototype.brighter=y.prototype.brighten,y.prototype.get=function(p){var v=p.split("."),_=v[0],k=v[1],P=this[_]();if(k){var F=_.indexOf(k);if(-1<F)return P[F];throw new Error("unknown channel "+k+" in mode "+_)}return P};var ou=u.type,Bs=Math.pow;y.prototype.luminance=function(p){if(p===void 0||ou(p)!=="number")return An.apply(void 0,this._rgb.slice(0,3));if(p===0)return new y([0,0,0,this._rgb[3]],"rgb");if(p===1)return new y([255,255,255,this._rgb[3]],"rgb");var v=this.luminance(),_=20,k=o(function(F,D){var M=F.interpolate(D,.5,"rgb"),q=M.luminance();return Math.abs(p-q)<1e-7||!_--?M:p<q?k(F,M):k(M,D)},"o"),P=(p<v?k(new y([0,0,0]),this):k(this,new y([255,255,255]))).rgb();return new y(P.concat([this._rgb[3]]))};var An=o(function(p,v,_){return .2126*(p=Di(p))+.7152*(v=Di(v))+.0722*(_=Di(_))},"Be"),Di=o(function(p){return(p/=255)<=.03928?p/12.92:Bs((p+.055)/1.055,2.4)},"Ce"),qt={},rr=u.type,Zr=o(function(p,v,_){_===void 0&&(_=.5);for(var k=[],P=arguments.length-3;0<P--;)k[P]=arguments[P+3];var F=k[0]||"lrgb";if(qt[F]||k.length||(F=Object.keys(qt)[0]),!qt[F])throw new Error("interpolation mode "+F+" is not defined");return rr(p)!=="object"&&(p=new y(p)),rr(v)!=="object"&&(v=new y(v)),qt[F](p,v,_).alpha(p.alpha()+_*(v.alpha()-p.alpha()))},"$e");y.prototype.mix=y.prototype.interpolate=function(p,v){v===void 0&&(v=.5);for(var _=[],k=arguments.length-2;0<k--;)_[k]=arguments[k+2];return Zr.apply(void 0,[this,p,v].concat(_))},y.prototype.premultiply=function(p){p===void 0&&(p=!1);var v=this._rgb,_=v[3];return p?(this._rgb=[v[0]*_,v[1]*_,v[2]*_,_],this):new y([v[0]*_,v[1]*_,v[2]*_,_],"rgb")},y.prototype.saturate=function(p){p===void 0&&(p=1);var v=this.lch();return v[1]+=ha*p,v[1]<0&&(v[1]=0),new y(v,"lch").alpha(this.alpha(),!0)},y.prototype.desaturate=function(p){return p===void 0&&(p=1),this.saturate(-p)};var mi=u.type;y.prototype.set=function(p,v,_){_===void 0&&(_=!1);var k=p.split("."),P=k[0],F=k[1],D=this[P]();if(F){var M=P.indexOf(F);if(-1<M){if(mi(v)=="string")switch(v.charAt(0)){case"+":case"-":D[M]+=+v;break;case"*":D[M]*=+v.substr(1);break;case"/":D[M]/=+v.substr(1);break;default:D[M]=+v}else{if(mi(v)!=="number")throw new Error("unsupported value for Color.set");D[M]=v}var q=new y(D,P);return _?(this._rgb=q._rgb,this):q}throw new Error("unknown channel "+F+" in mode "+P)}return D},qt.rgb=function(p,v,_){var k=p._rgb,P=v._rgb;return new y(k[0]+_*(P[0]-k[0]),k[1]+_*(P[1]-k[1]),k[2]+_*(P[2]-k[2]),"rgb")};var $r=Math.sqrt,Dr=Math.pow;qt.lrgb=function(p,v,_){var k=p._rgb,P=k[0],F=k[1],D=k[2],M=v._rgb,q=M[0],Z=M[1],le=M[2];return new y($r(Dr(P,2)*(1-_)+Dr(q,2)*_),$r(Dr(F,2)*(1-_)+Dr(Z,2)*_),$r(Dr(D,2)*(1-_)+Dr(le,2)*_),"rgb")},qt.lab=function(p,v,_){var k=p.lab(),P=v.lab();return new y(k[0]+_*(P[0]-k[0]),k[1]+_*(P[1]-k[1]),k[2]+_*(P[2]-k[2]),"lab")};var Li=o(function(p,v,_,k){var P,F,D,M,q,Z,le,ae,we,he,Te,et;return k==="hsl"?(D=p.hsl(),M=v.hsl()):k==="hsv"?(D=p.hsv(),M=v.hsv()):k==="hcg"?(D=p.hcg(),M=v.hcg()):k==="hsi"?(D=p.hsi(),M=v.hsi()):k!=="lch"&&k!=="hcl"||(k="hcl",D=p.hcl(),M=v.hcl()),k.substr(0,1)==="h"&&(q=(P=D)[0],le=P[1],we=P[2],Z=(F=M)[0],ae=F[1],he=F[2]),isNaN(q)||isNaN(Z)?isNaN(q)?isNaN(Z)?et=Number.NaN:(et=Z,we!=1&&we!=0||k=="hsv"||(Te=ae)):(et=q,he!=1&&he!=0||k=="hsv"||(Te=le)):et=q+_*(q<Z&&180<Z-q?Z-(q+360):Z<q&&180<q-Z?Z+360-q:Z-q),Te===void 0&&(Te=le+_*(ae-le)),new y([et,Te,we+_*(he-we)],k)},"Ue"),ga=o(function(p,v,_){return Li(p,v,_,"lch")},"Ve");qt.lch=ga,qt.hcl=ga,qt.num=function(p,v,_){var k=p.num(),P=v.num();return new y(k+_*(P-k),"num")},qt.hcg=function(p,v,_){return Li(p,v,_,"hcg")},qt.hsi=function(p,v,_){return Li(p,v,_,"hsi")},qt.hsl=function(p,v,_){return Li(p,v,_,"hsl")},qt.hsv=function(p,v,_){return Li(p,v,_,"hsv")};var su=u.clip_rgb,$i=Math.pow,bo=Math.sqrt,en=Math.PI,Tn=Math.cos,Cn=Math.sin,Ws=Math.atan2,jn=o(function(p,v){for(var _=p.length,k=[0,0,0,0],P=0;P<p.length;P++){var F=p[P],D=v[P]/_,M=F._rgb;k[0]+=$i(M[0],2)*D,k[1]+=$i(M[1],2)*D,k[2]+=$i(M[2],2)*D,k[3]+=M[3]*D}return k[0]=bo(k[0]),k[1]=bo(k[1]),k[2]=bo(k[2]),.9999999<k[3]&&(k[3]=1),new y(su(k))},"rn"),ei=u.type,Lr=Math.pow,gr=o(function(p){var v="rgb",_=x("#ccc"),k=0,P=[0,1],F=[],D=[0,0],M=!1,q=[],Z=!1,le=0,ae=1,we=!1,he={},Te=!0,et=1,Ke=o(function(ne){if((ne=ne||["#fff","#000"])&&ei(ne)==="string"&&x.brewer&&x.brewer[ne.toLowerCase()]&&(ne=x.brewer[ne.toLowerCase()]),ei(ne)==="array"){ne.length===1&&(ne=[ne[0],ne[0]]),ne=ne.slice(0);for(var De=0;De<ne.length;De++)ne[De]=x(ne[De]);for(var Ye=F.length=0;Ye<ne.length;Ye++)F.push(Ye/(ne.length-1))}return ar(),q=ne},"a"),ft=o(function(ne){return ne},"w"),ht=o(function(ne){return ne},"k"),Rt=o(function(ne,De){var Ye,Je;if(De==null&&(De=!1),isNaN(ne)||ne===null)return _;De?Je=ne:Je=M&&2<M.length?(function(Pt){if(M==null)return 0;for(var dt=M.length-1,Ze=0;Ze<dt&&Pt>=M[Ze];)Ze++;return Ze-1})(ne)/(M.length-2):ae!==le?(ne-le)/(ae-le):1,Je=ht(Je),De||(Je=ft(Je)),et!==1&&(Je=Lr(Je,et)),Je=D[0]+Je*(1-D[0]-D[1]),Je=Math.min(1,Math.max(0,Je));var Vr=Math.floor(1e4*Je);if(Te&&he[Vr])Ye=he[Vr];else{if(ei(q)==="array")for(var pt=0;pt<F.length;pt++){var vt=F[pt];if(Je<=vt){Ye=q[pt];break}if(vt<=Je&&pt===F.length-1){Ye=q[pt];break}if(vt<Je&&Je<F[pt+1]){Je=(Je-vt)/(F[pt+1]-vt),Ye=x.interpolate(q[pt],q[pt+1],Je,v);break}}else ei(q)==="function"&&(Ye=q(Je));Te&&(he[Vr]=Ye)}return Ye},"M"),ar=o(function(){return he={}},"f");Ke(p);var qe=o(function(ne){var De=x(Rt(ne));return Z&&De[Z]?De[Z]():De},"N");return qe.classes=function(ne){if(ne==null)return M;if(ei(ne)==="array")P=[(M=ne)[0],ne[ne.length-1]];else{var De=x.analyze(P);M=ne===0?[De.min,De.max]:x.limits(De,"e",ne)}return qe},qe.domain=function(ne){if(!arguments.length)return P;le=ne[0],ae=ne[ne.length-1],F=[];var De=q.length;if(ne.length===De&&le!==ae)for(var Ye=0,Je=Array.from(ne);Ye<Je.length;Ye+=1){var Vr=Je[Ye];F.push((Vr-le)/(ae-le))}else{for(var pt=0;pt<De;pt++)F.push(pt/(De-1));if(2<ne.length){var vt=ne.map(function(dt,Ze){return Ze/(ne.length-1)}),Pt=ne.map(function(dt){return(dt-le)/(ae-le)});Pt.every(function(dt,Ze){return vt[Ze]===dt})||(ht=o(function(dt){if(dt<=0||1<=dt)return dt;for(var Ze=0;dt>=Pt[Ze+1];)Ze++;var yr=(dt-Pt[Ze])/(Pt[Ze+1]-Pt[Ze]);return vt[Ze]+yr*(vt[Ze+1]-vt[Ze])},"k"))}}return P=[le,ae],qe},qe.mode=function(ne){return arguments.length?(v=ne,ar(),qe):v},qe.range=function(ne,De){return Ke(ne),qe},qe.out=function(ne){return Z=ne,qe},qe.spread=function(ne){return arguments.length?(k=ne,qe):k},qe.correctLightness=function(ne){return ne==null&&(ne=!0),we=ne,ar(),ft=we?function(De){for(var Ye=Rt(0,!0).lab()[0],Je=Rt(1,!0).lab()[0],Vr=Je<Ye,pt=Rt(De,!0).lab()[0],vt=Ye+(Je-Ye)*De,Pt=pt-vt,dt=0,Ze=1,yr=20;.01<Math.abs(Pt)&&0<yr--;)Vr&&(Pt*=-1),De+=Pt<0?.5*(Ze-(dt=De)):.5*(dt-(Ze=De)),pt=Rt(De,!0).lab()[0],Pt=pt-vt;return De}:function(De){return De},qe},qe.padding=function(ne){return ne!=null?(ei(ne)==="number"&&(ne=[ne,ne]),D=ne,qe):D},qe.colors=function(ne,De){arguments.length<2&&(De="hex");var Ye=[];if(arguments.length===0)Ye=q.slice(0);else if(ne===1)Ye=[qe(.5)];else if(1<ne){var Je=P[0],Vr=P[1]-Je;Ye=(function(Ze,yr,_a){for(var Dn=[],Ii=Ze<yr,xa=_a?Ii?yr+1:yr-1:yr,gi=Ze;Ii?gi<xa:xa<gi;Ii?gi++:gi--)Dn.push(gi);return Dn})(0,ne,!1).map(function(Ze){return qe(Je+Ze/(ne-1)*Vr)})}else{p=[];var pt=[];if(M&&2<M.length)for(var vt=1,Pt=M.length,dt=1<=Pt;dt?vt<Pt:Pt<vt;dt?vt++:vt--)pt.push(.5*(M[vt-1]+M[vt]));else pt=P;Ye=pt.map(function(Ze){return qe(Ze)})}return x[De]&&(Ye=Ye.map(function(Ze){return Ze[De]()})),Ye},qe.cache=function(ne){return ne!=null?(Te=ne,qe):Te},qe.gamma=function(ne){return ne!=null?(et=ne,qe):et},qe.nodata=function(ne){return ne!=null?(_=x(ne),qe):_},qe},"tn"),Re=o(function(p){var v,_,k,P,F,D,M;if((p=p.map(function(ae){return new y(ae)})).length===2)v=p.map(function(ae){return ae.lab()}),F=v[0],D=v[1],P=o(function(ae){var we=[0,1,2].map(function(he){return F[he]+ae*(D[he]-F[he])});return new y(we,"lab")},"a");else if(p.length===3)_=p.map(function(ae){return ae.lab()}),F=_[0],D=_[1],M=_[2],P=o(function(ae){var we=[0,1,2].map(function(he){return(1-ae)*(1-ae)*F[he]+2*(1-ae)*ae*D[he]+ae*ae*M[he]});return new y(we,"lab")},"a");else if(p.length===4){var q;k=p.map(function(ae){return ae.lab()}),F=k[0],D=k[1],M=k[2],q=k[3],P=o(function(ae){var we=[0,1,2].map(function(he){return(1-ae)*(1-ae)*(1-ae)*F[he]+3*(1-ae)*(1-ae)*ae*D[he]+3*(1-ae)*ae*ae*M[he]+ae*ae*ae*q[he]});return new y(we,"lab")},"a")}else if(p.length===5){var Z=Re(p.slice(0,3)),le=Re(p.slice(2,5));P=o(function(ae){return ae<.5?Z(2*ae):le(2*(ae-.5))},"a")}return P},"an"),ir=o(function(p,v,_){if(!ir[_])throw new Error("unknown blend mode "+_);return ir[_](p,v)},"fn"),zr=o(function(p){return function(v,_){var k=x(_).rgb(),P=x(v).rgb();return x.rgb(p(k,P))}},"on"),qr=o(function(p){return function(v,_){var k=[];return k[0]=p(v[0],_[0]),k[1]=p(v[1],_[1]),k[2]=p(v[2],_[2]),k}},"un");ir.normal=zr(qr(function(p){return p})),ir.multiply=zr(qr(function(p,v){return p*v/255})),ir.screen=zr(qr(function(p,v){return 255*(1-(1-p/255)*(1-v/255))})),ir.overlay=zr(qr(function(p,v){return v<128?2*p*v/255:255*(1-2*(1-p/255)*(1-v/255))})),ir.darken=zr(qr(function(p,v){return v<p?v:p})),ir.lighten=zr(qr(function(p,v){return v<p?p:v})),ir.dodge=zr(qr(function(p,v){return p===255||255<(p=v/255*255/(1-p/255))?255:p})),ir.burn=zr(qr(function(p,v){return 255*(1-(1-v/255)/(p/255))}));for(var Rn=ir,Xt=u.type,nr=u.clip_rgb,vr=u.TWOPI,va=Math.pow,Gs=Math.sin,Hs=Math.cos,tn=Math.floor,wo=Math.random,Pi=Math.log,_o=Math.pow,ya=Math.floor,xo=Math.abs,Ks=function(p,v){v===void 0&&(v=null);var _={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0};return c(p)==="object"&&(p=Object.values(p)),p.forEach(function(k){v&&c(k)==="object"&&(k=k[v]),k==null||isNaN(k)||(_.values.push(k),_.sum+=k,k<_.min&&(_.min=k),k>_.max&&(_.max=k),_.count+=1)}),_.domain=[_.min,_.max],_.limits=function(k,P){return Ys(_,k,P)},_},Ys=function(p,v,_){v===void 0&&(v="equal"),_===void 0&&(_=7),c(p)=="array"&&(p=Ks(p));var k=p.min,P=p.max,F=p.values.sort(function(pu,du){return pu-du});if(_===1)return[k,P];var D=[];if(v.substr(0,1)==="c"&&(D.push(k),D.push(P)),v.substr(0,1)==="e"){D.push(k);for(var M=1;M<_;M++)D.push(k+M/_*(P-k));D.push(P)}else if(v.substr(0,1)==="l"){if(k<=0)throw new Error("Logarithmic scales are only possible for values > 0");var q=Math.LOG10E*Pi(k),Z=Math.LOG10E*Pi(P);D.push(k);for(var le=1;le<_;le++)D.push(_o(10,q+le/_*(Z-q)));D.push(P)}else if(v.substr(0,1)==="q"){D.push(k);for(var ae=1;ae<_;ae++){var we=(F.length-1)*ae/_,he=ya(we);if(he===we)D.push(F[he]);else{var Te=we-he;D.push(F[he]*(1-Te)+F[he+1]*Te)}}D.push(P)}else if(v.substr(0,1)==="k"){var et,Ke=F.length,ft=new Array(Ke),ht=new Array(_),Rt=!0,ar=0,qe=null;(qe=[]).push(k);for(var ne=1;ne<_;ne++)qe.push(k+ne/_*(P-k));for(qe.push(P);Rt;){for(var De=0;De<_;De++)ht[De]=0;for(var Ye=0;Ye<Ke;Ye++)for(var Je=F[Ye],Vr=Number.MAX_VALUE,pt=void 0,vt=0;vt<_;vt++){var Pt=xo(qe[vt]-Je);Pt<Vr&&(Vr=Pt,pt=vt),ht[pt]++,ft[Ye]=pt}for(var dt=new Array(_),Ze=0;Ze<_;Ze++)dt[Ze]=null;for(var yr=0;yr<Ke;yr++)dt[et=ft[yr]]===null?dt[et]=F[yr]:dt[et]+=F[yr];for(var _a=0;_a<_;_a++)dt[_a]*=1/ht[_a];Rt=!1;for(var Dn=0;Dn<_;Dn++)if(dt[Dn]!==qe[Dn]){Rt=!0;break}qe=dt,200<++ar&&(Rt=!1)}for(var Ii={},xa=0;xa<_;xa++)Ii[xa]=[];for(var gi=0;gi<Ke;gi++)Ii[et=ft[gi]].push(F[gi]);for(var Ln=[],Eo=0;Eo<_;Eo++)Ln.push(Ii[Eo][0]),Ln.push(Ii[Eo][Ii[Eo].length-1]);Ln=Ln.sort(function(pu,du){return pu-du}),D.push(Ln[0]);for(var fu=1;fu<Ln.length;fu+=2){var hu=Ln[fu];isNaN(hu)||D.indexOf(hu)!==-1||D.push(hu)}}return D},Js={analyze:Ks,limits:Ys},ba=Math.sqrt,lu=Math.atan2,wa=Math.abs,Qs=Math.cos,Oo=Math.PI,cu={cool:o(function(){return gr([x.hsl(180,1,.9),x.hsl(250,.7,.4)])},"cool"),hot:o(function(){return gr(["#000","#f00","#ff0","#fff"]).mode("rgb")},"hot")},rn={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},uu=0,id=Object.keys(rn);uu<id.length;uu+=1){var nd=id[uu];rn[nd.toLowerCase()]=rn[nd]}var ib=rn;return x.average=function(p,v,_){v===void 0&&(v="lrgb"),_===void 0&&(_=null);var k=p.length;_||(_=Array.from(new Array(k)).map(function(){return 1}));var P=k/_.reduce(function(et,Ke){return et+Ke});if(_.forEach(function(et,Ke){_[Ke]*=P}),p=p.map(function(et){return new y(et)}),v==="lrgb")return jn(p,_);for(var F=p.shift(),D=F.get(v),M=[],q=0,Z=0,le=0;le<D.length;le++)if(D[le]=(D[le]||0)*_[0],M.push(isNaN(D[le])?0:_[0]),v.charAt(le)==="h"&&!isNaN(D[le])){var ae=D[le]/180*en;q+=Tn(ae)*_[0],Z+=Cn(ae)*_[0]}var we=F.alpha()*_[0];p.forEach(function(et,Ke){var ft=et.get(v);we+=et.alpha()*_[Ke+1];for(var ht=0;ht<D.length;ht++)if(!isNaN(ft[ht]))if(M[ht]+=_[Ke+1],v.charAt(ht)==="h"){var Rt=ft[ht]/180*en;q+=Tn(Rt)*_[Ke+1],Z+=Cn(Rt)*_[Ke+1]}else D[ht]+=ft[ht]*_[Ke+1]});for(var he=0;he<D.length;he++)if(v.charAt(he)==="h"){for(var Te=Ws(Z/M[he],q/M[he])/en*180;Te<0;)Te+=360;for(;360<=Te;)Te-=360;D[he]=Te}else D[he]=D[he]/M[he];return we/=k,new y(D,v).alpha(.99999<we?1:we,!0)},x.bezier=function(p){var v=Re(p);return v.scale=function(){return gr(v)},v},x.blend=Rn,x.cubehelix=function(p,v,_,k,P){p===void 0&&(p=300),v===void 0&&(v=-1.5),_===void 0&&(_=1),k===void 0&&(k=1),P===void 0&&(P=[0,1]);var F,D=0;Xt(P)==="array"?F=P[1]-P[0]:(F=0,P=[P,P]);var M=o(function(q){var Z=vr*((p+120)/360+v*q),le=va(P[0]+F*q,k),ae=(D!==0?_[0]+q*D:_)*le*(1-le)/2,we=Hs(Z),he=Gs(Z);return x(nr([255*(le+ae*(-.14861*we+1.78277*he)),255*(le+ae*(-.29227*we-.90649*he)),255*(le+ae*(1.97294*we)),1]))},"e");return M.start=function(q){return q==null?p:(p=q,M)},M.rotations=function(q){return q==null?v:(v=q,M)},M.gamma=function(q){return q==null?k:(k=q,M)},M.hue=function(q){return q==null?_:(Xt(_=q)==="array"?(D=_[1]-_[0])==0&&(_=_[1]):D=0,M)},M.lightness=function(q){return q==null?P:(F=Xt(q)==="array"?(P=q)[1]-q[0]:(P=[q,q],0),M)},M.scale=function(){return x.scale(M)},M.hue(_),M},x.mix=x.interpolate=Zr,x.random=function(){for(var p="#",v=0;v<6;v++)p+="0123456789abcdef".charAt(tn(16*wo()));return new y(p,"hex")},x.scale=gr,x.analyze=Js.analyze,x.contrast=function(p,v){p=new y(p),v=new y(v);var _=p.luminance(),k=v.luminance();return k<_?(_+.05)/(k+.05):(k+.05)/(_+.05)},x.deltaE=function(p,v,_,k){_===void 0&&(_=1),k===void 0&&(k=1),p=new y(p),v=new y(v);for(var P=Array.from(p.lab()),F=P[0],D=P[1],M=P[2],q=Array.from(v.lab()),Z=q[0],le=q[1],ae=q[2],we=ba(D*D+M*M),he=ba(le*le+ae*ae),Te=F<16?.511:.040975*F/(1+.01765*F),et=.0638*we/(1+.0131*we)+.638,Ke=we<1e-6?0:180*lu(M,D)/Oo;Ke<0;)Ke+=360;for(;360<=Ke;)Ke-=360;var ft=164<=Ke&&Ke<=345?.56+wa(.2*Qs(Oo*(Ke+168)/180)):.36+wa(.4*Qs(Oo*(Ke+35)/180)),ht=we*we*we*we,Rt=ba(ht/(ht+1900)),ar=et*(Rt*ft+1-Rt),qe=we-he,ne=D-le,De=M-ae,Ye=(F-Z)/(_*Te),Je=qe/(k*et);return ba(Ye*Ye+Je*Je+(ne*ne+De*De-qe*qe)/(ar*ar))},x.distance=function(p,v,_){_===void 0&&(_="lab"),p=new y(p),v=new y(v);var k=p.get(_),P=v.get(_),F=0;for(var D in k){var M=(k[D]||0)-(P[D]||0);F+=M*M}return Math.sqrt(F)},x.limits=Js.limits,x.valid=function(){for(var p=[],v=arguments.length;v--;)p[v]=arguments[v];try{return new(Function.prototype.bind.apply(y,[null].concat(p))),!0}catch{return!1}},x.scales=cu,x.colors=gt,x.brewer=ib,x})}).call(void 0,Qf,Qf.exports,void 0);Gi=Qf.exports});var Xf={};ge(Xf,{LightColor:()=>Ei});function Iw(e){for(var t=Object.keys(Oi),r=t[t.length-1],i=0;i<t.length;i++)if(e<=Oi[t[i]]){r=t[i];break}if(r===t[0]){var n=Gi(r).rgb();return[Math.round(n[0]),Math.round(n[1]),Math.round(n[2])]}var a=t.indexOf(r),s=t[a-1],l=(e-Oi[s])/(Oi[r]-Oi[s]),c=Gi.mix(s,r,isNaN(l)?0:l),f=c.rgb();return[Math.round(f[0]),Math.round(f[1]),Math.round(f[2])]}function Fw(e){for(var t=Math.max(0,Math.min(1,e)),r=Yn[0],i=Yn[Yn.length-1],n=0;n<Yn.length-1;n++)if(t<=Yn[n+1].threshold){r=Yn[n],i=Yn[n+1];break}var a=i.threshold-r.threshold,s=a>0?(t-r.threshold)/a:0,l=Gi.mix(Gi.rgb(r.rgb),Gi.rgb(i.rgb),s),c=l.rgb();return[Math.round(c[0]),Math.round(c[1]),Math.round(c[2])]}function Nw(e,t){var r=Math.max(0,Math.min(1,e)),i=t!=null?Math.max(0,Math.min(1,t)):.35;return i+r*(1-i)}function Mm(e){return Fw(e)}function Mw(e){var t=Math.max(0,Math.min(1,e)),r=Gi.mix(Gi.rgb(Nm[0].rgb),Gi.rgb(Nm[1].rgb),t),i=r.rgb();return[Math.round(i[0]),Math.round(i[1]),Math.round(i[2])]}function Um(e){return Mw(e)}function Uw(e,t){return e==="roygbiv"?Mm(t):e==="greyscale"?Um(t):zm(t)}function zm(e){return Iw(e)}function zw(e){for(var t=Object.keys(Oi),r=0;r<t.length;r++)if(e<=Oi[t[r]])return t[r];return"pink"}function qw(e){return Oi[e]!==void 0?Oi[e]:.5}var Oi,Yn,Nm,Ei,Ba=ue(()=>{Fm();Oi={red:.1,orange:.2,yellow:.3,green:.4,cyan:.5,blue:.6,indigo:.7,violet:.8,pink:.9},Yn=[{threshold:0,name:"red",rgb:[255,0,0]},{threshold:1/6,name:"orange",rgb:[255,127,0]},{threshold:2/6,name:"yellow",rgb:[255,255,0]},{threshold:3/6,name:"green",rgb:[0,200,0]},{threshold:4/6,name:"blue",rgb:[0,0,255]},{threshold:5/6,name:"indigo",rgb:[75,0,130]},{threshold:1,name:"violet",rgb:[148,0,211]}];o(Iw,"_chromaWarmcool");o(Fw,"_chromaRoygbiv");o(Nw,"getAlphaFromIntensity");o(Mm,"getRgbColorFromFrequency");Nm=[{threshold:0,name:"greyscale-dark",rgb:[60,60,60]},{threshold:1,name:"greyscale-light",rgb:[235,235,235]}];o(Mw,"_chromaGreyscale");o(Um,"getRgbColorFromGreyscale");o(Uw,"getRgbBySchemeName");o(zm,"getRgbColorFromFullness");o(zw,"getColorNameFor");o(qw,"getFullnessForColorName");Ei={fullnessColorMap:Oi,getRgbColorFromFullness:zm,getRgbColorFromFrequency:Mm,getRgbColorFromGreyscale:Um,getRgbBySchemeName:Uw,getAlphaFromIntensity:Nw,getColorNameFor:zw,getFullnessForColorName:qw}});var Zf={};ge(Zf,{LiveChart:()=>Jn});function qm(e){return!!e&&(typeof e.getCollisionHistogram=="function"||typeof e.getAbsorbStats=="function"||typeof e.getLiveCount=="function")}function Vw(e,t){if(!e||typeof e.getObjectByName!="function")throw new Error("[ObjectFactory] a named LiveChart source resolves through runner.getObjectByName (the declared-object registry); this runner has none. (FAIL-LOUD.)");return e.getObjectByName(t,qm)}var Jn,Bw,$f=ue(()=>{At();_r();Vt();ln();xt();Jn=class{static{o(this,"LiveChart")}constructor(){throw new Error("[LiveChart] LiveChart is a kind token \u2014 declare it with exp.addObject(LiveChart, props) (or exp.addObject('LiveChart', props)); its build returns the chart. (FAIL-LOUD.)")}};o(qm,"_isChartSource");o(Vw,"_resolveHistogramSource");Bw={description:"An in-scene live chart panel that plots a counting Wall's running y\u2192count histogram (getCollisionHistogram) as the sim runs. A render-only LargeObject (NONE collision, zero physics) \u2014 the Chart.js chart renders to an offscreen canvas and is composited into the scene as a texture/image, so it moves and scales with the scene. Point it at a detect/count Wall; a non-counting source fails loud.",ux:{resizable:!0,draggable:{"2d":!0},shellRender:"run"},fields:[{name:"rect",type:"rect",engineVisible:!1,unit:"px",description:"Placement + size of the chart panel in physics pixels "+bt(4)+". Render-only \u2014 never a collision region."},{name:"source",type:"string",engineVisible:!1,description:"Name of the source Wall that feeds this chart (a direct wall handle is also accepted at construction). For projector detectorHistogram: a detect/count wall (getCollisionHistogram). For projector absorberStats: an ABSORB wall (getAbsorbStats). For projector liveCount: a count-hook wall (getLiveCount). A source lacking the projector's read method fails loud at wire time."},{name:"projector",type:"enum",constraint:{values:{detectorHistogram:"detectorHistogram",absorberStats:"absorberStats",liveCount:"liveCount",detectorSurface:"detectorSurface"}},engineVisible:!1,description:"The blessed live-chart projector to poll (default detectorHistogram). detectorHistogram = a counting Wall's y\u2192count column-profile (fringes); absorberStats = an ABSORB Wall's {stored,absorbed,radiated} mass ledger; liveCount = a counting Wall's per-tick collided-frame count (a full-area background wall's live population); detectorSurface = the SAME counting Wall's hits binned over its FACE (y\xD7z) and drawn as a topology heightfield \u2014 the 3D instrument, where a detector is a plane and the fringes read as ridges. One vocabulary, owned by live-chart-controller's LIVE_CHART_PROJECTORS."},{name:"series",type:"enum",constraint:{values:{bar:"bar",line:"line"}},engineVisible:!1,description:"Chart series kind: bar (default, a histogram) or line."},{name:"orientation",type:"enum",constraint:{values:{0:"0",90:"90"}},engineVisible:!1,live:!0,description:"Chart orientation in degrees. 0 = standard vertical bars (bins along x). 90 = the GYM detector-histogram presentation: HORIZONTAL bars stacked along y (Chart.js indexAxis:y, y-axis reversed to run top-down) so a detector column-profile aligns SPATIALLY with the vertical detector wall beside it. Default: 90 for a detectorHistogram chart (detector-aligned), 0 otherwise. Live-editable in the Inspector."},{name:"label",type:"string",engineVisible:!1,description:"Dataset label shown in the chart legend (default = the source name)."},{name:"refreshMs",type:"number",constraint:{min:16,integer:!0},engineVisible:!1,unit:"ms",description:"Redraw cadence in ms (default 100 \u2192 ~10 fps). Caps Chart.js redraw cost regardless of tick rate; accumulation still runs EVERY tick (no dropped counts)."},{name:"visible",type:"boolean",engineVisible:!1,live:!0,description:"Whether the chart panel is rendered (render-only)."},{name:"alpha",type:"number",constraint:{min:0,max:255,integer:!0},engineVisible:!1,live:!0,widgetHint:"slider",description:"Render opacity 0-255 (render-only)."}]};at(Jn,{from:new URL("frqtl/parts/LiveChart.js",ze()).href,descriptor:Bw,defaults:{w:200,h:140,projector:"detectorHistogram",series:"bar",refreshMs:100,color:[30,40,55]},palette:{displayName:"Live Chart",category:"measurement",iconHint:"chart",rank:4},build:o(function(e,t,r){var i=Se,n=Ee,a=e.rect,s,l,c,f;Array.isArray(a)?a.length>=6?(c=a[0],f=a[1],s=a[3],l=a[4]):(c=a[0],f=a[1],s=a[2],l=a[3]):a&&a.left!=null?(c=a.left,f=a.top,s=a.w,l=a.h):(s=e.w||200,l=e.h||140,c=Math.round(t.x-s/2),f=Math.round(t.y-l/2));var u=e.name||"livechart "+(t.runner.largeObjects.length+1),h=e.color||[30,40,55],g=new i(t.runner.universe,[c,f,s,l],n.NONE,[],u,"closest",null,1,h);e.alpha!=null&&(g.alpha=e.alpha),e.visible!=null&&(g.visible=e.visible),g._schemaKind=r.name;var d=e.source,m=null,b=null;if(d&&typeof d=="object"&&qm(d))m=d,b=typeof d.name=="string"?d.name:null;else if(typeof d=="string"&&d){if(b=d,m=Vw(t.runner,d),!m)throw new Error('[ObjectFactory] LiveChart source wall "'+d+'" not found among the registered objects \u2014 a LiveChart must be pointed at an already-added counting/absorbing Wall (by name or handle). (FAIL-LOUD.)')}else if(d!=null)throw new Error("[ObjectFactory] LiveChart `source` must be a Wall handle (exposing getCollisionHistogram or getAbsorbStats) or its name string; got "+typeof d+". (FAIL-LOUD.)");var y=e.projector||"detectorHistogram",w;return e.orientation===90||e.orientation==="90"?w=90:e.orientation===0||e.orientation==="0"?w=0:w=y==="detectorHistogram"?90:0,g.orientation=String(w),g.chartSpec={source:b,sourceHandle:m,projector:y,kind:e.series==="line"?"line":"bar",label:e.label||b||"detector",refreshMs:typeof e.refreshMs=="number"?e.refreshMs:100,orientation:w},g.source=b,g.projector=y,g.series=g.chartSpec.kind,g.label=g.chartSpec.label,g.refreshMs=g.chartSpec.refreshMs,g.liveCanvas=null,g},"build")})});var Wa={};ge(Wa,{BEHAVIORS:()=>Ww,LEGACY_VARIANT_MAP:()=>eh,applyLinerScatter:()=>th,buildLinerProgram:()=>Bm,resolveLegacyVariant:()=>Vm});function Vm(e){if(e==null)return null;if(!Object.prototype.hasOwnProperty.call(eh,e))throw new Error("[slitLinerScatter] unknown slitScatter legacy variant: "+e);return eh[e]}function Bm(e,t,r,i,n,a,s,l,c){var f=r.Lit,u=r.Bin,h=r.Cond,g=r.Cmp,d=r.Fn,m=r.Ref,b=r.HANDLE_FRAME,y=r.HANDLE_SELF,w=o(function(){return u("-",u("*",d("random",[]),f(2)),f(1))},"randomSigned"),x=o(function(){return h(g("<",d("random",[]),f(.5)),f(0),f(1))},"chargeDraw"),S,A,T;if(e==="ejectY"||e==="ejectYReflect")S=i(l,b,y,f,m,u,g,h,d)||[],A=e==="ejectYReflect"?[{set:b+".vy",to:u("*",m(b,"vy"),f(-1))}]:[],T=!1;else if(e==="randomXY"){var j=n(["BLOCK"],a,s,Ee.NONE);S=j.program?j.program.ops:[],A=[{set:b+".vx",to:d("random",[])},{set:b+".vy",to:w()}],c&&A.push({set:b+".vz",to:w()}),T=!0}else if(e==="symmetric"){var Q=n(["BLOCK"],a,s,Ee.NONE);S=Q.program?Q.program.ops:[],A=[{set:b+".vx",to:w()},{set:b+".vy",to:w()}],c&&A.push({set:b+".vz",to:w()}),T=!0}else if(e==="bounce"){var Y=n(["BLOCK"],a,s,Ee.NONE);S=Y.program?Y.program.ops:[],A=[{set:b+".vy",to:u("*",m(b,"vy"),f(-1))}],T=!1}else throw new Error("[slitLinerScatter] unknown behavior: "+e);var H=S.concat(A);return t&&(H=H.concat([{set:b+".local_time",to:f(0)}])),T&&(H=H.concat([{set:b+".charge",to:x()}])),H}function th(e,t,r,i){i=i||{};var n;if(i.behavior!==void 0?n={behavior:i.behavior,resetLocalTime:!!i.resetLocalTime}:n=Vm(i.slitScatter),n!==null){var a=Zt,s=Bm(n.behavior,n.resetLocalTime,a,Ni,Ta,e.name,e.reposition,r,!!i.hasRealDepth),l={on:"collision",ops:s},c=an(e.reposition||null,!1,a.HANDLE_FRAME,a.HANDLE_SELF,a.Lit,a.Ref,a.Cmp,a.Cond,a.Fn);vi(l,c),e.program=l,t&&typeof t.updateObjectProperty=="function"&&t.updateObjectProperty(e.handle,"LargeObject","program",l)}}var Ww,eh,Bl=ue(()=>{Mn();In();Vt();Ww=["randomXY","symmetric","bounce","ejectY","ejectYReflect"],eh={current:null,noreset:{behavior:"randomXY",resetLocalTime:!1},symmetric:{behavior:"symmetric",resetLocalTime:!0},combined:{behavior:"symmetric",resetLocalTime:!1},bounce:{behavior:"bounce",resetLocalTime:!1},ejectY:{behavior:"ejectY",resetLocalTime:!1},ejectYReflect:{behavior:"ejectYReflect",resetLocalTime:!1}};o(Vm,"resolveLegacyVariant");o(Bm,"buildLinerProgram");o(th,"applyLinerScatter")});var Wl={};ge(Wl,{buildRedirectApplier:()=>rh});function rh(e,t){t=t||{};var r=t.wallHandles||[],i=t.angleRad;if(typeof i!="number"||!isFinite(i))throw new Error("[directedRedirectProgram] spec.angleRad must be a finite number (radians).");var n=t.spreadRad!==void 0&&t.spreadRad!==null?t.spreadRad:0,a=t.polarSpreadRad!==void 0&&t.polarSpreadRad!==null?t.polarSpreadRad:0,s=t.speed!==void 0?t.speed:null;return o(function(c){if(!(!c||!c.objects))for(var f=0;f<r.length;f++){var u=c.objects[r[f]];if(!(!u||!Array.isArray(u.frames)))for(var h=u.frames,g=0;g<h.length;g++){var d=h[g],m=i;n&&(m+=(e.random()*2-1)*n);var b=s!==null?s:Math.sqrt(d.vx*d.vx+d.vy*d.vy)||1,y=0;a&&(y=(e.random()*2-1)*a);var w=Math.cos(m)*Math.cos(y)*b,x=Math.sin(m)*Math.cos(y)*b,S=Math.sin(y)*b;e.setFrameProperty(d.id,"vx",w),e.setFrameProperty(d.id,"vy",x),a&&e.setFrameProperty(d.id,"vz",S)}}},"applyRedirect")}var ih=ue(()=>{"use strict";o(rh,"buildRedirectApplier")});function Gw(e,t){if(Math.abs(e.length-t.length)>2)return 99;var r=[],i=[],n,a;for(a=0;a<=t.length;a++)r[a]=a;for(n=1;n<=e.length;n++){for(i[0]=n,a=1;a<=t.length;a++)i[a]=Math.min(r[a]+1,i[a-1]+1,r[a-1]+(e.charAt(n-1)===t.charAt(a-1)?0:1));r=i.slice()}return r[t.length]}function Hw(e,t){for(var r=null,i=3,n=e.toLowerCase(),a=0;a<t.length;a++){var s=Gw(n,String(t[a]).toLowerCase());s<i&&(i=s,r=t[a])}return r}function Ga(e,t,r){if(t==null)return{};if(typeof t!="object"||Array.isArray(t))throw new Error("["+e+"] options must be a plain object, got "+(Array.isArray(t)?"an array":typeof t)+". Legal keys: "+r.slice().sort().join(", ")+".");for(var i=r.slice().sort(),n=Object.keys(t),a=0;a<n.length;a++)if(r.indexOf(n[a])===-1){var s=Hw(n[a],r);throw new Error("["+e+"] unknown option '"+n[a]+"'"+(s?" \u2014 did you mean '"+s+"'?":"")+" This factory reads NONE of the keys it does not declare, so an unrecognized one would have silently resolved to a default and run a DIFFERENT experiment than you asked for. Legal options: "+i.join(", ")+".")}return t}function Zo(e,t){return Be.worldRect(t,e)}var nh=ue(()=>{bi();o(Gw,"_editDistance");o(Hw,"_suggest");o(Ga,"assertSetupOptions");o(Zo,"requireWorldRect")});function ah(e){var t=Math.pow(2,e);return t*t}var Kw,ZS,Wm=ue(()=>{"use strict";Kw={wavelength:{default:null,desc:"Per-frame wavelength override (Engine Invariant #6 mass=max(1,capacity/wavelength)). null = engine default (mass=capacity)."},charge:{default:null,desc:"Per-frame charge override (0=Positive,1=Negative). null = random draw per quantum."},velocityProfile:{default:"beam",enum:["beam","spray"],desc:"'beam' = collimated single-direction (orientationRad+speed, vy=vz=0); 'spray' = biased random fan (spraySpec)."},speed:{default:1,desc:"'beam' profile only: speed magnitude."},orientationRad:{default:0,desc:"'beam' profile only: direction, radians (0 = +X)."},spraySpec:{default:{vxMin:.2,vxRange:.6,vyMin:.1,vyRange:.7},desc:"'spray' profile only: vx=vxMin+random()*vxRange, vy=vyMin+random()*vyRange (setupTunnelLab.js's original literal fan)."},entranceBias:{default:"center",enum:["center","top"],desc:"'center' = bore Y-centreline (LightSource.js's convention); 'top' = bunched 2px from the TOP wall (setupTunnelLab.js's original biased-entry/uniformization-demo shape)."},zIsotropy:{default:!0,desc:"When real depth is armed AND velocityProfile='spray': draw vz=(random()*2-1)*spraySpec.vyRange (SAME half-range as vy) for a 3D-symmetric fan. 'beam' stays vy=vz=0 regardless (deliberate collimation)."},level:{default:null,desc:"makeLeafFrame's level override (rarely used)."},mass:{default:void 0,desc:"Post-placement mass override via setFrameProperty. undefined = no override."},density:{default:5,desc:"Quanta hand-placed per burst."},rate:{default:10,desc:"Ticks between bursts (everyNTicks cadence)."},active:{default:!0,desc:"Master on/off for the recurring source."}},ZS=Object.keys(Kw);o(ah,"capacityAtDimension")});function Jw(){return oh.map(function(e){return e.key}).join(", ")}function Hm(e,t,r){Object.keys(t).forEach(function(a){if(Object.prototype.hasOwnProperty.call(Gm,a))throw new Error(e+": '"+a+"' is not a world-cfg key \u2014 "+Gm[a]+". (FAIL-LOUD: one declaration per fact.)")});var i=r?r.constructor:null,n=i&&i.RETIRED_CONFIG_KEYS&&typeof i.RETIRED_CONFIG_KEYS=="object"?i.RETIRED_CONFIG_KEYS:null;Object.keys(t).forEach(function(a){var s=oh.some(function(c){return c.key===a});if(!s){var l=e+": unknown option '"+a+"'. Legal options: "+Jw()+".";throw n&&Object.prototype.hasOwnProperty.call(n,a)&&(l+=" That name is RETIRED at the engine \u2014 '"+a+"' "+n[a]+". Note this is the RECIPE vocabulary, not the engine option list: migrate to one of the legal options above."),new Error(l)}})}function Qw(e){if(arguments.length>1)throw new Error("FrqtlWorldInit.initArgs(cfg) takes no rect \u2014 the world rect is written ONCE, by EGPTUniverse.create({ rect, seed, \u2026 }), and universe.init(fundamentalDimension, options) reads it. (FAIL-LOUD.)");e=e||{},Hm("FrqtlWorldInit.initArgs(cfg)",e,null);var t=e.dimension!==void 0?e.dimension:2,r={wavelengthScale:e.wavelengthScale!==void 0?e.wavelengthScale:8,noEscape:e.bonding!==void 0?e.bonding:!1,frameGenMode:e.frames!==void 0&&e.frames?"topDown":"groundUp"};return e.stepping!==void 0&&e.stepping!==null&&(r.stepping=e.stepping),[t,r]}function Xw(e,t){e&&e.iframeIntervalSeconds!==void 0&&e.iframeIntervalSeconds!==null&&(t.iframe_interval_seconds=e.iframeIntervalSeconds)}var oh,Gm,Gl,sh=ue(()=>{oh=[{key:"dimension",effect:"the fundamental (base) dimension layer \u2014 universe.init()'s 1st argument. default 2."},{key:"wavelengthScale",effect:"\u2192 universe.init options.wavelengthScale \u2014 the GLOBAL \u03BB multiplier. default 8."},{key:"interQuantumCollisions",effect:"ACCEPTED BUT INERT \u2014 it fed a removed positional slot the engine never read."},{key:"bonding",effect:"\u2192 universe.init options.noEscape (the names do NOT line up 1:1). default false."},{key:"frames",effect:"BOOLEAN \u2192 universe.init options.frameGenMode: true \u2192 'topDown', false \u2192 'groundUp'. default false."},{key:"stepping",effect:"'fixed' | 'average' \u2014 the wave-walk sampler, ferried VERBATIM (never validated or defaulted here). Omitted \u21D2 the engine's default."},{key:"iframeIntervalSeconds",effect:"the parent-generation interval (s) \u2014 applied through the universe's own PRE-INIT setter (`universe.iframe_interval_seconds`) by applyPreInit(), immediately before universe.init; the engine freezes it at init. Omitted \u21D2 untouched (the engine's default)."}];o(Jw,"_initCfgKeyList");Gm={activeAxes:"the axes are the method: exp.createCanvas(w, h, cfg) is 2D, exp.createScene(w, h, d, cfg) is 3D",depth:"the depth is exp.createScene(w, h, d, cfg)'s d",canvasW:"the size is the co-init call's w, h (exp.createCanvas(w, h, cfg) / exp.createScene(w, h, d, cfg))",canvasH:"the size is the co-init call's w, h (exp.createCanvas(w, h, cfg) / exp.createScene(w, h, d, cfg))",stage:"the size is the co-init call's w, h (exp.createCanvas(w, h, cfg) / exp.createScene(w, h, d, cfg))"};o(Hm,"assertInitCfg");o(Qw,"initArgs");o(Xw,"applyPreInit");Gl={INIT_CFG:oh,assertInitCfg:Hm,initArgs:Qw,applyPreInit:Xw}});var ch={};ge(ch,{setupSphereEmitter3D:()=>cr});function Qn(e,t,r){return Math.max(t,Math.min(r,e))}function Km(e){e=Ga("setupSphereEmitter3D.worldCfg",e,Ym);var t=e.fundamentalWaveLength!==void 0?e.fundamentalWaveLength:64,r={dimension:e.fundamentalDimension!==void 0?e.fundamentalDimension:0,wavelengthScale:Math.max(1,Math.floor(t/4))};return e.stepping!==void 0&&e.stepping!==null&&(r.stepping=e.stepping),r}function Zw(){return Gl.initArgs}function $w(e,t){var r=Zw()(Km(t));r[1].activeAxes={x:!0,y:!0,z:!(t&&t.is2D)},e.init.apply(e,r)}function e_(e){var t=e.fundamentalDimension;if(typeof t!="number"||!isFinite(t)||t<0||Math.floor(t)!==t)throw new Error("setupSphereEmitter3D: the universe did not report its fundamental dimension (universe.fundamentalDimension = "+String(t)+"). An emitter that declares no fundamentalDimension/leafDimension mints at the world's own layer, read from EGPTUniverse.fundamentalDimension on an init'd world.");return t}function cr(e,t){if(t=t||{},Qm.indexOf("skipInit")!==-1&&"skipInit"in t)throw new Error("setupSphereEmitter3D: 'skipInit' is DELETED. This factory constructs a PART and never inits the world \u2014 the SKETCH does, once, before any part: setupSphereEmitter3D.initWorld(universe, opts). Remove skipInit; a second emitter on an already-init'd universe needs no flag.");t=Ga("setupSphereEmitter3D",t,lh);var r=e.universe_rect;Zo("setupSphereEmitter3D universe.universe_rect",r);var i=!!t.is2D,n=t.fundamentalDimension!==void 0||t.leafDimension!==void 0,a=t.fundamentalDimension!==void 0?t.fundamentalDimension:n?0:e_(e),s=t.leafDimension!==void 0?t.leafDimension:a,l=ah(s);s!==a&&e.addDimension(s);var c=Math.floor(r.w/2),f=Math.floor(r.h/2),u,h,g;o((function(ee,X){Array.isArray(ee)?(u=Math.round(ee[0]),h=Math.round(ee[1]),g=ee.length>2&&ee[2]!=null?Math.round(ee[2]):0):Array.isArray(X)?(u=c+Math.round(X[0]),h=f+Math.round(X[1]),g=X.length>2&&X[2]!=null?Math.round(X[2]):0):(u=c,h=f,g=0)}),"resolveCenter")(t.center,t.offset);var d={R:t.R!==void 0?t.R:24,emissionBoxSide:0,mode:t.mode!==void 0?t.mode:"ball",preset:t.preset!==void 0?t.preset:"spherical",burstSize:0,wavelength:t.wavelength!==void 0&&t.wavelength!==null?Qn(t.wavelength,1,l):null,chargeMode:t.chargeMode==="random"||t.chargeMode==="negative"||t.chargeMode==="positive"?t.chargeMode:"positive",emissionShell:t.emissionShell==="surface"?"surface":"volume",innerR:t.innerR!==void 0?Math.max(0,Math.round(t.innerR)):0,renderColor:Array.isArray(t.renderColor)?t.renderColor.slice():null,renderShape:typeof t.renderShape=="string"&&t.renderShape?t.renderShape:null,orientationDeg:typeof t.orientationDeg=="number"?t.orientationDeg:0,active:!0},m=10,b=20,y=1;d.emissionBoxSide=Qn(t.emissionBoxSide!==void 0?t.emissionBoxSide:d.preset==="particle-walk"?m:0,0,d.R),d.burstSize=t.burstSize!==void 0?t.burstSize:d.preset==="particle-walk"?b:40;var w=t.emissionBox||null,x=t.sourceShape!==void 0?t.sourceShape:null;function S(L){return Qn(L,0,d.R)}o(S,"clampBox");function A(){if(w){d.emissionBox={x:S(w.x!==void 0?w.x:0),y:S(w.y!==void 0?w.y:0),z:S(w.z!==void 0?w.z:0)},d.sourceShape=x||"box";return}if(d.preset==="particle-walk")d.emissionBox={x:0,y:S(d.emissionBoxSide),z:0},d.sourceShape=x||"box";else{var L=S(d.emissionBoxSide);d.emissionBox={x:L,y:L,z:L},d.sourceShape=x||"box"}}o(A,"deriveSourceShape"),A();var T=t.emitEveryTicks!==void 0?t.emitEveryTicks:d.preset==="particle-walk"?y:6,j={vx:[0,0],vy:[0,0],vz:[0,0]};function Q(L,ee){if(L==="laser"){var X=Math.max(1,Math.round(ee*.15)),te=[Math.round(ee*.6),ee];i?(j.vx=te,j.vy=[-X,X],j.vz=[0,0]):(j.vx=[-X,X],j.vy=[-X,X],j.vz=te)}else L==="hemisphere"?(j.vx=[0,ee],j.vy=[-ee,ee],j.vz=[-ee,ee]):L==="drum"?(j.vx=[-ee,ee],j.vy=[-ee,ee],j.vz=[0,0]):L==="particle-walk"?(j.vx=[ee,ee],j.vy=[0,0],j.vz=[0,0]):(j.vx=[-ee,ee],j.vy=[-ee,ee],j.vz=[-ee,ee])}o(Q,"applyPreset"),Q(d.preset,d.R);function Y(L){var ee=d.orientationDeg||0;if(!ee)return L;var X=ee*Math.PI/180,te=Math.cos(X),be=Math.sin(X);return[Math.round(L[0]*te-L[1]*be),Math.round(L[0]*be+L[1]*te),L[2]]}o(Y,"rotateVelocity2D");function H(){return Y(V())}o(H,"sampleVelocity");function V(){for(var L=d.R,ee=d.preset==="laser"||d.preset==="particle-walk",X=500,te=0,be=0,Oe=0,Ue=0;Ue<X;Ue++){te=Math.round(j.vx[0]+e.random()*(j.vx[1]-j.vx[0])),be=Math.round(j.vy[0]+e.random()*(j.vy[1]-j.vy[0])),Oe=i?0:Math.round(j.vz[0]+e.random()*(j.vz[1]-j.vz[0]));var Ce=te*te+be*be+Oe*Oe;if(Ce!==0){if(ee)return[te,be,Oe];if(d.mode==="shell"){var xe=.9*L;if(Ce<=L*L&&Ce>=xe*xe)return[te,be,Oe]}else if(Ce<=L*L)return[te,be,Oe]}}return[te,be,Oe]}o(V,"sampleVelocityCore");function C(){return d.chargeMode==="random"?e.random()<.5?0:1:d.chargeMode==="negative"?1:0}o(C,"sampleCharge");function J(L){return L<=0?0:-L/2+e.random()*L}o(J,"sampleOffsetAxis");function R(L){var ee=L/2;if(ee<=0)return[0,0];for(var X=200,te=0;te<X;te++){var be=-ee+e.random()*2*ee,Oe=-ee+e.random()*2*ee;if(be*be+Oe*Oe<=ee*ee)return[be,Oe]}return[0,0]}o(R,"sampleDiskOffsetYZ");function K(L,ee){if(ee<=0)return[0,0,0];var X=L[0],te=L[1],be=i?0:L[2],Oe=Math.sqrt(X*X+te*te+be*be);if(Oe<1e-9)return[0,0,0];var Ue=ee/Oe;return[Math.round(X*Ue),Math.round(te*Ue),i?0:Math.round(be*Ue)]}o(K,"shellOffsetFromVelocity");function N(){var L=d.emissionBox,ee=J(L.x);if(d.sourceShape==="disk"){var X=R(Math.max(L.y,L.z));return[ee,X[0],i?0:X[1]]}var te=J(L.y),be=i?0:J(L.z);return[ee,te,be]}o(N,"sampleSourcePosition");function B(){var L,ee,X,te;if(d.emissionShell==="surface"){L=H();var be=K(L,d.innerR);ee=be[0],X=be[1],te=be[2]}else{var Oe=N();ee=Oe[0],X=Oe[1],te=Oe[2],L=H()}var Ue=C(),Ce=u+ee,xe=h+X,Ve=g+te,Ot=e.makeLeafFrame(Ce,xe,s,d.wavelength,L[0],L[1],!1,Ue,d.renderColor,d.renderShape);if(Ot!==null){e.injectFrame(Ot);var Wt=e.getFrameQuantumId(Ot);e.setFrameProperty(Wt,"z",Ve),e.setFrameProperty(Wt,"vz",L[2]),e.setFrameProperty(Wt,"vx",L[0]),e.setFrameProperty(Wt,"vy",L[1])}}o(B,"emitOneLeaf");function ie(){for(var L=0;L<d.burstSize;L++)B()}o(ie,"emitBurst");var oe=0,$=o(function(){d.active&&oe%T===0&&ie(),oe++},"_tickFn");e.experimentTickFunctions.push($);var pe=null;function ye(){var L=pe.rect.w;pe.setRect([u-L/2,h-L/2,g-L/2,L,L,L])}o(ye,"placeMarker");var ce={setR:o(function(L){d.R=L,d.emissionBoxSide=Qn(d.emissionBoxSide,0,d.R),Q(d.preset,d.R),A()},"setR"),getR:o(function(){return d.R},"getR"),setEmissionBoxSide:o(function(L){d.emissionBoxSide=Qn(L,0,d.R),A()},"setEmissionBoxSide"),getEmissionBoxSide:o(function(){return d.emissionBoxSide},"getEmissionBoxSide"),getEmissionBox:o(function(){return{x:d.emissionBox.x,y:d.emissionBox.y,z:d.emissionBox.z}},"getEmissionBox"),getSourceShape:o(function(){return d.sourceShape},"getSourceShape"),setMode:o(function(L){d.mode=L==="shell"?"shell":"ball"},"setMode"),getMode:o(function(){return d.mode},"getMode"),setPreset:o(function(L){d.preset=L,Q(L,d.R),A()},"setPreset"),getPreset:o(function(){return d.preset},"getPreset"),setAxisRange:o(function(L,ee,X){j[L]=[ee,X]},"setAxisRange"),getAxisRange:o(function(L){return j[L].slice()},"getAxisRange"),setBurstSize:o(function(L){d.burstSize=Math.max(1,Math.round(L))},"setBurstSize"),getBurstSize:o(function(){return d.burstSize},"getBurstSize"),setEmitEveryTicks:o(function(L){T=Math.max(1,Math.round(L))},"setEmitEveryTicks"),getEmitEveryTicks:o(function(){return T},"getEmitEveryTicks"),setActive:o(function(L){d.active=!!L},"setActive"),getIs2D:o(function(){return i},"getIs2D"),setCenter:o(function(L,ee,X){u=Math.round(L),h=Math.round(ee),X!=null&&(g=Math.round(X)),pe&&ye()},"setCenter"),attachMarker:o(function(L){if(!L||!L.rect||typeof L.rect.z!="number")throw new TypeError("[setupSphereEmitter3D.attachMarker] the marker must be a z-capable LO (constructed with a 6-element rect) \u2014 it follows the centre in x, y AND z. (FAIL-LOUD.)");pe=L,ye()},"attachMarker"),getCenter:o(function(){return[u,h,g]},"getCenter"),setChargeMode:o(function(L){d.chargeMode=L==="random"||L==="negative"||L==="positive"?L:d.chargeMode},"setChargeMode"),getChargeMode:o(function(){return d.chargeMode},"getChargeMode"),setEmissionShell:o(function(L){d.emissionShell=L==="surface"?"surface":"volume"},"setEmissionShell"),getEmissionShell:o(function(){return d.emissionShell},"getEmissionShell"),setInnerR:o(function(L){d.innerR=Math.max(0,Math.round(L))},"setInnerR"),getInnerR:o(function(){return d.innerR},"getInnerR"),setWavelength:o(function(L){d.wavelength=Qn(Math.round(L),1,l)},"setWavelength"),getWavelength:o(function(){return d.wavelength!==null?d.wavelength:1},"getWavelength"),getMaxWavelength:o(function(){return l},"getMaxWavelength"),getFundamentalDimension:o(function(){return a},"getFundamentalDimension"),getLeafDimension:o(function(){return s},"getLeafDimension"),setLeafDimension:o(function(L){var ee=Math.max(0,Math.round(L));return ee===s||(ee!==a&&typeof e.addDimension=="function"&&e.addDimension(ee),s=ee,l=ah(s),d.wavelength!==null&&(d.wavelength=Qn(d.wavelength,1,l))),s},"setLeafDimension"),setRenderColor:o(function(L){d.renderColor=Array.isArray(L)?L.slice():null},"setRenderColor"),getRenderColor:o(function(){return d.renderColor?d.renderColor.slice():null},"getRenderColor"),setRenderShape:o(function(L){d.renderShape=typeof L=="string"&&L?L:null},"setRenderShape"),getRenderShape:o(function(){return d.renderShape||null},"getRenderShape"),setOrientation:o(function(L){var ee=typeof L=="number"&&isFinite(L)?L:0;d.orientationDeg=(ee%360+360)%360},"setOrientation"),getOrientation:o(function(){return d.orientationDeg||0},"getOrientation"),dispose:o(function(){var L=e.experimentTickFunctions.indexOf($);L!==-1&&e.experimentTickFunctions.splice(L,1)},"dispose")};return ce.controls=[{id:"R",label:"R (radius / blockiness)",min:2,max:40,step:1,value:d.R,fmt:o(function(L){return String(L)},"fmt"),get:o(function(){return ce.getR()},"get"),onChange:o(function(L){ce.setR(L)},"onChange")},{id:"emissionBoxSide",label:"emission box",min:0,max:40,step:1,value:d.emissionBoxSide,maxRef:"R",fmt:o(function(L){return String(L)},"fmt"),get:o(function(){return ce.getEmissionBoxSide()},"get"),onChange:o(function(L){ce.setEmissionBoxSide(L)},"onChange")},{id:"preset",label:"preset",kind:"select",options:Jm.slice(),value:d.preset,fmt:o(function(L){return String(L)},"fmt"),get:o(function(){return ce.getPreset()},"get"),onChange:o(function(L){ce.setPreset(L)},"onChange")},{id:"mode",label:"mode",kind:"select",options:["ball","shell"],value:d.mode,fmt:o(function(L){return String(L)},"fmt"),get:o(function(){return ce.getMode()},"get"),onChange:o(function(L){ce.setMode(L)},"onChange")},{id:"burstSize",label:"burst size",min:1,max:200,step:1,value:d.burstSize,fmt:o(function(L){return String(L)},"fmt"),get:o(function(){return ce.getBurstSize()},"get"),onChange:o(function(L){ce.setBurstSize(L)},"onChange")},{id:"emitEveryTicks",label:"rate (ticks/burst)",min:1,max:30,step:1,value:T,fmt:o(function(L){return String(L)},"fmt"),get:o(function(){return ce.getEmitEveryTicks()},"get"),onChange:o(function(L){ce.setEmitEveryTicks(L)},"onChange")},{id:"wavelength",label:"wavelength/mass (\u03BB, capacity="+l+")",min:1,max:l,step:1,value:ce.getWavelength(),fmt:o(function(L){return String(L)},"fmt"),get:o(function(){return ce.getWavelength()},"get"),onChange:o(function(L){ce.setWavelength(L)},"onChange")}],{sphereEmitterControl:ce,largeObjects:[],dispose:o(function(){ce.dispose()},"dispose")}}var lh,Ym,Jm,Qm,$o=ue(()=>{nh();Wm();sh();o(Qn,"clamp");o(Km,"worldCfg");o(Zw,"_worldInitArgs");o($w,"initWorld");lh=["R","burstSize","center","chargeMode","emissionBox","emissionBoxSide","emissionShell","emitEveryTicks","fundamentalDimension","fundamentalWaveLength","innerR","is2D","leafDimension","mode","offset","orientationDeg","preset","renderColor","renderShape","sourceShape","stepping","wavelength"],Ym=lh.concat(["emissionCap","gateCounter"]),Jm=["spherical","hemisphere","laser","drum","particle-walk"],Qm=["skipInit"];o(e_,"_worldFundamentalDimension");o(cr,"setupSphereEmitter3D");cr.WAVELENGTH_DEMO_DIMENSION=2;cr.worldCfg=Km;cr.initWorld=$w;cr.OPTIONS=lh;cr.PRESETS=Jm;cr.SKETCH_OPTIONS=Ym;cr.RETIRED_OPTIONS=Qm});var fh={};ge(fh,{setupTunnelPointExit:()=>Hi});function t_(e){return e=Ga("setupTunnelPointExit.sceneSpec",e,eg),$m(e,Zo("setupTunnelPointExit.sceneSpec canvasW/canvasH",{w:e.canvasW,h:e.canvasH}))}function $m(e,t){var r=t.w,i=t.h,n=e.tunnelLength!==void 0?e.tunnelLength:240,a=e.bore!==void 0?e.bore:40,s=e.wallThickness!==void 0?e.wallThickness:10,l=e.wavelengthScale!==void 0?e.wavelengthScale:16,c=e.exitRecenter!==void 0?!!e.exitRecenter:!0,f=!!e.exitPhaseReset,u=e.burstSize!==void 0?e.burstSize:6,h=e.emitEveryTicks!==void 0?e.emitEveryTicks:1,g=Math.round(r*.08),d=Math.round(i/2),m=d-Math.round(a/2),b=g+Math.max(2,Math.round(s/2));return{emitter:{preset:"hemisphere",is2D:!0,center:[b,d],emissionBoxSide:0,chargeMode:"random",fundamentalDimension:Xm,wavelength:Zm,fundamentalWaveLength:4*l,burstSize:u,emitEveryTicks:h},tunnel:{left:g,top:m,length:n,bore:a,wallThickness:s,axis:"x",mode:"directed",exitCollapse:!0,exitRecenter:c,exitPhaseReset:f,name:"point_exit_tunnel",color:[90,120,200]},geom:{left:g,top:m,midY:d,bore:a,exitX:g+n,tunnelLength:n,wavelengthScale:l,effectiveWavelength:Math.floor(Hl*l)}}}function Hi(e,t){t=Ga("setupTunnelPointExit",t,uh);var r=$m(t,Zo("setupTunnelPointExit universe.universe_rect",e.universe_rect)),i=r.geom.tunnelLength,n=r.geom.bore,a=r.geom.wavelengthScale,s=r.geom.midY,l=r.geom.exitX,c=t.active!==void 0?!!t.active:!0,f=cr,u=ja("Tunnel");f.initWorld(e,r.emitter);var h=f(e,r.emitter),g=h.sphereEmitterControl;g.setActive(c);var d=new u(e,r.tunnel);e.wavelengthScale=a;var m={setWavelengthScale:o(function(b){var y=Math.max(1,Math.round(b));return a=y,e.wavelengthScale=y,y},"setWavelengthScale"),getWavelengthScale:o(function(){return a},"getWavelengthScale"),getEffectiveWavelength:o(function(){return Math.floor(Hl*a)},"getEffectiveWavelength"),setExitPhaseReset:o(function(b){return d.setExitPhaseReset(b)},"setExitPhaseReset"),getExitPhaseReset:o(function(){return!!d.exitPhaseReset},"getExitPhaseReset"),setExitRecenter:o(function(b){return d.setExitRecenter(b)},"setExitRecenter"),getExitRecenter:o(function(){return!!d.exitRecenter},"getExitRecenter"),isExitGateArmed:o(function(){return d.isExitGateArmed()},"isExitGateArmed"),setActive:o(function(b){g.setActive(!!b)},"setActive"),getTunnelLength:o(function(){return i},"getTunnelLength"),getBore:o(function(){return n},"getBore"),getExitX:o(function(){return l},"getExitX"),getMidY:o(function(){return s},"getMidY")};return m.controls=[{id:"wavelengthScale",label:"\u03BB scale (eff \u03BB = 16 \xD7 scale)",min:1,max:24,step:1,value:a,fmt:o(function(b){return String(b)+" (eff \u03BB "+Math.floor(Hl*b)+"px)"},"fmt"),get:o(function(){return m.getWavelengthScale()},"get"),onChange:o(function(b){m.setWavelengthScale(b)},"onChange")},{id:"exitRecenter",label:"recenter at exit",kind:"checkbox",value:r.tunnel.exitRecenter,fmt:o(function(b){return b?"on":"off"},"fmt"),get:o(function(){return m.getExitRecenter()},"get"),onChange:o(function(b){m.setExitRecenter(b)},"onChange")},{id:"exitPhaseReset",label:"phase reset at exit",kind:"checkbox",value:r.tunnel.exitPhaseReset,fmt:o(function(b){return b?"on":"off"},"fmt"),get:o(function(){return m.getExitPhaseReset()},"get"),onChange:o(function(b){m.setExitPhaseReset(b)},"onChange")},{id:"tunnelLength",label:"tunnel length (rebuild)",min:60,max:420,step:20,value:i,rebuild:!0,fmt:o(function(b){return String(b)+"px"},"fmt"),get:o(function(){return m.getTunnelLength()},"get"),onChange:o(function(){},"onChange")}],{tunnel:d,emitterControl:g,pointExitControl:m,largeObjects:d.largeObjects,dispose:o(function(){h&&typeof h.dispose=="function"&&h.dispose(),d&&typeof d.dispose=="function"&&d.dispose()},"dispose")}}var Xm,Zm,Hl,uh,eg,hh=ue(()=>{nh();$o();xt();Xm=2,Zm=32,Hl=16;o(t_,"sceneSpec");o($m,"_sceneGeometry");uh=["active","bore","burstSize","emitEveryTicks","exitPhaseReset","exitRecenter","tunnelLength","wallThickness","wavelengthScale"],eg=uh.concat(["canvasH","canvasW"]);o(Hi,"setupTunnelPointExit");Hi.sceneSpec=t_;Hi.FUNDAMENTAL_DIMENSION=Xm;Hi.LEAF_WAVELENGTH_ARG=Zm;Hi.CAPACITY_OVER_MASS=Hl;Hi.OPTIONS=uh;Hi.SCENE_SPEC_OPTIONS=eg});var ph={};ge(ph,{Tunnel:()=>yt});function rg(e){return yi(e)}function ig(e,t,r,i,n,a,s,l){var c={};if(a==="x"?(c.rectA=[e,t-n,r,n],c.rectB=[e,t+i,r,n],c.innerRect=[e,t,r,i],c.gateRect=[e+r-Kl,t,Kl,i],c.midCoord=t+i/2):(c.rectA=[e-n,t,n,r],c.rectB=[e+i,t,n,r],c.innerRect=[e,t,i,r],c.gateRect=[e,t+r-Kl,i,Kl],c.midCoord=e+i/2),l!==null){var f=o(function(u){return[u[0],u[1],s,u[2],u[3],l]},"zs");c.rectA6=f(c.rectA),c.rectB6=f(c.rectB),c.gateRect6=f(c.gateRect),c.innerRect=f(c.innerRect)}return c}function yt(e,t){t=t||{},this.universe=e,this._schemaKind=this.constructor.name;var r=t.left,i=t.top,n=t.length,a=t.bore;if(!(n>0)||!(a>0))throw new Error("[Tunnel] opts.length and opts.bore must both be positive numbers.");var s=t.wallThickness!==void 0&&t.wallThickness!==null?t.wallThickness:10,l=t.axis==="y"?"y":"x",c=t.depth!==void 0&&t.depth!==null,f=t.z!==void 0&&t.z!==null?t.z:0,u=c?t.depth:null,h=t.color||[90,120,200],g=t.name||"tunnel",d=t.mode!==void 0&&t.mode!==null?t.mode:tg;if(Yl.indexOf(d)===-1)throw new Error('[Tunnel] unknown mode "'+d+'". Expected: '+Yl.join(" | "));var m=d===Jl,b=typeof t.directedAngle=="number"?t.directedAngle:l==="y"?90:0,y=typeof t.redirectSpread=="number"?t.redirectSpread:90,w=typeof t.polarSpread=="number"?t.polarSpread:0,x=!!t.exitCollapse,S=t.exitRecenter!==void 0?!!t.exitRecenter:!0,A=!!t.exitPhaseReset;if((A||t.exitRecenter!==void 0)&&!x)throw new Error("[Tunnel] exitPhaseReset / exitRecenter require exitCollapse \u2014 both are ops on the exit gate, and without the gate there is nothing to carry them. (FAIL-LOUD.)");if((m||x)&&e&&e.withInterQuantumCollisions===!0)throw new Error('[Tunnel] mode:"directed" / exitCollapse require withInterQuantumCollisions:false (the fast path). With inter-quantum collisions ON the collapse point becomes a one-frame-per-tick serializer: the frustration pass reverts the collapse write and KILLS contended quanta, so the scene measures contention rather than the point source. (FAIL-LOUD.)');this.left=r,this.top=i,this.length=n,this.bore=a,this.wallThickness=s,this.axis=l,this.color=h,this.name=g,this.mode=d,m&&(this.directedAngle=b,this.redirectSpread=y,this.polarSpread=w),x&&(this.exitCollapse=!0,this.exitRecenter=S,this.exitPhaseReset=A),c&&(this.z=f,this.depth=u);var T=ig(r,i,n,a,s,l,f,u),j=T.rectA,Q=T.rectB,Y=this;function H(ee,X){var te={rect:ee,collisionBehavior:m?"nothing":"bounce",name:g+X,color:h};return m&&(te.collectCollided=!0),t.wallOpacity!==void 0&&(te.alpha=t.wallOpacity),u!==null&&(te.z=f,te.depth=u),new _e(Y.universe,te)}if(o(H,"mkWall"),this.wallA=H(j,"_A"),this.wallB=H(Q,"_B"),this.walls=[this.wallA,this.wallB],this.largeObjects=[this.wallA.lo,this.wallB.lo],this.innerRect=T.innerRect,this.exitGate=null,this._exitGateMid=null,x){var V=Zt,C=an,J=vi,R=T.gateRect,K=T.midCoord,N=l==="x"?"top":"left",B=l==="x"?"h":"w";this._exitGateMid=K,this._exitPinProp=N,this._exitSizeProp=B;var ie={rect:R,collisionBehavior:"nothing",collectCollided:!0,visible:!1,name:g+"_exitgate",color:h};u!==null&&(ie.z=f,ie.depth=u);var oe=_e;this.exitGate=new oe(this.universe,ie),this.exitRecenter=S,this.exitPhaseReset=A,this._applyExitGateProgram(),this.walls.push(this.exitGate),this.largeObjects.push(this.exitGate.lo)}if(this.applyRedirect=null,this._unsubRedirect=null,m){var $=Wa,pe=rh,ye=l==="y"?"right":"bottom",ce=l==="y"?"left":"top";$.applyLinerScatter(this.wallA.lo,e,ye,{behavior:"ejectY",resetLocalTime:!1}),$.applyLinerScatter(this.wallB.lo,e,ce,{behavior:"ejectY",resetLocalTime:!1}),this.applyRedirect=pe(e,{wallHandles:[this.wallA.lo.handle,this.wallB.lo.handle],angleRad:b*Math.PI/180,spreadRad:y*Math.PI/180,speed:null,polarSpreadRad:w*Math.PI/180})}for(var L=0;L<this.walls.length;L++)this.walls[L]._owner=this}var tg,Jl,Yl,Kl,r_,es=ue(()=>{At();wi();Bl();ih();In();Mn();_r();Da();xt();hh();tg="mirror",Jl="directed",Yl=[tg,Jl],Kl=2;o(rg,"_hasZ");o(ig,"_geometry");o(yt,"Tunnel");Object.defineProperty(yt.prototype,"rect",{get:o(function(){for(var e=1/0,t=1/0,r=-1/0,i=-1/0,n=1/0,a=-1/0,s=!1,l=0;l<this.walls.length;l++){var c=this.walls[l]&&this.walls[l].rect;if(c&&(e=Math.min(e,c.left),t=Math.min(t,c.top),r=Math.max(r,c.left+c.w),i=Math.max(i,c.top+c.h),rg(c))){s=!0;var f=typeof c.d=="number"?c.d:c.w;n=Math.min(n,c.z),a=Math.max(a,c.z+f)}}if(!(!(e<r)||!(t<i))){var u={left:e,top:t,w:r-e,h:i-t};return s&&(u.z=n,u.d=a-n),u}},"get")});yt.prototype._applyExitGateProgram=function(){if(!this.exitGate)return null;var e=Zt,t=e.HANDLE_FRAME,r=[];this.exitRecenter&&r.push({set:t+"."+this._exitPinProp,to:e.Bin("-",e.Lit(this._exitGateMid),e.Bin("*",e.Ref(t,this._exitSizeProp),e.Lit(.5)))}),this.exitPhaseReset&&r.push({set:t+".local_time",to:e.Lit(0)});var i=null;return r.length&&(i={on:"collision",ops:r},vi(i,an(this.exitGate.lo.reposition||null,!1,e.HANDLE_FRAME,e.HANDLE_SELF,e.Lit,e.Ref,e.Cmp,e.Cond,e.Fn))),this.exitGate.lo.program=i,this.universe&&typeof this.universe.updateObjectProperty=="function"&&this.universe.updateObjectProperty(this.exitGate.lo.handle,"LargeObject","program",i),i};yt.prototype.applyProp=function(e,t){var r=yt.LIVE_PROPS[e];if(!r)return!1;if(typeof this[r]!="function")throw new Error('[Tunnel] live prop "'+e+'" is routed to '+r+"() but that setter does not exist. (FAIL-LOUD.)");return this[r](t),!0};yt.LIVE_PROPS={exitRecenter:"setExitRecenter",exitPhaseReset:"setExitPhaseReset",rect:"setRect",left:"setLeft",top:"setTop"};yt.prototype.setRect=function(e){if(!Array.isArray(e)||e.length!==4&&e.length!==6||!e.every(function(x){return typeof x=="number"&&isFinite(x)}))throw new TypeError("[Tunnel.setRect] rect must be the envelope [l,t,w,h] or [l,t,z,w,h,d] of finite numbers; got "+JSON.stringify(e)+". (FAIL-LOUD.)");var t=this.rect,r=rg(t);if(e.length===6&&!r)throw new Error('[Tunnel.setRect] "'+this.name+'" is a flat corridor (built without a depth); a 6-element rect would give it one, but its 3D-ness is compiled into its walls at construction. (FAIL-LOUD.)');var i=e[0],n=e[1],a=e.length===6?e[3]:e[2],s=e.length===6?e[4]:e[3],l=e.length===6?e[2]:r?t.z:null,c=e.length===6?e[5]:r?t.d:null,f=this.wallThickness,u=this.axis,h=a!==t.w||s!==t.h||r&&c!==t.d,g=this.length,d=this.bore;if(h){if(g=u==="x"?a:s,d=(u==="x"?s:a)-2*f,!(g>0)||!(d>0))throw new Error("[Tunnel.setRect] the envelope "+JSON.stringify(e)+" leaves no bore inside two "+f+"px walls. (FAIL-LOUD.)");for(var m=0;m<this.walls.length;m++)this.walls[m].assertOwnsProgram()}var b=u==="x"?i:i+f,y=u==="x"?n+f:n,w=ig(b,y,g,d,f,u,r?l:0,r?c:null);return this.wallA.setRect(r?w.rectA6:w.rectA),this.wallB.setRect(r?w.rectB6:w.rectB),this.left=b,this.top=y,this.length=g,this.bore=d,r&&(this.z=l,this.depth=c),this.innerRect=w.innerRect,this.exitGate&&(this.exitGate.setRect(r?w.gateRect6:w.gateRect),this._exitGateMid=w.midCoord,this._applyExitGateProgram()),this};yt.prototype.setLeft=function(e){var t=this.rect;return this.setRect([t.left+(e-this.left),t.top,t.w,t.h])};yt.prototype.setTop=function(e){var t=this.rect;return this.setRect([t.left,t.top+(e-this.top),t.w,t.h])};yt.prototype.isExitGateArmed=function(){return!!(this.exitGate&&this.exitGate.lo.program&&this.exitGate.lo.program.ops&&this.exitGate.lo.program.ops.length>0)};yt.prototype.setExitRecenter=function(e){if(!this.exitGate)return!1;var t=!!e;return this.exitRecenter===t||(this.exitRecenter=t,this._applyExitGateProgram()),t};yt.prototype.setExitPhaseReset=function(e){if(!this.exitGate)return!1;var t=!!e;return this.exitPhaseReset===t||(this.exitPhaseReset=t,this._applyExitGateProgram()),t};yt.prototype.applyRedirectIfActive=function(e){this.mode===Jl&&this.applyRedirect&&this.applyRedirect(e)};yt.prototype.attachToRunner=function(e){if(this.mode!==Jl||this._unsubRedirect)return this._unsubRedirect;if(!e||typeof e.addTickListener!="function")return null;var t=this;return this._unsubRedirect=e.addTickListener(function(r){t.applyRedirectIfActive(r)}),this._unsubRedirect};yt.prototype.dispose=function(){if(!this._disposed){this._disposed=!0,this._unsubRedirect&&(this._unsubRedirect(),this._unsubRedirect=null);for(var e=0;e<this.walls.length;e++)this.walls[e]&&typeof this.walls[e].dispose=="function"&&this.walls[e].dispose()}};yt.MODES=Yl;yt.pointExitSpec=o(function(t){return Hi.sceneSpec(t)},"pointExitSpec");r_={description:"A corridor built from TWO parallel MIRROR walls (guarded bounce) a `bore` apart \u2014 a waveguide / light-pipe. A beam travelling down the bore reflects off the two facing mirrors and stays collimated (no random scatter, no leak through the walls). The group is the single author-surface entity; the two mirror Walls it composes carry its `_owner` up-link. Zero physics of its own.",ux:{resizable:!0,draggable:{"2d":!0},shellRender:"run"},fields:[{name:"rect",type:"rect",engineVisible:!1,live:!0,writeOnly:!0,description:"WRITE-ONLY reposition ADAPTER: the corridor ENVELOPE (both mirrors and the exit gate). A rect write \u2014 the 2D drag, the SPACE carry \u2014 moves the whole Tunnel through Tunnel.setRect (a same-size write is a translation; a resize re-derives length/bore). Its read getter derives the envelope from the members; captureProps SKIPS it via writeOnly:true, so left/top/length/bore stay the captured position authority."},{name:"left",type:"number",constraint:{integer:!0},engineVisible:!0,live:!0,unit:"px",description:"Bore (aperture) left X position (physics pixels). For an X-axis tunnel this is the corridor mouth."},{name:"top",type:"number",constraint:{integer:!0},engineVisible:!0,live:!0,unit:"px",description:"Bore (aperture) top Y position (physics pixels)."},{name:"length",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Corridor travel-axis extent (physics pixels) \u2014 X extent for an X-axis tunnel, Y for a Y-axis tunnel. The mirrors span this length."},{name:"bore",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Clear aperture \u2014 the gap between the two mirror inner faces (physics pixels). The beam passes through the bore; a wider bore lets more through with less collimation."},{name:"wallThickness",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Thickness of each mirror wall in physics pixels (default 10)."},{name:"axis",type:"enum",constraint:{values:{x:"x",y:"y"}},engineVisible:!0,description:"Corridor travel axis: x = horizontal (two wide mirrors above+below the bore; a +x beam reflects its vy); y = vertical (two tall mirrors left+right; a +y beam reflects its vx)."},{name:"z",type:"number",constraint:{integer:!0},engineVisible:!0,unit:"px",description:"Near-face Z of the corridor z-slab (physics pixels). Paired with `depth`: both mirror walls are built as 6-element-rect z-slabs, so the corridor is a real 3D tube whose z-faces also reflect. Inert without `depth` (a flat 2D corridor)."},{name:"depth",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Z extent of the corridor z-slab (physics pixels). OMIT for a flat 2D corridor (the mirror walls stay 4-element rects, unconstrained in z). Supplying it makes each mirror a z-slab spanning z .. z+depth \u2014 the corridor a real tube in space."},{name:"color",type:"rgb",engineVisible:!1,live:!0,description:"Render color [r, g, b] for both mirror walls (render-only). A live edit fans out to both mirrors (the `_owner` fan-out in updateObjectProperty)."},{name:"mode",type:"enum",constraint:{values:Object.fromEntries(Yl.map(function(e){return[e,e]}))},engineVisible:!0,live:!1,description:"Collision mode. mirror (default) = the guarded-bounce waveguide: a beam reflects off the two facing mirrors and stays collimated. directed = the tunnel acts as a semi-circular EMITTER: each wall hit ejects the quantum back into the bore and re-emits it in a uniformly random FORWARD direction within 180\xB0 of the corridor axis. Construction-level (collection is a registration-time engine flag)."},{name:"directedAngle",type:"number",constraint:{min:0,max:360},engineVisible:!0,live:!1,unit:"deg",visibleWhen:{field:"mode",equals:"directed"},description:"Centre of the forward re-emission fan, in degrees. Omitted = DERIVED from `axis` (0 = +x for an x corridor, 90 = +y for a y one), i.e. the corridor's own travel direction. Set 180/270 for a corridor fed from the far end. The tunnel BODY stays axis-aligned; this aims the re-emission only."},{name:"redirectSpread",type:"number",constraint:{min:0,max:180},engineVisible:!0,live:!1,unit:"deg",visibleWhen:{field:"mode",equals:"directed"},description:"Half-width of the forward fan, in degrees (default 90 = a full 180\xB0 forward fan). The exit azimuth is drawn UNIFORMLY in directedAngle \xB1 this. 0 collapses to a perfectly collimated re-emission along directedAngle."},{name:"exitCollapse",type:"boolean",engineVisible:!0,live:!1,description:"Point-exit gate. Adds a third LargeObject spanning the last 2 columns of the bore at the output mouth; every crossing quantum is pinned to the bore mid-line, so the mouth emits as a one-pixel POINT SOURCE (the self-interference geometry). Composes with either mode. Requires withInterQuantumCollisions:false \u2014 FAIL-LOUD otherwise, because with collisions ON the collapse pixel serializes and kills quanta."},{name:"exitRecenter",type:"boolean",engineVisible:!1,live:!0,visibleWhen:{field:"exitCollapse",truthy:!0},description:'Pin every quantum crossing the exit gate to the bore mid-line \u2014 the point-source collapse. DEFAULT ON. Turning it OFF leaves the exit spatially unchanged, which is what separates "does the point source matter?" from "does coherence matter?" (exitPhaseReset) \u2014 while recentering was mandatory the two were confounded. With BOTH off the gate carries no program at all and stays registered only as an inert collector. LIVE (next collision).'},{name:"exitPhaseReset",type:"boolean",engineVisible:!1,live:!0,visibleWhen:{field:"exitCollapse",truthy:!0},description:"Re-phase-lock the ensemble at the exit gate (appends `set local_time = 0` to the gate program). Default OFF \u2014 a deliberate coherence choice, not a ratified behavior. Whether banding needs it is \u03BB-dependent: at long effective \u03BB the exit is already ~90% phase-aligned and bands survive with it OFF; at short \u03BB the exit is phase-flat and the fan reads smooth OFF, banded ON. PHASE ONLY \u2014 never the decoherence bundle (whose second op redraws charge). LIVE (next collision)."},{name:"polarSpread",type:"number",constraint:{min:0,max:90},engineVisible:!0,live:!1,unit:"deg",visibleWhen:{field:"mode",equals:"directed"},description:"Half-width of the OUT-OF-PLANE (polar) fan, in degrees. 0 (default, even on a 3D corridor) keeps the re-emission in the XY plane \u2014 the angle-uniform case. A non-zero value draws the polar angle uniformly in phi, which over-weights the pole: it is polar-uniform, NOT solid-angle-uniform on the hemisphere."}]};at(yt,{from:new URL("frqtl/parts/Tunnel.js",ze()).href,descriptor:r_,defaults:{length:80,bore:24,wallThickness:10,axis:"x",color:[90,120,200]},palette:{displayName:"Mirror Tunnel",category:"composite",iconHint:"tunnel",rank:2},build:o(function(e,t,r){var i=r,n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a]);var s=n.length!=null?n.length:80,l=n.bore!=null?n.bore:24;n.left==null&&(n.left=Math.round(t.x-s/2)),n.top==null&&(n.top=Math.round(t.y-l/2)),n.length=s,n.bore=l;var c=new i(t.runner.universe,n);return c._schemaKind=r.name,typeof c.attachToRunner=="function"&&c.attachToRunner(t.runner),c},"build")})});var mh={};ge(mh,{Trace:()=>Bt});function Ql(e,t){var r=t[0]-e[0],i=t[1]-e[1];if(r!==0==(i!==0))throw new Error("[Trace] path leg "+JSON.stringify(e)+"->"+JSON.stringify(t)+" is not cardinal. A Trace routes on the x/y grid only: a diagonal corridor was measured NOT to conduct (G ~ 0.04 vs 1.01 on-axis). Insert a waypoint. (FAIL-LOUD.)");return r>0?{ux:1,uy:0,deg:0,axis:"x"}:r<0?{ux:-1,uy:0,deg:180,axis:"x"}:i>0?{ux:0,uy:1,deg:90,axis:"y"}:{ux:0,uy:-1,deg:270,axis:"y"}}function Bt(e,t){t=t||{},this.universe=e,this._schemaKind=this.constructor.name;var r=t.path;if(!Array.isArray(r)||r.length<2)throw new Error("[Trace] opts.path must be an array of 2+ [x,y] waypoints. (FAIL-LOUD.)");var i=t.bore!==void 0&&t.bore!==null?t.bore:3,n=t.wallThickness!==void 0&&t.wallThickness!==null?t.wallThickness:6;if(!(i>0)||!(n>0))throw new Error("[Trace] bore and wallThickness must both be positive. (FAIL-LOUD.)");var a=typeof t.cornerSpread=="number"?t.cornerSpread:5,s=t.color||[90,120,200],l=t.name||"trace",c=t.groundGap!==void 0?t.groundGap:4,f=typeof t.cornerSize=="number"?t.cornerSize:Math.max(i,12);this.path=r.map(function(ye){return[ye[0],ye[1]]}),this.bore=i,this.wallThickness=n,this.cornerSpread=a,this.cornerSize=f,this.color=s,this.name=l;var u=yt,h=_e;this.segments=[],this.junctions=[],this.caps=[],this.ground=null,this.largeObjects=[],this.walls=[];var g=i/2,d,m,b;for(d=0;d<r.length-1;d++){m=Ql(r[d],r[d+1]);var y=f/2,w=d===0?0:y,x=d===r.length-2?0:y,S=r[d][0]+m.ux*w,A=r[d][1]+m.uy*w,T=r[d+1][0]-m.ux*x,j=r[d+1][1]-m.uy*x,Q=(T-S)*m.ux+(j-A)*m.uy;if(Q<=0)throw new Error("[Trace] leg "+d+" is shorter than the corner cells it must join (length "+Q+" after trimming for bore "+i+"). Space the waypoints at least one bore apart. (FAIL-LOUD.)");var Y=new u(e,m.axis==="x"?{left:Math.min(S,T),top:A-g,length:Q,bore:i,wallThickness:n,axis:"x",mode:"mirror",name:l+"_run"+d,color:s}:{left:S-g,top:Math.min(A,j),length:Q,bore:i,wallThickness:n,axis:"y",mode:"mirror",name:l+"_run"+d,color:s});this.segments.push(Y)}for(d=1;d<r.length-1;d++){if(b=Ql(r[d-1],r[d]),m=Ql(r[d],r[d+1]),m.axis===b.axis)throw new Error("[Trace] waypoint "+d+" does not turn (both legs run on the "+m.axis+" axis). Merge the collinear legs. (FAIL-LOUD.)");var H=r[d][0],V=r[d][1],C=f/2,J=new u(e,{left:H-C,top:V-C,length:f,bore:f,wallThickness:n,axis:m.axis,mode:"directed",directedAngle:m.deg,redirectSpread:a,name:l+"_corner"+d,color:s});this.junctions.push(J);var R=f+2*n,K=m.axis==="y"?[H-C-n,m.uy>0?V-C-n:V+C,R,n]:[m.ux>0?H-C-n:H+C,V-C-n,n,R];this.caps.push(new h(e,{rect:K,collisionBehavior:"bounce",bounceDirection:"reflect",name:(m.axis==="y"?"TOP_":"LEFT_")+l+"_cap"+d,color:s}))}this.inPort=[r[0][0],r[0][1]],this.outPort=[r[r.length-1][0],r[r.length-1][1]];var N=Ql(r[r.length-2],r[r.length-1]);if(this.outDirection=N.deg,t.ground){var B=i+2*n,ie=this.outPort[0]+N.ux*c,oe=this.outPort[1]+N.uy*c;this.ground=new h(e,{rect:N.axis==="x"?[N.ux>0?ie:ie-4,oe-B/2,4,B]:[ie-B/2,N.uy>0?oe:oe-4,B,4],collisionBehavior:"destroy",hooks:["count"],name:l+"_ground",color:[60,60,255]})}var $=[];this.segments.forEach(function(ye){$=$.concat(ye.walls)}),this.junctions.forEach(function(ye){$=$.concat(ye.walls)}),$=$.concat(this.caps),this.ground&&$.push(this.ground),this.walls=$;var pe=this;$.forEach(function(ye){ye&&ye.lo&&pe.largeObjects.push(ye.lo)}),this.segments.concat(this.junctions,this.caps,this.ground?[this.ground]:[]).forEach(function(ye){ye&&(ye._owner=pe)}),this._rawDelivered=0,this._window=[],this._unsub=null,this._disposed=!1}var dh,Xl=ue(()=>{es();wi();dh=2;o(Ql,"_dir");o(Bt,"Trace");Bt.prototype.onTick=function(e){for(var t=0;t<this.junctions.length;t++)this.junctions[t].applyRedirectIfActive(e);if(this.ground){var r=this.ground.getCollisionHistogram(e).total;this._window.push(r),this._window.length>251&&this._window.shift(),this._rawDelivered=r}};Bt.prototype.attachToRunner=function(e){if(this._unsub||!e||typeof e.addTickListener!="function")return this._unsub||null;var t=this;return this._unsub=e.addTickListener(function(r){t.onTick(r)}),this._unsub};Bt.prototype.getDelivered=function(){if(!this.ground)throw new Error("[Trace.getDelivered] this Trace has no ground terminal (construct with `ground:true`). (FAIL-LOUD.)");return this._rawDelivered/dh};Bt.prototype.getCurrent=function(){if(this._window.length<2)return 0;var e=this._window.length-1;return(this._window[e]-this._window[0])/dh/e};Bt.prototype.dispose=function(){if(!this._disposed){this._disposed=!0,this._unsub&&(this._unsub(),this._unsub=null);var e=this.segments.concat(this.junctions);e.forEach(function(t){t&&typeof t.dispose=="function"&&t.dispose()}),this.caps.forEach(function(t){t&&typeof t.dispose=="function"&&t.dispose()}),this.ground&&typeof this.ground.dispose=="function"&&this.ground.dispose()}};Bt.lanePitch=function(e,t){return e+2*t};Bt.GEOMETRIES=[{bore:3,wallThickness:3,pitch:9,crosstalk:.0098,note:"densest independent lane"},{bore:2,wallThickness:6,pitch:14,crosstalk:0,note:"narrow bore, thick insulation"},{bore:1,wallThickness:10,pitch:21,crosstalk:0,note:"smallest bore that conducts"},{bore:12,wallThickness:6,pitch:24,crosstalk:0,note:"roomy \u2014 the only bore that TURNS well"}];Bt.CORNER_THROUGHPUT={0:.935,5:.951,10:.92,20:.881,45:.76,90:.59};Bt.CORNER_MECHANISMS={mirrorElbow:{G:.738,sd:.011,part:"Wall{collisionBehavior:'bounce', bounceDirection:'reflect'}"},directedJunction:{G:.951,sd:.005,part:"Tunnel{mode:'directed'}"}};Bt.GROUND_COUNTS_PER_ARRIVAL=dh});var gh={};ge(gh,{SphereEmitter:()=>Le});function Le(e,t){if(this._schemaKind=this.constructor.name,Array.isArray(e)?this._center=e.slice():e&&typeof e=="object"&&t===void 0?(t=e,this._center=null):this._center=null,this._opts=t&&typeof t=="object"?t:{},this._control=null,this._setupResult=null,this.universe=null,this._active=!0,this._emissionCap=void 0,this._gateCounter=void 0,this._gateTickFn=null,this._runner=null,this._opts.emissionCap!=null&&(this._emissionCap=ag(this._opts.emissionCap),typeof this._opts.gateCounter!="string"||!this._opts.gateCounter))throw new Error(`[SphereEmitter] emissionCap requires gateCounter \u2014 the NAME of the counting Wall (collisionBehavior "nothing" + count hook) whose getLiveCount() is the cap's population authority. An unresolved gate silently running uncapped is the FAIL-LOUD violation this contract closes.`);if(this._opts.gateCounter!=null){if(typeof this._opts.gateCounter!="string"||!this._opts.gateCounter)throw new Error("[SphereEmitter] gateCounter must be a non-empty string (the counting Wall's name).");this._gateCounter=this._opts.gateCounter}}function ag(e){if(typeof e!="number"||!isFinite(e)||e<1||Math.floor(e)!==e)throw new Error("[SphereEmitter] emissionCap must be an integer >= 1; got "+JSON.stringify(e)+". (Throw-or-apply \u2014 never a silently ignored cap.)");return e}function og(e){if(!e._control)throw new Error("[SphereEmitter] not added yet \u2014 call .addTo(universe) before driving the emitter.");return e._control}function Or(e){return{get:o(function(){return this._control?e(this._control,this):void 0},"get")}}var ng,i_,ts=ue(()=>{At();$o();xt();_r();Vt();ng=["emissionCap","gateCounter"];o(Le,"SphereEmitter");o(ag,"_validateEmissionCap");Le.prototype.addTo=function(e){if(this._control)throw new Error("[SphereEmitter] addTo() called twice \u2014 one SphereEmitter maps to one live emitter. Construct a new SphereEmitter for a second source.");var t=cr,r={};for(var i in this._opts)Object.prototype.hasOwnProperty.call(this._opts,i)&&ng.indexOf(i)===-1&&(r[i]=this._opts[i]);Array.isArray(this._center)&&(r.center=this._center.slice());var n=t(e,r);this.universe=e,this._setupResult=n,this._control=n.sphereEmitterControl;var a=this._control,s=this;return Object.keys(a).forEach(function(l){typeof a[l]=="function"&&typeof s[l]>"u"&&(s[l]=function(){return a[l].apply(a,arguments)})}),this._emissionCap!=null&&this._installEmissionGate(e),this};Le.prototype._installEmissionGate=function(e){var t=this,r=null,i=o(function(a){var s=t._emissionCap;if(s!=null){if(!r){var l=t._runner;if(!l||typeof l.getObjectByName!="function")throw new Error('[SphereEmitter] emissionCap gate cannot resolve gateCounter "'+t._gateCounter+'" \u2014 no runner with getObjectByName() is attached (construct via ObjectFactory/addObject, which threads the runner). FAIL-LOUD, never a silent uncapped run.');var c=l.getObjectByName(t._gateCounter);if(!c)throw new Error('[SphereEmitter] emissionCap gate: gateCounter "'+t._gateCounter+`" names no live object on the runner \u2014 place a counting Wall (collisionBehavior "nothing" + hooks ['count']) with that name. FAIL-LOUD, never a silent uncapped run.`);if(typeof c.getLiveCount!="function")throw new Error('[SphereEmitter] emissionCap gate: "'+t._gateCounter+'" is not a counting Wall (no getLiveCount). FAIL-LOUD, never a silent uncapped run.');r=c}var f=a&&a.experimentTickFunctions?a:t.universe,u=r.getLiveCount(f?f._lastTickData:null);t.setActive(u<s)}},"emissionGateTick");i._emissionGate=!0,e.experimentTickFunctions.push(i),this._gateTickFn=i};o(og,"_requireLive");Le.prototype.setCenter=function(e,t,r){var i=og(this);return Array.isArray(e)?i.setCenter(e[0],e[1],e.length>2?e[2]:void 0):i.setCenter(e,t,r),this};Le.prototype.setActive=function(e){var t=og(this);return this._active=!!e,t.setActive(this._active),this};Le.prototype.setEmissionCap=function(e){return this._emissionCap=e==null?void 0:ag(e),this};Le.prototype.dispose=function(){if(this._gateTickFn&&this.universe&&Array.isArray(this.universe.experimentTickFunctions)){var e=this.universe.experimentTickFunctions.indexOf(this._gateTickFn);e!==-1&&this.universe.experimentTickFunctions.splice(e,1)}this._gateTickFn=null,this._control&&this._control.dispose(),this._marker&&typeof this._marker.dispose=="function"&&this._marker.dispose()};Le.prototype.attachMarker=function(e){if(!e||typeof e!="object")throw new TypeError("[SphereEmitter.attachMarker] needs the marker LargeObject. (FAIL-LOUD.)");if(this._marker)throw new Error("[SphereEmitter.attachMarker] this emitter already owns a marker \u2014 one emitter, one marker. (FAIL-LOUD.)");if(this._marker=e,e._owner=this,!this._control)throw new Error("[SphereEmitter.attachMarker] addTo() first \u2014 the marker follows the live control's centre write. (FAIL-LOUD.)");return this._control.attachMarker(e),this};Object.defineProperty(Le.prototype,"center",{get:o(function(){return this._control?this._control.getCenter():this._center?this._center.slice():null},"get")});Object.defineProperty(Le.prototype,"active",{get:o(function(){return this._active},"get")});Object.defineProperty(Le.prototype,"control",{get:o(function(){return this._control},"get")});Object.defineProperty(Le.prototype,"controls",{get:o(function(){return this._control?this._control.controls:null},"get")});o(Or,"_liveGetter");Object.defineProperty(Le.prototype,"rect",{get:o(function(){var e=this._control&&typeof this._control.getCenter=="function"?this._control.getCenter():null;if(!(!Array.isArray(e)||typeof e[0]!="number"||typeof e[1]!="number")){var t=Le.MARKER_D,r=typeof e[2]=="number"?e[2]:0;return{left:e[0]-t/2,top:e[1]-t/2,z:r-t/2,w:t,h:t,d:t}}},"get")});Object.defineProperty(Le.prototype,"preset",Or(function(e){return e.getPreset()}));Object.defineProperty(Le.prototype,"chargeMode",Or(function(e){return e.getChargeMode()}));Object.defineProperty(Le.prototype,"burstSize",Or(function(e){return e.getBurstSize()}));Object.defineProperty(Le.prototype,"emitEveryTicks",Or(function(e){return e.getEmitEveryTicks()}));Object.defineProperty(Le.prototype,"wavelength",Or(function(e){return e.getWavelength()}));Object.defineProperty(Le.prototype,"emissionShell",Or(function(e){return e.getEmissionShell()}));Object.defineProperty(Le.prototype,"innerR",Or(function(e){return e.getInnerR()}));Object.defineProperty(Le.prototype,"renderColor",Or(function(e){return e.getRenderColor()}));Object.defineProperty(Le.prototype,"renderShape",Or(function(e){return e.getRenderShape()}));Object.defineProperty(Le.prototype,"fundamentalDimension",Or(function(e){return e.getFundamentalDimension()}));Object.defineProperty(Le.prototype,"leafDimension",Or(function(e){return e.getLeafDimension()}));Object.defineProperty(Le.prototype,"is2D",Or(function(e){return e.getIs2D()}));Object.defineProperty(Le.prototype,"orientationDeg",Or(function(e){return e.getOrientation()}));Object.defineProperty(Le.prototype,"emissionBox",Or(function(e){return e.getEmissionBox()}));Object.defineProperty(Le.prototype,"emissionCap",{get:o(function(){return this._emissionCap},"get")});Object.defineProperty(Le.prototype,"gateCounter",{get:o(function(){return this._gateCounter},"get")});Object.defineProperty(Le.prototype,"fundamentalWaveLength",{get:o(function(){return this._opts&&this._opts.fundamentalWaveLength!==void 0?this._opts.fundamentalWaveLength:64},"get")});Le.prototype.applyProp=function(e,t){var r=this._control;if(!r)return this;switch(e){case"rect":Array.isArray(t)&&t.length===6?r.setCenter(t[0]+t[3]/2,t[1]+t[4]/2,t[2]+t[5]/2):Array.isArray(t)&&t.length===4&&r.setCenter(t[0]+t[2]/2,t[1]+t[3]/2);break;case"center":Array.isArray(t)&&r.setCenter(t[0],t[1],t.length>2?t[2]:void 0);break;case"preset":r.setPreset(t);break;case"chargeMode":r.setChargeMode(t);break;case"burstSize":r.setBurstSize(t);break;case"emitEveryTicks":r.setEmitEveryTicks(t);break;case"wavelength":r.setWavelength(t);break;case"emissionShell":r.setEmissionShell(t);break;case"innerR":r.setInnerR(t);break;case"renderColor":r.setRenderColor(t);break;case"renderShape":r.setRenderShape(t);break;case"leafDimension":r.setLeafDimension(t);break;case"orientationDeg":r.setOrientation(t);break;case"emissionCap":this.setEmissionCap(t);break;case"gateCounter":break;case"fundamentalWaveLength":case"fundamentalDimension":case"is2D":case"emissionBox":break;default:break}return this};Le.FACADE_OPTIONS=ng;Le.MARKER_D=24;Le.worldCfg=o(function(t){return cr.worldCfg(t)},"worldCfg");i_={description:'A spherical/omni "sun" emitter \u2014 uniform-direction ball-rejected emission (preset spherical/laser/drum/particle-walk). The manipulable palette face over the setupSphereEmitter3D setup factory: pure sugar (a NONE-collision visual marker + a host emit tick-fn), zero physics of its own. Drag the marker to move the emission center live; edit burst/rate/wavelength/charge/preset/shell live; dimension/is2D are boot-level (reload).',ux:{resizable:!1,draggable:{"2d":!0},handles:["move"],shellRender:"design"},fields:[{name:"rect",type:"rect",engineVisible:!1,live:!0,writeOnly:!0,description:"WRITE-ONLY reposition ADAPTER (drag handle). A rect write \u2014 from the visual marker's coupled-move or a rect edit \u2014 maps rect-CENTER \u2192 the emission center (control.setCenter). Its READ getter DERIVES a fresh rect from `center` (PR-1 item iii, for the Design bbox); captureProps SKIPS it via writeOnly:true so `center` stays the single captured position authority. Inspector seeds the vector control from `center` via a FIELD_VALUE_OVERRIDE."},{name:"center",type:"object",engineVisible:!1,live:!1,description:"Emission SOURCE POSITION in absolute canvas px as [x,y,z] (the captured position authority \u2014 the parts writer writes this, not rect). Edited live via the rect adapter / the visual marker drag; shown read-only here."},{name:"preset",type:"enum",constraint:{values:{spherical:"spherical",hemisphere:"hemisphere",laser:"laser",drum:"drum","particle-walk":"particle-walk"}},engineVisible:!1,live:!0,description:"Velocity-range preset: spherical (full ball / the sun), hemisphere (the SAME ball-rejected sampler with the forward axis halved to [0,R] \u2014 180\xB0 forward emission, aimed by orientationDeg), laser (collimated beam), drum (z=0 disk), particle-walk (deterministic +X drift). LIVE (next burst)."},{name:"chargeMode",type:"enum",constraint:{values:{positive:"positive",negative:"negative",random:"random"}},engineVisible:!1,live:!0,description:"Per-emitted-leaf charge: positive (0), negative (1), or random (per-leaf \xB1, the braiding that makes self-interference structure). LIVE (affects the next leaf)."},{name:"burstSize",type:"number",constraint:{min:1,integer:!0},engineVisible:!1,live:!0,description:"Leaves emitted per burst (flux). LIVE (affects the next burst)."},{name:"emitEveryTicks",type:"number",constraint:{min:1,integer:!0},engineVisible:!1,live:!0,unit:"ticks",description:"Ticks between bursts (sustained-emission cadence). LIVE (affects the next burst)."},{name:"emissionCap",type:"number",label:"Population Limit",constraint:{min:1,integer:!0},widgetConfig:{max:12800,step:1},engineVisible:!1,live:!0,description:"Self-throttle target: the emitter deactivates when the live population measured by gateCounter reaches this value and reactivates when it drops below. null/omitted = uncapped (byte-identical to today). LIVE (next tick). Zero physics (SU1) \u2014 pure emission regulation, like the blackbody thermostat."},{name:"gateCounter",type:"string",engineVisible:!1,live:!1,visibleWhen:{field:"emissionCap",present:!0},description:`The NAME of the counting Wall (collisionBehavior:"nothing" + count hook) whose getLiveCount() is this cap's population authority. Resolved lazily by name at tick time (construction-order independent). FAIL-LOUD if absent once emissionCap is set.`},{name:"wavelength",type:"number",constraint:{min:1,integer:!0},engineVisible:!1,live:!0,description:"Per-leaf wavelength arg \u2192 mass=max(1,capacity/wavelength), hence the transverse oscillation period (CLAUDE.md \xA76 fork). A NO-OP until fundamentalDimension is raised (capacity 1 saturates mass). LIVE (affects the next leaf)."},{name:"emissionShell",type:"enum",constraint:{values:{volume:"volume",surface:"surface"}},engineVisible:!1,live:!0,description:"Emission start topology: volume (seed within the box) or surface (velocity-aligned ring launch at innerR \u2014 empty center, sharp bands). LIVE (affects the next leaf)."},{name:"innerR",type:"number",constraint:{min:0,integer:!0},engineVisible:!1,live:!0,unit:"px",description:"Shell radius for emissionShell:surface (0 collapses to the center point; ignored in volume mode). LIVE (affects the next leaf)."},{name:"renderColor",type:"rgb",engineVisible:!1,live:!0,description:"Per-leaf render color override [r,g,b] (render-intent data, zero physics); null = colorless (scheme-driven fullness\u2192ROYGBIV). LIVE (affects the next leaf)."},{name:"renderShape",type:"enum",constraint:{values:{ball:"ball",box:"box",circle:"circle",cube:"cube",sphere:"sphere"}},engineVisible:!1,live:!0,description:`Per-leaf render.shape override (render-intent data, zero physics) \u2014 peer of renderColor. Stamped into string_map['render.shape'] on each emitted leaf via the provider render-intent MERGE seam. Overrides the render-level "Default Shape" (setRenderOption). null/omitted = fall back to the default. LIVE (affects the next leaf).`},{name:"orientationDeg",type:"number",constraint:{min:0,max:360},engineVisible:!1,live:!0,widgetHint:"slider",description:"Emitter orientation in degrees (default 0). The velocity sampler rotates each emitted (vx,vy) by this angle (M5: affects the NEXT leaf), so spinning a constrained/laser emitter sweeps its beam (pulsar); an omni emitter is unaffected. LIVE via control.setOrientation; the LOOK-drive rotation target."},{name:"fundamentalWaveLength",type:"number",constraint:{min:1,integer:!0},engineVisible:!1,live:!1,description:"Init-time wavelengthScale seed (waveLengthMultiplier=floor(fwl/4)); boot-level (set at universe.init \u2014 reload to change). Captured for round-trip."},{name:"fundamentalDimension",type:"number",constraint:{min:0,integer:!0},engineVisible:!1,live:!1,description:"The universe base dimension this emitter inits at; boot-level (reload to change). Raises leaf capacity so the wavelength knob gains leverage. Captured for round-trip."},{name:"leafDimension",type:"number",constraint:{min:0,integer:!0},engineVisible:!1,live:!0,label:"Emit Dimension",widgetHint:"dimension-select",description:"The per-emitter dimension leaves are born at (default = fundamentalDimension). LIVE (host-side addDimension + closure flip; next emitted leaf). A leaf born ABOVE the fundamental is move-gated (Invariant 6A) \u2014 slower/larger/redder, the per-dimension observable. A value BELOW the current fundamental self-lowers the floor universe-globally (a one-way ratchet). Captured for round-trip."},{name:"is2D",type:"boolean",engineVisible:!1,live:!1,description:"Whether the z-axis is inactive (2D disk of directions vs 3D ball); boot-level (set at init via activeAxes \u2014 reload to change). Captured for round-trip."},{name:"emissionBox",type:"object",engineVisible:!1,live:!1,description:"Derived per-axis emission-position box {x,y,z} (subsumes the scalar emissionBoxSide input). Captured for round-trip; frozen when re-passed on reload."}]};at(Le,{from:new URL("frqtl/parts/SphereEmitter.js",ze()).href,descriptor:i_,defaults:{preset:"spherical",is2D:!0},palette:{displayName:"Sphere Emitter",category:"emitter",iconHint:"emitter",rank:0},build:o(function(e,t,r){var i=r,n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&a!=="name"&&(n[a]=e[a]);t.fromPalette&&n.center==null&&n.offset==null&&typeof t.x=="number"&&typeof t.y=="number"&&(n.center=[t.x,t.y]);var s=new i(n);s._schemaKind=r.name;var l=Se,c=Ee;s._runner=t.runner,s.addTo(t.runner.universe);var f=typeof s.getCenter=="function"?s.getCenter():[t.x,t.y,0],u=i.MARKER_D,h=typeof f[2]=="number"?f[2]:0,g=[Math.round(f[0]-u/2),Math.round(f[1]-u/2),h-u/2,u,u,u];s.name=e.name||"sphere emitter "+t.runner.largeObjects.length;var d=new l(t.runner.universe,g,c.NONE,[],s.name,"closest",null,1,[240,200,80]);return d.drawAsCircle=!0,d.alpha=255,d.shellRender="design",d.shellShape="circle",d._schemaKind="LargeObject",d._designMarker=!0,s.attachMarker(d),s},"build")})});var vh={};ge(vh,{LogicGate:()=>Me});function Me(e,t){t=t||{},this.universe=e,this._schemaKind=this.constructor.name;var r=yt,i=_e,n=Bt,a=Le,s=String(t.logic||"").toUpperCase();if(!Ki[s])throw new Error("[LogicGate] opts.logic must be one of "+Object.keys(Ki).join(", ")+" \u2014 got "+JSON.stringify(t.logic)+". (FAIL-LOUD.)");var l=t.axis||"x";if(l!=="x")throw new Error('[LogicGate] only axis "x" (+x flow) is built and MEASURED. A rotated gate would be an unmeasured part wearing a measured datasheet. Rotate the layout instead. (FAIL-LOUD.)');var c=t.left,f=t.top;if(typeof c!="number"||typeof f!="number")throw new Error("[LogicGate] opts.left and opts.top are required (px). (FAIL-LOUD.)");var u=t.bore!==void 0&&t.bore!==null?t.bore:3,h=t.wallThickness!==void 0&&t.wallThickness!==null?t.wallThickness:6;if(!(u>0)||!(h>0))throw new Error("[LogicGate] bore and wallThickness must both be positive. (FAIL-LOUD.)");var g=t.length!==void 0?t.length:48;if(g<Me.MIN_LENGTH)throw new Error("[LogicGate] opts.length "+g+" is below the measured minimum "+Me.MIN_LENGTH+"px (the supply inlet and the shunt valve would overlap). (FAIL-LOUD.)");var d=t.supplyVoltage!==void 0?t.supplyVoltage:6;this._pinnedHigh=t.thresholdHigh!==void 0,this._pinnedLow=t.thresholdLow!==void 0;var m=this._pinnedHigh?t.thresholdHigh:Me.THRESHOLD_HIGH_FRACTION*d,b=this._pinnedLow?t.thresholdLow:Me.THRESHOLD_LOW_FRACTION*d;if(!(b<m))throw new Error("[LogicGate] thresholdLow ("+b+") must be BELOW thresholdHigh ("+m+") \u2014 the gap IS the hysteresis. (FAIL-LOUD.)");var y=t.name||"gate",w=t.color||[200,170,70],x=n.lanePitch(u,h);this.logic=s,this.left=c,this.top=f,this.bore=u,this.wallThickness=h,this.length=g,this.pitch=x,this.supplyVoltage=d,this.thresholdHigh=m,this.thresholdLow=b,this.windowTicks=t.windowTicks!==void 0?t.windowTicks:20,this.name=y,this.color=w;var S=f+x/2,A=f+x*1.5,T=f+x*2.5;this.inPortA=[c,S],this.inPortB=[c,T],this.outPort=[c+g,A],this.footprint=[c,f,g,x*3];var j=Me.TERMINAL_THICKNESS;this.terminals=[new i(e,{rect:[c,S-x/2,j,x],collisionBehavior:"destroy",hooks:["count"],name:y+"_inA",color:[60,60,255]}),new i(e,{rect:[c,T-x/2,j,x],collisionBehavior:"destroy",hooks:["count"],name:y+"_inB",color:[60,60,255]})],this.channel=new r(e,{left:c,top:A-u/2,length:g,bore:u,wallThickness:h,axis:"x",mode:"mirror",name:y+"_channel",color:w}),this.supplyCap=new i(e,{rect:[c,A-x/2,j,x],collisionBehavior:"destroy",name:y+"_cap",color:[70,70,90]}),this.valve=new i(e,{rect:[c+g-Me.VALVE_INSET,A-x/2,j,x],collisionBehavior:"destroy",name:y+"_valve",color:[220,90,90]}),this.supply=new a([c+Me.SUPPLY_INSET,A],{preset:"laser",is2D:!0,R:24,orientationDeg:0,emissionBoxSide:0,fundamentalDimension:0,burstSize:Math.max(1,d),emitEveryTicks:1,chargeMode:"random",renderColor:[255,120,60]}).addTo(e);var Q=this.terminals.concat(this.channel.walls,[this.supplyCap,this.valve]);this.walls=Q,this.largeObjects=[];var Y=this;Q.forEach(function(H){H&&H.lo&&Y.largeObjects.push(H.lo)}),this.terminals.concat([this.channel,this.supplyCap,this.valve,this.supply]).forEach(function(H){H&&(H._owner=Y)}),this._counts=[[],[]],this._current=[0,0],this._states=[!1,!1],this._out=null,this._unsub=null,this._disposed=!1,this._applyOutput(Ki[s](!1,!1))}var Ki,n_,yh=ue(()=>{At();es();wi();Xl();ts();xt();Ki={AND:o(function(e,t){return e&&t},"AND"),OR:o(function(e,t){return e||t},"OR"),XOR:o(function(e,t){return e!==t},"XOR"),NAND:o(function(e,t){return!(e&&t)},"NAND"),NOR:o(function(e,t){return!(e||t)},"NOR"),XNOR:o(function(e,t){return e===t},"XNOR")};o(Me,"LogicGate");Me.TERMINAL_THICKNESS=4;Me.SUPPLY_INSET=8;Me.VALVE_INSET=8;Me.MIN_LENGTH=Me.SUPPLY_INSET+Me.VALVE_INSET+Me.TERMINAL_THICKNESS;Me.THRESHOLD_HIGH_FRACTION=.5;Me.THRESHOLD_LOW_FRACTION=.25;Me.TRUTH=Ki;Me.LOGICS=Object.keys(Ki);Me.MEASURED={inputGain:1.011,inputGainSpread:.024,outputLevelFraction:1.001,outputLevelSd:.036,outputLowLevel:0,noiseCoefficient:.75,thresholdMarginSd:{4:5.67,6:7.21,8:8.87},reliableLowMarginSd:4,gateLatencyTicks:8,flightPxPerTick:1,levelRestorationSd:.018,chatterTransitions:0};Me.MINIMAL={bore:3,wallThickness:3,length:20,w:20,h:27,area:540};Me.prototype.onTick=function(e){for(var t=Bt,r=t.GROUND_COUNTS_PER_ARRIVAL,i=0;i<2;i++){var n=this.terminals[i].getCollisionHistogram(e).total,a=this._counts[i];a.push(n),a.length>this.windowTicks+1&&a.shift();var s=a.length-1;this._current[i]=s>0?(a[s]-a[0])/r/s:0,this._states[i]&&this._current[i]<this.thresholdLow?this._states[i]=!1:!this._states[i]&&this._current[i]>=this.thresholdHigh&&(this._states[i]=!0)}this._applyOutput(Ki[this.logic](this._states[0],this._states[1]))};Me.prototype._applyOutput=function(e){e!==this._out&&(this._out=e,this.valve.lo.setActive(!e))};Me.prototype.attachToRunner=function(e){if(this._unsub||!e||typeof e.addTickListener!="function")return this._unsub||null;var t=this;return this._unsub=e.addTickListener(function(r){t.onTick(r)}),this._unsub};Me.prototype.getState=function(){return{a:this._states[0],b:this._states[1],out:!!this._out,currentA:this._current[0],currentB:this._current[1]}};Me.prototype.getOutputLevel=function(){return this._out?this.supplyVoltage:0};Me.prototype.setSupplyVoltage=function(e){return this.supplyVoltage=Math.max(0,Math.round(e)),this.supply.setBurstSize(Math.max(1,this.supplyVoltage)),this.supply.setActive(this.supplyVoltage>0),this._pinnedHigh||(this.thresholdHigh=Me.THRESHOLD_HIGH_FRACTION*this.supplyVoltage),this._pinnedLow||(this.thresholdLow=Me.THRESHOLD_LOW_FRACTION*this.supplyVoltage),this.supplyVoltage};Me.prototype.getSupplyVoltage=function(){return this.supplyVoltage};Me.prototype.setLogic=function(e){var t=String(e||"").toUpperCase();if(!Ki[t])throw new Error("[LogicGate.setLogic] unknown logic "+JSON.stringify(e)+" \u2014 expected one of "+Me.LOGICS.join(", ")+". (FAIL-LOUD.)");return this.logic=t,this._applyOutput(Ki[t](this._states[0],this._states[1])),t};Me.prototype.getLogic=function(){return this.logic};Me.prototype.footprintArea=function(){return this.footprint[2]*this.footprint[3]};Me.prototype.dispose=function(){this._disposed||(this._disposed=!0,this._unsub&&(this._unsub(),this._unsub=null),this.terminals.forEach(function(e){e.dispose()}),this.channel.dispose(),this.supplyCap.dispose(),this.valve.dispose(),this.supply&&typeof this.supply.dispose=="function"&&this.supply.dispose())};Me.cellSize=function(e,t,r){var i=Bt,n=i.lanePitch(e,t),a=r!==void 0?r:48;return{w:a,h:n*3,pitch:n,area:a*n*3}};n_={description:"A powered logic gate assembled from stock: two counting-Wall ammeter terminals sense the current arriving on two input lanes, a comparator with hysteresis thresholds them into booleans, and one shunt valve either lets the gate's own supply rail reach the outlet or dumps it. Because the output is the gate's OWN rail, its HIGH level is independent of the input levels, so gates cascade without per-stage retuning. Zero physics of its own.",ux:{resizable:!1,draggable:{"2d":!0},shellRender:"run"},fields:[{name:"logic",type:"enum",constraint:{values:Object.fromEntries(Object.keys(Ki).map(function(e){return[e,e]}))},engineVisible:!1,live:!0,description:"The comparator row applied to the two sensed inputs. DATA, not geometry: every row builds the identical hardware and differs only in this function, so an inverting gate (NAND/NOR/XNOR) costs exactly what a non-inverting one costs here \u2014 unlike silicon."},{name:"left",type:"number",constraint:{integer:!0},engineVisible:!0,unit:"px",description:"Gate cell left X position (physics pixels). The two input terminal faces and the output-channel inlet all sit on this edge."},{name:"top",type:"number",constraint:{integer:!0},engineVisible:!0,unit:"px",description:"Gate cell top Y position (physics pixels). Input A rides the first lane, the powered output the middle lane, input B the third."},{name:"bore",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Lane aperture in physics pixels \u2014 the same bore the Traces wired to this gate should use. Sets the lane pitch (bore + 2 x wallThickness) and therefore the whole cell height."},{name:"wallThickness",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Lane insulation in physics pixels. This is the knob that sets the shrink floor: too thin and the channel mirrors go transparent, which reads as a dead gate rather than a noisy one."},{name:"length",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Output-channel X extent in physics pixels \u2014 the cell width. The measured floor is 20px (below that the supply inlet and the shunt valve overlap)."},{name:"supplyVoltage",type:"number",constraint:{min:0,integer:!0},engineVisible:!1,live:!0,unit:"quanta/tick",description:"The supply rail: emitter burst per tick, and therefore the gate's HIGH output level in quanta per tick. Raising it raises the output level and (unless the thresholds are pinned) the switching thresholds with it, so the gate stays correctly biased at any rail."},{name:"thresholdHigh",type:"number",constraint:{min:0},engineVisible:!1,live:!0,unit:"quanta/tick",description:"Input current at or above which an input is called HIGH. Defaults to half the rail. Because the sensed current is a counting process, an input must sit several standard deviations clear of this value to be reliably read \u2014 see the part datasheet for the measured margin."},{name:"thresholdLow",type:"number",constraint:{min:0},engineVisible:!1,live:!0,unit:"quanta/tick",description:"Input current below which a HIGH input reverts to LOW. Defaults to a quarter of the rail. The gap up to thresholdHigh IS the hysteresis \u2014 it is what stops an input sitting near its threshold from chattering on shot noise."},{name:"windowTicks",type:"number",constraint:{min:1,integer:!0},engineVisible:!1,live:!0,unit:"ticks",description:"Sliding window over which the input current is averaged. It sets BOTH the sense noise (which falls as 1/sqrt(window)) and half the switching delay \u2014 a longer window is a steadier, slower gate."},{name:"color",type:"rgb",engineVisible:!1,live:!0,description:"Render color [r, g, b] for the output-channel mirrors (render-only). A live edit fans out to both mirrors via the `_owner` fan-out in updateObjectProperty."}]};at(Me,{from:new URL("frqtl/parts/LogicGate.js",ze()).href,descriptor:n_,defaults:{logic:"AND",bore:3,wallThickness:3,length:20,supplyVoltage:6,windowTicks:20,color:[200,170,70]},palette:{displayName:"Logic Gate",category:"circuit",iconHint:"gate",rank:5},build:o(function(e,t,r){var i=r,n=Object.assign({},e),a=n.bore!=null?n.bore:3,s=n.wallThickness!=null?n.wallThickness:3,l=n.length!=null?n.length:20;n.left==null&&(n.left=Math.round(t.x-l/2)),n.top==null&&(n.top=Math.round(t.y-1.5*(a+2*s))),n.bore=a,n.wallThickness=s,n.length=l;var c=new i(t.runner.universe,n);return c._schemaKind=r.name,typeof c.attachToRunner=="function"&&c.attachToRunner(t.runner),c},"build")})});var bh={};ge(bh,{Box:()=>hn});function hn(e,t){t=t||{},this.universe=e,this._schemaKind="Box";var r=t.left,i=t.top,n=t.width,a=t.height,s=t.wallThickness||10,l=t.collisionType||Ee.BOUNCE,c=t.actions||[],f=t.color||[120,120,120],u=t.slit||null,h=r-s,g=i-s,d=n+2*s,m=a+2*s;this.walls=[],this.innerRect={left:r,top:i,w:n,h:a},this.outerRect={left:h,top:g,w:d,h:m},this.wallThickness=s,this.walls.push(new Se(e,[h,g,d,s],l,c,"TOP","bottom",null,1,f)),this.walls.push(new Se(e,[h,g+m-s,d,s],l,c,"BOTTOM","top",null,1,f)),u&&u.wall==="left"?this._createSlittedWall(e,"left",h,g,m,s,u.height,l,c,f):this.walls.push(new Se(e,[h,g,s,m],l,c,"LEFT","right",null,1,f)),u&&u.wall==="right"?this._createSlittedWall(e,"right",h+d-s,g,m,s,u.height,l,c,f):this.walls.push(new Se(e,[h+d-s,g,s,m],l,c,"RIGHT","left",null,1,f));for(var b=0;b<this.walls.length;b++)this.walls[b]._owner=this}var a_,wh=ue(()=>{At();_r();Vt();ti();xt();o(hn,"Box");hn.prototype._createSlittedWall=function(e,t,r,i,n,a,s,l,c,f){var u=(n-s)/2,h=t==="left"?"right":"left",g=t.toUpperCase();this.walls.push(new Se(e,[r,i,a,u],l,c,g+"_T",h,null,1,f)),this.walls.push(new Se(e,[r,i+n-u-1,a,u],l,c,g+"_B",h,null,1,f))};hn.prototype.setCollisionType=function(e){for(var t=0;t<this.walls.length;t++)this.walls[t].setCollisionType(e)};hn.prototype.setActive=function(e){for(var t=0;t<this.walls.length;t++)this.walls[t].setActive(e)};hn.prototype.dispose=function(){for(var e=0;e<this.walls.length;e++)this.walls[e].dispose()};a_={description:"A rectangular enclosure built from 4 LargeObject walls (top, bottom, left, right). Any wall can optionally have a slit opening. Used to confine particles, build cavities, or create directed channels. Inner dimensions define the open cavity; walls extend outward by wallThickness.",fields:[{name:"left",type:"number",constraint:{integer:!0},engineVisible:!0,description:"Inner box left X position (physics pixels). The outer wall begins at left - wallThickness."},{name:"top",type:"number",constraint:{integer:!0},engineVisible:!0,description:"Inner box top Y position (physics pixels). The outer wall begins at top - wallThickness."},{name:"width",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Inner box width (physics pixels). Outer width = width + 2 * wallThickness."},{name:"height",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Inner box height (physics pixels). Outer height = height + 2 * wallThickness."},{name:"wallThickness",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Thickness of each wall in physics pixels (default 10). Walls extend outward from the inner box."},{name:"collisionType",type:"enum",constraint:{values:Ee},engineVisible:!0,description:"Collision type applied to all four walls (e.g. BOUNCE confines particles inside)."},{name:"actions",type:"enum-set",constraint:{values:st},engineVisible:!0,description:"Actions applied on collision for all four walls (e.g. [BOUNCE, ABSORB])."},{name:"color",type:"rgb",engineVisible:!1,live:!0,description:"Render color [r, g, b] for all four walls (render-only). A live edit fans out to every wall the group owns (the `_owner` fan-out in updateObjectProperty)."}]};at(hn,{from:new URL("frqtl/objects/objects/Box.js",ze()).href,descriptor:a_,defaults:{left:60,top:60,width:80,height:80,wallThickness:10,collisionType:"BOUNCE",actions:[],color:[120,120,120]},build:o(function(e,t,r){var i=r,n=new i(t.runner.universe,Object.assign({left:e.left!=null?e.left:Math.round(t.x-40),top:e.top!=null?e.top:Math.round(t.y-40),width:80,height:80,wallThickness:10,collisionType:"BOUNCE",actions:[],color:[120,120,120]},e));return n._schemaKind=r.name,n},"build")})});function o_(e,t){for(var r=t.burstSize,i=0;i<r&&t.remainingQuanta>0;i++)for(var n=t.sourceRects,a=0;a<n.length&&t.remainingQuanta>0;a++){var s=n[a],l=s[0]+e.random()*s[2],c=s[1]+e.random()*s[3],f=t.vx,u=t.vy,h=null;if(t.randomDirection)if(t.zIsotropy){var g=e.random()*2*Math.PI,d=e.random()*2-1,m=Math.sqrt(Math.max(0,1-d*d)),b=Math.sqrt(f*f+u*u)||1;f=Math.cos(g)*m*b,u=Math.sin(g)*m*b,h=d*b}else{var y=e.random()*2*Math.PI,w=Math.sqrt(f*f+u*u)||1;f=Math.cos(y)*w,u=Math.sin(y)*w}var x;t.charge===null||t.charge===void 0?x=e.random()<.5?0:1:x=t.charge==="Positive"||t.charge==="POSITIVE"?0:1;var S=t.fundamentalDim!=null?t.fundamentalDim:null,A=e.makeLeafFrame(l,c,S,t.wavelength!==null&&t.wavelength!==void 0?t.wavelength:0,f,u,!!t.wrap,x,t.color||null,t.renderShape!=null&&t.renderShape!==""?t.renderShape:null,t.renderOutline!=null?t.renderOutline:null);if(A!==null){e.injectFrame(A);var T=t.zMin!==null&&t.zMin!==void 0;if(T||h!==null){var j=e.getFrameQuantumId(A);if(T){var Q=t.zDepth!==null&&t.zDepth!==void 0?t.zDepth:0,Y=t.zMin+(Q>0?e.random()*Q:0);e.setFrameProperty(j,"z",Y)}h!==null&&e.setFrameProperty(j,"vz",h)}t.remainingQuanta--}}}function Zl(e,t){return function(){return t.tombstoned||!t.active?[]:t.remainingDelay>0?(t.remainingDelay--,[]):t.remainingQuanta<=0?[]:t.everyNTicks!==null&&t.everyNTicks!==void 0&&t.everyNTicks>1&&(t._rateCounter=(t._rateCounter||0)+1,t._rateCounter%t.everyNTicks!==0)?[]:(o_(e,t),[])}}var _h=ue(()=>{"use strict";o(o_,"_fireBurst");o(Zl,"buildEmitterTickFn")});var xh={};ge(xh,{V1_REPLACEMENTS:()=>Ha});var Ha,$l=ue(()=>{Ha=Object.freeze({DetectorWall:"Wall{ collisionBehavior:'destroy', hooks:['count'] } (preset 'detector-screen')",SlitScreen:"Wall{ collisionBehavior:'destroy' } slabs + Tunnel{ mode:'directed', exitCollapse }",DSEWall:"Wall{ collisionBehavior:'destroy' } slabs + one Tunnel{ mode:'directed' } per passage",SlitLightSource:"SphereEmitter{ preset:'laser' }",QuantumEmitter:"SphereEmitter",PointSource:"SphereEmitter{ preset:'drum' | 'spherical' }",DirectedTunnel:"Tunnel{ mode:'directed' }",LightSource:"SphereEmitter{ preset:'hemisphere' | 'laser' } + Tunnel",Tube:"Tunnel (with Wall end caps)",ChamberEmitter:"SphereEmitter + Tunnel (with Wall end caps)",Gun:"Tunnel + SphereEmitter, composed at the sketch level",Bullet:"Wall{ collisionBehavior:'bounce' } moved by a sketch tick-fn through setRect",Box:"four Wall{ collisionBehavior:'block' } slabs",OvenBox:"Wall{ collisionBehavior:'absorb' } + SphereEmitter{ emissionCap, gateCounter }",CircuitGate:"LogicGate (the stock V2 gate: Wall{'destroy',['count']} input ammeters + Tunnel{'mirror'} channel + SphereEmitter rail + Wall{'destroy'} shunt valve)",CircuitProbe:"Wall preset 'transparent-probe'",LeafField:"(archived \u2014 no V2 successor)",EgptFractal:"(archived \u2014 no V2 successor)"})});function Oh(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Oh);var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=Oh(e[r]));return t}function s_(e,t){var r=Oh(Be.defaultPropsFor(e));return Object.assign({},r,t||{})}function l_(e){if(e!=="SphereEmitter")return[];var t=[],r=cr,i=Le;return r.OPTIONS&&(t=t.concat(r.OPTIONS)),r.RETIRED_OPTIONS&&(t=t.concat(r.RETIRED_OPTIONS)),i.FACADE_OPTIONS&&(t=t.concat(i.FACADE_OPTIONS)),t}function c_(e,t){if(t){var r=Be.get(e);if(!(!r||!r.fields)){var i={};r.fields.forEach(function(s){i[s.name]=!0}),Object.keys(Be.defaultPropsFor(e)).forEach(function(s){i[s]=!0}),lg.forEach(function(s){i[s]=!0}),l_(e).forEach(function(s){i[s]=!0});var n=Object.keys(t).filter(function(s){return!i[s]});if(n.length){var a=r.fields.map(function(s){return s.name}).sort();throw new Error('[ObjectFactory] create("'+e+'"): unknown prop key'+(n.length>1?"s":"")+" "+n.map(function(s){return'"'+s+'"'}).join(", ")+'. The builder reads only declared props, so this would have been merged in, read by nobody, and the object built with ITS OWN default \u2014 a different scene than the one you wrote, with no signal. "'+e+'" declares: '+a.join(", ")+". Construction adapters: "+lg.slice().sort().join(", ")+".")}}}}function u_(e,t){if(t){var r=Be.get(e);if(!(!r||!r.fields)){var i=r.fields.filter(function(a){return a.writeOnly===!0&&t[a.name]!==void 0});if(i.length){var n=r.fields.filter(function(a){return!a.writeOnly}).map(function(a){return a.name});throw new Error('[ObjectFactory] create("'+e+'"): "'+i[0].name+'" is a write-only reposition adapter (it moves a built '+e+"), not a construction key. Declare the position with the fields the part is built from: "+n.join(", ")+". (FAIL-LOUD.)")}}}}function ec(e,t){return e.declared.filter(function(r){return r._schemaKind===t}).length}var lg,Eh,tc=ue(()=>{bi();xt();$o();ts();$l();o(Oh,"_deepCopy");o(s_,"_mergeProps");lg=["x","y","w","h","left","top","rect","layer","name","preset","_wavelength","_optColor","_emergentPhysics"];o(l_,"_forwardedVocabulary");o(c_,"_assertPropKeys");o(u_,"_refuseWriteOnlyKeys");o(ec,"declaredCount");Eh={create:o(function(e,t,r){if(!r||!r.runner)throw new Error('[ObjectFactory] create("'+e+'"): ctx.runner is required \u2014 pass { runner, x, y }.');if(typeof e=="function"){if(!Dt(e))throw new Error("[ObjectFactory] create: the class "+(e.name||"(anonymous)")+" is not a registered kind in this realm \u2014 "+vl(e.name||"?")+". (FAIL-LOUD.)");e=e.name}var i=Dt(e);if(!i){var n='[ObjectFactory] create: unknown kind "'+e+'". Registered kinds: '+Eh.kinds().slice().sort().join(", ")+". The "+vl(e)+".";throw Object.prototype.hasOwnProperty.call(Ha,e)&&(n+=' "'+e+'" is a retired V1 part, not a published part \u2014 compose '+Ha[e]+" instead."),new Error(n+" (FAIL-LOUD.)")}if(typeof i.build!="function")throw new Error('[ObjectFactory] create: kind "'+e+'" registers a descriptor only \u2014 it is not constructed by ObjectFactory; construct it with new '+e+"(\u2026) ("+i.from+"). (FAIL-LOUD.)");c_(e,t),u_(e,t);var a=s_(e,t),s=r.runner,l=new Set(s.largeObjects),c=s.universe&&Array.isArray(s.universe.experimentTickFunctions)?s.universe.experimentTickFunctions:null,f=new Set(c||[]),u=i.build(a,r,i.Class);if(u===null||typeof u!="object")throw new Error('[ObjectFactory] create("'+e+'"): the builder returned '+(u===null?"null":typeof u)+", not a handle. Every kind returns the object it built or throws naming what is missing \u2014 a non-handle here is a part silently absent from the scene. (FAIL-LOUD.)");if(typeof s.declare!="function")throw new Error('[ObjectFactory] create("'+e+'"): ctx.runner has no declare() \u2014 the runner (FrqtlApp) owns the declared-object registry every created part is recorded in. (FAIL-LOUD.)');var h=s.largeObjects.filter(function(m){return!l.has(m)});if(!h.length)throw new Error('[ObjectFactory] create("'+e+'"): the build put nothing in the world \u2014 every part draws at least one LO, so a part with none is silently absent from the scene. (FAIL-LOUD.)');var g=s.universe&&Array.isArray(s.universe.experimentTickFunctions)?s.universe.experimentTickFunctions:[],d=g.filter(function(m){return!f.has(m)});return s.declare(u,h,d,{kind:e}),u},"create"),list:o(function(){return Be.placeableCatalog()},"list"),kinds:o(function(){return Ra().filter(function(e){return typeof Dt(e).build=="function"})},"kinds")}});var Sh={};ge(Sh,{QuantumEmitter:()=>Tt});function p_(e){if(e==null)return"random";if(typeof e=="string"){var t=e.toUpperCase();if(t==="POSITIVE"||e==="Positive"||e==="+")return"positive";if(t==="NEGATIVE"||e==="Negative"||e==="-")return"negative"}return e===0?"positive":e===1?"negative":"random"}function d_(e){return e==="positive"?"POSITIVE":e==="negative"?"NEGATIVE":null}function rs(e,t){return String(e)+":"+String(!!t)}function Tt(e,t,r,i,n,a,s,l,c,f,u,h){n=n!==void 0?n:1,a===void 0&&(a=null),s=s!==void 0?s:!0,l=l!==void 0?l:!1,c=c!==void 0?c:1/0,f=f!==void 0?f:0,u=u!==void 0?u:!1,h=h||{};var g=h.wavelength!==void 0?h.wavelength:null,d=h.zMin!==void 0?h.zMin:null,m=h.zDepth!==void 0?h.zDepth:null,b=!!h.zIsotropy;this.universe=e,this._schemaKind="QuantumEmitter",this.vx=r,this.vy=i,this.burst_size=n,this.auto_fire=s,this.colorOverride=null,this.renderShape=null,this.renderOutline=null,this.wavelength=g,this.quantum_limit=c===1/0?null:c,this.delay=f,this.wrap=u,this.source_rects=(t||[]).map(function(y){return f_(y)}),this._chargeMode=p_(a),this._random_direction=!!l,this._specTemplate={source_rects:this.source_rects,vx:r,vy:i,burst_size:n,auto_fire:s,quantum_limit:this.quantum_limit,delay:f,wrap:u,wavelength:g,zMin:d,zDepth:m,zIsotropy:b},this._emitterMap={},this._ensureAndActivate(this._chargeMode,this._random_direction),this.handle=this._primaryHandle()}var f_,h_,m_,kh=ue(()=>{At();_r();_h();xt();Vt();ln();tc();f_=Se.rectToArray,h_=Zl;o(p_,"_chargeToMode");o(d_,"_modeToCharge");o(rs,"_handleKey");o(Tt,"QuantumEmitter");Tt.prototype._ensureHandle=function(e,t){var r=rs(e,t);if(this._emitterMap[r]!==void 0)return this._emitterMap[r];var i=this._specTemplate,n={sourceRects:(i.source_rects||[]).map(function(s){return Array.isArray(s)?s:[s.left,s.top,s.w,s.h]}),vx:i.vx||0,vy:i.vy||0,burstSize:i.burst_size||1,charge:e,randomDirection:!!t,quantumLimit:i.quantum_limit!==void 0&&i.quantum_limit!==null?i.quantum_limit:1/0,remainingQuanta:i.quantum_limit!==void 0&&i.quantum_limit!==null?i.quantum_limit:1/0,delay:i.delay||0,remainingDelay:i.delay||0,active:i.auto_fire!==void 0?i.auto_fire:!0,tombstoned:!1,color:this.colorOverride||null,renderShape:this.renderShape||null,renderOutline:this.renderOutline!=null?this.renderOutline:null,wrap:!!i.wrap,wavelength:i.wavelength||null,fundamentalDim:null,zMin:i.zMin!==void 0&&i.zMin!==null?i.zMin:null,zDepth:i.zDepth!==void 0&&i.zDepth!==null?i.zDepth:null,zIsotropy:!!i.zIsotropy},a=h_(this.universe,n);return a._emState=n,this.universe.experimentTickFunctions.push(a),this._emitterMap[r]=n,n};Tt.prototype._ensureAndActivate=function(e,t){var r=!!t,i=this,n=[];e==="both"?(n.push({charge:"POSITIVE",rd:r}),n.push({charge:"NEGATIVE",rd:r})):n.push({charge:d_(e),rd:r});for(var a=0;a<n.length;a++)i._ensureHandle(n[a].charge,n[a].rd);for(var s={},l=0;l<n.length;l++)s[rs(n[l].charge,n[l].rd)]=!0;for(var c=Object.keys(i._emitterMap),f=0;f<c.length;f++){var u=c[f];i._emitterMap[u].active=!!s[u]}};Tt.prototype._primaryHandle=function(){var e=this._random_direction,t=this._chargeMode,r;if((t==="both"||t==="positive")&&(r=rs("POSITIVE",e),this._emitterMap[r]!==void 0))return this._emitterMap[r];if(t==="negative"&&(r=rs("NEGATIVE",e),this._emitterMap[r]!==void 0))return this._emitterMap[r];if(r=rs(null,e),this._emitterMap[r]!==void 0)return this._emitterMap[r];var i=Object.keys(this._emitterMap);return i.length>0?this._emitterMap[i[0]]:null};Tt.prototype.forEachHandle=function(e){for(var t=Object.keys(this._emitterMap),r=0;r<t.length;r++)e(this._emitterMap[t[r]])};Tt.prototype._activeHandles=function(){for(var e=Object.keys(this._emitterMap),t=[],r=0;r<e.length;r++){var i=this._emitterMap[e[r]];i.active&&t.push(i)}return t};Object.defineProperty(Tt.prototype,"chargeMode",{get:o(function(){return this._chargeMode},"get"),set:o(function(e){var t={random:!0,positive:!0,negative:!0,both:!0};if(!t[e])throw new TypeError('[QuantumEmitter] Invalid chargeMode "'+e+'". Expected: random | positive | negative | both');this._chargeMode=e,this._ensureAndActivate(e,this._random_direction),this.handle=this._primaryHandle()},"set"),enumerable:!0,configurable:!0});Object.defineProperty(Tt.prototype,"random_direction",{get:o(function(){return this._random_direction},"get"),set:o(function(e){var t=!!e;this._random_direction=t,this._ensureAndActivate(this._chargeMode,t),this.handle=this._primaryHandle()},"set"),enumerable:!0,configurable:!0});Tt.prototype.setActive=function(e){this.auto_fire=e;var t=this;if(e)this._ensureAndActivate(this._chargeMode,this._random_direction);else for(var r=Object.keys(this._emitterMap),i=0;i<r.length;i++)t._emitterMap[r[i]].active=!1};Tt.prototype.setVelocity=function(e,t){this.vx=e,this.vy=t,this._specTemplate.vx=e,this._specTemplate.vy=t;for(var r=Object.keys(this._emitterMap),i=0;i<r.length;i++)this._emitterMap[r[i]].vx=e,this._emitterMap[r[i]].vy=t};Tt.prototype.setBurstSize=function(e){this.burst_size=e,this._specTemplate.burst_size=e;for(var t=Object.keys(this._emitterMap),r=0;r<t.length;r++)this._emitterMap[t[r]].burstSize=e};Tt.prototype.setWavelength=function(e){this.wavelength=e,this._specTemplate.wavelength=e;for(var t=Object.keys(this._emitterMap),r=0;r<t.length;r++)this._emitterMap[t[r]].wavelength=e};Tt.prototype.setSourceRect=function(e){var t=e&&e.slice?e.slice():e;this._marker&&this._marker.setRect([t[0],t[1],t[2],t[3]]),this.source_rects=[t],this._specTemplate.source_rects=this.source_rects;for(var r=Object.keys(this._emitterMap),i=0;i<r.length;i++)this._emitterMap[r[i]].sourceRects=[t.slice()]};Tt.prototype.dispose=function(){if(!this._disposed){this._disposed=!0;for(var e=Object.keys(this._emitterMap),t=[],r=0;r<e.length;r++){var i=this._emitterMap[e[r]];i.tombstoned=!0,i.active=!1,t.push(i)}if(this.universe&&Array.isArray(this.universe.experimentTickFunctions))for(var n=this.universe.experimentTickFunctions,a=n.length-1;a>=0;a--)n[a]._emState&&t.indexOf(n[a]._emState)!==-1&&n.splice(a,1);this._marker&&typeof this._marker.dispose=="function"&&this._marker.dispose()}};Tt.prototype.attachMarker=function(e){if(!e||typeof e!="object")throw new TypeError("[QuantumEmitter.attachMarker] needs the marker LargeObject. (FAIL-LOUD.)");if(this._marker)throw new Error("[QuantumEmitter.attachMarker] this emitter already owns a marker. (FAIL-LOUD.)");return this._marker=e,e._owner=this,this};m_={description:'A particle emitter that fires leaf quanta (particles) from one or more source rectangles. Supports directed or random emission, charge polarity, burst-size (amperage), and velocity (voltage direction). The chargeMode/random_direction sugar layer composes multiple underlying engine handles to implement "both" charge and random direction without engine changes.',fields:[{name:"rect",type:"rect",engineVisible:!0,description:"Canonical bounding rect "+bt(4)+" \u2014 repositions the single emission source rect. Routed through QuantumEmitter.setSourceRect() (mutates emState.sourceRects directly \u2014 the RETIRED provider ABI updateEmitterSourceRects no longer exists post-G-EMIT-2). The emitter moves its own marker."},{name:"source_rects",type:"rect-array",engineVisible:!0,description:"Emission regions as array of "+bt(4)+" rects"},{name:"vx",type:"number",constraint:{integer:!1},engineVisible:!0,unit:"px/tick",description:"Initial X velocity of emitted particles (pixels/tick). Positive = rightward, negative = leftward."},{name:"vy",type:"number",constraint:{integer:!1},engineVisible:!0,unit:"px/tick",description:"Initial Y velocity of emitted particles (pixels/tick). Positive = downward (screen coords), negative = upward."},{name:"burst_size",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Number of particles fired per burst (amperage). Higher values produce more particles per tick; lower values reduce flux."},{name:"auto_fire",type:"boolean",engineVisible:!0,description:"Whether the emitter fires automatically every tick. false = must be triggered manually (e.g. by a tick function or the inspector)."},{name:"quantum_limit",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Maximum total quanta to emit (null/Infinity = unlimited). The emitter auto-deactivates after reaching this count."},{name:"delay",type:"number",constraint:{min:0,integer:!0},engineVisible:!0,unit:"ticks",description:"Ticks between bursts. 0 = fire every tick; N = fire once every N+1 ticks."},{name:"wrap",type:"boolean",engineVisible:!0,description:"Wrap emitted particles at canvas boundaries instead of letting them escape."},{name:"colorOverride",type:"rgb",engineVisible:!1,description:"Override render color for emitted particles [r, g, b] (render-only; stored on the emitter wrapper)"},{name:"chargeMode",type:"enum",constraint:{values:{random:"random",positive:"positive",negative:"negative",both:"both"}},engineVisible:!1,description:"Charge mode (user-facing sugar): random = null charge, positive, negative, or both (two co-located emitters). Composes underlying emitter handle-programs by toggling their active flag \u2014 no engine ABI change. Use this instead of the raw charge param."},{name:"random_direction",type:"boolean",engineVisible:!1,description:"Randomize emission direction each burst (sugar layer). Registers a new underlying handle with rd=true \u2014 no engine ABI change."},{name:"layer",type:"number",constraint:{min:0,integer:!0},engineVisible:!1,description:"Dimension layer this emitter targets (0 = fundamental; null = default). Emitted particles are placed in this layer. Stored on the emitter wrapper; no engine ABI change required."}]};at(Tt,{from:new URL("frqtl/objects/objects/QuantumEmitter.js",ze()).href,descriptor:m_,defaults:{source_rects:[[50,95,10,10]],vx:1,vy:0,burst_size:1,chargeMode:"random",auto_fire:!0,random_direction:!1,quantum_limit:null,delay:0,wrap:!1},build:o(function(e,t,r){var i=r,n=Se,a=Ee,s=20,l=20,c;if(e.rect)c=[e.rect.left||0,e.rect.top||0,e.rect.w||s,e.rect.h||l];else if(e.source_rects&&e.source_rects.length){var f=e.source_rects[0];c=f.slice?f.slice():f}else c=[Math.round(t.x-s/2),Math.round(t.y-l/2),s,l];var u=new i(t.runner.universe,[c.slice?c.slice():c],e.vx!=null?e.vx:1,e.vy!=null?e.vy:0,e.burst_size!=null?e.burst_size:1,null,e.auto_fire!=null?e.auto_fire:!0,e.random_direction!=null?e.random_direction:!1,e.quantum_limit!=null?e.quantum_limit:1/0,e.delay!=null?e.delay:0,e.wrap||!1);u._schemaKind=r.name,e.chargeMode&&(u.chargeMode=e.chargeMode),e.colorOverride&&(u.colorOverride=e.colorOverride);var h=e.layer!=null?[e.layer]:null,g=e.name||"emitter "+ec(t.runner,"QuantumEmitter");u.name=g;var d=new n(t.runner.universe,[c[0],c[1],c[2]||s,c[3]||l],a.NONE,[],g,"closest",h,1,e.color||[80,200,80]);return d.drawAsCircle=!0,d._schemaKind="LargeObject",u.attachMarker(d),u},"build")})});var Ah={};ge(Ah,{OvenBox:()=>Yi});function g_(e,t,r){var i=Zt,n=i.Lit,a=i.Ref,s=i.Bin,l=i.Cmp,c=i.Cond,f=i.Fn,u=i.HANDLE_FRAME,h=i.HANDLE_SELF,g=[],d=Nn,m=d.buildEjectOps(e,u,h,n,a,s,l,c,f);if(!m)return null;for(var b=0;b<m.length;b++)g.push(m[b]);if(r){var y=d.buildVelocityFlipOp(t,u,n,a,s);y&&g.push(y)}if(g.length===0)return null;var w=Nn,x=w.buildTriggerExpr(e,!0,u,h,n,a,l,c,f),S={on:"collision",ops:g};return w.applyProgramTrigger(S,x),S}function Yi(e,t){t=t||{},this.universe=e,this._schemaKind=this.constructor.name,this.name=t.name||"oven",this.temperature=t.temperature||300;var r=t.wallThickness||10,i=t.slitHeight||60,n=t.slitWall||"right",a=t.layer3!==void 0?t.layer3:!0,s=a&&(t.layer4!==void 0?t.layer4:!0);this.box=new hn(e,{left:t.left,top:t.top,width:t.width,height:t.height,wallThickness:r,collisionType:Ee.NONE,actions:[],color:t.color||[120,120,120],slit:{wall:n,height:i}}),this.walls=this.box.walls;var l=t.left,c=t.top,f=t.width,u=t.height;if(a)for(var h=0;h<this.walls.length;h++){var g=this.walls[h],d=g_(g.reposition,g.name,s);d&&e.updateObjectProperty(g.handle,"LargeObject","program",d)}var m=l-r,b=c-r,y=f+2*r,w=u+2*r;this.emitters=[],this.emitters.push(new Tt(e,[[m+r+4,b+2,1,w-4]],1,0,1,null,!1,!1,1/0,0)),this.emitters.push(new Tt(e,[[m+y-r-4,b+2,1,w-4]],-1,0,1,null,!1,!1,1/0,0)),this.emitters.push(new Tt(e,[[m+2*r+2,b+r+5,y-2*r-4,1]],0,1,1,null,!1,!1,1/0,0)),this.emitters.push(new Tt(e,[[m+2*r+2,b+w-r-2,y-2*r-4,1]],0,-1,1,null,!1,!1,1/0,0)),this.box._owner=this;for(var x=0;x<this.emitters.length;x++)this.emitters[x]._owner=this;var S=t.countSource||"active-quanta";if(this._countSource=S,this.ovenHandle=null,this._counterWall=null,S==="oven-rect"){var A=new _e(e,{rect:[l,c,f,u],collisionBehavior:"nothing",visible:!1,name:"oven_counter"});A._owner=this,this._counterWall=A;var T=Zt,j=T.Lit,Q=T.Ref,Y=T.Bin,H=T.Fn,V=T.HANDLE_FRAME,C=T.HANDLE_SELF,J=Nn,R=J.buildTriggerExpr(null,!1,V,C,j,Q,function(B,ie,oe){return{kind:"Cmp",op:B,a:ie,b:oe}},function(B,ie,oe){return{kind:"Cond",test:B,then:ie,else:oe}},H),K={on:"collision",ops:[{set:C+".count",to:Y("+",Q(C,"count"),j(1))}]};J.applyProgramTrigger(K,R),A.lo.program=K,e&&typeof e.updateObjectProperty=="function"&&e.updateObjectProperty(A.lo.handle,"LargeObject","program",K),this.ovenHandle=A.lo.handle;var N=this;this.thermostatStep=function(B){e.updateObjectProperty(N.ovenHandle,"LargeObject","count",0);var ie=0;B&&B.objects&&B.objects[N.ovenHandle]!==void 0&&(ie=B.objects[N.ovenHandle].count||0);var oe=0;ie<N.temperature&&(oe=Math.max(1,Math.floor((N.temperature-ie)/N.emitters.length)));for(var $=0;$<N.emitters.length;$++)oe>0&&N.emitters[$].setBurstSize(oe),N.emitters[$].setActive(oe>0)}}}var v_,Th=ue(()=>{At();wh();kh();_r();Vt();ti();wi();In();Mn();xt();o(g_,"makeEjectProgram");o(Yi,"OvenBox");Yi.prototype.getTemperatureTickFunction=function(){if(this._countSource==="oven-rect")throw new Error("[OvenBox] getTemperatureTickFunction() is not applicable when countSource='oven-rect'. Use thermostatStep(tickData) instead \u2014 call it after every doTick() in your harness.");var e=this;return function(){var t=typeof e.universe.activeQuanta=="function"?e.universe.activeQuanta():e.universe.activeQuanta,r=Math.floor(e.temperature-t);if(r<=0){for(var i=0;i<e.emitters.length;i++)e.emitters[i].setActive(!1);return[]}for(var n=Math.max(1,Math.floor(r/e.emitters.length)),i=0;i<e.emitters.length;i++)e.emitters[i].setBurstSize(n),e.emitters[i].setActive(!0);return[]}};Yi.prototype.setTemperature=function(e){this.temperature=e};Yi.prototype.getTemperature=function(){return this.temperature};Yi.prototype.dispose=function(){for(var e=0;e<this.emitters.length;e++)this.emitters[e].dispose();this.box.dispose(),this._counterWall&&this._counterWall.dispose()};v_={description:"A thermostat-controlled cavity for blackbody radiation experiments. Builds a Box with a slit on one wall and installs 4 inward-firing wall emitters (top, bottom, left, right). A tick function adjusts emitter burst sizes to maintain the target quanta count (temperature). Demonstrates how energy equilibrium emerges from local emitter control rather than a global energy equation.",fields:[{name:"left",type:"number",constraint:{integer:!0},engineVisible:!0,description:"Inner box left X position (physics pixels)."},{name:"top",type:"number",constraint:{integer:!0},engineVisible:!0,description:"Inner box top Y position (physics pixels)."},{name:"width",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Inner box width (physics pixels)."},{name:"height",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Inner box height (physics pixels)."},{name:"wallThickness",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Wall thickness in physics pixels (default 10)."},{name:"temperature",type:"number",constraint:{min:1,integer:!0},engineVisible:!1,widgetConfig:{max:3e3,step:50},description:'Target quanta count inside the cavity (the "temperature"). The thermostat tick function increases emission until this count is reached, then stops all emitters. Higher = more particles = higher "temperature".'},{name:"slitHeight",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Height of the slit opening on the exit wall (physics pixels, default 60). Particles leak through this slit to the outside for blackbody spectrum measurement."},{name:"color",type:"rgb",engineVisible:!1,live:!0,description:"Render color [r, g, b] for the box walls (render-only). A live edit fans out to every wall the group owns (the `_owner` fan-out in updateObjectProperty)."}]};at(Yi,{from:new URL("frqtl/parts/OvenBox.js",ze()).href,descriptor:v_,defaults:{left:60,top:40,width:100,height:120,wallThickness:10,temperature:300,slitHeight:60,color:[120,120,120]},build:o(function(e,t,r){var i=r,n=new i(t.runner.universe,Object.assign({left:e.left!=null?e.left:Math.round(t.x-50),top:e.top!=null?e.top:Math.round(t.y-60),width:100,height:120,wallThickness:10,temperature:300,slitHeight:60,color:[120,120,120]},e));return n._schemaKind=r.name,n},"build")})});var Ch={};ge(Ch,{PointSource:()=>Ht});function y_(e){if(e==null)return"random";if(typeof e=="string"){var t=e.toUpperCase();if(t==="POSITIVE"||e==="Positive"||e==="+")return"positive";if(t==="NEGATIVE"||e==="Negative"||e==="-")return"negative"}return e===0?"positive":e===1?"negative":"random"}function ug(e){return e==="positive"?"POSITIVE":e==="negative"?"NEGATIVE":null}function is(e,t){return String(e)+":"+String(!!t)}function b_(e,t){var r=[];if(t!=null)for(var i=Math.max(t,e),n=i;n>=t;n-=2)r.push(n);else r.push(e);return r}function Ht(e,t,r,i,n,a,s,l,c,f,u){a===void 0&&(a=null),s=s!==void 0?s:!0,l=l!==void 0?l:1/0,c=c!==void 0?c:0,f=f!==void 0?f:5,u=u||{};var h=u.emergentPhysics||!1,g=u.minRadius!==void 0?u.minRadius:null,d=u.color||null,m=u.wavelength||null,b=u.zMin!==void 0?u.zMin:null,y=u.zDepth!==void 0?u.zDepth:null;this.universe=e,this._schemaKind=this.constructor.name,this.x=t,this.y=r,this.diameter=i,this.speed=n,this.angle_increment=f,this.auto_fire=s,this.colorOverride=d||null,this.renderShape=null,this.renderOutline=null,this._chargeMode=y_(a),this._random_direction=!1,this._emergentPhysics=h,this._color=d,this._wavelength=m,this._quantum_limit=l,this._delay=c,this._zMin=b,this._zDepth=y,this._radii=b_(i/2,g),this._handleGroups={},this._ensureAndActivate(this._chargeMode,this._random_direction),this.emitterHandles=this._activeHandles()}var cg,w_,rc=ue(()=>{At();_h();xt();_r();Vt();ln();tc();cg=Zl;o(y_,"_chargeToMode");o(ug,"_modeToCharge");o(is,"_groupKey");o(b_,"_buildRadii");o(Ht,"PointSource");Ht.prototype._ensureGroup=function(e,t){var r=is(e,t);if(this._handleGroups[r]!==void 0)return this._handleGroups[r];for(var i=[],n=this.universe,a=this.x,s=this.y,l=this.angle_increment,c=Math.floor(360/l),f=this._emergentPhysics,u=this._color,h=this.renderShape,g=this.renderOutline,d=this._wavelength,m=this._quantum_limit,b=this._delay,y=this._radii,w=!!t,x=this.auto_fire,S=this._zMin,A=this._zDepth,T=0;T<y.length;T++)for(var j=y[T],Q=0;Q<c;Q++){var Y=Q*l,H=Y*Math.PI/180,V=a+j*Math.cos(H),C=s+j*Math.sin(H),J,R;f?(J=0,R=0):(J=j*Math.cos(H),R=j*Math.sin(H));var K=[Math.round(V),Math.round(C),1,1],N={sourceRects:[K],vx:J,vy:R,burstSize:1,charge:e,randomDirection:w,quantumLimit:m===1/0||m==null?1/0:m,remainingQuanta:m===1/0||m==null?1/0:m,delay:b||0,remainingDelay:b||0,active:x,tombstoned:!1,color:u||null,renderShape:h||null,renderOutline:g??null,wrap:!1,wavelength:d||null,fundamentalDim:null,zMin:S,zDepth:A},B=cg(n,N);B._emState=N,n.experimentTickFunctions.push(B),i.push(N)}return this._handleGroups[r]=i,i};Ht.prototype._ensureAndActivate=function(e,t){var r=!!t,i=this,n=[];e==="both"?(n.push({charge:"POSITIVE",rd:r}),n.push({charge:"NEGATIVE",rd:r})):n.push({charge:ug(e),rd:r});for(var a=0;a<n.length;a++)i._ensureGroup(n[a].charge,n[a].rd);for(var s={},l=0;l<n.length;l++)s[is(n[l].charge,n[l].rd)]=!0;for(var c=Object.keys(i._handleGroups),f=0;f<c.length;f++)for(var u=c[f],h=i._handleGroups[u],g=!!s[u],d=0;d<h.length;d++)h[d].active=g};Ht.prototype._activeHandles=function(){var e=this._chargeMode,t=this._random_direction,r=[],i={};e==="both"?(i[is("POSITIVE",t)]=!0,i[is("NEGATIVE",t)]=!0):i[is(ug(e),t)]=!0;for(var n=Object.keys(this._handleGroups),a=0;a<n.length;a++)if(i[n[a]])for(var s=this._handleGroups[n[a]],l=0;l<s.length;l++)r.push(s[l]);return r};Ht.prototype.forEachHandle=function(e){for(var t=Object.keys(this._handleGroups),r=0;r<t.length;r++)for(var i=this._handleGroups[t[r]],n=0;n<i.length;n++)e(i[n])};Object.defineProperty(Ht.prototype,"chargeMode",{get:o(function(){return this._chargeMode},"get"),set:o(function(e){var t={random:!0,positive:!0,negative:!0,both:!0};if(!t[e])throw new TypeError('[PointSource] Invalid chargeMode "'+e+'". Expected: random | positive | negative | both');this._chargeMode=e,this._ensureAndActivate(e,this._random_direction),this.emitterHandles=this._activeHandles()},"set"),enumerable:!0,configurable:!0});Object.defineProperty(Ht.prototype,"random_direction",{get:o(function(){return this._random_direction},"get"),set:o(function(e){var t=!!e;this._random_direction=t,this._ensureAndActivate(this._chargeMode,t),this.emitterHandles=this._activeHandles()},"set"),enumerable:!0,configurable:!0});Ht.prototype.setActive=function(e){this.auto_fire=e;var t=this;if(e)this._ensureAndActivate(this._chargeMode,this._random_direction);else for(var r=Object.keys(t._handleGroups),i=0;i<r.length;i++)for(var n=t._handleGroups[r[i]],a=0;a<n.length;a++)n[a].active=!1};Ht.prototype.repositionToRect=function(e,t,r,i,n){var a=n||this.universe,s=e+r/2,l=t+i/2,c=this.diameter/2,f=this.angle_increment,u=Math.floor(360/f);this.x=s,this.y=l,this._marker&&this._marker.setRect([Math.round(s-this.diameter/2),Math.round(l-this.diameter/2),this.diameter,this.diameter]);for(var h=[],g=0;g<u;g++){var d=g*f,m=d*Math.PI/180,b=Math.round(s+c*Math.cos(m)),y=Math.round(l+c*Math.sin(m));h.push([b,y,1,1])}for(var w=Object.keys(this._handleGroups),x=0;x<w.length;x++)for(var S=this._handleGroups[w[x]],A=0;A<S.length;A++){var T=A%u;S[A].sourceRects=[h[T]]}};Ht.prototype.dispose=function(){if(!this._disposed){this._disposed=!0;for(var e=[],t=Object.keys(this._handleGroups),r=0;r<t.length;r++)for(var i=this._handleGroups[t[r]],n=0;n<i.length;n++)i[n].tombstoned=!0,i[n].active=!1,e.push(i[n]);if(this.universe&&Array.isArray(this.universe.experimentTickFunctions))for(var a=this.universe.experimentTickFunctions,s=a.length-1;s>=0;s--)a[s]._emState&&e.indexOf(a[s]._emState)!==-1&&a.splice(s,1);this._marker&&typeof this._marker.dispose=="function"&&this._marker.dispose()}};Ht.prototype.attachMarker=function(e){if(!e||typeof e!="object")throw new TypeError("[PointSource.attachMarker] needs the marker LargeObject. (FAIL-LOUD.)");if(this._marker)throw new Error("[PointSource.attachMarker] this emitter already owns a marker. (FAIL-LOUD.)");return this._marker=e,e._owner=this,this};w_={description:"A radial point emitter that fires particles outward from the surface of a circle at regular angular intervals. Each angle gets its own engine emitter handle so the angular pattern is deterministic. Produces wave fronts, interference patterns, and Big Bang-style expansions depending on configuration.",fields:[{name:"rect",type:"rect",engineVisible:!0,description:"Canonical bounding rect "+bt(4)+" \u2014 repositions center (cx=left+w/2, cy=top+h/2) and recomputes all angle source rects (one-path via repositionToRect)"},{name:"x",type:"number",constraint:{integer:!0},engineVisible:!0,description:"Center X of the point source (physics pixels)"},{name:"y",type:"number",constraint:{integer:!0},engineVisible:!0,description:"Center Y of the point source (physics pixels)"},{name:"diameter",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Diameter of the emission circle (physics pixels)"},{name:"speed",type:"number",constraint:{min:0,integer:!1},engineVisible:!0,unit:"px/tick",description:"Velocity magnitude for emitted particles (pixels/tick)"},{name:"auto_fire",type:"boolean",engineVisible:!0,description:"Whether all angle emitters fire automatically"},{name:"quantum_limit",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Max quanta per angle emitter (null = Infinity)"},{name:"delay",type:"number",constraint:{min:0,integer:!0},engineVisible:!0,description:"Ticks between bursts for each angle emitter"},{name:"angle_increment",type:"number",constraint:{min:1,max:360,integer:!1},engineVisible:!0,description:"Degrees between emission angles. Fewer degrees = more angles = denser wave front. 5\xB0 gives 72 directions; 10\xB0 gives 36; 45\xB0 gives 8 (coarser)."},{name:"colorOverride",type:"rgb",engineVisible:!1,description:"Override render color for emitted particles [r, g, b] (render-only; stored on the emitter wrapper)."},{name:"chargeMode",type:"enum",constraint:{values:{random:"random",positive:"positive",negative:"negative",both:"both"}},engineVisible:!1,description:'High-level charge mode (sugar layer). "both" creates two per-angle handle groups (POSITIVE + NEGATIVE), doubling the emission count. Toggles the handle active flag \u2014 no engine ABI change.'},{name:"random_direction",type:"boolean",engineVisible:!1,description:"Whether emitted particles have randomized direction (sugar layer). PointSource normally uses directed emission; enabling this registers a new handle group with rd=true."},{name:"layer",type:"number",constraint:{min:0,integer:!0},engineVisible:!1,description:"Dimension layer this emitter targets (0 = fundamental; null = default). Stored on the emitter wrapper; no engine ABI change required."}]};at(Ht,{from:new URL("frqtl/parts/PointSource.js",ze()).href,descriptor:w_,defaults:{x:50,y:100,diameter:16,speed:1,chargeMode:"random",auto_fire:!0,quantum_limit:null,delay:0,angle_increment:10},build:o(function(e,t,r){var i=r,n=Se,a=Ee,s=e.x!=null?e.x:Math.round(t.x),l=e.y!=null?e.y:Math.round(t.y),c=e.diameter||16,f=new i(t.runner.universe,s,l,c,e.speed!=null?e.speed:1,null,e.auto_fire!=null?e.auto_fire:!0,e.quantum_limit!=null?e.quantum_limit:1/0,e.delay!=null?e.delay:0,e.angle_increment||10,{wavelength:e._wavelength!=null?e._wavelength:null,color:e._optColor||null,emergentPhysics:e._emergentPhysics||!1});f._schemaKind=r.name,e.chargeMode&&(f.chargeMode=e.chargeMode),e.colorOverride&&(f.colorOverride=e.colorOverride);var u=Math.round(s-c/2),h=Math.round(l-c/2),g=c,d=c,m=e.name||"source "+ec(t.runner,"PointSource");f.name=m;var b=new n(t.runner.universe,[u,h,g,d],a.NONE,[],m,"closest",null,1,[0,0,0]);return b.drawAsCircle=!0,b._schemaKind="LargeObject",f.attachMarker(b),f},"build")})});var jh={};ge(jh,{SlitLightSource:()=>pn});function pn(e,t,r,i,n,a){r=r!==void 0?r:10,i=i!==void 0?i:1/0,n=n!==void 0?n:1,a=a||{};var s=a.depth!==void 0&&a.depth!==null?a.depth:null,l=s!==null?-s/2:null,c=s!==null?s:null;this.universe=e,this._schemaKind=this.constructor.name;var f=16,u=20,h=t.slit_wall_gap_top+t.slit_wall_gap_height/2,g=null,d=1,m=a.color!==void 0?a.color:null;this.lightSource=new Ht(e,u,h,f,d,g,!0,i,n,r,{color:m,wavelength:t.wavelength,zMin:l,zDepth:c}),this.lightSource._owner=this}var __,Rh=ue(()=>{At();rc();xt();$l();o(pn,"SlitLightSource");pn.prototype.getTickFunction=function(){return function(){}};pn.prototype.setActive=function(e){this.lightSource.setActive(e)};Object.defineProperty(pn.prototype,"chargeMode",{get:o(function(){return this.lightSource.chargeMode},"get"),set:o(function(e){this.lightSource.chargeMode=e},"set"),enumerable:!0,configurable:!0});__={description:"A radial light source for the double-slit experiment. Wraps a PointSource positioned equidistant between the two slits (at the inter-slit gap center), so particles reach both openings with equal path length. Emits in all directions; the slit screen selects which particles pass through.",fields:[{name:"angle_increment",type:"number",constraint:{min:1,max:360,integer:!1},engineVisible:!0,description:"Degrees between emission angles (fewer degrees = more angles = denser wave front). 10\xB0 gives 36 directions, the double-slit experiment default."},{name:"quantum_limit",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Max quanta per angle emitter (null/Infinity = unlimited). Limits total particle count for performance control."},{name:"delay",type:"number",constraint:{min:0,integer:!0},engineVisible:!0,description:"Ticks between bursts for each angle emitter. 1 = emit every other tick (default for the double-slit source)."}]};at(pn,{from:new URL("frqtl/parts/SlitLightSource.js",ze()).href,descriptor:__,defaults:{angle_increment:10,quantum_limit:null,delay:1},build:o(function(){throw new Error('[ObjectFactory] create("SlitLightSource"): a SlitLightSource requires a paired SlitScreen and cannot be constructed independently \u2014 build it through its setup factory (setupDoubleSlit), or compose '+Ha.SlitLightSource+". (FAIL-LOUD.)")},"build")})});var Dh={};ge(Dh,{SlitScreen:()=>Xn});function dn(e,t,r,i){th(e,r,i,{slitScatter:t})}function Xn(e,t,r,i,n,a,s,l,c,f,u,h){this.universe=e,this._schemaKind=this.constructor.name,this.wavelength=n,this.depth=f??null,this.linerScatter=h||"current",this.slit_height=l!==void 0?l:Math.floor(n*.8),this.slit_wall_gap_height=c!==void 0?c:Math.floor(n*.8),this.slit_group_height=this.slit_height+this.slit_wall_gap_height+this.slit_height,this.slit_group_center_y=i/2,this.slit1_top=this.slit_group_center_y-this.slit_group_height/2,this.slit_wall_gap_top=this.slit1_top+this.slit_height,this.slit2_bottom=this.slit_group_center_y+this.slit_group_height/2,this.slit2_top=this.slit2_bottom-this.slit_height,this.slit_group_left=t,this.slit_width=r,this.bottom_wall_height=i-this.slit2_bottom,this.hole_depth=u??this.slit_height;var g=a?[st.ABSORB]:[st.BLOCK],d=Ee.NONE,m=a?"destroy":"block",b=e;function y($,pe,ye){return new _e(b,{rect:$,collisionBehavior:m,name:pe,color:ye}).lo}o(y,"_wallLO");var w=[st.MARK],x=Ee.NONE,S=[0,0,0,0],A=[0,0,0,0];s===1&&(w.push(st.DETECT),x=Ee.RANDOM_XY),s===2&&(w.push(st.DETECT),S=[0,0,255],A=[0,0,255]);var T=Math.min(10,Math.floor(this.slit_height*.2)),j=this.depth;if(j===null){let $=function(pe,ye,ce,L){return[pe,ye,ce,L]};o($,"rect3"),this.wall1=y($(this.slit_group_left,0,this.slit_width,this.slit1_top-1),"wall1",[255,0,0]),this.slit1=new Se(e,$(this.slit_group_left,this.slit1_top,this.slit_width,this.slit_height-1),x,w,"slit1","closest",null,1,S),this.wall2=y($(this.slit_group_left,this.slit_wall_gap_top,this.slit_width,this.slit_wall_gap_height-1),"wall2",[128,0,0]),this.slit2=new Se(e,$(this.slit_group_left,this.slit2_top,this.slit_width,this.slit_height-1),x,w,"slit2","closest",null,1,A),this.wall3=y($(this.slit_group_left,this.slit2_bottom,this.slit_width,this.bottom_wall_height-1),"wall3",[255,0,0]);var Q=new Se(e,$(this.slit_group_left,this.slit1_top,this.slit_width,T),Ee.RANDOM_XY,[st.BLOCK],"slit1_liner_top","closest",null,1,[0,0,255]);dn(Q,this.linerScatter,e,"bottom");var Y=new Se(e,$(this.slit_group_left,this.slit1_top+this.slit_height-T,this.slit_width,T),Ee.RANDOM_XY,[st.BLOCK],"slit1_liner_bottom","closest",null,1,[0,0,255]);dn(Y,this.linerScatter,e,"top");var H=new Se(e,$(this.slit_group_left,this.slit2_top,this.slit_width,T),Ee.RANDOM_XY,[st.BLOCK],"slit2_liner_top","closest",null,1,[0,0,255]);dn(H,this.linerScatter,e,"bottom");var V=new Se(e,$(this.slit_group_left,this.slit2_top+this.slit_height-T,this.slit_width,T),Ee.RANDOM_XY,[st.BLOCK],"slit2_liner_bottom","closest",null,1,[0,0,255]);dn(V,this.linerScatter,e,"top"),this.walls=[this.wall1,this.slit1,this.wall2,this.slit2,this.wall3,Q,Y,H,V]}else{let $=function(X,te,be,Oe){return[X,te,C,be,Oe,j]},pe=function(X,te,be,Oe,Ue,Ce){return[X,te,Ue,be,Oe,Ce]};o($,"zSlab"),o(pe,"zBand");var C=-j/2,J=-this.hole_depth/2,R=this.hole_depth,K=J+R,N=J-C,B=j/2-K;this.wall1=y($(this.slit_group_left,0,this.slit_width,this.slit1_top-1),"wall1",[255,0,0]),this.slit1_near=new Se(e,pe(this.slit_group_left,this.slit1_top,this.slit_width,this.slit_height-1,C,N),Ee.NONE,g,"slit1_near","closest",null,1,[200,60,60]),this.slit1=new Se(e,pe(this.slit_group_left,this.slit1_top,this.slit_width,this.slit_height-1,J,R),x,w,"slit1","closest",null,1,S),this.slit1_far=new Se(e,pe(this.slit_group_left,this.slit1_top,this.slit_width,this.slit_height-1,K,B),Ee.NONE,g,"slit1_far","closest",null,1,[200,60,60]),this.wall2=y($(this.slit_group_left,this.slit_wall_gap_top,this.slit_width,this.slit_wall_gap_height-1),"wall2",[128,0,0]),this.slit2_near=new Se(e,pe(this.slit_group_left,this.slit2_top,this.slit_width,this.slit_height-1,C,N),Ee.NONE,g,"slit2_near","closest",null,1,[200,60,60]),this.slit2=new Se(e,pe(this.slit_group_left,this.slit2_top,this.slit_width,this.slit_height-1,J,R),x,w,"slit2","closest",null,1,A),this.slit2_far=new Se(e,pe(this.slit_group_left,this.slit2_top,this.slit_width,this.slit_height-1,K,B),Ee.NONE,g,"slit2_far","closest",null,1,[200,60,60]),this.wall3=y($(this.slit_group_left,this.slit2_bottom,this.slit_width,this.bottom_wall_height-1),"wall3",[255,0,0]);var Q=new Se(e,pe(this.slit_group_left,this.slit1_top,this.slit_width,T,J,R),Ee.RANDOM_XY,[st.BLOCK],"slit1_liner_top","closest",null,1,[0,0,255]);dn(Q,this.linerScatter,e,"bottom");var Y=new Se(e,pe(this.slit_group_left,this.slit1_top+this.slit_height-T,this.slit_width,T,J,R),Ee.RANDOM_XY,[st.BLOCK],"slit1_liner_bottom","closest",null,1,[0,0,255]);dn(Y,this.linerScatter,e,"top");var H=new Se(e,pe(this.slit_group_left,this.slit2_top,this.slit_width,T,J,R),Ee.RANDOM_XY,[st.BLOCK],"slit2_liner_top","closest",null,1,[0,0,255]);dn(H,this.linerScatter,e,"bottom");var V=new Se(e,pe(this.slit_group_left,this.slit2_top+this.slit_height-T,this.slit_width,T,J,R),Ee.RANDOM_XY,[st.BLOCK],"slit2_liner_bottom","closest",null,1,[0,0,255]);dn(V,this.linerScatter,e,"top"),this.walls=[this.wall1,this.slit1_near,this.slit1,this.slit1_far,this.wall2,this.slit2_near,this.slit2,this.slit2_far,this.wall3,Q,Y,H,V]}for(var ie=0;ie<this.walls.length;ie++)this.walls[ie].rect.d!==void 0&&(this.walls[ie].shape="box",this.walls[ie].depth=this.walls[ie].rect.d);for(var oe=0;oe<this.walls.length;oe++)this.walls[oe]._owner=this}var x_,Lh=ue(()=>{At();_r();Vt();ti();Bl();wi();xt();bi();o(dn,"_applyLinerScatter");o(Xn,"SlitScreen");Xn.prototype.dispose=function(){for(var e=0;e<this.walls.length;e++)this.walls[e].dispose()};Xn.prototype.updateGapHeight=function(e,t){if(this.depth!==null)return!1;if(!t||typeof t.updateObjectProperty!="function")throw new Error("[SlitScreen.updateGapHeight] requires a runner exposing updateObjectProperty(lo, prop, value).");var r=this.slit_group_center_y*2;this.slit_wall_gap_height=e,this.slit_group_height=this.slit_height+this.slit_wall_gap_height+this.slit_height,this.slit1_top=this.slit_group_center_y-this.slit_group_height/2,this.slit_wall_gap_top=this.slit1_top+this.slit_height,this.slit2_bottom=this.slit_group_center_y+this.slit_group_height/2,this.slit2_top=this.slit2_bottom-this.slit_height,this.bottom_wall_height=r-this.slit2_bottom;var i=Math.min(10,Math.floor(this.slit_height*.2)),n=this.slit_group_left,a=this.slit_width;function s(y,w){for(var x=0;x<y.length;x++)if(y[x].name===w)return y[x];return null}o(s,"findWall");var l=s(this.walls,"wall1");l&&t.updateObjectProperty(l,"rect",[n,0,a,this.slit1_top-1]);var c=s(this.walls,"slit1");c&&t.updateObjectProperty(c,"rect",[n,this.slit1_top,a,this.slit_height-1]);var f=s(this.walls,"wall2");f&&t.updateObjectProperty(f,"rect",[n,this.slit_wall_gap_top,a,this.slit_wall_gap_height-1]);var u=s(this.walls,"slit2");u&&t.updateObjectProperty(u,"rect",[n,this.slit2_top,a,this.slit_height-1]);var h=s(this.walls,"wall3");h&&t.updateObjectProperty(h,"rect",[n,this.slit2_bottom,a,this.bottom_wall_height-1]);var g=s(this.walls,"slit1_liner_top");g&&t.updateObjectProperty(g,"rect",[n,this.slit1_top,a,i]);var d=s(this.walls,"slit1_liner_bottom");d&&t.updateObjectProperty(d,"rect",[n,this.slit1_top+this.slit_height-i,a,i]);var m=s(this.walls,"slit2_liner_top");m&&t.updateObjectProperty(m,"rect",[n,this.slit2_top,a,i]);var b=s(this.walls,"slit2_liner_bottom");return b&&t.updateObjectProperty(b,"rect",[n,this.slit2_top+this.slit_height-i,a,i]),!0};x_={description:"A double-slit barrier that produces quantum interference. Creates 9 sub-LargeObjects: wall1 (above slit1), slit1, wall2 (between slits), slit2, wall3 (below slit2), and 4 edge-diffraction liners (slit1_liner_top/bottom, slit2_liner_top/bottom). The group is the single author-surface entity; slit geometry is derived from the wavelength so the interference fringe spacing is automatically correct for the particle wavelength.",fields:[{name:"slit_group_left",type:"number",constraint:{integer:!0},engineVisible:!0,description:"X position of the slit barrier left edge (physics pixels). Moving this repositions the entire slit assembly."},{name:"slit_width",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,unit:"px",description:"Width/thickness of the slit screen (physics pixels). Thicker screens affect diffraction character."},{name:"wavelength",type:"number",constraint:{min:4,integer:!0},engineVisible:!0,description:"Wavelength driving slit and gap sizing. Default slit height = floor(wavelength * 0.8); inter-slit gap = same. Engine invariant 6: minimum wavelength is 4."},{name:"slit_height",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Height of each slit opening (physics pixels). Narrower slits increase diffraction spread; wider slits reduce it."},{name:"slit_wall_gap_height",type:"number",constraint:{min:1,integer:!0},engineVisible:!0,description:"Height of the wall segment between the two slits (physics pixels). Larger gap \u2192 tighter interference fringes on the screen."},{name:"absorbAtSlitWall",type:"boolean",engineVisible:!0,description:"If true, wall segments use ABSORB (particles disappear on contact). If false, walls use BLOCK. Absorbing walls eliminate back-scatter and produce cleaner interference patterns."},{name:"detectAtSlits",type:"enum",constraint:{values:{NONE:0,DETECT_RANDOM_XY:1,DETECT_MARK:2}},engineVisible:!0,description:"Slit detection mode: 0 = no detection (coherent, wave-like pattern); 1 = DETECT+RANDOM_XY (which-path measurement collapses the wavefunction); 2 = DETECT+MARK (which-path marker via string_map.detector_name)."}]};at(Xn,{from:new URL("frqtl/parts/SlitScreen.js",ze()).href,descriptor:x_,defaults:{slit_group_left:100,slit_width:8,wavelength:20,slit_height:16,slit_wall_gap_height:16,absorbAtSlitWall:!0,detectAtSlits:0},build:o(function(e,t,r){var i=r,n=Be.worldRect(t.runner.canvas_rect,'ObjectFactory create("SlitScreen") runner.canvas_rect').h,a=new i(t.runner.universe,e.slit_group_left!=null?e.slit_group_left:Math.round(t.x),e.slit_width||8,n,e.wavelength||20,e.absorbAtSlitWall!=null?e.absorbAtSlitWall:!0,e.detectAtSlits!=null?e.detectAtSlits:0,e.slit_height,e.slit_wall_gap_height);return a._schemaKind=r.name,a},"build")})});var ic={};ge(ic,{CameraControls:()=>$s,CameraPath:()=>Sa,CollisionActions:()=>st,CollisionTypes:()=>Ee,DetectorWall:()=>_i,FrqtlControlOverlay:()=>Dl,FrqtlControlsPanel:()=>xi,FrqtlVision:()=>Kn,GraphingDetectorWall:()=>Nt,LargeObject:()=>Se,LightColor:()=>Ei,LiveChart:()=>Jn,LogicGate:()=>Me,OvenBox:()=>Yi,PointSource:()=>Ht,Rectangle:()=>lt,SlitLightSource:()=>pn,SlitScreen:()=>Xn,SphereEmitter:()=>Le,Trace:()=>Bt,Tunnel:()=>yt,Wall:()=>_e});var nc=ue(()=>{yu();il();ti();Vt();hf();kf();Ia();ql();Jf();_r();Ba();$f();yh();Th();rc();Do();Rh();Lh();ts();Xl();es();wi()});var PO={};ge(PO,{CameraControls:()=>$s,CameraPath:()=>Sa,CaptureEnvelope:()=>Ma,CollisionActions:()=>st,CollisionTypes:()=>Ee,DetectorWall:()=>_i,FieldBuilder:()=>Er,FrqtlCapture:()=>lc,FrqtlControlOverlay:()=>Dl,FrqtlControlsPanel:()=>xi,FrqtlVision:()=>Kn,GraphingDetectorWall:()=>Nt,LargeObject:()=>Se,LightColor:()=>Ei,LiveChart:()=>Jn,LogicGate:()=>Me,OvenBox:()=>Yi,PointSource:()=>Ht,RENDERER_PROVIDER_OPTIONAL:()=>Ll,RENDERER_PROVIDER_REQUIRED:()=>qo,Rectangle:()=>lt,RenderStages:()=>lr,SlitLightSource:()=>pn,SlitScreen:()=>Xn,SphereEmitter:()=>Le,Trace:()=>Bt,Tunnel:()=>yt,Wall:()=>_e,bootProject:()=>LO,bootRecipe:()=>Ky,bootScene:()=>$y,engine:()=>ea,engineState:()=>ns,modules:()=>rb,validateRendererProvider:()=>Vo});At();nc();var Bh={};ge(Bh,{JS_ARCHIVED_MSG:()=>Sg,bootEngine:()=>Vh,engine:()=>ea,engineState:()=>ns,refuseRetiredDoors:()=>sc});bi();Ba();Do();var O_=Object.freeze({POSITIVE:0,NEGATIVE:1});function dg(e,t,r,i,n,a,s,l,c,f,u,h,g,d){this.tick=e,this.id=t,this.layer=r,this.rect=i,this.fullness=n,this.isAlive=a,this.childCount=s,this.mass=l,this.collidedId=c,this.vx=f,this.vy=u,this.z=h??0,this.vz=g??0,this.data=d??null}o(dg,"FrameData");function mg(e,t,r,i){this.tick=e,this.layer=t,this.frameCount=r,this.boundaryRect=i}o(mg,"DimensionData");function gg(e,t,r){this.tick=e,this.dimensionCount=t,this.boundaryRect=r}o(gg,"UniverseData");function oc(e){this.universeData=e,this.dimensionData=[],this.frameData=[]}o(oc,"TickData");oc.prototype.addDimensionData=function(e){this.dimensionData.push(e)};oc.prototype.addFrameData=function(e){this.frameData.push(e)};function Nh(e){return e.z!==void 0||e.d!==void 0?[e.left,e.top,e.z!==void 0?e.z:0,e.w,e.h,e.d!==void 0?e.d:e.w]:[e.left,e.top,e.w,e.h]}o(Nh,"_rectSpecToArray");var Zn=[{key:"rect",required:!0,unit:"Rectangle (px)",effect:"REQUIRED \u2014 the ONE world-rect declaration; there is no world without it. init(fundamentalDimension, options) reads it and takes no rect. A leaf that leaves this rect is gone (the boundary is the only engine-side sink)."},{key:"seed",def:42,unit:"integer",effect:"THE deterministic RNG stream. Same seed + same ops \u21D2 bit-identical run."},{key:"fps",def:60,unit:"frames/second",effect:"the nominal tick rate the engine config records. Does not change physics per tick (1 tick = 1 time quantum, always)."},{key:"iframeIntervalSeconds",def:1,unit:"seconds",effect:"how often Phase B (STRUCTURE \u2014 build higher dimensions from the fundamental quadtree) runs. 1/60 = every tick (emergent composites appear immediately); 1 = once a second."},{key:"withInterQuantumCollisions",def:!1,unit:"boolean",effect:"false = leaves pass through each other (the fast path). true = leaf-leaf collision resolution (superlinear in alive-count \u2014 this is what makes a medium resistive)."},{key:"withBonding",def:!1,unit:"boolean",effect:"false = no bonding pass. true = collided leaves may bond into composites."},{key:"frameGenMode",def:"groundUp",unit:"'groundUp' | 'topDown'",effect:"how PARENT frames are generated. 'groundUp' = bottom-up, by actual collisions between the smallest frames (collision-based promotion, wave-walk). 'topDown' = by how many frames an area can parent (density clustering, brownian ON, collisions off). init() takes its own frameGenMode and does NOT inherit this one."},{key:"minMBFillRate",def:.1,unit:"fraction of capacity (0..1)",effect:"the minimum fullness a merged/promoted composite must reach to survive."},{key:"wavelengthScale",def:1,unit:"multiplier",effect:"the GLOBAL multiplier on every frame per-frame (capacity/mass) wavelength: lambda_eff = (capacity/mass) * wavelengthScale. Raising it widens fringes. init() re-reads this."},{key:"liveQuantaCap",def:3e5,unit:"leaf quanta | false",effect:"the WASM preview cap: once this many leaf quanta are alive, every further leaf add (makeLeafFrame) is skipped (returns null) until the count falls below it; the debug console is warned once per universe. The default is the preview limit set for this release: a value above it throws. false = uncapped."}],Mh=[{key:"wavelengthScale",def:1,unit:"multiplier",effect:"universe-wide multiplier on every frame's (capacity/mass) wavelength ratio: lambda_eff = (capacity/mass) * wavelengthScale. Raising it widens fringes. (The retired spelling 'wavelengthConstant' THROWS \u2014 see _RETIRED_CONFIG_KEYS.)"},{key:"frameGenMode",def:"groundUp",unit:"'groundUp' | 'topDown'",effect:"how PARENT frames are generated. 'groundUp' = bottom-up, by actual collisions between the smallest frames (promotion, wave-walk). 'topDown' = by how many frames an area can parent (density clustering, brownian ON, no collisions). init() does NOT inherit create()'s frameGenMode \u2014 the create()-time key is a pre-init record only. (The retired bool 'emergentPhysics' THROWS with the VALUE mapping.)"},{key:"brownianMotion",def:void 0,unit:"boolean",effect:"true = brownian random walk \xB7 false = wave-walk (particle walk). Rides the CONFIG BAG (brownian_motion) as the caller's REQUEST; the ENGINE resolves it at construction and JS reads the answer back, so nothing is inherited from a previous init. Omitted \u21D2 null \u21D2 the Rust unwrap_or is the ONE default authority. frameGenMode:'topDown' REQUIRES it: an explicit brownianMotion:false alongside topDown THROWS (the engine coerces it back to true, so accepting the false would be a lie). (The INVERTED alias 'noObserverFrame' is DELETED and THROWS.)"},{key:"noEscape",def:!1,unit:"boolean",effect:"true = children hard-trapped inside the parent rect."},{key:"activeAxes",def:void 0,unit:"{x,y,z} boolean bag",effect:"the 1D/2D/3D selector \u2014 which axes the base-walk + yo-yo coins fire on. Omitted \u21D2 the WASM serde default {x:true,y:true,z:false}, which keeps every existing 2D experiment byte-identical. capacity()/wavelength scale as the product over active axes."},{key:"depth",def:void 0,unit:"pixels",effect:"explicit world z-extent, DECOUPLED from width. Omitted \u21D2 width (a CUBE), so a square 2D scene is byte-identical to the historic coupling. The z-range is CENTERED [-depth/2, depth/2]."},{key:"stepping",def:"fixed",unit:"'fixed' | 'average'",effect:"the wave-walk STEPPING SAMPLER. Both realize the same mean step (1 px/tick along the momentum vector) and differ in the VARIANCE about it. 'fixed' walks a deterministic error accumulator, so along-ray deviation stays bounded below 1 px forever; 'average' draws a per-axis Bernoulli coin, so it random-walks along the ray (Var = (L1/L2 - 1) px^2/tick \u2014 zero on-axis, 0.414 at 45 degrees) and the 2nd/3rd-order interference rings wash out OFF-axis while staying crisp on-axis. Axis-aligned and stationary frames are BIT-IDENTICAL under both. SET ONCE at init \u2014 there is no runtime setter and no live property (a mid-run flip would splice two samplers into one trajectory)."}],Ka={groundUp:"GroundUp",topDown:"TopDown"};function E_(){return Object.keys(Ka).map(function(e){return"'"+e+"'"}).join(" | ")}o(E_,"_frameGenModeNames");function vg(e,t){if(!Object.prototype.hasOwnProperty.call(Ka,t))throw new Error(e+": frameGenMode must be "+E_()+" (got "+JSON.stringify(t)+"). 'groundUp' = parents form from actual collisions between the smallest frames; 'topDown' = parents form from how many frames an area can parent (density clustering).");return t}o(vg,"_assertFrameGenMode");function S_(e){for(var t=Object.keys(Ka),r=0;r<t.length;r++)if(Ka[t[r]]===e)return t[r];throw new Error("EGPTUniverse: the engine reported an unknown frame_gen_mode '"+e+"'. Legal wire names: "+t.map(function(i){return Ka[i]}).join(", ")+".")}o(S_,"_frameGenModeFromWire");var $n={iframe_interval_seconds:"renamed to 'iframeIntervalSeconds'",universe_rect:"renamed to 'rect'",wavelength_constant:"renamed to 'wavelengthScale'",wavelengthConstant:"renamed to 'wavelengthScale'",lowest_dimension:"is RETIRED, and it is NOT a rename. The base (fundamental) scale layer is the FIRST ARGUMENT of init(fundamentalDimension, options) \u2014 pass it there: universe.init(2). create() does not carry it.",lowestDimension:"is RETIRED, and it was INERT: create() recorded it and init() never read it, so create({lowestDimension: 2}) silently ran a dimension-0 world. The base (fundamental) scale layer is the FIRST ARGUMENT of init(fundamentalDimension, options) \u2014 pass it there: universe.init(2).",withFrames:"deleted \u2014 it was inert (the WASM engine always has frames). Remove it.",noObserverFrame:"is DELETED \u2014 it is NOT a rename. It was the INVERTED alias of 'brownianMotion': noObserverFrame:TRUE meant brownianMotion:FALSE (the wave-walk), and noObserverFrame:false meant nothing at all \u2014 it landed on the engine default, which is already brownianMotion:false. So OMIT the key: dropping it is exactly what every caller of it was asking for. Only if you want the random walk instead, pass brownianMotion:true",emergentPhysics:"is RETIRED \u2014 it is now 'frameGenMode', an ENUM, not a boolean. Migrate the VALUE, not just the name: emergentPhysics:true becomes frameGenMode:'topDown' (parent frames are generated by how many frames an area can parent \u2014 density clustering), and emergentPhysics:false becomes frameGenMode:'groundUp' (parent frames are generated by actual collisions between the smallest frames \u2014 the default)"};function yg(e,t){Object.keys(t).forEach(function(r){if(Object.prototype.hasOwnProperty.call($n,r))throw new Error(e+": '"+r+"' "+$n[r]+".")})}o(yg,"_assertNoRetiredKeys");function Ph(){return Zn.map(function(e){return e.key}).join(", ")}o(Ph,"_configKeyList");function k_(){return Mh.map(function(e){return e.key}).join(", ")}o(k_,"_initOptionKeyList");function bg(e,t,r,i){Object.keys(t).forEach(function(n){var a=r.some(function(s){return s.key===n});if(!a)throw new Error(e+": unknown key '"+n+"'. Valid keys: "+i+".")})}o(bg,"_assertNoUnknownKeys");var wg={};function ke(e,t){if(t!==wg)throw new Error("new EGPTUniverse(...) is not the construction path. Build a universe with the ONE construction authority: EGPTUniverse.create(config) \u2014 e.g. EGPTUniverse.create({ rect: { left: 0, top: 0, w: 600, h: 400 }, seed: 42 }). Reach it as engine().EGPTUniverse.create (lib/frqtl/compat/engine.js). Keys + defaults: EGPTUniverse.CONFIG ("+Ph()+").");var r=e;this._params={fps:r.fps,iframe_interval_seconds:r.iframeIntervalSeconds,withInterQuantumCollisions:!!r.withInterQuantumCollisions,withBonding:!!r.withBonding,frameGenMode:r.frameGenMode,minMBFillRate:r.minMBFillRate,wavelength_scale:r.wavelengthScale,seed:r.seed,liveQuantaCap:r.liveQuantaCap},this._capTick=null,this._capAlive=0,this._capAdmitted=0,this._capWarned=!1,this._wasm=null,this.tick=0,this._universeRect=r.rect,this._withInterQuantumCollisions=!!r.withInterQuantumCollisions,this._brownianMotion=!1,this._wavelengthScale=r.wavelengthScale,this._frameGenMode=r.frameGenMode,this.experimentTickFunctions=[],this._loHandles=[],this.largeObjects=[]}o(ke,"EGPTUniverse");ke.CONFIG=Zn;ke.INIT_OPTIONS=Mh;ke.RETIRED_CONFIG_KEYS=$n;function A_(e){return!!e&&typeof e=="object"&&e.is_centered!==void 0&&e._left!==void 0}o(A_,"_isRectangle");function T_(e){if(!Uh)throw new Error("EGPTUniverse.create(config): the engine is not booted \u2014 boot it through a door first: await bootEngine(loader) (lib/frqtl/compat/engine.js), which the boot module (experiments/_shared/boot.js) and the node door call for you. (FAIL-LOUD.)");if(e===void 0&&(e={}),e===null||typeof e!="object"||Array.isArray(e))throw new Error("EGPTUniverse.create(config): takes ONE config bag, e.g. EGPTUniverse.create({ rect: rect, seed: 42 }). The positional argument list (fps, iframeInterval, \u2026) and the two-argument (canvasRect, opts) factory are both DELETED \u2014 name the keys you mean: "+Ph()+".");yg("EGPTUniverse.create(config)",e),bg("EGPTUniverse.create(config)",e,Zn,Ph());var t={};if(Zn.forEach(function(n){t[n.key]=e[n.key]!==void 0&&e[n.key]!==null?e[n.key]:n.def}),vg("EGPTUniverse.create(config)",t.frameGenMode),C_(t.liveQuantaCap),t.rect===void 0||t.rect===null)throw new Error("EGPTUniverse.create(config): `rect` is REQUIRED \u2014 there is no world without it (got "+String(t.rect)+"). "+xg+" Then universe.init(fundamentalDimension, options) reads it. (FAIL-LOUD.)");if(!A_(t.rect)){var r=t.rect;if(typeof r!="object"||Array.isArray(r))throw new Error("EGPTUniverse.create(config): `rect` must be a Rectangle or a bounds literal { left, top, w, h } \u2014 got "+JSON.stringify(r)+".");var i=lt;if(!i)throw new Error("EGPTUniverse.create(config): `rect` was given as a bounds literal but the Rectangle class is not loaded. Load parts/Rectangle.js (the ENGINE boot phase does this in the browser; the compat shim does it in Node), or pass a Rectangle instance.");t.rect=new i(r.left!==void 0?r.left:r.x||0,r.top!==void 0?r.top:r.y||0,r.w,r.h,null,!1)}return j_(t.rect),new ke(t,wg)}o(T_,"createUniverse");function _g(){for(var e=0;e<Zn.length;e++)if(Zn[e].key==="liveQuantaCap")return Zn[e];throw new Error("[wasm-engine] UNIVERSE_CONFIG has no liveQuantaCap row.")}o(_g,"_liveQuantaCapRow");function C_(e){var t=_g().def;if(e!==!1&&!(typeof e=="number"&&Number.isInteger(e)&&e>0&&e<=t))throw new Error("EGPTUniverse.create(config): liveQuantaCap must be false (uncapped) or a positive integer no larger than "+t+" (the release ceiling, EGPTUniverse.CONFIG row 'liveQuantaCap') \u2014 got "+(typeof e=="string"?JSON.stringify(e):String(e))+".")}o(C_,"_assertLiveQuantaCap");function fg(e){return typeof e=="number"&&isFinite(e)&&e>0}o(fg,"_isPositiveFiniteDimension");var xg="The world rect is written ONCE by the co-init call \u2014 EGPTUniverse.create({ rect }) \u2190 new FrqtlApp({ canvasW, canvasH }) / exp.createCanvas(w, h, cfg). There is no default world size.";function j_(e){if(!(fg(e.w)&&fg(e.h)))throw new Error("EGPTUniverse.create(config): rect w and h must be positive finite numbers (got w="+hg(e.w)+", h="+hg(e.h)+"). "+xg+" (FAIL-LOUD.)")}o(j_,"_requireWorldDimensions");function hg(e){return typeof e=="string"?JSON.stringify(e)+" (a string)":String(e)}o(hg,"_describeDimension");ke.create=T_;Object.defineProperty(ke.prototype,"brownianMotion",{get:o(function(){return this._wasm?this._wasm.brownian_motion():this._brownianMotion},"get"),set:o(function(e){this._brownianMotion=e,this._wasm&&this._wasm.set_brownian_motion(e)},"set")});Object.defineProperty(ke.prototype,"withInterQuantumCollisions",{get:o(function(){return this._withInterQuantumCollisions},"get"),set:o(function(e){this._withInterQuantumCollisions=e,this._wasm&&this._wasm.set_with_inter_quantum_collisions(e)},"set")});Object.defineProperty(ke.prototype,"activeQuanta",{get:o(function(){return this._wasm?this._wasm.active_quanta():0},"get")});Object.defineProperty(ke.prototype,"liveQuantaCap",{get:o(function(){return this._params.liveQuantaCap},"get")});Object.defineProperty(ke.prototype,"universe_rect",{get:o(function(){return this._universeRect},"get"),set:o(function(){throw new Error("EGPTUniverse: 'universe_rect' is read-only \u2014 its one writer is EGPTUniverse.create({ rect, seed, \u2026 }); universe.init(fundamentalDimension, options) reads it. (FAIL-LOUD: one declaration per fact.)")},"set")});Object.defineProperty(ke.prototype,"initDimension",{get:o(function(){return this._ensureInit(),this._initDimension},"get"),set:o(function(){throw new Error("EGPTUniverse: 'initDimension' is read-only \u2014 its one writer is universe.init(fundamentalDimension, options).")},"set")});Object.defineProperty(ke.prototype,"fundamentalDimension",{get:o(function(){return this._ensureInit(),this._wasm.fundamental_dimension()},"get"),set:o(function(){throw new Error("EGPTUniverse: 'fundamentalDimension' is read-only \u2014 the world's base layer is set by init() and lowered only by universe.addDimension(layer).")},"set")});Object.defineProperty(ke.prototype,"wavelengthScale",{get:o(function(){return this._wasm?this._wasm.wavelength_scale():this._wavelengthScale},"get"),set:o(function(e){this._wavelengthScale=e,this._wasm&&this._wasm.set_wavelength_scale(e)},"set")});Object.defineProperty(ke.prototype,"frameGenMode",{get:o(function(){return this._wasm?S_(this._wasm.frame_gen_mode()):this._frameGenMode},"get"),set:o(function(e){throw new Error("EGPTUniverse: 'frameGenMode' is SET ONCE, at construction \u2014 there is no runtime setter (the engine holds the mode, and a mid-run flip would splice two frame-generation regimes into one run). Pass it where the world is built: universe.init(dim, { frameGenMode: "+JSON.stringify(e)+" }), or EGPTUniverse.create({ frameGenMode: \u2026 }) before init.")},"set")});Object.defineProperty(ke.prototype,"emergentPhysics",{get:o(function(){throw new Error("EGPTUniverse: 'emergentPhysics' "+$n.emergentPhysics+".")},"get"),set:o(function(){throw new Error("EGPTUniverse: 'emergentPhysics' "+$n.emergentPhysics+".")},"set")});Object.defineProperty(ke.prototype,"wavelengthConstant",{get:o(function(){throw new Error("EGPTUniverse: 'wavelengthConstant' "+$n.wavelengthConstant+".")},"get"),set:o(function(){throw new Error("EGPTUniverse: 'wavelengthConstant' "+$n.wavelengthConstant+".")},"set")});Object.defineProperty(ke.prototype,"iframe_interval_seconds",{get:o(function(){return this._params.iframe_interval_seconds},"get"),set:o(function(e){this._params.iframe_interval_seconds=e},"set")});ke.prototype._ensureInit=function(){if(!this._wasm)throw new Error("EGPTUniverse.init() must be called before any simulation methods.")};var pg="EGPTUniverse.init(fundamentalDimension, options) takes NO rect \u2014 the world rect is written ONCE, by EGPTUniverse.create({ rect, seed, \u2026 }), and init reads it (universe.universe_rect). Call e.g. universe.init(0, { wavelengthScale: 1 }). (FAIL-LOUD.)";ke.prototype.init=function(e,t){if(e!==null&&typeof e=="object"||arguments.length>2)throw new Error("EGPTUniverse.init(): the rect argument is DELETED. "+pg);if(e==null)throw new Error("EGPTUniverse.init(): the fundamental dimension is required. "+pg);var r=this.universe_rect;if(t=t===void 0?{}:t,t===null||typeof t!="object"||Array.isArray(t))throw new Error("EGPTUniverse.init(): the second argument must be a plain options object, e.g. init(dim, { wavelengthScale: 1, noEscape: false, frameGenMode: 'groundUp' }).");yg("EGPTUniverse.init()",t);var i={};i.isGreedy="the 'isGreedy' option has been removed (it was inert). Delete it.",i.emergentDimensions="the 'emergentDimensions' option is DELETED. The frame-generation regime is now the enum frameGenMode: 'topDown' (what a truthy emergentDimensions asked for) | 'groundUp' (the default).",Object.keys(i).forEach(function(S){if(S in t)throw new Error("EGPTUniverse.init(): "+i[S])}),bg("EGPTUniverse.init()",t,Mh,k_());var n=t.wavelengthScale,a=t.stepping,s=t.noEscape,l=t.frameGenMode,c=t.brownianMotion,f=l==null?"groundUp":vg("EGPTUniverse.init()",l),u=f==="topDown";if(a!=null&&a!=="fixed"&&a!=="average")throw new Error("EGPTUniverse.init(): stepping must be 'fixed' or 'average' (got "+JSON.stringify(a)+"). 'fixed' = deterministic accumulator walk (default, bounded along-ray error); 'average' = per-axis Bernoulli walk (the historic sampler).");var h=t.activeAxes;if(h!=null&&(typeof h!="object"||Array.isArray(h)||typeof h.x!="boolean"||typeof h.y!="boolean"||typeof h.z!="boolean"))throw new Error("EGPTUniverse.init(): activeAxes must be a plain object { x:boolean, y:boolean, z:boolean }, e.g. { x:true, y:false, z:false } for a 1D walk.");var g=Ka[f],d=this._params.withInterQuantumCollisions;if(u&&(d=!1),u&&c!==void 0&&c!==null&&!c)throw new Error("EGPTUniverse.init(): frameGenMode:'topDown' requires brownian motion, so an explicit brownianMotion:false contradicts it \u2014 top-down frame generation IS the brownian regime and the engine coerces brownian_motion = true unconditionally, so the false would be silently discarded. Choose one: drop brownianMotion (topDown supplies it), or use frameGenMode:'groundUp' if you want the wave-walk. brownianMotion:true with topDown is redundant but consistent, and is allowed.");var m;c!=null&&(m=!!c);var b=n??1,y={fps:this._params.fps,iframe_interval_seconds:this._params.iframe_interval_seconds,with_inter_quantum_collisions:d,with_bonding:this._params.withBonding,frame_gen_mode:g,brownian_motion:m===void 0?null:m,min_fill_rate:this._params.minMBFillRate,universe_rect:[r.left,r.top,r.w,r.h],wavelength_scale:b,fundamental_dimension:e,seed:this._params.seed};h!=null&&(y.active_axes={x:h.x,y:h.y,z:h.z}),a!=null&&(y.stepping=a),this.activeAxes=y.active_axes?{x:y.active_axes.x,y:y.active_axes.y,z:y.active_axes.z}:{x:!0,y:!0,z:!1};var w=t.depth!==void 0&&t.depth!==null?t.depth:r&&r.d!==void 0&&r.d!==null&&r.d!==r.w?r.d:void 0;if(w!==void 0){if(typeof w!="number"||!(w>0))throw new Error("EGPTUniverse.init(): depth must be a positive number (the world z-extent).");y.depth=w}var x=w!==void 0?w:r.w;this.initBounds=Fh([r.left+r.w/2,r.top+r.h/2,0,r.w,r.h,x]),this.largeObjects.length=0,this._loHandles.length=0,this._wasm=new Uh(y),this._initDimension=e,ni=this,this._capTick=null,this._withInterQuantumCollisions&&this._wasm.set_with_inter_quantum_collisions(this._withInterQuantumCollisions),s&&this._wasm.set_no_escape(!0)};ke.prototype.addDimension=function(e){return this._ensureInit(),this._wasm.add_dimension(e),D_(e,this._wasm)};ke.prototype.registerLargeObject=function(e){this._ensureInit();var t=Object.assign({},e);e.rect&&!Array.isArray(e.rect)&&e.rect.left!==void 0&&(t.rect=Nh(e.rect));var r=t.program;delete t.program;var i=this._wasm.register_large_object(t);return this._loHandles.push(i),r!=null&&typeof this._wasm.set_large_object_program_json=="function"&&this._wasm.set_large_object_program_json(i,JSON.stringify(r)),i};ke.prototype.doTick=function(){this._ensureInit();for(var e=0;e<this.experimentTickFunctions.length;e++){var t=this.experimentTickFunctions[e],r=t(this);if(Array.isArray(r)&&r.length>0)throw new TypeError("[doTick] experimentTickFunctions["+e+"] returned an array of "+r.length+" frames. Returning frames to be injected is no longer supported \u2014 it could not express a frame's layer. Mint and inject explicitly instead: universe.makeLeafFrame(left, top, level, ...) then universe.injectFrame(handle), and return nothing.")}var i=this._wasm.do_tick();this.tick=Number(this._wasm.tick());var n=this._wrapTickData(i);return this._lastTickData=n,n};ke.prototype.random=function(){return this._ensureInit(),this._wasm.random()};function Og(e,t,r){if(!(!e||!t||t<=0||!r)&&typeof e.set_frame_property=="function"){var i=null;if(typeof e.get_frame_property=="function")try{var n=e.get_frame_property(t,"data");typeof n=="string"&&n.length?i=JSON.parse(n):n&&typeof n=="object"&&(i=n)}catch{i=null}(!i||typeof i!="object")&&(i={});var a=i.string_map&&typeof i.string_map=="object"?i.string_map:{};for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&r[s]!=null&&(a[s]=String(r[s]));i.string_map=a;try{e.set_frame_property(t,"data",JSON.stringify(i))}catch{}}}o(Og,"_stampRenderIntentMerge");ke.prototype.makeLeafFrame=function(e,t,r,i,n,a,s,l,c,f,u){if(this._ensureInit(),!this._admitLeaf())return null;var h=r??this.fundamentalDimension,g=l??-1,d=this._wasm.make_leaf_frame(e,t,h,i??0,n,a,!!s,g),m=null;if(c&&(m=m||{},m["render.color"]=[c[0],c[1],c[2],c[3]!==void 0?c[3]:255].join(",")),f!=null&&f!==""&&(m=m||{},m["render.shape"]=String(f)),u!=null&&u!==""&&(m=m||{},m["render.outline"]=u===!0||u==="true"?"true":"false"),m&&typeof this._wasm.get_frame_quantum_id=="function"){var b=this._wasm.get_frame_quantum_id(d);b>0&&Og(this._wasm,b,m)}return d};ke.prototype._admitLeaf=function(){var e=this._params.liveQuantaCap;if(e===!1)return!0;if(this._capTick!==this.tick){var t=this._wasm.active_quanta();if(typeof t!="number"||!isFinite(t))throw new Error("[EGPTUniverse] liveQuantaCap cannot read the alive count: active_quanta() returned "+String(t)+", not a finite number.");this._capTick=this.tick,this._capAlive=t,this._capAdmitted=0}if(this._capAlive+this._capAdmitted>=e){if(!this._capWarned){this._capWarned=!0;var r=_g().def.toLocaleString("en-US");console.warn("[EGPTUniverse] liveQuantaCap: "+e.toLocaleString("en-US")+" leaf quanta are alive \u2014 further leaf frames are skipped until the count falls below it. This version of the engine is a limited preview release capped at "+r+" live quanta.")}return!1}return this._capAdmitted++,!0};ke.prototype.levelCapacity=function(e){if(this._ensureInit(),typeof this._wasm.level_capacity!="function")throw new Error("[EGPTUniverse.levelCapacity] the engine does not publish the capacity law (level_capacity). Rebuild the engine (make wasm / make wasm-node).");return this._wasm.level_capacity(e)};ke.prototype.injectFrame=function(e){this._ensureInit(),e!==null&&this._wasm.inject_frame(e)};ke.prototype.getFrameQuantumId=function(e){return this._ensureInit(),e===null?0:typeof this._wasm.get_frame_quantum_id=="function"?this._wasm.get_frame_quantum_id(e):e};ke.prototype.setLargeObjectFrame=function(e,t){if(this._ensureInit(),t===null)throw new Error("[EGPTUniverse.setLargeObjectFrame] the backing frame is null \u2014 the leaf add was refused by liveQuantaCap ("+this._params.liveQuantaCap+" live quanta). A LargeObject needs a real backing frame.");this._wasm.set_large_object_property(e,"frame_id",JSON.stringify(t))};ke.prototype.getLargeObjectFrameId=function(e){return this._ensureInit(),this._wasm.get_large_object_frame_id(e)};var Ih={LargeObject:{rect:o(function(e,t,r){var i=Array.isArray(r)?r:Nh(r);e._wasm.set_large_object_property(t,"rect",JSON.stringify(i))},"rect"),layer:o(function(e,t,r){e._wasm.set_large_object_property(t,"layer",JSON.stringify(r??null))},"layer"),count:o(function(e,t,r){e._wasm.set_large_object_property(t,"count",JSON.stringify(Math.trunc(r)))},"count"),program:o(function(e,t,r){if(typeof e._wasm.set_large_object_program_json=="function"){var i=r!=null?JSON.stringify(r):"null";e._wasm.set_large_object_program_json(t,i)}},"program"),region:o(function(e,t,r){var i=r!=null?JSON.stringify(r):"null";e._wasm.set_large_object_property(t,"region",i)},"region")}};Ih.backdrop=Ih.LargeObject;var R_={reposition:!0};ke.prototype.updateObjectProperty=function(e,t,r,i){this._ensureInit();var n=Be,a=null,s=n.get(t);if(!s)throw new TypeError('[updateObjectProperty] Unknown object kind "'+t+'"');for(var l=0;l<s.fields.length;l++)if(s.fields[l].name===r){a=s.fields[l];break}if(!a)throw new TypeError('[updateObjectProperty] Property "'+r+'" is not in the schema for kind "'+t+'"');if(a.type==="readonly")throw new TypeError('[updateObjectProperty] Property "'+r+'" is readonly for kind "'+t+'"');if(a.engineVisible){var c=Ih[t];if(c&&Object.prototype.hasOwnProperty.call(c,r)){c[r](this,e,i);return}if(!Object.prototype.hasOwnProperty.call(R_,r)){for(var f=c?Object.keys(c):[],u=[],h=n.get(t),g=0;g<h.fields.length;g++)h.fields[g].engineVisible&&h.fields[g].type!=="readonly"&&u.push(h.fields[g].name);throw new TypeError('[updateObjectProperty] Property "'+r+'" is engine-visible for kind "'+t+'" but no WASM ABI routes it \u2014 the write would be silently discarded. '+(f.length?'This provider routes for "'+t+'": '+f.join(", ")+".":'This provider has NO engine dispatch for kind "'+t+'" at all.')+' The schema declares these engine-visible fields for "'+t+'": '+(u.length?u.join(", "):"(none)")+". Either add the ABI, or apply the write at the JS layer (the object's own setter) and return before delegating to universe.updateObjectProperty.")}}};ke.prototype.setLargeObjectCollisionType=function(e,t){typeof console<"u"&&console.warn("[wasm-engine] setLargeObjectCollisionType("+e+", "+JSON.stringify(t)+") called after G2 deletion \u2014 no-op. Compile velocity behavior into an op-program at registration time instead.")};ke.prototype.setLargeObjectActive=function(e,t){this._ensureInit(),this._wasm.set_large_object_property(e,"active",JSON.stringify(!!t))};ke.prototype.updateLargeObjectRect=function(e,t){this._ensureInit();var r=Array.isArray(t)?t:Nh(t);typeof this._wasm.set_large_object_property=="function"&&this._wasm.set_large_object_property(e,"rect",JSON.stringify(r))};ke.prototype.queryRect=function(e,t,r,i){return this._ensureInit(),this._wasm.query_rect(e,t,r,i)};ke.prototype.setLargeObjectCount=function(e,t){this._ensureInit(),this._wasm.set_large_object_property(e,"count",JSON.stringify(Math.trunc(t)))};ke.prototype.queryRectFrames=function(e,t,r,i){this._ensureInit();var n=this._wasm.query_rect_frames(e,t,r,i);if(!n)return[];var a;try{a=JSON.parse(n)}catch{return[]}if(!Array.isArray(a)||a.length===0)return[];for(var s=[],l=0;l<a.length;l++)s.push(ac(a[l],this.tick));return s};ke.prototype.queryObbFrames=function(e,t,r,i,n,a,s){if(this._ensureInit(),typeof this._wasm.query_obb_frames!="function")throw new Error("[queryObbFrames] the active WASM binary predates the swept-OBB ABI (query_obb_frames). Rebuild the engine (make wasm / make wasm-node).");var l=this._wasm.query_obb_frames(e,t,r,i,n,a,s);if(!l)return[];var c;try{c=JSON.parse(l)}catch{return[]}if(!Array.isArray(c)||c.length===0)return[];for(var f=[],u=0;u<c.length;u++)f.push(ac(c[u],this.tick));return f};ke.prototype.injectMutations=function(e){if(this._ensureInit(),!Array.isArray(e))throw new TypeError("[injectMutations] batch must be an array, got: "+typeof e);for(var t=Be.get("Frame"),r=0;r<e.length;r++){var i=e[r];if(i===null||typeof i!="object"||typeof i.id!="number"||typeof i.prop!="string"||!("value"in i))throw new TypeError("[injectMutations] Malformed entry at index "+r+": expected { id: number, prop: string, value: * }, got "+JSON.stringify(i));for(var n=null,a=0;a<t.fields.length;a++)if(t.fields[a].name===i.prop){n=t.fields[a];break}if(!n)throw new TypeError('[injectMutations] Unknown property "'+i.prop+'" for kind "Frame" (entry index '+r+"). Valid properties: "+t.fields.map(function(u){return u.name}).join(", "));if(n.type==="forbidden")throw new TypeError('[injectMutations] Property "'+i.prop+'" is engine-owned topology \u2014 forbidden (entry index '+r+"). Set position (x/y) and let the engine reconcile topology next tick.");if(n.type==="readonly")throw new TypeError('[injectMutations] Property "'+i.prop+'" is read-only (entry index '+r+"). Use a writable property to change it indirectly.")}for(var s=[],l=0;l<e.length;l++){var c=e[l],f=c.value;c.prop==="charge"?f==="POSITIVE"||f==="Positive"?f=0:(f==="NEGATIVE"||f==="Negative")&&(f=1):c.prop==="data"&&(f=f??null),s.push({id:c.id,prop:c.prop,value:f})}this._wasm.inject_mutations(JSON.stringify(s))};ke.prototype.killFrame=function(e){this._ensureInit(),this._wasm.kill_frame(e)};ke.prototype.getFramePosition=function(e){this._ensureInit();var t=this._wasm.get_frame_position(e);return t.length===2?{x:t[0],y:t[1]}:null};ke.prototype.getFrameProperty=function(e,t){this._ensureInit();for(var r=Be.get("Frame"),i=null,n=0;n<r.fields.length;n++)if(r.fields[n].name===t){i=r.fields[n];break}if(!i)throw new TypeError('[getFrameProperty] Unknown property "'+t+'" for kind "Frame". Valid properties: '+r.fields.map(function(s){return s.name}).join(", "));var a=this._wasm.get_frame_property(e,t);if(a==null)return null;if(typeof a=="string")try{return JSON.parse(a)}catch{return a}return a};ke.prototype.setFrameProperty=function(e,t,r){this._ensureInit();for(var i=Be.get("Frame"),n=null,a=0;a<i.fields.length;a++)if(i.fields[a].name===t){n=i.fields[a];break}if(!n)throw new TypeError('[setFrameProperty] Unknown property "'+t+'" for kind "Frame". Valid properties: '+i.fields.map(function(c){return c.name}).join(", "));if(n.type==="forbidden")throw new TypeError('[setFrameProperty] Property "'+t+'" is engine-owned topology \u2014 structure is engine-derived. Set position and let the next tick reconcile.');if(n.type==="readonly")throw new TypeError('[setFrameProperty] Property "'+t+'" is read-only (derived: '+t+").");var s=r;if(t==="charge"){if(r==="POSITIVE"||r==="Positive")s=0;else if(r==="NEGATIVE"||r==="Negative")s=1;else if(typeof r!="number")throw new TypeError("[setFrameProperty] Invalid charge value: "+JSON.stringify(r)+'. Use "POSITIVE" or "NEGATIVE".')}var l=s==null?"null":JSON.stringify(s);this._wasm.set_frame_property(e,t,l)};function ac(e,t){var r=new lt(e.x!=null?e.x:0,e.y!=null?e.y:0,e.w!=null?e.w:1,e.h!=null?e.h:1,null,!0),i=e.data!==void 0&&e.data!==null?e.data:null;if(i&&i.string_map instanceof Map){var n={};i.string_map.forEach(function(a,s){n[s]=a}),i=Object.assign({},i,{string_map:n})}return new dg(e.tick!=null?e.tick:t,e.id!=null?e.id:0,e.layer!=null?e.layer:0,r,e.fullness!=null?e.fullness:0,e.is_alive!==!1,e.child_count!=null?e.child_count:0,e.mass!=null?e.mass:1,e.collided_id!=null?e.collided_id:-1,e.vx!=null?e.vx:0,e.vy!=null?e.vy:0,e.z!=null?e.z:0,e.vz!=null?e.vz:0,i)}o(ac,"_wrapRawFrame");function Fh(e){if(!Array.isArray(e)||e.length!==6)throw new Error("wasm-engine: TickData boundary_rect must be the engine's 6-tuple (x, y, z, w, h, d) \u2014 got "+JSON.stringify(e)+". The world bounds are owned by the engine (tick_data.rs UniverseData/DimensionData::boundary_rect); the shim ferries them and never re-derives them from the JS-side config rect.");var t=e[0],r=e[1],i=e[2],n=e[3],a=e[4],s=e[5];return{x:t,y:r,z:i,w:n,h:a,d:s,left:t-n/2,right:t+n/2,top:r-a/2,bottom:r+a/2,near:i-s/2,far:i+s/2,r:n/2}}o(Fh,"_wrapBoundaryRect");ke.prototype._wrapTickData=function(e){var t=new gg(e.universe!=null?e.universe.tick:this.tick,e.universe!=null?e.universe.dimension_count:0,Fh(e.universe&&e.universe.boundary_rect)),r=new oc(t);if(e.dimensions)for(var i=0;i<e.dimensions.length;i++){var n=e.dimensions[i];r.addDimensionData(new mg(n.tick!=null?n.tick:this.tick,n.layer!=null?n.layer:0,n.frame_count!=null?n.frame_count:0,Fh(n.boundary_rect)))}if(e.frames)for(var a=0;a<e.frames.length;a++)r.addFrameData(ac(e.frames[a],this.tick));if(e.objects&&Array.isArray(e.objects)&&e.objects.length>0){r.objects||(r.objects=[]);for(var s=this.tick,l=0;l<e.objects.length;l++){var c=e.objects[l];r.objects.push({handle:c.handle!=null?c.handle:l,count:c.count!=null?Number(c.count):0,frames:Array.isArray(c.frames)?c.frames.map(function(f){return ac(f,s)}):[]})}}return r};ke.prototype.unregisterLargeObject=function(e){this._ensureInit(),this._wasm.unregister_large_object(e);for(var t=this.largeObjects.length-1;t>=0;t--)this.largeObjects[t]&&this.largeObjects[t].handle===e&&this.largeObjects.splice(t,1);var r=this._loHandles.indexOf(e);r!==-1&&this._loHandles.splice(r,1)};ke.prototype.unwrappedLargeObjectHandles=function(){var e=Object.create(null),t;for(t=0;t<this.largeObjects.length;t++)this.largeObjects[t]&&(e[this.largeObjects[t].handle]=!0);var r=[];for(t=0;t<this._loHandles.length;t++)e[this._loHandles[t]]||r.push(this._loHandles[t]);return r};function mt(){this.is_alive=!1,this.is_leaf=!1,this.children=[],this.mass=0,this.layer=0,this.rect=null,this.name=null,this._isBoundaryNull=!0}o(mt,"BoundaryFrame");mt.prototype.insert=function(e){return ni&&this._handle!==void 0&&e&&e._handle!==void 0?ni._wasm.insert_into_frame(this._handle,e._handle):(console.log("[shim] Frame.insert: missing handle(s) or no active WASM universe \u2014 returning null"),null)};mt.prototype.addPoints=function(e){return console.log("[shim] Frame.addPoints not implemented in WASM engine \u2014 returning null"),null};mt.prototype.move=function(e,t){return console.log("[shim] Frame.move not implemented in WASM engine \u2014 returning null"),null};mt.prototype.compress=function(){return console.log("[shim] Frame.compress not implemented in WASM engine \u2014 returning null"),null};mt.prototype.reinit=function(){return console.log("[shim] Frame.reinit not implemented in WASM engine \u2014 returning null"),null};mt.prototype.kill=function(){return console.log("[shim] Frame.kill not implemented in WASM engine \u2014 returning null"),null};mt.prototype.reset=function(){return console.log("[shim] Frame.reset not implemented in WASM engine \u2014 returning null"),null};mt.prototype.toFrameData=function(){return console.log("[shim] Frame.toFrameData not implemented in WASM engine \u2014 returning null"),null};mt.prototype.checkCollision=function(){return console.log("[shim] Frame.checkCollision not implemented in WASM engine \u2014 returning null"),null};mt.prototype.collide=function(){return console.log("[shim] Frame.collide not implemented in WASM engine \u2014 returning null"),null};mt.prototype.merge=function(){return console.log("[shim] Frame.merge not implemented in WASM engine \u2014 returning null"),null};mt.prototype.bond=function(){return console.log("[shim] Frame.bond not implemented in WASM engine \u2014 returning null"),null};mt.prototype.bounce=function(){return console.log("[shim] Frame.bounce not implemented in WASM engine \u2014 returning null"),null};mt.prototype.boundary_check=function(){return console.log("[shim] Frame.boundary_check not implemented in WASM engine \u2014 returning null"),null};mt.prototype.setWavelength=function(){return console.log("[shim] Frame.setWavelength not implemented in WASM engine \u2014 returning null"),null};mt.makeLeafFrame=function(e,t,r,i,n,a,s,l,c,f){if(!ni){console.log("[shim] Frame.makeLeafFrame: no active WASM universe \u2014 returning null");var u=new mt;return u.layer=r||0,u}var h=ni.makeLeafFrame(e,t,r,i,n,a,s,l);if(h===null){var g=new mt;return g.layer=r||0,g}var d=new mt;return d._handle=h,d.layer=r||0,d.is_leaf=!0,d.is_alive=!0,d._isBoundaryNull=!1,d};function D_(e,t){var r=Math.pow(2,e),i=r,n=!1,a={layer:e,mb_w:r,mb_h:i,frames:[],addFrame:o(function(s){var l=t||ni&&ni._wasm;if(l&&s&&s._handle!==void 0){l.add_frame_to_dimension(e,s._handle);return}return console.log("[shim] Dimension.addFrame: missing handle or no active WASM universe \u2014 returning null"),null},"addFrame"),createFrameFromRect:o(function(s,l,c,f,u,h,g){var d=t||ni&&ni._wasm;if(d&&s){var m=(l||[]).map(function(A){return A&&A._handle!==void 0?A._handle:0}),b=[s.left||0,s.top||0,s.w||r,s.h||i],y=4294967295,w=d.create_frame_from_rect(e,b,m,c||0,f||0,u!==!1,!!h);if(w>=y)return console.log("[shim] Dimension.createFrameFromRect: Rust returned INVALID \u2014 returning sentinel"),new mt;var x=new mt;if(x._handle=w,x.layer=e,x.is_alive=!0,x._isBoundaryNull=!1,g&&typeof d.get_frame_quantum_id=="function"){var S=d.get_frame_quantum_id(w);S>0&&Og(d,S,g)}return x}return console.log("[shim] Dimension.createFrameFromRect: no active WASM universe \u2014 returning sentinel"),new mt},"createFrameFromRect"),createParentFrame:o(function(s,l){var c=t||ni&&ni._wasm;if(c&&s&&s._handle!==void 0&&l&&l._handle!==void 0){var f=4294967295,u=c.create_parent_frame(e,s._handle,l._handle);if(u>=f)return console.log("[shim] Dimension.createParentFrame: Rust returned INVALID \u2014 returning sentinel"),new mt;var h=new mt;return h._handle=u,h.layer=e,h.is_alive=!0,h._isBoundaryNull=!1,h}return console.log("[shim] Dimension.createParentFrame: missing handle(s) or no active WASM universe \u2014 returning null"),new mt},"createParentFrame"),handleStructurePromotion:o(function(s,l){return console.log("[shim] Dimension.handleStructurePromotion not implemented in WASM engine \u2014 returning null"),null},"handleStructurePromotion"),generateFrames:o(function(s){return console.log("[shim] Dimension.generateFrames not implemented in WASM engine \u2014 returning null"),null},"generateFrames"),addPointsFromQuadTree:o(function(s){return console.log("[shim] Dimension.addPointsFromQuadTree not implemented in WASM engine \u2014 returning null"),null},"addPointsFromQuadTree"),releasePoints:o(function(s){return console.log("[shim] Dimension.releasePoints not implemented in WASM engine \u2014 returning null"),null},"releasePoints"),reset:o(function(){return console.log("[shim] Dimension.reset not implemented in WASM engine \u2014 returning null"),null},"reset"),update:o(function(s,l){return console.log("[shim] Dimension.update not implemented in WASM engine \u2014 returning null"),null},"update"),collectFrameData:o(function(s){return console.log("[shim] Dimension.collectFrameData not implemented in WASM engine \u2014 returning null"),null},"collectFrameData"),getMassForColor:o(function(s){return console.log("[shim] Dimension.getMassForColor not implemented in WASM engine \u2014 returning null"),null},"getMassForColor"),getWavelengthForColor:o(function(s){return console.log("[shim] Dimension.getWavelengthForColor not implemented in WASM engine \u2014 returning null"),null},"getWavelengthForColor"),alignMBtoDimGrid:o(function(s){return console.log("[shim] Dimension.alignMBtoDimGrid not implemented in WASM engine \u2014 returning null"),null},"alignMBtoDimGrid"),getQtreeFromFrames:o(function(){return console.log("[shim] Dimension.getQtreeFromFrames not implemented in WASM engine \u2014 returning null"),null},"getQtreeFromFrames")};return Object.defineProperty(a,"isHidden",{get:o(function(){return n},"get"),set:o(function(s){n=s},"set"),enumerable:!0,configurable:!0}),a}o(D_,"_makeBoundaryDimension");var Uh=null,ni=null;function Eg(e){if(!e)throw new Error("[wasm-engine] WasmUniverse constructor is required.");return Uh=e,{backend:"wasm",Rectangle:lt,EGPTUniverse:ke,Frame:mt,TickData:oc,FrameData:dg,DimensionData:mg,UniverseData:gg,LightColor:Ei,Charge:O_,createUniverse:o(function(){throw new Error("handle.createUniverse(canvasRect, opts) is DELETED \u2014 it was a second construction convention with divergent defaults (seed 0, not 42). Use the ONE construction authority: handle.EGPTUniverse.create({ rect: canvasRect, seed: \u2026 }). `rect` accepts the same { left, top, w, h } literal.")},"createUniverse")}}o(Eg,"makeProvider");var Sg="[engine] JS reference engine archived \u2014 FRQTL is WASM-only. Remove ?engine=js / --engine js / EGPT_ENGINE=js; the only FRQTL physics engine is the compiled Rust/WASM engine (frqtl/crates/egpt_engine \u2192 fat/pkg-web).";function sc(e,t){let r=t;if(!r||typeof r!="object")throw new TypeError("[engine] refuseRetiredDoors(bag, table): the owner's table of retired names is required. (FAIL-LOUD.)");for(let i of Object.keys(r)){if(typeof r[i]!="string"||!r[i])throw new TypeError('[engine] refuseRetiredDoors: the retirement message for "'+i+`" must be a non-empty string (it is the replacement's one home). (FAIL-LOUD.)`);let n=Object.getOwnPropertyDescriptor(e,i);if(n&&!n.configurable)throw new Error('[engine] this page already holds a global "'+i+'" (a `var` or function declaration in a classic script), and that name is a retired FRQTL door: '+r[i]+" Keep the page's own binding off the global object \u2014 declare it inside a function or a block (const/let), or import it from the ES module doors. (FAIL-LOUD.)");Object.defineProperty(e,i,{enumerable:!1,configurable:!1,get:o(function(){throw new Error(r[i])},"get"),set:o(function(){throw new Error(r[i])},"set")})}return e}o(sc,"refuseRetiredDoors");var zh=null,Ya=null,qh=null,Ja="unbooted";function Vh(e,t){if(!e||typeof e.load!="function"||typeof e.env!="string")throw new TypeError("[engine] bootEngine(loader): loader must be a WASM loader \u2014 browserWasmLoader (compat/providers/wasm-load-browser.js) or nodeWasmLoader (compat/providers/wasm-load-node.js). (FAIL-LOUD.)");if(Ya){if(e!==zh)throw new Error('[engine] bootEngine: this realm already booted its engine with the "'+zh.env+'" loader \u2014 one engine per realm; a second loader is refused. (FAIL-LOUD.)');return Ya}zh=e;let r=t&&t.engine;return r!=null&&r!=="wasm"?(Ja="failed",Ya=Promise.reject(new Error(Sg+' (requested engine="'+r+'")')),Ya):(Ja="booting",Ya=e.load().then(function(i){let n=Eg(i.WasmUniverse);return n.env=e.env,qh=n,Ja="booted",n},function(i){throw Ja="failed",i}),Ya)}o(Vh,"bootEngine");function ea(){if(qh)return qh;throw new Error("[engine] the engine is not booted (state: "+Ja+") \u2014 boot it through a door first: await bootEngine(loader) (lib/frqtl/compat/engine.js), which the boot module (experiments/_shared/boot.js) and the node door call for you. (FAIL-LOUD.)")}o(ea,"engine");function ns(){return Ja}o(ns,"engineState");Na();un();var Qa={w:300,h:200,radius:2,gain:4,blur:!0};function L_(e,t){Wi("FieldBuilder.buildHeightField(frameData, Object.assign({}, FIELD_OPTS, { canvasW, canvasH })) opts.canvasW/canvasH",t&&t.canvasW,t&&t.canvasH);var r=t.canvasW,i=t.canvasH,n=t.w||Qa.w,a=t.h||Qa.h,s=t.radius!==void 0?t.radius:Qa.radius,l=t.gain!==void 0?t.gain:Qa.gain,c=t.blur!==void 0?t.blur:Qa.blur,f=s*s,u=new Float32Array(n*a);if(e)for(var h=n/r,g=a/i,d=0;d<e.length;d++){var m=e[d],b=m.rect.x*h,y=m.rect.y*g,w=Math.round(b)|0,x=Math.round(y)|0,S=m.fullness||0;if(!(S<=0))for(var A=Math.max(0,w-s),T=Math.min(n-1,w+s),j=Math.max(0,x-s),Q=Math.min(a-1,x+s),Y=j;Y<=Q;Y++)for(var H=Y-x,V=A;V<=T;V++){var C=V-w,J=C*C+H*H;if(!(J>f)){var R=1-J/f;u[Y*n+V]+=S*R}}}for(var K=new Uint8Array(n*a),N=0;N<u.length;N++){var B=Math.round(u[N]*l*255);K[N]=B>255?255:B}if(c&&n>2&&a>2){var ie=new Uint8Array(n*a),oe,$,pe,ye,ce,L;for(oe=0;oe<a;oe++){var ee=oe*n;for(ie[ee]=K[ee],ie[ee+n-1]=K[ee+n-1],$=1;$<n-1;$++)pe=ee+$,ye=K[pe-1],ce=K[pe],L=K[pe+1],ie[pe]=ye+2*ce+L+2>>2}for($=0;$<n;$++)K[$]=ie[$],K[(a-1)*n+$]=ie[(a-1)*n+$];for(oe=1;oe<a-1;oe++)for($=0;$<n;$++)ye=ie[(oe-1)*n+$],ce=ie[oe*n+$],L=ie[(oe+1)*n+$],K[oe*n+$]=ye+2*ce+L+2>>2}return K}o(L_,"buildHeightField");var Er={FIELD_OPTS:Qa,buildHeightField:L_};Nf();At();var P_=new URL("../../../fat/pkg-web/egpt_wasm.js",new URL("frqtl/compat/providers/wasm-load-browser.js",ze()).href).href,kg=null;async function I_(e){let t=typeof crypto<"u"?crypto.subtle:null;if(!t||typeof t.digest!="function")return null;let r=new Uint8Array(await t.digest("SHA-256",e)),i="";for(let n=0;n<r.length;n++)i+=(r[n]<16?"0":"")+r[n].toString(16);return i}o(I_,"_sha256Hex");function Ag(){return kg}o(Ag,"loadedWasmSha256");async function F_(e){let t=e||P_,r;try{r=await import(t)}catch(a){throw new Error("[wasm-load-browser] the WASM package glue did not load from "+t+" ("+(a&&a.message?a.message:String(a))+`).
|
|
4
4
|
Build it with:
|
|
5
|
-
wasm-pack build fat/crates/egpt_wasm --target web --out-dir fat/pkg-web`)}let n=null;if(typeof r.default=="function"){let a=new URL("egpt_wasm_bg.wasm",t).href,s=await fetch(String(a));if(!s.ok)throw new Error("[wasm-load-browser] failed to fetch WASM binary: "+s.status+" "+s.statusText+" ("+a+")");let l=await s.arrayBuffer();n=await s_(l),await r.default({module_or_path:l})}let i=r.WasmUniverse;if(!i)throw new Error("[wasm-load-browser] WasmUniverse not found in loaded WASM module.");return ig=n,{WasmUniverse:i}}o(l_,"load");var og=Object.freeze({env:"browser",load:o(function(){return l_()},"load")});var li={};Oe(li,{clear:()=>u_,get:()=>ch,name:()=>On,set:()=>uh});var sh=null,lh=null;function uh(e,t){if(!e||typeof e!="object")throw new Error("[FrqtlDisplay.set] the display provider must be a RendererProvider instance. Got: "+String(e)+". (FAIL-LOUD \u2014 never a display slot holding nothing while a page believes it has a renderer.)");return sh=e,lh=t==null?null:String(t),e}o(uh,"set");function ch(){return sh}o(ch,"get");function On(){return lh}o(On,"name");function u_(){sh=null,lh=null}o(u_,"clear");function c_(){try{if(typeof location>"u"||!location)return null;var e=String(location.pathname).match(/\/experiments\/([^/]+)\//);return e&&e[1]?e[1]:null}catch{return null}}o(c_,"_defaultSourceRef");var Wa;function f_(){if(Wa!==void 0)return Wa;Wa=null;try{if(typeof document<"u"&&document.createElement){var e=document.createElement("canvas"),t=e.getContext("webgl2")||e.getContext("webgl"),r=t&&t.getExtension("WEBGL_debug_renderer_info");r&&(Wa=String(t.getParameter(r.UNMASKED_RENDERER_WEBGL)))}}catch{Wa=null}return Wa}o(f_,"_rasterPath");function h_(e,t,r){var n=r.renderedTick;if(!(typeof n=="number"&&isFinite(n)))throw new Error("[FrqtlCapture.capture] the provider's captureStill() bag reports no renderedTick (got "+String(n)+") \u2014 the tick of the TickData its pixels were drawn from is REQUIRED (RENDERER_CONTRACT \xA71a.4), because without it a still stamped tick "+t+" cannot be shown to carry tick "+t+"'s picture. (FAIL-LOUD.)");if(n!==t)throw new Error("[FrqtlCapture.capture] PROVENANCE MISMATCH at stage '"+e+"': the still would be stamped tick "+t+" (the loop's retained TickData) but the provider composited tick "+n+" \u2014 these pixels are not tick "+t+"'s. Capture a tick that was RENDERED: drive the clock with runner.step() (it renders, then notifies), or HOLD it from a tick listener \u2014 runner.suspendTicks(), runner.repaint() (forces the draw; an fps cap skips display frames), capture, runner.resumeTicks() in the capture's finally; outside a listener, runner.repaint() then capture in the same task. (FAIL-LOUD \u2014 a still whose label is not its pixels is a falsified record.)")}o(h_,"_assertComposited");function Zt(e,t,r,n){if(!e||typeof e!="object")throw new Error("[FrqtlCapture.create] argument 1 must be the LOOP \u2014 anything exposing `lastTickData` (SimLoop / the FrqtlApp host). (FAIL-LOUD.)");if(typeof t!="function")throw new Error("[FrqtlCapture.create] argument 2 must be a providerGetter function returning the active RendererProvider or null \u2014 the provider is read LIVE, never captured at bind time. (FAIL-LOUD.)");if(!r||typeof r!="object"||r.seed===void 0||!r.rect)throw new Error("[FrqtlCapture.create] argument 3 must be the identity bag { seed, rect, sourceRef? } \u2014 `seed` is FERRIED from the party that handed it to the universe and `rect` is the physics canvas. (FAIL-LOUD.)");if(typeof n!="function")throw new Error("[FrqtlCapture.create] argument 4 must be a renderOptionsGetter function returning the ONE LIVE render-options bag \u2014 read through the getter, never copied (a copy is a second options authority). (FAIL-LOUD.)");this._loop=e,this._providerGetter=t,this._identity=r,this._renderOptionsGetter=n,this._sourceRef=r.sourceRef===void 0||r.sourceRef===null?c_():String(r.sourceRef),this._sourceSha256=null,this._sceneMemo=null,this._host=null}o(Zt,"CaptureInstrument");Zt.prototype.attachCaptureHost=function(e){var t=Ia;t.assertCaptureHost(e);var r=this._provider();if(r&&typeof r.captureStill=="function"&&e.stages.indexOf("composite")!==-1)throw new Error("[FrqtlCapture.attachCaptureHost] this instrument already has a display provider that implements captureStill(), so the `composite` stage is already executed locally. A capture host is for a stage this process CANNOT execute; attaching one here would mint a second executor \u2014 two truths about one picture. (FAIL-LOUD.)");return this._host=e,this._sceneMemo=null,e};Zt.prototype.captureHost=function(){return this._host};Zt.prototype._provider=function(){return this._providerGetter()||null};Zt.prototype.setSourceRef=function(e){this._sourceRef=e==null?null:String(e)};Zt.prototype.setSourceSha256=function(e){this._sourceSha256=fl(e)};Zt.prototype._buildIdentity=function(){if(this._host)return this._host.identity().build||null;var e=ag(),t=e!==null;return{engine:t&&Ho()==="booted"?String(Hi().backend):null,renderer:t&&On()?String(On()):null,wasmSha256:t?e:null,gl:f_()}};Zt.prototype._projection=function(){if(this._host){var e=this._host.identity();return e&&e.projection?e.projection:null}var t=this._provider();return!t||typeof t.projection!="function"?null:t.projection()};Zt.prototype._pose=function(){var e=this._provider();if(!e||typeof e.getCameraControl!="function")return null;var t=e.getCameraControl();return t?t.getOrbit():null};Zt.prototype.sceneRecord=function(){var e=sr,t=this,r;try{var n=this._identity.rect;r=e.normalizeScene({seed:this._identity.seed,sourceRef:this._sourceRef,sourceSha256:this._sourceSha256,build:this._buildIdentity(),physicsW:n.w,physicsH:n.h,projection:this._projection()})}catch(a){return Promise.reject(a)}var i=e.canonicalizeScene(r);return this._sceneMemo&&this._sceneMemo.canon===i?Promise.resolve(e.deepPlainCopy(this._sceneMemo.value)):e.sceneHash(r).then(function(a){var s=Object.assign({},r,{scene:a});return t._sceneMemo={canon:i,value:s},e.deepPlainCopy(s)})};Zt.prototype._tickIndex=function(e){var t=e&&e.universeData&&e.universeData.tick;if(typeof t=="number"&&isFinite(t))return t;throw new Error("[FrqtlCapture.capture] the live TickData carries no universeData.tick \u2014 the tick stamp is what co-registers a multi-channel capture, so it is never defaulted or omitted. (FAIL-LOUD.)")};Zt.prototype._renderCapabilities=function(){var e=this._provider();return!e||typeof e.renderCapabilities!="function"?[]:e.renderCapabilities()};Zt.prototype._captureRenderOptions=function(){for(var e=this._renderCapabilities(),t=this._renderOptionsGetter()||{},r={},n=0;n<e.length;n++){var i=e[n].name;!i||i.indexOf("filter.")===0||(r[i]=t[i]!==void 0?t[i]:e[n].default)}return r};Zt.prototype.capture=function(e){try{return this._captureDispatch(e)}catch(t){return Promise.reject(t)}};Zt.prototype._captureDispatch=function(e){var t=sr;if(t.assertStage(e),this._host&&this._host.stages.indexOf(e)!==-1){var r=Ia,n=this._host;return this.sceneRecord().then(function(c){return Promise.resolve(n.capture(e)).then(function(h){return r.verifyStill(c.scene,e,h)})})}var i=this._loop.lastTickData;if(!i)throw new Error("[FrqtlCapture.capture] no tick has run yet (the loop has retained no TickData), so there is no channel to read. Run start()/step() first. (FAIL-LOUD \u2014 never an empty buffer.)");var a=this._provider();if(e==="scene")throw t.stageNotTappableError(e,"the active renderer provider");if(e==="composite"&&(!a||typeof a.captureStill!="function"))throw t.stageNotTappableError(e,"the active renderer provider (it does not implement the OPTIONAL captureStill() capability), and no capture host is attached. In a process with no display renderer \u2014 a node rig \u2014 the composed picture is produced by the HOSTED headless stack, which runs the real renderer and its shaders: openHostedEyes({sceneRecord, sceneSource, pageUrl}) from @descix/frqtl-node/eyes (lib/frqtl/objects/instruments/hosted-eyes.js)");var s=this,l=this._tickIndex(i),u={pose:null,renderOptions:null},f=null;return t.STAGE_FORMATS[e]==="rgba8"?f=Promise.resolve().then(function(){return u.pose=s._pose(),u.renderOptions=s._captureRenderOptions(),a.captureStill()}):(u.pose=this._pose(),u.renderOptions=this._captureRenderOptions()),Promise.all([this.sceneRecord(),f]).then(function(c){var h=c[0],g={scene:h.scene,stage:e,tick:l,pose:u.pose,renderOptions:u.renderOptions};if(e==="tick")return t.normalizeStill(Object.assign({},g,{data:i.frameData,width:h.physicsW,height:h.physicsH,filtersApplied:[],renderBaseCanvas:null}));if(e==="field"){var p=Er,m=Object.assign({},p.FIELD_OPTS,{canvasW:h.physicsW,canvasH:h.physicsH});return t.normalizeStill(Object.assign({},g,{data:p.buildHeightField(i.frameData,m),width:m.w,height:m.h,fieldOpts:m,filtersApplied:[],renderBaseCanvas:null}))}var b=c[1];if(!b)throw new Error("[FrqtlCapture.capture] the provider's captureStill() resolved with nothing. (FAIL-LOUD \u2014 never a null still.)");return h_(e,l,b),t.normalizeStill(Object.assign({},g,{data:b.pixels,width:b.width,height:b.height,cssWidth:b.cssWidth,cssHeight:b.cssHeight,filtersApplied:b.filtersApplied,renderBaseCanvas:b.renderBaseCanvas,filterTime:b.filterTime}))})};Zt.prototype.captureStill=function(){return this.capture(tf())};function d_(e,t,r,n){return new Zt(e,t,r,n)}o(d_,"create");var Nl={create:d_};ja();pl();ni();var dh={};Oe(dh,{POSE_FIELDS_2D:()=>m_,PRESETS_2D:()=>g_,defaultPose2d:()=>fh,resolveView2d:()=>Ml,screenToWorld2d:()=>hh});Ci();function p_(e){throw new Error("[camera2d-geometry] "+e+" (FAIL-LOUD.)")}o(p_,"_fail");function m_(e,t){var r=Nn;return[r({name:"distance",label:"zoom",type:"number",unit:"px",default:t,constraint:{min:8,max:Math.max(t*4,32),integer:!1},widgetConfig:{step:Math.max(1,Math.round(t/60))},description:`The VISIBLE HEIGHT of the view in physics pixels \u2014 smaller = zoomed IN. Default = the full canvas height (1:1). The same observable as the 3D camera's distance: "how much world you see".`}),r({name:"target",label:"centre",type:"object",unit:"px",default:null,description:"The physics-px point {x,y} at the view centre; null = the canvas centre. Pan IS target \u2014 the same key the 3D camera uses."})]}o(m_,"POSE_FIELDS_2D");function g_(e,t){return{fit:{target:null,distance:t}}}o(g_,"PRESETS_2D");function fh(e,t){return{distance:t,target:null}}o(fh,"defaultPose2d");function Ml(e,t,r){t>0&&r>0||p_("physics dims must be positive, got "+t+"x"+r);var n=e&&typeof e.distance=="number"&&isFinite(e.distance)&&e.distance>0?e.distance:r,i=e&&e.target&&typeof e.target.x=="number"&&typeof e.target.y=="number"?e.target:null;return{k:r/n,cx:i?i.x:t/2,cy:i?i.y:r/2}}o(Ml,"resolveView2d");function hh(e,t,r,n,i,a,s){var l=a>0?a:t,u=s>0?s:r,f=Ml(e,t,r),c=n*(t/l),h=i*(r/u);return{x:(c-t/2)/f.k+f.cx,y:(h-r/2)/f.k+f.cy}}o(hh,"screenToWorld2d");var Ko={};Oe(Ko,{assertNonBlank:()=>ph,captureFrom2dCanvas:()=>v_,captureFromGl:()=>y_,flipRowsToTopLeft:()=>sg});function Sr(e){throw new Error("[captureStill] "+e+" (FAIL-LOUD \u2014 never a null or blank still.)")}o(Sr,"_fail");function sg(e,t,r){(!e||typeof e.length!="number")&&Sr("flipRowsToTopLeft: src is not an indexed buffer");var n=t*4;e.length!==n*r&&Sr("flipRowsToTopLeft: buffer length "+e.length+" != width*height*4 ("+t+"*"+r+"*4 = "+n*r+")");for(var i=new Uint8ClampedArray(e.length),a=0;a<r;a++)for(var s=(r-1-a)*n,l=0;l<n;l++)i[a*n+l]=e[s+l];return i}o(sg,"flipRowsToTopLeft");function ph(e,t){e.length||Sr(t+": readback returned an EMPTY buffer");for(var r=e[0],n=1;n<e.length;n++)if(e[n]!==r)return;Sr(t+": readback is UNIFORMLY "+r+" across every byte \u2014 the buffer was cleared or unbound. A GL provider must re-render its retained scene and read back in the SAME JS task (no preserveDrawingBuffer)")}o(ph,"assertNonBlank");function lg(e,t,r){e=e||{},Array.isArray(e.filtersApplied)||Sr("meta.filtersApplied must be the provider's ORDERED filter-name array (its own _filters list is the one authority \u2014 never the runner's unordered _activeFilters map)"),(!(typeof e.physicsW=="number"&&e.physicsW>0)||!(typeof e.physicsH=="number"&&e.physicsH>0))&&Sr("meta.physicsW/physicsH must be the POSITIVE physics-canvas dimensions this buffer maps from \u2014 they are the universe-mapping half of provenance and cannot be guessed from the buffer size (that is only right at 1:1). Got "+String(e.physicsW)+"x"+String(e.physicsH));var n=e.composited,i=n&&n.universeData&&n.universeData.tick;typeof i=="number"&&isFinite(i)||Sr("meta.composited must be the TickData this provider last drew (its retained _lastTickData, carrying universeData.tick) \u2014 nothing has been composited, so there is no tick these pixels could be labelled with");var a=e.filterTime===void 0?null:e.filterTime,s=e.filtersApplied.length>0;return(s?!(typeof a=="number"&&isFinite(a)):a!==null)&&Sr("meta.filterTime must be the finite uTime the filter passes drew with when filtersApplied is non-empty, and null when it is empty (filtersApplied "+JSON.stringify(e.filtersApplied)+", filterTime "+String(a)+")"),{renderedTick:i,width:t,height:r,cssWidth:typeof e.cssWidth=="number"&&e.cssWidth>0?e.cssWidth:t,cssHeight:typeof e.cssHeight=="number"&&e.cssHeight>0?e.cssHeight:r,physicsW:e.physicsW,physicsH:e.physicsH,filtersApplied:e.filtersApplied.slice(),renderBaseCanvas:typeof e.renderBaseCanvas=="boolean"?e.renderBaseCanvas:null,filterTime:a}}o(lg,"_meta");function v_(e,t){e||Sr("no canvas to read \u2014 captureStill() was called before init() created one");var r=typeof e.getContext=="function"?e.getContext("2d"):null;(!r||typeof r.getImageData!="function")&&Sr("the canvas has no readable 2D context (getImageData unavailable)");var n=e.width,i=e.height;n>0&&i>0||Sr("canvas backing store is "+n+"x"+i);var a=r.getImageData(0,0,n,i);(!a||!a.data||a.data.length!==n*i*4)&&Sr("getImageData returned "+(a&&a.data?a.data.length:"nothing")+" bytes, expected "+n*i*4),ph(a.data,"2d-canvas");var s=lg(t,n,i);return s.pixels=new Uint8ClampedArray(a.data),s}o(v_,"captureFrom2dCanvas");function y_(e,t,r,n){(!e||typeof e.readPixels!="function")&&Sr("no WebGL context to read \u2014 captureStill() was called before init(), or the context was lost"),t>0&&r>0||Sr("GL framebuffer is "+t+"x"+r);var i=new Uint8Array(t*r*4);e.readPixels(0,0,t,r,e.RGBA,e.UNSIGNED_BYTE,i),ph(i,"webgl");var a=lg(n,t,r);return a.pixels=sg(i,t,r),a}o(y_,"captureFromGl");Ci();var b_=["precision highp float;","","uniform sampler2D uField;","uniform sampler2D uScene;","uniform vec2 uResolution;","uniform float uTime;","","varying vec2 vTexCoord;","","// Sample height with a small ripple that advances with simulation time (uTime).","float height(vec2 uv) {"," float h = texture2D(uField, uv).r;"," h += 0.03 * sin(uv.x * 60.0 + uTime * 1.5)"," + 0.03 * sin(uv.y * 48.0 - uTime * 1.1);"," return h;","}","","void main() {"," vec2 uv = vTexCoord;"," vec2 texel = 1.0 / uResolution;",""," // Surface normal from finite differences (Sobel-ish)."," float hL = height(uv - vec2(texel.x, 0.0));"," float hR = height(uv + vec2(texel.x, 0.0));"," float hD = height(uv - vec2(0.0, texel.y));"," float hU = height(uv + vec2(0.0, texel.y));"," vec3 n = normalize(vec3(hL - hR, hD - hU, 0.18));",""," // Refraction: offset scene lookup by surface slope (Snell-ish cheap approx)."," float refractAmt = 0.025;"," vec2 refracted = uv + n.xy * refractAmt;"," vec3 base = texture2D(uScene, refracted).rgb;",""," // Specular highlight from a fixed directional light."," vec3 lightDir = normalize(vec3(0.4, 0.7, 0.6));"," float spec = pow(max(dot(n, lightDir), 0.0), 32.0);",""," // Fake caustics: bright where the surface focuses (high curvature)."," float curvature = abs((hL + hR + hU + hD) * 0.25 - height(uv));"," float caustic = smoothstep(0.02, 0.12, curvature);",""," // Shallow-water tint deepening with height; add specular + caustics."," vec3 waterTint = mix("," vec3(0.02, 0.10, 0.16),"," vec3(0.10, 0.34, 0.42),"," height(uv)"," );"," vec3 color = base * 0.65 + waterTint * 0.55"," + spec * vec3(0.9, 0.97, 1.0)"," + caustic * vec3(0.45, 0.85, 0.95);",""," gl_FragColor = vec4(color, 1.0);","}"].join(`
|
|
6
|
-
`),
|
|
7
|
-
`),
|
|
8
|
-
`);function
|
|
9
|
-
`)}o(D_,"upgradeGlsl");function vh(){var e=Nn,t=Yo,r=Ga;return t.universalRenderCapabilities(e,nn,ar).concat(t.filterRenderCapabilities(e,r))}o(vh,"_renderCapabilitiesP5");function cg(){var e=null,t=null;function r(){return new Error("p5Provider: the physics rect was read before init({width, height}) or setSize(w, h) stated it. FrqtlApp.createCanvas hands the runner's canvas_rect to provider.init \u2014 the provider has no default size.")}o(r,"_unsized");function n(){if(e===null)throw r();return e}o(n,"_physW");function i(){if(t===null)throw r();return t}o(i,"_physH");var a=[],s=!1,l=null,u={},f=null,c=null,h=null,g=null;function p(){return g||(g=fh(n(),i())),g}o(p,"_poseOrDefault");function m(){var T=p();return{distance:T.distance,target:T.target?{x:T.target.x,y:T.target.y}:null}}o(m,"_poseBag");var b=null;function y(){b&&b.notify(m())}o(y,"_notifyPose");function w(T){if(!(!T||typeof image!="function"))for(var J=0;J<T.length;J++){var D=T[J];D.visible===!1||!D.backdrop||!D.image||image(D.image,D.rect.left,D.rect.top,D.rect.w,D.rect.h)}}o(w,"_layerBackdrop");function O(T){if(T)for(var J=0;J<T.length;J++){var D=T[J];if(!(D.visible===!1||D.backdrop)){var K=D.alpha!==void 0?D.alpha:255;if(D.liveCanvas){var N=typeof D.liveCanvas=="function"?D.liveCanvas():D.liveCanvas,B=!1;if(push(),N&&typeof drawingContext<"u"&&drawingContext&&typeof drawingContext.drawImage=="function"){var ne=drawingContext.globalAlpha;drawingContext.globalAlpha=Math.max(0,Math.min(1,K/255));try{drawingContext.drawImage(N,D.rect.left,D.rect.top,D.rect.w,D.rect.h),B=!0}catch{}drawingContext.globalAlpha=ne}else if(N&&typeof image=="function")try{image(N,D.rect.left,D.rect.top,D.rect.w,D.rect.h),B=!0}catch{}B||(noStroke(),fill(D.color[0],D.color[1],D.color[2],K),rect(D.rect.left,D.rect.top,D.rect.w,D.rect.h)),pop();continue}var oe;typeof D.shellShape=="string"&&D.shellShape?oe=D.shellShape!=="box"&&D.shellShape!=="cube":oe=!!D.drawAsCircle;var $=D.rect.left+D.rect.w/2,de=D.rect.top+D.rect.h/2,ve=typeof D.orientationDeg=="number"?(D.orientationDeg%360+360)%360:0;if(ve!==0){push(),noStroke(),fill(D.color[0],D.color[1],D.color[2],K),translate($,de),rotate(radians(ve)),oe?ellipse(0,0,D.rect.w,D.rect.h):rect(-D.rect.w/2,-D.rect.h/2,D.rect.w,D.rect.h),pop();continue}noStroke(),fill(D.color[0],D.color[1],D.color[2],K),oe?ellipse($,de,D.rect.w,D.rect.h):rect(D.rect.left,D.rect.top,D.rect.w,D.rect.h)}}}o(O,"_layerBodies");function S(T,J){if(!(!T||!T.frameData)){for(var D=xn,K=nn,N={},B=[],ne=0;ne<T.frameData.length;ne++){var oe=T.frameData[ne].layer,$=oe??0;N[$]||(N[$]=[],B.push($)),N[$].push(T.frameData[ne])}B.sort(function(L,ee){return L-ee});for(var de=0;de<B.length;de++)for(var ve=N[B[de]],ue=0;ue<ve.length;ue++)A(ve[ue],D,K,J)}}o(S,"_layerParticles");function A(T,J,D,K){var N,B=T.data&&T.data.string_map,ne=null;if(B&&B["render.color"]){var oe=String(B["render.color"]).split(",").map(Number);oe.length>=3&&oe.every(function(Ce){return!isNaN(Ce)})&&(ne=oe)}var $=B&&B["render.colorScheme"]?B["render.colorScheme"]:K&&K.colorScheme?K.colorScheme:"warmcool";if(ne)N=ne;else{var de=J.getRgbBySchemeName($,T.fullness),ve=J.getAlphaFromIntensity(T.fullness);N=[de[0],de[1],de[2],ve]}var ue=D.resolve(T,K),L=N[0],ee=N[1],X=N[2],te=N[3]!==void 0?N[3]:1;if(noStroke(),ue==="box")fill(L,ee,X,te*255),rect(T.rect.left,T.rect.top,T.rect.w,T.rect.h);else if(ue==="circle")strokeWeight(1),stroke(L,ee,X,te*255),noFill(),ellipse(T.rect.x,T.rect.y,T.rect.w,T.rect.h);else{var ye=!!(B&&B["render.outline"]==="true");if(ye)strokeWeight(1),stroke(L,ee,X,te*255),noFill(),rect(T.rect.left,T.rect.top,T.rect.w,T.rect.h);else{var xe=Math.max(1,T.rect.w/2),Ue=Math.max(2,T.rect.w);fill(L,ee,X,te*255),ellipse(T.rect.x,T.rect.y,xe,xe),fill(L,ee,X,25),ellipse(T.rect.x,T.rect.y,Ue,Ue)}}}o(A,"_drawQuantum");function C(T,J,D,K){if(!(typeof background>"u")){background(0);var N=Ml(p(),n(),i()),B=typeof push=="function"&&typeof scale=="function"&&typeof translate=="function";B&&(push(),translate(n()/2,i()/2),scale(N.k),translate(-N.cx,-N.cy)),w(J),O(J),D&&S(T,K),B&&pop()}}o(C,"_composeLayers");function R(){if(l&&l.elt)return l.elt;throw new Error("p5Provider: no canvas to read \u2014 the provider's p5 canvas element is absent. init({width, height}) creates it (p5's createCanvas() \u2192 .elt); call init first (FrqtlApp.createCanvas does).")}o(R,"_getP5Canvas");function Q(){return!f||!f.frameData?new Uint8Array(Er.FIELD_OPTS.w*Er.FIELD_OPTS.h):Er.buildHeightField(f.frameData,Object.assign({},Er.FIELD_OPTS,{canvasW:n(),canvasH:i()}))}o(Q,"_buildFieldTexture");function Y(T,J){var D=document.createElement("canvas");D.width=J.width,D.height=J.height;var K=D.getContext("webgl2");if(!K)return console.warn("[p5-provider] WebGL2 unavailable for filter:",T.name),{skip:!0};var N=T.glsl.indexOf("#version")===-1?D_(T.glsl):T.glsl,B=R_(K,C_,N);if(!B)return{skip:!0};var ne=K.createBuffer();K.bindBuffer(K.ARRAY_BUFFER,ne),K.bufferData(K.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,1]),K.STATIC_DRAW);function oe(){var $=K.createTexture();return K.bindTexture(K.TEXTURE_2D,$),K.texParameteri(K.TEXTURE_2D,K.TEXTURE_MIN_FILTER,K.LINEAR),K.texParameteri(K.TEXTURE_2D,K.TEXTURE_WRAP_S,K.CLAMP_TO_EDGE),K.texParameteri(K.TEXTURE_2D,K.TEXTURE_WRAP_T,K.CLAMP_TO_EDGE),$}return o(oe,"makeTex"),{gl:K,prog:B,quadBuf:ne,sceneTex:oe(),fieldTex:oe(),offscreen:D}}o(Y,"_initFilterState");function H(T,J){var D=R(),K=T.name||"filter",N=u[K];if(N||(N=Y(T,D),u[K]=N),!N.skip){var B=N.gl,ne=D.width,oe=D.height,$=n(),de=i();(N.offscreen.width!==ne||N.offscreen.height!==oe)&&(N.offscreen.width=ne,N.offscreen.height=oe),B.viewport(0,0,ne,oe),B.bindTexture(B.TEXTURE_2D,N.sceneTex);try{B.texImage2D(B.TEXTURE_2D,0,B.RGBA,B.RGBA,B.UNSIGNED_BYTE,D)}catch{return}var ve=Er.FIELD_OPTS,ue=ve.w,L=ve.h,ee=Q();B.bindTexture(B.TEXTURE_2D,N.fieldTex),B.texImage2D(B.TEXTURE_2D,0,B.R8,ue,L,0,B.RED,B.UNSIGNED_BYTE,ee),B.useProgram(N.prog);var X=B.getAttribLocation(N.prog,"aPosition");B.bindBuffer(B.ARRAY_BUFFER,N.quadBuf),B.enableVertexAttribArray(X),B.vertexAttribPointer(X,2,B.FLOAT,!1,0,0),B.uniform2f(B.getUniformLocation(N.prog,"uResolution"),ne,oe),B.uniform1f(B.getUniformLocation(N.prog,"uTime"),J),B.activeTexture(B.TEXTURE0),B.bindTexture(B.TEXTURE_2D,N.sceneTex),B.uniform1i(B.getUniformLocation(N.prog,"uScene"),0),B.activeTexture(B.TEXTURE1),B.bindTexture(B.TEXTURE_2D,N.fieldTex),B.uniform1i(B.getUniformLocation(N.prog,"uField"),1),B.drawArrays(B.TRIANGLE_STRIP,0,4);var te=D.getContext("2d");te&&te.drawImage(N.offscreen,0,0,ne,oe,0,0,$,de)}}o(H,"_runFilter");var q={init:o(function(T){zn("p5Provider.init",T&&T.width,T&&T.height),e=T.width,t=T.height;var J=jo("p5Provider.init",T.parentEl);return l=createCanvas(n(),i()),l.parent(J),s=!0,R()},"init"),renderTick:o(function(T,J,D){f=T;var K=!D||D.renderBaseCanvas!==!1;c=K,C(T,J,K,D);var N=a.length>0?Lo(T):null;h=N;for(var B=0;B<a.length;B++)H(a[B],N)},"renderTick"),filter:o(function(T,J){if(T){if(T.name){for(var D=0;D<a.length;D++)if(a[D].name===T.name){J&&(a[D]._perFilterOptions=J);return}}var K=T;J&&(K=Object.assign({},T),K._perFilterOptions=J),a.push(K)}},"filter"),removeFilter:o(function(T){var J=typeof T=="string"?T:T&&T.name;a=a.filter(function(D){return D.name!==J}),J&&u[J]&&delete u[J]},"removeFilter"),setSize:o(function(T,J){zn("p5Provider.setSize",T,J),e=T,t=J,s&&typeof resizeCanvas=="function"&&resizeCanvas(T,J),y()},"setSize"),start:o(function(){},"start"),stop:o(function(){},"stop"),destroy:o(function(){l&&l.remove&&l.remove(),s=!1,a=[],u={},f=null,h=null},"destroy"),raw:o(function(){return l},"raw"),renderCapabilities:vh,screenToWorld:o(function(T,J,D,K){return hh(p(),n(),i(),T,J,D||n(),K||i())},"screenToWorld"),getCameraControl:o(function(){var T=dh;function J(N,B,ne){if(typeof N=="number"&&isFinite(N))return N;throw new Error("p5-provider camera "+ne+": "+B+" must be a finite number, got "+String(N)+" \u2014 throw-or-apply, never a silent clamp.")}o(J,"_finite");function D(){return T.PRESETS_2D(n(),i())}o(D,"_presets");var K={presets:Object.keys(D()),poseFields:T.POSE_FIELDS_2D(n(),i()),setOrbit:o(function(N){if(N){N=yo(N);var B=p();if(N.distance!==void 0){var ne=J(N.distance,"distance","setOrbit");if(ne<=0)throw new Error("p5-provider camera setOrbit: distance is the VISIBLE HEIGHT in physics px and must be > 0, got "+ne+". (FAIL-LOUD.)");B.distance=ne}if("target"in N){var oe=N.target;B.target=oe?{x:oe.x,y:oe.y}:null}for(var $=Is,de=0;de<$.length;de++)if(N[$[de]]!==void 0)throw new Error('p5-provider camera setOrbit: this camera declares no "'+$[de]+'" axis (2D pose is {distance, target}). Check cameraControl.poseFields rather than assuming a mode. (FAIL-LOUD.)');y()}},"setOrbit"),getOrbit:o(function(){return m()},"getOrbit"),addPoseListener:o(function(N){return b||(b=bo()),b.add(N)},"addPoseListener"),setPreset:o(function(N){var B=D(),ne=B[N];if(!ne)throw new Error('[p5-provider camera] setPreset("'+N+'"): this camera offers only ['+Object.keys(B).join(", ")+"] (ctl.presets). (FAIL-LOUD.)");K.setOrbit(ne)},"setPreset")};return K},"getCameraControl"),projection:o(function(){return{kind:"affine2d"}},"projection"),captureStill:o(function(){var T=Ko,J=T.captureFrom2dCanvas(R(),{cssWidth:n(),cssHeight:i(),physicsW:n(),physicsH:i(),filtersApplied:a.map(function(D){return D.name}),renderBaseCanvas:c,filterTime:h,composited:f});return Promise.resolve(J)},"captureStill"),get initialized(){return s}};return q}o(cg,"makeP5Provider");Na();Ci();Ln();var Zo={};Oe(Zo,{GODRAY_SOURCES:()=>Qo,GODRAY_SOURCE_DEFAULT:()=>Xo,fundamentalLayerOf:()=>fg,godraySourceFrames:()=>pg,isGodraySource:()=>hg,makeGodrayPasses:()=>I_,resolveGodraySource:()=>dg});function fg(e){var t=e&&e.dimensionData,r=null;if(t)for(var n=0;n<t.length;n++){var i=t[n]&&t[n].layer;typeof i=="number"&&(r===null||i<r)&&(r=i)}if(r===null&&e&&e.frameData&&e.frameData.length)throw new Error("GodraysLayer: tickData carries "+e.frameData.length+" frames but no dimensionData[].layer, so the fundamental layer the god-rays are computed from cannot be named.");return r}o(fg,"fundamentalLayerOf");function hg(e,t){return t!==null&&e===t}o(hg,"isGodraySource");var Qo=["leaf","all"],Xo="leaf";function dg(e){if(e==null)return Xo;if(Qo.indexOf(e)===-1)throw new Error("GodraysLayer: godraySource "+JSON.stringify(e)+" is not one of ["+Qo.join(", ")+"] (default "+JSON.stringify(Xo)+").");return e}o(dg,"resolveGodraySource");function pg(e,t){var r=e&&e.frameData||[];if(dg(t)==="all")return r.slice();for(var n=fg(e),i=[],a=0;a<r.length;a++)hg(r[a].layer,n)&&i.push(r[a]);return i}o(pg,"godraySourceFrames");var j_=["uniform sampler2D uScene;","uniform vec2 uLightPos;","uniform float uDecay;","uniform float uDensity;","uniform float uWeight;","uniform float uExposure;","varying vec2 vTexCoord;","const int SAMPLES = 50;","void main() {"," vec2 tc = vTexCoord;"," vec2 delta = (tc - uLightPos) * (1.0 / float(SAMPLES)) * uDensity;"," vec3 rays = vec3(0.0);"," float decay = 1.0;"," for (int i = 0; i < SAMPLES; i++) {"," tc -= delta;"," vec3 s = texture2D(uScene, tc).rgb;"," rays += s * decay * uWeight;"," decay *= uDecay;"," }"," gl_FragColor = vec4(rays * uExposure, 1.0);","}"].join(`
|
|
10
|
-
`),
|
|
11
|
-
`);function
|
|
12
|
-
`),
|
|
13
|
-
`),
|
|
14
|
-
`),Vl=[.92,.72,1,.6,.86,.78];function Eg(e){return{color:e&&e.color||[200,200,200],alpha:e&&e.alpha!==void 0?e.alpha/255:1}}o(Eg,"loSkin");function q_(e){var t=Eg(e);return t.color.join(",")+"|"+t.alpha}o(q_,"loSkinSig");function B_(e,t){for(var r=Eg(t),n=Array.isArray(e)?e:[e],i=n.length===Vl.length,a=0;a<n.length;a++){var s=n[a];if(s){var l=i?Vl[a]:1;!s.map&&s.color&&typeof s.color.setRGB=="function"&&s.color.setRGB(r.color[0]/255*l,r.color[1]/255*l,r.color[2]/255*l);var u=s.map?!0:r.alpha<1;s.transparent!==u&&(s.transparent=u,s.needsUpdate=!0),s.opacity=r.alpha,s.depthWrite=r.alpha>=1}}return r}o(B_,"applyLoSkin");function Ch(){var e=Nn,t=nn,r=ar,n=Ga,i=Yo,a=i.universalRenderCapabilities(e,t,r).concat([e({name:"godrays",type:"number",unit:"intensity",default:0,constraint:{min:0,max:3,integer:!1},description:"God-rays post-process composite intensity (three-only final-composite layer)."}),e({name:"godrayDensity",type:"number",unit:"density",default:.8,constraint:{min:.2,max:1.5,integer:!1},description:"God-rays radial-blur density/spread (only consulted when godrays > 0)."}),e({name:"godraySource",type:"enum",default:Xo,constraint:{values:Qo.reduce(function(s,l){return s[l]=l,s},{})},description:"What the god-rays are computed from: 'leaf' = the fundamental-layer frames (LOs only occlude), 'all' = the whole lit scene (every frame of every layer and every LO)."}),e({name:"glowIntensity",type:"number",unit:"intensity",default:0,constraint:{min:0,max:3,integer:!1},description:"Per-dim glow-layer intensity multiplier (R4-GEO additive glow shading)."}),e({name:"heat",type:"number",unit:"0-1",default:0,constraint:{min:0,max:1,integer:!1},description:"Heat-ramp shift: warms dense-quanta color toward the hot end of the scheme."}),e({name:"smoke",type:"number",unit:"intensity",default:0,constraint:{min:0,max:16,integer:!1},description:"Smoke-puff layer intensity (per-dim greyscale+soft paint gate)."})]).concat(i.meshRenderCapabilities(e)).concat(i.filterRenderCapabilities(e,n));return a}o(Ch,"_renderCapabilitiesThree");function Sg(e){var t=uf(),r=null,n=null;function i(){return new Error("threeProvider: the physics rect was read before init({width, height}) or setSize(w, h) stated it. FrqtlApp.createCanvas hands the runner's canvas_rect to provider.init \u2014 the provider has no default size.")}o(i,"_unsized");function a(){if(r===null)throw i();return r}o(a,"_physW");function s(){if(n===null)throw i();return n}o(s,"_physH");var l=null,u=null,f=null,c=null,h=!!(e&&e.is3D),g=null,p=0,m={azimuth:0,elevation:0,distance:0,roll:0,target:null};function b(){if(h){if(f){var E=Th,P=E._orbitCenter(m,a(),s()),z=E._orbitCameraBasis(m,a(),s());f.position.set(z.pos.x,z.pos.y,z.pos.z),f.up.set(z.up.x,z.up.y,z.up.z),f.lookAt(P.x,P.y,P.z),f.updateProjectionMatrix()}w&&w.notify(y())}}o(b,"_applyOrbit");function y(){return{azimuth:m.azimuth,elevation:m.elevation,distance:m.distance,roll:m.roll,target:m.target?{x:m.target.x,y:m.target.y,z:m.target.z}:null}}o(y,"_orbitBag");var w=null,O={},S=2048;function A(E){return{cap:E,posArr:new Float32Array(E*3),fullArr:new Float32Array(E),colArr:new Float32Array(E*3),alphaArr:new Float32Array(E),sizeArr:new Float32Array(E),smokeArr:new Float32Array(E)}}o(A,"_makeDimLayerBuffers");function C(E,P,z){var G=O[E];if(G)return G;if(z==="sphere"){var U=ms(S);return U.visible=!1,u.add(U),G={isSphere:!0,mesh:U,capacity:S,centroid:{x:0,y:0,z:0}},O[E]=G,G}var fe=A(S),re=new t.BufferGeometry;re.setAttribute("position",new t.BufferAttribute(fe.posArr,3)),re.setAttribute("aFullness",new t.BufferAttribute(fe.fullArr,1)),re.setAttribute("aColor",new t.BufferAttribute(fe.colArr,3)),re.setAttribute("aAlpha",new t.BufferAttribute(fe.alphaArr,1)),re.setAttribute("aSize",new t.BufferAttribute(fe.sizeArr,1)),re.setAttribute("aSmoke",new t.BufferAttribute(fe.smokeArr,1)),re.setDrawRange(0,0);var Be={uIntensity:{value:1},uHeat:{value:0},uSmoke:{value:0},uPersp:{value:h?1:0}};P||(Be.uShape={value:p});var rt=new t.ShaderMaterial({vertexShader:z_,fragmentShader:V_,transparent:!0,depthTest:!0,depthWrite:!1,uniforms:Be});P&&(rt.blending=t.AdditiveBlending);var Ne=new t.Points(re,rt);return Ne.visible=!1,u.add(Ne),G={geo:re,mat:rt,mesh:Ne,isAdditive:P,bufs:fe,centroid:{x:0,y:0,z:0}},O[E]=G,G}o(C,"_ensureDimLayer");function R(E,P){if(E.isSphere){if(P<=E.capacity)return;for(var z=E.capacity;z<P;)z=z*2;var G=E.mesh,U=ms(z);U.visible=G.visible,U.renderOrder=G.renderOrder,u.remove(G),G.dispose(),u.add(U),E.mesh=U,E.capacity=z;return}if(!(P<=E.bufs.cap)){for(var fe=E.bufs.cap;fe<P;)fe=fe*2;E.bufs=A(fe),E.geo.setAttribute("position",new t.BufferAttribute(E.bufs.posArr,3)),E.geo.setAttribute("aFullness",new t.BufferAttribute(E.bufs.fullArr,1)),E.geo.setAttribute("aColor",new t.BufferAttribute(E.bufs.colArr,3)),E.geo.setAttribute("aAlpha",new t.BufferAttribute(E.bufs.alphaArr,1)),E.geo.setAttribute("aSize",new t.BufferAttribute(E.bufs.sizeArr,1)),E.geo.setAttribute("aSmoke",new t.BufferAttribute(E.bufs.smokeArr,1))}}o(R,"_growDimLayerIfNeeded");function Q(){for(var E in O)O.hasOwnProperty(E)&&(O[E].mesh.visible=!1)}o(Q,"_hideAllDimLayers");function Y(E){var P=E.x-f.position.x,z=E.y-f.position.y,G=E.z-f.position.z;return P*P+z*z+G*G}o(Y,"_camDistSq");var H=new Map,q=null,T=null,J=0,D=null,K=null,N=null,B=null,ne=null,oe=null,$=null,de=null,ve=null,ue=null,L=null,ee=null,X=null,te=null,ye=null,xe=null,Ue=null,Ce={},_e=null,Ve={},wt=0,Vt=0,Gt=null,se=null,ge=null,jt=null,ut=null,Ht=null,_t={},ct=[],ot=null,Yr=0,Kt=!1,cr=null,pi=null,mi=null,fr=null;function er(E){zn("threeProvider.init",E&&E.width,E&&E.height);var P=jo("threeProvider.init",E.parentEl);r=E.width,n=E.height,h=!!(E&&E.is3D),g=E&&E.depth!==void 0?E.depth:null,l=new t.WebGLRenderer({antialias:!1,alpha:!1}),l.setSize(a(),s()),l.setPixelRatio(1),c=l.domElement,P.appendChild(c),h?(f=new t.PerspectiveCamera(es,a()/s(),.1,1e5),m.distance=Math.max(a(),s())*1.6,b()):f=new t.OrthographicCamera(0,a(),s(),0,-1,1),u=new t.Scene,u.background=new t.Color(0);var z=new t.AmbientLight(16777215,.45);u.add(z);var G=new t.DirectionalLight(16777215,.9);G.position.set(1.2,-2,2.5).normalize(),u.add(G),D=new t.Matrix4,K=new t.Color,ee=new t.Matrix4,X=new t.Vector3,te=new t.Quaternion,ye=new t.Vector3,xe=new t.Color;var U=Er.FIELD_OPTS;wt=U.w,Vt=U.h,se=new Uint8Array(wt*Vt),Gt=new t.DataTexture(se,wt,Vt,t.RedFormat,t.UnsignedByteType),Gt.minFilter=t.LinearFilter,Gt.magFilter=t.LinearFilter,Gt.needsUpdate=!0,ge=new t.WebGLRenderTarget(a(),s()),jt=new t.WebGLRenderTarget(a(),s()),ut=new t.Scene,Ht=new t.OrthographicCamera(-1,1,1,-1,0,1),Kt=!0}o(er,"_init");function no(E,P){var z=Ha.resolve(E,P),G=z&&Ce[z]?Ce[z].status:"";return[E.shape||(E.drawAsCircle?"c":"r"),E.rect.w,E.rect.h,E.depth||"",E.rect.d||"",E.shellShape||"",E.renderHint||"",E.sprite||"",E.liveCanvas?"L":"",E.renderHint?(E.color||[]).join("-"):"",z||"",G,E.meshScale||"",(E.meshRotation||[]).join("|")].join(",")}o(no,"_loSig");function na(E){var P=E&&E.liveCanvas;if(!P)return null;try{var z=typeof P=="function"?P():P;return z||null}catch{return null}}o(na,"_resolveLiveCanvas");var ia=[{uAxis:"z",uDir:-1,vAxis:"y",vDir:1},{uAxis:"z",uDir:1,vAxis:"y",vDir:1},{uAxis:"x",uDir:1,vAxis:"z",vDir:-1},{uAxis:"x",uDir:1,vAxis:"z",vDir:1},{uAxis:"x",uDir:1,vAxis:"y",vDir:1},{uAxis:"x",uDir:-1,vAxis:"y",vDir:1}];function io(E,P,z){return z>0?E<=P&&E<=z?{axis:"x",faces:[0,1]}:P<=E&&P<=z?{axis:"y",faces:[2,3]}:{axis:"z",faces:[4,5]}:{axis:"z",faces:[4,5]}}o(io,"_thinAxisFaces");function cn(E,P){var z=typeof E=="string"?new t.TextureLoader().load(E):new t.CanvasTexture(E);return z.minFilter=t.LinearFilter,z.flipY=!1,P&&P.mirrorU&&(z.wrapS=t.RepeatWrapping,z.repeat.x=-1,z.offset.x=1),P&&P.mirrorV&&(z.wrapT=t.RepeatWrapping,z.repeat.y=-1,z.offset.y=1),z}o(cn,"_makeWorldTexture");function kn(E,P,z){return new t.MeshBasicMaterial({map:E,transparent:!0,opacity:P,depthWrite:z,side:t.DoubleSide})}o(kn,"_worldPlaneMaterial");function Ir(E){var P=ia[E]||ia[4];return{mirrorU:P.uDir<0,mirrorV:P.vDir<0}}o(Ir,"_liveFaceTransform");function ao(E,P){var z=E.alpha!==void 0?E.alpha/255:1,G=z>=1,U=Ha.resolve(E,P);if(U){so(U);var fe=Ce[U];if(fe&&fe.status==="ready"&&fe.scene){var re=fe.scene.clone(!0);re.frustumCulled=!1;var Be=Math.max(E.rect.w,E.rect.h,E.depth||0)||E.rect.w,rt=typeof E.meshScale=="number"&&E.meshScale>0?E.meshScale:1;return re.scale.setScalar(Be*fe.norm*rt),E.meshRotation&&re.rotation.set(E.meshRotation[0]||0,E.meshRotation[1]||0,E.meshRotation[2]||0),re}return new t.Group}if(E.liveCanvas){var Ne=na(E),Fe=E.depth!==void 0&&E.depth>0?E.depth:E.rect.d!==void 0&&E.rect.d>0?E.rect.d:0,nt=E.color||[30,40,55],We,Ie;if(Fe>0){var kt=io(E.rect.w,E.rect.h,Fe),Pe=new t.BoxGeometry(E.rect.w,E.rect.h,Fe);Ie=[];var it=Vl.map(function(Jt,dn){var yi=kt.faces.indexOf(dn)!==-1;if(yi&&Ne){var Rr=Ir(dn);return Ie.push({index:dn,mirrorU:Rr.mirrorU,mirrorV:Rr.mirrorV}),new t.MeshBasicMaterial({map:cn(Ne,Rr),transparent:!0,opacity:z,depthWrite:G})}return new t.MeshBasicMaterial({color:new t.Color(nt[0]/255*Jt,nt[1]/255*Jt,nt[2]/255*Jt),transparent:z<1,opacity:z,depthWrite:G})});Ne||(Ie=kt.faces.map(function(Jt){var dn=Ir(Jt);return{index:Jt,mirrorU:dn.mirrorU,mirrorV:dn.mirrorV}})),We=new t.Mesh(Pe,it),We.add(new t.LineSegments(new t.EdgesGeometry(Pe),new t.LineBasicMaterial({color:16777215,transparent:!0,opacity:.35})))}else{var xt=new t.PlaneGeometry(E.rect.w,E.rect.h),hr=Ir(4);Ie=[{index:-1,mirrorU:hr.mirrorU,mirrorV:hr.mirrorV}];var Yt;Ne?Yt=kn(cn(Ne,hr),z,G):Yt=new t.MeshBasicMaterial({color:new t.Color(nt[0]/255,nt[1]/255,nt[2]/255),transparent:z<1,opacity:z,depthWrite:G,side:t.DoubleSide}),We=new t.Mesh(xt,Yt)}return We.userData=We.userData||{},We.userData.liveCanvasSrc=Ne||null,We.userData.liveCanvasFaces=Ie,We}var Tt=typeof E.shellShape=="string"&&E.shellShape?E.shellShape:null,hn=E.shape==="box"||Tt==="box"||Tt==="cube"||E.shape===void 0&&Tt===null&&E.rect.d!==void 0&&E.rect.d>0;if(hn){var Pr=E.depth!==void 0?E.depth:E.rect.d!==void 0?E.rect.d:E.rect.w,Jr=new t.BoxGeometry(E.rect.w,E.rect.h,Pr),dr=E.color||[200,200,200],Cr=Vl.map(function(Jt){return new t.MeshBasicMaterial({color:new t.Color(dr[0]/255*Jt,dr[1]/255*Jt,dr[2]/255*Jt),transparent:z<1,opacity:z,depthWrite:G})}),Fr=new t.Mesh(Jr,Cr);return Fr.add(new t.LineSegments(new t.EdgesGeometry(Jr),new t.LineBasicMaterial({color:16777215,transparent:!0,opacity:.35}))),Fr}var gt=Tt?Tt!=="box"&&Tt!=="cube"&&Tt!=="sphere":!!E.drawAsCircle,An=Tt==="sphere"?new t.SphereGeometry(E.rect.w/2,24,16):gt?new t.CircleGeometry(E.rect.w/2,32):new t.PlaneGeometry(E.rect.w,E.rect.h),Nr;if(E.sprite||E.renderHint){var vi=E.sprite?cn(E.sprite,Ir(4)):yu(E.renderHint,E.color);Nr=kn(vi,z,G)}else Nr=new t.MeshBasicMaterial({color:new t.Color(E.color[0]/255,E.color[1]/255,E.color[2]/255),transparent:z<1,opacity:z,depthWrite:G});return new t.Mesh(An,Nr)}o(ao,"_buildLoMesh");var fn={};function yu(E,P){var z=E+"|"+(P?P.join(","):"");if(fn[z])return fn[z];var G=document.createElement("canvas");G.width=256,G.height=256;var U=G.getContext("2d");if(E==="gun"){var fe="rgb("+(P?P.join(","):"46,46,52")+")";U.clearRect(0,0,256,256),U.fillStyle=fe,U.fillRect(40,96,120,56),U.fillRect(150,110,86,26),U.save(),U.translate(70,150),U.rotate(.35),U.fillRect(0,0,34,80),U.restore(),U.fillStyle="rgba(150,160,180,0.55)",U.fillRect(40,96,196,8);var re=U.createRadialGradient(236,123,2,236,123,26);re.addColorStop(0,"rgba(255,230,150,0.95)"),re.addColorStop(1,"rgba(255,180,60,0)"),U.fillStyle=re,U.beginPath(),U.arc(236,123,26,0,Math.PI*2),U.fill()}else U.fillStyle="rgb("+(P?P.join(","):"60,60,70")+")",U.fillRect(0,0,256,256),U.strokeStyle="rgba(180,200,220,0.7)",U.lineWidth=6,U.strokeRect(8,8,240,240);var Be=cn(G,Ir(4));return fn[z]=Be,Be}o(yu,"_hintTexture");function bu(E,P){var z=!T;if(!q||P>J){for(var G=J||4096;G<P;)G=G*2;q&&(u.remove(q),q.dispose()),(z||!T)&&(T&&T.dispose(),T=new t.BoxGeometry(E,E,E));var U=new t.MeshLambertMaterial({});q=new t.InstancedMesh(T,U,G),q.instanceMatrix.setUsage(t.DynamicDrawUsage),q.instanceColor=new t.InstancedBufferAttribute(new Float32Array(G*3).fill(1),3),q.instanceColor.setUsage(t.DynamicDrawUsage),q.count=0,q.frustumCulled=!1,u.add(q),J=G}}o(bu,"_ensureCubeMesh");function ms(E){L||(L=new t.SphereGeometry(.5,8,6));var P=new t.MeshLambertMaterial({}),z=new t.InstancedMesh(L,P,E);return z.instanceMatrix.setUsage(t.DynamicDrawUsage),z.instanceColor=new t.InstancedBufferAttribute(new Float32Array(E*3).fill(1),3),z.instanceColor.setUsage(t.DynamicDrawUsage),z.count=0,z.frustumCulled=!1,z}o(ms,"_buildSphereInstancedMesh");function oo(E){if(typeof document>"u")throw new Error(E);if(!document.getElementById("egpt-renderer-error")){var P=document.createElement("div");P.id="egpt-renderer-error",P.style.cssText="position:fixed;inset:0;background:#300;color:#fdd;font:14px monospace;padding:18px;white-space:pre-wrap;z-index:99999;overflow:auto;",P.textContent=`render.mesh FAIL-LOUD
|
|
5
|
+
wasm-pack build fat/crates/egpt_wasm --target web --out-dir fat/pkg-web`)}let i=null;if(typeof r.default=="function"){let a=new URL("egpt_wasm_bg.wasm",t).href,s=await fetch(String(a));if(!s.ok)throw new Error("[wasm-load-browser] failed to fetch WASM binary: "+s.status+" "+s.statusText+" ("+a+")");let l=await s.arrayBuffer();i=await I_(l),await r.default({module_or_path:l})}let n=r.WasmUniverse;if(!n)throw new Error("[wasm-load-browser] WasmUniverse not found in loaded WASM module.");return kg=i,{WasmUniverse:n}}o(F_,"load");var Tg=Object.freeze({env:"browser",load:o(function(){return F_()},"load")});var mn={};ge(mn,{clear:()=>N_,get:()=>Kh,name:()=>Si,set:()=>Hh});var Wh=null,Gh=null;function Hh(e,t){if(!e||typeof e!="object")throw new Error("[FrqtlDisplay.set] the display provider must be a RendererProvider instance. Got: "+String(e)+". (FAIL-LOUD \u2014 never a display slot holding nothing while a page believes it has a renderer.)");return Wh=e,Gh=t==null?null:String(t),e}o(Hh,"set");function Kh(){return Wh}o(Kh,"get");function Si(){return Gh}o(Si,"name");function N_(){Wh=null,Gh=null}o(N_,"clear");var Xa;function M_(){if(Xa!==void 0)return Xa;Xa=null;try{if(typeof document<"u"&&document.createElement){var e=document.createElement("canvas"),t=e.getContext("webgl2")||e.getContext("webgl"),r=t&&t.getExtension("WEBGL_debug_renderer_info");r&&(Xa=String(t.getParameter(r.UNMASKED_RENDERER_WEBGL)))}}catch{Xa=null}return Xa}o(M_,"_rasterPath");function U_(e,t,r){var i=r.renderedTick;if(!(typeof i=="number"&&isFinite(i)))throw new Error("[FrqtlCapture.capture] the provider's captureStill() bag reports no renderedTick (got "+String(i)+") \u2014 the tick of the TickData its pixels were drawn from is REQUIRED (RENDERER_CONTRACT \xA71a.4), because without it a still stamped tick "+t+" cannot be shown to carry tick "+t+"'s picture. (FAIL-LOUD.)");if(i!==t)throw new Error("[FrqtlCapture.capture] PROVENANCE MISMATCH at stage '"+e+"': the still would be stamped tick "+t+" (the loop's retained TickData) but the provider composited tick "+i+" \u2014 these pixels are not tick "+t+"'s. Capture a tick that was RENDERED: drive the clock with runner.step() (it renders, then notifies), or HOLD it from a tick listener \u2014 runner.suspendTicks(), runner.repaint() (forces the draw; an fps cap skips display frames), capture, runner.resumeTicks() in the capture's finally; outside a listener, runner.repaint() then capture in the same task. (FAIL-LOUD \u2014 a still whose label is not its pixels is a falsified record.)")}o(U_,"_assertComposited");function $t(e,t,r,i){if(!e||typeof e!="object")throw new Error("[FrqtlCapture.create] argument 1 must be the LOOP \u2014 anything exposing `lastTickData` (SimLoop / the FrqtlApp host). (FAIL-LOUD.)");if(typeof t!="function")throw new Error("[FrqtlCapture.create] argument 2 must be a providerGetter function returning the active RendererProvider or null \u2014 the provider is read LIVE, never captured at bind time. (FAIL-LOUD.)");if(!r||typeof r!="object"||r.seed===void 0||!r.rect)throw new Error("[FrqtlCapture.create] argument 3 must be the identity bag { seed, rect, sourceRef? } \u2014 `seed` is FERRIED from the party that handed it to the universe and `rect` is the physics canvas. (FAIL-LOUD.)");if(typeof i!="function")throw new Error("[FrqtlCapture.create] argument 4 must be a renderOptionsGetter function returning the ONE LIVE render-options bag \u2014 read through the getter, never copied (a copy is a second options authority). (FAIL-LOUD.)");this._loop=e,this._providerGetter=t,this._identity=r,this._renderOptionsGetter=i,this._sourceRef=r.sourceRef===void 0||r.sourceRef===null?null:String(r.sourceRef),this._sourceSha256=null,this._sceneMemo=null,this._host=null}o($t,"CaptureInstrument");$t.prototype.attachCaptureHost=function(e){var t=Ua;t.assertCaptureHost(e);var r=this._provider();if(r&&typeof r.captureStill=="function"&&e.stages.indexOf("composite")!==-1)throw new Error("[FrqtlCapture.attachCaptureHost] this instrument already has a display provider that implements captureStill(), so the `composite` stage is already executed locally. A capture host is for a stage this process CANNOT execute; attaching one here would mint a second executor \u2014 two truths about one picture. (FAIL-LOUD.)");return this._host=e,this._sceneMemo=null,e};$t.prototype.captureHost=function(){return this._host};$t.prototype._provider=function(){return this._providerGetter()||null};$t.prototype.setSourceRef=function(e){this._sourceRef=e==null?null:String(e)};$t.prototype.setSourceSha256=function(e){this._sourceSha256=Il(e)};$t.prototype._buildIdentity=function(){if(this._host)return this._host.identity().build||null;var e=Ag(),t=e!==null;return{engine:t&&ns()==="booted"?String(ea().backend):null,renderer:t&&Si()?String(Si()):null,wasmSha256:t?e:null,gl:M_()}};$t.prototype._projection=function(){if(this._host){var e=this._host.identity();return e&&e.projection?e.projection:null}var t=this._provider();return!t||typeof t.projection!="function"?null:t.projection()};$t.prototype._pose=function(){var e=this._provider();if(!e||typeof e.getCameraControl!="function")return null;var t=e.getCameraControl();return t?t.getOrbit():null};$t.prototype.sceneRecord=function(){var e=lr,t=this,r;try{var i=this._identity.rect;r=e.normalizeScene({seed:this._identity.seed,sourceRef:this._sourceRef,sourceSha256:this._sourceSha256,build:this._buildIdentity(),physicsW:i.w,physicsH:i.h,projection:this._projection()})}catch(a){return Promise.reject(a)}var n=e.canonicalizeScene(r);return this._sceneMemo&&this._sceneMemo.canon===n?Promise.resolve(e.deepPlainCopy(this._sceneMemo.value)):e.sceneHash(r).then(function(a){var s=Object.assign({},r,{scene:a});return t._sceneMemo={canon:n,value:s},e.deepPlainCopy(s)})};$t.prototype._tickIndex=function(e){var t=e&&e.universeData&&e.universeData.tick;if(typeof t=="number"&&isFinite(t))return t;throw new Error("[FrqtlCapture.capture] the live TickData carries no universeData.tick \u2014 the tick stamp is what co-registers a multi-channel capture, so it is never defaulted or omitted. (FAIL-LOUD.)")};$t.prototype._renderCapabilities=function(){var e=this._provider();return!e||typeof e.renderCapabilities!="function"?[]:e.renderCapabilities()};$t.prototype._captureRenderOptions=function(){for(var e=this._renderCapabilities(),t=this._renderOptionsGetter()||{},r={},i=0;i<e.length;i++){var n=e[i].name;!n||n.indexOf("filter.")===0||(r[n]=t[n]!==void 0?t[n]:e[i].default)}return r};$t.prototype.capture=function(e){try{return this._captureDispatch(e)}catch(t){return Promise.reject(t)}};$t.prototype._captureDispatch=function(e){var t=lr;if(t.assertStage(e),this._host&&this._host.stages.indexOf(e)!==-1){var r=Ua,i=this._host;return this.sceneRecord().then(function(u){return Promise.resolve(i.capture(e)).then(function(h){return r.verifyStill(u.scene,e,h)})})}var n=this._loop.lastTickData;if(!n)throw new Error("[FrqtlCapture.capture] no tick has run yet (the loop has retained no TickData), so there is no channel to read. Run start()/step() first. (FAIL-LOUD \u2014 never an empty buffer.)");var a=this._provider();if(e==="scene")throw t.stageNotTappableError(e,"the active renderer provider");if(e==="composite"&&(!a||typeof a.captureStill!="function"))throw t.stageNotTappableError(e,"the active renderer provider (it does not implement the OPTIONAL captureStill() capability), and no capture host is attached. In a process with no display renderer \u2014 a node rig \u2014 the composed picture is produced by the HOSTED headless stack, which runs the real renderer and its shaders: openHostedEyes({sceneRecord, sceneSource, pageUrl}) from @descix/frqtl-node/eyes (lib/frqtl/objects/instruments/hosted-eyes.js)");var s=this,l=this._tickIndex(n),c={pose:null,renderOptions:null},f=null;return t.STAGE_FORMATS[e]==="rgba8"?f=Promise.resolve().then(function(){return c.pose=s._pose(),c.renderOptions=s._captureRenderOptions(),a.captureStill()}):(c.pose=this._pose(),c.renderOptions=this._captureRenderOptions()),Promise.all([this.sceneRecord(),f]).then(function(u){var h=u[0],g={scene:h.scene,stage:e,tick:l,pose:c.pose,renderOptions:c.renderOptions};if(e==="tick")return t.normalizeStill(Object.assign({},g,{data:n.frameData,width:h.physicsW,height:h.physicsH,filtersApplied:[],renderBaseCanvas:null}));if(e==="field"){var d=Er,m=Object.assign({},d.FIELD_OPTS,{canvasW:h.physicsW,canvasH:h.physicsH});return t.normalizeStill(Object.assign({},g,{data:d.buildHeightField(n.frameData,m),width:m.w,height:m.h,fieldOpts:m,filtersApplied:[],renderBaseCanvas:null}))}var b=u[1];if(!b)throw new Error("[FrqtlCapture.capture] the provider's captureStill() resolved with nothing. (FAIL-LOUD \u2014 never a null still.)");return U_(e,l,b),t.normalizeStill(Object.assign({},g,{data:b.pixels,width:b.width,height:b.height,cssWidth:b.cssWidth,cssHeight:b.cssHeight,filtersApplied:b.filtersApplied,renderBaseCanvas:b.renderBaseCanvas,filterTime:b.filterTime}))})};$t.prototype.captureStill=function(){return this.capture(Rf())};function z_(e,t,r,i){return new $t(e,t,r,i)}o(z_,"create");var lc={create:z_};Na();Ml();un();var Qh={};ge(Qh,{POSE_FIELDS_2D:()=>V_,PRESETS_2D:()=>B_,defaultPose2d:()=>Yh,resolveView2d:()=>cc,screenToWorld2d:()=>Jh});Un();function q_(e){throw new Error("[camera2d-geometry] "+e+" (FAIL-LOUD.)")}o(q_,"_fail");function V_(e,t){var r=zi;return[r({name:"distance",label:"zoom",type:"number",unit:"px",default:t,constraint:{min:8,max:Math.max(t*4,32),integer:!1},widgetConfig:{step:Math.max(1,Math.round(t/60))},description:`The VISIBLE HEIGHT of the view in physics pixels \u2014 smaller = zoomed IN. Default = the full canvas height (1:1). The same observable as the 3D camera's distance: "how much world you see".`}),r({name:"target",label:"centre",type:"object",unit:"px",default:null,description:"The physics-px point {x,y} at the view centre; null = the canvas centre. Pan IS target \u2014 the same key the 3D camera uses."})]}o(V_,"POSE_FIELDS_2D");function B_(e,t){return{fit:{target:null,distance:t}}}o(B_,"PRESETS_2D");function Yh(e,t){return{distance:t,target:null}}o(Yh,"defaultPose2d");function cc(e,t,r){t>0&&r>0||q_("physics dims must be positive, got "+t+"x"+r);var i=e&&typeof e.distance=="number"&&isFinite(e.distance)&&e.distance>0?e.distance:r,n=e&&e.target&&typeof e.target.x=="number"&&typeof e.target.y=="number"?e.target:null;return{k:r/i,cx:n?n.x:t/2,cy:n?n.y:r/2}}o(cc,"resolveView2d");function Jh(e,t,r,i,n,a,s){var l=a>0?a:t,c=s>0?s:r,f=cc(e,t,r),u=i*(t/l),h=n*(r/c);return{x:(u-t/2)/f.k+f.cx,y:(h-r/2)/f.k+f.cy}}o(Jh,"screenToWorld2d");var as={};ge(as,{assertNonBlank:()=>Xh,captureFrom2dCanvas:()=>W_,captureFromGl:()=>G_,flipRowsToTopLeft:()=>Cg});function Sr(e){throw new Error("[captureStill] "+e+" (FAIL-LOUD \u2014 never a null or blank still.)")}o(Sr,"_fail");function Cg(e,t,r){(!e||typeof e.length!="number")&&Sr("flipRowsToTopLeft: src is not an indexed buffer");var i=t*4;e.length!==i*r&&Sr("flipRowsToTopLeft: buffer length "+e.length+" != width*height*4 ("+t+"*"+r+"*4 = "+i*r+")");for(var n=new Uint8ClampedArray(e.length),a=0;a<r;a++)for(var s=(r-1-a)*i,l=0;l<i;l++)n[a*i+l]=e[s+l];return n}o(Cg,"flipRowsToTopLeft");function Xh(e,t){e.length||Sr(t+": readback returned an EMPTY buffer");for(var r=e[0],i=1;i<e.length;i++)if(e[i]!==r)return;Sr(t+": readback is UNIFORMLY "+r+" across every byte \u2014 the buffer was cleared or unbound. A GL provider must re-render its retained scene and read back in the SAME JS task (no preserveDrawingBuffer)")}o(Xh,"assertNonBlank");function jg(e,t,r){e=e||{},Array.isArray(e.filtersApplied)||Sr("meta.filtersApplied must be the provider's ORDERED filter-name array (its own _filters list is the one authority \u2014 never the runner's unordered _activeFilters map)"),(!(typeof e.physicsW=="number"&&e.physicsW>0)||!(typeof e.physicsH=="number"&&e.physicsH>0))&&Sr("meta.physicsW/physicsH must be the POSITIVE physics-canvas dimensions this buffer maps from \u2014 they are the universe-mapping half of provenance and cannot be guessed from the buffer size (that is only right at 1:1). Got "+String(e.physicsW)+"x"+String(e.physicsH));var i=e.composited,n=i&&i.universeData&&i.universeData.tick;typeof n=="number"&&isFinite(n)||Sr("meta.composited must be the TickData this provider last drew (its retained _lastTickData, carrying universeData.tick) \u2014 nothing has been composited, so there is no tick these pixels could be labelled with");var a=e.filterTime===void 0?null:e.filterTime,s=e.filtersApplied.length>0;return(s?!(typeof a=="number"&&isFinite(a)):a!==null)&&Sr("meta.filterTime must be the finite uTime the filter passes drew with when filtersApplied is non-empty, and null when it is empty (filtersApplied "+JSON.stringify(e.filtersApplied)+", filterTime "+String(a)+")"),{renderedTick:n,width:t,height:r,cssWidth:typeof e.cssWidth=="number"&&e.cssWidth>0?e.cssWidth:t,cssHeight:typeof e.cssHeight=="number"&&e.cssHeight>0?e.cssHeight:r,physicsW:e.physicsW,physicsH:e.physicsH,filtersApplied:e.filtersApplied.slice(),renderBaseCanvas:typeof e.renderBaseCanvas=="boolean"?e.renderBaseCanvas:null,filterTime:a}}o(jg,"_meta");function W_(e,t){e||Sr("no canvas to read \u2014 captureStill() was called before init() created one");var r=typeof e.getContext=="function"?e.getContext("2d"):null;(!r||typeof r.getImageData!="function")&&Sr("the canvas has no readable 2D context (getImageData unavailable)");var i=e.width,n=e.height;i>0&&n>0||Sr("canvas backing store is "+i+"x"+n);var a=r.getImageData(0,0,i,n);(!a||!a.data||a.data.length!==i*n*4)&&Sr("getImageData returned "+(a&&a.data?a.data.length:"nothing")+" bytes, expected "+i*n*4),Xh(a.data,"2d-canvas");var s=jg(t,i,n);return s.pixels=new Uint8ClampedArray(a.data),s}o(W_,"captureFrom2dCanvas");function G_(e,t,r,i){(!e||typeof e.readPixels!="function")&&Sr("no WebGL context to read \u2014 captureStill() was called before init(), or the context was lost"),t>0&&r>0||Sr("GL framebuffer is "+t+"x"+r);var n=new Uint8Array(t*r*4);e.readPixels(0,0,t,r,e.RGBA,e.UNSIGNED_BYTE,n),Xh(n,"webgl");var a=jg(i,t,r);return a.pixels=Cg(n,t,r),a}o(G_,"captureFromGl");Un();var H_=["precision highp float;","","uniform sampler2D uField;","uniform sampler2D uScene;","uniform vec2 uResolution;","uniform float uTime;","","varying vec2 vTexCoord;","","// Sample height with a small ripple that advances with simulation time (uTime).","float height(vec2 uv) {"," float h = texture2D(uField, uv).r;"," h += 0.03 * sin(uv.x * 60.0 + uTime * 1.5)"," + 0.03 * sin(uv.y * 48.0 - uTime * 1.1);"," return h;","}","","void main() {"," vec2 uv = vTexCoord;"," vec2 texel = 1.0 / uResolution;",""," // Surface normal from finite differences (Sobel-ish)."," float hL = height(uv - vec2(texel.x, 0.0));"," float hR = height(uv + vec2(texel.x, 0.0));"," float hD = height(uv - vec2(0.0, texel.y));"," float hU = height(uv + vec2(0.0, texel.y));"," vec3 n = normalize(vec3(hL - hR, hD - hU, 0.18));",""," // Refraction: offset scene lookup by surface slope (Snell-ish cheap approx)."," float refractAmt = 0.025;"," vec2 refracted = uv + n.xy * refractAmt;"," vec3 base = texture2D(uScene, refracted).rgb;",""," // Specular highlight from a fixed directional light."," vec3 lightDir = normalize(vec3(0.4, 0.7, 0.6));"," float spec = pow(max(dot(n, lightDir), 0.0), 32.0);",""," // Fake caustics: bright where the surface focuses (high curvature)."," float curvature = abs((hL + hR + hU + hD) * 0.25 - height(uv));"," float caustic = smoothstep(0.02, 0.12, curvature);",""," // Shallow-water tint deepening with height; add specular + caustics."," vec3 waterTint = mix("," vec3(0.02, 0.10, 0.16),"," vec3(0.10, 0.34, 0.42),"," height(uv)"," );"," vec3 color = base * 0.65 + waterTint * 0.55"," + spec * vec3(0.9, 0.97, 1.0)"," + caustic * vec3(0.45, 0.85, 0.95);",""," gl_FragColor = vec4(color, 1.0);","}"].join(`
|
|
6
|
+
`),K_=["precision highp float;","","uniform sampler2D uScene;","uniform vec2 uResolution;","uniform float uTime;","","varying vec2 vTexCoord;","","float luma(vec3 c) { return dot(c, vec3(0.299, 0.587, 0.114)); }","","void main() {"," vec2 uv = vTexCoord;"," vec2 texel = 1.0 / uResolution;",""," vec3 base = texture2D(uScene, uv).rgb;",""," // 9-tap box blur of bright regions only"," vec3 bloom = vec3(0.0);"," float wSum = 0.0;"," for (int dx = -2; dx <= 2; dx++) {"," for (int dy = -2; dy <= 2; dy++) {"," vec2 off = vec2(float(dx), float(dy)) * texel * 2.0;"," vec3 s = texture2D(uScene, uv + off).rgb;"," float l = luma(s);"," float w = step(0.5, l); // only bright pixels contribute"," bloom += s * w;"," wSum += w;"," }"," }"," if (wSum > 0.0) bloom /= wSum;",""," // Additive blend: base + soft bloom"," vec3 color = base + bloom * 0.35;"," gl_FragColor = vec4(color, 1.0);","}"].join(`
|
|
7
|
+
`),Za={water:{name:"water",glsl:H_,uniforms:["uField","uScene","uResolution","uTime"]},bloom:{name:"bloom",glsl:K_,uniforms:["uScene","uResolution","uTime"]}};Fi();Ba();Ea();var os={};ge(os,{_identityMap:()=>Zh,filterRenderCapabilities:()=>Q_,knownRenderCapabilityNames:()=>$h,meshRenderCapabilities:()=>J_,universalRenderCapabilities:()=>Y_});function Zh(e){for(var t={},r=0;r<e.length;r++)t[e[r]]=e[r];return t}o(Zh,"_identityMap");function Y_(e,t,r){return[e({name:"shape",type:"enum",default:"ball",label:"Default Shape",constraint:{values:Zh(t.VALID_SHAPES)},description:"Render-level DEFAULT particle shape (RenderShape.js \u2014 the one shape authority). A per-object sugar override (e.g. a SphereEmitter renderShape) wins per-leaf via the render.shape key; this is the fallback when none is set."}),e({name:"colorScheme",type:"enum",default:"warmcool",constraint:{values:Zh(r.RENDER_INTENT_VALUES["render.colorScheme"])},description:"Per-experiment default fullness-to-color ramp (LightColor.js \u2014 the one color authority)."}),e({name:"renderBaseCanvas",type:"boolean",default:!0,engineVisible:!1,description:"Whether the particle/base layer composites into the scene before any post-process pass (README \xA73). Both p5 and three honor this identically; the write gate coerces a 0/1 control value to the boolean the providers read."})]}o(Y_,"universalRenderCapabilities");function J_(e){return[e({name:"mesh",type:"string",default:null,description:"Scene-default external glTF asset id (URL) every frame is drawn as, in 3D. OPEN-ID like its per-frame twin render.mesh; unset draws the shape path."}),e({name:"meshScale",type:"number",unit:"multiplier",default:1,constraint:{min:.01,max:100,integer:!1},description:"Scene-wide scale multiplier for external-mesh clones (a frame's render.meshScale overrides it per frame)."})]}o(J_,"meshRenderCapabilities");function Q_(e,t){for(var r=[],i=Object.keys(t),n=0;n<i.length;n++)r.push(e({name:"filter."+i[n],type:"boolean",default:!1,engineVisible:!1,description:'Toggle the "'+i[n]+'" post-process filter (Filters.js \u2014 the runner routes the write to filter()/removeFilter(); a 0/1 control value is coerced to the boolean).'}));return r}o(Q_,"filterRenderCapabilities");function $h(e){if(!e||typeof e!="object")throw new Error("[RenderCapabilitiesCommon.knownRenderCapabilityNames] requires the renderer registry (providers/index.js RENDERER_PROVIDERS); got "+(e===null?"null":typeof e)+". (FAIL-LOUD.)");for(var t={},r=Object.keys(e),i=0;i<r.length;i++){var n=e[r[i]];if(!n||typeof n.renderCapabilities!="function")throw new Error('[RenderCapabilitiesCommon.knownRenderCapabilityNames] registered renderer "'+r[i]+'" exposes no static renderCapabilities() \u2014 every registry entry publishes its capability descriptors beside makeProvider. (FAIL-LOUD.)');for(var a=n.renderCapabilities(),s=0;s<a.length;s++)t[a[s].name]=!0}return Object.keys(t).sort()}o($h,"knownRenderCapabilityNames");Fi();var X_=or,ss=X_.RENDER_INTENT_VALUES["render.shape"];if(!Array.isArray(ss)||ss.length===0)throw new Error('RenderShape: frame-data RENDER_INTENT_VALUES["render.shape"] is missing or empty \u2014 the shape value set must be owned by lib/shim/frame-data.');function Z_(e,t){var r=e&&e.data&&e.data.string_map;if(r&&r["render.shape"]&&ss.indexOf(r["render.shape"])!==-1)return r["render.shape"];var i=t&&t.shape;return i&&ss.indexOf(i)!==-1?i:"ball"}o(Z_,"resolve");function $_(e){return e==="box"?1:0}o($_,"toUniform");function ex(e){return e==="cube"}o(ex,"isCubeMesh");function tx(e){return e==="sphere"}o(tx,"isSphereMesh");var ai={VALID_SHAPES:ss,resolve:Z_,toUniform:$_,isCubeMesh:ex,isSphereMesh:tx};un();var rx=["#version 300 es","in vec2 aPosition;","out vec2 vTexCoord;","void main() {"," vTexCoord = aPosition * 0.5 + 0.5;"," gl_Position = vec4(aPosition, 0.0, 1.0);","}"].join(`
|
|
8
|
+
`);function Rg(e,t,r){var i=e.createShader(t);return e.shaderSource(i,r),e.compileShader(i),e.getShaderParameter(i,e.COMPILE_STATUS)?i:(console.error("[p5-provider] shader compile error:",e.getShaderInfoLog(i)),e.deleteShader(i),null)}o(Rg,"compileShader");function ix(e,t,r){var i=Rg(e,e.VERTEX_SHADER,t),n=Rg(e,e.FRAGMENT_SHADER,r);if(!i||!n)return null;var a=e.createProgram();return e.attachShader(a,i),e.attachShader(a,n),e.linkProgram(a),e.getProgramParameter(a,e.LINK_STATUS)?a:(console.error("[p5-provider] shader link error:",e.getProgramInfoLog(a)),null)}o(ix,"compileProgram");function nx(e){var t=e.replace(/precision\s+\w+\s+float\s*;/g,"").replace(/uniform\s+sampler2D\s+\w+\s*;/g,"").replace(/uniform\s+vec2\s+\w+\s*;/g,"").replace(/uniform\s+float\s+\w+\s*;/g,"").replace(/varying\s+vec2\s+\w+\s*;/g,"").replace(/texture2D\s*\(/g,"texture(").replace(/gl_FragColor/g,"fragColor");return["#version 300 es","precision highp float;","out vec4 fragColor;","uniform sampler2D uField;","uniform sampler2D uScene;","uniform vec2 uResolution;","uniform float uTime;","in vec2 vTexCoord;",t].join(`
|
|
9
|
+
`)}o(nx,"upgradeGlsl");function ep(){var e=zi,t=os,r=Za;return t.universalRenderCapabilities(e,ai,or).concat(t.filterRenderCapabilities(e,r))}o(ep,"_renderCapabilitiesP5");function Dg(){var e=null,t=null;function r(){return new Error("p5Provider: the physics rect was read before init({width, height}) or setSize(w, h) stated it. FrqtlApp.createCanvas hands the runner's canvas_rect to provider.init \u2014 the provider has no default size.")}o(r,"_unsized");function i(){if(e===null)throw r();return e}o(i,"_physW");function n(){if(t===null)throw r();return t}o(n,"_physH");var a=[],s=!1,l=null,c={},f=null,u=null,h=null,g=null;function d(){return g||(g=Yh(i(),n())),g}o(d,"_poseOrDefault");function m(){var C=d();return{distance:C.distance,target:C.target?{x:C.target.x,y:C.target.y}:null}}o(m,"_poseBag");var b=null;function y(){b&&b.notify(m())}o(y,"_notifyPose");function w(C){if(!(!C||typeof image!="function"))for(var J=0;J<C.length;J++){var R=C[J];R.visible===!1||!R.backdrop||!R.image||image(R.image,R.rect.left,R.rect.top,R.rect.w,R.rect.h)}}o(w,"_layerBackdrop");function x(C){if(C)for(var J=0;J<C.length;J++){var R=C[J];if(!(R.visible===!1||R.backdrop)){var K=R.alpha!==void 0?R.alpha:255;if(R.liveCanvas){var N=typeof R.liveCanvas=="function"?R.liveCanvas():R.liveCanvas,B=!1;if(push(),N&&typeof drawingContext<"u"&&drawingContext&&typeof drawingContext.drawImage=="function"){var ie=drawingContext.globalAlpha;drawingContext.globalAlpha=Math.max(0,Math.min(1,K/255));try{drawingContext.drawImage(N,R.rect.left,R.rect.top,R.rect.w,R.rect.h),B=!0}catch{}drawingContext.globalAlpha=ie}else if(N&&typeof image=="function")try{image(N,R.rect.left,R.rect.top,R.rect.w,R.rect.h),B=!0}catch{}B||(noStroke(),fill(R.color[0],R.color[1],R.color[2],K),rect(R.rect.left,R.rect.top,R.rect.w,R.rect.h)),pop();continue}var oe;typeof R.shellShape=="string"&&R.shellShape?oe=R.shellShape!=="box"&&R.shellShape!=="cube":oe=!!R.drawAsCircle;var $=R.rect.left+R.rect.w/2,pe=R.rect.top+R.rect.h/2,ye=typeof R.orientationDeg=="number"?(R.orientationDeg%360+360)%360:0;if(ye!==0){push(),noStroke(),fill(R.color[0],R.color[1],R.color[2],K),translate($,pe),rotate(radians(ye)),oe?ellipse(0,0,R.rect.w,R.rect.h):rect(-R.rect.w/2,-R.rect.h/2,R.rect.w,R.rect.h),pop();continue}noStroke(),fill(R.color[0],R.color[1],R.color[2],K),oe?ellipse($,pe,R.rect.w,R.rect.h):rect(R.rect.left,R.rect.top,R.rect.w,R.rect.h)}}}o(x,"_layerBodies");function S(C,J){if(!(!C||!C.frameData)){for(var R=Ei,K=ai,N={},B=[],ie=0;ie<C.frameData.length;ie++){var oe=C.frameData[ie].layer,$=oe??0;N[$]||(N[$]=[],B.push($)),N[$].push(C.frameData[ie])}B.sort(function(L,ee){return L-ee});for(var pe=0;pe<B.length;pe++)for(var ye=N[B[pe]],ce=0;ce<ye.length;ce++)A(ye[ce],R,K,J)}}o(S,"_layerParticles");function A(C,J,R,K){var N,B=C.data&&C.data.string_map,ie=null;if(B&&B["render.color"]){var oe=String(B["render.color"]).split(",").map(Number);oe.length>=3&&oe.every(function(Ce){return!isNaN(Ce)})&&(ie=oe)}var $=B&&B["render.colorScheme"]?B["render.colorScheme"]:K&&K.colorScheme?K.colorScheme:"warmcool";if(ie)N=ie;else{var pe=J.getRgbBySchemeName($,C.fullness),ye=J.getAlphaFromIntensity(C.fullness);N=[pe[0],pe[1],pe[2],ye]}var ce=R.resolve(C,K),L=N[0],ee=N[1],X=N[2],te=N[3]!==void 0?N[3]:1;if(noStroke(),ce==="box")fill(L,ee,X,te*255),rect(C.rect.left,C.rect.top,C.rect.w,C.rect.h);else if(ce==="circle")strokeWeight(1),stroke(L,ee,X,te*255),noFill(),ellipse(C.rect.x,C.rect.y,C.rect.w,C.rect.h);else{var be=!!(B&&B["render.outline"]==="true");if(be)strokeWeight(1),stroke(L,ee,X,te*255),noFill(),rect(C.rect.left,C.rect.top,C.rect.w,C.rect.h);else{var Oe=Math.max(1,C.rect.w/2),Ue=Math.max(2,C.rect.w);fill(L,ee,X,te*255),ellipse(C.rect.x,C.rect.y,Oe,Oe),fill(L,ee,X,25),ellipse(C.rect.x,C.rect.y,Ue,Ue)}}}o(A,"_drawQuantum");function T(C,J,R,K){if(!(typeof background>"u")){background(0);var N=cc(d(),i(),n()),B=typeof push=="function"&&typeof scale=="function"&&typeof translate=="function";B&&(push(),translate(i()/2,n()/2),scale(N.k),translate(-N.cx,-N.cy)),w(J),x(J),R&&S(C,K),B&&pop()}}o(T,"_composeLayers");function j(){if(l&&l.elt)return l.elt;throw new Error("p5Provider: no canvas to read \u2014 the provider's p5 canvas element is absent. init({width, height}) creates it (p5's createCanvas() \u2192 .elt); call init first (FrqtlApp.createCanvas does).")}o(j,"_getP5Canvas");function Q(){return!f||!f.frameData?new Uint8Array(Er.FIELD_OPTS.w*Er.FIELD_OPTS.h):Er.buildHeightField(f.frameData,Object.assign({},Er.FIELD_OPTS,{canvasW:i(),canvasH:n()}))}o(Q,"_buildFieldTexture");function Y(C,J){var R=document.createElement("canvas");R.width=J.width,R.height=J.height;var K=R.getContext("webgl2");if(!K)return console.warn("[p5-provider] WebGL2 unavailable for filter:",C.name),{skip:!0};var N=C.glsl.indexOf("#version")===-1?nx(C.glsl):C.glsl,B=ix(K,rx,N);if(!B)return{skip:!0};var ie=K.createBuffer();K.bindBuffer(K.ARRAY_BUFFER,ie),K.bufferData(K.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,1]),K.STATIC_DRAW);function oe(){var $=K.createTexture();return K.bindTexture(K.TEXTURE_2D,$),K.texParameteri(K.TEXTURE_2D,K.TEXTURE_MIN_FILTER,K.LINEAR),K.texParameteri(K.TEXTURE_2D,K.TEXTURE_WRAP_S,K.CLAMP_TO_EDGE),K.texParameteri(K.TEXTURE_2D,K.TEXTURE_WRAP_T,K.CLAMP_TO_EDGE),$}return o(oe,"makeTex"),{gl:K,prog:B,quadBuf:ie,sceneTex:oe(),fieldTex:oe(),offscreen:R}}o(Y,"_initFilterState");function H(C,J){var R=j(),K=C.name||"filter",N=c[K];if(N||(N=Y(C,R),c[K]=N),!N.skip){var B=N.gl,ie=R.width,oe=R.height,$=i(),pe=n();(N.offscreen.width!==ie||N.offscreen.height!==oe)&&(N.offscreen.width=ie,N.offscreen.height=oe),B.viewport(0,0,ie,oe),B.bindTexture(B.TEXTURE_2D,N.sceneTex);try{B.texImage2D(B.TEXTURE_2D,0,B.RGBA,B.RGBA,B.UNSIGNED_BYTE,R)}catch{return}var ye=Er.FIELD_OPTS,ce=ye.w,L=ye.h,ee=Q();B.bindTexture(B.TEXTURE_2D,N.fieldTex),B.texImage2D(B.TEXTURE_2D,0,B.R8,ce,L,0,B.RED,B.UNSIGNED_BYTE,ee),B.useProgram(N.prog);var X=B.getAttribLocation(N.prog,"aPosition");B.bindBuffer(B.ARRAY_BUFFER,N.quadBuf),B.enableVertexAttribArray(X),B.vertexAttribPointer(X,2,B.FLOAT,!1,0,0),B.uniform2f(B.getUniformLocation(N.prog,"uResolution"),ie,oe),B.uniform1f(B.getUniformLocation(N.prog,"uTime"),J),B.activeTexture(B.TEXTURE0),B.bindTexture(B.TEXTURE_2D,N.sceneTex),B.uniform1i(B.getUniformLocation(N.prog,"uScene"),0),B.activeTexture(B.TEXTURE1),B.bindTexture(B.TEXTURE_2D,N.fieldTex),B.uniform1i(B.getUniformLocation(N.prog,"uField"),1),B.drawArrays(B.TRIANGLE_STRIP,0,4);var te=R.getContext("2d");te&&te.drawImage(N.offscreen,0,0,ie,oe,0,0,$,pe)}}o(H,"_runFilter");var V={init:o(function(C){Wi("p5Provider.init",C&&C.width,C&&C.height),e=C.width,t=C.height;var J=Bo("p5Provider.init",C.parentEl);return l=createCanvas(i(),n()),l.parent(J),s=!0,j()},"init"),renderTick:o(function(C,J,R){f=C;var K=!R||R.renderBaseCanvas!==!1;u=K,T(C,J,K,R);var N=a.length>0?Wo(C):null;h=N;for(var B=0;B<a.length;B++)H(a[B],N)},"renderTick"),filter:o(function(C,J){if(C){if(C.name){for(var R=0;R<a.length;R++)if(a[R].name===C.name){J&&(a[R]._perFilterOptions=J);return}}var K=C;J&&(K=Object.assign({},C),K._perFilterOptions=J),a.push(K)}},"filter"),removeFilter:o(function(C){var J=typeof C=="string"?C:C&&C.name;a=a.filter(function(R){return R.name!==J}),J&&c[J]&&delete c[J]},"removeFilter"),setSize:o(function(C,J){Wi("p5Provider.setSize",C,J),e=C,t=J,s&&typeof resizeCanvas=="function"&&resizeCanvas(C,J),y()},"setSize"),start:o(function(){},"start"),stop:o(function(){},"stop"),destroy:o(function(){l&&l.remove&&l.remove(),s=!1,a=[],c={},f=null,h=null},"destroy"),raw:o(function(){return l},"raw"),renderCapabilities:ep,screenToWorld:o(function(C,J,R,K){return Jh(d(),i(),n(),C,J,R||i(),K||n())},"screenToWorld"),getCameraControl:o(function(){var C=Qh;function J(N,B,ie){if(typeof N=="number"&&isFinite(N))return N;throw new Error("p5-provider camera "+ie+": "+B+" must be a finite number, got "+String(N)+" \u2014 throw-or-apply, never a silent clamp.")}o(J,"_finite");function R(){return C.PRESETS_2D(i(),n())}o(R,"_presets");var K={presets:Object.keys(R()),poseFields:C.POSE_FIELDS_2D(i(),n()),setOrbit:o(function(N){if(N){N=ko(N);var B=d();if(N.distance!==void 0){var ie=J(N.distance,"distance","setOrbit");if(ie<=0)throw new Error("p5-provider camera setOrbit: distance is the VISIBLE HEIGHT in physics px and must be > 0, got "+ie+". (FAIL-LOUD.)");B.distance=ie}if("target"in N){var oe=N.target;B.target=oe?{x:oe.x,y:oe.y}:null}for(var $=Zs,pe=0;pe<$.length;pe++)if(N[$[pe]]!==void 0)throw new Error('p5-provider camera setOrbit: this camera declares no "'+$[pe]+'" axis (2D pose is {distance, target}). Check cameraControl.poseFields rather than assuming a mode. (FAIL-LOUD.)');y()}},"setOrbit"),getOrbit:o(function(){return m()},"getOrbit"),addPoseListener:o(function(N){return b||(b=Ao()),b.add(N)},"addPoseListener"),setPreset:o(function(N){var B=R(),ie=B[N];if(!ie)throw new Error('[p5-provider camera] setPreset("'+N+'"): this camera offers only ['+Object.keys(B).join(", ")+"] (ctl.presets). (FAIL-LOUD.)");K.setOrbit(ie)},"setPreset")};return K},"getCameraControl"),projection:o(function(){return{kind:"affine2d"}},"projection"),captureStill:o(function(){var C=as,J=C.captureFrom2dCanvas(j(),{cssWidth:i(),cssHeight:n(),physicsW:i(),physicsH:n(),filtersApplied:a.map(function(R){return R.name}),renderBaseCanvas:u,filterTime:h,composited:f});return Promise.resolve(J)},"captureStill"),get initialized(){return s}};return V}o(Dg,"makeP5Provider");Va();Un();Fi();var us={};ge(us,{GODRAY_SOURCES:()=>ls,GODRAY_SOURCE_DEFAULT:()=>cs,fundamentalLayerOf:()=>Lg,godraySourceFrames:()=>Fg,isGodraySource:()=>Pg,makeGodrayPasses:()=>sx,resolveGodraySource:()=>Ig});function Lg(e){var t=e&&e.dimensionData,r=null;if(t)for(var i=0;i<t.length;i++){var n=t[i]&&t[i].layer;typeof n=="number"&&(r===null||n<r)&&(r=n)}if(r===null&&e&&e.frameData&&e.frameData.length)throw new Error("GodraysLayer: tickData carries "+e.frameData.length+" frames but no dimensionData[].layer, so the fundamental layer the god-rays are computed from cannot be named.");return r}o(Lg,"fundamentalLayerOf");function Pg(e,t){return t!==null&&e===t}o(Pg,"isGodraySource");var ls=["leaf","all"],cs="leaf";function Ig(e){if(e==null)return cs;if(ls.indexOf(e)===-1)throw new Error("GodraysLayer: godraySource "+JSON.stringify(e)+" is not one of ["+ls.join(", ")+"] (default "+JSON.stringify(cs)+").");return e}o(Ig,"resolveGodraySource");function Fg(e,t){var r=e&&e.frameData||[];if(Ig(t)==="all")return r.slice();for(var i=Lg(e),n=[],a=0;a<r.length;a++)Pg(r[a].layer,i)&&n.push(r[a]);return n}o(Fg,"godraySourceFrames");var ax=["uniform sampler2D uScene;","uniform vec2 uLightPos;","uniform float uDecay;","uniform float uDensity;","uniform float uWeight;","uniform float uExposure;","varying vec2 vTexCoord;","const int SAMPLES = 50;","void main() {"," vec2 tc = vTexCoord;"," vec2 delta = (tc - uLightPos) * (1.0 / float(SAMPLES)) * uDensity;"," vec3 rays = vec3(0.0);"," float decay = 1.0;"," for (int i = 0; i < SAMPLES; i++) {"," tc -= delta;"," vec3 s = texture2D(uScene, tc).rgb;"," rays += s * decay * uWeight;"," decay *= uDecay;"," }"," gl_FragColor = vec4(rays * uExposure, 1.0);","}"].join(`
|
|
10
|
+
`),ox=["uniform sampler2D uScene;","uniform sampler2D uRays;","uniform float uIntensity;","varying vec2 vTexCoord;","void main() {"," vec3 scene = texture2D(uScene, vTexCoord).rgb;"," vec3 rays = texture2D(uRays, vTexCoord).rgb;"," gl_FragColor = vec4(scene + rays * uIntensity, 1.0);","}"].join(`
|
|
11
|
+
`);function sx(e,t,r,i){var n=new e.Scene,a=new e.Mesh(new e.PlaneGeometry(2,2),null);n.add(a);var s=new e.Vector3,l=new e.ShaderMaterial({uniforms:{uScene:{value:null},uLightPos:{value:new e.Vector2(.5,.5)},uDecay:{value:.95},uDensity:{value:.8},uWeight:{value:.4},uExposure:{value:.35}},vertexShader:t,fragmentShader:ax,depthWrite:!1,depthTest:!1}),c=new e.ShaderMaterial({uniforms:{uScene:{value:null},uRays:{value:null},uIntensity:{value:1}},vertexShader:t,fragmentShader:ox,depthWrite:!1,depthTest:!1}),f={rtSource:new e.WebGLRenderTarget(r,i),setSize:o(function(u,h){f.rtSource.setSize(u,h)},"setSize"),lightUV:o(function(u,h,g){for(var d=Fg(u,g),m=0,b=0,y=0,w=0,x=0;x<d.length;x++){var S=d[x],A=(S.fullness||0)+.05;m+=S.rect.x*A,b+=S.rect.y*A,y+=(S.z||0)*A,w+=A}return w<=0?new e.Vector2(.5,.5):(s.set(m/w,b/w,y/w).project(h),new e.Vector2(s.x*.5+.5,s.y*.5+.5))},"lightUV"),march:o(function(u,h,g,d,m,b,y,w){l.uniforms.uScene.value=d.texture,l.uniforms.uLightPos.value.copy(b),typeof y=="number"&&(l.uniforms.uDensity.value=y),a.material=l,u.setRenderTarget(m),u.render(n,h),c.uniforms.uScene.value=g.texture,c.uniforms.uRays.value=m.texture,c.uniforms.uIntensity.value=w,a.material=c,u.setRenderTarget(null),u.render(n,h)},"march")};return f}o(sx,"makeGodrayPasses");Ba();Da();Ea();Fi();var gn="render.mesh",Ng=or;if(Ng.RENDER_INTENT_KEYS.indexOf(gn)===-1)throw new Error('RenderMesh: "'+gn+'" is not a declared render-intent key in lib/shim/frame-data RENDER_INTENT_KEYS \u2014 the open-id key set must be owned there.');if(Ng.RENDER_INTENT_VALUES[gn]!==void 0)throw new Error('RenderMesh: "'+gn+'" must be OPEN-ID (no RENDER_INTENT_VALUES entry) \u2014 an asset id is a free string validated at load time by the renderer, not an enum.');function Mg(e,t){var r=e&&e.data&&e.data.string_map;return r&&typeof r[gn]=="string"&&r[gn].length>0?r[gn]:e&&typeof e.mesh=="string"&&e.mesh.length>0?e.mesh:t&&typeof t.mesh=="string"&&t.mesh.length>0?t.mesh:null}o(Mg,"resolve");function lx(e,t){return Mg(e,t)!==null}o(lx,"hasMesh");var $a={KEY:gn,resolve:Mg,hasMesh:lx};function cx(e,t,r){if(r){var i=$a.resolve(e,t);if(i)return{family:"mesh",assetId:i,key:"mesh:"+i}}var n=ai.resolve(e,t);if(r&&ai.isCubeMesh(n))return{family:"cube",key:"cube"};if(r&&ai.isSphereMesh(n))return{family:"sphere",key:"sphere"};var a=ai.toUniform(n);return{family:"pts",uShapeVariant:a,key:"pts:"+a}}o(cx,"resolveRenderFamily");function ux(e){return e&&e.key?e.key:"pts:0"}o(ux,"familyKey");var Ug={resolveRenderFamily:cx,familyKey:ux};un();var tp={};ge(tp,{cameraPoseFields:()=>hx,cameraPresets:()=>fx});Un();function fx(e,t){var r=Math.max(e,t);return{"down-barrel":{azimuth:90,elevation:0,distance:r*.95},"table-top":{azimuth:0,elevation:0,distance:r*1.3},rooftop:{azimuth:45,elevation:45,distance:r*1.5}}}o(fx,"cameraPresets");function hx(e,t){var r=zi,i=Math.max(e,t);return[r({name:"azimuth",label:"az",type:"number",unit:"deg",default:0,constraint:{min:-180,max:180,integer:!1,wrap:360},widgetConfig:{step:1},description:"Orbit angle around the vertical axis, in degrees. az=0 looks straight at the x/y plane from +z; az=+90 puts the camera on +x looking back along it."}),r({name:"elevation",label:"el",type:"number",unit:"deg",default:0,constraint:{min:-90,max:90,integer:!1},widgetConfig:{step:1},description:"Orbit angle above (+) / below (\u2212) the horizontal, in degrees. \xB190 is straight down / straight up the vertical axis."}),r({name:"distance",label:"dist",type:"number",unit:"px",default:i*1.6,constraint:{min:Math.round(i/3),max:i*4,integer:!1},widgetConfig:{step:Math.max(1,Math.round(i/30))},description:"Camera distance from the orbit centre, in engine pixels. Bounds are relative to the scene size (base = max(width,height)) so the slider frames any scene."}),r({name:"roll",label:"roll",type:"number",unit:"deg",default:0,constraint:{min:-180,max:180,integer:!1,wrap:360},widgetConfig:{step:1},description:"Rotation about the view axis \u2014 the horizon tilt, in degrees. It spins the picture in the screen plane without moving the eye: roll=90 puts what was screen-vertical onto the screen horizontal. Unlike elevation it has NO pole, so the range is a WRAP point (mod 360), never a clamp."}),r({name:"target",label:"centre",type:"object",unit:"px",default:null,description:"The world point {x,y,z} the orbit revolves around; null = the scene centre. Pan/track IS target \u2014 the same key the 2D camera uses."})]}o(hx,"cameraPoseFields");var fp={};ge(fp,{CAMERA_FOV_DEG:()=>hs,MIN_RAY_PLANE_COS:()=>zg,POLE_EPS:()=>ap,SANITY_EXTENT_FACTOR:()=>qg,UP_HINT:()=>np,_cameraOffsetFromWorld:()=>lp,_decomposeOrbitBasis:()=>Vg,_intersectRayWithZPlane:()=>Wg,_orbitCameraBasis:()=>ro,_orbitCenter:()=>ps,_orbitTranslate:()=>sp,_rayDirForNdc:()=>Bg,_rotateOrbit:()=>op,_screenToWorldThree:()=>up,_worldFromCameraOffset:()=>cp});var hs=50,zg=.05,qg=20,np={x:0,y:-1,z:0},ap=1e-9,to=Math.PI/180,uc=180/Math.PI;function fs(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}o(fs,"_cross");function ip(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}o(ip,"_dot");function fc(e){var t=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}o(fc,"_norm");function eo(e,t,r){var i=Math.cos(r),n=Math.sin(r),a=fs(t,e),s=ip(t,e)*(1-i);return{x:e.x*i+a.x*n+t.x*s,y:e.y*i+a.y*n+t.y*s,z:e.z*i+a.z*n+t.z*s}}o(eo,"_rotateAbout");function rp(e){var t=((e+180)%360+360)%360-180;return t===-180?180:t}o(rp,"_wrapDeg");function ps(e,t,r){var i=e&&e.target;return i&&typeof i.x=="number"&&typeof i.y=="number"&&typeof i.z=="number"?{x:i.x,y:i.y,z:i.z}:{x:t/2,y:r/2,z:0}}o(ps,"_orbitCenter");function ro(e,t,r){var i=ps(e,t,r),n=i.x,a=i.y,s=i.z,l=e.azimuth*to,c=e.elevation*to,f=e.distance,u=Math.cos(c),h=Math.sin(c),g={x:n+f*u*Math.sin(l),y:a+f*h,z:s+f*u*Math.cos(l)},d={x:-u*Math.sin(l),y:-h,z:-u*Math.cos(l)},m;Math.abs(u)<ap?m={x:-Math.cos(l),y:0,z:Math.sin(l)}:m=fc(fs(d,np));var b=fs(m,d),y=typeof e.roll=="number"?e.roll:0;if(y){var w=y*to;m=eo(m,d,w),b=eo(b,d,w)}return{pos:g,forward:d,right:m,up:b}}o(ro,"_orbitCameraBasis");function Vg(e){var t=e.forward,r=e.right,i=-t.y;i>1&&(i=1),i<-1&&(i=-1);var n=Math.asin(i)*uc,a=Math.sqrt(t.x*t.x+t.z*t.z);if(a<ap)return{azimuth:rp(Math.atan2(r.z,-r.x)*uc),elevation:n,roll:0};var s=Math.atan2(-t.x,-t.z)*uc,l=fc(fs(t,np)),c=fs(l,t),f=Math.atan2(-ip(r,c),ip(r,l))*uc;return{azimuth:rp(s),elevation:n,roll:rp(f)}}o(Vg,"_decomposeOrbitBasis");function op(e,t,r,i){var n=t&&typeof t.spin=="number"?t.spin:0,a=t&&typeof t.pitch=="number"?t.pitch:0,s=ro(e,r,i),l=s.forward,c=s.right,f=s.up;if(n){var u=n*to;c=eo(c,l,u),f=eo(f,l,u)}if(a){var h=a*to;l=eo(l,c,h),f=eo(f,c,h)}l=fc(l),c=fc(c);var g=Vg({forward:l,right:c,up:f});return{azimuth:g.azimuth,elevation:g.elevation,distance:e.distance,roll:g.roll,target:e.target||null}}o(op,"_rotateOrbit");function sp(e,t,r,i,n){var a=ps(e,t,r),s=ro(e,t,r);return{x:a.x+i*s.forward.x+n*s.right.x,y:a.y+i*s.forward.y+n*s.right.y,z:a.z+i*s.forward.z+n*s.right.z}}o(sp,"_orbitTranslate");function lp(e,t,r,i){if(!i)return null;var n=ro(e,t,r),a=i[0]-n.pos.x,s=i[1]-n.pos.y,l=i[2]-n.pos.z;return{right:a*n.right.x+s*n.right.y+l*n.right.z,up:a*n.up.x+s*n.up.y+l*n.up.z,forward:a*n.forward.x+s*n.forward.y+l*n.forward.z}}o(lp,"_cameraOffsetFromWorld");function cp(e,t,r,i){if(!i)return null;var n=ro(e,t,r),a=i.right||0,s=i.up||0,l=i.forward||0;return[n.pos.x+a*n.right.x+s*n.up.x+l*n.forward.x,n.pos.y+a*n.right.y+s*n.up.y+l*n.forward.y,n.pos.z+a*n.right.z+s*n.up.z+l*n.forward.z]}o(cp,"_worldFromCameraOffset");function Bg(e,t,r,i,n){var a=Math.tan(i*to/2),s=t*a*n,l=r*a,c=e.forward.x+s*e.right.x+l*e.up.x,f=e.forward.y+s*e.right.y+l*e.up.y,u=e.forward.z+s*e.right.z+l*e.up.z,h=Math.sqrt(c*c+f*f+u*u)||1;return{x:c/h,y:f/h,z:u/h}}o(Bg,"_rayDirForNdc");function Wg(e,t,r){if(Math.abs(t.z)<zg)return null;var i=(r-e.z)/t.z;return i<-1e-6?null:{x:e.x+t.x*i,y:e.y+t.y*i}}o(Wg,"_intersectRayWithZPlane");function up(e,t,r,i,n,a,s,l,c){var f=a||t,u=s||r,h=typeof c=="number"&&isFinite(c)&&c>0?c:hs,g=i/f*2-1,d=-(n/u*2-1),m=ro(e,t,r),b=Bg(m,g,d,h,t/r),y=Wg(m.pos,b,typeof l=="number"?l:0);if(!y)return null;var w=qg*Math.max(t,r,1);return!isFinite(y.x)||!isFinite(y.y)||Math.abs(y.x)>w||Math.abs(y.y)>w?null:y}o(up,"_screenToWorldThree");var px=["attribute float aFullness;","attribute vec3 aColor;","attribute float aAlpha;","attribute float aSize;","attribute float aSmoke;","uniform float uPersp;","uniform float uSmoke;","varying vec3 vColor;","varying float vAlpha;","varying float vFull;","varying float vSmoke;","void main() {"," vColor = aColor;"," vAlpha = aAlpha;"," vFull = aFullness;"," vSmoke = aSmoke;"," vec4 mv = modelViewMatrix * vec4(position, 1.0);"," float size;"," if (uSmoke > 0.0 && aSmoke > 0.5) {"," float world = max(2.0, aSize * uSmoke);"," size = mix(world, world * (800.0 / max(1.0, -mv.z)), uPersp);"," } else {"," float base = max(2.0, aSize);"," size = mix(base, base * (800.0 / max(1.0, -mv.z)), uPersp);"," }"," gl_PointSize = size;"," gl_Position = projectionMatrix * mv;","}"].join(`
|
|
12
|
+
`),dx=["uniform float uIntensity;","uniform float uHeat;","uniform float uSmoke;","uniform float uShape;","varying vec3 vColor;","varying float vAlpha;","varying float vFull;","varying float vSmoke;","void main() {"," vec2 c = gl_PointCoord - 0.5;"," if (uShape > 0.5) {"," float e = max(abs(c.x), abs(c.y)) * 2.0;"," if (e > 1.0) discard;"," float rim = smoothstep(0.80, 1.0, e);"," vec3 bcol = mix(vColor, vColor + vec3(0.55, 0.18, -0.25) * vFull, uHeat);"," bcol = mix(bcol, vec3(1.0), rim * 0.6);"," float ba = clamp(vAlpha, 0.15, 1.0) * uIntensity;"," gl_FragColor = vec4(bcol * ba, ba);"," return;"," }"," float d = length(c) * 2.0;"," float glow = smoothstep(1.0, 0.0, d);"," if (uSmoke > 0.0 && vSmoke > 0.5) { glow = pow(glow, 0.6) * 0.5; }"," float a = glow * vAlpha * uIntensity;"," vec3 col = mix(vColor, vColor + vec3(0.55, 0.18, -0.25) * vFull, uHeat);"," gl_FragColor = vec4(col * a, a);","}"].join(`
|
|
13
|
+
`),Gg=["varying vec2 vTexCoord;","void main() {"," vTexCoord = uv;"," gl_Position = vec4(position, 1.0);","}"].join(`
|
|
14
|
+
`),hc=[.92,.72,1,.6,.86,.78];function Hg(e){return{color:e&&e.color||[200,200,200],alpha:e&&e.alpha!==void 0?e.alpha/255:1}}o(Hg,"loSkin");function mx(e){var t=Hg(e);return t.color.join(",")+"|"+t.alpha}o(mx,"loSkinSig");function gx(e,t){for(var r=Hg(t),i=Array.isArray(e)?e:[e],n=i.length===hc.length,a=0;a<i.length;a++){var s=i[a];if(s){var l=n?hc[a]:1;!s.map&&s.color&&typeof s.color.setRGB=="function"&&s.color.setRGB(r.color[0]/255*l,r.color[1]/255*l,r.color[2]/255*l);var c=s.map?!0:r.alpha<1;s.transparent!==c&&(s.transparent=c,s.needsUpdate=!0),s.opacity=r.alpha,s.depthWrite=r.alpha>=1}}return r}o(gx,"applyLoSkin");function hp(){var e=zi,t=ai,r=or,i=Za,n=os,a=n.universalRenderCapabilities(e,t,r).concat([e({name:"godrays",type:"number",unit:"intensity",default:0,constraint:{min:0,max:3,integer:!1},description:"God-rays post-process composite intensity (three-only final-composite layer)."}),e({name:"godrayDensity",type:"number",unit:"density",default:.8,constraint:{min:.2,max:1.5,integer:!1},description:"God-rays radial-blur density/spread (only consulted when godrays > 0)."}),e({name:"godraySource",type:"enum",default:cs,constraint:{values:ls.reduce(function(s,l){return s[l]=l,s},{})},description:"What the god-rays are computed from: 'leaf' = the fundamental-layer frames (LOs only occlude), 'all' = the whole lit scene (every frame of every layer and every LO)."}),e({name:"glowIntensity",type:"number",unit:"intensity",default:0,constraint:{min:0,max:3,integer:!1},description:"Per-dim glow-layer intensity multiplier (R4-GEO additive glow shading)."}),e({name:"heat",type:"number",unit:"0-1",default:0,constraint:{min:0,max:1,integer:!1},description:"Heat-ramp shift: warms dense-quanta color toward the hot end of the scheme."}),e({name:"smoke",type:"number",unit:"intensity",default:0,constraint:{min:0,max:16,integer:!1},description:"Smoke-puff layer intensity (per-dim greyscale+soft paint gate)."})]).concat(n.meshRenderCapabilities(e)).concat(n.filterRenderCapabilities(e,i));return a}o(hp,"_renderCapabilitiesThree");function Kg(e){var t=Mf(),r=null,i=null;function n(){return new Error("threeProvider: the physics rect was read before init({width, height}) or setSize(w, h) stated it. FrqtlApp.createCanvas hands the runner's canvas_rect to provider.init \u2014 the provider has no default size.")}o(n,"_unsized");function a(){if(r===null)throw n();return r}o(a,"_physW");function s(){if(i===null)throw n();return i}o(s,"_physH");var l=null,c=null,f=null,u=null,h=!!(e&&e.is3D),g=null,d=0,m={azimuth:0,elevation:0,distance:0,roll:0,target:null};function b(){if(h){if(f){var E=fp,I=E._orbitCenter(m,a(),s()),z=E._orbitCameraBasis(m,a(),s());f.position.set(z.pos.x,z.pos.y,z.pos.z),f.up.set(z.up.x,z.up.y,z.up.z),f.lookAt(I.x,I.y,I.z),f.updateProjectionMatrix()}w&&w.notify(y())}}o(b,"_applyOrbit");function y(){return{azimuth:m.azimuth,elevation:m.elevation,distance:m.distance,roll:m.roll,target:m.target?{x:m.target.x,y:m.target.y,z:m.target.z}:null}}o(y,"_orbitBag");var w=null,x={},S=2048;function A(E){return{cap:E,posArr:new Float32Array(E*3),fullArr:new Float32Array(E),colArr:new Float32Array(E*3),alphaArr:new Float32Array(E),sizeArr:new Float32Array(E),smokeArr:new Float32Array(E)}}o(A,"_makeDimLayerBuffers");function T(E,I,z){var G=x[E];if(G)return G;if(z==="sphere"){var U=Ls(S);return U.visible=!1,c.add(U),G={isSphere:!0,mesh:U,capacity:S,centroid:{x:0,y:0,z:0}},x[E]=G,G}var fe=A(S),re=new t.BufferGeometry;re.setAttribute("position",new t.BufferAttribute(fe.posArr,3)),re.setAttribute("aFullness",new t.BufferAttribute(fe.fullArr,1)),re.setAttribute("aColor",new t.BufferAttribute(fe.colArr,3)),re.setAttribute("aAlpha",new t.BufferAttribute(fe.alphaArr,1)),re.setAttribute("aSize",new t.BufferAttribute(fe.sizeArr,1)),re.setAttribute("aSmoke",new t.BufferAttribute(fe.smokeArr,1)),re.setDrawRange(0,0);var Ge={uIntensity:{value:1},uHeat:{value:0},uSmoke:{value:0},uPersp:{value:h?1:0}};I||(Ge.uShape={value:d});var rt=new t.ShaderMaterial({vertexShader:px,fragmentShader:dx,transparent:!0,depthTest:!0,depthWrite:!1,uniforms:Ge});I&&(rt.blending=t.AdditiveBlending);var Ne=new t.Points(re,rt);return Ne.visible=!1,c.add(Ne),G={geo:re,mat:rt,mesh:Ne,isAdditive:I,bufs:fe,centroid:{x:0,y:0,z:0}},x[E]=G,G}o(T,"_ensureDimLayer");function j(E,I){if(E.isSphere){if(I<=E.capacity)return;for(var z=E.capacity;z<I;)z=z*2;var G=E.mesh,U=Ls(z);U.visible=G.visible,U.renderOrder=G.renderOrder,c.remove(G),G.dispose(),c.add(U),E.mesh=U,E.capacity=z;return}if(!(I<=E.bufs.cap)){for(var fe=E.bufs.cap;fe<I;)fe=fe*2;E.bufs=A(fe),E.geo.setAttribute("position",new t.BufferAttribute(E.bufs.posArr,3)),E.geo.setAttribute("aFullness",new t.BufferAttribute(E.bufs.fullArr,1)),E.geo.setAttribute("aColor",new t.BufferAttribute(E.bufs.colArr,3)),E.geo.setAttribute("aAlpha",new t.BufferAttribute(E.bufs.alphaArr,1)),E.geo.setAttribute("aSize",new t.BufferAttribute(E.bufs.sizeArr,1)),E.geo.setAttribute("aSmoke",new t.BufferAttribute(E.bufs.smokeArr,1))}}o(j,"_growDimLayerIfNeeded");function Q(){for(var E in x)x.hasOwnProperty(E)&&(x[E].mesh.visible=!1)}o(Q,"_hideAllDimLayers");function Y(E){var I=E.x-f.position.x,z=E.y-f.position.y,G=E.z-f.position.z;return I*I+z*z+G*G}o(Y,"_camDistSq");var H=new Map,V=null,C=null,J=0,R=null,K=null,N=null,B=null,ie=null,oe=null,$=null,pe=null,ye=null,ce=null,L=null,ee=null,X=null,te=null,be=null,Oe=null,Ue=null,Ce={},xe=null,Ve={},Ot=0,Wt=0,zt=null,se=null,ve=null,Lt=null,ct=null,Kt=null,Et={},ut=[],ot=null,Qr=0,Yt=!1,hr=null,_n=null,xn=null,pr=null;function tr(E){Wi("threeProvider.init",E&&E.width,E&&E.height);var I=Bo("threeProvider.init",E.parentEl);r=E.width,i=E.height,h=!!(E&&E.is3D),g=E&&E.depth!==void 0?E.depth:null,l=new t.WebGLRenderer({antialias:!1,alpha:!1}),l.setSize(a(),s()),l.setPixelRatio(1),u=l.domElement,I.appendChild(u),h?(f=new t.PerspectiveCamera(hs,a()/s(),.1,1e5),m.distance=Math.max(a(),s())*1.6,b()):f=new t.OrthographicCamera(0,a(),s(),0,-1,1),c=new t.Scene,c.background=new t.Color(0);var z=new t.AmbientLight(16777215,.45);c.add(z);var G=new t.DirectionalLight(16777215,.9);G.position.set(1.2,-2,2.5).normalize(),c.add(G),R=new t.Matrix4,K=new t.Color,ee=new t.Matrix4,X=new t.Vector3,te=new t.Quaternion,be=new t.Vector3,Oe=new t.Color;var U=Er.FIELD_OPTS;Ot=U.w,Wt=U.h,se=new Uint8Array(Ot*Wt),zt=new t.DataTexture(se,Ot,Wt,t.RedFormat,t.UnsignedByteType),zt.minFilter=t.LinearFilter,zt.magFilter=t.LinearFilter,zt.needsUpdate=!0,ve=new t.WebGLRenderTarget(a(),s()),Lt=new t.WebGLRenderTarget(a(),s()),ct=new t.Scene,Kt=new t.OrthographicCamera(-1,1,1,-1,0,1),Yt=!0}o(tr,"_init");function fo(E,I){var z=$a.resolve(E,I),G=z&&Ce[z]?Ce[z].status:"";return[E.shape||(E.drawAsCircle?"c":"r"),E.rect.w,E.rect.h,E.depth||"",E.rect.d||"",E.shellShape||"",E.renderHint||"",E.sprite||"",E.liveCanvas?"L":"",E.renderHint?(E.color||[]).join("-"):"",z||"",G,E.meshScale||"",(E.meshRotation||[]).join("|")].join(",")}o(fo,"_loSig");function ua(E){var I=E&&E.liveCanvas;if(!I)return null;try{var z=typeof I=="function"?I():I;return z||null}catch{return null}}o(ua,"_resolveLiveCanvas");var fa=[{uAxis:"z",uDir:-1,vAxis:"y",vDir:1},{uAxis:"z",uDir:1,vAxis:"y",vDir:1},{uAxis:"x",uDir:1,vAxis:"z",vDir:-1},{uAxis:"x",uDir:1,vAxis:"z",vDir:1},{uAxis:"x",uDir:1,vAxis:"y",vDir:1},{uAxis:"x",uDir:-1,vAxis:"y",vDir:1}];function ho(E,I,z){return z>0?E<=I&&E<=z?{axis:"x",faces:[0,1]}:I<=E&&I<=z?{axis:"y",faces:[2,3]}:{axis:"z",faces:[4,5]}:{axis:"z",faces:[4,5]}}o(ho,"_thinAxisFaces");function fi(E,I){var z=typeof E=="string"?new t.TextureLoader().load(E):new t.CanvasTexture(E);return z.minFilter=t.LinearFilter,z.flipY=!1,I&&I.mirrorU&&(z.wrapS=t.RepeatWrapping,z.repeat.x=-1,z.offset.x=1),I&&I.mirrorV&&(z.wrapT=t.RepeatWrapping,z.repeat.y=-1,z.offset.y=1),z}o(fi,"_makeWorldTexture");function Ci(E,I,z){return new t.MeshBasicMaterial({map:E,transparent:!0,opacity:I,depthWrite:z,side:t.DoubleSide})}o(Ci,"_worldPlaneMaterial");function Fr(E){var I=fa[E]||fa[4];return{mirrorU:I.uDir<0,mirrorV:I.vDir<0}}o(Fr,"_liveFaceTransform");function po(E,I){var z=E.alpha!==void 0?E.alpha/255:1,G=z>=1,U=$a.resolve(E,I);if(U){go(U);var fe=Ce[U];if(fe&&fe.status==="ready"&&fe.scene){var re=fe.scene.clone(!0);re.frustumCulled=!1;var Ge=Math.max(E.rect.w,E.rect.h,E.depth||0)||E.rect.w,rt=typeof E.meshScale=="number"&&E.meshScale>0?E.meshScale:1;return re.scale.setScalar(Ge*fe.norm*rt),E.meshRotation&&re.rotation.set(E.meshRotation[0]||0,E.meshRotation[1]||0,E.meshRotation[2]||0),re}return new t.Group}if(E.liveCanvas){var Ne=ua(E),Fe=E.depth!==void 0&&E.depth>0?E.depth:E.rect.d!==void 0&&E.rect.d>0?E.rect.d:0,it=E.color||[30,40,55],He,Pe;if(Fe>0){var kt=ho(E.rect.w,E.rect.h,Fe),Ie=new t.BoxGeometry(E.rect.w,E.rect.h,Fe);Pe=[];var nt=hc.map(function(Qt,di){var Sn=kt.faces.indexOf(di)!==-1;if(Sn&&Ne){var Rr=Fr(di);return Pe.push({index:di,mirrorU:Rr.mirrorU,mirrorV:Rr.mirrorV}),new t.MeshBasicMaterial({map:fi(Ne,Rr),transparent:!0,opacity:z,depthWrite:G})}return new t.MeshBasicMaterial({color:new t.Color(it[0]/255*Qt,it[1]/255*Qt,it[2]/255*Qt),transparent:z<1,opacity:z,depthWrite:G})});Ne||(Pe=kt.faces.map(function(Qt){var di=Fr(Qt);return{index:Qt,mirrorU:di.mirrorU,mirrorV:di.mirrorV}})),He=new t.Mesh(Ie,nt),He.add(new t.LineSegments(new t.EdgesGeometry(Ie),new t.LineBasicMaterial({color:16777215,transparent:!0,opacity:.35})))}else{var St=new t.PlaneGeometry(E.rect.w,E.rect.h),dr=Fr(4);Pe=[{index:-1,mirrorU:dr.mirrorU,mirrorV:dr.mirrorV}];var Jt;Ne?Jt=Ci(fi(Ne,dr),z,G):Jt=new t.MeshBasicMaterial({color:new t.Color(it[0]/255,it[1]/255,it[2]/255),transparent:z<1,opacity:z,depthWrite:G,side:t.DoubleSide}),He=new t.Mesh(St,Jt)}return He.userData=He.userData||{},He.userData.liveCanvasSrc=Ne||null,He.userData.liveCanvasFaces=Pe,He}var jt=typeof E.shellShape=="string"&&E.shellShape?E.shellShape:null,pi=E.shape==="box"||jt==="box"||jt==="cube"||E.shape===void 0&&jt===null&&E.rect.d!==void 0&&E.rect.d>0;if(pi){var Nr=E.depth!==void 0?E.depth:E.rect.d!==void 0?E.rect.d:E.rect.w,Xr=new t.BoxGeometry(E.rect.w,E.rect.h,Nr),mr=E.color||[200,200,200],jr=hc.map(function(Qt){return new t.MeshBasicMaterial({color:new t.Color(mr[0]/255*Qt,mr[1]/255*Qt,mr[2]/255*Qt),transparent:z<1,opacity:z,depthWrite:G})}),Mr=new t.Mesh(Xr,jr);return Mr.add(new t.LineSegments(new t.EdgesGeometry(Xr),new t.LineBasicMaterial({color:16777215,transparent:!0,opacity:.35}))),Mr}var gt=jt?jt!=="box"&&jt!=="cube"&&jt!=="sphere":!!E.drawAsCircle,ji=jt==="sphere"?new t.SphereGeometry(E.rect.w/2,24,16):gt?new t.CircleGeometry(E.rect.w/2,32):new t.PlaneGeometry(E.rect.w,E.rect.h),Ur;if(E.sprite||E.renderHint){var En=E.sprite?fi(E.sprite,Fr(4)):Kc(E.renderHint,E.color);Ur=Ci(En,z,G)}else Ur=new t.MeshBasicMaterial({color:new t.Color(E.color[0]/255,E.color[1]/255,E.color[2]/255),transparent:z<1,opacity:z,depthWrite:G});return new t.Mesh(ji,Ur)}o(po,"_buildLoMesh");var hi={};function Kc(E,I){var z=E+"|"+(I?I.join(","):"");if(hi[z])return hi[z];var G=document.createElement("canvas");G.width=256,G.height=256;var U=G.getContext("2d");if(E==="gun"){var fe="rgb("+(I?I.join(","):"46,46,52")+")";U.clearRect(0,0,256,256),U.fillStyle=fe,U.fillRect(40,96,120,56),U.fillRect(150,110,86,26),U.save(),U.translate(70,150),U.rotate(.35),U.fillRect(0,0,34,80),U.restore(),U.fillStyle="rgba(150,160,180,0.55)",U.fillRect(40,96,196,8);var re=U.createRadialGradient(236,123,2,236,123,26);re.addColorStop(0,"rgba(255,230,150,0.95)"),re.addColorStop(1,"rgba(255,180,60,0)"),U.fillStyle=re,U.beginPath(),U.arc(236,123,26,0,Math.PI*2),U.fill()}else U.fillStyle="rgb("+(I?I.join(","):"60,60,70")+")",U.fillRect(0,0,256,256),U.strokeStyle="rgba(180,200,220,0.7)",U.lineWidth=6,U.strokeRect(8,8,240,240);var Ge=fi(G,Fr(4));return hi[z]=Ge,Ge}o(Kc,"_hintTexture");function Yc(E,I){var z=!C;if(!V||I>J){for(var G=J||4096;G<I;)G=G*2;V&&(c.remove(V),V.dispose()),(z||!C)&&(C&&C.dispose(),C=new t.BoxGeometry(E,E,E));var U=new t.MeshLambertMaterial({});V=new t.InstancedMesh(C,U,G),V.instanceMatrix.setUsage(t.DynamicDrawUsage),V.instanceColor=new t.InstancedBufferAttribute(new Float32Array(G*3).fill(1),3),V.instanceColor.setUsage(t.DynamicDrawUsage),V.count=0,V.frustumCulled=!1,c.add(V),J=G}}o(Yc,"_ensureCubeMesh");function Ls(E){L||(L=new t.SphereGeometry(.5,8,6));var I=new t.MeshLambertMaterial({}),z=new t.InstancedMesh(L,I,E);return z.instanceMatrix.setUsage(t.DynamicDrawUsage),z.instanceColor=new t.InstancedBufferAttribute(new Float32Array(E*3).fill(1),3),z.instanceColor.setUsage(t.DynamicDrawUsage),z.count=0,z.frustumCulled=!1,z}o(Ls,"_buildSphereInstancedMesh");function mo(E){if(typeof document>"u")throw new Error(E);if(!document.getElementById("egpt-renderer-error")){var I=document.createElement("div");I.id="egpt-renderer-error",I.style.cssText="position:fixed;inset:0;background:#300;color:#fdd;font:14px monospace;padding:18px;white-space:pre-wrap;z-index:99999;overflow:auto;",I.textContent=`render.mesh FAIL-LOUD
|
|
15
15
|
|
|
16
|
-
`+E,document.body.appendChild(
|
|
17
|
-
`+String(U))})}}o(so,"_ensureMeshLoaded");function gs(E,P,z,G,U){_e||(_e=new t.Group,_e.frustumCulled=!1,u.add(_e));for(var fe=Ve[U]||(Ve[U]=[]),re=typeof G=="number"&&G>0?G:1,Be=z&&P?P.length:0,rt=0;rt<Be;rt++){var Ne=P[rt],Fe=fe[rt];Fe||(Fe=E.scene.clone(!0),Fe.frustumCulled=!1,fe[rt]=Fe,_e.add(Fe));var nt=Ne.data&&Ne.data.string_map,We=re;if(nt&&nt["render.meshScale"]!=null){var Ie=Number(nt["render.meshScale"]);!isNaN(Ie)&&Ie>0&&(We=Ie)}var kt=(Ne.rect&&Ne.rect.w?Ne.rect.w:1)*E.norm*We;if(Fe.scale.setScalar(kt),Fe.position.set(Ne.rect.x,Ne.rect.y,Ne.z||0),Fe.userData.frameLayer=Ne.layer,nt&&nt["render.meshRotation"]!=null){var Pe=String(nt["render.meshRotation"]).split(",").map(Number);Pe.length>=3&&Pe.every(function(xt){return!isNaN(xt)})?Fe.rotation.set(Pe[0],Pe[1],Pe[2]):Fe.rotation.set(0,0,0)}else Fe.rotation.set(0,0,0);Fe.visible=!0}for(var it=Be;it<fe.length;it++)fe[it]&&(fe[it].visible=!1);return Be>0&&_e&&(_e.visible=!0),Be}o(gs,"_layoutMeshClones");function vs(E){for(var P in Ve)if(Ve.hasOwnProperty(P)&&!(E&&E.indexOf(P)!==-1))for(var z=Ve[P],G=0;G<z.length;G++)z[G]&&(z[G].visible=!1)}o(vs,"_hideMeshClonesExcept");function wu(E,P){if(E){for(var z=new Set,G=0;G<E.length;G++){var U=E[G];z.add(U);var fe=no(U,P),re=H.get(U);if(!re||re.sig!==fe){re&&re.mesh&&u.remove(re.mesh);var Be=ao(U,P);re={mesh:Be,sig:fe,skinSig:null},H.set(U,re),u.add(Be)}var rt=q_(U);re.skinSig!==rt&&(re.mesh&&re.mesh.material&&B_(re.mesh.material,U),re.skinSig=rt);var Ne=ji(U.rect);re.mesh.position.set(Ne[0],Ne[1],Ne[2]);var Fe=typeof U.orientationDeg=="number"?(U.orientationDeg%360+360)%360:0,nt=typeof U.pitchDeg=="number"?U.pitchDeg:0;if(U.billboard||(re.mesh.rotation.order="ZYX",re.mesh.rotation.z=Fe*Math.PI/180,re.mesh.rotation.y=nt*Math.PI/180),U.billboard&&f&&re.mesh.quaternion.copy(f.quaternion),U.liveCanvas&&re.mesh&&re.mesh.material){for(var We=na(U),Ie=re.mesh.userData||(re.mesh.userData={}),kt=Ie.liveCanvasFaces||[{index:-1,mirrorU:!1,mirrorV:!1}],Pe=0;Pe<kt.length;Pe++){var it=kt[Pe],xt=it.index>=0&&Array.isArray(re.mesh.material)?re.mesh.material[it.index]:re.mesh.material;if(xt)if(We&&(Ie.liveCanvasSrc!==We||!xt.map)){if(xt.map)try{xt.map.dispose()}catch{}xt.map=cn(We,it),xt.color&&xt.color.setRGB(1,1,1),xt.transparent=!0,xt.needsUpdate=!0}else We&&xt.map&&(xt.map.needsUpdate=!0)}We&&(Ie.liveCanvasSrc=We)}re.mesh.visible=U.visible!==!1}H.forEach(function(hr,Yt){z.has(Yt)||(hr.mesh.visible=!1)})}}o(wu,"_syncLargeObjects");function _u(E){if(!(!E||!E.frameData||!se)){var P=Er.buildHeightField(E.frameData,Object.assign({},Er.FIELD_OPTS,{canvasW:a(),canvasH:s()}));se.set(P),Gt.needsUpdate=!0}}o(_u,"_updateFieldTex");function xu(E){var P=E.name||"filter";if(_t[P])return _t[P];var z=E.glsl,G=new t.ShaderMaterial({uniforms:{uScene:{value:ge.texture},uField:{value:Gt},uResolution:{value:new t.Vector2(a(),s())},uTime:{value:0}},vertexShader:Og,fragmentShader:z,transparent:!1,depthWrite:!1}),U=new t.Mesh(new t.PlaneGeometry(2,2),G);return ut.add(U),_t[P]=U,U}o(xu,"_ensureQuadMesh");function Ou(E,P){var z=E.name||"filter",G=xu(E);G.material.uniforms.uTime.value=P,G.material.uniforms.uResolution.value.set(a(),s()),l.setRenderTarget(ge),l.render(u,f),l.setRenderTarget(null),G.material.uniforms.uScene.value=ge.texture,G.material.uniforms.uField.value=Gt,l.render(ut,Ht)}o(Ou,"_applyFilter");function Eu(E){var P=Zo,z=P.fundamentalLayerOf(E),G=[],U=null,fe=[];function re(Ie){Ie&&Ie.visible&&(Ie.visible=!1,G.push(Ie))}o(re,"hide");for(var Be in O)O.hasOwnProperty(Be)&&!P.isGodraySource(O[Be].layer,z)&&re(O[Be].mesh);q&&q.visible&&(U=q.count,q.count=Yr);for(var rt in Ve)if(Ve.hasOwnProperty(rt))for(var Ne=Ve[rt],Fe=0;Fe<Ne.length;Fe++)Ne[Fe]&&!P.isGodraySource(Ne[Fe].userData.frameLayer,z)&&re(Ne[Fe]);H.forEach(function(Ie){Ie.mesh&&Ie.mesh.traverse(function(kt){for(var Pe=kt.material?Array.isArray(kt.material)?kt.material:[kt.material]:[],it=0;it<Pe.length;it++)Pe[it]&&Pe[it].colorWrite!==!1&&(Pe[it].colorWrite=!1,fe.push(Pe[it]))})}),l.setRenderTarget(ot.rtSource),l.render(u,f);for(var nt=0;nt<G.length;nt++)G[nt].visible=!0;U!==null&&(q.count=U);for(var We=0;We<fe.length;We++)fe[We].colorWrite=!0}o(Eu,"_renderGodraySource");function Su(E,P){var z=Zo,G=z.resolveGodraySource(E.godraySource)==="leaf";ot||(ot=z.makeGodrayPasses(t,Og,a(),s())),l.setRenderTarget(ge),l.render(u,f),G&&Eu(P),ot.march(l,Ht,ge,G?ot.rtSource:ge,jt,ot.lightUV(P,f,E.godraySource),E.godrayDensity,E.godrays)}o(Su,"_renderGodrays");var ku=16724991,aa=16755200,ys=3407769;function gi(E){var P=new t.BufferGeometry;return P.setAttribute("position",new t.BufferAttribute(new Float32Array(E),3)),P}o(gi,"_lineGeo");function Kn(E,P){var z=new t.LineSegments(E,new t.LineBasicMaterial({color:P,depthTest:!1,transparent:!0,opacity:1}));return z.renderOrder=9999,z.frustumCulled=!1,z}o(Kn,"_overlayLines");function oa(E,P,z){for(var G=[],U=0;U<P;U++){var fe=U/P*Math.PI*2,re=(U+1)/P*Math.PI*2;G.push(E*Math.cos(fe),E*Math.sin(fe),z||0,E*Math.cos(re),E*Math.sin(re),z||0)}return G}o(oa,"_circlePts");function bs(){var E=new t.BoxGeometry(1,1,1),P=o(function(){return new t.MeshBasicMaterial({color:0,transparent:!0,opacity:.38,depthTest:!1,depthWrite:!1,side:t.DoubleSide})},"dark"),z=new t.Mesh(E,P());z.add(Kn(new t.EdgesGeometry(E),aa));var G=new t.Mesh(new t.CircleGeometry(1,48),P());return G.add(Kn(gi(oa(1,48)),aa)),[z,G].forEach(function(U){U.renderOrder=9997,U.frustumCulled=!1,U.visible=!1,ue.add(U)}),{box:z,disc:G}}o(bs,"_makeSurround");function lo(E,P,z){var G=P.center;if(P.kind==="sphere"){var U=P.radius+z;return E.disc.position.set(G[0],G[1],G[2]),E.disc.quaternion.copy(f.quaternion),E.disc.scale.setScalar(U),E.disc.visible=!0,E.box.visible=!1,U}return E.box.position.set(G[0],G[1],G[2]),E.box.rotation.order="ZYX",E.box.rotation.z=(P.yawDeg||0)*Math.PI/180,E.box.rotation.y=(P.pitchDeg||0)*Math.PI/180,E.box.scale.set(2*(P.half[0]+z),2*(P.half[1]+z),2*(P.half[2]+z)),E.box.visible=!0,E.disc.visible=!1,Math.hypot(P.half[0],P.half[1],P.half[2])+z}o(lo,"_placeSurround");function sa(E){E&&(E.box.visible=!1,E.disc.visible=!1)}o(sa,"_hideSurround");function Au(E){var P=E&&E.aimFeedback;if(!h||!P||!P.bounds){N&&(N.visible=!1),ne&&(ne.visible=!1),oe&&(oe.visible=!1),$&&($.visible=!1),sa(de),sa(ve);return}ue||(ue=new t.Scene);var z=P.bounds.width,G=P.bounds.height,U=P.bounds.zHalf,fe=z+"x"+G+"x"+U,re=Math.max(4,Math.min(z,G)*.06);if(!N||B!==fe){[N,ne,oe,$].forEach(function(An){An&&(ue.remove(An),An.geometry.dispose())});var Be=new t.BoxGeometry(z,G,Math.max(1,2*U));N=new t.LineSegments(new t.EdgesGeometry(Be),new t.LineBasicMaterial({color:6737151,transparent:!0,opacity:.5,depthTest:!1})),N.renderOrder=9998,N.frustumCulled=!1,ue.add(N),Be.dispose();var rt=re*.25;ne=Kn(gi([-re,0,0,-rt,0,0,rt,0,0,re,0,0,0,-re,0,0,-rt,0,0,rt,0,0,re,0].concat(oa(re*.55,32))),ku),ue.add(ne);var Ne=re*1.6,Fe=Ne*1.35,nt=Ne*.22;oe=Kn(gi(oa(Ne,48).concat([0,0,0,Fe,0,0,Fe,0,0,Fe-nt,nt*.6,0,Fe,0,0,Fe-nt,-nt*.6,0])),aa),ue.add(oe);for(var We=re*.45,Ie=re*.4,kt=[-We,-Ie,0,We,-Ie,0,We,-Ie,0,We,Ie*.4,0,We,Ie*.4,0,-We,Ie*.4,0,-We,Ie*.4,0,-We,-Ie,0],Pe=We*.62,it=0;it<12;it++){var xt=it/12*Math.PI,hr=(it+1)/12*Math.PI;kt.push(Pe*Math.cos(xt),Ie*.4+Pe*.3+Pe*Math.sin(xt),0,Pe*Math.cos(hr),Ie*.4+Pe*.3+Pe*Math.sin(hr),0)}kt.push(Pe,Ie*.4,0,Pe,Ie*.4+Pe*.3,0,-Pe,Ie*.4,0,-Pe,Ie*.4+Pe*.3,0),$=Kn(gi(kt),ys),ue.add($),de||(de=bs(),ve=bs()),B=fe}N.position.set(z/2,G/2,0),N.visible=!0;var Yt=Math.max(a(),s())*1.6,Tt=Yt>0&&m.distance>0?m.distance/Yt:1,hn=ts(m,a(),s());ne.position.set(hn.x,hn.y,hn.z),ne.quaternion.copy(f.quaternion),ne.scale.setScalar(Tt),ne.visible=!0;var Pr=4*Tt,Jr=P.hover?lo(de,P.hover.volume,Pr):0;if(P.hover||sa(de),P.selected&&!(P.hover&&P.hover.name===P.selected.name)?lo(ve,P.selected.volume,Pr):sa(ve),P.grabbed&&P.hover){var dr=P.hover.volume.center,Cr=f.up,Fr=Jr+re*.8*Tt;$.position.set(dr[0]+Cr.x*Fr,dr[1]+Cr.y*Fr,dr[2]+Cr.z*Fr),$.quaternion.copy(f.quaternion),$.scale.setScalar(Tt),$.visible=!0}else $.visible=!1;var gt=P.orientation;gt&>.pivot&&(oe.position.set(gt.pivot[0],gt.pivot[1],gt.pivot[2]!=null?gt.pivot[2]:0),oe.rotation.z=(gt.deg||0)*Math.PI/180,oe.scale.setScalar(Tt)),oe.visible=!!(gt&>.pivot)}o(Au,"_updateAimFeedback");function ws(){if(!(!ue||!N||!N.visible)){var E=l.autoClear;l.autoClear=!1,l.setRenderTarget(null),l.render(ue,f),l.autoClear=E}}o(ws,"_renderAimFeedbackPass");function uo(E,P,z){if(Kt){cr=E,Au(z||{}),wu(P,z||{});var G=z||{},U=G.renderBaseCanvas!==!1;pi=Object.assign({},G),mi=U;var fe=ct.length>0,re=G.glowIntensity,Be=xn,rt=nn,Ne=rt.resolve(null,G),Fe=h?Ha.resolve(null,G):null,nt=!!Fe,We=!nt&&h&&rt.isCubeMesh(Ne);if(!nt&&_e&&(_e.visible=!1),nt){Q(),q&&(q.visible=!1),so(Fe);var Ie=Ce[Fe],kt=0;Ie&&Ie.status==="ready"&&(kt=gs(Ie,E.frameData,G.renderBaseCanvas!==!1,G.meshScale,Fe)),vs([Fe]),_e&&(_e.visible=kt>0)}else if(We)if(Q(),U&&E&&E.frameData){for(var Pe=E.frameData,it=Pe.length,xt=G.colorScheme||"warmcool",hr=64,Yt=0;Yt<it;Yt++)if(Pe[Yt].rect&&Pe[Yt].rect.w){hr=Pe[Yt].rect.w;break}bu(hr,it);for(var Tt=Zo,hn=Tt.fundamentalLayerOf(E),Pr=[],Jr=0;Jr<it;Jr++)Tt.isGodraySource(Pe[Jr].layer,hn)&&Pr.push(Jr);Yr=Pr.length;for(var dr=0;dr<it;dr++)Tt.isGodraySource(Pe[dr].layer,hn)||Pr.push(dr);for(var Cr=0,Fr=0;Fr<it;Fr++){var gt=Pe[Pr[Fr]],An=gt.fullness||0,Nr=gt.data&>.data.string_map,vi=null;if(Nr&&Nr["render.color"]){var Jt=String(Nr["render.color"]).split(",").map(Number);Jt.length>=3&&Jt.every(function(Dn){return!isNaN(Dn)})&&(vi=Jt)}var dn=Nr&&Nr["render.colorScheme"]?Nr["render.colorScheme"]:xt,yi=vi||Be.getRgbBySchemeName(dn,An),Rr=gt.rect.x,Tn=gt.rect.y,_s=gt.z||0;D.makeTranslation(Rr,Tn,_s),q.setMatrixAt(Cr,D),K.setRGB((yi[0]||0)/255,(yi[1]||0)/255,(yi[2]||0)/255),q.setColorAt(Cr,K),Cr++}q.count=Cr,q.instanceMatrix.needsUpdate=!0,q.instanceColor&&(q.instanceColor.needsUpdate=!0),q.visible=U&&Cr>0}else q&&(q.visible=!1);else if(q&&(q.visible=!1),Q(),U&&E&&E.frameData){let Dn=function(ho,fa,po,Cs,Rs,Ds,ha,Lu,da,js,mo,Iu){var Xn=Cn[fa];Xn||(Xn=Cn[fa]={layer:ho,additive:po,paint:Cs,uShape:Iu,list:[]}),Xn.list.push({x:Rs,y:Ds,z:ha,full:Lu,r:da[0]||0,g:da[1]||0,b2:da[2]||0,a:js,size:mo})};o(Dn,"_pushTo");var bi=E.frameData,xs=bi.length,Os=Be,Cu=rt,Es=typeof G.smoke=="number"&&G.smoke>0,Ru=Es?G.smoke:0,Du=G.colorScheme||"warmcool";p=Cu.toUniform(Ne);for(var Ss=typeof re=="number"&&re>0,wi={},Cn={},Mt=0;Mt<xs;Mt++){var tr=bi[Mt],Qr=tr.layer||0,pn=vg.resolveRenderFamily(tr,G,h);if(pn.family==="mesh"){(wi[pn.assetId]||(wi[pn.assetId]=[])).push(tr);continue}var Xr=tr.fullness||0,Dr=tr.data&&tr.data.string_map,Rn=null;if(Dr&&Dr["render.color"]){var ua=String(Dr["render.color"]).split(",").map(Number);ua.length>=3&&ua.every(function(po){return!isNaN(po)})&&(Rn=ua)}var ju=Dr&&Dr["render.colorScheme"]?Dr["render.colorScheme"]:Du,Yn=tr.z||0,Rr=tr.rect.x,Tn=tr.rect.y,co=tr.rect&&tr.rect.w?tr.rect.w:1,Jn=Os.getAlphaFromIntensity(Xr),_i=Rn||Os.getRgbBySchemeName(ju,Xr),xi=Ss?4*Xr+1:co;if(Ss)Dn(Qr,Qr+"|A",!0,"crisp",Rr,Tn,Yn,Xr,_i,Jn,xi);else if(Es)Dn(Qr,Qr+"|N|soft",!1,"soft",Rr,Tn,Yn,Xr,_i,Jn,xi);else if(pn.family==="sphere")Dn(Qr,Qr+"|N|sphere",!1,"sphere",Rr,Tn,Yn,Xr,_i,Jn,xi,0);else{var ks=pn.family==="cube"?1:pn.uShapeVariant!=null?pn.uShapeVariant:0;Dn(Qr,Qr+"|N|pts:"+ks,!1,"crisp",Rr,Tn,Yn,Xr,_i,Jn,xi,ks)}}var Oi=[];for(var Zr in Cn)if(Cn.hasOwnProperty(Zr)){var jr=Cn[Zr],pr=jr.list.length;if(pr!==0){Oi.push(Zr);var De=C(Zr,jr.additive,jr.paint);R(De,pr),De.layer=jr.layer;var rr=0,Mr=0,Ur=0;if(De.isSphere){for(var Ei=0;Ei<pr;Ei++){var Qt=jr.list[Ei];X.set(Qt.x,Qt.y,Qt.z),ye.set(Qt.size,Qt.size,Qt.size),ee.compose(X,te,ye),De.mesh.setMatrixAt(Ei,ee),xe.setRGB(Qt.r/255,Qt.g/255,Qt.b2/255),De.mesh.setColorAt(Ei,xe),rr+=Qt.x,Mr+=Qt.y,Ur+=Qt.z}De.mesh.count=pr,De.mesh.instanceMatrix.needsUpdate=!0,De.mesh.instanceColor&&(De.mesh.instanceColor.needsUpdate=!0)}else{for(var nr=0;nr<pr;nr++){var mr=jr.list[nr];De.bufs.posArr[nr*3]=mr.x,De.bufs.posArr[nr*3+1]=mr.y,De.bufs.posArr[nr*3+2]=mr.z,De.bufs.fullArr[nr]=mr.full,De.bufs.colArr[nr*3]=mr.r/255,De.bufs.colArr[nr*3+1]=mr.g/255,De.bufs.colArr[nr*3+2]=mr.b2/255,De.bufs.alphaArr[nr]=mr.a,De.bufs.sizeArr[nr]=mr.size,De.bufs.smokeArr[nr]=jr.paint==="soft"?1:0,rr+=mr.x,Mr+=mr.y,Ur+=mr.z}De.geo.setDrawRange(0,pr),De.geo.attributes.position.needsUpdate=!0,De.geo.attributes.aFullness.needsUpdate=!0,De.geo.attributes.aColor.needsUpdate=!0,De.geo.attributes.aAlpha.needsUpdate=!0,De.geo.attributes.aSize.needsUpdate=!0,De.geo.attributes.aSmoke.needsUpdate=!0,De.mat.uniforms.uPersp.value=h?1:0,De.mat.uniforms.uShape&&(De.mat.uniforms.uShape.value=jr.uShape!=null?jr.uShape:p),jr.additive?(De.mat.uniforms.uIntensity.value=typeof re=="number"?re:1,De.mat.uniforms.uHeat.value=typeof G.heat=="number"?G.heat:0,De.mat.uniforms.uSmoke.value=0):(De.mat.uniforms.uIntensity.value=1,De.mat.uniforms.uHeat.value=typeof G.heat=="number"?G.heat:0,De.mat.uniforms.uSmoke.value=jr.paint==="soft"?Ru:0)}De.centroid.x=rr/pr,De.centroid.y=Mr/pr,De.centroid.z=Ur/pr,De.mesh.visible=U}}if(h&&Oi.length>1){Oi.sort(function(ho,fa){return Y(O[fa].centroid)-Y(O[ho].centroid)});for(var ca=0;ca<Oi.length;ca++)O[Oi[ca]].mesh.renderOrder=ca}var As=[],Ts=0;for(var Qn in wi)if(wi.hasOwnProperty(Qn)){As.push(Qn),so(Qn);var fo=Ce[Qn];fo&&fo.status==="ready"&&(Ts+=gs(fo,wi[Qn],U,G.meshScale,Qn))}vs(As),_e&&(_e.visible=Ts>0)}fe&&_u(E),la(G,E)}}o(uo,"_renderTick");function la(E,P){E=E||{};var z=E.godrays>0,G=ct.length>0?Lo(P):null;fr=G,z?Su(E,P):ct.length>0?Ou(ct[0],G):(l.setRenderTarget(null),l.render(u,f)),ws()}o(la,"_composeFinal");var Tu={init:o(function(E){return er(E),c},"init"),renderTick:o(function(E,P,z){uo(E,P,z)},"renderTick"),filter:o(function(E,P){if(E){if(E.name){for(var z=0;z<ct.length;z++)if(ct[z].name===E.name){P&&(ct[z]._perFilterOptions=P);return}}var G=E;P&&(G=Object.assign({},E),G._perFilterOptions=P),ct.push(G)}},"filter"),removeFilter:o(function(E){var P=typeof E=="string"?E:E&&E.name;ct=ct.filter(function(z){return z.name!==P}),P&&_t[P]&&(ut.remove(_t[P]),delete _t[P])},"removeFilter"),setSize:o(function(E,P){zn("threeProvider.setSize",E,P),r=E,n=P,l?(l.setSize(E,P),h?(f.aspect=E/P,b()):(f.right=E,f.bottom=P,f.updateProjectionMatrix()),ge&&ge.setSize(E,P),jt&&jt.setSize(E,P),ot&&ot.setSize(E,P)):h&&b()},"setSize"),start:o(function(){},"start"),stop:o(function(){},"stop"),destroy:o(function(){l&&l.dispose(),c&&c.parentNode&&c.parentNode.removeChild(c),Kt=!1,ct=[]},"destroy"),raw:o(function(){return{renderer:l,scene:u,camera:f}},"raw"),projection:o(function(){return h?{kind:"perspective",fovY:es}:{kind:"affine2d"}},"projection"),captureStill:o(function(){if(!Kt||!l)throw new Error("[three-provider.captureStill] no live renderer \u2014 init() has not run. (FAIL-LOUD \u2014 never a null or blank still.)");if(!cr)throw new Error("[three-provider.captureStill] nothing has been composited yet (no renderTick/repaint since init). A capture before the first draw would be a cleared framebuffer, i.e. a black still. (FAIL-LOUD.)");var E=Ko;la(pi,cr);var P=l.getContext(),z=l.domElement,G=E.captureFromGl(P,z.width,z.height,{cssWidth:z.clientWidth||a(),cssHeight:z.clientHeight||s(),physicsW:a(),physicsH:s(),filtersApplied:ct.map(function(U){return U.name}),renderBaseCanvas:mi,filterTime:fr,composited:cr});return Promise.resolve(G)},"captureStill"),getCameraControl:o(function(){if(!h)return null;var E=yh;function P(){return E.cameraPresets(a(),s())}o(P,"_presets");function z(U,fe,re){if(typeof U=="number"&&isFinite(U))return U;throw new Error("three-provider camera "+re+": "+fe+" must be a finite number, got "+String(U)+" \u2014 throw-or-apply, never a silent clamp.")}o(z,"_finite");var G={presets:Object.keys(P()),poseFields:E.cameraPoseFields(a(),s()),setOrbit:o(function(U){if(U){if(U=yo(U),U.azimuth!==void 0&&(m.azimuth=z(U.azimuth,"azimuth","setOrbit")),U.elevation!==void 0&&(m.elevation=z(U.elevation,"elevation","setOrbit")),U.distance!==void 0&&(m.distance=z(U.distance,"distance","setOrbit")),U.roll!==void 0){var fe=z(U.roll,"roll","setOrbit")%360;m.roll=fe>180?fe-360:fe<=-180?fe+360:fe}if("target"in U){var re=U.target;m.target=re?{x:re.x,y:re.y,z:re.z}:null}b()}},"setOrbit"),getOrbit:o(function(){return y()},"getOrbit"),addPoseListener:o(function(U){return w||(w=bo()),w.add(U)},"addPoseListener"),setPreset:o(function(U){var fe=P(),re=fe[U];if(!re)throw new Error('[three-provider camera] setPreset("'+U+'"): this camera offers only ['+Object.keys(fe).join(", ")+"] (ctl.presets). (FAIL-LOUD.)");G.setOrbit({azimuth:re.azimuth,elevation:re.elevation,distance:re.distance,roll:0,target:null})},"setPreset"),look:o(function(U){if(U){var fe=U.spin===void 0?0:z(U.spin,"spin","look"),re=U.pitch===void 0?0:z(U.pitch,"pitch","look");if(!(!fe&&!re)){var Be=Oh(m,{spin:fe,pitch:re},a(),s());m.azimuth=Be.azimuth,m.elevation=Be.elevation,m.roll=Be.roll,b()}}},"look"),move:o(function(U){if(U){var fe=U.forward===void 0?0:z(U.forward,"forward","move"),re=U.strafe===void 0?0:z(U.strafe,"strafe","move");!fe&&!re||(m.target=Eh(m,a(),s(),fe,re),b())}},"move"),cameraOffsetFromWorld:o(function(U){return Sh(m,a(),s(),U)},"cameraOffsetFromWorld"),worldFromCameraOffset:o(function(U){return kh(m,a(),s(),U)},"worldFromCameraOffset")};return G},"getCameraControl"),renderCapabilities:Ch,screenToWorld:o(function(E,P,z,G,U){return h?Ah(m,a(),s(),E,P,z,G,U):null},"screenToWorld"),get initialized(){return Kt}};return Tu}o(Sg,"makeThreeProvider");var rs=Object.freeze({p5:Object.freeze({makeProvider:cg,renderCapabilities:vh}),three:Object.freeze({makeProvider:Sg,renderCapabilities:Ch})});function ns(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}o(ns,"_isPlainObject");function kg(e){if(!e||!e.camera)return null;var t=e.camera;return typeof t.preset=="string"&&t.preset.length>0?{mode:"preset",name:t.preset}:t.orbit&&typeof t.orbit=="object"?{mode:"orbit",orbit:t.orbit}:null}o(kg,"pickCameraReplay");function ql(e){var t=ns(e)?e:{};if(Array.isArray(t.pageControls)&&t.pageControls.length>0)throw new Error("[render-state] this saved project carries page controls (renderState.pageControls: "+t.pageControls.map(function(n){return ns(n)?String(n.id):"?"}).join(", ")+") \u2014 page controls are declared in the sketch's own code; move them into the sketch and save again. (FAIL-LOUD.)");var r=null;return ns(t.camera)&&(r={orbit:ns(t.camera.orbit)?t.camera.orbit:null,preset:typeof t.camera.preset=="string"?t.camera.preset:null}),{version:typeof t.version=="number"?t.version:1,renderer:typeof t.renderer=="string"&&t.renderer.length>0?t.renderer:null,engine:typeof t.engine=="string"&&t.engine.length>0?t.engine:null,seed:t.seed!==void 0&&t.seed!==null&&t.seed!==""?String(t.seed):null,backdropVisible:typeof t.backdropVisible=="boolean"?t.backdropVisible:null,camera:r,render:Array.isArray(t.render)?t.render.filter(function(n){return ns(n)&&typeof n.key=="string"&&n.key.length>0}):[]}}o(ql,"normalizeSavedRenderState");function Ag(e,t,r){if(!Array.isArray(e)||!Array.isArray(t)||!Array.isArray(r))throw new Error("[render-state] partitionRenderRows(rows, declaredNames, knownNames) takes three arrays. (FAIL-LOUD.)");for(var n={},i=[],a=0;a<e.length;a++){var s=e[a];if(t.indexOf(s.key)!==-1)n[s.key]=s.value;else if(r.indexOf(s.key)!==-1)i.push({key:s.key,value:s.value});else throw new Error('[render-state] saved render option "'+s.key+'" is declared by no registered renderer (known: ['+r.join(", ")+"]). (FAIL-LOUD: a typo or a deleted option would otherwise silently change the picture.)")}return{apply:n,retained:i}}o(Ag,"partitionRenderRows");function W_(e){var t=e&&e.largeObjects;if(!Array.isArray(t))throw new Error("[render-state] RenderState.backdropOf: runner.largeObjects is not the world's census (an array) \u2014 the backdrop is found there and nowhere else. (FAIL-LOUD.)");for(var r=0;r<t.length;r++)if(t[r]&&t[r].backdrop===!0)return t[r];return null}o(W_,"backdropOf");function Tg(e,t,r){if(!e||typeof e.renderCapabilities!="function"||typeof e.setRenderOptions!="function")throw new Error("[render-state] RenderState.apply(runner, bag, env): runner must be a booted FrqtlApp (renderCapabilities + setRenderOptions). (FAIL-LOUD.)");if(!r||!Array.isArray(r.knownNames))throw new Error("[render-state] RenderState.apply(runner, bag, env): env.knownNames must be the page's RenderCapabilitiesCommon.knownRenderCapabilityNames(providers) array. (FAIL-LOUD.)");var n=ql(t),i=Ag(n.render,e.renderCapabilities().map(function(h){return h.name}),r.knownNames),a=kg(n),s=null,l=null,u=null;if(a){if(s=e.cameraControl,!s)throw new Error("[render-state] the bag declares a camera ("+JSON.stringify(n.camera)+") but the runner has no cameraControl \u2014 a declared view on a display with no pose control would look fine and be wrong. (FAIL-LOUD.)");if(a.mode==="preset"){if(!Array.isArray(s.presets))throw new Error("[render-state] the booted camera publishes no `presets` array \u2014 every getCameraControl() handle declares the presets it offers. (FAIL-LOUD.)");u=a.name,l=s.presets.indexOf(a.name)===-1?"retained":"preset"}else l="orbit"}var f=W_(e);e.setRenderOptions(i.apply),l==="preset"?s.setPreset(a.name):l==="orbit"&&s.setOrbit(a.orbit);var c=null;return f&&n.backdropVisible!==null&&(e.updateObjectProperty(f,"visible",n.backdropVisible),c=n.backdropVisible),{applied:i.apply,retained:i.retained,camera:l,preset:u,backdrop:c}}o(Tg,"apply");ni();Na();var Ki=Object.freeze({SEED:"seed",RENDERER:"renderer",ENGINE:"engine",STEPPING:"stepping"}),H_=Object.freeze([Object.freeze({key:Ki.SEED,reader:"lib/frqtl/experiments/_shared/fx-experiment.js",forward:!0}),Object.freeze({key:Ki.RENDERER,reader:"lib/frqtl/experiments/_shared/boot.js",forward:!0}),Object.freeze({key:Ki.STEPPING,reader:"lib/frqtl/experiments/single-source-interference/index.html",forward:!0}),Object.freeze({key:Ki.ENGINE,reader:"lib/frqtl/experiments/_shared/boot.js",forward:!1,why:"the host's own physics-engine selector (e.g. the GYM's Benchmark/Compare engine dropdown) is the SOLE authority for this axis; forwarding an outer ?engine= would let it silently override an explicit host choice, which is exactly the engine-sniffing-from-above-the-shim class of bug this codebase forbids elsewhere"})]),Cg=Object.freeze([Object.freeze({key:"chrome",appliedBy:"lib/frqtl/experiments/_shared/boot.js",forward:!1,acceptedValues:Object.freeze(["canvas"]),why:`chrome is a HOST-COMPOSITION decision (whether the experiment's own control chrome DOM renders), never a per-experiment physics/render parameter; forwarding it from an outer host URL into an embedded iframe would reintroduce the hidden-experiment-chrome bug (the GYM must always show the experiment's own full chrome, never chrome=canvas \u2014 see the "WHEN should a host set chrome=canvas" doc above for the general criterion, not just the GYM's specific answer to it)`})]),TT=Object.freeze(H_.filter(function(e){return e.forward}).map(function(e){return e.key}));var K_=Object.freeze([{id:"modules",means:"Loading the scene objects"},{id:"engine-ready",means:"Starting the WASM engine"},{id:"renderer",means:"Loading the renderer"},{id:"sketch",means:"Building the scene"}].map(Object.freeze)),Rh=Object.freeze(K_.map(e=>e.id)),Dh="frqtl:boot-phase";var Y_={engine:{id:"egpt-engine-error",marker:"data-egpt-engine-error",bg:"#1a0000",fg:"#ff6b6b",border:"#b6161c"},renderer:{id:"egpt-renderer-error",marker:"data-egpt-renderer-error",bg:"#000a1a",fg:"#6b9eff",border:"#1640b6"}},Yi=null;function Rg(e){Yi=e||null}o(Rg,"setBootOverlayHost");function Ji(e,t){let r=Y_[e];if(!r)throw new Error("[boot] paintBootFailure: axis must be engine | renderer (got "+JSON.stringify(e)+")");typeof console<"u"&&console.error&&console.error(t);function n(){if(Yi){if(Yi.querySelector&&Yi.querySelector("["+r.marker+"]"))return;let a=document.createElement("div");a.setAttribute(r.marker,"1"),a.setAttribute("data-egpt-boot-error","1"),a.style.cssText="position:absolute;inset:0;z-index:9998;background:"+r.bg+";color:"+r.fg+";font:12px/1.5 ui-monospace,Menlo,Consolas,monospace;padding:14px;white-space:pre-wrap;overflow:auto;border:2px solid "+r.border+";",a.textContent=t;let s=getComputedStyle(Yi);(!s||s.position==="static")&&(Yi.style.position="relative"),Yi.appendChild(a);return}if(document.getElementById(r.id))return;let i=document.createElement("div");i.id=r.id,i.setAttribute("data-egpt-boot-error","1"),i.style.cssText="position:fixed;inset:0;z-index:99999;background:"+r.bg+";color:"+r.fg+";font:13px/1.55 ui-monospace,Menlo,Consolas,monospace;padding:22px;white-space:pre-wrap;overflow:auto;border:2px solid "+r.border+";",i.textContent=t,(document.body||document.documentElement).appendChild(i)}o(n,"paint"),document.body?n():addEventListener("DOMContentLoaded",n)}o(Ji,"paintBootFailure");Un();Et();Rt();var Qi=Object.freeze([Object.freeze({specifier:"@descix/frqtl-web/parts",libPath:"frqtl/parts/index.js",why:"the parts barrel"}),Object.freeze({specifier:"@descix/frqtl-web/parts/",libPath:"frqtl/parts/",why:"one part = one file"}),Object.freeze({specifier:"@descix/frqtl-web/shim/controls/registry.js",libPath:"shim/controls/registry.js",why:"knob registration (blackbody, circuit-sat, collision-matrix-3d, dse-tunnel-rebuild)"}),Object.freeze({specifier:"@descix/frqtl-web/shim/render/sun-look.js",libPath:"shim/render/sun-look.js",why:"the one owner of the sun's FX bag (dse-tunnel-rebuild)"}),Object.freeze({specifier:"@descix/frqtl-web/compat/renderer/display-slot.js",libPath:"frqtl/compat/renderer/display-slot.js",why:"the booted display name before co-init (mirror-route, dse-tunnel-rebuild)"}),Object.freeze({specifier:"@descix/frqtl-web/compat/renderer/orbit-bag.js",libPath:"frqtl/compat/renderer/orbit-bag.js",why:"hasAngularPose, THE 3D-ness predicate (atomic-model)"}),Object.freeze({specifier:"@descix/frqtl-web/objects/setup/_collisionMatrixLanes.js",libPath:"frqtl/objects/setup/_collisionMatrixLanes.js",why:"the one lane table (collision-matrix-3d)"}),Object.freeze({specifier:"@descix/frqtl-web/compat/engine.js",libPath:"frqtl/compat/engine.js",why:"the engine accessor (atomic-model builds its frames by hand)"}),Object.freeze({specifier:"@descix/frqtl-web/kinds",libPath:"frqtl/objects/kinds-entry.js",why:"the kind registry: a composed fork registers its renamed class (registerKind, kindNamed, kindOf, registeredKinds)"})]),J_=Object.freeze({specifier:"@descix/frqtl-web/boot",libPath:"frqtl/experiments/_shared/doors.js",why:"the scene doors (bootScene, bootProject)"}),IT=Object.freeze([J_,Object.freeze({specifier:"@descix/frqtl-web/registry",libPath:"shim/registry/index.js",why:"the walk-through rungs, the showcase roster, the experiment registry, projectOf"}),Object.freeze({specifier:"@descix/frqtl-web/project",libPath:"shim/project/index.js",why:"the specifier table, the link site, sketchProject and the project identity"})]),Lh="@descix/frqtl-web";function jh(e){return e.specifier.endsWith("/")}o(jh,"_isPrefix");function Bl(e){if(typeof e!="string")throw new TypeError("[specifiers] libPathOf(specifier): a string specifier (got "+typeof e+"). (FAIL-LOUD.)");for(let t of Qi)if(!jh(t)&&t.specifier===e)return t.libPath;for(let t of Qi)if(jh(t)&&e.startsWith(t.specifier)&&e.length>t.specifier.length){let r=e.slice(t.specifier.length);if(r.split("/").indexOf("..")!==-1)throw new Error('[specifiers] "'+e+'" climbs out of its prefix row ('+t.specifier+"). (FAIL-LOUD.)");return t.libPath+r}throw new Error('[specifiers] "'+e+'" is not a @descix/frqtl-web specifier \u2014 the table (lib/shim/project/specifiers.js FRQTL_WEB_SPECIFIERS) offers: '+Qi.map(function(t){return t.specifier+(jh(t)?"<file>":"")}).join(", ")+". (FAIL-LOUD.)")}o(Bl,"libPathOf");var Dg=Qi.find(function(e){return e.libPath==="frqtl/parts/index.js"});if(!Dg)throw new Error("[parts-module] FRQTL_WEB_SPECIFIERS has no row for the parts barrel (frqtl/parts/index.js). (FAIL-LOUD.)");var Q_=Dg.specifier,X_=/^frqtl\/parts\/[A-Za-z_$][\w$]*\.js$/;function Wl(e,t){if(typeof e!="string"||!e)throw new TypeError("[parts-module] moduleOfKind(from, urls): from is the kind row's module URL (got "+JSON.stringify(e)+"). (FAIL-LOUD.)");let r=He();if(e.startsWith(r)&&X_.test(e.slice(r.length)))return Q_;if(t){for(let n of Object.keys(t))if(t[n]===e)return n}return null}o(Wl,"moduleOfKind");function jg(e,t){if(typeof e!="string"||!e)throw new TypeError("[parts-module] importSpecifierOf(module, entry): a module specifier or project path. (FAIL-LOUD.)");if(e.startsWith("@"))return e;let r=t.split("/");r.pop();let n=e.split("/");for(;r.length&&n.length>1&&r[0]===n[0];)r.shift(),n.shift();let i=r.map(function(){return".."});return(i.length?i.join("/")+"/":"./")+n.join("/")}o(jg,"importSpecifierOf");ni();va();So();wr();Ut();Na();var Z_=100,$_=10,ex=200,Ih=Object.freeze(["fpsLimit","tpsLimit"]),Ig=Object.freeze(["initWorld"]);function Pg(e,t){if(e.RATE_LIMITS!==void 0)throw new Error("[FrqtlApp."+t+"] the RATE_LIMITS factory static is DELETED \u2014 pacing is declared where the scene is: exp.runner.setRateLimits({ fpsLimit?, tpsLimit? }) in a scene file, runner.setRateLimits(...) on a page. (FAIL-LOUD.)")}o(Pg,"_refuseDeletedStatics");function Lg(e,t){return t&&t[e]?t[e]:Hi()[e]}o(Lg,"_resolveEngineClass");function tx(e,t){for(var r=e.get("Wall"),n=0;n<r.fields.length;n++)if(r.fields[n].name===t)return!0;return!1}o(tx,"_isWallField");function Fg(e){return e&&e.lo&&e.lo._owner===e?e:null}o(Fg,"_wallFacadeOf");W._wallFacadeOf=Fg;function Ng(e){if(typeof requestAnimationFrame!="function")throw new Error("[FrqtlApp."+e+"] no animation frame in this host \u2014 the wall-clock loop needs requestAnimationFrame. Drive the clock with `runner.step()` (one tick + render per call, any host), or boot in a browser through `@descix/frqtl-web/boot`. (FAIL-LOUD.)")}o(Ng,"_requireAnimationFrame");function W(e){e=e||{};var t=e.canvasW,r=e.canvasH;if(typeof t!="number"||!(t>0)||typeof r!="number"||!(r>0))throw new Error("[FrqtlApp] canvasW and canvasH are REQUIRED positive numbers (got "+JSON.stringify(t)+" x "+JSON.stringify(r)+"). There is no default world size: a scene states its world with exp.createCanvas(w, h, cfg) / exp.createScene(w, h, d, cfg); a page passes it here. (FAIL-LOUD.)");this._is3D=!!e.is3D,this._depth=e.canvasD!==void 0&&e.canvasD!==null?e.canvasD:null;var n=e.seed!==void 0?e.seed:42;this._canvasParentId=e.canvasParentId||null,this._onTick=e.onTick||null,this._onReady=e.onReady||null,this._tickListeners=[],this._drawHz=e.drawHz!==void 0&&e.drawHz>0?e.drawHz:0;var i=e.stepsPerFrame!==void 0?Math.max(1,e.stepsPerFrame):1;e.tickHz!==void 0&&e.tickHz>0?this._tickHz=e.tickHz:i>1?this._tickHz=this._drawHz>0?this._drawHz*i:60*i:this._tickHz=0,this.stepsPerFrame=i;var a=Lg("Rectangle",e.engine);this.canvas_rect=new a(0,0,t,r,null,!1),this._seed=n,this._tickSuspend=0;var s=Lg("EGPTUniverse",e.engine);this.universe=s.create({rect:this.canvas_rect,seed:n}),this._declared=[],this._declaredMembers=new Map,this._declaredTicks=new Map,this._setupResult=null,this._sceneReplay=null,this._designMode=!1,this._aim=null,this._selected=null,this._onObjectMoved=null,this._isLooping=!1,this._rafId=null,this._lastTickData=null,this._accumulator=0,this._lastFrame=0,this._lastDraw=0,this._lastBudgetWarn=0,this._BUDGET_WARN_INTERVAL_MS=5e3,this._rateWindowMs=1e3,this._rateWindowEnd=0,this._tickCount=0,this._drawCount=0,this._lastTps=0,this._lastFps=0,this._renderOptions={renderBaseCanvas:!0},this._stagedRenderOptions=null,this._renderer=null;var l=this;this._capture=Nl.create({get lastTickData(){return l._lastTickData}},function(){return l._getRenderer()},{seed:this._seed,get rect(){return l.canvas_rect}},function(){return l._renderOptions})}o(W,"FrqtlApp");Object.defineProperty(W.prototype,"largeObjects",{configurable:!0,get:o(function(){var e=this.universe;return e&&Array.isArray(e.largeObjects)?e.largeObjects:[]},"get")});Object.defineProperty(W.prototype,"controlHost",{configurable:!0,get:o(function(){if(this._controlHost)return this._controlHost;var e=this._sceneSurface;return e&&e.parentNode?e.parentNode:null},"get"),set:o(function(e){if(!e||typeof e.appendChild!="function"||!e.ownerDocument)throw new TypeError("[FrqtlApp.controlHost] a control host is a DOM element (it carries appendChild + ownerDocument); got "+String(e)+". (FAIL-LOUD.)");this._controlHost=e;for(var t=(this._controlChrome||[]).slice(),r=0;r<t.length;r++)t[r].rehost(e)},"set")});W.prototype.addControlChrome=function(e){if(!e||typeof e.rehost!="function")throw new TypeError("[FrqtlApp.addControlChrome] chrome must expose rehost(el). (FAIL-LOUD.)");var t=this._controlChrome||(this._controlChrome=[]);return t.push(e),function(){var r=t.indexOf(e);r!==-1&&t.splice(r,1)}};W.prototype.setDesignMode=function(e){this._designMode=!!e};W.prototype._shellRenderOf=function(e){var t=e&&e.shellRender;return t==="design"||t==="run"||t==="never"?t:e&&e._designMarker===!0?"design":"run"};W.prototype._visibleLargeObjects=function(){var e=this.largeObjects;if(!e||e.length===0)return e;for(var t=this,r=!1,n=0;n<e.length;n++)if(e[n]&&!t._isShellVisible(e[n])){r=!0;break}return r?e.filter(function(i){return t._isShellVisible(i)}):e};W.prototype._isShellVisible=function(e){var t=this._shellRenderOf(e);return t==="run"?!0:t==="never"?!1:!!this._designMode};var Hl="filter.";function Kl(e){var t=li,r=t.get()===e?t.name():null;return r?'renderer "'+r+'"':"the active renderer"}o(Kl,"_providerLabel");function Mg(e,t){if(typeof e.renderCapabilities!="function")throw new TypeError("[FrqtlApp.setRenderOption] "+Kl(e)+' declares no renderCapabilities(), so it accepts no render option (tried "'+t.map(function(c){return c[0]}).join('", "')+'"). A provider declares its knobs by implementing renderCapabilities().');for(var r=e.renderCapabilities(),n={},i=0;i<r.length;i++)n[r[i].name]=r[i];for(var a=Ke.normalizeValue,s=[],l=0;l<t.length;l++){var u=t[l][0];if(W.RUNNER_INJECTED_RENDER_KEYS.indexOf(u)!==-1)throw new TypeError('[FrqtlApp.setRenderOption] "'+u+'" is merged into the render bag by the runner itself (FrqtlApp.RUNNER_INJECTED_RENDER_KEYS); it is not a writable render option.');var f=Object.prototype.hasOwnProperty.call(n,u)?n[u]:null;if(!f)throw new TypeError('[FrqtlApp.setRenderOption] "'+u+'" is not a render option '+Kl(e)+" declares. Declared by renderCapabilities(): ["+r.map(function(c){return c.name}).join(", ")+"]. (FAIL-LOUD: an undeclared key is read by nothing, so the picture would silently differ from the recipe.)");s.push([u,a(f,t[l][1],"render option")])}return s}o(Mg,"_validateRenderWrites");W.prototype._applyRenderWrites=function(e){for(var t=0;t<e.length;t++){var r=e[t][0];r.indexOf(Hl)===0?this.setFilterActive(r.slice(Hl.length),!!e[t][1]):this._renderOptions[r]=e[t][1]}for(var n=(this._renderOptionsListeners||[]).slice(),i=0;i<n.length;i++)n[i](e.map(function(a){return[a[0],a[1]]}));this._isLooping||this.repaint()};W.prototype.addRenderOptionsListener=function(e){var t=this._renderOptionsListeners||(this._renderOptionsListeners=[]);return t.indexOf(e)===-1&&t.push(e),function(){var r=t.indexOf(e);r!==-1&&t.splice(r,1)}};W.prototype.setRenderOptions=function(e){if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("[FrqtlApp.setRenderOptions] expects a plain object of { capabilityName: value }; got "+(Array.isArray(e)?"an array":String(e))+".");var t=Object.keys(e).map(function(n){return[n,e[n]]}),r=this._getRenderer();if(!r){this._stagedRenderOptions=(this._stagedRenderOptions||[]).concat(t);return}this._applyRenderWrites(Mg(r,t))};W.prototype.setRenderOption=function(e,t){var r={};r[e]=t,this.setRenderOptions(r)};W.prototype.renderCapabilities=function(){var e=this._getRenderer();return!e||typeof e.renderCapabilities!="function"?[]:e.renderCapabilities()};W.prototype.getRenderOption=function(e){var t=this._getRenderer();if(!t)throw new TypeError("[FrqtlApp.getRenderOption] no display provider has attached yet, so no render option is declared. Read after the renderer boots.");if(typeof t.renderCapabilities!="function")throw new TypeError("[FrqtlApp.getRenderOption] "+Kl(t)+' declares no renderCapabilities(), so "'+e+'" is not a render option it has.');for(var r=t.renderCapabilities(),n=!1,i=0;i<r.length;i++)if(r[i].name===e){n=!0;break}if(!n)throw new TypeError('[FrqtlApp.getRenderOption] "'+e+'" is not declared by '+Kl(t)+" (declared: ["+r.map(function(a){return a.name}).join(", ")+"]).");return e.indexOf(Hl)===0?this.isFilterActive(e.slice(Hl.length)):this._renderOptions[e]};W.prototype.setFilterActive=function(e,t){var r=this._getRenderer();if(!r||typeof r.filter!="function"||typeof r.removeFilter!="function")throw new Error("[FrqtlApp.setFilterActive] no active renderer with filter()/removeFilter() (RendererProvider REQUIRED methods). (FAIL-LOUD.)");var n=Ga;if(!Object.prototype.hasOwnProperty.call(n,e))throw new Error('[FrqtlApp.setFilterActive] unknown filter "'+e+'" \u2014 not a Filters.js catalog entry. (FAIL-LOUD.)');this._activeFilters||(this._activeFilters={}),t?(r.filter(n[e]),this._activeFilters[e]=!0):(r.removeFilter(e),delete this._activeFilters[e])};W.prototype.isFilterActive=function(e){return!!(this._activeFilters&&this._activeFilters[e])};W.prototype.setSourceRef=function(e){return this._capture.setSourceRef(e)};W.prototype.setSourceSha256=function(e){return this._capture.setSourceSha256(e)};W.prototype.sceneRecord=function(){return this._capture.sceneRecord()};W.prototype._assertRenderCensus=function(){var e=this.universe;if(!(!e||typeof e.unwrappedLargeObjectHandles!="function")){var t=e.unwrappedLargeObjectHandles();if(t.length!==0)throw new Error("[FrqtlApp] "+t.length+" object(s) are registered with the PHYSICS of this world but absent from its render census \u2014 handle(s) ["+t.join(", ")+"]. They collide and count correctly and CANNOT BE SEEN, which is the one outcome this surface refuses: a silently wrong picture is worse than an error, because what the eye is taught from it is wrong. Construct large objects through `new LargeObject(universe, \u2026)` (or a part that does \u2014 Wall, GraphingDetectorWall, Tunnel \u2026), which registers them for physics AND render in one act. The raw `universe.registerLargeObject(spec)` path carries no wrapper and belongs to headless harnesses only. (FAIL-LOUD.)")}};W.prototype.capture=function(e){try{this._assertRenderCensus()}catch(t){return Promise.reject(t)}return this._capture.capture(e)};W.prototype.captureStill=function(){try{this._assertRenderCensus()}catch(e){return Promise.reject(e)}return this._capture.captureStill()};W.prototype.addBackdrop=function(e,t,r){r=r||{};var n=t||{left:0,top:0,w:this.canvas_rect.w,h:this.canvas_rect.h},i=r.color||[0,0,0],a=r.visible!==void 0?r.visible:!1,s=Se,l=Ee,u=new s(this.universe,[n.left,n.top,n.w,n.h],l.NONE,[],"backdrop","closest",null,1,i);return u.backdrop=!0,u.image=e,u.visible=a,u};function is(e){return e._declaredMembers||(e._declaredMembers=new Map)}o(is,"_declaredMembersMap");function as(e){return e._declaredTicks||(e._declaredTicks=new Map)}o(as,"_declaredTicksMap");Object.defineProperty(W.prototype,"declared",{configurable:!0,get:o(function(){var e=this._declared||(this._declared=[]);if(!e.length)return e;for(var t=new Set(this.largeObjects),r=is(this),n=0;n<e.length;n++)for(var i=r.get(e[n])||[],a=0;a<i.length;a++)if(!t.has(i[a]))throw new Error('[FrqtlApp.declared] stale declaration \u2014 "'+(e[n].name||e[n]._schemaKind)+'" lost its census LO "'+(i[a].name||"?")+'": the world was re-inited without clearing the registry (clearDeclared runs at FrqtlApp.setup and the RecipeContext co-init exp.createCanvas / exp.createScene \u2014 the world-init paths). (FAIL-LOUD.)');return e},"get")});W.prototype.declare=function(e,t,r,n){if(!e||typeof e!="object")throw new TypeError("[FrqtlApp.declare] a declared object is a handle, got "+typeof e+". (FAIL-LOUD.)");var i=this._declared||(this._declared=[]);if(i.indexOf(e)!==-1)throw new Error('[FrqtlApp.declare] "'+(e.name||e._schemaKind)+'" is already declared. (FAIL-LOUD.)');i.push(e);var a=(t||[]).slice();is(this).set(e,a),as(this).set(e,(r||[]).slice());for(var s=0;s<a.length;s++)if(this.declaredOf(a[s])!==e)throw i.pop(),is(this).delete(e),as(this).delete(e),new Error('[FrqtlApp.declare] "'+(e.name||e._schemaKind)+'" put the LO "'+(a[s].name||"?")+'" in the world without an `_owner` chain ending at it \u2014 a composer stamps ONE up-link on what it composed, so every drawn thing resolves to its declared object. (FAIL-LOUD.)');var l=n&&n.kind||e._schemaKind,u=l?Xt(l):null;return rx(e,{inParts:!1,module:u?Wl(u.from,this._projectUrls||null):null}),e};var Gl=new WeakMap;function rx(e,t){Gl.set(e,t),Object.prototype.hasOwnProperty.call(e,"inParts")||(Object.defineProperty(e,"inParts",{configurable:!0,enumerable:!1,get:o(function(){var r=Gl.get(this);return r?r.inParts:!1},"get")}),Object.defineProperty(e,"module",{configurable:!0,enumerable:!1,get:o(function(){var r=Gl.get(this);return r?r.module:null},"get")}))}o(rx,"_setCensusRow");function Ug(e,t){var r=e._declared;if(!(!r||!r.length)){var n=e.declaredOf(t);n&&(e._handTouched||(e._handTouched=new Set)).add(n)}}o(Ug,"_markHand");W.prototype._takeHandTouched=function(){var e=this._handTouched||new Set;return this._handTouched=new Set,e};W.prototype._adoptIntoParts=function(e){var t=Gl.get(e);if(!t)throw new Error('[FrqtlApp] _adoptIntoParts: "'+(e&&e.name)+'" is not a declared object. (FAIL-LOUD.)');t.inParts=!0};W.prototype.beginWorld=function(){this._lastTickData=null};W.prototype.clearDeclared=function(){this._declared=[],this._declaredMembers=new Map,this._declaredTicks=new Map,this._handTouched=new Set};W.prototype.declaredOf=function(e){for(var t=this._declared||[],r=e,n=0;r&&n<64;r=r._owner,n++)if(t.indexOf(r)!==-1)return r;return null};W.prototype.membersOf=function(e){return(is(this).get(e)||[]).slice()};W.prototype.undeclaredTickFunctions=function(){var e=this.universe&&Array.isArray(this.universe.experimentTickFunctions)?this.universe.experimentTickFunctions:[],t=new Set;return as(this).forEach(function(r){for(var n=0;n<r.length;n++)t.add(r[n])}),e.filter(function(r){return!t.has(r)})};W.prototype.removeObject=function(e){var t=this.declared,r=t.indexOf(e);if(r===-1){var n=this.declaredOf(e);throw n?new Error('[FrqtlApp.removeObject] "'+(e&&e.name)+'" is part of the declared '+(n._schemaKind||"object")+' "'+n.name+'" \u2014 delete "'+n.name+'", not its part. (FAIL-LOUD.)'):new Error('[FrqtlApp.removeObject] "'+(e&&(e.name||e._schemaKind))+'" is not a declared object (runner.declared) \u2014 only what a declaring call (exp.addObject, a palette drop) produced is removed here; a primitive-surface object is disposed by whoever built it (obj.dispose()). (FAIL-LOUD.)')}if(typeof e.dispose!="function")throw new Error("[FrqtlApp.removeObject] the declared "+(e._schemaKind||"object")+' "'+e.name+'" has no dispose() \u2014 a part tears down what it composed. (FAIL-LOUD.)');var i=this.membersOf(e),a=(as(this).get(e)||[]).slice();t.splice(r,1),is(this).delete(e),as(this).delete(e),e.dispose();var s=this.universe&&Array.isArray(this.universe.experimentTickFunctions)?this.universe.experimentTickFunctions:[],l=a.filter(function(c){return s.indexOf(c)!==-1});if(l.length)throw new Error('[FrqtlApp.removeObject] disposing "'+e.name+'" left '+l.length+" of its tick-functions running \u2014 its dispose() must tear down everything it composed. (FAIL-LOUD.)");var u=new Set(this.largeObjects),f=i.filter(function(c){return u.has(c)});if(f.length)throw new Error('[FrqtlApp.removeObject] disposing "'+e.name+'" left '+f.length+" of its LOs in the world ("+f.map(function(c){return c.name}).join(", ")+") \u2014 its dispose() must tear down everything it composed. (FAIL-LOUD.)")};W.prototype.getObjectByName=function(e,t){if(typeof e!="string"||!e)return null;for(var r=this.declared,n=0;n<r.length;n++){var i=r[n];if(i&&i.name===e&&(!t||t(i)))return i}return null};function nx(e,t,r,n){var i=e.largeObjects;if(!(!t||!i||i.length===0)){for(var a=Ke,s=[],l=0;l<i.length;l++)for(var u=i[l],f=0;u&&u._owner&&f<64;u=u._owner,f++)if(u._owner===t){s.indexOf(u)===-1&&s.push(u);break}for(var c=0;c<s.length;c++){var h=s[c];if(a){var g=a.get(h._schemaKind||h.kind||"LargeObject"),p=!1;if(g){for(var m=0;m<g.fields.length;m++)if(g.fields[m].name===r){p=!0;break}}if(!p)continue}e.updateObjectProperty(h,r,n)}}}o(nx,"_fanOutRenderPropToGroup");W.prototype.updateObjectProperty=function(e,t,r){if(e){var n=t==="name"?this.declaredOf(e):null;if(n&&n.inParts)throw new TypeError('[FrqtlApp.updateObjectProperty] "name" of the parts entry "'+n.name+'": '+W.RENAME_REFUSAL+" (FAIL-LOUD.)");Ug(this,e);var i=e._schemaKind||e.kind;if(!i)throw new TypeError('[FrqtlApp.updateObjectProperty] this object carries no `_schemaKind` (nor `kind`), so its descriptor cannot be resolved \u2014 property "'+t+'" was not rejected by any schema. Every shipped object class stamps `_schemaKind`; a handle without one is usually the wrong handle (e.g. a raw emitter handle rather than the palette object that wraps it).');var a=Ke,s=null;if(a){var l=a.get(i);if(!l)throw new TypeError('[FrqtlApp.updateObjectProperty] Unknown object kind "'+i+'"');for(var u=0;u<l.fields.length;u++)if(l.fields[u].name===t){s=l.fields[u];break}if(!s)throw new TypeError('[FrqtlApp.updateObjectProperty] Property "'+t+'" is not in the schema for kind "'+i+'"');if(s.type==="readonly")throw new TypeError('[FrqtlApp.updateObjectProperty] Property "'+t+'" is readonly for kind "'+i+'"');r=a.normalizeValue(s,r,i);var f=Fg(e);if(t==="rect"&&f){f.setRect(r),typeof this._onObjectMoved=="function"&&this._onObjectMoved(f,t);return}var c=["collisionBehavior","bounceDirection","decoherence","hooks","markTag","countFilter","capacity","orientationDeg","pitchDeg"];if(f===e&&tx(a,t)){c.indexOf(t)!==-1?typeof e.setV2Prop=="function"&&e.setV2Prop(t,r):e.lo&&this.updateObjectProperty(e.lo,t,r),t==="rect"&&typeof this._onObjectMoved=="function"&&this._onObjectMoved(e,t);return}if(i==="Tunnel"&&typeof e.applyProp=="function"&&e.applyProp(t,r)){(t==="rect"||t==="left"||t==="top")&&typeof this._onObjectMoved=="function"&&this._onObjectMoved(e,t);return}if(i==="SphereEmitter"){typeof e.applyProp=="function"&&e.applyProp(t,r),(t==="center"||t==="rect")&&typeof this._onObjectMoved=="function"&&this._onObjectMoved(e,t);return}if(!s.engineVisible){if((i==="LargeObject"||i==="backdrop")&&(t==="collision_type"||t==="actions")&&typeof e.recompileActions=="function"){var h={};h[t==="collision_type"?"collisionType":"actions"]=r,e.recompileActions(h);return}e[t]=r,nx(this,e,t,r);return}}if(t==="rect"&&e.rect){if(typeof e.setRect!="function")throw new TypeError('[FrqtlApp.updateObjectProperty] "'+(e.name||i)+'" ('+i+") carries a rect but no setRect \u2014 its rect has no writer, so a rect write cannot land. (FAIL-LOUD.)");e.setRect(r);return}if(t!=="rect"&&t!=="source_rects")if(t==="actions"&&(i==="LargeObject"||i==="backdrop")){var g=Array.isArray(r)?r.slice():[r];e.arr_collision_actions=g,e.actions=g}else t==="layer"&&(i==="LargeObject"||i==="backdrop")?(e.layer=r??null,e.observedDimensions=r!=null?[r]:[]):e[t]=r;if(i==="PointSource"&&t==="rect"){typeof e.repositionToRect=="function"&&e.repositionToRect(r[0],r[1],r[2],r[3],this.universe);return}if(i==="QuantumEmitter"&&t==="rect"){typeof e.setSourceRect=="function"&&e.setSourceRect(r);return}this.universe&&typeof this.universe.updateObjectProperty=="function"&&this.universe.updateObjectProperty(e.handle,i,t,r)}};W.prototype._centerOf=function(e){if(!e||typeof e.getCenter!="function"||typeof e.setCenter!="function")return null;var t=e.getCenter();return Array.isArray(t)?t:null};W.prototype._rectAuthorityOf=function(e){return e&&e.rect&&typeof e.setRect=="function"?e:null};W.prototype.positionAuthorityOf=function(e){return this._centerOf(e)?"center":this._rectAuthorityOf(e)?"rect":null};W.prototype.noPositionAuthorityMessage=function(e){return'"'+(e&&e.name)+'" ('+(e&&e._schemaKind||"object")+") has no position authority \u2014 neither a centre (getCenter/setCenter) nor a rect (rect + setRect) \u2014 so it cannot be moved as a unit."};W.prototype._requireDeclared=function(e,t){if(e&&this.declaredOf(e)===e)return e;var r=e?this.declaredOf(e):null;throw new Error("[FrqtlApp."+t+"] "+(e?'"'+(e.name||e._schemaKind||"object")+'"':String(e))+" is not a declared object \u2014 only what the scene declared (runner.declared) is placed or read here"+(r?"; it belongs to the declared "+(r._schemaKind||"object")+' "'+r.name+'" \u2014 pass that handle (runner.declaredOf(x))':"; a primitive-surface object is not manipulable")+". (FAIL-LOUD.)")};W.prototype.centerOf=function(e){this._requireDeclared(e,"centerOf");var t=this._centerOf(e);if(t)return t;var r=this._rectAuthorityOf(e);if(r)return ji(r.rect);throw new Error(this.noPositionAuthorityMessage(e))};W.prototype.kindOf=function(e){if(this._requireDeclared(e,"kindOf"),typeof e._schemaKind!="string"||!e._schemaKind)throw new Error('[FrqtlApp.kindOf] the declared object "'+e.name+'" carries no kind stamp \u2014 ObjectFactory.create stamps every declaration. (FAIL-LOUD.)');return e._schemaKind};W.prototype._placementAuthority=function(e){if(this._centerOf(e))return"center";var t=this._rectAuthorityOf(e);if(!t)throw new Error(this.noPositionAuthorityMessage(e));return typeof t.assertOwnsProgram=="function"&&t.assertOwnsProgram(),"rect"};W.prototype.placeDeclaredAt=function(e,t){if(Ug(this,e),this._requireDeclared(e,"placeDeclaredAt"),!Array.isArray(t)||t.length!==2&&t.length!==3||!t.every(function(s){return typeof s=="number"&&isFinite(s)}))throw new TypeError("[FrqtlApp.placeDeclaredAt] the point is [x, y, z?] of finite numbers; got "+JSON.stringify(t)+". (FAIL-LOUD.)");var r=[t[0],t[1],t.length===3?t[2]:0],n=this.getUniverseBounds();if(r[0]<0||r[0]>n.width||r[1]<0||r[1]>n.height||r[2]<-n.zHalf||r[2]>n.zHalf)throw new RangeError("[FrqtlApp.placeDeclaredAt] "+JSON.stringify(r)+" is outside the universe cube (getUniverseBounds(): width "+n.width+", height "+n.height+", zHalf "+n.zHalf+" \u2014 x in [0, width], y in [0, height], z in [-zHalf, zHalf]). (FAIL-LOUD.)");var i=!1;if(this._placementAuthority(e)==="rect"){var a=Li;a.hasZ(e.rect)||(i=Math.abs(r[2])>W.Z_HOLD_EPS,r=[r[0],r[1],0]),this.updateObjectProperty(e,"rect",a.snapRectPosition(a.rectAtCenter(e.rect,r)))}else this.updateObjectProperty(e,"center",Cc(r));return{center:this.centerOf(e),zHeld:i}};W.prototype._orientationOf=function(e){return e&&typeof e.setOrientation=="function"?e:null};W.prototype.envelopeOf=function(e){if(e&&e.rect&&typeof e.rect.w=="number")return e.rect;for(var t=this.membersOf(e),r=1/0,n=1/0,i=-1/0,a=-1/0,s=1/0,l=-1/0,u=!1,f=0;f<t.length;f++){var c=t[f]&&t[f].rect;c&&(r=Math.min(r,c.left),n=Math.min(n,c.top),i=Math.max(i,c.left+c.w),a=Math.max(a,c.top+c.h),vn(c)&&(u=!0,s=Math.min(s,c.z),l=Math.max(l,c.z+(typeof c.d=="number"?c.d:c.w))))}if(!(r<i)||!(n<a))return null;var h={left:r,top:n,w:i-r,h:a-n};return u&&(h.z=s,h.d=l-s),h};W.prototype._objectCentroid=function(e){var t=this._centerOf(this.declaredOf(e));if(t)return t;var r=e&&e.rect;return r?ji(r):null};W.prototype.getUniverseBounds=function(){var e=Ke.worldRect(this.canvas_rect,"FrqtlApp.getUniverseBounds canvas_rect"),t=e.w,r=e.h;return{width:t,height:r,zHalf:Math.min(t,r)/2}};W.prototype._clampToUniverseCube=function(e){var t=this.getUniverseBounds(),r=Math.max(0,Math.min(t.width,e[0])),n=Math.max(0,Math.min(t.height,e[1])),i=Math.max(-t.zHalf,Math.min(t.zHalf,e[2]!=null?e[2]:0));return[r,n,i]};W.HOVER_MARGIN=6;W.HEADING_HOLD_EPS=.05;W.HEADING_WRITE_EPS_DEG=1e-6;W.Z_HOLD_EPS=1e-6;W.RENAME_REFUSAL="the key is the name \u2014 a rename is a new key in `parts` (with every reference to it, in code) or a fork of the sketch; a hand never writes a `name` into an entry.";var zg="off",ix="roaming",ax="grab-ready",ox="grabbed";W.prototype.setAimArmed=function(e){if(!e){if(!this._aim)return;this._aim.unsubscribePose(),this._aim=null,this._notifyAim();return}if(!this._aim){var t=this.cameraControl;if(vo(t)){if(typeof t.addPoseListener!="function"||typeof t.cameraOffsetFromWorld!="function"||typeof t.worldFromCameraOffset!="function")throw new Error("[FrqtlApp.setAimArmed] the angular camera handle lacks addPoseListener / cameraOffsetFromWorld / worldFromCameraOffset \u2014 the aim follows the camera through its pose notice and reads the ray off the offset pair (RENDERER_CONTRACT \xA71a.2). (FAIL-LOUD.)");var r=this;this._aim={cam:t,hover:null,grab:null,atEdge:!1,headingHeld:!1,zHeld:!1,error:null,last:null,unsubscribePose:null},this._aim.unsubscribePose=t.addPoseListener(function(){r._onAimPose()}),this._refreshHover(),this._notifyAim()}}};W.prototype.isAimArmed=function(){return!!this._aim};W.prototype.getAimState=function(){var e=this._aim;return e?{state:e.grab?ox:e.hover?ax:ix,hover:e.hover?e.hover.name||"":null,grabbed:e.grab?e.grab.object.name||"":null,atEdge:!!(e.grab&&e.atEdge),headingHeld:!!(e.grab&&e.headingHeld),zHeld:!!(e.grab&&e.zHeld),error:e.error}:{state:zg,hover:null,grabbed:null,atEdge:!1,headingHeld:!1,zHeld:!1,error:null}};W.prototype.getGrabbedObject=function(){return this._aim&&this._aim.grab?this._aim.grab.object:null};W.prototype.addAimListener=function(e){var t=this._aimListeners||(this._aimListeners=[]);return t.indexOf(e)===-1&&t.push(e),function(){var r=t.indexOf(e);r!==-1&&t.splice(r,1)}};W.prototype._notifyAim=function(){var e=this.getAimState();this._aim&&(this._aim.last=JSON.stringify(e));for(var t=(this._aimListeners||[]).slice(),r=0;r<t.length;r++)t[r](e)};W.prototype._notifyAimIfChanged=function(){this._aim&&JSON.stringify(this.getAimState())===this._aim.last||this._notifyAim()};W.prototype.grabToggle=function(){var e=this._aim;if(!e)return zg;if(e.error=null,e.grab)this._releaseGrab();else if(this._refreshHover(),e.hover)try{e.grab=this._captureGrab(e.hover),e.atEdge=!1,e.headingHeld=!1,e.zHeld=!1}catch(t){e.grab=null,e.error="the object cannot be grabbed: "+(t&&t.message?t.message:t)}return this._notifyAim(),this.getAimState().state};W.prototype._releaseGrab=function(){this._aim&&(this._aim.grab=null,this._aim.atEdge=!1,this._aim.headingHeld=!1,this._aim.zHeld=!1)};W.prototype.setSelectHighlight=function(e){this._selected=e||null;var t=this._aim;t&&t.grab&&t.grab.object!==this._selected&&(this._releaseGrab(),t.error=null,this._notifyAim())};W.prototype._captureGrab=function(e){var t=this._aim.cam;this._placementAuthority(e);var r=this.centerOf(e),n=this._orientationOf(e),i={object:e,off:t.cameraOffsetFromWorld(r),oriTarget:n,hCam:null};if(n&&typeof n.getOrientation=="function"){var a=(n.getOrientation()||0)*Math.PI/180,s=t.cameraOffsetFromWorld([0,0,0]),l=t.cameraOffsetFromWorld([Math.cos(a),Math.sin(a),0]);i.hCam={right:l.right-s.right,up:l.up-s.up,forward:l.forward-s.forward}}return i};W.prototype._onAimPose=function(){this._aim&&this._aim.grab&&this._carryGrab(),this._refreshHover(),this._notifyAimIfChanged()};W.prototype._carryGrab=function(){var e=this._aim,t=e.grab,r=e.cam;try{var n=r.worldFromCameraOffset(t.off),i=this._clampToUniverseCube(n);e.atEdge=Math.abs(i[0]-n[0])+Math.abs(i[1]-n[1])+Math.abs(i[2]-n[2])>1e-6;var a=this.placeDeclaredAt(t.object,i);if(e.zHeld=a.zHeld,t.off=r.cameraOffsetFromWorld(a.zHeld?[i[0],i[1],0]:i),t.hCam){var s=r.worldFromCameraOffset({right:0,up:0,forward:0}),l=r.worldFromCameraOffset(t.hCam),u=l[0]-s[0],f=l[1]-s[1];if(e.headingHeld=Math.hypot(u,f)<W.HEADING_HOLD_EPS,!e.headingHeld){var c=Math.atan2(f,u)*180/Math.PI,h=typeof t.oriTarget.getOrientation=="function"?t.oriTarget.getOrientation():null,g=h===null?1/0:Math.abs(((c-h)%360+540)%360-180);g>W.HEADING_WRITE_EPS_DEG&&t.oriTarget.setOrientation(c)}}}catch(p){this._releaseGrab(),e.error="the grabbed object could not follow the camera: "+(p&&p.message?p.message:p),this._notifyAim()}};W.prototype._aimVolume=function(e,t){var r=Li,n=this._centerOf(t===void 0?this.declaredOf(e):t);if(n){var i=e.rect?Math.max(e.rect.w||0,e.rect.h||0)/2:0;return r.drawnVolume({center:n,radius:i})}return e.rect?r.drawnVolume(e):null};W.prototype._declaredVolume=function(e){var t=this.membersOf(e);if(t.length===1||this._centerOf(e))return t.length?this._aimVolume(t[0],e):null;var r=this.envelopeOf(e);return r?Ac({rect:r}):null};W.prototype._isDeclaredAimable=function(e){for(var t=this.membersOf(e),r=0;r<t.length;r++)if(this._isAimable(t[r]))return!0;return!1};W.prototype._isAimable=function(e){return!!e&&!e.backdrop&&e.visible!==!1&&this._isShellVisible(e)};W.prototype._centerRay=function(){var e=this._aim.cam,t=e.worldFromCameraOffset({right:0,up:0,forward:0}),r=e.worldFromCameraOffset({right:0,up:0,forward:1});return{origin:t,dir:[r[0]-t[0],r[1]-t[1],r[2]-t[2]]}};W.prototype._refreshHover=function(){var e=this._aim;if(e){for(var t=this.largeObjects,r=[],n=[],i=0;i<t.length;i++)if(this._isAimable(t[i])){var a=this.declaredOf(t[i]);if(a){var s=this._aimVolume(t[i],a);s&&(r.push(a),n.push(s))}}var l=this._centerRay(),u=Tc(l.origin,l.dir,n,W.HOVER_MARGIN),f=u?r[u.index]:null;f!==e.hover&&(e.error=null),e.hover=f}};var Vg="aimFeedback";W.RUNNER_INJECTED_RENDER_KEYS=Object.freeze([Vg]);W.prototype._computeAimFeedback=function(){var e=this._aim;if(!e)return null;this._refreshHover(),this._notifyAimIfChanged();var t=this;function r(f){var c=f&&t._declaredVolume(f);return c?{name:f.name||"",volume:c}:null}o(r,"mark");var n={bounds:this.getUniverseBounds(),state:this.getAimState().state},i=r(e.grab?e.grab.object:e.hover);i&&(n.hover=i);var a=this._selected&&this._isDeclaredAimable(this._selected)?r(this._selected):null;a&&(n.selected=a),e.grab&&i&&(n.grabbed=i);var s=e.grab?e.grab.object:this._selected,l=this._orientationOf(s),u=s?this._declaredVolume(s):null;return l&&u&&typeof l.getOrientation=="function"&&(n.orientation={pivot:u.center,deg:l.getOrientation()||0}),n};W.prototype._renderOptsWithFeedback=function(){var e=this._computeAimFeedback();if(!e)return this._renderOptions;var t=Object.assign({},this._renderOptions);return t[Vg]=e,t};W.prototype.screenPointOf=function(e,t,r,n){var i=this.renderer;if(!i||typeof i.screenToWorld!="function")throw new Error("[FrqtlApp.screenPointOf] the active renderer provider has no screenToWorld capability (RENDERER_CONTRACT) \u2014 world\u2192screen is its adjoint and has no other source. (FAIL-LOUD.)");for(var a=typeof e[2]=="number"?e[2]:0,s=n?n[0]:t/2,l=n?n[1]:r/2,u=0;u<8;u++){var f=i.screenToWorld(s,l,t,r,a),c=i.screenToWorld(s+1,l,t,r,a),h=i.screenToWorld(s,l+1,t,r,a);if(!f||!c||!h)return null;var g=c.x-f.x,p=h.x-f.x,m=c.y-f.y,b=h.y-f.y,y=g*b-p*m;if(!y)return null;var w=e[0]-f.x,O=e[1]-f.y,S=(b*w-p*O)/y,A=(g*O-m*w)/y;if(s+=S,l+=A,Math.abs(S)+Math.abs(A)<.05)break}var C=i.screenToWorld(s,l,t,r,a);return!C||Math.abs(C.x-e[0])+Math.abs(C.y-e[1])>.5?null:[s,l]};W.PICK_RADIUS_PX=32;W.PICK_DRIVE_PRIORITY=2;W.prototype.pickObjectAtScreen=function(e,t,r,n){var i=this.renderer;if(!i||typeof i.screenToWorld!="function")return null;for(var a=this.largeObjects,s=null,l=1/0,u=0;u<a.length;u++){var f=a[u],c=this.declaredOf(f);if(c){var h=this._objectCentroid(f);if(h){var g=this.screenPointOf(h,r,n,[e,t]);if(g){var p=typeof c.getCenter=="function",m=Math.hypot(g[0]-e,g[1]-t)/(p?W.PICK_DRIVE_PRIORITY:1);m<l&&(l=m,s=c)}}}}return l<=W.PICK_RADIUS_PX?s:null};W.prototype.setUniverseProperty=function(e,t){var r=Ke;if(!r)throw new TypeError('[FrqtlApp.setUniverseProperty] ObjectSchema is unavailable \u2014 cannot validate "'+e+'" (FAIL-LOUD: never write to the universe unvalidated).');var n=r.get("Universe");if(!n)throw new TypeError('[FrqtlApp.setUniverseProperty] Unknown object kind "Universe"');for(var i=null,a=0;a<n.fields.length;a++)if(n.fields[a].name===e){i=n.fields[a];break}if(!i)throw new TypeError('[FrqtlApp.setUniverseProperty] Property "'+e+'" is not in the schema for kind "Universe". Valid properties: '+n.fields.map(function(s){return s.name}).join(", "));if(i.type==="readonly")throw new TypeError('[FrqtlApp.setUniverseProperty] Property "'+e+'" is readonly for kind "Universe"');this.universe[e]=t};W.prototype.getUniverseProperty=function(e){var t=Ke;if(t){var r=t.get("Universe");if(r){for(var n=null,i=0;i<r.fields.length;i++)if(r.fields[i].name===e){n=r.fields[i];break}if(!n)throw new TypeError('[FrqtlApp.getUniverseProperty] Property "'+e+'" is not in the schema for kind "Universe". Valid properties: '+r.fields.map(function(a){return a.name}).join(", "))}}return this.universe[e]};W.prototype.moveLargeObject=function(e,t,r,n,i){if(!(!e||!e.rect)){var a=n!==void 0?n:e.rect.w,s=i!==void 0?i:e.rect.h;this.updateObjectProperty(e,"rect",[t,r,a,s])}};W.prototype.createCanvas=function(){this._createCanvasCalled=!0;var e=this._getRenderer();if(e&&e.init){var t={parentEl:this._canvasParentId,width:this.canvas_rect.w,height:this.canvas_rect.h,is3D:this._is3D};this._depth!==null&&(t.depth=this._depth);var r=Io,n=r.requireSceneSurface("FrqtlApp.createCanvas",e.init(t));return n.setAttribute(r.SCENE_SURFACE_ATTR,""),this._sceneSurface=n,this._onReady&&this._onReady(this),n}throw new Error("[FrqtlApp.createCanvas] no RendererProvider is active \u2014 one is selected by the boot module (lib/frqtl/experiments/_shared/boot.js) \u2014 a page boots through bootPage(), a programmatic host awaits bootRealm() \u2014 before calling createCanvas().")};W.prototype.setup=function(e,t){t=t||{},this._aim&&this.setAimArmed(!1),this._selected=null,this._setupResult&&typeof this._setupResult.dispose=="function"&&this._setupResult.dispose();var r=this;return this.retainSceneReplay(function(){return r.setup(e,t)}),this.clearDeclared(),Pg(e,"setup"),typeof e.initWorld=="function"&&e.initWorld(this.universe,t),this._setupResult=e(this.universe,t),this._setupResult};W.prototype.retainSceneReplay=function(e){if(typeof e!="function")throw new TypeError("[FrqtlApp] retainSceneReplay(fn) takes the scene's replay function; got "+(e===null?"null":typeof e)+". (FAIL-LOUD.)");this._sceneReplay=e};W.prototype.restart=function(){if(typeof this._sceneReplay!="function")throw new Error("[FrqtlApp] restart(): nothing to replay \u2014 no scene has been built on this runner. Build one first with runner.setup(factory, opts) or RecipeContext.build(sketch). (FAIL-LOUD \u2014 a restart with nothing to replay would silently do nothing.)");this.stop();var e=this;function t(n){return e.beginWorld(),e.start(),n}o(t,"resume");var r;try{r=this._sceneReplay()}catch(n){return Promise.reject(n)}return r&&typeof r.then=="function"?r.then(t):Promise.resolve(t(r))};W.prototype._getRenderer=function(){if(!this._renderer){var e=ch();if(e){var t=this._stagedRenderOptions?Mg(e,this._stagedRenderOptions):null;this._createCanvasCalled||e.setSize(this.canvas_rect.w,this.canvas_rect.h),this._renderer=e,t&&(this._stagedRenderOptions=null,this._applyRenderWrites(t))}}return this._renderer||null};Object.defineProperty(W.prototype,"cameraControl",{configurable:!0,get:o(function(){if(!this._cameraControl){var e=this._getRenderer();e&&typeof e.getCameraControl=="function"&&(this._cameraControl=e.getCameraControl())}return this._cameraControl||null},"get")});W.prototype._failLoudMissingRenderer=function(){var e=`FrqtlApp: the DISPLAY SLOT is empty (FrqtlDisplay.get() === null).
|
|
16
|
+
`+E,document.body.appendChild(I)}typeof console<"u"&&console.error("[three-provider] render.mesh: "+E)}o(mo,"_meshFailLoud");function go(E){if(!Ce[E]){if(typeof t.GLTFLoader>"u"){Ce[E]={status:"error",scene:null,norm:1,error:"loaders-missing"},mo("THREE.GLTFLoader is undefined \u2014 the mesh experiment must boot with bootRealm({ meshLoaders: true }) so the UMD loaders load after three.");return}if(!Ue){var I=new t.GLTFLoader;if(typeof t.DRACOLoader<"u"){var z=Uf(),G=new t.DRACOLoader;G.setDecoderPath(z+"/draco/"),I.setDRACOLoader(G)}Ue=I}Ce[E]={status:"loading",scene:null,norm:1,error:null},Ue.load(E,function(U){var fe=U.scene||U.scenes&&U.scenes[0];if(!fe){Ce[E]={status:"error",scene:null,norm:1,error:"no-scene"},mo("glTF loaded but has no scene: "+E);return}var re=new t.Box3().setFromObject(fe),Ge=new t.Vector3;re.getSize(Ge);var rt=new t.Vector3;re.getCenter(rt);var Ne=Math.max(Ge.x,Ge.y,Ge.z)||1;fe.position.sub(rt);var Fe=new t.Group;Fe.add(fe),Ce[E]={status:"ready",scene:Fe,norm:1/Ne,error:null}},void 0,function(U){Ce[E]={status:"error",scene:null,norm:1,error:String(U)},mo("failed to load render.mesh asset: "+E+`
|
|
17
|
+
`+String(U))})}}o(go,"_ensureMeshLoaded");function Ps(E,I,z,G,U){xe||(xe=new t.Group,xe.frustumCulled=!1,c.add(xe));for(var fe=Ve[U]||(Ve[U]=[]),re=typeof G=="number"&&G>0?G:1,Ge=z&&I?I.length:0,rt=0;rt<Ge;rt++){var Ne=I[rt],Fe=fe[rt];Fe||(Fe=E.scene.clone(!0),Fe.frustumCulled=!1,fe[rt]=Fe,xe.add(Fe));var it=Ne.data&&Ne.data.string_map,He=re;if(it&&it["render.meshScale"]!=null){var Pe=Number(it["render.meshScale"]);!isNaN(Pe)&&Pe>0&&(He=Pe)}var kt=(Ne.rect&&Ne.rect.w?Ne.rect.w:1)*E.norm*He;if(Fe.scale.setScalar(kt),Fe.position.set(Ne.rect.x,Ne.rect.y,Ne.z||0),Fe.userData.frameLayer=Ne.layer,it&&it["render.meshRotation"]!=null){var Ie=String(it["render.meshRotation"]).split(",").map(Number);Ie.length>=3&&Ie.every(function(St){return!isNaN(St)})?Fe.rotation.set(Ie[0],Ie[1],Ie[2]):Fe.rotation.set(0,0,0)}else Fe.rotation.set(0,0,0);Fe.visible=!0}for(var nt=Ge;nt<fe.length;nt++)fe[nt]&&(fe[nt].visible=!1);return Ge>0&&xe&&(xe.visible=!0),Ge}o(Ps,"_layoutMeshClones");function Is(E){for(var I in Ve)if(Ve.hasOwnProperty(I)&&!(E&&E.indexOf(I)!==-1))for(var z=Ve[I],G=0;G<z.length;G++)z[G]&&(z[G].visible=!1)}o(Is,"_hideMeshClonesExcept");function Jc(E,I){if(E){for(var z=new Set,G=0;G<E.length;G++){var U=E[G];z.add(U);var fe=fo(U,I),re=H.get(U);if(!re||re.sig!==fe){re&&re.mesh&&c.remove(re.mesh);var Ge=po(U,I);re={mesh:Ge,sig:fe,skinSig:null},H.set(U,re),c.add(Ge)}var rt=mx(U);re.skinSig!==rt&&(re.mesh&&re.mesh.material&&gx(re.mesh.material,U),re.skinSig=rt);var Ne=Vn(U.rect);re.mesh.position.set(Ne[0],Ne[1],Ne[2]);var Fe=typeof U.orientationDeg=="number"?(U.orientationDeg%360+360)%360:0,it=typeof U.pitchDeg=="number"?U.pitchDeg:0;if(U.billboard||(re.mesh.rotation.order="ZYX",re.mesh.rotation.z=Fe*Math.PI/180,re.mesh.rotation.y=it*Math.PI/180),U.billboard&&f&&re.mesh.quaternion.copy(f.quaternion),U.liveCanvas&&re.mesh&&re.mesh.material){for(var He=ua(U),Pe=re.mesh.userData||(re.mesh.userData={}),kt=Pe.liveCanvasFaces||[{index:-1,mirrorU:!1,mirrorV:!1}],Ie=0;Ie<kt.length;Ie++){var nt=kt[Ie],St=nt.index>=0&&Array.isArray(re.mesh.material)?re.mesh.material[nt.index]:re.mesh.material;if(St)if(He&&(Pe.liveCanvasSrc!==He||!St.map)){if(St.map)try{St.map.dispose()}catch{}St.map=fi(He,nt),St.color&&St.color.setRGB(1,1,1),St.transparent=!0,St.needsUpdate=!0}else He&&St.map&&(St.map.needsUpdate=!0)}He&&(Pe.liveCanvasSrc=He)}re.mesh.visible=U.visible!==!1}H.forEach(function(dr,Jt){z.has(Jt)||(dr.mesh.visible=!1)})}}o(Jc,"_syncLargeObjects");function Qc(E){if(!(!E||!E.frameData||!se)){var I=Er.buildHeightField(E.frameData,Object.assign({},Er.FIELD_OPTS,{canvasW:a(),canvasH:s()}));se.set(I),zt.needsUpdate=!0}}o(Qc,"_updateFieldTex");function Xc(E){var I=E.name||"filter";if(Et[I])return Et[I];var z=E.glsl,G=new t.ShaderMaterial({uniforms:{uScene:{value:ve.texture},uField:{value:zt},uResolution:{value:new t.Vector2(a(),s())},uTime:{value:0}},vertexShader:Gg,fragmentShader:z,transparent:!1,depthWrite:!1}),U=new t.Mesh(new t.PlaneGeometry(2,2),G);return ct.add(U),Et[I]=U,U}o(Xc,"_ensureQuadMesh");function Zc(E,I){var z=E.name||"filter",G=Xc(E);G.material.uniforms.uTime.value=I,G.material.uniforms.uResolution.value.set(a(),s()),l.setRenderTarget(ve),l.render(c,f),l.setRenderTarget(null),G.material.uniforms.uScene.value=ve.texture,G.material.uniforms.uField.value=zt,l.render(ct,Kt)}o(Zc,"_applyFilter");function $c(E){var I=us,z=I.fundamentalLayerOf(E),G=[],U=null,fe=[];function re(Pe){Pe&&Pe.visible&&(Pe.visible=!1,G.push(Pe))}o(re,"hide");for(var Ge in x)x.hasOwnProperty(Ge)&&!I.isGodraySource(x[Ge].layer,z)&&re(x[Ge].mesh);V&&V.visible&&(U=V.count,V.count=Qr);for(var rt in Ve)if(Ve.hasOwnProperty(rt))for(var Ne=Ve[rt],Fe=0;Fe<Ne.length;Fe++)Ne[Fe]&&!I.isGodraySource(Ne[Fe].userData.frameLayer,z)&&re(Ne[Fe]);H.forEach(function(Pe){Pe.mesh&&Pe.mesh.traverse(function(kt){for(var Ie=kt.material?Array.isArray(kt.material)?kt.material:[kt.material]:[],nt=0;nt<Ie.length;nt++)Ie[nt]&&Ie[nt].colorWrite!==!1&&(Ie[nt].colorWrite=!1,fe.push(Ie[nt]))})}),l.setRenderTarget(ot.rtSource),l.render(c,f);for(var it=0;it<G.length;it++)G[it].visible=!0;U!==null&&(V.count=U);for(var He=0;He<fe.length;He++)fe[He].colorWrite=!0}o($c,"_renderGodraySource");function eu(E,I){var z=us,G=z.resolveGodraySource(E.godraySource)==="leaf";ot||(ot=z.makeGodrayPasses(t,Gg,a(),s())),l.setRenderTarget(ve),l.render(c,f),G&&$c(I),ot.march(l,Kt,ve,G?ot.rtSource:ve,Lt,ot.lightUV(I,f,E.godraySource),E.godrayDensity,E.godrays)}o(eu,"_renderGodrays");var tu=16724991,ha=16755200,Fs=3407769;function On(E){var I=new t.BufferGeometry;return I.setAttribute("position",new t.BufferAttribute(new Float32Array(E),3)),I}o(On,"_lineGeo");function Zi(E,I){var z=new t.LineSegments(E,new t.LineBasicMaterial({color:I,depthTest:!1,transparent:!0,opacity:1}));return z.renderOrder=9999,z.frustumCulled=!1,z}o(Zi,"_overlayLines");function pa(E,I,z){for(var G=[],U=0;U<I;U++){var fe=U/I*Math.PI*2,re=(U+1)/I*Math.PI*2;G.push(E*Math.cos(fe),E*Math.sin(fe),z||0,E*Math.cos(re),E*Math.sin(re),z||0)}return G}o(pa,"_circlePts");function Ns(){var E=new t.BoxGeometry(1,1,1),I=o(function(){return new t.MeshBasicMaterial({color:0,transparent:!0,opacity:.38,depthTest:!1,depthWrite:!1,side:t.DoubleSide})},"dark"),z=new t.Mesh(E,I());z.add(Zi(new t.EdgesGeometry(E),ha));var G=new t.Mesh(new t.CircleGeometry(1,48),I());return G.add(Zi(On(pa(1,48)),ha)),[z,G].forEach(function(U){U.renderOrder=9997,U.frustumCulled=!1,U.visible=!1,ce.add(U)}),{box:z,disc:G}}o(Ns,"_makeSurround");function vo(E,I,z){var G=I.center;if(I.kind==="sphere"){var U=I.radius+z;return E.disc.position.set(G[0],G[1],G[2]),E.disc.quaternion.copy(f.quaternion),E.disc.scale.setScalar(U),E.disc.visible=!0,E.box.visible=!1,U}return E.box.position.set(G[0],G[1],G[2]),E.box.rotation.order="ZYX",E.box.rotation.z=(I.yawDeg||0)*Math.PI/180,E.box.rotation.y=(I.pitchDeg||0)*Math.PI/180,E.box.scale.set(2*(I.half[0]+z),2*(I.half[1]+z),2*(I.half[2]+z)),E.box.visible=!0,E.disc.visible=!1,Math.hypot(I.half[0],I.half[1],I.half[2])+z}o(vo,"_placeSurround");function da(E){E&&(E.box.visible=!1,E.disc.visible=!1)}o(da,"_hideSurround");function ru(E){var I=E&&E.aimFeedback;if(!h||!I||!I.bounds){N&&(N.visible=!1),ie&&(ie.visible=!1),oe&&(oe.visible=!1),$&&($.visible=!1),da(pe),da(ye);return}ce||(ce=new t.Scene);var z=I.bounds.width,G=I.bounds.height,U=I.bounds.zHalf,fe=z+"x"+G+"x"+U,re=Math.max(4,Math.min(z,G)*.06);if(!N||B!==fe){[N,ie,oe,$].forEach(function(ji){ji&&(ce.remove(ji),ji.geometry.dispose())});var Ge=new t.BoxGeometry(z,G,Math.max(1,2*U));N=new t.LineSegments(new t.EdgesGeometry(Ge),new t.LineBasicMaterial({color:6737151,transparent:!0,opacity:.5,depthTest:!1})),N.renderOrder=9998,N.frustumCulled=!1,ce.add(N),Ge.dispose();var rt=re*.25;ie=Zi(On([-re,0,0,-rt,0,0,rt,0,0,re,0,0,0,-re,0,0,-rt,0,0,rt,0,0,re,0].concat(pa(re*.55,32))),tu),ce.add(ie);var Ne=re*1.6,Fe=Ne*1.35,it=Ne*.22;oe=Zi(On(pa(Ne,48).concat([0,0,0,Fe,0,0,Fe,0,0,Fe-it,it*.6,0,Fe,0,0,Fe-it,-it*.6,0])),ha),ce.add(oe);for(var He=re*.45,Pe=re*.4,kt=[-He,-Pe,0,He,-Pe,0,He,-Pe,0,He,Pe*.4,0,He,Pe*.4,0,-He,Pe*.4,0,-He,Pe*.4,0,-He,-Pe,0],Ie=He*.62,nt=0;nt<12;nt++){var St=nt/12*Math.PI,dr=(nt+1)/12*Math.PI;kt.push(Ie*Math.cos(St),Pe*.4+Ie*.3+Ie*Math.sin(St),0,Ie*Math.cos(dr),Pe*.4+Ie*.3+Ie*Math.sin(dr),0)}kt.push(Ie,Pe*.4,0,Ie,Pe*.4+Ie*.3,0,-Ie,Pe*.4,0,-Ie,Pe*.4+Ie*.3,0),$=Zi(On(kt),Fs),ce.add($),pe||(pe=Ns(),ye=Ns()),B=fe}N.position.set(z/2,G/2,0),N.visible=!0;var Jt=Math.max(a(),s())*1.6,jt=Jt>0&&m.distance>0?m.distance/Jt:1,pi=ps(m,a(),s());ie.position.set(pi.x,pi.y,pi.z),ie.quaternion.copy(f.quaternion),ie.scale.setScalar(jt),ie.visible=!0;var Nr=4*jt,Xr=I.hover?vo(pe,I.hover.volume,Nr):0;if(I.hover||da(pe),I.selected&&!(I.hover&&I.hover.name===I.selected.name)?vo(ye,I.selected.volume,Nr):da(ye),I.grabbed&&I.hover){var mr=I.hover.volume.center,jr=f.up,Mr=Xr+re*.8*jt;$.position.set(mr[0]+jr.x*Mr,mr[1]+jr.y*Mr,mr[2]+jr.z*Mr),$.quaternion.copy(f.quaternion),$.scale.setScalar(jt),$.visible=!0}else $.visible=!1;var gt=I.orientation;gt&>.pivot&&(oe.position.set(gt.pivot[0],gt.pivot[1],gt.pivot[2]!=null?gt.pivot[2]:0),oe.rotation.z=(gt.deg||0)*Math.PI/180,oe.scale.setScalar(jt)),oe.visible=!!(gt&>.pivot)}o(ru,"_updateAimFeedback");function Ms(){if(!(!ce||!N||!N.visible)){var E=l.autoClear;l.autoClear=!1,l.setRenderTarget(null),l.render(ce,f),l.autoClear=E}}o(Ms,"_renderAimFeedbackPass");function yo(E,I,z){if(Yt){hr=E,ru(z||{}),Jc(I,z||{});var G=z||{},U=G.renderBaseCanvas!==!1;_n=Object.assign({},G),xn=U;var fe=ut.length>0,re=G.glowIntensity,Ge=Ei,rt=ai,Ne=rt.resolve(null,G),Fe=h?$a.resolve(null,G):null,it=!!Fe,He=!it&&h&&rt.isCubeMesh(Ne);if(!it&&xe&&(xe.visible=!1),it){Q(),V&&(V.visible=!1),go(Fe);var Pe=Ce[Fe],kt=0;Pe&&Pe.status==="ready"&&(kt=Ps(Pe,E.frameData,G.renderBaseCanvas!==!1,G.meshScale,Fe)),Is([Fe]),xe&&(xe.visible=kt>0)}else if(He)if(Q(),U&&E&&E.frameData){for(var Ie=E.frameData,nt=Ie.length,St=G.colorScheme||"warmcool",dr=64,Jt=0;Jt<nt;Jt++)if(Ie[Jt].rect&&Ie[Jt].rect.w){dr=Ie[Jt].rect.w;break}Yc(dr,nt);for(var jt=us,pi=jt.fundamentalLayerOf(E),Nr=[],Xr=0;Xr<nt;Xr++)jt.isGodraySource(Ie[Xr].layer,pi)&&Nr.push(Xr);Qr=Nr.length;for(var mr=0;mr<nt;mr++)jt.isGodraySource(Ie[mr].layer,pi)||Nr.push(mr);for(var jr=0,Mr=0;Mr<nt;Mr++){var gt=Ie[Nr[Mr]],ji=gt.fullness||0,Ur=gt.data&>.data.string_map,En=null;if(Ur&&Ur["render.color"]){var Qt=String(Ur["render.color"]).split(",").map(Number);Qt.length>=3&&Qt.every(function(Pi){return!isNaN(Pi)})&&(En=Qt)}var di=Ur&&Ur["render.colorScheme"]?Ur["render.colorScheme"]:St,Sn=En||Ge.getRgbBySchemeName(di,ji),Rr=gt.rect.x,Ri=gt.rect.y,Us=gt.z||0;R.makeTranslation(Rr,Ri,Us),V.setMatrixAt(jr,R),K.setRGB((Sn[0]||0)/255,(Sn[1]||0)/255,(Sn[2]||0)/255),V.setColorAt(jr,K),jr++}V.count=jr,V.instanceMatrix.needsUpdate=!0,V.instanceColor&&(V.instanceColor.needsUpdate=!0),V.visible=U&&jr>0}else V&&(V.visible=!1);else if(V&&(V.visible=!1),Q(),U&&E&&E.frameData){let Pi=function(_o,ya,xo,Ks,Ys,Js,ba,lu,wa,Qs,Oo,cu){var rn=Di[ya];rn||(rn=Di[ya]={layer:_o,additive:xo,paint:Ks,uShape:cu,list:[]}),rn.list.push({x:Ys,y:Js,z:ba,full:lu,r:wa[0]||0,g:wa[1]||0,b2:wa[2]||0,a:Qs,size:Oo})};o(Pi,"_pushTo");var kn=E.frameData,zs=kn.length,qs=Ge,nu=rt,Vs=typeof G.smoke=="number"&&G.smoke>0,au=Vs?G.smoke:0,ou=G.colorScheme||"warmcool";d=nu.toUniform(Ne);for(var Bs=typeof re=="number"&&re>0,An={},Di={},qt=0;qt<zs;qt++){var rr=kn[qt],Zr=rr.layer||0,mi=Ug.resolveRenderFamily(rr,G,h);if(mi.family==="mesh"){(An[mi.assetId]||(An[mi.assetId]=[])).push(rr);continue}var $r=rr.fullness||0,Dr=rr.data&&rr.data.string_map,Li=null;if(Dr&&Dr["render.color"]){var ga=String(Dr["render.color"]).split(",").map(Number);ga.length>=3&&ga.every(function(xo){return!isNaN(xo)})&&(Li=ga)}var su=Dr&&Dr["render.colorScheme"]?Dr["render.colorScheme"]:ou,$i=rr.z||0,Rr=rr.rect.x,Ri=rr.rect.y,bo=rr.rect&&rr.rect.w?rr.rect.w:1,en=qs.getAlphaFromIntensity($r),Tn=Li||qs.getRgbBySchemeName(su,$r),Cn=Bs?4*$r+1:bo;if(Bs)Pi(Zr,Zr+"|A",!0,"crisp",Rr,Ri,$i,$r,Tn,en,Cn);else if(Vs)Pi(Zr,Zr+"|N|soft",!1,"soft",Rr,Ri,$i,$r,Tn,en,Cn);else if(mi.family==="sphere")Pi(Zr,Zr+"|N|sphere",!1,"sphere",Rr,Ri,$i,$r,Tn,en,Cn,0);else{var Ws=mi.family==="cube"?1:mi.uShapeVariant!=null?mi.uShapeVariant:0;Pi(Zr,Zr+"|N|pts:"+Ws,!1,"crisp",Rr,Ri,$i,$r,Tn,en,Cn,Ws)}}var jn=[];for(var ei in Di)if(Di.hasOwnProperty(ei)){var Lr=Di[ei],gr=Lr.list.length;if(gr!==0){jn.push(ei);var Re=T(ei,Lr.additive,Lr.paint);j(Re,gr),Re.layer=Lr.layer;var ir=0,zr=0,qr=0;if(Re.isSphere){for(var Rn=0;Rn<gr;Rn++){var Xt=Lr.list[Rn];X.set(Xt.x,Xt.y,Xt.z),be.set(Xt.size,Xt.size,Xt.size),ee.compose(X,te,be),Re.mesh.setMatrixAt(Rn,ee),Oe.setRGB(Xt.r/255,Xt.g/255,Xt.b2/255),Re.mesh.setColorAt(Rn,Oe),ir+=Xt.x,zr+=Xt.y,qr+=Xt.z}Re.mesh.count=gr,Re.mesh.instanceMatrix.needsUpdate=!0,Re.mesh.instanceColor&&(Re.mesh.instanceColor.needsUpdate=!0)}else{for(var nr=0;nr<gr;nr++){var vr=Lr.list[nr];Re.bufs.posArr[nr*3]=vr.x,Re.bufs.posArr[nr*3+1]=vr.y,Re.bufs.posArr[nr*3+2]=vr.z,Re.bufs.fullArr[nr]=vr.full,Re.bufs.colArr[nr*3]=vr.r/255,Re.bufs.colArr[nr*3+1]=vr.g/255,Re.bufs.colArr[nr*3+2]=vr.b2/255,Re.bufs.alphaArr[nr]=vr.a,Re.bufs.sizeArr[nr]=vr.size,Re.bufs.smokeArr[nr]=Lr.paint==="soft"?1:0,ir+=vr.x,zr+=vr.y,qr+=vr.z}Re.geo.setDrawRange(0,gr),Re.geo.attributes.position.needsUpdate=!0,Re.geo.attributes.aFullness.needsUpdate=!0,Re.geo.attributes.aColor.needsUpdate=!0,Re.geo.attributes.aAlpha.needsUpdate=!0,Re.geo.attributes.aSize.needsUpdate=!0,Re.geo.attributes.aSmoke.needsUpdate=!0,Re.mat.uniforms.uPersp.value=h?1:0,Re.mat.uniforms.uShape&&(Re.mat.uniforms.uShape.value=Lr.uShape!=null?Lr.uShape:d),Lr.additive?(Re.mat.uniforms.uIntensity.value=typeof re=="number"?re:1,Re.mat.uniforms.uHeat.value=typeof G.heat=="number"?G.heat:0,Re.mat.uniforms.uSmoke.value=0):(Re.mat.uniforms.uIntensity.value=1,Re.mat.uniforms.uHeat.value=typeof G.heat=="number"?G.heat:0,Re.mat.uniforms.uSmoke.value=Lr.paint==="soft"?au:0)}Re.centroid.x=ir/gr,Re.centroid.y=zr/gr,Re.centroid.z=qr/gr,Re.mesh.visible=U}}if(h&&jn.length>1){jn.sort(function(_o,ya){return Y(x[ya].centroid)-Y(x[_o].centroid)});for(var va=0;va<jn.length;va++)x[jn[va]].mesh.renderOrder=va}var Gs=[],Hs=0;for(var tn in An)if(An.hasOwnProperty(tn)){Gs.push(tn),go(tn);var wo=Ce[tn];wo&&wo.status==="ready"&&(Hs+=Ps(wo,An[tn],U,G.meshScale,tn))}Is(Gs),xe&&(xe.visible=Hs>0)}fe&&Qc(E),ma(G,E)}}o(yo,"_renderTick");function ma(E,I){E=E||{};var z=E.godrays>0,G=ut.length>0?Wo(I):null;pr=G,z?eu(E,I):ut.length>0?Zc(ut[0],G):(l.setRenderTarget(null),l.render(c,f)),Ms()}o(ma,"_composeFinal");var iu={init:o(function(E){return tr(E),u},"init"),renderTick:o(function(E,I,z){yo(E,I,z)},"renderTick"),filter:o(function(E,I){if(E){if(E.name){for(var z=0;z<ut.length;z++)if(ut[z].name===E.name){I&&(ut[z]._perFilterOptions=I);return}}var G=E;I&&(G=Object.assign({},E),G._perFilterOptions=I),ut.push(G)}},"filter"),removeFilter:o(function(E){var I=typeof E=="string"?E:E&&E.name;ut=ut.filter(function(z){return z.name!==I}),I&&Et[I]&&(ct.remove(Et[I]),delete Et[I])},"removeFilter"),setSize:o(function(E,I){Wi("threeProvider.setSize",E,I),r=E,i=I,l?(l.setSize(E,I),h?(f.aspect=E/I,b()):(f.right=E,f.bottom=I,f.updateProjectionMatrix()),ve&&ve.setSize(E,I),Lt&&Lt.setSize(E,I),ot&&ot.setSize(E,I)):h&&b()},"setSize"),start:o(function(){},"start"),stop:o(function(){},"stop"),destroy:o(function(){l&&l.dispose(),u&&u.parentNode&&u.parentNode.removeChild(u),Yt=!1,ut=[]},"destroy"),raw:o(function(){return{renderer:l,scene:c,camera:f}},"raw"),projection:o(function(){return h?{kind:"perspective",fovY:hs}:{kind:"affine2d"}},"projection"),captureStill:o(function(){if(!Yt||!l)throw new Error("[three-provider.captureStill] no live renderer \u2014 init() has not run. (FAIL-LOUD \u2014 never a null or blank still.)");if(!hr)throw new Error("[three-provider.captureStill] nothing has been composited yet (no renderTick/repaint since init). A capture before the first draw would be a cleared framebuffer, i.e. a black still. (FAIL-LOUD.)");var E=as;ma(_n,hr);var I=l.getContext(),z=l.domElement,G=E.captureFromGl(I,z.width,z.height,{cssWidth:z.clientWidth||a(),cssHeight:z.clientHeight||s(),physicsW:a(),physicsH:s(),filtersApplied:ut.map(function(U){return U.name}),renderBaseCanvas:xn,filterTime:pr,composited:hr});return Promise.resolve(G)},"captureStill"),getCameraControl:o(function(){if(!h)return null;var E=tp;function I(){return E.cameraPresets(a(),s())}o(I,"_presets");function z(U,fe,re){if(typeof U=="number"&&isFinite(U))return U;throw new Error("three-provider camera "+re+": "+fe+" must be a finite number, got "+String(U)+" \u2014 throw-or-apply, never a silent clamp.")}o(z,"_finite");var G={presets:Object.keys(I()),poseFields:E.cameraPoseFields(a(),s()),setOrbit:o(function(U){if(U){if(U=ko(U),U.azimuth!==void 0&&(m.azimuth=z(U.azimuth,"azimuth","setOrbit")),U.elevation!==void 0&&(m.elevation=z(U.elevation,"elevation","setOrbit")),U.distance!==void 0&&(m.distance=z(U.distance,"distance","setOrbit")),U.roll!==void 0){var fe=z(U.roll,"roll","setOrbit")%360;m.roll=fe>180?fe-360:fe<=-180?fe+360:fe}if("target"in U){var re=U.target;m.target=re?{x:re.x,y:re.y,z:re.z}:null}b()}},"setOrbit"),getOrbit:o(function(){return y()},"getOrbit"),addPoseListener:o(function(U){return w||(w=Ao()),w.add(U)},"addPoseListener"),setPreset:o(function(U){var fe=I(),re=fe[U];if(!re)throw new Error('[three-provider camera] setPreset("'+U+'"): this camera offers only ['+Object.keys(fe).join(", ")+"] (ctl.presets). (FAIL-LOUD.)");G.setOrbit({azimuth:re.azimuth,elevation:re.elevation,distance:re.distance,roll:0,target:null})},"setPreset"),look:o(function(U){if(U){var fe=U.spin===void 0?0:z(U.spin,"spin","look"),re=U.pitch===void 0?0:z(U.pitch,"pitch","look");if(!(!fe&&!re)){var Ge=op(m,{spin:fe,pitch:re},a(),s());m.azimuth=Ge.azimuth,m.elevation=Ge.elevation,m.roll=Ge.roll,b()}}},"look"),move:o(function(U){if(U){var fe=U.forward===void 0?0:z(U.forward,"forward","move"),re=U.strafe===void 0?0:z(U.strafe,"strafe","move");!fe&&!re||(m.target=sp(m,a(),s(),fe,re),b())}},"move"),cameraOffsetFromWorld:o(function(U){return lp(m,a(),s(),U)},"cameraOffsetFromWorld"),worldFromCameraOffset:o(function(U){return cp(m,a(),s(),U)},"worldFromCameraOffset")};return G},"getCameraControl"),renderCapabilities:hp,screenToWorld:o(function(E,I,z,G,U){return h?up(m,a(),s(),E,I,z,G,U):null},"screenToWorld"),get initialized(){return Yt}};return iu}o(Kg,"makeThreeProvider");var ds=Object.freeze({p5:Object.freeze({makeProvider:Dg,renderCapabilities:ep}),three:Object.freeze({makeProvider:Kg,renderCapabilities:hp})});function ms(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}o(ms,"_isPlainObject");function Yg(e){if(!e||!e.camera)return null;var t=e.camera;return typeof t.preset=="string"&&t.preset.length>0?{mode:"preset",name:t.preset}:t.orbit&&typeof t.orbit=="object"?{mode:"orbit",orbit:t.orbit}:null}o(Yg,"pickCameraReplay");var pc=1,pp=Object.freeze([{key:"version",normalize:o(function(e){if(e===void 0||e===pc)return pc;throw new Error("[render-state] renderState.version "+JSON.stringify(e)+" \u2014 this owner reads version "+pc+" only. (FAIL-LOUD.)")},"normalize")},{key:"renderer",normalize:o(function(e){return typeof e=="string"&&e.length>0?e:null},"normalize")},{key:"engine",normalize:o(function(e){return typeof e=="string"&&e.length>0?e:null},"normalize")},{key:"seed",normalize:o(function(e){return e!=null&&e!==""?String(e):null},"normalize")},{key:"backdropVisible",normalize:o(function(e){return typeof e=="boolean"?e:null},"normalize")},{key:"camera",normalize:o(function(e){return ms(e)?{orbit:ms(e.orbit)?e.orbit:null,preset:typeof e.preset=="string"?e.preset:null}:null},"normalize")},{key:"render",normalize:o(function(e){return Array.isArray(e)?e.filter(function(t){return ms(t)&&typeof t.key=="string"&&t.key.length>0}):[]},"normalize")}].map(Object.freeze));function dc(e){if(e!==null&&!ms(e))throw new Error("[render-state] a renderState is a bag (a plain object) or null for none \u2014 got "+(e===void 0?"undefined":Array.isArray(e)?"an array":typeof e)+". (FAIL-LOUD.)");var t=e||{};if(Object.prototype.hasOwnProperty.call(t,"pageControls")){var r=Array.isArray(t.pageControls)?t.pageControls:[];throw new Error("[render-state] this saved project carries page controls (renderState.pageControls: "+(r.map(function(a){return ms(a)?String(a.id):"?"}).join(", ")||"an empty list")+") \u2014 page controls are declared in the sketch's own code; move them into the sketch and save again. (FAIL-LOUD.)")}var i=pp.map(function(a){return a.key});Object.keys(t).forEach(function(a){if(i.indexOf(a)===-1)throw new Error('[render-state] renderState has no key "'+a+'" \u2014 its keys (RENDER_STATE_KEYS): '+i.join(", ")+". (FAIL-LOUD.)")});var n={};return pp.forEach(function(a){n[a.key]=a.normalize(t[a.key])}),n}o(dc,"normalizeSavedRenderState");function Jg(e,t,r){if(!Array.isArray(e)||!Array.isArray(t)||!Array.isArray(r))throw new Error("[render-state] partitionRenderRows(rows, declaredNames, knownNames) takes three arrays. (FAIL-LOUD.)");for(var i={},n=[],a=0;a<e.length;a++){var s=e[a];if(t.indexOf(s.key)!==-1)i[s.key]=s.value;else if(r.indexOf(s.key)!==-1)n.push({key:s.key,value:s.value});else throw new Error('[render-state] saved render option "'+s.key+'" is declared by no registered renderer (known: ['+r.join(", ")+"]). (FAIL-LOUD: a typo or a deleted option would otherwise silently change the picture.)")}return{apply:i,retained:n}}o(Jg,"partitionRenderRows");function vx(e){var t=e&&e.largeObjects;if(!Array.isArray(t))throw new Error("[render-state] RenderState.backdropOf: runner.largeObjects is not the world's census (an array) \u2014 the backdrop is found there and nowhere else. (FAIL-LOUD.)");for(var r=0;r<t.length;r++)if(t[r]&&t[r].backdrop===!0)return t[r];return null}o(vx,"backdropOf");function Qg(e,t,r){if(!e||typeof e.renderCapabilities!="function"||typeof e.setRenderOptions!="function")throw new Error("[render-state] RenderState.apply(runner, bag, env): runner must be a booted FrqtlApp (renderCapabilities + setRenderOptions). (FAIL-LOUD.)");if(!r||!Array.isArray(r.knownNames))throw new Error("[render-state] RenderState.apply(runner, bag, env): env.knownNames must be the page's RenderCapabilitiesCommon.knownRenderCapabilityNames(providers) array. (FAIL-LOUD.)");var i=dc(t),n=Jg(i.render,e.renderCapabilities().map(function(h){return h.name}),r.knownNames),a=Yg(i),s=null,l=null,c=null;if(a){if(s=e.cameraControl,!s)throw new Error("[render-state] the bag declares a camera ("+JSON.stringify(i.camera)+") but the runner has no cameraControl \u2014 a declared view on a display with no pose control would look fine and be wrong. (FAIL-LOUD.)");if(a.mode==="preset"){if(!Array.isArray(s.presets))throw new Error("[render-state] the booted camera publishes no `presets` array \u2014 every getCameraControl() handle declares the presets it offers. (FAIL-LOUD.)");c=a.name,l=s.presets.indexOf(a.name)===-1?"retained":"preset"}else l="orbit"}var f=vx(e);e.setRenderOptions(n.apply),l==="preset"?s.setPreset(a.name):l==="orbit"&&s.setOrbit(a.orbit);var u=null;return f&&i.backdropVisible!==null&&(e.updateObjectProperty(f,"visible",i.backdropVisible),u=i.backdropVisible),{applied:n.apply,retained:n.retained,camera:l,preset:c,backdrop:u}}o(Qg,"apply");un();Va();var io=Object.freeze({SEED:"seed",RENDERER:"renderer",ENGINE:"engine"}),bx=Object.freeze([Object.freeze({key:io.SEED,reader:"lib/frqtl/experiments/empty/index.html",forward:!0}),Object.freeze({key:io.RENDERER,reader:"lib/frqtl/experiments/_shared/boot.js",forward:!0}),Object.freeze({key:io.ENGINE,reader:"lib/frqtl/experiments/_shared/boot.js",forward:!1,why:"the host's own physics-engine selector (e.g. the GYM's Benchmark/Compare engine dropdown) is the SOLE authority for this axis; forwarding an outer ?engine= would let it silently override an explicit host choice, which is exactly the engine-sniffing-from-above-the-shim class of bug this codebase forbids elsewhere"})]),Xg=Object.freeze([Object.freeze({key:"chrome",appliedBy:"lib/frqtl/experiments/_shared/boot.js",forward:!1,acceptedValues:Object.freeze(["canvas"]),why:`chrome is a HOST-COMPOSITION decision (whether the experiment's own control chrome DOM renders), never a per-experiment physics/render parameter; forwarding it from an outer host URL into an embedded iframe would reintroduce the hidden-experiment-chrome bug (the GYM must always show the experiment's own full chrome, never chrome=canvas \u2014 see the "WHEN should a host set chrome=canvas" doc above for the general criterion, not just the GYM's specific answer to it)`})]),rC=Object.freeze(bx.filter(function(e){return e.forward}).map(function(e){return e.key}));var wx=Object.freeze([{id:"modules",means:"Loading the scene objects"},{id:"engine-ready",means:"Starting the WASM engine"},{id:"renderer",means:"Loading the renderer"},{id:"sketch",means:"Building the scene"}].map(Object.freeze)),dp=Object.freeze(wx.map(e=>e.id)),mp="frqtl:boot-phase";var _x={engine:{id:"egpt-engine-error",marker:"data-egpt-engine-error",bg:"#1a0000",fg:"#ff6b6b",border:"#b6161c"},renderer:{id:"egpt-renderer-error",marker:"data-egpt-renderer-error",bg:"#000a1a",fg:"#6b9eff",border:"#1640b6"}},ta=null;function Zg(e){ta=e||null}o(Zg,"setBootOverlayHost");function ra(e,t){let r=_x[e];if(!r)throw new Error("[boot] paintBootFailure: axis must be engine | renderer (got "+JSON.stringify(e)+")");typeof console<"u"&&console.error&&console.error(t);function i(){if(ta){if(ta.querySelector&&ta.querySelector("["+r.marker+"]"))return;let a=document.createElement("div");a.setAttribute(r.marker,"1"),a.setAttribute("data-egpt-boot-error","1"),a.style.cssText="position:absolute;inset:0;z-index:9998;background:"+r.bg+";color:"+r.fg+";font:12px/1.5 ui-monospace,Menlo,Consolas,monospace;padding:14px;white-space:pre-wrap;overflow:auto;border:2px solid "+r.border+";",a.textContent=t;let s=getComputedStyle(ta);(!s||s.position==="static")&&(ta.style.position="relative"),ta.appendChild(a);return}if(document.getElementById(r.id))return;let n=document.createElement("div");n.id=r.id,n.setAttribute("data-egpt-boot-error","1"),n.style.cssText="position:fixed;inset:0;z-index:99999;background:"+r.bg+";color:"+r.fg+";font:13px/1.55 ui-monospace,Menlo,Consolas,monospace;padding:22px;white-space:pre-wrap;overflow:auto;border:2px solid "+r.border+";",n.textContent=t,(document.body||document.documentElement).appendChild(n)}o(i,"paint"),document.body?i():addEventListener("DOMContentLoaded",i)}o(ra,"paintBootFailure");bi();xt();At();var lC=Object.freeze({scene:Object.freeze({id:"scene",importedBy:"any project file (a sketch imports it)"}),"part-internal":Object.freeze({id:"part-internal",importedBy:"a part file (parts/*.js) of a project \u2014 a forked part imports its parent part's internals; never a sketch"})}),oi=Object.freeze([Object.freeze({specifier:"@descix/frqtl-web/parts",libPath:"frqtl/parts/index.js",why:"the parts barrel",tier:"scene"}),Object.freeze({specifier:"@descix/frqtl-web/parts/",libPath:"frqtl/parts/",why:"one part = one file",tier:"scene"}),Object.freeze({specifier:"@descix/frqtl-web/shim/controls/registry.js",libPath:"shim/controls/registry.js",why:"knob registration (blackbody, circuit-sat, collision-matrix-3d, dse-tunnel-rebuild)",tier:"scene"}),Object.freeze({specifier:"@descix/frqtl-web/shim/render/sun-look.js",libPath:"shim/render/sun-look.js",why:"the one owner of the sun's FX bag (dse-tunnel-rebuild)",tier:"scene"}),Object.freeze({specifier:"@descix/frqtl-web/compat/renderer/display-slot.js",libPath:"frqtl/compat/renderer/display-slot.js",why:"the booted display name before co-init (mirror-route, dse-tunnel-rebuild)",tier:"scene"}),Object.freeze({specifier:"@descix/frqtl-web/compat/renderer/orbit-bag.js",libPath:"frqtl/compat/renderer/orbit-bag.js",why:"hasAngularPose, THE 3D-ness predicate (atomic-model)",tier:"scene"}),Object.freeze({specifier:"@descix/frqtl-web/objects/setup/_collisionMatrixLanes.js",libPath:"frqtl/objects/setup/_collisionMatrixLanes.js",why:"the one lane table (collision-matrix-3d)",tier:"scene"}),Object.freeze({specifier:"@descix/frqtl-web/compat/engine.js",libPath:"frqtl/compat/engine.js",why:"the engine accessor (atomic-model builds its frames by hand)",tier:"scene"}),Object.freeze({specifier:"@descix/frqtl-web/kinds",libPath:"frqtl/objects/kinds-entry.js",why:"the kind registry: a composed fork registers its renamed class (registerKind, kindNamed, kindOf, registeredKinds)",tier:"scene"}),Object.freeze({specifier:"@descix/frqtl-web/objects/objects/tagger.js",libPath:"frqtl/objects/objects/tagger.js",why:"imported by DetectorWall \u2014 a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/schema/index.js",libPath:"frqtl/objects/schema/index.js",why:"imported by DetectorWall, SlitScreen, Wall \u2014 a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/shim/render/heat-colormap.js",libPath:"shim/render/heat-colormap.js",why:"imported by GraphingDetectorWall \u2014 a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/schema/valueNormalizer.js",libPath:"frqtl/objects/schema/valueNormalizer.js",why:"imported by LiveChart, Wall \u2014 a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/objects/Box.js",libPath:"frqtl/objects/objects/Box.js",why:"imported by OvenBox \u2014 a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/objects/QuantumEmitter.js",libPath:"frqtl/objects/objects/QuantumEmitter.js",why:"imported by OvenBox \u2014 a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/shim/expr/ast-schema.js",libPath:"shim/expr/ast-schema.js",why:"imported by OvenBox, Tunnel \u2014 a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/objects/actionCompiler.js",libPath:"frqtl/objects/objects/actionCompiler.js",why:"imported by OvenBox, Tunnel \u2014 a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/v1-replacements.js",libPath:"frqtl/objects/v1-replacements.js",why:"imported by SlitLightSource \u2014 a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/objects/slitLinerScatter.js",libPath:"frqtl/objects/objects/slitLinerScatter.js",why:"imported by SlitScreen, Tunnel \u2014 a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/setup/setupSphereEmitter3D.js",libPath:"frqtl/objects/setup/setupSphereEmitter3D.js",why:"imported by SphereEmitter \u2014 a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/objects/directedRedirectProgram.js",libPath:"frqtl/objects/objects/directedRedirectProgram.js",why:"imported by Tunnel \u2014 a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/compat/renderer/lo-drawn-center.js",libPath:"frqtl/compat/renderer/lo-drawn-center.js",why:"imported by Tunnel \u2014 a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/setup/setupTunnelPointExit.js",libPath:"frqtl/objects/setup/setupTunnelPointExit.js",why:"imported by Tunnel \u2014 a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/constants/WallBehaviors.js",libPath:"frqtl/objects/constants/WallBehaviors.js",why:"imported by Wall \u2014 a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/objects/absorbRadiation.js",libPath:"frqtl/objects/objects/absorbRadiation.js",why:"imported by Wall \u2014 a forked copy imports it",tier:"part-internal"}),Object.freeze({specifier:"@descix/frqtl-web/objects/geometry/SlabFace.js",libPath:"frqtl/objects/geometry/SlabFace.js",why:"imported by Wall \u2014 a forked copy imports it",tier:"part-internal"})]),xx=Object.freeze({specifier:"@descix/frqtl-web/boot",libPath:"frqtl/experiments/_shared/doors.js",why:"the scene doors (bootScene, bootProject)"}),cC=Object.freeze([xx,Object.freeze({specifier:"@descix/frqtl-web/registry",libPath:"shim/registry/index.js",why:"the walk-through rungs, the showcase roster, the scene list (sceneGroups), projectOf"}),Object.freeze({specifier:"@descix/frqtl-web/project",libPath:"shim/project/index.js",why:"the specifier table, the link site, sketchProject and the project identity"}),Object.freeze({specifier:"@descix/frqtl-web/host-view",libPath:"shim/host/index.js",why:"the DeSciX host-view declarer: a page declares its own view"})]),gp="@descix/frqtl-web";function ia(e){return e.specifier.endsWith("/")}o(ia,"_isPrefix");function gs(e){if(typeof e!="string")throw new TypeError("[specifiers] libPathOf(specifier): a string specifier (got "+typeof e+"). (FAIL-LOUD.)");for(let t of oi)if(!ia(t)&&t.specifier===e)return t.libPath;for(let t of oi)if(ia(t)&&e.startsWith(t.specifier)&&e.length>t.specifier.length){let r=e.slice(t.specifier.length);if(r.split("/").indexOf("..")!==-1)throw new Error('[specifiers] "'+e+'" climbs out of its prefix row ('+t.specifier+"). (FAIL-LOUD.)");return t.libPath+r}throw new Error('[specifiers] "'+e+'" is not a @descix/frqtl-web specifier \u2014 the table (lib/shim/project/specifiers.js FRQTL_WEB_SPECIFIERS) offers: '+oi.map(function(t){return t.specifier+(ia(t)?"<file>":"")}).join(", ")+". (FAIL-LOUD.)")}o(gs,"libPathOf");function Ox(e){for(let t of oi)if(!ia(t)&&t.specifier===e)return t;for(let t of oi)if(ia(t)&&e.startsWith(t.specifier)&&e.length>t.specifier.length)return t;return null}o(Ox,"_rowOf");function $g(e){return gs(e),Ox(e).tier}o($g,"tierOf");function vs(e){if(typeof e!="string"||!e)throw new TypeError("[specifiers] specifierOfLibPath(libPath): a lib-identity path (got "+JSON.stringify(e)+"). (FAIL-LOUD.)");for(let t of oi)if(!ia(t)&&t.libPath===e)return t.specifier;for(let t of oi)if(ia(t)&&e.startsWith(t.libPath)){let r=e.slice(t.libPath.length);if(r&&r.indexOf("/")===-1)return t.specifier+r}return null}o(vs,"specifierOfLibPath");var ev=oi.find(function(e){return e.libPath==="frqtl/parts/index.js"});if(!ev)throw new Error("[parts-module] FRQTL_WEB_SPECIFIERS has no row for the parts barrel (frqtl/parts/index.js). (FAIL-LOUD.)");var mc=ev.specifier,Ex=/^frqtl\/parts\/[A-Za-z_$][\w$]*\.js$/;function ys(e,t){if(typeof e!="string"||!e)throw new TypeError("[parts-module] moduleOfKind(from, urls): from is the kind row's module URL (got "+JSON.stringify(e)+"). (FAIL-LOUD.)");let r=ze();if(e.startsWith(r)&&Ex.test(e.slice(r.length)))return mc;if(t){for(let i of Object.keys(t))if(t[i]===e)return i}return null}o(ys,"moduleOfKind");function vp(e,t){if(typeof e!="string"||!e)throw new TypeError("[parts-module] importSpecifierOf(module, entry): a module specifier or project path. (FAIL-LOUD.)");if(e.startsWith("@"))return e;let r=t.split("/");r.pop();let i=e.split("/");for(;r.length&&i.length>1&&r[0]===i[0];)r.shift(),i.shift();let n=r.map(function(){return".."});return(n.length?n.join("/")+"/":"./")+i.join("/")}o(vp,"importSpecifierOf");un();Ea();Da();_r();Vt();Va();var Sx=100,kx=10,Ax=200,yp=Object.freeze(["fpsLimit","tpsLimit"]),rv=Object.freeze(["initWorld"]);function iv(e,t){if(e.RATE_LIMITS!==void 0)throw new Error("[FrqtlApp."+t+"] the RATE_LIMITS factory static is DELETED \u2014 pacing is declared where the scene is: exp.runner.setRateLimits({ fpsLimit?, tpsLimit? }) in a scene file, runner.setRateLimits(...) on a page. (FAIL-LOUD.)")}o(iv,"_refuseDeletedStatics");function tv(e,t){return t&&t[e]?t[e]:ea()[e]}o(tv,"_resolveEngineClass");function Tx(e,t){for(var r=e.get("Wall"),i=0;i<r.fields.length;i++)if(r.fields[i].name===t)return!0;return!1}o(Tx,"_isWallField");function nv(e){return e&&e.lo&&e.lo._owner===e?e:null}o(nv,"_wallFacadeOf");W._wallFacadeOf=nv;function av(e){if(typeof requestAnimationFrame!="function")throw new Error("[FrqtlApp."+e+"] no animation frame in this host \u2014 the wall-clock loop needs requestAnimationFrame. Drive the clock with `runner.step()` (one tick + render per call, any host), or boot in a browser through `@descix/frqtl-web/boot`. (FAIL-LOUD.)")}o(av,"_requireAnimationFrame");function W(e){e=e||{};var t=e.canvasW,r=e.canvasH;if(typeof t!="number"||!(t>0)||typeof r!="number"||!(r>0))throw new Error("[FrqtlApp] canvasW and canvasH are REQUIRED positive numbers (got "+JSON.stringify(t)+" x "+JSON.stringify(r)+"). There is no default world size: a scene states its world with exp.createCanvas(w, h, cfg) / exp.createScene(w, h, d, cfg); a page passes it here. (FAIL-LOUD.)");this._is3D=!!e.is3D,this._depth=e.canvasD!==void 0&&e.canvasD!==null?e.canvasD:null;var i=e.seed!==void 0?e.seed:42;this._canvasParentId=e.canvasParentId||null,this._onTick=e.onTick||null,this._onReady=e.onReady||null,this._tickListeners=[],this._drawHz=e.drawHz!==void 0&&e.drawHz>0?e.drawHz:0;var n=e.stepsPerFrame!==void 0?Math.max(1,e.stepsPerFrame):1;e.tickHz!==void 0&&e.tickHz>0?this._tickHz=e.tickHz:n>1?this._tickHz=this._drawHz>0?this._drawHz*n:60*n:this._tickHz=0,this.stepsPerFrame=n;var a=tv("Rectangle",e.engine);this.canvas_rect=new a(0,0,t,r,null,!1),this._seed=i,this._tickSuspend=0;var s=tv("EGPTUniverse",e.engine);this.universe=s.create({rect:this.canvas_rect,seed:i}),this._declared=[],this._declaredMembers=new Map,this._declaredTicks=new Map,this._setupResult=null,this._sceneReplay=null,this._designMode=!1,this._aim=null,this._selected=null,this._onObjectMoved=null,this._isLooping=!1,this._rafId=null,this._lastTickData=null,this._accumulator=0,this._lastFrame=0,this._lastDraw=0,this._lastBudgetWarn=0,this._BUDGET_WARN_INTERVAL_MS=5e3,this._rateWindowMs=1e3,this._rateWindowEnd=0,this._tickCount=0,this._drawCount=0,this._lastTps=0,this._lastFps=0,this._renderOptions={renderBaseCanvas:!0},this._stagedRenderOptions=null,this._renderer=null;var l=this;this._capture=lc.create({get lastTickData(){return l._lastTickData}},function(){return l._getRenderer()},{seed:this._seed,get rect(){return l.canvas_rect}},function(){return l._renderOptions})}o(W,"FrqtlApp");Object.defineProperty(W.prototype,"largeObjects",{configurable:!0,get:o(function(){var e=this.universe;return e&&Array.isArray(e.largeObjects)?e.largeObjects:[]},"get")});Object.defineProperty(W.prototype,"controlHost",{configurable:!0,get:o(function(){if(this._controlHost)return this._controlHost;var e=this._sceneSurface;return e&&e.parentNode?e.parentNode:null},"get"),set:o(function(e){if(!e||typeof e.appendChild!="function"||!e.ownerDocument)throw new TypeError("[FrqtlApp.controlHost] a control host is a DOM element (it carries appendChild + ownerDocument); got "+String(e)+". (FAIL-LOUD.)");this._controlHost=e;for(var t=(this._controlChrome||[]).slice(),r=0;r<t.length;r++)t[r].rehost(e)},"set")});W.prototype.addControlChrome=function(e){if(!e||typeof e.rehost!="function")throw new TypeError("[FrqtlApp.addControlChrome] chrome must expose rehost(el). (FAIL-LOUD.)");var t=this._controlChrome||(this._controlChrome=[]);return t.push(e),function(){var r=t.indexOf(e);r!==-1&&t.splice(r,1)}};W.prototype.setDesignMode=function(e){this._designMode=!!e};W.prototype._shellRenderOf=function(e){var t=e&&e.shellRender;return t==="design"||t==="run"||t==="never"?t:e&&e._designMarker===!0?"design":"run"};W.prototype._visibleLargeObjects=function(){var e=this.largeObjects;if(!e||e.length===0)return e;for(var t=this,r=!1,i=0;i<e.length;i++)if(e[i]&&!t._isShellVisible(e[i])){r=!0;break}return r?e.filter(function(n){return t._isShellVisible(n)}):e};W.prototype._isShellVisible=function(e){var t=this._shellRenderOf(e);return t==="run"?!0:t==="never"?!1:!!this._designMode};var vc="filter.";function yc(e){var t=mn,r=t.get()===e?t.name():null;return r?'renderer "'+r+'"':"the active renderer"}o(yc,"_providerLabel");function ov(e,t){if(typeof e.renderCapabilities!="function")throw new TypeError("[FrqtlApp.setRenderOption] "+yc(e)+' declares no renderCapabilities(), so it accepts no render option (tried "'+t.map(function(u){return u[0]}).join('", "')+'"). A provider declares its knobs by implementing renderCapabilities().');for(var r=e.renderCapabilities(),i={},n=0;n<r.length;n++)i[r[n].name]=r[n];for(var a=Be.normalizeValue,s=[],l=0;l<t.length;l++){var c=t[l][0];if(W.RUNNER_INJECTED_RENDER_KEYS.indexOf(c)!==-1)throw new TypeError('[FrqtlApp.setRenderOption] "'+c+'" is merged into the render bag by the runner itself (FrqtlApp.RUNNER_INJECTED_RENDER_KEYS); it is not a writable render option.');var f=Object.prototype.hasOwnProperty.call(i,c)?i[c]:null;if(!f)throw new TypeError('[FrqtlApp.setRenderOption] "'+c+'" is not a render option '+yc(e)+" declares. Declared by renderCapabilities(): ["+r.map(function(u){return u.name}).join(", ")+"]. (FAIL-LOUD: an undeclared key is read by nothing, so the picture would silently differ from the recipe.)");s.push([c,a(f,t[l][1],"render option")])}return s}o(ov,"_validateRenderWrites");W.prototype._applyRenderWrites=function(e){for(var t=0;t<e.length;t++){var r=e[t][0];r.indexOf(vc)===0?this.setFilterActive(r.slice(vc.length),!!e[t][1]):this._renderOptions[r]=e[t][1]}for(var i=(this._renderOptionsListeners||[]).slice(),n=0;n<i.length;n++)i[n](e.map(function(a){return[a[0],a[1]]}));this._isLooping||this.repaint()};W.prototype.addRenderOptionsListener=function(e){var t=this._renderOptionsListeners||(this._renderOptionsListeners=[]);return t.indexOf(e)===-1&&t.push(e),function(){var r=t.indexOf(e);r!==-1&&t.splice(r,1)}};W.prototype.setRenderOptions=function(e){if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("[FrqtlApp.setRenderOptions] expects a plain object of { capabilityName: value }; got "+(Array.isArray(e)?"an array":String(e))+".");var t=Object.keys(e).map(function(i){return[i,e[i]]}),r=this._getRenderer();if(!r){this._stagedRenderOptions=(this._stagedRenderOptions||[]).concat(t);return}this._applyRenderWrites(ov(r,t))};W.prototype.setRenderOption=function(e,t){var r={};r[e]=t,this.setRenderOptions(r)};W.prototype.renderCapabilities=function(){var e=this._getRenderer();return!e||typeof e.renderCapabilities!="function"?[]:e.renderCapabilities()};W.prototype.getRenderOption=function(e){var t=this._getRenderer();if(!t)throw new TypeError("[FrqtlApp.getRenderOption] no display provider has attached yet, so no render option is declared. Read after the renderer boots.");if(typeof t.renderCapabilities!="function")throw new TypeError("[FrqtlApp.getRenderOption] "+yc(t)+' declares no renderCapabilities(), so "'+e+'" is not a render option it has.');for(var r=t.renderCapabilities(),i=!1,n=0;n<r.length;n++)if(r[n].name===e){i=!0;break}if(!i)throw new TypeError('[FrqtlApp.getRenderOption] "'+e+'" is not declared by '+yc(t)+" (declared: ["+r.map(function(a){return a.name}).join(", ")+"]).");return e.indexOf(vc)===0?this.isFilterActive(e.slice(vc.length)):this._renderOptions[e]};W.prototype.setFilterActive=function(e,t){var r=this._getRenderer();if(!r||typeof r.filter!="function"||typeof r.removeFilter!="function")throw new Error("[FrqtlApp.setFilterActive] no active renderer with filter()/removeFilter() (RendererProvider REQUIRED methods). (FAIL-LOUD.)");var i=Za;if(!Object.prototype.hasOwnProperty.call(i,e))throw new Error('[FrqtlApp.setFilterActive] unknown filter "'+e+'" \u2014 not a Filters.js catalog entry. (FAIL-LOUD.)');this._activeFilters||(this._activeFilters={}),t?(r.filter(i[e]),this._activeFilters[e]=!0):(r.removeFilter(e),delete this._activeFilters[e])};W.prototype.isFilterActive=function(e){return!!(this._activeFilters&&this._activeFilters[e])};W.prototype.setSourceRef=function(e){return this._capture.setSourceRef(e)};W.prototype.setSourceSha256=function(e){return this._capture.setSourceSha256(e)};W.prototype.sceneRecord=function(){return this._capture.sceneRecord()};W.prototype._assertRenderCensus=function(){var e=this.universe;if(!(!e||typeof e.unwrappedLargeObjectHandles!="function")){var t=e.unwrappedLargeObjectHandles();if(t.length!==0)throw new Error("[FrqtlApp] "+t.length+" object(s) are registered with the PHYSICS of this world but absent from its render census \u2014 handle(s) ["+t.join(", ")+"]. They collide and count correctly and CANNOT BE SEEN, which is the one outcome this surface refuses: a silently wrong picture is worse than an error, because what the eye is taught from it is wrong. Construct large objects through `new LargeObject(universe, \u2026)` (or a part that does \u2014 Wall, GraphingDetectorWall, Tunnel \u2026), which registers them for physics AND render in one act. The raw `universe.registerLargeObject(spec)` path carries no wrapper and belongs to headless harnesses only. (FAIL-LOUD.)")}};W.prototype.capture=function(e){try{this._assertRenderCensus()}catch(t){return Promise.reject(t)}return this._capture.capture(e)};W.prototype.captureStill=function(){try{this._assertRenderCensus()}catch(e){return Promise.reject(e)}return this._capture.captureStill()};W.prototype.addBackdrop=function(e,t,r){r=r||{};var i=t||{left:0,top:0,w:this.canvas_rect.w,h:this.canvas_rect.h},n=r.color||[0,0,0],a=r.visible!==void 0?r.visible:!1,s=Se,l=Ee,c=new s(this.universe,[i.left,i.top,i.w,i.h],l.NONE,[],"backdrop","closest",null,1,n);return c.backdrop=!0,c.image=e,c.visible=a,c};function bs(e){return e._declaredMembers||(e._declaredMembers=new Map)}o(bs,"_declaredMembersMap");function ws(e){return e._declaredTicks||(e._declaredTicks=new Map)}o(ws,"_declaredTicksMap");Object.defineProperty(W.prototype,"declared",{configurable:!0,get:o(function(){var e=this._declared||(this._declared=[]);if(!e.length)return e;for(var t=new Set(this.largeObjects),r=bs(this),i=0;i<e.length;i++)for(var n=r.get(e[i])||[],a=0;a<n.length;a++)if(!t.has(n[a]))throw new Error('[FrqtlApp.declared] stale declaration \u2014 "'+(e[i].name||e[i]._schemaKind)+'" lost its census LO "'+(n[a].name||"?")+'": the world was re-inited without clearing the registry (clearDeclared runs at FrqtlApp.setup and the RecipeContext co-init exp.createCanvas / exp.createScene \u2014 the world-init paths). (FAIL-LOUD.)');return e},"get")});W.prototype.declare=function(e,t,r,i){if(!e||typeof e!="object")throw new TypeError("[FrqtlApp.declare] a declared object is a handle, got "+typeof e+". (FAIL-LOUD.)");var n=this._declared||(this._declared=[]);if(n.indexOf(e)!==-1)throw new Error('[FrqtlApp.declare] "'+(e.name||e._schemaKind)+'" is already declared. (FAIL-LOUD.)');n.push(e);var a=(t||[]).slice();bs(this).set(e,a),ws(this).set(e,(r||[]).slice());for(var s=0;s<a.length;s++)if(this.declaredOf(a[s])!==e)throw n.pop(),bs(this).delete(e),ws(this).delete(e),new Error('[FrqtlApp.declare] "'+(e.name||e._schemaKind)+'" put the LO "'+(a[s].name||"?")+'" in the world without an `_owner` chain ending at it \u2014 a composer stamps ONE up-link on what it composed, so every drawn thing resolves to its declared object. (FAIL-LOUD.)');var l=i&&i.kind||e._schemaKind,c=l?Dt(l):null;return Cx(e,{inParts:!1,module:c?ys(c.from,this._projectUrls||null):null}),e};var gc=new WeakMap;function Cx(e,t){gc.set(e,t),Object.prototype.hasOwnProperty.call(e,"inParts")||(Object.defineProperty(e,"inParts",{configurable:!0,enumerable:!1,get:o(function(){var r=gc.get(this);return r?r.inParts:!1},"get")}),Object.defineProperty(e,"module",{configurable:!0,enumerable:!1,get:o(function(){var r=gc.get(this);return r?r.module:null},"get")}))}o(Cx,"_setCensusRow");function sv(e,t){var r=e._declared;if(!(!r||!r.length)){var i=e.declaredOf(t);i&&(e._handTouched||(e._handTouched=new Set)).add(i)}}o(sv,"_markHand");W.prototype._takeHandTouched=function(){var e=this._handTouched||new Set;return this._handTouched=new Set,e};W.prototype._adoptIntoParts=function(e){var t=gc.get(e);if(!t)throw new Error('[FrqtlApp] _adoptIntoParts: "'+(e&&e.name)+'" is not a declared object. (FAIL-LOUD.)');t.inParts=!0};W.prototype.beginWorld=function(){this._lastTickData=null};W.prototype.clearDeclared=function(){this._declared=[],this._declaredMembers=new Map,this._declaredTicks=new Map,this._handTouched=new Set};W.prototype.declaredOf=function(e){for(var t=this._declared||[],r=e,i=0;r&&i<64;r=r._owner,i++)if(t.indexOf(r)!==-1)return r;return null};W.prototype.membersOf=function(e){return(bs(this).get(e)||[]).slice()};W.prototype.undeclaredTickFunctions=function(){var e=this.universe&&Array.isArray(this.universe.experimentTickFunctions)?this.universe.experimentTickFunctions:[],t=new Set;return ws(this).forEach(function(r){for(var i=0;i<r.length;i++)t.add(r[i])}),e.filter(function(r){return!t.has(r)})};W.prototype.removeObject=function(e){var t=this.declared,r=t.indexOf(e);if(r===-1){var i=this.declaredOf(e);throw i?new Error('[FrqtlApp.removeObject] "'+(e&&e.name)+'" is part of the declared '+(i._schemaKind||"object")+' "'+i.name+'" \u2014 delete "'+i.name+'", not its part. (FAIL-LOUD.)'):new Error('[FrqtlApp.removeObject] "'+(e&&(e.name||e._schemaKind))+'" is not a declared object (runner.declared) \u2014 only what a declaring call (exp.addObject, a palette drop) produced is removed here; a primitive-surface object is disposed by whoever built it (obj.dispose()). (FAIL-LOUD.)')}if(typeof e.dispose!="function")throw new Error("[FrqtlApp.removeObject] the declared "+(e._schemaKind||"object")+' "'+e.name+'" has no dispose() \u2014 a part tears down what it composed. (FAIL-LOUD.)');var n=this.membersOf(e),a=(ws(this).get(e)||[]).slice();t.splice(r,1),bs(this).delete(e),ws(this).delete(e),e.dispose();var s=this.universe&&Array.isArray(this.universe.experimentTickFunctions)?this.universe.experimentTickFunctions:[],l=a.filter(function(u){return s.indexOf(u)!==-1});if(l.length)throw new Error('[FrqtlApp.removeObject] disposing "'+e.name+'" left '+l.length+" of its tick-functions running \u2014 its dispose() must tear down everything it composed. (FAIL-LOUD.)");var c=new Set(this.largeObjects),f=n.filter(function(u){return c.has(u)});if(f.length)throw new Error('[FrqtlApp.removeObject] disposing "'+e.name+'" left '+f.length+" of its LOs in the world ("+f.map(function(u){return u.name}).join(", ")+") \u2014 its dispose() must tear down everything it composed. (FAIL-LOUD.)")};W.prototype.getObjectByName=function(e,t){if(typeof e!="string"||!e)return null;for(var r=this.declared,i=0;i<r.length;i++){var n=r[i];if(n&&n.name===e&&(!t||t(n)))return n}return null};function jx(e,t,r,i){var n=e.largeObjects;if(!(!t||!n||n.length===0)){for(var a=Be,s=[],l=0;l<n.length;l++)for(var c=n[l],f=0;c&&c._owner&&f<64;c=c._owner,f++)if(c._owner===t){s.indexOf(c)===-1&&s.push(c);break}for(var u=0;u<s.length;u++){var h=s[u];if(a){var g=a.get(h._schemaKind||h.kind||"LargeObject"),d=!1;if(g){for(var m=0;m<g.fields.length;m++)if(g.fields[m].name===r){d=!0;break}}if(!d)continue}e.updateObjectProperty(h,r,i)}}}o(jx,"_fanOutRenderPropToGroup");W.prototype.updateObjectProperty=function(e,t,r){if(e){var i=t==="name"?this.declaredOf(e):null;if(i&&i.inParts)throw new TypeError('[FrqtlApp.updateObjectProperty] "name" of the parts entry "'+i.name+'": '+W.RENAME_REFUSAL+" (FAIL-LOUD.)");sv(this,e);var n=e._schemaKind||e.kind;if(!n)throw new TypeError('[FrqtlApp.updateObjectProperty] this object carries no `_schemaKind` (nor `kind`), so its descriptor cannot be resolved \u2014 property "'+t+'" was not rejected by any schema. Every shipped object class stamps `_schemaKind`; a handle without one is usually the wrong handle (e.g. a raw emitter handle rather than the palette object that wraps it).');var a=Be,s=null;if(a){var l=a.get(n);if(!l)throw new TypeError('[FrqtlApp.updateObjectProperty] Unknown object kind "'+n+'"');for(var c=0;c<l.fields.length;c++)if(l.fields[c].name===t){s=l.fields[c];break}if(!s)throw new TypeError('[FrqtlApp.updateObjectProperty] Property "'+t+'" is not in the schema for kind "'+n+'"');if(s.type==="readonly")throw new TypeError('[FrqtlApp.updateObjectProperty] Property "'+t+'" is readonly for kind "'+n+'"');r=a.normalizeValue(s,r,n);var f=nv(e);if(t==="rect"&&f){f.setRect(r),typeof this._onObjectMoved=="function"&&this._onObjectMoved(f,t);return}var u=["collisionBehavior","bounceDirection","decoherence","hooks","markTag","countFilter","capacity","orientationDeg","pitchDeg"];if(f===e&&Tx(a,t)){u.indexOf(t)!==-1?typeof e.setV2Prop=="function"&&e.setV2Prop(t,r):e.lo&&this.updateObjectProperty(e.lo,t,r),t==="rect"&&typeof this._onObjectMoved=="function"&&this._onObjectMoved(e,t);return}if(n==="Tunnel"&&typeof e.applyProp=="function"&&e.applyProp(t,r)){(t==="rect"||t==="left"||t==="top")&&typeof this._onObjectMoved=="function"&&this._onObjectMoved(e,t);return}if(n==="SphereEmitter"){typeof e.applyProp=="function"&&e.applyProp(t,r),(t==="center"||t==="rect")&&typeof this._onObjectMoved=="function"&&this._onObjectMoved(e,t);return}if(!s.engineVisible){if((n==="LargeObject"||n==="backdrop")&&(t==="collision_type"||t==="actions")&&typeof e.recompileActions=="function"){var h={};h[t==="collision_type"?"collisionType":"actions"]=r,e.recompileActions(h);return}e[t]=r,jx(this,e,t,r);return}}if(t==="rect"&&e.rect){if(typeof e.setRect!="function")throw new TypeError('[FrqtlApp.updateObjectProperty] "'+(e.name||n)+'" ('+n+") carries a rect but no setRect \u2014 its rect has no writer, so a rect write cannot land. (FAIL-LOUD.)");e.setRect(r);return}if(t!=="rect"&&t!=="source_rects")if(t==="actions"&&(n==="LargeObject"||n==="backdrop")){var g=Array.isArray(r)?r.slice():[r];e.arr_collision_actions=g,e.actions=g}else t==="layer"&&(n==="LargeObject"||n==="backdrop")?(e.layer=r??null,e.observedDimensions=r!=null?[r]:[]):e[t]=r;if(n==="PointSource"&&t==="rect"){typeof e.repositionToRect=="function"&&e.repositionToRect(r[0],r[1],r[2],r[3],this.universe);return}if(n==="QuantumEmitter"&&t==="rect"){typeof e.setSourceRect=="function"&&e.setSourceRect(r);return}this.universe&&typeof this.universe.updateObjectProperty=="function"&&this.universe.updateObjectProperty(e.handle,n,t,r)}};W.prototype._centerOf=function(e){if(!e||typeof e.getCenter!="function"||typeof e.setCenter!="function")return null;var t=e.getCenter();return Array.isArray(t)?t:null};W.prototype._rectAuthorityOf=function(e){return e&&e.rect&&typeof e.setRect=="function"?e:null};W.prototype.positionAuthorityOf=function(e){return this._centerOf(e)?"center":this._rectAuthorityOf(e)?"rect":null};W.prototype.noPositionAuthorityMessage=function(e){return'"'+(e&&e.name)+'" ('+(e&&e._schemaKind||"object")+") has no position authority \u2014 neither a centre (getCenter/setCenter) nor a rect (rect + setRect) \u2014 so it cannot be moved as a unit."};W.prototype._requireDeclared=function(e,t){if(e&&this.declaredOf(e)===e)return e;var r=e?this.declaredOf(e):null;throw new Error("[FrqtlApp."+t+"] "+(e?'"'+(e.name||e._schemaKind||"object")+'"':String(e))+" is not a declared object \u2014 only what the scene declared (runner.declared) is placed or read here"+(r?"; it belongs to the declared "+(r._schemaKind||"object")+' "'+r.name+'" \u2014 pass that handle (runner.declaredOf(x))':"; a primitive-surface object is not manipulable")+". (FAIL-LOUD.)")};W.prototype.centerOf=function(e){this._requireDeclared(e,"centerOf");var t=this._centerOf(e);if(t)return t;var r=this._rectAuthorityOf(e);if(r)return Vn(r.rect);throw new Error(this.noPositionAuthorityMessage(e))};W.prototype.kindOf=function(e){if(this._requireDeclared(e,"kindOf"),typeof e._schemaKind!="string"||!e._schemaKind)throw new Error('[FrqtlApp.kindOf] the declared object "'+e.name+'" carries no kind stamp \u2014 ObjectFactory.create stamps every declaration. (FAIL-LOUD.)');return e._schemaKind};W.prototype._placementAuthority=function(e){if(this._centerOf(e))return"center";var t=this._rectAuthorityOf(e);if(!t)throw new Error(this.noPositionAuthorityMessage(e));return typeof t.assertOwnsProgram=="function"&&t.assertOwnsProgram(),"rect"};W.prototype.placeDeclaredAt=function(e,t){if(sv(this,e),this._requireDeclared(e,"placeDeclaredAt"),!Array.isArray(t)||t.length!==2&&t.length!==3||!t.every(function(s){return typeof s=="number"&&isFinite(s)}))throw new TypeError("[FrqtlApp.placeDeclaredAt] the point is [x, y, z?] of finite numbers; got "+JSON.stringify(t)+". (FAIL-LOUD.)");var r=[t[0],t[1],t.length===3?t[2]:0],i=this.getUniverseBounds();if(r[0]<0||r[0]>i.width||r[1]<0||r[1]>i.height||r[2]<-i.zHalf||r[2]>i.zHalf)throw new RangeError("[FrqtlApp.placeDeclaredAt] "+JSON.stringify(r)+" is outside the universe cube (getUniverseBounds(): width "+i.width+", height "+i.height+", zHalf "+i.zHalf+" \u2014 x in [0, width], y in [0, height], z in [-zHalf, zHalf]). (FAIL-LOUD.)");var n=!1;if(this._placementAuthority(e)==="rect"){var a=Bi;a.hasZ(e.rect)||(n=Math.abs(r[2])>W.Z_HOLD_EPS,r=[r[0],r[1],0]),this.updateObjectProperty(e,"rect",a.snapRectPosition(a.rectAtCenter(e.rect,r)))}else this.updateObjectProperty(e,"center",nf(r));return{center:this.centerOf(e),zHeld:n}};W.prototype._orientationOf=function(e){return e&&typeof e.setOrientation=="function"?e:null};W.prototype.envelopeOf=function(e){if(e&&e.rect&&typeof e.rect.w=="number")return e.rect;for(var t=this.membersOf(e),r=1/0,i=1/0,n=-1/0,a=-1/0,s=1/0,l=-1/0,c=!1,f=0;f<t.length;f++){var u=t[f]&&t[f].rect;u&&(r=Math.min(r,u.left),i=Math.min(i,u.top),n=Math.max(n,u.left+u.w),a=Math.max(a,u.top+u.h),yi(u)&&(c=!0,s=Math.min(s,u.z),l=Math.max(l,u.z+(typeof u.d=="number"?u.d:u.w))))}if(!(r<n)||!(i<a))return null;var h={left:r,top:i,w:n-r,h:a-i};return c&&(h.z=s,h.d=l-s),h};W.prototype._objectCentroid=function(e){var t=this._centerOf(this.declaredOf(e));if(t)return t;var r=e&&e.rect;return r?Vn(r):null};W.prototype.getUniverseBounds=function(){var e=Be.worldRect(this.canvas_rect,"FrqtlApp.getUniverseBounds canvas_rect"),t=e.w,r=e.h;return{width:t,height:r,zHalf:Math.min(t,r)/2}};W.prototype._clampToUniverseCube=function(e){var t=this.getUniverseBounds(),r=Math.max(0,Math.min(t.width,e[0])),i=Math.max(0,Math.min(t.height,e[1])),n=Math.max(-t.zHalf,Math.min(t.zHalf,e[2]!=null?e[2]:0));return[r,i,n]};W.HOVER_MARGIN=6;W.HEADING_HOLD_EPS=.05;W.HEADING_WRITE_EPS_DEG=1e-6;W.Z_HOLD_EPS=1e-6;W.RENAME_REFUSAL="the key is the name \u2014 a rename is a new key in `parts` (with every reference to it, in code) or a fork of the sketch; a hand never writes a `name` into an entry.";var lv="off",Rx="roaming",Dx="grab-ready",Lx="grabbed";W.prototype.setAimArmed=function(e){if(!e){if(!this._aim)return;this._aim.unsubscribePose(),this._aim=null,this._notifyAim();return}if(!this._aim){var t=this.cameraControl;if(So(t)){if(typeof t.addPoseListener!="function"||typeof t.cameraOffsetFromWorld!="function"||typeof t.worldFromCameraOffset!="function")throw new Error("[FrqtlApp.setAimArmed] the angular camera handle lacks addPoseListener / cameraOffsetFromWorld / worldFromCameraOffset \u2014 the aim follows the camera through its pose notice and reads the ray off the offset pair (RENDERER_CONTRACT \xA71a.2). (FAIL-LOUD.)");var r=this;this._aim={cam:t,hover:null,grab:null,atEdge:!1,headingHeld:!1,zHeld:!1,error:null,last:null,unsubscribePose:null},this._aim.unsubscribePose=t.addPoseListener(function(){r._onAimPose()}),this._refreshHover(),this._notifyAim()}}};W.prototype.isAimArmed=function(){return!!this._aim};W.prototype.getAimState=function(){var e=this._aim;return e?{state:e.grab?Lx:e.hover?Dx:Rx,hover:e.hover?e.hover.name||"":null,grabbed:e.grab?e.grab.object.name||"":null,atEdge:!!(e.grab&&e.atEdge),headingHeld:!!(e.grab&&e.headingHeld),zHeld:!!(e.grab&&e.zHeld),error:e.error}:{state:lv,hover:null,grabbed:null,atEdge:!1,headingHeld:!1,zHeld:!1,error:null}};W.prototype.getGrabbedObject=function(){return this._aim&&this._aim.grab?this._aim.grab.object:null};W.prototype.addAimListener=function(e){var t=this._aimListeners||(this._aimListeners=[]);return t.indexOf(e)===-1&&t.push(e),function(){var r=t.indexOf(e);r!==-1&&t.splice(r,1)}};W.prototype._notifyAim=function(){var e=this.getAimState();this._aim&&(this._aim.last=JSON.stringify(e));for(var t=(this._aimListeners||[]).slice(),r=0;r<t.length;r++)t[r](e)};W.prototype._notifyAimIfChanged=function(){this._aim&&JSON.stringify(this.getAimState())===this._aim.last||this._notifyAim()};W.prototype.grabToggle=function(){var e=this._aim;if(!e)return lv;if(e.error=null,e.grab)this._releaseGrab();else if(this._refreshHover(),e.hover)try{e.grab=this._captureGrab(e.hover),e.atEdge=!1,e.headingHeld=!1,e.zHeld=!1}catch(t){e.grab=null,e.error="the object cannot be grabbed: "+(t&&t.message?t.message:t)}return this._notifyAim(),this.getAimState().state};W.prototype._releaseGrab=function(){this._aim&&(this._aim.grab=null,this._aim.atEdge=!1,this._aim.headingHeld=!1,this._aim.zHeld=!1)};W.prototype.setSelectHighlight=function(e){this._selected=e||null;var t=this._aim;t&&t.grab&&t.grab.object!==this._selected&&(this._releaseGrab(),t.error=null,this._notifyAim())};W.prototype._captureGrab=function(e){var t=this._aim.cam;this._placementAuthority(e);var r=this.centerOf(e),i=this._orientationOf(e),n={object:e,off:t.cameraOffsetFromWorld(r),oriTarget:i,hCam:null};if(i&&typeof i.getOrientation=="function"){var a=(i.getOrientation()||0)*Math.PI/180,s=t.cameraOffsetFromWorld([0,0,0]),l=t.cameraOffsetFromWorld([Math.cos(a),Math.sin(a),0]);n.hCam={right:l.right-s.right,up:l.up-s.up,forward:l.forward-s.forward}}return n};W.prototype._onAimPose=function(){this._aim&&this._aim.grab&&this._carryGrab(),this._refreshHover(),this._notifyAimIfChanged()};W.prototype._carryGrab=function(){var e=this._aim,t=e.grab,r=e.cam;try{var i=r.worldFromCameraOffset(t.off),n=this._clampToUniverseCube(i);e.atEdge=Math.abs(n[0]-i[0])+Math.abs(n[1]-i[1])+Math.abs(n[2]-i[2])>1e-6;var a=this.placeDeclaredAt(t.object,n);if(e.zHeld=a.zHeld,t.off=r.cameraOffsetFromWorld(a.zHeld?[n[0],n[1],0]:n),t.hCam){var s=r.worldFromCameraOffset({right:0,up:0,forward:0}),l=r.worldFromCameraOffset(t.hCam),c=l[0]-s[0],f=l[1]-s[1];if(e.headingHeld=Math.hypot(c,f)<W.HEADING_HOLD_EPS,!e.headingHeld){var u=Math.atan2(f,c)*180/Math.PI,h=typeof t.oriTarget.getOrientation=="function"?t.oriTarget.getOrientation():null,g=h===null?1/0:Math.abs(((u-h)%360+540)%360-180);g>W.HEADING_WRITE_EPS_DEG&&t.oriTarget.setOrientation(u)}}}catch(d){this._releaseGrab(),e.error="the grabbed object could not follow the camera: "+(d&&d.message?d.message:d),this._notifyAim()}};W.prototype._aimVolume=function(e,t){var r=Bi,i=this._centerOf(t===void 0?this.declaredOf(e):t);if(i){var n=e.rect?Math.max(e.rect.w||0,e.rect.h||0)/2:0;return r.drawnVolume({center:i,radius:n})}return e.rect?r.drawnVolume(e):null};W.prototype._declaredVolume=function(e){var t=this.membersOf(e);if(t.length===1||this._centerOf(e))return t.length?this._aimVolume(t[0],e):null;var r=this.envelopeOf(e);return r?tf({rect:r}):null};W.prototype._isDeclaredAimable=function(e){for(var t=this.membersOf(e),r=0;r<t.length;r++)if(this._isAimable(t[r]))return!0;return!1};W.prototype._isAimable=function(e){return!!e&&!e.backdrop&&e.visible!==!1&&this._isShellVisible(e)};W.prototype._centerRay=function(){var e=this._aim.cam,t=e.worldFromCameraOffset({right:0,up:0,forward:0}),r=e.worldFromCameraOffset({right:0,up:0,forward:1});return{origin:t,dir:[r[0]-t[0],r[1]-t[1],r[2]-t[2]]}};W.prototype._refreshHover=function(){var e=this._aim;if(e){for(var t=this.largeObjects,r=[],i=[],n=0;n<t.length;n++)if(this._isAimable(t[n])){var a=this.declaredOf(t[n]);if(a){var s=this._aimVolume(t[n],a);s&&(r.push(a),i.push(s))}}var l=this._centerRay(),c=rf(l.origin,l.dir,i,W.HOVER_MARGIN),f=c?r[c.index]:null;f!==e.hover&&(e.error=null),e.hover=f}};var cv="aimFeedback";W.RUNNER_INJECTED_RENDER_KEYS=Object.freeze([cv]);W.prototype._computeAimFeedback=function(){var e=this._aim;if(!e)return null;this._refreshHover(),this._notifyAimIfChanged();var t=this;function r(f){var u=f&&t._declaredVolume(f);return u?{name:f.name||"",volume:u}:null}o(r,"mark");var i={bounds:this.getUniverseBounds(),state:this.getAimState().state},n=r(e.grab?e.grab.object:e.hover);n&&(i.hover=n);var a=this._selected&&this._isDeclaredAimable(this._selected)?r(this._selected):null;a&&(i.selected=a),e.grab&&n&&(i.grabbed=n);var s=e.grab?e.grab.object:this._selected,l=this._orientationOf(s),c=s?this._declaredVolume(s):null;return l&&c&&typeof l.getOrientation=="function"&&(i.orientation={pivot:c.center,deg:l.getOrientation()||0}),i};W.prototype._renderOptsWithFeedback=function(){var e=this._computeAimFeedback();if(!e)return this._renderOptions;var t=Object.assign({},this._renderOptions);return t[cv]=e,t};W.prototype.screenPointOf=function(e,t,r,i){var n=this.renderer;if(!n||typeof n.screenToWorld!="function")throw new Error("[FrqtlApp.screenPointOf] the active renderer provider has no screenToWorld capability (RENDERER_CONTRACT) \u2014 world\u2192screen is its adjoint and has no other source. (FAIL-LOUD.)");for(var a=typeof e[2]=="number"?e[2]:0,s=i?i[0]:t/2,l=i?i[1]:r/2,c=0;c<8;c++){var f=n.screenToWorld(s,l,t,r,a),u=n.screenToWorld(s+1,l,t,r,a),h=n.screenToWorld(s,l+1,t,r,a);if(!f||!u||!h)return null;var g=u.x-f.x,d=h.x-f.x,m=u.y-f.y,b=h.y-f.y,y=g*b-d*m;if(!y)return null;var w=e[0]-f.x,x=e[1]-f.y,S=(b*w-d*x)/y,A=(g*x-m*w)/y;if(s+=S,l+=A,Math.abs(S)+Math.abs(A)<.05)break}var T=n.screenToWorld(s,l,t,r,a);return!T||Math.abs(T.x-e[0])+Math.abs(T.y-e[1])>.5?null:[s,l]};W.PICK_RADIUS_PX=32;W.PICK_DRIVE_PRIORITY=2;W.prototype.pickObjectAtScreen=function(e,t,r,i){var n=this.renderer;if(!n||typeof n.screenToWorld!="function")return null;for(var a=this.largeObjects,s=null,l=1/0,c=0;c<a.length;c++){var f=a[c],u=this.declaredOf(f);if(u){var h=this._objectCentroid(f);if(h){var g=this.screenPointOf(h,r,i,[e,t]);if(g){var d=typeof u.getCenter=="function",m=Math.hypot(g[0]-e,g[1]-t)/(d?W.PICK_DRIVE_PRIORITY:1);m<l&&(l=m,s=u)}}}}return l<=W.PICK_RADIUS_PX?s:null};W.prototype.setUniverseProperty=function(e,t){var r=Be;if(!r)throw new TypeError('[FrqtlApp.setUniverseProperty] ObjectSchema is unavailable \u2014 cannot validate "'+e+'" (FAIL-LOUD: never write to the universe unvalidated).');var i=r.get("Universe");if(!i)throw new TypeError('[FrqtlApp.setUniverseProperty] Unknown object kind "Universe"');for(var n=null,a=0;a<i.fields.length;a++)if(i.fields[a].name===e){n=i.fields[a];break}if(!n)throw new TypeError('[FrqtlApp.setUniverseProperty] Property "'+e+'" is not in the schema for kind "Universe". Valid properties: '+i.fields.map(function(s){return s.name}).join(", "));if(n.type==="readonly")throw new TypeError('[FrqtlApp.setUniverseProperty] Property "'+e+'" is readonly for kind "Universe"');this.universe[e]=t};W.prototype.getUniverseProperty=function(e){var t=Be;if(t){var r=t.get("Universe");if(r){for(var i=null,n=0;n<r.fields.length;n++)if(r.fields[n].name===e){i=r.fields[n];break}if(!i)throw new TypeError('[FrqtlApp.getUniverseProperty] Property "'+e+'" is not in the schema for kind "Universe". Valid properties: '+r.fields.map(function(a){return a.name}).join(", "))}}return this.universe[e]};W.prototype.moveLargeObject=function(e,t,r,i,n){if(!(!e||!e.rect)){var a=i!==void 0?i:e.rect.w,s=n!==void 0?n:e.rect.h;this.updateObjectProperty(e,"rect",[t,r,a,s])}};W.prototype.createCanvas=function(){this._createCanvasCalled=!0;var e=this._getRenderer();if(e&&e.init){var t={parentEl:this._canvasParentId,width:this.canvas_rect.w,height:this.canvas_rect.h,is3D:this._is3D};this._depth!==null&&(t.depth=this._depth);var r=Go,i=r.requireSceneSurface("FrqtlApp.createCanvas",e.init(t));return i.setAttribute(r.SCENE_SURFACE_ATTR,""),this._sceneSurface=i,this._onReady&&this._onReady(this),i}throw new Error("[FrqtlApp.createCanvas] no RendererProvider is active \u2014 one is selected by the boot module (lib/frqtl/experiments/_shared/boot.js) \u2014 a page boots through bootPage(), a programmatic host awaits bootRealm() \u2014 before calling createCanvas().")};W.prototype.setup=function(e,t){t=t||{},this._aim&&this.setAimArmed(!1),this._selected=null,this._setupResult&&typeof this._setupResult.dispose=="function"&&this._setupResult.dispose();var r=this;return this.retainSceneReplay(function(){return r.setup(e,t)}),this.clearDeclared(),iv(e,"setup"),typeof e.initWorld=="function"&&e.initWorld(this.universe,t),this._setupResult=e(this.universe,t),this._setupResult};W.prototype.retainSceneReplay=function(e){if(typeof e!="function")throw new TypeError("[FrqtlApp] retainSceneReplay(fn) takes the scene's replay function; got "+(e===null?"null":typeof e)+". (FAIL-LOUD.)");this._sceneReplay=e};W.prototype.restart=function(){if(typeof this._sceneReplay!="function")throw new Error("[FrqtlApp] restart(): nothing to replay \u2014 no scene has been built on this runner. Build one first with runner.setup(factory, opts) or RecipeContext.build(sketch). (FAIL-LOUD \u2014 a restart with nothing to replay would silently do nothing.)");this.stop();var e=this;function t(i){return e.beginWorld(),e.start(),i}o(t,"resume");var r;try{r=this._sceneReplay()}catch(i){return Promise.reject(i)}return r&&typeof r.then=="function"?r.then(t):Promise.resolve(t(r))};W.prototype._getRenderer=function(){if(!this._renderer){var e=Kh();if(e){var t=this._stagedRenderOptions?ov(e,this._stagedRenderOptions):null;this._createCanvasCalled||e.setSize(this.canvas_rect.w,this.canvas_rect.h),this._renderer=e,t&&(this._stagedRenderOptions=null,this._applyRenderWrites(t))}}return this._renderer||null};Object.defineProperty(W.prototype,"cameraControl",{configurable:!0,get:o(function(){if(!this._cameraControl){var e=this._getRenderer();e&&typeof e.getCameraControl=="function"&&(this._cameraControl=e.getCameraControl())}return this._cameraControl||null},"get")});W.prototype._failLoudMissingRenderer=function(){var e=`FrqtlApp: the DISPLAY SLOT is empty (FrqtlDisplay.get() === null).
|
|
18
18
|
|
|
19
19
|
The boot module (lib/frqtl/experiments/_shared/boot.js) must select a renderer
|
|
20
20
|
BEFORE the draw loop fires. This is a page configuration error.
|
|
21
21
|
|
|
22
|
-
P5Renderer has been removed
|
|
23
|
-
boot the canonical RendererProvider stack through bootPage().`;typeof document>"u"?typeof console<"u"&&console.error&&console.error("[FrqtlApp] "+e):Ji("renderer",e),this._isLooping=!1,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)};W.prototype._makeFrame=function(){var e=this;function t(r){if(e._isLooping){e._rafId=requestAnimationFrame(t),e._lastFrame===0&&(e._lastFrame=r);var n=Math.min(r-e._lastFrame,Z_);e._lastFrame=r,e._accumulator+=n;var i=e._tickHz,a=e._drawHz,s,l;i===1/0?s=0:i>0?s=1e3/i:(s=n,e._accumulator=n),l=a>0?1e3/a:0;for(var u=null,f=i===1/0?ex:$_;(s===0||e._accumulator>=s)&&f-- >0&&e._tickSuspend===0&&e._isLooping;){var c=e.universe.doTick();u=c,e._lastTickData=c,s>0&&(e._accumulator-=s),e._countTick(r),e._onTick&&e._onTick(c,e._setupResult),e._notifyTickListeners(c)}if(f<=0&&s>0&&e._accumulator>=s){if(W.verbose===!0&&typeof console<"u"&&console.warn){var h=e._lastBudgetWarn||0;r-h>=e._BUDGET_WARN_INTERVAL_MS&&(e._lastBudgetWarn=r,console.warn("[FrqtlApp] tick budget exhausted \u2014 physics may be falling behind"))}e._accumulator=0}i===1/0&&(e._accumulator=0);var g=l>0?r-e._lastDraw>=l:!0;if(u&&g){var p=e._getRenderer();if(p&&p.renderTick)e._assertRenderCensus(),p.renderTick(u,e._visibleLargeObjects(),e._renderOptsWithFeedback());else if(!e._rendererMissingReported){e._rendererMissingReported=!0,e._failLoudMissingRenderer();return}e._countDraw(r),e._lastDraw=r}}}return o(t,"frame"),t};W.prototype.start=function(){this._isLooping||this._rafId!==null||(Ng("start"),Qp(),sx(this),this._isLooping=!0,this._accumulator=0,this._lastFrame=0,this._lastDraw=0,this._rateWindowEnd=0,this._tickCount=0,this._drawCount=0,this._lastTps=0,this._lastFps=0,this._rafId=requestAnimationFrame(this._makeFrame()),Xp())};W.prototype.suspendTicks=function(){return this._tickSuspend+=1,this._tickSuspend};W.prototype.resumeTicks=function(){return this._tickSuspend>0&&(this._tickSuspend-=1),this._tickSuspend};Object.defineProperty(W.prototype,"worldTick",{configurable:!0,get:o(function(){if(this._lastTickData===null)return 0;var e=this._lastTickData&&this._lastTickData.universeData&&this._lastTickData.universeData.tick;if(!(typeof e=="number"&&e>=0&&e%1===0))throw new Error("[FrqtlApp.worldTick] the last delivered TickData carries tick "+String(e)+", not a whole number \u2265 0. (FAIL-LOUD.)");return e},"get")});Object.defineProperty(W.prototype,"ticksSuspended",{configurable:!0,get:o(function(){return this._tickSuspend>0},"get")});W.prototype.stop=function(){this._isLooping=!1,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)};W.prototype.dispose=function(){this.stop(),Yl===this&&(Yl=null)};W.prototype.toggle=function(){this._isLooping?this.stop():(Ng("toggle"),this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._isLooping=!0,this._lastFrame=0,this._rafId=requestAnimationFrame(this._makeFrame()))};W.prototype.step=function(){if(this._tickSuspend>0)throw new Error("[FrqtlApp.step] the tick clock is HELD (runner.ticksSuspended is true, depth "+this._tickSuspend+"): a capture or waypoint handler is observing the current tick, and stepping now would advance the world out from under it. Wait until runner.ticksSuspended is false, then step. (FAIL-LOUD \u2014 a step that silently did nothing would be a tick the driver believes it ran.)");var e=this.universe.doTick();if(this._lastTickData=e,e){var t=this._getRenderer();t&&t.renderTick?(this._assertRenderCensus(),t.renderTick(e,this._visibleLargeObjects(),this._renderOptsWithFeedback())):this._rendererMissingReported||(this._rendererMissingReported=!0,this._failLoudMissingRenderer())}return this._onTick&&this._onTick(e,this._setupResult),this._notifyTickListeners(e),e};W.prototype.addTickListener=function(e){if(typeof e!="function")return function(){};this._tickListeners.indexOf(e)===-1&&this._tickListeners.push(e);var t=this;return function(){t.removeTickListener(e)}};W.prototype.firstTick=function(e){var t=e&&e.deadlineMs;if(typeof t!="number"||!isFinite(t)||t<=0)throw new Error("[FrqtlApp.firstTick] opts.deadlineMs must be a positive number of ms (got "+String(t)+"). A first-tick wait with no bound hangs forever on a dead tick clock.");var r=this,n=typeof document<"u"?document:null;return new Promise(function(i,a){var s=!1,l=null,u=t,f=0,c=null;function h(){return!n||n.visibilityState==="visible"}o(h,"isVisible");function g(){l!==null&&(clearTimeout(l),l=null,u=Math.max(0,u-(Date.now()-f)))}o(g,"disarm");function p(){s=!0,g(),c&&c(),n&&n.removeEventListener("visibilitychange",y)}o(p,"settle");function m(){l=null,!s&&(p(),r.stop(),a(new Error("[FrqtlApp.firstTick] the runner (FrqtlPage.runner, FrqtlApp seed "+r._seed+", canvas "+r.canvas_rect.w+"x"+r.canvas_rect.h+") was started but delivered no tick within "+t+" ms of visible time \u2014 the scene is NOT live; the runner has been stopped. A per-frame error in the tick loop (see the page console) or a held tick clock (runner.ticksSuspended) is the usual cause.")))}o(m,"expire");function b(){s||l!==null||!h()||(f=Date.now(),l=setTimeout(m,u))}o(b,"arm");function y(){h()?b():g()}o(y,"onVisibility"),c=r.addTickListener(function(w){s||(p(),i(w))}),n&&n.addEventListener("visibilitychange",y),b()})};W.prototype.removeTickListener=function(e){var t=this._tickListeners.indexOf(e);t!==-1&&this._tickListeners.splice(t,1)};W.prototype._notifyTickListeners=function(e){if(!(!this._tickListeners||!this._tickListeners.length))for(var t=this._tickListeners.slice(),r=0;r<t.length;r++)try{t[r](e,this._setupResult)}catch(n){typeof console<"u"&&console.error&&console.error("[FrqtlApp] tick listener threw:",n)}};W.prototype.repaint=function(){if(this._lastTickData){var e=this._getRenderer();e&&e.renderTick&&(this._assertRenderCensus(),e.renderTick(this._lastTickData,this._visibleLargeObjects(),this._renderOptsWithFeedback()))}};Object.defineProperty(W.prototype,"isRunning",{get:o(function(){return this._isLooping},"get")});Object.defineProperty(W.prototype,"setupResult",{get:o(function(){return this._setupResult},"get")});Object.defineProperty(W.prototype,"worldBounds",{get:o(function(){if(this._lastTickData)return this._lastTickData.universeData.boundaryRect;var e=this.universe;return e&&e.initBounds||null},"get")});Object.defineProperty(W.prototype,"renderer",{get:o(function(){return this._getRenderer()},"get")});W.prototype.getRates=function(){return{fps:this._lastFps,tps:this._lastTps}};W.prototype.getRateLimits=function(){return{fpsLimit:this._drawHz,tpsLimit:this._tickHz}};W.prototype.setRateLimits=function(e){if(!e||typeof e!="object")throw new TypeError("[FrqtlApp.setRateLimits] limits must be an object");if(Object.keys(e).forEach(function(n){if(Ih.indexOf(n)===-1)throw new TypeError('[FrqtlApp.setRateLimits] unknown rate key "'+n+'" \u2014 accepted keys: '+Ih.join(", ")+" (FAIL-LOUD).")}),e.fpsLimit!==void 0){var t=e.fpsLimit;if(typeof t!="number"||t<0||isNaN(t))throw new RangeError("[FrqtlApp.setRateLimits] fpsLimit must be a non-negative number, got: "+t);this._drawHz=t}if(e.tpsLimit!==void 0){var r=e.tpsLimit;if(typeof r!="number"||r<0&&r!==-1/0||isNaN(r))throw new RangeError("[FrqtlApp.setRateLimits] tpsLimit must be \u2265 0 or Infinity, got: "+r);this._tickHz=r<0?0:r}};W.prototype._countTick=function(e){this._tickCount+=1,this._rateWindowEnd===0&&(this._rateWindowEnd=e+this._rateWindowMs)};W.prototype._countDraw=function(e){if(this._drawCount+=1,e>=this._rateWindowEnd&&this._rateWindowEnd>0){var t=Math.max(e-(this._rateWindowEnd-this._rateWindowMs),1);this._lastFps=Math.round(this._drawCount*1e3/t),this._lastTps=Math.round(this._tickCount*1e3/t),this._drawCount=0,this._tickCount=0,this._rateWindowEnd=e+this._rateWindowMs}};W.RATE_LIMIT_KEYS=Ih;W.FACTORY_STATICS=Ig;W.carryFactoryStatics=function(e,t){if(typeof e!="function"||typeof t!="function")throw new TypeError("[FrqtlApp.carryFactoryStatics] wrapper and factory must both be functions (got "+typeof e+", "+typeof t+") (FAIL-LOUD).");return Pg(t,"carryFactoryStatics"),Ig.forEach(function(r){t[r]!==void 0&&(e[r]=t[r])}),e};W.verbose=!1;var Yl=null;function sx(e){if(!e||typeof e.step!="function")throw new TypeError("[FrqtlApp] setPageRunner(runner): expected an FrqtlApp. (FAIL-LOUD.)");Yl=e}o(sx,"setPageRunner");function qg(){return Yl}o(qg,"pageRunner");Rl();Df();Un();Et();var Ph=new TextEncoder;function an(e){throw new Error("[identity] "+e+" (FAIL-LOUD.)")}o(an,"_fail");function lx(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)if(e[n]!==t[n])return e[n]-t[n];return e.length-t.length}o(lx,"_byteCompare");function Qa(e){e||an("a project file has an empty path."),(e.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(e))&&an('"'+e+'" is absolute \u2014 a project path is root-relative.'),e.startsWith("./")&&an('"'+e+'" starts with "./" \u2014 a project path carries no leading "./".'),e.indexOf("\\")!==-1&&an('"'+e+'" uses "\\" \u2014 a project path is "/"-separated.'),e.split("/").some(t=>t===""||t==="."||t==="..")&&an('"'+e+'" has an empty, "." or ".." segment \u2014 a project path names one file under the root.')}o(Qa,"checkProjectPath");function Bg(e){(!e||typeof e!="object")&&an("projectBytes(files): files is the map { path: text } (got "+typeof e+").");let t={};for(let r of Object.keys(e))typeof e[r]!="string"&&an('projectBytes: file "'+r+'" is not text (got '+typeof e[r]+")."),t[r]=Ph.encode(e[r]);return t}o(Bg,"projectBytes");async function Wg(e){let t=e&&e.files;(!t||typeof t!="object")&&an("projectIdentity(project): project.files is the map { path: bytes } (got "+typeof t+").");let r=Object.keys(t).map(c=>{Qa(c);let h=t[c];return h instanceof Uint8Array||an('file "'+c+'" is not bytes (got '+typeof h+") \u2014 the identity is over the bytes a host ran; a { path: text } map goes through projectBytes(files) first."),{path:Ph.encode(c),bytes:h}});r.length===0&&an("projectIdentity(project): the project has no files."),r.sort((c,h)=>lx(c.path,h.path));let n=[],i=0;for(let c of r){let h=Ph.encode(String(c.bytes.length));for(let g of[c.path,Uint8Array.of(0),h,Uint8Array.of(0),c.bytes])n.push(g),i+=g.length}let a=new Uint8Array(i),s=0;for(let c of n)a.set(c,s),s+=c.length;let l=typeof crypto<"u"?crypto.subtle:null;(!l||typeof l.digest!="function")&&an("crypto.subtle.digest is unavailable \u2014 the project identity is a content hash with no second hashing path.");let u=new Uint8Array(await l.digest("SHA-256",a)),f="";for(let c=0;c<u.length;c++)f+=(u[c]<16?"0":"")+u[c].toString(16);return f}o(Wg,"projectIdentity");var tt="frqtl.json";function on(e){throw new Error("["+tt+"] "+e+" (FAIL-LOUD.)")}o(on,"_fail");function Gg(){return Fh.map(function(e){return e.key}).join(", ")}o(Gg,"_keyList");var Fh=Object.freeze([Object.freeze({key:"name",type:"string",required:!0,rule:"a non-empty string \u2014 the project's name",check:o(function(e){e.length===0&&on(`"name" is empty \u2014 a project's name is a non-empty string.`)},"check")}),Object.freeze({key:"kind",type:"string",required:!0,rule:'"scene" (a notebook project, "notebook", comes with P5)',check:o(function(e){e==="notebook"&&on('"kind": "notebook" \u2014 a notebook project comes with P5 (notebooks on projects); a project today is "kind": "scene".'),e!=="scene"&&on('"kind": '+JSON.stringify(e)+' is not a project kind \u2014 "scene", or "notebook" (P5).')},"check")}),Object.freeze({key:"entry",type:"string",required:!0,rule:'a root-relative project path ending ".js" \u2014 the module whose default export is buildExperiment(exp)',check:o(function(e){try{Qa(e)}catch(t){on('"entry": '+String(t&&t.message||t))}e.endsWith(".js")||on('"entry": '+JSON.stringify(e)+' does not end ".js" \u2014 the entry is the project module whose default export is buildExperiment(exp).')},"check")}),Object.freeze({key:"version",type:"string",required:!1,rule:"the author's own string, never interpreted (optional)",check:o(function(){},"check")})]);function ux(e){(!e||typeof e!="object"||Array.isArray(e))&&on("a manifest is an object { "+Gg()+" } (got "+(Array.isArray(e)?"an array":e===null?"null":typeof e)+").");let t=Fh.map(function(i){return i.key}),r=Object.keys(e).filter(function(i){return t.indexOf(i)===-1});r.length&&on("unknown key"+(r.length>1?"s ":" ")+r.map(function(i){return JSON.stringify(i)}).join(", ")+" \u2014 a manifest holds exactly MANIFEST_KEYS (lib/shim/project/manifest.js): "+Gg()+". How a host boots the folder (display, seed, camera, render rows) is its renderState, kept beside the folder.");let n={};for(let i of Fh){let a=e[i.key];if(a===void 0){i.required&&on('"'+i.key+'" is REQUIRED \u2014 '+i.rule+".");continue}typeof a!==i.type&&on('"'+i.key+'" is '+(a===null?"null":typeof a)+" \u2014 "+i.rule+"."),i.check(a),n[i.key]=a}return Object.freeze(n)}o(ux,"normalizeManifest");function Jl(e){typeof e!="string"&&on("parseManifest(text): the text of "+tt+" (got "+typeof e+").");let t;try{t=JSON.parse(e)}catch(r){on("is not valid JSON: "+String(r&&r.message||r)+".")}return ux(t)}o(Jl,"parseManifest");Rt();var cx="export default function buildExperiment(exp) { \u2026 }",Yg=new TextDecoder("utf-8",{fatal:!0});function Ze(e){throw new Error("[link] "+e+" (FAIL-LOUD.)")}o(Ze,"_fail");function fx(e){let t=e.split(""),r=0,n=e.length;for(;r<n;){let i=e[r];if(i==="/"&&e[r+1]==="/")for(;r<n&&e[r]!==`
|
|
24
|
-
`;)t[r]=" ",r++;else if(
|
|
25
|
-
`&&(t[r]=" ")}else if(i==="'"||i==='"'||i==="`"){for(r++;r<n&&e[r]!==i;)e[r]==="\\"&&r++,r++;r++}else r++}return t.join("")}o(fx,"_blankComments");var Hg=/(?:^|[;\n}])\s*(?:import|export)\b[^'";]*?\bfrom\s*(['"])([^'"\n]+)\1|(?:^|[;\n}])\s*import\s*(['"])([^'"\n]+)\3|\bimport\s*\(\s*(['"])([^'"\n]+)\5\s*\)/dg;function hx(e){let t=fx(e),r=[],n;for(Hg.lastIndex=0;n=Hg.exec(t);){let i=n[2]!==void 0?2:n[4]!==void 0?4:6;r.push({spec:n[i],start:n.indices[i][0],end:n.indices[i][1]})}return r}o(hx,"_imports");function dx(e){return e.startsWith("./")||e.startsWith("../")}o(dx,"_isRelative");function px(e){try{return Bl(e),!0}catch{return!1}}o(px,"_isPublished");function mx(){return Qi.map(function(e){return e.specifier+(e.specifier.endsWith("/")?"<file>":"")}).join(", ")}o(mx,"_publishedList");function gx(e){return e===Lh||e.startsWith(Lh+"/")}o(gx,"_isPackage");function vx(e,t){let r=e.split("/");r.pop();for(let n of t.split("/"))if(!(n==="."||n===""))if(n===".."){if(r.length===0)return null;r.pop()}else r.push(n);return r.join("/")}o(vx,"_resolveRelative");async function yx(e,t){let r={},n={},i={},a=[],s={};async function l(u,f,c){if(s[u]==="done")return;if(s[u]==="visiting"){let m=f.slice(f.indexOf(u)).concat(u);Ze("the project files import each other in a cycle: "+m.join(" \u2192 ")+" \u2014 a project file graph is acyclic (each file is minted after everything it imports).")}s[u]="visiting";let h=await t(u,f[f.length-1],c),g=h.text;r[u]=g,n[u]=h.bytes;let p=[];for(let m of hx(g))if(dx(m.spec)){let b=vx(u,m.spec);b===null&&Ze('"'+u+'" imports "'+m.spec+'" \u2014 outside the project; package internals have no public specifier (a project file imports the package by a @descix/frqtl-web/... row).'),Uh(b)||Ze('"'+u+'" imports "'+m.spec+'" ('+b+"), which is not a module path \u2014 a project imports only its module files ("+Mh.join(" / ")+"); any other file of the folder (a data file, an extensionless name, "+tt+") travels with it unlinked."),p.push(Object.assign({kind:"file",target:b},m))}else gx(m.spec)?(px(m.spec)||Ze('"'+u+'" imports "'+m.spec+'" \u2014 not a published specifier; the table (lib/shim/project/specifiers.js FRQTL_WEB_SPECIFIERS) offers: '+mx()+"."),p.push(Object.assign({kind:"package"},m))):Ze('"'+u+'" imports "'+m.spec+'" \u2014 a project file imports another project file by a relative specifier (./X.js) and the package by @descix/frqtl-web/...; nothing else.');i[u]=p;for(let m of p)m.kind==="file"&&await l(m.target,f.concat(u),m.spec);s[u]="done",a.push(u)}return o(l,"visit"),await l(e,[]),{order:a,files:r,bytes:n,edges:i}}o(yx,"_walk");function bx(e){try{return new URL(e).href}catch{}return(typeof document>"u"||!document||typeof document.baseURI!="string")&&Ze("linkProject({ url }): "+JSON.stringify(e)+" is relative and this host has no document to resolve it against \u2014 pass the absolute folder URL (e.g. new URL('./proj/', import.meta.url).href)."),new URL(e,document.baseURI).href}o(bx,"_folderUrl");function wx(e,t,r){let n=e;for(let i of t.slice().sort((a,s)=>s.start-a.start)){let a=e[i.start-1],s=String(r(i)).replace(/\\/g,"\\\\").split(a).join("\\"+a);n=n.slice(0,i.start)+s+n.slice(i.end)}return n}o(wx,"_rewrite");var Mh=Object.freeze([".js",".mjs"]);function Uh(e){return Mh.some(function(t){return e.endsWith(t)})}o(Uh,"isModulePath");function Nh(e){(!e||typeof e!="object")&&Ze("linkedFiles(files): files is the map { path: text | bytes } (got "+(e===null?"null":typeof e)+").");let t={};for(let r of Object.keys(e))(r===tt||Uh(r))&&(t[r]=e[r]);return t}o(Nh,"linkedFiles");function _x(e,t){if(e.files===void 0)return;let r=Object.keys(Nh(e.files)).filter(function(n){return n!==tt&&!Object.prototype.hasOwnProperty.call(t.files,n)});r.length&&Ze('unused project file "'+r[0]+'" \u2014 a project holds the module files its entry imports'+(r.length>1?" (also unused: "+r.slice(1).join(", ")+")":"")+"; a non-module file (README.md) travels with the folder unlinked.")}o(_x,"_refuseUnreached");function xx(e){return new URL(Bl(e),He()).href}o(xx,"_defaultBare");function Ox(e,t){return typeof e.default!="function"&&Ze('the entry "'+t+'" has no default export function \u2014 its form is '+cx+" (a classic sketch's `window.buildExperiment` tail is retired: write the ES module form)."),e.default}o(Ox,"_entryFunction");async function Ex(e){let t=new URL(tt,e).href,r;try{r=await fetch(t)}catch(s){Ze('fetching "'+tt+'" ('+t+") failed: "+String(s&&s.message||s)+".")}if(r.status===404)return null;r.ok||Ze('"'+tt+'" is not served at '+t+" (HTTP "+r.status+").");let n=new Uint8Array(await r.arrayBuffer()),i;try{i=Yg.decode(n)}catch{Ze('"'+tt+'" is not valid UTF-8 ('+t+").")}let a;try{a=Jl(i)}catch(s){let l=r.headers&&typeof r.headers.get=="function"?r.headers.get("content-type"):null;Ze("the served "+tt+" ("+t+", HTTP "+r.status+(l?", "+l:"")+") is refused: "+String(s&&s.message||s)+" \u2014 a host that answers a missing file with a page serves no 404, so a folder there carries its own "+tt+".")}return{manifest:a,text:i,bytes:n}}o(Ex,"_fetchManifest");function Jg(e,t){return t?(e!==void 0&&e!==t.entry&&Ze('entryOf: `entry` "'+e+'" disagrees with '+tt+`'s "entry" "`+t.entry+'" \u2014 the manifest names the entry; drop `entry`, or make the two equal.'),t.entry):(e===void 0&&Ze("entryOf: no entry \u2014 the project carries no "+tt+' (manifest.js; manifestFor({ name, entry }) writes one) and no `entry` was given (a one-string sketch: { files: { "sketch.js": text }, entry: "sketch.js" }).'),e)}o(Jg,"_entryOf");function Qg(e,t){let r=e&&Object.prototype.hasOwnProperty.call(e,tt);return Jg(t,r?Jl(e[tt]):null)}o(Qg,"entryOf");async function Xa(e){(!e||typeof e!="object")&&Ze("linkProject(project): project is { files, mint } or { url, mint } (+ `entry` when it carries no "+tt+") (got "+typeof e+").");let t=e.entry;t!==void 0&&((typeof t!="string"||!t)&&Ze("linkProject: `entry` is the root-relative path of the module whose default export is the scene (got "+JSON.stringify(t)+")."),Qa(t));let r=e.files!==void 0,n=e.url!==void 0;r===n&&Ze("linkProject: a project is EITHER { files } OR { url } (got "+(r?"both":"neither")+").");let i=e.mint;typeof i!="function"&&Ze("linkProject: mint is REQUIRED \u2014 the host's (text, path) \u2192 { url, release? } (blobMint in a page, dataMint in node; lib/shim/project/link.js). A served folder is minted from the bytes it fetched.");let a=e.bare===void 0?xx:e.bare;typeof a!="function"&&Ze("linkProject: bare is (specifier) \u2192 URL for a @descix/frqtl-web/... specifier.");let s,l=null,u=null;if(r){let y=e.files;(!y||typeof y!="object"||Object.keys(y).length===0)&&Ze("linkProject: project.files is the map { path: text } and has no files.");for(let w of Object.keys(y))Qa(w),typeof y[w]!="string"&&Ze('linkProject: file "'+w+'" is not text.');u=Bg(y),Object.prototype.hasOwnProperty.call(y,tt)&&(l={manifest:Jl(y[tt]),text:y[tt],bytes:u[tt]}),s=o(async function(w,O,S){Object.prototype.hasOwnProperty.call(y,w)||Ze(O===void 0?'the entry "'+w+'" is not a project file (files: '+Object.keys(y).join(", ")+").":'"'+O+'" imports "'+S+'" ('+w+"), which is not a project file (files: "+Object.keys(y).join(", ")+") \u2014 a relative specifier names a file in the project, never an HTTP sibling; package internals have no public specifier.");let A=y[w];return A.trim()||Ze('the project file "'+w+'" is empty.'),{text:A,bytes:u[w]}},"sourceOf")}else{(typeof e.url!="string"||!e.url.endsWith("/"))&&Ze('linkProject({ url }): url is the served project folder, ending in "/" (got '+JSON.stringify(e.url)+").");let y=bx(e.url);l=await Ex(y),s=o(async function(w,O,S){let A=new URL(w,y).href,C;try{C=await fetch(A)}catch(Y){Ze('fetching "'+w+'" ('+A+") failed: "+String(Y&&Y.message||Y)+".")}C.ok||Ze((O===void 0?'the entry "'+w+'"':'"'+O+'" imports "'+S+'" ('+w+"), which")+" is not served at "+A+" (HTTP "+C.status+")"+(O===void 0?".":" \u2014 a relative specifier names a file in the project; package internals have no public specifier."));let R=new Uint8Array(await C.arrayBuffer()),Q;try{Q=Yg.decode(R)}catch{Ze('"'+w+'" is not valid UTF-8 ('+A+") \u2014 a project file is a UTF-8 text module.")}return Q.trim()||Ze('the project file "'+w+'" is empty.'),{text:Q,bytes:R}},"sourceOf")}let f=l?l.manifest:null,c=Jg(t,f);Uh(c)||Ze('linkProject: the entry "'+c+'" is not a module path ('+Mh.join(" / ")+").");let h=await yx(c,s);_x(e,h);let g=Nh(r?u:Object.assign(l?{[tt]:l.bytes}:{},h.bytes)),p=r?Object.assign({},e.files):Object.assign(l?{[tt]:l.text}:{},h.files),m={},b=[];try{for(let O of h.order){let S=wx(h.files[O],h.edges[O],function(C){return C.kind==="file"?m[C.target]:a(C.spec)}),A=i(S,O);(!A||typeof A.url!="string")&&Ze('mint(text, path) must return { url, release? } (for "'+O+'").'),b.push(A),m[O]=A.url}let y=await import(m[c]),w={files:p,entry:c,mint:i};return e.bare!==void 0&&(w.bare=e.bare),{buildExperiment:Ox(y,c),module:y,manifest:f,files:g,urls:Object.assign({},m),project:w}}finally{for(let y of b)typeof y.release=="function"&&y.release()}}o(Xa,"linkProject");var Kg=new Map;function Ql(e){let t=Kg.get(e);return t||(t=URL.createObjectURL(new Blob([e],{type:"text/javascript"})),Kg.set(e,t)),{url:t,release:o(function(){},"release")}}o(Ql,"blobMint");function Xg(e,t,r){let n={};return o(function(a){let s=Bl(a);if(n[s])return n[s];let l=e[s];l||Ze('"'+a+'" names '+s+", which this host does not carry (it carries: "+Object.keys(e).join(", ")+").");let u=["const ns = "+t+"["+JSON.stringify(s)+"];"];for(let f of Object.keys(l))f==="default"?u.push("export default ns.default;"):/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(f)?u.push("export const "+f+" = ns."+f+";"):Ze(s+' exports "'+f+'", which is not an identifier.');return n[s]=r(u.join(`
|
|
22
|
+
P5Renderer has been removed. All experiment pages
|
|
23
|
+
boot the canonical RendererProvider stack through bootPage().`;typeof document>"u"?typeof console<"u"&&console.error&&console.error("[FrqtlApp] "+e):ra("renderer",e),this._isLooping=!1,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)};W.prototype._makeFrame=function(){var e=this;function t(r){if(e._isLooping){e._rafId=requestAnimationFrame(t),e._lastFrame===0&&(e._lastFrame=r);var i=Math.min(r-e._lastFrame,Sx);e._lastFrame=r,e._accumulator+=i;var n=e._tickHz,a=e._drawHz,s,l;n===1/0?s=0:n>0?s=1e3/n:(s=i,e._accumulator=i),l=a>0?1e3/a:0;for(var c=null,f=n===1/0?Ax:kx;(s===0||e._accumulator>=s)&&f-- >0&&e._tickSuspend===0&&e._isLooping;){var u=e.universe.doTick();c=u,e._lastTickData=u,s>0&&(e._accumulator-=s),e._countTick(r),e._onTick&&e._onTick(u,e._setupResult),e._notifyTickListeners(u)}if(f<=0&&s>0&&e._accumulator>=s){if(W.verbose===!0&&typeof console<"u"&&console.warn){var h=e._lastBudgetWarn||0;r-h>=e._BUDGET_WARN_INTERVAL_MS&&(e._lastBudgetWarn=r,console.warn("[FrqtlApp] tick budget exhausted \u2014 physics may be falling behind"))}e._accumulator=0}n===1/0&&(e._accumulator=0);var g=l>0?r-e._lastDraw>=l:!0;if(c&&g){var d=e._getRenderer();if(d&&d.renderTick)e._assertRenderCensus(),d.renderTick(c,e._visibleLargeObjects(),e._renderOptsWithFeedback());else if(!e._rendererMissingReported){e._rendererMissingReported=!0,e._failLoudMissingRenderer();return}e._countDraw(r),e._lastDraw=r}}}return o(t,"frame"),t};W.prototype.start=function(){this._isLooping||this._rafId!==null||(av("start"),Em(),Px(this),this._isLooping=!0,this._accumulator=0,this._lastFrame=0,this._lastDraw=0,this._rateWindowEnd=0,this._tickCount=0,this._drawCount=0,this._lastTps=0,this._lastFps=0,this._rafId=requestAnimationFrame(this._makeFrame()),Sm())};W.prototype.suspendTicks=function(){return this._tickSuspend+=1,this._tickSuspend};W.prototype.resumeTicks=function(){return this._tickSuspend>0&&(this._tickSuspend-=1),this._tickSuspend};Object.defineProperty(W.prototype,"worldTick",{configurable:!0,get:o(function(){if(this._lastTickData===null)return 0;var e=this._lastTickData&&this._lastTickData.universeData&&this._lastTickData.universeData.tick;if(!(typeof e=="number"&&e>=0&&e%1===0))throw new Error("[FrqtlApp.worldTick] the last delivered TickData carries tick "+String(e)+", not a whole number \u2265 0. (FAIL-LOUD.)");return e},"get")});Object.defineProperty(W.prototype,"ticksSuspended",{configurable:!0,get:o(function(){return this._tickSuspend>0},"get")});W.prototype.stop=function(){this._isLooping=!1,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)};W.prototype.dispose=function(){this.stop(),bc===this&&(bc=null)};W.prototype.toggle=function(){this._isLooping?this.stop():(av("toggle"),this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._isLooping=!0,this._lastFrame=0,this._rafId=requestAnimationFrame(this._makeFrame()))};W.prototype.step=function(){if(this._tickSuspend>0)throw new Error("[FrqtlApp.step] the tick clock is HELD (runner.ticksSuspended is true, depth "+this._tickSuspend+"): a capture or waypoint handler is observing the current tick, and stepping now would advance the world out from under it. Wait until runner.ticksSuspended is false, then step. (FAIL-LOUD \u2014 a step that silently did nothing would be a tick the driver believes it ran.)");var e=this.universe.doTick();if(this._lastTickData=e,e){var t=this._getRenderer();t&&t.renderTick?(this._assertRenderCensus(),t.renderTick(e,this._visibleLargeObjects(),this._renderOptsWithFeedback())):this._rendererMissingReported||(this._rendererMissingReported=!0,this._failLoudMissingRenderer())}return this._onTick&&this._onTick(e,this._setupResult),this._notifyTickListeners(e),e};W.prototype.addTickListener=function(e){if(typeof e!="function")return function(){};this._tickListeners.indexOf(e)===-1&&this._tickListeners.push(e);var t=this;return function(){t.removeTickListener(e)}};W.prototype.firstTick=function(e){var t=e&&e.deadlineMs;if(typeof t!="number"||!isFinite(t)||t<=0)throw new Error("[FrqtlApp.firstTick] opts.deadlineMs must be a positive number of ms (got "+String(t)+"). A first-tick wait with no bound hangs forever on a dead tick clock.");var r=this,i=typeof document<"u"?document:null;return new Promise(function(n,a){var s=!1,l=null,c=t,f=0,u=null;function h(){return!i||i.visibilityState==="visible"}o(h,"isVisible");function g(){l!==null&&(clearTimeout(l),l=null,c=Math.max(0,c-(Date.now()-f)))}o(g,"disarm");function d(){s=!0,g(),u&&u(),i&&i.removeEventListener("visibilitychange",y)}o(d,"settle");function m(){l=null,!s&&(d(),r.stop(),a(new Error("[FrqtlApp.firstTick] the runner (FrqtlPage.runner, FrqtlApp seed "+r._seed+", canvas "+r.canvas_rect.w+"x"+r.canvas_rect.h+") was started but delivered no tick within "+t+" ms of visible time \u2014 the scene is NOT live; the runner has been stopped. A per-frame error in the tick loop (see the page console) or a held tick clock (runner.ticksSuspended) is the usual cause.")))}o(m,"expire");function b(){s||l!==null||!h()||(f=Date.now(),l=setTimeout(m,c))}o(b,"arm");function y(){h()?b():g()}o(y,"onVisibility"),u=r.addTickListener(function(w){s||(d(),n(w))}),i&&i.addEventListener("visibilitychange",y),b()})};W.prototype.removeTickListener=function(e){var t=this._tickListeners.indexOf(e);t!==-1&&this._tickListeners.splice(t,1)};W.prototype._notifyTickListeners=function(e){if(!(!this._tickListeners||!this._tickListeners.length))for(var t=this._tickListeners.slice(),r=0;r<t.length;r++)try{t[r](e,this._setupResult)}catch(i){typeof console<"u"&&console.error&&console.error("[FrqtlApp] tick listener threw:",i)}};W.prototype.repaint=function(){if(this._lastTickData){var e=this._getRenderer();e&&e.renderTick&&(this._assertRenderCensus(),e.renderTick(this._lastTickData,this._visibleLargeObjects(),this._renderOptsWithFeedback()))}};Object.defineProperty(W.prototype,"isRunning",{get:o(function(){return this._isLooping},"get")});Object.defineProperty(W.prototype,"setupResult",{get:o(function(){return this._setupResult},"get")});Object.defineProperty(W.prototype,"worldBounds",{get:o(function(){if(this._lastTickData)return this._lastTickData.universeData.boundaryRect;var e=this.universe;return e&&e.initBounds||null},"get")});Object.defineProperty(W.prototype,"renderer",{get:o(function(){return this._getRenderer()},"get")});W.prototype.getRates=function(){return{fps:this._lastFps,tps:this._lastTps}};W.prototype.getRateLimits=function(){return{fpsLimit:this._drawHz,tpsLimit:this._tickHz}};W.prototype.setRateLimits=function(e){if(!e||typeof e!="object")throw new TypeError("[FrqtlApp.setRateLimits] limits must be an object");if(Object.keys(e).forEach(function(i){if(yp.indexOf(i)===-1)throw new TypeError('[FrqtlApp.setRateLimits] unknown rate key "'+i+'" \u2014 accepted keys: '+yp.join(", ")+" (FAIL-LOUD).")}),e.fpsLimit!==void 0){var t=e.fpsLimit;if(typeof t!="number"||t<0||isNaN(t))throw new RangeError("[FrqtlApp.setRateLimits] fpsLimit must be a non-negative number, got: "+t);this._drawHz=t}if(e.tpsLimit!==void 0){var r=e.tpsLimit;if(typeof r!="number"||r<0&&r!==-1/0||isNaN(r))throw new RangeError("[FrqtlApp.setRateLimits] tpsLimit must be \u2265 0 or Infinity, got: "+r);this._tickHz=r<0?0:r}};W.prototype._countTick=function(e){this._tickCount+=1,this._rateWindowEnd===0&&(this._rateWindowEnd=e+this._rateWindowMs)};W.prototype._countDraw=function(e){if(this._drawCount+=1,e>=this._rateWindowEnd&&this._rateWindowEnd>0){var t=Math.max(e-(this._rateWindowEnd-this._rateWindowMs),1);this._lastFps=Math.round(this._drawCount*1e3/t),this._lastTps=Math.round(this._tickCount*1e3/t),this._drawCount=0,this._tickCount=0,this._rateWindowEnd=e+this._rateWindowMs}};W.RATE_LIMIT_KEYS=yp;W.FACTORY_STATICS=rv;W.carryFactoryStatics=function(e,t){if(typeof e!="function"||typeof t!="function")throw new TypeError("[FrqtlApp.carryFactoryStatics] wrapper and factory must both be functions (got "+typeof e+", "+typeof t+") (FAIL-LOUD).");return iv(t,"carryFactoryStatics"),rv.forEach(function(r){t[r]!==void 0&&(e[r]=t[r])}),e};W.verbose=!1;var bc=null;function Px(e){if(!e||typeof e.step!="function")throw new TypeError("[FrqtlApp] setPageRunner(runner): expected an FrqtlApp. (FAIL-LOUD.)");bc=e}o(Px,"setPageRunner");function uv(){return bc}o(uv,"pageRunner");tc();sh();bi();xt();var bp=new TextEncoder;function si(e){throw new Error("[identity] "+e+" (FAIL-LOUD.)")}o(si,"_fail");function Ix(e,t){let r=Math.min(e.length,t.length);for(let i=0;i<r;i++)if(e[i]!==t[i])return e[i]-t[i];return e.length-t.length}o(Ix,"_byteCompare");function no(e){e||si("a project file has an empty path."),(e.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(e))&&si('"'+e+'" is absolute \u2014 a project path is root-relative.'),e.startsWith("./")&&si('"'+e+'" starts with "./" \u2014 a project path carries no leading "./".'),e.indexOf("\\")!==-1&&si('"'+e+'" uses "\\" \u2014 a project path is "/"-separated.'),e.split("/").some(t=>t===""||t==="."||t==="..")&&si('"'+e+'" has an empty, "." or ".." segment \u2014 a project path names one file under the root.')}o(no,"checkProjectPath");function fv(e){(!e||typeof e!="object")&&si("projectBytes(files): files is the map { path: text } (got "+typeof e+").");let t={};for(let r of Object.keys(e))typeof e[r]!="string"&&si('projectBytes: file "'+r+'" is not text (got '+typeof e[r]+")."),t[r]=bp.encode(e[r]);return t}o(fv,"projectBytes");async function hv(e){let t=e&&e.files;(!t||typeof t!="object")&&si("projectIdentity(project): project.files is the map { path: bytes } (got "+typeof t+").");let r=Object.keys(t).map(u=>{no(u);let h=t[u];return h instanceof Uint8Array||si('file "'+u+'" is not bytes (got '+typeof h+") \u2014 the identity is over the bytes a host ran; a { path: text } map goes through projectBytes(files) first."),{path:bp.encode(u),bytes:h}});r.length===0&&si("projectIdentity(project): the project has no files."),r.sort((u,h)=>Ix(u.path,h.path));let i=[],n=0;for(let u of r){let h=bp.encode(String(u.bytes.length));for(let g of[u.path,Uint8Array.of(0),h,Uint8Array.of(0),u.bytes])i.push(g),n+=g.length}let a=new Uint8Array(n),s=0;for(let u of i)a.set(u,s),s+=u.length;let l=typeof crypto<"u"?crypto.subtle:null;(!l||typeof l.digest!="function")&&si("crypto.subtle is unavailable \u2014 this page is not a secure context (isSecureContext "+String(typeof isSecureContext>"u"?void 0:isSecureContext)+"): serve the folder from https or from localhost (e.g. npx serve). The project identity is a content hash with no second hashing path.");let c=new Uint8Array(await l.digest("SHA-256",a)),f="";for(let u=0;u<c.length;u++)f+=(c[u]<16?"0":"")+c[u].toString(16);return f}o(hv,"projectIdentity");var tt="frqtl.json";function li(e){throw new Error("["+tt+"] "+e+" (FAIL-LOUD.)")}o(li,"_fail");function pv(){return wp.map(function(e){return e.key}).join(", ")}o(pv,"_keyList");var wp=Object.freeze([Object.freeze({key:"name",type:"string",required:!0,rule:"a non-empty string \u2014 the project's name",check:o(function(e){e.length===0&&li(`"name" is empty \u2014 a project's name is a non-empty string.`)},"check")}),Object.freeze({key:"kind",type:"string",required:!0,rule:'"scene" (a notebook project, "notebook", comes with P5)',check:o(function(e){e==="notebook"&&li('"kind": "notebook" \u2014 a notebook project comes with P5 (notebooks on projects); a project today is "kind": "scene".'),e!=="scene"&&li('"kind": '+JSON.stringify(e)+' is not a project kind \u2014 "scene", or "notebook" (P5).')},"check")}),Object.freeze({key:"entry",type:"string",required:!0,rule:'a root-relative project path ending ".js" \u2014 the module whose default export is buildExperiment(exp)',check:o(function(e){try{no(e)}catch(t){li('"entry": '+String(t&&t.message||t))}e.endsWith(".js")||li('"entry": '+JSON.stringify(e)+' does not end ".js" \u2014 the entry is the project module whose default export is buildExperiment(exp).')},"check")}),Object.freeze({key:"version",type:"string",required:!1,rule:"the author's own string, never interpreted (optional)",check:o(function(){},"check")})]);function Fx(e){(!e||typeof e!="object"||Array.isArray(e))&&li("a manifest is an object { "+pv()+" } (got "+(Array.isArray(e)?"an array":e===null?"null":typeof e)+").");let t=wp.map(function(n){return n.key}),r=Object.keys(e).filter(function(n){return t.indexOf(n)===-1});r.length&&li("unknown key"+(r.length>1?"s ":" ")+r.map(function(n){return JSON.stringify(n)}).join(", ")+" \u2014 a manifest holds exactly MANIFEST_KEYS (lib/shim/project/manifest.js): "+pv()+". How a host boots the folder (display, seed, camera, render rows) is its renderState, kept beside the folder.");let i={};for(let n of wp){let a=e[n.key];if(a===void 0){n.required&&li('"'+n.key+'" is REQUIRED \u2014 '+n.rule+".");continue}typeof a!==n.type&&li('"'+n.key+'" is '+(a===null?"null":typeof a)+" \u2014 "+n.rule+"."),n.check(a),i[n.key]=a}return Object.freeze(i)}o(Fx,"normalizeManifest");function wc(e){typeof e!="string"&&li("parseManifest(text): the text of "+tt+" (got "+typeof e+").");let t;try{t=JSON.parse(e)}catch(r){li("is not valid JSON: "+String(r&&r.message||r)+".")}return Fx(t)}o(wc,"parseManifest");At();var Nx="export default function buildExperiment(exp) { \u2026 }",gv=new TextDecoder("utf-8",{fatal:!0});function Xe(e){throw new Error("[link] "+e+" (FAIL-LOUD.)")}o(Xe,"_fail");function Mx(e){let t=e.split(""),r=0,i=e.length;for(;r<i;){let n=e[r];if(n==="/"&&e[r+1]==="/")for(;r<i&&e[r]!==`
|
|
24
|
+
`;)t[r]=" ",r++;else if(n==="/"&&e[r+1]==="*"){let a=e.indexOf("*/",r+2),s=a===-1?i:a+2;for(;r<s;r++)e[r]!==`
|
|
25
|
+
`&&(t[r]=" ")}else if(n==="'"||n==='"'||n==="`"){for(r++;r<i&&e[r]!==n;)e[r]==="\\"&&r++,r++;r++}else r++}return t.join("")}o(Mx,"_blankComments");var dv=/(?:^|[;\n}])\s*(?:import|export)\b[^'";]*?\bfrom\s*(['"])([^'"\n]+)\1|(?:^|[;\n}])\s*import\s*(['"])([^'"\n]+)\3|\bimport\s*\(\s*(['"])([^'"\n]+)\5\s*\)/dg;function Ux(e){let t=Mx(e),r=[],i;for(dv.lastIndex=0;i=dv.exec(t);){let n=i[2]!==void 0?2:i[4]!==void 0?4:6;r.push({spec:i[n],start:i.indices[n][0],end:i.indices[n][1]})}return r}o(Ux,"_imports");function zx(e){return e.startsWith("./")||e.startsWith("../")}o(zx,"_isRelative");function qx(e){try{return gs(e),!0}catch{return!1}}o(qx,"_isPublished");function Vx(){return oi.map(function(e){return e.specifier+(e.specifier.endsWith("/")?"<file>":"")}).join(", ")}o(Vx,"_publishedList");var Bx="part-internal";function Wx(e){return/^parts\/[^/]+\.m?js$/.test(e)}o(Wx,"_isPartFile");function Gx(e){return e===gp||e.startsWith(gp+"/")}o(Gx,"_isPackage");function Hx(e,t){let r=e.split("/");r.pop();for(let i of t.split("/"))if(!(i==="."||i===""))if(i===".."){if(r.length===0)return null;r.pop()}else r.push(i);return r.join("/")}o(Hx,"_resolveRelative");async function Kx(e,t){let r={},i={},n={},a=[],s={};async function l(c,f,u){if(s[c]==="done")return;if(s[c]==="visiting"){let m=f.slice(f.indexOf(c)).concat(c);Xe("the project files import each other in a cycle: "+m.join(" \u2192 ")+" \u2014 a project file graph is acyclic (each file is minted after everything it imports).")}s[c]="visiting";let h=await t(c,f[f.length-1],u),g=h.text;r[c]=g,i[c]=h.bytes;let d=[];for(let m of Ux(g))if(zx(m.spec)){let b=Hx(c,m.spec);b===null&&Xe('"'+c+'" imports "'+m.spec+'" \u2014 outside the project; package internals have no public specifier (a project file imports the package by a @descix/frqtl-web/... row).'),Op(b)||Xe('"'+c+'" imports "'+m.spec+'" ('+b+"), which is not a module path \u2014 a project imports only its module files ("+xp.join(" / ")+"); any other file of the folder (a data file, an extensionless name, "+tt+") travels with it unlinked."),d.push(Object.assign({kind:"file",target:b},m))}else Gx(m.spec)?(qx(m.spec)||Xe('"'+c+'" imports "'+m.spec+'" \u2014 not a published specifier; the table (lib/shim/project/specifiers.js FRQTL_WEB_SPECIFIERS) offers: '+Vx()+"."),$g(m.spec)===Bx&&!Wx(c)&&Xe('"'+c+'" imports "'+m.spec+'" \u2014 a part-internal module is imported by a part file (parts/*.js), never by a sketch \u2014 a sketch imports parts by @descix/frqtl-web/parts.'),d.push(Object.assign({kind:"package"},m))):Xe('"'+c+'" imports "'+m.spec+'" \u2014 a project file imports another project file by a relative specifier (./X.js) and the package by @descix/frqtl-web/...; nothing else.');n[c]=d;for(let m of d)m.kind==="file"&&await l(m.target,f.concat(c),m.spec);s[c]="done",a.push(c)}return o(l,"visit"),await l(e,[]),{order:a,files:r,bytes:i,edges:n}}o(Kx,"_walk");function Yx(e){try{return new URL(e).href}catch{}return(typeof document>"u"||!document||typeof document.baseURI!="string")&&Xe("linkProject({ url }): "+JSON.stringify(e)+" is relative and this host has no document to resolve it against \u2014 pass the absolute folder URL (e.g. new URL('./proj/', import.meta.url).href)."),new URL(e,document.baseURI).href}o(Yx,"_folderUrl");function Jx(e,t,r){let i=e;for(let n of t.slice().sort((a,s)=>s.start-a.start)){let a=e[n.start-1],s=String(r(n)).replace(/\\/g,"\\\\").split(a).join("\\"+a);i=i.slice(0,n.start)+s+i.slice(n.end)}return i}o(Jx,"_rewrite");var xp=Object.freeze([".js",".mjs"]);function Op(e){return xp.some(function(t){return e.endsWith(t)})}o(Op,"isModulePath");function _p(e){(!e||typeof e!="object")&&Xe("linkedFiles(files): files is the map { path: text | bytes } (got "+(e===null?"null":typeof e)+").");let t={};for(let r of Object.keys(e))(r===tt||Op(r))&&(t[r]=e[r]);return t}o(_p,"linkedFiles");function Qx(e,t){if(e.files===void 0)return;let r=Object.keys(_p(e.files)).filter(function(i){return i!==tt&&!Object.prototype.hasOwnProperty.call(t.files,i)});r.length&&Xe('unused project file "'+r[0]+'" \u2014 a project holds the module files its entry imports'+(r.length>1?" (also unused: "+r.slice(1).join(", ")+")":"")+"; a non-module file (README.md) travels with the folder unlinked.")}o(Qx,"_refuseUnreached");function Xx(e){return new URL(gs(e),ze()).href}o(Xx,"_defaultBare");function Zx(e,t){return typeof e.default!="function"&&Xe('the entry "'+t+'" has no default export function \u2014 its form is '+Nx+" (a classic sketch's `window.buildExperiment` tail is retired: write the ES module form)."),e.default}o(Zx,"_entryFunction");async function $x(e){let t=new URL(tt,e).href,r;try{r=await fetch(t)}catch(s){Xe('fetching "'+tt+'" ('+t+") failed: "+String(s&&s.message||s)+".")}if(r.status===404)return null;r.ok||Xe('"'+tt+'" is not served at '+t+" (HTTP "+r.status+").");let i=new Uint8Array(await r.arrayBuffer()),n;try{n=gv.decode(i)}catch{Xe('"'+tt+'" is not valid UTF-8 ('+t+").")}let a;try{a=wc(n)}catch(s){let l=r.headers&&typeof r.headers.get=="function"?r.headers.get("content-type"):null;Xe("the served "+tt+" ("+t+", HTTP "+r.status+(l?", "+l:"")+") is refused: "+String(s&&s.message||s)+" \u2014 a host that answers a missing file with a page serves no 404, so a folder there carries its own "+tt+".")}return{manifest:a,text:n,bytes:i}}o($x,"_fetchManifest");function vv(e,t){return t?(e!==void 0&&e!==t.entry&&Xe('entryOf: `entry` "'+e+'" disagrees with '+tt+`'s "entry" "`+t.entry+'" \u2014 the manifest names the entry; drop `entry`, or make the two equal.'),t.entry):(e===void 0&&Xe("entryOf: no entry \u2014 the project carries no "+tt+' (manifest.js; manifestFor({ name, entry }) writes one) and no `entry` was given (a one-string sketch: { files: { "sketch.js": text }, entry: "sketch.js" }).'),e)}o(vv,"_entryOf");function yv(e,t){let r=e&&Object.prototype.hasOwnProperty.call(e,tt);return vv(t,r?wc(e[tt]):null)}o(yv,"entryOf");async function ao(e){(!e||typeof e!="object")&&Xe("linkProject(project): project is { files, mint } or { url, mint } (+ `entry` when it carries no "+tt+") (got "+typeof e+").");let t=e.entry;t!==void 0&&((typeof t!="string"||!t)&&Xe("linkProject: `entry` is the root-relative path of the module whose default export is the scene (got "+JSON.stringify(t)+")."),no(t));let r=e.files!==void 0,i=e.url!==void 0;r===i&&Xe("linkProject: a project is EITHER { files } OR { url } (got "+(r?"both":"neither")+").");let n=e.mint;typeof n!="function"&&Xe("linkProject: mint is REQUIRED \u2014 the host's (text, path) \u2192 { url, release? } (blobMint in a page, dataMint in node; lib/shim/project/link.js). A served folder is minted from the bytes it fetched.");let a=e.bare===void 0?Xx:e.bare;typeof a!="function"&&Xe("linkProject: bare is (specifier) \u2192 URL for a @descix/frqtl-web/... specifier.");let s,l=null,c=null;if(r){let y=e.files;(!y||typeof y!="object"||Object.keys(y).length===0)&&Xe("linkProject: project.files is the map { path: text } and has no files.");for(let w of Object.keys(y))no(w),typeof y[w]!="string"&&Xe('linkProject: file "'+w+'" is not text.');c=fv(y),Object.prototype.hasOwnProperty.call(y,tt)&&(l={manifest:wc(y[tt]),text:y[tt],bytes:c[tt]}),s=o(async function(w,x,S){Object.prototype.hasOwnProperty.call(y,w)||Xe(x===void 0?'the entry "'+w+'" is not a project file (files: '+Object.keys(y).join(", ")+").":'"'+x+'" imports "'+S+'" ('+w+"), which is not a project file (files: "+Object.keys(y).join(", ")+") \u2014 a relative specifier names a file in the project, never an HTTP sibling; package internals have no public specifier.");let A=y[w];return A.trim()||Xe('the project file "'+w+'" is empty.'),{text:A,bytes:c[w]}},"sourceOf")}else{(typeof e.url!="string"||!e.url.endsWith("/"))&&Xe('linkProject({ url }): url is the served project folder, ending in "/" (got '+JSON.stringify(e.url)+").");let y=Yx(e.url);l=await $x(y),s=o(async function(w,x,S){let A=new URL(w,y).href,T;try{T=await fetch(A)}catch(Y){Xe('fetching "'+w+'" ('+A+") failed: "+String(Y&&Y.message||Y)+".")}T.ok||Xe((x===void 0?'the entry "'+w+'"':'"'+x+'" imports "'+S+'" ('+w+"), which")+" is not served at "+A+" (HTTP "+T.status+")"+(x===void 0?".":" \u2014 a relative specifier names a file in the project; package internals have no public specifier."));let j=new Uint8Array(await T.arrayBuffer()),Q;try{Q=gv.decode(j)}catch{Xe('"'+w+'" is not valid UTF-8 ('+A+") \u2014 a project file is a UTF-8 text module.")}return Q.trim()||Xe('the project file "'+w+'" is empty.'),{text:Q,bytes:j}},"sourceOf")}let f=l?l.manifest:null,u=vv(t,f);Op(u)||Xe('linkProject: the entry "'+u+'" is not a module path ('+xp.join(" / ")+").");let h=await Kx(u,s);Qx(e,h);let g=_p(r?c:Object.assign(l?{[tt]:l.bytes}:{},h.bytes)),d=r?Object.assign({},e.files):Object.assign(l?{[tt]:l.text}:{},h.files),m={},b=[];try{for(let x of h.order){let S=Jx(h.files[x],h.edges[x],function(T){return T.kind==="file"?m[T.target]:a(T.spec)}),A=n(S,x);(!A||typeof A.url!="string")&&Xe('mint(text, path) must return { url, release? } (for "'+x+'").'),b.push(A),m[x]=A.url}let y;try{y=await import(m[u])}catch(x){throw e1(x,m)}let w={files:d,entry:u,mint:n};return e.bare!==void 0&&(w.bare=e.bare),{buildExperiment:Zx(y,u),module:y,manifest:f,files:g,urls:Object.assign({},m),project:w}}finally{for(let y of b)typeof y.release=="function"&&y.release()}}o(ao,"linkProject");function e1(e,t){if(!e||typeof e.message!="string")return e;let r=new Map;for(let a of Object.keys(t))r.set(t[a],(r.get(t[a])||[]).concat(a));let i=e.message;for(let[a,s]of[...r.entries()].sort(function(l,c){return c[0].length-l[0].length}))i=i.split(a).join(s.join(" (= ")+(s.length>1?", byte-identical)":""));let n=ze();i=i.replace(new RegExp(n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+`([^\\s;,)'"]+)`,"g"),function(a,s){return vs(s)||a});try{e.message=i}catch{}return e}o(e1,"_namePaths");var mv=new Map;function _c(e){let t=mv.get(e);return t||(t=URL.createObjectURL(new Blob([e],{type:"text/javascript"})),mv.set(e,t)),{url:t,release:o(function(){},"release")}}o(_c,"blobMint");function bv(e,t,r){let i={};return o(function(a){let s=gs(a);if(i[s])return i[s];let l=e[s];l||Xe('"'+a+'" names '+s+", which this host does not carry (it carries: "+Object.keys(e).join(", ")+").");let c=["const ns = "+t+"["+JSON.stringify(s)+"];"];for(let f of Object.keys(l))f==="default"?c.push("export default ns.default;"):/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(f)?c.push("export const "+f+" = ns."+f+";"):Xe(s+' exports "'+f+'", which is not an identifier.');return i[s]=r(c.join(`
|
|
26
26
|
`)+`
|
|
27
|
-
`).url,n[s]},"bare")}o(Xg,"namespaceBare");var Sx=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,78,5,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,199,7,137,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,55,9,266,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],nv=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,7,25,39,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,5,57,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,24,43,261,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7381,42,31,98,114,8702,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,208,30,2,2,2,1,2,6,3,4,10,1,225,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4381,3,5773,3,7472,16,621,2467,541,1507,4938,6,8489],kx="\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ADD\u1AE0-\u1AEB\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65",iv="\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC",zh={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},Vh="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",Ax={5:Vh,"5module":Vh+" export import",6:Vh+" const class extends export import super"},av=/^in(stanceof)?$/,Tx=new RegExp("["+iv+"]"),Cx=new RegExp("["+iv+kx+"]");function Bh(e,t){for(var r=65536,n=0;n<t.length;n+=2){if(r+=t[n],r>e)return!1;if(r+=t[n+1],r>=e)return!0}return!1}o(Bh,"isInAstralSet");function En(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Tx.test(String.fromCharCode(e)):t===!1?!1:Bh(e,nv)}o(En,"isIdentifierStart");function fi(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Cx.test(String.fromCharCode(e)):t===!1?!1:Bh(e,nv)||Bh(e,Sx)}o(fi,"isIdentifierChar");var $e=o(function(t,r){r===void 0&&(r={}),this.label=t,this.keyword=r.keyword,this.beforeExpr=!!r.beforeExpr,this.startsExpr=!!r.startsExpr,this.isLoop=!!r.isLoop,this.isAssign=!!r.isAssign,this.prefix=!!r.prefix,this.postfix=!!r.postfix,this.binop=r.binop||null,this.updateContext=null},"TokenType");function Vr(e,t){return new $e(e,{beforeExpr:!0,binop:t})}o(Vr,"binop");var qr={beforeExpr:!0},kr={startsExpr:!0},Kh={};function Qe(e,t){return t===void 0&&(t={}),t.keyword=e,Kh[e]=new $e(e,t)}o(Qe,"kw");var x={num:new $e("num",kr),regexp:new $e("regexp",kr),string:new $e("string",kr),name:new $e("name",kr),privateId:new $e("privateId",kr),eof:new $e("eof"),bracketL:new $e("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new $e("]"),braceL:new $e("{",{beforeExpr:!0,startsExpr:!0}),braceR:new $e("}"),parenL:new $e("(",{beforeExpr:!0,startsExpr:!0}),parenR:new $e(")"),comma:new $e(",",qr),semi:new $e(";",qr),colon:new $e(":",qr),dot:new $e("."),question:new $e("?",qr),questionDot:new $e("?."),arrow:new $e("=>",qr),template:new $e("template"),invalidTemplate:new $e("invalidTemplate"),ellipsis:new $e("...",qr),backQuote:new $e("`",kr),dollarBraceL:new $e("${",{beforeExpr:!0,startsExpr:!0}),eq:new $e("=",{beforeExpr:!0,isAssign:!0}),assign:new $e("_=",{beforeExpr:!0,isAssign:!0}),incDec:new $e("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new $e("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:Vr("||",1),logicalAND:Vr("&&",2),bitwiseOR:Vr("|",3),bitwiseXOR:Vr("^",4),bitwiseAND:Vr("&",5),equality:Vr("==/!=/===/!==",6),relational:Vr("</>/<=/>=",7),bitShift:Vr("<</>>/>>>",8),plusMin:new $e("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:Vr("%",10),star:Vr("*",10),slash:Vr("/",10),starstar:new $e("**",{beforeExpr:!0}),coalesce:Vr("??",1),_break:Qe("break"),_case:Qe("case",qr),_catch:Qe("catch"),_continue:Qe("continue"),_debugger:Qe("debugger"),_default:Qe("default",qr),_do:Qe("do",{isLoop:!0,beforeExpr:!0}),_else:Qe("else",qr),_finally:Qe("finally"),_for:Qe("for",{isLoop:!0}),_function:Qe("function",kr),_if:Qe("if"),_return:Qe("return",qr),_switch:Qe("switch"),_throw:Qe("throw",qr),_try:Qe("try"),_var:Qe("var"),_const:Qe("const"),_while:Qe("while",{isLoop:!0}),_with:Qe("with"),_new:Qe("new",{beforeExpr:!0,startsExpr:!0}),_this:Qe("this",kr),_super:Qe("super",kr),_class:Qe("class",kr),_extends:Qe("extends",qr),_export:Qe("export"),_import:Qe("import",kr),_null:Qe("null",kr),_true:Qe("true",kr),_false:Qe("false",kr),_in:Qe("in",{beforeExpr:!0,binop:7}),_instanceof:Qe("instanceof",{beforeExpr:!0,binop:7}),_typeof:Qe("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:Qe("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:Qe("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},Ar=/\r\n?|\n|\u2028|\u2029/,Rx=new RegExp(Ar.source,"g");function Za(e){return e===10||e===13||e===8232||e===8233}o(Za,"isNewLine");function ov(e,t,r){r===void 0&&(r=e.length);for(var n=t;n<r;n++){var i=e.charCodeAt(n);if(Za(i))return n<r-1&&i===13&&e.charCodeAt(n+1)===10?n+2:n+1}return-1}o(ov,"nextLineBreak");var sv=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,$t=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,lv=Object.prototype,Dx=lv.hasOwnProperty,jx=lv.toString,$a=Object.hasOwn||(function(e,t){return Dx.call(e,t)}),Zg=Array.isArray||(function(e){return jx.call(e)==="[object Array]"}),$g=Object.create(null);function ci(e){return $g[e]||($g[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}o(ci,"wordsRegexp");function Wn(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}o(Wn,"codePointToString");var Lx=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,ss=o(function(t,r){this.line=t,this.column=r},"Position");ss.prototype.offset=o(function(t){return new ss(this.line,this.column+t)},"offset");var ru=o(function(t,r,n){this.start=r,this.end=n,t.sourceFile!==null&&(this.source=t.sourceFile)},"SourceLocation");function uv(e,t){for(var r=1,n=0;;){var i=ov(e,n,t);if(i<0)return new ss(r,t-n);++r,n=i}}o(uv,"getLineInfo");var Wh={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},ev=!1;function Ix(e){var t={};for(var r in Wh)t[r]=e&&$a(e,r)?e[r]:Wh[r];if(t.ecmaVersion==="latest"?t.ecmaVersion=1e8:t.ecmaVersion==null?(!ev&&typeof console=="object"&&console.warn&&(ev=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
28
|
-
Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved==null&&(t.allowReserved=t.ecmaVersion<5),(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),
|
|
29
|
-
`,n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(Ar).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=x.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=t.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&t.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType==="commonjs"?Zi:Xi),this.regexpState=null,this.privateNameStack=[]},"Parser"),Wr={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};Nt.prototype.parse=o(function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)},"parse");Wr.inFunction.get=function(){return(this.currentVarScope().flags&Zi)>0};Wr.inGenerator.get=function(){return(this.currentVarScope().flags&cv)>0};Wr.inAsync.get=function(){return(this.currentVarScope().flags&Yh)>0};Wr.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],r=t.flags;if(r&($i|ls))return!1;if(r&Zi)return(r&Yh)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};Wr.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&Xi)};Wr.allowSuper.get=function(){var e=this.currentThisScope(),t=e.flags;return(t&nu)>0||this.options.allowSuperOutsideMethod};Wr.allowDirectSuper.get=function(){return(this.currentThisScope().flags&hv)>0};Wr.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};Wr.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],r=t.flags;if(r&($i|ls)||r&Zi&&!(r&Jh))return!0}return!1};Wr.allowUsing.get=function(){var e=this.currentScope(),t=e.flags;return!(t&dv||!this.inModule&&t&Xi)};Wr.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&$i)>0};Nt.extend=o(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];for(var n=this,i=0;i<t.length;i++)n=t[i](n);return n},"extend");Nt.parse=o(function(t,r){return new this(r,t).parse()},"parse");Nt.parseExpressionAt=o(function(t,r,n){var i=new this(n,t,r);return i.nextToken(),i.parseExpression()},"parseExpressionAt");Nt.tokenizer=o(function(t,r){return new this(r,t)},"tokenizer");Object.defineProperties(Nt.prototype,Wr);var lr=Nt.prototype,Fx=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;lr.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){$t.lastIndex=e,e+=$t.exec(this.input)[0].length;var t=Fx.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])==="use strict"){$t.lastIndex=e+t[0].length;var r=$t.exec(this.input),n=r.index+r[0].length,i=this.input.charAt(n);return i===";"||i==="}"||Ar.test(r[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||i==="!"&&this.input.charAt(n+1)==="=")}e+=t[0].length,$t.lastIndex=e,e+=$t.exec(this.input)[0].length,this.input[e]===";"&&e++}};lr.eat=function(e){return this.type===e?(this.next(),!0):!1};lr.isContextual=function(e){return this.type===x.name&&this.value===e&&!this.containsEsc};lr.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1};lr.expectContextual=function(e){this.eatContextual(e)||this.unexpected()};lr.canInsertSemicolon=function(){return this.type===x.eof||this.type===x.braceR||Ar.test(this.input.slice(this.lastTokEnd,this.start))};lr.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};lr.semicolon=function(){!this.eat(x.semi)&&!this.insertSemicolon()&&this.unexpected()};lr.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0};lr.expect=function(e){this.eat(e)||this.unexpected()};lr.unexpected=function(e){this.raise(e??this.start,"Unexpected token")};var au=o(function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1},"DestructuringErrors");lr.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var r=t?e.parenthesizedAssign:e.parenthesizedBind;r>-1&&this.raiseRecoverable(r,t?"Assigning to rvalue":"Parenthesized pattern")}};lr.checkExpressionErrors=function(e,t){if(!e)return!1;var r=e.shorthandAssign,n=e.doubleProto;if(!t)return r>=0||n>=0;r>=0&&this.raise(r,"Shorthand property assignments are valid only in destructuring patterns"),n>=0&&this.raiseRecoverable(n,"Redefinition of __proto__ property")};lr.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")};lr.isSimpleAssignTarget=function(e){return e.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(e.expression):e.type==="Identifier"||e.type==="MemberExpression"};var me=Nt.prototype;me.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==x.eof;){var r=this.parseStatement(null,!0,t);e.body.push(r)}if(this.inModule)for(var n=0,i=Object.keys(this.undefinedExports);n<i.length;n+=1){var a=i[n];this.raiseRecoverable(this.undefinedExports[a].start,"Export '"+a+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType==="commonjs"?"script":this.options.sourceType,this.finishNode(e,"Program")};var Zh={kind:"loop"},Nx={kind:"switch"};me.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;$t.lastIndex=this.pos;var t=$t.exec(this.input),r=this.pos+t[0].length,n=this.fullCharCodeAt(r);if(n===91||n===92)return!0;if(e)return!1;if(n===123)return!0;if(En(n)){var i=r;do r+=n<=65535?1:2;while(fi(n=this.fullCharCodeAt(r)));if(n===92)return!0;var a=this.input.slice(i,r);if(!av.test(a))return!0}return!1};me.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;$t.lastIndex=this.pos;var e=$t.exec(this.input),t=this.pos+e[0].length,r;return!Ar.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)==="function"&&(t+8===this.input.length||!(fi(r=this.fullCharCodeAt(t+8))||r===92))};me.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;$t.lastIndex=this.pos;var r=$t.exec(this.input),n=this.pos+r[0].length;if(Ar.test(this.input.slice(this.pos,n)))return!1;if(e){var i=n+5,a;if(this.input.slice(n,i)!=="using"||i===this.input.length||fi(a=this.fullCharCodeAt(i))||a===92)return!1;$t.lastIndex=i;var s=$t.exec(this.input);if(n=i+s[0].length,s&&Ar.test(this.input.slice(i,n)))return!1}var l=this.fullCharCodeAt(n);if(!En(l)&&l!==92)return!1;var u=n;do n+=l<=65535?1:2;while(fi(l=this.fullCharCodeAt(n)));if(l===92)return!0;var f=this.input.slice(u,n);return!(av.test(f)||t&&f==="of")};me.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)};me.isUsing=function(e){return this.isUsingKeyword(!1,e)};me.parseStatement=function(e,t,r){var n=this.type,i=this.startNode(),a;switch(this.isLet(e)&&(n=x._var,a="let"),n){case x._break:case x._continue:return this.parseBreakContinueStatement(i,n.keyword);case x._debugger:return this.parseDebuggerStatement(i);case x._do:return this.parseDoStatement(i);case x._for:return this.parseForStatement(i);case x._function:return e&&(this.strict||e!=="if"&&e!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!e);case x._class:return e&&this.unexpected(),this.parseClass(i,!0);case x._if:return this.parseIfStatement(i);case x._return:return this.parseReturnStatement(i);case x._switch:return this.parseSwitchStatement(i);case x._throw:return this.parseThrowStatement(i);case x._try:return this.parseTryStatement(i);case x._const:case x._var:return a=a||this.value,e&&a!=="var"&&this.unexpected(),this.parseVarStatement(i,a);case x._while:return this.parseWhileStatement(i);case x._with:return this.parseWithStatement(i);case x.braceL:return this.parseBlock(!0,i);case x.semi:return this.parseEmptyStatement(i);case x._export:case x._import:if(this.options.ecmaVersion>10&&n===x._import){$t.lastIndex=this.pos;var s=$t.exec(this.input),l=this.pos+s[0].length,u=this.input.charCodeAt(l);if(u===40||u===46)return this.parseExpressionStatement(i,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),n===x._import?this.parseImport(i):this.parseExport(i,r);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(i,!0,!e);var f=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(f)return this.allowUsing||this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"),f==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(i,!1,f),this.semicolon(),this.finishNode(i,"VariableDeclaration");var c=this.value,h=this.parseExpression();return n===x.name&&h.type==="Identifier"&&this.eat(x.colon)?this.parseLabeledStatement(i,c,h,e):this.parseExpressionStatement(i,h)}};me.parseBreakContinueStatement=function(e,t){var r=t==="break";this.next(),this.eat(x.semi)||this.insertSemicolon()?e.label=null:this.type!==x.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var n=0;n<this.labels.length;++n){var i=this.labels[n];if((e.label==null||i.name===e.label.name)&&(i.kind!=null&&(r||i.kind==="loop")||e.label&&r))break}return n===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,r?"BreakStatement":"ContinueStatement")};me.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")};me.parseDoStatement=function(e){return this.next(),this.labels.push(Zh),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(x._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(x.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")};me.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(Zh),this.enterScope(0),this.expect(x.parenL),this.type===x.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var r=this.isLet();if(this.type===x._var||this.type===x._const||r){var n=this.startNode(),i=r?"let":this.value;return this.next(),this.parseVar(n,!0,i),this.finishNode(n,"VariableDeclaration"),this.parseForAfterInit(e,n,t)}var a=this.isContextual("let"),s=!1,l=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(l){var u=this.startNode();return this.next(),l==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.parseVar(u,!0,l),this.finishNode(u,"VariableDeclaration"),this.parseForAfterInit(e,u,t)}var f=this.containsEsc,c=new au,h=this.start,g=t>-1?this.parseExprSubscripts(c,"await"):this.parseExpression(!0,c);return this.type===x._in||(s=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===x._in&&this.unexpected(t),e.await=!0):s&&this.options.ecmaVersion>=8&&(g.start===h&&!f&&g.type==="Identifier"&&g.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&s&&this.raise(g.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(g,!1,c),this.checkLValPattern(g),this.parseForIn(e,g)):(this.checkExpressionErrors(c,!0),t>-1&&this.unexpected(t),this.parseFor(e,g))};me.parseForAfterInit=function(e,t,r){return(this.type===x._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&t.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===x._in?r>-1&&this.unexpected(r):e.await=r>-1),this.parseForIn(e,t)):(r>-1&&this.unexpected(r),this.parseFor(e,t))};me.parseFunctionStatement=function(e,t,r){return this.next(),this.parseFunction(e,os|(r?0:Gh),!1,t)};me.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(x._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")};me.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(x.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")};me.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(x.braceL),this.labels.push(Nx),this.enterScope(dv);for(var t,r=!1;this.type!==x.braceR;)if(this.type===x._case||this.type===x._default){var n=this.type===x._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),n?t.test=this.parseExpression():(r&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),r=!0,t.test=null),this.expect(x.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")};me.parseThrowStatement=function(e){return this.next(),Ar.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var Mx=[];me.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type==="Identifier";return this.enterScope(t?fv:0),this.checkLValPattern(e,t?mv:Hn),this.expect(x.parenR),e};me.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===x._catch){var t=this.startNode();this.next(),this.eat(x.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(x._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")};me.parseVarStatement=function(e,t,r){return this.next(),this.parseVar(e,!1,t,r),this.semicolon(),this.finishNode(e,"VariableDeclaration")};me.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Zh),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")};me.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement("with"),this.finishNode(e,"WithStatement")};me.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")};me.parseLabeledStatement=function(e,t,r,n){for(var i=0,a=this.labels;i<a.length;i+=1){var s=a[i];s.name===t&&this.raise(r.start,"Label '"+t+"' is already declared")}for(var l=this.type.isLoop?"loop":this.type===x._switch?"switch":null,u=this.labels.length-1;u>=0;u--){var f=this.labels[u];if(f.statementStart===e.start)f.statementStart=this.start,f.kind=l;else break}return this.labels.push({name:t,kind:l,statementStart:this.start}),e.body=this.parseStatement(n?n.indexOf("label")===-1?n+"label":n:"label"),this.labels.pop(),e.label=r,this.finishNode(e,"LabeledStatement")};me.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")};me.parseBlock=function(e,t,r){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(x.braceL),e&&this.enterScope(0);this.type!==x.braceR;){var n=this.parseStatement(null);t.body.push(n)}return r&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")};me.parseFor=function(e,t){return e.init=t,this.expect(x.semi),e.test=this.type===x.semi?null:this.parseExpression(),this.expect(x.semi),e.update=this.type===x.parenR?null:this.parseExpression(),this.expect(x.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")};me.parseForIn=function(e,t){var r=this.type===x._in;return this.next(),t.type==="VariableDeclaration"&&t.declarations[0].init!=null&&(!r||this.options.ecmaVersion<8||this.strict||t.kind!=="var"||t.declarations[0].id.type!=="Identifier")&&this.raise(t.start,(r?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=t,e.right=r?this.parseExpression():this.parseMaybeAssign(),this.expect(x.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,r?"ForInStatement":"ForOfStatement")};me.parseVar=function(e,t,r,n){for(e.declarations=[],e.kind=r;;){var i=this.startNode();if(this.parseVarId(i,r),this.eat(x.eq)?i.init=this.parseMaybeAssign(t):!n&&r==="const"&&!(this.type===x._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!n&&(r==="using"||r==="await using")&&this.options.ecmaVersion>=17&&this.type!==x._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+r+" declaration"):!n&&i.id.type!=="Identifier"&&!(t&&(this.type===x._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):i.init=null,e.declarations.push(this.finishNode(i,"VariableDeclarator")),!this.eat(x.comma))break}return e};me.parseVarId=function(e,t){e.id=t==="using"||t==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t==="var"?Xh:Hn,!1)};var os=1,Gh=2,vv=4;me.parseFunction=function(e,t,r,n,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!n)&&(this.type===x.star&&t&Gh&&this.unexpected(),e.generator=this.eat(x.star)),this.options.ecmaVersion>=8&&(e.async=!!n),t&os&&(e.id=t&vv&&this.type!==x.name?null:this.parseIdent(),e.id&&!(t&Gh)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?Xh:Hn:pv));var a=this.yieldPos,s=this.awaitPos,l=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Qh(e.async,e.generator)),t&os||(e.id=this.type===x.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,r,!1,i),this.yieldPos=a,this.awaitPos=s,this.awaitIdentPos=l,this.finishNode(e,t&os?"FunctionDeclaration":"FunctionExpression")};me.parseFunctionParams=function(e){this.expect(x.parenL),e.params=this.parseBindingList(x.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};me.parseClass=function(e,t){this.next();var r=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var n=this.enterClassBody(),i=this.startNode(),a=!1;for(i.body=[],this.expect(x.braceL);this.type!==x.braceR;){var s=this.parseClassElement(e.superClass!==null);s&&(i.body.push(s),s.type==="MethodDefinition"&&s.kind==="constructor"?(a&&this.raiseRecoverable(s.start,"Duplicate constructor in the same class"),a=!0):s.key&&s.key.type==="PrivateIdentifier"&&Ux(n,s)&&this.raiseRecoverable(s.key.start,"Identifier '#"+s.key.name+"' has already been declared"))}return this.strict=r,this.next(),e.body=this.finishNode(i,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")};me.parseClassElement=function(e){if(this.eat(x.semi))return null;var t=this.options.ecmaVersion,r=this.startNode(),n="",i=!1,a=!1,s="method",l=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(x.braceL))return this.parseClassStaticBlock(r),r;this.isClassElementNameStart()||this.type===x.star?l=!0:n="static"}if(r.static=l,!n&&t>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===x.star)&&!this.canInsertSemicolon()?a=!0:n="async"),!n&&(t>=9||!a)&&this.eat(x.star)&&(i=!0),!n&&!a&&!i){var u=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?s=u:n=u)}if(n?(r.computed=!1,r.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),r.key.name=n,this.finishNode(r.key,"Identifier")):this.parseClassElementName(r),t<13||this.type===x.parenL||s!=="method"||i||a){var f=!r.static&&$l(r,"constructor"),c=f&&e;f&&s!=="method"&&this.raise(r.key.start,"Constructor can't have get/set modifier"),r.kind=f?"constructor":s,this.parseClassMethod(r,i,a,c)}else this.parseClassField(r);return r};me.isClassElementNameStart=function(){return this.type===x.name||this.type===x.privateId||this.type===x.num||this.type===x.string||this.type===x.bracketL||this.type.keyword};me.parseClassElementName=function(e){this.type===x.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)};me.parseClassMethod=function(e,t,r,n){var i=e.key;e.kind==="constructor"?(t&&this.raise(i.start,"Constructor can't be a generator"),r&&this.raise(i.start,"Constructor can't be an async method")):e.static&&$l(e,"prototype")&&this.raise(i.start,"Classes may not have a static property named prototype");var a=e.value=this.parseMethod(t,r,n);return e.kind==="get"&&a.params.length!==0&&this.raiseRecoverable(a.start,"getter should have no params"),e.kind==="set"&&a.params.length!==1&&this.raiseRecoverable(a.start,"setter should have exactly one param"),e.kind==="set"&&a.params[0].type==="RestElement"&&this.raiseRecoverable(a.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")};me.parseClassField=function(e){return $l(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&$l(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(x.eq)?(this.enterScope(ls|nu),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")};me.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope($i|nu);this.type!==x.braceR;){var r=this.parseStatement(null);e.body.push(r)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")};me.parseClassId=function(e,t){this.type===x.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,Hn,!1)):(t===!0&&this.unexpected(),e.id=null)};me.parseClassSuper=function(e){e.superClass=this.eat(x._extends)?this.parseExprSubscripts(null,!1):null};me.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared};me.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,r=e.used;if(this.options.checkPrivateFields)for(var n=this.privateNameStack.length,i=n===0?null:this.privateNameStack[n-1],a=0;a<r.length;++a){var s=r[a];$a(t,s.name)||(i?i.used.push(s):this.raiseRecoverable(s.start,"Private field '#"+s.name+"' must be declared in an enclosing class"))}};function Ux(e,t){var r=t.key.name,n=e[r],i="true";return t.type==="MethodDefinition"&&(t.kind==="get"||t.kind==="set")&&(i=(t.static?"s":"i")+t.kind),n==="iget"&&i==="iset"||n==="iset"&&i==="iget"||n==="sget"&&i==="sset"||n==="sset"&&i==="sget"?(e[r]="true",!1):n?!0:(e[r]=i,!1)}o(Ux,"isPrivateNameConflicted");function $l(e,t){var r=e.computed,n=e.key;return!r&&(n.type==="Identifier"&&n.name===t||n.type==="Literal"&&n.value===t)}o($l,"checkKeyName");me.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual("from"),this.type!==x.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")};me.parseExport=function(e,t){if(this.next(),this.eat(x.star))return this.parseExportAllDeclaration(e,t);if(this.eat(x._default))return this.checkExport(t,"default",this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type==="VariableDeclaration"?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))this.type!==x.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var r=0,n=e.specifiers;r<n.length;r+=1){var i=n[r];this.checkUnreserved(i.local),this.checkLocalExport(i.local),i.local.type==="Literal"&&this.raise(i.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,"ExportNamedDeclaration")};me.parseExportDeclaration=function(e){return this.parseStatement(null)};me.parseExportDefaultDeclaration=function(){var e;if(this.type===x._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,os|vv,!1,e)}else if(this.type===x._class){var r=this.startNode();return this.parseClass(r,"nullableID")}else{var n=this.parseMaybeAssign();return this.semicolon(),n}};me.checkExport=function(e,t,r){e&&(typeof t!="string"&&(t=t.type==="Identifier"?t.name:t.value),$a(e,t)&&this.raiseRecoverable(r,"Duplicate export '"+t+"'"),e[t]=!0)};me.checkPatternExport=function(e,t){var r=t.type;if(r==="Identifier")this.checkExport(e,t,t.start);else if(r==="ObjectPattern")for(var n=0,i=t.properties;n<i.length;n+=1){var a=i[n];this.checkPatternExport(e,a)}else if(r==="ArrayPattern")for(var s=0,l=t.elements;s<l.length;s+=1){var u=l[s];u&&this.checkPatternExport(e,u)}else r==="Property"?this.checkPatternExport(e,t.value):r==="AssignmentPattern"?this.checkPatternExport(e,t.left):r==="RestElement"&&this.checkPatternExport(e,t.argument)};me.checkVariableExport=function(e,t){if(e)for(var r=0,n=t;r<n.length;r+=1){var i=n[r];this.checkPatternExport(e,i.id)}};me.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};me.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual("as")?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,"ExportSpecifier")};me.parseExportSpecifiers=function(e){var t=[],r=!0;for(this.expect(x.braceL);!this.eat(x.braceR);){if(r)r=!1;else if(this.expect(x.comma),this.afterTrailingComma(x.braceR))break;t.push(this.parseExportSpecifier(e))}return t};me.parseImport=function(e){return this.next(),this.type===x.string?(e.specifiers=Mx,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===x.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")};me.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual("as")?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,Hn),this.finishNode(e,"ImportSpecifier")};me.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,Hn),this.finishNode(e,"ImportDefaultSpecifier")};me.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,Hn),this.finishNode(e,"ImportNamespaceSpecifier")};me.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===x.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(x.comma)))return e;if(this.type===x.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(x.braceL);!this.eat(x.braceR);){if(t)t=!1;else if(this.expect(x.comma),this.afterTrailingComma(x.braceR))break;e.push(this.parseImportSpecifier())}return e};me.parseWithClause=function(){var e=[];if(!this.eat(x._with))return e;this.expect(x.braceL);for(var t={},r=!0;!this.eat(x.braceR);){if(r)r=!1;else if(this.expect(x.comma),this.afterTrailingComma(x.braceR))break;var n=this.parseImportAttribute(),i=n.key.type==="Identifier"?n.key.name:n.key.value;$a(t,i)&&this.raiseRecoverable(n.key.start,"Duplicate attribute key '"+i+"'"),t[i]=!0,e.push(n)}return e};me.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===x.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(x.colon),this.type!==x.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")};me.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===x.string){var e=this.parseLiteral(this.value);return Lx.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)};me.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)};me.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type==="ExpressionStatement"&&e.expression.type==="Literal"&&typeof e.expression.value=="string"&&(this.input[e.start]==='"'||this.input[e.start]==="'")};var Gr=Nt.prototype;Gr.toAssignable=function(e,t,r){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&e.name==="await"&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",r&&this.checkPatternErrors(r,!0);for(var n=0,i=e.properties;n<i.length;n+=1){var a=i[n];this.toAssignable(a,t),a.type==="RestElement"&&(a.argument.type==="ArrayPattern"||a.argument.type==="ObjectPattern")&&this.raise(a.argument.start,"Unexpected token")}break;case"Property":e.kind!=="init"&&this.raise(e.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(e.value,t);break;case"ArrayExpression":e.type="ArrayPattern",r&&this.checkPatternErrors(r,!0),this.toAssignableList(e.elements,t);break;case"SpreadElement":e.type="RestElement",this.toAssignable(e.argument,t),e.argument.type==="AssignmentPattern"&&this.raise(e.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":e.operator!=="="&&this.raise(e.left.end,"Only '=' operator can be used for specifying default value."),e.type="AssignmentPattern",delete e.operator,this.toAssignable(e.left,t);break;case"ParenthesizedExpression":this.toAssignable(e.expression,t,r);break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!t)break;default:this.raise(e.start,"Assigning to rvalue")}else r&&this.checkPatternErrors(r,!0);return e};Gr.toAssignableList=function(e,t){for(var r=e.length,n=0;n<r;n++){var i=e[n];i&&this.toAssignable(i,t)}if(r){var a=e[r-1];this.options.ecmaVersion===6&&t&&a&&a.type==="RestElement"&&a.argument.type!=="Identifier"&&this.unexpected(a.argument.start)}return e};Gr.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")};Gr.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==x.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")};Gr.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case x.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(x.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case x.braceL:return this.parseObj(!0)}return this.parseIdent()};Gr.parseBindingList=function(e,t,r,n){for(var i=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(x.comma),t&&this.type===x.comma)i.push(null);else{if(r&&this.afterTrailingComma(e))break;if(this.type===x.ellipsis){var s=this.parseRestBinding();this.parseBindingListItem(s),i.push(s),this.type===x.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}else i.push(this.parseAssignableListItem(n))}return i};Gr.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t};Gr.parseBindingListItem=function(e){return e};Gr.parseMaybeDefault=function(e,t,r){if(r=r||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(x.eq))return r;var n=this.startNodeAt(e,t);return n.left=r,n.right=this.parseMaybeAssign(),this.finishNode(n,"AssignmentPattern")};Gr.checkLValSimple=function(e,t,r){t===void 0&&(t=Zl);var n=t!==Zl;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(n?"Binding ":"Assigning to ")+e.name+" in strict mode"),n&&(t===Hn&&e.name==="let"&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),r&&($a(r,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),r[e.name]=!0),t!==gv&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":n&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return n&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,r);default:this.raise(e.start,(n?"Binding":"Assigning to")+" rvalue")}};Gr.checkLValPattern=function(e,t,r){switch(t===void 0&&(t=Zl),e.type){case"ObjectPattern":for(var n=0,i=e.properties;n<i.length;n+=1){var a=i[n];this.checkLValInnerPattern(a,t,r)}break;case"ArrayPattern":for(var s=0,l=e.elements;s<l.length;s+=1){var u=l[s];u&&this.checkLValInnerPattern(u,t,r)}break;default:this.checkLValSimple(e,t,r)}};Gr.checkLValInnerPattern=function(e,t,r){switch(t===void 0&&(t=Zl),e.type){case"Property":this.checkLValInnerPattern(e.value,t,r);break;case"AssignmentPattern":this.checkLValPattern(e.left,t,r);break;case"RestElement":this.checkLValPattern(e.argument,t,r);break;default:this.checkLValPattern(e,t,r)}};var sn=o(function(t,r,n,i,a){this.token=t,this.isExpr=!!r,this.preserveSpace=!!n,this.override=i,this.generator=!!a},"TokContext"),bt={b_stat:new sn("{",!1),b_expr:new sn("{",!0),b_tmpl:new sn("${",!1),p_stat:new sn("(",!1),p_expr:new sn("(",!0),q_tmpl:new sn("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new sn("function",!1),f_expr:new sn("function",!0),f_expr_gen:new sn("function",!0,!1,null,!0),f_gen:new sn("function",!1,!1,null,!0)},eo=Nt.prototype;eo.initialContext=function(){return[bt.b_stat]};eo.curContext=function(){return this.context[this.context.length-1]};eo.braceIsBlock=function(e){var t=this.curContext();return t===bt.f_expr||t===bt.f_stat?!0:e===x.colon&&(t===bt.b_stat||t===bt.b_expr)?!t.isExpr:e===x._return||e===x.name&&this.exprAllowed?Ar.test(this.input.slice(this.lastTokEnd,this.start)):e===x._else||e===x.semi||e===x.eof||e===x.parenR||e===x.arrow?!0:e===x.braceL?t===bt.b_stat:e===x._var||e===x._const||e===x.name?!1:!this.exprAllowed};eo.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token==="function")return t.generator}return!1};eo.updateContext=function(e){var t,r=this.type;r.keyword&&e===x.dot?this.exprAllowed=!1:(t=r.updateContext)?t.call(this,e):this.exprAllowed=r.beforeExpr};eo.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)};x.parenR.updateContext=x.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===bt.b_stat&&this.curContext().token==="function"&&(e=this.context.pop()),this.exprAllowed=!e.isExpr};x.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?bt.b_stat:bt.b_expr),this.exprAllowed=!0};x.dollarBraceL.updateContext=function(){this.context.push(bt.b_tmpl),this.exprAllowed=!0};x.parenL.updateContext=function(e){var t=e===x._if||e===x._for||e===x._with||e===x._while;this.context.push(t?bt.p_stat:bt.p_expr),this.exprAllowed=!0};x.incDec.updateContext=function(){};x._function.updateContext=x._class.updateContext=function(e){e.beforeExpr&&e!==x._else&&!(e===x.semi&&this.curContext()!==bt.p_stat)&&!(e===x._return&&Ar.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===x.colon||e===x.braceL)&&this.curContext()===bt.b_stat)?this.context.push(bt.f_expr):this.context.push(bt.f_stat),this.exprAllowed=!1};x.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};x.backQuote.updateContext=function(){this.curContext()===bt.q_tmpl?this.context.pop():this.context.push(bt.q_tmpl),this.exprAllowed=!1};x.star.updateContext=function(e){if(e===x._function){var t=this.context.length-1;this.context[t]===bt.f_expr?this.context[t]=bt.f_expr_gen:this.context[t]=bt.f_gen}this.exprAllowed=!0};x.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==x.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var Ae=Nt.prototype;Ae.checkPropClash=function(e,t,r){if(!(this.options.ecmaVersion>=9&&e.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var n=e.key,i;switch(n.type){case"Identifier":i=n.name;break;case"Literal":i=String(n.value);break;default:return}var a=e.kind;if(this.options.ecmaVersion>=6){i==="__proto__"&&a==="init"&&(t.proto&&(r?r.doubleProto<0&&(r.doubleProto=n.start):this.raiseRecoverable(n.start,"Redefinition of __proto__ property")),t.proto=!0);return}i="$"+i;var s=t[i];if(s){var l;a==="init"?l=this.strict&&s.init||s.get||s.set:l=s.init||s[a],l&&this.raiseRecoverable(n.start,"Redefinition of property")}else s=t[i]={init:!1,get:!1,set:!1};s[a]=!0}};Ae.parseExpression=function(e,t){var r=this.start,n=this.startLoc,i=this.parseMaybeAssign(e,t);if(this.type===x.comma){var a=this.startNodeAt(r,n);for(a.expressions=[i];this.eat(x.comma);)a.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(a,"SequenceExpression")}return i};Ae.parseMaybeAssign=function(e,t,r){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var n=!1,i=-1,a=-1,s=-1;t?(i=t.parenthesizedAssign,a=t.trailingComma,s=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new au,n=!0);var l=this.start,u=this.startLoc;(this.type===x.parenL||this.type===x.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e==="await");var f=this.parseMaybeConditional(e,t);if(r&&(f=r.call(this,f,l,u)),this.type.isAssign){var c=this.startNodeAt(l,u);return c.operator=this.value,this.type===x.eq&&(f=this.toAssignable(f,!1,t)),n||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=f.start&&(t.shorthandAssign=-1),this.type===x.eq?this.checkLValPattern(f):this.checkLValSimple(f),c.left=f,this.next(),c.right=this.parseMaybeAssign(e),s>-1&&(t.doubleProto=s),this.finishNode(c,"AssignmentExpression")}else n&&this.checkExpressionErrors(t,!0);return i>-1&&(t.parenthesizedAssign=i),a>-1&&(t.trailingComma=a),f};Ae.parseMaybeConditional=function(e,t){var r=this.start,n=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if(this.eat(x.question)){var a=this.startNodeAt(r,n);return a.test=i,a.consequent=this.parseMaybeAssign(),this.expect(x.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,"ConditionalExpression")}return i};Ae.parseExprOps=function(e,t){var r=this.start,n=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===r&&i.type==="ArrowFunctionExpression"?i:this.parseExprOp(i,r,n,-1,e)};Ae.parseExprOp=function(e,t,r,n,i){var a=this.type.binop;if(a!=null&&(!i||this.type!==x._in)&&a>n){var s=this.type===x.logicalOR||this.type===x.logicalAND,l=this.type===x.coalesce;l&&(a=x.logicalAND.binop);var u=this.value;this.next();var f=this.start,c=this.startLoc,h=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),f,c,a,i),g=this.buildBinary(t,r,e,h,u,s||l);return(s&&this.type===x.coalesce||l&&(this.type===x.logicalOR||this.type===x.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(g,t,r,n,i)}return e};Ae.buildBinary=function(e,t,r,n,i,a){n.type==="PrivateIdentifier"&&this.raise(n.start,"Private identifier can only be left side of binary expression");var s=this.startNodeAt(e,t);return s.left=r,s.operator=i,s.right=n,this.finishNode(s,a?"LogicalExpression":"BinaryExpression")};Ae.parseMaybeUnary=function(e,t,r,n){var i=this.start,a=this.startLoc,s;if(this.isContextual("await")&&this.canAwait)s=this.parseAwait(n),t=!0;else if(this.type.prefix){var l=this.startNode(),u=this.type===x.incDec;l.operator=this.value,l.prefix=!0,this.next(),l.argument=this.parseMaybeUnary(null,!0,u,n),this.checkExpressionErrors(e,!0),u?this.checkLValSimple(l.argument):this.strict&&l.operator==="delete"&&yv(l.argument)?this.raiseRecoverable(l.start,"Deleting local variable in strict mode"):l.operator==="delete"&&Hh(l.argument)?this.raiseRecoverable(l.start,"Private fields can not be deleted"):t=!0,s=this.finishNode(l,u?"UpdateExpression":"UnaryExpression")}else if(!t&&this.type===x.privateId)(n||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),s=this.parsePrivateIdent(),this.type!==x._in&&this.unexpected();else{if(s=this.parseExprSubscripts(e,n),this.checkExpressionErrors(e))return s;for(;this.type.postfix&&!this.canInsertSemicolon();){var f=this.startNodeAt(i,a);f.operator=this.value,f.prefix=!1,f.argument=s,this.checkLValSimple(s),this.next(),s=this.finishNode(f,"UpdateExpression")}}if(!r&&this.eat(x.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(i,a,s,this.parseMaybeUnary(null,!1,!1,n),"**",!1);else return s};function yv(e){return e.type==="Identifier"||e.type==="ParenthesizedExpression"&&yv(e.expression)}o(yv,"isLocalVariableAccess");function Hh(e){return e.type==="MemberExpression"&&e.property.type==="PrivateIdentifier"||e.type==="ChainExpression"&&Hh(e.expression)||e.type==="ParenthesizedExpression"&&Hh(e.expression)}o(Hh,"isPrivateFieldAccess");Ae.parseExprSubscripts=function(e,t){var r=this.start,n=this.startLoc,i=this.parseExprAtom(e,t);if(i.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return i;var a=this.parseSubscripts(i,r,n,!1,t);return e&&a.type==="MemberExpression"&&(e.parenthesizedAssign>=a.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=a.start&&(e.parenthesizedBind=-1),e.trailingComma>=a.start&&(e.trailingComma=-1)),a};Ae.parseSubscripts=function(e,t,r,n,i){for(var a=this.options.ecmaVersion>=8&&e.type==="Identifier"&&e.name==="async"&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,s=!1;;){var l=this.parseSubscript(e,t,r,n,a,s,i);if(l.optional&&(s=!0),l===e||l.type==="ArrowFunctionExpression"){if(s){var u=this.startNodeAt(t,r);u.expression=l,l=this.finishNode(u,"ChainExpression")}return l}e=l}};Ae.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(x.arrow)};Ae.parseSubscriptAsyncArrow=function(e,t,r,n){return this.parseArrowExpression(this.startNodeAt(e,t),r,!0,n)};Ae.parseSubscript=function(e,t,r,n,i,a,s){var l=this.options.ecmaVersion>=11,u=l&&this.eat(x.questionDot);n&&u&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var f=this.eat(x.bracketL);if(f||u&&this.type!==x.parenL&&this.type!==x.backQuote||this.eat(x.dot)){var c=this.startNodeAt(t,r);c.object=e,f?(c.property=this.parseExpression(),this.expect(x.bracketR)):this.type===x.privateId&&e.type!=="Super"?c.property=this.parsePrivateIdent():c.property=this.parseIdent(this.options.allowReserved!=="never"),c.computed=!!f,l&&(c.optional=u),e=this.finishNode(c,"MemberExpression")}else if(!n&&this.eat(x.parenL)){var h=new au,g=this.yieldPos,p=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var b=this.parseExprList(x.parenR,this.options.ecmaVersion>=8,!1,h);if(i&&!u&&this.shouldParseAsyncArrow())return this.checkPatternErrors(h,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=g,this.awaitPos=p,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(t,r,b,s);this.checkExpressionErrors(h,!0),this.yieldPos=g||this.yieldPos,this.awaitPos=p||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var y=this.startNodeAt(t,r);y.callee=e,y.arguments=b,l&&(y.optional=u),e=this.finishNode(y,"CallExpression")}else if(this.type===x.backQuote){(u||a)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var w=this.startNodeAt(t,r);w.tag=e,w.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(w,"TaggedTemplateExpression")}return e};Ae.parseExprAtom=function(e,t,r){this.type===x.slash&&this.readRegexp();var n,i=this.potentialArrowAt===this.start;switch(this.type){case x._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),n=this.startNode(),this.next(),this.type===x.parenL&&!this.allowDirectSuper&&this.raise(n.start,"super() call outside constructor of a subclass"),this.type!==x.dot&&this.type!==x.bracketL&&this.type!==x.parenL&&this.unexpected(),this.finishNode(n,"Super");case x._this:return n=this.startNode(),this.next(),this.finishNode(n,"ThisExpression");case x.name:var a=this.start,s=this.startLoc,l=this.containsEsc,u=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!l&&u.name==="async"&&!this.canInsertSemicolon()&&this.eat(x._function))return this.overrideContext(bt.f_expr),this.parseFunction(this.startNodeAt(a,s),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(x.arrow))return this.parseArrowExpression(this.startNodeAt(a,s),[u],!1,t);if(this.options.ecmaVersion>=8&&u.name==="async"&&this.type===x.name&&!l&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return u=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(x.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,s),[u],!0,t)}return u;case x.regexp:var f=this.value;return n=this.parseLiteral(f.value),n.regex={pattern:f.pattern,flags:f.flags},n;case x.num:case x.string:return this.parseLiteral(this.value);case x._null:case x._true:case x._false:return n=this.startNode(),n.value=this.type===x._null?null:this.type===x._true,n.raw=this.type.keyword,this.next(),this.finishNode(n,"Literal");case x.parenL:var c=this.start,h=this.parseParenAndDistinguishExpression(i,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(h)&&(e.parenthesizedAssign=c),e.parenthesizedBind<0&&(e.parenthesizedBind=c)),h;case x.bracketL:return n=this.startNode(),this.next(),n.elements=this.parseExprList(x.bracketR,!0,!0,e),this.finishNode(n,"ArrayExpression");case x.braceL:return this.overrideContext(bt.b_expr),this.parseObj(!1,e);case x._function:return n=this.startNode(),this.next(),this.parseFunction(n,0);case x._class:return this.parseClass(this.startNode(),!1);case x._new:return this.parseNew();case x.backQuote:return this.parseTemplate();case x._import:return this.options.ecmaVersion>=11?this.parseExprImport(r):this.unexpected();default:return this.parseExprAtomDefault()}};Ae.parseExprAtomDefault=function(){this.unexpected()};Ae.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===x.parenL&&!e)return this.parseDynamicImport(t);if(this.type===x.dot){var r=this.startNodeAt(t.start,t.loc&&t.loc.start);return r.name="import",t.meta=this.finishNode(r,"Identifier"),this.parseImportMeta(t)}else this.unexpected()};Ae.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(x.parenR)?e.options=null:(this.expect(x.comma),this.afterTrailingComma(x.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(x.parenR)||(this.expect(x.comma),this.afterTrailingComma(x.parenR)||this.unexpected())));else if(!this.eat(x.parenR)){var t=this.start;this.eat(x.comma)&&this.eat(x.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")};Ae.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="meta"&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),t&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")};Ae.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value!=null?t.value.toString():t.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(t,"Literal")};Ae.parseParenExpression=function(){this.expect(x.parenL);var e=this.parseExpression();return this.expect(x.parenR),e};Ae.shouldParseArrow=function(e){return!this.canInsertSemicolon()};Ae.parseParenAndDistinguishExpression=function(e,t){var r=this.start,n=this.startLoc,i,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var s=this.start,l=this.startLoc,u=[],f=!0,c=!1,h=new au,g=this.yieldPos,p=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==x.parenR;)if(f?f=!1:this.expect(x.comma),a&&this.afterTrailingComma(x.parenR,!0)){c=!0;break}else if(this.type===x.ellipsis){m=this.start,u.push(this.parseParenItem(this.parseRestBinding())),this.type===x.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else u.push(this.parseMaybeAssign(!1,h,this.parseParenItem));var b=this.lastTokEnd,y=this.lastTokEndLoc;if(this.expect(x.parenR),e&&this.shouldParseArrow(u)&&this.eat(x.arrow))return this.checkPatternErrors(h,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=g,this.awaitPos=p,this.parseParenArrowList(r,n,u,t);(!u.length||c)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(h,!0),this.yieldPos=g||this.yieldPos,this.awaitPos=p||this.awaitPos,u.length>1?(i=this.startNodeAt(s,l),i.expressions=u,this.finishNodeAt(i,"SequenceExpression",b,y)):i=u[0]}else i=this.parseParenExpression();if(this.options.preserveParens){var w=this.startNodeAt(r,n);return w.expression=i,this.finishNode(w,"ParenthesizedExpression")}else return i};Ae.parseParenItem=function(e){return e};Ae.parseParenArrowList=function(e,t,r,n){return this.parseArrowExpression(this.startNodeAt(e,t),r,!1,n)};var zx=[];Ae.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===x.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var r=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="target"&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),r&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var n=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),n,i,!0,!1),this.eat(x.parenL)?e.arguments=this.parseExprList(x.parenR,this.options.ecmaVersion>=8,!1):e.arguments=zx,this.finishNode(e,"NewExpression")};Ae.parseTemplateElement=function(e){var t=e.isTagged,r=this.startNode();return this.type===x.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),r.value={raw:this.value.replace(/\r\n?/g,`
|
|
27
|
+
`).url,i[s]},"bare")}o(bv,"namespaceBare");var t1=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,78,5,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,199,7,137,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,55,9,266,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],Sv=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,7,25,39,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,5,57,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,24,43,261,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7381,42,31,98,114,8702,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,208,30,2,2,2,1,2,6,3,4,10,1,225,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4381,3,5773,3,7472,16,621,2467,541,1507,4938,6,8489],r1="\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ADD\u1AE0-\u1AEB\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65",kv="\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC",Ep={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},Sp="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",i1={5:Sp,"5module":Sp+" export import",6:Sp+" const class extends export import super"},Av=/^in(stanceof)?$/,n1=new RegExp("["+kv+"]"),a1=new RegExp("["+kv+r1+"]");function Ap(e,t){for(var r=65536,i=0;i<t.length;i+=2){if(r+=t[i],r>e)return!1;if(r+=t[i+1],r>=e)return!0}return!1}o(Ap,"isInAstralSet");function ki(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&n1.test(String.fromCharCode(e)):t===!1?!1:Ap(e,Sv)}o(ki,"isIdentifierStart");function yn(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&a1.test(String.fromCharCode(e)):t===!1?!1:Ap(e,Sv)||Ap(e,t1)}o(yn,"isIdentifierChar");var $e=o(function(t,r){r===void 0&&(r={}),this.label=t,this.keyword=r.keyword,this.beforeExpr=!!r.beforeExpr,this.startsExpr=!!r.startsExpr,this.isLoop=!!r.isLoop,this.isAssign=!!r.isAssign,this.prefix=!!r.prefix,this.postfix=!!r.postfix,this.binop=r.binop||null,this.updateContext=null},"TokenType");function Br(e,t){return new $e(e,{beforeExpr:!0,binop:t})}o(Br,"binop");var Wr={beforeExpr:!0},kr={startsExpr:!0},Rp={};function Qe(e,t){return t===void 0&&(t={}),t.keyword=e,Rp[e]=new $e(e,t)}o(Qe,"kw");var O={num:new $e("num",kr),regexp:new $e("regexp",kr),string:new $e("string",kr),name:new $e("name",kr),privateId:new $e("privateId",kr),eof:new $e("eof"),bracketL:new $e("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new $e("]"),braceL:new $e("{",{beforeExpr:!0,startsExpr:!0}),braceR:new $e("}"),parenL:new $e("(",{beforeExpr:!0,startsExpr:!0}),parenR:new $e(")"),comma:new $e(",",Wr),semi:new $e(";",Wr),colon:new $e(":",Wr),dot:new $e("."),question:new $e("?",Wr),questionDot:new $e("?."),arrow:new $e("=>",Wr),template:new $e("template"),invalidTemplate:new $e("invalidTemplate"),ellipsis:new $e("...",Wr),backQuote:new $e("`",kr),dollarBraceL:new $e("${",{beforeExpr:!0,startsExpr:!0}),eq:new $e("=",{beforeExpr:!0,isAssign:!0}),assign:new $e("_=",{beforeExpr:!0,isAssign:!0}),incDec:new $e("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new $e("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:Br("||",1),logicalAND:Br("&&",2),bitwiseOR:Br("|",3),bitwiseXOR:Br("^",4),bitwiseAND:Br("&",5),equality:Br("==/!=/===/!==",6),relational:Br("</>/<=/>=",7),bitShift:Br("<</>>/>>>",8),plusMin:new $e("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:Br("%",10),star:Br("*",10),slash:Br("/",10),starstar:new $e("**",{beforeExpr:!0}),coalesce:Br("??",1),_break:Qe("break"),_case:Qe("case",Wr),_catch:Qe("catch"),_continue:Qe("continue"),_debugger:Qe("debugger"),_default:Qe("default",Wr),_do:Qe("do",{isLoop:!0,beforeExpr:!0}),_else:Qe("else",Wr),_finally:Qe("finally"),_for:Qe("for",{isLoop:!0}),_function:Qe("function",kr),_if:Qe("if"),_return:Qe("return",Wr),_switch:Qe("switch"),_throw:Qe("throw",Wr),_try:Qe("try"),_var:Qe("var"),_const:Qe("const"),_while:Qe("while",{isLoop:!0}),_with:Qe("with"),_new:Qe("new",{beforeExpr:!0,startsExpr:!0}),_this:Qe("this",kr),_super:Qe("super",kr),_class:Qe("class",kr),_extends:Qe("extends",Wr),_export:Qe("export"),_import:Qe("import",kr),_null:Qe("null",kr),_true:Qe("true",kr),_false:Qe("false",kr),_in:Qe("in",{beforeExpr:!0,binop:7}),_instanceof:Qe("instanceof",{beforeExpr:!0,binop:7}),_typeof:Qe("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:Qe("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:Qe("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},Ar=/\r\n?|\n|\u2028|\u2029/,o1=new RegExp(Ar.source,"g");function oo(e){return e===10||e===13||e===8232||e===8233}o(oo,"isNewLine");function Tv(e,t,r){r===void 0&&(r=e.length);for(var i=t;i<r;i++){var n=e.charCodeAt(i);if(oo(n))return i<r-1&&n===13&&e.charCodeAt(i+1)===10?i+2:i+1}return-1}o(Tv,"nextLineBreak");var Cv=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,er=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,jv=Object.prototype,s1=jv.hasOwnProperty,l1=jv.toString,so=Object.hasOwn||(function(e,t){return s1.call(e,t)}),wv=Array.isArray||(function(e){return l1.call(e)==="[object Array]"}),_v=Object.create(null);function vn(e){return _v[e]||(_v[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}o(vn,"wordsRegexp");function Ji(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}o(Ji,"codePointToString");var c1=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,xs=o(function(t,r){this.line=t,this.column=r},"Position");xs.prototype.offset=o(function(t){return new xs(this.line,this.column+t)},"offset");var Ac=o(function(t,r,i){this.start=r,this.end=i,t.sourceFile!==null&&(this.source=t.sourceFile)},"SourceLocation");function Rv(e,t){for(var r=1,i=0;;){var n=Tv(e,i,t);if(n<0)return new xs(r,t-i);++r,i=n}}o(Rv,"getLineInfo");var Tp={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},xv=!1;function u1(e){var t={};for(var r in Tp)t[r]=e&&so(e,r)?e[r]:Tp[r];if(t.ecmaVersion==="latest"?t.ecmaVersion=1e8:t.ecmaVersion==null?(!xv&&typeof console=="object"&&console.warn&&(xv=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
28
|
+
Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved==null&&(t.allowReserved=t.ecmaVersion<5),(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),wv(t.onToken)){var i=t.onToken;t.onToken=function(n){return i.push(n)}}if(wv(t.onComment)&&(t.onComment=f1(t,t.onComment)),t.sourceType==="commonjs"&&t.allowAwaitOutsideFunction)throw new Error("Cannot use allowAwaitOutsideFunction with sourceType: commonjs");return t}o(u1,"getOptions");function f1(e,t){return function(r,i,n,a,s,l){var c={type:r?"Block":"Line",value:i,start:n,end:a};e.locations&&(c.loc=new Ac(this,s,l)),e.ranges&&(c.range=[n,a]),t.push(c)}}o(f1,"pushComment");var na=1,aa=2,Dp=4,Dv=8,Lp=16,Lv=32,Tc=64,Pv=128,oa=256,Os=512,Iv=1024,Cc=na|aa|oa;function Pp(e,t){return aa|(e?Dp:0)|(t?Dv:0)}o(Pp,"functionFlags");var Oc=0,Ip=1,Xi=2,Fv=3,Nv=4,Mv=5,Mt=o(function(t,r,i){this.options=t=u1(t),this.sourceFile=t.sourceFile,this.keywords=vn(i1[t.ecmaVersion>=6?6:t.sourceType==="module"?"5module":5]);var n="";t.allowReserved!==!0&&(n=Ep[t.ecmaVersion>=6?6:t.ecmaVersion===5?5:3],t.sourceType==="module"&&(n+=" await")),this.reservedWords=vn(n);var a=(n?n+" ":"")+Ep.strict;this.reservedWordsStrict=vn(a),this.reservedWordsStrictBind=vn(a+" "+Ep.strictBind),this.input=String(r),this.containsEsc=!1,i?(this.pos=i,this.lineStart=this.input.lastIndexOf(`
|
|
29
|
+
`,i-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(Ar).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=O.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=t.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&t.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType==="commonjs"?aa:na),this.regexpState=null,this.privateNameStack=[]},"Parser"),Hr={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};Mt.prototype.parse=o(function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)},"parse");Hr.inFunction.get=function(){return(this.currentVarScope().flags&aa)>0};Hr.inGenerator.get=function(){return(this.currentVarScope().flags&Dv)>0};Hr.inAsync.get=function(){return(this.currentVarScope().flags&Dp)>0};Hr.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],r=t.flags;if(r&(oa|Os))return!1;if(r&aa)return(r&Dp)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};Hr.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&na)};Hr.allowSuper.get=function(){var e=this.currentThisScope(),t=e.flags;return(t&Tc)>0||this.options.allowSuperOutsideMethod};Hr.allowDirectSuper.get=function(){return(this.currentThisScope().flags&Pv)>0};Hr.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};Hr.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],r=t.flags;if(r&(oa|Os)||r&aa&&!(r&Lp))return!0}return!1};Hr.allowUsing.get=function(){var e=this.currentScope(),t=e.flags;return!(t&Iv||!this.inModule&&t&na)};Hr.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&oa)>0};Mt.extend=o(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];for(var i=this,n=0;n<t.length;n++)i=t[n](i);return i},"extend");Mt.parse=o(function(t,r){return new this(r,t).parse()},"parse");Mt.parseExpressionAt=o(function(t,r,i){var n=new this(i,t,r);return n.nextToken(),n.parseExpression()},"parseExpressionAt");Mt.tokenizer=o(function(t,r){return new this(r,t)},"tokenizer");Object.defineProperties(Mt.prototype,Hr);var ur=Mt.prototype,h1=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;ur.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){er.lastIndex=e,e+=er.exec(this.input)[0].length;var t=h1.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])==="use strict"){er.lastIndex=e+t[0].length;var r=er.exec(this.input),i=r.index+r[0].length,n=this.input.charAt(i);return n===";"||n==="}"||Ar.test(r[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(n)||n==="!"&&this.input.charAt(i+1)==="=")}e+=t[0].length,er.lastIndex=e,e+=er.exec(this.input)[0].length,this.input[e]===";"&&e++}};ur.eat=function(e){return this.type===e?(this.next(),!0):!1};ur.isContextual=function(e){return this.type===O.name&&this.value===e&&!this.containsEsc};ur.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1};ur.expectContextual=function(e){this.eatContextual(e)||this.unexpected()};ur.canInsertSemicolon=function(){return this.type===O.eof||this.type===O.braceR||Ar.test(this.input.slice(this.lastTokEnd,this.start))};ur.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};ur.semicolon=function(){!this.eat(O.semi)&&!this.insertSemicolon()&&this.unexpected()};ur.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0};ur.expect=function(e){this.eat(e)||this.unexpected()};ur.unexpected=function(e){this.raise(e??this.start,"Unexpected token")};var jc=o(function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1},"DestructuringErrors");ur.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var r=t?e.parenthesizedAssign:e.parenthesizedBind;r>-1&&this.raiseRecoverable(r,t?"Assigning to rvalue":"Parenthesized pattern")}};ur.checkExpressionErrors=function(e,t){if(!e)return!1;var r=e.shorthandAssign,i=e.doubleProto;if(!t)return r>=0||i>=0;r>=0&&this.raise(r,"Shorthand property assignments are valid only in destructuring patterns"),i>=0&&this.raiseRecoverable(i,"Redefinition of __proto__ property")};ur.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")};ur.isSimpleAssignTarget=function(e){return e.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(e.expression):e.type==="Identifier"||e.type==="MemberExpression"};var me=Mt.prototype;me.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==O.eof;){var r=this.parseStatement(null,!0,t);e.body.push(r)}if(this.inModule)for(var i=0,n=Object.keys(this.undefinedExports);i<n.length;i+=1){var a=n[i];this.raiseRecoverable(this.undefinedExports[a].start,"Export '"+a+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType==="commonjs"?"script":this.options.sourceType,this.finishNode(e,"Program")};var Fp={kind:"loop"},p1={kind:"switch"};me.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;er.lastIndex=this.pos;var t=er.exec(this.input),r=this.pos+t[0].length,i=this.fullCharCodeAt(r);if(i===91||i===92)return!0;if(e)return!1;if(i===123)return!0;if(ki(i)){var n=r;do r+=i<=65535?1:2;while(yn(i=this.fullCharCodeAt(r)));if(i===92)return!0;var a=this.input.slice(n,r);if(!Av.test(a))return!0}return!1};me.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;er.lastIndex=this.pos;var e=er.exec(this.input),t=this.pos+e[0].length,r;return!Ar.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)==="function"&&(t+8===this.input.length||!(yn(r=this.fullCharCodeAt(t+8))||r===92))};me.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;er.lastIndex=this.pos;var r=er.exec(this.input),i=this.pos+r[0].length;if(Ar.test(this.input.slice(this.pos,i)))return!1;if(e){var n=i+5,a;if(this.input.slice(i,n)!=="using"||n===this.input.length||yn(a=this.fullCharCodeAt(n))||a===92)return!1;er.lastIndex=n;var s=er.exec(this.input);if(i=n+s[0].length,s&&Ar.test(this.input.slice(n,i)))return!1}var l=this.fullCharCodeAt(i);if(!ki(l)&&l!==92)return!1;var c=i;do i+=l<=65535?1:2;while(yn(l=this.fullCharCodeAt(i)));if(l===92)return!0;var f=this.input.slice(c,i);return!(Av.test(f)||t&&f==="of")};me.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)};me.isUsing=function(e){return this.isUsingKeyword(!1,e)};me.parseStatement=function(e,t,r){var i=this.type,n=this.startNode(),a;switch(this.isLet(e)&&(i=O._var,a="let"),i){case O._break:case O._continue:return this.parseBreakContinueStatement(n,i.keyword);case O._debugger:return this.parseDebuggerStatement(n);case O._do:return this.parseDoStatement(n);case O._for:return this.parseForStatement(n);case O._function:return e&&(this.strict||e!=="if"&&e!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(n,!1,!e);case O._class:return e&&this.unexpected(),this.parseClass(n,!0);case O._if:return this.parseIfStatement(n);case O._return:return this.parseReturnStatement(n);case O._switch:return this.parseSwitchStatement(n);case O._throw:return this.parseThrowStatement(n);case O._try:return this.parseTryStatement(n);case O._const:case O._var:return a=a||this.value,e&&a!=="var"&&this.unexpected(),this.parseVarStatement(n,a);case O._while:return this.parseWhileStatement(n);case O._with:return this.parseWithStatement(n);case O.braceL:return this.parseBlock(!0,n);case O.semi:return this.parseEmptyStatement(n);case O._export:case O._import:if(this.options.ecmaVersion>10&&i===O._import){er.lastIndex=this.pos;var s=er.exec(this.input),l=this.pos+s[0].length,c=this.input.charCodeAt(l);if(c===40||c===46)return this.parseExpressionStatement(n,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),i===O._import?this.parseImport(n):this.parseExport(n,r);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(n,!0,!e);var f=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(f)return this.allowUsing||this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"),f==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(n,!1,f),this.semicolon(),this.finishNode(n,"VariableDeclaration");var u=this.value,h=this.parseExpression();return i===O.name&&h.type==="Identifier"&&this.eat(O.colon)?this.parseLabeledStatement(n,u,h,e):this.parseExpressionStatement(n,h)}};me.parseBreakContinueStatement=function(e,t){var r=t==="break";this.next(),this.eat(O.semi)||this.insertSemicolon()?e.label=null:this.type!==O.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var i=0;i<this.labels.length;++i){var n=this.labels[i];if((e.label==null||n.name===e.label.name)&&(n.kind!=null&&(r||n.kind==="loop")||e.label&&r))break}return i===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,r?"BreakStatement":"ContinueStatement")};me.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")};me.parseDoStatement=function(e){return this.next(),this.labels.push(Fp),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(O._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(O.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")};me.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(Fp),this.enterScope(0),this.expect(O.parenL),this.type===O.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var r=this.isLet();if(this.type===O._var||this.type===O._const||r){var i=this.startNode(),n=r?"let":this.value;return this.next(),this.parseVar(i,!0,n),this.finishNode(i,"VariableDeclaration"),this.parseForAfterInit(e,i,t)}var a=this.isContextual("let"),s=!1,l=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(l){var c=this.startNode();return this.next(),l==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.parseVar(c,!0,l),this.finishNode(c,"VariableDeclaration"),this.parseForAfterInit(e,c,t)}var f=this.containsEsc,u=new jc,h=this.start,g=t>-1?this.parseExprSubscripts(u,"await"):this.parseExpression(!0,u);return this.type===O._in||(s=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===O._in&&this.unexpected(t),e.await=!0):s&&this.options.ecmaVersion>=8&&(g.start===h&&!f&&g.type==="Identifier"&&g.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&s&&this.raise(g.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(g,!1,u),this.checkLValPattern(g),this.parseForIn(e,g)):(this.checkExpressionErrors(u,!0),t>-1&&this.unexpected(t),this.parseFor(e,g))};me.parseForAfterInit=function(e,t,r){return(this.type===O._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&t.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===O._in?r>-1&&this.unexpected(r):e.await=r>-1),this.parseForIn(e,t)):(r>-1&&this.unexpected(r),this.parseFor(e,t))};me.parseFunctionStatement=function(e,t,r){return this.next(),this.parseFunction(e,_s|(r?0:Cp),!1,t)};me.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(O._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")};me.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(O.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")};me.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(O.braceL),this.labels.push(p1),this.enterScope(Iv);for(var t,r=!1;this.type!==O.braceR;)if(this.type===O._case||this.type===O._default){var i=this.type===O._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),i?t.test=this.parseExpression():(r&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),r=!0,t.test=null),this.expect(O.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")};me.parseThrowStatement=function(e){return this.next(),Ar.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var d1=[];me.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type==="Identifier";return this.enterScope(t?Lv:0),this.checkLValPattern(e,t?Nv:Xi),this.expect(O.parenR),e};me.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===O._catch){var t=this.startNode();this.next(),this.eat(O.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(O._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")};me.parseVarStatement=function(e,t,r){return this.next(),this.parseVar(e,!1,t,r),this.semicolon(),this.finishNode(e,"VariableDeclaration")};me.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Fp),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")};me.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement("with"),this.finishNode(e,"WithStatement")};me.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")};me.parseLabeledStatement=function(e,t,r,i){for(var n=0,a=this.labels;n<a.length;n+=1){var s=a[n];s.name===t&&this.raise(r.start,"Label '"+t+"' is already declared")}for(var l=this.type.isLoop?"loop":this.type===O._switch?"switch":null,c=this.labels.length-1;c>=0;c--){var f=this.labels[c];if(f.statementStart===e.start)f.statementStart=this.start,f.kind=l;else break}return this.labels.push({name:t,kind:l,statementStart:this.start}),e.body=this.parseStatement(i?i.indexOf("label")===-1?i+"label":i:"label"),this.labels.pop(),e.label=r,this.finishNode(e,"LabeledStatement")};me.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")};me.parseBlock=function(e,t,r){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(O.braceL),e&&this.enterScope(0);this.type!==O.braceR;){var i=this.parseStatement(null);t.body.push(i)}return r&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")};me.parseFor=function(e,t){return e.init=t,this.expect(O.semi),e.test=this.type===O.semi?null:this.parseExpression(),this.expect(O.semi),e.update=this.type===O.parenR?null:this.parseExpression(),this.expect(O.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")};me.parseForIn=function(e,t){var r=this.type===O._in;return this.next(),t.type==="VariableDeclaration"&&t.declarations[0].init!=null&&(!r||this.options.ecmaVersion<8||this.strict||t.kind!=="var"||t.declarations[0].id.type!=="Identifier")&&this.raise(t.start,(r?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=t,e.right=r?this.parseExpression():this.parseMaybeAssign(),this.expect(O.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,r?"ForInStatement":"ForOfStatement")};me.parseVar=function(e,t,r,i){for(e.declarations=[],e.kind=r;;){var n=this.startNode();if(this.parseVarId(n,r),this.eat(O.eq)?n.init=this.parseMaybeAssign(t):!i&&r==="const"&&!(this.type===O._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!i&&(r==="using"||r==="await using")&&this.options.ecmaVersion>=17&&this.type!==O._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+r+" declaration"):!i&&n.id.type!=="Identifier"&&!(t&&(this.type===O._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):n.init=null,e.declarations.push(this.finishNode(n,"VariableDeclarator")),!this.eat(O.comma))break}return e};me.parseVarId=function(e,t){e.id=t==="using"||t==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t==="var"?Ip:Xi,!1)};var _s=1,Cp=2,Uv=4;me.parseFunction=function(e,t,r,i,n){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!i)&&(this.type===O.star&&t&Cp&&this.unexpected(),e.generator=this.eat(O.star)),this.options.ecmaVersion>=8&&(e.async=!!i),t&_s&&(e.id=t&Uv&&this.type!==O.name?null:this.parseIdent(),e.id&&!(t&Cp)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?Ip:Xi:Fv));var a=this.yieldPos,s=this.awaitPos,l=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Pp(e.async,e.generator)),t&_s||(e.id=this.type===O.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,r,!1,n),this.yieldPos=a,this.awaitPos=s,this.awaitIdentPos=l,this.finishNode(e,t&_s?"FunctionDeclaration":"FunctionExpression")};me.parseFunctionParams=function(e){this.expect(O.parenL),e.params=this.parseBindingList(O.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};me.parseClass=function(e,t){this.next();var r=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var i=this.enterClassBody(),n=this.startNode(),a=!1;for(n.body=[],this.expect(O.braceL);this.type!==O.braceR;){var s=this.parseClassElement(e.superClass!==null);s&&(n.body.push(s),s.type==="MethodDefinition"&&s.kind==="constructor"?(a&&this.raiseRecoverable(s.start,"Duplicate constructor in the same class"),a=!0):s.key&&s.key.type==="PrivateIdentifier"&&m1(i,s)&&this.raiseRecoverable(s.key.start,"Identifier '#"+s.key.name+"' has already been declared"))}return this.strict=r,this.next(),e.body=this.finishNode(n,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")};me.parseClassElement=function(e){if(this.eat(O.semi))return null;var t=this.options.ecmaVersion,r=this.startNode(),i="",n=!1,a=!1,s="method",l=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(O.braceL))return this.parseClassStaticBlock(r),r;this.isClassElementNameStart()||this.type===O.star?l=!0:i="static"}if(r.static=l,!i&&t>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===O.star)&&!this.canInsertSemicolon()?a=!0:i="async"),!i&&(t>=9||!a)&&this.eat(O.star)&&(n=!0),!i&&!a&&!n){var c=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?s=c:i=c)}if(i?(r.computed=!1,r.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),r.key.name=i,this.finishNode(r.key,"Identifier")):this.parseClassElementName(r),t<13||this.type===O.parenL||s!=="method"||n||a){var f=!r.static&&Ec(r,"constructor"),u=f&&e;f&&s!=="method"&&this.raise(r.key.start,"Constructor can't have get/set modifier"),r.kind=f?"constructor":s,this.parseClassMethod(r,n,a,u)}else this.parseClassField(r);return r};me.isClassElementNameStart=function(){return this.type===O.name||this.type===O.privateId||this.type===O.num||this.type===O.string||this.type===O.bracketL||this.type.keyword};me.parseClassElementName=function(e){this.type===O.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)};me.parseClassMethod=function(e,t,r,i){var n=e.key;e.kind==="constructor"?(t&&this.raise(n.start,"Constructor can't be a generator"),r&&this.raise(n.start,"Constructor can't be an async method")):e.static&&Ec(e,"prototype")&&this.raise(n.start,"Classes may not have a static property named prototype");var a=e.value=this.parseMethod(t,r,i);return e.kind==="get"&&a.params.length!==0&&this.raiseRecoverable(a.start,"getter should have no params"),e.kind==="set"&&a.params.length!==1&&this.raiseRecoverable(a.start,"setter should have exactly one param"),e.kind==="set"&&a.params[0].type==="RestElement"&&this.raiseRecoverable(a.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")};me.parseClassField=function(e){return Ec(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&Ec(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(O.eq)?(this.enterScope(Os|Tc),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")};me.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(oa|Tc);this.type!==O.braceR;){var r=this.parseStatement(null);e.body.push(r)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")};me.parseClassId=function(e,t){this.type===O.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,Xi,!1)):(t===!0&&this.unexpected(),e.id=null)};me.parseClassSuper=function(e){e.superClass=this.eat(O._extends)?this.parseExprSubscripts(null,!1):null};me.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared};me.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,r=e.used;if(this.options.checkPrivateFields)for(var i=this.privateNameStack.length,n=i===0?null:this.privateNameStack[i-1],a=0;a<r.length;++a){var s=r[a];so(t,s.name)||(n?n.used.push(s):this.raiseRecoverable(s.start,"Private field '#"+s.name+"' must be declared in an enclosing class"))}};function m1(e,t){var r=t.key.name,i=e[r],n="true";return t.type==="MethodDefinition"&&(t.kind==="get"||t.kind==="set")&&(n=(t.static?"s":"i")+t.kind),i==="iget"&&n==="iset"||i==="iset"&&n==="iget"||i==="sget"&&n==="sset"||i==="sset"&&n==="sget"?(e[r]="true",!1):i?!0:(e[r]=n,!1)}o(m1,"isPrivateNameConflicted");function Ec(e,t){var r=e.computed,i=e.key;return!r&&(i.type==="Identifier"&&i.name===t||i.type==="Literal"&&i.value===t)}o(Ec,"checkKeyName");me.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual("from"),this.type!==O.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")};me.parseExport=function(e,t){if(this.next(),this.eat(O.star))return this.parseExportAllDeclaration(e,t);if(this.eat(O._default))return this.checkExport(t,"default",this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type==="VariableDeclaration"?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))this.type!==O.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var r=0,i=e.specifiers;r<i.length;r+=1){var n=i[r];this.checkUnreserved(n.local),this.checkLocalExport(n.local),n.local.type==="Literal"&&this.raise(n.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,"ExportNamedDeclaration")};me.parseExportDeclaration=function(e){return this.parseStatement(null)};me.parseExportDefaultDeclaration=function(){var e;if(this.type===O._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,_s|Uv,!1,e)}else if(this.type===O._class){var r=this.startNode();return this.parseClass(r,"nullableID")}else{var i=this.parseMaybeAssign();return this.semicolon(),i}};me.checkExport=function(e,t,r){e&&(typeof t!="string"&&(t=t.type==="Identifier"?t.name:t.value),so(e,t)&&this.raiseRecoverable(r,"Duplicate export '"+t+"'"),e[t]=!0)};me.checkPatternExport=function(e,t){var r=t.type;if(r==="Identifier")this.checkExport(e,t,t.start);else if(r==="ObjectPattern")for(var i=0,n=t.properties;i<n.length;i+=1){var a=n[i];this.checkPatternExport(e,a)}else if(r==="ArrayPattern")for(var s=0,l=t.elements;s<l.length;s+=1){var c=l[s];c&&this.checkPatternExport(e,c)}else r==="Property"?this.checkPatternExport(e,t.value):r==="AssignmentPattern"?this.checkPatternExport(e,t.left):r==="RestElement"&&this.checkPatternExport(e,t.argument)};me.checkVariableExport=function(e,t){if(e)for(var r=0,i=t;r<i.length;r+=1){var n=i[r];this.checkPatternExport(e,n.id)}};me.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};me.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual("as")?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,"ExportSpecifier")};me.parseExportSpecifiers=function(e){var t=[],r=!0;for(this.expect(O.braceL);!this.eat(O.braceR);){if(r)r=!1;else if(this.expect(O.comma),this.afterTrailingComma(O.braceR))break;t.push(this.parseExportSpecifier(e))}return t};me.parseImport=function(e){return this.next(),this.type===O.string?(e.specifiers=d1,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===O.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")};me.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual("as")?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,Xi),this.finishNode(e,"ImportSpecifier")};me.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,Xi),this.finishNode(e,"ImportDefaultSpecifier")};me.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,Xi),this.finishNode(e,"ImportNamespaceSpecifier")};me.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===O.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(O.comma)))return e;if(this.type===O.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(O.braceL);!this.eat(O.braceR);){if(t)t=!1;else if(this.expect(O.comma),this.afterTrailingComma(O.braceR))break;e.push(this.parseImportSpecifier())}return e};me.parseWithClause=function(){var e=[];if(!this.eat(O._with))return e;this.expect(O.braceL);for(var t={},r=!0;!this.eat(O.braceR);){if(r)r=!1;else if(this.expect(O.comma),this.afterTrailingComma(O.braceR))break;var i=this.parseImportAttribute(),n=i.key.type==="Identifier"?i.key.name:i.key.value;so(t,n)&&this.raiseRecoverable(i.key.start,"Duplicate attribute key '"+n+"'"),t[n]=!0,e.push(i)}return e};me.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===O.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(O.colon),this.type!==O.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")};me.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===O.string){var e=this.parseLiteral(this.value);return c1.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)};me.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)};me.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type==="ExpressionStatement"&&e.expression.type==="Literal"&&typeof e.expression.value=="string"&&(this.input[e.start]==='"'||this.input[e.start]==="'")};var Kr=Mt.prototype;Kr.toAssignable=function(e,t,r){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&e.name==="await"&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",r&&this.checkPatternErrors(r,!0);for(var i=0,n=e.properties;i<n.length;i+=1){var a=n[i];this.toAssignable(a,t),a.type==="RestElement"&&(a.argument.type==="ArrayPattern"||a.argument.type==="ObjectPattern")&&this.raise(a.argument.start,"Unexpected token")}break;case"Property":e.kind!=="init"&&this.raise(e.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(e.value,t);break;case"ArrayExpression":e.type="ArrayPattern",r&&this.checkPatternErrors(r,!0),this.toAssignableList(e.elements,t);break;case"SpreadElement":e.type="RestElement",this.toAssignable(e.argument,t),e.argument.type==="AssignmentPattern"&&this.raise(e.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":e.operator!=="="&&this.raise(e.left.end,"Only '=' operator can be used for specifying default value."),e.type="AssignmentPattern",delete e.operator,this.toAssignable(e.left,t);break;case"ParenthesizedExpression":this.toAssignable(e.expression,t,r);break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!t)break;default:this.raise(e.start,"Assigning to rvalue")}else r&&this.checkPatternErrors(r,!0);return e};Kr.toAssignableList=function(e,t){for(var r=e.length,i=0;i<r;i++){var n=e[i];n&&this.toAssignable(n,t)}if(r){var a=e[r-1];this.options.ecmaVersion===6&&t&&a&&a.type==="RestElement"&&a.argument.type!=="Identifier"&&this.unexpected(a.argument.start)}return e};Kr.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")};Kr.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==O.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")};Kr.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case O.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(O.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case O.braceL:return this.parseObj(!0)}return this.parseIdent()};Kr.parseBindingList=function(e,t,r,i){for(var n=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(O.comma),t&&this.type===O.comma)n.push(null);else{if(r&&this.afterTrailingComma(e))break;if(this.type===O.ellipsis){var s=this.parseRestBinding();this.parseBindingListItem(s),n.push(s),this.type===O.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}else n.push(this.parseAssignableListItem(i))}return n};Kr.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t};Kr.parseBindingListItem=function(e){return e};Kr.parseMaybeDefault=function(e,t,r){if(r=r||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(O.eq))return r;var i=this.startNodeAt(e,t);return i.left=r,i.right=this.parseMaybeAssign(),this.finishNode(i,"AssignmentPattern")};Kr.checkLValSimple=function(e,t,r){t===void 0&&(t=Oc);var i=t!==Oc;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(i?"Binding ":"Assigning to ")+e.name+" in strict mode"),i&&(t===Xi&&e.name==="let"&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),r&&(so(r,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),r[e.name]=!0),t!==Mv&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":i&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return i&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,r);default:this.raise(e.start,(i?"Binding":"Assigning to")+" rvalue")}};Kr.checkLValPattern=function(e,t,r){switch(t===void 0&&(t=Oc),e.type){case"ObjectPattern":for(var i=0,n=e.properties;i<n.length;i+=1){var a=n[i];this.checkLValInnerPattern(a,t,r)}break;case"ArrayPattern":for(var s=0,l=e.elements;s<l.length;s+=1){var c=l[s];c&&this.checkLValInnerPattern(c,t,r)}break;default:this.checkLValSimple(e,t,r)}};Kr.checkLValInnerPattern=function(e,t,r){switch(t===void 0&&(t=Oc),e.type){case"Property":this.checkLValInnerPattern(e.value,t,r);break;case"AssignmentPattern":this.checkLValPattern(e.left,t,r);break;case"RestElement":this.checkLValPattern(e.argument,t,r);break;default:this.checkLValPattern(e,t,r)}};var ci=o(function(t,r,i,n,a){this.token=t,this.isExpr=!!r,this.preserveSpace=!!i,this.override=n,this.generator=!!a},"TokContext"),wt={b_stat:new ci("{",!1),b_expr:new ci("{",!0),b_tmpl:new ci("${",!1),p_stat:new ci("(",!1),p_expr:new ci("(",!0),q_tmpl:new ci("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new ci("function",!1),f_expr:new ci("function",!0),f_expr_gen:new ci("function",!0,!1,null,!0),f_gen:new ci("function",!1,!1,null,!0)},lo=Mt.prototype;lo.initialContext=function(){return[wt.b_stat]};lo.curContext=function(){return this.context[this.context.length-1]};lo.braceIsBlock=function(e){var t=this.curContext();return t===wt.f_expr||t===wt.f_stat?!0:e===O.colon&&(t===wt.b_stat||t===wt.b_expr)?!t.isExpr:e===O._return||e===O.name&&this.exprAllowed?Ar.test(this.input.slice(this.lastTokEnd,this.start)):e===O._else||e===O.semi||e===O.eof||e===O.parenR||e===O.arrow?!0:e===O.braceL?t===wt.b_stat:e===O._var||e===O._const||e===O.name?!1:!this.exprAllowed};lo.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token==="function")return t.generator}return!1};lo.updateContext=function(e){var t,r=this.type;r.keyword&&e===O.dot?this.exprAllowed=!1:(t=r.updateContext)?t.call(this,e):this.exprAllowed=r.beforeExpr};lo.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)};O.parenR.updateContext=O.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===wt.b_stat&&this.curContext().token==="function"&&(e=this.context.pop()),this.exprAllowed=!e.isExpr};O.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?wt.b_stat:wt.b_expr),this.exprAllowed=!0};O.dollarBraceL.updateContext=function(){this.context.push(wt.b_tmpl),this.exprAllowed=!0};O.parenL.updateContext=function(e){var t=e===O._if||e===O._for||e===O._with||e===O._while;this.context.push(t?wt.p_stat:wt.p_expr),this.exprAllowed=!0};O.incDec.updateContext=function(){};O._function.updateContext=O._class.updateContext=function(e){e.beforeExpr&&e!==O._else&&!(e===O.semi&&this.curContext()!==wt.p_stat)&&!(e===O._return&&Ar.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===O.colon||e===O.braceL)&&this.curContext()===wt.b_stat)?this.context.push(wt.f_expr):this.context.push(wt.f_stat),this.exprAllowed=!1};O.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};O.backQuote.updateContext=function(){this.curContext()===wt.q_tmpl?this.context.pop():this.context.push(wt.q_tmpl),this.exprAllowed=!1};O.star.updateContext=function(e){if(e===O._function){var t=this.context.length-1;this.context[t]===wt.f_expr?this.context[t]=wt.f_expr_gen:this.context[t]=wt.f_gen}this.exprAllowed=!0};O.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==O.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var Ae=Mt.prototype;Ae.checkPropClash=function(e,t,r){if(!(this.options.ecmaVersion>=9&&e.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var i=e.key,n;switch(i.type){case"Identifier":n=i.name;break;case"Literal":n=String(i.value);break;default:return}var a=e.kind;if(this.options.ecmaVersion>=6){n==="__proto__"&&a==="init"&&(t.proto&&(r?r.doubleProto<0&&(r.doubleProto=i.start):this.raiseRecoverable(i.start,"Redefinition of __proto__ property")),t.proto=!0);return}n="$"+n;var s=t[n];if(s){var l;a==="init"?l=this.strict&&s.init||s.get||s.set:l=s.init||s[a],l&&this.raiseRecoverable(i.start,"Redefinition of property")}else s=t[n]={init:!1,get:!1,set:!1};s[a]=!0}};Ae.parseExpression=function(e,t){var r=this.start,i=this.startLoc,n=this.parseMaybeAssign(e,t);if(this.type===O.comma){var a=this.startNodeAt(r,i);for(a.expressions=[n];this.eat(O.comma);)a.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(a,"SequenceExpression")}return n};Ae.parseMaybeAssign=function(e,t,r){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var i=!1,n=-1,a=-1,s=-1;t?(n=t.parenthesizedAssign,a=t.trailingComma,s=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new jc,i=!0);var l=this.start,c=this.startLoc;(this.type===O.parenL||this.type===O.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e==="await");var f=this.parseMaybeConditional(e,t);if(r&&(f=r.call(this,f,l,c)),this.type.isAssign){var u=this.startNodeAt(l,c);return u.operator=this.value,this.type===O.eq&&(f=this.toAssignable(f,!1,t)),i||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=f.start&&(t.shorthandAssign=-1),this.type===O.eq?this.checkLValPattern(f):this.checkLValSimple(f),u.left=f,this.next(),u.right=this.parseMaybeAssign(e),s>-1&&(t.doubleProto=s),this.finishNode(u,"AssignmentExpression")}else i&&this.checkExpressionErrors(t,!0);return n>-1&&(t.parenthesizedAssign=n),a>-1&&(t.trailingComma=a),f};Ae.parseMaybeConditional=function(e,t){var r=this.start,i=this.startLoc,n=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return n;if(this.eat(O.question)){var a=this.startNodeAt(r,i);return a.test=n,a.consequent=this.parseMaybeAssign(),this.expect(O.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,"ConditionalExpression")}return n};Ae.parseExprOps=function(e,t){var r=this.start,i=this.startLoc,n=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||n.start===r&&n.type==="ArrowFunctionExpression"?n:this.parseExprOp(n,r,i,-1,e)};Ae.parseExprOp=function(e,t,r,i,n){var a=this.type.binop;if(a!=null&&(!n||this.type!==O._in)&&a>i){var s=this.type===O.logicalOR||this.type===O.logicalAND,l=this.type===O.coalesce;l&&(a=O.logicalAND.binop);var c=this.value;this.next();var f=this.start,u=this.startLoc,h=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,n),f,u,a,n),g=this.buildBinary(t,r,e,h,c,s||l);return(s&&this.type===O.coalesce||l&&(this.type===O.logicalOR||this.type===O.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(g,t,r,i,n)}return e};Ae.buildBinary=function(e,t,r,i,n,a){i.type==="PrivateIdentifier"&&this.raise(i.start,"Private identifier can only be left side of binary expression");var s=this.startNodeAt(e,t);return s.left=r,s.operator=n,s.right=i,this.finishNode(s,a?"LogicalExpression":"BinaryExpression")};Ae.parseMaybeUnary=function(e,t,r,i){var n=this.start,a=this.startLoc,s;if(this.isContextual("await")&&this.canAwait)s=this.parseAwait(i),t=!0;else if(this.type.prefix){var l=this.startNode(),c=this.type===O.incDec;l.operator=this.value,l.prefix=!0,this.next(),l.argument=this.parseMaybeUnary(null,!0,c,i),this.checkExpressionErrors(e,!0),c?this.checkLValSimple(l.argument):this.strict&&l.operator==="delete"&&zv(l.argument)?this.raiseRecoverable(l.start,"Deleting local variable in strict mode"):l.operator==="delete"&&jp(l.argument)?this.raiseRecoverable(l.start,"Private fields can not be deleted"):t=!0,s=this.finishNode(l,c?"UpdateExpression":"UnaryExpression")}else if(!t&&this.type===O.privateId)(i||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),s=this.parsePrivateIdent(),this.type!==O._in&&this.unexpected();else{if(s=this.parseExprSubscripts(e,i),this.checkExpressionErrors(e))return s;for(;this.type.postfix&&!this.canInsertSemicolon();){var f=this.startNodeAt(n,a);f.operator=this.value,f.prefix=!1,f.argument=s,this.checkLValSimple(s),this.next(),s=this.finishNode(f,"UpdateExpression")}}if(!r&&this.eat(O.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(n,a,s,this.parseMaybeUnary(null,!1,!1,i),"**",!1);else return s};function zv(e){return e.type==="Identifier"||e.type==="ParenthesizedExpression"&&zv(e.expression)}o(zv,"isLocalVariableAccess");function jp(e){return e.type==="MemberExpression"&&e.property.type==="PrivateIdentifier"||e.type==="ChainExpression"&&jp(e.expression)||e.type==="ParenthesizedExpression"&&jp(e.expression)}o(jp,"isPrivateFieldAccess");Ae.parseExprSubscripts=function(e,t){var r=this.start,i=this.startLoc,n=this.parseExprAtom(e,t);if(n.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return n;var a=this.parseSubscripts(n,r,i,!1,t);return e&&a.type==="MemberExpression"&&(e.parenthesizedAssign>=a.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=a.start&&(e.parenthesizedBind=-1),e.trailingComma>=a.start&&(e.trailingComma=-1)),a};Ae.parseSubscripts=function(e,t,r,i,n){for(var a=this.options.ecmaVersion>=8&&e.type==="Identifier"&&e.name==="async"&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,s=!1;;){var l=this.parseSubscript(e,t,r,i,a,s,n);if(l.optional&&(s=!0),l===e||l.type==="ArrowFunctionExpression"){if(s){var c=this.startNodeAt(t,r);c.expression=l,l=this.finishNode(c,"ChainExpression")}return l}e=l}};Ae.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(O.arrow)};Ae.parseSubscriptAsyncArrow=function(e,t,r,i){return this.parseArrowExpression(this.startNodeAt(e,t),r,!0,i)};Ae.parseSubscript=function(e,t,r,i,n,a,s){var l=this.options.ecmaVersion>=11,c=l&&this.eat(O.questionDot);i&&c&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var f=this.eat(O.bracketL);if(f||c&&this.type!==O.parenL&&this.type!==O.backQuote||this.eat(O.dot)){var u=this.startNodeAt(t,r);u.object=e,f?(u.property=this.parseExpression(),this.expect(O.bracketR)):this.type===O.privateId&&e.type!=="Super"?u.property=this.parsePrivateIdent():u.property=this.parseIdent(this.options.allowReserved!=="never"),u.computed=!!f,l&&(u.optional=c),e=this.finishNode(u,"MemberExpression")}else if(!i&&this.eat(O.parenL)){var h=new jc,g=this.yieldPos,d=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var b=this.parseExprList(O.parenR,this.options.ecmaVersion>=8,!1,h);if(n&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(h,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=g,this.awaitPos=d,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(t,r,b,s);this.checkExpressionErrors(h,!0),this.yieldPos=g||this.yieldPos,this.awaitPos=d||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var y=this.startNodeAt(t,r);y.callee=e,y.arguments=b,l&&(y.optional=c),e=this.finishNode(y,"CallExpression")}else if(this.type===O.backQuote){(c||a)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var w=this.startNodeAt(t,r);w.tag=e,w.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(w,"TaggedTemplateExpression")}return e};Ae.parseExprAtom=function(e,t,r){this.type===O.slash&&this.readRegexp();var i,n=this.potentialArrowAt===this.start;switch(this.type){case O._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),i=this.startNode(),this.next(),this.type===O.parenL&&!this.allowDirectSuper&&this.raise(i.start,"super() call outside constructor of a subclass"),this.type!==O.dot&&this.type!==O.bracketL&&this.type!==O.parenL&&this.unexpected(),this.finishNode(i,"Super");case O._this:return i=this.startNode(),this.next(),this.finishNode(i,"ThisExpression");case O.name:var a=this.start,s=this.startLoc,l=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!l&&c.name==="async"&&!this.canInsertSemicolon()&&this.eat(O._function))return this.overrideContext(wt.f_expr),this.parseFunction(this.startNodeAt(a,s),0,!1,!0,t);if(n&&!this.canInsertSemicolon()){if(this.eat(O.arrow))return this.parseArrowExpression(this.startNodeAt(a,s),[c],!1,t);if(this.options.ecmaVersion>=8&&c.name==="async"&&this.type===O.name&&!l&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(O.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,s),[c],!0,t)}return c;case O.regexp:var f=this.value;return i=this.parseLiteral(f.value),i.regex={pattern:f.pattern,flags:f.flags},i;case O.num:case O.string:return this.parseLiteral(this.value);case O._null:case O._true:case O._false:return i=this.startNode(),i.value=this.type===O._null?null:this.type===O._true,i.raw=this.type.keyword,this.next(),this.finishNode(i,"Literal");case O.parenL:var u=this.start,h=this.parseParenAndDistinguishExpression(n,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(h)&&(e.parenthesizedAssign=u),e.parenthesizedBind<0&&(e.parenthesizedBind=u)),h;case O.bracketL:return i=this.startNode(),this.next(),i.elements=this.parseExprList(O.bracketR,!0,!0,e),this.finishNode(i,"ArrayExpression");case O.braceL:return this.overrideContext(wt.b_expr),this.parseObj(!1,e);case O._function:return i=this.startNode(),this.next(),this.parseFunction(i,0);case O._class:return this.parseClass(this.startNode(),!1);case O._new:return this.parseNew();case O.backQuote:return this.parseTemplate();case O._import:return this.options.ecmaVersion>=11?this.parseExprImport(r):this.unexpected();default:return this.parseExprAtomDefault()}};Ae.parseExprAtomDefault=function(){this.unexpected()};Ae.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===O.parenL&&!e)return this.parseDynamicImport(t);if(this.type===O.dot){var r=this.startNodeAt(t.start,t.loc&&t.loc.start);return r.name="import",t.meta=this.finishNode(r,"Identifier"),this.parseImportMeta(t)}else this.unexpected()};Ae.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(O.parenR)?e.options=null:(this.expect(O.comma),this.afterTrailingComma(O.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(O.parenR)||(this.expect(O.comma),this.afterTrailingComma(O.parenR)||this.unexpected())));else if(!this.eat(O.parenR)){var t=this.start;this.eat(O.comma)&&this.eat(O.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")};Ae.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="meta"&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),t&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")};Ae.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value!=null?t.value.toString():t.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(t,"Literal")};Ae.parseParenExpression=function(){this.expect(O.parenL);var e=this.parseExpression();return this.expect(O.parenR),e};Ae.shouldParseArrow=function(e){return!this.canInsertSemicolon()};Ae.parseParenAndDistinguishExpression=function(e,t){var r=this.start,i=this.startLoc,n,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var s=this.start,l=this.startLoc,c=[],f=!0,u=!1,h=new jc,g=this.yieldPos,d=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==O.parenR;)if(f?f=!1:this.expect(O.comma),a&&this.afterTrailingComma(O.parenR,!0)){u=!0;break}else if(this.type===O.ellipsis){m=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===O.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else c.push(this.parseMaybeAssign(!1,h,this.parseParenItem));var b=this.lastTokEnd,y=this.lastTokEndLoc;if(this.expect(O.parenR),e&&this.shouldParseArrow(c)&&this.eat(O.arrow))return this.checkPatternErrors(h,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=g,this.awaitPos=d,this.parseParenArrowList(r,i,c,t);(!c.length||u)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(h,!0),this.yieldPos=g||this.yieldPos,this.awaitPos=d||this.awaitPos,c.length>1?(n=this.startNodeAt(s,l),n.expressions=c,this.finishNodeAt(n,"SequenceExpression",b,y)):n=c[0]}else n=this.parseParenExpression();if(this.options.preserveParens){var w=this.startNodeAt(r,i);return w.expression=n,this.finishNode(w,"ParenthesizedExpression")}else return n};Ae.parseParenItem=function(e){return e};Ae.parseParenArrowList=function(e,t,r,i){return this.parseArrowExpression(this.startNodeAt(e,t),r,!1,i)};var g1=[];Ae.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===O.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var r=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="target"&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),r&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var i=this.start,n=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),i,n,!0,!1),this.eat(O.parenL)?e.arguments=this.parseExprList(O.parenR,this.options.ecmaVersion>=8,!1):e.arguments=g1,this.finishNode(e,"NewExpression")};Ae.parseTemplateElement=function(e){var t=e.isTagged,r=this.startNode();return this.type===O.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),r.value={raw:this.value.replace(/\r\n?/g,`
|
|
30
30
|
`),cooked:null}):r.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
|
|
31
|
-
`),cooked:this.value},this.next(),r.tail=this.type===x.backQuote,this.finishNode(r,"TemplateElement")};Ae.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var r=this.startNode();this.next(),r.expressions=[];var n=this.parseTemplateElement({isTagged:t});for(r.quasis=[n];!n.tail;)this.type===x.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(x.dollarBraceL),r.expressions.push(this.parseExpression()),this.expect(x.braceR),r.quasis.push(n=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(r,"TemplateLiteral")};Ae.isAsyncProp=function(e){return!e.computed&&e.key.type==="Identifier"&&e.key.name==="async"&&(this.type===x.name||this.type===x.num||this.type===x.string||this.type===x.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===x.star)&&!Ar.test(this.input.slice(this.lastTokEnd,this.start))};Ae.parseObj=function(e,t){var r=this.startNode(),n=!0,i={};for(r.properties=[],this.next();!this.eat(x.braceR);){if(n)n=!1;else if(this.expect(x.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(x.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,i,t),r.properties.push(a)}return this.finishNode(r,e?"ObjectPattern":"ObjectExpression")};Ae.parseProperty=function(e,t){var r=this.startNode(),n,i,a,s;if(this.options.ecmaVersion>=9&&this.eat(x.ellipsis))return e?(r.argument=this.parseIdent(!1),this.type===x.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(r,"RestElement")):(r.argument=this.parseMaybeAssign(!1,t),this.type===x.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(r,"SpreadElement"));this.options.ecmaVersion>=6&&(r.method=!1,r.shorthand=!1,(e||t)&&(a=this.start,s=this.startLoc),e||(n=this.eat(x.star)));var l=this.containsEsc;return this.parsePropertyName(r),!e&&!l&&this.options.ecmaVersion>=8&&!n&&this.isAsyncProp(r)?(i=!0,n=this.options.ecmaVersion>=9&&this.eat(x.star),this.parsePropertyName(r)):i=!1,this.parsePropertyValue(r,e,n,i,a,s,t,l),this.finishNode(r,"Property")};Ae.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var r=e.kind==="get"?0:1;if(e.value.params.length!==r){var n=e.value.start;e.kind==="get"?this.raiseRecoverable(n,"getter should have no params"):this.raiseRecoverable(n,"setter should have exactly one param")}else e.kind==="set"&&e.value.params[0].type==="RestElement"&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")};Ae.parsePropertyValue=function(e,t,r,n,i,a,s,l){(r||n)&&this.type===x.colon&&this.unexpected(),this.eat(x.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,s),e.kind="init"):this.options.ecmaVersion>=6&&this.type===x.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(r,n),e.kind="init"):!t&&!l&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type==="Identifier"&&(e.key.name==="get"||e.key.name==="set")&&this.type!==x.comma&&this.type!==x.braceR&&this.type!==x.eq?((r||n)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type==="Identifier"?((r||n)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=i),t?e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key)):this.type===x.eq&&s?(s.shorthandAssign<0&&(s.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected()};Ae.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(x.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(x.bracketR),e.key;e.computed=!1}return e.key=this.type===x.num||this.type===x.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};Ae.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)};Ae.parseMethod=function(e,t,r){var n=this.startNode(),i=this.yieldPos,a=this.awaitPos,s=this.awaitIdentPos;return this.initFunction(n),this.options.ecmaVersion>=6&&(n.generator=e),this.options.ecmaVersion>=8&&(n.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Qh(t,n.generator)|nu|(r?hv:0)),this.expect(x.parenL),n.params=this.parseBindingList(x.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(n,!1,!0,!1),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=s,this.finishNode(n,"FunctionExpression")};Ae.parseArrowExpression=function(e,t,r,n){var i=this.yieldPos,a=this.awaitPos,s=this.awaitIdentPos;return this.enterScope(Qh(r,!1)|Jh),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!r),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,n),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=s,this.finishNode(e,"ArrowFunctionExpression")};Ae.parseFunctionBody=function(e,t,r,n){var i=t&&this.type!==x.braceL,a=this.strict,s=!1;if(i)e.body=this.parseMaybeAssign(n),e.expression=!0,this.checkParams(e,!1);else{var l=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!a||l)&&(s=this.strictDirective(this.end),s&&l&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var u=this.labels;this.labels=[],s&&(this.strict=!0),this.checkParams(e,!a&&!s&&!t&&!r&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,gv),e.body=this.parseBlock(!1,void 0,s&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=u}this.exitScope()};Ae.isSimpleParamList=function(e){for(var t=0,r=e;t<r.length;t+=1){var n=r[t];if(n.type!=="Identifier")return!1}return!0};Ae.checkParams=function(e,t){for(var r=Object.create(null),n=0,i=e.params;n<i.length;n+=1){var a=i[n];this.checkLValInnerPattern(a,Xh,t?null:r)}};Ae.parseExprList=function(e,t,r,n){for(var i=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(x.comma),t&&this.afterTrailingComma(e))break;var s=void 0;r&&this.type===x.comma?s=null:this.type===x.ellipsis?(s=this.parseSpread(n),n&&this.type===x.comma&&n.trailingComma<0&&(n.trailingComma=this.start)):s=this.parseMaybeAssign(!1,n),i.push(s)}return i};Ae.checkUnreserved=function(e){var t=e.start,r=e.end,n=e.name;if(this.inGenerator&&n==="yield"&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&n==="await"&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&iu)&&n==="arguments"&&this.raiseRecoverable(t,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(n==="arguments"||n==="await")&&this.raise(t,"Cannot use "+n+" in class static initialization block"),this.keywords.test(n)&&this.raise(t,"Unexpected keyword '"+n+"'"),!(this.options.ecmaVersion<6&&this.input.slice(t,r).indexOf("\\")!==-1)){var i=this.strict?this.reservedWordsStrict:this.reservedWords;i.test(n)&&(!this.inAsync&&n==="await"&&this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+n+"' is reserved"))}};Ae.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,"Identifier"),e||(this.checkUnreserved(t),t.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t};Ae.parseIdentNode=function(){var e=this.startNode();return this.type===x.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name==="class"||e.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=x.name):this.unexpected(),e};Ae.parsePrivateIdent=function(){var e=this.startNode();return this.type===x.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,"Private field '#"+e.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e};Ae.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===x.semi||this.canInsertSemicolon()||this.type!==x.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(x.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")};Ae.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,"AwaitExpression")};var eu=Nt.prototype;eu.raise=function(e,t){var r=uv(this.input,e);t+=" ("+r.line+":"+r.column+")",this.sourceFile&&(t+=" in "+this.sourceFile);var n=new SyntaxError(t);throw n.pos=e,n.loc=r,n.raisedAt=this.pos,n};eu.raiseRecoverable=eu.raise;eu.curPosition=function(){if(this.options.locations)return new ss(this.curLine,this.pos-this.lineStart)};var hi=Nt.prototype,Vx=o(function(t){this.flags=t,this.var=[],this.lexical=[],this.functions=[]},"Scope");hi.enterScope=function(e){this.scopeStack.push(new Vx(e))};hi.exitScope=function(){this.scopeStack.pop()};hi.treatFunctionsAsVarInScope=function(e){return e.flags&Zi||!this.inModule&&e.flags&Xi};hi.declareName=function(e,t,r){var n=!1;if(t===Hn){var i=this.currentScope();n=i.lexical.indexOf(e)>-1||i.functions.indexOf(e)>-1||i.var.indexOf(e)>-1,i.lexical.push(e),this.inModule&&i.flags&Xi&&delete this.undefinedExports[e]}else if(t===mv){var a=this.currentScope();a.lexical.push(e)}else if(t===pv){var s=this.currentScope();this.treatFunctionsAsVar?n=s.lexical.indexOf(e)>-1:n=s.lexical.indexOf(e)>-1||s.var.indexOf(e)>-1,s.functions.push(e)}else for(var l=this.scopeStack.length-1;l>=0;--l){var u=this.scopeStack[l];if(u.lexical.indexOf(e)>-1&&!(u.flags&fv&&u.lexical[0]===e)||!this.treatFunctionsAsVarInScope(u)&&u.functions.indexOf(e)>-1){n=!0;break}if(u.var.push(e),this.inModule&&u.flags&Xi&&delete this.undefinedExports[e],u.flags&iu)break}n&&this.raiseRecoverable(r,"Identifier '"+e+"' has already been declared")};hi.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)};hi.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};hi.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(iu|ls|$i))return t}};hi.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(iu|ls|$i)&&!(t.flags&Jh))return t}};var ou=o(function(t,r,n){this.type="",this.start=r,this.end=0,t.options.locations&&(this.loc=new ru(t,n)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[r,0])},"Node"),us=Nt.prototype;us.startNode=function(){return new ou(this,this.start,this.startLoc)};us.startNodeAt=function(e,t){return new ou(this,e,t)};function bv(e,t,r,n){return e.type=t,e.end=r,this.options.locations&&(e.loc.end=n),this.options.ranges&&(e.range[1]=r),e}o(bv,"finishNodeAt");us.finishNode=function(e,t){return bv.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)};us.finishNodeAt=function(e,t,r,n){return bv.call(this,e,t,r,n)};us.copyNode=function(e){var t=new ou(this,e.start,this.startLoc);for(var r in e)t[r]=e[r];return t};var qx="Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz",wv="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",_v=wv+" Extended_Pictographic",xv=_v,Ov=xv+" EBase EComp EMod EPres ExtPict",Ev=Ov,Bx=Ev,Wx={9:wv,10:_v,11:xv,12:Ov,13:Ev,14:Bx},Gx="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",Hx={9:"",10:"",11:"",12:"",13:"",14:Gx},tv="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",Sv="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",kv=Sv+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",Av=kv+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Tv=Av+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Cv=Tv+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Kx=Cv+" "+qx,Yx={9:Sv,10:kv,11:Av,12:Tv,13:Cv,14:Kx},Rv={};function Jx(e){var t=Rv[e]={binary:ci(Wx[e]+" "+tv),binaryOfStrings:ci(Hx[e]),nonBinary:{General_Category:ci(tv),Script:ci(Yx[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}o(Jx,"buildUnicodeData");for(Xl=0,qh=[9,10,11,12,13,14];Xl<qh.length;Xl+=1)rv=qh[Xl],Jx(rv);var rv,Xl,qh,pe=Nt.prototype,tu=o(function(t,r){this.parent=t,this.base=r||this},"BranchID");tu.prototype.separatedFrom=o(function(t){for(var r=this;r;r=r.parent)for(var n=t;n;n=n.parent)if(r.base===n.base&&r!==n)return!0;return!1},"separatedFrom");tu.prototype.sibling=o(function(){return new tu(this.parent,this.base)},"sibling");var Sn=o(function(t){this.parser=t,this.validFlags="gim"+(t.options.ecmaVersion>=6?"uy":"")+(t.options.ecmaVersion>=9?"s":"")+(t.options.ecmaVersion>=13?"d":"")+(t.options.ecmaVersion>=15?"v":""),this.unicodeProperties=Rv[t.options.ecmaVersion>=14?14:t.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null},"RegExpValidationState");Sn.prototype.reset=o(function(t,r,n){var i=n.indexOf("v")!==-1,a=n.indexOf("u")!==-1;this.start=t|0,this.source=r+"",this.flags=n,i&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=a&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=a&&this.parser.options.ecmaVersion>=9)},"reset");Sn.prototype.raise=o(function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)},"raise");Sn.prototype.at=o(function(t,r){r===void 0&&(r=!1);var n=this.source,i=n.length;if(t>=i)return-1;var a=n.charCodeAt(t);if(!(r||this.switchU)||a<=55295||a>=57344||t+1>=i)return a;var s=n.charCodeAt(t+1);return s>=56320&&s<=57343?(a<<10)+s-56613888:a},"at");Sn.prototype.nextIndex=o(function(t,r){r===void 0&&(r=!1);var n=this.source,i=n.length;if(t>=i)return i;var a=n.charCodeAt(t),s;return!(r||this.switchU)||a<=55295||a>=57344||t+1>=i||(s=n.charCodeAt(t+1))<56320||s>57343?t+1:t+2},"nextIndex");Sn.prototype.current=o(function(t){return t===void 0&&(t=!1),this.at(this.pos,t)},"current");Sn.prototype.lookahead=o(function(t){return t===void 0&&(t=!1),this.at(this.nextIndex(this.pos,t),t)},"lookahead");Sn.prototype.advance=o(function(t){t===void 0&&(t=!1),this.pos=this.nextIndex(this.pos,t)},"advance");Sn.prototype.eat=o(function(t,r){return r===void 0&&(r=!1),this.current(r)===t?(this.advance(r),!0):!1},"eat");Sn.prototype.eatChars=o(function(t,r){r===void 0&&(r=!1);for(var n=this.pos,i=0,a=t;i<a.length;i+=1){var s=a[i],l=this.at(n,r);if(l===-1||l!==s)return!1;n=this.nextIndex(n,r)}return this.pos=n,!0},"eatChars");pe.validateRegExpFlags=function(e){for(var t=e.validFlags,r=e.flags,n=!1,i=!1,a=0;a<r.length;a++){var s=r.charAt(a);t.indexOf(s)===-1&&this.raise(e.start,"Invalid regular expression flag"),r.indexOf(s,a+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),s==="u"&&(n=!0),s==="v"&&(i=!0)}this.options.ecmaVersion>=15&&n&&i&&this.raise(e.start,"Invalid regular expression flag")};function Qx(e){for(var t in e)return!0;return!1}o(Qx,"hasProp");pe.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&Qx(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))};pe.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var t=0,r=e.backReferenceNames;t<r.length;t+=1){var n=r[t];e.groupNames[n]||e.raise("Invalid named capture referenced")}};pe.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new tu(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise("Nothing to repeat"),e.eat(123)&&e.raise("Lone quantifier brackets")};pe.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););};pe.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise("Invalid quantifier"),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1};pe.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var r=!1;if(this.options.ecmaVersion>=9&&(r=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!r,!0}return e.pos=t,!1};pe.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1};pe.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)};pe.regexp_eatBracedQuantifier=function(e,t){var r=e.pos;if(e.eat(123)){var n=0,i=-1;if(this.regexp_eatDecimalDigits(e)&&(n=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return i!==-1&&i<n&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=r}return!1};pe.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)};pe.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1};pe.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var r=this.regexp_eatModifiers(e),n=e.eat(45);if(r||n){for(var i=0;i<r.length;i++){var a=r.charAt(i);r.indexOf(a,i+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(n){var s=this.regexp_eatModifiers(e);!r&&!s&&e.current()===58&&e.raise("Invalid regular expression modifiers");for(var l=0;l<s.length;l++){var u=s.charAt(l);(s.indexOf(u,l+1)>-1||r.indexOf(u)>-1)&&e.raise("Duplicate regular expression modifiers")}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise("Unterminated group")}}e.pos=t}return!1};pe.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1};pe.regexp_eatModifiers=function(e){for(var t="",r=0;(r=e.current())!==-1&&Xx(r);)t+=Wn(r),e.advance();return t};function Xx(e){return e===105||e===109||e===115}o(Xx,"isRegularExpressionModifier");pe.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)};pe.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1};pe.regexp_eatSyntaxCharacter=function(e){var t=e.current();return Dv(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Dv(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}o(Dv,"isSyntaxCharacter");pe.regexp_eatPatternCharacters=function(e){for(var t=e.pos,r=0;(r=e.current())!==-1&&!Dv(r);)e.advance();return e.pos!==t};pe.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124?(e.advance(),!0):!1};pe.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var t=this.options.ecmaVersion>=16,r=e.groupNames[e.lastStringValue];if(r)if(t)for(var n=0,i=r;n<i.length;n+=1){var a=i[n];a.separatedFrom(e.branchID)||e.raise("Duplicate capture group name")}else e.raise("Duplicate capture group name");t?(r||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}};pe.regexp_eatGroupName=function(e){if(e.lastStringValue="",e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise("Invalid capture group name")}return!1};pe.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=Wn(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=Wn(e.lastIntValue);return!0}return!1};pe.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,r=this.options.ecmaVersion>=11,n=e.current(r);return e.advance(r),n===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,r)&&(n=e.lastIntValue),Zx(n)?(e.lastIntValue=n,!0):(e.pos=t,!1)};function Zx(e){return En(e,!0)||e===36||e===95}o(Zx,"isRegExpIdentifierStart");pe.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,r=this.options.ecmaVersion>=11,n=e.current(r);return e.advance(r),n===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,r)&&(n=e.lastIntValue),$x(n)?(e.lastIntValue=n,!0):(e.pos=t,!1)};function $x(e){return fi(e,!0)||e===36||e===95||e===8204||e===8205}o($x,"isRegExpIdentifierPart");pe.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)};pe.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var r=e.lastIntValue;if(e.switchU)return r>e.maxBackReference&&(e.maxBackReference=r),!0;if(r<=e.numCapturingParens)return!0;e.pos=t}return!1};pe.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1};pe.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)};pe.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1};pe.regexp_eatZero=function(e){return e.current()===48&&!su(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1};pe.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114?(e.lastIntValue=13,e.advance(),!0):!1};pe.regexp_eatControlLetter=function(e){var t=e.current();return jv(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function jv(e){return e>=65&&e<=90||e>=97&&e<=122}o(jv,"isControlLetter");pe.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var r=e.pos,n=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(n&&i>=55296&&i<=56319){var a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var s=e.lastIntValue;if(s>=56320&&s<=57343)return e.lastIntValue=(i-55296)*1024+(s-56320)+65536,!0}e.pos=a,e.lastIntValue=i}return!0}if(n&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&e1(e.lastIntValue))return!0;n&&e.raise("Invalid unicode escape"),e.pos=r}return!1};function e1(e){return e>=0&&e<=1114111}o(e1,"isValidUnicode");pe.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)?(e.lastIntValue=t,e.advance(),!0):!1};pe.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var Lv=0,Gn=1,Br=2;pe.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(t1(t))return e.lastIntValue=-1,e.advance(),Gn;var r=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((r=t===80)||t===112)){e.lastIntValue=-1,e.advance();var n;if(e.eat(123)&&(n=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return r&&n===Br&&e.raise("Invalid property name"),n;e.raise("Invalid property name")}return Lv};function t1(e){return e===100||e===68||e===115||e===83||e===119||e===87}o(t1,"isCharacterClassEscape");pe.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var r=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var n=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,r,n),Gn}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return Lv};pe.regexp_validateUnicodePropertyNameAndValue=function(e,t,r){$a(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(r)||e.raise("Invalid property value")};pe.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return Gn;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return Br;e.raise("Invalid property name")};pe.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";Iv(t=e.current());)e.lastStringValue+=Wn(t),e.advance();return e.lastStringValue!==""};function Iv(e){return jv(e)||e===95}o(Iv,"isUnicodePropertyNameCharacter");pe.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";r1(t=e.current());)e.lastStringValue+=Wn(t),e.advance();return e.lastStringValue!==""};function r1(e){return Iv(e)||su(e)}o(r1,"isUnicodePropertyValueCharacter");pe.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)};pe.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),r=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&r===Br&&e.raise("Negated character class may contain strings"),!0}return!1};pe.regexp_classContents=function(e){return e.current()===93?Gn:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),Gn)};pe.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var r=e.lastIntValue;e.switchU&&(t===-1||r===-1)&&e.raise("Invalid character class"),t!==-1&&r!==-1&&t>r&&e.raise("Range out of order in character class")}}};pe.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var r=e.current();(r===99||Nv(r))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var n=e.current();return n!==93?(e.lastIntValue=n,e.advance(),!0):!1};pe.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)};pe.regexp_classSetExpression=function(e){var t=Gn,r;if(!this.regexp_eatClassSetRange(e))if(r=this.regexp_eatClassSetOperand(e)){r===Br&&(t=Br);for(var n=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(r=this.regexp_eatClassSetOperand(e))){r!==Br&&(t=Gn);continue}e.raise("Invalid character in character class")}if(n!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(n!==e.pos)return t}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(r=this.regexp_eatClassSetOperand(e),!r)return t;r===Br&&(t=Br)}};pe.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;return r!==-1&&n!==-1&&r>n&&e.raise("Range out of order in character class"),!0}e.pos=t}return!1};pe.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?Gn:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)};pe.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var r=e.eat(94),n=this.regexp_classContents(e);if(e.eat(93))return r&&n===Br&&e.raise("Negated character class may contain strings"),n;e.pos=t}if(e.eat(92)){var i=this.regexp_eatCharacterClassEscape(e);if(i)return i;e.pos=t}return null};pe.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var r=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return r}else e.raise("Invalid escape");e.pos=t}return null};pe.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===Br&&(t=Br);return t};pe.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?Gn:Br};pe.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var r=e.current();return r<0||r===e.lookahead()&&n1(r)||i1(r)?!1:(e.advance(),e.lastIntValue=r,!0)};function n1(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}o(n1,"isClassSetReservedDoublePunctuatorCharacter");function i1(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}o(i1,"isClassSetSyntaxCharacter");pe.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return a1(t)?(e.lastIntValue=t,e.advance(),!0):!1};function a1(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}o(a1,"isClassSetReservedPunctuator");pe.regexp_eatClassControlLetter=function(e){var t=e.current();return su(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1};pe.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=t}return!1};pe.regexp_eatDecimalDigits=function(e){var t=e.pos,r=0;for(e.lastIntValue=0;su(r=e.current());)e.lastIntValue=10*e.lastIntValue+(r-48),e.advance();return e.pos!==t};function su(e){return e>=48&&e<=57}o(su,"isDecimalDigit");pe.regexp_eatHexDigits=function(e){var t=e.pos,r=0;for(e.lastIntValue=0;Pv(r=e.current());)e.lastIntValue=16*e.lastIntValue+Fv(r),e.advance();return e.pos!==t};function Pv(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}o(Pv,"isHexDigit");function Fv(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}o(Fv,"hexToInt");pe.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var r=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=t*64+r*8+e.lastIntValue:e.lastIntValue=t*8+r}else e.lastIntValue=t;return!0}return!1};pe.regexp_eatOctalDigit=function(e){var t=e.current();return Nv(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Nv(e){return e>=48&&e<=55}o(Nv,"isOctalDigit");pe.regexp_eatFixedHexDigits=function(e,t){var r=e.pos;e.lastIntValue=0;for(var n=0;n<t;++n){var i=e.current();if(!Pv(i))return e.pos=r,!1;e.lastIntValue=16*e.lastIntValue+Fv(i),e.advance()}return!0};var $h=o(function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new ru(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},"Token"),qe=Nt.prototype;qe.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new $h(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};qe.getToken=function(){return this.next(),new $h(this)};typeof Symbol<"u"&&(qe[Symbol.iterator]=function(){var e=this;return{next:o(function(){var t=e.getToken();return{done:t.type===x.eof,value:t}},"next")}});qe.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(x.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())};qe.readToken=function(e){return En(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)};qe.fullCharCodeAt=function(e){var t=this.input.charCodeAt(e);if(t<=55295||t>=56320)return t;var r=this.input.charCodeAt(e+1);return r<=56319||r>=57344?t:(t<<10)+r-56613888};qe.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)};qe.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,r=this.input.indexOf("*/",this.pos+=2);if(r===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=r+2,this.options.locations)for(var n=void 0,i=t;(n=ov(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=n;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,r),t,this.pos,e,this.curPosition())};qe.skipLineComment=function(e){for(var t=this.pos,r=this.options.onComment&&this.curPosition(),n=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!Za(n);)n=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,r,this.curPosition())};qe.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(e>8&&e<14||e>=5760&&sv.test(String.fromCharCode(e)))++this.pos;else break e}}};qe.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var r=this.type;this.type=e,this.value=t,this.updateContext(r)};qe.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(x.ellipsis)):(++this.pos,this.finishToken(x.dot))};qe.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(x.assign,2):this.finishOp(x.slash,1)};qe.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),r=1,n=e===42?x.star:x.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++r,n=x.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(x.assign,r+1):this.finishOp(n,r)};qe.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);if(t===e){if(this.options.ecmaVersion>=12){var r=this.input.charCodeAt(this.pos+2);if(r===61)return this.finishOp(x.assign,3)}return this.finishOp(e===124?x.logicalOR:x.logicalAND,2)}return t===61?this.finishOp(x.assign,2):this.finishOp(e===124?x.bitwiseOR:x.bitwiseAND,1)};qe.readToken_caret=function(){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(x.assign,2):this.finishOp(x.bitwiseXOR,1)};qe.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||Ar.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(x.incDec,2):t===61?this.finishOp(x.assign,2):this.finishOp(x.plusMin,1)};qe.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),r=1;return t===e?(r=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+r)===61?this.finishOp(x.assign,r+1):this.finishOp(x.bitShift,r)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(r=2),this.finishOp(x.relational,r))};qe.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(x.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(x.arrow)):this.finishOp(e===61?x.eq:x.prefix,1)};qe.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var r=this.input.charCodeAt(this.pos+2);if(r<48||r>57)return this.finishOp(x.questionDot,2)}if(t===63){if(e>=12){var n=this.input.charCodeAt(this.pos+2);if(n===61)return this.finishOp(x.assign,3)}return this.finishOp(x.coalesce,2)}}return this.finishOp(x.question,1)};qe.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),En(t,!0)||t===92))return this.finishToken(x.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+Wn(t)+"'")};qe.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(x.parenL);case 41:return++this.pos,this.finishToken(x.parenR);case 59:return++this.pos,this.finishToken(x.semi);case 44:return++this.pos,this.finishToken(x.comma);case 91:return++this.pos,this.finishToken(x.bracketL);case 93:return++this.pos,this.finishToken(x.bracketR);case 123:return++this.pos,this.finishToken(x.braceL);case 125:return++this.pos,this.finishToken(x.braceR);case 58:return++this.pos,this.finishToken(x.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(x.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(x.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+Wn(e)+"'")};qe.finishOp=function(e,t){var r=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,r)};qe.readRegexp=function(){for(var e,t,r=this.pos;;){this.pos>=this.input.length&&this.raise(r,"Unterminated regular expression");var n=this.input.charAt(this.pos);if(Ar.test(n)&&this.raise(r,"Unterminated regular expression"),e)e=!1;else{if(n==="[")t=!0;else if(n==="]"&&t)t=!1;else if(n==="/"&&!t)break;e=n==="\\"}++this.pos}var i=this.input.slice(r,this.pos);++this.pos;var a=this.pos,s=this.readWord1();this.containsEsc&&this.unexpected(a);var l=this.regexpState||(this.regexpState=new Sn(this));l.reset(r,i,s),this.validateRegExpFlags(l),this.validateRegExpPattern(l);var u=null;try{u=new RegExp(i,s)}catch{}return this.finishToken(x.regexp,{pattern:i,flags:s,value:u})};qe.readInt=function(e,t,r){for(var n=this.options.ecmaVersion>=12&&t===void 0,i=r&&this.input.charCodeAt(this.pos)===48,a=this.pos,s=0,l=0,u=0,f=t??1/0;u<f;++u,++this.pos){var c=this.input.charCodeAt(this.pos),h=void 0;if(n&&c===95){i&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),l===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),u===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),l=c;continue}if(c>=97?h=c-97+10:c>=65?h=c-65+10:c>=48&&c<=57?h=c-48:h=1/0,h>=e)break;l=c,s=s*e+h}return n&&l===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===a||t!=null&&this.pos-a!==t?null:s};function o1(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}o(o1,"stringToNumber");function Mv(e){return typeof BigInt!="function"?null:BigInt(e.replace(/_/g,""))}o(Mv,"stringToBigInt");qe.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var r=this.readInt(e);return r==null&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(r=Mv(this.input.slice(t,this.pos)),++this.pos):En(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(x.num,r)};qe.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,"Invalid number");var r=this.pos-t>=2&&this.input.charCodeAt(t)===48;r&&this.strict&&this.raise(t,"Invalid number");var n=this.input.charCodeAt(this.pos);if(!r&&!e&&this.options.ecmaVersion>=11&&n===110){var i=Mv(this.input.slice(t,this.pos));return++this.pos,En(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(x.num,i)}r&&/[89]/.test(this.input.slice(t,this.pos))&&(r=!1),n===46&&!r&&(++this.pos,this.readInt(10),n=this.input.charCodeAt(this.pos)),(n===69||n===101)&&!r&&(n=this.input.charCodeAt(++this.pos),(n===43||n===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,"Invalid number")),En(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var a=o1(this.input.slice(t,this.pos),r);return this.finishToken(x.num,a)};qe.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var r=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(r,"Code point out of bounds")}else t=this.readHexChar(4);return t};qe.readString=function(e){for(var t="",r=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var n=this.input.charCodeAt(this.pos);if(n===e)break;n===92?(t+=this.input.slice(r,this.pos),t+=this.readEscapedChar(!1),r=this.pos):n===8232||n===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(Za(n)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(r,this.pos++),this.finishToken(x.string,t)};var Uv={};qe.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===Uv)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1};qe.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Uv;this.raise(e,t)};qe.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var r=this.input.charCodeAt(this.pos);if(r===96||r===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===x.template||this.type===x.invalidTemplate)?r===36?(this.pos+=2,this.finishToken(x.dollarBraceL)):(++this.pos,this.finishToken(x.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(x.template,e));if(r===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(Za(r)){switch(e+=this.input.slice(t,this.pos),++this.pos,r){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`
|
|
32
|
-
`;break;default:e+=String.fromCharCode(r);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}};
|
|
31
|
+
`),cooked:this.value},this.next(),r.tail=this.type===O.backQuote,this.finishNode(r,"TemplateElement")};Ae.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var r=this.startNode();this.next(),r.expressions=[];var i=this.parseTemplateElement({isTagged:t});for(r.quasis=[i];!i.tail;)this.type===O.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(O.dollarBraceL),r.expressions.push(this.parseExpression()),this.expect(O.braceR),r.quasis.push(i=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(r,"TemplateLiteral")};Ae.isAsyncProp=function(e){return!e.computed&&e.key.type==="Identifier"&&e.key.name==="async"&&(this.type===O.name||this.type===O.num||this.type===O.string||this.type===O.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===O.star)&&!Ar.test(this.input.slice(this.lastTokEnd,this.start))};Ae.parseObj=function(e,t){var r=this.startNode(),i=!0,n={};for(r.properties=[],this.next();!this.eat(O.braceR);){if(i)i=!1;else if(this.expect(O.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(O.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,n,t),r.properties.push(a)}return this.finishNode(r,e?"ObjectPattern":"ObjectExpression")};Ae.parseProperty=function(e,t){var r=this.startNode(),i,n,a,s;if(this.options.ecmaVersion>=9&&this.eat(O.ellipsis))return e?(r.argument=this.parseIdent(!1),this.type===O.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(r,"RestElement")):(r.argument=this.parseMaybeAssign(!1,t),this.type===O.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(r,"SpreadElement"));this.options.ecmaVersion>=6&&(r.method=!1,r.shorthand=!1,(e||t)&&(a=this.start,s=this.startLoc),e||(i=this.eat(O.star)));var l=this.containsEsc;return this.parsePropertyName(r),!e&&!l&&this.options.ecmaVersion>=8&&!i&&this.isAsyncProp(r)?(n=!0,i=this.options.ecmaVersion>=9&&this.eat(O.star),this.parsePropertyName(r)):n=!1,this.parsePropertyValue(r,e,i,n,a,s,t,l),this.finishNode(r,"Property")};Ae.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var r=e.kind==="get"?0:1;if(e.value.params.length!==r){var i=e.value.start;e.kind==="get"?this.raiseRecoverable(i,"getter should have no params"):this.raiseRecoverable(i,"setter should have exactly one param")}else e.kind==="set"&&e.value.params[0].type==="RestElement"&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")};Ae.parsePropertyValue=function(e,t,r,i,n,a,s,l){(r||i)&&this.type===O.colon&&this.unexpected(),this.eat(O.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,s),e.kind="init"):this.options.ecmaVersion>=6&&this.type===O.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(r,i),e.kind="init"):!t&&!l&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type==="Identifier"&&(e.key.name==="get"||e.key.name==="set")&&this.type!==O.comma&&this.type!==O.braceR&&this.type!==O.eq?((r||i)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type==="Identifier"?((r||i)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=n),t?e.value=this.parseMaybeDefault(n,a,this.copyNode(e.key)):this.type===O.eq&&s?(s.shorthandAssign<0&&(s.shorthandAssign=this.start),e.value=this.parseMaybeDefault(n,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected()};Ae.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(O.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(O.bracketR),e.key;e.computed=!1}return e.key=this.type===O.num||this.type===O.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};Ae.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)};Ae.parseMethod=function(e,t,r){var i=this.startNode(),n=this.yieldPos,a=this.awaitPos,s=this.awaitIdentPos;return this.initFunction(i),this.options.ecmaVersion>=6&&(i.generator=e),this.options.ecmaVersion>=8&&(i.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Pp(t,i.generator)|Tc|(r?Pv:0)),this.expect(O.parenL),i.params=this.parseBindingList(O.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(i,!1,!0,!1),this.yieldPos=n,this.awaitPos=a,this.awaitIdentPos=s,this.finishNode(i,"FunctionExpression")};Ae.parseArrowExpression=function(e,t,r,i){var n=this.yieldPos,a=this.awaitPos,s=this.awaitIdentPos;return this.enterScope(Pp(r,!1)|Lp),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!r),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,i),this.yieldPos=n,this.awaitPos=a,this.awaitIdentPos=s,this.finishNode(e,"ArrowFunctionExpression")};Ae.parseFunctionBody=function(e,t,r,i){var n=t&&this.type!==O.braceL,a=this.strict,s=!1;if(n)e.body=this.parseMaybeAssign(i),e.expression=!0,this.checkParams(e,!1);else{var l=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!a||l)&&(s=this.strictDirective(this.end),s&&l&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var c=this.labels;this.labels=[],s&&(this.strict=!0),this.checkParams(e,!a&&!s&&!t&&!r&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,Mv),e.body=this.parseBlock(!1,void 0,s&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=c}this.exitScope()};Ae.isSimpleParamList=function(e){for(var t=0,r=e;t<r.length;t+=1){var i=r[t];if(i.type!=="Identifier")return!1}return!0};Ae.checkParams=function(e,t){for(var r=Object.create(null),i=0,n=e.params;i<n.length;i+=1){var a=n[i];this.checkLValInnerPattern(a,Ip,t?null:r)}};Ae.parseExprList=function(e,t,r,i){for(var n=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(O.comma),t&&this.afterTrailingComma(e))break;var s=void 0;r&&this.type===O.comma?s=null:this.type===O.ellipsis?(s=this.parseSpread(i),i&&this.type===O.comma&&i.trailingComma<0&&(i.trailingComma=this.start)):s=this.parseMaybeAssign(!1,i),n.push(s)}return n};Ae.checkUnreserved=function(e){var t=e.start,r=e.end,i=e.name;if(this.inGenerator&&i==="yield"&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&i==="await"&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&Cc)&&i==="arguments"&&this.raiseRecoverable(t,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(i==="arguments"||i==="await")&&this.raise(t,"Cannot use "+i+" in class static initialization block"),this.keywords.test(i)&&this.raise(t,"Unexpected keyword '"+i+"'"),!(this.options.ecmaVersion<6&&this.input.slice(t,r).indexOf("\\")!==-1)){var n=this.strict?this.reservedWordsStrict:this.reservedWords;n.test(i)&&(!this.inAsync&&i==="await"&&this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+i+"' is reserved"))}};Ae.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,"Identifier"),e||(this.checkUnreserved(t),t.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t};Ae.parseIdentNode=function(){var e=this.startNode();return this.type===O.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name==="class"||e.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=O.name):this.unexpected(),e};Ae.parsePrivateIdent=function(){var e=this.startNode();return this.type===O.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,"Private field '#"+e.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e};Ae.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===O.semi||this.canInsertSemicolon()||this.type!==O.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(O.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")};Ae.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,"AwaitExpression")};var Sc=Mt.prototype;Sc.raise=function(e,t){var r=Rv(this.input,e);t+=" ("+r.line+":"+r.column+")",this.sourceFile&&(t+=" in "+this.sourceFile);var i=new SyntaxError(t);throw i.pos=e,i.loc=r,i.raisedAt=this.pos,i};Sc.raiseRecoverable=Sc.raise;Sc.curPosition=function(){if(this.options.locations)return new xs(this.curLine,this.pos-this.lineStart)};var bn=Mt.prototype,v1=o(function(t){this.flags=t,this.var=[],this.lexical=[],this.functions=[]},"Scope");bn.enterScope=function(e){this.scopeStack.push(new v1(e))};bn.exitScope=function(){this.scopeStack.pop()};bn.treatFunctionsAsVarInScope=function(e){return e.flags&aa||!this.inModule&&e.flags&na};bn.declareName=function(e,t,r){var i=!1;if(t===Xi){var n=this.currentScope();i=n.lexical.indexOf(e)>-1||n.functions.indexOf(e)>-1||n.var.indexOf(e)>-1,n.lexical.push(e),this.inModule&&n.flags&na&&delete this.undefinedExports[e]}else if(t===Nv){var a=this.currentScope();a.lexical.push(e)}else if(t===Fv){var s=this.currentScope();this.treatFunctionsAsVar?i=s.lexical.indexOf(e)>-1:i=s.lexical.indexOf(e)>-1||s.var.indexOf(e)>-1,s.functions.push(e)}else for(var l=this.scopeStack.length-1;l>=0;--l){var c=this.scopeStack[l];if(c.lexical.indexOf(e)>-1&&!(c.flags&Lv&&c.lexical[0]===e)||!this.treatFunctionsAsVarInScope(c)&&c.functions.indexOf(e)>-1){i=!0;break}if(c.var.push(e),this.inModule&&c.flags&na&&delete this.undefinedExports[e],c.flags&Cc)break}i&&this.raiseRecoverable(r,"Identifier '"+e+"' has already been declared")};bn.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)};bn.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};bn.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Cc|Os|oa))return t}};bn.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Cc|Os|oa)&&!(t.flags&Lp))return t}};var Rc=o(function(t,r,i){this.type="",this.start=r,this.end=0,t.options.locations&&(this.loc=new Ac(t,i)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[r,0])},"Node"),Es=Mt.prototype;Es.startNode=function(){return new Rc(this,this.start,this.startLoc)};Es.startNodeAt=function(e,t){return new Rc(this,e,t)};function qv(e,t,r,i){return e.type=t,e.end=r,this.options.locations&&(e.loc.end=i),this.options.ranges&&(e.range[1]=r),e}o(qv,"finishNodeAt");Es.finishNode=function(e,t){return qv.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)};Es.finishNodeAt=function(e,t,r,i){return qv.call(this,e,t,r,i)};Es.copyNode=function(e){var t=new Rc(this,e.start,this.startLoc);for(var r in e)t[r]=e[r];return t};var y1="Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz",Vv="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",Bv=Vv+" Extended_Pictographic",Wv=Bv,Gv=Wv+" EBase EComp EMod EPres ExtPict",Hv=Gv,b1=Hv,w1={9:Vv,10:Bv,11:Wv,12:Gv,13:Hv,14:b1},_1="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",x1={9:"",10:"",11:"",12:"",13:"",14:_1},Ov="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",Kv="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",Yv=Kv+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",Jv=Yv+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Qv=Jv+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Xv=Qv+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",O1=Xv+" "+y1,E1={9:Kv,10:Yv,11:Jv,12:Qv,13:Xv,14:O1},Zv={};function S1(e){var t=Zv[e]={binary:vn(w1[e]+" "+Ov),binaryOfStrings:vn(x1[e]),nonBinary:{General_Category:vn(Ov),Script:vn(E1[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}o(S1,"buildUnicodeData");for(xc=0,kp=[9,10,11,12,13,14];xc<kp.length;xc+=1)Ev=kp[xc],S1(Ev);var Ev,xc,kp,de=Mt.prototype,kc=o(function(t,r){this.parent=t,this.base=r||this},"BranchID");kc.prototype.separatedFrom=o(function(t){for(var r=this;r;r=r.parent)for(var i=t;i;i=i.parent)if(r.base===i.base&&r!==i)return!0;return!1},"separatedFrom");kc.prototype.sibling=o(function(){return new kc(this.parent,this.base)},"sibling");var Ai=o(function(t){this.parser=t,this.validFlags="gim"+(t.options.ecmaVersion>=6?"uy":"")+(t.options.ecmaVersion>=9?"s":"")+(t.options.ecmaVersion>=13?"d":"")+(t.options.ecmaVersion>=15?"v":""),this.unicodeProperties=Zv[t.options.ecmaVersion>=14?14:t.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null},"RegExpValidationState");Ai.prototype.reset=o(function(t,r,i){var n=i.indexOf("v")!==-1,a=i.indexOf("u")!==-1;this.start=t|0,this.source=r+"",this.flags=i,n&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=a&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=a&&this.parser.options.ecmaVersion>=9)},"reset");Ai.prototype.raise=o(function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)},"raise");Ai.prototype.at=o(function(t,r){r===void 0&&(r=!1);var i=this.source,n=i.length;if(t>=n)return-1;var a=i.charCodeAt(t);if(!(r||this.switchU)||a<=55295||a>=57344||t+1>=n)return a;var s=i.charCodeAt(t+1);return s>=56320&&s<=57343?(a<<10)+s-56613888:a},"at");Ai.prototype.nextIndex=o(function(t,r){r===void 0&&(r=!1);var i=this.source,n=i.length;if(t>=n)return n;var a=i.charCodeAt(t),s;return!(r||this.switchU)||a<=55295||a>=57344||t+1>=n||(s=i.charCodeAt(t+1))<56320||s>57343?t+1:t+2},"nextIndex");Ai.prototype.current=o(function(t){return t===void 0&&(t=!1),this.at(this.pos,t)},"current");Ai.prototype.lookahead=o(function(t){return t===void 0&&(t=!1),this.at(this.nextIndex(this.pos,t),t)},"lookahead");Ai.prototype.advance=o(function(t){t===void 0&&(t=!1),this.pos=this.nextIndex(this.pos,t)},"advance");Ai.prototype.eat=o(function(t,r){return r===void 0&&(r=!1),this.current(r)===t?(this.advance(r),!0):!1},"eat");Ai.prototype.eatChars=o(function(t,r){r===void 0&&(r=!1);for(var i=this.pos,n=0,a=t;n<a.length;n+=1){var s=a[n],l=this.at(i,r);if(l===-1||l!==s)return!1;i=this.nextIndex(i,r)}return this.pos=i,!0},"eatChars");de.validateRegExpFlags=function(e){for(var t=e.validFlags,r=e.flags,i=!1,n=!1,a=0;a<r.length;a++){var s=r.charAt(a);t.indexOf(s)===-1&&this.raise(e.start,"Invalid regular expression flag"),r.indexOf(s,a+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),s==="u"&&(i=!0),s==="v"&&(n=!0)}this.options.ecmaVersion>=15&&i&&n&&this.raise(e.start,"Invalid regular expression flag")};function k1(e){for(var t in e)return!0;return!1}o(k1,"hasProp");de.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&k1(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))};de.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var t=0,r=e.backReferenceNames;t<r.length;t+=1){var i=r[t];e.groupNames[i]||e.raise("Invalid named capture referenced")}};de.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new kc(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise("Nothing to repeat"),e.eat(123)&&e.raise("Lone quantifier brackets")};de.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););};de.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise("Invalid quantifier"),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1};de.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var r=!1;if(this.options.ecmaVersion>=9&&(r=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!r,!0}return e.pos=t,!1};de.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1};de.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)};de.regexp_eatBracedQuantifier=function(e,t){var r=e.pos;if(e.eat(123)){var i=0,n=-1;if(this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(n=e.lastIntValue),e.eat(125)))return n!==-1&&n<i&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=r}return!1};de.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)};de.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1};de.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var r=this.regexp_eatModifiers(e),i=e.eat(45);if(r||i){for(var n=0;n<r.length;n++){var a=r.charAt(n);r.indexOf(a,n+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(i){var s=this.regexp_eatModifiers(e);!r&&!s&&e.current()===58&&e.raise("Invalid regular expression modifiers");for(var l=0;l<s.length;l++){var c=s.charAt(l);(s.indexOf(c,l+1)>-1||r.indexOf(c)>-1)&&e.raise("Duplicate regular expression modifiers")}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise("Unterminated group")}}e.pos=t}return!1};de.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1};de.regexp_eatModifiers=function(e){for(var t="",r=0;(r=e.current())!==-1&&A1(r);)t+=Ji(r),e.advance();return t};function A1(e){return e===105||e===109||e===115}o(A1,"isRegularExpressionModifier");de.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)};de.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1};de.regexp_eatSyntaxCharacter=function(e){var t=e.current();return $v(t)?(e.lastIntValue=t,e.advance(),!0):!1};function $v(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}o($v,"isSyntaxCharacter");de.regexp_eatPatternCharacters=function(e){for(var t=e.pos,r=0;(r=e.current())!==-1&&!$v(r);)e.advance();return e.pos!==t};de.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124?(e.advance(),!0):!1};de.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var t=this.options.ecmaVersion>=16,r=e.groupNames[e.lastStringValue];if(r)if(t)for(var i=0,n=r;i<n.length;i+=1){var a=n[i];a.separatedFrom(e.branchID)||e.raise("Duplicate capture group name")}else e.raise("Duplicate capture group name");t?(r||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}};de.regexp_eatGroupName=function(e){if(e.lastStringValue="",e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise("Invalid capture group name")}return!1};de.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=Ji(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=Ji(e.lastIntValue);return!0}return!1};de.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,r=this.options.ecmaVersion>=11,i=e.current(r);return e.advance(r),i===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,r)&&(i=e.lastIntValue),T1(i)?(e.lastIntValue=i,!0):(e.pos=t,!1)};function T1(e){return ki(e,!0)||e===36||e===95}o(T1,"isRegExpIdentifierStart");de.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,r=this.options.ecmaVersion>=11,i=e.current(r);return e.advance(r),i===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,r)&&(i=e.lastIntValue),C1(i)?(e.lastIntValue=i,!0):(e.pos=t,!1)};function C1(e){return yn(e,!0)||e===36||e===95||e===8204||e===8205}o(C1,"isRegExpIdentifierPart");de.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)};de.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var r=e.lastIntValue;if(e.switchU)return r>e.maxBackReference&&(e.maxBackReference=r),!0;if(r<=e.numCapturingParens)return!0;e.pos=t}return!1};de.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1};de.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)};de.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1};de.regexp_eatZero=function(e){return e.current()===48&&!Dc(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1};de.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114?(e.lastIntValue=13,e.advance(),!0):!1};de.regexp_eatControlLetter=function(e){var t=e.current();return ey(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function ey(e){return e>=65&&e<=90||e>=97&&e<=122}o(ey,"isControlLetter");de.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var r=e.pos,i=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var n=e.lastIntValue;if(i&&n>=55296&&n<=56319){var a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var s=e.lastIntValue;if(s>=56320&&s<=57343)return e.lastIntValue=(n-55296)*1024+(s-56320)+65536,!0}e.pos=a,e.lastIntValue=n}return!0}if(i&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&j1(e.lastIntValue))return!0;i&&e.raise("Invalid unicode escape"),e.pos=r}return!1};function j1(e){return e>=0&&e<=1114111}o(j1,"isValidUnicode");de.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)?(e.lastIntValue=t,e.advance(),!0):!1};de.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var ty=0,Qi=1,Gr=2;de.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(R1(t))return e.lastIntValue=-1,e.advance(),Qi;var r=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((r=t===80)||t===112)){e.lastIntValue=-1,e.advance();var i;if(e.eat(123)&&(i=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return r&&i===Gr&&e.raise("Invalid property name"),i;e.raise("Invalid property name")}return ty};function R1(e){return e===100||e===68||e===115||e===83||e===119||e===87}o(R1,"isCharacterClassEscape");de.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var r=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,r,i),Qi}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var n=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,n)}return ty};de.regexp_validateUnicodePropertyNameAndValue=function(e,t,r){so(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(r)||e.raise("Invalid property value")};de.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return Qi;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return Gr;e.raise("Invalid property name")};de.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";ry(t=e.current());)e.lastStringValue+=Ji(t),e.advance();return e.lastStringValue!==""};function ry(e){return ey(e)||e===95}o(ry,"isUnicodePropertyNameCharacter");de.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";D1(t=e.current());)e.lastStringValue+=Ji(t),e.advance();return e.lastStringValue!==""};function D1(e){return ry(e)||Dc(e)}o(D1,"isUnicodePropertyValueCharacter");de.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)};de.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),r=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&r===Gr&&e.raise("Negated character class may contain strings"),!0}return!1};de.regexp_classContents=function(e){return e.current()===93?Qi:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),Qi)};de.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var r=e.lastIntValue;e.switchU&&(t===-1||r===-1)&&e.raise("Invalid character class"),t!==-1&&r!==-1&&t>r&&e.raise("Range out of order in character class")}}};de.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var r=e.current();(r===99||ay(r))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var i=e.current();return i!==93?(e.lastIntValue=i,e.advance(),!0):!1};de.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)};de.regexp_classSetExpression=function(e){var t=Qi,r;if(!this.regexp_eatClassSetRange(e))if(r=this.regexp_eatClassSetOperand(e)){r===Gr&&(t=Gr);for(var i=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(r=this.regexp_eatClassSetOperand(e))){r!==Gr&&(t=Qi);continue}e.raise("Invalid character in character class")}if(i!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(i!==e.pos)return t}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(r=this.regexp_eatClassSetOperand(e),!r)return t;r===Gr&&(t=Gr)}};de.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var i=e.lastIntValue;return r!==-1&&i!==-1&&r>i&&e.raise("Range out of order in character class"),!0}e.pos=t}return!1};de.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?Qi:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)};de.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var r=e.eat(94),i=this.regexp_classContents(e);if(e.eat(93))return r&&i===Gr&&e.raise("Negated character class may contain strings"),i;e.pos=t}if(e.eat(92)){var n=this.regexp_eatCharacterClassEscape(e);if(n)return n;e.pos=t}return null};de.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var r=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return r}else e.raise("Invalid escape");e.pos=t}return null};de.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===Gr&&(t=Gr);return t};de.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?Qi:Gr};de.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var r=e.current();return r<0||r===e.lookahead()&&L1(r)||P1(r)?!1:(e.advance(),e.lastIntValue=r,!0)};function L1(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}o(L1,"isClassSetReservedDoublePunctuatorCharacter");function P1(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}o(P1,"isClassSetSyntaxCharacter");de.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return I1(t)?(e.lastIntValue=t,e.advance(),!0):!1};function I1(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}o(I1,"isClassSetReservedPunctuator");de.regexp_eatClassControlLetter=function(e){var t=e.current();return Dc(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1};de.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=t}return!1};de.regexp_eatDecimalDigits=function(e){var t=e.pos,r=0;for(e.lastIntValue=0;Dc(r=e.current());)e.lastIntValue=10*e.lastIntValue+(r-48),e.advance();return e.pos!==t};function Dc(e){return e>=48&&e<=57}o(Dc,"isDecimalDigit");de.regexp_eatHexDigits=function(e){var t=e.pos,r=0;for(e.lastIntValue=0;iy(r=e.current());)e.lastIntValue=16*e.lastIntValue+ny(r),e.advance();return e.pos!==t};function iy(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}o(iy,"isHexDigit");function ny(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}o(ny,"hexToInt");de.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var r=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=t*64+r*8+e.lastIntValue:e.lastIntValue=t*8+r}else e.lastIntValue=t;return!0}return!1};de.regexp_eatOctalDigit=function(e){var t=e.current();return ay(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function ay(e){return e>=48&&e<=55}o(ay,"isOctalDigit");de.regexp_eatFixedHexDigits=function(e,t){var r=e.pos;e.lastIntValue=0;for(var i=0;i<t;++i){var n=e.current();if(!iy(n))return e.pos=r,!1;e.lastIntValue=16*e.lastIntValue+ny(n),e.advance()}return!0};var Np=o(function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new Ac(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},"Token"),We=Mt.prototype;We.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new Np(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};We.getToken=function(){return this.next(),new Np(this)};typeof Symbol<"u"&&(We[Symbol.iterator]=function(){var e=this;return{next:o(function(){var t=e.getToken();return{done:t.type===O.eof,value:t}},"next")}});We.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(O.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())};We.readToken=function(e){return ki(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)};We.fullCharCodeAt=function(e){var t=this.input.charCodeAt(e);if(t<=55295||t>=56320)return t;var r=this.input.charCodeAt(e+1);return r<=56319||r>=57344?t:(t<<10)+r-56613888};We.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)};We.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,r=this.input.indexOf("*/",this.pos+=2);if(r===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=r+2,this.options.locations)for(var i=void 0,n=t;(i=Tv(this.input,n,this.pos))>-1;)++this.curLine,n=this.lineStart=i;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,r),t,this.pos,e,this.curPosition())};We.skipLineComment=function(e){for(var t=this.pos,r=this.options.onComment&&this.curPosition(),i=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!oo(i);)i=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,r,this.curPosition())};We.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(e>8&&e<14||e>=5760&&Cv.test(String.fromCharCode(e)))++this.pos;else break e}}};We.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var r=this.type;this.type=e,this.value=t,this.updateContext(r)};We.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(O.ellipsis)):(++this.pos,this.finishToken(O.dot))};We.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(O.assign,2):this.finishOp(O.slash,1)};We.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),r=1,i=e===42?O.star:O.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++r,i=O.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(O.assign,r+1):this.finishOp(i,r)};We.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);if(t===e){if(this.options.ecmaVersion>=12){var r=this.input.charCodeAt(this.pos+2);if(r===61)return this.finishOp(O.assign,3)}return this.finishOp(e===124?O.logicalOR:O.logicalAND,2)}return t===61?this.finishOp(O.assign,2):this.finishOp(e===124?O.bitwiseOR:O.bitwiseAND,1)};We.readToken_caret=function(){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(O.assign,2):this.finishOp(O.bitwiseXOR,1)};We.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||Ar.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(O.incDec,2):t===61?this.finishOp(O.assign,2):this.finishOp(O.plusMin,1)};We.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),r=1;return t===e?(r=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+r)===61?this.finishOp(O.assign,r+1):this.finishOp(O.bitShift,r)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(r=2),this.finishOp(O.relational,r))};We.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(O.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(O.arrow)):this.finishOp(e===61?O.eq:O.prefix,1)};We.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var r=this.input.charCodeAt(this.pos+2);if(r<48||r>57)return this.finishOp(O.questionDot,2)}if(t===63){if(e>=12){var i=this.input.charCodeAt(this.pos+2);if(i===61)return this.finishOp(O.assign,3)}return this.finishOp(O.coalesce,2)}}return this.finishOp(O.question,1)};We.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),ki(t,!0)||t===92))return this.finishToken(O.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+Ji(t)+"'")};We.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(O.parenL);case 41:return++this.pos,this.finishToken(O.parenR);case 59:return++this.pos,this.finishToken(O.semi);case 44:return++this.pos,this.finishToken(O.comma);case 91:return++this.pos,this.finishToken(O.bracketL);case 93:return++this.pos,this.finishToken(O.bracketR);case 123:return++this.pos,this.finishToken(O.braceL);case 125:return++this.pos,this.finishToken(O.braceR);case 58:return++this.pos,this.finishToken(O.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(O.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(O.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+Ji(e)+"'")};We.finishOp=function(e,t){var r=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,r)};We.readRegexp=function(){for(var e,t,r=this.pos;;){this.pos>=this.input.length&&this.raise(r,"Unterminated regular expression");var i=this.input.charAt(this.pos);if(Ar.test(i)&&this.raise(r,"Unterminated regular expression"),e)e=!1;else{if(i==="[")t=!0;else if(i==="]"&&t)t=!1;else if(i==="/"&&!t)break;e=i==="\\"}++this.pos}var n=this.input.slice(r,this.pos);++this.pos;var a=this.pos,s=this.readWord1();this.containsEsc&&this.unexpected(a);var l=this.regexpState||(this.regexpState=new Ai(this));l.reset(r,n,s),this.validateRegExpFlags(l),this.validateRegExpPattern(l);var c=null;try{c=new RegExp(n,s)}catch{}return this.finishToken(O.regexp,{pattern:n,flags:s,value:c})};We.readInt=function(e,t,r){for(var i=this.options.ecmaVersion>=12&&t===void 0,n=r&&this.input.charCodeAt(this.pos)===48,a=this.pos,s=0,l=0,c=0,f=t??1/0;c<f;++c,++this.pos){var u=this.input.charCodeAt(this.pos),h=void 0;if(i&&u===95){n&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),l===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),c===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),l=u;continue}if(u>=97?h=u-97+10:u>=65?h=u-65+10:u>=48&&u<=57?h=u-48:h=1/0,h>=e)break;l=u,s=s*e+h}return i&&l===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===a||t!=null&&this.pos-a!==t?null:s};function F1(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}o(F1,"stringToNumber");function oy(e){return typeof BigInt!="function"?null:BigInt(e.replace(/_/g,""))}o(oy,"stringToBigInt");We.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var r=this.readInt(e);return r==null&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(r=oy(this.input.slice(t,this.pos)),++this.pos):ki(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(O.num,r)};We.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,"Invalid number");var r=this.pos-t>=2&&this.input.charCodeAt(t)===48;r&&this.strict&&this.raise(t,"Invalid number");var i=this.input.charCodeAt(this.pos);if(!r&&!e&&this.options.ecmaVersion>=11&&i===110){var n=oy(this.input.slice(t,this.pos));return++this.pos,ki(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(O.num,n)}r&&/[89]/.test(this.input.slice(t,this.pos))&&(r=!1),i===46&&!r&&(++this.pos,this.readInt(10),i=this.input.charCodeAt(this.pos)),(i===69||i===101)&&!r&&(i=this.input.charCodeAt(++this.pos),(i===43||i===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,"Invalid number")),ki(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var a=F1(this.input.slice(t,this.pos),r);return this.finishToken(O.num,a)};We.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var r=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(r,"Code point out of bounds")}else t=this.readHexChar(4);return t};We.readString=function(e){for(var t="",r=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var i=this.input.charCodeAt(this.pos);if(i===e)break;i===92?(t+=this.input.slice(r,this.pos),t+=this.readEscapedChar(!1),r=this.pos):i===8232||i===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(oo(i)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(r,this.pos++),this.finishToken(O.string,t)};var sy={};We.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===sy)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1};We.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw sy;this.raise(e,t)};We.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var r=this.input.charCodeAt(this.pos);if(r===96||r===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===O.template||this.type===O.invalidTemplate)?r===36?(this.pos+=2,this.finishToken(O.dollarBraceL)):(++this.pos,this.finishToken(O.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(O.template,e));if(r===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(oo(r)){switch(e+=this.input.slice(t,this.pos),++this.pos,r){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`
|
|
32
|
+
`;break;default:e+=String.fromCharCode(r);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}};We.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(O.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
|
|
33
33
|
`&&++this.pos;case`
|
|
34
|
-
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};
|
|
35
|
-
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return
|
|
36
|
-
`,t-1)+1;return/^[ \t]*/.exec(e.slice(r))[0]}o(
|
|
37
|
-
`)!==-1}o(
|
|
38
|
-
`)!==-1){let
|
|
39
|
-
`+
|
|
40
|
-
`+
|
|
41
|
-
`+l+r+","}:{start:
|
|
42
|
-
`+l+r}}return s!==-1?{start:
|
|
43
|
-
`,
|
|
44
|
-
`,f);return/^[ \t]*$/.test(e.slice(c
|
|
45
|
-
`+
|
|
46
|
-
`+w.map(function(S){return
|
|
34
|
+
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};We.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
|
|
35
|
+
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return Ji(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var r=this.pos-1;this.invalidStringToken(r,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var i=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],n=parseInt(i,8);return n>255&&(i=i.slice(0,-1),n=parseInt(i,8)),this.pos+=i.length-1,t=this.input.charCodeAt(this.pos),(i!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-i.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(n)}return oo(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}};We.readHexChar=function(e){var t=this.pos,r=this.readInt(16,e);return r===null&&this.invalidStringToken(t,"Bad character escape sequence"),r};We.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,r=this.pos,i=this.options.ecmaVersion>=6;this.pos<this.input.length;){var n=this.fullCharCodeAtPos();if(yn(n,i))this.pos+=n<=65535?1:2;else if(n===92){this.containsEsc=!0,e+=this.input.slice(r,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var s=this.readCodePoint();(t?ki:yn)(s,i)||this.invalidStringToken(a,"Invalid Unicode escape"),e+=Ji(s),r=this.pos}else break;t=!1}return e+this.input.slice(r,this.pos)};We.readWord=function(){var e=this.readWord1(),t=O.name;return this.keywords.test(e)&&(t=Rp[e]),this.finishToken(t,e)};var N1="8.16.0";Mt.acorn={Parser:Mt,version:N1,defaultOptions:Tp,Position:xs,SourceLocation:Ac,getLineInfo:Rv,Node:Rc,TokenType:$e,tokTypes:O,keywordTypes:Rp,TokContext:ci,tokContexts:wt,isIdentifierChar:yn,isIdentifierStart:ki,Token:Np,isNewLine:oo,lineBreak:Ar,lineBreakG:o1,nonASCIIwhitespace:Cv};function Lc(e,t){return Mt.parse(e,t)}o(Lc,"parse");function cy(e){return Lc(e,{ecmaVersion:"latest",sourceType:"module"})}o(cy,"parseModule");var sa="parts",Pc=/^[A-Za-z_$][\w$]*$/,uy=new Set("break case catch class const continue debugger default delete do else export extends false finally for function if import in instanceof new null return super switch this throw true try typeof var void while with yield let static enum await implements package protected interface private public".split(" "));function fy(e){return typeof e=="string"&&Pc.test(e)&&!uy.has(e)}o(fy,"isIdentifierName");function Ss(e){return Pc.test(e)&&!uy.has(e)?e:As(e)}o(Ss,"_keyText");function As(e){return"'"+e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")+"'"}o(As,"_quote");function Ic(e,t){if(e===null)return"null";let r=typeof e;if(r==="number"){if(!Number.isFinite(e))throw new Error('"'+t+'" is '+String(e)+" \u2014 the writer writes finite numbers only.");return Object.is(e,-0)?"0":String(e)}if(r==="string")return As(e);if(r==="boolean")return e?"true":"false";if(Array.isArray(e))return"["+e.map(function(i,n){return Ic(i,t+"["+n+"]")}).join(", ")+"]";if(r==="object"){let i=Object.getPrototypeOf(e);if(i!==Object.prototype&&i!==null)throw new Error('"'+t+'" is a '+(e.constructor&&e.constructor.name||"class")+" instance \u2014 the writer writes numbers, strings, booleans, null, arrays and plain objects.");let n=Object.keys(e);return n.length?"{ "+n.map(function(a){return Ss(a)+": "+Ic(e[a],t+"."+a)}).join(", ")+" }":"{}"}throw new Error('"'+t+'" is '+(r==="undefined"?"undefined":"a "+r)+" \u2014 the writer writes numbers, strings, booleans, null, arrays and plain objects.")}o(Ic,"serializeValue");function Fc(e){return e?e.type==="Literal"?!e.regex&&typeof e.value!="bigint":e.type==="UnaryExpression"&&e.operator==="-"?e.argument.type==="Literal"&&typeof e.argument.value=="number":e.type==="ArrayExpression"?e.elements.every(function(t){return t&&Fc(t)}):e.type==="ObjectExpression"?e.properties.every(function(t){return t.type==="Property"&&!t.computed&&t.kind==="init"&&!t.method&&!t.shorthand&&Fc(t.value)}):!1:!1}o(Fc,"_isLiteral");function co(e){return e.type!=="Property"||e.computed?null:e.key.type==="Identifier"?e.key.name:e.key.type==="Literal"&&(typeof e.key.value=="string"||typeof e.key.value=="number")?String(e.key.value):null}o(co,"_plainKey");function hy(e){for(let t of e.body)if(!(t.type!=="ExportNamedDeclaration"||!t.declaration||t.declaration.type!=="VariableDeclaration")){for(let r of t.declaration.declarations)if(r.id.type==="Identifier"&&r.id.name===sa)return r.init&&r.init.type==="ObjectExpression"?r.init:null}return null}o(hy,"_partsLiteral");function M1(e){let t=new Map;for(let r of e.body){if(r.type==="ImportDeclaration"){for(let n of r.specifiers)t.set(n.local.name,{kind:"import",source:r.source.value,imported:n.type==="ImportSpecifier"?n.imported.name||n.imported.value:null});continue}let i=r.type==="ExportNamedDeclaration"||r.type==="ExportDefaultDeclaration"?r.declaration:r;if(i)if(i.type==="VariableDeclaration")for(let n of i.declarations)ks(n.id).forEach(function(a){t.set(a,{kind:"decl"})});else(i.type==="FunctionDeclaration"||i.type==="ClassDeclaration")&&i.id&&t.set(i.id.name,{kind:"decl"})}return t}o(M1,"_topBindings");function ks(e){return e?e.type==="Identifier"?[e.name]:e.type==="ObjectPattern"?e.properties.flatMap(function(t){return ks(t.type==="RestElement"?t.argument:t.value)}):e.type==="ArrayPattern"?e.elements.flatMap(ks):e.type==="RestElement"?ks(e.argument):e.type==="AssignmentPattern"?ks(e.left):[]:[]}o(ks,"_patternNames");function Ts(e,t){let r=e.lastIndexOf(`
|
|
36
|
+
`,t-1)+1;return/^[ \t]*/.exec(e.slice(r))[0]}o(Ts,"_indentAt");function Mp(e,t){return e.slice(t.start,t.end).indexOf(`
|
|
37
|
+
`)!==-1}o(Mp,"_multiline");function ly(e,t,r){let i=t.end-1,n=t.properties[t.properties.length-1];if(!n){if(e.slice(t.start+1,i).indexOf(`
|
|
38
|
+
`)!==-1){let c=Ts(e,i);return{start:t.start+1,end:i,text:`
|
|
39
|
+
`+c+" "+r+`,
|
|
40
|
+
`+c}}return{start:t.start+1,end:i,text:" "+r+" "}}let s=e.slice(n.end,i).indexOf(",");if(Mp(e,t)){let l=Ts(e,n.start);return s!==-1?{start:n.end+s+1,end:n.end+s+1,text:`
|
|
41
|
+
`+l+r+","}:{start:n.end,end:n.end,text:`,
|
|
42
|
+
`+l+r}}return s!==-1?{start:n.end+s+1,end:n.end+s+1,text:" "+r+","}:{start:n.end,end:n.end,text:", "+r}}o(ly,"_appendProperty");function U1(e,t,r){let i=t.properties.indexOf(r),n=t.properties[i+1],a=n?n.start:t.end-1,l=e.slice(r.end,a).indexOf(","),c=r.start,f=l!==-1?r.end+l+1:r.end;if(l===-1&&i>0){let g=t.properties[i-1],d=e.slice(g.end,r.start).indexOf(",");d!==-1&&(c=g.end+d)}let u=e.lastIndexOf(`
|
|
43
|
+
`,c-1)+1,h=e.indexOf(`
|
|
44
|
+
`,f);return/^[ \t]*$/.test(e.slice(u,c))&&h!==-1&&/^[ \t]*$/.test(e.slice(f,h))&&(c=u,f=h+1),{start:c,end:f,text:""}}o(U1,"_removeProperty");function Nc(e,t,r){let i=r&&r.entry||"sketch.js";if(typeof e!="string")throw new TypeError("[parts-writer] patchParts(text, edits): text is the sketch file (got "+typeof e+"). (FAIL-LOUD.)");if(!Array.isArray(t))throw new TypeError("[parts-writer] patchParts(text, edits): edits is an array of { op: set | add | remove | kind }. (FAIL-LOUD.)");let n=[],a=[];if(!t.length)return{text:e,changes:n,refused:a};function s(w,x,S){let A={op:w.op,name:w.name,reason:x};S!==void 0&&(A.key=S),a.push(A)}o(s,"refuse");let l;try{l=Lc(e,{ecmaVersion:"latest",sourceType:"module"})}catch(w){return t.forEach(function(x){s(x,"the sketch does not parse ("+w.message+") \u2014 fix it, then Run.")}),{text:e,changes:n,refused:a}}let c=hy(l);if(!c)return t.forEach(function(w){s(w,"this sketch has no `export const "+sa+" = { \u2026 }` object literal \u2014 the writer writes only into that literal; declare the parts there (exp.declare("+sa+")) to make them editable.")}),{text:e,changes:n,refused:a};let f=new Map,u=!1;for(let w of c.properties){let x=co(w);if(x===null){u=!0;continue}f.set(x,w)}let h=M1(l),g=[],d=[],m=o(function(w){let x=f.get(w.name);return x||(s(w,u?'no plain key "'+w.name+'" in the parts literal, which carries a spread or a computed key \u2014 a name that comes from either is not writable here; write the entry as a plain key.':'the parts literal has no entry "'+w.name+'".'),null)},"entryOf"),b=[];for(let w of t){if(!w||typeof w!="object"||typeof w.name!="string"||!w.name)throw new TypeError("[parts-writer] an edit is { op, name, \u2026 } with a non-empty name (got "+JSON.stringify(w)+"). (FAIL-LOUD.)");if(w.op==="set"){let x=m(w);if(!x)continue;let S=x.value;if(S.type!=="ArrayExpression"||S.elements.length!==2||!S.elements[0]||S.elements[0].type!=="Identifier"||!S.elements[1]||S.elements[1].type!=="ObjectExpression"){s(w,'the entry "'+w.name+'" is not written as [Kind, { \u2026props }] \u2014 the writer patches only that form.');continue}let A=S.elements[1],T=new Map;for(let Q of A.properties){let Y=co(Q);Y!==null&&T.set(Y,Q)}let j=[];for(let Q of Object.keys(w.props||{})){let Y;try{Y=Ic(w.props[Q],Q)}catch(V){s(w,V.message,Q);continue}let H=T.get(Q);if(H&&!H.shorthand){let V=e.slice(H.value.start,H.value.end);if(V===Y)continue;g.push({start:H.value.start,end:H.value.end,text:Y});let C={op:"set",name:w.name,key:Q,from:V,to:Y};Fc(H.value)||(C.literalized=!0),n.push(C)}else H&&H.shorthand?(g.push({start:H.start,end:H.end,text:Ss(Q)+": "+Y}),n.push({op:"set",name:w.name,key:Q,from:Q,to:Y,literalized:!0})):(j.push(Ss(Q)+": "+Y),n.push({op:"set",name:w.name,key:Q,from:null,to:Y}))}if(j.length){let Q=ly(e,A,j.join(Mp(e,A)?`,
|
|
45
|
+
`+Ts(e,(A.properties[A.properties.length-1]||A).start):", "));g.push(Q)}}else if(w.op==="kind"){let x=m(w);if(!x)continue;let S=x.value;if(S.type!=="ArrayExpression"||S.elements.length!==2||!S.elements[0]||S.elements[0].type!=="Identifier"){s(w,'the entry "'+w.name+'" is not written as [Kind, { \u2026props }] \u2014 the writer patches only that form.');continue}if(typeof w.Kind!="string"||!Pc.test(w.Kind))throw new TypeError("[parts-writer] kind: Kind is the new kind's class name (got "+JSON.stringify(w.Kind)+"). (FAIL-LOUD.)");if(w.module===null||w.module===void 0){s(w,"the kind "+w.Kind+" has no importable module, so a sketch cannot import it.");continue}let A=vp(w.module,i),T=h.get(w.Kind);if(T&&!(T.kind==="import"&&T.source===A&&T.imported===w.Kind)){s(w,"the identifier "+w.Kind+" is already bound in this sketch to "+(T.kind==="import"?'"'+(T.imported||"*")+`" from '`+T.source+"'":"its own declaration")+" \u2014 the writer cannot import the kind "+w.Kind+" under that name.");continue}let j=S.elements[0];if(j.name===w.Kind)continue;g.push({start:j.start,end:j.end,text:w.Kind});let Q="import { "+w.Kind+" } from "+As(A)+";";!T&&!d.some(function(Y){return Y.Kind===w.Kind})&&d.push({Kind:w.Kind,line:Q}),n.push({op:"kind",name:w.name,from:j.name,to:w.Kind,import:T?null:Q})}else if(w.op==="remove"){let x=m(w);if(!x)continue;g.push(U1(e,c,x)),n.push({op:"remove",name:w.name,from:e.slice(x.start,x.end),to:null})}else if(w.op==="add"){if(f.has(w.name)||b.some(function(T){return T.name===w.name})){s(w,'the parts literal already has an entry "'+w.name+'" \u2014 a declared name is one key.');continue}if(typeof w.Kind!="string"||!Pc.test(w.Kind))throw new TypeError("[parts-writer] add: Kind is the kind's class name (got "+JSON.stringify(w.Kind)+"). (FAIL-LOUD.)");if(w.module===null||w.module===void 0){s(w,"the kind "+w.Kind+" has no importable module (an internal kind, not a part of @descix/frqtl-web/parts nor a project file), so a sketch cannot import it \u2014 declare it in code.");continue}let x=vp(w.module,i),S=h.get(w.Kind);if(S&&!(S.kind==="import"&&S.source===x&&S.imported===w.Kind)){s(w,"the identifier "+w.Kind+" is already bound in this sketch to "+(S.kind==="import"?'"'+(S.imported||"*")+`" from '`+S.source+"'":"its own declaration")+" \u2014 the writer cannot import the kind "+w.Kind+" under that name.");continue}let A;try{A=Ic(w.props||{},w.name)}catch(T){s(w,T.message);continue}!S&&!d.some(function(T){return T.Kind===w.Kind})&&d.push({Kind:w.Kind,line:"import { "+w.Kind+" } from "+As(x)+";"}),b.push({name:w.name,text:Ss(w.name)+": ["+w.Kind+", "+A+"]"}),n.push({op:"add",name:w.name,from:null,to:Ss(w.name)+": ["+w.Kind+", "+A+"]",import:S?null:"import { "+w.Kind+" } from "+As(x)+";"})}else throw new TypeError("[parts-writer] unknown edit op "+JSON.stringify(w.op)+" \u2014 set | add | remove | kind. (FAIL-LOUD.)")}if(b.length){let w=b.map(function(x){return x.text});if(Mp(e,c)||c.properties.length===0)if(c.properties.length===0){let x=Ts(e,c.start);g.push({start:c.start+1,end:c.end-1,text:`
|
|
46
|
+
`+w.map(function(S){return x+" "+S+","}).join(`
|
|
47
47
|
`)+`
|
|
48
|
-
`+
|
|
49
|
-
`+
|
|
50
|
-
`+
|
|
51
|
-
`,S.end);
|
|
52
|
-
`}).join("");g.push({start:
|
|
53
|
-
`+
|
|
54
|
-
`,S.start-1)+1:e.length,g.push({start:
|
|
48
|
+
`+x})}else{let x=Ts(e,c.properties[c.properties.length-1].start),S=c.properties[c.properties.length-1],A=e.slice(S.end,c.end-1).indexOf(",");A!==-1?g.push({start:S.end+A+1,end:S.end+A+1,text:w.map(function(T){return`
|
|
49
|
+
`+x+T+","}).join("")}):g.push({start:S.end,end:S.end,text:w.map(function(T){return`,
|
|
50
|
+
`+x+T}).join("")})}else g.push(ly(e,c,w.join(", ")))}if(d.length){let w=l.body.filter(function(S){return S.type==="ImportDeclaration"}),x;if(w.length){let S=w[w.length-1],A=e.indexOf(`
|
|
51
|
+
`,S.end);x=A===-1?e.length:A+1;let T=d.map(function(j){return j.line+`
|
|
52
|
+
`}).join("");g.push({start:x,end:x,text:A===-1?`
|
|
53
|
+
`+T:T})}else{let S=l.body[0];x=S?e.lastIndexOf(`
|
|
54
|
+
`,S.start-1)+1:e.length,g.push({start:x,end:x,text:d.map(function(A){return A.line+`
|
|
55
55
|
`}).join("")+`
|
|
56
|
-
`})}}g.sort(function(w,O){return O.start-w.start||O.end-w.end});for(let w=1;w<g.length;w++)if(g[w].end>g[w-1].start)throw new Error("[parts-writer] two edits touch overlapping text \u2014 one edit per property. (FAIL-LOUD.)");let y=e;for(let w of g)y=y.slice(0,w.start)+w.text+y.slice(w.end);return{text:y,changes:i,refused:a}}o(nd,"patchParts");function Bv(e,t,r){let n=ed(e,{ecmaVersion:"latest",sourceType:"module"}),i=qv(n);if(!i)throw new Error("[parts-writer] "+r+": the sketch has no `export const "+ea+" = { \u2026 }` object literal. (FAIL-LOUD.)");let a=null;for(let l of i.properties)to(l)===t&&(a=l);let s=a&&a.value;if(!s||s.type!=="ArrayExpression"||s.elements.length!==2||!s.elements[1]||s.elements[1].type!=="ObjectExpression")throw new Error("[parts-writer] "+r+': the parts literal has no entry "'+t+'" written as [Kind, { \u2026props }]. (FAIL-LOUD.)');return s.elements[1]}o(Bv,"_entryProps");function rd(e){if(e.type==="Literal")return e.value;if(e.type==="UnaryExpression")return-e.argument.value;if(e.type==="ArrayExpression")return e.elements.map(rd);let t={};for(let r of e.properties)t[to(r)]=rd(r.value);return t}o(rd,"_literalValue");function id(e,t){let r=[];for(let n of Bv(e,t,"entryKeys").properties){let i=to(n);i!==null&&r.push(i)}return r}o(id,"entryKeys");function ad(e,t,r){for(let n of Bv(e,t,"entryLiteral").properties)if(to(n)===r)return cu(n.value)?{literal:!0,value:rd(n.value)}:n.value.type==="ArrayExpression"?{literal:!1,length:n.value.elements.length}:{literal:!1};throw new Error('[parts-writer] entryLiteral: the entry "'+t+'" spells no key "'+r+'". (FAIL-LOUD.)')}o(ad,"entryLiteral");vl();var At=Object.freeze({record:"record.json",partsBefore:"parts.before.json",partsAfter:"parts.after.json",project:"project/"}),fu=Object.freeze(["tickRange","clips","changes"]),ta=Object.freeze(["tick","name","op","by","from","to"]),f1=Object.freeze(["move","setDeclared","add","remove","fork"]),ds=Object.freeze(["human","maxi"]),Hr=Object.freeze({min:5,max:10}),h1=/^clip-(\d{2})\.mp4$/;function hu(e){if(!Number.isInteger(e)||e<1||e>99)throw new Error("[record-format] a clip number is a whole number 1\u201399, got "+JSON.stringify(e)+". (FAIL-LOUD.)");return"clip-"+String(e).padStart(2,"0")+".mp4"}o(hu,"clipName");function od(e){return JSON.stringify(e,null,2)+`
|
|
57
|
-
`}o(
|
|
56
|
+
`})}}g.sort(function(w,x){return x.start-w.start||x.end-w.end});for(let w=1;w<g.length;w++)if(g[w].end>g[w-1].start)throw new Error("[parts-writer] two edits touch overlapping text \u2014 one edit per property. (FAIL-LOUD.)");let y=e;for(let w of g)y=y.slice(0,w.start)+w.text+y.slice(w.end);return{text:y,changes:n,refused:a}}o(Nc,"patchParts");function py(e,t,r){let i=Lc(e,{ecmaVersion:"latest",sourceType:"module"}),n=hy(i);if(!n)throw new Error("[parts-writer] "+r+": the sketch has no `export const "+sa+" = { \u2026 }` object literal. (FAIL-LOUD.)");let a=null;for(let l of n.properties)co(l)===t&&(a=l);let s=a&&a.value;if(!s||s.type!=="ArrayExpression"||s.elements.length!==2||!s.elements[1]||s.elements[1].type!=="ObjectExpression")throw new Error("[parts-writer] "+r+': the parts literal has no entry "'+t+'" written as [Kind, { \u2026props }]. (FAIL-LOUD.)');return s.elements[1]}o(py,"_entryProps");function Up(e){if(e.type==="Literal")return e.value;if(e.type==="UnaryExpression")return-e.argument.value;if(e.type==="ArrayExpression")return e.elements.map(Up);let t={};for(let r of e.properties)t[co(r)]=Up(r.value);return t}o(Up,"_literalValue");function zp(e,t){let r=[];for(let i of py(e,t,"entryKeys").properties){let n=co(i);n!==null&&r.push(n)}return r}o(zp,"entryKeys");function qp(e,t,r){for(let i of py(e,t,"entryLiteral").properties){if(co(i)!==r)continue;return Fc(i.value)?{literal:!0,value:Up(i.value)}:i.value.type==="ArrayExpression"&&!i.value.elements.some(function(a){return a&&a.type==="SpreadElement"})?{literal:!1,length:i.value.elements.length}:{literal:!1}}throw new Error('[parts-writer] entryLiteral: the entry "'+t+'" spells no key "'+r+'". (FAIL-LOUD.)')}o(qp,"entryLiteral");xt();var Vp={};ge(Vp,{KINDS_EXPORTS:()=>Mc,kindNamed:()=>ja,kindOf:()=>Dt,registerKind:()=>at,registeredKinds:()=>Ra});xt();var Mc=Object.freeze(["registerKind","kindNamed","kindOf","registeredKinds"]);var Cs=Object.freeze({LargeObject:"LargeObject is a scope row (schema/scopes.js SCOPE_DESCRIPTORS) and passes 'LargeObject' as the engine scope name to universe.updateObjectProperty \u2014 a copy would be a second scope row",PointSource:"PointSource numbers its default name with declaredCount(ctx.runner, 'PointSource') \u2014 a copy would number itself in its parent's sequence (the class name used as a string)"}),z1="frqtl/parts/",q1="frqtl/objects/kinds.js";function Tr(e){throw new Error("[fork] "+e+" (FAIL-LOUD.)")}o(Tr,"_fail");function my(e){let t=[];for(let r of Object.keys(e)){if(r==="type"||r==="start"||r==="end"||r==="loc"||r==="range")continue;let i=e[r];if(Array.isArray(i))for(let n of i)n&&typeof n.type=="string"&&t.push(n);else i&&typeof i.type=="string"&&t.push(i)}return t}o(my,"_children");function Ti(e,t){if(!e)return t;if(e.type==="Identifier")t.push(e.name);else if(e.type==="ObjectPattern")for(let r of e.properties)Ti(r.type==="RestElement"?r.argument:r.value,t);else if(e.type==="ArrayPattern")for(let r of e.elements)Ti(r,t);else e.type==="RestElement"?Ti(e.argument,t):e.type==="AssignmentPattern"&&Ti(e.left,t);return t}o(Ti,"_patternNames");var gy={FunctionDeclaration:1,FunctionExpression:1,ArrowFunctionExpression:1};function vy(e,t){for(let r of my(e))if(!gy[r.type]){if(r.type==="VariableDeclaration"&&r.kind==="var")for(let i of r.declarations)Ti(i.id,t);vy(r,t)}return t}o(vy,"_varNames");function Bp(e,t){for(let r of e){let i=r.type==="ExportNamedDeclaration"||r.type==="ExportDefaultDeclaration"?r.declaration:r;if(i)if(i.type==="VariableDeclaration"&&i.kind!=="var")for(let n of i.declarations)Ti(n.id,t);else(i.type==="ClassDeclaration"||i.type==="FunctionDeclaration")&&i.id&&t.push(i.id.name)}return t}o(Bp,"_lexicalNames");function V1(e,t){if(gy[e.type]){let r=[];for(let i of e.params)Ti(i,r);return e.type==="FunctionExpression"&&e.id&&r.push(e.id.name),e.body.type==="BlockStatement"&&(vy(e.body,r),Bp(e.body.body,r)),r}if(e.type==="BlockStatement"||e.type==="StaticBlock")return t?null:Bp(e.body,[]);if(e.type==="SwitchStatement")return Bp(e.cases.flatMap(function(r){return r.consequent}),[]);if(e.type==="ForStatement"||e.type==="ForInStatement"||e.type==="ForOfStatement"){let r=e.type==="ForStatement"?e.init:e.left;return!r||r.type!=="VariableDeclaration"||r.kind==="var"?[]:r.declarations.reduce(function(i,n){return Ti(n.id,i)},[])}return e.type==="CatchClause"?e.param?Ti(e.param,[]):[]:e.type==="ClassExpression"&&e.id?[e.id.name]:null}o(V1,"_scopeNames");function B1(e,t){let r=[];function i(a,s,l,c){if(a.type==="Identifier"){if(a.name!==t||s||l&&(l.type==="MemberExpression"&&c==="property"&&!l.computed||(l.type==="Property"||l.type==="MethodDefinition"||l.type==="PropertyDefinition")&&c==="key"&&!l.computed&&!l.shorthand||(l.type==="LabeledStatement"||l.type==="BreakStatement"||l.type==="ContinueStatement")&&c==="label"||l.type==="ImportSpecifier"&&c==="imported"||l.type==="ExportSpecifier"&&c==="exported"))return;r.push(a);return}let f=a===e?null:V1(a,!1),u=s||!!(f&&f.indexOf(t)!==-1);for(let h of Object.keys(a)){if(h==="type"||h==="start"||h==="end"||h==="loc")continue;let g=a[h];if(Array.isArray(g))for(let d of g)d&&typeof d.type=="string"&&i(d,n(a,h,d,u,s),a,h);else g&&typeof g.type=="string"&&i(g,n(a,h,g,u,s),a,h)}}o(i,"visit");function n(a,s,l,c,f){return a.type==="FunctionDeclaration"&&s==="id"?f:c}return o(n,"_childShadow"),i(e,!1,null,null),r}o(B1,"_moduleBindingIds");function W1(e,t){for(let r of e.body){let i=r.type==="ExportNamedDeclaration"||r.type==="ExportDefaultDeclaration"?r.declaration:r;if(i&&((i.type==="ClassDeclaration"||i.type==="FunctionDeclaration")&&i.id&&i.id.name===t||i.type==="VariableDeclaration"&&i.declarations.some(function(n){return Ti(n.id,[]).indexOf(t)!==-1})))return i}return null}o(W1,"_topDeclaration");function G1(e,t){let r=null;return o((function i(n){if(!r){if(n.type==="CallExpression"&&n.callee.type==="Identifier"&&n.callee.name==="registerKind"&&n.arguments[0]&&n.arguments[0].type==="Identifier"&&n.arguments[0].name===t&&n.arguments[1]&&n.arguments[1].type==="ObjectExpression"){let a=n.arguments[1].properties.find(function(s){return s.type==="Property"&&!s.computed&&s.key.name==="palette"});if(a&&a.value.type==="ObjectExpression"){let s=a.value.properties.find(function(l){return l.type==="Property"&&!l.computed&&l.key.name==="displayName"});s&&s.value.type==="Literal"&&typeof s.value.value=="string"&&(r=s.value)}return}for(let a of my(n))i(a)}}),"visit")(e),r}o(G1,"_paletteName");function H1(e,t){let r=e.split("/");r.pop();for(let i of t.split("/"))i==="."||i===""||(i===".."?r.pop():r.push(i));return r.join("/")}o(H1,"_resolve");function dy(e,t){let r=e[0]==='"'?'"':"'";return r+t.replace(/\\/g,"\\\\").split(r).join("\\"+r)+r}o(dy,"_quoteLike");function yy(e,t){(typeof e!="string"||!e)&&Tr("forkPartText(text, opts): text is the part file (got "+typeof e+").");let r=t||{},i=r.from,n=r.to,a=r.libPath,s=r.files;(typeof i!="string"||!i)&&Tr("forkPartText: `from` is the class name the part registers."),(typeof a!="string"||!a)&&Tr("forkPartText("+i+"): `libPath` names the source file."),(!s||typeof s!="object")&&Tr("forkPartText("+i+"): `files` is the project's file map ({} when none)."),(typeof n!="string"||!fy(n))&&Tr("forkPartText("+i+"): the new class name "+JSON.stringify(n)+" is not an identifier (or is a reserved word) \u2014 the class name IS the kind name."),n===i&&Tr("forkPartText("+i+"): the new class name equals the part's own \u2014 a fork is a NEW kind; name it."),Dt(n)&&Tr("forkPartText("+i+'): "'+n+'" is already a registered kind ('+Dt(n).from+") \u2014 one name has one owner; choose another name.");let l="parts/"+n+".js";Object.prototype.hasOwnProperty.call(s,l)&&Tr("forkPartText("+i+"): "+l+" is already a project file \u2014 a fork never overwrites one."),Object.prototype.hasOwnProperty.call(Cs,i)&&Tr("forkPartText("+i+"): "+i+" is not forkable \u2014 "+Cs[i]+".");let c=a.indexOf(z1)===0,f;try{f=cy(e)}catch(m){Tr("forkPartText("+i+"): "+a+" does not parse ("+m.message+").")}W1(f,i)||Tr("forkPartText("+i+"): "+a+" declares no module-scope "+i+" \u2014 the file a kind's `from` names declares its class.");let u=[],h=[];for(let m of f.body){let b=m.type==="ImportDeclaration"||(m.type==="ExportNamedDeclaration"||m.type==="ExportAllDeclaration")&&m.source?m.source:null;if(!b)continue;let y=b.value;if(!(y.startsWith("./")||y.startsWith("../"))){h.push({from:y,to:y});continue}if(!c){h.push({from:y,to:y});continue}let w=H1(a,y),x;if(w===q1){let A=(m.specifiers||[]).map(function(T){return T.type==="ImportSpecifier"?T.imported.name||T.imported.value:"*"}).filter(function(T){return Mc.indexOf(T)===-1});A.length&&Tr("forkPartText("+i+"): "+a+" imports "+A.join(", ")+' from "'+y+'" \u2014 the kinds door (@descix/frqtl-web/kinds) publishes '+Mc.join(", ")+" only."),x=vs("frqtl/objects/kinds-entry.js")}else x=vs(w);x||Tr("forkPartText("+i+"): "+a+' imports "'+y+'" ('+w+"), which no specifier row names \u2014 a fork imports every non-part module from the package (lib/shim/project/specifiers.js); it never copies one."),u.push({start:b.start,end:b.end,text:dy(e.slice(b.start,b.end),x)}),h.push({from:y,to:x})}for(let m of B1(f,i))u.push({start:m.start,end:m.end,text:n});let g=G1(f,i);g&&u.push({start:g.start,end:g.end,text:dy(e.slice(g.start,g.end),n)}),u.sort(function(m,b){return b.start-m.start});for(let m=1;m<u.length;m++)u[m].end>u[m-1].start&&Tr("forkPartText("+i+"): overlapping rewrites \u2014 a bug in the transform.");let d=e;for(let m of u)d=d.slice(0,m.start)+m.text+d.slice(m.end);return{text:d,imports:h}}o(yy,"forkPartText");function by(e,t){return Promise.resolve().then(function(){if(typeof e!="string"||!e)throw new TypeError("readText(url): a URL string (got "+JSON.stringify(e)+")");if(e.indexOf("file:")===0){var r=typeof process<"u"&&process.getBuiltinModule?process.getBuiltinModule:null;if(typeof r!="function")throw new Error(e+" is a file: URL; reading one needs node's process.getBuiltinModule (Node 20.16+ / 22.3+). In a page, serve the package over http");var i=r("node:fs"),n=r("node:url").fileURLToPath;return i.promises.readFile(n(e),"utf8").catch(function(s){throw new Error("reading "+e+" failed: "+(s&&s.message))})}var a=t&&t.fetch||(typeof fetch=="function"?fetch:null);if(!a)throw new Error("no fetch available to load "+e);return Promise.resolve(a(e)).then(function(s){if(!s||!s.ok)throw new Error("GET "+e+" answered "+(s?s.status:"nothing"));return s.text()})})}o(by,"readText");At();ql();var Ct=Object.freeze({record:"record.json",partsBefore:"parts.before.json",partsAfter:"parts.after.json",project:"project/"}),Uc=Object.freeze(["tickRange","clips","changes"]),la=Object.freeze(["tick","name","op","by","from","to"]),K1=Object.freeze(["move","setDeclared","add","remove","fork"]),js=Object.freeze(["human","maxi"]),Yr=Object.freeze({min:5,max:10}),Y1=/^clip-(\d{2})\.mp4$/;function zc(e){if(!Number.isInteger(e)||e<1||e>99)throw new Error("[record-format] a clip number is a whole number 1\u201399, got "+JSON.stringify(e)+". (FAIL-LOUD.)");return"clip-"+String(e).padStart(2,"0")+".mp4"}o(zc,"clipName");function Wp(e){return JSON.stringify(e,null,2)+`
|
|
57
|
+
`}o(Wp,"jsonText");var wy=Object.freeze({center:[3],rect:[4,6]}),J1=/^parts\/[^/]+\.js$/;function Pr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)}o(Pr,"_isPlain");function Rs(e,t){if(e===null||typeof e=="string"||typeof e=="boolean")return null;if(typeof e=="number")return Number.isFinite(e)?null:t+" is "+String(e);if(Array.isArray(e)){for(let r=0;r<e.length;r++){let i=Rs(e[r],t+"["+r+"]");if(i)return i}return null}if(Pr(e)){for(let r of Object.keys(e)){let i=Rs(e[r],t+"."+r);if(i)return i}return null}return t+" is "+(e===void 0?"undefined":typeof e=="object"?"a "+(e.constructor&&e.constructor.name||"class")+" instance":"a "+typeof e)}o(Rs,"_strictJsonFault");function qc(e,t,r){if(e==="*")return r.push(t+' is the placeholder "*"'),r;if(Array.isArray(e))return e.forEach(function(i,n){qc(i,t+"["+n+"]",r)}),r;if(e&&typeof e=="object"){if(Object.prototype.hasOwnProperty.call(e,"unavailable"))return r.push(t+" is the placeholder {unavailable}"),r;Object.keys(e).forEach(function(i){qc(e[i],t+"."+i,r)})}return r}o(qc,"_placeholders");function Gp(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&e[0].length>0&&Pr(e[1])&&!Rs(e[1],"")}o(Gp,"_isEntry");function Hp(e){if(!Pr(e))return null;let t=Object.keys(e);if(t.length!==1||!wy[t[0]])return null;let r=e[t[0]];return!Array.isArray(r)||wy[t[0]].indexOf(r.length)===-1||!r.every(function(i){return typeof i=="number"&&Number.isFinite(i)})?null:{key:t[0],length:r.length}}o(Hp,"_placement");var Q1="move carries from/to as ONE key, {center: [x, y, z]} or {rect: [4 numbers flat | 6 with a z-extent]}, the same key and length in both";function Sy(e,t){let r=[];if(!Pr(e))return[t+" is not a change {"+la.join(", ")+"}"];let i=Object.keys(e);if((i.length!==la.length||!la.every(function(n){return i.indexOf(n)!==-1}))&&r.push(t+" carries exactly {"+la.join(", ")+"}, got {"+i.join(", ")+"}"),(!Number.isInteger(e.tick)||e.tick<0)&&r.push(t+".tick is a whole tick \u2265 0, got "+JSON.stringify(e.tick)),(typeof e.name!="string"||!e.name)&&r.push(t+".name is the declared name, got "+JSON.stringify(e.name)),js.indexOf(e.by)===-1&&r.push(t+".by is one of "+js.join("|")+", got "+JSON.stringify(e.by)),["from","to"].forEach(function(n){let a=Rs(e[n],t+"."+n);a&&r.push(a+" \u2014 from/to are strict JSON")}),e.op==="move"){let n=Hp(e.from),a=Hp(e.to);!n||!a||n.key!==a.key||n.length!==a.length?r.push(t+": "+Q1+", got "+JSON.stringify([e.from,e.to])):JSON.stringify(e.from)===JSON.stringify(e.to)&&r.push(t+' is a zero move of "'+e.name+'" \u2014 an act that moved nothing writes no row')}else e.op==="setDeclared"?(!Pr(e.from)||!Pr(e.to)||!Object.keys(e.to).length||JSON.stringify(Object.keys(e.from).sort())!==JSON.stringify(Object.keys(e.to).sort()))&&r.push(t+": setDeclared carries from/to as {key: value} of the patched keys, the same keys before and after, got "+JSON.stringify([e.from,e.to])):e.op==="add"?(e.from!==null||!Gp(e.to))&&r.push(t+': add carries from: null and to: ["<registered kind name>", {props}], got '+JSON.stringify([e.from,e.to])):e.op==="remove"?(e.to!==null||!Gp(e.from))&&r.push(t+': remove carries from: ["<registered kind name>", {props}] and to: null, got '+JSON.stringify([e.from,e.to])):e.op==="fork"?typeof e.from=="string"&&e.from.length>0&&Pr(e.to)&&JSON.stringify(Object.keys(e.to).sort())==='["file","kind"]'&&typeof e.to.kind=="string"&&e.to.kind.length>0&&typeof e.to.file=="string"&&J1.test(e.to.file)||r.push(t+': fork carries from: "<source kind name>" and to: {"kind": "<new kind name>", "file": "parts/<File>.js"}, got '+JSON.stringify([e.from,e.to])):r.push(t+".op "+JSON.stringify(e.op)+" is not one of "+K1.join("|")+' (a placement is "move" whatever hand made it)');return r}o(Sy,"_rowFaults");function ky(e){return typeof e=="string"?e:new TextDecoder("utf-8",{fatal:!0}).decode(e)}o(ky,"_text");function _y(e){return e instanceof Uint8Array}o(_y,"_isBytes");function xy(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))return{fault:"the folder has no "+t};try{return{value:JSON.parse(ky(e[t]))}}catch(r){return{fault:t+" is not JSON: "+(r&&r.message||String(r))}}}o(xy,"_json");function X1(e){if(!Pr(e))return["a Record folder is a tree { path: string | Uint8Array }"];let t=[];Object.keys(e).forEach(function(l){typeof e[l]!="string"&&!_y(e[l])&&t.push(l+" is neither text nor bytes")});let r=xy(e,Ct.record);r.fault&&t.push(r.fault);let i=r.value,n=null,a=[];if(i!==void 0)if(!Pr(i))t.push(Ct.record+" is an object {"+Uc.join(", ")+"}");else{let l=Object.keys(i);(l.length!==Uc.length||!Uc.every(function(f){return l.indexOf(f)!==-1}))&&t.push(Ct.record+" carries exactly {"+Uc.join(", ")+"} (no record-level who: each change names its `by`), got {"+l.join(", ")+"}"),qc(i,Ct.record,[]).forEach(function(f){t.push(f+" \u2014 a placeholder never sits in a \xA76 field")});let c=i.tickRange;if(!Array.isArray(c)||c.length!==2||!c.every(function(f){return Number.isInteger(f)&&f>=0})||c[1]<c[0]?t.push(Ct.record+" tickRange is [first, last] whole ticks, first \u2264 last, got "+JSON.stringify(c)):n=c,Array.isArray(i.clips)?(a=i.clips,a.forEach(function(f,u){let h=zc(u+1);f!==h?t.push(Ct.record+" clips["+u+"] is "+JSON.stringify(f)+", not "+h+" (clips in the order filmed)"):(!_y(e[f])||!e[f].length)&&t.push(f+" is listed in "+Ct.record+" clips but is not in the folder as bytes")})):t.push(Ct.record+" clips is the list of clip files, got "+JSON.stringify(i.clips)),!Array.isArray(i.changes))t.push(Ct.record+" changes is the list of change rows, got "+JSON.stringify(i.changes));else{let f={},u=-1/0;i.changes.forEach(function(h,g){let d=Ct.record+" changes["+g+"]";if(Sy(h,d).forEach(function(m){t.push(m)}),!!Pr(h)&&(Number.isInteger(h.tick)&&(n&&(h.tick<n[0]||h.tick>n[1])&&t.push(d+" at tick "+h.tick+" lies outside tickRange "+JSON.stringify(n)),h.tick<u&&t.push(d+" at tick "+h.tick+" comes after a row at tick "+u+" \u2014 rows are in the order acted, so ticks only climb"),u=Math.max(u,h.tick)),h.op==="move")){let m=Hp(h.from);if(m){let b=m.key+"/"+m.length;f[h.name]&&f[h.name]!==b&&t.push(d+' moves "'+h.name+'" as {'+m.key+": "+m.length+" numbers} after a row that moved it as {"+f[h.name].replace("/",": ")+" numbers} \u2014 one part moves in the one shape of its position authority"),f[h.name]=f[h.name]||b}}})}}Object.keys(e).filter(function(l){return Y1.test(l)&&a.indexOf(l)===-1}).sort().forEach(function(l){t.push(l+" is in the folder but not listed in "+Ct.record+" clips")}),[Ct.partsBefore,Ct.partsAfter].forEach(function(l){let c=xy(e,l);if(c.fault){t.push(c.fault);return}if(!Pr(c.value)){t.push(l+' is {"<name>": ["<registered kind name>", {props}]}, got '+JSON.stringify(c.value));return}qc(c.value,l,[]).forEach(function(f){t.push(f+" \u2014 a placeholder never sits in a \xA76 field")}),Object.keys(c.value).forEach(function(f){Gp(c.value[f])||t.push(l+' "'+f+'" is not ["<registered kind name>", {props}]: '+JSON.stringify(c.value[f]))})});let s=Ct.project+tt;if(!Object.prototype.hasOwnProperty.call(e,s))t.push("project/ has no "+tt+" naming its entry (a Record snapshots a project folder)");else{let l=null;try{l=yv({[tt]:ky(e[s])})}catch(c){t.push(s+" is refused by the entry rule (link.js entryOf): "+(c&&c.message||String(c)))}l!==null&&!Object.prototype.hasOwnProperty.call(e,Ct.project+l)&&t.push("project/ has no "+l+" (the entry "+tt+" names)")}return t}o(X1,"recordFolderFaults");function Oy(e,t){if(!Pr(e))throw new TypeError("[record-format] "+t+' is { "<name>": ["<registered kind name>", {props}] }. (FAIL-LOUD.)');let r={};return Object.keys(e).forEach(function(i){let n=e[i];if(!Array.isArray(n)||n.length!==2||typeof n[0]!="string"||!n[0]||!Pr(n[1]))throw new TypeError("[record-format] "+t+' "'+i+'" is not ["<registered kind name>", {props}]. (FAIL-LOUD.)');let a=Rs(n[1],i);if(a)throw new TypeError("[record-format] "+t+": "+a+" \u2014 a Record writes props as strict JSON; declare that value as a literal in `parts`. (FAIL-LOUD.)");r[i]=[n[0],JSON.parse(JSON.stringify(n[1]))]}),r}o(Oy,"_partsValue");var Ey="film after your last change: the footage must show every change";function Ay(e){let t=e.changes,r=e.clips;if(!t.length&&!r.length)return{empty:!0};if(!r.length)throw new Error("[record-format] this Record has "+t.length+" change(s) and no clip \u2014 "+Ey+". (FAIL-LOUD.)");let i=r[r.length-1].lastTick,n=t.filter(function(u){return u.tick>i});if(n.length)throw new Error("[record-format] "+n.length+" change(s) after the last clip ends (Record tick "+i+"): "+n.map(function(u){return u.op+" "+u.name+" at tick "+u.tick}).join("; ")+" \u2014 "+Ey+". (FAIL-LOUD.)");let s={tickRange:[t.reduce(function(u,h){return Math.min(u,h.tick)},r[0].firstTick),i],clips:r.map(function(u,h){return zc(h+1)}),changes:t.map(function(u){let h={};return la.forEach(function(g){h[g]=u[g]}),h})},l=[];if(s.changes.forEach(function(u,h){l.push.apply(l,Sy(u,"changes["+h+"]"))}),l.length)throw new Error("[record-format] a change row is not strict JSON: "+l.join("; ")+" (FAIL-LOUD.)");let c={};c[Ct.record]=Wp(s),r.forEach(function(u,h){c[zc(h+1)]=u.bytes}),c[Ct.partsBefore]=Wp(Oy(e.partsBefore,Ct.partsBefore)),c[Ct.partsAfter]=Wp(Oy(e.partsAfter,Ct.partsAfter)),Object.keys(e.project).sort().forEach(function(u){c[Ct.project+u]=e.project[u]});let f=X1(c);if(f.length)throw new Error(`[record-format] the Record folder this producer wrote is not a complete \xA76 Record:
|
|
58
58
|
- `+f.join(`
|
|
59
59
|
- `)+`
|
|
60
|
-
(FAIL-LOUD.)`);return{files:u,record:s,clips:r.map(function(c,h){return{file:hu(h+1),firstTick:c.firstTick,lastTick:c.lastTick}})}}o(Xv,"serializeRecordFolder");Et();df();function Tr(e){throw new Error("[Record] "+e+" (FAIL-LOUD.)")}o(Tr,"_fail");function g1(e){for(var t=atob(e),r=new Uint8Array(t.length),n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}o(g1,"_bytesOfBase64");async function Zv(e){var t=await Xa(e),r=t.module&&t.module.parts;(!r||typeof r!="object")&&Tr("the held sketch exports no `parts` block \u2014 a Record writes parts.before/after from `export const parts`.");var n={};return Object.keys(r).forEach(function(i){var a=r[i],s=Array.isArray(a)?a[0]:null;typeof s!="function"&&Tr("parts."+i+" carries no kind class."),ka(s.name),n[i]=[s.name,a[1]]}),n}o(Zv,"_partsOf");function v1(e){return Object.assign({},e.files)}o(v1,"_heldFiles");function Wt(e){var t=this;this._exp=e,this._runner=e.runner,this._tick=0,this._rows=[],this._clips=[],this._inflight=0,this._open=!0,this._stopping=!1,this._filmArm=null,this._before=null,this._closedSettle=null,this._closedRead=!1,this._refused=null,this._closed=new Promise(function(r,n){t._closedSettle={resolve:r,reject:n}}),this._closed.then(null,function(){}),this._settled=this._closed.then(function(){},function(){}),this._onTick=function(){t._tick+=1},this._off=this._runner.addTickListener(this._onTick),hf(this._runner,this)}o(Wt,"Record");Object.defineProperty(Wt.prototype,"tick",{get:o(function(){return this._tick},"get")});function ud(e){if(e===null||typeof e!="object")return e;var t=Array.isArray(e)?e.map(ud):Object.keys(e).reduce(function(r,n){return r[n]=ud(e[n]),r},{});return Object.freeze(t)}o(ud,"_frozen");Object.defineProperty(Wt.prototype,"changes",{get:o(function(){return ud(this._rows.map(function(e){var t={};return ta.forEach(function(r){t[r]=e[r]}),t}))},"get")});Object.defineProperty(Wt.prototype,"closed",{get:o(function(){return this._closedRead=!0,this._closed},"get")});Wt.prototype._carry=function(e){var t=e instanceof Error?e:new Error(String(e));return t.record={changes:this._rows.map(function(r){return JSON.parse(JSON.stringify(r))}),clips:this._clips.map(function(r){return{firstTick:r.firstTick,lastTick:r.lastTick}})},t};Wt.prototype._ready=async function(e){return this._held=e,this._before=await Zv(e),this};Wt.requireBy=function(e,t){if(ds.indexOf(e)===-1)throw new TypeError("["+t+"] a Record is open: the act names who acted \u2014 { by: "+ds.map(function(r){return JSON.stringify(r)}).join(" | ")+" } (record-format.js BY); got "+JSON.stringify(e)+". (FAIL-LOUD.)");return e};Wt.prototype._row=function(e){this._open||Tr("this Record is closed \u2014 no row is written into it."),this._stopping&&Tr("this Record is stopping \u2014 an act during stop() belongs to the next Record."),this._rows.push({tick:this._tick,name:e.name,op:e.op,by:e.by,from:e.from,to:e.to})};Wt.prototype._clipFor=function(e){var t=this,r=Hr.min+"\u2013"+Hr.max+" s",n="film inside an open Record with rec.film({ seconds, fps, everyTicks }), or record "+r+" (frames / fps) per clip",i=null;e.stopAt.ticks!==void 0&&(i=Math.min(e.maxFrames,Math.floor(e.stopAt.ticks/e.everyTicks)+1));var a=i===null?e.maxFrames:i,s=o(function(h){return h/e.fps},"secs");(i!==null&&(s(i)<Hr.min||s(i)>Hr.max)||i===null&&s(a)<Hr.min)&&Tr("a Record is open on this runner, so this recording is one of its clips, and a clip is "+r+" long: this one is "+(i!==null?s(i):"at most "+s(a))+" s ("+a+" frames at "+e.fps+" fps) \u2014 "+n+".");var l=this._filmArm;this._filmArm=null;var u=[],f=!1;this._inflight+=1;function c(){f||(f=!0,t._inflight-=1)}return o(c,"settle"),{sample:o(function(h){if(u[h]=t._tick,l&&h===e.maxFrames-1){var g=l.onLast;l=null,g()}},"sample"),check:o(function(h){(s(h)<Hr.min||s(h)>Hr.max)&&(c(),Tr("a Record is open on this runner, so this recording is one of its clips, and a clip is "+r+" long: this one stopped at "+s(h)+" s ("+h+" frames at "+e.fps+" fps) \u2014 "+n+"."))},"check"),end:o(function(h){if(c(),!!t._open){var g=h.track.frames.length;t._clips.push({bytes:g1(h.encoded.bytes),firstTick:u[0],lastTick:u[g-1]})}},"end"),drop:o(function(){c()},"drop")}};Wt.prototype.film=function(e){var t=this;try{this._open||Tr("this Record is closed \u2014 open the next one (exp.startRecord()) to film."),(!e||typeof e!="object")&&Tr("rec.film({ seconds, fps, everyTicks, stage? })"),Object.keys(e).forEach(function(b){["seconds","fps","everyTicks","stage"].indexOf(b)===-1&&Tr('rec.film takes { seconds, fps, everyTicks, stage? }, not "'+b+'".')});var r=e.seconds,n=e.fps,i=e.everyTicks;(typeof r!="number"||!isFinite(r)||r<Hr.min)&&Tr("rec.film: seconds is at least "+Hr.min+" (CLIP_SECONDS), got "+JSON.stringify(r)+"."),(!Number.isInteger(n)||n<1)&&Tr("rec.film: fps is a whole number \u2265 1 (the playback rate), got "+JSON.stringify(n)+"."),(!Number.isInteger(i)||i<1)&&Tr("rec.film: everyTicks is a whole number \u2265 1 (the capture cadence in ticks), got "+JSON.stringify(i)+".");var a=Math.ceil(r/Hr.max),s=r*n;(!Number.isInteger(s)||s%a!==0)&&Tr("rec.film: "+r+" s at "+n+" fps is "+s+" frames, which does not split into "+a+" equal whole-frame segments of at most "+Hr.max+" s \u2014 choose seconds \xD7 fps divisible by "+a+".");var l=s/a,u={everyTicks:i,fps:n,maxFrames:l,stopAt:{ticks:(l-1)*i}};e.stage!==void 0&&(u.stage=e.stage);for(var f=Mi.attach(this._runner),c=this._clips.length,h=[],g=0;g<a;g++)(function(){var b={};b.promise=new Promise(function(y,w){b.resolve=y,b.reject=w}),h.push(b)})();var p=[],m=o(function(b){p[b]=!0,t._filmArm=b<a-1?{onLast:o(function(){m(b+1)},"onLast")}:null;var y=f.record(u);h[b].resolve(y),y.then(function(){b+1<a&&!p[b+1]&&h[b+1].reject(new Error("[Record.film] segment "+(b+1)+" of "+a+" ended without sampling its last frame, so segment "+(b+2)+" never started. (FAIL-LOUD.)"))},function(w){t._filmArm=null;for(var O=b+1;O<a;O++)p[O]||(p[O]=!0,h[O].reject(w))})},"start");return m(0),Promise.all(h.map(function(b){return b.promise})).then(function(){return t._clips.slice(c).map(function(b){return{firstTick:b.firstTick,lastTick:b.lastTick}})})}catch(b){return Promise.reject(b)}};Wt.prototype._folder=async function(e){var t=await Zv(e);return Xv({changes:this._rows.slice(),clips:this._clips.slice(),partsBefore:this._before,partsAfter:t,project:v1(e)})};Wt.prototype._detach=function(){this._open=!1,this._off&&(this._off(),this._off=null),hf(this._runner,null),this._exp._record=null};Wt.prototype.stop=async function(){var e=this,t=o(function(n){try{Tr(n)}catch(i){throw e._carry(i)}},"refuse");this._open||t("this Record is already closed"+(this._closedBy?" (closedBy: "+this._closedBy+")":"")+" \u2014 read rec.closed."),this._stopping&&t("stop() is already running."),this._inflight&&t(this._inflight+" clip(s) are still being filmed \u2014 await rec.film (or the record()) before stop()."),this._stopping=!0;var r;try{r=await this._folder(this._exp._project)}catch(n){throw this._carry(n)}finally{this._stopping=!1}return this._closedBy="stop",this._detach(),this._closedSettle.resolve(Object.assign({},r,{closedBy:"stop"})),r};Wt.prototype._closeOnReauthor=function(e){var t=this;this._closedBy="reauthor",this._detach(),this._folder(e).then(function(r){t._closedSettle.resolve(Object.assign({},r,{closedBy:"reauthor"}))},function(r){t._refused=t._carry(r),t._refused.closedBy="reauthor",t._closedSettle.reject(t._refused)})};function y1(){return wl}o(y1,"_worldInit");function b1(){var e=On();if(!e)throw new Error("[RecipeContext] no display is booted (FrqtlDisplay.name() is empty): the host boots the renderer the scene's registry row names (renderState.renderer) before the scene runs. (FAIL-LOUD.)");return e}o(b1,"_bootedRenderer");var pu="exp.createCanvas(w, h, cfg) (p5, 2D) or exp.createScene(w, h, d, cfg) (three, 3D)",w1="[RecipeContext] the scene has not created its world \u2014 its first statement is "+pu+".",ty=["canvasParentId","seed","tickHz","drawHz","stepsPerFrame","onTick","onReady","engine"],$v=ty.concat(["deferCanvas"]);function St(e){e=e||{},Object.keys(e).forEach(function(t){if($v.indexOf(t)===-1)throw new Error('[RecipeContext] unknown option "'+t+'" \u2014 the facade is SIZELESS: it takes '+$v.join(", ")+". A world size (canvasW/canvasH) or 3D-ness is the scene's, stated by "+pu+". (FAIL-LOUD.)")}),this._opts=e,this._runner=null,this._world=null,this._built=!1,this._buildFn=null,this._project=null,this._urls=null,this._parts=new Map,this._code=new Map,this._declaredOnce=!1,this._record=null,this._reauthored=null}o(St,"RecipeContext");function un(e){if(!e._world)throw new Error(w1)}o(un,"_requireWorld");Object.defineProperty(St.prototype,"world",{get:o(function(){return this._world},"get")});Object.defineProperty(St.prototype,"runner",{get:o(function(){return un(this),this._runner},"get")});Object.defineProperty(St.prototype,"universe",{get:o(function(){return un(this),this._runner.universe},"get")});Object.defineProperty(St.prototype,"is3D",{get:o(function(){return un(this),this._world.renderer==="three"},"get")});function ry(e,t,r,n,i,a,s){var l="RecipeContext."+t;if(e._world)throw new Error("["+l+"] one world per scene: this recipe already created "+JSON.stringify({renderer:e._world.renderer,w:e._world.w,h:e._world.h,d:e._world.d})+". (FAIL-LOUD.)");[["w",n],["h",i]].concat(r==="three"?[["d",a]]:[]).forEach(function(b){if(typeof b[1]!="number"||!(b[1]>0))throw new Error("["+l+"] "+b[0]+" must be a positive number (got "+JSON.stringify(b[1])+") \u2014 every scene states its whole world"+(b[0]==="d"?"; the engine's cube default is not relied on":"")+". (FAIL-LOUD.)")}),s=s||{};var u=y1();u.assertInitCfg(l+"(\u2026, cfg)",s,null);var f=b1();if(f!==r){var c=new Error("["+l+"] the scene calls "+t+" ("+r+') but the host booted "'+f+`" \u2014 the host's display (a registry row's renderState.renderer, bootScene's opts.renderer) and the scene disagree. (FAIL-LOUD.)`);throw c.frqtlRequiredRenderer=r,c.frqtlBootedRenderer=f,c}if(e._runner){var h=e._runner.canvas_rect;if(h.w!==n||h.h!==i||e._runner._depth!==(r==="three"?a:null)||e._runner._is3D!==(r==="three"))throw new Error("["+l+"] this page already holds a "+h.w+"x"+h.h+" world; a scene with a different world needs a fresh page. (FAIL-LOUD.)")}else{var g={canvasW:n,canvasH:i,is3D:r==="three"};r==="three"&&(g.canvasD=a),ty.forEach(function(b){e._opts[b]!==void 0&&(g[b]=e._opts[b])}),e._runner=new W(g),e._opts.deferCanvas||e._runner.createCanvas()}e._runner._projectUrls=e._urls;var p=e._runner.universe,m=u.initArgs(s);return r==="three"&&(m[1].activeAxes={x:!0,y:!0,z:!0},m[1].depth=a),e._runner.clearDeclared(),e._runner.beginWorld(),u.applyPreInit(s,p),p.init.apply(p,m),e._world=Object.freeze({renderer:r,w:n,h:i,d:r==="three"?a:null,cfg:Object.freeze(Object.assign({},s))}),e}o(ry,"_coinit");St.prototype.createCanvas=function(e,t,r){if(arguments.length>3)throw new Error("[RecipeContext.createCanvas] takes (w, h, cfg) \u2014 a 2D world has no depth; a 3D world is exp.createScene(w, h, d, cfg). (FAIL-LOUD.)");return ry(this,"createCanvas","p5",e,t,null,r)};St.prototype.createScene=function(e,t,r,n){return ry(this,"createScene","three",e,t,r,n)};St.prototype.init=function(){throw new Error("[RecipeContext] exp.init(cfg) is DELETED \u2014 a scene states its world, size included, with "+pu+". (FAIL-LOUD: a saved module carrying exp.init( must be re-saved.)")};Object.defineProperty(St.prototype,"initCfg",{get:o(function(){throw new Error("[RecipeContext] exp.initCfg is DELETED \u2014 read exp.world ({renderer, w, h, d, cfg}). (FAIL-LOUD.)")},"get")});St.prototype.addObject=function(e,t){un(this);var r=t&&t.x!=null?t.x:0,n=t&&t.y!=null?t.y:0,i={runner:this._runner,cw:null,x:r,y:n};return Bf.create(e,t,i)};var ey="import { <Kind> } from '@descix/frqtl-web/parts'";function ur(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(ur);var t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)return e;var r={};return Object.keys(e).forEach(function(n){r[n]=ur(e[n])}),r}o(ur,"_plain");St.prototype.declare=function(e){if(un(this),this._declaredOnce)throw new Error("[RecipeContext.declare] exp.declare(parts) runs ONCE per build \u2014 the scene's one `export const "+ea+"` block is its declared parts. (FAIL-LOUD.)");if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("[RecipeContext.declare] exp.declare(parts): parts is the sketch's `export const "+ea+" = { name: [Kind, { \u2026props }] }` object. (FAIL-LOUD.)");this._declaredOnce=!0;var t=this,r={};return Object.keys(e).forEach(function(n){var i=e[n];if(!Array.isArray(i)||i.length!==2||!i[1]||typeof i[1]!="object"||Array.isArray(i[1]))throw new TypeError("[RecipeContext.declare] parts."+n+" is not [Kind, { \u2026props }]. (FAIL-LOUD.)");var a=i[0],s=i[1];if(typeof a=="string")throw new TypeError("[RecipeContext.declare] parts."+n+' names its kind by the string "'+a+'" \u2014 in `parts` a kind is the imported class: '+ey.replace("<Kind>",a)+". (exp.addObject(name, props) still takes a string.) (FAIL-LOUD.)");if(typeof a!="function"||!Xt(a))throw new TypeError("[RecipeContext.declare] parts."+n+": "+(typeof a=="function"?"the class "+(a.name||"(anonymous)")+" is not a registered kind in this realm":"the kind is "+(a===null?"null":typeof a)+", not a registered class")+" \u2014 "+ey+", or register a forked part's renamed class (@descix/frqtl-web/kinds). (FAIL-LOUD.)");if(Object.prototype.hasOwnProperty.call(s,"name"))throw new TypeError("[RecipeContext.declare] parts."+n+" carries name "+JSON.stringify(s.name)+' \u2014 in `parts` the KEY is the name ("'+n+'"); delete the name prop. (FAIL-LOUD.)');var l=t.addObject(a,Object.assign({name:n},ur(s)));t._runner._adoptIntoParts(l),t._parts.set(l,{key:n,baseline:ln(t,l),kind:t._runner.kindOf(l)}),r[n]=l}),Object.freeze(r)};function ln(e,t){return Ke.captureProps(t,e._runner.kindOf(t))}o(ln,"_capture");function mu(e){var t=Ke.get(e),r={};return(t&&t.fields||[]).forEach(function(n){n.writeOnly!==!0&&n.type!=="readonly"&&(r[n.name]=n)}),r}o(mu,"_writable");function cd(e,t,r){var n=mu(e),i={},a=[];return Object.keys(n).forEach(function(s){var l=t[s],u=r[s];if(JSON.stringify(l)!==JSON.stringify(u)){if(u===void 0){a.push(s);return}i[s]=u}}),{props:i,lost:a}}o(cd,"_touched");var ny=W.RENAME_REFUSAL,di=o(function(e){return JSON.stringify(e)},"_JSON");function iy(e,t,r,n,i){var a=Ke.derivedReads(r);if(!a.length)return n;var s=id(e,t),l=Ke.RECT_TUPLE[4],u=Ke.RECT_TUPLE[6];return Object.keys(n).forEach(function(f){var c=n[f],h=a.filter(function(m){return m.field===f&&m.tuple===6&&s.indexOf(m.name)!==-1});if(!(!h.length||!Array.isArray(c)||c.length!==6)){var g=Array.isArray(i[f])&&i[f].length===6?i[f]:null,p=l.map(function(m){return c[u.indexOf(m)]});g&&di(p)===di(l.map(function(m){return g[u.indexOf(m)]}))?delete n[f]:n[f]=p,h.forEach(function(m){var b=c[u.indexOf(m.key)];(!g||b!==g[u.indexOf(m.key)])&&(n[m.name]=b)})}}),n}o(iy,"_spell");function _1(e,t,r){var n=r.center;if(!Array.isArray(n)||n.length!==3||n[2]!==0||id(e,t).indexOf("center")===-1)return r;var i=ad(e,t,"center"),a=i.literal?Array.isArray(i.value)?i.value.length:null:i.length;return a===2&&(r.center=[n[0],n[1]]),r}o(_1,"_spellCenter");function x1(e,t,r,n,i,a){var s=[],l=Ke.RECT_TUPLE[4],u=Ke.RECT_TUPLE[6],f=Ke.derivedReads(r),c={};Object.keys(n).forEach(function(m){var b=ad(e,t,m);c[m]=b.literal?b.value:void 0,m==="center"&&Array.isArray(c[m])&&c[m].length===2&&(c[m]=c[m].concat([0]))});function h(m,b,y){s.push({op:"set",name:t,key:m,reason:"the written text declares "+di(b)+" but the live object is "+di(y)+" \u2014 the hand is not in the text."})}o(h,"refuse");var g={};f.forEach(function(m){g[m.name]=m}),Object.keys(n).forEach(function(m){if(!g[m]){var b=a[m];Array.isArray(b)&&b.length===6&&f.some(function(y){return y.field===m})||di(c[m])!==di(b)&&h(m,c[m],b)}});var p={};return f.forEach(function(m){p[m.field]=!0}),Object.keys(p).forEach(function(m){var b=a[m];if(!(!Array.isArray(b)||b.length!==6)){var y=n[m]!==void 0||f.some(function(S){return S.field===m&&n[S.name]!==void 0});if(y){var w=Array.isArray(i[m])&&i[m].length===6?i[m].slice():null,O=c[m];Array.isArray(O)&&O.length===6?w=O.slice():Array.isArray(O)&&O.length===4&&w&&l.forEach(function(S,A){w[u.indexOf(S)]=O[A]}),f.forEach(function(S){S.field===m&&w&&c[S.name]!==void 0&&(w[u.indexOf(S.key)]=c[S.name])}),di(w)!==di(b)&&h(m,w,b)}}}),s}o(x1,"_verifyWritten");var fd="this sketch declares its parts outside `parts`; STUDIO can run it but cannot write hand edits into it \u2014 declare them in `export const parts` to make it editable.";function hd(e,t){if(!e._project)throw new Error("[RecipeContext."+t+"] this scene was not built from linked text \u2014 the writer writes the text a facade linked: exp.build(await linkProject({ files, entry, mint })) (lib/shim/project/link.js). (FAIL-LOUD.)")}o(hd,"_requireHeld");St.prototype.toSketch=async function(e){un(this),hd(this,"toSketch");var t=this._record?Wt.requireBy(e&&e.by,"RecipeContext.toSketch"):null,r=this,n=this._runner,i=n.declared,a=[],s=[],l=[],u=n._takeHandTouched();this._parts.forEach(function(b,y){if(i.indexOf(y)===-1){a.push({op:"remove",name:b.key,kind:b.kind,baseline:b.baseline});return}if(u.has(y)){var w=n.kindOf(y),O=cd(w,b.baseline,ln(r,y));if(Object.prototype.hasOwnProperty.call(O.props,"name")&&(s.push({op:"set",name:b.key,key:"name",reason:ny}),delete O.props.name),O.lost.forEach(function(A){s.push({op:"set",name:b.key,key:A,reason:'the live object no longer reports "'+A+'" \u2014 there is no value to write.'})}),Object.keys(O.props).length){var S=ur(O.props);iy(r._project.files[r._project.entry],b.key,w,O.props,b.baseline),_1(r._project.files[r._project.entry],b.key,O.props),Object.keys(O.props).length&&a.push({op:"set",name:b.key,props:O.props,obj:y,kind:w,baseline:b.baseline,raw:S})}}}),this._code.forEach(function(b,y){var w=y.name||n.kindOf(y);if(i.indexOf(y)===-1){s.push({op:"remove",name:w,reason:'"'+w+'" is declared in code: '+fd});return}if(u.has(y)){var O=cd(n.kindOf(y),b,ln(r,y));(Object.keys(O.props).length||O.lost.length)&&s.push({op:"set",name:w,reason:'"'+w+'" is declared in code: '+fd})}}),i.forEach(function(b){if(!(r._parts.has(b)||r._code.has(b))){var y=n.kindOf(b),w=Xt(y),O=ln(r,b),S=mu(y);Object.keys(O).forEach(function(A){(!S[A]||A==="name")&&delete O[A]}),a.push({op:"add",name:b.name||y,Kind:y,module:w?Wl(w.from,r._urls):null,props:O}),l.push(b)}});var f=this._project.entry,c=nd(this._project.files[f],a.map(function(b){return b.op==="set"?{op:"set",name:b.name,props:b.props}:b.op==="remove"?{op:"remove",name:b.name}:{op:"add",name:b.name,Kind:b.Kind,module:b.module,props:b.props}}),{entry:f});a.forEach(function(b){b.op==="set"&&(c.refused.some(function(y){return y.op==="set"&&y.name===b.name})||s.push.apply(s,x1(c.text,b.name,b.kind,b.props,b.baseline,ln(r,b.obj))))});var h={};c.refused.forEach(function(b){b.op==="add"&&(h[b.name]=!0)});var g=Object.assign({},this._project.files);g[f]=c.text,this._project=Object.assign({},this._project,{files:g});var p={};c.refused.forEach(function(b){b.op==="remove"&&(p[b.name]=!0)}),this._parts.forEach(function(b,y){if(i.indexOf(y)===-1){p[b.key]||r._parts.delete(y);return}b.baseline=ln(r,y)}),l.forEach(function(b){var y=b.name||n.kindOf(b);h[y]||(n._adoptIntoParts(b),r._parts.set(b,{key:y,baseline:ln(r,b),kind:n.kindOf(b)}))});var m=s.concat(c.refused);return this._record&&O1(this,a,m,t),{files:Object.assign({},g),changes:c.changes,refused:m}};function O1(e,t,r,n){var i=e._runner,a=e._record;function s(u,f){var c={},h=!1;return r.forEach(function(g){g.name!==u||g.op!==f||(g.key===void 0?h=!0:c[g.key]=!0)}),h?null:c}o(s,"refusedKeys");function l(u,f){var c=mu(u),h={};return Object.keys(f).forEach(function(g){c[g]&&g!=="name"&&(h[g]=ur(f[g]))}),h}o(l,"writableProps"),t.forEach(function(u){if(u.op==="add"){if(s(u.name,"add")===null)return;a._row({name:u.name,op:"add",by:n,from:null,to:[u.Kind,ur(u.props)]});return}if(u.op==="remove"){if(s(u.name,"remove")===null)return;a._row({name:u.name,op:"remove",by:n,from:[u.kind,l(u.kind,u.baseline)],to:null});return}var f=s(u.name,"set");if(f!==null){var c=u.raw,h=c.center!==void 0||c.rect!==void 0?i._placementAuthority(u.obj):null,g={};h&&(g[h]=!0,Ke.derivedReads(u.kind).forEach(function(S){S.field===h&&(g[S.name]=!0)}));var p=Object.keys(f).some(function(S){return g[S]});if(h&&c[h]!==void 0&&!p){var m={},b={};m[h]=ur(u.baseline[h]),b[h]=ur(c[h]),a._row({name:u.name,op:"move",by:n,from:m,to:b})}var y={},w={},O=!1;Object.keys(c).forEach(function(S){S===h||f[S]||(y[S]=u.baseline[S]===void 0?null:ur(u.baseline[S]),w[S]=ur(c[S]),O=!0)}),O&&a._row({name:u.name,op:"setDeclared",by:n,from:y,to:w})}})}o(O1,"_recordRows");function ay(e){var t=e._runner,r=t._handTouched;if(!r||!r.size)return[];var n=[];return r.forEach(function(i){if(t.declared.indexOf(i)!==-1){var a=e._parts.get(i),s=a?a.baseline:e._code.get(i);if(s){var l=cd(t.kindOf(i),s,ln(e,i));(Object.keys(l.props).length||l.lost.length)&&n.push(a?a.key:i.name||t.kindOf(i))}}}),n}o(ay,"_unwrittenHands");function E1(e){var t=e.cameraControl;if(!t||typeof t.getOrbit!="function"||!Array.isArray(t.poseFields))return null;var r=t.getOrbit()||{},n={};return t.poseFields.forEach(function(i){r[i.name]!==void 0&&(n[i.name]=ur(r[i.name]))}),n}o(E1,"_cameraPose");St.prototype.setDeclared=async function(e,t,r){un(this),hd(this,"setDeclared");var n=this._record?Wt.requireBy(r&&r.by,"RecipeContext.setDeclared"):null,i=this._runner,a=null;if(this._parts.forEach(function(C,R){C.key===e&&(a=R)}),!a||i.declared.indexOf(a)===-1)throw new Error('[RecipeContext.setDeclared] "'+e+"\" is not an object of this sketch's `parts` block"+(this._code.size?" (code declarations: "+Array.from(this._code.keys()).map(function(C){return C.name}).join(", ")+" \u2014 "+fd+")":"")+". (FAIL-LOUD.)");if(!t||typeof t!="object"||Array.isArray(t)||!Object.keys(t).length)throw new TypeError("[RecipeContext.setDeclared] patch is { <field>: value, \u2026 } with at least one field. (FAIL-LOUD.)");if(Object.prototype.hasOwnProperty.call(t,"name"))throw new TypeError('[RecipeContext.setDeclared] "name": '+ny+" (FAIL-LOUD.)");var s=ay(this);if(s.length)throw new Error('[RecipeContext.setDeclared] "'+s.join('", "')+'" carries a hand the sketch text does not hold yet \u2014 write the hand first: await exp.toSketch(). (FAIL-LOUD.)');var l=i.kindOf(a),u=mu(l),f=ln(this,a),c={};Object.keys(t).forEach(function(C){if(!u[C])throw new TypeError('[RecipeContext.setDeclared] "'+C+'" is not a writable field of '+l+" (writable: "+Object.keys(u).join(", ")+"). (FAIL-LOUD.)");try{Ke.normalizeValue(u[C],t[C],l)}catch(R){throw new TypeError('[RecipeContext.setDeclared] "'+C+'": '+String(R&&R.message||R)+" (FAIL-LOUD.)")}c[C]=f[C]===void 0?null:f[C]});var h=this._project.entry,g=iy(this._project.files[h],e,l,ur(t),f),p=nd(this._project.files[h],[{op:"set",name:e,props:g}],{entry:h});if(p.refused.length)throw new Error("[RecipeContext.setDeclared] the sketch text refused the patch: "+p.refused.map(function(C){return(C.key?C.key+": ":"")+C.reason}).join("; ")+" (FAIL-LOUD.)");var m=Object.assign({},this._project.files);m[h]=p.text,this._project=Object.assign({},this._project,{files:m});var b=E1(i),y=!!i._isLooping;await i.restart(),y||i.stop();var w=["seed"];b&&i.cameraControl&&typeof i.cameraControl.setOrbit=="function"&&(i.cameraControl.setOrbit(b),w.push("cameraPose"));var O=null;if(this._parts.forEach(function(C,R){C.key===e&&(O=R)}),!O)throw new Error('[RecipeContext.setDeclared] the re-run declared no "'+e+'" \u2014 the patched text dropped the entry. (FAIL-LOUD.)');var S=ln(this,O),A={};return Object.keys(t).forEach(function(C){A[C]=S[C]===void 0?null:ur(S[C])}),this._record&&this._record._row({name:e,op:"setDeclared",by:n,from:ur(c),to:ur(A)}),{set:e,from:c,to:A,tick:0,kept:w,files:Object.assign({},m)}};St.prototype.addTickFunction=function(e){un(this);var t=this._runner.universe.experimentTickFunctions;return t.push(e),t.length-1};St.prototype.render=function(e){return un(this),this._runner.setRenderOptions(e),this};function S1(e){var t=e._runner;t.stop();for(var r=t.universe.experimentTickFunctions,n=t.undeclaredTickFunctions(),i=t.declared.slice(),a=i.length-1;a>=0;a--)t.removeObject(i[a]);for(var s=0;s<n.length;s++){var l=r.indexOf(n[s]);l!==-1&&r.splice(l,1)}if(r.length)throw new Error("[RecipeContext.build] rebuilding on the same runner: "+r.length+" tick-function(s) of the previous scene survived its teardown ("+r.map(function(u,f){return u.name?u.name:"<anonymous #"+f+">"}).join(", ")+") \u2014 no declared part owned them and the scene did not add them (exp.addTickFunction). Host per-tick work belongs on runner.addTickListener, which survives a rebuild. (FAIL-LOUD.)")}o(S1,"_teardownSceneForRebuild");St.prototype.build=function(e){var t=null;if(e&&typeof e=="object"&&typeof e.buildExperiment=="function"){if(!e.project||typeof e.project!="object"||!e.project.files||typeof e.project.entry!="string")throw new TypeError("[RecipeContext.build] build(linked): linked is linkProject's result (its contract: lib/shim/project/link.js). (FAIL-LOUD.)");t=e,e=t.buildExperiment}else if(e!=null&&typeof e!="function")throw new TypeError("[RecipeContext.build] build(sketch): sketch is the scene's buildExperiment(exp) function or linkProject's result (got "+typeof e+"). (FAIL-LOUD.)");if(typeof e=="function"){if(this._record&&!(t&&this._project&&k1(t.project.files,this._project.files))&&(this._reauthored=this._record,this._record._closeOnReauthor(this._project)),this._buildFn=e,this._project=t?t.project:null,this._urls=t&&t.urls||null,this._runner&&S1(this),this._world=null,this._parts=new Map,this._code=new Map,this._declaredOnce=!1,e(this),!this._world)throw new Error("[RecipeContext.build] the scene never created its world \u2014 its first statement must be "+pu+". (FAIL-LOUD.)");this._built=!0;var r=this;this._runner.declared.forEach(function(n){r._parts.has(n)||r._code.set(n,ln(r,n))}),this._runner.retainSceneReplay(this._project?function(){return Xa(r._project).then(function(n){return r.build(n)})}:function(){return r.build(r._buildFn)})}return sy(this),this};function k1(e,t){var r=Object.keys(e),n=Object.keys(t);return r.length!==n.length?!1:r.every(function(i){return Object.prototype.hasOwnProperty.call(t,i)&&e[i]===t[i]})}o(k1,"_sameFiles");St.prototype.startRecord=async function(){if(un(this),hd(this,"startRecord"),this._record)throw new Error("[RecipeContext.startRecord] a Record is already open on this facade (one per booted world) \u2014 await rec.stop() first. (FAIL-LOUD.)");var e=this._reauthored;if(e){if(await e._settled,e._refused&&!e._closedRead){var t=new Error("[RecipeContext.startRecord] the previous Record of this facade was closed by a re-authoring and REFUSED ("+e._refused.message+") \u2014 nobody read rec.closed, so its "+e._refused.record.changes.length+" row(s) would be lost: read rec.closed (its rejection carries err.record = { changes, clips }) first. (FAIL-LOUD.)");throw t.record=e._refused.record,t}this._reauthored=null}if(Mo(this._runner))throw new Error("[RecipeContext.startRecord] another facade holds an open Record on this runner. (FAIL-LOUD.)");if(!Object.prototype.hasOwnProperty.call(this._project.files,tt))throw new Error("[RecipeContext.startRecord] a Record snapshots a folder; boot it as one \u2014 the held project carries no "+tt+": add files['"+tt+"'] = serializeManifest(manifestFor({ name, entry: SKETCH_ENTRY })) (all from ./project) to the files you boot. (FAIL-LOUD.)");var r=ay(this);if(r.length)throw new Error('[RecipeContext.startRecord] "'+r.join('", "')+'" carries a hand the sketch text does not hold yet \u2014 write the hand first: await exp.toSketch(). (FAIL-LOUD.)');var n=new Wt(this);this._record=n;try{await n._ready(this._project)}catch(i){throw n._detach(),i}return n};St.prototype.run=function(e){e&&typeof e=="function"&&!this._built&&this.build(e),un(this),sy(this),this._runner.start()};["INIT_CFG","assertInitCfg","initArgs"].forEach(function(e){Object.defineProperty(St,e,{get:o(function(){throw new Error("RecipeContext."+e+" does not exist: the world-cfg contract is FrqtlWorldInit."+e+" (objects/setup/_worldInit.js).")},"get")})});var A1=Object.freeze({buildSource:'[RecipeContext] exp.buildSource(src) is retired \u2014 a sketch held as text is a project: boot it with bootProject(mount, { files: { "sketch.js": src }, entry: "sketch.js" }) (@descix/frqtl-web/boot), or re-scene a booted facade with exp.build(await linkProject({ files, entry, mint })) (lib/shim/project/link.js). (FAIL-LOUD.)'});Fl(St.prototype,A1);var oy=null;function sy(e){if(!(e instanceof St))throw new TypeError("[RecipeContext] setPageExperiment(exp): expected a RecipeContext. (FAIL-LOUD.)");oy=e}o(sy,"setPageExperiment");function ly(){return oy}o(ly,"pageExperiment");Ra();Na();var T1=Object.freeze({AbsorbRadiation:"import * as AbsorbRadiation from its module, lib/frqtl/objects/objects/absorbRadiation.js",AstSchema:"import * as AstSchema from its module, lib/shim/expr/ast-schema.js",BOUNCE_DIRECTIONS:"import { BOUNCE_DIRECTIONS } from its module, lib/frqtl/objects/constants/WallBehaviors.js",Box:"import { Box } from its module, lib/frqtl/objects/objects/Box.js",Bullet:"import { Bullet } from its module, lib/frqtl/objects/objects/Bullet.js",Camera2dGeometry:"import * as Camera2dGeometry from its module, lib/frqtl/compat/renderer/camera2d-geometry.js",CameraControls:"import { CameraControls } from '@descix/frqtl-web/parts'",CameraPath:"import { CameraPath } from '@descix/frqtl-web/parts'",CaptureEnvelope:"import * as CaptureEnvelope from its module, lib/shim/render/capture-envelope.js",CaptureStillCommon:"import * as CaptureStillCommon from its module, lib/frqtl/compat/renderer/captureStill-common.js",Charge:"read the engine at call time: engine().Charge (lib/frqtl/compat/engine.js)",CircuitGate:"import { CircuitGate } from its module, lib/frqtl/objects/objects/CircuitGate.js",CircuitProbe:"import { CircuitProbe } from its module, lib/frqtl/objects/objects/CircuitProbe.js",CollisionActions:"import { CollisionActions } from '@descix/frqtl-web/parts'",CollisionTypes:"import { CollisionTypes } from '@descix/frqtl-web/parts'",ControlAction:"import { ControlAction } from its module, lib/frqtl/objects/objects/controlAction.js",ControlBind:"import { ControlBind } from its module, lib/frqtl/objects/objects/controlBind.js",ControlRegistry:"import * as ControlRegistry from '@descix/frqtl-web/shim/controls/registry.js'",ControlsSchema:"import * as ControlsSchema from its module, lib/shim/controls/index.js",DataCollector:"import { DataCollector } from its module, lib/frqtl/objects/collectors/DataCollector.js",DetectorWall:"import { DetectorWall } from '@descix/frqtl-web/parts'",DirectedRedirectProgram:"import * as DirectedRedirectProgram from its module, lib/frqtl/objects/objects/directedRedirectProgram.js",DirectedTunnel:"import { DirectedTunnel } from its module, lib/frqtl/objects/objects/DirectedTunnel.js",EGPTUniverse:"read the engine at call time: engine().EGPTUniverse (lib/frqtl/compat/engine.js)",EgptFractal:"import { EgptFractal } from its module, lib/frqtl/objects/objects/EgptFractal.js",EmitterProgram:"import * as EmitterProgram from its module, lib/frqtl/objects/objects/emitterProgram.js",EngineScopeDescriptors:"import * as EngineScopeDescriptors from its module, lib/frqtl/objects/schema/engine-scopes.js",ExperimentMetrics:"import { ExperimentMetrics } from its module, lib/frqtl/experiments/_shared/experiment-metrics.js",FieldBuilder:"import { FieldBuilder } from its module, lib/frqtl/compat/renderer/FieldBuilder.js",FieldDescriptorSchema:"import * as FieldDescriptorSchema from its module, lib/shim/field-descriptor/index.js",Filters:"import { Filters } from its module, lib/frqtl/compat/renderer/Filters.js",Frame:"read the engine at call time: engine().Frame (lib/frqtl/compat/engine.js)",FrameData:"read the engine at call time: engine().FrameData (lib/frqtl/compat/engine.js)",FrameDataSchema:"import * as FrameDataSchema from its module, lib/shim/frame-data/index.js",FrqtlApp:"import { FrqtlApp } from its module, lib/frqtl/objects/FrqtlApp.js",FrqtlCapture:"import { FrqtlCapture } from its module, lib/frqtl/objects/instruments/capture.js",FrqtlCaptureHost:"import { FrqtlCaptureHost } from its module, lib/frqtl/objects/instruments/capture-host.js",FrqtlControlOverlay:"import { FrqtlControlOverlay } from '@descix/frqtl-web/parts'",FrqtlControlSlider:"import { FrqtlControlSlider } from its module, lib/frqtl/objects/objects/frqtl-control-slider.js",FrqtlControlSync:"import { FrqtlControlSync } from its module, lib/frqtl/objects/objects/frqtl-control-sync.js",FrqtlControlWidgets:"import { FrqtlControlWidgets } from its module, lib/frqtl/objects/objects/frqtl-control-widgets.js",FrqtlControlWriteQueue:"import { FrqtlControlWriteQueue } from its module, lib/frqtl/objects/objects/frqtl-control-write-queue.js",FrqtlControlsPanel:"import { FrqtlControlsPanel } from '@descix/frqtl-web/parts'",FrqtlDisplay:"import * as FrqtlDisplay from '@descix/frqtl-web/compat/renderer/display-slot.js'",FrqtlHostedEyes:"import { FrqtlHostedEyes } from its module, lib/frqtl/objects/instruments/hosted-eyes.js",FrqtlVision:"import { FrqtlVision } from '@descix/frqtl-web/parts'",FrqtlWorldInit:"import { FrqtlWorldInit } from its module, lib/frqtl/objects/setup/_worldInit.js",GodraysLayer:"import * as GodraysLayer from its module, lib/frqtl/compat/renderer/providers/godrays-layer.js",GraphingDetectorWall:"import { GraphingDetectorWall } from '@descix/frqtl-web/parts'",HeatColormap:"import * as HeatColormap from its module, lib/shim/render/heat-colormap.js",InterferenceAnalysis:"import { InterferenceAnalysis } from its module, lib/frqtl/experiments/_shared/interference-analysis.js",LargeObject:"import { LargeObject } from '@descix/frqtl-web/parts'",LightColor:"import { LightColor } from '@descix/frqtl-web/parts'",LightSource:"import { LightSource } from its module, lib/frqtl/objects/objects/LightSource.js",LoDrawnCenter:"import * as LoDrawnCenter from its module, lib/frqtl/compat/renderer/lo-drawn-center.js",LogicGate:"import { LogicGate } from '@descix/frqtl-web/parts'",MakeControlsForObject:"import { MakeControlsForObject } from its module, lib/frqtl/objects/objects/makeControlsForObject.js",MakeControlsForRenderSurface:"import { MakeControlsForRenderSurface } from its module, lib/frqtl/objects/objects/makeControlsForRenderSurface.js",ObjectFactory:"import { ObjectFactory } from its module, lib/frqtl/objects/ObjectFactory.js",ObjectSchema:"import { ObjectSchema } from its module, lib/frqtl/objects/schema/index.js",ObjectValueNormalizer:"import * as ObjectValueNormalizer from its module, lib/frqtl/objects/schema/valueNormalizer.js",OrbitBag:"import * as OrbitBag from '@descix/frqtl-web/compat/renderer/orbit-bag.js'",OvenBox:"import { OvenBox } from '@descix/frqtl-web/parts'",PLACEABLE_KINDS:"read ObjectSchema.placeableCatalog() (lib/frqtl/objects/schema/index.js)",PUBLIC_PARTS:"the parts directory is the roster \u2014 import * as parts from '@descix/frqtl-web/parts'",PageParams:"import * as PageParams from its module, lib/shim/page-params/index.js",PointSource:"import { PointSource } from '@descix/frqtl-web/parts'",QuantumEmitter:"import { QuantumEmitter } from its module, lib/frqtl/objects/objects/QuantumEmitter.js",RENDERER_PROVIDER_OPTIONAL:"import { RENDERER_PROVIDER_OPTIONAL } from its module, lib/frqtl/compat/renderer/renderer-provider-contract.js",RENDERER_PROVIDER_REQUIRED:"import { RENDERER_PROVIDER_REQUIRED } from its module, lib/frqtl/compat/renderer/renderer-provider-contract.js",RadiationHistogram:"import { RadiationHistogram } from its module, lib/frqtl/experiments/_shared/radiation-histogram.js",RecipeContext:"import { RecipeContext } from its module, lib/frqtl/objects/RecipeContext.js",Rectangle:"import { Rectangle } from '@descix/frqtl-web/parts'",RenderCapabilitiesCommon:"import * as RenderCapabilitiesCommon from its module, lib/frqtl/compat/renderer/renderCapabilities-common.js",RenderFamily:"import { RenderFamily } from its module, lib/frqtl/compat/renderer/RenderFamily.js",RenderMesh:"import { RenderMesh } from its module, lib/frqtl/compat/renderer/RenderMesh.js",RenderShape:"import { RenderShape } from its module, lib/frqtl/compat/renderer/RenderShape.js",RenderStages:"import * as RenderStages from its module, lib/shim/render/render-stages.js",RenderState:"import * as RenderState from its module, lib/shim/render-state/apply.js",RendererProviderContract:"import * as RendererProviderContract from its module, lib/frqtl/compat/renderer/renderer-provider-contract.js",ShimRpc:"import * as ShimRpc from its module, lib/shim/rpc/index.js",SlabFace:"import * as SlabFace from its module, lib/frqtl/objects/geometry/SlabFace.js",SlitLightSource:"import { SlitLightSource } from '@descix/frqtl-web/parts'",SlitLinerScatter:"import * as SlitLinerScatter from its module, lib/frqtl/objects/objects/slitLinerScatter.js",SlitScreen:"import { SlitScreen } from '@descix/frqtl-web/parts'",SphereEmitter:"import { SphereEmitter } from '@descix/frqtl-web/parts'",SunLook:"import * as SunLook from '@descix/frqtl-web/shim/render/sun-look.js'",SustainedSource:"import * as SustainedSource from its module, lib/frqtl/objects/objects/sustainedSource.js",Tagger:"import * as Tagger from its module, lib/frqtl/objects/objects/tagger.js",ThreeCameraContract:"import * as ThreeCameraContract from its module, lib/frqtl/compat/renderer/providers/three-camera-contract.js",ThreeCameraGeometry:"import * as ThreeCameraGeometry from its module, lib/frqtl/compat/renderer/providers/three-camera-geometry.js",TickData:"read the engine at call time: engine().TickData (lib/frqtl/compat/engine.js)",Trace:"import { Trace } from '@descix/frqtl-web/parts'",Tube:"import { Tube } from its module, lib/frqtl/objects/objects/Tube.js",Tunnel:"import { Tunnel } from '@descix/frqtl-web/parts'",UnprojectStill:"import * as UnprojectStill from its module, lib/frqtl/compat/renderer/unprojectStill.js",WALL_BEHAVIORS:"import { WALL_BEHAVIORS } from its module, lib/frqtl/objects/constants/WallBehaviors.js",WALL_HOOKS:"import { WALL_HOOKS } from its module, lib/frqtl/objects/constants/WallBehaviors.js",WALL_PRESETS:"import { WALL_PRESETS } from its module, lib/frqtl/objects/constants/WallBehaviors.js",Wall:"import { Wall } from '@descix/frqtl-web/parts'",_WasmLoadBrowser:"import { loadedWasmSha256 } from lib/frqtl/compat/providers/wasm-load-browser.js",_egptEngine:"import { engineState } from lib/frqtl/compat/engine.js",_egptExperiment:"read the page door: FrqtlPage.experiment",_egptFailLoud:"import { paintBootFailure } from lib/frqtl/experiments/_shared/boot-failure.js",_egptRenderer:"read the display slot (lib/frqtl/compat/renderer/display-slot.js name()), or <html data-frqtl-renderer> from outside the realm",_egptRendererFailLoud:"import { paintBootFailure } from lib/frqtl/experiments/_shared/boot-failure.js",_egptRendererProviders:"import { RENDERER_PROVIDERS } from lib/frqtl/compat/renderer/providers/index.js",_egptResolveFrqtl:"a module locates a sibling file with new URL(rel, import.meta.url)",_frqtlApp:"read the page door: FrqtlPage.runner",_frqtlControlsRegistry:"read the page door: FrqtlPage.controls",_frqtlHostedRecordings:"the capture-host KIND keeps its ledger as module state (lib/frqtl/objects/instruments/capture-host.js parkedRecording)",applyProgramTrigger:"import { applyProgramTrigger } from its module, lib/frqtl/objects/objects/actionCompiler.js",assertSetupOptions:"import { assertSetupOptions } from its module, lib/frqtl/objects/setup/_setupOptions.js",bounceDirectionValuesMap:"import { bounceDirectionValuesMap } from its module, lib/frqtl/objects/constants/WallBehaviors.js",buildAbsorbRadiationTickFn:"import { buildAbsorbRadiationTickFn } from its module, lib/frqtl/objects/objects/absorbRadiation.js",buildAngledReflectOps:"import { buildAngledReflectOps } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildConstrainedRandomOps:"import { buildConstrainedRandomOps } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildDecoherenceOps:"import { buildDecoherenceOps } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildEjectOps:"import { buildEjectOps } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildExperiment:"a sketch is an ES module \u2014 export default function buildExperiment(exp)",buildFaceExitEjectOps:"import { buildFaceExitEjectOps } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildIncidenceReflectOps:"import { buildIncidenceReflectOps } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildIncidenceReflectOps3D:"import { buildIncidenceReflectOps3D } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildOmniRandomOps:"import { buildOmniRandomOps } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildReflectOps:"import { buildReflectOps } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildSwapReflectOps:"import { buildSwapReflectOps } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildTiltedReflectGuardTrigger:"import { buildTiltedReflectGuardTrigger } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildTriggerExpr:"import { buildTriggerExpr } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildVelocityFlipOp:"import { buildVelocityFlipOp } from its module, lib/frqtl/objects/objects/actionCompiler.js",collisionMatrixLanes:"import { collisionMatrixLanes } from '@descix/frqtl-web/objects/setup/_collisionMatrixLanes.js'",compileActions:"import { compileActions } from its module, lib/frqtl/objects/objects/actionCompiler.js",compileWallV2:"import { compileWallV2 } from its module, lib/frqtl/objects/objects/actionCompiler.js",draw:"p5 global mode's draw hook \u2014 written by compat/vendor.js suppressP5Draw",expandWallPreset:"import { expandWallPreset } from its module, lib/frqtl/objects/constants/WallBehaviors.js",mapCharge:"deleted \u2014 the engine's Charge (engine().Charge) is the one charge vocabulary (lib/frqtl/compat/providers/wasm-engine.js)",requireWorldRect:"import { requireWorldRect } from its module, lib/frqtl/objects/setup/_setupOptions.js",resolveSlabFace:"import { resolveSlabFace } from its module, lib/frqtl/objects/geometry/SlabFace.js",resolveWallSpec:"import { resolveWallSpec } from its module, lib/frqtl/objects/constants/WallBehaviors.js",setup:"p5 global mode's setup hook \u2014 written by compat/vendor.js runSketch (bootPage({ setup }))",setupBlackbodySubstrate:"import { setupBlackbodySubstrate } from its module, lib/frqtl/objects/setup/setupBlackbodySubstrate.js",setupCircuitBasic:"import { setupCircuitBasic } from its module, lib/frqtl/objects/setup/setupCircuitBasic.js",setupCollisionMatrix:"import { setupCollisionMatrix } from its module, lib/frqtl/objects/setup/setupCollisionMatrix.js",setupConeEmitter3D:"import { setupConeEmitter3D } from its module, lib/frqtl/objects/setup/setupConeEmitter3D.js",setupDoubleSlit:"import { setupDoubleSlit } from its module, lib/frqtl/objects/setup/setupDoubleSlit.js",setupDoubleSlit_Laser:"import { setupDoubleSlit_Laser } from its module, lib/frqtl/objects/setup/setupDoubleSlit_Laser.js",setupEmpty:"import { setupEmpty } from its module, lib/frqtl/objects/setup/setupEmpty.js",setupFxSmoke:"import { setupFxSmoke } from its module, lib/frqtl/objects/setup/setupFxSmoke.js",setupG1Race:"import { setupG1Race } from its module, lib/frqtl/objects/setup/setupG1Race.js",setupG2Sweep:"import { setupG2Sweep } from its module, lib/frqtl/objects/setup/setupG2Sweep.js",setupG3Collide:"import { setupG3Collide } from its module, lib/frqtl/objects/setup/setupG3Collide.js",setupLightSourceLab:"import { setupLightSourceLab } from its module, lib/frqtl/objects/setup/setupLightSourceLab.js",setupOscillator:"import { setupOscillator } from its module, lib/frqtl/objects/setup/setupOscillator.js",setupParticleWalk:"import { setupParticleWalk } from its module, lib/frqtl/objects/setup/setupParticleWalk.js",setupParticleWalk3D:"import { setupParticleWalk3D } from its module, lib/frqtl/objects/setup/setupParticleWalk3D.js",setupSphereEmitter3D:"import { setupSphereEmitter3D } from its module, lib/frqtl/objects/setup/setupSphereEmitter3D.js",setupTraceCircuit:"import { setupTraceCircuit } from its module, lib/frqtl/objects/setup/setupTraceCircuit.js",setupTunnelLab:"import { setupTunnelLab } from its module, lib/frqtl/objects/setup/setupTunnelLab.js",setupTunnelPointExit:"import { setupTunnelPointExit } from its module, lib/frqtl/objects/setup/setupTunnelPointExit.js",setupWaveInterference:"import { setupWaveInterference } from its module, lib/frqtl/objects/setup/setupWaveInterference.js",validateRendererProvider:"import { validateRendererProvider } from its module, lib/frqtl/compat/renderer/renderer-provider-contract.js",wallBehaviorV2ValuesMap:"import { wallBehaviorV2ValuesMap } from its module, lib/frqtl/objects/constants/WallBehaviors.js",wallHookValuesMap:"import { wallHookValuesMap } from its module, lib/frqtl/objects/constants/WallBehaviors.js"});var C1=Object.freeze([Object.freeze({key:"runner",kind:"owner",replaces:"_frqtlApp",read:qg,why:"the runner the page drives (objects/FrqtlApp.js pageRunner)"}),Object.freeze({key:"experiment",kind:"owner",replaces:"_egptExperiment",read:ly,why:"the recipe facade the page builds through (objects/RecipeContext.js pageExperiment)"}),Object.freeze({key:"controls",kind:"owner",replaces:"_frqtlControlsRegistry",read:o(function(){return wn.exposedRegistry()},"read"),why:"the control registry the page exposed (parts/FrqtlControlsPanel.js exposedRegistry)"}),Object.freeze({key:"isReady",kind:"page",why:"the empty page: a host may apply a scene now"}),Object.freeze({key:"applyModuleSource",kind:"page",why:"the empty page: apply a sketch held as text"}),Object.freeze({key:"applyRenderState",kind:"page",why:"the empty page: apply a renderState bag"}),Object.freeze({key:"displayResolution",kind:"page",why:"the empty page: the renderer the scene requires vs booted"})]);var dd=null;function uy(){if(dd)return dd;if(typeof document>"u")throw new Error("[page-door] installPageDoor: the page door is a PAGE's \u2014 this realm has no document. (FAIL-LOUD.)");let e={};for(let t of C1)t.kind==="owner"&&Object.defineProperty(e,t.key,{enumerable:!0,get:t.read});return dd=e,window.FrqtlPage=e,e}o(uy,"installPageDoor");function R1(e,t){if(!e||!e.documentElement||typeof e.documentElement.setAttribute!="function")throw new TypeError("[boot] createBootRecord(doc, ids): doc must be a Document");if(typeof e.dispatchEvent!="function")throw new TypeError("[boot] createBootRecord: the document has no dispatchEvent \u2014 the "+Dh+" event is half of the published boot record");if(!Array.isArray(t)||t.length===0)throw new TypeError("[boot] createBootRecord: phaseIds must be a non-empty array (lib/shim/engine/boot-phases.js)");let r=Object.create(null);t.forEach(function(f){if(typeof f!="string"||!f||r[f])throw new TypeError("[boot] createBootRecord: phase ids must be unique non-empty strings (got "+JSON.stringify(f)+")");r[f]={done:0,total:0,complete:!1}});let n=null;function i(f){if(!r[f])throw new Error('[boot] boot record: "'+f+'" is not a boot phase \u2014 '+t.join(", ")+" (lib/shim/engine/boot-phases.js).");return r[f]}o(i,"phase");function a(){for(let f=0;f<t.length;f++)if(!r[t[f]].complete)return t[f];return t[t.length-1]}o(a,"current");function s(){let f={};t.forEach(function(h){let g=r[h];f[h]={done:g.done,total:g.total,complete:g.complete}});let c=a();return{phase:c,done:r[c].done,total:r[c].total,phases:f,failed:n}}o(s,"snapshot");function l(f,c){let h=f.ownerDocument?f.ownerDocument.defaultView:f.defaultView||null,g=h&&h.CustomEvent||CustomEvent;f.dispatchEvent(new g(Dh,{detail:c}))}o(l,"dispatch");function u(){let f=s(),c=e.documentElement;c.setAttribute("data-egpt-boot-phase",f.phase),c.setAttribute("data-egpt-boot-done",String(f.done)),c.setAttribute("data-egpt-boot-total",String(f.total)),c.setAttribute("data-egpt-boot-progress",JSON.stringify(f.phases)),n&&c.setAttribute("data-egpt-boot-failed",n),l(e,f);let h=null;try{h=e.defaultView?e.defaultView.frameElement:null}catch{h=null}return h&&typeof h.dispatchEvent=="function"&&l(h,s()),f}return o(u,"publish"),{begin:o(function(f,c){let h=i(f);if(typeof c!="number"||c<0||Math.floor(c)!==c)throw new TypeError('[boot] boot record: begin("'+f+'", total) needs a non-negative integer');return h.total=c,u()},"begin"),step:o(function(f){let c=i(f);if(c.done>=c.total)throw new Error('[boot] boot record: "'+f+'" stepped past its total '+c.total);return c.done++,u()},"step"),complete:o(function(f){let c=i(f);return c.done=c.total,c.complete=!0,u()},"complete"),fail:o(function(f){return i(f),n||(n=f),u()},"fail"),snapshot:s}}o(R1,"createBootRecord");function pd(e){return String(e&&e.message?e.message:e)}o(pd,"_detail");function D1(e,t){return"ENGINE BOOT FAILED \u2014 engine="+e+`
|
|
60
|
+
(FAIL-LOUD.)`);return{files:c,record:s,clips:r.map(function(u,h){return{file:zc(h+1),firstTick:u.firstTick,lastTick:u.lastTick}})}}o(Ay,"serializeRecordFolder");xt();Vf();function Cr(e){throw new Error("[Record] "+e+" (FAIL-LOUD.)")}o(Cr,"_fail");function Z1(e){for(var t=atob(e),r=new Uint8Array(t.length),i=0;i<t.length;i++)r[i]=t.charCodeAt(i);return r}o(Z1,"_bytesOfBase64");async function Ty(e){var t=await ao(e),r=t.module&&t.module.parts;(!r||typeof r!="object")&&Cr("the held sketch exports no `parts` block \u2014 a Record writes parts.before/after from `export const parts`.");var i={};return Object.keys(r).forEach(function(n){var a=r[n],s=Array.isArray(a)?a[0]:null;typeof s!="function"&&Cr("parts."+n+" carries no kind class."),ja(s.name),i[n]=[s.name,a[1]]}),i}o(Ty,"_partsOf");function $1(e){return Object.assign({},e.files)}o($1,"_heldFiles");function Ut(e){var t=this;this._exp=e,this._runner=e.runner,this._tick=0,this._rows=[],this._clips=[],this._inflight=0,this._open=!0,this._stopping=!1,this._filmArm=null,this._before=null,this._closedSettle=null,this._closedRead=!1,this._refused=null,this._closed=new Promise(function(r,i){t._closedSettle={resolve:r,reject:i}}),this._closed.then(null,function(){}),this._settled=this._closed.then(function(){},function(){}),this._onTick=function(){t._tick+=1},this._off=this._runner.addTickListener(this._onTick),qf(this._runner,this)}o(Ut,"Record");Object.defineProperty(Ut.prototype,"tick",{get:o(function(){return this._tick},"get")});function Kp(e){if(e===null||typeof e!="object")return e;var t=Array.isArray(e)?e.map(Kp):Object.keys(e).reduce(function(r,i){return r[i]=Kp(e[i]),r},{});return Object.freeze(t)}o(Kp,"_frozen");Object.defineProperty(Ut.prototype,"changes",{get:o(function(){return Kp(this._rows.map(function(e){var t={};return la.forEach(function(r){t[r]=e[r]}),t}))},"get")});Object.defineProperty(Ut.prototype,"closed",{get:o(function(){return this._closedRead=!0,this._closed},"get")});Ut.prototype._carry=function(e){var t=e instanceof Error?e:new Error(String(e));return t.record={changes:this._rows.map(function(r){return JSON.parse(JSON.stringify(r))}),clips:this._clips.map(function(r){return{firstTick:r.firstTick,lastTick:r.lastTick}})},t};Ut.prototype._ready=async function(e){return this._held=e,this._before=await Ty(e),this};Ut.requireBy=function(e,t){if(js.indexOf(e)===-1)throw new TypeError("["+t+"] a Record is open: the act names who acted \u2014 { by: "+js.map(function(r){return JSON.stringify(r)}).join(" | ")+" } (record-format.js BY); got "+JSON.stringify(e)+". (FAIL-LOUD.)");return e};Ut.prototype._admit=function(e){var t=e?e+": ":"";this._open||Cr(t+"this Record is closed \u2014 no row is written into it."),this._stopping&&Cr(t+"this Record is stopping \u2014 an act during stop() belongs to the next Record.")};Ut.prototype._row=function(e){this._admit(),this._rows.push({tick:this._tick,name:e.name,op:e.op,by:e.by,from:e.from,to:e.to})};Ut.prototype._clipFor=function(e){var t=this,r=Yr.min+"\u2013"+Yr.max+" s",i="film inside an open Record with rec.film({ seconds, fps, everyTicks }), or record "+r+" (frames / fps) per clip",n=null;e.stopAt.ticks!==void 0&&(n=Math.min(e.maxFrames,Math.floor(e.stopAt.ticks/e.everyTicks)+1));var a=n===null?e.maxFrames:n,s=o(function(h){return h/e.fps},"secs");(n!==null&&(s(n)<Yr.min||s(n)>Yr.max)||n===null&&s(a)<Yr.min)&&Cr("a Record is open on this runner, so this recording is one of its clips, and a clip is "+r+" long: this one is "+(n!==null?s(n):"at most "+s(a))+" s ("+a+" frames at "+e.fps+" fps) \u2014 "+i+".");var l=this._filmArm;this._filmArm=null;var c=[],f=!1;this._inflight+=1;function u(){f||(f=!0,t._inflight-=1)}return o(u,"settle"),{sample:o(function(h){if(c[h]=t._tick,l&&h===e.maxFrames-1){var g=l.onLast;l=null,g()}},"sample"),check:o(function(h){(s(h)<Yr.min||s(h)>Yr.max)&&(u(),Cr("a Record is open on this runner, so this recording is one of its clips, and a clip is "+r+" long: this one stopped at "+s(h)+" s ("+h+" frames at "+e.fps+" fps) \u2014 "+i+"."))},"check"),end:o(function(h){if(u(),!!t._open){var g=h.track.frames.length;t._clips.push({bytes:Z1(h.encoded.bytes),firstTick:c[0],lastTick:c[g-1]})}},"end"),drop:o(function(){u()},"drop")}};Ut.prototype.film=function(e){var t=this;try{this._open||Cr("this Record is closed \u2014 open the next one (exp.startRecord()) to film."),(!e||typeof e!="object")&&Cr("rec.film({ seconds, fps, everyTicks, stage? })"),Object.keys(e).forEach(function(b){["seconds","fps","everyTicks","stage"].indexOf(b)===-1&&Cr('rec.film takes { seconds, fps, everyTicks, stage? }, not "'+b+'".')});var r=e.seconds,i=e.fps,n=e.everyTicks;(typeof r!="number"||!isFinite(r)||r<Yr.min)&&Cr("rec.film: seconds is at least "+Yr.min+" (CLIP_SECONDS), got "+JSON.stringify(r)+"."),(!Number.isInteger(i)||i<1)&&Cr("rec.film: fps is a whole number \u2265 1 (the playback rate), got "+JSON.stringify(i)+"."),(!Number.isInteger(n)||n<1)&&Cr("rec.film: everyTicks is a whole number \u2265 1 (the capture cadence in ticks), got "+JSON.stringify(n)+".");var a=Math.ceil(r/Yr.max),s=r*i;(!Number.isInteger(s)||s%a!==0)&&Cr("rec.film: "+r+" s at "+i+" fps is "+s+" frames, which does not split into "+a+" equal whole-frame segments of at most "+Yr.max+" s \u2014 choose seconds \xD7 fps divisible by "+a+".");var l=s/a,c={everyTicks:n,fps:i,maxFrames:l,stopAt:{ticks:(l-1)*n}};e.stage!==void 0&&(c.stage=e.stage);for(var f=Kn.attach(this._runner),u=this._clips.length,h=[],g=0;g<a;g++)(function(){var b={};b.promise=new Promise(function(y,w){b.resolve=y,b.reject=w}),h.push(b)})();var d=[],m=o(function(b){d[b]=!0,t._filmArm=b<a-1?{onLast:o(function(){m(b+1)},"onLast")}:null;var y=f.record(c);h[b].resolve(y),y.then(function(){b+1<a&&!d[b+1]&&h[b+1].reject(new Error("[Record.film] segment "+(b+1)+" of "+a+" ended without sampling its last frame, so segment "+(b+2)+" never started. (FAIL-LOUD.)"))},function(w){t._filmArm=null;for(var x=b+1;x<a;x++)d[x]||(d[x]=!0,h[x].reject(w))})},"start");return m(0),Promise.all(h.map(function(b){return b.promise})).then(function(){return t._clips.slice(u).map(function(b){return{firstTick:b.firstTick,lastTick:b.lastTick}})})}catch(b){return Promise.reject(b)}};Ut.prototype._folder=async function(e){var t=await Ty(e);return Ay({changes:this._rows.slice(),clips:this._clips.slice(),partsBefore:this._before,partsAfter:t,project:$1(e)})};Ut.prototype._detach=function(){this._open=!1,this._off&&(this._off(),this._off=null),qf(this._runner,null),this._exp._record=null};Ut.prototype.stop=async function(){var e=this,t=o(function(i){try{Cr(i)}catch(n){throw e._carry(n)}},"refuse");this._open||t("this Record is already closed"+(this._closedBy?" (closedBy: "+this._closedBy+")":"")+" \u2014 read rec.closed."),this._stopping&&t("stop() is already running."),this._inflight&&t(this._inflight+" clip(s) are still being filmed \u2014 await rec.film (or the record()) before stop()."),this._stopping=!0;var r;try{r=await this._folder(this._exp._project)}catch(i){throw this._carry(i)}finally{this._stopping=!1}return this._closedBy="stop",this._detach(),this._closedSettle.resolve(Object.assign({},r,{closedBy:"stop",droppedClips:0})),r};Ut.prototype._closeOnReauthor=function(e){var t=this,r=this._inflight;this._closedBy="reauthor",this._detach(),this._folder(e).then(function(i){t._closedSettle.resolve(Object.assign({},i,{closedBy:"reauthor",droppedClips:r}))},function(i){t._refused=t._carry(i),t._refused.closedBy="reauthor",t._refused.droppedClips=r,t._closedSettle.reject(t._refused)})};function eO(){return Gl}o(eO,"_worldInit");function tO(){var e=Si();if(!e)throw new Error("[RecipeContext] no display is booted (FrqtlDisplay.name() is empty): the host boots the renderer the scene's registry row names (renderState.renderer) before the scene runs. (FAIL-LOUD.)");return e}o(tO,"_bootedRenderer");var Bc="exp.createCanvas(w, h, cfg) (p5, 2D) or exp.createScene(w, h, d, cfg) (three, 3D)",rO="[RecipeContext] the scene has not created its world \u2014 its first statement is "+Bc+".",Ry=["canvasParentId","seed","tickHz","drawHz","stepsPerFrame","onTick","onReady","engine"],Cy=Ry.concat(["deferCanvas"]);function _t(e){e=e||{},Object.keys(e).forEach(function(t){if(Cy.indexOf(t)===-1)throw new Error('[RecipeContext] unknown option "'+t+'" \u2014 the facade is SIZELESS: it takes '+Cy.join(", ")+". A world size (canvasW/canvasH) or 3D-ness is the scene's, stated by "+Bc+". (FAIL-LOUD.)")}),this._opts=e,this._runner=null,this._world=null,this._built=!1,this._buildFn=null,this._project=null,this._urls=null,this._parts=new Map,this._code=new Map,this._declaredOnce=!1,this._record=null,this._reauthored=null}o(_t,"RecipeContext");function Ir(e){if(!e._world)throw new Error(rO)}o(Ir,"_requireWorld");Object.defineProperty(_t.prototype,"world",{get:o(function(){return this._world},"get")});Object.defineProperty(_t.prototype,"runner",{get:o(function(){return Ir(this),this._runner},"get")});Object.defineProperty(_t.prototype,"universe",{get:o(function(){return Ir(this),this._runner.universe},"get")});Object.defineProperty(_t.prototype,"is3D",{get:o(function(){return Ir(this),this._world.renderer==="three"},"get")});function Dy(e,t,r,i,n,a,s){var l="RecipeContext."+t;if(e._world)throw new Error("["+l+"] one world per scene: this recipe already created "+JSON.stringify({renderer:e._world.renderer,w:e._world.w,h:e._world.h,d:e._world.d})+". (FAIL-LOUD.)");[["w",i],["h",n]].concat(r==="three"?[["d",a]]:[]).forEach(function(b){if(typeof b[1]!="number"||!(b[1]>0))throw new Error("["+l+"] "+b[0]+" must be a positive number (got "+JSON.stringify(b[1])+") \u2014 every scene states its whole world"+(b[0]==="d"?"; the engine's cube default is not relied on":"")+". (FAIL-LOUD.)")}),s=s||{};var c=eO();c.assertInitCfg(l+"(\u2026, cfg)",s,null);var f=tO();if(f!==r){var u=new Error("["+l+"] the scene calls "+t+" ("+r+') but the host booted "'+f+`" \u2014 the host's display (a registry row's renderState.renderer, bootScene's opts.renderer) and the scene disagree. (FAIL-LOUD.)`);throw u.frqtlRequiredRenderer=r,u.frqtlBootedRenderer=f,u}if(e._runner){var h=e._runner.canvas_rect;if(h.w!==i||h.h!==n||e._runner._depth!==(r==="three"?a:null)||e._runner._is3D!==(r==="three"))throw new Error("["+l+"] this page already holds a "+h.w+"x"+h.h+" world; a scene with a different world needs a fresh page. (FAIL-LOUD.)")}else{var g={canvasW:i,canvasH:n,is3D:r==="three"};r==="three"&&(g.canvasD=a),Ry.forEach(function(b){e._opts[b]!==void 0&&(g[b]=e._opts[b])}),e._runner=new W(g),e._opts.deferCanvas||e._runner.createCanvas()}e._runner._projectUrls=e._urls;var d=e._runner.universe,m=c.initArgs(s);return r==="three"&&(m[1].activeAxes={x:!0,y:!0,z:!0},m[1].depth=a),e._runner.clearDeclared(),e._runner.beginWorld(),c.applyPreInit(s,d),d.init.apply(d,m),e._world=Object.freeze({renderer:r,w:i,h:n,d:r==="three"?a:null,cfg:Object.freeze(Object.assign({},s))}),e}o(Dy,"_coinit");_t.prototype.createCanvas=function(e,t,r){if(arguments.length>3)throw new Error("[RecipeContext.createCanvas] takes (w, h, cfg) \u2014 a 2D world has no depth; a 3D world is exp.createScene(w, h, d, cfg). (FAIL-LOUD.)");return Dy(this,"createCanvas","p5",e,t,null,r)};_t.prototype.createScene=function(e,t,r,i){return Dy(this,"createScene","three",e,t,r,i)};_t.prototype.init=function(){throw new Error("[RecipeContext] exp.init(cfg) is DELETED \u2014 a scene states its world, size included, with "+Bc+". (FAIL-LOUD: a saved module carrying exp.init( must be re-saved.)")};Object.defineProperty(_t.prototype,"initCfg",{get:o(function(){throw new Error("[RecipeContext] exp.initCfg is DELETED \u2014 read exp.world ({renderer, w, h, d, cfg}). (FAIL-LOUD.)")},"get")});_t.prototype.addObject=function(e,t){Ir(this);var r=t&&t.x!=null?t.x:0,i=t&&t.y!=null?t.y:0,n={runner:this._runner,cw:null,x:r,y:i};return Eh.create(e,t,n)};var jy="import { <Kind> } from '@descix/frqtl-web/parts'";function fr(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(fr);var t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)return e;var r={};return Object.keys(e).forEach(function(i){r[i]=fr(e[i])}),r}o(fr,"_plain");_t.prototype.declare=function(e){if(Ir(this),this._declaredOnce)throw new Error("[RecipeContext.declare] exp.declare(parts) runs ONCE per build \u2014 the scene's one `export const "+sa+"` block is its declared parts. (FAIL-LOUD.)");if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("[RecipeContext.declare] exp.declare(parts): parts is the sketch's `export const "+sa+" = { name: [Kind, { \u2026props }] }` object. (FAIL-LOUD.)");this._declaredOnce=!0;var t=this,r={};return Object.keys(e).forEach(function(i){var n=e[i];if(!Array.isArray(n)||n.length!==2||!n[1]||typeof n[1]!="object"||Array.isArray(n[1]))throw new TypeError("[RecipeContext.declare] parts."+i+" is not [Kind, { \u2026props }]. (FAIL-LOUD.)");var a=n[0],s=n[1];if(typeof a=="string")throw new TypeError("[RecipeContext.declare] parts."+i+' names its kind by the string "'+a+'" \u2014 in `parts` a kind is the imported class: '+jy.replace("<Kind>",a)+". (exp.addObject(name, props) still takes a string.) (FAIL-LOUD.)");if(typeof a!="function"||!Dt(a))throw new TypeError("[RecipeContext.declare] parts."+i+": "+(typeof a=="function"?"the class "+(a.name||"(anonymous)")+" is not a registered kind in this realm":"the kind is "+(a===null?"null":typeof a)+", not a registered class")+" \u2014 "+jy+", or register a forked part's renamed class (@descix/frqtl-web/kinds). (FAIL-LOUD.)");if(Object.prototype.hasOwnProperty.call(s,"name"))throw new TypeError("[RecipeContext.declare] parts."+i+" carries name "+JSON.stringify(s.name)+' \u2014 in `parts` the KEY is the name ("'+i+'"); delete the name prop. (FAIL-LOUD.)');var l=t.addObject(a,Object.assign({name:i},fr(s)));t._runner._adoptIntoParts(l),t._parts.set(l,{key:i,baseline:ui(t,l),kind:t._runner.kindOf(l)}),r[i]=l}),Object.freeze(r)};function ui(e,t){return Be.captureProps(t,e._runner.kindOf(t))}o(ui,"_capture");function Wc(e){var t=Be.get(e),r={};return(t&&t.fields||[]).forEach(function(i){i.writeOnly!==!0&&i.type!=="readonly"&&(r[i.name]=i)}),r}o(Wc,"_writable");function Yp(e,t,r){var i=Wc(e),n={},a=[];return Object.keys(i).forEach(function(s){var l=t[s],c=r[s];if(JSON.stringify(l)!==JSON.stringify(c)){if(c===void 0){a.push(s);return}n[s]=c}}),{props:n,lost:a}}o(Yp,"_touched");var Ly=W.RENAME_REFUSAL,wn=o(function(e){return JSON.stringify(e)},"_JSON");function Py(e,t,r,i,n){var a=Be.derivedReads(r);if(!a.length)return i;var s=zp(e,t),l=Be.RECT_TUPLE[4],c=Be.RECT_TUPLE[6];return Object.keys(i).forEach(function(f){var u=i[f],h=a.filter(function(m){return m.field===f&&m.tuple===6&&s.indexOf(m.name)!==-1});if(!(!h.length||!Array.isArray(u)||u.length!==6)){var g=Array.isArray(n[f])&&n[f].length===6?n[f]:null,d=l.map(function(m){return u[c.indexOf(m)]});g&&wn(d)===wn(l.map(function(m){return g[c.indexOf(m)]}))?delete i[f]:i[f]=d,h.forEach(function(m){var b=u[c.indexOf(m.key)];(!g||b!==g[c.indexOf(m.key)])&&(i[m.name]=b)})}}),i}o(Py,"_spell");function iO(e,t,r){var i=r.center;if(!Array.isArray(i)||i.length!==3||i[2]!==0||zp(e,t).indexOf("center")===-1)return r;var n=qp(e,t,"center"),a=n.literal?Array.isArray(n.value)?n.value.length:null:n.length;return a===2&&(r.center=[i[0],i[1]]),r}o(iO,"_spellCenter");function nO(e,t,r,i,n,a){var s=[],l=Be.RECT_TUPLE[4],c=Be.RECT_TUPLE[6],f=Be.derivedReads(r),u={};Object.keys(i).forEach(function(m){var b=qp(e,t,m);u[m]=b.literal?b.value:void 0,m==="center"&&Array.isArray(u[m])&&u[m].length===2&&(u[m]=u[m].concat([0]))});function h(m,b,y){s.push({op:"set",name:t,key:m,reason:"the written text declares "+wn(b)+" but the live object is "+wn(y)+" \u2014 the hand is not in the text."})}o(h,"refuse");var g={};f.forEach(function(m){g[m.name]=m}),Object.keys(i).forEach(function(m){if(!g[m]){var b=a[m];Array.isArray(b)&&b.length===6&&f.some(function(y){return y.field===m})||wn(u[m])!==wn(b)&&h(m,u[m],b)}});var d={};return f.forEach(function(m){d[m.field]=!0}),Object.keys(d).forEach(function(m){var b=a[m];if(!(!Array.isArray(b)||b.length!==6)){var y=i[m]!==void 0||f.some(function(S){return S.field===m&&i[S.name]!==void 0});if(y){var w=Array.isArray(n[m])&&n[m].length===6?n[m].slice():null,x=u[m];Array.isArray(x)&&x.length===6?w=x.slice():Array.isArray(x)&&x.length===4&&w&&l.forEach(function(S,A){w[c.indexOf(S)]=x[A]}),f.forEach(function(S){S.field===m&&w&&u[S.name]!==void 0&&(w[c.indexOf(S.key)]=u[S.name])}),wn(w)!==wn(b)&&h(m,w,b)}}}),s}o(nO,"_verifyWritten");var Vc="this sketch declares its parts outside `parts`; STUDIO can run it but cannot write hand edits into it \u2014 declare them in `export const parts` to make it editable.";function Ds(e,t){if(!e._project)throw new Error("[RecipeContext."+t+"] this scene was not built from linked text \u2014 the writer writes the text a facade linked: exp.build(await linkProject({ files, entry, mint })) (lib/shim/project/link.js). (FAIL-LOUD.)")}o(Ds,"_requireHeld");_t.prototype.toSketch=async function(e){Ir(this),Ds(this,"toSketch");var t=this._record?Ut.requireBy(e&&e.by,"RecipeContext.toSketch"):null;this._record&&this._record._admit("RecipeContext.toSketch");var r=this,i=this._runner,n=i.declared,a=[],s=[],l=[],c=i._takeHandTouched();this._parts.forEach(function(b,y){if(n.indexOf(y)===-1){a.push({op:"remove",name:b.key,kind:b.kind,baseline:b.baseline});return}if(c.has(y)){var w=i.kindOf(y),x=Yp(w,b.baseline,ui(r,y));if(Object.prototype.hasOwnProperty.call(x.props,"name")&&(s.push({op:"set",name:b.key,key:"name",reason:Ly}),delete x.props.name),x.lost.forEach(function(A){s.push({op:"set",name:b.key,key:A,reason:'the live object no longer reports "'+A+'" \u2014 there is no value to write.'})}),Object.keys(x.props).length){var S=fr(x.props);Py(r._project.files[r._project.entry],b.key,w,x.props,b.baseline),iO(r._project.files[r._project.entry],b.key,x.props),Object.keys(x.props).length&&a.push({op:"set",name:b.key,props:x.props,obj:y,kind:w,baseline:b.baseline,raw:S})}}}),this._code.forEach(function(b,y){var w=y.name||i.kindOf(y);if(n.indexOf(y)===-1){s.push({op:"remove",name:w,reason:'"'+w+'" is declared in code: '+Vc});return}if(c.has(y)){var x=Yp(i.kindOf(y),b,ui(r,y));(Object.keys(x.props).length||x.lost.length)&&s.push({op:"set",name:w,reason:'"'+w+'" is declared in code: '+Vc})}}),n.forEach(function(b){if(!(r._parts.has(b)||r._code.has(b))){var y=i.kindOf(b),w=Dt(y),x=ui(r,b),S=Wc(y);Object.keys(x).forEach(function(A){(!S[A]||A==="name")&&delete x[A]}),a.push({op:"add",name:b.name||y,Kind:y,module:w?ys(w.from,r._urls):null,props:x}),l.push(b)}});var f=this._project.entry,u=Nc(this._project.files[f],a.map(function(b){return b.op==="set"?{op:"set",name:b.name,props:b.props}:b.op==="remove"?{op:"remove",name:b.name}:{op:"add",name:b.name,Kind:b.Kind,module:b.module,props:b.props}}),{entry:f});a.forEach(function(b){b.op==="set"&&(u.refused.some(function(y){return y.op==="set"&&y.name===b.name})||s.push.apply(s,nO(u.text,b.name,b.kind,b.props,b.baseline,ui(r,b.obj))))});var h={};u.refused.forEach(function(b){b.op==="add"&&(h[b.name]=!0)});var g=Object.assign({},this._project.files);g[f]=u.text,this._project=Object.assign({},this._project,{files:g});var d={};u.refused.forEach(function(b){b.op==="remove"&&(d[b.name]=!0)}),this._parts.forEach(function(b,y){if(n.indexOf(y)===-1){d[b.key]||r._parts.delete(y);return}b.baseline=ui(r,y)}),l.forEach(function(b){var y=b.name||i.kindOf(b);h[y]||(i._adoptIntoParts(b),r._parts.set(b,{key:y,baseline:ui(r,b),kind:i.kindOf(b)}))});var m=s.concat(u.refused);return this._record&&aO(this,a,m,t),{files:Object.assign({},g),changes:u.changes,refused:m}};function aO(e,t,r,i){var n=e._runner,a=e._record;function s(c,f){var u={},h=!1;return r.forEach(function(g){g.name!==c||g.op!==f||(g.key===void 0?h=!0:u[g.key]=!0)}),h?null:u}o(s,"refusedKeys");function l(c,f){var u=Wc(c),h={};return Object.keys(f).forEach(function(g){u[g]&&g!=="name"&&(h[g]=fr(f[g]))}),h}o(l,"writableProps"),t.forEach(function(c){if(c.op==="add"){if(s(c.name,"add")===null)return;a._row({name:c.name,op:"add",by:i,from:null,to:[c.Kind,fr(c.props)]});return}if(c.op==="remove"){if(s(c.name,"remove")===null)return;a._row({name:c.name,op:"remove",by:i,from:[c.kind,l(c.kind,c.baseline)],to:null});return}var f=s(c.name,"set");if(f!==null){var u=c.raw,h=u.center!==void 0||u.rect!==void 0?n._placementAuthority(c.obj):null,g={};h&&(g[h]=!0,Be.derivedReads(c.kind).forEach(function(S){S.field===h&&(g[S.name]=!0)}));var d=Object.keys(f).some(function(S){return g[S]});if(h&&u[h]!==void 0&&!d){var m={},b={};m[h]=fr(c.baseline[h]),b[h]=fr(u[h]),a._row({name:c.name,op:"move",by:i,from:m,to:b})}var y={},w={},x=!1;Object.keys(u).forEach(function(S){S===h||f[S]||(y[S]=c.baseline[S]===void 0?null:fr(c.baseline[S]),w[S]=fr(u[S]),x=!0)}),x&&a._row({name:c.name,op:"setDeclared",by:i,from:y,to:w})}})}o(aO,"_recordRows");function Jp(e){var t=e._runner,r=t._handTouched;if(!r||!r.size)return[];var i=[];return r.forEach(function(n){if(t.declared.indexOf(n)!==-1){var a=e._parts.get(n),s=a?a.baseline:e._code.get(n);if(s){var l=Yp(t.kindOf(n),s,ui(e,n));(Object.keys(l.props).length||l.lost.length)&&i.push(a?a.key:n.name||t.kindOf(n))}}}),i}o(Jp,"_unwrittenHands");function Iy(e){var t=e.cameraControl;if(!t||typeof t.getOrbit!="function"||!Array.isArray(t.poseFields))return null;var r=t.getOrbit()||{},i={};return t.poseFields.forEach(function(n){r[n.name]!==void 0&&(i[n.name]=fr(r[n.name]))}),i}o(Iy,"_cameraPose");_t.prototype.setDeclared=async function(e,t,r){Ir(this),Ds(this,"setDeclared");var i=this._record?Ut.requireBy(r&&r.by,"RecipeContext.setDeclared"):null;this._record&&this._record._admit("RecipeContext.setDeclared");var n=this._runner,a=null;if(this._parts.forEach(function(T,j){T.key===e&&(a=j)}),!a||n.declared.indexOf(a)===-1)throw new Error('[RecipeContext.setDeclared] "'+e+"\" is not an object of this sketch's `parts` block"+(this._code.size?" (code declarations: "+Array.from(this._code.keys()).map(function(T){return T.name}).join(", ")+" \u2014 "+Vc+")":"")+". (FAIL-LOUD.)");if(!t||typeof t!="object"||Array.isArray(t)||!Object.keys(t).length)throw new TypeError("[RecipeContext.setDeclared] patch is { <field>: value, \u2026 } with at least one field. (FAIL-LOUD.)");if(Object.prototype.hasOwnProperty.call(t,"name"))throw new TypeError('[RecipeContext.setDeclared] "name": '+Ly+" (FAIL-LOUD.)");var s=Jp(this);if(s.length)throw new Error('[RecipeContext.setDeclared] "'+s.join('", "')+'" carries a hand the sketch text does not hold yet \u2014 write the hand first: await exp.toSketch(). (FAIL-LOUD.)');var l=n.kindOf(a),c=Wc(l),f=ui(this,a),u={};Object.keys(t).forEach(function(T){if(!c[T])throw new TypeError('[RecipeContext.setDeclared] "'+T+'" is not a writable field of '+l+" (writable: "+Object.keys(c).join(", ")+"). (FAIL-LOUD.)");try{Be.normalizeValue(c[T],t[T],l)}catch(j){throw new TypeError('[RecipeContext.setDeclared] "'+T+'": '+String(j&&j.message||j)+" (FAIL-LOUD.)")}u[T]=f[T]===void 0?null:f[T]});var h=this._project.entry,g=Py(this._project.files[h],e,l,fr(t),f),d=Nc(this._project.files[h],[{op:"set",name:e,props:g}],{entry:h});if(d.refused.length)throw new Error("[RecipeContext.setDeclared] the sketch text refused the patch: "+d.refused.map(function(T){return(T.key?T.key+": ":"")+T.reason}).join("; ")+" (FAIL-LOUD.)");var m=Object.assign({},this._project.files);m[h]=d.text,this._project=Object.assign({},this._project,{files:m});var b=Iy(n),y=!!n._isLooping;await n.restart(),y||n.stop();var w=["seed"];b&&n.cameraControl&&typeof n.cameraControl.setOrbit=="function"&&(n.cameraControl.setOrbit(b),w.push("cameraPose"));var x=null;if(this._parts.forEach(function(T,j){T.key===e&&(x=j)}),!x)throw new Error('[RecipeContext.setDeclared] the re-run declared no "'+e+'" \u2014 the patched text dropped the entry. (FAIL-LOUD.)');var S=ui(this,x),A={};return Object.keys(t).forEach(function(T){A[T]=S[T]===void 0?null:fr(S[T])}),this._record&&this._record._row({name:e,op:"setDeclared",by:i,from:fr(u),to:fr(A)}),{set:e,from:u,to:A,tick:0,kept:w,files:Object.assign({},m)}};function Fy(e,t){var r=e._runner,i=null;if(e._parts.forEach(function(c,f){c.key===t&&(i=f)}),!i||r.declared.indexOf(i)===-1)throw new Error('[RecipeContext.fork] "'+t+"\" is not an object of this sketch's `parts` block"+(e._code.size?" (code declarations: "+Array.from(e._code.keys()).map(function(c){return c.name}).join(", ")+" \u2014 "+Vc+")":"")+". (FAIL-LOUD.)");var n=Jp(e);if(n.length)throw new Error('[RecipeContext.fork] "'+n.join('", "')+'" carries a hand the sketch text does not hold yet \u2014 write the hand first: await exp.toSketch(). (FAIL-LOUD.)');var a=r.kindOf(i);if(Object.prototype.hasOwnProperty.call(Cs,a))throw new Error("[RecipeContext.fork] "+a+' (the kind of "'+t+'") is not forkable \u2014 '+Cs[a]+". (FAIL-LOUD.)");var s=Dt(a),l=s?ys(s.from,e._urls):null;if(l!==mc&&!(l&&Object.prototype.hasOwnProperty.call(e._project.files,l)))throw new Error("[RecipeContext.fork] "+a+' (the kind of "'+t+'") has no part file a fork can copy \u2014 a fork copies a part of @descix/frqtl-web/parts or a part file of this project. (FAIL-LOUD.)');return{obj:i,from:a,row:s,module:l}}o(Fy,"_forkPlan");_t.prototype.forkRefusal=function(e){Ir(this),Ds(this,"forkRefusal");try{return Fy(this,e),null}catch(t){return String(t&&t.message).replace(/^\[RecipeContext\.fork\] /,"").replace(/ \(FAIL-LOUD\.\)$/,"")}};_t.prototype.fork=async function(e,t,r){Ir(this),Ds(this,"fork");var i=this._record?Ut.requireBy(r&&r.by,"RecipeContext.fork"):null;this._record&&this._record._admit("RecipeContext.fork");var n=this._runner,a=Fy(this,e),s=a.from,l=a.row,c=a.module,f,u;if(c===mc){u=l.from.slice(ze().length);try{f=await by(l.from)}catch(S){throw new Error("[RecipeContext.fork] the part file of "+s+": "+(S&&S.message||S)+". (FAIL-LOUD.)")}}else u=c,f=this._project.files[c];var h=yy(f,{from:s,to:t,libPath:u,files:this._project.files}),g="parts/"+t+".js",d=this._project.entry,m=Nc(this._project.files[d],[{op:"kind",name:e,Kind:t,module:g}],{entry:d});if(m.refused.length)throw new Error("[RecipeContext.fork] the sketch text refused the fork: "+m.refused.map(function(S){return S.reason}).join("; ")+" (FAIL-LOUD.)");var b=Object.assign({},this._project.files);b[g]=h.text,b[d]=m.text,this._project=Object.assign({},this._project,{files:b});var y=Iy(n),w=!!n._isLooping;await n.restart(),w||n.stop(),y&&n.cameraControl&&typeof n.cameraControl.setOrbit=="function"&&n.cameraControl.setOrbit(y);var x=null;if(this._parts.forEach(function(S,A){S.key===e&&(x=A)}),!x||n.kindOf(x)!==t)throw new Error('[RecipeContext.fork] the re-run declared "'+e+'" as '+(x?n.kindOf(x):"nothing")+", not the fork "+t+". (FAIL-LOUD.)");return this._record&&this._record._row({name:e,op:"fork",by:i,from:s,to:{kind:t,file:g}}),{fork:t,file:g,from:s,files:Object.assign({},b)}};_t.prototype.addTickFunction=function(e){Ir(this);var t=this._runner.universe.experimentTickFunctions;return t.push(e),t.length-1};_t.prototype.render=function(e){return Ir(this),this._runner.setRenderOptions(e),this};function oO(e){var t=e._runner;t.stop();for(var r=t.universe.experimentTickFunctions,i=t.undeclaredTickFunctions(),n=t.declared.slice(),a=n.length-1;a>=0;a--)t.removeObject(n[a]);for(var s=0;s<i.length;s++){var l=r.indexOf(i[s]);l!==-1&&r.splice(l,1)}if(r.length)throw new Error("[RecipeContext.build] rebuilding on the same runner: "+r.length+" tick-function(s) of the previous scene survived its teardown ("+r.map(function(c,f){return c.name?c.name:"<anonymous #"+f+">"}).join(", ")+") \u2014 no declared part owned them and the scene did not add them (exp.addTickFunction). Host per-tick work belongs on runner.addTickListener, which survives a rebuild. (FAIL-LOUD.)")}o(oO,"_teardownSceneForRebuild");_t.prototype.build=function(e){var t=null;if(e&&typeof e=="object"&&typeof e.buildExperiment=="function"){if(!e.project||typeof e.project!="object"||!e.project.files||typeof e.project.entry!="string")throw new TypeError("[RecipeContext.build] build(linked): linked is linkProject's result (its contract: lib/shim/project/link.js). (FAIL-LOUD.)");t=e,e=t.buildExperiment}else if(e!=null&&typeof e!="function")throw new TypeError("[RecipeContext.build] build(sketch): sketch is the scene's buildExperiment(exp) function or linkProject's result (got "+typeof e+"). (FAIL-LOUD.)");if(typeof e=="function"){if(this._record&&!(t&&this._project&&sO(t.project.files,this._project.files))&&(this._reauthored=this._record,this._record._closeOnReauthor(this._project)),this._buildFn=e,this._project=t?t.project:null,this._urls=t&&t.urls||null,this._runner&&oO(this),this._world=null,this._parts=new Map,this._code=new Map,this._declaredOnce=!1,e(this),!this._world)throw new Error("[RecipeContext.build] the scene never created its world \u2014 its first statement must be "+Bc+". (FAIL-LOUD.)");this._built=!0;var r=this;this._runner.declared.forEach(function(i){r._parts.has(i)||r._code.set(i,ui(r,i))}),this._runner.retainSceneReplay(this._project?function(){return ao(r._project).then(function(i){return r.build(i)})}:function(){return r.build(r._buildFn)})}return My(this),this};function sO(e,t){var r=Object.keys(e),i=Object.keys(t);return r.length!==i.length?!1:r.every(function(n){return Object.prototype.hasOwnProperty.call(t,n)&&e[n]===t[n]})}o(sO,"_sameFiles");_t.prototype.startRecord=async function(){if(Ir(this),Ds(this,"startRecord"),this._record)throw new Error("[RecipeContext.startRecord] a Record is already open on this facade (one per booted world) \u2014 await rec.stop() first. (FAIL-LOUD.)");var e=this._reauthored;if(e){if(await e._settled,e._refused&&!e._closedRead){var t=new Error("[RecipeContext.startRecord] the previous Record of this facade was closed by a re-authoring and REFUSED ("+e._refused.message+") \u2014 nobody read rec.closed, so its "+e._refused.record.changes.length+" row(s) would be lost: read rec.closed (its rejection carries err.record = { changes, clips }) first. (FAIL-LOUD.)");throw t.record=e._refused.record,t}this._reauthored=null}if(Jo(this._runner))throw new Error("[RecipeContext.startRecord] another facade holds an open Record on this runner. (FAIL-LOUD.)");if(!Object.prototype.hasOwnProperty.call(this._project.files,tt))throw new Error("[RecipeContext.startRecord] a Record snapshots a folder; boot it as one \u2014 the held project carries no "+tt+": add files['"+tt+"'] = serializeManifest(manifestFor({ name, entry: SKETCH_ENTRY })) (all from ./project) to the files you boot. (FAIL-LOUD.)");var r=Jp(this);if(r.length)throw new Error('[RecipeContext.startRecord] "'+r.join('", "')+'" carries a hand the sketch text does not hold yet \u2014 write the hand first: await exp.toSketch(). (FAIL-LOUD.)');var i=new Ut(this);this._record=i;try{await i._ready(this._project)}catch(n){throw i._detach(),n}return i};_t.prototype.run=function(e){e&&typeof e=="function"&&!this._built&&this.build(e),Ir(this),My(this),this._runner.start()};["INIT_CFG","assertInitCfg","initArgs"].forEach(function(e){Object.defineProperty(_t,e,{get:o(function(){throw new Error("RecipeContext."+e+" does not exist: the world-cfg contract is FrqtlWorldInit."+e+" (objects/setup/_worldInit.js).")},"get")})});var lO=Object.freeze({buildSource:'[RecipeContext] exp.buildSource(src) is retired \u2014 a sketch held as text is a project: boot it with bootProject(mount, { files: { "sketch.js": src }, entry: "sketch.js" }) (@descix/frqtl-web/boot), or re-scene a booted facade with exp.build(await linkProject({ files, entry, mint })) (lib/shim/project/link.js). (FAIL-LOUD.)'});sc(_t.prototype,lO);var Ny=null;function My(e){if(!(e instanceof _t))throw new TypeError("[RecipeContext] setPageExperiment(exp): expected a RecipeContext. (FAIL-LOUD.)");Ny=e}o(My,"setPageExperiment");function Uy(){return Ny}o(Uy,"pageExperiment");Ia();Va();var cO=Object.freeze({AbsorbRadiation:"import * as AbsorbRadiation from its module, lib/frqtl/objects/objects/absorbRadiation.js",AstSchema:"import * as AstSchema from its module, lib/shim/expr/ast-schema.js",BOUNCE_DIRECTIONS:"import { BOUNCE_DIRECTIONS } from its module, lib/frqtl/objects/constants/WallBehaviors.js",Box:"import { Box } from its module, lib/frqtl/objects/objects/Box.js",Bullet:"import { Bullet } from its module, lib/frqtl/objects/objects/Bullet.js",Camera2dGeometry:"import * as Camera2dGeometry from its module, lib/frqtl/compat/renderer/camera2d-geometry.js",CameraControls:"import { CameraControls } from '@descix/frqtl-web/parts'",CameraPath:"import { CameraPath } from '@descix/frqtl-web/parts'",CaptureEnvelope:"import * as CaptureEnvelope from its module, lib/shim/render/capture-envelope.js",CaptureStillCommon:"import * as CaptureStillCommon from its module, lib/frqtl/compat/renderer/captureStill-common.js",Charge:"read the engine at call time: engine().Charge (lib/frqtl/compat/engine.js)",CircuitGate:"import { CircuitGate } from its module, lib/frqtl/objects/objects/CircuitGate.js",CircuitProbe:"import { CircuitProbe } from its module, lib/frqtl/objects/objects/CircuitProbe.js",CollisionActions:"import { CollisionActions } from '@descix/frqtl-web/parts'",CollisionTypes:"import { CollisionTypes } from '@descix/frqtl-web/parts'",ControlAction:"import { ControlAction } from its module, lib/frqtl/objects/objects/controlAction.js",ControlBind:"import { ControlBind } from its module, lib/frqtl/objects/objects/controlBind.js",ControlRegistry:"import * as ControlRegistry from '@descix/frqtl-web/shim/controls/registry.js'",ControlsSchema:"import * as ControlsSchema from its module, lib/shim/controls/index.js",DataCollector:"import { DataCollector } from its module, lib/frqtl/objects/collectors/DataCollector.js",DetectorWall:"import { DetectorWall } from '@descix/frqtl-web/parts'",DirectedRedirectProgram:"import * as DirectedRedirectProgram from its module, lib/frqtl/objects/objects/directedRedirectProgram.js",DirectedTunnel:"import { DirectedTunnel } from its module, lib/frqtl/objects/objects/DirectedTunnel.js",EGPTUniverse:"read the engine at call time: engine().EGPTUniverse (lib/frqtl/compat/engine.js)",EgptFractal:"import { EgptFractal } from its module, lib/frqtl/objects/objects/EgptFractal.js",EmitterProgram:"import * as EmitterProgram from its module, lib/frqtl/objects/objects/emitterProgram.js",EngineScopeDescriptors:"import * as EngineScopeDescriptors from its module, lib/frqtl/objects/schema/engine-scopes.js",ExperimentMetrics:"import { ExperimentMetrics } from its module, lib/frqtl/experiments/_shared/experiment-metrics.js",FieldBuilder:"import { FieldBuilder } from its module, lib/frqtl/compat/renderer/FieldBuilder.js",FieldDescriptorSchema:"import * as FieldDescriptorSchema from its module, lib/shim/field-descriptor/index.js",Filters:"import { Filters } from its module, lib/frqtl/compat/renderer/Filters.js",Frame:"read the engine at call time: engine().Frame (lib/frqtl/compat/engine.js)",FrameData:"read the engine at call time: engine().FrameData (lib/frqtl/compat/engine.js)",FrameDataSchema:"import * as FrameDataSchema from its module, lib/shim/frame-data/index.js",FrqtlApp:"import { FrqtlApp } from its module, lib/frqtl/objects/FrqtlApp.js",FrqtlCapture:"import { FrqtlCapture } from its module, lib/frqtl/objects/instruments/capture.js",FrqtlCaptureHost:"import { FrqtlCaptureHost } from its module, lib/frqtl/objects/instruments/capture-host.js",FrqtlControlOverlay:"import { FrqtlControlOverlay } from '@descix/frqtl-web/parts'",FrqtlControlSlider:"import { FrqtlControlSlider } from its module, lib/frqtl/objects/objects/frqtl-control-slider.js",FrqtlControlSync:"import { FrqtlControlSync } from its module, lib/frqtl/objects/objects/frqtl-control-sync.js",FrqtlControlWidgets:"import { FrqtlControlWidgets } from its module, lib/frqtl/objects/objects/frqtl-control-widgets.js",FrqtlControlWriteQueue:"import { FrqtlControlWriteQueue } from its module, lib/frqtl/objects/objects/frqtl-control-write-queue.js",FrqtlControlsPanel:"import { FrqtlControlsPanel } from '@descix/frqtl-web/parts'",FrqtlDisplay:"import * as FrqtlDisplay from '@descix/frqtl-web/compat/renderer/display-slot.js'",FrqtlHostedEyes:"import { FrqtlHostedEyes } from its module, lib/frqtl/objects/instruments/hosted-eyes.js",FrqtlVision:"import { FrqtlVision } from '@descix/frqtl-web/parts'",FrqtlWorldInit:"import { FrqtlWorldInit } from its module, lib/frqtl/objects/setup/_worldInit.js",GodraysLayer:"import * as GodraysLayer from its module, lib/frqtl/compat/renderer/providers/godrays-layer.js",GraphingDetectorWall:"import { GraphingDetectorWall } from '@descix/frqtl-web/parts'",HeatColormap:"import * as HeatColormap from its module, lib/shim/render/heat-colormap.js",InterferenceAnalysis:"import { InterferenceAnalysis } from its module, lib/frqtl/experiments/_shared/interference-analysis.js",LargeObject:"import { LargeObject } from '@descix/frqtl-web/parts'",LightColor:"import { LightColor } from '@descix/frqtl-web/parts'",LightSource:"import { LightSource } from its module, lib/frqtl/objects/objects/LightSource.js",LoDrawnCenter:"import * as LoDrawnCenter from its module, lib/frqtl/compat/renderer/lo-drawn-center.js",LogicGate:"import { LogicGate } from '@descix/frqtl-web/parts'",MakeControlsForObject:"import { MakeControlsForObject } from its module, lib/frqtl/objects/objects/makeControlsForObject.js",MakeControlsForRenderSurface:"import { MakeControlsForRenderSurface } from its module, lib/frqtl/objects/objects/makeControlsForRenderSurface.js",ObjectFactory:"import { ObjectFactory } from its module, lib/frqtl/objects/ObjectFactory.js",ObjectSchema:"import { ObjectSchema } from its module, lib/frqtl/objects/schema/index.js",ObjectValueNormalizer:"import * as ObjectValueNormalizer from its module, lib/frqtl/objects/schema/valueNormalizer.js",OrbitBag:"import * as OrbitBag from '@descix/frqtl-web/compat/renderer/orbit-bag.js'",OvenBox:"import { OvenBox } from '@descix/frqtl-web/parts'",PLACEABLE_KINDS:"read ObjectSchema.placeableCatalog() (lib/frqtl/objects/schema/index.js)",PUBLIC_PARTS:"the parts directory is the roster \u2014 import * as parts from '@descix/frqtl-web/parts'",PageParams:"import * as PageParams from its module, lib/shim/page-params/index.js",PointSource:"import { PointSource } from '@descix/frqtl-web/parts'",QuantumEmitter:"import { QuantumEmitter } from its module, lib/frqtl/objects/objects/QuantumEmitter.js",RENDERER_PROVIDER_OPTIONAL:"import { RENDERER_PROVIDER_OPTIONAL } from its module, lib/frqtl/compat/renderer/renderer-provider-contract.js",RENDERER_PROVIDER_REQUIRED:"import { RENDERER_PROVIDER_REQUIRED } from its module, lib/frqtl/compat/renderer/renderer-provider-contract.js",RadiationHistogram:"import { RadiationHistogram } from its module, lib/frqtl/experiments/_shared/radiation-histogram.js",RecipeContext:"import { RecipeContext } from its module, lib/frqtl/objects/RecipeContext.js",Rectangle:"import { Rectangle } from '@descix/frqtl-web/parts'",RenderCapabilitiesCommon:"import * as RenderCapabilitiesCommon from its module, lib/frqtl/compat/renderer/renderCapabilities-common.js",RenderFamily:"import { RenderFamily } from its module, lib/frqtl/compat/renderer/RenderFamily.js",RenderMesh:"import { RenderMesh } from its module, lib/frqtl/compat/renderer/RenderMesh.js",RenderShape:"import { RenderShape } from its module, lib/frqtl/compat/renderer/RenderShape.js",RenderStages:"import * as RenderStages from its module, lib/shim/render/render-stages.js",RenderState:"import * as RenderState from its module, lib/shim/render-state/apply.js",RendererProviderContract:"import * as RendererProviderContract from its module, lib/frqtl/compat/renderer/renderer-provider-contract.js",ShimRpc:"import * as ShimRpc from its module, lib/shim/rpc/index.js",SlabFace:"import * as SlabFace from its module, lib/frqtl/objects/geometry/SlabFace.js",SlitLightSource:"import { SlitLightSource } from '@descix/frqtl-web/parts'",SlitLinerScatter:"import * as SlitLinerScatter from its module, lib/frqtl/objects/objects/slitLinerScatter.js",SlitScreen:"import { SlitScreen } from '@descix/frqtl-web/parts'",SphereEmitter:"import { SphereEmitter } from '@descix/frqtl-web/parts'",SunLook:"import * as SunLook from '@descix/frqtl-web/shim/render/sun-look.js'",SustainedSource:"import * as SustainedSource from its module, lib/frqtl/objects/objects/sustainedSource.js",Tagger:"import * as Tagger from its module, lib/frqtl/objects/objects/tagger.js",ThreeCameraContract:"import * as ThreeCameraContract from its module, lib/frqtl/compat/renderer/providers/three-camera-contract.js",ThreeCameraGeometry:"import * as ThreeCameraGeometry from its module, lib/frqtl/compat/renderer/providers/three-camera-geometry.js",TickData:"read the engine at call time: engine().TickData (lib/frqtl/compat/engine.js)",Trace:"import { Trace } from '@descix/frqtl-web/parts'",Tube:"import { Tube } from its module, lib/frqtl/objects/objects/Tube.js",Tunnel:"import { Tunnel } from '@descix/frqtl-web/parts'",UnprojectStill:"import * as UnprojectStill from its module, lib/frqtl/compat/renderer/unprojectStill.js",WALL_BEHAVIORS:"import { WALL_BEHAVIORS } from its module, lib/frqtl/objects/constants/WallBehaviors.js",WALL_HOOKS:"import { WALL_HOOKS } from its module, lib/frqtl/objects/constants/WallBehaviors.js",WALL_PRESETS:"import { WALL_PRESETS } from its module, lib/frqtl/objects/constants/WallBehaviors.js",Wall:"import { Wall } from '@descix/frqtl-web/parts'",_WasmLoadBrowser:"import { loadedWasmSha256 } from lib/frqtl/compat/providers/wasm-load-browser.js",_egptEngine:"import { engineState } from lib/frqtl/compat/engine.js",_egptExperiment:"read the page door: FrqtlPage.experiment",_egptFailLoud:"import { paintBootFailure } from lib/frqtl/experiments/_shared/boot-failure.js",_egptRenderer:"read the display slot (lib/frqtl/compat/renderer/display-slot.js name()), or <html data-frqtl-renderer> from outside the realm",_egptRendererFailLoud:"import { paintBootFailure } from lib/frqtl/experiments/_shared/boot-failure.js",_egptRendererProviders:"import { RENDERER_PROVIDERS } from lib/frqtl/compat/renderer/providers/index.js",_egptResolveFrqtl:"a module locates a sibling file with new URL(rel, import.meta.url)",_frqtlApp:"read the page door: FrqtlPage.runner",_frqtlControlsRegistry:"read the page door: FrqtlPage.controls",_frqtlHostedRecordings:"the capture-host KIND keeps its ledger as module state (lib/frqtl/objects/instruments/capture-host.js parkedRecording)",applyProgramTrigger:"import { applyProgramTrigger } from its module, lib/frqtl/objects/objects/actionCompiler.js",assertSetupOptions:"import { assertSetupOptions } from its module, lib/frqtl/objects/setup/_setupOptions.js",bounceDirectionValuesMap:"import { bounceDirectionValuesMap } from its module, lib/frqtl/objects/constants/WallBehaviors.js",buildAbsorbRadiationTickFn:"import { buildAbsorbRadiationTickFn } from its module, lib/frqtl/objects/objects/absorbRadiation.js",buildAngledReflectOps:"import { buildAngledReflectOps } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildConstrainedRandomOps:"import { buildConstrainedRandomOps } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildDecoherenceOps:"import { buildDecoherenceOps } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildEjectOps:"import { buildEjectOps } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildExperiment:"a sketch is an ES module \u2014 export default function buildExperiment(exp)",buildFaceExitEjectOps:"import { buildFaceExitEjectOps } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildIncidenceReflectOps:"import { buildIncidenceReflectOps } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildIncidenceReflectOps3D:"import { buildIncidenceReflectOps3D } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildOmniRandomOps:"import { buildOmniRandomOps } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildReflectOps:"import { buildReflectOps } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildSwapReflectOps:"import { buildSwapReflectOps } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildTiltedReflectGuardTrigger:"import { buildTiltedReflectGuardTrigger } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildTriggerExpr:"import { buildTriggerExpr } from its module, lib/frqtl/objects/objects/actionCompiler.js",buildVelocityFlipOp:"import { buildVelocityFlipOp } from its module, lib/frqtl/objects/objects/actionCompiler.js",collisionMatrixLanes:"import { collisionMatrixLanes } from '@descix/frqtl-web/objects/setup/_collisionMatrixLanes.js'",compileActions:"import { compileActions } from its module, lib/frqtl/objects/objects/actionCompiler.js",compileWallV2:"import { compileWallV2 } from its module, lib/frqtl/objects/objects/actionCompiler.js",draw:"p5 global mode's draw hook \u2014 written by compat/vendor.js suppressP5Draw",expandWallPreset:"import { expandWallPreset } from its module, lib/frqtl/objects/constants/WallBehaviors.js",mapCharge:"deleted \u2014 the engine's Charge (engine().Charge) is the one charge vocabulary (lib/frqtl/compat/providers/wasm-engine.js)",requireWorldRect:"import { requireWorldRect } from its module, lib/frqtl/objects/setup/_setupOptions.js",resolveSlabFace:"import { resolveSlabFace } from its module, lib/frqtl/objects/geometry/SlabFace.js",resolveWallSpec:"import { resolveWallSpec } from its module, lib/frqtl/objects/constants/WallBehaviors.js",setup:"p5 global mode's setup hook \u2014 written by compat/vendor.js runSketch (bootPage({ setup }))",setupBlackbodySubstrate:"import { setupBlackbodySubstrate } from its module, lib/frqtl/objects/setup/setupBlackbodySubstrate.js",setupCircuitBasic:"import { setupCircuitBasic } from its module, lib/frqtl/objects/setup/setupCircuitBasic.js",setupCollisionMatrix:"import { setupCollisionMatrix } from its module, lib/frqtl/objects/setup/setupCollisionMatrix.js",setupConeEmitter3D:"import { setupConeEmitter3D } from its module, lib/frqtl/objects/setup/setupConeEmitter3D.js",setupDoubleSlit:"import { setupDoubleSlit } from its module, lib/frqtl/objects/setup/setupDoubleSlit.js",setupDoubleSlit_Laser:"import { setupDoubleSlit_Laser } from its module, lib/frqtl/objects/setup/setupDoubleSlit_Laser.js",setupEmpty:"import { setupEmpty } from its module, lib/frqtl/objects/setup/setupEmpty.js",setupFxSmoke:"import { setupFxSmoke } from its module, lib/frqtl/objects/setup/setupFxSmoke.js",setupG1Race:"import { setupG1Race } from its module, lib/frqtl/objects/setup/setupG1Race.js",setupG2Sweep:"import { setupG2Sweep } from its module, lib/frqtl/objects/setup/setupG2Sweep.js",setupG3Collide:"import { setupG3Collide } from its module, lib/frqtl/objects/setup/setupG3Collide.js",setupLightSourceLab:"import { setupLightSourceLab } from its module, lib/frqtl/objects/setup/setupLightSourceLab.js",setupOscillator:"import { setupOscillator } from its module, lib/frqtl/objects/setup/setupOscillator.js",setupParticleWalk:"import { setupParticleWalk } from its module, lib/frqtl/objects/setup/setupParticleWalk.js",setupParticleWalk3D:"import { setupParticleWalk3D } from its module, lib/frqtl/objects/setup/setupParticleWalk3D.js",setupSphereEmitter3D:"import { setupSphereEmitter3D } from its module, lib/frqtl/objects/setup/setupSphereEmitter3D.js",setupTraceCircuit:"import { setupTraceCircuit } from its module, lib/frqtl/objects/setup/setupTraceCircuit.js",setupTunnelLab:"import { setupTunnelLab } from its module, lib/frqtl/objects/setup/setupTunnelLab.js",setupTunnelPointExit:"import { setupTunnelPointExit } from its module, lib/frqtl/objects/setup/setupTunnelPointExit.js",setupWaveInterference:"import { setupWaveInterference } from its module, lib/frqtl/objects/setup/setupWaveInterference.js",validateRendererProvider:"import { validateRendererProvider } from its module, lib/frqtl/compat/renderer/renderer-provider-contract.js",wallBehaviorV2ValuesMap:"import { wallBehaviorV2ValuesMap } from its module, lib/frqtl/objects/constants/WallBehaviors.js",wallHookValuesMap:"import { wallHookValuesMap } from its module, lib/frqtl/objects/constants/WallBehaviors.js"});var uO=Object.freeze([Object.freeze({key:"runner",kind:"owner",replaces:"_frqtlApp",read:uv,why:"the runner the page drives (objects/FrqtlApp.js pageRunner)"}),Object.freeze({key:"experiment",kind:"owner",replaces:"_egptExperiment",read:Uy,why:"the recipe facade the page builds through (objects/RecipeContext.js pageExperiment)"}),Object.freeze({key:"controls",kind:"owner",replaces:"_frqtlControlsRegistry",read:o(function(){return xi.exposedRegistry()},"read"),why:"the control registry the page exposed (parts/FrqtlControlsPanel.js exposedRegistry)"}),Object.freeze({key:"isReady",kind:"page",why:"the empty page: a host may apply a scene now"}),Object.freeze({key:"applyModuleSource",kind:"page",why:"the empty page: apply a sketch held as text"}),Object.freeze({key:"applyRenderState",kind:"page",why:"the empty page: apply a renderState bag"}),Object.freeze({key:"displayResolution",kind:"page",why:"the empty page: the renderer the scene requires vs booted"})]);var Qp=null;function zy(){if(Qp)return Qp;if(typeof document>"u")throw new Error("[page-door] installPageDoor: the page door is a PAGE's \u2014 this realm has no document. (FAIL-LOUD.)");let e={};for(let t of uO)t.kind==="owner"&&Object.defineProperty(e,t.key,{enumerable:!0,get:t.read});return Qp=e,window.FrqtlPage=e,e}o(zy,"installPageDoor");function fO(e,t){if(!e||!e.documentElement||typeof e.documentElement.setAttribute!="function")throw new TypeError("[boot] createBootRecord(doc, ids): doc must be a Document");if(typeof e.dispatchEvent!="function")throw new TypeError("[boot] createBootRecord: the document has no dispatchEvent \u2014 the "+mp+" event is half of the published boot record");if(!Array.isArray(t)||t.length===0)throw new TypeError("[boot] createBootRecord: phaseIds must be a non-empty array (lib/shim/engine/boot-phases.js)");let r=Object.create(null);t.forEach(function(f){if(typeof f!="string"||!f||r[f])throw new TypeError("[boot] createBootRecord: phase ids must be unique non-empty strings (got "+JSON.stringify(f)+")");r[f]={done:0,total:0,complete:!1}});let i=null;function n(f){if(!r[f])throw new Error('[boot] boot record: "'+f+'" is not a boot phase \u2014 '+t.join(", ")+" (lib/shim/engine/boot-phases.js).");return r[f]}o(n,"phase");function a(){for(let f=0;f<t.length;f++)if(!r[t[f]].complete)return t[f];return t[t.length-1]}o(a,"current");function s(){let f={};t.forEach(function(h){let g=r[h];f[h]={done:g.done,total:g.total,complete:g.complete}});let u=a();return{phase:u,done:r[u].done,total:r[u].total,phases:f,failed:i}}o(s,"snapshot");function l(f,u){let h=f.ownerDocument?f.ownerDocument.defaultView:f.defaultView||null,g=h&&h.CustomEvent||CustomEvent;f.dispatchEvent(new g(mp,{detail:u}))}o(l,"dispatch");function c(){let f=s(),u=e.documentElement;u.setAttribute("data-egpt-boot-phase",f.phase),u.setAttribute("data-egpt-boot-done",String(f.done)),u.setAttribute("data-egpt-boot-total",String(f.total)),u.setAttribute("data-egpt-boot-progress",JSON.stringify(f.phases)),i&&u.setAttribute("data-egpt-boot-failed",i),l(e,f);let h=null;try{h=e.defaultView?e.defaultView.frameElement:null}catch{h=null}return h&&typeof h.dispatchEvent=="function"&&l(h,s()),f}return o(c,"publish"),{begin:o(function(f,u){let h=n(f);if(typeof u!="number"||u<0||Math.floor(u)!==u)throw new TypeError('[boot] boot record: begin("'+f+'", total) needs a non-negative integer');return h.total=u,c()},"begin"),step:o(function(f){let u=n(f);if(u.done>=u.total)throw new Error('[boot] boot record: "'+f+'" stepped past its total '+u.total);return u.done++,c()},"step"),complete:o(function(f){let u=n(f);return u.done=u.total,u.complete=!0,c()},"complete"),fail:o(function(f){return n(f),i||(i=f),c()},"fail"),snapshot:s}}o(fO,"createBootRecord");function Xp(e){return String(e&&e.message?e.message:e)}o(Xp,"_detail");function hO(e,t){return"ENGINE BOOT FAILED \u2014 engine="+e+`
|
|
61
61
|
|
|
62
|
-
WASM module failed to load: `+
|
|
62
|
+
WASM module failed to load: `+Xp(t)+`
|
|
63
63
|
|
|
64
64
|
This pane is intentionally blank. The requested engine is unavailable and the
|
|
65
65
|
page did NOT fall back to a different engine (that would make a JS\u2194WASM
|
|
66
66
|
comparison meaningless).
|
|
67
67
|
|
|
68
68
|
To build the canonical Rust/WASM engine:
|
|
69
|
-
cd frqtl && wasm-pack build crates/egpt_wasm --target web --out-dir ../fat/pkg-web`}o(
|
|
69
|
+
cd frqtl && wasm-pack build crates/egpt_wasm --target web --out-dir ../fat/pkg-web`}o(hO,"_engineText");function pO(e,t){return"RENDERER BOOT FAILED \u2014 renderer="+e+`
|
|
70
70
|
|
|
71
|
-
`+
|
|
71
|
+
`+Xp(t)+`
|
|
72
72
|
|
|
73
73
|
This pane is intentionally blank. The requested renderer is unavailable
|
|
74
74
|
and the page did NOT fall back to a different renderer.
|
|
75
75
|
|
|
76
|
-
Available renderers: `+Object.keys(
|
|
76
|
+
Available renderers: `+Object.keys(ds).join(" | ")+" | custom"}o(pO,"_rendererText");function qy(e,t){return"STACK BOOT FAILED \u2014 "+e+` phase
|
|
77
77
|
|
|
78
|
-
[boot] `+
|
|
78
|
+
[boot] `+Xp(t)+`
|
|
79
79
|
|
|
80
|
-
`+(e==="modules"?"A game-layer module did not load (the browser console names the URL that failed). Remedy: make the host serve it \u2014 the file is missing from this tree, or a built host's build did not copy it.":"The boot sequence stopped here and nothing after it ran.")}o(
|
|
80
|
+
`+(e==="modules"?"A game-layer module did not load (the browser console names the URL that failed). Remedy: make the host serve it \u2014 the file is missing from this tree, or a built host's build did not copy it.":"The boot sequence stopped here and nothing after it ran.")}o(qy,"_stackText");var Gc=Xg.filter(function(e){return e.key==="chrome"})[0];function dO(){let e=new URLSearchParams(location.search).get(Gc.key);if(!e)return;if(Gc.acceptedValues.indexOf(e)!==-1){document.documentElement.setAttribute("data-chrome",e);return}let t="[boot] Unknown ?"+Gc.key+'= value: "'+e+'". Accepted: '+Gc.acceptedValues.map(function(i){return'"'+i+'"'}).join(", ")+". Remove the param to use full chrome.";console&&console.error&&console.error(t);let r=document.createElement("div");r.id="egpt-chrome-error",r.style.cssText="position:fixed;inset:0;z-index:99999;background:#1a0000;color:#ff6b6b;font:13px/1.55 ui-monospace,monospace;padding:22px;white-space:pre-wrap;overflow:auto;border:2px solid #b6161c;",r.textContent=t,(document.body||document.documentElement).appendChild(r)}o(dO,"applyChrome");function mO(e,t){return Promise.resolve().then(function(){if(e==="custom"){let i=t&&t.provider,n=Vo(i);if(!n.ok)throw new Error("renderer=custom: the BYO provider is missing required method(s): "+n.missing.join(", ")+" (lib/frqtl/compat/renderer/renderer-provider-contract.js RENDERER_PROVIDER_REQUIRED).");return i}let r=ds[e];if(!r)throw new Error('unknown renderer "'+e+'" \u2014 the registry offers '+Object.keys(ds).join(" | ")+" (or custom with a BYO provider).");return e==="three"?xm({meshLoaders:!!(t&&t.meshLoaders)}).then(function(){return r.makeProvider()}):r.makeProvider()}).then(function(r){return gO(r,e),r})}o(mO,"selectRenderer");function gO(e,t){Hh(e,t),document.documentElement.setAttribute(vO,Si())}o(gO,"setDisplay");var vO="data-frqtl-renderer",Hc=null,ca=null,Jr=null;function Vy(){return Si()}o(Vy,"bootedRenderer");function yO(e,t){let r={name:e,failed:!1,promise:null};return r.promise=mO(e,t).then(function(i){return Jr.complete("renderer"),i},function(i){throw r.failed=!0,Jr.fail("renderer"),ra("renderer",pO(e,i)),i.frqtlBootPainted=!0,i.axis="renderer",i}),r.promise.catch(function(){}),r}o(yO,"_select");function bO(e){if(e=e||{},e.pageScripts!==void 0)throw new Error('[boot] bootRealm: `pageScripts` is retired \u2014 there are no classic scripts to load; a page imports its setup factory and helpers in its own module script (import { setupX } from "../../objects/setup/setupX.js"). (FAIL-LOUD.)');Zg(e.overlayHost||null);let t=new URLSearchParams(location.search),r=t.get(io.RENDERER)||e.renderer||(ca?ca.name:"p5");if(!Hc){dO();let a=t.get(io.ENGINE)||e.engine||"wasm";Jr=fO(document,dp),dp.forEach(function(f){Jr.begin(f,1)}),zy();let s=Promise.resolve().then(()=>(nc(),ic)).then(function(){Jr.complete("modules")},function(f){throw Jr.fail("modules"),ra("engine",qy("modules",f)),f.frqtlBootPainted=!0,f.axis="modules",f}),l=Vh(Tg,{engine:a});Hc=Promise.all([l,s]).then(function(f){return Jr.complete("engine-ready"),f[0]},function(f){throw f.frqtlBootPainted||(Jr.fail("engine-ready"),ra("engine",hO(a,f)),f.frqtlBootPainted=!0,f.axis="engine"),f}),Hc.catch(function(){})}(!ca||ca.failed||ca.name!==r)&&(ca=yO(r,e));let i=ca,n=Promise.all([Hc,i.promise]).then(function(a){return{engine:a[0],display:Si(),renderer:i.name}});return n.catch(function(){}),n}o(bO,"bootRealm");function By(e,t){return Qg(e,t,{knownNames:$h(ds)})}o(By,"applyRenderState");function Wy(e){if(e=e||{},e.sketch!==void 0&&e.sketch!=="deferred")throw new Error("[boot] bootPage: unknown sketch mode "+JSON.stringify(e.sketch)+" \u2014 the one mode is { sketch: 'deferred' }. (FAIL-LOUD.)");if(e.p5!==void 0&&e.p5!=="always")throw new Error("[boot] bootPage: unknown p5 mode "+JSON.stringify(e.p5)+" \u2014 the one mode is { p5: 'always' }. (FAIL-LOUD.)");if(e.setup!==void 0&&typeof e.setup!="function")throw new TypeError("[boot] bootPage: `setup` is the page's setup function (got "+typeof e.setup+"). (FAIL-LOUD.)");let t=e.sketch==="deferred",r=Object.assign({},e);delete r.setup,delete r.p5,delete r.sketch;let i=bO(r),n=i.then(function(s){return Om({setup:e.setup,p5:e.p5==="always"||s.renderer==="p5",onSetup:o(function(){t||Jr.complete("sketch")},"onSetup")}).catch(function(l){throw Jr.fail("sketch"),ra(s.renderer==="p5"||e.p5==="always"?"renderer":"engine",qy("sketch",l)),l.frqtlBootPainted=!0,l.axis="renderer",l})});n.catch(function(){});function a(s){if(!t)throw new Error("[boot] "+s+": this page did not defer its sketch \u2014 only a page that boots with bootPage({ sketch: 'deferred' }) completes the sketch phase itself. (FAIL-LOUD.)")}return o(a,"requireDeferred"),{realm:i,ready:n,completeSketch:o(function(){a("completeSketch"),Jr.complete("sketch")},"completeSketch"),failSketch:o(function(s){a("failSketch"),typeof console<"u"&&console.error&&console.error("[boot] the page's sketch failed:",s),Jr.fail("sketch")},"failSketch")}}o(Wy,"bootPage");var wO=Object.freeze({bootRecipe:'[doors] bootRecipe(mount, recipeSource, opts) is retired \u2014 boot a project: bootProject(mount, { files: { "sketch.js": recipeSource }, entry: "sketch.js" }, opts) (@descix/frqtl-web/boot, lib/frqtl/experiments/_shared/doors.js). (FAIL-LOUD.)'});function Ky(){throw new Error(wO.bootRecipe)}o(Ky,"bootRecipe");function uo(e,t,r){let i=document.createElement("div");i.setAttribute("data-egpt-artifact-error","1"),i.style.cssText="position:absolute;inset:0;font:12px/1.5 ui-monospace,Menlo,Consolas,monospace;white-space:pre-wrap;background:#1a0000;color:#ff6b6b;border:2px solid #b6161c;padding:14px;overflow:auto;z-index:9998;",i.textContent=t+`
|
|
81
81
|
|
|
82
|
-
`+r,e.innerHTML="",e.style&&(!e.style.position||e.style.position==="static")&&(e.style.position="relative"),e.appendChild(n)}o(ro,"paintError");function z1(e){if(typeof e=="string"){let t=document.getElementById(e);if(!t)throw new Error('[doors] mount element id "'+e+'" not found.');return t}if(!e||typeof e.appendChild!="function")throw new Error("[doors] mount must be a DOM element or its id.");return e}o(z1,"resolveMount");function vy(e,t){let r=z1(e);r.innerHTML="";let n=document.createElement("div");return n.setAttribute("data-role",t),n.id=t+"-"+Math.random().toString(36).slice(2),r.appendChild(n),{host:r,canvasHost:n}}o(vy,"mountCanvasHost");function yy(e,t){if(t!=="p5"&&t!=="three")throw new Error("[doors] "+e+': renderer "'+t+'" is invalid (expected "p5" | "three").');return t}o(yy,"assertRenderer");function by(e,t,r){let n=Object.keys(t).filter(function(i){return r.indexOf(i)===-1});if(n.length)throw new Error("[doors] "+e+": unknown option(s) "+n.join(", ")+" (accepted: "+r.join(", ")+"). The world \u2014 its size, 3D-ness and physics \u2014 is the sketch's own co-init call; the package copy a page boots from is the one it imported this module from. (FAIL-LOUD.)")}o(by,"refuseStray");var py=15e3;function wy(e){let t=e.host,r=e.label;return new Promise(function(n,i){let a=null;function s(){let l;try{l=new St({canvasParentId:e.canvasHost.id,seed:e.seed,onTick:e.onTick}),l.build(e.sketch),l.runner.universe.fundamentalDimension,a.completeSketch()}catch(c){a.failSketch(c),ro(t,"FRQTL "+r+" SETUP FAILED",String(c&&c.stack||c)),i(c);return}let u=l.runner,f;try{u.start(),f=e.afterStart(u,l)||{}}catch(c){u.stop(),ro(t,"FRQTL "+r+" SETUP FAILED",String(c&&c.stack||c)),i(c);return}u.firstTick({deadlineMs:py}).then(function(){let c={runner:u,recipeContext:l,display:fy()};Object.keys(f).forEach(function(h){c[h]=f[h]}),n(c)},function(c){let h=new Error("[doors] "+r.toLowerCase()+": FIRST_TICK_DEADLINE_MS = "+py+" ms \u2014 "+String(c&&c.message||c));ro(t,"FRQTL "+r+" NEVER TICKED",String(h.stack||h)),i(h)})}o(s,"setup"),a=dy(Object.assign({p5:"always",sketch:"deferred",setup:s},e.bootOpts)),a.ready.catch(function(l){ro(t,"FRQTL "+r+" BOOT FAILED",String(l&&l.stack||l)),i(l)})})}o(wy,"runSketch");var my=null;function _y(e){let t=my;if(t&&t.state==="pending")throw new Error("[doors] "+e+": a boot through "+t.door+" is IN PROGRESS in this document; await its promise. When it resolves, show another scene through the facade it returns (recipeContext.build); if it rejects, this document cannot host a second attempt. (FAIL-LOUD.)");if(t&&t.state==="failed")throw new Error("[doors] "+e+": a boot through "+t.door+" was attempted in this document and FAILED; the stack cannot be re-booted in the same document \u2014 open a fresh document. (FAIL-LOUD.)");if(t)throw new Error("[doors] "+e+": this document already booted the FRQTL stack (through "+t.door+"). One engine stack per document \u2014 there is no dispose(). To show another scene, use the facade the first boot returned: recipeContext.build(buildExperiment) \u2014 for a project, build(await linkProject({ files, entry, mint })) (same runner, same canvas); a different world size needs a fresh document. (FAIL-LOUD.)");let r={door:e,state:"pending"};return my=r,o(function(i){return i.then(function(a){return r.state="booted",a},function(a){throw r.state="failed",a})},"settle")}o(_y,"claimDocument");function V1(e){return!e||typeof e!="object"?Promise.reject(new Error("[doors] linkInPage(project): project is { files } or { url } (+ entry when it carries no frqtl.json) (got "+typeof e+"). (FAIL-LOUD.)")):Xa(Object.assign({},e,e.mint===void 0?{mint:Ql}:{}))}o(V1,"linkInPage");var q1=Object.freeze(["renderer","seed","onTick","render"]),B1=Object.freeze(["renderState","seed","onTick"]);function xy(e,t,r){let n;try{n=_y("bootScene")}catch(i){return Promise.reject(i)}return n(W1(e,t,r||{}))}o(xy,"bootScene");async function W1(e,t,r){let n=vy(e,"frqtl-scene-canvas"),i;try{if(typeof t!="function")throw new Error('[doors] bootScene(mount, sketch, opts): `sketch` must be the scene\'s buildExperiment(exp) function \u2014 a sketch held as text is a project: bootProject(mount, { files: { "sketch.js": text }, entry: "sketch.js" }). (got '+typeof t+")");by("bootScene",r,q1),i=yy("bootScene",r.renderer===void 0?"p5":r.renderer)}catch(a){throw ro(n.host,"FRQTL SCENE BOOT FAILED",String(a&&a.stack||a)),a}return wy({host:n.host,canvasHost:n.canvasHost,label:"SCENE",sketch:t,bootOpts:{renderer:i,overlayHost:n.host},seed:r.seed!==void 0?r.seed:42,onTick:typeof r.onTick=="function"?r.onTick:function(){},afterStart:o(function(a){r.render!==void 0&&a.setRenderOptions(r.render)},"afterStart")})}o(W1,"bootSceneClaimed");function md(e,t,r){let n;try{n=_y("bootProject")}catch(i){return Promise.reject(i)}return n(G1(e,t,r||{}))}o(md,"bootProject");async function G1(e,t,r){let n=vy(e,"frqtl-project-canvas"),i,a,s,l;try{if(!t||typeof t!="object"||typeof t=="function")throw new Error("[doors] bootProject(mount, project, opts): project is { files } or { url } (+ entry when it carries no frqtl.json) (a sketch function boots through bootScene). (got "+typeof t+")");by("bootProject",r,B1),i=ql(r.renderState||null),a=yy("bootProject",i.renderer||"p5"),s=await V1(t),l=await Wg({files:s.files})}catch(u){throw ro(n.host,"FRQTL PROJECT BOOT FAILED",String(u&&u.stack||u)),u}return wy({host:n.host,canvasHost:n.canvasHost,label:"PROJECT",sketch:s,bootOpts:{renderer:a,overlayHost:n.host},seed:r.seed!==void 0?r.seed:i.seed!=null?Number(i.seed):42,onTick:typeof r.onTick=="function"?r.onTick:function(){},afterStart:o(function(u){u.setSourceSha256(l);let f=hy(u,i);if(f.camera==="retained")throw new Error('[doors] bootProject: renderState camera preset "'+f.preset+'" is not offered by the booted camera (cameraControl.presets). (FAIL-LOUD.)');return{retainedRenderRows:f.retained}},"afterStart")})}o(G1,"bootProjectClaimed");Ll();Bu();Us();$r();Ut();Fc();Qc();Ra();vl();wf();wr();Ma();Ef();Uf();Gf();Dl();Oo();Yf();Qf();qo();Al();Vo();yn();var gd={};Oe(gd,{makeControlRegistry:()=>K1});ol();function Oy(e){return typeof e=="string"&&e.length>0}o(Oy,"_isValidName");function K1(){var e=Object.create(null),t=Object.create(null);function r(m,b,y){if(!Oy(m))throw new Error("[controls/registry] registerObject: name must be a non-empty string; got "+JSON.stringify(m)+". (FAIL-LOUD.)");if(b==null)throw new Error('[controls/registry] registerObject("'+m+'"): instance must not be null/undefined. (FAIL-LOUD.)');if(e[m])throw new Error('[controls/registry] registerObject: id collision \u2014 "'+m+'" is already registered (existing kind: "'+(e[m].kind||"unknown")+'"). Call unregisterObject("'+m+'") first, or choose a different name. (FAIL-LOUD \u2014 never a silent overwrite.)');e[m]={instance:b,kind:y||null}}o(r,"registerObject");function n(m){var b=e[m];if(!b)throw new Error('[controls/registry] getObject: no object registered for "'+String(m)+'". Registered: ['+s().join(", ")+"]. (FAIL-LOUD.)");return b.instance}o(n,"getObject");function i(m){var b=e[m];if(!b)throw new Error('[controls/registry] getObjectKind: no object registered for "'+String(m)+'". Registered: ['+s().join(", ")+"]. (FAIL-LOUD.)");return b.kind}o(i,"getObjectKind");function a(m){return!!e[m]}o(a,"hasObject");function s(){return Object.keys(e)}o(s,"objectNames");function l(m){if(!e[m])throw new Error('[controls/registry] unregisterObject: no object registered for "'+String(m)+'". (FAIL-LOUD.)');delete e[m]}o(l,"unregisterObject");function u(m,b){if(!Oy(m))throw new Error("[controls/registry] registerControls: name must be a non-empty string; got "+JSON.stringify(m)+". (FAIL-LOUD.)");if(t[m])throw new Error('[controls/registry] registerControls: id collision \u2014 "'+m+'" already has controls registered. Call unregisterControls("'+m+'") first, or choose a different name. (FAIL-LOUD \u2014 never a silent overwrite.)');if(!Array.isArray(b))throw new Error('[controls/registry] registerControls("'+m+'"): descriptors must be an array. (FAIL-LOUD.)');for(var y=[],w=Object.create(null),O=0;O<b.length;O++){var S=mp(b[O]);if(w[S.id])throw new Error('[controls/registry] registerControls("'+m+'"): duplicate control id "'+S.id+'" within the same array at index '+O+". (FAIL-LOUD.)");w[S.id]=!0,y.push(S)}return t[m]=y,y}o(u,"registerControls");function f(m){var b=t[m];if(!b)throw new Error('[controls/registry] getControls: no controls registered for "'+String(m)+'". Registered: ['+h().join(", ")+"]. (FAIL-LOUD.)");return b}o(f,"getControls");function c(m){return!!t[m]}o(c,"hasControls");function h(){return Object.keys(t)}o(h,"controlNames");function g(m){if(!t[m])throw new Error('[controls/registry] unregisterControls: no controls registered for "'+String(m)+'". (FAIL-LOUD.)');delete t[m]}o(g,"unregisterControls");function p(){for(var m={},b=h(),y=0;y<b.length;y++)m[b[y]]=t[b[y]];return m}return o(p,"allControls"),{registerObject:r,getObject:n,getObjectKind:i,hasObject:a,objectNames:s,unregisterObject:l,registerControls:u,getControls:f,hasControls:c,controlNames:h,unregisterControls:g,allControls:p}}o(K1,"makeControlRegistry");var yd={};Oe(yd,{SUN_GODRAYS:()=>Y1,SUN_RENDER:()=>vd});var vd=Object.freeze({shape:"sphere",colorScheme:"warmcool",godrays:1.08,godrayDensity:1.085,glowIntensity:.93,heat:.35,smoke:0}),Y1=Object.freeze({godrays:vd.godrays,godrayDensity:vd.godrayDensity});va();var bd={};Oe(bd,{collisionMatrixLanes:()=>Q1});var Ey=[Math.pow(2,-12),Math.pow(2,-9),Math.pow(2,-6),Math.pow(2,-3),Math.pow(2,-2),Math.pow(2,-1),1];function J1(e){if(!isFinite(e)||e<=0)throw new Error("[collisionMatrixLanes] capacity must be a positive number, got "+JSON.stringify(e)+". Read it back from the engine after building a body (universe.getFrameProperty(qid, 'mass')) \u2014 never assume it.");return Ey.map(function(t){return Math.max(1,Math.min(e,Math.round(t*e)))})}o(J1,"laneMassesForCapacity");var Q1={LANE_DENSITIES:Ey,laneMassesForCapacity:J1};var wd={};Oe(wd,{KINDS_EXPORTS:()=>X1,kindNamed:()=>ka,kindOf:()=>Xt,registerKind:()=>at,registeredKinds:()=>Aa});Et();var X1=Object.freeze(["registerKind","kindNamed","kindOf","registeredKinds"]);var Sy=Object.freeze({"frqtl/parts/index.js":jl,"frqtl/parts/CameraControls.js":qu,"frqtl/parts/CameraPath.js":Wu,"frqtl/parts/CollisionActions.js":zs,"frqtl/parts/CollisionTypes.js":Vs,"frqtl/parts/DetectorWall.js":Pc,"frqtl/parts/FrqtlControlOverlay.js":Jc,"frqtl/parts/FrqtlControlsPanel.js":Kc,"frqtl/parts/FrqtlVision.js":mf,"frqtl/parts/GraphingDetectorWall.js":bf,"frqtl/parts/LargeObject.js":hc,"frqtl/parts/LightColor.js":xf,"frqtl/parts/LiveChart.js":Of,"frqtl/parts/LogicGate.js":Mf,"frqtl/parts/OvenBox.js":Wf,"frqtl/parts/PointSource.js":Hf,"frqtl/parts/Rectangle.js":tc,"frqtl/parts/SlitLightSource.js":Kf,"frqtl/parts/SlitScreen.js":Jf,"frqtl/parts/SphereEmitter.js":Nf,"frqtl/parts/Trace.js":Ff,"frqtl/parts/Tunnel.js":If,"frqtl/parts/Wall.js":Lc,"shim/controls/registry.js":gd,"shim/render/sun-look.js":yd,"frqtl/compat/renderer/display-slot.js":li,"frqtl/compat/renderer/orbit-bag.js":Ai,"frqtl/objects/setup/_collisionMatrixLanes.js":bd,"frqtl/compat/engine.js":oh,"frqtl/objects/kinds-entry.js":wd}),Z1=Xg(Sy,"FRQTL.modules",Ql);function $1(e,t,r){return md(e,Object.assign({},t,{bare:Z1}),r)}o($1,"bootProject");return Dy(eO);})();
|
|
82
|
+
`+r,e.innerHTML="",e.style&&(!e.style.position||e.style.position==="static")&&(e.style.position="relative"),e.appendChild(i)}o(uo,"paintError");function _O(e){if(typeof e=="string"){let t=document.getElementById(e);if(!t)throw new Error('[doors] mount element id "'+e+'" not found.');return t}if(!e||typeof e.appendChild!="function")throw new Error("[doors] mount must be a DOM element or its id.");return e}o(_O,"resolveMount");function Yy(e,t){let r=_O(e);r.innerHTML="";let i=document.createElement("div");return i.setAttribute("data-role",t),i.id=t+"-"+Math.random().toString(36).slice(2),r.appendChild(i),{host:r,canvasHost:i}}o(Yy,"mountCanvasHost");function Jy(e,t){if(t!=="p5"&&t!=="three")throw new Error("[doors] "+e+': renderer "'+t+'" is invalid (expected "p5" | "three").');return t}o(Jy,"assertRenderer");function Qy(e,t,r){let i=Object.keys(t).filter(function(n){return r.indexOf(n)===-1});if(i.length)throw new Error("[doors] "+e+": unknown option(s) "+i.join(", ")+" (accepted: "+r.join(", ")+"). The world \u2014 its size, 3D-ness and physics \u2014 is the sketch's own co-init call; the package copy a page boots from is the one it imported this module from. (FAIL-LOUD.)")}o(Qy,"refuseStray");var Gy=15e3;function Xy(e){let t=e.host,r=e.label;return new Promise(function(i,n){let a=null;function s(){let l;try{l=new _t({canvasParentId:e.canvasHost.id,seed:e.seed,onTick:e.onTick}),l.build(e.sketch),l.runner.universe.fundamentalDimension,a.completeSketch()}catch(u){a.failSketch(u),uo(t,"FRQTL "+r+" SETUP FAILED",String(u&&u.stack||u)),n(u);return}let c=l.runner,f;try{c.start(),f=e.afterStart(c,l)||{}}catch(u){c.stop(),uo(t,"FRQTL "+r+" SETUP FAILED",String(u&&u.stack||u)),n(u);return}c.firstTick({deadlineMs:Gy}).then(function(){let u={runner:c,recipeContext:l,display:Vy()};Object.keys(f).forEach(function(h){u[h]=f[h]}),i(u)},function(u){let h=new Error("[doors] "+r.toLowerCase()+": FIRST_TICK_DEADLINE_MS = "+Gy+" ms \u2014 "+String(u&&u.message||u));uo(t,"FRQTL "+r+" NEVER TICKED",String(h.stack||h)),n(h)})}o(s,"setup"),a=Wy(Object.assign({p5:"always",sketch:"deferred",setup:s},e.bootOpts)),a.ready.catch(function(l){uo(t,"FRQTL "+r+" BOOT FAILED",String(l&&l.stack||l)),n(l)})})}o(Xy,"runSketch");var Hy=null;function Zy(e){let t=Hy;if(t&&t.state==="pending")throw new Error("[doors] "+e+": a boot through "+t.door+" is IN PROGRESS in this document; await its promise. When it resolves, show another scene through the facade it returns (recipeContext.build); if it rejects, this document cannot host a second attempt. (FAIL-LOUD.)");if(t&&t.state==="failed")throw new Error("[doors] "+e+": a boot through "+t.door+" was attempted in this document and FAILED; the stack cannot be re-booted in the same document \u2014 open a fresh document. (FAIL-LOUD.)");if(t)throw new Error("[doors] "+e+": this document already booted the FRQTL stack (through "+t.door+"). One engine stack per document \u2014 there is no dispose(). To show another scene, use the facade the first boot returned: recipeContext.build(buildExperiment) \u2014 for a project, build(await linkProject({ files, entry, mint })) (same runner, same canvas); a different world size needs a fresh document. (FAIL-LOUD.)");let r={door:e,state:"pending"};return Hy=r,o(function(n){return n.then(function(a){return r.state="booted",a},function(a){throw r.state="failed",a})},"settle")}o(Zy,"claimDocument");function xO(e){return!e||typeof e!="object"?Promise.reject(new Error("[doors] linkInPage(project): project is { files } or { url } (+ entry when it carries no frqtl.json) (got "+typeof e+"). (FAIL-LOUD.)")):ao(Object.assign({},e,e.mint===void 0?{mint:_c}:{}))}o(xO,"linkInPage");var OO=Object.freeze(["renderer","seed","onTick","render"]),EO=Object.freeze(["renderState","seed","onTick"]);function $y(e,t,r){let i;try{i=Zy("bootScene")}catch(n){return Promise.reject(n)}return i(SO(e,t,r||{}))}o($y,"bootScene");async function SO(e,t,r){let i=Yy(e,"frqtl-scene-canvas"),n;try{if(typeof t!="function")throw new Error('[doors] bootScene(mount, sketch, opts): `sketch` must be the scene\'s buildExperiment(exp) function \u2014 a sketch held as text is a project: bootProject(mount, { files: { "sketch.js": text }, entry: "sketch.js" }). (got '+typeof t+")");Qy("bootScene",r,OO),n=Jy("bootScene",r.renderer===void 0?"p5":r.renderer)}catch(a){throw uo(i.host,"FRQTL SCENE BOOT FAILED",String(a&&a.stack||a)),a}return Xy({host:i.host,canvasHost:i.canvasHost,label:"SCENE",sketch:t,bootOpts:{renderer:n,overlayHost:i.host},seed:r.seed!==void 0?r.seed:42,onTick:typeof r.onTick=="function"?r.onTick:function(){},afterStart:o(function(a){r.render!==void 0&&a.setRenderOptions(r.render)},"afterStart")})}o(SO,"bootSceneClaimed");function Zp(e,t,r){let i;try{i=Zy("bootProject")}catch(n){return Promise.reject(n)}return i(kO(e,t,r||{}))}o(Zp,"bootProject");async function kO(e,t,r){let i=Yy(e,"frqtl-project-canvas"),n,a,s,l;try{if(!t||typeof t!="object"||typeof t=="function")throw new Error("[doors] bootProject(mount, project, opts): project is { files } or { url } (+ entry when it carries no frqtl.json) (a sketch function boots through bootScene). (got "+typeof t+")");Qy("bootProject",r,EO),n=dc(r.renderState||null),a=Jy("bootProject",n.renderer||"p5"),s=await xO(t),l=await hv({files:s.files})}catch(c){throw uo(i.host,"FRQTL PROJECT BOOT FAILED",String(c&&c.stack||c)),c}return Xy({host:i.host,canvasHost:i.canvasHost,label:"PROJECT",sketch:s,bootOpts:{renderer:a,overlayHost:i.host},seed:r.seed!==void 0?r.seed:n.seed!=null?Number(n.seed):42,onTick:typeof r.onTick=="function"?r.onTick:function(){},afterStart:o(function(c){c.setSourceSha256(l);let f=By(c,n);if(f.camera==="retained")throw new Error('[doors] bootProject: renderState camera preset "'+f.preset+'" is not offered by the booted camera (cameraControl.presets). (FAIL-LOUD.)');return{retainedRenderRows:f.retained}},"afterStart")})}o(kO,"bootProjectClaimed");nc();yu();il();ti();Vt();hf();kf();Ia();ql();Jf();_r();Ba();$f();yh();Th();rc();Do();Rh();Lh();ts();Xl();es();wi();var $p={};ge($p,{makeControlRegistry:()=>TO});jl();function eb(e){return typeof e=="string"&&e.length>0}o(eb,"_isValidName");function TO(){var e=Object.create(null),t=Object.create(null);function r(m,b,y){if(!eb(m))throw new Error("[controls/registry] registerObject: name must be a non-empty string; got "+JSON.stringify(m)+". (FAIL-LOUD.)");if(b==null)throw new Error('[controls/registry] registerObject("'+m+'"): instance must not be null/undefined. (FAIL-LOUD.)');if(e[m])throw new Error('[controls/registry] registerObject: id collision \u2014 "'+m+'" is already registered (existing kind: "'+(e[m].kind||"unknown")+'"). Call unregisterObject("'+m+'") first, or choose a different name. (FAIL-LOUD \u2014 never a silent overwrite.)');e[m]={instance:b,kind:y||null}}o(r,"registerObject");function i(m){var b=e[m];if(!b)throw new Error('[controls/registry] getObject: no object registered for "'+String(m)+'". Registered: ['+s().join(", ")+"]. (FAIL-LOUD.)");return b.instance}o(i,"getObject");function n(m){var b=e[m];if(!b)throw new Error('[controls/registry] getObjectKind: no object registered for "'+String(m)+'". Registered: ['+s().join(", ")+"]. (FAIL-LOUD.)");return b.kind}o(n,"getObjectKind");function a(m){return!!e[m]}o(a,"hasObject");function s(){return Object.keys(e)}o(s,"objectNames");function l(m){if(!e[m])throw new Error('[controls/registry] unregisterObject: no object registered for "'+String(m)+'". (FAIL-LOUD.)');delete e[m]}o(l,"unregisterObject");function c(m,b){if(!eb(m))throw new Error("[controls/registry] registerControls: name must be a non-empty string; got "+JSON.stringify(m)+". (FAIL-LOUD.)");if(t[m])throw new Error('[controls/registry] registerControls: id collision \u2014 "'+m+'" already has controls registered. Call unregisterControls("'+m+'") first, or choose a different name. (FAIL-LOUD \u2014 never a silent overwrite.)');if(!Array.isArray(b))throw new Error('[controls/registry] registerControls("'+m+'"): descriptors must be an array. (FAIL-LOUD.)');for(var y=[],w=Object.create(null),x=0;x<b.length;x++){var S=Bd(b[x]);if(w[S.id])throw new Error('[controls/registry] registerControls("'+m+'"): duplicate control id "'+S.id+'" within the same array at index '+x+". (FAIL-LOUD.)");w[S.id]=!0,y.push(S)}return t[m]=y,y}o(c,"registerControls");function f(m){var b=t[m];if(!b)throw new Error('[controls/registry] getControls: no controls registered for "'+String(m)+'". Registered: ['+h().join(", ")+"]. (FAIL-LOUD.)");return b}o(f,"getControls");function u(m){return!!t[m]}o(u,"hasControls");function h(){return Object.keys(t)}o(h,"controlNames");function g(m){if(!t[m])throw new Error('[controls/registry] unregisterControls: no controls registered for "'+String(m)+'". (FAIL-LOUD.)');delete t[m]}o(g,"unregisterControls");function d(){for(var m={},b=h(),y=0;y<b.length;y++)m[b[y]]=t[b[y]];return m}return o(d,"allControls"),{registerObject:r,getObject:i,getObjectKind:n,hasObject:a,objectNames:s,unregisterObject:l,registerControls:c,getControls:f,hasControls:u,controlNames:h,unregisterControls:g,allControls:d}}o(TO,"makeControlRegistry");var td={};ge(td,{SUN_GODRAYS:()=>CO,SUN_RENDER:()=>ed});var ed=Object.freeze({shape:"sphere",colorScheme:"warmcool",godrays:1.08,godrayDensity:1.085,glowIntensity:.93,heat:.35,smoke:0}),CO=Object.freeze({godrays:ed.godrays,godrayDensity:ed.godrayDensity});Ea();var rd={};ge(rd,{collisionMatrixLanes:()=>RO});var tb=[Math.pow(2,-12),Math.pow(2,-9),Math.pow(2,-6),Math.pow(2,-3),Math.pow(2,-2),Math.pow(2,-1),1];function jO(e){if(!isFinite(e)||e<=0)throw new Error("[collisionMatrixLanes] capacity must be a positive number, got "+JSON.stringify(e)+". Read it back from the engine after building a body (universe.getFrameProperty(qid, 'mass')) \u2014 never assume it.");return tb.map(function(t){return Math.max(1,Math.min(e,Math.round(t*e)))})}o(jO,"laneMassesForCapacity");var RO={LANE_DENSITIES:tb,laneMassesForCapacity:jO};ul();bi();Gf();ln();wh();kh();In();Mn();$l();Bl();$o();ih();Da();hh();Io();Qu();sl();var rb=Object.freeze({"frqtl/parts/index.js":ic,"frqtl/parts/CameraControls.js":vu,"frqtl/parts/CameraPath.js":bu,"frqtl/parts/CollisionActions.js":nl,"frqtl/parts/CollisionTypes.js":al,"frqtl/parts/DetectorWall.js":ff,"frqtl/parts/FrqtlControlOverlay.js":Sf,"frqtl/parts/FrqtlControlsPanel.js":Of,"frqtl/parts/FrqtlVision.js":Wf,"frqtl/parts/GraphingDetectorWall.js":Yf,"frqtl/parts/LargeObject.js":Bu,"frqtl/parts/LightColor.js":Xf,"frqtl/parts/LiveChart.js":Zf,"frqtl/parts/LogicGate.js":vh,"frqtl/parts/OvenBox.js":Ah,"frqtl/parts/PointSource.js":Ch,"frqtl/parts/Rectangle.js":Cu,"frqtl/parts/SlitLightSource.js":jh,"frqtl/parts/SlitScreen.js":Dh,"frqtl/parts/SphereEmitter.js":gh,"frqtl/parts/Trace.js":mh,"frqtl/parts/Tunnel.js":ph,"frqtl/parts/Wall.js":cf,"shim/controls/registry.js":$p,"shim/render/sun-look.js":td,"frqtl/compat/renderer/display-slot.js":mn,"frqtl/compat/renderer/orbit-bag.js":Pn,"frqtl/objects/setup/_collisionMatrixLanes.js":rd,"frqtl/compat/engine.js":Bh,"frqtl/objects/kinds-entry.js":Vp,"frqtl/objects/objects/tagger.js":Ro,"frqtl/objects/schema/index.js":of,"shim/render/heat-colormap.js":Xo,"frqtl/objects/schema/valueNormalizer.js":qi,"frqtl/objects/objects/Box.js":bh,"frqtl/objects/objects/QuantumEmitter.js":Sh,"shim/expr/ast-schema.js":Zt,"frqtl/objects/objects/actionCompiler.js":Nn,"frqtl/objects/v1-replacements.js":xh,"frqtl/objects/objects/slitLinerScatter.js":Wa,"frqtl/objects/setup/setupSphereEmitter3D.js":ch,"frqtl/objects/objects/directedRedirectProgram.js":Wl,"frqtl/compat/renderer/lo-drawn-center.js":Bi,"frqtl/objects/setup/setupTunnelPointExit.js":fh,"frqtl/objects/constants/WallBehaviors.js":El,"frqtl/objects/objects/absorbRadiation.js":Fo,"frqtl/objects/geometry/SlabFace.js":Aa}),DO=bv(rb,"FRQTL.modules",_c);function LO(e,t,r){return Zp(e,Object.assign({},t,{bare:DO}),r)}o(LO,"bootProject");return lb(PO);})();
|
|
83
83
|
/**
|
|
84
84
|
* chroma.js - JavaScript library for color conversions
|
|
85
85
|
*
|