exodeui 6.4.5 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
- (function(ee,ne){typeof exports=="object"&&typeof module<"u"?ne(exports,require("react/jsx-runtime"),require("react"),require("@chenglou/pretext"),require("@dimforge/rapier2d-compat"),require("lz-string")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@chenglou/pretext","@dimforge/rapier2d-compat","lz-string"],ne):(ee=typeof globalThis<"u"?globalThis:ee||self,ne(ee.ExodeUIReact={},ee.jsxRuntime,ee.React,ee.pretext,ee.Rapier,ee.LZString))})(this,(function(ee,ne,Nt,qe,pe,vs){"use strict";var di=Object.defineProperty;var pi=(ee,ne,Nt)=>ne in ee?di(ee,ne,{enumerable:!0,configurable:!0,writable:!0,value:Nt}):ee[ne]=Nt;var pt=(ee,ne,Nt)=>pi(ee,typeof ne!="symbol"?ne+"":ne,Nt);function Ss(b){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(b){for(const s in b)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(b,s);Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:()=>b[s]})}}return t.default=b,Object.freeze(t)}const Cs=Ss(vs);var st=(b=>(b.Proximity="Proximity",b.Magnetic="Magnetic",b.Repel="Repel",b.Orbit="Orbit",b.Vortex="Vortex",b.Fluid="Fluid",b.Elastic="Elastic",b.Holographic="Holographic",b.Sticky="Sticky",b.Dilation="Dilation",b.Parallax="Parallax",b.Noise="Noise",b.Float="Float",b.Pulse="Pulse",b.Draggable="Draggable",b.Scroll="Scroll",b.LookAt="LookAt",b.Glint="Glint",b.Scan="Scan",b.Ratchet="Ratchet",b.Jitter="Jitter",b.Follower="Follower",b.Wrap="Wrap",b.Typewriter="Typewriter",b.Scramble="Scramble",b.Wave="Wave",b.Bounce="Bounce",b.TextTrail="TextTrail",b.Reveal3D="Reveal3D",b.RevealSlide="RevealSlide",b.RevealBlur="RevealBlur",b.TextLiquid="TextLiquid",b.TextVortex="TextVortex",b.TextExplosion="TextExplosion",b.TextRain="TextRain",b.TextGravity="TextGravity",b.TextMatrix="TextMatrix",b.TextNeon="TextNeon",b.TextDissolve="TextDissolve",b.TextOrganic="TextOrganic",b.TextBreathe="TextBreathe",b.TextSpin="TextSpin",b.TextMagnet="TextMagnet",b.TextPerspective="TextPerspective",b.TextMirror="TextMirror",b.TextFloral="TextFloral",b.TextSmoke="TextSmoke",b.TextVariable="TextVariable",b.TextZing="TextZing",b.TextElastic="TextElastic",b.TextGlitch3D="TextGlitch3D",b.GlitchText="GlitchText",b.TextCounter="TextCounter",b.Squash="Squash",b.Spotlight="Spotlight",b.Lens="Lens",b.Gravity="Gravity",b.Velocity="Velocity",b.Shear="Shear",b.LayoutAnimation="LayoutAnimation",b.SpringChain="SpringChain",b.ParticleEmitter="ParticleEmitter",b.StateReactive="StateReactive",b.Fold="Fold",b.Crumple="Crumple",b))(st||{}),ue=(b=>(b.Scale="Scale",b.Opacity="Opacity",b.RotateZ="RotateZ",b.RotateX="RotateX",b.RotateY="RotateY",b.PositionX="PositionX",b.PositionY="PositionY",b.SkewX="SkewX",b.Blur="Blur",b.Exposure="Exposure",b.HueShift="HueShift",b.Negative="Negative",b.CornerRadius="CornerRadius",b.StrokeWidth="StrokeWidth",b.BoxShadow="BoxShadow",b.FontSize="FontSize",b.LetterSpacing="LetterSpacing",b))(ue||{}),es=(b=>(b.Equal="Equal",b.NotEqual="NotEqual",b.GreaterThan="GreaterThan",b.LessThan="LessThan",b.GreaterEqual="GreaterEqual",b.LessEqual="LessEqual",b.IsTrue="IsTrue",b.IsFalse="IsFalse",b))(es||{}),Ht=(b=>(b.AND="AND",b.OR="OR",b.NOT="NOT",b.XOR="XOR",b.OBJECT="OBJECT",b.PROPERTY="PROPERTY",b.GET_PROPERTY="GET_PROPERTY",b.SET_PROPERTY="SET_PROPERTY",b.ADD="ADD",b.SUB="SUB",b.MUL="MUL",b.DIV="DIV",b.MOD="MOD",b.POW="POW",b.ABS="ABS",b.ROUND="ROUND",b.FLOOR="FLOOR",b.CEIL="CEIL",b.SIN="SIN",b.COS="COS",b.TAN="TAN",b.CLAMP="CLAMP",b.REMAP="REMAP",b.EQ="EQ",b.NEQ="NEQ",b.GT="GT",b.LT="LT",b.GTE="GTE",b.LTE="LTE",b.IF_ELSE="IF_ELSE",b.VALUE="VALUE",b.INPUT="INPUT",b.LOG="LOG",b.SCROLL_X="SCROLL_X",b.SCROLL_Y="SCROLL_Y",b.MOUSE_X="MOUSE_X",b.MOUSE_Y="MOUSE_Y",b.IS_MOUSE_DOWN="IS_MOUSE_DOWN",b.EFFECTOR="EFFECTOR",b.MONITOR="MONITOR",b.DELAY="DELAY",b.SPRING_PULL="SPRING_PULL",b.SPRING_SETTLE="SPRING_SETTLE",b.EMIT="EMIT",b))(Ht||{});function ws(b){if(b.length<5)return b;const t=new Set("aeiouyAEIOUY".split(""));if(/[\u4E00-\u9FFF\u3400-\u4DBF]/.test(b))return b;let o="";for(let e=0;e<b.length;e++){if(o+=b[e],e>=b.length-2)continue;const n=t.has(b[e]),i=t.has(b[e+1]),a=t.has(b[e+2]);n&&!i&&a&&(o+="­"),n&&!i&&!a&&e>=1&&(o+="­")}return o}function Ms(b){return b.replace(/\b([a-zA-Z]{4,})\b/g,(t,s)=>ws(s))}function Is(b,t,s){return b}function ks(b,t,s){return b}const Ve=new Map;function ss(b){var I;const{text:t,fontFamily:s="Inter",fontSize:o=16,fontWeight:e=400,fontStyle:n="normal",lineHeight:i=1.2,width:a=200,letterSpacing:r=0,paragraphSpacing:l=0,paragraphIndent:d=0,textCase:u="none",segments:g=[],enableSegments:p=!1}=b;let f=String(t||"");u==="uppercase"?f=f.toUpperCase():u==="lowercase"?f=f.toLowerCase():u==="capitalize"&&(f=f.replace(/\b\w/g,A=>A.toUpperCase())),b.hyphenation===!0&&(f=Ms(f));const h=`${n} ${e} ${o}px "${s}", sans-serif`,S=`${f}|${h}|${r}|${l}|${d}|${p}|${JSON.stringify(g)}|hyp:${!!b.hyphenation}|comp:${b.composer}|bal:${!!b.balanceRaggedLines}`;let y=Ve.get(S);const c=typeof CanvasRenderingContext2D<"u"?CanvasRenderingContext2D.prototype.measureText:null,v=function(A){if(!c)return{width:0,fontBoundingBoxAscent:0,fontBoundingBoxDescent:0};const _=c.call(this,A);return r!==0&&A&&A.length>0?{..._,width:_.width+(A.length-1)*r}:_};if(!y){try{if(r!==0&&typeof CanvasRenderingContext2D<"u"&&(CanvasRenderingContext2D.prototype.measureText=v),p&&g&&g.length>0){const A=g.map(_=>{let T=_.text||"";const L=_.textCase||u||"none";return L==="uppercase"?T.toUpperCase():L==="lowercase"?T.toLowerCase():L==="capitalize"?T.replace(/\b\w/g,F=>F.toUpperCase()):T}).join("");if(y=qe.prepareWithSegments(A,h),y){let _=0,T=o;for(const L of g){let F=L.text||"";if(!F)continue;const D=L.textCase||u||"none";D==="uppercase"?F=F.toUpperCase():D==="lowercase"?F=F.toLowerCase():D==="capitalize"&&(F=F.replace(/\b\w/g,k=>k.toUpperCase()));const R=L.fontSize||o;R>T&&(T=R);const X=`${L.fontStyle||n} ${L.fontWeight||e} ${R}px "${L.fontFamily||s}", sans-serif`,P=qe.prepareWithSegments(F,X);if(P&&P.widths)for(let k=0;k<P.widths.length;k++){const O=_+k;if(O<y.widths.length){y.widths[O]=P.widths[k];const E=P.kinds[k];if(E===2){const N=F[k];N===`
2
- `||N==="\r"?y.kinds[O]=2:y.kinds[O]=0}else y.kinds[O]=E}}_+=F.length}y.fullText=A,y.maxFontSize=T}}else y=qe.prepareWithSegments(f,h);y&&Ve.set(S,y)}catch(A){return console.error("[ExodeUI] Pretext prepare failed:",A),{width:a,height:0,lineCount:0,lines:[]}}finally{r!==0&&typeof CanvasRenderingContext2D<"u"&&c&&(CanvasRenderingContext2D.prototype.measureText=c)}if(Ve.size>500){const A=Ve.keys().next().value;A&&Ve.delete(A)}}if(d>0&&y&&y.widths&&!y.indentApplied){const A=[...y.widths],_=y.fullText||f;let T=!0;for(let L=0;L<_.length;L++)T&&A[L]!==void 0&&(A[L]+=d,T=!1),(_[L]===`
3
- `||_[L]==="\r")&&(T=!0,_[L]==="\r"&&_[L+1]===`
4
- `&&L++);y={...y,widths:A,indentApplied:!0}}if(!y)return{width:a,height:0,lineCount:0,lines:[]};let m=i;typeof m=="string"&&(m=parseFloat(m)),m>5&&o>0&&(m=m/o),r!==0&&(CanvasRenderingContext2D.prototype.measureText=v);let C;try{const A=y.maxFontSize||o;if(a>=1e5){const _=f.split(/\r\n|\r|\n/);C={lines:_.map(T=>({text:T,width:0})),height:_.length*(m*A),lineCount:_.length}}else C=qe.layoutWithLines(y,a,m*A)}finally{r!==0&&c&&(CanvasRenderingContext2D.prototype.measureText=c)}let w=(C==null?void 0:C.height)!==void 0&&C.height>0?C.height:(((I=C==null?void 0:C.lines)==null?void 0:I.length)||0)*m*o;if(l>0&&C&&C.lines&&C.lines.length>1){let A=0;const _=y.fullText||t;for(let T=0;T<C.lines.length-1;T++)A+=C.lines[T].text.length,(_[A]===`
5
- `||_[A]==="\r")&&(w+=l,A++,_[A-1]==="\r"&&_[A]===`
6
- `&&A++)}let M=(C==null?void 0:C.lines)||[];return b.composer==="every-line"&&M.length>1&&(M=Is(M)),b.balanceRaggedLines===!0&&M.length>1&&(M=ks(M)),{width:a,height:w,lineCount:M.length,lines:M}}function is(b,t,s){let o=String(b||"").trim();if(o&&!isNaN(Number(o))&&!o.includes(" ")&&!o.endsWith("fr")&&!o.endsWith("px")&&!o.endsWith("%")){const r=Math.max(1,parseInt(o));o=new Array(r).fill("1fr").join(" ")}const e=o.split(/\s+/).filter(Boolean),n=new Array(e.length).fill(0);let i=t-(e.length-1)*s,a=0;if(e.forEach((r,l)=>{if(r.endsWith("px")){const d=parseFloat(r);n[l]=d,i-=d}else r.endsWith("fr")?a+=parseFloat(r):r==="auto"&&(n[l]=100,i-=100)}),a>0&&i>0){const r=i/a;e.forEach((l,d)=>{l.endsWith("fr")&&(n[d]=r*parseFloat(l))})}return n}function ns(b,t,s){try{const o=b.autoLayout;return!o||!o.enabled?{childUpdates:[]}:(o.mode||"linear")==="grid"?Ps(b,t,s):Ts(b,t,s)}catch(o){return console.error("Layout Engine Error:",o),{childUpdates:[]}}}function Ts(b,t,s){var F,D;const o=b.autoLayout,{direction:e,spacing:n,padding:i,align:a,wrap:r}=o,l=e==="vertical",d=t.map(R=>{const X=s(R.id),P=R.geometry;let k=(X==null?void 0:X.width)??P.width??100,O=(X==null?void 0:X.height)??P.height??100;if(P.type==="Ellipse"||P.type==="Polygon"||P.type==="Star"){const E=(X==null?void 0:X.radius)??P.radius??(X==null?void 0:X.outer_radius)??P.outer_radius??50;k=E*2,O=E*2}else if(P.type==="Text"){const E=ss({text:(X==null?void 0:X.text)??P.text??"",fontFamily:P.fontFamily,fontSize:P.fontSize,fontWeight:P.fontWeight,fontStyle:P.fontStyle,lineHeight:P.lineHeight,width:P.width||200,letterSpacing:P.letterSpacing,paragraphSpacing:P.paragraphSpacing,paragraphIndent:P.paragraphIndent,textCase:P.textCase,segments:P.segments,enableSegments:P.enableSegments});O=E.height,P.width||(k=E.width)}return k*=R.transform.scale_x||1,O*=R.transform.scale_y||1,{id:R.id,w:k,h:O,original:R}});let u=b.width,g=b.height;const p=((F=b.layoutProps)==null?void 0:F.width)==="hug",f=((D=b.layoutProps)==null?void 0:D.height)==="hug",h=[];let S=[],y=0,c=0;const v=u-i.left-i.right,m=g-i.top-i.bottom;d.forEach(R=>{r&&S.length>0&&(l?c+n+R.h>m:y+n+R.w>v)?(h.push({children:S,width:y,height:c}),S=[R],y=R.w,c=R.h):(S.push(R),l?(y=Math.max(y,R.w),c+=(S.length>1?n:0)+R.h):(y+=(S.length>1?n:0)+R.w,c=Math.max(c,R.h)))}),S.length>0&&h.push({children:S,width:y,height:c}),p&&!l&&(u=Math.max(...h.map(R=>R.width),0)+i.left+i.right),f&&l&&(g=Math.max(...h.map(R=>R.height),0)+i.top+i.bottom);const C=[];let w=i.left,M=i.top;const I=a.toLowerCase(),A=I==="center"||I.endsWith("-center"),_=I.endsWith("-right"),T=I==="center"||I.startsWith("center-"),L=I.startsWith("bottom-");return h.forEach(R=>{let X=w,P=M;l?T?P=i.top+(g-i.top-i.bottom-R.height)/2:L&&(P=g-i.bottom-R.height):A?X=i.left+(u-i.left-i.right-R.width)/2:_&&(X=u-i.right-R.width),R.children.forEach(k=>{var B,G;let O=X,E=P;l?A?O+=(R.width-k.w)/2:_&&(O+=R.width-k.w):T?E+=(R.height-k.h)/2:L&&(E+=R.height-k.h);const N=((B=k.original.layoutProps)==null?void 0:B.width)==="fill",W=((G=k.original.layoutProps)==null?void 0:G.height)==="fill";C.push({id:k.id,x:O+k.w/2-u/2,y:E+k.h/2-g/2,width:N&&l?R.width:void 0,height:W?l?void 0:R.height:void 0}),l?P+=k.h+n:X+=k.w+n}),l?w+=R.width+n:M+=R.height+n}),{frameWidth:p?u:void 0,frameHeight:f?g:void 0,childUpdates:C}}function Ps(b,t,s){const o=b.autoLayout;if(!o)return{childUpdates:[]};const{gridColumns:e,gridRows:n,columnGap:i=0,rowGap:a=0,padding:r,align:l}=o;let d=b.width,u=b.height;const g=d-r.left-r.right,p=u-r.top-r.bottom,f=is(e||"1fr",g,i),h=is(n||"auto",p,a),S=f.length>0?f.reduce((_,T)=>_+T,0)+(f.length-1)*i:0,y=h.length>0?h.reduce((_,T)=>_+T,0)+(h.length-1)*a:0,c=l.toLowerCase(),v=c==="center"||c.endsWith("-center"),m=c.endsWith("-right"),C=c==="center"||c.startsWith("center-"),w=c.startsWith("bottom-");let M=0,I=0;v?M=(g-S)/2:m&&(M=g-S),C?I=(p-y)/2:w&&(I=p-y);const A=[];return t.forEach((_,T)=>{var G,z;const L=T%f.length||0,F=Math.floor(T/f.length)||0;F>=h.length&&h.push(100);const D=f[L],R=h[F];let X=r.left+M+f.slice(0,L).reduce((V,U)=>V+U+i,0),P=r.top+I+h.slice(0,F).reduce((V,U)=>V+U+a,0);const k=s(_.id),O=_.geometry;let E=(k==null?void 0:k.width)??O.width??100,N=(k==null?void 0:k.height)??O.height??100;if(O.type==="Ellipse"||O.type==="Polygon"||O.type==="Star"){const V=(k==null?void 0:k.radius)??O.radius??(k==null?void 0:k.outer_radius)??O.outer_radius??50;E=V*2,N=V*2}E*=_.transform.scale_x||1,N*=_.transform.scale_y||1;let W=X,B=P;v?W+=(D-E)/2:m&&(W+=D-E),C?B+=(R-N)/2:w&&(B+=R-N),A.push({id:_.id,x:W+E/2-d/2,y:B+N/2-u/2,width:((G=_.layoutProps)==null?void 0:G.width)==="fill"?D:void 0,height:((z=_.layoutProps)==null?void 0:z.height)==="fill"?R:void 0})}),{childUpdates:A}}class os{constructor(){pt(this,"world",null);pt(this,"bodies",new Map);pt(this,"colliders",new Map);pt(this,"joints",new Map);pt(this,"initialized",!1);pt(this,"bodyIdByCollider",new Map);pt(this,"onCollisionCB",null);pt(this,"eventQueue",null)}setCollisionCallback(t){this.onCollisionCB=t}async init(t){this.initialized||(await pe.init(),this.world=new pe.World(new pe.Vector2(t.x*100,t.y*100)),this.eventQueue=new pe.EventQueue(!0),this.initialized=!0)}destroy(){this.bodies.clear(),this.colliders.clear(),this.joints.clear(),this.world&&(this.world.free(),this.world=null),this.initialized=!1}setGravity(t){this.world&&(this.world.gravity=new pe.Vector2(t.x*100,t.y*100))}createBody(t){if(!this.world){console.warn("[RapierPhysics] World not initialized");return}this.bodies.has(t.id)&&this.removeBody(t.id);const s=t.isStatic?pe.RigidBodyDesc.fixed():pe.RigidBodyDesc.dynamic();s.setTranslation(t.x,t.y),t.rotation!==void 0&&s.setRotation(t.rotation);const o=this.world.createRigidBody(s);let e;switch(t.type){case"Rectangle":e=pe.ColliderDesc.cuboid(t.width/2,t.height/2);break;case"Ellipse":e=pe.ColliderDesc.ball(Math.max(t.width,t.height)/2);break;case"Triangle":case"Star":case"Polygon":e=pe.ColliderDesc.cuboid(t.width/2,t.height/2);break;default:e=pe.ColliderDesc.cuboid(t.width/2,t.height/2)}if(t.friction!==void 0&&e.setFriction(t.friction),t.restitution!==void 0&&e.setRestitution(t.restitution),t.density!==void 0)e.setDensity(t.density);else if(t.mass!==void 0&&!t.isStatic){const i=t.width*t.height;e.setDensity(t.mass/i)}t.isSensor&&e.setSensor(!0);const n=this.world.createCollider(e,o);this.bodyIdByCollider.set(n.handle,t.id),t.frictionAir!==void 0&&o.setLinearDamping(t.frictionAir*10),this.bodies.set(t.id,o),this.colliders.set(t.id,n)}removeBody(t){const s=this.bodies.get(t),o=this.colliders.get(t);o&&this.bodyIdByCollider.delete(o.handle),s&&this.world&&(this.world.removeRigidBody(s),this.bodies.delete(t),this.colliders.delete(t))}step(t){if(!this.world)return;this.world.step(this.eventQueue);const s=this.onCollisionCB,o=this.eventQueue;s&&o&&o.drainContactEvents((e,n,i)=>{const a=this.bodyIdByCollider.get(e),r=this.bodyIdByCollider.get(n);a&&r&&s(a,r,i)})}getPosition(t){const s=this.bodies.get(t);if(!s)return null;const o=s.translation();return{x:o.x,y:o.y}}getRotation(t){const s=this.bodies.get(t);return s?s.rotation():null}getVelocity(t){const s=this.bodies.get(t);if(!s)return null;const o=s.linvel();return{x:o.x,y:o.y}}setPosition(t,s,o){const e=this.bodies.get(t);e&&e.setTranslation(new pe.Vector2(s,o),!0)}setRotation(t,s){const o=this.bodies.get(t);o&&o.setRotation(s,!0)}setVelocity(t,s,o){const e=this.bodies.get(t);e&&e.setLinvel(new pe.Vector2(s,o),!0)}setAngularVelocity(t,s){const o=this.bodies.get(t);o&&o.setAngvel(s,!0)}applyForce(t,s,o){const e=this.bodies.get(t);e&&e.addForce(new pe.Vector2(s,o),!0)}applyImpulse(t,s,o){const e=this.bodies.get(t);e&&e.applyImpulse(new pe.Vector2(s,o),!0)}createJoint(t){if(!this.world){console.warn("[RapierPhysics] World not initialized");return}this.joints.has(t.id)&&this.removeJoint(t.id);const s=this.bodies.get(t.bodyA),o=this.bodies.get(t.bodyB);if(!s||!o){console.warn(`[RapierPhysics] Cannot create joint ${t.id}: bodyA (${t.bodyA}) or bodyB (${t.bodyB}) not found`);return}const e=new pe.Vector2(t.anchorA.x,t.anchorA.y),n=new pe.Vector2(t.anchorB.x,t.anchorB.y);let i;if(t.type==="Distance"){const a=t.length??100,r=t.stiffness??100,l=t.damping??10;i=pe.JointData.spring(a,r,l,e,n)}else i=pe.JointData.revolute(e,n);try{const a=this.world.createImpulseJoint(i,s,o,!0);this.joints.set(t.id,a)}catch(a){console.error(`[RapierPhysics] Failed to create joint ${t.id}:`,a)}}removeJoint(t){const s=this.joints.get(t);if(s&&this.world){try{this.world.removeImpulseJoint(s,!0)}catch(o){console.error(`[RapierPhysics] Failed to remove joint ${t}:`,o)}this.joints.delete(t)}}}const as=b=>b,_s=b=>b>0?1:0,As=b=>b<1?0:1,rs=b=>b*b,ls=b=>b*(2-b),cs=b=>b<.5?2*b*b:-1+(4-2*b)*b,Es=b=>b*b*b,Ls=b=>--b*b*b+1,Rs=b=>b<.5?4*b*b*b:(b-1)*(2*b-2)*(2*b-2)+1,Os=b=>b*b*b*b,$s=b=>1- --b*b*b*b,Fs=b=>b<.5?8*b*b*b*b:1-8*--b*b*b*b,Ws=b=>b*b*b*b*b,Bs=b=>1+--b*b*b*b*b,Ds=b=>b<.5?16*b*b*b*b*b:1+16*--b*b*b*b*b,Ys=b=>1-Math.cos(b*Math.PI/2),Xs=b=>Math.sin(b*Math.PI/2),Ns=b=>-(Math.cos(Math.PI*b)-1)/2,Hs=b=>b===0?0:Math.pow(2,10*(b-1)),xs=b=>b===1?1:1-Math.pow(2,-10*b),Vs=b=>b===0?0:b===1?1:b<.5?Math.pow(2,20*b-10)/2:(2-Math.pow(2,-20*b+10))/2,Gs=b=>1-Math.sqrt(1-b*b),zs=b=>Math.sqrt(1- --b*b),Us=b=>b<.5?(1-Math.sqrt(1-4*b*b))/2:(Math.sqrt(1-(-2*b+2)*(-2*b+2))+1)/2,Je=1.70158,Ke=Je*1.525,hs=Je+1,qs=b=>hs*b*b*b-Je*b*b,Js=b=>1+hs*Math.pow(b-1,3)+Je*Math.pow(b-1,2),Ks=b=>b<.5?Math.pow(2*b,2)*((Ke+1)*2*b-Ke)/2:(Math.pow(2*b-2,2)*((Ke+1)*(b*2-2)+Ke)+2)/2,fs=2*Math.PI/3,ds=2*Math.PI/4.5,Qs=b=>b===0?0:b===1?1:-Math.pow(2,10*b-10)*Math.sin((b*10-10.75)*fs),Zs=b=>b===0?0:b===1?1:Math.pow(2,-10*b)*Math.sin((b*10-.75)*fs)+1,js=b=>b===0?0:b===1?1:b<.5?-(Math.pow(2,20*b-10)*Math.sin((20*b-11.125)*ds))/2:Math.pow(2,-20*b+10)*Math.sin((20*b-11.125)*ds)/2+1,Qe=b=>b<1/2.75?7.5625*b*b:b<2/2.75?7.5625*(b-=1.5/2.75)*b+.75:b<2.5/2.75?7.5625*(b-=2.25/2.75)*b+.9375:7.5625*(b-=2.625/2.75)*b+.984375,ti=b=>1-Qe(1-b),ei=Qe,si=b=>b<.5?(1-Qe(1-2*b))/2:(1+Qe(2*b-1))/2,ts=new Map,Ge=(b,t,s,o)=>{const e=`${b},${t},${s},${o}`;if(ts.has(e))return ts.get(e);const n=d=>(1-3*s+3*b)*d*d*d+(3*s-6*b)*d*d+3*b*d,i=d=>(1-3*o+3*t)*d*d*d+(3*o-6*t)*d*d+3*t*d,a=d=>3*(1-3*s+3*b)*d*d+2*(3*s-6*b)*d+3*b,r=d=>{let u=d;for(let g=0;g<8;g++){const p=n(u)-d;if(Math.abs(p)<1e-6)return u;const f=a(u);if(Math.abs(f)<1e-6)break;u=u-p/f}return u},l=d=>d===0?0:d===1?1:i(r(d));return ts.set(e,l),l},ps=b=>{const t=b.match(/cubic-bezier\s*\(\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*\)/);if(!t)return null;const[,s,o,e,n]=t.map(Number);return Ge(s,o,e,n)},us={ease:Ge(.25,.1,.25,1),"ease-in":Ge(.42,0,1,1),"ease-out":Ge(0,0,.58,1),"ease-in-out":Ge(.42,0,.58,1)},Ze={Linear:as,EaseInQuad:rs,EaseOutQuad:ls,EaseInOutQuad:cs,EaseInCubic:Es,EaseOutCubic:Ls,EaseInOutCubic:Rs,EaseInQuart:Os,EaseOutQuart:$s,EaseInOutQuart:Fs,EaseInQuint:Ws,EaseOutQuint:Bs,EaseInOutQuint:Ds,EaseInSine:Ys,EaseOutSine:Xs,EaseInOutSine:Ns,EaseInExpo:Hs,EaseOutExpo:xs,EaseInOutExpo:Vs,EaseInCirc:Gs,EaseOutCirc:zs,EaseInOutCirc:Us,EaseInBack:qs,EaseOutBack:Js,EaseInOutBack:Ks,EaseInElastic:Qs,EaseOutElastic:Zs,EaseInOutElastic:js,EaseInBounce:ti,EaseOutBounce:ei,EaseInOutBounce:si,EaseIn:rs,EaseOut:ls,EaseInOut:cs,StepStart:_s,StepEnd:As},ii=b=>{const t=b.trim(),s=t.toLowerCase();if(Ze[t])return Ze[t];const o=Object.keys(Ze).find(n=>n.toLowerCase()===s);if(o)return Ze[o];const e=Object.keys(gs).find(n=>n.toLowerCase()===s);if(e){const n=ps(gs[e].value);if(n)return n}if(us[s])return us[s];if(s.startsWith("cubic-bezier")){const n=ps(t);if(n)return n}return as},gs={Snappy:{label:"Snappy",description:"High energy, quick arrival.",value:"cubic-bezier(0.2, 1, 0.2, 1)"},Bouncy:{label:"Bouncy",description:"Springy with an overshoot.",value:"cubic-bezier(0.2, 0.9, 0.4, 1.3)"},Gentle:{label:"Gentle",description:"Smooth and organic flow.",value:"cubic-bezier(0.4, 0, 0.6, 1)"},Stiff:{label:"Stiff",description:"Solid and reliable movement.",value:"cubic-bezier(0.3, 1, 0.7, 1)"},Floating:{label:"Floating",description:"Weightless and airy transition.",value:"cubic-bezier(0.5, 0, 0.5, 1)"},Sudden:{label:"Sudden",description:"Instant, direct movement.",value:"cubic-bezier(1, 0, 1, 1)"},Elastic:{label:"Elastic",description:"Extreme overshoot and spring.",value:"cubic-bezier(0.5, 1.5, 0.5, 1.5)"},Sharp:{label:"Sharp",description:"Fast start, very hard stop.",value:"cubic-bezier(0.1, 0.9, 0.1, 1)"},Fluid:{label:"Fluid",description:"Natural high-end flow.",value:"cubic-bezier(0.4, 0, 0.2, 1)"},Heavy:{label:"Heavy",description:"Slow start, massive impact.",value:"cubic-bezier(0.6, 0, 1, 1)"}},ni=(b,t,s,o,e)=>{if(!b||!t||!s)return b;const n=o.scale_x??1,i=o.scale_y??1,a=(r,l,d)=>{let u=0,g=0;const p=o.rotation*Math.PI/180,f=Math.cos(p),h=Math.sin(p),S=r*n*f-l*i*h+o.x,y=r*n*h+l*i*f+o.y;d.forEach(I=>{const A=e(I.boneId);if(!A)return;const _={x:A.x,y:A.y,rotation:A.rotation,scaleX:A.scale_x??1,scaleY:A.scale_y??1},T=s[I.boneId]||[1,0,0,1,0,0],L=S*T[0]+y*T[2]+T[4],F=S*T[1]+y*T[3]+T[5],D=_.rotation*Math.PI/180,R=Math.cos(D),X=Math.sin(D),P=L*_.scaleX*R-F*_.scaleY*X+_.x,k=L*_.scaleX*X+F*_.scaleY*R+_.y;u+=P*I.amount,g+=k*I.amount});const c=[...d].sort((I,A)=>A.amount-I.amount);if(c.length>=2&&c[0].amount>0&&c[1].amount>0){const I=e(c[0].boneId),A=e(c[1].boneId);if(I&&A&&I.length!==void 0&&A.length!==void 0){const _=I.length*(I.scale_y??1),T=I.rotation*Math.PI/180,L=I.x-_*Math.sin(T),F=I.y+_*Math.cos(T),D=A.length*(A.scale_y??1),R=A.rotation*Math.PI/180,X=A.x-D*Math.sin(R),P=A.y+D*Math.cos(R);let k=null,O=null,E=!1;const N=1;if(Math.hypot(I.x-A.x,I.y-A.y)<N||Math.hypot(I.x-X,I.y-P)<N?(k=I.x,O=I.y):(Math.hypot(L-A.x,F-A.y)<N||Math.hypot(L-X,F-P)<N)&&(k=L,O=F,E=!0),k!==null&&O!==null){const W=s[c[0].boneId]||[1,0,0,1,0,0],B=W[0]*W[3]-W[1]*W[2];let G=0,z=0;if(B!==0){const V=(W[2]*W[5]-W[3]*W[4])/B,U=(W[1]*W[4]-W[0]*W[5])/B,q=Math.atan2(-W[1],W[3]);if(!E)G=V,z=U;else{const x=-W[2]/B,dt=W[0]/B,_t=Math.hypot(x,dt),vt=I.length*_t;G=V-vt*Math.sin(q),z=U+vt*Math.cos(q)}const Y=Math.hypot(S-G,y-z),H=Math.hypot(u-k,g-O);if(H>0&&Y>0){const x=Math.max(H,.01),dt=Math.min(Y/x,3),_t=k+(u-k)*dt,vt=O+(g-O)*dt,Yt=c[0].amount,Mt=c[1].amount,Wt=Math.min(Yt,Mt)*2,Ot=1-Math.pow(1-Wt,4);u=u*(1-Ot)+_t*Ot,g=g*(1-Ot)+vt*Ot}}}}}const v=o.rotation*Math.PI/180,m=Math.cos(v),C=Math.sin(v),w=u-o.x,M=g-o.y;return{x:(w*m+M*C)/n,y:(-w*C+M*m)/i}};return b.map((r,l)=>{const d=t[l];if(!d||d.length===0)return{...r};const u={...r,...a(r.x,r.y,d)};if(r.in_x!==void 0&&r.in_y!==void 0){const g=a(r.in_x,r.in_y,d);u.in_x=g.x,u.in_y=g.y}if(r.out_x!==void 0&&r.out_y!==void 0){const g=a(r.out_x,r.out_y,d);u.out_x=g.x,u.out_y=g.y}return u})};function oi(b,t,s,o,e){const n=b*s*.01,i=t*s*.01,a=Math.sin(e*12.9898)*43758.5453%(Math.PI*2),r=Math.cos(e*78.233)*43758.5453%(Math.PI*2);return(Math.sin(n+a)*Math.cos(i+r)+.5*Math.sin(n*2.1-r)*Math.cos(i*2.3+a)+.25*Math.sin(n*4.5+a)*Math.cos(i*4.2-r))/1.75*o}function ai(b,t,s,o,e,n,i=0,a=0){const r=[];if(!b)return[];const l=b.type;if(l==="Rectangle"||l==="Image"||l==="Frame"){const f=Math.max(20,Math.floor((t+s)/10)),h=Math.max(2,Math.floor(f*(t/(t+s)))),S=Math.max(2,Math.floor(f*(s/(t+s))));for(let y=0;y<h;y++)r.push({x:-t/2+t/h*y,y:-s/2,nx:0,ny:-1});for(let y=0;y<S;y++)r.push({x:t/2,y:-s/2+s/S*y,nx:1,ny:0});for(let y=0;y<h;y++)r.push({x:t/2-t/h*y,y:s/2,nx:0,ny:1});for(let y=0;y<S;y++)r.push({x:-t/2,y:s/2-s/S*y,nx:-1,ny:0})}else if(l==="Ellipse"){const f=Math.max(60,Math.floor(Math.PI*Math.max(t,s)/5));for(let h=0;h<f;h++){const S=h/f*Math.PI*2,y=Math.cos(S),c=Math.sin(S);r.push({x:y*t/2,y:c*s/2,nx:y,ny:c})}}else if(l==="Triangle"){const f={x:0,y:-s/2},h={x:t/2,y:s/2},S={x:-t/2,y:s/2},y=20;let c=h.x-f.x,v=h.y-f.y,m=Math.hypot(c,v),C=-v/m,w=c/m;for(let M=0;M<y;M++)r.push({x:f.x+c*(M/y),y:f.y+v*(M/y),nx:C,ny:w});c=S.x-h.x,v=S.y-h.y,m=Math.hypot(c,v),C=-v/m,w=c/m;for(let M=0;M<y;M++)r.push({x:h.x+c*(M/y),y:h.y+v*(M/y),nx:C,ny:w});c=f.x-S.x,v=f.y-S.y,m=Math.hypot(c,v),C=-v/m,w=c/m;for(let M=0;M<y;M++)r.push({x:S.x+c*(M/y),y:S.y+v*(M/y),nx:C,ny:w})}else for(let h=0;h<80;h++){const S=h/80*Math.PI*2,y=Math.cos(S),c=Math.sin(S);r.push({x:y*t/2,y:c*s/2,nx:y,ny:c})}const d=i*Math.PI/180,u=Math.cos(d),g=Math.sin(d);return r.map(f=>{const h=oi(f.x,f.y,e,o,n),S=f.nx*(1-a)+u*a,y=f.ny*(1-a)+g*a;let c=Math.hypot(S,y);return c===0&&(c=1),{x:f.x+S/c*h,y:f.y+y/c*h}})}const ri={default:{label:"Default",colors:["#6366f1","#f59e0b"],cardBackground:"rgba(255,255,255,0.04)",cardBorderColor:"rgba(255,255,255,0.08)",gridColor:"rgba(255,255,255,0.06)",axisLabelColor:"rgba(255,255,255,0.5)",legendColor:"rgba(255,255,255,0.7)",barGradient:!0},neon:{label:"Neon",colors:["#00f5ff","#ff00e5"],cardBackground:"rgba(0,0,0,0.5)",cardBorderColor:"rgba(0,245,255,0.2)",gridColor:"rgba(0,245,255,0.08)",axisLabelColor:"rgba(0,245,255,0.6)",legendColor:"rgba(0,245,255,0.8)",barGradient:!0},pastel:{label:"Pastel",colors:["#a5b4fc","#fcd34d"],cardBackground:"rgba(255,255,255,0.06)",cardBorderColor:"rgba(255,255,255,0.12)",gridColor:"rgba(255,255,255,0.08)",axisLabelColor:"rgba(255,255,255,0.45)",legendColor:"rgba(255,255,255,0.65)",barGradient:!1},warm:{label:"Warm",colors:["#f97316","#ef4444"],cardBackground:"rgba(30,10,0,0.4)",cardBorderColor:"rgba(249,115,22,0.2)",gridColor:"rgba(249,115,22,0.08)",axisLabelColor:"rgba(253,186,116,0.7)",legendColor:"rgba(253,186,116,0.85)",barGradient:!0},ocean:{label:"Ocean",colors:["#06b6d4","#0ea5e9"],cardBackground:"rgba(0,20,40,0.5)",cardBorderColor:"rgba(6,182,212,0.2)",gridColor:"rgba(6,182,212,0.06)",axisLabelColor:"rgba(125,211,252,0.6)",legendColor:"rgba(125,211,252,0.8)",barGradient:!0},mono:{label:"Mono",colors:["rgba(255,255,255,0.9)","rgba(255,255,255,0.4)"],cardBackground:"rgba(255,255,255,0.03)",cardBorderColor:"rgba(255,255,255,0.1)",gridColor:"rgba(255,255,255,0.05)",axisLabelColor:"rgba(255,255,255,0.4)",legendColor:"rgba(255,255,255,0.6)",barGradient:!1}},ms={vibrant:["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399","#a855f7","#f87171"],pastel:["#a5b4fc","#67e8f9","#fcd34d","#f9a8d4","#6ee7b7","#c4b5fd","#fca5a5"],neon:["#00f5ff","#ff00e5","#00ff9f","#ff6b00","#b400ff","#ffe600","#00c3ff"],warm:["#f97316","#ef4444","#f59e0b","#dc2626","#fb923c","#e11d48","#ea580c"],ocean:["#06b6d4","#0ea5e9","#38bdf8","#7dd3fc","#0284c7","#0369a1","#bae6fd"]},ze={Rectangle:"M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5z",Hexagon:"M12 2l8.5 5v10L12 22l-8.5-5V7L12 2z",Octagon:"M7.86 2h8.28L22 7.86v8.28L16.14 22H7.86L2 16.14V7.86L7.86 2z",Heart:"M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z",Cloud:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96z",Shield:"M12 2L4 5v6.09c0 5.05 3.41 9.76 8 10.91 4.59-1.15 8-5.86 8-10.91V5l-8-3z",Badge:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76z",Leaf:"M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z",Tag:"M12 2H2v10l9.29 9.29c.94.94 2.48.94 3.42 0l6.58-6.58c.94-.94.94-2.48 0-3.42L12 2Z",Sparkle:"M12 2v4m0 12v4M4.93 4.93l2.83 2.83m8.48 8.48l2.83 2.83M2 12h4m12 0h4M4.93 19.07l2.83-2.83m8.48-8.48l2.83-2.83",Diamond:"M12 2L2 12l10 10 10-10L12 2z",Star:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"},We=b=>{let t=1/0,s=1/0,o=-1/0,e=-1/0,n=0,i=0;const a=/([a-df-z])([^a-df-z]*)/gi;let r;for(;(r=a.exec(b))!==null;){const p=r[1],f=p===p.toLowerCase(),h=p.toUpperCase(),S=[],y=/[-+]?(?:\d*\.\d+|\d+)(?:[eE][-+]?\d+)?/g;let c;for(;(c=y.exec(r[2]))!==null;)S.push(parseFloat(c[0]));const v=(m,C)=>{!isNaN(m)&&!isNaN(C)&&(m<t&&(t=m),m>o&&(o=m),C<s&&(s=C),C>e&&(e=C),n=m,i=C)};if(h==="M"||h==="L"||h==="T")for(let m=0;m<S.length-1;m+=2){const C=f?n+S[m]:S[m],w=f?i+S[m+1]:S[m+1];v(C,w)}else if(h==="H")for(let m=0;m<S.length;m++){const C=f?n+S[m]:S[m];v(C,i)}else if(h==="V")for(let m=0;m<S.length;m++){const C=f?i+S[m]:S[m];v(n,C)}else if(h==="C")for(let m=0;m<S.length-5;m+=6){const C=f?n+S[m]:S[m],w=f?i+S[m+1]:S[m+1],M=f?n+S[m+2]:S[m+2],I=f?i+S[m+3]:S[m+3],A=f?n+S[m+4]:S[m+4],_=f?i+S[m+5]:S[m+5];v(C,w),v(M,I),v(A,_)}else if(h==="S"||h==="Q")for(let m=0;m<S.length-3;m+=4){const C=f?n+S[m]:S[m],w=f?i+S[m+1]:S[m+1],M=f?n+S[m+2]:S[m+2],I=f?i+S[m+3]:S[m+3];v(C,w),v(M,I)}else if(h==="A")for(let m=0;m<S.length-6;m+=7){const C=f?n+S[m+5]:S[m+5],w=f?i+S[m+6]:S[m+6];v(C,w)}}(!isFinite(t)||!isFinite(o)||!isFinite(s)||!isFinite(e))&&(t=0,o=24,s=0,e=24);const l=Math.max(.001,o-t),d=Math.max(.001,e-s),u=(t+o)/2,g=(s+e)/2;return{minX:t,minY:s,maxX:o,maxY:e,width:l,height:d,cx:u,cy:g}};class ys{constructor(){pt(this,"artboard",null);pt(this,"objectStates",new Map);pt(this,"physicsEngine",null);pt(this,"activeStateMachine",null);pt(this,"inputs",new Map);pt(this,"inputNameMap",new Map);pt(this,"layerStates",new Map);pt(this,"pretextCache",new Map);pt(this,"pointerHistory",[]);pt(this,"MAX_HISTORY",200);pt(this,"imageCache",new Map);pt(this,"lastValidSvgImgMap",new Map);pt(this,"maskBuffer",null);pt(this,"maskCtx",null);pt(this,"lumaBuffer",null);pt(this,"lumaCtx",null);pt(this,"_noiseTileCanvas",null);pt(this,"layout",{fit:"Contain",alignment:"Center"});pt(this,"onTrigger");pt(this,"onInputUpdate");pt(this,"onComponentChange");pt(this,"onToggle");pt(this,"onInputChange");pt(this,"onInputFocus");pt(this,"onInputBlur");pt(this,"onLog");pt(this,"onButtonClick");pt(this,"onGraphPointClick");pt(this,"justFiredTriggers",new Set);pt(this,"rootTransform",null);pt(this,"canvasWidth",0);pt(this,"canvasHeight",0);pt(this,"lastHoveredObjectId",null);pt(this,"_lastPointerPos",null);pt(this,"_prevPointerPos",null);pt(this,"_mouseDelta",{dx:0,dy:0});pt(this,"focusedId",null);pt(this,"draggingSliderId",null);pt(this,"draggingJoystickId",null);pt(this,"activeDropdownId",null);pt(this,"activeObjectId",null);pt(this,"draggingListViewId",null);pt(this,"draggingListViewIsScrollbar",!1);pt(this,"scrollOffset",{x:0,y:0});pt(this,"_totalScroll",{x:0,y:0});pt(this,"draggingBehaviors",new Set);pt(this,"dragStartPointer",null);pt(this,"dragStartPositions",new Map);pt(this,"isMouseDown",!1);pt(this,"activeKeys",new Set);pt(this,"graphHoverStates",new Map);pt(this,"barChartRenderedBars",new Map);pt(this,"pieChartRenderedSlices",new Map);pt(this,"_layoutAnimCache",new Map);pt(this,"_springChainState",new Map);pt(this,"_emitterPools",new Map);pt(this,"objectVelocities",new Map);pt(this,"currentTime",0);pt(this,"frameCount",0);pt(this,"fontLeadingFactors",{Inter:.35,Roboto:.45,Montserrat:.4,Outfit:.35,"Open Sans":.4,Poppins:.45,"Playfair Display":.35,Lora:.4,Lato:.35,"Bebas Neue":.45,Oswald:.4});pt(this,"onLogicUpdate");pt(this,"logicNodeValues",new Map);pt(this,"logicNodeState",new Map);pt(this,"pointerDownTimes",new Map);pt(this,"activeHoverIds",new Set);pt(this,"onNavigation");pt(this,"periodicTriggerTimes",new Map);pt(this,"wasInView",new Set);pt(this,"scrollProgressLastValue",new Map);pt(this,"debug_objectsRendered",0);pt(this,"debug_objectsTotal",0);pt(this,"lastRenderTime",0);pt(this,"debugMode",!1);pt(this,"activeTriggers",new Map);console.info("%c[ExodeUI Engine] Pixel-Perfect Parity Active (v6.3.10) - SVG Fill & Gradient Parity Active","color: #3b82f6; font-weight: bold; padding: 2px 4px; border-radius: 4px; background: rgba(59, 130, 246, 0.1)")}getInputValue(t){if(this.inputs.has(t))return this.inputs.get(t);const s=this.inputNameMap.get(t);if(s&&s.length>0)return this.inputs.get(s[0])}setTriggerCallback(t){this.onTrigger=t}setInputUpdateCallback(t){this.onInputUpdate=t}setComponentChangeCallback(t){this.onComponentChange=t}setToggleCallback(t){this.onToggle=t}setLogicUpdateCallback(t){this.onLogicUpdate=t}setInputChangeCallback(t){this.onInputChange=t}setButtonClickCallback(t){this.onButtonClick=t}setGraphPointClickCallback(t){this.onGraphPointClick=t}setNavigationCallback(t){this.onNavigation=t}ensurePathPoints(t){if(!t)return;const s=(t.type||"").toLowerCase();if(!(s==="path"||s==="custom"||s==="customshape"||s==="shape"||s==="subtract"||s==="union"||s==="intersect"||s==="exclude"||s==="booleanoperation"))return;const e=t.data||t.pathData||t.d||t.path||t.svgPath;if(t.points&&t.points.length>0){if(t.is_closed===void 0&&t.isClosed===void 0&&e){const{isClosed:a}=this.svgPathToPoints(e);t.is_closed=a}return}if(!e)return;const{points:n,isClosed:i}=this.svgPathToPoints(e);t.points=n,t.is_closed===void 0&&(t.is_closed=i)}svgPathToPoints(t){const s=/([MLHVCSQTAZmlhvcsqtaz])([^MLHVCSQTAZmlhvcsqtaz]*)/g,o=/[-+]?(?:\d*\.\d+|\d+)(?:[eE][-+]?\d+)?/g,e=[];let n=!1,i=0,a=0,r=0,l=0,d=0,u=0,g="",p;for(;(p=s.exec(t))!==null;){const f=p[1],h=(p[2].match(o)||[]).map(parseFloat),S=f===f.toLowerCase(),y=f.toUpperCase();let c=0;const v=C=>{let w=h[c++];return S&&(w+=C?i:a),w},m=()=>({x:v(!0),y:v(!1)});switch(y){case"M":{const C=m();for(d=i=C.x,u=a=C.y,e.push({x:i,y:a,in_x:i,in_y:a,out_x:i,out_y:a,moveTo:!0});c<h.length;){const w=m();i=w.x,a=w.y,e.push({x:i,y:a,in_x:i,in_y:a,out_x:i,out_y:a})}break}case"L":for(;c<h.length;){const C=m();i=C.x,a=C.y,e.push({x:i,y:a,in_x:i,in_y:a,out_x:i,out_y:a})}break;case"H":for(;c<h.length;)i=v(!0),e.push({x:i,y:a,in_x:i,in_y:a,out_x:i,out_y:a});break;case"V":for(;c<h.length;)a=v(!1),e.push({x:i,y:a,in_x:i,in_y:a,out_x:i,out_y:a});break;case"C":for(;c<h.length;){const C=m(),w=m(),M=m();if(e.length>0){const I=e[e.length-1];I.out_x=C.x,I.out_y=C.y}i=M.x,a=M.y,e.push({x:i,y:a,in_x:w.x,in_y:w.y,out_x:i,out_y:a}),r=w.x,l=w.y}break;case"S":for(;c<h.length;){let C=i,w=a;(g==="C"||g==="S")&&(C=2*i-r,w=2*a-l);const M=m(),I=m();if(e.length>0){const A=e[e.length-1];A.out_x=C,A.out_y=w}i=I.x,a=I.y,e.push({x:i,y:a,in_x:M.x,in_y:M.y,out_x:i,out_y:a}),r=M.x,l=M.y}break;case"Q":for(;c<h.length;){const C=m(),w=m();if(e.length>0){const M=e[e.length-1];M.out_x=M.x+2/3*(C.x-M.x),M.out_y=M.y+2/3*(C.y-M.y)}i=w.x,a=w.y,e.push({x:i,y:a,in_x:i+2/3*(C.x-i),in_y:a+2/3*(C.y-a),out_x:i,out_y:a}),r=C.x,l=C.y}break;case"T":for(;c<h.length;){let C=i,w=a;(g==="Q"||g==="T")&&(C=2*i-r,w=2*a-l);const M=m();if(e.length>0){const I=e[e.length-1];I.out_x=I.x+2/3*(C-I.x),I.out_y=I.y+2/3*(w-I.y)}i=M.x,a=M.y,e.push({x:i,y:a,in_x:i+2/3*(C-i),in_y:a+2/3*(w-a),out_x:i,out_y:a}),r=C,l=w}break;case"A":for(;c+6<h.length;){const C=Math.abs(h[c++]),w=Math.abs(h[c++]),M=h[c++],I=h[c++],A=h[c++];let _=h[c++],T=h[c++];if(S&&(_+=i,T+=a),C===0||w===0||Math.abs(_-i)<.001&&Math.abs(T-a)<.001){i=_,a=T,e.push({x:i,y:a,in_x:i,in_y:a,out_x:i,out_y:a});break}const L=M*Math.PI/180,F=Math.cos(L),D=Math.sin(L),R=(i-_)/2,X=(a-T)/2,P=F*R+D*X,k=-D*R+F*X;let O=C,E=w;const N=P*P,W=k*k;let B=O*O,G=E*E;const z=N/B+W/G;if(z>1){const Ct=Math.sqrt(z);O*=Ct,E*=Ct,B=O*O,G=E*E}const V=I!==A?1:-1,U=Math.max(0,B*G-B*W-G*N),q=B*W+G*N,Y=q>0?Math.sqrt(U/q):0,H=V*Y*(O*k)/E,x=V*Y*-(E*P)/O,dt=F*H-D*x+(i+_)/2,_t=D*H+F*x+(a+T)/2,vt=(P-H)/O,Yt=(k-x)/E,Mt=(-P-H)/O,Wt=(-k-x)/E,Ot=(Ct,Tt)=>{const Et=Ct[0]*Tt[0]+Ct[1]*Tt[1],tt=Math.sqrt((Ct[0]**2+Ct[1]**2)*(Tt[0]**2+Tt[1]**2)),at=Math.max(-1,Math.min(1,Et/tt));return(Ct[0]*Tt[1]-Ct[1]*Tt[0]<0?-1:1)*Math.acos(at)};let yt=Ot([1,0],[vt,Yt]),Ft=Ot([vt,Yt],[Mt,Wt]);!A&&Ft>0&&(Ft-=2*Math.PI),A&&Ft<0&&(Ft+=2*Math.PI);const K=Math.max(1,Math.ceil(Math.abs(Ft)/(Math.PI/2))),ut=Ft/K,Lt=Ct=>({x:F*O*Math.cos(Ct)-D*E*Math.sin(Ct)+dt,y:D*O*Math.cos(Ct)+F*E*Math.sin(Ct)+_t,tx:-F*O*Math.sin(Ct)-D*E*Math.cos(Ct),ty:-D*O*Math.sin(Ct)+F*E*Math.cos(Ct)});for(let Ct=0;Ct<K;Ct++){const Tt=yt+Ct*ut,Et=yt+(Ct+1)*ut,tt=Math.sin(ut)*(Math.sqrt(4+3*Math.tan(ut/2)**2)-1)/3,at=Lt(Tt),ct=Lt(Et),Pt=at.x+tt*at.tx,kt=at.y+tt*at.ty,It=ct.x-tt*ct.tx,xt=ct.y-tt*ct.ty;if(e.length>0){const ie=e[e.length-1];ie.out_x=Pt,ie.out_y=kt}i=ct.x,a=ct.y,e.push({x:i,y:a,in_x:It,in_y:xt,out_x:i,out_y:a})}r=i,l=a}break;case"Z":if(n=!0,e.length>0){const C=e[e.length-1];C.closePath=!0;const w=[...e].reverse().find(M=>M.moveTo)||e[0];w&&Math.hypot(w.x-C.x,w.y-C.y)<.1&&(w.in_x=C.in_x,w.in_y=C.in_y,e.pop(),e.length>0&&(e[e.length-1].closePath=!0))}i=d,a=u;break;default:if(h.length>=2){const C=m();i=C.x,a=C.y,e.push({x:i,y:a,in_x:i,in_y:a,out_x:i,out_y:a})}break}y!=="S"&&y!=="T"&&(g=y)}return{points:e,isClosed:n}}setOnLogCallback(t){this.onLog=t}debugLog(t){this.onLog&&this.onLog(t)}setInputFocusCallback(t){this.onInputFocus=t}setInputBlurCallback(t){this.onInputBlur=t}updateConstraint(t,s,o){var n;const e=(n=this.artboard)==null?void 0:n.objects.find(i=>i.id===t);e&&e.constraints&&e.constraints[s]&&(e.constraints[s]={...e.constraints[s],...o},o.useSpring===!1&&this.objectVelocities.delete(t))}log(...t){this.debugMode&&console.log(...t)}warn(...t){this.debugMode&&console.warn(...t)}setInternalInput(t,s){this.inputs.set(t,s),this.onInputUpdate&&this.onInputUpdate(t,s)}setLayout(t,s){this.layout={fit:t,alignment:s}}getActiveStateIds(t="Base Layer"){const s=this.layerStates.get(t);return s?s.currentStateIds:[]}getObjectState(t){return this.objectStates.get(t)}updateObjectOptions(t,s){const o=this.objectStates.get(t);o&&(o.options={...o.options,...s})}updateGraphData(t,s,o){var n,i,a;if(!this.artboard)return;const e=this.artboard.objects.find(r=>r.id===t||r.name===t);if(e){const r=((n=e.geometry)==null?void 0:n.type)==="LineGraph",l=e.type==="BarChart"||e.type==="Component"&&e.variant==="barchart",d=e.type==="PieChart"||e.type==="Component"&&e.variant==="piechart";if(r){const u=e.geometry,g=Array.isArray(s[0])?s[0]:s;!u.datasets||u.datasets.length===0?u.datasets=[{id:"default",label:"Runtime Data",data:g,lineColor:"#3b82f6",lineWidth:2,showArea:!1}]:u.datasets[0].data=g;const p=this.objectStates.get(e.id);p&&((i=p.geometry)==null?void 0:i.type)==="LineGraph"&&(!p.geometry.datasets||p.geometry.datasets.length===0?p.geometry.datasets=JSON.parse(JSON.stringify(u.datasets)):p.geometry.datasets[0].data=[...g]),(a=u.datasets[0])!=null&&a.inputId&&this.updateInput(u.datasets[0].inputId,g);return}else if(l){this.updateBarChartData(e.id,Array.isArray(s[0])?s:[s],o);return}else if(d){this.updatePieChartData(e.id,Array.isArray(s[0])?s[0]:s);return}}this.updateInput(t,s)}updateBarChartData(t,s,o){if(!this.artboard)return;const e=this.artboard.objects.find(l=>l.id===t||l.name===t);if(!e){this.updateInput(t,s);return}const n=this.objectStates.get(e.id),i=(n==null?void 0:n.options)||e.options||{},a=s.map((l,d)=>{var g;const u=((g=i.datasets)==null?void 0:g[d])||{};return Array.isArray(l)?{id:u.id||`ds-${d}`,label:u.label||`Series ${d+1}`,color:u.color||"#6366f1",data:l}:{id:l.id||u.id||`ds-${d}`,label:l.label||u.label||`Series ${d+1}`,color:l.color||u.color||"#6366f1",data:l.data||[]}}),r={...i,datasets:a};o&&Array.isArray(o)&&(r.categories=o),e.options=r,n&&(n.options=r),i.datasetInputIds&&Array.isArray(i.datasetInputIds)&&i.datasetInputIds.forEach((l,d)=>{a[d]&&this.updateInput(l,a[d].data)}),o&&i.dataInputId&&this.updateInput(i.dataInputId,o)}updatePieChartData(t,s){if(!this.artboard)return;const o=this.artboard.objects.find(l=>l.id===t||l.name===t);if(!o){this.updateInput(t,s);return}const e=this.objectStates.get(o.id),n=(e==null?void 0:e.options)||o.options||{},i=n.slices||[],a=s.map((l,d)=>{const u=i[d]||{};return typeof l=="number"?{id:u.id||`slice-${d}`,label:u.label||`Item ${d+1}`,color:u.color||"",value:l}:{id:l.id||u.id||`slice-${d}`,label:l.label||u.label||`Item ${d+1}`,color:l.color||u.color||"",value:typeof l.value=="number"?l.value:parseFloat(l.value)||0}}),r={...n,slices:a};o.options=r,e&&(e.options=r),n.dataInputId&&this.updateInput(n.dataInputId,a.map(l=>l.value))}setDropdownOptions(t,s){if(!this.artboard)return;const o=this.artboard.objects.find(a=>a.id===t||a.name===t);if(!o){this.updateInput(t,s);return}const e=this.objectStates.get(o.id),n=(e==null?void 0:e.options)||o.options||{},i={...n,optionsList:s};o.options=i,e&&(e.options=i),n.dataInputId&&this.updateInput(n.dataInputId,s)}load(t){var i,a;if(!t)return;let s=this.decompressStrings(t);const o=[],e=new Set,n=r=>{r&&r.forEach(l=>{if(e.has(l.id))return;const d={...l},u=d.childrenObjects||[];e.add(d.id),o.push(d),n(u)})};if(n(s.objects||[]),o.length>(s.objects||[]).length&&this.log(`[Engine] Flattened artboard from ${(s.objects||[]).length} to ${o.length} objects.`),s.objects=o,this.artboard=s,this.currentTime=0,this.objectStates.clear(),this.log(`[ExodeUIEngine] Loading artboard: "${(i=this.artboard)==null?void 0:i.name}" with ${(a=this.artboard)==null?void 0:a.objects.length} objects`),this.artboard&&this.artboard.objects){const r=new Map;this.artboard.objects.forEach(l=>{r.set(l.id,l),l.children||(l.children=[])}),this.artboard.objects.forEach(l=>{if(l.parentId){const d=r.get(l.parentId);d&&(d.children||(d.children=[]),d.children.includes(l.id)||d.children.push(l.id))}})}this.loadFonts(),this.preloadImages(this.artboard),this.reset(),this.advance(0)}preloadImages(t){if(!t||!t.objects)return;const s=o=>{if(!o||this.imageCache.has(o))return;const e=new Image;e.onload=()=>{this.log(`[ExodeUI Preload] loaded ${e.naturalWidth}x${e.naturalHeight}`)},e.onerror=n=>{console.error("[ExodeUI Preload] failed:",n,`Src: ${o.substring(0,80)}...`)},e.src=o,this.imageCache.set(o,e)};t.objects.forEach(o=>{var e,n,i;(e=o.geometry)!=null&&e.src&&s(o.geometry.src),(i=(n=o.style)==null?void 0:n.fill)!=null&&i.src&&s(o.style.fill.src)})}decompressStrings(t){if(t&&typeof t=="object"&&!Array.isArray(t)){if(t._compressed&&t._data)try{const o=Cs.decompressFromBase64(t._data);if(o)return o}catch(o){return console.error("[ExodeUI] Failed to decompress string:",o),t._data}const s={};for(const[o,e]of Object.entries(t))s[o]=this.decompressStrings(e);return s}return Array.isArray(t)?t.map(s=>this.decompressStrings(s)):t}reset(){if(!this.artboard)return;if(this.objectStates.clear(),this.objectVelocities.clear(),this.currentTime=0,this.inputs.clear(),this.inputNameMap.clear(),this.layerStates.clear(),this.logicNodeValues.clear(),this.justFiredTriggers.clear(),this.inputs.set("mouseX",0),this.inputs.set("mouseY",0),this.inputs.set("scrollX",0),this.inputs.set("scrollY",0),this.inputs.set("isMouseDown",!1),this.physicsEngine&&(this.physicsEngine.destroy(),this.physicsEngine=null),this._layoutAnimCache.clear(),this._springChainState.clear(),this._emitterPools.clear(),this.artboard.objects.forEach(s=>{var i,a,r,l,d,u,g;const o=s.width??((i=s.geometry)==null?void 0:i.width)??0,e=s.height??((a=s.geometry)==null?void 0:a.height)??0,n=s.cornerRadius??s.corner_radius??((r=s.geometry)==null?void 0:r.corner_radius)??((l=s.geometry)==null?void 0:l.cornerRadius)??0;this.objectStates.set(s.id,{...s.transform||{},x:((d=s.transform)==null?void 0:d.x)??s.x??0,y:((u=s.transform)==null?void 0:u.y)??s.y??0,width:o,height:e,cornerRadius:n,corner_radius:n,clipContent:s.clipContent??!1,autoLayout:s.autoLayout?JSON.parse(JSON.stringify(s.autoLayout)):void 0,layoutProps:s.layoutProps?JSON.parse(JSON.stringify(s.layoutProps)):void 0,opacity:((g=s.transform)==null?void 0:g.opacity)!==void 0?s.transform.opacity:s.opacity!==void 0?s.opacity:100,visible:s.visible!==void 0?s.visible:s.isVisible!==void 0?s.isVisible:!0,blendMode:s.blendMode||"Normal",style:JSON.parse(JSON.stringify(s.style||{})),geometry:JSON.parse(JSON.stringify(s.geometry||{})),options:s.options?JSON.parse(JSON.stringify(s.options)):{},masks:s.masks?JSON.parse(JSON.stringify(s.masks)):[],zIndex:s.zIndex!==void 0?s.zIndex:void 0})}),this.artboard.objects.some(s=>{var o;return(o=s.physics)==null?void 0:o.enabled})){this.physicsEngine=new os;const s=this.artboard.physics?{x:this.artboard.physics.gravity.x,y:this.artboard.physics.gravity.y}:{x:0,y:1};this.physicsEngine.init(s).then(()=>{var o;this.physicsEngine&&((o=this.artboard)==null||o.objects.forEach(e=>{var n,i;if((n=e.physics)!=null&&n.enabled&&e.type==="Shape"){const a=this.objectStates.get(e.id);if(!a)return;const r=e.geometry.width||100,l=e.geometry.height||100;this.physicsEngine.createBody({id:e.id,type:((i=e.geometry)==null?void 0:i.type)||"Rectangle",x:a.x,y:a.y,width:r,height:l,rotation:a.rotation*(Math.PI/180),isStatic:e.physics.bodyType==="Static",mass:e.physics.mass,friction:e.physics.friction,restitution:e.physics.restitution,frictionAir:e.physics.frictionAir,density:e.physics.density,isSensor:e.physics.isSensor})}}))})}this.artboard.stateVariables&&this.artboard.stateVariables.forEach(s=>{var n,i;let o=s.value;if(s.type==="RandomNumber"||s.type==="random_number"||s.min!==void 0&&s.max!==void 0&&((n=s.type)!=null&&n.toLowerCase().includes("random"))){const a=s.min??0,r=s.max??100;o=Math.random()*(r-a)+a}else if(s.type==="RandomColor"||s.type==="random_color"||s.minAlpha!==void 0&&((i=s.type)!=null&&i.toLowerCase().includes("random"))){const a=Math.floor(Math.random()*256),r=Math.floor(Math.random()*256),l=Math.floor(Math.random()*256),d=s.minAlpha??0,u=s.maxAlpha??1,g=(Math.random()*(u-d)+d).toFixed(2);o=`rgba(${a}, ${r}, ${l}, ${g})`}this.inputs.set(s.id,o);const e=this.inputNameMap.get(s.name)||[];e.includes(s.id)||e.push(s.id),this.inputNameMap.set(s.name,e)}),this.artboard.stateMachine&&(this.activeStateMachine=this.artboard.stateMachine,this.activeStateMachine.inputs.forEach(s=>{this.inputs.set(s.id,s.value.value);const o=this.inputNameMap.get(s.name)||[];o.push(s.id),this.inputNameMap.set(s.name,o)}),this.activeStateMachine.layers.forEach(s=>{let o=s.states.find(e=>e.id===s.entryStateId);!o&&s.states.length>0&&(console.warn(`[ExodeUI] Invalid entryStateId "${s.entryStateId}" in layer "${s.name}". Falling back to first state.`),o=s.states[0]),o&&this.enterStates(s.name,[o.id])}),this.evaluateTransitions()),this.initGlobalAnimationTriggers(),this.updateAutoLayout(!0),this.loadFonts()}updateAutoLayout(t=!1){var n;if(!this.artboard)return;const s=new Map;this.artboard.objects.forEach(i=>s.set(i.id,i));const o=.15,e=i=>{i.forEach(a=>{const r=this.objectStates.get(a.id);if(r){const l=Math.abs(r.x-a.x),d=Math.abs(r.y-a.y);!t&&(l>20||d>20)?(r.x+=(a.x-r.x)*o,r.y+=(a.y-r.y)*o):(r.x=a.x,r.y=a.y),a.width!==void 0&&(r.width=a.width),a.height!==void 0&&(r.height=a.height)}})};if((n=this.artboard.autoLayout)!=null&&n.enabled){const i=this.artboard.objects.filter(r=>!r.parentId),a=ns(this.artboard,i,r=>this.objectStates.get(r));e(a.childUpdates)}this.artboard.objects.forEach(i=>{var a;if(i.type==="Frame"&&((a=i.autoLayout)!=null&&a.enabled)&&i.children&&i.children.length>0){const r=i.children.map(u=>s.get(u)).filter(u=>!!u),l=this.objectStates.get(i.id);if(!l)return;const d=ns(l,r,u=>this.objectStates.get(u));d.frameWidth!==void 0&&(l.width=d.frameWidth),d.frameHeight!==void 0&&(l.height=d.frameHeight),e(d.childUpdates)}})}loadFonts(){if(!this.artboard)return;const t=new Set;if(this.artboard.objects.forEach(i=>{i.geometry&&i.geometry.type==="Text"&&i.geometry.fontFamily&&t.add(i.geometry.fontFamily)}),this.artboard.animations.forEach(i=>{i.tracks.forEach(a=>{(a.property==="geometry.fontFamily"||a.property==="fontFamily")&&a.keyframes.forEach(r=>{r.value&&typeof r.value=="string"&&t.add(r.value)})})}),t.size===0)return;let s="";t.forEach(i=>{const a=i.replace(/ /g,"+");s+=`&family=${a}:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900`});const o="exodeui-google-fonts",e="exodeui-fontshare-fonts";if(s.length>0){const i=`https://fonts.googleapis.com/css2?display=swap${s}`;let a=document.getElementById(o);a||(a=document.createElement("link"),a.id=o,a.rel="stylesheet",document.head.appendChild(a)),a.href!==i&&(a.href=i)}const n=[];if(t.forEach(i=>{i.toLowerCase().includes("clash display")&&n.push("clash-display@200,300,400,500,600,700")}),n.length>0){const i=`https://api.fontshare.com/v2/css?f[]=${n.join("&f[]=")}&display=swap`;let a=document.getElementById(e);a||(a=document.createElement("link"),a.id=e,a.rel="stylesheet",document.head.appendChild(a)),a.href!==i&&(a.href=i)}document.fonts&&document.fonts.ready&&document.fonts.ready.then(()=>{this.pretextCache.clear(),this.advance(0)})}enterStates(t,s){var i;if(s.length===0)return;const o=this.layerStates.get(t);if(o&&o.currentStateIds.length===s.length&&s.every(r=>o.currentStateIds.includes(r))&&this.justFiredTriggers.size===0)return;const e=[];let n=0;if(this.artboard&&this.activeStateMachine){const a=this.activeStateMachine.layers.find(r=>r.name===t);if(a)for(const r of s){const l=a.states.find(d=>d.id===r);if(l)if(l.isBlendState&&l.blendAnimations&&l.blendAnimations.length>0)e.push({animation:null,state:l}),l.blendAnimations.forEach(d=>{const u=this.artboard.animations.find(g=>g.id===d.animationId);u&&(n=Math.max(n,this.getAnimationDuration(u)))});else{let d=null;l.animationId&&(d=this.artboard.animations.find(u=>u.id===l.animationId)||null),d||(d=this.artboard.animations.find(u=>{var g,p;return u.name===l.name||u.id===l.name||(l.name==="Entry"||l.id==="entry")&&(((g=u.name)==null?void 0:g.toLowerCase())==="onload"||((p=u.name)==null?void 0:p.toLowerCase())==="intro")})||null),d&&((i=this.artboard.animationFlow)!=null&&i.some(g=>(g.trigger==="on_load"||g.trigger==="after_delay")&&g.targetAnimationId===(d==null?void 0:d.id))||(e.push({animation:d,state:l}),n=Math.max(n,this.getAnimationDuration(d))))}}}this.layerStates.set(t,{currentStateIds:s,animations:e,time:0,duration:n})}setInputBool(t,s){this.updateInput(t,s)}setInputNumber(t,s){this.updateInput(t,s)}fireTrigger(t){this.updateInput(t,!0)}setInputText(t,s){this.updateInput(t,s)}setInputNumberArray(t,s){this.updateInput(t,s)}setInputStringArray(t,s){this.updateInput(t,s)}updateObjectProperty(t,s,o){const e=this.objectStates.get(t);if(e)if(s.includes(".")||s.includes("[")){const n=s.replace(/\[(\d+)\]/g,".$1").split(".");let i=e;for(let a=0;a<n.length-1;a++){if(typeof i[n[a]]!="object"||i[n[a]]===null){const r=n[a+1],l=!isNaN(Number(r));i[n[a]]=l?[]:{}}i=i[n[a]]}i[n[n.length-1]]=o}else e[s]=o}updateInput(t,s){var l,d,u,g,p;let o;if(this.inputs.has(t)){const f=(l=this.activeStateMachine)==null?void 0:l.inputs.find(h=>h.id===t);f&&typeof f.value=="object"&&(o=f.value.type)}else{const f=this.inputNameMap.get(t);if(f&&f.length>0){const h=(d=this.activeStateMachine)==null?void 0:d.inputs.find(S=>S.id===f[0]);h&&typeof h.value=="object"&&(o=h.value.type)}}let e=s;o==="Trigger"&&(s===1?e=!0:s===0&&(e=!1));const n=(g=(u=this.artboard)==null?void 0:u.stateVariables)==null?void 0:g.find(f=>f.id===t||f.name===t);if(n&&(n.type==="RandomNumber"||n.type==="RandomColor"||n.type&&String(n.type).toLowerCase().includes("random"))){if(n.type==="RandomNumber"||n.type==="random_number"||n.min!==void 0&&n.max!==void 0){const f=n.min??0,h=n.max??100;e=Math.random()*(h-f)+f}else if(n.type==="RandomColor"||n.type==="random_color"||n.minAlpha!==void 0){const f=Math.floor(Math.random()*256),h=Math.floor(Math.random()*256),S=Math.floor(Math.random()*256),y=n.minAlpha??0,c=n.maxAlpha??1,v=(Math.random()*(c-y)+y).toFixed(2);e=`rgba(${f}, ${h}, ${S}, ${v})`}}let i=!1;this.inputs.has(t)&&(this.setInternalInput(t,e),i=!0);const a=this.inputNameMap.get(t);a&&a.length>0&&(a.forEach(f=>this.setInternalInput(f,e)),i=!0),i||this.setInternalInput(t,e),o==="Trigger"&&e===!0&&(this.justFiredTriggers.add(t),a&&a.forEach(f=>this.justFiredTriggers.add(f)));let r=null;if(Array.isArray(e))r=e;else if(typeof e=="string"&&e.trim().startsWith("[")&&e.trim().endsWith("]"))try{const f=JSON.parse(e);Array.isArray(f)&&(r=f)}catch{}r&&((p=this.artboard)==null||p.objects.forEach(f=>{var y;const h=(y=f.options)==null?void 0:y.dataInputId;if(f.inputId===t||f.name===t||h===t||a&&(a.includes(f.inputId)||h&&a.includes(h))){let c=this.objectStates.get(f.id);c&&!c.options&&(c.options=JSON.parse(JSON.stringify(f.options||{}))),c&&c.options&&(this.isListViewObject(f)?c.options.items=r:(f.type==="Dropdown"||f.variant==="dropdown")&&(c.options.optionsList=r)),f.options&&(this.isListViewObject(f)?f.options.items=r:(f.type==="Dropdown"||f.variant==="dropdown")&&(f.options.optionsList=r))}})),this.evaluateTransitions(),this.evaluateVariableTriggers(t,e)}evaluateVariableTriggers(t,s){if(!this.artboard)return;const o=this.artboard.animationFlow||[],e=this.inputNameMap.get(t);o.forEach(n=>{if(n.trigger==="variable"&&n.conditionVariableId&&n.targetAnimationId&&(n.conditionVariableId===t||e&&e.includes(n.conditionVariableId))){const a=n.conditionOperator||"IsTrue",r=n.conditionValue;let l=!1;switch(a){case"Equal":case"==":l=s==r;break;case"NotEqual":case"!=":l=s!=r;break;case"GreaterThan":case">":l=s>r;break;case"LessThan":case"<":l=s<r;break;case"GreaterEqual":case">=":l=s>=r;break;case"LessEqual":case"<=":l=s<=r;break;case"IsTrue":l=!!s;break;case"IsFalse":l=!s;break}if(l){const d=n.delay||0;d<=0?this.triggerGlobalAnimation(n.targetAnimationId,n.subAnimationIds,n.loop,n.id):setTimeout(()=>this.triggerGlobalAnimation(n.targetAnimationId,n.subAnimationIds,n.loop,n.id),d)}}})}evaluateTransitions(){this.activeStateMachine&&(this.activeStateMachine.layers.forEach(t=>{const s=this.layerStates.get(t.name);if(!s||s.currentStateIds.length===0)return;const o=[];let e=!1;for(const n of s.currentStateIds){const i=t.states.find(r=>r.id===n);if(!i)continue;let a=!1;for(const r of i.transitions||[])this.checkConditions(r.conditions)&&(o.push(r.targetStateId),a=!0,e=!0);a||o.push(n)}if(!e){const n=this.findGlobalTransition(t,s.currentStateIds);n&&(o.length=0,o.push(n.targetStateId),e=!0,n.conditions&&(n.conditions||[]).forEach(i=>{var r;const a=(r=this.activeStateMachine)==null?void 0:r.inputs.find(l=>l.id===i.inputId);a&&typeof a.value=="object"&&a.value.type==="Trigger"&&this.setInternalInput(i.inputId,!1)}))}if(e){const n=Array.from(new Set(o));this.enterStates(t.name,n)}}),this.justFiredTriggers.size>0&&(this.justFiredTriggers.forEach(t=>{var o,e;this.setInternalInput(t,!1);const s=(o=this.activeStateMachine)==null?void 0:o.inputs.find(n=>n.id===t);s&&this.inputNameMap.has(s.name)&&((e=this.inputNameMap.get(s.name))==null||e.forEach(n=>this.setInternalInput(n,!1)))}),this.justFiredTriggers.clear()))}findGlobalTransition(t,s){for(const o of t.states)if(!(s.includes(o.id)&&this.justFiredTriggers.size===0)){for(const n of o.transitions||[])if(!(s.includes(n.targetStateId)&&this.justFiredTriggers.size===0)&&this.checkConditions(n.conditions))return n}return null}checkConditions(t){return!t||t.length===0?!0:t.every(s=>{const o=s.inputId,e=s.op;let n=s.value;const i=this.evaluateLogicTree(o);if(i===void 0)return this.log(`[Engine] Condition Check Failed: Input ${o} is undefined`),!1;typeof i=="boolean"?n==="true"||n==="1"||n===1?n=!0:(n==="false"||n==="0"||n===0)&&(n=!1):typeof i=="number"&&typeof n=="string"&&(n=parseFloat(n));let a=!1;switch(e){case"Equal":case"==":a=i==n;break;case"NotEqual":case"!=":a=i!=n;break;case"GreaterThan":case">":a=i>n;break;case"LessThan":case"<":a=i<n;break;case"GreaterEqual":case">=":a=i>=n;break;case"LessEqual":case"<=":a=i<=n;break;case"IsTrue":a=!!i;break;case"IsFalse":a=!i;break;default:a=!1}return a||this.justFiredTriggers.has(o),a})}evaluateLogicTree(t,s=null,o=new Set){var a,r,l,d,u,g;if(o.has(t))return this.inputs.get(t)??this.logicNodeValues.get(t)??0;o.add(t);const e=(r=(a=this.activeStateMachine)==null?void 0:a.logicNodes)==null?void 0:r.find(p=>p.id===t);if(e){const p=(h,S)=>{const y=e.inputs.find(c=>c.id===h);return y?y.sourceId?this.evaluateLogicTree(y.sourceId,y.sourceHandleId,o):y.value!==void 0?y.value:S:S};let f=0;switch(e.op){case Ht.AND:f=p("a",!1)&&p("b",!1);break;case Ht.OR:f=p("a",!1)||p("b",!1);break;case Ht.NOT:f=!p("in",!1);break;case Ht.XOR:f=!!p("a",!1)!=!!p("b",!1);break;case Ht.OBJECT:f=e.name;break;case Ht.PROPERTY:case Ht.GET_PROPERTY:{const h=p("id","");if(!h){f=0;break}const S=e.name;if(!S||S==="GET_PROPERTY"||S==="PROPERTY"){f=0;break}const y=this.objectStates.get(h);if(!y){f=0;break}S in y?f=y[S]:f=this.resolvePath(y,S);break}case Ht.SET_PROPERTY:{const h=p("id",""),S=p("value",void 0);if(!h||S===void 0){f=0;break}const y=e.name;if(!y||y==="SET_PROPERTY"){f=0;break}const c=this.objectStates.get(h);if(!c){f=0;break}if(["x","y","rotation","scale_x","scale_y","opacity","width","height","cornerRadius","visible","zIndex"].includes(y))c[y]=S,f=S;else{const m=y.replace(/\[(\d+)\]/g,".$1").split(".");let C=c;for(let M=0;M<m.length-1;M++){const I=m[M],A=m[M+1];C[I]===void 0&&(C[I]=isNaN(Number(A))?{}:[]),C=C[I]}const w=m[m.length-1];C[w]=S,f=S}break}case Ht.ADD:f=p("a",0)+p("b",0);break;case Ht.SUB:f=p("a",0)-p("b",0);break;case Ht.MUL:f=p("a",0)*p("b",0);break;case Ht.DIV:{const h=p("b",1);f=h===0?0:p("a",0)/h;break}case Ht.MOD:f=p("a",0)%p("b",1);break;case Ht.POW:f=Math.pow(p("a",0),p("b",1));break;case Ht.ABS:f=Math.abs(p("in",0));break;case Ht.ROUND:f=Math.round(p("in",0));break;case Ht.FLOOR:f=Math.floor(p("in",0));break;case Ht.CEIL:f=Math.ceil(p("in",0));break;case Ht.SIN:f=Math.sin(p("in",0));break;case Ht.COS:f=Math.cos(p("in",0));break;case Ht.TAN:f=Math.tan(p("in",0));break;case Ht.CLAMP:{const h=p("in",0),S=p("min",0),y=p("max",1);f=Math.max(S,Math.min(y,h));break}case Ht.REMAP:{const h=p("in",0),S=p("inMin",0),y=p("inMax",100),c=p("outMin",0),v=p("outMax",1);f=y===S?c:c+(h-S)*(v-c)/(y-S);break}case Ht.EQ:f=p("a",0)==p("b",0);break;case Ht.NEQ:f=p("a",0)!=p("b",0);break;case Ht.GT:f=p("a",0)>p("b",0);break;case Ht.LT:f=p("a",0)<p("b",0);break;case Ht.GTE:f=p("a",0)>=p("b",0);break;case Ht.LTE:f=p("a",0)<=p("b",0);break;case Ht.IF_ELSE:f=p("cond",!1)?p("then",0):p("else",0);break;case Ht.VALUE:f=e.value!==void 0?e.value:0;break;case Ht.INPUT:f=this.inputs.get(e.name)??0;break;case Ht.LOG:{const h=p("in","");this.debugLog(`[User Logic] ${h}`),f=h;break}case Ht.SCROLL_X:f=this.inputs.get("scrollX")??0;break;case Ht.SCROLL_Y:f=this.inputs.get("scrollY")??0;break;case Ht.MOUSE_X:f=this.inputs.get("mouseX")??0;break;case Ht.MOUSE_Y:f=this.inputs.get("mouseY")??0;break;case Ht.IS_MOUSE_DOWN:f=this.inputs.get("isMouseDown")??!1;break;case Ht.EFFECTOR:{const h=p("id",""),S=p("intensity",1),y=p("trigger",!0);if(!h||!y){f=0;break}const c=e.name;if(!c){f=0;break}const v=this.objectStates.get(h);if(!v){f=0;break}if(["glitch","halftone","pixelate","noise","acid_gradient","acid_rave","shimmer"].includes(c))v.style||(v.style={}),v.style.artEffect={enabled:!0,type:c,intensity:S},f=1;else{v.behaviors||(v.behaviors=[]);let C=v.behaviors.find(w=>w.type===c);C?(C.enabled=!0,C.settings||(C.settings={}),C.settings.intensity=S):(C={id:`eff_${Date.now()}_${c}`,type:c,enabled:!0,sensors:[],settings:{intensity:S}},v.behaviors.push(C)),f=1}break}case Ht.MONITOR:{f=p("in",0);break}case Ht.SPRING_PULL:{const h=p("objectId",""),S=p("forceX",0),y=p("forceY",0);h&&((l=this.artboard)==null||l.objects.forEach(c=>{c.behaviors&&c.behaviors.forEach(v=>{var m;if(v.type===st.SpringChain&&((m=v.settings)!=null&&m.connections)&&(v.settings.connections.some(w=>w.targetId===h)||c.id===h)){this._springChainState.has(c.id)||this._springChainState.set(c.id,new Map);const w=this._springChainState.get(c.id);if(!w.has(h)){const I=this.objectStates.get(h);w.set(h,{x:(I==null?void 0:I.x)??0,y:(I==null?void 0:I.y)??0,vx:0,vy:0})}const M=w.get(h);M&&(M.vx+=S,M.vy+=y)}})})),f=1;break}case Ht.SPRING_SETTLE:{const h=p("objectId","");let S=!0;if(h){const y=p("threshold",1);this._springChainState.forEach(c=>{const v=c.get(h);v&&(Math.abs(v.vx)>y||Math.abs(v.vy)>y)&&(S=!1)})}f=S;break}case Ht.EMIT:{const h=p("objectId",""),S=p("count",20);h&&((d=this.artboard)==null||d.objects.forEach(y=>{y.behaviors&&y.behaviors.forEach(c=>{c.type===st.ParticleEmitter&&y.id===h&&(c._pendingBurst=(c._pendingBurst||0)+S)})})),f=1;break}default:f=0;break}if(this.logicNodeValues.set(t,f),e.op===Ht.DELAY){const h=p("delay",0),S=p("in",0);let y=this.logicNodeState.get(t);for(y||(y={queue:[]},this.logicNodeState.set(t,y)),y.queue.push({time:this.currentTime+h,value:S});y.queue.length>0&&y.queue[0].time<=this.currentTime;)y.lastValue=y.queue.shift().value;f=y.lastValue??0}return f}const n=(u=this.activeStateMachine)==null?void 0:u.inputs.find(p=>p.id===t||p.name===t);if(n&&n.sourceId&&!o.has(n.sourceId)){const p=this.evaluateLogicTree(n.sourceId,n.sourceHandleId,o);return this.inputs.set(n.id,p),p}let i=this.inputs.get(t)??(n?this.inputs.get(n.id):void 0);if((this.justFiredTriggers.has(t)||n&&this.justFiredTriggers.has(n.id))&&(i=!0),s&&i!==void 0){const p=(g=this.activeStateMachine)==null?void 0:g.inputs.find(f=>f.id===t);if(p&&p.value.type==="Number"&&typeof i=="number"){const f=p.value.defaultValue??p.value.value;if(s==="source-greater")return i>f;if(s==="source-less")return i<f;if(s==="source-equal")return i===f}if(s==="source-true")return i===!0;if(s==="source-false")return i===!1;if(s==="source-fire")return this.justFiredTriggers.has(t)}return i!==void 0?i:0}runLogicNodes(){!this.activeStateMachine||!this.activeStateMachine.logicNodes||this.activeStateMachine.logicNodes.forEach(t=>{(t.op===Ht.SET_PROPERTY||t.op===Ht.EFFECTOR)&&this.evaluateLogicTree(t.id)})}resolvePath(t,s){const o=s.replace(/\[(\d+)\]/g,".$1").split(".");let e=t;for(const n of o)if(e&&typeof e=="object"&&n in e)e=e[n];else return;return e}processLogicProperties(){!this.artboard||!this.artboard.objects||this.artboard.objects.forEach(t=>{const s=t.logicProperties;if(s&&s.length>0){const o=this.objectStates.get(t.id);if(!o)return;s.forEach(e=>{let n;if(e.valueType==="variable"?n=this.getInputValue(e.variableId):e.valueType==="constant"&&(n=e.value),n!==void 0){const i=e.name;if(["x","y","rotation","scale_x","scale_y","opacity","width","height","cornerRadius","visible","zIndex"].includes(i))o[i]=n;else{const r=i.replace(/\[(\d+)\]/g,".$1").split(".");let l=o;for(let u=0;u<r.length-1;u++){const g=r[u],p=r[u+1];l[g]===void 0&&(l[g]=isNaN(Number(p))?{}:[]),l=l[g]}const d=r[r.length-1];l[d]=n}}})}})}seek(t){this.artboard&&(this.currentTime=t,this.layerStates.forEach(s=>{s.time=t,s.time>(s.duration||0)&&(s.animations.some(e=>{var n;return((n=e.state)==null?void 0:n.loop)===!0})?s.time%=s.duration||1:s.time=s.duration)}),this.advance(0))}advance(t){if(!this.artboard)return;this.currentTime+=t,this.isMouseDown&&this.pointerDownTimes.forEach((o,e)=>{e&&this.currentTime-o>=.5&&(this.log(`[Engine] onHold detected for ${e}`),this.fireEventForObject(e,"onHold"),this.pointerDownTimes.delete(e))}),this.frameCount++,this.physicsEngine&&(this.physicsEngine.step(t),this.artboard.objects.forEach(o=>{var e;if((e=o.physics)!=null&&e.enabled){const n=this.physicsEngine.getPosition(o.id),i=this.physicsEngine.getRotation(o.id),a=this.objectStates.get(o.id);a&&n!==null&&i!==null&&(a.x=n.x,a.y=n.y,a.rotation=i*(180/Math.PI))}})),this.activeStateMachine&&(this.runLogicNodes(),this.evaluateTransitions()),this.processLogicProperties();const s=[];this.layerStates.forEach((o,e)=>{if(o.animations.length>0){if(o.time+=t,this.frameCount%240===0&&this.debugLog(`Advancing Layer time: ${o.time.toFixed(3)} / ${o.duration.toFixed(3)}`),o.time>o.duration)if(o.animations.some(i=>{var a;return((a=i.state)==null?void 0:a.loop)===!0}))o.time%=o.duration;else{const i=o.time<o.duration+.1;o.time=o.duration,i&&(e.startsWith("global_")&&console.log(`[Engine] GLOBAL layer done: ${e}, duration=${o.duration}, currentStateIds=${JSON.stringify(o.currentStateIds)}, ruleId=${o.ruleId}`),o.currentStateIds.length>0&&this.handleAnimationFinished(o.currentStateIds[0],o.ruleId),e.startsWith("global_")&&s.push(e))}o.animations.forEach(n=>{var i;(i=n.state)!=null&&i.isBlendState&&n.state.blendAnimations?this.applyBlendState(n.state,o.time):n.animation&&this.applyAnimation(n.animation,o.time,n.filterObjectIds)})}}),s.forEach(o=>{this.layerStates.delete(o),this.debugLog(`[Engine] Cleaned up completed global layer: ${o}`)}),this.solveConstraints(t),this.solveBehaviors(t),this.activeTriggers.forEach((o,e)=>{var n,i,a,r,l,d,u;if(o.phase==="entry")o.time+=t,o.time>=this.getAnimationDuration(o.animation)&&((a=(i=(n=this.artboard)==null?void 0:n.objects.find(g=>g.id===e))==null?void 0:i.triggers)==null||a.find(g=>g.id===o.triggerId),o.phase="hold",o.elapsedHold=0,o.time=this.getAnimationDuration(o.animation)),this.applyAnimation(o.animation,o.time,o.filterObjectIds||o.filterObjectId||void 0);else if(o.phase==="hold"){const g=(d=(l=(r=this.artboard)==null?void 0:r.objects.find(h=>h.id===e))==null?void 0:l.triggers)==null?void 0:d.find(h=>h.id===o.triggerId),p=(g==null?void 0:g.duration)||0;o.elapsedHold+=t*1e3;let f=o.elapsedHold>=p;if((g==null?void 0:g.eventType)==="hover"&&!this.activeHoverIds.has(e)&&(f=!0),((g==null?void 0:g.eventType)==="onHold"||(g==null?void 0:g.eventType)==="pointerDown")&&!this.isMouseDown&&(f=!0),f)if(g!=null&&g.exitAnimationId){const h=(u=this.artboard)==null?void 0:u.animations.find(S=>S.id===g.exitAnimationId);h?(o.phase="exit",o.animation=h,o.time=0):this.activeTriggers.delete(e)}else this.activeTriggers.delete(e)}else o.phase==="exit"&&(o.time+=t,o.time>=this.getAnimationDuration(o.animation)?this.activeTriggers.delete(e):this.applyAnimation(o.animation,o.time,o.filterObjectIds||o.filterObjectId||void 0))}),this.evaluateContinuousInteractions(t),this.processJoysticks(t),this.activeStateMachine&&this.onLogicUpdate&&this.logicNodeValues.size>0&&this.onLogicUpdate(Object.fromEntries(this.logicNodeValues))}evaluateContinuousInteractions(t){this.artboard&&(this.artboard.objects.forEach(s=>{var e,n,i;const o=(e=s.style)==null?void 0:e.analytics;if(o&&o.isEnabled&&o.triggerType==="visible"){const a=this.objectStates.get(s.id);if(a&&a.visible!==!1){const r=this.getGlobalTransform(s.id),l=(((n=s.geometry)==null?void 0:n.width)||100)*(r.scale_x||1),d=(((i=s.geometry)==null?void 0:i.height)||100)*(r.scale_y||1),u=50,g=r.x+l/2>=-this.canvasWidth/2-u&&r.x-l/2<=this.canvasWidth/2+u&&r.y+d/2>=-this.canvasHeight/2-u&&r.y-d/2<=this.canvasHeight/2+u,p=`analytics_${s.id}`,f=this.wasInView.has(p);g&&!f&&this.fireAnalyticsEvent(s.id,"visible"),g?this.wasInView.add(p):this.wasInView.delete(p)}}}),this.artboard.objects.forEach(s=>{const o=s.interactions||[];o.length!==0&&o.forEach(e=>{const n=e.triggers||[e.event||e.trigger];n&&n.forEach(i=>{var r,l,d;const a=i.toLowerCase();if(a==="on interval"||a==="oninterval"){const u=e.intervalValue||2e3,g=this.periodicTriggerTimes.get(e.id)||0;this.currentTime*1e3-g>=u&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(s.id,"On Interval"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="on delay"||a==="ondelay"){const u=e.delayValue||1e3;!this.periodicTriggerTimes.has(e.id)&&this.currentTime*1e3>=u&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(s.id,"On Delay"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="scroll into view"||a==="scrollintoview"){const u=this.objectStates.get(s.id);if(u&&u.visible!==!1){const g=this.getGlobalTransform(s.id),p=(((r=s.geometry)==null?void 0:r.width)||100)*(g.scale_x||1),f=(((l=s.geometry)==null?void 0:l.height)||100)*(g.scale_y||1),h=50,S=g.x+p/2>=-this.canvasWidth/2-h&&g.x-p/2<=this.canvasWidth/2+h&&g.y+f/2>=-this.canvasHeight/2-h&&g.y-f/2<=this.canvasHeight/2+h,y=this.wasInView.has(s.id);S&&!y&&(!e.conditions||this.checkConditions(e.conditions))&&this.fireEventForObject(s.id,"Scroll Into View"),S?this.wasInView.add(s.id):this.wasInView.delete(s.id)}}if(a==="scroll progress"||a==="scrollprogress"){const u=Math.abs(this.scrollOffset.y)/(((d=this.artboard)==null?void 0:d.height)||1e3),g=this.scrollProgressLastValue.get(e.id)||0;Math.abs(u-g)>.001&&(this.scrollProgressLastValue.set(e.id,u),(e.action==="Set Input"||e.action==="setInput")&&this.updateInput(e.targetInputId,u))}})})}))}solveConstraints(t){this.artboard&&this.artboard.objects.forEach(s=>{if(!s.constraints||s.constraints.length===0)return;const o=this.objectStates.get(s.id);if(!o)return;const e=this.getGlobalTransform(s.id);if(s.constraints.forEach((n,i)=>{var d,u,g,p,f,h,S,y,c;const a=((d=o.constraints)==null?void 0:d[i])||{},r={...n,...a},l=r.strength??1;if(r.type==="Translation"){const v=this.getGlobalTransform(r.targetId);if(v){const m=r.offsetX||0,C=r.offsetY||0,w=v.x+m,M=v.y+C,I=r.useSpring;if(I){const T=this.objectVelocities.get(s.id)||{vx:0,vy:0},L=Math.max(0,Math.min(t,.05)),F=r.copyX!==!1,D=r.copyY!==!1,R=F?e.x+(w-e.x)*l:e.x,X=D?e.y+(M-e.y)*l:e.y,{x:P,y:k,vx:O,vy:E}=this.computeSpring(e.x,e.y,T.vx,T.vy,R,X,r,L);F&&(e.x=P),D&&(e.y=k),this.objectVelocities.set(s.id,{vx:F?O:0,vy:D?E:0})}else r.copyX!==!1&&(e.x=e.x+(w-e.x)*l),r.copyY!==!1&&(e.y=e.y+(M-e.y)*l);let A=!1,_=!1;if((u=r.limitX)!=null&&u.enabled){const T=e.x;e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x)),e.x!==T&&(A=!0)}if((g=r.limitY)!=null&&g.enabled){const T=e.y;e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)),e.y!==T&&(_=!0)}if((A||_)&&I){const T=this.objectVelocities.get(s.id)||{vx:0,vy:0};this.objectVelocities.set(s.id,{vx:A?0:T.vx,vy:_?0:T.vy})}}}else if(r.type==="Rotation"){const v=this.getGlobalTransform(r.targetId);if(v){let C=(v.rotation+(r.offset||0)-e.rotation)%360;C>180&&(C-=360),C<-180&&(C+=360),e.rotation=e.rotation+C*l}}else if(r.type==="Scale"){const v=this.getGlobalTransform(r.targetId);v&&(r.copyX&&(e.scale_x=e.scale_x+(v.scale_x-e.scale_x)*l),r.copyY&&(e.scale_y=e.scale_y+(v.scale_y-e.scale_y)*l))}else if(r.type==="Transform"){const v=this.getGlobalTransform(r.targetId);if(v){e.x=e.x+(v.x-e.x)*l,e.y=e.y+(v.y-e.y)*l;let m=(v.rotation-e.rotation)%360;m>180&&(m-=360),m<-180&&(m+=360),e.rotation=e.rotation+m*l,e.scale_x=e.scale_x+(v.scale_x-e.scale_x)*l,e.scale_y=e.scale_y+(v.scale_y-e.scale_y)*l}}else if(r.type==="FollowPointer"){const v=((p=this._lastPointerPos)==null?void 0:p.x)??e.x,m=((f=this._lastPointerPos)==null?void 0:f.y)??e.y,C=r.useSpring;if(C){const M=this.objectVelocities.get(s.id)||{vx:0,vy:0},{x:I,y:A,vx:_,vy:T}=this.computeSpring(e.x,e.y,M.vx,M.vy,v,m,r,t);e.x=I,e.y=A,this.objectVelocities.set(s.id,{vx:_,vy:T})}else e.x=e.x+(v-e.x)*l,e.y=e.y+(m-e.y)*l;let w=!1;if((h=r.limitX)!=null&&h.enabled){const M=e.x;e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x)),e.x!==M&&(w=!0)}if((S=r.limitY)!=null&&S.enabled){const M=e.y;e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)),e.y!==M&&(w=!0)}w&&C&&this.objectVelocities.set(s.id,{vx:0,vy:0})}else if(r.type==="Distance"){const v=this.getGlobalTransform(r.targetId);if(v){const m=e.x-v.x,C=e.y-v.y,w=Math.sqrt(m*m+C*C),M=r.distance||0;let I=w;switch(r.mode){case"exact":I=M;break;case"minimum":I=Math.max(M,w);break;case"maximum":I=Math.min(M,w);break;case"clamped":I=Math.max(0,Math.min(M,w));break}if(w>0){const A=e.x===v.x&&e.y===v.y?1:I/w;e.x=e.x+(v.x+m*A-e.x)*l,e.y=e.y+(v.y+C*A-e.y)*l}}}else if(r.type==="FollowPath"){const v=(y=this.artboard)==null?void 0:y.objects.find(m=>m.id===r.targetId);if(v){const m=this.getGlobalTransform(v.id);if(m){let C=v.geometry;if(v.type==="Frame"||v.type==="Group"||!C||C.type!=="Path"&&C.type!=="Ellipse"&&C.type!=="Rectangle"){const B=(c=this.artboard)==null?void 0:c.objects.find(G=>G.parentId===v.id&&G.type==="Shape"&&G.geometry&&(G.geometry.type==="Path"||G.geometry.type==="Ellipse"||G.geometry.type==="Rectangle"));B&&(C=B.geometry)}if(!C)return;const w=Math.max(0,Math.min(1,(r.distance||0)/100)),M=m.width||C.width||0,I=m.height||C.height||0,A=this.getPointOnPath(C,M,I,w),_=m.rotation*Math.PI/180,T=Math.cos(_),L=Math.sin(_),F=A.x*m.scale_x*T-A.y*m.scale_y*L,D=A.x*m.scale_x*L+A.y*m.scale_y*T;let R=m.rotation+(r.offsetRotation||0);if(r.orient){const B=Math.cos(A.angle),G=Math.sin(A.angle),z=B*m.scale_x*T-G*m.scale_y*L,V=B*m.scale_x*L+G*m.scale_y*T;R=Math.atan2(V,z)*180/Math.PI+(r.offsetRotation||0)}const X=R*Math.PI/180,P=Math.cos(X),k=Math.sin(X),O=(r.offsetX||0)*P-(r.offsetY||0)*k,E=(r.offsetX||0)*k+(r.offsetY||0)*P,N=m.x+F+O,W=m.y+D+E;if(e.x=e.x+(N-e.x)*l,e.y=e.y+(W-e.y)*l,r.orient){let B=(R-e.rotation)%360;B>180&&(B-=360),B<-180&&(B+=360),e.rotation=e.rotation+B*l}}}}else if(r.type==="IK"){const v=this.getGlobalTransform(r.targetId);v&&this.solveIK(s,v,r.boneCount||2,l)}}),s.constraints.some(n=>n.type!=="IK")){const n=this.globalToLocal(s.parentId,e);o.x=n.x,o.y=n.y,o.rotation=n.rotation,o.flip_x=n.scale_x<0,o.scale_x=Math.abs(n.scale_x),o.flip_y=n.scale_y<0,o.scale_y=Math.abs(n.scale_y)}})}getGlobalTransform(t){var u,g;const s=this.objectStates.get(t);if(!s)return{x:0,y:0,rotation:0,scale_x:1,scale_y:1};const o=(u=this.artboard)==null?void 0:u.objects.find(p=>p.id===t),e=(o==null?void 0:o.type)==="Bone"?(g=o.geometry)==null?void 0:g.length:void 0;if(!o||!o.parentId)return{x:s.x,y:s.y,rotation:s.rotation,scale_x:(s.scale_x??1)*(s.flip_x?-1:1),scale_y:(s.scale_y??1)*(s.flip_y?-1:1),length:e};const n=this.getGlobalTransform(o.parentId),i=n.rotation*Math.PI/180,a=Math.cos(i),r=Math.sin(i),l=n.x+(s.x*n.scale_x*a-s.y*n.scale_y*r),d=n.y+(s.x*n.scale_x*r+s.y*n.scale_y*a);return{x:l,y:d,rotation:n.rotation+s.rotation,scale_x:n.scale_x*(s.scale_x??1)*(s.flip_x?-1:1),scale_y:n.scale_y*(s.scale_y??1)*(s.flip_y?-1:1),length:e}}globalToLocal(t,s){if(!t)return s;const o=this.getGlobalTransform(t),e=o.scale_x===0?0:1/o.scale_x,n=o.scale_y===0?0:1/o.scale_y,i=-o.rotation*Math.PI/180,a=Math.cos(i),r=Math.sin(i),l=s.x-o.x,d=s.y-o.y,u=(l*a-d*r)*e,g=(l*r+d*a)*n;return{x:u,y:g,rotation:s.rotation-o.rotation,scale_x:s.scale_x/(o.scale_x||1),scale_y:s.scale_y/(o.scale_y||1)}}solveIK(t,s,o,e){var l;const n=[];let i=t.id;for(let d=0;d<o&&i;d++){const u=(l=this.artboard)==null?void 0:l.objects.find(g=>g.id===i);if(!u)break;n.push({id:i,local:this.objectStates.get(i),global:this.getGlobalTransform(i)}),i=u.parentId}if(n.length<2)return;const a=n.reverse(),r=5;for(let d=0;d<r;d++){const u=this.getGlobalTransform(t.id);for(let g=a.length-2;g>=0;g--){const p=a[g],f=this.getGlobalTransform(p.id),h=u.x-f.x,S=u.y-f.y,y=s.x-f.x,c=s.y-f.y,v=Math.sqrt(h*h+S*S),m=Math.sqrt(y*y+c*c);if(v>.001&&m>.001){const C=Math.atan2(S,h);let M=(Math.atan2(c,y)-C)*180/Math.PI;M*=e;const I=this.objectStates.get(p.id);I&&(I.rotation+=M)}}}}computeSpring(t,s,o,e,n,i,a,r){const l=a.stiffness??100,d=a.damping??10,u=a.mass??1,g=-l*(t-n),p=-l*(s-i),f=-d*o,h=-d*e,S=(g+f)/u,y=(p+h)/u,c=o+S*r,v=e+y*r,m=t+c*r,C=s+v*r;return{x:m,y:C,vx:c,vy:v}}handlePointerInput(t,s,o,e,n){if(!this.artboard)return;const i=this.calculateTransform(e,n,this.artboard.width,this.artboard.height,this.layout.fit,this.layout.alignment),a=(s-i.tx)/i.scaleX,r=(o-i.ty)/i.scaleY;this._prevPointerPos=this._lastPointerPos,this._lastPointerPos={x:a,y:r},this._prevPointerPos&&(this._mouseDelta.dx+=a-this._prevPointerPos.x,this._mouseDelta.dy+=r-this._prevPointerPos.y),this.updateInput("mouseX",a),this.updateInput("mouseY",r),this.handlePointerEvent(t,a,r)}handleScroll(t,s){const o=this.scrollOffset.x,e=this.scrollOffset.y;this.scrollOffset={x:t,y:s},this._totalScroll.x+=t-o,this._totalScroll.y+=s-e,this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}isListViewObject(t){var n;if(!t)return!1;const s=(t.type||"").toLowerCase(),o=(t.variant||"").toLowerCase(),e=(((n=t.geometry)==null?void 0:n.type)||"").toLowerCase();return s==="listview"||o==="listview"||e==="listview"}isLineGraphObject(t){var i;if(!t)return!1;const s=(t.type||"").toLowerCase(),o=(t.variant||"").toLowerCase(),e=(((i=t.geometry)==null?void 0:i.type)||"").toLowerCase(),n=(t.name||"").toLowerCase();return s==="linegraph"||e==="linegraph"||o==="linegraph"||n.includes("linegraph")}isBarChartObject(t){var i;if(!t)return!1;const s=(t.type||"").toLowerCase(),o=(t.variant||"").toLowerCase(),e=(((i=t.geometry)==null?void 0:i.type)||"").toLowerCase(),n=(t.name||"").toLowerCase();return s==="barchart"||e==="barchart"||o==="barchart"||n.includes("barchart")}isPieChartObject(t){var i;if(!t)return!1;const s=(t.type||"").toLowerCase(),o=(t.variant||"").toLowerCase(),e=(((i=t.geometry)==null?void 0:i.type)||"").toLowerCase(),n=(t.name||"").toLowerCase();return s==="piechart"||e==="piechart"||o==="piechart"||n.includes("piechart")}isGraphObject(t){return this.isLineGraphObject(t)||this.isBarChartObject(t)||this.isPieChartObject(t)}isInputBoxObject(t){if(!t)return!1;const s=(t.type||"").toLowerCase(),o=(t.variant||"").toLowerCase(),e=(t.name||"").toLowerCase();return s==="inputbox"||o==="inputbox"||e==="inputbox"}isClickableObject(t){if(!t)return!1;const s=(t.variant||"").toLowerCase(),o=(t.type||"").toLowerCase(),e=["button","toggle","toggle_button","dropdown","slider","checkbox","radiogroup"];return e.includes(s)||e.includes(o)}getLastHoveredObject(){return!this.lastHoveredObjectId||!this.artboard?null:this.artboard.objects.find(t=>t.id===this.lastHoveredObjectId)||null}clearAllGraphHover(){this.graphHoverStates.size>0&&this.graphHoverStates.clear()}getLocalCoords(t,s,o){const e=this.getWorldTransform(t),n=s-e.x,i=o-e.y,a=-(e.rotation||0)*(Math.PI/180),r=Math.cos(a),l=Math.sin(a),d=e.scaleX||1,u=e.scaleY||1;return{x:(n*r-i*l)/(d!==0?d:1),y:(n*l+i*r)/(u!==0?u:1)}}updateGraphHoverFromPointer(t,s,o){var r,l;if(!t||!this.isGraphObject(t)){this.clearAllGraphHover();return}for(const d of Array.from(this.graphHoverStates.keys()))d!==t.id&&this.graphHoverStates.delete(d);const e=this.getLocalCoords(t.id,s,o),n=this.objectStates.get(t.id),i=(n==null?void 0:n.width)??((r=t.geometry)==null?void 0:r.width)??t.width??300,a=(n==null?void 0:n.height)??((l=t.geometry)==null?void 0:l.height)??t.height??180;if(e.x<-i/2||e.x>i/2||e.y<-a/2||e.y>a/2){this.graphHoverStates.delete(t.id);return}if(this.isLineGraphObject(t)){const d=n!=null&&n.geometry?this.deepMerge(t.geometry,n.geometry):t.geometry||{};let u=d.datasets||[];(!u||u.length===0)&&(d.data||d.graphData)&&(u=[{data:d.data||d.graphData}]);let g=0;if(u.forEach(p=>{let f=p.data;if(p.isVarEnabled&&p.inputId){let h=this.inputs.get(p.inputId);if(h===void 0){const S=this.inputNameMap.get(p.inputId);S&&S.length>0&&(h=this.inputs.get(S[0]))}h&&Array.isArray(h)&&(f=h)}f&&f.length>0&&(g=Math.max(g,f.length))}),g>=2){const p=i/(g-1),f=e.x+i/2,h=Math.max(0,Math.min(g-1,Math.round(f/p)));this.graphHoverStates.set(t.id,{hoveredIndex:h,hoverPointer:{x:e.x,y:e.y}})}}else if(this.isBarChartObject(t)){const d=this.barChartRenderedBars.get(t.id)||[];let u=null;for(let g=d.length-1;g>=0;g--){const p=d[g];if(e.x>=p.x&&e.x<=p.x+p.w&&e.y>=p.y&&e.y<=p.y+p.h){u=p;break}}u?this.graphHoverStates.set(t.id,{hoveredCatIdx:u.catIdx,hoveredDsIdx:u.dsIdx,bar:u,hoverPointer:{x:e.x,y:e.y}}):this.graphHoverStates.delete(t.id)}else if(this.isPieChartObject(t)){const d=this.pieChartRenderedSlices.get(t.id)||[];let u=null;for(const g of d){const p=e.x-g.cx,f=e.y-g.cy,h=Math.hypot(p,f);if(h>=g.innerR&&h<=g.outerR){let S=Math.atan2(f,p);const y=w=>(w%(Math.PI*2)+Math.PI*2)%(Math.PI*2),c=y(S),v=y(g.startA),m=y(g.endA);if(v<=m?c>=v&&c<=m:c>=v||c<=m){u=g.index;break}}}u!==null?this.graphHoverStates.set(t.id,{hoveredSliceIndex:u,hoverPointer:{x:e.x,y:e.y}}):this.graphHoverStates.delete(t.id)}}getGraphHoverState(t){return this.graphHoverStates.get(t)}getResolvedListViewItems(t,s){const o=this.objectStates.get(t==null?void 0:t.id),e=s||(o==null?void 0:o.options)||(t==null?void 0:t.options)||{};let n=Array.isArray(e.items)?e.items:typeof e.items=="string"?e.items.split(",").map(i=>i.trim()):[];if(e.isDataVarEnabled&&e.dataInputId){let i=this.inputs.get(e.dataInputId);if(i===void 0){const a=this.inputNameMap.get(e.dataInputId);a&&a.length>0&&(i=this.inputs.get(a[0]))}if(i&&Array.isArray(i))n=i.map(a=>typeof a=="string"?a:String(a));else if(typeof i=="string")try{n=JSON.parse(i).map(a=>String(a))}catch{}}return n}getResolvedDropdownOptions(t,s){const o=this.objectStates.get(t==null?void 0:t.id),e=s||(o==null?void 0:o.options)||(t==null?void 0:t.options)||{};let n=Array.isArray(e.optionsList)?e.optionsList:typeof e.optionsList=="string"?e.optionsList.split(",").map(i=>i.trim()):[];if(e.isDataVarEnabled&&e.dataInputId){let i=this.inputs.get(e.dataInputId);if(i===void 0){const a=this.inputNameMap.get(e.dataInputId);a&&a.length>0&&(i=this.inputs.get(a[0]))}if(i&&Array.isArray(i))n=i.map(a=>typeof a=="string"?a:String(a));else if(typeof i=="string")try{const a=JSON.parse(i);Array.isArray(a)?n=a.map(String):n=i.split(",").map(r=>r.trim())}catch{n=i.split(",").map(a=>a.trim())}}return n}handleWheel(t,s,o,e,n,i){var a,r,l,d;if(o!==void 0&&e!==void 0&&n&&i&&this.artboard){const u=this.calculateTransform(n,i,this.artboard.width,this.artboard.height,this.layout.fit,this.layout.alignment),g=(o-u.tx)/u.scaleX,p=(e-u.ty)/u.scaleY;this._lastPointerPos={x:g,y:p}}if(this._lastPointerPos&&this.artboard){let u=!1;for(let g=this.artboard.objects.length-1;g>=0;g--){const p=this.artboard.objects[g];if(this.isListViewObject(p)){const f=this.objectStates.get(p.id),h=(f==null?void 0:f.options)||p.options||{},S=(f==null?void 0:f.width)??(((a=p.geometry)==null?void 0:a.width)||200),y=(f==null?void 0:f.height)??(((r=p.geometry)==null?void 0:r.height)||300),c=this.getWorldTransform(p.id),v=this._lastPointerPos.x-c.x,m=this._lastPointerPos.y-c.y,C=-c.rotation*(Math.PI/180),w=Math.cos(C),M=Math.sin(C),I=v*w-m*M,A=v*M+m*w,_=c.scaleX||1,T=c.scaleY||1,L=S*Math.abs(_),F=y*Math.abs(T);if(Math.abs(I)<=L/2&&Math.abs(A)<=F/2){const D=h.orientation||"vertical";let R=h.scrollOffset||0;if(D==="vertical"?R-=s:R-=Math.abs(t)>Math.abs(s)?t:s,(h.listLayout||"linear")==="circular")h.scrollOffset=R,f&&f.options&&(f.options.scrollOffset=R),p.options&&(p.options.scrollOffset=R);else{const P=this.getResolvedListViewItems(p,h),k=h.itemGap??10,O=h.itemHeight??50,E=h.itemWidth??200,N=typeof h.padding=="number"?h.padding:D==="vertical"?((l=h.padding)==null?void 0:l[0])||0:((d=h.padding)==null?void 0:d[3])||0,B=(P.length||0)*(D==="vertical"?O:E)+Math.max(0,(P.length||0)-1)*k+N*2,z=Math.max(0,B-(D==="vertical"?y:S));R>0&&(R=0),R<-z&&(R=-z),h.scrollOffset=R,f&&f.options&&(f.options.scrollOffset=R),p.options&&(p.options.scrollOffset=R)}u=!0;break}}}if(u)return}this._totalScroll.x+=t,this._totalScroll.y+=s,this.scrollOffset={x:this._totalScroll.x,y:this._totalScroll.y},this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}handlePointerEvent(t,s,o){var r,l,d,u,g,p,f,h,S,y;if(!this.artboard)return;t==="down"?(this.isMouseDown=!0,this.updateInput("isMouseDown",!0)):(t==="up"||t==="blur")&&(this.isMouseDown=!1,this.updateInput("isMouseDown",!1));let e=null;const n=(c,v)=>{var A;let m=v;v==="click"?m="onClick":v==="down"?m="onPointerDown":v==="up"?m="onPointerUp":v==="blur"&&(m="onPointerLeave");const C=new Set([m]);v==="move"&&(C.add("onPointerEnter").add("hover").add("onPointerLeave").add("blur"),C.add("Drag").add("drag").add("ondrag")),m==="onClick"&&C.add("click"),m==="onPointerDown"&&C.add("pointerDown"),m==="onPointerUp"&&C.add("pointerUp");const w=["button","toggle","toggle_button","dropdown","listview","inputbox","slider","checkbox","radiogroup","joystick","barchart","piechart","linegraph"];if(this.isListViewObject(c)||this.isGraphObject(c)||c.type==="Component"&&c.variant&&w.includes(String(c.variant).toLowerCase())||c.type==="Joystick"||w.includes((A=c.type)==null?void 0:A.toLowerCase()))return!0;const M=c.interactions||[];return!!(M.some(_=>C.has(_.event)||C.has(_.trigger))||M.some(_=>Array.isArray(_.triggers)&&_.triggers.some(T=>C.has(String(T))))||(c.triggers||[]).some(_=>C.has(_.eventType)))};let i=null;for(let c=this.artboard.objects.length-1;c>=0;c--){const v=this.artboard.objects[c],m=this.objectStates.get(v.id);if(m&&m.visible!==!1&&m.opacity>0&&this.hitTest(v,s,o)&&(i||(i=v),n(v,t))){e=v;break}}!e&&i&&(e=i),this.pointerHistory.push({x:s,y:o,time:Date.now()}),this.pointerHistory.length>this.MAX_HISTORY&&this.pointerHistory.shift();const a=(e==null?void 0:e.id)||null;if(t==="move"){if(this.draggingSliderId){const c=this.artboard.objects.find(v=>v.id===this.draggingSliderId);c&&this.updateSliderValueFromPointer(c,s,o);return}if(this.draggingJoystickId){const c=this.artboard.objects.find(v=>v.id===this.draggingJoystickId);c&&this.updateJoystickValueFromPointer(c,s,o);return}if(this.draggingListViewId){const c=this.artboard.objects.find(v=>v.id===this.draggingListViewId);c&&this.updateListViewScrollFromPointer(c);return}if(e&&this.isListViewObject(e)&&this.updateListViewHoverFromPointer(e,s,o),this.updateGraphHoverFromPointer(e,s,o),this.isMouseDown&&this.dragStartPointer&&this.draggingBehaviors.size>0){const c=s-this.dragStartPointer.x,v=o-this.dragStartPointer.y;this.draggingBehaviors.forEach(m=>{const C=this.dragStartPositions.get(m);if(!C)return;const w=this.artboard.objects.find(I=>I.id===m);if(!w||w.parentId)return;const M=this.objectStates.get(m);M&&(M.x=C.x+c,M.y=C.y+v)})}if(this.isMouseDown){const c=this.activeObjectId&&this.artboard.objects.some(m=>m.id===this.activeObjectId)?this.activeObjectId:a,v=c?this.artboard.objects.find(m=>m.id===c):null;v&&n(v,"move")&&this.fireEventForObject(v.id,"Drag")}!this.isMouseDown&&a!==this.lastHoveredObjectId&&(this.log(`[Engine] HOVER CHANGE: ${this.lastHoveredObjectId} -> ${a}`),this.lastHoveredObjectId&&this.fireEventForObject(this.lastHoveredObjectId,"onPointerLeave"),a&&this.fireEventForObject(a,"onPointerEnter"),this.lastHoveredObjectId=a);return}if((t==="up"||t==="blur")&&(this.draggingSliderId=null,this.draggingJoystickId=null,this.draggingListViewId=null,this.draggingListViewIsScrollbar=!1,this.draggingBehaviors.clear(),this.dragStartPointer=null,this.dragStartPositions.clear(),this.pointerDownTimes.delete(a),this.activeObjectId=null,t==="blur"&&this.clearAllGraphHover()),t==="down"&&(this.pointerDownTimes.set(a,this.currentTime),this.activeObjectId=a,e&&((r=e.behaviors)!=null&&r.some(c=>c.type===st.Draggable)||this.hasDragInteraction(e)))){this.draggingBehaviors.add(a);const c=this.objectStates.get(a);c&&(this.dragStartPointer={x:s,y:o},this.dragStartPositions.set(a,{x:c.x??0,y:c.y??0}))}if(t==="move"?(a&&!this.activeHoverIds.has(a)&&this.activeHoverIds.add(a),this.activeHoverIds.forEach(c=>{c!==a&&this.activeHoverIds.delete(c)})):t==="blur"&&this.activeHoverIds.clear(),this.activeDropdownId&&t==="down"){const c=this.artboard.objects.find(v=>v.id===this.activeDropdownId);if(c&&(c.type==="Dropdown"||c.variant==="dropdown")){const v=this.objectStates.get(c.id),m=(v==null?void 0:v.options)||c.options||{},C=c.geometry||{},w=C.width??c.width??200,M=C.height??c.height??40,I=this.getResolvedDropdownOptions(c,m),A=m.itemHeight||32,_=m.listPadding??4,T=I.length*A+_*2,L=this.getWorldTransform(c.id),F=w*Math.abs(L.scaleX),D=M*Math.abs(L.scaleY),R=L.y+D/2+4,X=Math.abs(s-L.x)<=F/2,P=o>=R&&o<=R+T*Math.abs(L.scaleY);if(X&&P){const k=Math.abs(L.scaleY),O=o-(R+_*k),E=Math.floor(O/(A*k));if(E>=0&&E<I.length){const N=I[E];m.selectedOption=N,m.isOpen=!1,this.activeDropdownId=null,c.inputId&&this.setInternalInput(c.inputId,N),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"dropdown",property:"selectedOption",value:N})}return}else a!==this.activeDropdownId&&(m.isOpen=!1,this.activeDropdownId=null)}}if(e){let c=e,v=e;for(;v&&v.parentId;){const w=this.artboard.objects.find(M=>M.id===v.parentId);if(w&&w.type==="Component"){c=w;break}v=w}let m=t;if(t==="click"?m="onClick":t==="down"?m="onPointerDown":t==="up"?m="onPointerUp":t==="blur"&&(m="onPointerLeave"),this.fireEventForObject(e.id,m),c!==e&&this.fireEventForObject(c.id,m),c.type==="Component"&&c.variant==="toggle_button"&&t==="down"){const w=this.objectStates.get(c.id),M=(w==null?void 0:w.options)||c.options||{};M.checked=!M.checked,c.inputId&&this.setInternalInput(c.inputId,M.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"toggle_button",property:"checked",value:M.checked}),this.fireEventForObject(c.id,"Toggle"),this.fireEventForObject(c.id,M.checked?"Toggle True":"Toggle False")}if(c.type==="Component"&&c.variant==="toggle"&&t==="down"){const w=this.objectStates.get(c.id),M=(w==null?void 0:w.options)||c.options||{};M.checked=!M.checked,c.inputId&&this.setInternalInput(c.inputId,M.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"toggle",property:"checked",value:M.checked}),this.onToggle&&this.onToggle(c.name,M.checked),this.fireEventForObject(c.id,"Toggle"),this.fireEventForObject(c.id,M.checked?"Toggle True":"Toggle False")}if(c.type==="Component"&&c.variant==="dropdown"&&t==="down"){const w=this.objectStates.get(c.id),M=(w==null?void 0:w.options)||c.options||{},I=!M.isOpen;if(I&&this.activeDropdownId&&this.activeDropdownId!==c.id){const A=this.artboard.objects.find(_=>_.id===this.activeDropdownId);A&&A.options&&(A.options.isOpen=!1)}M.isOpen=I,this.activeDropdownId=I?c.id:null}if((c.type==="Button"||c.type==="Component"&&(c.variant==="button"||(c.name||"").toLowerCase().includes("button")||(c.name||"").toLowerCase().includes("cta")))&&t==="down"&&(this.onButtonClick&&this.onButtonClick(c.name,c.id),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"button",property:"click",value:!0})),this.isListViewObject(c)&&t==="down"){this.draggingListViewId=c.id;const w=this.objectStates.get(c.id),M=(w==null?void 0:w.options)||c.options||{},I=(w==null?void 0:w.width)??(((l=c.geometry)==null?void 0:l.width)||200),A=(w==null?void 0:w.height)??(((d=c.geometry)==null?void 0:d.height)||300),_=M.orientation||"vertical",T=M.scrollbarWidth||4,L=M.showScrollbar!==!1;let F=!1;if(L&&M.listLayout!=="circular"){const R=this.getWorldTransform(c.id),X=-R.rotation*(Math.PI/180),P=Math.cos(X),k=Math.sin(X),O=s-R.x,E=o-R.y,N=O*P-E*k,W=O*k+E*P,B=R.scaleX||1,G=R.scaleY||1,z=N/B,V=W/G,U=12;_==="vertical"?z>=I/2-T-U&&z<=I/2+U&&(F=!0):V>=A/2-T-U&&V<=A/2+U&&(F=!0)}this.draggingListViewIsScrollbar=F;const D=this.getListViewItemIndexAtPointer(c,s,o);if(D!==null){const R=c.options||{};R.activeItemIndex=D;const X=this.objectStates.get(c.id);X&&X.options&&(X.options.activeItemIndex=D);const k=this.getResolvedListViewItems(c,R)[D],O=typeof k=="string"?k:(k==null?void 0:k.label)||(k==null?void 0:k.value)||D;X&&X.options&&(X.options.selectedValue=O),c.inputId&&this.setInternalInput(c.inputId,O),this.onComponentChange&&(this.onComponentChange({objectId:c.id,componentName:c.name,variant:"listview",property:"activeItemIndex",value:D}),this.onComponentChange({objectId:c.id,componentName:c.name,variant:"listview",property:"selected",value:O}))}}if(c.type==="Component"&&c.variant==="slider"&&t==="down"&&(this.draggingSliderId=c.id,this.updateSliderValueFromPointer(c,s,o)),c.type==="Joystick"||c.type==="Component"&&c.variant==="joystick"){if(t==="down")this.draggingJoystickId=c.id,this.updateJoystickValueFromPointer(c,s,o);else if(t==="up"||t==="blur"){const w=this.objectStates.get(c.id);w&&c.isSpringReturn!==!1&&(w.handleX=0,w.handleY=0),c.isSpringReturn!==!1&&(c.handleX=0,c.handleY=0)}}if((c.type==="Checkbox"||c.type==="Component"&&c.variant==="checkbox")&&t==="down"){const w=this.objectStates.get(c.id),M=(w==null?void 0:w.options)||c.options||{};if(M.disabled)return;M.checked=!M.checked,M.indeterminate&&(M.indeterminate=!1),c.inputId&&this.setInternalInput(c.inputId,M.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"checkbox",property:"checked",value:M.checked}),this.fireEventForObject(c.id,"Click"),this.fireEventForObject(c.id,M.checked?"Checked":"Unchecked")}if(c.type==="Component"&&c.variant==="radiogroup"&&t==="down"){const w=this.objectStates.get(c.id),M=(w==null?void 0:w.options)||c.options||{},I=M.optionsList||[],A=this.getRadioGroupItemIndexAtPointer(c,s,o);if(A!==null&&A>=0&&A<I.length){const _=I[A];M.selectedValue=_,c.inputId&&this.setInternalInput(c.inputId,_),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"radiogroup",property:"selectedValue",value:_}),this.fireEventForObject(c.id,"Click"),this.fireEventForObject(c.id,`Selected: ${_}`)}}if(c.type==="LineGraph"&&(t==="down"||t==="click")){const w=c.geometry,M=(w==null?void 0:w.datasets)||[],I=this.objectStates.get(c.id),A=(I==null?void 0:I.width)||(w==null?void 0:w.width)||200,_=(I==null?void 0:I.height)||(w==null?void 0:w.height)||150,T=this.getWorldTransform(c.id),L=30,F=20,D=A-L,R=_-F;let X=1;M.forEach(O=>{const E=Math.max(...O.data||[0]);E>X&&(X=E)});let P=1/0,k=null;M.forEach((O,E)=>{const N=O.data||[],W=D/Math.max(N.length-1,1);N.forEach((B,G)=>{const z=T.x-A/2+L+G*W,V=T.y+_/2-F-B/X*R,U=Math.sqrt((s-z)**2+(o-V)**2);U<P&&(P=U,k={dIdx:E,pIdx:G,val:B,label:O.label||`Dataset ${E+1}`})})}),k&&P<20&&this.onGraphPointClick&&this.onGraphPointClick({objectId:c.id,componentName:c.name,datasetIndex:k.dIdx,pointIndex:k.pIdx,value:k.val,label:k.label}),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"linegraph",property:"click",value:(k==null?void 0:k.val)??null})}if((c==null?void 0:c.type)==="InputBox"||(c==null?void 0:c.type)==="Component"&&(c.variant==="inputbox"||c.name==="InputBox")){if(t==="down"||t==="click"){const w=this.focusedId;if(this.focusedId=c.id,this.log(`[Engine] Focus set to: ${c.id}`),w!==this.focusedId){if(w){const G=(u=this.artboard)==null?void 0:u.objects.find(z=>z.id===w);G&&this.onInputBlur&&this.onInputBlur(G.name)}this.onInputFocus&&this.onInputFocus(c.name)}const M=this.objectStates.get(c.id),I=(M==null?void 0:M.options)||c.options||{},A=c.geometry||{},_=(M==null?void 0:M.width)||(A==null?void 0:A.width)||250,T=(M==null?void 0:M.height)||(A==null?void 0:A.height)||45,L=this.getWorldTransform(c.id),F=-L.rotation*(Math.PI/180),D=Math.cos(F),R=Math.sin(F),X=s-L.x,P=o-L.y,k=(X*D-P*R)/(L.scaleX||1),O=(X*R+P*D)/(L.scaleY||1);if(I.inputType==="number"&&((g=I.number)==null?void 0:g.showSteppers)!==!1){const z=_/2-4,V=z-24;if(k>=V&&k<=z&&Math.abs(O)<=T/2){const U=Number(((p=I.number)==null?void 0:p.step)??1),q=((f=I.number)==null?void 0:f.min)!==void 0?Number(I.number.min):-1/0,Y=((h=I.number)==null?void 0:h.max)!==void 0?Number(I.number.max):1/0;let H=parseFloat(I.text??I.value??"0");isNaN(H)&&(H=0),O<0?H=Math.min(Y,H+U):H=Math.max(q,H-U);const x=String(H);I.text=x,I.value=x,c.options&&(c.options.text=x,c.options.value=x),M&&M.options&&(M.options.text=x,M.options.value=x),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"inputbox",property:"value",value:x}),this.onInputChange&&this.onInputChange(c.name,x),this.onInputUpdate&&this.onInputUpdate(c.id,x);return}}const E=I.rightIcon||{},N=I.inputType==="password",W=E.mode==="clear"||I.inputType==="search"&&(I.text||I.value),B=E.mode==="password-toggle"||N&&E.visible!==!1;if(E.visible||B||W){const G=E.offset??16,z=E.size??16,V=_/2-G;if(Math.abs(k-V)<=z&&Math.abs(O)<=T/2){if(B){I.passwordVisible=!I.passwordVisible,M&&M.options&&(M.options.passwordVisible=I.passwordVisible),c.options&&(c.options.passwordVisible=I.passwordVisible);return}else if(W){I.text="",I.value="",M&&M.options&&(M.options.text="",M.options.value=""),c.options&&(c.options.text="",c.options.value=""),this.onInputChange&&this.onInputChange(c.name,""),this.onInputUpdate&&this.onInputUpdate(c.id,"");return}}}}}else if((t==="click"||t==="down")&&this.focusedId){const w=this.focusedId;this.focusedId=null;const M=(S=this.artboard)==null?void 0:S.objects.find(I=>I.id===w);M&&this.onInputBlur&&this.onInputBlur(M.name)}}else if(t==="click"||t==="down"){const c=this.focusedId;if(this.focusedId=null,c){const v=(y=this.artboard)==null?void 0:y.objects.find(m=>m.id===c);v&&this.onInputBlur&&this.onInputBlur(v.name)}}}handleKeyDown(t){var l,d,u,g;if(!this.artboard||(this.activeKeys.add(t.key.toLowerCase()),this.activeKeys.add(t.code),!this.focusedId))return;const s=this.artboard.objects.find(p=>p.id===this.focusedId),o=(s==null?void 0:s.type)==="InputBox"||(s==null?void 0:s.type)==="Component"&&(s.variant==="inputbox"||s.name==="InputBox");if(!s||!o)return;const e=this.objectStates.get(s.id),n=(e==null?void 0:e.options)||s.options||{};let i=String(n.text??n.value??"");const a=n.inputType==="textarea"||n.multiline===!0;if(t.key==="Backspace")i=i.slice(0,-1),t.preventDefault();else if(t.key==="Escape"){this.focusedId=null,this.onInputBlur&&this.onInputBlur(s.name);return}else if(t.key==="Enter")if(a)i+=`
7
- `,t.preventDefault();else{this.focusedId=null,this.onInputBlur&&this.onInputBlur(s.name);return}else if(t.key==="ArrowUp"&&n.inputType==="number"){const p=Number(((l=n.number)==null?void 0:l.step)??1),f=((d=n.number)==null?void 0:d.max)!==void 0?Number(n.number.max):1/0;let h=parseFloat(i)||0;h=Math.min(f,h+p),i=String(h),t.preventDefault()}else if(t.key==="ArrowDown"&&n.inputType==="number"){const p=Number(((u=n.number)==null?void 0:u.step)??1),f=((g=n.number)==null?void 0:g.min)!==void 0?Number(n.number.min):-1/0;let h=parseFloat(i)||0;h=Math.max(f,h-p),i=String(h),t.preventDefault()}else if(t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey){if(n.maxLength>0&&i.length>=n.maxLength||n.inputType==="number"&&(!/[\d.\-]/.test(t.key)||t.key==="-"&&i.includes("-")||t.key==="."&&i.includes(".")))return;i+=t.key,t.preventDefault()}else return;n.text=i,n.value=i,s.options&&(s.options.text=i,s.options.value=i),e&&e.options&&(e.options.text=i,e.options.value=i);const r=s.geometry;r!=null&&r.textInputId&&this.updateInput(r.textInputId,i),this.onComponentChange&&(this.onComponentChange({objectId:s.id,componentName:s.name,variant:"inputbox",property:"text",value:i}),this.onComponentChange({objectId:s.id,componentName:s.name,variant:"inputbox",property:"value",value:i})),this.onInputChange&&this.onInputChange(s.name,i),this.onInputUpdate&&this.onInputUpdate(this.focusedId,i)}handleKeyUp(t){this.artboard&&(this.activeKeys.delete(t.key.toLowerCase()),this.activeKeys.delete(t.code))}hasDragInteraction(t){return t?(t.interactions||[]).some(o=>{const e=o.triggers||[o.event||o.trigger];return Array.isArray(e)&&e.some(n=>String(n).toLowerCase()==="drag")}):!1}fireEventForObject(t,s){var d,u,g,p,f;const o=(d=this.artboard)==null?void 0:d.objects.find(h=>h.id===t);if(!o)return;const e=new Set([s,s.toLowerCase()]),n=s.toLowerCase();n==="onclick"||n==="click"||n==="onpointerdown"||n==="pointerdown"?this.fireAnalyticsEvent(t,"click"):(n==="onpointerenter"||n==="hover"||n==="move")&&this.fireAnalyticsEvent(t,"hover"),n==="onclick"||n==="click"?(e.add("click"),e.add("onclick")):n==="onpointerdown"||n==="pointerdown"?(e.add("pointerdown"),e.add("onpointerdown")):n==="onpointerup"||n==="pointerup"?(e.add("pointerup"),e.add("onpointerup")):n==="onpointerenter"||n==="hover"||n==="move"?(e.add("hover"),e.add("onpointerenter")):n==="onpointerleave"||n==="blur"?(e.add("onpointerleave"),e.add("blur")):n==="drag"||n==="ondrag"?(e.add("drag"),e.add("ondrag")):n==="toggle"||n==="ontoggle"?(e.add("toggle"),e.add("ontoggle")):n==="toggle true"||n==="toggle_true"||n==="toggletrue"?(e.add("toggle true"),e.add("toggle_true"),e.add("toggletrue")):(n==="toggle false"||n==="toggle_false"||n==="togglefalse")&&(e.add("toggle false"),e.add("toggle_false"),e.add("togglefalse"));const a=(o.interactions||[]).find(h=>{const S=h.triggers||[h.event||h.trigger||"click"];return((h.triggerLogic||"OR")==="AND"?S.every(v=>e.has(v.toLowerCase())):S.some(v=>e.has(v.toLowerCase())))?h.conditions&&h.conditions.length>0?this.checkConditions(h.conditions):!0:!1});if(a){if(this.log(`[Engine] Interaction matched: ${s} -> Action: ${a.action}`),a.action==="setInput"||a.action==="Set Input"){let h=a.value||a.inputValue;h==="toggle"&&(h=!this.inputs.get(a.targetInputId)),this.updateInput(a.targetInputId,h)}else if(a.action==="Toggle Boolean"){const h=a.targetInputId;if(h&&this.inputs.has(h)){const c=this.inputs.get(h);this.updateInput(h,!c)}const S=this.objectStates.get(o.id),y=(S==null?void 0:S.options)||o.options;y&&typeof y.checked=="boolean"&&(y.checked=!y.checked,y.indeterminate&&(y.indeterminate=!1),this.onComponentChange&&this.onComponentChange({objectId:o.id,componentName:o.name,variant:"checkbox",property:"checked",value:y.checked}))}else if(a.action==="fireTrigger")this.updateInput(a.targetInputId,!0);else if(a.action==="setProperty"){const h=a.targetObjectId||o.id,S=a.targetProperty;S&&this.updateObjectProperty(h,S,a.value)}else if(a.action==="Navigate Artboard"||a.action==="navigate")this.onNavigation&&this.onNavigation({type:"artboard",value:a.targetArtboard||a.value});else if(a.action==="Navigate URL")this.onNavigation&&this.onNavigation({type:"url",value:a.navigateUrl});else if(a.action==="Play Animation"){const h=a.targetAnimationId,S=!a.playMode||a.playMode==="all"?void 0:a.subAnimationIds;h==="__all__"?(g=(u=this.artboard)==null?void 0:u.animations)==null||g.forEach(y=>{this.triggerGlobalAnimation(y.id,S)}):h&&this.triggerGlobalAnimation(h,S)}else if(a.action==="setState"||a.action==="Set State"){const h=a.targetObjectId||o.id,y={...this.objectStates.get(h)||{},...a.value||{}};this.objectStates.set(h,y),this.log(`[Engine] State updated for ${h}:`,y)}else if(a.action==="Stop Animation"||a.action==="Pause Animation"){const h=a.targetAnimationId;h==="__all__"?this.layerStates.forEach((S,y)=>{y.startsWith("global_")&&this.layerStates.delete(y)}):h&&this.layerStates.forEach((S,y)=>{y.startsWith(`global_${h}_`)&&this.layerStates.delete(y)})}else if(a.action==="Switch to State"&&this.activeStateMachine){const h=a.targetState,S=this.activeStateMachine.layers.find(y=>y.states.some(c=>c.id===h||c.name===h));S&&(this.log(`[Engine] Switching Layer ${S.name} to State ${h}`),this.enterStates(S.name,[h]))}this.onTrigger&&this.onTrigger(s,a.action)}const l=(o.triggers||[]).find(h=>{const S=h.eventType.toLowerCase();let y=!1;return(e.has(S)||S==="click"&&e.has("onclick")||S==="hover"&&(e.has("onpointerenter")||e.has("hover"))||S==="pointerdown"&&e.has("onpointerdown")||S==="pointerup"&&e.has("onpointerup"))&&(y=!0),y&&h.conditions&&h.conditions.length>0?this.checkConditions(h.conditions):y});if(l&&l.entryAnimationId){this.log(`[Engine] Trigger matched: ${s} (as ${l.eventType}) -> Animation ${l.entryAnimationId}`);const h=(f=(p=this.artboard)==null?void 0:p.animations)==null?void 0:f.find(S=>S.id===l.entryAnimationId);h&&(this.activeTriggers.set(o.id,{triggerId:l.id,animation:h,time:0,phase:"entry",elapsedHold:0,filterObjectId:l.targetObjectId}),this.onTrigger&&this.onTrigger(l.name,h.name))}}fireAnalyticsEvent(t,s){var r,l;const o=(r=this.artboard)==null?void 0:r.objects.find(d=>d.id===t);if(!o)return;const e=(l=o.style)==null?void 0:l.analytics;if(!e||!e.isEnabled||e.triggerType!==s)return;const n=e.eventName||`${o.name.toLowerCase().replace(/\s+/g,"_")}_interacted`,i={};e.parameters&&Array.isArray(e.parameters)&&e.parameters.forEach(d=>{if(d.type==="literal")i[d.key]=d.value;else if(d.type==="variable"){const u=this.inputs.get(d.value);i[d.key]=u!==void 0?u:""}}),this.log(`[ExodeUI Analytics] Dispatching event "${n}" via ${s} trigger:`,i);const a=e.platforms||{ga4:!0,meta:!0,mixpanel:!1};if(a.ga4){const d=window;typeof d.gtag=="function"?(d.gtag("event",n,i),this.log(`[ExodeUI Analytics] GA4: Event "${n}" sent successfully.`)):this.warn(`[ExodeUI Analytics] GA4: window.gtag is not a function. Event "${n}" skipped.`)}if(a.meta){const d=window;typeof d.fbq=="function"?(d.fbq("track",n,i),this.log(`[ExodeUI Analytics] Meta Pixel: Event "${n}" sent successfully.`)):this.warn(`[ExodeUI Analytics] Meta Pixel: window.fbq is not a function. Event "${n}" skipped.`)}if(a.mixpanel){const d=window;d.mixpanel&&typeof d.mixpanel.track=="function"?(d.mixpanel.track(n,i),this.log(`[ExodeUI Analytics] Mixpanel: Event "${n}" sent successfully.`)):this.warn(`[ExodeUI Analytics] Mixpanel: window.mixpanel.track is not a function. Event "${n}" skipped.`)}}getAnimationDuration(t){var o;if(!t)return 0;let s=t.duration||0;return s<=0&&((o=t.tracks)==null||o.forEach(e=>{var n;(n=e.keyframes)==null||n.forEach(i=>{i.time>s&&(s=i.time)})})),s>0?s:1}initGlobalAnimationTriggers(){if(!this.artboard)return;const t=this.artboard.animationFlow||[];let s=!1;t.forEach(o=>{if((o.trigger==="on_load"||o.trigger==="after_delay")&&o.targetAnimationId){s=!0;const e=o.delay||0;e<=0?this.triggerGlobalAnimation(o.targetAnimationId,o.subAnimationIds,o.loop,o.id):setTimeout(()=>this.triggerGlobalAnimation(o.targetAnimationId,o.subAnimationIds,o.loop,o.id),e)}}),!s&&this.artboard.startupAnimationId&&this.triggerGlobalAnimation(this.artboard.startupAnimationId,this.artboard.startupSubAnimationIds)}triggerGlobalAnimation(t,s,o=!1,e){var r;if(!this.artboard)return;const n=this.artboard.animations.find(l=>l.id===t);if(!n)return;let i=this.getAnimationDuration(n);const a=`global_${t}_${Math.random().toString(36).substr(2,5)}`;this.layerStates.set(a,{currentStateIds:[t],animations:[{animation:n,state:{loop:o},filterObjectIds:s}],time:0,duration:i,ruleId:e}),console.log(`[Engine] Triggered global animation: ${n.name} (AnimID: ${t}, RuleID: ${e}, Loop: ${o}, StoredDuration: ${i}, anim.duration: ${n.duration}, Tracks: ${((r=n.tracks)==null?void 0:r.length)||0})`),this.debugLog(`[Engine] Triggered global animation: ${n.name} (Loop: ${o}, Sub-Anims: ${(s==null?void 0:s.length)||"All"})`)}handleAnimationFinished(t,s){if(!this.artboard)return;console.log(`[Engine] Animation finished! AnimID: ${t}, RuleID: ${s}`);const o=this.artboard.animationFlow||[];o.forEach((e,n)=>{if(e.trigger==="after_anim"&&e.targetAnimationId){let i=e.afterAnim;!i&&n>0&&(i=o[n-1].id);const a=i===t||s&&i===s;if(console.log(`[Engine] Checking rule ${e.id} (Trigger: ${e.trigger}). ExpectedParent: ${i}. isMatch? ${a}`),a){const r=e.delay||0;console.log(`[Engine] Match found! Triggering target animation: ${e.targetAnimationId} after delay: ${r}`),r<=0?this.triggerGlobalAnimation(e.targetAnimationId,e.subAnimationIds,e.loop,e.id):setTimeout(()=>this.triggerGlobalAnimation(e.targetAnimationId,e.subAnimationIds,e.loop,e.id),r)}}})}getWorldTransform(t){var g;const s=this.objectStates.get(t);if(!s)return{x:0,y:0,scaleX:1,scaleY:1,rotation:0};const o=(g=this.artboard)==null?void 0:g.objects.find(p=>p.id===t);if(!o||!o.parentId)return{x:s.x,y:s.y,scaleX:s.scale_x??1,scaleY:s.scale_y??1,rotation:s.rotation??0};const e=this.getWorldTransform(o.parentId),n=e.rotation*(Math.PI/180),i=Math.cos(n),a=Math.sin(n),r=s.x*e.scaleX,l=s.y*e.scaleY,d=e.x+(r*i-l*a),u=e.y+(r*a+l*i);return{x:d,y:u,scaleX:(s.scale_x??1)*e.scaleX,scaleY:(s.scale_y??1)*e.scaleY,rotation:e.rotation+(s.rotation??0)}}hitTest(t,s,o){var v,m;if(!this.objectStates.get(t.id))return!1;const n=((v=t.geometry)==null?void 0:v.width)??t.width??100,i=((m=t.geometry)==null?void 0:m.height)??t.height??100,a=this.getWorldTransform(t.id),r=s-a.x,l=o-a.y,d=-a.rotation*(Math.PI/180),u=Math.cos(d),g=Math.sin(d),p=r*u-l*g,f=r*g+l*u,h=a.scaleX,S=a.scaleY,y=n*Math.abs(h),c=i*Math.abs(S);return Math.abs(p)<=y/2&&Math.abs(f)<=c/2}updateSliderValueFromPointer(t,s,o){var M;const e=this.objectStates.get(t.id);if(!e)return;const n=t.options||{},i=((M=t.geometry)==null?void 0:M.width)??t.width??200,a=this.getWorldTransform(t.id),r=s-a.x,l=o-a.y,d=-a.rotation*(Math.PI/180),u=Math.cos(d),g=Math.sin(d),p=r*u-l*g,f=n.thumbWidth??16,h=i-f;let y=(p+h/2)/h;y=Math.max(0,Math.min(1,y));const c=n.min??0,v=n.max??100,m=n.step||1;let C=c+y*(v-c);m>0&&(C=Math.round(C/m)*m),C=Math.max(c,Math.min(v,C));const w=e.options||{};w.value!==C&&(e.options={...w,value:C},t.inputId&&this.setInternalInput(t.inputId,C),this.onComponentChange&&this.onComponentChange({objectId:t.id,componentName:t.name,variant:"slider",property:"value",value:C}))}updateJoystickValueFromPointer(t,s,o){var M,I;const e=this.objectStates.get(t.id);if(!e)return;const n=(e==null?void 0:e.width)!==void 0?e.width:((M=t.geometry)==null?void 0:M.width)??t.width??100,i=(e==null?void 0:e.height)!==void 0?e.height:((I=t.geometry)==null?void 0:I.height)??t.height??100,a=this.getWorldTransform(t.id),r=s-a.x,l=o-a.y,d=-a.rotation*(Math.PI/180),u=Math.cos(d),g=Math.sin(d);let p=(r*u-l*g)/Math.max(.001,Math.abs(a.scaleX||1)),f=(r*g+l*u)/Math.max(.001,Math.abs(a.scaleY||1));t.handleOrigin==="top-left"?(p-=n/2,f-=i/2):t.handleOrigin==="bottom-right"&&(p+=n/2,f+=i/2);const h=Math.min(n,i)*.45,S=Math.min(n,i)*.15,y=h-S;let c=p/y,v=f/y;const m=Math.sqrt(c*c+v*v);t.boundsShape==="square"?(c=Math.max(-1,Math.min(1,c)),v=Math.max(-1,Math.min(1,v))):m>1&&(c/=m,v/=m),t.deadzone!==void 0&&m<t.deadzone?(c=0,v=0):(t.stepX!==void 0&&t.stepX>0&&(c=Math.round(c/t.stepX)*t.stepX),t.stepY!==void 0&&t.stepY>0&&(v=Math.round(v/t.stepY)*t.stepY)),t.joystickType==="1D_X"?v=0:t.joystickType==="1D_Y"&&(c=0);const C=e.handleX,w=e.handleY;(C!==c||w!==v)&&(e.handleX=c,e.handleY=v,t.handleX=c,t.handleY=v)}processJoysticks(t){this.artboard&&(this.artboard.objects.forEach(s=>{var l,d,u,g;if(s.type!=="Joystick"&&!(s.type==="Component"&&s.variant==="joystick"))return;const o=s,e=this.objectStates.get(o.id);if(!e)return;let n=e.handleX??o.handleX??0,i=e.handleY??o.handleY??0;const r=(o.globalInput??!1)||this.lastHoveredObjectId===o.id;if(r&&((l=o.inputBinding)==null?void 0:l.type)==="keyboard"&&o.inputBinding.keyboardConfig){const p=o.inputBinding.keyboardConfig;let f=n,h=i;const y=(p.speed||5)*t;let c=!1;this.activeKeys.has(p.upKey.toLowerCase())&&(h-=y,c=!0),this.activeKeys.has(p.downKey.toLowerCase())&&(h+=y,c=!0),this.activeKeys.has(p.leftKey.toLowerCase())&&(f-=y,c=!0),this.activeKeys.has(p.rightKey.toLowerCase())&&(f+=y,c=!0),o.joystickType==="1D_X"&&(h=0),o.joystickType==="1D_Y"&&(f=0);const v=Math.sqrt(f*f+h*h);v>1&&(f/=v,h/=v),!c&&o.isSpringReturn!==!1&&(f+=(0-f)*(10*t),h+=(0-h)*(10*t),Math.abs(f)<.01&&(f=0),Math.abs(h)<.01&&(h=0)),n=f,i=h}else if(r&&((d=o.inputBinding)==null?void 0:d.type)==="mouse"&&o.inputBinding.mouseConfig){const p=o.inputBinding.mouseConfig;let f=e._mouseTargetX??n,h=e._mouseTargetY??i;const S=p.sensitivity||.01;if(p.mode==="absolute"){const v=((u=this.artboard)==null?void 0:u.width)||window.innerWidth,m=((g=this.artboard)==null?void 0:g.height)||window.innerHeight,C=this.inputs.get("mouseX")||0,w=this.inputs.get("mouseY")||0;p.axisX&&(f=C/v*2-1),p.axisY&&(h=w/m*2-1)}else p.axisX&&(f+=this._mouseDelta.dx*S),p.axisY&&(h+=this._mouseDelta.dy*S);o.joystickType==="1D_X"&&(h=0),o.joystickType==="1D_Y"&&(f=0);const y=Math.sqrt(f*f+h*h);y>1&&(f/=y,h/=y),o.isSpringReturn!==!1&&(f+=(0-f)*(5*t),h+=(0-h)*(5*t),Math.abs(f)<.01&&(f=0),Math.abs(h)<.01&&(h=0)),e._mouseTargetX=f,e._mouseTargetY=h;const c=15*t;n+=(f-n)*Math.min(c,1),i+=(h-i)*Math.min(c,1)}if(e.handleX=n,e.handleY=i,o.handleX=n,o.handleY=i,o.bindings&&o.bindings.length>0){const p=Math.sqrt(n*n+i*i);let f=Math.atan2(i,n)*(180/Math.PI);f<0&&(f+=360),o.bindings.forEach(h=>{var c,v,m,C,w,M,I,A;let S=0;h.sourceAxis==="x"?S=o.invertX?-n:n:h.sourceAxis==="y"?S=o.invertY?-i:i:h.sourceAxis==="distance"?S=p:h.sourceAxis==="angle"&&(S=f);const y=(c=this.artboard)==null?void 0:c.objects.find(_=>_.id===h.targetObjectId);if(y){if(h.actionType==="bind"&&h.targetProperty&&h.isContinuous!==!1){const _=h.sourceMin??-1,T=h.sourceMax??1,L=h.targetMin??0,F=h.targetMax??100;let D=!!h.isContinuous,R=0,X=0;if(D){if((h.sourceAxis==="x"||h.sourceAxis==="y")&&L>=0){const k=Math.max(Math.abs(_),Math.abs(T))||1;X=S/k*F}else{let k=(S-_)/(T-_);k=Math.max(0,Math.min(1,k)),X=L+k*(F-L)}Math.abs(S)<.05&&(X=0)}else{const k=(S-_)/(T-_),O=Math.max(0,Math.min(1,k));R=L+O*(F-L),h.step&&h.step>0&&(R=Math.round(R/h.step)*h.step)}const P=this.objectStates.get(y.id);if(P){const k=h.isRelative!==!1,O=k?((v=y.transform)==null?void 0:v.x)??0:0,E=k?((m=y.transform)==null?void 0:m.y)??0:0,N=k?((C=y.transform)==null?void 0:C.rotation)??0:0,W=k?((w=y.transform)==null?void 0:w.scale_x)??1:0,B=k?((M=y.transform)==null?void 0:M.scale_y)??1:0,G=k?((I=y.style)==null?void 0:I.opacity)??100:0,z=Math.min(t*60,3),V=(U,q)=>{let Y=R;if(D){const H=`_internal_${U}_${h.id}`;let x=P[H];x===void 0&&(x=P[U]??q),Y=x+X*z,P[H]=Y,h.step&&h.step>0&&(Y=Math.round(Y/h.step)*h.step)}else{Y=q+R;const H=`_internal_smooth_${U}_${h.id}`;let x=P[H];if(x===void 0)x=Y;else{const dt=Math.min(15*t,1);x+=(Y-x)*dt}P[H]=x,Y=x}P[U]=Y};h.targetProperty==="x"||h.targetProperty==="transform.x"?V("x",O):h.targetProperty==="y"||h.targetProperty==="transform.y"?V("y",E):h.targetProperty==="rotation"||h.targetProperty==="r"||h.targetProperty==="transform.rotation"?V("rotation",N):h.targetProperty==="scaleX"||h.targetProperty==="transform.scale_x"?V("scale_x",W):h.targetProperty==="scaleY"||h.targetProperty==="transform.scale_y"?V("scale_y",B):(h.targetProperty==="opacity"||h.targetProperty==="transform.opacity")&&V("opacity",G)}(A=y.physics)!=null&&A.enabled&&this.physicsEngine&&(h.targetProperty==="x"||h.targetProperty==="transform.x"||h.targetProperty==="y"||h.targetProperty==="transform.y")&&(h.targetProperty==="x"||h.targetProperty==="transform.x"?this.physicsEngine.applyForce(y.id,(R-((P==null?void 0:P.x)||0))*10,0):(h.targetProperty==="y"||h.targetProperty==="transform.y")&&this.physicsEngine.applyForce(y.id,0,(R-((P==null?void 0:P.y)||0))*10))}else if(h.actionType==="playAnimation"||h.actionType==="stopAnimation"||h.actionType==="pauseAnimation"){let _=!1;const T=h.threshold??0;h.condition==="always"?_=!0:h.condition===">"?_=S>T:h.condition==="<"?_=S<T:h.condition==="=="&&(_=Math.abs(S-T)<.01);const L=e[`_prev_src_${h.id}`]??S;let F=!1;h.condition==="always"?F=!0:h.condition===">"?F=L>T:h.condition==="<"?F=L<T:h.condition==="=="&&(F=Math.abs(L-T)<.01),e[`_prev_src_${h.id}`]=S,_&&!F&&h.targetAnimationId&&(h.actionType==="playAnimation"||h.actionType)}}})}}),this._mouseDelta.dx=0,this._mouseDelta.dy=0)}applyBlendState(t,s){var l,d,u,g,p,f,h,S;if(!t.blendAnimations||t.blendAnimations.length===0)return;let o=0,e=0;t.blendInputX&&(o=this.inputs.get(t.blendInputX)??0),t.blendInputY&&(e=this.inputs.get(t.blendInputY)??0);const n=[];let i=0;if(t.blendType==="1D"){const y=[...t.blendAnimations].sort((c,v)=>c.position[0]-v.position[0]);if(y.length===1){const c=(d=(l=this.artboard)==null?void 0:l.animations)==null?void 0:d.find(v=>v.id===y[0].animationId);c&&(n.push({anim:c,weight:1}),i=1)}else{let c=0;for(;c<y.length-1&&y[c+1].position[0]<o;)c++;if(c===y.length-1&&o>y[c].position[0]){const v=(g=(u=this.artboard)==null?void 0:u.animations)==null?void 0:g.find(m=>m.id===y[c].animationId);v&&(n.push({anim:v,weight:1}),i=1)}else{const v=y[c].position[0],m=y[c+1].position[0],C=(f=(p=this.artboard)==null?void 0:p.animations)==null?void 0:f.find(_=>_.id===y[c].animationId),w=(S=(h=this.artboard)==null?void 0:h.animations)==null?void 0:S.find(_=>_.id===y[c+1].animationId),M=Math.max(.001,m-v);let I=(o-v)/M;I=Math.max(0,Math.min(1,I));const A=1-I;C&&(n.push({anim:C,weight:A}),i+=A),w&&(n.push({anim:w,weight:I}),i+=I)}}}else t.blendAnimations.forEach(y=>{var w,M;const c=(M=(w=this.artboard)==null?void 0:w.animations)==null?void 0:M.find(I=>I.id===y.animationId);if(!c)return;const v=y.position[0]-o,m=y.position[1]-e,C=v*v+m*m;if(C<1e-4)n.push({anim:c,weight:1e4}),i+=1e4;else{const I=1/C;n.push({anim:c,weight:I}),i+=I}});if(i===0)return;n.forEach(y=>y.weight/=i);const a=new Map,r=y=>{let c=y.startsWith("#")?y.substring(1):y;return c.length===3&&(c=[c[0],c[0],c[1],c[1],c[2],c[2]].join("")),c="0x"+c,{r:c>>16&255,g:c>>8&255,b:c&255,a:1}};n.forEach(({anim:y,weight:c})=>{y.tracks&&y.tracks.forEach(v=>{var T,L;const m=v.object_id||v.objectId,C=v.property,w=(T=this.artboard)==null?void 0:T.objects.find(F=>F.id===m);if(((L=w==null?void 0:w.physics)==null?void 0:L.enabled)&&w.physics.bodyType!=="Static"&&(C==="x"||C==="y"||C==="rotation"))return;const I=this.interpolate(v.keyframes,s);if(I===void 0)return;let A=a.get(m);A||(A=new Map,a.set(m,A));let _=A.get(C);if(!_){if(typeof I=="number")_={type:"number",value:0};else if(typeof I=="string"&&I.startsWith("#"))_={type:"color",value:I,colorAcc:{r:0,g:0,b:0,a:0}};else if(_={type:"number",value:I},c<.5)return;A.set(C,_)}if(_.type==="number"&&typeof I=="number")_.value+=I*c;else if(_.type==="color"&&typeof I=="string"&&_.colorAcc){const F=r(I);F&&(_.colorAcc.r+=F.r*c,_.colorAcc.g+=F.g*c,_.colorAcc.b+=F.b*c,_.colorAcc.a+=F.a*c)}else c>.5&&(_.value=I)})}),a.forEach((y,c)=>{var C;const v=this.objectStates.get(c),m=(C=this.artboard)==null?void 0:C.objects.find(w=>w.id===c);!v||!m||y.forEach((w,M)=>{let I=w.value;if(w.type==="color"&&w.colorAcc){const A=Math.round(w.colorAcc.r).toString(16).padStart(2,"0"),_=Math.round(w.colorAcc.g).toString(16).padStart(2,"0"),T=Math.round(w.colorAcc.b).toString(16).padStart(2,"0");I=`#${A}${_}${T}`}if(M.includes(".")||M.includes("[")){const A=(M||"").replace(/\[(\d+)\]/g,".$1").split(".");let _=v;for(let T=0;T<A.length-1;T++){if(typeof _[A[T]]!="object"||_[A[T]]===null){let L=m;for(let F=0;F<=T;F++)L=L?L[A[F]]:null;if(A[T]==="corner_radius"||A[T]==="cornerRadius"){const F=typeof _[A[T]]=="number"?_[A[T]]:typeof L=="number"?L:0;_[A[T]]={tl:F,tr:F,bl:F,br:F}}else{const F=A[T+1],D=!isNaN(Number(F));_[A[T]]=L?JSON.parse(JSON.stringify(L)):D?[]:{}}}_=_[A[T]]}_[A[A.length-1]]=I,A[A.length-1]==="color"&&(A[A.length-2]==="fill"||A[A.length-2]==="stroke")&&(_.type="Solid")}else M==="fill"?(v.style||(v.style={}),v.style.fill=I):M==="stroke"?(v.style||(v.style={}),v.style.stroke=I):v[M]=I})})}applyAnimation(t,s,o){!t||!t.tracks||t.tracks.forEach(e=>{var u,g,p;const n=e.object_id||e.objectId;if(o){if(Array.isArray(o)){if(!o.includes(n))return}else if(n!==o)return}const i=(u=this.artboard)==null?void 0:u.objects.find(f=>f.id===n),a=((g=i==null?void 0:i.physics)==null?void 0:g.enabled)&&i.physics.bodyType!=="Static";let r=e.property;if(a&&(r==="x"||r==="y"||r==="rotation"))return;const l=this.objectStates.get(n);if(!l){this.frameCount%600===0&&this.debugLog(`Skipping track: Object ${n} not found in state`);return}const d=this.interpolate(e.keyframes,s);if(d!==void 0){if(this.frameCount%240===0){const f=(i==null?void 0:i.name)||n,h=typeof d=="object"?JSON.stringify(d).slice(0,50):d;this.debugLog(`[Anim] Applying ${r} = ${h} to ${f}`)}if(r.includes(".")||r.includes("[")){const f=(r||"").replace(/\[(\d+)\]/g,".$1").split(".");let h=l;for(let S=0;S<f.length-1;S++){if(typeof h[f[S]]!="object"||h[f[S]]===null){let y=i;for(let c=0;c<=S;c++)y=y?y[f[c]]:null;if(f[S]==="corner_radius"||f[S]==="cornerRadius"){let c=0,v=0,m=0,C=0;const w=h[f[S]]??y;typeof w=="number"?c=v=m=C=w:Array.isArray(w)?w.length===1?c=v=m=C=w[0]:w.length===2?(c=m=w[0],v=C=w[1]):w.length===3?(c=w[0],v=C=w[1],m=w[2]):w.length>=4&&(c=w[0],v=w[1],m=w[2],C=w[3]):w&&typeof w=="object"&&(c=w[0]??w.tl??w.corner_radius??w.cornerRadius??0,v=w[1]??w.tr??w.corner_radius??w.cornerRadius??0,m=w[2]??w.br??w.corner_radius??w.cornerRadius??0,C=w[3]??w.bl??w.corner_radius??w.cornerRadius??0),h[f[S]]={tl:c,tr:v,bl:C,br:m,0:c,1:v,2:m,3:C}}else{const c=f[S+1],v=!isNaN(Number(c));h[f[S]]=y?JSON.parse(JSON.stringify(y)):v?[]:{}}}h=h[f[S]]}h[f[f.length-1]]=d,f[f.length-1]==="color"&&(f[f.length-2]==="fill"||f[f.length-2]==="stroke")&&(h.type="Solid")}else r==="fill"?(l.style||(l.style={}),l.style.fill=d):r==="stroke"?(l.style||(l.style={}),l.style.stroke=d):l[r]=d;if(this.physicsEngine&&((p=i==null?void 0:i.physics)!=null&&p.enabled)&&i.physics.bodyType==="Static")if(r==="x"){const f=this.physicsEngine.getPosition(n);f&&this.physicsEngine.setPosition(n,d,f.y)}else if(r==="y"){const f=this.physicsEngine.getPosition(n);f&&this.physicsEngine.setPosition(n,f.x,d)}else r==="rotation"&&this.physicsEngine.setRotation(n,d*(Math.PI/180))}})}interpolate(t,s){if(t.length===0)return;let o=t[0],e=t[t.length-1];if(s<=o.time)return o.value;if(s>=e.time)return e.value;for(let a=0;a<t.length-1;a++)if(s>=t[a].time&&s<t[a+1].time){o=t[a],e=t[a+1];break}const n=e.time-o.time;let i=(s-o.time)/n;return o.easing&&(i=ii(o.easing)(i)),this.interpolateValue(o.value,e.value,i)}interpolateValue(t,s,o){if(t===void 0)return s;if(s===void 0)return t;if(typeof t=="string"&&typeof s=="string"){if(t.startsWith("#"))return this.interpolateColor(t,s,o);const e=parseFloat(t),n=parseFloat(s);return!isNaN(e)&&!isNaN(n)?Math.round(e+(n-e)*o).toString():o<.5?t:s}if(Array.isArray(t)&&Array.isArray(s))return t.length===s.length?t.map((e,n)=>this.interpolateValue(e,s[n],o)):o<.5?t:s;if(typeof t=="object"&&typeof s=="object"&&t!==null&&s!==null){if(t.width!==void 0&&t.color!==void 0&&typeof t.width=="number")return this.interpolateStroke(t,s,o);if(t.type&&s.type&&(t.type==="Solid"||t.type==="LinearGradient"||t.type==="RadialGradient"||t.type==="Image"))return this.interpolateFill(t,s,o);const e={};return new Set([...Object.keys(t),...Object.keys(s)]).forEach(i=>{e[i]=this.interpolateValue(t[i],s[i],o)}),e}return typeof t=="number"&&typeof s=="number"?t+(s-t)*o:o<.5?t:s}interpolateColor(t,s,o){var f,h;const e=((h=(f=this.artboard)==null?void 0:f.tokens)==null?void 0:h.colors)||{},n=e[t]||t,i=e[s]||s,a=S=>{if(!S)return{r:0,g:0,b:0};const y=S.startsWith("#")?S.replace("#",""):"000000";return y.length===3?{r:parseInt(y[0]+y[0],16),g:parseInt(y[1]+y[1],16),b:parseInt(y[2]+y[2],16)}:{r:parseInt(y.substring(0,2),16),g:parseInt(y.substring(2,4),16),b:parseInt(y.substring(4,6),16)}},r=a(n),l=a(i),d=Math.round(r.r+(l.r-r.r)*o),u=Math.round(r.g+(l.g-r.g)*o),g=Math.round(r.b+(l.b-r.b)*o),p=S=>{const y=Math.max(0,Math.min(255,S)).toString(16);return y.length===1?"0"+y:y};return`#${p(d)}${p(u)}${p(g)}`}interpolateStops(t,s,o){return!t||!s||t.length!==s.length?o<.5?t:s:t.map((e,n)=>{const i=s[n];return{offset:e.offset+(i.offset-e.offset)*o,color:this.interpolateColor(e.color,i.color,o),opacity:(e.opacity??1)+((i.opacity??1)-(e.opacity??1))*o}})}interpolateFill(t,s,o){if(!t||!s||t.type!==s.type)return o<.5?t:s;const e={...t,opacity:(t.opacity??1)+((s.opacity??1)-(t.opacity??1))*o};return t.type==="Solid"?e.color=this.interpolateColor(t.color,s.color,o):(t.type==="LinearGradient"||t.type==="RadialGradient")&&(t.start&&s.start&&(e.start=[t.start[0]+(s.start[0]-t.start[0])*o,t.start[1]+(s.start[1]-t.start[1])*o]),t.end&&s.end&&(e.end=[t.end[0]+(s.end[0]-t.end[0])*o,t.end[1]+(s.end[1]-t.end[1])*o]),t.center&&s.center&&(e.center=[t.center[0]+(s.center[0]-t.center[0])*o,t.center[1]+(s.center[1]-t.center[1])*o]),t.radius!==void 0&&s.radius!==void 0&&(e.radius=t.radius+(s.radius-t.radius)*o),e.stops=this.interpolateStops(t.stops,s.stops,o)),e}interpolateStroke(t,s,o){if(!t||!s)return o<.5?t:s;const e={...t};return e.width=(t.width??0)+((s.width??0)-(t.width??0))*o,e.opacity=(t.opacity??1)+((s.opacity??1)-(t.opacity??1))*o,t.fill&&s.fill?e.fill=this.interpolateFill(t.fill,s.fill,o):t.color&&s.color&&t.color.startsWith("#")&&s.color.startsWith("#")&&(e.color=this.interpolateColor(t.color,s.color,o)),e.trimStart=(t.trimStart??0)+((s.trimStart??0)-(t.trimStart??0))*o,e.trimEnd=(t.trimEnd??1)+((s.trimEnd??1)-(t.trimEnd??1))*o,e.trimOffset=(t.trimOffset??0)+((s.trimOffset??0)-(t.trimOffset??0))*o,e.dashOffset=(t.dashOffset??0)+((s.dashOffset??0)-(t.dashOffset??0))*o,e}render(t,s,o){var u;this.debug_objectsTotal=((u=this.artboard)==null?void 0:u.objects.length)||0,this.debug_objectsRendered=0;const e=performance.now();if(this.canvasWidth=s,this.canvasHeight=o,!this.artboard)return;t.clearRect(0,0,s,o);const n=this.artboard.width,i=this.artboard.height,a=this.calculateTransform(s,o,n,i,this.layout.fit,this.layout.alignment);if(t.save(),t.translate(Math.round(a.tx),Math.round(a.ty)),t.scale(a.scaleX,a.scaleY),this.rootTransform=t.getTransform(),this.artboard.backgroundVisible!==!1&&(t.fillStyle=this.artboard.backgroundColor||"#000000",t.fillRect(0,0,n,i)),this.artboard.backgroundImage){const g=this.artboard.backgroundImage;let p=this.imageCache.get(g);if(p||(p=new Image,p.src=g,this.imageCache.set(g,p)),p.complete&&p.naturalWidth>0){t.save(),t.globalAlpha=this.normalizeOpacity(this.artboard.backgroundOpacity??100);const f=p.naturalWidth/p.naturalHeight,h=n/i;let S,y,c,v;h>f?(S=n,y=n/f):(y=i,S=i*f),c=(n-S)/2,v=(i-y)/2,t.drawImage(p,c,v,S,y),t.restore()}}this.artboard.clipContent!==!1&&this.artboard.clip_content!==!1&&(t.beginPath(),t.rect(0,0,n,i),t.clip());const l=new Map;this.artboard.objects.forEach(g=>l.set(g.id,g)),this.artboard.objects.filter(g=>!g.parentId).map((g,p)=>{const f=this.objectStates.get(g.id),h=(f==null?void 0:f.zIndex)??p;return{obj:g,zIndex:h}}).sort((g,p)=>g.zIndex-p.zIndex).forEach(({obj:g})=>{this.renderObject(t,g,l)}),this._emitterPools.forEach((g,p)=>{if(!(g.length===0||!l.get(p)))for(const h of g)t.save(),t.globalAlpha=h.opacity,t.fillStyle=h.color,t.beginPath(),t.arc(h.x,h.y,Math.max(1,h.size*h.opacity),0,Math.PI*2),t.fill(),t.restore()}),this.lastRenderTime=performance.now()-e,this.debugMode&&this.frameCount%60===0&&this.log(`[Engine Debug] Rendered ${this.debug_objectsRendered}/${this.debug_objectsTotal} objects in ${this.lastRenderTime.toFixed(2)}ms`),t.restore()}isObjectInView(t,s,o,e,n,i=0){const a=t.getTransform(),r=s*a.a+o*a.c+a.e,l=s*a.b+o*a.d+a.f,d=Math.sqrt(a.a*a.a+a.b*a.b),u=Math.sqrt(a.c*a.c+a.d*a.d),g=(e/2+i)*d,p=(n/2+i)*u;return r+g>=0&&r-g<=this.canvasWidth&&l+p>=0&&l-p<=this.canvasHeight}calculateTransform(t,s,o,e,n,i){let a=1,r=1,l=1;const d=o/e,u=t/s;switch(n){case"Contain":u>d?l=s/e:l=t/o,a=r=l;break;case"Cover":u>d?l=t/o:l=s/e,a=r=l;break;case"Fill":a=t/o,r=s/e;break;case"FitWidth":l=t/o,a=r=l;break;case"FitHeight":l=s/e,a=r=l;break;case"None":a=r=1;break;case"ScaleDown":l=Math.min(t/o,s/e),l>1&&(l=1),a=r=l;break;default:a=r=1;break}const g=o*a,p=e*r;let f=0,h=0;return i.includes("Left")?f=0:i.includes("Right")?f=t-g:f=(t-g)/2,i.includes("Top")?h=0:i.includes("Bottom")?h=s-p:h=(s-p)/2,{scaleX:a,scaleY:r,tx:f,ty:h}}mapFontWeight(t){const s=t.toLowerCase();return s==="thin"||s==="100"?"100":s==="extralight"||s==="200"?"200":s==="light"||s==="300"?"300":s==="regular"||s==="normal"||s==="400"?"400":s==="medium"||s==="500"?"500":s==="semibold"||s==="600"?"600":s==="bold"||s==="700"?"700":s==="extrabold"||s==="800"?"800":s==="black"||s==="900"?"900":t}drawTextDecoration(t,s,o,e,n,i){t.beginPath();const a=Math.max(1,i/14);let r=e;s==="underline"?r=e+i*.12:s==="line-through"&&(r=e-i*.3),t.lineWidth=a,t.strokeStyle=t.fillStyle,t.moveTo(o-n/2,r),t.lineTo(o+n/2,r),t.stroke()}renderObject(t,s,o,e=!1,n=!1){var v,m,C,w,M,I,A,_,T,L,F,D,R,X,P,k,O,E,N,W,B,G,z,V,U,q,Y,H,x,dt,_t,vt,Yt,Mt,Wt,Ot;const i=this.objectStates.get(s.id);if(!i){this.warn("No state for object:",s.id);return}this.frameCount%60,t.roundRect||(t.roundRect=(yt,Ft,K,ut,Lt)=>(this.drawRoundRect(t,yt,Ft,K,ut,Lt),t));const a=i.geometry?this.deepMerge(s.geometry,i.geometry):s.geometry;let r=i.style?this.deepMerge(s.style,i.style):s.style,l=(a==null?void 0:a.width)||((v=s.geometry)==null?void 0:v.width)||s.width||0,d=(a==null?void 0:a.height)||((m=s.geometry)==null?void 0:m.height)||s.height||0;if((l===0||d===0)&&(a!=null&&a.points)&&Array.isArray(a.points)&&a.points.length>0){let yt=1/0,Ft=-1/0,K=1/0,ut=-1/0;a.points.forEach(Lt=>{yt=Math.min(yt,Lt.x),Ft=Math.max(Ft,Lt.x),K=Math.min(K,Lt.y),ut=Math.max(ut,Lt.y)}),l===0&&(l=Ft-yt),d===0&&(d=ut-K)}const u=yt=>{if(yt)return yt.corner_radius??yt.cornerRadius},g=u(a)??u(i)??u(r)??u(s.geometry)??u(s.style)??u(s)??0;let p={...a,width:l,height:d};if(delete p.cornerRadius,p.corner_radius=g,!p.type&&(s.type==="Frame"||s.type==="Component"||s.type==="Group")&&(p.type="Rectangle"),s.type==="Text"&&(p.type="Text"),p.type==="Path"&&s.weights&&s.bindMatrices&&p.points){const yt=this.getGlobalTransform(s.id);if(yt){const Ft=ni(p.points,s.weights,s.bindMatrices,yt,K=>this.getGlobalTransform(K));p={...p,points:Ft}}}if(i.visible===!1)return;const h=(r.effects||((C=s.style)==null?void 0:C.effects)||[]).find(yt=>yt.isEnabled!==!1&&yt.type==="PathDistortion");if(h){const yt=ai(p,l,d,h.amplitude||5,h.frequency||10,h.seed||0,h.direction||0,h.directionStrength||0);p={...p,type:"Path",points:yt}}const S=s.repeaterConfig,y=S&&S.isEnabled&&S.count>1,c=y?S.count:1;for(let yt=0;yt<c;yt++){let Ft=i.x!==void 0?i.x:((w=i.transform)==null?void 0:w.x)??0,K=i.y!==void 0?i.y:((M=i.transform)==null?void 0:M.y)??0,ut=i.rotation!==void 0?i.rotation:((I=i.transform)==null?void 0:I.rotation)??0,Lt=i.scale_x!==void 0?i.scale_x:((A=i.transform)==null?void 0:A.scale_x)??1,Ct=i.scale_y!==void 0?i.scale_y:((_=i.transform)==null?void 0:_.scale_y)??1;if(y&&yt>0){if(S.type==="Linear"){const j=S.offsetX||0,mt=S.offsetY||0,et=S.rotation||0,J=S.scale!==void 0?S.scale:1;Ft+=yt*j,K+=yt*mt,ut+=yt*et,Lt*=Math.pow(J,yt),Ct*=Math.pow(J,yt)}else if(S.type==="Grid"){const j=S.cols||Math.ceil(Math.sqrt(S.count)),mt=S.gapX||0,et=S.gapY||0,J=Math.floor(yt/j),ot=yt%j,ht=l+mt,At=d+et;Ft+=ot*ht,K+=J*At}else if(S.type==="Radial"){const j=S.radius||100,mt=S.startAngle||0,J=(S.endAngle||360)-mt,ot=S.count>1?J/(J===360?S.count:S.count-1):0,ht=mt+yt*ot,At=ht*Math.PI/180;Ft=i.x+j*Math.cos(At),K=i.y+j*Math.sin(At),ut+=ht}}const Tt=s.type==="Group"||s.type==="Frame"||s.type==="Component",Et=l>0&&d>0;if(!Tt&&Et&&!e){const j=(((T=r.shadow)==null?void 0:T.isEnabled)!==!1?(((L=r.shadow)==null?void 0:L.blur)||0)+10:0)+(((F=r.blur)==null?void 0:F.isEnabled)!==!1&&((D=r.blur)==null?void 0:D.radius)||0)+20;if(!this.isObjectInView(t,Ft,K,l,d,j))continue}this.debug_objectsRendered++,t.save();const tt=[],at=r.blur||((R=s.style)==null?void 0:R.blur);at&&at.amount>0&&tt.push(`blur(${at.amount}px)`);const ct=r.effects||((X=s.style)==null?void 0:X.effects)||[];let Pt=ct.find(j=>j.isEnabled!==!1&&(j.type==="BackgroundBlur"||j.type==="LayerBlur"));Pt||(Pt=r.effect||((P=s.style)==null?void 0:P.effect)||ct.find(j=>j.isEnabled!==!1));const kt=Pt,It=(kt==null?void 0:kt.isEnabled)!==!1,xt=kt==null?void 0:kt.type,ie=(kt==null?void 0:kt.radius)??10;It&&xt==="LayerBlur"?tt.push(`blur(${ie}px)`):It&&xt==="BackgroundBlur"&&(r===s.style&&(r={...r}),r.fill={type:"None"});const se=(p==null?void 0:p.adjustments)||(a==null?void 0:a.adjustments)||((k=s.geometry)==null?void 0:k.adjustments),Qt=(r==null?void 0:r.adjustments)||((O=s.style)==null?void 0:O.adjustments),ce=((E=r==null?void 0:r.fill)==null?void 0:E.adjustments)||((W=(N=s.style)==null?void 0:N.fill)==null?void 0:W.adjustments),le=s==null?void 0:s.adjustments,qt=se||Qt||ce||le;if(i&&qt&&(i.geometry=i.geometry||{},i.geometry.adjustments={...qt}),qt){const j=(qt.exposure||0)/100,mt=(qt.contrast||0)/100,et=(qt.saturation||0)/100,J=(qt.temperature||0)/200,ot=(qt.tint||0)/200,ht=(qt.highlights||0)/500,At=(qt.shadows||0)/500,ft=qt.hue||0,St=(qt.negative||0)/100,Dt=qt.blur||0;if(j!==0&&tt.push(`brightness(${1+j})`),mt!==0){const gt=mt>0?1+mt*2:1+mt;tt.push(`contrast(${Number(gt.toFixed(2))})`)}if(et!==0){const gt=et>0?1+et*1.5:1+et;tt.push(`saturate(${Number(gt.toFixed(2))})`)}const Bt=ft+ot*30-J*20;Bt!==0&&tt.push(`hue-rotate(${Math.round(Bt)}deg)`),J>0&&tt.push(`sepia(${Math.round(J*40)}%)`),St!==0&&tt.push(`invert(${Math.abs(St)})`),ht!==0&&tt.push(`brightness(${1+ht})`),At!==0&&tt.push(`contrast(${1+At})`),Dt>0&&tt.push(`blur(${Dt}px)`)}tt.length>0?(t.filter=tt.join(" "),(!this._lastLoggedAdjustments||this._lastLoggedAdjustments!==t.filter)&&(this._lastLoggedAdjustments=t.filter,this.log(`[ExodeUI Engine] Applied Canvas Filter for (${s.name||s.id}): "${t.filter}" (Adjustments: ${JSON.stringify(qt)})`),console.log(`[ExodeUI Engine Log] Applied Canvas Filter for (${s.name||s.id}):`,{filter:t.filter,adjustments:qt}))):t.filter="none",t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high";const Se=t.globalAlpha,Ce=this.normalizeOpacity(i.opacity!==void 0?i.opacity:100);t.globalAlpha=Se*Ce;const Ie=i.compositeOperation||i.blendMode;if(Ie&&Ie!=="Normal"){const j=Ie.toLowerCase();["multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","source-over","source-in","source-out","source-atop","destination-over","destination-in","destination-out","destination-atop","lighter","copy","xor","multiply","screen"].includes(j)&&(t.globalCompositeOperation=j)}const fe=t,Oe=i.masks||(s.maskedBy?[{maskId:s.maskedBy,inverted:s.maskInverted===!0,type:s.maskType||"alpha",opacity:s.maskOpacity!==void 0?s.maskOpacity/100:1,feather:s.maskFeather||0,isVisible:!0}]:[]);let ye=!1;const ke=Oe.filter(j=>j.isVisible!==!1&&o.has(j.maskId));if(ke.length>0){const j=ke[0],mt=o.get(j.maskId),et=this.objectStates.get(mt.id);et&&et.visible!==!1&&(ye=!0,(!this.maskBuffer||this.maskBuffer.width!==this.canvasWidth||this.maskBuffer.height!==this.canvasHeight)&&(this.maskBuffer=document.createElement("canvas"),this.maskBuffer.width=this.canvasWidth,this.maskBuffer.height=this.canvasHeight,this.maskCtx=this.maskBuffer.getContext("2d",{willReadFrequently:!0}),this.maskCtx&&(this.maskCtx.imageSmoothingEnabled=!0,this.maskCtx.imageSmoothingQuality="high")),this.maskCtx.setTransform(1,0,0,1,0,0),this.maskCtx.globalCompositeOperation="source-over",this.maskCtx.globalAlpha=1,this.maskCtx.filter="none",this.maskCtx.clearRect(0,0,this.maskBuffer.width,this.maskBuffer.height),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),s.parentId&&this.applyAbsoluteTransform(this.maskCtx,s.parentId,o),this.maskCtx.save(),this.maskCtx.globalAlpha=1,t=this.maskCtx,t.filter=fe.filter)}if(!n){t.translate(Ft,K),t.rotate(ut*Math.PI/180);const j=i.skew_x||0,mt=i.skew_y||0;if(j!==0||mt!==0){const St=Math.tan(j*Math.PI/180),Dt=Math.tan(mt*Math.PI/180);t.transform(1+St*Dt,Dt,St,1,0,0)}const et=i.rotate_x!==void 0?i.rotate_x:((B=i.transform)==null?void 0:B.rotate_x)??0,J=i.rotate_y!==void 0?i.rotate_y:((G=i.transform)==null?void 0:G.rotate_y)??0,ht=1+(i.translate_z!==void 0?i.translate_z:((z=i.transform)==null?void 0:z.translate_z)??0)/1e3,At=(i.flip_x===!0?-1:1)*Math.cos(J*Math.PI/180)*ht,ft=(i.flip_y===!0?-1:1)*Math.cos(et*Math.PI/180)*ht;t.scale(Lt*At,Ct*ft)}r.shadow&&r.shadow.isEnabled===void 0&&((r.shadow.blur||0)>0||Math.abs(r.shadow.offsetX||0)>0||Math.abs(r.shadow.offsetY||0)>0)&&(r.shadow.isEnabled=!0);const Vt=r.shadow;if(Vt&&Vt.isEnabled!==!1&&!e){let j=Vt.color||"#000000";(U=(V=this.artboard)==null?void 0:V.tokens)!=null&&U.colors&&this.artboard.tokens.colors[j]&&(j=this.artboard.tokens.colors[j]);const mt=this.normalizeOpacity(Vt.opacity??100)*.75,et=Vt.spread||0,ot=(Vt.blur||0)+et*1.5;let ht=j;if(j.startsWith("#")){const St=j.replace("#",""),Dt=parseInt(St.substring(0,2),16),Bt=parseInt(St.substring(2,4),16),gt=parseInt(St.substring(4,6),16);ht=`rgba(${Dt}, ${Bt}, ${gt}, ${mt})`}else if(j.startsWith("rgba")){const St=j.match(/[\d.]+/g);if(St&&St.length>=4){const Dt=St[0],Bt=St[1],gt=St[2],$=St[3];ht=`rgba(${Dt}, ${Bt}, ${gt}, ${parseFloat($)*mt})`}}const At=t.getTransform(),ft=Math.sqrt(At.a*At.a+At.b*At.b)||1;t.shadowColor=ht,t.shadowBlur=ot*ft,t.shadowOffsetX=(Vt.offsetX||0)*ft,t.shadowOffsetY=(Vt.offsetY||0)*ft}const te=s.liquidFill||((q=s.style)==null?void 0:q.liquidFill);if(te&&te.enabled){t.save();const j=te.fillLevel??.5;t.beginPath();const mt=d/2-d*j;t.rect(-l/2,mt,l,d*j),t.clip(),t.fillStyle=te.color||"#3b82f6",t.globalAlpha=t.globalAlpha*(te.opacity??1)}if(e||this.applyOuterGlowUnderlay(t,s,p,l,d,g,r,o),(a==null?void 0:a.type)==="Text"||s.type==="Text")this._renderText(t,s,p,r,i,l,d,!1,!1);else if((a==null?void 0:a.type)==="Image"||((Y=r.fill)==null?void 0:Y.type)==="Image"||s.type==="Image"&&(a!=null&&a.src||(H=r.fill)!=null&&H.src)){const j=(a==null?void 0:a.originalSrc)||(a==null?void 0:a.src)||((x=r.fill)==null?void 0:x.originalSrc)||((dt=r.fill)==null?void 0:dt.src)||(s==null?void 0:s.src);if(j){let mt=this.imageCache.get(j);mt||(mt=new Image,mt.onload=()=>{this.log(`[ExodeUI] Image loaded successfully, size: ${mt.naturalWidth}x${mt.naturalHeight}`)},mt.onerror=ot=>{console.error("[ExodeUI] Image load failed:",ot,`Src preview: ${j.substring(0,100)}...`)},mt.src=j,this.imageCache.set(j,mt));const et=r.stroke&&r.stroke.width>0&&r.stroke.isEnabled!==!1,J=(((_t=r.stroke)==null?void 0:_t.alignment)||"center").toLowerCase();if(et&&J==="outside"&&this.applyStrokeAlignment(t,r,p,l,d,g),r.fill&&r.fill.type!=="None"){t.save();const ot=t.globalAlpha,ht=this.createCanvasFill(t,r.fill,l,d);t.fillStyle=ht||r.fill.color||"transparent",t.globalAlpha=ot*this.normalizeOpacity(r.fill.opacity??100),g!==0?(this.drawRoundRect(t,-l/2,-d/2,l,d,g),t.fill()):t.fillRect(-l/2,-d/2,l,d),t.globalAlpha=ot,t.restore()}if(mt.complete&&mt.naturalWidth>0){const ot=qt?this.processFabricAdjustmentsCanvas(mt,l,d,qt):mt;g!==0?(t.save(),this.drawRoundRect(t,-l/2,-d/2,l,d,g),t.clip(),t.drawImage(ot,-l/2,-d/2,l,d),t.restore()):t.drawImage(ot,-l/2,-d/2,l,d),et&&(J==="inside"||J==="center")&&this.applyStrokeAlignment(t,r,p,l,d,g)}else et&&(J==="inside"||J==="center")&&this.applyStrokeAlignment(t,r,p,l,d,g)}}else if(a.type==="SVG"){const j=a.svgContent;if(j){const mt=r.palette||[],et=r.fill,J=r.stroke,ot=et?this.normalizeOpacity(et.opacity??100):1,ht=J&&J.isEnabled!==!1?this.normalizeOpacity(J.opacity??100):1,At=(et==null?void 0:et.type)==="Solid"&&(!J||J.isEnabled===!1||J.type==="Solid"&&J.color===et.color&&ht===ot),ft=et&&et.type!=="None"?At?"monochrome":et.type==="Solid"?(et.color||"")+"|opacity:"+ot:JSON.stringify(et.stops||[])+"|opacity:"+ot:"",St=J&&J.isEnabled!==!1&&(J.width||0)>0?At?["monochrome",J.width||0,J.trimStart??0,J.trimEnd??1,J.trimOffset??0,J.dashOffset??0].join("|"):[J.width||0,J.fill?J.fill.type==="Solid"?J.fill.color||"":JSON.stringify(J.fill.stops||[]):J.color||"",J.opacity??1,J.lineCap||"",J.lineJoin||"",(J.dashArray||[]).join(","),J.trimStart??0,J.trimEnd??1,J.trimOffset??0,J.dashOffset??0].join("|"):"nostroke",Dt=[s.id,mt.join("_"),ft,St,i.opacity??100,i.visible!==!1?"v":"h"].join("_");let Bt=this.imageCache.get(Dt);if(!Bt){Bt=new Image,Bt.crossOrigin="anonymous";let $=j;$.match(/xmlns=["']http:\/\/www\.w3\.org\/2000\/svg["']/i)||($=$.replace(/<svg([^>]*)>/i,(Rt,Kt)=>`<svg xmlns="http://www.w3.org/2000/svg"${Kt}>`));let bt=a.width||l||100,$t=a.height||d||100;const Q=$.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(Q&&(bt=parseFloat(Q[1]),$t=parseFloat(Q[2])),$=$.replace(/<svg([^>]*)>/i,(Rt,Kt)=>{let Xt=Kt.replace(/\b(?:width|height)=["'][^"']*["']/gi," ");return Xt.match(/\bviewBox=/i)||(Xt+=` viewBox="0 0 ${bt} ${$t}"`),Xt.match(/\bpreserveAspectRatio=/i)||(Xt+=' preserveAspectRatio="none"'),Xt+=' width="100%" height="100%"',`<svg${Xt}>`}),a.colors&&a.colors.length>0&&mt.length>0&&a.colors.forEach((Rt,Kt)=>{if(mt[Kt]){const Xt=Rt.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),Jt=new RegExp(Xt,"gi");$=$.replace(Jt,mt[Kt])}}),et&&et.type&&et.type!=="None"){if(et.type==="Solid"&&et.color){const Rt=At?"#FFFFFF":et.color,Kt=At?1:this.normalizeOpacity(et.opacity??100);$=$.replace(/\bfill\s*=\s*["'][^"']*["']/gi,Xt=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(Xt)?Xt:`fill="${Rt}"`),$=$.replace(/fill\s*:\s*[^;"')]+/gi,Xt=>/fill\s*:\s*(none|transparent)/i.test(Xt)?Xt:`fill:${Rt}`),Kt<1&&($=$.replace(/\bfill-opacity\s*=\s*["'][^"']*["']/gi,`fill-opacity="${Kt}"`),$=$.replace(/fill-opacity\s*:\s*[^;"')]+/gi,`fill-opacity:${Kt}`),$.match(/\bfill-opacity\s*=/i)||($=$.replace(/(<svg[^>]*>)/i,`$1<g fill-opacity="${Kt}">`),$=$.replace(/<\/svg>/i,"</g></svg>")))}else if(et.type==="LinearGradient"||et.type==="RadialGradient"||et.type==="Linear"||et.type==="Radial"){const Rt="exode-fill",Kt=this.normalizeOpacity(et.opacity??100),Xt=(et.stops||[]).map(Gt=>{const ge=Gt.offset!==void 0?Gt.offset:Gt.pos??0,be=this.normalizeOpacity(Gt.opacity??100)*Kt;return`<stop offset="${ge*100}%" stop-color="${Gt.color||"#000"}" stop-opacity="${be}"/>`}).join("");let Jt="";if(et.type==="LinearGradient"||et.type==="Linear"){const Gt=(de,he)=>Array.isArray(de)?de[he]??(he===0?0:1):de&&typeof de=="object"?de[he===0?"x":"y"]??(he===0?0:1):he===0?0:1,ge=Gt(et.start,0)*100,be=Gt(et.start,1)*100,Le=Gt(et.end,0)*100,ae=Gt(et.end,1)*100;Jt=`<linearGradient id="${Rt}" x1="${ge}%" y1="${be}%" x2="${Le}%" y2="${ae}%" gradientUnits="objectBoundingBox">${Xt}</linearGradient>`}else{const Gt=(ae,de)=>Array.isArray(ae)?ae[de]??.5:ae&&typeof ae=="object"?ae[de===0?"x":"y"]??.5:.5,ge=Gt(et.center,0)*100,be=Gt(et.center,1)*100,Le=(et.radius??.5)*100;Jt=`<radialGradient id="${Rt}" cx="${ge}%" cy="${be}%" r="${Le}%" gradientUnits="objectBoundingBox">${Xt}</radialGradient>`}/<defs>/i.test($)?$=$.replace(/<defs>/i,`<defs>${Jt}`):$=$.replace(/<svg([^>]*)>/i,`<svg$1><defs>${Jt}</defs>`),$=$.replace(/\bfill\s*=\s*["'][^"']*["']/gi,Gt=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(Gt)?Gt:`fill="url(#${Rt})"`),$=$.replace(/fill\s*:\s*[^;"')]+/gi,Gt=>/fill\s*:\s*(none|transparent)/i.test(Gt)?Gt:`fill:url(#${Rt})`)}}const rt=(Rt,Kt,Xt=1)=>{const Jt=(Rt.stops||[]).map(ae=>{const de=ae.offset!==void 0?ae.offset:ae.pos??0,he=this.normalizeOpacity(ae.opacity??100)*Xt;return`<stop offset="${de*100}%" stop-color="${ae.color||"#000"}" stop-opacity="${he}"/>`}).join(""),Gt=(ae,de,he=.5)=>Array.isArray(ae)?ae[de]??he:ae&&typeof ae=="object"?ae[de===0?"x":"y"]??he:he;if(Rt.type==="LinearGradient"||Rt.type==="Linear"){const ae=Gt(Rt.start,0,0)*100,de=Gt(Rt.start,1,0)*100,he=Gt(Rt.end,0,1)*100,$e=Gt(Rt.end,1,1)*100;return`<linearGradient id="${Kt}" x1="${ae}%" y1="${de}%" x2="${he}%" y2="${$e}%" gradientUnits="objectBoundingBox">${Jt}</linearGradient>`}const ge=Gt(Rt.center,0,.5)*100,be=Gt(Rt.center,1,.5)*100,Le=(Rt.radius??.5)*100;return`<radialGradient id="${Kt}" cx="${ge}%" cy="${be}%" r="${Le}%" gradientUnits="objectBoundingBox">${Jt}</radialGradient>`},lt=(Rt,Kt)=>/<defs>/i.test(Rt)?Rt.replace(/<defs>/i,`<defs>${Kt}`):Rt.replace(/(<svg[^>]*>)/i,`$1<defs>${Kt}</defs>`);if(J&&J.isEnabled!==!1&&(J.width||0)>0){const Rt=At?1:this.normalizeOpacity(J.opacity??100),Kt=At?"#FFFFFF":J.color||(et==null?void 0:et.color)||"#000000";let Xt="";const Jt=J.fill;if(Jt&&Jt.type){if(Jt.type==="Solid")Xt=Jt.color||J.color||"#000000";else if(Jt.type==="LinearGradient"||Jt.type==="RadialGradient"||Jt.type==="Linear"||Jt.type==="Radial"){const re="exode-stroke";$=lt($,rt(Jt,re,Rt)),Xt=`url(#${re})`}}Xt||(Xt=Kt),$.match(/\bstroke\s*=\s*["']/i)?$=$.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,re=>/stroke\s*=\s*["']\s*(none|transparent)\s*["']/i.test(re)?re:`stroke="${Xt}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke="${Xt}"`),$=$.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),`stroke:${Xt}`);let Gt=a.width||l||100,ge=a.height||d||100;const be=j.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(be){const re=parseFloat(be[1]),ve=parseFloat(be[2]);!isNaN(re)&&!isNaN(ve)&&(Gt=re,ge=ve)}const Le=Math.max(.001,l/Gt),ae=Math.max(.001,d/ge),de=(Le+ae)/2,he=(J.width||1)/de;$.match(/\bstroke-width\s*=\s*["']/i)?$=$.replace(/\bstroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${he}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-width="${he}"`),$=$.replace(/stroke-width\s*:\s*[^;"')]+/gi,`stroke-width:${he}`),$.match(/\bstroke-opacity\s*=\s*["']/i)?$=$.replace(/\bstroke-opacity\s*=\s*["'][^"']*["']/gi,`stroke-opacity="${Rt}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-opacity="${Rt}"`),$=$.replace(/stroke-opacity\s*:\s*[^;"')]+/gi,`stroke-opacity:${Rt}`);const $e=J.lineCap||"round";$.match(/\bstroke-linecap\s*=\s*["']/i)?$=$.replace(/\bstroke-linecap\s*=\s*["'][^"']*["']/gi,`stroke-linecap="${$e}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linecap="${$e}"`),$=$.replace(/stroke-linecap\s*:\s*[^;"')]+/gi,`stroke-linecap:${$e}`);const Be=J.lineJoin||"round";$.match(/\bstroke-linejoin\s*=\s*["']/i)?$=$.replace(/\bstroke-linejoin\s*=\s*["'][^"']*["']/gi,`stroke-linejoin="${Be}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linejoin="${Be}"`),$=$.replace(/stroke-linejoin\s*:\s*[^;"')]+/gi,`stroke-linejoin:${Be}`);const De=J.trimStart??0,Ye=J.trimEnd??1,Xe=J.trimOffset??0,Ne=J.dashOffset??0,Ue=De!==0||Ye!==1||Xe!==0||Ne!==0;if(Ue){const re=Math.max(0,Math.min(1,De)),ve=Math.max(0,Math.min(1,Ye));this.frameCount%600===0&&this.debugLog(`SVG Trim - Object: ${s.name||s.id}, Start: ${re}, End: ${ve}`);const Te=(Gt+ge)*2,He=(Xe%1+1)%1,xe=(Ne%1+1)%1;let _e="",Pe=0;if(re>=ve)_e=`0 ${Te}`,Pe=0;else{const Z=Te*(ve-re),it=Te-Z;Pe=-(Te*(re+He+xe)),_e=`${Z} ${it}`}$.match(/\bstroke-dasharray\s*=/i)?$=$.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${_e}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dasharray="${_e}"`),$=$.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${_e}`),$.match(/\bstroke-dashoffset\s*=/i)?$=$.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${Pe}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dashoffset="${Pe}"`),$=$.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${Pe}`)}else if(J.dashArray&&J.dashArray.length>0){const re=J.dashArray.join(" ");if($=$.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${re}"`),$=$.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${re}`),J.dashOffset){const ve=(Gt+ge)*2,Te=-(J.dashOffset*ve);$=$.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${Te}"`),$=$.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${Te}`)}}if(!/\bstroke\s*=\s*["']/i.test(j)&&!new RegExp("(?<![a-z-])stroke\\s*:","i").test(j)){let re="",ve="";if(Ue){const _e=a.width||l||100,Pe=a.height||d||100,Z=(_e+Pe)*2,it=Math.max(0,Math.min(1,De)),nt=Math.max(0,Math.min(1,Ye)),wt=(Xe%1+1)%1,zt=(Ne%1+1)%1;if(it>=nt)re=` stroke-dasharray="0 ${Z}"`,ve=' stroke-dashoffset="0"';else{const Ut=Z*(nt-it),Zt=Z-Ut,me=-(Z*(it+wt+zt));re=` stroke-dasharray="${Ut} ${Zt}"`,ve=` stroke-dashoffset="${me}"`}}else(vt=J.dashArray)!=null&&vt.length&&(re=` stroke-dasharray="${J.dashArray.join(" ")}"`,J.dashOffset&&(ve=` stroke-dashoffset="${J.dashOffset}"`));const Te=` stroke-linecap="${J.lineCap||"round"}"`,He=` stroke-linejoin="${J.lineJoin||"round"}"`,xe=`stroke="${Xt}" stroke-width="${he}" stroke-opacity="${Rt}"${Te}${He}${re}${ve}`;$=$.replace(/(<svg[^>]*>)(\s*(?:<defs>[\s\S]*?<\/defs>)?)/i,(_e,Pe,Z)=>`${Pe}${Z}<g ${xe}>`),$=$.replace(/<\/svg>/i,"</g></svg>")}}else J&&J.isEnabled===!1&&($=$.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,'stroke="none"'),$=$.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),"stroke:none"));const jt=new Blob([$],{type:"image/svg+xml"}),oe=URL.createObjectURL(jt);Bt.onload=()=>{if(URL.revokeObjectURL(oe),this.frameCount%900===0){const Rt=this.imageCache.get(Dt);Rt&&this.debugLog(`SVG Payload Ready: ${s.name||s.id} (${Rt.naturalWidth}x${Rt.naturalHeight})`)}},Bt.onerror=()=>{URL.revokeObjectURL(oe),this.debugLog(`SVG Error: Failed to load payload for ${s.name||s.id}`)},Bt.src=oe,this.imageCache.set(Dt,Bt)}let gt=null;if(Bt.complete&&Bt.naturalWidth>0?(gt=Bt,this.lastValidSvgImgMap.set(s.id,Bt)):gt=this.lastValidSvgImgMap.get(s.id)||null,gt&&gt.complete&&gt.naturalWidth>0){const $=Math.max(1,l),bt=Math.max(1,d);if(At&&(et==null?void 0:et.type)==="Solid"){this.maskBuffer||(this.maskBuffer=document.createElement("canvas"),this.maskCtx=this.maskBuffer.getContext("2d")),this.maskBuffer.width=$,this.maskBuffer.height=bt,this.maskCtx.setTransform(1,0,0,1,0,0),this.maskCtx.globalCompositeOperation="source-over",this.maskCtx.globalAlpha=1,this.maskCtx.filter="none",this.maskCtx.clearRect(0,0,$,bt),this.maskCtx.drawImage(gt,0,0,$,bt),this.maskCtx.globalCompositeOperation="source-in";const $t=et.color||"#000000",Q=this.normalizeOpacity(et.opacity??100);this.maskCtx.fillStyle=$t,this.maskCtx.globalAlpha=Q,this.maskCtx.fillRect(0,0,$,bt),t.drawImage(this.maskBuffer,-$/2,-bt/2,$,bt)}else g!==0?(t.save(),this.drawRoundRect(t,-$/2,-bt/2,$,bt,g),t.clip(),t.drawImage(gt,-$/2,-bt/2,$,bt),t.restore()):t.drawImage(gt,-$/2,-bt/2,$,bt)}}}else if(p.type==="LineGraph"||s.type==="LineGraph"||this.isLineGraphObject(s))this.renderLineGraph(t,s,p,l,d);else if(s.type==="Shape"){if(this.applyPath(t,p,l,d,g),t.save(),r.blur&&r.blur.amount>0&&(t.filter=`blur(${r.blur.amount}px)`),It&&xt==="BackgroundBlur")if(e)t.fillStyle="#000000",t.globalAlpha=1,this.applyPath(t,p,l,d,g),t.fill();else{if(t.shadowColor&&t.shadowColor!=="rgba(0, 0, 0, 0)"&&t.shadowColor!=="transparent"){const et=t.getTransform(),J=t.shadowOffsetX,ot=t.shadowOffsetY;t.shadowOffsetX=J+1e4*et.a,t.shadowOffsetY=ot+1e4*et.b,t.save(),t.translate(-1e4,0),this.applyPath(t,p,l,d,g),t.fillStyle="white",t.fill(),t.restore(),t.shadowOffsetX=J,t.shadowOffsetY=ot,t.shadowColor="transparent"}this.applyBackgroundBlurGlass(t,p,l,d,g,kt,r)}else if(r.fill){const mt=t.globalAlpha;if(((Yt=r.fill)==null?void 0:Yt.type)==="Image"&&(r.fill.originalSrc||r.fill.src)){const et=r.fill.originalSrc||r.fill.src;let J=this.imageCache.get(et);J||(J=new Image,J.src=et,this.imageCache.set(et,J)),J.complete&&J.naturalWidth>0&&(t.save(),this.applyPath(t,p,l,d,g),t.clip(),this.renderFittedImage(t,J,-l/2,-d/2,l,d,r.fill.fillMode),t.restore())}else{const et=this.createCanvasFill(t,r.fill,l,d);t.fillStyle=et||(typeof r.fill=="string"?r.fill:r.fill.color||"transparent"),t.globalAlpha=mt*this.normalizeOpacity(r.fill.opacity??100),this.applyPath(t,p,l,d,g),t.fill()}t.globalAlpha=mt}t.restore(),r.stroke&&r.stroke.width>0&&(this.applyPath(t,p,l,d,g),this.applyStrokeAlignment(t,r,p,l,d,g))}else if(s.type==="Frame"||s.type==="Component"&&!s.variant||s.type==="Group"&&!s.isStructuralGroup){const j=i.width??a.width??s.width??l,mt=i.height??a.height??s.height??d,et=g;if(t.save(),t.beginPath(),this.drawRoundRect(t,-j/2,-mt/2,j,mt,et),It&&xt==="BackgroundBlur")if(e)t.fillStyle="#000000",t.globalAlpha=1,t.beginPath(),this.drawRoundRect(t,-j/2,-mt/2,j,mt,et),t.fill();else{if(t.shadowColor&&t.shadowColor!=="rgba(0, 0, 0, 0)"&&t.shadowColor!=="transparent"){const ht=t.getTransform(),At=t.shadowOffsetX,ft=t.shadowOffsetY;t.shadowOffsetX=At+1e4*ht.a,t.shadowOffsetY=ft+1e4*ht.b,t.save(),t.translate(-1e4,0),t.beginPath(),this.drawRoundRect(t,-j/2,-mt/2,j,mt,et),t.fillStyle="white",t.fill(),t.restore(),t.shadowOffsetX=At,t.shadowOffsetY=ft,t.shadowColor="transparent"}this.applyBackgroundBlurGlass(t,p,j,mt,et,kt,r)}else if(r.fill&&r.fill.type!=="None"){const ot=t.globalAlpha;if(((Mt=r.fill)==null?void 0:Mt.type)==="Image"&&(r.fill.originalSrc||r.fill.src)){const ht=r.fill.originalSrc||r.fill.src;let At=this.imageCache.get(ht);At||(At=new Image,At.src=ht,this.imageCache.set(ht,At)),At.complete&&At.naturalWidth>0&&(t.save(),t.beginPath(),this.drawRoundRect(t,-j/2,-mt/2,j,mt,et),t.clip(),this.renderFittedImage(t,At,-j/2,-mt/2,j,mt,r.fill.fillMode),t.restore())}else{const ht=this.createCanvasFill(t,r.fill,j,mt);t.fillStyle=ht||r.fill.color||"transparent",t.globalAlpha=ot*this.normalizeOpacity(r.fill.opacity??100),t.beginPath(),this.drawRoundRect(t,-j/2,-mt/2,j,mt,et),t.fill(),t.globalAlpha=ot}}if(t.restore(),!e&&(It&&xt==="BackgroundBlur"||r.fill&&r.fill.type!=="None")&&(t.shadowColor="transparent"),r.stroke&&r.stroke.width>0&&r.stroke.isEnabled!==!1){const ot={type:"Rectangle"};t.beginPath(),this.drawRoundRect(t,-j/2,-mt/2,j,mt,et),this.applyStrokeAlignment(t,r,ot,j,mt,et)}}else s.type==="Group"&&s.isStructuralGroup||(s.type==="Component"&&s.variant==="inputbox"?this.renderInputBox(t,s):s.type==="Button"||s.type==="Component"&&(s.variant==="button"||(s.name||"").toLowerCase().includes("button")||(s.name||"").toLowerCase().includes("cta"))?this.renderButton(t,s):s.type==="Component"&&s.variant==="toggle_button"?this.renderToggleButton(t,s):s.type==="Toggle"||s.type==="Component"&&s.variant==="toggle"?this.renderToggle(t,s):s.type==="Slider"||s.type==="Component"&&s.variant==="slider"?this.renderSlider(t,s):s.type==="Dropdown"||s.type==="Component"&&s.variant==="dropdown"?this.renderDropdown(t,s):s.type==="ListView"||s.type==="Component"&&s.variant==="listview"?this.renderListView(t,s):s.type==="Checkbox"||((Wt=s.geometry)==null?void 0:Wt.type)==="Checkbox"||s.type==="Component"&&s.variant==="checkbox"?this.renderCheckbox(t,s):s.type==="RadioGroup"||s.type==="Component"&&s.variant==="radiogroup"?this.renderRadioGroup(t,s):s.type==="BarChart"||s.type==="Component"&&s.variant==="barchart"?this.renderBarChart(t,s):s.type==="PieChart"||s.type==="Component"&&s.variant==="piechart"?this.renderPieChart(t,s):s.type==="Joystick"||s.type==="Component"&&s.variant==="joystick"?this.renderJoystick(t,s):this.frameCount%300===0&&this.warn("[Engine] Unhandled object type in renderObject:",s.type,"Geo:",(Ot=s.geometry)==null?void 0:Ot.type));if(e||(this.applyInnerGlowOverlay(t,s,p,l,d,g,r),this.applyArtEffectOverlay(t,s,p,l,d,g)),te&&te.enabled&&t.restore(),s.children&&s.children.length>0){const mt=s.type==="Frame",et=s.clipsContent!==void 0?s.clipsContent:s.clipContent!==void 0?s.clipContent:mt;if(t.save(),et){t.beginPath();const ot=i.width??(a==null?void 0:a.width)??s.width??0,ht=i.height??(a==null?void 0:a.height)??s.height??0,At=i.cornerRadius??(a==null?void 0:a.corner_radius)??s.cornerRadius??0;this.drawRoundRect(t,-ot/2,-ht/2,ot,ht,At),t.clip()}let J=0;for(s.children.forEach(ot=>{const ht=o.get(ot);if(!ht)return;const At=this.objectStates.get(ot),ft=(At==null?void 0:At.geometry)||ht.geometry;if(ft&&ft.isMask&&(At==null?void 0:At.visible)!==!1){const St=ft.width||0,Dt=ft.height||0;this.applyObjectTransform(t,ot);const Bt=(At==null?void 0:At.corner_radius)??(ft==null?void 0:ft.corner_radius)??0;this.applyPath(t,ft,St,Dt,Bt),t.clip(),J++}else this.renderObject(t,ht,o,e)});J>0;)t.restore(),J--;t.restore()}if(ye){this.maskCtx.restore(),(i.masks||(s.maskedBy?[{maskId:s.maskedBy,inverted:s.maskInverted===!0,type:s.maskType||"alpha",opacity:s.maskOpacity!==void 0?s.maskOpacity/100:1,feather:s.maskFeather||0,isVisible:!0}]:[])).filter(J=>J.isVisible!==!1&&o.has(J.maskId)).forEach(J=>{var Bt,gt,$,bt,$t,Q;const ot=o.get(J.maskId),ht=this.objectStates.get(ot.id),At=J.feather||0,ft=J.inverted===!0,St=J.opacity!==void 0?typeof J.opacity=="number"?J.opacity:J.opacity/100:1;if((J.type||"alpha")==="luma"){(!this.lumaBuffer||this.lumaBuffer.width!==this.maskBuffer.width||this.lumaBuffer.height!==this.maskBuffer.height)&&(this.lumaBuffer=document.createElement("canvas"),this.lumaBuffer.width=this.maskBuffer.width,this.lumaBuffer.height=this.maskBuffer.height,this.lumaCtx=this.lumaBuffer.getContext("2d",{willReadFrequently:!0}),this.lumaCtx&&(this.lumaCtx.imageSmoothingEnabled=!0,this.lumaCtx.imageSmoothingQuality="high")),this.lumaCtx.setTransform(1,0,0,1,0,0),this.lumaCtx.globalCompositeOperation="source-over",this.lumaCtx.globalAlpha=1,this.lumaCtx.filter="none",this.lumaCtx.clearRect(0,0,this.lumaBuffer.width,this.lumaBuffer.height),this.lumaCtx.save(),this.rootTransform&&this.lumaCtx.setTransform(this.rootTransform),this.applyAbsoluteTransform(this.lumaCtx,ot.id,o),At>0&&(this.lumaCtx.filter=`blur(${At}px)`),this.lumaCtx.globalAlpha=St;const rt=(ht==null?void 0:ht.width)||ot.geometry.width||0,lt=(ht==null?void 0:ht.height)||ot.geometry.height||0,jt=(ht==null?void 0:ht.corner_radius)??ot.corner_radius??0;if(((Bt=ot.geometry)==null?void 0:Bt.type)==="Text"){const Xt=ht!=null&&ht.geometry?this.deepMerge(ot.geometry,ht.geometry):ot.geometry,Jt=ht!=null&&ht.style?this.deepMerge(ot.style,ht.style):ot.style;this._renderText(this.lumaCtx,ot,{...Xt,width:rt,height:lt,corner_radius:jt},Jt,ht,rt,lt,!0,!1)}else if(((gt=ot.geometry)==null?void 0:gt.type)==="Image"){const Xt=ot.geometry.src;if(Xt){let Jt=this.imageCache.get(Xt);Jt||(Jt=new Image,Jt.src=Xt,this.imageCache.set(Xt,Jt)),Jt.complete&&Jt.naturalWidth>0?this.lumaCtx.drawImage(Jt,-rt/2,-lt/2,rt,lt):(this.applyPath(this.lumaCtx,ot.geometry,rt,lt,jt),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else if((($=ot.geometry)==null?void 0:$.type)==="SVG"){const Xt=ot.geometry.svgContent;if(Xt){const Jt=`__lumamask_${ot.id}`;let Gt=this.imageCache.get(Jt);if(!Gt){Gt=new Image;const ge=new Blob([Xt],{type:"image/svg+xml"});Gt.src=URL.createObjectURL(ge),Gt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(Jt,Gt)}Gt.complete&&Gt.naturalWidth>0?this.lumaCtx.drawImage(Gt,-rt/2,-lt/2,rt,lt):(this.applyPath(this.lumaCtx,ot.geometry,rt,lt,jt),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else this.applyPath(this.lumaCtx,ot.geometry,rt,lt,jt),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill();this.lumaCtx.restore();const oe=this.maskCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight),Rt=this.lumaCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight).data,Kt=oe.data;for(let Xt=0;Xt<Kt.length;Xt+=4){const Jt=Rt[Xt],Gt=Rt[Xt+1],ge=Rt[Xt+2];let be=(.299*Jt+.587*Gt+.114*ge)/255;ft&&(be=1-be),Kt[Xt+3]*=be}this.maskCtx.putImageData(oe,0,0)}else{this.maskCtx.save(),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),this.maskCtx.globalCompositeOperation=ft?"destination-out":"destination-in",At>0&&(this.maskCtx.filter=`blur(${At}px)`),this.maskCtx.globalAlpha=St,this.applyAbsoluteTransform(this.maskCtx,ot.id,o);const rt=(ht==null?void 0:ht.width)||ot.geometry.width||0,lt=(ht==null?void 0:ht.height)||ot.geometry.height||0,jt=(ht==null?void 0:ht.corner_radius)??ot.corner_radius??0;if(((bt=ot.geometry)==null?void 0:bt.type)==="Text"){const oe=ht!=null&&ht.geometry?this.deepMerge(ot.geometry,ht.geometry):ot.geometry,Rt=ht!=null&&ht.style?this.deepMerge(ot.style,ht.style):ot.style;this._renderText(this.maskCtx,ot,{...oe,width:rt,height:lt,corner_radius:jt},Rt,ht,rt,lt,!0,!1)}else if((($t=ot.geometry)==null?void 0:$t.type)==="Image"){const oe=ot.geometry.src;if(oe){let Rt=this.imageCache.get(oe);Rt||(Rt=new Image,Rt.src=oe,this.imageCache.set(oe,Rt)),Rt.complete&&Rt.naturalWidth>0?this.maskCtx.drawImage(Rt,-rt/2,-lt/2,rt,lt):(this.applyPath(this.maskCtx,ot.geometry,rt,lt,jt),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else if(((Q=ot.geometry)==null?void 0:Q.type)==="SVG"){const oe=ot.geometry.svgContent;if(oe){const Rt=`__alphamask_${ot.id}`;let Kt=this.imageCache.get(Rt);if(!Kt){Kt=new Image;const Xt=new Blob([oe],{type:"image/svg+xml"});Kt.src=URL.createObjectURL(Xt),Kt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(Rt,Kt)}Kt.complete&&Kt.naturalWidth>0?this.maskCtx.drawImage(Kt,-rt/2,-lt/2,rt,lt):(this.applyPath(this.maskCtx,ot.geometry,rt,lt,jt),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else this.applyPath(this.maskCtx,ot.geometry,rt,lt,jt),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill();this.maskCtx.restore()}}),fe.save(),fe.setTransform(1,0,0,1,0,0);const et=s.maskBlendMode||s.blendMode;et&&et!=="Normal"&&(fe.globalCompositeOperation=et.toLowerCase()),fe.drawImage(this.maskBuffer,0,0),fe.restore(),fe.restore()}else t.restore()}}applyOuterGlowUnderlay(t,s,o,e,n,i,a,r){var I,A,_;const l=a||s.style||{},d=l.effect,u=l.effects||(d?[d]:[]),g=u.find(T=>T.isEnabled!==!1&&T.type==="Glow"&&(T.mode==="outer"||T.mode==="Outer Glow"||!T.mode));if(!g)return;const p=g.blur||10,f=1e4;let h=g.color||"white";(A=(I=this.artboard)==null?void 0:I.tokens)!=null&&A.colors&&this.artboard.tokens.colors[h]&&(h=this.artboard.tokens.colors[h]),t.save();const S=l.fill&&l.fill.type!=="None",y=u.some(T=>T.isEnabled!==!1&&T.type==="BackgroundBlur"),c=s.type==="Text",v=s.type==="Group";!c&&!v&&(S||y)&&(t.beginPath(),t.rect(-1e6,-1e6,2e6,2e6),s.type==="Frame"||s.type==="Component"?this.drawRoundRect(t,-e/2,-n/2,e,n,i):this._tracePath(t,o,e,n,i),t.clip("evenodd"));const m=t.getTransform();t.shadowColor=h,t.shadowBlur=p,t.shadowOffsetX=f*m.a,t.shadowOffsetY=f*m.b,t.translate(-f,0);let C="black";l.fill&&l.fill.type!=="None"&&(C=this.createCanvasFill(t,l.fill,e,n)||l.fill.color||"black");let w="black";l.stroke&&l.stroke.width>0&&(w=this.createCanvasFill(t,l.stroke.fill||{type:"Solid",color:l.stroke.color},e,n)||l.stroke.color||"black"),t.fillStyle=C,t.strokeStyle=w,t.lineWidth=((_=l.stroke)==null?void 0:_.width)||0;const M=Math.min(g.intensity||1,10);for(let T=0;T<M;T++)if(r)this.renderObject(t,s,r,!0,!0);else if(o.type==="Text")l.fill&&l.fill.type!=="None"&&t.fillText(s.text||"",0,0),l.stroke&&l.stroke.width>0&&t.strokeText(s.text||"",0,0);else if(o.points&&o.type==="Path")this.applyPath(t,o,e,n,i),l.fill&&l.fill.type!=="None"&&t.fill(),l.stroke&&l.stroke.width>0&&t.stroke();else{if(t.beginPath(),o.type==="circle"||o.type==="Ellipse"){const D=e/2,R=n/2;t.ellipse(0,0,D,R,0,0,Math.PI*2)}else i!==0?this.drawRoundRect(t,-e/2,-n/2,e,n,i):t.rect(-e/2,-n/2,e,n);const L=l.fill&&l.fill.type!=="None",F=l.stroke&&l.stroke.width>0;(L||!L&&!F)&&t.fill(),F&&t.stroke()}t.restore()}_renderText(t,s,o,e,n,i,a,r=!1,l=!1){var dt,_t,vt,Yt,Mt,Wt,Ot,yt,Ft;let d=(o==null?void 0:o.text)||(s==null?void 0:s.text)||(s==null?void 0:s.name)||"";if(o.textInputId&&!r){const K=this.inputs.get(o.textInputId);K!==void 0&&(d=String(K),n.geometry&&n.geometry.type==="Text"&&(n.geometry.text=d))}if(o.svgPath){const K=o.svgPath;t.save();const ut=((dt=e==null?void 0:e.fill)==null?void 0:dt.color)||"#000000",Lt=((_t=e==null?void 0:e.fill)==null?void 0:_t.opacity)!==void 0?(vt=e==null?void 0:e.fill)==null?void 0:vt.opacity:1;t.fillStyle=ut,t.globalAlpha*=Lt;const Ct=new Path2D(K);t.fill(Ct),t.restore();return}let u=d||"";o.enableSegments===!0&&o.segments&&Array.isArray(o.segments)&&(u=o.segments.map(K=>K&&K.text?K.text:"").join(""));const g=o.textCase||"none";g==="uppercase"?u=u.toUpperCase():g==="lowercase"?u=u.toLowerCase():g==="capitalize"&&(u=u.replace(/\b\w/g,K=>K.toUpperCase()));let p=((Yt=o.fontWeight)==null?void 0:Yt.toString())||"400",f=o.fontStyle||"normal";p.toLowerCase().includes("italic")&&(f="italic",p=p.replace(/italic/gi,"").trim()||"400");const h=this.mapFontWeight(p),S=Math.max(1,o.fontSize||32);let y=o.fontFamily||"Inter";const c=["Bold","SemiBold","Medium","Regular","Light","Thin","ExtraBold","Black","Italic"];c.forEach(K=>{const ut=new RegExp(`[\\s-]${K}$`,"i");ut.test(y)&&(y=y.replace(ut,"").trim())});const v=o.smallCaps===!0,C=`${v?"small-caps ":""}${f} ${h} ${S}px "${y}", sans-serif`;t.font=C;const w=o.textVerticalAlign||"top";t.textBaseline="top";const M=o.textAlign||"left";t.textAlign=M;let I=0;if(typeof o.letterSpacing=="number")I=o.letterSpacing;else if(typeof o.letterSpacing=="object"&&o.letterSpacing.value!==void 0){const K=o.letterSpacing;I=K.unit==="PERCENT"?K.value/100*S:K.value}t.letterSpacing!==void 0&&(t.letterSpacing=`${I}px`);const A=o.kerning||"auto",_=o.kerningValue||0;A==="manual"&&_!==0&&(t.letterSpacing=`${I+_}px`);const T=o.paragraphSpacing||0;let L=o.lineHeight??1.2;typeof L=="string"&&(L=parseFloat(L)),L>5&&S>0&&(L=L/S);const F=(L||1.2)*S,D=o.isPointText===!0||!o.width||o.width<=0,R=((Mt=o.padding)==null?void 0:Mt.left)||((Wt=o.padding)==null?void 0:Wt.right)||0,X=D?1e5:o.width&&o.width>0?Math.ceil(o.width)-R*2:1e5;o.autoHeight;const P=ss({text:u,fontFamily:y,fontSize:S,fontWeight:h,fontStyle:f,lineHeight:L,width:X,letterSpacing:I,paragraphSpacing:T,paragraphIndent:o.paragraphIndent||0,segments:o.segments,enableSegments:o.enableSegments,textCase:g,hyphenation:o.hyphenation,composer:o.composer,balanceRaggedLines:o.balanceRaggedLines}),k=P.lines||[],O=P.maxFontSize||S,E=this.fontLeadingFactors[y]??.5,N=(F-S)*E;let W=P.height,B=i,G=a;if(B===0||G===0||B>=1e5||D){let K=0,ut=0;const Lt=P.fullText||u;(k||[]).forEach(Ct=>{const Tt=Ct.text||"",Et=t.measureText(Tt).width+(Tt.length>0?(Tt.length-1)*I:0);Et>K&&(K=Et),ut+=Tt.length,ut<Lt.length&&(Lt[ut]===`
8
- `||Lt[ut]==="\r")&&(ut++,Lt[ut-1]==="\r"&&Lt[ut]===`
9
- `&&ut++)}),(B===0||B>=1e5)&&(B=K),G===0&&(G=W||0)}let z=-W/2;a>0&&a>W&&(w==="top"?z=-a/2:w==="middle"||w==="center"?z=-W/2:w==="bottom"&&(z=a/2-W));const V=w==="top"&&a>0?0:N;let U=z+V+N,q=null,Y=0;if(o.pathId&&this.artboard){const K=this.artboard.objects.find(ut=>ut.id===o.pathId);if(K&&K.type==="Shape"&&((Ot=K.geometry)==null?void 0:Ot.type)==="Path"){const ut=this.objectStates.get(K.id),Lt=ut!=null&&ut.geometry?this.deepMerge(K.geometry,ut.geometry):K.geometry,Ct=(ut==null?void 0:ut.scale_x)!==void 0?(K.width||0)*ut.scale_x:K.width||0,Tt=(ut==null?void 0:ut.scale_y)!==void 0?(K.height||0)*ut.scale_y:K.height||0;q={geo:Lt,obj:K,w:Ct,h:Tt},Y=this.getPerimeter(Lt,Ct,Tt)}}const H=(K,ut)=>{var Ct,Tt;if(!I&&!v&&!r&&(!o.enableSegments||!((Ct=o.segments)!=null&&Ct.length)))return t.measureText(K).width;let Lt=0;for(let Et=0;Et<K.length;Et++){const tt=ut+Et;let at=0;if(o.enableSegments===!0&&((Tt=o.segments)==null?void 0:Tt.length)>0){let ct=0,Pt=null;for(const kt of o.segments){if(tt<ct+(kt.text||"").length){Pt=kt;break}ct+=(kt.text||"").length}if(Pt){t.save();let kt=Pt.fontFamily||o.fontFamily||"Inter";const It=this.mapFontWeight((Pt.fontWeight||o.fontWeight||"400").toString()),xt=Pt.fontStyle||f,ie=Pt.fontSize||S;t.font=`${xt} ${It} ${ie}px "${kt}", sans-serif`,at=t.measureText(K[Et]).width,t.restore()}else at=t.measureText(K[Et]).width}else at=t.measureText(K[Et]).width;Lt+=at+I}return Lt-(K.length>0?I:0)},x=(K,ut,Lt,Ct,Tt)=>{var ie,se;const tt=(Tt===0||u[Tt-1]===`
10
- `||u[Tt-1]==="\r")&&o.paragraphIndent?o.paragraphIndent:0,at=(!r||l)&&(s.behaviors||[]).some(Qt=>Qt.enabled&&(Qt.type.toString().includes("Text")||["Typewriter","Scramble","Wave","Bounce","GlitchText","Reveal3D","RevealSlide","RevealBlur"].includes(Qt.type))),ct=!o.pathId&&!at&&(o.enableSegments!==!0||!o.segments||o.segments.length===0),Pt=o.baselineShift||0,kt=Lt+Pt,It=H(K,Tt);let xt=ut+tt;if(M==="center"?xt-=It/2:M==="right"&&(xt-=It),ct){t.font=C;const Qt=t.textAlign;t.textAlign="left",Ct?t.strokeText(K,xt,kt):t.fillText(K,xt,kt),t.textAlign=Qt}else{const Qt=t.textAlign;t.textAlign="left";const ce=Tt+K.length>=u.length||u[Tt+K.length]===`
11
- `||u[Tt+K.length]==="\r";let le=0,qt=0;const Se=o.justifyMinWordSpacing,Ce=o.justifyMaxWordSpacing;if(M==="justify"&&!ce&&It>0&&!o.pathId){const ye=D?It:X-R*2+0,ke=Math.max(0,ye-It);for(let Vt=0;Vt<K.length;Vt++)K[Vt]===" "&&qt++;if(qt>0){const Vt=t.measureText(" ").width;let te=Se||Vt*.5,j=Ce||Vt*2.5;le=Math.max(0,Math.min(ke/qt,j-te))}}let Ie=o.pathOffset||0;o.pathId&&Y>0&&q&&(M==="center"?Ie+=Y/2-It/2:M==="right"&&(Ie+=Y-It));let fe=xt;const Oe=r&&!l?[]:((ie=s.behaviors)==null?void 0:ie.filter(ye=>[st.Typewriter,st.Scramble,st.Wave,st.Bounce,st.GlitchText,st.TextTrail,st.Reveal3D,st.RevealSlide,st.RevealBlur,st.TextLiquid,st.TextVortex,st.TextExplosion,st.TextRain,st.TextGravity,st.TextElastic,st.TextMatrix,st.TextNeon,st.TextGlitch3D,st.TextDissolve,st.TextOrganic,st.TextBreathe,st.TextFloral,st.TextSmoke,st.TextVariable,st.TextMagnet,st.TextSpin,st.TextZing,st.TextPerspective,st.TextMirror].includes(ye.type)&&ye.enabled))||[];for(let ye=0;ye<K.length;ye++){let ke=K[ye];const Vt=Tt+ye;let te=0,j=0,mt=1,et=1,J=0,ot=1,ht=ke;Oe.forEach(gt=>{const $=gt.settings||{},bt=$.strength||1,$t=Date.now();if(gt.type===st.Typewriter)this.currentTime*($.speed||1)-Vt*($.stagger||.05)<0&&(ot=0);else if(gt.type===st.Scramble)Math.max(0,Math.min(1,this.currentTime/($.duration||1.5))-Vt*.02)<1&&Math.random()<.3&&(ht="$%#@!*&"[Math.floor(Math.random()*7)]);else if(gt.type===st.Wave)j+=Math.sin(this.currentTime*5*($.speed||1)+Vt*($.frequency||1))*($.amplitude||20)*bt;else if(gt.type===st.Bounce){const Q=Math.max(0,this.currentTime%2-Vt*($.stagger||.1));Q<1&&(j-=Math.abs(Math.sin(Q*Math.PI))*($.height||50)*bt)}else if(gt.type===st.TextTrail){const Q=this.pointerHistory[Math.max(0,this.pointerHistory.length-1-Vt*($.delay||5))];Q&&(te+=(Q.x-(n.x+fe))*bt*.2,j+=(Q.y-(n.y+Lt+j))*bt*.2)}else if(gt.type===st.Reveal3D){const Q=Math.max(0,Math.min(1,this.currentTime*($.speed||1)-Vt*($.stagger||.1)));mt*=Q,et*=Q,ot=Q}else if(gt.type===st.RevealSlide){const Q=Math.max(0,Math.min(1,this.currentTime*1.5-Vt*.05)),rt=(1-Q)*($.distance||40)*bt,lt=$.direction||"up";lt==="up"?j-=rt:lt==="down"?j+=rt:lt==="left"?te-=rt:lt==="right"&&(te+=rt),ot=Q}else if(gt.type===st.RevealBlur){const Q=Math.max(0,Math.min(1,this.currentTime*1.2-Vt*.1));ot=Q,te+=(1-Q)*5}else if(gt.type===st.TextLiquid){const Q=Math.max(0,Math.sin($t*.001*($.speed||1)+Vt*.5));j+=Q*($.amplitude||10)*bt,et*=1+Q*.2}else if(gt.type===st.TextVortex){const Q=$t*.002*($.speed||1)+Vt*.2,rt=(1-(Math.sin($t*.001)*.5+.5))*($.radius||50);te+=Math.cos(Q)*rt*bt,j+=Math.sin(Q)*rt*bt}else if(gt.type===st.TextExplosion){const Q=$.force||1,rt=this.currentTime%2;if(rt<1){const lt=(Vt/K.length-.5)*Math.PI*2,jt=rt*100*Q;te+=Math.cos(lt)*jt*bt,j+=Math.sin(lt)*jt*bt,ot=1-rt}}else if(gt.type===st.TextRain){const Q=$.speed||1,rt=$.height||100,lt=($t*.001*Q+Vt*.1)%1;j-=(1-lt)*rt*bt,ot=lt>.1?1:lt*10}else if(gt.type===st.TextGravity){const Q=$.gravity||9.8,rt=this.currentTime%3/3,lt=.5*Q*Math.pow(rt*10,2);lt<100?j+=lt*bt:j+=100*bt}else if(gt.type===st.TextMatrix){const Q=$.speed||1;if(Math.random()<.1*Q){const lt="0123456789ABCDEF!@#$%^&*";ht=lt[Math.floor(Math.random()*lt.length)]}ot=.3+(Math.sin($t*.01*Q+Vt)+1)/2*.7}else if(gt.type===st.TextNeon){const Q=Math.random()>.95?.5:1;ot=(.7+(Math.sin($t*.005)+1)/2*.3)*Q}else if(gt.type===st.TextDissolve)Math.sin(Vt*1.5+$t*.002*($.speed||1))>.5&&(ot=0);else if(gt.type===st.TextOrganic){const Q=$.speed||1,rt=$.amplitude||10;te+=Math.sin($t*.002*Q+Vt)*rt*bt,j+=Math.cos($t*.0015*Q+Vt*.7)*rt*bt}else if(gt.type===st.TextBreathe){const rt=1+(Math.sin($t*.003+Vt*.2)+1)/2*.2*bt;mt*=rt,et*=rt}else if(gt.type===st.TextSpin){const Q=$.speed||1;J+=$t*.01*Q+Vt}else if(gt.type===st.TextMagnet){const Q=this.pointerHistory[this.pointerHistory.length-1];if(Q){const rt=Q.x-(n.x+fe),lt=Q.y-(n.y+Lt);J=Math.atan2(lt,rt)}}else if(gt.type===st.TextPerspective){const Q=K.length/2,rt=(Vt-Q)/Q,lt=1-Math.abs(rt)*.3*bt;mt*=lt,et*=lt,te+=rt*20*bt}else if(gt.type===st.TextMirror)ot*=.8;else if(gt.type===st.TextFloral){const Q=$.speed||1,rt=$.stagger||.1,lt=($t*.001*Q+Vt*rt)%2;lt<1&&(mt*=lt,et*=lt,J+=lt*Math.PI)}else if(gt.type===st.TextSmoke){const Q=$.speed||1,rt=$.height||50,lt=($t*5e-4*Q+Vt*.2)%1;j-=lt*rt*bt,te+=Math.sin($t*.002+Vt)*5*bt,ot=1-lt}else if(gt.type===st.TextVariable){const Q=$.speed||1,rt=$.intensity||1.5,lt=(Math.sin($t*.004*Q+Vt*.3)+1)/2;mt*=1+lt*(rt-1)*bt}else if(gt.type===st.TextZing){const Q=$.speed||2,rt=$.distance||100,lt=($t*.002*Q+Vt*.05)%1;te+=(1-lt)*rt*bt,ot=lt}else if(gt.type===st.TextElastic){const Q=$.stiffness||.2,rt=$.damping||.1,lt=Math.sin($t*.01)*Math.exp(-$t*.001*rt);et*=1+lt*Q*bt}else if(gt.type===st.TextGlitch3D){const Q=$.intensity||5;Math.random()<.2&&(te+=(Math.random()-.5)*Q,j+=(Math.random()-.5)*Q,ot=.8)}else if(gt.type===st.GlitchText){const Q=$.intensity||5;Math.random()<.1&&(te+=(Math.random()-.5)*Q,j+=(Math.random()-.5)*Q,Math.random()<.05&&(ot=.5))}});let At=null,ft=o.textDecoration||"none",St=S;if(o.enableSegments===!0&&((se=o.segments)==null?void 0:se.length)>0){let gt=0,$=null;for(const bt of o.segments){if(Vt<gt+(bt.text||"").length){$=bt;break}gt+=(bt.text||"").length}if($){let bt=$.fontFamily||o.fontFamily||"Inter";c.forEach(rt=>{const lt=new RegExp(`[\\s-]${rt}$`,"i");lt.test(bt)&&(bt=bt.replace(lt,"").trim())});const $t=this.mapFontWeight(($.fontWeight||o.fontWeight||"400").toString()),Q=$.fontStyle||f;St=$.fontSize||S,t.font=`${Q} ${$t} ${St}px "${bt}", sans-serif`,$.fill&&(At=$.fill),$.textDecoration&&(ft=$.textDecoration),St<O&&(j+=(O-St)*.85)}}else t.font=C;const Dt=t.globalAlpha;t.globalAlpha*=ot,t.save();const Bt=t.measureText(ht).width;if(q&&Y>0){const gt=fe-xt+Bt/2,bt=(Ie+gt)/Y,$t=this.getPointOnPath(q.geo,q.w,q.h,Math.abs(bt%1)),Q=$t.angle,rt=Lt+j+(o.pathOffsetY||0),lt=o.pathSide==="right"?-1:1,jt=Math.cos(Q+Math.PI/2)*rt*lt,oe=Math.sin(Q+Math.PI/2)*rt*lt;t.translate($t.x+jt+te,$t.y+oe),t.rotate(Q+J+(lt===-1?Math.PI:0))}else t.translate(fe+te+Bt/2,Lt+j),J!==0&&t.rotate(J);if(t.scale(mt,et),At&&!r&&!l){const gt=this.createCanvasFill(t,At,B,G);t.fillStyle=gt||At.color||"#000000"}else if(!r&&!l){const gt=this.createCanvasFill(t,e.fill,B,G);t.fillStyle=gt||e.fill.color||"#000000"}if(ot>0)if(r||l){const gt=l?"#000000":this.createCanvasFill(t,e.fill,B,G);t.fillStyle=gt||e.fill.color||"#ffffff",t.fillText(ht,-Bt/2,0)}else Ct?t.strokeText(ht,-Bt/2,0):t.fillText(ht,-Bt/2,0);ft!=="none"&&!r&&this.drawTextDecoration(t,ft,0,0,Bt,St),t.restore(),t.globalAlpha=Dt,M==="justify"&&le>0&&ht===" "&&!ce?fe+=Bt+I+le:fe+=Bt+I}t.textAlign=Qt}};if(r){let K=0,ut=U;(k||[]).forEach(Lt=>{const Ct=Lt.text||"",Tt=u.indexOf(Ct,K);Tt!==-1&&(K=Tt);let Et=-B/2;M==="center"?Et=0:M==="right"&&(Et=B/2),x(Ct,Et,ut,!1,K),K+=Ct.length,ut+=F})}else if(l){let K=0,ut=U;(k||[]).forEach(Lt=>{const Ct=Lt.text||"";let Tt=-B/2;M==="center"?Tt=0:M==="right"&&(Tt=B/2),x(Ct,Tt,ut,!1,K),K+=Ct.length,K<u.length&&(u[K]===`
12
- `||u[K]==="\r")&&(K++,u[K-1]==="\r"&&u[K]===`
13
- `&&K++),ut+=F})}else{if(e.fill){const ut=t.globalAlpha,Lt=this.createCanvasFill(t,e.fill,B,G);t.fillStyle=Lt||e.fill.color||"#000000",t.globalAlpha=ut*this.normalizeOpacity(e.fill.opacity??100);const Ct=P.fullText||(o.enableSegments?(o.segments||[]).map(tt=>{let at=tt.text||"";const ct=tt.textCase||o.textCase||"none";return ct==="uppercase"?at.toUpperCase():ct==="lowercase"?at.toLowerCase():ct==="capitalize"?at.replace(/\b\w/g,Pt=>Pt.toUpperCase()):at}).join(""):u);let Tt=0,Et=U;(k||[]).forEach(tt=>{const at=tt.text||"";let ct=-B/2;M==="center"?ct=0:M==="right"&&(ct=B/2),x(at,ct,Et,!1,Tt),Tt+=at.length,Et+=F,Tt<Ct.length&&(Ct[Tt]===`
14
- `||Ct[Tt]==="\r")&&(T>0&&(Et+=T),Tt++,Ct[Tt-1]==="\r"&&Ct[Tt]===`
15
- `&&Tt++)}),t.globalAlpha=ut}const K=o.paragraphRule;if(K&&(((yt=K.top)==null?void 0:yt.width)>0||((Ft=K.bottom)==null?void 0:Ft.width)>0)){let ut=0;(k||[]).forEach((Lt,Ct)=>{var tt,at;const Et=ut===0||ut<u.length&&(u[ut]===`
16
- `||u[ut]==="\r");if(Et&&Ct>0&&ut++,Et){if(((tt=K.top)==null?void 0:tt.width)>0){const ct=U+Ct*F-K.top.offset;t.strokeStyle=K.top.color||"#000000",t.lineWidth=K.top.width,t.beginPath();const Pt=-i/2+F*.2;t.moveTo(Pt,ct),t.lineTo(i/2-F*.2,ct),t.stroke()}if(((at=K.bottom)==null?void 0:at.width)>0){const ct=U+(Ct+1)*F-K.bottom.offset;t.strokeStyle=K.bottom.color||"#000000",t.lineWidth=K.bottom.width,t.beginPath();const Pt=-i/2+F*.2;t.moveTo(Pt,ct),t.lineTo(i/2-F*.2,ct),t.stroke()}}ut+=(Lt.text||"").length})}if(e.stroke&&e.stroke.width>0){const ut=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 Ct=t.getTransform(),Tt=Math.sqrt(Ct.a*Ct.a+Ct.b*Ct.b)||1,Et=window.devicePixelRatio||1;t.lineWidth=(e.stroke.width||1)*Et/Tt,t.globalAlpha=ut*this.normalizeOpacity(e.stroke.opacity??100);let tt=0,at=U;(k||[]).forEach(ct=>{let Pt=-B/2;M==="center"?Pt=0:M==="right"&&(Pt=B/2),x(ct.text,Pt,at,!0,tt),tt+=(ct.text||"").length,at+=F,tt<u.length&&(u[tt]===`
17
- `||u[tt]==="\r")&&(T>0&&(at+=T),tt++,u[tt-1]==="\r"&&u[tt]===`
18
- `&&tt++)}),t.globalAlpha=ut}}}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,u=(a.width||1)*d/l,g=(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 m=this.createCanvasFill(t,a.fill,e,n);m?t.strokeStyle=m:t.strokeStyle=a.color||"#000000"}else t.strokeStyle=a.color||"#000000";const f=t.globalAlpha;t.globalAlpha=f*this.normalizeOpacity(a.opacity??100),t.lineWidth=u,t.lineCap=a.lineCap||"round",t.lineJoin=a.lineJoin||"round",a.miterLimit!==void 0&&(t.miterLimit=a.miterLimit);const h=a.trimStart??0,S=a.trimEnd??1,y=a.trimOffset??0,c=a.dashOffset??0,v=a.dashArray||[];if(h!==0||S!==1||y!==0){const m=this.getPerimeter(o,e,n);if(m>0){const C=Math.max(0,Math.min(1,h)),w=Math.max(0,Math.min(1,S));if(C<w){const M=m*(w-C),I=m-M,A=-(m*(C+y%1));t.setLineDash([M,I]),t.lineDashOffset=A-c*m}else if(C===w)t.setLineDash([0,m]);else{const M=m*(1-C+w),I=m-M,A=-(m*C);t.setLineDash([M,I]),t.lineDashOffset=A-c*m}}}else if(v.length>0||c!==0){v.length>0&&t.setLineDash(v);const m=this.getPerimeter(o,e,n);t.lineDashOffset=-(c*m)}if((o==null?void 0:o.type)==="Line"||e===0||n===0)this.applyPath(t,o,e,n,i),t.stroke();else if(g==="inside")t.lineWidth=u*2,t.save(),this.applyPath(t,o,e,n,i),t.clip(),t.stroke(),t.restore();else if(g==="outside"){t.save(),t.beginPath();const m=Math.max(e,n,2e4);t.rect(-m,-m,m*2,m*2),this._tracePath(t,o,e,n,i),t.clip("evenodd"),t.lineWidth=u*2,t.beginPath(),this.applyPath(t,o,e,n,i),t.stroke(),t.restore()}else t.lineWidth=u,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,u=a,g=e[r-1].out_x,p=e[r-1].out_y;if(g!==void 0||l.in_x!==void 0?n+=this.getBezierLength(d,u,g??d,p??u,l.in_x??l.x,l.in_y??l.y,l.x,l.y):n+=Math.sqrt((l.x-d)**2+(l.y-u)**2),i=l.x,a=l.y,l.closePath||r===e.length-1&&(t.is_closed||t.isClosed)){const f=i,h=a,S=[...e.slice(0,r+1)].reverse().find(M=>M.moveTo)||e[0],y=S.x,c=S.y,v=e[r].out_x,m=e[r].out_y,C=S.in_x,w=S.in_y;v!==void 0||C!==void 0?n+=this.getBezierLength(f,h,v??f,m??h,C??y,w??c,y,c):n+=Math.sqrt((y-f)**2+(c-h)**2)}}return n}default:return(s+o)*2}}getBezierLength(t,s,o,e,n,i,a,r,l=10){let d=0,u=t,g=s;for(let p=1;p<=l;p++){const f=p/l,h=1-f,S=f*f,y=h*h,c=y*h,v=S*f,m=c*t+3*y*f*o+3*h*S*n+v*a,C=c*s+3*y*f*e+3*h*S*i+v*r,w=m-u,M=C-g;d+=Math.sqrt(w*w+M*M),u=m,g=C}return d}getBezierTAtLength(t,s,o,e,n,i,a,r,l,d=20){if(t<=0)return 0;let u=0,g=s,p=o;for(let f=1;f<=d;f++){const h=f/d,S=1-h,y=h*h,c=S*S,v=c*S,m=y*h,C=v*s+3*c*h*e+3*S*y*i+m*r,w=v*o+3*c*h*n+3*S*y*a+m*l,M=C-g,I=w-p,A=Math.sqrt(M*M+I*I);if(u+A>=t){const _=t-u,T=A===0?0:_/A;return(f-1+T)/d}u+=A,g=C,p=w}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,u=(r+l)/2,p=this.getPerimeter(t,s,o)*e;let f=0;const h=[];let S=n[0],y=n[0];for(let c=1;c<n.length;c++){const v=n[c];if(v.moveTo){S=v,y=v;continue}h.push({p0:S,p1:v}),(v.closePath||c===n.length-1&&(t.is_closed||t.isClosed))&&h.push({p0:v,p1:y}),S=v}for(const c of h){const v=c.p0,m=c.p1;let C=0;const w=v.out_x!==void 0||m.in_x!==void 0;if(w?C=this.getBezierLength(v.x,v.y,v.out_x??v.x,v.out_y??v.y,m.in_x??m.x,m.in_y??m.y,m.x,m.y):C=Math.sqrt((m.x-v.x)**2+(m.y-v.y)**2),f+C>=p||c===h[h.length-1]){let M=0;if(w)return M=this.getBezierTAtLength(p-f,v.x,v.y,v.out_x??v.x,v.out_y??v.y,m.in_x??m.x,m.in_y??m.y,m.x,m.y,20),this.getBezierPointAndAngle(M,v,m,d,u);{M=C===0?0:(p-f)/C;const I=v.x+(m.x-v.x)*M-d,A=v.y+(m.y-v.y)*M-u,_=Math.atan2(m.y-v.y,m.x-v.x);return{x:I,y:A,angle:_}}}f+=C}}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),u=i*Math.sin(l),g=-n*Math.sin(l),p=i*Math.cos(l),f=Math.atan2(p,g);return{x:d,y:u,angle:f}}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,u=0;return r<n?(l=-n/2+r,d=-i/2,u=0):r<n+i?(l=n/2,d=-i/2+(r-n),u=Math.PI/2):r<2*n+i?(l=n/2-(r-(n+i)),d=i/2,u=Math.PI):(l=-n/2,d=i/2-(r-(2*n+i)),u=-Math.PI/2),{x:l,y:d,angle:u}}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,u=o.in_y??o.y,g=o.x,p=o.y,f=1-t,h=t*t,S=f*f,y=S*f,c=h*t,v=y*i+3*S*t*r+3*f*h*d+c*g-e,m=y*a+3*S*t*l+3*f*h*u+c*p-n,C=3*S*(r-i)+6*f*t*(d-r)+3*h*(g-d),w=3*S*(l-a)+6*f*t*(u-l)+3*h*(p-u),M=Math.atan2(w,C);return{x:v,y:m,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 f,h,S;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 y=Math.tan(e*Math.PI/180),c=Math.tan(n*Math.PI/180);t.transform(1+y*c,c,y,1,0,0)}const i=o.rotate_x!==void 0?o.rotate_x:((f=o.transform)==null?void 0:f.rotate_x)??0,a=o.rotate_y!==void 0?o.rotate_y:((h=o.transform)==null?void 0:h.rotate_y)??0,l=1+(o.translate_z!==void 0?o.translate_z:((S=o.transform)==null?void 0:S.translate_z)??0)/1e3,d=(o.flip_x===!0?-1:1)*Math.cos(a*Math.PI/180)*l,u=(o.flip_y===!0?-1:1)*Math.cos(i*Math.PI/180)*l,g=(o.scale_x??1)*d,p=(o.scale_y??1)*u;t.scale(g,p)}applyInnerGlowOverlay(t,s,o,e,n,i,a){var y,c;const r=a||s.style||{},l=r==null?void 0:r.effect,u=((r==null?void 0:r.effects)||(l?[l]:[])).find(v=>v.isEnabled!==!1&&v.type==="Glow"&&(v.mode==="inner"||v.mode==="Inner Glow"));if(!u)return;t.save(),t.beginPath(),this.applyPath(t,o,e,n,i),t.clip();const g=u.blur||10,p=1e4,f=t.getTransform();let h=u.color||"white";(c=(y=this.artboard)==null?void 0:y.tokens)!=null&&c.colors&&this.artboard.tokens.colors[h]&&(h=this.artboard.tokens.colors[h]),t.shadowColor=h,t.shadowBlur=g,t.shadowOffsetX=p*f.a,t.shadowOffsetY=p*f.b,t.translate(-p,0),t.lineWidth=g+5,t.strokeStyle=h;const S=Math.min(u.intensity||1,5);for(let v=0;v<S;v++)t.beginPath(),this.applyPath(t,o,e,n,i),t.stroke();t.restore()}applyArtEffectOverlay(t,s,o,e,n,i){var p,f,h,S,y;const a=this.objectStates.get(s.id),r=((p=a==null?void 0:a.style)==null?void 0:p.artEffect)||s.artEffect||((f=s.style)==null?void 0:f.artEffect);if(!r||!r.enabled)return;const l=r.type,d=r.intensity??.5,u=r.speed??1,g=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 v=this.currentTime*u%2/2,m=t.createLinearGradient(-e,-n,e,n);m.addColorStop(Math.max(0,v-.2),"rgba(255,255,255,0)"),m.addColorStop(v,`rgba(255,255,255,${d*.8})`),m.addColorStop(Math.min(1,v+.2),"rgba(255,255,255,0)"),t.fillStyle=m,t.globalCompositeOperation="screen",t.fillRect(-e/2,-n/2,e,n),t.globalCompositeOperation="source-over"}else if(l==="glint_overlay"){let m=((this._lastPointerPos||{x:0}).x-(((h=s.transform)==null?void 0:h.x)??0)+300)/600;m=Math.max(-.2,Math.min(1.2,m));const C=t.createLinearGradient(-e,-n,e,n);C.addColorStop(Math.max(0,m-.15),"rgba(255,255,255,0)"),C.addColorStop(Math.max(0,Math.min(1,m)),`rgba(255,255,255,${d})`),C.addColorStop(Math.min(1,m+.15),"rgba(255,255,255,0)"),t.fillStyle=C,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},v=c.x-(((S=s.transform)==null?void 0:S.x)??0),m=c.y-(((y=s.transform)==null?void 0:y.y)??0),C=t.createLinearGradient(v>0?-e/2:e/2,m>0?-n/2:n/2,v>0?e/2:-e/2,m>0?n/2:-n/2);C.addColorStop(0,`rgba(0,0,0,${d*.6})`),C.addColorStop(.4,"rgba(0,0,0,0)"),C.addColorStop(.5,`rgba(255,255,255,${d*.4})`),C.addColorStop(1,`rgba(0,0,0,${d*.2})`),t.fillStyle=C,t.globalCompositeOperation="overlay",t.fillRect(-e/2,-n/2,e,n),t.globalCompositeOperation="source-over",t.beginPath(),v>0&&m>0?(t.moveTo(e/2-40,n/2),t.lineTo(e/2,n/2-40),t.lineTo(e/2-40,n/2-40)):v<0&&m>0?(t.moveTo(-e/2+40,n/2),t.lineTo(-e/2,n/2-40),t.lineTo(-e/2+40,n/2-40)):v>0&&m<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=v>0?-2:2,t.shadowOffsetY=m>0?-2:2,t.fill()}else if(l==="crumple_overlay"){const c=Math.floor(e/g),v=document.createElement("canvas");v.width=c,v.height=Math.floor(n/g);const m=v.getContext("2d"),C=m.createImageData(v.width,v.height);for(let w=0;w<C.data.length;w+=4){const M=Math.random()>.95?150:255;C.data[w]=M,C.data[w+1]=M,C.data[w+2]=M,C.data[w+3]=255*d}m.putImageData(C,0,0),t.globalCompositeOperation="multiply",t.imageSmoothingEnabled=!1,t.drawImage(v,-e/2,-n/2,e,n)}else if(l==="acid_gradient"||l==="acid_rave"){const c=this.currentTime*u,v=r.color1,m=r.color2,C=t.createLinearGradient(-e/2,-n/2,e/2,n/2);if(v&&m){const w=c*60%360;C.addColorStop(0,this._shiftHue(v,w,d*.7)),C.addColorStop(1,this._shiftHue(m,(w+180)%360,d*.7))}else{const w=c*100%360,M=(w+180)%360;C.addColorStop(0,`hsla(${w}, 80%, 50%, ${d*.5})`),C.addColorStop(1,`hsla(${M}, 80%, 50%, ${d*.5})`)}t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-n/2,e,n)}else if(l==="halftone"){const c=Math.max(2,g*(1-d*.8)),v=document.createElement("canvas");v.width=c,v.height=c;const m=v.getContext("2d");if(m){m.fillStyle="black",m.beginPath(),m.arc(c/2,c/2,c/2*d,0,Math.PI*2),m.fill();const C=t.createPattern(v,"repeat");C&&(t.globalAlpha=.3*d,t.fillStyle=C,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 v=0;v<c;v++){const m=Math.random()>.5?255:0;t.fillStyle=`rgba(${m}, ${m}, ${m}, ${.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(g*(1-d*.5))),v=document.createElement("canvas"),m=Math.max(1,Math.ceil(e/c)),C=Math.max(1,Math.ceil(n/c));v.width=m,v.height=C;const w=v.getContext("2d");if(w){w.imageSmoothingEnabled=!1;const M=t.getTransform(),I=M.e-e/2,A=M.f-n/2;w.drawImage(t.canvas,I,A,e,n,0,0,m,C),t.imageSmoothingEnabled=!1,t.drawImage(v,0,0,m,C,-e/2,-n/2,e,n),t.imageSmoothingEnabled=!0}}else if(l==="glitch"){const c=this.currentTime*u,v=r.chaosAmount??.2,m=Math.max(3,Math.floor(8*d)),C=d*e*.15;t.globalCompositeOperation="screen",t.globalAlpha=d*.4;const w=C*.3;t.fillStyle="rgba(255, 0, 0, 0.4)",t.fillRect(-e/2+w,-n/2,e,n),t.fillStyle="rgba(0, 255, 255, 0.4)",t.fillRect(-e/2-w,-n/2,e,n),t.globalCompositeOperation="source-over",t.globalAlpha=1;const M=n/m;for(let I=0;I<m;I++){const A=Math.sin(I*127.1+c*311.7*u)*43758.5,_=A-Math.floor(A);if(_>1-v){const T=(_-(1-v))/v*C*(Math.random()>.5?1:-1),L=-n/2+I*M,F=t.getTransform(),D=F.e-e/2+T,R=F.f+L;t.save(),t.beginPath(),t.rect(-e/2,L,e,M),t.clip(),t.globalAlpha=.8,t.drawImage(t.canvas,D,R,e,M,-e/2+T,L,e,M),t.restore()}}}t.restore()}}_shiftHue(t,s,o){let e=0,n=0,i=0;if(t.startsWith("#")){const p=t.replace("#","");e=parseInt(p.substring(0,2),16)/255,n=parseInt(p.substring(2,4),16)/255,i=parseInt(p.substring(4,6),16)/255}const a=Math.max(e,n,i),r=Math.min(e,n,i);let l=0,d=0,u=(a+r)/2;if(a!==r){const p=a-r;switch(d=u>.5?p/(2-a-r):p/(a+r),a){case e:l=((n-i)/p+(n<i?6:0))/6;break;case n:l=((i-e)/p+2)/6;break;case i:l=((e-n)/p+4)/6;break}}return`hsla(${(((l*360+s)%360+360)%360).toFixed(0)}, ${(d*100).toFixed(0)}%, ${(u*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,u=i.color??"rgba(255,255,255,0.2)";t.save(),this.applyPath(t,s,o,e,n),t.clip();const g=t.getTransform(),p=t.canvas;try{const S=document.createElement("canvas");S.width=Math.max(1,Math.ceil(o)),S.height=Math.max(1,Math.ceil(e));const y=S.getContext("2d");if(y){y.save(),y.translate(o/2,e/2);const c=i.magnification||1;if(c!==1&&y.scale(c,c),typeof g.inverse=="function"){const C=g.inverse();y.transform(C.a,C.b,C.c,C.d,C.e,C.f)}else{const C=g.a*g.d-g.b*g.c;C!==0&&y.transform(g.d/C,-g.b/C,-g.c/C,g.a/C,(g.c*g.f-g.d*g.e)/C,(g.b*g.e-g.a*g.f)/C)}y.drawImage(p,0,0),y.restore();const v=document.createElement("canvas");v.width=S.width,v.height=S.height;const m=v.getContext("2d");m.filter=`blur(${r}px)`,m.drawImage(S,0,0),t.globalCompositeOperation="destination-out",t.fillRect(-o/2,-e/2,o,e),t.globalCompositeOperation="source-over",t.globalAlpha=1,t.drawImage(v,-o/2,-e/2,o,e)}}catch(S){console.error("Background blur failed:",S)}t.globalCompositeOperation="source-over",t.globalAlpha=l,t.fillStyle=u,t.fillRect(-o/2,-e/2,o,e),t.globalAlpha=1;const f=t.createLinearGradient(-o/2,-e/2,o/2,e/2);if(f.addColorStop(0,"rgba(255,255,255,0.12)"),f.addColorStop(.3,"rgba(255,255,255,0.04)"),f.addColorStop(.5,"rgba(255,255,255,0.0)"),f.addColorStop(1,"rgba(255,255,255,0.0)"),t.fillStyle=f,t.fillRect(-o/2,-e/2,o,e),d>0){if(t.globalAlpha=d/100,!this._noiseTileCanvas){const y=document.createElement("canvas");y.width=64,y.height=64;const c=y.getContext("2d"),v=c.createImageData(64,64),m=v.data;for(let C=0;C<m.length;C+=4){const w=Math.floor(Math.random()*255);m[C]=w,m[C+1]=w,m[C+2]=w,m[C+3]=18}c.putImageData(v,0,0),this._noiseTileCanvas=y}const S=t.createPattern(this._noiseTileCanvas,"repeat");S&&(t.fillStyle=S,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,u=i*Math.PI/180,g=a*Math.PI/180,p=u+g;a>=360&&r<=0?t.ellipse(0,0,l,d,0,0,Math.PI*2):(t.ellipse(0,0,l,d,0,u,p,!1),r>0?t.ellipse(0,0,l*r,d*r,0,p,u,!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),u=a*Math.sin(l);r===0?t.moveTo(d,u):t.lineTo(d,u)}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,u=l%2===0?a:r,g=u*Math.cos(d),p=u*Math.sin(d);l===0?t.moveTo(g,p):t.lineTo(g,p)}t.closePath()}else if(s!=null&&s.points&&["path","custom","customshape","shape","subtract","union","intersect","exclude","booleanoperation"].includes((s.type||"").toLowerCase())){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(g=>{typeof g.x=="number"&&typeof g.y=="number"&&(i=Math.min(i,g.x),a=Math.max(a,g.x),r=Math.min(r,g.y),l=Math.max(l,g.y),g.out_x!==void 0&&(i=Math.min(i,g.out_x),a=Math.max(a,g.out_x)),g.out_y!==void 0&&(r=Math.min(r,g.out_y),l=Math.max(l,g.out_y)),g.in_x!==void 0&&(i=Math.min(i,g.in_x),a=Math.max(a,g.in_x)),g.in_y!==void 0&&(r=Math.min(r,g.in_y),l=Math.max(l,g.in_y)))}),i===1/0)return;let d=(i+a)/2,u=(r+l)/2;if(isNaN(d)||isNaN(u)){this.warn("[Engine] Invalid path center:",d,u);return}s.points.forEach((g,p)=>{if(p===0||g.moveTo)t.moveTo(g.x-d,g.y-u);else{const f=s.points[p-1];if(!f)return;const h=(f.out_x??f.x)-d,S=(f.out_y??f.y)-u,y=(g.in_x??g.x)-d,c=(g.in_y??g.y)-u;isNaN(h)||isNaN(y)||isNaN(g.x)?t.lineTo(g.x-d,g.y-u):t.bezierCurveTo(h,S,y,c,g.x-d,g.y-u)}if(g.closePath||p===s.points.length-1&&(s.is_closed||s.isClosed)){const f=[...s.points.slice(0,p+1)].reverse().find(h=>h.moveTo)||s.points[0];f&&(g.out_x!==void 0||f.in_x!==void 0)&&t.bezierCurveTo((g.out_x??g.x)-d,(g.out_y??g.y)-u,(f.in_x??f.x)-d,(f.in_y??f.y)-u,f.x-d,f.y-u),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(g=>{i=Math.min(i,g.x),a=Math.max(a,g.x),r=Math.min(r,g.y),l=Math.max(l,g.y)});const d=(i+a)/2,u=(r+l)/2;s.points.forEach((g,p)=>{if(p===0)t.moveTo(g.x-d,g.y-u);else{const f=s.points[p-1];f.out_x!==void 0||g.in_x!==void 0?t.bezierCurveTo((f.out_x??f.x)-d,(f.out_y??f.y)-u,(g.in_x??g.x)-d,(g.in_y??g.y)-u,g.x-d,g.y-u):t.lineTo(g.x-d,g.y-u)}(g.closePath||p===s.points.length-1&&(s.is_closed||s.isClosed))&&t.closePath()})}}}renderInputBox(t,s){var ie,se,Qt,ce,le,qt,Se,Ce,Ie,fe,Oe,ye,ke,Vt,te,j,mt,et,J,ot,ht,At;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=s.geometry||{},i=s.style||{},a=this.focusedId===s.id,r=this.lastHoveredObjectId===s.id,l=e.previewState||"default",d=l==="focused"||l==="active"||!e.disabled&&a,u=l==="hover"||!e.disabled&&r&&!d,g=l==="disabled"||!!e.disabled,p=l==="error"||!!e.error,f=e.inputType==="textarea"||e.multiline===!0;let h={};g&&e.disabledStyle&&Object.keys(e.disabledStyle).length>0?h=e.disabledStyle:p&&e.errorStyle&&Object.keys(e.errorStyle).length>0?h=e.errorStyle:d?h={...e.focusedStyle||{},...e.activeStyle||{}}:u&&(h={...e.hoveredStyle||{},...e.hoverStyle||{}});const S=Number(h.scale??1);S!==1&&t.scale(S,S);const y=Number(h.width??n.width)||250,c=Number(h.height??n.height)||45,v=e.label||{visible:!0,text:"Label"},m=e.helperText||{visible:!1,text:"Helper text"},C=e.leftIcon||{visible:!1},w=e.rightIcon||{visible:!1},M=((ie=h.leftIcon)==null?void 0:ie.color)||h.leftIconColor||h.iconColor,I=((se=h.rightIcon)==null?void 0:se.color)||h.rightIconColor||h.iconColor,A={...C,...h.leftIcon||{},...M?{color:M}:{}},_={...w,...h.rightIcon||{},...I?{color:I}:{}};h.leftIconVisible!==void 0&&(A.visible=h.leftIconVisible),h.rightIconVisible!==void 0&&(_.visible=h.rightIconVisible),((Qt=h.leftIcon)==null?void 0:Qt.visible)!==void 0&&(A.visible=h.leftIcon.visible),((ce=h.rightIcon)==null?void 0:ce.visible)!==void 0&&(_.visible=h.rightIcon.visible);const T=n.corner_radius??n.cornerRadius,L=Array.isArray(T)?{tl:T[0],tr:T[1],br:T[2],bl:T[3]}:T&&typeof T=="object"?T:void 0,F=h.cornerRadius??h.corner_radius,D=Number(F??e.cornerRadius??e.corner_radius??T??e.radius??8),R=h.corners??(F!==void 0?{tl:D,tr:D,bl:D,br:D}:e.corners??L??{tl:D,tr:D,bl:D,br:D}),X=[Number(R.tl??D),Number(R.tr??D),Number(R.br??D),Number(R.bl??D)],P=(ft,St,Dt,Bt,gt,$=0)=>{const bt=Math.max(0,Dt-$*2),$t=Math.max(0,Bt-$*2);let[Q,rt,lt,jt]=gt.map(Rt=>Math.max(0,(Number(Rt)||0)-$));const oe=Math.min(bt,$t)/2;Q=Math.min(Q,oe),rt=Math.min(rt,oe),lt=Math.min(lt,oe),jt=Math.min(jt,oe),t.beginPath(),t.roundRect?t.roundRect(ft+$,St+$,bt,$t,[Q,rt,lt,jt]):(t.moveTo(ft+$+Q,St+$),t.lineTo(ft+$+bt-rt,St+$),t.arcTo(ft+$+bt,St+$,ft+$+bt,St+$+rt,rt),t.lineTo(ft+$+bt,St+$+$t-lt),t.arcTo(ft+$+bt,St+$+$t,ft+$+bt-lt,St+$+$t,lt),t.lineTo(ft+$+jt,St+$+$t),t.arcTo(ft+$,St+$+$t,ft+$,St+$+$t-jt,jt),t.lineTo(ft+$+Q,St+$),t.arcTo(ft+$,St+$,ft+$+Q,St+$,Q),t.closePath())};let k=h.backgroundColor??e.backgroundColor??((le=i.fill)==null?void 0:le.color)??"rgba(31, 41, 55, 1)",O=h.borderColor??e.borderColor??((Se=(qt=i.stroke)==null?void 0:qt.fill)==null?void 0:Se.color)??((Ce=i.stroke)==null?void 0:Ce.color)??"rgba(55, 65, 81, 1)",E=Number(h.borderWidth??e.borderWidth??((Ie=i.stroke)==null?void 0:Ie.width)??1),N=h.color??e.color??((fe=i.fill)==null?void 0:fe.color)??"#ffffff",W=h.placeholderColor??e.placeholderColor??"rgba(156, 163, 175, 1)",B=Number(h.fontSize??e.fontSize??14),G=h.caretColor??e.caretColor??e.accentColor??"#3b82f6";!h.borderColor&&!h.borderWidth&&(d&&!g?(O=e.focusBorderColor||e.accentColor||"#3b82f6",E=Math.max(E,1.5)):u&&!g?(O=e.hoverBorderColor||"#64748b",k=e.hoverBackgroundColor||k):g?(k=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",O=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):p&&(O="rgba(239, 68, 68, 1)",E=Math.max(E,2)));const z=E>0?E/2:0,V=this.createCanvasFill(t,k,y,c);if(V&&k!=="transparent"&&(P(-y/2,-c/2,y,c,X,z),t.fillStyle=V,t.fill()),E>0){const ft=this.createCanvasFill(t,O,y,c);ft&&O!=="transparent"&&(P(-y/2,-c/2,y,c,X,z),t.strokeStyle=ft,t.lineWidth=E,t.lineCap="round",t.lineJoin="round",t.stroke())}if(d&&!g){t.save();const ft=-3,St=X.map(gt=>Math.max(0,gt+3));P(-y/2+ft,-c/2+ft,y-ft*2,c-ft*2,St);const Dt=h.borderColor||((Oe=e.activeStyle)==null?void 0:Oe.borderColor)||G||"rgba(59, 130, 246, 0.4)",Bt=this.createCanvasFill(t,Dt,y,c)||"rgba(59, 130, 246, 0.4)";t.strokeStyle=Bt,t.lineWidth=2,t.lineCap="round",t.lineJoin="round",t.stroke(),t.restore()}const U=e.fontFamily||"Inter",q=e.fontWeight||400,Y=B,H=e.inputType==="number"&&((ye=e.number)==null?void 0:ye.showSteppers)!==!1,x=24,dt=H?x+4:0,_t=String(e.text??e.value??"");let vt="Enter text...";if(e.inputType==="tel")vt=`${((ke=e.tel)==null?void 0:ke.dialCode)||"+1"} (555) 000-0000`;else if(e.inputType==="number"){const ft=(Vt=e.number)!=null&&Vt.prefix?`${e.number.prefix} `:"",St=(te=e.number)!=null&&te.suffix?` ${e.number.suffix}`:"";vt=`${ft}0.00${St}`}else e.inputType==="email"?vt="user@example.com":e.inputType==="search"?vt="Search anything...":e.inputType==="url"?vt="https://example.com":e.inputType==="password"?vt="••••••••":e.inputType==="textarea"&&(vt="Enter text...");const Yt=e.placeholder||vt,Mt=!_t,Wt=e.inputType==="password",Ot=_.mode==="password-toggle"||Wt&&_.visible!==!1,yt=_.mode==="clear"||e.inputType==="search"&&!!_t,Ft=(ft,St)=>{var rt;let Dt=ft.svgPath||"";const Bt=ft.char||"";if(!Dt&&!Bt&&(St?e.inputType==="search"&&(Dt="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"):Ot?Dt=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":yt&&(Dt="M18 6L6 18M6 6l12 12")),!(ft.visible||!!(Dt||Bt)&&(!St&&(Ot||yt)||St&&e.inputType==="search")))return;const $=ft.size||16,bt=(ft.offset??16)+(St?0:dt),$t=typeof ft.color=="string"?ft.color:((rt=ft.color)==null?void 0:rt.color)||"#9ca3af",Q=St?-(y/2)+bt:y/2-bt;if(Dt){if(t.save(),t.translate(Q,0),!Dt.startsWith("<svg")){const lt=new Path2D(Dt),jt=$/24;t.scale(jt,jt),t.translate(-12,-12),Dt.includes("M18 6L6 18")||Dt.includes("M1 1l22 22")||Dt.includes("M21 21")||Dt.includes("M11 19a8")?(t.strokeStyle=$t,t.lineWidth=2/jt,t.lineCap="round",t.lineJoin="round",t.stroke(lt)):(t.fillStyle=$t,t.fill(lt))}t.restore()}else Bt&&(t.save(),t.translate(Q,0),t.fillStyle=$t,t.font=`${$}px sans-serif`,t.textAlign="center",t.textBaseline="middle",t.fillText(Bt,0,0),t.restore())};if(Ft(A,!0),Ft(_,!1),H){const ft=y/2-x-4;t.save(),t.strokeStyle=O||"rgba(55, 65, 81, 0.5)",t.lineWidth=1,t.beginPath(),t.moveTo(ft,-c/2+6),t.lineTo(ft,c/2-6),t.stroke(),t.beginPath(),t.moveTo(ft,0),t.lineTo(y/2-4,0),t.stroke(),t.fillStyle=N||"rgba(156, 163, 175, 0.8)",t.font=`600 8px "${U}", sans-serif`,t.textAlign="center",t.textBaseline="middle",t.fillText("▲",ft+x/2,-c/4),t.fillText("▼",ft+x/2,c/4),t.restore()}const K=((j=e.padding)==null?void 0:j.left)??e.inputPadding??12,ut=((mt=e.padding)==null?void 0:mt.right)??e.inputPadding??12,Lt=A.visible||e.inputType==="search",Ct=_.visible||Ot||yt,Tt=Lt?(A.offset??16)+(A.size||16)/2+8:K,Et=Ct?(_.offset??16)+(_.size||16)/2+8+dt:ut+dt,tt=-(y/2)+Tt,at=Math.max(0,y-Tt-Et);let ct=_t||Yt;if(e.inputType==="number"&&_t){const ft=(et=e.number)!=null&&et.prefix?`${e.number.prefix} `:"",St=(J=e.number)!=null&&J.suffix?` ${e.number.suffix}`:"";ct=`${ft}${_t}${St}`}const Pt=Wt&&_t?e.passwordVisible?_t:"•".repeat(_t.length):ct,kt=Mt?W:N;if(t.font=`${q} ${Y}px "${U}", sans-serif`,t.fillStyle=kt,t.textAlign="left",t.save(),t.beginPath(),t.rect(tt-2,-c/2+4,at+4,c-8),t.clip(),f){t.textBaseline="top";const ft=Pt.split(`
19
- `);let St=-c/2+(((ot=e.padding)==null?void 0:ot.top)??8);const Dt=Y*1.4,Bt=e.rows||3;let gt=0,$=0;for(const bt of ft){if(gt>=Bt)break;const $t=bt.split(" ");let Q="";for(let rt=0;rt<$t.length;rt++){const lt=Q+$t[rt]+" ";if(t.measureText(lt).width>at&&rt>0){if(gt>=Bt)break;t.fillText(Q.trim(),tt,St),Q=$t[rt]+" ",St+=Dt,gt++}else Q=lt}gt<Bt&&(t.fillText(Q.trim(),tt,St),$=t.measureText(Q.trim()).width,St+=Dt,gt++)}if(d&&!Mt&&Math.floor(performance.now()/500)%2===0){const bt=St-Dt;t.fillStyle=G,t.fillRect(tt+Math.min($,at),bt,1.5,Y)}}else{t.textBaseline="middle";const St=t.measureText(Pt).width;let Dt=0;if(St>at&&(Dt=St-at),t.fillText(Pt,tt-Dt,0),d&&Math.floor(performance.now()/500)%2===0){const Bt=Mt?tt:tt+St-Dt;t.fillStyle=G,t.fillRect(Bt,-(Y/2),1.5,Y)}}if(t.restore(),e.showCharCounter){t.save();const ft=Number(e.maxLength||0),St=ft>0?`${_t.length}/${ft}`:`${_t.length}`;t.font=`400 10px "${U}", sans-serif`,t.fillStyle=ft>0&&_t.length>=ft?"#ef4444":"rgba(156, 163, 175, 0.6)",t.textAlign="right",t.textBaseline="top",t.fillText(St,-(y/2)+y-8,-(c/2)+c+4),t.restore()}if(v.visible!==!1){const ft=!!(v.required||(ht=e.validation)!=null&&ht.required),St=(v.text||"Label")+(ft?" *":""),Dt=v.fontSize||12,Bt=v.color||"rgba(156, 163, 175, 1)",gt=v.position||"top",$=v.gap??v.offset??6;let bt=-(y/2),$t=-(c/2)-$,Q="left",rt="bottom",lt=`600 ${Dt}px "${v.fontFamily||U}", sans-serif`;gt==="left"?(bt=-(y/2)-$,$t=0,Q="right",rt="middle"):gt==="bottom"?(bt=-(y/2),$t=c/2+$,Q="left",rt="top"):gt==="floating"&&(!!_t||a?(bt=-(y/2)+12,$t=-(c/2)+4,Q="left",rt="top",lt=`600 ${Math.max(9,Dt-2)}px "${v.fontFamily||U}", sans-serif`):lt=null),lt&&(t.save(),t.font=lt,t.fillStyle=Bt,t.textAlign=Q,t.textBaseline=rt,t.fillText(St,bt,$t),t.restore())}const It=(At=e.validation)==null?void 0:At.errorMessage;if(p&&It||m.visible===!0&&m.text){t.save();const ft=m.fontSize||11,St=p?"#ef4444":m.color||"rgba(156, 163, 175, 1)",Dt=m.offset??6,Bt=p&&It?It:m.text;t.font=`400 ${ft}px "${U}", sans-serif`,t.fillStyle=St,t.textAlign="left",t.textBaseline="top",t.fillText(Bt,-(y/2),c/2+Dt),t.restore()}g&&(t.save(),P(-y/2,-c/2,y,c,X),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,u=d===0?0:(a-r)/d,g=n.trackHeight||4,p=n.trackRoundedness??2,f=n.trackShape??"Rectangle",h=n.trackPath||"",S=n.activeColor||n.accentColor||"#3b82f6",y=n.inactiveColor||"#374151",c=n.thumbShape||"Ellipse",v=n.thumbWidth??16,m=n.thumbHeight??16,C=n.thumbRoundedness??0,w=n.thumbColor||"#ffffff",M=n.thumbPath||"",I=n.thumbIcon||"",A=n.trackStrokeWidth??0,_=n.trackStrokeColor||"",T=n.thumbStrokeWidth??0,L=n.thumbStrokeColor||"",F=n.showValueTooltip??!1,D=n.tooltipBgColor||"#333333",R=n.tooltipColor||"#ffffff",X=n.tooltipOffsetX??0,P=n.tooltipOffsetY??-25,k=this.lastHoveredObjectId===s.id,O=this.isMouseDown&&k,E=n.hoverStyle||{},N=n.activeStyle||{};let W=g,B=S,G=y,z=c,V=v,U=m,q=C,Y=w,H=A,x=_,dt=T,_t=L,vt=1;O&&N?(vt=N.scale??1,W=N.trackHeight??W,B=N.activeColor??B,G=N.inactiveColor??G,Y=N.thumbColor??Y,V=N.thumbWidth??V,U=N.thumbHeight??U,q=N.thumbRoundedness??q,z=N.thumbShape||z,H=N.trackStrokeWidth??H,x=N.trackStrokeColor??x,dt=N.thumbStrokeWidth??dt,_t=N.thumbStrokeColor??_t):k&&E&&(vt=E.scale??1,W=E.trackHeight??W,B=E.activeColor??B,G=E.inactiveColor??G,Y=E.thumbColor??Y,V=E.thumbWidth??V,U=E.thumbHeight??U,q=E.thumbRoundedness??q,z=E.thumbShape||z,H=E.trackStrokeWidth??H,x=E.trackStrokeColor??x,dt=E.thumbStrokeWidth??dt,_t=E.thumbStrokeColor??_t);const Yt=O&&N.thumbPath?N.thumbPath:k&&E.thumbPath?E.thumbPath:M;vt!==1&&(t.save(),t.scale(vt,vt));const Mt=(at,ct,Pt,kt,It,xt,ie)=>{const se=ze[at]||ie||(at&&(at.startsWith("M")||at.startsWith("m"))?at:"");if((at==="Custom"||at==="Icon"||se)&&se)try{const Qt=new Path2D(se),ce=We(se),le=Math.min(kt/ce.width,It/ce.height);t.save(),t.translate(ct,Pt),t.scale(le,le),t.translate(-ce.cx,-ce.cy);const qt=!se.includes("z")&&!se.includes("Z");qt?(t.strokeStyle=t.fillStyle,t.lineWidth=Math.max(1.8,2.2/le),t.lineCap="round",t.lineJoin="round",t.stroke(Qt)):t.fill(Qt),t.strokeStyle&&t.lineWidth>0&&!qt&&t.stroke(Qt),t.restore();return}catch(Qt){console.error("Error drawing slider shape in engine:",Qt)}if(t.beginPath(),at==="Ellipse")t.ellipse(ct,Pt,kt/2,It/2,0,0,Math.PI*2);else if(at==="Rectangle")this.drawRoundRect(t,ct-kt/2,Pt-It/2,kt,It,xt);else if(at==="Triangle")t.moveTo(ct,Pt-It/2),t.lineTo(ct+kt/2,Pt+It/2),t.lineTo(ct-kt/2,Pt+It/2),t.closePath();else if(at==="Diamond")t.moveTo(ct,Pt-It/2),t.lineTo(ct+kt/2,Pt),t.lineTo(ct,Pt+It/2),t.lineTo(ct-kt/2,Pt),t.closePath();else if(at==="Polygon"){const Qt=s.geometry.sides||3,ce=s.geometry.radius||Math.min(kt,It)/2;for(let le=0;le<Qt;le++){const qt=le*2*Math.PI/Qt-Math.PI/2,Se=ct+ce*Math.cos(qt),Ce=Pt+ce*Math.sin(qt);le===0?t.moveTo(Se,Ce):t.lineTo(Se,Ce)}t.closePath()}else if(at==="Star"){const ce=Math.min(kt,It)/2,le=ce/2;for(let qt=0;qt<10;qt++){const Se=qt%2===0?ce:le,Ce=qt*Math.PI/5-Math.PI/2;t.lineTo(ct+Se*Math.cos(Ce),Pt+Se*Math.sin(Ce))}t.closePath()}else at==="Line"&&(t.moveTo(ct-kt/2,Pt),t.lineTo(ct+kt/2,Pt));t.fill(),t.strokeStyle&&t.lineWidth>0&&t.stroke()},Wt=this.createCanvasFill(t,G,i,W);Wt&&(t.fillStyle=Wt,t.strokeStyle=Wt),f==="Line"?(t.strokeStyle=H>0&&x?x:Wt,t.lineWidth=H>0?H:W,t.beginPath(),t.moveTo(-i/2,0),t.lineTo(i/2,0),t.stroke()):(H>0&&x&&(t.strokeStyle=x,t.lineWidth=H),Mt(f,0,0,i,W,p,h));const Ot=i-V,yt=-i/2+V/2+u*Ot,Ft=yt- -i/2;if(Ft>0){const at=this.createCanvasFill(t,B,i,W);if(at&&(t.fillStyle=at),f==="Line")t.strokeStyle=H>0&&x?x:at||B,t.lineWidth=H>0?H:W,t.beginPath(),t.moveTo(-i/2,0),t.lineTo(yt,0),t.stroke();else{if(H>0&&x&&(t.strokeStyle=x,t.lineWidth=H),t.beginPath(),f==="Rectangle")this.drawRoundRect(t,-i/2,-W/2,Ft,W,p);else{const ct=ze[f]||h||"";if(ct)try{const Pt=new Path2D(ct),kt=We(ct),It=Math.min(Ft/kt.width,W/kt.height);t.save(),t.translate(-i/2+Ft/2,0),t.scale(It,It),t.translate(-kt.cx,-kt.cy),t.fill(Pt),t.strokeStyle&&t.lineWidth>0&&t.stroke(Pt),t.restore()}catch{this.drawRoundRect(t,-i/2,-W/2,Ft,W,p)}else this.drawRoundRect(t,-i/2,-W/2,Ft,W,p)}t.fill(),t.strokeStyle&&t.lineWidth>0&&t.stroke()}}t.save(),t.translate(yt,0);const K=t.getTransform(),ut=Math.sqrt(K.a*K.a+K.b*K.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*ut,t.shadowOffsetY=1*ut;const Lt=this.createCanvasFill(t,Y,V,U);Lt&&(t.fillStyle=Lt),dt>0&&_t&&(t.strokeStyle=_t,t.lineWidth=dt);const Ct=O&&N.thumbShape==="Icon"?N.thumbPath||I:k&&E.thumbShape==="Icon"&&E.thumbPath||I;if(Mt(z,0,0,V,U,q,z==="Icon"?Ct:Yt),t.restore(),F){t.save(),t.translate(yt+X,P);const at=Math.round(a).toString();t.font="10px Inter, sans-serif";const ct=t.measureText(at),Pt=6,kt=4,It=ct.width+Pt*2,xt=14+kt;t.beginPath(),this.drawRoundRect(t,-It/2,-xt/2,It,xt,4),t.fillStyle=D,t.fill(),t.fillStyle=R,t.textAlign="center",t.textBaseline="middle",t.fillText(at,0,0),t.restore()}const Tt=n.label||{},Et=n.helperText||{},tt=n.fontFamily||"Inter";if(Tt.visible!==!1){const at=Tt.text||"Label",ct=Tt.fontSize||12,Pt=Tt.color||"rgba(156, 163, 175, 1)",kt=Tt.offset??8;t.font=`600 ${ct}px "${tt}", sans-serif`,t.fillStyle=Pt,t.textAlign="left",t.textBaseline="bottom";const It=-(i/2),xt=-(W/2)-kt;t.fillText(at,It,xt)}if(Et.visible===!0){const at=Et.text||"Helper text",ct=Et.fontSize||11,Pt=Et.color||"rgba(156, 163, 175, 1)",kt=Et.offset??6;t.font=`400 ${ct}px "${tt}", sans-serif`,t.fillStyle=Pt,t.textAlign="left",t.textBaseline="top";const It=-(i/2),xt=W/2+kt;t.fillText(at,It,xt)}vt!==1&&t.restore()}renderDropdown(t,s){var F;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",u=this.lastHoveredObjectId===s.id||e.previewState==="hover",g=(e.isOpen||e.previewState==="active")&&!d;let p=e.backgroundColor,f=e.borderColor,h=e.color||"#333333";d?(p=e.disabledBackgroundColor||"#f3f4f6",f=e.disabledBorderColor||"#e5e7eb",h=e.disabledColor||"#9ca3af"):g?(p=e.activeBackgroundColor||p,f=e.activeBorderColor||f,h=e.activeColor||h):u&&(p=e.hoverBackgroundColor||p,f=e.hoverBorderColor||f,h=e.hoverColor||h),p||(p="#ffffff"),f||(f="#e5e7eb"),t.save();const S=t.globalAlpha;t.globalAlpha=S*(e.opacity??1),t.beginPath(),this.drawRoundRect(t,a,r,n,i,l),t.fillStyle=this.createCanvasFill(t,typeof p=="string"?{type:"Solid",color:p}:p,n,i)||"#ffffff",t.fill();const y=e.borderWidth??1;y>0&&(t.beginPath(),this.drawRoundRect(t,a,r,n,i,l),t.strokeStyle=this.createCanvasFill(t,typeof f=="string"?{type:"Solid",color:f}:f,n,i)||"#e5e7eb",t.lineWidth=y,t.stroke());const c=12,v=e.chevronType||"chevron",m=e.chevronSize||16,C=(g?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(v!=="none"){const D=a+n-c-m/2;t.save(),t.translate(D,0);const R=g?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(R*Math.PI/180),t.strokeStyle=C,t.fillStyle=C,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",v==="chevron")t.beginPath(),t.moveTo(-m/2,-m*.2),t.lineTo(0,m*.2),t.lineTo(m/2,-m*.2),t.stroke();else if(v==="custom"||v==="path"){const X=g&&e.openIconPath||e.closedIconPath;if(X){const P=new Path2D(X);t.save();const k=m/24;t.scale(k,k),t.translate(-12,-12),t.fill(P),t.restore()}}t.restore()}const w=e.selectedOption||e.placeholder||"Select...",M=e.fontSize||14,I=e.fontWeight||400,A=e.fontFamily||"Inter, sans-serif";t.font=`${I} ${M}px ${A}`;const _=d?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":h;t.fillStyle=this.createCanvasFill(t,typeof _=="string"?{type:"Solid",color:_}:_,n,i)||"#333333",t.textAlign="left",t.textBaseline="middle";const T=v==="none"?0:m+8,L=n-c*2-T;if(t.save(),t.beginPath(),t.rect(a+c,r,L,i),t.clip(),t.fillText(w,a+c,0),t.restore(),g&&!d){const D=r+i+4,R=this.getResolvedDropdownOptions(s,e),X=e.itemHeight||32,P=e.listPadding??4,k=R.length*X+P*2,O=e.listCornerRadius??l;t.save();const E=e.listShadow||{},N=t.getTransform(),W=Math.sqrt(N.a*N.a+N.b*N.b)||1;t.shadowColor=typeof E.color=="string"?E.color:((F=E.color)==null?void 0:F.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(E.blur??12)*W,t.shadowOffsetY=(E.offsetY??6)*W,t.shadowOffsetX=(E.offsetX??0)*W,t.beginPath(),this.drawRoundRect(t,a,D,n,k,O),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},n,k)||"#ffffff",t.fill();const B=e.listBorderWidth??1;B>0&&(t.shadowColor="transparent",t.beginPath(),this.drawRoundRect(t,a,D,n,k,O),t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:f},n,k)||"#e5e7eb",t.lineWidth=B,t.stroke()),t.restore();const G=e.itemFontSize||M,z=e.itemFontFamily||A;t.font=`${I} ${G}px ${z}`,R.forEach((V,U)=>{const q=D+P+U*X;if(V===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},n,X)||"#f3f4f6",t.fillRect(a+B,q,n-B*2,X),t.fillStyle=e.itemSelectedColor||e.accentColor||h||"#374151";else if(t.fillStyle=e.listTextColor||h||"#333333",this.activeDropdownId===s.id&&this._lastPointerPos){const H=this._lastPointerPos.y-(D+P),x=Math.floor(H/X);U===x&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},n,X)||"#f9fafb",t.fillRect(a+B,q,n-B*2,X),t.fillStyle=e.itemHoverColor||h)}t.fillText(V,a+c,q+X/2)})}t.restore()}renderButton(t,s){var U;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||{},u=e.hoverStyle||{},g=e.activeStyle||{},p=e.icon||{enabled:!1};let f=e.backgroundColor||e.buttonBgColor||((U=s.style)==null?void 0:U.fill)||"#3b82f6",h=(typeof d=="object"?d.color:null)||"#ffffff",S=typeof d=="string"?d:d.text||s.text||(s.name&&!s.name.toLowerCase().includes("component")?s.name:"Button"),y=n.cornerRadius??n.corner_radius??8,c=e.borderColor||"transparent",v=e.borderWidth||0,m=1;l&&g?(f=g.backgroundColor||f,h=g.color||h,S=g.text||S,m=g.scale??.95,y=g.cornerRadius??y):r&&u&&(f=u.backgroundColor||f,h=u.color||h,S=u.text||S,m=u.scale??1,y=u.cornerRadius??y,c=u.borderColor||c);const C=-i/2,w=-a/2;t.save(),t.scale(m,m),t.beginPath(),this.drawRoundRect(t,C,w,i,a,y);const M=this.createCanvasFill(t,f,i,a);M&&(t.fillStyle=M,t.fill()),(v>0||r&&u.borderColor)&&(t.strokeStyle=c,t.lineWidth=v||(r?1:0),t.stroke());const I=d.fontSize||14,A=d.fontFamily||"Inter",_=d.fontWeight||600;t.font=`${_} ${I}px "${A}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=h,t.textAlign="center",t.textBaseline="middle";const T=p.enabled===!0||p.enabled==="true",L=Number(p.size)||Math.round(I*1.15)||16,F=p.color||h,D=Number(p.gap)??8,R=p.position||"left",X=p.margin||{left:0,right:0,top:0,bottom:0},P=(Number(X.left)||0)-(Number(X.right)||0),k=(Number(X.top)||0)-(Number(X.bottom)||0),O=!!(S&&String(S).trim().length>0),N=(O?t.measureText(String(S)):{width:0}).width,W=I*1.2;let B=0,G=0,z=0,V=0;if(T){if(!O||R==="center")z=P,V=k,B=0,G=0;else if(R==="left"){const q=L+D+N;z=-q/2+L/2+P,V=k,B=-q/2+L+D+N/2+P,G=0}else if(R==="right"){const q=N+D+L;B=-q/2+N/2+P,G=0,z=-q/2+N+D+L/2+P,V=k}else if(R==="top"){const q=L+D+W;z=P,V=-q/2+L/2+k,B=P,G=-q/2+L+D+W/2+k}else if(R==="bottom"){const q=W+D+L;B=P,G=-q/2+W/2+k,z=P,V=-q/2+W+D+L/2+k}this.drawButtonIcon(t,p,z,V,L,F,A)}O&&R!=="center"&&(t.fillStyle=h,t.fillText(String(S),B,G)),t.restore()}drawButtonIcon(t,s,o,e,n,i,a="Inter"){const r=(s.svgPath||"").trim(),l=(s.character||s.char||"").trim(),d="M12 3L10.088 8.813A2 2 0 0 1 8.813 10.088L3 12L8.813 13.912A2 2 0 0 1 10.088 15.187L12 21L13.912 15.187A2 2 0 0 1 15.187 13.912L21 12L15.187 10.088A2 2 0 0 1 13.912 8.813L12 3Z";if(t.save(),l){t.font=`${Math.round(n)}px "${a}", -apple-system, sans-serif`,t.fillStyle=i,t.textAlign="center",t.textBaseline="middle",t.fillText(l,o,e),t.restore();return}if(r.startsWith("<svg")){const p=s.fill&&s.fill.type!=="None";let f=r.replace(/stroke\s*=\s*(['"])currentColor\1/gi,`stroke="${i}"`).replace(/stroke\s*:\s*currentColor/gi,`stroke: ${i}`);p?f=f.replace(/fill\s*=\s*(['"])currentColor\1/gi,`fill="${i}"`).replace(/fill\s*:\s*currentColor/gi,`fill: ${i}`):f=f.replace(/fill\s*=\s*(['"])currentColor\1/gi,'fill="none"').replace(/fill\s*:\s*currentColor/gi,"fill: none"),f.includes("xmlns=")||(f=f.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"'));const h=`svg_icon_${i}_${n}_${btoa(f.slice(0,80))}`;let S=this.imageCache.get(h);if(S||(S=new Image,S.crossOrigin="anonymous",S.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(f)))}`,this.imageCache.set(h,S)),S.complete&&S.naturalWidth>0){t.drawImage(S,o-n/2,e-n/2,n,n),t.restore();return}const y=[...f.matchAll(/<path[^>]*\bd=["']([^"']+)["']/gi)];if(y.length>0){t.translate(o,e);const c=n/24;t.scale(c,c),t.translate(-12,-12);const v=new Path2D(y.map(m=>m[1]).join(" "));p?(t.fillStyle=i,t.fill(v)):(t.strokeStyle=i,t.lineWidth=2,t.lineCap="round",t.lineJoin="round",t.stroke(v)),t.restore();return}}if(r&&!r.startsWith("<")){t.translate(o,e);const p=n/24;t.scale(p,p),t.translate(-12,-12);const f=new Path2D(r);t.fillStyle=i,t.fill(f),t.strokeStyle=i,t.lineWidth=1,t.stroke(f),t.restore();return}t.translate(o,e);const u=n/24;t.scale(u,u),t.translate(-12,-12);const g=new Path2D(d);t.fillStyle=i,t.fill(g),t.restore()}renderToggleButton(t,s){var S,y;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=e.checked??!1,i=((S=s.geometry)==null?void 0:S.width)||120,a=((y=s.geometry)==null?void 0:y.height)||40,r=-i/2,l=-a/2,d=e.corner_radius??8,u=e.label||{},g=n?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",p=n?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,r,l,i,a,d),t.fillStyle=g,t.fill();const f=u.fontSize||14,h=u.fontFamily||"Inter";t.font=`${u.fontWeight||600} ${f}px "${h}", sans-serif`,t.fillStyle=p,t.textAlign="center",t.textBaseline="middle",t.fillText(u.text||"Toggle",0,0),t.restore()}renderToggle(t,s){var _t,vt,Yt,Mt,Wt,Ot,yt,Ft,K,ut,Lt,Ct,Tt,Et;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=s.geometry||{},i=n.width||52,a=n.height||30,r=e.checked??!1,l=e.toggleStyle||{},d=l.width,u=l.height,g=l.cornerRadius,p=r&&d?d:i,f=r&&u?u:a,h=-p/2,S=-f/2,y=r&&g!==void 0?g:e.cornerRadius??e.corner_radius??a/2,c=l.backgroundColor||e.activeColor||"#10b981",v=l.borderColor||e.borderColor||"transparent",m=l.borderWidth??e.borderWidth??0,C=l.knobColor||e.knobColor||"#ffffff",w=r?c:e.inactiveColor||"#374151",M=r?v:e.borderColor||"transparent",I=r?m:e.borderWidth??0,A=r?C:e.knobColor||"#ffffff",_=r&&l.knobShape||e.knobShape||"Circle",T=r&&l.knobSize||e.knobSize||0,L=r&&l.trackShape||e.trackShape||"Pill";e.disabled&&(t.globalAlpha*=.5);const F=(tt,at,ct,Pt,kt,It)=>{try{const xt=new Path2D(tt),ie=We(tt),se=Math.min(Pt/ie.width,kt/ie.height),Qt=!tt.includes("z")&&!tt.includes("Z");t.save(),t.translate(at,ct),t.scale(se,se),t.translate(-ie.cx,-ie.cy),Qt?(t.strokeStyle=It,t.lineWidth=Math.max(1.8,2.2/se),t.lineCap="round",t.lineJoin="round",t.stroke(xt)):(t.fillStyle=It,t.fill(xt)),t.restore()}catch{t.beginPath(),t.arc(at,ct,Math.min(Pt,kt)/2,0,Math.PI*2),It&&(t.fillStyle=It),t.fill()}},D=(tt,at,ct,Pt,kt,It,xt)=>{try{const ie=new Path2D(tt),se=We(tt),Qt=Math.min(Pt/se.width,kt/se.height);t.save(),t.translate(at,ct),t.scale(Qt,Qt),t.translate(-se.cx,-se.cy),t.strokeStyle=It,t.lineWidth=xt/Qt,t.lineCap="round",t.lineJoin="round",t.stroke(ie),t.restore()}catch{t.beginPath(),t.arc(at,ct,Math.min(Pt,kt)/2,0,Math.PI*2),It&&(t.strokeStyle=It),t.lineWidth=xt,t.stroke()}},R=ze[L]||L,X=!["Pill","Rectangle","Circle"].includes(R),P=ze[_]||_,k=!["Circle","Square","Diamond","Star"].includes(P),O=this.createCanvasFill(t,w,p,f);if(X?F(R,h+p/2,S+f/2,p,f,O):(t.beginPath(),L==="Circle"?t.ellipse(h+p/2,S+f/2,p/2,f/2,0,0,Math.PI*2):L==="Pill"?this.drawRoundRect(t,h,S,p,f,f/2):this.drawRoundRect(t,h,S,p,f,y),O&&(t.fillStyle=O,t.fill())),I>0){const tt=this.createCanvasFill(t,M,p,f);X?D(R,h+p/2,S+f/2,p,f,tt,I):(t.beginPath(),L==="Circle"?t.ellipse(h+p/2,S+f/2,p/2,f/2,0,0,Math.PI*2):L==="Pill"?this.drawRoundRect(t,h,S,p,f,f/2):this.drawRoundRect(t,h,S,p,f,y),t.lineWidth=I,tt&&(t.strokeStyle=tt,t.stroke()))}const E=e.knobPadding??2,N=f-E*2,W=T>0?T:N,B=W/2,G=h+E,z=h+p-E-W,V=r?z:G,U=S+(f-W)/2,q=this.createCanvasFill(t,A,W,W);if(k)F(P,V+B,U+B,W,W,q);else{if(t.beginPath(),_==="Square"){const tt=Math.min(4,B/2);t.roundRect(V,U,W,W,tt)}else if(_==="Diamond"){const tt=V+B,at=U+B;t.moveTo(tt,at-B),t.lineTo(tt+B,at),t.lineTo(tt,at+B),t.lineTo(tt-B,at),t.closePath()}else if(_==="Star"){const tt=V+B,at=U+B,ct=5,Pt=B,kt=B*.4;for(let It=0;It<ct*2;It++){const xt=It%2===0?Pt:kt,ie=It*Math.PI/ct-Math.PI/2,se=tt+xt*Math.cos(ie),Qt=at+xt*Math.sin(ie);It===0?t.moveTo(se,Qt):t.lineTo(se,Qt)}t.closePath()}else t.arc(V+B,U+B,B,0,Math.PI*2);q&&(t.fillStyle=q,t.fill())}e.disabled&&(t.globalAlpha*=2);const Y=((_t=e.leftLabel)==null?void 0:_t.enabled)&&((vt=e.leftLabel)==null?void 0:vt.text),H=((Yt=e.rightLabel)==null?void 0:Yt.enabled)&&((Mt=e.rightLabel)==null?void 0:Mt.text),x=((Wt=e.leftLabel)==null?void 0:Wt.gap)||8,dt=((Ot=e.rightLabel)==null?void 0:Ot.gap)||8;if(Y){const tt=(r?(yt=l.leftLabel)==null?void 0:yt.text:null)||((Ft=e.leftLabel)==null?void 0:Ft.text)||"",at=(r?(K=l.leftLabel)==null?void 0:K.color:null)||((ut=e.leftLabel)==null?void 0:ut.color)||"#f3f4f6",ct=e.leftLabel;t.font=`${ct.fontWeight||400} ${ct.fontSize||12}px "${ct.fontFamily||"Inter"}", sans-serif`,t.fillStyle=at,t.textBaseline="middle",t.textAlign="right",t.fillText(tt,h-x,0)}if(H){const tt=(r?(Lt=l.rightLabel)==null?void 0:Lt.text:null)||((Ct=e.rightLabel)==null?void 0:Ct.text)||"",at=(r?(Tt=l.rightLabel)==null?void 0:Tt.color:null)||((Et=e.rightLabel)==null?void 0:Et.color)||"#f3f4f6",ct=e.rightLabel;t.font=`${ct.fontWeight||400} ${ct.fontSize||12}px "${ct.fontFamily||"Inter"}", sans-serif`,t.fillStyle=at,t.textBaseline="middle",t.textAlign="left",t.fillText(tt,h+p+dt,0)}if(!Y&&!H&&e.label&&e.label.text){const tt=e.label,at=tt.fontSize||14,ct=tt.fontWeight||400,Pt=tt.fontFamily||"Inter";t.font=`${ct} ${at}px "${Pt}", sans-serif`,t.fillStyle=tt.color||"#f3f4f6",t.textBaseline="middle";const kt=tt.gap||10;let It=0,xt=0;tt.position==="left"?(t.textAlign="right",It=h-kt,xt=0):tt.position==="right"?(t.textAlign="left",It=h+p+kt,xt=0):tt.position==="top"?(t.textAlign="center",It=0,xt=S-kt,t.textBaseline="bottom"):tt.position==="bottom"?(t.textAlign="center",It=0,xt=S+f+kt,t.textBaseline="top"):(t.textAlign="left",It=h+p+kt,xt=0),t.fillText(tt.text,It,xt)}}renderCheckbox(t,s){var X,P,k,O;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=((X=s.geometry)==null?void 0:X.width)||140,i=((P=s.geometry)==null?void 0:P.height)||24,a=-n/2,r=-i/2,l=Math.max(12,Math.min(e.boxSize||18,i,n)),d=Math.min(e.cornerRadius??4,l/2),u=e.checked??!1,g=!!e.indeterminate,p=e.activeColor||"#3b82f6",f=e.inactiveColor||"transparent",h=e.checkColor||"#ffffff",S=e.borderColor||"#9ca3af",y=e.borderWidth??1.5,c=!!(e.label&&e.label.text),v=((k=e.label)==null?void 0:k.gap)??8,m=((O=e.label)==null?void 0:O.position)||"right";let C=a,w=r+(i-l)/2,M=0,I=0,A="left",_="middle";c?m==="right"?(C=a,w=r+(i-l)/2,M=C+l+v,I=0,A="left",_="middle"):m==="left"?(C=a+n-l,w=r+(i-l)/2,M=C-v,I=0,A="right",_="middle"):m==="top"?(C=a+(n-l)/2,w=r+i-l,M=0,I=w-v,A="center",_="bottom"):m==="bottom"&&(C=a+(n-l)/2,w=r,M=0,I=w+l+v,A="center",_="top"):(C=a+(n-l)/2,w=r+(i-l)/2);const T=u||g,L=T?p:f,F=T?p:S,D=T?0:y;e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,C,w,l,l,d);const R=this.createCanvasFill(t,L,l,l);if(R&&(t.fillStyle=R,t.fill()),D>0){t.lineWidth=D;const E=this.createCanvasFill(t,F,l,l);E&&(t.strokeStyle=E,t.stroke())}else if(T){t.lineWidth=1;const E=this.createCanvasFill(t,p,l,l);E&&(t.strokeStyle=E,t.stroke())}if(g){t.save(),t.beginPath();const E=this.createCanvasFill(t,h,l,l);t.strokeStyle=E||h,t.lineWidth=Math.max(2,l*.12),t.lineCap="round",t.moveTo(C+l*.25,w+l*.5),t.lineTo(C+l*.75,w+l*.5),t.stroke(),t.restore()}else if(u){t.save(),t.beginPath();const E=this.createCanvasFill(t,h,l,l);t.strokeStyle=E||h,t.lineWidth=Math.max(2,l*.12),t.lineCap="round",t.lineJoin="round";const N=C+l*.24,W=w+l*.5,B=C+l*.44,G=w+l*.7,z=C+l*.76,V=w+l*.28;t.moveTo(N,W),t.lineTo(B,G),t.lineTo(z,V),t.stroke(),t.restore()}if(e.disabled&&(t.globalAlpha*=2),c&&e.label&&e.label.text){const E=e.label;t.save(),t.font=`${E.fontWeight||400} ${E.fontSize||14}px "${E.fontFamily||"Inter"}", sans-serif`,t.fillStyle=E.color||"#111827",t.textAlign=A,t.textBaseline=_,t.fillText(E.text,M,I),t.restore()}}renderRadioGroup(t,s){var A,_;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=((A=s.geometry)==null?void 0:A.width)||180,i=((_=s.geometry)==null?void 0:_.height)||100,a=-n/2,r=-i/2;let l=e.optionsList||["Option 1","Option 2","Option 3"];if(e.isDataVarEnabled&&e.dataInputId){let T=this.inputs.get(e.dataInputId);if(T===void 0){const L=this.inputNameMap.get(e.dataInputId);L&&L.length>0&&(T=this.inputs.get(L[0]))}T&&Array.isArray(T)&&(l=T.map(L=>typeof L=="string"?L:String(L)))}const d=e.selectedValue,u=e.orientation||"vertical",g=e.itemGap!==void 0?e.itemGap:16,p=e.activeColor||"#3b82f6",f=e.inactiveColor||"#4b5563",h=e.textColor||"#ffffff",S=e.fontSize||14,y=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 v=8,m=v*2,C=e.radioShape||"circle",w=e.borderWidth!==void 0?e.borderWidth:2,M=e.fillEmpty||"transparent",I=(T,L,F,D)=>{if(t.beginPath(),D==="custom"&&e.customShapePath)try{const R=new Path2D(e.customShapePath),X=We(e.customShapePath),P=Math.min(F*2/X.width,F*2/X.height);t.save(),t.translate(T,L),t.scale(P,P),t.translate(-X.cx,-X.cy),!e.customShapePath.includes("z")&&!e.customShapePath.includes("Z")?(t.strokeStyle=t.fillStyle,t.lineWidth=Math.max(1.8,2.2/P),t.lineCap="round",t.lineJoin="round",t.stroke(R)):t.fill(R),t.restore();return}catch{t.arc(T,L,F,0,Math.PI*2);return}if(D==="square"){const R=F*1.6;t.rect(T-R/2,L-R/2,R,R)}else if(D==="diamond"){const R=F*1.4;t.moveTo(T,L-R),t.lineTo(T+R,L),t.lineTo(T,L+R),t.lineTo(T-R,L),t.closePath()}else if(D==="heart"){const R=F*.9;t.moveTo(T,L+R*.7),t.bezierCurveTo(T-R*1.5,L-R*.3,T-R*.5,L-R*1.5,T,L-R*.5),t.bezierCurveTo(T+R*.5,L-R*1.5,T+R*1.5,L-R*.3,T,L+R*.7)}else if(D==="star"){const R=F*1.1,X=F*.5;for(let P=0;P<5;P++){const k=(P*72-90)*Math.PI/180,O=(P*72+36-90)*Math.PI/180;P===0?t.moveTo(T+R*Math.cos(k),L+R*Math.sin(k)):t.lineTo(T+R*Math.cos(k),L+R*Math.sin(k)),t.lineTo(T+X*Math.cos(O),L+X*Math.sin(O))}t.closePath()}else t.arc(T,L,F,0,Math.PI*2)};if(t.font=`${c} ${S}px "${y}", sans-serif`,t.textBaseline="middle",t.textAlign="left",u==="vertical"){const T=Math.max(m,S)+g,L=l.length*T-g,F=r+Math.max(0,(i-L)/2);l.forEach((D,R)=>{const X=F+v+R*T,P=d===D,k=this.createCanvasFill(t,p,m,m),O=this.createCanvasFill(t,f,m,m);P?(t.fillStyle=k||p,I(a+v,X,v,C),t.fill(),t.strokeStyle=k||p,t.lineWidth=w,I(a+v,X,v,C),t.stroke()):(M!=="transparent"&&(t.fillStyle=M,I(a+v,X,v,C),t.fill()),t.strokeStyle=O||f,t.lineWidth=w,I(a+v,X,v,C),t.stroke()),t.fillStyle=h,t.fillText(D,a+m+8,X)})}else{const T=r+i/2;let L=0;t.font=`${c} ${S}px "${y}", sans-serif`,l.forEach(R=>{L+=m+6+t.measureText(R).width+g}),L-=g;let D=a+Math.max(0,(n-L)/2);l.forEach(R=>{const X=d===R,P=t.measureText(R).width,k=this.createCanvasFill(t,p,m,m),O=this.createCanvasFill(t,f,m,m);X?(t.fillStyle=k||p,I(D+v,T,v,C),t.fill(),t.strokeStyle=k||p,t.lineWidth=w,I(D+v,T,v,C),t.stroke()):(M!=="transparent"&&(t.fillStyle=M,I(D+v,T,v,C),t.fill()),t.strokeStyle=O||f,t.lineWidth=w,I(D+v,T,v,C),t.stroke()),t.fillStyle=h,t.fillText(R,D+m+6,T),D+=m+6+P+g})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const T=e.label;t.save(),t.font=`${T.fontWeight||400} ${T.fontSize||14}px "${T.fontFamily||"Inter"}", sans-serif`,t.fillStyle=T.color||"#9ca3af",t.textBaseline="middle";const L=T.gap||8;let F=0,D=0;T.position==="left"?(t.textAlign="right",F=a-L,D=0):T.position==="right"?(t.textAlign="left",F=a+n+L,D=0):T.position==="top"?(t.textAlign="center",F=0,D=r-L,t.textBaseline="bottom"):T.position==="bottom"&&(t.textAlign="center",F=0,D=r+i+L,t.textBaseline="top"),t.fillText(T.text,F,D),t.restore()}}renderBarChart(t,s){var D,R,X;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 P=this.inputs.get(e.dataInputId);if(P===void 0){const k=this.inputNameMap.get(e.dataInputId);k&&k.length>0&&(P=this.inputs.get(k[0]))}P&&Array.isArray(P)&&(n.categories=P.map(k=>typeof k=="string"?k:String(k)))}if(e.isDatasetsVarEnabled&&((D=e.datasetInputIds)==null?void 0:D.length)>0){const P=e.datasetInputIds.map((k,O)=>{var W;let E=this.inputs.get(k);if(E===void 0){const B=this.inputNameMap.get(k);B&&B.length>0&&(E=this.inputs.get(B[0]))}const N=((W=e.datasets)==null?void 0:W[O])||{id:`ds-${O}`,label:`Series ${O+1}`,data:[],color:"#6366f1"};return E&&Array.isArray(E)?{...N,data:E.map(B=>typeof B=="number"?B:parseFloat(B)||0)}:N});n.datasets=P}const i={width:((R=s.geometry)==null?void 0:R.width)||300,height:((X=s.geometry)==null?void 0:X.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],showHoverTooltip:n.showHoverTooltip!==void 0?!!n.showHoverTooltip:!0,hoverHighlight:n.hoverHighlight!==void 0?!!n.hoverHighlight:!0,hoverHighlightColor:n.hoverHighlightColor||"rgba(255, 255, 255, 0.22)",tooltipBg:n.tooltipBg||"#111827",tooltipTextColor:n.tooltipTextColor||"#f9fafb",tooltipRadius:n.tooltipRadius!==void 0?n.tooltipRadius:6,_hexToRgb:function(P,k){if(P.startsWith("rgba")||P.startsWith("rgb"))return P;P.startsWith("#")||(P="#"+P),P.length===4&&(P="#"+P[1]+P[1]+P[2]+P[2]+P[3]+P[3]);const O=parseInt(P.slice(1,3),16),E=parseInt(P.slice(3,5),16),N=parseInt(P.slice(5,7),16);return`rgba(${O},${E},${N},${k})`},_resolveColor:function(P,k){return typeof P=="string"?P:"#6366f1"},_makeGradient:function(P,k,O,E,N,W){if(!this.barGradient)return k;const B=this.gradientStartColor||k,G=P.createLinearGradient(O,E,N,W);return G.addColorStop(0,k),G.addColorStop(1,this._hexToRgb(B,this.gradientEndOpacity)),G},_drawRoundedBar:function(P,k,O,E,N,W,B){if(W=Math.min(W,Math.min(Math.abs(E),Math.abs(N))/2),W<=0||E===0||N===0){P.rect(k,O,E,N);return}P.beginPath(),B?(P.moveTo(k,O+N),P.lineTo(k,O+W),P.quadraticCurveTo(k,O,k+W,O),P.lineTo(k+E-W,O),P.quadraticCurveTo(k+E,O,k+E,O+W),P.lineTo(k+E,O+N),P.lineTo(k,O+N)):(P.moveTo(k,O),P.lineTo(k+E-W,O),P.quadraticCurveTo(k+E,O,k+E,O+W),P.lineTo(k+E,O+N-W),P.quadraticCurveTo(k+E,O+N,k+E-W,O+N),P.lineTo(k,O+N),P.lineTo(k,O)),P.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 u=-1/0,g=1/0;const p=i.categories.length,f=i.datasets.length;if(i.chartType==="stacked")for(let P=0;P<p;P++){let k=0,O=0;i.datasets.forEach(E=>{const N=E.data[P]??0;N>=0?k+=N:O+=N}),k>u&&(u=k),O<g&&(g=O)}else i.datasets.forEach(P=>{P.data&&P.data.forEach(k=>{k>u&&(u=k),k<g&&(g=k)})});isFinite(u)||(u=10),isFinite(g)||(g=0),u=Math.max(u,0),g=Math.min(g,0);const h=u-g||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 S=i.showYLabels?t.measureText(u.toFixed(0)).width+14:10,y=i.showXLabels?i.axisLabelFontSize+12:8,v=(i.showLegend&&f>0?i.legendFontSize+10:0)+8,m=10,C=l+S,w=d+v,M=a-S-m,I=r-v-y;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&&f>0){t.font=i.legendFontSize+"px Inter, sans-serif",t.textBaseline="middle";const P=d+12;let k=C;i.datasets.forEach((O,E)=>{const N=i._resolveColor(O.color,E),W=O.label||"Series "+(E+1),B=7;t.beginPath(),t.roundRect(k,P-B/2,B,B,2),t.fillStyle=N,t.fill(),t.fillStyle=i.legendColor,t.textAlign="left",t.fillText(W,k+B+4,P),k+=t.measureText(W).width+B+16})}const A=4;if(i.showGridLines){t.setLineDash(i.gridLineDash||[]),t.lineWidth=i.gridLineWidth||1,t.strokeStyle=i.gridColor;for(let P=0;P<=A;P++)if(i.orientation==="horizontal"){const k=C+P/A*M;t.beginPath(),t.moveTo(k,w),t.lineTo(k,w+I),t.stroke()}else{const k=w+P/A*I;t.beginPath(),t.moveTo(C,k),t.lineTo(C+M,k),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 P=0;P<=A;P++)if(i.orientation==="horizontal"){const k=g+P/A*h,O=C+P/A*M;t.textAlign="center",t.fillText(k.toFixed(0),O,w+I+i.axisLabelFontSize)}else{const k=u-P/A*h,O=w+P/A*I;t.textAlign="right",t.fillText(k.toFixed(0),C-6,O)}}t.setLineDash([]),i.showXAxis&&(t.lineWidth=i.xAxisLineWidth||1,t.strokeStyle=i.xAxisColor,t.beginPath(),t.moveTo(C,w+I),t.lineTo(C+M,w+I),t.stroke()),i.showYAxis&&(t.lineWidth=i.yAxisLineWidth||1,t.strokeStyle=i.yAxisColor,t.beginPath(),t.moveTo(C,w),t.lineTo(C,w+I),t.stroke()),i.enableShadows&&(t.shadowColor=i.shadowColor);const _=[],T=this.graphHoverStates.get(s.id),L=T==null?void 0:T.hoveredCatIdx,F=T==null?void 0:T.hoveredDsIdx;if(i.chartType==="stacked")if(i.orientation==="horizontal"){const P=I/p;for(let k=0;k<p;k++){const O=w+k*P+P/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[k]||"",C-5,O),i.enableShadows&&(t.shadowColor=i.shadowColor));let E=C;i.datasets.forEach((N,W)=>{const B=N.data[k]??0;if(B===0)return;const G=B/h*M,z=Math.min(i.barWidth*f+i.barGap,P-8),V=O-z/2,U=E;E+=G;const q=i._resolveColor(N.color,W);_.push({catIdx:k,dsIdx:W,category:i.categories[k]||"",label:N.label||`Series ${W+1}`,val:B,color:q,x:U,y:V,w:G,h:z}),t.beginPath(),t.fillStyle=i._makeGradient(t,q,U,V,U+G,V),i._drawRoundedBar(t,U,V,G,z,W===f-1?i.barCornerRadius:0,!1),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?q:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),L===k&&F===W&&i.hoverHighlight&&(t.save(),t.fillStyle=i.hoverHighlightColor,i._drawRoundedBar(t,U,V,G,z,W===f-1?i.barCornerRadius:0,!1),t.fill(),t.restore())})}}else{const P=M/p;for(let k=0;k<p;k++){const O=C+k*P+P/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[k]||"",O,w+I+5),i.enableShadows&&(t.shadowColor=i.shadowColor));let E=w+I;i.datasets.forEach((N,W)=>{const B=N.data[k]??0;if(B===0)return;const G=B/h*I,z=Math.min(i.barWidth*f+i.barGap,P-8),V=O-z/2,U=E-G;E-=G;const q=i._resolveColor(N.color,W);_.push({catIdx:k,dsIdx:W,category:i.categories[k]||"",label:N.label||`Series ${W+1}`,val:B,color:q,x:V,y:U,w:z,h:G}),t.beginPath(),t.fillStyle=i._makeGradient(t,q,V,U,V,U+G),i._drawRoundedBar(t,V,U,z,G,W===f-1?i.barCornerRadius:0,!0),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?q:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),L===k&&F===W&&i.hoverHighlight&&(t.save(),t.fillStyle=i.hoverHighlightColor,i._drawRoundedBar(t,V,U,z,G,W===f-1?i.barCornerRadius:0,!0),t.fill(),t.restore())})}}else if(i.orientation==="horizontal"){const P=I/p,k=f*i.barWidth+Math.max(0,(f-1)*i.barGap),O=C+(0-g)/h*M;for(let E=0;E<p;E++){const N=w+E*P+P/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[E]||"",C-5,N),i.enableShadows&&(t.shadowColor=i.shadowColor));const W=N-k/2;i.datasets.forEach((B,G)=>{const z=B.data[E]??0,V=Math.abs(z/h*M);if(V<1)return;const U=W+G*(i.barWidth+i.barGap),q=z>=0?O:O-V,Y=i._resolveColor(B.color,G);_.push({catIdx:E,dsIdx:G,category:i.categories[E]||"",label:B.label||`Series ${G+1}`,val:z,color:Y,x:q,y:U,w:V,h:i.barWidth}),t.beginPath(),t.fillStyle=i._makeGradient(t,Y,q,U,q+V,U),i._drawRoundedBar(t,q,U,V,i.barWidth,i.barCornerRadius,!1),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?Y:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),L===E&&F===G&&i.hoverHighlight&&(t.save(),t.fillStyle=i.hoverHighlightColor,i._drawRoundedBar(t,q,U,V,i.barWidth,i.barCornerRadius,!1),t.fill(),t.restore()),i.showValueOnTop&&z!==0&&(t.font=(i.valueFontWeight||"bold")+" "+(i.valueFontSize||10)+"px Inter, sans-serif",t.textAlign=z>=0?"left":"right",t.textBaseline="middle",t.fillStyle=i.valueColor==="auto"?Y:i.valueColor||"#fff",t.shadowColor="transparent",t.fillText(z.toString(),z>=0?q+V+4:q-4,U+i.barWidth/2),i.enableShadows&&(t.shadowColor=i.shadowColor))})}}else{const P=M/p,k=f*i.barWidth+Math.max(0,(f-1)*i.barGap),O=w+I-(0-g)/h*I;for(let E=0;E<p;E++){const N=C+E*P+P/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[E]||"",N,w+I+5),i.enableShadows&&(t.shadowColor=i.shadowColor));const W=N-k/2;i.datasets.forEach((B,G)=>{const z=B.data[E]??0,V=Math.abs(z/h*I);if(V<1)return;const U=W+G*(i.barWidth+i.barGap),q=z>=0?O-V:O,Y=i._resolveColor(B.color,G);_.push({catIdx:E,dsIdx:G,category:i.categories[E]||"",label:B.label||`Series ${G+1}`,val:z,color:Y,x:U,y:q,w:i.barWidth,h:V}),t.beginPath(),t.fillStyle=i._makeGradient(t,Y,U,q,U,q+V),i._drawRoundedBar(t,U,q,i.barWidth,V,i.barCornerRadius,!0),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?Y:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),L===E&&F===G&&i.hoverHighlight&&(t.save(),t.fillStyle=i.hoverHighlightColor,i._drawRoundedBar(t,U,q,i.barWidth,V,i.barCornerRadius,!0),t.fill(),t.restore()),i.showValueOnTop&&z!==0&&(t.font=(i.valueFontWeight||"bold")+" "+(i.valueFontSize||10)+"px Inter, sans-serif",t.textAlign="center",t.textBaseline=z>=0?"bottom":"top",t.fillStyle=i.valueColor==="auto"?Y:i.valueColor||"#fff",t.shadowColor="transparent",t.fillText(z.toString(),U+i.barWidth/2,z>=0?q-4:q+V+4),i.enableShadows&&(t.shadowColor=i.shadowColor))})}}if(this.barChartRenderedBars.set(s.id,_),i.showHoverTooltip&&L!==null&&L!==void 0&&F!==null&&F!==void 0){const P=_.find(k=>k.catIdx===L&&k.dsIdx===F);if(P){t.save();const k=10,O=8,E=14,W=O*2+E+16;t.font="bold 10px Inter, system-ui, sans-serif";const B=t.measureText(P.category||"Category").width;t.font="9px Inter, system-ui, sans-serif";const G=t.measureText(`${P.label}: ${P.val}`).width+16,z=Math.max(B,G)+k*2;let V=P.x+P.w/2-z/2,U=P.y-W-8;V<-a/2+6&&(V=-a/2+6),V+z>a/2-6&&(V=a/2-z-6),U<-r/2+6&&(U=P.y+P.h+8),t.shadowColor="rgba(0, 0, 0, 0.35)",t.shadowBlur=10,t.shadowOffsetX=0,t.shadowOffsetY=4,t.beginPath(),this.drawRoundRect(t,V,U,z,W,i.tooltipRadius),t.fillStyle=i.tooltipBg,t.fill(),t.shadowColor="transparent",t.lineWidth=1,t.strokeStyle="rgba(255, 255, 255, 0.12)",t.stroke(),t.font="bold 10px Inter, system-ui, sans-serif",t.fillStyle=i.tooltipTextColor,t.textAlign="left",t.textBaseline="top",t.fillText(P.category,V+k,U+O);const q=U+O+E+2;t.beginPath(),t.arc(V+k+4,q+5,3.5,0,Math.PI*2),t.fillStyle=P.color,t.fill(),t.font="9px Inter, system-ui, sans-serif",t.fillStyle=i.tooltipTextColor,t.fillText(`${P.label}: `,V+k+12,q);const Y=t.measureText(`${P.label}: `).width;t.font="bold 9px Inter, system-ui, sans-serif",t.fillStyle="#60a5fa",t.fillText(`${P.val}`,V+k+12+Y,q),t.restore()}}t.restore()}renderPieChart(t,s){var C,w;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:ms[e.colorPalette||"vibrant"]||ms.vibrant;let i=e.slices||[{id:"slice-1",label:"Item 1",value:45,color:""}];if(e.isDataVarEnabled&&e.dataInputId){let M=this.inputs.get(e.dataInputId);if(M===void 0){const I=this.inputNameMap.get(e.dataInputId);I&&I.length>0&&(M=this.inputs.get(I[0]))}M&&Array.isArray(M)&&(i=M.map((I,A)=>{var _,T;return{id:`slice-${A}`,label:((_=i[A])==null?void 0:_.label)||`Item ${A+1}`,value:typeof I=="number"?I:0,color:((T=i[A])==null?void 0:T.color)||""}}))}const a={width:((C=s.geometry)==null?void 0:C.width)||180,height:((w=s.geometry)==null?void 0:w.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)",showHoverTooltip:e.showHoverTooltip!==void 0?!!e.showHoverTooltip:!0,hoverExplode:e.hoverExplode!==void 0?!!e.hoverExplode:!0,tooltipBg:e.tooltipBg||"#111827",tooltipTextColor:e.tooltipTextColor||"#f9fafb",tooltipRadius:e.tooltipRadius!==void 0?e.tooltipRadius:6,_resolveSliceColor:function(M,I){return M.color?M.color:n[I%n.length]},_hexToRgb:function(M){if(M.startsWith("rgba")||M.startsWith("rgb"))return M;const I=M.replace("#",""),A=parseInt(I.substring(0,2),16),_=parseInt(I.substring(2,4),16),T=parseInt(I.substring(4,6),16);return`rgba(${A},${_},${T},${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((M,I)=>M+(I.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 u=a._hexToRgb(a.cardBackground);t.beginPath(),t.roundRect(-r/2,-l/2,r,l,10),t.fillStyle=u,t.fill(),t.strokeStyle=a.cardBorderColor,t.lineWidth=1,t.stroke();const g=a.showLegend?Math.ceil(a.slices.length/2):0,p=g>0?g*(a.legendFontSize+8)+10:0,f=l-p-16,h=Math.min(r-24,f)/2,S=0,y=-p/2,c=[],v=this.graphHoverStates.get(s.id),m=(v==null?void 0:v.hoveredSliceIndex)??null;if(a.chartType==="rose"){const M=Math.max(...a.slices.map(_=>_.value||0)),I=Math.PI*2/a.slices.length,A=h>0?a.sliceGap/h:0;a.slices.forEach((_,T)=>{const L=_.value||0;if(L===0)return;const F=L/M*h,D=-Math.PI/2+T*I+A/2,R=D+I-A,X=a._resolveSliceColor(_,T),P=D+(R-D)/2,k=m===T;let O=S,E=y;if(k&&a.hoverExplode&&(O+=Math.cos(P)*6,E+=Math.sin(P)*6),c.push({index:T,startA:D,endA:R,innerR:0,outerR:F,cx:O,cy:E,slice:_,color:X,pct:Math.round(L/d*100)}),t.beginPath(),t.moveTo(O,E),t.arc(O,E,F,D,R),t.closePath(),t.fillStyle=X+"cc",t.fill(),t.strokeStyle=X,t.lineWidth=k?2.5:1.5,t.stroke(),a.showLabels){const N=O+F*.65*Math.cos(P),W=E+F*.65*Math.sin(P),B=Math.round(L/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(`${B}%`,N,W),t.restore()}})}else{const M=a.chartType==="pie"?0:a.innerRadius,I=h*Math.max(0,M),A=h>0?a.sliceGap/h:0;let _=-Math.PI/2;if(a.slices.forEach((T,L)=>{const F=T.value||0;if(F===0){_+=F/d*Math.PI*2;return}const D=F/d*Math.PI*2,R=_+A/2,X=_+D-A/2;if(X<=R){_+=D;return}const P=a._resolveSliceColor(T,L),k=R+(X-R)/2,O=m===L;let E=S,N=y;if(O&&a.hoverExplode&&(E+=Math.cos(k)*6,N+=Math.sin(k)*6),c.push({index:L,startA:R,endA:X,innerR:I,outerR:h,cx:E,cy:N,slice:T,color:P,pct:Math.round(F/d*100)}),t.beginPath(),t.fillStyle=P,I<=0?(t.moveTo(E,N),t.arc(E,N,h,R,X),t.lineTo(E,N)):(t.moveTo(E+h*Math.cos(R),N+h*Math.sin(R)),t.arc(E,N,h,R,X),t.arc(E,N,I,X,R,!0),t.closePath()),t.fill(),O&&(t.lineWidth=2,t.strokeStyle="#ffffff",t.stroke()),a.showLabels){const W=I+(h-I)/2,B=E+W*Math.cos(k),G=N+W*Math.sin(k),z=Math.round(F/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(`${z}%`,B,G),t.restore()}_+=D}),a.chartType==="donut"&&a.showCenterText&&I>14){const T=Math.round(d),L=Math.min(Math.floor(I*.52),20),F=Math.min(Math.floor(I*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${L}px Inter, sans-serif`,t.fillStyle=a.centerTextColor,t.fillText(T.toString(),S,y-F*.5),t.font=`${F}px Inter, sans-serif`,t.fillStyle=a.centerLabelColor,t.fillText(a.centerLabel,S,y+L*.6)}}if(this.pieChartRenderedSlices.set(s.id,c),a.showLegend&&a.slices.length>0){t.font=`${a.legendFontSize}px Inter, sans-serif`;const M=2,I=r/M,A=a.legendFontSize+8,_=l/2-p+10,T=-r/2+10;a.slices.forEach((L,F)=>{const D=F%M,R=Math.floor(F/M),X=T+D*I,P=_+R*A,k=a._resolveSliceColor(L,F),O=7;t.beginPath(),t.roundRect(X,P-O/2,O,O,2),t.fillStyle=k,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=a.legendColor;const E=Math.round((L.value||0)/d*100),N=`${L.label||"Item"} ${E}%`,W=I-O-20;let B=N;for(;t.measureText(B).width>W&&B.length>4;)B=B.slice(0,-4)+"…";t.fillText(B,X+O+4,P)})}if(a.showHoverTooltip&&m!==null&&m!==void 0){const M=c.find(I=>I.index===m);if(M){t.save();const I=10,A=8,_=14,L=A*2+_+16;t.font="bold 10px Inter, system-ui, sans-serif";const F=t.measureText(M.slice.label||"Item").width;t.font="9px Inter, system-ui, sans-serif";const D=`${M.slice.value} (${M.pct}%)`,R=t.measureText(D).width+16,X=Math.max(F,R)+I*2,P=M.startA+(M.endA-M.startA)/2,k=(M.innerR+M.outerR)/2;let O=M.cx+Math.cos(P)*(k+10)-X/2,E=M.cy+Math.sin(P)*(k+10)-L/2;O<-r/2+6&&(O=-r/2+6),O+X>r/2-6&&(O=r/2-X-6),E<-l/2+6&&(E=-l/2+6),E+L>l/2-6&&(E=l/2-L-6),t.shadowColor="rgba(0, 0, 0, 0.35)",t.shadowBlur=10,t.shadowOffsetX=0,t.shadowOffsetY=4,t.beginPath(),this.drawRoundRect(t,O,E,X,L,a.tooltipRadius),t.fillStyle=a.tooltipBg,t.fill(),t.shadowColor="transparent",t.lineWidth=1,t.strokeStyle="rgba(255, 255, 255, 0.12)",t.stroke(),t.font="bold 10px Inter, system-ui, sans-serif",t.fillStyle=a.tooltipTextColor,t.textAlign="left",t.textBaseline="top",t.fillText(M.slice.label||"Item",O+I,E+A);const N=E+A+_+2;t.beginPath(),t.arc(O+I+4,N+5,3.5,0,Math.PI*2),t.fillStyle=M.color,t.fill(),t.font="bold 9px Inter, system-ui, sans-serif",t.fillStyle="#60a5fa",t.fillText(D,O+I+12,N),t.restore()}}t.restore()}renderJoystick(t,s){var S,y,c,v,m,C,w,M,I,A,_,T;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.width)!==void 0?o.width:((S=s.geometry)==null?void 0:S.width)??s.width??100,n=(o==null?void 0:o.height)!==void 0?o.height:((y=s.geometry)==null?void 0:y.height)??s.height??100,i=Math.min(e,n)*(((c=s.style)==null?void 0:c.baseSize)??.45),a=Math.min(e,n)*(((v=s.style)==null?void 0:v.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,u=0;s.handleOrigin==="top-left"?(d=e/2,u=n/2):s.handleOrigin==="bottom-right"&&(d=-e/2,u=-n/2),t.translate(d,u);const g=t.globalAlpha;if(t.globalAlpha=g*(((m=s.style)==null?void 0:m.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=((C=s.style)==null?void 0:C.baseColor)||"rgba(0,0,0,0.04)",t.fill(),(w=s.style)!=null&&w.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 p=s.overflowHandle?i:Math.max(.1,i-a);let f=0,h=0;s.joystickType==="2D"?(f=r*p,h=l*p):s.joystickType==="1D_X"?(f=r*p,h=0):s.joystickType==="1D_Y"&&(f=0,h=l*p),t.globalAlpha=g*(((I=s.style)==null?void 0:I.handleOpacity)??1),t.beginPath(),t.arc(f,h,a,0,Math.PI*2),t.fillStyle=((A=s.style)==null?void 0:A.handleColor)||"#3b82f6",t.fill(),(_=s.style)!=null&&_.handleBorderWidth?(t.lineWidth=s.style.handleBorderWidth,t.strokeStyle=s.style.handleBorderColor||"rgba(255,255,255,0.5)",t.stroke()):(t.lineWidth=1,t.strokeStyle=((T=s.style)==null?void 0:T.handleBorderColor)||"rgba(255,255,255,0.5)",t.stroke()),t.globalAlpha=g,t.restore()}getRadioGroupItemIndexAtPointer(t,s,o){var I,A;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:((A=t.geometry)==null?void 0:A.height)||100,l=e.orientation||"vertical",d=e.itemGap!==void 0?e.itemGap:16,u=e.fontSize||14,g=this.getWorldTransform(t.id),p=s-g.x,f=o-g.y,h=-g.rotation*(Math.PI/180),S=Math.cos(h),y=Math.sin(h),c=p*S-f*y,v=p*y+f*S,C=8*2,w=-a/2,M=-r/2;if(l==="vertical"){const _=Math.max(C,u)+d;for(let T=0;T<i.length;T++){const L=M+T*_;if(c>=w&&c<=w+a&&v>=L&&v<=L+_)return T}}else{let _=w;for(let T=0;T<i.length;T++){const F=i[T].length*8,D=C+6+F+d;if(c>=_&&c<=_+D&&v>=M&&v<=M+r)return T;_+=D}}return null}renderLineGraph(t,s,o,e,n){let i=o.datasets||[];if((!i||i.length===0)&&(o.data||o.graphData)&&(i=[{id:"line-1",label:"Series 1",data:o.data||o.graphData||[],lineColor:o.lineColor||"#3b82f6",lineWidth:o.lineWidth||2,showArea:o.showArea||!1,areaColor:o.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:o.smoothing||!1,showPoints:o.showPoints!==void 0?o.showPoints:!0,pointSize:o.pointSize||6,pointFill:o.pointFill||"#ffffff",pointStrokeColor:o.pointStrokeColor||o.lineColor||"#3b82f6",pointStrokeWidth:o.pointStrokeWidth||2}]),!i||i.length===0||!i.some(m=>m.data&&m.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 a=1/0,r=-1/0,l=0;if(i.forEach(m=>{let C=m.data;if(m.isVarEnabled&&m.inputId){let w=this.inputs.get(m.inputId);if(w===void 0){const M=this.inputNameMap.get(m.inputId);M&&M.length>0&&(w=this.inputs.get(M[0]))}w&&Array.isArray(w)&&(C=w)}if(C&&C.length>0){const w=C.filter(M=>typeof M=="number"&&!isNaN(M));w.length>0&&(a=Math.min(a,...w),r=Math.max(r,...w),l=Math.max(l,C.length))}m._resolvedData=C}),l<2)return;const d=r-a,u=e/(l-1),g=m=>{const C=d===0?.5:(m-a)/d;return n/2-C*n},p=m=>m*u-e/2,f=o.axisColor||"#333333";if(o.showXAxis&&(t.beginPath(),t.strokeStyle=o.xAxisColor||f,t.lineWidth=1,t.moveTo(-e/2,n/2),t.lineTo(e/2,n/2),t.stroke()),o.showYAxis&&(t.beginPath(),t.strokeStyle=o.yAxisColor||f,t.lineWidth=1,t.moveTo(-e/2,-n/2),t.lineTo(-e/2,n/2),t.stroke()),t.fillStyle=o.axisLabelColor||"#333333",t.font=`${o.axisLabelFontSize||10}px Inter, sans-serif`,o.showXLabels){t.textAlign="center",t.textBaseline="top";for(let m=0;m<l;m++){const C=p(m);t.fillText(`${m+1}`,C,n/2+5)}}if(o.showYLabels){t.textAlign="right",t.textBaseline="middle";const m=-e/2-5,C=(r+a)/2;t.fillText(r.toFixed(1),m,g(r)),t.fillText(C.toFixed(1),m,g(C)),t.fillText(a.toFixed(1),m,g(a))}const h=10;if(i.forEach(m=>{const C=m._resolvedData;if(!(!C||C.length<2)){if(m.showArea){if(t.beginPath(),t.moveTo(p(0),n/2),t.lineTo(p(0),g(C[0])),m.smoothing&&C.length>2)for(let M=0;M<C.length-1;M++){const I=C[M===0?M:M-1],A=C[M],_=C[M+1],T=C[M+1===C.length-1?M+1:M+2];for(let L=1;L<=h;L++){const F=L/h,D=this._catmullRom(I,A,_,T,F);t.lineTo(p(M+F),g(D))}}else for(let M=1;M<C.length;M++)t.lineTo(p(M),g(C[M]));t.lineTo(p(C.length-1),n/2),t.closePath();const w=t.globalAlpha;t.globalAlpha=w*(o.areaOpacity??.3),t.fillStyle=m.areaColor||"rgba(139, 92, 246, 0.2)",t.fill(),t.globalAlpha=w}if(t.beginPath(),t.strokeStyle=m.lineColor||"#3b82f6",t.lineWidth=m.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.moveTo(p(0),g(C[0])),m.smoothing&&C.length>2)for(let w=0;w<C.length-1;w++){const M=C[w===0?w:w-1],I=C[w],A=C[w+1],_=C[w+1===C.length-1?w+1:w+2];for(let T=1;T<=h;T++){const L=T/h,F=this._catmullRom(M,I,A,_,L);t.lineTo(p(w+L),g(F))}}else for(let w=1;w<C.length;w++)t.lineTo(p(w),g(C[w]));t.stroke(),m.showPoints&&C.forEach((w,M)=>{const I=p(M),A=g(w);t.beginPath(),t.arc(I,A,(m.pointSize||6)/2,0,Math.PI*2),t.fillStyle=m.pointFill||"#ffffff",t.fill(),t.strokeStyle=m.pointStrokeColor||m.lineColor||"#3b82f6",t.lineWidth=m.pointStrokeWidth||1,t.stroke()})}}),o.showLegend&&i.length>0){const m=e/2-10;let C=-n/2+15;const w=o.legendFontSize||10,M=w+5;t.font=`${w}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",i.forEach(I=>{const _=I.label||"Series",T=t.measureText(_).width;t.beginPath(),t.rect(m-T-8-5,C-(8/2+2),8,8),t.fillStyle=I.lineColor||"#3b82f6",t.fill(),t.fillStyle=o.legendColor||"#333333",t.fillText(_,m,C),C+=M})}const S=this.graphHoverStates.get(s==null?void 0:s.id),y=S==null?void 0:S.hoveredIndex,c=o.showHoverTooltip!==!1,v=o.showHoverLine!==!1;if(y!=null&&(c||v)){const m=p(y);v&&(t.save(),t.beginPath(),t.strokeStyle=o.hoverLineColor||"rgba(255, 255, 255, 0.35)",t.lineWidth=1,t.setLineDash([3,3]),t.moveTo(m,-n/2),t.lineTo(m,n/2),t.stroke(),t.setLineDash([]),t.restore());const C=[];if(i.forEach(w=>{const M=w._resolvedData||w.data;if(M&&M[y]!==void 0&&typeof M[y]=="number"&&!isNaN(M[y])){const I=M[y],A=g(I),_=w.lineColor||"#3b82f6";C.push({y:A,color:_,label:w.label||"Series",val:I}),t.save(),t.beginPath();const T=o.pointHighlightRadius||5;t.arc(m,A,T+3,0,Math.PI*2),t.fillStyle=typeof _=="string"&&_.startsWith("#")?`${_}33`:"rgba(59, 130, 246, 0.2)",t.fill(),t.beginPath(),t.arc(m,A,T,0,Math.PI*2),t.fillStyle="#ffffff",t.fill(),t.strokeStyle=_,t.lineWidth=2.5,t.stroke(),t.restore()}}),c&&C.length>0){t.save();const w=10,M=8,I=16,A=14,_=M*2+A+C.length*I;t.font="bold 10px Inter, system-ui, sans-serif";let T=t.measureText(`Point #${y+1}`).width;t.font="9px Inter, system-ui, sans-serif",C.forEach(P=>{const k=t.measureText(`${P.label}: ${P.val.toFixed(1)}`).width+16;k>T&&(T=k)});const L=T+w*2;let F=m+12;F+L>e/2-4&&(F=m-L-12),F<-e/2+4&&(F=-e/2+4);let R=C.reduce((P,k)=>P+k.y,0)/C.length-_/2;R<-n/2+6&&(R=-n/2+6),R+_>n/2-6&&(R=n/2-_-6),t.shadowColor="rgba(0, 0, 0, 0.35)",t.shadowBlur=10,t.shadowOffsetX=0,t.shadowOffsetY=4,t.beginPath(),this.drawRoundRect(t,F,R,L,_,o.tooltipRadius||6),t.fillStyle=o.tooltipBg||"#111827",t.fill(),t.shadowColor="transparent",t.lineWidth=1,t.strokeStyle="rgba(255, 255, 255, 0.12)",t.stroke(),t.font="bold 10px Inter, system-ui, sans-serif",t.fillStyle=o.tooltipTextColor||"#f9fafb",t.textAlign="left",t.textBaseline="top",t.fillText(`Point #${y+1}`,F+w,R+M);let X=R+M+A+2;t.font="9px Inter, system-ui, sans-serif",C.forEach(P=>{t.beginPath(),t.arc(F+w+4,X+5,3.5,0,Math.PI*2),t.fillStyle=P.color,t.fill(),t.fillStyle=o.tooltipTextColor||"#f9fafb",t.fillText(`${P.label}: `,F+w+12,X);const k=t.measureText(`${P.label}: `).width;t.font="bold 9px Inter, system-ui, sans-serif",t.fillStyle="#60a5fa",t.fillText(`${P.val.toFixed(1)}`,F+w+12+k,X),t.font="9px Inter, system-ui, sans-serif",X+=I}),t.restore()}}}_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.type)&&s.color){const r=typeof s.color=="string"?s.color:s.color.color||"#000000",d=(((i=(n=this.artboard)==null?void 0:n.tokens)==null?void 0:i.colors)||{})[r]||r;return t.fillStyle=d,d}if(typeof s=="object"&&"r"in s&&"g"in s&&"b"in s){const r=s.a!==void 0?s.a:s.opacity!==void 0?s.opacity:1;return`rgba(${s.r}, ${s.g}, ${s.b}, ${r})`}if((s.type==="LinearGradient"||s.type==="RadialGradient"||s.type==="AngularGradient"||s.type==="DiamondGradient")&&s.stops){const r=(l,d=100)=>{var m,C;const g=(((C=(m=this.artboard)==null?void 0:m.tokens)==null?void 0:C.colors)||{})[l]||l,p=this.normalizeOpacity(s.opacity??100),h=this.normalizeOpacity(d)*p;if(h>=1&&g.startsWith("#"))return g;const S=g.startsWith("#")?g.replace("#",""):"ffffff",y=parseInt(S.substring(0,2),16),c=parseInt(S.substring(2,4),16),v=parseInt(S.substring(4,6),16);return`rgba(${y}, ${c}, ${v}, ${h})`};if(s.type==="LinearGradient"){let l=0,d=-e/2,u=0,g=e/2;if(s.angle!==void 0&&(!s.start||!s.end)){const f=(s.angle-90)*Math.PI/180,h=Math.max(o,e)/2;l=Math.cos(f)*-h,d=Math.sin(f)*-h,u=Math.cos(f)*h,g=Math.sin(f)*h}else if(s.start||s.end){const f=(h,S,y)=>Array.isArray(h)?h[S]??.5:h&&typeof h=="object"?h[y]??.5:.5;l=f(s.start,0,"x")*o-o/2,d=f(s.start,1,"y")*e-e/2,u=f(s.end,0,"x")*o-o/2,g=f(s.end,1,"y")*e-e/2}Math.abs(l-u)<.001&&Math.abs(d-g)<.001&&(l=0,d=-e/2,u=0,g=e/2);const p=t.createLinearGradient(l,d,u,g);if(s.stops.forEach(f=>{const h=f.offset!==void 0?f.offset:f.pos!==void 0?f.pos:f.position!==void 0?f.position:0,S=r(f.color||"#000000",f.opacity??100);p.addColorStop(Math.max(0,Math.min(1,h)),S)}),s.gradientTransform&&p.setTransform){const[f,h,S,y,c,v]=s.gradientTransform;p.setTransform({a:f,b:h,c:S,d:y,e:c,f:v})}return p}else if(s.type==="RadialGradient"){const l=(f,h,S)=>Array.isArray(f)?f[h]??.5:f&&typeof f=="object"?f[S]??.5:.5,d=l(s.center,0,"x")*o-o/2,u=l(s.center,1,"y")*e-e/2,g=(s.radius??.5)*Math.max(o,e),p=t.createRadialGradient(d,u,0,d,u,g);if(s.stops.forEach(f=>{const h=f.offset!==void 0?f.offset:f.pos!==void 0?f.pos:f.position!==void 0?f.position:0,S=r(f.color||"#000000",f.opacity??100);p.addColorStop(Math.max(0,Math.min(1,h)),S)}),s.gradientTransform&&p.setTransform){const[f,h,S,y,c,v]=s.gradientTransform;p.setTransform({a:f,b:h,c:S,d:y,e:c,f:v})}return p}else if(s.type==="AngularGradient"){const l=(f,h,S)=>Array.isArray(f)?f[h]??.5:f&&typeof f=="object"?f[S]??.5:.5,d=l(s.center||[.5,.5],0,"x")*o-o/2,u=l(s.center||[.5,.5],1,"y")*e-e/2,g=(s.degree||s.angle||0)*(Math.PI/180),p=(a=t.createConicGradient)==null?void 0:a.call(t,g,d,u);if(p){if(s.stops.forEach(f=>{const h=f.offset!==void 0?f.offset:f.pos!==void 0?f.pos:f.position!==void 0?f.position:0,S=r(f.color||"#000000",f.opacity??100);p.addColorStop(Math.max(0,Math.min(1,h)),S)}),s.gradientTransform&&p.setTransform){const[f,h,S,y,c,v]=s.gradientTransform;p.setTransform({a:f,b:h,c:S,d:y,e:c,f:v})}return p}}else if(s.type==="DiamondGradient"){const l=(f,h,S)=>Array.isArray(f)?f[h]??.5:f&&typeof f=="object"?f[S]??.5:.5,d=l(s.center||[.5,.5],0,"x")*o-o/2,u=l(s.center||[.5,.5],1,"y")*e-e/2,g=(s.radius??.5)*Math.max(o,e);t.save(),t.translate(d,u),t.rotate(Math.PI/4);const p=t.createRadialGradient(0,0,0,0,0,g);if(s.stops.forEach(f=>{const h=f.offset!==void 0?f.offset:f.pos!==void 0?f.pos:f.position!==void 0?f.position:0,S=r(f.color||"#000000",f.opacity??100);p.addColorStop(Math.max(0,Math.min(1,h)),S)}),s.gradientTransform&&p.setTransform){const[f,h,S,y,c,v]=s.gradientTransform;p.setTransform({a:f,b:h,c:S,d:y,e:c,f:v})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=p,t.restore(),p}}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,u=s.scaleX??1,g=s.scaleY??1,p=s.offsetX??0,f=s.offsetY??0,h=s.rotation??0;d.translateSelf(p,f),d.rotateSelf(h),d.scaleSelf(u,g),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,u=0;typeof a=="number"?r=l=d=u=a:Array.isArray(a)?a.length===1?r=l=d=u=a[0]:a.length===2?(r=d=a[0],l=u=a[1]):a.length===3?(r=a[0],l=u=a[1],d=a[2]):a.length>=4&&(r=a[0],l=a[1],d=a[2],u=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,u=a[3]??a.bl??a.corner_radius??a.cornerRadius??0);const g=Math.min(Math.abs(e)/2,Math.abs(n)/2);if(r=Math.min(Math.max(0,r),g),l=Math.min(Math.max(0,l),g),d=Math.min(Math.max(0,d),g),u=Math.min(Math.max(0,u),g),t.roundRect){t.roundRect(s,o,e,n,[r,l,d,u]);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+u,o+n),t.arcTo(s,o+n,s,o+n-u,u),t.lineTo(s,o+r),t.arcTo(s,o,s+r,o,r),t.closePath()}renderListView(t,s){var R,X,P,k,O,E,N,W,B,G;const o=this.objectStates.get(s.id)||{},e=o.options||s.options||{},n=o.width!==void 0?o.width:((R=s.geometry)==null?void 0:R.width)||200,i=o.height!==void 0?o.height:((X=s.geometry)==null?void 0:X.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??((P=s.geometry)==null?void 0:P.cornerRadius)??((k=s.geometry)==null?void 0:k.corner_radius)??0,d=e.orientation||"vertical",u=this.getResolvedListViewItems(s,e),g=e.itemGap??10,p=e.itemHeight??50,f=e.itemWidth??200,h=e.scrollOffset??0,S=e.padding??0,y=e.glassEffect!==!1,c=e.accentColor||"#3b82f6",v=e.itemTextColor||"#333333",m=e.itemBackgroundColor||"#ffffff",C=e.hoveredIndex??null,w=e.activeItemIndex??null,M=e.glowIntensity??0,I=e.glowColor||"#3b82f6",A=typeof I=="string"?I:I.color||((E=(O=I.stops)==null?void 0:O[0])==null?void 0:E.color)||"#3b82f6",_=e.opacity!==void 0?e.opacity:s.opacity!==void 0?s.opacity:1;if(t.save(),t.globalAlpha*=_,M>0){const z=t.getTransform(),V=Math.sqrt(z.a*z.a+z.b*z.b)||1;t.shadowColor=A,t.shadowBlur=M*2*V,t.shadowOffsetX=0,t.shadowOffsetY=0}if(y){const z=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",V=this.createCanvasFill(t,z,n,i);t.fillStyle=V||"rgba(31, 41, 55, 0.4)",t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)||t.fill();const q=t.createLinearGradient(a,r,a+n,r+i);q.addColorStop(0,"rgba(255, 255, 255, 0.15)"),q.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),q.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=q,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)||t.fill();const H=e.borderWidth??0;if(H>0&&e.borderColor&&e.borderColor!=="transparent"){const dt=this.createCanvasFill(t,e.borderColor,n,i);t.strokeStyle=dt||"rgba(255, 255, 255, 0.25)",t.lineWidth=H}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 z=e.backgroundColor&&e.backgroundColor!=="transparent"?e.backgroundColor:e.listBackgroundColor||"transparent",V=this.createCanvasFill(t,z,n,i);if(V){t.fillStyle=V,t.beginPath();const q=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l);t.fill()}const U=e.borderWidth??0;if(U>0){const q=this.createCanvasFill(t,e.borderColor||"#cccccc",n,i);t.strokeStyle=q||"#cccccc",t.lineWidth=U,t.beginPath();const Y=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l);t.stroke()}}t.shadowBlur=0;const T=e.clipContent!==!1&&e.listLayout!=="circular";if(T)if(t.save(),t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)&&e.containerShape==="custom")try{const V=new Path2D(e.containerPath);t.translate(a,r),t.scale(n/100,i/100),t.clip(V),t.scale(100/n,100/i),t.translate(-a,-r)}catch{}else t.clip();const L=typeof S=="number"?S:d==="vertical"?S[0]:S[3];let F=(d==="vertical"?r:a)+h+L;if(t.textBaseline="middle",u.forEach((z,V)=>{var ut,Lt,Ct,Tt;const U=e.listLayout||"linear",q=U==="circular"?f:d==="vertical"?n:f,Y=U==="circular"||d==="vertical"?p:i;let H=0,x=0,dt=0;if(U==="circular"){const Et=u.length||1,tt=Math.PI*2/Et,at=e.circularStartAngle||0,ct=e.circularRadius||100,Pt=h*.01+at*Math.PI/180,kt=V*tt+Pt,It=a+n/2,xt=r+i/2;H=It+Math.cos(kt)*ct-q/2,x=xt+Math.sin(kt)*ct-Y/2,dt=kt+(e.itemRotation||0)*Math.PI/180}else H=d==="vertical"?a:F,x=d==="vertical"?F:r,dt=(e.itemRotation||0)*Math.PI/180;const _t=C===V,vt=w===V,Yt=e.itemBorderWidth??0;t.save(),dt!==0&&(t.translate(H+q/2,x+Y/2),t.rotate(dt),t.translate(-(H+q/2),-(x+Y/2)));const Mt=_t?((ut=e.hoverStyle)==null?void 0:ut.scale)??1:vt?((Lt=e.activeStyle)==null?void 0:Lt.scale)??1:1;if(Mt!==1&&(t.translate(H+q/2,x+Y/2),t.scale(Mt,Mt),t.translate(-(H+q/2),-(x+Y/2))),vt){const Et=((Ct=e.activeStyle)==null?void 0:Ct.itemBackgroundColor)||e.activeBackgroundColor||(y?"rgba(255, 255, 255, 0.15)":"rgba(0, 0, 0, 0.1)"),tt=this.createCanvasFill(t,Et,q,Y);t.fillStyle=tt||(typeof Et=="string"?Et:"transparent"),t.beginPath(),this.drawCustomShape(t,e.activeItemShape||e.itemShape||"rectangle",e.activeItemShape==="custom"?e.activeItemPath||"":e.itemPath||"",H,x,q,Y,e.itemCornerRadius??0)||t.fill()}else if(_t){const Et=((Tt=e.hoverStyle)==null?void 0:Tt.itemBackgroundColor)||e.hoverBackgroundColor||(y?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)"),tt=this.createCanvasFill(t,Et,q,Y);t.fillStyle=tt||(typeof Et=="string"?Et:"transparent"),t.beginPath(),this.drawCustomShape(t,e.itemShape||"rectangle",e.itemPath||"",H,x,q,Y,e.itemCornerRadius??0)||t.fill()}else if(m!=="transparent"){const Et=this.createCanvasFill(t,m,q,Y);t.fillStyle=Et||(typeof m=="string"?m:"transparent"),t.beginPath(),this.drawCustomShape(t,e.itemShape||"rectangle",e.itemPath||"",H,x,q,Y,e.itemCornerRadius??0)||t.fill()}if(Yt>0&&e.itemBorderColor&&e.itemBorderColor!=="transparent"){const Et=this.createCanvasFill(t,e.itemBorderColor,q,Y);t.strokeStyle=Et||(typeof e.itemBorderColor=="string"?e.itemBorderColor:"#cccccc"),t.lineWidth=Yt,t.beginPath(),this.drawCustomShape(t,e.itemShape||"rectangle",e.itemPath||"",H,x,q,Y,e.itemCornerRadius??0)||t.stroke()}if(vt){const Et=this.createCanvasFill(t,c,d==="vertical"?3:q,d==="vertical"?Y:3);t.fillStyle=Et||c,d==="vertical"?t.fillRect(H,x,3,Y):t.fillRect(H,x+Y-3,q,3)}const Wt=vt?"#ffffff":y?"rgba(255, 255, 255, 0.9)":v;t.fillStyle=Wt,t.font=vt||_t?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const Ot=typeof z=="string"?z:(z==null?void 0:z.label)||`Item ${V+1}`,yt=H+(d==="vertical"?16:q/2),Ft=x+Y/2;d==="horizontal"||U==="circular"?t.textAlign="center":t.textAlign="left";const K=U==="circular"?H+q/2:yt;t.fillText(Ot,K,Ft),t.restore(),t.beginPath(),F+=(d==="vertical"?p:f)+g}),T&&t.restore(),e.showScrollbar!==!1){const z=typeof S=="number"?S:d==="vertical"?S[0]:S[3],U=(u.length||0)*(d==="vertical"?p:f)+Math.max(0,(u.length||0)-1)*g+z*2,q=d==="vertical"?i:n,Y=e.listLayout||"linear",H=e.containerShape==="circle"||Y==="circular",x=e.scrollbarColor||"rgba(255,255,255,0.3)";let dt=typeof x=="object"?x.color||((W=(N=x.stops)==null?void 0:N[0])==null?void 0:W.color)||"rgba(255,255,255,0.3)":x;const _t=((G=(B=this.artboard)==null?void 0:B.tokens)==null?void 0:G.colors)||{};_t[dt]&&(dt=_t[dt]);const vt=e.scrollbarWidth||2;if(t.save(),H){const Yt=Math.min(n,i)/2-vt/2-2,Mt=a+n/2,Wt=r+i/2;if(t.strokeStyle=dt,t.lineWidth=vt,t.lineCap="round",t.beginPath(),Y==="circular"){const Ot=Math.PI/4,yt=-(h*.01)-Math.PI/2;t.arc(Mt,Wt,Yt,yt,yt+Ot)}else{const Ot=Math.PI/2,yt=U>0?Math.min(1,q/U):1,Ft=Ot*yt,K=U>0?-h/U*Ot:0,Lt=-Math.PI/4+K;t.arc(Mt,Wt,Yt,Lt,Lt+Ft)}t.stroke()}else{let Yt=q,Mt=0;if(U>q){const Wt=q/U;Yt=Math.max(16,q*Wt);const Ot=q-Yt,yt=U-q;Mt=yt>0?Math.max(0,Math.min(Ot,-h/yt*Ot)):0}if(t.fillStyle=dt,d==="vertical"){const Wt=a+n-vt-2,Ot=r+Mt,yt=vt,Ft=Yt;if(vt>2){t.beginPath();const K=Math.min(vt/2,Yt/2);if(t.roundRect)try{t.roundRect(Wt,Ot,yt,Ft,K),t.fill()}catch{t.fillRect(Wt,Ot,yt,Ft)}else t.fillRect(Wt,Ot,yt,Ft)}else t.fillRect(Wt,Ot,yt,Ft)}else{const Wt=a+Mt,Ot=r+i-vt-2,yt=Yt,Ft=vt;if(vt>2){t.beginPath();const K=Math.min(vt/2,Yt/2);if(t.roundRect)try{t.roundRect(Wt,Ot,yt,Ft,K),t.fill()}catch{t.fillRect(Wt,Ot,yt,Ft)}else t.fillRect(Wt,Ot,yt,Ft)}else t.fillRect(Wt,Ot,yt,Ft)}}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 m,C,w,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,u=o.itemWidth??200,g=(s==null?void 0:s.width)!==void 0?s.width:((m=t.geometry)==null?void 0:m.width)||200,p=(s==null?void 0:s.height)!==void 0?s.height:((C=t.geometry)==null?void 0:C.height)||300,f=typeof o.padding=="number"?o.padding:e==="vertical"?((w=o.padding)==null?void 0:w[0])||0:((M=o.padding)==null?void 0:M[3])||0,S=(r.length||0)*(e==="vertical"?d:u)+Math.max(0,(r.length||0)-1)*l+f*2,y=e==="vertical"?p:g,c=Math.max(0,S-y);if(this.draggingListViewIsScrollbar&&o.listLayout!=="circular"){const I=S>0?y/S:1,A=Math.max(16,y*I),_=Math.max(1,y-A),T=c>0?c/_:1;e==="vertical"?a-=i*T:a-=n*T}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 P,k;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:((P=t.geometry)==null?void 0:P.width)||200,r=(e==null?void 0:e.height)!==void 0?e.height:((k=t.geometry)==null?void 0:k.height)||300,l=n.orientation||"vertical",d=n.itemGap??10,u=n.itemHeight??50,g=n.itemWidth??200,p=n.scrollOffset??0,f=n.padding??0,h=this.getWorldTransform(t.id),S=s-h.x,y=o-h.y,c=-h.rotation*(Math.PI/180),v=Math.cos(c),m=Math.sin(c),C=S*v-y*m,w=S*m+y*v,M=-a/2,I=-r/2,A=typeof f=="number"?f:l==="vertical"?f[0]:f[3];let _=(l==="vertical"?I:M)+p+A;const T=n.listLayout||"linear",L=i.length||1,F=Math.PI*2/L,D=n.circularStartAngle||0,R=n.circularRadius||100,X=p*.01+D*Math.PI/180;for(let O=0;O<i.length;O++){const E=T==="circular"?g:l==="vertical"?a:g,N=T==="circular"||l==="vertical"?u:r;let W=0,B=0,G=0;if(T==="circular"){const z=O*F+X,V=M+a/2,U=I+r/2;W=V+Math.cos(z)*R-E/2,B=U+Math.sin(z)*R-N/2,G=z+(n.itemRotation||0)*Math.PI/180}else W=l==="vertical"?M:_,B=l==="vertical"?_:I,G=(n.itemRotation||0)*Math.PI/180;if(G!==0){const z=W+E/2,V=B+N/2,U=C-z,q=w-V,Y=-G,H=U*Math.cos(Y)-q*Math.sin(Y)+z,x=U*Math.sin(Y)+q*Math.cos(Y)+V;if(H>=W&&H<=W+E&&x>=B&&x<=B+N)return O}else if(C>=W&&C<=W+E&&w>=B&&w<=B+N)return O;_+=(l==="vertical"?u:g)+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 g,p,f,h,S,y,c,v,m,C,w,M,I,A,_,T,L,F,D,R,X,P,k,O,E,N,W,B,G,z,V,U,q,Y,H,x,dt,_t,vt,Yt,Mt,Wt,Ot,yt,Ft,K,ut,Lt,Ct,Tt,Et,tt,at,ct,Pt,kt,It,xt,ie,se,Qt,ce,le,qt,Se,Ce,Ie,fe,Oe,ye,ke,Vt,te,j,mt,et,J,ot,ht,At,ft,St,Dt,Bt,gt,$,bt,$t,Q,rt,lt,jt,oe,Rt,Kt,Xt,Jt,Gt,ge,be,Le,ae,de,he,$e,Be,De,Ye,Xe,Ne,Ue,re,ve,Te,He,xe,_e,Pe;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,u=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===st.Proximity){const Z=((g=i.settings)==null?void 0:g.radius)||300,it=((p=i.settings)==null?void 0:p.falloff)||"smooth";let nt=0;u<Z&&(it==="linear"?nt=1-u/Z:nt=Math.pow(1-u/Z,2)),i.sensors.forEach(wt=>{this.applyBehaviorSensor(n,wt,nt,t,i.settings,e,l,d,u)})}else if(i.type===st.Magnetic){const Z=((f=i.settings)==null?void 0:f.radius)||400,it=((h=i.settings)==null?void 0:h.strength)||.5;if(u<Z&&u>5){const nt=1-u/Z,wt=l*nt*it,zt=d*nt*it;n.x-=wt*t*10,n.y-=zt*t*10}}else if(i.type===st.Repel){const Z=((S=i.settings)==null?void 0:S.radius)||300,it=((y=i.settings)==null?void 0:y.strength)||1;if(u<Z){const nt=Math.pow(1-u/Z,2);n.x+=l/(u||1)*nt*60*it*t*5,n.y+=d/(u||1)*nt*60*it*t*5}}else if(i.type===st.Orbit){const Z=((c=i.settings)==null?void 0:c.speed)||1,it=((v=i.settings)==null?void 0:v.radius)||30,nt=this.currentTime*Z*Math.PI*2;n.x+=Math.cos(nt)*it*t*5,n.y+=Math.sin(nt)*it*t*5,n.rotation+=2*t*5}else if(i.type===st.Vortex){const Z=((m=i.settings)==null?void 0:m.radius)||400,it=((C=i.settings)==null?void 0:C.speed)||2,nt=((w=i.settings)==null?void 0:w.strength)||1;if(u<Z){const wt=Math.pow(1-u/Z,1.5),zt=this.currentTime*it*Math.PI*2,Ut=Math.cos(zt)*30-l*.4,Zt=Math.sin(zt)*30-d*.4;n.x+=Ut*wt*nt*t*5,n.y+=Zt*wt*nt*t*5,n.rotation+=5*wt*nt*t*5,n.scale_x*=1-wt*.1*nt*t,n.scale_y*=1-wt*.1*nt*t}}else if(i.type===st.Fluid){const Z=((M=i.settings)==null?void 0:M.radius)||300,it=((I=i.settings)==null?void 0:I.strength)||1;if(u<Z){const nt=Math.pow(1-u/Z,1.2),wt=l/(u||1)*nt*1.2*it,zt=d/(u||1)*nt*1.2*it;n.x+=wt*10*t*5,n.y+=zt*10*t*5,n.scale_x*=1+nt*.3*it*t,n.scale_y*=1+nt*.3*it*t}}else if(i.type===st.Elastic){const Z=((A=i.settings)==null?void 0:A.radius)||300,it=((_=i.settings)==null?void 0:_.strength)||1;if(u<Z){const nt=1-u/Z;n.scale_x*=1+nt*.4*it*t,n.scale_y*=1+nt*.4*it*t}}else if(i.type===st.Holographic){const Z=n.x-this.canvasWidth/2,it=n.y-this.canvasHeight/2,nt=((T=i.settings)==null?void 0:T.factor)||25;if(n.x-=Z/1e3*nt*t*5,n.y-=it/1e3*nt*t*5,n.style){const wt=1-Math.min(1,u/400);n.style.exposure=(n.style.exposure||1)+wt*.5*t}}else if(i.type===st.Sticky){const Z=((L=i.settings)==null?void 0:L.radius)||80,it=((F=i.settings)==null?void 0:F.strength)||1;if(u<Z){const nt=Math.pow(1-u/Z,2);n.x-=l*nt*it*t*10,n.y-=d*nt*it*t*10,n.scale_x*=1-nt*.1*it*t,n.scale_y*=1-nt*.1*it*t}}else if(i.type===st.Dilation){const Z=((D=i.settings)==null?void 0:D.size)||120,it=((R=i.settings)==null?void 0:R.strength)||1;if(u<Z){const nt=1-u/Z;n.scale_x*=1+nt*.5*it*t,n.scale_y*=1+nt*.5*it*t}}else if(i.type===st.Parallax){const Z=((X=i.settings)==null?void 0:X.factor)||15,it=((P=i.settings)==null?void 0:P.strength)||1,nt=this.canvasWidth/2,wt=this.canvasHeight/2,zt=this._lastPointerPos||{x:nt,y:wt},Ut=(zt.x-nt)/nt,Zt=(zt.y-wt)/wt,me=(((k=e.transform)==null?void 0:k.x)??0)+Ut*Z*it,Ae=(((O=e.transform)==null?void 0:O.y)??0)+Zt*Z*it,Fe=(((E=e.transform)==null?void 0:E.rotate_x)??0)-Zt*Z*1.5*it,we=(((N=e.transform)==null?void 0:N.rotate_y)??0)+Ut*Z*1.5*it,Re=Math.min(1,10*t);n.x=this.lerp(n.x??((W=e.transform)==null?void 0:W.x)??0,me,Re),n.y=this.lerp(n.y??((B=e.transform)==null?void 0:B.y)??0,Ae,Re),n.rotate_x=this.lerp(n.rotate_x??((G=e.transform)==null?void 0:G.rotate_x)??0,Fe,Re),n.rotate_y=this.lerp(n.rotate_y??((z=e.transform)==null?void 0:z.rotate_y)??0,we,Re)}else if(i.type===st.Fold){if(u<300){const Z=1-u/300,it=(l>0?-1:1)*Z*10,nt=1-Z*.1,wt=d/300*Z*20,zt=-(l/300)*Z*20,Ut=Math.min(1,10*t);n.skew_x=this.lerp(n.skew_x??((V=e.transform)==null?void 0:V.skew_x)??0,it,Ut),n.scale_y=this.lerp(n.scale_y??((U=e.transform)==null?void 0:U.scale_y)??1,(((q=e.transform)==null?void 0:q.scale_y)??1)*nt,Ut),n.rotate_x=this.lerp(n.rotate_x??((Y=e.transform)==null?void 0:Y.rotate_x)??0,wt,Ut),n.rotate_y=this.lerp(n.rotate_y??((H=e.transform)==null?void 0:H.rotate_y)??0,zt,Ut),n.style=n.style||{...e.style},n.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((x=i.settings)==null?void 0:x.opacity)??.5}}}else if(i.type===st.Crumple){if(u<300){const Z=1-u/300,it=Z*(Math.random()-.5)*5,nt=Z*(Math.random()-.5)*.05,wt=Math.min(1,15*t);n.skew_x=this.lerp(n.skew_x??((dt=e.transform)==null?void 0:dt.skew_x)??0,it,wt),n.scale_x=this.lerp(n.scale_x??((_t=e.transform)==null?void 0:_t.scale_x)??1,(((vt=e.transform)==null?void 0:vt.scale_x)??1)*(1+nt),wt),n.scale_y=this.lerp(n.scale_y??((Yt=e.transform)==null?void 0:Yt.scale_y)??1,(((Mt=e.transform)==null?void 0:Mt.scale_y)??1)*(1+nt),wt),n.style=n.style||{...e.style},n.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((Wt=i.settings)==null?void 0:Wt.intensity)??1,scale:((Ot=i.settings)==null?void 0:Ot.scale)??2}}}else if(i.type===st.Squash){const Z=((yt=i.settings)==null?void 0:yt.strength)||.8;u<(e.width||100)&&this.isMouseDown?(n.scale_y=this.lerp(n.scale_y??1,(((Ft=e.transform)==null?void 0:Ft.scale_y)??1)*Z,.3),n.scale_x=this.lerp(n.scale_x??1,(((K=e.transform)==null?void 0:K.scale_x)??1)*(1+(1-Z)*.4),.3)):(n.scale_y=this.lerp(n.scale_y??1,((ut=e.transform)==null?void 0:ut.scale_y)??1,.2),n.scale_x=this.lerp(n.scale_x??1,((Lt=e.transform)==null?void 0:Lt.scale_x)??1,.2))}else if(i.type===st.TextCounter){const Z=((Ct=i.settings)==null?void 0:Ct.duration)||2,it=((Tt=i.settings)==null?void 0:Tt.from)||0,nt=((Et=i.settings)==null?void 0:Et.to)||100;i._runtimeStart===void 0&&(i._runtimeStart=this.currentTime);const wt=this.currentTime-i._runtimeStart,zt=Math.min(1,wt/Z),Ut=Math.floor(it+(nt-it)*zt);if(((tt=e.geometry)==null?void 0:tt.type)==="Text"){const Zt=((at=i.settings)==null?void 0:at.prefix)||"",me=((ct=i.settings)==null?void 0:ct.suffix)||"";n.geometry||(n.geometry={...e.geometry}),n.geometry.text=`${Zt}${Ut}${me}`}}else if(i.type===st.Spotlight){const Z=((Pt=i.settings)==null?void 0:Pt.radius)||250,it=((kt=i.settings)==null?void 0:kt.strength)||1.5;if(u<Z){const nt=Math.pow(1-u/Z,2);n.style||(n.style={...e.style}),n.style.adjustments||(n.style.adjustments={...(It=e.style)==null?void 0:It.adjustments}),n.style.adjustments.exposure=(((ie=(xt=e.style)==null?void 0:xt.adjustments)==null?void 0:ie.exposure)||0)+nt*it*50}else(se=n.style)!=null&&se.adjustments&&(n.style.adjustments.exposure=this.lerp(n.style.adjustments.exposure||0,((ce=(Qt=e.style)==null?void 0:Qt.adjustments)==null?void 0:ce.exposure)||0,.1))}else if(i.type===st.Noise||i.type===st.Float){const Z=(((le=i.settings)==null?void 0:le.frequency)||((qt=i.settings)==null?void 0:qt.speed)||1)*.002,it=(((Se=i.settings)==null?void 0:Se.amplitude)||((Ce=i.settings)==null?void 0:Ce.range)||50)*(((Ie=i.settings)==null?void 0:Ie.strength)||1),nt=Date.now();n.x+=Math.sin(nt*Z)*it*t,n.y+=Math.cos(nt*Z*.8)*it*t,n.rotation+=Math.sin(nt*Z*.5)*5*t}else if(i.type===st.Pulse){const Z=(((fe=i.settings)==null?void 0:fe.speed)||1)*.005,it=(((Oe=i.settings)==null?void 0:Oe.scale)||1.2)-1,nt=Math.sin(Date.now()*Z),wt=((ye=i.settings)==null?void 0:ye.strength)||1;n.scale_x*=1+nt*it*wt*t,n.scale_y*=1+nt*it*wt*t,n.style&&(n.style.exposure=(n.style.exposure||1)+Math.max(0,nt)*.1*wt*t)}else if(i.type===st.Draggable){if(!this.draggingBehaviors.has(e.id)){const it=((ke=i.settings)==null?void 0:ke.radius)||150;if(u<it){const nt=((Vt=i.settings)==null?void 0:Vt.strength)||1,wt=Math.max(0,1-u/it);this.applyBehaviorSensor(n,ue.PositionX,wt*nt,t,i.settings,e,l,d,u),this.applyBehaviorSensor(n,ue.PositionY,wt*nt,t,i.settings,e,l,d,u)}}}else if(i.type===st.Scroll){const Z=((te=i.settings)==null?void 0:te.axis)||"vertical",it=((j=i.settings)==null?void 0:j.factor)||.5,nt=((mt=i.settings)==null?void 0:mt.strength)||1,wt=((et=i.settings)==null?void 0:et.scaleFactor)||0;(Z==="vertical"||Z==="both")&&(n.y+=this.scrollOffset.y*it*nt*t),(Z==="horizontal"||Z==="both")&&(n.x+=this.scrollOffset.x*it*nt*t),wt!==0&&(n.scale_x*=1+this.scrollOffset.y*wt*t,n.scale_y*=1+this.scrollOffset.y*wt*t)}else if(i.type===st.LookAt){const Z=((J=i.settings)==null?void 0:J.factor)||1,it=((ot=i.settings)==null?void 0:ot.strength)||1,nt=Math.atan2(-d,-l)*(180/Math.PI),wt=n.rotation,zt=(nt-wt+180)%360-180;n.rotation+=zt*Z*it*t*10}else if(i.type===st.Scan){const Z=(((ht=i.settings)==null?void 0:ht.speed)||1)*.004,it=((At=i.settings)==null?void 0:At.strength)||1,nt=(Math.sin(Date.now()*Z)+1)/2;n.style&&(n.style.exposure=(n.style.exposure||1)+nt*it*t*5),n.x+=(nt-.5)*20*it*t}else if(i.type===st.Glint)n.style=n.style||{...e.style},n.style.artEffect={enabled:!0,type:"glint_overlay",intensity:((ft=i.settings)==null?void 0:ft.strength)??.8};else if(i.type===st.Ratchet){const Z=((St=i.settings)==null?void 0:St.steps)||12,it=(((Dt=i.settings)==null?void 0:Dt.speed)||1)*30,nt=Math.floor(n.rotation/(360/Z))*(360/Z);n.rotation=this.lerp(n.rotation,nt+it*t,.1)}else if(i.type===st.Jitter&&u<300){const Z=((Bt=i.settings)==null?void 0:Bt.strength)||1,it=(((gt=i.settings)==null?void 0:gt.intensity)||5)*Z;n.x+=(Math.random()-.5)*it*t*60,n.y+=(Math.random()-.5)*it*t*60,n.rotation+=(Math.random()-.5)*it*t*120}else if(i.type===st.Follower){const Z=($=i.settings)==null?void 0:$.targetId;if(Z){const it=this.objectStates.get(Z);if(it){const nt=((bt=i.settings)==null?void 0:bt.stiffness)||.1,wt=it.x-n.x,zt=it.y-n.y;n.x+=wt*nt*t*60,n.y+=zt*nt*t*60}}}else if(i.type===st.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===st.Gravity){const Z=(($t=i.settings)==null?void 0:$t.strength)||9.8;n.y+=Z*t*10}else if(i.type===st.Velocity){const Z=((Q=i.settings)==null?void 0:Q.vx)||0,it=((rt=i.settings)==null?void 0:rt.vy)||0;n.x+=Z*t*10,n.y+=it*t*10}else if(i.type===st.Shear){const Z=((lt=i.settings)==null?void 0:lt.strength)||1,it=((jt=i.settings)==null?void 0:jt.radius)||300;if(u<it){const nt=1-u/it;n.skew_x=this.lerp(n.skew_x||0,(((oe=e.transform)==null?void 0:oe.skew_x)||0)+nt*Z*30,.1)}else n.skew_x=this.lerp(n.skew_x||0,((Rt=e.transform)==null?void 0:Rt.skew_x)||0,.05)}else if(i.type===st.Lens){const Z=((Kt=i.settings)==null?void 0:Kt.radius)||200,it=((Xt=i.settings)==null?void 0:Xt.strength)||.5;if(u<Z){const nt=Math.pow(1-u/Z,2);n.scale_x=this.lerp(n.scale_x??1,(((Jt=e.transform)==null?void 0:Jt.scale_x)??1)*(1+nt*it),.2),n.scale_y=this.lerp(n.scale_y??1,(((Gt=e.transform)==null?void 0:Gt.scale_y)??1)*(1+nt*it),.2)}else n.scale_x=this.lerp(n.scale_x??1,((ge=e.transform)==null?void 0:ge.scale_x)??1,.1),n.scale_y=this.lerp(n.scale_y??1,((be=e.transform)==null?void 0:be.scale_y)??1,.1)}else if(i.type===st.LayoutAnimation){const Z=((Le=i.settings)==null?void 0:Le.watchProperties)||["x","y","scale_x","scale_y","opacity","rotation"],it=((ae=i.settings)==null?void 0:ae.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const nt=this._layoutAnimCache.get(e.id);for(const wt of Z){const zt=this.getObjectProperty(n,e,wt);if(zt===void 0)continue;const Ut=nt.get(wt);if(!Ut)nt.set(wt,{from:zt,to:zt,startTime:this.currentTime,duration:0});else if(Ut.to!==zt){const me=this.getObjectProperty(n,e,wt);nt.set(wt,{from:me??Ut.from,to:zt,startTime:this.currentTime,duration:((de=i.settings)==null?void 0:de.duration)??it})}const Zt=nt.get(wt);if(Zt.duration>0&&Zt.from!==Zt.to){const me=this.currentTime-Zt.startTime,Ae=Math.min(1,me/Zt.duration),Fe=this.applyEasing(Ae,((he=i.settings)==null?void 0:he.easing)||"easeOutCubic"),we=Zt.from+(Zt.to-Zt.from)*Fe;this.setObjectProperty(n,e,wt,we)}}}else if(i.type===st.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const Z=this._layoutAnimCache.get(e.id),it=(($e=i.settings)==null?void 0:$e.defaultDuration)||.3,nt=["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 wt of nt){const zt=this.getObjectProperty(n,e,wt);if(zt===void 0||typeof zt!="number")continue;const Ut=Z.get(wt);if(!Ut)Z.set(wt,{from:zt,to:zt,startTime:this.currentTime,duration:0});else if(Ut.to!==zt){const me=this.getObjectProperty(n,e,wt);Z.set(wt,{from:me??Ut.from,to:zt,startTime:this.currentTime,duration:it})}const Zt=Z.get(wt);if(Zt.duration>0&&Zt.from!==Zt.to){const me=this.currentTime-Zt.startTime,Ae=Math.min(1,me/Zt.duration),Fe=this.applyEasing(Ae,((Be=i.settings)==null?void 0:Be.defaultEasing)||"easeOutCubic"),we=Zt.from+(Zt.to-Zt.from)*Fe;this.setObjectProperty(n,e,wt,we)}}}else if(i.type===st.SpringChain){const Z=((De=i.settings)==null?void 0:De.connections)||[],it=((Ye=i.settings)==null?void 0:Ye.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const nt=this._springChainState.get(e.id);for(const zt of Z){if(!nt.has(zt.targetId)){const Ut=this.objectStates.get(zt.targetId);nt.set(zt.targetId,{x:(Ut==null?void 0:Ut.x)??0,y:(Ut==null?void 0:Ut.y)??0,vx:0,vy:0})}nt.has(e.id)||nt.set(e.id,{x:n.x,y:n.y,vx:0,vy:0})}const wt=nt.get(e.id);if(wt){wt.x=n.x,wt.y=n.y;for(const zt of Z){const Ut=nt.get(zt.targetId);if(!Ut)continue;const Zt=Ut.x-wt.x,me=Ut.y-wt.y,Ae=Math.sqrt(Zt*Zt+me*me)||.001,we=(Ae-(zt.restLength||50))*(zt.stiffness||.8),Re=Zt/Ae*we,je=me/Ae*we;wt.vx+=Re*t*10,wt.vy+=je*t*10,Ut.vx-=Re*t*10,Ut.vy-=je*t*10,wt.vx*=1-it*t*10,wt.vy*=1-it*t*10,Ut.vx*=1-it*t*10,Ut.vy*=1-it*t*10;const Ee=this.objectStates.get(zt.targetId);Ee&&(Ee.x+=Ut.vx*t,Ee.y+=Ut.vy*t)}n.x+=wt.vx*t,n.y+=wt.vy*t}}else if(i.type===st.ParticleEmitter){const Z=((Xe=i.settings)==null?void 0:Xe.rate)||10,it=((Ne=i.settings)==null?void 0:Ne.speed)||100,nt=((Ue=i.settings)==null?void 0:Ue.size)||5,wt=((re=i.settings)==null?void 0:re.lifetime)||2,zt=((ve=i.settings)==null?void 0:ve.gravity)||0,Ut=((Te=i.settings)==null?void 0:Te.color)||"#ffffff",Zt=((He=i.settings)==null?void 0:He.maxParticles)||200,me=(xe=i.settings)!=null&&xe.rateInputId?this.inputs.get(i.settings.rateInputId)??Z:Z,Ae=(_e=i.settings)!=null&&_e.gravityInputId?this.inputs.get(i.settings.gravityInputId)??zt:zt,Fe=(Pe=i.settings)!=null&&Pe.speedInputId?this.inputs.get(i.settings.speedInputId)??it:it;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const we=this._emitterPools.get(e.id);let Re=0;i._pendingBurst&&i._pendingBurst>0&&(Re=i._pendingBurst,i._pendingBurst=0);const je=Math.floor(me*t)+(Re||0);for(let Ee=0;Ee<Math.min(je,Zt-we.length);Ee++){const Me=Math.random()*Math.PI*2,bs=Fe*(.5+Math.random()*.5);we.push({x:n.x,y:n.y,vx:Math.cos(Me)*bs,vy:Math.sin(Me)*bs,life:0,maxLife:wt*(.5+Math.random()*.5),size:nt*(.5+Math.random()),color:Ut,opacity:1})}for(let Ee=we.length-1;Ee>=0;Ee--){const Me=we[Ee];Me.vy+=Ae*t*10,Me.x+=Me.vx*t,Me.y+=Me.vy*t,Me.life+=t,Me.opacity=Math.max(0,1-Me.life/Me.maxLife),Me.life>=Me.maxLife&&we.splice(Ee,1)}}})})}applyBehaviorSensor(t,s,o,e,n,i,a=0,r=0,l=1){var f,h,S,y,c,v,m,C,w,M,I,A,_,T,L,F,D,R,X,P,k,O,E,N;const d=(n==null?void 0:n.intensity)||(n==null?void 0:n.strength)||1,u=Math.min(1,15*e),g=l>0?a/l:0,p=l>0?r/l:0;switch(s){case ue.Scale:{const W=((f=i==null?void 0:i.transform)==null?void 0:f.scale_x)??1,B=((h=i==null?void 0:i.transform)==null?void 0:h.scale_y)??1,G=W*(1+o*d*.4),z=B*(1+o*d*.4);t.scale_x=(t.scale_x??W)*(1-u)+G*u,t.scale_y=(t.scale_y??B)*(1-u)+z*u;break}case ue.Opacity:{const W=((S=i==null?void 0:i.transform)==null?void 0:S.opacity)??100,B=Math.max(0,Math.min(100,W-o*d*100));t.opacity=(t.opacity??W)*(1-u)+B*u;break}case ue.RotateZ:{const W=((y=i==null?void 0:i.transform)==null?void 0:y.rotation)??0,B=W+o*d*45;t.rotation=(t.rotation??W)*(1-u)+B*u;break}case ue.RotateX:{const W=((c=i==null?void 0:i.transform)==null?void 0:c.rotate_x)??0,B=W-p*o*d*60;t.rotate_x=(t.rotate_x??W)*(1-u)+B*u;break}case ue.RotateY:{const W=((v=i==null?void 0:i.transform)==null?void 0:v.rotate_y)??0,B=W+g*o*d*60;t.rotate_y=(t.rotate_y??W)*(1-u)+B*u;break}case ue.PositionX:{const W=((m=i==null?void 0:i.transform)==null?void 0:m.x)??0,B=W-g*o*d*40;t.x=(t.x??W)*(1-u)+B*u;break}case ue.PositionY:{const W=((C=i==null?void 0:i.transform)==null?void 0:C.y)??0,B=W-p*o*d*40;t.y=(t.y??W)*(1-u)+B*u;break}case ue.SkewX:{const W=((w=i==null?void 0:i.transform)==null?void 0:w.skew_x)??0,B=W+g*o*d*45;t.skew_x=(t.skew_x??W)*(1-u)+B*u,t.skew_x>85&&(t.skew_x=85),t.skew_x<-85&&(t.skew_x=-85);break}case ue.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 W=((A=(I=i==null?void 0:i.style)==null?void 0:I.blur)==null?void 0:A.amount)||0,B=W+o*((n==null?void 0:n.blur)||20)*d;t.style.blur.amount=(t.style.blur.amount??W)*(1-u)+B*u;break}case ue.Exposure:{t.style||(t.style={...i==null?void 0:i.style}),t.style.adjustments||(t.style.adjustments={...(_=i==null?void 0:i.style)==null?void 0:_.adjustments});const W=((L=(T=i==null?void 0:i.style)==null?void 0:T.adjustments)==null?void 0:L.exposure)||0,B=W+o*((n==null?void 0:n.exposure)||50)*d;t.style.adjustments.exposure=(t.style.adjustments.exposure??W)*(1-u)+B*u;break}case ue.HueShift:{t.style||(t.style={...i==null?void 0:i.style}),t.style.adjustments||(t.style.adjustments={...(F=i==null?void 0:i.style)==null?void 0:F.adjustments});const W=((R=(D=i==null?void 0:i.style)==null?void 0:D.adjustments)==null?void 0:R.hue)||0,B=W+o*((n==null?void 0:n.hue)||180)*d;t.style.adjustments.hue=(t.style.adjustments.hue??W)*(1-u)+B*u;break}case ue.Negative:{t.style||(t.style={...i==null?void 0:i.style}),t.style.adjustments||(t.style.adjustments={...(X=i==null?void 0:i.style)==null?void 0:X.adjustments});const W=((k=(P=i==null?void 0:i.style)==null?void 0:P.adjustments)==null?void 0:k.negative)||0,B=W+o*((n==null?void 0:n.negative)||100)*d;t.style.adjustments.negative=(t.style.adjustments.negative??W)*(1-u)+B*u;break}case ue.CornerRadius:{const W=((O=i==null?void 0:i.transform)==null?void 0:O.corner_radius)||0,B=W+o*d*50;t.corner_radius=(t.corner_radius??W)*(1-u)+B*u;break}case ue.StrokeWidth:{t.style||(t.style={...i==null?void 0:i.style});const W=((E=i==null?void 0:i.style)==null?void 0:E.borderWidth)||0,B=W+o*d*10;t.style.borderWidth=(t.style.borderWidth??W)*(1-u)+B*u;break}case ue.LetterSpacing:{t.geometry||(t.geometry={});const W=((N=i==null?void 0:i.geometry)==null?void 0:N.letterSpacing)||0,B=W+o*d*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??W)*(1-u)+B*u;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,u=n.slice(0,r+1).reduce((f,h)=>f==null?void 0:f[h],d),g=n[r+1],p=!isNaN(Number(g));i[l]=u!==void 0?Array.isArray(u)?[...u]:{...u}:p?[]:{}}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,u=(e.shadows||0)/500,g=e.hue||0,p=(e.negative||0)/100,f=e.blur||0;if(!(n!==0||i!==0||a!==0||r!==0||l!==0||d!==0||u!==0||g!==0||p!==0||f>0))return t;const S=t.naturalWidth||Math.max(1,Math.round(s)),y=t.naturalHeight||Math.max(1,Math.round(o)),c=document.createElement("canvas");c.width=S,c.height=y;const v=c.getContext("2d");if(!v)return t;const m=[];f>0&&m.push(`blur(${f}px)`),g!==0&&m.push(`hue-rotate(${Math.round(g)}deg)`),m.length>0&&(v.filter=m.join(" ")),v.drawImage(t,0,0,S,y);try{const C=v.getImageData(0,0,S,y),w=C.data,M=w.length,I=n*255,A=i>=0?(1+i)/Math.max(.01,1-i):1+i,_=1+a,T=1+r-l/2,L=1+l,F=1-r-l/2,D=1+d+u,R=u*25.5,X=1-p/50,P=(1-X)*255;for(let k=0;k<M;k+=4){let O=w[k],E=w[k+1],N=w[k+2];if(n!==0&&(O+=I,E+=I,N+=I),i!==0&&(O=(O-127.5)*A+127.5,E=(E-127.5)*A+127.5,N=(N-127.5)*A+127.5),a!==0){const W=.2989*O+.587*E+.114*N;O=W+(O-W)*_,E=W+(E-W)*_,N=W+(N-W)*_}(r!==0||l!==0)&&(O=O*T,E=E*L,N=N*F),(d!==0||u!==0)&&(O=O*D+R,E=E*D+R,N=N*D+R),p!==0&&(O=O*X+P,E=E*X+P,N=N*X+P),w[k]=Math.min(255,Math.max(0,O)),w[k+1]=Math.min(255,Math.max(0,E)),w[k+2]=Math.min(255,Math.max(0,N))}return v.putImageData(C,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,u=n/i;let g=n,p=i,f=o,h=e;a==="cover"?d>u?(g=i*d,f=o-(g-n)/2):(p=n/d,h=e-(p-i)/2):a==="contain"&&(d>u?(p=n/d,h=e+(i-p)/2):(g=i*d,f=o+(n-g)/2)),t.drawImage(s,f,h,g,p)}}const li=Nt.forwardRef(({artboard:b,src:t,style:s,autoPlay:o=!0,fit:e="Contain",alignment:n="Center",onReady:i,onTrigger:a,onInputUpdate:r,onComponentChange:l,onToggle:d,onInputChange:u,onInputFocus:g,onInputBlur:p,onLog:f,onLogicUpdate:h,onButtonClick:S,onGraphPointClick:y,currentTime:c,revision:v=0,scrollY:m,scrollX:C,mouseX:w,mouseY:M,isMouseDown:I,inputs:A,interactive:_=!0,onNavigation:T},L)=>{const F=Nt.useRef(null),D=Nt.useRef(null);D.current||(D.current=new ys);const R=Nt.useRef(void 0),X=Nt.useRef(0),P=Nt.useRef(null),k=Nt.useRef(v),O=Nt.useRef(null),[,E]=Nt.useState(b||null),N=Nt.useRef(!0),W=Nt.useRef(o),B=Nt.useRef(c);Nt.useEffect(()=>{W.current=o},[o]),Nt.useEffect(()=>{B.current=c},[c]),Nt.useImperativeHandle(L,()=>F.current),Nt.useEffect(()=>(N.current=!0,()=>{N.current=!1,R.current&&cancelAnimationFrame(R.current)}),[]),Nt.useEffect(()=>{D.current.setLayout(e,n)},[e,n]),Nt.useEffect(()=>{const Y=D.current;a&&Y.setTriggerCallback(a),r&&Y.setInputUpdateCallback((H,x)=>r({[H]:x})),l&&Y.setComponentChangeCallback(H=>l(H)),d&&Y.setToggleCallback(d),u&&Y.setInputChangeCallback(u),g&&Y.setInputFocusCallback(g),p&&Y.setInputBlurCallback(p),f&&Y.setOnLogCallback(H=>f(H,"info")),h&&Y.setLogicUpdateCallback(h),S&&Y.setButtonClickCallback(S),y&&Y.setGraphPointClickCallback(H=>y(H.objectId,H)),T&&Y.setNavigationCallback(T)},[a,r,l,d,u,g,p,f,h,S,y,T]),Nt.useEffect(()=>{(async()=>{let H=b;if(t&&!b)try{t.startsWith("{")?H=JSON.parse(t):H=await(await fetch(t)).json()}catch(x){console.error("[ExodeUI] Failed to load src:",x)}if(H){const x=D.current,dt=H.id||H.name||"default";(P.current!==dt||k.current!==v||O.current!==H)&&(x.load(H),P.current=dt,k.current=v,O.current=H,E(H),X.current=-1,x.advance(0)),i&&i(x)}})()},[b,t,v]),Nt.useEffect(()=>{const Y=H=>{if(!D.current||!N.current)return;const x=D.current,dt=F.current;if(!dt)return;const _t=dt.getContext("2d");if(!_t)return;const vt=H/1e3;X.current<0&&(X.current=vt),X.current===0&&(X.current=vt);let Yt=vt-X.current;Yt>.1&&(Yt=.1),X.current=vt;const Mt=dt.getBoundingClientRect(),Wt=window.devicePixelRatio||1,Ot=Math.round(Mt.width*Wt),yt=Math.round(Mt.height*Wt);(dt.width!==Ot||dt.height!==yt)&&(dt.width=Ot,dt.height=yt);try{W.current?x.advance(Yt):B.current!==void 0&&x.seek(B.current),x.render(_t,dt.width,dt.height)}catch(Ft){console.error("[ExodeUICanvas] Error in animation loop:",Ft),f&&f(`[Error] Animation loop crashed: ${Ft}`,"error")}R.current=requestAnimationFrame(Y)};return R.current=requestAnimationFrame(Y),()=>{R.current&&cancelAnimationFrame(R.current)}},[]),Nt.useEffect(()=>{const Y=D.current;m!==void 0&&Y.updateInput("scrollY",m),C!==void 0&&Y.updateInput("scrollX",C),w!==void 0&&Y.updateInput("mouseX",w),M!==void 0&&Y.updateInput("mouseY",M),I!==void 0&&Y.updateInput("isMouseDown",I),A&&Object.entries(A).forEach(([H,x])=>Y.updateInput(H,x))},[m,C,w,M,I,A]);const G=(Y,H)=>{var Mt,Wt,Ot;if(!_||!F.current)return;Y.stopPropagation(),"nativeEvent"in Y&&Y.nativeEvent&&typeof Y.nativeEvent.stopImmediatePropagation=="function"?Y.nativeEvent.stopImmediatePropagation():typeof Y.stopImmediatePropagation=="function"&&Y.stopImmediatePropagation();const x=F.current,dt=x.getBoundingClientRect(),_t=Y.clientX-dt.left,vt=Y.clientY-dt.top,Yt=window.devicePixelRatio||1;if((H==="click"||H==="down"||H==="up")&&f&&f(`[Canvas] Pointer ${H} at rect(${Math.round(_t)},${Math.round(vt)}) mapped to buffer(${Math.round(_t*Yt)},${Math.round(vt*Yt)})`,"info"),D.current.handlePointerInput(H,_t*Yt,vt*Yt,x.width,x.height),H==="move"){const yt=(Mt=D.current)==null?void 0:Mt.getLastHoveredObject();yt?(Wt=D.current)!=null&&Wt.isInputBoxObject(yt)?x.style.cursor="text":(Ot=D.current)!=null&&Ot.isClickableObject(yt)?x.style.cursor="pointer":x.style.cursor="default":x.style.cursor="default"}else H==="blur"&&(x.style.cursor="default")};Nt.useEffect(()=>{if(!_)return;const Y=x=>{var dt,_t,vt;((dt=document.activeElement)==null?void 0:dt.tagName)==="INPUT"||((_t=document.activeElement)==null?void 0:_t.tagName)==="TEXTAREA"||(vt=D.current)==null||vt.handleKeyDown(x)},H=x=>{var dt,_t,vt;((dt=document.activeElement)==null?void 0:dt.tagName)==="INPUT"||((_t=document.activeElement)==null?void 0:_t.tagName)==="TEXTAREA"||(vt=D.current)==null||vt.handleKeyUp(x)};return window.addEventListener("keydown",Y),window.addEventListener("keyup",H),()=>{window.removeEventListener("keydown",Y),window.removeEventListener("keyup",H)}},[_]),Nt.useEffect(()=>{const Y=F.current;if(!Y||!_)return;const H=x=>{if(x.preventDefault(),x.stopPropagation(),D.current){const dt=Y.getBoundingClientRect(),_t=window.devicePixelRatio||1,vt=(x.clientX-dt.left)*_t,Yt=(x.clientY-dt.top)*_t;let Mt=x.deltaX,Wt=x.deltaY;x.deltaMode===1?(Mt*=25,Wt*=25):x.deltaMode===2&&(Mt*=100,Wt*=100),D.current.handlePointerInput("move",vt,Yt,Y.width,Y.height),D.current.handleWheel(Mt,Wt,vt,Yt,Y.width,Y.height)}};return Y.addEventListener("wheel",H,{passive:!1}),()=>{Y.removeEventListener("wheel",H)}},[_]);const[z,V]=Nt.useState([]);Nt.useEffect(()=>{if(b&&b.objects){const Y=b.objects.filter(H=>{var x,dt;return H.type==="Joystick"&&((x=H.inputBinding)==null?void 0:x.type)==="keyboard"&&((dt=H.inputBinding.keyboardConfig)==null?void 0:dt.showVirtualKeyboard)});V(Y)}},[b]);const[,U]=Nt.useState(0);Nt.useEffect(()=>{if(z.length===0)return;let Y;const H=()=>{U(x=>x+1),Y=requestAnimationFrame(H)};return Y=requestAnimationFrame(H),()=>cancelAnimationFrame(Y)},[z.length]);const q=()=>z.map(Y=>{const H=Y.inputBinding.keyboardConfig,x=Mt=>{var Ot;const Wt={key:Mt,code:Mt,preventDefault:()=>{}};(Ot=D.current)==null||Ot.handleKeyDown(Wt)},dt=Mt=>{var Ot;const Wt={key:Mt,code:Mt,preventDefault:()=>{}};(Ot=D.current)==null||Ot.handleKeyUp(Wt)},_t=D.current,vt=Mt=>_t&&_t.activeKeys?_t.activeKeys.has(Mt.toLowerCase()):!1,Yt=Mt=>({width:"50px",height:"50px",background:Mt?"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:Mt?"none":"0 4px 6px rgba(0,0,0,0.1)"});return ne.jsxs("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",pointerEvents:"auto",zIndex:100},children:[ne.jsx("div",{style:Yt(vt(H.upKey)),onMouseDown:()=>x(H.upKey),onMouseUp:()=>dt(H.upKey),onMouseLeave:()=>dt(H.upKey),onTouchStart:Mt=>{Mt.preventDefault(),x(H.upKey)},onTouchEnd:Mt=>{Mt.preventDefault(),dt(H.upKey)},children:H.upKey.toUpperCase()}),ne.jsxs("div",{style:{display:"flex",gap:"8px"},children:[ne.jsx("div",{style:Yt(vt(H.leftKey)),onMouseDown:()=>x(H.leftKey),onMouseUp:()=>dt(H.leftKey),onMouseLeave:()=>dt(H.leftKey),onTouchStart:Mt=>{Mt.preventDefault(),x(H.leftKey)},onTouchEnd:Mt=>{Mt.preventDefault(),dt(H.leftKey)},children:H.leftKey.toUpperCase()}),ne.jsx("div",{style:Yt(vt(H.downKey)),onMouseDown:()=>x(H.downKey),onMouseUp:()=>dt(H.downKey),onMouseLeave:()=>dt(H.downKey),onTouchStart:Mt=>{Mt.preventDefault(),x(H.downKey)},onTouchEnd:Mt=>{Mt.preventDefault(),dt(H.downKey)},children:H.downKey.toUpperCase()}),ne.jsx("div",{style:Yt(vt(H.rightKey)),onMouseDown:()=>x(H.rightKey),onMouseUp:()=>dt(H.rightKey),onMouseLeave:()=>dt(H.rightKey),onTouchStart:Mt=>{Mt.preventDefault(),x(H.rightKey)},onTouchEnd:Mt=>{Mt.preventDefault(),dt(H.rightKey)},children:H.rightKey.toUpperCase()})]})]},Y.id)});return ne.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[ne.jsx("canvas",{ref:F,onPointerDown:Y=>{var H;G(Y,"down"),Y.currentTarget.setPointerCapture(Y.pointerId),(H=F.current)==null||H.focus()},onPointerMove:Y=>G(Y,"move"),onPointerUp:Y=>{G(Y,"up"),Y.currentTarget.releasePointerCapture(Y.pointerId)},onPointerCancel:Y=>{G(Y,"up"),Y.currentTarget.releasePointerCapture(Y.pointerId)},onPointerLeave:Y=>G(Y,"blur"),onClick:Y=>G(Y,"click"),onKeyDown:Y=>D.current.handleKeyDown(Y.nativeEvent),onKeyUp:Y=>D.current.handleKeyUp(Y.nativeEvent),onContextMenu:Y=>Y.preventDefault(),tabIndex:0,style:{...s,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:_?"auto":"none"}}),q()]})});function ci(){const[b,t]=Nt.useState(null),s=Nt.useCallback((y,c)=>{b==null||b.setInputBool(y,c)},[b]),o=Nt.useCallback((y,c)=>{b==null||b.setInputNumber(y,c)},[b]),e=Nt.useCallback(y=>{b==null||b.fireTrigger(y)},[b]),n=Nt.useCallback((y,c)=>{b==null||b.setInputText(y,c)},[b]),i=Nt.useCallback((y,c)=>{b==null||b.setInputNumberArray(y,c)},[b]),a=Nt.useCallback((y,c)=>{b==null||b.setInputStringArray(y,c)},[b]),r=Nt.useCallback((y,c)=>{b==null||b.updateInput(y,c)},[b]),l=r,d=Nt.useCallback((y,c)=>{b==null||b.updateObjectOptions(y,c)},[b]),u=Nt.useCallback((y,c,v)=>{b==null||b.updateConstraint(y,c,v)},[b]),g=Nt.useCallback((y,c,v)=>{b==null||b.updateGraphData(y,c,v)},[b]),p=Nt.useCallback((y,c,v)=>{b==null||b.updateBarChartData(y,c,v)},[b]),f=Nt.useCallback((y,c)=>{b==null||b.updatePieChartData(y,c)},[b]),h=Nt.useCallback((y,c)=>{b==null||b.setDropdownOptions(y,c)},[b]),S=Nt.useCallback(y=>b==null?void 0:b.getInputValue(y),[b]);return{setEngine:t,engine:b,updateInput:r,setInputValue:l,setInputBool:s,setInputNumber:o,fireTrigger:e,setInputText:n,setInputNumberArray:i,setInputStringArray:a,updateConstraint:u,updateGraphData:g,updateBarChartData:p,updatePieChartData:f,setDropdownOptions:h,updateObjectOptions:d,getInputValue:S}}const hi=({artboard:b,config:t})=>{const s={...b.seo,...t},o=s.enableSmartExtraction!==!1;Nt.useEffect(()=>{const a=s.title||b.name;a&&(document.title=a);let r=s.description;if(!r&&o){const u=b.objects.filter(g=>{var p;return((p=g.geometry)==null?void 0:p.type)==="Text"}).sort((g,p)=>{var f,h;return(((f=p.geometry.text)==null?void 0:f.length)||0)-(((h=g.geometry.text)==null?void 0:h.length)||0)});u.length>0&&(r=u[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||b.backgroundImage;l&&e("property","og:image",l),a&&e("property","og:title",a),e("property","og:type","website")},[s,b,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(ne.jsx("h1",{children:s.title||b.name},"artboard-title")),b.objects.forEach((l,d)=>{var u,g;if(!(l.visible===!1||l.isVisible===!1))if(((u=l.geometry)==null?void 0:u.type)==="Text"){const p=l.geometry.text;p&&(l.geometry.fontSize>24?a.push(ne.jsx("h2",{children:p},l.id||d)):a.push(ne.jsx("p",{children:p},l.id||d)))}else if(((g=l.geometry)==null?void 0:g.type)==="Image"){const p=l.geometry.src,f=l.altText||l.name||"Illustration";a.push(ne.jsx("img",{src:p,alt:f},l.id||d))}else l.type==="Button"&&a.push(ne.jsx("button",{children:l.name||"Button"},l.id||d))}),a},i=s.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:s.title||b.name,description:s.description,image:s.ogImage||b.backgroundImage,abstract:"Animated interface created with ExodeUI"};return ne.jsxs("div",{id:`exode-seo-${b.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(),ne.jsx("script",{type:"application/ld+json",children:JSON.stringify(i)})]})},fi={version:"6.4.4"}.version;ee.BAR_STYLE_PRESETS=ri,ee.BehaviorSensor=ue,ee.BehaviorType=st,ee.ConditionOp=es,ee.ExodeSEO=hi,ee.ExodeUICanvas=li,ee.ExodeUIEngine=ys,ee.LogicOp=Ht,ee.RapierPhysics=os,ee.TOGGLE_SHAPE_NAME_MAP=ze,ee.VERSION=fi,ee.getToggleSvgPathBounds=We,ee.useExodeUI=ci,Object.defineProperty(ee,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(se,ne){typeof exports=="object"&&typeof module<"u"?ne(exports,require("react/jsx-runtime"),require("react"),require("@chenglou/pretext"),require("@dimforge/rapier2d-compat"),require("lz-string")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@chenglou/pretext","@dimforge/rapier2d-compat","lz-string"],ne):(se=typeof globalThis<"u"?globalThis:se||self,ne(se.ExodeUIReact={},se.jsxRuntime,se.React,se.pretext,se.Rapier,se.LZString))})(this,(function(se,ne,Nt,qe,ue,Ss){"use strict";var di=Object.defineProperty;var pi=(se,ne,Nt)=>ne in se?di(se,ne,{enumerable:!0,configurable:!0,writable:!0,value:Nt}):se[ne]=Nt;var pt=(se,ne,Nt)=>pi(se,typeof ne!="symbol"?ne+"":ne,Nt);function Cs(y){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(y){for(const s in y)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(y,s);Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:()=>y[s]})}}return t.default=y,Object.freeze(t)}const ws=Cs(Ss);var it=(y=>(y.Proximity="Proximity",y.Magnetic="Magnetic",y.Repel="Repel",y.Orbit="Orbit",y.Vortex="Vortex",y.Fluid="Fluid",y.Elastic="Elastic",y.Holographic="Holographic",y.Sticky="Sticky",y.Dilation="Dilation",y.Parallax="Parallax",y.Noise="Noise",y.Float="Float",y.Pulse="Pulse",y.Draggable="Draggable",y.Scroll="Scroll",y.LookAt="LookAt",y.Glint="Glint",y.Scan="Scan",y.Ratchet="Ratchet",y.Jitter="Jitter",y.Follower="Follower",y.Wrap="Wrap",y.Typewriter="Typewriter",y.Scramble="Scramble",y.Wave="Wave",y.Bounce="Bounce",y.TextTrail="TextTrail",y.Reveal3D="Reveal3D",y.RevealSlide="RevealSlide",y.RevealBlur="RevealBlur",y.TextLiquid="TextLiquid",y.TextVortex="TextVortex",y.TextExplosion="TextExplosion",y.TextRain="TextRain",y.TextGravity="TextGravity",y.TextMatrix="TextMatrix",y.TextNeon="TextNeon",y.TextDissolve="TextDissolve",y.TextOrganic="TextOrganic",y.TextBreathe="TextBreathe",y.TextSpin="TextSpin",y.TextMagnet="TextMagnet",y.TextPerspective="TextPerspective",y.TextMirror="TextMirror",y.TextFloral="TextFloral",y.TextSmoke="TextSmoke",y.TextVariable="TextVariable",y.TextZing="TextZing",y.TextElastic="TextElastic",y.TextGlitch3D="TextGlitch3D",y.GlitchText="GlitchText",y.TextCounter="TextCounter",y.Squash="Squash",y.Spotlight="Spotlight",y.Lens="Lens",y.Gravity="Gravity",y.Velocity="Velocity",y.Shear="Shear",y.LayoutAnimation="LayoutAnimation",y.SpringChain="SpringChain",y.ParticleEmitter="ParticleEmitter",y.StateReactive="StateReactive",y.Fold="Fold",y.Crumple="Crumple",y))(it||{}),ge=(y=>(y.Scale="Scale",y.Opacity="Opacity",y.RotateZ="RotateZ",y.RotateX="RotateX",y.RotateY="RotateY",y.PositionX="PositionX",y.PositionY="PositionY",y.SkewX="SkewX",y.Blur="Blur",y.Exposure="Exposure",y.HueShift="HueShift",y.Negative="Negative",y.CornerRadius="CornerRadius",y.StrokeWidth="StrokeWidth",y.BoxShadow="BoxShadow",y.FontSize="FontSize",y.LetterSpacing="LetterSpacing",y))(ge||{}),es=(y=>(y.Equal="Equal",y.NotEqual="NotEqual",y.GreaterThan="GreaterThan",y.LessThan="LessThan",y.GreaterEqual="GreaterEqual",y.LessEqual="LessEqual",y.IsTrue="IsTrue",y.IsFalse="IsFalse",y))(es||{}),Ht=(y=>(y.AND="AND",y.OR="OR",y.NOT="NOT",y.XOR="XOR",y.OBJECT="OBJECT",y.PROPERTY="PROPERTY",y.GET_PROPERTY="GET_PROPERTY",y.SET_PROPERTY="SET_PROPERTY",y.ADD="ADD",y.SUB="SUB",y.MUL="MUL",y.DIV="DIV",y.MOD="MOD",y.POW="POW",y.ABS="ABS",y.ROUND="ROUND",y.FLOOR="FLOOR",y.CEIL="CEIL",y.SIN="SIN",y.COS="COS",y.TAN="TAN",y.CLAMP="CLAMP",y.REMAP="REMAP",y.EQ="EQ",y.NEQ="NEQ",y.GT="GT",y.LT="LT",y.GTE="GTE",y.LTE="LTE",y.IF_ELSE="IF_ELSE",y.VALUE="VALUE",y.INPUT="INPUT",y.LOG="LOG",y.SCROLL_X="SCROLL_X",y.SCROLL_Y="SCROLL_Y",y.MOUSE_X="MOUSE_X",y.MOUSE_Y="MOUSE_Y",y.IS_MOUSE_DOWN="IS_MOUSE_DOWN",y.EFFECTOR="EFFECTOR",y.MONITOR="MONITOR",y.DELAY="DELAY",y.SPRING_PULL="SPRING_PULL",y.SPRING_SETTLE="SPRING_SETTLE",y.EMIT="EMIT",y))(Ht||{});function Ms(y){if(y.length<5)return y;const t=new Set("aeiouyAEIOUY".split(""));if(/[\u4E00-\u9FFF\u3400-\u4DBF]/.test(y))return y;let o="";for(let e=0;e<y.length;e++){if(o+=y[e],e>=y.length-2)continue;const n=t.has(y[e]),i=t.has(y[e+1]),a=t.has(y[e+2]);n&&!i&&a&&(o+="­"),n&&!i&&!a&&e>=1&&(o+="­")}return o}function Is(y){return y.replace(/\b([a-zA-Z]{4,})\b/g,(t,s)=>Ms(s))}function ks(y,t,s){return y}function Ts(y,t,s){return y}const Ge=new Map;function ss(y){var k;const{text:t,fontFamily:s="Inter",fontSize:o=16,fontWeight:e=400,fontStyle:n="normal",lineHeight:i=1.2,width:a=200,letterSpacing:r=0,paragraphSpacing:l=0,paragraphIndent:d=0,textCase:p="none",segments:g=[],enableSegments:u=!1}=y;let f=String(t||"");p==="uppercase"?f=f.toUpperCase():p==="lowercase"?f=f.toLowerCase():p==="capitalize"&&(f=f.replace(/\b\w/g,O=>O.toUpperCase())),y.hyphenation===!0&&(f=Is(f));const h=`${n} ${e} ${o}px "${s}", sans-serif`,m=`${f}|${h}|${r}|${l}|${d}|${u}|${JSON.stringify(g)}|hyp:${!!y.hyphenation}|comp:${y.composer}|bal:${!!y.balanceRaggedLines}`;let b=Ge.get(m);const c=typeof CanvasRenderingContext2D<"u"?CanvasRenderingContext2D.prototype.measureText:null,S=function(O){if(!c)return{width:0,fontBoundingBoxAscent:0,fontBoundingBoxDescent:0};const T=c.call(this,O);return r!==0&&O&&O.length>0?{...T,width:T.width+(O.length-1)*r}:T};if(!b){try{if(r!==0&&typeof CanvasRenderingContext2D<"u"&&(CanvasRenderingContext2D.prototype.measureText=S),u&&g&&g.length>0){const O=g.map(T=>{let A=T.text||"";const D=T.textCase||p||"none";return D==="uppercase"?A.toUpperCase():D==="lowercase"?A.toLowerCase():D==="capitalize"?A.replace(/\b\w/g,Y=>Y.toUpperCase()):A}).join("");if(b=qe.prepareWithSegments(O,h),b){let T=0,A=o;for(const D of g){let Y=D.text||"";if(!Y)continue;const B=D.textCase||p||"none";B==="uppercase"?Y=Y.toUpperCase():B==="lowercase"?Y=Y.toLowerCase():B==="capitalize"&&(Y=Y.replace(/\b\w/g,F=>F.toUpperCase()));const R=D.fontSize||o;R>A&&(A=R);const L=`${D.fontStyle||n} ${D.fontWeight||e} ${R}px "${D.fontFamily||s}", sans-serif`,$=qe.prepareWithSegments(Y,L);if($&&$.widths)for(let F=0;F<$.widths.length;F++){const X=T+F;if(X<b.widths.length){b.widths[X]=$.widths[F];const M=$.kinds[F];if(M===2){const E=Y[F];E===`
2
+ `||E==="\r"?b.kinds[X]=2:b.kinds[X]=0}else b.kinds[X]=M}}T+=Y.length}b.fullText=O,b.maxFontSize=A}}else b=qe.prepareWithSegments(f,h);b&&Ge.set(m,b)}catch(O){return console.error("[ExodeUI] Pretext prepare failed:",O),{width:a,height:0,lineCount:0,lines:[]}}finally{r!==0&&typeof CanvasRenderingContext2D<"u"&&c&&(CanvasRenderingContext2D.prototype.measureText=c)}if(Ge.size>500){const O=Ge.keys().next().value;O&&Ge.delete(O)}}if(d>0&&b&&b.widths&&!b.indentApplied){const O=[...b.widths],T=b.fullText||f;let A=!0;for(let D=0;D<T.length;D++)A&&O[D]!==void 0&&(O[D]+=d,A=!1),(T[D]===`
3
+ `||T[D]==="\r")&&(A=!0,T[D]==="\r"&&T[D+1]===`
4
+ `&&D++);b={...b,widths:O,indentApplied:!0}}if(!b)return{width:a,height:0,lineCount:0,lines:[]};let v=i;typeof v=="string"&&(v=parseFloat(v)),v>5&&o>0&&(v=v/o),r!==0&&(CanvasRenderingContext2D.prototype.measureText=S);let C;try{const O=b.maxFontSize||o;if(a>=1e5){const T=f.split(/\r\n|\r|\n/);C={lines:T.map(A=>({text:A,width:0})),height:T.length*(v*O),lineCount:T.length}}else C=qe.layoutWithLines(b,a,v*O)}finally{r!==0&&c&&(CanvasRenderingContext2D.prototype.measureText=c)}let w=(C==null?void 0:C.height)!==void 0&&C.height>0?C.height:(((k=C==null?void 0:C.lines)==null?void 0:k.length)||0)*v*o;if(l>0&&C&&C.lines&&C.lines.length>1){let O=0;const T=b.fullText||t;for(let A=0;A<C.lines.length-1;A++)O+=C.lines[A].text.length,(T[O]===`
5
+ `||T[O]==="\r")&&(w+=l,O++,T[O-1]==="\r"&&T[O]===`
6
+ `&&O++)}let I=(C==null?void 0:C.lines)||[];return y.composer==="every-line"&&I.length>1&&(I=ks(I)),y.balanceRaggedLines===!0&&I.length>1&&(I=Ts(I)),{width:a,height:w,lineCount:I.length,lines:I}}function is(y,t,s){let o=String(y||"").trim();if(o&&!isNaN(Number(o))&&!o.includes(" ")&&!o.endsWith("fr")&&!o.endsWith("px")&&!o.endsWith("%")){const r=Math.max(1,parseInt(o));o=new Array(r).fill("1fr").join(" ")}const e=o.split(/\s+/).filter(Boolean),n=new Array(e.length).fill(0);let i=t-(e.length-1)*s,a=0;if(e.forEach((r,l)=>{if(r.endsWith("px")){const d=parseFloat(r);n[l]=d,i-=d}else r.endsWith("fr")?a+=parseFloat(r):r==="auto"&&(n[l]=100,i-=100)}),a>0&&i>0){const r=i/a;e.forEach((l,d)=>{l.endsWith("fr")&&(n[d]=r*parseFloat(l))})}return n}function ns(y,t,s){try{const o=y.autoLayout;return!o||!o.enabled?{childUpdates:[]}:(o.mode||"linear")==="grid"?_s(y,t,s):Ps(y,t,s)}catch(o){return console.error("Layout Engine Error:",o),{childUpdates:[]}}}function Ps(y,t,s){var Y,B;const o=y.autoLayout,{direction:e,spacing:n,padding:i,align:a,wrap:r}=o,l=e==="vertical",d=t.map(R=>{const L=s(R.id),$=R.geometry;let F=(L==null?void 0:L.width)??$.width??100,X=(L==null?void 0:L.height)??$.height??100;if($.type==="Ellipse"||$.type==="Polygon"||$.type==="Star"){const M=(L==null?void 0:L.radius)??$.radius??(L==null?void 0:L.outer_radius)??$.outer_radius??50;F=M*2,X=M*2}else if($.type==="Text"){const M=ss({text:(L==null?void 0:L.text)??$.text??"",fontFamily:$.fontFamily,fontSize:$.fontSize,fontWeight:$.fontWeight,fontStyle:$.fontStyle,lineHeight:$.lineHeight,width:$.width||200,letterSpacing:$.letterSpacing,paragraphSpacing:$.paragraphSpacing,paragraphIndent:$.paragraphIndent,textCase:$.textCase,segments:$.segments,enableSegments:$.enableSegments});X=M.height,$.width||(F=M.width)}return F*=R.transform.scale_x||1,X*=R.transform.scale_y||1,{id:R.id,w:F,h:X,original:R}});let p=y.width,g=y.height;const u=((Y=y.layoutProps)==null?void 0:Y.width)==="hug",f=((B=y.layoutProps)==null?void 0:B.height)==="hug",h=[];let m=[],b=0,c=0;const S=p-i.left-i.right,v=g-i.top-i.bottom;d.forEach(R=>{r&&m.length>0&&(l?c+n+R.h>v:b+n+R.w>S)?(h.push({children:m,width:b,height:c}),m=[R],b=R.w,c=R.h):(m.push(R),l?(b=Math.max(b,R.w),c+=(m.length>1?n:0)+R.h):(b+=(m.length>1?n:0)+R.w,c=Math.max(c,R.h)))}),m.length>0&&h.push({children:m,width:b,height:c}),u&&!l&&(p=Math.max(...h.map(R=>R.width),0)+i.left+i.right),f&&l&&(g=Math.max(...h.map(R=>R.height),0)+i.top+i.bottom);const C=[];let w=i.left,I=i.top;const k=a.toLowerCase(),O=k==="center"||k.endsWith("-center"),T=k.endsWith("-right"),A=k==="center"||k.startsWith("center-"),D=k.startsWith("bottom-");return h.forEach(R=>{let L=w,$=I;l?A?$=i.top+(g-i.top-i.bottom-R.height)/2:D&&($=g-i.bottom-R.height):O?L=i.left+(p-i.left-i.right-R.width)/2:T&&(L=p-i.right-R.width),R.children.forEach(F=>{var _,V;let X=L,M=$;l?O?X+=(R.width-F.w)/2:T&&(X+=R.width-F.w):A?M+=(R.height-F.h)/2:D&&(M+=R.height-F.h);const E=((_=F.original.layoutProps)==null?void 0:_.width)==="fill",P=((V=F.original.layoutProps)==null?void 0:V.height)==="fill";C.push({id:F.id,x:X+F.w/2-p/2,y:M+F.h/2-g/2,width:E&&l?R.width:void 0,height:P?l?void 0:R.height:void 0}),l?$+=F.h+n:L+=F.w+n}),l?w+=R.width+n:I+=R.height+n}),{frameWidth:u?p:void 0,frameHeight:f?g:void 0,childUpdates:C}}function _s(y,t,s){const o=y.autoLayout;if(!o)return{childUpdates:[]};const{gridColumns:e,gridRows:n,columnGap:i=0,rowGap:a=0,padding:r,align:l}=o;let d=y.width,p=y.height;const g=d-r.left-r.right,u=p-r.top-r.bottom,f=is(e||"1fr",g,i),h=is(n||"auto",u,a),m=f.length>0?f.reduce((T,A)=>T+A,0)+(f.length-1)*i:0,b=h.length>0?h.reduce((T,A)=>T+A,0)+(h.length-1)*a:0,c=l.toLowerCase(),S=c==="center"||c.endsWith("-center"),v=c.endsWith("-right"),C=c==="center"||c.startsWith("center-"),w=c.startsWith("bottom-");let I=0,k=0;S?I=(g-m)/2:v&&(I=g-m),C?k=(u-b)/2:w&&(k=u-b);const O=[];return t.forEach((T,A)=>{var V,G;const D=A%f.length||0,Y=Math.floor(A/f.length)||0;Y>=h.length&&h.push(100);const B=f[D],R=h[Y];let L=r.left+I+f.slice(0,D).reduce((x,U)=>x+U+i,0),$=r.top+k+h.slice(0,Y).reduce((x,U)=>x+U+a,0);const F=s(T.id),X=T.geometry;let M=(F==null?void 0:F.width)??X.width??100,E=(F==null?void 0:F.height)??X.height??100;if(X.type==="Ellipse"||X.type==="Polygon"||X.type==="Star"){const x=(F==null?void 0:F.radius)??X.radius??(F==null?void 0:F.outer_radius)??X.outer_radius??50;M=x*2,E=x*2}M*=T.transform.scale_x||1,E*=T.transform.scale_y||1;let P=L,_=$;S?P+=(B-M)/2:v&&(P+=B-M),C?_+=(R-E)/2:w&&(_+=R-E),O.push({id:T.id,x:P+M/2-d/2,y:_+E/2-p/2,width:((V=T.layoutProps)==null?void 0:V.width)==="fill"?B:void 0,height:((G=T.layoutProps)==null?void 0:G.height)==="fill"?R:void 0})}),{childUpdates:O}}class os{constructor(){pt(this,"world",null);pt(this,"bodies",new Map);pt(this,"colliders",new Map);pt(this,"joints",new Map);pt(this,"initialized",!1);pt(this,"bodyIdByCollider",new Map);pt(this,"onCollisionCB",null);pt(this,"eventQueue",null)}setCollisionCallback(t){this.onCollisionCB=t}async init(t){this.initialized||(await ue.init(),this.world=new ue.World(new ue.Vector2(t.x*100,t.y*100)),this.eventQueue=new ue.EventQueue(!0),this.initialized=!0)}destroy(){this.bodies.clear(),this.colliders.clear(),this.joints.clear(),this.world&&(this.world.free(),this.world=null),this.initialized=!1}setGravity(t){this.world&&(this.world.gravity=new ue.Vector2(t.x*100,t.y*100))}createBody(t){if(!this.world){console.warn("[RapierPhysics] World not initialized");return}this.bodies.has(t.id)&&this.removeBody(t.id);const s=t.isStatic?ue.RigidBodyDesc.fixed():ue.RigidBodyDesc.dynamic();s.setTranslation(t.x,t.y),t.rotation!==void 0&&s.setRotation(t.rotation);const o=this.world.createRigidBody(s);let e;switch(t.type){case"Rectangle":e=ue.ColliderDesc.cuboid(t.width/2,t.height/2);break;case"Ellipse":e=ue.ColliderDesc.ball(Math.max(t.width,t.height)/2);break;case"Triangle":case"Star":case"Polygon":e=ue.ColliderDesc.cuboid(t.width/2,t.height/2);break;default:e=ue.ColliderDesc.cuboid(t.width/2,t.height/2)}if(t.friction!==void 0&&e.setFriction(t.friction),t.restitution!==void 0&&e.setRestitution(t.restitution),t.density!==void 0)e.setDensity(t.density);else if(t.mass!==void 0&&!t.isStatic){const i=t.width*t.height;e.setDensity(t.mass/i)}t.isSensor&&e.setSensor(!0);const n=this.world.createCollider(e,o);this.bodyIdByCollider.set(n.handle,t.id),t.frictionAir!==void 0&&o.setLinearDamping(t.frictionAir*10),this.bodies.set(t.id,o),this.colliders.set(t.id,n)}removeBody(t){const s=this.bodies.get(t),o=this.colliders.get(t);o&&this.bodyIdByCollider.delete(o.handle),s&&this.world&&(this.world.removeRigidBody(s),this.bodies.delete(t),this.colliders.delete(t))}step(t){if(!this.world)return;this.world.step(this.eventQueue);const s=this.onCollisionCB,o=this.eventQueue;s&&o&&o.drainContactEvents((e,n,i)=>{const a=this.bodyIdByCollider.get(e),r=this.bodyIdByCollider.get(n);a&&r&&s(a,r,i)})}getPosition(t){const s=this.bodies.get(t);if(!s)return null;const o=s.translation();return{x:o.x,y:o.y}}getRotation(t){const s=this.bodies.get(t);return s?s.rotation():null}getVelocity(t){const s=this.bodies.get(t);if(!s)return null;const o=s.linvel();return{x:o.x,y:o.y}}setPosition(t,s,o){const e=this.bodies.get(t);e&&e.setTranslation(new ue.Vector2(s,o),!0)}setRotation(t,s){const o=this.bodies.get(t);o&&o.setRotation(s,!0)}setVelocity(t,s,o){const e=this.bodies.get(t);e&&e.setLinvel(new ue.Vector2(s,o),!0)}setAngularVelocity(t,s){const o=this.bodies.get(t);o&&o.setAngvel(s,!0)}applyForce(t,s,o){const e=this.bodies.get(t);e&&e.addForce(new ue.Vector2(s,o),!0)}applyImpulse(t,s,o){const e=this.bodies.get(t);e&&e.applyImpulse(new ue.Vector2(s,o),!0)}createJoint(t){if(!this.world){console.warn("[RapierPhysics] World not initialized");return}this.joints.has(t.id)&&this.removeJoint(t.id);const s=this.bodies.get(t.bodyA),o=this.bodies.get(t.bodyB);if(!s||!o){console.warn(`[RapierPhysics] Cannot create joint ${t.id}: bodyA (${t.bodyA}) or bodyB (${t.bodyB}) not found`);return}const e=new ue.Vector2(t.anchorA.x,t.anchorA.y),n=new ue.Vector2(t.anchorB.x,t.anchorB.y);let i;if(t.type==="Distance"){const a=t.length??100,r=t.stiffness??100,l=t.damping??10;i=ue.JointData.spring(a,r,l,e,n)}else i=ue.JointData.revolute(e,n);try{const a=this.world.createImpulseJoint(i,s,o,!0);this.joints.set(t.id,a)}catch(a){console.error(`[RapierPhysics] Failed to create joint ${t.id}:`,a)}}removeJoint(t){const s=this.joints.get(t);if(s&&this.world){try{this.world.removeImpulseJoint(s,!0)}catch(o){console.error(`[RapierPhysics] Failed to remove joint ${t}:`,o)}this.joints.delete(t)}}}const as=y=>y,As=y=>y>0?1:0,Es=y=>y<1?0:1,rs=y=>y*y,ls=y=>y*(2-y),cs=y=>y<.5?2*y*y:-1+(4-2*y)*y,Ls=y=>y*y*y,Os=y=>--y*y*y+1,Rs=y=>y<.5?4*y*y*y:(y-1)*(2*y-2)*(2*y-2)+1,$s=y=>y*y*y*y,Fs=y=>1- --y*y*y*y,Ws=y=>y<.5?8*y*y*y*y:1-8*--y*y*y*y,Bs=y=>y*y*y*y*y,Ys=y=>1+--y*y*y*y*y,Ds=y=>y<.5?16*y*y*y*y*y:1+16*--y*y*y*y*y,Xs=y=>1-Math.cos(y*Math.PI/2),Ns=y=>Math.sin(y*Math.PI/2),Hs=y=>-(Math.cos(Math.PI*y)-1)/2,Vs=y=>y===0?0:Math.pow(2,10*(y-1)),Gs=y=>y===1?1:1-Math.pow(2,-10*y),zs=y=>y===0?0:y===1?1:y<.5?Math.pow(2,20*y-10)/2:(2-Math.pow(2,-20*y+10))/2,xs=y=>1-Math.sqrt(1-y*y),Us=y=>Math.sqrt(1- --y*y),qs=y=>y<.5?(1-Math.sqrt(1-4*y*y))/2:(Math.sqrt(1-(-2*y+2)*(-2*y+2))+1)/2,Je=1.70158,Ke=Je*1.525,hs=Je+1,Js=y=>hs*y*y*y-Je*y*y,Ks=y=>1+hs*Math.pow(y-1,3)+Je*Math.pow(y-1,2),Qs=y=>y<.5?Math.pow(2*y,2)*((Ke+1)*2*y-Ke)/2:(Math.pow(2*y-2,2)*((Ke+1)*(y*2-2)+Ke)+2)/2,fs=2*Math.PI/3,ds=2*Math.PI/4.5,Zs=y=>y===0?0:y===1?1:-Math.pow(2,10*y-10)*Math.sin((y*10-10.75)*fs),js=y=>y===0?0:y===1?1:Math.pow(2,-10*y)*Math.sin((y*10-.75)*fs)+1,ti=y=>y===0?0:y===1?1:y<.5?-(Math.pow(2,20*y-10)*Math.sin((20*y-11.125)*ds))/2:Math.pow(2,-20*y+10)*Math.sin((20*y-11.125)*ds)/2+1,Qe=y=>y<1/2.75?7.5625*y*y:y<2/2.75?7.5625*(y-=1.5/2.75)*y+.75:y<2.5/2.75?7.5625*(y-=2.25/2.75)*y+.9375:7.5625*(y-=2.625/2.75)*y+.984375,ei=y=>1-Qe(1-y),si=Qe,ii=y=>y<.5?(1-Qe(1-2*y))/2:(1+Qe(2*y-1))/2,ts=new Map,ze=(y,t,s,o)=>{const e=`${y},${t},${s},${o}`;if(ts.has(e))return ts.get(e);const n=d=>(1-3*s+3*y)*d*d*d+(3*s-6*y)*d*d+3*y*d,i=d=>(1-3*o+3*t)*d*d*d+(3*o-6*t)*d*d+3*t*d,a=d=>3*(1-3*s+3*y)*d*d+2*(3*s-6*y)*d+3*y,r=d=>{let p=d;for(let g=0;g<8;g++){const u=n(p)-d;if(Math.abs(u)<1e-6)return p;const f=a(p);if(Math.abs(f)<1e-6)break;p=p-u/f}return p},l=d=>d===0?0:d===1?1:i(r(d));return ts.set(e,l),l},ps=y=>{const t=y.match(/cubic-bezier\s*\(\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*\)/);if(!t)return null;const[,s,o,e,n]=t.map(Number);return ze(s,o,e,n)},us={ease:ze(.25,.1,.25,1),"ease-in":ze(.42,0,1,1),"ease-out":ze(0,0,.58,1),"ease-in-out":ze(.42,0,.58,1)},Ze={Linear:as,EaseInQuad:rs,EaseOutQuad:ls,EaseInOutQuad:cs,EaseInCubic:Ls,EaseOutCubic:Os,EaseInOutCubic:Rs,EaseInQuart:$s,EaseOutQuart:Fs,EaseInOutQuart:Ws,EaseInQuint:Bs,EaseOutQuint:Ys,EaseInOutQuint:Ds,EaseInSine:Xs,EaseOutSine:Ns,EaseInOutSine:Hs,EaseInExpo:Vs,EaseOutExpo:Gs,EaseInOutExpo:zs,EaseInCirc:xs,EaseOutCirc:Us,EaseInOutCirc:qs,EaseInBack:Js,EaseOutBack:Ks,EaseInOutBack:Qs,EaseInElastic:Zs,EaseOutElastic:js,EaseInOutElastic:ti,EaseInBounce:ei,EaseOutBounce:si,EaseInOutBounce:ii,EaseIn:rs,EaseOut:ls,EaseInOut:cs,StepStart:As,StepEnd:Es},gs=y=>{const t=y.trim(),s=t.toLowerCase();if(Ze[t])return Ze[t];const o=Object.keys(Ze).find(n=>n.toLowerCase()===s);if(o)return Ze[o];const e=Object.keys(ms).find(n=>n.toLowerCase()===s);if(e){const n=ps(ms[e].value);if(n)return n}if(us[s])return us[s];if(s.startsWith("cubic-bezier")){const n=ps(t);if(n)return n}return as},ms={Snappy:{label:"Snappy",description:"High energy, quick arrival.",value:"cubic-bezier(0.2, 1, 0.2, 1)"},Bouncy:{label:"Bouncy",description:"Springy with an overshoot.",value:"cubic-bezier(0.2, 0.9, 0.4, 1.3)"},Gentle:{label:"Gentle",description:"Smooth and organic flow.",value:"cubic-bezier(0.4, 0, 0.6, 1)"},Stiff:{label:"Stiff",description:"Solid and reliable movement.",value:"cubic-bezier(0.3, 1, 0.7, 1)"},Floating:{label:"Floating",description:"Weightless and airy transition.",value:"cubic-bezier(0.5, 0, 0.5, 1)"},Sudden:{label:"Sudden",description:"Instant, direct movement.",value:"cubic-bezier(1, 0, 1, 1)"},Elastic:{label:"Elastic",description:"Extreme overshoot and spring.",value:"cubic-bezier(0.5, 1.5, 0.5, 1.5)"},Sharp:{label:"Sharp",description:"Fast start, very hard stop.",value:"cubic-bezier(0.1, 0.9, 0.1, 1)"},Fluid:{label:"Fluid",description:"Natural high-end flow.",value:"cubic-bezier(0.4, 0, 0.2, 1)"},Heavy:{label:"Heavy",description:"Slow start, massive impact.",value:"cubic-bezier(0.6, 0, 1, 1)"}},ni=(y,t,s,o,e)=>{if(!y||!t||!s)return y;const n=o.scale_x??1,i=o.scale_y??1,a=(r,l,d)=>{let p=0,g=0;const u=o.rotation*Math.PI/180,f=Math.cos(u),h=Math.sin(u),m=r*n*f-l*i*h+o.x,b=r*n*h+l*i*f+o.y;d.forEach(k=>{const O=e(k.boneId);if(!O)return;const T={x:O.x,y:O.y,rotation:O.rotation,scaleX:O.scale_x??1,scaleY:O.scale_y??1},A=s[k.boneId]||[1,0,0,1,0,0],D=m*A[0]+b*A[2]+A[4],Y=m*A[1]+b*A[3]+A[5],B=T.rotation*Math.PI/180,R=Math.cos(B),L=Math.sin(B),$=D*T.scaleX*R-Y*T.scaleY*L+T.x,F=D*T.scaleX*L+Y*T.scaleY*R+T.y;p+=$*k.amount,g+=F*k.amount});const c=[...d].sort((k,O)=>O.amount-k.amount);if(c.length>=2&&c[0].amount>0&&c[1].amount>0){const k=e(c[0].boneId),O=e(c[1].boneId);if(k&&O&&k.length!==void 0&&O.length!==void 0){const T=k.length*(k.scale_y??1),A=k.rotation*Math.PI/180,D=k.x-T*Math.sin(A),Y=k.y+T*Math.cos(A),B=O.length*(O.scale_y??1),R=O.rotation*Math.PI/180,L=O.x-B*Math.sin(R),$=O.y+B*Math.cos(R);let F=null,X=null,M=!1;const E=1;if(Math.hypot(k.x-O.x,k.y-O.y)<E||Math.hypot(k.x-L,k.y-$)<E?(F=k.x,X=k.y):(Math.hypot(D-O.x,Y-O.y)<E||Math.hypot(D-L,Y-$)<E)&&(F=D,X=Y,M=!0),F!==null&&X!==null){const P=s[c[0].boneId]||[1,0,0,1,0,0],_=P[0]*P[3]-P[1]*P[2];let V=0,G=0;if(_!==0){const x=(P[2]*P[5]-P[3]*P[4])/_,U=(P[1]*P[4]-P[0]*P[5])/_,q=Math.atan2(-P[1],P[3]);if(!M)V=x,G=U;else{const z=-P[2]/_,et=P[0]/_,Mt=Math.hypot(z,et),ct=k.length*Mt;V=x-ct*Math.sin(q),G=U+ct*Math.cos(q)}const N=Math.hypot(m-V,b-G),H=Math.hypot(p-F,g-X);if(H>0&&N>0){const z=Math.max(H,.01),et=Math.min(N/z,3),Mt=F+(p-F)*et,ct=X+(g-X)*et,It=c[0].amount,mt=c[1].amount,kt=Math.min(It,mt)*2,Ot=1-Math.pow(1-kt,4);p=p*(1-Ot)+Mt*Ot,g=g*(1-Ot)+ct*Ot}}}}}const S=o.rotation*Math.PI/180,v=Math.cos(S),C=Math.sin(S),w=p-o.x,I=g-o.y;return{x:(w*v+I*C)/n,y:(-w*C+I*v)/i}};return y.map((r,l)=>{const d=t[l];if(!d||d.length===0)return{...r};const p={...r,...a(r.x,r.y,d)};if(r.in_x!==void 0&&r.in_y!==void 0){const g=a(r.in_x,r.in_y,d);p.in_x=g.x,p.in_y=g.y}if(r.out_x!==void 0&&r.out_y!==void 0){const g=a(r.out_x,r.out_y,d);p.out_x=g.x,p.out_y=g.y}return p})};function oi(y,t,s,o,e){const n=y*s*.01,i=t*s*.01,a=Math.sin(e*12.9898)*43758.5453%(Math.PI*2),r=Math.cos(e*78.233)*43758.5453%(Math.PI*2);return(Math.sin(n+a)*Math.cos(i+r)+.5*Math.sin(n*2.1-r)*Math.cos(i*2.3+a)+.25*Math.sin(n*4.5+a)*Math.cos(i*4.2-r))/1.75*o}function ai(y,t,s,o,e,n,i=0,a=0){const r=[];if(!y)return[];const l=y.type;if(l==="Rectangle"||l==="Image"||l==="Frame"){const f=Math.max(20,Math.floor((t+s)/10)),h=Math.max(2,Math.floor(f*(t/(t+s)))),m=Math.max(2,Math.floor(f*(s/(t+s))));for(let b=0;b<h;b++)r.push({x:-t/2+t/h*b,y:-s/2,nx:0,ny:-1});for(let b=0;b<m;b++)r.push({x:t/2,y:-s/2+s/m*b,nx:1,ny:0});for(let b=0;b<h;b++)r.push({x:t/2-t/h*b,y:s/2,nx:0,ny:1});for(let b=0;b<m;b++)r.push({x:-t/2,y:s/2-s/m*b,nx:-1,ny:0})}else if(l==="Ellipse"){const f=Math.max(60,Math.floor(Math.PI*Math.max(t,s)/5));for(let h=0;h<f;h++){const m=h/f*Math.PI*2,b=Math.cos(m),c=Math.sin(m);r.push({x:b*t/2,y:c*s/2,nx:b,ny:c})}}else if(l==="Triangle"){const f={x:0,y:-s/2},h={x:t/2,y:s/2},m={x:-t/2,y:s/2},b=20;let c=h.x-f.x,S=h.y-f.y,v=Math.hypot(c,S),C=-S/v,w=c/v;for(let I=0;I<b;I++)r.push({x:f.x+c*(I/b),y:f.y+S*(I/b),nx:C,ny:w});c=m.x-h.x,S=m.y-h.y,v=Math.hypot(c,S),C=-S/v,w=c/v;for(let I=0;I<b;I++)r.push({x:h.x+c*(I/b),y:h.y+S*(I/b),nx:C,ny:w});c=f.x-m.x,S=f.y-m.y,v=Math.hypot(c,S),C=-S/v,w=c/v;for(let I=0;I<b;I++)r.push({x:m.x+c*(I/b),y:m.y+S*(I/b),nx:C,ny:w})}else for(let h=0;h<80;h++){const m=h/80*Math.PI*2,b=Math.cos(m),c=Math.sin(m);r.push({x:b*t/2,y:c*s/2,nx:b,ny:c})}const d=i*Math.PI/180,p=Math.cos(d),g=Math.sin(d);return r.map(f=>{const h=oi(f.x,f.y,e,o,n),m=f.nx*(1-a)+p*a,b=f.ny*(1-a)+g*a;let c=Math.hypot(m,b);return c===0&&(c=1),{x:f.x+m/c*h,y:f.y+b/c*h}})}const ri={default:{label:"Default",colors:["#6366f1","#f59e0b"],cardBackground:"rgba(255,255,255,0.04)",cardBorderColor:"rgba(255,255,255,0.08)",gridColor:"rgba(255,255,255,0.06)",axisLabelColor:"rgba(255,255,255,0.5)",legendColor:"rgba(255,255,255,0.7)",barGradient:!0},neon:{label:"Neon",colors:["#00f5ff","#ff00e5"],cardBackground:"rgba(0,0,0,0.5)",cardBorderColor:"rgba(0,245,255,0.2)",gridColor:"rgba(0,245,255,0.08)",axisLabelColor:"rgba(0,245,255,0.6)",legendColor:"rgba(0,245,255,0.8)",barGradient:!0},pastel:{label:"Pastel",colors:["#a5b4fc","#fcd34d"],cardBackground:"rgba(255,255,255,0.06)",cardBorderColor:"rgba(255,255,255,0.12)",gridColor:"rgba(255,255,255,0.08)",axisLabelColor:"rgba(255,255,255,0.45)",legendColor:"rgba(255,255,255,0.65)",barGradient:!1},warm:{label:"Warm",colors:["#f97316","#ef4444"],cardBackground:"rgba(30,10,0,0.4)",cardBorderColor:"rgba(249,115,22,0.2)",gridColor:"rgba(249,115,22,0.08)",axisLabelColor:"rgba(253,186,116,0.7)",legendColor:"rgba(253,186,116,0.85)",barGradient:!0},ocean:{label:"Ocean",colors:["#06b6d4","#0ea5e9"],cardBackground:"rgba(0,20,40,0.5)",cardBorderColor:"rgba(6,182,212,0.2)",gridColor:"rgba(6,182,212,0.06)",axisLabelColor:"rgba(125,211,252,0.6)",legendColor:"rgba(125,211,252,0.8)",barGradient:!0},mono:{label:"Mono",colors:["rgba(255,255,255,0.9)","rgba(255,255,255,0.4)"],cardBackground:"rgba(255,255,255,0.03)",cardBorderColor:"rgba(255,255,255,0.1)",gridColor:"rgba(255,255,255,0.05)",axisLabelColor:"rgba(255,255,255,0.4)",legendColor:"rgba(255,255,255,0.6)",barGradient:!1}},ys={vibrant:["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399","#a855f7","#f87171"],pastel:["#a5b4fc","#67e8f9","#fcd34d","#f9a8d4","#6ee7b7","#c4b5fd","#fca5a5"],neon:["#00f5ff","#ff00e5","#00ff9f","#ff6b00","#b400ff","#ffe600","#00c3ff"],warm:["#f97316","#ef4444","#f59e0b","#dc2626","#fb923c","#e11d48","#ea580c"],ocean:["#06b6d4","#0ea5e9","#38bdf8","#7dd3fc","#0284c7","#0369a1","#bae6fd"]},xe={Rectangle:"M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5z",Hexagon:"M12 2l8.5 5v10L12 22l-8.5-5V7L12 2z",Octagon:"M7.86 2h8.28L22 7.86v8.28L16.14 22H7.86L2 16.14V7.86L7.86 2z",Heart:"M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z",Cloud:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96z",Shield:"M12 2L4 5v6.09c0 5.05 3.41 9.76 8 10.91 4.59-1.15 8-5.86 8-10.91V5l-8-3z",Badge:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76z",Leaf:"M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z",Tag:"M12 2H2v10l9.29 9.29c.94.94 2.48.94 3.42 0l6.58-6.58c.94-.94.94-2.48 0-3.42L12 2Z",Sparkle:"M12 2v4m0 12v4M4.93 4.93l2.83 2.83m8.48 8.48l2.83 2.83M2 12h4m12 0h4M4.93 19.07l2.83-2.83m8.48-8.48l2.83-2.83",Diamond:"M12 2L2 12l10 10 10-10L12 2z",Star:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"},We=y=>{let t=1/0,s=1/0,o=-1/0,e=-1/0,n=0,i=0;const a=/([a-df-z])([^a-df-z]*)/gi;let r;for(;(r=a.exec(y))!==null;){const u=r[1],f=u===u.toLowerCase(),h=u.toUpperCase(),m=[],b=/[-+]?(?:\d*\.\d+|\d+)(?:[eE][-+]?\d+)?/g;let c;for(;(c=b.exec(r[2]))!==null;)m.push(parseFloat(c[0]));const S=(v,C)=>{!isNaN(v)&&!isNaN(C)&&(v<t&&(t=v),v>o&&(o=v),C<s&&(s=C),C>e&&(e=C),n=v,i=C)};if(h==="M"||h==="L"||h==="T")for(let v=0;v<m.length-1;v+=2){const C=f?n+m[v]:m[v],w=f?i+m[v+1]:m[v+1];S(C,w)}else if(h==="H")for(let v=0;v<m.length;v++){const C=f?n+m[v]:m[v];S(C,i)}else if(h==="V")for(let v=0;v<m.length;v++){const C=f?i+m[v]:m[v];S(n,C)}else if(h==="C")for(let v=0;v<m.length-5;v+=6){const C=f?n+m[v]:m[v],w=f?i+m[v+1]:m[v+1],I=f?n+m[v+2]:m[v+2],k=f?i+m[v+3]:m[v+3],O=f?n+m[v+4]:m[v+4],T=f?i+m[v+5]:m[v+5];S(C,w),S(I,k),S(O,T)}else if(h==="S"||h==="Q")for(let v=0;v<m.length-3;v+=4){const C=f?n+m[v]:m[v],w=f?i+m[v+1]:m[v+1],I=f?n+m[v+2]:m[v+2],k=f?i+m[v+3]:m[v+3];S(C,w),S(I,k)}else if(h==="A")for(let v=0;v<m.length-6;v+=7){const C=f?n+m[v+5]:m[v+5],w=f?i+m[v+6]:m[v+6];S(C,w)}}(!isFinite(t)||!isFinite(o)||!isFinite(s)||!isFinite(e))&&(t=0,o=24,s=0,e=24);const l=Math.max(.001,o-t),d=Math.max(.001,e-s),p=(t+o)/2,g=(s+e)/2;return{minX:t,minY:s,maxX:o,maxY:e,width:l,height:d,cx:p,cy:g}};class bs{constructor(){pt(this,"artboard",null);pt(this,"objectStates",new Map);pt(this,"physicsEngine",null);pt(this,"activeStateMachine",null);pt(this,"inputs",new Map);pt(this,"inputNameMap",new Map);pt(this,"layerStates",new Map);pt(this,"pretextCache",new Map);pt(this,"pointerHistory",[]);pt(this,"MAX_HISTORY",200);pt(this,"imageCache",new Map);pt(this,"lastValidSvgImgMap",new Map);pt(this,"maskBuffer",null);pt(this,"maskCtx",null);pt(this,"lumaBuffer",null);pt(this,"lumaCtx",null);pt(this,"_noiseTileCanvas",null);pt(this,"layout",{fit:"Contain",alignment:"Center"});pt(this,"onTrigger");pt(this,"onInputUpdate");pt(this,"onComponentChange");pt(this,"onToggle");pt(this,"onInputChange");pt(this,"onInputFocus");pt(this,"onInputBlur");pt(this,"onLog");pt(this,"onButtonClick");pt(this,"onGraphPointClick");pt(this,"justFiredTriggers",new Set);pt(this,"rootTransform",null);pt(this,"canvasWidth",0);pt(this,"canvasHeight",0);pt(this,"lastHoveredObjectId",null);pt(this,"_lastPointerPos",null);pt(this,"_prevPointerPos",null);pt(this,"_mouseDelta",{dx:0,dy:0});pt(this,"focusedId",null);pt(this,"draggingSliderId",null);pt(this,"draggingJoystickId",null);pt(this,"activeDropdownId",null);pt(this,"activeObjectId",null);pt(this,"draggingListViewId",null);pt(this,"draggingListViewIsScrollbar",!1);pt(this,"scrollOffset",{x:0,y:0});pt(this,"_totalScroll",{x:0,y:0});pt(this,"draggingBehaviors",new Set);pt(this,"dragStartPointer",null);pt(this,"dragStartPositions",new Map);pt(this,"isMouseDown",!1);pt(this,"activeKeys",new Set);pt(this,"graphHoverStates",new Map);pt(this,"barChartRenderedBars",new Map);pt(this,"pieChartRenderedSlices",new Map);pt(this,"_layoutAnimCache",new Map);pt(this,"_springChainState",new Map);pt(this,"_emitterPools",new Map);pt(this,"objectVelocities",new Map);pt(this,"currentTime",0);pt(this,"frameCount",0);pt(this,"entranceStartTimes",new Map);pt(this,"fontLeadingFactors",{Inter:.35,Roboto:.45,Montserrat:.4,Outfit:.35,"Open Sans":.4,Poppins:.45,"Playfair Display":.35,Lora:.4,Lato:.35,"Bebas Neue":.45,Oswald:.4});pt(this,"onLogicUpdate");pt(this,"logicNodeValues",new Map);pt(this,"logicNodeState",new Map);pt(this,"pointerDownTimes",new Map);pt(this,"activeHoverIds",new Set);pt(this,"onNavigation");pt(this,"periodicTriggerTimes",new Map);pt(this,"wasInView",new Set);pt(this,"scrollProgressLastValue",new Map);pt(this,"debug_objectsRendered",0);pt(this,"debug_objectsTotal",0);pt(this,"lastRenderTime",0);pt(this,"debugMode",!1);pt(this,"activeTriggers",new Map);console.info("%c[ExodeUI Engine] Pixel-Perfect Parity Active (v6.3.10) - SVG Fill & Gradient Parity Active","color: #3b82f6; font-weight: bold; padding: 2px 4px; border-radius: 4px; background: rgba(59, 130, 246, 0.1)")}getInputValue(t){if(this.inputs.has(t))return this.inputs.get(t);const s=this.inputNameMap.get(t);if(s&&s.length>0)return this.inputs.get(s[0])}setTriggerCallback(t){this.onTrigger=t}setInputUpdateCallback(t){this.onInputUpdate=t}setComponentChangeCallback(t){this.onComponentChange=t}setToggleCallback(t){this.onToggle=t}setLogicUpdateCallback(t){this.onLogicUpdate=t}setInputChangeCallback(t){this.onInputChange=t}setButtonClickCallback(t){this.onButtonClick=t}setGraphPointClickCallback(t){this.onGraphPointClick=t}setNavigationCallback(t){this.onNavigation=t}ensurePathPoints(t){if(!t)return;const s=(t.type||"").toLowerCase();if(!(s==="path"||s==="custom"||s==="customshape"||s==="shape"||s==="subtract"||s==="union"||s==="intersect"||s==="exclude"||s==="booleanoperation"))return;const e=t.data||t.pathData||t.d||t.path||t.svgPath;if(t.points&&t.points.length>0){if(t.is_closed===void 0&&t.isClosed===void 0&&e){const{isClosed:a}=this.svgPathToPoints(e);t.is_closed=a}return}if(!e)return;const{points:n,isClosed:i}=this.svgPathToPoints(e);t.points=n,t.is_closed===void 0&&(t.is_closed=i)}svgPathToPoints(t){const s=/([MLHVCSQTAZmlhvcsqtaz])([^MLHVCSQTAZmlhvcsqtaz]*)/g,o=/[-+]?(?:\d*\.\d+|\d+)(?:[eE][-+]?\d+)?/g,e=[];let n=!1,i=0,a=0,r=0,l=0,d=0,p=0,g="",u;for(;(u=s.exec(t))!==null;){const f=u[1],h=(u[2].match(o)||[]).map(parseFloat),m=f===f.toLowerCase(),b=f.toUpperCase();let c=0;const S=C=>{let w=h[c++];return m&&(w+=C?i:a),w},v=()=>({x:S(!0),y:S(!1)});switch(b){case"M":{const C=v();for(d=i=C.x,p=a=C.y,e.push({x:i,y:a,in_x:i,in_y:a,out_x:i,out_y:a,moveTo:!0});c<h.length;){const w=v();i=w.x,a=w.y,e.push({x:i,y:a,in_x:i,in_y:a,out_x:i,out_y:a})}break}case"L":for(;c<h.length;){const C=v();i=C.x,a=C.y,e.push({x:i,y:a,in_x:i,in_y:a,out_x:i,out_y:a})}break;case"H":for(;c<h.length;)i=S(!0),e.push({x:i,y:a,in_x:i,in_y:a,out_x:i,out_y:a});break;case"V":for(;c<h.length;)a=S(!1),e.push({x:i,y:a,in_x:i,in_y:a,out_x:i,out_y:a});break;case"C":for(;c<h.length;){const C=v(),w=v(),I=v();if(e.length>0){const k=e[e.length-1];k.out_x=C.x,k.out_y=C.y}i=I.x,a=I.y,e.push({x:i,y:a,in_x:w.x,in_y:w.y,out_x:i,out_y:a}),r=w.x,l=w.y}break;case"S":for(;c<h.length;){let C=i,w=a;(g==="C"||g==="S")&&(C=2*i-r,w=2*a-l);const I=v(),k=v();if(e.length>0){const O=e[e.length-1];O.out_x=C,O.out_y=w}i=k.x,a=k.y,e.push({x:i,y:a,in_x:I.x,in_y:I.y,out_x:i,out_y:a}),r=I.x,l=I.y}break;case"Q":for(;c<h.length;){const C=v(),w=v();if(e.length>0){const I=e[e.length-1];I.out_x=I.x+2/3*(C.x-I.x),I.out_y=I.y+2/3*(C.y-I.y)}i=w.x,a=w.y,e.push({x:i,y:a,in_x:i+2/3*(C.x-i),in_y:a+2/3*(C.y-a),out_x:i,out_y:a}),r=C.x,l=C.y}break;case"T":for(;c<h.length;){let C=i,w=a;(g==="Q"||g==="T")&&(C=2*i-r,w=2*a-l);const I=v();if(e.length>0){const k=e[e.length-1];k.out_x=k.x+2/3*(C-k.x),k.out_y=k.y+2/3*(w-k.y)}i=I.x,a=I.y,e.push({x:i,y:a,in_x:i+2/3*(C-i),in_y:a+2/3*(w-a),out_x:i,out_y:a}),r=C,l=w}break;case"A":for(;c+6<h.length;){const C=Math.abs(h[c++]),w=Math.abs(h[c++]),I=h[c++],k=h[c++],O=h[c++];let T=h[c++],A=h[c++];if(m&&(T+=i,A+=a),C===0||w===0||Math.abs(T-i)<.001&&Math.abs(A-a)<.001){i=T,a=A,e.push({x:i,y:a,in_x:i,in_y:a,out_x:i,out_y:a});break}const D=I*Math.PI/180,Y=Math.cos(D),B=Math.sin(D),R=(i-T)/2,L=(a-A)/2,$=Y*R+B*L,F=-B*R+Y*L;let X=C,M=w;const E=$*$,P=F*F;let _=X*X,V=M*M;const G=E/_+P/V;if(G>1){const St=Math.sqrt(G);X*=St,M*=St,_=X*X,V=M*M}const x=k!==O?1:-1,U=Math.max(0,_*V-_*P-V*E),q=_*P+V*E,N=q>0?Math.sqrt(U/q):0,H=x*N*(X*F)/M,z=x*N*-(M*$)/X,et=Y*H-B*z+(i+T)/2,Mt=B*H+Y*z+(a+A)/2,ct=($-H)/X,It=(F-z)/M,mt=(-$-H)/X,kt=(-F-z)/M,Ot=(St,Pt)=>{const Ft=St[0]*Pt[0]+St[1]*Pt[1],lt=Math.sqrt((St[0]**2+St[1]**2)*(Pt[0]**2+Pt[1]**2)),ht=Math.max(-1,Math.min(1,Ft/lt));return(St[0]*Pt[1]-St[1]*Pt[0]<0?-1:1)*Math.acos(ht)};let vt=Ot([1,0],[ct,It]),Wt=Ot([ct,It],[mt,kt]);!O&&Wt>0&&(Wt-=2*Math.PI),O&&Wt<0&&(Wt+=2*Math.PI);const J=Math.max(1,Math.ceil(Math.abs(Wt)/(Math.PI/2))),ut=Wt/J,$t=St=>({x:Y*X*Math.cos(St)-B*M*Math.sin(St)+et,y:B*X*Math.cos(St)+Y*M*Math.sin(St)+Mt,tx:-Y*X*Math.sin(St)-B*M*Math.cos(St),ty:-B*X*Math.sin(St)+Y*M*Math.cos(St)});for(let St=0;St<J;St++){const Pt=vt+St*ut,Ft=vt+(St+1)*ut,lt=Math.sin(ut)*(Math.sqrt(4+3*Math.tan(ut/2)**2)-1)/3,ht=$t(Pt),dt=$t(Ft),At=ht.x+lt*ht.tx,Tt=ht.y+lt*ht.ty,Ct=dt.x-lt*dt.tx,Yt=dt.y-lt*dt.ty;if(e.length>0){const ie=e[e.length-1];ie.out_x=At,ie.out_y=Tt}i=dt.x,a=dt.y,e.push({x:i,y:a,in_x:Ct,in_y:Yt,out_x:i,out_y:a})}r=i,l=a}break;case"Z":if(n=!0,e.length>0){const C=e[e.length-1];C.closePath=!0;const w=[...e].reverse().find(I=>I.moveTo)||e[0];w&&Math.hypot(w.x-C.x,w.y-C.y)<.1&&(w.in_x=C.in_x,w.in_y=C.in_y,e.pop(),e.length>0&&(e[e.length-1].closePath=!0))}i=d,a=p;break;default:if(h.length>=2){const C=v();i=C.x,a=C.y,e.push({x:i,y:a,in_x:i,in_y:a,out_x:i,out_y:a})}break}b!=="S"&&b!=="T"&&(g=b)}return{points:e,isClosed:n}}setOnLogCallback(t){this.onLog=t}debugLog(t){this.onLog&&this.onLog(t)}setInputFocusCallback(t){this.onInputFocus=t}setInputBlurCallback(t){this.onInputBlur=t}updateConstraint(t,s,o){var n;const e=(n=this.artboard)==null?void 0:n.objects.find(i=>i.id===t);e&&e.constraints&&e.constraints[s]&&(e.constraints[s]={...e.constraints[s],...o},o.useSpring===!1&&this.objectVelocities.delete(t))}log(...t){this.debugMode&&console.log(...t)}warn(...t){this.debugMode&&console.warn(...t)}setInternalInput(t,s){this.inputs.set(t,s),this.onInputUpdate&&this.onInputUpdate(t,s)}setLayout(t,s){this.layout={fit:t,alignment:s}}getActiveStateIds(t="Base Layer"){const s=this.layerStates.get(t);return s?s.currentStateIds:[]}getObjectState(t){return this.objectStates.get(t)}updateObjectOptions(t,s){const o=this.objectStates.get(t);o&&(o.options={...o.options,...s})}updateGraphData(t,s,o){var n,i,a;if(!this.artboard)return;const e=this.artboard.objects.find(r=>r.id===t||r.name===t);if(e){const r=((n=e.geometry)==null?void 0:n.type)==="LineGraph",l=e.type==="BarChart"||e.type==="Component"&&e.variant==="barchart",d=e.type==="PieChart"||e.type==="Component"&&e.variant==="piechart";if(r){const p=e.geometry,g=Array.isArray(s[0])?s[0]:s;!p.datasets||p.datasets.length===0?p.datasets=[{id:"default",label:"Runtime Data",data:g,lineColor:"#3b82f6",lineWidth:2,showArea:!1}]:p.datasets[0].data=g;const u=this.objectStates.get(e.id);u&&((i=u.geometry)==null?void 0:i.type)==="LineGraph"&&(!u.geometry.datasets||u.geometry.datasets.length===0?u.geometry.datasets=JSON.parse(JSON.stringify(p.datasets)):u.geometry.datasets[0].data=[...g]),(a=p.datasets[0])!=null&&a.inputId&&this.updateInput(p.datasets[0].inputId,g);return}else if(l){this.updateBarChartData(e.id,Array.isArray(s[0])?s:[s],o);return}else if(d){this.updatePieChartData(e.id,Array.isArray(s[0])?s[0]:s);return}}this.updateInput(t,s)}updateBarChartData(t,s,o){if(!this.artboard)return;const e=this.artboard.objects.find(l=>l.id===t||l.name===t);if(!e){this.updateInput(t,s);return}const n=this.objectStates.get(e.id),i=(n==null?void 0:n.options)||e.options||{},a=s.map((l,d)=>{var g;const p=((g=i.datasets)==null?void 0:g[d])||{};return Array.isArray(l)?{id:p.id||`ds-${d}`,label:p.label||`Series ${d+1}`,color:p.color||"#6366f1",data:l}:{id:l.id||p.id||`ds-${d}`,label:l.label||p.label||`Series ${d+1}`,color:l.color||p.color||"#6366f1",data:l.data||[]}}),r={...i,datasets:a};o&&Array.isArray(o)&&(r.categories=o),e.options=r,n&&(n.options=r),i.datasetInputIds&&Array.isArray(i.datasetInputIds)&&i.datasetInputIds.forEach((l,d)=>{a[d]&&this.updateInput(l,a[d].data)}),o&&i.dataInputId&&this.updateInput(i.dataInputId,o)}updatePieChartData(t,s){if(!this.artboard)return;const o=this.artboard.objects.find(l=>l.id===t||l.name===t);if(!o){this.updateInput(t,s);return}const e=this.objectStates.get(o.id),n=(e==null?void 0:e.options)||o.options||{},i=n.slices||[],a=s.map((l,d)=>{const p=i[d]||{};return typeof l=="number"?{id:p.id||`slice-${d}`,label:p.label||`Item ${d+1}`,color:p.color||"",value:l}:{id:l.id||p.id||`slice-${d}`,label:l.label||p.label||`Item ${d+1}`,color:l.color||p.color||"",value:typeof l.value=="number"?l.value:parseFloat(l.value)||0}}),r={...n,slices:a};o.options=r,e&&(e.options=r),n.dataInputId&&this.updateInput(n.dataInputId,a.map(l=>l.value))}setDropdownOptions(t,s){if(!this.artboard)return;const o=this.artboard.objects.find(a=>a.id===t||a.name===t);if(!o){this.updateInput(t,s);return}const e=this.objectStates.get(o.id),n=(e==null?void 0:e.options)||o.options||{},i={...n,optionsList:s};o.options=i,e&&(e.options=i),n.dataInputId&&this.updateInput(n.dataInputId,s)}load(t){var i,a;if(!t)return;let s=this.decompressStrings(t);const o=[],e=new Set,n=r=>{r&&r.forEach(l=>{if(e.has(l.id))return;const d={...l},p=d.childrenObjects||[];e.add(d.id),o.push(d),n(p)})};if(n(s.objects||[]),o.length>(s.objects||[]).length&&this.log(`[Engine] Flattened artboard from ${(s.objects||[]).length} to ${o.length} objects.`),s.objects=o,this.artboard=s,this.currentTime=0,this.objectStates.clear(),this.log(`[ExodeUIEngine] Loading artboard: "${(i=this.artboard)==null?void 0:i.name}" with ${(a=this.artboard)==null?void 0:a.objects.length} objects`),this.artboard&&this.artboard.objects){const r=new Map;this.artboard.objects.forEach(l=>{r.set(l.id,l),l.children||(l.children=[])}),this.artboard.objects.forEach(l=>{if(l.parentId){const d=r.get(l.parentId);d&&(d.children||(d.children=[]),d.children.includes(l.id)||d.children.push(l.id))}})}this.loadFonts(),this.preloadImages(this.artboard),this.reset(),this.advance(0)}preloadImages(t){if(!t||!t.objects)return;const s=o=>{if(!o||this.imageCache.has(o))return;const e=new Image;e.onload=()=>{this.log(`[ExodeUI Preload] loaded ${e.naturalWidth}x${e.naturalHeight}`)},e.onerror=n=>{console.error("[ExodeUI Preload] failed:",n,`Src: ${o.substring(0,80)}...`)},e.src=o,this.imageCache.set(o,e)};t.objects.forEach(o=>{var e,n,i;(e=o.geometry)!=null&&e.src&&s(o.geometry.src),(i=(n=o.style)==null?void 0:n.fill)!=null&&i.src&&s(o.style.fill.src)})}decompressStrings(t){if(t&&typeof t=="object"&&!Array.isArray(t)){if(t._compressed&&t._data)try{const o=ws.decompressFromBase64(t._data);if(o)return o}catch(o){return console.error("[ExodeUI] Failed to decompress string:",o),t._data}const s={};for(const[o,e]of Object.entries(t))s[o]=this.decompressStrings(e);return s}return Array.isArray(t)?t.map(s=>this.decompressStrings(s)):t}reset(){if(!this.artboard)return;if(this.objectStates.clear(),this.objectVelocities.clear(),this.currentTime=0,this.inputs.clear(),this.inputNameMap.clear(),this.layerStates.clear(),this.logicNodeValues.clear(),this.justFiredTriggers.clear(),this.inputs.set("mouseX",0),this.inputs.set("mouseY",0),this.inputs.set("scrollX",0),this.inputs.set("scrollY",0),this.inputs.set("isMouseDown",!1),this.physicsEngine&&(this.physicsEngine.destroy(),this.physicsEngine=null),this._layoutAnimCache.clear(),this._springChainState.clear(),this._emitterPools.clear(),this.artboard.objects.forEach(s=>{var i,a,r,l,d,p,g;const o=s.width??((i=s.geometry)==null?void 0:i.width)??0,e=s.height??((a=s.geometry)==null?void 0:a.height)??0,n=s.cornerRadius??s.corner_radius??((r=s.geometry)==null?void 0:r.corner_radius)??((l=s.geometry)==null?void 0:l.cornerRadius)??0;this.objectStates.set(s.id,{...s.transform||{},x:((d=s.transform)==null?void 0:d.x)??s.x??0,y:((p=s.transform)==null?void 0:p.y)??s.y??0,width:o,height:e,cornerRadius:n,corner_radius:n,clipContent:s.clipContent??!1,autoLayout:s.autoLayout?JSON.parse(JSON.stringify(s.autoLayout)):void 0,layoutProps:s.layoutProps?JSON.parse(JSON.stringify(s.layoutProps)):void 0,opacity:((g=s.transform)==null?void 0:g.opacity)!==void 0?s.transform.opacity:s.opacity!==void 0?s.opacity:100,visible:s.visible!==void 0?s.visible:s.isVisible!==void 0?s.isVisible:!0,blendMode:s.blendMode||"Normal",style:JSON.parse(JSON.stringify(s.style||{})),geometry:JSON.parse(JSON.stringify(s.geometry||{})),options:s.options?JSON.parse(JSON.stringify(s.options)):{},masks:s.masks?JSON.parse(JSON.stringify(s.masks)):[],zIndex:s.zIndex!==void 0?s.zIndex:void 0})}),this.artboard.objects.some(s=>{var o;return(o=s.physics)==null?void 0:o.enabled})){this.physicsEngine=new os;const s=this.artboard.physics?{x:this.artboard.physics.gravity.x,y:this.artboard.physics.gravity.y}:{x:0,y:1};this.physicsEngine.init(s).then(()=>{var o;this.physicsEngine&&((o=this.artboard)==null||o.objects.forEach(e=>{var n,i;if((n=e.physics)!=null&&n.enabled&&e.type==="Shape"){const a=this.objectStates.get(e.id);if(!a)return;const r=e.geometry.width||100,l=e.geometry.height||100;this.physicsEngine.createBody({id:e.id,type:((i=e.geometry)==null?void 0:i.type)||"Rectangle",x:a.x,y:a.y,width:r,height:l,rotation:a.rotation*(Math.PI/180),isStatic:e.physics.bodyType==="Static",mass:e.physics.mass,friction:e.physics.friction,restitution:e.physics.restitution,frictionAir:e.physics.frictionAir,density:e.physics.density,isSensor:e.physics.isSensor})}}))})}this.artboard.stateVariables&&this.artboard.stateVariables.forEach(s=>{var n,i;let o=s.value;if(s.type==="RandomNumber"||s.type==="random_number"||s.min!==void 0&&s.max!==void 0&&((n=s.type)!=null&&n.toLowerCase().includes("random"))){const a=s.min??0,r=s.max??100;o=Math.random()*(r-a)+a}else if(s.type==="RandomColor"||s.type==="random_color"||s.minAlpha!==void 0&&((i=s.type)!=null&&i.toLowerCase().includes("random"))){const a=Math.floor(Math.random()*256),r=Math.floor(Math.random()*256),l=Math.floor(Math.random()*256),d=s.minAlpha??0,p=s.maxAlpha??1,g=(Math.random()*(p-d)+d).toFixed(2);o=`rgba(${a}, ${r}, ${l}, ${g})`}this.inputs.set(s.id,o);const e=this.inputNameMap.get(s.name)||[];e.includes(s.id)||e.push(s.id),this.inputNameMap.set(s.name,e)}),this.artboard.stateMachine&&(this.activeStateMachine=this.artboard.stateMachine,this.activeStateMachine.inputs.forEach(s=>{this.inputs.set(s.id,s.value.value);const o=this.inputNameMap.get(s.name)||[];o.push(s.id),this.inputNameMap.set(s.name,o)}),this.activeStateMachine.layers.forEach(s=>{let o=s.states.find(e=>e.id===s.entryStateId);!o&&s.states.length>0&&(console.warn(`[ExodeUI] Invalid entryStateId "${s.entryStateId}" in layer "${s.name}". Falling back to first state.`),o=s.states[0]),o&&this.enterStates(s.name,[o.id])}),this.evaluateTransitions()),this.initGlobalAnimationTriggers(),this.updateAutoLayout(!0),this.loadFonts()}updateAutoLayout(t=!1){var n;if(!this.artboard)return;const s=new Map;this.artboard.objects.forEach(i=>s.set(i.id,i));const o=.15,e=i=>{i.forEach(a=>{const r=this.objectStates.get(a.id);if(r){const l=Math.abs(r.x-a.x),d=Math.abs(r.y-a.y);!t&&(l>20||d>20)?(r.x+=(a.x-r.x)*o,r.y+=(a.y-r.y)*o):(r.x=a.x,r.y=a.y),a.width!==void 0&&(r.width=a.width),a.height!==void 0&&(r.height=a.height)}})};if((n=this.artboard.autoLayout)!=null&&n.enabled){const i=this.artboard.objects.filter(r=>!r.parentId),a=ns(this.artboard,i,r=>this.objectStates.get(r));e(a.childUpdates)}this.artboard.objects.forEach(i=>{var a;if(i.type==="Frame"&&((a=i.autoLayout)!=null&&a.enabled)&&i.children&&i.children.length>0){const r=i.children.map(p=>s.get(p)).filter(p=>!!p),l=this.objectStates.get(i.id);if(!l)return;const d=ns(l,r,p=>this.objectStates.get(p));d.frameWidth!==void 0&&(l.width=d.frameWidth),d.frameHeight!==void 0&&(l.height=d.frameHeight),e(d.childUpdates)}})}loadFonts(){if(!this.artboard)return;const t=new Set;if(this.artboard.objects.forEach(i=>{i.geometry&&i.geometry.type==="Text"&&i.geometry.fontFamily&&t.add(i.geometry.fontFamily)}),this.artboard.animations.forEach(i=>{i.tracks.forEach(a=>{(a.property==="geometry.fontFamily"||a.property==="fontFamily")&&a.keyframes.forEach(r=>{r.value&&typeof r.value=="string"&&t.add(r.value)})})}),t.size===0)return;let s="";t.forEach(i=>{const a=i.replace(/ /g,"+");s+=`&family=${a}:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900`});const o="exodeui-google-fonts",e="exodeui-fontshare-fonts";if(s.length>0){const i=`https://fonts.googleapis.com/css2?display=swap${s}`;let a=document.getElementById(o);a||(a=document.createElement("link"),a.id=o,a.rel="stylesheet",document.head.appendChild(a)),a.href!==i&&(a.href=i)}const n=[];if(t.forEach(i=>{i.toLowerCase().includes("clash display")&&n.push("clash-display@200,300,400,500,600,700")}),n.length>0){const i=`https://api.fontshare.com/v2/css?f[]=${n.join("&f[]=")}&display=swap`;let a=document.getElementById(e);a||(a=document.createElement("link"),a.id=e,a.rel="stylesheet",document.head.appendChild(a)),a.href!==i&&(a.href=i)}document.fonts&&document.fonts.ready&&document.fonts.ready.then(()=>{this.pretextCache.clear(),this.advance(0)})}enterStates(t,s){var i;if(s.length===0)return;const o=this.layerStates.get(t);if(o&&o.currentStateIds.length===s.length&&s.every(r=>o.currentStateIds.includes(r))&&this.justFiredTriggers.size===0)return;const e=[];let n=0;if(this.artboard&&this.activeStateMachine){const a=this.activeStateMachine.layers.find(r=>r.name===t);if(a)for(const r of s){const l=a.states.find(d=>d.id===r);if(l)if(l.isBlendState&&l.blendAnimations&&l.blendAnimations.length>0)e.push({animation:null,state:l}),l.blendAnimations.forEach(d=>{const p=this.artboard.animations.find(g=>g.id===d.animationId);p&&(n=Math.max(n,this.getAnimationDuration(p)))});else{let d=null;l.animationId&&(d=this.artboard.animations.find(p=>p.id===l.animationId)||null),d||(d=this.artboard.animations.find(p=>{var g,u;return p.name===l.name||p.id===l.name||(l.name==="Entry"||l.id==="entry")&&(((g=p.name)==null?void 0:g.toLowerCase())==="onload"||((u=p.name)==null?void 0:u.toLowerCase())==="intro")})||null),d&&((i=this.artboard.animationFlow)!=null&&i.some(g=>(g.trigger==="on_load"||g.trigger==="after_delay")&&g.targetAnimationId===(d==null?void 0:d.id))||(e.push({animation:d,state:l}),n=Math.max(n,this.getAnimationDuration(d))))}}}this.layerStates.set(t,{currentStateIds:s,animations:e,time:0,duration:n})}setInputBool(t,s){this.updateInput(t,s)}setInputNumber(t,s){this.updateInput(t,s)}fireTrigger(t){this.updateInput(t,!0)}setInputText(t,s){this.updateInput(t,s)}setInputNumberArray(t,s){this.updateInput(t,s)}setInputStringArray(t,s){this.updateInput(t,s)}updateObjectProperty(t,s,o){const e=this.objectStates.get(t);if(e)if(s.includes(".")||s.includes("[")){const n=s.replace(/\[(\d+)\]/g,".$1").split(".");let i=e;for(let a=0;a<n.length-1;a++){if(typeof i[n[a]]!="object"||i[n[a]]===null){const r=n[a+1],l=!isNaN(Number(r));i[n[a]]=l?[]:{}}i=i[n[a]]}i[n[n.length-1]]=o}else e[s]=o}updateInput(t,s){var l,d,p,g,u;let o;if(this.inputs.has(t)){const f=(l=this.activeStateMachine)==null?void 0:l.inputs.find(h=>h.id===t);f&&typeof f.value=="object"&&(o=f.value.type)}else{const f=this.inputNameMap.get(t);if(f&&f.length>0){const h=(d=this.activeStateMachine)==null?void 0:d.inputs.find(m=>m.id===f[0]);h&&typeof h.value=="object"&&(o=h.value.type)}}let e=s;o==="Trigger"&&(s===1?e=!0:s===0&&(e=!1));const n=(g=(p=this.artboard)==null?void 0:p.stateVariables)==null?void 0:g.find(f=>f.id===t||f.name===t);if(n&&(n.type==="RandomNumber"||n.type==="RandomColor"||n.type&&String(n.type).toLowerCase().includes("random"))){if(n.type==="RandomNumber"||n.type==="random_number"||n.min!==void 0&&n.max!==void 0){const f=n.min??0,h=n.max??100;e=Math.random()*(h-f)+f}else if(n.type==="RandomColor"||n.type==="random_color"||n.minAlpha!==void 0){const f=Math.floor(Math.random()*256),h=Math.floor(Math.random()*256),m=Math.floor(Math.random()*256),b=n.minAlpha??0,c=n.maxAlpha??1,S=(Math.random()*(c-b)+b).toFixed(2);e=`rgba(${f}, ${h}, ${m}, ${S})`}}let i=!1;this.inputs.has(t)&&(this.setInternalInput(t,e),i=!0);const a=this.inputNameMap.get(t);a&&a.length>0&&(a.forEach(f=>this.setInternalInput(f,e)),i=!0),i||this.setInternalInput(t,e),o==="Trigger"&&e===!0&&(this.justFiredTriggers.add(t),a&&a.forEach(f=>this.justFiredTriggers.add(f)));let r=null;if(Array.isArray(e))r=e;else if(typeof e=="string"&&e.trim().startsWith("[")&&e.trim().endsWith("]"))try{const f=JSON.parse(e);Array.isArray(f)&&(r=f)}catch{}r&&((u=this.artboard)==null||u.objects.forEach(f=>{var b;const h=(b=f.options)==null?void 0:b.dataInputId;if(f.inputId===t||f.name===t||h===t||a&&(a.includes(f.inputId)||h&&a.includes(h))){let c=this.objectStates.get(f.id);c&&!c.options&&(c.options=JSON.parse(JSON.stringify(f.options||{}))),c&&c.options&&(this.isListViewObject(f)?c.options.items=r:(f.type==="Dropdown"||f.variant==="dropdown")&&(c.options.optionsList=r)),f.options&&(this.isListViewObject(f)?f.options.items=r:(f.type==="Dropdown"||f.variant==="dropdown")&&(f.options.optionsList=r))}})),this.evaluateTransitions(),this.evaluateVariableTriggers(t,e)}evaluateVariableTriggers(t,s){if(!this.artboard)return;const o=this.artboard.animationFlow||[],e=this.inputNameMap.get(t);o.forEach(n=>{if(n.trigger==="variable"&&n.conditionVariableId&&n.targetAnimationId&&(n.conditionVariableId===t||e&&e.includes(n.conditionVariableId))){const a=n.conditionOperator||"IsTrue",r=n.conditionValue;let l=!1;switch(a){case"Equal":case"==":l=s==r;break;case"NotEqual":case"!=":l=s!=r;break;case"GreaterThan":case">":l=s>r;break;case"LessThan":case"<":l=s<r;break;case"GreaterEqual":case">=":l=s>=r;break;case"LessEqual":case"<=":l=s<=r;break;case"IsTrue":l=!!s;break;case"IsFalse":l=!s;break}if(l){const d=n.delay||0;d<=0?this.triggerGlobalAnimation(n.targetAnimationId,n.subAnimationIds,n.loop,n.id):setTimeout(()=>this.triggerGlobalAnimation(n.targetAnimationId,n.subAnimationIds,n.loop,n.id),d)}}})}evaluateTransitions(){this.activeStateMachine&&(this.activeStateMachine.layers.forEach(t=>{const s=this.layerStates.get(t.name);if(!s||s.currentStateIds.length===0)return;const o=[];let e=!1;for(const n of s.currentStateIds){const i=t.states.find(r=>r.id===n);if(!i)continue;let a=!1;for(const r of i.transitions||[])this.checkConditions(r.conditions)&&(o.push(r.targetStateId),a=!0,e=!0);a||o.push(n)}if(!e){const n=this.findGlobalTransition(t,s.currentStateIds);n&&(o.length=0,o.push(n.targetStateId),e=!0,n.conditions&&(n.conditions||[]).forEach(i=>{var r;const a=(r=this.activeStateMachine)==null?void 0:r.inputs.find(l=>l.id===i.inputId);a&&typeof a.value=="object"&&a.value.type==="Trigger"&&this.setInternalInput(i.inputId,!1)}))}if(e){const n=Array.from(new Set(o));this.enterStates(t.name,n)}}),this.justFiredTriggers.size>0&&(this.justFiredTriggers.forEach(t=>{var o,e;this.setInternalInput(t,!1);const s=(o=this.activeStateMachine)==null?void 0:o.inputs.find(n=>n.id===t);s&&this.inputNameMap.has(s.name)&&((e=this.inputNameMap.get(s.name))==null||e.forEach(n=>this.setInternalInput(n,!1)))}),this.justFiredTriggers.clear()))}findGlobalTransition(t,s){for(const o of t.states)if(!(s.includes(o.id)&&this.justFiredTriggers.size===0)){for(const n of o.transitions||[])if(!(s.includes(n.targetStateId)&&this.justFiredTriggers.size===0)&&this.checkConditions(n.conditions))return n}return null}checkConditions(t){return!t||t.length===0?!0:t.every(s=>{const o=s.inputId,e=s.op;let n=s.value;const i=this.evaluateLogicTree(o);if(i===void 0)return this.log(`[Engine] Condition Check Failed: Input ${o} is undefined`),!1;typeof i=="boolean"?n==="true"||n==="1"||n===1?n=!0:(n==="false"||n==="0"||n===0)&&(n=!1):typeof i=="number"&&typeof n=="string"&&(n=parseFloat(n));let a=!1;switch(e){case"Equal":case"==":a=i==n;break;case"NotEqual":case"!=":a=i!=n;break;case"GreaterThan":case">":a=i>n;break;case"LessThan":case"<":a=i<n;break;case"GreaterEqual":case">=":a=i>=n;break;case"LessEqual":case"<=":a=i<=n;break;case"IsTrue":a=!!i;break;case"IsFalse":a=!i;break;default:a=!1}return a||this.justFiredTriggers.has(o),a})}evaluateLogicTree(t,s=null,o=new Set){var a,r,l,d,p,g;if(o.has(t))return this.inputs.get(t)??this.logicNodeValues.get(t)??0;o.add(t);const e=(r=(a=this.activeStateMachine)==null?void 0:a.logicNodes)==null?void 0:r.find(u=>u.id===t);if(e){const u=(h,m)=>{const b=e.inputs.find(c=>c.id===h);return b?b.sourceId?this.evaluateLogicTree(b.sourceId,b.sourceHandleId,o):b.value!==void 0?b.value:m:m};let f=0;switch(e.op){case Ht.AND:f=u("a",!1)&&u("b",!1);break;case Ht.OR:f=u("a",!1)||u("b",!1);break;case Ht.NOT:f=!u("in",!1);break;case Ht.XOR:f=!!u("a",!1)!=!!u("b",!1);break;case Ht.OBJECT:f=e.name;break;case Ht.PROPERTY:case Ht.GET_PROPERTY:{const h=u("id","");if(!h){f=0;break}const m=e.name;if(!m||m==="GET_PROPERTY"||m==="PROPERTY"){f=0;break}const b=this.objectStates.get(h);if(!b){f=0;break}m in b?f=b[m]:f=this.resolvePath(b,m);break}case Ht.SET_PROPERTY:{const h=u("id",""),m=u("value",void 0);if(!h||m===void 0){f=0;break}const b=e.name;if(!b||b==="SET_PROPERTY"){f=0;break}const c=this.objectStates.get(h);if(!c){f=0;break}if(["x","y","rotation","scale_x","scale_y","opacity","width","height","cornerRadius","visible","zIndex"].includes(b))c[b]=m,f=m;else{const v=b.replace(/\[(\d+)\]/g,".$1").split(".");let C=c;for(let I=0;I<v.length-1;I++){const k=v[I],O=v[I+1];C[k]===void 0&&(C[k]=isNaN(Number(O))?{}:[]),C=C[k]}const w=v[v.length-1];C[w]=m,f=m}break}case Ht.ADD:f=u("a",0)+u("b",0);break;case Ht.SUB:f=u("a",0)-u("b",0);break;case Ht.MUL:f=u("a",0)*u("b",0);break;case Ht.DIV:{const h=u("b",1);f=h===0?0:u("a",0)/h;break}case Ht.MOD:f=u("a",0)%u("b",1);break;case Ht.POW:f=Math.pow(u("a",0),u("b",1));break;case Ht.ABS:f=Math.abs(u("in",0));break;case Ht.ROUND:f=Math.round(u("in",0));break;case Ht.FLOOR:f=Math.floor(u("in",0));break;case Ht.CEIL:f=Math.ceil(u("in",0));break;case Ht.SIN:f=Math.sin(u("in",0));break;case Ht.COS:f=Math.cos(u("in",0));break;case Ht.TAN:f=Math.tan(u("in",0));break;case Ht.CLAMP:{const h=u("in",0),m=u("min",0),b=u("max",1);f=Math.max(m,Math.min(b,h));break}case Ht.REMAP:{const h=u("in",0),m=u("inMin",0),b=u("inMax",100),c=u("outMin",0),S=u("outMax",1);f=b===m?c:c+(h-m)*(S-c)/(b-m);break}case Ht.EQ:f=u("a",0)==u("b",0);break;case Ht.NEQ:f=u("a",0)!=u("b",0);break;case Ht.GT:f=u("a",0)>u("b",0);break;case Ht.LT:f=u("a",0)<u("b",0);break;case Ht.GTE:f=u("a",0)>=u("b",0);break;case Ht.LTE:f=u("a",0)<=u("b",0);break;case Ht.IF_ELSE:f=u("cond",!1)?u("then",0):u("else",0);break;case Ht.VALUE:f=e.value!==void 0?e.value:0;break;case Ht.INPUT:f=this.inputs.get(e.name)??0;break;case Ht.LOG:{const h=u("in","");this.debugLog(`[User Logic] ${h}`),f=h;break}case Ht.SCROLL_X:f=this.inputs.get("scrollX")??0;break;case Ht.SCROLL_Y:f=this.inputs.get("scrollY")??0;break;case Ht.MOUSE_X:f=this.inputs.get("mouseX")??0;break;case Ht.MOUSE_Y:f=this.inputs.get("mouseY")??0;break;case Ht.IS_MOUSE_DOWN:f=this.inputs.get("isMouseDown")??!1;break;case Ht.EFFECTOR:{const h=u("id",""),m=u("intensity",1),b=u("trigger",!0);if(!h||!b){f=0;break}const c=e.name;if(!c){f=0;break}const S=this.objectStates.get(h);if(!S){f=0;break}if(["glitch","halftone","pixelate","noise","acid_gradient","acid_rave","shimmer"].includes(c))S.style||(S.style={}),S.style.artEffect={enabled:!0,type:c,intensity:m},f=1;else{S.behaviors||(S.behaviors=[]);let C=S.behaviors.find(w=>w.type===c);C?(C.enabled=!0,C.settings||(C.settings={}),C.settings.intensity=m):(C={id:`eff_${Date.now()}_${c}`,type:c,enabled:!0,sensors:[],settings:{intensity:m}},S.behaviors.push(C)),f=1}break}case Ht.MONITOR:{f=u("in",0);break}case Ht.SPRING_PULL:{const h=u("objectId",""),m=u("forceX",0),b=u("forceY",0);h&&((l=this.artboard)==null||l.objects.forEach(c=>{c.behaviors&&c.behaviors.forEach(S=>{var v;if(S.type===it.SpringChain&&((v=S.settings)!=null&&v.connections)&&(S.settings.connections.some(w=>w.targetId===h)||c.id===h)){this._springChainState.has(c.id)||this._springChainState.set(c.id,new Map);const w=this._springChainState.get(c.id);if(!w.has(h)){const k=this.objectStates.get(h);w.set(h,{x:(k==null?void 0:k.x)??0,y:(k==null?void 0:k.y)??0,vx:0,vy:0})}const I=w.get(h);I&&(I.vx+=m,I.vy+=b)}})})),f=1;break}case Ht.SPRING_SETTLE:{const h=u("objectId","");let m=!0;if(h){const b=u("threshold",1);this._springChainState.forEach(c=>{const S=c.get(h);S&&(Math.abs(S.vx)>b||Math.abs(S.vy)>b)&&(m=!1)})}f=m;break}case Ht.EMIT:{const h=u("objectId",""),m=u("count",20);h&&((d=this.artboard)==null||d.objects.forEach(b=>{b.behaviors&&b.behaviors.forEach(c=>{c.type===it.ParticleEmitter&&b.id===h&&(c._pendingBurst=(c._pendingBurst||0)+m)})})),f=1;break}default:f=0;break}if(this.logicNodeValues.set(t,f),e.op===Ht.DELAY){const h=u("delay",0),m=u("in",0);let b=this.logicNodeState.get(t);for(b||(b={queue:[]},this.logicNodeState.set(t,b)),b.queue.push({time:this.currentTime+h,value:m});b.queue.length>0&&b.queue[0].time<=this.currentTime;)b.lastValue=b.queue.shift().value;f=b.lastValue??0}return f}const n=(p=this.activeStateMachine)==null?void 0:p.inputs.find(u=>u.id===t||u.name===t);if(n&&n.sourceId&&!o.has(n.sourceId)){const u=this.evaluateLogicTree(n.sourceId,n.sourceHandleId,o);return this.inputs.set(n.id,u),u}let i=this.inputs.get(t)??(n?this.inputs.get(n.id):void 0);if((this.justFiredTriggers.has(t)||n&&this.justFiredTriggers.has(n.id))&&(i=!0),s&&i!==void 0){const u=(g=this.activeStateMachine)==null?void 0:g.inputs.find(f=>f.id===t);if(u&&u.value.type==="Number"&&typeof i=="number"){const f=u.value.defaultValue??u.value.value;if(s==="source-greater")return i>f;if(s==="source-less")return i<f;if(s==="source-equal")return i===f}if(s==="source-true")return i===!0;if(s==="source-false")return i===!1;if(s==="source-fire")return this.justFiredTriggers.has(t)}return i!==void 0?i:0}runLogicNodes(){!this.activeStateMachine||!this.activeStateMachine.logicNodes||this.activeStateMachine.logicNodes.forEach(t=>{(t.op===Ht.SET_PROPERTY||t.op===Ht.EFFECTOR)&&this.evaluateLogicTree(t.id)})}resolvePath(t,s){const o=s.replace(/\[(\d+)\]/g,".$1").split(".");let e=t;for(const n of o)if(e&&typeof e=="object"&&n in e)e=e[n];else return;return e}processLogicProperties(){!this.artboard||!this.artboard.objects||this.artboard.objects.forEach(t=>{const s=t.logicProperties;if(s&&s.length>0){const o=this.objectStates.get(t.id);if(!o)return;s.forEach(e=>{let n;if(e.valueType==="variable"?n=this.getInputValue(e.variableId):e.valueType==="constant"&&(n=e.value),n!==void 0){const i=e.name;if(["x","y","rotation","scale_x","scale_y","opacity","width","height","cornerRadius","visible","zIndex"].includes(i))o[i]=n;else{const r=i.replace(/\[(\d+)\]/g,".$1").split(".");let l=o;for(let p=0;p<r.length-1;p++){const g=r[p],u=r[p+1];l[g]===void 0&&(l[g]=isNaN(Number(u))?{}:[]),l=l[g]}const d=r[r.length-1];l[d]=n}}})}})}seek(t){this.artboard&&(this.currentTime=t,this.layerStates.forEach(s=>{s.time=t,s.time>(s.duration||0)&&(s.animations.some(e=>{var n;return((n=e.state)==null?void 0:n.loop)===!0})?s.time%=s.duration||1:s.time=s.duration)}),this.advance(0))}advance(t){if(!this.artboard)return;this.currentTime+=t,this.isMouseDown&&this.pointerDownTimes.forEach((o,e)=>{e&&this.currentTime-o>=.5&&(this.log(`[Engine] onHold detected for ${e}`),this.fireEventForObject(e,"onHold"),this.pointerDownTimes.delete(e))}),this.frameCount++,this.physicsEngine&&(this.physicsEngine.step(t),this.artboard.objects.forEach(o=>{var e;if((e=o.physics)!=null&&e.enabled){const n=this.physicsEngine.getPosition(o.id),i=this.physicsEngine.getRotation(o.id),a=this.objectStates.get(o.id);a&&n!==null&&i!==null&&(a.x=n.x,a.y=n.y,a.rotation=i*(180/Math.PI))}})),this.activeStateMachine&&(this.runLogicNodes(),this.evaluateTransitions()),this.processLogicProperties();const s=[];this.layerStates.forEach((o,e)=>{if(o.animations.length>0){if(o.time+=t,this.frameCount%240===0&&this.debugLog(`Advancing Layer time: ${o.time.toFixed(3)} / ${o.duration.toFixed(3)}`),o.time>o.duration)if(o.animations.some(i=>{var a;return((a=i.state)==null?void 0:a.loop)===!0}))o.time%=o.duration;else{const i=o.time<o.duration+.1;o.time=o.duration,i&&(e.startsWith("global_")&&console.log(`[Engine] GLOBAL layer done: ${e}, duration=${o.duration}, currentStateIds=${JSON.stringify(o.currentStateIds)}, ruleId=${o.ruleId}`),o.currentStateIds.length>0&&this.handleAnimationFinished(o.currentStateIds[0],o.ruleId),e.startsWith("global_")&&s.push(e))}o.animations.forEach(n=>{var i;(i=n.state)!=null&&i.isBlendState&&n.state.blendAnimations?this.applyBlendState(n.state,o.time):n.animation&&this.applyAnimation(n.animation,o.time,n.filterObjectIds)})}}),s.forEach(o=>{this.layerStates.delete(o),this.debugLog(`[Engine] Cleaned up completed global layer: ${o}`)}),this.solveConstraints(t),this.solveBehaviors(t),this.activeTriggers.forEach((o,e)=>{var n,i,a,r,l,d,p;if(o.phase==="entry")o.time+=t,o.time>=this.getAnimationDuration(o.animation)&&((a=(i=(n=this.artboard)==null?void 0:n.objects.find(g=>g.id===e))==null?void 0:i.triggers)==null||a.find(g=>g.id===o.triggerId),o.phase="hold",o.elapsedHold=0,o.time=this.getAnimationDuration(o.animation)),this.applyAnimation(o.animation,o.time,o.filterObjectIds||o.filterObjectId||void 0);else if(o.phase==="hold"){const g=(d=(l=(r=this.artboard)==null?void 0:r.objects.find(h=>h.id===e))==null?void 0:l.triggers)==null?void 0:d.find(h=>h.id===o.triggerId),u=(g==null?void 0:g.duration)||0;o.elapsedHold+=t*1e3;let f=o.elapsedHold>=u;if((g==null?void 0:g.eventType)==="hover"&&!this.activeHoverIds.has(e)&&(f=!0),((g==null?void 0:g.eventType)==="onHold"||(g==null?void 0:g.eventType)==="pointerDown")&&!this.isMouseDown&&(f=!0),f)if(g!=null&&g.exitAnimationId){const h=(p=this.artboard)==null?void 0:p.animations.find(m=>m.id===g.exitAnimationId);h?(o.phase="exit",o.animation=h,o.time=0):this.activeTriggers.delete(e)}else this.activeTriggers.delete(e)}else o.phase==="exit"&&(o.time+=t,o.time>=this.getAnimationDuration(o.animation)?this.activeTriggers.delete(e):this.applyAnimation(o.animation,o.time,o.filterObjectIds||o.filterObjectId||void 0))}),this.evaluateContinuousInteractions(t),this.processJoysticks(t),this.activeStateMachine&&this.onLogicUpdate&&this.logicNodeValues.size>0&&this.onLogicUpdate(Object.fromEntries(this.logicNodeValues))}evaluateContinuousInteractions(t){this.artboard&&(this.artboard.objects.forEach(s=>{var e,n,i;const o=(e=s.style)==null?void 0:e.analytics;if(o&&o.isEnabled&&o.triggerType==="visible"){const a=this.objectStates.get(s.id);if(a&&a.visible!==!1){const r=this.getGlobalTransform(s.id),l=(((n=s.geometry)==null?void 0:n.width)||100)*(r.scale_x||1),d=(((i=s.geometry)==null?void 0:i.height)||100)*(r.scale_y||1),p=50,g=r.x+l/2>=-this.canvasWidth/2-p&&r.x-l/2<=this.canvasWidth/2+p&&r.y+d/2>=-this.canvasHeight/2-p&&r.y-d/2<=this.canvasHeight/2+p,u=`analytics_${s.id}`,f=this.wasInView.has(u);g&&!f&&this.fireAnalyticsEvent(s.id,"visible"),g?this.wasInView.add(u):this.wasInView.delete(u)}}}),this.artboard.objects.forEach(s=>{const o=s.interactions||[];o.length!==0&&o.forEach(e=>{const n=e.triggers||[e.event||e.trigger];n&&n.forEach(i=>{var r,l,d;const a=i.toLowerCase();if(a==="on interval"||a==="oninterval"){const p=e.intervalValue||2e3,g=this.periodicTriggerTimes.get(e.id)||0;this.currentTime*1e3-g>=p&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(s.id,"On Interval"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="on delay"||a==="ondelay"){const p=e.delayValue||1e3;!this.periodicTriggerTimes.has(e.id)&&this.currentTime*1e3>=p&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(s.id,"On Delay"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="scroll into view"||a==="scrollintoview"){const p=this.objectStates.get(s.id);if(p&&p.visible!==!1){const g=this.getGlobalTransform(s.id),u=(((r=s.geometry)==null?void 0:r.width)||100)*(g.scale_x||1),f=(((l=s.geometry)==null?void 0:l.height)||100)*(g.scale_y||1),h=50,m=g.x+u/2>=-this.canvasWidth/2-h&&g.x-u/2<=this.canvasWidth/2+h&&g.y+f/2>=-this.canvasHeight/2-h&&g.y-f/2<=this.canvasHeight/2+h,b=this.wasInView.has(s.id);m&&!b&&(!e.conditions||this.checkConditions(e.conditions))&&this.fireEventForObject(s.id,"Scroll Into View"),m?this.wasInView.add(s.id):this.wasInView.delete(s.id)}}if(a==="scroll progress"||a==="scrollprogress"){const p=Math.abs(this.scrollOffset.y)/(((d=this.artboard)==null?void 0:d.height)||1e3),g=this.scrollProgressLastValue.get(e.id)||0;Math.abs(p-g)>.001&&(this.scrollProgressLastValue.set(e.id,p),(e.action==="Set Input"||e.action==="setInput")&&this.updateInput(e.targetInputId,p))}})})}))}solveConstraints(t){this.artboard&&this.artboard.objects.forEach(s=>{if(!s.constraints||s.constraints.length===0)return;const o=this.objectStates.get(s.id);if(!o)return;const e=this.getGlobalTransform(s.id);if(s.constraints.forEach((n,i)=>{var d,p,g,u,f,h,m,b,c;const a=((d=o.constraints)==null?void 0:d[i])||{},r={...n,...a},l=r.strength??1;if(r.type==="Translation"){const S=this.getGlobalTransform(r.targetId);if(S){const v=r.offsetX||0,C=r.offsetY||0,w=S.x+v,I=S.y+C,k=r.useSpring;if(k){const A=this.objectVelocities.get(s.id)||{vx:0,vy:0},D=Math.max(0,Math.min(t,.05)),Y=r.copyX!==!1,B=r.copyY!==!1,R=Y?e.x+(w-e.x)*l:e.x,L=B?e.y+(I-e.y)*l:e.y,{x:$,y:F,vx:X,vy:M}=this.computeSpring(e.x,e.y,A.vx,A.vy,R,L,r,D);Y&&(e.x=$),B&&(e.y=F),this.objectVelocities.set(s.id,{vx:Y?X:0,vy:B?M:0})}else r.copyX!==!1&&(e.x=e.x+(w-e.x)*l),r.copyY!==!1&&(e.y=e.y+(I-e.y)*l);let O=!1,T=!1;if((p=r.limitX)!=null&&p.enabled){const A=e.x;e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x)),e.x!==A&&(O=!0)}if((g=r.limitY)!=null&&g.enabled){const A=e.y;e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)),e.y!==A&&(T=!0)}if((O||T)&&k){const A=this.objectVelocities.get(s.id)||{vx:0,vy:0};this.objectVelocities.set(s.id,{vx:O?0:A.vx,vy:T?0:A.vy})}}}else if(r.type==="Rotation"){const S=this.getGlobalTransform(r.targetId);if(S){let C=(S.rotation+(r.offset||0)-e.rotation)%360;C>180&&(C-=360),C<-180&&(C+=360),e.rotation=e.rotation+C*l}}else if(r.type==="Scale"){const S=this.getGlobalTransform(r.targetId);S&&(r.copyX&&(e.scale_x=e.scale_x+(S.scale_x-e.scale_x)*l),r.copyY&&(e.scale_y=e.scale_y+(S.scale_y-e.scale_y)*l))}else if(r.type==="Transform"){const S=this.getGlobalTransform(r.targetId);if(S){e.x=e.x+(S.x-e.x)*l,e.y=e.y+(S.y-e.y)*l;let v=(S.rotation-e.rotation)%360;v>180&&(v-=360),v<-180&&(v+=360),e.rotation=e.rotation+v*l,e.scale_x=e.scale_x+(S.scale_x-e.scale_x)*l,e.scale_y=e.scale_y+(S.scale_y-e.scale_y)*l}}else if(r.type==="FollowPointer"){const S=((u=this._lastPointerPos)==null?void 0:u.x)??e.x,v=((f=this._lastPointerPos)==null?void 0:f.y)??e.y,C=r.useSpring;if(C){const I=this.objectVelocities.get(s.id)||{vx:0,vy:0},{x:k,y:O,vx:T,vy:A}=this.computeSpring(e.x,e.y,I.vx,I.vy,S,v,r,t);e.x=k,e.y=O,this.objectVelocities.set(s.id,{vx:T,vy:A})}else e.x=e.x+(S-e.x)*l,e.y=e.y+(v-e.y)*l;let w=!1;if((h=r.limitX)!=null&&h.enabled){const I=e.x;e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x)),e.x!==I&&(w=!0)}if((m=r.limitY)!=null&&m.enabled){const I=e.y;e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)),e.y!==I&&(w=!0)}w&&C&&this.objectVelocities.set(s.id,{vx:0,vy:0})}else if(r.type==="Distance"){const S=this.getGlobalTransform(r.targetId);if(S){const v=e.x-S.x,C=e.y-S.y,w=Math.sqrt(v*v+C*C),I=r.distance||0;let k=w;switch(r.mode){case"exact":k=I;break;case"minimum":k=Math.max(I,w);break;case"maximum":k=Math.min(I,w);break;case"clamped":k=Math.max(0,Math.min(I,w));break}if(w>0){const O=e.x===S.x&&e.y===S.y?1:k/w;e.x=e.x+(S.x+v*O-e.x)*l,e.y=e.y+(S.y+C*O-e.y)*l}}}else if(r.type==="FollowPath"){const S=(b=this.artboard)==null?void 0:b.objects.find(v=>v.id===r.targetId);if(S){const v=this.getGlobalTransform(S.id);if(v){let C=S.geometry;if(S.type==="Frame"||S.type==="Group"||!C||C.type!=="Path"&&C.type!=="Ellipse"&&C.type!=="Rectangle"){const _=(c=this.artboard)==null?void 0:c.objects.find(V=>V.parentId===S.id&&V.type==="Shape"&&V.geometry&&(V.geometry.type==="Path"||V.geometry.type==="Ellipse"||V.geometry.type==="Rectangle"));_&&(C=_.geometry)}if(!C)return;const w=Math.max(0,Math.min(1,(r.distance||0)/100)),I=v.width||C.width||0,k=v.height||C.height||0,O=this.getPointOnPath(C,I,k,w),T=v.rotation*Math.PI/180,A=Math.cos(T),D=Math.sin(T),Y=O.x*v.scale_x*A-O.y*v.scale_y*D,B=O.x*v.scale_x*D+O.y*v.scale_y*A;let R=v.rotation+(r.offsetRotation||0);if(r.orient){const _=Math.cos(O.angle),V=Math.sin(O.angle),G=_*v.scale_x*A-V*v.scale_y*D,x=_*v.scale_x*D+V*v.scale_y*A;R=Math.atan2(x,G)*180/Math.PI+(r.offsetRotation||0)}const L=R*Math.PI/180,$=Math.cos(L),F=Math.sin(L),X=(r.offsetX||0)*$-(r.offsetY||0)*F,M=(r.offsetX||0)*F+(r.offsetY||0)*$,E=v.x+Y+X,P=v.y+B+M;if(e.x=e.x+(E-e.x)*l,e.y=e.y+(P-e.y)*l,r.orient){let _=(R-e.rotation)%360;_>180&&(_-=360),_<-180&&(_+=360),e.rotation=e.rotation+_*l}}}}else if(r.type==="IK"){const S=this.getGlobalTransform(r.targetId);S&&this.solveIK(s,S,r.boneCount||2,l)}}),s.constraints.some(n=>n.type!=="IK")){const n=this.globalToLocal(s.parentId,e);o.x=n.x,o.y=n.y,o.rotation=n.rotation,o.flip_x=n.scale_x<0,o.scale_x=Math.abs(n.scale_x),o.flip_y=n.scale_y<0,o.scale_y=Math.abs(n.scale_y)}})}getGlobalTransform(t){var p,g;const s=this.objectStates.get(t);if(!s)return{x:0,y:0,rotation:0,scale_x:1,scale_y:1};const o=(p=this.artboard)==null?void 0:p.objects.find(u=>u.id===t),e=(o==null?void 0:o.type)==="Bone"?(g=o.geometry)==null?void 0:g.length:void 0;if(!o||!o.parentId)return{x:s.x,y:s.y,rotation:s.rotation,scale_x:(s.scale_x??1)*(s.flip_x?-1:1),scale_y:(s.scale_y??1)*(s.flip_y?-1:1),length:e};const n=this.getGlobalTransform(o.parentId),i=n.rotation*Math.PI/180,a=Math.cos(i),r=Math.sin(i),l=n.x+(s.x*n.scale_x*a-s.y*n.scale_y*r),d=n.y+(s.x*n.scale_x*r+s.y*n.scale_y*a);return{x:l,y:d,rotation:n.rotation+s.rotation,scale_x:n.scale_x*(s.scale_x??1)*(s.flip_x?-1:1),scale_y:n.scale_y*(s.scale_y??1)*(s.flip_y?-1:1),length:e}}globalToLocal(t,s){if(!t)return s;const o=this.getGlobalTransform(t),e=o.scale_x===0?0:1/o.scale_x,n=o.scale_y===0?0:1/o.scale_y,i=-o.rotation*Math.PI/180,a=Math.cos(i),r=Math.sin(i),l=s.x-o.x,d=s.y-o.y,p=(l*a-d*r)*e,g=(l*r+d*a)*n;return{x:p,y:g,rotation:s.rotation-o.rotation,scale_x:s.scale_x/(o.scale_x||1),scale_y:s.scale_y/(o.scale_y||1)}}solveIK(t,s,o,e){var l;const n=[];let i=t.id;for(let d=0;d<o&&i;d++){const p=(l=this.artboard)==null?void 0:l.objects.find(g=>g.id===i);if(!p)break;n.push({id:i,local:this.objectStates.get(i),global:this.getGlobalTransform(i)}),i=p.parentId}if(n.length<2)return;const a=n.reverse(),r=5;for(let d=0;d<r;d++){const p=this.getGlobalTransform(t.id);for(let g=a.length-2;g>=0;g--){const u=a[g],f=this.getGlobalTransform(u.id),h=p.x-f.x,m=p.y-f.y,b=s.x-f.x,c=s.y-f.y,S=Math.sqrt(h*h+m*m),v=Math.sqrt(b*b+c*c);if(S>.001&&v>.001){const C=Math.atan2(m,h);let I=(Math.atan2(c,b)-C)*180/Math.PI;I*=e;const k=this.objectStates.get(u.id);k&&(k.rotation+=I)}}}}computeSpring(t,s,o,e,n,i,a,r){const l=a.stiffness??100,d=a.damping??10,p=a.mass??1,g=-l*(t-n),u=-l*(s-i),f=-d*o,h=-d*e,m=(g+f)/p,b=(u+h)/p,c=o+m*r,S=e+b*r,v=t+c*r,C=s+S*r;return{x:v,y:C,vx:c,vy:S}}handlePointerInput(t,s,o,e,n){if(!this.artboard)return;const i=this.calculateTransform(e,n,this.artboard.width,this.artboard.height,this.layout.fit,this.layout.alignment),a=(s-i.tx)/i.scaleX,r=(o-i.ty)/i.scaleY;this._prevPointerPos=this._lastPointerPos,this._lastPointerPos={x:a,y:r},this._prevPointerPos&&(this._mouseDelta.dx+=a-this._prevPointerPos.x,this._mouseDelta.dy+=r-this._prevPointerPos.y),this.updateInput("mouseX",a),this.updateInput("mouseY",r),this.handlePointerEvent(t,a,r)}handleScroll(t,s){const o=this.scrollOffset.x,e=this.scrollOffset.y;this.scrollOffset={x:t,y:s},this._totalScroll.x+=t-o,this._totalScroll.y+=s-e,this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}isListViewObject(t){var n;if(!t)return!1;const s=(t.type||"").toLowerCase(),o=(t.variant||"").toLowerCase(),e=(((n=t.geometry)==null?void 0:n.type)||"").toLowerCase();return s==="listview"||o==="listview"||e==="listview"}isLineGraphObject(t){var i;if(!t)return!1;const s=(t.type||"").toLowerCase(),o=(t.variant||"").toLowerCase(),e=(((i=t.geometry)==null?void 0:i.type)||"").toLowerCase(),n=(t.name||"").toLowerCase();return s==="linegraph"||e==="linegraph"||o==="linegraph"||n.includes("linegraph")}isBarChartObject(t){var i;if(!t)return!1;const s=(t.type||"").toLowerCase(),o=(t.variant||"").toLowerCase(),e=(((i=t.geometry)==null?void 0:i.type)||"").toLowerCase(),n=(t.name||"").toLowerCase();return s==="barchart"||e==="barchart"||o==="barchart"||n.includes("barchart")}isPieChartObject(t){var i;if(!t)return!1;const s=(t.type||"").toLowerCase(),o=(t.variant||"").toLowerCase(),e=(((i=t.geometry)==null?void 0:i.type)||"").toLowerCase(),n=(t.name||"").toLowerCase();return s==="piechart"||e==="piechart"||o==="piechart"||n.includes("piechart")}isGraphObject(t){return this.isLineGraphObject(t)||this.isBarChartObject(t)||this.isPieChartObject(t)}isInputBoxObject(t){if(!t)return!1;const s=(t.type||"").toLowerCase(),o=(t.variant||"").toLowerCase(),e=(t.name||"").toLowerCase();return s==="inputbox"||o==="inputbox"||e==="inputbox"}isClickableObject(t){if(!t)return!1;const s=(t.variant||"").toLowerCase(),o=(t.type||"").toLowerCase(),e=["button","toggle","toggle_button","dropdown","slider","checkbox","radiogroup"];return e.includes(s)||e.includes(o)}getLastHoveredObject(){return!this.lastHoveredObjectId||!this.artboard?null:this.artboard.objects.find(t=>t.id===this.lastHoveredObjectId)||null}clearAllGraphHover(){this.graphHoverStates.size>0&&this.graphHoverStates.clear()}getLocalCoords(t,s,o){const e=this.getWorldTransform(t),n=s-e.x,i=o-e.y,a=-(e.rotation||0)*(Math.PI/180),r=Math.cos(a),l=Math.sin(a),d=e.scaleX||1,p=e.scaleY||1;return{x:(n*r-i*l)/(d!==0?d:1),y:(n*l+i*r)/(p!==0?p:1)}}updateGraphHoverFromPointer(t,s,o){var r,l;if(!t||!this.isGraphObject(t)){this.clearAllGraphHover();return}for(const d of Array.from(this.graphHoverStates.keys()))d!==t.id&&this.graphHoverStates.delete(d);const e=this.getLocalCoords(t.id,s,o),n=this.objectStates.get(t.id),i=(n==null?void 0:n.width)??((r=t.geometry)==null?void 0:r.width)??t.width??300,a=(n==null?void 0:n.height)??((l=t.geometry)==null?void 0:l.height)??t.height??180;if(e.x<-i/2||e.x>i/2||e.y<-a/2||e.y>a/2){this.graphHoverStates.delete(t.id);return}if(this.isLineGraphObject(t)){const d=n!=null&&n.geometry?this.deepMerge(t.geometry,n.geometry):t.geometry||{};let p=d.datasets||[];(!p||p.length===0)&&(d.data||d.graphData)&&(p=[{data:d.data||d.graphData}]);let g=0;if(p.forEach(u=>{let f=u.data;if(u.isVarEnabled&&u.inputId){let h=this.inputs.get(u.inputId);if(h===void 0){const m=this.inputNameMap.get(u.inputId);m&&m.length>0&&(h=this.inputs.get(m[0]))}h&&Array.isArray(h)&&(f=h)}f&&f.length>0&&(g=Math.max(g,f.length))}),g>=2){const u=i/(g-1),f=e.x+i/2,h=Math.max(0,Math.min(g-1,Math.round(f/u)));this.graphHoverStates.set(t.id,{hoveredIndex:h,hoverPointer:{x:e.x,y:e.y}})}}else if(this.isBarChartObject(t)){const d=this.barChartRenderedBars.get(t.id)||[];let p=null;for(let g=d.length-1;g>=0;g--){const u=d[g];if(e.x>=u.x&&e.x<=u.x+u.w&&e.y>=u.y&&e.y<=u.y+u.h){p=u;break}}p?this.graphHoverStates.set(t.id,{hoveredCatIdx:p.catIdx,hoveredDsIdx:p.dsIdx,bar:p,hoverPointer:{x:e.x,y:e.y}}):this.graphHoverStates.delete(t.id)}else if(this.isPieChartObject(t)){const d=this.pieChartRenderedSlices.get(t.id)||[];let p=null;for(const g of d){const u=e.x-g.cx,f=e.y-g.cy,h=Math.hypot(u,f);if(h>=g.innerR&&h<=g.outerR){let m=Math.atan2(f,u);const b=w=>(w%(Math.PI*2)+Math.PI*2)%(Math.PI*2),c=b(m),S=b(g.startA),v=b(g.endA);if(S<=v?c>=S&&c<=v:c>=S||c<=v){p=g.index;break}}}p!==null?this.graphHoverStates.set(t.id,{hoveredSliceIndex:p,hoverPointer:{x:e.x,y:e.y}}):this.graphHoverStates.delete(t.id)}}getGraphHoverState(t){return this.graphHoverStates.get(t)}getResolvedListViewItems(t,s){const o=this.objectStates.get(t==null?void 0:t.id),e=s||(o==null?void 0:o.options)||(t==null?void 0:t.options)||{};let n=Array.isArray(e.items)?e.items:typeof e.items=="string"?e.items.split(",").map(i=>i.trim()):[];if(e.isDataVarEnabled&&e.dataInputId){let i=this.inputs.get(e.dataInputId);if(i===void 0){const a=this.inputNameMap.get(e.dataInputId);a&&a.length>0&&(i=this.inputs.get(a[0]))}if(i&&Array.isArray(i))n=i.map(a=>typeof a=="string"?a:String(a));else if(typeof i=="string")try{n=JSON.parse(i).map(a=>String(a))}catch{}}return n}getResolvedDropdownOptions(t,s){const o=this.objectStates.get(t==null?void 0:t.id),e=s||(o==null?void 0:o.options)||(t==null?void 0:t.options)||{};let n=Array.isArray(e.optionsList)?e.optionsList:typeof e.optionsList=="string"?e.optionsList.split(",").map(i=>i.trim()):[];if(e.isDataVarEnabled&&e.dataInputId){let i=this.inputs.get(e.dataInputId);if(i===void 0){const a=this.inputNameMap.get(e.dataInputId);a&&a.length>0&&(i=this.inputs.get(a[0]))}if(i&&Array.isArray(i))n=i.map(a=>typeof a=="string"?a:String(a));else if(typeof i=="string")try{const a=JSON.parse(i);Array.isArray(a)?n=a.map(String):n=i.split(",").map(r=>r.trim())}catch{n=i.split(",").map(a=>a.trim())}}return n}handleWheel(t,s,o,e,n,i){var a,r,l,d;if(o!==void 0&&e!==void 0&&n&&i&&this.artboard){const p=this.calculateTransform(n,i,this.artboard.width,this.artboard.height,this.layout.fit,this.layout.alignment),g=(o-p.tx)/p.scaleX,u=(e-p.ty)/p.scaleY;this._lastPointerPos={x:g,y:u}}if(this._lastPointerPos&&this.artboard){let p=!1;for(let g=this.artboard.objects.length-1;g>=0;g--){const u=this.artboard.objects[g];if(this.isListViewObject(u)){const f=this.objectStates.get(u.id),h=(f==null?void 0:f.options)||u.options||{},m=(f==null?void 0:f.width)??(((a=u.geometry)==null?void 0:a.width)||200),b=(f==null?void 0:f.height)??(((r=u.geometry)==null?void 0:r.height)||300),c=this.getWorldTransform(u.id),S=this._lastPointerPos.x-c.x,v=this._lastPointerPos.y-c.y,C=-c.rotation*(Math.PI/180),w=Math.cos(C),I=Math.sin(C),k=S*w-v*I,O=S*I+v*w,T=c.scaleX||1,A=c.scaleY||1,D=m*Math.abs(T),Y=b*Math.abs(A);if(Math.abs(k)<=D/2&&Math.abs(O)<=Y/2){const B=h.orientation||"vertical";let R=h.scrollOffset||0;if(B==="vertical"?R-=s:R-=Math.abs(t)>Math.abs(s)?t:s,(h.listLayout||"linear")==="circular")h.scrollOffset=R,f&&f.options&&(f.options.scrollOffset=R),u.options&&(u.options.scrollOffset=R);else{const $=this.getResolvedListViewItems(u,h),F=h.itemGap??10,X=h.itemHeight??50,M=h.itemWidth??200,E=typeof h.padding=="number"?h.padding:B==="vertical"?((l=h.padding)==null?void 0:l[0])||0:((d=h.padding)==null?void 0:d[3])||0,_=($.length||0)*(B==="vertical"?X:M)+Math.max(0,($.length||0)-1)*F+E*2,G=Math.max(0,_-(B==="vertical"?b:m));R>0&&(R=0),R<-G&&(R=-G),h.scrollOffset=R,f&&f.options&&(f.options.scrollOffset=R),u.options&&(u.options.scrollOffset=R)}p=!0;break}}}if(p)return}this._totalScroll.x+=t,this._totalScroll.y+=s,this.scrollOffset={x:this._totalScroll.x,y:this._totalScroll.y},this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}handlePointerEvent(t,s,o){var r,l,d,p,g,u,f,h,m,b;if(!this.artboard)return;t==="down"?(this.isMouseDown=!0,this.updateInput("isMouseDown",!0)):(t==="up"||t==="blur")&&(this.isMouseDown=!1,this.updateInput("isMouseDown",!1));let e=null;const n=(c,S)=>{var O;let v=S;S==="click"?v="onClick":S==="down"?v="onPointerDown":S==="up"?v="onPointerUp":S==="blur"&&(v="onPointerLeave");const C=new Set([v]);S==="move"&&(C.add("onPointerEnter").add("hover").add("onPointerLeave").add("blur"),C.add("Drag").add("drag").add("ondrag")),v==="onClick"&&C.add("click"),v==="onPointerDown"&&C.add("pointerDown"),v==="onPointerUp"&&C.add("pointerUp");const w=["button","toggle","toggle_button","dropdown","listview","inputbox","slider","checkbox","radiogroup","joystick","barchart","piechart","linegraph"];if(this.isListViewObject(c)||this.isGraphObject(c)||c.type==="Component"&&c.variant&&w.includes(String(c.variant).toLowerCase())||c.type==="Joystick"||w.includes((O=c.type)==null?void 0:O.toLowerCase()))return!0;const I=c.interactions||[];return!!(I.some(T=>C.has(T.event)||C.has(T.trigger))||I.some(T=>Array.isArray(T.triggers)&&T.triggers.some(A=>C.has(String(A))))||(c.triggers||[]).some(T=>C.has(T.eventType)))};let i=null;for(let c=this.artboard.objects.length-1;c>=0;c--){const S=this.artboard.objects[c],v=this.objectStates.get(S.id);if(v&&v.visible!==!1&&v.opacity>0&&this.hitTest(S,s,o)&&(i||(i=S),n(S,t))){e=S;break}}!e&&i&&(e=i),this.pointerHistory.push({x:s,y:o,time:Date.now()}),this.pointerHistory.length>this.MAX_HISTORY&&this.pointerHistory.shift();const a=(e==null?void 0:e.id)||null;if(t==="move"){if(this.draggingSliderId){const c=this.artboard.objects.find(S=>S.id===this.draggingSliderId);c&&this.updateSliderValueFromPointer(c,s,o);return}if(this.draggingJoystickId){const c=this.artboard.objects.find(S=>S.id===this.draggingJoystickId);c&&this.updateJoystickValueFromPointer(c,s,o);return}if(this.draggingListViewId){const c=this.artboard.objects.find(S=>S.id===this.draggingListViewId);c&&this.updateListViewScrollFromPointer(c);return}if(e&&this.isListViewObject(e)&&this.updateListViewHoverFromPointer(e,s,o),this.updateGraphHoverFromPointer(e,s,o),this.isMouseDown&&this.dragStartPointer&&this.draggingBehaviors.size>0){const c=s-this.dragStartPointer.x,S=o-this.dragStartPointer.y;this.draggingBehaviors.forEach(v=>{const C=this.dragStartPositions.get(v);if(!C)return;const w=this.artboard.objects.find(k=>k.id===v);if(!w||w.parentId)return;const I=this.objectStates.get(v);I&&(I.x=C.x+c,I.y=C.y+S)})}if(this.isMouseDown){const c=this.activeObjectId&&this.artboard.objects.some(v=>v.id===this.activeObjectId)?this.activeObjectId:a,S=c?this.artboard.objects.find(v=>v.id===c):null;S&&n(S,"move")&&this.fireEventForObject(S.id,"Drag")}!this.isMouseDown&&a!==this.lastHoveredObjectId&&(this.log(`[Engine] HOVER CHANGE: ${this.lastHoveredObjectId} -> ${a}`),this.lastHoveredObjectId&&this.fireEventForObject(this.lastHoveredObjectId,"onPointerLeave"),a&&this.fireEventForObject(a,"onPointerEnter"),this.lastHoveredObjectId=a);return}if((t==="up"||t==="blur")&&(this.draggingSliderId=null,this.draggingJoystickId=null,this.draggingListViewId=null,this.draggingListViewIsScrollbar=!1,this.draggingBehaviors.clear(),this.dragStartPointer=null,this.dragStartPositions.clear(),this.pointerDownTimes.delete(a),this.activeObjectId=null,t==="blur"&&this.clearAllGraphHover()),t==="down"&&(this.pointerDownTimes.set(a,this.currentTime),this.activeObjectId=a,e&&((r=e.behaviors)!=null&&r.some(c=>c.type===it.Draggable)||this.hasDragInteraction(e)))){this.draggingBehaviors.add(a);const c=this.objectStates.get(a);c&&(this.dragStartPointer={x:s,y:o},this.dragStartPositions.set(a,{x:c.x??0,y:c.y??0}))}if(t==="move"?(a&&!this.activeHoverIds.has(a)&&this.activeHoverIds.add(a),this.activeHoverIds.forEach(c=>{c!==a&&this.activeHoverIds.delete(c)})):t==="blur"&&this.activeHoverIds.clear(),this.activeDropdownId&&t==="down"){const c=this.artboard.objects.find(S=>S.id===this.activeDropdownId);if(c&&(c.type==="Dropdown"||c.variant==="dropdown")){const S=this.objectStates.get(c.id),v=(S==null?void 0:S.options)||c.options||{},C=c.geometry||{},w=C.width??c.width??200,I=C.height??c.height??40,k=this.getResolvedDropdownOptions(c,v),O=v.itemHeight||32,T=v.listPadding??4,A=k.length*O+T*2,D=this.getWorldTransform(c.id),Y=w*Math.abs(D.scaleX),B=I*Math.abs(D.scaleY),R=D.y+B/2+4,L=Math.abs(s-D.x)<=Y/2,$=o>=R&&o<=R+A*Math.abs(D.scaleY);if(L&&$){const F=Math.abs(D.scaleY),X=o-(R+T*F),M=Math.floor(X/(O*F));if(M>=0&&M<k.length){const E=k[M];v.selectedOption=E,v.isOpen=!1,this.activeDropdownId=null,c.inputId&&this.setInternalInput(c.inputId,E),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"dropdown",property:"selectedOption",value:E})}return}else a!==this.activeDropdownId&&(v.isOpen=!1,this.activeDropdownId=null)}}if(e){let c=e,S=e;for(;S&&S.parentId;){const w=this.artboard.objects.find(I=>I.id===S.parentId);if(w&&w.type==="Component"){c=w;break}S=w}let v=t;if(t==="click"?v="onClick":t==="down"?v="onPointerDown":t==="up"?v="onPointerUp":t==="blur"&&(v="onPointerLeave"),this.fireEventForObject(e.id,v),c!==e&&this.fireEventForObject(c.id,v),c.type==="Component"&&c.variant==="toggle_button"&&t==="down"){const w=this.objectStates.get(c.id),I=(w==null?void 0:w.options)||c.options||{};I.checked=!I.checked,c.inputId&&this.setInternalInput(c.inputId,I.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"toggle_button",property:"checked",value:I.checked}),this.fireEventForObject(c.id,"Toggle"),this.fireEventForObject(c.id,I.checked?"Toggle True":"Toggle False")}if(c.type==="Component"&&c.variant==="toggle"&&t==="down"){const w=this.objectStates.get(c.id),I=(w==null?void 0:w.options)||c.options||{};I.checked=!I.checked,c.inputId&&this.setInternalInput(c.inputId,I.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"toggle",property:"checked",value:I.checked}),this.onToggle&&this.onToggle(c.name,I.checked),this.fireEventForObject(c.id,"Toggle"),this.fireEventForObject(c.id,I.checked?"Toggle True":"Toggle False")}if(c.type==="Component"&&c.variant==="dropdown"&&t==="down"){const w=this.objectStates.get(c.id),I=(w==null?void 0:w.options)||c.options||{},k=!I.isOpen;if(k&&this.activeDropdownId&&this.activeDropdownId!==c.id){const O=this.artboard.objects.find(T=>T.id===this.activeDropdownId);O&&O.options&&(O.options.isOpen=!1)}I.isOpen=k,this.activeDropdownId=k?c.id:null}if((c.type==="Button"||c.type==="Component"&&(c.variant==="button"||(c.name||"").toLowerCase().includes("button")||(c.name||"").toLowerCase().includes("cta")))&&t==="down"&&(this.onButtonClick&&this.onButtonClick(c.name,c.id),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"button",property:"click",value:!0})),this.isListViewObject(c)&&t==="down"){this.draggingListViewId=c.id;const w=this.objectStates.get(c.id),I=(w==null?void 0:w.options)||c.options||{},k=(w==null?void 0:w.width)??(((l=c.geometry)==null?void 0:l.width)||200),O=(w==null?void 0:w.height)??(((d=c.geometry)==null?void 0:d.height)||300),T=I.orientation||"vertical",A=I.scrollbarWidth||4,D=I.showScrollbar!==!1;let Y=!1;if(D&&I.listLayout!=="circular"){const R=this.getWorldTransform(c.id),L=-R.rotation*(Math.PI/180),$=Math.cos(L),F=Math.sin(L),X=s-R.x,M=o-R.y,E=X*$-M*F,P=X*F+M*$,_=R.scaleX||1,V=R.scaleY||1,G=E/_,x=P/V,U=12;T==="vertical"?G>=k/2-A-U&&G<=k/2+U&&(Y=!0):x>=O/2-A-U&&x<=O/2+U&&(Y=!0)}this.draggingListViewIsScrollbar=Y;const B=this.getListViewItemIndexAtPointer(c,s,o);if(B!==null){const R=c.options||{};R.activeItemIndex=B;const L=this.objectStates.get(c.id);L&&L.options&&(L.options.activeItemIndex=B);const F=this.getResolvedListViewItems(c,R)[B],X=typeof F=="string"?F:(F==null?void 0:F.label)||(F==null?void 0:F.value)||B;L&&L.options&&(L.options.selectedValue=X),c.inputId&&this.setInternalInput(c.inputId,X),this.onComponentChange&&(this.onComponentChange({objectId:c.id,componentName:c.name,variant:"listview",property:"activeItemIndex",value:B}),this.onComponentChange({objectId:c.id,componentName:c.name,variant:"listview",property:"selected",value:X}))}}if(c.type==="Component"&&c.variant==="slider"&&t==="down"&&(this.draggingSliderId=c.id,this.updateSliderValueFromPointer(c,s,o)),c.type==="Joystick"||c.type==="Component"&&c.variant==="joystick"){if(t==="down")this.draggingJoystickId=c.id,this.updateJoystickValueFromPointer(c,s,o);else if(t==="up"||t==="blur"){const w=this.objectStates.get(c.id);w&&c.isSpringReturn!==!1&&(w.handleX=0,w.handleY=0),c.isSpringReturn!==!1&&(c.handleX=0,c.handleY=0)}}if((c.type==="Checkbox"||c.type==="Component"&&c.variant==="checkbox")&&t==="down"){const w=this.objectStates.get(c.id),I=(w==null?void 0:w.options)||c.options||{};if(I.disabled)return;I.checked=!I.checked,I.indeterminate&&(I.indeterminate=!1),c.inputId&&this.setInternalInput(c.inputId,I.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"checkbox",property:"checked",value:I.checked}),this.fireEventForObject(c.id,"Click"),this.fireEventForObject(c.id,I.checked?"Checked":"Unchecked")}if(c.type==="Component"&&c.variant==="radiogroup"&&t==="down"){const w=this.objectStates.get(c.id),I=(w==null?void 0:w.options)||c.options||{},k=I.optionsList||[],O=this.getRadioGroupItemIndexAtPointer(c,s,o);if(O!==null&&O>=0&&O<k.length){const T=k[O];I.selectedValue=T,c.inputId&&this.setInternalInput(c.inputId,T),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"radiogroup",property:"selectedValue",value:T}),this.fireEventForObject(c.id,"Click"),this.fireEventForObject(c.id,`Selected: ${T}`)}}if(c.type==="LineGraph"&&(t==="down"||t==="click")){const w=c.geometry,I=(w==null?void 0:w.datasets)||[],k=this.objectStates.get(c.id),O=(k==null?void 0:k.width)||(w==null?void 0:w.width)||200,T=(k==null?void 0:k.height)||(w==null?void 0:w.height)||150,A=this.getWorldTransform(c.id),D=30,Y=20,B=O-D,R=T-Y;let L=1;I.forEach(X=>{const M=Math.max(...X.data||[0]);M>L&&(L=M)});let $=1/0,F=null;I.forEach((X,M)=>{const E=X.data||[],P=B/Math.max(E.length-1,1);E.forEach((_,V)=>{const G=A.x-O/2+D+V*P,x=A.y+T/2-Y-_/L*R,U=Math.sqrt((s-G)**2+(o-x)**2);U<$&&($=U,F={dIdx:M,pIdx:V,val:_,label:X.label||`Dataset ${M+1}`})})}),F&&$<20&&this.onGraphPointClick&&this.onGraphPointClick({objectId:c.id,componentName:c.name,datasetIndex:F.dIdx,pointIndex:F.pIdx,value:F.val,label:F.label}),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"linegraph",property:"click",value:(F==null?void 0:F.val)??null})}if((c==null?void 0:c.type)==="InputBox"||(c==null?void 0:c.type)==="Component"&&(c.variant==="inputbox"||c.name==="InputBox")){if(t==="down"||t==="click"){const w=this.focusedId;if(this.focusedId=c.id,this.log(`[Engine] Focus set to: ${c.id}`),w!==this.focusedId){if(w){const V=(p=this.artboard)==null?void 0:p.objects.find(G=>G.id===w);V&&this.onInputBlur&&this.onInputBlur(V.name)}this.onInputFocus&&this.onInputFocus(c.name)}const I=this.objectStates.get(c.id),k=(I==null?void 0:I.options)||c.options||{},O=c.geometry||{},T=(I==null?void 0:I.width)||(O==null?void 0:O.width)||250,A=(I==null?void 0:I.height)||(O==null?void 0:O.height)||45,D=this.getWorldTransform(c.id),Y=-D.rotation*(Math.PI/180),B=Math.cos(Y),R=Math.sin(Y),L=s-D.x,$=o-D.y,F=(L*B-$*R)/(D.scaleX||1),X=(L*R+$*B)/(D.scaleY||1);if(k.inputType==="number"&&((g=k.number)==null?void 0:g.showSteppers)!==!1){const G=T/2-4,x=G-24;if(F>=x&&F<=G&&Math.abs(X)<=A/2){const U=Number(((u=k.number)==null?void 0:u.step)??1),q=((f=k.number)==null?void 0:f.min)!==void 0?Number(k.number.min):-1/0,N=((h=k.number)==null?void 0:h.max)!==void 0?Number(k.number.max):1/0;let H=parseFloat(k.text??k.value??"0");isNaN(H)&&(H=0),X<0?H=Math.min(N,H+U):H=Math.max(q,H-U);const z=String(H);k.text=z,k.value=z,c.options&&(c.options.text=z,c.options.value=z),I&&I.options&&(I.options.text=z,I.options.value=z),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"inputbox",property:"value",value:z}),this.onInputChange&&this.onInputChange(c.name,z),this.onInputUpdate&&this.onInputUpdate(c.id,z);return}}const M=k.rightIcon||{},E=k.inputType==="password",P=M.mode==="clear"||k.inputType==="search"&&(k.text||k.value),_=M.mode==="password-toggle"||E&&M.visible!==!1;if(M.visible||_||P){const V=M.offset??16,G=M.size??16,x=T/2-V;if(Math.abs(F-x)<=G&&Math.abs(X)<=A/2){if(_){k.passwordVisible=!k.passwordVisible,I&&I.options&&(I.options.passwordVisible=k.passwordVisible),c.options&&(c.options.passwordVisible=k.passwordVisible);return}else if(P){k.text="",k.value="",I&&I.options&&(I.options.text="",I.options.value=""),c.options&&(c.options.text="",c.options.value=""),this.onInputChange&&this.onInputChange(c.name,""),this.onInputUpdate&&this.onInputUpdate(c.id,"");return}}}}}else if((t==="click"||t==="down")&&this.focusedId){const w=this.focusedId;this.focusedId=null;const I=(m=this.artboard)==null?void 0:m.objects.find(k=>k.id===w);I&&this.onInputBlur&&this.onInputBlur(I.name)}}else if(t==="click"||t==="down"){const c=this.focusedId;if(this.focusedId=null,c){const S=(b=this.artboard)==null?void 0:b.objects.find(v=>v.id===c);S&&this.onInputBlur&&this.onInputBlur(S.name)}}}handleKeyDown(t){var l,d,p,g;if(!this.artboard||(this.activeKeys.add(t.key.toLowerCase()),this.activeKeys.add(t.code),!this.focusedId))return;const s=this.artboard.objects.find(u=>u.id===this.focusedId),o=(s==null?void 0:s.type)==="InputBox"||(s==null?void 0:s.type)==="Component"&&(s.variant==="inputbox"||s.name==="InputBox");if(!s||!o)return;const e=this.objectStates.get(s.id),n=(e==null?void 0:e.options)||s.options||{};let i=String(n.text??n.value??"");const a=n.inputType==="textarea"||n.multiline===!0;if(t.key==="Backspace")i=i.slice(0,-1),t.preventDefault();else if(t.key==="Escape"){this.focusedId=null,this.onInputBlur&&this.onInputBlur(s.name);return}else if(t.key==="Enter")if(a)i+=`
7
+ `,t.preventDefault();else{this.focusedId=null,this.onInputBlur&&this.onInputBlur(s.name);return}else if(t.key==="ArrowUp"&&n.inputType==="number"){const u=Number(((l=n.number)==null?void 0:l.step)??1),f=((d=n.number)==null?void 0:d.max)!==void 0?Number(n.number.max):1/0;let h=parseFloat(i)||0;h=Math.min(f,h+u),i=String(h),t.preventDefault()}else if(t.key==="ArrowDown"&&n.inputType==="number"){const u=Number(((p=n.number)==null?void 0:p.step)??1),f=((g=n.number)==null?void 0:g.min)!==void 0?Number(n.number.min):-1/0;let h=parseFloat(i)||0;h=Math.max(f,h-u),i=String(h),t.preventDefault()}else if(t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey){if(n.maxLength>0&&i.length>=n.maxLength||n.inputType==="number"&&(!/[\d.\-]/.test(t.key)||t.key==="-"&&i.includes("-")||t.key==="."&&i.includes(".")))return;i+=t.key,t.preventDefault()}else return;n.text=i,n.value=i,s.options&&(s.options.text=i,s.options.value=i),e&&e.options&&(e.options.text=i,e.options.value=i);const r=s.geometry;r!=null&&r.textInputId&&this.updateInput(r.textInputId,i),this.onComponentChange&&(this.onComponentChange({objectId:s.id,componentName:s.name,variant:"inputbox",property:"text",value:i}),this.onComponentChange({objectId:s.id,componentName:s.name,variant:"inputbox",property:"value",value:i})),this.onInputChange&&this.onInputChange(s.name,i),this.onInputUpdate&&this.onInputUpdate(this.focusedId,i)}handleKeyUp(t){this.artboard&&(this.activeKeys.delete(t.key.toLowerCase()),this.activeKeys.delete(t.code))}hasDragInteraction(t){return t?(t.interactions||[]).some(o=>{const e=o.triggers||[o.event||o.trigger];return Array.isArray(e)&&e.some(n=>String(n).toLowerCase()==="drag")}):!1}fireEventForObject(t,s){var d,p,g,u,f;const o=(d=this.artboard)==null?void 0:d.objects.find(h=>h.id===t);if(!o)return;const e=new Set([s,s.toLowerCase()]),n=s.toLowerCase();n==="onclick"||n==="click"||n==="onpointerdown"||n==="pointerdown"?this.fireAnalyticsEvent(t,"click"):(n==="onpointerenter"||n==="hover"||n==="move")&&this.fireAnalyticsEvent(t,"hover"),n==="onclick"||n==="click"?(e.add("click"),e.add("onclick")):n==="onpointerdown"||n==="pointerdown"?(e.add("pointerdown"),e.add("onpointerdown")):n==="onpointerup"||n==="pointerup"?(e.add("pointerup"),e.add("onpointerup")):n==="onpointerenter"||n==="hover"||n==="move"?(e.add("hover"),e.add("onpointerenter")):n==="onpointerleave"||n==="blur"?(e.add("onpointerleave"),e.add("blur")):n==="drag"||n==="ondrag"?(e.add("drag"),e.add("ondrag")):n==="toggle"||n==="ontoggle"?(e.add("toggle"),e.add("ontoggle")):n==="toggle true"||n==="toggle_true"||n==="toggletrue"?(e.add("toggle true"),e.add("toggle_true"),e.add("toggletrue")):(n==="toggle false"||n==="toggle_false"||n==="togglefalse")&&(e.add("toggle false"),e.add("toggle_false"),e.add("togglefalse"));const a=(o.interactions||[]).find(h=>{const m=h.triggers||[h.event||h.trigger||"click"];return((h.triggerLogic||"OR")==="AND"?m.every(S=>e.has(S.toLowerCase())):m.some(S=>e.has(S.toLowerCase())))?h.conditions&&h.conditions.length>0?this.checkConditions(h.conditions):!0:!1});if(a){if(this.log(`[Engine] Interaction matched: ${s} -> Action: ${a.action}`),a.action==="setInput"||a.action==="Set Input"){let h=a.value||a.inputValue;h==="toggle"&&(h=!this.inputs.get(a.targetInputId)),this.updateInput(a.targetInputId,h)}else if(a.action==="Toggle Boolean"){const h=a.targetInputId;if(h&&this.inputs.has(h)){const c=this.inputs.get(h);this.updateInput(h,!c)}const m=this.objectStates.get(o.id),b=(m==null?void 0:m.options)||o.options;b&&typeof b.checked=="boolean"&&(b.checked=!b.checked,b.indeterminate&&(b.indeterminate=!1),this.onComponentChange&&this.onComponentChange({objectId:o.id,componentName:o.name,variant:"checkbox",property:"checked",value:b.checked}))}else if(a.action==="fireTrigger")this.updateInput(a.targetInputId,!0);else if(a.action==="setProperty"){const h=a.targetObjectId||o.id,m=a.targetProperty;m&&this.updateObjectProperty(h,m,a.value)}else if(a.action==="Navigate Artboard"||a.action==="navigate")this.onNavigation&&this.onNavigation({type:"artboard",value:a.targetArtboard||a.value});else if(a.action==="Navigate URL")this.onNavigation&&this.onNavigation({type:"url",value:a.navigateUrl});else if(a.action==="Play Animation"){const h=a.targetAnimationId,m=!a.playMode||a.playMode==="all"?void 0:a.subAnimationIds;h==="__all__"?(g=(p=this.artboard)==null?void 0:p.animations)==null||g.forEach(b=>{this.triggerGlobalAnimation(b.id,m)}):h&&this.triggerGlobalAnimation(h,m)}else if(a.action==="setState"||a.action==="Set State"){const h=a.targetObjectId||o.id,b={...this.objectStates.get(h)||{},...a.value||{}};this.objectStates.set(h,b),this.log(`[Engine] State updated for ${h}:`,b)}else if(a.action==="Stop Animation"||a.action==="Pause Animation"){const h=a.targetAnimationId;h==="__all__"?this.layerStates.forEach((m,b)=>{b.startsWith("global_")&&this.layerStates.delete(b)}):h&&this.layerStates.forEach((m,b)=>{b.startsWith(`global_${h}_`)&&this.layerStates.delete(b)})}else if(a.action==="Switch to State"&&this.activeStateMachine){const h=a.targetState,m=this.activeStateMachine.layers.find(b=>b.states.some(c=>c.id===h||c.name===h));m&&(this.log(`[Engine] Switching Layer ${m.name} to State ${h}`),this.enterStates(m.name,[h]))}this.onTrigger&&this.onTrigger(s,a.action)}const l=(o.triggers||[]).find(h=>{const m=h.eventType.toLowerCase();let b=!1;return(e.has(m)||m==="click"&&e.has("onclick")||m==="hover"&&(e.has("onpointerenter")||e.has("hover"))||m==="pointerdown"&&e.has("onpointerdown")||m==="pointerup"&&e.has("onpointerup"))&&(b=!0),b&&h.conditions&&h.conditions.length>0?this.checkConditions(h.conditions):b});if(l&&l.entryAnimationId){this.log(`[Engine] Trigger matched: ${s} (as ${l.eventType}) -> Animation ${l.entryAnimationId}`);const h=(f=(u=this.artboard)==null?void 0:u.animations)==null?void 0:f.find(m=>m.id===l.entryAnimationId);h&&(this.activeTriggers.set(o.id,{triggerId:l.id,animation:h,time:0,phase:"entry",elapsedHold:0,filterObjectId:l.targetObjectId}),this.onTrigger&&this.onTrigger(l.name,h.name))}}fireAnalyticsEvent(t,s){var r,l;const o=(r=this.artboard)==null?void 0:r.objects.find(d=>d.id===t);if(!o)return;const e=(l=o.style)==null?void 0:l.analytics;if(!e||!e.isEnabled||e.triggerType!==s)return;const n=e.eventName||`${o.name.toLowerCase().replace(/\s+/g,"_")}_interacted`,i={};e.parameters&&Array.isArray(e.parameters)&&e.parameters.forEach(d=>{if(d.type==="literal")i[d.key]=d.value;else if(d.type==="variable"){const p=this.inputs.get(d.value);i[d.key]=p!==void 0?p:""}}),this.log(`[ExodeUI Analytics] Dispatching event "${n}" via ${s} trigger:`,i);const a=e.platforms||{ga4:!0,meta:!0,mixpanel:!1};if(a.ga4){const d=window;typeof d.gtag=="function"?(d.gtag("event",n,i),this.log(`[ExodeUI Analytics] GA4: Event "${n}" sent successfully.`)):this.warn(`[ExodeUI Analytics] GA4: window.gtag is not a function. Event "${n}" skipped.`)}if(a.meta){const d=window;typeof d.fbq=="function"?(d.fbq("track",n,i),this.log(`[ExodeUI Analytics] Meta Pixel: Event "${n}" sent successfully.`)):this.warn(`[ExodeUI Analytics] Meta Pixel: window.fbq is not a function. Event "${n}" skipped.`)}if(a.mixpanel){const d=window;d.mixpanel&&typeof d.mixpanel.track=="function"?(d.mixpanel.track(n,i),this.log(`[ExodeUI Analytics] Mixpanel: Event "${n}" sent successfully.`)):this.warn(`[ExodeUI Analytics] Mixpanel: window.mixpanel.track is not a function. Event "${n}" skipped.`)}}getAnimationDuration(t){var o;if(!t)return 0;let s=t.duration||0;return s<=0&&((o=t.tracks)==null||o.forEach(e=>{var n;(n=e.keyframes)==null||n.forEach(i=>{i.time>s&&(s=i.time)})})),s>0?s:1}initGlobalAnimationTriggers(){if(!this.artboard)return;const t=this.artboard.animationFlow||[];let s=!1;t.forEach(o=>{if((o.trigger==="on_load"||o.trigger==="after_delay")&&o.targetAnimationId){s=!0;const e=o.delay||0;e<=0?this.triggerGlobalAnimation(o.targetAnimationId,o.subAnimationIds,o.loop,o.id):setTimeout(()=>this.triggerGlobalAnimation(o.targetAnimationId,o.subAnimationIds,o.loop,o.id),e)}}),!s&&this.artboard.startupAnimationId&&this.triggerGlobalAnimation(this.artboard.startupAnimationId,this.artboard.startupSubAnimationIds)}triggerGlobalAnimation(t,s,o=!1,e){var r;if(!this.artboard)return;const n=this.artboard.animations.find(l=>l.id===t);if(!n)return;let i=this.getAnimationDuration(n);const a=`global_${t}_${Math.random().toString(36).substr(2,5)}`;this.layerStates.set(a,{currentStateIds:[t],animations:[{animation:n,state:{loop:o},filterObjectIds:s}],time:0,duration:i,ruleId:e}),console.log(`[Engine] Triggered global animation: ${n.name} (AnimID: ${t}, RuleID: ${e}, Loop: ${o}, StoredDuration: ${i}, anim.duration: ${n.duration}, Tracks: ${((r=n.tracks)==null?void 0:r.length)||0})`),this.debugLog(`[Engine] Triggered global animation: ${n.name} (Loop: ${o}, Sub-Anims: ${(s==null?void 0:s.length)||"All"})`)}handleAnimationFinished(t,s){if(!this.artboard)return;console.log(`[Engine] Animation finished! AnimID: ${t}, RuleID: ${s}`);const o=this.artboard.animationFlow||[];o.forEach((e,n)=>{if(e.trigger==="after_anim"&&e.targetAnimationId){let i=e.afterAnim;!i&&n>0&&(i=o[n-1].id);const a=i===t||s&&i===s;if(console.log(`[Engine] Checking rule ${e.id} (Trigger: ${e.trigger}). ExpectedParent: ${i}. isMatch? ${a}`),a){const r=e.delay||0;console.log(`[Engine] Match found! Triggering target animation: ${e.targetAnimationId} after delay: ${r}`),r<=0?this.triggerGlobalAnimation(e.targetAnimationId,e.subAnimationIds,e.loop,e.id):setTimeout(()=>this.triggerGlobalAnimation(e.targetAnimationId,e.subAnimationIds,e.loop,e.id),r)}}})}getEntranceProgress(t,s,o){if((s.type||"none")==="none")return 1;const n=s.duration||1.2,i=s.delay||0,a=s.easing||"EaseOutCubic",r=gs(a);let l=0;if(o==="entrance"){const d=n+i+2,p=this.currentTime%d;p<i?l=0:p<i+n?l=(p-i)/n:l=1}else{this.entranceStartTimes.has(t)||this.entranceStartTimes.set(t,this.currentTime);const d=this.entranceStartTimes.get(t),p=this.currentTime-d;p<i?l=0:p<i+n?l=(p-i)/n:l=1}return r(l)}getWorldTransform(t){var g;const s=this.objectStates.get(t);if(!s)return{x:0,y:0,scaleX:1,scaleY:1,rotation:0};const o=(g=this.artboard)==null?void 0:g.objects.find(u=>u.id===t);if(!o||!o.parentId)return{x:s.x,y:s.y,scaleX:s.scale_x??1,scaleY:s.scale_y??1,rotation:s.rotation??0};const e=this.getWorldTransform(o.parentId),n=e.rotation*(Math.PI/180),i=Math.cos(n),a=Math.sin(n),r=s.x*e.scaleX,l=s.y*e.scaleY,d=e.x+(r*i-l*a),p=e.y+(r*a+l*i);return{x:d,y:p,scaleX:(s.scale_x??1)*e.scaleX,scaleY:(s.scale_y??1)*e.scaleY,rotation:e.rotation+(s.rotation??0)}}hitTest(t,s,o){var S,v;if(!this.objectStates.get(t.id))return!1;const n=((S=t.geometry)==null?void 0:S.width)??t.width??100,i=((v=t.geometry)==null?void 0:v.height)??t.height??100,a=this.getWorldTransform(t.id),r=s-a.x,l=o-a.y,d=-a.rotation*(Math.PI/180),p=Math.cos(d),g=Math.sin(d),u=r*p-l*g,f=r*g+l*p,h=a.scaleX,m=a.scaleY,b=n*Math.abs(h),c=i*Math.abs(m);return Math.abs(u)<=b/2&&Math.abs(f)<=c/2}updateSliderValueFromPointer(t,s,o){var I;const e=this.objectStates.get(t.id);if(!e)return;const n=t.options||{},i=((I=t.geometry)==null?void 0:I.width)??t.width??200,a=this.getWorldTransform(t.id),r=s-a.x,l=o-a.y,d=-a.rotation*(Math.PI/180),p=Math.cos(d),g=Math.sin(d),u=r*p-l*g,f=n.thumbWidth??16,h=i-f;let b=(u+h/2)/h;b=Math.max(0,Math.min(1,b));const c=n.min??0,S=n.max??100,v=n.step||1;let C=c+b*(S-c);v>0&&(C=Math.round(C/v)*v),C=Math.max(c,Math.min(S,C));const w=e.options||{};w.value!==C&&(e.options={...w,value:C},t.inputId&&this.setInternalInput(t.inputId,C),this.onComponentChange&&this.onComponentChange({objectId:t.id,componentName:t.name,variant:"slider",property:"value",value:C}))}updateJoystickValueFromPointer(t,s,o){var I,k;const e=this.objectStates.get(t.id);if(!e)return;const n=(e==null?void 0:e.width)!==void 0?e.width:((I=t.geometry)==null?void 0:I.width)??t.width??100,i=(e==null?void 0:e.height)!==void 0?e.height:((k=t.geometry)==null?void 0:k.height)??t.height??100,a=this.getWorldTransform(t.id),r=s-a.x,l=o-a.y,d=-a.rotation*(Math.PI/180),p=Math.cos(d),g=Math.sin(d);let u=(r*p-l*g)/Math.max(.001,Math.abs(a.scaleX||1)),f=(r*g+l*p)/Math.max(.001,Math.abs(a.scaleY||1));t.handleOrigin==="top-left"?(u-=n/2,f-=i/2):t.handleOrigin==="bottom-right"&&(u+=n/2,f+=i/2);const h=Math.min(n,i)*.45,m=Math.min(n,i)*.15,b=h-m;let c=u/b,S=f/b;const v=Math.sqrt(c*c+S*S);t.boundsShape==="square"?(c=Math.max(-1,Math.min(1,c)),S=Math.max(-1,Math.min(1,S))):v>1&&(c/=v,S/=v),t.deadzone!==void 0&&v<t.deadzone?(c=0,S=0):(t.stepX!==void 0&&t.stepX>0&&(c=Math.round(c/t.stepX)*t.stepX),t.stepY!==void 0&&t.stepY>0&&(S=Math.round(S/t.stepY)*t.stepY)),t.joystickType==="1D_X"?S=0:t.joystickType==="1D_Y"&&(c=0);const C=e.handleX,w=e.handleY;(C!==c||w!==S)&&(e.handleX=c,e.handleY=S,t.handleX=c,t.handleY=S)}processJoysticks(t){this.artboard&&(this.artboard.objects.forEach(s=>{var l,d,p,g;if(s.type!=="Joystick"&&!(s.type==="Component"&&s.variant==="joystick"))return;const o=s,e=this.objectStates.get(o.id);if(!e)return;let n=e.handleX??o.handleX??0,i=e.handleY??o.handleY??0;const r=(o.globalInput??!1)||this.lastHoveredObjectId===o.id;if(r&&((l=o.inputBinding)==null?void 0:l.type)==="keyboard"&&o.inputBinding.keyboardConfig){const u=o.inputBinding.keyboardConfig;let f=n,h=i;const b=(u.speed||5)*t;let c=!1;this.activeKeys.has(u.upKey.toLowerCase())&&(h-=b,c=!0),this.activeKeys.has(u.downKey.toLowerCase())&&(h+=b,c=!0),this.activeKeys.has(u.leftKey.toLowerCase())&&(f-=b,c=!0),this.activeKeys.has(u.rightKey.toLowerCase())&&(f+=b,c=!0),o.joystickType==="1D_X"&&(h=0),o.joystickType==="1D_Y"&&(f=0);const S=Math.sqrt(f*f+h*h);S>1&&(f/=S,h/=S),!c&&o.isSpringReturn!==!1&&(f+=(0-f)*(10*t),h+=(0-h)*(10*t),Math.abs(f)<.01&&(f=0),Math.abs(h)<.01&&(h=0)),n=f,i=h}else if(r&&((d=o.inputBinding)==null?void 0:d.type)==="mouse"&&o.inputBinding.mouseConfig){const u=o.inputBinding.mouseConfig;let f=e._mouseTargetX??n,h=e._mouseTargetY??i;const m=u.sensitivity||.01;if(u.mode==="absolute"){const S=((p=this.artboard)==null?void 0:p.width)||window.innerWidth,v=((g=this.artboard)==null?void 0:g.height)||window.innerHeight,C=this.inputs.get("mouseX")||0,w=this.inputs.get("mouseY")||0;u.axisX&&(f=C/S*2-1),u.axisY&&(h=w/v*2-1)}else u.axisX&&(f+=this._mouseDelta.dx*m),u.axisY&&(h+=this._mouseDelta.dy*m);o.joystickType==="1D_X"&&(h=0),o.joystickType==="1D_Y"&&(f=0);const b=Math.sqrt(f*f+h*h);b>1&&(f/=b,h/=b),o.isSpringReturn!==!1&&(f+=(0-f)*(5*t),h+=(0-h)*(5*t),Math.abs(f)<.01&&(f=0),Math.abs(h)<.01&&(h=0)),e._mouseTargetX=f,e._mouseTargetY=h;const c=15*t;n+=(f-n)*Math.min(c,1),i+=(h-i)*Math.min(c,1)}if(e.handleX=n,e.handleY=i,o.handleX=n,o.handleY=i,o.bindings&&o.bindings.length>0){const u=Math.sqrt(n*n+i*i);let f=Math.atan2(i,n)*(180/Math.PI);f<0&&(f+=360),o.bindings.forEach(h=>{var c,S,v,C,w,I,k,O;let m=0;h.sourceAxis==="x"?m=o.invertX?-n:n:h.sourceAxis==="y"?m=o.invertY?-i:i:h.sourceAxis==="distance"?m=u:h.sourceAxis==="angle"&&(m=f);const b=(c=this.artboard)==null?void 0:c.objects.find(T=>T.id===h.targetObjectId);if(b){if(h.actionType==="bind"&&h.targetProperty&&h.isContinuous!==!1){const T=h.sourceMin??-1,A=h.sourceMax??1,D=h.targetMin??0,Y=h.targetMax??100;let B=!!h.isContinuous,R=0,L=0;if(B){if((h.sourceAxis==="x"||h.sourceAxis==="y")&&D>=0){const F=Math.max(Math.abs(T),Math.abs(A))||1;L=m/F*Y}else{let F=(m-T)/(A-T);F=Math.max(0,Math.min(1,F)),L=D+F*(Y-D)}Math.abs(m)<.05&&(L=0)}else{const F=(m-T)/(A-T),X=Math.max(0,Math.min(1,F));R=D+X*(Y-D),h.step&&h.step>0&&(R=Math.round(R/h.step)*h.step)}const $=this.objectStates.get(b.id);if($){const F=h.isRelative!==!1,X=F?((S=b.transform)==null?void 0:S.x)??0:0,M=F?((v=b.transform)==null?void 0:v.y)??0:0,E=F?((C=b.transform)==null?void 0:C.rotation)??0:0,P=F?((w=b.transform)==null?void 0:w.scale_x)??1:0,_=F?((I=b.transform)==null?void 0:I.scale_y)??1:0,V=F?((k=b.style)==null?void 0:k.opacity)??100:0,G=Math.min(t*60,3),x=(U,q)=>{let N=R;if(B){const H=`_internal_${U}_${h.id}`;let z=$[H];z===void 0&&(z=$[U]??q),N=z+L*G,$[H]=N,h.step&&h.step>0&&(N=Math.round(N/h.step)*h.step)}else{N=q+R;const H=`_internal_smooth_${U}_${h.id}`;let z=$[H];if(z===void 0)z=N;else{const et=Math.min(15*t,1);z+=(N-z)*et}$[H]=z,N=z}$[U]=N};h.targetProperty==="x"||h.targetProperty==="transform.x"?x("x",X):h.targetProperty==="y"||h.targetProperty==="transform.y"?x("y",M):h.targetProperty==="rotation"||h.targetProperty==="r"||h.targetProperty==="transform.rotation"?x("rotation",E):h.targetProperty==="scaleX"||h.targetProperty==="transform.scale_x"?x("scale_x",P):h.targetProperty==="scaleY"||h.targetProperty==="transform.scale_y"?x("scale_y",_):(h.targetProperty==="opacity"||h.targetProperty==="transform.opacity")&&x("opacity",V)}(O=b.physics)!=null&&O.enabled&&this.physicsEngine&&(h.targetProperty==="x"||h.targetProperty==="transform.x"||h.targetProperty==="y"||h.targetProperty==="transform.y")&&(h.targetProperty==="x"||h.targetProperty==="transform.x"?this.physicsEngine.applyForce(b.id,(R-(($==null?void 0:$.x)||0))*10,0):(h.targetProperty==="y"||h.targetProperty==="transform.y")&&this.physicsEngine.applyForce(b.id,0,(R-(($==null?void 0:$.y)||0))*10))}else if(h.actionType==="playAnimation"||h.actionType==="stopAnimation"||h.actionType==="pauseAnimation"){let T=!1;const A=h.threshold??0;h.condition==="always"?T=!0:h.condition===">"?T=m>A:h.condition==="<"?T=m<A:h.condition==="=="&&(T=Math.abs(m-A)<.01);const D=e[`_prev_src_${h.id}`]??m;let Y=!1;h.condition==="always"?Y=!0:h.condition===">"?Y=D>A:h.condition==="<"?Y=D<A:h.condition==="=="&&(Y=Math.abs(D-A)<.01),e[`_prev_src_${h.id}`]=m,T&&!Y&&h.targetAnimationId&&(h.actionType==="playAnimation"||h.actionType)}}})}}),this._mouseDelta.dx=0,this._mouseDelta.dy=0)}applyBlendState(t,s){var l,d,p,g,u,f,h,m;if(!t.blendAnimations||t.blendAnimations.length===0)return;let o=0,e=0;t.blendInputX&&(o=this.inputs.get(t.blendInputX)??0),t.blendInputY&&(e=this.inputs.get(t.blendInputY)??0);const n=[];let i=0;if(t.blendType==="1D"){const b=[...t.blendAnimations].sort((c,S)=>c.position[0]-S.position[0]);if(b.length===1){const c=(d=(l=this.artboard)==null?void 0:l.animations)==null?void 0:d.find(S=>S.id===b[0].animationId);c&&(n.push({anim:c,weight:1}),i=1)}else{let c=0;for(;c<b.length-1&&b[c+1].position[0]<o;)c++;if(c===b.length-1&&o>b[c].position[0]){const S=(g=(p=this.artboard)==null?void 0:p.animations)==null?void 0:g.find(v=>v.id===b[c].animationId);S&&(n.push({anim:S,weight:1}),i=1)}else{const S=b[c].position[0],v=b[c+1].position[0],C=(f=(u=this.artboard)==null?void 0:u.animations)==null?void 0:f.find(T=>T.id===b[c].animationId),w=(m=(h=this.artboard)==null?void 0:h.animations)==null?void 0:m.find(T=>T.id===b[c+1].animationId),I=Math.max(.001,v-S);let k=(o-S)/I;k=Math.max(0,Math.min(1,k));const O=1-k;C&&(n.push({anim:C,weight:O}),i+=O),w&&(n.push({anim:w,weight:k}),i+=k)}}}else t.blendAnimations.forEach(b=>{var w,I;const c=(I=(w=this.artboard)==null?void 0:w.animations)==null?void 0:I.find(k=>k.id===b.animationId);if(!c)return;const S=b.position[0]-o,v=b.position[1]-e,C=S*S+v*v;if(C<1e-4)n.push({anim:c,weight:1e4}),i+=1e4;else{const k=1/C;n.push({anim:c,weight:k}),i+=k}});if(i===0)return;n.forEach(b=>b.weight/=i);const a=new Map,r=b=>{let c=b.startsWith("#")?b.substring(1):b;return c.length===3&&(c=[c[0],c[0],c[1],c[1],c[2],c[2]].join("")),c="0x"+c,{r:c>>16&255,g:c>>8&255,b:c&255,a:1}};n.forEach(({anim:b,weight:c})=>{b.tracks&&b.tracks.forEach(S=>{var A,D;const v=S.object_id||S.objectId,C=S.property,w=(A=this.artboard)==null?void 0:A.objects.find(Y=>Y.id===v);if(((D=w==null?void 0:w.physics)==null?void 0:D.enabled)&&w.physics.bodyType!=="Static"&&(C==="x"||C==="y"||C==="rotation"))return;const k=this.interpolate(S.keyframes,s);if(k===void 0)return;let O=a.get(v);O||(O=new Map,a.set(v,O));let T=O.get(C);if(!T){if(typeof k=="number")T={type:"number",value:0};else if(typeof k=="string"&&k.startsWith("#"))T={type:"color",value:k,colorAcc:{r:0,g:0,b:0,a:0}};else if(T={type:"number",value:k},c<.5)return;O.set(C,T)}if(T.type==="number"&&typeof k=="number")T.value+=k*c;else if(T.type==="color"&&typeof k=="string"&&T.colorAcc){const Y=r(k);Y&&(T.colorAcc.r+=Y.r*c,T.colorAcc.g+=Y.g*c,T.colorAcc.b+=Y.b*c,T.colorAcc.a+=Y.a*c)}else c>.5&&(T.value=k)})}),a.forEach((b,c)=>{var C;const S=this.objectStates.get(c),v=(C=this.artboard)==null?void 0:C.objects.find(w=>w.id===c);!S||!v||b.forEach((w,I)=>{let k=w.value;if(w.type==="color"&&w.colorAcc){const O=Math.round(w.colorAcc.r).toString(16).padStart(2,"0"),T=Math.round(w.colorAcc.g).toString(16).padStart(2,"0"),A=Math.round(w.colorAcc.b).toString(16).padStart(2,"0");k=`#${O}${T}${A}`}if(I.includes(".")||I.includes("[")){const O=(I||"").replace(/\[(\d+)\]/g,".$1").split(".");let T=S;for(let A=0;A<O.length-1;A++){if(typeof T[O[A]]!="object"||T[O[A]]===null){let D=v;for(let Y=0;Y<=A;Y++)D=D?D[O[Y]]:null;if(O[A]==="corner_radius"||O[A]==="cornerRadius"){const Y=typeof T[O[A]]=="number"?T[O[A]]:typeof D=="number"?D:0;T[O[A]]={tl:Y,tr:Y,bl:Y,br:Y}}else{const Y=O[A+1],B=!isNaN(Number(Y));T[O[A]]=D?JSON.parse(JSON.stringify(D)):B?[]:{}}}T=T[O[A]]}T[O[O.length-1]]=k,O[O.length-1]==="color"&&(O[O.length-2]==="fill"||O[O.length-2]==="stroke")&&(T.type="Solid")}else I==="fill"?(S.style||(S.style={}),S.style.fill=k):I==="stroke"?(S.style||(S.style={}),S.style.stroke=k):S[I]=k})})}applyAnimation(t,s,o){!t||!t.tracks||t.tracks.forEach(e=>{var p,g,u;const n=e.object_id||e.objectId;if(o){if(Array.isArray(o)){if(!o.includes(n))return}else if(n!==o)return}const i=(p=this.artboard)==null?void 0:p.objects.find(f=>f.id===n),a=((g=i==null?void 0:i.physics)==null?void 0:g.enabled)&&i.physics.bodyType!=="Static";let r=e.property;if(a&&(r==="x"||r==="y"||r==="rotation"))return;const l=this.objectStates.get(n);if(!l){this.frameCount%600===0&&this.debugLog(`Skipping track: Object ${n} not found in state`);return}const d=this.interpolate(e.keyframes,s);if(d!==void 0){if(this.frameCount%240===0){const f=(i==null?void 0:i.name)||n,h=typeof d=="object"?JSON.stringify(d).slice(0,50):d;this.debugLog(`[Anim] Applying ${r} = ${h} to ${f}`)}if(r.includes(".")||r.includes("[")){const f=(r||"").replace(/\[(\d+)\]/g,".$1").split(".");let h=l;for(let m=0;m<f.length-1;m++){if(typeof h[f[m]]!="object"||h[f[m]]===null){let b=i;for(let c=0;c<=m;c++)b=b?b[f[c]]:null;if(f[m]==="corner_radius"||f[m]==="cornerRadius"){let c=0,S=0,v=0,C=0;const w=h[f[m]]??b;typeof w=="number"?c=S=v=C=w:Array.isArray(w)?w.length===1?c=S=v=C=w[0]:w.length===2?(c=v=w[0],S=C=w[1]):w.length===3?(c=w[0],S=C=w[1],v=w[2]):w.length>=4&&(c=w[0],S=w[1],v=w[2],C=w[3]):w&&typeof w=="object"&&(c=w[0]??w.tl??w.corner_radius??w.cornerRadius??0,S=w[1]??w.tr??w.corner_radius??w.cornerRadius??0,v=w[2]??w.br??w.corner_radius??w.cornerRadius??0,C=w[3]??w.bl??w.corner_radius??w.cornerRadius??0),h[f[m]]={tl:c,tr:S,bl:C,br:v,0:c,1:S,2:v,3:C}}else{const c=f[m+1],S=!isNaN(Number(c));h[f[m]]=b?JSON.parse(JSON.stringify(b)):S?[]:{}}}h=h[f[m]]}h[f[f.length-1]]=d,f[f.length-1]==="color"&&(f[f.length-2]==="fill"||f[f.length-2]==="stroke")&&(h.type="Solid")}else r==="fill"?(l.style||(l.style={}),l.style.fill=d):r==="stroke"?(l.style||(l.style={}),l.style.stroke=d):l[r]=d;if(this.physicsEngine&&((u=i==null?void 0:i.physics)!=null&&u.enabled)&&i.physics.bodyType==="Static")if(r==="x"){const f=this.physicsEngine.getPosition(n);f&&this.physicsEngine.setPosition(n,d,f.y)}else if(r==="y"){const f=this.physicsEngine.getPosition(n);f&&this.physicsEngine.setPosition(n,f.x,d)}else r==="rotation"&&this.physicsEngine.setRotation(n,d*(Math.PI/180))}})}interpolate(t,s){if(t.length===0)return;let o=t[0],e=t[t.length-1];if(s<=o.time)return o.value;if(s>=e.time)return e.value;for(let a=0;a<t.length-1;a++)if(s>=t[a].time&&s<t[a+1].time){o=t[a],e=t[a+1];break}const n=e.time-o.time;let i=(s-o.time)/n;return o.easing&&(i=gs(o.easing)(i)),this.interpolateValue(o.value,e.value,i)}interpolateValue(t,s,o){if(t===void 0)return s;if(s===void 0)return t;if(typeof t=="string"&&typeof s=="string"){if(t.startsWith("#"))return this.interpolateColor(t,s,o);const e=parseFloat(t),n=parseFloat(s);return!isNaN(e)&&!isNaN(n)?Math.round(e+(n-e)*o).toString():o<.5?t:s}if(Array.isArray(t)&&Array.isArray(s))return t.length===s.length?t.map((e,n)=>this.interpolateValue(e,s[n],o)):o<.5?t:s;if(typeof t=="object"&&typeof s=="object"&&t!==null&&s!==null){if(t.width!==void 0&&t.color!==void 0&&typeof t.width=="number")return this.interpolateStroke(t,s,o);if(t.type&&s.type&&(t.type==="Solid"||t.type==="LinearGradient"||t.type==="RadialGradient"||t.type==="Image"))return this.interpolateFill(t,s,o);const e={};return new Set([...Object.keys(t),...Object.keys(s)]).forEach(i=>{e[i]=this.interpolateValue(t[i],s[i],o)}),e}return typeof t=="number"&&typeof s=="number"?t+(s-t)*o:o<.5?t:s}interpolateColor(t,s,o){var f,h;const e=((h=(f=this.artboard)==null?void 0:f.tokens)==null?void 0:h.colors)||{},n=e[t]||t,i=e[s]||s,a=m=>{if(!m)return{r:0,g:0,b:0};const b=m.startsWith("#")?m.replace("#",""):"000000";return b.length===3?{r:parseInt(b[0]+b[0],16),g:parseInt(b[1]+b[1],16),b:parseInt(b[2]+b[2],16)}:{r:parseInt(b.substring(0,2),16),g:parseInt(b.substring(2,4),16),b:parseInt(b.substring(4,6),16)}},r=a(n),l=a(i),d=Math.round(r.r+(l.r-r.r)*o),p=Math.round(r.g+(l.g-r.g)*o),g=Math.round(r.b+(l.b-r.b)*o),u=m=>{const b=Math.max(0,Math.min(255,m)).toString(16);return b.length===1?"0"+b:b};return`#${u(d)}${u(p)}${u(g)}`}interpolateStops(t,s,o){return!t||!s||t.length!==s.length?o<.5?t:s:t.map((e,n)=>{const i=s[n];return{offset:e.offset+(i.offset-e.offset)*o,color:this.interpolateColor(e.color,i.color,o),opacity:(e.opacity??1)+((i.opacity??1)-(e.opacity??1))*o}})}interpolateFill(t,s,o){if(!t||!s||t.type!==s.type)return o<.5?t:s;const e={...t,opacity:(t.opacity??1)+((s.opacity??1)-(t.opacity??1))*o};return t.type==="Solid"?e.color=this.interpolateColor(t.color,s.color,o):(t.type==="LinearGradient"||t.type==="RadialGradient")&&(t.start&&s.start&&(e.start=[t.start[0]+(s.start[0]-t.start[0])*o,t.start[1]+(s.start[1]-t.start[1])*o]),t.end&&s.end&&(e.end=[t.end[0]+(s.end[0]-t.end[0])*o,t.end[1]+(s.end[1]-t.end[1])*o]),t.center&&s.center&&(e.center=[t.center[0]+(s.center[0]-t.center[0])*o,t.center[1]+(s.center[1]-t.center[1])*o]),t.radius!==void 0&&s.radius!==void 0&&(e.radius=t.radius+(s.radius-t.radius)*o),e.stops=this.interpolateStops(t.stops,s.stops,o)),e}interpolateStroke(t,s,o){if(!t||!s)return o<.5?t:s;const e={...t};return e.width=(t.width??0)+((s.width??0)-(t.width??0))*o,e.opacity=(t.opacity??1)+((s.opacity??1)-(t.opacity??1))*o,t.fill&&s.fill?e.fill=this.interpolateFill(t.fill,s.fill,o):t.color&&s.color&&t.color.startsWith("#")&&s.color.startsWith("#")&&(e.color=this.interpolateColor(t.color,s.color,o)),e.trimStart=(t.trimStart??0)+((s.trimStart??0)-(t.trimStart??0))*o,e.trimEnd=(t.trimEnd??1)+((s.trimEnd??1)-(t.trimEnd??1))*o,e.trimOffset=(t.trimOffset??0)+((s.trimOffset??0)-(t.trimOffset??0))*o,e.dashOffset=(t.dashOffset??0)+((s.dashOffset??0)-(t.dashOffset??0))*o,e}render(t,s,o){var p;this.debug_objectsTotal=((p=this.artboard)==null?void 0:p.objects.length)||0,this.debug_objectsRendered=0;const e=performance.now();if(this.canvasWidth=s,this.canvasHeight=o,!this.artboard)return;t.clearRect(0,0,s,o);const n=this.artboard.width,i=this.artboard.height,a=this.calculateTransform(s,o,n,i,this.layout.fit,this.layout.alignment);if(t.save(),t.translate(Math.round(a.tx),Math.round(a.ty)),t.scale(a.scaleX,a.scaleY),this.rootTransform=t.getTransform(),this.artboard.backgroundVisible!==!1&&(t.fillStyle=this.artboard.backgroundColor||"#000000",t.fillRect(0,0,n,i)),this.artboard.backgroundImage){const g=this.artboard.backgroundImage;let u=this.imageCache.get(g);if(u||(u=new Image,u.src=g,this.imageCache.set(g,u)),u.complete&&u.naturalWidth>0){t.save(),t.globalAlpha=this.normalizeOpacity(this.artboard.backgroundOpacity??100);const f=u.naturalWidth/u.naturalHeight,h=n/i;let m,b,c,S;h>f?(m=n,b=n/f):(b=i,m=i*f),c=(n-m)/2,S=(i-b)/2,t.drawImage(u,c,S,m,b),t.restore()}}this.artboard.clipContent!==!1&&this.artboard.clip_content!==!1&&(t.beginPath(),t.rect(0,0,n,i),t.clip());const l=new Map;this.artboard.objects.forEach(g=>l.set(g.id,g)),this.artboard.objects.filter(g=>!g.parentId).map((g,u)=>{const f=this.objectStates.get(g.id),h=(f==null?void 0:f.zIndex)??u;return{obj:g,zIndex:h}}).sort((g,u)=>g.zIndex-u.zIndex).forEach(({obj:g})=>{this.renderObject(t,g,l)}),this._emitterPools.forEach((g,u)=>{if(!(g.length===0||!l.get(u)))for(const h of g)t.save(),t.globalAlpha=h.opacity,t.fillStyle=h.color,t.beginPath(),t.arc(h.x,h.y,Math.max(1,h.size*h.opacity),0,Math.PI*2),t.fill(),t.restore()}),this.lastRenderTime=performance.now()-e,this.debugMode&&this.frameCount%60===0&&this.log(`[Engine Debug] Rendered ${this.debug_objectsRendered}/${this.debug_objectsTotal} objects in ${this.lastRenderTime.toFixed(2)}ms`),t.restore()}isObjectInView(t,s,o,e,n,i=0){const a=t.getTransform(),r=s*a.a+o*a.c+a.e,l=s*a.b+o*a.d+a.f,d=Math.sqrt(a.a*a.a+a.b*a.b),p=Math.sqrt(a.c*a.c+a.d*a.d),g=(e/2+i)*d,u=(n/2+i)*p;return r+g>=0&&r-g<=this.canvasWidth&&l+u>=0&&l-u<=this.canvasHeight}calculateTransform(t,s,o,e,n,i){let a=1,r=1,l=1;const d=o/e,p=t/s;switch(n){case"Contain":p>d?l=s/e:l=t/o,a=r=l;break;case"Cover":p>d?l=t/o:l=s/e,a=r=l;break;case"Fill":a=t/o,r=s/e;break;case"FitWidth":l=t/o,a=r=l;break;case"FitHeight":l=s/e,a=r=l;break;case"None":a=r=1;break;case"ScaleDown":l=Math.min(t/o,s/e),l>1&&(l=1),a=r=l;break;default:a=r=1;break}const g=o*a,u=e*r;let f=0,h=0;return i.includes("Left")?f=0:i.includes("Right")?f=t-g:f=(t-g)/2,i.includes("Top")?h=0:i.includes("Bottom")?h=s-u:h=(s-u)/2,{scaleX:a,scaleY:r,tx:f,ty:h}}mapFontWeight(t){const s=t.toLowerCase();return s==="thin"||s==="100"?"100":s==="extralight"||s==="200"?"200":s==="light"||s==="300"?"300":s==="regular"||s==="normal"||s==="400"?"400":s==="medium"||s==="500"?"500":s==="semibold"||s==="600"?"600":s==="bold"||s==="700"?"700":s==="extrabold"||s==="800"?"800":s==="black"||s==="900"?"900":t}drawTextDecoration(t,s,o,e,n,i){t.beginPath();const a=Math.max(1,i/14);let r=e;s==="underline"?r=e+i*.12:s==="line-through"&&(r=e-i*.3),t.lineWidth=a,t.strokeStyle=t.fillStyle,t.moveTo(o-n/2,r),t.lineTo(o+n/2,r),t.stroke()}renderObject(t,s,o,e=!1,n=!1){var S,v,C,w,I,k,O,T,A,D,Y,B,R,L,$,F,X,M,E,P,_,V,G,x,U,q,N,H,z,et,Mt,ct,It,mt,kt,Ot;const i=this.objectStates.get(s.id);if(!i){this.warn("No state for object:",s.id);return}this.frameCount%60,t.roundRect||(t.roundRect=(vt,Wt,J,ut,$t)=>(this.drawRoundRect(t,vt,Wt,J,ut,$t),t));const a=i.geometry?this.deepMerge(s.geometry,i.geometry):s.geometry;let r=i.style?this.deepMerge(s.style,i.style):s.style,l=(a==null?void 0:a.width)||((S=s.geometry)==null?void 0:S.width)||s.width||0,d=(a==null?void 0:a.height)||((v=s.geometry)==null?void 0:v.height)||s.height||0;if((l===0||d===0)&&(a!=null&&a.points)&&Array.isArray(a.points)&&a.points.length>0){let vt=1/0,Wt=-1/0,J=1/0,ut=-1/0;a.points.forEach($t=>{vt=Math.min(vt,$t.x),Wt=Math.max(Wt,$t.x),J=Math.min(J,$t.y),ut=Math.max(ut,$t.y)}),l===0&&(l=Wt-vt),d===0&&(d=ut-J)}const p=vt=>{if(vt)return vt.corner_radius??vt.cornerRadius},g=p(a)??p(i)??p(r)??p(s.geometry)??p(s.style)??p(s)??0;let u={...a,width:l,height:d};if(delete u.cornerRadius,u.corner_radius=g,!u.type&&(s.type==="Frame"||s.type==="Component"||s.type==="Group")&&(u.type="Rectangle"),s.type==="Text"&&(u.type="Text"),u.type==="Path"&&s.weights&&s.bindMatrices&&u.points){const vt=this.getGlobalTransform(s.id);if(vt){const Wt=ni(u.points,s.weights,s.bindMatrices,vt,J=>this.getGlobalTransform(J));u={...u,points:Wt}}}if(i.visible===!1)return;const h=(r.effects||((C=s.style)==null?void 0:C.effects)||[]).find(vt=>vt.isEnabled!==!1&&vt.type==="PathDistortion");if(h){const vt=ai(u,l,d,h.amplitude||5,h.frequency||10,h.seed||0,h.direction||0,h.directionStrength||0);u={...u,type:"Path",points:vt}}const m=s.repeaterConfig,b=m&&m.isEnabled&&m.count>1,c=b?m.count:1;for(let vt=0;vt<c;vt++){let Wt=i.x!==void 0?i.x:((w=i.transform)==null?void 0:w.x)??0,J=i.y!==void 0?i.y:((I=i.transform)==null?void 0:I.y)??0,ut=i.rotation!==void 0?i.rotation:((k=i.transform)==null?void 0:k.rotation)??0,$t=i.scale_x!==void 0?i.scale_x:((O=i.transform)==null?void 0:O.scale_x)??1,St=i.scale_y!==void 0?i.scale_y:((T=i.transform)==null?void 0:T.scale_y)??1;if(b&&vt>0){if(m.type==="Linear"){const j=m.offsetX||0,bt=m.offsetY||0,st=m.rotation||0,K=m.scale!==void 0?m.scale:1;Wt+=vt*j,J+=vt*bt,ut+=vt*st,$t*=Math.pow(K,vt),St*=Math.pow(K,vt)}else if(m.type==="Grid"){const j=m.cols||Math.ceil(Math.sqrt(m.count)),bt=m.gapX||0,st=m.gapY||0,K=Math.floor(vt/j),rt=vt%j,ft=l+bt,Rt=d+st;Wt+=rt*ft,J+=K*Rt}else if(m.type==="Radial"){const j=m.radius||100,bt=m.startAngle||0,K=(m.endAngle||360)-bt,rt=m.count>1?K/(K===360?m.count:m.count-1):0,ft=bt+vt*rt,Rt=ft*Math.PI/180;Wt=i.x+j*Math.cos(Rt),J=i.y+j*Math.sin(Rt),ut+=ft}}const Pt=s.type==="Group"||s.type==="Frame"||s.type==="Component",Ft=l>0&&d>0;if(!Pt&&Ft&&!e){const j=(((A=r.shadow)==null?void 0:A.isEnabled)!==!1?(((D=r.shadow)==null?void 0:D.blur)||0)+10:0)+(((Y=r.blur)==null?void 0:Y.isEnabled)!==!1&&((B=r.blur)==null?void 0:B.radius)||0)+20;if(!this.isObjectInView(t,Wt,J,l,d,j))continue}this.debug_objectsRendered++,t.save();const lt=[],ht=r.blur||((R=s.style)==null?void 0:R.blur);ht&&ht.amount>0&&lt.push(`blur(${ht.amount}px)`);const dt=r.effects||((L=s.style)==null?void 0:L.effects)||[];let At=dt.find(j=>j.isEnabled!==!1&&(j.type==="BackgroundBlur"||j.type==="LayerBlur"));At||(At=r.effect||(($=s.style)==null?void 0:$.effect)||dt.find(j=>j.isEnabled!==!1));const Tt=At,Ct=(Tt==null?void 0:Tt.isEnabled)!==!1,Yt=Tt==null?void 0:Tt.type,ie=(Tt==null?void 0:Tt.radius)??10;Ct&&Yt==="LayerBlur"?lt.push(`blur(${ie}px)`):Ct&&Yt==="BackgroundBlur"&&(r===s.style&&(r={...r}),r.fill={type:"None"});const te=(u==null?void 0:u.adjustments)||(a==null?void 0:a.adjustments)||((F=s.geometry)==null?void 0:F.adjustments),Zt=(r==null?void 0:r.adjustments)||((X=s.style)==null?void 0:X.adjustments),le=((M=r==null?void 0:r.fill)==null?void 0:M.adjustments)||((P=(E=s.style)==null?void 0:E.fill)==null?void 0:P.adjustments),fe=s==null?void 0:s.adjustments,qt=te||Zt||le||fe;if(i&&qt&&(i.geometry=i.geometry||{},i.geometry.adjustments={...qt}),qt){const j=(qt.exposure||0)/100,bt=(qt.contrast||0)/100,st=(qt.saturation||0)/100,K=(qt.temperature||0)/200,rt=(qt.tint||0)/200,ft=(qt.highlights||0)/500,Rt=(qt.shadows||0)/500,Qt=qt.hue||0,Kt=(qt.negative||0)/100,ae=qt.blur||0;if(j!==0&&lt.push(`brightness(${1+j})`),bt!==0){const Et=bt>0?1+bt*2:1+bt;lt.push(`contrast(${Number(Et.toFixed(2))})`)}if(st!==0){const Et=st>0?1+st*1.5:1+st;lt.push(`saturate(${Number(Et.toFixed(2))})`)}const Jt=Qt+rt*30-K*20;Jt!==0&&lt.push(`hue-rotate(${Math.round(Jt)}deg)`),K>0&&lt.push(`sepia(${Math.round(K*40)}%)`),Kt!==0&&lt.push(`invert(${Math.abs(Kt)})`),ft!==0&&lt.push(`brightness(${1+ft})`),Rt!==0&&lt.push(`contrast(${1+Rt})`),ae>0&&lt.push(`blur(${ae}px)`)}lt.length>0?(t.filter=lt.join(" "),(!this._lastLoggedAdjustments||this._lastLoggedAdjustments!==t.filter)&&(this._lastLoggedAdjustments=t.filter,this.log(`[ExodeUI Engine] Applied Canvas Filter for (${s.name||s.id}): "${t.filter}" (Adjustments: ${JSON.stringify(qt)})`),console.log(`[ExodeUI Engine Log] Applied Canvas Filter for (${s.name||s.id}):`,{filter:t.filter,adjustments:qt}))):t.filter="none",t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high";const Se=t.globalAlpha,Ce=this.normalizeOpacity(i.opacity!==void 0?i.opacity:100);t.globalAlpha=Se*Ce;const Ie=i.compositeOperation||i.blendMode;if(Ie&&Ie!=="Normal"){const j=Ie.toLowerCase();["multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","source-over","source-in","source-out","source-atop","destination-over","destination-in","destination-out","destination-atop","lighter","copy","xor","multiply","screen"].includes(j)&&(t.globalCompositeOperation=j)}const de=t,Re=i.masks||(s.maskedBy?[{maskId:s.maskedBy,inverted:s.maskInverted===!0,type:s.maskType||"alpha",opacity:s.maskOpacity!==void 0?s.maskOpacity/100:1,feather:s.maskFeather||0,isVisible:!0}]:[]);let ye=!1;const ke=Re.filter(j=>j.isVisible!==!1&&o.has(j.maskId));if(ke.length>0){const j=ke[0],bt=o.get(j.maskId),st=this.objectStates.get(bt.id);st&&st.visible!==!1&&(ye=!0,(!this.maskBuffer||this.maskBuffer.width!==this.canvasWidth||this.maskBuffer.height!==this.canvasHeight)&&(this.maskBuffer=document.createElement("canvas"),this.maskBuffer.width=this.canvasWidth,this.maskBuffer.height=this.canvasHeight,this.maskCtx=this.maskBuffer.getContext("2d",{willReadFrequently:!0}),this.maskCtx&&(this.maskCtx.imageSmoothingEnabled=!0,this.maskCtx.imageSmoothingQuality="high")),this.maskCtx.setTransform(1,0,0,1,0,0),this.maskCtx.globalCompositeOperation="source-over",this.maskCtx.globalAlpha=1,this.maskCtx.filter="none",this.maskCtx.clearRect(0,0,this.maskBuffer.width,this.maskBuffer.height),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),s.parentId&&this.applyAbsoluteTransform(this.maskCtx,s.parentId,o),this.maskCtx.save(),this.maskCtx.globalAlpha=1,t=this.maskCtx,t.filter=de.filter)}if(!n){t.translate(Wt,J),t.rotate(ut*Math.PI/180);const j=i.skew_x||0,bt=i.skew_y||0;if(j!==0||bt!==0){const Kt=Math.tan(j*Math.PI/180),ae=Math.tan(bt*Math.PI/180);t.transform(1+Kt*ae,ae,Kt,1,0,0)}const st=i.rotate_x!==void 0?i.rotate_x:((_=i.transform)==null?void 0:_.rotate_x)??0,K=i.rotate_y!==void 0?i.rotate_y:((V=i.transform)==null?void 0:V.rotate_y)??0,ft=1+(i.translate_z!==void 0?i.translate_z:((G=i.transform)==null?void 0:G.translate_z)??0)/1e3,Rt=(i.flip_x===!0?-1:1)*Math.cos(K*Math.PI/180)*ft,Qt=(i.flip_y===!0?-1:1)*Math.cos(st*Math.PI/180)*ft;t.scale($t*Rt,St*Qt)}r.shadow&&r.shadow.isEnabled===void 0&&((r.shadow.blur||0)>0||Math.abs(r.shadow.offsetX||0)>0||Math.abs(r.shadow.offsetY||0)>0)&&(r.shadow.isEnabled=!0);const Vt=r.shadow;if(Vt&&Vt.isEnabled!==!1&&!e){let j=Vt.color||"#000000";(U=(x=this.artboard)==null?void 0:x.tokens)!=null&&U.colors&&this.artboard.tokens.colors[j]&&(j=this.artboard.tokens.colors[j]);const bt=this.normalizeOpacity(Vt.opacity??100)*.75,st=Vt.spread||0,rt=(Vt.blur||0)+st*1.5;let ft=j;if(j.startsWith("#")){const Kt=j.replace("#",""),ae=parseInt(Kt.substring(0,2),16),Jt=parseInt(Kt.substring(2,4),16),Et=parseInt(Kt.substring(4,6),16);ft=`rgba(${ae}, ${Jt}, ${Et}, ${bt})`}else if(j.startsWith("rgba")){const Kt=j.match(/[\d.]+/g);if(Kt&&Kt.length>=4){const ae=Kt[0],Jt=Kt[1],Et=Kt[2],W=Kt[3];ft=`rgba(${ae}, ${Jt}, ${Et}, ${parseFloat(W)*bt})`}}const Rt=t.getTransform(),Qt=Math.sqrt(Rt.a*Rt.a+Rt.b*Rt.b)||1;t.shadowColor=ft,t.shadowBlur=rt*Qt,t.shadowOffsetX=(Vt.offsetX||0)*Qt,t.shadowOffsetY=(Vt.offsetY||0)*Qt}const ee=s.liquidFill||((q=s.style)==null?void 0:q.liquidFill);if(ee&&ee.enabled){t.save();const j=ee.fillLevel??.5;t.beginPath();const bt=d/2-d*j;t.rect(-l/2,bt,l,d*j),t.clip(),t.fillStyle=ee.color||"#3b82f6",t.globalAlpha=t.globalAlpha*(ee.opacity??1)}if(e||this.applyOuterGlowUnderlay(t,s,u,l,d,g,r,o),(a==null?void 0:a.type)==="Text"||s.type==="Text")this._renderText(t,s,u,r,i,l,d,!1,!1);else if((a==null?void 0:a.type)==="Image"||((N=r.fill)==null?void 0:N.type)==="Image"||s.type==="Image"&&(a!=null&&a.src||(H=r.fill)!=null&&H.src)){const j=(a==null?void 0:a.originalSrc)||(a==null?void 0:a.src)||((z=r.fill)==null?void 0:z.originalSrc)||((et=r.fill)==null?void 0:et.src)||(s==null?void 0:s.src);if(j){let bt=this.imageCache.get(j);bt||(bt=new Image,bt.onload=()=>{this.log(`[ExodeUI] Image loaded successfully, size: ${bt.naturalWidth}x${bt.naturalHeight}`)},bt.onerror=rt=>{console.error("[ExodeUI] Image load failed:",rt,`Src preview: ${j.substring(0,100)}...`)},bt.src=j,this.imageCache.set(j,bt));const st=r.stroke&&r.stroke.width>0&&r.stroke.isEnabled!==!1,K=(((Mt=r.stroke)==null?void 0:Mt.alignment)||"center").toLowerCase();if(st&&K==="outside"&&this.applyStrokeAlignment(t,r,u,l,d,g),r.fill&&r.fill.type!=="None"){t.save();const rt=t.globalAlpha,ft=this.createCanvasFill(t,r.fill,l,d);t.fillStyle=ft||r.fill.color||"transparent",t.globalAlpha=rt*this.normalizeOpacity(r.fill.opacity??100),g!==0?(this.drawRoundRect(t,-l/2,-d/2,l,d,g),t.fill()):t.fillRect(-l/2,-d/2,l,d),t.globalAlpha=rt,t.restore()}if(bt.complete&&bt.naturalWidth>0){const rt=qt?this.processFabricAdjustmentsCanvas(bt,l,d,qt):bt;g!==0?(t.save(),this.drawRoundRect(t,-l/2,-d/2,l,d,g),t.clip(),t.drawImage(rt,-l/2,-d/2,l,d),t.restore()):t.drawImage(rt,-l/2,-d/2,l,d),st&&(K==="inside"||K==="center")&&this.applyStrokeAlignment(t,r,u,l,d,g)}else st&&(K==="inside"||K==="center")&&this.applyStrokeAlignment(t,r,u,l,d,g)}}else if(a.type==="SVG"){const j=a.svgContent;if(j){const bt=r.palette||[],st=r.fill,K=r.stroke,rt=st?this.normalizeOpacity(st.opacity??100):1,ft=K&&K.isEnabled!==!1?this.normalizeOpacity(K.opacity??100):1,Rt=(st==null?void 0:st.type)==="Solid"&&(!K||K.isEnabled===!1||K.type==="Solid"&&K.color===st.color&&ft===rt),Qt=st&&st.type!=="None"?Rt?"monochrome":st.type==="Solid"?(st.color||"")+"|opacity:"+rt:JSON.stringify(st.stops||[])+"|opacity:"+rt:"",Kt=K&&K.isEnabled!==!1&&(K.width||0)>0?Rt?["monochrome",K.width||0,K.trimStart??0,K.trimEnd??1,K.trimOffset??0,K.dashOffset??0].join("|"):[K.width||0,K.fill?K.fill.type==="Solid"?K.fill.color||"":JSON.stringify(K.fill.stops||[]):K.color||"",K.opacity??1,K.lineCap||"",K.lineJoin||"",(K.dashArray||[]).join(","),K.trimStart??0,K.trimEnd??1,K.trimOffset??0,K.dashOffset??0].join("|"):"nostroke",ae=[s.id,bt.join("_"),Qt,Kt,i.opacity??100,i.visible!==!1?"v":"h"].join("_");let Jt=this.imageCache.get(ae);if(!Jt){Jt=new Image,Jt.crossOrigin="anonymous";let W=j;W.match(/xmlns=["']http:\/\/www\.w3\.org\/2000\/svg["']/i)||(W=W.replace(/<svg([^>]*)>/i,(yt,Bt)=>`<svg xmlns="http://www.w3.org/2000/svg"${Bt}>`));let nt=a.width||l||100,Lt=a.height||d||100;const tt=W.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(tt&&(nt=parseFloat(tt[1]),Lt=parseFloat(tt[2])),W=W.replace(/<svg([^>]*)>/i,(yt,Bt)=>{let _t=Bt.replace(/\b(?:width|height)=["'][^"']*["']/gi," ");return _t.match(/\bviewBox=/i)||(_t+=` viewBox="0 0 ${nt} ${Lt}"`),_t.match(/\bpreserveAspectRatio=/i)||(_t+=' preserveAspectRatio="none"'),_t+=' width="100%" height="100%"',`<svg${_t}>`}),a.colors&&a.colors.length>0&&bt.length>0&&a.colors.forEach((yt,Bt)=>{if(bt[Bt]){const _t=yt.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),Xt=new RegExp(_t,"gi");W=W.replace(Xt,bt[Bt])}}),st&&st.type&&st.type!=="None"){if(st.type==="Solid"&&st.color){const yt=Rt?"#FFFFFF":st.color,Bt=Rt?1:this.normalizeOpacity(st.opacity??100);W=W.replace(/\bfill\s*=\s*["'][^"']*["']/gi,_t=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(_t)?_t:`fill="${yt}"`),W=W.replace(/fill\s*:\s*[^;"')]+/gi,_t=>/fill\s*:\s*(none|transparent)/i.test(_t)?_t:`fill:${yt}`),Bt<1&&(W=W.replace(/\bfill-opacity\s*=\s*["'][^"']*["']/gi,`fill-opacity="${Bt}"`),W=W.replace(/fill-opacity\s*:\s*[^;"')]+/gi,`fill-opacity:${Bt}`),W.match(/\bfill-opacity\s*=/i)||(W=W.replace(/(<svg[^>]*>)/i,`$1<g fill-opacity="${Bt}">`),W=W.replace(/<\/svg>/i,"</g></svg>")))}else if(st.type==="LinearGradient"||st.type==="RadialGradient"||st.type==="Linear"||st.type==="Radial"){const yt="exode-fill",Bt=this.normalizeOpacity(st.opacity??100),_t=(st.stops||[]).map(Dt=>{const ce=Dt.offset!==void 0?Dt.offset:Dt.pos??0,be=this.normalizeOpacity(Dt.opacity??100)*Bt;return`<stop offset="${ce*100}%" stop-color="${Dt.color||"#000"}" stop-opacity="${be}"/>`}).join("");let Xt="";if(st.type==="LinearGradient"||st.type==="Linear"){const Dt=(pe,he)=>Array.isArray(pe)?pe[he]??(he===0?0:1):pe&&typeof pe=="object"?pe[he===0?"x":"y"]??(he===0?0:1):he===0?0:1,ce=Dt(st.start,0)*100,be=Dt(st.start,1)*100,Le=Dt(st.end,0)*100,oe=Dt(st.end,1)*100;Xt=`<linearGradient id="${yt}" x1="${ce}%" y1="${be}%" x2="${Le}%" y2="${oe}%" gradientUnits="objectBoundingBox">${_t}</linearGradient>`}else{const Dt=(oe,pe)=>Array.isArray(oe)?oe[pe]??.5:oe&&typeof oe=="object"?oe[pe===0?"x":"y"]??.5:.5,ce=Dt(st.center,0)*100,be=Dt(st.center,1)*100,Le=(st.radius??.5)*100;Xt=`<radialGradient id="${yt}" cx="${ce}%" cy="${be}%" r="${Le}%" gradientUnits="objectBoundingBox">${_t}</radialGradient>`}/<defs>/i.test(W)?W=W.replace(/<defs>/i,`<defs>${Xt}`):W=W.replace(/<svg([^>]*)>/i,`<svg$1><defs>${Xt}</defs>`),W=W.replace(/\bfill\s*=\s*["'][^"']*["']/gi,Dt=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(Dt)?Dt:`fill="url(#${yt})"`),W=W.replace(/fill\s*:\s*[^;"')]+/gi,Dt=>/fill\s*:\s*(none|transparent)/i.test(Dt)?Dt:`fill:url(#${yt})`)}}const gt=(yt,Bt,_t=1)=>{const Xt=(yt.stops||[]).map(oe=>{const pe=oe.offset!==void 0?oe.offset:oe.pos??0,he=this.normalizeOpacity(oe.opacity??100)*_t;return`<stop offset="${pe*100}%" stop-color="${oe.color||"#000"}" stop-opacity="${he}"/>`}).join(""),Dt=(oe,pe,he=.5)=>Array.isArray(oe)?oe[pe]??he:oe&&typeof oe=="object"?oe[pe===0?"x":"y"]??he:he;if(yt.type==="LinearGradient"||yt.type==="Linear"){const oe=Dt(yt.start,0,0)*100,pe=Dt(yt.start,1,0)*100,he=Dt(yt.end,0,1)*100,$e=Dt(yt.end,1,1)*100;return`<linearGradient id="${Bt}" x1="${oe}%" y1="${pe}%" x2="${he}%" y2="${$e}%" gradientUnits="objectBoundingBox">${Xt}</linearGradient>`}const ce=Dt(yt.center,0,.5)*100,be=Dt(yt.center,1,.5)*100,Le=(yt.radius??.5)*100;return`<radialGradient id="${Bt}" cx="${ce}%" cy="${be}%" r="${Le}%" gradientUnits="objectBoundingBox">${Xt}</radialGradient>`},Q=(yt,Bt)=>/<defs>/i.test(yt)?yt.replace(/<defs>/i,`<defs>${Bt}`):yt.replace(/(<svg[^>]*>)/i,`$1<defs>${Bt}</defs>`);if(K&&K.isEnabled!==!1&&(K.width||0)>0){const yt=Rt?1:this.normalizeOpacity(K.opacity??100),Bt=Rt?"#FFFFFF":K.color||(st==null?void 0:st.color)||"#000000";let _t="";const Xt=K.fill;if(Xt&&Xt.type){if(Xt.type==="Solid")_t=Xt.color||K.color||"#000000";else if(Xt.type==="LinearGradient"||Xt.type==="RadialGradient"||Xt.type==="Linear"||Xt.type==="Radial"){const re="exode-stroke";W=Q(W,gt(Xt,re,yt)),_t=`url(#${re})`}}_t||(_t=Bt),W.match(/\bstroke\s*=\s*["']/i)?W=W.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,re=>/stroke\s*=\s*["']\s*(none|transparent)\s*["']/i.test(re)?re:`stroke="${_t}"`):W=W.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke="${_t}"`),W=W.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),`stroke:${_t}`);let Dt=a.width||l||100,ce=a.height||d||100;const be=j.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(be){const re=parseFloat(be[1]),ve=parseFloat(be[2]);!isNaN(re)&&!isNaN(ve)&&(Dt=re,ce=ve)}const Le=Math.max(.001,l/Dt),oe=Math.max(.001,d/ce),pe=(Le+oe)/2,he=(K.width||1)/pe;W.match(/\bstroke-width\s*=\s*["']/i)?W=W.replace(/\bstroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${he}"`):W=W.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-width="${he}"`),W=W.replace(/stroke-width\s*:\s*[^;"')]+/gi,`stroke-width:${he}`),W.match(/\bstroke-opacity\s*=\s*["']/i)?W=W.replace(/\bstroke-opacity\s*=\s*["'][^"']*["']/gi,`stroke-opacity="${yt}"`):W=W.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-opacity="${yt}"`),W=W.replace(/stroke-opacity\s*:\s*[^;"')]+/gi,`stroke-opacity:${yt}`);const $e=K.lineCap||"round";W.match(/\bstroke-linecap\s*=\s*["']/i)?W=W.replace(/\bstroke-linecap\s*=\s*["'][^"']*["']/gi,`stroke-linecap="${$e}"`):W=W.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linecap="${$e}"`),W=W.replace(/stroke-linecap\s*:\s*[^;"')]+/gi,`stroke-linecap:${$e}`);const Be=K.lineJoin||"round";W.match(/\bstroke-linejoin\s*=\s*["']/i)?W=W.replace(/\bstroke-linejoin\s*=\s*["'][^"']*["']/gi,`stroke-linejoin="${Be}"`):W=W.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linejoin="${Be}"`),W=W.replace(/stroke-linejoin\s*:\s*[^;"')]+/gi,`stroke-linejoin:${Be}`);const Ye=K.trimStart??0,De=K.trimEnd??1,Xe=K.trimOffset??0,Ne=K.dashOffset??0,Ue=Ye!==0||De!==1||Xe!==0||Ne!==0;if(Ue){const re=Math.max(0,Math.min(1,Ye)),ve=Math.max(0,Math.min(1,De));this.frameCount%600===0&&this.debugLog(`SVG Trim - Object: ${s.name||s.id}, Start: ${re}, End: ${ve}`);const Te=(Dt+ce)*2,He=(Xe%1+1)%1,Ve=(Ne%1+1)%1;let _e="",Pe=0;if(re>=ve)_e=`0 ${Te}`,Pe=0;else{const Z=Te*(ve-re),ot=Te-Z;Pe=-(Te*(re+He+Ve)),_e=`${Z} ${ot}`}W.match(/\bstroke-dasharray\s*=/i)?W=W.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${_e}"`):W=W.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dasharray="${_e}"`),W=W.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${_e}`),W.match(/\bstroke-dashoffset\s*=/i)?W=W.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${Pe}"`):W=W.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dashoffset="${Pe}"`),W=W.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${Pe}`)}else if(K.dashArray&&K.dashArray.length>0){const re=K.dashArray.join(" ");if(W=W.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${re}"`),W=W.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${re}`),K.dashOffset){const ve=(Dt+ce)*2,Te=-(K.dashOffset*ve);W=W.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${Te}"`),W=W.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${Te}`)}}if(!/\bstroke\s*=\s*["']/i.test(j)&&!new RegExp("(?<![a-z-])stroke\\s*:","i").test(j)){let re="",ve="";if(Ue){const _e=a.width||l||100,Pe=a.height||d||100,Z=(_e+Pe)*2,ot=Math.max(0,Math.min(1,Ye)),at=Math.max(0,Math.min(1,De)),wt=(Xe%1+1)%1,Gt=(Ne%1+1)%1;if(ot>=at)re=` stroke-dasharray="0 ${Z}"`,ve=' stroke-dashoffset="0"';else{const xt=Z*(at-ot),jt=Z-xt,me=-(Z*(ot+wt+Gt));re=` stroke-dasharray="${xt} ${jt}"`,ve=` stroke-dashoffset="${me}"`}}else(ct=K.dashArray)!=null&&ct.length&&(re=` stroke-dasharray="${K.dashArray.join(" ")}"`,K.dashOffset&&(ve=` stroke-dashoffset="${K.dashOffset}"`));const Te=` stroke-linecap="${K.lineCap||"round"}"`,He=` stroke-linejoin="${K.lineJoin||"round"}"`,Ve=`stroke="${_t}" stroke-width="${he}" stroke-opacity="${yt}"${Te}${He}${re}${ve}`;W=W.replace(/(<svg[^>]*>)(\s*(?:<defs>[\s\S]*?<\/defs>)?)/i,(_e,Pe,Z)=>`${Pe}${Z}<g ${Ve}>`),W=W.replace(/<\/svg>/i,"</g></svg>")}}else K&&K.isEnabled===!1&&(W=W.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,'stroke="none"'),W=W.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),"stroke:none"));const Ut=new Blob([W],{type:"image/svg+xml"}),zt=URL.createObjectURL(Ut);Jt.onload=()=>{if(URL.revokeObjectURL(zt),this.frameCount%900===0){const yt=this.imageCache.get(ae);yt&&this.debugLog(`SVG Payload Ready: ${s.name||s.id} (${yt.naturalWidth}x${yt.naturalHeight})`)}},Jt.onerror=()=>{URL.revokeObjectURL(zt),this.debugLog(`SVG Error: Failed to load payload for ${s.name||s.id}`)},Jt.src=zt,this.imageCache.set(ae,Jt)}let Et=null;if(Jt.complete&&Jt.naturalWidth>0?(Et=Jt,this.lastValidSvgImgMap.set(s.id,Jt)):Et=this.lastValidSvgImgMap.get(s.id)||null,Et&&Et.complete&&Et.naturalWidth>0){const W=Math.max(1,l),nt=Math.max(1,d);if(Rt&&(st==null?void 0:st.type)==="Solid"){this.maskBuffer||(this.maskBuffer=document.createElement("canvas"),this.maskCtx=this.maskBuffer.getContext("2d")),this.maskBuffer.width=W,this.maskBuffer.height=nt,this.maskCtx.setTransform(1,0,0,1,0,0),this.maskCtx.globalCompositeOperation="source-over",this.maskCtx.globalAlpha=1,this.maskCtx.filter="none",this.maskCtx.clearRect(0,0,W,nt),this.maskCtx.drawImage(Et,0,0,W,nt),this.maskCtx.globalCompositeOperation="source-in";const Lt=st.color||"#000000",tt=this.normalizeOpacity(st.opacity??100);this.maskCtx.fillStyle=Lt,this.maskCtx.globalAlpha=tt,this.maskCtx.fillRect(0,0,W,nt),t.drawImage(this.maskBuffer,-W/2,-nt/2,W,nt)}else g!==0?(t.save(),this.drawRoundRect(t,-W/2,-nt/2,W,nt,g),t.clip(),t.drawImage(Et,-W/2,-nt/2,W,nt),t.restore()):t.drawImage(Et,-W/2,-nt/2,W,nt)}}}else if(u.type==="LineGraph"||s.type==="LineGraph"||this.isLineGraphObject(s))this.renderLineGraph(t,s,u,l,d);else if(s.type==="Shape"){if(this.applyPath(t,u,l,d,g),t.save(),r.blur&&r.blur.amount>0&&(t.filter=`blur(${r.blur.amount}px)`),Ct&&Yt==="BackgroundBlur")if(e)t.fillStyle="#000000",t.globalAlpha=1,this.applyPath(t,u,l,d,g),t.fill();else{if(t.shadowColor&&t.shadowColor!=="rgba(0, 0, 0, 0)"&&t.shadowColor!=="transparent"){const st=t.getTransform(),K=t.shadowOffsetX,rt=t.shadowOffsetY;t.shadowOffsetX=K+1e4*st.a,t.shadowOffsetY=rt+1e4*st.b,t.save(),t.translate(-1e4,0),this.applyPath(t,u,l,d,g),t.fillStyle="white",t.fill(),t.restore(),t.shadowOffsetX=K,t.shadowOffsetY=rt,t.shadowColor="transparent"}this.applyBackgroundBlurGlass(t,u,l,d,g,Tt,r)}else if(r.fill){const bt=t.globalAlpha;if(((It=r.fill)==null?void 0:It.type)==="Image"&&(r.fill.originalSrc||r.fill.src)){const st=r.fill.originalSrc||r.fill.src;let K=this.imageCache.get(st);K||(K=new Image,K.src=st,this.imageCache.set(st,K)),K.complete&&K.naturalWidth>0&&(t.save(),this.applyPath(t,u,l,d,g),t.clip(),this.renderFittedImage(t,K,-l/2,-d/2,l,d,r.fill.fillMode),t.restore())}else{const st=this.createCanvasFill(t,r.fill,l,d);t.fillStyle=st||(typeof r.fill=="string"?r.fill:r.fill.color||"transparent"),t.globalAlpha=bt*this.normalizeOpacity(r.fill.opacity??100),this.applyPath(t,u,l,d,g),t.fill()}t.globalAlpha=bt}t.restore(),r.stroke&&r.stroke.width>0&&(this.applyPath(t,u,l,d,g),this.applyStrokeAlignment(t,r,u,l,d,g))}else if(s.type==="Frame"||s.type==="Component"&&!s.variant||s.type==="Group"&&!s.isStructuralGroup){const j=i.width??a.width??s.width??l,bt=i.height??a.height??s.height??d,st=g;if(t.save(),t.beginPath(),this.drawRoundRect(t,-j/2,-bt/2,j,bt,st),Ct&&Yt==="BackgroundBlur")if(e)t.fillStyle="#000000",t.globalAlpha=1,t.beginPath(),this.drawRoundRect(t,-j/2,-bt/2,j,bt,st),t.fill();else{if(t.shadowColor&&t.shadowColor!=="rgba(0, 0, 0, 0)"&&t.shadowColor!=="transparent"){const ft=t.getTransform(),Rt=t.shadowOffsetX,Qt=t.shadowOffsetY;t.shadowOffsetX=Rt+1e4*ft.a,t.shadowOffsetY=Qt+1e4*ft.b,t.save(),t.translate(-1e4,0),t.beginPath(),this.drawRoundRect(t,-j/2,-bt/2,j,bt,st),t.fillStyle="white",t.fill(),t.restore(),t.shadowOffsetX=Rt,t.shadowOffsetY=Qt,t.shadowColor="transparent"}this.applyBackgroundBlurGlass(t,u,j,bt,st,Tt,r)}else if(r.fill&&r.fill.type!=="None"){const rt=t.globalAlpha;if(((mt=r.fill)==null?void 0:mt.type)==="Image"&&(r.fill.originalSrc||r.fill.src)){const ft=r.fill.originalSrc||r.fill.src;let Rt=this.imageCache.get(ft);Rt||(Rt=new Image,Rt.src=ft,this.imageCache.set(ft,Rt)),Rt.complete&&Rt.naturalWidth>0&&(t.save(),t.beginPath(),this.drawRoundRect(t,-j/2,-bt/2,j,bt,st),t.clip(),this.renderFittedImage(t,Rt,-j/2,-bt/2,j,bt,r.fill.fillMode),t.restore())}else{const ft=this.createCanvasFill(t,r.fill,j,bt);t.fillStyle=ft||r.fill.color||"transparent",t.globalAlpha=rt*this.normalizeOpacity(r.fill.opacity??100),t.beginPath(),this.drawRoundRect(t,-j/2,-bt/2,j,bt,st),t.fill(),t.globalAlpha=rt}}if(t.restore(),!e&&(Ct&&Yt==="BackgroundBlur"||r.fill&&r.fill.type!=="None")&&(t.shadowColor="transparent"),r.stroke&&r.stroke.width>0&&r.stroke.isEnabled!==!1){const rt={type:"Rectangle"};t.beginPath(),this.drawRoundRect(t,-j/2,-bt/2,j,bt,st),this.applyStrokeAlignment(t,r,rt,j,bt,st)}}else s.type==="Group"&&s.isStructuralGroup||(s.type==="Component"&&s.variant==="inputbox"?this.renderInputBox(t,s):s.type==="Button"||s.type==="Component"&&(s.variant==="button"||(s.name||"").toLowerCase().includes("button")||(s.name||"").toLowerCase().includes("cta"))?this.renderButton(t,s):s.type==="Component"&&s.variant==="toggle_button"?this.renderToggleButton(t,s):s.type==="Toggle"||s.type==="Component"&&s.variant==="toggle"?this.renderToggle(t,s):s.type==="Slider"||s.type==="Component"&&s.variant==="slider"?this.renderSlider(t,s):s.type==="Dropdown"||s.type==="Component"&&s.variant==="dropdown"?this.renderDropdown(t,s):s.type==="ListView"||s.type==="Component"&&s.variant==="listview"?this.renderListView(t,s):s.type==="Checkbox"||((kt=s.geometry)==null?void 0:kt.type)==="Checkbox"||s.type==="Component"&&s.variant==="checkbox"?this.renderCheckbox(t,s):s.type==="RadioGroup"||s.type==="Component"&&s.variant==="radiogroup"?this.renderRadioGroup(t,s):s.type==="BarChart"||s.type==="Component"&&s.variant==="barchart"?this.renderBarChart(t,s):s.type==="PieChart"||s.type==="Component"&&s.variant==="piechart"?this.renderPieChart(t,s):s.type==="Joystick"||s.type==="Component"&&s.variant==="joystick"?this.renderJoystick(t,s):this.frameCount%300===0&&this.warn("[Engine] Unhandled object type in renderObject:",s.type,"Geo:",(Ot=s.geometry)==null?void 0:Ot.type));if(e||(this.applyInnerGlowOverlay(t,s,u,l,d,g,r),this.applyArtEffectOverlay(t,s,u,l,d,g)),ee&&ee.enabled&&t.restore(),s.children&&s.children.length>0){const bt=s.type==="Frame",st=s.clipsContent!==void 0?s.clipsContent:s.clipContent!==void 0?s.clipContent:bt;if(t.save(),st){t.beginPath();const rt=i.width??(a==null?void 0:a.width)??s.width??0,ft=i.height??(a==null?void 0:a.height)??s.height??0,Rt=i.cornerRadius??(a==null?void 0:a.corner_radius)??s.cornerRadius??0;this.drawRoundRect(t,-rt/2,-ft/2,rt,ft,Rt),t.clip()}let K=0;for(s.children.forEach(rt=>{const ft=o.get(rt);if(!ft)return;const Rt=this.objectStates.get(rt),Qt=(Rt==null?void 0:Rt.geometry)||ft.geometry;if(Qt&&Qt.isMask&&(Rt==null?void 0:Rt.visible)!==!1){const Kt=Qt.width||0,ae=Qt.height||0;this.applyObjectTransform(t,rt);const Jt=(Rt==null?void 0:Rt.corner_radius)??(Qt==null?void 0:Qt.corner_radius)??0;this.applyPath(t,Qt,Kt,ae,Jt),t.clip(),K++}else this.renderObject(t,ft,o,e)});K>0;)t.restore(),K--;t.restore()}if(ye){this.maskCtx.restore(),(i.masks||(s.maskedBy?[{maskId:s.maskedBy,inverted:s.maskInverted===!0,type:s.maskType||"alpha",opacity:s.maskOpacity!==void 0?s.maskOpacity/100:1,feather:s.maskFeather||0,isVisible:!0}]:[])).filter(K=>K.isVisible!==!1&&o.has(K.maskId)).forEach(K=>{var Jt,Et,W,nt,Lt,tt;const rt=o.get(K.maskId),ft=this.objectStates.get(rt.id),Rt=K.feather||0,Qt=K.inverted===!0,Kt=K.opacity!==void 0?typeof K.opacity=="number"?K.opacity:K.opacity/100:1;if((K.type||"alpha")==="luma"){(!this.lumaBuffer||this.lumaBuffer.width!==this.maskBuffer.width||this.lumaBuffer.height!==this.maskBuffer.height)&&(this.lumaBuffer=document.createElement("canvas"),this.lumaBuffer.width=this.maskBuffer.width,this.lumaBuffer.height=this.maskBuffer.height,this.lumaCtx=this.lumaBuffer.getContext("2d",{willReadFrequently:!0}),this.lumaCtx&&(this.lumaCtx.imageSmoothingEnabled=!0,this.lumaCtx.imageSmoothingQuality="high")),this.lumaCtx.setTransform(1,0,0,1,0,0),this.lumaCtx.globalCompositeOperation="source-over",this.lumaCtx.globalAlpha=1,this.lumaCtx.filter="none",this.lumaCtx.clearRect(0,0,this.lumaBuffer.width,this.lumaBuffer.height),this.lumaCtx.save(),this.rootTransform&&this.lumaCtx.setTransform(this.rootTransform),this.applyAbsoluteTransform(this.lumaCtx,rt.id,o),Rt>0&&(this.lumaCtx.filter=`blur(${Rt}px)`),this.lumaCtx.globalAlpha=Kt;const gt=(ft==null?void 0:ft.width)||rt.geometry.width||0,Q=(ft==null?void 0:ft.height)||rt.geometry.height||0,Ut=(ft==null?void 0:ft.corner_radius)??rt.corner_radius??0;if(((Jt=rt.geometry)==null?void 0:Jt.type)==="Text"){const _t=ft!=null&&ft.geometry?this.deepMerge(rt.geometry,ft.geometry):rt.geometry,Xt=ft!=null&&ft.style?this.deepMerge(rt.style,ft.style):rt.style;this._renderText(this.lumaCtx,rt,{..._t,width:gt,height:Q,corner_radius:Ut},Xt,ft,gt,Q,!0,!1)}else if(((Et=rt.geometry)==null?void 0:Et.type)==="Image"){const _t=rt.geometry.src;if(_t){let Xt=this.imageCache.get(_t);Xt||(Xt=new Image,Xt.src=_t,this.imageCache.set(_t,Xt)),Xt.complete&&Xt.naturalWidth>0?this.lumaCtx.drawImage(Xt,-gt/2,-Q/2,gt,Q):(this.applyPath(this.lumaCtx,rt.geometry,gt,Q,Ut),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else if(((W=rt.geometry)==null?void 0:W.type)==="SVG"){const _t=rt.geometry.svgContent;if(_t){const Xt=`__lumamask_${rt.id}`;let Dt=this.imageCache.get(Xt);if(!Dt){Dt=new Image;const ce=new Blob([_t],{type:"image/svg+xml"});Dt.src=URL.createObjectURL(ce),Dt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(Xt,Dt)}Dt.complete&&Dt.naturalWidth>0?this.lumaCtx.drawImage(Dt,-gt/2,-Q/2,gt,Q):(this.applyPath(this.lumaCtx,rt.geometry,gt,Q,Ut),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else this.applyPath(this.lumaCtx,rt.geometry,gt,Q,Ut),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill();this.lumaCtx.restore();const zt=this.maskCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight),yt=this.lumaCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight).data,Bt=zt.data;for(let _t=0;_t<Bt.length;_t+=4){const Xt=yt[_t],Dt=yt[_t+1],ce=yt[_t+2];let be=(.299*Xt+.587*Dt+.114*ce)/255;Qt&&(be=1-be),Bt[_t+3]*=be}this.maskCtx.putImageData(zt,0,0)}else{this.maskCtx.save(),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),this.maskCtx.globalCompositeOperation=Qt?"destination-out":"destination-in",Rt>0&&(this.maskCtx.filter=`blur(${Rt}px)`),this.maskCtx.globalAlpha=Kt,this.applyAbsoluteTransform(this.maskCtx,rt.id,o);const gt=(ft==null?void 0:ft.width)||rt.geometry.width||0,Q=(ft==null?void 0:ft.height)||rt.geometry.height||0,Ut=(ft==null?void 0:ft.corner_radius)??rt.corner_radius??0;if(((nt=rt.geometry)==null?void 0:nt.type)==="Text"){const zt=ft!=null&&ft.geometry?this.deepMerge(rt.geometry,ft.geometry):rt.geometry,yt=ft!=null&&ft.style?this.deepMerge(rt.style,ft.style):rt.style;this._renderText(this.maskCtx,rt,{...zt,width:gt,height:Q,corner_radius:Ut},yt,ft,gt,Q,!0,!1)}else if(((Lt=rt.geometry)==null?void 0:Lt.type)==="Image"){const zt=rt.geometry.src;if(zt){let yt=this.imageCache.get(zt);yt||(yt=new Image,yt.src=zt,this.imageCache.set(zt,yt)),yt.complete&&yt.naturalWidth>0?this.maskCtx.drawImage(yt,-gt/2,-Q/2,gt,Q):(this.applyPath(this.maskCtx,rt.geometry,gt,Q,Ut),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else if(((tt=rt.geometry)==null?void 0:tt.type)==="SVG"){const zt=rt.geometry.svgContent;if(zt){const yt=`__alphamask_${rt.id}`;let Bt=this.imageCache.get(yt);if(!Bt){Bt=new Image;const _t=new Blob([zt],{type:"image/svg+xml"});Bt.src=URL.createObjectURL(_t),Bt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(yt,Bt)}Bt.complete&&Bt.naturalWidth>0?this.maskCtx.drawImage(Bt,-gt/2,-Q/2,gt,Q):(this.applyPath(this.maskCtx,rt.geometry,gt,Q,Ut),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else this.applyPath(this.maskCtx,rt.geometry,gt,Q,Ut),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill();this.maskCtx.restore()}}),de.save(),de.setTransform(1,0,0,1,0,0);const st=s.maskBlendMode||s.blendMode;st&&st!=="Normal"&&(de.globalCompositeOperation=st.toLowerCase()),de.drawImage(this.maskBuffer,0,0),de.restore(),de.restore()}else t.restore()}}applyOuterGlowUnderlay(t,s,o,e,n,i,a,r){var k,O,T;const l=a||s.style||{},d=l.effect,p=l.effects||(d?[d]:[]),g=p.find(A=>A.isEnabled!==!1&&A.type==="Glow"&&(A.mode==="outer"||A.mode==="Outer Glow"||!A.mode));if(!g)return;const u=g.blur||10,f=1e4;let h=g.color||"white";(O=(k=this.artboard)==null?void 0:k.tokens)!=null&&O.colors&&this.artboard.tokens.colors[h]&&(h=this.artboard.tokens.colors[h]),t.save();const m=l.fill&&l.fill.type!=="None",b=p.some(A=>A.isEnabled!==!1&&A.type==="BackgroundBlur"),c=s.type==="Text",S=s.type==="Group";!c&&!S&&(m||b)&&(t.beginPath(),t.rect(-1e6,-1e6,2e6,2e6),s.type==="Frame"||s.type==="Component"?this.drawRoundRect(t,-e/2,-n/2,e,n,i):this._tracePath(t,o,e,n,i),t.clip("evenodd"));const v=t.getTransform();t.shadowColor=h,t.shadowBlur=u,t.shadowOffsetX=f*v.a,t.shadowOffsetY=f*v.b,t.translate(-f,0);let C="black";l.fill&&l.fill.type!=="None"&&(C=this.createCanvasFill(t,l.fill,e,n)||l.fill.color||"black");let w="black";l.stroke&&l.stroke.width>0&&(w=this.createCanvasFill(t,l.stroke.fill||{type:"Solid",color:l.stroke.color},e,n)||l.stroke.color||"black"),t.fillStyle=C,t.strokeStyle=w,t.lineWidth=((T=l.stroke)==null?void 0:T.width)||0;const I=Math.min(g.intensity||1,10);for(let A=0;A<I;A++)if(r)this.renderObject(t,s,r,!0,!0);else if(o.type==="Text")l.fill&&l.fill.type!=="None"&&t.fillText(s.text||"",0,0),l.stroke&&l.stroke.width>0&&t.strokeText(s.text||"",0,0);else if(o.points&&o.type==="Path")this.applyPath(t,o,e,n,i),l.fill&&l.fill.type!=="None"&&t.fill(),l.stroke&&l.stroke.width>0&&t.stroke();else{if(t.beginPath(),o.type==="circle"||o.type==="Ellipse"){const B=e/2,R=n/2;t.ellipse(0,0,B,R,0,0,Math.PI*2)}else i!==0?this.drawRoundRect(t,-e/2,-n/2,e,n,i):t.rect(-e/2,-n/2,e,n);const D=l.fill&&l.fill.type!=="None",Y=l.stroke&&l.stroke.width>0;(D||!D&&!Y)&&t.fill(),Y&&t.stroke()}t.restore()}_renderText(t,s,o,e,n,i,a,r=!1,l=!1){var et,Mt,ct,It,mt,kt,Ot,vt,Wt;let d=(o==null?void 0:o.text)||(s==null?void 0:s.text)||(s==null?void 0:s.name)||"";if(o.textInputId&&!r){const J=this.inputs.get(o.textInputId);J!==void 0&&(d=String(J),n.geometry&&n.geometry.type==="Text"&&(n.geometry.text=d))}if(o.svgPath){const J=o.svgPath;t.save();const ut=((et=e==null?void 0:e.fill)==null?void 0:et.color)||"#000000",$t=((Mt=e==null?void 0:e.fill)==null?void 0:Mt.opacity)!==void 0?(ct=e==null?void 0:e.fill)==null?void 0:ct.opacity:1;t.fillStyle=ut,t.globalAlpha*=$t;const St=new Path2D(J);t.fill(St),t.restore();return}let p=d||"";o.enableSegments===!0&&o.segments&&Array.isArray(o.segments)&&(p=o.segments.map(J=>J&&J.text?J.text:"").join(""));const g=o.textCase||"none";g==="uppercase"?p=p.toUpperCase():g==="lowercase"?p=p.toLowerCase():g==="capitalize"&&(p=p.replace(/\b\w/g,J=>J.toUpperCase()));let u=((It=o.fontWeight)==null?void 0:It.toString())||"400",f=o.fontStyle||"normal";u.toLowerCase().includes("italic")&&(f="italic",u=u.replace(/italic/gi,"").trim()||"400");const h=this.mapFontWeight(u),m=Math.max(1,o.fontSize||32);let b=o.fontFamily||"Inter";const c=["Bold","SemiBold","Medium","Regular","Light","Thin","ExtraBold","Black","Italic"];c.forEach(J=>{const ut=new RegExp(`[\\s-]${J}$`,"i");ut.test(b)&&(b=b.replace(ut,"").trim())});const S=o.smallCaps===!0,C=`${S?"small-caps ":""}${f} ${h} ${m}px "${b}", sans-serif`;t.font=C;const w=o.textVerticalAlign||"top";t.textBaseline="top";const I=o.textAlign||"left";t.textAlign=I;let k=0;if(typeof o.letterSpacing=="number")k=o.letterSpacing;else if(typeof o.letterSpacing=="object"&&o.letterSpacing.value!==void 0){const J=o.letterSpacing;k=J.unit==="PERCENT"?J.value/100*m:J.value}t.letterSpacing!==void 0&&(t.letterSpacing=`${k}px`);const O=o.kerning||"auto",T=o.kerningValue||0;O==="manual"&&T!==0&&(t.letterSpacing=`${k+T}px`);const A=o.paragraphSpacing||0;let D=o.lineHeight??1.2;typeof D=="string"&&(D=parseFloat(D)),D>5&&m>0&&(D=D/m);const Y=(D||1.2)*m,B=o.isPointText===!0||!o.width||o.width<=0,R=((mt=o.padding)==null?void 0:mt.left)||((kt=o.padding)==null?void 0:kt.right)||0,L=B?1e5:o.width&&o.width>0?Math.ceil(o.width)-R*2:1e5;o.autoHeight;const $=ss({text:p,fontFamily:b,fontSize:m,fontWeight:h,fontStyle:f,lineHeight:D,width:L,letterSpacing:k,paragraphSpacing:A,paragraphIndent:o.paragraphIndent||0,segments:o.segments,enableSegments:o.enableSegments,textCase:g,hyphenation:o.hyphenation,composer:o.composer,balanceRaggedLines:o.balanceRaggedLines}),F=$.lines||[],X=$.maxFontSize||m,M=this.fontLeadingFactors[b]??.5,E=(Y-m)*M;let P=$.height,_=i,V=a;if(_===0||V===0||_>=1e5||B){let J=0,ut=0;const $t=$.fullText||p;(F||[]).forEach(St=>{const Pt=St.text||"",Ft=t.measureText(Pt).width+(Pt.length>0?(Pt.length-1)*k:0);Ft>J&&(J=Ft),ut+=Pt.length,ut<$t.length&&($t[ut]===`
8
+ `||$t[ut]==="\r")&&(ut++,$t[ut-1]==="\r"&&$t[ut]===`
9
+ `&&ut++)}),(_===0||_>=1e5)&&(_=J),V===0&&(V=P||0)}let G=-P/2;a>0&&a>P&&(w==="top"?G=-a/2:w==="middle"||w==="center"?G=-P/2:w==="bottom"&&(G=a/2-P));const x=w==="top"&&a>0?0:E;let U=G+x+E,q=null,N=0;if(o.pathId&&this.artboard){const J=this.artboard.objects.find(ut=>ut.id===o.pathId);if(J&&J.type==="Shape"&&((Ot=J.geometry)==null?void 0:Ot.type)==="Path"){const ut=this.objectStates.get(J.id),$t=ut!=null&&ut.geometry?this.deepMerge(J.geometry,ut.geometry):J.geometry,St=(ut==null?void 0:ut.scale_x)!==void 0?(J.width||0)*ut.scale_x:J.width||0,Pt=(ut==null?void 0:ut.scale_y)!==void 0?(J.height||0)*ut.scale_y:J.height||0;q={geo:$t,obj:J,w:St,h:Pt},N=this.getPerimeter($t,St,Pt)}}const H=(J,ut)=>{var St,Pt;if(!k&&!S&&!r&&(!o.enableSegments||!((St=o.segments)!=null&&St.length)))return t.measureText(J).width;let $t=0;for(let Ft=0;Ft<J.length;Ft++){const lt=ut+Ft;let ht=0;if(o.enableSegments===!0&&((Pt=o.segments)==null?void 0:Pt.length)>0){let dt=0,At=null;for(const Tt of o.segments){if(lt<dt+(Tt.text||"").length){At=Tt;break}dt+=(Tt.text||"").length}if(At){t.save();let Tt=At.fontFamily||o.fontFamily||"Inter";const Ct=this.mapFontWeight((At.fontWeight||o.fontWeight||"400").toString()),Yt=At.fontStyle||f,ie=At.fontSize||m;t.font=`${Yt} ${Ct} ${ie}px "${Tt}", sans-serif`,ht=t.measureText(J[Ft]).width,t.restore()}else ht=t.measureText(J[Ft]).width}else ht=t.measureText(J[Ft]).width;$t+=ht+k}return $t-(J.length>0?k:0)},z=(J,ut,$t,St,Pt)=>{var ie,te;const lt=(Pt===0||p[Pt-1]===`
10
+ `||p[Pt-1]==="\r")&&o.paragraphIndent?o.paragraphIndent:0,ht=(!r||l)&&(s.behaviors||[]).some(Zt=>Zt.enabled&&(Zt.type.toString().includes("Text")||["Typewriter","Scramble","Wave","Bounce","GlitchText","Reveal3D","RevealSlide","RevealBlur"].includes(Zt.type))),dt=!o.pathId&&!ht&&(o.enableSegments!==!0||!o.segments||o.segments.length===0),At=o.baselineShift||0,Tt=$t+At,Ct=H(J,Pt);let Yt=ut+lt;if(I==="center"?Yt-=Ct/2:I==="right"&&(Yt-=Ct),dt){t.font=C;const Zt=t.textAlign;t.textAlign="left",St?t.strokeText(J,Yt,Tt):t.fillText(J,Yt,Tt),t.textAlign=Zt}else{const Zt=t.textAlign;t.textAlign="left";const le=Pt+J.length>=p.length||p[Pt+J.length]===`
11
+ `||p[Pt+J.length]==="\r";let fe=0,qt=0;const Se=o.justifyMinWordSpacing,Ce=o.justifyMaxWordSpacing;if(I==="justify"&&!le&&Ct>0&&!o.pathId){const ye=B?Ct:L-R*2+0,ke=Math.max(0,ye-Ct);for(let Vt=0;Vt<J.length;Vt++)J[Vt]===" "&&qt++;if(qt>0){const Vt=t.measureText(" ").width;let ee=Se||Vt*.5,j=Ce||Vt*2.5;fe=Math.max(0,Math.min(ke/qt,j-ee))}}let Ie=o.pathOffset||0;o.pathId&&N>0&&q&&(I==="center"?Ie+=N/2-Ct/2:I==="right"&&(Ie+=N-Ct));let de=Yt;const Re=r&&!l?[]:((ie=s.behaviors)==null?void 0:ie.filter(ye=>[it.Typewriter,it.Scramble,it.Wave,it.Bounce,it.GlitchText,it.TextTrail,it.Reveal3D,it.RevealSlide,it.RevealBlur,it.TextLiquid,it.TextVortex,it.TextExplosion,it.TextRain,it.TextGravity,it.TextElastic,it.TextMatrix,it.TextNeon,it.TextGlitch3D,it.TextDissolve,it.TextOrganic,it.TextBreathe,it.TextFloral,it.TextSmoke,it.TextVariable,it.TextMagnet,it.TextSpin,it.TextZing,it.TextPerspective,it.TextMirror].includes(ye.type)&&ye.enabled))||[];for(let ye=0;ye<J.length;ye++){let ke=J[ye];const Vt=Pt+ye;let ee=0,j=0,bt=1,st=1,K=0,rt=1,ft=ke;Re.forEach(Et=>{const W=Et.settings||{},nt=W.strength||1,Lt=Date.now();if(Et.type===it.Typewriter)this.currentTime*(W.speed||1)-Vt*(W.stagger||.05)<0&&(rt=0);else if(Et.type===it.Scramble)Math.max(0,Math.min(1,this.currentTime/(W.duration||1.5))-Vt*.02)<1&&Math.random()<.3&&(ft="$%#@!*&"[Math.floor(Math.random()*7)]);else if(Et.type===it.Wave)j+=Math.sin(this.currentTime*5*(W.speed||1)+Vt*(W.frequency||1))*(W.amplitude||20)*nt;else if(Et.type===it.Bounce){const tt=Math.max(0,this.currentTime%2-Vt*(W.stagger||.1));tt<1&&(j-=Math.abs(Math.sin(tt*Math.PI))*(W.height||50)*nt)}else if(Et.type===it.TextTrail){const tt=this.pointerHistory[Math.max(0,this.pointerHistory.length-1-Vt*(W.delay||5))];tt&&(ee+=(tt.x-(n.x+de))*nt*.2,j+=(tt.y-(n.y+$t+j))*nt*.2)}else if(Et.type===it.Reveal3D){const tt=Math.max(0,Math.min(1,this.currentTime*(W.speed||1)-Vt*(W.stagger||.1)));bt*=tt,st*=tt,rt=tt}else if(Et.type===it.RevealSlide){const tt=Math.max(0,Math.min(1,this.currentTime*1.5-Vt*.05)),gt=(1-tt)*(W.distance||40)*nt,Q=W.direction||"up";Q==="up"?j-=gt:Q==="down"?j+=gt:Q==="left"?ee-=gt:Q==="right"&&(ee+=gt),rt=tt}else if(Et.type===it.RevealBlur){const tt=Math.max(0,Math.min(1,this.currentTime*1.2-Vt*.1));rt=tt,ee+=(1-tt)*5}else if(Et.type===it.TextLiquid){const tt=Math.max(0,Math.sin(Lt*.001*(W.speed||1)+Vt*.5));j+=tt*(W.amplitude||10)*nt,st*=1+tt*.2}else if(Et.type===it.TextVortex){const tt=Lt*.002*(W.speed||1)+Vt*.2,gt=(1-(Math.sin(Lt*.001)*.5+.5))*(W.radius||50);ee+=Math.cos(tt)*gt*nt,j+=Math.sin(tt)*gt*nt}else if(Et.type===it.TextExplosion){const tt=W.force||1,gt=this.currentTime%2;if(gt<1){const Q=(Vt/J.length-.5)*Math.PI*2,Ut=gt*100*tt;ee+=Math.cos(Q)*Ut*nt,j+=Math.sin(Q)*Ut*nt,rt=1-gt}}else if(Et.type===it.TextRain){const tt=W.speed||1,gt=W.height||100,Q=(Lt*.001*tt+Vt*.1)%1;j-=(1-Q)*gt*nt,rt=Q>.1?1:Q*10}else if(Et.type===it.TextGravity){const tt=W.gravity||9.8,gt=this.currentTime%3/3,Q=.5*tt*Math.pow(gt*10,2);Q<100?j+=Q*nt:j+=100*nt}else if(Et.type===it.TextMatrix){const tt=W.speed||1;if(Math.random()<.1*tt){const Q="0123456789ABCDEF!@#$%^&*";ft=Q[Math.floor(Math.random()*Q.length)]}rt=.3+(Math.sin(Lt*.01*tt+Vt)+1)/2*.7}else if(Et.type===it.TextNeon){const tt=Math.random()>.95?.5:1;rt=(.7+(Math.sin(Lt*.005)+1)/2*.3)*tt}else if(Et.type===it.TextDissolve)Math.sin(Vt*1.5+Lt*.002*(W.speed||1))>.5&&(rt=0);else if(Et.type===it.TextOrganic){const tt=W.speed||1,gt=W.amplitude||10;ee+=Math.sin(Lt*.002*tt+Vt)*gt*nt,j+=Math.cos(Lt*.0015*tt+Vt*.7)*gt*nt}else if(Et.type===it.TextBreathe){const gt=1+(Math.sin(Lt*.003+Vt*.2)+1)/2*.2*nt;bt*=gt,st*=gt}else if(Et.type===it.TextSpin){const tt=W.speed||1;K+=Lt*.01*tt+Vt}else if(Et.type===it.TextMagnet){const tt=this.pointerHistory[this.pointerHistory.length-1];if(tt){const gt=tt.x-(n.x+de),Q=tt.y-(n.y+$t);K=Math.atan2(Q,gt)}}else if(Et.type===it.TextPerspective){const tt=J.length/2,gt=(Vt-tt)/tt,Q=1-Math.abs(gt)*.3*nt;bt*=Q,st*=Q,ee+=gt*20*nt}else if(Et.type===it.TextMirror)rt*=.8;else if(Et.type===it.TextFloral){const tt=W.speed||1,gt=W.stagger||.1,Q=(Lt*.001*tt+Vt*gt)%2;Q<1&&(bt*=Q,st*=Q,K+=Q*Math.PI)}else if(Et.type===it.TextSmoke){const tt=W.speed||1,gt=W.height||50,Q=(Lt*5e-4*tt+Vt*.2)%1;j-=Q*gt*nt,ee+=Math.sin(Lt*.002+Vt)*5*nt,rt=1-Q}else if(Et.type===it.TextVariable){const tt=W.speed||1,gt=W.intensity||1.5,Q=(Math.sin(Lt*.004*tt+Vt*.3)+1)/2;bt*=1+Q*(gt-1)*nt}else if(Et.type===it.TextZing){const tt=W.speed||2,gt=W.distance||100,Q=(Lt*.002*tt+Vt*.05)%1;ee+=(1-Q)*gt*nt,rt=Q}else if(Et.type===it.TextElastic){const tt=W.stiffness||.2,gt=W.damping||.1,Q=Math.sin(Lt*.01)*Math.exp(-Lt*.001*gt);st*=1+Q*tt*nt}else if(Et.type===it.TextGlitch3D){const tt=W.intensity||5;Math.random()<.2&&(ee+=(Math.random()-.5)*tt,j+=(Math.random()-.5)*tt,rt=.8)}else if(Et.type===it.GlitchText){const tt=W.intensity||5;Math.random()<.1&&(ee+=(Math.random()-.5)*tt,j+=(Math.random()-.5)*tt,Math.random()<.05&&(rt=.5))}});let Rt=null,Qt=o.textDecoration||"none",Kt=m;if(o.enableSegments===!0&&((te=o.segments)==null?void 0:te.length)>0){let Et=0,W=null;for(const nt of o.segments){if(Vt<Et+(nt.text||"").length){W=nt;break}Et+=(nt.text||"").length}if(W){let nt=W.fontFamily||o.fontFamily||"Inter";c.forEach(gt=>{const Q=new RegExp(`[\\s-]${gt}$`,"i");Q.test(nt)&&(nt=nt.replace(Q,"").trim())});const Lt=this.mapFontWeight((W.fontWeight||o.fontWeight||"400").toString()),tt=W.fontStyle||f;Kt=W.fontSize||m,t.font=`${tt} ${Lt} ${Kt}px "${nt}", sans-serif`,W.fill&&(Rt=W.fill),W.textDecoration&&(Qt=W.textDecoration),Kt<X&&(j+=(X-Kt)*.85)}}else t.font=C;const ae=t.globalAlpha;t.globalAlpha*=rt,t.save();const Jt=t.measureText(ft).width;if(q&&N>0){const Et=de-Yt+Jt/2,nt=(Ie+Et)/N,Lt=this.getPointOnPath(q.geo,q.w,q.h,Math.abs(nt%1)),tt=Lt.angle,gt=$t+j+(o.pathOffsetY||0),Q=o.pathSide==="right"?-1:1,Ut=Math.cos(tt+Math.PI/2)*gt*Q,zt=Math.sin(tt+Math.PI/2)*gt*Q;t.translate(Lt.x+Ut+ee,Lt.y+zt),t.rotate(tt+K+(Q===-1?Math.PI:0))}else t.translate(de+ee+Jt/2,$t+j),K!==0&&t.rotate(K);if(t.scale(bt,st),Rt&&!r&&!l){const Et=this.createCanvasFill(t,Rt,_,V);t.fillStyle=Et||Rt.color||"#000000"}else if(!r&&!l){const Et=this.createCanvasFill(t,e.fill,_,V);t.fillStyle=Et||e.fill.color||"#000000"}if(rt>0)if(r||l){const Et=l?"#000000":this.createCanvasFill(t,e.fill,_,V);t.fillStyle=Et||e.fill.color||"#ffffff",t.fillText(ft,-Jt/2,0)}else St?t.strokeText(ft,-Jt/2,0):t.fillText(ft,-Jt/2,0);Qt!=="none"&&!r&&this.drawTextDecoration(t,Qt,0,0,Jt,Kt),t.restore(),t.globalAlpha=ae,I==="justify"&&fe>0&&ft===" "&&!le?de+=Jt+k+fe:de+=Jt+k}t.textAlign=Zt}};if(r){let J=0,ut=U;(F||[]).forEach($t=>{const St=$t.text||"",Pt=p.indexOf(St,J);Pt!==-1&&(J=Pt);let Ft=-_/2;I==="center"?Ft=0:I==="right"&&(Ft=_/2),z(St,Ft,ut,!1,J),J+=St.length,ut+=Y})}else if(l){let J=0,ut=U;(F||[]).forEach($t=>{const St=$t.text||"";let Pt=-_/2;I==="center"?Pt=0:I==="right"&&(Pt=_/2),z(St,Pt,ut,!1,J),J+=St.length,J<p.length&&(p[J]===`
12
+ `||p[J]==="\r")&&(J++,p[J-1]==="\r"&&p[J]===`
13
+ `&&J++),ut+=Y})}else{if(e.fill){const ut=t.globalAlpha,$t=this.createCanvasFill(t,e.fill,_,V);t.fillStyle=$t||e.fill.color||"#000000",t.globalAlpha=ut*this.normalizeOpacity(e.fill.opacity??100);const St=$.fullText||(o.enableSegments?(o.segments||[]).map(lt=>{let ht=lt.text||"";const dt=lt.textCase||o.textCase||"none";return dt==="uppercase"?ht.toUpperCase():dt==="lowercase"?ht.toLowerCase():dt==="capitalize"?ht.replace(/\b\w/g,At=>At.toUpperCase()):ht}).join(""):p);let Pt=0,Ft=U;(F||[]).forEach(lt=>{const ht=lt.text||"";let dt=-_/2;I==="center"?dt=0:I==="right"&&(dt=_/2),z(ht,dt,Ft,!1,Pt),Pt+=ht.length,Ft+=Y,Pt<St.length&&(St[Pt]===`
14
+ `||St[Pt]==="\r")&&(A>0&&(Ft+=A),Pt++,St[Pt-1]==="\r"&&St[Pt]===`
15
+ `&&Pt++)}),t.globalAlpha=ut}const J=o.paragraphRule;if(J&&(((vt=J.top)==null?void 0:vt.width)>0||((Wt=J.bottom)==null?void 0:Wt.width)>0)){let ut=0;(F||[]).forEach(($t,St)=>{var lt,ht;const Ft=ut===0||ut<p.length&&(p[ut]===`
16
+ `||p[ut]==="\r");if(Ft&&St>0&&ut++,Ft){if(((lt=J.top)==null?void 0:lt.width)>0){const dt=U+St*Y-J.top.offset;t.strokeStyle=J.top.color||"#000000",t.lineWidth=J.top.width,t.beginPath();const At=-i/2+Y*.2;t.moveTo(At,dt),t.lineTo(i/2-Y*.2,dt),t.stroke()}if(((ht=J.bottom)==null?void 0:ht.width)>0){const dt=U+(St+1)*Y-J.bottom.offset;t.strokeStyle=J.bottom.color||"#000000",t.lineWidth=J.bottom.width,t.beginPath();const At=-i/2+Y*.2;t.moveTo(At,dt),t.lineTo(i/2-Y*.2,dt),t.stroke()}}ut+=($t.text||"").length})}if(e.stroke&&e.stroke.width>0){const ut=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 St=t.getTransform(),Pt=Math.sqrt(St.a*St.a+St.b*St.b)||1,Ft=window.devicePixelRatio||1;t.lineWidth=(e.stroke.width||1)*Ft/Pt,t.globalAlpha=ut*this.normalizeOpacity(e.stroke.opacity??100);let lt=0,ht=U;(F||[]).forEach(dt=>{let At=-_/2;I==="center"?At=0:I==="right"&&(At=_/2),z(dt.text,At,ht,!0,lt),lt+=(dt.text||"").length,ht+=Y,lt<p.length&&(p[lt]===`
17
+ `||p[lt]==="\r")&&(A>0&&(ht+=A),lt++,p[lt-1]==="\r"&&p[lt]===`
18
+ `&&lt++)}),t.globalAlpha=ut}}}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,g=(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 v=this.createCanvasFill(t,a.fill,e,n);v?t.strokeStyle=v:t.strokeStyle=a.color||"#000000"}else t.strokeStyle=a.color||"#000000";const f=t.globalAlpha;t.globalAlpha=f*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 h=a.trimStart??0,m=a.trimEnd??1,b=a.trimOffset??0,c=a.dashOffset??0,S=a.dashArray||[];if(h!==0||m!==1||b!==0){const v=this.getPerimeter(o,e,n);if(v>0){const C=Math.max(0,Math.min(1,h)),w=Math.max(0,Math.min(1,m));if(C<w){const I=v*(w-C),k=v-I,O=-(v*(C+b%1));t.setLineDash([I,k]),t.lineDashOffset=O-c*v}else if(C===w)t.setLineDash([0,v]);else{const I=v*(1-C+w),k=v-I,O=-(v*C);t.setLineDash([I,k]),t.lineDashOffset=O-c*v}}}else if(S.length>0||c!==0){S.length>0&&t.setLineDash(S);const v=this.getPerimeter(o,e,n);t.lineDashOffset=-(c*v)}if((o==null?void 0:o.type)==="Line"||e===0||n===0)this.applyPath(t,o,e,n,i),t.stroke();else if(g==="inside")t.lineWidth=p*2,t.save(),this.applyPath(t,o,e,n,i),t.clip(),t.stroke(),t.restore();else if(g==="outside"){t.save(),t.beginPath();const v=Math.max(e,n,2e4);t.rect(-v,-v,v*2,v*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,g=e[r-1].out_x,u=e[r-1].out_y;if(g!==void 0||l.in_x!==void 0?n+=this.getBezierLength(d,p,g??d,u??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 f=i,h=a,m=[...e.slice(0,r+1)].reverse().find(I=>I.moveTo)||e[0],b=m.x,c=m.y,S=e[r].out_x,v=e[r].out_y,C=m.in_x,w=m.in_y;S!==void 0||C!==void 0?n+=this.getBezierLength(f,h,S??f,v??h,C??b,w??c,b,c):n+=Math.sqrt((b-f)**2+(c-h)**2)}}return n}default:return(s+o)*2}}getBezierLength(t,s,o,e,n,i,a,r,l=10){let d=0,p=t,g=s;for(let u=1;u<=l;u++){const f=u/l,h=1-f,m=f*f,b=h*h,c=b*h,S=m*f,v=c*t+3*b*f*o+3*h*m*n+S*a,C=c*s+3*b*f*e+3*h*m*i+S*r,w=v-p,I=C-g;d+=Math.sqrt(w*w+I*I),p=v,g=C}return d}getBezierTAtLength(t,s,o,e,n,i,a,r,l,d=20){if(t<=0)return 0;let p=0,g=s,u=o;for(let f=1;f<=d;f++){const h=f/d,m=1-h,b=h*h,c=m*m,S=c*m,v=b*h,C=S*s+3*c*h*e+3*m*b*i+v*r,w=S*o+3*c*h*n+3*m*b*a+v*l,I=C-g,k=w-u,O=Math.sqrt(I*I+k*k);if(p+O>=t){const T=t-p,A=O===0?0:T/O;return(f-1+A)/d}p+=O,g=C,u=w}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,u=this.getPerimeter(t,s,o)*e;let f=0;const h=[];let m=n[0],b=n[0];for(let c=1;c<n.length;c++){const S=n[c];if(S.moveTo){m=S,b=S;continue}h.push({p0:m,p1:S}),(S.closePath||c===n.length-1&&(t.is_closed||t.isClosed))&&h.push({p0:S,p1:b}),m=S}for(const c of h){const S=c.p0,v=c.p1;let C=0;const w=S.out_x!==void 0||v.in_x!==void 0;if(w?C=this.getBezierLength(S.x,S.y,S.out_x??S.x,S.out_y??S.y,v.in_x??v.x,v.in_y??v.y,v.x,v.y):C=Math.sqrt((v.x-S.x)**2+(v.y-S.y)**2),f+C>=u||c===h[h.length-1]){let I=0;if(w)return I=this.getBezierTAtLength(u-f,S.x,S.y,S.out_x??S.x,S.out_y??S.y,v.in_x??v.x,v.in_y??v.y,v.x,v.y,20),this.getBezierPointAndAngle(I,S,v,d,p);{I=C===0?0:(u-f)/C;const k=S.x+(v.x-S.x)*I-d,O=S.y+(v.y-S.y)*I-p,T=Math.atan2(v.y-S.y,v.x-S.x);return{x:k,y:O,angle:T}}}f+=C}}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),g=-n*Math.sin(l),u=i*Math.cos(l),f=Math.atan2(u,g);return{x:d,y:p,angle:f}}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,g=o.x,u=o.y,f=1-t,h=t*t,m=f*f,b=m*f,c=h*t,S=b*i+3*m*t*r+3*f*h*d+c*g-e,v=b*a+3*m*t*l+3*f*h*p+c*u-n,C=3*m*(r-i)+6*f*t*(d-r)+3*h*(g-d),w=3*m*(l-a)+6*f*t*(p-l)+3*h*(u-p),I=Math.atan2(w,C);return{x:S,y:v,angle:I}}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 f,h,m;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 b=Math.tan(e*Math.PI/180),c=Math.tan(n*Math.PI/180);t.transform(1+b*c,c,b,1,0,0)}const i=o.rotate_x!==void 0?o.rotate_x:((f=o.transform)==null?void 0:f.rotate_x)??0,a=o.rotate_y!==void 0?o.rotate_y:((h=o.transform)==null?void 0:h.rotate_y)??0,l=1+(o.translate_z!==void 0?o.translate_z:((m=o.transform)==null?void 0:m.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,g=(o.scale_x??1)*d,u=(o.scale_y??1)*p;t.scale(g,u)}applyInnerGlowOverlay(t,s,o,e,n,i,a){var b,c;const r=a||s.style||{},l=r==null?void 0:r.effect,p=((r==null?void 0:r.effects)||(l?[l]:[])).find(S=>S.isEnabled!==!1&&S.type==="Glow"&&(S.mode==="inner"||S.mode==="Inner Glow"));if(!p)return;t.save(),t.beginPath(),this.applyPath(t,o,e,n,i),t.clip();const g=p.blur||10,u=1e4,f=t.getTransform();let h=p.color||"white";(c=(b=this.artboard)==null?void 0:b.tokens)!=null&&c.colors&&this.artboard.tokens.colors[h]&&(h=this.artboard.tokens.colors[h]),t.shadowColor=h,t.shadowBlur=g,t.shadowOffsetX=u*f.a,t.shadowOffsetY=u*f.b,t.translate(-u,0),t.lineWidth=g+5,t.strokeStyle=h;const m=Math.min(p.intensity||1,5);for(let S=0;S<m;S++)t.beginPath(),this.applyPath(t,o,e,n,i),t.stroke();t.restore()}applyArtEffectOverlay(t,s,o,e,n,i){var u,f,h,m,b;const a=this.objectStates.get(s.id),r=((u=a==null?void 0:a.style)==null?void 0:u.artEffect)||s.artEffect||((f=s.style)==null?void 0:f.artEffect);if(!r||!r.enabled)return;const l=r.type,d=r.intensity??.5,p=r.speed??1,g=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 S=this.currentTime*p%2/2,v=t.createLinearGradient(-e,-n,e,n);v.addColorStop(Math.max(0,S-.2),"rgba(255,255,255,0)"),v.addColorStop(S,`rgba(255,255,255,${d*.8})`),v.addColorStop(Math.min(1,S+.2),"rgba(255,255,255,0)"),t.fillStyle=v,t.globalCompositeOperation="screen",t.fillRect(-e/2,-n/2,e,n),t.globalCompositeOperation="source-over"}else if(l==="glint_overlay"){let v=((this._lastPointerPos||{x:0}).x-(((h=s.transform)==null?void 0:h.x)??0)+300)/600;v=Math.max(-.2,Math.min(1.2,v));const C=t.createLinearGradient(-e,-n,e,n);C.addColorStop(Math.max(0,v-.15),"rgba(255,255,255,0)"),C.addColorStop(Math.max(0,Math.min(1,v)),`rgba(255,255,255,${d})`),C.addColorStop(Math.min(1,v+.15),"rgba(255,255,255,0)"),t.fillStyle=C,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},S=c.x-(((m=s.transform)==null?void 0:m.x)??0),v=c.y-(((b=s.transform)==null?void 0:b.y)??0),C=t.createLinearGradient(S>0?-e/2:e/2,v>0?-n/2:n/2,S>0?e/2:-e/2,v>0?n/2:-n/2);C.addColorStop(0,`rgba(0,0,0,${d*.6})`),C.addColorStop(.4,"rgba(0,0,0,0)"),C.addColorStop(.5,`rgba(255,255,255,${d*.4})`),C.addColorStop(1,`rgba(0,0,0,${d*.2})`),t.fillStyle=C,t.globalCompositeOperation="overlay",t.fillRect(-e/2,-n/2,e,n),t.globalCompositeOperation="source-over",t.beginPath(),S>0&&v>0?(t.moveTo(e/2-40,n/2),t.lineTo(e/2,n/2-40),t.lineTo(e/2-40,n/2-40)):S<0&&v>0?(t.moveTo(-e/2+40,n/2),t.lineTo(-e/2,n/2-40),t.lineTo(-e/2+40,n/2-40)):S>0&&v<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=S>0?-2:2,t.shadowOffsetY=v>0?-2:2,t.fill()}else if(l==="crumple_overlay"){const c=Math.floor(e/g),S=document.createElement("canvas");S.width=c,S.height=Math.floor(n/g);const v=S.getContext("2d"),C=v.createImageData(S.width,S.height);for(let w=0;w<C.data.length;w+=4){const I=Math.random()>.95?150:255;C.data[w]=I,C.data[w+1]=I,C.data[w+2]=I,C.data[w+3]=255*d}v.putImageData(C,0,0),t.globalCompositeOperation="multiply",t.imageSmoothingEnabled=!1,t.drawImage(S,-e/2,-n/2,e,n)}else if(l==="acid_gradient"||l==="acid_rave"){const c=this.currentTime*p,S=r.color1,v=r.color2,C=t.createLinearGradient(-e/2,-n/2,e/2,n/2);if(S&&v){const w=c*60%360;C.addColorStop(0,this._shiftHue(S,w,d*.7)),C.addColorStop(1,this._shiftHue(v,(w+180)%360,d*.7))}else{const w=c*100%360,I=(w+180)%360;C.addColorStop(0,`hsla(${w}, 80%, 50%, ${d*.5})`),C.addColorStop(1,`hsla(${I}, 80%, 50%, ${d*.5})`)}t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-n/2,e,n)}else if(l==="halftone"){const c=Math.max(2,g*(1-d*.8)),S=document.createElement("canvas");S.width=c,S.height=c;const v=S.getContext("2d");if(v){v.fillStyle="black",v.beginPath(),v.arc(c/2,c/2,c/2*d,0,Math.PI*2),v.fill();const C=t.createPattern(S,"repeat");C&&(t.globalAlpha=.3*d,t.fillStyle=C,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 S=0;S<c;S++){const v=Math.random()>.5?255:0;t.fillStyle=`rgba(${v}, ${v}, ${v}, ${.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(g*(1-d*.5))),S=document.createElement("canvas"),v=Math.max(1,Math.ceil(e/c)),C=Math.max(1,Math.ceil(n/c));S.width=v,S.height=C;const w=S.getContext("2d");if(w){w.imageSmoothingEnabled=!1;const I=t.getTransform(),k=I.e-e/2,O=I.f-n/2;w.drawImage(t.canvas,k,O,e,n,0,0,v,C),t.imageSmoothingEnabled=!1,t.drawImage(S,0,0,v,C,-e/2,-n/2,e,n),t.imageSmoothingEnabled=!0}}else if(l==="glitch"){const c=this.currentTime*p,S=r.chaosAmount??.2,v=Math.max(3,Math.floor(8*d)),C=d*e*.15;t.globalCompositeOperation="screen",t.globalAlpha=d*.4;const w=C*.3;t.fillStyle="rgba(255, 0, 0, 0.4)",t.fillRect(-e/2+w,-n/2,e,n),t.fillStyle="rgba(0, 255, 255, 0.4)",t.fillRect(-e/2-w,-n/2,e,n),t.globalCompositeOperation="source-over",t.globalAlpha=1;const I=n/v;for(let k=0;k<v;k++){const O=Math.sin(k*127.1+c*311.7*p)*43758.5,T=O-Math.floor(O);if(T>1-S){const A=(T-(1-S))/S*C*(Math.random()>.5?1:-1),D=-n/2+k*I,Y=t.getTransform(),B=Y.e-e/2+A,R=Y.f+D;t.save(),t.beginPath(),t.rect(-e/2,D,e,I),t.clip(),t.globalAlpha=.8,t.drawImage(t.canvas,B,R,e,I,-e/2+A,D,e,I),t.restore()}}}t.restore()}}_shiftHue(t,s,o){let e=0,n=0,i=0;if(t.startsWith("#")){const u=t.replace("#","");e=parseInt(u.substring(0,2),16)/255,n=parseInt(u.substring(2,4),16)/255,i=parseInt(u.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 u=a-r;switch(d=p>.5?u/(2-a-r):u/(a+r),a){case e:l=((n-i)/u+(n<i?6:0))/6;break;case n:l=((i-e)/u+2)/6;break;case i:l=((e-n)/u+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 g=t.getTransform(),u=t.canvas;try{const m=document.createElement("canvas");m.width=Math.max(1,Math.ceil(o)),m.height=Math.max(1,Math.ceil(e));const b=m.getContext("2d");if(b){b.save(),b.translate(o/2,e/2);const c=i.magnification||1;if(c!==1&&b.scale(c,c),typeof g.inverse=="function"){const C=g.inverse();b.transform(C.a,C.b,C.c,C.d,C.e,C.f)}else{const C=g.a*g.d-g.b*g.c;C!==0&&b.transform(g.d/C,-g.b/C,-g.c/C,g.a/C,(g.c*g.f-g.d*g.e)/C,(g.b*g.e-g.a*g.f)/C)}b.drawImage(u,0,0),b.restore();const S=document.createElement("canvas");S.width=m.width,S.height=m.height;const v=S.getContext("2d");v.filter=`blur(${r}px)`,v.drawImage(m,0,0),t.globalCompositeOperation="destination-out",t.fillRect(-o/2,-e/2,o,e),t.globalCompositeOperation="source-over",t.globalAlpha=1,t.drawImage(S,-o/2,-e/2,o,e)}}catch(m){console.error("Background blur failed:",m)}t.globalCompositeOperation="source-over",t.globalAlpha=l,t.fillStyle=p,t.fillRect(-o/2,-e/2,o,e),t.globalAlpha=1;const f=t.createLinearGradient(-o/2,-e/2,o/2,e/2);if(f.addColorStop(0,"rgba(255,255,255,0.12)"),f.addColorStop(.3,"rgba(255,255,255,0.04)"),f.addColorStop(.5,"rgba(255,255,255,0.0)"),f.addColorStop(1,"rgba(255,255,255,0.0)"),t.fillStyle=f,t.fillRect(-o/2,-e/2,o,e),d>0){if(t.globalAlpha=d/100,!this._noiseTileCanvas){const b=document.createElement("canvas");b.width=64,b.height=64;const c=b.getContext("2d"),S=c.createImageData(64,64),v=S.data;for(let C=0;C<v.length;C+=4){const w=Math.floor(Math.random()*255);v[C]=w,v[C+1]=w,v[C+2]=w,v[C+3]=18}c.putImageData(S,0,0),this._noiseTileCanvas=b}const m=t.createPattern(this._noiseTileCanvas,"repeat");m&&(t.fillStyle=m,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,g=a*Math.PI/180,u=p+g;a>=360&&r<=0?t.ellipse(0,0,l,d,0,0,Math.PI*2):(t.ellipse(0,0,l,d,0,p,u,!1),r>0?t.ellipse(0,0,l*r,d*r,0,u,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,g=p*Math.cos(d),u=p*Math.sin(d);l===0?t.moveTo(g,u):t.lineTo(g,u)}t.closePath()}else if(s!=null&&s.points&&["path","custom","customshape","shape","subtract","union","intersect","exclude","booleanoperation"].includes((s.type||"").toLowerCase())){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(g=>{typeof g.x=="number"&&typeof g.y=="number"&&(i=Math.min(i,g.x),a=Math.max(a,g.x),r=Math.min(r,g.y),l=Math.max(l,g.y),g.out_x!==void 0&&(i=Math.min(i,g.out_x),a=Math.max(a,g.out_x)),g.out_y!==void 0&&(r=Math.min(r,g.out_y),l=Math.max(l,g.out_y)),g.in_x!==void 0&&(i=Math.min(i,g.in_x),a=Math.max(a,g.in_x)),g.in_y!==void 0&&(r=Math.min(r,g.in_y),l=Math.max(l,g.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((g,u)=>{if(u===0||g.moveTo)t.moveTo(g.x-d,g.y-p);else{const f=s.points[u-1];if(!f)return;const h=(f.out_x??f.x)-d,m=(f.out_y??f.y)-p,b=(g.in_x??g.x)-d,c=(g.in_y??g.y)-p;isNaN(h)||isNaN(b)||isNaN(g.x)?t.lineTo(g.x-d,g.y-p):t.bezierCurveTo(h,m,b,c,g.x-d,g.y-p)}if(g.closePath||u===s.points.length-1&&(s.is_closed||s.isClosed)){const f=[...s.points.slice(0,u+1)].reverse().find(h=>h.moveTo)||s.points[0];f&&(g.out_x!==void 0||f.in_x!==void 0)&&t.bezierCurveTo((g.out_x??g.x)-d,(g.out_y??g.y)-p,(f.in_x??f.x)-d,(f.in_y??f.y)-p,f.x-d,f.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(g=>{i=Math.min(i,g.x),a=Math.max(a,g.x),r=Math.min(r,g.y),l=Math.max(l,g.y)});const d=(i+a)/2,p=(r+l)/2;s.points.forEach((g,u)=>{if(u===0)t.moveTo(g.x-d,g.y-p);else{const f=s.points[u-1];f.out_x!==void 0||g.in_x!==void 0?t.bezierCurveTo((f.out_x??f.x)-d,(f.out_y??f.y)-p,(g.in_x??g.x)-d,(g.in_y??g.y)-p,g.x-d,g.y-p):t.lineTo(g.x-d,g.y-p)}(g.closePath||u===s.points.length-1&&(s.is_closed||s.isClosed))&&t.closePath()})}}}renderInputBox(t,s){var qt,Se,Ce,Ie,de,Re,ye,ke,Vt,ee,j,bt,st,K,rt,ft,Rt,Qt,Kt,ae,Jt,Et;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=s.geometry||{},i=s.style||{},a=this.focusedId===s.id,r=this.lastHoveredObjectId===s.id,l=e.previewState||"default",d=l==="focused"||l==="active"||!e.disabled&&a,p=l==="hover"||!e.disabled&&r&&!d,g=l==="disabled"||!!e.disabled,u=l==="error"||!!e.error,f=e.inputType==="textarea"||e.multiline===!0;let h={};g&&e.disabledStyle&&Object.keys(e.disabledStyle).length>0?h=e.disabledStyle:u&&e.errorStyle&&Object.keys(e.errorStyle).length>0?h=e.errorStyle:d?h={...e.focusedStyle||{},...e.activeStyle||{}}:p&&(h={...e.hoveredStyle||{},...e.hoverStyle||{}});const m=Number(h.scale??1);m!==1&&t.scale(m,m);const b=Number(h.translateX??0),c=Number(h.translateY??0);(b||c)&&t.translate(b,c);const S=Number(h.rotate??0);S&&t.rotate(S*Math.PI/180);const v=Number(h.opacity??1);v!==1&&(t.globalAlpha=v);const C=Number(h.width??n.width)||250,w=Number(h.height??n.height)||45,I=e.label||{visible:!0,text:"Label"},k=e.helperText||{visible:!1,text:"Helper text"},O=e.leftIcon||{visible:!1},T=e.rightIcon||{visible:!1},A=((qt=h.leftIcon)==null?void 0:qt.color)||h.leftIconColor||h.iconColor,D=((Se=h.rightIcon)==null?void 0:Se.color)||h.rightIconColor||h.iconColor,Y={...O,...h.leftIcon||{},...A?{color:A}:{}},B={...T,...h.rightIcon||{},...D?{color:D}:{}};h.leftIconVisible!==void 0&&(Y.visible=h.leftIconVisible),h.rightIconVisible!==void 0&&(B.visible=h.rightIconVisible),((Ce=h.leftIcon)==null?void 0:Ce.visible)!==void 0&&(Y.visible=h.leftIcon.visible),((Ie=h.rightIcon)==null?void 0:Ie.visible)!==void 0&&(B.visible=h.rightIcon.visible);const R=n.corner_radius??n.cornerRadius,L=Array.isArray(R)?{tl:R[0],tr:R[1],br:R[2],bl:R[3]}:R&&typeof R=="object"?R:void 0,$=h.cornerRadius??h.corner_radius,F=Number($??e.cornerRadius??e.corner_radius??R??e.radius??8),X=h.corners??($!==void 0?{tl:F,tr:F,bl:F,br:F}:e.corners??L??{tl:F,tr:F,bl:F,br:F}),M=[Number(X.tl??F),Number(X.tr??F),Number(X.br??F),Number(X.bl??F)],E=(W,nt,Lt,tt,gt,Q=0)=>{const Ut=Math.max(0,Lt-Q*2),zt=Math.max(0,tt-Q*2);let[yt,Bt,_t,Xt]=gt.map(ce=>Math.max(0,(Number(ce)||0)-Q));const Dt=Math.min(Ut,zt)/2;yt=Math.min(yt,Dt),Bt=Math.min(Bt,Dt),_t=Math.min(_t,Dt),Xt=Math.min(Xt,Dt),t.beginPath(),t.roundRect?t.roundRect(W+Q,nt+Q,Ut,zt,[yt,Bt,_t,Xt]):(t.moveTo(W+Q+yt,nt+Q),t.lineTo(W+Q+Ut-Bt,nt+Q),t.arcTo(W+Q+Ut,nt+Q,W+Q+Ut,nt+Q+Bt,Bt),t.lineTo(W+Q+Ut,nt+Q+zt-_t),t.arcTo(W+Q+Ut,nt+Q+zt,W+Q+Ut-_t,nt+Q+zt,_t),t.lineTo(W+Q+Xt,nt+Q+zt),t.arcTo(W+Q,nt+Q+zt,W+Q,nt+Q+zt-Xt,Xt),t.lineTo(W+Q+yt,nt+Q),t.arcTo(W+Q,nt+Q,W+Q+yt,nt+Q,yt),t.closePath())};let P=h.backgroundColor??e.backgroundColor??((de=i.fill)==null?void 0:de.color)??"rgba(31, 41, 55, 1)",_=h.borderColor??e.borderColor??((ye=(Re=i.stroke)==null?void 0:Re.fill)==null?void 0:ye.color)??((ke=i.stroke)==null?void 0:ke.color)??"rgba(55, 65, 81, 1)",V=Number(h.borderWidth??e.borderWidth??((Vt=i.stroke)==null?void 0:Vt.width)??1),G=h.color??e.color??((ee=i.fill)==null?void 0:ee.color)??"#ffffff",x=h.placeholderColor??e.placeholderColor??"rgba(156, 163, 175, 1)",U=Number(h.fontSize??e.fontSize??14),q=h.caretColor??e.caretColor??e.accentColor??"#3b82f6";!h.borderColor&&!h.borderWidth&&(d&&!g?(_=e.focusBorderColor||e.accentColor||"#3b82f6",V=Math.max(V,1.5)):p&&!g?(_=e.hoverBorderColor||"#64748b",P=e.hoverBackgroundColor||P):g?(P=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",_=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):u&&(_="rgba(239, 68, 68, 1)",V=Math.max(V,2)));const N=V>0?V/2:0,H=this.createCanvasFill(t,P,C,w);if(H&&P!=="transparent"&&(E(-C/2,-w/2,C,w,M,N),t.fillStyle=H,t.fill()),V>0){const W=this.createCanvasFill(t,_,C,w);W&&_!=="transparent"&&(E(-C/2,-w/2,C,w,M,N),t.strokeStyle=W,t.lineWidth=V,t.lineCap="round",t.lineJoin="round",t.stroke())}if(h.boxShadow&&h.boxShadow.color&&h.boxShadow.color!=="transparent"){t.save();const W=h.boxShadow;t.shadowColor=W.color,t.shadowOffsetX=Number(W.offsetX??0),t.shadowOffsetY=Number(W.offsetY??2),t.shadowBlur=Number(W.blur??8),E(-C/2,-w/2,C,w,M,N),t.fillStyle=P!=="transparent"?H||P:"rgba(0,0,0,0.01)",t.fill(),t.restore()}if(d&&!g){t.save();const W=-3,nt=M.map(gt=>Math.max(0,gt+3));E(-C/2+W,-w/2+W,C-W*2,w-W*2,nt);const Lt=h.borderColor||((j=e.activeStyle)==null?void 0:j.borderColor)||q||"rgba(59, 130, 246, 0.4)",tt=this.createCanvasFill(t,Lt,C,w)||"rgba(59, 130, 246, 0.4)";t.strokeStyle=tt,t.lineWidth=2,t.lineCap="round",t.lineJoin="round",t.stroke(),t.restore()}const z=h.fontFamily||e.fontFamily||"Inter",et=(h.fontWeight??e.fontWeight)||400,Mt=Number(h.fontSize??U),ct=e.inputType==="number"&&((bt=e.number)==null?void 0:bt.showSteppers)!==!1,It=24,mt=ct?It+4:0,kt=String(e.text??e.value??"");let Ot="Enter text...";if(e.inputType==="tel")Ot=`${((st=e.tel)==null?void 0:st.dialCode)||"+1"} (555) 000-0000`;else if(e.inputType==="number"){const W=(K=e.number)!=null&&K.prefix?`${e.number.prefix} `:"",nt=(rt=e.number)!=null&&rt.suffix?` ${e.number.suffix}`:"";Ot=`${W}0.00${nt}`}else e.inputType==="email"?Ot="user@example.com":e.inputType==="search"?Ot="Search anything...":e.inputType==="url"?Ot="https://example.com":e.inputType==="password"?Ot="••••••••":e.inputType==="textarea"&&(Ot="Enter text...");const vt=e.placeholder||Ot,Wt=!kt,J=e.inputType==="password",ut=B.mode==="password-toggle"||J&&B.visible!==!1,$t=B.mode==="clear"||e.inputType==="search"&&!!kt,St=(W,nt)=>{var Bt;let Lt=W.svgPath||"";const tt=W.char||"";if(!Lt&&!tt&&(nt?e.inputType==="search"&&(Lt="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"):ut?Lt=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":$t&&(Lt="M18 6L6 18M6 6l12 12")),!(W.visible||!!(Lt||tt)&&(!nt&&(ut||$t)||nt&&e.inputType==="search")))return;const Q=W.size||16,Ut=(W.offset??16)+(nt?0:mt),zt=typeof W.color=="string"?W.color:((Bt=W.color)==null?void 0:Bt.color)||"#9ca3af",yt=nt?-(C/2)+Ut:C/2-Ut;if(Lt){if(t.save(),t.translate(yt,0),!Lt.startsWith("<svg")){const _t=new Path2D(Lt),Xt=Q/24;t.scale(Xt,Xt),t.translate(-12,-12),Lt.includes("M18 6L6 18")||Lt.includes("M1 1l22 22")||Lt.includes("M21 21")||Lt.includes("M11 19a8")?(t.strokeStyle=zt,t.lineWidth=2/Xt,t.lineCap="round",t.lineJoin="round",t.stroke(_t)):(t.fillStyle=zt,t.fill(_t))}t.restore()}else tt&&(t.save(),t.translate(yt,0),t.fillStyle=zt,t.font=`${Q}px sans-serif`,t.textAlign="center",t.textBaseline="middle",t.fillText(tt,0,0),t.restore())};if(St(Y,!0),St(B,!1),ct){const W=C/2-It-4;t.save(),t.strokeStyle=_||"rgba(55, 65, 81, 0.5)",t.lineWidth=1,t.beginPath(),t.moveTo(W,-w/2+6),t.lineTo(W,w/2-6),t.stroke(),t.beginPath(),t.moveTo(W,0),t.lineTo(C/2-4,0),t.stroke(),t.fillStyle=G||"rgba(156, 163, 175, 0.8)",t.font=`600 8px "${z}", sans-serif`,t.textAlign="center",t.textBaseline="middle",t.fillText("▲",W+It/2,-w/4),t.fillText("▼",W+It/2,w/4),t.restore()}const Pt=h.padding||e.padding||{},Ft=Pt.left??((ft=e.padding)==null?void 0:ft.left)??e.inputPadding??12,lt=Pt.right??((Rt=e.padding)==null?void 0:Rt.right)??e.inputPadding??12,ht=Y.visible||e.inputType==="search",dt=B.visible||ut||$t,At=ht?(Y.offset??16)+(Y.size||16)/2+8:Ft,Tt=dt?(B.offset??16)+(B.size||16)/2+8+mt:lt+mt,Ct=-(C/2)+At,Yt=Math.max(0,C-At-Tt);let ie=kt||vt;if(e.inputType==="number"&&kt){const W=(Qt=e.number)!=null&&Qt.prefix?`${e.number.prefix} `:"",nt=(Kt=e.number)!=null&&Kt.suffix?` ${e.number.suffix}`:"";ie=`${W}${kt}${nt}`}const te=J&&kt?e.passwordVisible?kt:"•".repeat(kt.length):ie,Zt=Wt?x:G;if(t.font=`${et} ${Mt}px "${z}", sans-serif`,t.fillStyle=Zt,t.textAlign="left",t.save(),t.beginPath(),t.rect(Ct-2,-w/2+4,Yt+4,w-8),t.clip(),f){t.textBaseline="top";const W=te.split(`
19
+ `);let nt=-w/2+(((ae=e.padding)==null?void 0:ae.top)??8);const Lt=Mt*1.4,tt=e.rows||3;let gt=0,Q=0;for(const Ut of W){if(gt>=tt)break;const zt=Ut.split(" ");let yt="";for(let Bt=0;Bt<zt.length;Bt++){const _t=yt+zt[Bt]+" ";if(t.measureText(_t).width>Yt&&Bt>0){if(gt>=tt)break;t.fillText(yt.trim(),Ct,nt),yt=zt[Bt]+" ",nt+=Lt,gt++}else yt=_t}gt<tt&&(t.fillText(yt.trim(),Ct,nt),Q=t.measureText(yt.trim()).width,nt+=Lt,gt++)}if(d&&!Wt&&Math.floor(performance.now()/500)%2===0){const Ut=nt-Lt;t.fillStyle=q,t.fillRect(Ct+Math.min(Q,Yt),Ut,1.5,Mt)}}else{t.textBaseline="middle";const nt=t.measureText(te).width;let Lt=0;if(nt>Yt&&(Lt=nt-Yt),t.fillText(te,Ct-Lt,0),d&&Math.floor(performance.now()/500)%2===0){const tt=Wt?Ct:Ct+nt-Lt;t.fillStyle=q,t.fillRect(tt,-(Mt/2),1.5,Mt)}}if(t.restore(),e.showCharCounter){t.save();const W=Number(e.maxLength||0),nt=W>0?`${kt.length}/${W}`:`${kt.length}`;t.font=`400 10px "${z}", sans-serif`,t.fillStyle=W>0&&kt.length>=W?"#ef4444":"rgba(156, 163, 175, 0.6)",t.textAlign="right",t.textBaseline="top",t.fillText(nt,-(C/2)+C-8,-(w/2)+w+4),t.restore()}if(I.visible!==!1){const W=!!(I.required||(Jt=e.validation)!=null&&Jt.required),nt=(I.text||"Label")+(W?" *":""),Lt=I.fontSize||12,tt=I.color||"rgba(156, 163, 175, 1)",gt=I.position||"top",Q=I.gap??I.offset??6;let Ut=-(C/2),zt=-(w/2)-Q,yt="left",Bt="bottom",_t=`600 ${Lt}px "${I.fontFamily||z}", sans-serif`;gt==="left"?(Ut=-(C/2)-Q,zt=0,yt="right",Bt="middle"):gt==="bottom"?(Ut=-(C/2),zt=w/2+Q,yt="left",Bt="top"):gt==="floating"&&(!!kt||a?(Ut=-(C/2)+12,zt=-(w/2)+4,yt="left",Bt="top",_t=`600 ${Math.max(9,Lt-2)}px "${I.fontFamily||z}", sans-serif`):_t=null),_t&&(t.save(),t.font=_t,t.fillStyle=tt,t.textAlign=yt,t.textBaseline=Bt,t.fillText(nt,Ut,zt),t.restore())}const le=(Et=e.validation)==null?void 0:Et.errorMessage;if(u&&le||k.visible===!0&&k.text){t.save();const W=k.fontSize||11,nt=u?"#ef4444":k.color||"rgba(156, 163, 175, 1)",Lt=k.offset??6,tt=u&&le?le:k.text;t.font=`400 ${W}px "${z}", sans-serif`,t.fillStyle=nt,t.textAlign="left",t.textBaseline="top",t.fillText(tt,-(C/2),w/2+Lt),t.restore()}g&&(t.save(),E(-C/2,-w/2,C,w,M),t.fillStyle="rgba(0, 0, 0, 0.3)",t.fill(),t.restore()),v!==1&&(t.globalAlpha=1)}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,g=n.trackHeight||4,u=n.trackRoundedness??2,f=n.trackShape??"Rectangle",h=n.trackPath||"",m=n.activeColor||n.accentColor||"#3b82f6",b=n.inactiveColor||"#374151",c=n.thumbShape||"Ellipse",S=n.thumbWidth??16,v=n.thumbHeight??16,C=n.thumbRoundedness??0,w=n.thumbColor||"#ffffff",I=n.thumbPath||"",k=n.thumbIcon||"",O=n.trackStrokeWidth??0,T=n.trackStrokeColor||"",A=n.thumbStrokeWidth??0,D=n.thumbStrokeColor||"",Y=n.showValueTooltip??!1,B=n.tooltipBgColor||"#333333",R=n.tooltipColor||"#ffffff",L=n.tooltipOffsetX??0,$=n.tooltipOffsetY??-25,F=this.lastHoveredObjectId===s.id,X=this.isMouseDown&&F,M=n.hoverStyle||{},E=n.activeStyle||{};let P=g,_=m,V=b,G=c,x=S,U=v,q=C,N=w,H=O,z=T,et=A,Mt=D,ct=1;X&&E?(ct=E.scale??1,P=E.trackHeight??P,_=E.activeColor??_,V=E.inactiveColor??V,N=E.thumbColor??N,x=E.thumbWidth??x,U=E.thumbHeight??U,q=E.thumbRoundedness??q,G=E.thumbShape||G,H=E.trackStrokeWidth??H,z=E.trackStrokeColor??z,et=E.thumbStrokeWidth??et,Mt=E.thumbStrokeColor??Mt):F&&M&&(ct=M.scale??1,P=M.trackHeight??P,_=M.activeColor??_,V=M.inactiveColor??V,N=M.thumbColor??N,x=M.thumbWidth??x,U=M.thumbHeight??U,q=M.thumbRoundedness??q,G=M.thumbShape||G,H=M.trackStrokeWidth??H,z=M.trackStrokeColor??z,et=M.thumbStrokeWidth??et,Mt=M.thumbStrokeColor??Mt);const It=X&&E.thumbPath?E.thumbPath:F&&M.thumbPath?M.thumbPath:I;ct!==1&&(t.save(),t.scale(ct,ct));const mt=(ht,dt,At,Tt,Ct,Yt,ie)=>{const te=xe[ht]||ie||(ht&&(ht.startsWith("M")||ht.startsWith("m"))?ht:"");if((ht==="Custom"||ht==="Icon"||te)&&te)try{const Zt=new Path2D(te),le=We(te),fe=Math.min(Tt/le.width,Ct/le.height);t.save(),t.translate(dt,At),t.scale(fe,fe),t.translate(-le.cx,-le.cy);const qt=!te.includes("z")&&!te.includes("Z");qt?(t.strokeStyle=t.fillStyle,t.lineWidth=Math.max(1.8,2.2/fe),t.lineCap="round",t.lineJoin="round",t.stroke(Zt)):t.fill(Zt),t.strokeStyle&&t.lineWidth>0&&!qt&&t.stroke(Zt),t.restore();return}catch(Zt){console.error("Error drawing slider shape in engine:",Zt)}if(t.beginPath(),ht==="Ellipse")t.ellipse(dt,At,Tt/2,Ct/2,0,0,Math.PI*2);else if(ht==="Rectangle")this.drawRoundRect(t,dt-Tt/2,At-Ct/2,Tt,Ct,Yt);else if(ht==="Triangle")t.moveTo(dt,At-Ct/2),t.lineTo(dt+Tt/2,At+Ct/2),t.lineTo(dt-Tt/2,At+Ct/2),t.closePath();else if(ht==="Diamond")t.moveTo(dt,At-Ct/2),t.lineTo(dt+Tt/2,At),t.lineTo(dt,At+Ct/2),t.lineTo(dt-Tt/2,At),t.closePath();else if(ht==="Polygon"){const Zt=s.geometry.sides||3,le=s.geometry.radius||Math.min(Tt,Ct)/2;for(let fe=0;fe<Zt;fe++){const qt=fe*2*Math.PI/Zt-Math.PI/2,Se=dt+le*Math.cos(qt),Ce=At+le*Math.sin(qt);fe===0?t.moveTo(Se,Ce):t.lineTo(Se,Ce)}t.closePath()}else if(ht==="Star"){const le=Math.min(Tt,Ct)/2,fe=le/2;for(let qt=0;qt<10;qt++){const Se=qt%2===0?le:fe,Ce=qt*Math.PI/5-Math.PI/2;t.lineTo(dt+Se*Math.cos(Ce),At+Se*Math.sin(Ce))}t.closePath()}else ht==="Line"&&(t.moveTo(dt-Tt/2,At),t.lineTo(dt+Tt/2,At));t.fill(),t.strokeStyle&&t.lineWidth>0&&t.stroke()},kt=this.createCanvasFill(t,V,i,P);kt&&(t.fillStyle=kt,t.strokeStyle=kt),f==="Line"?(t.strokeStyle=H>0&&z?z:kt,t.lineWidth=H>0?H:P,t.beginPath(),t.moveTo(-i/2,0),t.lineTo(i/2,0),t.stroke()):(H>0&&z&&(t.strokeStyle=z,t.lineWidth=H),mt(f,0,0,i,P,u,h));const Ot=i-x,vt=-i/2+x/2+p*Ot,Wt=vt- -i/2;if(Wt>0){const ht=this.createCanvasFill(t,_,i,P);if(ht&&(t.fillStyle=ht),f==="Line")t.strokeStyle=H>0&&z?z:ht||_,t.lineWidth=H>0?H:P,t.beginPath(),t.moveTo(-i/2,0),t.lineTo(vt,0),t.stroke();else{if(H>0&&z&&(t.strokeStyle=z,t.lineWidth=H),t.beginPath(),f==="Rectangle")this.drawRoundRect(t,-i/2,-P/2,Wt,P,u);else{const dt=xe[f]||h||"";if(dt)try{const At=new Path2D(dt),Tt=We(dt),Ct=Math.min(Wt/Tt.width,P/Tt.height);t.save(),t.translate(-i/2+Wt/2,0),t.scale(Ct,Ct),t.translate(-Tt.cx,-Tt.cy),t.fill(At),t.strokeStyle&&t.lineWidth>0&&t.stroke(At),t.restore()}catch{this.drawRoundRect(t,-i/2,-P/2,Wt,P,u)}else this.drawRoundRect(t,-i/2,-P/2,Wt,P,u)}t.fill(),t.strokeStyle&&t.lineWidth>0&&t.stroke()}}t.save(),t.translate(vt,0);const J=t.getTransform(),ut=Math.sqrt(J.a*J.a+J.b*J.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*ut,t.shadowOffsetY=1*ut;const $t=this.createCanvasFill(t,N,x,U);$t&&(t.fillStyle=$t),et>0&&Mt&&(t.strokeStyle=Mt,t.lineWidth=et);const St=X&&E.thumbShape==="Icon"?E.thumbPath||k:F&&M.thumbShape==="Icon"&&M.thumbPath||k;if(mt(G,0,0,x,U,q,G==="Icon"?St:It),t.restore(),Y){t.save(),t.translate(vt+L,$);const ht=Math.round(a).toString();t.font="10px Inter, sans-serif";const dt=t.measureText(ht),At=6,Tt=4,Ct=dt.width+At*2,Yt=14+Tt;t.beginPath(),this.drawRoundRect(t,-Ct/2,-Yt/2,Ct,Yt,4),t.fillStyle=B,t.fill(),t.fillStyle=R,t.textAlign="center",t.textBaseline="middle",t.fillText(ht,0,0),t.restore()}const Pt=n.label||{},Ft=n.helperText||{},lt=n.fontFamily||"Inter";if(Pt.visible!==!1){const ht=Pt.text||"Label",dt=Pt.fontSize||12,At=Pt.color||"rgba(156, 163, 175, 1)",Tt=Pt.offset??8;t.font=`600 ${dt}px "${lt}", sans-serif`,t.fillStyle=At,t.textAlign="left",t.textBaseline="bottom";const Ct=-(i/2),Yt=-(P/2)-Tt;t.fillText(ht,Ct,Yt)}if(Ft.visible===!0){const ht=Ft.text||"Helper text",dt=Ft.fontSize||11,At=Ft.color||"rgba(156, 163, 175, 1)",Tt=Ft.offset??6;t.font=`400 ${dt}px "${lt}", sans-serif`,t.fillStyle=At,t.textAlign="left",t.textBaseline="top";const Ct=-(i/2),Yt=P/2+Tt;t.fillText(ht,Ct,Yt)}ct!==1&&t.restore()}renderDropdown(t,s){var Y;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",g=(e.isOpen||e.previewState==="active")&&!d;let u=e.backgroundColor,f=e.borderColor,h=e.color||"#333333";d?(u=e.disabledBackgroundColor||"#f3f4f6",f=e.disabledBorderColor||"#e5e7eb",h=e.disabledColor||"#9ca3af"):g?(u=e.activeBackgroundColor||u,f=e.activeBorderColor||f,h=e.activeColor||h):p&&(u=e.hoverBackgroundColor||u,f=e.hoverBorderColor||f,h=e.hoverColor||h),u||(u="#ffffff"),f||(f="#e5e7eb"),t.save();const m=t.globalAlpha;t.globalAlpha=m*(e.opacity??1),t.beginPath(),this.drawRoundRect(t,a,r,n,i,l),t.fillStyle=this.createCanvasFill(t,typeof u=="string"?{type:"Solid",color:u}:u,n,i)||"#ffffff",t.fill();const b=e.borderWidth??1;b>0&&(t.beginPath(),this.drawRoundRect(t,a,r,n,i,l),t.strokeStyle=this.createCanvasFill(t,typeof f=="string"?{type:"Solid",color:f}:f,n,i)||"#e5e7eb",t.lineWidth=b,t.stroke());const c=12,S=e.chevronType||"chevron",v=e.chevronSize||16,C=(g?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(S!=="none"){const B=a+n-c-v/2;t.save(),t.translate(B,0);const R=g?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(R*Math.PI/180),t.strokeStyle=C,t.fillStyle=C,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",S==="chevron")t.beginPath(),t.moveTo(-v/2,-v*.2),t.lineTo(0,v*.2),t.lineTo(v/2,-v*.2),t.stroke();else if(S==="custom"||S==="path"){const L=g&&e.openIconPath||e.closedIconPath;if(L){const $=new Path2D(L);t.save();const F=v/24;t.scale(F,F),t.translate(-12,-12),t.fill($),t.restore()}}t.restore()}const w=e.selectedOption||e.placeholder||"Select...",I=e.fontSize||14,k=e.fontWeight||400,O=e.fontFamily||"Inter, sans-serif";t.font=`${k} ${I}px ${O}`;const T=d?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":h;t.fillStyle=this.createCanvasFill(t,typeof T=="string"?{type:"Solid",color:T}:T,n,i)||"#333333",t.textAlign="left",t.textBaseline="middle";const A=S==="none"?0:v+8,D=n-c*2-A;if(t.save(),t.beginPath(),t.rect(a+c,r,D,i),t.clip(),t.fillText(w,a+c,0),t.restore(),g&&!d){const B=r+i+4,R=this.getResolvedDropdownOptions(s,e),L=e.itemHeight||32,$=e.listPadding??4,F=R.length*L+$*2,X=e.listCornerRadius??l;t.save();const M=e.listShadow||{},E=t.getTransform(),P=Math.sqrt(E.a*E.a+E.b*E.b)||1;t.shadowColor=typeof M.color=="string"?M.color:((Y=M.color)==null?void 0:Y.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(M.blur??12)*P,t.shadowOffsetY=(M.offsetY??6)*P,t.shadowOffsetX=(M.offsetX??0)*P,t.beginPath(),this.drawRoundRect(t,a,B,n,F,X),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},n,F)||"#ffffff",t.fill();const _=e.listBorderWidth??1;_>0&&(t.shadowColor="transparent",t.beginPath(),this.drawRoundRect(t,a,B,n,F,X),t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:f},n,F)||"#e5e7eb",t.lineWidth=_,t.stroke()),t.restore();const V=e.itemFontSize||I,G=e.itemFontFamily||O;t.font=`${k} ${V}px ${G}`,R.forEach((x,U)=>{const q=B+$+U*L;if(x===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},n,L)||"#f3f4f6",t.fillRect(a+_,q,n-_*2,L),t.fillStyle=e.itemSelectedColor||e.accentColor||h||"#374151";else if(t.fillStyle=e.listTextColor||h||"#333333",this.activeDropdownId===s.id&&this._lastPointerPos){const H=this._lastPointerPos.y-(B+$),z=Math.floor(H/L);U===z&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},n,L)||"#f9fafb",t.fillRect(a+_,q,n-_*2,L),t.fillStyle=e.itemHoverColor||h)}t.fillText(x,a+c,q+L/2)})}t.restore()}renderButton(t,s){var U;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||{},g=e.activeStyle||{},u=e.icon||{enabled:!1};let f=e.backgroundColor||e.buttonBgColor||((U=s.style)==null?void 0:U.fill)||"#3b82f6",h=(typeof d=="object"?d.color:null)||"#ffffff",m=typeof d=="string"?d:d.text||s.text||(s.name&&!s.name.toLowerCase().includes("component")?s.name:"Button"),b=n.cornerRadius??n.corner_radius??8,c=e.borderColor||"transparent",S=e.borderWidth||0,v=1;l&&g?(f=g.backgroundColor||f,h=g.color||h,m=g.text||m,v=g.scale??.95,b=g.cornerRadius??b):r&&p&&(f=p.backgroundColor||f,h=p.color||h,m=p.text||m,v=p.scale??1,b=p.cornerRadius??b,c=p.borderColor||c);const C=-i/2,w=-a/2;t.save(),t.scale(v,v),t.beginPath(),this.drawRoundRect(t,C,w,i,a,b);const I=this.createCanvasFill(t,f,i,a);I&&(t.fillStyle=I,t.fill()),(S>0||r&&p.borderColor)&&(t.strokeStyle=c,t.lineWidth=S||(r?1:0),t.stroke());const k=d.fontSize||14,O=d.fontFamily||"Inter",T=d.fontWeight||600;t.font=`${T} ${k}px "${O}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=h,t.textAlign="center",t.textBaseline="middle";const A=u.enabled===!0||u.enabled==="true",D=Number(u.size)||Math.round(k*1.15)||16,Y=u.color||h,B=Number(u.gap)??8,R=u.position||"left",L=u.margin||{left:0,right:0,top:0,bottom:0},$=(Number(L.left)||0)-(Number(L.right)||0),F=(Number(L.top)||0)-(Number(L.bottom)||0),X=!!(m&&String(m).trim().length>0),E=(X?t.measureText(String(m)):{width:0}).width,P=k*1.2;let _=0,V=0,G=0,x=0;if(A){if(!X||R==="center")G=$,x=F,_=0,V=0;else if(R==="left"){const q=D+B+E;G=-q/2+D/2+$,x=F,_=-q/2+D+B+E/2+$,V=0}else if(R==="right"){const q=E+B+D;_=-q/2+E/2+$,V=0,G=-q/2+E+B+D/2+$,x=F}else if(R==="top"){const q=D+B+P;G=$,x=-q/2+D/2+F,_=$,V=-q/2+D+B+P/2+F}else if(R==="bottom"){const q=P+B+D;_=$,V=-q/2+P/2+F,G=$,x=-q/2+P+B+D/2+F}this.drawButtonIcon(t,u,G,x,D,Y,O)}X&&R!=="center"&&(t.fillStyle=h,t.fillText(String(m),_,V)),t.restore()}drawButtonIcon(t,s,o,e,n,i,a="Inter"){const r=(s.svgPath||"").trim(),l=(s.character||s.char||"").trim(),d="M12 3L10.088 8.813A2 2 0 0 1 8.813 10.088L3 12L8.813 13.912A2 2 0 0 1 10.088 15.187L12 21L13.912 15.187A2 2 0 0 1 15.187 13.912L21 12L15.187 10.088A2 2 0 0 1 13.912 8.813L12 3Z";if(t.save(),l){t.font=`${Math.round(n)}px "${a}", -apple-system, sans-serif`,t.fillStyle=i,t.textAlign="center",t.textBaseline="middle",t.fillText(l,o,e),t.restore();return}if(r.startsWith("<svg")){const u=s.fill&&s.fill.type!=="None";let f=r.replace(/stroke\s*=\s*(['"])currentColor\1/gi,`stroke="${i}"`).replace(/stroke\s*:\s*currentColor/gi,`stroke: ${i}`);u?f=f.replace(/fill\s*=\s*(['"])currentColor\1/gi,`fill="${i}"`).replace(/fill\s*:\s*currentColor/gi,`fill: ${i}`):f=f.replace(/fill\s*=\s*(['"])currentColor\1/gi,'fill="none"').replace(/fill\s*:\s*currentColor/gi,"fill: none"),f.includes("xmlns=")||(f=f.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"'));const h=`svg_icon_${i}_${n}_${btoa(f.slice(0,80))}`;let m=this.imageCache.get(h);if(m||(m=new Image,m.crossOrigin="anonymous",m.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(f)))}`,this.imageCache.set(h,m)),m.complete&&m.naturalWidth>0){t.drawImage(m,o-n/2,e-n/2,n,n),t.restore();return}const b=[...f.matchAll(/<path[^>]*\bd=["']([^"']+)["']/gi)];if(b.length>0){t.translate(o,e);const c=n/24;t.scale(c,c),t.translate(-12,-12);const S=new Path2D(b.map(v=>v[1]).join(" "));u?(t.fillStyle=i,t.fill(S)):(t.strokeStyle=i,t.lineWidth=2,t.lineCap="round",t.lineJoin="round",t.stroke(S)),t.restore();return}}if(r&&!r.startsWith("<")){t.translate(o,e);const u=n/24;t.scale(u,u),t.translate(-12,-12);const f=new Path2D(r);t.fillStyle=i,t.fill(f),t.strokeStyle=i,t.lineWidth=1,t.stroke(f),t.restore();return}t.translate(o,e);const p=n/24;t.scale(p,p),t.translate(-12,-12);const g=new Path2D(d);t.fillStyle=i,t.fill(g),t.restore()}renderToggleButton(t,s){var m,b;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=e.checked??!1,i=((m=s.geometry)==null?void 0:m.width)||120,a=((b=s.geometry)==null?void 0:b.height)||40,r=-i/2,l=-a/2,d=e.corner_radius??8,p=e.label||{},g=n?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",u=n?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,r,l,i,a,d),t.fillStyle=g,t.fill();const f=p.fontSize||14,h=p.fontFamily||"Inter";t.font=`${p.fontWeight||600} ${f}px "${h}", sans-serif`,t.fillStyle=u,t.textAlign="center",t.textBaseline="middle",t.fillText(p.text||"Toggle",0,0),t.restore()}renderToggle(t,s){var Mt,ct,It,mt,kt,Ot,vt,Wt,J,ut,$t,St,Pt,Ft;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=s.geometry||{},i=n.width||52,a=n.height||30,r=e.checked??!1,l=e.toggleStyle||{},d=l.width,p=l.height,g=l.cornerRadius,u=r&&d?d:i,f=r&&p?p:a,h=-u/2,m=-f/2,b=r&&g!==void 0?g:e.cornerRadius??e.corner_radius??a/2,c=l.backgroundColor||e.activeColor||"#10b981",S=l.borderColor||e.borderColor||"transparent",v=l.borderWidth??e.borderWidth??0,C=l.knobColor||e.knobColor||"#ffffff",w=r?c:e.inactiveColor||"#374151",I=r?S:e.borderColor||"transparent",k=r?v:e.borderWidth??0,O=r?C:e.knobColor||"#ffffff",T=r&&l.knobShape||e.knobShape||"Circle",A=r&&l.knobSize||e.knobSize||0,D=r&&l.trackShape||e.trackShape||"Pill";e.disabled&&(t.globalAlpha*=.5);const Y=(lt,ht,dt,At,Tt,Ct)=>{try{const Yt=new Path2D(lt),ie=We(lt),te=Math.min(At/ie.width,Tt/ie.height),Zt=!lt.includes("z")&&!lt.includes("Z");t.save(),t.translate(ht,dt),t.scale(te,te),t.translate(-ie.cx,-ie.cy),Zt?(t.strokeStyle=Ct,t.lineWidth=Math.max(1.8,2.2/te),t.lineCap="round",t.lineJoin="round",t.stroke(Yt)):(t.fillStyle=Ct,t.fill(Yt)),t.restore()}catch{t.beginPath(),t.arc(ht,dt,Math.min(At,Tt)/2,0,Math.PI*2),Ct&&(t.fillStyle=Ct),t.fill()}},B=(lt,ht,dt,At,Tt,Ct,Yt)=>{try{const ie=new Path2D(lt),te=We(lt),Zt=Math.min(At/te.width,Tt/te.height);t.save(),t.translate(ht,dt),t.scale(Zt,Zt),t.translate(-te.cx,-te.cy),t.strokeStyle=Ct,t.lineWidth=Yt/Zt,t.lineCap="round",t.lineJoin="round",t.stroke(ie),t.restore()}catch{t.beginPath(),t.arc(ht,dt,Math.min(At,Tt)/2,0,Math.PI*2),Ct&&(t.strokeStyle=Ct),t.lineWidth=Yt,t.stroke()}},R=xe[D]||D,L=!["Pill","Rectangle","Circle"].includes(R),$=xe[T]||T,F=!["Circle","Square","Diamond","Star"].includes($),X=this.createCanvasFill(t,w,u,f);if(L?Y(R,h+u/2,m+f/2,u,f,X):(t.beginPath(),D==="Circle"?t.ellipse(h+u/2,m+f/2,u/2,f/2,0,0,Math.PI*2):D==="Pill"?this.drawRoundRect(t,h,m,u,f,f/2):this.drawRoundRect(t,h,m,u,f,b),X&&(t.fillStyle=X,t.fill())),k>0){const lt=this.createCanvasFill(t,I,u,f);L?B(R,h+u/2,m+f/2,u,f,lt,k):(t.beginPath(),D==="Circle"?t.ellipse(h+u/2,m+f/2,u/2,f/2,0,0,Math.PI*2):D==="Pill"?this.drawRoundRect(t,h,m,u,f,f/2):this.drawRoundRect(t,h,m,u,f,b),t.lineWidth=k,lt&&(t.strokeStyle=lt,t.stroke()))}const M=e.knobPadding??2,E=f-M*2,P=A>0?A:E,_=P/2,V=h+M,G=h+u-M-P,x=r?G:V,U=m+(f-P)/2,q=this.createCanvasFill(t,O,P,P);if(F)Y($,x+_,U+_,P,P,q);else{if(t.beginPath(),T==="Square"){const lt=Math.min(4,_/2);t.roundRect(x,U,P,P,lt)}else if(T==="Diamond"){const lt=x+_,ht=U+_;t.moveTo(lt,ht-_),t.lineTo(lt+_,ht),t.lineTo(lt,ht+_),t.lineTo(lt-_,ht),t.closePath()}else if(T==="Star"){const lt=x+_,ht=U+_,dt=5,At=_,Tt=_*.4;for(let Ct=0;Ct<dt*2;Ct++){const Yt=Ct%2===0?At:Tt,ie=Ct*Math.PI/dt-Math.PI/2,te=lt+Yt*Math.cos(ie),Zt=ht+Yt*Math.sin(ie);Ct===0?t.moveTo(te,Zt):t.lineTo(te,Zt)}t.closePath()}else t.arc(x+_,U+_,_,0,Math.PI*2);q&&(t.fillStyle=q,t.fill())}e.disabled&&(t.globalAlpha*=2);const N=((Mt=e.leftLabel)==null?void 0:Mt.enabled)&&((ct=e.leftLabel)==null?void 0:ct.text),H=((It=e.rightLabel)==null?void 0:It.enabled)&&((mt=e.rightLabel)==null?void 0:mt.text),z=((kt=e.leftLabel)==null?void 0:kt.gap)||8,et=((Ot=e.rightLabel)==null?void 0:Ot.gap)||8;if(N){const lt=(r?(vt=l.leftLabel)==null?void 0:vt.text:null)||((Wt=e.leftLabel)==null?void 0:Wt.text)||"",ht=(r?(J=l.leftLabel)==null?void 0:J.color:null)||((ut=e.leftLabel)==null?void 0:ut.color)||"#f3f4f6",dt=e.leftLabel;t.font=`${dt.fontWeight||400} ${dt.fontSize||12}px "${dt.fontFamily||"Inter"}", sans-serif`,t.fillStyle=ht,t.textBaseline="middle",t.textAlign="right",t.fillText(lt,h-z,0)}if(H){const lt=(r?($t=l.rightLabel)==null?void 0:$t.text:null)||((St=e.rightLabel)==null?void 0:St.text)||"",ht=(r?(Pt=l.rightLabel)==null?void 0:Pt.color:null)||((Ft=e.rightLabel)==null?void 0:Ft.color)||"#f3f4f6",dt=e.rightLabel;t.font=`${dt.fontWeight||400} ${dt.fontSize||12}px "${dt.fontFamily||"Inter"}", sans-serif`,t.fillStyle=ht,t.textBaseline="middle",t.textAlign="left",t.fillText(lt,h+u+et,0)}if(!N&&!H&&e.label&&e.label.text){const lt=e.label,ht=lt.fontSize||14,dt=lt.fontWeight||400,At=lt.fontFamily||"Inter";t.font=`${dt} ${ht}px "${At}", sans-serif`,t.fillStyle=lt.color||"#f3f4f6",t.textBaseline="middle";const Tt=lt.gap||10;let Ct=0,Yt=0;lt.position==="left"?(t.textAlign="right",Ct=h-Tt,Yt=0):lt.position==="right"?(t.textAlign="left",Ct=h+u+Tt,Yt=0):lt.position==="top"?(t.textAlign="center",Ct=0,Yt=m-Tt,t.textBaseline="bottom"):lt.position==="bottom"?(t.textAlign="center",Ct=0,Yt=m+f+Tt,t.textBaseline="top"):(t.textAlign="left",Ct=h+u+Tt,Yt=0),t.fillText(lt.text,Ct,Yt)}}renderCheckbox(t,s){var E,P,_,V;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=((E=s.geometry)==null?void 0:E.width)||140,i=((P=s.geometry)==null?void 0:P.height)||24,a=-n/2,r=-i/2,l=Math.max(12,Math.min(e.boxSize||18,i,n)),d=Math.min(e.cornerRadius??4,l/2),p=e.checked??!1,g=!!e.indeterminate,u=this.lastHoveredObjectId===s.id,f=this.activeObjectId===s.id,h=e.hoverStyle||{},m=e.activeStyle||{};let b=e.activeColor||"#3b82f6";const c=e.inactiveColor||"transparent";let S=e.checkColor||"#ffffff",v=e.borderColor||"#9ca3af";const C=e.borderWidth??1.5;let w=1;f&&m?(m.backgroundColor&&(b=m.backgroundColor),m.borderColor&&(v=m.borderColor),m.checkColor&&(S=m.checkColor),w=m.scale??.95):u&&h&&(h.backgroundColor&&(b=h.backgroundColor),h.borderColor&&(v=h.borderColor),h.checkColor&&(S=h.checkColor),w=h.scale??1);const I=!!(e.label&&e.label.text),k=((_=e.label)==null?void 0:_.gap)??8,O=((V=e.label)==null?void 0:V.position)||"right";let T=a,A=r+(i-l)/2,D=0,Y=0,B="left",R="middle";I?O==="right"?(T=a,A=r+(i-l)/2,D=T+l+k,Y=0,B="left",R="middle"):O==="left"?(T=a+n-l,A=r+(i-l)/2,D=T-k,Y=0,B="right",R="middle"):O==="top"?(T=a+(n-l)/2,A=r+i-l,D=0,Y=A-k,B="center",R="bottom"):O==="bottom"&&(T=a+(n-l)/2,A=r,D=0,Y=A+l+k,B="center",R="top"):(T=a+(n-l)/2,A=r+(i-l)/2);const L=p||g,$=L?b:c,F=L?b:v,X=L?0:C;e.disabled&&(t.globalAlpha*=.5),t.save(),w!==1&&t.scale(w,w),t.beginPath(),this.drawRoundRect(t,T,A,l,l,d);const M=this.createCanvasFill(t,$,l,l);if(M&&(t.fillStyle=M,t.fill()),X>0){t.lineWidth=X;const G=this.createCanvasFill(t,F,l,l);G&&(t.strokeStyle=G,t.stroke())}else if(L){t.lineWidth=1;const G=this.createCanvasFill(t,b,l,l);G&&(t.strokeStyle=G,t.stroke())}if(g){t.save(),t.beginPath();const G=this.createCanvasFill(t,S,l,l);t.strokeStyle=G||S,t.lineWidth=Math.max(2,l*.12),t.lineCap="round",t.moveTo(T+l*.25,A+l*.5),t.lineTo(T+l*.75,A+l*.5),t.stroke(),t.restore()}else if(p){t.save(),t.beginPath();const G=this.createCanvasFill(t,S,l,l);t.strokeStyle=G||S,t.lineWidth=Math.max(2,l*.12),t.lineCap="round",t.lineJoin="round";const x=T+l*.24,U=A+l*.5,q=T+l*.44,N=A+l*.7,H=T+l*.76,z=A+l*.28;t.moveTo(x,U),t.lineTo(q,N),t.lineTo(H,z),t.stroke(),t.restore()}if(e.disabled&&(t.globalAlpha*=2),I&&e.label&&e.label.text){const G=e.label;t.save(),t.font=`${G.fontWeight||400} ${G.fontSize||14}px "${G.fontFamily||"Inter"}", sans-serif`,t.fillStyle=G.color||"#111827",t.textAlign=B,t.textBaseline=R,t.fillText(G.text,D,Y),t.restore()}t.restore()}renderRadioGroup(t,s){var B,R;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=((B=s.geometry)==null?void 0:B.width)||180,i=((R=s.geometry)==null?void 0:R.height)||100,a=-n/2,r=-i/2;let l=e.optionsList||["Option 1","Option 2","Option 3"];if(e.isDataVarEnabled&&e.dataInputId){let L=this.inputs.get(e.dataInputId);if(L===void 0){const $=this.inputNameMap.get(e.dataInputId);$&&$.length>0&&(L=this.inputs.get($[0]))}L&&Array.isArray(L)&&(l=L.map($=>typeof $=="string"?$:String($)))}const d=e.selectedValue,p=e.orientation||"vertical",g=e.itemGap!==void 0?e.itemGap:16,u=this.lastHoveredObjectId===s.id,f=this.activeObjectId===s.id,h=e.hoverStyle||{},m=e.activeStyle||{};let b=e.activeColor||"#3b82f6",c=e.inactiveColor||"#4b5563",S=e.textColor||"#ffffff",v=1;f&&m?(m.activeColor&&(b=m.activeColor),m.inactiveColor&&(c=m.inactiveColor),m.textColor&&(S=m.textColor),v=m.scale??.95):u&&h&&(h.activeColor&&(b=h.activeColor),h.inactiveColor&&(c=h.inactiveColor),h.textColor&&(S=h.textColor),v=h.scale??1);const C=e.fontSize||14,w=e.fontFamily||"Inter",I=e.fontWeight||400;t.save(),e.disabled&&(t.globalAlpha*=.5),v!==1&&t.scale(v,v);const k=8,O=k*2,T=e.radioShape||"circle",A=e.borderWidth!==void 0?e.borderWidth:2,D=e.fillEmpty||"transparent",Y=(L,$,F,X)=>{if(t.beginPath(),X==="custom"&&e.customShapePath)try{const M=new Path2D(e.customShapePath),E=We(e.customShapePath),P=Math.min(F*2/E.width,F*2/E.height);t.save(),t.translate(L,$),t.scale(P,P),t.translate(-E.cx,-E.cy),!e.customShapePath.includes("z")&&!e.customShapePath.includes("Z")?(t.strokeStyle=t.fillStyle,t.lineWidth=Math.max(1.8,2.2/P),t.lineCap="round",t.lineJoin="round",t.stroke(M)):t.fill(M),t.restore();return}catch{t.arc(L,$,F,0,Math.PI*2);return}if(X==="square"){const M=F*1.6;t.rect(L-M/2,$-M/2,M,M)}else if(X==="diamond"){const M=F*1.4;t.moveTo(L,$-M),t.lineTo(L+M,$),t.lineTo(L,$+M),t.lineTo(L-M,$),t.closePath()}else if(X==="heart"){const M=F*.9;t.moveTo(L,$+M*.7),t.bezierCurveTo(L-M*1.5,$-M*.3,L-M*.5,$-M*1.5,L,$-M*.5),t.bezierCurveTo(L+M*.5,$-M*1.5,L+M*1.5,$-M*.3,L,$+M*.7)}else if(X==="star"){const M=F*1.1,E=F*.5;for(let P=0;P<5;P++){const _=(P*72-90)*Math.PI/180,V=(P*72+36-90)*Math.PI/180;P===0?t.moveTo(L+M*Math.cos(_),$+M*Math.sin(_)):t.lineTo(L+M*Math.cos(_),$+M*Math.sin(_)),t.lineTo(L+E*Math.cos(V),$+E*Math.sin(V))}t.closePath()}else t.arc(L,$,F,0,Math.PI*2)};if(t.font=`${I} ${C}px "${w}", sans-serif`,t.textBaseline="middle",t.textAlign="left",p==="vertical"){const L=Math.max(O,C)+g,$=l.length*L-g,F=r+Math.max(0,(i-$)/2);l.forEach((X,M)=>{const E=F+k+M*L,P=d===X,_=this.createCanvasFill(t,b,O,O),V=this.createCanvasFill(t,c,O,O);P?(t.fillStyle=_||b,Y(a+k,E,k,T),t.fill(),t.strokeStyle=_||b,t.lineWidth=A,Y(a+k,E,k,T),t.stroke()):(D!=="transparent"&&(t.fillStyle=D,Y(a+k,E,k,T),t.fill()),t.strokeStyle=V||c,t.lineWidth=A,Y(a+k,E,k,T),t.stroke()),t.fillStyle=S,t.fillText(X,a+O+8,E)})}else{const L=r+i/2;let $=0;t.font=`${I} ${C}px "${w}", sans-serif`,l.forEach(M=>{$+=O+6+t.measureText(M).width+g}),$-=g;let X=a+Math.max(0,(n-$)/2);l.forEach(M=>{const E=d===M,P=t.measureText(M).width,_=this.createCanvasFill(t,b,O,O),V=this.createCanvasFill(t,c,O,O);E?(t.fillStyle=_||b,Y(X+k,L,k,T),t.fill(),t.strokeStyle=_||b,t.lineWidth=A,Y(X+k,L,k,T),t.stroke()):(D!=="transparent"&&(t.fillStyle=D,Y(X+k,L,k,T),t.fill()),t.strokeStyle=V||c,t.lineWidth=A,Y(X+k,L,k,T),t.stroke()),t.fillStyle=S,t.fillText(M,X+O+6,L),X+=O+6+P+g})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const L=e.label;t.save(),t.font=`${L.fontWeight||400} ${L.fontSize||14}px "${L.fontFamily||"Inter"}", sans-serif`,t.fillStyle=L.color||"#9ca3af",t.textBaseline="middle";const $=L.gap||8;let F=0,X=0;L.position==="left"?(t.textAlign="right",F=a-$,X=0):L.position==="right"?(t.textAlign="left",F=a+n+$,X=0):L.position==="top"?(t.textAlign="center",F=0,X=r-$,t.textBaseline="bottom"):L.position==="bottom"&&(t.textAlign="center",F=0,X=r+i+$,t.textBaseline="top"),t.fillText(L.text,F,X),t.restore()}}renderBarChart(t,s){var $,F,X;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 M=this.inputs.get(e.dataInputId);if(M===void 0){const E=this.inputNameMap.get(e.dataInputId);E&&E.length>0&&(M=this.inputs.get(E[0]))}M&&Array.isArray(M)&&(n.categories=M.map(E=>typeof E=="string"?E:String(E)))}if(e.isDatasetsVarEnabled&&(($=e.datasetInputIds)==null?void 0:$.length)>0){const M=e.datasetInputIds.map((E,P)=>{var G;let _=this.inputs.get(E);if(_===void 0){const x=this.inputNameMap.get(E);x&&x.length>0&&(_=this.inputs.get(x[0]))}const V=((G=e.datasets)==null?void 0:G[P])||{id:`ds-${P}`,label:`Series ${P+1}`,data:[],color:"#6366f1"};return _&&Array.isArray(_)?{...V,data:_.map(x=>typeof x=="number"?x:parseFloat(x)||0)}:V});n.datasets=M}const i={width:((F=s.geometry)==null?void 0:F.width)||300,height:((X=s.geometry)==null?void 0:X.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],showHoverTooltip:n.showHoverTooltip!==void 0?!!n.showHoverTooltip:!0,hoverHighlight:n.hoverHighlight!==void 0?!!n.hoverHighlight:!0,hoverHighlightColor:n.hoverHighlightColor||"rgba(255, 255, 255, 0.22)",tooltipBg:n.tooltipBg||"#111827",tooltipTextColor:n.tooltipTextColor||"#f9fafb",tooltipRadius:n.tooltipRadius!==void 0?n.tooltipRadius:6,_hexToRgb:function(M,E){if(M.startsWith("rgba")||M.startsWith("rgb"))return M;M.startsWith("#")||(M="#"+M),M.length===4&&(M="#"+M[1]+M[1]+M[2]+M[2]+M[3]+M[3]);const P=parseInt(M.slice(1,3),16),_=parseInt(M.slice(3,5),16),V=parseInt(M.slice(5,7),16);return`rgba(${P},${_},${V},${E})`},_resolveColor:function(M,E){return typeof M=="string"?M:"#6366f1"},_makeGradient:function(M,E,P,_,V,G){if(!this.barGradient)return E;const x=this.gradientStartColor||E,U=M.createLinearGradient(P,_,V,G);return U.addColorStop(0,E),U.addColorStop(1,this._hexToRgb(x,this.gradientEndOpacity)),U},_drawRoundedBar:function(M,E,P,_,V,G,x){if(G=Math.min(G,Math.min(Math.abs(_),Math.abs(V))/2),G<=0||_===0||V===0){M.rect(E,P,_,V);return}M.beginPath(),x?(M.moveTo(E,P+V),M.lineTo(E,P+G),M.quadraticCurveTo(E,P,E+G,P),M.lineTo(E+_-G,P),M.quadraticCurveTo(E+_,P,E+_,P+G),M.lineTo(E+_,P+V),M.lineTo(E,P+V)):(M.moveTo(E,P),M.lineTo(E+_-G,P),M.quadraticCurveTo(E+_,P,E+_,P+G),M.lineTo(E+_,P+V-G),M.quadraticCurveTo(E+_,P+V,E+_-G,P+V),M.lineTo(E,P+V),M.lineTo(E,P)),M.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,g=1/0;const u=i.categories.length,f=i.datasets.length;if(i.chartType==="stacked")for(let M=0;M<u;M++){let E=0,P=0;i.datasets.forEach(_=>{const V=_.data[M]??0;V>=0?E+=V:P+=V}),E>p&&(p=E),P<g&&(g=P)}else i.datasets.forEach(M=>{M.data&&M.data.forEach(E=>{E>p&&(p=E),E<g&&(g=E)})});isFinite(p)||(p=10),isFinite(g)||(g=0),p=Math.max(p,0),g=Math.min(g,0);const h=p-g||10;t.save();const m=n.entranceStyle||{},b=m.type||"none",c=this.getEntranceProgress(s.id,m,n.previewState||"default");if(b!=="none"){if(b==="fade")t.globalAlpha*=c;else if(b==="draw")t.beginPath(),t.rect(-a/2-10,-r/2-10,(a+20)*c,r+20),t.clip();else if(b==="barGrow"){const M=-r/2+r*(1-c);t.beginPath(),t.rect(-a/2-10,M,a+20,r+20),t.clip()}else if(b==="slideUp"){const M=(1-c)*r*.4;t.translate(0,M),t.globalAlpha*=Math.min(1,c*2)}else b==="stagger"&&(i._staggerProg=c);m.showLegend===!1&&(i.showLegend=!1),m.showAxes===!1&&(i.showXAxis=!1,i.showYAxis=!1),m.showLabels===!1&&(i.showXLabels=!1,i.showYLabels=!1),m.showGrid===!1&&(i.showGridLines=!1)}i.enableShadows&&(t.shadowColor=i.shadowColor,t.shadowBlur=i.shadowBlur,t.shadowOffsetY=i.shadowOffsetY),t.font=i.axisLabelFontSize+"px Inter, sans-serif";const S=i.showYLabels?t.measureText(p.toFixed(0)).width+14:10,v=i.showXLabels?i.axisLabelFontSize+12:8,w=(i.showLegend&&f>0?i.legendFontSize+10:0)+8,I=10,k=l+S,O=d+w,T=a-S-I,A=r-w-v;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&&f>0){t.font=i.legendFontSize+"px Inter, sans-serif",t.textBaseline="middle";const M=d+12;let E=k;i.datasets.forEach((P,_)=>{const V=i._resolveColor(P.color,_),G=P.label||"Series "+(_+1),x=7;t.beginPath(),t.roundRect(E,M-x/2,x,x,2),t.fillStyle=V,t.fill(),t.fillStyle=i.legendColor,t.textAlign="left",t.fillText(G,E+x+4,M),E+=t.measureText(G).width+x+16})}const D=4;if(i.showGridLines){t.setLineDash(i.gridLineDash||[]),t.lineWidth=i.gridLineWidth||1,t.strokeStyle=i.gridColor;for(let M=0;M<=D;M++)if(i.orientation==="horizontal"){const E=k+M/D*T;t.beginPath(),t.moveTo(E,O),t.lineTo(E,O+A),t.stroke()}else{const E=O+M/D*A;t.beginPath(),t.moveTo(k,E),t.lineTo(k+T,E),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 M=0;M<=D;M++)if(i.orientation==="horizontal"){const E=g+M/D*h,P=k+M/D*T;t.textAlign="center",t.fillText(E.toFixed(0),P,O+A+i.axisLabelFontSize)}else{const E=p-M/D*h,P=O+M/D*A;t.textAlign="right",t.fillText(E.toFixed(0),k-6,P)}}t.setLineDash([]),i.showXAxis&&(t.lineWidth=i.xAxisLineWidth||1,t.strokeStyle=i.xAxisColor,t.beginPath(),t.moveTo(k,O+A),t.lineTo(k+T,O+A),t.stroke()),i.showYAxis&&(t.lineWidth=i.yAxisLineWidth||1,t.strokeStyle=i.yAxisColor,t.beginPath(),t.moveTo(k,O),t.lineTo(k,O+A),t.stroke()),i.enableShadows&&(t.shadowColor=i.shadowColor);const Y=[],B=this.graphHoverStates.get(s.id),R=B==null?void 0:B.hoveredCatIdx,L=B==null?void 0:B.hoveredDsIdx;if(i.chartType==="stacked")if(i.orientation==="horizontal"){const M=A/u;for(let E=0;E<u;E++){const P=O+E*M+M/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[E]||"",k-5,P),i.enableShadows&&(t.shadowColor=i.shadowColor));let _=k;i.datasets.forEach((V,G)=>{const x=V.data[E]??0;if(x===0)return;const U=x/h*T,q=Math.min(i.barWidth*f+i.barGap,M-8),N=P-q/2,H=_;_+=U;const z=i._resolveColor(V.color,G);Y.push({catIdx:E,dsIdx:G,category:i.categories[E]||"",label:V.label||`Series ${G+1}`,val:x,color:z,x:H,y:N,w:U,h:q}),t.beginPath(),t.fillStyle=i._makeGradient(t,z,H,N,H+U,N);const et=i._staggerProg;if(et!==void 0&&b==="stagger"){const ct=u*f,It=E*f+G,mt=Math.max(0,Math.min(1,et*ct-It));t.globalAlpha*=mt}i._drawRoundedBar(t,H,N,U,q,G===f-1?i.barCornerRadius:0,!1),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?z:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),R===E&&L===G&&i.hoverHighlight&&(t.save(),t.fillStyle=i.hoverHighlightColor,i._drawRoundedBar(t,H,N,U,q,G===f-1?i.barCornerRadius:0,!1),t.fill(),t.restore())})}}else{const M=T/u;for(let E=0;E<u;E++){const P=k+E*M+M/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[E]||"",P,O+A+5),i.enableShadows&&(t.shadowColor=i.shadowColor));let _=O+A;i.datasets.forEach((V,G)=>{const x=V.data[E]??0;if(x===0)return;const U=x/h*A,q=Math.min(i.barWidth*f+i.barGap,M-8),N=P-q/2,H=_-U;_-=U;const z=i._resolveColor(V.color,G);Y.push({catIdx:E,dsIdx:G,category:i.categories[E]||"",label:V.label||`Series ${G+1}`,val:x,color:z,x:N,y:H,w:q,h:U}),t.beginPath(),t.fillStyle=i._makeGradient(t,z,N,H,N,H+U);const et=i._staggerProg;if(et!==void 0&&b==="stagger"){const ct=u*f,It=E*f+G,mt=Math.max(0,Math.min(1,et*ct-It));t.globalAlpha*=mt}i._drawRoundedBar(t,N,H,q,U,G===f-1?i.barCornerRadius:0,!0),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?z:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),R===E&&L===G&&i.hoverHighlight&&(t.save(),t.fillStyle=i.hoverHighlightColor,i._drawRoundedBar(t,N,H,q,U,G===f-1?i.barCornerRadius:0,!0),t.fill(),t.restore())})}}else if(i.orientation==="horizontal"){const M=A/u,E=f*i.barWidth+Math.max(0,(f-1)*i.barGap),P=k+(0-g)/h*T;for(let _=0;_<u;_++){const V=O+_*M+M/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[_]||"",k-5,V),i.enableShadows&&(t.shadowColor=i.shadowColor));const G=V-E/2;i.datasets.forEach((x,U)=>{const q=x.data[_]??0,N=Math.abs(q/h*T);if(N<1)return;const H=G+U*(i.barWidth+i.barGap),z=q>=0?P:P-N,et=i._resolveColor(x.color,U);Y.push({catIdx:_,dsIdx:U,category:i.categories[_]||"",label:x.label||`Series ${U+1}`,val:q,color:et,x:z,y:H,w:N,h:i.barWidth}),t.beginPath(),t.fillStyle=i._makeGradient(t,et,z,H,z+N,H);const Mt=i._staggerProg;if(Mt!==void 0&&b==="stagger"){const It=u*f,mt=_*f+U,kt=Math.max(0,Math.min(1,Mt*It-mt));t.globalAlpha*=kt}i._drawRoundedBar(t,z,H,N,i.barWidth,i.barCornerRadius,!1),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?et:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),R===_&&L===U&&i.hoverHighlight&&(t.save(),t.fillStyle=i.hoverHighlightColor,i._drawRoundedBar(t,z,H,N,i.barWidth,i.barCornerRadius,!1),t.fill(),t.restore()),i.showValueOnTop&&q!==0&&(t.font=(i.valueFontWeight||"bold")+" "+(i.valueFontSize||10)+"px Inter, sans-serif",t.textAlign=q>=0?"left":"right",t.textBaseline="middle",t.fillStyle=i.valueColor==="auto"?et:i.valueColor||"#fff",t.shadowColor="transparent",t.fillText(q.toString(),q>=0?z+N+4:z-4,H+i.barWidth/2),i.enableShadows&&(t.shadowColor=i.shadowColor))})}}else{const M=T/u,E=f*i.barWidth+Math.max(0,(f-1)*i.barGap),P=O+A-(0-g)/h*A;for(let _=0;_<u;_++){const V=k+_*M+M/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[_]||"",V,O+A+5),i.enableShadows&&(t.shadowColor=i.shadowColor));const G=V-E/2;i.datasets.forEach((x,U)=>{const q=x.data[_]??0,N=Math.abs(q/h*A);if(N<1)return;const H=G+U*(i.barWidth+i.barGap),z=q>=0?P-N:P,et=i._resolveColor(x.color,U);Y.push({catIdx:_,dsIdx:U,category:i.categories[_]||"",label:x.label||`Series ${U+1}`,val:q,color:et,x:H,y:z,w:i.barWidth,h:N}),t.beginPath(),t.fillStyle=i._makeGradient(t,et,H,z,H,z+N);const Mt=i._staggerProg;if(Mt!==void 0&&b==="stagger"){const It=u*f,mt=_*f+U,kt=Math.max(0,Math.min(1,Mt*It-mt));t.globalAlpha*=kt}i._drawRoundedBar(t,H,z,i.barWidth,N,i.barCornerRadius,!0),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?et:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),R===_&&L===U&&i.hoverHighlight&&(t.save(),t.fillStyle=i.hoverHighlightColor,i._drawRoundedBar(t,H,z,i.barWidth,N,i.barCornerRadius,!0),t.fill(),t.restore()),i.showValueOnTop&&q!==0&&(t.font=(i.valueFontWeight||"bold")+" "+(i.valueFontSize||10)+"px Inter, sans-serif",t.textAlign="center",t.textBaseline=q>=0?"bottom":"top",t.fillStyle=i.valueColor==="auto"?et:i.valueColor||"#fff",t.shadowColor="transparent",t.fillText(q.toString(),H+i.barWidth/2,q>=0?z-4:z+N+4),i.enableShadows&&(t.shadowColor=i.shadowColor))})}}if(this.barChartRenderedBars.set(s.id,Y),i.showHoverTooltip&&R!==null&&R!==void 0&&L!==null&&L!==void 0){const M=Y.find(E=>E.catIdx===R&&E.dsIdx===L);if(M){t.save();const E=10,P=8,_=14,V=12,x=P*2+_+V+16,U=Math.max(...Y.map(Ot=>Math.abs(Ot.val))),q=U>0?Math.round(Math.abs(M.val)/U*100):0;t.font="bold 10px Inter, system-ui, sans-serif";const N=t.measureText(M.category||"Category").width;t.font="8px Inter, system-ui, sans-serif";const H=`${q}% of max (${U})`,z=t.measureText(H).width;t.font="9px Inter, system-ui, sans-serif";const et=t.measureText(`${M.label}: ${M.val}`).width+16,Mt=Math.max(N,z,et)+E*2;let ct=M.x+M.w/2-Mt/2,It=M.y-x-8;ct<-a/2+6&&(ct=-a/2+6),ct+Mt>a/2-6&&(ct=a/2-Mt-6),It<-r/2+6&&(It=M.y+M.h+8),It+x>r/2-6&&(It=r/2-x-6),t.shadowColor="rgba(0, 0, 0, 0.35)",t.shadowBlur=10,t.shadowOffsetX=0,t.shadowOffsetY=4,t.beginPath(),this.drawRoundRect(t,ct,It,Mt,x,i.tooltipRadius),t.fillStyle=i.tooltipBg,t.fill(),t.shadowColor="transparent",t.lineWidth=1,t.strokeStyle="rgba(255, 255, 255, 0.12)",t.stroke(),t.font="bold 10px Inter, system-ui, sans-serif",t.fillStyle=i.tooltipTextColor,t.textAlign="left",t.textBaseline="top",t.fillText(M.category,ct+E,It+P),t.font="8px Inter, system-ui, sans-serif",t.fillStyle="rgba(255,255,255,0.5)",t.fillText(H,ct+E,It+P+_);const mt=It+P+_+V+2;t.beginPath(),t.arc(ct+E+4,mt+5,3.5,0,Math.PI*2),t.fillStyle=M.color,t.fill(),t.font="9px Inter, system-ui, sans-serif",t.fillStyle=i.tooltipTextColor,t.fillText(`${M.label}: `,ct+E+12,mt);const kt=t.measureText(`${M.label}: `).width;t.font="bold 9px Inter, system-ui, sans-serif",t.fillStyle=M.color,t.fillText(`${M.val}`,ct+E+12+kt,mt),t.restore()}}t.restore()}renderPieChart(t,s){var k,O;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:ys[e.colorPalette||"vibrant"]||ys.vibrant;let i=e.slices||[{id:"slice-1",label:"Item 1",value:45,color:""}];if(e.isDataVarEnabled&&e.dataInputId){let T=this.inputs.get(e.dataInputId);if(T===void 0){const A=this.inputNameMap.get(e.dataInputId);A&&A.length>0&&(T=this.inputs.get(A[0]))}T&&Array.isArray(T)&&(i=T.map((A,D)=>{var Y,B;return{id:`slice-${D}`,label:((Y=i[D])==null?void 0:Y.label)||`Item ${D+1}`,value:typeof A=="number"?A:0,color:((B=i[D])==null?void 0:B.color)||""}}))}const a={width:((k=s.geometry)==null?void 0:k.width)||180,height:((O=s.geometry)==null?void 0:O.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)",showHoverTooltip:e.showHoverTooltip!==void 0?!!e.showHoverTooltip:!0,hoverExplode:e.hoverExplode!==void 0?!!e.hoverExplode:!0,tooltipBg:e.tooltipBg||"#111827",tooltipTextColor:e.tooltipTextColor||"#f9fafb",tooltipRadius:e.tooltipRadius!==void 0?e.tooltipRadius:6,_resolveSliceColor:function(T,A){return T.color?T.color:n[A%n.length]},_hexToRgb:function(T){if(T.startsWith("rgba")||T.startsWith("rgb"))return T;const A=T.replace("#",""),D=parseInt(A.substring(0,2),16),Y=parseInt(A.substring(2,4),16),B=parseInt(A.substring(4,6),16);return`rgba(${D},${Y},${B},${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((T,A)=>T+(A.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=e.entranceStyle||{},g=p.type||"none",u=this.getEntranceProgress(s.id,p,e.previewState||"default");if(g!=="none"){if(g==="fade")t.globalAlpha*=u;else if(g==="draw")t.beginPath(),t.rect(-r/2-10,-l/2-10,(r+20)*u,l+20),t.clip();else if(g==="radial"){const T=Math.sqrt(r*r+l*l)/2;t.beginPath(),t.arc(0,0,T*u,0,Math.PI*2),t.clip()}else if(g==="sliceReveal"){if(i.reduce((A,D)=>A+(D.value||0),0)>0){const A=-Math.PI/2+u*Math.PI*2;t.beginPath(),t.moveTo(0,0),t.arc(0,0,Math.max(r,l),-Math.PI/2,A),t.lineTo(0,0),t.clip()}}else if(g==="spinIn"){const T=(1-u)*Math.PI*2;t.rotate(T),t.globalAlpha*=u}else if(g==="grow"){const T=u;t.scale(T,T),t.globalAlpha*=Math.min(1,u*2)}p.showLegend===!1&&(a.showLegend=!1),p.showLabels===!1&&(a.showLabels=!1),p.showCenterText===!1&&(a.showCenterText=!1)}const f=a._hexToRgb(a.cardBackground);t.beginPath(),t.roundRect(-r/2,-l/2,r,l,10),t.fillStyle=f,t.fill(),t.strokeStyle=a.cardBorderColor,t.lineWidth=1,t.stroke();const h=a.showLegend?Math.ceil(a.slices.length/2):0,m=h>0?h*(a.legendFontSize+8)+10:0,b=l-m-16,c=Math.min(r-24,b)/2,S=0,v=-m/2,C=[],w=this.graphHoverStates.get(s.id),I=(w==null?void 0:w.hoveredSliceIndex)??null;if(a.chartType==="rose"){const T=Math.max(...a.slices.map(Y=>Y.value||0)),A=Math.PI*2/a.slices.length,D=c>0?a.sliceGap/c:0;a.slices.forEach((Y,B)=>{const R=Y.value||0;if(R===0)return;const L=R/T*c,$=-Math.PI/2+B*A+D/2,F=$+A-D,X=a._resolveSliceColor(Y,B),M=$+(F-$)/2,E=I===B;let P=S,_=v;if(E&&a.hoverExplode&&(P+=Math.cos(M)*6,_+=Math.sin(M)*6),C.push({index:B,startA:$,endA:F,innerR:0,outerR:L,cx:P,cy:_,slice:Y,color:X,pct:Math.round(R/d*100)}),t.beginPath(),t.moveTo(P,_),t.arc(P,_,L,$,F),t.closePath(),t.fillStyle=X+"cc",t.fill(),t.strokeStyle=X,t.lineWidth=E?2.5:1.5,t.stroke(),a.showLabels){const V=P+L*.65*Math.cos(M),G=_+L*.65*Math.sin(M),x=Math.round(R/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(`${x}%`,V,G),t.restore()}})}else{const T=a.chartType==="pie"?0:a.innerRadius,A=c*Math.max(0,T),D=c>0?a.sliceGap/c:0;let Y=-Math.PI/2;if(a.slices.forEach((B,R)=>{const L=B.value||0;if(L===0){Y+=L/d*Math.PI*2;return}const $=L/d*Math.PI*2,F=Y+D/2,X=Y+$-D/2;if(X<=F){Y+=$;return}const M=a._resolveSliceColor(B,R),E=F+(X-F)/2,P=I===R;let _=S,V=v;if(P&&a.hoverExplode&&(_+=Math.cos(E)*6,V+=Math.sin(E)*6),C.push({index:R,startA:F,endA:X,innerR:A,outerR:c,cx:_,cy:V,slice:B,color:M,pct:Math.round(L/d*100)}),t.beginPath(),t.fillStyle=M,A<=0?(t.moveTo(_,V),t.arc(_,V,c,F,X),t.lineTo(_,V)):(t.moveTo(_+c*Math.cos(F),V+c*Math.sin(F)),t.arc(_,V,c,F,X),t.arc(_,V,A,X,F,!0),t.closePath()),t.fill(),P&&(t.lineWidth=2,t.strokeStyle="#ffffff",t.stroke()),a.showLabels){const G=A+(c-A)/2,x=_+G*Math.cos(E),U=V+G*Math.sin(E),q=Math.round(L/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(`${q}%`,x,U),t.restore()}Y+=$}),a.chartType==="donut"&&a.showCenterText&&A>14){const B=Math.round(d),R=Math.min(Math.floor(A*.52),20),L=Math.min(Math.floor(A*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${R}px Inter, sans-serif`,t.fillStyle=a.centerTextColor,t.fillText(B.toString(),S,v-L*.5),t.font=`${L}px Inter, sans-serif`,t.fillStyle=a.centerLabelColor,t.fillText(a.centerLabel,S,v+R*.6)}}if(this.pieChartRenderedSlices.set(s.id,C),a.showLegend&&a.slices.length>0){t.font=`${a.legendFontSize}px Inter, sans-serif`;const T=2,A=r/T,D=a.legendFontSize+8,Y=l/2-m+10,B=-r/2+10;a.slices.forEach((R,L)=>{const $=L%T,F=Math.floor(L/T),X=B+$*A,M=Y+F*D,E=a._resolveSliceColor(R,L),P=7;t.beginPath(),t.roundRect(X,M-P/2,P,P,2),t.fillStyle=E,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=a.legendColor;const _=Math.round((R.value||0)/d*100),V=`${R.label||"Item"} ${_}%`,G=A-P-20;let x=V;for(;t.measureText(x).width>G&&x.length>4;)x=x.slice(0,-4)+"…";t.fillText(x,X+P+4,M)})}if(a.showHoverTooltip&&I!==null&&I!==void 0){const T=C.find(A=>A.index===I);if(T){t.save();const A=10,D=8,Y=14,B=12,L=D*2+Y+B+16,$=i.reduce((N,H)=>N+(H.value||0),0);t.font="bold 10px Inter, system-ui, sans-serif";const F=t.measureText(T.slice.label||"Item").width;t.font="8px Inter, system-ui, sans-serif";const X=`of ${$} total`,M=t.measureText(X).width;t.font="9px Inter, system-ui, sans-serif";const E=`${T.slice.value} (${T.pct}%)`,P=t.measureText(E).width+16,_=Math.max(F,M,P)+A*2,V=T.startA+(T.endA-T.startA)/2,G=(T.innerR+T.outerR)/2;let x=T.cx+Math.cos(V)*(G+10)-_/2,U=T.cy+Math.sin(V)*(G+10)-L/2;x<-r/2+6&&(x=-r/2+6),x+_>r/2-6&&(x=r/2-_-6),U<-l/2+6&&(U=-l/2+6),U+L>l/2-6&&(U=l/2-L-6),t.shadowColor="rgba(0, 0, 0, 0.35)",t.shadowBlur=10,t.shadowOffsetX=0,t.shadowOffsetY=4,t.beginPath(),this.drawRoundRect(t,x,U,_,L,a.tooltipRadius),t.fillStyle=a.tooltipBg,t.fill(),t.shadowColor="transparent",t.lineWidth=1,t.strokeStyle="rgba(255, 255, 255, 0.12)",t.stroke(),t.font="bold 10px Inter, system-ui, sans-serif",t.fillStyle=a.tooltipTextColor,t.textAlign="left",t.textBaseline="top",t.fillText(T.slice.label||"Item",x+A,U+D),t.font="8px Inter, system-ui, sans-serif",t.fillStyle="rgba(255,255,255,0.5)",t.fillText(X,x+A,U+D+Y);const q=U+D+Y+B+2;t.beginPath(),t.arc(x+A+4,q+5,3.5,0,Math.PI*2),t.fillStyle=T.color,t.fill(),t.font="bold 9px Inter, system-ui, sans-serif",t.fillStyle="#60a5fa",t.fillText(E,x+A+12,q),t.restore()}}t.restore()}renderJoystick(t,s){var m,b,c,S,v,C,w,I,k,O,T,A;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.width)!==void 0?o.width:((m=s.geometry)==null?void 0:m.width)??s.width??100,n=(o==null?void 0:o.height)!==void 0?o.height:((b=s.geometry)==null?void 0:b.height)??s.height??100,i=Math.min(e,n)*(((c=s.style)==null?void 0:c.baseSize)??.45),a=Math.min(e,n)*(((S=s.style)==null?void 0:S.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 g=t.globalAlpha;if(t.globalAlpha=g*(((v=s.style)==null?void 0:v.baseOpacity)??1),t.beginPath(),s.boundsShape==="square"){const D=s.joystickType==="2D"?12:18;t.roundRect(-i,-i,i*2,i*2,D)}else t.arc(0,0,i,0,Math.PI*2);t.fillStyle=((C=s.style)==null?void 0:C.baseColor)||"rgba(255, 255, 255, 0.5)",t.fill(),(w=s.style)!=null&&w.baseBorderWidth?(t.lineWidth=s.style.baseBorderWidth,t.strokeStyle=s.style.baseBorderColor||"rgba(0,0,0,0.1)",t.stroke()):(t.lineWidth=1.5,t.strokeStyle=((I=s.style)==null?void 0:I.baseBorderColor)||"rgba(0, 0, 0, 0.15)",t.stroke());const u=s.overflowHandle?i:Math.max(.1,i-a);let f=0,h=0;s.joystickType==="2D"?(f=r*u,h=l*u):s.joystickType==="1D_X"?(f=r*u,h=0):s.joystickType==="1D_Y"&&(f=0,h=l*u),t.globalAlpha=g*(((k=s.style)==null?void 0:k.handleOpacity)??1),t.beginPath(),t.arc(f,h,a,0,Math.PI*2),t.fillStyle=((O=s.style)==null?void 0:O.handleColor)||"#3b82f6",t.fill(),(T=s.style)!=null&&T.handleBorderWidth?(t.lineWidth=s.style.handleBorderWidth,t.strokeStyle=s.style.handleBorderColor||"rgba(255,255,255,0.5)",t.stroke()):(t.lineWidth=1,t.strokeStyle=((A=s.style)==null?void 0:A.handleBorderColor)||"rgba(255,255,255,0.5)",t.stroke()),t.globalAlpha=g,t.restore()}getRadioGroupItemIndexAtPointer(t,s,o){var k,O;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:((k=t.geometry)==null?void 0:k.width)||180,r=n.height!==void 0?n.height:((O=t.geometry)==null?void 0:O.height)||100,l=e.orientation||"vertical",d=e.itemGap!==void 0?e.itemGap:16,p=e.fontSize||14,g=this.getWorldTransform(t.id),u=s-g.x,f=o-g.y,h=-g.rotation*(Math.PI/180),m=Math.cos(h),b=Math.sin(h),c=u*m-f*b,S=u*b+f*m,C=8*2,w=-a/2,I=-r/2;if(l==="vertical"){const T=Math.max(C,p)+d;for(let A=0;A<i.length;A++){const D=I+A*T;if(c>=w&&c<=w+a&&S>=D&&S<=D+T)return A}}else{let T=w;for(let A=0;A<i.length;A++){const Y=i[A].length*8,B=C+6+Y+d;if(c>=T&&c<=T+B&&S>=I&&S<=I+r)return A;T+=B}}return null}renderLineGraph(t,s,o,e,n){const i=this.objectStates.get(s.id),a=(i==null?void 0:i.options)||s.options||{},r=a.hoverStyle||{},l=a.loadingStyle||{},d=a.entranceStyle||{},p=a.pressedStyle||{};let g=o.datasets||[];(!g||g.length===0)&&(o.data||o.graphData)&&(g=[{id:"line-1",label:"Series 1",data:o.data||o.graphData||[],lineColor:o.lineColor||"#3b82f6",lineWidth:o.lineWidth||2,showArea:o.showArea||!1,areaColor:o.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:o.smoothing||!1,showPoints:o.showPoints!==void 0?o.showPoints:!0,pointSize:o.pointSize||6,pointFill:o.pointFill||"#ffffff",pointStrokeColor:o.pointStrokeColor||o.lineColor||"#3b82f6",pointStrokeWidth:o.pointStrokeWidth||2}]);let u=1/0,f=-1/0,h=0;g.forEach(B=>{let R=B.data;if(B.isVarEnabled&&B.inputId){let L=this.inputs.get(B.inputId);if(L===void 0){const $=this.inputNameMap.get(B.inputId);$&&$.length>0&&(L=this.inputs.get($[0]))}if(L!=null){if(typeof L=="string")try{L=JSON.parse(L)}catch{L=L.split(",").map($=>Number($.trim()))}Array.isArray(L)&&(R=L)}}if(R&&R.length>0){const L=R.map($=>Number($)).filter($=>!isNaN($));L.length>0&&(u=Math.min(u,...L),f=Math.max(f,...L),h=Math.max(h,L.length))}B._resolvedData=R});const m=a.previewState||"default";if(a.simulateLoading||m==="loading"||h<2){const B=l.skeletonColor||"rgba(100, 116, 139, 0.4)",R=l.pulseSpeed||1.5,L=l.minOpacity||.3,$=this.currentTime,F=L+(1-L)*(.5*(1+Math.sin($*Math.PI*2*R)));t.save(),t.globalAlpha=F,t.strokeStyle=B,t.lineWidth=o.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.beginPath();const X=40;for(let M=0;M<=X;M++){const E=-e/2+e/X*M,P=Math.sin(M*.4-$*4)*(n/8);M===0?t.moveTo(E,P):t.lineTo(E,P)}t.stroke(),t.restore();return}const c=f-u,S=e/(h-1),v=B=>{const R=c===0?.5:(B-u)/c;return n/2-R*n},C=B=>B*S-e/2,w=o.axisColor||"#333333";if(o.showXAxis&&(t.beginPath(),t.strokeStyle=o.xAxisColor||w,t.lineWidth=1,t.moveTo(-e/2,n/2),t.lineTo(e/2,n/2),t.stroke()),o.showYAxis&&(t.beginPath(),t.strokeStyle=o.yAxisColor||w,t.lineWidth=1,t.moveTo(-e/2,-n/2),t.lineTo(-e/2,n/2),t.stroke()),t.fillStyle=o.axisLabelColor||"#333333",t.font=`${o.axisLabelFontSize||10}px Inter, sans-serif`,o.showXLabels){t.textAlign="center",t.textBaseline="top";for(let B=0;B<h;B++){const R=C(B);t.fillText(`${B+1}`,R,n/2+5)}}if(o.showYLabels){t.textAlign="right",t.textBaseline="middle";const B=-e/2-5,R=(f+u)/2;t.fillText(f.toFixed(1),B,v(f)),t.fillText(R.toFixed(1),B,v(R)),t.fillText(u.toFixed(1),B,v(u))}const I=10,k=d.type||"none",O=this.getEntranceProgress(s.id,d,m);if(t.save(),k==="fade"?t.globalAlpha*=O:k==="draw"&&(t.beginPath(),t.rect(-e/2-10,-n/2-10,(e+20)*O,n+20),t.clip()),k!=="none"&&(d.showAxes===!1&&(o.showXAxis=!1,o.showYAxis=!1),d.showLabels===!1&&(o.showXLabels=!1,o.showYLabels=!1)),g.forEach(B=>{const R=B._resolvedData;if(!(!R||R.length<2)){if(B.showArea){if(t.beginPath(),t.moveTo(C(0),n/2),t.lineTo(C(0),v(R[0])),B.smoothing&&R.length>2)for(let $=0;$<R.length-1;$++){const F=R[$===0?$:$-1],X=R[$],M=R[$+1],E=R[$+1===R.length-1?$+1:$+2];for(let P=1;P<=I;P++){const _=P/I,V=this._catmullRom(F,X,M,E,_);t.lineTo(C($+_),v(V))}}else for(let $=1;$<R.length;$++)t.lineTo(C($),v(R[$]));t.lineTo(C(R.length-1),n/2),t.closePath();const L=t.globalAlpha;t.globalAlpha=L*(o.areaOpacity??.3),t.fillStyle=B.areaColor||"rgba(139, 92, 246, 0.2)",t.fill(),t.globalAlpha=L}if(t.beginPath(),t.strokeStyle=B.lineColor||"#3b82f6",t.lineWidth=B.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.moveTo(C(0),v(R[0])),B.smoothing&&R.length>2)for(let L=0;L<R.length-1;L++){const $=R[L===0?L:L-1],F=R[L],X=R[L+1],M=R[L+1===R.length-1?L+1:L+2];for(let E=1;E<=I;E++){const P=E/I,_=this._catmullRom($,F,X,M,P);t.lineTo(C(L+P),v(_))}}else for(let L=1;L<R.length;L++)t.lineTo(C(L),v(R[L]));t.stroke(),(B.showPoints||m==="hover"||m==="pressed")&&R.forEach((L,$)=>{const F=C($),X=v(L);let M=(B.pointSize||6)/2,E=!1,P=!1;const _=$===Math.floor(R.length/2);m==="pressed"&&_?P=!0:m==="hover"&&_&&(E=!0),!(!B.showPoints&&!E&&!P)&&(P?(M*=p.scale||1.5,t.beginPath(),t.arc(F,X,M*1.5,0,Math.PI*2),t.fillStyle=p.rippleColor||"rgba(59, 130, 246, 0.4)",t.fill()):E&&(M*=r.scale||1.02),t.beginPath(),t.arc(F,X,M,0,Math.PI*2),t.fillStyle=B.pointFill||"#ffffff",t.fill(),t.strokeStyle=B.pointStrokeColor||B.lineColor||"#3b82f6",t.lineWidth=B.pointStrokeWidth||1,t.stroke())})}}),t.restore(),o.showLegend&&g.length>0){const B=e/2-10;let R=-n/2+15;const L=o.legendFontSize||10,$=L+5;t.font=`${L}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",g.forEach(F=>{const M=F.label||"Series",E=t.measureText(M).width;t.beginPath(),t.rect(B-E-8-5,R-(8/2+2),8,8),t.fillStyle=F.lineColor||"#3b82f6",t.fill(),t.fillStyle=o.legendColor||"#333333",t.fillText(M,B,R),R+=$})}const T=this.graphHoverStates.get(s==null?void 0:s.id),A=T==null?void 0:T.hoveredIndex,D=o.showHoverTooltip!==!1,Y=o.showHoverLine!==!1;if(A!=null&&(D||Y)){const B=C(A);Y&&(t.save(),t.beginPath(),t.strokeStyle=o.hoverLineColor||"rgba(255, 255, 255, 0.35)",t.lineWidth=1,t.setLineDash([3,3]),t.moveTo(B,-n/2),t.lineTo(B,n/2),t.stroke(),t.setLineDash([]),t.restore());const R=[];if(g.forEach(L=>{const $=L._resolvedData||L.data;if($&&$[A]!==void 0&&typeof $[A]=="number"&&!isNaN($[A])){const F=$[A],X=v(F),M=L.lineColor||"#3b82f6";R.push({y:X,color:M,label:L.label||"Series",val:F});const E=this.isMouseDown,P=E?p.scale||1.5:1,_=E?p.rippleColor||"rgba(59, 130, 246, 0.4)":typeof M=="string"&&M.startsWith("#")?`${M}33`:"rgba(59, 130, 246, 0.2)";t.save(),t.beginPath();const V=o.pointHighlightRadius||5;t.arc(B,X,(V+3)*P,0,Math.PI*2),t.fillStyle=_,t.fill(),t.beginPath(),t.arc(B,X,V*P,0,Math.PI*2),t.fillStyle="#ffffff",t.fill(),t.strokeStyle=M,t.lineWidth=2.5*P,t.stroke(),t.restore()}}),D&&R.length>0){t.save();const L=10,$=8,F=16,X=14,M=$*2+X+R.length*F;t.font="bold 10px Inter, system-ui, sans-serif";let E=t.measureText(`Point #${A+1}`).width;t.font="9px Inter, system-ui, sans-serif",R.forEach(U=>{const q=t.measureText(`${U.label}: ${U.val.toFixed(1)}`).width+16;q>E&&(E=q)});const P=E+L*2;let _=B+12;_+P>e/2-4&&(_=B-P-12),_<-e/2+4&&(_=-e/2+4);let G=R.reduce((U,q)=>U+q.y,0)/R.length-M/2;G<-n/2+6&&(G=-n/2+6),G+M>n/2-6&&(G=n/2-M-6),t.shadowColor="rgba(0, 0, 0, 0.35)",t.shadowBlur=10,t.shadowOffsetX=0,t.shadowOffsetY=4,t.beginPath(),this.drawRoundRect(t,_,G,P,M,o.tooltipRadius||6),t.fillStyle=o.tooltipBg||"#111827",t.fill(),t.shadowColor="transparent",t.lineWidth=1,t.strokeStyle="rgba(255, 255, 255, 0.12)",t.stroke(),t.font="bold 10px Inter, system-ui, sans-serif",t.fillStyle=o.tooltipTextColor||"#f9fafb",t.textAlign="left",t.textBaseline="top",t.fillText(`Point #${A+1}`,_+L,G+$);let x=G+$+X+2;t.font="9px Inter, system-ui, sans-serif",R.forEach(U=>{t.beginPath(),t.arc(_+L+4,x+5,3.5,0,Math.PI*2),t.fillStyle=U.color,t.fill(),t.fillStyle=o.tooltipTextColor||"#f9fafb",t.fillText(`${U.label}: `,_+L+12,x);const q=t.measureText(`${U.label}: `).width;t.font="bold 9px Inter, system-ui, sans-serif",t.fillStyle="#60a5fa",t.fillText(`${U.val.toFixed(1)}`,_+L+12+q,x),t.font="9px Inter, system-ui, sans-serif",x+=F}),t.restore()}}}_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.type)&&s.color){const r=typeof s.color=="string"?s.color:s.color.color||"#000000",d=(((i=(n=this.artboard)==null?void 0:n.tokens)==null?void 0:i.colors)||{})[r]||r;return t.fillStyle=d,d}if(typeof s=="object"&&"r"in s&&"g"in s&&"b"in s){const r=s.a!==void 0?s.a:s.opacity!==void 0?s.opacity:1;return`rgba(${s.r}, ${s.g}, ${s.b}, ${r})`}if((s.type==="LinearGradient"||s.type==="RadialGradient"||s.type==="AngularGradient"||s.type==="DiamondGradient")&&s.stops){const r=(l,d=100)=>{var v,C;const g=(((C=(v=this.artboard)==null?void 0:v.tokens)==null?void 0:C.colors)||{})[l]||l,u=this.normalizeOpacity(s.opacity??100),h=this.normalizeOpacity(d)*u;if(h>=1&&g.startsWith("#"))return g;const m=g.startsWith("#")?g.replace("#",""):"ffffff",b=parseInt(m.substring(0,2),16),c=parseInt(m.substring(2,4),16),S=parseInt(m.substring(4,6),16);return`rgba(${b}, ${c}, ${S}, ${h})`};if(s.type==="LinearGradient"){let l=0,d=-e/2,p=0,g=e/2;if(s.angle!==void 0&&(!s.start||!s.end)){const f=(s.angle-90)*Math.PI/180,h=Math.max(o,e)/2;l=Math.cos(f)*-h,d=Math.sin(f)*-h,p=Math.cos(f)*h,g=Math.sin(f)*h}else if(s.start||s.end){const f=(h,m,b)=>Array.isArray(h)?h[m]??.5:h&&typeof h=="object"?h[b]??.5:.5;l=f(s.start,0,"x")*o-o/2,d=f(s.start,1,"y")*e-e/2,p=f(s.end,0,"x")*o-o/2,g=f(s.end,1,"y")*e-e/2}Math.abs(l-p)<.001&&Math.abs(d-g)<.001&&(l=0,d=-e/2,p=0,g=e/2);const u=t.createLinearGradient(l,d,p,g);if(s.stops.forEach(f=>{const h=f.offset!==void 0?f.offset:f.pos!==void 0?f.pos:f.position!==void 0?f.position:0,m=r(f.color||"#000000",f.opacity??100);u.addColorStop(Math.max(0,Math.min(1,h)),m)}),s.gradientTransform&&u.setTransform){const[f,h,m,b,c,S]=s.gradientTransform;u.setTransform({a:f,b:h,c:m,d:b,e:c,f:S})}return u}else if(s.type==="RadialGradient"){const l=(f,h,m)=>Array.isArray(f)?f[h]??.5:f&&typeof f=="object"?f[m]??.5:.5,d=l(s.center,0,"x")*o-o/2,p=l(s.center,1,"y")*e-e/2,g=(s.radius??.5)*Math.max(o,e),u=t.createRadialGradient(d,p,0,d,p,g);if(s.stops.forEach(f=>{const h=f.offset!==void 0?f.offset:f.pos!==void 0?f.pos:f.position!==void 0?f.position:0,m=r(f.color||"#000000",f.opacity??100);u.addColorStop(Math.max(0,Math.min(1,h)),m)}),s.gradientTransform&&u.setTransform){const[f,h,m,b,c,S]=s.gradientTransform;u.setTransform({a:f,b:h,c:m,d:b,e:c,f:S})}return u}else if(s.type==="AngularGradient"){const l=(f,h,m)=>Array.isArray(f)?f[h]??.5:f&&typeof f=="object"?f[m]??.5:.5,d=l(s.center||[.5,.5],0,"x")*o-o/2,p=l(s.center||[.5,.5],1,"y")*e-e/2,g=(s.degree||s.angle||0)*(Math.PI/180),u=(a=t.createConicGradient)==null?void 0:a.call(t,g,d,p);if(u){if(s.stops.forEach(f=>{const h=f.offset!==void 0?f.offset:f.pos!==void 0?f.pos:f.position!==void 0?f.position:0,m=r(f.color||"#000000",f.opacity??100);u.addColorStop(Math.max(0,Math.min(1,h)),m)}),s.gradientTransform&&u.setTransform){const[f,h,m,b,c,S]=s.gradientTransform;u.setTransform({a:f,b:h,c:m,d:b,e:c,f:S})}return u}}else if(s.type==="DiamondGradient"){const l=(f,h,m)=>Array.isArray(f)?f[h]??.5:f&&typeof f=="object"?f[m]??.5:.5,d=l(s.center||[.5,.5],0,"x")*o-o/2,p=l(s.center||[.5,.5],1,"y")*e-e/2,g=(s.radius??.5)*Math.max(o,e);t.save(),t.translate(d,p),t.rotate(Math.PI/4);const u=t.createRadialGradient(0,0,0,0,0,g);if(s.stops.forEach(f=>{const h=f.offset!==void 0?f.offset:f.pos!==void 0?f.pos:f.position!==void 0?f.position:0,m=r(f.color||"#000000",f.opacity??100);u.addColorStop(Math.max(0,Math.min(1,h)),m)}),s.gradientTransform&&u.setTransform){const[f,h,m,b,c,S]=s.gradientTransform;u.setTransform({a:f,b:h,c:m,d:b,e:c,f:S})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=u,t.restore(),u}}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,g=s.scaleY??1,u=s.offsetX??0,f=s.offsetY??0,h=s.rotation??0;d.translateSelf(u,f),d.rotateSelf(h),d.scaleSelf(p,g),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 g=Math.min(Math.abs(e)/2,Math.abs(n)/2);if(r=Math.min(Math.max(0,r),g),l=Math.min(Math.max(0,l),g),d=Math.min(Math.max(0,d),g),p=Math.min(Math.max(0,p),g),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 R,L,$,F,X,M,E,P,_,V;const o=this.objectStates.get(s.id)||{},e=o.options||s.options||{},n=o.width!==void 0?o.width:((R=s.geometry)==null?void 0:R.width)||200,i=o.height!==void 0?o.height:((L=s.geometry)==null?void 0:L.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??(($=s.geometry)==null?void 0:$.cornerRadius)??((F=s.geometry)==null?void 0:F.corner_radius)??0,d=e.orientation||"vertical",p=this.getResolvedListViewItems(s,e),g=e.itemGap??10,u=e.itemHeight??50,f=e.itemWidth??200,h=e.scrollOffset??0,m=e.padding??0,b=e.glassEffect!==!1,c=e.accentColor||"#3b82f6",S=e.itemTextColor||"#333333",v=e.itemBackgroundColor||"#ffffff",C=e.hoveredIndex??null,w=e.activeItemIndex??null,I=e.glowIntensity??0,k=e.glowColor||"#3b82f6",O=typeof k=="string"?k:k.color||((M=(X=k.stops)==null?void 0:X[0])==null?void 0:M.color)||"#3b82f6",T=e.opacity!==void 0?e.opacity:s.opacity!==void 0?s.opacity:1;if(t.save(),t.globalAlpha*=T,I>0){const G=t.getTransform(),x=Math.sqrt(G.a*G.a+G.b*G.b)||1;t.shadowColor=O,t.shadowBlur=I*2*x,t.shadowOffsetX=0,t.shadowOffsetY=0}if(b){const G=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",x=this.createCanvasFill(t,G,n,i);t.fillStyle=x||"rgba(31, 41, 55, 0.4)",t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)||t.fill();const q=t.createLinearGradient(a,r,a+n,r+i);q.addColorStop(0,"rgba(255, 255, 255, 0.15)"),q.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),q.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=q,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)||t.fill();const H=e.borderWidth??0;if(H>0&&e.borderColor&&e.borderColor!=="transparent"){const et=this.createCanvasFill(t,e.borderColor,n,i);t.strokeStyle=et||"rgba(255, 255, 255, 0.25)",t.lineWidth=H}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 G=e.backgroundColor&&e.backgroundColor!=="transparent"?e.backgroundColor:e.listBackgroundColor||"transparent",x=this.createCanvasFill(t,G,n,i);if(x){t.fillStyle=x,t.beginPath();const q=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l);t.fill()}const U=e.borderWidth??0;if(U>0){const q=this.createCanvasFill(t,e.borderColor||"#cccccc",n,i);t.strokeStyle=q||"#cccccc",t.lineWidth=U,t.beginPath();const N=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l);t.stroke()}}t.shadowBlur=0;const A=e.clipContent!==!1&&e.listLayout!=="circular";if(A)if(t.save(),t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)&&e.containerShape==="custom")try{const x=new Path2D(e.containerPath);t.translate(a,r),t.scale(n/100,i/100),t.clip(x),t.scale(100/n,100/i),t.translate(-a,-r)}catch{}else t.clip();const D=typeof m=="number"?m:d==="vertical"?m[0]:m[3];let Y=(d==="vertical"?r:a)+h+D;if(t.textBaseline="middle",p.forEach((G,x)=>{var ut,$t,St,Pt;const U=e.listLayout||"linear",q=U==="circular"?f:d==="vertical"?n:f,N=U==="circular"||d==="vertical"?u:i;let H=0,z=0,et=0;if(U==="circular"){const Ft=p.length||1,lt=Math.PI*2/Ft,ht=e.circularStartAngle||0,dt=e.circularRadius||100,At=h*.01+ht*Math.PI/180,Tt=x*lt+At,Ct=a+n/2,Yt=r+i/2;H=Ct+Math.cos(Tt)*dt-q/2,z=Yt+Math.sin(Tt)*dt-N/2,et=Tt+(e.itemRotation||0)*Math.PI/180}else H=d==="vertical"?a:Y,z=d==="vertical"?Y:r,et=(e.itemRotation||0)*Math.PI/180;const Mt=C===x,ct=w===x,It=e.itemBorderWidth??0;t.save(),et!==0&&(t.translate(H+q/2,z+N/2),t.rotate(et),t.translate(-(H+q/2),-(z+N/2)));const mt=Mt?((ut=e.hoverStyle)==null?void 0:ut.scale)??1:ct?(($t=e.activeStyle)==null?void 0:$t.scale)??1:1;if(mt!==1&&(t.translate(H+q/2,z+N/2),t.scale(mt,mt),t.translate(-(H+q/2),-(z+N/2))),ct){const Ft=((St=e.activeStyle)==null?void 0:St.itemBackgroundColor)||e.activeBackgroundColor||(b?"rgba(255, 255, 255, 0.15)":"rgba(0, 0, 0, 0.1)"),lt=this.createCanvasFill(t,Ft,q,N);t.fillStyle=lt||(typeof Ft=="string"?Ft:"transparent"),t.beginPath(),this.drawCustomShape(t,e.activeItemShape||e.itemShape||"rectangle",e.activeItemShape==="custom"?e.activeItemPath||"":e.itemPath||"",H,z,q,N,e.itemCornerRadius??0)||t.fill()}else if(Mt){const Ft=((Pt=e.hoverStyle)==null?void 0:Pt.itemBackgroundColor)||e.hoverBackgroundColor||(b?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)"),lt=this.createCanvasFill(t,Ft,q,N);t.fillStyle=lt||(typeof Ft=="string"?Ft:"transparent"),t.beginPath(),this.drawCustomShape(t,e.itemShape||"rectangle",e.itemPath||"",H,z,q,N,e.itemCornerRadius??0)||t.fill()}else if(v!=="transparent"){const Ft=this.createCanvasFill(t,v,q,N);t.fillStyle=Ft||(typeof v=="string"?v:"transparent"),t.beginPath(),this.drawCustomShape(t,e.itemShape||"rectangle",e.itemPath||"",H,z,q,N,e.itemCornerRadius??0)||t.fill()}if(It>0&&e.itemBorderColor&&e.itemBorderColor!=="transparent"){const Ft=this.createCanvasFill(t,e.itemBorderColor,q,N);t.strokeStyle=Ft||(typeof e.itemBorderColor=="string"?e.itemBorderColor:"#cccccc"),t.lineWidth=It,t.beginPath(),this.drawCustomShape(t,e.itemShape||"rectangle",e.itemPath||"",H,z,q,N,e.itemCornerRadius??0)||t.stroke()}if(ct){const Ft=this.createCanvasFill(t,c,d==="vertical"?3:q,d==="vertical"?N:3);t.fillStyle=Ft||c,d==="vertical"?t.fillRect(H,z,3,N):t.fillRect(H,z+N-3,q,3)}const kt=ct?"#ffffff":b?"rgba(255, 255, 255, 0.9)":S;t.fillStyle=kt,t.font=ct||Mt?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const Ot=typeof G=="string"?G:(G==null?void 0:G.label)||`Item ${x+1}`,vt=H+(d==="vertical"?16:q/2),Wt=z+N/2;d==="horizontal"||U==="circular"?t.textAlign="center":t.textAlign="left";const J=U==="circular"?H+q/2:vt;t.fillText(Ot,J,Wt),t.restore(),t.beginPath(),Y+=(d==="vertical"?u:f)+g}),A&&t.restore(),e.showScrollbar!==!1){const G=typeof m=="number"?m:d==="vertical"?m[0]:m[3],U=(p.length||0)*(d==="vertical"?u:f)+Math.max(0,(p.length||0)-1)*g+G*2,q=d==="vertical"?i:n,N=e.listLayout||"linear",H=e.containerShape==="circle"||N==="circular",z=e.scrollbarColor||"rgba(255,255,255,0.3)";let et=typeof z=="object"?z.color||((P=(E=z.stops)==null?void 0:E[0])==null?void 0:P.color)||"rgba(255,255,255,0.3)":z;const Mt=((V=(_=this.artboard)==null?void 0:_.tokens)==null?void 0:V.colors)||{};Mt[et]&&(et=Mt[et]);const ct=e.scrollbarWidth||2;if(t.save(),H){const It=Math.min(n,i)/2-ct/2-2,mt=a+n/2,kt=r+i/2;if(t.strokeStyle=et,t.lineWidth=ct,t.lineCap="round",t.beginPath(),N==="circular"){const Ot=Math.PI/4,vt=-(h*.01)-Math.PI/2;t.arc(mt,kt,It,vt,vt+Ot)}else{const Ot=Math.PI/2,vt=U>0?Math.min(1,q/U):1,Wt=Ot*vt,J=U>0?-h/U*Ot:0,$t=-Math.PI/4+J;t.arc(mt,kt,It,$t,$t+Wt)}t.stroke()}else{let It=q,mt=0;if(U>q){const kt=q/U;It=Math.max(16,q*kt);const Ot=q-It,vt=U-q;mt=vt>0?Math.max(0,Math.min(Ot,-h/vt*Ot)):0}if(t.fillStyle=et,d==="vertical"){const kt=a+n-ct-2,Ot=r+mt,vt=ct,Wt=It;if(ct>2){t.beginPath();const J=Math.min(ct/2,It/2);if(t.roundRect)try{t.roundRect(kt,Ot,vt,Wt,J),t.fill()}catch{t.fillRect(kt,Ot,vt,Wt)}else t.fillRect(kt,Ot,vt,Wt)}else t.fillRect(kt,Ot,vt,Wt)}else{const kt=a+mt,Ot=r+i-ct-2,vt=It,Wt=ct;if(ct>2){t.beginPath();const J=Math.min(ct/2,It/2);if(t.roundRect)try{t.roundRect(kt,Ot,vt,Wt,J),t.fill()}catch{t.fillRect(kt,Ot,vt,Wt)}else t.fillRect(kt,Ot,vt,Wt)}else t.fillRect(kt,Ot,vt,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 v,C,w,I;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,g=(s==null?void 0:s.width)!==void 0?s.width:((v=t.geometry)==null?void 0:v.width)||200,u=(s==null?void 0:s.height)!==void 0?s.height:((C=t.geometry)==null?void 0:C.height)||300,f=typeof o.padding=="number"?o.padding:e==="vertical"?((w=o.padding)==null?void 0:w[0])||0:((I=o.padding)==null?void 0:I[3])||0,m=(r.length||0)*(e==="vertical"?d:p)+Math.max(0,(r.length||0)-1)*l+f*2,b=e==="vertical"?u:g,c=Math.max(0,m-b);if(this.draggingListViewIsScrollbar&&o.listLayout!=="circular"){const k=m>0?b/m:1,O=Math.max(16,b*k),T=Math.max(1,b-O),A=c>0?c/T:1;e==="vertical"?a-=i*A:a-=n*A}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;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:(($=t.geometry)==null?void 0:$.width)||200,r=(e==null?void 0:e.height)!==void 0?e.height:((F=t.geometry)==null?void 0:F.height)||300,l=n.orientation||"vertical",d=n.itemGap??10,p=n.itemHeight??50,g=n.itemWidth??200,u=n.scrollOffset??0,f=n.padding??0,h=this.getWorldTransform(t.id),m=s-h.x,b=o-h.y,c=-h.rotation*(Math.PI/180),S=Math.cos(c),v=Math.sin(c),C=m*S-b*v,w=m*v+b*S,I=-a/2,k=-r/2,O=typeof f=="number"?f:l==="vertical"?f[0]:f[3];let T=(l==="vertical"?k:I)+u+O;const A=n.listLayout||"linear",D=i.length||1,Y=Math.PI*2/D,B=n.circularStartAngle||0,R=n.circularRadius||100,L=u*.01+B*Math.PI/180;for(let X=0;X<i.length;X++){const M=A==="circular"?g:l==="vertical"?a:g,E=A==="circular"||l==="vertical"?p:r;let P=0,_=0,V=0;if(A==="circular"){const G=X*Y+L,x=I+a/2,U=k+r/2;P=x+Math.cos(G)*R-M/2,_=U+Math.sin(G)*R-E/2,V=G+(n.itemRotation||0)*Math.PI/180}else P=l==="vertical"?I:T,_=l==="vertical"?T:k,V=(n.itemRotation||0)*Math.PI/180;if(V!==0){const G=P+M/2,x=_+E/2,U=C-G,q=w-x,N=-V,H=U*Math.cos(N)-q*Math.sin(N)+G,z=U*Math.sin(N)+q*Math.cos(N)+x;if(H>=P&&H<=P+M&&z>=_&&z<=_+E)return X}else if(C>=P&&C<=P+M&&w>=_&&w<=_+E)return X;T+=(l==="vertical"?p:g)+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 g,u,f,h,m,b,c,S,v,C,w,I,k,O,T,A,D,Y,B,R,L,$,F,X,M,E,P,_,V,G,x,U,q,N,H,z,et,Mt,ct,It,mt,kt,Ot,vt,Wt,J,ut,$t,St,Pt,Ft,lt,ht,dt,At,Tt,Ct,Yt,ie,te,Zt,le,fe,qt,Se,Ce,Ie,de,Re,ye,ke,Vt,ee,j,bt,st,K,rt,ft,Rt,Qt,Kt,ae,Jt,Et,W,nt,Lt,tt,gt,Q,Ut,zt,yt,Bt,_t,Xt,Dt,ce,be,Le,oe,pe,he,$e,Be,Ye,De,Xe,Ne,Ue,re,ve,Te,He,Ve,_e,Pe;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===it.Proximity){const Z=((g=i.settings)==null?void 0:g.radius)||300,ot=((u=i.settings)==null?void 0:u.falloff)||"smooth";let at=0;p<Z&&(ot==="linear"?at=1-p/Z:at=Math.pow(1-p/Z,2)),i.sensors.forEach(wt=>{this.applyBehaviorSensor(n,wt,at,t,i.settings,e,l,d,p)})}else if(i.type===it.Magnetic){const Z=((f=i.settings)==null?void 0:f.radius)||400,ot=((h=i.settings)==null?void 0:h.strength)||.5;if(p<Z&&p>5){const at=1-p/Z,wt=l*at*ot,Gt=d*at*ot;n.x-=wt*t*10,n.y-=Gt*t*10}}else if(i.type===it.Repel){const Z=((m=i.settings)==null?void 0:m.radius)||300,ot=((b=i.settings)==null?void 0:b.strength)||1;if(p<Z){const at=Math.pow(1-p/Z,2);n.x+=l/(p||1)*at*60*ot*t*5,n.y+=d/(p||1)*at*60*ot*t*5}}else if(i.type===it.Orbit){const Z=((c=i.settings)==null?void 0:c.speed)||1,ot=((S=i.settings)==null?void 0:S.radius)||30,at=this.currentTime*Z*Math.PI*2;n.x+=Math.cos(at)*ot*t*5,n.y+=Math.sin(at)*ot*t*5,n.rotation+=2*t*5}else if(i.type===it.Vortex){const Z=((v=i.settings)==null?void 0:v.radius)||400,ot=((C=i.settings)==null?void 0:C.speed)||2,at=((w=i.settings)==null?void 0:w.strength)||1;if(p<Z){const wt=Math.pow(1-p/Z,1.5),Gt=this.currentTime*ot*Math.PI*2,xt=Math.cos(Gt)*30-l*.4,jt=Math.sin(Gt)*30-d*.4;n.x+=xt*wt*at*t*5,n.y+=jt*wt*at*t*5,n.rotation+=5*wt*at*t*5,n.scale_x*=1-wt*.1*at*t,n.scale_y*=1-wt*.1*at*t}}else if(i.type===it.Fluid){const Z=((I=i.settings)==null?void 0:I.radius)||300,ot=((k=i.settings)==null?void 0:k.strength)||1;if(p<Z){const at=Math.pow(1-p/Z,1.2),wt=l/(p||1)*at*1.2*ot,Gt=d/(p||1)*at*1.2*ot;n.x+=wt*10*t*5,n.y+=Gt*10*t*5,n.scale_x*=1+at*.3*ot*t,n.scale_y*=1+at*.3*ot*t}}else if(i.type===it.Elastic){const Z=((O=i.settings)==null?void 0:O.radius)||300,ot=((T=i.settings)==null?void 0:T.strength)||1;if(p<Z){const at=1-p/Z;n.scale_x*=1+at*.4*ot*t,n.scale_y*=1+at*.4*ot*t}}else if(i.type===it.Holographic){const Z=n.x-this.canvasWidth/2,ot=n.y-this.canvasHeight/2,at=((A=i.settings)==null?void 0:A.factor)||25;if(n.x-=Z/1e3*at*t*5,n.y-=ot/1e3*at*t*5,n.style){const wt=1-Math.min(1,p/400);n.style.exposure=(n.style.exposure||1)+wt*.5*t}}else if(i.type===it.Sticky){const Z=((D=i.settings)==null?void 0:D.radius)||80,ot=((Y=i.settings)==null?void 0:Y.strength)||1;if(p<Z){const at=Math.pow(1-p/Z,2);n.x-=l*at*ot*t*10,n.y-=d*at*ot*t*10,n.scale_x*=1-at*.1*ot*t,n.scale_y*=1-at*.1*ot*t}}else if(i.type===it.Dilation){const Z=((B=i.settings)==null?void 0:B.size)||120,ot=((R=i.settings)==null?void 0:R.strength)||1;if(p<Z){const at=1-p/Z;n.scale_x*=1+at*.5*ot*t,n.scale_y*=1+at*.5*ot*t}}else if(i.type===it.Parallax){const Z=((L=i.settings)==null?void 0:L.factor)||15,ot=(($=i.settings)==null?void 0:$.strength)||1,at=this.canvasWidth/2,wt=this.canvasHeight/2,Gt=this._lastPointerPos||{x:at,y:wt},xt=(Gt.x-at)/at,jt=(Gt.y-wt)/wt,me=(((F=e.transform)==null?void 0:F.x)??0)+xt*Z*ot,Ae=(((X=e.transform)==null?void 0:X.y)??0)+jt*Z*ot,Fe=(((M=e.transform)==null?void 0:M.rotate_x)??0)-jt*Z*1.5*ot,we=(((E=e.transform)==null?void 0:E.rotate_y)??0)+xt*Z*1.5*ot,Oe=Math.min(1,10*t);n.x=this.lerp(n.x??((P=e.transform)==null?void 0:P.x)??0,me,Oe),n.y=this.lerp(n.y??((_=e.transform)==null?void 0:_.y)??0,Ae,Oe),n.rotate_x=this.lerp(n.rotate_x??((V=e.transform)==null?void 0:V.rotate_x)??0,Fe,Oe),n.rotate_y=this.lerp(n.rotate_y??((G=e.transform)==null?void 0:G.rotate_y)??0,we,Oe)}else if(i.type===it.Fold){if(p<300){const Z=1-p/300,ot=(l>0?-1:1)*Z*10,at=1-Z*.1,wt=d/300*Z*20,Gt=-(l/300)*Z*20,xt=Math.min(1,10*t);n.skew_x=this.lerp(n.skew_x??((x=e.transform)==null?void 0:x.skew_x)??0,ot,xt),n.scale_y=this.lerp(n.scale_y??((U=e.transform)==null?void 0:U.scale_y)??1,(((q=e.transform)==null?void 0:q.scale_y)??1)*at,xt),n.rotate_x=this.lerp(n.rotate_x??((N=e.transform)==null?void 0:N.rotate_x)??0,wt,xt),n.rotate_y=this.lerp(n.rotate_y??((H=e.transform)==null?void 0:H.rotate_y)??0,Gt,xt),n.style=n.style||{...e.style},n.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((z=i.settings)==null?void 0:z.opacity)??.5}}}else if(i.type===it.Crumple){if(p<300){const Z=1-p/300,ot=Z*(Math.random()-.5)*5,at=Z*(Math.random()-.5)*.05,wt=Math.min(1,15*t);n.skew_x=this.lerp(n.skew_x??((et=e.transform)==null?void 0:et.skew_x)??0,ot,wt),n.scale_x=this.lerp(n.scale_x??((Mt=e.transform)==null?void 0:Mt.scale_x)??1,(((ct=e.transform)==null?void 0:ct.scale_x)??1)*(1+at),wt),n.scale_y=this.lerp(n.scale_y??((It=e.transform)==null?void 0:It.scale_y)??1,(((mt=e.transform)==null?void 0:mt.scale_y)??1)*(1+at),wt),n.style=n.style||{...e.style},n.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((kt=i.settings)==null?void 0:kt.intensity)??1,scale:((Ot=i.settings)==null?void 0:Ot.scale)??2}}}else if(i.type===it.Squash){const Z=((vt=i.settings)==null?void 0:vt.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,(((J=e.transform)==null?void 0:J.scale_x)??1)*(1+(1-Z)*.4),.3)):(n.scale_y=this.lerp(n.scale_y??1,((ut=e.transform)==null?void 0:ut.scale_y)??1,.2),n.scale_x=this.lerp(n.scale_x??1,(($t=e.transform)==null?void 0:$t.scale_x)??1,.2))}else if(i.type===it.TextCounter){const Z=((St=i.settings)==null?void 0:St.duration)||2,ot=((Pt=i.settings)==null?void 0:Pt.from)||0,at=((Ft=i.settings)==null?void 0:Ft.to)||100;i._runtimeStart===void 0&&(i._runtimeStart=this.currentTime);const wt=this.currentTime-i._runtimeStart,Gt=Math.min(1,wt/Z),xt=Math.floor(ot+(at-ot)*Gt);if(((lt=e.geometry)==null?void 0:lt.type)==="Text"){const jt=((ht=i.settings)==null?void 0:ht.prefix)||"",me=((dt=i.settings)==null?void 0:dt.suffix)||"";n.geometry||(n.geometry={...e.geometry}),n.geometry.text=`${jt}${xt}${me}`}}else if(i.type===it.Spotlight){const Z=((At=i.settings)==null?void 0:At.radius)||250,ot=((Tt=i.settings)==null?void 0:Tt.strength)||1.5;if(p<Z){const at=Math.pow(1-p/Z,2);n.style||(n.style={...e.style}),n.style.adjustments||(n.style.adjustments={...(Ct=e.style)==null?void 0:Ct.adjustments}),n.style.adjustments.exposure=(((ie=(Yt=e.style)==null?void 0:Yt.adjustments)==null?void 0:ie.exposure)||0)+at*ot*50}else(te=n.style)!=null&&te.adjustments&&(n.style.adjustments.exposure=this.lerp(n.style.adjustments.exposure||0,((le=(Zt=e.style)==null?void 0:Zt.adjustments)==null?void 0:le.exposure)||0,.1))}else if(i.type===it.Noise||i.type===it.Float){const Z=(((fe=i.settings)==null?void 0:fe.frequency)||((qt=i.settings)==null?void 0:qt.speed)||1)*.002,ot=(((Se=i.settings)==null?void 0:Se.amplitude)||((Ce=i.settings)==null?void 0:Ce.range)||50)*(((Ie=i.settings)==null?void 0:Ie.strength)||1),at=Date.now();n.x+=Math.sin(at*Z)*ot*t,n.y+=Math.cos(at*Z*.8)*ot*t,n.rotation+=Math.sin(at*Z*.5)*5*t}else if(i.type===it.Pulse){const Z=(((de=i.settings)==null?void 0:de.speed)||1)*.005,ot=(((Re=i.settings)==null?void 0:Re.scale)||1.2)-1,at=Math.sin(Date.now()*Z),wt=((ye=i.settings)==null?void 0:ye.strength)||1;n.scale_x*=1+at*ot*wt*t,n.scale_y*=1+at*ot*wt*t,n.style&&(n.style.exposure=(n.style.exposure||1)+Math.max(0,at)*.1*wt*t)}else if(i.type===it.Draggable){if(!this.draggingBehaviors.has(e.id)){const ot=((ke=i.settings)==null?void 0:ke.radius)||150;if(p<ot){const at=((Vt=i.settings)==null?void 0:Vt.strength)||1,wt=Math.max(0,1-p/ot);this.applyBehaviorSensor(n,ge.PositionX,wt*at,t,i.settings,e,l,d,p),this.applyBehaviorSensor(n,ge.PositionY,wt*at,t,i.settings,e,l,d,p)}}}else if(i.type===it.Scroll){const Z=((ee=i.settings)==null?void 0:ee.axis)||"vertical",ot=((j=i.settings)==null?void 0:j.factor)||.5,at=((bt=i.settings)==null?void 0:bt.strength)||1,wt=((st=i.settings)==null?void 0:st.scaleFactor)||0;(Z==="vertical"||Z==="both")&&(n.y+=this.scrollOffset.y*ot*at*t),(Z==="horizontal"||Z==="both")&&(n.x+=this.scrollOffset.x*ot*at*t),wt!==0&&(n.scale_x*=1+this.scrollOffset.y*wt*t,n.scale_y*=1+this.scrollOffset.y*wt*t)}else if(i.type===it.LookAt){const Z=((K=i.settings)==null?void 0:K.factor)||1,ot=((rt=i.settings)==null?void 0:rt.strength)||1,at=Math.atan2(-d,-l)*(180/Math.PI),wt=n.rotation,Gt=(at-wt+180)%360-180;n.rotation+=Gt*Z*ot*t*10}else if(i.type===it.Scan){const Z=(((ft=i.settings)==null?void 0:ft.speed)||1)*.004,ot=((Rt=i.settings)==null?void 0:Rt.strength)||1,at=(Math.sin(Date.now()*Z)+1)/2;n.style&&(n.style.exposure=(n.style.exposure||1)+at*ot*t*5),n.x+=(at-.5)*20*ot*t}else if(i.type===it.Glint)n.style=n.style||{...e.style},n.style.artEffect={enabled:!0,type:"glint_overlay",intensity:((Qt=i.settings)==null?void 0:Qt.strength)??.8};else if(i.type===it.Ratchet){const Z=((Kt=i.settings)==null?void 0:Kt.steps)||12,ot=(((ae=i.settings)==null?void 0:ae.speed)||1)*30,at=Math.floor(n.rotation/(360/Z))*(360/Z);n.rotation=this.lerp(n.rotation,at+ot*t,.1)}else if(i.type===it.Jitter&&p<300){const Z=((Jt=i.settings)==null?void 0:Jt.strength)||1,ot=(((Et=i.settings)==null?void 0:Et.intensity)||5)*Z;n.x+=(Math.random()-.5)*ot*t*60,n.y+=(Math.random()-.5)*ot*t*60,n.rotation+=(Math.random()-.5)*ot*t*120}else if(i.type===it.Follower){const Z=(W=i.settings)==null?void 0:W.targetId;if(Z){const ot=this.objectStates.get(Z);if(ot){const at=((nt=i.settings)==null?void 0:nt.stiffness)||.1,wt=ot.x-n.x,Gt=ot.y-n.y;n.x+=wt*at*t*60,n.y+=Gt*at*t*60}}}else if(i.type===it.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===it.Gravity){const Z=((Lt=i.settings)==null?void 0:Lt.strength)||9.8;n.y+=Z*t*10}else if(i.type===it.Velocity){const Z=((tt=i.settings)==null?void 0:tt.vx)||0,ot=((gt=i.settings)==null?void 0:gt.vy)||0;n.x+=Z*t*10,n.y+=ot*t*10}else if(i.type===it.Shear){const Z=((Q=i.settings)==null?void 0:Q.strength)||1,ot=((Ut=i.settings)==null?void 0:Ut.radius)||300;if(p<ot){const at=1-p/ot;n.skew_x=this.lerp(n.skew_x||0,(((zt=e.transform)==null?void 0:zt.skew_x)||0)+at*Z*30,.1)}else n.skew_x=this.lerp(n.skew_x||0,((yt=e.transform)==null?void 0:yt.skew_x)||0,.05)}else if(i.type===it.Lens){const Z=((Bt=i.settings)==null?void 0:Bt.radius)||200,ot=((_t=i.settings)==null?void 0:_t.strength)||.5;if(p<Z){const at=Math.pow(1-p/Z,2);n.scale_x=this.lerp(n.scale_x??1,(((Xt=e.transform)==null?void 0:Xt.scale_x)??1)*(1+at*ot),.2),n.scale_y=this.lerp(n.scale_y??1,(((Dt=e.transform)==null?void 0:Dt.scale_y)??1)*(1+at*ot),.2)}else n.scale_x=this.lerp(n.scale_x??1,((ce=e.transform)==null?void 0:ce.scale_x)??1,.1),n.scale_y=this.lerp(n.scale_y??1,((be=e.transform)==null?void 0:be.scale_y)??1,.1)}else if(i.type===it.LayoutAnimation){const Z=((Le=i.settings)==null?void 0:Le.watchProperties)||["x","y","scale_x","scale_y","opacity","rotation"],ot=((oe=i.settings)==null?void 0:oe.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const at=this._layoutAnimCache.get(e.id);for(const wt of Z){const Gt=this.getObjectProperty(n,e,wt);if(Gt===void 0)continue;const xt=at.get(wt);if(!xt)at.set(wt,{from:Gt,to:Gt,startTime:this.currentTime,duration:0});else if(xt.to!==Gt){const me=this.getObjectProperty(n,e,wt);at.set(wt,{from:me??xt.from,to:Gt,startTime:this.currentTime,duration:((pe=i.settings)==null?void 0:pe.duration)??ot})}const jt=at.get(wt);if(jt.duration>0&&jt.from!==jt.to){const me=this.currentTime-jt.startTime,Ae=Math.min(1,me/jt.duration),Fe=this.applyEasing(Ae,((he=i.settings)==null?void 0:he.easing)||"easeOutCubic"),we=jt.from+(jt.to-jt.from)*Fe;this.setObjectProperty(n,e,wt,we)}}}else if(i.type===it.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const Z=this._layoutAnimCache.get(e.id),ot=(($e=i.settings)==null?void 0:$e.defaultDuration)||.3,at=["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 wt of at){const Gt=this.getObjectProperty(n,e,wt);if(Gt===void 0||typeof Gt!="number")continue;const xt=Z.get(wt);if(!xt)Z.set(wt,{from:Gt,to:Gt,startTime:this.currentTime,duration:0});else if(xt.to!==Gt){const me=this.getObjectProperty(n,e,wt);Z.set(wt,{from:me??xt.from,to:Gt,startTime:this.currentTime,duration:ot})}const jt=Z.get(wt);if(jt.duration>0&&jt.from!==jt.to){const me=this.currentTime-jt.startTime,Ae=Math.min(1,me/jt.duration),Fe=this.applyEasing(Ae,((Be=i.settings)==null?void 0:Be.defaultEasing)||"easeOutCubic"),we=jt.from+(jt.to-jt.from)*Fe;this.setObjectProperty(n,e,wt,we)}}}else if(i.type===it.SpringChain){const Z=((Ye=i.settings)==null?void 0:Ye.connections)||[],ot=((De=i.settings)==null?void 0:De.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const at=this._springChainState.get(e.id);for(const Gt of Z){if(!at.has(Gt.targetId)){const xt=this.objectStates.get(Gt.targetId);at.set(Gt.targetId,{x:(xt==null?void 0:xt.x)??0,y:(xt==null?void 0:xt.y)??0,vx:0,vy:0})}at.has(e.id)||at.set(e.id,{x:n.x,y:n.y,vx:0,vy:0})}const wt=at.get(e.id);if(wt){wt.x=n.x,wt.y=n.y;for(const Gt of Z){const xt=at.get(Gt.targetId);if(!xt)continue;const jt=xt.x-wt.x,me=xt.y-wt.y,Ae=Math.sqrt(jt*jt+me*me)||.001,we=(Ae-(Gt.restLength||50))*(Gt.stiffness||.8),Oe=jt/Ae*we,je=me/Ae*we;wt.vx+=Oe*t*10,wt.vy+=je*t*10,xt.vx-=Oe*t*10,xt.vy-=je*t*10,wt.vx*=1-ot*t*10,wt.vy*=1-ot*t*10,xt.vx*=1-ot*t*10,xt.vy*=1-ot*t*10;const Ee=this.objectStates.get(Gt.targetId);Ee&&(Ee.x+=xt.vx*t,Ee.y+=xt.vy*t)}n.x+=wt.vx*t,n.y+=wt.vy*t}}else if(i.type===it.ParticleEmitter){const Z=((Xe=i.settings)==null?void 0:Xe.rate)||10,ot=((Ne=i.settings)==null?void 0:Ne.speed)||100,at=((Ue=i.settings)==null?void 0:Ue.size)||5,wt=((re=i.settings)==null?void 0:re.lifetime)||2,Gt=((ve=i.settings)==null?void 0:ve.gravity)||0,xt=((Te=i.settings)==null?void 0:Te.color)||"#ffffff",jt=((He=i.settings)==null?void 0:He.maxParticles)||200,me=(Ve=i.settings)!=null&&Ve.rateInputId?this.inputs.get(i.settings.rateInputId)??Z:Z,Ae=(_e=i.settings)!=null&&_e.gravityInputId?this.inputs.get(i.settings.gravityInputId)??Gt:Gt,Fe=(Pe=i.settings)!=null&&Pe.speedInputId?this.inputs.get(i.settings.speedInputId)??ot:ot;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const we=this._emitterPools.get(e.id);let Oe=0;i._pendingBurst&&i._pendingBurst>0&&(Oe=i._pendingBurst,i._pendingBurst=0);const je=Math.floor(me*t)+(Oe||0);for(let Ee=0;Ee<Math.min(je,jt-we.length);Ee++){const Me=Math.random()*Math.PI*2,vs=Fe*(.5+Math.random()*.5);we.push({x:n.x,y:n.y,vx:Math.cos(Me)*vs,vy:Math.sin(Me)*vs,life:0,maxLife:wt*(.5+Math.random()*.5),size:at*(.5+Math.random()),color:xt,opacity:1})}for(let Ee=we.length-1;Ee>=0;Ee--){const Me=we[Ee];Me.vy+=Ae*t*10,Me.x+=Me.vx*t,Me.y+=Me.vy*t,Me.life+=t,Me.opacity=Math.max(0,1-Me.life/Me.maxLife),Me.life>=Me.maxLife&&we.splice(Ee,1)}}})})}applyBehaviorSensor(t,s,o,e,n,i,a=0,r=0,l=1){var f,h,m,b,c,S,v,C,w,I,k,O,T,A,D,Y,B,R,L,$,F,X,M,E;const d=(n==null?void 0:n.intensity)||(n==null?void 0:n.strength)||1,p=Math.min(1,15*e),g=l>0?a/l:0,u=l>0?r/l:0;switch(s){case ge.Scale:{const P=((f=i==null?void 0:i.transform)==null?void 0:f.scale_x)??1,_=((h=i==null?void 0:i.transform)==null?void 0:h.scale_y)??1,V=P*(1+o*d*.4),G=_*(1+o*d*.4);t.scale_x=(t.scale_x??P)*(1-p)+V*p,t.scale_y=(t.scale_y??_)*(1-p)+G*p;break}case ge.Opacity:{const P=((m=i==null?void 0:i.transform)==null?void 0:m.opacity)??100,_=Math.max(0,Math.min(100,P-o*d*100));t.opacity=(t.opacity??P)*(1-p)+_*p;break}case ge.RotateZ:{const P=((b=i==null?void 0:i.transform)==null?void 0:b.rotation)??0,_=P+o*d*45;t.rotation=(t.rotation??P)*(1-p)+_*p;break}case ge.RotateX:{const P=((c=i==null?void 0:i.transform)==null?void 0:c.rotate_x)??0,_=P-u*o*d*60;t.rotate_x=(t.rotate_x??P)*(1-p)+_*p;break}case ge.RotateY:{const P=((S=i==null?void 0:i.transform)==null?void 0:S.rotate_y)??0,_=P+g*o*d*60;t.rotate_y=(t.rotate_y??P)*(1-p)+_*p;break}case ge.PositionX:{const P=((v=i==null?void 0:i.transform)==null?void 0:v.x)??0,_=P-g*o*d*40;t.x=(t.x??P)*(1-p)+_*p;break}case ge.PositionY:{const P=((C=i==null?void 0:i.transform)==null?void 0:C.y)??0,_=P-u*o*d*40;t.y=(t.y??P)*(1-p)+_*p;break}case ge.SkewX:{const P=((w=i==null?void 0:i.transform)==null?void 0:w.skew_x)??0,_=P+g*o*d*45;t.skew_x=(t.skew_x??P)*(1-p)+_*p,t.skew_x>85&&(t.skew_x=85),t.skew_x<-85&&(t.skew_x=-85);break}case ge.Blur:{t.style||(t.style={...i==null?void 0:i.style}),t.style.blur||(t.style.blur={...(I=i==null?void 0:i.style)==null?void 0:I.blur});const P=((O=(k=i==null?void 0:i.style)==null?void 0:k.blur)==null?void 0:O.amount)||0,_=P+o*((n==null?void 0:n.blur)||20)*d;t.style.blur.amount=(t.style.blur.amount??P)*(1-p)+_*p;break}case ge.Exposure:{t.style||(t.style={...i==null?void 0:i.style}),t.style.adjustments||(t.style.adjustments={...(T=i==null?void 0:i.style)==null?void 0:T.adjustments});const P=((D=(A=i==null?void 0:i.style)==null?void 0:A.adjustments)==null?void 0:D.exposure)||0,_=P+o*((n==null?void 0:n.exposure)||50)*d;t.style.adjustments.exposure=(t.style.adjustments.exposure??P)*(1-p)+_*p;break}case ge.HueShift:{t.style||(t.style={...i==null?void 0:i.style}),t.style.adjustments||(t.style.adjustments={...(Y=i==null?void 0:i.style)==null?void 0:Y.adjustments});const P=((R=(B=i==null?void 0:i.style)==null?void 0:B.adjustments)==null?void 0:R.hue)||0,_=P+o*((n==null?void 0:n.hue)||180)*d;t.style.adjustments.hue=(t.style.adjustments.hue??P)*(1-p)+_*p;break}case ge.Negative:{t.style||(t.style={...i==null?void 0:i.style}),t.style.adjustments||(t.style.adjustments={...(L=i==null?void 0:i.style)==null?void 0:L.adjustments});const P=((F=($=i==null?void 0:i.style)==null?void 0:$.adjustments)==null?void 0:F.negative)||0,_=P+o*((n==null?void 0:n.negative)||100)*d;t.style.adjustments.negative=(t.style.adjustments.negative??P)*(1-p)+_*p;break}case ge.CornerRadius:{const P=((X=i==null?void 0:i.transform)==null?void 0:X.corner_radius)||0,_=P+o*d*50;t.corner_radius=(t.corner_radius??P)*(1-p)+_*p;break}case ge.StrokeWidth:{t.style||(t.style={...i==null?void 0:i.style});const P=((M=i==null?void 0:i.style)==null?void 0:M.borderWidth)||0,_=P+o*d*10;t.style.borderWidth=(t.style.borderWidth??P)*(1-p)+_*p;break}case ge.LetterSpacing:{t.geometry||(t.geometry={});const P=((E=i==null?void 0:i.geometry)==null?void 0:E.letterSpacing)||0,_=P+o*d*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??P)*(1-p)+_*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((f,h)=>f==null?void 0:f[h],d),g=n[r+1],u=!isNaN(Number(g));i[l]=p!==void 0?Array.isArray(p)?[...p]:{...p}:u?[]:{}}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,g=e.hue||0,u=(e.negative||0)/100,f=e.blur||0;if(!(n!==0||i!==0||a!==0||r!==0||l!==0||d!==0||p!==0||g!==0||u!==0||f>0))return t;const m=t.naturalWidth||Math.max(1,Math.round(s)),b=t.naturalHeight||Math.max(1,Math.round(o)),c=document.createElement("canvas");c.width=m,c.height=b;const S=c.getContext("2d");if(!S)return t;const v=[];f>0&&v.push(`blur(${f}px)`),g!==0&&v.push(`hue-rotate(${Math.round(g)}deg)`),v.length>0&&(S.filter=v.join(" ")),S.drawImage(t,0,0,m,b);try{const C=S.getImageData(0,0,m,b),w=C.data,I=w.length,k=n*255,O=i>=0?(1+i)/Math.max(.01,1-i):1+i,T=1+a,A=1+r-l/2,D=1+l,Y=1-r-l/2,B=1+d+p,R=p*25.5,L=1-u/50,$=(1-L)*255;for(let F=0;F<I;F+=4){let X=w[F],M=w[F+1],E=w[F+2];if(n!==0&&(X+=k,M+=k,E+=k),i!==0&&(X=(X-127.5)*O+127.5,M=(M-127.5)*O+127.5,E=(E-127.5)*O+127.5),a!==0){const P=.2989*X+.587*M+.114*E;X=P+(X-P)*T,M=P+(M-P)*T,E=P+(E-P)*T}(r!==0||l!==0)&&(X=X*A,M=M*D,E=E*Y),(d!==0||p!==0)&&(X=X*B+R,M=M*B+R,E=E*B+R),u!==0&&(X=X*L+$,M=M*L+$,E=E*L+$),w[F]=Math.min(255,Math.max(0,X)),w[F+1]=Math.min(255,Math.max(0,M)),w[F+2]=Math.min(255,Math.max(0,E))}return S.putImageData(C,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 g=n,u=i,f=o,h=e;a==="cover"?d>p?(g=i*d,f=o-(g-n)/2):(u=n/d,h=e-(u-i)/2):a==="contain"&&(d>p?(u=n/d,h=e+(i-u)/2):(g=i*d,f=o+(n-g)/2)),t.drawImage(s,f,h,g,u)}}const li=Nt.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:g,onInputBlur:u,onLog:f,onLogicUpdate:h,onButtonClick:m,onGraphPointClick:b,currentTime:c,revision:S=0,scrollY:v,scrollX:C,mouseX:w,mouseY:I,isMouseDown:k,inputs:O,interactive:T=!0,onNavigation:A},D)=>{const Y=Nt.useRef(null),B=Nt.useRef(null);B.current||(B.current=new bs);const R=Nt.useRef(void 0),L=Nt.useRef(0),$=Nt.useRef(null),F=Nt.useRef(S),X=Nt.useRef(null),[,M]=Nt.useState(y||null),E=Nt.useRef(!0),P=Nt.useRef(o),_=Nt.useRef(c);Nt.useEffect(()=>{P.current=o},[o]),Nt.useEffect(()=>{_.current=c},[c]),Nt.useImperativeHandle(D,()=>Y.current),Nt.useEffect(()=>(E.current=!0,()=>{E.current=!1,R.current&&cancelAnimationFrame(R.current)}),[]),Nt.useEffect(()=>{B.current.setLayout(e,n)},[e,n]),Nt.useEffect(()=>{const N=B.current;a&&N.setTriggerCallback(a),r&&N.setInputUpdateCallback((H,z)=>r({[H]:z})),l&&N.setComponentChangeCallback(H=>l(H)),d&&N.setToggleCallback(d),p&&N.setInputChangeCallback(p),g&&N.setInputFocusCallback(g),u&&N.setInputBlurCallback(u),f&&N.setOnLogCallback(H=>f(H,"info")),h&&N.setLogicUpdateCallback(h),m&&N.setButtonClickCallback(m),b&&N.setGraphPointClickCallback(H=>b(H.objectId,H)),A&&N.setNavigationCallback(A)},[a,r,l,d,p,g,u,f,h,m,b,A]),Nt.useEffect(()=>{(async()=>{let H=y;if(t&&!y)try{t.startsWith("{")?H=JSON.parse(t):H=await(await fetch(t)).json()}catch(z){console.error("[ExodeUI] Failed to load src:",z)}if(H){const z=B.current,et=H.id||H.name||"default";($.current!==et||F.current!==S||X.current!==H)&&(z.load(H),$.current=et,F.current=S,X.current=H,M(H),L.current=-1,z.advance(0)),i&&i(z)}})()},[y,t,S]),Nt.useEffect(()=>{const N=H=>{if(!B.current||!E.current)return;const z=B.current,et=Y.current;if(!et)return;const Mt=et.getContext("2d");if(!Mt)return;const ct=H/1e3;L.current<0&&(L.current=ct),L.current===0&&(L.current=ct);let It=ct-L.current;It>.1&&(It=.1),L.current=ct;const mt=et.getBoundingClientRect(),kt=window.devicePixelRatio||1,Ot=Math.round(mt.width*kt),vt=Math.round(mt.height*kt);(et.width!==Ot||et.height!==vt)&&(et.width=Ot,et.height=vt);try{P.current?z.advance(It):_.current!==void 0&&z.seek(_.current),z.render(Mt,et.width,et.height)}catch(Wt){console.error("[ExodeUICanvas] Error in animation loop:",Wt),f&&f(`[Error] Animation loop crashed: ${Wt}`,"error")}R.current=requestAnimationFrame(N)};return R.current=requestAnimationFrame(N),()=>{R.current&&cancelAnimationFrame(R.current)}},[]),Nt.useEffect(()=>{const N=B.current;v!==void 0&&N.updateInput("scrollY",v),C!==void 0&&N.updateInput("scrollX",C),w!==void 0&&N.updateInput("mouseX",w),I!==void 0&&N.updateInput("mouseY",I),k!==void 0&&N.updateInput("isMouseDown",k),O&&Object.entries(O).forEach(([H,z])=>N.updateInput(H,z))},[v,C,w,I,k,O]);const V=(N,H)=>{var mt,kt,Ot;if(!T||!Y.current)return;N.stopPropagation(),"nativeEvent"in N&&N.nativeEvent&&typeof N.nativeEvent.stopImmediatePropagation=="function"?N.nativeEvent.stopImmediatePropagation():typeof N.stopImmediatePropagation=="function"&&N.stopImmediatePropagation();const z=Y.current,et=z.getBoundingClientRect(),Mt=N.clientX-et.left,ct=N.clientY-et.top,It=window.devicePixelRatio||1;if((H==="click"||H==="down"||H==="up")&&f&&f(`[Canvas] Pointer ${H} at rect(${Math.round(Mt)},${Math.round(ct)}) mapped to buffer(${Math.round(Mt*It)},${Math.round(ct*It)})`,"info"),B.current.handlePointerInput(H,Mt*It,ct*It,z.width,z.height),H==="move"){const vt=(mt=B.current)==null?void 0:mt.getLastHoveredObject();vt?(kt=B.current)!=null&&kt.isInputBoxObject(vt)?z.style.cursor="text":(Ot=B.current)!=null&&Ot.isClickableObject(vt)?z.style.cursor="pointer":z.style.cursor="default":z.style.cursor="default"}else H==="blur"&&(z.style.cursor="default")};Nt.useEffect(()=>{if(!T)return;const N=z=>{var et,Mt,ct;((et=document.activeElement)==null?void 0:et.tagName)==="INPUT"||((Mt=document.activeElement)==null?void 0:Mt.tagName)==="TEXTAREA"||(ct=B.current)==null||ct.handleKeyDown(z)},H=z=>{var et,Mt,ct;((et=document.activeElement)==null?void 0:et.tagName)==="INPUT"||((Mt=document.activeElement)==null?void 0:Mt.tagName)==="TEXTAREA"||(ct=B.current)==null||ct.handleKeyUp(z)};return window.addEventListener("keydown",N),window.addEventListener("keyup",H),()=>{window.removeEventListener("keydown",N),window.removeEventListener("keyup",H)}},[T]),Nt.useEffect(()=>{const N=Y.current;if(!N||!T)return;const H=z=>{if(z.preventDefault(),z.stopPropagation(),B.current){const et=N.getBoundingClientRect(),Mt=window.devicePixelRatio||1,ct=(z.clientX-et.left)*Mt,It=(z.clientY-et.top)*Mt;let mt=z.deltaX,kt=z.deltaY;z.deltaMode===1?(mt*=25,kt*=25):z.deltaMode===2&&(mt*=100,kt*=100),B.current.handlePointerInput("move",ct,It,N.width,N.height),B.current.handleWheel(mt,kt,ct,It,N.width,N.height)}};return N.addEventListener("wheel",H,{passive:!1}),()=>{N.removeEventListener("wheel",H)}},[T]);const[G,x]=Nt.useState([]);Nt.useEffect(()=>{if(y&&y.objects){const N=y.objects.filter(H=>{var z,et;return H.type==="Joystick"&&((z=H.inputBinding)==null?void 0:z.type)==="keyboard"&&((et=H.inputBinding.keyboardConfig)==null?void 0:et.showVirtualKeyboard)});x(N)}},[y]);const[,U]=Nt.useState(0);Nt.useEffect(()=>{if(G.length===0)return;let N;const H=()=>{U(z=>z+1),N=requestAnimationFrame(H)};return N=requestAnimationFrame(H),()=>cancelAnimationFrame(N)},[G.length]);const q=()=>G.map(N=>{const H=N.inputBinding.keyboardConfig,z=mt=>{var Ot;const kt={key:mt,code:mt,preventDefault:()=>{}};(Ot=B.current)==null||Ot.handleKeyDown(kt)},et=mt=>{var Ot;const kt={key:mt,code:mt,preventDefault:()=>{}};(Ot=B.current)==null||Ot.handleKeyUp(kt)},Mt=B.current,ct=mt=>Mt&&Mt.activeKeys?Mt.activeKeys.has(mt.toLowerCase()):!1,It=mt=>({width:"50px",height:"50px",background:mt?"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:mt?"none":"0 4px 6px rgba(0,0,0,0.1)"});return ne.jsxs("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",pointerEvents:"auto",zIndex:100},children:[ne.jsx("div",{style:It(ct(H.upKey)),onMouseDown:()=>z(H.upKey),onMouseUp:()=>et(H.upKey),onMouseLeave:()=>et(H.upKey),onTouchStart:mt=>{mt.preventDefault(),z(H.upKey)},onTouchEnd:mt=>{mt.preventDefault(),et(H.upKey)},children:H.upKey.toUpperCase()}),ne.jsxs("div",{style:{display:"flex",gap:"8px"},children:[ne.jsx("div",{style:It(ct(H.leftKey)),onMouseDown:()=>z(H.leftKey),onMouseUp:()=>et(H.leftKey),onMouseLeave:()=>et(H.leftKey),onTouchStart:mt=>{mt.preventDefault(),z(H.leftKey)},onTouchEnd:mt=>{mt.preventDefault(),et(H.leftKey)},children:H.leftKey.toUpperCase()}),ne.jsx("div",{style:It(ct(H.downKey)),onMouseDown:()=>z(H.downKey),onMouseUp:()=>et(H.downKey),onMouseLeave:()=>et(H.downKey),onTouchStart:mt=>{mt.preventDefault(),z(H.downKey)},onTouchEnd:mt=>{mt.preventDefault(),et(H.downKey)},children:H.downKey.toUpperCase()}),ne.jsx("div",{style:It(ct(H.rightKey)),onMouseDown:()=>z(H.rightKey),onMouseUp:()=>et(H.rightKey),onMouseLeave:()=>et(H.rightKey),onTouchStart:mt=>{mt.preventDefault(),z(H.rightKey)},onTouchEnd:mt=>{mt.preventDefault(),et(H.rightKey)},children:H.rightKey.toUpperCase()})]})]},N.id)});return ne.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[ne.jsx("canvas",{ref:Y,onPointerDown:N=>{var H;V(N,"down"),N.currentTarget.setPointerCapture(N.pointerId),(H=Y.current)==null||H.focus()},onPointerMove:N=>V(N,"move"),onPointerUp:N=>{V(N,"up"),N.currentTarget.releasePointerCapture(N.pointerId)},onPointerCancel:N=>{V(N,"up"),N.currentTarget.releasePointerCapture(N.pointerId)},onPointerLeave:N=>V(N,"blur"),onClick:N=>V(N,"click"),onKeyDown:N=>B.current.handleKeyDown(N.nativeEvent),onKeyUp:N=>B.current.handleKeyUp(N.nativeEvent),onContextMenu:N=>N.preventDefault(),tabIndex:0,style:{...s,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:T?"auto":"none"}}),q()]})});function ci(){const[y,t]=Nt.useState(null),s=Nt.useCallback((b,c)=>{y==null||y.setInputBool(b,c)},[y]),o=Nt.useCallback((b,c)=>{y==null||y.setInputNumber(b,c)},[y]),e=Nt.useCallback(b=>{y==null||y.fireTrigger(b)},[y]),n=Nt.useCallback((b,c)=>{y==null||y.setInputText(b,c)},[y]),i=Nt.useCallback((b,c)=>{y==null||y.setInputNumberArray(b,c)},[y]),a=Nt.useCallback((b,c)=>{y==null||y.setInputStringArray(b,c)},[y]),r=Nt.useCallback((b,c)=>{y==null||y.updateInput(b,c)},[y]),l=r,d=Nt.useCallback((b,c)=>{y==null||y.updateObjectOptions(b,c)},[y]),p=Nt.useCallback((b,c,S)=>{y==null||y.updateConstraint(b,c,S)},[y]),g=Nt.useCallback((b,c,S)=>{y==null||y.updateGraphData(b,c,S)},[y]),u=Nt.useCallback((b,c,S)=>{y==null||y.updateBarChartData(b,c,S)},[y]),f=Nt.useCallback((b,c)=>{y==null||y.updatePieChartData(b,c)},[y]),h=Nt.useCallback((b,c)=>{y==null||y.setDropdownOptions(b,c)},[y]),m=Nt.useCallback(b=>y==null?void 0:y.getInputValue(b),[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:g,updateBarChartData:u,updatePieChartData:f,setDropdownOptions:h,updateObjectOptions:d,getInputValue:m}}const hi=({artboard:y,config:t})=>{const s={...y.seo,...t},o=s.enableSmartExtraction!==!1;Nt.useEffect(()=>{const a=s.title||y.name;a&&(document.title=a);let r=s.description;if(!r&&o){const p=y.objects.filter(g=>{var u;return((u=g.geometry)==null?void 0:u.type)==="Text"}).sort((g,u)=>{var f,h;return(((f=u.geometry.text)==null?void 0:f.length)||0)-(((h=g.geometry.text)==null?void 0:h.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(ne.jsx("h1",{children:s.title||y.name},"artboard-title")),y.objects.forEach((l,d)=>{var p,g;if(!(l.visible===!1||l.isVisible===!1))if(((p=l.geometry)==null?void 0:p.type)==="Text"){const u=l.geometry.text;u&&(l.geometry.fontSize>24?a.push(ne.jsx("h2",{children:u},l.id||d)):a.push(ne.jsx("p",{children:u},l.id||d)))}else if(((g=l.geometry)==null?void 0:g.type)==="Image"){const u=l.geometry.src,f=l.altText||l.name||"Illustration";a.push(ne.jsx("img",{src:u,alt:f},l.id||d))}else l.type==="Button"&&a.push(ne.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 ne.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(),ne.jsx("script",{type:"application/ld+json",children:JSON.stringify(i)})]})},fi={version:"7.0.0"}.version;se.BAR_STYLE_PRESETS=ri,se.BehaviorSensor=ge,se.BehaviorType=it,se.ConditionOp=es,se.ExodeSEO=hi,se.ExodeUICanvas=li,se.ExodeUIEngine=bs,se.LogicOp=Ht,se.RapierPhysics=os,se.TOGGLE_SHAPE_NAME_MAP=xe,se.VERSION=fi,se.getToggleSvgPathBounds=We,se.useExodeUI=ci,Object.defineProperty(se,Symbol.toStringTag,{value:"Module"})}));