exodeui 6.3.41 → 6.3.42
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/dist/index.js +2 -2
- package/dist/index.mjs +12 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
`&&dt++)}),t.globalAlpha=yt}const st=o.paragraphRule;if(st&&(((ae=st.top)==null?void 0:ae.width)>0||((pe=st.bottom)==null?void 0:pe.width)>0)){let yt=0;(N||[]).forEach((Rt,_t)=>{var Vt,Bt;const $t=yt===0||yt<c.length&&(c[yt]===`
|
|
31
31
|
`||c[yt]==="\r");if($t&&_t>0&&yt++,$t){if(((Vt=st.top)==null?void 0:Vt.width)>0){const Ft=L+_t*A-st.top.offset;t.strokeStyle=st.top.color||"#000000",t.lineWidth=st.top.width,t.beginPath();const Ut=-n/2+A*.2;t.moveTo(Ut,Ft),t.lineTo(n/2-A*.2,Ft),t.stroke()}if(((Bt=st.bottom)==null?void 0:Bt.width)>0){const Ft=L+(_t+1)*A-st.bottom.offset;t.strokeStyle=st.bottom.color||"#000000",t.lineWidth=st.bottom.width,t.beginPath();const Ut=-n/2+A*.2;t.moveTo(Ut,Ft),t.lineTo(n/2-A*.2,Ft),t.stroke()}}yt+=(Rt.text||"").length})}if(e.stroke&&e.stroke.width>0){const yt=t.globalAlpha;e.fill&&e.fill.type!=="None"&&e.fill.isEnabled!==!1&&e.fill.opacity!==0&&e.fill.color!=="transparent"&&e.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.strokeStyle=e.stroke.color;let _t=1;if(this.rootTransform){const Vt=t.getTransform(),Bt=Math.sqrt(Vt.a*Vt.a+Vt.b*Vt.b)||1,Ft=this.rootTransform,Ut=Math.sqrt(Ft.a*Ft.a+Ft.b*Ft.b)||1;_t=Bt/Ut}else _t=(Math.abs(h)+Math.abs(l))/2||1;t.lineWidth=(e.stroke.width||1)/(_t||1),t.globalAlpha=yt*this.normalizeOpacity(e.stroke.opacity??100);let dt=0,$t=L;(N||[]).forEach(Vt=>{let Bt=-X/2;k==="center"?Bt=0:k==="right"&&(Bt=X/2),ot(Vt.text,Bt,$t,!0,dt),dt+=(Vt.text||"").length,$t+=A,dt<c.length&&(c[dt]===`
|
|
32
32
|
`||c[dt]==="\r")&&(_>0&&($t+=_),dt++,c[dt-1]==="\r"&&c[dt]===`
|
|
33
|
-
`&&dt++)}),t.globalAlpha=yt}}}applyStrokeAlignment(t,i,o,e,s,n,a=1,r=1){if(!i.stroke||i.stroke.width<=0||i.stroke.isEnabled===!1)return;const f=i.stroke;let h=1;if(this.rootTransform){const S=t.getTransform(),C=Math.sqrt(S.a*S.a+S.b*S.b)||1,w=this.rootTransform,M=Math.sqrt(w.a*w.a+w.b*w.b)||1;h=C/M}else h=(Math.abs(a)+Math.abs(r))/2||1;const l=(f.width||1)/(h||1),p=(f.alignment||"center").toLowerCase();if(t.save(),i.fill&&i.fill.type!=="None"&&i.fill.isEnabled!==!1&&i.fill.opacity!==0&&i.fill.color!=="transparent"&&i.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),f.fill){const S=this.createCanvasFill(t,f.fill,e,s);S?t.strokeStyle=S:t.strokeStyle=f.color||"#000000"}else t.strokeStyle=f.color||"#000000";const d=t.globalAlpha;t.globalAlpha=d*this.normalizeOpacity(f.opacity??100),t.lineWidth=l,t.lineCap=f.lineCap||"round",t.lineJoin=f.lineJoin||"round",f.miterLimit!==void 0&&(t.miterLimit=f.miterLimit);const u=f.trimStart??0,v=f.trimEnd??1,b=f.trimOffset??0,y=f.dashOffset??0,m=f.dashArray||[];if(u!==0||v!==1||b!==0){const S=this.getPerimeter(o,e,s);if(S>0){const C=Math.max(0,Math.min(1,u)),w=Math.max(0,Math.min(1,v));if(C<w){const M=S*(w-C),I=S-M,k=-(S*(C+b%1));t.setLineDash([M,I]),t.lineDashOffset=k+y*S}else if(C===w)t.setLineDash([0,S]);else{const M=S*(1-C+w),I=S-M,k=-(S*C);t.setLineDash([M,I]),t.lineDashOffset=k+y*S}}}else m.length>0&&(t.setLineDash(m),t.lineDashOffset=y);(o==null?void 0:o.type)==="Line"||e===0||s===0?(this.applyPath(t,o,e,s,n),t.stroke()):p==="inside"?(t.lineWidth=l*2,t.save(),this.applyPath(t,o,e,s,n),t.clip(),t.stroke(),t.restore()):p==="outside"?(t.lineWidth=l*2,this.applyPath(t,o,e,s,n),t.stroke(),t.save(),t.globalCompositeOperation="destination-out",this.applyPath(t,o,e,s,n),t.fill(),t.restore()):(t.lineWidth=l,this.applyPath(t,o,e,s,n),t.stroke()),t.restore()}getPerimeter(t,i,o){switch(this.ensurePathPoints(t),t==null?void 0:t.type){case"Rectangle":return(i+o)*2;case"Ellipse":{const e=Math.abs(i)/2,s=Math.abs(o)/2,n=Math.abs(t.sweepAngle??360),a=t.ratio||0,r=Math.PI*(3*(e+s)-Math.sqrt((3*e+s)*(e+3*s)));if(n>=360&&a<=0)return r;let f=n/360*r;if(a>0){const h=Math.PI*(3*(e*a+s*a)-Math.sqrt((3*e*a+s*a)*(e*a+3*s*a)));f+=n/360*h,n<360&&(f+=2*Math.sqrt((e-e*a)**2+(s-s*a)**2))}else n<360&&(f+=2*Math.max(e,s));return isNaN(f)?0:f}case"Line":return t.length||Math.sqrt(i*i+o*o);case"Triangle":return i+Math.sqrt((i/2)**2+o**2)*2;case"Polygon":{const e=t.sides||3,s=t.radius||Math.min(i,o)/2;return 2*e*s*Math.sin(Math.PI/e)}case"Star":{const e=t.points||5,s=t.outer_radius||Math.min(i,o)/2,n=t.inner_radius||s/2,a=Math.PI/e;return Math.sqrt(s*s+n*n-2*s*n*Math.cos(a))*e*2}case"Path":{const e=t.points||[];if(e.length<2)return t.length||0;let s=0,n=e[0].x,a=e[0].y;for(let r=1;r<e.length;r++){const f=e[r];if(f.moveTo){n=f.x,a=f.y;continue}const h=n,l=a,p=e[r-1].out_x,c=e[r-1].out_y;if(p!==void 0||f.in_x!==void 0?s+=this.getBezierLength(h,l,p??h,c??l,f.in_x??f.x,f.in_y??f.y,f.x,f.y):s+=Math.sqrt((f.x-h)**2+(f.y-l)**2),n=f.x,a=f.y,f.closePath||r===e.length-1&&(t.is_closed||t.isClosed)){const d=n,u=a,v=[...e.slice(0,r+1)].reverse().find(M=>M.moveTo)||e[0],b=v.x,y=v.y,m=e[r].out_x,S=e[r].out_y,C=v.in_x,w=v.in_y;m!==void 0||C!==void 0?s+=this.getBezierLength(d,u,m??d,S??u,C??b,w??y,b,y):s+=Math.sqrt((b-d)**2+(y-u)**2)}}return s}default:return(i+o)*2}}getBezierLength(t,i,o,e,s,n,a,r,f=10){let h=0,l=t,p=i;for(let c=1;c<=f;c++){const d=c/f,u=1-d,v=d*d,b=u*u,y=b*u,m=v*d,S=y*t+3*b*d*o+3*u*v*s+m*a,C=y*i+3*b*d*e+3*u*v*n+m*r,w=S-l,M=C-p;h+=Math.sqrt(w*w+M*M),l=S,p=C}return h}getBezierTAtLength(t,i,o,e,s,n,a,r,f,h=20){if(t<=0)return 0;let l=0,p=i,c=o;for(let d=1;d<=h;d++){const u=d/h,v=1-u,b=u*u,y=v*v,m=y*v,S=b*u,C=m*i+3*y*u*e+3*v*b*n+S*r,w=m*o+3*y*u*s+3*v*b*a+S*f,M=C-p,I=w-c,k=Math.sqrt(M*M+I*I);if(l+k>=t){const T=t-l,O=k===0?0:T/k;return(d-1+O)/h}l+=k,p=C,c=w}return 1}getPointOnPath(t,i,o,e){if(this.ensurePathPoints(t),(t==null?void 0:t.type)==="Path"){const s=t.points||[];if(s.length<2)return{x:0,y:0,angle:0};let n=1/0,a=-1/0,r=1/0,f=-1/0;s.forEach(y=>{typeof y.x=="number"&&typeof y.y=="number"&&(n=Math.min(n,y.x),a=Math.max(a,y.x),r=Math.min(r,y.y),f=Math.max(f,y.y),y.out_x!==void 0&&(n=Math.min(n,y.out_x),a=Math.max(a,y.out_x)),y.out_y!==void 0&&(r=Math.min(r,y.out_y),f=Math.max(f,y.out_y)),y.in_x!==void 0&&(n=Math.min(n,y.in_x),a=Math.max(a,y.in_x)),y.in_y!==void 0&&(r=Math.min(r,y.in_y),f=Math.max(f,y.in_y)))});const h=(n+a)/2,l=(r+f)/2,c=this.getPerimeter(t,i,o)*e;let d=0;const u=[];let v=s[0],b=s[0];for(let y=1;y<s.length;y++){const m=s[y];if(m.moveTo){v=m,b=m;continue}u.push({p0:v,p1:m}),(m.closePath||y===s.length-1&&(t.is_closed||t.isClosed))&&u.push({p0:m,p1:b}),v=m}for(const y of u){const m=y.p0,S=y.p1;let C=0;const w=m.out_x!==void 0||S.in_x!==void 0;if(w?C=this.getBezierLength(m.x,m.y,m.out_x??m.x,m.out_y??m.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y):C=Math.sqrt((S.x-m.x)**2+(S.y-m.y)**2),d+C>=c||y===u[u.length-1]){let M=0;if(w)return M=this.getBezierTAtLength(c-d,m.x,m.y,m.out_x??m.x,m.out_y??m.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y,20),this.getBezierPointAndAngle(M,m,S,h,l);{M=C===0?0:(c-d)/C;const I=m.x+(S.x-m.x)*M-h,k=m.y+(S.y-m.y)*M-l,T=Math.atan2(S.y-m.y,S.x-m.x);return{x:I,y:k,angle:T}}}d+=C}}else if(t.type==="Ellipse"){const s=Math.abs(i)/2,n=Math.abs(o)/2,a=t.sweepAngle??360,f=((t.startAngle??0)+a*e)*Math.PI/180,h=s*Math.cos(f),l=n*Math.sin(f),p=-s*Math.sin(f),c=n*Math.cos(f),d=Math.atan2(c,p);return{x:h,y:l,angle:d}}else if((t==null?void 0:t.type)==="Rectangle"){const s=Math.abs(i),n=Math.abs(o),r=(s+n)*2*e;let f=0,h=0,l=0;return r<s?(f=-s/2+r,h=-n/2,l=0):r<s+n?(f=s/2,h=-n/2+(r-s),l=Math.PI/2):r<2*s+n?(f=s/2-(r-(s+n)),h=n/2,l=Math.PI):(f=-s/2,h=n/2-(r-(2*s+n)),l=-Math.PI/2),{x:f,y:h,angle:l}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(t,i,o,e,s){const n=i.x,a=i.y,r=i.out_x??i.x,f=i.out_y??i.y,h=o.in_x??o.x,l=o.in_y??o.y,p=o.x,c=o.y,d=1-t,u=t*t,v=d*d,b=v*d,y=u*t,m=b*n+3*v*t*r+3*d*u*h+y*p-e,S=b*a+3*v*t*f+3*d*u*l+y*c-s,C=3*v*(r-n)+6*d*t*(h-r)+3*u*(p-h),w=3*v*(f-a)+6*d*t*(l-f)+3*u*(c-l),M=Math.atan2(w,C);return{x:m,y:S,angle:M}}applyAbsoluteTransform(t,i,o){if(!o.get(i))return;const s=[];let n=i;for(;n;){s.unshift(n);const a=o.get(n);n=a==null?void 0:a.parentId}s.forEach(a=>{this.applyObjectTransform(t,a)})}applyObjectTransform(t,i){var d,u,v;const o=this.objectStates.get(i);if(!o)return;t.translate(o.x,o.y),t.rotate((o.rotation??0)*Math.PI/180);const e=o.skew_x||0,s=o.skew_y||0;if(e!==0||s!==0){const b=Math.tan(e*Math.PI/180),y=Math.tan(s*Math.PI/180);t.transform(1+b*y,y,b,1,0,0)}const n=o.rotate_x!==void 0?o.rotate_x:((d=o.transform)==null?void 0:d.rotate_x)??0,a=o.rotate_y!==void 0?o.rotate_y:((u=o.transform)==null?void 0:u.rotate_y)??0,f=1+(o.translate_z!==void 0?o.translate_z:((v=o.transform)==null?void 0:v.translate_z)??0)/1e3,h=(o.flip_x===!0?-1:1)*Math.cos(a*Math.PI/180)*f,l=(o.flip_y===!0?-1:1)*Math.cos(n*Math.PI/180)*f,p=(o.scale_x??1)*h,c=(o.scale_y??1)*l;t.scale(p,c)}applyArtEffectOverlay(t,i,o,e,s,n){var c,d,u,v,b;const a=this.objectStates.get(i.id),r=((c=a==null?void 0:a.style)==null?void 0:c.artEffect)||i.artEffect||((d=i.style)==null?void 0:d.artEffect);if(!r||!r.enabled)return;const f=r.type,h=r.intensity??.5,l=r.speed??1,p=r.scale??10;if(f==="acid_gradient"||f==="acid_rave"||f==="shimmer"||f==="glint_overlay"||f==="halftone"||f==="noise"||f==="scanlines"||f==="chromatic_aberration"||f==="pixelate"||f==="glitch"||f==="fold_overlay"||f==="crumple_overlay"){if(t.save(),this.applyPath(t,o,e,s,n),t.clip(),f==="shimmer"){const m=this.currentTime*l%2/2,S=t.createLinearGradient(-e,-s,e,s);S.addColorStop(Math.max(0,m-.2),"rgba(255,255,255,0)"),S.addColorStop(m,`rgba(255,255,255,${h*.8})`),S.addColorStop(Math.min(1,m+.2),"rgba(255,255,255,0)"),t.fillStyle=S,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over"}else if(f==="glint_overlay"){let S=((this._lastPointerPos||{x:0}).x-(((u=i.transform)==null?void 0:u.x)??0)+300)/600;S=Math.max(-.2,Math.min(1.2,S));const C=t.createLinearGradient(-e,-s,e,s);C.addColorStop(Math.max(0,S-.15),"rgba(255,255,255,0)"),C.addColorStop(Math.max(0,Math.min(1,S)),`rgba(255,255,255,${h})`),C.addColorStop(Math.min(1,S+.15),"rgba(255,255,255,0)"),t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over"}else if(f==="fold_overlay"){const y=this._lastPointerPos||{x:0,y:0},m=y.x-(((v=i.transform)==null?void 0:v.x)??0),S=y.y-(((b=i.transform)==null?void 0:b.y)??0),C=t.createLinearGradient(m>0?-e/2:e/2,S>0?-s/2:s/2,m>0?e/2:-e/2,S>0?s/2:-s/2);C.addColorStop(0,`rgba(0,0,0,${h*.6})`),C.addColorStop(.4,"rgba(0,0,0,0)"),C.addColorStop(.5,`rgba(255,255,255,${h*.4})`),C.addColorStop(1,`rgba(0,0,0,${h*.2})`),t.fillStyle=C,t.globalCompositeOperation="overlay",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over",t.beginPath(),m>0&&S>0?(t.moveTo(e/2-40,s/2),t.lineTo(e/2,s/2-40),t.lineTo(e/2-40,s/2-40)):m<0&&S>0?(t.moveTo(-e/2+40,s/2),t.lineTo(-e/2,s/2-40),t.lineTo(-e/2+40,s/2-40)):m>0&&S<0?(t.moveTo(e/2-40,-s/2),t.lineTo(e/2,-s/2+40),t.lineTo(e/2-40,-s/2+40)):(t.moveTo(-e/2+40,-s/2),t.lineTo(-e/2,-s/2+40),t.lineTo(-e/2+40,-s/2+40)),t.closePath(),t.fillStyle="#ffffff",t.shadowColor="rgba(0,0,0,0.5)",t.shadowBlur=10,t.shadowOffsetX=m>0?-2:2,t.shadowOffsetY=S>0?-2:2,t.fill()}else if(f==="crumple_overlay"){const y=Math.floor(e/p),m=document.createElement("canvas");m.width=y,m.height=Math.floor(s/p);const S=m.getContext("2d"),C=S.createImageData(m.width,m.height);for(let w=0;w<C.data.length;w+=4){const M=Math.random()>.95?150:255;C.data[w]=M,C.data[w+1]=M,C.data[w+2]=M,C.data[w+3]=255*h}S.putImageData(C,0,0),t.globalCompositeOperation="multiply",t.imageSmoothingEnabled=!1,t.drawImage(m,-e/2,-s/2,e,s)}else if(f==="acid_gradient"||f==="acid_rave"){const y=this.currentTime*l,m=r.color1,S=r.color2,C=t.createLinearGradient(-e/2,-s/2,e/2,s/2);if(m&&S){const w=y*60%360;C.addColorStop(0,this._shiftHue(m,w,h*.7)),C.addColorStop(1,this._shiftHue(S,(w+180)%360,h*.7))}else{const w=y*100%360,M=(w+180)%360;C.addColorStop(0,`hsla(${w}, 80%, 50%, ${h*.5})`),C.addColorStop(1,`hsla(${M}, 80%, 50%, ${h*.5})`)}t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s)}else if(f==="halftone"){const y=Math.max(2,p*(1-h*.8)),m=document.createElement("canvas");m.width=y,m.height=y;const S=m.getContext("2d");if(S){S.fillStyle="black",S.beginPath(),S.arc(y/2,y/2,y/2*h,0,Math.PI*2),S.fill();const C=t.createPattern(m,"repeat");C&&(t.globalAlpha=.3*h,t.fillStyle=C,t.fillRect(-e/2,-s/2,e,s))}}else if(f==="noise"){const y=Math.floor(e*s*h*.02);t.globalAlpha=.4*h;for(let m=0;m<y;m++){const S=Math.random()>.5?255:0;t.fillStyle=`rgba(${S}, ${S}, ${S}, ${.5+Math.random()*.5})`,t.fillRect(-e/2+Math.random()*e,-s/2+Math.random()*s,2,2)}}else if(f==="scanlines"){t.globalAlpha=.2*h,t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1;for(let y=-s/2;y<s/2;y+=4)t.beginPath(),t.moveTo(-e/2,y),t.lineTo(e/2,y),t.stroke()}else if(f==="chromatic_aberration"){const y=5*h;t.globalCompositeOperation="screen",t.globalAlpha=.5,t.fillStyle="cyan",t.fillRect(-e/2-y,-s/2,e,s),t.fillStyle="magenta",t.fillRect(-e/2+y,-s/2,e,s)}else if(f==="pixelate"){const y=Math.max(2,Math.round(p*(1-h*.5))),m=document.createElement("canvas"),S=Math.max(1,Math.ceil(e/y)),C=Math.max(1,Math.ceil(s/y));m.width=S,m.height=C;const w=m.getContext("2d");if(w){w.imageSmoothingEnabled=!1;const M=t.getTransform(),I=M.e-e/2,k=M.f-s/2;w.drawImage(t.canvas,I,k,e,s,0,0,S,C),t.imageSmoothingEnabled=!1,t.drawImage(m,0,0,S,C,-e/2,-s/2,e,s),t.imageSmoothingEnabled=!0}}else if(f==="glitch"){const y=this.currentTime*l,m=r.chaosAmount??.2,S=Math.max(3,Math.floor(8*h)),C=h*e*.15;t.globalCompositeOperation="screen",t.globalAlpha=h*.4;const w=C*.3;t.fillStyle="rgba(255, 0, 0, 0.4)",t.fillRect(-e/2+w,-s/2,e,s),t.fillStyle="rgba(0, 255, 255, 0.4)",t.fillRect(-e/2-w,-s/2,e,s),t.globalCompositeOperation="source-over",t.globalAlpha=1;const M=s/S;for(let I=0;I<S;I++){const k=Math.sin(I*127.1+y*311.7*l)*43758.5,T=k-Math.floor(k);if(T>1-m){const O=(T-(1-m))/m*C*(Math.random()>.5?1:-1),P=-s/2+I*M,_=t.getTransform(),E=_.e-e/2+O,A=_.f+P;t.save(),t.beginPath(),t.rect(-e/2,P,e,M),t.clip(),t.globalAlpha=.8,t.drawImage(t.canvas,E,A,e,M,-e/2+O,P,e,M),t.restore()}}}t.restore()}}_shiftHue(t,i,o){let e=0,s=0,n=0;if(t.startsWith("#")){const c=t.replace("#","");e=parseInt(c.substring(0,2),16)/255,s=parseInt(c.substring(2,4),16)/255,n=parseInt(c.substring(4,6),16)/255}const a=Math.max(e,s,n),r=Math.min(e,s,n);let f=0,h=0,l=(a+r)/2;if(a!==r){const c=a-r;switch(h=l>.5?c/(2-a-r):c/(a+r),a){case e:f=((s-n)/c+(s<n?6:0))/6;break;case s:f=((n-e)/c+2)/6;break;case n:f=((e-s)/c+4)/6;break}}return`hsla(${(((f*360+i)%360+360)%360).toFixed(0)}, ${(h*100).toFixed(0)}%, ${(l*100).toFixed(0)}%, ${o})`}applyBackgroundBlurGlass(t,i,o,e,s,n){const a=n.radius??10,r=n.color??"rgba(255,255,255,0.2)",f=n.opacity!==void 0?this.normalizeOpacity(n.opacity):.5,h=n.noise??0;t.save(),this.applyPath(t,i,o,e,s),t.clip();const l=t.getTransform(),p=t.canvas;try{const d=document.createElement("canvas");d.width=Math.max(1,Math.ceil(o)),d.height=Math.max(1,Math.ceil(e));const u=d.getContext("2d");if(u){u.save(),u.translate(o/2,e/2);const v=n.magnification||1;if(v!==1&&u.scale(v,v),typeof l.inverse=="function"){const m=l.inverse();u.transform(m.a,m.b,m.c,m.d,m.e,m.f)}else{const m=l.a*l.d-l.b*l.c;m!==0&&u.transform(l.d/m,-l.b/m,-l.c/m,l.a/m,(l.c*l.f-l.d*l.e)/m,(l.b*l.e-l.a*l.f)/m)}u.drawImage(p,0,0),u.restore(),u.filter=`blur(${a}px)`;const b=document.createElement("canvas");b.width=d.width,b.height=d.height;const y=b.getContext("2d");y.filter=`blur(${a}px)`,y.drawImage(d,0,0),t.globalCompositeOperation="source-over",t.globalAlpha=1,t.drawImage(b,-o/2,-e/2,o,e)}}catch{}t.globalCompositeOperation="source-over",t.globalAlpha=f,t.fillStyle=r,t.fillRect(-o/2,-e/2,o,e),t.globalAlpha=1,t.globalCompositeOperation="source-atop";const c=t.createLinearGradient(-o/2,-e/2,o/2,e/2);if(c.addColorStop(0,"rgba(255,255,255,0.12)"),c.addColorStop(.3,"rgba(255,255,255,0.04)"),c.addColorStop(.5,"rgba(255,255,255,0.0)"),c.addColorStop(1,"rgba(255,255,255,0.0)"),t.fillStyle=c,t.fillRect(-o/2,-e/2,o,e),h>0){if(t.globalAlpha=h/100,!this._noiseTileCanvas){const u=document.createElement("canvas");u.width=64,u.height=64;const v=u.getContext("2d"),b=v.createImageData(64,64),y=b.data;for(let m=0;m<y.length;m+=4){const S=Math.floor(Math.random()*255);y[m]=S,y[m+1]=S,y[m+2]=S,y[m+3]=18}v.putImageData(b,0,0),this._noiseTileCanvas=u}const d=t.createPattern(this._noiseTileCanvas,"repeat");d&&(t.fillStyle=d,t.fillRect(-o/2,-e/2,o,e))}t.restore(),t.save(),t.globalAlpha=1,t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1.5,this.applyPath(t,i,o,e,s),t.stroke(),t.restore()}applyPath(t,i,o,e,s){i!=null&&i.data&&(i.type==="Path"||i.type==="Subtract"||i.type==="Union"||i.type==="Intersect"||i.type==="Exclude"||i.type),t.beginPath(),this._tracePath(t,i,o,e,s)}_tracePath(t,i,o,e,s){if(i){if(this.ensurePathPoints(i),(i==null?void 0:i.type)==="Rectangle"||i.type==="Image"){const n=s!==void 0?s:i.corner_radius??0;this.drawRoundRect(t,-o/2,-e/2,o,e,n)}else if(i.type==="Line")t.moveTo(-o/2,0),t.lineTo(o/2,0);else if(i.type==="Ellipse"){const{startAngle:n=0,sweepAngle:a=360,ratio:r=0}=i,f=o/2,h=e/2,l=n*Math.PI/180,p=a*Math.PI/180,c=l+p;a>=360&&r<=0?t.ellipse(0,0,f,h,0,0,Math.PI*2):(t.ellipse(0,0,f,h,0,l,c,!1),r>0?t.ellipse(0,0,f*r,h*r,0,c,l,!0):t.lineTo(0,0),t.closePath())}else if(i.type==="Triangle")t.moveTo(0,-e/2),t.lineTo(o/2,e/2),t.lineTo(-o/2,e/2),t.closePath();else if(i.type==="Polygon"){const n=i.sides||3,a=i.radius||Math.min(o,e)/2;for(let r=0;r<n;r++){const f=r*2*Math.PI/n-Math.PI/2,h=a*Math.cos(f),l=a*Math.sin(f);r===0?t.moveTo(h,l):t.lineTo(h,l)}t.closePath()}else if(i.type==="Star"){const n=i.points||5,a=i.outer_radius||Math.min(o,e)/2;let r=i.inner_radius;r==null?r=a*.382:r<=1&&(r=a*r);for(let f=0;f<n*2;f++){const h=f*Math.PI/n-Math.PI/2,l=f%2===0?a:r,p=l*Math.cos(h),c=l*Math.sin(h);f===0?t.moveTo(p,c):t.lineTo(p,c)}t.closePath()}else if(((i==null?void 0:i.type)==="Path"||i.type==="Subtract"||i.type==="Union"||i.type==="Intersect"||i.type==="Exclude"||i.type==="BooleanOperation")&&i.points){this.frameCount%300===0&&this.log("[Engine] Tracing Path:",i.points.length,"points");let n=1/0,a=-1/0,r=1/0,f=-1/0;if(i.points.forEach(p=>{typeof p.x=="number"&&typeof p.y=="number"&&(n=Math.min(n,p.x),a=Math.max(a,p.x),r=Math.min(r,p.y),f=Math.max(f,p.y),p.out_x!==void 0&&(n=Math.min(n,p.out_x),a=Math.max(a,p.out_x)),p.out_y!==void 0&&(r=Math.min(r,p.out_y),f=Math.max(f,p.out_y)),p.in_x!==void 0&&(n=Math.min(n,p.in_x),a=Math.max(a,p.in_x)),p.in_y!==void 0&&(r=Math.min(r,p.in_y),f=Math.max(f,p.in_y)))}),n===1/0)return;const h=(n+a)/2,l=(r+f)/2;if(isNaN(h)||isNaN(l)){this.warn("[Engine] Invalid path center:",h,l);return}i.points.forEach((p,c)=>{if(c===0||p.moveTo)t.moveTo(p.x-h,p.y-l);else{const d=i.points[c-1];if(!d)return;const u=(d.out_x??d.x)-h,v=(d.out_y??d.y)-l,b=(p.in_x??p.x)-h,y=(p.in_y??p.y)-l;isNaN(u)||isNaN(b)||isNaN(p.x)?t.lineTo(p.x-h,p.y-l):t.bezierCurveTo(u,v,b,y,p.x-h,p.y-l)}if(p.closePath||c===i.points.length-1&&(i.is_closed||i.isClosed)){const d=[...i.points.slice(0,c+1)].reverse().find(u=>u.moveTo)||i.points[0];d&&(p.out_x!==void 0||d.in_x!==void 0)&&t.bezierCurveTo((p.out_x??p.x)-h,(p.out_y??p.y)-l,(d.in_x??d.x)-h,(d.in_y??d.y)-l,d.x-h,d.y-l),t.closePath()}})}else if(i.points&&Array.isArray(i.points)){let n=1/0,a=-1/0,r=1/0,f=-1/0;i.points.forEach(p=>{n=Math.min(n,p.x),a=Math.max(a,p.x),r=Math.min(r,p.y),f=Math.max(f,p.y)});const h=(n+a)/2,l=(r+f)/2;i.points.forEach((p,c)=>{if(c===0)t.moveTo(p.x-h,p.y-l);else{const d=i.points[c-1];d.out_x!==void 0||p.in_x!==void 0?t.bezierCurveTo((d.out_x??d.x)-h,(d.out_y??d.y)-l,(p.in_x??p.x)-h,(p.in_y??p.y)-l,p.x-h,p.y-l):t.lineTo(p.x-h,p.y-l)}(p.closePath||c===i.points.length-1&&(i.is_closed||i.isClosed))&&t.closePath()})}}}renderInputBox(t,i){var L,R;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((L=i.geometry)==null?void 0:L.width)||250,n=((R=i.geometry)==null?void 0:R.height)||45,a=this.focusedId===i.id,r=this.lastHoveredObjectId===i.id,f=e.previewState||"default",h=f!=="default"?f:a?"focused":r?"hovered":"default",l=e.label||{visible:!0,text:"Label"},p=e.helperText||{visible:!1,text:"Helper text"},c=e.leftIcon||{visible:!1},d=e.rightIcon||{visible:!1},u=e.multiline===!0,v=e.corner_radius??8,b=e.corners||{tl:v,tr:v,bl:v,br:v},y=[b.tl,b.tr,b.br,b.bl];let m=e.backgroundColor||"rgba(31, 41, 55, 1)",S=e.borderColor||"rgba(55, 65, 81, 1)",C=e.borderWidth??1.5,w=e.color||"#ffffff",M=e.placeholderColor||"rgba(156, 163, 175, 1)",I=e.fontSize||14;const k=`${h}Style`,T=e[k];T?(T.backgroundColor!==void 0&&(m=T.backgroundColor),T.borderColor!==void 0&&(S=T.borderColor),T.borderWidth!==void 0&&(C=T.borderWidth),T.color!==void 0&&(w=T.color),T.placeholderColor!==void 0&&(M=T.placeholderColor),T.fontSize!==void 0&&(I=T.fontSize)):h==="focused"?(S=e.focusBorderColor||"rgba(59, 130, 246, 1)",C=Math.max(C,2)):h==="hovered"||h==="hover"?(S=e.hoverBorderColor||S,m=e.hoverBackgroundColor||m):h==="disabled"?(m=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",S=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):h==="error"&&(S="rgba(239, 68, 68, 1)",C=Math.max(C,2)),t.beginPath(),this.drawRoundRect(t,-s/2,-n/2,s,n,y);const O=this.createCanvasFill(t,m,s,n);if(O&&(t.fillStyle=O,t.fill()),C>0){const D=this.createCanvasFill(t,S,s,n);if(D&&(t.strokeStyle=D,t.lineWidth=C,t.stroke()),h==="focused"||h==="focus"){t.save(),t.beginPath();const q=y.map(ot=>ot+2);this.drawRoundRect(t,-s/2-2,-n/2-2,s+4,n+4,q),t.strokeStyle="rgba(59, 130, 246, 0.3)",t.lineWidth=2,t.stroke(),t.restore()}}const P=(D,q)=>{if(!D.visible||!D.svgPath)return;const ot=D.size||14,mt=D.offset??16,bt=D.color||"#ffffff",gt=q?-(s/2)+mt:s/2-mt,Et=D.svgPath;if(t.save(),t.translate(gt,0),!Et.startsWith("<svg")){const It=new Path2D(Et),vt=ot/24;t.scale(vt,vt),t.translate(-12,-12),t.fillStyle=bt,t.fill(It)}t.restore()};P(c,!0),P(d,!1);const _=e.text||"",E=e.placeholder||"Enter text...",A=!_,W=_||E,z=A?M:w,Y=I,G=e.fontFamily||"Inter",N=e.fontWeight||400;t.font=`${N} ${Y}px "${G}", sans-serif`,t.fillStyle=z,t.textAlign="left",t.textBaseline=u?"top":"middle";const J=e.inputPadding??16,x=c.visible?(c.offset??16)+(c.size||14)/2+8:J,F=d.visible?(d.offset??16)+(d.size||14)/2+8:J,j=-(s/2)+x,X=s-x-F,tt=e.inputType==="password"?"•".repeat(W.length):W;if(t.save(),t.beginPath(),t.rect(j-2,-n/2+4,X+4,n-8),t.clip(),u){const D=tt.split(`
|
|
34
|
-
`);let q=-n/2+J;const ot=Y*1.2;let mt=0;D.forEach((bt,gt)=>{const Et=bt.split(" ");let It="";for(let vt=0;vt<Et.length;vt++){const Dt=It+Et[vt]+" ";t.measureText(Dt).width>X&&vt>0?(t.fillText(It,j,q),It=Et[vt]+" ",q+=ot):It=Dt}t.fillText(It,j,q),mt=t.measureText(It).width,gt<D.length-1&&(q+=ot,mt=0)}),a&&!A&&Math.floor(performance.now()/500)%2===0&&t.fillRect(j+mt,q,1.5,Y)}else{const q=t.measureText(tt).width;let ot=0;if(q>X&&(ot=q-X),t.fillText(tt,j-ot,0),a&&!A&&Math.floor(performance.now()/500)%2===0){const bt=j+q-ot;t.fillRect(bt,-(Y/2),1.5,Y)}}if(t.restore(),l.visible!==!1){const D=l.text||"Label",q=l.fontSize||12,ot=l.color||"rgba(156, 163, 175, 1)",mt=l.offset??8;t.font=`600 ${q}px "${G}", sans-serif`,t.fillStyle=ot,t.textAlign="left",t.textBaseline="bottom";const bt=-(s/2),gt=-(n/2)-mt;t.fillText(D,bt,gt)}if(p.visible===!0){const D=p.text||"Helper text",q=p.fontSize||11,ot=h==="error"?"rgba(239, 68, 68, 1)":p.color||"rgba(156, 163, 175, 1)",mt=p.offset??6;t.font=`400 ${q}px "${G}", sans-serif`,t.fillStyle=ot,t.textAlign="left",t.textBaseline="top";const bt=-(s/2),gt=n/2+mt;t.fillText(D,bt,gt)}}renderSlider(t,i){const o=this.objectStates.get(i.id),e=(o==null?void 0:o.geometry)||i.geometry,s=(o==null?void 0:o.options)||i.options||{},n=e.width||200,a=s.value??50,r=s.min??0,h=(s.max??100)-r,l=h===0?0:(a-r)/h,p=s.trackHeight||4,c=s.trackRoundedness??2,d=s.trackShape??"Rectangle",u=s.trackPath||"",v=s.accentColor||"#3b82f6",b=s.inactiveColor||"#374151",y=s.thumbShape||"Ellipse",m=s.thumbWidth??16,S=s.thumbHeight??16,C=s.thumbRoundedness??0,w=s.thumbColor||"#ffffff",M=s.thumbPath||"",I=s.thumbIcon||"",k=s.showValueTooltip??!1,T=s.tooltipBgColor||"#333333",O=s.tooltipColor||"#ffffff",P=s.tooltipOffsetX??0,_=s.tooltipOffsetY??-25,E=(X,tt,L,R,D,q,ot)=>{if((X==="Custom"||X==="Icon")&&ot)try{const mt=new Path2D(ot);if(t.save(),t.translate(tt,L),X==="Icon"){const bt=Math.min(R,D)/24;t.scale(bt,bt),t.translate(-12,-12)}t.fill(mt),t.restore();return}catch(mt){console.error("Error drawing slider shape in engine:",mt)}if(t.beginPath(),X==="Ellipse")t.ellipse(tt,L,R/2,D/2,0,0,Math.PI*2);else if(X==="Rectangle")this.drawRoundRect(t,tt-R/2,L-D/2,R,D,q);else if(X==="Triangle")t.moveTo(tt,L-D/2),t.lineTo(tt+R/2,L+D/2),t.lineTo(tt-R/2,L+D/2),t.closePath();else if(X==="Diamond")t.moveTo(tt,L-D/2),t.lineTo(tt+R/2,L),t.lineTo(tt,L+D/2),t.lineTo(tt-R/2,L),t.closePath();else if(X==="Polygon"){const mt=i.geometry.sides||3,bt=i.geometry.radius||Math.min(R,D)/2;for(let gt=0;gt<mt;gt++){const Et=gt*2*Math.PI/mt-Math.PI/2,It=tt+bt*Math.cos(Et),vt=L+bt*Math.sin(Et);gt===0?t.moveTo(It,vt):t.lineTo(It,vt)}t.closePath()}else if(X==="Star"){const bt=Math.min(R,D)/2,gt=bt/2;for(let Et=0;Et<10;Et++){const It=Et%2===0?bt:gt,vt=Et*Math.PI/5-Math.PI/2;t.lineTo(tt+It*Math.cos(vt),L+It*Math.sin(vt))}t.closePath()}else X==="Line"&&(t.moveTo(tt-R/2,L),t.lineTo(tt+R/2,L));t.fill()},A=this.createCanvasFill(t,b,n,p);A&&(t.fillStyle=A,t.strokeStyle=A),d==="Line"?(t.lineWidth=p,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(n/2,0),t.stroke()):E(d,0,0,n,p,c,u);const W=n-m,z=-n/2+m/2+l*W,Y=z- -n/2;if(Y>0){const X=this.createCanvasFill(t,v,n,p);X&&(t.fillStyle=X,t.strokeStyle=X),d==="Line"?(t.lineWidth=p,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(z,0),t.stroke()):d==="Rectangle"&&(t.beginPath(),this.drawRoundRect(t,-n/2,-p/2,Y,p,c),t.fill())}t.save(),t.translate(z,0);const G=t.getTransform(),N=Math.sqrt(G.a*G.a+G.b*G.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*N,t.shadowOffsetY=1*N;const J=this.createCanvasFill(t,w,m,S);if(J&&(t.fillStyle=J),E(y,0,0,m,S,C,y==="Icon"?I:M),t.restore(),k){t.save(),t.translate(z+P,_);const X=Math.round(a).toString();t.font="10px Inter, sans-serif";const tt=t.measureText(X),L=6,R=4,D=tt.width+L*2,q=14+R;t.beginPath(),this.drawRoundRect(t,-D/2,-q/2,D,q,4),t.fillStyle=T,t.fill(),t.fillStyle=O,t.textAlign="center",t.textBaseline="middle",t.fillText(X,0,0),t.restore()}const x=s.label||{},F=s.helperText||{},j=s.fontFamily||"Inter";if(x.visible!==!1){const X=x.text||"Label",tt=x.fontSize||12,L=x.color||"rgba(156, 163, 175, 1)",R=x.offset??8;t.font=`600 ${tt}px "${j}", sans-serif`,t.fillStyle=L,t.textAlign="left",t.textBaseline="bottom";const D=-(n/2),q=-(p/2)-R;t.fillText(X,D,q)}if(F.visible===!0){const X=F.text||"Helper text",tt=F.fontSize||11,L=F.color||"rgba(156, 163, 175, 1)",R=F.offset??6;t.font=`400 ${tt}px "${j}", sans-serif`,t.fillStyle=L,t.textAlign="left",t.textBaseline="top";const D=-(n/2),q=p/2+R;t.fillText(X,D,q)}}renderDropdown(t,i){var _;const o=this.objectStates.get(i.id);if(!o)return;const e=o.options||i.options||{},s=i.geometry.width||160,n=i.geometry.height||40,a=-s/2,r=-n/2,f=e.corner_radius??6,h=e.disabled||e.previewState==="disabled",l=this.lastHoveredObjectId===i.id||e.previewState==="hover",p=(e.isOpen||e.previewState==="active")&&!h;let c=e.backgroundColor,d=e.borderColor,u=e.color||"#333333";h?(c=e.disabledBackgroundColor||"#f3f4f6",d=e.disabledBorderColor||"#e5e7eb",u=e.disabledColor||"#9ca3af"):p?(c=e.activeBackgroundColor||c,d=e.activeBorderColor||d,u=e.activeColor||u):l&&(c=e.hoverBackgroundColor||c,d=e.hoverBorderColor||d,u=e.hoverColor||u),c||(c="#ffffff"),d||(d="#e5e7eb");const v=t.globalAlpha;t.globalAlpha=v*(e.opacity??1),this.drawRoundRect(t,a,r,s,n,f),t.fillStyle=this.createCanvasFill(t,typeof c=="string"?{type:"Solid",color:c}:c,s,n)||"#ffffff",t.fill();const b=e.borderWidth??1;b>0&&(t.strokeStyle=this.createCanvasFill(t,typeof d=="string"?{type:"Solid",color:d}:d,s,n)||"#e5e7eb",t.lineWidth=b,t.stroke());const y=12,m=e.chevronType||"chevron",S=e.chevronSize||16,C=(p?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(m!=="none"){const E=a+s-y-S/2;t.save(),t.translate(E,0);const A=p?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(A*Math.PI/180),t.strokeStyle=C,t.fillStyle=C,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",m==="chevron")t.beginPath(),t.moveTo(-S/2,-S*.2),t.lineTo(0,S*.2),t.lineTo(S/2,-S*.2),t.stroke();else if(m==="custom"||m==="path"){const W=p&&e.openIconPath||e.closedIconPath;if(W){const z=new Path2D(W);t.save();const Y=S/24;t.scale(Y,Y),t.translate(-12,-12),t.fill(z),t.restore()}}t.restore()}const w=e.selectedOption||e.placeholder||"Select...",M=e.fontSize||14,I=e.fontWeight||400,k=e.fontFamily||"Inter, sans-serif";t.font=`${I} ${M}px ${k}`;const T=h?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":u;t.fillStyle=this.createCanvasFill(t,typeof T=="string"?{type:"Solid",color:T}:T,s,n)||"#333333",t.textAlign="left",t.textBaseline="middle";const O=m==="none"?0:S+8,P=s-y*2-O;if(t.save(),t.beginPath(),t.rect(a+y,r,P,n),t.clip(),t.fillText(w,a+y,0),t.restore(),p&&!h){const E=r+n+4,A=e.optionsList||[],W=e.itemHeight||32,z=e.listPadding??4,Y=A.length*W+z*2,G=e.listCornerRadius??f;t.save();const N=e.listShadow||{},J=t.getTransform(),x=Math.sqrt(J.a*J.a+J.b*J.b)||1;t.shadowColor=typeof N.color=="string"?N.color:((_=N.color)==null?void 0:_.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(N.blur??12)*x,t.shadowOffsetY=(N.offsetY??6)*x,t.shadowOffsetX=(N.offsetX??0)*x,t.beginPath(),this.drawRoundRect(t,a,E,s,Y,G),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},s,Y)||"#ffffff",t.fill();const F=e.listBorderWidth??1;F>0&&(t.shadowColor="transparent",t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:d},s,Y)||"#e5e7eb",t.lineWidth=F,t.stroke()),t.restore();const j=e.itemFontSize||M,X=e.itemFontFamily||k;t.font=`${I} ${j}px ${X}`,A.forEach((tt,L)=>{const R=E+z+L*W;if(tt===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},s,W)||"#f3f4f6",t.fillRect(a+F,R,s-F*2,W),t.fillStyle=e.itemSelectedColor||e.accentColor||u||"#374151";else if(t.fillStyle=e.listTextColor||u||"#333333",this.activeDropdownId===i.id&&this._lastPointerPos){const q=this._lastPointerPos.y-(E+z),ot=Math.floor(q/W);L===ot&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},s,W)||"#f9fafb",t.fillRect(a+F,R,s-F*2,W),t.fillStyle=e.itemHoverColor||u)}t.fillText(tt,a+y,R+W/2)})}t.globalAlpha=v}renderButton(t,i){if(i.children&&i.children.length>0)return;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=i.geometry||{},n=s.width||120,a=s.height||40,r=this.lastHoveredObjectId===i.id,f=this.activeObjectId===i.id,h=e.label||{},l=e.hoverStyle||{},p=e.activeStyle||{},c=e.icon||{enabled:!1};let d=e.backgroundColor||"#3b82f6",u=h.color||"#ffffff",v=h.text||"Button",b=s.cornerRadius??8,y=e.borderColor||"transparent",m=e.borderWidth||0,S=1;f&&p?(d=p.backgroundColor||d,u=p.color||u,v=p.text||v,S=p.scale??.95,b=p.cornerRadius??b):r&&l&&(d=l.backgroundColor||d,u=l.color||u,v=l.text||v,S=l.scale??1,b=l.cornerRadius??b,y=l.borderColor||y);const C=-n/2,w=-a/2;t.save(),t.scale(S,S),t.beginPath(),this.drawRoundRect(t,C,w,n,a,b);const M=this.createCanvasFill(t,d,n,a);M&&(t.fillStyle=M,t.fill()),(m>0||r&&l.borderColor)&&(t.strokeStyle=y,t.lineWidth=m||(r?1:0),t.stroke());const I=h.fontSize||14,k=h.fontFamily||"Inter",T=h.fontWeight||600;t.font=`${T} ${I}px "${k}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=u,t.textAlign="center",t.textBaseline="middle";let O=0;if(c.enabled&&c.svgPath){const P=I*1.1,_=c.gap||8,E=t.measureText(v),W=-(E.width+P+_)/2,z=c.position==="left"?W+P/2:W+E.width+_+P/2;O=c.position==="left"?W+P+_+E.width/2:W+E.width/2,t.save(),t.translate(z,0);const Y=new Path2D(c.svgPath),G=P/24;t.scale(G,G),t.translate(-12,-12),t.fillStyle=u,t.fill(Y),t.restore()}t.fillText(v,O,0),t.restore()}renderToggleButton(t,i){var v,b;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=e.checked??!1,n=((v=i.geometry)==null?void 0:v.width)||120,a=((b=i.geometry)==null?void 0:b.height)||40,r=-n/2,f=-a/2,h=e.corner_radius??8,l=e.label||{},p=s?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",c=s?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,r,f,n,a,h),t.fillStyle=p,t.fill();const d=l.fontSize||14,u=l.fontFamily||"Inter";t.font=`${l.fontWeight||600} ${d}px "${u}", sans-serif`,t.fillStyle=c,t.textAlign="center",t.textBaseline="middle",t.fillText(l.text||"Toggle",0,0),t.restore()}renderToggle(t,i){var G,N,J,x,F,j,X,tt,L,R,D,q;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((G=i.geometry)==null?void 0:G.width)||52,n=((N=i.geometry)==null?void 0:N.height)||30,a=-s/2,r=-n/2,f=e.checked??!1,h=e.cornerRadius??e.corner_radius??n/2,l=e.toggleStyle||{},p=l.backgroundColor||e.activeColor||"#10b981",c=l.borderColor||e.borderColor||"transparent",d=l.borderWidth??e.borderWidth??0,u=l.knobColor||e.knobColor||"#ffffff",v=f?p:e.inactiveColor||"#374151",b=f?c:e.borderColor||"transparent",y=f?d:e.borderWidth??0,m=f?u:e.knobColor||"#ffffff";e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,s,n,h);const S=this.createCanvasFill(t,v,s,n);if(S&&(t.fillStyle=S,t.fill()),y>0){t.lineWidth=y;const ot=this.createCanvasFill(t,b,s,n);ot&&(t.strokeStyle=ot,t.stroke())}const C=2,w=n-C*2,M=w/2,I=a+C,k=a+s-C-w,T=f?k:I,O=r+C;t.beginPath(),t.arc(T+M,O+M,M,0,Math.PI*2);const P=this.createCanvasFill(t,m,w,w);P&&(t.fillStyle=P,t.fill()),e.disabled&&(t.globalAlpha*=2);let _=!1,E=!1;const A=(f?(J=l.leftLabel)==null?void 0:J.text:null)||((x=e.leftLabel)==null?void 0:x.text)||"",W=(f?(F=l.leftLabel)==null?void 0:F.color:null)||((j=e.leftLabel)==null?void 0:j.color)||"#f3f4f6";if((X=e.leftLabel)!=null&&X.enabled&&A){const ot=e.leftLabel;t.font=`${ot.fontWeight||400} ${ot.fontSize||12}px "${ot.fontFamily||"Inter"}", sans-serif`,t.fillStyle=W,t.textBaseline="middle",t.textAlign="right",t.fillText(A,a-(ot.gap||8),0),_=!0}const z=(f?(tt=l.rightLabel)==null?void 0:tt.text:null)||((L=e.rightLabel)==null?void 0:L.text)||"",Y=(f?(R=l.rightLabel)==null?void 0:R.color:null)||((D=e.rightLabel)==null?void 0:D.color)||"#f3f4f6";if((q=e.rightLabel)!=null&&q.enabled&&z){const ot=e.rightLabel;t.font=`${ot.fontWeight||400} ${ot.fontSize||12}px "${ot.fontFamily||"Inter"}", sans-serif`,t.fillStyle=Y,t.textBaseline="middle",t.textAlign="left",t.fillText(z,a+s+(ot.gap||8),0),E=!0}if(!_&&!E&&e.label&&e.label.text){const ot=e.label,mt=ot.fontSize||14,bt=ot.fontWeight||400,gt=ot.fontFamily||"Inter";t.font=`${bt} ${mt}px "${gt}", sans-serif`,t.fillStyle=ot.color||"#f3f4f6",t.textBaseline="middle";const Et=ot.gap||10;let It=0,vt=0;ot.position==="left"?(t.textAlign="right",It=a-Et,vt=0):ot.position==="right"?(t.textAlign="left",It=a+s+Et,vt=0):ot.position==="top"?(t.textAlign="center",It=0,vt=r-Et,t.textBaseline="bottom"):ot.position==="bottom"?(t.textAlign="center",It=0,vt=r+n+Et,t.textBaseline="top"):(t.textAlign="left",It=a+s+Et,vt=0),t.fillText(ot.text,It,vt)}}renderCheckbox(t,i){var S,C;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((S=i.geometry)==null?void 0:S.width)||20,n=((C=i.geometry)==null?void 0:C.height)||20,a=-s/2,r=-n/2,f=e.cornerRadius??4,h=e.checked??!1,l=e.activeColor||"#3b82f6",p=e.inactiveColor||"transparent",c=e.checkColor||"#ffffff",d=e.borderColor||"#4b5563",u=e.borderWidth??2,v=h?l:p,b=h?"transparent":d,y=h?0:u;e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,s,n,f);const m=this.createCanvasFill(t,v,s,n);if(m&&(t.fillStyle=m,t.fill()),y>0){t.lineWidth=y;const w=this.createCanvasFill(t,b,s,n);w&&(t.strokeStyle=w,t.stroke())}else if(h){t.lineWidth=1;const w=this.createCanvasFill(t,l,s,n);w&&(t.strokeStyle=w,t.stroke())}if(h){t.save(),t.beginPath();const w=this.createCanvasFill(t,c,s,n);t.strokeStyle=w||c,t.lineWidth=Math.max(2,s*.12),t.lineCap="round",t.lineJoin="round";const M=a+s*.25,I=r+n*.5,k=a+s*.45,T=r+n*.7,O=a+s*.75,P=r+n*.25;t.moveTo(M,I),t.lineTo(k,T),t.lineTo(O,P),t.stroke(),t.restore()}if(e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const w=e.label;t.save(),t.font=`${w.fontWeight||400} ${w.fontSize||14}px "${w.fontFamily||"Inter"}", sans-serif`,t.fillStyle=w.color||"#f3f4f6",t.textBaseline="middle";const M=w.gap||8;let I=0,k=0;w.position==="left"?(t.textAlign="right",I=a-M,k=0):w.position==="right"?(t.textAlign="left",I=a+s+M,k=0):w.position==="top"?(t.textAlign="center",I=0,k=r-M,t.textBaseline="bottom"):w.position==="bottom"&&(t.textAlign="center",I=0,k=r+n+M,t.textBaseline="top"),t.fillText(w.text,I,k),t.restore()}}renderRadioGroup(t,i){var C,w;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((C=i.geometry)==null?void 0:C.width)||180,n=((w=i.geometry)==null?void 0:w.height)||100,a=-s/2,r=-n/2,f=e.selectedValue,h=e.optionsList||["Option 1","Option 2","Option 3"],l=e.orientation||"vertical",p=e.itemGap!==void 0?e.itemGap:16,c=e.activeColor||"#3b82f6",d=e.inactiveColor||"#4b5563",u=e.textColor||"#ffffff",v=e.fontSize||14,b=e.fontFamily||"Inter",y=e.fontWeight||400;e.disabled&&(t.globalAlpha*=.5);const m=8,S=m*2;if(t.save(),t.font=`${y} ${v}px "${b}", sans-serif`,t.textBaseline="middle",t.textAlign="left",l==="vertical"){const M=Math.max(S,v)+p;h.forEach((I,k)=>{const T=r+k*M+m;t.beginPath(),t.arc(a+m,T,m,0,Math.PI*2);const O=f===I,P=this.createCanvasFill(t,c,S,S),_=this.createCanvasFill(t,d,S,S);O?(t.strokeStyle=P||c,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(a+m,T,m/2,0,Math.PI*2),t.fillStyle=P||c,t.fill()):(t.strokeStyle=_||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(I,a+S+8,T)})}else{let M=a;h.forEach(I=>{const k=f===I,T=t.measureText(I).width;t.beginPath(),t.arc(M+m,0,m,0,Math.PI*2);const O=this.createCanvasFill(t,c,S,S),P=this.createCanvasFill(t,d,S,S);k?(t.strokeStyle=O||c,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(M+m,0,m/2,0,Math.PI*2),t.fillStyle=O||c,t.fill()):(t.strokeStyle=P||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(I,M+S+6,0),M+=S+6+T+p})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const M=e.label;t.save(),t.font=`${M.fontWeight||400} ${M.fontSize||14}px "${M.fontFamily||"Inter"}", sans-serif`,t.fillStyle=M.color||"#9ca3af",t.textBaseline="middle";const I=M.gap||8;let k=0,T=0;M.position==="left"?(t.textAlign="right",k=a-I,T=0):M.position==="right"?(t.textAlign="left",k=a+s+I,T=0):M.position==="top"?(t.textAlign="center",k=0,T=r-I,t.textBaseline="bottom"):M.position==="bottom"&&(t.textAlign="center",k=0,T=r+n+I,t.textBaseline="top"),t.fillText(M.text,k,T),t.restore()}}renderBarChart(t,i){var T,O;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s={width:((T=i.geometry)==null?void 0:T.width)||300,height:((O=i.geometry)==null?void 0:O.height)||180,chartType:e.chartType||"grouped",stylePreset:e.stylePreset||"default",datasets:e.datasets||[{id:"ds-1",label:"Revenue",data:[42,67,31,55,78,48],color:"#6366f1"}],categories:e.categories||["Jan","Feb","Mar","Apr","May","Jun"],orientation:e.orientation||"vertical",barWidth:e.barWidth!==void 0?e.barWidth:14,barGap:e.barGap!==void 0?e.barGap:4,barCornerRadius:e.barCornerRadius!==void 0?e.barCornerRadius:5,showXAxis:!!e.showXAxis,showYAxis:!!e.showYAxis,xAxisColor:e.xAxisColor||"rgba(255,255,255,0.12)",yAxisColor:e.yAxisColor||"rgba(255,255,255,0.12)",showXLabels:e.showXLabels!==void 0?!!e.showXLabels:!0,showYLabels:!!e.showYLabels,axisLabelColor:e.axisLabelColor||"rgba(255,255,255,0.5)",axisLabelFontSize:e.axisLabelFontSize||9,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.7)",legendFontSize:e.legendFontSize||9,showGridLines:e.showGridLines!==void 0?!!e.showGridLines:!0,gridColor:e.gridColor||"rgba(255,255,255,0.06)",cardBackground:e.cardBackground||"rgba(255,255,255,0.04)",cardBorderColor:e.cardBorderColor||"rgba(255,255,255,0.08)",barGradient:e.barGradient!==void 0?!!e.barGradient:!0,showValueOnTop:!!e.showValueOnTop,chartBackground:e.chartBackground||"transparent",barStyle:e.barStyle||"solid",barBorderWidth:e.barBorderWidth!==void 0?e.barBorderWidth:1,barBorderColor:e.barBorderColor||"auto",enableShadows:!!e.enableShadows,shadowColor:e.shadowColor||"rgba(0,0,0,0.5)",shadowBlur:e.shadowBlur!==void 0?e.shadowBlur:4,shadowOffsetY:e.shadowOffsetY!==void 0?e.shadowOffsetY:2,valueFontSize:e.valueFontSize||10,valueColor:e.valueColor||"auto",valueFontWeight:e.valueFontWeight||"bold",xAxisLineWidth:e.xAxisLineWidth!==void 0?e.xAxisLineWidth:1,yAxisLineWidth:e.yAxisLineWidth!==void 0?e.yAxisLineWidth:1,gridLineWidth:e.gridLineWidth!==void 0?e.gridLineWidth:1,gridLineDash:e.gridLineDash||[3,4],_getPreset:function(){return ps[this.stylePreset]||ps.default},_resolveColor:function(P,_){const E=this._getPreset();return["#6366f1","#f59e0b","#10b981","#3b82f6","#a855f7"].includes(P)?E.colors[_%E.colors.length]:typeof P=="string"?P:E.colors[_%E.colors.length]},_makeGradient:function(P,_,E,A,W,z){if(!this._getPreset().barGradient&&!this.barGradient)return _;const G=P.createLinearGradient(E,A,W,z);return G.addColorStop(0,_),G.addColorStop(1,_+"44"),G},_drawRoundedBar:function(P,_,E,A,W,z,Y){if(z=Math.min(z,Math.min(Math.abs(A),Math.abs(W))/2),z<=0||A===0||W===0){P.rect(_,E,A,W);return}P.beginPath(),Y?(P.moveTo(_,E+W),P.lineTo(_,E+z),P.quadraticCurveTo(_,E,_+z,E),P.lineTo(_+A-z,E),P.quadraticCurveTo(_+A,E,_+A,E+z),P.lineTo(_+A,E+W),P.lineTo(_,E+W)):(P.moveTo(_,E),P.lineTo(_+A-z,E),P.quadraticCurveTo(_+A,E,_+A,E+z),P.lineTo(_+A,E+W-z),P.quadraticCurveTo(_+A,E+W,_+A-z,E+W),P.lineTo(_,E+W),P.lineTo(_,E)),P.closePath()}},n=s.width,a=s.height,r=-n/2,f=-a/2;if(!s.datasets||s.datasets.length===0||s.categories.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.7)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO CHART DATA",0,0),t.restore();return}const h=s._getPreset();let l=-1/0,p=1/0;const c=s.categories.length,d=s.datasets.length;if(s.chartType==="stacked")for(let P=0;P<c;P++){let _=0,E=0;s.datasets.forEach(A=>{const W=A.data[P]??0;W>=0?_+=W:E+=W}),_>l&&(l=_),E<p&&(p=E)}else s.datasets.forEach(P=>{P.data&&P.data.forEach(_=>{_>l&&(l=_),_<p&&(p=_)})});isFinite(l)||(l=10),isFinite(p)||(p=0),l=Math.max(l,0),p=Math.min(p,0);const u=l-p||10;t.save(),s.enableShadows&&(t.shadowColor=s.shadowColor,t.shadowBlur=s.shadowBlur,t.shadowOffsetY=s.shadowOffsetY),t.font=s.axisLabelFontSize+"px Inter, sans-serif";const v=s.showYLabels?t.measureText(l.toFixed(0)).width+14:10,b=s.showXLabels?s.axisLabelFontSize+12:8,m=(s.showLegend&&d>0?s.legendFontSize+10:0)+8,S=10,C=r+v,w=f+m,M=n-v-S,I=a-m-b;if(s.enableShadows&&(t.shadowColor="transparent"),t.beginPath(),t.roundRect(r,f,n,a,10),t.fillStyle=h.cardBackground,t.fill(),t.strokeStyle=h.cardBorderColor,t.lineWidth=1,t.stroke(),s.chartBackground&&s.chartBackground!=="transparent"&&(t.beginPath(),t.rect(C,w,M,I),t.fillStyle=s.chartBackground,t.fill()),s.showLegend&&d>0){t.font=s.legendFontSize+"px Inter, sans-serif",t.textBaseline="middle";const P=f+12;let _=C;s.datasets.forEach((E,A)=>{const W=s._resolveColor(E.color,A),z=E.label||"Series "+(A+1),Y=7;t.beginPath(),t.roundRect(_,P-Y/2,Y,Y,2),t.fillStyle=W,t.fill(),t.fillStyle=h.legendColor,t.textAlign="left",t.fillText(z,_+Y+4,P),_+=t.measureText(z).width+Y+16})}const k=4;if(s.showGridLines){t.setLineDash(s.gridLineDash||[]),t.lineWidth=s.gridLineWidth||1,t.strokeStyle=h.gridColor;for(let P=0;P<=k;P++)if(s.orientation==="horizontal"){const _=C+P/k*M;t.beginPath(),t.moveTo(_,w),t.lineTo(_,w+I),t.stroke()}else{const _=w+P/k*I;t.beginPath(),t.moveTo(C,_),t.lineTo(C+M,_),t.stroke()}t.setLineDash([])}if(s.showYLabels){t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor;for(let P=0;P<=k;P++)if(s.orientation==="horizontal"){const _=p+P/k*u,E=C+P/k*M;t.textAlign="center",t.fillText(_.toFixed(0),E,w+I+s.axisLabelFontSize)}else{const _=l-P/k*u,E=w+P/k*I;t.textAlign="right",t.fillText(_.toFixed(0),C-6,E)}}if(t.setLineDash([]),s.showXAxis&&(t.lineWidth=s.xAxisLineWidth||1,t.strokeStyle=s.xAxisColor,t.beginPath(),t.moveTo(C,w+I),t.lineTo(C+M,w+I),t.stroke()),s.showYAxis&&(t.lineWidth=s.yAxisLineWidth||1,t.strokeStyle=s.yAxisColor,t.beginPath(),t.moveTo(C,w),t.lineTo(C,w+I),t.stroke()),s.enableShadows&&(t.shadowColor=s.shadowColor),s.chartType==="stacked")if(s.orientation==="horizontal"){const P=I/c;for(let _=0;_<c;_++){const E=w+_*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[_]||"",C-5,E),s.enableShadows&&(t.shadowColor=s.shadowColor));let A=C;s.datasets.forEach((W,z)=>{const Y=W.data[_]??0;if(Y===0)return;const G=Y/u*M,N=Math.min(s.barWidth*d+s.barGap,P-8),J=E-N/2,x=A;A+=G;const F=s._resolveColor(W.color,z);t.beginPath(),t.fillStyle=s._makeGradient(t,F,x,J,x+G,J),s._drawRoundedBar(t,x,J,G,N,z===d-1?s.barCornerRadius:0,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?F:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else{const P=M/c;for(let _=0;_<c;_++){const E=C+_*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[_]||"",E,w+I+5),s.enableShadows&&(t.shadowColor=s.shadowColor));let A=w+I;s.datasets.forEach((W,z)=>{const Y=W.data[_]??0;if(Y===0)return;const G=Y/u*I,N=Math.min(s.barWidth*d+s.barGap,P-8),J=E-N/2,x=A-G;A-=G;const F=s._resolveColor(W.color,z);t.beginPath(),t.fillStyle=s._makeGradient(t,F,J,x,J,x+G),s._drawRoundedBar(t,J,x,N,G,z===d-1?s.barCornerRadius:0,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?F:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else if(s.orientation==="horizontal"){const P=I/c,_=d*s.barWidth+Math.max(0,(d-1)*s.barGap),E=C+(0-p)/u*M;for(let A=0;A<c;A++){const W=w+A*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[A]||"",C-5,W),s.enableShadows&&(t.shadowColor=s.shadowColor));const z=W-_/2;s.datasets.forEach((Y,G)=>{const N=Y.data[A]??0,J=Math.abs(N/u*M);if(J<1)return;const x=z+G*(s.barWidth+s.barGap),F=N>=0?E:E-J,j=s._resolveColor(Y.color,G);t.beginPath(),t.fillStyle=s._makeGradient(t,j,F,x,F+J,x),s._drawRoundedBar(t,F,x,J,s.barWidth,s.barCornerRadius,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?j:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&N!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign=N>=0?"left":"right",t.textBaseline="middle",t.fillStyle=s.valueColor==="auto"?j:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(N.toString(),N>=0?F+J+4:F-4,x+s.barWidth/2),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}else{const P=M/c,_=d*s.barWidth+Math.max(0,(d-1)*s.barGap),E=w+I-(0-p)/u*I;for(let A=0;A<c;A++){const W=C+A*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[A]||"",W,w+I+5),s.enableShadows&&(t.shadowColor=s.shadowColor));const z=W-_/2;s.datasets.forEach((Y,G)=>{const N=Y.data[A]??0,J=Math.abs(N/u*I);if(J<1)return;const x=z+G*(s.barWidth+s.barGap),F=N>=0?E-J:E,j=s._resolveColor(Y.color,G);t.beginPath(),t.fillStyle=s._makeGradient(t,j,x,F,x,F+J),s._drawRoundedBar(t,x,F,s.barWidth,J,s.barCornerRadius,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?j:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&N!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign="center",t.textBaseline=N>=0?"bottom":"top",t.fillStyle=s.valueColor==="auto"?j:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(N.toString(),x+s.barWidth/2,N>=0?F-4:F+J+4),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}t.restore()}renderPieChart(t,i){var v,b;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s={width:((v=i.geometry)==null?void 0:v.width)||180,height:((b=i.geometry)==null?void 0:b.height)||180,chartType:e.chartType||"donut",stylePreset:e.stylePreset||"default",slices:e.slices||[{id:"slice-1",label:"Item 1",value:45,color:"#6366f1"}],innerRadius:e.innerRadius!==void 0?e.innerRadius:.55,sliceGap:e.sliceGap!==void 0?e.sliceGap:3,showLabels:!!e.showLabels,labelColor:e.labelColor||"#ffffff",labelFontSize:e.labelFontSize||10,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.65)",legendFontSize:e.legendFontSize||9,showCenterText:e.showCenterText!==void 0?!!e.showCenterText:!0,centerLabel:e.centerLabel||"Total",centerTextColor:e.centerTextColor||"#ffffff",centerLabelColor:e.centerLabelColor||"rgba(255,255,255,0.4)",_getPreset:function(){return gs[this.stylePreset]||gs.default},_resolveSliceColor:function(y,m){const S=y.color,C=m,w=this._getPreset();return["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399","#a855f7","#f87171"].includes(S)?w.colors[C%w.colors.length]:typeof S=="string"?S:w.colors[C%w.colors.length]}},n=s.width,a=s.height;if(!s.slices||s.slices.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO PIE DATA",0,0),t.restore();return}const r=s.slices.reduce((y,m)=>y+(m.value||0),0);if(r<=0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("EMPTY DATA",0,0),t.restore();return}const f=s._getPreset();t.save(),t.beginPath(),t.roundRect(-n/2,-a/2,n,a,10),t.fillStyle=f.cardBackground,t.fill(),t.strokeStyle=f.cardBorderColor,t.lineWidth=1,t.stroke();const h=s.showLegend?Math.ceil(s.slices.length/2):0,l=h>0?h*(s.legendFontSize+8)+10:0,p=a-l-16,c=Math.min(n-24,p)/2,d=0,u=-l/2;if(s.chartType==="rose"){const y=Math.max(...s.slices.map(C=>C.value||0)),m=Math.PI*2/s.slices.length,S=c>0?s.sliceGap/c:0;s.slices.forEach((C,w)=>{const M=C.value||0;if(M===0)return;const I=M/y*c,k=-Math.PI/2+w*m+S/2,T=k+m-S,O=s._resolveSliceColor(C,w);if(t.beginPath(),t.moveTo(d,u),t.arc(d,u,I,k,T),t.closePath(),t.fillStyle=O+"cc",t.fill(),t.strokeStyle=O,t.lineWidth=1.5,t.stroke(),s.showLabels){const P=k+(T-k)/2,_=d+I*.65*Math.cos(P),E=u+I*.65*Math.sin(P),A=Math.round(M/r*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=f.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${A}%`,_,E),t.restore()}})}else{const y=s.chartType==="pie"?0:s.innerRadius,m=c*Math.max(0,y),S=c>0?s.sliceGap/c:0;let C=-Math.PI/2;if(s.slices.forEach((w,M)=>{const I=w.value||0;if(I===0){C+=I/r*Math.PI*2;return}const k=I/r*Math.PI*2,T=C+S/2,O=C+k-S/2;if(O<=T){C+=k;return}const P=s._resolveSliceColor(w,M);if(t.beginPath(),t.fillStyle=P,m<=0?(t.moveTo(d,u),t.arc(d,u,c,T,O),t.lineTo(d,u)):(t.moveTo(d+c*Math.cos(T),u+c*Math.sin(T)),t.arc(d,u,c,T,O),t.arc(d,u,m,O,T,!0),t.closePath()),t.fill(),s.showLabels){const _=T+(O-T)/2,E=m+(c-m)/2,A=d+E*Math.cos(_),W=u+E*Math.sin(_),z=Math.round(I/r*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=f.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${z}%`,A,W),t.restore()}C+=k}),s.chartType==="donut"&&s.showCenterText&&m>14){const w=Math.round(r),M=Math.min(Math.floor(m*.52),20),I=Math.min(Math.floor(m*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${M}px Inter, sans-serif`,t.fillStyle=f.centerTextColor,t.fillText(w.toString(),d,u-I*.5),s.centerLabel&&(t.font=`${I}px Inter, sans-serif`,t.fillStyle=f.centerLabelColor,t.fillText(s.centerLabel,d,u+M*.6))}}if(s.showLegend&&s.slices.length>0){t.font=`${s.legendFontSize}px Inter, sans-serif`;const y=2,m=n/y,S=s.legendFontSize+8,C=a/2-l+10,w=-n/2+10;s.slices.forEach((M,I)=>{const k=I%y,T=Math.floor(I/y),O=w+k*m,P=C+T*S,_=s._resolveSliceColor(M,I),E=7;t.beginPath(),t.roundRect(O,P-E/2,E,E,2),t.fillStyle=_,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=f.legendColor;const A=Math.round((M.value||0)/r*100),W=`${M.label||"Item"} ${A}%`,z=m-E-20;let Y=W;for(;t.measureText(Y).width>z&&Y.length>4;)Y=Y.slice(0,-4)+"…";t.fillText(Y,O+E+4,P)})}t.restore()}renderJoystick(t,i){var u,v,b,y,m;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.width)!==void 0?o.width:((u=i.geometry)==null?void 0:u.width)??i.width??100,s=(o==null?void 0:o.height)!==void 0?o.height:((v=i.geometry)==null?void 0:v.height)??i.height??100,n=Math.min(e,s)*.45,a=Math.min(e,s)*.15;let r=i.handleX||0,f=i.handleY||0;o&&o.handleX!==void 0&&(r=o.handleX),o&&o.handleY!==void 0&&(f=o.handleY),t.save();let h=0,l=0;i.handleOrigin==="top-left"?(h=e/2,l=s/2):i.handleOrigin==="bottom-right"&&(h=-e/2,l=-s/2),t.translate(h,l),t.beginPath(),i.boundsShape==="square"?t.rect(-n,-n,n*2,n*2):t.arc(0,0,n,0,Math.PI*2),t.fillStyle="rgba(0,0,0,0.2)",(b=i.style)!=null&&b.fill&&typeof i.style.fill=="string"?t.fillStyle=i.style.fill:(y=i.style)!=null&&y.fill&&i.style.fill.type==="solid"&&(t.fillStyle=i.style.fill.color),t.fill(),(m=i.style)!=null&&m.stroke&&i.style.stroke.isEnabled!==!1&&(t.lineWidth=i.style.stroke.width||1,t.strokeStyle=i.style.stroke.color||"#000",t.stroke());const p=n-a;let c=0,d=0;i.joystickType==="2D"?(c=r*p,d=f*p):i.joystickType==="1D_X"?(c=r*p,d=0):i.joystickType==="1D_Y"&&(c=0,d=f*p),t.beginPath(),t.arc(c,d,a,0,Math.PI*2),t.fillStyle="#fff",t.fill(),t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1,t.stroke(),t.restore()}getRadioGroupItemIndexAtPointer(t,i,o){var I,k;const e=t.options||{},s=this.objectStates.get(t.id)||{},n=e.optionsList||[];if(n.length===0)return null;const a=s.width!==void 0?s.width:((I=t.geometry)==null?void 0:I.width)||180,r=s.height!==void 0?s.height:((k=t.geometry)==null?void 0:k.height)||100,f=e.orientation||"vertical",h=e.itemGap!==void 0?e.itemGap:16,l=e.fontSize||14,p=this.getWorldTransform(t.id),c=i-p.x,d=o-p.y,u=-p.rotation*(Math.PI/180),v=Math.cos(u),b=Math.sin(u),y=c*v-d*b,m=c*b+d*v,C=8*2,w=-a/2,M=-r/2;if(f==="vertical"){const T=Math.max(C,l)+h;for(let O=0;O<n.length;O++){const P=M+O*T;if(y>=w&&y<=w+a&&m>=P&&m<=P+T)return O}}else{let T=w;for(let O=0;O<n.length;O++){const _=n[O].length*8,E=C+6+_+h;if(y>=T&&y<=T+E&&m>=M&&m<=M+r)return O;T+=E}}return null}renderLineGraph(t,i,o,e){let s=i.datasets||[];if((!s||s.length===0)&&(i.data||i.graphData)&&(s=[{id:"line-1",label:"Series 1",data:i.data||i.graphData||[],lineColor:i.lineColor||"#3b82f6",lineWidth:i.lineWidth||2,showArea:i.showArea||!1,areaColor:i.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:i.smoothing||!1,showPoints:i.showPoints!==void 0?i.showPoints:!0,pointSize:i.pointSize||6,pointFill:i.pointFill||"#ffffff",pointStrokeColor:i.pointStrokeColor||i.lineColor||"#3b82f6",pointStrokeWidth:i.pointStrokeWidth||2}]),!s||s.length===0||!s.some(u=>u.data&&u.data.length>=2)){t.save(),t.fillStyle="#6366f1",t.font="12px Inter, system-ui, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO DATA",0,0),t.restore();return}let n=1/0,a=-1/0,r=0;if(s.forEach(u=>{let v=u.data;if(u.isVarEnabled&&u.inputId){let b=this.inputs.get(u.inputId);if(b===void 0){const y=this.inputNameMap.get(u.inputId);y&&y.length>0&&(b=this.inputs.get(y[0]))}b&&Array.isArray(b)&&(v=b)}if(v&&v.length>0){const b=v.filter(y=>typeof y=="number"&&!isNaN(y));b.length>0&&(n=Math.min(n,...b),a=Math.max(a,...b),r=Math.max(r,v.length))}u._resolvedData=v}),r<2)return;const f=a-n,h=o/(r-1),l=u=>{const v=f===0?.5:(u-n)/f;return e/2-v*e},p=u=>u*h-o/2,c=i.axisColor||"#333333";if(i.showXAxis&&(t.beginPath(),t.strokeStyle=i.xAxisColor||c,t.lineWidth=1,t.moveTo(-o/2,e/2),t.lineTo(o/2,e/2),t.stroke()),i.showYAxis&&(t.beginPath(),t.strokeStyle=i.yAxisColor||c,t.lineWidth=1,t.moveTo(-o/2,-e/2),t.lineTo(-o/2,e/2),t.stroke()),t.fillStyle=i.axisLabelColor||"#333333",t.font=`${i.axisLabelFontSize||10}px Inter, sans-serif`,i.showXLabels){t.textAlign="center",t.textBaseline="top";for(let u=0;u<r;u++){const v=p(u);t.fillText(`${u+1}`,v,e/2+5)}}if(i.showYLabels){t.textAlign="right",t.textBaseline="middle";const u=-o/2-5,v=(a+n)/2;t.fillText(a.toFixed(1),u,l(a)),t.fillText(v.toFixed(1),u,l(v)),t.fillText(n.toFixed(1),u,l(n))}const d=10;if(s.forEach(u=>{const v=u._resolvedData;if(!(!v||v.length<2)){if(u.showArea){if(t.beginPath(),t.moveTo(p(0),e/2),t.lineTo(p(0),l(v[0])),u.smoothing&&v.length>2)for(let y=0;y<v.length-1;y++){const m=v[y===0?y:y-1],S=v[y],C=v[y+1],w=v[y+1===v.length-1?y+1:y+2];for(let M=1;M<=d;M++){const I=M/d,k=this._catmullRom(m,S,C,w,I);t.lineTo(p(y+I),l(k))}}else for(let y=1;y<v.length;y++)t.lineTo(p(y),l(v[y]));t.lineTo(p(v.length-1),e/2),t.closePath();const b=t.globalAlpha;t.globalAlpha=b*(i.areaOpacity??.3),t.fillStyle=u.areaColor||"rgba(139, 92, 246, 0.2)",t.fill(),t.globalAlpha=b}if(t.beginPath(),t.strokeStyle=u.lineColor||"#3b82f6",t.lineWidth=u.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.moveTo(p(0),l(v[0])),u.smoothing&&v.length>2)for(let b=0;b<v.length-1;b++){const y=v[b===0?b:b-1],m=v[b],S=v[b+1],C=v[b+1===v.length-1?b+1:b+2];for(let w=1;w<=d;w++){const M=w/d,I=this._catmullRom(y,m,S,C,M);t.lineTo(p(b+M),l(I))}}else for(let b=1;b<v.length;b++)t.lineTo(p(b),l(v[b]));t.stroke(),u.showPoints&&v.forEach((b,y)=>{const m=p(y),S=l(b);t.beginPath(),t.arc(m,S,(u.pointSize||6)/2,0,Math.PI*2),t.fillStyle=u.pointFill||"#ffffff",t.fill(),t.strokeStyle=u.pointStrokeColor||u.lineColor||"#3b82f6",t.lineWidth=u.pointStrokeWidth||1,t.stroke()})}}),i.showLegend&&s.length>0){const u=o/2-10;let v=-e/2+15;const b=i.legendFontSize||10,y=b+5;t.font=`${b}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",s.forEach(m=>{const C=m.label||"Series",w=t.measureText(C).width;t.beginPath(),t.rect(u-w-8-5,v-(8/2+2),8,8),t.fillStyle=m.lineColor||"#3b82f6",t.fill(),t.fillStyle=i.legendColor||"#333333",t.fillText(C,u,v),v+=y})}}_catmullRom(t,i,o,e,s){const n=(o-t)*.5,a=(e-i)*.5,r=s*s,f=s*r;return(2*i-2*o+n+a)*f+(-3*i+3*o-2*n-a)*r+n*s+i}normalizeOpacity(t){const i=typeof t=="number"?t:parseFloat(String(t));return isNaN(i)?1:i>1?Math.min(1,i/100):Math.max(0,Math.min(1,i))}createCanvasFill(t,i,o,e){var s,n,a;if(!i||i.type==="None")return null;if(typeof i=="string")return i;if(i.type==="Solid"&&i.color){const r=i.color,h=(((n=(s=this.artboard)==null?void 0:s.tokens)==null?void 0:n.colors)||{})[r]||r;return t.fillStyle=h,h}if((i.type==="LinearGradient"||i.type==="RadialGradient"||i.type==="AngularGradient"||i.type==="DiamondGradient")&&i.stops){const r=(f,h=100)=>{var S,C;const p=(((C=(S=this.artboard)==null?void 0:S.tokens)==null?void 0:C.colors)||{})[f]||f,c=this.normalizeOpacity(i.opacity??100),u=this.normalizeOpacity(h)*c;if(u>=1&&p.startsWith("#"))return p;const v=p.startsWith("#")?p.replace("#",""):"ffffff",b=parseInt(v.substring(0,2),16),y=parseInt(v.substring(2,4),16),m=parseInt(v.substring(4,6),16);return`rgba(${b}, ${y}, ${m}, ${u})`};if(i.type==="LinearGradient"){const f=(u,v,b)=>Array.isArray(u)?u[v]??(v===0?0:1):u&&typeof u=="object"?u[b]??(v===0?0:1):v===0?0:1,h=f(i.start,0,"x")*o-o/2,l=f(i.start,1,"y")*e-e/2,p=f(i.end,0,"x")*o-o/2,c=f(i.end,1,"y")*e-e/2,d=t.createLinearGradient(h,l,p,c);if(i.stops.forEach(u=>{const v=u.offset!==void 0?u.offset:u.pos!==void 0?u.pos:u.position!==void 0?u.position:0,b=r(u.color||"#000000",u.opacity??100);d.addColorStop(Math.max(0,Math.min(1,v)),b)}),i.gradientTransform&&d.setTransform){const[u,v,b,y,m,S]=i.gradientTransform;d.setTransform({a:u,b:v,c:b,d:y,e:m,f:S})}return d}else if(i.type==="RadialGradient"){const f=(d,u,v)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[v]??.5:.5,h=f(i.center,0,"x")*o-o/2,l=f(i.center,1,"y")*e-e/2,p=(i.radius??.5)*Math.max(o,e),c=t.createRadialGradient(h,l,0,h,l,p);if(i.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,v=r(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,u)),v)}),i.gradientTransform&&c.setTransform){const[d,u,v,b,y,m]=i.gradientTransform;c.setTransform({a:d,b:u,c:v,d:b,e:y,f:m})}return c}else if(i.type==="AngularGradient"){const f=(d,u,v)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[v]??.5:.5,h=f(i.center||[.5,.5],0,"x")*o-o/2,l=f(i.center||[.5,.5],1,"y")*e-e/2,p=(i.degree||i.angle||0)*(Math.PI/180),c=(a=t.createConicGradient)==null?void 0:a.call(t,p,h,l);if(c){if(i.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,v=r(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,u)),v)}),i.gradientTransform&&c.setTransform){const[d,u,v,b,y,m]=i.gradientTransform;c.setTransform({a:d,b:u,c:v,d:b,e:y,f:m})}return c}}else if(i.type==="DiamondGradient"){const f=(d,u,v)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[v]??.5:.5,h=f(i.center||[.5,.5],0,"x")*o-o/2,l=f(i.center||[.5,.5],1,"y")*e-e/2,p=(i.radius??.5)*Math.max(o,e);t.save(),t.translate(h,l),t.rotate(Math.PI/4);const c=t.createRadialGradient(0,0,0,0,0,p);if(i.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,v=r(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,u)),v)}),i.gradientTransform&&c.setTransform){const[d,u,v,b,y,m]=i.gradientTransform;c.setTransform({a:d,b:u,c:v,d:b,e:y,f:m})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=c,t.restore(),c}}if(i.type==="Pattern"&&i.url){let r=this.imageCache.get(i.url);if(r||(r=new Image,r.src=i.url,this.imageCache.set(i.url,r)),r.complete&&r.naturalWidth>0){const f=t.createPattern(r,"repeat");if(f&&(i.scaleX!==void 0||i.offsetX!==void 0)){const h=new DOMMatrix,l=i.scaleX??1,p=i.scaleY??1,c=i.offsetX??0,d=i.offsetY??0,u=i.rotation??0;h.translateSelf(c,d),h.rotateSelf(u),h.scaleSelf(l,p),f.setTransform(h)}return f}}return i.color||null}drawRoundRect(t,i,o,e,s,n){if(n===0||n===void 0||n===null){t.rect(i,o,e,s);return}let a=n;if(typeof a=="string")try{a=JSON.parse(a)}catch{a=parseFloat(a)||0}let r=0,f=0,h=0,l=0;typeof a=="number"?r=f=h=l=a:Array.isArray(a)?a.length===1?r=f=h=l=a[0]:a.length===2?(r=h=a[0],f=l=a[1]):a.length===3?(r=a[0],f=l=a[1],h=a[2]):a.length>=4&&(r=a[0],f=a[1],h=a[2],l=a[3]):a&&typeof a=="object"&&(r=a.tl??a.corner_radius??a.cornerRadius??0,f=a.tr??a.corner_radius??a.cornerRadius??0,h=a.br??a.corner_radius??a.cornerRadius??0,l=a.bl??a.corner_radius??a.cornerRadius??0);const p=Math.min(Math.abs(e)/2,Math.abs(s)/2);if(r=Math.min(Math.max(0,r),p),f=Math.min(Math.max(0,f),p),h=Math.min(Math.max(0,h),p),l=Math.min(Math.max(0,l),p),t.roundRect){t.roundRect(i,o,e,s,[r,f,h,l]);return}t.moveTo(i+r,o),t.lineTo(i+e-f,o),t.arcTo(i+e,o,i+e,o+f,f),t.lineTo(i+e,o+s-h),t.arcTo(i+e,o+s,i+e-h,o+s,h),t.lineTo(i+l,o+s),t.arcTo(i,o+s,i,o+s-l,l),t.lineTo(i,o+r),t.arcTo(i,o,i+r,o,r),t.closePath()}renderListView(t,i){var A,W,z,Y;const o=this.objectStates.get(i.id)||{},e=o.options||i.options||{},s=o.width!==void 0?o.width:((A=i.geometry)==null?void 0:A.width)||200,n=o.height!==void 0?o.height:((W=i.geometry)==null?void 0:W.height)||300,a=-s/2,r=-n/2,f=o.corner_radius!==void 0?o.corner_radius:e.corner_radius??0,h=e.orientation||"vertical",l=e.items||[],p=e.itemGap??10,c=e.itemHeight??50,d=e.itemWidth??200,u=e.scrollOffset??0,v=e.padding??0,b=e.glassEffect!==!1,y=e.accentColor||"#3b82f6",m=e.itemTextColor||"#333333",S=e.itemBackgroundColor||"#ffffff",C=e.hoveredIndex??null,w=e.activeItemIndex??null,M=e.glowIntensity??0,I=e.glowColor||"#3b82f6",k=typeof I=="string"?I:I.color||((Y=(z=I.stops)==null?void 0:z[0])==null?void 0:Y.color)||"#3b82f6",T=e.opacity!==void 0?e.opacity:i.opacity!==void 0?i.opacity:1;if(t.save(),t.globalAlpha*=T,M>0){const G=t.getTransform(),N=Math.sqrt(G.a*G.a+G.b*G.b)||1;t.shadowColor=k,t.shadowBlur=M*2*N,t.shadowOffsetX=0,t.shadowOffsetY=0}if(b){const G=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",N=this.createCanvasFill(t,G,s,n);t.fillStyle=N||"rgba(31, 41, 55, 0.4)",t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f)||t.fill();const x=t.createLinearGradient(a,r,a+s,r+n);x.addColorStop(0,"rgba(255, 255, 255, 0.15)"),x.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),x.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=x,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f)||t.fill(),t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f)||t.stroke()}else{const G=e.backgroundColor||e.listBackgroundColor||"transparent",N=this.createCanvasFill(t,G,s,n);if(N){t.fillStyle=N,t.beginPath();const x=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f);t.fill()}const J=e.borderWidth??0;if(J>0){t.strokeStyle=e.borderColor||"#cccccc",t.lineWidth=J,t.beginPath();const x=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f);t.stroke()}}t.shadowBlur=0,t.save(),t.beginPath();const O=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f);if(e.listLayout!=="circular")if(O&&e.containerShape==="custom")try{const G=new Path2D(e.containerPath);t.translate(a,r),t.scale(s/100,n/100),t.clip(G),t.scale(100/s,100/n),t.translate(-a,-r)}catch{}else t.clip();const P=typeof v=="number"?v:h==="vertical"?v[0]:v[3];let _=(h==="vertical"?r:a)+u+P;if(t.textBaseline="middle",l.forEach((G,N)=>{const J=e.listLayout||"linear",x=J==="circular"?d:h==="vertical"?s:d,F=J==="circular"||h==="vertical"?c:n;let j=0,X=0,tt=0;if(J==="circular"){const vt=l.length||1,Dt=Math.PI*2/vt,ae=e.circularStartAngle||0,pe=e.circularRadius||100,st=u*.01+ae*Math.PI/180,yt=N*Dt+st,Rt=a+s/2,_t=r+n/2;j=Rt+Math.cos(yt)*pe-x/2,X=_t+Math.sin(yt)*pe-F/2,tt=yt+(e.itemRotation||0)*Math.PI/180}else j=h==="vertical"?a:_,X=h==="vertical"?_:r,tt=(e.itemRotation||0)*Math.PI/180;const L=C===N,R=w===N,D=R&&e.activeItemShape?e.activeItemShape:e.itemShape||"rectangle",q=R&&e.activeItemShape?e.activeItemPath:e.itemPath||"",ot=e.itemCornerRadius||0;if(t.save(),tt!==0&&(t.translate(j+x/2,X+F/2),t.rotate(tt),t.translate(-(j+x/2),-(X+F/2))),R){const vt=this.createCanvasFill(t,y,x,F);t.fillStyle=vt||y;const Dt=t.globalAlpha;t.globalAlpha=Dt*.8,t.beginPath(),this.drawCustomShape(t,D,q,j,X,x,F,ot)||(t.rect(j,X,x,F),t.fill()),t.globalAlpha=Dt}else if(L)t.fillStyle=b?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",t.beginPath(),this.drawCustomShape(t,D,q,j,X,x,F,ot)||(t.rect(j,X,x,F),t.fill());else if(S!=="transparent"){const vt=this.createCanvasFill(t,S,x,F);t.fillStyle=vt||S,t.beginPath(),this.drawCustomShape(t,D,q,j,X,x,F,ot)||(t.rect(j,X,x,F),t.fill())}if(R||L){const vt=this.createCanvasFill(t,y,h==="vertical"?3:x,h==="vertical"?F:3);t.fillStyle=vt||y,h==="vertical"?t.fillRect(j,X,3,F):t.fillRect(j,X+F-3,x,3)}const mt=R?"#ffffff":b?"rgba(255, 255, 255, 0.9)":m;t.fillStyle=mt,t.font=R||L?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const bt=typeof G=="string"?G:(G==null?void 0:G.label)||`Item ${N+1}`,gt=j+(h==="vertical"?16:x/2),Et=X+F/2;h==="horizontal"||J==="circular"?t.textAlign="center":t.textAlign="left";const It=J==="circular"?j+x/2:gt;t.fillText(bt,It,Et),t.restore(),_+=(h==="vertical"?c:d)+p}),t.restore(),e.showScrollbar!==!1){const G=(l.length||0)*(h==="vertical"?c:d)+((l.length||0)-1)*p,N=h==="vertical"?n:s,J=e.listLayout||"linear",x=e.containerShape==="circle"||J==="circular";if(G>N||J==="circular"&&l.length>0){const F=e.scrollbarColor||"rgba(255,255,255,0.3)",j=e.scrollbarWidth||4;if(x){const X=Math.min(s,n)/2-j/2-2,tt=a+s/2,L=r+n/2;if(t.strokeStyle=F,t.lineWidth=j,t.lineCap="round",t.beginPath(),J==="circular"){const R=Math.PI/4,D=-(u*.01)-Math.PI/2;t.arc(tt,L,X,D,D+R)}else{const R=Math.PI/2,D=N/G,q=R*D,ot=-u/G*R,bt=-Math.PI/4+ot;t.arc(tt,L,X,bt,bt+q)}t.stroke()}else{const X=N/G,tt=N*X,L=-u/G*N;t.fillStyle=F,h==="vertical"?t.fillRect(a+s-j-2,r+L,j,tt):t.fillRect(a+L,r+n-j-2,tt,j)}}}t.restore()}drawCustomShape(t,i,o,e,s,n,a,r){if(i==="circle"){const f=Math.min(n,a)/2;return t.arc(e+n/2,s+a/2,f,0,Math.PI*2),!1}else if(i==="pill"){const f=Math.min(n,a)/2;return this.drawListViewRect(t,e,s,n,a,f),!1}else if(i==="custom"&&o)try{const f=new Path2D(o);return t.save(),t.translate(e,s),t.scale(n/100,a/100),t.fill(f),t.restore(),!0}catch{return this.drawListViewRect(t,e,s,n,a,r),!1}return this.drawListViewRect(t,e,s,n,a,r),!1}updateListViewScrollFromPointer(t){var b,y;if(!this._lastPointerPos||!this._prevPointerPos)return;const i=t.options||{},o=i.orientation||"vertical",e=this._lastPointerPos.x-this._prevPointerPos.x,s=this._lastPointerPos.y-this._prevPointerPos.y;o==="vertical"?i.scrollOffset=(i.scrollOffset||0)+s:i.scrollOffset=(i.scrollOffset||0)+e;const n=i.listLayout||"linear",a=this.objectStates.get(t.id)||{},r=i.items||[],f=i.itemGap??10,h=i.itemHeight??50,l=i.itemWidth??200,p=a.width!==void 0?a.width:((b=t.geometry)==null?void 0:b.width)||200,c=a.height!==void 0?a.height:((y=t.geometry)==null?void 0:y.height)||300;if(n==="circular")return;const d=(r.length||0)*(o==="vertical"?h:l)+((r.length||0)-1)*f,v=Math.max(0,d-(o==="vertical"?c:p)+(i.padding*2||0));i.scrollOffset>0&&(i.scrollOffset=0),i.scrollOffset<-v&&(i.scrollOffset=-v)}updateListViewHoverFromPointer(t,i,o){const e=this.getListViewItemIndexAtPointer(t,i,o),s=t.options||{};s.hoveredIndex!==e&&(s.hoveredIndex=e)}getListViewItemIndexAtPointer(t,i,o){var z,Y;const e=t.options||{},s=this.objectStates.get(t.id)||{},n=e.items||[];if(n.length===0)return null;const a=s.width!==void 0?s.width:((z=t.geometry)==null?void 0:z.width)||200,r=s.height!==void 0?s.height:((Y=t.geometry)==null?void 0:Y.height)||300,f=e.orientation||"vertical",h=e.itemGap??10,l=e.itemHeight??50,p=e.itemWidth??200,c=e.scrollOffset??0,d=e.padding??0,u=this.getWorldTransform(t.id),v=i-u.x,b=o-u.y,y=-u.rotation*(Math.PI/180),m=Math.cos(y),S=Math.sin(y),C=v*m-b*S,w=v*S+b*m,M=-a/2,I=-r/2,k=typeof d=="number"?d:f==="vertical"?d[0]:d[3];let T=(f==="vertical"?I:M)+c+k;const O=e.listLayout||"linear",P=n.length||1,_=Math.PI*2/P,E=e.circularStartAngle||0,A=e.circularRadius||100,W=c*.01+E*Math.PI/180;for(let G=0;G<n.length;G++){const N=O==="circular"?p:f==="vertical"?a:p,J=O==="circular"||f==="vertical"?l:r;let x=0,F=0,j=0;if(O==="circular"){const X=G*_+W,tt=M+a/2,L=I+r/2;x=tt+Math.cos(X)*A-N/2,F=L+Math.sin(X)*A-J/2,j=X+(e.itemRotation||0)*Math.PI/180}else x=f==="vertical"?M:T,F=f==="vertical"?T:I,j=(e.itemRotation||0)*Math.PI/180;if(j!==0){const X=x+N/2,tt=F+J/2,L=C-X,R=w-tt,D=-j,q=L*Math.cos(D)-R*Math.sin(D)+X,ot=L*Math.sin(D)+R*Math.cos(D)+tt;if(q>=x&&q<=x+N&&ot>=F&&ot<=F+J)return G}else if(C>=x&&C<=x+N&&w>=F&&w<=F+J)return G;T+=(f==="vertical"?l:p)+h}return null}drawListViewRect(t,i,o,e,s,n){t.beginPath(),this.drawRoundRect(t,i,o,e,s,n),t.fill()}solveBehaviors(t){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:i,y:o}=this._lastPointerPos;this.artboard.objects.forEach(e=>{if(!e.behaviors||e.behaviors.length===0)return;const s=this.objectStates.get(e.id);s&&e.behaviors.forEach(n=>{var p,c,d,u,v,b,y,m,S,C,w,M,I,k,T,O,P,_,E,A,W,z,Y,G,N,J,x,F,j,X,tt,L,R,D,q,ot,mt,bt,gt,Et,It,vt,Dt,ae,pe,st,yt,Rt,_t,dt,$t,Vt,Bt,Ft,Ut,re,be,ve,Zt,Ce,_e,Pe,we,Ee,Ae,oe,se,ft,ut,at,B,et,Q,Pt,Ot,kt,At,Mt,$,Yt,jt,ie,te,pt,ct,Ct,rt,V,it,nt,St,Gt,ee,le,Nt,Kt,qt,Ie,xe,Oe,Le,Re,Fe,Xe,Ht,ce,Me,$e,Be,ge,de,ue,ke,De,qe,Ke,Ge,Je;if(!n.enabled)return;const a=n.startTime||0,r=n.endTime||1/0;if(this.currentTime<a||this.currentTime>r)return;const f=s.x-i,h=s.y-o,l=Math.sqrt(f*f+h*h);if(this.frameCount%240===0&&Math.random()<.1&&this.log(`[ExodeUI] Executing ${n.type} on ${e.name}`),n.type===H.Proximity){const U=((p=n.settings)==null?void 0:p.radius)||300,Z=((c=n.settings)==null?void 0:c.falloff)||"smooth";let K=0;l<U&&(Z==="linear"?K=1-l/U:K=Math.pow(1-l/U,2)),n.sensors.forEach(ht=>{this.applyBehaviorSensor(s,ht,K,t,n.settings,e,f,h,l)})}else if(n.type===H.Magnetic){const U=((d=n.settings)==null?void 0:d.radius)||400,Z=((u=n.settings)==null?void 0:u.strength)||.5;if(l<U&&l>5){const K=1-l/U,ht=f*K*Z,Tt=h*K*Z;s.x-=ht*t*10,s.y-=Tt*t*10}}else if(n.type===H.Repel){const U=((v=n.settings)==null?void 0:v.radius)||300,Z=((b=n.settings)==null?void 0:b.strength)||1;if(l<U){const K=Math.pow(1-l/U,2);s.x+=f/(l||1)*K*60*Z*t*5,s.y+=h/(l||1)*K*60*Z*t*5}}else if(n.type===H.Orbit){const U=((y=n.settings)==null?void 0:y.speed)||1,Z=((m=n.settings)==null?void 0:m.radius)||30,K=this.currentTime*U*Math.PI*2;s.x+=Math.cos(K)*Z*t*5,s.y+=Math.sin(K)*Z*t*5,s.rotation+=2*t*5}else if(n.type===H.Vortex){const U=((S=n.settings)==null?void 0:S.radius)||400,Z=((C=n.settings)==null?void 0:C.speed)||2,K=((w=n.settings)==null?void 0:w.strength)||1;if(l<U){const ht=Math.pow(1-l/U,1.5),Tt=this.currentTime*Z*Math.PI*2,Lt=Math.cos(Tt)*30-f*.4,Wt=Math.sin(Tt)*30-h*.4;s.x+=Lt*ht*K*t*5,s.y+=Wt*ht*K*t*5,s.rotation+=5*ht*K*t*5,s.scale_x*=1-ht*.1*K*t,s.scale_y*=1-ht*.1*K*t}}else if(n.type===H.Fluid){const U=((M=n.settings)==null?void 0:M.radius)||300,Z=((I=n.settings)==null?void 0:I.strength)||1;if(l<U){const K=Math.pow(1-l/U,1.2),ht=f/(l||1)*K*1.2*Z,Tt=h/(l||1)*K*1.2*Z;s.x+=ht*10*t*5,s.y+=Tt*10*t*5,s.scale_x*=1+K*.3*Z*t,s.scale_y*=1+K*.3*Z*t}}else if(n.type===H.Elastic){const U=((k=n.settings)==null?void 0:k.radius)||300,Z=((T=n.settings)==null?void 0:T.strength)||1;if(l<U){const K=1-l/U;s.scale_x*=1+K*.4*Z*t,s.scale_y*=1+K*.4*Z*t}}else if(n.type===H.Holographic){const U=s.x-this.canvasWidth/2,Z=s.y-this.canvasHeight/2,K=((O=n.settings)==null?void 0:O.factor)||25;if(s.x-=U/1e3*K*t*5,s.y-=Z/1e3*K*t*5,s.style){const ht=1-Math.min(1,l/400);s.style.exposure=(s.style.exposure||1)+ht*.5*t}}else if(n.type===H.Sticky){const U=((P=n.settings)==null?void 0:P.radius)||80,Z=((_=n.settings)==null?void 0:_.strength)||1;if(l<U){const K=Math.pow(1-l/U,2);s.x-=f*K*Z*t*10,s.y-=h*K*Z*t*10,s.scale_x*=1-K*.1*Z*t,s.scale_y*=1-K*.1*Z*t}}else if(n.type===H.Dilation){const U=((E=n.settings)==null?void 0:E.size)||120,Z=((A=n.settings)==null?void 0:A.strength)||1;if(l<U){const K=1-l/U;s.scale_x*=1+K*.5*Z*t,s.scale_y*=1+K*.5*Z*t}}else if(n.type===H.Parallax){const U=((W=n.settings)==null?void 0:W.factor)||15,Z=((z=n.settings)==null?void 0:z.strength)||1,K=this.canvasWidth/2,ht=this.canvasHeight/2,Tt=this._lastPointerPos||{x:K,y:ht},Lt=(Tt.x-K)/K,Wt=(Tt.y-ht)/ht,ne=(((Y=e.transform)==null?void 0:Y.x)??0)+Lt*U*Z,ye=(((G=e.transform)==null?void 0:G.y)??0)+Wt*U*Z,Te=(((N=e.transform)==null?void 0:N.rotate_x)??0)-Wt*U*1.5*Z,fe=(((J=e.transform)==null?void 0:J.rotate_y)??0)+Lt*U*1.5*Z,Se=Math.min(1,10*t);s.x=this.lerp(s.x??((x=e.transform)==null?void 0:x.x)??0,ne,Se),s.y=this.lerp(s.y??((F=e.transform)==null?void 0:F.y)??0,ye,Se),s.rotate_x=this.lerp(s.rotate_x??((j=e.transform)==null?void 0:j.rotate_x)??0,Te,Se),s.rotate_y=this.lerp(s.rotate_y??((X=e.transform)==null?void 0:X.rotate_y)??0,fe,Se)}else if(n.type===H.Fold){if(l<300){const U=1-l/300,Z=(f>0?-1:1)*U*10,K=1-U*.1,ht=h/300*U*20,Tt=-(f/300)*U*20,Lt=Math.min(1,10*t);s.skew_x=this.lerp(s.skew_x??((tt=e.transform)==null?void 0:tt.skew_x)??0,Z,Lt),s.scale_y=this.lerp(s.scale_y??((L=e.transform)==null?void 0:L.scale_y)??1,(((R=e.transform)==null?void 0:R.scale_y)??1)*K,Lt),s.rotate_x=this.lerp(s.rotate_x??((D=e.transform)==null?void 0:D.rotate_x)??0,ht,Lt),s.rotate_y=this.lerp(s.rotate_y??((q=e.transform)==null?void 0:q.rotate_y)??0,Tt,Lt),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((ot=n.settings)==null?void 0:ot.opacity)??.5}}}else if(n.type===H.Crumple){if(l<300){const U=1-l/300,Z=U*(Math.random()-.5)*5,K=U*(Math.random()-.5)*.05,ht=Math.min(1,15*t);s.skew_x=this.lerp(s.skew_x??((mt=e.transform)==null?void 0:mt.skew_x)??0,Z,ht),s.scale_x=this.lerp(s.scale_x??((bt=e.transform)==null?void 0:bt.scale_x)??1,(((gt=e.transform)==null?void 0:gt.scale_x)??1)*(1+K),ht),s.scale_y=this.lerp(s.scale_y??((Et=e.transform)==null?void 0:Et.scale_y)??1,(((It=e.transform)==null?void 0:It.scale_y)??1)*(1+K),ht),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((vt=n.settings)==null?void 0:vt.intensity)??1,scale:((Dt=n.settings)==null?void 0:Dt.scale)??2}}}else if(n.type===H.Squash){const U=((ae=n.settings)==null?void 0:ae.strength)||.8;l<(e.width||100)&&this.isMouseDown?(s.scale_y=this.lerp(s.scale_y??1,(((pe=e.transform)==null?void 0:pe.scale_y)??1)*U,.3),s.scale_x=this.lerp(s.scale_x??1,(((st=e.transform)==null?void 0:st.scale_x)??1)*(1+(1-U)*.4),.3)):(s.scale_y=this.lerp(s.scale_y??1,((yt=e.transform)==null?void 0:yt.scale_y)??1,.2),s.scale_x=this.lerp(s.scale_x??1,((Rt=e.transform)==null?void 0:Rt.scale_x)??1,.2))}else if(n.type===H.TextCounter){const U=((_t=n.settings)==null?void 0:_t.duration)||2,Z=((dt=n.settings)==null?void 0:dt.from)||0,K=(($t=n.settings)==null?void 0:$t.to)||100;n._runtimeStart===void 0&&(n._runtimeStart=this.currentTime);const ht=this.currentTime-n._runtimeStart,Tt=Math.min(1,ht/U),Lt=Math.floor(Z+(K-Z)*Tt);if(((Vt=e.geometry)==null?void 0:Vt.type)==="Text"){const Wt=((Bt=n.settings)==null?void 0:Bt.prefix)||"",ne=((Ft=n.settings)==null?void 0:Ft.suffix)||"";s.geometry||(s.geometry={...e.geometry}),s.geometry.text=`${Wt}${Lt}${ne}`}}else if(n.type===H.Spotlight){const U=((Ut=n.settings)==null?void 0:Ut.radius)||250,Z=((re=n.settings)==null?void 0:re.strength)||1.5;if(l<U){const K=Math.pow(1-l/U,2);s.style||(s.style={...e.style}),s.style.adjustments||(s.style.adjustments={...(be=e.style)==null?void 0:be.adjustments}),s.style.adjustments.exposure=(((Zt=(ve=e.style)==null?void 0:ve.adjustments)==null?void 0:Zt.exposure)||0)+K*Z*50}else(Ce=s.style)!=null&&Ce.adjustments&&(s.style.adjustments.exposure=this.lerp(s.style.adjustments.exposure||0,((Pe=(_e=e.style)==null?void 0:_e.adjustments)==null?void 0:Pe.exposure)||0,.1))}else if(n.type===H.Noise||n.type===H.Float){const U=(((we=n.settings)==null?void 0:we.frequency)||((Ee=n.settings)==null?void 0:Ee.speed)||1)*.002,Z=(((Ae=n.settings)==null?void 0:Ae.amplitude)||((oe=n.settings)==null?void 0:oe.range)||50)*(((se=n.settings)==null?void 0:se.strength)||1),K=Date.now();s.x+=Math.sin(K*U)*Z*t,s.y+=Math.cos(K*U*.8)*Z*t,s.rotation+=Math.sin(K*U*.5)*5*t}else if(n.type===H.Pulse){const U=(((ft=n.settings)==null?void 0:ft.speed)||1)*.005,Z=(((ut=n.settings)==null?void 0:ut.scale)||1.2)-1,K=Math.sin(Date.now()*U),ht=((at=n.settings)==null?void 0:at.strength)||1;s.scale_x*=1+K*Z*ht*t,s.scale_y*=1+K*Z*ht*t,s.style&&(s.style.exposure=(s.style.exposure||1)+Math.max(0,K)*.1*ht*t)}else if(n.type===H.Draggable){const U=((B=n.settings)==null?void 0:B.radius)||150,Z=this.draggingBehaviors.has(e.id);if(l<U||Z){const K=((et=n.settings)==null?void 0:et.strength)||1,ht=Z?1:Math.max(0,1-l/U);this.applyBehaviorSensor(s,Qt.PositionX,ht*K,t,n.settings),this.applyBehaviorSensor(s,Qt.PositionY,ht*K,t,n.settings)}}else if(n.type===H.Scroll){const U=((Q=n.settings)==null?void 0:Q.axis)||"vertical",Z=((Pt=n.settings)==null?void 0:Pt.factor)||.5,K=((Ot=n.settings)==null?void 0:Ot.strength)||1,ht=((kt=n.settings)==null?void 0:kt.scaleFactor)||0;(U==="vertical"||U==="both")&&(s.y+=this.scrollOffset.y*Z*K*t),(U==="horizontal"||U==="both")&&(s.x+=this.scrollOffset.x*Z*K*t),ht!==0&&(s.scale_x*=1+this.scrollOffset.y*ht*t,s.scale_y*=1+this.scrollOffset.y*ht*t)}else if(n.type===H.LookAt){const U=((At=n.settings)==null?void 0:At.factor)||1,Z=((Mt=n.settings)==null?void 0:Mt.strength)||1,K=Math.atan2(-h,-f)*(180/Math.PI),ht=s.rotation,Tt=(K-ht+180)%360-180;s.rotation+=Tt*U*Z*t*10}else if(n.type===H.Scan){const U=((($=n.settings)==null?void 0:$.speed)||1)*.004,Z=((Yt=n.settings)==null?void 0:Yt.strength)||1,K=(Math.sin(Date.now()*U)+1)/2;s.style&&(s.style.exposure=(s.style.exposure||1)+K*Z*t*5),s.x+=(K-.5)*20*Z*t}else if(n.type===H.Glint)s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"glint_overlay",intensity:((jt=n.settings)==null?void 0:jt.strength)??.8};else if(n.type===H.Ratchet){const U=((ie=n.settings)==null?void 0:ie.steps)||12,Z=(((te=n.settings)==null?void 0:te.speed)||1)*30,K=Math.floor(s.rotation/(360/U))*(360/U);s.rotation=this.lerp(s.rotation,K+Z*t,.1)}else if(n.type===H.Jitter&&l<300){const U=((pt=n.settings)==null?void 0:pt.strength)||1,Z=(((ct=n.settings)==null?void 0:ct.intensity)||5)*U;s.x+=(Math.random()-.5)*Z*t*60,s.y+=(Math.random()-.5)*Z*t*60,s.rotation+=(Math.random()-.5)*Z*t*120}else if(n.type===H.Follower){const U=(Ct=n.settings)==null?void 0:Ct.targetId;if(U){const Z=this.objectStates.get(U);if(Z){const K=((rt=n.settings)==null?void 0:rt.stiffness)||.1,ht=Z.x-s.x,Tt=Z.y-s.y;s.x+=ht*K*t*60,s.y+=Tt*K*t*60}}}else if(n.type===H.Wrap)s.x<0?s.x=this.canvasWidth:s.x>this.canvasWidth&&(s.x=0),s.y<0?s.y=this.canvasHeight:s.y>this.canvasHeight&&(s.y=0);else if(n.type===H.Gravity){const U=((V=n.settings)==null?void 0:V.strength)||9.8;s.y+=U*t*10}else if(n.type===H.Velocity){const U=((it=n.settings)==null?void 0:it.vx)||0,Z=((nt=n.settings)==null?void 0:nt.vy)||0;s.x+=U*t*10,s.y+=Z*t*10}else if(n.type===H.Shear){const U=((St=n.settings)==null?void 0:St.strength)||1,Z=((Gt=n.settings)==null?void 0:Gt.radius)||300;if(l<Z){const K=1-l/Z;s.skew_x=this.lerp(s.skew_x||0,(((ee=e.transform)==null?void 0:ee.skew_x)||0)+K*U*30,.1)}else s.skew_x=this.lerp(s.skew_x||0,((le=e.transform)==null?void 0:le.skew_x)||0,.05)}else if(n.type===H.Lens){const U=((Nt=n.settings)==null?void 0:Nt.radius)||200,Z=((Kt=n.settings)==null?void 0:Kt.strength)||.5;if(l<U){const K=Math.pow(1-l/U,2);s.scale_x=this.lerp(s.scale_x??1,(((qt=e.transform)==null?void 0:qt.scale_x)??1)*(1+K*Z),.2),s.scale_y=this.lerp(s.scale_y??1,(((Ie=e.transform)==null?void 0:Ie.scale_y)??1)*(1+K*Z),.2)}else s.scale_x=this.lerp(s.scale_x??1,((xe=e.transform)==null?void 0:xe.scale_x)??1,.1),s.scale_y=this.lerp(s.scale_y??1,((Oe=e.transform)==null?void 0:Oe.scale_y)??1,.1)}else if(n.type===H.LayoutAnimation){const U=((Le=n.settings)==null?void 0:Le.watchProperties)||["x","y","scale_x","scale_y","opacity","rotation"],Z=((Re=n.settings)==null?void 0:Re.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const K=this._layoutAnimCache.get(e.id);for(const ht of U){const Tt=this.getObjectProperty(s,e,ht);if(Tt===void 0)continue;const Lt=K.get(ht);if(!Lt)K.set(ht,{from:Tt,to:Tt,startTime:this.currentTime,duration:0});else if(Lt.to!==Tt){const ne=this.getObjectProperty(s,e,ht);K.set(ht,{from:ne??Lt.from,to:Tt,startTime:this.currentTime,duration:((Fe=n.settings)==null?void 0:Fe.duration)??Z})}const Wt=K.get(ht);if(Wt.duration>0&&Wt.from!==Wt.to){const ne=this.currentTime-Wt.startTime,ye=Math.min(1,ne/Wt.duration),Te=this.applyEasing(ye,((Xe=n.settings)==null?void 0:Xe.easing)||"easeOutCubic"),fe=Wt.from+(Wt.to-Wt.from)*Te;this.setObjectProperty(s,e,ht,fe)}}}else if(n.type===H.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const U=this._layoutAnimCache.get(e.id),Z=((Ht=n.settings)==null?void 0:Ht.defaultDuration)||.3,K=["x","y","scale_x","scale_y","opacity","rotation","style.fill.color","style.stroke.width","geometry.cornerRadius","style.blur.value","style.shadow.blur","style.shadow.offsetX","style.shadow.offsetY"];for(const ht of K){const Tt=this.getObjectProperty(s,e,ht);if(Tt===void 0||typeof Tt!="number")continue;const Lt=U.get(ht);if(!Lt)U.set(ht,{from:Tt,to:Tt,startTime:this.currentTime,duration:0});else if(Lt.to!==Tt){const ne=this.getObjectProperty(s,e,ht);U.set(ht,{from:ne??Lt.from,to:Tt,startTime:this.currentTime,duration:Z})}const Wt=U.get(ht);if(Wt.duration>0&&Wt.from!==Wt.to){const ne=this.currentTime-Wt.startTime,ye=Math.min(1,ne/Wt.duration),Te=this.applyEasing(ye,((ce=n.settings)==null?void 0:ce.defaultEasing)||"easeOutCubic"),fe=Wt.from+(Wt.to-Wt.from)*Te;this.setObjectProperty(s,e,ht,fe)}}}else if(n.type===H.SpringChain){const U=((Me=n.settings)==null?void 0:Me.connections)||[],Z=(($e=n.settings)==null?void 0:$e.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const K=this._springChainState.get(e.id);for(const Tt of U){if(!K.has(Tt.targetId)){const Lt=this.objectStates.get(Tt.targetId);K.set(Tt.targetId,{x:(Lt==null?void 0:Lt.x)??0,y:(Lt==null?void 0:Lt.y)??0,vx:0,vy:0})}K.has(e.id)||K.set(e.id,{x:s.x,y:s.y,vx:0,vy:0})}const ht=K.get(e.id);if(ht){ht.x=s.x,ht.y=s.y;for(const Tt of U){const Lt=K.get(Tt.targetId);if(!Lt)continue;const Wt=Lt.x-ht.x,ne=Lt.y-ht.y,ye=Math.sqrt(Wt*Wt+ne*ne)||.001,fe=(ye-(Tt.restLength||50))*(Tt.stiffness||.8),Se=Wt/ye*fe,Qe=ne/ye*fe;ht.vx+=Se*t*10,ht.vy+=Qe*t*10,Lt.vx-=Se*t*10,Lt.vy-=Qe*t*10,ht.vx*=1-Z*t*10,ht.vy*=1-Z*t*10,Lt.vx*=1-Z*t*10,Lt.vy*=1-Z*t*10;const me=this.objectStates.get(Tt.targetId);me&&(me.x+=Lt.vx*t,me.y+=Lt.vy*t)}s.x+=ht.vx*t,s.y+=ht.vy*t}}else if(n.type===H.ParticleEmitter){const U=((Be=n.settings)==null?void 0:Be.rate)||10,Z=((ge=n.settings)==null?void 0:ge.speed)||100,K=((de=n.settings)==null?void 0:de.size)||5,ht=((ue=n.settings)==null?void 0:ue.lifetime)||2,Tt=((ke=n.settings)==null?void 0:ke.gravity)||0,Lt=((De=n.settings)==null?void 0:De.color)||"#ffffff",Wt=((qe=n.settings)==null?void 0:qe.maxParticles)||200,ne=(Ke=n.settings)!=null&&Ke.rateInputId?this.inputs.get(n.settings.rateInputId)??U:U,ye=(Ge=n.settings)!=null&&Ge.gravityInputId?this.inputs.get(n.settings.gravityInputId)??Tt:Tt,Te=(Je=n.settings)!=null&&Je.speedInputId?this.inputs.get(n.settings.speedInputId)??Z:Z;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const fe=this._emitterPools.get(e.id);let Se=0;n._pendingBurst&&n._pendingBurst>0&&(Se=n._pendingBurst,n._pendingBurst=0);const Qe=Math.floor(ne*t)+(Se||0);for(let me=0;me<Math.min(Qe,Wt-fe.length);me++){const he=Math.random()*Math.PI*2,ms=Te*(.5+Math.random()*.5);fe.push({x:s.x,y:s.y,vx:Math.cos(he)*ms,vy:Math.sin(he)*ms,life:0,maxLife:ht*(.5+Math.random()*.5),size:K*(.5+Math.random()),color:Lt,opacity:1})}for(let me=fe.length-1;me>=0;me--){const he=fe[me];he.vy+=ye*t*10,he.x+=he.vx*t,he.y+=he.vy*t,he.life+=t,he.opacity=Math.max(0,1-he.life/he.maxLife),he.life>=he.maxLife&&fe.splice(me,1)}}})})}applyBehaviorSensor(t,i,o,e,s,n,a=0,r=0,f=1){var d,u,v,b,y,m,S,C,w,M,I,k,T,O,P,_,E,A,W,z,Y,G,N,J;const h=(s==null?void 0:s.intensity)||(s==null?void 0:s.strength)||1,l=Math.min(1,15*e),p=f>0?a/f:0,c=f>0?r/f:0;switch(i){case Qt.Scale:{const x=((d=n==null?void 0:n.transform)==null?void 0:d.scale_x)??1,F=((u=n==null?void 0:n.transform)==null?void 0:u.scale_y)??1,j=x*(1+o*h*.4),X=F*(1+o*h*.4);t.scale_x=(t.scale_x??x)*(1-l)+j*l,t.scale_y=(t.scale_y??F)*(1-l)+X*l;break}case Qt.Opacity:{const x=((v=n==null?void 0:n.transform)==null?void 0:v.opacity)??100,F=Math.max(0,Math.min(100,x-o*h*100));t.opacity=(t.opacity??x)*(1-l)+F*l;break}case Qt.RotateZ:{const x=((b=n==null?void 0:n.transform)==null?void 0:b.rotation)??0,F=x+o*h*45;t.rotation=(t.rotation??x)*(1-l)+F*l;break}case Qt.RotateX:{const x=((y=n==null?void 0:n.transform)==null?void 0:y.rotate_x)??0,F=x-c*o*h*60;t.rotate_x=(t.rotate_x??x)*(1-l)+F*l;break}case Qt.RotateY:{const x=((m=n==null?void 0:n.transform)==null?void 0:m.rotate_y)??0,F=x+p*o*h*60;t.rotate_y=(t.rotate_y??x)*(1-l)+F*l;break}case Qt.PositionX:{const x=((S=n==null?void 0:n.transform)==null?void 0:S.x)??0,F=x-p*o*h*40;t.x=(t.x??x)*(1-l)+F*l;break}case Qt.PositionY:{const x=((C=n==null?void 0:n.transform)==null?void 0:C.y)??0,F=x-c*o*h*40;t.y=(t.y??x)*(1-l)+F*l;break}case Qt.SkewX:{const x=((w=n==null?void 0:n.transform)==null?void 0:w.skew_x)??0,F=x+p*o*h*45;t.skew_x=(t.skew_x??x)*(1-l)+F*l,t.skew_x>85&&(t.skew_x=85),t.skew_x<-85&&(t.skew_x=-85);break}case Qt.Blur:{t.style||(t.style={...n==null?void 0:n.style}),t.style.blur||(t.style.blur={...(M=n==null?void 0:n.style)==null?void 0:M.blur});const x=((k=(I=n==null?void 0:n.style)==null?void 0:I.blur)==null?void 0:k.amount)||0,F=x+o*((s==null?void 0:s.blur)||20)*h;t.style.blur.amount=(t.style.blur.amount??x)*(1-l)+F*l;break}case Qt.Exposure:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(T=n==null?void 0:n.style)==null?void 0:T.adjustments});const x=((P=(O=n==null?void 0:n.style)==null?void 0:O.adjustments)==null?void 0:P.exposure)||0,F=x+o*((s==null?void 0:s.exposure)||50)*h;t.style.adjustments.exposure=(t.style.adjustments.exposure??x)*(1-l)+F*l;break}case Qt.HueShift:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(_=n==null?void 0:n.style)==null?void 0:_.adjustments});const x=((A=(E=n==null?void 0:n.style)==null?void 0:E.adjustments)==null?void 0:A.hue)||0,F=x+o*((s==null?void 0:s.hue)||180)*h;t.style.adjustments.hue=(t.style.adjustments.hue??x)*(1-l)+F*l;break}case Qt.Negative:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(W=n==null?void 0:n.style)==null?void 0:W.adjustments});const x=((Y=(z=n==null?void 0:n.style)==null?void 0:z.adjustments)==null?void 0:Y.negative)||0,F=x+o*((s==null?void 0:s.negative)||100)*h;t.style.adjustments.negative=(t.style.adjustments.negative??x)*(1-l)+F*l;break}case Qt.CornerRadius:{const x=((G=n==null?void 0:n.transform)==null?void 0:G.corner_radius)||0,F=x+o*h*50;t.corner_radius=(t.corner_radius??x)*(1-l)+F*l;break}case Qt.StrokeWidth:{t.style||(t.style={...n==null?void 0:n.style});const x=((N=n==null?void 0:n.style)==null?void 0:N.borderWidth)||0,F=x+o*h*10;t.style.borderWidth=(t.style.borderWidth??x)*(1-l)+F*l;break}case Qt.LetterSpacing:{t.geometry||(t.geometry={});const x=((J=n==null?void 0:n.geometry)==null?void 0:J.letterSpacing)||0,F=x+o*h*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??x)*(1-l)+F*l;break}}}getObjectProperty(t,i,o){const e=o.split(".");let s=t;for(const n of e){if(s==null||typeof s!="object")return;if(n==="style"&&t.style===void 0){s=i.style;continue}s=s[n]}return typeof s=="number"?s:void 0}setObjectProperty(t,i,o,e){const s=o.split(".");let n=t;for(let r=0;r<s.length-1;r++){const f=s[r];if(n[f]===void 0||n[f]===null){const h=i,l=s.slice(0,r+1).reduce((p,c)=>p==null?void 0:p[c],h);n[f]=l!==void 0?{...l}:{}}n=n[f]}const a=s[s.length-1];n!=null&&(n[a]=e)}applyEasing(t,i){switch(i){case"easeOutCubic":return 1-Math.pow(1-t,3);case"easeInCubic":return t*t*t;case"easeInOutCubic":return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;case"easeOutQuad":return t*(2-t);case"easeInQuad":return t*t;case"easeInOutQuad":return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2;case"easeOutExpo":return t===1?1:1-Math.pow(2,-10*t);case"easeOutBack":return 1+2.70158*Math.pow(t-1,3)+1.70158*Math.pow(t-1,2);case"easeOutElastic":{const o=2*Math.PI/3;return t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*o)+1}case"easeOutBounce":return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375;case"linear":return t;default:return 1-Math.pow(1-t,3)}}lerp(t,i,o){return t*(1-o)+i*o}deepMerge(t,i){if(!t)return i;if(!i)return t;if(typeof t!="object"||typeof i!="object"||t===null||i===null)return i;const o={...t};for(const e in i)Object.prototype.hasOwnProperty.call(i,e)&&(i[e]&&typeof i[e]=="object"&&!Array.isArray(i[e])?o[e]=this.deepMerge(t[e],i[e]):o[e]=i[e]);return o}renderFittedImage(t,i,o,e,s,n,a="cover"){const r=i.naturalWidth,f=i.naturalHeight,h=r/f,l=s/n;let p=s,c=n,d=o,u=e;a==="cover"?h>l?(p=n*h,d=o-(p-s)/2):(c=s/h,u=e-(c-n)/2):a==="contain"&&(h>l?(c=s/h,u=e+(n-c)/2):(p=n*h,d=o+(s-p)/2)),t.drawImage(i,d,u,p,c)}}const ni=xt.forwardRef(({artboard:g,src:t,style:i,autoPlay:o=!0,fit:e="Contain",alignment:s="Center",onReady:n,onTrigger:a,onInputUpdate:r,onComponentChange:f,onToggle:h,onInputChange:l,onInputFocus:p,onInputBlur:c,onLog:d,onLogicUpdate:u,onButtonClick:v,onGraphPointClick:b,currentTime:y,revision:m=0,scrollY:S,scrollX:C,mouseX:w,mouseY:M,isMouseDown:I,inputs:k,interactive:T=!0,onNavigation:O},P)=>{const _=xt.useRef(null),E=xt.useRef(null);E.current||(E.current=new ys);const A=xt.useRef(void 0),W=xt.useRef(0),z=xt.useRef(null),Y=xt.useRef(m),G=xt.useRef(null),[,N]=xt.useState(g||null),J=xt.useRef(!0);xt.useImperativeHandle(P,()=>_.current),xt.useEffect(()=>(J.current=!0,()=>{J.current=!1,A.current&&cancelAnimationFrame(A.current)}),[]),xt.useEffect(()=>{E.current.setLayout(e,s)},[e,s]),xt.useEffect(()=>{const L=E.current;a&&L.setTriggerCallback(a),r&&L.setInputUpdateCallback((R,D)=>r({[R]:D})),f&&L.setComponentChangeCallback(R=>f(R)),h&&L.setToggleCallback(h),l&&L.setInputChangeCallback(l),p&&L.setInputFocusCallback(p),c&&L.setInputBlurCallback(c),d&&L.setOnLogCallback(R=>d(R,"info")),u&&L.setLogicUpdateCallback(u),v&&L.setButtonClickCallback(v),b&&L.setGraphPointClickCallback(R=>b(R.objectId,R)),O&&L.setNavigationCallback(O)},[a,r,f,h,l,p,c,d,u,v,b,O]),xt.useEffect(()=>{(async()=>{let R=g;if(t&&!g)try{t.startsWith("{")?R=JSON.parse(t):R=await(await fetch(t)).json()}catch(D){console.error("[ExodeUI] Failed to load src:",D)}if(R){const D=E.current,q=R.id||R.name||"default";(z.current!==q||Y.current!==m||G.current!==R)&&(D.load(R),z.current=q,Y.current=m,G.current=R,N(R),W.current=0,D.advance(0)),n&&n(D)}})()},[g,t,m]),xt.useEffect(()=>{const L=R=>{if(!E.current||!J.current)return;const D=E.current,q=_.current;if(!q)return;const ot=q.getContext("2d");if(!ot)return;const mt=R/1e3;W.current===0&&(W.current=mt);let bt=mt-W.current;bt>.1&&(bt=.1),W.current=mt;const gt=q.getBoundingClientRect(),Et=window.devicePixelRatio||1,It=Math.round(gt.width*Et),vt=Math.round(gt.height*Et);(q.width!==It||q.height!==vt)&&(q.width=It,q.height=vt);try{o?D.advance(bt):y!==void 0&&D.seek(y),D.render(ot,q.width,q.height)}catch(Dt){console.error("[ExodeUICanvas] Error in animation loop:",Dt),d&&d(`[Error] Animation loop crashed: ${Dt}`,"error")}A.current=requestAnimationFrame(L)};return A.current=requestAnimationFrame(L),()=>{A.current&&cancelAnimationFrame(A.current)}},[o,y]),xt.useEffect(()=>{const L=E.current;S!==void 0&&L.updateInput("scrollY",S),C!==void 0&&L.updateInput("scrollX",C),w!==void 0&&L.updateInput("mouseX",w),M!==void 0&&L.updateInput("mouseY",M),I!==void 0&&L.updateInput("isMouseDown",I),k&&Object.entries(k).forEach(([R,D])=>L.updateInput(R,D))},[S,C,w,M,I,k]);const x=(L,R)=>{if(!T||!_.current)return;L.stopPropagation(),"nativeEvent"in L&&L.nativeEvent&&typeof L.nativeEvent.stopImmediatePropagation=="function"?L.nativeEvent.stopImmediatePropagation():typeof L.stopImmediatePropagation=="function"&&L.stopImmediatePropagation();const D=_.current,q=D.getBoundingClientRect(),ot=L.clientX-q.left,mt=L.clientY-q.top,bt=window.devicePixelRatio||1;(R==="click"||R==="down"||R==="up")&&d&&d(`[Canvas] Pointer ${R} at rect(${Math.round(ot)},${Math.round(mt)}) mapped to buffer(${Math.round(ot*bt)},${Math.round(mt*bt)})`,"info"),E.current.handlePointerInput(R,ot*bt,mt*bt,D.width,D.height)};xt.useEffect(()=>{if(!T)return;const L=D=>{var q,ot,mt;((q=document.activeElement)==null?void 0:q.tagName)==="INPUT"||((ot=document.activeElement)==null?void 0:ot.tagName)==="TEXTAREA"||(mt=E.current)==null||mt.handleKeyDown(D)},R=D=>{var q,ot,mt;((q=document.activeElement)==null?void 0:q.tagName)==="INPUT"||((ot=document.activeElement)==null?void 0:ot.tagName)==="TEXTAREA"||(mt=E.current)==null||mt.handleKeyUp(D)};return window.addEventListener("keydown",L),window.addEventListener("keyup",R),()=>{window.removeEventListener("keydown",L),window.removeEventListener("keyup",R)}},[T]);const[F,j]=xt.useState([]);xt.useEffect(()=>{if(g&&g.objects){const L=g.objects.filter(R=>{var D,q;return R.type==="Joystick"&&((D=R.inputBinding)==null?void 0:D.type)==="keyboard"&&((q=R.inputBinding.keyboardConfig)==null?void 0:q.showVirtualKeyboard)});j(L)}},[g]);const[,X]=xt.useState(0);xt.useEffect(()=>{if(F.length===0)return;let L;const R=()=>{X(D=>D+1),L=requestAnimationFrame(R)};return L=requestAnimationFrame(R),()=>cancelAnimationFrame(L)},[F.length]);const tt=()=>F.map(L=>{const R=L.inputBinding.keyboardConfig,D=gt=>{var It;const Et={key:gt,code:gt,preventDefault:()=>{}};(It=E.current)==null||It.handleKeyDown(Et)},q=gt=>{var It;const Et={key:gt,code:gt,preventDefault:()=>{}};(It=E.current)==null||It.handleKeyUp(Et)},ot=E.current,mt=gt=>ot&&ot.activeKeys?ot.activeKeys.has(gt.toLowerCase()):!1,bt=gt=>({width:"50px",height:"50px",background:gt?"rgba(255, 255, 255, 0.4)":"rgba(0, 0, 0, 0.4)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontWeight:"bold",fontSize:"18px",userSelect:"none",cursor:"pointer",backdropFilter:"blur(8px)",transition:"background 0.1s",boxShadow:gt?"none":"0 4px 6px rgba(0,0,0,0.1)"});return Xt.jsxs("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",pointerEvents:"auto",zIndex:100},children:[Xt.jsx("div",{style:bt(mt(R.upKey)),onMouseDown:()=>D(R.upKey),onMouseUp:()=>q(R.upKey),onMouseLeave:()=>q(R.upKey),onTouchStart:gt=>{gt.preventDefault(),D(R.upKey)},onTouchEnd:gt=>{gt.preventDefault(),q(R.upKey)},children:R.upKey.toUpperCase()}),Xt.jsxs("div",{style:{display:"flex",gap:"8px"},children:[Xt.jsx("div",{style:bt(mt(R.leftKey)),onMouseDown:()=>D(R.leftKey),onMouseUp:()=>q(R.leftKey),onMouseLeave:()=>q(R.leftKey),onTouchStart:gt=>{gt.preventDefault(),D(R.leftKey)},onTouchEnd:gt=>{gt.preventDefault(),q(R.leftKey)},children:R.leftKey.toUpperCase()}),Xt.jsx("div",{style:bt(mt(R.downKey)),onMouseDown:()=>D(R.downKey),onMouseUp:()=>q(R.downKey),onMouseLeave:()=>q(R.downKey),onTouchStart:gt=>{gt.preventDefault(),D(R.downKey)},onTouchEnd:gt=>{gt.preventDefault(),q(R.downKey)},children:R.downKey.toUpperCase()}),Xt.jsx("div",{style:bt(mt(R.rightKey)),onMouseDown:()=>D(R.rightKey),onMouseUp:()=>q(R.rightKey),onMouseLeave:()=>q(R.rightKey),onTouchStart:gt=>{gt.preventDefault(),D(R.rightKey)},onTouchEnd:gt=>{gt.preventDefault(),q(R.rightKey)},children:R.rightKey.toUpperCase()})]})]},L.id)});return Xt.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[Xt.jsx("canvas",{ref:_,onPointerDown:L=>{var R;x(L,"down"),(R=_.current)==null||R.focus()},onPointerMove:L=>x(L,"move"),onPointerUp:L=>x(L,"up"),onPointerCancel:L=>x(L,"up"),onClick:L=>x(L,"click"),onWheel:L=>{E.current.handleWheel(L.deltaX,L.deltaY)},onKeyDown:L=>E.current.handleKeyDown(L.nativeEvent),onKeyUp:L=>E.current.handleKeyUp(L.nativeEvent),onContextMenu:L=>L.preventDefault(),tabIndex:0,style:{...i,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:T?"auto":"none"}}),tt()]})});function oi(){const[g,t]=xt.useState(null),i=xt.useCallback((l,p)=>{g==null||g.setInputBool(l,p)},[g]),o=xt.useCallback((l,p)=>{g==null||g.setInputNumber(l,p)},[g]),e=xt.useCallback(l=>{g==null||g.fireTrigger(l)},[g]),s=xt.useCallback((l,p)=>{g==null||g.setInputText(l,p)},[g]),n=xt.useCallback((l,p)=>{g==null||g.setInputNumberArray(l,p)},[g]),a=xt.useCallback((l,p)=>{g==null||g.setInputStringArray(l,p)},[g]),r=xt.useCallback((l,p)=>{g==null||g.updateObjectOptions(l,p)},[g]),f=xt.useCallback((l,p,c)=>{g==null||g.updateConstraint(l,p,c)},[g]),h=xt.useCallback((l,p)=>{g==null||g.updateGraphData(l,p)},[g]);return{setEngine:t,engine:g,setInputBool:i,setInputNumber:o,fireTrigger:e,setInputText:s,setInputNumberArray:n,setInputStringArray:a,updateConstraint:f,updateGraphData:h,updateObjectOptions:r}}const ai=({artboard:g,config:t})=>{const i={...g.seo,...t},o=i.enableSmartExtraction!==!1;xt.useEffect(()=>{const a=i.title||g.name;a&&(document.title=a);let r=i.description;if(!r&&o){const l=g.objects.filter(p=>{var c;return((c=p.geometry)==null?void 0:c.type)==="Text"}).sort((p,c)=>{var d,u;return(((d=c.geometry.text)==null?void 0:d.length)||0)-(((u=p.geometry.text)==null?void 0:u.length)||0)});l.length>0&&(r=l[0].geometry.text)}r&&(e("name","description",r),e("property","og:description",r)),i.keywords&&i.keywords.length>0&&e("name","keywords",i.keywords.join(", "));const f=i.ogImage||g.backgroundImage;f&&e("property","og:image",f),a&&e("property","og:title",a),e("property","og:type","website")},[i,g,o]);const e=(a,r,f)=>{let h=document.querySelector(`meta[${a}="${r}"]`);h||(h=document.createElement("meta"),h.setAttribute(a,r),document.head.appendChild(h)),h.setAttribute("content",f)},s=()=>{const a=[];return a.push(Xt.jsx("h1",{children:i.title||g.name},"artboard-title")),g.objects.forEach((f,h)=>{var l,p;if(!(f.visible===!1||f.isVisible===!1))if(((l=f.geometry)==null?void 0:l.type)==="Text"){const c=f.geometry.text;c&&(f.geometry.fontSize>24?a.push(Xt.jsx("h2",{children:c},f.id||h)):a.push(Xt.jsx("p",{children:c},f.id||h)))}else if(((p=f.geometry)==null?void 0:p.type)==="Image"){const c=f.geometry.src,d=f.altText||f.name||"Illustration";a.push(Xt.jsx("img",{src:c,alt:d},f.id||h))}else f.type==="Button"&&a.push(Xt.jsx("button",{children:f.name||"Button"},f.id||h))}),a},n=i.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:i.title||g.name,description:i.description,image:i.ogImage||g.backgroundImage,abstract:"Animated interface created with ExodeUI"};return Xt.jsxs("div",{id:`exode-seo-${g.id||"default"}`,"aria-hidden":"false",style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0",zIndex:-1},children:[s(),Xt.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})]})},ri={version:"6.3.40"}.version;zt.BehaviorSensor=Qt,zt.BehaviorType=H,zt.ConditionOp=je,zt.ExodeSEO=ai,zt.ExodeUICanvas=ni,zt.ExodeUIEngine=ys,zt.LogicOp=wt,zt.RapierPhysics=is,zt.VERSION=ri,zt.useExodeUI=oi,Object.defineProperty(zt,Symbol.toStringTag,{value:"Module"})}));
|
|
33
|
+
`&&dt++)}),t.globalAlpha=yt}}}applyStrokeAlignment(t,i,o,e,s,n,a=1,r=1){if(!i.stroke||i.stroke.width<=0||i.stroke.isEnabled===!1)return;const f=i.stroke;let h=1;if(this.rootTransform){const S=t.getTransform(),C=Math.sqrt(S.a*S.a+S.b*S.b)||1,w=this.rootTransform,M=Math.sqrt(w.a*w.a+w.b*w.b)||1;h=C/M}else h=(Math.abs(a)+Math.abs(r))/2||1;const l=(f.width||1)/(h||1),p=(f.alignment||"center").toLowerCase();if(t.save(),i.fill&&i.fill.type!=="None"&&i.fill.isEnabled!==!1&&i.fill.opacity!==0&&i.fill.color!=="transparent"&&i.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),f.fill){const S=this.createCanvasFill(t,f.fill,e,s);S?t.strokeStyle=S:t.strokeStyle=f.color||"#000000"}else t.strokeStyle=f.color||"#000000";const d=t.globalAlpha;t.globalAlpha=d*this.normalizeOpacity(f.opacity??100),t.lineWidth=l,t.lineCap=f.lineCap||"round",t.lineJoin=f.lineJoin||"round",f.miterLimit!==void 0&&(t.miterLimit=f.miterLimit);const u=f.trimStart??0,v=f.trimEnd??1,b=f.trimOffset??0,y=f.dashOffset??0,m=f.dashArray||[];if(u!==0||v!==1||b!==0){const S=this.getPerimeter(o,e,s);if(S>0){const C=Math.max(0,Math.min(1,u)),w=Math.max(0,Math.min(1,v));if(C<w){const M=S*(w-C),I=S-M,k=-(S*(C+b%1));t.setLineDash([M,I]),t.lineDashOffset=k+y*S}else if(C===w)t.setLineDash([0,S]);else{const M=S*(1-C+w),I=S-M,k=-(S*C);t.setLineDash([M,I]),t.lineDashOffset=k+y*S}}}else m.length>0&&(t.setLineDash(m),t.lineDashOffset=y);if((o==null?void 0:o.type)==="Line"||e===0||s===0)this.applyPath(t,o,e,s,n),t.stroke();else if(p==="inside")t.lineWidth=l*2,t.save(),this.applyPath(t,o,e,s,n),t.clip(),t.stroke(),t.restore();else if(p==="outside"){t.save(),t.beginPath();const S=Math.max(e,s,2e4);t.rect(-S,-S,S*2,S*2),this.applyPath(t,o,e,s,n),t.clip("evenodd"),t.lineWidth=l*2,t.beginPath(),this.applyPath(t,o,e,s,n),t.stroke(),t.restore()}else t.lineWidth=l,this.applyPath(t,o,e,s,n),t.stroke();t.restore()}getPerimeter(t,i,o){switch(this.ensurePathPoints(t),t==null?void 0:t.type){case"Rectangle":return(i+o)*2;case"Ellipse":{const e=Math.abs(i)/2,s=Math.abs(o)/2,n=Math.abs(t.sweepAngle??360),a=t.ratio||0,r=Math.PI*(3*(e+s)-Math.sqrt((3*e+s)*(e+3*s)));if(n>=360&&a<=0)return r;let f=n/360*r;if(a>0){const h=Math.PI*(3*(e*a+s*a)-Math.sqrt((3*e*a+s*a)*(e*a+3*s*a)));f+=n/360*h,n<360&&(f+=2*Math.sqrt((e-e*a)**2+(s-s*a)**2))}else n<360&&(f+=2*Math.max(e,s));return isNaN(f)?0:f}case"Line":return t.length||Math.sqrt(i*i+o*o);case"Triangle":return i+Math.sqrt((i/2)**2+o**2)*2;case"Polygon":{const e=t.sides||3,s=t.radius||Math.min(i,o)/2;return 2*e*s*Math.sin(Math.PI/e)}case"Star":{const e=t.points||5,s=t.outer_radius||Math.min(i,o)/2,n=t.inner_radius||s/2,a=Math.PI/e;return Math.sqrt(s*s+n*n-2*s*n*Math.cos(a))*e*2}case"Path":{const e=t.points||[];if(e.length<2)return t.length||0;let s=0,n=e[0].x,a=e[0].y;for(let r=1;r<e.length;r++){const f=e[r];if(f.moveTo){n=f.x,a=f.y;continue}const h=n,l=a,p=e[r-1].out_x,c=e[r-1].out_y;if(p!==void 0||f.in_x!==void 0?s+=this.getBezierLength(h,l,p??h,c??l,f.in_x??f.x,f.in_y??f.y,f.x,f.y):s+=Math.sqrt((f.x-h)**2+(f.y-l)**2),n=f.x,a=f.y,f.closePath||r===e.length-1&&(t.is_closed||t.isClosed)){const d=n,u=a,v=[...e.slice(0,r+1)].reverse().find(M=>M.moveTo)||e[0],b=v.x,y=v.y,m=e[r].out_x,S=e[r].out_y,C=v.in_x,w=v.in_y;m!==void 0||C!==void 0?s+=this.getBezierLength(d,u,m??d,S??u,C??b,w??y,b,y):s+=Math.sqrt((b-d)**2+(y-u)**2)}}return s}default:return(i+o)*2}}getBezierLength(t,i,o,e,s,n,a,r,f=10){let h=0,l=t,p=i;for(let c=1;c<=f;c++){const d=c/f,u=1-d,v=d*d,b=u*u,y=b*u,m=v*d,S=y*t+3*b*d*o+3*u*v*s+m*a,C=y*i+3*b*d*e+3*u*v*n+m*r,w=S-l,M=C-p;h+=Math.sqrt(w*w+M*M),l=S,p=C}return h}getBezierTAtLength(t,i,o,e,s,n,a,r,f,h=20){if(t<=0)return 0;let l=0,p=i,c=o;for(let d=1;d<=h;d++){const u=d/h,v=1-u,b=u*u,y=v*v,m=y*v,S=b*u,C=m*i+3*y*u*e+3*v*b*n+S*r,w=m*o+3*y*u*s+3*v*b*a+S*f,M=C-p,I=w-c,k=Math.sqrt(M*M+I*I);if(l+k>=t){const T=t-l,O=k===0?0:T/k;return(d-1+O)/h}l+=k,p=C,c=w}return 1}getPointOnPath(t,i,o,e){if(this.ensurePathPoints(t),(t==null?void 0:t.type)==="Path"){const s=t.points||[];if(s.length<2)return{x:0,y:0,angle:0};let n=1/0,a=-1/0,r=1/0,f=-1/0;s.forEach(y=>{typeof y.x=="number"&&typeof y.y=="number"&&(n=Math.min(n,y.x),a=Math.max(a,y.x),r=Math.min(r,y.y),f=Math.max(f,y.y),y.out_x!==void 0&&(n=Math.min(n,y.out_x),a=Math.max(a,y.out_x)),y.out_y!==void 0&&(r=Math.min(r,y.out_y),f=Math.max(f,y.out_y)),y.in_x!==void 0&&(n=Math.min(n,y.in_x),a=Math.max(a,y.in_x)),y.in_y!==void 0&&(r=Math.min(r,y.in_y),f=Math.max(f,y.in_y)))});const h=(n+a)/2,l=(r+f)/2,c=this.getPerimeter(t,i,o)*e;let d=0;const u=[];let v=s[0],b=s[0];for(let y=1;y<s.length;y++){const m=s[y];if(m.moveTo){v=m,b=m;continue}u.push({p0:v,p1:m}),(m.closePath||y===s.length-1&&(t.is_closed||t.isClosed))&&u.push({p0:m,p1:b}),v=m}for(const y of u){const m=y.p0,S=y.p1;let C=0;const w=m.out_x!==void 0||S.in_x!==void 0;if(w?C=this.getBezierLength(m.x,m.y,m.out_x??m.x,m.out_y??m.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y):C=Math.sqrt((S.x-m.x)**2+(S.y-m.y)**2),d+C>=c||y===u[u.length-1]){let M=0;if(w)return M=this.getBezierTAtLength(c-d,m.x,m.y,m.out_x??m.x,m.out_y??m.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y,20),this.getBezierPointAndAngle(M,m,S,h,l);{M=C===0?0:(c-d)/C;const I=m.x+(S.x-m.x)*M-h,k=m.y+(S.y-m.y)*M-l,T=Math.atan2(S.y-m.y,S.x-m.x);return{x:I,y:k,angle:T}}}d+=C}}else if(t.type==="Ellipse"){const s=Math.abs(i)/2,n=Math.abs(o)/2,a=t.sweepAngle??360,f=((t.startAngle??0)+a*e)*Math.PI/180,h=s*Math.cos(f),l=n*Math.sin(f),p=-s*Math.sin(f),c=n*Math.cos(f),d=Math.atan2(c,p);return{x:h,y:l,angle:d}}else if((t==null?void 0:t.type)==="Rectangle"){const s=Math.abs(i),n=Math.abs(o),r=(s+n)*2*e;let f=0,h=0,l=0;return r<s?(f=-s/2+r,h=-n/2,l=0):r<s+n?(f=s/2,h=-n/2+(r-s),l=Math.PI/2):r<2*s+n?(f=s/2-(r-(s+n)),h=n/2,l=Math.PI):(f=-s/2,h=n/2-(r-(2*s+n)),l=-Math.PI/2),{x:f,y:h,angle:l}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(t,i,o,e,s){const n=i.x,a=i.y,r=i.out_x??i.x,f=i.out_y??i.y,h=o.in_x??o.x,l=o.in_y??o.y,p=o.x,c=o.y,d=1-t,u=t*t,v=d*d,b=v*d,y=u*t,m=b*n+3*v*t*r+3*d*u*h+y*p-e,S=b*a+3*v*t*f+3*d*u*l+y*c-s,C=3*v*(r-n)+6*d*t*(h-r)+3*u*(p-h),w=3*v*(f-a)+6*d*t*(l-f)+3*u*(c-l),M=Math.atan2(w,C);return{x:m,y:S,angle:M}}applyAbsoluteTransform(t,i,o){if(!o.get(i))return;const s=[];let n=i;for(;n;){s.unshift(n);const a=o.get(n);n=a==null?void 0:a.parentId}s.forEach(a=>{this.applyObjectTransform(t,a)})}applyObjectTransform(t,i){var d,u,v;const o=this.objectStates.get(i);if(!o)return;t.translate(o.x,o.y),t.rotate((o.rotation??0)*Math.PI/180);const e=o.skew_x||0,s=o.skew_y||0;if(e!==0||s!==0){const b=Math.tan(e*Math.PI/180),y=Math.tan(s*Math.PI/180);t.transform(1+b*y,y,b,1,0,0)}const n=o.rotate_x!==void 0?o.rotate_x:((d=o.transform)==null?void 0:d.rotate_x)??0,a=o.rotate_y!==void 0?o.rotate_y:((u=o.transform)==null?void 0:u.rotate_y)??0,f=1+(o.translate_z!==void 0?o.translate_z:((v=o.transform)==null?void 0:v.translate_z)??0)/1e3,h=(o.flip_x===!0?-1:1)*Math.cos(a*Math.PI/180)*f,l=(o.flip_y===!0?-1:1)*Math.cos(n*Math.PI/180)*f,p=(o.scale_x??1)*h,c=(o.scale_y??1)*l;t.scale(p,c)}applyArtEffectOverlay(t,i,o,e,s,n){var c,d,u,v,b;const a=this.objectStates.get(i.id),r=((c=a==null?void 0:a.style)==null?void 0:c.artEffect)||i.artEffect||((d=i.style)==null?void 0:d.artEffect);if(!r||!r.enabled)return;const f=r.type,h=r.intensity??.5,l=r.speed??1,p=r.scale??10;if(f==="acid_gradient"||f==="acid_rave"||f==="shimmer"||f==="glint_overlay"||f==="halftone"||f==="noise"||f==="scanlines"||f==="chromatic_aberration"||f==="pixelate"||f==="glitch"||f==="fold_overlay"||f==="crumple_overlay"){if(t.save(),this.applyPath(t,o,e,s,n),t.clip(),f==="shimmer"){const m=this.currentTime*l%2/2,S=t.createLinearGradient(-e,-s,e,s);S.addColorStop(Math.max(0,m-.2),"rgba(255,255,255,0)"),S.addColorStop(m,`rgba(255,255,255,${h*.8})`),S.addColorStop(Math.min(1,m+.2),"rgba(255,255,255,0)"),t.fillStyle=S,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over"}else if(f==="glint_overlay"){let S=((this._lastPointerPos||{x:0}).x-(((u=i.transform)==null?void 0:u.x)??0)+300)/600;S=Math.max(-.2,Math.min(1.2,S));const C=t.createLinearGradient(-e,-s,e,s);C.addColorStop(Math.max(0,S-.15),"rgba(255,255,255,0)"),C.addColorStop(Math.max(0,Math.min(1,S)),`rgba(255,255,255,${h})`),C.addColorStop(Math.min(1,S+.15),"rgba(255,255,255,0)"),t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over"}else if(f==="fold_overlay"){const y=this._lastPointerPos||{x:0,y:0},m=y.x-(((v=i.transform)==null?void 0:v.x)??0),S=y.y-(((b=i.transform)==null?void 0:b.y)??0),C=t.createLinearGradient(m>0?-e/2:e/2,S>0?-s/2:s/2,m>0?e/2:-e/2,S>0?s/2:-s/2);C.addColorStop(0,`rgba(0,0,0,${h*.6})`),C.addColorStop(.4,"rgba(0,0,0,0)"),C.addColorStop(.5,`rgba(255,255,255,${h*.4})`),C.addColorStop(1,`rgba(0,0,0,${h*.2})`),t.fillStyle=C,t.globalCompositeOperation="overlay",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over",t.beginPath(),m>0&&S>0?(t.moveTo(e/2-40,s/2),t.lineTo(e/2,s/2-40),t.lineTo(e/2-40,s/2-40)):m<0&&S>0?(t.moveTo(-e/2+40,s/2),t.lineTo(-e/2,s/2-40),t.lineTo(-e/2+40,s/2-40)):m>0&&S<0?(t.moveTo(e/2-40,-s/2),t.lineTo(e/2,-s/2+40),t.lineTo(e/2-40,-s/2+40)):(t.moveTo(-e/2+40,-s/2),t.lineTo(-e/2,-s/2+40),t.lineTo(-e/2+40,-s/2+40)),t.closePath(),t.fillStyle="#ffffff",t.shadowColor="rgba(0,0,0,0.5)",t.shadowBlur=10,t.shadowOffsetX=m>0?-2:2,t.shadowOffsetY=S>0?-2:2,t.fill()}else if(f==="crumple_overlay"){const y=Math.floor(e/p),m=document.createElement("canvas");m.width=y,m.height=Math.floor(s/p);const S=m.getContext("2d"),C=S.createImageData(m.width,m.height);for(let w=0;w<C.data.length;w+=4){const M=Math.random()>.95?150:255;C.data[w]=M,C.data[w+1]=M,C.data[w+2]=M,C.data[w+3]=255*h}S.putImageData(C,0,0),t.globalCompositeOperation="multiply",t.imageSmoothingEnabled=!1,t.drawImage(m,-e/2,-s/2,e,s)}else if(f==="acid_gradient"||f==="acid_rave"){const y=this.currentTime*l,m=r.color1,S=r.color2,C=t.createLinearGradient(-e/2,-s/2,e/2,s/2);if(m&&S){const w=y*60%360;C.addColorStop(0,this._shiftHue(m,w,h*.7)),C.addColorStop(1,this._shiftHue(S,(w+180)%360,h*.7))}else{const w=y*100%360,M=(w+180)%360;C.addColorStop(0,`hsla(${w}, 80%, 50%, ${h*.5})`),C.addColorStop(1,`hsla(${M}, 80%, 50%, ${h*.5})`)}t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s)}else if(f==="halftone"){const y=Math.max(2,p*(1-h*.8)),m=document.createElement("canvas");m.width=y,m.height=y;const S=m.getContext("2d");if(S){S.fillStyle="black",S.beginPath(),S.arc(y/2,y/2,y/2*h,0,Math.PI*2),S.fill();const C=t.createPattern(m,"repeat");C&&(t.globalAlpha=.3*h,t.fillStyle=C,t.fillRect(-e/2,-s/2,e,s))}}else if(f==="noise"){const y=Math.floor(e*s*h*.02);t.globalAlpha=.4*h;for(let m=0;m<y;m++){const S=Math.random()>.5?255:0;t.fillStyle=`rgba(${S}, ${S}, ${S}, ${.5+Math.random()*.5})`,t.fillRect(-e/2+Math.random()*e,-s/2+Math.random()*s,2,2)}}else if(f==="scanlines"){t.globalAlpha=.2*h,t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1;for(let y=-s/2;y<s/2;y+=4)t.beginPath(),t.moveTo(-e/2,y),t.lineTo(e/2,y),t.stroke()}else if(f==="chromatic_aberration"){const y=5*h;t.globalCompositeOperation="screen",t.globalAlpha=.5,t.fillStyle="cyan",t.fillRect(-e/2-y,-s/2,e,s),t.fillStyle="magenta",t.fillRect(-e/2+y,-s/2,e,s)}else if(f==="pixelate"){const y=Math.max(2,Math.round(p*(1-h*.5))),m=document.createElement("canvas"),S=Math.max(1,Math.ceil(e/y)),C=Math.max(1,Math.ceil(s/y));m.width=S,m.height=C;const w=m.getContext("2d");if(w){w.imageSmoothingEnabled=!1;const M=t.getTransform(),I=M.e-e/2,k=M.f-s/2;w.drawImage(t.canvas,I,k,e,s,0,0,S,C),t.imageSmoothingEnabled=!1,t.drawImage(m,0,0,S,C,-e/2,-s/2,e,s),t.imageSmoothingEnabled=!0}}else if(f==="glitch"){const y=this.currentTime*l,m=r.chaosAmount??.2,S=Math.max(3,Math.floor(8*h)),C=h*e*.15;t.globalCompositeOperation="screen",t.globalAlpha=h*.4;const w=C*.3;t.fillStyle="rgba(255, 0, 0, 0.4)",t.fillRect(-e/2+w,-s/2,e,s),t.fillStyle="rgba(0, 255, 255, 0.4)",t.fillRect(-e/2-w,-s/2,e,s),t.globalCompositeOperation="source-over",t.globalAlpha=1;const M=s/S;for(let I=0;I<S;I++){const k=Math.sin(I*127.1+y*311.7*l)*43758.5,T=k-Math.floor(k);if(T>1-m){const O=(T-(1-m))/m*C*(Math.random()>.5?1:-1),P=-s/2+I*M,_=t.getTransform(),E=_.e-e/2+O,A=_.f+P;t.save(),t.beginPath(),t.rect(-e/2,P,e,M),t.clip(),t.globalAlpha=.8,t.drawImage(t.canvas,E,A,e,M,-e/2+O,P,e,M),t.restore()}}}t.restore()}}_shiftHue(t,i,o){let e=0,s=0,n=0;if(t.startsWith("#")){const c=t.replace("#","");e=parseInt(c.substring(0,2),16)/255,s=parseInt(c.substring(2,4),16)/255,n=parseInt(c.substring(4,6),16)/255}const a=Math.max(e,s,n),r=Math.min(e,s,n);let f=0,h=0,l=(a+r)/2;if(a!==r){const c=a-r;switch(h=l>.5?c/(2-a-r):c/(a+r),a){case e:f=((s-n)/c+(s<n?6:0))/6;break;case s:f=((n-e)/c+2)/6;break;case n:f=((e-s)/c+4)/6;break}}return`hsla(${(((f*360+i)%360+360)%360).toFixed(0)}, ${(h*100).toFixed(0)}%, ${(l*100).toFixed(0)}%, ${o})`}applyBackgroundBlurGlass(t,i,o,e,s,n){const a=n.radius??10,r=n.color??"rgba(255,255,255,0.2)",f=n.opacity!==void 0?this.normalizeOpacity(n.opacity):.5,h=n.noise??0;t.save(),this.applyPath(t,i,o,e,s),t.clip();const l=t.getTransform(),p=t.canvas;try{const d=document.createElement("canvas");d.width=Math.max(1,Math.ceil(o)),d.height=Math.max(1,Math.ceil(e));const u=d.getContext("2d");if(u){u.save(),u.translate(o/2,e/2);const v=n.magnification||1;if(v!==1&&u.scale(v,v),typeof l.inverse=="function"){const m=l.inverse();u.transform(m.a,m.b,m.c,m.d,m.e,m.f)}else{const m=l.a*l.d-l.b*l.c;m!==0&&u.transform(l.d/m,-l.b/m,-l.c/m,l.a/m,(l.c*l.f-l.d*l.e)/m,(l.b*l.e-l.a*l.f)/m)}u.drawImage(p,0,0),u.restore(),u.filter=`blur(${a}px)`;const b=document.createElement("canvas");b.width=d.width,b.height=d.height;const y=b.getContext("2d");y.filter=`blur(${a}px)`,y.drawImage(d,0,0),t.globalCompositeOperation="source-over",t.globalAlpha=1,t.drawImage(b,-o/2,-e/2,o,e)}}catch{}t.globalCompositeOperation="source-over",t.globalAlpha=f,t.fillStyle=r,t.fillRect(-o/2,-e/2,o,e),t.globalAlpha=1,t.globalCompositeOperation="source-atop";const c=t.createLinearGradient(-o/2,-e/2,o/2,e/2);if(c.addColorStop(0,"rgba(255,255,255,0.12)"),c.addColorStop(.3,"rgba(255,255,255,0.04)"),c.addColorStop(.5,"rgba(255,255,255,0.0)"),c.addColorStop(1,"rgba(255,255,255,0.0)"),t.fillStyle=c,t.fillRect(-o/2,-e/2,o,e),h>0){if(t.globalAlpha=h/100,!this._noiseTileCanvas){const u=document.createElement("canvas");u.width=64,u.height=64;const v=u.getContext("2d"),b=v.createImageData(64,64),y=b.data;for(let m=0;m<y.length;m+=4){const S=Math.floor(Math.random()*255);y[m]=S,y[m+1]=S,y[m+2]=S,y[m+3]=18}v.putImageData(b,0,0),this._noiseTileCanvas=u}const d=t.createPattern(this._noiseTileCanvas,"repeat");d&&(t.fillStyle=d,t.fillRect(-o/2,-e/2,o,e))}t.restore(),t.save(),t.globalAlpha=1,t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1.5,this.applyPath(t,i,o,e,s),t.stroke(),t.restore()}applyPath(t,i,o,e,s){i!=null&&i.data&&(i.type==="Path"||i.type==="Subtract"||i.type==="Union"||i.type==="Intersect"||i.type==="Exclude"||i.type),t.beginPath(),this._tracePath(t,i,o,e,s)}_tracePath(t,i,o,e,s){if(i){if(this.ensurePathPoints(i),(i==null?void 0:i.type)==="Rectangle"||i.type==="Image"){const n=s!==void 0?s:i.corner_radius??0;this.drawRoundRect(t,-o/2,-e/2,o,e,n)}else if(i.type==="Line")t.moveTo(-o/2,0),t.lineTo(o/2,0);else if(i.type==="Ellipse"){const{startAngle:n=0,sweepAngle:a=360,ratio:r=0}=i,f=o/2,h=e/2,l=n*Math.PI/180,p=a*Math.PI/180,c=l+p;a>=360&&r<=0?t.ellipse(0,0,f,h,0,0,Math.PI*2):(t.ellipse(0,0,f,h,0,l,c,!1),r>0?t.ellipse(0,0,f*r,h*r,0,c,l,!0):t.lineTo(0,0),t.closePath())}else if(i.type==="Triangle")t.moveTo(0,-e/2),t.lineTo(o/2,e/2),t.lineTo(-o/2,e/2),t.closePath();else if(i.type==="Polygon"){const n=i.sides||3,a=i.radius||Math.min(o,e)/2;for(let r=0;r<n;r++){const f=r*2*Math.PI/n-Math.PI/2,h=a*Math.cos(f),l=a*Math.sin(f);r===0?t.moveTo(h,l):t.lineTo(h,l)}t.closePath()}else if(i.type==="Star"){const n=i.points||5,a=i.outer_radius||Math.min(o,e)/2;let r=i.inner_radius;r==null?r=a*.382:r<=1&&(r=a*r);for(let f=0;f<n*2;f++){const h=f*Math.PI/n-Math.PI/2,l=f%2===0?a:r,p=l*Math.cos(h),c=l*Math.sin(h);f===0?t.moveTo(p,c):t.lineTo(p,c)}t.closePath()}else if(((i==null?void 0:i.type)==="Path"||i.type==="Subtract"||i.type==="Union"||i.type==="Intersect"||i.type==="Exclude"||i.type==="BooleanOperation")&&i.points){this.frameCount%300===0&&this.log("[Engine] Tracing Path:",i.points.length,"points");let n=1/0,a=-1/0,r=1/0,f=-1/0;if(i.points.forEach(p=>{typeof p.x=="number"&&typeof p.y=="number"&&(n=Math.min(n,p.x),a=Math.max(a,p.x),r=Math.min(r,p.y),f=Math.max(f,p.y),p.out_x!==void 0&&(n=Math.min(n,p.out_x),a=Math.max(a,p.out_x)),p.out_y!==void 0&&(r=Math.min(r,p.out_y),f=Math.max(f,p.out_y)),p.in_x!==void 0&&(n=Math.min(n,p.in_x),a=Math.max(a,p.in_x)),p.in_y!==void 0&&(r=Math.min(r,p.in_y),f=Math.max(f,p.in_y)))}),n===1/0)return;const h=(n+a)/2,l=(r+f)/2;if(isNaN(h)||isNaN(l)){this.warn("[Engine] Invalid path center:",h,l);return}i.points.forEach((p,c)=>{if(c===0||p.moveTo)t.moveTo(p.x-h,p.y-l);else{const d=i.points[c-1];if(!d)return;const u=(d.out_x??d.x)-h,v=(d.out_y??d.y)-l,b=(p.in_x??p.x)-h,y=(p.in_y??p.y)-l;isNaN(u)||isNaN(b)||isNaN(p.x)?t.lineTo(p.x-h,p.y-l):t.bezierCurveTo(u,v,b,y,p.x-h,p.y-l)}if(p.closePath||c===i.points.length-1&&(i.is_closed||i.isClosed)){const d=[...i.points.slice(0,c+1)].reverse().find(u=>u.moveTo)||i.points[0];d&&(p.out_x!==void 0||d.in_x!==void 0)&&t.bezierCurveTo((p.out_x??p.x)-h,(p.out_y??p.y)-l,(d.in_x??d.x)-h,(d.in_y??d.y)-l,d.x-h,d.y-l),t.closePath()}})}else if(i.points&&Array.isArray(i.points)){let n=1/0,a=-1/0,r=1/0,f=-1/0;i.points.forEach(p=>{n=Math.min(n,p.x),a=Math.max(a,p.x),r=Math.min(r,p.y),f=Math.max(f,p.y)});const h=(n+a)/2,l=(r+f)/2;i.points.forEach((p,c)=>{if(c===0)t.moveTo(p.x-h,p.y-l);else{const d=i.points[c-1];d.out_x!==void 0||p.in_x!==void 0?t.bezierCurveTo((d.out_x??d.x)-h,(d.out_y??d.y)-l,(p.in_x??p.x)-h,(p.in_y??p.y)-l,p.x-h,p.y-l):t.lineTo(p.x-h,p.y-l)}(p.closePath||c===i.points.length-1&&(i.is_closed||i.isClosed))&&t.closePath()})}}}renderInputBox(t,i){var L,R;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((L=i.geometry)==null?void 0:L.width)||250,n=((R=i.geometry)==null?void 0:R.height)||45,a=this.focusedId===i.id,r=this.lastHoveredObjectId===i.id,f=e.previewState||"default",h=f!=="default"?f:a?"focused":r?"hovered":"default",l=e.label||{visible:!0,text:"Label"},p=e.helperText||{visible:!1,text:"Helper text"},c=e.leftIcon||{visible:!1},d=e.rightIcon||{visible:!1},u=e.multiline===!0,v=e.corner_radius??8,b=e.corners||{tl:v,tr:v,bl:v,br:v},y=[b.tl,b.tr,b.br,b.bl];let m=e.backgroundColor||"rgba(31, 41, 55, 1)",S=e.borderColor||"rgba(55, 65, 81, 1)",C=e.borderWidth??1.5,w=e.color||"#ffffff",M=e.placeholderColor||"rgba(156, 163, 175, 1)",I=e.fontSize||14;const k=`${h}Style`,T=e[k];T?(T.backgroundColor!==void 0&&(m=T.backgroundColor),T.borderColor!==void 0&&(S=T.borderColor),T.borderWidth!==void 0&&(C=T.borderWidth),T.color!==void 0&&(w=T.color),T.placeholderColor!==void 0&&(M=T.placeholderColor),T.fontSize!==void 0&&(I=T.fontSize)):h==="focused"?(S=e.focusBorderColor||"rgba(59, 130, 246, 1)",C=Math.max(C,2)):h==="hovered"||h==="hover"?(S=e.hoverBorderColor||S,m=e.hoverBackgroundColor||m):h==="disabled"?(m=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",S=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):h==="error"&&(S="rgba(239, 68, 68, 1)",C=Math.max(C,2)),t.beginPath(),this.drawRoundRect(t,-s/2,-n/2,s,n,y);const O=this.createCanvasFill(t,m,s,n);if(O&&(t.fillStyle=O,t.fill()),C>0){const D=this.createCanvasFill(t,S,s,n);if(D&&(t.strokeStyle=D,t.lineWidth=C,t.stroke()),h==="focused"||h==="focus"){t.save(),t.beginPath();const q=y.map(ot=>ot+2);this.drawRoundRect(t,-s/2-2,-n/2-2,s+4,n+4,q),t.strokeStyle="rgba(59, 130, 246, 0.3)",t.lineWidth=2,t.stroke(),t.restore()}}const P=(D,q)=>{if(!D.visible||!D.svgPath)return;const ot=D.size||14,mt=D.offset??16,bt=D.color||"#ffffff",gt=q?-(s/2)+mt:s/2-mt,Et=D.svgPath;if(t.save(),t.translate(gt,0),!Et.startsWith("<svg")){const It=new Path2D(Et),vt=ot/24;t.scale(vt,vt),t.translate(-12,-12),t.fillStyle=bt,t.fill(It)}t.restore()};P(c,!0),P(d,!1);const _=e.text||"",E=e.placeholder||"Enter text...",A=!_,W=_||E,z=A?M:w,Y=I,G=e.fontFamily||"Inter",N=e.fontWeight||400;t.font=`${N} ${Y}px "${G}", sans-serif`,t.fillStyle=z,t.textAlign="left",t.textBaseline=u?"top":"middle";const J=e.inputPadding??16,x=c.visible?(c.offset??16)+(c.size||14)/2+8:J,F=d.visible?(d.offset??16)+(d.size||14)/2+8:J,j=-(s/2)+x,X=s-x-F,tt=e.inputType==="password"?"•".repeat(W.length):W;if(t.save(),t.beginPath(),t.rect(j-2,-n/2+4,X+4,n-8),t.clip(),u){const D=tt.split(`
|
|
34
|
+
`);let q=-n/2+J;const ot=Y*1.2;let mt=0;D.forEach((bt,gt)=>{const Et=bt.split(" ");let It="";for(let vt=0;vt<Et.length;vt++){const Dt=It+Et[vt]+" ";t.measureText(Dt).width>X&&vt>0?(t.fillText(It,j,q),It=Et[vt]+" ",q+=ot):It=Dt}t.fillText(It,j,q),mt=t.measureText(It).width,gt<D.length-1&&(q+=ot,mt=0)}),a&&!A&&Math.floor(performance.now()/500)%2===0&&t.fillRect(j+mt,q,1.5,Y)}else{const q=t.measureText(tt).width;let ot=0;if(q>X&&(ot=q-X),t.fillText(tt,j-ot,0),a&&!A&&Math.floor(performance.now()/500)%2===0){const bt=j+q-ot;t.fillRect(bt,-(Y/2),1.5,Y)}}if(t.restore(),l.visible!==!1){const D=l.text||"Label",q=l.fontSize||12,ot=l.color||"rgba(156, 163, 175, 1)",mt=l.offset??8;t.font=`600 ${q}px "${G}", sans-serif`,t.fillStyle=ot,t.textAlign="left",t.textBaseline="bottom";const bt=-(s/2),gt=-(n/2)-mt;t.fillText(D,bt,gt)}if(p.visible===!0){const D=p.text||"Helper text",q=p.fontSize||11,ot=h==="error"?"rgba(239, 68, 68, 1)":p.color||"rgba(156, 163, 175, 1)",mt=p.offset??6;t.font=`400 ${q}px "${G}", sans-serif`,t.fillStyle=ot,t.textAlign="left",t.textBaseline="top";const bt=-(s/2),gt=n/2+mt;t.fillText(D,bt,gt)}}renderSlider(t,i){const o=this.objectStates.get(i.id),e=(o==null?void 0:o.geometry)||i.geometry,s=(o==null?void 0:o.options)||i.options||{},n=e.width||200,a=s.value??50,r=s.min??0,h=(s.max??100)-r,l=h===0?0:(a-r)/h,p=s.trackHeight||4,c=s.trackRoundedness??2,d=s.trackShape??"Rectangle",u=s.trackPath||"",v=s.accentColor||"#3b82f6",b=s.inactiveColor||"#374151",y=s.thumbShape||"Ellipse",m=s.thumbWidth??16,S=s.thumbHeight??16,C=s.thumbRoundedness??0,w=s.thumbColor||"#ffffff",M=s.thumbPath||"",I=s.thumbIcon||"",k=s.showValueTooltip??!1,T=s.tooltipBgColor||"#333333",O=s.tooltipColor||"#ffffff",P=s.tooltipOffsetX??0,_=s.tooltipOffsetY??-25,E=(X,tt,L,R,D,q,ot)=>{if((X==="Custom"||X==="Icon")&&ot)try{const mt=new Path2D(ot);if(t.save(),t.translate(tt,L),X==="Icon"){const bt=Math.min(R,D)/24;t.scale(bt,bt),t.translate(-12,-12)}t.fill(mt),t.restore();return}catch(mt){console.error("Error drawing slider shape in engine:",mt)}if(t.beginPath(),X==="Ellipse")t.ellipse(tt,L,R/2,D/2,0,0,Math.PI*2);else if(X==="Rectangle")this.drawRoundRect(t,tt-R/2,L-D/2,R,D,q);else if(X==="Triangle")t.moveTo(tt,L-D/2),t.lineTo(tt+R/2,L+D/2),t.lineTo(tt-R/2,L+D/2),t.closePath();else if(X==="Diamond")t.moveTo(tt,L-D/2),t.lineTo(tt+R/2,L),t.lineTo(tt,L+D/2),t.lineTo(tt-R/2,L),t.closePath();else if(X==="Polygon"){const mt=i.geometry.sides||3,bt=i.geometry.radius||Math.min(R,D)/2;for(let gt=0;gt<mt;gt++){const Et=gt*2*Math.PI/mt-Math.PI/2,It=tt+bt*Math.cos(Et),vt=L+bt*Math.sin(Et);gt===0?t.moveTo(It,vt):t.lineTo(It,vt)}t.closePath()}else if(X==="Star"){const bt=Math.min(R,D)/2,gt=bt/2;for(let Et=0;Et<10;Et++){const It=Et%2===0?bt:gt,vt=Et*Math.PI/5-Math.PI/2;t.lineTo(tt+It*Math.cos(vt),L+It*Math.sin(vt))}t.closePath()}else X==="Line"&&(t.moveTo(tt-R/2,L),t.lineTo(tt+R/2,L));t.fill()},A=this.createCanvasFill(t,b,n,p);A&&(t.fillStyle=A,t.strokeStyle=A),d==="Line"?(t.lineWidth=p,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(n/2,0),t.stroke()):E(d,0,0,n,p,c,u);const W=n-m,z=-n/2+m/2+l*W,Y=z- -n/2;if(Y>0){const X=this.createCanvasFill(t,v,n,p);X&&(t.fillStyle=X,t.strokeStyle=X),d==="Line"?(t.lineWidth=p,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(z,0),t.stroke()):d==="Rectangle"&&(t.beginPath(),this.drawRoundRect(t,-n/2,-p/2,Y,p,c),t.fill())}t.save(),t.translate(z,0);const G=t.getTransform(),N=Math.sqrt(G.a*G.a+G.b*G.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*N,t.shadowOffsetY=1*N;const J=this.createCanvasFill(t,w,m,S);if(J&&(t.fillStyle=J),E(y,0,0,m,S,C,y==="Icon"?I:M),t.restore(),k){t.save(),t.translate(z+P,_);const X=Math.round(a).toString();t.font="10px Inter, sans-serif";const tt=t.measureText(X),L=6,R=4,D=tt.width+L*2,q=14+R;t.beginPath(),this.drawRoundRect(t,-D/2,-q/2,D,q,4),t.fillStyle=T,t.fill(),t.fillStyle=O,t.textAlign="center",t.textBaseline="middle",t.fillText(X,0,0),t.restore()}const x=s.label||{},F=s.helperText||{},j=s.fontFamily||"Inter";if(x.visible!==!1){const X=x.text||"Label",tt=x.fontSize||12,L=x.color||"rgba(156, 163, 175, 1)",R=x.offset??8;t.font=`600 ${tt}px "${j}", sans-serif`,t.fillStyle=L,t.textAlign="left",t.textBaseline="bottom";const D=-(n/2),q=-(p/2)-R;t.fillText(X,D,q)}if(F.visible===!0){const X=F.text||"Helper text",tt=F.fontSize||11,L=F.color||"rgba(156, 163, 175, 1)",R=F.offset??6;t.font=`400 ${tt}px "${j}", sans-serif`,t.fillStyle=L,t.textAlign="left",t.textBaseline="top";const D=-(n/2),q=p/2+R;t.fillText(X,D,q)}}renderDropdown(t,i){var _;const o=this.objectStates.get(i.id);if(!o)return;const e=o.options||i.options||{},s=i.geometry.width||160,n=i.geometry.height||40,a=-s/2,r=-n/2,f=e.corner_radius??6,h=e.disabled||e.previewState==="disabled",l=this.lastHoveredObjectId===i.id||e.previewState==="hover",p=(e.isOpen||e.previewState==="active")&&!h;let c=e.backgroundColor,d=e.borderColor,u=e.color||"#333333";h?(c=e.disabledBackgroundColor||"#f3f4f6",d=e.disabledBorderColor||"#e5e7eb",u=e.disabledColor||"#9ca3af"):p?(c=e.activeBackgroundColor||c,d=e.activeBorderColor||d,u=e.activeColor||u):l&&(c=e.hoverBackgroundColor||c,d=e.hoverBorderColor||d,u=e.hoverColor||u),c||(c="#ffffff"),d||(d="#e5e7eb");const v=t.globalAlpha;t.globalAlpha=v*(e.opacity??1),this.drawRoundRect(t,a,r,s,n,f),t.fillStyle=this.createCanvasFill(t,typeof c=="string"?{type:"Solid",color:c}:c,s,n)||"#ffffff",t.fill();const b=e.borderWidth??1;b>0&&(t.strokeStyle=this.createCanvasFill(t,typeof d=="string"?{type:"Solid",color:d}:d,s,n)||"#e5e7eb",t.lineWidth=b,t.stroke());const y=12,m=e.chevronType||"chevron",S=e.chevronSize||16,C=(p?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(m!=="none"){const E=a+s-y-S/2;t.save(),t.translate(E,0);const A=p?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(A*Math.PI/180),t.strokeStyle=C,t.fillStyle=C,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",m==="chevron")t.beginPath(),t.moveTo(-S/2,-S*.2),t.lineTo(0,S*.2),t.lineTo(S/2,-S*.2),t.stroke();else if(m==="custom"||m==="path"){const W=p&&e.openIconPath||e.closedIconPath;if(W){const z=new Path2D(W);t.save();const Y=S/24;t.scale(Y,Y),t.translate(-12,-12),t.fill(z),t.restore()}}t.restore()}const w=e.selectedOption||e.placeholder||"Select...",M=e.fontSize||14,I=e.fontWeight||400,k=e.fontFamily||"Inter, sans-serif";t.font=`${I} ${M}px ${k}`;const T=h?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":u;t.fillStyle=this.createCanvasFill(t,typeof T=="string"?{type:"Solid",color:T}:T,s,n)||"#333333",t.textAlign="left",t.textBaseline="middle";const O=m==="none"?0:S+8,P=s-y*2-O;if(t.save(),t.beginPath(),t.rect(a+y,r,P,n),t.clip(),t.fillText(w,a+y,0),t.restore(),p&&!h){const E=r+n+4,A=e.optionsList||[],W=e.itemHeight||32,z=e.listPadding??4,Y=A.length*W+z*2,G=e.listCornerRadius??f;t.save();const N=e.listShadow||{},J=t.getTransform(),x=Math.sqrt(J.a*J.a+J.b*J.b)||1;t.shadowColor=typeof N.color=="string"?N.color:((_=N.color)==null?void 0:_.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(N.blur??12)*x,t.shadowOffsetY=(N.offsetY??6)*x,t.shadowOffsetX=(N.offsetX??0)*x,t.beginPath(),this.drawRoundRect(t,a,E,s,Y,G),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},s,Y)||"#ffffff",t.fill();const F=e.listBorderWidth??1;F>0&&(t.shadowColor="transparent",t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:d},s,Y)||"#e5e7eb",t.lineWidth=F,t.stroke()),t.restore();const j=e.itemFontSize||M,X=e.itemFontFamily||k;t.font=`${I} ${j}px ${X}`,A.forEach((tt,L)=>{const R=E+z+L*W;if(tt===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},s,W)||"#f3f4f6",t.fillRect(a+F,R,s-F*2,W),t.fillStyle=e.itemSelectedColor||e.accentColor||u||"#374151";else if(t.fillStyle=e.listTextColor||u||"#333333",this.activeDropdownId===i.id&&this._lastPointerPos){const q=this._lastPointerPos.y-(E+z),ot=Math.floor(q/W);L===ot&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},s,W)||"#f9fafb",t.fillRect(a+F,R,s-F*2,W),t.fillStyle=e.itemHoverColor||u)}t.fillText(tt,a+y,R+W/2)})}t.globalAlpha=v}renderButton(t,i){if(i.children&&i.children.length>0)return;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=i.geometry||{},n=s.width||120,a=s.height||40,r=this.lastHoveredObjectId===i.id,f=this.activeObjectId===i.id,h=e.label||{},l=e.hoverStyle||{},p=e.activeStyle||{},c=e.icon||{enabled:!1};let d=e.backgroundColor||"#3b82f6",u=h.color||"#ffffff",v=h.text||"Button",b=s.cornerRadius??8,y=e.borderColor||"transparent",m=e.borderWidth||0,S=1;f&&p?(d=p.backgroundColor||d,u=p.color||u,v=p.text||v,S=p.scale??.95,b=p.cornerRadius??b):r&&l&&(d=l.backgroundColor||d,u=l.color||u,v=l.text||v,S=l.scale??1,b=l.cornerRadius??b,y=l.borderColor||y);const C=-n/2,w=-a/2;t.save(),t.scale(S,S),t.beginPath(),this.drawRoundRect(t,C,w,n,a,b);const M=this.createCanvasFill(t,d,n,a);M&&(t.fillStyle=M,t.fill()),(m>0||r&&l.borderColor)&&(t.strokeStyle=y,t.lineWidth=m||(r?1:0),t.stroke());const I=h.fontSize||14,k=h.fontFamily||"Inter",T=h.fontWeight||600;t.font=`${T} ${I}px "${k}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=u,t.textAlign="center",t.textBaseline="middle";let O=0;if(c.enabled&&c.svgPath){const P=I*1.1,_=c.gap||8,E=t.measureText(v),W=-(E.width+P+_)/2,z=c.position==="left"?W+P/2:W+E.width+_+P/2;O=c.position==="left"?W+P+_+E.width/2:W+E.width/2,t.save(),t.translate(z,0);const Y=new Path2D(c.svgPath),G=P/24;t.scale(G,G),t.translate(-12,-12),t.fillStyle=u,t.fill(Y),t.restore()}t.fillText(v,O,0),t.restore()}renderToggleButton(t,i){var v,b;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=e.checked??!1,n=((v=i.geometry)==null?void 0:v.width)||120,a=((b=i.geometry)==null?void 0:b.height)||40,r=-n/2,f=-a/2,h=e.corner_radius??8,l=e.label||{},p=s?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",c=s?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,r,f,n,a,h),t.fillStyle=p,t.fill();const d=l.fontSize||14,u=l.fontFamily||"Inter";t.font=`${l.fontWeight||600} ${d}px "${u}", sans-serif`,t.fillStyle=c,t.textAlign="center",t.textBaseline="middle",t.fillText(l.text||"Toggle",0,0),t.restore()}renderToggle(t,i){var G,N,J,x,F,j,X,tt,L,R,D,q;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((G=i.geometry)==null?void 0:G.width)||52,n=((N=i.geometry)==null?void 0:N.height)||30,a=-s/2,r=-n/2,f=e.checked??!1,h=e.cornerRadius??e.corner_radius??n/2,l=e.toggleStyle||{},p=l.backgroundColor||e.activeColor||"#10b981",c=l.borderColor||e.borderColor||"transparent",d=l.borderWidth??e.borderWidth??0,u=l.knobColor||e.knobColor||"#ffffff",v=f?p:e.inactiveColor||"#374151",b=f?c:e.borderColor||"transparent",y=f?d:e.borderWidth??0,m=f?u:e.knobColor||"#ffffff";e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,s,n,h);const S=this.createCanvasFill(t,v,s,n);if(S&&(t.fillStyle=S,t.fill()),y>0){t.lineWidth=y;const ot=this.createCanvasFill(t,b,s,n);ot&&(t.strokeStyle=ot,t.stroke())}const C=2,w=n-C*2,M=w/2,I=a+C,k=a+s-C-w,T=f?k:I,O=r+C;t.beginPath(),t.arc(T+M,O+M,M,0,Math.PI*2);const P=this.createCanvasFill(t,m,w,w);P&&(t.fillStyle=P,t.fill()),e.disabled&&(t.globalAlpha*=2);let _=!1,E=!1;const A=(f?(J=l.leftLabel)==null?void 0:J.text:null)||((x=e.leftLabel)==null?void 0:x.text)||"",W=(f?(F=l.leftLabel)==null?void 0:F.color:null)||((j=e.leftLabel)==null?void 0:j.color)||"#f3f4f6";if((X=e.leftLabel)!=null&&X.enabled&&A){const ot=e.leftLabel;t.font=`${ot.fontWeight||400} ${ot.fontSize||12}px "${ot.fontFamily||"Inter"}", sans-serif`,t.fillStyle=W,t.textBaseline="middle",t.textAlign="right",t.fillText(A,a-(ot.gap||8),0),_=!0}const z=(f?(tt=l.rightLabel)==null?void 0:tt.text:null)||((L=e.rightLabel)==null?void 0:L.text)||"",Y=(f?(R=l.rightLabel)==null?void 0:R.color:null)||((D=e.rightLabel)==null?void 0:D.color)||"#f3f4f6";if((q=e.rightLabel)!=null&&q.enabled&&z){const ot=e.rightLabel;t.font=`${ot.fontWeight||400} ${ot.fontSize||12}px "${ot.fontFamily||"Inter"}", sans-serif`,t.fillStyle=Y,t.textBaseline="middle",t.textAlign="left",t.fillText(z,a+s+(ot.gap||8),0),E=!0}if(!_&&!E&&e.label&&e.label.text){const ot=e.label,mt=ot.fontSize||14,bt=ot.fontWeight||400,gt=ot.fontFamily||"Inter";t.font=`${bt} ${mt}px "${gt}", sans-serif`,t.fillStyle=ot.color||"#f3f4f6",t.textBaseline="middle";const Et=ot.gap||10;let It=0,vt=0;ot.position==="left"?(t.textAlign="right",It=a-Et,vt=0):ot.position==="right"?(t.textAlign="left",It=a+s+Et,vt=0):ot.position==="top"?(t.textAlign="center",It=0,vt=r-Et,t.textBaseline="bottom"):ot.position==="bottom"?(t.textAlign="center",It=0,vt=r+n+Et,t.textBaseline="top"):(t.textAlign="left",It=a+s+Et,vt=0),t.fillText(ot.text,It,vt)}}renderCheckbox(t,i){var S,C;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((S=i.geometry)==null?void 0:S.width)||20,n=((C=i.geometry)==null?void 0:C.height)||20,a=-s/2,r=-n/2,f=e.cornerRadius??4,h=e.checked??!1,l=e.activeColor||"#3b82f6",p=e.inactiveColor||"transparent",c=e.checkColor||"#ffffff",d=e.borderColor||"#4b5563",u=e.borderWidth??2,v=h?l:p,b=h?"transparent":d,y=h?0:u;e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,s,n,f);const m=this.createCanvasFill(t,v,s,n);if(m&&(t.fillStyle=m,t.fill()),y>0){t.lineWidth=y;const w=this.createCanvasFill(t,b,s,n);w&&(t.strokeStyle=w,t.stroke())}else if(h){t.lineWidth=1;const w=this.createCanvasFill(t,l,s,n);w&&(t.strokeStyle=w,t.stroke())}if(h){t.save(),t.beginPath();const w=this.createCanvasFill(t,c,s,n);t.strokeStyle=w||c,t.lineWidth=Math.max(2,s*.12),t.lineCap="round",t.lineJoin="round";const M=a+s*.25,I=r+n*.5,k=a+s*.45,T=r+n*.7,O=a+s*.75,P=r+n*.25;t.moveTo(M,I),t.lineTo(k,T),t.lineTo(O,P),t.stroke(),t.restore()}if(e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const w=e.label;t.save(),t.font=`${w.fontWeight||400} ${w.fontSize||14}px "${w.fontFamily||"Inter"}", sans-serif`,t.fillStyle=w.color||"#f3f4f6",t.textBaseline="middle";const M=w.gap||8;let I=0,k=0;w.position==="left"?(t.textAlign="right",I=a-M,k=0):w.position==="right"?(t.textAlign="left",I=a+s+M,k=0):w.position==="top"?(t.textAlign="center",I=0,k=r-M,t.textBaseline="bottom"):w.position==="bottom"&&(t.textAlign="center",I=0,k=r+n+M,t.textBaseline="top"),t.fillText(w.text,I,k),t.restore()}}renderRadioGroup(t,i){var C,w;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((C=i.geometry)==null?void 0:C.width)||180,n=((w=i.geometry)==null?void 0:w.height)||100,a=-s/2,r=-n/2,f=e.selectedValue,h=e.optionsList||["Option 1","Option 2","Option 3"],l=e.orientation||"vertical",p=e.itemGap!==void 0?e.itemGap:16,c=e.activeColor||"#3b82f6",d=e.inactiveColor||"#4b5563",u=e.textColor||"#ffffff",v=e.fontSize||14,b=e.fontFamily||"Inter",y=e.fontWeight||400;e.disabled&&(t.globalAlpha*=.5);const m=8,S=m*2;if(t.save(),t.font=`${y} ${v}px "${b}", sans-serif`,t.textBaseline="middle",t.textAlign="left",l==="vertical"){const M=Math.max(S,v)+p;h.forEach((I,k)=>{const T=r+k*M+m;t.beginPath(),t.arc(a+m,T,m,0,Math.PI*2);const O=f===I,P=this.createCanvasFill(t,c,S,S),_=this.createCanvasFill(t,d,S,S);O?(t.strokeStyle=P||c,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(a+m,T,m/2,0,Math.PI*2),t.fillStyle=P||c,t.fill()):(t.strokeStyle=_||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(I,a+S+8,T)})}else{let M=a;h.forEach(I=>{const k=f===I,T=t.measureText(I).width;t.beginPath(),t.arc(M+m,0,m,0,Math.PI*2);const O=this.createCanvasFill(t,c,S,S),P=this.createCanvasFill(t,d,S,S);k?(t.strokeStyle=O||c,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(M+m,0,m/2,0,Math.PI*2),t.fillStyle=O||c,t.fill()):(t.strokeStyle=P||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(I,M+S+6,0),M+=S+6+T+p})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const M=e.label;t.save(),t.font=`${M.fontWeight||400} ${M.fontSize||14}px "${M.fontFamily||"Inter"}", sans-serif`,t.fillStyle=M.color||"#9ca3af",t.textBaseline="middle";const I=M.gap||8;let k=0,T=0;M.position==="left"?(t.textAlign="right",k=a-I,T=0):M.position==="right"?(t.textAlign="left",k=a+s+I,T=0):M.position==="top"?(t.textAlign="center",k=0,T=r-I,t.textBaseline="bottom"):M.position==="bottom"&&(t.textAlign="center",k=0,T=r+n+I,t.textBaseline="top"),t.fillText(M.text,k,T),t.restore()}}renderBarChart(t,i){var T,O;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s={width:((T=i.geometry)==null?void 0:T.width)||300,height:((O=i.geometry)==null?void 0:O.height)||180,chartType:e.chartType||"grouped",stylePreset:e.stylePreset||"default",datasets:e.datasets||[{id:"ds-1",label:"Revenue",data:[42,67,31,55,78,48],color:"#6366f1"}],categories:e.categories||["Jan","Feb","Mar","Apr","May","Jun"],orientation:e.orientation||"vertical",barWidth:e.barWidth!==void 0?e.barWidth:14,barGap:e.barGap!==void 0?e.barGap:4,barCornerRadius:e.barCornerRadius!==void 0?e.barCornerRadius:5,showXAxis:!!e.showXAxis,showYAxis:!!e.showYAxis,xAxisColor:e.xAxisColor||"rgba(255,255,255,0.12)",yAxisColor:e.yAxisColor||"rgba(255,255,255,0.12)",showXLabels:e.showXLabels!==void 0?!!e.showXLabels:!0,showYLabels:!!e.showYLabels,axisLabelColor:e.axisLabelColor||"rgba(255,255,255,0.5)",axisLabelFontSize:e.axisLabelFontSize||9,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.7)",legendFontSize:e.legendFontSize||9,showGridLines:e.showGridLines!==void 0?!!e.showGridLines:!0,gridColor:e.gridColor||"rgba(255,255,255,0.06)",cardBackground:e.cardBackground||"rgba(255,255,255,0.04)",cardBorderColor:e.cardBorderColor||"rgba(255,255,255,0.08)",barGradient:e.barGradient!==void 0?!!e.barGradient:!0,showValueOnTop:!!e.showValueOnTop,chartBackground:e.chartBackground||"transparent",barStyle:e.barStyle||"solid",barBorderWidth:e.barBorderWidth!==void 0?e.barBorderWidth:1,barBorderColor:e.barBorderColor||"auto",enableShadows:!!e.enableShadows,shadowColor:e.shadowColor||"rgba(0,0,0,0.5)",shadowBlur:e.shadowBlur!==void 0?e.shadowBlur:4,shadowOffsetY:e.shadowOffsetY!==void 0?e.shadowOffsetY:2,valueFontSize:e.valueFontSize||10,valueColor:e.valueColor||"auto",valueFontWeight:e.valueFontWeight||"bold",xAxisLineWidth:e.xAxisLineWidth!==void 0?e.xAxisLineWidth:1,yAxisLineWidth:e.yAxisLineWidth!==void 0?e.yAxisLineWidth:1,gridLineWidth:e.gridLineWidth!==void 0?e.gridLineWidth:1,gridLineDash:e.gridLineDash||[3,4],_getPreset:function(){return ps[this.stylePreset]||ps.default},_resolveColor:function(P,_){const E=this._getPreset();return["#6366f1","#f59e0b","#10b981","#3b82f6","#a855f7"].includes(P)?E.colors[_%E.colors.length]:typeof P=="string"?P:E.colors[_%E.colors.length]},_makeGradient:function(P,_,E,A,W,z){if(!this._getPreset().barGradient&&!this.barGradient)return _;const G=P.createLinearGradient(E,A,W,z);return G.addColorStop(0,_),G.addColorStop(1,_+"44"),G},_drawRoundedBar:function(P,_,E,A,W,z,Y){if(z=Math.min(z,Math.min(Math.abs(A),Math.abs(W))/2),z<=0||A===0||W===0){P.rect(_,E,A,W);return}P.beginPath(),Y?(P.moveTo(_,E+W),P.lineTo(_,E+z),P.quadraticCurveTo(_,E,_+z,E),P.lineTo(_+A-z,E),P.quadraticCurveTo(_+A,E,_+A,E+z),P.lineTo(_+A,E+W),P.lineTo(_,E+W)):(P.moveTo(_,E),P.lineTo(_+A-z,E),P.quadraticCurveTo(_+A,E,_+A,E+z),P.lineTo(_+A,E+W-z),P.quadraticCurveTo(_+A,E+W,_+A-z,E+W),P.lineTo(_,E+W),P.lineTo(_,E)),P.closePath()}},n=s.width,a=s.height,r=-n/2,f=-a/2;if(!s.datasets||s.datasets.length===0||s.categories.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.7)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO CHART DATA",0,0),t.restore();return}const h=s._getPreset();let l=-1/0,p=1/0;const c=s.categories.length,d=s.datasets.length;if(s.chartType==="stacked")for(let P=0;P<c;P++){let _=0,E=0;s.datasets.forEach(A=>{const W=A.data[P]??0;W>=0?_+=W:E+=W}),_>l&&(l=_),E<p&&(p=E)}else s.datasets.forEach(P=>{P.data&&P.data.forEach(_=>{_>l&&(l=_),_<p&&(p=_)})});isFinite(l)||(l=10),isFinite(p)||(p=0),l=Math.max(l,0),p=Math.min(p,0);const u=l-p||10;t.save(),s.enableShadows&&(t.shadowColor=s.shadowColor,t.shadowBlur=s.shadowBlur,t.shadowOffsetY=s.shadowOffsetY),t.font=s.axisLabelFontSize+"px Inter, sans-serif";const v=s.showYLabels?t.measureText(l.toFixed(0)).width+14:10,b=s.showXLabels?s.axisLabelFontSize+12:8,m=(s.showLegend&&d>0?s.legendFontSize+10:0)+8,S=10,C=r+v,w=f+m,M=n-v-S,I=a-m-b;if(s.enableShadows&&(t.shadowColor="transparent"),t.beginPath(),t.roundRect(r,f,n,a,10),t.fillStyle=h.cardBackground,t.fill(),t.strokeStyle=h.cardBorderColor,t.lineWidth=1,t.stroke(),s.chartBackground&&s.chartBackground!=="transparent"&&(t.beginPath(),t.rect(C,w,M,I),t.fillStyle=s.chartBackground,t.fill()),s.showLegend&&d>0){t.font=s.legendFontSize+"px Inter, sans-serif",t.textBaseline="middle";const P=f+12;let _=C;s.datasets.forEach((E,A)=>{const W=s._resolveColor(E.color,A),z=E.label||"Series "+(A+1),Y=7;t.beginPath(),t.roundRect(_,P-Y/2,Y,Y,2),t.fillStyle=W,t.fill(),t.fillStyle=h.legendColor,t.textAlign="left",t.fillText(z,_+Y+4,P),_+=t.measureText(z).width+Y+16})}const k=4;if(s.showGridLines){t.setLineDash(s.gridLineDash||[]),t.lineWidth=s.gridLineWidth||1,t.strokeStyle=h.gridColor;for(let P=0;P<=k;P++)if(s.orientation==="horizontal"){const _=C+P/k*M;t.beginPath(),t.moveTo(_,w),t.lineTo(_,w+I),t.stroke()}else{const _=w+P/k*I;t.beginPath(),t.moveTo(C,_),t.lineTo(C+M,_),t.stroke()}t.setLineDash([])}if(s.showYLabels){t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor;for(let P=0;P<=k;P++)if(s.orientation==="horizontal"){const _=p+P/k*u,E=C+P/k*M;t.textAlign="center",t.fillText(_.toFixed(0),E,w+I+s.axisLabelFontSize)}else{const _=l-P/k*u,E=w+P/k*I;t.textAlign="right",t.fillText(_.toFixed(0),C-6,E)}}if(t.setLineDash([]),s.showXAxis&&(t.lineWidth=s.xAxisLineWidth||1,t.strokeStyle=s.xAxisColor,t.beginPath(),t.moveTo(C,w+I),t.lineTo(C+M,w+I),t.stroke()),s.showYAxis&&(t.lineWidth=s.yAxisLineWidth||1,t.strokeStyle=s.yAxisColor,t.beginPath(),t.moveTo(C,w),t.lineTo(C,w+I),t.stroke()),s.enableShadows&&(t.shadowColor=s.shadowColor),s.chartType==="stacked")if(s.orientation==="horizontal"){const P=I/c;for(let _=0;_<c;_++){const E=w+_*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[_]||"",C-5,E),s.enableShadows&&(t.shadowColor=s.shadowColor));let A=C;s.datasets.forEach((W,z)=>{const Y=W.data[_]??0;if(Y===0)return;const G=Y/u*M,N=Math.min(s.barWidth*d+s.barGap,P-8),J=E-N/2,x=A;A+=G;const F=s._resolveColor(W.color,z);t.beginPath(),t.fillStyle=s._makeGradient(t,F,x,J,x+G,J),s._drawRoundedBar(t,x,J,G,N,z===d-1?s.barCornerRadius:0,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?F:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else{const P=M/c;for(let _=0;_<c;_++){const E=C+_*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[_]||"",E,w+I+5),s.enableShadows&&(t.shadowColor=s.shadowColor));let A=w+I;s.datasets.forEach((W,z)=>{const Y=W.data[_]??0;if(Y===0)return;const G=Y/u*I,N=Math.min(s.barWidth*d+s.barGap,P-8),J=E-N/2,x=A-G;A-=G;const F=s._resolveColor(W.color,z);t.beginPath(),t.fillStyle=s._makeGradient(t,F,J,x,J,x+G),s._drawRoundedBar(t,J,x,N,G,z===d-1?s.barCornerRadius:0,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?F:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else if(s.orientation==="horizontal"){const P=I/c,_=d*s.barWidth+Math.max(0,(d-1)*s.barGap),E=C+(0-p)/u*M;for(let A=0;A<c;A++){const W=w+A*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[A]||"",C-5,W),s.enableShadows&&(t.shadowColor=s.shadowColor));const z=W-_/2;s.datasets.forEach((Y,G)=>{const N=Y.data[A]??0,J=Math.abs(N/u*M);if(J<1)return;const x=z+G*(s.barWidth+s.barGap),F=N>=0?E:E-J,j=s._resolveColor(Y.color,G);t.beginPath(),t.fillStyle=s._makeGradient(t,j,F,x,F+J,x),s._drawRoundedBar(t,F,x,J,s.barWidth,s.barCornerRadius,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?j:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&N!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign=N>=0?"left":"right",t.textBaseline="middle",t.fillStyle=s.valueColor==="auto"?j:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(N.toString(),N>=0?F+J+4:F-4,x+s.barWidth/2),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}else{const P=M/c,_=d*s.barWidth+Math.max(0,(d-1)*s.barGap),E=w+I-(0-p)/u*I;for(let A=0;A<c;A++){const W=C+A*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[A]||"",W,w+I+5),s.enableShadows&&(t.shadowColor=s.shadowColor));const z=W-_/2;s.datasets.forEach((Y,G)=>{const N=Y.data[A]??0,J=Math.abs(N/u*I);if(J<1)return;const x=z+G*(s.barWidth+s.barGap),F=N>=0?E-J:E,j=s._resolveColor(Y.color,G);t.beginPath(),t.fillStyle=s._makeGradient(t,j,x,F,x,F+J),s._drawRoundedBar(t,x,F,s.barWidth,J,s.barCornerRadius,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?j:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&N!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign="center",t.textBaseline=N>=0?"bottom":"top",t.fillStyle=s.valueColor==="auto"?j:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(N.toString(),x+s.barWidth/2,N>=0?F-4:F+J+4),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}t.restore()}renderPieChart(t,i){var v,b;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s={width:((v=i.geometry)==null?void 0:v.width)||180,height:((b=i.geometry)==null?void 0:b.height)||180,chartType:e.chartType||"donut",stylePreset:e.stylePreset||"default",slices:e.slices||[{id:"slice-1",label:"Item 1",value:45,color:"#6366f1"}],innerRadius:e.innerRadius!==void 0?e.innerRadius:.55,sliceGap:e.sliceGap!==void 0?e.sliceGap:3,showLabels:!!e.showLabels,labelColor:e.labelColor||"#ffffff",labelFontSize:e.labelFontSize||10,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.65)",legendFontSize:e.legendFontSize||9,showCenterText:e.showCenterText!==void 0?!!e.showCenterText:!0,centerLabel:e.centerLabel||"Total",centerTextColor:e.centerTextColor||"#ffffff",centerLabelColor:e.centerLabelColor||"rgba(255,255,255,0.4)",_getPreset:function(){return gs[this.stylePreset]||gs.default},_resolveSliceColor:function(y,m){const S=y.color,C=m,w=this._getPreset();return["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399","#a855f7","#f87171"].includes(S)?w.colors[C%w.colors.length]:typeof S=="string"?S:w.colors[C%w.colors.length]}},n=s.width,a=s.height;if(!s.slices||s.slices.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO PIE DATA",0,0),t.restore();return}const r=s.slices.reduce((y,m)=>y+(m.value||0),0);if(r<=0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("EMPTY DATA",0,0),t.restore();return}const f=s._getPreset();t.save(),t.beginPath(),t.roundRect(-n/2,-a/2,n,a,10),t.fillStyle=f.cardBackground,t.fill(),t.strokeStyle=f.cardBorderColor,t.lineWidth=1,t.stroke();const h=s.showLegend?Math.ceil(s.slices.length/2):0,l=h>0?h*(s.legendFontSize+8)+10:0,p=a-l-16,c=Math.min(n-24,p)/2,d=0,u=-l/2;if(s.chartType==="rose"){const y=Math.max(...s.slices.map(C=>C.value||0)),m=Math.PI*2/s.slices.length,S=c>0?s.sliceGap/c:0;s.slices.forEach((C,w)=>{const M=C.value||0;if(M===0)return;const I=M/y*c,k=-Math.PI/2+w*m+S/2,T=k+m-S,O=s._resolveSliceColor(C,w);if(t.beginPath(),t.moveTo(d,u),t.arc(d,u,I,k,T),t.closePath(),t.fillStyle=O+"cc",t.fill(),t.strokeStyle=O,t.lineWidth=1.5,t.stroke(),s.showLabels){const P=k+(T-k)/2,_=d+I*.65*Math.cos(P),E=u+I*.65*Math.sin(P),A=Math.round(M/r*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=f.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${A}%`,_,E),t.restore()}})}else{const y=s.chartType==="pie"?0:s.innerRadius,m=c*Math.max(0,y),S=c>0?s.sliceGap/c:0;let C=-Math.PI/2;if(s.slices.forEach((w,M)=>{const I=w.value||0;if(I===0){C+=I/r*Math.PI*2;return}const k=I/r*Math.PI*2,T=C+S/2,O=C+k-S/2;if(O<=T){C+=k;return}const P=s._resolveSliceColor(w,M);if(t.beginPath(),t.fillStyle=P,m<=0?(t.moveTo(d,u),t.arc(d,u,c,T,O),t.lineTo(d,u)):(t.moveTo(d+c*Math.cos(T),u+c*Math.sin(T)),t.arc(d,u,c,T,O),t.arc(d,u,m,O,T,!0),t.closePath()),t.fill(),s.showLabels){const _=T+(O-T)/2,E=m+(c-m)/2,A=d+E*Math.cos(_),W=u+E*Math.sin(_),z=Math.round(I/r*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=f.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${z}%`,A,W),t.restore()}C+=k}),s.chartType==="donut"&&s.showCenterText&&m>14){const w=Math.round(r),M=Math.min(Math.floor(m*.52),20),I=Math.min(Math.floor(m*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${M}px Inter, sans-serif`,t.fillStyle=f.centerTextColor,t.fillText(w.toString(),d,u-I*.5),s.centerLabel&&(t.font=`${I}px Inter, sans-serif`,t.fillStyle=f.centerLabelColor,t.fillText(s.centerLabel,d,u+M*.6))}}if(s.showLegend&&s.slices.length>0){t.font=`${s.legendFontSize}px Inter, sans-serif`;const y=2,m=n/y,S=s.legendFontSize+8,C=a/2-l+10,w=-n/2+10;s.slices.forEach((M,I)=>{const k=I%y,T=Math.floor(I/y),O=w+k*m,P=C+T*S,_=s._resolveSliceColor(M,I),E=7;t.beginPath(),t.roundRect(O,P-E/2,E,E,2),t.fillStyle=_,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=f.legendColor;const A=Math.round((M.value||0)/r*100),W=`${M.label||"Item"} ${A}%`,z=m-E-20;let Y=W;for(;t.measureText(Y).width>z&&Y.length>4;)Y=Y.slice(0,-4)+"…";t.fillText(Y,O+E+4,P)})}t.restore()}renderJoystick(t,i){var u,v,b,y,m;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.width)!==void 0?o.width:((u=i.geometry)==null?void 0:u.width)??i.width??100,s=(o==null?void 0:o.height)!==void 0?o.height:((v=i.geometry)==null?void 0:v.height)??i.height??100,n=Math.min(e,s)*.45,a=Math.min(e,s)*.15;let r=i.handleX||0,f=i.handleY||0;o&&o.handleX!==void 0&&(r=o.handleX),o&&o.handleY!==void 0&&(f=o.handleY),t.save();let h=0,l=0;i.handleOrigin==="top-left"?(h=e/2,l=s/2):i.handleOrigin==="bottom-right"&&(h=-e/2,l=-s/2),t.translate(h,l),t.beginPath(),i.boundsShape==="square"?t.rect(-n,-n,n*2,n*2):t.arc(0,0,n,0,Math.PI*2),t.fillStyle="rgba(0,0,0,0.2)",(b=i.style)!=null&&b.fill&&typeof i.style.fill=="string"?t.fillStyle=i.style.fill:(y=i.style)!=null&&y.fill&&i.style.fill.type==="solid"&&(t.fillStyle=i.style.fill.color),t.fill(),(m=i.style)!=null&&m.stroke&&i.style.stroke.isEnabled!==!1&&(t.lineWidth=i.style.stroke.width||1,t.strokeStyle=i.style.stroke.color||"#000",t.stroke());const p=n-a;let c=0,d=0;i.joystickType==="2D"?(c=r*p,d=f*p):i.joystickType==="1D_X"?(c=r*p,d=0):i.joystickType==="1D_Y"&&(c=0,d=f*p),t.beginPath(),t.arc(c,d,a,0,Math.PI*2),t.fillStyle="#fff",t.fill(),t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1,t.stroke(),t.restore()}getRadioGroupItemIndexAtPointer(t,i,o){var I,k;const e=t.options||{},s=this.objectStates.get(t.id)||{},n=e.optionsList||[];if(n.length===0)return null;const a=s.width!==void 0?s.width:((I=t.geometry)==null?void 0:I.width)||180,r=s.height!==void 0?s.height:((k=t.geometry)==null?void 0:k.height)||100,f=e.orientation||"vertical",h=e.itemGap!==void 0?e.itemGap:16,l=e.fontSize||14,p=this.getWorldTransform(t.id),c=i-p.x,d=o-p.y,u=-p.rotation*(Math.PI/180),v=Math.cos(u),b=Math.sin(u),y=c*v-d*b,m=c*b+d*v,C=8*2,w=-a/2,M=-r/2;if(f==="vertical"){const T=Math.max(C,l)+h;for(let O=0;O<n.length;O++){const P=M+O*T;if(y>=w&&y<=w+a&&m>=P&&m<=P+T)return O}}else{let T=w;for(let O=0;O<n.length;O++){const _=n[O].length*8,E=C+6+_+h;if(y>=T&&y<=T+E&&m>=M&&m<=M+r)return O;T+=E}}return null}renderLineGraph(t,i,o,e){let s=i.datasets||[];if((!s||s.length===0)&&(i.data||i.graphData)&&(s=[{id:"line-1",label:"Series 1",data:i.data||i.graphData||[],lineColor:i.lineColor||"#3b82f6",lineWidth:i.lineWidth||2,showArea:i.showArea||!1,areaColor:i.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:i.smoothing||!1,showPoints:i.showPoints!==void 0?i.showPoints:!0,pointSize:i.pointSize||6,pointFill:i.pointFill||"#ffffff",pointStrokeColor:i.pointStrokeColor||i.lineColor||"#3b82f6",pointStrokeWidth:i.pointStrokeWidth||2}]),!s||s.length===0||!s.some(u=>u.data&&u.data.length>=2)){t.save(),t.fillStyle="#6366f1",t.font="12px Inter, system-ui, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO DATA",0,0),t.restore();return}let n=1/0,a=-1/0,r=0;if(s.forEach(u=>{let v=u.data;if(u.isVarEnabled&&u.inputId){let b=this.inputs.get(u.inputId);if(b===void 0){const y=this.inputNameMap.get(u.inputId);y&&y.length>0&&(b=this.inputs.get(y[0]))}b&&Array.isArray(b)&&(v=b)}if(v&&v.length>0){const b=v.filter(y=>typeof y=="number"&&!isNaN(y));b.length>0&&(n=Math.min(n,...b),a=Math.max(a,...b),r=Math.max(r,v.length))}u._resolvedData=v}),r<2)return;const f=a-n,h=o/(r-1),l=u=>{const v=f===0?.5:(u-n)/f;return e/2-v*e},p=u=>u*h-o/2,c=i.axisColor||"#333333";if(i.showXAxis&&(t.beginPath(),t.strokeStyle=i.xAxisColor||c,t.lineWidth=1,t.moveTo(-o/2,e/2),t.lineTo(o/2,e/2),t.stroke()),i.showYAxis&&(t.beginPath(),t.strokeStyle=i.yAxisColor||c,t.lineWidth=1,t.moveTo(-o/2,-e/2),t.lineTo(-o/2,e/2),t.stroke()),t.fillStyle=i.axisLabelColor||"#333333",t.font=`${i.axisLabelFontSize||10}px Inter, sans-serif`,i.showXLabels){t.textAlign="center",t.textBaseline="top";for(let u=0;u<r;u++){const v=p(u);t.fillText(`${u+1}`,v,e/2+5)}}if(i.showYLabels){t.textAlign="right",t.textBaseline="middle";const u=-o/2-5,v=(a+n)/2;t.fillText(a.toFixed(1),u,l(a)),t.fillText(v.toFixed(1),u,l(v)),t.fillText(n.toFixed(1),u,l(n))}const d=10;if(s.forEach(u=>{const v=u._resolvedData;if(!(!v||v.length<2)){if(u.showArea){if(t.beginPath(),t.moveTo(p(0),e/2),t.lineTo(p(0),l(v[0])),u.smoothing&&v.length>2)for(let y=0;y<v.length-1;y++){const m=v[y===0?y:y-1],S=v[y],C=v[y+1],w=v[y+1===v.length-1?y+1:y+2];for(let M=1;M<=d;M++){const I=M/d,k=this._catmullRom(m,S,C,w,I);t.lineTo(p(y+I),l(k))}}else for(let y=1;y<v.length;y++)t.lineTo(p(y),l(v[y]));t.lineTo(p(v.length-1),e/2),t.closePath();const b=t.globalAlpha;t.globalAlpha=b*(i.areaOpacity??.3),t.fillStyle=u.areaColor||"rgba(139, 92, 246, 0.2)",t.fill(),t.globalAlpha=b}if(t.beginPath(),t.strokeStyle=u.lineColor||"#3b82f6",t.lineWidth=u.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.moveTo(p(0),l(v[0])),u.smoothing&&v.length>2)for(let b=0;b<v.length-1;b++){const y=v[b===0?b:b-1],m=v[b],S=v[b+1],C=v[b+1===v.length-1?b+1:b+2];for(let w=1;w<=d;w++){const M=w/d,I=this._catmullRom(y,m,S,C,M);t.lineTo(p(b+M),l(I))}}else for(let b=1;b<v.length;b++)t.lineTo(p(b),l(v[b]));t.stroke(),u.showPoints&&v.forEach((b,y)=>{const m=p(y),S=l(b);t.beginPath(),t.arc(m,S,(u.pointSize||6)/2,0,Math.PI*2),t.fillStyle=u.pointFill||"#ffffff",t.fill(),t.strokeStyle=u.pointStrokeColor||u.lineColor||"#3b82f6",t.lineWidth=u.pointStrokeWidth||1,t.stroke()})}}),i.showLegend&&s.length>0){const u=o/2-10;let v=-e/2+15;const b=i.legendFontSize||10,y=b+5;t.font=`${b}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",s.forEach(m=>{const C=m.label||"Series",w=t.measureText(C).width;t.beginPath(),t.rect(u-w-8-5,v-(8/2+2),8,8),t.fillStyle=m.lineColor||"#3b82f6",t.fill(),t.fillStyle=i.legendColor||"#333333",t.fillText(C,u,v),v+=y})}}_catmullRom(t,i,o,e,s){const n=(o-t)*.5,a=(e-i)*.5,r=s*s,f=s*r;return(2*i-2*o+n+a)*f+(-3*i+3*o-2*n-a)*r+n*s+i}normalizeOpacity(t){const i=typeof t=="number"?t:parseFloat(String(t));return isNaN(i)?1:i>1?Math.min(1,i/100):Math.max(0,Math.min(1,i))}createCanvasFill(t,i,o,e){var s,n,a;if(!i||i.type==="None")return null;if(typeof i=="string")return i;if(i.type==="Solid"&&i.color){const r=i.color,h=(((n=(s=this.artboard)==null?void 0:s.tokens)==null?void 0:n.colors)||{})[r]||r;return t.fillStyle=h,h}if((i.type==="LinearGradient"||i.type==="RadialGradient"||i.type==="AngularGradient"||i.type==="DiamondGradient")&&i.stops){const r=(f,h=100)=>{var S,C;const p=(((C=(S=this.artboard)==null?void 0:S.tokens)==null?void 0:C.colors)||{})[f]||f,c=this.normalizeOpacity(i.opacity??100),u=this.normalizeOpacity(h)*c;if(u>=1&&p.startsWith("#"))return p;const v=p.startsWith("#")?p.replace("#",""):"ffffff",b=parseInt(v.substring(0,2),16),y=parseInt(v.substring(2,4),16),m=parseInt(v.substring(4,6),16);return`rgba(${b}, ${y}, ${m}, ${u})`};if(i.type==="LinearGradient"){const f=(u,v,b)=>Array.isArray(u)?u[v]??(v===0?0:1):u&&typeof u=="object"?u[b]??(v===0?0:1):v===0?0:1,h=f(i.start,0,"x")*o-o/2,l=f(i.start,1,"y")*e-e/2,p=f(i.end,0,"x")*o-o/2,c=f(i.end,1,"y")*e-e/2,d=t.createLinearGradient(h,l,p,c);if(i.stops.forEach(u=>{const v=u.offset!==void 0?u.offset:u.pos!==void 0?u.pos:u.position!==void 0?u.position:0,b=r(u.color||"#000000",u.opacity??100);d.addColorStop(Math.max(0,Math.min(1,v)),b)}),i.gradientTransform&&d.setTransform){const[u,v,b,y,m,S]=i.gradientTransform;d.setTransform({a:u,b:v,c:b,d:y,e:m,f:S})}return d}else if(i.type==="RadialGradient"){const f=(d,u,v)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[v]??.5:.5,h=f(i.center,0,"x")*o-o/2,l=f(i.center,1,"y")*e-e/2,p=(i.radius??.5)*Math.max(o,e),c=t.createRadialGradient(h,l,0,h,l,p);if(i.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,v=r(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,u)),v)}),i.gradientTransform&&c.setTransform){const[d,u,v,b,y,m]=i.gradientTransform;c.setTransform({a:d,b:u,c:v,d:b,e:y,f:m})}return c}else if(i.type==="AngularGradient"){const f=(d,u,v)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[v]??.5:.5,h=f(i.center||[.5,.5],0,"x")*o-o/2,l=f(i.center||[.5,.5],1,"y")*e-e/2,p=(i.degree||i.angle||0)*(Math.PI/180),c=(a=t.createConicGradient)==null?void 0:a.call(t,p,h,l);if(c){if(i.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,v=r(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,u)),v)}),i.gradientTransform&&c.setTransform){const[d,u,v,b,y,m]=i.gradientTransform;c.setTransform({a:d,b:u,c:v,d:b,e:y,f:m})}return c}}else if(i.type==="DiamondGradient"){const f=(d,u,v)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[v]??.5:.5,h=f(i.center||[.5,.5],0,"x")*o-o/2,l=f(i.center||[.5,.5],1,"y")*e-e/2,p=(i.radius??.5)*Math.max(o,e);t.save(),t.translate(h,l),t.rotate(Math.PI/4);const c=t.createRadialGradient(0,0,0,0,0,p);if(i.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,v=r(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,u)),v)}),i.gradientTransform&&c.setTransform){const[d,u,v,b,y,m]=i.gradientTransform;c.setTransform({a:d,b:u,c:v,d:b,e:y,f:m})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=c,t.restore(),c}}if(i.type==="Pattern"&&i.url){let r=this.imageCache.get(i.url);if(r||(r=new Image,r.src=i.url,this.imageCache.set(i.url,r)),r.complete&&r.naturalWidth>0){const f=t.createPattern(r,"repeat");if(f&&(i.scaleX!==void 0||i.offsetX!==void 0)){const h=new DOMMatrix,l=i.scaleX??1,p=i.scaleY??1,c=i.offsetX??0,d=i.offsetY??0,u=i.rotation??0;h.translateSelf(c,d),h.rotateSelf(u),h.scaleSelf(l,p),f.setTransform(h)}return f}}return i.color||null}drawRoundRect(t,i,o,e,s,n){if(n===0||n===void 0||n===null){t.rect(i,o,e,s);return}let a=n;if(typeof a=="string")try{a=JSON.parse(a)}catch{a=parseFloat(a)||0}let r=0,f=0,h=0,l=0;typeof a=="number"?r=f=h=l=a:Array.isArray(a)?a.length===1?r=f=h=l=a[0]:a.length===2?(r=h=a[0],f=l=a[1]):a.length===3?(r=a[0],f=l=a[1],h=a[2]):a.length>=4&&(r=a[0],f=a[1],h=a[2],l=a[3]):a&&typeof a=="object"&&(r=a.tl??a.corner_radius??a.cornerRadius??0,f=a.tr??a.corner_radius??a.cornerRadius??0,h=a.br??a.corner_radius??a.cornerRadius??0,l=a.bl??a.corner_radius??a.cornerRadius??0);const p=Math.min(Math.abs(e)/2,Math.abs(s)/2);if(r=Math.min(Math.max(0,r),p),f=Math.min(Math.max(0,f),p),h=Math.min(Math.max(0,h),p),l=Math.min(Math.max(0,l),p),t.roundRect){t.roundRect(i,o,e,s,[r,f,h,l]);return}t.moveTo(i+r,o),t.lineTo(i+e-f,o),t.arcTo(i+e,o,i+e,o+f,f),t.lineTo(i+e,o+s-h),t.arcTo(i+e,o+s,i+e-h,o+s,h),t.lineTo(i+l,o+s),t.arcTo(i,o+s,i,o+s-l,l),t.lineTo(i,o+r),t.arcTo(i,o,i+r,o,r),t.closePath()}renderListView(t,i){var A,W,z,Y;const o=this.objectStates.get(i.id)||{},e=o.options||i.options||{},s=o.width!==void 0?o.width:((A=i.geometry)==null?void 0:A.width)||200,n=o.height!==void 0?o.height:((W=i.geometry)==null?void 0:W.height)||300,a=-s/2,r=-n/2,f=o.corner_radius!==void 0?o.corner_radius:e.corner_radius??0,h=e.orientation||"vertical",l=e.items||[],p=e.itemGap??10,c=e.itemHeight??50,d=e.itemWidth??200,u=e.scrollOffset??0,v=e.padding??0,b=e.glassEffect!==!1,y=e.accentColor||"#3b82f6",m=e.itemTextColor||"#333333",S=e.itemBackgroundColor||"#ffffff",C=e.hoveredIndex??null,w=e.activeItemIndex??null,M=e.glowIntensity??0,I=e.glowColor||"#3b82f6",k=typeof I=="string"?I:I.color||((Y=(z=I.stops)==null?void 0:z[0])==null?void 0:Y.color)||"#3b82f6",T=e.opacity!==void 0?e.opacity:i.opacity!==void 0?i.opacity:1;if(t.save(),t.globalAlpha*=T,M>0){const G=t.getTransform(),N=Math.sqrt(G.a*G.a+G.b*G.b)||1;t.shadowColor=k,t.shadowBlur=M*2*N,t.shadowOffsetX=0,t.shadowOffsetY=0}if(b){const G=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",N=this.createCanvasFill(t,G,s,n);t.fillStyle=N||"rgba(31, 41, 55, 0.4)",t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f)||t.fill();const x=t.createLinearGradient(a,r,a+s,r+n);x.addColorStop(0,"rgba(255, 255, 255, 0.15)"),x.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),x.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=x,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f)||t.fill(),t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f)||t.stroke()}else{const G=e.backgroundColor||e.listBackgroundColor||"transparent",N=this.createCanvasFill(t,G,s,n);if(N){t.fillStyle=N,t.beginPath();const x=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f);t.fill()}const J=e.borderWidth??0;if(J>0){t.strokeStyle=e.borderColor||"#cccccc",t.lineWidth=J,t.beginPath();const x=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f);t.stroke()}}t.shadowBlur=0,t.save(),t.beginPath();const O=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f);if(e.listLayout!=="circular")if(O&&e.containerShape==="custom")try{const G=new Path2D(e.containerPath);t.translate(a,r),t.scale(s/100,n/100),t.clip(G),t.scale(100/s,100/n),t.translate(-a,-r)}catch{}else t.clip();const P=typeof v=="number"?v:h==="vertical"?v[0]:v[3];let _=(h==="vertical"?r:a)+u+P;if(t.textBaseline="middle",l.forEach((G,N)=>{const J=e.listLayout||"linear",x=J==="circular"?d:h==="vertical"?s:d,F=J==="circular"||h==="vertical"?c:n;let j=0,X=0,tt=0;if(J==="circular"){const vt=l.length||1,Dt=Math.PI*2/vt,ae=e.circularStartAngle||0,pe=e.circularRadius||100,st=u*.01+ae*Math.PI/180,yt=N*Dt+st,Rt=a+s/2,_t=r+n/2;j=Rt+Math.cos(yt)*pe-x/2,X=_t+Math.sin(yt)*pe-F/2,tt=yt+(e.itemRotation||0)*Math.PI/180}else j=h==="vertical"?a:_,X=h==="vertical"?_:r,tt=(e.itemRotation||0)*Math.PI/180;const L=C===N,R=w===N,D=R&&e.activeItemShape?e.activeItemShape:e.itemShape||"rectangle",q=R&&e.activeItemShape?e.activeItemPath:e.itemPath||"",ot=e.itemCornerRadius||0;if(t.save(),tt!==0&&(t.translate(j+x/2,X+F/2),t.rotate(tt),t.translate(-(j+x/2),-(X+F/2))),R){const vt=this.createCanvasFill(t,y,x,F);t.fillStyle=vt||y;const Dt=t.globalAlpha;t.globalAlpha=Dt*.8,t.beginPath(),this.drawCustomShape(t,D,q,j,X,x,F,ot)||(t.rect(j,X,x,F),t.fill()),t.globalAlpha=Dt}else if(L)t.fillStyle=b?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",t.beginPath(),this.drawCustomShape(t,D,q,j,X,x,F,ot)||(t.rect(j,X,x,F),t.fill());else if(S!=="transparent"){const vt=this.createCanvasFill(t,S,x,F);t.fillStyle=vt||S,t.beginPath(),this.drawCustomShape(t,D,q,j,X,x,F,ot)||(t.rect(j,X,x,F),t.fill())}if(R||L){const vt=this.createCanvasFill(t,y,h==="vertical"?3:x,h==="vertical"?F:3);t.fillStyle=vt||y,h==="vertical"?t.fillRect(j,X,3,F):t.fillRect(j,X+F-3,x,3)}const mt=R?"#ffffff":b?"rgba(255, 255, 255, 0.9)":m;t.fillStyle=mt,t.font=R||L?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const bt=typeof G=="string"?G:(G==null?void 0:G.label)||`Item ${N+1}`,gt=j+(h==="vertical"?16:x/2),Et=X+F/2;h==="horizontal"||J==="circular"?t.textAlign="center":t.textAlign="left";const It=J==="circular"?j+x/2:gt;t.fillText(bt,It,Et),t.restore(),_+=(h==="vertical"?c:d)+p}),t.restore(),e.showScrollbar!==!1){const G=(l.length||0)*(h==="vertical"?c:d)+((l.length||0)-1)*p,N=h==="vertical"?n:s,J=e.listLayout||"linear",x=e.containerShape==="circle"||J==="circular";if(G>N||J==="circular"&&l.length>0){const F=e.scrollbarColor||"rgba(255,255,255,0.3)",j=e.scrollbarWidth||4;if(x){const X=Math.min(s,n)/2-j/2-2,tt=a+s/2,L=r+n/2;if(t.strokeStyle=F,t.lineWidth=j,t.lineCap="round",t.beginPath(),J==="circular"){const R=Math.PI/4,D=-(u*.01)-Math.PI/2;t.arc(tt,L,X,D,D+R)}else{const R=Math.PI/2,D=N/G,q=R*D,ot=-u/G*R,bt=-Math.PI/4+ot;t.arc(tt,L,X,bt,bt+q)}t.stroke()}else{const X=N/G,tt=N*X,L=-u/G*N;t.fillStyle=F,h==="vertical"?t.fillRect(a+s-j-2,r+L,j,tt):t.fillRect(a+L,r+n-j-2,tt,j)}}}t.restore()}drawCustomShape(t,i,o,e,s,n,a,r){if(i==="circle"){const f=Math.min(n,a)/2;return t.arc(e+n/2,s+a/2,f,0,Math.PI*2),!1}else if(i==="pill"){const f=Math.min(n,a)/2;return this.drawListViewRect(t,e,s,n,a,f),!1}else if(i==="custom"&&o)try{const f=new Path2D(o);return t.save(),t.translate(e,s),t.scale(n/100,a/100),t.fill(f),t.restore(),!0}catch{return this.drawListViewRect(t,e,s,n,a,r),!1}return this.drawListViewRect(t,e,s,n,a,r),!1}updateListViewScrollFromPointer(t){var b,y;if(!this._lastPointerPos||!this._prevPointerPos)return;const i=t.options||{},o=i.orientation||"vertical",e=this._lastPointerPos.x-this._prevPointerPos.x,s=this._lastPointerPos.y-this._prevPointerPos.y;o==="vertical"?i.scrollOffset=(i.scrollOffset||0)+s:i.scrollOffset=(i.scrollOffset||0)+e;const n=i.listLayout||"linear",a=this.objectStates.get(t.id)||{},r=i.items||[],f=i.itemGap??10,h=i.itemHeight??50,l=i.itemWidth??200,p=a.width!==void 0?a.width:((b=t.geometry)==null?void 0:b.width)||200,c=a.height!==void 0?a.height:((y=t.geometry)==null?void 0:y.height)||300;if(n==="circular")return;const d=(r.length||0)*(o==="vertical"?h:l)+((r.length||0)-1)*f,v=Math.max(0,d-(o==="vertical"?c:p)+(i.padding*2||0));i.scrollOffset>0&&(i.scrollOffset=0),i.scrollOffset<-v&&(i.scrollOffset=-v)}updateListViewHoverFromPointer(t,i,o){const e=this.getListViewItemIndexAtPointer(t,i,o),s=t.options||{};s.hoveredIndex!==e&&(s.hoveredIndex=e)}getListViewItemIndexAtPointer(t,i,o){var z,Y;const e=t.options||{},s=this.objectStates.get(t.id)||{},n=e.items||[];if(n.length===0)return null;const a=s.width!==void 0?s.width:((z=t.geometry)==null?void 0:z.width)||200,r=s.height!==void 0?s.height:((Y=t.geometry)==null?void 0:Y.height)||300,f=e.orientation||"vertical",h=e.itemGap??10,l=e.itemHeight??50,p=e.itemWidth??200,c=e.scrollOffset??0,d=e.padding??0,u=this.getWorldTransform(t.id),v=i-u.x,b=o-u.y,y=-u.rotation*(Math.PI/180),m=Math.cos(y),S=Math.sin(y),C=v*m-b*S,w=v*S+b*m,M=-a/2,I=-r/2,k=typeof d=="number"?d:f==="vertical"?d[0]:d[3];let T=(f==="vertical"?I:M)+c+k;const O=e.listLayout||"linear",P=n.length||1,_=Math.PI*2/P,E=e.circularStartAngle||0,A=e.circularRadius||100,W=c*.01+E*Math.PI/180;for(let G=0;G<n.length;G++){const N=O==="circular"?p:f==="vertical"?a:p,J=O==="circular"||f==="vertical"?l:r;let x=0,F=0,j=0;if(O==="circular"){const X=G*_+W,tt=M+a/2,L=I+r/2;x=tt+Math.cos(X)*A-N/2,F=L+Math.sin(X)*A-J/2,j=X+(e.itemRotation||0)*Math.PI/180}else x=f==="vertical"?M:T,F=f==="vertical"?T:I,j=(e.itemRotation||0)*Math.PI/180;if(j!==0){const X=x+N/2,tt=F+J/2,L=C-X,R=w-tt,D=-j,q=L*Math.cos(D)-R*Math.sin(D)+X,ot=L*Math.sin(D)+R*Math.cos(D)+tt;if(q>=x&&q<=x+N&&ot>=F&&ot<=F+J)return G}else if(C>=x&&C<=x+N&&w>=F&&w<=F+J)return G;T+=(f==="vertical"?l:p)+h}return null}drawListViewRect(t,i,o,e,s,n){t.beginPath(),this.drawRoundRect(t,i,o,e,s,n),t.fill()}solveBehaviors(t){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:i,y:o}=this._lastPointerPos;this.artboard.objects.forEach(e=>{if(!e.behaviors||e.behaviors.length===0)return;const s=this.objectStates.get(e.id);s&&e.behaviors.forEach(n=>{var p,c,d,u,v,b,y,m,S,C,w,M,I,k,T,O,P,_,E,A,W,z,Y,G,N,J,x,F,j,X,tt,L,R,D,q,ot,mt,bt,gt,Et,It,vt,Dt,ae,pe,st,yt,Rt,_t,dt,$t,Vt,Bt,Ft,Ut,re,be,ve,Zt,Ce,_e,Pe,we,Ee,Ae,oe,se,ft,ut,at,B,et,Q,Pt,Ot,kt,At,Mt,$,Yt,jt,ie,te,pt,ct,Ct,rt,V,it,nt,St,Gt,ee,le,Nt,Kt,qt,Ie,xe,Oe,Le,Re,Fe,Xe,Ht,ce,Me,$e,Be,ge,de,ue,ke,De,qe,Ke,Ge,Je;if(!n.enabled)return;const a=n.startTime||0,r=n.endTime||1/0;if(this.currentTime<a||this.currentTime>r)return;const f=s.x-i,h=s.y-o,l=Math.sqrt(f*f+h*h);if(this.frameCount%240===0&&Math.random()<.1&&this.log(`[ExodeUI] Executing ${n.type} on ${e.name}`),n.type===H.Proximity){const U=((p=n.settings)==null?void 0:p.radius)||300,Z=((c=n.settings)==null?void 0:c.falloff)||"smooth";let K=0;l<U&&(Z==="linear"?K=1-l/U:K=Math.pow(1-l/U,2)),n.sensors.forEach(ht=>{this.applyBehaviorSensor(s,ht,K,t,n.settings,e,f,h,l)})}else if(n.type===H.Magnetic){const U=((d=n.settings)==null?void 0:d.radius)||400,Z=((u=n.settings)==null?void 0:u.strength)||.5;if(l<U&&l>5){const K=1-l/U,ht=f*K*Z,Tt=h*K*Z;s.x-=ht*t*10,s.y-=Tt*t*10}}else if(n.type===H.Repel){const U=((v=n.settings)==null?void 0:v.radius)||300,Z=((b=n.settings)==null?void 0:b.strength)||1;if(l<U){const K=Math.pow(1-l/U,2);s.x+=f/(l||1)*K*60*Z*t*5,s.y+=h/(l||1)*K*60*Z*t*5}}else if(n.type===H.Orbit){const U=((y=n.settings)==null?void 0:y.speed)||1,Z=((m=n.settings)==null?void 0:m.radius)||30,K=this.currentTime*U*Math.PI*2;s.x+=Math.cos(K)*Z*t*5,s.y+=Math.sin(K)*Z*t*5,s.rotation+=2*t*5}else if(n.type===H.Vortex){const U=((S=n.settings)==null?void 0:S.radius)||400,Z=((C=n.settings)==null?void 0:C.speed)||2,K=((w=n.settings)==null?void 0:w.strength)||1;if(l<U){const ht=Math.pow(1-l/U,1.5),Tt=this.currentTime*Z*Math.PI*2,Lt=Math.cos(Tt)*30-f*.4,Wt=Math.sin(Tt)*30-h*.4;s.x+=Lt*ht*K*t*5,s.y+=Wt*ht*K*t*5,s.rotation+=5*ht*K*t*5,s.scale_x*=1-ht*.1*K*t,s.scale_y*=1-ht*.1*K*t}}else if(n.type===H.Fluid){const U=((M=n.settings)==null?void 0:M.radius)||300,Z=((I=n.settings)==null?void 0:I.strength)||1;if(l<U){const K=Math.pow(1-l/U,1.2),ht=f/(l||1)*K*1.2*Z,Tt=h/(l||1)*K*1.2*Z;s.x+=ht*10*t*5,s.y+=Tt*10*t*5,s.scale_x*=1+K*.3*Z*t,s.scale_y*=1+K*.3*Z*t}}else if(n.type===H.Elastic){const U=((k=n.settings)==null?void 0:k.radius)||300,Z=((T=n.settings)==null?void 0:T.strength)||1;if(l<U){const K=1-l/U;s.scale_x*=1+K*.4*Z*t,s.scale_y*=1+K*.4*Z*t}}else if(n.type===H.Holographic){const U=s.x-this.canvasWidth/2,Z=s.y-this.canvasHeight/2,K=((O=n.settings)==null?void 0:O.factor)||25;if(s.x-=U/1e3*K*t*5,s.y-=Z/1e3*K*t*5,s.style){const ht=1-Math.min(1,l/400);s.style.exposure=(s.style.exposure||1)+ht*.5*t}}else if(n.type===H.Sticky){const U=((P=n.settings)==null?void 0:P.radius)||80,Z=((_=n.settings)==null?void 0:_.strength)||1;if(l<U){const K=Math.pow(1-l/U,2);s.x-=f*K*Z*t*10,s.y-=h*K*Z*t*10,s.scale_x*=1-K*.1*Z*t,s.scale_y*=1-K*.1*Z*t}}else if(n.type===H.Dilation){const U=((E=n.settings)==null?void 0:E.size)||120,Z=((A=n.settings)==null?void 0:A.strength)||1;if(l<U){const K=1-l/U;s.scale_x*=1+K*.5*Z*t,s.scale_y*=1+K*.5*Z*t}}else if(n.type===H.Parallax){const U=((W=n.settings)==null?void 0:W.factor)||15,Z=((z=n.settings)==null?void 0:z.strength)||1,K=this.canvasWidth/2,ht=this.canvasHeight/2,Tt=this._lastPointerPos||{x:K,y:ht},Lt=(Tt.x-K)/K,Wt=(Tt.y-ht)/ht,ne=(((Y=e.transform)==null?void 0:Y.x)??0)+Lt*U*Z,ye=(((G=e.transform)==null?void 0:G.y)??0)+Wt*U*Z,Te=(((N=e.transform)==null?void 0:N.rotate_x)??0)-Wt*U*1.5*Z,fe=(((J=e.transform)==null?void 0:J.rotate_y)??0)+Lt*U*1.5*Z,Se=Math.min(1,10*t);s.x=this.lerp(s.x??((x=e.transform)==null?void 0:x.x)??0,ne,Se),s.y=this.lerp(s.y??((F=e.transform)==null?void 0:F.y)??0,ye,Se),s.rotate_x=this.lerp(s.rotate_x??((j=e.transform)==null?void 0:j.rotate_x)??0,Te,Se),s.rotate_y=this.lerp(s.rotate_y??((X=e.transform)==null?void 0:X.rotate_y)??0,fe,Se)}else if(n.type===H.Fold){if(l<300){const U=1-l/300,Z=(f>0?-1:1)*U*10,K=1-U*.1,ht=h/300*U*20,Tt=-(f/300)*U*20,Lt=Math.min(1,10*t);s.skew_x=this.lerp(s.skew_x??((tt=e.transform)==null?void 0:tt.skew_x)??0,Z,Lt),s.scale_y=this.lerp(s.scale_y??((L=e.transform)==null?void 0:L.scale_y)??1,(((R=e.transform)==null?void 0:R.scale_y)??1)*K,Lt),s.rotate_x=this.lerp(s.rotate_x??((D=e.transform)==null?void 0:D.rotate_x)??0,ht,Lt),s.rotate_y=this.lerp(s.rotate_y??((q=e.transform)==null?void 0:q.rotate_y)??0,Tt,Lt),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((ot=n.settings)==null?void 0:ot.opacity)??.5}}}else if(n.type===H.Crumple){if(l<300){const U=1-l/300,Z=U*(Math.random()-.5)*5,K=U*(Math.random()-.5)*.05,ht=Math.min(1,15*t);s.skew_x=this.lerp(s.skew_x??((mt=e.transform)==null?void 0:mt.skew_x)??0,Z,ht),s.scale_x=this.lerp(s.scale_x??((bt=e.transform)==null?void 0:bt.scale_x)??1,(((gt=e.transform)==null?void 0:gt.scale_x)??1)*(1+K),ht),s.scale_y=this.lerp(s.scale_y??((Et=e.transform)==null?void 0:Et.scale_y)??1,(((It=e.transform)==null?void 0:It.scale_y)??1)*(1+K),ht),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((vt=n.settings)==null?void 0:vt.intensity)??1,scale:((Dt=n.settings)==null?void 0:Dt.scale)??2}}}else if(n.type===H.Squash){const U=((ae=n.settings)==null?void 0:ae.strength)||.8;l<(e.width||100)&&this.isMouseDown?(s.scale_y=this.lerp(s.scale_y??1,(((pe=e.transform)==null?void 0:pe.scale_y)??1)*U,.3),s.scale_x=this.lerp(s.scale_x??1,(((st=e.transform)==null?void 0:st.scale_x)??1)*(1+(1-U)*.4),.3)):(s.scale_y=this.lerp(s.scale_y??1,((yt=e.transform)==null?void 0:yt.scale_y)??1,.2),s.scale_x=this.lerp(s.scale_x??1,((Rt=e.transform)==null?void 0:Rt.scale_x)??1,.2))}else if(n.type===H.TextCounter){const U=((_t=n.settings)==null?void 0:_t.duration)||2,Z=((dt=n.settings)==null?void 0:dt.from)||0,K=(($t=n.settings)==null?void 0:$t.to)||100;n._runtimeStart===void 0&&(n._runtimeStart=this.currentTime);const ht=this.currentTime-n._runtimeStart,Tt=Math.min(1,ht/U),Lt=Math.floor(Z+(K-Z)*Tt);if(((Vt=e.geometry)==null?void 0:Vt.type)==="Text"){const Wt=((Bt=n.settings)==null?void 0:Bt.prefix)||"",ne=((Ft=n.settings)==null?void 0:Ft.suffix)||"";s.geometry||(s.geometry={...e.geometry}),s.geometry.text=`${Wt}${Lt}${ne}`}}else if(n.type===H.Spotlight){const U=((Ut=n.settings)==null?void 0:Ut.radius)||250,Z=((re=n.settings)==null?void 0:re.strength)||1.5;if(l<U){const K=Math.pow(1-l/U,2);s.style||(s.style={...e.style}),s.style.adjustments||(s.style.adjustments={...(be=e.style)==null?void 0:be.adjustments}),s.style.adjustments.exposure=(((Zt=(ve=e.style)==null?void 0:ve.adjustments)==null?void 0:Zt.exposure)||0)+K*Z*50}else(Ce=s.style)!=null&&Ce.adjustments&&(s.style.adjustments.exposure=this.lerp(s.style.adjustments.exposure||0,((Pe=(_e=e.style)==null?void 0:_e.adjustments)==null?void 0:Pe.exposure)||0,.1))}else if(n.type===H.Noise||n.type===H.Float){const U=(((we=n.settings)==null?void 0:we.frequency)||((Ee=n.settings)==null?void 0:Ee.speed)||1)*.002,Z=(((Ae=n.settings)==null?void 0:Ae.amplitude)||((oe=n.settings)==null?void 0:oe.range)||50)*(((se=n.settings)==null?void 0:se.strength)||1),K=Date.now();s.x+=Math.sin(K*U)*Z*t,s.y+=Math.cos(K*U*.8)*Z*t,s.rotation+=Math.sin(K*U*.5)*5*t}else if(n.type===H.Pulse){const U=(((ft=n.settings)==null?void 0:ft.speed)||1)*.005,Z=(((ut=n.settings)==null?void 0:ut.scale)||1.2)-1,K=Math.sin(Date.now()*U),ht=((at=n.settings)==null?void 0:at.strength)||1;s.scale_x*=1+K*Z*ht*t,s.scale_y*=1+K*Z*ht*t,s.style&&(s.style.exposure=(s.style.exposure||1)+Math.max(0,K)*.1*ht*t)}else if(n.type===H.Draggable){const U=((B=n.settings)==null?void 0:B.radius)||150,Z=this.draggingBehaviors.has(e.id);if(l<U||Z){const K=((et=n.settings)==null?void 0:et.strength)||1,ht=Z?1:Math.max(0,1-l/U);this.applyBehaviorSensor(s,Qt.PositionX,ht*K,t,n.settings),this.applyBehaviorSensor(s,Qt.PositionY,ht*K,t,n.settings)}}else if(n.type===H.Scroll){const U=((Q=n.settings)==null?void 0:Q.axis)||"vertical",Z=((Pt=n.settings)==null?void 0:Pt.factor)||.5,K=((Ot=n.settings)==null?void 0:Ot.strength)||1,ht=((kt=n.settings)==null?void 0:kt.scaleFactor)||0;(U==="vertical"||U==="both")&&(s.y+=this.scrollOffset.y*Z*K*t),(U==="horizontal"||U==="both")&&(s.x+=this.scrollOffset.x*Z*K*t),ht!==0&&(s.scale_x*=1+this.scrollOffset.y*ht*t,s.scale_y*=1+this.scrollOffset.y*ht*t)}else if(n.type===H.LookAt){const U=((At=n.settings)==null?void 0:At.factor)||1,Z=((Mt=n.settings)==null?void 0:Mt.strength)||1,K=Math.atan2(-h,-f)*(180/Math.PI),ht=s.rotation,Tt=(K-ht+180)%360-180;s.rotation+=Tt*U*Z*t*10}else if(n.type===H.Scan){const U=((($=n.settings)==null?void 0:$.speed)||1)*.004,Z=((Yt=n.settings)==null?void 0:Yt.strength)||1,K=(Math.sin(Date.now()*U)+1)/2;s.style&&(s.style.exposure=(s.style.exposure||1)+K*Z*t*5),s.x+=(K-.5)*20*Z*t}else if(n.type===H.Glint)s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"glint_overlay",intensity:((jt=n.settings)==null?void 0:jt.strength)??.8};else if(n.type===H.Ratchet){const U=((ie=n.settings)==null?void 0:ie.steps)||12,Z=(((te=n.settings)==null?void 0:te.speed)||1)*30,K=Math.floor(s.rotation/(360/U))*(360/U);s.rotation=this.lerp(s.rotation,K+Z*t,.1)}else if(n.type===H.Jitter&&l<300){const U=((pt=n.settings)==null?void 0:pt.strength)||1,Z=(((ct=n.settings)==null?void 0:ct.intensity)||5)*U;s.x+=(Math.random()-.5)*Z*t*60,s.y+=(Math.random()-.5)*Z*t*60,s.rotation+=(Math.random()-.5)*Z*t*120}else if(n.type===H.Follower){const U=(Ct=n.settings)==null?void 0:Ct.targetId;if(U){const Z=this.objectStates.get(U);if(Z){const K=((rt=n.settings)==null?void 0:rt.stiffness)||.1,ht=Z.x-s.x,Tt=Z.y-s.y;s.x+=ht*K*t*60,s.y+=Tt*K*t*60}}}else if(n.type===H.Wrap)s.x<0?s.x=this.canvasWidth:s.x>this.canvasWidth&&(s.x=0),s.y<0?s.y=this.canvasHeight:s.y>this.canvasHeight&&(s.y=0);else if(n.type===H.Gravity){const U=((V=n.settings)==null?void 0:V.strength)||9.8;s.y+=U*t*10}else if(n.type===H.Velocity){const U=((it=n.settings)==null?void 0:it.vx)||0,Z=((nt=n.settings)==null?void 0:nt.vy)||0;s.x+=U*t*10,s.y+=Z*t*10}else if(n.type===H.Shear){const U=((St=n.settings)==null?void 0:St.strength)||1,Z=((Gt=n.settings)==null?void 0:Gt.radius)||300;if(l<Z){const K=1-l/Z;s.skew_x=this.lerp(s.skew_x||0,(((ee=e.transform)==null?void 0:ee.skew_x)||0)+K*U*30,.1)}else s.skew_x=this.lerp(s.skew_x||0,((le=e.transform)==null?void 0:le.skew_x)||0,.05)}else if(n.type===H.Lens){const U=((Nt=n.settings)==null?void 0:Nt.radius)||200,Z=((Kt=n.settings)==null?void 0:Kt.strength)||.5;if(l<U){const K=Math.pow(1-l/U,2);s.scale_x=this.lerp(s.scale_x??1,(((qt=e.transform)==null?void 0:qt.scale_x)??1)*(1+K*Z),.2),s.scale_y=this.lerp(s.scale_y??1,(((Ie=e.transform)==null?void 0:Ie.scale_y)??1)*(1+K*Z),.2)}else s.scale_x=this.lerp(s.scale_x??1,((xe=e.transform)==null?void 0:xe.scale_x)??1,.1),s.scale_y=this.lerp(s.scale_y??1,((Oe=e.transform)==null?void 0:Oe.scale_y)??1,.1)}else if(n.type===H.LayoutAnimation){const U=((Le=n.settings)==null?void 0:Le.watchProperties)||["x","y","scale_x","scale_y","opacity","rotation"],Z=((Re=n.settings)==null?void 0:Re.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const K=this._layoutAnimCache.get(e.id);for(const ht of U){const Tt=this.getObjectProperty(s,e,ht);if(Tt===void 0)continue;const Lt=K.get(ht);if(!Lt)K.set(ht,{from:Tt,to:Tt,startTime:this.currentTime,duration:0});else if(Lt.to!==Tt){const ne=this.getObjectProperty(s,e,ht);K.set(ht,{from:ne??Lt.from,to:Tt,startTime:this.currentTime,duration:((Fe=n.settings)==null?void 0:Fe.duration)??Z})}const Wt=K.get(ht);if(Wt.duration>0&&Wt.from!==Wt.to){const ne=this.currentTime-Wt.startTime,ye=Math.min(1,ne/Wt.duration),Te=this.applyEasing(ye,((Xe=n.settings)==null?void 0:Xe.easing)||"easeOutCubic"),fe=Wt.from+(Wt.to-Wt.from)*Te;this.setObjectProperty(s,e,ht,fe)}}}else if(n.type===H.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const U=this._layoutAnimCache.get(e.id),Z=((Ht=n.settings)==null?void 0:Ht.defaultDuration)||.3,K=["x","y","scale_x","scale_y","opacity","rotation","style.fill.color","style.stroke.width","geometry.cornerRadius","style.blur.value","style.shadow.blur","style.shadow.offsetX","style.shadow.offsetY"];for(const ht of K){const Tt=this.getObjectProperty(s,e,ht);if(Tt===void 0||typeof Tt!="number")continue;const Lt=U.get(ht);if(!Lt)U.set(ht,{from:Tt,to:Tt,startTime:this.currentTime,duration:0});else if(Lt.to!==Tt){const ne=this.getObjectProperty(s,e,ht);U.set(ht,{from:ne??Lt.from,to:Tt,startTime:this.currentTime,duration:Z})}const Wt=U.get(ht);if(Wt.duration>0&&Wt.from!==Wt.to){const ne=this.currentTime-Wt.startTime,ye=Math.min(1,ne/Wt.duration),Te=this.applyEasing(ye,((ce=n.settings)==null?void 0:ce.defaultEasing)||"easeOutCubic"),fe=Wt.from+(Wt.to-Wt.from)*Te;this.setObjectProperty(s,e,ht,fe)}}}else if(n.type===H.SpringChain){const U=((Me=n.settings)==null?void 0:Me.connections)||[],Z=(($e=n.settings)==null?void 0:$e.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const K=this._springChainState.get(e.id);for(const Tt of U){if(!K.has(Tt.targetId)){const Lt=this.objectStates.get(Tt.targetId);K.set(Tt.targetId,{x:(Lt==null?void 0:Lt.x)??0,y:(Lt==null?void 0:Lt.y)??0,vx:0,vy:0})}K.has(e.id)||K.set(e.id,{x:s.x,y:s.y,vx:0,vy:0})}const ht=K.get(e.id);if(ht){ht.x=s.x,ht.y=s.y;for(const Tt of U){const Lt=K.get(Tt.targetId);if(!Lt)continue;const Wt=Lt.x-ht.x,ne=Lt.y-ht.y,ye=Math.sqrt(Wt*Wt+ne*ne)||.001,fe=(ye-(Tt.restLength||50))*(Tt.stiffness||.8),Se=Wt/ye*fe,Qe=ne/ye*fe;ht.vx+=Se*t*10,ht.vy+=Qe*t*10,Lt.vx-=Se*t*10,Lt.vy-=Qe*t*10,ht.vx*=1-Z*t*10,ht.vy*=1-Z*t*10,Lt.vx*=1-Z*t*10,Lt.vy*=1-Z*t*10;const me=this.objectStates.get(Tt.targetId);me&&(me.x+=Lt.vx*t,me.y+=Lt.vy*t)}s.x+=ht.vx*t,s.y+=ht.vy*t}}else if(n.type===H.ParticleEmitter){const U=((Be=n.settings)==null?void 0:Be.rate)||10,Z=((ge=n.settings)==null?void 0:ge.speed)||100,K=((de=n.settings)==null?void 0:de.size)||5,ht=((ue=n.settings)==null?void 0:ue.lifetime)||2,Tt=((ke=n.settings)==null?void 0:ke.gravity)||0,Lt=((De=n.settings)==null?void 0:De.color)||"#ffffff",Wt=((qe=n.settings)==null?void 0:qe.maxParticles)||200,ne=(Ke=n.settings)!=null&&Ke.rateInputId?this.inputs.get(n.settings.rateInputId)??U:U,ye=(Ge=n.settings)!=null&&Ge.gravityInputId?this.inputs.get(n.settings.gravityInputId)??Tt:Tt,Te=(Je=n.settings)!=null&&Je.speedInputId?this.inputs.get(n.settings.speedInputId)??Z:Z;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const fe=this._emitterPools.get(e.id);let Se=0;n._pendingBurst&&n._pendingBurst>0&&(Se=n._pendingBurst,n._pendingBurst=0);const Qe=Math.floor(ne*t)+(Se||0);for(let me=0;me<Math.min(Qe,Wt-fe.length);me++){const he=Math.random()*Math.PI*2,ms=Te*(.5+Math.random()*.5);fe.push({x:s.x,y:s.y,vx:Math.cos(he)*ms,vy:Math.sin(he)*ms,life:0,maxLife:ht*(.5+Math.random()*.5),size:K*(.5+Math.random()),color:Lt,opacity:1})}for(let me=fe.length-1;me>=0;me--){const he=fe[me];he.vy+=ye*t*10,he.x+=he.vx*t,he.y+=he.vy*t,he.life+=t,he.opacity=Math.max(0,1-he.life/he.maxLife),he.life>=he.maxLife&&fe.splice(me,1)}}})})}applyBehaviorSensor(t,i,o,e,s,n,a=0,r=0,f=1){var d,u,v,b,y,m,S,C,w,M,I,k,T,O,P,_,E,A,W,z,Y,G,N,J;const h=(s==null?void 0:s.intensity)||(s==null?void 0:s.strength)||1,l=Math.min(1,15*e),p=f>0?a/f:0,c=f>0?r/f:0;switch(i){case Qt.Scale:{const x=((d=n==null?void 0:n.transform)==null?void 0:d.scale_x)??1,F=((u=n==null?void 0:n.transform)==null?void 0:u.scale_y)??1,j=x*(1+o*h*.4),X=F*(1+o*h*.4);t.scale_x=(t.scale_x??x)*(1-l)+j*l,t.scale_y=(t.scale_y??F)*(1-l)+X*l;break}case Qt.Opacity:{const x=((v=n==null?void 0:n.transform)==null?void 0:v.opacity)??100,F=Math.max(0,Math.min(100,x-o*h*100));t.opacity=(t.opacity??x)*(1-l)+F*l;break}case Qt.RotateZ:{const x=((b=n==null?void 0:n.transform)==null?void 0:b.rotation)??0,F=x+o*h*45;t.rotation=(t.rotation??x)*(1-l)+F*l;break}case Qt.RotateX:{const x=((y=n==null?void 0:n.transform)==null?void 0:y.rotate_x)??0,F=x-c*o*h*60;t.rotate_x=(t.rotate_x??x)*(1-l)+F*l;break}case Qt.RotateY:{const x=((m=n==null?void 0:n.transform)==null?void 0:m.rotate_y)??0,F=x+p*o*h*60;t.rotate_y=(t.rotate_y??x)*(1-l)+F*l;break}case Qt.PositionX:{const x=((S=n==null?void 0:n.transform)==null?void 0:S.x)??0,F=x-p*o*h*40;t.x=(t.x??x)*(1-l)+F*l;break}case Qt.PositionY:{const x=((C=n==null?void 0:n.transform)==null?void 0:C.y)??0,F=x-c*o*h*40;t.y=(t.y??x)*(1-l)+F*l;break}case Qt.SkewX:{const x=((w=n==null?void 0:n.transform)==null?void 0:w.skew_x)??0,F=x+p*o*h*45;t.skew_x=(t.skew_x??x)*(1-l)+F*l,t.skew_x>85&&(t.skew_x=85),t.skew_x<-85&&(t.skew_x=-85);break}case Qt.Blur:{t.style||(t.style={...n==null?void 0:n.style}),t.style.blur||(t.style.blur={...(M=n==null?void 0:n.style)==null?void 0:M.blur});const x=((k=(I=n==null?void 0:n.style)==null?void 0:I.blur)==null?void 0:k.amount)||0,F=x+o*((s==null?void 0:s.blur)||20)*h;t.style.blur.amount=(t.style.blur.amount??x)*(1-l)+F*l;break}case Qt.Exposure:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(T=n==null?void 0:n.style)==null?void 0:T.adjustments});const x=((P=(O=n==null?void 0:n.style)==null?void 0:O.adjustments)==null?void 0:P.exposure)||0,F=x+o*((s==null?void 0:s.exposure)||50)*h;t.style.adjustments.exposure=(t.style.adjustments.exposure??x)*(1-l)+F*l;break}case Qt.HueShift:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(_=n==null?void 0:n.style)==null?void 0:_.adjustments});const x=((A=(E=n==null?void 0:n.style)==null?void 0:E.adjustments)==null?void 0:A.hue)||0,F=x+o*((s==null?void 0:s.hue)||180)*h;t.style.adjustments.hue=(t.style.adjustments.hue??x)*(1-l)+F*l;break}case Qt.Negative:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(W=n==null?void 0:n.style)==null?void 0:W.adjustments});const x=((Y=(z=n==null?void 0:n.style)==null?void 0:z.adjustments)==null?void 0:Y.negative)||0,F=x+o*((s==null?void 0:s.negative)||100)*h;t.style.adjustments.negative=(t.style.adjustments.negative??x)*(1-l)+F*l;break}case Qt.CornerRadius:{const x=((G=n==null?void 0:n.transform)==null?void 0:G.corner_radius)||0,F=x+o*h*50;t.corner_radius=(t.corner_radius??x)*(1-l)+F*l;break}case Qt.StrokeWidth:{t.style||(t.style={...n==null?void 0:n.style});const x=((N=n==null?void 0:n.style)==null?void 0:N.borderWidth)||0,F=x+o*h*10;t.style.borderWidth=(t.style.borderWidth??x)*(1-l)+F*l;break}case Qt.LetterSpacing:{t.geometry||(t.geometry={});const x=((J=n==null?void 0:n.geometry)==null?void 0:J.letterSpacing)||0,F=x+o*h*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??x)*(1-l)+F*l;break}}}getObjectProperty(t,i,o){const e=o.split(".");let s=t;for(const n of e){if(s==null||typeof s!="object")return;if(n==="style"&&t.style===void 0){s=i.style;continue}s=s[n]}return typeof s=="number"?s:void 0}setObjectProperty(t,i,o,e){const s=o.split(".");let n=t;for(let r=0;r<s.length-1;r++){const f=s[r];if(n[f]===void 0||n[f]===null){const h=i,l=s.slice(0,r+1).reduce((p,c)=>p==null?void 0:p[c],h);n[f]=l!==void 0?{...l}:{}}n=n[f]}const a=s[s.length-1];n!=null&&(n[a]=e)}applyEasing(t,i){switch(i){case"easeOutCubic":return 1-Math.pow(1-t,3);case"easeInCubic":return t*t*t;case"easeInOutCubic":return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;case"easeOutQuad":return t*(2-t);case"easeInQuad":return t*t;case"easeInOutQuad":return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2;case"easeOutExpo":return t===1?1:1-Math.pow(2,-10*t);case"easeOutBack":return 1+2.70158*Math.pow(t-1,3)+1.70158*Math.pow(t-1,2);case"easeOutElastic":{const o=2*Math.PI/3;return t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*o)+1}case"easeOutBounce":return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375;case"linear":return t;default:return 1-Math.pow(1-t,3)}}lerp(t,i,o){return t*(1-o)+i*o}deepMerge(t,i){if(!t)return i;if(!i)return t;if(typeof t!="object"||typeof i!="object"||t===null||i===null)return i;const o={...t};for(const e in i)Object.prototype.hasOwnProperty.call(i,e)&&(i[e]&&typeof i[e]=="object"&&!Array.isArray(i[e])?o[e]=this.deepMerge(t[e],i[e]):o[e]=i[e]);return o}renderFittedImage(t,i,o,e,s,n,a="cover"){const r=i.naturalWidth,f=i.naturalHeight,h=r/f,l=s/n;let p=s,c=n,d=o,u=e;a==="cover"?h>l?(p=n*h,d=o-(p-s)/2):(c=s/h,u=e-(c-n)/2):a==="contain"&&(h>l?(c=s/h,u=e+(n-c)/2):(p=n*h,d=o+(s-p)/2)),t.drawImage(i,d,u,p,c)}}const ni=xt.forwardRef(({artboard:g,src:t,style:i,autoPlay:o=!0,fit:e="Contain",alignment:s="Center",onReady:n,onTrigger:a,onInputUpdate:r,onComponentChange:f,onToggle:h,onInputChange:l,onInputFocus:p,onInputBlur:c,onLog:d,onLogicUpdate:u,onButtonClick:v,onGraphPointClick:b,currentTime:y,revision:m=0,scrollY:S,scrollX:C,mouseX:w,mouseY:M,isMouseDown:I,inputs:k,interactive:T=!0,onNavigation:O},P)=>{const _=xt.useRef(null),E=xt.useRef(null);E.current||(E.current=new ys);const A=xt.useRef(void 0),W=xt.useRef(0),z=xt.useRef(null),Y=xt.useRef(m),G=xt.useRef(null),[,N]=xt.useState(g||null),J=xt.useRef(!0);xt.useImperativeHandle(P,()=>_.current),xt.useEffect(()=>(J.current=!0,()=>{J.current=!1,A.current&&cancelAnimationFrame(A.current)}),[]),xt.useEffect(()=>{E.current.setLayout(e,s)},[e,s]),xt.useEffect(()=>{const L=E.current;a&&L.setTriggerCallback(a),r&&L.setInputUpdateCallback((R,D)=>r({[R]:D})),f&&L.setComponentChangeCallback(R=>f(R)),h&&L.setToggleCallback(h),l&&L.setInputChangeCallback(l),p&&L.setInputFocusCallback(p),c&&L.setInputBlurCallback(c),d&&L.setOnLogCallback(R=>d(R,"info")),u&&L.setLogicUpdateCallback(u),v&&L.setButtonClickCallback(v),b&&L.setGraphPointClickCallback(R=>b(R.objectId,R)),O&&L.setNavigationCallback(O)},[a,r,f,h,l,p,c,d,u,v,b,O]),xt.useEffect(()=>{(async()=>{let R=g;if(t&&!g)try{t.startsWith("{")?R=JSON.parse(t):R=await(await fetch(t)).json()}catch(D){console.error("[ExodeUI] Failed to load src:",D)}if(R){const D=E.current,q=R.id||R.name||"default";(z.current!==q||Y.current!==m||G.current!==R)&&(D.load(R),z.current=q,Y.current=m,G.current=R,N(R),W.current=0,D.advance(0)),n&&n(D)}})()},[g,t,m]),xt.useEffect(()=>{const L=R=>{if(!E.current||!J.current)return;const D=E.current,q=_.current;if(!q)return;const ot=q.getContext("2d");if(!ot)return;const mt=R/1e3;W.current===0&&(W.current=mt);let bt=mt-W.current;bt>.1&&(bt=.1),W.current=mt;const gt=q.getBoundingClientRect(),Et=window.devicePixelRatio||1,It=Math.round(gt.width*Et),vt=Math.round(gt.height*Et);(q.width!==It||q.height!==vt)&&(q.width=It,q.height=vt);try{o?D.advance(bt):y!==void 0&&D.seek(y),D.render(ot,q.width,q.height)}catch(Dt){console.error("[ExodeUICanvas] Error in animation loop:",Dt),d&&d(`[Error] Animation loop crashed: ${Dt}`,"error")}A.current=requestAnimationFrame(L)};return A.current=requestAnimationFrame(L),()=>{A.current&&cancelAnimationFrame(A.current)}},[o,y]),xt.useEffect(()=>{const L=E.current;S!==void 0&&L.updateInput("scrollY",S),C!==void 0&&L.updateInput("scrollX",C),w!==void 0&&L.updateInput("mouseX",w),M!==void 0&&L.updateInput("mouseY",M),I!==void 0&&L.updateInput("isMouseDown",I),k&&Object.entries(k).forEach(([R,D])=>L.updateInput(R,D))},[S,C,w,M,I,k]);const x=(L,R)=>{if(!T||!_.current)return;L.stopPropagation(),"nativeEvent"in L&&L.nativeEvent&&typeof L.nativeEvent.stopImmediatePropagation=="function"?L.nativeEvent.stopImmediatePropagation():typeof L.stopImmediatePropagation=="function"&&L.stopImmediatePropagation();const D=_.current,q=D.getBoundingClientRect(),ot=L.clientX-q.left,mt=L.clientY-q.top,bt=window.devicePixelRatio||1;(R==="click"||R==="down"||R==="up")&&d&&d(`[Canvas] Pointer ${R} at rect(${Math.round(ot)},${Math.round(mt)}) mapped to buffer(${Math.round(ot*bt)},${Math.round(mt*bt)})`,"info"),E.current.handlePointerInput(R,ot*bt,mt*bt,D.width,D.height)};xt.useEffect(()=>{if(!T)return;const L=D=>{var q,ot,mt;((q=document.activeElement)==null?void 0:q.tagName)==="INPUT"||((ot=document.activeElement)==null?void 0:ot.tagName)==="TEXTAREA"||(mt=E.current)==null||mt.handleKeyDown(D)},R=D=>{var q,ot,mt;((q=document.activeElement)==null?void 0:q.tagName)==="INPUT"||((ot=document.activeElement)==null?void 0:ot.tagName)==="TEXTAREA"||(mt=E.current)==null||mt.handleKeyUp(D)};return window.addEventListener("keydown",L),window.addEventListener("keyup",R),()=>{window.removeEventListener("keydown",L),window.removeEventListener("keyup",R)}},[T]);const[F,j]=xt.useState([]);xt.useEffect(()=>{if(g&&g.objects){const L=g.objects.filter(R=>{var D,q;return R.type==="Joystick"&&((D=R.inputBinding)==null?void 0:D.type)==="keyboard"&&((q=R.inputBinding.keyboardConfig)==null?void 0:q.showVirtualKeyboard)});j(L)}},[g]);const[,X]=xt.useState(0);xt.useEffect(()=>{if(F.length===0)return;let L;const R=()=>{X(D=>D+1),L=requestAnimationFrame(R)};return L=requestAnimationFrame(R),()=>cancelAnimationFrame(L)},[F.length]);const tt=()=>F.map(L=>{const R=L.inputBinding.keyboardConfig,D=gt=>{var It;const Et={key:gt,code:gt,preventDefault:()=>{}};(It=E.current)==null||It.handleKeyDown(Et)},q=gt=>{var It;const Et={key:gt,code:gt,preventDefault:()=>{}};(It=E.current)==null||It.handleKeyUp(Et)},ot=E.current,mt=gt=>ot&&ot.activeKeys?ot.activeKeys.has(gt.toLowerCase()):!1,bt=gt=>({width:"50px",height:"50px",background:gt?"rgba(255, 255, 255, 0.4)":"rgba(0, 0, 0, 0.4)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontWeight:"bold",fontSize:"18px",userSelect:"none",cursor:"pointer",backdropFilter:"blur(8px)",transition:"background 0.1s",boxShadow:gt?"none":"0 4px 6px rgba(0,0,0,0.1)"});return Xt.jsxs("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",pointerEvents:"auto",zIndex:100},children:[Xt.jsx("div",{style:bt(mt(R.upKey)),onMouseDown:()=>D(R.upKey),onMouseUp:()=>q(R.upKey),onMouseLeave:()=>q(R.upKey),onTouchStart:gt=>{gt.preventDefault(),D(R.upKey)},onTouchEnd:gt=>{gt.preventDefault(),q(R.upKey)},children:R.upKey.toUpperCase()}),Xt.jsxs("div",{style:{display:"flex",gap:"8px"},children:[Xt.jsx("div",{style:bt(mt(R.leftKey)),onMouseDown:()=>D(R.leftKey),onMouseUp:()=>q(R.leftKey),onMouseLeave:()=>q(R.leftKey),onTouchStart:gt=>{gt.preventDefault(),D(R.leftKey)},onTouchEnd:gt=>{gt.preventDefault(),q(R.leftKey)},children:R.leftKey.toUpperCase()}),Xt.jsx("div",{style:bt(mt(R.downKey)),onMouseDown:()=>D(R.downKey),onMouseUp:()=>q(R.downKey),onMouseLeave:()=>q(R.downKey),onTouchStart:gt=>{gt.preventDefault(),D(R.downKey)},onTouchEnd:gt=>{gt.preventDefault(),q(R.downKey)},children:R.downKey.toUpperCase()}),Xt.jsx("div",{style:bt(mt(R.rightKey)),onMouseDown:()=>D(R.rightKey),onMouseUp:()=>q(R.rightKey),onMouseLeave:()=>q(R.rightKey),onTouchStart:gt=>{gt.preventDefault(),D(R.rightKey)},onTouchEnd:gt=>{gt.preventDefault(),q(R.rightKey)},children:R.rightKey.toUpperCase()})]})]},L.id)});return Xt.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[Xt.jsx("canvas",{ref:_,onPointerDown:L=>{var R;x(L,"down"),(R=_.current)==null||R.focus()},onPointerMove:L=>x(L,"move"),onPointerUp:L=>x(L,"up"),onPointerCancel:L=>x(L,"up"),onClick:L=>x(L,"click"),onWheel:L=>{E.current.handleWheel(L.deltaX,L.deltaY)},onKeyDown:L=>E.current.handleKeyDown(L.nativeEvent),onKeyUp:L=>E.current.handleKeyUp(L.nativeEvent),onContextMenu:L=>L.preventDefault(),tabIndex:0,style:{...i,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:T?"auto":"none"}}),tt()]})});function oi(){const[g,t]=xt.useState(null),i=xt.useCallback((l,p)=>{g==null||g.setInputBool(l,p)},[g]),o=xt.useCallback((l,p)=>{g==null||g.setInputNumber(l,p)},[g]),e=xt.useCallback(l=>{g==null||g.fireTrigger(l)},[g]),s=xt.useCallback((l,p)=>{g==null||g.setInputText(l,p)},[g]),n=xt.useCallback((l,p)=>{g==null||g.setInputNumberArray(l,p)},[g]),a=xt.useCallback((l,p)=>{g==null||g.setInputStringArray(l,p)},[g]),r=xt.useCallback((l,p)=>{g==null||g.updateObjectOptions(l,p)},[g]),f=xt.useCallback((l,p,c)=>{g==null||g.updateConstraint(l,p,c)},[g]),h=xt.useCallback((l,p)=>{g==null||g.updateGraphData(l,p)},[g]);return{setEngine:t,engine:g,setInputBool:i,setInputNumber:o,fireTrigger:e,setInputText:s,setInputNumberArray:n,setInputStringArray:a,updateConstraint:f,updateGraphData:h,updateObjectOptions:r}}const ai=({artboard:g,config:t})=>{const i={...g.seo,...t},o=i.enableSmartExtraction!==!1;xt.useEffect(()=>{const a=i.title||g.name;a&&(document.title=a);let r=i.description;if(!r&&o){const l=g.objects.filter(p=>{var c;return((c=p.geometry)==null?void 0:c.type)==="Text"}).sort((p,c)=>{var d,u;return(((d=c.geometry.text)==null?void 0:d.length)||0)-(((u=p.geometry.text)==null?void 0:u.length)||0)});l.length>0&&(r=l[0].geometry.text)}r&&(e("name","description",r),e("property","og:description",r)),i.keywords&&i.keywords.length>0&&e("name","keywords",i.keywords.join(", "));const f=i.ogImage||g.backgroundImage;f&&e("property","og:image",f),a&&e("property","og:title",a),e("property","og:type","website")},[i,g,o]);const e=(a,r,f)=>{let h=document.querySelector(`meta[${a}="${r}"]`);h||(h=document.createElement("meta"),h.setAttribute(a,r),document.head.appendChild(h)),h.setAttribute("content",f)},s=()=>{const a=[];return a.push(Xt.jsx("h1",{children:i.title||g.name},"artboard-title")),g.objects.forEach((f,h)=>{var l,p;if(!(f.visible===!1||f.isVisible===!1))if(((l=f.geometry)==null?void 0:l.type)==="Text"){const c=f.geometry.text;c&&(f.geometry.fontSize>24?a.push(Xt.jsx("h2",{children:c},f.id||h)):a.push(Xt.jsx("p",{children:c},f.id||h)))}else if(((p=f.geometry)==null?void 0:p.type)==="Image"){const c=f.geometry.src,d=f.altText||f.name||"Illustration";a.push(Xt.jsx("img",{src:c,alt:d},f.id||h))}else f.type==="Button"&&a.push(Xt.jsx("button",{children:f.name||"Button"},f.id||h))}),a},n=i.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:i.title||g.name,description:i.description,image:i.ogImage||g.backgroundImage,abstract:"Animated interface created with ExodeUI"};return Xt.jsxs("div",{id:`exode-seo-${g.id||"default"}`,"aria-hidden":"false",style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0",zIndex:-1},children:[s(),Xt.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})]})},ri={version:"6.3.41"}.version;zt.BehaviorSensor=Qt,zt.BehaviorType=H,zt.ConditionOp=je,zt.ExodeSEO=ai,zt.ExodeUICanvas=ni,zt.ExodeUIEngine=ys,zt.LogicOp=wt,zt.RapierPhysics=is,zt.VERSION=ri,zt.useExodeUI=oi,Object.defineProperty(zt,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/index.mjs
CHANGED
|
@@ -3927,7 +3927,17 @@ class ci {
|
|
|
3927
3927
|
}
|
|
3928
3928
|
}
|
|
3929
3929
|
} else y.length > 0 && (t.setLineDash(y), t.lineDashOffset = m);
|
|
3930
|
-
(o == null ? void 0 : o.type) === "Line" || e === 0 || s === 0
|
|
3930
|
+
if ((o == null ? void 0 : o.type) === "Line" || e === 0 || s === 0)
|
|
3931
|
+
this.applyPath(t, o, e, s, n), t.stroke();
|
|
3932
|
+
else if (p === "inside")
|
|
3933
|
+
t.lineWidth = l * 2, t.save(), this.applyPath(t, o, e, s, n), t.clip(), t.stroke(), t.restore();
|
|
3934
|
+
else if (p === "outside") {
|
|
3935
|
+
t.save(), t.beginPath();
|
|
3936
|
+
const S = Math.max(e, s, 2e4);
|
|
3937
|
+
t.rect(-S, -S, S * 2, S * 2), this.applyPath(t, o, e, s, n), t.clip("evenodd"), t.lineWidth = l * 2, t.beginPath(), this.applyPath(t, o, e, s, n), t.stroke(), t.restore();
|
|
3938
|
+
} else
|
|
3939
|
+
t.lineWidth = l, this.applyPath(t, o, e, s, n), t.stroke();
|
|
3940
|
+
t.restore();
|
|
3931
3941
|
}
|
|
3932
3942
|
getPerimeter(t, i, o) {
|
|
3933
3943
|
switch (this.ensurePathPoints(t), t == null ? void 0 : t.type) {
|
|
@@ -6142,7 +6152,7 @@ const vi = ({ artboard: g, config: t }) => {
|
|
|
6142
6152
|
]
|
|
6143
6153
|
}
|
|
6144
6154
|
);
|
|
6145
|
-
}, hi = "6.3.
|
|
6155
|
+
}, hi = "6.3.41", fi = {
|
|
6146
6156
|
version: hi
|
|
6147
6157
|
}, Si = fi.version;
|
|
6148
6158
|
export {
|