exodeui 6.4.2 → 6.4.3

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 CHANGED
@@ -16,4 +16,4 @@
16
16
  `||p[ft]==="\r");if(vt&&Ot>0&&ft++,vt){if(((Yt=q.top)==null?void 0:Yt.width)>0){const Gt=j+Ot*k-q.top.offset;t.strokeStyle=q.top.color||"#000000",t.lineWidth=q.top.width,t.beginPath();const Dt=-i/2+k*.2;t.moveTo(Dt,Gt),t.lineTo(i/2-k*.2,Gt),t.stroke()}if(((zt=q.bottom)==null?void 0:zt.width)>0){const Gt=j+(Ot+1)*k-q.bottom.offset;t.strokeStyle=q.bottom.color||"#000000",t.lineWidth=q.bottom.width,t.beginPath();const Dt=-i/2+k*.2;t.moveTo(Dt,Gt),t.lineTo(i/2-k*.2,Gt),t.stroke()}}ft+=(Bt.text||"").length})}if(e.stroke&&e.stroke.width>0){const ft=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;const Ot=t.getTransform(),Pt=Math.sqrt(Ot.a*Ot.a+Ot.b*Ot.b)||1,vt=window.devicePixelRatio||1;t.lineWidth=(e.stroke.width||1)*vt/Pt,t.globalAlpha=ft*this.normalizeOpacity(e.stroke.opacity??100);let Yt=0,zt=j;(O||[]).forEach(Gt=>{let Dt=-Y/2;M==="center"?Dt=0:M==="right"&&(Dt=Y/2),N(Gt.text,Dt,zt,!0,Yt),Yt+=(Gt.text||"").length,zt+=k,Yt<p.length&&(p[Yt]===`
17
17
  `||p[Yt]==="\r")&&(P>0&&(zt+=P),Yt++,p[Yt-1]==="\r"&&p[Yt]===`
18
18
  `&&Yt++)}),t.globalAlpha=ft}}}applyStrokeAlignment(t,s,o,e,n,i){if(!s.stroke||s.stroke.width<=0||s.stroke.isEnabled===!1)return;const a=s.stroke,r=t.getTransform(),l=Math.sqrt(r.a*r.a+r.b*r.b)||1,d=window.devicePixelRatio||1,p=(a.width||1)*d/l,u=(a.alignment||"center").toLowerCase();if(t.save(),s.fill&&s.fill.type!=="None"&&s.fill.isEnabled!==!1&&s.fill.opacity!==0&&s.fill.color!=="transparent"&&s.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),a.fill){const S=this.createCanvasFill(t,a.fill,e,n);S?t.strokeStyle=S:t.strokeStyle=a.color||"#000000"}else t.strokeStyle=a.color||"#000000";const h=t.globalAlpha;t.globalAlpha=h*this.normalizeOpacity(a.opacity??100),t.lineWidth=p,t.lineCap=a.lineCap||"round",t.lineJoin=a.lineJoin||"round",a.miterLimit!==void 0&&(t.miterLimit=a.miterLimit);const f=a.trimStart??0,v=a.trimEnd??1,g=a.trimOffset??0,c=a.dashOffset??0,b=a.dashArray||[];if(f!==0||v!==1||g!==0){const S=this.getPerimeter(o,e,n);if(S>0){const w=Math.max(0,Math.min(1,f)),C=Math.max(0,Math.min(1,v));if(w<C){const M=S*(C-w),I=S-M,_=-(S*(w+g%1));t.setLineDash([M,I]),t.lineDashOffset=_-c*S}else if(w===C)t.setLineDash([0,S]);else{const M=S*(1-w+C),I=S-M,_=-(S*w);t.setLineDash([M,I]),t.lineDashOffset=_-c*S}}}else if(b.length>0||c!==0){b.length>0&&t.setLineDash(b);const S=this.getPerimeter(o,e,n);t.lineDashOffset=-(c*S)}if((o==null?void 0:o.type)==="Line"||e===0||n===0)this.applyPath(t,o,e,n,i),t.stroke();else if(u==="inside")t.lineWidth=p*2,t.save(),this.applyPath(t,o,e,n,i),t.clip(),t.stroke(),t.restore();else if(u==="outside"){t.save(),t.beginPath();const S=Math.max(e,n,2e4);t.rect(-S,-S,S*2,S*2),this._tracePath(t,o,e,n,i),t.clip("evenodd"),t.lineWidth=p*2,t.beginPath(),this.applyPath(t,o,e,n,i),t.stroke(),t.restore()}else t.lineWidth=p,this.applyPath(t,o,e,n,i),t.stroke();t.restore()}getPerimeter(t,s,o){switch(this.ensurePathPoints(t),t==null?void 0:t.type){case"Rectangle":return(s+o)*2;case"Ellipse":{const e=Math.abs(s)/2,n=Math.abs(o)/2,i=Math.abs(t.sweepAngle??360),a=t.ratio||0,r=Math.PI*(3*(e+n)-Math.sqrt((3*e+n)*(e+3*n)));if(i>=360&&a<=0)return r;let l=i/360*r;if(a>0){const d=Math.PI*(3*(e*a+n*a)-Math.sqrt((3*e*a+n*a)*(e*a+3*n*a)));l+=i/360*d,i<360&&(l+=2*Math.sqrt((e-e*a)**2+(n-n*a)**2))}else i<360&&(l+=2*Math.max(e,n));return isNaN(l)?0:l}case"Line":return t.length||Math.sqrt(s*s+o*o);case"Triangle":return s+Math.sqrt((s/2)**2+o**2)*2;case"Polygon":{const e=t.sides||3,n=t.radius||Math.min(s,o)/2;return 2*e*n*Math.sin(Math.PI/e)}case"Star":{const e=t.points||5,n=t.outer_radius||Math.min(s,o)/2,i=t.inner_radius||n/2,a=Math.PI/e;return Math.sqrt(n*n+i*i-2*n*i*Math.cos(a))*e*2}case"Path":{const e=t.points||[];if(e.length<2)return t.length||0;let n=0,i=e[0].x,a=e[0].y;for(let r=1;r<e.length;r++){const l=e[r];if(l.moveTo){i=l.x,a=l.y;continue}const d=i,p=a,u=e[r-1].out_x,m=e[r-1].out_y;if(u!==void 0||l.in_x!==void 0?n+=this.getBezierLength(d,p,u??d,m??p,l.in_x??l.x,l.in_y??l.y,l.x,l.y):n+=Math.sqrt((l.x-d)**2+(l.y-p)**2),i=l.x,a=l.y,l.closePath||r===e.length-1&&(t.is_closed||t.isClosed)){const h=i,f=a,v=[...e.slice(0,r+1)].reverse().find(M=>M.moveTo)||e[0],g=v.x,c=v.y,b=e[r].out_x,S=e[r].out_y,w=v.in_x,C=v.in_y;b!==void 0||w!==void 0?n+=this.getBezierLength(h,f,b??h,S??f,w??g,C??c,g,c):n+=Math.sqrt((g-h)**2+(c-f)**2)}}return n}default:return(s+o)*2}}getBezierLength(t,s,o,e,n,i,a,r,l=10){let d=0,p=t,u=s;for(let m=1;m<=l;m++){const h=m/l,f=1-h,v=h*h,g=f*f,c=g*f,b=v*h,S=c*t+3*g*h*o+3*f*v*n+b*a,w=c*s+3*g*h*e+3*f*v*i+b*r,C=S-p,M=w-u;d+=Math.sqrt(C*C+M*M),p=S,u=w}return d}getBezierTAtLength(t,s,o,e,n,i,a,r,l,d=20){if(t<=0)return 0;let p=0,u=s,m=o;for(let h=1;h<=d;h++){const f=h/d,v=1-f,g=f*f,c=v*v,b=c*v,S=g*f,w=b*s+3*c*f*e+3*v*g*i+S*r,C=b*o+3*c*f*n+3*v*g*a+S*l,M=w-u,I=C-m,_=Math.sqrt(M*M+I*I);if(p+_>=t){const E=t-p,P=_===0?0:E/_;return(h-1+P)/d}p+=_,u=w,m=C}return 1}getPointOnPath(t,s,o,e){if(this.ensurePathPoints(t),(t==null?void 0:t.type)==="Path"){const n=t.points||[];if(n.length<2)return{x:0,y:0,angle:0};let i=1/0,a=-1/0,r=1/0,l=-1/0;n.forEach(c=>{typeof c.x=="number"&&typeof c.y=="number"&&(i=Math.min(i,c.x),a=Math.max(a,c.x),r=Math.min(r,c.y),l=Math.max(l,c.y),c.out_x!==void 0&&(i=Math.min(i,c.out_x),a=Math.max(a,c.out_x)),c.out_y!==void 0&&(r=Math.min(r,c.out_y),l=Math.max(l,c.out_y)),c.in_x!==void 0&&(i=Math.min(i,c.in_x),a=Math.max(a,c.in_x)),c.in_y!==void 0&&(r=Math.min(r,c.in_y),l=Math.max(l,c.in_y)))});const d=(i+a)/2,p=(r+l)/2,m=this.getPerimeter(t,s,o)*e;let h=0;const f=[];let v=n[0],g=n[0];for(let c=1;c<n.length;c++){const b=n[c];if(b.moveTo){v=b,g=b;continue}f.push({p0:v,p1:b}),(b.closePath||c===n.length-1&&(t.is_closed||t.isClosed))&&f.push({p0:b,p1:g}),v=b}for(const c of f){const b=c.p0,S=c.p1;let w=0;const C=b.out_x!==void 0||S.in_x!==void 0;if(C?w=this.getBezierLength(b.x,b.y,b.out_x??b.x,b.out_y??b.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y):w=Math.sqrt((S.x-b.x)**2+(S.y-b.y)**2),h+w>=m||c===f[f.length-1]){let M=0;if(C)return M=this.getBezierTAtLength(m-h,b.x,b.y,b.out_x??b.x,b.out_y??b.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y,20),this.getBezierPointAndAngle(M,b,S,d,p);{M=w===0?0:(m-h)/w;const I=b.x+(S.x-b.x)*M-d,_=b.y+(S.y-b.y)*M-p,E=Math.atan2(S.y-b.y,S.x-b.x);return{x:I,y:_,angle:E}}}h+=w}}else if(t.type==="Ellipse"){const n=Math.abs(s)/2,i=Math.abs(o)/2,a=t.sweepAngle??360,l=((t.startAngle??0)+a*e)*Math.PI/180,d=n*Math.cos(l),p=i*Math.sin(l),u=-n*Math.sin(l),m=i*Math.cos(l),h=Math.atan2(m,u);return{x:d,y:p,angle:h}}else if((t==null?void 0:t.type)==="Rectangle"){const n=Math.abs(s),i=Math.abs(o),r=(n+i)*2*e;let l=0,d=0,p=0;return r<n?(l=-n/2+r,d=-i/2,p=0):r<n+i?(l=n/2,d=-i/2+(r-n),p=Math.PI/2):r<2*n+i?(l=n/2-(r-(n+i)),d=i/2,p=Math.PI):(l=-n/2,d=i/2-(r-(2*n+i)),p=-Math.PI/2),{x:l,y:d,angle:p}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(t,s,o,e,n){const i=s.x,a=s.y,r=s.out_x??s.x,l=s.out_y??s.y,d=o.in_x??o.x,p=o.in_y??o.y,u=o.x,m=o.y,h=1-t,f=t*t,v=h*h,g=v*h,c=f*t,b=g*i+3*v*t*r+3*h*f*d+c*u-e,S=g*a+3*v*t*l+3*h*f*p+c*m-n,w=3*v*(r-i)+6*h*t*(d-r)+3*f*(u-d),C=3*v*(l-a)+6*h*t*(p-l)+3*f*(m-p),M=Math.atan2(C,w);return{x:b,y:S,angle:M}}applyAbsoluteTransform(t,s,o){if(!o.get(s))return;const n=[];let i=s;for(;i;){n.unshift(i);const a=o.get(i);i=a==null?void 0:a.parentId}n.forEach(a=>{this.applyObjectTransform(t,a)})}applyObjectTransform(t,s){var h,f,v;const o=this.objectStates.get(s);if(!o)return;t.translate(o.x,o.y),t.rotate((o.rotation??0)*Math.PI/180);const e=o.skew_x||0,n=o.skew_y||0;if(e!==0||n!==0){const g=Math.tan(e*Math.PI/180),c=Math.tan(n*Math.PI/180);t.transform(1+g*c,c,g,1,0,0)}const i=o.rotate_x!==void 0?o.rotate_x:((h=o.transform)==null?void 0:h.rotate_x)??0,a=o.rotate_y!==void 0?o.rotate_y:((f=o.transform)==null?void 0:f.rotate_y)??0,l=1+(o.translate_z!==void 0?o.translate_z:((v=o.transform)==null?void 0:v.translate_z)??0)/1e3,d=(o.flip_x===!0?-1:1)*Math.cos(a*Math.PI/180)*l,p=(o.flip_y===!0?-1:1)*Math.cos(i*Math.PI/180)*l,u=(o.scale_x??1)*d,m=(o.scale_y??1)*p;t.scale(u,m)}applyInnerGlowOverlay(t,s,o,e,n,i,a){var g,c;const r=a||s.style||{},l=r==null?void 0:r.effect,p=((r==null?void 0:r.effects)||(l?[l]:[])).find(b=>b.isEnabled!==!1&&b.type==="Glow"&&(b.mode==="inner"||b.mode==="Inner Glow"));if(!p)return;t.save(),t.beginPath(),this.applyPath(t,o,e,n,i),t.clip();const u=p.blur||10,m=1e4,h=t.getTransform();let f=p.color||"white";(c=(g=this.artboard)==null?void 0:g.tokens)!=null&&c.colors&&this.artboard.tokens.colors[f]&&(f=this.artboard.tokens.colors[f]),t.shadowColor=f,t.shadowBlur=u,t.shadowOffsetX=m*h.a,t.shadowOffsetY=m*h.b,t.translate(-m,0),t.lineWidth=u+5,t.strokeStyle=f;const v=Math.min(p.intensity||1,5);for(let b=0;b<v;b++)t.beginPath(),this.applyPath(t,o,e,n,i),t.stroke();t.restore()}applyArtEffectOverlay(t,s,o,e,n,i){var m,h,f,v,g;const a=this.objectStates.get(s.id),r=((m=a==null?void 0:a.style)==null?void 0:m.artEffect)||s.artEffect||((h=s.style)==null?void 0:h.artEffect);if(!r||!r.enabled)return;const l=r.type,d=r.intensity??.5,p=r.speed??1,u=r.scale??10;if(l==="acid_gradient"||l==="acid_rave"||l==="shimmer"||l==="glint_overlay"||l==="halftone"||l==="noise"||l==="scanlines"||l==="chromatic_aberration"||l==="pixelate"||l==="glitch"||l==="fold_overlay"||l==="crumple_overlay"){if(t.save(),this.applyPath(t,o,e,n,i),t.clip(),l==="shimmer"){const b=this.currentTime*p%2/2,S=t.createLinearGradient(-e,-n,e,n);S.addColorStop(Math.max(0,b-.2),"rgba(255,255,255,0)"),S.addColorStop(b,`rgba(255,255,255,${d*.8})`),S.addColorStop(Math.min(1,b+.2),"rgba(255,255,255,0)"),t.fillStyle=S,t.globalCompositeOperation="screen",t.fillRect(-e/2,-n/2,e,n),t.globalCompositeOperation="source-over"}else if(l==="glint_overlay"){let S=((this._lastPointerPos||{x:0}).x-(((f=s.transform)==null?void 0:f.x)??0)+300)/600;S=Math.max(-.2,Math.min(1.2,S));const w=t.createLinearGradient(-e,-n,e,n);w.addColorStop(Math.max(0,S-.15),"rgba(255,255,255,0)"),w.addColorStop(Math.max(0,Math.min(1,S)),`rgba(255,255,255,${d})`),w.addColorStop(Math.min(1,S+.15),"rgba(255,255,255,0)"),t.fillStyle=w,t.globalCompositeOperation="screen",t.fillRect(-e/2,-n/2,e,n),t.globalCompositeOperation="source-over"}else if(l==="fold_overlay"){const c=this._lastPointerPos||{x:0,y:0},b=c.x-(((v=s.transform)==null?void 0:v.x)??0),S=c.y-(((g=s.transform)==null?void 0:g.y)??0),w=t.createLinearGradient(b>0?-e/2:e/2,S>0?-n/2:n/2,b>0?e/2:-e/2,S>0?n/2:-n/2);w.addColorStop(0,`rgba(0,0,0,${d*.6})`),w.addColorStop(.4,"rgba(0,0,0,0)"),w.addColorStop(.5,`rgba(255,255,255,${d*.4})`),w.addColorStop(1,`rgba(0,0,0,${d*.2})`),t.fillStyle=w,t.globalCompositeOperation="overlay",t.fillRect(-e/2,-n/2,e,n),t.globalCompositeOperation="source-over",t.beginPath(),b>0&&S>0?(t.moveTo(e/2-40,n/2),t.lineTo(e/2,n/2-40),t.lineTo(e/2-40,n/2-40)):b<0&&S>0?(t.moveTo(-e/2+40,n/2),t.lineTo(-e/2,n/2-40),t.lineTo(-e/2+40,n/2-40)):b>0&&S<0?(t.moveTo(e/2-40,-n/2),t.lineTo(e/2,-n/2+40),t.lineTo(e/2-40,-n/2+40)):(t.moveTo(-e/2+40,-n/2),t.lineTo(-e/2,-n/2+40),t.lineTo(-e/2+40,-n/2+40)),t.closePath(),t.fillStyle="#ffffff",t.shadowColor="rgba(0,0,0,0.5)",t.shadowBlur=10,t.shadowOffsetX=b>0?-2:2,t.shadowOffsetY=S>0?-2:2,t.fill()}else if(l==="crumple_overlay"){const c=Math.floor(e/u),b=document.createElement("canvas");b.width=c,b.height=Math.floor(n/u);const S=b.getContext("2d"),w=S.createImageData(b.width,b.height);for(let C=0;C<w.data.length;C+=4){const M=Math.random()>.95?150:255;w.data[C]=M,w.data[C+1]=M,w.data[C+2]=M,w.data[C+3]=255*d}S.putImageData(w,0,0),t.globalCompositeOperation="multiply",t.imageSmoothingEnabled=!1,t.drawImage(b,-e/2,-n/2,e,n)}else if(l==="acid_gradient"||l==="acid_rave"){const c=this.currentTime*p,b=r.color1,S=r.color2,w=t.createLinearGradient(-e/2,-n/2,e/2,n/2);if(b&&S){const C=c*60%360;w.addColorStop(0,this._shiftHue(b,C,d*.7)),w.addColorStop(1,this._shiftHue(S,(C+180)%360,d*.7))}else{const C=c*100%360,M=(C+180)%360;w.addColorStop(0,`hsla(${C}, 80%, 50%, ${d*.5})`),w.addColorStop(1,`hsla(${M}, 80%, 50%, ${d*.5})`)}t.fillStyle=w,t.globalCompositeOperation="screen",t.fillRect(-e/2,-n/2,e,n)}else if(l==="halftone"){const c=Math.max(2,u*(1-d*.8)),b=document.createElement("canvas");b.width=c,b.height=c;const S=b.getContext("2d");if(S){S.fillStyle="black",S.beginPath(),S.arc(c/2,c/2,c/2*d,0,Math.PI*2),S.fill();const w=t.createPattern(b,"repeat");w&&(t.globalAlpha=.3*d,t.fillStyle=w,t.fillRect(-e/2,-n/2,e,n))}}else if(l==="noise"){const c=Math.floor(e*n*d*.02);t.globalAlpha=.4*d;for(let b=0;b<c;b++){const S=Math.random()>.5?255:0;t.fillStyle=`rgba(${S}, ${S}, ${S}, ${.5+Math.random()*.5})`,t.fillRect(-e/2+Math.random()*e,-n/2+Math.random()*n,2,2)}}else if(l==="scanlines"){t.globalAlpha=.2*d,t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1;for(let c=-n/2;c<n/2;c+=4)t.beginPath(),t.moveTo(-e/2,c),t.lineTo(e/2,c),t.stroke()}else if(l==="chromatic_aberration"){const c=5*d;t.globalCompositeOperation="screen",t.globalAlpha=.5,t.fillStyle="cyan",t.fillRect(-e/2-c,-n/2,e,n),t.fillStyle="magenta",t.fillRect(-e/2+c,-n/2,e,n)}else if(l==="pixelate"){const c=Math.max(2,Math.round(u*(1-d*.5))),b=document.createElement("canvas"),S=Math.max(1,Math.ceil(e/c)),w=Math.max(1,Math.ceil(n/c));b.width=S,b.height=w;const C=b.getContext("2d");if(C){C.imageSmoothingEnabled=!1;const M=t.getTransform(),I=M.e-e/2,_=M.f-n/2;C.drawImage(t.canvas,I,_,e,n,0,0,S,w),t.imageSmoothingEnabled=!1,t.drawImage(b,0,0,S,w,-e/2,-n/2,e,n),t.imageSmoothingEnabled=!0}}else if(l==="glitch"){const c=this.currentTime*p,b=r.chaosAmount??.2,S=Math.max(3,Math.floor(8*d)),w=d*e*.15;t.globalCompositeOperation="screen",t.globalAlpha=d*.4;const C=w*.3;t.fillStyle="rgba(255, 0, 0, 0.4)",t.fillRect(-e/2+C,-n/2,e,n),t.fillStyle="rgba(0, 255, 255, 0.4)",t.fillRect(-e/2-C,-n/2,e,n),t.globalCompositeOperation="source-over",t.globalAlpha=1;const M=n/S;for(let I=0;I<S;I++){const _=Math.sin(I*127.1+c*311.7*p)*43758.5,E=_-Math.floor(_);if(E>1-b){const P=(E-(1-b))/b*w*(Math.random()>.5?1:-1),L=-n/2+I*M,k=t.getTransform(),A=k.e-e/2+P,T=k.f+L;t.save(),t.beginPath(),t.rect(-e/2,L,e,M),t.clip(),t.globalAlpha=.8,t.drawImage(t.canvas,A,T,e,M,-e/2+P,L,e,M),t.restore()}}}t.restore()}}_shiftHue(t,s,o){let e=0,n=0,i=0;if(t.startsWith("#")){const m=t.replace("#","");e=parseInt(m.substring(0,2),16)/255,n=parseInt(m.substring(2,4),16)/255,i=parseInt(m.substring(4,6),16)/255}const a=Math.max(e,n,i),r=Math.min(e,n,i);let l=0,d=0,p=(a+r)/2;if(a!==r){const m=a-r;switch(d=p>.5?m/(2-a-r):m/(a+r),a){case e:l=((n-i)/m+(n<i?6:0))/6;break;case n:l=((i-e)/m+2)/6;break;case i:l=((e-n)/m+4)/6;break}}return`hsla(${(((l*360+s)%360+360)%360).toFixed(0)}, ${(d*100).toFixed(0)}%, ${(p*100).toFixed(0)}%, ${o})`}applyBackgroundBlurGlass(t,s,o,e,n,i,a){const r=i.radius??10,l=i.opacity!==void 0?this.normalizeOpacity(i.opacity):.5,d=i.noise??0,p=i.color??"rgba(255,255,255,0.2)";t.save(),this.applyPath(t,s,o,e,n),t.clip();const u=t.getTransform(),m=t.canvas;try{const v=document.createElement("canvas");v.width=Math.max(1,Math.ceil(o)),v.height=Math.max(1,Math.ceil(e));const g=v.getContext("2d");if(g){g.save(),g.translate(o/2,e/2);const c=i.magnification||1;if(c!==1&&g.scale(c,c),typeof u.inverse=="function"){const w=u.inverse();g.transform(w.a,w.b,w.c,w.d,w.e,w.f)}else{const w=u.a*u.d-u.b*u.c;w!==0&&g.transform(u.d/w,-u.b/w,-u.c/w,u.a/w,(u.c*u.f-u.d*u.e)/w,(u.b*u.e-u.a*u.f)/w)}g.drawImage(m,0,0),g.restore();const b=document.createElement("canvas");b.width=v.width,b.height=v.height;const S=b.getContext("2d");S.filter=`blur(${r}px)`,S.drawImage(v,0,0),t.globalCompositeOperation="destination-out",t.fillRect(-o/2,-e/2,o,e),t.globalCompositeOperation="source-over",t.globalAlpha=1,t.drawImage(b,-o/2,-e/2,o,e)}}catch(v){console.error("Background blur failed:",v)}t.globalCompositeOperation="source-over",t.globalAlpha=l,t.fillStyle=p,t.fillRect(-o/2,-e/2,o,e),t.globalAlpha=1;const h=t.createLinearGradient(-o/2,-e/2,o/2,e/2);if(h.addColorStop(0,"rgba(255,255,255,0.12)"),h.addColorStop(.3,"rgba(255,255,255,0.04)"),h.addColorStop(.5,"rgba(255,255,255,0.0)"),h.addColorStop(1,"rgba(255,255,255,0.0)"),t.fillStyle=h,t.fillRect(-o/2,-e/2,o,e),d>0){if(t.globalAlpha=d/100,!this._noiseTileCanvas){const g=document.createElement("canvas");g.width=64,g.height=64;const c=g.getContext("2d"),b=c.createImageData(64,64),S=b.data;for(let w=0;w<S.length;w+=4){const C=Math.floor(Math.random()*255);S[w]=C,S[w+1]=C,S[w+2]=C,S[w+3]=18}c.putImageData(b,0,0),this._noiseTileCanvas=g}const v=t.createPattern(this._noiseTileCanvas,"repeat");v&&(t.fillStyle=v,t.fillRect(-o/2,-e/2,o,e))}t.restore(),t.save(),t.globalAlpha=1,(a==null?void 0:a.stroke)&&a.stroke.width>0&&a.stroke.isEnabled!==!1?(this.applyPath(t,s,o,e,n),this.applyStrokeAlignment(t,a,s,o,e,n)):(t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1.5,this.applyPath(t,s,o,e,n),t.stroke()),t.restore()}applyPath(t,s,o,e,n){s!=null&&s.data&&(s.type==="Path"||s.type==="Subtract"||s.type==="Union"||s.type==="Intersect"||s.type==="Exclude"||s.type),t.beginPath(),this._tracePath(t,s,o,e,n)}_tracePath(t,s,o,e,n){if(s){if(this.ensurePathPoints(s),(s==null?void 0:s.type)==="Rectangle"||s.type==="Image"){const i=n!==void 0?n:s.corner_radius??0;this.drawRoundRect(t,-o/2,-e/2,o,e,i)}else if(s.type==="Line")t.moveTo(-o/2,0),t.lineTo(o/2,0);else if(s.type==="Ellipse"||s.type==="circle"){const{startAngle:i=0,sweepAngle:a=360,ratio:r=0}=s,l=o/2,d=e/2,p=i*Math.PI/180,u=a*Math.PI/180,m=p+u;a>=360&&r<=0?t.ellipse(0,0,l,d,0,0,Math.PI*2):(t.ellipse(0,0,l,d,0,p,m,!1),r>0?t.ellipse(0,0,l*r,d*r,0,m,p,!0):t.lineTo(0,0),t.closePath())}else if(s.type==="Triangle")t.moveTo(0,-e/2),t.lineTo(o/2,e/2),t.lineTo(-o/2,e/2),t.closePath();else if(s.type==="Polygon"){const i=s.sides||3,a=s.radius||Math.min(o,e)/2;for(let r=0;r<i;r++){const l=r*2*Math.PI/i-Math.PI/2,d=a*Math.cos(l),p=a*Math.sin(l);r===0?t.moveTo(d,p):t.lineTo(d,p)}t.closePath()}else if(s.type==="Star"){const i=s.points||5,a=s.outer_radius||Math.min(o,e)/2;let r=s.inner_radius;r==null?r=a*.382:r<=1&&(r=a*r);for(let l=0;l<i*2;l++){const d=l*Math.PI/i-Math.PI/2,p=l%2===0?a:r,u=p*Math.cos(d),m=p*Math.sin(d);l===0?t.moveTo(u,m):t.lineTo(u,m)}t.closePath()}else if(((s==null?void 0:s.type)==="Path"||s.type==="Subtract"||s.type==="Union"||s.type==="Intersect"||s.type==="Exclude"||s.type==="BooleanOperation")&&s.points){this.frameCount%300===0&&this.log("[Engine] Tracing Path:",s.points.length,"points");let i=1/0,a=-1/0,r=1/0,l=-1/0;if(s.points.forEach(u=>{typeof u.x=="number"&&typeof u.y=="number"&&(i=Math.min(i,u.x),a=Math.max(a,u.x),r=Math.min(r,u.y),l=Math.max(l,u.y),u.out_x!==void 0&&(i=Math.min(i,u.out_x),a=Math.max(a,u.out_x)),u.out_y!==void 0&&(r=Math.min(r,u.out_y),l=Math.max(l,u.out_y)),u.in_x!==void 0&&(i=Math.min(i,u.in_x),a=Math.max(a,u.in_x)),u.in_y!==void 0&&(r=Math.min(r,u.in_y),l=Math.max(l,u.in_y)))}),i===1/0)return;let d=(i+a)/2,p=(r+l)/2;if(isNaN(d)||isNaN(p)){this.warn("[Engine] Invalid path center:",d,p);return}s.points.forEach((u,m)=>{if(m===0||u.moveTo)t.moveTo(u.x-d,u.y-p);else{const h=s.points[m-1];if(!h)return;const f=(h.out_x??h.x)-d,v=(h.out_y??h.y)-p,g=(u.in_x??u.x)-d,c=(u.in_y??u.y)-p;isNaN(f)||isNaN(g)||isNaN(u.x)?t.lineTo(u.x-d,u.y-p):t.bezierCurveTo(f,v,g,c,u.x-d,u.y-p)}if(u.closePath||m===s.points.length-1&&(s.is_closed||s.isClosed)){const h=[...s.points.slice(0,m+1)].reverse().find(f=>f.moveTo)||s.points[0];h&&(u.out_x!==void 0||h.in_x!==void 0)&&t.bezierCurveTo((u.out_x??u.x)-d,(u.out_y??u.y)-p,(h.in_x??h.x)-d,(h.in_y??h.y)-p,h.x-d,h.y-p),t.closePath()}})}else if(s.points&&Array.isArray(s.points)){let i=1/0,a=-1/0,r=1/0,l=-1/0;s.points.forEach(u=>{i=Math.min(i,u.x),a=Math.max(a,u.x),r=Math.min(r,u.y),l=Math.max(l,u.y)});const d=(i+a)/2,p=(r+l)/2;s.points.forEach((u,m)=>{if(m===0)t.moveTo(u.x-d,u.y-p);else{const h=s.points[m-1];h.out_x!==void 0||u.in_x!==void 0?t.bezierCurveTo((h.out_x??h.x)-d,(h.out_y??h.y)-p,(u.in_x??u.x)-d,(u.in_y??u.y)-p,u.x-d,u.y-p):t.lineTo(u.x-d,u.y-p)}(u.closePath||m===s.points.length-1&&(s.is_closed||s.isClosed))&&t.closePath()})}}}renderInputBox(t,s){var zt,Gt,Dt,te,ie,ce,ve,_e,ge,Ee,Zt,Me,Re,Ie,de,me,Ae,he;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=s.geometry||{},i=s.style||{},a=n.width||250,r=n.height||45,l=this.focusedId===s.id,d=this.lastHoveredObjectId===s.id,p=e.previewState||"default",u=p!=="default"?p:l?"focused":d?"hovered":"default",m=e.label||{visible:!0,text:"Label"},h=e.helperText||{visible:!1,text:"Helper text"},f=e.leftIcon||{visible:!1},v=e.rightIcon||{visible:!1},g=e.inputType==="textarea"||e.multiline===!0,c=u==="disabled",b=u==="error",S=n.corner_radius??n.cornerRadius,w=Array.isArray(S)?{tl:S[0],tr:S[1],br:S[2],bl:S[3]}:S&&typeof S=="object"?S:void 0,C=Number(e.cornerRadius??e.corner_radius??S??e.radius??8),M=e.corners??w??{tl:C,tr:C,bl:C,br:C},I=[Number(M.tl??C),Number(M.tr??C),Number(M.br??C),Number(M.bl??C)],_=(mt,rt,z,K,G,x=0)=>{const Q=Math.max(0,z-x*2),H=Math.max(0,K-x*2);let[lt,kt,At,Ht]=G.map(qt=>Math.max(0,(Number(qt)||0)-x));const Ut=Math.min(Q,H)/2;lt=Math.min(lt,Ut),kt=Math.min(kt,Ut),At=Math.min(At,Ut),Ht=Math.min(Ht,Ut),t.beginPath(),t.roundRect?t.roundRect(mt+x,rt+x,Q,H,[lt,kt,At,Ht]):(t.moveTo(mt+x+lt,rt+x),t.lineTo(mt+x+Q-kt,rt+x),t.arcTo(mt+x+Q,rt+x,mt+x+Q,rt+x+kt,kt),t.lineTo(mt+x+Q,rt+x+H-At),t.arcTo(mt+x+Q,rt+x+H,mt+x+Q-At,rt+x+H,At),t.lineTo(mt+x+Ht,rt+x+H),t.arcTo(mt+x,rt+x+H,mt+x,rt+x+H-Ht,Ht),t.lineTo(mt+x+lt,rt+x),t.arcTo(mt+x,rt+x,mt+x+lt,rt+x,lt),t.closePath())};let E=e.backgroundColor||((zt=i.fill)==null?void 0:zt.color)||"rgba(31, 41, 55, 1)",P=e.borderColor||((Dt=(Gt=i.stroke)==null?void 0:Gt.fill)==null?void 0:Dt.color)||((te=i.stroke)==null?void 0:te.color)||"rgba(55, 65, 81, 1)",L=Number(e.borderWidth??((ie=i.stroke)==null?void 0:ie.width)??1),k=e.color||((ce=i.fill)==null?void 0:ce.color)||"#ffffff",A=e.placeholderColor||"rgba(156, 163, 175, 1)",T=e.fontSize||14,R=e.caretColor||"#3b82f6";const F=`${u}Style`,O=e[F];O?(O.backgroundColor!==void 0&&(E=O.backgroundColor),O.borderColor!==void 0&&(P=O.borderColor),O.borderWidth!==void 0&&(L=O.borderWidth),O.color!==void 0&&(k=O.color),O.placeholderColor!==void 0&&(A=O.placeholderColor),O.fontSize!==void 0&&(T=O.fontSize),O.caretColor!==void 0&&(R=O.caretColor)):u==="focused"?(P=e.focusBorderColor||"rgba(59, 130, 246, 1)",L=Math.max(L,2)):u==="hovered"||u==="hover"?(P=e.hoverBorderColor||P,E=e.hoverBackgroundColor||E):c?(E=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",P=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):b&&(P="rgba(239, 68, 68, 1)",L=Math.max(L,2));const W=L>0?L/2:0,V=this.createCanvasFill(t,E,a,r);if(V&&E!=="transparent"&&(_(-a/2,-r/2,a,r,I,W),t.fillStyle=V,t.fill()),L>0){const mt=this.createCanvasFill(t,P,a,r);mt&&P!=="transparent"&&(_(-a/2,-r/2,a,r,I,W),t.strokeStyle=mt,t.lineWidth=L,t.lineCap="round",t.lineJoin="round",t.stroke())}if((u==="focused"||u==="focus")&&!c){t.save();const mt=-3,rt=I.map(G=>Math.max(0,G+3));_(-a/2+mt,-r/2+mt,a-mt*2,r-mt*2,rt);const z=((ve=e.activeStyle)==null?void 0:ve.borderColor)||R||"rgba(59, 130, 246, 0.4)",K=this.createCanvasFill(t,z,a,r)||"rgba(59, 130, 246, 0.4)";t.strokeStyle=K,t.lineWidth=2,t.lineCap="round",t.lineJoin="round",t.stroke(),t.restore()}const U=e.fontFamily||"Inter",D=e.fontWeight||400,Y=T,ot=e.inputType==="number"&&((_e=e.number)==null?void 0:_e.showSteppers)!==!1,J=24,at=ot?J+4:0,j=String(e.text??e.value??"");let it="Enter text...";if(e.inputType==="tel")it=`${((ge=e.tel)==null?void 0:ge.dialCode)||"+1"} (555) 000-0000`;else if(e.inputType==="number"){const mt=(Ee=e.number)!=null&&Ee.prefix?`${e.number.prefix} `:"",rt=(Zt=e.number)!=null&&Zt.suffix?` ${e.number.suffix}`:"";it=`${mt}0.00${rt}`}else e.inputType==="email"?it="user@example.com":e.inputType==="search"?it="Search anything...":e.inputType==="url"?it="https://example.com":e.inputType==="password"?it="••••••••":e.inputType==="textarea"&&(it="Enter text...");const B=e.placeholder||it,X=!j,N=e.inputType==="password",ct=v.mode==="password-toggle"||N&&v.visible!==!1,Mt=v.mode==="clear"||e.inputType==="search"&&!!j,bt=(mt,rt)=>{var lt;let z=mt.svgPath||"";if(z||(rt?e.inputType==="search"&&(z="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"):ct?z=e.passwordVisible?"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24M1 1l22 22":"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z M12 9a3 3 0 100 6 3 3 0 000-6z":Mt&&(z="M18 6L6 18M6 6l12 12")),!(mt.visible||!!z&&(!rt&&(ct||Mt)||rt&&e.inputType==="search"))||!z)return;const G=mt.size||16,x=(mt.offset??16)+(rt?0:at),Q=typeof mt.color=="string"?mt.color:((lt=mt.color)==null?void 0:lt.color)||"#9ca3af",H=rt?-(a/2)+x:a/2-x;if(t.save(),t.translate(H,0),!z.startsWith("<svg")){const kt=new Path2D(z),At=G/24;t.scale(At,At),t.translate(-12,-12),z.includes("M18 6L6 18")||z.includes("M1 1l22 22")||z.includes("M21 21")?(t.strokeStyle=Q,t.lineWidth=2,t.lineCap="round",t.stroke(kt)):(t.fillStyle=Q,t.fill(kt))}t.restore()};if(bt(f,!0),bt(v,!1),ot){const mt=a/2-J-4;t.save(),t.strokeStyle=P||"rgba(55, 65, 81, 0.5)",t.lineWidth=1,t.beginPath(),t.moveTo(mt,-r/2+6),t.lineTo(mt,r/2-6),t.stroke(),t.beginPath(),t.moveTo(mt,0),t.lineTo(a/2-4,0),t.stroke(),t.fillStyle=k||"rgba(156, 163, 175, 0.8)",t.font=`600 8px "${U}", sans-serif`,t.textAlign="center",t.textBaseline="middle",t.fillText("▲",mt+J/2,-r/4),t.fillText("▼",mt+J/2,r/4),t.restore()}const wt=((Me=e.padding)==null?void 0:Me.left)??e.inputPadding??12,gt=((Re=e.padding)==null?void 0:Re.right)??e.inputPadding??12,It=f.visible||e.inputType==="search",ut=v.visible||ct||Mt,Lt=It?(f.offset??16)+(f.size||16)/2+8:wt,Wt=ut?(v.offset??16)+(v.size||16)/2+8+at:gt+at,q=-(a/2)+Lt,ft=Math.max(0,a-Lt-Wt);let Bt=j||B;if(e.inputType==="number"&&j){const mt=(Ie=e.number)!=null&&Ie.prefix?`${e.number.prefix} `:"",rt=(de=e.number)!=null&&de.suffix?` ${e.number.suffix}`:"";Bt=`${mt}${j}${rt}`}const Ot=N&&j?e.passwordVisible?j:"•".repeat(j.length):Bt,Pt=X?A:k;if(t.font=`${D} ${Y}px "${U}", sans-serif`,t.fillStyle=Pt,t.textAlign="left",t.save(),t.beginPath(),t.rect(q-2,-r/2+4,ft+4,r-8),t.clip(),g){t.textBaseline="top";const mt=Ot.split(`
