1import{r as g,j as M}from"./index-_Sg_1KT6.js";import{u as B}from"./useCanvas-DRXw8nFR.js";import{u as F}from"./useMouseInteraction-DqIzV1q4.js";import{E as X}from"./ExperimentControls-DmwC3FZh.js";import{E as A}from"./ExperimentMetrics-D-l2z47K.js";import{E as L}from"./ExperimentNav-CPfQyQAJ.js";const $=[{id:"closure",label:"closure()"},{id:"figure",label:"figure.ground()"},{id:"binding",label:"binding()"}],G={closure:"edges withheld // the mind completes the animal before the eye can prove it",figure:"ground and figure trade masks // vase becomes watcher becomes vessel",binding:"near things conspire // similarity stitches a hidden syntax"},S=(e,a,o)=>Math.min(o,Math.max(a,e)),Y=(e,a,o,r,l,t,s,n)=>{const i=t+l,m=t+Math.PI*2-l;e.save(),e.beginPath(),e.moveTo(a,o),e.arc(a,o,r,i,m),e.closePath(),e.fillStyle=n?"rgba(0, 4, 12, 0.95)":s,e.shadowColor=s,e.shadowBlur=n?3:18,e.fill(),e.restore()},q=(e,a,o)=>{e.save(),e.globalCompositeOperation="lighter",a.forEach((r,l)=>{const t=o-r.t,s=S(1-t/620,0,1),n=8+Math.sin(o*.05+l)*3+t*.035;e.strokeStyle=`rgba(255, 226, 138, ${s*.42})`,e.lineWidth=1,e.beginPath(),e.arc(r.x,r.y,n,0,Math.PI*2),e.stroke(),e.strokeStyle=`rgba(102, 255, 204, ${s*.7})`,e.beginPath(),e.moveTo(r.x-5,r.y),e.lineTo(r.x+5,r.y),e.moveTo(r.x,r.y-5),e.lineTo(r.x,r.y+5),e.stroke()}),e.restore()},D=(e,a,o,r,l)=>{const t=e.createLinearGradient(0,0,a,o);t.addColorStop(0,l?"rgba(16, 1, 18, 1)":"rgba(0, 6, 13, 1)"),t.addColorStop(.5,"rgba(0, 2, 8, 1)"),t.addColorStop(1,l?"rgba(3, 18, 18, 1)":"rgba(8, 3, 18, 1)"),e.fillStyle=t,e.fillRect(0,0,a,o),e.save(),e.globalAlpha=l?.12:.08,e.strokeStyle="#66ffcc",e.lineWidth=1;const s=34,n=r*.12%s;for(let i=-s;i<a+s;i+=s)e.beginPath(),e.moveTo(i+n,0),e.lineTo(i+n-o*.24,o),e.stroke();for(let i=-s;i<o+s;i+=s)e.beginPath(),e.moveTo(0,i-n),e.lineTo(a,i-n+a*.16),e.stroke();e.restore()},H=(e,a,o,r,l,t,s)=>{const n=a/2,i=o/2,m=Math.min(a,o)*.32,y=.72+t*.34,f=(l/Math.max(1,a)-.5)*.55,p=s?"rgba(255, 118, 194, 0.84)":"rgba(102, 255, 204, 0.88)",d=[{x:n,y:i-m*.82,rot:Math.PI/2+f},{x:n-m*.78,y:i+m*.54,rot:-Math.PI/6+f},{x:n+m*.78,y:i+m*.54,rot:Math.PI+Math.PI/6+f}];e.save(),e.globalCompositeOperation="lighter",e.strokeStyle=s?"rgba(255, 170, 220, 0.2)":"rgba(180, 255, 230, 0.22)",e.lineWidth=2,e.beginPath(),e.moveTo(d[0].x,d[0].y),e.lineTo(d[1].x,d[1].y),e.lineTo(d[2].x,d[2].y),e.closePath(),e.stroke();const c=e.createRadialGradient(n,i,12,n,i,m*1.15);c.addColorStop(0,s?"rgba(255, 102, 204, 0.14)":"rgba(255, 255, 210, 0.12)"),c.addColorStop(.68,s?"rgba(102, 255, 204, 0.055)":"rgba(102, 255, 204, 0.04)"),c.addColorStop(1,"rgba(0, 0, 0, 0)"),e.fillStyle=c,e.beginPath(),e.moveTo(d[0].x,d[0].y),e.lineTo(d[1].x,d[1].y),e.lineTo(d[2].x,d[2].y),e.closePath(),e.fill(),e.restore(),d.forEach((b,v)=>{Y(e,b.x,b.y,m*.31,y,b.rot+Math.sin(r*.018+v)*.06,p,s)}),e.save(),e.globalCompositeOperation="lighter",e.strokeStyle=s?"rgba(255, 226, 138, 0.38)":"rgba(102, 255, 204, 0.38)",e.lineWidth=1.3;for(let b=0;b<3;b+=1){const v=b*Math.PI*2/3+r*.01;e.beginPath(),e.arc(n,i,m*(.38+b*.18),v,v+Math.PI*.42),e.stroke()}e.restore()},j=(e,a,o,r,l)=>{const t=o*.17,s=o*.83,n=34+Math.sin(l*.018)*9,i=14+Math.cos(l*.021)*5;e.moveTo(a,t),e.bezierCurveTo(a+r*42,t+o*.05,a+r*24,t+o*.13,a+r*54,t+o*.2),e.bezierCurveTo(a+r*(n+28),t+o*.28,a+r*i,t+o*.35,a+r*48,t+o*.45),e.bezierCurveTo(a+r*74,t+o*.56,a+r*30,t+o*.66,a+r*58,s)},_=(e,a,o,r,l,t)=>{const s=a/2+l*42,n=Math.min(a,o)*.2;e.save(),e.fillStyle=t?"rgba(255, 226, 138, 0.9)":"rgba(102, 255, 204, 0.82)",e.shadowColor=t?"rgba(255, 226, 138, 0.8)":"rgba(102, 255, 204, 0.75)",e.shadowBlur=22,e.beginPath(),e.moveTo(s-n,o*.18),e.bezierCurveTo(s-n*.25,o*.27,s-n*.78,o*.44,s-n*.28,o*.5),e.bezierCurveTo(s-n*.84,o*.6,s-n*.22,o*.75,s-n*.9,o*.84),e.lineTo(s+n*.9,o*.84),e.bezierCurveTo(s+n*.22,o*.75,s+n*.84,o*.6,s+n*.28,o*.5),e.bezierCurveTo(s+n*.78,o*.44,s+n*.25,o*.27,s+n,o*.18),e.closePath(),e.fill(),e.restore(),e.save(),e.globalCompositeOperation=t?"source-over":"lighter",e.strokeStyle=t?"rgba(0, 4, 12, 0.78)":"rgba(255, 118, 194, 0.64)",e.lineWidth=3,e.shadowColor=t?"rgba(0, 4, 12, 0.4)":"rgba(255, 118, 194, 0.7)",e.shadowBlur=16,e.beginPath(),j(e,s-n*1.04,o,-1,r),e.stroke(),e.beginPath(),j(e,s+n*1.04,o,1,r),e.stroke(),e.restore(
1),e.save(),e.font="12px monospace",e.fillStyle=t?"rgba(0, 4, 12, 0.55)":"rgba(180, 255, 230, 0.42)",e.textAlign="center",e.fillText(l<0?"faces rise":l>0?"vessel holds":"double reading",a/2,o*.92),e.restore()},J=(e,a,o,r,l,t)=>{const i=a/12,m=o/9,y=t?["#ff77c9","#ffe28a","#66ffcc"]:["#66ffcc","#8ef5ff","#ffdd66"];e.save(),e.lineCap="round";for(let f=0;f<8;f+=1)for(let p=0;p<11;p+=1){const d=i*(p+1),c=m*(f+1),b=(p+Math.floor(f/2)+Math.round(l*3))%3,v=b===0?Math.PI/4:b===1?-Math.PI/4:Math.sin(r*.02+p*.7+f)*.8,C=Math.min(i,m)*(.34+b*.06);e.strokeStyle=y[b],e.globalAlpha=.42+b*.15,e.lineWidth=b===2?3.2:2,e.shadowColor=y[b],e.shadowBlur=b===2?13:7,e.beginPath(),e.moveTo(d-Math.cos(v)*C,c-Math.sin(v)*C),e.lineTo(d+Math.cos(v)*C,c+Math.sin(v)*C),e.stroke(),(p+f+b)%5===0&&(e.beginPath(),e.arc(d,c,2.5,0,Math.PI*2),e.fillStyle=y[(b+1)%y.length],e.fill())}e.restore(),e.save(),e.globalCompositeOperation="lighter",e.strokeStyle=t?"rgba(255, 226, 138, 0.24)":"rgba(102, 255, 204, 0.2)",e.lineWidth=1.4;for(let f=0;f<4;f+=1){const p=o*(.22+f*.17);e.beginPath();for(let d=0;d<=a;d+=18){const c=Math.sin(d*.018+r*.02+f)*(12+l*18);d===0?e.moveTo(d,p+c):e.lineTo(d,p+c)}e.stroke()}e.restore()},ee=({category:e,experiment:a})=>{const{canvasRef:o,ctx:r,dimensions:l}=B(),t=F(o),[s,n]=g.useState("closure"),[i,m]=g.useState(!1),[y,f]=g.useState(.45),[p,d]=g.useState("edges withheld // perception finishes the spell"),[c,b]=g.useState({ambiguity:50,fixations:0,closure:62,ground:"vessel"}),v=g.useRef(0),C=g.useRef([]),I=g.useCallback(u=>{n(u),d(G[u])},[]),R=g.useCallback(()=>{m(u=>{const h=!u;return d(h?"negative ground awakened // absence takes the lead":"positive ground restored // the seen thing steps forward"),h})},[]),z=g.useCallback(()=>{f(u=>{const h=u>=.85?.2:u+.13;return d(`occlusion veil set to ${Math.round(h*100)} // certainty thins`),h})},[]),O=g.useCallback(()=>{C.current=[],b(u=>({...u,fixations:0})),d("gaze archive cleared // the mirror forgets your trail")},[]),k=g.useCallback(u=>{const h=o.current;if(!h)return;const P=h.getBoundingClientRect(),w=u.clientX??u.touches?.[0]?.clientX??0,T=u.clientY??u.touches?.[0]?.clientY??0;C.current.push({x:w-P.left,y:T-P.top,t:v.current}),C.current.length>18&&C.current.shift(),d("attention mark archived // seeing becomes evidence")},[o]);g.useEffect(()=>{const u=o.current;if(u)return u.addEventListener("click",k),u.addEventListener("touchstart",k),()=>{u.removeEventListener("click",k),u.removeEventListener("touchstart",k)}},[o,k]);const E=g.useCallback(()=>{if(!r||l.width===0)return;v.current+=1;const u=v.current,h=t.positionRef.current.x||l.centerX,P=S((h/Math.max(1,l.width)-.5)*2,-1,1);if(D(r,l.width,l.height,u,i),s==="closure"?H(r,l.width,l.height,u,h,y,i):s==="figure"?_(r,l.width,l.height,u,P,i):J(r,l.width,l.height,u,y,i),q(r,C.current,u),u%14===0){const w=Math.round(Math.abs(P)*24+y*58+(i?14:5)),T=Math.round(S(88-y*44+C.current.length*1.5,18,96));b({ambiguity:w,fixations:C.current.length,closure:T,ground:i?"absence":P>.16?"vessel":P<-.16?"faces":"unstable"})}},[r,l.centerX,l.height,l.width,i,s,t.positionRef,y]);g.useEffect(()=>{if(!r||l.width===0)return;let u;const h=()=>{E(),u=requestAnimationFrame(h)};return u=requestAnimationFrame(h),()=>cancelAnimationFrame(u)},[r,l.width,E]);const N=g.useMemo(()=>[{label:"ambiguity",value:`${c.ambiguity}%`},{label:"fixations",value:c.fixations},{label:"closure",value:`${c.closure}%`},{label:"ground",value:c.ground}],[c]),W=[{id:"flip",label:"flip.figure()",onClick:R,active:i},{id:"occlude",label:"veil.shift()",onClick:z},{id:"clear",label:"clear.gaze()",onClick:O,variant:"reset"}];return M.jsxs("div",{className:"fixed inset-0 flex flex-col",children:[M.jsxs("header",{className:"relative z-50 flex items-center justify-between p-2 sm:p-4 border-b border-void-green/20 bg-void-dark/80 backdrop-blur-sm",children:[M.jsxs("div",{className:"flex items-center gap-2 sm:gap-4",children:[M.jsx(L,{currentCategory:e.slug,currentExperiment:a.slug}),M.jsx("h1",{className:"text-xl text-glow hidden sm:block",style:{color:a.color},children:a.name})]}),M.jsx(A,{metrics:N})]}),M.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-2 sm:gap-3 p-2 sm:p-4 border-b border-void-green/10 bg-void-dark/60 backdrop-blur-sm",children:[M.jsx(X,{modes:$,currentMode:s,onModeChange:I,controls:W}),M.jsx("p",{className:"text-void-green/50 text-xs sm:text-right max-w-lg",children:p})]}),M.jsx("div",{className:"flex-1 min-h-0 relative bg-void-dark",children:M.jsx("canvas",{ref:o,className:"absolute inset-0 w-full h-full cursor-crosshair","data-testid":"gestalt-mirror-canvas"})})]})};export{ee as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.