19
- `);let rt=-r/2+(((me=e.padding)==null?void 0:me.top)??8);const z=Y*1.4,K=e.rows||3;let G=0,x=0;for(const Q of mt){if(G>=K)break;const H=Q.split(" ");let lt="";for(let kt=0;kt<H.length;kt++){const At=lt+H[kt]+" ";if(t.measureText(At).width>ft&&kt>0){if(G>=K)break;t.fillText(lt.trim(),q,rt),lt=H[kt]+" ",rt+=z,G++}else lt=At}G<K&&(t.fillText(lt.trim(),q,rt),x=t.measureText(lt.trim()).width,rt+=z,G++)}if(l&&!X&&Math.floor(performance.now()/500)%2===0){const Q=rt-z;t.fillStyle=R,t.fillRect(q+Math.min(x,ft),Q,1.5,Y)}}else{t.textBaseline="middle";const rt=t.measureText(Ot).width;let z=0;if(rt>ft&&(z=rt-ft),t.fillText(Ot,q-z,0),l&&Math.floor(performance.now()/500)%2===0){const K=X?q:q+rt-z;t.fillStyle=R,t.fillRect(K,-(Y/2),1.5,Y)}}if(t.restore(),e.showCharCounter){t.save();const mt=Number(e.maxLength||0),rt=mt>0?`${j.length}/${mt}`:`${j.length}`;t.font=`400 10px "${U}", sans-serif`,t.fillStyle=mt>0&&j.length>=mt?"#ef4444":"rgba(156, 163, 175, 0.6)",t.textAlign="right",t.textBaseline="top",t.fillText(rt,-(a/2)+a-8,-(r/2)+r+4),t.restore()}if(m.visible!==!1){const mt=!!(m.required||(Ae=e.validation)!=null&&Ae.required),rt=(m.text||"Label")+(mt?" *":""),z=m.fontSize||12,K=m.color||"rgba(156, 163, 175, 1)",G=m.position||"top",x=m.gap??m.offset??6;let Q=-(a/2),H=-(r/2)-x,lt="left",kt="bottom",At=`600 ${z}px "${m.fontFamily||U}", sans-serif`;G==="left"?(Q=-(a/2)-x,H=0,lt="right",kt="middle"):G==="bottom"?(Q=-(a/2),H=r/2+x,lt="left",kt="top"):G==="floating"&&(!!j||l?(Q=-(a/2)+12,H=-(r/2)+4,lt="left",kt="top",At=`600 ${Math.max(9,z-2)}px "${m.fontFamily||U}", sans-serif`):At=null),At&&(t.save(),t.font=At,t.fillStyle=K,t.textAlign=lt,t.textBaseline=kt,t.fillText(rt,Q,H),t.restore())}const vt=(he=e.validation)==null?void 0:he.errorMessage;if(b&&vt||h.visible===!0&&h.text){t.save();const mt=h.fontSize||11,rt=b?"#ef4444":h.color||"rgba(156, 163, 175, 1)",z=h.offset??6,K=b&&vt?vt:h.text;t.font=`400 ${mt}px "${U}", sans-serif`,t.fillStyle=rt,t.textAlign="left",t.textBaseline="top",t.fillText(K,-(a/2),r/2+z),t.restore()}c&&(t.save(),_(-a/2,-r/2,a,r,I),t.fillStyle="rgba(0, 0, 0, 0.3)",t.fill(),t.restore())}renderSlider(t,s){const o=this.objectStates.get(s.id),e=(o==null?void 0:o.geometry)||s.geometry,n=(o==null?void 0:o.options)||s.options||{},i=e.width||200,a=n.value??50,r=n.min??0,d=(n.max??100)-r,p=d===0?0:(a-r)/d,u=n.trackHeight||4,m=n.trackRoundedness??2,h=n.trackShape??"Rectangle",f=n.trackPath||"",v=n.accentColor||"#3b82f6",g=n.inactiveColor||"#374151",c=n.thumbShape||"Ellipse",b=n.thumbWidth??16,S=n.thumbHeight??16,w=n.thumbRoundedness??0,C=n.thumbColor||"#ffffff",M=n.thumbPath||"",I=n.thumbIcon||"",_=n.showValueTooltip??!1,E=n.tooltipBgColor||"#333333",P=n.tooltipColor||"#ffffff",L=n.tooltipOffsetX??0,k=n.tooltipOffsetY??-25,A=(J,at,j,it,B,X,N)=>{if((J==="Custom"||J==="Icon")&&N)try{const ct=new Path2D(N);if(t.save(),t.translate(at,j),J==="Icon"){const Mt=Math.min(it,B)/24;t.scale(Mt,Mt),t.translate(-12,-12)}t.fill(ct),t.restore();return}catch(ct){console.error("Error drawing slider shape in engine:",ct)}if(t.beginPath(),J==="Ellipse")t.ellipse(at,j,it/2,B/2,0,0,Math.PI*2);else if(J==="Rectangle")this.drawRoundRect(t,at-it/2,j-B/2,it,B,X);else if(J==="Triangle")t.moveTo(at,j-B/2),t.lineTo(at+it/2,j+B/2),t.lineTo(at-it/2,j+B/2),t.closePath();else if(J==="Diamond")t.moveTo(at,j-B/2),t.lineTo(at+it/2,j),t.lineTo(at,j+B/2),t.lineTo(at-it/2,j),t.closePath();else if(J==="Polygon"){const ct=s.geometry.sides||3,Mt=s.geometry.radius||Math.min(it,B)/2;for(let bt=0;bt<ct;bt++){const wt=bt*2*Math.PI/ct-Math.PI/2,gt=at+Mt*Math.cos(wt),It=j+Mt*Math.sin(wt);bt===0?t.moveTo(gt,It):t.lineTo(gt,It)}t.closePath()}else if(J==="Star"){const Mt=Math.min(it,B)/2,bt=Mt/2;for(let wt=0;wt<10;wt++){const gt=wt%2===0?Mt:bt,It=wt*Math.PI/5-Math.PI/2;t.lineTo(at+gt*Math.cos(It),j+gt*Math.sin(It))}t.closePath()}else J==="Line"&&(t.moveTo(at-it/2,j),t.lineTo(at+it/2,j));t.fill()},T=this.createCanvasFill(t,g,i,u);T&&(t.fillStyle=T,t.strokeStyle=T),h==="Line"?(t.lineWidth=u,t.beginPath(),t.moveTo(-i/2,0),t.lineTo(i/2,0),t.stroke()):A(h,0,0,i,u,m,f);const R=i-b,F=-i/2+b/2+p*R,O=F- -i/2;if(O>0){const J=this.createCanvasFill(t,v,i,u);J&&(t.fillStyle=J,t.strokeStyle=J),h==="Line"?(t.lineWidth=u,t.beginPath(),t.moveTo(-i/2,0),t.lineTo(F,0),t.stroke()):h==="Rectangle"&&(t.beginPath(),this.drawRoundRect(t,-i/2,-u/2,O,u,m),t.fill())}t.save(),t.translate(F,0);const W=t.getTransform(),V=Math.sqrt(W.a*W.a+W.b*W.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*V,t.shadowOffsetY=1*V;const U=this.createCanvasFill(t,C,b,S);if(U&&(t.fillStyle=U),A(c,0,0,b,S,w,c==="Icon"?I:M),t.restore(),_){t.save(),t.translate(F+L,k);const J=Math.round(a).toString();t.font="10px Inter, sans-serif";const at=t.measureText(J),j=6,it=4,B=at.width+j*2,X=14+it;t.beginPath(),this.drawRoundRect(t,-B/2,-X/2,B,X,4),t.fillStyle=E,t.fill(),t.fillStyle=P,t.textAlign="center",t.textBaseline="middle",t.fillText(J,0,0),t.restore()}const D=n.label||{},Y=n.helperText||{},ot=n.fontFamily||"Inter";if(D.visible!==!1){const J=D.text||"Label",at=D.fontSize||12,j=D.color||"rgba(156, 163, 175, 1)",it=D.offset??8;t.font=`600 ${at}px "${ot}", sans-serif`,t.fillStyle=j,t.textAlign="left",t.textBaseline="bottom";const B=-(i/2),X=-(u/2)-it;t.fillText(J,B,X)}if(Y.visible===!0){const J=Y.text||"Helper text",at=Y.fontSize||11,j=Y.color||"rgba(156, 163, 175, 1)",it=Y.offset??6;t.font=`400 ${at}px "${ot}", sans-serif`,t.fillStyle=j,t.textAlign="left",t.textBaseline="top";const B=-(i/2),X=u/2+it;t.fillText(J,B,X)}}renderDropdown(t,s){var k;const o=this.objectStates.get(s.id);if(!o)return;const e=o.options||s.options||{},n=s.geometry.width||180,i=s.geometry.height||40,a=-n/2,r=-i/2,l=e.cornerRadius??e.corner_radius??6,d=e.disabled||e.previewState==="disabled",p=this.lastHoveredObjectId===s.id||e.previewState==="hover",u=(e.isOpen||e.previewState==="active")&&!d;let m=e.backgroundColor,h=e.borderColor,f=e.color||"#333333";d?(m=e.disabledBackgroundColor||"#f3f4f6",h=e.disabledBorderColor||"#e5e7eb",f=e.disabledColor||"#9ca3af"):u?(m=e.activeBackgroundColor||m,h=e.activeBorderColor||h,f=e.activeColor||f):p&&(m=e.hoverBackgroundColor||m,h=e.hoverBorderColor||h,f=e.hoverColor||f),m||(m="#ffffff"),h||(h="#e5e7eb"),t.save();const v=t.globalAlpha;t.globalAlpha=v*(e.opacity??1),t.beginPath(),this.drawRoundRect(t,a,r,n,i,l),t.fillStyle=this.createCanvasFill(t,typeof m=="string"?{type:"Solid",color:m}:m,n,i)||"#ffffff",t.fill();const g=e.borderWidth??1;g>0&&(t.beginPath(),this.drawRoundRect(t,a,r,n,i,l),t.strokeStyle=this.createCanvasFill(t,typeof h=="string"?{type:"Solid",color:h}:h,n,i)||"#e5e7eb",t.lineWidth=g,t.stroke());const c=12,b=e.chevronType||"chevron",S=e.chevronSize||16,w=(u?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(b!=="none"){const A=a+n-c-S/2;t.save(),t.translate(A,0);const T=u?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(T*Math.PI/180),t.strokeStyle=w,t.fillStyle=w,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",b==="chevron")t.beginPath(),t.moveTo(-S/2,-S*.2),t.lineTo(0,S*.2),t.lineTo(S/2,-S*.2),t.stroke();else if(b==="custom"||b==="path"){const R=u&&e.openIconPath||e.closedIconPath;if(R){const F=new Path2D(R);t.save();const O=S/24;t.scale(O,O),t.translate(-12,-12),t.fill(F),t.restore()}}t.restore()}const C=e.selectedOption||e.placeholder||"Select...",M=e.fontSize||14,I=e.fontWeight||400,_=e.fontFamily||"Inter, sans-serif";t.font=`${I} ${M}px ${_}`;const E=d?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":f;t.fillStyle=this.createCanvasFill(t,typeof E=="string"?{type:"Solid",color:E}:E,n,i)||"#333333",t.textAlign="left",t.textBaseline="middle";const P=b==="none"?0:S+8,L=n-c*2-P;if(t.save(),t.beginPath(),t.rect(a+c,r,L,i),t.clip(),t.fillText(C,a+c,0),t.restore(),u&&!d){const A=r+i+4,T=this.getResolvedDropdownOptions(s,e),R=e.itemHeight||32,F=e.listPadding??4,O=T.length*R+F*2,W=e.listCornerRadius??l;t.save();const V=e.listShadow||{},U=t.getTransform(),D=Math.sqrt(U.a*U.a+U.b*U.b)||1;t.shadowColor=typeof V.color=="string"?V.color:((k=V.color)==null?void 0:k.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(V.blur??12)*D,t.shadowOffsetY=(V.offsetY??6)*D,t.shadowOffsetX=(V.offsetX??0)*D,t.beginPath(),this.drawRoundRect(t,a,A,n,O,W),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},n,O)||"#ffffff",t.fill();const Y=e.listBorderWidth??1;Y>0&&(t.shadowColor="transparent",t.beginPath(),this.drawRoundRect(t,a,A,n,O,W),t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:h},n,O)||"#e5e7eb",t.lineWidth=Y,t.stroke()),t.restore();const ot=e.itemFontSize||M,J=e.itemFontFamily||_;t.font=`${I} ${ot}px ${J}`,T.forEach((at,j)=>{const it=A+F+j*R;if(at===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},n,R)||"#f3f4f6",t.fillRect(a+Y,it,n-Y*2,R),t.fillStyle=e.itemSelectedColor||e.accentColor||f||"#374151";else if(t.fillStyle=e.listTextColor||f||"#333333",this.activeDropdownId===s.id&&this._lastPointerPos){const X=this._lastPointerPos.y-(A+F),N=Math.floor(X/R);j===N&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},n,R)||"#f9fafb",t.fillRect(a+Y,it,n-Y*2,R),t.fillStyle=e.itemHoverColor||f)}t.fillText(at,a+c,it+R/2)})}t.restore()}renderButton(t,s){var L;if(s.children&&s.children.length>0)return;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=s.geometry||{},i=n.width||s.width||160,a=n.height||s.height||45,r=this.lastHoveredObjectId===s.id,l=this.activeObjectId===s.id,d=e.label||{},p=e.hoverStyle||{},u=e.activeStyle||{},m=e.icon||{enabled:!1};let h=e.backgroundColor||e.buttonBgColor||((L=s.style)==null?void 0:L.fill)||"#3b82f6",f=(typeof d=="object"?d.color:null)||"#ffffff",v=typeof d=="string"?d:d.text||s.text||(s.name&&!s.name.toLowerCase().includes("component")?s.name:"Button"),g=n.cornerRadius??n.corner_radius??8,c=e.borderColor||"transparent",b=e.borderWidth||0,S=1;l&&u?(h=u.backgroundColor||h,f=u.color||f,v=u.text||v,S=u.scale??.95,g=u.cornerRadius??g):r&&p&&(h=p.backgroundColor||h,f=p.color||f,v=p.text||v,S=p.scale??1,g=p.cornerRadius??g,c=p.borderColor||c);const w=-i/2,C=-a/2;t.save(),t.scale(S,S),t.beginPath(),this.drawRoundRect(t,w,C,i,a,g);const M=this.createCanvasFill(t,h,i,a);M&&(t.fillStyle=M,t.fill()),(b>0||r&&p.borderColor)&&(t.strokeStyle=c,t.lineWidth=b||(r?1:0),t.stroke());const I=d.fontSize||14,_=d.fontFamily||"Inter",E=d.fontWeight||600;t.font=`${E} ${I}px "${_}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=f,t.textAlign="center",t.textBaseline="middle";let P=0;if(m.enabled&&m.svgPath){const k=I*1.1,A=m.gap||8,T=t.measureText(v),F=-(T.width+k+A)/2,O=m.position==="left"?F+k/2:F+T.width+A+k/2;P=m.position==="left"?F+k+A+T.width/2:F+T.width/2,t.save(),t.translate(O,0);const W=new Path2D(m.svgPath),V=k/24;t.scale(V,V),t.translate(-12,-12),t.fillStyle=f,t.fill(W),t.restore()}t.fillText(v,P,0),t.restore()}renderToggleButton(t,s){var v,g;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=e.checked??!1,i=((v=s.geometry)==null?void 0:v.width)||120,a=((g=s.geometry)==null?void 0:g.height)||40,r=-i/2,l=-a/2,d=e.corner_radius??8,p=e.label||{},u=n?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",m=n?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,r,l,i,a,d),t.fillStyle=u,t.fill();const h=p.fontSize||14,f=p.fontFamily||"Inter";t.font=`${p.fontWeight||600} ${h}px "${f}", sans-serif`,t.fillStyle=m,t.textAlign="center",t.textBaseline="middle",t.fillText(p.text||"Toggle",0,0),t.restore()}renderToggle(t,s){var W,V,U,D,Y,ot,J,at,j,it,B,X;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=((W=s.geometry)==null?void 0:W.width)||52,i=((V=s.geometry)==null?void 0:V.height)||30,a=-n/2,r=-i/2,l=e.checked??!1,d=e.cornerRadius??e.corner_radius??i/2,p=e.toggleStyle||{},u=p.backgroundColor||e.activeColor||"#10b981",m=p.borderColor||e.borderColor||"transparent",h=p.borderWidth??e.borderWidth??0,f=p.knobColor||e.knobColor||"#ffffff",v=l?u:e.inactiveColor||"#374151",g=l?m:e.borderColor||"transparent",c=l?h:e.borderWidth??0,b=l?f:e.knobColor||"#ffffff";e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,n,i,d);const S=this.createCanvasFill(t,v,n,i);if(S&&(t.fillStyle=S,t.fill()),c>0){t.lineWidth=c;const N=this.createCanvasFill(t,g,n,i);N&&(t.strokeStyle=N,t.stroke())}const w=2,C=i-w*2,M=C/2,I=a+w,_=a+n-w-C,E=l?_:I,P=r+w;t.beginPath(),t.arc(E+M,P+M,M,0,Math.PI*2);const L=this.createCanvasFill(t,b,C,C);L&&(t.fillStyle=L,t.fill()),e.disabled&&(t.globalAlpha*=2);let k=!1,A=!1;const T=(l?(U=p.leftLabel)==null?void 0:U.text:null)||((D=e.leftLabel)==null?void 0:D.text)||"",R=(l?(Y=p.leftLabel)==null?void 0:Y.color:null)||((ot=e.leftLabel)==null?void 0:ot.color)||"#f3f4f6";if((J=e.leftLabel)!=null&&J.enabled&&T){const N=e.leftLabel;t.font=`${N.fontWeight||400} ${N.fontSize||12}px "${N.fontFamily||"Inter"}", sans-serif`,t.fillStyle=R,t.textBaseline="middle",t.textAlign="right",t.fillText(T,a-(N.gap||8),0),k=!0}const F=(l?(at=p.rightLabel)==null?void 0:at.text:null)||((j=e.rightLabel)==null?void 0:j.text)||"",O=(l?(it=p.rightLabel)==null?void 0:it.color:null)||((B=e.rightLabel)==null?void 0:B.color)||"#f3f4f6";if((X=e.rightLabel)!=null&&X.enabled&&F){const N=e.rightLabel;t.font=`${N.fontWeight||400} ${N.fontSize||12}px "${N.fontFamily||"Inter"}", sans-serif`,t.fillStyle=O,t.textBaseline="middle",t.textAlign="left",t.fillText(F,a+n+(N.gap||8),0),A=!0}if(!k&&!A&&e.label&&e.label.text){const N=e.label,ct=N.fontSize||14,Mt=N.fontWeight||400,bt=N.fontFamily||"Inter";t.font=`${Mt} ${ct}px "${bt}", sans-serif`,t.fillStyle=N.color||"#f3f4f6",t.textBaseline="middle";const wt=N.gap||10;let gt=0,It=0;N.position==="left"?(t.textAlign="right",gt=a-wt,It=0):N.position==="right"?(t.textAlign="left",gt=a+n+wt,It=0):N.position==="top"?(t.textAlign="center",gt=0,It=r-wt,t.textBaseline="bottom"):N.position==="bottom"?(t.textAlign="center",gt=0,It=r+i+wt,t.textBaseline="top"):(t.textAlign="left",gt=a+n+wt,It=0),t.fillText(N.text,gt,It)}}renderCheckbox(t,s){var S,w;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=((S=s.geometry)==null?void 0:S.width)||20,i=((w=s.geometry)==null?void 0:w.height)||20,a=-n/2,r=-i/2,l=e.cornerRadius??4,d=e.checked??!1,p=e.activeColor||"#3b82f6",u=e.inactiveColor||"transparent",m=e.checkColor||"#ffffff",h=e.borderColor||"#4b5563",f=e.borderWidth??2,v=d?p:u,g=d?"transparent":h,c=d?0:f;e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,n,i,l);const b=this.createCanvasFill(t,v,n,i);if(b&&(t.fillStyle=b,t.fill()),c>0){t.lineWidth=c;const C=this.createCanvasFill(t,g,n,i);C&&(t.strokeStyle=C,t.stroke())}else if(d){t.lineWidth=1;const C=this.createCanvasFill(t,p,n,i);C&&(t.strokeStyle=C,t.stroke())}if(d){t.save(),t.beginPath();const C=this.createCanvasFill(t,m,n,i);t.strokeStyle=C||m,t.lineWidth=Math.max(2,n*.12),t.lineCap="round",t.lineJoin="round";const M=a+n*.25,I=r+i*.5,_=a+n*.45,E=r+i*.7,P=a+n*.75,L=r+i*.25;t.moveTo(M,I),t.lineTo(_,E),t.lineTo(P,L),t.stroke(),t.restore()}if(e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const C=e.label;t.save(),t.font=`${C.fontWeight||400} ${C.fontSize||14}px "${C.fontFamily||"Inter"}", sans-serif`,t.fillStyle=C.color||"#f3f4f6",t.textBaseline="middle";const M=C.gap||8;let I=0,_=0;C.position==="left"?(t.textAlign="right",I=a-M,_=0):C.position==="right"?(t.textAlign="left",I=a+n+M,_=0):C.position==="top"?(t.textAlign="center",I=0,_=r-M,t.textBaseline="bottom"):C.position==="bottom"&&(t.textAlign="center",I=0,_=r+i+M,t.textBaseline="top"),t.fillText(C.text,I,_),t.restore()}}renderRadioGroup(t,s){var _,E;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=((_=s.geometry)==null?void 0:_.width)||180,i=((E=s.geometry)==null?void 0:E.height)||100,a=-n/2,r=-i/2;let l=e.optionsList||["Option 1","Option 2","Option 3"];if(e.isDataVarEnabled&&e.dataInputId){let P=this.inputs.get(e.dataInputId);if(P===void 0){const L=this.inputNameMap.get(e.dataInputId);L&&L.length>0&&(P=this.inputs.get(L[0]))}P&&Array.isArray(P)&&(l=P.map(L=>typeof L=="string"?L:String(L)))}const d=e.selectedValue,p=e.orientation||"vertical",u=e.itemGap!==void 0?e.itemGap:16,m=e.activeColor||"#3b82f6",h=e.inactiveColor||"#4b5563",f=e.textColor||"#ffffff",v=e.fontSize||14,g=e.fontFamily||"Inter",c=e.fontWeight||400;t.save(),t.beginPath(),t.rect(a,r,n,i),t.clip(),e.disabled&&(t.globalAlpha*=.5);const b=8,S=b*2,w=e.radioShape||"circle",C=e.borderWidth!==void 0?e.borderWidth:2,M=e.fillEmpty||"transparent",I=(P,L,k,A)=>{if(t.beginPath(),A==="custom"&&e.customShapePath)try{const T=new Path2D(e.customShapePath);t.save(),t.translate(P-k,L-k),t.scale(k*2/24,k*2/24),t.fill(T),t.restore();return}catch{t.arc(P,L,k,0,Math.PI*2);return}if(A==="square"){const T=k*1.6;t.rect(P-T/2,L-T/2,T,T)}else if(A==="diamond"){const T=k*1.4;t.moveTo(P,L-T),t.lineTo(P+T,L),t.lineTo(P,L+T),t.lineTo(P-T,L),t.closePath()}else if(A==="heart"){const T=k*.9;t.moveTo(P,L+T*.7),t.bezierCurveTo(P-T*1.5,L-T*.3,P-T*.5,L-T*1.5,P,L-T*.5),t.bezierCurveTo(P+T*.5,L-T*1.5,P+T*1.5,L-T*.3,P,L+T*.7)}else if(A==="star"){const T=k*1.1,R=k*.5;for(let F=0;F<5;F++){const O=(F*72-90)*Math.PI/180,W=(F*72+36-90)*Math.PI/180;F===0?t.moveTo(P+T*Math.cos(O),L+T*Math.sin(O)):t.lineTo(P+T*Math.cos(O),L+T*Math.sin(O)),t.lineTo(P+R*Math.cos(W),L+R*Math.sin(W))}t.closePath()}else t.arc(P,L,k,0,Math.PI*2)};if(t.font=`${c} ${v}px "${g}", sans-serif`,t.textBaseline="middle",t.textAlign="left",p==="vertical"){const P=Math.max(S,v)+u,L=l.length*P-u,k=r+Math.max(0,(i-L)/2);l.forEach((A,T)=>{const R=k+b+T*P,F=d===A,O=this.createCanvasFill(t,m,S,S),W=this.createCanvasFill(t,h,S,S);F?(t.fillStyle=O||m,I(a+b,R,b,w),t.fill(),t.strokeStyle=O||m,t.lineWidth=C,I(a+b,R,b,w),t.stroke()):(M!=="transparent"&&(t.fillStyle=M,I(a+b,R,b,w),t.fill()),t.strokeStyle=W||h,t.lineWidth=C,I(a+b,R,b,w),t.stroke()),t.fillStyle=f,t.fillText(A,a+S+8,R)})}else{const P=r+i/2;let L=0;t.font=`${c} ${v}px "${g}", sans-serif`,l.forEach(T=>{L+=S+6+t.measureText(T).width+u}),L-=u;let A=a+Math.max(0,(n-L)/2);l.forEach(T=>{const R=d===T,F=t.measureText(T).width,O=this.createCanvasFill(t,m,S,S),W=this.createCanvasFill(t,h,S,S);R?(t.fillStyle=O||m,I(A+b,P,b,w),t.fill(),t.strokeStyle=O||m,t.lineWidth=C,I(A+b,P,b,w),t.stroke()):(M!=="transparent"&&(t.fillStyle=M,I(A+b,P,b,w),t.fill()),t.strokeStyle=W||h,t.lineWidth=C,I(A+b,P,b,w),t.stroke()),t.fillStyle=f,t.fillText(T,A+S+6,P),A+=S+6+F+u})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const P=e.label;t.save(),t.font=`${P.fontWeight||400} ${P.fontSize||14}px "${P.fontFamily||"Inter"}", sans-serif`,t.fillStyle=P.color||"#9ca3af",t.textBaseline="middle";const L=P.gap||8;let k=0,A=0;P.position==="left"?(t.textAlign="right",k=a-L,A=0):P.position==="right"?(t.textAlign="left",k=a+n+L,A=0):P.position==="top"?(t.textAlign="center",k=0,A=r-L,t.textBaseline="bottom"):P.position==="bottom"&&(t.textAlign="center",k=0,A=r+i+L,t.textBaseline="top"),t.fillText(P.text,k,A),t.restore()}}renderBarChart(t,s){var E,P,L;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{};let n={...e};if(e.isDataVarEnabled&&e.dataInputId){let k=this.inputs.get(e.dataInputId);if(k===void 0){const A=this.inputNameMap.get(e.dataInputId);A&&A.length>0&&(k=this.inputs.get(A[0]))}k&&Array.isArray(k)&&(n.categories=k.map(A=>typeof A=="string"?A:String(A)))}if(e.isDatasetsVarEnabled&&((E=e.datasetInputIds)==null?void 0:E.length)>0){const k=e.datasetInputIds.map((A,T)=>{var O;let R=this.inputs.get(A);if(R===void 0){const W=this.inputNameMap.get(A);W&&W.length>0&&(R=this.inputs.get(W[0]))}const F=((O=e.datasets)==null?void 0:O[T])||{id:`ds-${T}`,label:`Series ${T+1}`,data:[],color:"#6366f1"};return R&&Array.isArray(R)?{...F,data:R.map(W=>typeof W=="number"?W:parseFloat(W)||0)}:F});n.datasets=k}const i={width:((P=s.geometry)==null?void 0:P.width)||300,height:((L=s.geometry)==null?void 0:L.height)||180,chartType:n.chartType||"grouped",datasets:n.datasets||[{id:"ds-1",label:"Revenue",data:[42,67,31,55,78,48],color:"#6366f1"}],categories:n.categories||["Jan","Feb","Mar","Apr","May","Jun"],orientation:n.orientation||"vertical",barWidth:n.barWidth!==void 0?n.barWidth:14,barGap:n.barGap!==void 0?n.barGap:4,barCornerRadius:n.barCornerRadius!==void 0?n.barCornerRadius:5,showXAxis:!!n.showXAxis,showYAxis:!!n.showYAxis,xAxisColor:n.xAxisColor||"rgba(255,255,255,0.15)",yAxisColor:n.yAxisColor||"rgba(255,255,255,0.15)",showXLabels:n.showXLabels!==void 0?!!n.showXLabels:!0,showYLabels:!!n.showYLabels,axisLabelColor:n.axisLabelColor||"rgba(255,255,255,0.55)",axisLabelFontSize:n.axisLabelFontSize||9,showLegend:n.showLegend!==void 0?!!n.showLegend:!0,legendColor:n.legendColor||"rgba(255,255,255,0.7)",legendFontSize:n.legendFontSize||9,showGridLines:n.showGridLines!==void 0?!!n.showGridLines:!0,gridColor:n.gridColor||"rgba(255,255,255,0.06)",cardBackground:n.cardBackground||"#ffffff",cardBackgroundOpacity:n.cardBackgroundOpacity!==void 0?n.cardBackgroundOpacity:.04,cardBorderColor:n.cardBorderColor||"rgba(255,255,255,0.08)",barGradient:n.barGradient!==void 0?!!n.barGradient:!0,gradientStartColor:n.gradientStartColor||"",gradientEndOpacity:n.gradientEndOpacity!==void 0?n.gradientEndOpacity:.27,showValueOnTop:!!n.showValueOnTop,valueFontSize:n.valueFontSize||10,valueColor:n.valueColor||"",valueFontWeight:n.valueFontWeight||"bold",barStyle:n.barStyle||"solid",barBorderWidth:n.barBorderWidth!==void 0?n.barBorderWidth:1,barBorderColor:n.barBorderColor||"auto",enableShadows:!!n.enableShadows,shadowColor:n.shadowColor||"rgba(0,0,0,0.5)",shadowBlur:n.shadowBlur!==void 0?n.shadowBlur:4,shadowOffsetY:n.shadowOffsetY!==void 0?n.shadowOffsetY:2,xAxisLineWidth:n.xAxisLineWidth!==void 0?n.xAxisLineWidth:1,yAxisLineWidth:n.yAxisLineWidth!==void 0?n.yAxisLineWidth:1,gridLineWidth:n.gridLineWidth!==void 0?n.gridLineWidth:1,gridLineDash:n.gridLineDash||[3,4],_hexToRgb:function(k,A){if(k.startsWith("rgba")||k.startsWith("rgb"))return k;k.startsWith("#")||(k="#"+k),k.length===4&&(k="#"+k[1]+k[1]+k[2]+k[2]+k[3]+k[3]);const T=parseInt(k.slice(1,3),16),R=parseInt(k.slice(3,5),16),F=parseInt(k.slice(5,7),16);return`rgba(${T},${R},${F},${A})`},_resolveColor:function(k,A){return typeof k=="string"?k:"#6366f1"},_makeGradient:function(k,A,T,R,F,O){if(!this.barGradient)return A;const W=this.gradientStartColor||A,V=k.createLinearGradient(T,R,F,O);return V.addColorStop(0,A),V.addColorStop(1,this._hexToRgb(W,this.gradientEndOpacity)),V},_drawRoundedBar:function(k,A,T,R,F,O,W){if(O=Math.min(O,Math.min(Math.abs(R),Math.abs(F))/2),O<=0||R===0||F===0){k.rect(A,T,R,F);return}k.beginPath(),W?(k.moveTo(A,T+F),k.lineTo(A,T+O),k.quadraticCurveTo(A,T,A+O,T),k.lineTo(A+R-O,T),k.quadraticCurveTo(A+R,T,A+R,T+O),k.lineTo(A+R,T+F),k.lineTo(A,T+F)):(k.moveTo(A,T),k.lineTo(A+R-O,T),k.quadraticCurveTo(A+R,T,A+R,T+O),k.lineTo(A+R,T+F-O),k.quadraticCurveTo(A+R,T+F,A+R-O,T+F),k.lineTo(A,T+F),k.lineTo(A,T)),k.closePath()}},a=i.width,r=i.height,l=-a/2,d=-r/2;if(!i.datasets||i.datasets.length===0||i.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}let p=-1/0,u=1/0;const m=i.categories.length,h=i.datasets.length;if(i.chartType==="stacked")for(let k=0;k<m;k++){let A=0,T=0;i.datasets.forEach(R=>{const F=R.data[k]??0;F>=0?A+=F:T+=F}),A>p&&(p=A),T<u&&(u=T)}else i.datasets.forEach(k=>{k.data&&k.data.forEach(A=>{A>p&&(p=A),A<u&&(u=A)})});isFinite(p)||(p=10),isFinite(u)||(u=0),p=Math.max(p,0),u=Math.min(u,0);const f=p-u||10;t.save(),i.enableShadows&&(t.shadowColor=i.shadowColor,t.shadowBlur=i.shadowBlur,t.shadowOffsetY=i.shadowOffsetY),t.font=i.axisLabelFontSize+"px Inter, sans-serif";const v=i.showYLabels?t.measureText(p.toFixed(0)).width+14:10,g=i.showXLabels?i.axisLabelFontSize+12:8,b=(i.showLegend&&h>0?i.legendFontSize+10:0)+8,S=10,w=l+v,C=d+b,M=a-v-S,I=r-b-g;if(i.enableShadows&&(t.shadowColor="transparent"),t.beginPath(),t.roundRect(l,d,a,r,10),t.fillStyle=i._hexToRgb(i.cardBackground,i.cardBackgroundOpacity),t.fill(),t.strokeStyle=i.cardBorderColor,t.lineWidth=1,t.stroke(),i.showLegend&&h>0){t.font=i.legendFontSize+"px Inter, sans-serif",t.textBaseline="middle";const k=d+12;let A=w;i.datasets.forEach((T,R)=>{const F=i._resolveColor(T.color,R),O=T.label||"Series "+(R+1),W=7;t.beginPath(),t.roundRect(A,k-W/2,W,W,2),t.fillStyle=F,t.fill(),t.fillStyle=i.legendColor,t.textAlign="left",t.fillText(O,A+W+4,k),A+=t.measureText(O).width+W+16})}const _=4;if(i.showGridLines){t.setLineDash(i.gridLineDash||[]),t.lineWidth=i.gridLineWidth||1,t.strokeStyle=i.gridColor;for(let k=0;k<=_;k++)if(i.orientation==="horizontal"){const A=w+k/_*M;t.beginPath(),t.moveTo(A,C),t.lineTo(A,C+I),t.stroke()}else{const A=C+k/_*I;t.beginPath(),t.moveTo(w,A),t.lineTo(w+M,A),t.stroke()}t.setLineDash([])}if(i.showYLabels){t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=i.axisLabelColor;for(let k=0;k<=_;k++)if(i.orientation==="horizontal"){const A=u+k/_*f,T=w+k/_*M;t.textAlign="center",t.fillText(A.toFixed(0),T,C+I+i.axisLabelFontSize)}else{const A=p-k/_*f,T=C+k/_*I;t.textAlign="right",t.fillText(A.toFixed(0),w-6,T)}}if(t.setLineDash([]),i.showXAxis&&(t.lineWidth=i.xAxisLineWidth||1,t.strokeStyle=i.xAxisColor,t.beginPath(),t.moveTo(w,C+I),t.lineTo(w+M,C+I),t.stroke()),i.showYAxis&&(t.lineWidth=i.yAxisLineWidth||1,t.strokeStyle=i.yAxisColor,t.beginPath(),t.moveTo(w,C),t.lineTo(w,C+I),t.stroke()),i.enableShadows&&(t.shadowColor=i.shadowColor),i.chartType==="stacked")if(i.orientation==="horizontal"){const k=I/m;for(let A=0;A<m;A++){const T=C+A*k+k/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=i.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[A]||"",w-5,T),i.enableShadows&&(t.shadowColor=i.shadowColor));let R=w;i.datasets.forEach((F,O)=>{const W=F.data[A]??0;if(W===0)return;const V=W/f*M,U=Math.min(i.barWidth*h+i.barGap,k-8),D=T-U/2,Y=R;R+=V;const ot=i._resolveColor(F.color,O);t.beginPath(),t.fillStyle=i._makeGradient(t,ot,Y,D,Y+V,D),i._drawRoundedBar(t,Y,D,V,U,O===h-1?i.barCornerRadius:0,!1),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?ot:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else{const k=M/m;for(let A=0;A<m;A++){const T=w+A*k+k/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=i.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[A]||"",T,C+I+5),i.enableShadows&&(t.shadowColor=i.shadowColor));let R=C+I;i.datasets.forEach((F,O)=>{const W=F.data[A]??0;if(W===0)return;const V=W/f*I,U=Math.min(i.barWidth*h+i.barGap,k-8),D=T-U/2,Y=R-V;R-=V;const ot=i._resolveColor(F.color,O);t.beginPath(),t.fillStyle=i._makeGradient(t,ot,D,Y,D,Y+V),i._drawRoundedBar(t,D,Y,U,V,O===h-1?i.barCornerRadius:0,!0),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?ot:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else if(i.orientation==="horizontal"){const k=I/m,A=h*i.barWidth+Math.max(0,(h-1)*i.barGap),T=w+(0-u)/f*M;for(let R=0;R<m;R++){const F=C+R*k+k/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=i.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[R]||"",w-5,F),i.enableShadows&&(t.shadowColor=i.shadowColor));const O=F-A/2;i.datasets.forEach((W,V)=>{const U=W.data[R]??0,D=Math.abs(U/f*M);if(D<1)return;const Y=O+V*(i.barWidth+i.barGap),ot=U>=0?T:T-D,J=i._resolveColor(W.color,V);t.beginPath(),t.fillStyle=i._makeGradient(t,J,ot,Y,ot+D,Y),i._drawRoundedBar(t,ot,Y,D,i.barWidth,i.barCornerRadius,!1),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?J:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),i.showValueOnTop&&U!==0&&(t.font=(i.valueFontWeight||"bold")+" "+(i.valueFontSize||10)+"px Inter, sans-serif",t.textAlign=U>=0?"left":"right",t.textBaseline="middle",t.fillStyle=i.valueColor==="auto"?J:i.valueColor||"#fff",t.shadowColor="transparent",t.fillText(U.toString(),U>=0?ot+D+4:ot-4,Y+i.barWidth/2),i.enableShadows&&(t.shadowColor=i.shadowColor))})}}else{const k=M/m,A=h*i.barWidth+Math.max(0,(h-1)*i.barGap),T=C+I-(0-u)/f*I;for(let R=0;R<m;R++){const F=w+R*k+k/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=i.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[R]||"",F,C+I+5),i.enableShadows&&(t.shadowColor=i.shadowColor));const O=F-A/2;i.datasets.forEach((W,V)=>{const U=W.data[R]??0,D=Math.abs(U/f*I);if(D<1)return;const Y=O+V*(i.barWidth+i.barGap),ot=U>=0?T-D:T,J=i._resolveColor(W.color,V);t.beginPath(),t.fillStyle=i._makeGradient(t,J,Y,ot,Y,ot+D),i._drawRoundedBar(t,Y,ot,i.barWidth,D,i.barCornerRadius,!0),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?J:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),i.showValueOnTop&&U!==0&&(t.font=(i.valueFontWeight||"bold")+" "+(i.valueFontSize||10)+"px Inter, sans-serif",t.textAlign="center",t.textBaseline=U>=0?"bottom":"top",t.fillStyle=i.valueColor==="auto"?J:i.valueColor||"#fff",t.shadowColor="transparent",t.fillText(U.toString(),Y+i.barWidth/2,U>=0?ot-4:ot+D+4),i.enableShadows&&(t.shadowColor=i.shadowColor))})}}t.restore()}renderPieChart(t,s){var c,b;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=e.colorPalette==="custom"&&Array.isArray(e.customPalette)&&e.customPalette.length>0?e.customPalette:us[e.colorPalette||"vibrant"]||us.vibrant;let i=e.slices||[{id:"slice-1",label:"Item 1",value:45,color:""}];if(e.isDataVarEnabled&&e.dataInputId){let S=this.inputs.get(e.dataInputId);if(S===void 0){const w=this.inputNameMap.get(e.dataInputId);w&&w.length>0&&(S=this.inputs.get(w[0]))}S&&Array.isArray(S)&&(i=S.map((w,C)=>{var M,I;return{id:`slice-${C}`,label:((M=i[C])==null?void 0:M.label)||`Item ${C+1}`,value:typeof w=="number"?w:0,color:((I=i[C])==null?void 0:I.color)||""}}))}const a={width:((c=s.geometry)==null?void 0:c.width)||180,height:((b=s.geometry)==null?void 0:b.height)||180,chartType:e.chartType||"donut",slices:i,innerRadius:e.innerRadius!==void 0?e.innerRadius:.55,sliceGap:e.sliceGap!==void 0?e.sliceGap:3,showLabels:!!e.showLabels,labelColor:e.labelColor||"#000000",labelFontSize:e.labelFontSize||10,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(0,0,0,0.65)",legendFontSize:e.legendFontSize||9,showCenterText:e.showCenterText!==void 0?!!e.showCenterText:!0,centerLabel:e.centerLabel||"Total",centerTextColor:e.centerTextColor||"#000000",centerLabelColor:e.centerLabelColor||"rgba(0,0,0,0.4)",cardBackground:e.cardBackground||"#ffffff",cardBackgroundOpacity:e.cardBackgroundOpacity!==void 0?e.cardBackgroundOpacity:.04,cardBorderColor:e.cardBorderColor||"rgba(0,0,0,0.08)",_resolveSliceColor:function(S,w){return S.color?S.color:n[w%n.length]},_hexToRgb:function(S){if(S.startsWith("rgba")||S.startsWith("rgb"))return S;const w=S.replace("#",""),C=parseInt(w.substring(0,2),16),M=parseInt(w.substring(2,4),16),I=parseInt(w.substring(4,6),16);return`rgba(${C},${M},${I},${a.cardBackgroundOpacity})`}},r=a.width,l=a.height;if(!a.slices||a.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 d=a.slices.reduce((S,w)=>S+(w.value||0),0);if(d<=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}t.save();const p=a._hexToRgb(a.cardBackground);t.beginPath(),t.roundRect(-r/2,-l/2,r,l,10),t.fillStyle=p,t.fill(),t.strokeStyle=a.cardBorderColor,t.lineWidth=1,t.stroke();const u=a.showLegend?Math.ceil(a.slices.length/2):0,m=u>0?u*(a.legendFontSize+8)+10:0,h=l-m-16,f=Math.min(r-24,h)/2,v=0,g=-m/2;if(a.chartType==="rose"){const S=Math.max(...a.slices.map(M=>M.value||0)),w=Math.PI*2/a.slices.length,C=f>0?a.sliceGap/f:0;a.slices.forEach((M,I)=>{const _=M.value||0;if(_===0)return;const E=_/S*f,P=-Math.PI/2+I*w+C/2,L=P+w-C,k=a._resolveSliceColor(M,I);if(t.beginPath(),t.moveTo(v,g),t.arc(v,g,E,P,L),t.closePath(),t.fillStyle=k+"cc",t.fill(),t.strokeStyle=k,t.lineWidth=1.5,t.stroke(),a.showLabels){const A=P+(L-P)/2,T=v+E*.65*Math.cos(A),R=g+E*.65*Math.sin(A),F=Math.round(_/d*100);t.save(),t.font=`bold ${a.labelFontSize}px Inter, sans-serif`,t.fillStyle=a.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${F}%`,T,R),t.restore()}})}else{const S=a.chartType==="pie"?0:a.innerRadius,w=f*Math.max(0,S),C=f>0?a.sliceGap/f:0;let M=-Math.PI/2;if(a.slices.forEach((I,_)=>{const E=I.value||0;if(E===0){M+=E/d*Math.PI*2;return}const P=E/d*Math.PI*2,L=M+C/2,k=M+P-C/2;if(k<=L){M+=P;return}const A=a._resolveSliceColor(I,_);if(t.beginPath(),t.fillStyle=A,w<=0?(t.moveTo(v,g),t.arc(v,g,f,L,k),t.lineTo(v,g)):(t.moveTo(v+f*Math.cos(L),g+f*Math.sin(L)),t.arc(v,g,f,L,k),t.arc(v,g,w,k,L,!0),t.closePath()),t.fill(),a.showLabels){const T=L+(k-L)/2,R=w+(f-w)/2,F=v+R*Math.cos(T),O=g+R*Math.sin(T),W=Math.round(E/d*100);t.save(),t.font=`bold ${a.labelFontSize}px Inter, sans-serif`,t.fillStyle=a.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${W}%`,F,O),t.restore()}M+=P}),a.chartType==="donut"&&a.showCenterText&&w>14){const I=Math.round(d),_=Math.min(Math.floor(w*.52),20),E=Math.min(Math.floor(w*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${_}px Inter, sans-serif`,t.fillStyle=a.centerTextColor,t.fillText(I.toString(),v,g-E*.5),t.font=`${E}px Inter, sans-serif`,t.fillStyle=a.centerLabelColor,t.fillText(a.centerLabel,v,g+_*.6)}}if(a.showLegend&&a.slices.length>0){t.font=`${a.legendFontSize}px Inter, sans-serif`;const S=2,w=r/S,C=a.legendFontSize+8,M=l/2-m+10,I=-r/2+10;a.slices.forEach((_,E)=>{const P=E%S,L=Math.floor(E/S),k=I+P*w,A=M+L*C,T=a._resolveSliceColor(_,E),R=7;t.beginPath(),t.roundRect(k,A-R/2,R,R,2),t.fillStyle=T,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=a.legendColor;const F=Math.round((_.value||0)/d*100),O=`${_.label||"Item"} ${F}%`,W=w-R-20;let V=O;for(;t.measureText(V).width>W&&V.length>4;)V=V.slice(0,-4)+"…";t.fillText(V,k+R+4,A)})}t.restore()}renderJoystick(t,s){var v,g,c,b,S,w,C,M,I,_,E,P;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.width)!==void 0?o.width:((v=s.geometry)==null?void 0:v.width)??s.width??100,n=(o==null?void 0:o.height)!==void 0?o.height:((g=s.geometry)==null?void 0:g.height)??s.height??100,i=Math.min(e,n)*(((c=s.style)==null?void 0:c.baseSize)??.45),a=Math.min(e,n)*(((b=s.style)==null?void 0:b.handleSize)??.14);let r=s.handleX||0,l=s.handleY||0;o&&o.handleX!==void 0&&(r=o.handleX),o&&o.handleY!==void 0&&(l=o.handleY),t.save();let d=0,p=0;s.handleOrigin==="top-left"?(d=e/2,p=n/2):s.handleOrigin==="bottom-right"&&(d=-e/2,p=-n/2),t.translate(d,p);const u=t.globalAlpha;if(t.globalAlpha=u*(((S=s.style)==null?void 0:S.baseOpacity)??1),t.beginPath(),s.boundsShape==="square"){const L=s.joystickType==="2D"?12:18;t.roundRect(-i,-i,i*2,i*2,L)}else t.arc(0,0,i,0,Math.PI*2);t.fillStyle=((w=s.style)==null?void 0:w.baseColor)||"rgba(0,0,0,0.04)",t.fill(),(C=s.style)!=null&&C.baseBorderWidth?(t.lineWidth=s.style.baseBorderWidth,t.strokeStyle=s.style.baseBorderColor||"rgba(0,0,0,0.1)",t.stroke()):(t.lineWidth=1,t.strokeStyle=((M=s.style)==null?void 0:M.baseBorderColor)||"rgba(0,0,0,0.08)",t.stroke());const m=s.overflowHandle?i:Math.max(.1,i-a);let h=0,f=0;s.joystickType==="2D"?(h=r*m,f=l*m):s.joystickType==="1D_X"?(h=r*m,f=0):s.joystickType==="1D_Y"&&(h=0,f=l*m),t.globalAlpha=u*(((I=s.style)==null?void 0:I.handleOpacity)??1),t.beginPath(),t.arc(h,f,a,0,Math.PI*2),t.fillStyle=((_=s.style)==null?void 0:_.handleColor)||"#3b82f6",t.fill(),(E=s.style)!=null&&E.handleBorderWidth?(t.lineWidth=s.style.handleBorderWidth,t.strokeStyle=s.style.handleBorderColor||"rgba(255,255,255,0.5)",t.stroke()):(t.lineWidth=1,t.strokeStyle=((P=s.style)==null?void 0:P.handleBorderColor)||"rgba(255,255,255,0.5)",t.stroke()),t.globalAlpha=u,t.restore()}getRadioGroupItemIndexAtPointer(t,s,o){var I,_;const e=t.options||{},n=this.objectStates.get(t.id)||{},i=e.optionsList||[];if(i.length===0)return null;const a=n.width!==void 0?n.width:((I=t.geometry)==null?void 0:I.width)||180,r=n.height!==void 0?n.height:((_=t.geometry)==null?void 0:_.height)||100,l=e.orientation||"vertical",d=e.itemGap!==void 0?e.itemGap:16,p=e.fontSize||14,u=this.getWorldTransform(t.id),m=s-u.x,h=o-u.y,f=-u.rotation*(Math.PI/180),v=Math.cos(f),g=Math.sin(f),c=m*v-h*g,b=m*g+h*v,w=8*2,C=-a/2,M=-r/2;if(l==="vertical"){const E=Math.max(w,p)+d;for(let P=0;P<i.length;P++){const L=M+P*E;if(c>=C&&c<=C+a&&b>=L&&b<=L+E)return P}}else{let E=C;for(let P=0;P<i.length;P++){const k=i[P].length*8,A=w+6+k+d;if(c>=E&&c<=E+A&&b>=M&&b<=M+r)return P;E+=A}}return null}renderLineGraph(t,s,o,e){let n=s.datasets||[];if((!n||n.length===0)&&(s.data||s.graphData)&&(n=[{id:"line-1",label:"Series 1",data:s.data||s.graphData||[],lineColor:s.lineColor||"#3b82f6",lineWidth:s.lineWidth||2,showArea:s.showArea||!1,areaColor:s.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:s.smoothing||!1,showPoints:s.showPoints!==void 0?s.showPoints:!0,pointSize:s.pointSize||6,pointFill:s.pointFill||"#ffffff",pointStrokeColor:s.pointStrokeColor||s.lineColor||"#3b82f6",pointStrokeWidth:s.pointStrokeWidth||2}]),!n||n.length===0||!n.some(f=>f.data&&f.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 i=1/0,a=-1/0,r=0;if(n.forEach(f=>{let v=f.data;if(f.isVarEnabled&&f.inputId){let g=this.inputs.get(f.inputId);if(g===void 0){const c=this.inputNameMap.get(f.inputId);c&&c.length>0&&(g=this.inputs.get(c[0]))}g&&Array.isArray(g)&&(v=g)}if(v&&v.length>0){const g=v.filter(c=>typeof c=="number"&&!isNaN(c));g.length>0&&(i=Math.min(i,...g),a=Math.max(a,...g),r=Math.max(r,v.length))}f._resolvedData=v}),r<2)return;const l=a-i,d=o/(r-1),p=f=>{const v=l===0?.5:(f-i)/l;return e/2-v*e},u=f=>f*d-o/2,m=s.axisColor||"#333333";if(s.showXAxis&&(t.beginPath(),t.strokeStyle=s.xAxisColor||m,t.lineWidth=1,t.moveTo(-o/2,e/2),t.lineTo(o/2,e/2),t.stroke()),s.showYAxis&&(t.beginPath(),t.strokeStyle=s.yAxisColor||m,t.lineWidth=1,t.moveTo(-o/2,-e/2),t.lineTo(-o/2,e/2),t.stroke()),t.fillStyle=s.axisLabelColor||"#333333",t.font=`${s.axisLabelFontSize||10}px Inter, sans-serif`,s.showXLabels){t.textAlign="center",t.textBaseline="top";for(let f=0;f<r;f++){const v=u(f);t.fillText(`${f+1}`,v,e/2+5)}}if(s.showYLabels){t.textAlign="right",t.textBaseline="middle";const f=-o/2-5,v=(a+i)/2;t.fillText(a.toFixed(1),f,p(a)),t.fillText(v.toFixed(1),f,p(v)),t.fillText(i.toFixed(1),f,p(i))}const h=10;if(n.forEach(f=>{const v=f._resolvedData;if(!(!v||v.length<2)){if(f.showArea){if(t.beginPath(),t.moveTo(u(0),e/2),t.lineTo(u(0),p(v[0])),f.smoothing&&v.length>2)for(let c=0;c<v.length-1;c++){const b=v[c===0?c:c-1],S=v[c],w=v[c+1],C=v[c+1===v.length-1?c+1:c+2];for(let M=1;M<=h;M++){const I=M/h,_=this._catmullRom(b,S,w,C,I);t.lineTo(u(c+I),p(_))}}else for(let c=1;c<v.length;c++)t.lineTo(u(c),p(v[c]));t.lineTo(u(v.length-1),e/2),t.closePath();const g=t.globalAlpha;t.globalAlpha=g*(s.areaOpacity??.3),t.fillStyle=f.areaColor||"rgba(139, 92, 246, 0.2)",t.fill(),t.globalAlpha=g}if(t.beginPath(),t.strokeStyle=f.lineColor||"#3b82f6",t.lineWidth=f.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.moveTo(u(0),p(v[0])),f.smoothing&&v.length>2)for(let g=0;g<v.length-1;g++){const c=v[g===0?g:g-1],b=v[g],S=v[g+1],w=v[g+1===v.length-1?g+1:g+2];for(let C=1;C<=h;C++){const M=C/h,I=this._catmullRom(c,b,S,w,M);t.lineTo(u(g+M),p(I))}}else for(let g=1;g<v.length;g++)t.lineTo(u(g),p(v[g]));t.stroke(),f.showPoints&&v.forEach((g,c)=>{const b=u(c),S=p(g);t.beginPath(),t.arc(b,S,(f.pointSize||6)/2,0,Math.PI*2),t.fillStyle=f.pointFill||"#ffffff",t.fill(),t.strokeStyle=f.pointStrokeColor||f.lineColor||"#3b82f6",t.lineWidth=f.pointStrokeWidth||1,t.stroke()})}}),s.showLegend&&n.length>0){const f=o/2-10;let v=-e/2+15;const g=s.legendFontSize||10,c=g+5;t.font=`${g}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",n.forEach(b=>{const w=b.label||"Series",C=t.measureText(w).width;t.beginPath(),t.rect(f-C-8-5,v-(8/2+2),8,8),t.fillStyle=b.lineColor||"#3b82f6",t.fill(),t.fillStyle=s.legendColor||"#333333",t.fillText(w,f,v),v+=c})}}_catmullRom(t,s,o,e,n){const i=(o-t)*.5,a=(e-s)*.5,r=n*n,l=n*r;return(2*s-2*o+i+a)*l+(-3*s+3*o-2*i-a)*r+i*n+s}normalizeOpacity(t){const s=typeof t=="number"?t:parseFloat(String(t));return isNaN(s)?1:s>1?Math.min(1,s/100):Math.max(0,Math.min(1,s))}createCanvasFill(t,s,o,e){var n,i,a;if(!s||s.type==="None")return null;if(typeof s=="string")return s;if(s.type==="Solid"&&s.color){const r=s.color,d=(((i=(n=this.artboard)==null?void 0:n.tokens)==null?void 0:i.colors)||{})[r]||r;return t.fillStyle=d,d}if((s.type==="LinearGradient"||s.type==="RadialGradient"||s.type==="AngularGradient"||s.type==="DiamondGradient")&&s.stops){const r=(l,d=100)=>{var S,w;const u=(((w=(S=this.artboard)==null?void 0:S.tokens)==null?void 0:w.colors)||{})[l]||l,m=this.normalizeOpacity(s.opacity??100),f=this.normalizeOpacity(d)*m;if(f>=1&&u.startsWith("#"))return u;const v=u.startsWith("#")?u.replace("#",""):"ffffff",g=parseInt(v.substring(0,2),16),c=parseInt(v.substring(2,4),16),b=parseInt(v.substring(4,6),16);return`rgba(${g}, ${c}, ${b}, ${f})`};if(s.type==="LinearGradient"){let l=0,d=-e/2,p=0,u=e/2;if(s.angle!==void 0&&(!s.start||!s.end)){const h=(s.angle-90)*Math.PI/180,f=Math.max(o,e)/2;l=Math.cos(h)*-f,d=Math.sin(h)*-f,p=Math.cos(h)*f,u=Math.sin(h)*f}else if(s.start||s.end){const h=(f,v,g)=>Array.isArray(f)?f[v]??.5:f&&typeof f=="object"?f[g]??.5:.5;l=h(s.start,0,"x")*o-o/2,d=h(s.start,1,"y")*e-e/2,p=h(s.end,0,"x")*o-o/2,u=h(s.end,1,"y")*e-e/2}Math.abs(l-p)<.001&&Math.abs(d-u)<.001&&(l=0,d=-e/2,p=0,u=e/2);const m=t.createLinearGradient(l,d,p,u);if(s.stops.forEach(h=>{const f=h.offset!==void 0?h.offset:h.pos!==void 0?h.pos:h.position!==void 0?h.position:0,v=r(h.color||"#000000",h.opacity??100);m.addColorStop(Math.max(0,Math.min(1,f)),v)}),s.gradientTransform&&m.setTransform){const[h,f,v,g,c,b]=s.gradientTransform;m.setTransform({a:h,b:f,c:v,d:g,e:c,f:b})}return m}else if(s.type==="RadialGradient"){const l=(h,f,v)=>Array.isArray(h)?h[f]??.5:h&&typeof h=="object"?h[v]??.5:.5,d=l(s.center,0,"x")*o-o/2,p=l(s.center,1,"y")*e-e/2,u=(s.radius??.5)*Math.max(o,e),m=t.createRadialGradient(d,p,0,d,p,u);if(s.stops.forEach(h=>{const f=h.offset!==void 0?h.offset:h.pos!==void 0?h.pos:h.position!==void 0?h.position:0,v=r(h.color||"#000000",h.opacity??100);m.addColorStop(Math.max(0,Math.min(1,f)),v)}),s.gradientTransform&&m.setTransform){const[h,f,v,g,c,b]=s.gradientTransform;m.setTransform({a:h,b:f,c:v,d:g,e:c,f:b})}return m}else if(s.type==="AngularGradient"){const l=(h,f,v)=>Array.isArray(h)?h[f]??.5:h&&typeof h=="object"?h[v]??.5:.5,d=l(s.center||[.5,.5],0,"x")*o-o/2,p=l(s.center||[.5,.5],1,"y")*e-e/2,u=(s.degree||s.angle||0)*(Math.PI/180),m=(a=t.createConicGradient)==null?void 0:a.call(t,u,d,p);if(m){if(s.stops.forEach(h=>{const f=h.offset!==void 0?h.offset:h.pos!==void 0?h.pos:h.position!==void 0?h.position:0,v=r(h.color||"#000000",h.opacity??100);m.addColorStop(Math.max(0,Math.min(1,f)),v)}),s.gradientTransform&&m.setTransform){const[h,f,v,g,c,b]=s.gradientTransform;m.setTransform({a:h,b:f,c:v,d:g,e:c,f:b})}return m}}else if(s.type==="DiamondGradient"){const l=(h,f,v)=>Array.isArray(h)?h[f]??.5:h&&typeof h=="object"?h[v]??.5:.5,d=l(s.center||[.5,.5],0,"x")*o-o/2,p=l(s.center||[.5,.5],1,"y")*e-e/2,u=(s.radius??.5)*Math.max(o,e);t.save(),t.translate(d,p),t.rotate(Math.PI/4);const m=t.createRadialGradient(0,0,0,0,0,u);if(s.stops.forEach(h=>{const f=h.offset!==void 0?h.offset:h.pos!==void 0?h.pos:h.position!==void 0?h.position:0,v=r(h.color||"#000000",h.opacity??100);m.addColorStop(Math.max(0,Math.min(1,f)),v)}),s.gradientTransform&&m.setTransform){const[h,f,v,g,c,b]=s.gradientTransform;m.setTransform({a:h,b:f,c:v,d:g,e:c,f:b})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=m,t.restore(),m}}if(s.type==="Pattern"&&s.url){let r=this.imageCache.get(s.url);if(r||(r=new Image,r.src=s.url,this.imageCache.set(s.url,r)),r.complete&&r.naturalWidth>0){const l=t.createPattern(r,"repeat");if(l&&(s.scaleX!==void 0||s.offsetX!==void 0)){const d=new DOMMatrix,p=s.scaleX??1,u=s.scaleY??1,m=s.offsetX??0,h=s.offsetY??0,f=s.rotation??0;d.translateSelf(m,h),d.rotateSelf(f),d.scaleSelf(p,u),l.setTransform(d)}return l}}return s.color||null}drawRoundRect(t,s,o,e,n,i){if(i===0||i===void 0||i===null){t.rect(s,o,e,n);return}let a=i;if(typeof a=="string")try{a=JSON.parse(a)}catch{a=parseFloat(a)||0}let r=0,l=0,d=0,p=0;typeof a=="number"?r=l=d=p=a:Array.isArray(a)?a.length===1?r=l=d=p=a[0]:a.length===2?(r=d=a[0],l=p=a[1]):a.length===3?(r=a[0],l=p=a[1],d=a[2]):a.length>=4&&(r=a[0],l=a[1],d=a[2],p=a[3]):a&&typeof a=="object"&&(r=a[0]??a.tl??a.corner_radius??a.cornerRadius??0,l=a[1]??a.tr??a.corner_radius??a.cornerRadius??0,d=a[2]??a.br??a.corner_radius??a.cornerRadius??0,p=a[3]??a.bl??a.corner_radius??a.cornerRadius??0);const u=Math.min(Math.abs(e)/2,Math.abs(n)/2);if(r=Math.min(Math.max(0,r),u),l=Math.min(Math.max(0,l),u),d=Math.min(Math.max(0,d),u),p=Math.min(Math.max(0,p),u),t.roundRect){t.roundRect(s,o,e,n,[r,l,d,p]);return}t.moveTo(s+r,o),t.lineTo(s+e-l,o),t.arcTo(s+e,o,s+e,o+l,l),t.lineTo(s+e,o+n-d),t.arcTo(s+e,o+n,s+e-d,o+n,d),t.lineTo(s+p,o+n),t.arcTo(s,o+n,s,o+n-p,p),t.lineTo(s,o+r),t.arcTo(s,o,s+r,o,r),t.closePath()}renderListView(t,s){var T,R,F,O,W,V,U,D,Y,ot;const o=this.objectStates.get(s.id)||{},e=o.options||s.options||{},n=o.width!==void 0?o.width:((T=s.geometry)==null?void 0:T.width)||200,i=o.height!==void 0?o.height:((R=s.geometry)==null?void 0:R.height)||300,a=-n/2,r=-i/2,l=e.cornerRadius!==void 0?e.cornerRadius:o.cornerRadius!==void 0?o.cornerRadius:o.corner_radius??e.corner_radius??((F=s.geometry)==null?void 0:F.cornerRadius)??((O=s.geometry)==null?void 0:O.corner_radius)??0,d=e.orientation||"vertical",p=this.getResolvedListViewItems(s,e),u=e.itemGap??10,m=e.itemHeight??50,h=e.itemWidth??200,f=e.scrollOffset??0,v=e.padding??0,g=e.glassEffect!==!1,c=e.accentColor||"#3b82f6",b=e.itemTextColor||"#333333",S=e.itemBackgroundColor||"#ffffff",w=e.hoveredIndex??null,C=e.activeItemIndex??null,M=e.glowIntensity??0,I=e.glowColor||"#3b82f6",_=typeof I=="string"?I:I.color||((V=(W=I.stops)==null?void 0:W[0])==null?void 0:V.color)||"#3b82f6",E=e.opacity!==void 0?e.opacity:s.opacity!==void 0?s.opacity:1;if(t.save(),t.globalAlpha*=E,M>0){const J=t.getTransform(),at=Math.sqrt(J.a*J.a+J.b*J.b)||1;t.shadowColor=_,t.shadowBlur=M*2*at,t.shadowOffsetX=0,t.shadowOffsetY=0}if(g){const J=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",at=this.createCanvasFill(t,J,n,i);t.fillStyle=at||"rgba(31, 41, 55, 0.4)",t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)||t.fill();const it=t.createLinearGradient(a,r,a+n,r+i);it.addColorStop(0,"rgba(255, 255, 255, 0.15)"),it.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),it.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=it,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)||t.fill();const X=e.borderWidth??0;if(X>0&&e.borderColor&&e.borderColor!=="transparent"){const ct=this.createCanvasFill(t,e.borderColor,n,i);t.strokeStyle=ct||"rgba(255, 255, 255, 0.25)",t.lineWidth=X}else t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1;t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)||t.stroke()}else{const J=e.backgroundColor&&e.backgroundColor!=="transparent"?e.backgroundColor:e.listBackgroundColor||"transparent",at=this.createCanvasFill(t,J,n,i);if(at){t.fillStyle=at,t.beginPath();const it=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l);t.fill()}const j=e.borderWidth??0;if(j>0){const it=this.createCanvasFill(t,e.borderColor||"#cccccc",n,i);t.strokeStyle=it||"#cccccc",t.lineWidth=j,t.beginPath();const B=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l);t.stroke()}}t.shadowBlur=0;const P=e.clipContent!==!1&&e.listLayout!=="circular";if(P)if(t.save(),t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)&&e.containerShape==="custom")try{const at=new Path2D(e.containerPath);t.translate(a,r),t.scale(n/100,i/100),t.clip(at),t.scale(100/n,100/i),t.translate(-a,-r)}catch{}else t.clip();const L=typeof v=="number"?v:d==="vertical"?v[0]:v[3];let k=(d==="vertical"?r:a)+f+L;if(t.textBaseline="middle",p.forEach((J,at)=>{var ft,Bt,Ot,Pt;const j=e.listLayout||"linear",it=j==="circular"?h:d==="vertical"?n:h,B=j==="circular"||d==="vertical"?m:i;let X=0,N=0,ct=0;if(j==="circular"){const vt=p.length||1,Yt=Math.PI*2/vt,zt=e.circularStartAngle||0,Gt=e.circularRadius||100,Dt=f*.01+zt*Math.PI/180,te=at*Yt+Dt,ie=a+n/2,ce=r+i/2;X=ie+Math.cos(te)*Gt-it/2,N=ce+Math.sin(te)*Gt-B/2,ct=te+(e.itemRotation||0)*Math.PI/180}else X=d==="vertical"?a:k,N=d==="vertical"?k:r,ct=(e.itemRotation||0)*Math.PI/180;const Mt=w===at,bt=C===at,wt=e.itemBorderWidth??0;t.save(),ct!==0&&(t.translate(X+it/2,N+B/2),t.rotate(ct),t.translate(-(X+it/2),-(N+B/2)));const gt=Mt?((ft=e.hoverStyle)==null?void 0:ft.scale)??1:bt?((Bt=e.activeStyle)==null?void 0:Bt.scale)??1:1;if(gt!==1&&(t.translate(X+it/2,N+B/2),t.scale(gt,gt),t.translate(-(X+it/2),-(N+B/2))),bt){const vt=((Ot=e.activeStyle)==null?void 0:Ot.itemBackgroundColor)||e.activeBackgroundColor||(g?"rgba(255, 255, 255, 0.15)":"rgba(0, 0, 0, 0.1)"),Yt=this.createCanvasFill(t,vt,it,B);t.fillStyle=Yt||(typeof vt=="string"?vt:"transparent"),t.beginPath(),this.drawCustomShape(t,e.activeItemShape||e.itemShape||"rectangle",e.activeItemShape==="custom"?e.activeItemPath||"":e.itemPath||"",X,N,it,B,e.itemCornerRadius??0)||t.fill()}else if(Mt){const vt=((Pt=e.hoverStyle)==null?void 0:Pt.itemBackgroundColor)||e.hoverBackgroundColor||(g?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)"),Yt=this.createCanvasFill(t,vt,it,B);t.fillStyle=Yt||(typeof vt=="string"?vt:"transparent"),t.beginPath(),this.drawCustomShape(t,e.itemShape||"rectangle",e.itemPath||"",X,N,it,B,e.itemCornerRadius??0)||t.fill()}else if(S!=="transparent"){const vt=this.createCanvasFill(t,S,it,B);t.fillStyle=vt||(typeof S=="string"?S:"transparent"),t.beginPath(),this.drawCustomShape(t,e.itemShape||"rectangle",e.itemPath||"",X,N,it,B,e.itemCornerRadius??0)||t.fill()}if(wt>0&&e.itemBorderColor&&e.itemBorderColor!=="transparent"){const vt=this.createCanvasFill(t,e.itemBorderColor,it,B);t.strokeStyle=vt||(typeof e.itemBorderColor=="string"?e.itemBorderColor:"#cccccc"),t.lineWidth=wt,t.beginPath(),this.drawCustomShape(t,e.itemShape||"rectangle",e.itemPath||"",X,N,it,B,e.itemCornerRadius??0)||t.stroke()}if(bt){const vt=this.createCanvasFill(t,c,d==="vertical"?3:it,d==="vertical"?B:3);t.fillStyle=vt||c,d==="vertical"?t.fillRect(X,N,3,B):t.fillRect(X,N+B-3,it,3)}const It=bt?"#ffffff":g?"rgba(255, 255, 255, 0.9)":b;t.fillStyle=It,t.font=bt||Mt?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const ut=typeof J=="string"?J:(J==null?void 0:J.label)||`Item ${at+1}`,Lt=X+(d==="vertical"?16:it/2),Wt=N+B/2;d==="horizontal"||j==="circular"?t.textAlign="center":t.textAlign="left";const q=j==="circular"?X+it/2:Lt;t.fillText(ut,q,Wt),t.restore(),t.beginPath(),k+=(d==="vertical"?m:h)+u}),P&&t.restore(),e.showScrollbar!==!1){const J=typeof v=="number"?v:d==="vertical"?v[0]:v[3],j=(p.length||0)*(d==="vertical"?m:h)+Math.max(0,(p.length||0)-1)*u+J*2,it=d==="vertical"?i:n,B=e.listLayout||"linear",X=e.containerShape==="circle"||B==="circular",N=e.scrollbarColor||"rgba(255,255,255,0.3)";let ct=typeof N=="object"?N.color||((D=(U=N.stops)==null?void 0:U[0])==null?void 0:D.color)||"rgba(255,255,255,0.3)":N;const Mt=((ot=(Y=this.artboard)==null?void 0:Y.tokens)==null?void 0:ot.colors)||{};Mt[ct]&&(ct=Mt[ct]);const bt=e.scrollbarWidth||2;if(t.save(),X){const wt=Math.min(n,i)/2-bt/2-2,gt=a+n/2,It=r+i/2;if(t.strokeStyle=ct,t.lineWidth=bt,t.lineCap="round",t.beginPath(),B==="circular"){const ut=Math.PI/4,Lt=-(f*.01)-Math.PI/2;t.arc(gt,It,wt,Lt,Lt+ut)}else{const ut=Math.PI/2,Lt=j>0?Math.min(1,it/j):1,Wt=ut*Lt,q=j>0?-f/j*ut:0,Bt=-Math.PI/4+q;t.arc(gt,It,wt,Bt,Bt+Wt)}t.stroke()}else{let wt=it,gt=0;if(j>it){const It=it/j;wt=Math.max(16,it*It);const ut=it-wt,Lt=j-it;gt=Lt>0?Math.max(0,Math.min(ut,-f/Lt*ut)):0}if(t.fillStyle=ct,d==="vertical"){const It=a+n-bt-2,ut=r+gt,Lt=bt,Wt=wt;if(bt>2){t.beginPath();const q=Math.min(bt/2,wt/2);if(t.roundRect)try{t.roundRect(It,ut,Lt,Wt,q),t.fill()}catch{t.fillRect(It,ut,Lt,Wt)}else t.fillRect(It,ut,Lt,Wt)}else t.fillRect(It,ut,Lt,Wt)}else{const It=a+gt,ut=r+i-bt-2,Lt=wt,Wt=bt;if(bt>2){t.beginPath();const q=Math.min(bt/2,wt/2);if(t.roundRect)try{t.roundRect(It,ut,Lt,Wt,q),t.fill()}catch{t.fillRect(It,ut,Lt,Wt)}else t.fillRect(It,ut,Lt,Wt)}else t.fillRect(It,ut,Lt,Wt)}}t.restore()}t.beginPath(),t.restore()}drawCustomShape(t,s,o,e,n,i,a,r){if(s==="circle"){const l=Math.min(i,a)/2;return t.arc(e+i/2,n+a/2,l,0,Math.PI*2),!1}else if(s==="pill"){const l=Math.min(i,a)/2;return this.drawListViewRect(t,e,n,i,a,l),!1}else if(s==="custom"&&o)try{const l=new Path2D(o);return t.save(),t.translate(e,n),t.scale(i/100,a/100),t.fill(l),t.restore(),!0}catch{return this.drawListViewRect(t,e,n,i,a,r),!1}return this.drawListViewRect(t,e,n,i,a,r),!1}updateListViewScrollFromPointer(t){var S,w,C,M;if(!this._lastPointerPos||!this._prevPointerPos)return;const s=this.objectStates.get(t.id);s&&!s.options&&(s.options=JSON.parse(JSON.stringify(t.options||{})));const o=(s==null?void 0:s.options)||t.options||{},e=o.orientation||"vertical",n=this._lastPointerPos.x-this._prevPointerPos.x,i=this._lastPointerPos.y-this._prevPointerPos.y;let a=o.scrollOffset||0;const r=this.getResolvedListViewItems(t,o),l=o.itemGap??10,d=o.itemHeight??50,p=o.itemWidth??200,u=(s==null?void 0:s.width)!==void 0?s.width:((S=t.geometry)==null?void 0:S.width)||200,m=(s==null?void 0:s.height)!==void 0?s.height:((w=t.geometry)==null?void 0:w.height)||300,h=typeof o.padding=="number"?o.padding:e==="vertical"?((C=o.padding)==null?void 0:C[0])||0:((M=o.padding)==null?void 0:M[3])||0,v=(r.length||0)*(e==="vertical"?d:p)+Math.max(0,(r.length||0)-1)*l+h*2,g=e==="vertical"?m:u,c=Math.max(0,v-g);if(this.draggingListViewIsScrollbar&&o.listLayout!=="circular"){const I=v>0?g/v:1,_=Math.max(16,g*I),E=Math.max(1,g-_),P=c>0?c/E:1;e==="vertical"?a-=i*P:a-=n*P}else e==="vertical"?a+=i:a+=n;if((o.listLayout||"linear")==="circular"){o.scrollOffset=a,s&&s.options&&(s.options.scrollOffset=a),t.options&&(t.options.scrollOffset=a);return}a>0&&(a=0),a<-c&&(a=-c),o.scrollOffset=a,s&&s.options&&(s.options.scrollOffset=a),t.options&&(t.options.scrollOffset=a)}updateListViewHoverFromPointer(t,s,o){const e=this.getListViewItemIndexAtPointer(t,s,o),n=this.objectStates.get(t.id);if(n&&n.options)n.options.hoveredIndex!==e&&(n.options.hoveredIndex=e);else{const i=t.options||{};i.hoveredIndex!==e&&(i.hoveredIndex=e)}}getListViewItemIndexAtPointer(t,s,o){var F,O;const e=this.objectStates.get(t.id),n=(e==null?void 0:e.options)||t.options||{},i=this.getResolvedListViewItems(t,n);if(i.length===0)return null;const a=(e==null?void 0:e.width)!==void 0?e.width:((F=t.geometry)==null?void 0:F.width)||200,r=(e==null?void 0:e.height)!==void 0?e.height:((O=t.geometry)==null?void 0:O.height)||300,l=n.orientation||"vertical",d=n.itemGap??10,p=n.itemHeight??50,u=n.itemWidth??200,m=n.scrollOffset??0,h=n.padding??0,f=this.getWorldTransform(t.id),v=s-f.x,g=o-f.y,c=-f.rotation*(Math.PI/180),b=Math.cos(c),S=Math.sin(c),w=v*b-g*S,C=v*S+g*b,M=-a/2,I=-r/2,_=typeof h=="number"?h:l==="vertical"?h[0]:h[3];let E=(l==="vertical"?I:M)+m+_;const P=n.listLayout||"linear",L=i.length||1,k=Math.PI*2/L,A=n.circularStartAngle||0,T=n.circularRadius||100,R=m*.01+A*Math.PI/180;for(let W=0;W<i.length;W++){const V=P==="circular"?u:l==="vertical"?a:u,U=P==="circular"||l==="vertical"?p:r;let D=0,Y=0,ot=0;if(P==="circular"){const J=W*k+R,at=M+a/2,j=I+r/2;D=at+Math.cos(J)*T-V/2,Y=j+Math.sin(J)*T-U/2,ot=J+(n.itemRotation||0)*Math.PI/180}else D=l==="vertical"?M:E,Y=l==="vertical"?E:I,ot=(n.itemRotation||0)*Math.PI/180;if(ot!==0){const J=D+V/2,at=Y+U/2,j=w-J,it=C-at,B=-ot,X=j*Math.cos(B)-it*Math.sin(B)+J,N=j*Math.sin(B)+it*Math.cos(B)+at;if(X>=D&&X<=D+V&&N>=Y&&N<=Y+U)return W}else if(w>=D&&w<=D+V&&C>=Y&&C<=Y+U)return W;E+=(l==="vertical"?p:u)+d}return null}drawListViewRect(t,s,o,e,n,i){this.drawRoundRect(t,s,o,e,n,i)}solveBehaviors(t){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:s,y:o}=this._lastPointerPos;this.artboard.objects.forEach(e=>{if(!e.behaviors||e.behaviors.length===0)return;const n=this.objectStates.get(e.id);n&&e.behaviors.forEach(i=>{var u,m,h,f,v,g,c,b,S,w,C,M,I,_,E,P,L,k,A,T,R,F,O,W,V,U,D,Y,ot,J,at,j,it,B,X,N,ct,Mt,bt,wt,gt,It,ut,Lt,Wt,q,ft,Bt,Ot,Pt,vt,Yt,zt,Gt,Dt,te,ie,ce,ve,_e,ge,Ee,Zt,Me,Re,Ie,de,me,Ae,he,mt,rt,z,K,G,x,Q,H,lt,kt,At,Ht,Ut,qt,$,dt,Rt,Nt,st,yt,St,ee,Ct,Vt,Tt,Xt,Ft,le,fe,Oe,jt,oe,ne,Fe,Be,xe,We,De,Ye,Ge,se,ue,Se,Xe,Ne,ke,Ce,we;if(!i.enabled)return;const a=i.startTime||0,r=i.endTime||1/0;if(this.currentTime<a||this.currentTime>r)return;const l=n.x-s,d=n.y-o,p=Math.sqrt(l*l+d*d);if(this.frameCount%240===0&&Math.random()<.1&&this.log(`[ExodeUI] Executing ${i.type} on ${e.name}`),i.type===tt.Proximity){const Z=((u=i.settings)==null?void 0:u.radius)||300,nt=((m=i.settings)==null?void 0:m.falloff)||"smooth";let et=0;p<Z&&(nt==="linear"?et=1-p/Z:et=Math.pow(1-p/Z,2)),i.sensors.forEach(pt=>{this.applyBehaviorSensor(n,pt,et,t,i.settings,e,l,d,p)})}else if(i.type===tt.Magnetic){const Z=((h=i.settings)==null?void 0:h.radius)||400,nt=((f=i.settings)==null?void 0:f.strength)||.5;if(p<Z&&p>5){const et=1-p/Z,pt=l*et*nt,$t=d*et*nt;n.x-=pt*t*10,n.y-=$t*t*10}}else if(i.type===tt.Repel){const Z=((v=i.settings)==null?void 0:v.radius)||300,nt=((g=i.settings)==null?void 0:g.strength)||1;if(p<Z){const et=Math.pow(1-p/Z,2);n.x+=l/(p||1)*et*60*nt*t*5,n.y+=d/(p||1)*et*60*nt*t*5}}else if(i.type===tt.Orbit){const Z=((c=i.settings)==null?void 0:c.speed)||1,nt=((b=i.settings)==null?void 0:b.radius)||30,et=this.currentTime*Z*Math.PI*2;n.x+=Math.cos(et)*nt*t*5,n.y+=Math.sin(et)*nt*t*5,n.rotation+=2*t*5}else if(i.type===tt.Vortex){const Z=((S=i.settings)==null?void 0:S.radius)||400,nt=((w=i.settings)==null?void 0:w.speed)||2,et=((C=i.settings)==null?void 0:C.strength)||1;if(p<Z){const pt=Math.pow(1-p/Z,1.5),$t=this.currentTime*nt*Math.PI*2,xt=Math.cos($t)*30-l*.4,Jt=Math.sin($t)*30-d*.4;n.x+=xt*pt*et*t*5,n.y+=Jt*pt*et*t*5,n.rotation+=5*pt*et*t*5,n.scale_x*=1-pt*.1*et*t,n.scale_y*=1-pt*.1*et*t}}else if(i.type===tt.Fluid){const Z=((M=i.settings)==null?void 0:M.radius)||300,nt=((I=i.settings)==null?void 0:I.strength)||1;if(p<Z){const et=Math.pow(1-p/Z,1.2),pt=l/(p||1)*et*1.2*nt,$t=d/(p||1)*et*1.2*nt;n.x+=pt*10*t*5,n.y+=$t*10*t*5,n.scale_x*=1+et*.3*nt*t,n.scale_y*=1+et*.3*nt*t}}else if(i.type===tt.Elastic){const Z=((_=i.settings)==null?void 0:_.radius)||300,nt=((E=i.settings)==null?void 0:E.strength)||1;if(p<Z){const et=1-p/Z;n.scale_x*=1+et*.4*nt*t,n.scale_y*=1+et*.4*nt*t}}else if(i.type===tt.Holographic){const Z=n.x-this.canvasWidth/2,nt=n.y-this.canvasHeight/2,et=((P=i.settings)==null?void 0:P.factor)||25;if(n.x-=Z/1e3*et*t*5,n.y-=nt/1e3*et*t*5,n.style){const pt=1-Math.min(1,p/400);n.style.exposure=(n.style.exposure||1)+pt*.5*t}}else if(i.type===tt.Sticky){const Z=((L=i.settings)==null?void 0:L.radius)||80,nt=((k=i.settings)==null?void 0:k.strength)||1;if(p<Z){const et=Math.pow(1-p/Z,2);n.x-=l*et*nt*t*10,n.y-=d*et*nt*t*10,n.scale_x*=1-et*.1*nt*t,n.scale_y*=1-et*.1*nt*t}}else if(i.type===tt.Dilation){const Z=((A=i.settings)==null?void 0:A.size)||120,nt=((T=i.settings)==null?void 0:T.strength)||1;if(p<Z){const et=1-p/Z;n.scale_x*=1+et*.5*nt*t,n.scale_y*=1+et*.5*nt*t}}else if(i.type===tt.Parallax){const Z=((R=i.settings)==null?void 0:R.factor)||15,nt=((F=i.settings)==null?void 0:F.strength)||1,et=this.canvasWidth/2,pt=this.canvasHeight/2,$t=this._lastPointerPos||{x:et,y:pt},xt=($t.x-et)/et,Jt=($t.y-pt)/pt,pe=(((O=e.transform)==null?void 0:O.x)??0)+xt*Z*nt,Te=(((W=e.transform)==null?void 0:W.y)??0)+Jt*Z*nt,$e=(((V=e.transform)==null?void 0:V.rotate_x)??0)-Jt*Z*1.5*nt,ye=(((U=e.transform)==null?void 0:U.rotate_y)??0)+xt*Z*1.5*nt,Le=Math.min(1,10*t);n.x=this.lerp(n.x??((D=e.transform)==null?void 0:D.x)??0,pe,Le),n.y=this.lerp(n.y??((Y=e.transform)==null?void 0:Y.y)??0,Te,Le),n.rotate_x=this.lerp(n.rotate_x??((ot=e.transform)==null?void 0:ot.rotate_x)??0,$e,Le),n.rotate_y=this.lerp(n.rotate_y??((J=e.transform)==null?void 0:J.rotate_y)??0,ye,Le)}else if(i.type===tt.Fold){if(p<300){const Z=1-p/300,nt=(l>0?-1:1)*Z*10,et=1-Z*.1,pt=d/300*Z*20,$t=-(l/300)*Z*20,xt=Math.min(1,10*t);n.skew_x=this.lerp(n.skew_x??((at=e.transform)==null?void 0:at.skew_x)??0,nt,xt),n.scale_y=this.lerp(n.scale_y??((j=e.transform)==null?void 0:j.scale_y)??1,(((it=e.transform)==null?void 0:it.scale_y)??1)*et,xt),n.rotate_x=this.lerp(n.rotate_x??((B=e.transform)==null?void 0:B.rotate_x)??0,pt,xt),n.rotate_y=this.lerp(n.rotate_y??((X=e.transform)==null?void 0:X.rotate_y)??0,$t,xt),n.style=n.style||{...e.style},n.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((N=i.settings)==null?void 0:N.opacity)??.5}}}else if(i.type===tt.Crumple){if(p<300){const Z=1-p/300,nt=Z*(Math.random()-.5)*5,et=Z*(Math.random()-.5)*.05,pt=Math.min(1,15*t);n.skew_x=this.lerp(n.skew_x??((ct=e.transform)==null?void 0:ct.skew_x)??0,nt,pt),n.scale_x=this.lerp(n.scale_x??((Mt=e.transform)==null?void 0:Mt.scale_x)??1,(((bt=e.transform)==null?void 0:bt.scale_x)??1)*(1+et),pt),n.scale_y=this.lerp(n.scale_y??((wt=e.transform)==null?void 0:wt.scale_y)??1,(((gt=e.transform)==null?void 0:gt.scale_y)??1)*(1+et),pt),n.style=n.style||{...e.style},n.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((It=i.settings)==null?void 0:It.intensity)??1,scale:((ut=i.settings)==null?void 0:ut.scale)??2}}}else if(i.type===tt.Squash){const Z=((Lt=i.settings)==null?void 0:Lt.strength)||.8;p<(e.width||100)&&this.isMouseDown?(n.scale_y=this.lerp(n.scale_y??1,(((Wt=e.transform)==null?void 0:Wt.scale_y)??1)*Z,.3),n.scale_x=this.lerp(n.scale_x??1,(((q=e.transform)==null?void 0:q.scale_x)??1)*(1+(1-Z)*.4),.3)):(n.scale_y=this.lerp(n.scale_y??1,((ft=e.transform)==null?void 0:ft.scale_y)??1,.2),n.scale_x=this.lerp(n.scale_x??1,((Bt=e.transform)==null?void 0:Bt.scale_x)??1,.2))}else if(i.type===tt.TextCounter){const Z=((Ot=i.settings)==null?void 0:Ot.duration)||2,nt=((Pt=i.settings)==null?void 0:Pt.from)||0,et=((vt=i.settings)==null?void 0:vt.to)||100;i._runtimeStart===void 0&&(i._runtimeStart=this.currentTime);const pt=this.currentTime-i._runtimeStart,$t=Math.min(1,pt/Z),xt=Math.floor(nt+(et-nt)*$t);if(((Yt=e.geometry)==null?void 0:Yt.type)==="Text"){const Jt=((zt=i.settings)==null?void 0:zt.prefix)||"",pe=((Gt=i.settings)==null?void 0:Gt.suffix)||"";n.geometry||(n.geometry={...e.geometry}),n.geometry.text=`${Jt}${xt}${pe}`}}else if(i.type===tt.Spotlight){const Z=((Dt=i.settings)==null?void 0:Dt.radius)||250,nt=((te=i.settings)==null?void 0:te.strength)||1.5;if(p<Z){const et=Math.pow(1-p/Z,2);n.style||(n.style={...e.style}),n.style.adjustments||(n.style.adjustments={...(ie=e.style)==null?void 0:ie.adjustments}),n.style.adjustments.exposure=(((ve=(ce=e.style)==null?void 0:ce.adjustments)==null?void 0:ve.exposure)||0)+et*nt*50}else(_e=n.style)!=null&&_e.adjustments&&(n.style.adjustments.exposure=this.lerp(n.style.adjustments.exposure||0,((Ee=(ge=e.style)==null?void 0:ge.adjustments)==null?void 0:Ee.exposure)||0,.1))}else if(i.type===tt.Noise||i.type===tt.Float){const Z=(((Zt=i.settings)==null?void 0:Zt.frequency)||((Me=i.settings)==null?void 0:Me.speed)||1)*.002,nt=(((Re=i.settings)==null?void 0:Re.amplitude)||((Ie=i.settings)==null?void 0:Ie.range)||50)*(((de=i.settings)==null?void 0:de.strength)||1),et=Date.now();n.x+=Math.sin(et*Z)*nt*t,n.y+=Math.cos(et*Z*.8)*nt*t,n.rotation+=Math.sin(et*Z*.5)*5*t}else if(i.type===tt.Pulse){const Z=(((me=i.settings)==null?void 0:me.speed)||1)*.005,nt=(((Ae=i.settings)==null?void 0:Ae.scale)||1.2)-1,et=Math.sin(Date.now()*Z),pt=((he=i.settings)==null?void 0:he.strength)||1;n.scale_x*=1+et*nt*pt*t,n.scale_y*=1+et*nt*pt*t,n.style&&(n.style.exposure=(n.style.exposure||1)+Math.max(0,et)*.1*pt*t)}else if(i.type===tt.Draggable){if(!this.draggingBehaviors.has(e.id)){const nt=((mt=i.settings)==null?void 0:mt.radius)||150;if(p<nt){const et=((rt=i.settings)==null?void 0:rt.strength)||1,pt=Math.max(0,1-p/nt);this.applyBehaviorSensor(n,re.PositionX,pt*et,t,i.settings,e,l,d,p),this.applyBehaviorSensor(n,re.PositionY,pt*et,t,i.settings,e,l,d,p)}}}else if(i.type===tt.Scroll){const Z=((z=i.settings)==null?void 0:z.axis)||"vertical",nt=((K=i.settings)==null?void 0:K.factor)||.5,et=((G=i.settings)==null?void 0:G.strength)||1,pt=((x=i.settings)==null?void 0:x.scaleFactor)||0;(Z==="vertical"||Z==="both")&&(n.y+=this.scrollOffset.y*nt*et*t),(Z==="horizontal"||Z==="both")&&(n.x+=this.scrollOffset.x*nt*et*t),pt!==0&&(n.scale_x*=1+this.scrollOffset.y*pt*t,n.scale_y*=1+this.scrollOffset.y*pt*t)}else if(i.type===tt.LookAt){const Z=((Q=i.settings)==null?void 0:Q.factor)||1,nt=((H=i.settings)==null?void 0:H.strength)||1,et=Math.atan2(-d,-l)*(180/Math.PI),pt=n.rotation,$t=(et-pt+180)%360-180;n.rotation+=$t*Z*nt*t*10}else if(i.type===tt.Scan){const Z=(((lt=i.settings)==null?void 0:lt.speed)||1)*.004,nt=((kt=i.settings)==null?void 0:kt.strength)||1,et=(Math.sin(Date.now()*Z)+1)/2;n.style&&(n.style.exposure=(n.style.exposure||1)+et*nt*t*5),n.x+=(et-.5)*20*nt*t}else if(i.type===tt.Glint)n.style=n.style||{...e.style},n.style.artEffect={enabled:!0,type:"glint_overlay",intensity:((At=i.settings)==null?void 0:At.strength)??.8};else if(i.type===tt.Ratchet){const Z=((Ht=i.settings)==null?void 0:Ht.steps)||12,nt=(((Ut=i.settings)==null?void 0:Ut.speed)||1)*30,et=Math.floor(n.rotation/(360/Z))*(360/Z);n.rotation=this.lerp(n.rotation,et+nt*t,.1)}else if(i.type===tt.Jitter&&p<300){const Z=((qt=i.settings)==null?void 0:qt.strength)||1,nt=((($=i.settings)==null?void 0:$.intensity)||5)*Z;n.x+=(Math.random()-.5)*nt*t*60,n.y+=(Math.random()-.5)*nt*t*60,n.rotation+=(Math.random()-.5)*nt*t*120}else if(i.type===tt.Follower){const Z=(dt=i.settings)==null?void 0:dt.targetId;if(Z){const nt=this.objectStates.get(Z);if(nt){const et=((Rt=i.settings)==null?void 0:Rt.stiffness)||.1,pt=nt.x-n.x,$t=nt.y-n.y;n.x+=pt*et*t*60,n.y+=$t*et*t*60}}}else if(i.type===tt.Wrap)n.x<0?n.x=this.canvasWidth:n.x>this.canvasWidth&&(n.x=0),n.y<0?n.y=this.canvasHeight:n.y>this.canvasHeight&&(n.y=0);else if(i.type===tt.Gravity){const Z=((Nt=i.settings)==null?void 0:Nt.strength)||9.8;n.y+=Z*t*10}else if(i.type===tt.Velocity){const Z=((st=i.settings)==null?void 0:st.vx)||0,nt=((yt=i.settings)==null?void 0:yt.vy)||0;n.x+=Z*t*10,n.y+=nt*t*10}else if(i.type===tt.Shear){const Z=((St=i.settings)==null?void 0:St.strength)||1,nt=((ee=i.settings)==null?void 0:ee.radius)||300;if(p<nt){const et=1-p/nt;n.skew_x=this.lerp(n.skew_x||0,(((Ct=e.transform)==null?void 0:Ct.skew_x)||0)+et*Z*30,.1)}else n.skew_x=this.lerp(n.skew_x||0,((Vt=e.transform)==null?void 0:Vt.skew_x)||0,.05)}else if(i.type===tt.Lens){const Z=((Tt=i.settings)==null?void 0:Tt.radius)||200,nt=((Xt=i.settings)==null?void 0:Xt.strength)||.5;if(p<Z){const et=Math.pow(1-p/Z,2);n.scale_x=this.lerp(n.scale_x??1,(((Ft=e.transform)==null?void 0:Ft.scale_x)??1)*(1+et*nt),.2),n.scale_y=this.lerp(n.scale_y??1,(((le=e.transform)==null?void 0:le.scale_y)??1)*(1+et*nt),.2)}else n.scale_x=this.lerp(n.scale_x??1,((fe=e.transform)==null?void 0:fe.scale_x)??1,.1),n.scale_y=this.lerp(n.scale_y??1,((Oe=e.transform)==null?void 0:Oe.scale_y)??1,.1)}else if(i.type===tt.LayoutAnimation){const Z=((jt=i.settings)==null?void 0:jt.watchProperties)||["x","y","scale_x","scale_y","opacity","rotation"],nt=((oe=i.settings)==null?void 0:oe.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const et=this._layoutAnimCache.get(e.id);for(const pt of Z){const $t=this.getObjectProperty(n,e,pt);if($t===void 0)continue;const xt=et.get(pt);if(!xt)et.set(pt,{from:$t,to:$t,startTime:this.currentTime,duration:0});else if(xt.to!==$t){const pe=this.getObjectProperty(n,e,pt);et.set(pt,{from:pe??xt.from,to:$t,startTime:this.currentTime,duration:((ne=i.settings)==null?void 0:ne.duration)??nt})}const Jt=et.get(pt);if(Jt.duration>0&&Jt.from!==Jt.to){const pe=this.currentTime-Jt.startTime,Te=Math.min(1,pe/Jt.duration),$e=this.applyEasing(Te,((Fe=i.settings)==null?void 0:Fe.easing)||"easeOutCubic"),ye=Jt.from+(Jt.to-Jt.from)*$e;this.setObjectProperty(n,e,pt,ye)}}}else if(i.type===tt.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const Z=this._layoutAnimCache.get(e.id),nt=((Be=i.settings)==null?void 0:Be.defaultDuration)||.3,et=["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 pt of et){const $t=this.getObjectProperty(n,e,pt);if($t===void 0||typeof $t!="number")continue;const xt=Z.get(pt);if(!xt)Z.set(pt,{from:$t,to:$t,startTime:this.currentTime,duration:0});else if(xt.to!==$t){const pe=this.getObjectProperty(n,e,pt);Z.set(pt,{from:pe??xt.from,to:$t,startTime:this.currentTime,duration:nt})}const Jt=Z.get(pt);if(Jt.duration>0&&Jt.from!==Jt.to){const pe=this.currentTime-Jt.startTime,Te=Math.min(1,pe/Jt.duration),$e=this.applyEasing(Te,((xe=i.settings)==null?void 0:xe.defaultEasing)||"easeOutCubic"),ye=Jt.from+(Jt.to-Jt.from)*$e;this.setObjectProperty(n,e,pt,ye)}}}else if(i.type===tt.SpringChain){const Z=((We=i.settings)==null?void 0:We.connections)||[],nt=((De=i.settings)==null?void 0:De.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const et=this._springChainState.get(e.id);for(const $t of Z){if(!et.has($t.targetId)){const xt=this.objectStates.get($t.targetId);et.set($t.targetId,{x:(xt==null?void 0:xt.x)??0,y:(xt==null?void 0:xt.y)??0,vx:0,vy:0})}et.has(e.id)||et.set(e.id,{x:n.x,y:n.y,vx:0,vy:0})}const pt=et.get(e.id);if(pt){pt.x=n.x,pt.y=n.y;for(const $t of Z){const xt=et.get($t.targetId);if(!xt)continue;const Jt=xt.x-pt.x,pe=xt.y-pt.y,Te=Math.sqrt(Jt*Jt+pe*pe)||.001,ye=(Te-($t.restLength||50))*($t.stiffness||.8),Le=Jt/Te*ye,Qe=pe/Te*ye;pt.vx+=Le*t*10,pt.vy+=Qe*t*10,xt.vx-=Le*t*10,xt.vy-=Qe*t*10,pt.vx*=1-nt*t*10,pt.vy*=1-nt*t*10,xt.vx*=1-nt*t*10,xt.vy*=1-nt*t*10;const Pe=this.objectStates.get($t.targetId);Pe&&(Pe.x+=xt.vx*t,Pe.y+=xt.vy*t)}n.x+=pt.vx*t,n.y+=pt.vy*t}}else if(i.type===tt.ParticleEmitter){const Z=((Ye=i.settings)==null?void 0:Ye.rate)||10,nt=((Ge=i.settings)==null?void 0:Ge.speed)||100,et=((se=i.settings)==null?void 0:se.size)||5,pt=((ue=i.settings)==null?void 0:ue.lifetime)||2,$t=((Se=i.settings)==null?void 0:Se.gravity)||0,xt=((Xe=i.settings)==null?void 0:Xe.color)||"#ffffff",Jt=((Ne=i.settings)==null?void 0:Ne.maxParticles)||200,pe=(ke=i.settings)!=null&&ke.rateInputId?this.inputs.get(i.settings.rateInputId)??Z:Z,Te=(Ce=i.settings)!=null&&Ce.gravityInputId?this.inputs.get(i.settings.gravityInputId)??$t:$t,$e=(we=i.settings)!=null&&we.speedInputId?this.inputs.get(i.settings.speedInputId)??nt:nt;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const ye=this._emitterPools.get(e.id);let Le=0;i._pendingBurst&&i._pendingBurst>0&&(Le=i._pendingBurst,i._pendingBurst=0);const Qe=Math.floor(pe*t)+(Le||0);for(let Pe=0;Pe<Math.min(Qe,Jt-ye.length);Pe++){const be=Math.random()*Math.PI*2,ms=$e*(.5+Math.random()*.5);ye.push({x:n.x,y:n.y,vx:Math.cos(be)*ms,vy:Math.sin(be)*ms,life:0,maxLife:pt*(.5+Math.random()*.5),size:et*(.5+Math.random()),color:xt,opacity:1})}for(let Pe=ye.length-1;Pe>=0;Pe--){const be=ye[Pe];be.vy+=Te*t*10,be.x+=be.vx*t,be.y+=be.vy*t,be.life+=t,be.opacity=Math.max(0,1-be.life/be.maxLife),be.life>=be.maxLife&&ye.splice(Pe,1)}}})})}applyBehaviorSensor(t,s,o,e,n,i,a=0,r=0,l=1){var h,f,v,g,c,b,S,w,C,M,I,_,E,P,L,k,A,T,R,F,O,W,V,U;const d=(n==null?void 0:n.intensity)||(n==null?void 0:n.strength)||1,p=Math.min(1,15*e),u=l>0?a/l:0,m=l>0?r/l:0;switch(s){case re.Scale:{const D=((h=i==null?void 0:i.transform)==null?void 0:h.scale_x)??1,Y=((f=i==null?void 0:i.transform)==null?void 0:f.scale_y)??1,ot=D*(1+o*d*.4),J=Y*(1+o*d*.4);t.scale_x=(t.scale_x??D)*(1-p)+ot*p,t.scale_y=(t.scale_y??Y)*(1-p)+J*p;break}case re.Opacity:{const D=((v=i==null?void 0:i.transform)==null?void 0:v.opacity)??100,Y=Math.max(0,Math.min(100,D-o*d*100));t.opacity=(t.opacity??D)*(1-p)+Y*p;break}case re.RotateZ:{const D=((g=i==null?void 0:i.transform)==null?void 0:g.rotation)??0,Y=D+o*d*45;t.rotation=(t.rotation??D)*(1-p)+Y*p;break}case re.RotateX:{const D=((c=i==null?void 0:i.transform)==null?void 0:c.rotate_x)??0,Y=D-m*o*d*60;t.rotate_x=(t.rotate_x??D)*(1-p)+Y*p;break}case re.RotateY:{const D=((b=i==null?void 0:i.transform)==null?void 0:b.rotate_y)??0,Y=D+u*o*d*60;t.rotate_y=(t.rotate_y??D)*(1-p)+Y*p;break}case re.PositionX:{const D=((S=i==null?void 0:i.transform)==null?void 0:S.x)??0,Y=D-u*o*d*40;t.x=(t.x??D)*(1-p)+Y*p;break}case re.PositionY:{const D=((w=i==null?void 0:i.transform)==null?void 0:w.y)??0,Y=D-m*o*d*40;t.y=(t.y??D)*(1-p)+Y*p;break}case re.SkewX:{const D=((C=i==null?void 0:i.transform)==null?void 0:C.skew_x)??0,Y=D+u*o*d*45;t.skew_x=(t.skew_x??D)*(1-p)+Y*p,t.skew_x>85&&(t.skew_x=85),t.skew_x<-85&&(t.skew_x=-85);break}case re.Blur:{t.style||(t.style={...i==null?void 0:i.style}),t.style.blur||(t.style.blur={...(M=i==null?void 0:i.style)==null?void 0:M.blur});const D=((_=(I=i==null?void 0:i.style)==null?void 0:I.blur)==null?void 0:_.amount)||0,Y=D+o*((n==null?void 0:n.blur)||20)*d;t.style.blur.amount=(t.style.blur.amount??D)*(1-p)+Y*p;break}case re.Exposure:{t.style||(t.style={...i==null?void 0:i.style}),t.style.adjustments||(t.style.adjustments={...(E=i==null?void 0:i.style)==null?void 0:E.adjustments});const D=((L=(P=i==null?void 0:i.style)==null?void 0:P.adjustments)==null?void 0:L.exposure)||0,Y=D+o*((n==null?void 0:n.exposure)||50)*d;t.style.adjustments.exposure=(t.style.adjustments.exposure??D)*(1-p)+Y*p;break}case re.HueShift:{t.style||(t.style={...i==null?void 0:i.style}),t.style.adjustments||(t.style.adjustments={...(k=i==null?void 0:i.style)==null?void 0:k.adjustments});const D=((T=(A=i==null?void 0:i.style)==null?void 0:A.adjustments)==null?void 0:T.hue)||0,Y=D+o*((n==null?void 0:n.hue)||180)*d;t.style.adjustments.hue=(t.style.adjustments.hue??D)*(1-p)+Y*p;break}case re.Negative:{t.style||(t.style={...i==null?void 0:i.style}),t.style.adjustments||(t.style.adjustments={...(R=i==null?void 0:i.style)==null?void 0:R.adjustments});const D=((O=(F=i==null?void 0:i.style)==null?void 0:F.adjustments)==null?void 0:O.negative)||0,Y=D+o*((n==null?void 0:n.negative)||100)*d;t.style.adjustments.negative=(t.style.adjustments.negative??D)*(1-p)+Y*p;break}case re.CornerRadius:{const D=((W=i==null?void 0:i.transform)==null?void 0:W.corner_radius)||0,Y=D+o*d*50;t.corner_radius=(t.corner_radius??D)*(1-p)+Y*p;break}case re.StrokeWidth:{t.style||(t.style={...i==null?void 0:i.style});const D=((V=i==null?void 0:i.style)==null?void 0:V.borderWidth)||0,Y=D+o*d*10;t.style.borderWidth=(t.style.borderWidth??D)*(1-p)+Y*p;break}case re.LetterSpacing:{t.geometry||(t.geometry={});const D=((U=i==null?void 0:i.geometry)==null?void 0:U.letterSpacing)||0,Y=D+o*d*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??D)*(1-p)+Y*p;break}}}getObjectProperty(t,s,o){const e=o.replace(/\[(\d+)\]/g,".$1").split(".");let n=t;for(const i of e){if(n==null||typeof n!="object")return;if(i==="style"&&t.style===void 0){n=s.style;continue}n=n[i]}return typeof n=="number"?n:void 0}setObjectProperty(t,s,o,e){const n=o.replace(/\[(\d+)\]/g,".$1").split(".");let i=t;for(let r=0;r<n.length-1;r++){const l=n[r];if(i[l]===void 0||i[l]===null){const d=s,p=n.slice(0,r+1).reduce((h,f)=>h==null?void 0:h[f],d),u=n[r+1],m=!isNaN(Number(u));i[l]=p!==void 0?Array.isArray(p)?[...p]:{...p}:m?[]:{}}i=i[l]}const a=n[n.length-1];i!=null&&(i[a]=e)}applyEasing(t,s){switch(s){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,s,o){return t*(1-o)+s*o}deepMerge(t,s){if(!t)return s;if(!s)return t;if(typeof t!="object"||typeof s!="object"||t===null||s===null)return s;if(Array.isArray(s)){if(!Array.isArray(t))return s;const e=[...t];for(let n=0;n<s.length;n++)s[n]&&typeof s[n]=="object"&&!Array.isArray(s[n])&&t[n]&&typeof t[n]=="object"?e[n]=this.deepMerge(t[n],s[n]):e[n]=s[n];return e}const o={...t};for(const e in s)Object.prototype.hasOwnProperty.call(s,e)&&(s[e]&&typeof s[e]=="object"&&!Array.isArray(s[e])?o[e]=this.deepMerge(t[e],s[e]):Array.isArray(s[e])?o[e]=this.deepMerge(t[e],s[e]):o[e]=s[e]);return o}processFabricAdjustmentsCanvas(t,s,o,e){if(!e)return t;const n=(e.exposure||0)/100,i=(e.contrast||0)/100,a=(e.saturation||0)/100,r=(e.temperature||0)/200,l=(e.tint||0)/200,d=(e.highlights||0)/500,p=(e.shadows||0)/500,u=e.hue||0,m=(e.negative||0)/100,h=e.blur||0;if(!(n!==0||i!==0||a!==0||r!==0||l!==0||d!==0||p!==0||u!==0||m!==0||h>0))return t;const v=t.naturalWidth||Math.max(1,Math.round(s)),g=t.naturalHeight||Math.max(1,Math.round(o)),c=document.createElement("canvas");c.width=v,c.height=g;const b=c.getContext("2d");if(!b)return t;const S=[];h>0&&S.push(`blur(${h}px)`),u!==0&&S.push(`hue-rotate(${Math.round(u)}deg)`),S.length>0&&(b.filter=S.join(" ")),b.drawImage(t,0,0,v,g);try{const w=b.getImageData(0,0,v,g),C=w.data,M=C.length,I=n*255,_=i>=0?(1+i)/Math.max(.01,1-i):1+i,E=1+a,P=1+r-l/2,L=1+l,k=1-r-l/2,A=1+d+p,T=p*25.5,R=1-m/50,F=(1-R)*255;for(let O=0;O<M;O+=4){let W=C[O],V=C[O+1],U=C[O+2];if(n!==0&&(W+=I,V+=I,U+=I),i!==0&&(W=(W-127.5)*_+127.5,V=(V-127.5)*_+127.5,U=(U-127.5)*_+127.5),a!==0){const D=.2989*W+.587*V+.114*U;W=D+(W-D)*E,V=D+(V-D)*E,U=D+(U-D)*E}(r!==0||l!==0)&&(W=W*P,V=V*L,U=U*k),(d!==0||p!==0)&&(W=W*A+T,V=V*A+T,U=U*A+T),m!==0&&(W=W*R+F,V=V*R+F,U=U*R+F),C[O]=Math.min(255,Math.max(0,W)),C[O+1]=Math.min(255,Math.max(0,V)),C[O+2]=Math.min(255,Math.max(0,U))}return b.putImageData(w,0,0),c}catch{return c}}renderFittedImage(t,s,o,e,n,i,a="cover"){const r=s.naturalWidth||s.width||n,l=s.naturalHeight||s.height||i,d=r/l,p=n/i;let u=n,m=i,h=o,f=e;a==="cover"?d>p?(u=i*d,h=o-(u-n)/2):(m=n/d,f=e-(m-i)/2):a==="contain"&&(d>p?(m=n/d,f=e+(i-m)/2):(u=i*d,h=o+(n-u)/2)),t.drawImage(s,h,f,u,m)}}const ai=_t.forwardRef(({artboard:y,src:t,style:s,autoPlay:o=!0,fit:e="Contain",alignment:n="Center",onReady:i,onTrigger:a,onInputUpdate:r,onComponentChange:l,onToggle:d,onInputChange:p,onInputFocus:u,onInputBlur:m,onLog:h,onLogicUpdate:f,onButtonClick:v,onGraphPointClick:g,currentTime:c,revision:b=0,scrollY:S,scrollX:w,mouseX:C,mouseY:M,isMouseDown:I,inputs:_,interactive:E=!0,onNavigation:P},L)=>{const k=_t.useRef(null),A=_t.useRef(null);A.current||(A.current=new gs);const T=_t.useRef(void 0),R=_t.useRef(0),F=_t.useRef(null),O=_t.useRef(b),W=_t.useRef(null),[,V]=_t.useState(y||null),U=_t.useRef(!0),D=_t.useRef(o),Y=_t.useRef(c);_t.useEffect(()=>{D.current=o},[o]),_t.useEffect(()=>{Y.current=c},[c]),_t.useImperativeHandle(L,()=>k.current),_t.useEffect(()=>(U.current=!0,()=>{U.current=!1,T.current&&cancelAnimationFrame(T.current)}),[]),_t.useEffect(()=>{A.current.setLayout(e,n)},[e,n]),_t.useEffect(()=>{const B=A.current;a&&B.setTriggerCallback(a),r&&B.setInputUpdateCallback((X,N)=>r({[X]:N})),l&&B.setComponentChangeCallback(X=>l(X)),d&&B.setToggleCallback(d),p&&B.setInputChangeCallback(p),u&&B.setInputFocusCallback(u),m&&B.setInputBlurCallback(m),h&&B.setOnLogCallback(X=>h(X,"info")),f&&B.setLogicUpdateCallback(f),v&&B.setButtonClickCallback(v),g&&B.setGraphPointClickCallback(X=>g(X.objectId,X)),P&&B.setNavigationCallback(P)},[a,r,l,d,p,u,m,h,f,v,g,P]),_t.useEffect(()=>{(async()=>{let X=y;if(t&&!y)try{t.startsWith("{")?X=JSON.parse(t):X=await(await fetch(t)).json()}catch(N){console.error("[ExodeUI] Failed to load src:",N)}if(X){const N=A.current,ct=X.id||X.name||"default";(F.current!==ct||O.current!==b||W.current!==X)&&(N.load(X),F.current=ct,O.current=b,W.current=X,V(X),R.current=-1,N.advance(0)),i&&i(N)}})()},[y,t,b]),_t.useEffect(()=>{const B=X=>{if(!A.current||!U.current)return;const N=A.current,ct=k.current;if(!ct)return;const Mt=ct.getContext("2d");if(!Mt)return;const bt=X/1e3;R.current<0&&(R.current=bt),R.current===0&&(R.current=bt);let wt=bt-R.current;wt>.1&&(wt=.1),R.current=bt;const gt=ct.getBoundingClientRect(),It=window.devicePixelRatio||1,ut=Math.round(gt.width*It),Lt=Math.round(gt.height*It);(ct.width!==ut||ct.height!==Lt)&&(ct.width=ut,ct.height=Lt);try{D.current?N.advance(wt):Y.current!==void 0&&N.seek(Y.current),N.render(Mt,ct.width,ct.height)}catch(Wt){console.error("[ExodeUICanvas] Error in animation loop:",Wt),h&&h(`[Error] Animation loop crashed: ${Wt}`,"error")}T.current=requestAnimationFrame(B)};return T.current=requestAnimationFrame(B),()=>{T.current&&cancelAnimationFrame(T.current)}},[]),_t.useEffect(()=>{const B=A.current;S!==void 0&&B.updateInput("scrollY",S),w!==void 0&&B.updateInput("scrollX",w),C!==void 0&&B.updateInput("mouseX",C),M!==void 0&&B.updateInput("mouseY",M),I!==void 0&&B.updateInput("isMouseDown",I),_&&Object.entries(_).forEach(([X,N])=>B.updateInput(X,N))},[S,w,C,M,I,_]);const ot=(B,X)=>{if(!E||!k.current)return;B.stopPropagation(),"nativeEvent"in B&&B.nativeEvent&&typeof B.nativeEvent.stopImmediatePropagation=="function"?B.nativeEvent.stopImmediatePropagation():typeof B.stopImmediatePropagation=="function"&&B.stopImmediatePropagation();const N=k.current,ct=N.getBoundingClientRect(),Mt=B.clientX-ct.left,bt=B.clientY-ct.top,wt=window.devicePixelRatio||1;(X==="click"||X==="down"||X==="up")&&h&&h(`[Canvas] Pointer ${X} at rect(${Math.round(Mt)},${Math.round(bt)}) mapped to buffer(${Math.round(Mt*wt)},${Math.round(bt*wt)})`,"info"),A.current.handlePointerInput(X,Mt*wt,bt*wt,N.width,N.height)};_t.useEffect(()=>{if(!E)return;const B=N=>{var ct,Mt,bt;((ct=document.activeElement)==null?void 0:ct.tagName)==="INPUT"||((Mt=document.activeElement)==null?void 0:Mt.tagName)==="TEXTAREA"||(bt=A.current)==null||bt.handleKeyDown(N)},X=N=>{var ct,Mt,bt;((ct=document.activeElement)==null?void 0:ct.tagName)==="INPUT"||((Mt=document.activeElement)==null?void 0:Mt.tagName)==="TEXTAREA"||(bt=A.current)==null||bt.handleKeyUp(N)};return window.addEventListener("keydown",B),window.addEventListener("keyup",X),()=>{window.removeEventListener("keydown",B),window.removeEventListener("keyup",X)}},[E]),_t.useEffect(()=>{const B=k.current;if(!B||!E)return;const X=N=>{if(N.preventDefault(),N.stopPropagation(),A.current){const ct=B.getBoundingClientRect(),Mt=window.devicePixelRatio||1,bt=(N.clientX-ct.left)*Mt,wt=(N.clientY-ct.top)*Mt;let gt=N.deltaX,It=N.deltaY;N.deltaMode===1?(gt*=25,It*=25):N.deltaMode===2&&(gt*=100,It*=100),A.current.handlePointerInput("move",bt,wt,B.width,B.height),A.current.handleWheel(gt,It,bt,wt,B.width,B.height)}};return B.addEventListener("wheel",X,{passive:!1}),()=>{B.removeEventListener("wheel",X)}},[E]);const[J,at]=_t.useState([]);_t.useEffect(()=>{if(y&&y.objects){const B=y.objects.filter(X=>{var N,ct;return X.type==="Joystick"&&((N=X.inputBinding)==null?void 0:N.type)==="keyboard"&&((ct=X.inputBinding.keyboardConfig)==null?void 0:ct.showVirtualKeyboard)});at(B)}},[y]);const[,j]=_t.useState(0);_t.useEffect(()=>{if(J.length===0)return;let B;const X=()=>{j(N=>N+1),B=requestAnimationFrame(X)};return B=requestAnimationFrame(X),()=>cancelAnimationFrame(B)},[J.length]);const it=()=>J.map(B=>{const X=B.inputBinding.keyboardConfig,N=gt=>{var ut;const It={key:gt,code:gt,preventDefault:()=>{}};(ut=A.current)==null||ut.handleKeyDown(It)},ct=gt=>{var ut;const It={key:gt,code:gt,preventDefault:()=>{}};(ut=A.current)==null||ut.handleKeyUp(It)},Mt=A.current,bt=gt=>Mt&&Mt.activeKeys?Mt.activeKeys.has(gt.toLowerCase()):!1,wt=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 Qt.jsxs("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",pointerEvents:"auto",zIndex:100},children:[Qt.jsx("div",{style:wt(bt(X.upKey)),onMouseDown:()=>N(X.upKey),onMouseUp:()=>ct(X.upKey),onMouseLeave:()=>ct(X.upKey),onTouchStart:gt=>{gt.preventDefault(),N(X.upKey)},onTouchEnd:gt=>{gt.preventDefault(),ct(X.upKey)},children:X.upKey.toUpperCase()}),Qt.jsxs("div",{style:{display:"flex",gap:"8px"},children:[Qt.jsx("div",{style:wt(bt(X.leftKey)),onMouseDown:()=>N(X.leftKey),onMouseUp:()=>ct(X.leftKey),onMouseLeave:()=>ct(X.leftKey),onTouchStart:gt=>{gt.preventDefault(),N(X.leftKey)},onTouchEnd:gt=>{gt.preventDefault(),ct(X.leftKey)},children:X.leftKey.toUpperCase()}),Qt.jsx("div",{style:wt(bt(X.downKey)),onMouseDown:()=>N(X.downKey),onMouseUp:()=>ct(X.downKey),onMouseLeave:()=>ct(X.downKey),onTouchStart:gt=>{gt.preventDefault(),N(X.downKey)},onTouchEnd:gt=>{gt.preventDefault(),ct(X.downKey)},children:X.downKey.toUpperCase()}),Qt.jsx("div",{style:wt(bt(X.rightKey)),onMouseDown:()=>N(X.rightKey),onMouseUp:()=>ct(X.rightKey),onMouseLeave:()=>ct(X.rightKey),onTouchStart:gt=>{gt.preventDefault(),N(X.rightKey)},onTouchEnd:gt=>{gt.preventDefault(),ct(X.rightKey)},children:X.rightKey.toUpperCase()})]})]},B.id)});return Qt.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[Qt.jsx("canvas",{ref:k,onPointerDown:B=>{var X;ot(B,"down"),B.currentTarget.setPointerCapture(B.pointerId),(X=k.current)==null||X.focus()},onPointerMove:B=>ot(B,"move"),onPointerUp:B=>{ot(B,"up"),B.currentTarget.releasePointerCapture(B.pointerId)},onPointerCancel:B=>{ot(B,"up"),B.currentTarget.releasePointerCapture(B.pointerId)},onClick:B=>ot(B,"click"),onKeyDown:B=>A.current.handleKeyDown(B.nativeEvent),onKeyUp:B=>A.current.handleKeyUp(B.nativeEvent),onContextMenu:B=>B.preventDefault(),tabIndex:0,style:{...s,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:E?"auto":"none"}}),it()]})});function ri(){const[y,t]=_t.useState(null),s=_t.useCallback((g,c)=>{y==null||y.setInputBool(g,c)},[y]),o=_t.useCallback((g,c)=>{y==null||y.setInputNumber(g,c)},[y]),e=_t.useCallback(g=>{y==null||y.fireTrigger(g)},[y]),n=_t.useCallback((g,c)=>{y==null||y.setInputText(g,c)},[y]),i=_t.useCallback((g,c)=>{y==null||y.setInputNumberArray(g,c)},[y]),a=_t.useCallback((g,c)=>{y==null||y.setInputStringArray(g,c)},[y]),r=_t.useCallback((g,c)=>{y==null||y.updateInput(g,c)},[y]),l=r,d=_t.useCallback((g,c)=>{y==null||y.updateObjectOptions(g,c)},[y]),p=_t.useCallback((g,c,b)=>{y==null||y.updateConstraint(g,c,b)},[y]),u=_t.useCallback((g,c,b)=>{y==null||y.updateGraphData(g,c,b)},[y]),m=_t.useCallback((g,c,b)=>{y==null||y.updateBarChartData(g,c,b)},[y]),h=_t.useCallback((g,c)=>{y==null||y.updatePieChartData(g,c)},[y]),f=_t.useCallback((g,c)=>{y==null||y.setDropdownOptions(g,c)},[y]),v=_t.useCallback(g=>y==null?void 0:y.getInputValue(g),[y]);return{setEngine:t,engine:y,updateInput:r,setInputValue:l,setInputBool:s,setInputNumber:o,fireTrigger:e,setInputText:n,setInputNumberArray:i,setInputStringArray:a,updateConstraint:p,updateGraphData:u,updateBarChartData:m,updatePieChartData:h,setDropdownOptions:f,updateObjectOptions:d,getInputValue:v}}const li=({artboard:y,config:t})=>{const s={...y.seo,...t},o=s.enableSmartExtraction!==!1;_t.useEffect(()=>{const a=s.title||y.name;a&&(document.title=a);let r=s.description;if(!r&&o){const p=y.objects.filter(u=>{var m;return((m=u.geometry)==null?void 0:m.type)==="Text"}).sort((u,m)=>{var h,f;return(((h=m.geometry.text)==null?void 0:h.length)||0)-(((f=u.geometry.text)==null?void 0:f.length)||0)});p.length>0&&(r=p[0].geometry.text)}r&&(e("name","description",r),e("property","og:description",r)),s.keywords&&s.keywords.length>0&&e("name","keywords",s.keywords.join(", "));const l=s.ogImage||y.backgroundImage;l&&e("property","og:image",l),a&&e("property","og:title",a),e("property","og:type","website")},[s,y,o]);const e=(a,r,l)=>{let d=document.querySelector(`meta[${a}="${r}"]`);d||(d=document.createElement("meta"),d.setAttribute(a,r),document.head.appendChild(d)),d.setAttribute("content",l)},n=()=>{const a=[];return a.push(Qt.jsx("h1",{children:s.title||y.name},"artboard-title")),y.objects.forEach((l,d)=>{var p,u;if(!(l.visible===!1||l.isVisible===!1))if(((p=l.geometry)==null?void 0:p.type)==="Text"){const m=l.geometry.text;m&&(l.geometry.fontSize>24?a.push(Qt.jsx("h2",{children:m},l.id||d)):a.push(Qt.jsx("p",{children:m},l.id||d)))}else if(((u=l.geometry)==null?void 0:u.type)==="Image"){const m=l.geometry.src,h=l.altText||l.name||"Illustration";a.push(Qt.jsx("img",{src:m,alt:h},l.id||d))}else l.type==="Button"&&a.push(Qt.jsx("button",{children:l.name||"Button"},l.id||d))}),a},i=s.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:s.title||y.name,description:s.description,image:s.ogImage||y.backgroundImage,abstract:"Animated interface created with ExodeUI"};return Qt.jsxs("div",{id:`exode-seo-${y.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:[n(),Qt.jsx("script",{type:"application/ld+json",children:JSON.stringify(i)})]})},ci={version:"6.4.2"}.version;Kt.BAR_STYLE_PRESETS=oi,Kt.BehaviorSensor=re,Kt.BehaviorType=tt,Kt.ConditionOp=je,Kt.ExodeSEO=li,Kt.ExodeUICanvas=ai,Kt.ExodeUIEngine=gs,Kt.LogicOp=Et,Kt.RapierPhysics=is,Kt.VERSION=ci,Kt.useExodeUI=ri,Object.defineProperty(Kt,Symbol.toStringTag,{value:"Module"})}));
19
+ `);let rt=-r/2+(((me=e.padding)==null?void 0:me.top)??8);const z=Y*1.4,K=e.rows||3;let G=0,x=0;for(const Q of mt){if(G>=K)break;const H=Q.split(" ");let lt="";for(let kt=0;kt<H.length;kt++){const At=lt+H[kt]+" ";if(t.measureText(At).width>ft&&kt>0){if(G>=K)break;t.fillText(lt.trim(),q,rt),lt=H[kt]+" ",rt+=z,G++}else lt=At}G<K&&(t.fillText(lt.trim(),q,rt),x=t.measureText(lt.trim()).width,rt+=z,G++)}if(l&&!X&&Math.floor(performance.now()/500)%2===0){const Q=rt-z;t.fillStyle=R,t.fillRect(q+Math.min(x,ft),Q,1.5,Y)}}else{t.textBaseline="middle";const rt=t.measureText(Ot).width;let z=0;if(rt>ft&&(z=rt-ft),t.fillText(Ot,q-z,0),l&&Math.floor(performance.now()/500)%2===0){const K=X?q:q+rt-z;t.fillStyle=R,t.fillRect(K,-(Y/2),1.5,Y)}}if(t.restore(),e.showCharCounter){t.save();const mt=Number(e.maxLength||0),rt=mt>0?`${j.length}/${mt}`:`${j.length}`;t.font=`400 10px "${U}", sans-serif`,t.fillStyle=mt>0&&j.length>=mt?"#ef4444":"rgba(156, 163, 175, 0.6)",t.textAlign="right",t.textBaseline="top",t.fillText(rt,-(a/2)+a-8,-(r/2)+r+4),t.restore()}if(m.visible!==!1){const mt=!!(m.required||(Ae=e.validation)!=null&&Ae.required),rt=(m.text||"Label")+(mt?" *":""),z=m.fontSize||12,K=m.color||"rgba(156, 163, 175, 1)",G=m.position||"top",x=m.gap??m.offset??6;let Q=-(a/2),H=-(r/2)-x,lt="left",kt="bottom",At=`600 ${z}px "${m.fontFamily||U}", sans-serif`;G==="left"?(Q=-(a/2)-x,H=0,lt="right",kt="middle"):G==="bottom"?(Q=-(a/2),H=r/2+x,lt="left",kt="top"):G==="floating"&&(!!j||l?(Q=-(a/2)+12,H=-(r/2)+4,lt="left",kt="top",At=`600 ${Math.max(9,z-2)}px "${m.fontFamily||U}", sans-serif`):At=null),At&&(t.save(),t.font=At,t.fillStyle=K,t.textAlign=lt,t.textBaseline=kt,t.fillText(rt,Q,H),t.restore())}const vt=(he=e.validation)==null?void 0:he.errorMessage;if(b&&vt||h.visible===!0&&h.text){t.save();const mt=h.fontSize||11,rt=b?"#ef4444":h.color||"rgba(156, 163, 175, 1)",z=h.offset??6,K=b&&vt?vt:h.text;t.font=`400 ${mt}px "${U}", sans-serif`,t.fillStyle=rt,t.textAlign="left",t.textBaseline="top",t.fillText(K,-(a/2),r/2+z),t.restore()}c&&(t.save(),_(-a/2,-r/2,a,r,I),t.fillStyle="rgba(0, 0, 0, 0.3)",t.fill(),t.restore())}renderSlider(t,s){const o=this.objectStates.get(s.id),e=(o==null?void 0:o.geometry)||s.geometry,n=(o==null?void 0:o.options)||s.options||{},i=e.width||200,a=n.value??50,r=n.min??0,d=(n.max??100)-r,p=d===0?0:(a-r)/d,u=n.trackHeight||4,m=n.trackRoundedness??2,h=n.trackShape??"Rectangle",f=n.trackPath||"",v=n.accentColor||"#3b82f6",g=n.inactiveColor||"#374151",c=n.thumbShape||"Ellipse",b=n.thumbWidth??16,S=n.thumbHeight??16,w=n.thumbRoundedness??0,C=n.thumbColor||"#ffffff",M=n.thumbPath||"",I=n.thumbIcon||"",_=n.showValueTooltip??!1,E=n.tooltipBgColor||"#333333",P=n.tooltipColor||"#ffffff",L=n.tooltipOffsetX??0,k=n.tooltipOffsetY??-25,A=(J,at,j,it,B,X,N)=>{if((J==="Custom"||J==="Icon")&&N)try{const ct=new Path2D(N);if(t.save(),t.translate(at,j),J==="Icon"){const Mt=Math.min(it,B)/24;t.scale(Mt,Mt),t.translate(-12,-12)}t.fill(ct),t.restore();return}catch(ct){console.error("Error drawing slider shape in engine:",ct)}if(t.beginPath(),J==="Ellipse")t.ellipse(at,j,it/2,B/2,0,0,Math.PI*2);else if(J==="Rectangle")this.drawRoundRect(t,at-it/2,j-B/2,it,B,X);else if(J==="Triangle")t.moveTo(at,j-B/2),t.lineTo(at+it/2,j+B/2),t.lineTo(at-it/2,j+B/2),t.closePath();else if(J==="Diamond")t.moveTo(at,j-B/2),t.lineTo(at+it/2,j),t.lineTo(at,j+B/2),t.lineTo(at-it/2,j),t.closePath();else if(J==="Polygon"){const ct=s.geometry.sides||3,Mt=s.geometry.radius||Math.min(it,B)/2;for(let bt=0;bt<ct;bt++){const wt=bt*2*Math.PI/ct-Math.PI/2,gt=at+Mt*Math.cos(wt),It=j+Mt*Math.sin(wt);bt===0?t.moveTo(gt,It):t.lineTo(gt,It)}t.closePath()}else if(J==="Star"){const Mt=Math.min(it,B)/2,bt=Mt/2;for(let wt=0;wt<10;wt++){const gt=wt%2===0?Mt:bt,It=wt*Math.PI/5-Math.PI/2;t.lineTo(at+gt*Math.cos(It),j+gt*Math.sin(It))}t.closePath()}else J==="Line"&&(t.moveTo(at-it/2,j),t.lineTo(at+it/2,j));t.fill()},T=this.createCanvasFill(t,g,i,u);T&&(t.fillStyle=T,t.strokeStyle=T),h==="Line"?(t.lineWidth=u,t.beginPath(),t.moveTo(-i/2,0),t.lineTo(i/2,0),t.stroke()):A(h,0,0,i,u,m,f);const R=i-b,F=-i/2+b/2+p*R,O=F- -i/2;if(O>0){const J=this.createCanvasFill(t,v,i,u);J&&(t.fillStyle=J,t.strokeStyle=J),h==="Line"?(t.lineWidth=u,t.beginPath(),t.moveTo(-i/2,0),t.lineTo(F,0),t.stroke()):h==="Rectangle"&&(t.beginPath(),this.drawRoundRect(t,-i/2,-u/2,O,u,m),t.fill())}t.save(),t.translate(F,0);const W=t.getTransform(),V=Math.sqrt(W.a*W.a+W.b*W.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*V,t.shadowOffsetY=1*V;const U=this.createCanvasFill(t,C,b,S);if(U&&(t.fillStyle=U),A(c,0,0,b,S,w,c==="Icon"?I:M),t.restore(),_){t.save(),t.translate(F+L,k);const J=Math.round(a).toString();t.font="10px Inter, sans-serif";const at=t.measureText(J),j=6,it=4,B=at.width+j*2,X=14+it;t.beginPath(),this.drawRoundRect(t,-B/2,-X/2,B,X,4),t.fillStyle=E,t.fill(),t.fillStyle=P,t.textAlign="center",t.textBaseline="middle",t.fillText(J,0,0),t.restore()}const D=n.label||{},Y=n.helperText||{},ot=n.fontFamily||"Inter";if(D.visible!==!1){const J=D.text||"Label",at=D.fontSize||12,j=D.color||"rgba(156, 163, 175, 1)",it=D.offset??8;t.font=`600 ${at}px "${ot}", sans-serif`,t.fillStyle=j,t.textAlign="left",t.textBaseline="bottom";const B=-(i/2),X=-(u/2)-it;t.fillText(J,B,X)}if(Y.visible===!0){const J=Y.text||"Helper text",at=Y.fontSize||11,j=Y.color||"rgba(156, 163, 175, 1)",it=Y.offset??6;t.font=`400 ${at}px "${ot}", sans-serif`,t.fillStyle=j,t.textAlign="left",t.textBaseline="top";const B=-(i/2),X=u/2+it;t.fillText(J,B,X)}}renderDropdown(t,s){var k;const o=this.objectStates.get(s.id);if(!o)return;const e=o.options||s.options||{},n=s.geometry.width||180,i=s.geometry.height||40,a=-n/2,r=-i/2,l=e.cornerRadius??e.corner_radius??6,d=e.disabled||e.previewState==="disabled",p=this.lastHoveredObjectId===s.id||e.previewState==="hover",u=(e.isOpen||e.previewState==="active")&&!d;let m=e.backgroundColor,h=e.borderColor,f=e.color||"#333333";d?(m=e.disabledBackgroundColor||"#f3f4f6",h=e.disabledBorderColor||"#e5e7eb",f=e.disabledColor||"#9ca3af"):u?(m=e.activeBackgroundColor||m,h=e.activeBorderColor||h,f=e.activeColor||f):p&&(m=e.hoverBackgroundColor||m,h=e.hoverBorderColor||h,f=e.hoverColor||f),m||(m="#ffffff"),h||(h="#e5e7eb"),t.save();const v=t.globalAlpha;t.globalAlpha=v*(e.opacity??1),t.beginPath(),this.drawRoundRect(t,a,r,n,i,l),t.fillStyle=this.createCanvasFill(t,typeof m=="string"?{type:"Solid",color:m}:m,n,i)||"#ffffff",t.fill();const g=e.borderWidth??1;g>0&&(t.beginPath(),this.drawRoundRect(t,a,r,n,i,l),t.strokeStyle=this.createCanvasFill(t,typeof h=="string"?{type:"Solid",color:h}:h,n,i)||"#e5e7eb",t.lineWidth=g,t.stroke());const c=12,b=e.chevronType||"chevron",S=e.chevronSize||16,w=(u?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(b!=="none"){const A=a+n-c-S/2;t.save(),t.translate(A,0);const T=u?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(T*Math.PI/180),t.strokeStyle=w,t.fillStyle=w,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",b==="chevron")t.beginPath(),t.moveTo(-S/2,-S*.2),t.lineTo(0,S*.2),t.lineTo(S/2,-S*.2),t.stroke();else if(b==="custom"||b==="path"){const R=u&&e.openIconPath||e.closedIconPath;if(R){const F=new Path2D(R);t.save();const O=S/24;t.scale(O,O),t.translate(-12,-12),t.fill(F),t.restore()}}t.restore()}const C=e.selectedOption||e.placeholder||"Select...",M=e.fontSize||14,I=e.fontWeight||400,_=e.fontFamily||"Inter, sans-serif";t.font=`${I} ${M}px ${_}`;const E=d?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":f;t.fillStyle=this.createCanvasFill(t,typeof E=="string"?{type:"Solid",color:E}:E,n,i)||"#333333",t.textAlign="left",t.textBaseline="middle";const P=b==="none"?0:S+8,L=n-c*2-P;if(t.save(),t.beginPath(),t.rect(a+c,r,L,i),t.clip(),t.fillText(C,a+c,0),t.restore(),u&&!d){const A=r+i+4,T=this.getResolvedDropdownOptions(s,e),R=e.itemHeight||32,F=e.listPadding??4,O=T.length*R+F*2,W=e.listCornerRadius??l;t.save();const V=e.listShadow||{},U=t.getTransform(),D=Math.sqrt(U.a*U.a+U.b*U.b)||1;t.shadowColor=typeof V.color=="string"?V.color:((k=V.color)==null?void 0:k.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(V.blur??12)*D,t.shadowOffsetY=(V.offsetY??6)*D,t.shadowOffsetX=(V.offsetX??0)*D,t.beginPath(),this.drawRoundRect(t,a,A,n,O,W),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},n,O)||"#ffffff",t.fill();const Y=e.listBorderWidth??1;Y>0&&(t.shadowColor="transparent",t.beginPath(),this.drawRoundRect(t,a,A,n,O,W),t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:h},n,O)||"#e5e7eb",t.lineWidth=Y,t.stroke()),t.restore();const ot=e.itemFontSize||M,J=e.itemFontFamily||_;t.font=`${I} ${ot}px ${J}`,T.forEach((at,j)=>{const it=A+F+j*R;if(at===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},n,R)||"#f3f4f6",t.fillRect(a+Y,it,n-Y*2,R),t.fillStyle=e.itemSelectedColor||e.accentColor||f||"#374151";else if(t.fillStyle=e.listTextColor||f||"#333333",this.activeDropdownId===s.id&&this._lastPointerPos){const X=this._lastPointerPos.y-(A+F),N=Math.floor(X/R);j===N&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},n,R)||"#f9fafb",t.fillRect(a+Y,it,n-Y*2,R),t.fillStyle=e.itemHoverColor||f)}t.fillText(at,a+c,it+R/2)})}t.restore()}renderButton(t,s){var L;if(s.children&&s.children.length>0)return;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=s.geometry||{},i=n.width||s.width||160,a=n.height||s.height||45,r=this.lastHoveredObjectId===s.id,l=this.activeObjectId===s.id,d=e.label||{},p=e.hoverStyle||{},u=e.activeStyle||{},m=e.icon||{enabled:!1};let h=e.backgroundColor||e.buttonBgColor||((L=s.style)==null?void 0:L.fill)||"#3b82f6",f=(typeof d=="object"?d.color:null)||"#ffffff",v=typeof d=="string"?d:d.text||s.text||(s.name&&!s.name.toLowerCase().includes("component")?s.name:"Button"),g=n.cornerRadius??n.corner_radius??8,c=e.borderColor||"transparent",b=e.borderWidth||0,S=1;l&&u?(h=u.backgroundColor||h,f=u.color||f,v=u.text||v,S=u.scale??.95,g=u.cornerRadius??g):r&&p&&(h=p.backgroundColor||h,f=p.color||f,v=p.text||v,S=p.scale??1,g=p.cornerRadius??g,c=p.borderColor||c);const w=-i/2,C=-a/2;t.save(),t.scale(S,S),t.beginPath(),this.drawRoundRect(t,w,C,i,a,g);const M=this.createCanvasFill(t,h,i,a);M&&(t.fillStyle=M,t.fill()),(b>0||r&&p.borderColor)&&(t.strokeStyle=c,t.lineWidth=b||(r?1:0),t.stroke());const I=d.fontSize||14,_=d.fontFamily||"Inter",E=d.fontWeight||600;t.font=`${E} ${I}px "${_}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=f,t.textAlign="center",t.textBaseline="middle";let P=0;if(m.enabled&&m.svgPath){const k=I*1.1,A=m.gap||8,T=t.measureText(v),F=-(T.width+k+A)/2,O=m.position==="left"?F+k/2:F+T.width+A+k/2;P=m.position==="left"?F+k+A+T.width/2:F+T.width/2,t.save(),t.translate(O,0);const W=new Path2D(m.svgPath),V=k/24;t.scale(V,V),t.translate(-12,-12),t.fillStyle=f,t.fill(W),t.restore()}t.fillText(v,P,0),t.restore()}renderToggleButton(t,s){var v,g;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=e.checked??!1,i=((v=s.geometry)==null?void 0:v.width)||120,a=((g=s.geometry)==null?void 0:g.height)||40,r=-i/2,l=-a/2,d=e.corner_radius??8,p=e.label||{},u=n?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",m=n?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,r,l,i,a,d),t.fillStyle=u,t.fill();const h=p.fontSize||14,f=p.fontFamily||"Inter";t.font=`${p.fontWeight||600} ${h}px "${f}", sans-serif`,t.fillStyle=m,t.textAlign="center",t.textBaseline="middle",t.fillText(p.text||"Toggle",0,0),t.restore()}renderToggle(t,s){var W,V,U,D,Y,ot,J,at,j,it,B,X;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=((W=s.geometry)==null?void 0:W.width)||52,i=((V=s.geometry)==null?void 0:V.height)||30,a=-n/2,r=-i/2,l=e.checked??!1,d=e.cornerRadius??e.corner_radius??i/2,p=e.toggleStyle||{},u=p.backgroundColor||e.activeColor||"#10b981",m=p.borderColor||e.borderColor||"transparent",h=p.borderWidth??e.borderWidth??0,f=p.knobColor||e.knobColor||"#ffffff",v=l?u:e.inactiveColor||"#374151",g=l?m:e.borderColor||"transparent",c=l?h:e.borderWidth??0,b=l?f:e.knobColor||"#ffffff";e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,n,i,d);const S=this.createCanvasFill(t,v,n,i);if(S&&(t.fillStyle=S,t.fill()),c>0){t.lineWidth=c;const N=this.createCanvasFill(t,g,n,i);N&&(t.strokeStyle=N,t.stroke())}const w=2,C=i-w*2,M=C/2,I=a+w,_=a+n-w-C,E=l?_:I,P=r+w;t.beginPath(),t.arc(E+M,P+M,M,0,Math.PI*2);const L=this.createCanvasFill(t,b,C,C);L&&(t.fillStyle=L,t.fill()),e.disabled&&(t.globalAlpha*=2);let k=!1,A=!1;const T=(l?(U=p.leftLabel)==null?void 0:U.text:null)||((D=e.leftLabel)==null?void 0:D.text)||"",R=(l?(Y=p.leftLabel)==null?void 0:Y.color:null)||((ot=e.leftLabel)==null?void 0:ot.color)||"#f3f4f6";if((J=e.leftLabel)!=null&&J.enabled&&T){const N=e.leftLabel;t.font=`${N.fontWeight||400} ${N.fontSize||12}px "${N.fontFamily||"Inter"}", sans-serif`,t.fillStyle=R,t.textBaseline="middle",t.textAlign="right",t.fillText(T,a-(N.gap||8),0),k=!0}const F=(l?(at=p.rightLabel)==null?void 0:at.text:null)||((j=e.rightLabel)==null?void 0:j.text)||"",O=(l?(it=p.rightLabel)==null?void 0:it.color:null)||((B=e.rightLabel)==null?void 0:B.color)||"#f3f4f6";if((X=e.rightLabel)!=null&&X.enabled&&F){const N=e.rightLabel;t.font=`${N.fontWeight||400} ${N.fontSize||12}px "${N.fontFamily||"Inter"}", sans-serif`,t.fillStyle=O,t.textBaseline="middle",t.textAlign="left",t.fillText(F,a+n+(N.gap||8),0),A=!0}if(!k&&!A&&e.label&&e.label.text){const N=e.label,ct=N.fontSize||14,Mt=N.fontWeight||400,bt=N.fontFamily||"Inter";t.font=`${Mt} ${ct}px "${bt}", sans-serif`,t.fillStyle=N.color||"#f3f4f6",t.textBaseline="middle";const wt=N.gap||10;let gt=0,It=0;N.position==="left"?(t.textAlign="right",gt=a-wt,It=0):N.position==="right"?(t.textAlign="left",gt=a+n+wt,It=0):N.position==="top"?(t.textAlign="center",gt=0,It=r-wt,t.textBaseline="bottom"):N.position==="bottom"?(t.textAlign="center",gt=0,It=r+i+wt,t.textBaseline="top"):(t.textAlign="left",gt=a+n+wt,It=0),t.fillText(N.text,gt,It)}}renderCheckbox(t,s){var S,w;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=((S=s.geometry)==null?void 0:S.width)||20,i=((w=s.geometry)==null?void 0:w.height)||20,a=-n/2,r=-i/2,l=e.cornerRadius??4,d=e.checked??!1,p=e.activeColor||"#3b82f6",u=e.inactiveColor||"transparent",m=e.checkColor||"#ffffff",h=e.borderColor||"#4b5563",f=e.borderWidth??2,v=d?p:u,g=d?"transparent":h,c=d?0:f;e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,n,i,l);const b=this.createCanvasFill(t,v,n,i);if(b&&(t.fillStyle=b,t.fill()),c>0){t.lineWidth=c;const C=this.createCanvasFill(t,g,n,i);C&&(t.strokeStyle=C,t.stroke())}else if(d){t.lineWidth=1;const C=this.createCanvasFill(t,p,n,i);C&&(t.strokeStyle=C,t.stroke())}if(d){t.save(),t.beginPath();const C=this.createCanvasFill(t,m,n,i);t.strokeStyle=C||m,t.lineWidth=Math.max(2,n*.12),t.lineCap="round",t.lineJoin="round";const M=a+n*.25,I=r+i*.5,_=a+n*.45,E=r+i*.7,P=a+n*.75,L=r+i*.25;t.moveTo(M,I),t.lineTo(_,E),t.lineTo(P,L),t.stroke(),t.restore()}if(e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const C=e.label;t.save(),t.font=`${C.fontWeight||400} ${C.fontSize||14}px "${C.fontFamily||"Inter"}", sans-serif`,t.fillStyle=C.color||"#f3f4f6",t.textBaseline="middle";const M=C.gap||8;let I=0,_=0;C.position==="left"?(t.textAlign="right",I=a-M,_=0):C.position==="right"?(t.textAlign="left",I=a+n+M,_=0):C.position==="top"?(t.textAlign="center",I=0,_=r-M,t.textBaseline="bottom"):C.position==="bottom"&&(t.textAlign="center",I=0,_=r+i+M,t.textBaseline="top"),t.fillText(C.text,I,_),t.restore()}}renderRadioGroup(t,s){var _,E;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=((_=s.geometry)==null?void 0:_.width)||180,i=((E=s.geometry)==null?void 0:E.height)||100,a=-n/2,r=-i/2;let l=e.optionsList||["Option 1","Option 2","Option 3"];if(e.isDataVarEnabled&&e.dataInputId){let P=this.inputs.get(e.dataInputId);if(P===void 0){const L=this.inputNameMap.get(e.dataInputId);L&&L.length>0&&(P=this.inputs.get(L[0]))}P&&Array.isArray(P)&&(l=P.map(L=>typeof L=="string"?L:String(L)))}const d=e.selectedValue,p=e.orientation||"vertical",u=e.itemGap!==void 0?e.itemGap:16,m=e.activeColor||"#3b82f6",h=e.inactiveColor||"#4b5563",f=e.textColor||"#ffffff",v=e.fontSize||14,g=e.fontFamily||"Inter",c=e.fontWeight||400;t.save(),t.beginPath(),t.rect(a,r,n,i),t.clip(),e.disabled&&(t.globalAlpha*=.5);const b=8,S=b*2,w=e.radioShape||"circle",C=e.borderWidth!==void 0?e.borderWidth:2,M=e.fillEmpty||"transparent",I=(P,L,k,A)=>{if(t.beginPath(),A==="custom"&&e.customShapePath)try{const T=new Path2D(e.customShapePath);t.save(),t.translate(P-k,L-k),t.scale(k*2/24,k*2/24),t.fill(T),t.restore();return}catch{t.arc(P,L,k,0,Math.PI*2);return}if(A==="square"){const T=k*1.6;t.rect(P-T/2,L-T/2,T,T)}else if(A==="diamond"){const T=k*1.4;t.moveTo(P,L-T),t.lineTo(P+T,L),t.lineTo(P,L+T),t.lineTo(P-T,L),t.closePath()}else if(A==="heart"){const T=k*.9;t.moveTo(P,L+T*.7),t.bezierCurveTo(P-T*1.5,L-T*.3,P-T*.5,L-T*1.5,P,L-T*.5),t.bezierCurveTo(P+T*.5,L-T*1.5,P+T*1.5,L-T*.3,P,L+T*.7)}else if(A==="star"){const T=k*1.1,R=k*.5;for(let F=0;F<5;F++){const O=(F*72-90)*Math.PI/180,W=(F*72+36-90)*Math.PI/180;F===0?t.moveTo(P+T*Math.cos(O),L+T*Math.sin(O)):t.lineTo(P+T*Math.cos(O),L+T*Math.sin(O)),t.lineTo(P+R*Math.cos(W),L+R*Math.sin(W))}t.closePath()}else t.arc(P,L,k,0,Math.PI*2)};if(t.font=`${c} ${v}px "${g}", sans-serif`,t.textBaseline="middle",t.textAlign="left",p==="vertical"){const P=Math.max(S,v)+u,L=l.length*P-u,k=r+Math.max(0,(i-L)/2);l.forEach((A,T)=>{const R=k+b+T*P,F=d===A,O=this.createCanvasFill(t,m,S,S),W=this.createCanvasFill(t,h,S,S);F?(t.fillStyle=O||m,I(a+b,R,b,w),t.fill(),t.strokeStyle=O||m,t.lineWidth=C,I(a+b,R,b,w),t.stroke()):(M!=="transparent"&&(t.fillStyle=M,I(a+b,R,b,w),t.fill()),t.strokeStyle=W||h,t.lineWidth=C,I(a+b,R,b,w),t.stroke()),t.fillStyle=f,t.fillText(A,a+S+8,R)})}else{const P=r+i/2;let L=0;t.font=`${c} ${v}px "${g}", sans-serif`,l.forEach(T=>{L+=S+6+t.measureText(T).width+u}),L-=u;let A=a+Math.max(0,(n-L)/2);l.forEach(T=>{const R=d===T,F=t.measureText(T).width,O=this.createCanvasFill(t,m,S,S),W=this.createCanvasFill(t,h,S,S);R?(t.fillStyle=O||m,I(A+b,P,b,w),t.fill(),t.strokeStyle=O||m,t.lineWidth=C,I(A+b,P,b,w),t.stroke()):(M!=="transparent"&&(t.fillStyle=M,I(A+b,P,b,w),t.fill()),t.strokeStyle=W||h,t.lineWidth=C,I(A+b,P,b,w),t.stroke()),t.fillStyle=f,t.fillText(T,A+S+6,P),A+=S+6+F+u})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const P=e.label;t.save(),t.font=`${P.fontWeight||400} ${P.fontSize||14}px "${P.fontFamily||"Inter"}", sans-serif`,t.fillStyle=P.color||"#9ca3af",t.textBaseline="middle";const L=P.gap||8;let k=0,A=0;P.position==="left"?(t.textAlign="right",k=a-L,A=0):P.position==="right"?(t.textAlign="left",k=a+n+L,A=0):P.position==="top"?(t.textAlign="center",k=0,A=r-L,t.textBaseline="bottom"):P.position==="bottom"&&(t.textAlign="center",k=0,A=r+i+L,t.textBaseline="top"),t.fillText(P.text,k,A),t.restore()}}renderBarChart(t,s){var E,P,L;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{};let n={...e};if(e.isDataVarEnabled&&e.dataInputId){let k=this.inputs.get(e.dataInputId);if(k===void 0){const A=this.inputNameMap.get(e.dataInputId);A&&A.length>0&&(k=this.inputs.get(A[0]))}k&&Array.isArray(k)&&(n.categories=k.map(A=>typeof A=="string"?A:String(A)))}if(e.isDatasetsVarEnabled&&((E=e.datasetInputIds)==null?void 0:E.length)>0){const k=e.datasetInputIds.map((A,T)=>{var O;let R=this.inputs.get(A);if(R===void 0){const W=this.inputNameMap.get(A);W&&W.length>0&&(R=this.inputs.get(W[0]))}const F=((O=e.datasets)==null?void 0:O[T])||{id:`ds-${T}`,label:`Series ${T+1}`,data:[],color:"#6366f1"};return R&&Array.isArray(R)?{...F,data:R.map(W=>typeof W=="number"?W:parseFloat(W)||0)}:F});n.datasets=k}const i={width:((P=s.geometry)==null?void 0:P.width)||300,height:((L=s.geometry)==null?void 0:L.height)||180,chartType:n.chartType||"grouped",datasets:n.datasets||[{id:"ds-1",label:"Revenue",data:[42,67,31,55,78,48],color:"#6366f1"}],categories:n.categories||["Jan","Feb","Mar","Apr","May","Jun"],orientation:n.orientation||"vertical",barWidth:n.barWidth!==void 0?n.barWidth:14,barGap:n.barGap!==void 0?n.barGap:4,barCornerRadius:n.barCornerRadius!==void 0?n.barCornerRadius:5,showXAxis:!!n.showXAxis,showYAxis:!!n.showYAxis,xAxisColor:n.xAxisColor||"rgba(255,255,255,0.15)",yAxisColor:n.yAxisColor||"rgba(255,255,255,0.15)",showXLabels:n.showXLabels!==void 0?!!n.showXLabels:!0,showYLabels:!!n.showYLabels,axisLabelColor:n.axisLabelColor||"rgba(255,255,255,0.55)",axisLabelFontSize:n.axisLabelFontSize||9,showLegend:n.showLegend!==void 0?!!n.showLegend:!0,legendColor:n.legendColor||"rgba(255,255,255,0.7)",legendFontSize:n.legendFontSize||9,showGridLines:n.showGridLines!==void 0?!!n.showGridLines:!0,gridColor:n.gridColor||"rgba(255,255,255,0.06)",cardBackground:n.cardBackground||"#ffffff",cardBackgroundOpacity:n.cardBackgroundOpacity!==void 0?n.cardBackgroundOpacity:.04,cardBorderColor:n.cardBorderColor||"rgba(255,255,255,0.08)",barGradient:n.barGradient!==void 0?!!n.barGradient:!0,gradientStartColor:n.gradientStartColor||"",gradientEndOpacity:n.gradientEndOpacity!==void 0?n.gradientEndOpacity:.27,showValueOnTop:!!n.showValueOnTop,valueFontSize:n.valueFontSize||10,valueColor:n.valueColor||"",valueFontWeight:n.valueFontWeight||"bold",barStyle:n.barStyle||"solid",barBorderWidth:n.barBorderWidth!==void 0?n.barBorderWidth:1,barBorderColor:n.barBorderColor||"auto",enableShadows:!!n.enableShadows,shadowColor:n.shadowColor||"rgba(0,0,0,0.5)",shadowBlur:n.shadowBlur!==void 0?n.shadowBlur:4,shadowOffsetY:n.shadowOffsetY!==void 0?n.shadowOffsetY:2,xAxisLineWidth:n.xAxisLineWidth!==void 0?n.xAxisLineWidth:1,yAxisLineWidth:n.yAxisLineWidth!==void 0?n.yAxisLineWidth:1,gridLineWidth:n.gridLineWidth!==void 0?n.gridLineWidth:1,gridLineDash:n.gridLineDash||[3,4],_hexToRgb:function(k,A){if(k.startsWith("rgba")||k.startsWith("rgb"))return k;k.startsWith("#")||(k="#"+k),k.length===4&&(k="#"+k[1]+k[1]+k[2]+k[2]+k[3]+k[3]);const T=parseInt(k.slice(1,3),16),R=parseInt(k.slice(3,5),16),F=parseInt(k.slice(5,7),16);return`rgba(${T},${R},${F},${A})`},_resolveColor:function(k,A){return typeof k=="string"?k:"#6366f1"},_makeGradient:function(k,A,T,R,F,O){if(!this.barGradient)return A;const W=this.gradientStartColor||A,V=k.createLinearGradient(T,R,F,O);return V.addColorStop(0,A),V.addColorStop(1,this._hexToRgb(W,this.gradientEndOpacity)),V},_drawRoundedBar:function(k,A,T,R,F,O,W){if(O=Math.min(O,Math.min(Math.abs(R),Math.abs(F))/2),O<=0||R===0||F===0){k.rect(A,T,R,F);return}k.beginPath(),W?(k.moveTo(A,T+F),k.lineTo(A,T+O),k.quadraticCurveTo(A,T,A+O,T),k.lineTo(A+R-O,T),k.quadraticCurveTo(A+R,T,A+R,T+O),k.lineTo(A+R,T+F),k.lineTo(A,T+F)):(k.moveTo(A,T),k.lineTo(A+R-O,T),k.quadraticCurveTo(A+R,T,A+R,T+O),k.lineTo(A+R,T+F-O),k.quadraticCurveTo(A+R,T+F,A+R-O,T+F),k.lineTo(A,T+F),k.lineTo(A,T)),k.closePath()}},a=i.width,r=i.height,l=-a/2,d=-r/2;if(!i.datasets||i.datasets.length===0||i.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}let p=-1/0,u=1/0;const m=i.categories.length,h=i.datasets.length;if(i.chartType==="stacked")for(let k=0;k<m;k++){let A=0,T=0;i.datasets.forEach(R=>{const F=R.data[k]??0;F>=0?A+=F:T+=F}),A>p&&(p=A),T<u&&(u=T)}else i.datasets.forEach(k=>{k.data&&k.data.forEach(A=>{A>p&&(p=A),A<u&&(u=A)})});isFinite(p)||(p=10),isFinite(u)||(u=0),p=Math.max(p,0),u=Math.min(u,0);const f=p-u||10;t.save(),i.enableShadows&&(t.shadowColor=i.shadowColor,t.shadowBlur=i.shadowBlur,t.shadowOffsetY=i.shadowOffsetY),t.font=i.axisLabelFontSize+"px Inter, sans-serif";const v=i.showYLabels?t.measureText(p.toFixed(0)).width+14:10,g=i.showXLabels?i.axisLabelFontSize+12:8,b=(i.showLegend&&h>0?i.legendFontSize+10:0)+8,S=10,w=l+v,C=d+b,M=a-v-S,I=r-b-g;if(i.enableShadows&&(t.shadowColor="transparent"),t.beginPath(),t.roundRect(l,d,a,r,10),t.fillStyle=i._hexToRgb(i.cardBackground,i.cardBackgroundOpacity),t.fill(),t.strokeStyle=i.cardBorderColor,t.lineWidth=1,t.stroke(),i.showLegend&&h>0){t.font=i.legendFontSize+"px Inter, sans-serif",t.textBaseline="middle";const k=d+12;let A=w;i.datasets.forEach((T,R)=>{const F=i._resolveColor(T.color,R),O=T.label||"Series "+(R+1),W=7;t.beginPath(),t.roundRect(A,k-W/2,W,W,2),t.fillStyle=F,t.fill(),t.fillStyle=i.legendColor,t.textAlign="left",t.fillText(O,A+W+4,k),A+=t.measureText(O).width+W+16})}const _=4;if(i.showGridLines){t.setLineDash(i.gridLineDash||[]),t.lineWidth=i.gridLineWidth||1,t.strokeStyle=i.gridColor;for(let k=0;k<=_;k++)if(i.orientation==="horizontal"){const A=w+k/_*M;t.beginPath(),t.moveTo(A,C),t.lineTo(A,C+I),t.stroke()}else{const A=C+k/_*I;t.beginPath(),t.moveTo(w,A),t.lineTo(w+M,A),t.stroke()}t.setLineDash([])}if(i.showYLabels){t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=i.axisLabelColor;for(let k=0;k<=_;k++)if(i.orientation==="horizontal"){const A=u+k/_*f,T=w+k/_*M;t.textAlign="center",t.fillText(A.toFixed(0),T,C+I+i.axisLabelFontSize)}else{const A=p-k/_*f,T=C+k/_*I;t.textAlign="right",t.fillText(A.toFixed(0),w-6,T)}}if(t.setLineDash([]),i.showXAxis&&(t.lineWidth=i.xAxisLineWidth||1,t.strokeStyle=i.xAxisColor,t.beginPath(),t.moveTo(w,C+I),t.lineTo(w+M,C+I),t.stroke()),i.showYAxis&&(t.lineWidth=i.yAxisLineWidth||1,t.strokeStyle=i.yAxisColor,t.beginPath(),t.moveTo(w,C),t.lineTo(w,C+I),t.stroke()),i.enableShadows&&(t.shadowColor=i.shadowColor),i.chartType==="stacked")if(i.orientation==="horizontal"){const k=I/m;for(let A=0;A<m;A++){const T=C+A*k+k/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=i.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[A]||"",w-5,T),i.enableShadows&&(t.shadowColor=i.shadowColor));let R=w;i.datasets.forEach((F,O)=>{const W=F.data[A]??0;if(W===0)return;const V=W/f*M,U=Math.min(i.barWidth*h+i.barGap,k-8),D=T-U/2,Y=R;R+=V;const ot=i._resolveColor(F.color,O);t.beginPath(),t.fillStyle=i._makeGradient(t,ot,Y,D,Y+V,D),i._drawRoundedBar(t,Y,D,V,U,O===h-1?i.barCornerRadius:0,!1),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?ot:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else{const k=M/m;for(let A=0;A<m;A++){const T=w+A*k+k/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=i.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[A]||"",T,C+I+5),i.enableShadows&&(t.shadowColor=i.shadowColor));let R=C+I;i.datasets.forEach((F,O)=>{const W=F.data[A]??0;if(W===0)return;const V=W/f*I,U=Math.min(i.barWidth*h+i.barGap,k-8),D=T-U/2,Y=R-V;R-=V;const ot=i._resolveColor(F.color,O);t.beginPath(),t.fillStyle=i._makeGradient(t,ot,D,Y,D,Y+V),i._drawRoundedBar(t,D,Y,U,V,O===h-1?i.barCornerRadius:0,!0),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?ot:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else if(i.orientation==="horizontal"){const k=I/m,A=h*i.barWidth+Math.max(0,(h-1)*i.barGap),T=w+(0-u)/f*M;for(let R=0;R<m;R++){const F=C+R*k+k/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=i.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[R]||"",w-5,F),i.enableShadows&&(t.shadowColor=i.shadowColor));const O=F-A/2;i.datasets.forEach((W,V)=>{const U=W.data[R]??0,D=Math.abs(U/f*M);if(D<1)return;const Y=O+V*(i.barWidth+i.barGap),ot=U>=0?T:T-D,J=i._resolveColor(W.color,V);t.beginPath(),t.fillStyle=i._makeGradient(t,J,ot,Y,ot+D,Y),i._drawRoundedBar(t,ot,Y,D,i.barWidth,i.barCornerRadius,!1),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?J:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),i.showValueOnTop&&U!==0&&(t.font=(i.valueFontWeight||"bold")+" "+(i.valueFontSize||10)+"px Inter, sans-serif",t.textAlign=U>=0?"left":"right",t.textBaseline="middle",t.fillStyle=i.valueColor==="auto"?J:i.valueColor||"#fff",t.shadowColor="transparent",t.fillText(U.toString(),U>=0?ot+D+4:ot-4,Y+i.barWidth/2),i.enableShadows&&(t.shadowColor=i.shadowColor))})}}else{const k=M/m,A=h*i.barWidth+Math.max(0,(h-1)*i.barGap),T=C+I-(0-u)/f*I;for(let R=0;R<m;R++){const F=w+R*k+k/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=i.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[R]||"",F,C+I+5),i.enableShadows&&(t.shadowColor=i.shadowColor));const O=F-A/2;i.datasets.forEach((W,V)=>{const U=W.data[R]??0,D=Math.abs(U/f*I);if(D<1)return;const Y=O+V*(i.barWidth+i.barGap),ot=U>=0?T-D:T,J=i._resolveColor(W.color,V);t.beginPath(),t.fillStyle=i._makeGradient(t,J,Y,ot,Y,ot+D),i._drawRoundedBar(t,Y,ot,i.barWidth,D,i.barCornerRadius,!0),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?J:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),i.showValueOnTop&&U!==0&&(t.font=(i.valueFontWeight||"bold")+" "+(i.valueFontSize||10)+"px Inter, sans-serif",t.textAlign="center",t.textBaseline=U>=0?"bottom":"top",t.fillStyle=i.valueColor==="auto"?J:i.valueColor||"#fff",t.shadowColor="transparent",t.fillText(U.toString(),Y+i.barWidth/2,U>=0?ot-4:ot+D+4),i.enableShadows&&(t.shadowColor=i.shadowColor))})}}t.restore()}renderPieChart(t,s){var c,b;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=e.colorPalette==="custom"&&Array.isArray(e.customPalette)&&e.customPalette.length>0?e.customPalette:us[e.colorPalette||"vibrant"]||us.vibrant;let i=e.slices||[{id:"slice-1",label:"Item 1",value:45,color:""}];if(e.isDataVarEnabled&&e.dataInputId){let S=this.inputs.get(e.dataInputId);if(S===void 0){const w=this.inputNameMap.get(e.dataInputId);w&&w.length>0&&(S=this.inputs.get(w[0]))}S&&Array.isArray(S)&&(i=S.map((w,C)=>{var M,I;return{id:`slice-${C}`,label:((M=i[C])==null?void 0:M.label)||`Item ${C+1}`,value:typeof w=="number"?w:0,color:((I=i[C])==null?void 0:I.color)||""}}))}const a={width:((c=s.geometry)==null?void 0:c.width)||180,height:((b=s.geometry)==null?void 0:b.height)||180,chartType:e.chartType||"donut",slices:i,innerRadius:e.innerRadius!==void 0?e.innerRadius:.55,sliceGap:e.sliceGap!==void 0?e.sliceGap:3,showLabels:!!e.showLabels,labelColor:e.labelColor||"#000000",labelFontSize:e.labelFontSize||10,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(0,0,0,0.65)",legendFontSize:e.legendFontSize||9,showCenterText:e.showCenterText!==void 0?!!e.showCenterText:!0,centerLabel:e.centerLabel||"Total",centerTextColor:e.centerTextColor||"#000000",centerLabelColor:e.centerLabelColor||"rgba(0,0,0,0.4)",cardBackground:e.cardBackground||"#ffffff",cardBackgroundOpacity:e.cardBackgroundOpacity!==void 0?e.cardBackgroundOpacity:.04,cardBorderColor:e.cardBorderColor||"rgba(0,0,0,0.08)",_resolveSliceColor:function(S,w){return S.color?S.color:n[w%n.length]},_hexToRgb:function(S){if(S.startsWith("rgba")||S.startsWith("rgb"))return S;const w=S.replace("#",""),C=parseInt(w.substring(0,2),16),M=parseInt(w.substring(2,4),16),I=parseInt(w.substring(4,6),16);return`rgba(${C},${M},${I},${a.cardBackgroundOpacity})`}},r=a.width,l=a.height;if(!a.slices||a.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 d=a.slices.reduce((S,w)=>S+(w.value||0),0);if(d<=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}t.save();const p=a._hexToRgb(a.cardBackground);t.beginPath(),t.roundRect(-r/2,-l/2,r,l,10),t.fillStyle=p,t.fill(),t.strokeStyle=a.cardBorderColor,t.lineWidth=1,t.stroke();const u=a.showLegend?Math.ceil(a.slices.length/2):0,m=u>0?u*(a.legendFontSize+8)+10:0,h=l-m-16,f=Math.min(r-24,h)/2,v=0,g=-m/2;if(a.chartType==="rose"){const S=Math.max(...a.slices.map(M=>M.value||0)),w=Math.PI*2/a.slices.length,C=f>0?a.sliceGap/f:0;a.slices.forEach((M,I)=>{const _=M.value||0;if(_===0)return;const E=_/S*f,P=-Math.PI/2+I*w+C/2,L=P+w-C,k=a._resolveSliceColor(M,I);if(t.beginPath(),t.moveTo(v,g),t.arc(v,g,E,P,L),t.closePath(),t.fillStyle=k+"cc",t.fill(),t.strokeStyle=k,t.lineWidth=1.5,t.stroke(),a.showLabels){const A=P+(L-P)/2,T=v+E*.65*Math.cos(A),R=g+E*.65*Math.sin(A),F=Math.round(_/d*100);t.save(),t.font=`bold ${a.labelFontSize}px Inter, sans-serif`,t.fillStyle=a.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${F}%`,T,R),t.restore()}})}else{const S=a.chartType==="pie"?0:a.innerRadius,w=f*Math.max(0,S),C=f>0?a.sliceGap/f:0;let M=-Math.PI/2;if(a.slices.forEach((I,_)=>{const E=I.value||0;if(E===0){M+=E/d*Math.PI*2;return}const P=E/d*Math.PI*2,L=M+C/2,k=M+P-C/2;if(k<=L){M+=P;return}const A=a._resolveSliceColor(I,_);if(t.beginPath(),t.fillStyle=A,w<=0?(t.moveTo(v,g),t.arc(v,g,f,L,k),t.lineTo(v,g)):(t.moveTo(v+f*Math.cos(L),g+f*Math.sin(L)),t.arc(v,g,f,L,k),t.arc(v,g,w,k,L,!0),t.closePath()),t.fill(),a.showLabels){const T=L+(k-L)/2,R=w+(f-w)/2,F=v+R*Math.cos(T),O=g+R*Math.sin(T),W=Math.round(E/d*100);t.save(),t.font=`bold ${a.labelFontSize}px Inter, sans-serif`,t.fillStyle=a.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${W}%`,F,O),t.restore()}M+=P}),a.chartType==="donut"&&a.showCenterText&&w>14){const I=Math.round(d),_=Math.min(Math.floor(w*.52),20),E=Math.min(Math.floor(w*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${_}px Inter, sans-serif`,t.fillStyle=a.centerTextColor,t.fillText(I.toString(),v,g-E*.5),t.font=`${E}px Inter, sans-serif`,t.fillStyle=a.centerLabelColor,t.fillText(a.centerLabel,v,g+_*.6)}}if(a.showLegend&&a.slices.length>0){t.font=`${a.legendFontSize}px Inter, sans-serif`;const S=2,w=r/S,C=a.legendFontSize+8,M=l/2-m+10,I=-r/2+10;a.slices.forEach((_,E)=>{const P=E%S,L=Math.floor(E/S),k=I+P*w,A=M+L*C,T=a._resolveSliceColor(_,E),R=7;t.beginPath(),t.roundRect(k,A-R/2,R,R,2),t.fillStyle=T,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=a.legendColor;const F=Math.round((_.value||0)/d*100),O=`${_.label||"Item"} ${F}%`,W=w-R-20;let V=O;for(;t.measureText(V).width>W&&V.length>4;)V=V.slice(0,-4)+"…";t.fillText(V,k+R+4,A)})}t.restore()}renderJoystick(t,s){var v,g,c,b,S,w,C,M,I,_,E,P;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.width)!==void 0?o.width:((v=s.geometry)==null?void 0:v.width)??s.width??100,n=(o==null?void 0:o.height)!==void 0?o.height:((g=s.geometry)==null?void 0:g.height)??s.height??100,i=Math.min(e,n)*(((c=s.style)==null?void 0:c.baseSize)??.45),a=Math.min(e,n)*(((b=s.style)==null?void 0:b.handleSize)??.14);let r=s.handleX||0,l=s.handleY||0;o&&o.handleX!==void 0&&(r=o.handleX),o&&o.handleY!==void 0&&(l=o.handleY),t.save();let d=0,p=0;s.handleOrigin==="top-left"?(d=e/2,p=n/2):s.handleOrigin==="bottom-right"&&(d=-e/2,p=-n/2),t.translate(d,p);const u=t.globalAlpha;if(t.globalAlpha=u*(((S=s.style)==null?void 0:S.baseOpacity)??1),t.beginPath(),s.boundsShape==="square"){const L=s.joystickType==="2D"?12:18;t.roundRect(-i,-i,i*2,i*2,L)}else t.arc(0,0,i,0,Math.PI*2);t.fillStyle=((w=s.style)==null?void 0:w.baseColor)||"rgba(0,0,0,0.04)",t.fill(),(C=s.style)!=null&&C.baseBorderWidth?(t.lineWidth=s.style.baseBorderWidth,t.strokeStyle=s.style.baseBorderColor||"rgba(0,0,0,0.1)",t.stroke()):(t.lineWidth=1,t.strokeStyle=((M=s.style)==null?void 0:M.baseBorderColor)||"rgba(0,0,0,0.08)",t.stroke());const m=s.overflowHandle?i:Math.max(.1,i-a);let h=0,f=0;s.joystickType==="2D"?(h=r*m,f=l*m):s.joystickType==="1D_X"?(h=r*m,f=0):s.joystickType==="1D_Y"&&(h=0,f=l*m),t.globalAlpha=u*(((I=s.style)==null?void 0:I.handleOpacity)??1),t.beginPath(),t.arc(h,f,a,0,Math.PI*2),t.fillStyle=((_=s.style)==null?void 0:_.handleColor)||"#3b82f6",t.fill(),(E=s.style)!=null&&E.handleBorderWidth?(t.lineWidth=s.style.handleBorderWidth,t.strokeStyle=s.style.handleBorderColor||"rgba(255,255,255,0.5)",t.stroke()):(t.lineWidth=1,t.strokeStyle=((P=s.style)==null?void 0:P.handleBorderColor)||"rgba(255,255,255,0.5)",t.stroke()),t.globalAlpha=u,t.restore()}getRadioGroupItemIndexAtPointer(t,s,o){var I,_;const e=t.options||{},n=this.objectStates.get(t.id)||{},i=e.optionsList||[];if(i.length===0)return null;const a=n.width!==void 0?n.width:((I=t.geometry)==null?void 0:I.width)||180,r=n.height!==void 0?n.height:((_=t.geometry)==null?void 0:_.height)||100,l=e.orientation||"vertical",d=e.itemGap!==void 0?e.itemGap:16,p=e.fontSize||14,u=this.getWorldTransform(t.id),m=s-u.x,h=o-u.y,f=-u.rotation*(Math.PI/180),v=Math.cos(f),g=Math.sin(f),c=m*v-h*g,b=m*g+h*v,w=8*2,C=-a/2,M=-r/2;if(l==="vertical"){const E=Math.max(w,p)+d;for(let P=0;P<i.length;P++){const L=M+P*E;if(c>=C&&c<=C+a&&b>=L&&b<=L+E)return P}}else{let E=C;for(let P=0;P<i.length;P++){const k=i[P].length*8,A=w+6+k+d;if(c>=E&&c<=E+A&&b>=M&&b<=M+r)return P;E+=A}}return null}renderLineGraph(t,s,o,e){let n=s.datasets||[];if((!n||n.length===0)&&(s.data||s.graphData)&&(n=[{id:"line-1",label:"Series 1",data:s.data||s.graphData||[],lineColor:s.lineColor||"#3b82f6",lineWidth:s.lineWidth||2,showArea:s.showArea||!1,areaColor:s.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:s.smoothing||!1,showPoints:s.showPoints!==void 0?s.showPoints:!0,pointSize:s.pointSize||6,pointFill:s.pointFill||"#ffffff",pointStrokeColor:s.pointStrokeColor||s.lineColor||"#3b82f6",pointStrokeWidth:s.pointStrokeWidth||2}]),!n||n.length===0||!n.some(f=>f.data&&f.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 i=1/0,a=-1/0,r=0;if(n.forEach(f=>{let v=f.data;if(f.isVarEnabled&&f.inputId){let g=this.inputs.get(f.inputId);if(g===void 0){const c=this.inputNameMap.get(f.inputId);c&&c.length>0&&(g=this.inputs.get(c[0]))}g&&Array.isArray(g)&&(v=g)}if(v&&v.length>0){const g=v.filter(c=>typeof c=="number"&&!isNaN(c));g.length>0&&(i=Math.min(i,...g),a=Math.max(a,...g),r=Math.max(r,v.length))}f._resolvedData=v}),r<2)return;const l=a-i,d=o/(r-1),p=f=>{const v=l===0?.5:(f-i)/l;return e/2-v*e},u=f=>f*d-o/2,m=s.axisColor||"#333333";if(s.showXAxis&&(t.beginPath(),t.strokeStyle=s.xAxisColor||m,t.lineWidth=1,t.moveTo(-o/2,e/2),t.lineTo(o/2,e/2),t.stroke()),s.showYAxis&&(t.beginPath(),t.strokeStyle=s.yAxisColor||m,t.lineWidth=1,t.moveTo(-o/2,-e/2),t.lineTo(-o/2,e/2),t.stroke()),t.fillStyle=s.axisLabelColor||"#333333",t.font=`${s.axisLabelFontSize||10}px Inter, sans-serif`,s.showXLabels){t.textAlign="center",t.textBaseline="top";for(let f=0;f<r;f++){const v=u(f);t.fillText(`${f+1}`,v,e/2+5)}}if(s.showYLabels){t.textAlign="right",t.textBaseline="middle";const f=-o/2-5,v=(a+i)/2;t.fillText(a.toFixed(1),f,p(a)),t.fillText(v.toFixed(1),f,p(v)),t.fillText(i.toFixed(1),f,p(i))}const h=10;if(n.forEach(f=>{const v=f._resolvedData;if(!(!v||v.length<2)){if(f.showArea){if(t.beginPath(),t.moveTo(u(0),e/2),t.lineTo(u(0),p(v[0])),f.smoothing&&v.length>2)for(let c=0;c<v.length-1;c++){const b=v[c===0?c:c-1],S=v[c],w=v[c+1],C=v[c+1===v.length-1?c+1:c+2];for(let M=1;M<=h;M++){const I=M/h,_=this._catmullRom(b,S,w,C,I);t.lineTo(u(c+I),p(_))}}else for(let c=1;c<v.length;c++)t.lineTo(u(c),p(v[c]));t.lineTo(u(v.length-1),e/2),t.closePath();const g=t.globalAlpha;t.globalAlpha=g*(s.areaOpacity??.3),t.fillStyle=f.areaColor||"rgba(139, 92, 246, 0.2)",t.fill(),t.globalAlpha=g}if(t.beginPath(),t.strokeStyle=f.lineColor||"#3b82f6",t.lineWidth=f.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.moveTo(u(0),p(v[0])),f.smoothing&&v.length>2)for(let g=0;g<v.length-1;g++){const c=v[g===0?g:g-1],b=v[g],S=v[g+1],w=v[g+1===v.length-1?g+1:g+2];for(let C=1;C<=h;C++){const M=C/h,I=this._catmullRom(c,b,S,w,M);t.lineTo(u(g+M),p(I))}}else for(let g=1;g<v.length;g++)t.lineTo(u(g),p(v[g]));t.stroke(),f.showPoints&&v.forEach((g,c)=>{const b=u(c),S=p(g);t.beginPath(),t.arc(b,S,(f.pointSize||6)/2,0,Math.PI*2),t.fillStyle=f.pointFill||"#ffffff",t.fill(),t.strokeStyle=f.pointStrokeColor||f.lineColor||"#3b82f6",t.lineWidth=f.pointStrokeWidth||1,t.stroke()})}}),s.showLegend&&n.length>0){const f=o/2-10;let v=-e/2+15;const g=s.legendFontSize||10,c=g+5;t.font=`${g}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",n.forEach(b=>{const w=b.label||"Series",C=t.measureText(w).width;t.beginPath(),t.rect(f-C-8-5,v-(8/2+2),8,8),t.fillStyle=b.lineColor||"#3b82f6",t.fill(),t.fillStyle=s.legendColor||"#333333",t.fillText(w,f,v),v+=c})}}_catmullRom(t,s,o,e,n){const i=(o-t)*.5,a=(e-s)*.5,r=n*n,l=n*r;return(2*s-2*o+i+a)*l+(-3*s+3*o-2*i-a)*r+i*n+s}normalizeOpacity(t){const s=typeof t=="number"?t:parseFloat(String(t));return isNaN(s)?1:s>1?Math.min(1,s/100):Math.max(0,Math.min(1,s))}createCanvasFill(t,s,o,e){var n,i,a;if(!s||s.type==="None")return null;if(typeof s=="string")return s;if(s.type==="Solid"&&s.color){const r=s.color,d=(((i=(n=this.artboard)==null?void 0:n.tokens)==null?void 0:i.colors)||{})[r]||r;return t.fillStyle=d,d}if((s.type==="LinearGradient"||s.type==="RadialGradient"||s.type==="AngularGradient"||s.type==="DiamondGradient")&&s.stops){const r=(l,d=100)=>{var S,w;const u=(((w=(S=this.artboard)==null?void 0:S.tokens)==null?void 0:w.colors)||{})[l]||l,m=this.normalizeOpacity(s.opacity??100),f=this.normalizeOpacity(d)*m;if(f>=1&&u.startsWith("#"))return u;const v=u.startsWith("#")?u.replace("#",""):"ffffff",g=parseInt(v.substring(0,2),16),c=parseInt(v.substring(2,4),16),b=parseInt(v.substring(4,6),16);return`rgba(${g}, ${c}, ${b}, ${f})`};if(s.type==="LinearGradient"){let l=0,d=-e/2,p=0,u=e/2;if(s.angle!==void 0&&(!s.start||!s.end)){const h=(s.angle-90)*Math.PI/180,f=Math.max(o,e)/2;l=Math.cos(h)*-f,d=Math.sin(h)*-f,p=Math.cos(h)*f,u=Math.sin(h)*f}else if(s.start||s.end){const h=(f,v,g)=>Array.isArray(f)?f[v]??.5:f&&typeof f=="object"?f[g]??.5:.5;l=h(s.start,0,"x")*o-o/2,d=h(s.start,1,"y")*e-e/2,p=h(s.end,0,"x")*o-o/2,u=h(s.end,1,"y")*e-e/2}Math.abs(l-p)<.001&&Math.abs(d-u)<.001&&(l=0,d=-e/2,p=0,u=e/2);const m=t.createLinearGradient(l,d,p,u);if(s.stops.forEach(h=>{const f=h.offset!==void 0?h.offset:h.pos!==void 0?h.pos:h.position!==void 0?h.position:0,v=r(h.color||"#000000",h.opacity??100);m.addColorStop(Math.max(0,Math.min(1,f)),v)}),s.gradientTransform&&m.setTransform){const[h,f,v,g,c,b]=s.gradientTransform;m.setTransform({a:h,b:f,c:v,d:g,e:c,f:b})}return m}else if(s.type==="RadialGradient"){const l=(h,f,v)=>Array.isArray(h)?h[f]??.5:h&&typeof h=="object"?h[v]??.5:.5,d=l(s.center,0,"x")*o-o/2,p=l(s.center,1,"y")*e-e/2,u=(s.radius??.5)*Math.max(o,e),m=t.createRadialGradient(d,p,0,d,p,u);if(s.stops.forEach(h=>{const f=h.offset!==void 0?h.offset:h.pos!==void 0?h.pos:h.position!==void 0?h.position:0,v=r(h.color||"#000000",h.opacity??100);m.addColorStop(Math.max(0,Math.min(1,f)),v)}),s.gradientTransform&&m.setTransform){const[h,f,v,g,c,b]=s.gradientTransform;m.setTransform({a:h,b:f,c:v,d:g,e:c,f:b})}return m}else if(s.type==="AngularGradient"){const l=(h,f,v)=>Array.isArray(h)?h[f]??.5:h&&typeof h=="object"?h[v]??.5:.5,d=l(s.center||[.5,.5],0,"x")*o-o/2,p=l(s.center||[.5,.5],1,"y")*e-e/2,u=(s.degree||s.angle||0)*(Math.PI/180),m=(a=t.createConicGradient)==null?void 0:a.call(t,u,d,p);if(m){if(s.stops.forEach(h=>{const f=h.offset!==void 0?h.offset:h.pos!==void 0?h.pos:h.position!==void 0?h.position:0,v=r(h.color||"#000000",h.opacity??100);m.addColorStop(Math.max(0,Math.min(1,f)),v)}),s.gradientTransform&&m.setTransform){const[h,f,v,g,c,b]=s.gradientTransform;m.setTransform({a:h,b:f,c:v,d:g,e:c,f:b})}return m}}else if(s.type==="DiamondGradient"){const l=(h,f,v)=>Array.isArray(h)?h[f]??.5:h&&typeof h=="object"?h[v]??.5:.5,d=l(s.center||[.5,.5],0,"x")*o-o/2,p=l(s.center||[.5,.5],1,"y")*e-e/2,u=(s.radius??.5)*Math.max(o,e);t.save(),t.translate(d,p),t.rotate(Math.PI/4);const m=t.createRadialGradient(0,0,0,0,0,u);if(s.stops.forEach(h=>{const f=h.offset!==void 0?h.offset:h.pos!==void 0?h.pos:h.position!==void 0?h.position:0,v=r(h.color||"#000000",h.opacity??100);m.addColorStop(Math.max(0,Math.min(1,f)),v)}),s.gradientTransform&&m.setTransform){const[h,f,v,g,c,b]=s.gradientTransform;m.setTransform({a:h,b:f,c:v,d:g,e:c,f:b})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=m,t.restore(),m}}if(s.type==="Pattern"&&s.url){let r=this.imageCache.get(s.url);if(r||(r=new Image,r.src=s.url,this.imageCache.set(s.url,r)),r.complete&&r.naturalWidth>0){const l=t.createPattern(r,"repeat");if(l&&(s.scaleX!==void 0||s.offsetX!==void 0)){const d=new DOMMatrix,p=s.scaleX??1,u=s.scaleY??1,m=s.offsetX??0,h=s.offsetY??0,f=s.rotation??0;d.translateSelf(m,h),d.rotateSelf(f),d.scaleSelf(p,u),l.setTransform(d)}return l}}return s.color||null}drawRoundRect(t,s,o,e,n,i){if(i===0||i===void 0||i===null){t.rect(s,o,e,n);return}let a=i;if(typeof a=="string")try{a=JSON.parse(a)}catch{a=parseFloat(a)||0}let r=0,l=0,d=0,p=0;typeof a=="number"?r=l=d=p=a:Array.isArray(a)?a.length===1?r=l=d=p=a[0]:a.length===2?(r=d=a[0],l=p=a[1]):a.length===3?(r=a[0],l=p=a[1],d=a[2]):a.length>=4&&(r=a[0],l=a[1],d=a[2],p=a[3]):a&&typeof a=="object"&&(r=a[0]??a.tl??a.corner_radius??a.cornerRadius??0,l=a[1]??a.tr??a.corner_radius??a.cornerRadius??0,d=a[2]??a.br??a.corner_radius??a.cornerRadius??0,p=a[3]??a.bl??a.corner_radius??a.cornerRadius??0);const u=Math.min(Math.abs(e)/2,Math.abs(n)/2);if(r=Math.min(Math.max(0,r),u),l=Math.min(Math.max(0,l),u),d=Math.min(Math.max(0,d),u),p=Math.min(Math.max(0,p),u),t.roundRect){t.roundRect(s,o,e,n,[r,l,d,p]);return}t.moveTo(s+r,o),t.lineTo(s+e-l,o),t.arcTo(s+e,o,s+e,o+l,l),t.lineTo(s+e,o+n-d),t.arcTo(s+e,o+n,s+e-d,o+n,d),t.lineTo(s+p,o+n),t.arcTo(s,o+n,s,o+n-p,p),t.lineTo(s,o+r),t.arcTo(s,o,s+r,o,r),t.closePath()}renderListView(t,s){var T,R,F,O,W,V,U,D,Y,ot;const o=this.objectStates.get(s.id)||{},e=o.options||s.options||{},n=o.width!==void 0?o.width:((T=s.geometry)==null?void 0:T.width)||200,i=o.height!==void 0?o.height:((R=s.geometry)==null?void 0:R.height)||300,a=-n/2,r=-i/2,l=e.cornerRadius!==void 0?e.cornerRadius:o.cornerRadius!==void 0?o.cornerRadius:o.corner_radius??e.corner_radius??((F=s.geometry)==null?void 0:F.cornerRadius)??((O=s.geometry)==null?void 0:O.corner_radius)??0,d=e.orientation||"vertical",p=this.getResolvedListViewItems(s,e),u=e.itemGap??10,m=e.itemHeight??50,h=e.itemWidth??200,f=e.scrollOffset??0,v=e.padding??0,g=e.glassEffect!==!1,c=e.accentColor||"#3b82f6",b=e.itemTextColor||"#333333",S=e.itemBackgroundColor||"#ffffff",w=e.hoveredIndex??null,C=e.activeItemIndex??null,M=e.glowIntensity??0,I=e.glowColor||"#3b82f6",_=typeof I=="string"?I:I.color||((V=(W=I.stops)==null?void 0:W[0])==null?void 0:V.color)||"#3b82f6",E=e.opacity!==void 0?e.opacity:s.opacity!==void 0?s.opacity:1;if(t.save(),t.globalAlpha*=E,M>0){const J=t.getTransform(),at=Math.sqrt(J.a*J.a+J.b*J.b)||1;t.shadowColor=_,t.shadowBlur=M*2*at,t.shadowOffsetX=0,t.shadowOffsetY=0}if(g){const J=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",at=this.createCanvasFill(t,J,n,i);t.fillStyle=at||"rgba(31, 41, 55, 0.4)",t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)||t.fill();const it=t.createLinearGradient(a,r,a+n,r+i);it.addColorStop(0,"rgba(255, 255, 255, 0.15)"),it.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),it.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=it,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)||t.fill();const X=e.borderWidth??0;if(X>0&&e.borderColor&&e.borderColor!=="transparent"){const ct=this.createCanvasFill(t,e.borderColor,n,i);t.strokeStyle=ct||"rgba(255, 255, 255, 0.25)",t.lineWidth=X}else t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1;t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)||t.stroke()}else{const J=e.backgroundColor&&e.backgroundColor!=="transparent"?e.backgroundColor:e.listBackgroundColor||"transparent",at=this.createCanvasFill(t,J,n,i);if(at){t.fillStyle=at,t.beginPath();const it=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l);t.fill()}const j=e.borderWidth??0;if(j>0){const it=this.createCanvasFill(t,e.borderColor||"#cccccc",n,i);t.strokeStyle=it||"#cccccc",t.lineWidth=j,t.beginPath();const B=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l);t.stroke()}}t.shadowBlur=0;const P=e.clipContent!==!1&&e.listLayout!=="circular";if(P)if(t.save(),t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)&&e.containerShape==="custom")try{const at=new Path2D(e.containerPath);t.translate(a,r),t.scale(n/100,i/100),t.clip(at),t.scale(100/n,100/i),t.translate(-a,-r)}catch{}else t.clip();const L=typeof v=="number"?v:d==="vertical"?v[0]:v[3];let k=(d==="vertical"?r:a)+f+L;if(t.textBaseline="middle",p.forEach((J,at)=>{var ft,Bt,Ot,Pt;const j=e.listLayout||"linear",it=j==="circular"?h:d==="vertical"?n:h,B=j==="circular"||d==="vertical"?m:i;let X=0,N=0,ct=0;if(j==="circular"){const vt=p.length||1,Yt=Math.PI*2/vt,zt=e.circularStartAngle||0,Gt=e.circularRadius||100,Dt=f*.01+zt*Math.PI/180,te=at*Yt+Dt,ie=a+n/2,ce=r+i/2;X=ie+Math.cos(te)*Gt-it/2,N=ce+Math.sin(te)*Gt-B/2,ct=te+(e.itemRotation||0)*Math.PI/180}else X=d==="vertical"?a:k,N=d==="vertical"?k:r,ct=(e.itemRotation||0)*Math.PI/180;const Mt=w===at,bt=C===at,wt=e.itemBorderWidth??0;t.save(),ct!==0&&(t.translate(X+it/2,N+B/2),t.rotate(ct),t.translate(-(X+it/2),-(N+B/2)));const gt=Mt?((ft=e.hoverStyle)==null?void 0:ft.scale)??1:bt?((Bt=e.activeStyle)==null?void 0:Bt.scale)??1:1;if(gt!==1&&(t.translate(X+it/2,N+B/2),t.scale(gt,gt),t.translate(-(X+it/2),-(N+B/2))),bt){const vt=((Ot=e.activeStyle)==null?void 0:Ot.itemBackgroundColor)||e.activeBackgroundColor||(g?"rgba(255, 255, 255, 0.15)":"rgba(0, 0, 0, 0.1)"),Yt=this.createCanvasFill(t,vt,it,B);t.fillStyle=Yt||(typeof vt=="string"?vt:"transparent"),t.beginPath(),this.drawCustomShape(t,e.activeItemShape||e.itemShape||"rectangle",e.activeItemShape==="custom"?e.activeItemPath||"":e.itemPath||"",X,N,it,B,e.itemCornerRadius??0)||t.fill()}else if(Mt){const vt=((Pt=e.hoverStyle)==null?void 0:Pt.itemBackgroundColor)||e.hoverBackgroundColor||(g?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)"),Yt=this.createCanvasFill(t,vt,it,B);t.fillStyle=Yt||(typeof vt=="string"?vt:"transparent"),t.beginPath(),this.drawCustomShape(t,e.itemShape||"rectangle",e.itemPath||"",X,N,it,B,e.itemCornerRadius??0)||t.fill()}else if(S!=="transparent"){const vt=this.createCanvasFill(t,S,it,B);t.fillStyle=vt||(typeof S=="string"?S:"transparent"),t.beginPath(),this.drawCustomShape(t,e.itemShape||"rectangle",e.itemPath||"",X,N,it,B,e.itemCornerRadius??0)||t.fill()}if(wt>0&&e.itemBorderColor&&e.itemBorderColor!=="transparent"){const vt=this.createCanvasFill(t,e.itemBorderColor,it,B);t.strokeStyle=vt||(typeof e.itemBorderColor=="string"?e.itemBorderColor:"#cccccc"),t.lineWidth=wt,t.beginPath(),this.drawCustomShape(t,e.itemShape||"rectangle",e.itemPath||"",X,N,it,B,e.itemCornerRadius??0)||t.stroke()}if(bt){const vt=this.createCanvasFill(t,c,d==="vertical"?3:it,d==="vertical"?B:3);t.fillStyle=vt||c,d==="vertical"?t.fillRect(X,N,3,B):t.fillRect(X,N+B-3,it,3)}const It=bt?"#ffffff":g?"rgba(255, 255, 255, 0.9)":b;t.fillStyle=It,t.font=bt||Mt?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const ut=typeof J=="string"?J:(J==null?void 0:J.label)||`Item ${at+1}`,Lt=X+(d==="vertical"?16:it/2),Wt=N+B/2;d==="horizontal"||j==="circular"?t.textAlign="center":t.textAlign="left";const q=j==="circular"?X+it/2:Lt;t.fillText(ut,q,Wt),t.restore(),t.beginPath(),k+=(d==="vertical"?m:h)+u}),P&&t.restore(),e.showScrollbar!==!1){const J=typeof v=="number"?v:d==="vertical"?v[0]:v[3],j=(p.length||0)*(d==="vertical"?m:h)+Math.max(0,(p.length||0)-1)*u+J*2,it=d==="vertical"?i:n,B=e.listLayout||"linear",X=e.containerShape==="circle"||B==="circular",N=e.scrollbarColor||"rgba(255,255,255,0.3)";let ct=typeof N=="object"?N.color||((D=(U=N.stops)==null?void 0:U[0])==null?void 0:D.color)||"rgba(255,255,255,0.3)":N;const Mt=((ot=(Y=this.artboard)==null?void 0:Y.tokens)==null?void 0:ot.colors)||{};Mt[ct]&&(ct=Mt[ct]);const bt=e.scrollbarWidth||2;if(t.save(),X){const wt=Math.min(n,i)/2-bt/2-2,gt=a+n/2,It=r+i/2;if(t.strokeStyle=ct,t.lineWidth=bt,t.lineCap="round",t.beginPath(),B==="circular"){const ut=Math.PI/4,Lt=-(f*.01)-Math.PI/2;t.arc(gt,It,wt,Lt,Lt+ut)}else{const ut=Math.PI/2,Lt=j>0?Math.min(1,it/j):1,Wt=ut*Lt,q=j>0?-f/j*ut:0,Bt=-Math.PI/4+q;t.arc(gt,It,wt,Bt,Bt+Wt)}t.stroke()}else{let wt=it,gt=0;if(j>it){const It=it/j;wt=Math.max(16,it*It);const ut=it-wt,Lt=j-it;gt=Lt>0?Math.max(0,Math.min(ut,-f/Lt*ut)):0}if(t.fillStyle=ct,d==="vertical"){const It=a+n-bt-2,ut=r+gt,Lt=bt,Wt=wt;if(bt>2){t.beginPath();const q=Math.min(bt/2,wt/2);if(t.roundRect)try{t.roundRect(It,ut,Lt,Wt,q),t.fill()}catch{t.fillRect(It,ut,Lt,Wt)}else t.fillRect(It,ut,Lt,Wt)}else t.fillRect(It,ut,Lt,Wt)}else{const It=a+gt,ut=r+i-bt-2,Lt=wt,Wt=bt;if(bt>2){t.beginPath();const q=Math.min(bt/2,wt/2);if(t.roundRect)try{t.roundRect(It,ut,Lt,Wt,q),t.fill()}catch{t.fillRect(It,ut,Lt,Wt)}else t.fillRect(It,ut,Lt,Wt)}else t.fillRect(It,ut,Lt,Wt)}}t.restore()}t.beginPath(),t.restore()}drawCustomShape(t,s,o,e,n,i,a,r){if(s==="circle"){const l=Math.min(i,a)/2;return t.arc(e+i/2,n+a/2,l,0,Math.PI*2),!1}else if(s==="pill"){const l=Math.min(i,a)/2;return this.drawListViewRect(t,e,n,i,a,l),!1}else if(s==="custom"&&o)try{const l=new Path2D(o);return t.save(),t.translate(e,n),t.scale(i/100,a/100),t.fill(l),t.restore(),!0}catch{return this.drawListViewRect(t,e,n,i,a,r),!1}return this.drawListViewRect(t,e,n,i,a,r),!1}updateListViewScrollFromPointer(t){var S,w,C,M;if(!this._lastPointerPos||!this._prevPointerPos)return;const s=this.objectStates.get(t.id);s&&!s.options&&(s.options=JSON.parse(JSON.stringify(t.options||{})));const o=(s==null?void 0:s.options)||t.options||{},e=o.orientation||"vertical",n=this._lastPointerPos.x-this._prevPointerPos.x,i=this._lastPointerPos.y-this._prevPointerPos.y;let a=o.scrollOffset||0;const r=this.getResolvedListViewItems(t,o),l=o.itemGap??10,d=o.itemHeight??50,p=o.itemWidth??200,u=(s==null?void 0:s.width)!==void 0?s.width:((S=t.geometry)==null?void 0:S.width)||200,m=(s==null?void 0:s.height)!==void 0?s.height:((w=t.geometry)==null?void 0:w.height)||300,h=typeof o.padding=="number"?o.padding:e==="vertical"?((C=o.padding)==null?void 0:C[0])||0:((M=o.padding)==null?void 0:M[3])||0,v=(r.length||0)*(e==="vertical"?d:p)+Math.max(0,(r.length||0)-1)*l+h*2,g=e==="vertical"?m:u,c=Math.max(0,v-g);if(this.draggingListViewIsScrollbar&&o.listLayout!=="circular"){const I=v>0?g/v:1,_=Math.max(16,g*I),E=Math.max(1,g-_),P=c>0?c/E:1;e==="vertical"?a-=i*P:a-=n*P}else e==="vertical"?a+=i:a+=n;if((o.listLayout||"linear")==="circular"){o.scrollOffset=a,s&&s.options&&(s.options.scrollOffset=a),t.options&&(t.options.scrollOffset=a);return}a>0&&(a=0),a<-c&&(a=-c),o.scrollOffset=a,s&&s.options&&(s.options.scrollOffset=a),t.options&&(t.options.scrollOffset=a)}updateListViewHoverFromPointer(t,s,o){const e=this.getListViewItemIndexAtPointer(t,s,o),n=this.objectStates.get(t.id);if(n&&n.options)n.options.hoveredIndex!==e&&(n.options.hoveredIndex=e);else{const i=t.options||{};i.hoveredIndex!==e&&(i.hoveredIndex=e)}}getListViewItemIndexAtPointer(t,s,o){var F,O;const e=this.objectStates.get(t.id),n=(e==null?void 0:e.options)||t.options||{},i=this.getResolvedListViewItems(t,n);if(i.length===0)return null;const a=(e==null?void 0:e.width)!==void 0?e.width:((F=t.geometry)==null?void 0:F.width)||200,r=(e==null?void 0:e.height)!==void 0?e.height:((O=t.geometry)==null?void 0:O.height)||300,l=n.orientation||"vertical",d=n.itemGap??10,p=n.itemHeight??50,u=n.itemWidth??200,m=n.scrollOffset??0,h=n.padding??0,f=this.getWorldTransform(t.id),v=s-f.x,g=o-f.y,c=-f.rotation*(Math.PI/180),b=Math.cos(c),S=Math.sin(c),w=v*b-g*S,C=v*S+g*b,M=-a/2,I=-r/2,_=typeof h=="number"?h:l==="vertical"?h[0]:h[3];let E=(l==="vertical"?I:M)+m+_;const P=n.listLayout||"linear",L=i.length||1,k=Math.PI*2/L,A=n.circularStartAngle||0,T=n.circularRadius||100,R=m*.01+A*Math.PI/180;for(let W=0;W<i.length;W++){const V=P==="circular"?u:l==="vertical"?a:u,U=P==="circular"||l==="vertical"?p:r;let D=0,Y=0,ot=0;if(P==="circular"){const J=W*k+R,at=M+a/2,j=I+r/2;D=at+Math.cos(J)*T-V/2,Y=j+Math.sin(J)*T-U/2,ot=J+(n.itemRotation||0)*Math.PI/180}else D=l==="vertical"?M:E,Y=l==="vertical"?E:I,ot=(n.itemRotation||0)*Math.PI/180;if(ot!==0){const J=D+V/2,at=Y+U/2,j=w-J,it=C-at,B=-ot,X=j*Math.cos(B)-it*Math.sin(B)+J,N=j*Math.sin(B)+it*Math.cos(B)+at;if(X>=D&&X<=D+V&&N>=Y&&N<=Y+U)return W}else if(w>=D&&w<=D+V&&C>=Y&&C<=Y+U)return W;E+=(l==="vertical"?p:u)+d}return null}drawListViewRect(t,s,o,e,n,i){this.drawRoundRect(t,s,o,e,n,i)}solveBehaviors(t){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:s,y:o}=this._lastPointerPos;this.artboard.objects.forEach(e=>{if(!e.behaviors||e.behaviors.length===0)return;const n=this.objectStates.get(e.id);n&&e.behaviors.forEach(i=>{var u,m,h,f,v,g,c,b,S,w,C,M,I,_,E,P,L,k,A,T,R,F,O,W,V,U,D,Y,ot,J,at,j,it,B,X,N,ct,Mt,bt,wt,gt,It,ut,Lt,Wt,q,ft,Bt,Ot,Pt,vt,Yt,zt,Gt,Dt,te,ie,ce,ve,_e,ge,Ee,Zt,Me,Re,Ie,de,me,Ae,he,mt,rt,z,K,G,x,Q,H,lt,kt,At,Ht,Ut,qt,$,dt,Rt,Nt,st,yt,St,ee,Ct,Vt,Tt,Xt,Ft,le,fe,Oe,jt,oe,ne,Fe,Be,xe,We,De,Ye,Ge,se,ue,Se,Xe,Ne,ke,Ce,we;if(!i.enabled)return;const a=i.startTime||0,r=i.endTime||1/0;if(this.currentTime<a||this.currentTime>r)return;const l=n.x-s,d=n.y-o,p=Math.sqrt(l*l+d*d);if(this.frameCount%240===0&&Math.random()<.1&&this.log(`[ExodeUI] Executing ${i.type} on ${e.name}`),i.type===tt.Proximity){const Z=((u=i.settings)==null?void 0:u.radius)||300,nt=((m=i.settings)==null?void 0:m.falloff)||"smooth";let et=0;p<Z&&(nt==="linear"?et=1-p/Z:et=Math.pow(1-p/Z,2)),i.sensors.forEach(pt=>{this.applyBehaviorSensor(n,pt,et,t,i.settings,e,l,d,p)})}else if(i.type===tt.Magnetic){const Z=((h=i.settings)==null?void 0:h.radius)||400,nt=((f=i.settings)==null?void 0:f.strength)||.5;if(p<Z&&p>5){const et=1-p/Z,pt=l*et*nt,$t=d*et*nt;n.x-=pt*t*10,n.y-=$t*t*10}}else if(i.type===tt.Repel){const Z=((v=i.settings)==null?void 0:v.radius)||300,nt=((g=i.settings)==null?void 0:g.strength)||1;if(p<Z){const et=Math.pow(1-p/Z,2);n.x+=l/(p||1)*et*60*nt*t*5,n.y+=d/(p||1)*et*60*nt*t*5}}else if(i.type===tt.Orbit){const Z=((c=i.settings)==null?void 0:c.speed)||1,nt=((b=i.settings)==null?void 0:b.radius)||30,et=this.currentTime*Z*Math.PI*2;n.x+=Math.cos(et)*nt*t*5,n.y+=Math.sin(et)*nt*t*5,n.rotation+=2*t*5}else if(i.type===tt.Vortex){const Z=((S=i.settings)==null?void 0:S.radius)||400,nt=((w=i.settings)==null?void 0:w.speed)||2,et=((C=i.settings)==null?void 0:C.strength)||1;if(p<Z){const pt=Math.pow(1-p/Z,1.5),$t=this.currentTime*nt*Math.PI*2,xt=Math.cos($t)*30-l*.4,Jt=Math.sin($t)*30-d*.4;n.x+=xt*pt*et*t*5,n.y+=Jt*pt*et*t*5,n.rotation+=5*pt*et*t*5,n.scale_x*=1-pt*.1*et*t,n.scale_y*=1-pt*.1*et*t}}else if(i.type===tt.Fluid){const Z=((M=i.settings)==null?void 0:M.radius)||300,nt=((I=i.settings)==null?void 0:I.strength)||1;if(p<Z){const et=Math.pow(1-p/Z,1.2),pt=l/(p||1)*et*1.2*nt,$t=d/(p||1)*et*1.2*nt;n.x+=pt*10*t*5,n.y+=$t*10*t*5,n.scale_x*=1+et*.3*nt*t,n.scale_y*=1+et*.3*nt*t}}else if(i.type===tt.Elastic){const Z=((_=i.settings)==null?void 0:_.radius)||300,nt=((E=i.settings)==null?void 0:E.strength)||1;if(p<Z){const et=1-p/Z;n.scale_x*=1+et*.4*nt*t,n.scale_y*=1+et*.4*nt*t}}else if(i.type===tt.Holographic){const Z=n.x-this.canvasWidth/2,nt=n.y-this.canvasHeight/2,et=((P=i.settings)==null?void 0:P.factor)||25;if(n.x-=Z/1e3*et*t*5,n.y-=nt/1e3*et*t*5,n.style){const pt=1-Math.min(1,p/400);n.style.exposure=(n.style.exposure||1)+pt*.5*t}}else if(i.type===tt.Sticky){const Z=((L=i.settings)==null?void 0:L.radius)||80,nt=((k=i.settings)==null?void 0:k.strength)||1;if(p<Z){const et=Math.pow(1-p/Z,2);n.x-=l*et*nt*t*10,n.y-=d*et*nt*t*10,n.scale_x*=1-et*.1*nt*t,n.scale_y*=1-et*.1*nt*t}}else if(i.type===tt.Dilation){const Z=((A=i.settings)==null?void 0:A.size)||120,nt=((T=i.settings)==null?void 0:T.strength)||1;if(p<Z){const et=1-p/Z;n.scale_x*=1+et*.5*nt*t,n.scale_y*=1+et*.5*nt*t}}else if(i.type===tt.Parallax){const Z=((R=i.settings)==null?void 0:R.factor)||15,nt=((F=i.settings)==null?void 0:F.strength)||1,et=this.canvasWidth/2,pt=this.canvasHeight/2,$t=this._lastPointerPos||{x:et,y:pt},xt=($t.x-et)/et,Jt=($t.y-pt)/pt,pe=(((O=e.transform)==null?void 0:O.x)??0)+xt*Z*nt,Te=(((W=e.transform)==null?void 0:W.y)??0)+Jt*Z*nt,$e=(((V=e.transform)==null?void 0:V.rotate_x)??0)-Jt*Z*1.5*nt,ye=(((U=e.transform)==null?void 0:U.rotate_y)??0)+xt*Z*1.5*nt,Le=Math.min(1,10*t);n.x=this.lerp(n.x??((D=e.transform)==null?void 0:D.x)??0,pe,Le),n.y=this.lerp(n.y??((Y=e.transform)==null?void 0:Y.y)??0,Te,Le),n.rotate_x=this.lerp(n.rotate_x??((ot=e.transform)==null?void 0:ot.rotate_x)??0,$e,Le),n.rotate_y=this.lerp(n.rotate_y??((J=e.transform)==null?void 0:J.rotate_y)??0,ye,Le)}else if(i.type===tt.Fold){if(p<300){const Z=1-p/300,nt=(l>0?-1:1)*Z*10,et=1-Z*.1,pt=d/300*Z*20,$t=-(l/300)*Z*20,xt=Math.min(1,10*t);n.skew_x=this.lerp(n.skew_x??((at=e.transform)==null?void 0:at.skew_x)??0,nt,xt),n.scale_y=this.lerp(n.scale_y??((j=e.transform)==null?void 0:j.scale_y)??1,(((it=e.transform)==null?void 0:it.scale_y)??1)*et,xt),n.rotate_x=this.lerp(n.rotate_x??((B=e.transform)==null?void 0:B.rotate_x)??0,pt,xt),n.rotate_y=this.lerp(n.rotate_y??((X=e.transform)==null?void 0:X.rotate_y)??0,$t,xt),n.style=n.style||{...e.style},n.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((N=i.settings)==null?void 0:N.opacity)??.5}}}else if(i.type===tt.Crumple){if(p<300){const Z=1-p/300,nt=Z*(Math.random()-.5)*5,et=Z*(Math.random()-.5)*.05,pt=Math.min(1,15*t);n.skew_x=this.lerp(n.skew_x??((ct=e.transform)==null?void 0:ct.skew_x)??0,nt,pt),n.scale_x=this.lerp(n.scale_x??((Mt=e.transform)==null?void 0:Mt.scale_x)??1,(((bt=e.transform)==null?void 0:bt.scale_x)??1)*(1+et),pt),n.scale_y=this.lerp(n.scale_y??((wt=e.transform)==null?void 0:wt.scale_y)??1,(((gt=e.transform)==null?void 0:gt.scale_y)??1)*(1+et),pt),n.style=n.style||{...e.style},n.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((It=i.settings)==null?void 0:It.intensity)??1,scale:((ut=i.settings)==null?void 0:ut.scale)??2}}}else if(i.type===tt.Squash){const Z=((Lt=i.settings)==null?void 0:Lt.strength)||.8;p<(e.width||100)&&this.isMouseDown?(n.scale_y=this.lerp(n.scale_y??1,(((Wt=e.transform)==null?void 0:Wt.scale_y)??1)*Z,.3),n.scale_x=this.lerp(n.scale_x??1,(((q=e.transform)==null?void 0:q.scale_x)??1)*(1+(1-Z)*.4),.3)):(n.scale_y=this.lerp(n.scale_y??1,((ft=e.transform)==null?void 0:ft.scale_y)??1,.2),n.scale_x=this.lerp(n.scale_x??1,((Bt=e.transform)==null?void 0:Bt.scale_x)??1,.2))}else if(i.type===tt.TextCounter){const Z=((Ot=i.settings)==null?void 0:Ot.duration)||2,nt=((Pt=i.settings)==null?void 0:Pt.from)||0,et=((vt=i.settings)==null?void 0:vt.to)||100;i._runtimeStart===void 0&&(i._runtimeStart=this.currentTime);const pt=this.currentTime-i._runtimeStart,$t=Math.min(1,pt/Z),xt=Math.floor(nt+(et-nt)*$t);if(((Yt=e.geometry)==null?void 0:Yt.type)==="Text"){const Jt=((zt=i.settings)==null?void 0:zt.prefix)||"",pe=((Gt=i.settings)==null?void 0:Gt.suffix)||"";n.geometry||(n.geometry={...e.geometry}),n.geometry.text=`${Jt}${xt}${pe}`}}else if(i.type===tt.Spotlight){const Z=((Dt=i.settings)==null?void 0:Dt.radius)||250,nt=((te=i.settings)==null?void 0:te.strength)||1.5;if(p<Z){const et=Math.pow(1-p/Z,2);n.style||(n.style={...e.style}),n.style.adjustments||(n.style.adjustments={...(ie=e.style)==null?void 0:ie.adjustments}),n.style.adjustments.exposure=(((ve=(ce=e.style)==null?void 0:ce.adjustments)==null?void 0:ve.exposure)||0)+et*nt*50}else(_e=n.style)!=null&&_e.adjustments&&(n.style.adjustments.exposure=this.lerp(n.style.adjustments.exposure||0,((Ee=(ge=e.style)==null?void 0:ge.adjustments)==null?void 0:Ee.exposure)||0,.1))}else if(i.type===tt.Noise||i.type===tt.Float){const Z=(((Zt=i.settings)==null?void 0:Zt.frequency)||((Me=i.settings)==null?void 0:Me.speed)||1)*.002,nt=(((Re=i.settings)==null?void 0:Re.amplitude)||((Ie=i.settings)==null?void 0:Ie.range)||50)*(((de=i.settings)==null?void 0:de.strength)||1),et=Date.now();n.x+=Math.sin(et*Z)*nt*t,n.y+=Math.cos(et*Z*.8)*nt*t,n.rotation+=Math.sin(et*Z*.5)*5*t}else if(i.type===tt.Pulse){const Z=(((me=i.settings)==null?void 0:me.speed)||1)*.005,nt=(((Ae=i.settings)==null?void 0:Ae.scale)||1.2)-1,et=Math.sin(Date.now()*Z),pt=((he=i.settings)==null?void 0:he.strength)||1;n.scale_x*=1+et*nt*pt*t,n.scale_y*=1+et*nt*pt*t,n.style&&(n.style.exposure=(n.style.exposure||1)+Math.max(0,et)*.1*pt*t)}else if(i.type===tt.Draggable){if(!this.draggingBehaviors.has(e.id)){const nt=((mt=i.settings)==null?void 0:mt.radius)||150;if(p<nt){const et=((rt=i.settings)==null?void 0:rt.strength)||1,pt=Math.max(0,1-p/nt);this.applyBehaviorSensor(n,re.PositionX,pt*et,t,i.settings,e,l,d,p),this.applyBehaviorSensor(n,re.PositionY,pt*et,t,i.settings,e,l,d,p)}}}else if(i.type===tt.Scroll){const Z=((z=i.settings)==null?void 0:z.axis)||"vertical",nt=((K=i.settings)==null?void 0:K.factor)||.5,et=((G=i.settings)==null?void 0:G.strength)||1,pt=((x=i.settings)==null?void 0:x.scaleFactor)||0;(Z==="vertical"||Z==="both")&&(n.y+=this.scrollOffset.y*nt*et*t),(Z==="horizontal"||Z==="both")&&(n.x+=this.scrollOffset.x*nt*et*t),pt!==0&&(n.scale_x*=1+this.scrollOffset.y*pt*t,n.scale_y*=1+this.scrollOffset.y*pt*t)}else if(i.type===tt.LookAt){const Z=((Q=i.settings)==null?void 0:Q.factor)||1,nt=((H=i.settings)==null?void 0:H.strength)||1,et=Math.atan2(-d,-l)*(180/Math.PI),pt=n.rotation,$t=(et-pt+180)%360-180;n.rotation+=$t*Z*nt*t*10}else if(i.type===tt.Scan){const Z=(((lt=i.settings)==null?void 0:lt.speed)||1)*.004,nt=((kt=i.settings)==null?void 0:kt.strength)||1,et=(Math.sin(Date.now()*Z)+1)/2;n.style&&(n.style.exposure=(n.style.exposure||1)+et*nt*t*5),n.x+=(et-.5)*20*nt*t}else if(i.type===tt.Glint)n.style=n.style||{...e.style},n.style.artEffect={enabled:!0,type:"glint_overlay",intensity:((At=i.settings)==null?void 0:At.strength)??.8};else if(i.type===tt.Ratchet){const Z=((Ht=i.settings)==null?void 0:Ht.steps)||12,nt=(((Ut=i.settings)==null?void 0:Ut.speed)||1)*30,et=Math.floor(n.rotation/(360/Z))*(360/Z);n.rotation=this.lerp(n.rotation,et+nt*t,.1)}else if(i.type===tt.Jitter&&p<300){const Z=((qt=i.settings)==null?void 0:qt.strength)||1,nt=((($=i.settings)==null?void 0:$.intensity)||5)*Z;n.x+=(Math.random()-.5)*nt*t*60,n.y+=(Math.random()-.5)*nt*t*60,n.rotation+=(Math.random()-.5)*nt*t*120}else if(i.type===tt.Follower){const Z=(dt=i.settings)==null?void 0:dt.targetId;if(Z){const nt=this.objectStates.get(Z);if(nt){const et=((Rt=i.settings)==null?void 0:Rt.stiffness)||.1,pt=nt.x-n.x,$t=nt.y-n.y;n.x+=pt*et*t*60,n.y+=$t*et*t*60}}}else if(i.type===tt.Wrap)n.x<0?n.x=this.canvasWidth:n.x>this.canvasWidth&&(n.x=0),n.y<0?n.y=this.canvasHeight:n.y>this.canvasHeight&&(n.y=0);else if(i.type===tt.Gravity){const Z=((Nt=i.settings)==null?void 0:Nt.strength)||9.8;n.y+=Z*t*10}else if(i.type===tt.Velocity){const Z=((st=i.settings)==null?void 0:st.vx)||0,nt=((yt=i.settings)==null?void 0:yt.vy)||0;n.x+=Z*t*10,n.y+=nt*t*10}else if(i.type===tt.Shear){const Z=((St=i.settings)==null?void 0:St.strength)||1,nt=((ee=i.settings)==null?void 0:ee.radius)||300;if(p<nt){const et=1-p/nt;n.skew_x=this.lerp(n.skew_x||0,(((Ct=e.transform)==null?void 0:Ct.skew_x)||0)+et*Z*30,.1)}else n.skew_x=this.lerp(n.skew_x||0,((Vt=e.transform)==null?void 0:Vt.skew_x)||0,.05)}else if(i.type===tt.Lens){const Z=((Tt=i.settings)==null?void 0:Tt.radius)||200,nt=((Xt=i.settings)==null?void 0:Xt.strength)||.5;if(p<Z){const et=Math.pow(1-p/Z,2);n.scale_x=this.lerp(n.scale_x??1,(((Ft=e.transform)==null?void 0:Ft.scale_x)??1)*(1+et*nt),.2),n.scale_y=this.lerp(n.scale_y??1,(((le=e.transform)==null?void 0:le.scale_y)??1)*(1+et*nt),.2)}else n.scale_x=this.lerp(n.scale_x??1,((fe=e.transform)==null?void 0:fe.scale_x)??1,.1),n.scale_y=this.lerp(n.scale_y??1,((Oe=e.transform)==null?void 0:Oe.scale_y)??1,.1)}else if(i.type===tt.LayoutAnimation){const Z=((jt=i.settings)==null?void 0:jt.watchProperties)||["x","y","scale_x","scale_y","opacity","rotation"],nt=((oe=i.settings)==null?void 0:oe.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const et=this._layoutAnimCache.get(e.id);for(const pt of Z){const $t=this.getObjectProperty(n,e,pt);if($t===void 0)continue;const xt=et.get(pt);if(!xt)et.set(pt,{from:$t,to:$t,startTime:this.currentTime,duration:0});else if(xt.to!==$t){const pe=this.getObjectProperty(n,e,pt);et.set(pt,{from:pe??xt.from,to:$t,startTime:this.currentTime,duration:((ne=i.settings)==null?void 0:ne.duration)??nt})}const Jt=et.get(pt);if(Jt.duration>0&&Jt.from!==Jt.to){const pe=this.currentTime-Jt.startTime,Te=Math.min(1,pe/Jt.duration),$e=this.applyEasing(Te,((Fe=i.settings)==null?void 0:Fe.easing)||"easeOutCubic"),ye=Jt.from+(Jt.to-Jt.from)*$e;this.setObjectProperty(n,e,pt,ye)}}}else if(i.type===tt.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const Z=this._layoutAnimCache.get(e.id),nt=((Be=i.settings)==null?void 0:Be.defaultDuration)||.3,et=["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 pt of et){const $t=this.getObjectProperty(n,e,pt);if($t===void 0||typeof $t!="number")continue;const xt=Z.get(pt);if(!xt)Z.set(pt,{from:$t,to:$t,startTime:this.currentTime,duration:0});else if(xt.to!==$t){const pe=this.getObjectProperty(n,e,pt);Z.set(pt,{from:pe??xt.from,to:$t,startTime:this.currentTime,duration:nt})}const Jt=Z.get(pt);if(Jt.duration>0&&Jt.from!==Jt.to){const pe=this.currentTime-Jt.startTime,Te=Math.min(1,pe/Jt.duration),$e=this.applyEasing(Te,((xe=i.settings)==null?void 0:xe.defaultEasing)||"easeOutCubic"),ye=Jt.from+(Jt.to-Jt.from)*$e;this.setObjectProperty(n,e,pt,ye)}}}else if(i.type===tt.SpringChain){const Z=((We=i.settings)==null?void 0:We.connections)||[],nt=((De=i.settings)==null?void 0:De.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const et=this._springChainState.get(e.id);for(const $t of Z){if(!et.has($t.targetId)){const xt=this.objectStates.get($t.targetId);et.set($t.targetId,{x:(xt==null?void 0:xt.x)??0,y:(xt==null?void 0:xt.y)??0,vx:0,vy:0})}et.has(e.id)||et.set(e.id,{x:n.x,y:n.y,vx:0,vy:0})}const pt=et.get(e.id);if(pt){pt.x=n.x,pt.y=n.y;for(const $t of Z){const xt=et.get($t.targetId);if(!xt)continue;const Jt=xt.x-pt.x,pe=xt.y-pt.y,Te=Math.sqrt(Jt*Jt+pe*pe)||.001,ye=(Te-($t.restLength||50))*($t.stiffness||.8),Le=Jt/Te*ye,Qe=pe/Te*ye;pt.vx+=Le*t*10,pt.vy+=Qe*t*10,xt.vx-=Le*t*10,xt.vy-=Qe*t*10,pt.vx*=1-nt*t*10,pt.vy*=1-nt*t*10,xt.vx*=1-nt*t*10,xt.vy*=1-nt*t*10;const Pe=this.objectStates.get($t.targetId);Pe&&(Pe.x+=xt.vx*t,Pe.y+=xt.vy*t)}n.x+=pt.vx*t,n.y+=pt.vy*t}}else if(i.type===tt.ParticleEmitter){const Z=((Ye=i.settings)==null?void 0:Ye.rate)||10,nt=((Ge=i.settings)==null?void 0:Ge.speed)||100,et=((se=i.settings)==null?void 0:se.size)||5,pt=((ue=i.settings)==null?void 0:ue.lifetime)||2,$t=((Se=i.settings)==null?void 0:Se.gravity)||0,xt=((Xe=i.settings)==null?void 0:Xe.color)||"#ffffff",Jt=((Ne=i.settings)==null?void 0:Ne.maxParticles)||200,pe=(ke=i.settings)!=null&&ke.rateInputId?this.inputs.get(i.settings.rateInputId)??Z:Z,Te=(Ce=i.settings)!=null&&Ce.gravityInputId?this.inputs.get(i.settings.gravityInputId)??$t:$t,$e=(we=i.settings)!=null&&we.speedInputId?this.inputs.get(i.settings.speedInputId)??nt:nt;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const ye=this._emitterPools.get(e.id);let Le=0;i._pendingBurst&&i._pendingBurst>0&&(Le=i._pendingBurst,i._pendingBurst=0);const Qe=Math.floor(pe*t)+(Le||0);for(let Pe=0;Pe<Math.min(Qe,Jt-ye.length);Pe++){const be=Math.random()*Math.PI*2,ms=$e*(.5+Math.random()*.5);ye.push({x:n.x,y:n.y,vx:Math.cos(be)*ms,vy:Math.sin(be)*ms,life:0,maxLife:pt*(.5+Math.random()*.5),size:et*(.5+Math.random()),color:xt,opacity:1})}for(let Pe=ye.length-1;Pe>=0;Pe--){const be=ye[Pe];be.vy+=Te*t*10,be.x+=be.vx*t,be.y+=be.vy*t,be.life+=t,be.opacity=Math.max(0,1-be.life/be.maxLife),be.life>=be.maxLife&&ye.splice(Pe,1)}}})})}applyBehaviorSensor(t,s,o,e,n,i,a=0,r=0,l=1){var h,f,v,g,c,b,S,w,C,M,I,_,E,P,L,k,A,T,R,F,O,W,V,U;const d=(n==null?void 0:n.intensity)||(n==null?void 0:n.strength)||1,p=Math.min(1,15*e),u=l>0?a/l:0,m=l>0?r/l:0;switch(s){case re.Scale:{const D=((h=i==null?void 0:i.transform)==null?void 0:h.scale_x)??1,Y=((f=i==null?void 0:i.transform)==null?void 0:f.scale_y)??1,ot=D*(1+o*d*.4),J=Y*(1+o*d*.4);t.scale_x=(t.scale_x??D)*(1-p)+ot*p,t.scale_y=(t.scale_y??Y)*(1-p)+J*p;break}case re.Opacity:{const D=((v=i==null?void 0:i.transform)==null?void 0:v.opacity)??100,Y=Math.max(0,Math.min(100,D-o*d*100));t.opacity=(t.opacity??D)*(1-p)+Y*p;break}case re.RotateZ:{const D=((g=i==null?void 0:i.transform)==null?void 0:g.rotation)??0,Y=D+o*d*45;t.rotation=(t.rotation??D)*(1-p)+Y*p;break}case re.RotateX:{const D=((c=i==null?void 0:i.transform)==null?void 0:c.rotate_x)??0,Y=D-m*o*d*60;t.rotate_x=(t.rotate_x??D)*(1-p)+Y*p;break}case re.RotateY:{const D=((b=i==null?void 0:i.transform)==null?void 0:b.rotate_y)??0,Y=D+u*o*d*60;t.rotate_y=(t.rotate_y??D)*(1-p)+Y*p;break}case re.PositionX:{const D=((S=i==null?void 0:i.transform)==null?void 0:S.x)??0,Y=D-u*o*d*40;t.x=(t.x??D)*(1-p)+Y*p;break}case re.PositionY:{const D=((w=i==null?void 0:i.transform)==null?void 0:w.y)??0,Y=D-m*o*d*40;t.y=(t.y??D)*(1-p)+Y*p;break}case re.SkewX:{const D=((C=i==null?void 0:i.transform)==null?void 0:C.skew_x)??0,Y=D+u*o*d*45;t.skew_x=(t.skew_x??D)*(1-p)+Y*p,t.skew_x>85&&(t.skew_x=85),t.skew_x<-85&&(t.skew_x=-85);break}case re.Blur:{t.style||(t.style={...i==null?void 0:i.style}),t.style.blur||(t.style.blur={...(M=i==null?void 0:i.style)==null?void 0:M.blur});const D=((_=(I=i==null?void 0:i.style)==null?void 0:I.blur)==null?void 0:_.amount)||0,Y=D+o*((n==null?void 0:n.blur)||20)*d;t.style.blur.amount=(t.style.blur.amount??D)*(1-p)+Y*p;break}case re.Exposure:{t.style||(t.style={...i==null?void 0:i.style}),t.style.adjustments||(t.style.adjustments={...(E=i==null?void 0:i.style)==null?void 0:E.adjustments});const D=((L=(P=i==null?void 0:i.style)==null?void 0:P.adjustments)==null?void 0:L.exposure)||0,Y=D+o*((n==null?void 0:n.exposure)||50)*d;t.style.adjustments.exposure=(t.style.adjustments.exposure??D)*(1-p)+Y*p;break}case re.HueShift:{t.style||(t.style={...i==null?void 0:i.style}),t.style.adjustments||(t.style.adjustments={...(k=i==null?void 0:i.style)==null?void 0:k.adjustments});const D=((T=(A=i==null?void 0:i.style)==null?void 0:A.adjustments)==null?void 0:T.hue)||0,Y=D+o*((n==null?void 0:n.hue)||180)*d;t.style.adjustments.hue=(t.style.adjustments.hue??D)*(1-p)+Y*p;break}case re.Negative:{t.style||(t.style={...i==null?void 0:i.style}),t.style.adjustments||(t.style.adjustments={...(R=i==null?void 0:i.style)==null?void 0:R.adjustments});const D=((O=(F=i==null?void 0:i.style)==null?void 0:F.adjustments)==null?void 0:O.negative)||0,Y=D+o*((n==null?void 0:n.negative)||100)*d;t.style.adjustments.negative=(t.style.adjustments.negative??D)*(1-p)+Y*p;break}case re.CornerRadius:{const D=((W=i==null?void 0:i.transform)==null?void 0:W.corner_radius)||0,Y=D+o*d*50;t.corner_radius=(t.corner_radius??D)*(1-p)+Y*p;break}case re.StrokeWidth:{t.style||(t.style={...i==null?void 0:i.style});const D=((V=i==null?void 0:i.style)==null?void 0:V.borderWidth)||0,Y=D+o*d*10;t.style.borderWidth=(t.style.borderWidth??D)*(1-p)+Y*p;break}case re.LetterSpacing:{t.geometry||(t.geometry={});const D=((U=i==null?void 0:i.geometry)==null?void 0:U.letterSpacing)||0,Y=D+o*d*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??D)*(1-p)+Y*p;break}}}getObjectProperty(t,s,o){const e=o.replace(/\[(\d+)\]/g,".$1").split(".");let n=t;for(const i of e){if(n==null||typeof n!="object")return;if(i==="style"&&t.style===void 0){n=s.style;continue}n=n[i]}return typeof n=="number"?n:void 0}setObjectProperty(t,s,o,e){const n=o.replace(/\[(\d+)\]/g,".$1").split(".");let i=t;for(let r=0;r<n.length-1;r++){const l=n[r];if(i[l]===void 0||i[l]===null){const d=s,p=n.slice(0,r+1).reduce((h,f)=>h==null?void 0:h[f],d),u=n[r+1],m=!isNaN(Number(u));i[l]=p!==void 0?Array.isArray(p)?[...p]:{...p}:m?[]:{}}i=i[l]}const a=n[n.length-1];i!=null&&(i[a]=e)}applyEasing(t,s){switch(s){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,s,o){return t*(1-o)+s*o}deepMerge(t,s){if(!t)return s;if(!s)return t;if(typeof t!="object"||typeof s!="object"||t===null||s===null)return s;if(Array.isArray(s)){if(!Array.isArray(t))return s;const e=[...t];for(let n=0;n<s.length;n++)s[n]&&typeof s[n]=="object"&&!Array.isArray(s[n])&&t[n]&&typeof t[n]=="object"?e[n]=this.deepMerge(t[n],s[n]):e[n]=s[n];return e}const o={...t};for(const e in s)Object.prototype.hasOwnProperty.call(s,e)&&(s[e]&&typeof s[e]=="object"&&!Array.isArray(s[e])?o[e]=this.deepMerge(t[e],s[e]):Array.isArray(s[e])?o[e]=this.deepMerge(t[e],s[e]):o[e]=s[e]);return o}processFabricAdjustmentsCanvas(t,s,o,e){if(!e)return t;const n=(e.exposure||0)/100,i=(e.contrast||0)/100,a=(e.saturation||0)/100,r=(e.temperature||0)/200,l=(e.tint||0)/200,d=(e.highlights||0)/500,p=(e.shadows||0)/500,u=e.hue||0,m=(e.negative||0)/100,h=e.blur||0;if(!(n!==0||i!==0||a!==0||r!==0||l!==0||d!==0||p!==0||u!==0||m!==0||h>0))return t;const v=t.naturalWidth||Math.max(1,Math.round(s)),g=t.naturalHeight||Math.max(1,Math.round(o)),c=document.createElement("canvas");c.width=v,c.height=g;const b=c.getContext("2d");if(!b)return t;const S=[];h>0&&S.push(`blur(${h}px)`),u!==0&&S.push(`hue-rotate(${Math.round(u)}deg)`),S.length>0&&(b.filter=S.join(" ")),b.drawImage(t,0,0,v,g);try{const w=b.getImageData(0,0,v,g),C=w.data,M=C.length,I=n*255,_=i>=0?(1+i)/Math.max(.01,1-i):1+i,E=1+a,P=1+r-l/2,L=1+l,k=1-r-l/2,A=1+d+p,T=p*25.5,R=1-m/50,F=(1-R)*255;for(let O=0;O<M;O+=4){let W=C[O],V=C[O+1],U=C[O+2];if(n!==0&&(W+=I,V+=I,U+=I),i!==0&&(W=(W-127.5)*_+127.5,V=(V-127.5)*_+127.5,U=(U-127.5)*_+127.5),a!==0){const D=.2989*W+.587*V+.114*U;W=D+(W-D)*E,V=D+(V-D)*E,U=D+(U-D)*E}(r!==0||l!==0)&&(W=W*P,V=V*L,U=U*k),(d!==0||p!==0)&&(W=W*A+T,V=V*A+T,U=U*A+T),m!==0&&(W=W*R+F,V=V*R+F,U=U*R+F),C[O]=Math.min(255,Math.max(0,W)),C[O+1]=Math.min(255,Math.max(0,V)),C[O+2]=Math.min(255,Math.max(0,U))}return b.putImageData(w,0,0),c}catch{return c}}renderFittedImage(t,s,o,e,n,i,a="cover"){const r=s.naturalWidth||s.width||n,l=s.naturalHeight||s.height||i,d=r/l,p=n/i;let u=n,m=i,h=o,f=e;a==="cover"?d>p?(u=i*d,h=o-(u-n)/2):(m=n/d,f=e-(m-i)/2):a==="contain"&&(d>p?(m=n/d,f=e+(i-m)/2):(u=i*d,h=o+(n-u)/2)),t.drawImage(s,h,f,u,m)}}const ai=_t.forwardRef(({artboard:y,src:t,style:s,autoPlay:o=!0,fit:e="Contain",alignment:n="Center",onReady:i,onTrigger:a,onInputUpdate:r,onComponentChange:l,onToggle:d,onInputChange:p,onInputFocus:u,onInputBlur:m,onLog:h,onLogicUpdate:f,onButtonClick:v,onGraphPointClick:g,currentTime:c,revision:b=0,scrollY:S,scrollX:w,mouseX:C,mouseY:M,isMouseDown:I,inputs:_,interactive:E=!0,onNavigation:P},L)=>{const k=_t.useRef(null),A=_t.useRef(null);A.current||(A.current=new gs);const T=_t.useRef(void 0),R=_t.useRef(0),F=_t.useRef(null),O=_t.useRef(b),W=_t.useRef(null),[,V]=_t.useState(y||null),U=_t.useRef(!0),D=_t.useRef(o),Y=_t.useRef(c);_t.useEffect(()=>{D.current=o},[o]),_t.useEffect(()=>{Y.current=c},[c]),_t.useImperativeHandle(L,()=>k.current),_t.useEffect(()=>(U.current=!0,()=>{U.current=!1,T.current&&cancelAnimationFrame(T.current)}),[]),_t.useEffect(()=>{A.current.setLayout(e,n)},[e,n]),_t.useEffect(()=>{const B=A.current;a&&B.setTriggerCallback(a),r&&B.setInputUpdateCallback((X,N)=>r({[X]:N})),l&&B.setComponentChangeCallback(X=>l(X)),d&&B.setToggleCallback(d),p&&B.setInputChangeCallback(p),u&&B.setInputFocusCallback(u),m&&B.setInputBlurCallback(m),h&&B.setOnLogCallback(X=>h(X,"info")),f&&B.setLogicUpdateCallback(f),v&&B.setButtonClickCallback(v),g&&B.setGraphPointClickCallback(X=>g(X.objectId,X)),P&&B.setNavigationCallback(P)},[a,r,l,d,p,u,m,h,f,v,g,P]),_t.useEffect(()=>{(async()=>{let X=y;if(t&&!y)try{t.startsWith("{")?X=JSON.parse(t):X=await(await fetch(t)).json()}catch(N){console.error("[ExodeUI] Failed to load src:",N)}if(X){const N=A.current,ct=X.id||X.name||"default";(F.current!==ct||O.current!==b||W.current!==X)&&(N.load(X),F.current=ct,O.current=b,W.current=X,V(X),R.current=-1,N.advance(0)),i&&i(N)}})()},[y,t,b]),_t.useEffect(()=>{const B=X=>{if(!A.current||!U.current)return;const N=A.current,ct=k.current;if(!ct)return;const Mt=ct.getContext("2d");if(!Mt)return;const bt=X/1e3;R.current<0&&(R.current=bt),R.current===0&&(R.current=bt);let wt=bt-R.current;wt>.1&&(wt=.1),R.current=bt;const gt=ct.getBoundingClientRect(),It=window.devicePixelRatio||1,ut=Math.round(gt.width*It),Lt=Math.round(gt.height*It);(ct.width!==ut||ct.height!==Lt)&&(ct.width=ut,ct.height=Lt);try{D.current?N.advance(wt):Y.current!==void 0&&N.seek(Y.current),N.render(Mt,ct.width,ct.height)}catch(Wt){console.error("[ExodeUICanvas] Error in animation loop:",Wt),h&&h(`[Error] Animation loop crashed: ${Wt}`,"error")}T.current=requestAnimationFrame(B)};return T.current=requestAnimationFrame(B),()=>{T.current&&cancelAnimationFrame(T.current)}},[]),_t.useEffect(()=>{const B=A.current;S!==void 0&&B.updateInput("scrollY",S),w!==void 0&&B.updateInput("scrollX",w),C!==void 0&&B.updateInput("mouseX",C),M!==void 0&&B.updateInput("mouseY",M),I!==void 0&&B.updateInput("isMouseDown",I),_&&Object.entries(_).forEach(([X,N])=>B.updateInput(X,N))},[S,w,C,M,I,_]);const ot=(B,X)=>{if(!E||!k.current)return;B.stopPropagation(),"nativeEvent"in B&&B.nativeEvent&&typeof B.nativeEvent.stopImmediatePropagation=="function"?B.nativeEvent.stopImmediatePropagation():typeof B.stopImmediatePropagation=="function"&&B.stopImmediatePropagation();const N=k.current,ct=N.getBoundingClientRect(),Mt=B.clientX-ct.left,bt=B.clientY-ct.top,wt=window.devicePixelRatio||1;(X==="click"||X==="down"||X==="up")&&h&&h(`[Canvas] Pointer ${X} at rect(${Math.round(Mt)},${Math.round(bt)}) mapped to buffer(${Math.round(Mt*wt)},${Math.round(bt*wt)})`,"info"),A.current.handlePointerInput(X,Mt*wt,bt*wt,N.width,N.height)};_t.useEffect(()=>{if(!E)return;const B=N=>{var ct,Mt,bt;((ct=document.activeElement)==null?void 0:ct.tagName)==="INPUT"||((Mt=document.activeElement)==null?void 0:Mt.tagName)==="TEXTAREA"||(bt=A.current)==null||bt.handleKeyDown(N)},X=N=>{var ct,Mt,bt;((ct=document.activeElement)==null?void 0:ct.tagName)==="INPUT"||((Mt=document.activeElement)==null?void 0:Mt.tagName)==="TEXTAREA"||(bt=A.current)==null||bt.handleKeyUp(N)};return window.addEventListener("keydown",B),window.addEventListener("keyup",X),()=>{window.removeEventListener("keydown",B),window.removeEventListener("keyup",X)}},[E]),_t.useEffect(()=>{const B=k.current;if(!B||!E)return;const X=N=>{if(N.preventDefault(),N.stopPropagation(),A.current){const ct=B.getBoundingClientRect(),Mt=window.devicePixelRatio||1,bt=(N.clientX-ct.left)*Mt,wt=(N.clientY-ct.top)*Mt;let gt=N.deltaX,It=N.deltaY;N.deltaMode===1?(gt*=25,It*=25):N.deltaMode===2&&(gt*=100,It*=100),A.current.handlePointerInput("move",bt,wt,B.width,B.height),A.current.handleWheel(gt,It,bt,wt,B.width,B.height)}};return B.addEventListener("wheel",X,{passive:!1}),()=>{B.removeEventListener("wheel",X)}},[E]);const[J,at]=_t.useState([]);_t.useEffect(()=>{if(y&&y.objects){const B=y.objects.filter(X=>{var N,ct;return X.type==="Joystick"&&((N=X.inputBinding)==null?void 0:N.type)==="keyboard"&&((ct=X.inputBinding.keyboardConfig)==null?void 0:ct.showVirtualKeyboard)});at(B)}},[y]);const[,j]=_t.useState(0);_t.useEffect(()=>{if(J.length===0)return;let B;const X=()=>{j(N=>N+1),B=requestAnimationFrame(X)};return B=requestAnimationFrame(X),()=>cancelAnimationFrame(B)},[J.length]);const it=()=>J.map(B=>{const X=B.inputBinding.keyboardConfig,N=gt=>{var ut;const It={key:gt,code:gt,preventDefault:()=>{}};(ut=A.current)==null||ut.handleKeyDown(It)},ct=gt=>{var ut;const It={key:gt,code:gt,preventDefault:()=>{}};(ut=A.current)==null||ut.handleKeyUp(It)},Mt=A.current,bt=gt=>Mt&&Mt.activeKeys?Mt.activeKeys.has(gt.toLowerCase()):!1,wt=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 Qt.jsxs("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",pointerEvents:"auto",zIndex:100},children:[Qt.jsx("div",{style:wt(bt(X.upKey)),onMouseDown:()=>N(X.upKey),onMouseUp:()=>ct(X.upKey),onMouseLeave:()=>ct(X.upKey),onTouchStart:gt=>{gt.preventDefault(),N(X.upKey)},onTouchEnd:gt=>{gt.preventDefault(),ct(X.upKey)},children:X.upKey.toUpperCase()}),Qt.jsxs("div",{style:{display:"flex",gap:"8px"},children:[Qt.jsx("div",{style:wt(bt(X.leftKey)),onMouseDown:()=>N(X.leftKey),onMouseUp:()=>ct(X.leftKey),onMouseLeave:()=>ct(X.leftKey),onTouchStart:gt=>{gt.preventDefault(),N(X.leftKey)},onTouchEnd:gt=>{gt.preventDefault(),ct(X.leftKey)},children:X.leftKey.toUpperCase()}),Qt.jsx("div",{style:wt(bt(X.downKey)),onMouseDown:()=>N(X.downKey),onMouseUp:()=>ct(X.downKey),onMouseLeave:()=>ct(X.downKey),onTouchStart:gt=>{gt.preventDefault(),N(X.downKey)},onTouchEnd:gt=>{gt.preventDefault(),ct(X.downKey)},children:X.downKey.toUpperCase()}),Qt.jsx("div",{style:wt(bt(X.rightKey)),onMouseDown:()=>N(X.rightKey),onMouseUp:()=>ct(X.rightKey),onMouseLeave:()=>ct(X.rightKey),onTouchStart:gt=>{gt.preventDefault(),N(X.rightKey)},onTouchEnd:gt=>{gt.preventDefault(),ct(X.rightKey)},children:X.rightKey.toUpperCase()})]})]},B.id)});return Qt.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[Qt.jsx("canvas",{ref:k,onPointerDown:B=>{var X;ot(B,"down"),B.currentTarget.setPointerCapture(B.pointerId),(X=k.current)==null||X.focus()},onPointerMove:B=>ot(B,"move"),onPointerUp:B=>{ot(B,"up"),B.currentTarget.releasePointerCapture(B.pointerId)},onPointerCancel:B=>{ot(B,"up"),B.currentTarget.releasePointerCapture(B.pointerId)},onClick:B=>ot(B,"click"),onKeyDown:B=>A.current.handleKeyDown(B.nativeEvent),onKeyUp:B=>A.current.handleKeyUp(B.nativeEvent),onContextMenu:B=>B.preventDefault(),tabIndex:0,style:{...s,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:E?"auto":"none"}}),it()]})});function ri(){const[y,t]=_t.useState(null),s=_t.useCallback((g,c)=>{y==null||y.setInputBool(g,c)},[y]),o=_t.useCallback((g,c)=>{y==null||y.setInputNumber(g,c)},[y]),e=_t.useCallback(g=>{y==null||y.fireTrigger(g)},[y]),n=_t.useCallback((g,c)=>{y==null||y.setInputText(g,c)},[y]),i=_t.useCallback((g,c)=>{y==null||y.setInputNumberArray(g,c)},[y]),a=_t.useCallback((g,c)=>{y==null||y.setInputStringArray(g,c)},[y]),r=_t.useCallback((g,c)=>{y==null||y.updateInput(g,c)},[y]),l=r,d=_t.useCallback((g,c)=>{y==null||y.updateObjectOptions(g,c)},[y]),p=_t.useCallback((g,c,b)=>{y==null||y.updateConstraint(g,c,b)},[y]),u=_t.useCallback((g,c,b)=>{y==null||y.updateGraphData(g,c,b)},[y]),m=_t.useCallback((g,c,b)=>{y==null||y.updateBarChartData(g,c,b)},[y]),h=_t.useCallback((g,c)=>{y==null||y.updatePieChartData(g,c)},[y]),f=_t.useCallback((g,c)=>{y==null||y.setDropdownOptions(g,c)},[y]),v=_t.useCallback(g=>y==null?void 0:y.getInputValue(g),[y]);return{setEngine:t,engine:y,updateInput:r,setInputValue:l,setInputBool:s,setInputNumber:o,fireTrigger:e,setInputText:n,setInputNumberArray:i,setInputStringArray:a,updateConstraint:p,updateGraphData:u,updateBarChartData:m,updatePieChartData:h,setDropdownOptions:f,updateObjectOptions:d,getInputValue:v}}const li=({artboard:y,config:t})=>{const s={...y.seo,...t},o=s.enableSmartExtraction!==!1;_t.useEffect(()=>{const a=s.title||y.name;a&&(document.title=a);let r=s.description;if(!r&&o){const p=y.objects.filter(u=>{var m;return((m=u.geometry)==null?void 0:m.type)==="Text"}).sort((u,m)=>{var h,f;return(((h=m.geometry.text)==null?void 0:h.length)||0)-(((f=u.geometry.text)==null?void 0:f.length)||0)});p.length>0&&(r=p[0].geometry.text)}r&&(e("name","description",r),e("property","og:description",r)),s.keywords&&s.keywords.length>0&&e("name","keywords",s.keywords.join(", "));const l=s.ogImage||y.backgroundImage;l&&e("property","og:image",l),a&&e("property","og:title",a),e("property","og:type","website")},[s,y,o]);const e=(a,r,l)=>{let d=document.querySelector(`meta[${a}="${r}"]`);d||(d=document.createElement("meta"),d.setAttribute(a,r),document.head.appendChild(d)),d.setAttribute("content",l)},n=()=>{const a=[];return a.push(Qt.jsx("h1",{children:s.title||y.name},"artboard-title")),y.objects.forEach((l,d)=>{var p,u;if(!(l.visible===!1||l.isVisible===!1))if(((p=l.geometry)==null?void 0:p.type)==="Text"){const m=l.geometry.text;m&&(l.geometry.fontSize>24?a.push(Qt.jsx("h2",{children:m},l.id||d)):a.push(Qt.jsx("p",{children:m},l.id||d)))}else if(((u=l.geometry)==null?void 0:u.type)==="Image"){const m=l.geometry.src,h=l.altText||l.name||"Illustration";a.push(Qt.jsx("img",{src:m,alt:h},l.id||d))}else l.type==="Button"&&a.push(Qt.jsx("button",{children:l.name||"Button"},l.id||d))}),a},i=s.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:s.title||y.name,description:s.description,image:s.ogImage||y.backgroundImage,abstract:"Animated interface created with ExodeUI"};return Qt.jsxs("div",{id:`exode-seo-${y.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:[n(),Qt.jsx("script",{type:"application/ld+json",children:JSON.stringify(i)})]})},ci={version:"6.4.3"}.version;Kt.BAR_STYLE_PRESETS=oi,Kt.BehaviorSensor=re,Kt.BehaviorType=tt,Kt.ConditionOp=je,Kt.ExodeSEO=li,Kt.ExodeUICanvas=ai,Kt.ExodeUIEngine=gs,Kt.LogicOp=Et,Kt.RapierPhysics=is,Kt.VERSION=ci,Kt.useExodeUI=ri,Object.defineProperty(Kt,Symbol.toStringTag,{value:"Module"})}));
package/dist/index.mjs CHANGED
@@ -6822,7 +6822,7 @@ const Ci = ({ artboard: y, config: t }) => {
6822
6822
  ]
6823
6823
  }
6824
6824
  );
6825
- }, fi = "6.4.2", di = {
6825
+ }, fi = "6.4.3", di = {
6826
6826
  version: fi
6827
6827
  }, wi = di.version;
6828
6828
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exodeui",
3
- "version": "6.4.2",
3
+ "version": "6.4.3",
4
4
  "description": "React Runtime for ExodeUI Animation Engine",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",