exodeui 6.3.47 → 6.3.49

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,34 +1,34 @@
1
- (function(zt,Dt){typeof exports=="object"&&typeof module<"u"?Dt(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"],Dt):(zt=typeof globalThis<"u"?globalThis:zt||self,Dt(zt.ExodeUIReact={},zt.jsxRuntime,zt.React,zt.pretext,zt.Rapier,zt.LZString))})(this,(function(zt,Dt,Lt,Ge,ee,bs){"use strict";var fi=Object.defineProperty;var hi=(zt,Dt,Lt)=>Dt in zt?fi(zt,Dt,{enumerable:!0,configurable:!0,writable:!0,value:Lt}):zt[Dt]=Lt;var ct=(zt,Dt,Lt)=>hi(zt,typeof Dt!="symbol"?Dt+"":Dt,Lt);function vs(m){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(m){for(const s in m)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(m,s);Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:()=>m[s]})}}return t.default=m,Object.freeze(t)}const Ss=vs(bs);var q=(m=>(m.Proximity="Proximity",m.Magnetic="Magnetic",m.Repel="Repel",m.Orbit="Orbit",m.Vortex="Vortex",m.Fluid="Fluid",m.Elastic="Elastic",m.Holographic="Holographic",m.Sticky="Sticky",m.Dilation="Dilation",m.Parallax="Parallax",m.Noise="Noise",m.Float="Float",m.Pulse="Pulse",m.Draggable="Draggable",m.Scroll="Scroll",m.LookAt="LookAt",m.Glint="Glint",m.Scan="Scan",m.Ratchet="Ratchet",m.Jitter="Jitter",m.Follower="Follower",m.Wrap="Wrap",m.Typewriter="Typewriter",m.Scramble="Scramble",m.Wave="Wave",m.Bounce="Bounce",m.TextTrail="TextTrail",m.Reveal3D="Reveal3D",m.RevealSlide="RevealSlide",m.RevealBlur="RevealBlur",m.TextLiquid="TextLiquid",m.TextVortex="TextVortex",m.TextExplosion="TextExplosion",m.TextRain="TextRain",m.TextGravity="TextGravity",m.TextMatrix="TextMatrix",m.TextNeon="TextNeon",m.TextDissolve="TextDissolve",m.TextOrganic="TextOrganic",m.TextBreathe="TextBreathe",m.TextSpin="TextSpin",m.TextMagnet="TextMagnet",m.TextPerspective="TextPerspective",m.TextMirror="TextMirror",m.TextFloral="TextFloral",m.TextSmoke="TextSmoke",m.TextVariable="TextVariable",m.TextZing="TextZing",m.TextElastic="TextElastic",m.TextGlitch3D="TextGlitch3D",m.GlitchText="GlitchText",m.TextCounter="TextCounter",m.Squash="Squash",m.Spotlight="Spotlight",m.Lens="Lens",m.Gravity="Gravity",m.Velocity="Velocity",m.Shear="Shear",m.LayoutAnimation="LayoutAnimation",m.SpringChain="SpringChain",m.ParticleEmitter="ParticleEmitter",m.StateReactive="StateReactive",m.Fold="Fold",m.Crumple="Crumple",m))(q||{}),se=(m=>(m.Scale="Scale",m.Opacity="Opacity",m.RotateZ="RotateZ",m.RotateX="RotateX",m.RotateY="RotateY",m.PositionX="PositionX",m.PositionY="PositionY",m.SkewX="SkewX",m.Blur="Blur",m.Exposure="Exposure",m.HueShift="HueShift",m.Negative="Negative",m.CornerRadius="CornerRadius",m.StrokeWidth="StrokeWidth",m.BoxShadow="BoxShadow",m.FontSize="FontSize",m.LetterSpacing="LetterSpacing",m))(se||{}),je=(m=>(m.Equal="Equal",m.NotEqual="NotEqual",m.GreaterThan="GreaterThan",m.LessThan="LessThan",m.GreaterEqual="GreaterEqual",m.LessEqual="LessEqual",m.IsTrue="IsTrue",m.IsFalse="IsFalse",m))(je||{}),It=(m=>(m.AND="AND",m.OR="OR",m.NOT="NOT",m.XOR="XOR",m.OBJECT="OBJECT",m.PROPERTY="PROPERTY",m.GET_PROPERTY="GET_PROPERTY",m.SET_PROPERTY="SET_PROPERTY",m.ADD="ADD",m.SUB="SUB",m.MUL="MUL",m.DIV="DIV",m.MOD="MOD",m.POW="POW",m.ABS="ABS",m.ROUND="ROUND",m.FLOOR="FLOOR",m.CEIL="CEIL",m.SIN="SIN",m.COS="COS",m.TAN="TAN",m.CLAMP="CLAMP",m.REMAP="REMAP",m.EQ="EQ",m.NEQ="NEQ",m.GT="GT",m.LT="LT",m.GTE="GTE",m.LTE="LTE",m.IF_ELSE="IF_ELSE",m.VALUE="VALUE",m.INPUT="INPUT",m.LOG="LOG",m.SCROLL_X="SCROLL_X",m.SCROLL_Y="SCROLL_Y",m.MOUSE_X="MOUSE_X",m.MOUSE_Y="MOUSE_Y",m.IS_MOUSE_DOWN="IS_MOUSE_DOWN",m.EFFECTOR="EFFECTOR",m.MONITOR="MONITOR",m.DELAY="DELAY",m.SPRING_PULL="SPRING_PULL",m.SPRING_SETTLE="SPRING_SETTLE",m.EMIT="EMIT",m))(It||{});function Cs(m){if(m.length<5)return m;const t=new Set("aeiouyAEIOUY".split(""));if(/[\u4E00-\u9FFF\u3400-\u4DBF]/.test(m))return m;let o="";for(let e=0;e<m.length;e++){if(o+=m[e],e>=m.length-2)continue;const i=t.has(m[e]),n=t.has(m[e+1]),a=t.has(m[e+2]);i&&!n&&a&&(o+="­"),i&&!n&&!a&&e>=1&&(o+="­")}return o}function ws(m){return m.replace(/\b([a-zA-Z]{4,})\b/g,(t,s)=>Cs(s))}function Ms(m,t,s){return m}function Is(m,t,s){return m}const Be=new Map;function ts(m){var I;const{text:t,fontFamily:s="Inter",fontSize:o=16,fontWeight:e=400,fontStyle:i="normal",lineHeight:n=1.2,width:a=200,letterSpacing:r=0,paragraphSpacing:l=0,paragraphIndent:f=0,textCase:h="none",segments:u=[],enableSegments:c=!1}=m;let d=String(t||"");h==="uppercase"?d=d.toUpperCase():h==="lowercase"?d=d.toLowerCase():h==="capitalize"&&(d=d.replace(/\b\w/g,k=>k.toUpperCase())),m.hyphenation===!0&&(d=ws(d));const p=`${i} ${e} ${o}px "${s}", sans-serif`,g=`${d}|${p}|${r}|${l}|${f}|${c}|${JSON.stringify(u)}|hyp:${!!m.hyphenation}|comp:${m.composer}|bal:${!!m.balanceRaggedLines}`;let y=Be.get(g);const b=typeof CanvasRenderingContext2D<"u"?CanvasRenderingContext2D.prototype.measureText:null,v=function(k){if(!b)return{width:0,fontBoundingBoxAscent:0,fontBoundingBoxDescent:0};const T=b.call(this,k);return r!==0&&k&&k.length>0?{...T,width:T.width+(k.length-1)*r}:T};if(!y){try{if(r!==0&&typeof CanvasRenderingContext2D<"u"&&(CanvasRenderingContext2D.prototype.measureText=v),c&&u&&u.length>0){const k=u.map(T=>{let O=T.text||"";const _=T.textCase||h||"none";return _==="uppercase"?O.toUpperCase():_==="lowercase"?O.toLowerCase():_==="capitalize"?O.replace(/\b\w/g,P=>P.toUpperCase()):O}).join("");if(y=Ge.prepareWithSegments(k,p),y){let T=0,O=o;for(const _ of u){let P=_.text||"";if(!P)continue;const E=_.textCase||h||"none";E==="uppercase"?P=P.toUpperCase():E==="lowercase"?P=P.toLowerCase():E==="capitalize"&&(P=P.replace(/\b\w/g,W=>W.toUpperCase()));const A=_.fontSize||o;A>O&&(O=A);const B=`${_.fontStyle||i} ${_.fontWeight||e} ${A}px "${_.fontFamily||s}", sans-serif`,D=Ge.prepareWithSegments(P,B);if(D&&D.widths)for(let W=0;W<D.widths.length;W++){const X=T+W;if(X<y.widths.length){y.widths[X]=D.widths[W];const H=D.kinds[W];if(H===2){const Q=P[W];Q===`
2
- `||Q==="\r"?y.kinds[X]=2:y.kinds[X]=0}else y.kinds[X]=H}}T+=P.length}y.fullText=k,y.maxFontSize=O}}else y=Ge.prepareWithSegments(d,p);y&&Be.set(g,y)}catch(k){return console.error("[ExodeUI] Pretext prepare failed:",k),{width:a,height:0,lineCount:0,lines:[]}}finally{r!==0&&typeof CanvasRenderingContext2D<"u"&&b&&(CanvasRenderingContext2D.prototype.measureText=b)}if(Be.size>500){const k=Be.keys().next().value;k&&Be.delete(k)}}if(f>0&&y&&y.widths&&!y.indentApplied){const k=[...y.widths],T=y.fullText||d;let O=!0;for(let _=0;_<T.length;_++)O&&k[_]!==void 0&&(k[_]+=f,O=!1),(T[_]===`
3
- `||T[_]==="\r")&&(O=!0,T[_]==="\r"&&T[_+1]===`
4
- `&&_++);y={...y,widths:k,indentApplied:!0}}if(!y)return{width:a,height:0,lineCount:0,lines:[]};let S=n;typeof S=="string"&&(S=parseFloat(S)),S>5&&o>0&&(S=S/o),r!==0&&(CanvasRenderingContext2D.prototype.measureText=v);let C;try{const k=y.maxFontSize||o;if(a>=1e5){const T=d.split(/\r\n|\r|\n/);C={lines:T.map(O=>({text:O,width:0})),height:T.length*(S*k),lineCount:T.length}}else C=Ge.layoutWithLines(y,a,S*k)}finally{r!==0&&b&&(CanvasRenderingContext2D.prototype.measureText=b)}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)*S*o;if(l>0&&C&&C.lines&&C.lines.length>1){let k=0;const T=y.fullText||t;for(let O=0;O<C.lines.length-1;O++)k+=C.lines[O].text.length,(T[k]===`
5
- `||T[k]==="\r")&&(w+=l,k++,T[k-1]==="\r"&&T[k]===`
6
- `&&k++)}let M=(C==null?void 0:C.lines)||[];return m.composer==="every-line"&&M.length>1&&(M=Ms(M)),m.balanceRaggedLines===!0&&M.length>1&&(M=Is(M)),{width:a,height:w,lineCount:M.length,lines:M}}function es(m,t,s){let o=String(m||"").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),i=new Array(e.length).fill(0);let n=t-(e.length-1)*s,a=0;if(e.forEach((r,l)=>{if(r.endsWith("px")){const f=parseFloat(r);i[l]=f,n-=f}else r.endsWith("fr")?a+=parseFloat(r):r==="auto"&&(i[l]=100,n-=100)}),a>0&&n>0){const r=n/a;e.forEach((l,f)=>{l.endsWith("fr")&&(i[f]=r*parseFloat(l))})}return i}function ss(m,t,s){try{const o=m.autoLayout;return!o||!o.enabled?{childUpdates:[]}:(o.mode||"linear")==="grid"?Ts(m,t,s):ks(m,t,s)}catch(o){return console.error("Layout Engine Error:",o),{childUpdates:[]}}}function ks(m,t,s){var P,E;const o=m.autoLayout,{direction:e,spacing:i,padding:n,align:a,wrap:r}=o,l=e==="vertical",f=t.map(A=>{const B=s(A.id),D=A.geometry;let W=(B==null?void 0:B.width)??D.width??100,X=(B==null?void 0:B.height)??D.height??100;if(D.type==="Ellipse"||D.type==="Polygon"||D.type==="Star"){const H=(B==null?void 0:B.radius)??D.radius??(B==null?void 0:B.outer_radius)??D.outer_radius??50;W=H*2,X=H*2}else if(D.type==="Text"){const H=ts({text:(B==null?void 0:B.text)??D.text??"",fontFamily:D.fontFamily,fontSize:D.fontSize,fontWeight:D.fontWeight,fontStyle:D.fontStyle,lineHeight:D.lineHeight,width:D.width||200,letterSpacing:D.letterSpacing,paragraphSpacing:D.paragraphSpacing,paragraphIndent:D.paragraphIndent,textCase:D.textCase,segments:D.segments,enableSegments:D.enableSegments});X=H.height,D.width||(W=H.width)}return W*=A.transform.scale_x||1,X*=A.transform.scale_y||1,{id:A.id,w:W,h:X,original:A}});let h=m.width,u=m.height;const c=((P=m.layoutProps)==null?void 0:P.width)==="hug",d=((E=m.layoutProps)==null?void 0:E.height)==="hug",p=[];let g=[],y=0,b=0;const v=h-n.left-n.right,S=u-n.top-n.bottom;f.forEach(A=>{r&&g.length>0&&(l?b+i+A.h>S:y+i+A.w>v)?(p.push({children:g,width:y,height:b}),g=[A],y=A.w,b=A.h):(g.push(A),l?(y=Math.max(y,A.w),b+=(g.length>1?i:0)+A.h):(y+=(g.length>1?i:0)+A.w,b=Math.max(b,A.h)))}),g.length>0&&p.push({children:g,width:y,height:b}),c&&!l&&(h=Math.max(...p.map(A=>A.width),0)+n.left+n.right),d&&l&&(u=Math.max(...p.map(A=>A.height),0)+n.top+n.bottom);const C=[];let w=n.left,M=n.top;const I=a.toLowerCase(),k=I==="center"||I.endsWith("-center"),T=I.endsWith("-right"),O=I==="center"||I.startsWith("center-"),_=I.startsWith("bottom-");return p.forEach(A=>{let B=w,D=M;l?O?D=n.top+(u-n.top-n.bottom-A.height)/2:_&&(D=u-n.bottom-A.height):k?B=n.left+(h-n.left-n.right-A.width)/2:T&&(B=h-n.right-A.width),A.children.forEach(W=>{var R,et;let X=B,H=D;l?k?X+=(A.width-W.w)/2:T&&(X+=A.width-W.w):O?H+=(A.height-W.h)/2:_&&(H+=A.height-W.h);const Q=((R=W.original.layoutProps)==null?void 0:R.width)==="fill",L=((et=W.original.layoutProps)==null?void 0:et.height)==="fill";C.push({id:W.id,x:X+W.w/2-h/2,y:H+W.h/2-u/2,width:Q&&l?A.width:void 0,height:L?l?void 0:A.height:void 0}),l?D+=W.h+i:B+=W.w+i}),l?w+=A.width+i:M+=A.height+i}),{frameWidth:c?h:void 0,frameHeight:d?u:void 0,childUpdates:C}}function Ts(m,t,s){const o=m.autoLayout;if(!o)return{childUpdates:[]};const{gridColumns:e,gridRows:i,columnGap:n=0,rowGap:a=0,padding:r,align:l}=o;let f=m.width,h=m.height;const u=f-r.left-r.right,c=h-r.top-r.bottom,d=es(e||"1fr",u,n),p=es(i||"auto",c,a),g=d.length>0?d.reduce((T,O)=>T+O,0)+(d.length-1)*n:0,y=p.length>0?p.reduce((T,O)=>T+O,0)+(p.length-1)*a:0,b=l.toLowerCase(),v=b==="center"||b.endsWith("-center"),S=b.endsWith("-right"),C=b==="center"||b.startsWith("center-"),w=b.startsWith("bottom-");let M=0,I=0;v?M=(u-g)/2:S&&(M=u-g),C?I=(c-y)/2:w&&(I=c-y);const k=[];return t.forEach((T,O)=>{var et,U;const _=O%d.length||0,P=Math.floor(O/d.length)||0;P>=p.length&&p.push(100);const E=d[_],A=p[P];let B=r.left+M+d.slice(0,_).reduce((lt,x)=>lt+x+n,0),D=r.top+I+p.slice(0,P).reduce((lt,x)=>lt+x+a,0);const W=s(T.id),X=T.geometry;let H=(W==null?void 0:W.width)??X.width??100,Q=(W==null?void 0:W.height)??X.height??100;if(X.type==="Ellipse"||X.type==="Polygon"||X.type==="Star"){const lt=(W==null?void 0:W.radius)??X.radius??(W==null?void 0:W.outer_radius)??X.outer_radius??50;H=lt*2,Q=lt*2}H*=T.transform.scale_x||1,Q*=T.transform.scale_y||1;let L=B,R=D;v?L+=(E-H)/2:S&&(L+=E-H),C?R+=(A-Q)/2:w&&(R+=A-Q),k.push({id:T.id,x:L+H/2-f/2,y:R+Q/2-h/2,width:((et=T.layoutProps)==null?void 0:et.width)==="fill"?E:void 0,height:((U=T.layoutProps)==null?void 0:U.height)==="fill"?A:void 0})}),{childUpdates:k}}class is{constructor(){ct(this,"world",null);ct(this,"bodies",new Map);ct(this,"colliders",new Map);ct(this,"joints",new Map);ct(this,"initialized",!1);ct(this,"bodyIdByCollider",new Map);ct(this,"onCollisionCB",null);ct(this,"eventQueue",null)}setCollisionCallback(t){this.onCollisionCB=t}async init(t){this.initialized||(await ee.init(),this.world=new ee.World(new ee.Vector2(t.x*100,t.y*100)),this.eventQueue=new ee.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 ee.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?ee.RigidBodyDesc.fixed():ee.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=ee.ColliderDesc.cuboid(t.width/2,t.height/2);break;case"Ellipse":e=ee.ColliderDesc.ball(Math.max(t.width,t.height)/2);break;case"Triangle":case"Star":case"Polygon":e=ee.ColliderDesc.cuboid(t.width/2,t.height/2);break;default:e=ee.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 n=t.width*t.height;e.setDensity(t.mass/n)}t.isSensor&&e.setSensor(!0);const i=this.world.createCollider(e,o);this.bodyIdByCollider.set(i.handle,t.id),t.frictionAir!==void 0&&o.setLinearDamping(t.frictionAir*10),this.bodies.set(t.id,o),this.colliders.set(t.id,i)}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,i,n)=>{const a=this.bodyIdByCollider.get(e),r=this.bodyIdByCollider.get(i);a&&r&&s(a,r,n)})}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 ee.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 ee.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 ee.Vector2(s,o),!0)}applyImpulse(t,s,o){const e=this.bodies.get(t);e&&e.applyImpulse(new ee.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 ee.Vector2(t.anchorA.x,t.anchorA.y),i=new ee.Vector2(t.anchorB.x,t.anchorB.y);let n;if(t.type==="Distance"){const a=t.length??100,r=t.stiffness??100,l=t.damping??10;n=ee.JointData.spring(a,r,l,e,i)}else n=ee.JointData.revolute(e,i);try{const a=this.world.createImpulseJoint(n,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 ns=m=>m,Ps=m=>m>0?1:0,_s=m=>m<1?0:1,os=m=>m*m,as=m=>m*(2-m),rs=m=>m<.5?2*m*m:-1+(4-2*m)*m,Es=m=>m*m*m,As=m=>--m*m*m+1,Os=m=>m<.5?4*m*m*m:(m-1)*(2*m-2)*(2*m-2)+1,Ls=m=>m*m*m*m,xs=m=>1- --m*m*m*m,Rs=m=>m<.5?8*m*m*m*m:1-8*--m*m*m*m,Fs=m=>m*m*m*m*m,$s=m=>1+--m*m*m*m*m,Bs=m=>m<.5?16*m*m*m*m*m:1+16*--m*m*m*m*m,Ws=m=>1-Math.cos(m*Math.PI/2),Ys=m=>Math.sin(m*Math.PI/2),Xs=m=>-(Math.cos(Math.PI*m)-1)/2,Ds=m=>m===0?0:Math.pow(2,10*(m-1)),Gs=m=>m===1?1:1-Math.pow(2,-10*m),zs=m=>m===0?0:m===1?1:m<.5?Math.pow(2,20*m-10)/2:(2-Math.pow(2,-20*m+10))/2,Ns=m=>1-Math.sqrt(1-m*m),Vs=m=>Math.sqrt(1- --m*m),Hs=m=>m<.5?(1-Math.sqrt(1-4*m*m))/2:(Math.sqrt(1-(-2*m+2)*(-2*m+2))+1)/2,ze=1.70158,Ne=ze*1.525,ls=ze+1,Us=m=>ls*m*m*m-ze*m*m,qs=m=>1+ls*Math.pow(m-1,3)+ze*Math.pow(m-1,2),Ks=m=>m<.5?Math.pow(2*m,2)*((Ne+1)*2*m-Ne)/2:(Math.pow(2*m-2,2)*((Ne+1)*(m*2-2)+Ne)+2)/2,cs=2*Math.PI/3,fs=2*Math.PI/4.5,Js=m=>m===0?0:m===1?1:-Math.pow(2,10*m-10)*Math.sin((m*10-10.75)*cs),Qs=m=>m===0?0:m===1?1:Math.pow(2,-10*m)*Math.sin((m*10-.75)*cs)+1,Zs=m=>m===0?0:m===1?1:m<.5?-(Math.pow(2,20*m-10)*Math.sin((20*m-11.125)*fs))/2:Math.pow(2,-20*m+10)*Math.sin((20*m-11.125)*fs)/2+1,Ve=m=>m<1/2.75?7.5625*m*m:m<2/2.75?7.5625*(m-=1.5/2.75)*m+.75:m<2.5/2.75?7.5625*(m-=2.25/2.75)*m+.9375:7.5625*(m-=2.625/2.75)*m+.984375,js=m=>1-Ve(1-m),ti=Ve,ei=m=>m<.5?(1-Ve(1-2*m))/2:(1+Ve(2*m-1))/2,Ze=new Map,We=(m,t,s,o)=>{const e=`${m},${t},${s},${o}`;if(Ze.has(e))return Ze.get(e);const i=f=>(1-3*s+3*m)*f*f*f+(3*s-6*m)*f*f+3*m*f,n=f=>(1-3*o+3*t)*f*f*f+(3*o-6*t)*f*f+3*t*f,a=f=>3*(1-3*s+3*m)*f*f+2*(3*s-6*m)*f+3*m,r=f=>{let h=f;for(let u=0;u<8;u++){const c=i(h)-f;if(Math.abs(c)<1e-6)return h;const d=a(h);if(Math.abs(d)<1e-6)break;h=h-c/d}return h},l=f=>f===0?0:f===1?1:n(r(f));return Ze.set(e,l),l},hs=m=>{const t=m.match(/cubic-bezier\s*\(\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*\)/);if(!t)return null;const[,s,o,e,i]=t.map(Number);return We(s,o,e,i)},ds={ease:We(.25,.1,.25,1),"ease-in":We(.42,0,1,1),"ease-out":We(0,0,.58,1),"ease-in-out":We(.42,0,.58,1)},He={Linear:ns,EaseInQuad:os,EaseOutQuad:as,EaseInOutQuad:rs,EaseInCubic:Es,EaseOutCubic:As,EaseInOutCubic:Os,EaseInQuart:Ls,EaseOutQuart:xs,EaseInOutQuart:Rs,EaseInQuint:Fs,EaseOutQuint:$s,EaseInOutQuint:Bs,EaseInSine:Ws,EaseOutSine:Ys,EaseInOutSine:Xs,EaseInExpo:Ds,EaseOutExpo:Gs,EaseInOutExpo:zs,EaseInCirc:Ns,EaseOutCirc:Vs,EaseInOutCirc:Hs,EaseInBack:Us,EaseOutBack:qs,EaseInOutBack:Ks,EaseInElastic:Js,EaseOutElastic:Qs,EaseInOutElastic:Zs,EaseInBounce:js,EaseOutBounce:ti,EaseInOutBounce:ei,EaseIn:os,EaseOut:as,EaseInOut:rs,StepStart:Ps,StepEnd:_s},si=m=>{const t=m.trim(),s=t.toLowerCase();if(He[t])return He[t];const o=Object.keys(He).find(i=>i.toLowerCase()===s);if(o)return He[o];const e=Object.keys(ps).find(i=>i.toLowerCase()===s);if(e){const i=hs(ps[e].value);if(i)return i}if(ds[s])return ds[s];if(s.startsWith("cubic-bezier")){const i=hs(t);if(i)return i}return ns},ps={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)"}},ii=(m,t,s,o,e)=>{if(!m||!t||!s)return m;const i=o.scale_x??1,n=o.scale_y??1,a=(r,l,f)=>{let h=0,u=0;const c=o.rotation*Math.PI/180,d=Math.cos(c),p=Math.sin(c),g=r*i*d-l*n*p+o.x,y=r*i*p+l*n*d+o.y;f.forEach(I=>{const k=e(I.boneId);if(!k)return;const T={x:k.x,y:k.y,rotation:k.rotation,scaleX:k.scale_x??1,scaleY:k.scale_y??1},O=s[I.boneId]||[1,0,0,1,0,0],_=g*O[0]+y*O[2]+O[4],P=g*O[1]+y*O[3]+O[5],E=T.rotation*Math.PI/180,A=Math.cos(E),B=Math.sin(E),D=_*T.scaleX*A-P*T.scaleY*B+T.x,W=_*T.scaleX*B+P*T.scaleY*A+T.y;h+=D*I.amount,u+=W*I.amount});const b=[...f].sort((I,k)=>k.amount-I.amount);if(b.length>=2&&b[0].amount>0&&b[1].amount>0){const I=e(b[0].boneId),k=e(b[1].boneId);if(I&&k&&I.length!==void 0&&k.length!==void 0){const T=I.length*(I.scale_y??1),O=I.rotation*Math.PI/180,_=I.x-T*Math.sin(O),P=I.y+T*Math.cos(O),E=k.length*(k.scale_y??1),A=k.rotation*Math.PI/180,B=k.x-E*Math.sin(A),D=k.y+E*Math.cos(A);let W=null,X=null,H=!1;const Q=1;if(Math.hypot(I.x-k.x,I.y-k.y)<Q||Math.hypot(I.x-B,I.y-D)<Q?(W=I.x,X=I.y):(Math.hypot(_-k.x,P-k.y)<Q||Math.hypot(_-B,P-D)<Q)&&(W=_,X=P,H=!0),W!==null&&X!==null){const L=s[b[0].boneId]||[1,0,0,1,0,0],R=L[0]*L[3]-L[1]*L[2];let et=0,U=0;if(R!==0){const lt=(L[2]*L[5]-L[3]*L[4])/R,x=(L[1]*L[4]-L[0]*L[5])/R,F=Math.atan2(-L[1],L[3]);if(!H)et=lt,U=x;else{const z=-L[2]/R,gt=L[0]/R,mt=Math.hypot(z,gt),ut=I.length*mt;et=lt-ut*Math.sin(F),U=x+ut*Math.cos(F)}const N=Math.hypot(g-et,y-U),st=Math.hypot(h-W,u-X);if(st>0&&N>0){const z=Math.max(st,.01),gt=Math.min(N/z,3),mt=W+(h-W)*gt,ut=X+(u-X)*gt,wt=b[0].amount,Mt=b[1].amount,Et=Math.min(wt,Mt)*2,Ut=1-Math.pow(1-Et,4);h=h*(1-Ut)+mt*Ut,u=u*(1-Ut)+ut*Ut}}}}}const v=o.rotation*Math.PI/180,S=Math.cos(v),C=Math.sin(v),w=h-o.x,M=u-o.y;return{x:(w*S+M*C)/i,y:(-w*C+M*S)/n}};return m.map((r,l)=>{const f=t[l];if(!f||f.length===0)return{...r};const h={...r,...a(r.x,r.y,f)};if(r.in_x!==void 0&&r.in_y!==void 0){const u=a(r.in_x,r.in_y,f);h.in_x=u.x,h.in_y=u.y}if(r.out_x!==void 0&&r.out_y!==void 0){const u=a(r.out_x,r.out_y,f);h.out_x=u.x,h.out_y=u.y}return h})};function ni(m,t,s,o,e){const i=m*s*.01,n=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(i+a)*Math.cos(n+r)+.5*Math.sin(i*2.1-r)*Math.cos(n*2.3+a)+.25*Math.sin(i*4.5+a)*Math.cos(n*4.2-r))/1.75*o}function oi(m,t,s,o,e,i,n=0,a=0){const r=[];if(!m)return[];const l=m.type;if(l==="Rectangle"||l==="Image"||l==="Frame"){const d=Math.max(20,Math.floor((t+s)/10)),p=Math.max(2,Math.floor(d*(t/(t+s)))),g=Math.max(2,Math.floor(d*(s/(t+s))));for(let y=0;y<p;y++)r.push({x:-t/2+t/p*y,y:-s/2,nx:0,ny:-1});for(let y=0;y<g;y++)r.push({x:t/2,y:-s/2+s/g*y,nx:1,ny:0});for(let y=0;y<p;y++)r.push({x:t/2-t/p*y,y:s/2,nx:0,ny:1});for(let y=0;y<g;y++)r.push({x:-t/2,y:s/2-s/g*y,nx:-1,ny:0})}else if(l==="Ellipse"){const d=Math.max(60,Math.floor(Math.PI*Math.max(t,s)/5));for(let p=0;p<d;p++){const g=p/d*Math.PI*2,y=Math.cos(g),b=Math.sin(g);r.push({x:y*t/2,y:b*s/2,nx:y,ny:b})}}else if(l==="Triangle"){const d={x:0,y:-s/2},p={x:t/2,y:s/2},g={x:-t/2,y:s/2},y=20;let b=p.x-d.x,v=p.y-d.y,S=Math.hypot(b,v),C=-v/S,w=b/S;for(let M=0;M<y;M++)r.push({x:d.x+b*(M/y),y:d.y+v*(M/y),nx:C,ny:w});b=g.x-p.x,v=g.y-p.y,S=Math.hypot(b,v),C=-v/S,w=b/S;for(let M=0;M<y;M++)r.push({x:p.x+b*(M/y),y:p.y+v*(M/y),nx:C,ny:w});b=d.x-g.x,v=d.y-g.y,S=Math.hypot(b,v),C=-v/S,w=b/S;for(let M=0;M<y;M++)r.push({x:g.x+b*(M/y),y:g.y+v*(M/y),nx:C,ny:w})}else for(let p=0;p<80;p++){const g=p/80*Math.PI*2,y=Math.cos(g),b=Math.sin(g);r.push({x:y*t/2,y:b*s/2,nx:y,ny:b})}const f=n*Math.PI/180,h=Math.cos(f),u=Math.sin(f);return r.map(d=>{const p=ni(d.x,d.y,e,o,i),g=d.nx*(1-a)+h*a,y=d.ny*(1-a)+u*a;let b=Math.hypot(g,y);return b===0&&(b=1),{x:d.x+g/b*p,y:d.y+y/b*p}})}const us={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}},gs={default:{label:"Default",colors:["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399"],cardBackground:"rgba(255,255,255,0.04)",cardBorderColor:"rgba(255,255,255,0.08)",legendColor:"rgba(255,255,255,0.65)",labelColor:"#ffffff",centerTextColor:"#ffffff",centerLabelColor:"rgba(255,255,255,0.4)"},neon:{label:"Neon",colors:["#00f5ff","#ff00e5","#00ff9f","#ff6b00","#b400ff"],cardBackground:"rgba(0,0,0,0.55)",cardBorderColor:"rgba(0,245,255,0.2)",legendColor:"rgba(0,245,255,0.75)",labelColor:"#ffffff",centerTextColor:"#00f5ff",centerLabelColor:"rgba(0,245,255,0.5)"},pastel:{label:"Pastel",colors:["#a5b4fc","#67e8f9","#fcd34d","#f9a8d4","#6ee7b7"],cardBackground:"rgba(255,255,255,0.06)",cardBorderColor:"rgba(255,255,255,0.12)",legendColor:"rgba(255,255,255,0.6)",labelColor:"#1a1a2e",centerTextColor:"#ffffff",centerLabelColor:"rgba(255,255,255,0.45)"},warm:{label:"Warm",colors:["#f97316","#ef4444","#f59e0b","#dc2626","#fb923c"],cardBackground:"rgba(30,10,0,0.45)",cardBorderColor:"rgba(249,115,22,0.2)",legendColor:"rgba(253,186,116,0.8)",labelColor:"#ffffff",centerTextColor:"#fb923c",centerLabelColor:"rgba(253,186,116,0.5)"},ocean:{label:"Ocean",colors:["#06b6d4","#0ea5e9","#38bdf8","#7dd3fc","#0284c7"],cardBackground:"rgba(0,20,40,0.5)",cardBorderColor:"rgba(6,182,212,0.2)",legendColor:"rgba(125,211,252,0.75)",labelColor:"#ffffff",centerTextColor:"#38bdf8",centerLabelColor:"rgba(125,211,252,0.5)"},mono:{label:"Mono",colors:["rgba(255,255,255,0.9)","rgba(255,255,255,0.65)","rgba(255,255,255,0.45)","rgba(255,255,255,0.28)","rgba(255,255,255,0.15)"],cardBackground:"rgba(255,255,255,0.03)",cardBorderColor:"rgba(255,255,255,0.1)",legendColor:"rgba(255,255,255,0.55)",labelColor:"#000000",centerTextColor:"#ffffff",centerLabelColor:"rgba(255,255,255,0.4)"}};class ys{constructor(){ct(this,"artboard",null);ct(this,"objectStates",new Map);ct(this,"physicsEngine",null);ct(this,"activeStateMachine",null);ct(this,"inputs",new Map);ct(this,"inputNameMap",new Map);ct(this,"layerStates",new Map);ct(this,"pretextCache",new Map);ct(this,"pointerHistory",[]);ct(this,"MAX_HISTORY",200);ct(this,"imageCache",new Map);ct(this,"lastValidSvgImgMap",new Map);ct(this,"maskBuffer",null);ct(this,"maskCtx",null);ct(this,"lumaBuffer",null);ct(this,"lumaCtx",null);ct(this,"_noiseTileCanvas",null);ct(this,"layout",{fit:"Contain",alignment:"Center"});ct(this,"onTrigger");ct(this,"onInputUpdate");ct(this,"onComponentChange");ct(this,"onToggle");ct(this,"onInputChange");ct(this,"onInputFocus");ct(this,"onInputBlur");ct(this,"onLog");ct(this,"onButtonClick");ct(this,"onGraphPointClick");ct(this,"justFiredTriggers",new Set);ct(this,"rootTransform",null);ct(this,"canvasWidth",0);ct(this,"canvasHeight",0);ct(this,"lastHoveredObjectId",null);ct(this,"_lastPointerPos",null);ct(this,"_prevPointerPos",null);ct(this,"_mouseDelta",{dx:0,dy:0});ct(this,"focusedId",null);ct(this,"draggingSliderId",null);ct(this,"draggingJoystickId",null);ct(this,"activeDropdownId",null);ct(this,"activeObjectId",null);ct(this,"draggingListViewId",null);ct(this,"scrollOffset",{x:0,y:0});ct(this,"_totalScroll",{x:0,y:0});ct(this,"draggingBehaviors",new Set);ct(this,"isMouseDown",!1);ct(this,"activeKeys",new Set);ct(this,"_layoutAnimCache",new Map);ct(this,"_springChainState",new Map);ct(this,"_emitterPools",new Map);ct(this,"objectVelocities",new Map);ct(this,"currentTime",0);ct(this,"frameCount",0);ct(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});ct(this,"onLogicUpdate");ct(this,"logicNodeValues",new Map);ct(this,"logicNodeState",new Map);ct(this,"pointerDownTimes",new Map);ct(this,"activeHoverIds",new Set);ct(this,"onNavigation");ct(this,"periodicTriggerTimes",new Map);ct(this,"wasInView",new Set);ct(this,"scrollProgressLastValue",new Map);ct(this,"debug_objectsRendered",0);ct(this,"debug_objectsTotal",0);ct(this,"lastRenderTime",0);ct(this,"debugMode",!1);ct(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){return this.inputs.get(t)}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||t.type!=="Path"&&t.type!=="Subtract"&&t.type!=="Union"&&t.type!=="Intersect"&&t.type!=="Exclude"&&t.type!=="BooleanOperation")return;if(t.points&&t.points.length>0){if(t.is_closed===void 0&&t.isClosed===void 0&&t.data){const{isClosed:e}=this.svgPathToPoints(t.data);t.is_closed=e}return}if(!t.data)return;const{points:s,isClosed:o}=this.svgPathToPoints(t.data);t.points=s,t.is_closed===void 0&&(t.is_closed=o)}svgPathToPoints(t){const s=/([MLHVCSQTAZmlhvcsqtaz])([^MLHVCSQTAZmlhvcsqtaz]*)/g,o=/[-+]?(?:\d*\.\d+|\d+)(?:[eE][-+]?\d+)?/g,e=[];let i=!1,n=0,a=0,r=0,l=0,f=0,h=0,u;for(;(u=s.exec(t))!==null;){const c=u[1],d=(u[2].match(o)||[]).map(parseFloat),p=c===c.toLowerCase(),g=c.toUpperCase();let y=0;const b=S=>{let C=d[y++];return p&&(C+=S?n:a),C},v=()=>({x:b(!0),y:b(!1)});switch(g){case"M":{const S=v();for(f=n=S.x,h=a=S.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a,moveTo:!0});y<d.length;){const C=v();n=C.x,a=C.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break}case"L":for(;y<d.length;){const S=v();n=S.x,a=S.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break;case"H":for(;y<d.length;)n=b(!0),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"V":for(;y<d.length;)a=b(!1),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"C":for(;y<d.length;){const S=v(),C=v(),w=v();if(e.length>0){const M=e[e.length-1];M.out_x=S.x,M.out_y=S.y}n=w.x,a=w.y,e.push({x:n,y:a,in_x:C.x,in_y:C.y,out_x:n,out_y:a}),r=C.x,l=C.y}break;case"S":for(;y<d.length;){const S={x:2*n-r,y:2*a-l},C=v(),w=v();if(e.length>0){const M=e[e.length-1];M.out_x=S.x,M.out_y=S.y}n=w.x,a=w.y,e.push({x:n,y:a,in_x:C.x,in_y:C.y,out_x:n,out_y:a}),r=C.x,l=C.y}break;case"Q":for(;y<d.length;){const S=v(),C=v();if(e.length>0){const w=e[e.length-1];w.out_x=w.x+2/3*(S.x-w.x),w.out_y=w.y+2/3*(S.y-w.y)}n=C.x,a=C.y,e.push({x:n,y:a,in_x:n+2/3*(S.x-n),in_y:a+2/3*(S.y-a),out_x:n,out_y:a}),r=S.x,l=S.y}break;case"T":for(;y<d.length;){const S={x:2*n-r,y:2*a-l},C=v();if(e.length>0){const w=e[e.length-1];w.out_x=w.x+2/3*(S.x-w.x),w.out_y=w.y+2/3*(S.y-w.y)}n=C.x,a=C.y,e.push({x:n,y:a,in_x:n+2/3*(S.x-n),in_y:a+2/3*(S.y-a),out_x:n,out_y:a}),r=S.x,l=S.y}break;case"Z":if(i=!0,e.length>0){const S=e[e.length-1];S.closePath=!0;const C=[...e].reverse().find(w=>w.moveTo)||e[0];C&&Math.hypot(C.x-S.x,C.y-S.y)<.1&&(C.in_x=S.in_x,C.in_y=S.in_y,e.pop(),e.length>0&&(e[e.length-1].closePath=!0))}n=f,a=h;break;default:if(d.length>=2){const S=v();n=S.x,a=S.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break}}return{points:e,isClosed:i}}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 i;const e=(i=this.artboard)==null?void 0:i.objects.find(n=>n.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){var e,i;if(!this.artboard)return;const o=this.artboard.objects.find(n=>n.id===t||n.name===t);if(o&&((e=o.geometry)==null?void 0:e.type)==="LineGraph"){const n=o.geometry;!n.datasets||n.datasets.length===0?n.datasets=[{id:"default",label:"Runtime Data",data:s,lineColor:"#3b82f6",lineWidth:2,showArea:!1}]:n.datasets[0].data=s;const a=this.objectStates.get(o.id);a&&((i=a.geometry)==null?void 0:i.type)==="LineGraph"&&(!a.geometry.datasets||a.geometry.datasets.length===0?a.geometry.datasets=JSON.parse(JSON.stringify(n.datasets)):a.geometry.datasets[0].data=[...s]),n.datasets[0].inputId&&this.updateInput(n.datasets[0].inputId,s)}else this.updateInput(t,s)}load(t){var n,a;if(!t)return;let s=this.decompressStrings(t);const o=[],e=new Set,i=r=>{r&&r.forEach(l=>{if(e.has(l.id))return;const f={...l},h=f.childrenObjects||[];e.add(f.id),o.push(f),i(h)})};if(i(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: "${(n=this.artboard)==null?void 0:n.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 f=r.get(l.parentId);f&&(f.children||(f.children=[]),f.children.includes(l.id)||f.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=i=>{console.error("[ExodeUI Preload] failed:",i,`Src: ${o.substring(0,80)}...`)},e.src=o,this.imageCache.set(o,e)};t.objects.forEach(o=>{var e,i,n;(e=o.geometry)!=null&&e.src&&s(o.geometry.src),(n=(i=o.style)==null?void 0:i.fill)!=null&&n.src&&s(o.style.fill.src)})}decompressStrings(t){if(t&&typeof t=="object"&&!Array.isArray(t)){if(t._compressed&&t._data)try{const o=Ss.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 n,a,r,l,f,h,u;const o=s.width??((n=s.geometry)==null?void 0:n.width)??0,e=s.height??((a=s.geometry)==null?void 0:a.height)??0,i=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:((f=s.transform)==null?void 0:f.x)??s.x??0,y:((h=s.transform)==null?void 0:h.y)??s.y??0,width:o,height:e,cornerRadius:i,corner_radius:i,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:((u=s.transform)==null?void 0:u.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 is;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 i,n;if((i=e.physics)!=null&&i.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:((n=e.geometry)==null?void 0:n.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=>{this.inputs.set(s.id,s.value);const o=this.inputNameMap.get(s.name)||[];o.includes(s.id)||o.push(s.id),this.inputNameMap.set(s.name,o)}),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 i;if(!this.artboard)return;const s=new Map;this.artboard.objects.forEach(n=>s.set(n.id,n));const o=.15,e=n=>{n.forEach(a=>{const r=this.objectStates.get(a.id);if(r){const l=Math.abs(r.x-a.x),f=Math.abs(r.y-a.y);!t&&(l>20||f>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((i=this.artboard.autoLayout)!=null&&i.enabled){const n=this.artboard.objects.filter(r=>!r.parentId),a=ss(this.artboard,n,r=>this.objectStates.get(r));e(a.childUpdates)}this.artboard.objects.forEach(n=>{var a;if(n.type==="Frame"&&((a=n.autoLayout)!=null&&a.enabled)&&n.children&&n.children.length>0){const r=n.children.map(h=>s.get(h)).filter(h=>!!h),l=this.objectStates.get(n.id);if(!l)return;const f=ss(l,r,h=>this.objectStates.get(h));f.frameWidth!==void 0&&(l.width=f.frameWidth),f.frameHeight!==void 0&&(l.height=f.frameHeight),e(f.childUpdates)}})}loadFonts(){if(!this.artboard)return;const t=new Set;if(this.artboard.objects.forEach(n=>{n.geometry&&n.geometry.type==="Text"&&n.geometry.fontFamily&&t.add(n.geometry.fontFamily)}),this.artboard.animations.forEach(n=>{n.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(n=>{const a=n.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 n=`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!==n&&(a.href=n)}const i=[];if(t.forEach(n=>{n.toLowerCase().includes("clash display")&&i.push("clash-display@200,300,400,500,600,700")}),i.length>0){const n=`https://api.fontshare.com/v2/css?f[]=${i.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!==n&&(a.href=n)}document.fonts&&document.fonts.ready&&document.fonts.ready.then(()=>{this.pretextCache.clear(),this.advance(0)})}enterStates(t,s){var n;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 i=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(f=>f.id===r);if(l)if(l.isBlendState&&l.blendAnimations&&l.blendAnimations.length>0)e.push({animation:null,state:l}),l.blendAnimations.forEach(f=>{const h=this.artboard.animations.find(u=>u.id===f.animationId);h&&(i=Math.max(i,h.duration))});else{let f=null;l.animationId&&(f=this.artboard.animations.find(h=>h.id===l.animationId)||null),f||(f=this.artboard.animations.find(h=>{var u,c;return h.name===l.name||h.id===l.name||(l.name==="Entry"||l.id==="entry")&&(((u=h.name)==null?void 0:u.toLowerCase())==="onload"||((c=h.name)==null?void 0:c.toLowerCase())==="intro")})||null),f&&((n=this.artboard.animationFlow)!=null&&n.some(u=>(u.trigger==="on_load"||u.trigger==="after_delay")&&u.targetAnimationId===(f==null?void 0:f.id))||(e.push({animation:f,state:l}),i=Math.max(i,f.duration)))}}}this.layerStates.set(t,{currentStateIds:s,animations:e,time:0,duration:i})}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 i=s.replace(/\[(\d+)\]/g,".$1").split(".");let n=e;for(let a=0;a<i.length-1;a++){if(typeof n[i[a]]!="object"||n[i[a]]===null){const r=i[a+1],l=!isNaN(Number(r));n[i[a]]=l?[]:{}}n=n[i[a]]}n[i[i.length-1]]=o}else e[s]=o}updateInput(t,s){var n,a,r;let o;if(this.inputs.has(t)){const l=(n=this.activeStateMachine)==null?void 0:n.inputs.find(f=>f.id===t);l&&typeof l.value=="object"&&(o=l.value.type)}else{const l=this.inputNameMap.get(t);if(l&&l.length>0){const f=(a=this.activeStateMachine)==null?void 0:a.inputs.find(h=>h.id===l[0]);f&&typeof f.value=="object"&&(o=f.value.type)}}let e=s;o==="Trigger"&&(s===1?e=!0:s===0&&(e=!1)),this.inputs.has(t)&&this.setInternalInput(t,e);const i=this.inputNameMap.get(t);i&&i.forEach(l=>this.setInternalInput(l,e)),o==="Trigger"&&e===!0&&(this.justFiredTriggers.add(t),i&&i.forEach(l=>this.justFiredTriggers.add(l))),Array.isArray(e)&&((r=this.artboard)==null||r.objects.forEach(l=>{if(l.inputId===t||l.name===t){const f=this.objectStates.get(l.id);f&&f.options&&(l.type==="ListView"||l.variant==="listview"?f.options.items=e:(l.type==="Dropdown"||l.variant==="dropdown")&&(f.options.optionsList=e))}})),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(i=>{if(i.trigger==="variable"&&i.conditionVariableId&&i.targetAnimationId&&(i.conditionVariableId===t||e&&e.includes(i.conditionVariableId))){const a=i.conditionOperator||"IsTrue",r=i.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 f=i.delay||0;f<=0?this.triggerGlobalAnimation(i.targetAnimationId,i.subAnimationIds,i.loop,i.id):setTimeout(()=>this.triggerGlobalAnimation(i.targetAnimationId,i.subAnimationIds,i.loop,i.id),f)}}})}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 i of s.currentStateIds){const n=t.states.find(r=>r.id===i);if(!n)continue;let a=!1;for(const r of n.transitions||[])this.checkConditions(r.conditions)&&(o.push(r.targetStateId),a=!0,e=!0);a||o.push(i)}if(!e){const i=this.findGlobalTransition(t,s.currentStateIds);i&&(o.length=0,o.push(i.targetStateId),e=!0,i.conditions&&(i.conditions||[]).forEach(n=>{var r;const a=(r=this.activeStateMachine)==null?void 0:r.inputs.find(l=>l.id===n.inputId);a&&typeof a.value=="object"&&a.value.type==="Trigger"&&this.setInternalInput(n.inputId,!1)}))}if(e){const i=Array.from(new Set(o));this.enterStates(t.name,i)}}),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(i=>i.id===t);s&&this.inputNameMap.has(s.name)&&((e=this.inputNameMap.get(s.name))==null||e.forEach(i=>this.setInternalInput(i,!1)))}),this.justFiredTriggers.clear()))}findGlobalTransition(t,s){for(const o of t.states)if(!(s.includes(o.id)&&this.justFiredTriggers.size===0)){for(const i of o.transitions||[])if(!(s.includes(i.targetStateId)&&this.justFiredTriggers.size===0)&&this.checkConditions(i.conditions))return i}return null}checkConditions(t){return!t||t.length===0?!0:t.every(s=>{const o=s.inputId,e=s.op,i=s.value,n=this.evaluateLogicTree(o);if(n===void 0)return this.log(`[Engine] Condition Check Failed: Input ${o} is undefined`),!1;let a=!1;switch(e){case"Equal":case"==":a=n==i;break;case"NotEqual":case"!=":a=n!=i;break;case"GreaterThan":case">":a=n>i;break;case"LessThan":case"<":a=n<i;break;case"GreaterEqual":case">=":a=n>=i;break;case"LessEqual":case"<=":a=n<=i;break;case"IsTrue":a=!!n;break;case"IsFalse":a=!n;break;default:a=!1}return a||this.justFiredTriggers.has(o),a})}evaluateLogicTree(t,s=null,o=new Set){var a,r,l,f,h,u;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(c=>c.id===t);if(e){const c=(p,g)=>{const y=e.inputs.find(b=>b.id===p);return y?y.sourceId?this.evaluateLogicTree(y.sourceId,y.sourceHandleId,o):y.value!==void 0?y.value:g:g};let d=0;switch(e.op){case It.AND:d=c("a",!1)&&c("b",!1);break;case It.OR:d=c("a",!1)||c("b",!1);break;case It.NOT:d=!c("in",!1);break;case It.XOR:d=!!c("a",!1)!=!!c("b",!1);break;case It.OBJECT:d=e.name;break;case It.PROPERTY:case It.GET_PROPERTY:{const p=c("id","");if(!p){d=0;break}const g=e.name;if(!g||g==="GET_PROPERTY"||g==="PROPERTY"){d=0;break}const y=this.objectStates.get(p);if(!y){d=0;break}g in y?d=y[g]:d=this.resolvePath(y,g);break}case It.SET_PROPERTY:{const p=c("id",""),g=c("value",void 0);if(!p||g===void 0){d=0;break}const y=e.name;if(!y||y==="SET_PROPERTY"){d=0;break}const b=this.objectStates.get(p);if(!b){d=0;break}if(["x","y","rotation","scale_x","scale_y","opacity","width","height","cornerRadius","visible","zIndex"].includes(y))b[y]=g,d=g;else{const S=y.replace(/\[(\d+)\]/g,".$1").split(".");let C=b;for(let M=0;M<S.length-1;M++){const I=S[M],k=S[M+1];C[I]===void 0&&(C[I]=isNaN(Number(k))?{}:[]),C=C[I]}const w=S[S.length-1];C[w]=g,d=g}break}case It.ADD:d=c("a",0)+c("b",0);break;case It.SUB:d=c("a",0)-c("b",0);break;case It.MUL:d=c("a",0)*c("b",0);break;case It.DIV:{const p=c("b",1);d=p===0?0:c("a",0)/p;break}case It.MOD:d=c("a",0)%c("b",1);break;case It.POW:d=Math.pow(c("a",0),c("b",1));break;case It.ABS:d=Math.abs(c("in",0));break;case It.ROUND:d=Math.round(c("in",0));break;case It.FLOOR:d=Math.floor(c("in",0));break;case It.CEIL:d=Math.ceil(c("in",0));break;case It.SIN:d=Math.sin(c("in",0));break;case It.COS:d=Math.cos(c("in",0));break;case It.TAN:d=Math.tan(c("in",0));break;case It.CLAMP:{const p=c("in",0),g=c("min",0),y=c("max",1);d=Math.max(g,Math.min(y,p));break}case It.REMAP:{const p=c("in",0),g=c("inMin",0),y=c("inMax",100),b=c("outMin",0),v=c("outMax",1);d=y===g?b:b+(p-g)*(v-b)/(y-g);break}case It.EQ:d=c("a",0)==c("b",0);break;case It.NEQ:d=c("a",0)!=c("b",0);break;case It.GT:d=c("a",0)>c("b",0);break;case It.LT:d=c("a",0)<c("b",0);break;case It.GTE:d=c("a",0)>=c("b",0);break;case It.LTE:d=c("a",0)<=c("b",0);break;case It.IF_ELSE:d=c("cond",!1)?c("then",0):c("else",0);break;case It.VALUE:d=e.value!==void 0?e.value:0;break;case It.INPUT:d=this.inputs.get(e.name)??0;break;case It.LOG:{const p=c("in","");this.debugLog(`[User Logic] ${p}`),d=p;break}case It.SCROLL_X:d=this.inputs.get("scrollX")??0;break;case It.SCROLL_Y:d=this.inputs.get("scrollY")??0;break;case It.MOUSE_X:d=this.inputs.get("mouseX")??0;break;case It.MOUSE_Y:d=this.inputs.get("mouseY")??0;break;case It.IS_MOUSE_DOWN:d=this.inputs.get("isMouseDown")??!1;break;case It.EFFECTOR:{const p=c("id",""),g=c("intensity",1),y=c("trigger",!0);if(!p||!y){d=0;break}const b=e.name;if(!b){d=0;break}const v=this.objectStates.get(p);if(!v){d=0;break}if(["glitch","halftone","pixelate","noise","acid_gradient","acid_rave","shimmer"].includes(b))v.style||(v.style={}),v.style.artEffect={enabled:!0,type:b,intensity:g},d=1;else{v.behaviors||(v.behaviors=[]);let C=v.behaviors.find(w=>w.type===b);C?(C.enabled=!0,C.settings||(C.settings={}),C.settings.intensity=g):(C={id:`eff_${Date.now()}_${b}`,type:b,enabled:!0,sensors:[],settings:{intensity:g}},v.behaviors.push(C)),d=1}break}case It.MONITOR:{d=c("in",0);break}case It.SPRING_PULL:{const p=c("objectId",""),g=c("forceX",0),y=c("forceY",0);p&&((l=this.artboard)==null||l.objects.forEach(b=>{b.behaviors&&b.behaviors.forEach(v=>{var S;if(v.type===q.SpringChain&&((S=v.settings)!=null&&S.connections)&&(v.settings.connections.some(w=>w.targetId===p)||b.id===p)){this._springChainState.has(b.id)||this._springChainState.set(b.id,new Map);const w=this._springChainState.get(b.id);if(!w.has(p)){const I=this.objectStates.get(p);w.set(p,{x:(I==null?void 0:I.x)??0,y:(I==null?void 0:I.y)??0,vx:0,vy:0})}const M=w.get(p);M&&(M.vx+=g,M.vy+=y)}})})),d=1;break}case It.SPRING_SETTLE:{const p=c("objectId","");let g=!0;if(p){const y=c("threshold",1);this._springChainState.forEach(b=>{const v=b.get(p);v&&(Math.abs(v.vx)>y||Math.abs(v.vy)>y)&&(g=!1)})}d=g;break}case It.EMIT:{const p=c("objectId",""),g=c("count",20);p&&((f=this.artboard)==null||f.objects.forEach(y=>{y.behaviors&&y.behaviors.forEach(b=>{b.type===q.ParticleEmitter&&y.id===p&&(b._pendingBurst=(b._pendingBurst||0)+g)})})),d=1;break}default:d=0;break}if(this.logicNodeValues.set(t,d),e.op===It.DELAY){const p=c("delay",0),g=c("in",0);let y=this.logicNodeState.get(t);for(y||(y={queue:[]},this.logicNodeState.set(t,y)),y.queue.push({time:this.currentTime+p,value:g});y.queue.length>0&&y.queue[0].time<=this.currentTime;)y.lastValue=y.queue.shift().value;d=y.lastValue??0}return d}const i=(h=this.activeStateMachine)==null?void 0:h.inputs.find(c=>c.id===t||c.name===t);if(i&&i.sourceId&&!o.has(i.sourceId)){const c=this.evaluateLogicTree(i.sourceId,i.sourceHandleId,o);return this.inputs.set(i.id,c),c}let n=this.inputs.get(t)??(i?this.inputs.get(i.id):void 0);if((this.justFiredTriggers.has(t)||i&&this.justFiredTriggers.has(i.id))&&(n=!0),s&&n!==void 0){const c=(u=this.activeStateMachine)==null?void 0:u.inputs.find(d=>d.id===t);if(c&&c.value.type==="Number"&&typeof n=="number"){const d=c.value.defaultValue??c.value.value;if(s==="source-greater")return n>d;if(s==="source-less")return n<d;if(s==="source-equal")return n===d}if(s==="source-true")return n===!0;if(s==="source-false")return n===!1;if(s==="source-fire")return this.justFiredTriggers.has(t)}return n!==void 0?n:0}runLogicNodes(){!this.activeStateMachine||!this.activeStateMachine.logicNodes||this.activeStateMachine.logicNodes.forEach(t=>{(t.op===It.SET_PROPERTY||t.op===It.EFFECTOR)&&this.evaluateLogicTree(t.id)})}resolvePath(t,s){const o=s.replace(/\[(\d+)\]/g,".$1").split(".");let e=t;for(const i of o)if(e&&typeof e=="object"&&i in e)e=e[i];else return;return e}seek(t){this.artboard&&(this.currentTime=t,this.layerStates.forEach(s=>{s.time=t,s.time>(s.duration||0)&&(s.animations.some(e=>{var i;return((i=e.state)==null?void 0:i.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 i=this.physicsEngine.getPosition(o.id),n=this.physicsEngine.getRotation(o.id),a=this.objectStates.get(o.id);a&&i!==null&&n!==null&&(a.x=i.x,a.y=i.y,a.rotation=n*(180/Math.PI))}})),this.activeStateMachine&&(this.runLogicNodes(),this.evaluateTransitions());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(n=>{var a;return((a=n.state)==null?void 0:a.loop)===!0}))o.time%=o.duration;else{const n=o.time<o.duration+.1;o.time=o.duration,n&&(o.currentStateIds.length>0&&this.handleAnimationFinished(o.currentStateIds[0],o.ruleId),e.startsWith("global_")&&s.push(e))}o.animations.forEach(i=>{var n;(n=i.state)!=null&&n.isBlendState&&i.state.blendAnimations?this.applyBlendState(i.state,o.time):i.animation&&this.applyAnimation(i.animation,o.time,i.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 i,n,a,r,l,f,h;if(o.phase==="entry")o.time+=t,o.time>=o.animation.duration&&((a=(n=(i=this.artboard)==null?void 0:i.objects.find(u=>u.id===e))==null?void 0:n.triggers)==null||a.find(u=>u.id===o.triggerId),o.phase="hold",o.elapsedHold=0,o.time=o.animation.duration),this.applyAnimation(o.animation,o.time,o.filterObjectIds||o.filterObjectId||void 0);else if(o.phase==="hold"){const u=(f=(l=(r=this.artboard)==null?void 0:r.objects.find(p=>p.id===e))==null?void 0:l.triggers)==null?void 0:f.find(p=>p.id===o.triggerId),c=(u==null?void 0:u.duration)||0;o.elapsedHold+=t*1e3;let d=o.elapsedHold>=c;if((u==null?void 0:u.eventType)==="hover"&&!this.activeHoverIds.has(e)&&(d=!0),((u==null?void 0:u.eventType)==="onHold"||(u==null?void 0:u.eventType)==="pointerDown")&&!this.isMouseDown&&(d=!0),d)if(u!=null&&u.exitAnimationId){const p=(h=this.artboard)==null?void 0:h.animations.find(g=>g.id===u.exitAnimationId);p?(o.phase="exit",o.animation=p,o.time=0):this.activeTriggers.delete(e)}else this.activeTriggers.delete(e)}else o.phase==="exit"&&(o.time+=t,o.time>=o.animation.duration?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,i,n;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=(((i=s.geometry)==null?void 0:i.width)||100)*(r.scale_x||1),f=(((n=s.geometry)==null?void 0:n.height)||100)*(r.scale_y||1),h=50,u=r.x+l/2>=-this.canvasWidth/2-h&&r.x-l/2<=this.canvasWidth/2+h&&r.y+f/2>=-this.canvasHeight/2-h&&r.y-f/2<=this.canvasHeight/2+h,c=`analytics_${s.id}`,d=this.wasInView.has(c);u&&!d&&this.fireAnalyticsEvent(s.id,"visible"),u?this.wasInView.add(c):this.wasInView.delete(c)}}}),this.artboard.objects.forEach(s=>{const o=s.interactions||[];o.length!==0&&o.forEach(e=>{const i=e.triggers||[e.event||e.trigger];i&&i.forEach(n=>{var r,l,f;const a=n.toLowerCase();if(a==="on interval"||a==="oninterval"){const h=e.intervalValue||2e3,u=this.periodicTriggerTimes.get(e.id)||0;this.currentTime*1e3-u>=h&&(!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 h=e.delayValue||1e3;!this.periodicTriggerTimes.has(e.id)&&this.currentTime*1e3>=h&&(!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 h=this.objectStates.get(s.id);if(h&&h.visible!==!1){const u=this.getGlobalTransform(s.id),c=(((r=s.geometry)==null?void 0:r.width)||100)*(u.scale_x||1),d=(((l=s.geometry)==null?void 0:l.height)||100)*(u.scale_y||1),p=50,g=u.x+c/2>=-this.canvasWidth/2-p&&u.x-c/2<=this.canvasWidth/2+p&&u.y+d/2>=-this.canvasHeight/2-p&&u.y-d/2<=this.canvasHeight/2+p,y=this.wasInView.has(s.id);g&&!y&&(!e.conditions||this.checkConditions(e.conditions))&&this.fireEventForObject(s.id,"Scroll Into View"),g?this.wasInView.add(s.id):this.wasInView.delete(s.id)}}if(a==="scroll progress"||a==="scrollprogress"){const h=Math.abs(this.scrollOffset.y)/(((f=this.artboard)==null?void 0:f.height)||1e3),u=this.scrollProgressLastValue.get(e.id)||0;Math.abs(h-u)>.001&&(this.scrollProgressLastValue.set(e.id,h),(e.action==="Set Input"||e.action==="setInput")&&this.updateInput(e.targetInputId,h))}})})}))}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((i,n)=>{var f,h,u,c,d,p,g,y,b;const a=((f=o.constraints)==null?void 0:f[n])||{},r={...i,...a},l=r.strength??1;if(r.type==="Translation"){const v=this.getGlobalTransform(r.targetId);if(v){const S=r.offsetX||0,C=r.offsetY||0,w=v.x+S,M=v.y+C,I=r.useSpring;if(I){const T=this.objectVelocities.get(s.id)||{vx:0,vy:0},{x:O,y:_,vx:P,vy:E}=this.computeSpring(e.x,e.y,T.vx,T.vy,w,M,r,t);r.copyX&&(e.x=e.x+(O-e.x)*l),r.copyY&&(e.y=e.y+(_-e.y)*l),this.objectVelocities.set(s.id,{vx:P,vy:E})}else r.copyX&&(e.x=e.x+(w-e.x)*l),r.copyY&&(e.y=e.y+(M-e.y)*l);let k=!1;if((h=r.limitX)!=null&&h.enabled){const T=e.x;e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x)),e.x!==T&&(k=!0)}if((u=r.limitY)!=null&&u.enabled){const T=e.y;e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)),e.y!==T&&(k=!0)}k&&I&&this.objectVelocities.set(s.id,{vx:0,vy:0})}}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 S=(v.rotation-e.rotation)%360;S>180&&(S-=360),S<-180&&(S+=360),e.rotation=e.rotation+S*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=((c=this._lastPointerPos)==null?void 0:c.x)??e.x,S=((d=this._lastPointerPos)==null?void 0:d.y)??e.y,C=r.useSpring;if(C){const M=this.objectVelocities.get(s.id)||{vx:0,vy:0},{x:I,y:k,vx:T,vy:O}=this.computeSpring(e.x,e.y,M.vx,M.vy,v,S,r,t);e.x=I,e.y=k,this.objectVelocities.set(s.id,{vx:T,vy:O})}else e.x=e.x+(v-e.x)*l,e.y=e.y+(S-e.y)*l;let w=!1;if((p=r.limitX)!=null&&p.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((g=r.limitY)!=null&&g.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 S=e.x-v.x,C=e.y-v.y,w=Math.sqrt(S*S+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 k=e.x===v.x&&e.y===v.y?1:I/w;e.x=e.x+(v.x+S*k-e.x)*l,e.y=e.y+(v.y+C*k-e.y)*l}}}else if(r.type==="FollowPath"){const v=(y=this.artboard)==null?void 0:y.objects.find(S=>S.id===r.targetId);if(v){const S=this.getGlobalTransform(v.id);if(S){let C=v.geometry;if(v.type==="Frame"||v.type==="Group"||!C||C.type!=="Path"&&C.type!=="Ellipse"&&C.type!=="Rectangle"){const R=(b=this.artboard)==null?void 0:b.objects.find(et=>et.parentId===v.id&&et.type==="Shape"&&et.geometry&&(et.geometry.type==="Path"||et.geometry.type==="Ellipse"||et.geometry.type==="Rectangle"));R&&(C=R.geometry)}if(!C)return;const w=(r.distance||0)/100,M=S.width||C.width||0,I=S.height||C.height||0,k=this.getPointOnPath(C,M,I,w),T=S.rotation*Math.PI/180,O=Math.cos(T),_=Math.sin(T),P=k.x*S.scale_x*O-k.y*S.scale_y*_,E=k.x*S.scale_x*_+k.y*S.scale_y*O;let A=S.rotation+(r.offsetRotation||0);if(r.orient){const R=Math.cos(k.angle),et=Math.sin(k.angle),U=R*S.scale_x*O-et*S.scale_y*_,lt=R*S.scale_x*_+et*S.scale_y*O;A=Math.atan2(lt,U)*180/Math.PI+(r.offsetRotation||0)}const B=A*Math.PI/180,D=Math.cos(B),W=Math.sin(B),X=(r.offsetX||0)*D-(r.offsetY||0)*W,H=(r.offsetX||0)*W+(r.offsetY||0)*D,Q=S.x+P+X,L=S.y+E+H;if(e.x=e.x+(Q-e.x)*l,e.y=e.y+(L-e.y)*l,r.orient){let R=(A-e.rotation)%360;R>180&&(R-=360),R<-180&&(R+=360),e.rotation=e.rotation+R*l}}}}else if(r.type==="IK"){const v=this.getGlobalTransform(r.targetId);v&&this.solveIK(s,v,r.boneCount||2,l)}}),s.constraints.some(i=>i.type!=="IK")){const i=this.globalToLocal(s.parentId,e);o.x=i.x,o.y=i.y,o.rotation=i.rotation,o.flip_x=i.scale_x<0,o.scale_x=Math.abs(i.scale_x),o.flip_y=i.scale_y<0,o.scale_y=Math.abs(i.scale_y)}})}getGlobalTransform(t){var h,u;const s=this.objectStates.get(t);if(!s)return{x:0,y:0,rotation:0,scale_x:1,scale_y:1};const o=(h=this.artboard)==null?void 0:h.objects.find(c=>c.id===t),e=(o==null?void 0:o.type)==="Bone"?(u=o.geometry)==null?void 0:u.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 i=this.getGlobalTransform(o.parentId),n=i.rotation*Math.PI/180,a=Math.cos(n),r=Math.sin(n),l=i.x+(s.x*i.scale_x*a-s.y*i.scale_y*r),f=i.y+(s.x*i.scale_x*r+s.y*i.scale_y*a);return{x:l,y:f,rotation:i.rotation+s.rotation,scale_x:i.scale_x*(s.scale_x??1)*(s.flip_x?-1:1),scale_y:i.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,i=o.scale_y===0?0:1/o.scale_y,n=-o.rotation*Math.PI/180,a=Math.cos(n),r=Math.sin(n),l=s.x-o.x,f=s.y-o.y,h=(l*a-f*r)*e,u=(l*r+f*a)*i;return{x:h,y:u,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 i=[];let n=t.id;for(let f=0;f<o&&n;f++){const h=(l=this.artboard)==null?void 0:l.objects.find(u=>u.id===n);if(!h)break;i.push({id:n,local:this.objectStates.get(n),global:this.getGlobalTransform(n)}),n=h.parentId}if(i.length<2)return;const a=i.reverse(),r=5;for(let f=0;f<r;f++){const h=this.getGlobalTransform(t.id);for(let u=a.length-2;u>=0;u--){const c=a[u],d=this.getGlobalTransform(c.id),p=h.x-d.x,g=h.y-d.y,y=s.x-d.x,b=s.y-d.y,v=Math.sqrt(p*p+g*g),S=Math.sqrt(y*y+b*b);if(v>.001&&S>.001){const C=Math.atan2(g,p);let M=(Math.atan2(b,y)-C)*180/Math.PI;M*=e;const I=this.objectStates.get(c.id);I&&(I.rotation+=M)}}}}computeSpring(t,s,o,e,i,n,a,r){const l=a.stiffness??100,f=a.damping??10,h=a.mass??1,u=-l*(t-i),c=-l*(s-n),d=-f*o,p=-f*e,g=(u+d)/h,y=(c+p)/h,b=o+g*r,v=e+y*r,S=t+b*r,C=s+v*r;return{x:S,y:C,vx:b,vy:v}}handlePointerInput(t,s,o,e,i){if(!this.artboard)return;const n=this.calculateTransform(e,i,this.artboard.width,this.artboard.height,this.layout.fit,this.layout.alignment),a=(s-n.tx)/n.scaleX,r=(o-n.ty)/n.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)}handleWheel(t,s){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,f,h,u;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 i=(c,d)=>{var S;let p=d;d==="click"?p="onClick":d==="down"?p="onPointerDown":d==="up"?p="onPointerUp":d==="blur"&&(p="onPointerLeave");const g=new Set([p]);d==="move"&&g.add("onPointerEnter").add("hover").add("onPointerLeave").add("blur"),p==="onClick"&&g.add("click"),p==="onPointerDown"&&g.add("pointerDown"),p==="onPointerUp"&&g.add("pointerUp");const y=["button","toggle","toggle_button","dropdown","listview","inputbox","slider","checkbox","radiogroup","joystick"];return!!(c.type==="Component"&&y.includes(c.variant)||c.type==="Joystick"||y.includes((S=c.type)==null?void 0:S.toLowerCase())||(c.interactions||[]).some(C=>g.has(C.event))||(c.triggers||[]).some(C=>g.has(C.eventType)))};let n=null;for(let c=this.artboard.objects.length-1;c>=0;c--){const d=this.artboard.objects[c],p=this.objectStates.get(d.id);if(p&&p.visible!==!1&&p.opacity>0&&this.hitTest(d,s,o)&&(n||(n=d),i(d,t))){e=d;break}}!e&&n&&(e=n),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(d=>d.id===this.draggingSliderId);c&&this.updateSliderValueFromPointer(c,s,o);return}if(this.draggingJoystickId){const c=this.artboard.objects.find(d=>d.id===this.draggingJoystickId);c&&this.updateJoystickValueFromPointer(c,s,o);return}if(this.draggingListViewId){const c=this.artboard.objects.find(d=>d.id===this.draggingListViewId);c&&this.updateListViewScrollFromPointer(c);return}e&&(e.type==="ListView"||e.type==="Component"&&e.variant==="listview")&&this.updateListViewHoverFromPointer(e,s,o),this.isMouseDown&&a&&this.fireEventForObject(a,"Drag"),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.draggingBehaviors.clear(),this.pointerDownTimes.delete(a),this.activeObjectId=null),t==="down"&&(this.pointerDownTimes.set(a,this.currentTime),this.activeObjectId=a,e&&((r=e.behaviors)!=null&&r.some(c=>c.type===q.Draggable))&&this.draggingBehaviors.add(a)),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(d=>d.id===this.activeDropdownId);if(c&&(c.type==="Dropdown"||c.variant==="dropdown")){const d=this.objectStates.get(c.id),p=(d==null?void 0:d.options)||c.options||{},g=c.geometry||{},y=g.width??c.width??200,b=g.height??c.height??40,v=p.optionsList||[],S=p.itemHeight||32,C=p.listPadding??4,w=v.length*S+C*2,M=this.getWorldTransform(c.id),I=y*Math.abs(M.scaleX),k=b*Math.abs(M.scaleY),T=M.y+k/2+4,O=Math.abs(s-M.x)<=I/2,_=o>=T&&o<=T+w*Math.abs(M.scaleY);if(O&&_){const P=Math.abs(M.scaleY),E=o-(T+C*P),A=Math.floor(E/(S*P));if(A>=0&&A<v.length){const B=v[A];p.selectedOption=B,p.isOpen=!1,this.activeDropdownId=null,c.inputId&&this.setInternalInput(c.inputId,B),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"dropdown",property:"selectedOption",value:B})}return}else a!==this.activeDropdownId&&(p.isOpen=!1,this.activeDropdownId=null)}}if(e){let c=e,d=e;for(;d&&d.parentId;){const g=this.artboard.objects.find(y=>y.id===d.parentId);if(g&&g.type==="Component"){c=g;break}d=g}let p=t;if(t==="click"?p="onClick":t==="down"?p="onPointerDown":t==="up"?p="onPointerUp":t==="blur"&&(p="onPointerLeave"),this.fireEventForObject(e.id,p),c!==e&&this.fireEventForObject(c.id,p),c.type==="Component"&&c.variant==="toggle_button"&&t==="down"){const g=this.objectStates.get(c.id),y=(g==null?void 0:g.options)||c.options||{};y.checked=!y.checked,c.inputId&&this.setInternalInput(c.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"toggle_button",property:"checked",value:y.checked}),this.fireEventForObject(c.id,"Toggle"),this.fireEventForObject(c.id,y.checked?"Toggle True":"Toggle False")}if(c.type==="Component"&&c.variant==="toggle"&&t==="down"){const g=this.objectStates.get(c.id),y=(g==null?void 0:g.options)||c.options||{};y.checked=!y.checked,c.inputId&&this.setInternalInput(c.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"toggle",property:"checked",value:y.checked}),this.onToggle&&this.onToggle(c.name,y.checked),this.fireEventForObject(c.id,"Toggle"),this.fireEventForObject(c.id,y.checked?"Toggle True":"Toggle False")}if(c.type==="Component"&&c.variant==="dropdown"&&t==="down"){const g=this.objectStates.get(c.id),y=(g==null?void 0:g.options)||c.options||{},b=!y.isOpen;if(b&&this.activeDropdownId&&this.activeDropdownId!==c.id){const v=this.artboard.objects.find(S=>S.id===this.activeDropdownId);v&&v.options&&(v.options.isOpen=!1)}y.isOpen=b,this.activeDropdownId=b?c.id:null}if(c.type==="Component"&&c.variant==="button"&&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})),(c.type==="ListView"||c.type==="Component"&&c.variant==="listview")&&t==="down"){this.draggingListViewId=c.id;const g=this.getListViewItemIndexAtPointer(c,s,o);if(g!==null){const y=c.options||{};y.activeItemIndex=g;const b=this.objectStates.get(c.id);b&&b.options&&(b.options.activeItemIndex=g);const v=(y.items||[])[g],S=typeof v=="string"?v:v.label||v.value||g;b&&b.options&&(b.options.selectedValue=S),c.inputId&&this.setInternalInput(c.inputId,S),this.onComponentChange&&(this.onComponentChange({objectId:c.id,componentName:c.name,variant:"listview",property:"activeItemIndex",value:g}),this.onComponentChange({objectId:c.id,componentName:c.name,variant:"listview",property:"selected",value:S}))}}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 g=this.objectStates.get(c.id);g&&c.isSpringReturn!==!1&&(g.handleX=0,g.handleY=0),c.isSpringReturn!==!1&&(c.handleX=0,c.handleY=0)}}if(c.type==="Component"&&c.variant==="checkbox"&&t==="down"){const g=this.objectStates.get(c.id),y=(g==null?void 0:g.options)||c.options||{};y.checked=!y.checked,c.inputId&&this.setInternalInput(c.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"checkbox",property:"checked",value:y.checked}),this.fireEventForObject(c.id,"Click"),this.fireEventForObject(c.id,y.checked?"Checked":"Unchecked")}if(c.type==="Component"&&c.variant==="radiogroup"&&t==="down"){const g=this.objectStates.get(c.id),y=(g==null?void 0:g.options)||c.options||{},b=y.optionsList||[],v=this.getRadioGroupItemIndexAtPointer(c,s,o);if(v!==null&&v>=0&&v<b.length){const S=b[v];y.selectedValue=S,c.inputId&&this.setInternalInput(c.inputId,S),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"radiogroup",property:"selectedValue",value:S}),this.fireEventForObject(c.id,"Click"),this.fireEventForObject(c.id,`Selected: ${S}`)}}if(c.type==="LineGraph"&&(t==="down"||t==="click")){const g=c.geometry,y=(g==null?void 0:g.datasets)||[],b=this.objectStates.get(c.id),v=(b==null?void 0:b.width)||(g==null?void 0:g.width)||200,S=(b==null?void 0:b.height)||(g==null?void 0:g.height)||150,C=this.getWorldTransform(c.id),w=30,M=20,I=v-w,k=S-M;let T=1;y.forEach(P=>{const E=Math.max(...P.data||[0]);E>T&&(T=E)});let O=1/0,_=null;y.forEach((P,E)=>{const A=P.data||[],B=I/Math.max(A.length-1,1);A.forEach((D,W)=>{const X=C.x-v/2+w+W*B,H=C.y+S/2-M-D/T*k,Q=Math.sqrt((s-X)**2+(o-H)**2);Q<O&&(O=Q,_={dIdx:E,pIdx:W,val:D,label:P.label||`Dataset ${E+1}`})})}),_&&O<20&&this.onGraphPointClick&&this.onGraphPointClick({objectId:c.id,componentName:c.name,datasetIndex:_.dIdx,pointIndex:_.pIdx,value:_.val,label:_.label}),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"linegraph",property:"click",value:(_==null?void 0:_.val)??null})}if(t==="click"){const g=(l=this.artboard)==null?void 0:l.objects.find(v=>v.id===e.id),y=this.focusedId,b=(g==null?void 0:g.type)==="InputBox"||(g==null?void 0:g.type)==="Component"&&g.variant==="inputbox";if(g&&b){if(this.focusedId=e.id,this.log(`[Engine] Focus set to: ${e.id}`),y!==this.focusedId){if(y){const v=(f=this.artboard)==null?void 0:f.objects.find(S=>S.id===y);v&&this.onInputBlur&&this.onInputBlur(v.name)}this.onInputFocus&&this.onInputFocus(g.name)}}else if(this.focusedId=null,y){const v=(h=this.artboard)==null?void 0:h.objects.find(S=>S.id===y);v&&this.onInputBlur&&this.onInputBlur(v.name)}}}else if(t==="click"){const c=this.focusedId;if(this.focusedId=null,c){const d=(u=this.artboard)==null?void 0:u.objects.find(p=>p.id===c);d&&this.onInputBlur&&this.onInputBlur(d.name)}}}handleKeyDown(t){if(!this.artboard||(this.activeKeys.add(t.key.toLowerCase()),this.activeKeys.add(t.code),!this.focusedId))return;const s=this.artboard.objects.find(a=>a.id===this.focusedId),o=(s==null?void 0:s.type)==="InputBox"||(s==null?void 0:s.type)==="Component"&&s.variant==="inputbox";if(!s||!o)return;const e=s.options||{};let i=e.text||"";if(t.key==="Backspace")i=i.slice(0,-1);else if(t.key==="Enter")if(e.multiline)i+=`
7
- `;else{this.focusedId=null;return}else if(t.key.length===1)i+=t.key;else return;e.text=i;const n=s.geometry;n.textInputId&&this.updateInput(n.textInputId,i),this.onComponentChange&&this.onComponentChange({objectId:s.id,componentName:s.name,variant:"inputbox",property:"text",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))}fireEventForObject(t,s){var f,h,u,c,d;const o=(f=this.artboard)==null?void 0:f.objects.find(p=>p.id===t);if(!o)return;const e=new Set([s,s.toLowerCase()]),i=s.toLowerCase();i==="onclick"||i==="click"||i==="onpointerdown"||i==="pointerdown"?this.fireAnalyticsEvent(t,"click"):(i==="onpointerenter"||i==="hover"||i==="move")&&this.fireAnalyticsEvent(t,"hover"),i==="onclick"||i==="click"?(e.add("click"),e.add("onclick")):i==="onpointerdown"||i==="pointerdown"?(e.add("pointerdown"),e.add("onpointerdown")):i==="onpointerup"||i==="pointerup"?(e.add("pointerup"),e.add("onpointerup")):i==="onpointerenter"||i==="hover"||i==="move"?(e.add("hover"),e.add("onpointerenter")):i==="onpointerleave"||i==="blur"?(e.add("onpointerleave"),e.add("blur")):i==="drag"||i==="ondrag"?(e.add("drag"),e.add("ondrag")):i==="toggle"||i==="ontoggle"?(e.add("toggle"),e.add("ontoggle")):i==="toggle true"||i==="toggle_true"||i==="toggletrue"?(e.add("toggle true"),e.add("toggle_true"),e.add("toggletrue")):(i==="toggle false"||i==="toggle_false"||i==="togglefalse")&&(e.add("toggle false"),e.add("toggle_false"),e.add("togglefalse"));const a=(o.interactions||[]).find(p=>{const g=p.triggers||[p.event||p.trigger||"click"];return((p.triggerLogic||"OR")==="AND"?g.every(v=>e.has(v.toLowerCase())):g.some(v=>e.has(v.toLowerCase())))?p.conditions&&p.conditions.length>0?this.checkConditions(p.conditions):!0:!1});if(a){if(this.log(`[Engine] Interaction matched: ${s} -> Action: ${a.action}`),a.action==="setInput"||a.action==="Set Input"){let p=a.value||a.inputValue;p==="toggle"&&(p=!this.inputs.get(a.targetInputId)),this.updateInput(a.targetInputId,p)}else if(a.action==="Toggle Boolean"){const p=this.inputs.get(a.targetInputId);this.updateInput(a.targetInputId,!p)}else if(a.action==="fireTrigger")this.updateInput(a.targetInputId,!0);else if(a.action==="setProperty"){const p=a.targetObjectId||o.id,g=a.targetProperty;g&&this.updateObjectProperty(p,g,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 p=a.targetAnimationId,g=!a.playMode||a.playMode==="all"?void 0:a.subAnimationIds;p==="__all__"?(u=(h=this.artboard)==null?void 0:h.animations)==null||u.forEach(y=>{this.triggerGlobalAnimation(y.id,g)}):p&&this.triggerGlobalAnimation(p,g)}else if(a.action==="setState"||a.action==="Set State"){const p=a.targetObjectId||o.id,y={...this.objectStates.get(p)||{},...a.value||{}};this.objectStates.set(p,y),this.log(`[Engine] State updated for ${p}:`,y)}else if(a.action==="Stop Animation"||a.action==="Pause Animation"){const p=a.targetAnimationId;p==="__all__"?this.layerStates.forEach((g,y)=>{y.startsWith("global_")&&this.layerStates.delete(y)}):p&&this.layerStates.forEach((g,y)=>{y.startsWith(`global_${p}_`)&&this.layerStates.delete(y)})}else if(a.action==="Switch to State"&&this.activeStateMachine){const p=a.targetState,g=this.activeStateMachine.layers.find(y=>y.states.some(b=>b.id===p||b.name===p));g&&(this.log(`[Engine] Switching Layer ${g.name} to State ${p}`),this.enterStates(g.name,[p]))}this.onTrigger&&this.onTrigger(s,a.action)}const l=(o.triggers||[]).find(p=>{const g=p.eventType.toLowerCase();let y=!1;return(e.has(g)||g==="click"&&e.has("onclick")||g==="hover"&&(e.has("onpointerenter")||e.has("hover"))||g==="pointerdown"&&e.has("onpointerdown")||g==="pointerup"&&e.has("onpointerup"))&&(y=!0),y&&p.conditions&&p.conditions.length>0?this.checkConditions(p.conditions):y});if(l&&l.entryAnimationId){this.log(`[Engine] Trigger matched: ${s} (as ${l.eventType}) -> Animation ${l.entryAnimationId}`);const p=(d=(c=this.artboard)==null?void 0:c.animations)==null?void 0:d.find(g=>g.id===l.entryAnimationId);p&&(this.activeTriggers.set(o.id,{triggerId:l.id,animation:p,time:0,phase:"entry",elapsedHold:0,filterObjectId:l.targetObjectId}),this.onTrigger&&this.onTrigger(l.name,p.name))}}fireAnalyticsEvent(t,s){var r,l;const o=(r=this.artboard)==null?void 0:r.objects.find(f=>f.id===t);if(!o)return;const e=(l=o.style)==null?void 0:l.analytics;if(!e||!e.isEnabled||e.triggerType!==s)return;const i=e.eventName||`${o.name.toLowerCase().replace(/\s+/g,"_")}_interacted`,n={};e.parameters&&Array.isArray(e.parameters)&&e.parameters.forEach(f=>{if(f.type==="literal")n[f.key]=f.value;else if(f.type==="variable"){const h=this.inputs.get(f.value);n[f.key]=h!==void 0?h:""}}),this.log(`[ExodeUI Analytics] Dispatching event "${i}" via ${s} trigger:`,n);const a=e.platforms||{ga4:!0,meta:!0,mixpanel:!1};if(a.ga4){const f=window;typeof f.gtag=="function"?(f.gtag("event",i,n),this.log(`[ExodeUI Analytics] GA4: Event "${i}" sent successfully.`)):this.warn(`[ExodeUI Analytics] GA4: window.gtag is not a function. Event "${i}" skipped.`)}if(a.meta){const f=window;typeof f.fbq=="function"?(f.fbq("track",i,n),this.log(`[ExodeUI Analytics] Meta Pixel: Event "${i}" sent successfully.`)):this.warn(`[ExodeUI Analytics] Meta Pixel: window.fbq is not a function. Event "${i}" skipped.`)}if(a.mixpanel){const f=window;f.mixpanel&&typeof f.mixpanel.track=="function"?(f.mixpanel.track(i,n),this.log(`[ExodeUI Analytics] Mixpanel: Event "${i}" sent successfully.`)):this.warn(`[ExodeUI Analytics] Mixpanel: window.mixpanel.track is not a function. Event "${i}" skipped.`)}}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){if(!this.artboard)return;const i=this.artboard.animations.find(a=>a.id===t);if(!i)return;const n=`global_${t}_${Math.random().toString(36).substr(2,5)}`;this.layerStates.set(n,{currentStateIds:[t],animations:[{animation:i,state:{loop:o},filterObjectIds:s}],time:0,duration:i.duration,ruleId:e}),this.debugLog(`[Engine] Triggered global animation: ${i.name} (Loop: ${o}, Sub-Anims: ${(s==null?void 0:s.length)||"All"})`)}handleAnimationFinished(t,s){if(!this.artboard)return;(this.artboard.animationFlow||[]).forEach(e=>{if(e.trigger==="after_anim"&&e.targetAnimationId&&(e.afterAnim===t||s&&e.afterAnim===s)){const n=e.delay||0;n<=0?this.triggerGlobalAnimation(e.targetAnimationId,e.subAnimationIds,e.loop,e.id):setTimeout(()=>this.triggerGlobalAnimation(e.targetAnimationId,e.subAnimationIds,e.loop,e.id),n)}})}getWorldTransform(t){var u;const s=this.objectStates.get(t);if(!s)return{x:0,y:0,scaleX:1,scaleY:1,rotation:0};const o=(u=this.artboard)==null?void 0:u.objects.find(c=>c.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),i=e.rotation*(Math.PI/180),n=Math.cos(i),a=Math.sin(i),r=s.x*e.scaleX,l=s.y*e.scaleY,f=e.x+(r*n-l*a),h=e.y+(r*a+l*n);return{x:f,y:h,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,S;if(!this.objectStates.get(t.id))return!1;const i=((v=t.geometry)==null?void 0:v.width)??t.width??100,n=((S=t.geometry)==null?void 0:S.height)??t.height??100,a=this.getWorldTransform(t.id),r=s-a.x,l=o-a.y,f=-a.rotation*(Math.PI/180),h=Math.cos(f),u=Math.sin(f),c=r*h-l*u,d=r*u+l*h,p=a.scaleX,g=a.scaleY,y=i*Math.abs(p),b=n*Math.abs(g);return Math.abs(c)<=y/2&&Math.abs(d)<=b/2}updateSliderValueFromPointer(t,s,o){var M;const e=this.objectStates.get(t.id);if(!e)return;const i=t.options||{},n=((M=t.geometry)==null?void 0:M.width)??t.width??200,a=this.getWorldTransform(t.id),r=s-a.x,l=o-a.y,f=-a.rotation*(Math.PI/180),h=Math.cos(f),u=Math.sin(f),c=r*h-l*u,d=i.thumbWidth??16,p=n-d;let y=(c+p/2)/p;y=Math.max(0,Math.min(1,y));const b=i.min??0,v=i.max??100,S=i.step||1;let C=b+y*(v-b);S>0&&(C=Math.round(C/S)*S),C=Math.max(b,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 i=(e==null?void 0:e.width)!==void 0?e.width:((M=t.geometry)==null?void 0:M.width)??t.width??100,n=(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,f=-a.rotation*(Math.PI/180),h=Math.cos(f),u=Math.sin(f);let c=(r*h-l*u)/Math.max(.001,Math.abs(a.scaleX||1)),d=(r*u+l*h)/Math.max(.001,Math.abs(a.scaleY||1));t.handleOrigin==="top-left"?(c-=i/2,d-=n/2):t.handleOrigin==="bottom-right"&&(c+=i/2,d+=n/2);const p=Math.min(i,n)*.45,g=Math.min(i,n)*.15,y=p-g;let b=c/y,v=d/y;const S=Math.sqrt(b*b+v*v);t.boundsShape==="square"?(b=Math.max(-1,Math.min(1,b)),v=Math.max(-1,Math.min(1,v))):S>1&&(b/=S,v/=S),t.deadzone!==void 0&&S<t.deadzone?(b=0,v=0):(t.stepX!==void 0&&t.stepX>0&&(b=Math.round(b/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"&&(b=0);const C=e.handleX,w=e.handleY;(C!==b||w!==v)&&(e.handleX=b,e.handleY=v,t.handleX=b,t.handleY=v)}processJoysticks(t){this.artboard&&(this.artboard.objects.forEach(s=>{var a,r;if(s.type!=="Joystick"&&!(s.type==="Component"&&s.variant==="joystick"))return;const o=s,e=this.objectStates.get(o.id);if(!e)return;let i=e.handleX??o.handleX??0,n=e.handleY??o.handleY??0;if(((a=o.inputBinding)==null?void 0:a.type)==="keyboard"&&o.inputBinding.keyboardConfig){const l=o.inputBinding.keyboardConfig;let f=i,h=n;const c=(l.speed||5)*t;let d=!1;this.activeKeys.has(l.upKey.toLowerCase())&&(h-=c,d=!0),this.activeKeys.has(l.downKey.toLowerCase())&&(h+=c,d=!0),this.activeKeys.has(l.leftKey.toLowerCase())&&(f-=c,d=!0),this.activeKeys.has(l.rightKey.toLowerCase())&&(f+=c,d=!0),o.joystickType==="1D_X"&&(h=0),o.joystickType==="1D_Y"&&(f=0);const p=Math.sqrt(f*f+h*h);p>1&&(f/=p,h/=p),!d&&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)),i=f,n=h}else if(((r=o.inputBinding)==null?void 0:r.type)==="mouse"&&o.inputBinding.mouseConfig){const l=o.inputBinding.mouseConfig;let f=i,h=n;const u=l.sensitivity||.01,c=Math.abs(this._mouseDelta.dx)>0||Math.abs(this._mouseDelta.dy)>0;l.axisX&&(f+=this._mouseDelta.dx*u),l.axisY&&(h+=this._mouseDelta.dy*u),o.joystickType==="1D_X"&&(h=0),o.joystickType==="1D_Y"&&(f=0);const d=Math.sqrt(f*f+h*h);d>1&&(f/=d,h/=d),!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)),i=f,n=h}if(e.handleX=i,e.handleY=n,o.handleX=i,o.handleY=n,o.bindings&&o.bindings.length>0){const l=Math.sqrt(i*i+n*n);let f=Math.atan2(n,i)*(180/Math.PI);f<0&&(f+=360),o.bindings.forEach(h=>{var d,p,g,y,b,v,S,C;let u=0;h.sourceAxis==="x"?u=o.invertX?-i:i:h.sourceAxis==="y"?u=o.invertY?-n:n:h.sourceAxis==="distance"?u=l:h.sourceAxis==="angle"&&(u=f);const c=(d=this.artboard)==null?void 0:d.objects.find(w=>w.id===h.targetObjectId);if(c){if(h.actionType==="bind"&&h.targetProperty&&h.isContinuous!==!1){const w=h.sourceMin??-1,M=h.sourceMax??1,I=h.targetMin??0,k=h.targetMax??100;let T=!!h.isContinuous,O=0,_=0;if(T){if((h.sourceAxis==="x"||h.sourceAxis==="y")&&I>=0){const E=Math.max(Math.abs(w),Math.abs(M))||1;_=u/E*k}else{let E=(u-w)/(M-w);E=Math.max(0,Math.min(1,E)),_=I+E*(k-I)}Math.abs(u)<.05&&(_=0)}else{const E=(u-w)/(M-w),A=Math.max(0,Math.min(1,E));O=I+A*(k-I),h.step&&h.step>0&&(O=Math.round(O/h.step)*h.step)}const P=this.objectStates.get(c.id);if(P){const E=h.isRelative!==!1,A=E?((p=c.transform)==null?void 0:p.x)??0:0,B=E?((g=c.transform)==null?void 0:g.y)??0:0,D=E?((y=c.transform)==null?void 0:y.rotation)??0:0,W=E?((b=c.transform)==null?void 0:b.scale_x)??1:0,X=E?((v=c.transform)==null?void 0:v.scale_y)??1:0,H=E?((S=c.style)==null?void 0:S.opacity)??100:0,Q=t*60,L=(R,et)=>{let U=O;if(T){const lt=`_internal_${R}_${h.id}`;let x=P[lt];x===void 0&&(x=P[R]??et),U=x+_*Q,P[lt]=U,h.step&&h.step>0&&(U=Math.round(U/h.step)*h.step)}else U=et+O;P[R]=U};h.targetProperty==="x"||h.targetProperty==="transform.x"?L("x",A):h.targetProperty==="y"||h.targetProperty==="transform.y"?L("y",B):h.targetProperty==="rotation"||h.targetProperty==="r"||h.targetProperty==="transform.rotation"?L("rotation",D):h.targetProperty==="scaleX"||h.targetProperty==="transform.scale_x"?L("scale_x",W):h.targetProperty==="scaleY"||h.targetProperty==="transform.scale_y"?L("scale_y",X):(h.targetProperty==="opacity"||h.targetProperty==="transform.opacity")&&L("opacity",H)}(C=c.physics)!=null&&C.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(c.id,(O-((P==null?void 0:P.x)||0))*10,0):(h.targetProperty==="y"||h.targetProperty==="transform.y")&&this.physicsEngine.applyForce(c.id,0,(O-((P==null?void 0:P.y)||0))*10))}else if(h.actionType==="playAnimation"||h.actionType==="stopAnimation"||h.actionType==="pauseAnimation"){let w=!1;const M=h.threshold??0;h.condition==="always"?w=!0:h.condition===">"?w=u>M:h.condition==="<"?w=u<M:h.condition==="=="&&(w=Math.abs(u-M)<.01);const I=e[`_prev_src_${h.id}`]??u;let k=!1;h.condition==="always"?k=!0:h.condition===">"?k=I>M:h.condition==="<"?k=I<M:h.condition==="=="&&(k=Math.abs(I-M)<.01),e[`_prev_src_${h.id}`]=u,w&&!k&&h.targetAnimationId&&(h.actionType==="playAnimation"||h.actionType)}}})}}),this._mouseDelta.dx=0,this._mouseDelta.dy=0)}applyBlendState(t,s){var l,f,h,u,c,d,p,g;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 i=[];let n=0;if(t.blendType==="1D"){const y=[...t.blendAnimations].sort((b,v)=>b.position[0]-v.position[0]);if(y.length===1){const b=(f=(l=this.artboard)==null?void 0:l.animations)==null?void 0:f.find(v=>v.id===y[0].animationId);b&&(i.push({anim:b,weight:1}),n=1)}else{let b=0;for(;b<y.length-1&&y[b+1].position[0]<o;)b++;if(b===y.length-1&&o>y[b].position[0]){const v=(u=(h=this.artboard)==null?void 0:h.animations)==null?void 0:u.find(S=>S.id===y[b].animationId);v&&(i.push({anim:v,weight:1}),n=1)}else{const v=y[b].position[0],S=y[b+1].position[0],C=(d=(c=this.artboard)==null?void 0:c.animations)==null?void 0:d.find(T=>T.id===y[b].animationId),w=(g=(p=this.artboard)==null?void 0:p.animations)==null?void 0:g.find(T=>T.id===y[b+1].animationId),M=Math.max(.001,S-v);let I=(o-v)/M;I=Math.max(0,Math.min(1,I));const k=1-I;C&&(i.push({anim:C,weight:k}),n+=k),w&&(i.push({anim:w,weight:I}),n+=I)}}}else t.blendAnimations.forEach(y=>{var w,M;const b=(M=(w=this.artboard)==null?void 0:w.animations)==null?void 0:M.find(I=>I.id===y.animationId);if(!b)return;const v=y.position[0]-o,S=y.position[1]-e,C=v*v+S*S;if(C<1e-4)i.push({anim:b,weight:1e4}),n+=1e4;else{const I=1/C;i.push({anim:b,weight:I}),n+=I}});if(n===0)return;i.forEach(y=>y.weight/=n);const a=new Map,r=y=>{let b=y.startsWith("#")?y.substring(1):y;return b.length===3&&(b=[b[0],b[0],b[1],b[1],b[2],b[2]].join("")),b="0x"+b,{r:b>>16&255,g:b>>8&255,b:b&255,a:1}};i.forEach(({anim:y,weight:b})=>{y.tracks&&y.tracks.forEach(v=>{var O,_;const S=v.object_id||v.objectId,C=v.property,w=(O=this.artboard)==null?void 0:O.objects.find(P=>P.id===S);if(((_=w==null?void 0:w.physics)==null?void 0:_.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 k=a.get(S);k||(k=new Map,a.set(S,k));let T=k.get(C);if(!T){if(typeof I=="number")T={type:"number",value:0};else if(typeof I=="string"&&I.startsWith("#"))T={type:"color",value:I,colorAcc:{r:0,g:0,b:0,a:0}};else if(T={type:"number",value:I},b<.5)return;k.set(C,T)}if(T.type==="number"&&typeof I=="number")T.value+=I*b;else if(T.type==="color"&&typeof I=="string"&&T.colorAcc){const P=r(I);P&&(T.colorAcc.r+=P.r*b,T.colorAcc.g+=P.g*b,T.colorAcc.b+=P.b*b,T.colorAcc.a+=P.a*b)}else b>.5&&(T.value=I)})}),a.forEach((y,b)=>{var C;const v=this.objectStates.get(b),S=(C=this.artboard)==null?void 0:C.objects.find(w=>w.id===b);!v||!S||y.forEach((w,M)=>{let I=w.value;if(w.type==="color"&&w.colorAcc){const k=Math.round(w.colorAcc.r).toString(16).padStart(2,"0"),T=Math.round(w.colorAcc.g).toString(16).padStart(2,"0"),O=Math.round(w.colorAcc.b).toString(16).padStart(2,"0");I=`#${k}${T}${O}`}if(M.includes(".")||M.includes("[")){const k=(M||"").replace(/\[(\d+)\]/g,".$1").split(".");let T=v;for(let O=0;O<k.length-1;O++){if(typeof T[k[O]]!="object"||T[k[O]]===null){let _=S;for(let P=0;P<=O;P++)_=_?_[k[P]]:null;if(k[O]==="corner_radius"||k[O]==="cornerRadius"){const P=typeof T[k[O]]=="number"?T[k[O]]:typeof _=="number"?_:0;T[k[O]]={tl:P,tr:P,bl:P,br:P}}else{const P=k[O+1],E=!isNaN(Number(P));T[k[O]]=_?JSON.parse(JSON.stringify(_)):E?[]:{}}}T=T[k[O]]}T[k[k.length-1]]=I,k[k.length-1]==="color"&&(k[k.length-2]==="fill"||k[k.length-2]==="stroke")&&(T.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 h,u,c;const i=e.object_id||e.objectId;if(o){if(Array.isArray(o)){if(!o.includes(i))return}else if(i!==o)return}const n=(h=this.artboard)==null?void 0:h.objects.find(d=>d.id===i),a=((u=n==null?void 0:n.physics)==null?void 0:u.enabled)&&n.physics.bodyType!=="Static";let r=e.property;if(a&&(r==="x"||r==="y"||r==="rotation"))return;const l=this.objectStates.get(i);if(!l){this.frameCount%600===0&&this.debugLog(`Skipping track: Object ${i} not found in state`);return}const f=this.interpolate(e.keyframes,s);if(f!==void 0){if(this.frameCount%240===0){const d=(n==null?void 0:n.name)||i,p=typeof f=="object"?JSON.stringify(f).slice(0,50):f;this.debugLog(`[Anim] Applying ${r} = ${p} to ${d}`)}if(r.includes(".")||r.includes("[")){const d=(r||"").replace(/\[(\d+)\]/g,".$1").split(".");let p=l;for(let g=0;g<d.length-1;g++){if(typeof p[d[g]]!="object"||p[d[g]]===null){let y=n;for(let b=0;b<=g;b++)y=y?y[d[b]]:null;if(d[g]==="corner_radius"||d[g]==="cornerRadius"){const b=typeof p[d[g]]=="number"?p[d[g]]:typeof y=="number"?y:0;p[d[g]]={tl:b,tr:b,bl:b,br:b}}else{const b=d[g+1],v=!isNaN(Number(b));p[d[g]]=y?JSON.parse(JSON.stringify(y)):v?[]:{}}}p=p[d[g]]}p[d[d.length-1]]=f,d[d.length-1]==="color"&&(d[d.length-2]==="fill"||d[d.length-2]==="stroke")&&(p.type="Solid")}else r==="fill"?(l.style||(l.style={}),l.style.fill=f):r==="stroke"?(l.style||(l.style={}),l.style.stroke=f):l[r]=f;if(this.physicsEngine&&((c=n==null?void 0:n.physics)!=null&&c.enabled)&&n.physics.bodyType==="Static")if(r==="x"){const d=this.physicsEngine.getPosition(i);d&&this.physicsEngine.setPosition(i,f,d.y)}else if(r==="y"){const d=this.physicsEngine.getPosition(i);d&&this.physicsEngine.setPosition(i,d.x,f)}else r==="rotation"&&this.physicsEngine.setRotation(i,f*(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 i=e.time-o.time;let n=(s-o.time)/i;return o.easing&&(n=si(o.easing)(n)),this.interpolateValue(o.value,e.value,n)}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),i=parseFloat(s);return!isNaN(e)&&!isNaN(i)?Math.round(e+(i-e)*o).toString():o<.5?t:s}if(Array.isArray(t)&&Array.isArray(s))return t.length===s.length?t.map((e,i)=>this.interpolateValue(e,s[i],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(n=>{e[n]=this.interpolateValue(t[n],s[n],o)}),e}return typeof t=="number"&&typeof s=="number"?t+(s-t)*o:o<.5?t:s}interpolateColor(t,s,o){var d,p;const e=((p=(d=this.artboard)==null?void 0:d.tokens)==null?void 0:p.colors)||{},i=e[t]||t,n=e[s]||s,a=g=>{if(!g)return{r:0,g:0,b:0};const y=g.startsWith("#")?g.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(i),l=a(n),f=Math.round(r.r+(l.r-r.r)*o),h=Math.round(r.g+(l.g-r.g)*o),u=Math.round(r.b+(l.b-r.b)*o),c=g=>{const y=Math.max(0,Math.min(255,g)).toString(16);return y.length===1?"0"+y:y};return`#${c(f)}${c(h)}${c(u)}`}interpolateStops(t,s,o){return!t||!s||t.length!==s.length?o<.5?t:s:t.map((e,i)=>{const n=s[i];return{offset:e.offset+(n.offset-e.offset)*o,color:this.interpolateColor(e.color,n.color,o),opacity:(e.opacity??1)+((n.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 h;this.debug_objectsTotal=((h=this.artboard)==null?void 0:h.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 i=this.artboard.width,n=this.artboard.height,a=this.calculateTransform(s,o,i,n,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,i,n)),this.artboard.backgroundImage){const u=this.artboard.backgroundImage;let c=this.imageCache.get(u);if(c||(c=new Image,c.src=u,this.imageCache.set(u,c)),c.complete&&c.naturalWidth>0){t.save(),t.globalAlpha=this.normalizeOpacity(this.artboard.backgroundOpacity??100);const d=c.naturalWidth/c.naturalHeight,p=i/n;let g,y,b,v;p>d?(g=i,y=i/d):(y=n,g=n*d),b=(i-g)/2,v=(n-y)/2,t.drawImage(c,b,v,g,y),t.restore()}}(this.artboard.clipContent===!0||this.artboard.clip_content===!0)&&(t.beginPath(),t.rect(0,0,i,n),t.clip());const l=new Map;this.artboard.objects.forEach(u=>l.set(u.id,u)),this.artboard.objects.filter(u=>!u.parentId).map((u,c)=>{const d=this.objectStates.get(u.id),p=(d==null?void 0:d.zIndex)??c;return{obj:u,zIndex:p}}).sort((u,c)=>u.zIndex-c.zIndex).forEach(({obj:u})=>{this.renderObject(t,u,l)}),this._emitterPools.forEach((u,c)=>{if(!(u.length===0||!l.get(c)))for(const p of u)t.save(),t.globalAlpha=p.opacity,t.fillStyle=p.color,t.beginPath(),t.arc(p.x,p.y,Math.max(1,p.size*p.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,i,n=0){const a=t.getTransform(),r=s*a.a+o*a.c+a.e,l=s*a.b+o*a.d+a.f,f=Math.sqrt(a.a*a.a+a.b*a.b),h=Math.sqrt(a.c*a.c+a.d*a.d),u=(e/2+n)*f,c=(i/2+n)*h;return r+u>=0&&r-u<=this.canvasWidth&&l+c>=0&&l-c<=this.canvasHeight}calculateTransform(t,s,o,e,i,n){let a=1,r=1,l=1;const f=o/e,h=t/s;switch(i){case"Contain":h>f?l=s/e:l=t/o,a=r=l;break;case"Cover":h>f?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 u=o*a,c=e*r;let d=0,p=0;return n.includes("Left")?d=0:n.includes("Right")?d=t-u:d=(t-u)/2,n.includes("Top")?p=0:n.includes("Bottom")?p=s-c:p=(s-c)/2,{scaleX:a,scaleY:r,tx:d,ty:p}}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,i,n){t.beginPath();const a=Math.max(1,n/14);let r=e;s==="underline"?r=e+n*.12:s==="line-through"&&(r=e-n*.3),t.lineWidth=a,t.strokeStyle=t.fillStyle,t.moveTo(o-i/2,r),t.lineTo(o+i/2,r),t.stroke()}renderObject(t,s,o,e=!1,i=!1){var v,S,C,w,M,I,k,T,O,_,P,E,A,B,D,W,X,H,Q,L,R,et,U,lt,x,F,N,st;const n=this.objectStates.get(s.id);if(!n){this.warn("No state for object:",s.id);return}this.frameCount%60,t.roundRect||(t.roundRect=(z,gt,mt,ut,wt)=>(this.drawRoundRect(t,z,gt,mt,ut,wt),t));const a=n.geometry?this.deepMerge(s.geometry,n.geometry):s.geometry;let r=n.style?this.deepMerge(s.style,n.style):s.style,l=(a==null?void 0:a.width)||((v=s.geometry)==null?void 0:v.width)||s.width||0,f=(a==null?void 0:a.height)||((S=s.geometry)==null?void 0:S.height)||s.height||0;if((l===0||f===0)&&(a!=null&&a.points)&&Array.isArray(a.points)&&a.points.length>0){let z=1/0,gt=-1/0,mt=1/0,ut=-1/0;a.points.forEach(wt=>{z=Math.min(z,wt.x),gt=Math.max(gt,wt.x),mt=Math.min(mt,wt.y),ut=Math.max(ut,wt.y)}),l===0&&(l=gt-z),f===0&&(f=ut-mt)}const h=z=>{if(z)return z.corner_radius??z.cornerRadius},u=h(n)??h(r)??h(a)??h(s.style)??h(s.geometry)??0;let c={...a,width:l,height:f};if(delete c.cornerRadius,c.corner_radius=u,!c.type&&(s.type==="Frame"||s.type==="Component"||s.type==="Group")&&(c.type="Rectangle"),c.type==="Path"&&s.weights&&s.bindMatrices&&c.points){const z=this.getGlobalTransform(s.id);if(z){const gt=ii(c.points,s.weights,s.bindMatrices,z,mt=>this.getGlobalTransform(mt));c={...c,points:gt}}}if(n.visible===!1)return;const p=(r.effects||((C=s.style)==null?void 0:C.effects)||[]).find(z=>z.isEnabled!==!1&&z.type==="PathDistortion");if(p){const z=oi(c,l,f,p.amplitude||5,p.frequency||10,p.seed||0,p.direction||0,p.directionStrength||0);c={...c,type:"Path",points:z}}const g=s.repeaterConfig,y=g&&g.isEnabled&&g.count>1,b=y?g.count:1;for(let z=0;z<b;z++){let gt=n.x!==void 0?n.x:((w=n.transform)==null?void 0:w.x)??0,mt=n.y!==void 0?n.y:((M=n.transform)==null?void 0:M.y)??0,ut=n.rotation!==void 0?n.rotation:((I=n.transform)==null?void 0:I.rotation)??0,wt=n.scale_x!==void 0?n.scale_x:((k=n.transform)==null?void 0:k.scale_x)??1,Mt=n.scale_y!==void 0?n.scale_y:((T=n.transform)==null?void 0:T.scale_y)??1;if(y&&z>0){if(g.type==="Linear"){const ot=g.offsetX||0,ft=g.offsetY||0,it=g.rotation||0,G=g.scale!==void 0?g.scale:1;gt+=z*ot,mt+=z*ft,ut+=z*it,wt*=Math.pow(G,z),Mt*=Math.pow(G,z)}else if(g.type==="Grid"){const ot=g.cols||Math.ceil(Math.sqrt(g.count)),ft=g.gapX||0,it=g.gapY||0,G=Math.floor(z/ot),at=z%ot,V=l+ft,dt=f+it;gt+=at*V,mt+=G*dt}else if(g.type==="Radial"){const ot=g.radius||100,ft=g.startAngle||0,G=(g.endAngle||360)-ft,at=g.count>1?G/(G===360?g.count:g.count-1):0,V=ft+z*at,dt=V*Math.PI/180;gt=n.x+ot*Math.cos(dt),mt=n.y+ot*Math.sin(dt),ut+=V}}const Et=s.type==="Group"||s.type==="Frame"||s.type==="Component",Ut=l>0&&f>0;if(!Et&&Ut&&!e){const ot=(((O=r.shadow)==null?void 0:O.isEnabled)!==!1?(((_=r.shadow)==null?void 0:_.blur)||0)+10:0)+(((P=r.blur)==null?void 0:P.isEnabled)!==!1&&((E=r.blur)==null?void 0:E.radius)||0)+20;if(!this.isObjectInView(t,gt,mt,l,f,ot))continue}this.debug_objectsRendered++,t.save();const re=[],he=r.blur||((A=s.style)==null?void 0:A.blur);he&&he.amount>0&&re.push(`blur(${he.amount}px)`);const nt=r.effects||((B=s.style)==null?void 0:B.effects)||[];let yt=nt.find(ot=>ot.isEnabled!==!1&&(ot.type==="BackgroundBlur"||ot.type==="LayerBlur"));yt||(yt=r.effect||((D=s.style)==null?void 0:D.effect)||nt.find(ot=>ot.isEnabled!==!1));const Tt=yt,_t=(Tt==null?void 0:Tt.isEnabled)!==!1,St=Tt==null?void 0:Tt.type,Ft=(Tt==null?void 0:Tt.radius)??10;_t&&St==="LayerBlur"?re.push(`blur(${Ft}px)`):_t&&St==="BackgroundBlur"&&(r===s.style&&(r={...r}),r.fill={type:"None"});const Gt=((W=a==null?void 0:a.type)==null?void 0:W.toLowerCase().includes("image"))||((X=s.type)==null?void 0:X.toLowerCase().includes("image")),Bt=r.adjustments&&Object.keys(r.adjustments).length>0?r.adjustments:null,Wt=a!=null&&a.adjustments&&Object.keys(a.adjustments).length>0?a.adjustments:null,Jt=Gt?Wt||Bt:Bt||Wt,Yt=Gt&&!Jt?{exposure:0,contrast:0,saturation:100,temperature:0,tint:0,highlights:0,shadows:0,blur:0,negative:0,hue:0}:Jt;if(n&&Yt&&(n.geometry=n.geometry||{},n.geometry.adjustments={...Yt}),Yt){const ot=(Yt.exposure||0)/100,ft=Yt.contrast||0,it=1+(Yt.saturation||0)/100,G=(Yt.temperature||0)/200,at=(Yt.tint||0)/200,V=(Yt.highlights||0)/500,dt=(Yt.shadows||0)/500;let vt="",Pt="SourceGraphic";if(ot!==0&&(vt+=`
8
- <feComponentTransfer in="${Pt}" result="exposure">
1
+ (function(Nt,Dt){typeof exports=="object"&&typeof module<"u"?Dt(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"],Dt):(Nt=typeof globalThis<"u"?globalThis:Nt||self,Dt(Nt.ExodeUIReact={},Nt.jsxRuntime,Nt.React,Nt.pretext,Nt.Rapier,Nt.LZString))})(this,(function(Nt,Dt,Lt,Ge,jt,bs){"use strict";var fi=Object.defineProperty;var hi=(Nt,Dt,Lt)=>Dt in Nt?fi(Nt,Dt,{enumerable:!0,configurable:!0,writable:!0,value:Lt}):Nt[Dt]=Lt;var rt=(Nt,Dt,Lt)=>hi(Nt,typeof Dt!="symbol"?Dt+"":Dt,Lt);function vs(m){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(m){for(const s in m)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(m,s);Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:()=>m[s]})}}return t.default=m,Object.freeze(t)}const Ss=vs(bs);var V=(m=>(m.Proximity="Proximity",m.Magnetic="Magnetic",m.Repel="Repel",m.Orbit="Orbit",m.Vortex="Vortex",m.Fluid="Fluid",m.Elastic="Elastic",m.Holographic="Holographic",m.Sticky="Sticky",m.Dilation="Dilation",m.Parallax="Parallax",m.Noise="Noise",m.Float="Float",m.Pulse="Pulse",m.Draggable="Draggable",m.Scroll="Scroll",m.LookAt="LookAt",m.Glint="Glint",m.Scan="Scan",m.Ratchet="Ratchet",m.Jitter="Jitter",m.Follower="Follower",m.Wrap="Wrap",m.Typewriter="Typewriter",m.Scramble="Scramble",m.Wave="Wave",m.Bounce="Bounce",m.TextTrail="TextTrail",m.Reveal3D="Reveal3D",m.RevealSlide="RevealSlide",m.RevealBlur="RevealBlur",m.TextLiquid="TextLiquid",m.TextVortex="TextVortex",m.TextExplosion="TextExplosion",m.TextRain="TextRain",m.TextGravity="TextGravity",m.TextMatrix="TextMatrix",m.TextNeon="TextNeon",m.TextDissolve="TextDissolve",m.TextOrganic="TextOrganic",m.TextBreathe="TextBreathe",m.TextSpin="TextSpin",m.TextMagnet="TextMagnet",m.TextPerspective="TextPerspective",m.TextMirror="TextMirror",m.TextFloral="TextFloral",m.TextSmoke="TextSmoke",m.TextVariable="TextVariable",m.TextZing="TextZing",m.TextElastic="TextElastic",m.TextGlitch3D="TextGlitch3D",m.GlitchText="GlitchText",m.TextCounter="TextCounter",m.Squash="Squash",m.Spotlight="Spotlight",m.Lens="Lens",m.Gravity="Gravity",m.Velocity="Velocity",m.Shear="Shear",m.LayoutAnimation="LayoutAnimation",m.SpringChain="SpringChain",m.ParticleEmitter="ParticleEmitter",m.StateReactive="StateReactive",m.Fold="Fold",m.Crumple="Crumple",m))(V||{}),te=(m=>(m.Scale="Scale",m.Opacity="Opacity",m.RotateZ="RotateZ",m.RotateX="RotateX",m.RotateY="RotateY",m.PositionX="PositionX",m.PositionY="PositionY",m.SkewX="SkewX",m.Blur="Blur",m.Exposure="Exposure",m.HueShift="HueShift",m.Negative="Negative",m.CornerRadius="CornerRadius",m.StrokeWidth="StrokeWidth",m.BoxShadow="BoxShadow",m.FontSize="FontSize",m.LetterSpacing="LetterSpacing",m))(te||{}),je=(m=>(m.Equal="Equal",m.NotEqual="NotEqual",m.GreaterThan="GreaterThan",m.LessThan="LessThan",m.GreaterEqual="GreaterEqual",m.LessEqual="LessEqual",m.IsTrue="IsTrue",m.IsFalse="IsFalse",m))(je||{}),Ct=(m=>(m.AND="AND",m.OR="OR",m.NOT="NOT",m.XOR="XOR",m.OBJECT="OBJECT",m.PROPERTY="PROPERTY",m.GET_PROPERTY="GET_PROPERTY",m.SET_PROPERTY="SET_PROPERTY",m.ADD="ADD",m.SUB="SUB",m.MUL="MUL",m.DIV="DIV",m.MOD="MOD",m.POW="POW",m.ABS="ABS",m.ROUND="ROUND",m.FLOOR="FLOOR",m.CEIL="CEIL",m.SIN="SIN",m.COS="COS",m.TAN="TAN",m.CLAMP="CLAMP",m.REMAP="REMAP",m.EQ="EQ",m.NEQ="NEQ",m.GT="GT",m.LT="LT",m.GTE="GTE",m.LTE="LTE",m.IF_ELSE="IF_ELSE",m.VALUE="VALUE",m.INPUT="INPUT",m.LOG="LOG",m.SCROLL_X="SCROLL_X",m.SCROLL_Y="SCROLL_Y",m.MOUSE_X="MOUSE_X",m.MOUSE_Y="MOUSE_Y",m.IS_MOUSE_DOWN="IS_MOUSE_DOWN",m.EFFECTOR="EFFECTOR",m.MONITOR="MONITOR",m.DELAY="DELAY",m.SPRING_PULL="SPRING_PULL",m.SPRING_SETTLE="SPRING_SETTLE",m.EMIT="EMIT",m))(Ct||{});function Cs(m){if(m.length<5)return m;const t=new Set("aeiouyAEIOUY".split(""));if(/[\u4E00-\u9FFF\u3400-\u4DBF]/.test(m))return m;let o="";for(let e=0;e<m.length;e++){if(o+=m[e],e>=m.length-2)continue;const i=t.has(m[e]),n=t.has(m[e+1]),a=t.has(m[e+2]);i&&!n&&a&&(o+="­"),i&&!n&&!a&&e>=1&&(o+="­")}return o}function ws(m){return m.replace(/\b([a-zA-Z]{4,})\b/g,(t,s)=>Cs(s))}function Ms(m,t,s){return m}function Is(m,t,s){return m}const Be=new Map;function ts(m){var I;const{text:t,fontFamily:s="Inter",fontSize:o=16,fontWeight:e=400,fontStyle:i="normal",lineHeight:n=1.2,width:a=200,letterSpacing:r=0,paragraphSpacing:l=0,paragraphIndent:h=0,textCase:f="none",segments:p=[],enableSegments:c=!1}=m;let d=String(t||"");f==="uppercase"?d=d.toUpperCase():f==="lowercase"?d=d.toLowerCase():f==="capitalize"&&(d=d.replace(/\b\w/g,k=>k.toUpperCase())),m.hyphenation===!0&&(d=ws(d));const u=`${i} ${e} ${o}px "${s}", sans-serif`,g=`${d}|${u}|${r}|${l}|${h}|${c}|${JSON.stringify(p)}|hyp:${!!m.hyphenation}|comp:${m.composer}|bal:${!!m.balanceRaggedLines}`;let y=Be.get(g);const b=typeof CanvasRenderingContext2D<"u"?CanvasRenderingContext2D.prototype.measureText:null,v=function(k){if(!b)return{width:0,fontBoundingBoxAscent:0,fontBoundingBoxDescent:0};const P=b.call(this,k);return r!==0&&k&&k.length>0?{...P,width:P.width+(k.length-1)*r}:P};if(!y){try{if(r!==0&&typeof CanvasRenderingContext2D<"u"&&(CanvasRenderingContext2D.prototype.measureText=v),c&&p&&p.length>0){const k=p.map(P=>{let E=P.text||"";const _=P.textCase||f||"none";return _==="uppercase"?E.toUpperCase():_==="lowercase"?E.toLowerCase():_==="capitalize"?E.replace(/\b\w/g,T=>T.toUpperCase()):E}).join("");if(y=Ge.prepareWithSegments(k,u),y){let P=0,E=o;for(const _ of p){let T=_.text||"";if(!T)continue;const A=_.textCase||f||"none";A==="uppercase"?T=T.toUpperCase():A==="lowercase"?T=T.toLowerCase():A==="capitalize"&&(T=T.replace(/\b\w/g,$=>$.toUpperCase()));const L=_.fontSize||o;L>E&&(E=L);const X=`${_.fontStyle||i} ${_.fontWeight||e} ${L}px "${_.fontFamily||s}", sans-serif`,D=Ge.prepareWithSegments(T,X);if(D&&D.widths)for(let $=0;$<D.widths.length;$++){const G=P+$;if(G<y.widths.length){y.widths[G]=D.widths[$];const H=D.kinds[$];if(H===2){const et=T[$];et===`
2
+ `||et==="\r"?y.kinds[G]=2:y.kinds[G]=0}else y.kinds[G]=H}}P+=T.length}y.fullText=k,y.maxFontSize=E}}else y=Ge.prepareWithSegments(d,u);y&&Be.set(g,y)}catch(k){return console.error("[ExodeUI] Pretext prepare failed:",k),{width:a,height:0,lineCount:0,lines:[]}}finally{r!==0&&typeof CanvasRenderingContext2D<"u"&&b&&(CanvasRenderingContext2D.prototype.measureText=b)}if(Be.size>500){const k=Be.keys().next().value;k&&Be.delete(k)}}if(h>0&&y&&y.widths&&!y.indentApplied){const k=[...y.widths],P=y.fullText||d;let E=!0;for(let _=0;_<P.length;_++)E&&k[_]!==void 0&&(k[_]+=h,E=!1),(P[_]===`
3
+ `||P[_]==="\r")&&(E=!0,P[_]==="\r"&&P[_+1]===`
4
+ `&&_++);y={...y,widths:k,indentApplied:!0}}if(!y)return{width:a,height:0,lineCount:0,lines:[]};let S=n;typeof S=="string"&&(S=parseFloat(S)),S>5&&o>0&&(S=S/o),r!==0&&(CanvasRenderingContext2D.prototype.measureText=v);let C;try{const k=y.maxFontSize||o;if(a>=1e5){const P=d.split(/\r\n|\r|\n/);C={lines:P.map(E=>({text:E,width:0})),height:P.length*(S*k),lineCount:P.length}}else C=Ge.layoutWithLines(y,a,S*k)}finally{r!==0&&b&&(CanvasRenderingContext2D.prototype.measureText=b)}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)*S*o;if(l>0&&C&&C.lines&&C.lines.length>1){let k=0;const P=y.fullText||t;for(let E=0;E<C.lines.length-1;E++)k+=C.lines[E].text.length,(P[k]===`
5
+ `||P[k]==="\r")&&(w+=l,k++,P[k-1]==="\r"&&P[k]===`
6
+ `&&k++)}let M=(C==null?void 0:C.lines)||[];return m.composer==="every-line"&&M.length>1&&(M=Ms(M)),m.balanceRaggedLines===!0&&M.length>1&&(M=Is(M)),{width:a,height:w,lineCount:M.length,lines:M}}function es(m,t,s){let o=String(m||"").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),i=new Array(e.length).fill(0);let n=t-(e.length-1)*s,a=0;if(e.forEach((r,l)=>{if(r.endsWith("px")){const h=parseFloat(r);i[l]=h,n-=h}else r.endsWith("fr")?a+=parseFloat(r):r==="auto"&&(i[l]=100,n-=100)}),a>0&&n>0){const r=n/a;e.forEach((l,h)=>{l.endsWith("fr")&&(i[h]=r*parseFloat(l))})}return i}function ss(m,t,s){try{const o=m.autoLayout;return!o||!o.enabled?{childUpdates:[]}:(o.mode||"linear")==="grid"?Ts(m,t,s):ks(m,t,s)}catch(o){return console.error("Layout Engine Error:",o),{childUpdates:[]}}}function ks(m,t,s){var T,A;const o=m.autoLayout,{direction:e,spacing:i,padding:n,align:a,wrap:r}=o,l=e==="vertical",h=t.map(L=>{const X=s(L.id),D=L.geometry;let $=(X==null?void 0:X.width)??D.width??100,G=(X==null?void 0:X.height)??D.height??100;if(D.type==="Ellipse"||D.type==="Polygon"||D.type==="Star"){const H=(X==null?void 0:X.radius)??D.radius??(X==null?void 0:X.outer_radius)??D.outer_radius??50;$=H*2,G=H*2}else if(D.type==="Text"){const H=ts({text:(X==null?void 0:X.text)??D.text??"",fontFamily:D.fontFamily,fontSize:D.fontSize,fontWeight:D.fontWeight,fontStyle:D.fontStyle,lineHeight:D.lineHeight,width:D.width||200,letterSpacing:D.letterSpacing,paragraphSpacing:D.paragraphSpacing,paragraphIndent:D.paragraphIndent,textCase:D.textCase,segments:D.segments,enableSegments:D.enableSegments});G=H.height,D.width||($=H.width)}return $*=L.transform.scale_x||1,G*=L.transform.scale_y||1,{id:L.id,w:$,h:G,original:L}});let f=m.width,p=m.height;const c=((T=m.layoutProps)==null?void 0:T.width)==="hug",d=((A=m.layoutProps)==null?void 0:A.height)==="hug",u=[];let g=[],y=0,b=0;const v=f-n.left-n.right,S=p-n.top-n.bottom;h.forEach(L=>{r&&g.length>0&&(l?b+i+L.h>S:y+i+L.w>v)?(u.push({children:g,width:y,height:b}),g=[L],y=L.w,b=L.h):(g.push(L),l?(y=Math.max(y,L.w),b+=(g.length>1?i:0)+L.h):(y+=(g.length>1?i:0)+L.w,b=Math.max(b,L.h)))}),g.length>0&&u.push({children:g,width:y,height:b}),c&&!l&&(f=Math.max(...u.map(L=>L.width),0)+n.left+n.right),d&&l&&(p=Math.max(...u.map(L=>L.height),0)+n.top+n.bottom);const C=[];let w=n.left,M=n.top;const I=a.toLowerCase(),k=I==="center"||I.endsWith("-center"),P=I.endsWith("-right"),E=I==="center"||I.startsWith("center-"),_=I.startsWith("bottom-");return u.forEach(L=>{let X=w,D=M;l?E?D=n.top+(p-n.top-n.bottom-L.height)/2:_&&(D=p-n.bottom-L.height):k?X=n.left+(f-n.left-n.right-L.width)/2:P&&(X=f-n.right-L.width),L.children.forEach($=>{var x,st;let G=X,H=D;l?k?G+=(L.width-$.w)/2:P&&(G+=L.width-$.w):E?H+=(L.height-$.h)/2:_&&(H+=L.height-$.h);const et=((x=$.original.layoutProps)==null?void 0:x.width)==="fill",O=((st=$.original.layoutProps)==null?void 0:st.height)==="fill";C.push({id:$.id,x:G+$.w/2-f/2,y:H+$.h/2-p/2,width:et&&l?L.width:void 0,height:O?l?void 0:L.height:void 0}),l?D+=$.h+i:X+=$.w+i}),l?w+=L.width+i:M+=L.height+i}),{frameWidth:c?f:void 0,frameHeight:d?p:void 0,childUpdates:C}}function Ts(m,t,s){const o=m.autoLayout;if(!o)return{childUpdates:[]};const{gridColumns:e,gridRows:i,columnGap:n=0,rowGap:a=0,padding:r,align:l}=o;let h=m.width,f=m.height;const p=h-r.left-r.right,c=f-r.top-r.bottom,d=es(e||"1fr",p,n),u=es(i||"auto",c,a),g=d.length>0?d.reduce((P,E)=>P+E,0)+(d.length-1)*n:0,y=u.length>0?u.reduce((P,E)=>P+E,0)+(u.length-1)*a:0,b=l.toLowerCase(),v=b==="center"||b.endsWith("-center"),S=b.endsWith("-right"),C=b==="center"||b.startsWith("center-"),w=b.startsWith("bottom-");let M=0,I=0;v?M=(p-g)/2:S&&(M=p-g),C?I=(c-y)/2:w&&(I=c-y);const k=[];return t.forEach((P,E)=>{var st,Q;const _=E%d.length||0,T=Math.floor(E/d.length)||0;T>=u.length&&u.push(100);const A=d[_],L=u[T];let X=r.left+M+d.slice(0,_).reduce((lt,F)=>lt+F+n,0),D=r.top+I+u.slice(0,T).reduce((lt,F)=>lt+F+a,0);const $=s(P.id),G=P.geometry;let H=($==null?void 0:$.width)??G.width??100,et=($==null?void 0:$.height)??G.height??100;if(G.type==="Ellipse"||G.type==="Polygon"||G.type==="Star"){const lt=($==null?void 0:$.radius)??G.radius??($==null?void 0:$.outer_radius)??G.outer_radius??50;H=lt*2,et=lt*2}H*=P.transform.scale_x||1,et*=P.transform.scale_y||1;let O=X,x=D;v?O+=(A-H)/2:S&&(O+=A-H),C?x+=(L-et)/2:w&&(x+=L-et),k.push({id:P.id,x:O+H/2-h/2,y:x+et/2-f/2,width:((st=P.layoutProps)==null?void 0:st.width)==="fill"?A:void 0,height:((Q=P.layoutProps)==null?void 0:Q.height)==="fill"?L:void 0})}),{childUpdates:k}}class is{constructor(){rt(this,"world",null);rt(this,"bodies",new Map);rt(this,"colliders",new Map);rt(this,"joints",new Map);rt(this,"initialized",!1);rt(this,"bodyIdByCollider",new Map);rt(this,"onCollisionCB",null);rt(this,"eventQueue",null)}setCollisionCallback(t){this.onCollisionCB=t}async init(t){this.initialized||(await jt.init(),this.world=new jt.World(new jt.Vector2(t.x*100,t.y*100)),this.eventQueue=new jt.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 jt.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?jt.RigidBodyDesc.fixed():jt.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=jt.ColliderDesc.cuboid(t.width/2,t.height/2);break;case"Ellipse":e=jt.ColliderDesc.ball(Math.max(t.width,t.height)/2);break;case"Triangle":case"Star":case"Polygon":e=jt.ColliderDesc.cuboid(t.width/2,t.height/2);break;default:e=jt.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 n=t.width*t.height;e.setDensity(t.mass/n)}t.isSensor&&e.setSensor(!0);const i=this.world.createCollider(e,o);this.bodyIdByCollider.set(i.handle,t.id),t.frictionAir!==void 0&&o.setLinearDamping(t.frictionAir*10),this.bodies.set(t.id,o),this.colliders.set(t.id,i)}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,i,n)=>{const a=this.bodyIdByCollider.get(e),r=this.bodyIdByCollider.get(i);a&&r&&s(a,r,n)})}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 jt.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 jt.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 jt.Vector2(s,o),!0)}applyImpulse(t,s,o){const e=this.bodies.get(t);e&&e.applyImpulse(new jt.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 jt.Vector2(t.anchorA.x,t.anchorA.y),i=new jt.Vector2(t.anchorB.x,t.anchorB.y);let n;if(t.type==="Distance"){const a=t.length??100,r=t.stiffness??100,l=t.damping??10;n=jt.JointData.spring(a,r,l,e,i)}else n=jt.JointData.revolute(e,i);try{const a=this.world.createImpulseJoint(n,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 ns=m=>m,Ps=m=>m>0?1:0,_s=m=>m<1?0:1,os=m=>m*m,as=m=>m*(2-m),rs=m=>m<.5?2*m*m:-1+(4-2*m)*m,Es=m=>m*m*m,As=m=>--m*m*m+1,Os=m=>m<.5?4*m*m*m:(m-1)*(2*m-2)*(2*m-2)+1,Ls=m=>m*m*m*m,xs=m=>1- --m*m*m*m,Rs=m=>m<.5?8*m*m*m*m:1-8*--m*m*m*m,Fs=m=>m*m*m*m*m,$s=m=>1+--m*m*m*m*m,Bs=m=>m<.5?16*m*m*m*m*m:1+16*--m*m*m*m*m,Ws=m=>1-Math.cos(m*Math.PI/2),Ys=m=>Math.sin(m*Math.PI/2),Xs=m=>-(Math.cos(Math.PI*m)-1)/2,Ds=m=>m===0?0:Math.pow(2,10*(m-1)),Gs=m=>m===1?1:1-Math.pow(2,-10*m),Ns=m=>m===0?0:m===1?1:m<.5?Math.pow(2,20*m-10)/2:(2-Math.pow(2,-20*m+10))/2,zs=m=>1-Math.sqrt(1-m*m),Vs=m=>Math.sqrt(1- --m*m),Hs=m=>m<.5?(1-Math.sqrt(1-4*m*m))/2:(Math.sqrt(1-(-2*m+2)*(-2*m+2))+1)/2,Ne=1.70158,ze=Ne*1.525,ls=Ne+1,Us=m=>ls*m*m*m-Ne*m*m,qs=m=>1+ls*Math.pow(m-1,3)+Ne*Math.pow(m-1,2),Ks=m=>m<.5?Math.pow(2*m,2)*((ze+1)*2*m-ze)/2:(Math.pow(2*m-2,2)*((ze+1)*(m*2-2)+ze)+2)/2,cs=2*Math.PI/3,fs=2*Math.PI/4.5,Js=m=>m===0?0:m===1?1:-Math.pow(2,10*m-10)*Math.sin((m*10-10.75)*cs),Qs=m=>m===0?0:m===1?1:Math.pow(2,-10*m)*Math.sin((m*10-.75)*cs)+1,Zs=m=>m===0?0:m===1?1:m<.5?-(Math.pow(2,20*m-10)*Math.sin((20*m-11.125)*fs))/2:Math.pow(2,-20*m+10)*Math.sin((20*m-11.125)*fs)/2+1,Ve=m=>m<1/2.75?7.5625*m*m:m<2/2.75?7.5625*(m-=1.5/2.75)*m+.75:m<2.5/2.75?7.5625*(m-=2.25/2.75)*m+.9375:7.5625*(m-=2.625/2.75)*m+.984375,js=m=>1-Ve(1-m),ti=Ve,ei=m=>m<.5?(1-Ve(1-2*m))/2:(1+Ve(2*m-1))/2,Ze=new Map,We=(m,t,s,o)=>{const e=`${m},${t},${s},${o}`;if(Ze.has(e))return Ze.get(e);const i=h=>(1-3*s+3*m)*h*h*h+(3*s-6*m)*h*h+3*m*h,n=h=>(1-3*o+3*t)*h*h*h+(3*o-6*t)*h*h+3*t*h,a=h=>3*(1-3*s+3*m)*h*h+2*(3*s-6*m)*h+3*m,r=h=>{let f=h;for(let p=0;p<8;p++){const c=i(f)-h;if(Math.abs(c)<1e-6)return f;const d=a(f);if(Math.abs(d)<1e-6)break;f=f-c/d}return f},l=h=>h===0?0:h===1?1:n(r(h));return Ze.set(e,l),l},hs=m=>{const t=m.match(/cubic-bezier\s*\(\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*\)/);if(!t)return null;const[,s,o,e,i]=t.map(Number);return We(s,o,e,i)},ds={ease:We(.25,.1,.25,1),"ease-in":We(.42,0,1,1),"ease-out":We(0,0,.58,1),"ease-in-out":We(.42,0,.58,1)},He={Linear:ns,EaseInQuad:os,EaseOutQuad:as,EaseInOutQuad:rs,EaseInCubic:Es,EaseOutCubic:As,EaseInOutCubic:Os,EaseInQuart:Ls,EaseOutQuart:xs,EaseInOutQuart:Rs,EaseInQuint:Fs,EaseOutQuint:$s,EaseInOutQuint:Bs,EaseInSine:Ws,EaseOutSine:Ys,EaseInOutSine:Xs,EaseInExpo:Ds,EaseOutExpo:Gs,EaseInOutExpo:Ns,EaseInCirc:zs,EaseOutCirc:Vs,EaseInOutCirc:Hs,EaseInBack:Us,EaseOutBack:qs,EaseInOutBack:Ks,EaseInElastic:Js,EaseOutElastic:Qs,EaseInOutElastic:Zs,EaseInBounce:js,EaseOutBounce:ti,EaseInOutBounce:ei,EaseIn:os,EaseOut:as,EaseInOut:rs,StepStart:Ps,StepEnd:_s},si=m=>{const t=m.trim(),s=t.toLowerCase();if(He[t])return He[t];const o=Object.keys(He).find(i=>i.toLowerCase()===s);if(o)return He[o];const e=Object.keys(ps).find(i=>i.toLowerCase()===s);if(e){const i=hs(ps[e].value);if(i)return i}if(ds[s])return ds[s];if(s.startsWith("cubic-bezier")){const i=hs(t);if(i)return i}return ns},ps={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)"}},ii=(m,t,s,o,e)=>{if(!m||!t||!s)return m;const i=o.scale_x??1,n=o.scale_y??1,a=(r,l,h)=>{let f=0,p=0;const c=o.rotation*Math.PI/180,d=Math.cos(c),u=Math.sin(c),g=r*i*d-l*n*u+o.x,y=r*i*u+l*n*d+o.y;h.forEach(I=>{const k=e(I.boneId);if(!k)return;const P={x:k.x,y:k.y,rotation:k.rotation,scaleX:k.scale_x??1,scaleY:k.scale_y??1},E=s[I.boneId]||[1,0,0,1,0,0],_=g*E[0]+y*E[2]+E[4],T=g*E[1]+y*E[3]+E[5],A=P.rotation*Math.PI/180,L=Math.cos(A),X=Math.sin(A),D=_*P.scaleX*L-T*P.scaleY*X+P.x,$=_*P.scaleX*X+T*P.scaleY*L+P.y;f+=D*I.amount,p+=$*I.amount});const b=[...h].sort((I,k)=>k.amount-I.amount);if(b.length>=2&&b[0].amount>0&&b[1].amount>0){const I=e(b[0].boneId),k=e(b[1].boneId);if(I&&k&&I.length!==void 0&&k.length!==void 0){const P=I.length*(I.scale_y??1),E=I.rotation*Math.PI/180,_=I.x-P*Math.sin(E),T=I.y+P*Math.cos(E),A=k.length*(k.scale_y??1),L=k.rotation*Math.PI/180,X=k.x-A*Math.sin(L),D=k.y+A*Math.cos(L);let $=null,G=null,H=!1;const et=1;if(Math.hypot(I.x-k.x,I.y-k.y)<et||Math.hypot(I.x-X,I.y-D)<et?($=I.x,G=I.y):(Math.hypot(_-k.x,T-k.y)<et||Math.hypot(_-X,T-D)<et)&&($=_,G=T,H=!0),$!==null&&G!==null){const O=s[b[0].boneId]||[1,0,0,1,0,0],x=O[0]*O[3]-O[1]*O[2];let st=0,Q=0;if(x!==0){const lt=(O[2]*O[5]-O[3]*O[4])/x,F=(O[1]*O[4]-O[0]*O[5])/x,W=Math.atan2(-O[1],O[3]);if(!H)st=lt,Q=F;else{const N=-O[2]/x,pt=O[0]/x,yt=Math.hypot(N,pt),dt=I.length*yt;st=lt-dt*Math.sin(W),Q=F+dt*Math.cos(W)}const z=Math.hypot(g-st,y-Q),nt=Math.hypot(f-$,p-G);if(nt>0&&z>0){const N=Math.max(nt,.01),pt=Math.min(z/N,3),yt=$+(f-$)*pt,dt=G+(p-G)*pt,wt=b[0].amount,Pt=b[1].amount,_t=Math.min(wt,Pt)*2,Ut=1-Math.pow(1-_t,4);f=f*(1-Ut)+yt*Ut,p=p*(1-Ut)+dt*Ut}}}}}const v=o.rotation*Math.PI/180,S=Math.cos(v),C=Math.sin(v),w=f-o.x,M=p-o.y;return{x:(w*S+M*C)/i,y:(-w*C+M*S)/n}};return m.map((r,l)=>{const h=t[l];if(!h||h.length===0)return{...r};const f={...r,...a(r.x,r.y,h)};if(r.in_x!==void 0&&r.in_y!==void 0){const p=a(r.in_x,r.in_y,h);f.in_x=p.x,f.in_y=p.y}if(r.out_x!==void 0&&r.out_y!==void 0){const p=a(r.out_x,r.out_y,h);f.out_x=p.x,f.out_y=p.y}return f})};function ni(m,t,s,o,e){const i=m*s*.01,n=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(i+a)*Math.cos(n+r)+.5*Math.sin(i*2.1-r)*Math.cos(n*2.3+a)+.25*Math.sin(i*4.5+a)*Math.cos(n*4.2-r))/1.75*o}function oi(m,t,s,o,e,i,n=0,a=0){const r=[];if(!m)return[];const l=m.type;if(l==="Rectangle"||l==="Image"||l==="Frame"){const d=Math.max(20,Math.floor((t+s)/10)),u=Math.max(2,Math.floor(d*(t/(t+s)))),g=Math.max(2,Math.floor(d*(s/(t+s))));for(let y=0;y<u;y++)r.push({x:-t/2+t/u*y,y:-s/2,nx:0,ny:-1});for(let y=0;y<g;y++)r.push({x:t/2,y:-s/2+s/g*y,nx:1,ny:0});for(let y=0;y<u;y++)r.push({x:t/2-t/u*y,y:s/2,nx:0,ny:1});for(let y=0;y<g;y++)r.push({x:-t/2,y:s/2-s/g*y,nx:-1,ny:0})}else if(l==="Ellipse"){const d=Math.max(60,Math.floor(Math.PI*Math.max(t,s)/5));for(let u=0;u<d;u++){const g=u/d*Math.PI*2,y=Math.cos(g),b=Math.sin(g);r.push({x:y*t/2,y:b*s/2,nx:y,ny:b})}}else if(l==="Triangle"){const d={x:0,y:-s/2},u={x:t/2,y:s/2},g={x:-t/2,y:s/2},y=20;let b=u.x-d.x,v=u.y-d.y,S=Math.hypot(b,v),C=-v/S,w=b/S;for(let M=0;M<y;M++)r.push({x:d.x+b*(M/y),y:d.y+v*(M/y),nx:C,ny:w});b=g.x-u.x,v=g.y-u.y,S=Math.hypot(b,v),C=-v/S,w=b/S;for(let M=0;M<y;M++)r.push({x:u.x+b*(M/y),y:u.y+v*(M/y),nx:C,ny:w});b=d.x-g.x,v=d.y-g.y,S=Math.hypot(b,v),C=-v/S,w=b/S;for(let M=0;M<y;M++)r.push({x:g.x+b*(M/y),y:g.y+v*(M/y),nx:C,ny:w})}else for(let u=0;u<80;u++){const g=u/80*Math.PI*2,y=Math.cos(g),b=Math.sin(g);r.push({x:y*t/2,y:b*s/2,nx:y,ny:b})}const h=n*Math.PI/180,f=Math.cos(h),p=Math.sin(h);return r.map(d=>{const u=ni(d.x,d.y,e,o,i),g=d.nx*(1-a)+f*a,y=d.ny*(1-a)+p*a;let b=Math.hypot(g,y);return b===0&&(b=1),{x:d.x+g/b*u,y:d.y+y/b*u}})}const us={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}},gs={default:{label:"Default",colors:["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399"],cardBackground:"rgba(255,255,255,0.04)",cardBorderColor:"rgba(255,255,255,0.08)",legendColor:"rgba(255,255,255,0.65)",labelColor:"#ffffff",centerTextColor:"#ffffff",centerLabelColor:"rgba(255,255,255,0.4)"},neon:{label:"Neon",colors:["#00f5ff","#ff00e5","#00ff9f","#ff6b00","#b400ff"],cardBackground:"rgba(0,0,0,0.55)",cardBorderColor:"rgba(0,245,255,0.2)",legendColor:"rgba(0,245,255,0.75)",labelColor:"#ffffff",centerTextColor:"#00f5ff",centerLabelColor:"rgba(0,245,255,0.5)"},pastel:{label:"Pastel",colors:["#a5b4fc","#67e8f9","#fcd34d","#f9a8d4","#6ee7b7"],cardBackground:"rgba(255,255,255,0.06)",cardBorderColor:"rgba(255,255,255,0.12)",legendColor:"rgba(255,255,255,0.6)",labelColor:"#1a1a2e",centerTextColor:"#ffffff",centerLabelColor:"rgba(255,255,255,0.45)"},warm:{label:"Warm",colors:["#f97316","#ef4444","#f59e0b","#dc2626","#fb923c"],cardBackground:"rgba(30,10,0,0.45)",cardBorderColor:"rgba(249,115,22,0.2)",legendColor:"rgba(253,186,116,0.8)",labelColor:"#ffffff",centerTextColor:"#fb923c",centerLabelColor:"rgba(253,186,116,0.5)"},ocean:{label:"Ocean",colors:["#06b6d4","#0ea5e9","#38bdf8","#7dd3fc","#0284c7"],cardBackground:"rgba(0,20,40,0.5)",cardBorderColor:"rgba(6,182,212,0.2)",legendColor:"rgba(125,211,252,0.75)",labelColor:"#ffffff",centerTextColor:"#38bdf8",centerLabelColor:"rgba(125,211,252,0.5)"},mono:{label:"Mono",colors:["rgba(255,255,255,0.9)","rgba(255,255,255,0.65)","rgba(255,255,255,0.45)","rgba(255,255,255,0.28)","rgba(255,255,255,0.15)"],cardBackground:"rgba(255,255,255,0.03)",cardBorderColor:"rgba(255,255,255,0.1)",legendColor:"rgba(255,255,255,0.55)",labelColor:"#000000",centerTextColor:"#ffffff",centerLabelColor:"rgba(255,255,255,0.4)"}};class ys{constructor(){rt(this,"artboard",null);rt(this,"objectStates",new Map);rt(this,"physicsEngine",null);rt(this,"activeStateMachine",null);rt(this,"inputs",new Map);rt(this,"inputNameMap",new Map);rt(this,"layerStates",new Map);rt(this,"pretextCache",new Map);rt(this,"pointerHistory",[]);rt(this,"MAX_HISTORY",200);rt(this,"imageCache",new Map);rt(this,"lastValidSvgImgMap",new Map);rt(this,"maskBuffer",null);rt(this,"maskCtx",null);rt(this,"lumaBuffer",null);rt(this,"lumaCtx",null);rt(this,"_noiseTileCanvas",null);rt(this,"layout",{fit:"Contain",alignment:"Center"});rt(this,"onTrigger");rt(this,"onInputUpdate");rt(this,"onComponentChange");rt(this,"onToggle");rt(this,"onInputChange");rt(this,"onInputFocus");rt(this,"onInputBlur");rt(this,"onLog");rt(this,"onButtonClick");rt(this,"onGraphPointClick");rt(this,"justFiredTriggers",new Set);rt(this,"rootTransform",null);rt(this,"canvasWidth",0);rt(this,"canvasHeight",0);rt(this,"lastHoveredObjectId",null);rt(this,"_lastPointerPos",null);rt(this,"_prevPointerPos",null);rt(this,"_mouseDelta",{dx:0,dy:0});rt(this,"focusedId",null);rt(this,"draggingSliderId",null);rt(this,"draggingJoystickId",null);rt(this,"activeDropdownId",null);rt(this,"activeObjectId",null);rt(this,"draggingListViewId",null);rt(this,"scrollOffset",{x:0,y:0});rt(this,"_totalScroll",{x:0,y:0});rt(this,"draggingBehaviors",new Set);rt(this,"isMouseDown",!1);rt(this,"activeKeys",new Set);rt(this,"_layoutAnimCache",new Map);rt(this,"_springChainState",new Map);rt(this,"_emitterPools",new Map);rt(this,"objectVelocities",new Map);rt(this,"currentTime",0);rt(this,"frameCount",0);rt(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});rt(this,"onLogicUpdate");rt(this,"logicNodeValues",new Map);rt(this,"logicNodeState",new Map);rt(this,"pointerDownTimes",new Map);rt(this,"activeHoverIds",new Set);rt(this,"onNavigation");rt(this,"periodicTriggerTimes",new Map);rt(this,"wasInView",new Set);rt(this,"scrollProgressLastValue",new Map);rt(this,"debug_objectsRendered",0);rt(this,"debug_objectsTotal",0);rt(this,"lastRenderTime",0);rt(this,"debugMode",!1);rt(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||t.type!=="Path"&&t.type!=="Subtract"&&t.type!=="Union"&&t.type!=="Intersect"&&t.type!=="Exclude"&&t.type!=="BooleanOperation")return;if(t.points&&t.points.length>0){if(t.is_closed===void 0&&t.isClosed===void 0&&t.data){const{isClosed:e}=this.svgPathToPoints(t.data);t.is_closed=e}return}if(!t.data)return;const{points:s,isClosed:o}=this.svgPathToPoints(t.data);t.points=s,t.is_closed===void 0&&(t.is_closed=o)}svgPathToPoints(t){const s=/([MLHVCSQTAZmlhvcsqtaz])([^MLHVCSQTAZmlhvcsqtaz]*)/g,o=/[-+]?(?:\d*\.\d+|\d+)(?:[eE][-+]?\d+)?/g,e=[];let i=!1,n=0,a=0,r=0,l=0,h=0,f=0,p;for(;(p=s.exec(t))!==null;){const c=p[1],d=(p[2].match(o)||[]).map(parseFloat),u=c===c.toLowerCase(),g=c.toUpperCase();let y=0;const b=S=>{let C=d[y++];return u&&(C+=S?n:a),C},v=()=>({x:b(!0),y:b(!1)});switch(g){case"M":{const S=v();for(h=n=S.x,f=a=S.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a,moveTo:!0});y<d.length;){const C=v();n=C.x,a=C.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break}case"L":for(;y<d.length;){const S=v();n=S.x,a=S.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break;case"H":for(;y<d.length;)n=b(!0),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"V":for(;y<d.length;)a=b(!1),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"C":for(;y<d.length;){const S=v(),C=v(),w=v();if(e.length>0){const M=e[e.length-1];M.out_x=S.x,M.out_y=S.y}n=w.x,a=w.y,e.push({x:n,y:a,in_x:C.x,in_y:C.y,out_x:n,out_y:a}),r=C.x,l=C.y}break;case"S":for(;y<d.length;){const S={x:2*n-r,y:2*a-l},C=v(),w=v();if(e.length>0){const M=e[e.length-1];M.out_x=S.x,M.out_y=S.y}n=w.x,a=w.y,e.push({x:n,y:a,in_x:C.x,in_y:C.y,out_x:n,out_y:a}),r=C.x,l=C.y}break;case"Q":for(;y<d.length;){const S=v(),C=v();if(e.length>0){const w=e[e.length-1];w.out_x=w.x+2/3*(S.x-w.x),w.out_y=w.y+2/3*(S.y-w.y)}n=C.x,a=C.y,e.push({x:n,y:a,in_x:n+2/3*(S.x-n),in_y:a+2/3*(S.y-a),out_x:n,out_y:a}),r=S.x,l=S.y}break;case"T":for(;y<d.length;){const S={x:2*n-r,y:2*a-l},C=v();if(e.length>0){const w=e[e.length-1];w.out_x=w.x+2/3*(S.x-w.x),w.out_y=w.y+2/3*(S.y-w.y)}n=C.x,a=C.y,e.push({x:n,y:a,in_x:n+2/3*(S.x-n),in_y:a+2/3*(S.y-a),out_x:n,out_y:a}),r=S.x,l=S.y}break;case"Z":if(i=!0,e.length>0){const S=e[e.length-1];S.closePath=!0;const C=[...e].reverse().find(w=>w.moveTo)||e[0];C&&Math.hypot(C.x-S.x,C.y-S.y)<.1&&(C.in_x=S.in_x,C.in_y=S.in_y,e.pop(),e.length>0&&(e[e.length-1].closePath=!0))}n=h,a=f;break;default:if(d.length>=2){const S=v();n=S.x,a=S.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break}}return{points:e,isClosed:i}}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 i;const e=(i=this.artboard)==null?void 0:i.objects.find(n=>n.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){var e,i;if(!this.artboard)return;const o=this.artboard.objects.find(n=>n.id===t||n.name===t);if(o&&((e=o.geometry)==null?void 0:e.type)==="LineGraph"){const n=o.geometry;!n.datasets||n.datasets.length===0?n.datasets=[{id:"default",label:"Runtime Data",data:s,lineColor:"#3b82f6",lineWidth:2,showArea:!1}]:n.datasets[0].data=s;const a=this.objectStates.get(o.id);a&&((i=a.geometry)==null?void 0:i.type)==="LineGraph"&&(!a.geometry.datasets||a.geometry.datasets.length===0?a.geometry.datasets=JSON.parse(JSON.stringify(n.datasets)):a.geometry.datasets[0].data=[...s]),n.datasets[0].inputId&&this.updateInput(n.datasets[0].inputId,s)}else this.updateInput(t,s)}load(t){var n,a;if(!t)return;let s=this.decompressStrings(t);const o=[],e=new Set,i=r=>{r&&r.forEach(l=>{if(e.has(l.id))return;const h={...l},f=h.childrenObjects||[];e.add(h.id),o.push(h),i(f)})};if(i(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: "${(n=this.artboard)==null?void 0:n.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 h=r.get(l.parentId);h&&(h.children||(h.children=[]),h.children.includes(l.id)||h.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=i=>{console.error("[ExodeUI Preload] failed:",i,`Src: ${o.substring(0,80)}...`)},e.src=o,this.imageCache.set(o,e)};t.objects.forEach(o=>{var e,i,n;(e=o.geometry)!=null&&e.src&&s(o.geometry.src),(n=(i=o.style)==null?void 0:i.fill)!=null&&n.src&&s(o.style.fill.src)})}decompressStrings(t){if(t&&typeof t=="object"&&!Array.isArray(t)){if(t._compressed&&t._data)try{const o=Ss.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 n,a,r,l,h,f,p;const o=s.width??((n=s.geometry)==null?void 0:n.width)??0,e=s.height??((a=s.geometry)==null?void 0:a.height)??0,i=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:((h=s.transform)==null?void 0:h.x)??s.x??0,y:((f=s.transform)==null?void 0:f.y)??s.y??0,width:o,height:e,cornerRadius:i,corner_radius:i,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:((p=s.transform)==null?void 0:p.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 is;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 i,n;if((i=e.physics)!=null&&i.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:((n=e.geometry)==null?void 0:n.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=>{this.inputs.set(s.id,s.value);const o=this.inputNameMap.get(s.name)||[];o.includes(s.id)||o.push(s.id),this.inputNameMap.set(s.name,o)}),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 i;if(!this.artboard)return;const s=new Map;this.artboard.objects.forEach(n=>s.set(n.id,n));const o=.15,e=n=>{n.forEach(a=>{const r=this.objectStates.get(a.id);if(r){const l=Math.abs(r.x-a.x),h=Math.abs(r.y-a.y);!t&&(l>20||h>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((i=this.artboard.autoLayout)!=null&&i.enabled){const n=this.artboard.objects.filter(r=>!r.parentId),a=ss(this.artboard,n,r=>this.objectStates.get(r));e(a.childUpdates)}this.artboard.objects.forEach(n=>{var a;if(n.type==="Frame"&&((a=n.autoLayout)!=null&&a.enabled)&&n.children&&n.children.length>0){const r=n.children.map(f=>s.get(f)).filter(f=>!!f),l=this.objectStates.get(n.id);if(!l)return;const h=ss(l,r,f=>this.objectStates.get(f));h.frameWidth!==void 0&&(l.width=h.frameWidth),h.frameHeight!==void 0&&(l.height=h.frameHeight),e(h.childUpdates)}})}loadFonts(){if(!this.artboard)return;const t=new Set;if(this.artboard.objects.forEach(n=>{n.geometry&&n.geometry.type==="Text"&&n.geometry.fontFamily&&t.add(n.geometry.fontFamily)}),this.artboard.animations.forEach(n=>{n.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(n=>{const a=n.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 n=`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!==n&&(a.href=n)}const i=[];if(t.forEach(n=>{n.toLowerCase().includes("clash display")&&i.push("clash-display@200,300,400,500,600,700")}),i.length>0){const n=`https://api.fontshare.com/v2/css?f[]=${i.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!==n&&(a.href=n)}document.fonts&&document.fonts.ready&&document.fonts.ready.then(()=>{this.pretextCache.clear(),this.advance(0)})}enterStates(t,s){var n;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 i=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(h=>h.id===r);if(l)if(l.isBlendState&&l.blendAnimations&&l.blendAnimations.length>0)e.push({animation:null,state:l}),l.blendAnimations.forEach(h=>{const f=this.artboard.animations.find(p=>p.id===h.animationId);f&&(i=Math.max(i,f.duration))});else{let h=null;l.animationId&&(h=this.artboard.animations.find(f=>f.id===l.animationId)||null),h||(h=this.artboard.animations.find(f=>{var p,c;return f.name===l.name||f.id===l.name||(l.name==="Entry"||l.id==="entry")&&(((p=f.name)==null?void 0:p.toLowerCase())==="onload"||((c=f.name)==null?void 0:c.toLowerCase())==="intro")})||null),h&&((n=this.artboard.animationFlow)!=null&&n.some(p=>(p.trigger==="on_load"||p.trigger==="after_delay")&&p.targetAnimationId===(h==null?void 0:h.id))||(e.push({animation:h,state:l}),i=Math.max(i,h.duration)))}}}this.layerStates.set(t,{currentStateIds:s,animations:e,time:0,duration:i})}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 i=s.replace(/\[(\d+)\]/g,".$1").split(".");let n=e;for(let a=0;a<i.length-1;a++){if(typeof n[i[a]]!="object"||n[i[a]]===null){const r=i[a+1],l=!isNaN(Number(r));n[i[a]]=l?[]:{}}n=n[i[a]]}n[i[i.length-1]]=o}else e[s]=o}updateInput(t,s){var n,a,r;let o;if(this.inputs.has(t)){const l=(n=this.activeStateMachine)==null?void 0:n.inputs.find(h=>h.id===t);l&&typeof l.value=="object"&&(o=l.value.type)}else{const l=this.inputNameMap.get(t);if(l&&l.length>0){const h=(a=this.activeStateMachine)==null?void 0:a.inputs.find(f=>f.id===l[0]);h&&typeof h.value=="object"&&(o=h.value.type)}}let e=s;o==="Trigger"&&(s===1?e=!0:s===0&&(e=!1)),this.inputs.has(t)&&this.setInternalInput(t,e);const i=this.inputNameMap.get(t);i&&i.forEach(l=>this.setInternalInput(l,e)),o==="Trigger"&&e===!0&&(this.justFiredTriggers.add(t),i&&i.forEach(l=>this.justFiredTriggers.add(l))),Array.isArray(e)&&((r=this.artboard)==null||r.objects.forEach(l=>{if(l.inputId===t||l.name===t){const h=this.objectStates.get(l.id);h&&h.options&&(l.type==="ListView"||l.variant==="listview"?h.options.items=e:(l.type==="Dropdown"||l.variant==="dropdown")&&(h.options.optionsList=e))}})),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(i=>{if(i.trigger==="variable"&&i.conditionVariableId&&i.targetAnimationId&&(i.conditionVariableId===t||e&&e.includes(i.conditionVariableId))){const a=i.conditionOperator||"IsTrue",r=i.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 h=i.delay||0;h<=0?this.triggerGlobalAnimation(i.targetAnimationId,i.subAnimationIds,i.loop,i.id):setTimeout(()=>this.triggerGlobalAnimation(i.targetAnimationId,i.subAnimationIds,i.loop,i.id),h)}}})}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 i of s.currentStateIds){const n=t.states.find(r=>r.id===i);if(!n)continue;let a=!1;for(const r of n.transitions||[])this.checkConditions(r.conditions)&&(o.push(r.targetStateId),a=!0,e=!0);a||o.push(i)}if(!e){const i=this.findGlobalTransition(t,s.currentStateIds);i&&(o.length=0,o.push(i.targetStateId),e=!0,i.conditions&&(i.conditions||[]).forEach(n=>{var r;const a=(r=this.activeStateMachine)==null?void 0:r.inputs.find(l=>l.id===n.inputId);a&&typeof a.value=="object"&&a.value.type==="Trigger"&&this.setInternalInput(n.inputId,!1)}))}if(e){const i=Array.from(new Set(o));this.enterStates(t.name,i)}}),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(i=>i.id===t);s&&this.inputNameMap.has(s.name)&&((e=this.inputNameMap.get(s.name))==null||e.forEach(i=>this.setInternalInput(i,!1)))}),this.justFiredTriggers.clear()))}findGlobalTransition(t,s){for(const o of t.states)if(!(s.includes(o.id)&&this.justFiredTriggers.size===0)){for(const i of o.transitions||[])if(!(s.includes(i.targetStateId)&&this.justFiredTriggers.size===0)&&this.checkConditions(i.conditions))return i}return null}checkConditions(t){return!t||t.length===0?!0:t.every(s=>{const o=s.inputId,e=s.op,i=s.value,n=this.evaluateLogicTree(o);if(n===void 0)return this.log(`[Engine] Condition Check Failed: Input ${o} is undefined`),!1;let a=!1;switch(e){case"Equal":case"==":a=n==i;break;case"NotEqual":case"!=":a=n!=i;break;case"GreaterThan":case">":a=n>i;break;case"LessThan":case"<":a=n<i;break;case"GreaterEqual":case">=":a=n>=i;break;case"LessEqual":case"<=":a=n<=i;break;case"IsTrue":a=!!n;break;case"IsFalse":a=!n;break;default:a=!1}return a||this.justFiredTriggers.has(o),a})}evaluateLogicTree(t,s=null,o=new Set){var a,r,l,h,f,p;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(c=>c.id===t);if(e){const c=(u,g)=>{const y=e.inputs.find(b=>b.id===u);return y?y.sourceId?this.evaluateLogicTree(y.sourceId,y.sourceHandleId,o):y.value!==void 0?y.value:g:g};let d=0;switch(e.op){case Ct.AND:d=c("a",!1)&&c("b",!1);break;case Ct.OR:d=c("a",!1)||c("b",!1);break;case Ct.NOT:d=!c("in",!1);break;case Ct.XOR:d=!!c("a",!1)!=!!c("b",!1);break;case Ct.OBJECT:d=e.name;break;case Ct.PROPERTY:case Ct.GET_PROPERTY:{const u=c("id","");if(!u){d=0;break}const g=e.name;if(!g||g==="GET_PROPERTY"||g==="PROPERTY"){d=0;break}const y=this.objectStates.get(u);if(!y){d=0;break}g in y?d=y[g]:d=this.resolvePath(y,g);break}case Ct.SET_PROPERTY:{const u=c("id",""),g=c("value",void 0);if(!u||g===void 0){d=0;break}const y=e.name;if(!y||y==="SET_PROPERTY"){d=0;break}const b=this.objectStates.get(u);if(!b){d=0;break}if(["x","y","rotation","scale_x","scale_y","opacity","width","height","cornerRadius","visible","zIndex"].includes(y))b[y]=g,d=g;else{const S=y.replace(/\[(\d+)\]/g,".$1").split(".");let C=b;for(let M=0;M<S.length-1;M++){const I=S[M],k=S[M+1];C[I]===void 0&&(C[I]=isNaN(Number(k))?{}:[]),C=C[I]}const w=S[S.length-1];C[w]=g,d=g}break}case Ct.ADD:d=c("a",0)+c("b",0);break;case Ct.SUB:d=c("a",0)-c("b",0);break;case Ct.MUL:d=c("a",0)*c("b",0);break;case Ct.DIV:{const u=c("b",1);d=u===0?0:c("a",0)/u;break}case Ct.MOD:d=c("a",0)%c("b",1);break;case Ct.POW:d=Math.pow(c("a",0),c("b",1));break;case Ct.ABS:d=Math.abs(c("in",0));break;case Ct.ROUND:d=Math.round(c("in",0));break;case Ct.FLOOR:d=Math.floor(c("in",0));break;case Ct.CEIL:d=Math.ceil(c("in",0));break;case Ct.SIN:d=Math.sin(c("in",0));break;case Ct.COS:d=Math.cos(c("in",0));break;case Ct.TAN:d=Math.tan(c("in",0));break;case Ct.CLAMP:{const u=c("in",0),g=c("min",0),y=c("max",1);d=Math.max(g,Math.min(y,u));break}case Ct.REMAP:{const u=c("in",0),g=c("inMin",0),y=c("inMax",100),b=c("outMin",0),v=c("outMax",1);d=y===g?b:b+(u-g)*(v-b)/(y-g);break}case Ct.EQ:d=c("a",0)==c("b",0);break;case Ct.NEQ:d=c("a",0)!=c("b",0);break;case Ct.GT:d=c("a",0)>c("b",0);break;case Ct.LT:d=c("a",0)<c("b",0);break;case Ct.GTE:d=c("a",0)>=c("b",0);break;case Ct.LTE:d=c("a",0)<=c("b",0);break;case Ct.IF_ELSE:d=c("cond",!1)?c("then",0):c("else",0);break;case Ct.VALUE:d=e.value!==void 0?e.value:0;break;case Ct.INPUT:d=this.inputs.get(e.name)??0;break;case Ct.LOG:{const u=c("in","");this.debugLog(`[User Logic] ${u}`),d=u;break}case Ct.SCROLL_X:d=this.inputs.get("scrollX")??0;break;case Ct.SCROLL_Y:d=this.inputs.get("scrollY")??0;break;case Ct.MOUSE_X:d=this.inputs.get("mouseX")??0;break;case Ct.MOUSE_Y:d=this.inputs.get("mouseY")??0;break;case Ct.IS_MOUSE_DOWN:d=this.inputs.get("isMouseDown")??!1;break;case Ct.EFFECTOR:{const u=c("id",""),g=c("intensity",1),y=c("trigger",!0);if(!u||!y){d=0;break}const b=e.name;if(!b){d=0;break}const v=this.objectStates.get(u);if(!v){d=0;break}if(["glitch","halftone","pixelate","noise","acid_gradient","acid_rave","shimmer"].includes(b))v.style||(v.style={}),v.style.artEffect={enabled:!0,type:b,intensity:g},d=1;else{v.behaviors||(v.behaviors=[]);let C=v.behaviors.find(w=>w.type===b);C?(C.enabled=!0,C.settings||(C.settings={}),C.settings.intensity=g):(C={id:`eff_${Date.now()}_${b}`,type:b,enabled:!0,sensors:[],settings:{intensity:g}},v.behaviors.push(C)),d=1}break}case Ct.MONITOR:{d=c("in",0);break}case Ct.SPRING_PULL:{const u=c("objectId",""),g=c("forceX",0),y=c("forceY",0);u&&((l=this.artboard)==null||l.objects.forEach(b=>{b.behaviors&&b.behaviors.forEach(v=>{var S;if(v.type===V.SpringChain&&((S=v.settings)!=null&&S.connections)&&(v.settings.connections.some(w=>w.targetId===u)||b.id===u)){this._springChainState.has(b.id)||this._springChainState.set(b.id,new Map);const w=this._springChainState.get(b.id);if(!w.has(u)){const I=this.objectStates.get(u);w.set(u,{x:(I==null?void 0:I.x)??0,y:(I==null?void 0:I.y)??0,vx:0,vy:0})}const M=w.get(u);M&&(M.vx+=g,M.vy+=y)}})})),d=1;break}case Ct.SPRING_SETTLE:{const u=c("objectId","");let g=!0;if(u){const y=c("threshold",1);this._springChainState.forEach(b=>{const v=b.get(u);v&&(Math.abs(v.vx)>y||Math.abs(v.vy)>y)&&(g=!1)})}d=g;break}case Ct.EMIT:{const u=c("objectId",""),g=c("count",20);u&&((h=this.artboard)==null||h.objects.forEach(y=>{y.behaviors&&y.behaviors.forEach(b=>{b.type===V.ParticleEmitter&&y.id===u&&(b._pendingBurst=(b._pendingBurst||0)+g)})})),d=1;break}default:d=0;break}if(this.logicNodeValues.set(t,d),e.op===Ct.DELAY){const u=c("delay",0),g=c("in",0);let y=this.logicNodeState.get(t);for(y||(y={queue:[]},this.logicNodeState.set(t,y)),y.queue.push({time:this.currentTime+u,value:g});y.queue.length>0&&y.queue[0].time<=this.currentTime;)y.lastValue=y.queue.shift().value;d=y.lastValue??0}return d}const i=(f=this.activeStateMachine)==null?void 0:f.inputs.find(c=>c.id===t||c.name===t);if(i&&i.sourceId&&!o.has(i.sourceId)){const c=this.evaluateLogicTree(i.sourceId,i.sourceHandleId,o);return this.inputs.set(i.id,c),c}let n=this.inputs.get(t)??(i?this.inputs.get(i.id):void 0);if((this.justFiredTriggers.has(t)||i&&this.justFiredTriggers.has(i.id))&&(n=!0),s&&n!==void 0){const c=(p=this.activeStateMachine)==null?void 0:p.inputs.find(d=>d.id===t);if(c&&c.value.type==="Number"&&typeof n=="number"){const d=c.value.defaultValue??c.value.value;if(s==="source-greater")return n>d;if(s==="source-less")return n<d;if(s==="source-equal")return n===d}if(s==="source-true")return n===!0;if(s==="source-false")return n===!1;if(s==="source-fire")return this.justFiredTriggers.has(t)}return n!==void 0?n:0}runLogicNodes(){!this.activeStateMachine||!this.activeStateMachine.logicNodes||this.activeStateMachine.logicNodes.forEach(t=>{(t.op===Ct.SET_PROPERTY||t.op===Ct.EFFECTOR)&&this.evaluateLogicTree(t.id)})}resolvePath(t,s){const o=s.replace(/\[(\d+)\]/g,".$1").split(".");let e=t;for(const i of o)if(e&&typeof e=="object"&&i in e)e=e[i];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 i;if(e.valueType==="variable"?i=this.getInputValue(e.variableId):e.valueType==="constant"&&(i=e.value),i!==void 0){const n=e.name;if(["x","y","rotation","scale_x","scale_y","opacity","width","height","cornerRadius","visible","zIndex"].includes(n))o[n]=i;else{const r=n.replace(/\[(\d+)\]/g,".$1").split(".");let l=o;for(let f=0;f<r.length-1;f++){const p=r[f],c=r[f+1];l[p]===void 0&&(l[p]=isNaN(Number(c))?{}:[]),l=l[p]}const h=r[r.length-1];l[h]=i}}})}})}seek(t){this.artboard&&(this.currentTime=t,this.layerStates.forEach(s=>{s.time=t,s.time>(s.duration||0)&&(s.animations.some(e=>{var i;return((i=e.state)==null?void 0:i.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 i=this.physicsEngine.getPosition(o.id),n=this.physicsEngine.getRotation(o.id),a=this.objectStates.get(o.id);a&&i!==null&&n!==null&&(a.x=i.x,a.y=i.y,a.rotation=n*(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(n=>{var a;return((a=n.state)==null?void 0:a.loop)===!0}))o.time%=o.duration;else{const n=o.time<o.duration+.1;o.time=o.duration,n&&(o.currentStateIds.length>0&&this.handleAnimationFinished(o.currentStateIds[0],o.ruleId),e.startsWith("global_")&&s.push(e))}o.animations.forEach(i=>{var n;(n=i.state)!=null&&n.isBlendState&&i.state.blendAnimations?this.applyBlendState(i.state,o.time):i.animation&&this.applyAnimation(i.animation,o.time,i.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 i,n,a,r,l,h,f;if(o.phase==="entry")o.time+=t,o.time>=o.animation.duration&&((a=(n=(i=this.artboard)==null?void 0:i.objects.find(p=>p.id===e))==null?void 0:n.triggers)==null||a.find(p=>p.id===o.triggerId),o.phase="hold",o.elapsedHold=0,o.time=o.animation.duration),this.applyAnimation(o.animation,o.time,o.filterObjectIds||o.filterObjectId||void 0);else if(o.phase==="hold"){const p=(h=(l=(r=this.artboard)==null?void 0:r.objects.find(u=>u.id===e))==null?void 0:l.triggers)==null?void 0:h.find(u=>u.id===o.triggerId),c=(p==null?void 0:p.duration)||0;o.elapsedHold+=t*1e3;let d=o.elapsedHold>=c;if((p==null?void 0:p.eventType)==="hover"&&!this.activeHoverIds.has(e)&&(d=!0),((p==null?void 0:p.eventType)==="onHold"||(p==null?void 0:p.eventType)==="pointerDown")&&!this.isMouseDown&&(d=!0),d)if(p!=null&&p.exitAnimationId){const u=(f=this.artboard)==null?void 0:f.animations.find(g=>g.id===p.exitAnimationId);u?(o.phase="exit",o.animation=u,o.time=0):this.activeTriggers.delete(e)}else this.activeTriggers.delete(e)}else o.phase==="exit"&&(o.time+=t,o.time>=o.animation.duration?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,i,n;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=(((i=s.geometry)==null?void 0:i.width)||100)*(r.scale_x||1),h=(((n=s.geometry)==null?void 0:n.height)||100)*(r.scale_y||1),f=50,p=r.x+l/2>=-this.canvasWidth/2-f&&r.x-l/2<=this.canvasWidth/2+f&&r.y+h/2>=-this.canvasHeight/2-f&&r.y-h/2<=this.canvasHeight/2+f,c=`analytics_${s.id}`,d=this.wasInView.has(c);p&&!d&&this.fireAnalyticsEvent(s.id,"visible"),p?this.wasInView.add(c):this.wasInView.delete(c)}}}),this.artboard.objects.forEach(s=>{const o=s.interactions||[];o.length!==0&&o.forEach(e=>{const i=e.triggers||[e.event||e.trigger];i&&i.forEach(n=>{var r,l,h;const a=n.toLowerCase();if(a==="on interval"||a==="oninterval"){const f=e.intervalValue||2e3,p=this.periodicTriggerTimes.get(e.id)||0;this.currentTime*1e3-p>=f&&(!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 f=e.delayValue||1e3;!this.periodicTriggerTimes.has(e.id)&&this.currentTime*1e3>=f&&(!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 f=this.objectStates.get(s.id);if(f&&f.visible!==!1){const p=this.getGlobalTransform(s.id),c=(((r=s.geometry)==null?void 0:r.width)||100)*(p.scale_x||1),d=(((l=s.geometry)==null?void 0:l.height)||100)*(p.scale_y||1),u=50,g=p.x+c/2>=-this.canvasWidth/2-u&&p.x-c/2<=this.canvasWidth/2+u&&p.y+d/2>=-this.canvasHeight/2-u&&p.y-d/2<=this.canvasHeight/2+u,y=this.wasInView.has(s.id);g&&!y&&(!e.conditions||this.checkConditions(e.conditions))&&this.fireEventForObject(s.id,"Scroll Into View"),g?this.wasInView.add(s.id):this.wasInView.delete(s.id)}}if(a==="scroll progress"||a==="scrollprogress"){const f=Math.abs(this.scrollOffset.y)/(((h=this.artboard)==null?void 0:h.height)||1e3),p=this.scrollProgressLastValue.get(e.id)||0;Math.abs(f-p)>.001&&(this.scrollProgressLastValue.set(e.id,f),(e.action==="Set Input"||e.action==="setInput")&&this.updateInput(e.targetInputId,f))}})})}))}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((i,n)=>{var h,f,p,c,d,u,g,y,b;const a=((h=o.constraints)==null?void 0:h[n])||{},r={...i,...a},l=r.strength??1;if(r.type==="Translation"){const v=this.getGlobalTransform(r.targetId);if(v){const S=r.offsetX||0,C=r.offsetY||0,w=v.x+S,M=v.y+C,I=r.useSpring;if(I){const P=this.objectVelocities.get(s.id)||{vx:0,vy:0},{x:E,y:_,vx:T,vy:A}=this.computeSpring(e.x,e.y,P.vx,P.vy,w,M,r,t);r.copyX&&(e.x=e.x+(E-e.x)*l),r.copyY&&(e.y=e.y+(_-e.y)*l),this.objectVelocities.set(s.id,{vx:T,vy:A})}else r.copyX&&(e.x=e.x+(w-e.x)*l),r.copyY&&(e.y=e.y+(M-e.y)*l);let k=!1;if((f=r.limitX)!=null&&f.enabled){const P=e.x;e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x)),e.x!==P&&(k=!0)}if((p=r.limitY)!=null&&p.enabled){const P=e.y;e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)),e.y!==P&&(k=!0)}k&&I&&this.objectVelocities.set(s.id,{vx:0,vy:0})}}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 S=(v.rotation-e.rotation)%360;S>180&&(S-=360),S<-180&&(S+=360),e.rotation=e.rotation+S*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=((c=this._lastPointerPos)==null?void 0:c.x)??e.x,S=((d=this._lastPointerPos)==null?void 0:d.y)??e.y,C=r.useSpring;if(C){const M=this.objectVelocities.get(s.id)||{vx:0,vy:0},{x:I,y:k,vx:P,vy:E}=this.computeSpring(e.x,e.y,M.vx,M.vy,v,S,r,t);e.x=I,e.y=k,this.objectVelocities.set(s.id,{vx:P,vy:E})}else e.x=e.x+(v-e.x)*l,e.y=e.y+(S-e.y)*l;let w=!1;if((u=r.limitX)!=null&&u.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((g=r.limitY)!=null&&g.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 S=e.x-v.x,C=e.y-v.y,w=Math.sqrt(S*S+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 k=e.x===v.x&&e.y===v.y?1:I/w;e.x=e.x+(v.x+S*k-e.x)*l,e.y=e.y+(v.y+C*k-e.y)*l}}}else if(r.type==="FollowPath"){const v=(y=this.artboard)==null?void 0:y.objects.find(S=>S.id===r.targetId);if(v){const S=this.getGlobalTransform(v.id);if(S){let C=v.geometry;if(v.type==="Frame"||v.type==="Group"||!C||C.type!=="Path"&&C.type!=="Ellipse"&&C.type!=="Rectangle"){const x=(b=this.artboard)==null?void 0:b.objects.find(st=>st.parentId===v.id&&st.type==="Shape"&&st.geometry&&(st.geometry.type==="Path"||st.geometry.type==="Ellipse"||st.geometry.type==="Rectangle"));x&&(C=x.geometry)}if(!C)return;const w=(r.distance||0)/100,M=S.width||C.width||0,I=S.height||C.height||0,k=this.getPointOnPath(C,M,I,w),P=S.rotation*Math.PI/180,E=Math.cos(P),_=Math.sin(P),T=k.x*S.scale_x*E-k.y*S.scale_y*_,A=k.x*S.scale_x*_+k.y*S.scale_y*E;let L=S.rotation+(r.offsetRotation||0);if(r.orient){const x=Math.cos(k.angle),st=Math.sin(k.angle),Q=x*S.scale_x*E-st*S.scale_y*_,lt=x*S.scale_x*_+st*S.scale_y*E;L=Math.atan2(lt,Q)*180/Math.PI+(r.offsetRotation||0)}const X=L*Math.PI/180,D=Math.cos(X),$=Math.sin(X),G=(r.offsetX||0)*D-(r.offsetY||0)*$,H=(r.offsetX||0)*$+(r.offsetY||0)*D,et=S.x+T+G,O=S.y+A+H;if(e.x=e.x+(et-e.x)*l,e.y=e.y+(O-e.y)*l,r.orient){let x=(L-e.rotation)%360;x>180&&(x-=360),x<-180&&(x+=360),e.rotation=e.rotation+x*l}}}}else if(r.type==="IK"){const v=this.getGlobalTransform(r.targetId);v&&this.solveIK(s,v,r.boneCount||2,l)}}),s.constraints.some(i=>i.type!=="IK")){const i=this.globalToLocal(s.parentId,e);o.x=i.x,o.y=i.y,o.rotation=i.rotation,o.flip_x=i.scale_x<0,o.scale_x=Math.abs(i.scale_x),o.flip_y=i.scale_y<0,o.scale_y=Math.abs(i.scale_y)}})}getGlobalTransform(t){var f,p;const s=this.objectStates.get(t);if(!s)return{x:0,y:0,rotation:0,scale_x:1,scale_y:1};const o=(f=this.artboard)==null?void 0:f.objects.find(c=>c.id===t),e=(o==null?void 0:o.type)==="Bone"?(p=o.geometry)==null?void 0:p.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 i=this.getGlobalTransform(o.parentId),n=i.rotation*Math.PI/180,a=Math.cos(n),r=Math.sin(n),l=i.x+(s.x*i.scale_x*a-s.y*i.scale_y*r),h=i.y+(s.x*i.scale_x*r+s.y*i.scale_y*a);return{x:l,y:h,rotation:i.rotation+s.rotation,scale_x:i.scale_x*(s.scale_x??1)*(s.flip_x?-1:1),scale_y:i.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,i=o.scale_y===0?0:1/o.scale_y,n=-o.rotation*Math.PI/180,a=Math.cos(n),r=Math.sin(n),l=s.x-o.x,h=s.y-o.y,f=(l*a-h*r)*e,p=(l*r+h*a)*i;return{x:f,y:p,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 i=[];let n=t.id;for(let h=0;h<o&&n;h++){const f=(l=this.artboard)==null?void 0:l.objects.find(p=>p.id===n);if(!f)break;i.push({id:n,local:this.objectStates.get(n),global:this.getGlobalTransform(n)}),n=f.parentId}if(i.length<2)return;const a=i.reverse(),r=5;for(let h=0;h<r;h++){const f=this.getGlobalTransform(t.id);for(let p=a.length-2;p>=0;p--){const c=a[p],d=this.getGlobalTransform(c.id),u=f.x-d.x,g=f.y-d.y,y=s.x-d.x,b=s.y-d.y,v=Math.sqrt(u*u+g*g),S=Math.sqrt(y*y+b*b);if(v>.001&&S>.001){const C=Math.atan2(g,u);let M=(Math.atan2(b,y)-C)*180/Math.PI;M*=e;const I=this.objectStates.get(c.id);I&&(I.rotation+=M)}}}}computeSpring(t,s,o,e,i,n,a,r){const l=a.stiffness??100,h=a.damping??10,f=a.mass??1,p=-l*(t-i),c=-l*(s-n),d=-h*o,u=-h*e,g=(p+d)/f,y=(c+u)/f,b=o+g*r,v=e+y*r,S=t+b*r,C=s+v*r;return{x:S,y:C,vx:b,vy:v}}handlePointerInput(t,s,o,e,i){if(!this.artboard)return;const n=this.calculateTransform(e,i,this.artboard.width,this.artboard.height,this.layout.fit,this.layout.alignment),a=(s-n.tx)/n.scaleX,r=(o-n.ty)/n.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)}handleWheel(t,s){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,h,f,p;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 i=(c,d)=>{var S;let u=d;d==="click"?u="onClick":d==="down"?u="onPointerDown":d==="up"?u="onPointerUp":d==="blur"&&(u="onPointerLeave");const g=new Set([u]);d==="move"&&g.add("onPointerEnter").add("hover").add("onPointerLeave").add("blur"),u==="onClick"&&g.add("click"),u==="onPointerDown"&&g.add("pointerDown"),u==="onPointerUp"&&g.add("pointerUp");const y=["button","toggle","toggle_button","dropdown","listview","inputbox","slider","checkbox","radiogroup","joystick"];return!!(c.type==="Component"&&y.includes(c.variant)||c.type==="Joystick"||y.includes((S=c.type)==null?void 0:S.toLowerCase())||(c.interactions||[]).some(C=>g.has(C.event))||(c.triggers||[]).some(C=>g.has(C.eventType)))};let n=null;for(let c=this.artboard.objects.length-1;c>=0;c--){const d=this.artboard.objects[c],u=this.objectStates.get(d.id);if(u&&u.visible!==!1&&u.opacity>0&&this.hitTest(d,s,o)&&(n||(n=d),i(d,t))){e=d;break}}!e&&n&&(e=n),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(d=>d.id===this.draggingSliderId);c&&this.updateSliderValueFromPointer(c,s,o);return}if(this.draggingJoystickId){const c=this.artboard.objects.find(d=>d.id===this.draggingJoystickId);c&&this.updateJoystickValueFromPointer(c,s,o);return}if(this.draggingListViewId){const c=this.artboard.objects.find(d=>d.id===this.draggingListViewId);c&&this.updateListViewScrollFromPointer(c);return}e&&(e.type==="ListView"||e.type==="Component"&&e.variant==="listview")&&this.updateListViewHoverFromPointer(e,s,o),this.isMouseDown&&a&&this.fireEventForObject(a,"Drag"),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.draggingBehaviors.clear(),this.pointerDownTimes.delete(a),this.activeObjectId=null),t==="down"&&(this.pointerDownTimes.set(a,this.currentTime),this.activeObjectId=a,e&&((r=e.behaviors)!=null&&r.some(c=>c.type===V.Draggable))&&this.draggingBehaviors.add(a)),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(d=>d.id===this.activeDropdownId);if(c&&(c.type==="Dropdown"||c.variant==="dropdown")){const d=this.objectStates.get(c.id),u=(d==null?void 0:d.options)||c.options||{},g=c.geometry||{},y=g.width??c.width??200,b=g.height??c.height??40,v=u.optionsList||[],S=u.itemHeight||32,C=u.listPadding??4,w=v.length*S+C*2,M=this.getWorldTransform(c.id),I=y*Math.abs(M.scaleX),k=b*Math.abs(M.scaleY),P=M.y+k/2+4,E=Math.abs(s-M.x)<=I/2,_=o>=P&&o<=P+w*Math.abs(M.scaleY);if(E&&_){const T=Math.abs(M.scaleY),A=o-(P+C*T),L=Math.floor(A/(S*T));if(L>=0&&L<v.length){const X=v[L];u.selectedOption=X,u.isOpen=!1,this.activeDropdownId=null,c.inputId&&this.setInternalInput(c.inputId,X),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"dropdown",property:"selectedOption",value:X})}return}else a!==this.activeDropdownId&&(u.isOpen=!1,this.activeDropdownId=null)}}if(e){let c=e,d=e;for(;d&&d.parentId;){const g=this.artboard.objects.find(y=>y.id===d.parentId);if(g&&g.type==="Component"){c=g;break}d=g}let u=t;if(t==="click"?u="onClick":t==="down"?u="onPointerDown":t==="up"?u="onPointerUp":t==="blur"&&(u="onPointerLeave"),this.fireEventForObject(e.id,u),c!==e&&this.fireEventForObject(c.id,u),c.type==="Component"&&c.variant==="toggle_button"&&t==="down"){const g=this.objectStates.get(c.id),y=(g==null?void 0:g.options)||c.options||{};y.checked=!y.checked,c.inputId&&this.setInternalInput(c.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"toggle_button",property:"checked",value:y.checked}),this.fireEventForObject(c.id,"Toggle"),this.fireEventForObject(c.id,y.checked?"Toggle True":"Toggle False")}if(c.type==="Component"&&c.variant==="toggle"&&t==="down"){const g=this.objectStates.get(c.id),y=(g==null?void 0:g.options)||c.options||{};y.checked=!y.checked,c.inputId&&this.setInternalInput(c.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"toggle",property:"checked",value:y.checked}),this.onToggle&&this.onToggle(c.name,y.checked),this.fireEventForObject(c.id,"Toggle"),this.fireEventForObject(c.id,y.checked?"Toggle True":"Toggle False")}if(c.type==="Component"&&c.variant==="dropdown"&&t==="down"){const g=this.objectStates.get(c.id),y=(g==null?void 0:g.options)||c.options||{},b=!y.isOpen;if(b&&this.activeDropdownId&&this.activeDropdownId!==c.id){const v=this.artboard.objects.find(S=>S.id===this.activeDropdownId);v&&v.options&&(v.options.isOpen=!1)}y.isOpen=b,this.activeDropdownId=b?c.id:null}if(c.type==="Component"&&c.variant==="button"&&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})),(c.type==="ListView"||c.type==="Component"&&c.variant==="listview")&&t==="down"){this.draggingListViewId=c.id;const g=this.getListViewItemIndexAtPointer(c,s,o);if(g!==null){const y=c.options||{};y.activeItemIndex=g;const b=this.objectStates.get(c.id);b&&b.options&&(b.options.activeItemIndex=g);const v=(y.items||[])[g],S=typeof v=="string"?v:v.label||v.value||g;b&&b.options&&(b.options.selectedValue=S),c.inputId&&this.setInternalInput(c.inputId,S),this.onComponentChange&&(this.onComponentChange({objectId:c.id,componentName:c.name,variant:"listview",property:"activeItemIndex",value:g}),this.onComponentChange({objectId:c.id,componentName:c.name,variant:"listview",property:"selected",value:S}))}}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 g=this.objectStates.get(c.id);g&&c.isSpringReturn!==!1&&(g.handleX=0,g.handleY=0),c.isSpringReturn!==!1&&(c.handleX=0,c.handleY=0)}}if(c.type==="Component"&&c.variant==="checkbox"&&t==="down"){const g=this.objectStates.get(c.id),y=(g==null?void 0:g.options)||c.options||{};y.checked=!y.checked,c.inputId&&this.setInternalInput(c.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"checkbox",property:"checked",value:y.checked}),this.fireEventForObject(c.id,"Click"),this.fireEventForObject(c.id,y.checked?"Checked":"Unchecked")}if(c.type==="Component"&&c.variant==="radiogroup"&&t==="down"){const g=this.objectStates.get(c.id),y=(g==null?void 0:g.options)||c.options||{},b=y.optionsList||[],v=this.getRadioGroupItemIndexAtPointer(c,s,o);if(v!==null&&v>=0&&v<b.length){const S=b[v];y.selectedValue=S,c.inputId&&this.setInternalInput(c.inputId,S),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"radiogroup",property:"selectedValue",value:S}),this.fireEventForObject(c.id,"Click"),this.fireEventForObject(c.id,`Selected: ${S}`)}}if(c.type==="LineGraph"&&(t==="down"||t==="click")){const g=c.geometry,y=(g==null?void 0:g.datasets)||[],b=this.objectStates.get(c.id),v=(b==null?void 0:b.width)||(g==null?void 0:g.width)||200,S=(b==null?void 0:b.height)||(g==null?void 0:g.height)||150,C=this.getWorldTransform(c.id),w=30,M=20,I=v-w,k=S-M;let P=1;y.forEach(T=>{const A=Math.max(...T.data||[0]);A>P&&(P=A)});let E=1/0,_=null;y.forEach((T,A)=>{const L=T.data||[],X=I/Math.max(L.length-1,1);L.forEach((D,$)=>{const G=C.x-v/2+w+$*X,H=C.y+S/2-M-D/P*k,et=Math.sqrt((s-G)**2+(o-H)**2);et<E&&(E=et,_={dIdx:A,pIdx:$,val:D,label:T.label||`Dataset ${A+1}`})})}),_&&E<20&&this.onGraphPointClick&&this.onGraphPointClick({objectId:c.id,componentName:c.name,datasetIndex:_.dIdx,pointIndex:_.pIdx,value:_.val,label:_.label}),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"linegraph",property:"click",value:(_==null?void 0:_.val)??null})}if(t==="click"){const g=(l=this.artboard)==null?void 0:l.objects.find(v=>v.id===e.id),y=this.focusedId,b=(g==null?void 0:g.type)==="InputBox"||(g==null?void 0:g.type)==="Component"&&g.variant==="inputbox";if(g&&b){if(this.focusedId=e.id,this.log(`[Engine] Focus set to: ${e.id}`),y!==this.focusedId){if(y){const v=(h=this.artboard)==null?void 0:h.objects.find(S=>S.id===y);v&&this.onInputBlur&&this.onInputBlur(v.name)}this.onInputFocus&&this.onInputFocus(g.name)}}else if(this.focusedId=null,y){const v=(f=this.artboard)==null?void 0:f.objects.find(S=>S.id===y);v&&this.onInputBlur&&this.onInputBlur(v.name)}}}else if(t==="click"){const c=this.focusedId;if(this.focusedId=null,c){const d=(p=this.artboard)==null?void 0:p.objects.find(u=>u.id===c);d&&this.onInputBlur&&this.onInputBlur(d.name)}}}handleKeyDown(t){if(!this.artboard||(this.activeKeys.add(t.key.toLowerCase()),this.activeKeys.add(t.code),!this.focusedId))return;const s=this.artboard.objects.find(a=>a.id===this.focusedId),o=(s==null?void 0:s.type)==="InputBox"||(s==null?void 0:s.type)==="Component"&&s.variant==="inputbox";if(!s||!o)return;const e=s.options||{};let i=e.text||"";if(t.key==="Backspace")i=i.slice(0,-1);else if(t.key==="Enter")if(e.multiline)i+=`
7
+ `;else{this.focusedId=null;return}else if(t.key.length===1)i+=t.key;else return;e.text=i;const n=s.geometry;n.textInputId&&this.updateInput(n.textInputId,i),this.onComponentChange&&this.onComponentChange({objectId:s.id,componentName:s.name,variant:"inputbox",property:"text",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))}fireEventForObject(t,s){var h,f,p,c,d;const o=(h=this.artboard)==null?void 0:h.objects.find(u=>u.id===t);if(!o)return;const e=new Set([s,s.toLowerCase()]),i=s.toLowerCase();i==="onclick"||i==="click"||i==="onpointerdown"||i==="pointerdown"?this.fireAnalyticsEvent(t,"click"):(i==="onpointerenter"||i==="hover"||i==="move")&&this.fireAnalyticsEvent(t,"hover"),i==="onclick"||i==="click"?(e.add("click"),e.add("onclick")):i==="onpointerdown"||i==="pointerdown"?(e.add("pointerdown"),e.add("onpointerdown")):i==="onpointerup"||i==="pointerup"?(e.add("pointerup"),e.add("onpointerup")):i==="onpointerenter"||i==="hover"||i==="move"?(e.add("hover"),e.add("onpointerenter")):i==="onpointerleave"||i==="blur"?(e.add("onpointerleave"),e.add("blur")):i==="drag"||i==="ondrag"?(e.add("drag"),e.add("ondrag")):i==="toggle"||i==="ontoggle"?(e.add("toggle"),e.add("ontoggle")):i==="toggle true"||i==="toggle_true"||i==="toggletrue"?(e.add("toggle true"),e.add("toggle_true"),e.add("toggletrue")):(i==="toggle false"||i==="toggle_false"||i==="togglefalse")&&(e.add("toggle false"),e.add("toggle_false"),e.add("togglefalse"));const a=(o.interactions||[]).find(u=>{const g=u.triggers||[u.event||u.trigger||"click"];return((u.triggerLogic||"OR")==="AND"?g.every(v=>e.has(v.toLowerCase())):g.some(v=>e.has(v.toLowerCase())))?u.conditions&&u.conditions.length>0?this.checkConditions(u.conditions):!0:!1});if(a){if(this.log(`[Engine] Interaction matched: ${s} -> Action: ${a.action}`),a.action==="setInput"||a.action==="Set Input"){let u=a.value||a.inputValue;u==="toggle"&&(u=!this.inputs.get(a.targetInputId)),this.updateInput(a.targetInputId,u)}else if(a.action==="Toggle Boolean"){const u=this.inputs.get(a.targetInputId);this.updateInput(a.targetInputId,!u)}else if(a.action==="fireTrigger")this.updateInput(a.targetInputId,!0);else if(a.action==="setProperty"){const u=a.targetObjectId||o.id,g=a.targetProperty;g&&this.updateObjectProperty(u,g,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 u=a.targetAnimationId,g=!a.playMode||a.playMode==="all"?void 0:a.subAnimationIds;u==="__all__"?(p=(f=this.artboard)==null?void 0:f.animations)==null||p.forEach(y=>{this.triggerGlobalAnimation(y.id,g)}):u&&this.triggerGlobalAnimation(u,g)}else if(a.action==="setState"||a.action==="Set State"){const u=a.targetObjectId||o.id,y={...this.objectStates.get(u)||{},...a.value||{}};this.objectStates.set(u,y),this.log(`[Engine] State updated for ${u}:`,y)}else if(a.action==="Stop Animation"||a.action==="Pause Animation"){const u=a.targetAnimationId;u==="__all__"?this.layerStates.forEach((g,y)=>{y.startsWith("global_")&&this.layerStates.delete(y)}):u&&this.layerStates.forEach((g,y)=>{y.startsWith(`global_${u}_`)&&this.layerStates.delete(y)})}else if(a.action==="Switch to State"&&this.activeStateMachine){const u=a.targetState,g=this.activeStateMachine.layers.find(y=>y.states.some(b=>b.id===u||b.name===u));g&&(this.log(`[Engine] Switching Layer ${g.name} to State ${u}`),this.enterStates(g.name,[u]))}this.onTrigger&&this.onTrigger(s,a.action)}const l=(o.triggers||[]).find(u=>{const g=u.eventType.toLowerCase();let y=!1;return(e.has(g)||g==="click"&&e.has("onclick")||g==="hover"&&(e.has("onpointerenter")||e.has("hover"))||g==="pointerdown"&&e.has("onpointerdown")||g==="pointerup"&&e.has("onpointerup"))&&(y=!0),y&&u.conditions&&u.conditions.length>0?this.checkConditions(u.conditions):y});if(l&&l.entryAnimationId){this.log(`[Engine] Trigger matched: ${s} (as ${l.eventType}) -> Animation ${l.entryAnimationId}`);const u=(d=(c=this.artboard)==null?void 0:c.animations)==null?void 0:d.find(g=>g.id===l.entryAnimationId);u&&(this.activeTriggers.set(o.id,{triggerId:l.id,animation:u,time:0,phase:"entry",elapsedHold:0,filterObjectId:l.targetObjectId}),this.onTrigger&&this.onTrigger(l.name,u.name))}}fireAnalyticsEvent(t,s){var r,l;const o=(r=this.artboard)==null?void 0:r.objects.find(h=>h.id===t);if(!o)return;const e=(l=o.style)==null?void 0:l.analytics;if(!e||!e.isEnabled||e.triggerType!==s)return;const i=e.eventName||`${o.name.toLowerCase().replace(/\s+/g,"_")}_interacted`,n={};e.parameters&&Array.isArray(e.parameters)&&e.parameters.forEach(h=>{if(h.type==="literal")n[h.key]=h.value;else if(h.type==="variable"){const f=this.inputs.get(h.value);n[h.key]=f!==void 0?f:""}}),this.log(`[ExodeUI Analytics] Dispatching event "${i}" via ${s} trigger:`,n);const a=e.platforms||{ga4:!0,meta:!0,mixpanel:!1};if(a.ga4){const h=window;typeof h.gtag=="function"?(h.gtag("event",i,n),this.log(`[ExodeUI Analytics] GA4: Event "${i}" sent successfully.`)):this.warn(`[ExodeUI Analytics] GA4: window.gtag is not a function. Event "${i}" skipped.`)}if(a.meta){const h=window;typeof h.fbq=="function"?(h.fbq("track",i,n),this.log(`[ExodeUI Analytics] Meta Pixel: Event "${i}" sent successfully.`)):this.warn(`[ExodeUI Analytics] Meta Pixel: window.fbq is not a function. Event "${i}" skipped.`)}if(a.mixpanel){const h=window;h.mixpanel&&typeof h.mixpanel.track=="function"?(h.mixpanel.track(i,n),this.log(`[ExodeUI Analytics] Mixpanel: Event "${i}" sent successfully.`)):this.warn(`[ExodeUI Analytics] Mixpanel: window.mixpanel.track is not a function. Event "${i}" skipped.`)}}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){if(!this.artboard)return;const i=this.artboard.animations.find(a=>a.id===t);if(!i)return;const n=`global_${t}_${Math.random().toString(36).substr(2,5)}`;this.layerStates.set(n,{currentStateIds:[t],animations:[{animation:i,state:{loop:o},filterObjectIds:s}],time:0,duration:i.duration,ruleId:e}),this.debugLog(`[Engine] Triggered global animation: ${i.name} (Loop: ${o}, Sub-Anims: ${(s==null?void 0:s.length)||"All"})`)}handleAnimationFinished(t,s){if(!this.artboard)return;(this.artboard.animationFlow||[]).forEach(e=>{if(e.trigger==="after_anim"&&e.targetAnimationId&&(e.afterAnim===t||s&&e.afterAnim===s)){const n=e.delay||0;n<=0?this.triggerGlobalAnimation(e.targetAnimationId,e.subAnimationIds,e.loop,e.id):setTimeout(()=>this.triggerGlobalAnimation(e.targetAnimationId,e.subAnimationIds,e.loop,e.id),n)}})}getWorldTransform(t){var p;const s=this.objectStates.get(t);if(!s)return{x:0,y:0,scaleX:1,scaleY:1,rotation:0};const o=(p=this.artboard)==null?void 0:p.objects.find(c=>c.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),i=e.rotation*(Math.PI/180),n=Math.cos(i),a=Math.sin(i),r=s.x*e.scaleX,l=s.y*e.scaleY,h=e.x+(r*n-l*a),f=e.y+(r*a+l*n);return{x:h,y:f,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,S;if(!this.objectStates.get(t.id))return!1;const i=((v=t.geometry)==null?void 0:v.width)??t.width??100,n=((S=t.geometry)==null?void 0:S.height)??t.height??100,a=this.getWorldTransform(t.id),r=s-a.x,l=o-a.y,h=-a.rotation*(Math.PI/180),f=Math.cos(h),p=Math.sin(h),c=r*f-l*p,d=r*p+l*f,u=a.scaleX,g=a.scaleY,y=i*Math.abs(u),b=n*Math.abs(g);return Math.abs(c)<=y/2&&Math.abs(d)<=b/2}updateSliderValueFromPointer(t,s,o){var M;const e=this.objectStates.get(t.id);if(!e)return;const i=t.options||{},n=((M=t.geometry)==null?void 0:M.width)??t.width??200,a=this.getWorldTransform(t.id),r=s-a.x,l=o-a.y,h=-a.rotation*(Math.PI/180),f=Math.cos(h),p=Math.sin(h),c=r*f-l*p,d=i.thumbWidth??16,u=n-d;let y=(c+u/2)/u;y=Math.max(0,Math.min(1,y));const b=i.min??0,v=i.max??100,S=i.step||1;let C=b+y*(v-b);S>0&&(C=Math.round(C/S)*S),C=Math.max(b,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 i=(e==null?void 0:e.width)!==void 0?e.width:((M=t.geometry)==null?void 0:M.width)??t.width??100,n=(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,h=-a.rotation*(Math.PI/180),f=Math.cos(h),p=Math.sin(h);let c=(r*f-l*p)/Math.max(.001,Math.abs(a.scaleX||1)),d=(r*p+l*f)/Math.max(.001,Math.abs(a.scaleY||1));t.handleOrigin==="top-left"?(c-=i/2,d-=n/2):t.handleOrigin==="bottom-right"&&(c+=i/2,d+=n/2);const u=Math.min(i,n)*.45,g=Math.min(i,n)*.15,y=u-g;let b=c/y,v=d/y;const S=Math.sqrt(b*b+v*v);t.boundsShape==="square"?(b=Math.max(-1,Math.min(1,b)),v=Math.max(-1,Math.min(1,v))):S>1&&(b/=S,v/=S),t.deadzone!==void 0&&S<t.deadzone?(b=0,v=0):(t.stepX!==void 0&&t.stepX>0&&(b=Math.round(b/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"&&(b=0);const C=e.handleX,w=e.handleY;(C!==b||w!==v)&&(e.handleX=b,e.handleY=v,t.handleX=b,t.handleY=v)}processJoysticks(t){this.artboard&&(this.artboard.objects.forEach(s=>{var a,r;if(s.type!=="Joystick"&&!(s.type==="Component"&&s.variant==="joystick"))return;const o=s,e=this.objectStates.get(o.id);if(!e)return;let i=e.handleX??o.handleX??0,n=e.handleY??o.handleY??0;if(((a=o.inputBinding)==null?void 0:a.type)==="keyboard"&&o.inputBinding.keyboardConfig){const l=o.inputBinding.keyboardConfig;let h=i,f=n;const c=(l.speed||5)*t;let d=!1;this.activeKeys.has(l.upKey.toLowerCase())&&(f-=c,d=!0),this.activeKeys.has(l.downKey.toLowerCase())&&(f+=c,d=!0),this.activeKeys.has(l.leftKey.toLowerCase())&&(h-=c,d=!0),this.activeKeys.has(l.rightKey.toLowerCase())&&(h+=c,d=!0),o.joystickType==="1D_X"&&(f=0),o.joystickType==="1D_Y"&&(h=0);const u=Math.sqrt(h*h+f*f);u>1&&(h/=u,f/=u),!d&&o.isSpringReturn!==!1&&(h+=(0-h)*(10*t),f+=(0-f)*(10*t),Math.abs(h)<.01&&(h=0),Math.abs(f)<.01&&(f=0)),i=h,n=f}else if(((r=o.inputBinding)==null?void 0:r.type)==="mouse"&&o.inputBinding.mouseConfig){const l=o.inputBinding.mouseConfig;let h=i,f=n;const p=l.sensitivity||.01,c=Math.abs(this._mouseDelta.dx)>0||Math.abs(this._mouseDelta.dy)>0;l.axisX&&(h+=this._mouseDelta.dx*p),l.axisY&&(f+=this._mouseDelta.dy*p),o.joystickType==="1D_X"&&(f=0),o.joystickType==="1D_Y"&&(h=0);const d=Math.sqrt(h*h+f*f);d>1&&(h/=d,f/=d),!c&&o.isSpringReturn!==!1&&(h+=(0-h)*(10*t),f+=(0-f)*(10*t),Math.abs(h)<.01&&(h=0),Math.abs(f)<.01&&(f=0)),i=h,n=f}if(e.handleX=i,e.handleY=n,o.handleX=i,o.handleY=n,o.bindings&&o.bindings.length>0){const l=Math.sqrt(i*i+n*n);let h=Math.atan2(n,i)*(180/Math.PI);h<0&&(h+=360),o.bindings.forEach(f=>{var d,u,g,y,b,v,S,C;let p=0;f.sourceAxis==="x"?p=o.invertX?-i:i:f.sourceAxis==="y"?p=o.invertY?-n:n:f.sourceAxis==="distance"?p=l:f.sourceAxis==="angle"&&(p=h);const c=(d=this.artboard)==null?void 0:d.objects.find(w=>w.id===f.targetObjectId);if(c){if(f.actionType==="bind"&&f.targetProperty&&f.isContinuous!==!1){const w=f.sourceMin??-1,M=f.sourceMax??1,I=f.targetMin??0,k=f.targetMax??100;let P=!!f.isContinuous,E=0,_=0;if(P){if((f.sourceAxis==="x"||f.sourceAxis==="y")&&I>=0){const A=Math.max(Math.abs(w),Math.abs(M))||1;_=p/A*k}else{let A=(p-w)/(M-w);A=Math.max(0,Math.min(1,A)),_=I+A*(k-I)}Math.abs(p)<.05&&(_=0)}else{const A=(p-w)/(M-w),L=Math.max(0,Math.min(1,A));E=I+L*(k-I),f.step&&f.step>0&&(E=Math.round(E/f.step)*f.step)}const T=this.objectStates.get(c.id);if(T){const A=f.isRelative!==!1,L=A?((u=c.transform)==null?void 0:u.x)??0:0,X=A?((g=c.transform)==null?void 0:g.y)??0:0,D=A?((y=c.transform)==null?void 0:y.rotation)??0:0,$=A?((b=c.transform)==null?void 0:b.scale_x)??1:0,G=A?((v=c.transform)==null?void 0:v.scale_y)??1:0,H=A?((S=c.style)==null?void 0:S.opacity)??100:0,et=t*60,O=(x,st)=>{let Q=E;if(P){const lt=`_internal_${x}_${f.id}`;let F=T[lt];F===void 0&&(F=T[x]??st),Q=F+_*et,T[lt]=Q,f.step&&f.step>0&&(Q=Math.round(Q/f.step)*f.step)}else Q=st+E;T[x]=Q};f.targetProperty==="x"||f.targetProperty==="transform.x"?O("x",L):f.targetProperty==="y"||f.targetProperty==="transform.y"?O("y",X):f.targetProperty==="rotation"||f.targetProperty==="r"||f.targetProperty==="transform.rotation"?O("rotation",D):f.targetProperty==="scaleX"||f.targetProperty==="transform.scale_x"?O("scale_x",$):f.targetProperty==="scaleY"||f.targetProperty==="transform.scale_y"?O("scale_y",G):(f.targetProperty==="opacity"||f.targetProperty==="transform.opacity")&&O("opacity",H)}(C=c.physics)!=null&&C.enabled&&this.physicsEngine&&(f.targetProperty==="x"||f.targetProperty==="transform.x"||f.targetProperty==="y"||f.targetProperty==="transform.y")&&(f.targetProperty==="x"||f.targetProperty==="transform.x"?this.physicsEngine.applyForce(c.id,(E-((T==null?void 0:T.x)||0))*10,0):(f.targetProperty==="y"||f.targetProperty==="transform.y")&&this.physicsEngine.applyForce(c.id,0,(E-((T==null?void 0:T.y)||0))*10))}else if(f.actionType==="playAnimation"||f.actionType==="stopAnimation"||f.actionType==="pauseAnimation"){let w=!1;const M=f.threshold??0;f.condition==="always"?w=!0:f.condition===">"?w=p>M:f.condition==="<"?w=p<M:f.condition==="=="&&(w=Math.abs(p-M)<.01);const I=e[`_prev_src_${f.id}`]??p;let k=!1;f.condition==="always"?k=!0:f.condition===">"?k=I>M:f.condition==="<"?k=I<M:f.condition==="=="&&(k=Math.abs(I-M)<.01),e[`_prev_src_${f.id}`]=p,w&&!k&&f.targetAnimationId&&(f.actionType==="playAnimation"||f.actionType)}}})}}),this._mouseDelta.dx=0,this._mouseDelta.dy=0)}applyBlendState(t,s){var l,h,f,p,c,d,u,g;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 i=[];let n=0;if(t.blendType==="1D"){const y=[...t.blendAnimations].sort((b,v)=>b.position[0]-v.position[0]);if(y.length===1){const b=(h=(l=this.artboard)==null?void 0:l.animations)==null?void 0:h.find(v=>v.id===y[0].animationId);b&&(i.push({anim:b,weight:1}),n=1)}else{let b=0;for(;b<y.length-1&&y[b+1].position[0]<o;)b++;if(b===y.length-1&&o>y[b].position[0]){const v=(p=(f=this.artboard)==null?void 0:f.animations)==null?void 0:p.find(S=>S.id===y[b].animationId);v&&(i.push({anim:v,weight:1}),n=1)}else{const v=y[b].position[0],S=y[b+1].position[0],C=(d=(c=this.artboard)==null?void 0:c.animations)==null?void 0:d.find(P=>P.id===y[b].animationId),w=(g=(u=this.artboard)==null?void 0:u.animations)==null?void 0:g.find(P=>P.id===y[b+1].animationId),M=Math.max(.001,S-v);let I=(o-v)/M;I=Math.max(0,Math.min(1,I));const k=1-I;C&&(i.push({anim:C,weight:k}),n+=k),w&&(i.push({anim:w,weight:I}),n+=I)}}}else t.blendAnimations.forEach(y=>{var w,M;const b=(M=(w=this.artboard)==null?void 0:w.animations)==null?void 0:M.find(I=>I.id===y.animationId);if(!b)return;const v=y.position[0]-o,S=y.position[1]-e,C=v*v+S*S;if(C<1e-4)i.push({anim:b,weight:1e4}),n+=1e4;else{const I=1/C;i.push({anim:b,weight:I}),n+=I}});if(n===0)return;i.forEach(y=>y.weight/=n);const a=new Map,r=y=>{let b=y.startsWith("#")?y.substring(1):y;return b.length===3&&(b=[b[0],b[0],b[1],b[1],b[2],b[2]].join("")),b="0x"+b,{r:b>>16&255,g:b>>8&255,b:b&255,a:1}};i.forEach(({anim:y,weight:b})=>{y.tracks&&y.tracks.forEach(v=>{var E,_;const S=v.object_id||v.objectId,C=v.property,w=(E=this.artboard)==null?void 0:E.objects.find(T=>T.id===S);if(((_=w==null?void 0:w.physics)==null?void 0:_.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 k=a.get(S);k||(k=new Map,a.set(S,k));let P=k.get(C);if(!P){if(typeof I=="number")P={type:"number",value:0};else if(typeof I=="string"&&I.startsWith("#"))P={type:"color",value:I,colorAcc:{r:0,g:0,b:0,a:0}};else if(P={type:"number",value:I},b<.5)return;k.set(C,P)}if(P.type==="number"&&typeof I=="number")P.value+=I*b;else if(P.type==="color"&&typeof I=="string"&&P.colorAcc){const T=r(I);T&&(P.colorAcc.r+=T.r*b,P.colorAcc.g+=T.g*b,P.colorAcc.b+=T.b*b,P.colorAcc.a+=T.a*b)}else b>.5&&(P.value=I)})}),a.forEach((y,b)=>{var C;const v=this.objectStates.get(b),S=(C=this.artboard)==null?void 0:C.objects.find(w=>w.id===b);!v||!S||y.forEach((w,M)=>{let I=w.value;if(w.type==="color"&&w.colorAcc){const k=Math.round(w.colorAcc.r).toString(16).padStart(2,"0"),P=Math.round(w.colorAcc.g).toString(16).padStart(2,"0"),E=Math.round(w.colorAcc.b).toString(16).padStart(2,"0");I=`#${k}${P}${E}`}if(M.includes(".")||M.includes("[")){const k=(M||"").replace(/\[(\d+)\]/g,".$1").split(".");let P=v;for(let E=0;E<k.length-1;E++){if(typeof P[k[E]]!="object"||P[k[E]]===null){let _=S;for(let T=0;T<=E;T++)_=_?_[k[T]]:null;if(k[E]==="corner_radius"||k[E]==="cornerRadius"){const T=typeof P[k[E]]=="number"?P[k[E]]:typeof _=="number"?_:0;P[k[E]]={tl:T,tr:T,bl:T,br:T}}else{const T=k[E+1],A=!isNaN(Number(T));P[k[E]]=_?JSON.parse(JSON.stringify(_)):A?[]:{}}}P=P[k[E]]}P[k[k.length-1]]=I,k[k.length-1]==="color"&&(k[k.length-2]==="fill"||k[k.length-2]==="stroke")&&(P.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 f,p,c;const i=e.object_id||e.objectId;if(o){if(Array.isArray(o)){if(!o.includes(i))return}else if(i!==o)return}const n=(f=this.artboard)==null?void 0:f.objects.find(d=>d.id===i),a=((p=n==null?void 0:n.physics)==null?void 0:p.enabled)&&n.physics.bodyType!=="Static";let r=e.property;if(a&&(r==="x"||r==="y"||r==="rotation"))return;const l=this.objectStates.get(i);if(!l){this.frameCount%600===0&&this.debugLog(`Skipping track: Object ${i} not found in state`);return}const h=this.interpolate(e.keyframes,s);if(h!==void 0){if(this.frameCount%240===0){const d=(n==null?void 0:n.name)||i,u=typeof h=="object"?JSON.stringify(h).slice(0,50):h;this.debugLog(`[Anim] Applying ${r} = ${u} to ${d}`)}if(r.includes(".")||r.includes("[")){const d=(r||"").replace(/\[(\d+)\]/g,".$1").split(".");let u=l;for(let g=0;g<d.length-1;g++){if(typeof u[d[g]]!="object"||u[d[g]]===null){let y=n;for(let b=0;b<=g;b++)y=y?y[d[b]]:null;if(d[g]==="corner_radius"||d[g]==="cornerRadius"){const b=typeof u[d[g]]=="number"?u[d[g]]:typeof y=="number"?y:0;u[d[g]]={tl:b,tr:b,bl:b,br:b}}else{const b=d[g+1],v=!isNaN(Number(b));u[d[g]]=y?JSON.parse(JSON.stringify(y)):v?[]:{}}}u=u[d[g]]}u[d[d.length-1]]=h,d[d.length-1]==="color"&&(d[d.length-2]==="fill"||d[d.length-2]==="stroke")&&(u.type="Solid")}else r==="fill"?(l.style||(l.style={}),l.style.fill=h):r==="stroke"?(l.style||(l.style={}),l.style.stroke=h):l[r]=h;if(this.physicsEngine&&((c=n==null?void 0:n.physics)!=null&&c.enabled)&&n.physics.bodyType==="Static")if(r==="x"){const d=this.physicsEngine.getPosition(i);d&&this.physicsEngine.setPosition(i,h,d.y)}else if(r==="y"){const d=this.physicsEngine.getPosition(i);d&&this.physicsEngine.setPosition(i,d.x,h)}else r==="rotation"&&this.physicsEngine.setRotation(i,h*(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 i=e.time-o.time;let n=(s-o.time)/i;return o.easing&&(n=si(o.easing)(n)),this.interpolateValue(o.value,e.value,n)}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),i=parseFloat(s);return!isNaN(e)&&!isNaN(i)?Math.round(e+(i-e)*o).toString():o<.5?t:s}if(Array.isArray(t)&&Array.isArray(s))return t.length===s.length?t.map((e,i)=>this.interpolateValue(e,s[i],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(n=>{e[n]=this.interpolateValue(t[n],s[n],o)}),e}return typeof t=="number"&&typeof s=="number"?t+(s-t)*o:o<.5?t:s}interpolateColor(t,s,o){var d,u;const e=((u=(d=this.artboard)==null?void 0:d.tokens)==null?void 0:u.colors)||{},i=e[t]||t,n=e[s]||s,a=g=>{if(!g)return{r:0,g:0,b:0};const y=g.startsWith("#")?g.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(i),l=a(n),h=Math.round(r.r+(l.r-r.r)*o),f=Math.round(r.g+(l.g-r.g)*o),p=Math.round(r.b+(l.b-r.b)*o),c=g=>{const y=Math.max(0,Math.min(255,g)).toString(16);return y.length===1?"0"+y:y};return`#${c(h)}${c(f)}${c(p)}`}interpolateStops(t,s,o){return!t||!s||t.length!==s.length?o<.5?t:s:t.map((e,i)=>{const n=s[i];return{offset:e.offset+(n.offset-e.offset)*o,color:this.interpolateColor(e.color,n.color,o),opacity:(e.opacity??1)+((n.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 f;this.debug_objectsTotal=((f=this.artboard)==null?void 0:f.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 i=this.artboard.width,n=this.artboard.height,a=this.calculateTransform(s,o,i,n,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,i,n)),this.artboard.backgroundImage){const p=this.artboard.backgroundImage;let c=this.imageCache.get(p);if(c||(c=new Image,c.src=p,this.imageCache.set(p,c)),c.complete&&c.naturalWidth>0){t.save(),t.globalAlpha=this.normalizeOpacity(this.artboard.backgroundOpacity??100);const d=c.naturalWidth/c.naturalHeight,u=i/n;let g,y,b,v;u>d?(g=i,y=i/d):(y=n,g=n*d),b=(i-g)/2,v=(n-y)/2,t.drawImage(c,b,v,g,y),t.restore()}}(this.artboard.clipContent===!0||this.artboard.clip_content===!0)&&(t.beginPath(),t.rect(0,0,i,n),t.clip());const l=new Map;this.artboard.objects.forEach(p=>l.set(p.id,p)),this.artboard.objects.filter(p=>!p.parentId).map((p,c)=>{const d=this.objectStates.get(p.id),u=(d==null?void 0:d.zIndex)??c;return{obj:p,zIndex:u}}).sort((p,c)=>p.zIndex-c.zIndex).forEach(({obj:p})=>{this.renderObject(t,p,l)}),this._emitterPools.forEach((p,c)=>{if(!(p.length===0||!l.get(c)))for(const u of p)t.save(),t.globalAlpha=u.opacity,t.fillStyle=u.color,t.beginPath(),t.arc(u.x,u.y,Math.max(1,u.size*u.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,i,n=0){const a=t.getTransform(),r=s*a.a+o*a.c+a.e,l=s*a.b+o*a.d+a.f,h=Math.sqrt(a.a*a.a+a.b*a.b),f=Math.sqrt(a.c*a.c+a.d*a.d),p=(e/2+n)*h,c=(i/2+n)*f;return r+p>=0&&r-p<=this.canvasWidth&&l+c>=0&&l-c<=this.canvasHeight}calculateTransform(t,s,o,e,i,n){let a=1,r=1,l=1;const h=o/e,f=t/s;switch(i){case"Contain":f>h?l=s/e:l=t/o,a=r=l;break;case"Cover":f>h?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 p=o*a,c=e*r;let d=0,u=0;return n.includes("Left")?d=0:n.includes("Right")?d=t-p:d=(t-p)/2,n.includes("Top")?u=0:n.includes("Bottom")?u=s-c:u=(s-c)/2,{scaleX:a,scaleY:r,tx:d,ty:u}}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,i,n){t.beginPath();const a=Math.max(1,n/14);let r=e;s==="underline"?r=e+n*.12:s==="line-through"&&(r=e-n*.3),t.lineWidth=a,t.strokeStyle=t.fillStyle,t.moveTo(o-i/2,r),t.lineTo(o+i/2,r),t.stroke()}renderObject(t,s,o,e=!1,i=!1){var v,S,C,w,M,I,k,P,E,_,T,A,L,X,D,$,G,H,et,O,x,st,Q,lt,F,W,z,nt;const n=this.objectStates.get(s.id);if(!n){this.warn("No state for object:",s.id);return}this.frameCount%60,t.roundRect||(t.roundRect=(N,pt,yt,dt,wt)=>(this.drawRoundRect(t,N,pt,yt,dt,wt),t));const a=n.geometry?this.deepMerge(s.geometry,n.geometry):s.geometry;let r=n.style?this.deepMerge(s.style,n.style):s.style,l=(a==null?void 0:a.width)||((v=s.geometry)==null?void 0:v.width)||s.width||0,h=(a==null?void 0:a.height)||((S=s.geometry)==null?void 0:S.height)||s.height||0;if((l===0||h===0)&&(a!=null&&a.points)&&Array.isArray(a.points)&&a.points.length>0){let N=1/0,pt=-1/0,yt=1/0,dt=-1/0;a.points.forEach(wt=>{N=Math.min(N,wt.x),pt=Math.max(pt,wt.x),yt=Math.min(yt,wt.y),dt=Math.max(dt,wt.y)}),l===0&&(l=pt-N),h===0&&(h=dt-yt)}const f=N=>{if(N)return N.corner_radius??N.cornerRadius},p=f(n)??f(r)??f(a)??f(s.style)??f(s.geometry)??0;let c={...a,width:l,height:h};if(delete c.cornerRadius,c.corner_radius=p,!c.type&&(s.type==="Frame"||s.type==="Component"||s.type==="Group")&&(c.type="Rectangle"),c.type==="Path"&&s.weights&&s.bindMatrices&&c.points){const N=this.getGlobalTransform(s.id);if(N){const pt=ii(c.points,s.weights,s.bindMatrices,N,yt=>this.getGlobalTransform(yt));c={...c,points:pt}}}if(n.visible===!1)return;const u=(r.effects||((C=s.style)==null?void 0:C.effects)||[]).find(N=>N.isEnabled!==!1&&N.type==="PathDistortion");if(u){const N=oi(c,l,h,u.amplitude||5,u.frequency||10,u.seed||0,u.direction||0,u.directionStrength||0);c={...c,type:"Path",points:N}}const g=s.repeaterConfig,y=g&&g.isEnabled&&g.count>1,b=y?g.count:1;for(let N=0;N<b;N++){let pt=n.x!==void 0?n.x:((w=n.transform)==null?void 0:w.x)??0,yt=n.y!==void 0?n.y:((M=n.transform)==null?void 0:M.y)??0,dt=n.rotation!==void 0?n.rotation:((I=n.transform)==null?void 0:I.rotation)??0,wt=n.scale_x!==void 0?n.scale_x:((k=n.transform)==null?void 0:k.scale_x)??1,Pt=n.scale_y!==void 0?n.scale_y:((P=n.transform)==null?void 0:P.scale_y)??1;if(y&&N>0){if(g.type==="Linear"){const ot=g.offsetX||0,ct=g.offsetY||0,it=g.rotation||0,R=g.scale!==void 0?g.scale:1;pt+=N*ot,yt+=N*ct,dt+=N*it,wt*=Math.pow(R,N),Pt*=Math.pow(R,N)}else if(g.type==="Grid"){const ot=g.cols||Math.ceil(Math.sqrt(g.count)),ct=g.gapX||0,it=g.gapY||0,R=Math.floor(N/ot),Z=N%ot,q=l+ct,mt=h+it;pt+=Z*q,yt+=R*mt}else if(g.type==="Radial"){const ot=g.radius||100,ct=g.startAngle||0,R=(g.endAngle||360)-ct,Z=g.count>1?R/(R===360?g.count:g.count-1):0,q=ct+N*Z,mt=q*Math.PI/180;pt=n.x+ot*Math.cos(mt),yt=n.y+ot*Math.sin(mt),dt+=q}}const _t=s.type==="Group"||s.type==="Frame"||s.type==="Component",Ut=l>0&&h>0;if(!_t&&Ut&&!e){const ot=(((E=r.shadow)==null?void 0:E.isEnabled)!==!1?(((_=r.shadow)==null?void 0:_.blur)||0)+10:0)+(((T=r.blur)==null?void 0:T.isEnabled)!==!1&&((A=r.blur)==null?void 0:A.radius)||0)+20;if(!this.isObjectInView(t,pt,yt,l,h,ot))continue}this.debug_objectsRendered++,t.save();const j=[],gt=r.blur||((L=s.style)==null?void 0:L.blur);gt&&gt.amount>0&&j.push(`blur(${gt.amount}px)`);const Rt=r.effects||((X=s.style)==null?void 0:X.effects)||[];let It=Rt.find(ot=>ot.isEnabled!==!1&&(ot.type==="BackgroundBlur"||ot.type==="LayerBlur"));It||(It=r.effect||((D=s.style)==null?void 0:D.effect)||Rt.find(ot=>ot.isEnabled!==!1));const bt=It,Ft=(bt==null?void 0:bt.isEnabled)!==!1,Bt=bt==null?void 0:bt.type,zt=(bt==null?void 0:bt.radius)??10;Ft&&Bt==="LayerBlur"?j.push(`blur(${zt}px)`):Ft&&Bt==="BackgroundBlur"&&(r===s.style&&(r={...r}),r.fill={type:"None"});const Gt=(($=a==null?void 0:a.type)==null?void 0:$.toLowerCase().includes("image"))||((G=s.type)==null?void 0:G.toLowerCase().includes("image")),qt=r.adjustments&&Object.keys(r.adjustments).length>0?r.adjustments:null,ce=a!=null&&a.adjustments&&Object.keys(a.adjustments).length>0?a.adjustments:null,ve=Gt?ce||qt:qt||ce,Ht=Gt&&!ve?{exposure:0,contrast:0,saturation:100,temperature:0,tint:0,highlights:0,shadows:0,blur:0,negative:0,hue:0}:ve;if(n&&Ht&&(n.geometry=n.geometry||{},n.geometry.adjustments={...Ht}),Ht){const ot=(Ht.exposure||0)/100,ct=Ht.contrast||0,it=1+(Ht.saturation||0)/100,R=(Ht.temperature||0)/200,Z=(Ht.tint||0)/200,q=(Ht.highlights||0)/500,mt=(Ht.shadows||0)/500;let Et="",kt="SourceGraphic";if(ot!==0&&(Et+=`
8
+ <feComponentTransfer in="${kt}" result="exposure">
9
9
  <feFuncR type="linear" slope="1" intercept="${ot}"/>
10
10
  <feFuncG type="linear" slope="1" intercept="${ot}"/>
11
11
  <feFuncB type="linear" slope="1" intercept="${ot}"/>
12
- </feComponentTransfer>`,Pt="exposure"),ft!==0){const kt=(ft+100)/100,At=.5*(1-kt);vt+=`
13
- <feComponentTransfer in="${Pt}" result="contrast">
14
- <feFuncR type="linear" slope="${kt}" intercept="${At}"/>
15
- <feFuncG type="linear" slope="${kt}" intercept="${At}"/>
16
- <feFuncB type="linear" slope="${kt}" intercept="${At}"/>
17
- </feComponentTransfer>`,Pt="contrast"}if(it!==1&&(vt+=`<feColorMatrix in="${Pt}" type="saturate" values="${it}" result="saturate"/>`,Pt="saturate"),Yt.hue&&(vt+=`<feColorMatrix in="${Pt}" type="hueRotate" values="${Yt.hue}" result="hue"/>`,Pt="hue"),Yt.negative){const kt=1-Yt.negative/50;vt+=`
18
- <feColorMatrix in="${Pt}" type="matrix" result="invert"
19
- values="${kt} 0 0 0 ${1-kt}
20
- 0 ${kt} 0 0 ${1-kt}
21
- 0 0 ${kt} 0 ${1-kt}
22
- 0 0 0 1 0"/>`,Pt="invert"}if(G!==0||at!==0||V!==0||dt!==0){const kt=1+V+dt,At=kt*(1+G-at/2),$=kt*(1+at),Xt=kt*(1-G-at/2),ne=Yt.shadows*.1/255,ie=[At,0,0,0,ne,0,$,0,0,ne,0,0,Xt,0,ne,0,0,0,1,0].join(" ");vt+=`<feColorMatrix in="${Pt}" type="matrix" values="${ie}" result="advanced"/>`,Pt="advanced"}if(Yt.blur&&(vt+=`<feGaussianBlur in="${Pt}" stdDeviation="${Yt.blur}" result="blur"/>`,Pt="blur"),vt){const kt=`<svg xmlns="http://www.w3.org/2000/svg"><filter id="f" color-interpolation-filters="sRGB">${vt}</filter></svg>`,At=btoa(kt);re.push(`url('data:image/svg+xml;base64,${At}#f')`)}}re.length>0?t.filter=re.join(" "):t.filter="none",t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high";const we=t.globalAlpha,Me=this.normalizeOpacity(n.opacity!==void 0?n.opacity:100);t.globalAlpha=we*Me;const Zt=n.compositeOperation||n.blendMode;if(Zt&&Zt!=="Normal"){const ot=Zt.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(ot)&&(t.globalCompositeOperation=ot)}const le=t,Ee=n.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 Ie=!1;const ke=Ee.filter(ot=>ot.isVisible!==!1&&o.has(ot.maskId));if(ke.length>0){const ot=ke[0],ft=o.get(ot.maskId),it=this.objectStates.get(ft.id);it&&it.visible!==!1&&(Ie=!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=le.filter)}if(!i){t.translate(Math.round(gt),Math.round(mt)),t.rotate(ut*Math.PI/180);const ot=n.skew_x||0,ft=n.skew_y||0;if(ot!==0||ft!==0){const Pt=Math.tan(ot*Math.PI/180),Ht=Math.tan(ft*Math.PI/180);t.transform(1+Pt*Ht,Ht,Pt,1,0,0)}const it=n.rotate_x!==void 0?n.rotate_x:((H=n.transform)==null?void 0:H.rotate_x)??0,G=n.rotate_y!==void 0?n.rotate_y:((Q=n.transform)==null?void 0:Q.rotate_y)??0,V=1+(n.translate_z!==void 0?n.translate_z:((L=n.transform)==null?void 0:L.translate_z)??0)/1e3,dt=(n.flip_x===!0?-1:1)*Math.cos(G*Math.PI/180)*V,vt=(n.flip_y===!0?-1:1)*Math.cos(it*Math.PI/180)*V;t.scale(wt*dt,Mt*vt)}r.shadow&&r.shadow.isEnabled!==!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 de=r.shadow;if(de&&de.isEnabled!==!1&&!e){let ot=de.color||"#000000";(et=(R=this.artboard)==null?void 0:R.tokens)!=null&&et.colors&&this.artboard.tokens.colors[ot]&&(ot=this.artboard.tokens.colors[ot]);const ft=this.normalizeOpacity(de.opacity??100)*.75,it=de.spread||0,at=(de.blur||0)+it*1.5;let V=ot;if(ot.startsWith("#")){const Pt=ot.replace("#",""),Ht=parseInt(Pt.substring(0,2),16),kt=parseInt(Pt.substring(2,4),16),At=parseInt(Pt.substring(4,6),16);V=`rgba(${Ht}, ${kt}, ${At}, ${ft})`}else if(ot.startsWith("rgba")){const Pt=ot.match(/[\d.]+/g);if(Pt&&Pt.length>=4){const Ht=Pt[0],kt=Pt[1],At=Pt[2],$=Pt[3];V=`rgba(${Ht}, ${kt}, ${At}, ${parseFloat($)*ft})`}}const dt=t.getTransform(),vt=Math.sqrt(dt.a*dt.a+dt.b*dt.b)||1;t.shadowColor=V,t.shadowBlur=at*vt,t.shadowOffsetX=(de.offsetX||0)*vt,t.shadowOffsetY=(de.offsetY||0)*vt}const pe=s.liquidFill||((U=s.style)==null?void 0:U.liquidFill);if(pe&&pe.enabled){t.save();const ot=pe.fillLevel??.5;t.beginPath();const ft=f/2-f*ot;t.rect(-l/2,ft,l,f*ot),t.clip(),t.fillStyle=pe.color||"#3b82f6",t.globalAlpha=t.globalAlpha*(pe.opacity??1)}if(e||this.applyOuterGlowUnderlay(t,s,c,l,f,u,r,o),(a==null?void 0:a.type)==="Text")this._renderText(t,s,c,r,n,l,f,!1,!1,wt,Mt);else if((a==null?void 0:a.type)==="Image"){const ot=a.originalSrc||a.src;if(ot){let ft=this.imageCache.get(ot);ft||(ft=new Image,ft.onload=()=>{this.log(`[ExodeUI] Image loaded successfully, size: ${ft.naturalWidth}x${ft.naturalHeight}`)},ft.onerror=at=>{console.error("[ExodeUI] Image load failed:",at,`Src preview: ${ot.substring(0,100)}...`)},ft.src=ot,this.imageCache.set(ot,ft));const it=r.stroke&&r.stroke.width>0&&r.stroke.isEnabled!==!1,G=(((lt=r.stroke)==null?void 0:lt.alignment)||"center").toLowerCase();if(it&&(G==="outside"||G==="center")&&this.applyStrokeAlignment(t,r,c,l,f,u,wt,Mt),r.fill&&r.fill.type!=="None"){t.save();const at=t.globalAlpha,V=this.createCanvasFill(t,r.fill,l,f);t.fillStyle=V||r.fill.color||"transparent",t.globalAlpha=at*this.normalizeOpacity(r.fill.opacity??100),u!==0?(this.drawRoundRect(t,-l/2,-f/2,l,f,u),t.fill()):t.fillRect(-l/2,-f/2,l,f),t.globalAlpha=at,t.restore()}ft.complete&&ft.naturalWidth>0?(u!==0?(t.save(),this.drawRoundRect(t,-l/2,-f/2,l,f,u),t.clip(),t.drawImage(ft,-l/2,-f/2,l,f),t.restore()):t.drawImage(ft,-l/2,-f/2,l,f),it&&G==="inside"&&this.applyStrokeAlignment(t,r,c,l,f,u,wt,Mt)):it&&G==="inside"&&this.applyStrokeAlignment(t,r,c,l,f,u,wt,Mt)}}else if(a.type==="SVG"){const ot=a.svgContent;if(ot){const ft=r.palette||[],it=r.fill,G=r.stroke,at=it?this.normalizeOpacity(it.opacity??100):1,V=G&&G.isEnabled!==!1?this.normalizeOpacity(G.opacity??100):1,dt=(it==null?void 0:it.type)==="Solid"&&(!G||G.isEnabled===!1||G.type==="Solid"&&G.color===it.color&&V===at),vt=it&&it.type!=="None"?dt?"monochrome":it.type==="Solid"?(it.color||"")+"|opacity:"+at:JSON.stringify(it.stops||[])+"|opacity:"+at:"",Pt=G&&G.isEnabled!==!1&&(G.width||0)>0?dt?["monochrome",G.width||0,G.trimStart??0,G.trimEnd??1,G.trimOffset??0,G.dashOffset??0].join("|"):[G.width||0,G.fill?G.fill.type==="Solid"?G.fill.color||"":JSON.stringify(G.fill.stops||[]):G.color||"",G.opacity??1,G.lineCap||"",G.lineJoin||"",(G.dashArray||[]).join(","),G.trimStart??0,G.trimEnd??1,G.trimOffset??0,G.dashOffset??0].join("|"):"nostroke",Ht=[s.id,ft.join("_"),vt,Pt,n.opacity??100,n.visible!==!1?"v":"h"].join("_");let kt=this.imageCache.get(Ht);if(!kt){kt=new Image,kt.crossOrigin="anonymous";let $=ot;$.match(/xmlns=["']http:\/\/www\.w3\.org\/2000\/svg["']/i)||($=$.replace(/<svg([^>]*)>/i,(j,bt)=>`<svg xmlns="http://www.w3.org/2000/svg"${bt}>`));let Xt=a.width||l||100,ne=a.height||f||100;const ie=$.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(ie&&(Xt=parseFloat(ie[1]),ne=parseFloat(ie[2])),$=$.replace(/<svg([^>]*)>/i,(j,bt)=>{let Y=bt.replace(/\b(?:width|height)=["'][^"']*["']/gi," ");return Y.match(/\bviewBox=/i)||(Y+=` viewBox="0 0 ${Xt} ${ne}"`),Y.match(/\bpreserveAspectRatio=/i)||(Y+=' preserveAspectRatio="none"'),Y+=' width="100%" height="100%"',`<svg${Y}>`}),a.colors&&a.colors.length>0&&ft.length>0&&a.colors.forEach((j,bt)=>{if(ft[bt]){const Y=j.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),rt=new RegExp(Y,"gi");$=$.replace(rt,ft[bt])}}),it&&it.type&&it.type!=="None"){if(it.type==="Solid"&&it.color){const j=dt?"#FFFFFF":it.color,bt=dt?1:this.normalizeOpacity(it.opacity??100);$=$.replace(/\bfill\s*=\s*["'][^"']*["']/gi,Y=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(Y)?Y:`fill="${j}"`),$=$.replace(/fill\s*:\s*[^;"')]+/gi,Y=>/fill\s*:\s*(none|transparent)/i.test(Y)?Y:`fill:${j}`),bt<1&&($=$.replace(/\bfill-opacity\s*=\s*["'][^"']*["']/gi,`fill-opacity="${bt}"`),$=$.replace(/fill-opacity\s*:\s*[^;"')]+/gi,`fill-opacity:${bt}`),$.match(/\bfill-opacity\s*=/i)||($=$.replace(/(<svg[^>]*>)/i,`$1<g fill-opacity="${bt}">`),$=$.replace(/<\/svg>/i,"</g></svg>")))}else if(it.type==="LinearGradient"||it.type==="RadialGradient"||it.type==="Linear"||it.type==="Radial"){const j="exode-fill",bt=this.normalizeOpacity(it.opacity??100),Y=(it.stops||[]).map(tt=>{const qt=tt.offset!==void 0?tt.offset:tt.pos??0,jt=this.normalizeOpacity(tt.opacity??100)*bt;return`<stop offset="${qt*100}%" stop-color="${tt.color||"#000"}" stop-opacity="${jt}"/>`}).join("");let rt="";if(it.type==="LinearGradient"||it.type==="Linear"){const tt=(te,Qt)=>Array.isArray(te)?te[Qt]??(Qt===0?0:1):te&&typeof te=="object"?te[Qt===0?"x":"y"]??(Qt===0?0:1):Qt===0?0:1,qt=tt(it.start,0)*100,jt=tt(it.start,1)*100,Se=tt(it.end,0)*100,Vt=tt(it.end,1)*100;rt=`<linearGradient id="${j}" x1="${qt}%" y1="${jt}%" x2="${Se}%" y2="${Vt}%" gradientUnits="objectBoundingBox">${Y}</linearGradient>`}else{const tt=(Vt,te)=>Array.isArray(Vt)?Vt[te]??.5:Vt&&typeof Vt=="object"?Vt[te===0?"x":"y"]??.5:.5,qt=tt(it.center,0)*100,jt=tt(it.center,1)*100,Se=(it.radius??.5)*100;rt=`<radialGradient id="${j}" cx="${qt}%" cy="${jt}%" r="${Se}%" gradientUnits="objectBoundingBox">${Y}</radialGradient>`}/<defs>/i.test($)?$=$.replace(/<defs>/i,`<defs>${rt}`):$=$.replace(/<svg([^>]*)>/i,`<svg$1><defs>${rt}</defs>`),$=$.replace(/\bfill\s*=\s*["'][^"']*["']/gi,tt=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(tt)?tt:`fill="url(#${j})"`),$=$.replace(/fill\s*:\s*[^;"')]+/gi,tt=>/fill\s*:\s*(none|transparent)/i.test(tt)?tt:`fill:url(#${j})`)}}const Nt=(j,bt,Y=1)=>{const rt=(j.stops||[]).map(Vt=>{const te=Vt.offset!==void 0?Vt.offset:Vt.pos??0,Qt=this.normalizeOpacity(Vt.opacity??100)*Y;return`<stop offset="${te*100}%" stop-color="${Vt.color||"#000"}" stop-opacity="${Qt}"/>`}).join(""),tt=(Vt,te,Qt=.5)=>Array.isArray(Vt)?Vt[te]??Qt:Vt&&typeof Vt=="object"?Vt[te===0?"x":"y"]??Qt:Qt;if(j.type==="LinearGradient"||j.type==="Linear"){const Vt=tt(j.start,0,0)*100,te=tt(j.start,1,0)*100,Qt=tt(j.end,0,1)*100,Te=tt(j.end,1,1)*100;return`<linearGradient id="${bt}" x1="${Vt}%" y1="${te}%" x2="${Qt}%" y2="${Te}%" gradientUnits="objectBoundingBox">${rt}</linearGradient>`}const qt=tt(j.center,0,.5)*100,jt=tt(j.center,1,.5)*100,Se=(j.radius??.5)*100;return`<radialGradient id="${bt}" cx="${qt}%" cy="${jt}%" r="${Se}%" gradientUnits="objectBoundingBox">${rt}</radialGradient>`},Rt=(j,bt)=>/<defs>/i.test(j)?j.replace(/<defs>/i,`<defs>${bt}`):j.replace(/(<svg[^>]*>)/i,`$1<defs>${bt}</defs>`);if(G&&G.isEnabled!==!1&&(G.width||0)>0){const j=dt?1:this.normalizeOpacity(G.opacity??100),bt=dt?"#FFFFFF":G.color||(it==null?void 0:it.color)||"#000000";let Y="";const rt=G.fill;if(rt&&rt.type){if(rt.type==="Solid")Y=rt.color||G.color||"#000000";else if(rt.type==="LinearGradient"||rt.type==="RadialGradient"||rt.type==="Linear"||rt.type==="Radial"){const Kt="exode-stroke";$=Rt($,Nt(rt,Kt,j)),Y=`url(#${Kt})`}}Y||(Y=bt),$.match(/\bstroke\s*=\s*["']/i)?$=$.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,Kt=>/stroke\s*=\s*["']\s*(none|transparent)\s*["']/i.test(Kt)?Kt:`stroke="${Y}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke="${Y}"`),$=$.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),`stroke:${Y}`);let tt=a.width||l||100,qt=a.height||f||100;const jt=ot.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(jt){const Kt=parseFloat(jt[1]),ae=parseFloat(jt[2]);!isNaN(Kt)&&!isNaN(ae)&&(tt=Kt,qt=ae)}const Se=Math.max(.001,l/tt),Vt=Math.max(.001,f/qt),te=(Se+Vt)/2,Qt=(G.width||1)/te;$.match(/\bstroke-width\s*=\s*["']/i)?$=$.replace(/\bstroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${Qt}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-width="${Qt}"`),$=$.replace(/stroke-width\s*:\s*[^;"')]+/gi,`stroke-width:${Qt}`),$.match(/\bstroke-opacity\s*=\s*["']/i)?$=$.replace(/\bstroke-opacity\s*=\s*["'][^"']*["']/gi,`stroke-opacity="${j}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-opacity="${j}"`),$=$.replace(/stroke-opacity\s*:\s*[^;"')]+/gi,`stroke-opacity:${j}`);const Te=G.lineCap||"round";$.match(/\bstroke-linecap\s*=\s*["']/i)?$=$.replace(/\bstroke-linecap\s*=\s*["'][^"']*["']/gi,`stroke-linecap="${Te}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linecap="${Te}"`),$=$.replace(/stroke-linecap\s*:\s*[^;"')]+/gi,`stroke-linecap:${Te}`);const Ae=G.lineJoin||"round";$.match(/\bstroke-linejoin\s*=\s*["']/i)?$=$.replace(/\bstroke-linejoin\s*=\s*["'][^"']*["']/gi,`stroke-linejoin="${Ae}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linejoin="${Ae}"`),$=$.replace(/stroke-linejoin\s*:\s*[^;"')]+/gi,`stroke-linejoin:${Ae}`);const Oe=G.trimStart??0,Le=G.trimEnd??1,xe=G.trimOffset??0,Re=G.dashOffset??0,Ye=Oe!==0||Le!==1||xe!==0||Re!==0;if(Ye){const Kt=Math.max(0,Math.min(1,Oe)),ae=Math.max(0,Math.min(1,Le));this.frameCount%600===0&&this.debugLog(`SVG Trim - Object: ${s.name||s.id}, Start: ${Kt}, End: ${ae}`);const ue=(tt+qt)*2,Fe=(xe%1+1)%1,$e=(Re%1+1)%1;let me="",ge=0;if(Kt>=ae)me=`0 ${ue}`,ge=0;else{const ye=ue*(ae-Kt),Pe=ue-ye;ge=-(ue*(Kt+Fe+$e)),me=`${ye} ${Pe}`}$.match(/\bstroke-dasharray\s*=/i)?$=$.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${me}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dasharray="${me}"`),$=$.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${me}`),$.match(/\bstroke-dashoffset\s*=/i)?$=$.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${ge}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dashoffset="${ge}"`),$=$.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${ge}`)}else if(G.dashArray&&G.dashArray.length>0){const Kt=G.dashArray.join(" ");if($=$.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${Kt}"`),$=$.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${Kt}`),G.dashOffset){const ae=(tt+qt)*2,ue=-(G.dashOffset*ae);$=$.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${ue}"`),$=$.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${ue}`)}}if(!/\bstroke\s*=\s*["']/i.test(ot)&&!new RegExp("(?<![a-z-])stroke\\s*:","i").test(ot)){let Kt="",ae="";if(Ye){const me=a.width||l||100,ge=a.height||f||100,ye=(me+ge)*2,Pe=Math.max(0,Math.min(1,Oe)),Xe=Math.max(0,Math.min(1,Le)),Ue=(xe%1+1)%1,qe=(Re%1+1)%1;if(Pe>=Xe)Kt=` stroke-dasharray="0 ${ye}"`,ae=' stroke-dashoffset="0"';else{const De=ye*(Xe-Pe),Ke=ye-De,Je=-(ye*(Pe+Ue+qe));Kt=` stroke-dasharray="${De} ${Ke}"`,ae=` stroke-dashoffset="${Je}"`}}else(x=G.dashArray)!=null&&x.length&&(Kt=` stroke-dasharray="${G.dashArray.join(" ")}"`,G.dashOffset&&(ae=` stroke-dashoffset="${G.dashOffset}"`));const ue=` stroke-linecap="${G.lineCap||"round"}"`,Fe=` stroke-linejoin="${G.lineJoin||"round"}"`,$e=`stroke="${Y}" stroke-width="${Qt}" stroke-opacity="${j}"${ue}${Fe}${Kt}${ae}`;$=$.replace(/(<svg[^>]*>)(\s*(?:<defs>[\s\S]*?<\/defs>)?)/i,(me,ge,ye)=>`${ge}${ye}<g ${$e}>`),$=$.replace(/<\/svg>/i,"</g></svg>")}}else G&&G.isEnabled===!1&&($=$.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,'stroke="none"'),$=$.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),"stroke:none"));const Ct=new Blob([$],{type:"image/svg+xml"}),ht=URL.createObjectURL(Ct);kt.onload=()=>{if(URL.revokeObjectURL(ht),this.frameCount%900===0){const j=this.imageCache.get(Ht);j&&this.debugLog(`SVG Payload Ready: ${s.name||s.id} (${j.naturalWidth}x${j.naturalHeight})`)}},kt.onerror=()=>{URL.revokeObjectURL(ht),this.debugLog(`SVG Error: Failed to load payload for ${s.name||s.id}`)},kt.src=ht,this.imageCache.set(Ht,kt)}let At=null;if(kt.complete&&kt.naturalWidth>0?(At=kt,this.lastValidSvgImgMap.set(s.id,kt)):At=this.lastValidSvgImgMap.get(s.id)||null,At&&At.complete&&At.naturalWidth>0){const $=Math.max(1,l),Xt=Math.max(1,f);if(dt&&(it==null?void 0:it.type)==="Solid"){this.maskBuffer||(this.maskBuffer=document.createElement("canvas"),this.maskCtx=this.maskBuffer.getContext("2d")),this.maskBuffer.width=$,this.maskBuffer.height=Xt,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,$,Xt),this.maskCtx.drawImage(At,0,0,$,Xt),this.maskCtx.globalCompositeOperation="source-in";const ne=it.color||"#000000",ie=this.normalizeOpacity(it.opacity??100);this.maskCtx.fillStyle=ne,this.maskCtx.globalAlpha=ie,this.maskCtx.fillRect(0,0,$,Xt),t.drawImage(this.maskBuffer,-$/2,-Xt/2,$,Xt)}else u!==0?(t.save(),this.drawRoundRect(t,-$/2,-Xt/2,$,Xt,u),t.clip(),t.drawImage(At,-$/2,-Xt/2,$,Xt),t.restore()):t.drawImage(At,-$/2,-Xt/2,$,Xt)}}}else if(c.type==="LineGraph")this.renderLineGraph(t,c,l,f);else if(s.type==="Shape"){if(this.applyPath(t,c,l,f,u),t.save(),r.blur&&r.blur.amount>0&&(t.filter=`blur(${r.blur.amount}px)`),_t&&St==="BackgroundBlur")if(e)t.fillStyle="#000000",t.globalAlpha=1,this.applyPath(t,c,l,f,u),t.fill();else{if(t.shadowColor&&t.shadowColor!=="rgba(0, 0, 0, 0)"&&t.shadowColor!=="transparent"){const it=t.getTransform(),G=t.shadowOffsetX,at=t.shadowOffsetY;t.shadowOffsetX=G+1e4*it.a,t.shadowOffsetY=at+1e4*it.b,t.save(),t.translate(-1e4,0),this.applyPath(t,c,l,f,u),t.fillStyle="white",t.fill(),t.restore(),t.shadowOffsetX=G,t.shadowOffsetY=at,t.shadowColor="transparent"}this.applyBackgroundBlurGlass(t,c,l,f,u,Tt,r)}else if(r.fill){const ft=t.globalAlpha;if(((F=r.fill)==null?void 0:F.type)==="Image"&&(r.fill.originalSrc||r.fill.src)){const it=r.fill.originalSrc||r.fill.src;let G=this.imageCache.get(it);G||(G=new Image,G.src=it,this.imageCache.set(it,G)),G.complete&&G.naturalWidth>0&&(t.save(),this.applyPath(t,c,l,f,u),t.clip(),this.renderFittedImage(t,G,-l/2,-f/2,l,f,r.fill.fillMode),t.restore())}else{const it=this.createCanvasFill(t,r.fill,l,f);t.fillStyle=it||(typeof r.fill=="string"?r.fill:r.fill.color||"transparent"),t.globalAlpha=ft*this.normalizeOpacity(r.fill.opacity??100),this.applyPath(t,c,l,f,u),t.fill()}t.globalAlpha=ft}t.restore(),r.stroke&&r.stroke.width>0&&(this.applyPath(t,c,l,f,u),this.applyStrokeAlignment(t,r,c,l,f,u,wt,Mt))}else if(s.type==="Frame"||s.type==="Component"&&!s.variant||s.type==="Group"&&!s.isStructuralGroup){const ot=n.width??a.width??s.width??l,ft=n.height??a.height??s.height??f,it=u;if(t.save(),t.beginPath(),this.drawRoundRect(t,-ot/2,-ft/2,ot,ft,it),_t&&St==="BackgroundBlur")if(e)t.fillStyle="#000000",t.globalAlpha=1,t.beginPath(),this.drawRoundRect(t,-ot/2,-ft/2,ot,ft,it),t.fill();else{if(t.shadowColor&&t.shadowColor!=="rgba(0, 0, 0, 0)"&&t.shadowColor!=="transparent"){const V=t.getTransform(),dt=t.shadowOffsetX,vt=t.shadowOffsetY;t.shadowOffsetX=dt+1e4*V.a,t.shadowOffsetY=vt+1e4*V.b,t.save(),t.translate(-1e4,0),t.beginPath(),this.drawRoundRect(t,-ot/2,-ft/2,ot,ft,it),t.fillStyle="white",t.fill(),t.restore(),t.shadowOffsetX=dt,t.shadowOffsetY=vt,t.shadowColor="transparent"}this.applyBackgroundBlurGlass(t,c,ot,ft,it,Tt,r)}else if(r.fill&&r.fill.type!=="None"){const at=t.globalAlpha;if(((N=r.fill)==null?void 0:N.type)==="Image"&&(r.fill.originalSrc||r.fill.src)){const V=r.fill.originalSrc||r.fill.src;let dt=this.imageCache.get(V);dt||(dt=new Image,dt.src=V,this.imageCache.set(V,dt)),dt.complete&&dt.naturalWidth>0&&(t.save(),t.beginPath(),this.drawRoundRect(t,-ot/2,-ft/2,ot,ft,it),t.clip(),this.renderFittedImage(t,dt,-ot/2,-ft/2,ot,ft,r.fill.fillMode),t.restore())}else{const V=this.createCanvasFill(t,r.fill,ot,ft);t.fillStyle=V||r.fill.color||"transparent",t.globalAlpha=at*this.normalizeOpacity(r.fill.opacity??100),t.beginPath(),this.drawRoundRect(t,-ot/2,-ft/2,ot,ft,it),t.fill(),t.globalAlpha=at}}if(t.restore(),!e&&(_t&&St==="BackgroundBlur"||r.fill&&r.fill.type!=="None")&&(t.shadowColor="transparent"),r.stroke&&r.stroke.width>0&&r.stroke.isEnabled!==!1){const at={type:"Rectangle"};t.beginPath(),this.drawRoundRect(t,-ot/2,-ft/2,ot,ft,it),this.applyStrokeAlignment(t,r,at,ot,ft,it,wt,Mt)}}else s.type==="Group"&&s.isStructuralGroup||(s.type==="Component"&&s.variant==="inputbox"?this.renderInputBox(t,s):s.type==="Component"&&s.variant==="button"?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"||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:",(st=s.geometry)==null?void 0:st.type));if(e||(this.applyInnerGlowOverlay(t,s,c,l,f,u,r),this.applyArtEffectOverlay(t,s,c,l,f,u)),pe&&pe.enabled&&t.restore(),s.children&&s.children.length>0){const ft=s.type==="Frame",it=s.clipsContent!==void 0?s.clipsContent:s.clipContent!==void 0?s.clipContent:ft;if(t.save(),it){t.beginPath();const at=n.width??(a==null?void 0:a.width)??s.width??0,V=n.height??(a==null?void 0:a.height)??s.height??0,dt=n.cornerRadius??(a==null?void 0:a.corner_radius)??s.cornerRadius??0;this.drawRoundRect(t,-at/2,-V/2,at,V,dt),t.clip()}let G=0;for(s.children.forEach(at=>{const V=o.get(at);if(!V)return;const dt=this.objectStates.get(at),vt=(dt==null?void 0:dt.geometry)||V.geometry;if(vt&&vt.isMask&&(dt==null?void 0:dt.visible)!==!1){const Pt=vt.width||0,Ht=vt.height||0;this.applyObjectTransform(t,at);const kt=(dt==null?void 0:dt.corner_radius)??(vt==null?void 0:vt.corner_radius)??0;this.applyPath(t,vt,Pt,Ht,kt),t.clip(),G++}else this.renderObject(t,V,o,e)});G>0;)t.restore(),G--;t.restore()}if(Ie){this.maskCtx.restore(),(n.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(G=>G.isVisible!==!1&&o.has(G.maskId)).forEach(G=>{var kt,At,$,Xt,ne,ie;const at=o.get(G.maskId),V=this.objectStates.get(at.id),dt=G.feather||0,vt=G.inverted===!0,Pt=G.opacity!==void 0?typeof G.opacity=="number"?G.opacity:G.opacity/100:1;if((G.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,at.id,o),dt>0&&(this.lumaCtx.filter=`blur(${dt}px)`),this.lumaCtx.globalAlpha=Pt;const Nt=(V==null?void 0:V.width)||at.geometry.width||0,Rt=(V==null?void 0:V.height)||at.geometry.height||0,Ct=(V==null?void 0:V.corner_radius)??at.corner_radius??0;if(((kt=at.geometry)==null?void 0:kt.type)==="Text"){const Y=V!=null&&V.geometry?this.deepMerge(at.geometry,V.geometry):at.geometry,rt=V!=null&&V.style?this.deepMerge(at.style,V.style):at.style;this._renderText(this.lumaCtx,at,{...Y,width:Nt,height:Rt,corner_radius:Ct},rt,V,Nt,Rt,!0,!1,wt,Mt)}else if(((At=at.geometry)==null?void 0:At.type)==="Image"){const Y=at.geometry.src;if(Y){let rt=this.imageCache.get(Y);rt||(rt=new Image,rt.src=Y,this.imageCache.set(Y,rt)),rt.complete&&rt.naturalWidth>0?this.lumaCtx.drawImage(rt,-Nt/2,-Rt/2,Nt,Rt):(this.applyPath(this.lumaCtx,at.geometry,Nt,Rt,Ct),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else if((($=at.geometry)==null?void 0:$.type)==="SVG"){const Y=at.geometry.svgContent;if(Y){const rt=`__lumamask_${at.id}`;let tt=this.imageCache.get(rt);if(!tt){tt=new Image;const qt=new Blob([Y],{type:"image/svg+xml"});tt.src=URL.createObjectURL(qt),tt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(rt,tt)}tt.complete&&tt.naturalWidth>0?this.lumaCtx.drawImage(tt,-Nt/2,-Rt/2,Nt,Rt):(this.applyPath(this.lumaCtx,at.geometry,Nt,Rt,Ct),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else this.applyPath(this.lumaCtx,at.geometry,Nt,Rt,Ct),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill();this.lumaCtx.restore();const ht=this.maskCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight),j=this.lumaCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight).data,bt=ht.data;for(let Y=0;Y<bt.length;Y+=4){const rt=j[Y],tt=j[Y+1],qt=j[Y+2];let jt=(.299*rt+.587*tt+.114*qt)/255;vt&&(jt=1-jt),bt[Y+3]*=jt}this.maskCtx.putImageData(ht,0,0)}else{this.maskCtx.save(),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),this.maskCtx.globalCompositeOperation=vt?"destination-out":"destination-in",dt>0&&(this.maskCtx.filter=`blur(${dt}px)`),this.maskCtx.globalAlpha=Pt,this.applyAbsoluteTransform(this.maskCtx,at.id,o);const Nt=(V==null?void 0:V.width)||at.geometry.width||0,Rt=(V==null?void 0:V.height)||at.geometry.height||0,Ct=(V==null?void 0:V.corner_radius)??at.corner_radius??0;if(((Xt=at.geometry)==null?void 0:Xt.type)==="Text"){const ht=V!=null&&V.geometry?this.deepMerge(at.geometry,V.geometry):at.geometry,j=V!=null&&V.style?this.deepMerge(at.style,V.style):at.style;this._renderText(this.maskCtx,at,{...ht,width:Nt,height:Rt,corner_radius:Ct},j,V,Nt,Rt,!0,!1,wt,Mt)}else if(((ne=at.geometry)==null?void 0:ne.type)==="Image"){const ht=at.geometry.src;if(ht){let j=this.imageCache.get(ht);j||(j=new Image,j.src=ht,this.imageCache.set(ht,j)),j.complete&&j.naturalWidth>0?this.maskCtx.drawImage(j,-Nt/2,-Rt/2,Nt,Rt):(this.applyPath(this.maskCtx,at.geometry,Nt,Rt,Ct),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else if(((ie=at.geometry)==null?void 0:ie.type)==="SVG"){const ht=at.geometry.svgContent;if(ht){const j=`__alphamask_${at.id}`;let bt=this.imageCache.get(j);if(!bt){bt=new Image;const Y=new Blob([ht],{type:"image/svg+xml"});bt.src=URL.createObjectURL(Y),bt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(j,bt)}bt.complete&&bt.naturalWidth>0?this.maskCtx.drawImage(bt,-Nt/2,-Rt/2,Nt,Rt):(this.applyPath(this.maskCtx,at.geometry,Nt,Rt,Ct),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else this.applyPath(this.maskCtx,at.geometry,Nt,Rt,Ct),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill();this.maskCtx.restore()}}),le.save(),le.setTransform(1,0,0,1,0,0);const it=s.maskBlendMode||s.blendMode;it&&it!=="Normal"&&(le.globalCompositeOperation=it.toLowerCase()),le.drawImage(this.maskBuffer,0,0),le.restore(),le.restore()}else t.restore()}}applyOuterGlowUnderlay(t,s,o,e,i,n,a,r){var I,k,T;const l=a||s.style||{},f=l.effect,h=l.effects||(f?[f]:[]),u=h.find(O=>O.isEnabled!==!1&&O.type==="Glow"&&(O.mode==="outer"||O.mode==="Outer Glow"||!O.mode));if(!u)return;const c=u.blur||10,d=1e4;let p=u.color||"white";(k=(I=this.artboard)==null?void 0:I.tokens)!=null&&k.colors&&this.artboard.tokens.colors[p]&&(p=this.artboard.tokens.colors[p]),t.save();const g=l.fill&&l.fill.type!=="None",y=h.some(O=>O.isEnabled!==!1&&O.type==="BackgroundBlur"),b=s.type==="Text",v=s.type==="Group";!b&&!v&&(g||y)&&(t.beginPath(),t.rect(-1e6,-1e6,2e6,2e6),s.type==="Frame"||s.type==="Component"?this.drawRoundRect(t,-e/2,-i/2,e,i,n):this._tracePath(t,o,e,i,n),t.clip("evenodd"));const S=t.getTransform();t.shadowColor=p,t.shadowBlur=c,t.shadowOffsetX=d*S.a,t.shadowOffsetY=d*S.b,t.translate(-d,0);let C="black";l.fill&&l.fill.type!=="None"&&(C=this.createCanvasFill(t,l.fill,e,i)||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,i)||l.stroke.color||"black"),t.fillStyle=C,t.strokeStyle=w,t.lineWidth=((T=l.stroke)==null?void 0:T.width)||0;const M=Math.min(u.intensity||1,10);for(let O=0;O<M;O++)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,i,n),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 E=e/2,A=i/2;t.ellipse(0,0,E,A,0,0,Math.PI*2)}else n!==0?this.drawRoundRect(t,-e/2,-i/2,e,i,n):t.rect(-e/2,-i/2,e,i);const _=l.fill&&l.fill.type!=="None",P=l.stroke&&l.stroke.width>0;(_||!_&&!P)&&t.fill(),P&&t.stroke()}t.restore()}_renderText(t,s,o,e,i,n,a,r=!1,l=!1,f=1,h=1){var gt,mt,ut,wt,Mt,Et,Ut,re,he;let u=o.text||"";if(o.textInputId&&!r){const nt=this.inputs.get(o.textInputId);nt!==void 0&&(u=String(nt),i.geometry&&i.geometry.type==="Text"&&(i.geometry.text=u))}if(o.svgPath){const nt=o.svgPath;t.save();const yt=((gt=e==null?void 0:e.fill)==null?void 0:gt.color)||"#000000",Tt=((mt=e==null?void 0:e.fill)==null?void 0:mt.opacity)!==void 0?(ut=e==null?void 0:e.fill)==null?void 0:ut.opacity:1;t.fillStyle=yt,t.globalAlpha*=Tt;const _t=new Path2D(nt);t.fill(_t),t.restore();return}let c=u||"";o.enableSegments===!0&&o.segments&&Array.isArray(o.segments)&&(c=o.segments.map(nt=>nt&&nt.text?nt.text:"").join(""));const d=o.textCase||"none";d==="uppercase"?c=c.toUpperCase():d==="lowercase"?c=c.toLowerCase():d==="capitalize"&&(c=c.replace(/\b\w/g,nt=>nt.toUpperCase()));let p=((wt=o.fontWeight)==null?void 0:wt.toString())||"400",g=o.fontStyle||"normal";p.toLowerCase().includes("italic")&&(g="italic",p=p.replace(/italic/gi,"").trim()||"400");const y=this.mapFontWeight(p),b=Math.max(1,o.fontSize||32);let v=o.fontFamily||"Inter";const S=["Bold","SemiBold","Medium","Regular","Light","Thin","ExtraBold","Black","Italic"];S.forEach(nt=>{const yt=new RegExp(`[\\s-]${nt}$`,"i");yt.test(v)&&(v=v.replace(yt,"").trim())});const M=`${o.smallCaps===!0?"small-caps ":""}${g} ${y} ${b}px "${v}", sans-serif`;t.font=M;const I=o.textVerticalAlign||"top";t.textBaseline="top";const k=o.textAlign||"left";t.textAlign=k;let T=0;if(typeof o.letterSpacing=="number")T=o.letterSpacing;else if(typeof o.letterSpacing=="object"&&o.letterSpacing.value!==void 0){const nt=o.letterSpacing;T=nt.unit==="PERCENT"?nt.value/100*b:nt.value}t.letterSpacing!==void 0&&(t.letterSpacing=`${T}px`);const O=o.kerning||"auto",_=o.kerningValue||0;O==="manual"&&_!==0&&(t.letterSpacing=`${T+_}px`);const P=o.paragraphSpacing||0;let E=o.lineHeight??1.2;typeof E=="string"&&(E=parseFloat(E)),E>5&&b>0&&(E=E/b);const A=(E||1.2)*b,B=o.isPointText===!0||!o.width||o.width<=0,D=((Mt=o.padding)==null?void 0:Mt.left)||((Et=o.padding)==null?void 0:Et.right)||0,W=B?1e5:o.width&&o.width>0?Math.ceil(o.width)-D*2:1e5;o.autoHeight;const X=ts({text:c,fontFamily:v,fontSize:b,fontWeight:y,fontStyle:g,lineHeight:E,width:W,letterSpacing:T,paragraphSpacing:P,paragraphIndent:o.paragraphIndent||0,segments:o.segments,enableSegments:o.enableSegments,textCase:d,hyphenation:o.hyphenation,composer:o.composer,balanceRaggedLines:o.balanceRaggedLines}),H=X.lines||[],Q=X.maxFontSize||b,L=this.fontLeadingFactors[v]??.5,R=(A-b)*L;let et=X.height,U=n,lt=a;if(U===0||lt===0||U>=1e5){let nt=0,yt=0;const Tt=X.fullText||c;(H||[]).forEach(_t=>{const St=_t.text||"",Ft=t.measureText(St).width+(St.length>0?(St.length-1)*T:0);Ft>nt&&(nt=Ft),yt+=St.length,yt<Tt.length&&(Tt[yt]===`
23
- `||Tt[yt]==="\r")&&(yt++,Tt[yt-1]==="\r"&&Tt[yt]===`
24
- `&&yt++)}),(U===0||U>=1e5)&&(U=nt),lt===0&&(lt=et||0)}let x=-et/2;a>0&&a>et&&(I==="top"?x=-a/2:I==="middle"||I==="center"?x=-et/2:I==="bottom"&&(x=a/2-et)),x+=R;let F=null,N=0;if(o.pathId&&this.artboard){const nt=this.artboard.objects.find(yt=>yt.id===o.pathId);if(nt&&nt.type==="Shape"&&((Ut=nt.geometry)==null?void 0:Ut.type)==="Path"){const yt=this.objectStates.get(nt.id),Tt=yt!=null&&yt.geometry?this.deepMerge(nt.geometry,yt.geometry):nt.geometry,_t=(yt==null?void 0:yt.scale_x)!==void 0?(nt.width||0)*yt.scale_x:nt.width||0,St=(yt==null?void 0:yt.scale_y)!==void 0?(nt.height||0)*yt.scale_y:nt.height||0;F={geo:Tt,obj:nt,w:_t,h:St},N=this.getPerimeter(Tt,_t,St)}}const st=(nt,yt)=>{var _t,St;if(T===0&&(!o.enableSegments||!((_t=o.segments)!=null&&_t.length)))return t.measureText(nt).width;let Tt=0;for(let Ft=0;Ft<nt.length;Ft++){const Gt=yt+Ft;let Bt=0;if(o.enableSegments===!0&&((St=o.segments)==null?void 0:St.length)>0){let Wt=0,Jt=null;for(const Yt of o.segments){if(Gt<Wt+(Yt.text||"").length){Jt=Yt;break}Wt+=(Yt.text||"").length}if(Jt){t.save();let Yt=Jt.fontFamily||o.fontFamily||"Inter";const we=this.mapFontWeight((Jt.fontWeight||o.fontWeight||"400").toString()),Me=Jt.fontStyle||g,Zt=Jt.fontSize||b;t.font=`${Me} ${we} ${Zt}px "${Yt}", sans-serif`,Bt=t.measureText(nt[Ft]).width,t.restore()}else Bt=t.measureText(nt[Ft]).width}else Bt=t.measureText(nt[Ft]).width;Tt+=Bt+T}return Tt-(nt.length>0?T:0)},z=(nt,yt,Tt,_t,St)=>{var we,Me;const Gt=(St===0||c[St-1]===`
25
- `||c[St-1]==="\r")&&o.paragraphIndent?o.paragraphIndent:0,Bt=(!r||l)&&(s.behaviors||[]).some(Zt=>Zt.enabled&&(Zt.type.toString().includes("Text")||["Typewriter","Scramble","Wave","Bounce","GlitchText","Reveal3D","RevealSlide","RevealBlur"].includes(Zt.type))),Wt=!o.pathId&&!Bt&&(o.enableSegments!==!0||!o.segments||o.segments.length===0),Jt=o.baselineShift||0,Yt=Tt+Jt;if(Wt)t.font=M,_t?t.strokeText(nt,yt+Gt,Yt):t.fillText(nt,yt+Gt,Yt);else{const Zt=st(nt,St);let le=yt+Gt;k==="center"?le-=Zt/2:k==="right"&&(le-=Zt);const Ee=St+nt.length>=c.length||c[St+nt.length]===`
26
- `||c[St+nt.length]==="\r";let Ie=0,ke=0;const de=o.justifyMinWordSpacing,pe=o.justifyMaxWordSpacing;if(k==="justify"&&!Ee&&Zt>0&&!o.pathId){const G=B?Zt:W-D*2+0,at=Math.max(0,G-Zt);for(let V=0;V<nt.length;V++)nt[V]===" "&&ke++;if(ke>0){const V=t.measureText(" ").width;let dt=de||V*.5,vt=pe||V*2.5;Ie=Math.max(0,Math.min(at/ke,vt-dt))}}let ot=o.pathOffset||0;o.pathId&&N>0&&F&&(k==="center"?ot+=N/2-Zt/2:k==="right"&&(ot+=N-Zt));let ft=le;const it=r&&!l?[]:((we=s.behaviors)==null?void 0:we.filter(G=>[q.Typewriter,q.Scramble,q.Wave,q.Bounce,q.GlitchText,q.TextTrail,q.Reveal3D,q.RevealSlide,q.RevealBlur,q.TextLiquid,q.TextVortex,q.TextExplosion,q.TextRain,q.TextGravity,q.TextElastic,q.TextMatrix,q.TextNeon,q.TextGlitch3D,q.TextDissolve,q.TextOrganic,q.TextBreathe,q.TextFloral,q.TextSmoke,q.TextVariable,q.TextMagnet,q.TextSpin,q.TextZing,q.TextPerspective,q.TextMirror].includes(G.type)&&G.enabled))||[];for(let G=0;G<nt.length;G++){let at=nt[G];const V=St+G;let dt=0,vt=0,Pt=1,Ht=1,kt=0,At=1,$=at;it.forEach(Ct=>{const ht=Ct.settings||{},j=ht.strength||1,bt=Date.now();if(Ct.type===q.Typewriter)this.currentTime*(ht.speed||1)-V*(ht.stagger||.05)<0&&(At=0);else if(Ct.type===q.Scramble)Math.max(0,Math.min(1,this.currentTime/(ht.duration||1.5))-V*.02)<1&&Math.random()<.3&&($="$%#@!*&"[Math.floor(Math.random()*7)]);else if(Ct.type===q.Wave)vt+=Math.sin(this.currentTime*5*(ht.speed||1)+V*(ht.frequency||1))*(ht.amplitude||20)*j;else if(Ct.type===q.Bounce){const Y=Math.max(0,this.currentTime%2-V*(ht.stagger||.1));Y<1&&(vt-=Math.abs(Math.sin(Y*Math.PI))*(ht.height||50)*j)}else if(Ct.type===q.TextTrail){const Y=this.pointerHistory[Math.max(0,this.pointerHistory.length-1-V*(ht.delay||5))];Y&&(dt+=(Y.x-(i.x+ft))*j*.2,vt+=(Y.y-(i.y+Tt+vt))*j*.2)}else if(Ct.type===q.Reveal3D){const Y=Math.max(0,Math.min(1,this.currentTime*(ht.speed||1)-V*(ht.stagger||.1)));Pt*=Y,Ht*=Y,At=Y}else if(Ct.type===q.RevealSlide){const Y=Math.max(0,Math.min(1,this.currentTime*1.5-V*.05)),rt=(1-Y)*(ht.distance||40)*j,tt=ht.direction||"up";tt==="up"?vt-=rt:tt==="down"?vt+=rt:tt==="left"?dt-=rt:tt==="right"&&(dt+=rt),At=Y}else if(Ct.type===q.RevealBlur){const Y=Math.max(0,Math.min(1,this.currentTime*1.2-V*.1));At=Y,dt+=(1-Y)*5}else if(Ct.type===q.TextLiquid){const Y=Math.max(0,Math.sin(bt*.001*(ht.speed||1)+V*.5));vt+=Y*(ht.amplitude||10)*j,Ht*=1+Y*.2}else if(Ct.type===q.TextVortex){const Y=bt*.002*(ht.speed||1)+V*.2,rt=(1-(Math.sin(bt*.001)*.5+.5))*(ht.radius||50);dt+=Math.cos(Y)*rt*j,vt+=Math.sin(Y)*rt*j}else if(Ct.type===q.TextExplosion){const Y=ht.force||1,rt=this.currentTime%2;if(rt<1){const tt=(V/nt.length-.5)*Math.PI*2,qt=rt*100*Y;dt+=Math.cos(tt)*qt*j,vt+=Math.sin(tt)*qt*j,At=1-rt}}else if(Ct.type===q.TextRain){const Y=ht.speed||1,rt=ht.height||100,tt=(bt*.001*Y+V*.1)%1;vt-=(1-tt)*rt*j,At=tt>.1?1:tt*10}else if(Ct.type===q.TextGravity){const Y=ht.gravity||9.8,rt=this.currentTime%3/3,tt=.5*Y*Math.pow(rt*10,2);tt<100?vt+=tt*j:vt+=100*j}else if(Ct.type===q.TextMatrix){const Y=ht.speed||1;if(Math.random()<.1*Y){const tt="0123456789ABCDEF!@#$%^&*";$=tt[Math.floor(Math.random()*tt.length)]}At=.3+(Math.sin(bt*.01*Y+V)+1)/2*.7}else if(Ct.type===q.TextNeon){const Y=Math.random()>.95?.5:1;At=(.7+(Math.sin(bt*.005)+1)/2*.3)*Y}else if(Ct.type===q.TextDissolve)Math.sin(V*1.5+bt*.002*(ht.speed||1))>.5&&(At=0);else if(Ct.type===q.TextOrganic){const Y=ht.speed||1,rt=ht.amplitude||10;dt+=Math.sin(bt*.002*Y+V)*rt*j,vt+=Math.cos(bt*.0015*Y+V*.7)*rt*j}else if(Ct.type===q.TextBreathe){const rt=1+(Math.sin(bt*.003+V*.2)+1)/2*.2*j;Pt*=rt,Ht*=rt}else if(Ct.type===q.TextSpin){const Y=ht.speed||1;kt+=bt*.01*Y+V}else if(Ct.type===q.TextMagnet){const Y=this.pointerHistory[this.pointerHistory.length-1];if(Y){const rt=Y.x-(i.x+ft),tt=Y.y-(i.y+Tt);kt=Math.atan2(tt,rt)}}else if(Ct.type===q.TextPerspective){const Y=nt.length/2,rt=(V-Y)/Y,tt=1-Math.abs(rt)*.3*j;Pt*=tt,Ht*=tt,dt+=rt*20*j}else if(Ct.type===q.TextMirror)At*=.8;else if(Ct.type===q.TextFloral){const Y=ht.speed||1,rt=ht.stagger||.1,tt=(bt*.001*Y+V*rt)%2;tt<1&&(Pt*=tt,Ht*=tt,kt+=tt*Math.PI)}else if(Ct.type===q.TextSmoke){const Y=ht.speed||1,rt=ht.height||50,tt=(bt*5e-4*Y+V*.2)%1;vt-=tt*rt*j,dt+=Math.sin(bt*.002+V)*5*j,At=1-tt}else if(Ct.type===q.TextVariable){const Y=ht.speed||1,rt=ht.intensity||1.5,tt=(Math.sin(bt*.004*Y+V*.3)+1)/2;Pt*=1+tt*(rt-1)*j}else if(Ct.type===q.TextZing){const Y=ht.speed||2,rt=ht.distance||100,tt=(bt*.002*Y+V*.05)%1;dt+=(1-tt)*rt*j,At=tt}else if(Ct.type===q.TextElastic){const Y=ht.stiffness||.2,rt=ht.damping||.1,tt=Math.sin(bt*.01)*Math.exp(-bt*.001*rt);Ht*=1+tt*Y*j}else if(Ct.type===q.TextGlitch3D){const Y=ht.intensity||5;Math.random()<.2&&(dt+=(Math.random()-.5)*Y,vt+=(Math.random()-.5)*Y,At=.8)}else if(Ct.type===q.GlitchText){const Y=ht.intensity||5;Math.random()<.1&&(dt+=(Math.random()-.5)*Y,vt+=(Math.random()-.5)*Y,Math.random()<.05&&(At=.5))}});let Xt=null,ne=o.textDecoration||"none",ie=b;if(o.enableSegments===!0&&((Me=o.segments)==null?void 0:Me.length)>0){let Ct=0,ht=null;for(const j of o.segments){if(V<Ct+(j.text||"").length){ht=j;break}Ct+=(j.text||"").length}if(ht){let j=ht.fontFamily||o.fontFamily||"Inter";S.forEach(rt=>{const tt=new RegExp(`[\\s-]${rt}$`,"i");tt.test(j)&&(j=j.replace(tt,"").trim())});const bt=this.mapFontWeight((ht.fontWeight||o.fontWeight||"400").toString()),Y=ht.fontStyle||g;ie=ht.fontSize||b,t.font=`${Y} ${bt} ${ie}px "${j}", sans-serif`,ht.fill&&(Xt=ht.fill),ht.textDecoration&&(ne=ht.textDecoration),ie<Q&&(vt+=(Q-ie)*.85)}}else t.font=M;const Nt=t.globalAlpha;t.globalAlpha*=At,t.save();const Rt=t.measureText($).width;if(F&&N>0){const Ct=ft-le+Rt/2,j=(ot+Ct)/N,bt=this.getPointOnPath(F.geo,F.w,F.h,Math.abs(j%1)),Y=bt.angle,rt=Tt+vt+(o.pathOffsetY||0),tt=o.pathSide==="right"?-1:1,qt=Math.cos(Y+Math.PI/2)*rt*tt,jt=Math.sin(Y+Math.PI/2)*rt*tt;t.translate(bt.x+qt+dt,bt.y+jt),t.rotate(Y+kt+(tt===-1?Math.PI:0))}else t.translate(ft+dt+Rt/2,Tt+vt),kt!==0&&t.rotate(kt);if(t.scale(Pt,Ht),Xt&&!r&&!l){const Ct=this.createCanvasFill(t,Xt,U,lt);t.fillStyle=Ct||Xt.color||"#000000"}else if(!r&&!l){const Ct=this.createCanvasFill(t,e.fill,U,lt);t.fillStyle=Ct||e.fill.color||"#000000"}if(At>0)if(r||l){const Ct=l?"#000000":this.createCanvasFill(t,e.fill,U,lt);t.fillStyle=Ct||e.fill.color||"#ffffff",t.fillText($,-Rt/2,0)}else _t?t.strokeText($,-Rt/2,0):t.fillText($,-Rt/2,0);ne!=="none"&&!r&&this.drawTextDecoration(t,ne,0,0,Rt,ie),t.restore(),t.globalAlpha=Nt,k==="justify"&&Ie>0&&$===" "&&!Ee?ft+=Rt+T+Ie:ft+=Rt+T}}};if(r){let nt=0,yt=x;(H||[]).forEach(Tt=>{const _t=Tt.text||"",St=c.indexOf(_t,nt);St!==-1&&(nt=St);let Ft=-U/2;k==="center"?Ft=0:k==="right"&&(Ft=U/2),z(_t,Ft,yt,!1,nt),nt+=_t.length,yt+=A})}else if(l){let nt=0,yt=x;(H||[]).forEach(Tt=>{const _t=Tt.text||"";let St=-U/2;k==="center"?St=0:k==="right"&&(St=U/2),z(_t,St,yt,!1,nt),nt+=_t.length,nt<c.length&&(c[nt]===`
27
- `||c[nt]==="\r")&&(nt++,c[nt-1]==="\r"&&c[nt]===`
28
- `&&nt++),yt+=A})}else{if(e.fill){const yt=t.globalAlpha,Tt=this.createCanvasFill(t,e.fill,U,lt);t.fillStyle=Tt||e.fill.color||"#000000",t.globalAlpha=yt*this.normalizeOpacity(e.fill.opacity??100);const _t=X.fullText||(o.enableSegments?(o.segments||[]).map(Gt=>{let Bt=Gt.text||"";const Wt=Gt.textCase||o.textCase||"none";return Wt==="uppercase"?Bt.toUpperCase():Wt==="lowercase"?Bt.toLowerCase():Wt==="capitalize"?Bt.replace(/\b\w/g,Jt=>Jt.toUpperCase()):Bt}).join(""):c);let St=0,Ft=x;(H||[]).forEach(Gt=>{const Bt=Gt.text||"";let Wt=-U/2;k==="center"?Wt=0:k==="right"&&(Wt=U/2),z(Bt,Wt,Ft,!1,St),St+=Bt.length,Ft+=A,St<_t.length&&(_t[St]===`
29
- `||_t[St]==="\r")&&(P>0&&(Ft+=P),St++,_t[St-1]==="\r"&&_t[St]===`
30
- `&&St++)}),t.globalAlpha=yt}const nt=o.paragraphRule;if(nt&&(((re=nt.top)==null?void 0:re.width)>0||((he=nt.bottom)==null?void 0:he.width)>0)){let yt=0;(H||[]).forEach((Tt,_t)=>{var Gt,Bt;const Ft=yt===0||yt<c.length&&(c[yt]===`
31
- `||c[yt]==="\r");if(Ft&&_t>0&&yt++,Ft){if(((Gt=nt.top)==null?void 0:Gt.width)>0){const Wt=x+_t*A-nt.top.offset;t.strokeStyle=nt.top.color||"#000000",t.lineWidth=nt.top.width,t.beginPath();const Jt=-n/2+A*.2;t.moveTo(Jt,Wt),t.lineTo(n/2-A*.2,Wt),t.stroke()}if(((Bt=nt.bottom)==null?void 0:Bt.width)>0){const Wt=x+(_t+1)*A-nt.bottom.offset;t.strokeStyle=nt.bottom.color||"#000000",t.lineWidth=nt.bottom.width,t.beginPath();const Jt=-n/2+A*.2;t.moveTo(Jt,Wt),t.lineTo(n/2-A*.2,Wt),t.stroke()}}yt+=(Tt.text||"").length})}if(e.stroke&&e.stroke.width>0){const yt=t.globalAlpha;e.fill&&e.fill.type!=="None"&&e.fill.isEnabled!==!1&&e.fill.opacity!==0&&e.fill.color!=="transparent"&&e.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.strokeStyle=e.stroke.color;let _t=1;if(this.rootTransform){const Gt=t.getTransform(),Bt=Math.sqrt(Gt.a*Gt.a+Gt.b*Gt.b)||1,Wt=this.rootTransform,Jt=Math.sqrt(Wt.a*Wt.a+Wt.b*Wt.b)||1;_t=Bt/Jt}else _t=(Math.abs(f)+Math.abs(h))/2||1;t.lineWidth=(e.stroke.width||1)/(_t||1),t.globalAlpha=yt*this.normalizeOpacity(e.stroke.opacity??100);let St=0,Ft=x;(H||[]).forEach(Gt=>{let Bt=-U/2;k==="center"?Bt=0:k==="right"&&(Bt=U/2),z(Gt.text,Bt,Ft,!0,St),St+=(Gt.text||"").length,Ft+=A,St<c.length&&(c[St]===`
32
- `||c[St]==="\r")&&(P>0&&(Ft+=P),St++,c[St-1]==="\r"&&c[St]===`
33
- `&&St++)}),t.globalAlpha=yt}}}applyStrokeAlignment(t,s,o,e,i,n,a=1,r=1){if(!s.stroke||s.stroke.width<=0||s.stroke.isEnabled===!1)return;const l=s.stroke;let f=1;if(this.rootTransform){const S=t.getTransform(),C=Math.sqrt(S.a*S.a+S.b*S.b)||1,w=this.rootTransform,M=Math.sqrt(w.a*w.a+w.b*w.b)||1;f=C/M}else f=(Math.abs(a)+Math.abs(r))/2||1;const h=(l.width||1)/(f||1),u=(l.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),l.fill){const S=this.createCanvasFill(t,l.fill,e,i);S?t.strokeStyle=S:t.strokeStyle=l.color||"#000000"}else t.strokeStyle=l.color||"#000000";const d=t.globalAlpha;t.globalAlpha=d*this.normalizeOpacity(l.opacity??100),t.lineWidth=h,t.lineCap=l.lineCap||"round",t.lineJoin=l.lineJoin||"round",l.miterLimit!==void 0&&(t.miterLimit=l.miterLimit);const p=l.trimStart??0,g=l.trimEnd??1,y=l.trimOffset??0,b=l.dashOffset??0,v=l.dashArray||[];if(p!==0||g!==1||y!==0){const S=this.getPerimeter(o,e,i);if(S>0){const C=Math.max(0,Math.min(1,p)),w=Math.max(0,Math.min(1,g));if(C<w){const M=S*(w-C),I=S-M,k=-(S*(C+y%1));t.setLineDash([M,I]),t.lineDashOffset=k-b*S}else if(C===w)t.setLineDash([0,S]);else{const M=S*(1-C+w),I=S-M,k=-(S*C);t.setLineDash([M,I]),t.lineDashOffset=k-b*S}}}else if(v.length>0||b!==0){v.length>0&&t.setLineDash(v);const S=this.getPerimeter(o,e,i);t.lineDashOffset=-(b*S)}if((o==null?void 0:o.type)==="Line"||e===0||i===0)this.applyPath(t,o,e,i,n),t.stroke();else if(u==="inside")t.lineWidth=h*2,t.save(),this.applyPath(t,o,e,i,n),t.clip(),t.stroke(),t.restore();else if(u==="outside"){t.save(),t.beginPath();const S=Math.max(e,i,2e4);t.rect(-S,-S,S*2,S*2),this.applyPath(t,o,e,i,n),t.clip("evenodd"),t.lineWidth=h*2,t.beginPath(),this.applyPath(t,o,e,i,n),t.stroke(),t.restore()}else t.lineWidth=h,this.applyPath(t,o,e,i,n),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,i=Math.abs(o)/2,n=Math.abs(t.sweepAngle??360),a=t.ratio||0,r=Math.PI*(3*(e+i)-Math.sqrt((3*e+i)*(e+3*i)));if(n>=360&&a<=0)return r;let l=n/360*r;if(a>0){const f=Math.PI*(3*(e*a+i*a)-Math.sqrt((3*e*a+i*a)*(e*a+3*i*a)));l+=n/360*f,n<360&&(l+=2*Math.sqrt((e-e*a)**2+(i-i*a)**2))}else n<360&&(l+=2*Math.max(e,i));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,i=t.radius||Math.min(s,o)/2;return 2*e*i*Math.sin(Math.PI/e)}case"Star":{const e=t.points||5,i=t.outer_radius||Math.min(s,o)/2,n=t.inner_radius||i/2,a=Math.PI/e;return Math.sqrt(i*i+n*n-2*i*n*Math.cos(a))*e*2}case"Path":{const e=t.points||[];if(e.length<2)return t.length||0;let i=0,n=e[0].x,a=e[0].y;for(let r=1;r<e.length;r++){const l=e[r];if(l.moveTo){n=l.x,a=l.y;continue}const f=n,h=a,u=e[r-1].out_x,c=e[r-1].out_y;if(u!==void 0||l.in_x!==void 0?i+=this.getBezierLength(f,h,u??f,c??h,l.in_x??l.x,l.in_y??l.y,l.x,l.y):i+=Math.sqrt((l.x-f)**2+(l.y-h)**2),n=l.x,a=l.y,l.closePath||r===e.length-1&&(t.is_closed||t.isClosed)){const d=n,p=a,g=[...e.slice(0,r+1)].reverse().find(M=>M.moveTo)||e[0],y=g.x,b=g.y,v=e[r].out_x,S=e[r].out_y,C=g.in_x,w=g.in_y;v!==void 0||C!==void 0?i+=this.getBezierLength(d,p,v??d,S??p,C??y,w??b,y,b):i+=Math.sqrt((y-d)**2+(b-p)**2)}}return i}default:return(s+o)*2}}getBezierLength(t,s,o,e,i,n,a,r,l=10){let f=0,h=t,u=s;for(let c=1;c<=l;c++){const d=c/l,p=1-d,g=d*d,y=p*p,b=y*p,v=g*d,S=b*t+3*y*d*o+3*p*g*i+v*a,C=b*s+3*y*d*e+3*p*g*n+v*r,w=S-h,M=C-u;f+=Math.sqrt(w*w+M*M),h=S,u=C}return f}getBezierTAtLength(t,s,o,e,i,n,a,r,l,f=20){if(t<=0)return 0;let h=0,u=s,c=o;for(let d=1;d<=f;d++){const p=d/f,g=1-p,y=p*p,b=g*g,v=b*g,S=y*p,C=v*s+3*b*p*e+3*g*y*n+S*r,w=v*o+3*b*p*i+3*g*y*a+S*l,M=C-u,I=w-c,k=Math.sqrt(M*M+I*I);if(h+k>=t){const T=t-h,O=k===0?0:T/k;return(d-1+O)/f}h+=k,u=C,c=w}return 1}getPointOnPath(t,s,o,e){if(this.ensurePathPoints(t),(t==null?void 0:t.type)==="Path"){const i=t.points||[];if(i.length<2)return{x:0,y:0,angle:0};let n=1/0,a=-1/0,r=1/0,l=-1/0;i.forEach(b=>{typeof b.x=="number"&&typeof b.y=="number"&&(n=Math.min(n,b.x),a=Math.max(a,b.x),r=Math.min(r,b.y),l=Math.max(l,b.y),b.out_x!==void 0&&(n=Math.min(n,b.out_x),a=Math.max(a,b.out_x)),b.out_y!==void 0&&(r=Math.min(r,b.out_y),l=Math.max(l,b.out_y)),b.in_x!==void 0&&(n=Math.min(n,b.in_x),a=Math.max(a,b.in_x)),b.in_y!==void 0&&(r=Math.min(r,b.in_y),l=Math.max(l,b.in_y)))});const f=(n+a)/2,h=(r+l)/2,c=this.getPerimeter(t,s,o)*e;let d=0;const p=[];let g=i[0],y=i[0];for(let b=1;b<i.length;b++){const v=i[b];if(v.moveTo){g=v,y=v;continue}p.push({p0:g,p1:v}),(v.closePath||b===i.length-1&&(t.is_closed||t.isClosed))&&p.push({p0:v,p1:y}),g=v}for(const b of p){const v=b.p0,S=b.p1;let C=0;const w=v.out_x!==void 0||S.in_x!==void 0;if(w?C=this.getBezierLength(v.x,v.y,v.out_x??v.x,v.out_y??v.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y):C=Math.sqrt((S.x-v.x)**2+(S.y-v.y)**2),d+C>=c||b===p[p.length-1]){let M=0;if(w)return M=this.getBezierTAtLength(c-d,v.x,v.y,v.out_x??v.x,v.out_y??v.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y,20),this.getBezierPointAndAngle(M,v,S,f,h);{M=C===0?0:(c-d)/C;const I=v.x+(S.x-v.x)*M-f,k=v.y+(S.y-v.y)*M-h,T=Math.atan2(S.y-v.y,S.x-v.x);return{x:I,y:k,angle:T}}}d+=C}}else if(t.type==="Ellipse"){const i=Math.abs(s)/2,n=Math.abs(o)/2,a=t.sweepAngle??360,l=((t.startAngle??0)+a*e)*Math.PI/180,f=i*Math.cos(l),h=n*Math.sin(l),u=-i*Math.sin(l),c=n*Math.cos(l),d=Math.atan2(c,u);return{x:f,y:h,angle:d}}else if((t==null?void 0:t.type)==="Rectangle"){const i=Math.abs(s),n=Math.abs(o),r=(i+n)*2*e;let l=0,f=0,h=0;return r<i?(l=-i/2+r,f=-n/2,h=0):r<i+n?(l=i/2,f=-n/2+(r-i),h=Math.PI/2):r<2*i+n?(l=i/2-(r-(i+n)),f=n/2,h=Math.PI):(l=-i/2,f=n/2-(r-(2*i+n)),h=-Math.PI/2),{x:l,y:f,angle:h}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(t,s,o,e,i){const n=s.x,a=s.y,r=s.out_x??s.x,l=s.out_y??s.y,f=o.in_x??o.x,h=o.in_y??o.y,u=o.x,c=o.y,d=1-t,p=t*t,g=d*d,y=g*d,b=p*t,v=y*n+3*g*t*r+3*d*p*f+b*u-e,S=y*a+3*g*t*l+3*d*p*h+b*c-i,C=3*g*(r-n)+6*d*t*(f-r)+3*p*(u-f),w=3*g*(l-a)+6*d*t*(h-l)+3*p*(c-h),M=Math.atan2(w,C);return{x:v,y:S,angle:M}}applyAbsoluteTransform(t,s,o){if(!o.get(s))return;const i=[];let n=s;for(;n;){i.unshift(n);const a=o.get(n);n=a==null?void 0:a.parentId}i.forEach(a=>{this.applyObjectTransform(t,a)})}applyObjectTransform(t,s){var d,p,g;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,i=o.skew_y||0;if(e!==0||i!==0){const y=Math.tan(e*Math.PI/180),b=Math.tan(i*Math.PI/180);t.transform(1+y*b,b,y,1,0,0)}const n=o.rotate_x!==void 0?o.rotate_x:((d=o.transform)==null?void 0:d.rotate_x)??0,a=o.rotate_y!==void 0?o.rotate_y:((p=o.transform)==null?void 0:p.rotate_y)??0,l=1+(o.translate_z!==void 0?o.translate_z:((g=o.transform)==null?void 0:g.translate_z)??0)/1e3,f=(o.flip_x===!0?-1:1)*Math.cos(a*Math.PI/180)*l,h=(o.flip_y===!0?-1:1)*Math.cos(n*Math.PI/180)*l,u=(o.scale_x??1)*f,c=(o.scale_y??1)*h;t.scale(u,c)}applyInnerGlowOverlay(t,s,o,e,i,n,a){var y,b;const r=a||s.style||{},l=r==null?void 0:r.effect,h=((r==null?void 0:r.effects)||(l?[l]:[])).find(v=>v.isEnabled!==!1&&v.type==="Glow"&&(v.mode==="inner"||v.mode==="Inner Glow"));if(!h)return;t.save(),t.beginPath(),this.applyPath(t,o,e,i,n),t.clip();const u=h.blur||10,c=1e4,d=t.getTransform();let p=h.color||"white";(b=(y=this.artboard)==null?void 0:y.tokens)!=null&&b.colors&&this.artboard.tokens.colors[p]&&(p=this.artboard.tokens.colors[p]),t.shadowColor=p,t.shadowBlur=u,t.shadowOffsetX=c*d.a,t.shadowOffsetY=c*d.b,t.translate(-c,0),t.lineWidth=u+5,t.strokeStyle=p;const g=Math.min(h.intensity||1,5);for(let v=0;v<g;v++)t.beginPath(),this.applyPath(t,o,e,i,n),t.stroke();t.restore()}applyArtEffectOverlay(t,s,o,e,i,n){var c,d,p,g,y;const a=this.objectStates.get(s.id),r=((c=a==null?void 0:a.style)==null?void 0:c.artEffect)||s.artEffect||((d=s.style)==null?void 0:d.artEffect);if(!r||!r.enabled)return;const l=r.type,f=r.intensity??.5,h=r.speed??1,u=r.scale??10;if(l==="acid_gradient"||l==="acid_rave"||l==="shimmer"||l==="glint_overlay"||l==="halftone"||l==="noise"||l==="scanlines"||l==="chromatic_aberration"||l==="pixelate"||l==="glitch"||l==="fold_overlay"||l==="crumple_overlay"){if(t.save(),this.applyPath(t,o,e,i,n),t.clip(),l==="shimmer"){const v=this.currentTime*h%2/2,S=t.createLinearGradient(-e,-i,e,i);S.addColorStop(Math.max(0,v-.2),"rgba(255,255,255,0)"),S.addColorStop(v,`rgba(255,255,255,${f*.8})`),S.addColorStop(Math.min(1,v+.2),"rgba(255,255,255,0)"),t.fillStyle=S,t.globalCompositeOperation="screen",t.fillRect(-e/2,-i/2,e,i),t.globalCompositeOperation="source-over"}else if(l==="glint_overlay"){let S=((this._lastPointerPos||{x:0}).x-(((p=s.transform)==null?void 0:p.x)??0)+300)/600;S=Math.max(-.2,Math.min(1.2,S));const C=t.createLinearGradient(-e,-i,e,i);C.addColorStop(Math.max(0,S-.15),"rgba(255,255,255,0)"),C.addColorStop(Math.max(0,Math.min(1,S)),`rgba(255,255,255,${f})`),C.addColorStop(Math.min(1,S+.15),"rgba(255,255,255,0)"),t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-i/2,e,i),t.globalCompositeOperation="source-over"}else if(l==="fold_overlay"){const b=this._lastPointerPos||{x:0,y:0},v=b.x-(((g=s.transform)==null?void 0:g.x)??0),S=b.y-(((y=s.transform)==null?void 0:y.y)??0),C=t.createLinearGradient(v>0?-e/2:e/2,S>0?-i/2:i/2,v>0?e/2:-e/2,S>0?i/2:-i/2);C.addColorStop(0,`rgba(0,0,0,${f*.6})`),C.addColorStop(.4,"rgba(0,0,0,0)"),C.addColorStop(.5,`rgba(255,255,255,${f*.4})`),C.addColorStop(1,`rgba(0,0,0,${f*.2})`),t.fillStyle=C,t.globalCompositeOperation="overlay",t.fillRect(-e/2,-i/2,e,i),t.globalCompositeOperation="source-over",t.beginPath(),v>0&&S>0?(t.moveTo(e/2-40,i/2),t.lineTo(e/2,i/2-40),t.lineTo(e/2-40,i/2-40)):v<0&&S>0?(t.moveTo(-e/2+40,i/2),t.lineTo(-e/2,i/2-40),t.lineTo(-e/2+40,i/2-40)):v>0&&S<0?(t.moveTo(e/2-40,-i/2),t.lineTo(e/2,-i/2+40),t.lineTo(e/2-40,-i/2+40)):(t.moveTo(-e/2+40,-i/2),t.lineTo(-e/2,-i/2+40),t.lineTo(-e/2+40,-i/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=S>0?-2:2,t.fill()}else if(l==="crumple_overlay"){const b=Math.floor(e/u),v=document.createElement("canvas");v.width=b,v.height=Math.floor(i/u);const S=v.getContext("2d"),C=S.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*f}S.putImageData(C,0,0),t.globalCompositeOperation="multiply",t.imageSmoothingEnabled=!1,t.drawImage(v,-e/2,-i/2,e,i)}else if(l==="acid_gradient"||l==="acid_rave"){const b=this.currentTime*h,v=r.color1,S=r.color2,C=t.createLinearGradient(-e/2,-i/2,e/2,i/2);if(v&&S){const w=b*60%360;C.addColorStop(0,this._shiftHue(v,w,f*.7)),C.addColorStop(1,this._shiftHue(S,(w+180)%360,f*.7))}else{const w=b*100%360,M=(w+180)%360;C.addColorStop(0,`hsla(${w}, 80%, 50%, ${f*.5})`),C.addColorStop(1,`hsla(${M}, 80%, 50%, ${f*.5})`)}t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-i/2,e,i)}else if(l==="halftone"){const b=Math.max(2,u*(1-f*.8)),v=document.createElement("canvas");v.width=b,v.height=b;const S=v.getContext("2d");if(S){S.fillStyle="black",S.beginPath(),S.arc(b/2,b/2,b/2*f,0,Math.PI*2),S.fill();const C=t.createPattern(v,"repeat");C&&(t.globalAlpha=.3*f,t.fillStyle=C,t.fillRect(-e/2,-i/2,e,i))}}else if(l==="noise"){const b=Math.floor(e*i*f*.02);t.globalAlpha=.4*f;for(let v=0;v<b;v++){const S=Math.random()>.5?255:0;t.fillStyle=`rgba(${S}, ${S}, ${S}, ${.5+Math.random()*.5})`,t.fillRect(-e/2+Math.random()*e,-i/2+Math.random()*i,2,2)}}else if(l==="scanlines"){t.globalAlpha=.2*f,t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1;for(let b=-i/2;b<i/2;b+=4)t.beginPath(),t.moveTo(-e/2,b),t.lineTo(e/2,b),t.stroke()}else if(l==="chromatic_aberration"){const b=5*f;t.globalCompositeOperation="screen",t.globalAlpha=.5,t.fillStyle="cyan",t.fillRect(-e/2-b,-i/2,e,i),t.fillStyle="magenta",t.fillRect(-e/2+b,-i/2,e,i)}else if(l==="pixelate"){const b=Math.max(2,Math.round(u*(1-f*.5))),v=document.createElement("canvas"),S=Math.max(1,Math.ceil(e/b)),C=Math.max(1,Math.ceil(i/b));v.width=S,v.height=C;const w=v.getContext("2d");if(w){w.imageSmoothingEnabled=!1;const M=t.getTransform(),I=M.e-e/2,k=M.f-i/2;w.drawImage(t.canvas,I,k,e,i,0,0,S,C),t.imageSmoothingEnabled=!1,t.drawImage(v,0,0,S,C,-e/2,-i/2,e,i),t.imageSmoothingEnabled=!0}}else if(l==="glitch"){const b=this.currentTime*h,v=r.chaosAmount??.2,S=Math.max(3,Math.floor(8*f)),C=f*e*.15;t.globalCompositeOperation="screen",t.globalAlpha=f*.4;const w=C*.3;t.fillStyle="rgba(255, 0, 0, 0.4)",t.fillRect(-e/2+w,-i/2,e,i),t.fillStyle="rgba(0, 255, 255, 0.4)",t.fillRect(-e/2-w,-i/2,e,i),t.globalCompositeOperation="source-over",t.globalAlpha=1;const M=i/S;for(let I=0;I<S;I++){const k=Math.sin(I*127.1+b*311.7*h)*43758.5,T=k-Math.floor(k);if(T>1-v){const O=(T-(1-v))/v*C*(Math.random()>.5?1:-1),_=-i/2+I*M,P=t.getTransform(),E=P.e-e/2+O,A=P.f+_;t.save(),t.beginPath(),t.rect(-e/2,_,e,M),t.clip(),t.globalAlpha=.8,t.drawImage(t.canvas,E,A,e,M,-e/2+O,_,e,M),t.restore()}}}t.restore()}}_shiftHue(t,s,o){let e=0,i=0,n=0;if(t.startsWith("#")){const c=t.replace("#","");e=parseInt(c.substring(0,2),16)/255,i=parseInt(c.substring(2,4),16)/255,n=parseInt(c.substring(4,6),16)/255}const a=Math.max(e,i,n),r=Math.min(e,i,n);let l=0,f=0,h=(a+r)/2;if(a!==r){const c=a-r;switch(f=h>.5?c/(2-a-r):c/(a+r),a){case e:l=((i-n)/c+(i<n?6:0))/6;break;case i:l=((n-e)/c+2)/6;break;case n:l=((e-i)/c+4)/6;break}}return`hsla(${(((l*360+s)%360+360)%360).toFixed(0)}, ${(f*100).toFixed(0)}%, ${(h*100).toFixed(0)}%, ${o})`}applyBackgroundBlurGlass(t,s,o,e,i,n,a){const r=n.radius??10,l=n.opacity!==void 0?this.normalizeOpacity(n.opacity):.5,f=n.noise??0,h=n.color??"rgba(255,255,255,0.2)";t.save(),this.applyPath(t,s,o,e,i),t.clip();const u=t.getTransform(),c=t.canvas;try{const g=document.createElement("canvas");g.width=Math.max(1,Math.ceil(o)),g.height=Math.max(1,Math.ceil(e));const y=g.getContext("2d");if(y){y.save(),y.translate(o/2,e/2);const b=n.magnification||1;if(b!==1&&y.scale(b,b),typeof u.inverse=="function"){const C=u.inverse();y.transform(C.a,C.b,C.c,C.d,C.e,C.f)}else{const C=u.a*u.d-u.b*u.c;C!==0&&y.transform(u.d/C,-u.b/C,-u.c/C,u.a/C,(u.c*u.f-u.d*u.e)/C,(u.b*u.e-u.a*u.f)/C)}y.drawImage(c,0,0),y.restore();const v=document.createElement("canvas");v.width=g.width,v.height=g.height;const S=v.getContext("2d");S.filter=`blur(${r}px)`,S.drawImage(g,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(g){console.error("Background blur failed:",g)}t.globalCompositeOperation="source-over",t.globalAlpha=l,t.fillStyle=h,t.fillRect(-o/2,-e/2,o,e),t.globalAlpha=1;const d=t.createLinearGradient(-o/2,-e/2,o/2,e/2);if(d.addColorStop(0,"rgba(255,255,255,0.12)"),d.addColorStop(.3,"rgba(255,255,255,0.04)"),d.addColorStop(.5,"rgba(255,255,255,0.0)"),d.addColorStop(1,"rgba(255,255,255,0.0)"),t.fillStyle=d,t.fillRect(-o/2,-e/2,o,e),f>0){if(t.globalAlpha=f/100,!this._noiseTileCanvas){const y=document.createElement("canvas");y.width=64,y.height=64;const b=y.getContext("2d"),v=b.createImageData(64,64),S=v.data;for(let C=0;C<S.length;C+=4){const w=Math.floor(Math.random()*255);S[C]=w,S[C+1]=w,S[C+2]=w,S[C+3]=18}b.putImageData(v,0,0),this._noiseTileCanvas=y}const g=t.createPattern(this._noiseTileCanvas,"repeat");g&&(t.fillStyle=g,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,i),this.applyStrokeAlignment(t,a,s,o,e,i,1,1)):(t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1.5,this.applyPath(t,s,o,e,i),t.stroke()),t.restore()}applyPath(t,s,o,e,i){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,i)}_tracePath(t,s,o,e,i){if(s){if(this.ensurePathPoints(s),(s==null?void 0:s.type)==="Rectangle"||s.type==="Image"){const n=i!==void 0?i:s.corner_radius??0;this.drawRoundRect(t,-o/2,-e/2,o,e,n)}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:n=0,sweepAngle:a=360,ratio:r=0}=s,l=o/2,f=e/2,h=n*Math.PI/180,u=a*Math.PI/180,c=h+u;a>=360&&r<=0?t.ellipse(0,0,l,f,0,0,Math.PI*2):(t.ellipse(0,0,l,f,0,h,c,!1),r>0?t.ellipse(0,0,l*r,f*r,0,c,h,!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 n=s.sides||3,a=s.radius||Math.min(o,e)/2;for(let r=0;r<n;r++){const l=r*2*Math.PI/n-Math.PI/2,f=a*Math.cos(l),h=a*Math.sin(l);r===0?t.moveTo(f,h):t.lineTo(f,h)}t.closePath()}else if(s.type==="Star"){const n=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<n*2;l++){const f=l*Math.PI/n-Math.PI/2,h=l%2===0?a:r,u=h*Math.cos(f),c=h*Math.sin(f);l===0?t.moveTo(u,c):t.lineTo(u,c)}t.closePath()}else if(((s==null?void 0:s.type)==="Path"||s.type==="Subtract"||s.type==="Union"||s.type==="Intersect"||s.type==="Exclude"||s.type==="BooleanOperation")&&s.points){this.frameCount%300===0&&this.log("[Engine] Tracing Path:",s.points.length,"points");let n=1/0,a=-1/0,r=1/0,l=-1/0;if(s.points.forEach(u=>{typeof u.x=="number"&&typeof u.y=="number"&&(n=Math.min(n,u.x),a=Math.max(a,u.x),r=Math.min(r,u.y),l=Math.max(l,u.y),u.out_x!==void 0&&(n=Math.min(n,u.out_x),a=Math.max(a,u.out_x)),u.out_y!==void 0&&(r=Math.min(r,u.out_y),l=Math.max(l,u.out_y)),u.in_x!==void 0&&(n=Math.min(n,u.in_x),a=Math.max(a,u.in_x)),u.in_y!==void 0&&(r=Math.min(r,u.in_y),l=Math.max(l,u.in_y)))}),n===1/0)return;const f=(n+a)/2,h=(r+l)/2;if(isNaN(f)||isNaN(h)){this.warn("[Engine] Invalid path center:",f,h);return}s.points.forEach((u,c)=>{if(c===0||u.moveTo)t.moveTo(u.x-f,u.y-h);else{const d=s.points[c-1];if(!d)return;const p=(d.out_x??d.x)-f,g=(d.out_y??d.y)-h,y=(u.in_x??u.x)-f,b=(u.in_y??u.y)-h;isNaN(p)||isNaN(y)||isNaN(u.x)?t.lineTo(u.x-f,u.y-h):t.bezierCurveTo(p,g,y,b,u.x-f,u.y-h)}if(u.closePath||c===s.points.length-1&&(s.is_closed||s.isClosed)){const d=[...s.points.slice(0,c+1)].reverse().find(p=>p.moveTo)||s.points[0];d&&(u.out_x!==void 0||d.in_x!==void 0)&&t.bezierCurveTo((u.out_x??u.x)-f,(u.out_y??u.y)-h,(d.in_x??d.x)-f,(d.in_y??d.y)-h,d.x-f,d.y-h),t.closePath()}})}else if(s.points&&Array.isArray(s.points)){let n=1/0,a=-1/0,r=1/0,l=-1/0;s.points.forEach(u=>{n=Math.min(n,u.x),a=Math.max(a,u.x),r=Math.min(r,u.y),l=Math.max(l,u.y)});const f=(n+a)/2,h=(r+l)/2;s.points.forEach((u,c)=>{if(c===0)t.moveTo(u.x-f,u.y-h);else{const d=s.points[c-1];d.out_x!==void 0||u.in_x!==void 0?t.bezierCurveTo((d.out_x??d.x)-f,(d.out_y??d.y)-h,(u.in_x??u.x)-f,(u.in_y??u.y)-h,u.x-f,u.y-h):t.lineTo(u.x-f,u.y-h)}(u.closePath||c===s.points.length-1&&(s.is_closed||s.isClosed))&&t.closePath()})}}}renderInputBox(t,s){var x,F;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((x=s.geometry)==null?void 0:x.width)||250,n=((F=s.geometry)==null?void 0:F.height)||45,a=this.focusedId===s.id,r=this.lastHoveredObjectId===s.id,l=e.previewState||"default",f=l!=="default"?l:a?"focused":r?"hovered":"default",h=e.label||{visible:!0,text:"Label"},u=e.helperText||{visible:!1,text:"Helper text"},c=e.leftIcon||{visible:!1},d=e.rightIcon||{visible:!1},p=e.multiline===!0,g=e.corner_radius??8,y=e.corners||{tl:g,tr:g,bl:g,br:g},b=[y.tl,y.tr,y.br,y.bl];let v=e.backgroundColor||"rgba(31, 41, 55, 1)",S=e.borderColor||"rgba(55, 65, 81, 1)",C=e.borderWidth??1.5,w=e.color||"#ffffff",M=e.placeholderColor||"rgba(156, 163, 175, 1)",I=e.fontSize||14;const k=`${f}Style`,T=e[k];T?(T.backgroundColor!==void 0&&(v=T.backgroundColor),T.borderColor!==void 0&&(S=T.borderColor),T.borderWidth!==void 0&&(C=T.borderWidth),T.color!==void 0&&(w=T.color),T.placeholderColor!==void 0&&(M=T.placeholderColor),T.fontSize!==void 0&&(I=T.fontSize)):f==="focused"?(S=e.focusBorderColor||"rgba(59, 130, 246, 1)",C=Math.max(C,2)):f==="hovered"||f==="hover"?(S=e.hoverBorderColor||S,v=e.hoverBackgroundColor||v):f==="disabled"?(v=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",S=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):f==="error"&&(S="rgba(239, 68, 68, 1)",C=Math.max(C,2)),t.beginPath(),this.drawRoundRect(t,-i/2,-n/2,i,n,b);const O=this.createCanvasFill(t,v,i,n);if(O&&(t.fillStyle=O,t.fill()),C>0){const N=this.createCanvasFill(t,S,i,n);if(N&&(t.strokeStyle=N,t.lineWidth=C,t.stroke()),f==="focused"||f==="focus"){t.save(),t.beginPath();const st=b.map(z=>z+2);this.drawRoundRect(t,-i/2-2,-n/2-2,i+4,n+4,st),t.strokeStyle="rgba(59, 130, 246, 0.3)",t.lineWidth=2,t.stroke(),t.restore()}}const _=(N,st)=>{if(!N.visible||!N.svgPath)return;const z=N.size||14,gt=N.offset??16,mt=N.color||"#ffffff",ut=st?-(i/2)+gt:i/2-gt,wt=N.svgPath;if(t.save(),t.translate(ut,0),!wt.startsWith("<svg")){const Mt=new Path2D(wt),Et=z/24;t.scale(Et,Et),t.translate(-12,-12),t.fillStyle=mt,t.fill(Mt)}t.restore()};_(c,!0),_(d,!1);const P=e.text||"",E=e.placeholder||"Enter text...",A=!P,B=P||E,D=A?M:w,W=I,X=e.fontFamily||"Inter",H=e.fontWeight||400;t.font=`${H} ${W}px "${X}", sans-serif`,t.fillStyle=D,t.textAlign="left",t.textBaseline=p?"top":"middle";const Q=e.inputPadding??16,L=c.visible?(c.offset??16)+(c.size||14)/2+8:Q,R=d.visible?(d.offset??16)+(d.size||14)/2+8:Q,et=-(i/2)+L,U=i-L-R,lt=e.inputType==="password"?"•".repeat(B.length):B;if(t.save(),t.beginPath(),t.rect(et-2,-n/2+4,U+4,n-8),t.clip(),p){const N=lt.split(`
34
- `);let st=-n/2+Q;const z=W*1.2;let gt=0;N.forEach((mt,ut)=>{const wt=mt.split(" ");let Mt="";for(let Et=0;Et<wt.length;Et++){const Ut=Mt+wt[Et]+" ";t.measureText(Ut).width>U&&Et>0?(t.fillText(Mt,et,st),Mt=wt[Et]+" ",st+=z):Mt=Ut}t.fillText(Mt,et,st),gt=t.measureText(Mt).width,ut<N.length-1&&(st+=z,gt=0)}),a&&!A&&Math.floor(performance.now()/500)%2===0&&t.fillRect(et+gt,st,1.5,W)}else{const st=t.measureText(lt).width;let z=0;if(st>U&&(z=st-U),t.fillText(lt,et-z,0),a&&!A&&Math.floor(performance.now()/500)%2===0){const mt=et+st-z;t.fillRect(mt,-(W/2),1.5,W)}}if(t.restore(),h.visible!==!1){const N=h.text||"Label",st=h.fontSize||12,z=h.color||"rgba(156, 163, 175, 1)",gt=h.offset??8;t.font=`600 ${st}px "${X}", sans-serif`,t.fillStyle=z,t.textAlign="left",t.textBaseline="bottom";const mt=-(i/2),ut=-(n/2)-gt;t.fillText(N,mt,ut)}if(u.visible===!0){const N=u.text||"Helper text",st=u.fontSize||11,z=f==="error"?"rgba(239, 68, 68, 1)":u.color||"rgba(156, 163, 175, 1)",gt=u.offset??6;t.font=`400 ${st}px "${X}", sans-serif`,t.fillStyle=z,t.textAlign="left",t.textBaseline="top";const mt=-(i/2),ut=n/2+gt;t.fillText(N,mt,ut)}}renderSlider(t,s){const o=this.objectStates.get(s.id),e=(o==null?void 0:o.geometry)||s.geometry,i=(o==null?void 0:o.options)||s.options||{},n=e.width||200,a=i.value??50,r=i.min??0,f=(i.max??100)-r,h=f===0?0:(a-r)/f,u=i.trackHeight||4,c=i.trackRoundedness??2,d=i.trackShape??"Rectangle",p=i.trackPath||"",g=i.accentColor||"#3b82f6",y=i.inactiveColor||"#374151",b=i.thumbShape||"Ellipse",v=i.thumbWidth??16,S=i.thumbHeight??16,C=i.thumbRoundedness??0,w=i.thumbColor||"#ffffff",M=i.thumbPath||"",I=i.thumbIcon||"",k=i.showValueTooltip??!1,T=i.tooltipBgColor||"#333333",O=i.tooltipColor||"#ffffff",_=i.tooltipOffsetX??0,P=i.tooltipOffsetY??-25,E=(U,lt,x,F,N,st,z)=>{if((U==="Custom"||U==="Icon")&&z)try{const gt=new Path2D(z);if(t.save(),t.translate(lt,x),U==="Icon"){const mt=Math.min(F,N)/24;t.scale(mt,mt),t.translate(-12,-12)}t.fill(gt),t.restore();return}catch(gt){console.error("Error drawing slider shape in engine:",gt)}if(t.beginPath(),U==="Ellipse")t.ellipse(lt,x,F/2,N/2,0,0,Math.PI*2);else if(U==="Rectangle")this.drawRoundRect(t,lt-F/2,x-N/2,F,N,st);else if(U==="Triangle")t.moveTo(lt,x-N/2),t.lineTo(lt+F/2,x+N/2),t.lineTo(lt-F/2,x+N/2),t.closePath();else if(U==="Diamond")t.moveTo(lt,x-N/2),t.lineTo(lt+F/2,x),t.lineTo(lt,x+N/2),t.lineTo(lt-F/2,x),t.closePath();else if(U==="Polygon"){const gt=s.geometry.sides||3,mt=s.geometry.radius||Math.min(F,N)/2;for(let ut=0;ut<gt;ut++){const wt=ut*2*Math.PI/gt-Math.PI/2,Mt=lt+mt*Math.cos(wt),Et=x+mt*Math.sin(wt);ut===0?t.moveTo(Mt,Et):t.lineTo(Mt,Et)}t.closePath()}else if(U==="Star"){const mt=Math.min(F,N)/2,ut=mt/2;for(let wt=0;wt<10;wt++){const Mt=wt%2===0?mt:ut,Et=wt*Math.PI/5-Math.PI/2;t.lineTo(lt+Mt*Math.cos(Et),x+Mt*Math.sin(Et))}t.closePath()}else U==="Line"&&(t.moveTo(lt-F/2,x),t.lineTo(lt+F/2,x));t.fill()},A=this.createCanvasFill(t,y,n,u);A&&(t.fillStyle=A,t.strokeStyle=A),d==="Line"?(t.lineWidth=u,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(n/2,0),t.stroke()):E(d,0,0,n,u,c,p);const B=n-v,D=-n/2+v/2+h*B,W=D- -n/2;if(W>0){const U=this.createCanvasFill(t,g,n,u);U&&(t.fillStyle=U,t.strokeStyle=U),d==="Line"?(t.lineWidth=u,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(D,0),t.stroke()):d==="Rectangle"&&(t.beginPath(),this.drawRoundRect(t,-n/2,-u/2,W,u,c),t.fill())}t.save(),t.translate(D,0);const X=t.getTransform(),H=Math.sqrt(X.a*X.a+X.b*X.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*H,t.shadowOffsetY=1*H;const Q=this.createCanvasFill(t,w,v,S);if(Q&&(t.fillStyle=Q),E(b,0,0,v,S,C,b==="Icon"?I:M),t.restore(),k){t.save(),t.translate(D+_,P);const U=Math.round(a).toString();t.font="10px Inter, sans-serif";const lt=t.measureText(U),x=6,F=4,N=lt.width+x*2,st=14+F;t.beginPath(),this.drawRoundRect(t,-N/2,-st/2,N,st,4),t.fillStyle=T,t.fill(),t.fillStyle=O,t.textAlign="center",t.textBaseline="middle",t.fillText(U,0,0),t.restore()}const L=i.label||{},R=i.helperText||{},et=i.fontFamily||"Inter";if(L.visible!==!1){const U=L.text||"Label",lt=L.fontSize||12,x=L.color||"rgba(156, 163, 175, 1)",F=L.offset??8;t.font=`600 ${lt}px "${et}", sans-serif`,t.fillStyle=x,t.textAlign="left",t.textBaseline="bottom";const N=-(n/2),st=-(u/2)-F;t.fillText(U,N,st)}if(R.visible===!0){const U=R.text||"Helper text",lt=R.fontSize||11,x=R.color||"rgba(156, 163, 175, 1)",F=R.offset??6;t.font=`400 ${lt}px "${et}", sans-serif`,t.fillStyle=x,t.textAlign="left",t.textBaseline="top";const N=-(n/2),st=u/2+F;t.fillText(U,N,st)}}renderDropdown(t,s){var P;const o=this.objectStates.get(s.id);if(!o)return;const e=o.options||s.options||{},i=s.geometry.width||160,n=s.geometry.height||40,a=-i/2,r=-n/2,l=e.corner_radius??6,f=e.disabled||e.previewState==="disabled",h=this.lastHoveredObjectId===s.id||e.previewState==="hover",u=(e.isOpen||e.previewState==="active")&&!f;let c=e.backgroundColor,d=e.borderColor,p=e.color||"#333333";f?(c=e.disabledBackgroundColor||"#f3f4f6",d=e.disabledBorderColor||"#e5e7eb",p=e.disabledColor||"#9ca3af"):u?(c=e.activeBackgroundColor||c,d=e.activeBorderColor||d,p=e.activeColor||p):h&&(c=e.hoverBackgroundColor||c,d=e.hoverBorderColor||d,p=e.hoverColor||p),c||(c="#ffffff"),d||(d="#e5e7eb");const g=t.globalAlpha;t.globalAlpha=g*(e.opacity??1),this.drawRoundRect(t,a,r,i,n,l),t.fillStyle=this.createCanvasFill(t,typeof c=="string"?{type:"Solid",color:c}:c,i,n)||"#ffffff",t.fill();const y=e.borderWidth??1;y>0&&(t.strokeStyle=this.createCanvasFill(t,typeof d=="string"?{type:"Solid",color:d}:d,i,n)||"#e5e7eb",t.lineWidth=y,t.stroke());const b=12,v=e.chevronType||"chevron",S=e.chevronSize||16,C=(u?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(v!=="none"){const E=a+i-b-S/2;t.save(),t.translate(E,0);const A=u?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(A*Math.PI/180),t.strokeStyle=C,t.fillStyle=C,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",v==="chevron")t.beginPath(),t.moveTo(-S/2,-S*.2),t.lineTo(0,S*.2),t.lineTo(S/2,-S*.2),t.stroke();else if(v==="custom"||v==="path"){const B=u&&e.openIconPath||e.closedIconPath;if(B){const D=new Path2D(B);t.save();const W=S/24;t.scale(W,W),t.translate(-12,-12),t.fill(D),t.restore()}}t.restore()}const w=e.selectedOption||e.placeholder||"Select...",M=e.fontSize||14,I=e.fontWeight||400,k=e.fontFamily||"Inter, sans-serif";t.font=`${I} ${M}px ${k}`;const T=f?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":p;t.fillStyle=this.createCanvasFill(t,typeof T=="string"?{type:"Solid",color:T}:T,i,n)||"#333333",t.textAlign="left",t.textBaseline="middle";const O=v==="none"?0:S+8,_=i-b*2-O;if(t.save(),t.beginPath(),t.rect(a+b,r,_,n),t.clip(),t.fillText(w,a+b,0),t.restore(),u&&!f){const E=r+n+4,A=e.optionsList||[],B=e.itemHeight||32,D=e.listPadding??4,W=A.length*B+D*2,X=e.listCornerRadius??l;t.save();const H=e.listShadow||{},Q=t.getTransform(),L=Math.sqrt(Q.a*Q.a+Q.b*Q.b)||1;t.shadowColor=typeof H.color=="string"?H.color:((P=H.color)==null?void 0:P.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(H.blur??12)*L,t.shadowOffsetY=(H.offsetY??6)*L,t.shadowOffsetX=(H.offsetX??0)*L,t.beginPath(),this.drawRoundRect(t,a,E,i,W,X),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},i,W)||"#ffffff",t.fill();const R=e.listBorderWidth??1;R>0&&(t.shadowColor="transparent",t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:d},i,W)||"#e5e7eb",t.lineWidth=R,t.stroke()),t.restore();const et=e.itemFontSize||M,U=e.itemFontFamily||k;t.font=`${I} ${et}px ${U}`,A.forEach((lt,x)=>{const F=E+D+x*B;if(lt===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},i,B)||"#f3f4f6",t.fillRect(a+R,F,i-R*2,B),t.fillStyle=e.itemSelectedColor||e.accentColor||p||"#374151";else if(t.fillStyle=e.listTextColor||p||"#333333",this.activeDropdownId===s.id&&this._lastPointerPos){const st=this._lastPointerPos.y-(E+D),z=Math.floor(st/B);x===z&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},i,B)||"#f9fafb",t.fillRect(a+R,F,i-R*2,B),t.fillStyle=e.itemHoverColor||p)}t.fillText(lt,a+b,F+B/2)})}t.globalAlpha=g}renderButton(t,s){if(s.children&&s.children.length>0)return;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=s.geometry||{},n=i.width||120,a=i.height||40,r=this.lastHoveredObjectId===s.id,l=this.activeObjectId===s.id,f=e.label||{},h=e.hoverStyle||{},u=e.activeStyle||{},c=e.icon||{enabled:!1};let d=e.backgroundColor||"#3b82f6",p=f.color||"#ffffff",g=f.text||"Button",y=i.cornerRadius??8,b=e.borderColor||"transparent",v=e.borderWidth||0,S=1;l&&u?(d=u.backgroundColor||d,p=u.color||p,g=u.text||g,S=u.scale??.95,y=u.cornerRadius??y):r&&h&&(d=h.backgroundColor||d,p=h.color||p,g=h.text||g,S=h.scale??1,y=h.cornerRadius??y,b=h.borderColor||b);const C=-n/2,w=-a/2;t.save(),t.scale(S,S),t.beginPath(),this.drawRoundRect(t,C,w,n,a,y);const M=this.createCanvasFill(t,d,n,a);M&&(t.fillStyle=M,t.fill()),(v>0||r&&h.borderColor)&&(t.strokeStyle=b,t.lineWidth=v||(r?1:0),t.stroke());const I=f.fontSize||14,k=f.fontFamily||"Inter",T=f.fontWeight||600;t.font=`${T} ${I}px "${k}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=p,t.textAlign="center",t.textBaseline="middle";let O=0;if(c.enabled&&c.svgPath){const _=I*1.1,P=c.gap||8,E=t.measureText(g),B=-(E.width+_+P)/2,D=c.position==="left"?B+_/2:B+E.width+P+_/2;O=c.position==="left"?B+_+P+E.width/2:B+E.width/2,t.save(),t.translate(D,0);const W=new Path2D(c.svgPath),X=_/24;t.scale(X,X),t.translate(-12,-12),t.fillStyle=p,t.fill(W),t.restore()}t.fillText(g,O,0),t.restore()}renderToggleButton(t,s){var g,y;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=e.checked??!1,n=((g=s.geometry)==null?void 0:g.width)||120,a=((y=s.geometry)==null?void 0:y.height)||40,r=-n/2,l=-a/2,f=e.corner_radius??8,h=e.label||{},u=i?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",c=i?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,r,l,n,a,f),t.fillStyle=u,t.fill();const d=h.fontSize||14,p=h.fontFamily||"Inter";t.font=`${h.fontWeight||600} ${d}px "${p}", sans-serif`,t.fillStyle=c,t.textAlign="center",t.textBaseline="middle",t.fillText(h.text||"Toggle",0,0),t.restore()}renderToggle(t,s){var X,H,Q,L,R,et,U,lt,x,F,N,st;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((X=s.geometry)==null?void 0:X.width)||52,n=((H=s.geometry)==null?void 0:H.height)||30,a=-i/2,r=-n/2,l=e.checked??!1,f=e.cornerRadius??e.corner_radius??n/2,h=e.toggleStyle||{},u=h.backgroundColor||e.activeColor||"#10b981",c=h.borderColor||e.borderColor||"transparent",d=h.borderWidth??e.borderWidth??0,p=h.knobColor||e.knobColor||"#ffffff",g=l?u:e.inactiveColor||"#374151",y=l?c:e.borderColor||"transparent",b=l?d:e.borderWidth??0,v=l?p:e.knobColor||"#ffffff";e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,i,n,f);const S=this.createCanvasFill(t,g,i,n);if(S&&(t.fillStyle=S,t.fill()),b>0){t.lineWidth=b;const z=this.createCanvasFill(t,y,i,n);z&&(t.strokeStyle=z,t.stroke())}const C=2,w=n-C*2,M=w/2,I=a+C,k=a+i-C-w,T=l?k:I,O=r+C;t.beginPath(),t.arc(T+M,O+M,M,0,Math.PI*2);const _=this.createCanvasFill(t,v,w,w);_&&(t.fillStyle=_,t.fill()),e.disabled&&(t.globalAlpha*=2);let P=!1,E=!1;const A=(l?(Q=h.leftLabel)==null?void 0:Q.text:null)||((L=e.leftLabel)==null?void 0:L.text)||"",B=(l?(R=h.leftLabel)==null?void 0:R.color:null)||((et=e.leftLabel)==null?void 0:et.color)||"#f3f4f6";if((U=e.leftLabel)!=null&&U.enabled&&A){const z=e.leftLabel;t.font=`${z.fontWeight||400} ${z.fontSize||12}px "${z.fontFamily||"Inter"}", sans-serif`,t.fillStyle=B,t.textBaseline="middle",t.textAlign="right",t.fillText(A,a-(z.gap||8),0),P=!0}const D=(l?(lt=h.rightLabel)==null?void 0:lt.text:null)||((x=e.rightLabel)==null?void 0:x.text)||"",W=(l?(F=h.rightLabel)==null?void 0:F.color:null)||((N=e.rightLabel)==null?void 0:N.color)||"#f3f4f6";if((st=e.rightLabel)!=null&&st.enabled&&D){const z=e.rightLabel;t.font=`${z.fontWeight||400} ${z.fontSize||12}px "${z.fontFamily||"Inter"}", sans-serif`,t.fillStyle=W,t.textBaseline="middle",t.textAlign="left",t.fillText(D,a+i+(z.gap||8),0),E=!0}if(!P&&!E&&e.label&&e.label.text){const z=e.label,gt=z.fontSize||14,mt=z.fontWeight||400,ut=z.fontFamily||"Inter";t.font=`${mt} ${gt}px "${ut}", sans-serif`,t.fillStyle=z.color||"#f3f4f6",t.textBaseline="middle";const wt=z.gap||10;let Mt=0,Et=0;z.position==="left"?(t.textAlign="right",Mt=a-wt,Et=0):z.position==="right"?(t.textAlign="left",Mt=a+i+wt,Et=0):z.position==="top"?(t.textAlign="center",Mt=0,Et=r-wt,t.textBaseline="bottom"):z.position==="bottom"?(t.textAlign="center",Mt=0,Et=r+n+wt,t.textBaseline="top"):(t.textAlign="left",Mt=a+i+wt,Et=0),t.fillText(z.text,Mt,Et)}}renderCheckbox(t,s){var S,C;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((S=s.geometry)==null?void 0:S.width)||20,n=((C=s.geometry)==null?void 0:C.height)||20,a=-i/2,r=-n/2,l=e.cornerRadius??4,f=e.checked??!1,h=e.activeColor||"#3b82f6",u=e.inactiveColor||"transparent",c=e.checkColor||"#ffffff",d=e.borderColor||"#4b5563",p=e.borderWidth??2,g=f?h:u,y=f?"transparent":d,b=f?0:p;e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,i,n,l);const v=this.createCanvasFill(t,g,i,n);if(v&&(t.fillStyle=v,t.fill()),b>0){t.lineWidth=b;const w=this.createCanvasFill(t,y,i,n);w&&(t.strokeStyle=w,t.stroke())}else if(f){t.lineWidth=1;const w=this.createCanvasFill(t,h,i,n);w&&(t.strokeStyle=w,t.stroke())}if(f){t.save(),t.beginPath();const w=this.createCanvasFill(t,c,i,n);t.strokeStyle=w||c,t.lineWidth=Math.max(2,i*.12),t.lineCap="round",t.lineJoin="round";const M=a+i*.25,I=r+n*.5,k=a+i*.45,T=r+n*.7,O=a+i*.75,_=r+n*.25;t.moveTo(M,I),t.lineTo(k,T),t.lineTo(O,_),t.stroke(),t.restore()}if(e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const w=e.label;t.save(),t.font=`${w.fontWeight||400} ${w.fontSize||14}px "${w.fontFamily||"Inter"}", sans-serif`,t.fillStyle=w.color||"#f3f4f6",t.textBaseline="middle";const M=w.gap||8;let I=0,k=0;w.position==="left"?(t.textAlign="right",I=a-M,k=0):w.position==="right"?(t.textAlign="left",I=a+i+M,k=0):w.position==="top"?(t.textAlign="center",I=0,k=r-M,t.textBaseline="bottom"):w.position==="bottom"&&(t.textAlign="center",I=0,k=r+n+M,t.textBaseline="top"),t.fillText(w.text,I,k),t.restore()}}renderRadioGroup(t,s){var C,w;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((C=s.geometry)==null?void 0:C.width)||180,n=((w=s.geometry)==null?void 0:w.height)||100,a=-i/2,r=-n/2,l=e.selectedValue,f=e.optionsList||["Option 1","Option 2","Option 3"],h=e.orientation||"vertical",u=e.itemGap!==void 0?e.itemGap:16,c=e.activeColor||"#3b82f6",d=e.inactiveColor||"#4b5563",p=e.textColor||"#ffffff",g=e.fontSize||14,y=e.fontFamily||"Inter",b=e.fontWeight||400;e.disabled&&(t.globalAlpha*=.5);const v=8,S=v*2;if(t.save(),t.font=`${b} ${g}px "${y}", sans-serif`,t.textBaseline="middle",t.textAlign="left",h==="vertical"){const M=Math.max(S,g)+u;f.forEach((I,k)=>{const T=r+k*M+v;t.beginPath(),t.arc(a+v,T,v,0,Math.PI*2);const O=l===I,_=this.createCanvasFill(t,c,S,S),P=this.createCanvasFill(t,d,S,S);O?(t.strokeStyle=_||c,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(a+v,T,v/2,0,Math.PI*2),t.fillStyle=_||c,t.fill()):(t.strokeStyle=P||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=p,t.fillText(I,a+S+8,T)})}else{let M=a;f.forEach(I=>{const k=l===I,T=t.measureText(I).width;t.beginPath(),t.arc(M+v,0,v,0,Math.PI*2);const O=this.createCanvasFill(t,c,S,S),_=this.createCanvasFill(t,d,S,S);k?(t.strokeStyle=O||c,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(M+v,0,v/2,0,Math.PI*2),t.fillStyle=O||c,t.fill()):(t.strokeStyle=_||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=p,t.fillText(I,M+S+6,0),M+=S+6+T+u})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const M=e.label;t.save(),t.font=`${M.fontWeight||400} ${M.fontSize||14}px "${M.fontFamily||"Inter"}", sans-serif`,t.fillStyle=M.color||"#9ca3af",t.textBaseline="middle";const I=M.gap||8;let k=0,T=0;M.position==="left"?(t.textAlign="right",k=a-I,T=0):M.position==="right"?(t.textAlign="left",k=a+i+I,T=0):M.position==="top"?(t.textAlign="center",k=0,T=r-I,t.textBaseline="bottom"):M.position==="bottom"&&(t.textAlign="center",k=0,T=r+n+I,t.textBaseline="top"),t.fillText(M.text,k,T),t.restore()}}renderBarChart(t,s){var T,O;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i={width:((T=s.geometry)==null?void 0:T.width)||300,height:((O=s.geometry)==null?void 0:O.height)||180,chartType:e.chartType||"grouped",stylePreset:e.stylePreset||"default",datasets:e.datasets||[{id:"ds-1",label:"Revenue",data:[42,67,31,55,78,48],color:"#6366f1"}],categories:e.categories||["Jan","Feb","Mar","Apr","May","Jun"],orientation:e.orientation||"vertical",barWidth:e.barWidth!==void 0?e.barWidth:14,barGap:e.barGap!==void 0?e.barGap:4,barCornerRadius:e.barCornerRadius!==void 0?e.barCornerRadius:5,showXAxis:!!e.showXAxis,showYAxis:!!e.showYAxis,xAxisColor:e.xAxisColor||"rgba(255,255,255,0.12)",yAxisColor:e.yAxisColor||"rgba(255,255,255,0.12)",showXLabels:e.showXLabels!==void 0?!!e.showXLabels:!0,showYLabels:!!e.showYLabels,axisLabelColor:e.axisLabelColor||"rgba(255,255,255,0.5)",axisLabelFontSize:e.axisLabelFontSize||9,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.7)",legendFontSize:e.legendFontSize||9,showGridLines:e.showGridLines!==void 0?!!e.showGridLines:!0,gridColor:e.gridColor||"rgba(255,255,255,0.06)",cardBackground:e.cardBackground||"rgba(255,255,255,0.04)",cardBorderColor:e.cardBorderColor||"rgba(255,255,255,0.08)",barGradient:e.barGradient!==void 0?!!e.barGradient:!0,showValueOnTop:!!e.showValueOnTop,chartBackground:e.chartBackground||"transparent",barStyle:e.barStyle||"solid",barBorderWidth:e.barBorderWidth!==void 0?e.barBorderWidth:1,barBorderColor:e.barBorderColor||"auto",enableShadows:!!e.enableShadows,shadowColor:e.shadowColor||"rgba(0,0,0,0.5)",shadowBlur:e.shadowBlur!==void 0?e.shadowBlur:4,shadowOffsetY:e.shadowOffsetY!==void 0?e.shadowOffsetY:2,valueFontSize:e.valueFontSize||10,valueColor:e.valueColor||"auto",valueFontWeight:e.valueFontWeight||"bold",xAxisLineWidth:e.xAxisLineWidth!==void 0?e.xAxisLineWidth:1,yAxisLineWidth:e.yAxisLineWidth!==void 0?e.yAxisLineWidth:1,gridLineWidth:e.gridLineWidth!==void 0?e.gridLineWidth:1,gridLineDash:e.gridLineDash||[3,4],_getPreset:function(){return us[this.stylePreset]||us.default},_resolveColor:function(_,P){const E=this._getPreset();return["#6366f1","#f59e0b","#10b981","#3b82f6","#a855f7"].includes(_)?E.colors[P%E.colors.length]:typeof _=="string"?_:E.colors[P%E.colors.length]},_makeGradient:function(_,P,E,A,B,D){if(!this._getPreset().barGradient&&!this.barGradient)return P;const X=_.createLinearGradient(E,A,B,D);return X.addColorStop(0,P),X.addColorStop(1,P+"44"),X},_drawRoundedBar:function(_,P,E,A,B,D,W){if(D=Math.min(D,Math.min(Math.abs(A),Math.abs(B))/2),D<=0||A===0||B===0){_.rect(P,E,A,B);return}_.beginPath(),W?(_.moveTo(P,E+B),_.lineTo(P,E+D),_.quadraticCurveTo(P,E,P+D,E),_.lineTo(P+A-D,E),_.quadraticCurveTo(P+A,E,P+A,E+D),_.lineTo(P+A,E+B),_.lineTo(P,E+B)):(_.moveTo(P,E),_.lineTo(P+A-D,E),_.quadraticCurveTo(P+A,E,P+A,E+D),_.lineTo(P+A,E+B-D),_.quadraticCurveTo(P+A,E+B,P+A-D,E+B),_.lineTo(P,E+B),_.lineTo(P,E)),_.closePath()}},n=i.width,a=i.height,r=-n/2,l=-a/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}const f=i._getPreset();let h=-1/0,u=1/0;const c=i.categories.length,d=i.datasets.length;if(i.chartType==="stacked")for(let _=0;_<c;_++){let P=0,E=0;i.datasets.forEach(A=>{const B=A.data[_]??0;B>=0?P+=B:E+=B}),P>h&&(h=P),E<u&&(u=E)}else i.datasets.forEach(_=>{_.data&&_.data.forEach(P=>{P>h&&(h=P),P<u&&(u=P)})});isFinite(h)||(h=10),isFinite(u)||(u=0),h=Math.max(h,0),u=Math.min(u,0);const p=h-u||10;t.save(),i.enableShadows&&(t.shadowColor=i.shadowColor,t.shadowBlur=i.shadowBlur,t.shadowOffsetY=i.shadowOffsetY),t.font=i.axisLabelFontSize+"px Inter, sans-serif";const g=i.showYLabels?t.measureText(h.toFixed(0)).width+14:10,y=i.showXLabels?i.axisLabelFontSize+12:8,v=(i.showLegend&&d>0?i.legendFontSize+10:0)+8,S=10,C=r+g,w=l+v,M=n-g-S,I=a-v-y;if(i.enableShadows&&(t.shadowColor="transparent"),t.beginPath(),t.roundRect(r,l,n,a,10),t.fillStyle=f.cardBackground,t.fill(),t.strokeStyle=f.cardBorderColor,t.lineWidth=1,t.stroke(),i.chartBackground&&i.chartBackground!=="transparent"&&(t.beginPath(),t.rect(C,w,M,I),t.fillStyle=i.chartBackground,t.fill()),i.showLegend&&d>0){t.font=i.legendFontSize+"px Inter, sans-serif",t.textBaseline="middle";const _=l+12;let P=C;i.datasets.forEach((E,A)=>{const B=i._resolveColor(E.color,A),D=E.label||"Series "+(A+1),W=7;t.beginPath(),t.roundRect(P,_-W/2,W,W,2),t.fillStyle=B,t.fill(),t.fillStyle=f.legendColor,t.textAlign="left",t.fillText(D,P+W+4,_),P+=t.measureText(D).width+W+16})}const k=4;if(i.showGridLines){t.setLineDash(i.gridLineDash||[]),t.lineWidth=i.gridLineWidth||1,t.strokeStyle=f.gridColor;for(let _=0;_<=k;_++)if(i.orientation==="horizontal"){const P=C+_/k*M;t.beginPath(),t.moveTo(P,w),t.lineTo(P,w+I),t.stroke()}else{const P=w+_/k*I;t.beginPath(),t.moveTo(C,P),t.lineTo(C+M,P),t.stroke()}t.setLineDash([])}if(i.showYLabels){t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=f.axisLabelColor;for(let _=0;_<=k;_++)if(i.orientation==="horizontal"){const P=u+_/k*p,E=C+_/k*M;t.textAlign="center",t.fillText(P.toFixed(0),E,w+I+i.axisLabelFontSize)}else{const P=h-_/k*p,E=w+_/k*I;t.textAlign="right",t.fillText(P.toFixed(0),C-6,E)}}if(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),i.chartType==="stacked")if(i.orientation==="horizontal"){const _=I/c;for(let P=0;P<c;P++){const E=w+P*_+_/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=f.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[P]||"",C-5,E),i.enableShadows&&(t.shadowColor=i.shadowColor));let A=C;i.datasets.forEach((B,D)=>{const W=B.data[P]??0;if(W===0)return;const X=W/p*M,H=Math.min(i.barWidth*d+i.barGap,_-8),Q=E-H/2,L=A;A+=X;const R=i._resolveColor(B.color,D);t.beginPath(),t.fillStyle=i._makeGradient(t,R,L,Q,L+X,Q),i._drawRoundedBar(t,L,Q,X,H,D===d-1?i.barCornerRadius:0,!1),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?R:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else{const _=M/c;for(let P=0;P<c;P++){const E=C+P*_+_/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=f.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[P]||"",E,w+I+5),i.enableShadows&&(t.shadowColor=i.shadowColor));let A=w+I;i.datasets.forEach((B,D)=>{const W=B.data[P]??0;if(W===0)return;const X=W/p*I,H=Math.min(i.barWidth*d+i.barGap,_-8),Q=E-H/2,L=A-X;A-=X;const R=i._resolveColor(B.color,D);t.beginPath(),t.fillStyle=i._makeGradient(t,R,Q,L,Q,L+X),i._drawRoundedBar(t,Q,L,H,X,D===d-1?i.barCornerRadius:0,!0),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?R:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else if(i.orientation==="horizontal"){const _=I/c,P=d*i.barWidth+Math.max(0,(d-1)*i.barGap),E=C+(0-u)/p*M;for(let A=0;A<c;A++){const B=w+A*_+_/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=f.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[A]||"",C-5,B),i.enableShadows&&(t.shadowColor=i.shadowColor));const D=B-P/2;i.datasets.forEach((W,X)=>{const H=W.data[A]??0,Q=Math.abs(H/p*M);if(Q<1)return;const L=D+X*(i.barWidth+i.barGap),R=H>=0?E:E-Q,et=i._resolveColor(W.color,X);t.beginPath(),t.fillStyle=i._makeGradient(t,et,R,L,R+Q,L),i._drawRoundedBar(t,R,L,Q,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(),i.showValueOnTop&&H!==0&&(t.font=(i.valueFontWeight||"bold")+" "+(i.valueFontSize||10)+"px Inter, sans-serif",t.textAlign=H>=0?"left":"right",t.textBaseline="middle",t.fillStyle=i.valueColor==="auto"?et:i.valueColor||"#fff",t.shadowColor="transparent",t.fillText(H.toString(),H>=0?R+Q+4:R-4,L+i.barWidth/2),i.enableShadows&&(t.shadowColor=i.shadowColor))})}}else{const _=M/c,P=d*i.barWidth+Math.max(0,(d-1)*i.barGap),E=w+I-(0-u)/p*I;for(let A=0;A<c;A++){const B=C+A*_+_/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=f.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[A]||"",B,w+I+5),i.enableShadows&&(t.shadowColor=i.shadowColor));const D=B-P/2;i.datasets.forEach((W,X)=>{const H=W.data[A]??0,Q=Math.abs(H/p*I);if(Q<1)return;const L=D+X*(i.barWidth+i.barGap),R=H>=0?E-Q:E,et=i._resolveColor(W.color,X);t.beginPath(),t.fillStyle=i._makeGradient(t,et,L,R,L,R+Q),i._drawRoundedBar(t,L,R,i.barWidth,Q,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(),i.showValueOnTop&&H!==0&&(t.font=(i.valueFontWeight||"bold")+" "+(i.valueFontSize||10)+"px Inter, sans-serif",t.textAlign="center",t.textBaseline=H>=0?"bottom":"top",t.fillStyle=i.valueColor==="auto"?et:i.valueColor||"#fff",t.shadowColor="transparent",t.fillText(H.toString(),L+i.barWidth/2,H>=0?R-4:R+Q+4),i.enableShadows&&(t.shadowColor=i.shadowColor))})}}t.restore()}renderPieChart(t,s){var g,y;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i={width:((g=s.geometry)==null?void 0:g.width)||180,height:((y=s.geometry)==null?void 0:y.height)||180,chartType:e.chartType||"donut",stylePreset:e.stylePreset||"default",slices:e.slices||[{id:"slice-1",label:"Item 1",value:45,color:"#6366f1"}],innerRadius:e.innerRadius!==void 0?e.innerRadius:.55,sliceGap:e.sliceGap!==void 0?e.sliceGap:3,showLabels:!!e.showLabels,labelColor:e.labelColor||"#ffffff",labelFontSize:e.labelFontSize||10,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.65)",legendFontSize:e.legendFontSize||9,showCenterText:e.showCenterText!==void 0?!!e.showCenterText:!0,centerLabel:e.centerLabel||"Total",centerTextColor:e.centerTextColor||"#ffffff",centerLabelColor:e.centerLabelColor||"rgba(255,255,255,0.4)",_getPreset:function(){return gs[this.stylePreset]||gs.default},_resolveSliceColor:function(b,v){const S=b.color,C=v,w=this._getPreset();return["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399","#a855f7","#f87171"].includes(S)?w.colors[C%w.colors.length]:typeof S=="string"?S:w.colors[C%w.colors.length]}},n=i.width,a=i.height;if(!i.slices||i.slices.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO PIE DATA",0,0),t.restore();return}const r=i.slices.reduce((b,v)=>b+(v.value||0),0);if(r<=0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("EMPTY DATA",0,0),t.restore();return}const l=i._getPreset();t.save(),t.beginPath(),t.roundRect(-n/2,-a/2,n,a,10),t.fillStyle=l.cardBackground,t.fill(),t.strokeStyle=l.cardBorderColor,t.lineWidth=1,t.stroke();const f=i.showLegend?Math.ceil(i.slices.length/2):0,h=f>0?f*(i.legendFontSize+8)+10:0,u=a-h-16,c=Math.min(n-24,u)/2,d=0,p=-h/2;if(i.chartType==="rose"){const b=Math.max(...i.slices.map(C=>C.value||0)),v=Math.PI*2/i.slices.length,S=c>0?i.sliceGap/c:0;i.slices.forEach((C,w)=>{const M=C.value||0;if(M===0)return;const I=M/b*c,k=-Math.PI/2+w*v+S/2,T=k+v-S,O=i._resolveSliceColor(C,w);if(t.beginPath(),t.moveTo(d,p),t.arc(d,p,I,k,T),t.closePath(),t.fillStyle=O+"cc",t.fill(),t.strokeStyle=O,t.lineWidth=1.5,t.stroke(),i.showLabels){const _=k+(T-k)/2,P=d+I*.65*Math.cos(_),E=p+I*.65*Math.sin(_),A=Math.round(M/r*100);t.save(),t.font=`bold ${i.labelFontSize}px Inter, sans-serif`,t.fillStyle=l.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${A}%`,P,E),t.restore()}})}else{const b=i.chartType==="pie"?0:i.innerRadius,v=c*Math.max(0,b),S=c>0?i.sliceGap/c:0;let C=-Math.PI/2;if(i.slices.forEach((w,M)=>{const I=w.value||0;if(I===0){C+=I/r*Math.PI*2;return}const k=I/r*Math.PI*2,T=C+S/2,O=C+k-S/2;if(O<=T){C+=k;return}const _=i._resolveSliceColor(w,M);if(t.beginPath(),t.fillStyle=_,v<=0?(t.moveTo(d,p),t.arc(d,p,c,T,O),t.lineTo(d,p)):(t.moveTo(d+c*Math.cos(T),p+c*Math.sin(T)),t.arc(d,p,c,T,O),t.arc(d,p,v,O,T,!0),t.closePath()),t.fill(),i.showLabels){const P=T+(O-T)/2,E=v+(c-v)/2,A=d+E*Math.cos(P),B=p+E*Math.sin(P),D=Math.round(I/r*100);t.save(),t.font=`bold ${i.labelFontSize}px Inter, sans-serif`,t.fillStyle=l.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${D}%`,A,B),t.restore()}C+=k}),i.chartType==="donut"&&i.showCenterText&&v>14){const w=Math.round(r),M=Math.min(Math.floor(v*.52),20),I=Math.min(Math.floor(v*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${M}px Inter, sans-serif`,t.fillStyle=l.centerTextColor,t.fillText(w.toString(),d,p-I*.5),i.centerLabel&&(t.font=`${I}px Inter, sans-serif`,t.fillStyle=l.centerLabelColor,t.fillText(i.centerLabel,d,p+M*.6))}}if(i.showLegend&&i.slices.length>0){t.font=`${i.legendFontSize}px Inter, sans-serif`;const b=2,v=n/b,S=i.legendFontSize+8,C=a/2-h+10,w=-n/2+10;i.slices.forEach((M,I)=>{const k=I%b,T=Math.floor(I/b),O=w+k*v,_=C+T*S,P=i._resolveSliceColor(M,I),E=7;t.beginPath(),t.roundRect(O,_-E/2,E,E,2),t.fillStyle=P,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=l.legendColor;const A=Math.round((M.value||0)/r*100),B=`${M.label||"Item"} ${A}%`,D=v-E-20;let W=B;for(;t.measureText(W).width>D&&W.length>4;)W=W.slice(0,-4)+"…";t.fillText(W,O+E+4,_)})}t.restore()}renderJoystick(t,s){var p,g,y,b,v;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.width)!==void 0?o.width:((p=s.geometry)==null?void 0:p.width)??s.width??100,i=(o==null?void 0:o.height)!==void 0?o.height:((g=s.geometry)==null?void 0:g.height)??s.height??100,n=Math.min(e,i)*.45,a=Math.min(e,i)*.15;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 f=0,h=0;s.handleOrigin==="top-left"?(f=e/2,h=i/2):s.handleOrigin==="bottom-right"&&(f=-e/2,h=-i/2),t.translate(f,h),t.beginPath(),s.boundsShape==="square"?t.rect(-n,-n,n*2,n*2):t.arc(0,0,n,0,Math.PI*2),t.fillStyle="rgba(0,0,0,0.2)",(y=s.style)!=null&&y.fill&&typeof s.style.fill=="string"?t.fillStyle=s.style.fill:(b=s.style)!=null&&b.fill&&s.style.fill.type==="solid"&&(t.fillStyle=s.style.fill.color),t.fill(),(v=s.style)!=null&&v.stroke&&s.style.stroke.isEnabled!==!1&&(t.lineWidth=s.style.stroke.width||1,t.strokeStyle=s.style.stroke.color||"#000",t.stroke());const u=n-a;let c=0,d=0;s.joystickType==="2D"?(c=r*u,d=l*u):s.joystickType==="1D_X"?(c=r*u,d=0):s.joystickType==="1D_Y"&&(c=0,d=l*u),t.beginPath(),t.arc(c,d,a,0,Math.PI*2),t.fillStyle="#fff",t.fill(),t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1,t.stroke(),t.restore()}getRadioGroupItemIndexAtPointer(t,s,o){var I,k;const e=t.options||{},i=this.objectStates.get(t.id)||{},n=e.optionsList||[];if(n.length===0)return null;const a=i.width!==void 0?i.width:((I=t.geometry)==null?void 0:I.width)||180,r=i.height!==void 0?i.height:((k=t.geometry)==null?void 0:k.height)||100,l=e.orientation||"vertical",f=e.itemGap!==void 0?e.itemGap:16,h=e.fontSize||14,u=this.getWorldTransform(t.id),c=s-u.x,d=o-u.y,p=-u.rotation*(Math.PI/180),g=Math.cos(p),y=Math.sin(p),b=c*g-d*y,v=c*y+d*g,C=8*2,w=-a/2,M=-r/2;if(l==="vertical"){const T=Math.max(C,h)+f;for(let O=0;O<n.length;O++){const _=M+O*T;if(b>=w&&b<=w+a&&v>=_&&v<=_+T)return O}}else{let T=w;for(let O=0;O<n.length;O++){const P=n[O].length*8,E=C+6+P+f;if(b>=T&&b<=T+E&&v>=M&&v<=M+r)return O;T+=E}}return null}renderLineGraph(t,s,o,e){let i=s.datasets||[];if((!i||i.length===0)&&(s.data||s.graphData)&&(i=[{id:"line-1",label:"Series 1",data:s.data||s.graphData||[],lineColor:s.lineColor||"#3b82f6",lineWidth:s.lineWidth||2,showArea:s.showArea||!1,areaColor:s.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:s.smoothing||!1,showPoints:s.showPoints!==void 0?s.showPoints:!0,pointSize:s.pointSize||6,pointFill:s.pointFill||"#ffffff",pointStrokeColor:s.pointStrokeColor||s.lineColor||"#3b82f6",pointStrokeWidth:s.pointStrokeWidth||2}]),!i||i.length===0||!i.some(p=>p.data&&p.data.length>=2)){t.save(),t.fillStyle="#6366f1",t.font="12px Inter, system-ui, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO DATA",0,0),t.restore();return}let n=1/0,a=-1/0,r=0;if(i.forEach(p=>{let g=p.data;if(p.isVarEnabled&&p.inputId){let y=this.inputs.get(p.inputId);if(y===void 0){const b=this.inputNameMap.get(p.inputId);b&&b.length>0&&(y=this.inputs.get(b[0]))}y&&Array.isArray(y)&&(g=y)}if(g&&g.length>0){const y=g.filter(b=>typeof b=="number"&&!isNaN(b));y.length>0&&(n=Math.min(n,...y),a=Math.max(a,...y),r=Math.max(r,g.length))}p._resolvedData=g}),r<2)return;const l=a-n,f=o/(r-1),h=p=>{const g=l===0?.5:(p-n)/l;return e/2-g*e},u=p=>p*f-o/2,c=s.axisColor||"#333333";if(s.showXAxis&&(t.beginPath(),t.strokeStyle=s.xAxisColor||c,t.lineWidth=1,t.moveTo(-o/2,e/2),t.lineTo(o/2,e/2),t.stroke()),s.showYAxis&&(t.beginPath(),t.strokeStyle=s.yAxisColor||c,t.lineWidth=1,t.moveTo(-o/2,-e/2),t.lineTo(-o/2,e/2),t.stroke()),t.fillStyle=s.axisLabelColor||"#333333",t.font=`${s.axisLabelFontSize||10}px Inter, sans-serif`,s.showXLabels){t.textAlign="center",t.textBaseline="top";for(let p=0;p<r;p++){const g=u(p);t.fillText(`${p+1}`,g,e/2+5)}}if(s.showYLabels){t.textAlign="right",t.textBaseline="middle";const p=-o/2-5,g=(a+n)/2;t.fillText(a.toFixed(1),p,h(a)),t.fillText(g.toFixed(1),p,h(g)),t.fillText(n.toFixed(1),p,h(n))}const d=10;if(i.forEach(p=>{const g=p._resolvedData;if(!(!g||g.length<2)){if(p.showArea){if(t.beginPath(),t.moveTo(u(0),e/2),t.lineTo(u(0),h(g[0])),p.smoothing&&g.length>2)for(let b=0;b<g.length-1;b++){const v=g[b===0?b:b-1],S=g[b],C=g[b+1],w=g[b+1===g.length-1?b+1:b+2];for(let M=1;M<=d;M++){const I=M/d,k=this._catmullRom(v,S,C,w,I);t.lineTo(u(b+I),h(k))}}else for(let b=1;b<g.length;b++)t.lineTo(u(b),h(g[b]));t.lineTo(u(g.length-1),e/2),t.closePath();const y=t.globalAlpha;t.globalAlpha=y*(s.areaOpacity??.3),t.fillStyle=p.areaColor||"rgba(139, 92, 246, 0.2)",t.fill(),t.globalAlpha=y}if(t.beginPath(),t.strokeStyle=p.lineColor||"#3b82f6",t.lineWidth=p.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.moveTo(u(0),h(g[0])),p.smoothing&&g.length>2)for(let y=0;y<g.length-1;y++){const b=g[y===0?y:y-1],v=g[y],S=g[y+1],C=g[y+1===g.length-1?y+1:y+2];for(let w=1;w<=d;w++){const M=w/d,I=this._catmullRom(b,v,S,C,M);t.lineTo(u(y+M),h(I))}}else for(let y=1;y<g.length;y++)t.lineTo(u(y),h(g[y]));t.stroke(),p.showPoints&&g.forEach((y,b)=>{const v=u(b),S=h(y);t.beginPath(),t.arc(v,S,(p.pointSize||6)/2,0,Math.PI*2),t.fillStyle=p.pointFill||"#ffffff",t.fill(),t.strokeStyle=p.pointStrokeColor||p.lineColor||"#3b82f6",t.lineWidth=p.pointStrokeWidth||1,t.stroke()})}}),s.showLegend&&i.length>0){const p=o/2-10;let g=-e/2+15;const y=s.legendFontSize||10,b=y+5;t.font=`${y}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",i.forEach(v=>{const C=v.label||"Series",w=t.measureText(C).width;t.beginPath(),t.rect(p-w-8-5,g-(8/2+2),8,8),t.fillStyle=v.lineColor||"#3b82f6",t.fill(),t.fillStyle=s.legendColor||"#333333",t.fillText(C,p,g),g+=b})}}_catmullRom(t,s,o,e,i){const n=(o-t)*.5,a=(e-s)*.5,r=i*i,l=i*r;return(2*s-2*o+n+a)*l+(-3*s+3*o-2*n-a)*r+n*i+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 i,n,a;if(!s||s.type==="None")return null;if(typeof s=="string")return s;if(s.type==="Solid"&&s.color){const r=s.color,f=(((n=(i=this.artboard)==null?void 0:i.tokens)==null?void 0:n.colors)||{})[r]||r;return t.fillStyle=f,f}if((s.type==="LinearGradient"||s.type==="RadialGradient"||s.type==="AngularGradient"||s.type==="DiamondGradient")&&s.stops){const r=(l,f=100)=>{var S,C;const u=(((C=(S=this.artboard)==null?void 0:S.tokens)==null?void 0:C.colors)||{})[l]||l,c=this.normalizeOpacity(s.opacity??100),p=this.normalizeOpacity(f)*c;if(p>=1&&u.startsWith("#"))return u;const g=u.startsWith("#")?u.replace("#",""):"ffffff",y=parseInt(g.substring(0,2),16),b=parseInt(g.substring(2,4),16),v=parseInt(g.substring(4,6),16);return`rgba(${y}, ${b}, ${v}, ${p})`};if(s.type==="LinearGradient"){const l=(p,g,y)=>Array.isArray(p)?p[g]??(g===0?0:1):p&&typeof p=="object"?p[y]??(g===0?0:1):g===0?0:1,f=l(s.start,0,"x")*o-o/2,h=l(s.start,1,"y")*e-e/2,u=l(s.end,0,"x")*o-o/2,c=l(s.end,1,"y")*e-e/2,d=t.createLinearGradient(f,h,u,c);if(s.stops.forEach(p=>{const g=p.offset!==void 0?p.offset:p.pos!==void 0?p.pos:p.position!==void 0?p.position:0,y=r(p.color||"#000000",p.opacity??100);d.addColorStop(Math.max(0,Math.min(1,g)),y)}),s.gradientTransform&&d.setTransform){const[p,g,y,b,v,S]=s.gradientTransform;d.setTransform({a:p,b:g,c:y,d:b,e:v,f:S})}return d}else if(s.type==="RadialGradient"){const l=(d,p,g)=>Array.isArray(d)?d[p]??.5:d&&typeof d=="object"?d[g]??.5:.5,f=l(s.center,0,"x")*o-o/2,h=l(s.center,1,"y")*e-e/2,u=(s.radius??.5)*Math.max(o,e),c=t.createRadialGradient(f,h,0,f,h,u);if(s.stops.forEach(d=>{const p=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,g=r(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,p)),g)}),s.gradientTransform&&c.setTransform){const[d,p,g,y,b,v]=s.gradientTransform;c.setTransform({a:d,b:p,c:g,d:y,e:b,f:v})}return c}else if(s.type==="AngularGradient"){const l=(d,p,g)=>Array.isArray(d)?d[p]??.5:d&&typeof d=="object"?d[g]??.5:.5,f=l(s.center||[.5,.5],0,"x")*o-o/2,h=l(s.center||[.5,.5],1,"y")*e-e/2,u=(s.degree||s.angle||0)*(Math.PI/180),c=(a=t.createConicGradient)==null?void 0:a.call(t,u,f,h);if(c){if(s.stops.forEach(d=>{const p=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,g=r(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,p)),g)}),s.gradientTransform&&c.setTransform){const[d,p,g,y,b,v]=s.gradientTransform;c.setTransform({a:d,b:p,c:g,d:y,e:b,f:v})}return c}}else if(s.type==="DiamondGradient"){const l=(d,p,g)=>Array.isArray(d)?d[p]??.5:d&&typeof d=="object"?d[g]??.5:.5,f=l(s.center||[.5,.5],0,"x")*o-o/2,h=l(s.center||[.5,.5],1,"y")*e-e/2,u=(s.radius??.5)*Math.max(o,e);t.save(),t.translate(f,h),t.rotate(Math.PI/4);const c=t.createRadialGradient(0,0,0,0,0,u);if(s.stops.forEach(d=>{const p=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,g=r(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,p)),g)}),s.gradientTransform&&c.setTransform){const[d,p,g,y,b,v]=s.gradientTransform;c.setTransform({a:d,b:p,c:g,d:y,e:b,f:v})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=c,t.restore(),c}}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 f=new DOMMatrix,h=s.scaleX??1,u=s.scaleY??1,c=s.offsetX??0,d=s.offsetY??0,p=s.rotation??0;f.translateSelf(c,d),f.rotateSelf(p),f.scaleSelf(h,u),l.setTransform(f)}return l}}return s.color||null}drawRoundRect(t,s,o,e,i,n){if(n===0||n===void 0||n===null){t.rect(s,o,e,i);return}let a=n;if(typeof a=="string")try{a=JSON.parse(a)}catch{a=parseFloat(a)||0}let r=0,l=0,f=0,h=0;typeof a=="number"?r=l=f=h=a:Array.isArray(a)?a.length===1?r=l=f=h=a[0]:a.length===2?(r=f=a[0],l=h=a[1]):a.length===3?(r=a[0],l=h=a[1],f=a[2]):a.length>=4&&(r=a[0],l=a[1],f=a[2],h=a[3]):a&&typeof a=="object"&&(r=a.tl??a.corner_radius??a.cornerRadius??0,l=a.tr??a.corner_radius??a.cornerRadius??0,f=a.br??a.corner_radius??a.cornerRadius??0,h=a.bl??a.corner_radius??a.cornerRadius??0);const u=Math.min(Math.abs(e)/2,Math.abs(i)/2);if(r=Math.min(Math.max(0,r),u),l=Math.min(Math.max(0,l),u),f=Math.min(Math.max(0,f),u),h=Math.min(Math.max(0,h),u),t.roundRect){t.roundRect(s,o,e,i,[r,l,f,h]);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+i-f),t.arcTo(s+e,o+i,s+e-f,o+i,f),t.lineTo(s+h,o+i),t.arcTo(s,o+i,s,o+i-h,h),t.lineTo(s,o+r),t.arcTo(s,o,s+r,o,r),t.closePath()}renderListView(t,s){var A,B,D,W;const o=this.objectStates.get(s.id)||{},e=o.options||s.options||{},i=o.width!==void 0?o.width:((A=s.geometry)==null?void 0:A.width)||200,n=o.height!==void 0?o.height:((B=s.geometry)==null?void 0:B.height)||300,a=-i/2,r=-n/2,l=o.corner_radius!==void 0?o.corner_radius:e.corner_radius??0,f=e.orientation||"vertical",h=e.items||[],u=e.itemGap??10,c=e.itemHeight??50,d=e.itemWidth??200,p=e.scrollOffset??0,g=e.padding??0,y=e.glassEffect!==!1,b=e.accentColor||"#3b82f6",v=e.itemTextColor||"#333333",S=e.itemBackgroundColor||"#ffffff",C=e.hoveredIndex??null,w=e.activeItemIndex??null,M=e.glowIntensity??0,I=e.glowColor||"#3b82f6",k=typeof I=="string"?I:I.color||((W=(D=I.stops)==null?void 0:D[0])==null?void 0:W.color)||"#3b82f6",T=e.opacity!==void 0?e.opacity:s.opacity!==void 0?s.opacity:1;if(t.save(),t.globalAlpha*=T,M>0){const X=t.getTransform(),H=Math.sqrt(X.a*X.a+X.b*X.b)||1;t.shadowColor=k,t.shadowBlur=M*2*H,t.shadowOffsetX=0,t.shadowOffsetY=0}if(y){const X=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",H=this.createCanvasFill(t,X,i,n);t.fillStyle=H||"rgba(31, 41, 55, 0.4)",t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,i,n,l)||t.fill();const L=t.createLinearGradient(a,r,a+i,r+n);L.addColorStop(0,"rgba(255, 255, 255, 0.15)"),L.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),L.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=L,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,i,n,l)||t.fill(),t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,i,n,l)||t.stroke()}else{const X=e.backgroundColor||e.listBackgroundColor||"transparent",H=this.createCanvasFill(t,X,i,n);if(H){t.fillStyle=H,t.beginPath();const L=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,i,n,l);t.fill()}const Q=e.borderWidth??0;if(Q>0){t.strokeStyle=e.borderColor||"#cccccc",t.lineWidth=Q,t.beginPath();const L=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,i,n,l);t.stroke()}}t.shadowBlur=0,t.save(),t.beginPath();const O=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,i,n,l);if(e.listLayout!=="circular")if(O&&e.containerShape==="custom")try{const X=new Path2D(e.containerPath);t.translate(a,r),t.scale(i/100,n/100),t.clip(X),t.scale(100/i,100/n),t.translate(-a,-r)}catch{}else t.clip();const _=typeof g=="number"?g:f==="vertical"?g[0]:g[3];let P=(f==="vertical"?r:a)+p+_;if(t.textBaseline="middle",h.forEach((X,H)=>{const Q=e.listLayout||"linear",L=Q==="circular"?d:f==="vertical"?i:d,R=Q==="circular"||f==="vertical"?c:n;let et=0,U=0,lt=0;if(Q==="circular"){const Et=h.length||1,Ut=Math.PI*2/Et,re=e.circularStartAngle||0,he=e.circularRadius||100,nt=p*.01+re*Math.PI/180,yt=H*Ut+nt,Tt=a+i/2,_t=r+n/2;et=Tt+Math.cos(yt)*he-L/2,U=_t+Math.sin(yt)*he-R/2,lt=yt+(e.itemRotation||0)*Math.PI/180}else et=f==="vertical"?a:P,U=f==="vertical"?P:r,lt=(e.itemRotation||0)*Math.PI/180;const x=C===H,F=w===H,N=F&&e.activeItemShape?e.activeItemShape:e.itemShape||"rectangle",st=F&&e.activeItemShape?e.activeItemPath:e.itemPath||"",z=e.itemCornerRadius||0;if(t.save(),lt!==0&&(t.translate(et+L/2,U+R/2),t.rotate(lt),t.translate(-(et+L/2),-(U+R/2))),F){const Et=this.createCanvasFill(t,b,L,R);t.fillStyle=Et||b;const Ut=t.globalAlpha;t.globalAlpha=Ut*.8,t.beginPath(),this.drawCustomShape(t,N,st,et,U,L,R,z)||(t.rect(et,U,L,R),t.fill()),t.globalAlpha=Ut}else if(x)t.fillStyle=y?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",t.beginPath(),this.drawCustomShape(t,N,st,et,U,L,R,z)||(t.rect(et,U,L,R),t.fill());else if(S!=="transparent"){const Et=this.createCanvasFill(t,S,L,R);t.fillStyle=Et||S,t.beginPath(),this.drawCustomShape(t,N,st,et,U,L,R,z)||(t.rect(et,U,L,R),t.fill())}if(F||x){const Et=this.createCanvasFill(t,b,f==="vertical"?3:L,f==="vertical"?R:3);t.fillStyle=Et||b,f==="vertical"?t.fillRect(et,U,3,R):t.fillRect(et,U+R-3,L,3)}const gt=F?"#ffffff":y?"rgba(255, 255, 255, 0.9)":v;t.fillStyle=gt,t.font=F||x?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const mt=typeof X=="string"?X:(X==null?void 0:X.label)||`Item ${H+1}`,ut=et+(f==="vertical"?16:L/2),wt=U+R/2;f==="horizontal"||Q==="circular"?t.textAlign="center":t.textAlign="left";const Mt=Q==="circular"?et+L/2:ut;t.fillText(mt,Mt,wt),t.restore(),P+=(f==="vertical"?c:d)+u}),t.restore(),e.showScrollbar!==!1){const X=(h.length||0)*(f==="vertical"?c:d)+((h.length||0)-1)*u,H=f==="vertical"?n:i,Q=e.listLayout||"linear",L=e.containerShape==="circle"||Q==="circular";if(X>H||Q==="circular"&&h.length>0){const R=e.scrollbarColor||"rgba(255,255,255,0.3)",et=e.scrollbarWidth||4;if(L){const U=Math.min(i,n)/2-et/2-2,lt=a+i/2,x=r+n/2;if(t.strokeStyle=R,t.lineWidth=et,t.lineCap="round",t.beginPath(),Q==="circular"){const F=Math.PI/4,N=-(p*.01)-Math.PI/2;t.arc(lt,x,U,N,N+F)}else{const F=Math.PI/2,N=H/X,st=F*N,z=-p/X*F,mt=-Math.PI/4+z;t.arc(lt,x,U,mt,mt+st)}t.stroke()}else{const U=H/X,lt=H*U,x=-p/X*H;t.fillStyle=R,f==="vertical"?t.fillRect(a+i-et-2,r+x,et,lt):t.fillRect(a+x,r+n-et-2,lt,et)}}}t.restore()}drawCustomShape(t,s,o,e,i,n,a,r){if(s==="circle"){const l=Math.min(n,a)/2;return t.arc(e+n/2,i+a/2,l,0,Math.PI*2),!1}else if(s==="pill"){const l=Math.min(n,a)/2;return this.drawListViewRect(t,e,i,n,a,l),!1}else if(s==="custom"&&o)try{const l=new Path2D(o);return t.save(),t.translate(e,i),t.scale(n/100,a/100),t.fill(l),t.restore(),!0}catch{return this.drawListViewRect(t,e,i,n,a,r),!1}return this.drawListViewRect(t,e,i,n,a,r),!1}updateListViewScrollFromPointer(t){var y,b;if(!this._lastPointerPos||!this._prevPointerPos)return;const s=t.options||{},o=s.orientation||"vertical",e=this._lastPointerPos.x-this._prevPointerPos.x,i=this._lastPointerPos.y-this._prevPointerPos.y;o==="vertical"?s.scrollOffset=(s.scrollOffset||0)+i:s.scrollOffset=(s.scrollOffset||0)+e;const n=s.listLayout||"linear",a=this.objectStates.get(t.id)||{},r=s.items||[],l=s.itemGap??10,f=s.itemHeight??50,h=s.itemWidth??200,u=a.width!==void 0?a.width:((y=t.geometry)==null?void 0:y.width)||200,c=a.height!==void 0?a.height:((b=t.geometry)==null?void 0:b.height)||300;if(n==="circular")return;const d=(r.length||0)*(o==="vertical"?f:h)+((r.length||0)-1)*l,g=Math.max(0,d-(o==="vertical"?c:u)+(s.padding*2||0));s.scrollOffset>0&&(s.scrollOffset=0),s.scrollOffset<-g&&(s.scrollOffset=-g)}updateListViewHoverFromPointer(t,s,o){const e=this.getListViewItemIndexAtPointer(t,s,o),i=t.options||{};i.hoveredIndex!==e&&(i.hoveredIndex=e)}getListViewItemIndexAtPointer(t,s,o){var D,W;const e=t.options||{},i=this.objectStates.get(t.id)||{},n=e.items||[];if(n.length===0)return null;const a=i.width!==void 0?i.width:((D=t.geometry)==null?void 0:D.width)||200,r=i.height!==void 0?i.height:((W=t.geometry)==null?void 0:W.height)||300,l=e.orientation||"vertical",f=e.itemGap??10,h=e.itemHeight??50,u=e.itemWidth??200,c=e.scrollOffset??0,d=e.padding??0,p=this.getWorldTransform(t.id),g=s-p.x,y=o-p.y,b=-p.rotation*(Math.PI/180),v=Math.cos(b),S=Math.sin(b),C=g*v-y*S,w=g*S+y*v,M=-a/2,I=-r/2,k=typeof d=="number"?d:l==="vertical"?d[0]:d[3];let T=(l==="vertical"?I:M)+c+k;const O=e.listLayout||"linear",_=n.length||1,P=Math.PI*2/_,E=e.circularStartAngle||0,A=e.circularRadius||100,B=c*.01+E*Math.PI/180;for(let X=0;X<n.length;X++){const H=O==="circular"?u:l==="vertical"?a:u,Q=O==="circular"||l==="vertical"?h:r;let L=0,R=0,et=0;if(O==="circular"){const U=X*P+B,lt=M+a/2,x=I+r/2;L=lt+Math.cos(U)*A-H/2,R=x+Math.sin(U)*A-Q/2,et=U+(e.itemRotation||0)*Math.PI/180}else L=l==="vertical"?M:T,R=l==="vertical"?T:I,et=(e.itemRotation||0)*Math.PI/180;if(et!==0){const U=L+H/2,lt=R+Q/2,x=C-U,F=w-lt,N=-et,st=x*Math.cos(N)-F*Math.sin(N)+U,z=x*Math.sin(N)+F*Math.cos(N)+lt;if(st>=L&&st<=L+H&&z>=R&&z<=R+Q)return X}else if(C>=L&&C<=L+H&&w>=R&&w<=R+Q)return X;T+=(l==="vertical"?h:u)+f}return null}drawListViewRect(t,s,o,e,i,n){t.beginPath(),this.drawRoundRect(t,s,o,e,i,n),t.fill()}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 i=this.objectStates.get(e.id);i&&e.behaviors.forEach(n=>{var u,c,d,p,g,y,b,v,S,C,w,M,I,k,T,O,_,P,E,A,B,D,W,X,H,Q,L,R,et,U,lt,x,F,N,st,z,gt,mt,ut,wt,Mt,Et,Ut,re,he,nt,yt,Tt,_t,St,Ft,Gt,Bt,Wt,Jt,Yt,we,Me,Zt,le,Ee,Ie,ke,de,pe,ot,ft,it,G,at,V,dt,vt,Pt,Ht,kt,At,$,Xt,ne,ie,Nt,Rt,Ct,ht,j,bt,Y,rt,tt,qt,jt,Se,Vt,te,Qt,Te,Ae,Oe,Le,xe,Re,Ye,Kt,ae,ue,Fe,$e,me,ge,ye,Pe,Xe,Ue,qe,De,Ke,Je;if(!n.enabled)return;const a=n.startTime||0,r=n.endTime||1/0;if(this.currentTime<a||this.currentTime>r)return;const l=i.x-s,f=i.y-o,h=Math.sqrt(l*l+f*f);if(this.frameCount%240===0&&Math.random()<.1&&this.log(`[ExodeUI] Executing ${n.type} on ${e.name}`),n.type===q.Proximity){const K=((u=n.settings)==null?void 0:u.radius)||300,Z=((c=n.settings)==null?void 0:c.falloff)||"smooth";let J=0;h<K&&(Z==="linear"?J=1-h/K:J=Math.pow(1-h/K,2)),n.sensors.forEach(pt=>{this.applyBehaviorSensor(i,pt,J,t,n.settings,e,l,f,h)})}else if(n.type===q.Magnetic){const K=((d=n.settings)==null?void 0:d.radius)||400,Z=((p=n.settings)==null?void 0:p.strength)||.5;if(h<K&&h>5){const J=1-h/K,pt=l*J*Z,Ot=f*J*Z;i.x-=pt*t*10,i.y-=Ot*t*10}}else if(n.type===q.Repel){const K=((g=n.settings)==null?void 0:g.radius)||300,Z=((y=n.settings)==null?void 0:y.strength)||1;if(h<K){const J=Math.pow(1-h/K,2);i.x+=l/(h||1)*J*60*Z*t*5,i.y+=f/(h||1)*J*60*Z*t*5}}else if(n.type===q.Orbit){const K=((b=n.settings)==null?void 0:b.speed)||1,Z=((v=n.settings)==null?void 0:v.radius)||30,J=this.currentTime*K*Math.PI*2;i.x+=Math.cos(J)*Z*t*5,i.y+=Math.sin(J)*Z*t*5,i.rotation+=2*t*5}else if(n.type===q.Vortex){const K=((S=n.settings)==null?void 0:S.radius)||400,Z=((C=n.settings)==null?void 0:C.speed)||2,J=((w=n.settings)==null?void 0:w.strength)||1;if(h<K){const pt=Math.pow(1-h/K,1.5),Ot=this.currentTime*Z*Math.PI*2,xt=Math.cos(Ot)*30-l*.4,$t=Math.sin(Ot)*30-f*.4;i.x+=xt*pt*J*t*5,i.y+=$t*pt*J*t*5,i.rotation+=5*pt*J*t*5,i.scale_x*=1-pt*.1*J*t,i.scale_y*=1-pt*.1*J*t}}else if(n.type===q.Fluid){const K=((M=n.settings)==null?void 0:M.radius)||300,Z=((I=n.settings)==null?void 0:I.strength)||1;if(h<K){const J=Math.pow(1-h/K,1.2),pt=l/(h||1)*J*1.2*Z,Ot=f/(h||1)*J*1.2*Z;i.x+=pt*10*t*5,i.y+=Ot*10*t*5,i.scale_x*=1+J*.3*Z*t,i.scale_y*=1+J*.3*Z*t}}else if(n.type===q.Elastic){const K=((k=n.settings)==null?void 0:k.radius)||300,Z=((T=n.settings)==null?void 0:T.strength)||1;if(h<K){const J=1-h/K;i.scale_x*=1+J*.4*Z*t,i.scale_y*=1+J*.4*Z*t}}else if(n.type===q.Holographic){const K=i.x-this.canvasWidth/2,Z=i.y-this.canvasHeight/2,J=((O=n.settings)==null?void 0:O.factor)||25;if(i.x-=K/1e3*J*t*5,i.y-=Z/1e3*J*t*5,i.style){const pt=1-Math.min(1,h/400);i.style.exposure=(i.style.exposure||1)+pt*.5*t}}else if(n.type===q.Sticky){const K=((_=n.settings)==null?void 0:_.radius)||80,Z=((P=n.settings)==null?void 0:P.strength)||1;if(h<K){const J=Math.pow(1-h/K,2);i.x-=l*J*Z*t*10,i.y-=f*J*Z*t*10,i.scale_x*=1-J*.1*Z*t,i.scale_y*=1-J*.1*Z*t}}else if(n.type===q.Dilation){const K=((E=n.settings)==null?void 0:E.size)||120,Z=((A=n.settings)==null?void 0:A.strength)||1;if(h<K){const J=1-h/K;i.scale_x*=1+J*.5*Z*t,i.scale_y*=1+J*.5*Z*t}}else if(n.type===q.Parallax){const K=((B=n.settings)==null?void 0:B.factor)||15,Z=((D=n.settings)==null?void 0:D.strength)||1,J=this.canvasWidth/2,pt=this.canvasHeight/2,Ot=this._lastPointerPos||{x:J,y:pt},xt=(Ot.x-J)/J,$t=(Ot.y-pt)/pt,oe=(((W=e.transform)==null?void 0:W.x)??0)+xt*K*Z,be=(((X=e.transform)==null?void 0:X.y)??0)+$t*K*Z,_e=(((H=e.transform)==null?void 0:H.rotate_x)??0)-$t*K*1.5*Z,ce=(((Q=e.transform)==null?void 0:Q.rotate_y)??0)+xt*K*1.5*Z,Ce=Math.min(1,10*t);i.x=this.lerp(i.x??((L=e.transform)==null?void 0:L.x)??0,oe,Ce),i.y=this.lerp(i.y??((R=e.transform)==null?void 0:R.y)??0,be,Ce),i.rotate_x=this.lerp(i.rotate_x??((et=e.transform)==null?void 0:et.rotate_x)??0,_e,Ce),i.rotate_y=this.lerp(i.rotate_y??((U=e.transform)==null?void 0:U.rotate_y)??0,ce,Ce)}else if(n.type===q.Fold){if(h<300){const K=1-h/300,Z=(l>0?-1:1)*K*10,J=1-K*.1,pt=f/300*K*20,Ot=-(l/300)*K*20,xt=Math.min(1,10*t);i.skew_x=this.lerp(i.skew_x??((lt=e.transform)==null?void 0:lt.skew_x)??0,Z,xt),i.scale_y=this.lerp(i.scale_y??((x=e.transform)==null?void 0:x.scale_y)??1,(((F=e.transform)==null?void 0:F.scale_y)??1)*J,xt),i.rotate_x=this.lerp(i.rotate_x??((N=e.transform)==null?void 0:N.rotate_x)??0,pt,xt),i.rotate_y=this.lerp(i.rotate_y??((st=e.transform)==null?void 0:st.rotate_y)??0,Ot,xt),i.style=i.style||{...e.style},i.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((z=n.settings)==null?void 0:z.opacity)??.5}}}else if(n.type===q.Crumple){if(h<300){const K=1-h/300,Z=K*(Math.random()-.5)*5,J=K*(Math.random()-.5)*.05,pt=Math.min(1,15*t);i.skew_x=this.lerp(i.skew_x??((gt=e.transform)==null?void 0:gt.skew_x)??0,Z,pt),i.scale_x=this.lerp(i.scale_x??((mt=e.transform)==null?void 0:mt.scale_x)??1,(((ut=e.transform)==null?void 0:ut.scale_x)??1)*(1+J),pt),i.scale_y=this.lerp(i.scale_y??((wt=e.transform)==null?void 0:wt.scale_y)??1,(((Mt=e.transform)==null?void 0:Mt.scale_y)??1)*(1+J),pt),i.style=i.style||{...e.style},i.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((Et=n.settings)==null?void 0:Et.intensity)??1,scale:((Ut=n.settings)==null?void 0:Ut.scale)??2}}}else if(n.type===q.Squash){const K=((re=n.settings)==null?void 0:re.strength)||.8;h<(e.width||100)&&this.isMouseDown?(i.scale_y=this.lerp(i.scale_y??1,(((he=e.transform)==null?void 0:he.scale_y)??1)*K,.3),i.scale_x=this.lerp(i.scale_x??1,(((nt=e.transform)==null?void 0:nt.scale_x)??1)*(1+(1-K)*.4),.3)):(i.scale_y=this.lerp(i.scale_y??1,((yt=e.transform)==null?void 0:yt.scale_y)??1,.2),i.scale_x=this.lerp(i.scale_x??1,((Tt=e.transform)==null?void 0:Tt.scale_x)??1,.2))}else if(n.type===q.TextCounter){const K=((_t=n.settings)==null?void 0:_t.duration)||2,Z=((St=n.settings)==null?void 0:St.from)||0,J=((Ft=n.settings)==null?void 0:Ft.to)||100;n._runtimeStart===void 0&&(n._runtimeStart=this.currentTime);const pt=this.currentTime-n._runtimeStart,Ot=Math.min(1,pt/K),xt=Math.floor(Z+(J-Z)*Ot);if(((Gt=e.geometry)==null?void 0:Gt.type)==="Text"){const $t=((Bt=n.settings)==null?void 0:Bt.prefix)||"",oe=((Wt=n.settings)==null?void 0:Wt.suffix)||"";i.geometry||(i.geometry={...e.geometry}),i.geometry.text=`${$t}${xt}${oe}`}}else if(n.type===q.Spotlight){const K=((Jt=n.settings)==null?void 0:Jt.radius)||250,Z=((Yt=n.settings)==null?void 0:Yt.strength)||1.5;if(h<K){const J=Math.pow(1-h/K,2);i.style||(i.style={...e.style}),i.style.adjustments||(i.style.adjustments={...(we=e.style)==null?void 0:we.adjustments}),i.style.adjustments.exposure=(((Zt=(Me=e.style)==null?void 0:Me.adjustments)==null?void 0:Zt.exposure)||0)+J*Z*50}else(le=i.style)!=null&&le.adjustments&&(i.style.adjustments.exposure=this.lerp(i.style.adjustments.exposure||0,((Ie=(Ee=e.style)==null?void 0:Ee.adjustments)==null?void 0:Ie.exposure)||0,.1))}else if(n.type===q.Noise||n.type===q.Float){const K=(((ke=n.settings)==null?void 0:ke.frequency)||((de=n.settings)==null?void 0:de.speed)||1)*.002,Z=(((pe=n.settings)==null?void 0:pe.amplitude)||((ot=n.settings)==null?void 0:ot.range)||50)*(((ft=n.settings)==null?void 0:ft.strength)||1),J=Date.now();i.x+=Math.sin(J*K)*Z*t,i.y+=Math.cos(J*K*.8)*Z*t,i.rotation+=Math.sin(J*K*.5)*5*t}else if(n.type===q.Pulse){const K=(((it=n.settings)==null?void 0:it.speed)||1)*.005,Z=(((G=n.settings)==null?void 0:G.scale)||1.2)-1,J=Math.sin(Date.now()*K),pt=((at=n.settings)==null?void 0:at.strength)||1;i.scale_x*=1+J*Z*pt*t,i.scale_y*=1+J*Z*pt*t,i.style&&(i.style.exposure=(i.style.exposure||1)+Math.max(0,J)*.1*pt*t)}else if(n.type===q.Draggable){const K=((V=n.settings)==null?void 0:V.radius)||150,Z=this.draggingBehaviors.has(e.id);if(h<K||Z){const J=((dt=n.settings)==null?void 0:dt.strength)||1,pt=Z?1:Math.max(0,1-h/K);this.applyBehaviorSensor(i,se.PositionX,pt*J,t,n.settings),this.applyBehaviorSensor(i,se.PositionY,pt*J,t,n.settings)}}else if(n.type===q.Scroll){const K=((vt=n.settings)==null?void 0:vt.axis)||"vertical",Z=((Pt=n.settings)==null?void 0:Pt.factor)||.5,J=((Ht=n.settings)==null?void 0:Ht.strength)||1,pt=((kt=n.settings)==null?void 0:kt.scaleFactor)||0;(K==="vertical"||K==="both")&&(i.y+=this.scrollOffset.y*Z*J*t),(K==="horizontal"||K==="both")&&(i.x+=this.scrollOffset.x*Z*J*t),pt!==0&&(i.scale_x*=1+this.scrollOffset.y*pt*t,i.scale_y*=1+this.scrollOffset.y*pt*t)}else if(n.type===q.LookAt){const K=((At=n.settings)==null?void 0:At.factor)||1,Z=(($=n.settings)==null?void 0:$.strength)||1,J=Math.atan2(-f,-l)*(180/Math.PI),pt=i.rotation,Ot=(J-pt+180)%360-180;i.rotation+=Ot*K*Z*t*10}else if(n.type===q.Scan){const K=(((Xt=n.settings)==null?void 0:Xt.speed)||1)*.004,Z=((ne=n.settings)==null?void 0:ne.strength)||1,J=(Math.sin(Date.now()*K)+1)/2;i.style&&(i.style.exposure=(i.style.exposure||1)+J*Z*t*5),i.x+=(J-.5)*20*Z*t}else if(n.type===q.Glint)i.style=i.style||{...e.style},i.style.artEffect={enabled:!0,type:"glint_overlay",intensity:((ie=n.settings)==null?void 0:ie.strength)??.8};else if(n.type===q.Ratchet){const K=((Nt=n.settings)==null?void 0:Nt.steps)||12,Z=(((Rt=n.settings)==null?void 0:Rt.speed)||1)*30,J=Math.floor(i.rotation/(360/K))*(360/K);i.rotation=this.lerp(i.rotation,J+Z*t,.1)}else if(n.type===q.Jitter&&h<300){const K=((Ct=n.settings)==null?void 0:Ct.strength)||1,Z=(((ht=n.settings)==null?void 0:ht.intensity)||5)*K;i.x+=(Math.random()-.5)*Z*t*60,i.y+=(Math.random()-.5)*Z*t*60,i.rotation+=(Math.random()-.5)*Z*t*120}else if(n.type===q.Follower){const K=(j=n.settings)==null?void 0:j.targetId;if(K){const Z=this.objectStates.get(K);if(Z){const J=((bt=n.settings)==null?void 0:bt.stiffness)||.1,pt=Z.x-i.x,Ot=Z.y-i.y;i.x+=pt*J*t*60,i.y+=Ot*J*t*60}}}else if(n.type===q.Wrap)i.x<0?i.x=this.canvasWidth:i.x>this.canvasWidth&&(i.x=0),i.y<0?i.y=this.canvasHeight:i.y>this.canvasHeight&&(i.y=0);else if(n.type===q.Gravity){const K=((Y=n.settings)==null?void 0:Y.strength)||9.8;i.y+=K*t*10}else if(n.type===q.Velocity){const K=((rt=n.settings)==null?void 0:rt.vx)||0,Z=((tt=n.settings)==null?void 0:tt.vy)||0;i.x+=K*t*10,i.y+=Z*t*10}else if(n.type===q.Shear){const K=((qt=n.settings)==null?void 0:qt.strength)||1,Z=((jt=n.settings)==null?void 0:jt.radius)||300;if(h<Z){const J=1-h/Z;i.skew_x=this.lerp(i.skew_x||0,(((Se=e.transform)==null?void 0:Se.skew_x)||0)+J*K*30,.1)}else i.skew_x=this.lerp(i.skew_x||0,((Vt=e.transform)==null?void 0:Vt.skew_x)||0,.05)}else if(n.type===q.Lens){const K=((te=n.settings)==null?void 0:te.radius)||200,Z=((Qt=n.settings)==null?void 0:Qt.strength)||.5;if(h<K){const J=Math.pow(1-h/K,2);i.scale_x=this.lerp(i.scale_x??1,(((Te=e.transform)==null?void 0:Te.scale_x)??1)*(1+J*Z),.2),i.scale_y=this.lerp(i.scale_y??1,(((Ae=e.transform)==null?void 0:Ae.scale_y)??1)*(1+J*Z),.2)}else i.scale_x=this.lerp(i.scale_x??1,((Oe=e.transform)==null?void 0:Oe.scale_x)??1,.1),i.scale_y=this.lerp(i.scale_y??1,((Le=e.transform)==null?void 0:Le.scale_y)??1,.1)}else if(n.type===q.LayoutAnimation){const K=((xe=n.settings)==null?void 0:xe.watchProperties)||["x","y","scale_x","scale_y","opacity","rotation"],Z=((Re=n.settings)==null?void 0:Re.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const J=this._layoutAnimCache.get(e.id);for(const pt of K){const Ot=this.getObjectProperty(i,e,pt);if(Ot===void 0)continue;const xt=J.get(pt);if(!xt)J.set(pt,{from:Ot,to:Ot,startTime:this.currentTime,duration:0});else if(xt.to!==Ot){const oe=this.getObjectProperty(i,e,pt);J.set(pt,{from:oe??xt.from,to:Ot,startTime:this.currentTime,duration:((Ye=n.settings)==null?void 0:Ye.duration)??Z})}const $t=J.get(pt);if($t.duration>0&&$t.from!==$t.to){const oe=this.currentTime-$t.startTime,be=Math.min(1,oe/$t.duration),_e=this.applyEasing(be,((Kt=n.settings)==null?void 0:Kt.easing)||"easeOutCubic"),ce=$t.from+($t.to-$t.from)*_e;this.setObjectProperty(i,e,pt,ce)}}}else if(n.type===q.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const K=this._layoutAnimCache.get(e.id),Z=((ae=n.settings)==null?void 0:ae.defaultDuration)||.3,J=["x","y","scale_x","scale_y","opacity","rotation","style.fill.color","style.stroke.width","geometry.cornerRadius","style.blur.value","style.shadow.blur","style.shadow.offsetX","style.shadow.offsetY"];for(const pt of J){const Ot=this.getObjectProperty(i,e,pt);if(Ot===void 0||typeof Ot!="number")continue;const xt=K.get(pt);if(!xt)K.set(pt,{from:Ot,to:Ot,startTime:this.currentTime,duration:0});else if(xt.to!==Ot){const oe=this.getObjectProperty(i,e,pt);K.set(pt,{from:oe??xt.from,to:Ot,startTime:this.currentTime,duration:Z})}const $t=K.get(pt);if($t.duration>0&&$t.from!==$t.to){const oe=this.currentTime-$t.startTime,be=Math.min(1,oe/$t.duration),_e=this.applyEasing(be,((ue=n.settings)==null?void 0:ue.defaultEasing)||"easeOutCubic"),ce=$t.from+($t.to-$t.from)*_e;this.setObjectProperty(i,e,pt,ce)}}}else if(n.type===q.SpringChain){const K=((Fe=n.settings)==null?void 0:Fe.connections)||[],Z=(($e=n.settings)==null?void 0:$e.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const J=this._springChainState.get(e.id);for(const Ot of K){if(!J.has(Ot.targetId)){const xt=this.objectStates.get(Ot.targetId);J.set(Ot.targetId,{x:(xt==null?void 0:xt.x)??0,y:(xt==null?void 0:xt.y)??0,vx:0,vy:0})}J.has(e.id)||J.set(e.id,{x:i.x,y:i.y,vx:0,vy:0})}const pt=J.get(e.id);if(pt){pt.x=i.x,pt.y=i.y;for(const Ot of K){const xt=J.get(Ot.targetId);if(!xt)continue;const $t=xt.x-pt.x,oe=xt.y-pt.y,be=Math.sqrt($t*$t+oe*oe)||.001,ce=(be-(Ot.restLength||50))*(Ot.stiffness||.8),Ce=$t/be*ce,Qe=oe/be*ce;pt.vx+=Ce*t*10,pt.vy+=Qe*t*10,xt.vx-=Ce*t*10,xt.vy-=Qe*t*10,pt.vx*=1-Z*t*10,pt.vy*=1-Z*t*10,xt.vx*=1-Z*t*10,xt.vy*=1-Z*t*10;const ve=this.objectStates.get(Ot.targetId);ve&&(ve.x+=xt.vx*t,ve.y+=xt.vy*t)}i.x+=pt.vx*t,i.y+=pt.vy*t}}else if(n.type===q.ParticleEmitter){const K=((me=n.settings)==null?void 0:me.rate)||10,Z=((ge=n.settings)==null?void 0:ge.speed)||100,J=((ye=n.settings)==null?void 0:ye.size)||5,pt=((Pe=n.settings)==null?void 0:Pe.lifetime)||2,Ot=((Xe=n.settings)==null?void 0:Xe.gravity)||0,xt=((Ue=n.settings)==null?void 0:Ue.color)||"#ffffff",$t=((qe=n.settings)==null?void 0:qe.maxParticles)||200,oe=(De=n.settings)!=null&&De.rateInputId?this.inputs.get(n.settings.rateInputId)??K:K,be=(Ke=n.settings)!=null&&Ke.gravityInputId?this.inputs.get(n.settings.gravityInputId)??Ot:Ot,_e=(Je=n.settings)!=null&&Je.speedInputId?this.inputs.get(n.settings.speedInputId)??Z:Z;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const ce=this._emitterPools.get(e.id);let Ce=0;n._pendingBurst&&n._pendingBurst>0&&(Ce=n._pendingBurst,n._pendingBurst=0);const Qe=Math.floor(oe*t)+(Ce||0);for(let ve=0;ve<Math.min(Qe,$t-ce.length);ve++){const fe=Math.random()*Math.PI*2,ms=_e*(.5+Math.random()*.5);ce.push({x:i.x,y:i.y,vx:Math.cos(fe)*ms,vy:Math.sin(fe)*ms,life:0,maxLife:pt*(.5+Math.random()*.5),size:J*(.5+Math.random()),color:xt,opacity:1})}for(let ve=ce.length-1;ve>=0;ve--){const fe=ce[ve];fe.vy+=be*t*10,fe.x+=fe.vx*t,fe.y+=fe.vy*t,fe.life+=t,fe.opacity=Math.max(0,1-fe.life/fe.maxLife),fe.life>=fe.maxLife&&ce.splice(ve,1)}}})})}applyBehaviorSensor(t,s,o,e,i,n,a=0,r=0,l=1){var d,p,g,y,b,v,S,C,w,M,I,k,T,O,_,P,E,A,B,D,W,X,H,Q;const f=(i==null?void 0:i.intensity)||(i==null?void 0:i.strength)||1,h=Math.min(1,15*e),u=l>0?a/l:0,c=l>0?r/l:0;switch(s){case se.Scale:{const L=((d=n==null?void 0:n.transform)==null?void 0:d.scale_x)??1,R=((p=n==null?void 0:n.transform)==null?void 0:p.scale_y)??1,et=L*(1+o*f*.4),U=R*(1+o*f*.4);t.scale_x=(t.scale_x??L)*(1-h)+et*h,t.scale_y=(t.scale_y??R)*(1-h)+U*h;break}case se.Opacity:{const L=((g=n==null?void 0:n.transform)==null?void 0:g.opacity)??100,R=Math.max(0,Math.min(100,L-o*f*100));t.opacity=(t.opacity??L)*(1-h)+R*h;break}case se.RotateZ:{const L=((y=n==null?void 0:n.transform)==null?void 0:y.rotation)??0,R=L+o*f*45;t.rotation=(t.rotation??L)*(1-h)+R*h;break}case se.RotateX:{const L=((b=n==null?void 0:n.transform)==null?void 0:b.rotate_x)??0,R=L-c*o*f*60;t.rotate_x=(t.rotate_x??L)*(1-h)+R*h;break}case se.RotateY:{const L=((v=n==null?void 0:n.transform)==null?void 0:v.rotate_y)??0,R=L+u*o*f*60;t.rotate_y=(t.rotate_y??L)*(1-h)+R*h;break}case se.PositionX:{const L=((S=n==null?void 0:n.transform)==null?void 0:S.x)??0,R=L-u*o*f*40;t.x=(t.x??L)*(1-h)+R*h;break}case se.PositionY:{const L=((C=n==null?void 0:n.transform)==null?void 0:C.y)??0,R=L-c*o*f*40;t.y=(t.y??L)*(1-h)+R*h;break}case se.SkewX:{const L=((w=n==null?void 0:n.transform)==null?void 0:w.skew_x)??0,R=L+u*o*f*45;t.skew_x=(t.skew_x??L)*(1-h)+R*h,t.skew_x>85&&(t.skew_x=85),t.skew_x<-85&&(t.skew_x=-85);break}case se.Blur:{t.style||(t.style={...n==null?void 0:n.style}),t.style.blur||(t.style.blur={...(M=n==null?void 0:n.style)==null?void 0:M.blur});const L=((k=(I=n==null?void 0:n.style)==null?void 0:I.blur)==null?void 0:k.amount)||0,R=L+o*((i==null?void 0:i.blur)||20)*f;t.style.blur.amount=(t.style.blur.amount??L)*(1-h)+R*h;break}case se.Exposure:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(T=n==null?void 0:n.style)==null?void 0:T.adjustments});const L=((_=(O=n==null?void 0:n.style)==null?void 0:O.adjustments)==null?void 0:_.exposure)||0,R=L+o*((i==null?void 0:i.exposure)||50)*f;t.style.adjustments.exposure=(t.style.adjustments.exposure??L)*(1-h)+R*h;break}case se.HueShift:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(P=n==null?void 0:n.style)==null?void 0:P.adjustments});const L=((A=(E=n==null?void 0:n.style)==null?void 0:E.adjustments)==null?void 0:A.hue)||0,R=L+o*((i==null?void 0:i.hue)||180)*f;t.style.adjustments.hue=(t.style.adjustments.hue??L)*(1-h)+R*h;break}case se.Negative:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(B=n==null?void 0:n.style)==null?void 0:B.adjustments});const L=((W=(D=n==null?void 0:n.style)==null?void 0:D.adjustments)==null?void 0:W.negative)||0,R=L+o*((i==null?void 0:i.negative)||100)*f;t.style.adjustments.negative=(t.style.adjustments.negative??L)*(1-h)+R*h;break}case se.CornerRadius:{const L=((X=n==null?void 0:n.transform)==null?void 0:X.corner_radius)||0,R=L+o*f*50;t.corner_radius=(t.corner_radius??L)*(1-h)+R*h;break}case se.StrokeWidth:{t.style||(t.style={...n==null?void 0:n.style});const L=((H=n==null?void 0:n.style)==null?void 0:H.borderWidth)||0,R=L+o*f*10;t.style.borderWidth=(t.style.borderWidth??L)*(1-h)+R*h;break}case se.LetterSpacing:{t.geometry||(t.geometry={});const L=((Q=n==null?void 0:n.geometry)==null?void 0:Q.letterSpacing)||0,R=L+o*f*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??L)*(1-h)+R*h;break}}}getObjectProperty(t,s,o){const e=o.replace(/\[(\d+)\]/g,".$1").split(".");let i=t;for(const n of e){if(i==null||typeof i!="object")return;if(n==="style"&&t.style===void 0){i=s.style;continue}i=i[n]}return typeof i=="number"?i:void 0}setObjectProperty(t,s,o,e){const i=o.replace(/\[(\d+)\]/g,".$1").split(".");let n=t;for(let r=0;r<i.length-1;r++){const l=i[r];if(n[l]===void 0||n[l]===null){const f=s,h=i.slice(0,r+1).reduce((d,p)=>d==null?void 0:d[p],f),u=i[r+1],c=!isNaN(Number(u));n[l]=h!==void 0?Array.isArray(h)?[...h]:{...h}:c?[]:{}}n=n[l]}const a=i[i.length-1];n!=null&&(n[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 i=0;i<s.length;i++)s[i]&&typeof s[i]=="object"&&!Array.isArray(s[i])&&t[i]&&typeof t[i]=="object"?e[i]=this.deepMerge(t[i],s[i]):e[i]=s[i];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}renderFittedImage(t,s,o,e,i,n,a="cover"){const r=s.naturalWidth,l=s.naturalHeight,f=r/l,h=i/n;let u=i,c=n,d=o,p=e;a==="cover"?f>h?(u=n*f,d=o-(u-i)/2):(c=i/f,p=e-(c-n)/2):a==="contain"&&(f>h?(c=i/f,p=e+(n-c)/2):(u=n*f,d=o+(i-u)/2)),t.drawImage(s,d,p,u,c)}}const ai=Lt.forwardRef(({artboard:m,src:t,style:s,autoPlay:o=!0,fit:e="Contain",alignment:i="Center",onReady:n,onTrigger:a,onInputUpdate:r,onComponentChange:l,onToggle:f,onInputChange:h,onInputFocus:u,onInputBlur:c,onLog:d,onLogicUpdate:p,onButtonClick:g,onGraphPointClick:y,currentTime:b,revision:v=0,scrollY:S,scrollX:C,mouseX:w,mouseY:M,isMouseDown:I,inputs:k,interactive:T=!0,onNavigation:O},_)=>{const P=Lt.useRef(null),E=Lt.useRef(null);E.current||(E.current=new ys);const A=Lt.useRef(void 0),B=Lt.useRef(0),D=Lt.useRef(null),W=Lt.useRef(v),X=Lt.useRef(null),[,H]=Lt.useState(m||null),Q=Lt.useRef(!0);Lt.useImperativeHandle(_,()=>P.current),Lt.useEffect(()=>(Q.current=!0,()=>{Q.current=!1,A.current&&cancelAnimationFrame(A.current)}),[]),Lt.useEffect(()=>{E.current.setLayout(e,i)},[e,i]),Lt.useEffect(()=>{const x=E.current;a&&x.setTriggerCallback(a),r&&x.setInputUpdateCallback((F,N)=>r({[F]:N})),l&&x.setComponentChangeCallback(F=>l(F)),f&&x.setToggleCallback(f),h&&x.setInputChangeCallback(h),u&&x.setInputFocusCallback(u),c&&x.setInputBlurCallback(c),d&&x.setOnLogCallback(F=>d(F,"info")),p&&x.setLogicUpdateCallback(p),g&&x.setButtonClickCallback(g),y&&x.setGraphPointClickCallback(F=>y(F.objectId,F)),O&&x.setNavigationCallback(O)},[a,r,l,f,h,u,c,d,p,g,y,O]),Lt.useEffect(()=>{(async()=>{let F=m;if(t&&!m)try{t.startsWith("{")?F=JSON.parse(t):F=await(await fetch(t)).json()}catch(N){console.error("[ExodeUI] Failed to load src:",N)}if(F){const N=E.current,st=F.id||F.name||"default";(D.current!==st||W.current!==v||X.current!==F)&&(N.load(F),D.current=st,W.current=v,X.current=F,H(F),B.current=0,N.advance(0)),n&&n(N)}})()},[m,t,v]),Lt.useEffect(()=>{const x=F=>{if(!E.current||!Q.current)return;const N=E.current,st=P.current;if(!st)return;const z=st.getContext("2d");if(!z)return;const gt=F/1e3;B.current===0&&(B.current=gt);let mt=gt-B.current;mt>.1&&(mt=.1),B.current=gt;const ut=st.getBoundingClientRect(),wt=window.devicePixelRatio||1,Mt=Math.round(ut.width*wt),Et=Math.round(ut.height*wt);(st.width!==Mt||st.height!==Et)&&(st.width=Mt,st.height=Et);try{o?N.advance(mt):b!==void 0&&N.seek(b),N.render(z,st.width,st.height)}catch(Ut){console.error("[ExodeUICanvas] Error in animation loop:",Ut),d&&d(`[Error] Animation loop crashed: ${Ut}`,"error")}A.current=requestAnimationFrame(x)};return A.current=requestAnimationFrame(x),()=>{A.current&&cancelAnimationFrame(A.current)}},[o,b]),Lt.useEffect(()=>{const x=E.current;S!==void 0&&x.updateInput("scrollY",S),C!==void 0&&x.updateInput("scrollX",C),w!==void 0&&x.updateInput("mouseX",w),M!==void 0&&x.updateInput("mouseY",M),I!==void 0&&x.updateInput("isMouseDown",I),k&&Object.entries(k).forEach(([F,N])=>x.updateInput(F,N))},[S,C,w,M,I,k]);const L=(x,F)=>{if(!T||!P.current)return;x.stopPropagation(),"nativeEvent"in x&&x.nativeEvent&&typeof x.nativeEvent.stopImmediatePropagation=="function"?x.nativeEvent.stopImmediatePropagation():typeof x.stopImmediatePropagation=="function"&&x.stopImmediatePropagation();const N=P.current,st=N.getBoundingClientRect(),z=x.clientX-st.left,gt=x.clientY-st.top,mt=window.devicePixelRatio||1;(F==="click"||F==="down"||F==="up")&&d&&d(`[Canvas] Pointer ${F} at rect(${Math.round(z)},${Math.round(gt)}) mapped to buffer(${Math.round(z*mt)},${Math.round(gt*mt)})`,"info"),E.current.handlePointerInput(F,z*mt,gt*mt,N.width,N.height)};Lt.useEffect(()=>{if(!T)return;const x=N=>{var st,z,gt;((st=document.activeElement)==null?void 0:st.tagName)==="INPUT"||((z=document.activeElement)==null?void 0:z.tagName)==="TEXTAREA"||(gt=E.current)==null||gt.handleKeyDown(N)},F=N=>{var st,z,gt;((st=document.activeElement)==null?void 0:st.tagName)==="INPUT"||((z=document.activeElement)==null?void 0:z.tagName)==="TEXTAREA"||(gt=E.current)==null||gt.handleKeyUp(N)};return window.addEventListener("keydown",x),window.addEventListener("keyup",F),()=>{window.removeEventListener("keydown",x),window.removeEventListener("keyup",F)}},[T]);const[R,et]=Lt.useState([]);Lt.useEffect(()=>{if(m&&m.objects){const x=m.objects.filter(F=>{var N,st;return F.type==="Joystick"&&((N=F.inputBinding)==null?void 0:N.type)==="keyboard"&&((st=F.inputBinding.keyboardConfig)==null?void 0:st.showVirtualKeyboard)});et(x)}},[m]);const[,U]=Lt.useState(0);Lt.useEffect(()=>{if(R.length===0)return;let x;const F=()=>{U(N=>N+1),x=requestAnimationFrame(F)};return x=requestAnimationFrame(F),()=>cancelAnimationFrame(x)},[R.length]);const lt=()=>R.map(x=>{const F=x.inputBinding.keyboardConfig,N=ut=>{var Mt;const wt={key:ut,code:ut,preventDefault:()=>{}};(Mt=E.current)==null||Mt.handleKeyDown(wt)},st=ut=>{var Mt;const wt={key:ut,code:ut,preventDefault:()=>{}};(Mt=E.current)==null||Mt.handleKeyUp(wt)},z=E.current,gt=ut=>z&&z.activeKeys?z.activeKeys.has(ut.toLowerCase()):!1,mt=ut=>({width:"50px",height:"50px",background:ut?"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:ut?"none":"0 4px 6px rgba(0,0,0,0.1)"});return Dt.jsxs("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",pointerEvents:"auto",zIndex:100},children:[Dt.jsx("div",{style:mt(gt(F.upKey)),onMouseDown:()=>N(F.upKey),onMouseUp:()=>st(F.upKey),onMouseLeave:()=>st(F.upKey),onTouchStart:ut=>{ut.preventDefault(),N(F.upKey)},onTouchEnd:ut=>{ut.preventDefault(),st(F.upKey)},children:F.upKey.toUpperCase()}),Dt.jsxs("div",{style:{display:"flex",gap:"8px"},children:[Dt.jsx("div",{style:mt(gt(F.leftKey)),onMouseDown:()=>N(F.leftKey),onMouseUp:()=>st(F.leftKey),onMouseLeave:()=>st(F.leftKey),onTouchStart:ut=>{ut.preventDefault(),N(F.leftKey)},onTouchEnd:ut=>{ut.preventDefault(),st(F.leftKey)},children:F.leftKey.toUpperCase()}),Dt.jsx("div",{style:mt(gt(F.downKey)),onMouseDown:()=>N(F.downKey),onMouseUp:()=>st(F.downKey),onMouseLeave:()=>st(F.downKey),onTouchStart:ut=>{ut.preventDefault(),N(F.downKey)},onTouchEnd:ut=>{ut.preventDefault(),st(F.downKey)},children:F.downKey.toUpperCase()}),Dt.jsx("div",{style:mt(gt(F.rightKey)),onMouseDown:()=>N(F.rightKey),onMouseUp:()=>st(F.rightKey),onMouseLeave:()=>st(F.rightKey),onTouchStart:ut=>{ut.preventDefault(),N(F.rightKey)},onTouchEnd:ut=>{ut.preventDefault(),st(F.rightKey)},children:F.rightKey.toUpperCase()})]})]},x.id)});return Dt.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[Dt.jsx("canvas",{ref:P,onPointerDown:x=>{var F;L(x,"down"),(F=P.current)==null||F.focus()},onPointerMove:x=>L(x,"move"),onPointerUp:x=>L(x,"up"),onPointerCancel:x=>L(x,"up"),onClick:x=>L(x,"click"),onWheel:x=>{E.current.handleWheel(x.deltaX,x.deltaY)},onKeyDown:x=>E.current.handleKeyDown(x.nativeEvent),onKeyUp:x=>E.current.handleKeyUp(x.nativeEvent),onContextMenu:x=>x.preventDefault(),tabIndex:0,style:{...s,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:T?"auto":"none"}}),lt()]})});function ri(){const[m,t]=Lt.useState(null),s=Lt.useCallback((h,u)=>{m==null||m.setInputBool(h,u)},[m]),o=Lt.useCallback((h,u)=>{m==null||m.setInputNumber(h,u)},[m]),e=Lt.useCallback(h=>{m==null||m.fireTrigger(h)},[m]),i=Lt.useCallback((h,u)=>{m==null||m.setInputText(h,u)},[m]),n=Lt.useCallback((h,u)=>{m==null||m.setInputNumberArray(h,u)},[m]),a=Lt.useCallback((h,u)=>{m==null||m.setInputStringArray(h,u)},[m]),r=Lt.useCallback((h,u)=>{m==null||m.updateObjectOptions(h,u)},[m]),l=Lt.useCallback((h,u,c)=>{m==null||m.updateConstraint(h,u,c)},[m]),f=Lt.useCallback((h,u)=>{m==null||m.updateGraphData(h,u)},[m]);return{setEngine:t,engine:m,setInputBool:s,setInputNumber:o,fireTrigger:e,setInputText:i,setInputNumberArray:n,setInputStringArray:a,updateConstraint:l,updateGraphData:f,updateObjectOptions:r}}const li=({artboard:m,config:t})=>{const s={...m.seo,...t},o=s.enableSmartExtraction!==!1;Lt.useEffect(()=>{const a=s.title||m.name;a&&(document.title=a);let r=s.description;if(!r&&o){const h=m.objects.filter(u=>{var c;return((c=u.geometry)==null?void 0:c.type)==="Text"}).sort((u,c)=>{var d,p;return(((d=c.geometry.text)==null?void 0:d.length)||0)-(((p=u.geometry.text)==null?void 0:p.length)||0)});h.length>0&&(r=h[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||m.backgroundImage;l&&e("property","og:image",l),a&&e("property","og:title",a),e("property","og:type","website")},[s,m,o]);const e=(a,r,l)=>{let f=document.querySelector(`meta[${a}="${r}"]`);f||(f=document.createElement("meta"),f.setAttribute(a,r),document.head.appendChild(f)),f.setAttribute("content",l)},i=()=>{const a=[];return a.push(Dt.jsx("h1",{children:s.title||m.name},"artboard-title")),m.objects.forEach((l,f)=>{var h,u;if(!(l.visible===!1||l.isVisible===!1))if(((h=l.geometry)==null?void 0:h.type)==="Text"){const c=l.geometry.text;c&&(l.geometry.fontSize>24?a.push(Dt.jsx("h2",{children:c},l.id||f)):a.push(Dt.jsx("p",{children:c},l.id||f)))}else if(((u=l.geometry)==null?void 0:u.type)==="Image"){const c=l.geometry.src,d=l.altText||l.name||"Illustration";a.push(Dt.jsx("img",{src:c,alt:d},l.id||f))}else l.type==="Button"&&a.push(Dt.jsx("button",{children:l.name||"Button"},l.id||f))}),a},n=s.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:s.title||m.name,description:s.description,image:s.ogImage||m.backgroundImage,abstract:"Animated interface created with ExodeUI"};return Dt.jsxs("div",{id:`exode-seo-${m.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:[i(),Dt.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})]})},ci={version:"6.3.45"}.version;zt.BehaviorSensor=se,zt.BehaviorType=q,zt.ConditionOp=je,zt.ExodeSEO=li,zt.ExodeUICanvas=ai,zt.ExodeUIEngine=ys,zt.LogicOp=It,zt.RapierPhysics=is,zt.VERSION=ci,zt.useExodeUI=ri,Object.defineProperty(zt,Symbol.toStringTag,{value:"Module"})}));
12
+ </feComponentTransfer>`,kt="exposure"),ct!==0){const vt=(ct+100)/100,Wt=.5*(1-vt);Et+=`
13
+ <feComponentTransfer in="${kt}" result="contrast">
14
+ <feFuncR type="linear" slope="${vt}" intercept="${Wt}"/>
15
+ <feFuncG type="linear" slope="${vt}" intercept="${Wt}"/>
16
+ <feFuncB type="linear" slope="${vt}" intercept="${Wt}"/>
17
+ </feComponentTransfer>`,kt="contrast"}if(it!==1&&(Et+=`<feColorMatrix in="${kt}" type="saturate" values="${it}" result="saturate"/>`,kt="saturate"),Ht.hue&&(Et+=`<feColorMatrix in="${kt}" type="hueRotate" values="${Ht.hue}" result="hue"/>`,kt="hue"),Ht.negative){const vt=1-Ht.negative/50;Et+=`
18
+ <feColorMatrix in="${kt}" type="matrix" result="invert"
19
+ values="${vt} 0 0 0 ${1-vt}
20
+ 0 ${vt} 0 0 ${1-vt}
21
+ 0 0 ${vt} 0 ${1-vt}
22
+ 0 0 0 1 0"/>`,kt="invert"}if(R!==0||Z!==0||q!==0||mt!==0){const vt=1+q+mt,Wt=vt*(1+R-Z/2),Y=vt*(1+Z),Xt=vt*(1-R-Z/2),ae=Ht.shadows*.1/255,Jt=[Wt,0,0,0,ae,0,Y,0,0,ae,0,0,Xt,0,ae,0,0,0,1,0].join(" ");Et+=`<feColorMatrix in="${kt}" type="matrix" values="${Jt}" result="advanced"/>`,kt="advanced"}if(Ht.blur&&(Et+=`<feGaussianBlur in="${kt}" stdDeviation="${Ht.blur}" result="blur"/>`,kt="blur"),Et){const vt=`<svg xmlns="http://www.w3.org/2000/svg"><filter id="f" color-interpolation-filters="sRGB">${Et}</filter></svg>`,Wt=btoa(vt);j.push(`url('data:image/svg+xml;base64,${Wt}#f')`)}}j.length>0?t.filter=j.join(" "):t.filter="none",t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high";const se=t.globalAlpha,we=this.normalizeOpacity(n.opacity!==void 0?n.opacity:100);t.globalAlpha=se*we;const Me=n.compositeOperation||n.blendMode;if(Me&&Me!=="Normal"){const ot=Me.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(ot)&&(t.globalCompositeOperation=ot)}const fe=t,Ie=n.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 _e=!1;const Ee=Ie.filter(ot=>ot.isVisible!==!1&&o.has(ot.maskId));if(Ee.length>0){const ot=Ee[0],ct=o.get(ot.maskId),it=this.objectStates.get(ct.id);it&&it.visible!==!1&&(_e=!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(!i){t.translate(Math.round(pt),Math.round(yt)),t.rotate(dt*Math.PI/180);const ot=n.skew_x||0,ct=n.skew_y||0;if(ot!==0||ct!==0){const kt=Math.tan(ot*Math.PI/180),$t=Math.tan(ct*Math.PI/180);t.transform(1+kt*$t,$t,kt,1,0,0)}const it=n.rotate_x!==void 0?n.rotate_x:((H=n.transform)==null?void 0:H.rotate_x)??0,R=n.rotate_y!==void 0?n.rotate_y:((et=n.transform)==null?void 0:et.rotate_y)??0,q=1+(n.translate_z!==void 0?n.translate_z:((O=n.transform)==null?void 0:O.translate_z)??0)/1e3,mt=(n.flip_x===!0?-1:1)*Math.cos(R*Math.PI/180)*q,Et=(n.flip_y===!0?-1:1)*Math.cos(it*Math.PI/180)*q;t.scale(wt*mt,Pt*Et)}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 le=r.shadow;if(le&&le.isEnabled!==!1&&!e){let ot=le.color||"#000000";(st=(x=this.artboard)==null?void 0:x.tokens)!=null&&st.colors&&this.artboard.tokens.colors[ot]&&(ot=this.artboard.tokens.colors[ot]);const ct=this.normalizeOpacity(le.opacity??100)*.75,it=le.spread||0,Z=(le.blur||0)+it*1.5;let q=ot;if(ot.startsWith("#")){const kt=ot.replace("#",""),$t=parseInt(kt.substring(0,2),16),vt=parseInt(kt.substring(2,4),16),Wt=parseInt(kt.substring(4,6),16);q=`rgba(${$t}, ${vt}, ${Wt}, ${ct})`}else if(ot.startsWith("rgba")){const kt=ot.match(/[\d.]+/g);if(kt&&kt.length>=4){const $t=kt[0],vt=kt[1],Wt=kt[2],Y=kt[3];q=`rgba(${$t}, ${vt}, ${Wt}, ${parseFloat(Y)*ct})`}}const mt=t.getTransform(),Et=Math.sqrt(mt.a*mt.a+mt.b*mt.b)||1;t.shadowColor=q,t.shadowBlur=Z*Et,t.shadowOffsetX=(le.offsetX||0)*Et,t.shadowOffsetY=(le.offsetY||0)*Et}const ne=s.liquidFill||((Q=s.style)==null?void 0:Q.liquidFill);if(ne&&ne.enabled){t.save();const ot=ne.fillLevel??.5;t.beginPath();const ct=h/2-h*ot;t.rect(-l/2,ct,l,h*ot),t.clip(),t.fillStyle=ne.color||"#3b82f6",t.globalAlpha=t.globalAlpha*(ne.opacity??1)}if(e||this.applyOuterGlowUnderlay(t,s,c,l,h,p,r,o),(a==null?void 0:a.type)==="Text")this._renderText(t,s,c,r,n,l,h,!1,!1);else if((a==null?void 0:a.type)==="Image"){const ot=a.originalSrc||a.src;if(ot){let ct=this.imageCache.get(ot);ct||(ct=new Image,ct.onload=()=>{this.log(`[ExodeUI] Image loaded successfully, size: ${ct.naturalWidth}x${ct.naturalHeight}`)},ct.onerror=Z=>{console.error("[ExodeUI] Image load failed:",Z,`Src preview: ${ot.substring(0,100)}...`)},ct.src=ot,this.imageCache.set(ot,ct));const it=r.stroke&&r.stroke.width>0&&r.stroke.isEnabled!==!1,R=(((lt=r.stroke)==null?void 0:lt.alignment)||"center").toLowerCase();if(it&&R==="outside"&&this.applyStrokeAlignment(t,r,c,l,h,p),r.fill&&r.fill.type!=="None"){t.save();const Z=t.globalAlpha,q=this.createCanvasFill(t,r.fill,l,h);t.fillStyle=q||r.fill.color||"transparent",t.globalAlpha=Z*this.normalizeOpacity(r.fill.opacity??100),p!==0?(this.drawRoundRect(t,-l/2,-h/2,l,h,p),t.fill()):t.fillRect(-l/2,-h/2,l,h),t.globalAlpha=Z,t.restore()}ct.complete&&ct.naturalWidth>0?(p!==0?(t.save(),this.drawRoundRect(t,-l/2,-h/2,l,h,p),t.clip(),t.drawImage(ct,-l/2,-h/2,l,h),t.restore()):t.drawImage(ct,-l/2,-h/2,l,h),it&&(R==="inside"||R==="center")&&this.applyStrokeAlignment(t,r,c,l,h,p)):it&&(R==="inside"||R==="center")&&this.applyStrokeAlignment(t,r,c,l,h,p)}}else if(a.type==="SVG"){const ot=a.svgContent;if(ot){const ct=r.palette||[],it=r.fill,R=r.stroke,Z=it?this.normalizeOpacity(it.opacity??100):1,q=R&&R.isEnabled!==!1?this.normalizeOpacity(R.opacity??100):1,mt=(it==null?void 0:it.type)==="Solid"&&(!R||R.isEnabled===!1||R.type==="Solid"&&R.color===it.color&&q===Z),Et=it&&it.type!=="None"?mt?"monochrome":it.type==="Solid"?(it.color||"")+"|opacity:"+Z:JSON.stringify(it.stops||[])+"|opacity:"+Z:"",kt=R&&R.isEnabled!==!1&&(R.width||0)>0?mt?["monochrome",R.width||0,R.trimStart??0,R.trimEnd??1,R.trimOffset??0,R.dashOffset??0].join("|"):[R.width||0,R.fill?R.fill.type==="Solid"?R.fill.color||"":JSON.stringify(R.fill.stops||[]):R.color||"",R.opacity??1,R.lineCap||"",R.lineJoin||"",(R.dashArray||[]).join(","),R.trimStart??0,R.trimEnd??1,R.trimOffset??0,R.dashOffset??0].join("|"):"nostroke",$t=[s.id,ct.join("_"),Et,kt,n.opacity??100,n.visible!==!1?"v":"h"].join("_");let vt=this.imageCache.get($t);if(!vt){vt=new Image,vt.crossOrigin="anonymous";let Y=ot;Y.match(/xmlns=["']http:\/\/www\.w3\.org\/2000\/svg["']/i)||(Y=Y.replace(/<svg([^>]*)>/i,(B,at)=>`<svg xmlns="http://www.w3.org/2000/svg"${at}>`));let Xt=a.width||l||100,ae=a.height||h||100;const Jt=Y.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(Jt&&(Xt=parseFloat(Jt[1]),ae=parseFloat(Jt[2])),Y=Y.replace(/<svg([^>]*)>/i,(B,at)=>{let K=at.replace(/\b(?:width|height)=["'][^"']*["']/gi," ");return K.match(/\bviewBox=/i)||(K+=` viewBox="0 0 ${Xt} ${ae}"`),K.match(/\bpreserveAspectRatio=/i)||(K+=' preserveAspectRatio="none"'),K+=' width="100%" height="100%"',`<svg${K}>`}),a.colors&&a.colors.length>0&&ct.length>0&&a.colors.forEach((B,at)=>{if(ct[at]){const K=B.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),At=new RegExp(K,"gi");Y=Y.replace(At,ct[at])}}),it&&it.type&&it.type!=="None"){if(it.type==="Solid"&&it.color){const B=mt?"#FFFFFF":it.color,at=mt?1:this.normalizeOpacity(it.opacity??100);Y=Y.replace(/\bfill\s*=\s*["'][^"']*["']/gi,K=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(K)?K:`fill="${B}"`),Y=Y.replace(/fill\s*:\s*[^;"')]+/gi,K=>/fill\s*:\s*(none|transparent)/i.test(K)?K:`fill:${B}`),at<1&&(Y=Y.replace(/\bfill-opacity\s*=\s*["'][^"']*["']/gi,`fill-opacity="${at}"`),Y=Y.replace(/fill-opacity\s*:\s*[^;"')]+/gi,`fill-opacity:${at}`),Y.match(/\bfill-opacity\s*=/i)||(Y=Y.replace(/(<svg[^>]*>)/i,`$1<g fill-opacity="${at}">`),Y=Y.replace(/<\/svg>/i,"</g></svg>")))}else if(it.type==="LinearGradient"||it.type==="RadialGradient"||it.type==="Linear"||it.type==="Radial"){const B="exode-fill",at=this.normalizeOpacity(it.opacity??100),K=(it.stops||[]).map(Mt=>{const ee=Mt.offset!==void 0?Mt.offset:Mt.pos??0,ie=this.normalizeOpacity(Mt.opacity??100)*at;return`<stop offset="${ee*100}%" stop-color="${Mt.color||"#000"}" stop-opacity="${ie}"/>`}).join("");let At="";if(it.type==="LinearGradient"||it.type==="Linear"){const Mt=(Zt,Qt)=>Array.isArray(Zt)?Zt[Qt]??(Qt===0?0:1):Zt&&typeof Zt=="object"?Zt[Qt===0?"x":"y"]??(Qt===0?0:1):Qt===0?0:1,ee=Mt(it.start,0)*100,ie=Mt(it.start,1)*100,Se=Mt(it.end,0)*100,Vt=Mt(it.end,1)*100;At=`<linearGradient id="${B}" x1="${ee}%" y1="${ie}%" x2="${Se}%" y2="${Vt}%" gradientUnits="objectBoundingBox">${K}</linearGradient>`}else{const Mt=(Vt,Zt)=>Array.isArray(Vt)?Vt[Zt]??.5:Vt&&typeof Vt=="object"?Vt[Zt===0?"x":"y"]??.5:.5,ee=Mt(it.center,0)*100,ie=Mt(it.center,1)*100,Se=(it.radius??.5)*100;At=`<radialGradient id="${B}" cx="${ee}%" cy="${ie}%" r="${Se}%" gradientUnits="objectBoundingBox">${K}</radialGradient>`}/<defs>/i.test(Y)?Y=Y.replace(/<defs>/i,`<defs>${At}`):Y=Y.replace(/<svg([^>]*)>/i,`<svg$1><defs>${At}</defs>`),Y=Y.replace(/\bfill\s*=\s*["'][^"']*["']/gi,Mt=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(Mt)?Mt:`fill="url(#${B})"`),Y=Y.replace(/fill\s*:\s*[^;"')]+/gi,Mt=>/fill\s*:\s*(none|transparent)/i.test(Mt)?Mt:`fill:url(#${B})`)}}const ut=(B,at,K=1)=>{const At=(B.stops||[]).map(Vt=>{const Zt=Vt.offset!==void 0?Vt.offset:Vt.pos??0,Qt=this.normalizeOpacity(Vt.opacity??100)*K;return`<stop offset="${Zt*100}%" stop-color="${Vt.color||"#000"}" stop-opacity="${Qt}"/>`}).join(""),Mt=(Vt,Zt,Qt=.5)=>Array.isArray(Vt)?Vt[Zt]??Qt:Vt&&typeof Vt=="object"?Vt[Zt===0?"x":"y"]??Qt:Qt;if(B.type==="LinearGradient"||B.type==="Linear"){const Vt=Mt(B.start,0,0)*100,Zt=Mt(B.start,1,0)*100,Qt=Mt(B.end,0,1)*100,ke=Mt(B.end,1,1)*100;return`<linearGradient id="${at}" x1="${Vt}%" y1="${Zt}%" x2="${Qt}%" y2="${ke}%" gradientUnits="objectBoundingBox">${At}</linearGradient>`}const ee=Mt(B.center,0,.5)*100,ie=Mt(B.center,1,.5)*100,Se=(B.radius??.5)*100;return`<radialGradient id="${at}" cx="${ee}%" cy="${ie}%" r="${Se}%" gradientUnits="objectBoundingBox">${At}</radialGradient>`},ft=(B,at)=>/<defs>/i.test(B)?B.replace(/<defs>/i,`<defs>${at}`):B.replace(/(<svg[^>]*>)/i,`$1<defs>${at}</defs>`);if(R&&R.isEnabled!==!1&&(R.width||0)>0){const B=mt?1:this.normalizeOpacity(R.opacity??100),at=mt?"#FFFFFF":R.color||(it==null?void 0:it.color)||"#000000";let K="";const At=R.fill;if(At&&At.type){if(At.type==="Solid")K=At.color||R.color||"#000000";else if(At.type==="LinearGradient"||At.type==="RadialGradient"||At.type==="Linear"||At.type==="Radial"){const Kt="exode-stroke";Y=ft(Y,ut(At,Kt,B)),K=`url(#${Kt})`}}K||(K=at),Y.match(/\bstroke\s*=\s*["']/i)?Y=Y.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,Kt=>/stroke\s*=\s*["']\s*(none|transparent)\s*["']/i.test(Kt)?Kt:`stroke="${K}"`):Y=Y.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke="${K}"`),Y=Y.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),`stroke:${K}`);let Mt=a.width||l||100,ee=a.height||h||100;const ie=ot.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(ie){const Kt=parseFloat(ie[1]),re=parseFloat(ie[2]);!isNaN(Kt)&&!isNaN(re)&&(Mt=Kt,ee=re)}const Se=Math.max(.001,l/Mt),Vt=Math.max(.001,h/ee),Zt=(Se+Vt)/2,Qt=(R.width||1)/Zt;Y.match(/\bstroke-width\s*=\s*["']/i)?Y=Y.replace(/\bstroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${Qt}"`):Y=Y.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-width="${Qt}"`),Y=Y.replace(/stroke-width\s*:\s*[^;"')]+/gi,`stroke-width:${Qt}`),Y.match(/\bstroke-opacity\s*=\s*["']/i)?Y=Y.replace(/\bstroke-opacity\s*=\s*["'][^"']*["']/gi,`stroke-opacity="${B}"`):Y=Y.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-opacity="${B}"`),Y=Y.replace(/stroke-opacity\s*:\s*[^;"')]+/gi,`stroke-opacity:${B}`);const ke=R.lineCap||"round";Y.match(/\bstroke-linecap\s*=\s*["']/i)?Y=Y.replace(/\bstroke-linecap\s*=\s*["'][^"']*["']/gi,`stroke-linecap="${ke}"`):Y=Y.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linecap="${ke}"`),Y=Y.replace(/stroke-linecap\s*:\s*[^;"')]+/gi,`stroke-linecap:${ke}`);const Ae=R.lineJoin||"round";Y.match(/\bstroke-linejoin\s*=\s*["']/i)?Y=Y.replace(/\bstroke-linejoin\s*=\s*["'][^"']*["']/gi,`stroke-linejoin="${Ae}"`):Y=Y.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linejoin="${Ae}"`),Y=Y.replace(/stroke-linejoin\s*:\s*[^;"')]+/gi,`stroke-linejoin:${Ae}`);const Oe=R.trimStart??0,Le=R.trimEnd??1,xe=R.trimOffset??0,Re=R.dashOffset??0,Ye=Oe!==0||Le!==1||xe!==0||Re!==0;if(Ye){const Kt=Math.max(0,Math.min(1,Oe)),re=Math.max(0,Math.min(1,Le));this.frameCount%600===0&&this.debugLog(`SVG Trim - Object: ${s.name||s.id}, Start: ${Kt}, End: ${re}`);const pe=(Mt+ee)*2,Fe=(xe%1+1)%1,$e=(Re%1+1)%1;let ye="",ue=0;if(Kt>=re)ye=`0 ${pe}`,ue=0;else{const ge=pe*(re-Kt),Te=pe-ge;ue=-(pe*(Kt+Fe+$e)),ye=`${ge} ${Te}`}Y.match(/\bstroke-dasharray\s*=/i)?Y=Y.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${ye}"`):Y=Y.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dasharray="${ye}"`),Y=Y.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${ye}`),Y.match(/\bstroke-dashoffset\s*=/i)?Y=Y.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${ue}"`):Y=Y.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dashoffset="${ue}"`),Y=Y.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${ue}`)}else if(R.dashArray&&R.dashArray.length>0){const Kt=R.dashArray.join(" ");if(Y=Y.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${Kt}"`),Y=Y.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${Kt}`),R.dashOffset){const re=(Mt+ee)*2,pe=-(R.dashOffset*re);Y=Y.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${pe}"`),Y=Y.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${pe}`)}}if(!/\bstroke\s*=\s*["']/i.test(ot)&&!new RegExp("(?<![a-z-])stroke\\s*:","i").test(ot)){let Kt="",re="";if(Ye){const ye=a.width||l||100,ue=a.height||h||100,ge=(ye+ue)*2,Te=Math.max(0,Math.min(1,Oe)),Xe=Math.max(0,Math.min(1,Le)),Ue=(xe%1+1)%1,qe=(Re%1+1)%1;if(Te>=Xe)Kt=` stroke-dasharray="0 ${ge}"`,re=' stroke-dashoffset="0"';else{const De=ge*(Xe-Te),Ke=ge-De,Je=-(ge*(Te+Ue+qe));Kt=` stroke-dasharray="${De} ${Ke}"`,re=` stroke-dashoffset="${Je}"`}}else(F=R.dashArray)!=null&&F.length&&(Kt=` stroke-dasharray="${R.dashArray.join(" ")}"`,R.dashOffset&&(re=` stroke-dashoffset="${R.dashOffset}"`));const pe=` stroke-linecap="${R.lineCap||"round"}"`,Fe=` stroke-linejoin="${R.lineJoin||"round"}"`,$e=`stroke="${K}" stroke-width="${Qt}" stroke-opacity="${B}"${pe}${Fe}${Kt}${re}`;Y=Y.replace(/(<svg[^>]*>)(\s*(?:<defs>[\s\S]*?<\/defs>)?)/i,(ye,ue,ge)=>`${ue}${ge}<g ${$e}>`),Y=Y.replace(/<\/svg>/i,"</g></svg>")}}else R&&R.isEnabled===!1&&(Y=Y.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,'stroke="none"'),Y=Y.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),"stroke:none"));const St=new Blob([Y],{type:"image/svg+xml"}),Tt=URL.createObjectURL(St);vt.onload=()=>{if(URL.revokeObjectURL(Tt),this.frameCount%900===0){const B=this.imageCache.get($t);B&&this.debugLog(`SVG Payload Ready: ${s.name||s.id} (${B.naturalWidth}x${B.naturalHeight})`)}},vt.onerror=()=>{URL.revokeObjectURL(Tt),this.debugLog(`SVG Error: Failed to load payload for ${s.name||s.id}`)},vt.src=Tt,this.imageCache.set($t,vt)}let Wt=null;if(vt.complete&&vt.naturalWidth>0?(Wt=vt,this.lastValidSvgImgMap.set(s.id,vt)):Wt=this.lastValidSvgImgMap.get(s.id)||null,Wt&&Wt.complete&&Wt.naturalWidth>0){const Y=Math.max(1,l),Xt=Math.max(1,h);if(mt&&(it==null?void 0:it.type)==="Solid"){this.maskBuffer||(this.maskBuffer=document.createElement("canvas"),this.maskCtx=this.maskBuffer.getContext("2d")),this.maskBuffer.width=Y,this.maskBuffer.height=Xt,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,Y,Xt),this.maskCtx.drawImage(Wt,0,0,Y,Xt),this.maskCtx.globalCompositeOperation="source-in";const ae=it.color||"#000000",Jt=this.normalizeOpacity(it.opacity??100);this.maskCtx.fillStyle=ae,this.maskCtx.globalAlpha=Jt,this.maskCtx.fillRect(0,0,Y,Xt),t.drawImage(this.maskBuffer,-Y/2,-Xt/2,Y,Xt)}else p!==0?(t.save(),this.drawRoundRect(t,-Y/2,-Xt/2,Y,Xt,p),t.clip(),t.drawImage(Wt,-Y/2,-Xt/2,Y,Xt),t.restore()):t.drawImage(Wt,-Y/2,-Xt/2,Y,Xt)}}}else if(c.type==="LineGraph")this.renderLineGraph(t,c,l,h);else if(s.type==="Shape"){if(this.applyPath(t,c,l,h,p),t.save(),r.blur&&r.blur.amount>0&&(t.filter=`blur(${r.blur.amount}px)`),Ft&&Bt==="BackgroundBlur")if(e)t.fillStyle="#000000",t.globalAlpha=1,this.applyPath(t,c,l,h,p),t.fill();else{if(t.shadowColor&&t.shadowColor!=="rgba(0, 0, 0, 0)"&&t.shadowColor!=="transparent"){const it=t.getTransform(),R=t.shadowOffsetX,Z=t.shadowOffsetY;t.shadowOffsetX=R+1e4*it.a,t.shadowOffsetY=Z+1e4*it.b,t.save(),t.translate(-1e4,0),this.applyPath(t,c,l,h,p),t.fillStyle="white",t.fill(),t.restore(),t.shadowOffsetX=R,t.shadowOffsetY=Z,t.shadowColor="transparent"}this.applyBackgroundBlurGlass(t,c,l,h,p,bt,r)}else if(r.fill){const ct=t.globalAlpha;if(((W=r.fill)==null?void 0:W.type)==="Image"&&(r.fill.originalSrc||r.fill.src)){const it=r.fill.originalSrc||r.fill.src;let R=this.imageCache.get(it);R||(R=new Image,R.src=it,this.imageCache.set(it,R)),R.complete&&R.naturalWidth>0&&(t.save(),this.applyPath(t,c,l,h,p),t.clip(),this.renderFittedImage(t,R,-l/2,-h/2,l,h,r.fill.fillMode),t.restore())}else{const it=this.createCanvasFill(t,r.fill,l,h);t.fillStyle=it||(typeof r.fill=="string"?r.fill:r.fill.color||"transparent"),t.globalAlpha=ct*this.normalizeOpacity(r.fill.opacity??100),this.applyPath(t,c,l,h,p),t.fill()}t.globalAlpha=ct}t.restore(),r.stroke&&r.stroke.width>0&&(this.applyPath(t,c,l,h,p),this.applyStrokeAlignment(t,r,c,l,h,p))}else if(s.type==="Frame"||s.type==="Component"&&!s.variant||s.type==="Group"&&!s.isStructuralGroup){const ot=n.width??a.width??s.width??l,ct=n.height??a.height??s.height??h,it=p;if(t.save(),t.beginPath(),this.drawRoundRect(t,-ot/2,-ct/2,ot,ct,it),Ft&&Bt==="BackgroundBlur")if(e)t.fillStyle="#000000",t.globalAlpha=1,t.beginPath(),this.drawRoundRect(t,-ot/2,-ct/2,ot,ct,it),t.fill();else{if(t.shadowColor&&t.shadowColor!=="rgba(0, 0, 0, 0)"&&t.shadowColor!=="transparent"){const q=t.getTransform(),mt=t.shadowOffsetX,Et=t.shadowOffsetY;t.shadowOffsetX=mt+1e4*q.a,t.shadowOffsetY=Et+1e4*q.b,t.save(),t.translate(-1e4,0),t.beginPath(),this.drawRoundRect(t,-ot/2,-ct/2,ot,ct,it),t.fillStyle="white",t.fill(),t.restore(),t.shadowOffsetX=mt,t.shadowOffsetY=Et,t.shadowColor="transparent"}this.applyBackgroundBlurGlass(t,c,ot,ct,it,bt,r)}else if(r.fill&&r.fill.type!=="None"){const Z=t.globalAlpha;if(((z=r.fill)==null?void 0:z.type)==="Image"&&(r.fill.originalSrc||r.fill.src)){const q=r.fill.originalSrc||r.fill.src;let mt=this.imageCache.get(q);mt||(mt=new Image,mt.src=q,this.imageCache.set(q,mt)),mt.complete&&mt.naturalWidth>0&&(t.save(),t.beginPath(),this.drawRoundRect(t,-ot/2,-ct/2,ot,ct,it),t.clip(),this.renderFittedImage(t,mt,-ot/2,-ct/2,ot,ct,r.fill.fillMode),t.restore())}else{const q=this.createCanvasFill(t,r.fill,ot,ct);t.fillStyle=q||r.fill.color||"transparent",t.globalAlpha=Z*this.normalizeOpacity(r.fill.opacity??100),t.beginPath(),this.drawRoundRect(t,-ot/2,-ct/2,ot,ct,it),t.fill(),t.globalAlpha=Z}}if(t.restore(),!e&&(Ft&&Bt==="BackgroundBlur"||r.fill&&r.fill.type!=="None")&&(t.shadowColor="transparent"),r.stroke&&r.stroke.width>0&&r.stroke.isEnabled!==!1){const Z={type:"Rectangle"};t.beginPath(),this.drawRoundRect(t,-ot/2,-ct/2,ot,ct,it),this.applyStrokeAlignment(t,r,Z,ot,ct,it)}}else s.type==="Group"&&s.isStructuralGroup||(s.type==="Component"&&s.variant==="inputbox"?this.renderInputBox(t,s):s.type==="Component"&&s.variant==="button"?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"||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:",(nt=s.geometry)==null?void 0:nt.type));if(e||(this.applyInnerGlowOverlay(t,s,c,l,h,p,r),this.applyArtEffectOverlay(t,s,c,l,h,p)),ne&&ne.enabled&&t.restore(),s.children&&s.children.length>0){const ct=s.type==="Frame",it=s.clipsContent!==void 0?s.clipsContent:s.clipContent!==void 0?s.clipContent:ct;if(t.save(),it){t.beginPath();const Z=n.width??(a==null?void 0:a.width)??s.width??0,q=n.height??(a==null?void 0:a.height)??s.height??0,mt=n.cornerRadius??(a==null?void 0:a.corner_radius)??s.cornerRadius??0;this.drawRoundRect(t,-Z/2,-q/2,Z,q,mt),t.clip()}let R=0;for(s.children.forEach(Z=>{const q=o.get(Z);if(!q)return;const mt=this.objectStates.get(Z),Et=(mt==null?void 0:mt.geometry)||q.geometry;if(Et&&Et.isMask&&(mt==null?void 0:mt.visible)!==!1){const kt=Et.width||0,$t=Et.height||0;this.applyObjectTransform(t,Z);const vt=(mt==null?void 0:mt.corner_radius)??(Et==null?void 0:Et.corner_radius)??0;this.applyPath(t,Et,kt,$t,vt),t.clip(),R++}else this.renderObject(t,q,o,e)});R>0;)t.restore(),R--;t.restore()}if(_e){this.maskCtx.restore(),(n.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(R=>R.isVisible!==!1&&o.has(R.maskId)).forEach(R=>{var vt,Wt,Y,Xt,ae,Jt;const Z=o.get(R.maskId),q=this.objectStates.get(Z.id),mt=R.feather||0,Et=R.inverted===!0,kt=R.opacity!==void 0?typeof R.opacity=="number"?R.opacity:R.opacity/100:1;if((R.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,Z.id,o),mt>0&&(this.lumaCtx.filter=`blur(${mt}px)`),this.lumaCtx.globalAlpha=kt;const ut=(q==null?void 0:q.width)||Z.geometry.width||0,ft=(q==null?void 0:q.height)||Z.geometry.height||0,St=(q==null?void 0:q.corner_radius)??Z.corner_radius??0;if(((vt=Z.geometry)==null?void 0:vt.type)==="Text"){const K=q!=null&&q.geometry?this.deepMerge(Z.geometry,q.geometry):Z.geometry,At=q!=null&&q.style?this.deepMerge(Z.style,q.style):Z.style;this._renderText(this.lumaCtx,Z,{...K,width:ut,height:ft,corner_radius:St},At,q,ut,ft,!0,!1)}else if(((Wt=Z.geometry)==null?void 0:Wt.type)==="Image"){const K=Z.geometry.src;if(K){let At=this.imageCache.get(K);At||(At=new Image,At.src=K,this.imageCache.set(K,At)),At.complete&&At.naturalWidth>0?this.lumaCtx.drawImage(At,-ut/2,-ft/2,ut,ft):(this.applyPath(this.lumaCtx,Z.geometry,ut,ft,St),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else if(((Y=Z.geometry)==null?void 0:Y.type)==="SVG"){const K=Z.geometry.svgContent;if(K){const At=`__lumamask_${Z.id}`;let Mt=this.imageCache.get(At);if(!Mt){Mt=new Image;const ee=new Blob([K],{type:"image/svg+xml"});Mt.src=URL.createObjectURL(ee),Mt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(At,Mt)}Mt.complete&&Mt.naturalWidth>0?this.lumaCtx.drawImage(Mt,-ut/2,-ft/2,ut,ft):(this.applyPath(this.lumaCtx,Z.geometry,ut,ft,St),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else this.applyPath(this.lumaCtx,Z.geometry,ut,ft,St),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill();this.lumaCtx.restore();const Tt=this.maskCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight),B=this.lumaCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight).data,at=Tt.data;for(let K=0;K<at.length;K+=4){const At=B[K],Mt=B[K+1],ee=B[K+2];let ie=(.299*At+.587*Mt+.114*ee)/255;Et&&(ie=1-ie),at[K+3]*=ie}this.maskCtx.putImageData(Tt,0,0)}else{this.maskCtx.save(),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),this.maskCtx.globalCompositeOperation=Et?"destination-out":"destination-in",mt>0&&(this.maskCtx.filter=`blur(${mt}px)`),this.maskCtx.globalAlpha=kt,this.applyAbsoluteTransform(this.maskCtx,Z.id,o);const ut=(q==null?void 0:q.width)||Z.geometry.width||0,ft=(q==null?void 0:q.height)||Z.geometry.height||0,St=(q==null?void 0:q.corner_radius)??Z.corner_radius??0;if(((Xt=Z.geometry)==null?void 0:Xt.type)==="Text"){const Tt=q!=null&&q.geometry?this.deepMerge(Z.geometry,q.geometry):Z.geometry,B=q!=null&&q.style?this.deepMerge(Z.style,q.style):Z.style;this._renderText(this.maskCtx,Z,{...Tt,width:ut,height:ft,corner_radius:St},B,q,ut,ft,!0,!1)}else if(((ae=Z.geometry)==null?void 0:ae.type)==="Image"){const Tt=Z.geometry.src;if(Tt){let B=this.imageCache.get(Tt);B||(B=new Image,B.src=Tt,this.imageCache.set(Tt,B)),B.complete&&B.naturalWidth>0?this.maskCtx.drawImage(B,-ut/2,-ft/2,ut,ft):(this.applyPath(this.maskCtx,Z.geometry,ut,ft,St),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else if(((Jt=Z.geometry)==null?void 0:Jt.type)==="SVG"){const Tt=Z.geometry.svgContent;if(Tt){const B=`__alphamask_${Z.id}`;let at=this.imageCache.get(B);if(!at){at=new Image;const K=new Blob([Tt],{type:"image/svg+xml"});at.src=URL.createObjectURL(K),at.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(B,at)}at.complete&&at.naturalWidth>0?this.maskCtx.drawImage(at,-ut/2,-ft/2,ut,ft):(this.applyPath(this.maskCtx,Z.geometry,ut,ft,St),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else this.applyPath(this.maskCtx,Z.geometry,ut,ft,St),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill();this.maskCtx.restore()}}),fe.save(),fe.setTransform(1,0,0,1,0,0);const it=s.maskBlendMode||s.blendMode;it&&it!=="Normal"&&(fe.globalCompositeOperation=it.toLowerCase()),fe.drawImage(this.maskBuffer,0,0),fe.restore(),fe.restore()}else t.restore()}}applyOuterGlowUnderlay(t,s,o,e,i,n,a,r){var I,k,P;const l=a||s.style||{},h=l.effect,f=l.effects||(h?[h]:[]),p=f.find(E=>E.isEnabled!==!1&&E.type==="Glow"&&(E.mode==="outer"||E.mode==="Outer Glow"||!E.mode));if(!p)return;const c=p.blur||10,d=1e4;let u=p.color||"white";(k=(I=this.artboard)==null?void 0:I.tokens)!=null&&k.colors&&this.artboard.tokens.colors[u]&&(u=this.artboard.tokens.colors[u]),t.save();const g=l.fill&&l.fill.type!=="None",y=f.some(E=>E.isEnabled!==!1&&E.type==="BackgroundBlur"),b=s.type==="Text",v=s.type==="Group";!b&&!v&&(g||y)&&(t.beginPath(),t.rect(-1e6,-1e6,2e6,2e6),s.type==="Frame"||s.type==="Component"?this.drawRoundRect(t,-e/2,-i/2,e,i,n):this._tracePath(t,o,e,i,n),t.clip("evenodd"));const S=t.getTransform();t.shadowColor=u,t.shadowBlur=c,t.shadowOffsetX=d*S.a,t.shadowOffsetY=d*S.b,t.translate(-d,0);let C="black";l.fill&&l.fill.type!=="None"&&(C=this.createCanvasFill(t,l.fill,e,i)||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,i)||l.stroke.color||"black"),t.fillStyle=C,t.strokeStyle=w,t.lineWidth=((P=l.stroke)==null?void 0:P.width)||0;const M=Math.min(p.intensity||1,10);for(let E=0;E<M;E++)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,i,n),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 A=e/2,L=i/2;t.ellipse(0,0,A,L,0,0,Math.PI*2)}else n!==0?this.drawRoundRect(t,-e/2,-i/2,e,i,n):t.rect(-e/2,-i/2,e,i);const _=l.fill&&l.fill.type!=="None",T=l.stroke&&l.stroke.width>0;(_||!_&&!T)&&t.fill(),T&&t.stroke()}t.restore()}_renderText(t,s,o,e,i,n,a,r=!1,l=!1){var nt,N,pt,yt,dt,wt,Pt,_t,Ut;let h=o.text||"";if(o.textInputId&&!r){const j=this.inputs.get(o.textInputId);j!==void 0&&(h=String(j),i.geometry&&i.geometry.type==="Text"&&(i.geometry.text=h))}if(o.svgPath){const j=o.svgPath;t.save();const gt=((nt=e==null?void 0:e.fill)==null?void 0:nt.color)||"#000000",Rt=((N=e==null?void 0:e.fill)==null?void 0:N.opacity)!==void 0?(pt=e==null?void 0:e.fill)==null?void 0:pt.opacity:1;t.fillStyle=gt,t.globalAlpha*=Rt;const It=new Path2D(j);t.fill(It),t.restore();return}let f=h||"";o.enableSegments===!0&&o.segments&&Array.isArray(o.segments)&&(f=o.segments.map(j=>j&&j.text?j.text:"").join(""));const p=o.textCase||"none";p==="uppercase"?f=f.toUpperCase():p==="lowercase"?f=f.toLowerCase():p==="capitalize"&&(f=f.replace(/\b\w/g,j=>j.toUpperCase()));let c=((yt=o.fontWeight)==null?void 0:yt.toString())||"400",d=o.fontStyle||"normal";c.toLowerCase().includes("italic")&&(d="italic",c=c.replace(/italic/gi,"").trim()||"400");const u=this.mapFontWeight(c),g=Math.max(1,o.fontSize||32);let y=o.fontFamily||"Inter";const b=["Bold","SemiBold","Medium","Regular","Light","Thin","ExtraBold","Black","Italic"];b.forEach(j=>{const gt=new RegExp(`[\\s-]${j}$`,"i");gt.test(y)&&(y=y.replace(gt,"").trim())});const C=`${o.smallCaps===!0?"small-caps ":""}${d} ${u} ${g}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 j=o.letterSpacing;I=j.unit==="PERCENT"?j.value/100*g:j.value}t.letterSpacing!==void 0&&(t.letterSpacing=`${I}px`);const k=o.kerning||"auto",P=o.kerningValue||0;k==="manual"&&P!==0&&(t.letterSpacing=`${I+P}px`);const E=o.paragraphSpacing||0;let _=o.lineHeight??1.2;typeof _=="string"&&(_=parseFloat(_)),_>5&&g>0&&(_=_/g);const T=(_||1.2)*g,A=o.isPointText===!0||!o.width||o.width<=0,L=((dt=o.padding)==null?void 0:dt.left)||((wt=o.padding)==null?void 0:wt.right)||0,X=A?1e5:o.width&&o.width>0?Math.ceil(o.width)-L*2:1e5;o.autoHeight;const D=ts({text:f,fontFamily:y,fontSize:g,fontWeight:u,fontStyle:d,lineHeight:_,width:X,letterSpacing:I,paragraphSpacing:E,paragraphIndent:o.paragraphIndent||0,segments:o.segments,enableSegments:o.enableSegments,textCase:p,hyphenation:o.hyphenation,composer:o.composer,balanceRaggedLines:o.balanceRaggedLines}),$=D.lines||[],G=D.maxFontSize||g,H=this.fontLeadingFactors[y]??.5,et=(T-g)*H;let O=D.height,x=n,st=a;if(x===0||st===0||x>=1e5){let j=0,gt=0;const Rt=D.fullText||f;($||[]).forEach(It=>{const bt=It.text||"",Ft=t.measureText(bt).width+(bt.length>0?(bt.length-1)*I:0);Ft>j&&(j=Ft),gt+=bt.length,gt<Rt.length&&(Rt[gt]===`
23
+ `||Rt[gt]==="\r")&&(gt++,Rt[gt-1]==="\r"&&Rt[gt]===`
24
+ `&&gt++)}),(x===0||x>=1e5)&&(x=j),st===0&&(st=O||0)}let Q=-O/2;a>0&&a>O&&(w==="top"?Q=-a/2:w==="middle"||w==="center"?Q=-O/2:w==="bottom"&&(Q=a/2-O)),Q+=et;let lt=null,F=0;if(o.pathId&&this.artboard){const j=this.artboard.objects.find(gt=>gt.id===o.pathId);if(j&&j.type==="Shape"&&((Pt=j.geometry)==null?void 0:Pt.type)==="Path"){const gt=this.objectStates.get(j.id),Rt=gt!=null&&gt.geometry?this.deepMerge(j.geometry,gt.geometry):j.geometry,It=(gt==null?void 0:gt.scale_x)!==void 0?(j.width||0)*gt.scale_x:j.width||0,bt=(gt==null?void 0:gt.scale_y)!==void 0?(j.height||0)*gt.scale_y:j.height||0;lt={geo:Rt,obj:j,w:It,h:bt},F=this.getPerimeter(Rt,It,bt)}}const W=(j,gt)=>{var It,bt;if(I===0&&(!o.enableSegments||!((It=o.segments)!=null&&It.length)))return t.measureText(j).width;let Rt=0;for(let Ft=0;Ft<j.length;Ft++){const Bt=gt+Ft;let zt=0;if(o.enableSegments===!0&&((bt=o.segments)==null?void 0:bt.length)>0){let Gt=0,qt=null;for(const ce of o.segments){if(Bt<Gt+(ce.text||"").length){qt=ce;break}Gt+=(ce.text||"").length}if(qt){t.save();let ce=qt.fontFamily||o.fontFamily||"Inter";const ve=this.mapFontWeight((qt.fontWeight||o.fontWeight||"400").toString()),Ht=qt.fontStyle||d,se=qt.fontSize||g;t.font=`${Ht} ${ve} ${se}px "${ce}", sans-serif`,zt=t.measureText(j[Ft]).width,t.restore()}else zt=t.measureText(j[Ft]).width}else zt=t.measureText(j[Ft]).width;Rt+=zt+I}return Rt-(j.length>0?I:0)},z=(j,gt,Rt,It,bt)=>{var ve,Ht;const Bt=(bt===0||f[bt-1]===`
25
+ `||f[bt-1]==="\r")&&o.paragraphIndent?o.paragraphIndent:0,zt=(!r||l)&&(s.behaviors||[]).some(se=>se.enabled&&(se.type.toString().includes("Text")||["Typewriter","Scramble","Wave","Bounce","GlitchText","Reveal3D","RevealSlide","RevealBlur"].includes(se.type))),Gt=!o.pathId&&!zt&&(o.enableSegments!==!0||!o.segments||o.segments.length===0),qt=o.baselineShift||0,ce=Rt+qt;if(Gt)t.font=C,It?t.strokeText(j,gt+Bt,ce):t.fillText(j,gt+Bt,ce);else{const se=W(j,bt);let we=gt+Bt;M==="center"?we-=se/2:M==="right"&&(we-=se);const Me=bt+j.length>=f.length||f[bt+j.length]===`
26
+ `||f[bt+j.length]==="\r";let fe=0,Ie=0;const _e=o.justifyMinWordSpacing,Ee=o.justifyMaxWordSpacing;if(M==="justify"&&!Me&&se>0&&!o.pathId){const ct=A?se:X-L*2+0,it=Math.max(0,ct-se);for(let R=0;R<j.length;R++)j[R]===" "&&Ie++;if(Ie>0){const R=t.measureText(" ").width;let Z=_e||R*.5,q=Ee||R*2.5;fe=Math.max(0,Math.min(it/Ie,q-Z))}}let le=o.pathOffset||0;o.pathId&&F>0&&lt&&(M==="center"?le+=F/2-se/2:M==="right"&&(le+=F-se));let ne=we;const ot=r&&!l?[]:((ve=s.behaviors)==null?void 0:ve.filter(ct=>[V.Typewriter,V.Scramble,V.Wave,V.Bounce,V.GlitchText,V.TextTrail,V.Reveal3D,V.RevealSlide,V.RevealBlur,V.TextLiquid,V.TextVortex,V.TextExplosion,V.TextRain,V.TextGravity,V.TextElastic,V.TextMatrix,V.TextNeon,V.TextGlitch3D,V.TextDissolve,V.TextOrganic,V.TextBreathe,V.TextFloral,V.TextSmoke,V.TextVariable,V.TextMagnet,V.TextSpin,V.TextZing,V.TextPerspective,V.TextMirror].includes(ct.type)&&ct.enabled))||[];for(let ct=0;ct<j.length;ct++){let it=j[ct];const R=bt+ct;let Z=0,q=0,mt=1,Et=1,kt=0,$t=1,vt=it;ot.forEach(ut=>{const ft=ut.settings||{},St=ft.strength||1,Tt=Date.now();if(ut.type===V.Typewriter)this.currentTime*(ft.speed||1)-R*(ft.stagger||.05)<0&&($t=0);else if(ut.type===V.Scramble)Math.max(0,Math.min(1,this.currentTime/(ft.duration||1.5))-R*.02)<1&&Math.random()<.3&&(vt="$%#@!*&"[Math.floor(Math.random()*7)]);else if(ut.type===V.Wave)q+=Math.sin(this.currentTime*5*(ft.speed||1)+R*(ft.frequency||1))*(ft.amplitude||20)*St;else if(ut.type===V.Bounce){const B=Math.max(0,this.currentTime%2-R*(ft.stagger||.1));B<1&&(q-=Math.abs(Math.sin(B*Math.PI))*(ft.height||50)*St)}else if(ut.type===V.TextTrail){const B=this.pointerHistory[Math.max(0,this.pointerHistory.length-1-R*(ft.delay||5))];B&&(Z+=(B.x-(i.x+ne))*St*.2,q+=(B.y-(i.y+Rt+q))*St*.2)}else if(ut.type===V.Reveal3D){const B=Math.max(0,Math.min(1,this.currentTime*(ft.speed||1)-R*(ft.stagger||.1)));mt*=B,Et*=B,$t=B}else if(ut.type===V.RevealSlide){const B=Math.max(0,Math.min(1,this.currentTime*1.5-R*.05)),at=(1-B)*(ft.distance||40)*St,K=ft.direction||"up";K==="up"?q-=at:K==="down"?q+=at:K==="left"?Z-=at:K==="right"&&(Z+=at),$t=B}else if(ut.type===V.RevealBlur){const B=Math.max(0,Math.min(1,this.currentTime*1.2-R*.1));$t=B,Z+=(1-B)*5}else if(ut.type===V.TextLiquid){const B=Math.max(0,Math.sin(Tt*.001*(ft.speed||1)+R*.5));q+=B*(ft.amplitude||10)*St,Et*=1+B*.2}else if(ut.type===V.TextVortex){const B=Tt*.002*(ft.speed||1)+R*.2,at=(1-(Math.sin(Tt*.001)*.5+.5))*(ft.radius||50);Z+=Math.cos(B)*at*St,q+=Math.sin(B)*at*St}else if(ut.type===V.TextExplosion){const B=ft.force||1,at=this.currentTime%2;if(at<1){const K=(R/j.length-.5)*Math.PI*2,At=at*100*B;Z+=Math.cos(K)*At*St,q+=Math.sin(K)*At*St,$t=1-at}}else if(ut.type===V.TextRain){const B=ft.speed||1,at=ft.height||100,K=(Tt*.001*B+R*.1)%1;q-=(1-K)*at*St,$t=K>.1?1:K*10}else if(ut.type===V.TextGravity){const B=ft.gravity||9.8,at=this.currentTime%3/3,K=.5*B*Math.pow(at*10,2);K<100?q+=K*St:q+=100*St}else if(ut.type===V.TextMatrix){const B=ft.speed||1;if(Math.random()<.1*B){const K="0123456789ABCDEF!@#$%^&*";vt=K[Math.floor(Math.random()*K.length)]}$t=.3+(Math.sin(Tt*.01*B+R)+1)/2*.7}else if(ut.type===V.TextNeon){const B=Math.random()>.95?.5:1;$t=(.7+(Math.sin(Tt*.005)+1)/2*.3)*B}else if(ut.type===V.TextDissolve)Math.sin(R*1.5+Tt*.002*(ft.speed||1))>.5&&($t=0);else if(ut.type===V.TextOrganic){const B=ft.speed||1,at=ft.amplitude||10;Z+=Math.sin(Tt*.002*B+R)*at*St,q+=Math.cos(Tt*.0015*B+R*.7)*at*St}else if(ut.type===V.TextBreathe){const at=1+(Math.sin(Tt*.003+R*.2)+1)/2*.2*St;mt*=at,Et*=at}else if(ut.type===V.TextSpin){const B=ft.speed||1;kt+=Tt*.01*B+R}else if(ut.type===V.TextMagnet){const B=this.pointerHistory[this.pointerHistory.length-1];if(B){const at=B.x-(i.x+ne),K=B.y-(i.y+Rt);kt=Math.atan2(K,at)}}else if(ut.type===V.TextPerspective){const B=j.length/2,at=(R-B)/B,K=1-Math.abs(at)*.3*St;mt*=K,Et*=K,Z+=at*20*St}else if(ut.type===V.TextMirror)$t*=.8;else if(ut.type===V.TextFloral){const B=ft.speed||1,at=ft.stagger||.1,K=(Tt*.001*B+R*at)%2;K<1&&(mt*=K,Et*=K,kt+=K*Math.PI)}else if(ut.type===V.TextSmoke){const B=ft.speed||1,at=ft.height||50,K=(Tt*5e-4*B+R*.2)%1;q-=K*at*St,Z+=Math.sin(Tt*.002+R)*5*St,$t=1-K}else if(ut.type===V.TextVariable){const B=ft.speed||1,at=ft.intensity||1.5,K=(Math.sin(Tt*.004*B+R*.3)+1)/2;mt*=1+K*(at-1)*St}else if(ut.type===V.TextZing){const B=ft.speed||2,at=ft.distance||100,K=(Tt*.002*B+R*.05)%1;Z+=(1-K)*at*St,$t=K}else if(ut.type===V.TextElastic){const B=ft.stiffness||.2,at=ft.damping||.1,K=Math.sin(Tt*.01)*Math.exp(-Tt*.001*at);Et*=1+K*B*St}else if(ut.type===V.TextGlitch3D){const B=ft.intensity||5;Math.random()<.2&&(Z+=(Math.random()-.5)*B,q+=(Math.random()-.5)*B,$t=.8)}else if(ut.type===V.GlitchText){const B=ft.intensity||5;Math.random()<.1&&(Z+=(Math.random()-.5)*B,q+=(Math.random()-.5)*B,Math.random()<.05&&($t=.5))}});let Wt=null,Y=o.textDecoration||"none",Xt=g;if(o.enableSegments===!0&&((Ht=o.segments)==null?void 0:Ht.length)>0){let ut=0,ft=null;for(const St of o.segments){if(R<ut+(St.text||"").length){ft=St;break}ut+=(St.text||"").length}if(ft){let St=ft.fontFamily||o.fontFamily||"Inter";b.forEach(at=>{const K=new RegExp(`[\\s-]${at}$`,"i");K.test(St)&&(St=St.replace(K,"").trim())});const Tt=this.mapFontWeight((ft.fontWeight||o.fontWeight||"400").toString()),B=ft.fontStyle||d;Xt=ft.fontSize||g,t.font=`${B} ${Tt} ${Xt}px "${St}", sans-serif`,ft.fill&&(Wt=ft.fill),ft.textDecoration&&(Y=ft.textDecoration),Xt<G&&(q+=(G-Xt)*.85)}}else t.font=C;const ae=t.globalAlpha;t.globalAlpha*=$t,t.save();const Jt=t.measureText(vt).width;if(lt&&F>0){const ut=ne-we+Jt/2,St=(le+ut)/F,Tt=this.getPointOnPath(lt.geo,lt.w,lt.h,Math.abs(St%1)),B=Tt.angle,at=Rt+q+(o.pathOffsetY||0),K=o.pathSide==="right"?-1:1,At=Math.cos(B+Math.PI/2)*at*K,Mt=Math.sin(B+Math.PI/2)*at*K;t.translate(Tt.x+At+Z,Tt.y+Mt),t.rotate(B+kt+(K===-1?Math.PI:0))}else t.translate(ne+Z+Jt/2,Rt+q),kt!==0&&t.rotate(kt);if(t.scale(mt,Et),Wt&&!r&&!l){const ut=this.createCanvasFill(t,Wt,x,st);t.fillStyle=ut||Wt.color||"#000000"}else if(!r&&!l){const ut=this.createCanvasFill(t,e.fill,x,st);t.fillStyle=ut||e.fill.color||"#000000"}if($t>0)if(r||l){const ut=l?"#000000":this.createCanvasFill(t,e.fill,x,st);t.fillStyle=ut||e.fill.color||"#ffffff",t.fillText(vt,-Jt/2,0)}else It?t.strokeText(vt,-Jt/2,0):t.fillText(vt,-Jt/2,0);Y!=="none"&&!r&&this.drawTextDecoration(t,Y,0,0,Jt,Xt),t.restore(),t.globalAlpha=ae,M==="justify"&&fe>0&&vt===" "&&!Me?ne+=Jt+I+fe:ne+=Jt+I}}};if(r){let j=0,gt=Q;($||[]).forEach(Rt=>{const It=Rt.text||"",bt=f.indexOf(It,j);bt!==-1&&(j=bt);let Ft=-x/2;M==="center"?Ft=0:M==="right"&&(Ft=x/2),z(It,Ft,gt,!1,j),j+=It.length,gt+=T})}else if(l){let j=0,gt=Q;($||[]).forEach(Rt=>{const It=Rt.text||"";let bt=-x/2;M==="center"?bt=0:M==="right"&&(bt=x/2),z(It,bt,gt,!1,j),j+=It.length,j<f.length&&(f[j]===`
27
+ `||f[j]==="\r")&&(j++,f[j-1]==="\r"&&f[j]===`
28
+ `&&j++),gt+=T})}else{if(e.fill){const gt=t.globalAlpha,Rt=this.createCanvasFill(t,e.fill,x,st);t.fillStyle=Rt||e.fill.color||"#000000",t.globalAlpha=gt*this.normalizeOpacity(e.fill.opacity??100);const It=D.fullText||(o.enableSegments?(o.segments||[]).map(Bt=>{let zt=Bt.text||"";const Gt=Bt.textCase||o.textCase||"none";return Gt==="uppercase"?zt.toUpperCase():Gt==="lowercase"?zt.toLowerCase():Gt==="capitalize"?zt.replace(/\b\w/g,qt=>qt.toUpperCase()):zt}).join(""):f);let bt=0,Ft=Q;($||[]).forEach(Bt=>{const zt=Bt.text||"";let Gt=-x/2;M==="center"?Gt=0:M==="right"&&(Gt=x/2),z(zt,Gt,Ft,!1,bt),bt+=zt.length,Ft+=T,bt<It.length&&(It[bt]===`
29
+ `||It[bt]==="\r")&&(E>0&&(Ft+=E),bt++,It[bt-1]==="\r"&&It[bt]===`
30
+ `&&bt++)}),t.globalAlpha=gt}const j=o.paragraphRule;if(j&&(((_t=j.top)==null?void 0:_t.width)>0||((Ut=j.bottom)==null?void 0:Ut.width)>0)){let gt=0;($||[]).forEach((Rt,It)=>{var Bt,zt;const Ft=gt===0||gt<f.length&&(f[gt]===`
31
+ `||f[gt]==="\r");if(Ft&&It>0&&gt++,Ft){if(((Bt=j.top)==null?void 0:Bt.width)>0){const Gt=Q+It*T-j.top.offset;t.strokeStyle=j.top.color||"#000000",t.lineWidth=j.top.width,t.beginPath();const qt=-n/2+T*.2;t.moveTo(qt,Gt),t.lineTo(n/2-T*.2,Gt),t.stroke()}if(((zt=j.bottom)==null?void 0:zt.width)>0){const Gt=Q+(It+1)*T-j.bottom.offset;t.strokeStyle=j.bottom.color||"#000000",t.lineWidth=j.bottom.width,t.beginPath();const qt=-n/2+T*.2;t.moveTo(qt,Gt),t.lineTo(n/2-T*.2,Gt),t.stroke()}}gt+=(Rt.text||"").length})}if(e.stroke&&e.stroke.width>0){const gt=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 It=t.getTransform(),bt=Math.sqrt(It.a*It.a+It.b*It.b)||1,Ft=window.devicePixelRatio||1;t.lineWidth=(e.stroke.width||1)*Ft/bt,t.globalAlpha=gt*this.normalizeOpacity(e.stroke.opacity??100);let Bt=0,zt=Q;($||[]).forEach(Gt=>{let qt=-x/2;M==="center"?qt=0:M==="right"&&(qt=x/2),z(Gt.text,qt,zt,!0,Bt),Bt+=(Gt.text||"").length,zt+=T,Bt<f.length&&(f[Bt]===`
32
+ `||f[Bt]==="\r")&&(E>0&&(zt+=E),Bt++,f[Bt-1]==="\r"&&f[Bt]===`
33
+ `&&Bt++)}),t.globalAlpha=gt}}}applyStrokeAlignment(t,s,o,e,i,n){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,h=window.devicePixelRatio||1,f=(a.width||1)*h/l,p=(a.alignment||"center").toLowerCase();if(t.save(),s.fill&&s.fill.type!=="None"&&s.fill.isEnabled!==!1&&s.fill.opacity!==0&&s.fill.color!=="transparent"&&s.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),a.fill){const S=this.createCanvasFill(t,a.fill,e,i);S?t.strokeStyle=S:t.strokeStyle=a.color||"#000000"}else t.strokeStyle=a.color||"#000000";const d=t.globalAlpha;t.globalAlpha=d*this.normalizeOpacity(a.opacity??100),t.lineWidth=f,t.lineCap=a.lineCap||"round",t.lineJoin=a.lineJoin||"round",a.miterLimit!==void 0&&(t.miterLimit=a.miterLimit);const u=a.trimStart??0,g=a.trimEnd??1,y=a.trimOffset??0,b=a.dashOffset??0,v=a.dashArray||[];if(u!==0||g!==1||y!==0){const S=this.getPerimeter(o,e,i);if(S>0){const C=Math.max(0,Math.min(1,u)),w=Math.max(0,Math.min(1,g));if(C<w){const M=S*(w-C),I=S-M,k=-(S*(C+y%1));t.setLineDash([M,I]),t.lineDashOffset=k-b*S}else if(C===w)t.setLineDash([0,S]);else{const M=S*(1-C+w),I=S-M,k=-(S*C);t.setLineDash([M,I]),t.lineDashOffset=k-b*S}}}else if(v.length>0||b!==0){v.length>0&&t.setLineDash(v);const S=this.getPerimeter(o,e,i);t.lineDashOffset=-(b*S)}if((o==null?void 0:o.type)==="Line"||e===0||i===0)this.applyPath(t,o,e,i,n),t.stroke();else if(p==="inside")t.lineWidth=f*2,t.save(),this.applyPath(t,o,e,i,n),t.clip(),t.stroke(),t.restore();else if(p==="outside"){t.save(),t.beginPath();const S=Math.max(e,i,2e4);t.rect(-S,-S,S*2,S*2),this._tracePath(t,o,e,i,n),t.clip("evenodd"),t.lineWidth=f*2,t.beginPath(),this.applyPath(t,o,e,i,n),t.stroke(),t.restore()}else t.lineWidth=f,this.applyPath(t,o,e,i,n),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,i=Math.abs(o)/2,n=Math.abs(t.sweepAngle??360),a=t.ratio||0,r=Math.PI*(3*(e+i)-Math.sqrt((3*e+i)*(e+3*i)));if(n>=360&&a<=0)return r;let l=n/360*r;if(a>0){const h=Math.PI*(3*(e*a+i*a)-Math.sqrt((3*e*a+i*a)*(e*a+3*i*a)));l+=n/360*h,n<360&&(l+=2*Math.sqrt((e-e*a)**2+(i-i*a)**2))}else n<360&&(l+=2*Math.max(e,i));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,i=t.radius||Math.min(s,o)/2;return 2*e*i*Math.sin(Math.PI/e)}case"Star":{const e=t.points||5,i=t.outer_radius||Math.min(s,o)/2,n=t.inner_radius||i/2,a=Math.PI/e;return Math.sqrt(i*i+n*n-2*i*n*Math.cos(a))*e*2}case"Path":{const e=t.points||[];if(e.length<2)return t.length||0;let i=0,n=e[0].x,a=e[0].y;for(let r=1;r<e.length;r++){const l=e[r];if(l.moveTo){n=l.x,a=l.y;continue}const h=n,f=a,p=e[r-1].out_x,c=e[r-1].out_y;if(p!==void 0||l.in_x!==void 0?i+=this.getBezierLength(h,f,p??h,c??f,l.in_x??l.x,l.in_y??l.y,l.x,l.y):i+=Math.sqrt((l.x-h)**2+(l.y-f)**2),n=l.x,a=l.y,l.closePath||r===e.length-1&&(t.is_closed||t.isClosed)){const d=n,u=a,g=[...e.slice(0,r+1)].reverse().find(M=>M.moveTo)||e[0],y=g.x,b=g.y,v=e[r].out_x,S=e[r].out_y,C=g.in_x,w=g.in_y;v!==void 0||C!==void 0?i+=this.getBezierLength(d,u,v??d,S??u,C??y,w??b,y,b):i+=Math.sqrt((y-d)**2+(b-u)**2)}}return i}default:return(s+o)*2}}getBezierLength(t,s,o,e,i,n,a,r,l=10){let h=0,f=t,p=s;for(let c=1;c<=l;c++){const d=c/l,u=1-d,g=d*d,y=u*u,b=y*u,v=g*d,S=b*t+3*y*d*o+3*u*g*i+v*a,C=b*s+3*y*d*e+3*u*g*n+v*r,w=S-f,M=C-p;h+=Math.sqrt(w*w+M*M),f=S,p=C}return h}getBezierTAtLength(t,s,o,e,i,n,a,r,l,h=20){if(t<=0)return 0;let f=0,p=s,c=o;for(let d=1;d<=h;d++){const u=d/h,g=1-u,y=u*u,b=g*g,v=b*g,S=y*u,C=v*s+3*b*u*e+3*g*y*n+S*r,w=v*o+3*b*u*i+3*g*y*a+S*l,M=C-p,I=w-c,k=Math.sqrt(M*M+I*I);if(f+k>=t){const P=t-f,E=k===0?0:P/k;return(d-1+E)/h}f+=k,p=C,c=w}return 1}getPointOnPath(t,s,o,e){if(this.ensurePathPoints(t),(t==null?void 0:t.type)==="Path"){const i=t.points||[];if(i.length<2)return{x:0,y:0,angle:0};let n=1/0,a=-1/0,r=1/0,l=-1/0;i.forEach(b=>{typeof b.x=="number"&&typeof b.y=="number"&&(n=Math.min(n,b.x),a=Math.max(a,b.x),r=Math.min(r,b.y),l=Math.max(l,b.y),b.out_x!==void 0&&(n=Math.min(n,b.out_x),a=Math.max(a,b.out_x)),b.out_y!==void 0&&(r=Math.min(r,b.out_y),l=Math.max(l,b.out_y)),b.in_x!==void 0&&(n=Math.min(n,b.in_x),a=Math.max(a,b.in_x)),b.in_y!==void 0&&(r=Math.min(r,b.in_y),l=Math.max(l,b.in_y)))});const h=(n+a)/2,f=(r+l)/2,c=this.getPerimeter(t,s,o)*e;let d=0;const u=[];let g=i[0],y=i[0];for(let b=1;b<i.length;b++){const v=i[b];if(v.moveTo){g=v,y=v;continue}u.push({p0:g,p1:v}),(v.closePath||b===i.length-1&&(t.is_closed||t.isClosed))&&u.push({p0:v,p1:y}),g=v}for(const b of u){const v=b.p0,S=b.p1;let C=0;const w=v.out_x!==void 0||S.in_x!==void 0;if(w?C=this.getBezierLength(v.x,v.y,v.out_x??v.x,v.out_y??v.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y):C=Math.sqrt((S.x-v.x)**2+(S.y-v.y)**2),d+C>=c||b===u[u.length-1]){let M=0;if(w)return M=this.getBezierTAtLength(c-d,v.x,v.y,v.out_x??v.x,v.out_y??v.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y,20),this.getBezierPointAndAngle(M,v,S,h,f);{M=C===0?0:(c-d)/C;const I=v.x+(S.x-v.x)*M-h,k=v.y+(S.y-v.y)*M-f,P=Math.atan2(S.y-v.y,S.x-v.x);return{x:I,y:k,angle:P}}}d+=C}}else if(t.type==="Ellipse"){const i=Math.abs(s)/2,n=Math.abs(o)/2,a=t.sweepAngle??360,l=((t.startAngle??0)+a*e)*Math.PI/180,h=i*Math.cos(l),f=n*Math.sin(l),p=-i*Math.sin(l),c=n*Math.cos(l),d=Math.atan2(c,p);return{x:h,y:f,angle:d}}else if((t==null?void 0:t.type)==="Rectangle"){const i=Math.abs(s),n=Math.abs(o),r=(i+n)*2*e;let l=0,h=0,f=0;return r<i?(l=-i/2+r,h=-n/2,f=0):r<i+n?(l=i/2,h=-n/2+(r-i),f=Math.PI/2):r<2*i+n?(l=i/2-(r-(i+n)),h=n/2,f=Math.PI):(l=-i/2,h=n/2-(r-(2*i+n)),f=-Math.PI/2),{x:l,y:h,angle:f}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(t,s,o,e,i){const n=s.x,a=s.y,r=s.out_x??s.x,l=s.out_y??s.y,h=o.in_x??o.x,f=o.in_y??o.y,p=o.x,c=o.y,d=1-t,u=t*t,g=d*d,y=g*d,b=u*t,v=y*n+3*g*t*r+3*d*u*h+b*p-e,S=y*a+3*g*t*l+3*d*u*f+b*c-i,C=3*g*(r-n)+6*d*t*(h-r)+3*u*(p-h),w=3*g*(l-a)+6*d*t*(f-l)+3*u*(c-f),M=Math.atan2(w,C);return{x:v,y:S,angle:M}}applyAbsoluteTransform(t,s,o){if(!o.get(s))return;const i=[];let n=s;for(;n;){i.unshift(n);const a=o.get(n);n=a==null?void 0:a.parentId}i.forEach(a=>{this.applyObjectTransform(t,a)})}applyObjectTransform(t,s){var d,u,g;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,i=o.skew_y||0;if(e!==0||i!==0){const y=Math.tan(e*Math.PI/180),b=Math.tan(i*Math.PI/180);t.transform(1+y*b,b,y,1,0,0)}const n=o.rotate_x!==void 0?o.rotate_x:((d=o.transform)==null?void 0:d.rotate_x)??0,a=o.rotate_y!==void 0?o.rotate_y:((u=o.transform)==null?void 0:u.rotate_y)??0,l=1+(o.translate_z!==void 0?o.translate_z:((g=o.transform)==null?void 0:g.translate_z)??0)/1e3,h=(o.flip_x===!0?-1:1)*Math.cos(a*Math.PI/180)*l,f=(o.flip_y===!0?-1:1)*Math.cos(n*Math.PI/180)*l,p=(o.scale_x??1)*h,c=(o.scale_y??1)*f;t.scale(p,c)}applyInnerGlowOverlay(t,s,o,e,i,n,a){var y,b;const r=a||s.style||{},l=r==null?void 0:r.effect,f=((r==null?void 0:r.effects)||(l?[l]:[])).find(v=>v.isEnabled!==!1&&v.type==="Glow"&&(v.mode==="inner"||v.mode==="Inner Glow"));if(!f)return;t.save(),t.beginPath(),this.applyPath(t,o,e,i,n),t.clip();const p=f.blur||10,c=1e4,d=t.getTransform();let u=f.color||"white";(b=(y=this.artboard)==null?void 0:y.tokens)!=null&&b.colors&&this.artboard.tokens.colors[u]&&(u=this.artboard.tokens.colors[u]),t.shadowColor=u,t.shadowBlur=p,t.shadowOffsetX=c*d.a,t.shadowOffsetY=c*d.b,t.translate(-c,0),t.lineWidth=p+5,t.strokeStyle=u;const g=Math.min(f.intensity||1,5);for(let v=0;v<g;v++)t.beginPath(),this.applyPath(t,o,e,i,n),t.stroke();t.restore()}applyArtEffectOverlay(t,s,o,e,i,n){var c,d,u,g,y;const a=this.objectStates.get(s.id),r=((c=a==null?void 0:a.style)==null?void 0:c.artEffect)||s.artEffect||((d=s.style)==null?void 0:d.artEffect);if(!r||!r.enabled)return;const l=r.type,h=r.intensity??.5,f=r.speed??1,p=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,i,n),t.clip(),l==="shimmer"){const v=this.currentTime*f%2/2,S=t.createLinearGradient(-e,-i,e,i);S.addColorStop(Math.max(0,v-.2),"rgba(255,255,255,0)"),S.addColorStop(v,`rgba(255,255,255,${h*.8})`),S.addColorStop(Math.min(1,v+.2),"rgba(255,255,255,0)"),t.fillStyle=S,t.globalCompositeOperation="screen",t.fillRect(-e/2,-i/2,e,i),t.globalCompositeOperation="source-over"}else if(l==="glint_overlay"){let S=((this._lastPointerPos||{x:0}).x-(((u=s.transform)==null?void 0:u.x)??0)+300)/600;S=Math.max(-.2,Math.min(1.2,S));const C=t.createLinearGradient(-e,-i,e,i);C.addColorStop(Math.max(0,S-.15),"rgba(255,255,255,0)"),C.addColorStop(Math.max(0,Math.min(1,S)),`rgba(255,255,255,${h})`),C.addColorStop(Math.min(1,S+.15),"rgba(255,255,255,0)"),t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-i/2,e,i),t.globalCompositeOperation="source-over"}else if(l==="fold_overlay"){const b=this._lastPointerPos||{x:0,y:0},v=b.x-(((g=s.transform)==null?void 0:g.x)??0),S=b.y-(((y=s.transform)==null?void 0:y.y)??0),C=t.createLinearGradient(v>0?-e/2:e/2,S>0?-i/2:i/2,v>0?e/2:-e/2,S>0?i/2:-i/2);C.addColorStop(0,`rgba(0,0,0,${h*.6})`),C.addColorStop(.4,"rgba(0,0,0,0)"),C.addColorStop(.5,`rgba(255,255,255,${h*.4})`),C.addColorStop(1,`rgba(0,0,0,${h*.2})`),t.fillStyle=C,t.globalCompositeOperation="overlay",t.fillRect(-e/2,-i/2,e,i),t.globalCompositeOperation="source-over",t.beginPath(),v>0&&S>0?(t.moveTo(e/2-40,i/2),t.lineTo(e/2,i/2-40),t.lineTo(e/2-40,i/2-40)):v<0&&S>0?(t.moveTo(-e/2+40,i/2),t.lineTo(-e/2,i/2-40),t.lineTo(-e/2+40,i/2-40)):v>0&&S<0?(t.moveTo(e/2-40,-i/2),t.lineTo(e/2,-i/2+40),t.lineTo(e/2-40,-i/2+40)):(t.moveTo(-e/2+40,-i/2),t.lineTo(-e/2,-i/2+40),t.lineTo(-e/2+40,-i/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=S>0?-2:2,t.fill()}else if(l==="crumple_overlay"){const b=Math.floor(e/p),v=document.createElement("canvas");v.width=b,v.height=Math.floor(i/p);const S=v.getContext("2d"),C=S.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*h}S.putImageData(C,0,0),t.globalCompositeOperation="multiply",t.imageSmoothingEnabled=!1,t.drawImage(v,-e/2,-i/2,e,i)}else if(l==="acid_gradient"||l==="acid_rave"){const b=this.currentTime*f,v=r.color1,S=r.color2,C=t.createLinearGradient(-e/2,-i/2,e/2,i/2);if(v&&S){const w=b*60%360;C.addColorStop(0,this._shiftHue(v,w,h*.7)),C.addColorStop(1,this._shiftHue(S,(w+180)%360,h*.7))}else{const w=b*100%360,M=(w+180)%360;C.addColorStop(0,`hsla(${w}, 80%, 50%, ${h*.5})`),C.addColorStop(1,`hsla(${M}, 80%, 50%, ${h*.5})`)}t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-i/2,e,i)}else if(l==="halftone"){const b=Math.max(2,p*(1-h*.8)),v=document.createElement("canvas");v.width=b,v.height=b;const S=v.getContext("2d");if(S){S.fillStyle="black",S.beginPath(),S.arc(b/2,b/2,b/2*h,0,Math.PI*2),S.fill();const C=t.createPattern(v,"repeat");C&&(t.globalAlpha=.3*h,t.fillStyle=C,t.fillRect(-e/2,-i/2,e,i))}}else if(l==="noise"){const b=Math.floor(e*i*h*.02);t.globalAlpha=.4*h;for(let v=0;v<b;v++){const S=Math.random()>.5?255:0;t.fillStyle=`rgba(${S}, ${S}, ${S}, ${.5+Math.random()*.5})`,t.fillRect(-e/2+Math.random()*e,-i/2+Math.random()*i,2,2)}}else if(l==="scanlines"){t.globalAlpha=.2*h,t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1;for(let b=-i/2;b<i/2;b+=4)t.beginPath(),t.moveTo(-e/2,b),t.lineTo(e/2,b),t.stroke()}else if(l==="chromatic_aberration"){const b=5*h;t.globalCompositeOperation="screen",t.globalAlpha=.5,t.fillStyle="cyan",t.fillRect(-e/2-b,-i/2,e,i),t.fillStyle="magenta",t.fillRect(-e/2+b,-i/2,e,i)}else if(l==="pixelate"){const b=Math.max(2,Math.round(p*(1-h*.5))),v=document.createElement("canvas"),S=Math.max(1,Math.ceil(e/b)),C=Math.max(1,Math.ceil(i/b));v.width=S,v.height=C;const w=v.getContext("2d");if(w){w.imageSmoothingEnabled=!1;const M=t.getTransform(),I=M.e-e/2,k=M.f-i/2;w.drawImage(t.canvas,I,k,e,i,0,0,S,C),t.imageSmoothingEnabled=!1,t.drawImage(v,0,0,S,C,-e/2,-i/2,e,i),t.imageSmoothingEnabled=!0}}else if(l==="glitch"){const b=this.currentTime*f,v=r.chaosAmount??.2,S=Math.max(3,Math.floor(8*h)),C=h*e*.15;t.globalCompositeOperation="screen",t.globalAlpha=h*.4;const w=C*.3;t.fillStyle="rgba(255, 0, 0, 0.4)",t.fillRect(-e/2+w,-i/2,e,i),t.fillStyle="rgba(0, 255, 255, 0.4)",t.fillRect(-e/2-w,-i/2,e,i),t.globalCompositeOperation="source-over",t.globalAlpha=1;const M=i/S;for(let I=0;I<S;I++){const k=Math.sin(I*127.1+b*311.7*f)*43758.5,P=k-Math.floor(k);if(P>1-v){const E=(P-(1-v))/v*C*(Math.random()>.5?1:-1),_=-i/2+I*M,T=t.getTransform(),A=T.e-e/2+E,L=T.f+_;t.save(),t.beginPath(),t.rect(-e/2,_,e,M),t.clip(),t.globalAlpha=.8,t.drawImage(t.canvas,A,L,e,M,-e/2+E,_,e,M),t.restore()}}}t.restore()}}_shiftHue(t,s,o){let e=0,i=0,n=0;if(t.startsWith("#")){const c=t.replace("#","");e=parseInt(c.substring(0,2),16)/255,i=parseInt(c.substring(2,4),16)/255,n=parseInt(c.substring(4,6),16)/255}const a=Math.max(e,i,n),r=Math.min(e,i,n);let l=0,h=0,f=(a+r)/2;if(a!==r){const c=a-r;switch(h=f>.5?c/(2-a-r):c/(a+r),a){case e:l=((i-n)/c+(i<n?6:0))/6;break;case i:l=((n-e)/c+2)/6;break;case n:l=((e-i)/c+4)/6;break}}return`hsla(${(((l*360+s)%360+360)%360).toFixed(0)}, ${(h*100).toFixed(0)}%, ${(f*100).toFixed(0)}%, ${o})`}applyBackgroundBlurGlass(t,s,o,e,i,n,a){const r=n.radius??10,l=n.opacity!==void 0?this.normalizeOpacity(n.opacity):.5,h=n.noise??0,f=n.color??"rgba(255,255,255,0.2)";t.save(),this.applyPath(t,s,o,e,i),t.clip();const p=t.getTransform(),c=t.canvas;try{const g=document.createElement("canvas");g.width=Math.max(1,Math.ceil(o)),g.height=Math.max(1,Math.ceil(e));const y=g.getContext("2d");if(y){y.save(),y.translate(o/2,e/2);const b=n.magnification||1;if(b!==1&&y.scale(b,b),typeof p.inverse=="function"){const C=p.inverse();y.transform(C.a,C.b,C.c,C.d,C.e,C.f)}else{const C=p.a*p.d-p.b*p.c;C!==0&&y.transform(p.d/C,-p.b/C,-p.c/C,p.a/C,(p.c*p.f-p.d*p.e)/C,(p.b*p.e-p.a*p.f)/C)}y.drawImage(c,0,0),y.restore();const v=document.createElement("canvas");v.width=g.width,v.height=g.height;const S=v.getContext("2d");S.filter=`blur(${r}px)`,S.drawImage(g,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(g){console.error("Background blur failed:",g)}t.globalCompositeOperation="source-over",t.globalAlpha=l,t.fillStyle=f,t.fillRect(-o/2,-e/2,o,e),t.globalAlpha=1;const d=t.createLinearGradient(-o/2,-e/2,o/2,e/2);if(d.addColorStop(0,"rgba(255,255,255,0.12)"),d.addColorStop(.3,"rgba(255,255,255,0.04)"),d.addColorStop(.5,"rgba(255,255,255,0.0)"),d.addColorStop(1,"rgba(255,255,255,0.0)"),t.fillStyle=d,t.fillRect(-o/2,-e/2,o,e),h>0){if(t.globalAlpha=h/100,!this._noiseTileCanvas){const y=document.createElement("canvas");y.width=64,y.height=64;const b=y.getContext("2d"),v=b.createImageData(64,64),S=v.data;for(let C=0;C<S.length;C+=4){const w=Math.floor(Math.random()*255);S[C]=w,S[C+1]=w,S[C+2]=w,S[C+3]=18}b.putImageData(v,0,0),this._noiseTileCanvas=y}const g=t.createPattern(this._noiseTileCanvas,"repeat");g&&(t.fillStyle=g,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,i),this.applyStrokeAlignment(t,a,s,o,e,i)):(t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1.5,this.applyPath(t,s,o,e,i),t.stroke()),t.restore()}applyPath(t,s,o,e,i){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,i)}_tracePath(t,s,o,e,i){if(s){if(this.ensurePathPoints(s),(s==null?void 0:s.type)==="Rectangle"||s.type==="Image"){const n=i!==void 0?i:s.corner_radius??0;this.drawRoundRect(t,-o/2,-e/2,o,e,n)}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:n=0,sweepAngle:a=360,ratio:r=0}=s,l=o/2,h=e/2,f=n*Math.PI/180,p=a*Math.PI/180,c=f+p;a>=360&&r<=0?t.ellipse(0,0,l,h,0,0,Math.PI*2):(t.ellipse(0,0,l,h,0,f,c,!1),r>0?t.ellipse(0,0,l*r,h*r,0,c,f,!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 n=s.sides||3,a=s.radius||Math.min(o,e)/2;for(let r=0;r<n;r++){const l=r*2*Math.PI/n-Math.PI/2,h=a*Math.cos(l),f=a*Math.sin(l);r===0?t.moveTo(h,f):t.lineTo(h,f)}t.closePath()}else if(s.type==="Star"){const n=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<n*2;l++){const h=l*Math.PI/n-Math.PI/2,f=l%2===0?a:r,p=f*Math.cos(h),c=f*Math.sin(h);l===0?t.moveTo(p,c):t.lineTo(p,c)}t.closePath()}else if(((s==null?void 0:s.type)==="Path"||s.type==="Subtract"||s.type==="Union"||s.type==="Intersect"||s.type==="Exclude"||s.type==="BooleanOperation")&&s.points){this.frameCount%300===0&&this.log("[Engine] Tracing Path:",s.points.length,"points");let n=1/0,a=-1/0,r=1/0,l=-1/0;if(s.points.forEach(p=>{typeof p.x=="number"&&typeof p.y=="number"&&(n=Math.min(n,p.x),a=Math.max(a,p.x),r=Math.min(r,p.y),l=Math.max(l,p.y),p.out_x!==void 0&&(n=Math.min(n,p.out_x),a=Math.max(a,p.out_x)),p.out_y!==void 0&&(r=Math.min(r,p.out_y),l=Math.max(l,p.out_y)),p.in_x!==void 0&&(n=Math.min(n,p.in_x),a=Math.max(a,p.in_x)),p.in_y!==void 0&&(r=Math.min(r,p.in_y),l=Math.max(l,p.in_y)))}),n===1/0)return;const h=(n+a)/2,f=(r+l)/2;if(isNaN(h)||isNaN(f)){this.warn("[Engine] Invalid path center:",h,f);return}s.points.forEach((p,c)=>{if(c===0||p.moveTo)t.moveTo(p.x-h,p.y-f);else{const d=s.points[c-1];if(!d)return;const u=(d.out_x??d.x)-h,g=(d.out_y??d.y)-f,y=(p.in_x??p.x)-h,b=(p.in_y??p.y)-f;isNaN(u)||isNaN(y)||isNaN(p.x)?t.lineTo(p.x-h,p.y-f):t.bezierCurveTo(u,g,y,b,p.x-h,p.y-f)}if(p.closePath||c===s.points.length-1&&(s.is_closed||s.isClosed)){const d=[...s.points.slice(0,c+1)].reverse().find(u=>u.moveTo)||s.points[0];d&&(p.out_x!==void 0||d.in_x!==void 0)&&t.bezierCurveTo((p.out_x??p.x)-h,(p.out_y??p.y)-f,(d.in_x??d.x)-h,(d.in_y??d.y)-f,d.x-h,d.y-f),t.closePath()}})}else if(s.points&&Array.isArray(s.points)){let n=1/0,a=-1/0,r=1/0,l=-1/0;s.points.forEach(p=>{n=Math.min(n,p.x),a=Math.max(a,p.x),r=Math.min(r,p.y),l=Math.max(l,p.y)});const h=(n+a)/2,f=(r+l)/2;s.points.forEach((p,c)=>{if(c===0)t.moveTo(p.x-h,p.y-f);else{const d=s.points[c-1];d.out_x!==void 0||p.in_x!==void 0?t.bezierCurveTo((d.out_x??d.x)-h,(d.out_y??d.y)-f,(p.in_x??p.x)-h,(p.in_y??p.y)-f,p.x-h,p.y-f):t.lineTo(p.x-h,p.y-f)}(p.closePath||c===s.points.length-1&&(s.is_closed||s.isClosed))&&t.closePath()})}}}renderInputBox(t,s){var F,W;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((F=s.geometry)==null?void 0:F.width)||250,n=((W=s.geometry)==null?void 0:W.height)||45,a=this.focusedId===s.id,r=this.lastHoveredObjectId===s.id,l=e.previewState||"default",h=l!=="default"?l:a?"focused":r?"hovered":"default",f=e.label||{visible:!0,text:"Label"},p=e.helperText||{visible:!1,text:"Helper text"},c=e.leftIcon||{visible:!1},d=e.rightIcon||{visible:!1},u=e.multiline===!0,g=e.corner_radius??8,y=e.corners||{tl:g,tr:g,bl:g,br:g},b=[y.tl,y.tr,y.br,y.bl];let v=e.backgroundColor||"rgba(31, 41, 55, 1)",S=e.borderColor||"rgba(55, 65, 81, 1)",C=e.borderWidth??1.5,w=e.color||"#ffffff",M=e.placeholderColor||"rgba(156, 163, 175, 1)",I=e.fontSize||14;const k=`${h}Style`,P=e[k];P?(P.backgroundColor!==void 0&&(v=P.backgroundColor),P.borderColor!==void 0&&(S=P.borderColor),P.borderWidth!==void 0&&(C=P.borderWidth),P.color!==void 0&&(w=P.color),P.placeholderColor!==void 0&&(M=P.placeholderColor),P.fontSize!==void 0&&(I=P.fontSize)):h==="focused"?(S=e.focusBorderColor||"rgba(59, 130, 246, 1)",C=Math.max(C,2)):h==="hovered"||h==="hover"?(S=e.hoverBorderColor||S,v=e.hoverBackgroundColor||v):h==="disabled"?(v=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",S=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):h==="error"&&(S="rgba(239, 68, 68, 1)",C=Math.max(C,2)),t.beginPath(),this.drawRoundRect(t,-i/2,-n/2,i,n,b);const E=this.createCanvasFill(t,v,i,n);if(E&&(t.fillStyle=E,t.fill()),C>0){const z=this.createCanvasFill(t,S,i,n);if(z&&(t.strokeStyle=z,t.lineWidth=C,t.stroke()),h==="focused"||h==="focus"){t.save(),t.beginPath();const nt=b.map(N=>N+2);this.drawRoundRect(t,-i/2-2,-n/2-2,i+4,n+4,nt),t.strokeStyle="rgba(59, 130, 246, 0.3)",t.lineWidth=2,t.stroke(),t.restore()}}const _=(z,nt)=>{if(!z.visible||!z.svgPath)return;const N=z.size||14,pt=z.offset??16,yt=z.color||"#ffffff",dt=nt?-(i/2)+pt:i/2-pt,wt=z.svgPath;if(t.save(),t.translate(dt,0),!wt.startsWith("<svg")){const Pt=new Path2D(wt),_t=N/24;t.scale(_t,_t),t.translate(-12,-12),t.fillStyle=yt,t.fill(Pt)}t.restore()};_(c,!0),_(d,!1);const T=e.text||"",A=e.placeholder||"Enter text...",L=!T,X=T||A,D=L?M:w,$=I,G=e.fontFamily||"Inter",H=e.fontWeight||400;t.font=`${H} ${$}px "${G}", sans-serif`,t.fillStyle=D,t.textAlign="left",t.textBaseline=u?"top":"middle";const et=e.inputPadding??16,O=c.visible?(c.offset??16)+(c.size||14)/2+8:et,x=d.visible?(d.offset??16)+(d.size||14)/2+8:et,st=-(i/2)+O,Q=i-O-x,lt=e.inputType==="password"?"•".repeat(X.length):X;if(t.save(),t.beginPath(),t.rect(st-2,-n/2+4,Q+4,n-8),t.clip(),u){const z=lt.split(`
34
+ `);let nt=-n/2+et;const N=$*1.2;let pt=0;z.forEach((yt,dt)=>{const wt=yt.split(" ");let Pt="";for(let _t=0;_t<wt.length;_t++){const Ut=Pt+wt[_t]+" ";t.measureText(Ut).width>Q&&_t>0?(t.fillText(Pt,st,nt),Pt=wt[_t]+" ",nt+=N):Pt=Ut}t.fillText(Pt,st,nt),pt=t.measureText(Pt).width,dt<z.length-1&&(nt+=N,pt=0)}),a&&!L&&Math.floor(performance.now()/500)%2===0&&t.fillRect(st+pt,nt,1.5,$)}else{const nt=t.measureText(lt).width;let N=0;if(nt>Q&&(N=nt-Q),t.fillText(lt,st-N,0),a&&!L&&Math.floor(performance.now()/500)%2===0){const yt=st+nt-N;t.fillRect(yt,-($/2),1.5,$)}}if(t.restore(),f.visible!==!1){const z=f.text||"Label",nt=f.fontSize||12,N=f.color||"rgba(156, 163, 175, 1)",pt=f.offset??8;t.font=`600 ${nt}px "${G}", sans-serif`,t.fillStyle=N,t.textAlign="left",t.textBaseline="bottom";const yt=-(i/2),dt=-(n/2)-pt;t.fillText(z,yt,dt)}if(p.visible===!0){const z=p.text||"Helper text",nt=p.fontSize||11,N=h==="error"?"rgba(239, 68, 68, 1)":p.color||"rgba(156, 163, 175, 1)",pt=p.offset??6;t.font=`400 ${nt}px "${G}", sans-serif`,t.fillStyle=N,t.textAlign="left",t.textBaseline="top";const yt=-(i/2),dt=n/2+pt;t.fillText(z,yt,dt)}}renderSlider(t,s){const o=this.objectStates.get(s.id),e=(o==null?void 0:o.geometry)||s.geometry,i=(o==null?void 0:o.options)||s.options||{},n=e.width||200,a=i.value??50,r=i.min??0,h=(i.max??100)-r,f=h===0?0:(a-r)/h,p=i.trackHeight||4,c=i.trackRoundedness??2,d=i.trackShape??"Rectangle",u=i.trackPath||"",g=i.accentColor||"#3b82f6",y=i.inactiveColor||"#374151",b=i.thumbShape||"Ellipse",v=i.thumbWidth??16,S=i.thumbHeight??16,C=i.thumbRoundedness??0,w=i.thumbColor||"#ffffff",M=i.thumbPath||"",I=i.thumbIcon||"",k=i.showValueTooltip??!1,P=i.tooltipBgColor||"#333333",E=i.tooltipColor||"#ffffff",_=i.tooltipOffsetX??0,T=i.tooltipOffsetY??-25,A=(Q,lt,F,W,z,nt,N)=>{if((Q==="Custom"||Q==="Icon")&&N)try{const pt=new Path2D(N);if(t.save(),t.translate(lt,F),Q==="Icon"){const yt=Math.min(W,z)/24;t.scale(yt,yt),t.translate(-12,-12)}t.fill(pt),t.restore();return}catch(pt){console.error("Error drawing slider shape in engine:",pt)}if(t.beginPath(),Q==="Ellipse")t.ellipse(lt,F,W/2,z/2,0,0,Math.PI*2);else if(Q==="Rectangle")this.drawRoundRect(t,lt-W/2,F-z/2,W,z,nt);else if(Q==="Triangle")t.moveTo(lt,F-z/2),t.lineTo(lt+W/2,F+z/2),t.lineTo(lt-W/2,F+z/2),t.closePath();else if(Q==="Diamond")t.moveTo(lt,F-z/2),t.lineTo(lt+W/2,F),t.lineTo(lt,F+z/2),t.lineTo(lt-W/2,F),t.closePath();else if(Q==="Polygon"){const pt=s.geometry.sides||3,yt=s.geometry.radius||Math.min(W,z)/2;for(let dt=0;dt<pt;dt++){const wt=dt*2*Math.PI/pt-Math.PI/2,Pt=lt+yt*Math.cos(wt),_t=F+yt*Math.sin(wt);dt===0?t.moveTo(Pt,_t):t.lineTo(Pt,_t)}t.closePath()}else if(Q==="Star"){const yt=Math.min(W,z)/2,dt=yt/2;for(let wt=0;wt<10;wt++){const Pt=wt%2===0?yt:dt,_t=wt*Math.PI/5-Math.PI/2;t.lineTo(lt+Pt*Math.cos(_t),F+Pt*Math.sin(_t))}t.closePath()}else Q==="Line"&&(t.moveTo(lt-W/2,F),t.lineTo(lt+W/2,F));t.fill()},L=this.createCanvasFill(t,y,n,p);L&&(t.fillStyle=L,t.strokeStyle=L),d==="Line"?(t.lineWidth=p,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(n/2,0),t.stroke()):A(d,0,0,n,p,c,u);const X=n-v,D=-n/2+v/2+f*X,$=D- -n/2;if($>0){const Q=this.createCanvasFill(t,g,n,p);Q&&(t.fillStyle=Q,t.strokeStyle=Q),d==="Line"?(t.lineWidth=p,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(D,0),t.stroke()):d==="Rectangle"&&(t.beginPath(),this.drawRoundRect(t,-n/2,-p/2,$,p,c),t.fill())}t.save(),t.translate(D,0);const G=t.getTransform(),H=Math.sqrt(G.a*G.a+G.b*G.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*H,t.shadowOffsetY=1*H;const et=this.createCanvasFill(t,w,v,S);if(et&&(t.fillStyle=et),A(b,0,0,v,S,C,b==="Icon"?I:M),t.restore(),k){t.save(),t.translate(D+_,T);const Q=Math.round(a).toString();t.font="10px Inter, sans-serif";const lt=t.measureText(Q),F=6,W=4,z=lt.width+F*2,nt=14+W;t.beginPath(),this.drawRoundRect(t,-z/2,-nt/2,z,nt,4),t.fillStyle=P,t.fill(),t.fillStyle=E,t.textAlign="center",t.textBaseline="middle",t.fillText(Q,0,0),t.restore()}const O=i.label||{},x=i.helperText||{},st=i.fontFamily||"Inter";if(O.visible!==!1){const Q=O.text||"Label",lt=O.fontSize||12,F=O.color||"rgba(156, 163, 175, 1)",W=O.offset??8;t.font=`600 ${lt}px "${st}", sans-serif`,t.fillStyle=F,t.textAlign="left",t.textBaseline="bottom";const z=-(n/2),nt=-(p/2)-W;t.fillText(Q,z,nt)}if(x.visible===!0){const Q=x.text||"Helper text",lt=x.fontSize||11,F=x.color||"rgba(156, 163, 175, 1)",W=x.offset??6;t.font=`400 ${lt}px "${st}", sans-serif`,t.fillStyle=F,t.textAlign="left",t.textBaseline="top";const z=-(n/2),nt=p/2+W;t.fillText(Q,z,nt)}}renderDropdown(t,s){var T;const o=this.objectStates.get(s.id);if(!o)return;const e=o.options||s.options||{},i=s.geometry.width||160,n=s.geometry.height||40,a=-i/2,r=-n/2,l=e.corner_radius??6,h=e.disabled||e.previewState==="disabled",f=this.lastHoveredObjectId===s.id||e.previewState==="hover",p=(e.isOpen||e.previewState==="active")&&!h;let c=e.backgroundColor,d=e.borderColor,u=e.color||"#333333";h?(c=e.disabledBackgroundColor||"#f3f4f6",d=e.disabledBorderColor||"#e5e7eb",u=e.disabledColor||"#9ca3af"):p?(c=e.activeBackgroundColor||c,d=e.activeBorderColor||d,u=e.activeColor||u):f&&(c=e.hoverBackgroundColor||c,d=e.hoverBorderColor||d,u=e.hoverColor||u),c||(c="#ffffff"),d||(d="#e5e7eb");const g=t.globalAlpha;t.globalAlpha=g*(e.opacity??1),this.drawRoundRect(t,a,r,i,n,l),t.fillStyle=this.createCanvasFill(t,typeof c=="string"?{type:"Solid",color:c}:c,i,n)||"#ffffff",t.fill();const y=e.borderWidth??1;y>0&&(t.strokeStyle=this.createCanvasFill(t,typeof d=="string"?{type:"Solid",color:d}:d,i,n)||"#e5e7eb",t.lineWidth=y,t.stroke());const b=12,v=e.chevronType||"chevron",S=e.chevronSize||16,C=(p?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(v!=="none"){const A=a+i-b-S/2;t.save(),t.translate(A,0);const L=p?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(L*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(-S/2,-S*.2),t.lineTo(0,S*.2),t.lineTo(S/2,-S*.2),t.stroke();else if(v==="custom"||v==="path"){const X=p&&e.openIconPath||e.closedIconPath;if(X){const D=new Path2D(X);t.save();const $=S/24;t.scale($,$),t.translate(-12,-12),t.fill(D),t.restore()}}t.restore()}const w=e.selectedOption||e.placeholder||"Select...",M=e.fontSize||14,I=e.fontWeight||400,k=e.fontFamily||"Inter, sans-serif";t.font=`${I} ${M}px ${k}`;const P=h?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":u;t.fillStyle=this.createCanvasFill(t,typeof P=="string"?{type:"Solid",color:P}:P,i,n)||"#333333",t.textAlign="left",t.textBaseline="middle";const E=v==="none"?0:S+8,_=i-b*2-E;if(t.save(),t.beginPath(),t.rect(a+b,r,_,n),t.clip(),t.fillText(w,a+b,0),t.restore(),p&&!h){const A=r+n+4,L=e.optionsList||[],X=e.itemHeight||32,D=e.listPadding??4,$=L.length*X+D*2,G=e.listCornerRadius??l;t.save();const H=e.listShadow||{},et=t.getTransform(),O=Math.sqrt(et.a*et.a+et.b*et.b)||1;t.shadowColor=typeof H.color=="string"?H.color:((T=H.color)==null?void 0:T.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(H.blur??12)*O,t.shadowOffsetY=(H.offsetY??6)*O,t.shadowOffsetX=(H.offsetX??0)*O,t.beginPath(),this.drawRoundRect(t,a,A,i,$,G),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},i,$)||"#ffffff",t.fill();const x=e.listBorderWidth??1;x>0&&(t.shadowColor="transparent",t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:d},i,$)||"#e5e7eb",t.lineWidth=x,t.stroke()),t.restore();const st=e.itemFontSize||M,Q=e.itemFontFamily||k;t.font=`${I} ${st}px ${Q}`,L.forEach((lt,F)=>{const W=A+D+F*X;if(lt===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},i,X)||"#f3f4f6",t.fillRect(a+x,W,i-x*2,X),t.fillStyle=e.itemSelectedColor||e.accentColor||u||"#374151";else if(t.fillStyle=e.listTextColor||u||"#333333",this.activeDropdownId===s.id&&this._lastPointerPos){const nt=this._lastPointerPos.y-(A+D),N=Math.floor(nt/X);F===N&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},i,X)||"#f9fafb",t.fillRect(a+x,W,i-x*2,X),t.fillStyle=e.itemHoverColor||u)}t.fillText(lt,a+b,W+X/2)})}t.globalAlpha=g}renderButton(t,s){if(s.children&&s.children.length>0)return;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=s.geometry||{},n=i.width||120,a=i.height||40,r=this.lastHoveredObjectId===s.id,l=this.activeObjectId===s.id,h=e.label||{},f=e.hoverStyle||{},p=e.activeStyle||{},c=e.icon||{enabled:!1};let d=e.backgroundColor||"#3b82f6",u=h.color||"#ffffff",g=h.text||"Button",y=i.cornerRadius??8,b=e.borderColor||"transparent",v=e.borderWidth||0,S=1;l&&p?(d=p.backgroundColor||d,u=p.color||u,g=p.text||g,S=p.scale??.95,y=p.cornerRadius??y):r&&f&&(d=f.backgroundColor||d,u=f.color||u,g=f.text||g,S=f.scale??1,y=f.cornerRadius??y,b=f.borderColor||b);const C=-n/2,w=-a/2;t.save(),t.scale(S,S),t.beginPath(),this.drawRoundRect(t,C,w,n,a,y);const M=this.createCanvasFill(t,d,n,a);M&&(t.fillStyle=M,t.fill()),(v>0||r&&f.borderColor)&&(t.strokeStyle=b,t.lineWidth=v||(r?1:0),t.stroke());const I=h.fontSize||14,k=h.fontFamily||"Inter",P=h.fontWeight||600;t.font=`${P} ${I}px "${k}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=u,t.textAlign="center",t.textBaseline="middle";let E=0;if(c.enabled&&c.svgPath){const _=I*1.1,T=c.gap||8,A=t.measureText(g),X=-(A.width+_+T)/2,D=c.position==="left"?X+_/2:X+A.width+T+_/2;E=c.position==="left"?X+_+T+A.width/2:X+A.width/2,t.save(),t.translate(D,0);const $=new Path2D(c.svgPath),G=_/24;t.scale(G,G),t.translate(-12,-12),t.fillStyle=u,t.fill($),t.restore()}t.fillText(g,E,0),t.restore()}renderToggleButton(t,s){var g,y;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=e.checked??!1,n=((g=s.geometry)==null?void 0:g.width)||120,a=((y=s.geometry)==null?void 0:y.height)||40,r=-n/2,l=-a/2,h=e.corner_radius??8,f=e.label||{},p=i?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",c=i?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,r,l,n,a,h),t.fillStyle=p,t.fill();const d=f.fontSize||14,u=f.fontFamily||"Inter";t.font=`${f.fontWeight||600} ${d}px "${u}", sans-serif`,t.fillStyle=c,t.textAlign="center",t.textBaseline="middle",t.fillText(f.text||"Toggle",0,0),t.restore()}renderToggle(t,s){var G,H,et,O,x,st,Q,lt,F,W,z,nt;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((G=s.geometry)==null?void 0:G.width)||52,n=((H=s.geometry)==null?void 0:H.height)||30,a=-i/2,r=-n/2,l=e.checked??!1,h=e.cornerRadius??e.corner_radius??n/2,f=e.toggleStyle||{},p=f.backgroundColor||e.activeColor||"#10b981",c=f.borderColor||e.borderColor||"transparent",d=f.borderWidth??e.borderWidth??0,u=f.knobColor||e.knobColor||"#ffffff",g=l?p:e.inactiveColor||"#374151",y=l?c:e.borderColor||"transparent",b=l?d:e.borderWidth??0,v=l?u:e.knobColor||"#ffffff";e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,i,n,h);const S=this.createCanvasFill(t,g,i,n);if(S&&(t.fillStyle=S,t.fill()),b>0){t.lineWidth=b;const N=this.createCanvasFill(t,y,i,n);N&&(t.strokeStyle=N,t.stroke())}const C=2,w=n-C*2,M=w/2,I=a+C,k=a+i-C-w,P=l?k:I,E=r+C;t.beginPath(),t.arc(P+M,E+M,M,0,Math.PI*2);const _=this.createCanvasFill(t,v,w,w);_&&(t.fillStyle=_,t.fill()),e.disabled&&(t.globalAlpha*=2);let T=!1,A=!1;const L=(l?(et=f.leftLabel)==null?void 0:et.text:null)||((O=e.leftLabel)==null?void 0:O.text)||"",X=(l?(x=f.leftLabel)==null?void 0:x.color:null)||((st=e.leftLabel)==null?void 0:st.color)||"#f3f4f6";if((Q=e.leftLabel)!=null&&Q.enabled&&L){const N=e.leftLabel;t.font=`${N.fontWeight||400} ${N.fontSize||12}px "${N.fontFamily||"Inter"}", sans-serif`,t.fillStyle=X,t.textBaseline="middle",t.textAlign="right",t.fillText(L,a-(N.gap||8),0),T=!0}const D=(l?(lt=f.rightLabel)==null?void 0:lt.text:null)||((F=e.rightLabel)==null?void 0:F.text)||"",$=(l?(W=f.rightLabel)==null?void 0:W.color:null)||((z=e.rightLabel)==null?void 0:z.color)||"#f3f4f6";if((nt=e.rightLabel)!=null&&nt.enabled&&D){const N=e.rightLabel;t.font=`${N.fontWeight||400} ${N.fontSize||12}px "${N.fontFamily||"Inter"}", sans-serif`,t.fillStyle=$,t.textBaseline="middle",t.textAlign="left",t.fillText(D,a+i+(N.gap||8),0),A=!0}if(!T&&!A&&e.label&&e.label.text){const N=e.label,pt=N.fontSize||14,yt=N.fontWeight||400,dt=N.fontFamily||"Inter";t.font=`${yt} ${pt}px "${dt}", sans-serif`,t.fillStyle=N.color||"#f3f4f6",t.textBaseline="middle";const wt=N.gap||10;let Pt=0,_t=0;N.position==="left"?(t.textAlign="right",Pt=a-wt,_t=0):N.position==="right"?(t.textAlign="left",Pt=a+i+wt,_t=0):N.position==="top"?(t.textAlign="center",Pt=0,_t=r-wt,t.textBaseline="bottom"):N.position==="bottom"?(t.textAlign="center",Pt=0,_t=r+n+wt,t.textBaseline="top"):(t.textAlign="left",Pt=a+i+wt,_t=0),t.fillText(N.text,Pt,_t)}}renderCheckbox(t,s){var S,C;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((S=s.geometry)==null?void 0:S.width)||20,n=((C=s.geometry)==null?void 0:C.height)||20,a=-i/2,r=-n/2,l=e.cornerRadius??4,h=e.checked??!1,f=e.activeColor||"#3b82f6",p=e.inactiveColor||"transparent",c=e.checkColor||"#ffffff",d=e.borderColor||"#4b5563",u=e.borderWidth??2,g=h?f:p,y=h?"transparent":d,b=h?0:u;e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,i,n,l);const v=this.createCanvasFill(t,g,i,n);if(v&&(t.fillStyle=v,t.fill()),b>0){t.lineWidth=b;const w=this.createCanvasFill(t,y,i,n);w&&(t.strokeStyle=w,t.stroke())}else if(h){t.lineWidth=1;const w=this.createCanvasFill(t,f,i,n);w&&(t.strokeStyle=w,t.stroke())}if(h){t.save(),t.beginPath();const w=this.createCanvasFill(t,c,i,n);t.strokeStyle=w||c,t.lineWidth=Math.max(2,i*.12),t.lineCap="round",t.lineJoin="round";const M=a+i*.25,I=r+n*.5,k=a+i*.45,P=r+n*.7,E=a+i*.75,_=r+n*.25;t.moveTo(M,I),t.lineTo(k,P),t.lineTo(E,_),t.stroke(),t.restore()}if(e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const w=e.label;t.save(),t.font=`${w.fontWeight||400} ${w.fontSize||14}px "${w.fontFamily||"Inter"}", sans-serif`,t.fillStyle=w.color||"#f3f4f6",t.textBaseline="middle";const M=w.gap||8;let I=0,k=0;w.position==="left"?(t.textAlign="right",I=a-M,k=0):w.position==="right"?(t.textAlign="left",I=a+i+M,k=0):w.position==="top"?(t.textAlign="center",I=0,k=r-M,t.textBaseline="bottom"):w.position==="bottom"&&(t.textAlign="center",I=0,k=r+n+M,t.textBaseline="top"),t.fillText(w.text,I,k),t.restore()}}renderRadioGroup(t,s){var C,w;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((C=s.geometry)==null?void 0:C.width)||180,n=((w=s.geometry)==null?void 0:w.height)||100,a=-i/2,r=-n/2,l=e.selectedValue,h=e.optionsList||["Option 1","Option 2","Option 3"],f=e.orientation||"vertical",p=e.itemGap!==void 0?e.itemGap:16,c=e.activeColor||"#3b82f6",d=e.inactiveColor||"#4b5563",u=e.textColor||"#ffffff",g=e.fontSize||14,y=e.fontFamily||"Inter",b=e.fontWeight||400;e.disabled&&(t.globalAlpha*=.5);const v=8,S=v*2;if(t.save(),t.font=`${b} ${g}px "${y}", sans-serif`,t.textBaseline="middle",t.textAlign="left",f==="vertical"){const M=Math.max(S,g)+p;h.forEach((I,k)=>{const P=r+k*M+v;t.beginPath(),t.arc(a+v,P,v,0,Math.PI*2);const E=l===I,_=this.createCanvasFill(t,c,S,S),T=this.createCanvasFill(t,d,S,S);E?(t.strokeStyle=_||c,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(a+v,P,v/2,0,Math.PI*2),t.fillStyle=_||c,t.fill()):(t.strokeStyle=T||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(I,a+S+8,P)})}else{let M=a;h.forEach(I=>{const k=l===I,P=t.measureText(I).width;t.beginPath(),t.arc(M+v,0,v,0,Math.PI*2);const E=this.createCanvasFill(t,c,S,S),_=this.createCanvasFill(t,d,S,S);k?(t.strokeStyle=E||c,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(M+v,0,v/2,0,Math.PI*2),t.fillStyle=E||c,t.fill()):(t.strokeStyle=_||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(I,M+S+6,0),M+=S+6+P+p})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const M=e.label;t.save(),t.font=`${M.fontWeight||400} ${M.fontSize||14}px "${M.fontFamily||"Inter"}", sans-serif`,t.fillStyle=M.color||"#9ca3af",t.textBaseline="middle";const I=M.gap||8;let k=0,P=0;M.position==="left"?(t.textAlign="right",k=a-I,P=0):M.position==="right"?(t.textAlign="left",k=a+i+I,P=0):M.position==="top"?(t.textAlign="center",k=0,P=r-I,t.textBaseline="bottom"):M.position==="bottom"&&(t.textAlign="center",k=0,P=r+n+I,t.textBaseline="top"),t.fillText(M.text,k,P),t.restore()}}renderBarChart(t,s){var P,E;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i={width:((P=s.geometry)==null?void 0:P.width)||300,height:((E=s.geometry)==null?void 0:E.height)||180,chartType:e.chartType||"grouped",stylePreset:e.stylePreset||"default",datasets:e.datasets||[{id:"ds-1",label:"Revenue",data:[42,67,31,55,78,48],color:"#6366f1"}],categories:e.categories||["Jan","Feb","Mar","Apr","May","Jun"],orientation:e.orientation||"vertical",barWidth:e.barWidth!==void 0?e.barWidth:14,barGap:e.barGap!==void 0?e.barGap:4,barCornerRadius:e.barCornerRadius!==void 0?e.barCornerRadius:5,showXAxis:!!e.showXAxis,showYAxis:!!e.showYAxis,xAxisColor:e.xAxisColor||"rgba(255,255,255,0.12)",yAxisColor:e.yAxisColor||"rgba(255,255,255,0.12)",showXLabels:e.showXLabels!==void 0?!!e.showXLabels:!0,showYLabels:!!e.showYLabels,axisLabelColor:e.axisLabelColor||"rgba(255,255,255,0.5)",axisLabelFontSize:e.axisLabelFontSize||9,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.7)",legendFontSize:e.legendFontSize||9,showGridLines:e.showGridLines!==void 0?!!e.showGridLines:!0,gridColor:e.gridColor||"rgba(255,255,255,0.06)",cardBackground:e.cardBackground||"rgba(255,255,255,0.04)",cardBorderColor:e.cardBorderColor||"rgba(255,255,255,0.08)",barGradient:e.barGradient!==void 0?!!e.barGradient:!0,showValueOnTop:!!e.showValueOnTop,chartBackground:e.chartBackground||"transparent",barStyle:e.barStyle||"solid",barBorderWidth:e.barBorderWidth!==void 0?e.barBorderWidth:1,barBorderColor:e.barBorderColor||"auto",enableShadows:!!e.enableShadows,shadowColor:e.shadowColor||"rgba(0,0,0,0.5)",shadowBlur:e.shadowBlur!==void 0?e.shadowBlur:4,shadowOffsetY:e.shadowOffsetY!==void 0?e.shadowOffsetY:2,valueFontSize:e.valueFontSize||10,valueColor:e.valueColor||"auto",valueFontWeight:e.valueFontWeight||"bold",xAxisLineWidth:e.xAxisLineWidth!==void 0?e.xAxisLineWidth:1,yAxisLineWidth:e.yAxisLineWidth!==void 0?e.yAxisLineWidth:1,gridLineWidth:e.gridLineWidth!==void 0?e.gridLineWidth:1,gridLineDash:e.gridLineDash||[3,4],_getPreset:function(){return us[this.stylePreset]||us.default},_resolveColor:function(_,T){const A=this._getPreset();return["#6366f1","#f59e0b","#10b981","#3b82f6","#a855f7"].includes(_)?A.colors[T%A.colors.length]:typeof _=="string"?_:A.colors[T%A.colors.length]},_makeGradient:function(_,T,A,L,X,D){if(!this._getPreset().barGradient&&!this.barGradient)return T;const G=_.createLinearGradient(A,L,X,D);return G.addColorStop(0,T),G.addColorStop(1,T+"44"),G},_drawRoundedBar:function(_,T,A,L,X,D,$){if(D=Math.min(D,Math.min(Math.abs(L),Math.abs(X))/2),D<=0||L===0||X===0){_.rect(T,A,L,X);return}_.beginPath(),$?(_.moveTo(T,A+X),_.lineTo(T,A+D),_.quadraticCurveTo(T,A,T+D,A),_.lineTo(T+L-D,A),_.quadraticCurveTo(T+L,A,T+L,A+D),_.lineTo(T+L,A+X),_.lineTo(T,A+X)):(_.moveTo(T,A),_.lineTo(T+L-D,A),_.quadraticCurveTo(T+L,A,T+L,A+D),_.lineTo(T+L,A+X-D),_.quadraticCurveTo(T+L,A+X,T+L-D,A+X),_.lineTo(T,A+X),_.lineTo(T,A)),_.closePath()}},n=i.width,a=i.height,r=-n/2,l=-a/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}const h=i._getPreset();let f=-1/0,p=1/0;const c=i.categories.length,d=i.datasets.length;if(i.chartType==="stacked")for(let _=0;_<c;_++){let T=0,A=0;i.datasets.forEach(L=>{const X=L.data[_]??0;X>=0?T+=X:A+=X}),T>f&&(f=T),A<p&&(p=A)}else i.datasets.forEach(_=>{_.data&&_.data.forEach(T=>{T>f&&(f=T),T<p&&(p=T)})});isFinite(f)||(f=10),isFinite(p)||(p=0),f=Math.max(f,0),p=Math.min(p,0);const u=f-p||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 g=i.showYLabels?t.measureText(f.toFixed(0)).width+14:10,y=i.showXLabels?i.axisLabelFontSize+12:8,v=(i.showLegend&&d>0?i.legendFontSize+10:0)+8,S=10,C=r+g,w=l+v,M=n-g-S,I=a-v-y;if(i.enableShadows&&(t.shadowColor="transparent"),t.beginPath(),t.roundRect(r,l,n,a,10),t.fillStyle=h.cardBackground,t.fill(),t.strokeStyle=h.cardBorderColor,t.lineWidth=1,t.stroke(),i.chartBackground&&i.chartBackground!=="transparent"&&(t.beginPath(),t.rect(C,w,M,I),t.fillStyle=i.chartBackground,t.fill()),i.showLegend&&d>0){t.font=i.legendFontSize+"px Inter, sans-serif",t.textBaseline="middle";const _=l+12;let T=C;i.datasets.forEach((A,L)=>{const X=i._resolveColor(A.color,L),D=A.label||"Series "+(L+1),$=7;t.beginPath(),t.roundRect(T,_-$/2,$,$,2),t.fillStyle=X,t.fill(),t.fillStyle=h.legendColor,t.textAlign="left",t.fillText(D,T+$+4,_),T+=t.measureText(D).width+$+16})}const k=4;if(i.showGridLines){t.setLineDash(i.gridLineDash||[]),t.lineWidth=i.gridLineWidth||1,t.strokeStyle=h.gridColor;for(let _=0;_<=k;_++)if(i.orientation==="horizontal"){const T=C+_/k*M;t.beginPath(),t.moveTo(T,w),t.lineTo(T,w+I),t.stroke()}else{const T=w+_/k*I;t.beginPath(),t.moveTo(C,T),t.lineTo(C+M,T),t.stroke()}t.setLineDash([])}if(i.showYLabels){t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor;for(let _=0;_<=k;_++)if(i.orientation==="horizontal"){const T=p+_/k*u,A=C+_/k*M;t.textAlign="center",t.fillText(T.toFixed(0),A,w+I+i.axisLabelFontSize)}else{const T=f-_/k*u,A=w+_/k*I;t.textAlign="right",t.fillText(T.toFixed(0),C-6,A)}}if(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),i.chartType==="stacked")if(i.orientation==="horizontal"){const _=I/c;for(let T=0;T<c;T++){const A=w+T*_+_/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[T]||"",C-5,A),i.enableShadows&&(t.shadowColor=i.shadowColor));let L=C;i.datasets.forEach((X,D)=>{const $=X.data[T]??0;if($===0)return;const G=$/u*M,H=Math.min(i.barWidth*d+i.barGap,_-8),et=A-H/2,O=L;L+=G;const x=i._resolveColor(X.color,D);t.beginPath(),t.fillStyle=i._makeGradient(t,x,O,et,O+G,et),i._drawRoundedBar(t,O,et,G,H,D===d-1?i.barCornerRadius:0,!1),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?x:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else{const _=M/c;for(let T=0;T<c;T++){const A=C+T*_+_/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[T]||"",A,w+I+5),i.enableShadows&&(t.shadowColor=i.shadowColor));let L=w+I;i.datasets.forEach((X,D)=>{const $=X.data[T]??0;if($===0)return;const G=$/u*I,H=Math.min(i.barWidth*d+i.barGap,_-8),et=A-H/2,O=L-G;L-=G;const x=i._resolveColor(X.color,D);t.beginPath(),t.fillStyle=i._makeGradient(t,x,et,O,et,O+G),i._drawRoundedBar(t,et,O,H,G,D===d-1?i.barCornerRadius:0,!0),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?x:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else if(i.orientation==="horizontal"){const _=I/c,T=d*i.barWidth+Math.max(0,(d-1)*i.barGap),A=C+(0-p)/u*M;for(let L=0;L<c;L++){const X=w+L*_+_/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[L]||"",C-5,X),i.enableShadows&&(t.shadowColor=i.shadowColor));const D=X-T/2;i.datasets.forEach(($,G)=>{const H=$.data[L]??0,et=Math.abs(H/u*M);if(et<1)return;const O=D+G*(i.barWidth+i.barGap),x=H>=0?A:A-et,st=i._resolveColor($.color,G);t.beginPath(),t.fillStyle=i._makeGradient(t,st,x,O,x+et,O),i._drawRoundedBar(t,x,O,et,i.barWidth,i.barCornerRadius,!1),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?st:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),i.showValueOnTop&&H!==0&&(t.font=(i.valueFontWeight||"bold")+" "+(i.valueFontSize||10)+"px Inter, sans-serif",t.textAlign=H>=0?"left":"right",t.textBaseline="middle",t.fillStyle=i.valueColor==="auto"?st:i.valueColor||"#fff",t.shadowColor="transparent",t.fillText(H.toString(),H>=0?x+et+4:x-4,O+i.barWidth/2),i.enableShadows&&(t.shadowColor=i.shadowColor))})}}else{const _=M/c,T=d*i.barWidth+Math.max(0,(d-1)*i.barGap),A=w+I-(0-p)/u*I;for(let L=0;L<c;L++){const X=C+L*_+_/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[L]||"",X,w+I+5),i.enableShadows&&(t.shadowColor=i.shadowColor));const D=X-T/2;i.datasets.forEach(($,G)=>{const H=$.data[L]??0,et=Math.abs(H/u*I);if(et<1)return;const O=D+G*(i.barWidth+i.barGap),x=H>=0?A-et:A,st=i._resolveColor($.color,G);t.beginPath(),t.fillStyle=i._makeGradient(t,st,O,x,O,x+et),i._drawRoundedBar(t,O,x,i.barWidth,et,i.barCornerRadius,!0),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?st:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),i.showValueOnTop&&H!==0&&(t.font=(i.valueFontWeight||"bold")+" "+(i.valueFontSize||10)+"px Inter, sans-serif",t.textAlign="center",t.textBaseline=H>=0?"bottom":"top",t.fillStyle=i.valueColor==="auto"?st:i.valueColor||"#fff",t.shadowColor="transparent",t.fillText(H.toString(),O+i.barWidth/2,H>=0?x-4:x+et+4),i.enableShadows&&(t.shadowColor=i.shadowColor))})}}t.restore()}renderPieChart(t,s){var g,y;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i={width:((g=s.geometry)==null?void 0:g.width)||180,height:((y=s.geometry)==null?void 0:y.height)||180,chartType:e.chartType||"donut",stylePreset:e.stylePreset||"default",slices:e.slices||[{id:"slice-1",label:"Item 1",value:45,color:"#6366f1"}],innerRadius:e.innerRadius!==void 0?e.innerRadius:.55,sliceGap:e.sliceGap!==void 0?e.sliceGap:3,showLabels:!!e.showLabels,labelColor:e.labelColor||"#ffffff",labelFontSize:e.labelFontSize||10,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.65)",legendFontSize:e.legendFontSize||9,showCenterText:e.showCenterText!==void 0?!!e.showCenterText:!0,centerLabel:e.centerLabel||"Total",centerTextColor:e.centerTextColor||"#ffffff",centerLabelColor:e.centerLabelColor||"rgba(255,255,255,0.4)",_getPreset:function(){return gs[this.stylePreset]||gs.default},_resolveSliceColor:function(b,v){const S=b.color,C=v,w=this._getPreset();return["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399","#a855f7","#f87171"].includes(S)?w.colors[C%w.colors.length]:typeof S=="string"?S:w.colors[C%w.colors.length]}},n=i.width,a=i.height;if(!i.slices||i.slices.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO PIE DATA",0,0),t.restore();return}const r=i.slices.reduce((b,v)=>b+(v.value||0),0);if(r<=0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("EMPTY DATA",0,0),t.restore();return}const l=i._getPreset();t.save(),t.beginPath(),t.roundRect(-n/2,-a/2,n,a,10),t.fillStyle=l.cardBackground,t.fill(),t.strokeStyle=l.cardBorderColor,t.lineWidth=1,t.stroke();const h=i.showLegend?Math.ceil(i.slices.length/2):0,f=h>0?h*(i.legendFontSize+8)+10:0,p=a-f-16,c=Math.min(n-24,p)/2,d=0,u=-f/2;if(i.chartType==="rose"){const b=Math.max(...i.slices.map(C=>C.value||0)),v=Math.PI*2/i.slices.length,S=c>0?i.sliceGap/c:0;i.slices.forEach((C,w)=>{const M=C.value||0;if(M===0)return;const I=M/b*c,k=-Math.PI/2+w*v+S/2,P=k+v-S,E=i._resolveSliceColor(C,w);if(t.beginPath(),t.moveTo(d,u),t.arc(d,u,I,k,P),t.closePath(),t.fillStyle=E+"cc",t.fill(),t.strokeStyle=E,t.lineWidth=1.5,t.stroke(),i.showLabels){const _=k+(P-k)/2,T=d+I*.65*Math.cos(_),A=u+I*.65*Math.sin(_),L=Math.round(M/r*100);t.save(),t.font=`bold ${i.labelFontSize}px Inter, sans-serif`,t.fillStyle=l.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${L}%`,T,A),t.restore()}})}else{const b=i.chartType==="pie"?0:i.innerRadius,v=c*Math.max(0,b),S=c>0?i.sliceGap/c:0;let C=-Math.PI/2;if(i.slices.forEach((w,M)=>{const I=w.value||0;if(I===0){C+=I/r*Math.PI*2;return}const k=I/r*Math.PI*2,P=C+S/2,E=C+k-S/2;if(E<=P){C+=k;return}const _=i._resolveSliceColor(w,M);if(t.beginPath(),t.fillStyle=_,v<=0?(t.moveTo(d,u),t.arc(d,u,c,P,E),t.lineTo(d,u)):(t.moveTo(d+c*Math.cos(P),u+c*Math.sin(P)),t.arc(d,u,c,P,E),t.arc(d,u,v,E,P,!0),t.closePath()),t.fill(),i.showLabels){const T=P+(E-P)/2,A=v+(c-v)/2,L=d+A*Math.cos(T),X=u+A*Math.sin(T),D=Math.round(I/r*100);t.save(),t.font=`bold ${i.labelFontSize}px Inter, sans-serif`,t.fillStyle=l.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${D}%`,L,X),t.restore()}C+=k}),i.chartType==="donut"&&i.showCenterText&&v>14){const w=Math.round(r),M=Math.min(Math.floor(v*.52),20),I=Math.min(Math.floor(v*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${M}px Inter, sans-serif`,t.fillStyle=l.centerTextColor,t.fillText(w.toString(),d,u-I*.5),i.centerLabel&&(t.font=`${I}px Inter, sans-serif`,t.fillStyle=l.centerLabelColor,t.fillText(i.centerLabel,d,u+M*.6))}}if(i.showLegend&&i.slices.length>0){t.font=`${i.legendFontSize}px Inter, sans-serif`;const b=2,v=n/b,S=i.legendFontSize+8,C=a/2-f+10,w=-n/2+10;i.slices.forEach((M,I)=>{const k=I%b,P=Math.floor(I/b),E=w+k*v,_=C+P*S,T=i._resolveSliceColor(M,I),A=7;t.beginPath(),t.roundRect(E,_-A/2,A,A,2),t.fillStyle=T,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=l.legendColor;const L=Math.round((M.value||0)/r*100),X=`${M.label||"Item"} ${L}%`,D=v-A-20;let $=X;for(;t.measureText($).width>D&&$.length>4;)$=$.slice(0,-4)+"…";t.fillText($,E+A+4,_)})}t.restore()}renderJoystick(t,s){var u,g,y,b,v;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.width)!==void 0?o.width:((u=s.geometry)==null?void 0:u.width)??s.width??100,i=(o==null?void 0:o.height)!==void 0?o.height:((g=s.geometry)==null?void 0:g.height)??s.height??100,n=Math.min(e,i)*.45,a=Math.min(e,i)*.15;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 h=0,f=0;s.handleOrigin==="top-left"?(h=e/2,f=i/2):s.handleOrigin==="bottom-right"&&(h=-e/2,f=-i/2),t.translate(h,f),t.beginPath(),s.boundsShape==="square"?t.rect(-n,-n,n*2,n*2):t.arc(0,0,n,0,Math.PI*2),t.fillStyle="rgba(0,0,0,0.2)",(y=s.style)!=null&&y.fill&&typeof s.style.fill=="string"?t.fillStyle=s.style.fill:(b=s.style)!=null&&b.fill&&s.style.fill.type==="solid"&&(t.fillStyle=s.style.fill.color),t.fill(),(v=s.style)!=null&&v.stroke&&s.style.stroke.isEnabled!==!1&&(t.lineWidth=s.style.stroke.width||1,t.strokeStyle=s.style.stroke.color||"#000",t.stroke());const p=n-a;let c=0,d=0;s.joystickType==="2D"?(c=r*p,d=l*p):s.joystickType==="1D_X"?(c=r*p,d=0):s.joystickType==="1D_Y"&&(c=0,d=l*p),t.beginPath(),t.arc(c,d,a,0,Math.PI*2),t.fillStyle="#fff",t.fill(),t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1,t.stroke(),t.restore()}getRadioGroupItemIndexAtPointer(t,s,o){var I,k;const e=t.options||{},i=this.objectStates.get(t.id)||{},n=e.optionsList||[];if(n.length===0)return null;const a=i.width!==void 0?i.width:((I=t.geometry)==null?void 0:I.width)||180,r=i.height!==void 0?i.height:((k=t.geometry)==null?void 0:k.height)||100,l=e.orientation||"vertical",h=e.itemGap!==void 0?e.itemGap:16,f=e.fontSize||14,p=this.getWorldTransform(t.id),c=s-p.x,d=o-p.y,u=-p.rotation*(Math.PI/180),g=Math.cos(u),y=Math.sin(u),b=c*g-d*y,v=c*y+d*g,C=8*2,w=-a/2,M=-r/2;if(l==="vertical"){const P=Math.max(C,f)+h;for(let E=0;E<n.length;E++){const _=M+E*P;if(b>=w&&b<=w+a&&v>=_&&v<=_+P)return E}}else{let P=w;for(let E=0;E<n.length;E++){const T=n[E].length*8,A=C+6+T+h;if(b>=P&&b<=P+A&&v>=M&&v<=M+r)return E;P+=A}}return null}renderLineGraph(t,s,o,e){let i=s.datasets||[];if((!i||i.length===0)&&(s.data||s.graphData)&&(i=[{id:"line-1",label:"Series 1",data:s.data||s.graphData||[],lineColor:s.lineColor||"#3b82f6",lineWidth:s.lineWidth||2,showArea:s.showArea||!1,areaColor:s.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:s.smoothing||!1,showPoints:s.showPoints!==void 0?s.showPoints:!0,pointSize:s.pointSize||6,pointFill:s.pointFill||"#ffffff",pointStrokeColor:s.pointStrokeColor||s.lineColor||"#3b82f6",pointStrokeWidth:s.pointStrokeWidth||2}]),!i||i.length===0||!i.some(u=>u.data&&u.data.length>=2)){t.save(),t.fillStyle="#6366f1",t.font="12px Inter, system-ui, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO DATA",0,0),t.restore();return}let n=1/0,a=-1/0,r=0;if(i.forEach(u=>{let g=u.data;if(u.isVarEnabled&&u.inputId){let y=this.inputs.get(u.inputId);if(y===void 0){const b=this.inputNameMap.get(u.inputId);b&&b.length>0&&(y=this.inputs.get(b[0]))}y&&Array.isArray(y)&&(g=y)}if(g&&g.length>0){const y=g.filter(b=>typeof b=="number"&&!isNaN(b));y.length>0&&(n=Math.min(n,...y),a=Math.max(a,...y),r=Math.max(r,g.length))}u._resolvedData=g}),r<2)return;const l=a-n,h=o/(r-1),f=u=>{const g=l===0?.5:(u-n)/l;return e/2-g*e},p=u=>u*h-o/2,c=s.axisColor||"#333333";if(s.showXAxis&&(t.beginPath(),t.strokeStyle=s.xAxisColor||c,t.lineWidth=1,t.moveTo(-o/2,e/2),t.lineTo(o/2,e/2),t.stroke()),s.showYAxis&&(t.beginPath(),t.strokeStyle=s.yAxisColor||c,t.lineWidth=1,t.moveTo(-o/2,-e/2),t.lineTo(-o/2,e/2),t.stroke()),t.fillStyle=s.axisLabelColor||"#333333",t.font=`${s.axisLabelFontSize||10}px Inter, sans-serif`,s.showXLabels){t.textAlign="center",t.textBaseline="top";for(let u=0;u<r;u++){const g=p(u);t.fillText(`${u+1}`,g,e/2+5)}}if(s.showYLabels){t.textAlign="right",t.textBaseline="middle";const u=-o/2-5,g=(a+n)/2;t.fillText(a.toFixed(1),u,f(a)),t.fillText(g.toFixed(1),u,f(g)),t.fillText(n.toFixed(1),u,f(n))}const d=10;if(i.forEach(u=>{const g=u._resolvedData;if(!(!g||g.length<2)){if(u.showArea){if(t.beginPath(),t.moveTo(p(0),e/2),t.lineTo(p(0),f(g[0])),u.smoothing&&g.length>2)for(let b=0;b<g.length-1;b++){const v=g[b===0?b:b-1],S=g[b],C=g[b+1],w=g[b+1===g.length-1?b+1:b+2];for(let M=1;M<=d;M++){const I=M/d,k=this._catmullRom(v,S,C,w,I);t.lineTo(p(b+I),f(k))}}else for(let b=1;b<g.length;b++)t.lineTo(p(b),f(g[b]));t.lineTo(p(g.length-1),e/2),t.closePath();const y=t.globalAlpha;t.globalAlpha=y*(s.areaOpacity??.3),t.fillStyle=u.areaColor||"rgba(139, 92, 246, 0.2)",t.fill(),t.globalAlpha=y}if(t.beginPath(),t.strokeStyle=u.lineColor||"#3b82f6",t.lineWidth=u.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.moveTo(p(0),f(g[0])),u.smoothing&&g.length>2)for(let y=0;y<g.length-1;y++){const b=g[y===0?y:y-1],v=g[y],S=g[y+1],C=g[y+1===g.length-1?y+1:y+2];for(let w=1;w<=d;w++){const M=w/d,I=this._catmullRom(b,v,S,C,M);t.lineTo(p(y+M),f(I))}}else for(let y=1;y<g.length;y++)t.lineTo(p(y),f(g[y]));t.stroke(),u.showPoints&&g.forEach((y,b)=>{const v=p(b),S=f(y);t.beginPath(),t.arc(v,S,(u.pointSize||6)/2,0,Math.PI*2),t.fillStyle=u.pointFill||"#ffffff",t.fill(),t.strokeStyle=u.pointStrokeColor||u.lineColor||"#3b82f6",t.lineWidth=u.pointStrokeWidth||1,t.stroke()})}}),s.showLegend&&i.length>0){const u=o/2-10;let g=-e/2+15;const y=s.legendFontSize||10,b=y+5;t.font=`${y}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",i.forEach(v=>{const C=v.label||"Series",w=t.measureText(C).width;t.beginPath(),t.rect(u-w-8-5,g-(8/2+2),8,8),t.fillStyle=v.lineColor||"#3b82f6",t.fill(),t.fillStyle=s.legendColor||"#333333",t.fillText(C,u,g),g+=b})}}_catmullRom(t,s,o,e,i){const n=(o-t)*.5,a=(e-s)*.5,r=i*i,l=i*r;return(2*s-2*o+n+a)*l+(-3*s+3*o-2*n-a)*r+n*i+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 i,n,a;if(!s||s.type==="None")return null;if(typeof s=="string")return s;if(s.type==="Solid"&&s.color){const r=s.color,h=(((n=(i=this.artboard)==null?void 0:i.tokens)==null?void 0:n.colors)||{})[r]||r;return t.fillStyle=h,h}if((s.type==="LinearGradient"||s.type==="RadialGradient"||s.type==="AngularGradient"||s.type==="DiamondGradient")&&s.stops){const r=(l,h=100)=>{var S,C;const p=(((C=(S=this.artboard)==null?void 0:S.tokens)==null?void 0:C.colors)||{})[l]||l,c=this.normalizeOpacity(s.opacity??100),u=this.normalizeOpacity(h)*c;if(u>=1&&p.startsWith("#"))return p;const g=p.startsWith("#")?p.replace("#",""):"ffffff",y=parseInt(g.substring(0,2),16),b=parseInt(g.substring(2,4),16),v=parseInt(g.substring(4,6),16);return`rgba(${y}, ${b}, ${v}, ${u})`};if(s.type==="LinearGradient"){const l=(u,g,y)=>Array.isArray(u)?u[g]??(g===0?0:1):u&&typeof u=="object"?u[y]??(g===0?0:1):g===0?0:1,h=l(s.start,0,"x")*o-o/2,f=l(s.start,1,"y")*e-e/2,p=l(s.end,0,"x")*o-o/2,c=l(s.end,1,"y")*e-e/2,d=t.createLinearGradient(h,f,p,c);if(s.stops.forEach(u=>{const g=u.offset!==void 0?u.offset:u.pos!==void 0?u.pos:u.position!==void 0?u.position:0,y=r(u.color||"#000000",u.opacity??100);d.addColorStop(Math.max(0,Math.min(1,g)),y)}),s.gradientTransform&&d.setTransform){const[u,g,y,b,v,S]=s.gradientTransform;d.setTransform({a:u,b:g,c:y,d:b,e:v,f:S})}return d}else if(s.type==="RadialGradient"){const l=(d,u,g)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[g]??.5:.5,h=l(s.center,0,"x")*o-o/2,f=l(s.center,1,"y")*e-e/2,p=(s.radius??.5)*Math.max(o,e),c=t.createRadialGradient(h,f,0,h,f,p);if(s.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,g=r(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,u)),g)}),s.gradientTransform&&c.setTransform){const[d,u,g,y,b,v]=s.gradientTransform;c.setTransform({a:d,b:u,c:g,d:y,e:b,f:v})}return c}else if(s.type==="AngularGradient"){const l=(d,u,g)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[g]??.5:.5,h=l(s.center||[.5,.5],0,"x")*o-o/2,f=l(s.center||[.5,.5],1,"y")*e-e/2,p=(s.degree||s.angle||0)*(Math.PI/180),c=(a=t.createConicGradient)==null?void 0:a.call(t,p,h,f);if(c){if(s.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,g=r(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,u)),g)}),s.gradientTransform&&c.setTransform){const[d,u,g,y,b,v]=s.gradientTransform;c.setTransform({a:d,b:u,c:g,d:y,e:b,f:v})}return c}}else if(s.type==="DiamondGradient"){const l=(d,u,g)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[g]??.5:.5,h=l(s.center||[.5,.5],0,"x")*o-o/2,f=l(s.center||[.5,.5],1,"y")*e-e/2,p=(s.radius??.5)*Math.max(o,e);t.save(),t.translate(h,f),t.rotate(Math.PI/4);const c=t.createRadialGradient(0,0,0,0,0,p);if(s.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,g=r(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,u)),g)}),s.gradientTransform&&c.setTransform){const[d,u,g,y,b,v]=s.gradientTransform;c.setTransform({a:d,b:u,c:g,d:y,e:b,f:v})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=c,t.restore(),c}}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 h=new DOMMatrix,f=s.scaleX??1,p=s.scaleY??1,c=s.offsetX??0,d=s.offsetY??0,u=s.rotation??0;h.translateSelf(c,d),h.rotateSelf(u),h.scaleSelf(f,p),l.setTransform(h)}return l}}return s.color||null}drawRoundRect(t,s,o,e,i,n){if(n===0||n===void 0||n===null){t.rect(s,o,e,i);return}let a=n;if(typeof a=="string")try{a=JSON.parse(a)}catch{a=parseFloat(a)||0}let r=0,l=0,h=0,f=0;typeof a=="number"?r=l=h=f=a:Array.isArray(a)?a.length===1?r=l=h=f=a[0]:a.length===2?(r=h=a[0],l=f=a[1]):a.length===3?(r=a[0],l=f=a[1],h=a[2]):a.length>=4&&(r=a[0],l=a[1],h=a[2],f=a[3]):a&&typeof a=="object"&&(r=a.tl??a.corner_radius??a.cornerRadius??0,l=a.tr??a.corner_radius??a.cornerRadius??0,h=a.br??a.corner_radius??a.cornerRadius??0,f=a.bl??a.corner_radius??a.cornerRadius??0);const p=Math.min(Math.abs(e)/2,Math.abs(i)/2);if(r=Math.min(Math.max(0,r),p),l=Math.min(Math.max(0,l),p),h=Math.min(Math.max(0,h),p),f=Math.min(Math.max(0,f),p),t.roundRect){t.roundRect(s,o,e,i,[r,l,h,f]);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+i-h),t.arcTo(s+e,o+i,s+e-h,o+i,h),t.lineTo(s+f,o+i),t.arcTo(s,o+i,s,o+i-f,f),t.lineTo(s,o+r),t.arcTo(s,o,s+r,o,r),t.closePath()}renderListView(t,s){var L,X,D,$;const o=this.objectStates.get(s.id)||{},e=o.options||s.options||{},i=o.width!==void 0?o.width:((L=s.geometry)==null?void 0:L.width)||200,n=o.height!==void 0?o.height:((X=s.geometry)==null?void 0:X.height)||300,a=-i/2,r=-n/2,l=o.corner_radius!==void 0?o.corner_radius:e.corner_radius??0,h=e.orientation||"vertical",f=e.items||[],p=e.itemGap??10,c=e.itemHeight??50,d=e.itemWidth??200,u=e.scrollOffset??0,g=e.padding??0,y=e.glassEffect!==!1,b=e.accentColor||"#3b82f6",v=e.itemTextColor||"#333333",S=e.itemBackgroundColor||"#ffffff",C=e.hoveredIndex??null,w=e.activeItemIndex??null,M=e.glowIntensity??0,I=e.glowColor||"#3b82f6",k=typeof I=="string"?I:I.color||(($=(D=I.stops)==null?void 0:D[0])==null?void 0:$.color)||"#3b82f6",P=e.opacity!==void 0?e.opacity:s.opacity!==void 0?s.opacity:1;if(t.save(),t.globalAlpha*=P,M>0){const G=t.getTransform(),H=Math.sqrt(G.a*G.a+G.b*G.b)||1;t.shadowColor=k,t.shadowBlur=M*2*H,t.shadowOffsetX=0,t.shadowOffsetY=0}if(y){const G=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",H=this.createCanvasFill(t,G,i,n);t.fillStyle=H||"rgba(31, 41, 55, 0.4)",t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,i,n,l)||t.fill();const O=t.createLinearGradient(a,r,a+i,r+n);O.addColorStop(0,"rgba(255, 255, 255, 0.15)"),O.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),O.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=O,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,i,n,l)||t.fill(),t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,i,n,l)||t.stroke()}else{const G=e.backgroundColor||e.listBackgroundColor||"transparent",H=this.createCanvasFill(t,G,i,n);if(H){t.fillStyle=H,t.beginPath();const O=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,i,n,l);t.fill()}const et=e.borderWidth??0;if(et>0){t.strokeStyle=e.borderColor||"#cccccc",t.lineWidth=et,t.beginPath();const O=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,i,n,l);t.stroke()}}t.shadowBlur=0,t.save(),t.beginPath();const E=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,i,n,l);if(e.listLayout!=="circular")if(E&&e.containerShape==="custom")try{const G=new Path2D(e.containerPath);t.translate(a,r),t.scale(i/100,n/100),t.clip(G),t.scale(100/i,100/n),t.translate(-a,-r)}catch{}else t.clip();const _=typeof g=="number"?g:h==="vertical"?g[0]:g[3];let T=(h==="vertical"?r:a)+u+_;if(t.textBaseline="middle",f.forEach((G,H)=>{const et=e.listLayout||"linear",O=et==="circular"?d:h==="vertical"?i:d,x=et==="circular"||h==="vertical"?c:n;let st=0,Q=0,lt=0;if(et==="circular"){const _t=f.length||1,Ut=Math.PI*2/_t,j=e.circularStartAngle||0,gt=e.circularRadius||100,Rt=u*.01+j*Math.PI/180,It=H*Ut+Rt,bt=a+i/2,Ft=r+n/2;st=bt+Math.cos(It)*gt-O/2,Q=Ft+Math.sin(It)*gt-x/2,lt=It+(e.itemRotation||0)*Math.PI/180}else st=h==="vertical"?a:T,Q=h==="vertical"?T:r,lt=(e.itemRotation||0)*Math.PI/180;const F=C===H,W=w===H,z=W&&e.activeItemShape?e.activeItemShape:e.itemShape||"rectangle",nt=W&&e.activeItemShape?e.activeItemPath:e.itemPath||"",N=e.itemCornerRadius||0;if(t.save(),lt!==0&&(t.translate(st+O/2,Q+x/2),t.rotate(lt),t.translate(-(st+O/2),-(Q+x/2))),W){const _t=this.createCanvasFill(t,b,O,x);t.fillStyle=_t||b;const Ut=t.globalAlpha;t.globalAlpha=Ut*.8,t.beginPath(),this.drawCustomShape(t,z,nt,st,Q,O,x,N)||(t.rect(st,Q,O,x),t.fill()),t.globalAlpha=Ut}else if(F)t.fillStyle=y?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",t.beginPath(),this.drawCustomShape(t,z,nt,st,Q,O,x,N)||(t.rect(st,Q,O,x),t.fill());else if(S!=="transparent"){const _t=this.createCanvasFill(t,S,O,x);t.fillStyle=_t||S,t.beginPath(),this.drawCustomShape(t,z,nt,st,Q,O,x,N)||(t.rect(st,Q,O,x),t.fill())}if(W||F){const _t=this.createCanvasFill(t,b,h==="vertical"?3:O,h==="vertical"?x:3);t.fillStyle=_t||b,h==="vertical"?t.fillRect(st,Q,3,x):t.fillRect(st,Q+x-3,O,3)}const pt=W?"#ffffff":y?"rgba(255, 255, 255, 0.9)":v;t.fillStyle=pt,t.font=W||F?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const yt=typeof G=="string"?G:(G==null?void 0:G.label)||`Item ${H+1}`,dt=st+(h==="vertical"?16:O/2),wt=Q+x/2;h==="horizontal"||et==="circular"?t.textAlign="center":t.textAlign="left";const Pt=et==="circular"?st+O/2:dt;t.fillText(yt,Pt,wt),t.restore(),T+=(h==="vertical"?c:d)+p}),t.restore(),e.showScrollbar!==!1){const G=(f.length||0)*(h==="vertical"?c:d)+((f.length||0)-1)*p,H=h==="vertical"?n:i,et=e.listLayout||"linear",O=e.containerShape==="circle"||et==="circular";if(G>H||et==="circular"&&f.length>0){const x=e.scrollbarColor||"rgba(255,255,255,0.3)",st=e.scrollbarWidth||4;if(O){const Q=Math.min(i,n)/2-st/2-2,lt=a+i/2,F=r+n/2;if(t.strokeStyle=x,t.lineWidth=st,t.lineCap="round",t.beginPath(),et==="circular"){const W=Math.PI/4,z=-(u*.01)-Math.PI/2;t.arc(lt,F,Q,z,z+W)}else{const W=Math.PI/2,z=H/G,nt=W*z,N=-u/G*W,yt=-Math.PI/4+N;t.arc(lt,F,Q,yt,yt+nt)}t.stroke()}else{const Q=H/G,lt=H*Q,F=-u/G*H;t.fillStyle=x,h==="vertical"?t.fillRect(a+i-st-2,r+F,st,lt):t.fillRect(a+F,r+n-st-2,lt,st)}}}t.restore()}drawCustomShape(t,s,o,e,i,n,a,r){if(s==="circle"){const l=Math.min(n,a)/2;return t.arc(e+n/2,i+a/2,l,0,Math.PI*2),!1}else if(s==="pill"){const l=Math.min(n,a)/2;return this.drawListViewRect(t,e,i,n,a,l),!1}else if(s==="custom"&&o)try{const l=new Path2D(o);return t.save(),t.translate(e,i),t.scale(n/100,a/100),t.fill(l),t.restore(),!0}catch{return this.drawListViewRect(t,e,i,n,a,r),!1}return this.drawListViewRect(t,e,i,n,a,r),!1}updateListViewScrollFromPointer(t){var y,b;if(!this._lastPointerPos||!this._prevPointerPos)return;const s=t.options||{},o=s.orientation||"vertical",e=this._lastPointerPos.x-this._prevPointerPos.x,i=this._lastPointerPos.y-this._prevPointerPos.y;o==="vertical"?s.scrollOffset=(s.scrollOffset||0)+i:s.scrollOffset=(s.scrollOffset||0)+e;const n=s.listLayout||"linear",a=this.objectStates.get(t.id)||{},r=s.items||[],l=s.itemGap??10,h=s.itemHeight??50,f=s.itemWidth??200,p=a.width!==void 0?a.width:((y=t.geometry)==null?void 0:y.width)||200,c=a.height!==void 0?a.height:((b=t.geometry)==null?void 0:b.height)||300;if(n==="circular")return;const d=(r.length||0)*(o==="vertical"?h:f)+((r.length||0)-1)*l,g=Math.max(0,d-(o==="vertical"?c:p)+(s.padding*2||0));s.scrollOffset>0&&(s.scrollOffset=0),s.scrollOffset<-g&&(s.scrollOffset=-g)}updateListViewHoverFromPointer(t,s,o){const e=this.getListViewItemIndexAtPointer(t,s,o),i=t.options||{};i.hoveredIndex!==e&&(i.hoveredIndex=e)}getListViewItemIndexAtPointer(t,s,o){var D,$;const e=t.options||{},i=this.objectStates.get(t.id)||{},n=e.items||[];if(n.length===0)return null;const a=i.width!==void 0?i.width:((D=t.geometry)==null?void 0:D.width)||200,r=i.height!==void 0?i.height:(($=t.geometry)==null?void 0:$.height)||300,l=e.orientation||"vertical",h=e.itemGap??10,f=e.itemHeight??50,p=e.itemWidth??200,c=e.scrollOffset??0,d=e.padding??0,u=this.getWorldTransform(t.id),g=s-u.x,y=o-u.y,b=-u.rotation*(Math.PI/180),v=Math.cos(b),S=Math.sin(b),C=g*v-y*S,w=g*S+y*v,M=-a/2,I=-r/2,k=typeof d=="number"?d:l==="vertical"?d[0]:d[3];let P=(l==="vertical"?I:M)+c+k;const E=e.listLayout||"linear",_=n.length||1,T=Math.PI*2/_,A=e.circularStartAngle||0,L=e.circularRadius||100,X=c*.01+A*Math.PI/180;for(let G=0;G<n.length;G++){const H=E==="circular"?p:l==="vertical"?a:p,et=E==="circular"||l==="vertical"?f:r;let O=0,x=0,st=0;if(E==="circular"){const Q=G*T+X,lt=M+a/2,F=I+r/2;O=lt+Math.cos(Q)*L-H/2,x=F+Math.sin(Q)*L-et/2,st=Q+(e.itemRotation||0)*Math.PI/180}else O=l==="vertical"?M:P,x=l==="vertical"?P:I,st=(e.itemRotation||0)*Math.PI/180;if(st!==0){const Q=O+H/2,lt=x+et/2,F=C-Q,W=w-lt,z=-st,nt=F*Math.cos(z)-W*Math.sin(z)+Q,N=F*Math.sin(z)+W*Math.cos(z)+lt;if(nt>=O&&nt<=O+H&&N>=x&&N<=x+et)return G}else if(C>=O&&C<=O+H&&w>=x&&w<=x+et)return G;P+=(l==="vertical"?f:p)+h}return null}drawListViewRect(t,s,o,e,i,n){t.beginPath(),this.drawRoundRect(t,s,o,e,i,n),t.fill()}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 i=this.objectStates.get(e.id);i&&e.behaviors.forEach(n=>{var p,c,d,u,g,y,b,v,S,C,w,M,I,k,P,E,_,T,A,L,X,D,$,G,H,et,O,x,st,Q,lt,F,W,z,nt,N,pt,yt,dt,wt,Pt,_t,Ut,j,gt,Rt,It,bt,Ft,Bt,zt,Gt,qt,ce,ve,Ht,se,we,Me,fe,Ie,_e,Ee,le,ne,ot,ct,it,R,Z,q,mt,Et,kt,$t,vt,Wt,Y,Xt,ae,Jt,ut,ft,St,Tt,B,at,K,At,Mt,ee,ie,Se,Vt,Zt,Qt,ke,Ae,Oe,Le,xe,Re,Ye,Kt,re,pe,Fe,$e,ye,ue,ge,Te,Xe,Ue,qe,De,Ke,Je;if(!n.enabled)return;const a=n.startTime||0,r=n.endTime||1/0;if(this.currentTime<a||this.currentTime>r)return;const l=i.x-s,h=i.y-o,f=Math.sqrt(l*l+h*h);if(this.frameCount%240===0&&Math.random()<.1&&this.log(`[ExodeUI] Executing ${n.type} on ${e.name}`),n.type===V.Proximity){const U=((p=n.settings)==null?void 0:p.radius)||300,tt=((c=n.settings)==null?void 0:c.falloff)||"smooth";let J=0;f<U&&(tt==="linear"?J=1-f/U:J=Math.pow(1-f/U,2)),n.sensors.forEach(ht=>{this.applyBehaviorSensor(i,ht,J,t,n.settings,e,l,h,f)})}else if(n.type===V.Magnetic){const U=((d=n.settings)==null?void 0:d.radius)||400,tt=((u=n.settings)==null?void 0:u.strength)||.5;if(f<U&&f>5){const J=1-f/U,ht=l*J*tt,Ot=h*J*tt;i.x-=ht*t*10,i.y-=Ot*t*10}}else if(n.type===V.Repel){const U=((g=n.settings)==null?void 0:g.radius)||300,tt=((y=n.settings)==null?void 0:y.strength)||1;if(f<U){const J=Math.pow(1-f/U,2);i.x+=l/(f||1)*J*60*tt*t*5,i.y+=h/(f||1)*J*60*tt*t*5}}else if(n.type===V.Orbit){const U=((b=n.settings)==null?void 0:b.speed)||1,tt=((v=n.settings)==null?void 0:v.radius)||30,J=this.currentTime*U*Math.PI*2;i.x+=Math.cos(J)*tt*t*5,i.y+=Math.sin(J)*tt*t*5,i.rotation+=2*t*5}else if(n.type===V.Vortex){const U=((S=n.settings)==null?void 0:S.radius)||400,tt=((C=n.settings)==null?void 0:C.speed)||2,J=((w=n.settings)==null?void 0:w.strength)||1;if(f<U){const ht=Math.pow(1-f/U,1.5),Ot=this.currentTime*tt*Math.PI*2,xt=Math.cos(Ot)*30-l*.4,Yt=Math.sin(Ot)*30-h*.4;i.x+=xt*ht*J*t*5,i.y+=Yt*ht*J*t*5,i.rotation+=5*ht*J*t*5,i.scale_x*=1-ht*.1*J*t,i.scale_y*=1-ht*.1*J*t}}else if(n.type===V.Fluid){const U=((M=n.settings)==null?void 0:M.radius)||300,tt=((I=n.settings)==null?void 0:I.strength)||1;if(f<U){const J=Math.pow(1-f/U,1.2),ht=l/(f||1)*J*1.2*tt,Ot=h/(f||1)*J*1.2*tt;i.x+=ht*10*t*5,i.y+=Ot*10*t*5,i.scale_x*=1+J*.3*tt*t,i.scale_y*=1+J*.3*tt*t}}else if(n.type===V.Elastic){const U=((k=n.settings)==null?void 0:k.radius)||300,tt=((P=n.settings)==null?void 0:P.strength)||1;if(f<U){const J=1-f/U;i.scale_x*=1+J*.4*tt*t,i.scale_y*=1+J*.4*tt*t}}else if(n.type===V.Holographic){const U=i.x-this.canvasWidth/2,tt=i.y-this.canvasHeight/2,J=((E=n.settings)==null?void 0:E.factor)||25;if(i.x-=U/1e3*J*t*5,i.y-=tt/1e3*J*t*5,i.style){const ht=1-Math.min(1,f/400);i.style.exposure=(i.style.exposure||1)+ht*.5*t}}else if(n.type===V.Sticky){const U=((_=n.settings)==null?void 0:_.radius)||80,tt=((T=n.settings)==null?void 0:T.strength)||1;if(f<U){const J=Math.pow(1-f/U,2);i.x-=l*J*tt*t*10,i.y-=h*J*tt*t*10,i.scale_x*=1-J*.1*tt*t,i.scale_y*=1-J*.1*tt*t}}else if(n.type===V.Dilation){const U=((A=n.settings)==null?void 0:A.size)||120,tt=((L=n.settings)==null?void 0:L.strength)||1;if(f<U){const J=1-f/U;i.scale_x*=1+J*.5*tt*t,i.scale_y*=1+J*.5*tt*t}}else if(n.type===V.Parallax){const U=((X=n.settings)==null?void 0:X.factor)||15,tt=((D=n.settings)==null?void 0:D.strength)||1,J=this.canvasWidth/2,ht=this.canvasHeight/2,Ot=this._lastPointerPos||{x:J,y:ht},xt=(Ot.x-J)/J,Yt=(Ot.y-ht)/ht,oe=((($=e.transform)==null?void 0:$.x)??0)+xt*U*tt,me=(((G=e.transform)==null?void 0:G.y)??0)+Yt*U*tt,Pe=(((H=e.transform)==null?void 0:H.rotate_x)??0)-Yt*U*1.5*tt,he=(((et=e.transform)==null?void 0:et.rotate_y)??0)+xt*U*1.5*tt,Ce=Math.min(1,10*t);i.x=this.lerp(i.x??((O=e.transform)==null?void 0:O.x)??0,oe,Ce),i.y=this.lerp(i.y??((x=e.transform)==null?void 0:x.y)??0,me,Ce),i.rotate_x=this.lerp(i.rotate_x??((st=e.transform)==null?void 0:st.rotate_x)??0,Pe,Ce),i.rotate_y=this.lerp(i.rotate_y??((Q=e.transform)==null?void 0:Q.rotate_y)??0,he,Ce)}else if(n.type===V.Fold){if(f<300){const U=1-f/300,tt=(l>0?-1:1)*U*10,J=1-U*.1,ht=h/300*U*20,Ot=-(l/300)*U*20,xt=Math.min(1,10*t);i.skew_x=this.lerp(i.skew_x??((lt=e.transform)==null?void 0:lt.skew_x)??0,tt,xt),i.scale_y=this.lerp(i.scale_y??((F=e.transform)==null?void 0:F.scale_y)??1,(((W=e.transform)==null?void 0:W.scale_y)??1)*J,xt),i.rotate_x=this.lerp(i.rotate_x??((z=e.transform)==null?void 0:z.rotate_x)??0,ht,xt),i.rotate_y=this.lerp(i.rotate_y??((nt=e.transform)==null?void 0:nt.rotate_y)??0,Ot,xt),i.style=i.style||{...e.style},i.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((N=n.settings)==null?void 0:N.opacity)??.5}}}else if(n.type===V.Crumple){if(f<300){const U=1-f/300,tt=U*(Math.random()-.5)*5,J=U*(Math.random()-.5)*.05,ht=Math.min(1,15*t);i.skew_x=this.lerp(i.skew_x??((pt=e.transform)==null?void 0:pt.skew_x)??0,tt,ht),i.scale_x=this.lerp(i.scale_x??((yt=e.transform)==null?void 0:yt.scale_x)??1,(((dt=e.transform)==null?void 0:dt.scale_x)??1)*(1+J),ht),i.scale_y=this.lerp(i.scale_y??((wt=e.transform)==null?void 0:wt.scale_y)??1,(((Pt=e.transform)==null?void 0:Pt.scale_y)??1)*(1+J),ht),i.style=i.style||{...e.style},i.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((_t=n.settings)==null?void 0:_t.intensity)??1,scale:((Ut=n.settings)==null?void 0:Ut.scale)??2}}}else if(n.type===V.Squash){const U=((j=n.settings)==null?void 0:j.strength)||.8;f<(e.width||100)&&this.isMouseDown?(i.scale_y=this.lerp(i.scale_y??1,(((gt=e.transform)==null?void 0:gt.scale_y)??1)*U,.3),i.scale_x=this.lerp(i.scale_x??1,(((Rt=e.transform)==null?void 0:Rt.scale_x)??1)*(1+(1-U)*.4),.3)):(i.scale_y=this.lerp(i.scale_y??1,((It=e.transform)==null?void 0:It.scale_y)??1,.2),i.scale_x=this.lerp(i.scale_x??1,((bt=e.transform)==null?void 0:bt.scale_x)??1,.2))}else if(n.type===V.TextCounter){const U=((Ft=n.settings)==null?void 0:Ft.duration)||2,tt=((Bt=n.settings)==null?void 0:Bt.from)||0,J=((zt=n.settings)==null?void 0:zt.to)||100;n._runtimeStart===void 0&&(n._runtimeStart=this.currentTime);const ht=this.currentTime-n._runtimeStart,Ot=Math.min(1,ht/U),xt=Math.floor(tt+(J-tt)*Ot);if(((Gt=e.geometry)==null?void 0:Gt.type)==="Text"){const Yt=((qt=n.settings)==null?void 0:qt.prefix)||"",oe=((ce=n.settings)==null?void 0:ce.suffix)||"";i.geometry||(i.geometry={...e.geometry}),i.geometry.text=`${Yt}${xt}${oe}`}}else if(n.type===V.Spotlight){const U=((ve=n.settings)==null?void 0:ve.radius)||250,tt=((Ht=n.settings)==null?void 0:Ht.strength)||1.5;if(f<U){const J=Math.pow(1-f/U,2);i.style||(i.style={...e.style}),i.style.adjustments||(i.style.adjustments={...(se=e.style)==null?void 0:se.adjustments}),i.style.adjustments.exposure=(((Me=(we=e.style)==null?void 0:we.adjustments)==null?void 0:Me.exposure)||0)+J*tt*50}else(fe=i.style)!=null&&fe.adjustments&&(i.style.adjustments.exposure=this.lerp(i.style.adjustments.exposure||0,((_e=(Ie=e.style)==null?void 0:Ie.adjustments)==null?void 0:_e.exposure)||0,.1))}else if(n.type===V.Noise||n.type===V.Float){const U=(((Ee=n.settings)==null?void 0:Ee.frequency)||((le=n.settings)==null?void 0:le.speed)||1)*.002,tt=(((ne=n.settings)==null?void 0:ne.amplitude)||((ot=n.settings)==null?void 0:ot.range)||50)*(((ct=n.settings)==null?void 0:ct.strength)||1),J=Date.now();i.x+=Math.sin(J*U)*tt*t,i.y+=Math.cos(J*U*.8)*tt*t,i.rotation+=Math.sin(J*U*.5)*5*t}else if(n.type===V.Pulse){const U=(((it=n.settings)==null?void 0:it.speed)||1)*.005,tt=(((R=n.settings)==null?void 0:R.scale)||1.2)-1,J=Math.sin(Date.now()*U),ht=((Z=n.settings)==null?void 0:Z.strength)||1;i.scale_x*=1+J*tt*ht*t,i.scale_y*=1+J*tt*ht*t,i.style&&(i.style.exposure=(i.style.exposure||1)+Math.max(0,J)*.1*ht*t)}else if(n.type===V.Draggable){const U=((q=n.settings)==null?void 0:q.radius)||150,tt=this.draggingBehaviors.has(e.id);if(f<U||tt){const J=((mt=n.settings)==null?void 0:mt.strength)||1,ht=tt?1:Math.max(0,1-f/U);this.applyBehaviorSensor(i,te.PositionX,ht*J,t,n.settings),this.applyBehaviorSensor(i,te.PositionY,ht*J,t,n.settings)}}else if(n.type===V.Scroll){const U=((Et=n.settings)==null?void 0:Et.axis)||"vertical",tt=((kt=n.settings)==null?void 0:kt.factor)||.5,J=(($t=n.settings)==null?void 0:$t.strength)||1,ht=((vt=n.settings)==null?void 0:vt.scaleFactor)||0;(U==="vertical"||U==="both")&&(i.y+=this.scrollOffset.y*tt*J*t),(U==="horizontal"||U==="both")&&(i.x+=this.scrollOffset.x*tt*J*t),ht!==0&&(i.scale_x*=1+this.scrollOffset.y*ht*t,i.scale_y*=1+this.scrollOffset.y*ht*t)}else if(n.type===V.LookAt){const U=((Wt=n.settings)==null?void 0:Wt.factor)||1,tt=((Y=n.settings)==null?void 0:Y.strength)||1,J=Math.atan2(-h,-l)*(180/Math.PI),ht=i.rotation,Ot=(J-ht+180)%360-180;i.rotation+=Ot*U*tt*t*10}else if(n.type===V.Scan){const U=(((Xt=n.settings)==null?void 0:Xt.speed)||1)*.004,tt=((ae=n.settings)==null?void 0:ae.strength)||1,J=(Math.sin(Date.now()*U)+1)/2;i.style&&(i.style.exposure=(i.style.exposure||1)+J*tt*t*5),i.x+=(J-.5)*20*tt*t}else if(n.type===V.Glint)i.style=i.style||{...e.style},i.style.artEffect={enabled:!0,type:"glint_overlay",intensity:((Jt=n.settings)==null?void 0:Jt.strength)??.8};else if(n.type===V.Ratchet){const U=((ut=n.settings)==null?void 0:ut.steps)||12,tt=(((ft=n.settings)==null?void 0:ft.speed)||1)*30,J=Math.floor(i.rotation/(360/U))*(360/U);i.rotation=this.lerp(i.rotation,J+tt*t,.1)}else if(n.type===V.Jitter&&f<300){const U=((St=n.settings)==null?void 0:St.strength)||1,tt=(((Tt=n.settings)==null?void 0:Tt.intensity)||5)*U;i.x+=(Math.random()-.5)*tt*t*60,i.y+=(Math.random()-.5)*tt*t*60,i.rotation+=(Math.random()-.5)*tt*t*120}else if(n.type===V.Follower){const U=(B=n.settings)==null?void 0:B.targetId;if(U){const tt=this.objectStates.get(U);if(tt){const J=((at=n.settings)==null?void 0:at.stiffness)||.1,ht=tt.x-i.x,Ot=tt.y-i.y;i.x+=ht*J*t*60,i.y+=Ot*J*t*60}}}else if(n.type===V.Wrap)i.x<0?i.x=this.canvasWidth:i.x>this.canvasWidth&&(i.x=0),i.y<0?i.y=this.canvasHeight:i.y>this.canvasHeight&&(i.y=0);else if(n.type===V.Gravity){const U=((K=n.settings)==null?void 0:K.strength)||9.8;i.y+=U*t*10}else if(n.type===V.Velocity){const U=((At=n.settings)==null?void 0:At.vx)||0,tt=((Mt=n.settings)==null?void 0:Mt.vy)||0;i.x+=U*t*10,i.y+=tt*t*10}else if(n.type===V.Shear){const U=((ee=n.settings)==null?void 0:ee.strength)||1,tt=((ie=n.settings)==null?void 0:ie.radius)||300;if(f<tt){const J=1-f/tt;i.skew_x=this.lerp(i.skew_x||0,(((Se=e.transform)==null?void 0:Se.skew_x)||0)+J*U*30,.1)}else i.skew_x=this.lerp(i.skew_x||0,((Vt=e.transform)==null?void 0:Vt.skew_x)||0,.05)}else if(n.type===V.Lens){const U=((Zt=n.settings)==null?void 0:Zt.radius)||200,tt=((Qt=n.settings)==null?void 0:Qt.strength)||.5;if(f<U){const J=Math.pow(1-f/U,2);i.scale_x=this.lerp(i.scale_x??1,(((ke=e.transform)==null?void 0:ke.scale_x)??1)*(1+J*tt),.2),i.scale_y=this.lerp(i.scale_y??1,(((Ae=e.transform)==null?void 0:Ae.scale_y)??1)*(1+J*tt),.2)}else i.scale_x=this.lerp(i.scale_x??1,((Oe=e.transform)==null?void 0:Oe.scale_x)??1,.1),i.scale_y=this.lerp(i.scale_y??1,((Le=e.transform)==null?void 0:Le.scale_y)??1,.1)}else if(n.type===V.LayoutAnimation){const U=((xe=n.settings)==null?void 0:xe.watchProperties)||["x","y","scale_x","scale_y","opacity","rotation"],tt=((Re=n.settings)==null?void 0:Re.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const J=this._layoutAnimCache.get(e.id);for(const ht of U){const Ot=this.getObjectProperty(i,e,ht);if(Ot===void 0)continue;const xt=J.get(ht);if(!xt)J.set(ht,{from:Ot,to:Ot,startTime:this.currentTime,duration:0});else if(xt.to!==Ot){const oe=this.getObjectProperty(i,e,ht);J.set(ht,{from:oe??xt.from,to:Ot,startTime:this.currentTime,duration:((Ye=n.settings)==null?void 0:Ye.duration)??tt})}const Yt=J.get(ht);if(Yt.duration>0&&Yt.from!==Yt.to){const oe=this.currentTime-Yt.startTime,me=Math.min(1,oe/Yt.duration),Pe=this.applyEasing(me,((Kt=n.settings)==null?void 0:Kt.easing)||"easeOutCubic"),he=Yt.from+(Yt.to-Yt.from)*Pe;this.setObjectProperty(i,e,ht,he)}}}else if(n.type===V.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const U=this._layoutAnimCache.get(e.id),tt=((re=n.settings)==null?void 0:re.defaultDuration)||.3,J=["x","y","scale_x","scale_y","opacity","rotation","style.fill.color","style.stroke.width","geometry.cornerRadius","style.blur.value","style.shadow.blur","style.shadow.offsetX","style.shadow.offsetY"];for(const ht of J){const Ot=this.getObjectProperty(i,e,ht);if(Ot===void 0||typeof Ot!="number")continue;const xt=U.get(ht);if(!xt)U.set(ht,{from:Ot,to:Ot,startTime:this.currentTime,duration:0});else if(xt.to!==Ot){const oe=this.getObjectProperty(i,e,ht);U.set(ht,{from:oe??xt.from,to:Ot,startTime:this.currentTime,duration:tt})}const Yt=U.get(ht);if(Yt.duration>0&&Yt.from!==Yt.to){const oe=this.currentTime-Yt.startTime,me=Math.min(1,oe/Yt.duration),Pe=this.applyEasing(me,((pe=n.settings)==null?void 0:pe.defaultEasing)||"easeOutCubic"),he=Yt.from+(Yt.to-Yt.from)*Pe;this.setObjectProperty(i,e,ht,he)}}}else if(n.type===V.SpringChain){const U=((Fe=n.settings)==null?void 0:Fe.connections)||[],tt=(($e=n.settings)==null?void 0:$e.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const J=this._springChainState.get(e.id);for(const Ot of U){if(!J.has(Ot.targetId)){const xt=this.objectStates.get(Ot.targetId);J.set(Ot.targetId,{x:(xt==null?void 0:xt.x)??0,y:(xt==null?void 0:xt.y)??0,vx:0,vy:0})}J.has(e.id)||J.set(e.id,{x:i.x,y:i.y,vx:0,vy:0})}const ht=J.get(e.id);if(ht){ht.x=i.x,ht.y=i.y;for(const Ot of U){const xt=J.get(Ot.targetId);if(!xt)continue;const Yt=xt.x-ht.x,oe=xt.y-ht.y,me=Math.sqrt(Yt*Yt+oe*oe)||.001,he=(me-(Ot.restLength||50))*(Ot.stiffness||.8),Ce=Yt/me*he,Qe=oe/me*he;ht.vx+=Ce*t*10,ht.vy+=Qe*t*10,xt.vx-=Ce*t*10,xt.vy-=Qe*t*10,ht.vx*=1-tt*t*10,ht.vy*=1-tt*t*10,xt.vx*=1-tt*t*10,xt.vy*=1-tt*t*10;const be=this.objectStates.get(Ot.targetId);be&&(be.x+=xt.vx*t,be.y+=xt.vy*t)}i.x+=ht.vx*t,i.y+=ht.vy*t}}else if(n.type===V.ParticleEmitter){const U=((ye=n.settings)==null?void 0:ye.rate)||10,tt=((ue=n.settings)==null?void 0:ue.speed)||100,J=((ge=n.settings)==null?void 0:ge.size)||5,ht=((Te=n.settings)==null?void 0:Te.lifetime)||2,Ot=((Xe=n.settings)==null?void 0:Xe.gravity)||0,xt=((Ue=n.settings)==null?void 0:Ue.color)||"#ffffff",Yt=((qe=n.settings)==null?void 0:qe.maxParticles)||200,oe=(De=n.settings)!=null&&De.rateInputId?this.inputs.get(n.settings.rateInputId)??U:U,me=(Ke=n.settings)!=null&&Ke.gravityInputId?this.inputs.get(n.settings.gravityInputId)??Ot:Ot,Pe=(Je=n.settings)!=null&&Je.speedInputId?this.inputs.get(n.settings.speedInputId)??tt:tt;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const he=this._emitterPools.get(e.id);let Ce=0;n._pendingBurst&&n._pendingBurst>0&&(Ce=n._pendingBurst,n._pendingBurst=0);const Qe=Math.floor(oe*t)+(Ce||0);for(let be=0;be<Math.min(Qe,Yt-he.length);be++){const de=Math.random()*Math.PI*2,ms=Pe*(.5+Math.random()*.5);he.push({x:i.x,y:i.y,vx:Math.cos(de)*ms,vy:Math.sin(de)*ms,life:0,maxLife:ht*(.5+Math.random()*.5),size:J*(.5+Math.random()),color:xt,opacity:1})}for(let be=he.length-1;be>=0;be--){const de=he[be];de.vy+=me*t*10,de.x+=de.vx*t,de.y+=de.vy*t,de.life+=t,de.opacity=Math.max(0,1-de.life/de.maxLife),de.life>=de.maxLife&&he.splice(be,1)}}})})}applyBehaviorSensor(t,s,o,e,i,n,a=0,r=0,l=1){var d,u,g,y,b,v,S,C,w,M,I,k,P,E,_,T,A,L,X,D,$,G,H,et;const h=(i==null?void 0:i.intensity)||(i==null?void 0:i.strength)||1,f=Math.min(1,15*e),p=l>0?a/l:0,c=l>0?r/l:0;switch(s){case te.Scale:{const O=((d=n==null?void 0:n.transform)==null?void 0:d.scale_x)??1,x=((u=n==null?void 0:n.transform)==null?void 0:u.scale_y)??1,st=O*(1+o*h*.4),Q=x*(1+o*h*.4);t.scale_x=(t.scale_x??O)*(1-f)+st*f,t.scale_y=(t.scale_y??x)*(1-f)+Q*f;break}case te.Opacity:{const O=((g=n==null?void 0:n.transform)==null?void 0:g.opacity)??100,x=Math.max(0,Math.min(100,O-o*h*100));t.opacity=(t.opacity??O)*(1-f)+x*f;break}case te.RotateZ:{const O=((y=n==null?void 0:n.transform)==null?void 0:y.rotation)??0,x=O+o*h*45;t.rotation=(t.rotation??O)*(1-f)+x*f;break}case te.RotateX:{const O=((b=n==null?void 0:n.transform)==null?void 0:b.rotate_x)??0,x=O-c*o*h*60;t.rotate_x=(t.rotate_x??O)*(1-f)+x*f;break}case te.RotateY:{const O=((v=n==null?void 0:n.transform)==null?void 0:v.rotate_y)??0,x=O+p*o*h*60;t.rotate_y=(t.rotate_y??O)*(1-f)+x*f;break}case te.PositionX:{const O=((S=n==null?void 0:n.transform)==null?void 0:S.x)??0,x=O-p*o*h*40;t.x=(t.x??O)*(1-f)+x*f;break}case te.PositionY:{const O=((C=n==null?void 0:n.transform)==null?void 0:C.y)??0,x=O-c*o*h*40;t.y=(t.y??O)*(1-f)+x*f;break}case te.SkewX:{const O=((w=n==null?void 0:n.transform)==null?void 0:w.skew_x)??0,x=O+p*o*h*45;t.skew_x=(t.skew_x??O)*(1-f)+x*f,t.skew_x>85&&(t.skew_x=85),t.skew_x<-85&&(t.skew_x=-85);break}case te.Blur:{t.style||(t.style={...n==null?void 0:n.style}),t.style.blur||(t.style.blur={...(M=n==null?void 0:n.style)==null?void 0:M.blur});const O=((k=(I=n==null?void 0:n.style)==null?void 0:I.blur)==null?void 0:k.amount)||0,x=O+o*((i==null?void 0:i.blur)||20)*h;t.style.blur.amount=(t.style.blur.amount??O)*(1-f)+x*f;break}case te.Exposure:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(P=n==null?void 0:n.style)==null?void 0:P.adjustments});const O=((_=(E=n==null?void 0:n.style)==null?void 0:E.adjustments)==null?void 0:_.exposure)||0,x=O+o*((i==null?void 0:i.exposure)||50)*h;t.style.adjustments.exposure=(t.style.adjustments.exposure??O)*(1-f)+x*f;break}case te.HueShift:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(T=n==null?void 0:n.style)==null?void 0:T.adjustments});const O=((L=(A=n==null?void 0:n.style)==null?void 0:A.adjustments)==null?void 0:L.hue)||0,x=O+o*((i==null?void 0:i.hue)||180)*h;t.style.adjustments.hue=(t.style.adjustments.hue??O)*(1-f)+x*f;break}case te.Negative:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(X=n==null?void 0:n.style)==null?void 0:X.adjustments});const O=(($=(D=n==null?void 0:n.style)==null?void 0:D.adjustments)==null?void 0:$.negative)||0,x=O+o*((i==null?void 0:i.negative)||100)*h;t.style.adjustments.negative=(t.style.adjustments.negative??O)*(1-f)+x*f;break}case te.CornerRadius:{const O=((G=n==null?void 0:n.transform)==null?void 0:G.corner_radius)||0,x=O+o*h*50;t.corner_radius=(t.corner_radius??O)*(1-f)+x*f;break}case te.StrokeWidth:{t.style||(t.style={...n==null?void 0:n.style});const O=((H=n==null?void 0:n.style)==null?void 0:H.borderWidth)||0,x=O+o*h*10;t.style.borderWidth=(t.style.borderWidth??O)*(1-f)+x*f;break}case te.LetterSpacing:{t.geometry||(t.geometry={});const O=((et=n==null?void 0:n.geometry)==null?void 0:et.letterSpacing)||0,x=O+o*h*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??O)*(1-f)+x*f;break}}}getObjectProperty(t,s,o){const e=o.replace(/\[(\d+)\]/g,".$1").split(".");let i=t;for(const n of e){if(i==null||typeof i!="object")return;if(n==="style"&&t.style===void 0){i=s.style;continue}i=i[n]}return typeof i=="number"?i:void 0}setObjectProperty(t,s,o,e){const i=o.replace(/\[(\d+)\]/g,".$1").split(".");let n=t;for(let r=0;r<i.length-1;r++){const l=i[r];if(n[l]===void 0||n[l]===null){const h=s,f=i.slice(0,r+1).reduce((d,u)=>d==null?void 0:d[u],h),p=i[r+1],c=!isNaN(Number(p));n[l]=f!==void 0?Array.isArray(f)?[...f]:{...f}:c?[]:{}}n=n[l]}const a=i[i.length-1];n!=null&&(n[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 i=0;i<s.length;i++)s[i]&&typeof s[i]=="object"&&!Array.isArray(s[i])&&t[i]&&typeof t[i]=="object"?e[i]=this.deepMerge(t[i],s[i]):e[i]=s[i];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}renderFittedImage(t,s,o,e,i,n,a="cover"){const r=s.naturalWidth,l=s.naturalHeight,h=r/l,f=i/n;let p=i,c=n,d=o,u=e;a==="cover"?h>f?(p=n*h,d=o-(p-i)/2):(c=i/h,u=e-(c-n)/2):a==="contain"&&(h>f?(c=i/h,u=e+(n-c)/2):(p=n*h,d=o+(i-p)/2)),t.drawImage(s,d,u,p,c)}}const ai=Lt.forwardRef(({artboard:m,src:t,style:s,autoPlay:o=!0,fit:e="Contain",alignment:i="Center",onReady:n,onTrigger:a,onInputUpdate:r,onComponentChange:l,onToggle:h,onInputChange:f,onInputFocus:p,onInputBlur:c,onLog:d,onLogicUpdate:u,onButtonClick:g,onGraphPointClick:y,currentTime:b,revision:v=0,scrollY:S,scrollX:C,mouseX:w,mouseY:M,isMouseDown:I,inputs:k,interactive:P=!0,onNavigation:E},_)=>{const T=Lt.useRef(null),A=Lt.useRef(null);A.current||(A.current=new ys);const L=Lt.useRef(void 0),X=Lt.useRef(0),D=Lt.useRef(null),$=Lt.useRef(v),G=Lt.useRef(null),[,H]=Lt.useState(m||null),et=Lt.useRef(!0);Lt.useImperativeHandle(_,()=>T.current),Lt.useEffect(()=>(et.current=!0,()=>{et.current=!1,L.current&&cancelAnimationFrame(L.current)}),[]),Lt.useEffect(()=>{A.current.setLayout(e,i)},[e,i]),Lt.useEffect(()=>{const F=A.current;a&&F.setTriggerCallback(a),r&&F.setInputUpdateCallback((W,z)=>r({[W]:z})),l&&F.setComponentChangeCallback(W=>l(W)),h&&F.setToggleCallback(h),f&&F.setInputChangeCallback(f),p&&F.setInputFocusCallback(p),c&&F.setInputBlurCallback(c),d&&F.setOnLogCallback(W=>d(W,"info")),u&&F.setLogicUpdateCallback(u),g&&F.setButtonClickCallback(g),y&&F.setGraphPointClickCallback(W=>y(W.objectId,W)),E&&F.setNavigationCallback(E)},[a,r,l,h,f,p,c,d,u,g,y,E]),Lt.useEffect(()=>{(async()=>{let W=m;if(t&&!m)try{t.startsWith("{")?W=JSON.parse(t):W=await(await fetch(t)).json()}catch(z){console.error("[ExodeUI] Failed to load src:",z)}if(W){const z=A.current,nt=W.id||W.name||"default";(D.current!==nt||$.current!==v||G.current!==W)&&(z.load(W),D.current=nt,$.current=v,G.current=W,H(W),X.current=0,z.advance(0)),n&&n(z)}})()},[m,t,v]),Lt.useEffect(()=>{const F=W=>{if(!A.current||!et.current)return;const z=A.current,nt=T.current;if(!nt)return;const N=nt.getContext("2d");if(!N)return;const pt=W/1e3;X.current===0&&(X.current=pt);let yt=pt-X.current;yt>.1&&(yt=.1),X.current=pt;const dt=nt.getBoundingClientRect(),wt=window.devicePixelRatio||1,Pt=Math.round(dt.width*wt),_t=Math.round(dt.height*wt);(nt.width!==Pt||nt.height!==_t)&&(nt.width=Pt,nt.height=_t);try{o?z.advance(yt):b!==void 0&&z.seek(b),z.render(N,nt.width,nt.height)}catch(Ut){console.error("[ExodeUICanvas] Error in animation loop:",Ut),d&&d(`[Error] Animation loop crashed: ${Ut}`,"error")}L.current=requestAnimationFrame(F)};return L.current=requestAnimationFrame(F),()=>{L.current&&cancelAnimationFrame(L.current)}},[o,b]),Lt.useEffect(()=>{const F=A.current;S!==void 0&&F.updateInput("scrollY",S),C!==void 0&&F.updateInput("scrollX",C),w!==void 0&&F.updateInput("mouseX",w),M!==void 0&&F.updateInput("mouseY",M),I!==void 0&&F.updateInput("isMouseDown",I),k&&Object.entries(k).forEach(([W,z])=>F.updateInput(W,z))},[S,C,w,M,I,k]);const O=(F,W)=>{if(!P||!T.current)return;F.stopPropagation(),"nativeEvent"in F&&F.nativeEvent&&typeof F.nativeEvent.stopImmediatePropagation=="function"?F.nativeEvent.stopImmediatePropagation():typeof F.stopImmediatePropagation=="function"&&F.stopImmediatePropagation();const z=T.current,nt=z.getBoundingClientRect(),N=F.clientX-nt.left,pt=F.clientY-nt.top,yt=window.devicePixelRatio||1;(W==="click"||W==="down"||W==="up")&&d&&d(`[Canvas] Pointer ${W} at rect(${Math.round(N)},${Math.round(pt)}) mapped to buffer(${Math.round(N*yt)},${Math.round(pt*yt)})`,"info"),A.current.handlePointerInput(W,N*yt,pt*yt,z.width,z.height)};Lt.useEffect(()=>{if(!P)return;const F=z=>{var nt,N,pt;((nt=document.activeElement)==null?void 0:nt.tagName)==="INPUT"||((N=document.activeElement)==null?void 0:N.tagName)==="TEXTAREA"||(pt=A.current)==null||pt.handleKeyDown(z)},W=z=>{var nt,N,pt;((nt=document.activeElement)==null?void 0:nt.tagName)==="INPUT"||((N=document.activeElement)==null?void 0:N.tagName)==="TEXTAREA"||(pt=A.current)==null||pt.handleKeyUp(z)};return window.addEventListener("keydown",F),window.addEventListener("keyup",W),()=>{window.removeEventListener("keydown",F),window.removeEventListener("keyup",W)}},[P]);const[x,st]=Lt.useState([]);Lt.useEffect(()=>{if(m&&m.objects){const F=m.objects.filter(W=>{var z,nt;return W.type==="Joystick"&&((z=W.inputBinding)==null?void 0:z.type)==="keyboard"&&((nt=W.inputBinding.keyboardConfig)==null?void 0:nt.showVirtualKeyboard)});st(F)}},[m]);const[,Q]=Lt.useState(0);Lt.useEffect(()=>{if(x.length===0)return;let F;const W=()=>{Q(z=>z+1),F=requestAnimationFrame(W)};return F=requestAnimationFrame(W),()=>cancelAnimationFrame(F)},[x.length]);const lt=()=>x.map(F=>{const W=F.inputBinding.keyboardConfig,z=dt=>{var Pt;const wt={key:dt,code:dt,preventDefault:()=>{}};(Pt=A.current)==null||Pt.handleKeyDown(wt)},nt=dt=>{var Pt;const wt={key:dt,code:dt,preventDefault:()=>{}};(Pt=A.current)==null||Pt.handleKeyUp(wt)},N=A.current,pt=dt=>N&&N.activeKeys?N.activeKeys.has(dt.toLowerCase()):!1,yt=dt=>({width:"50px",height:"50px",background:dt?"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:dt?"none":"0 4px 6px rgba(0,0,0,0.1)"});return Dt.jsxs("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",pointerEvents:"auto",zIndex:100},children:[Dt.jsx("div",{style:yt(pt(W.upKey)),onMouseDown:()=>z(W.upKey),onMouseUp:()=>nt(W.upKey),onMouseLeave:()=>nt(W.upKey),onTouchStart:dt=>{dt.preventDefault(),z(W.upKey)},onTouchEnd:dt=>{dt.preventDefault(),nt(W.upKey)},children:W.upKey.toUpperCase()}),Dt.jsxs("div",{style:{display:"flex",gap:"8px"},children:[Dt.jsx("div",{style:yt(pt(W.leftKey)),onMouseDown:()=>z(W.leftKey),onMouseUp:()=>nt(W.leftKey),onMouseLeave:()=>nt(W.leftKey),onTouchStart:dt=>{dt.preventDefault(),z(W.leftKey)},onTouchEnd:dt=>{dt.preventDefault(),nt(W.leftKey)},children:W.leftKey.toUpperCase()}),Dt.jsx("div",{style:yt(pt(W.downKey)),onMouseDown:()=>z(W.downKey),onMouseUp:()=>nt(W.downKey),onMouseLeave:()=>nt(W.downKey),onTouchStart:dt=>{dt.preventDefault(),z(W.downKey)},onTouchEnd:dt=>{dt.preventDefault(),nt(W.downKey)},children:W.downKey.toUpperCase()}),Dt.jsx("div",{style:yt(pt(W.rightKey)),onMouseDown:()=>z(W.rightKey),onMouseUp:()=>nt(W.rightKey),onMouseLeave:()=>nt(W.rightKey),onTouchStart:dt=>{dt.preventDefault(),z(W.rightKey)},onTouchEnd:dt=>{dt.preventDefault(),nt(W.rightKey)},children:W.rightKey.toUpperCase()})]})]},F.id)});return Dt.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[Dt.jsx("canvas",{ref:T,onPointerDown:F=>{var W;O(F,"down"),(W=T.current)==null||W.focus()},onPointerMove:F=>O(F,"move"),onPointerUp:F=>O(F,"up"),onPointerCancel:F=>O(F,"up"),onClick:F=>O(F,"click"),onWheel:F=>{A.current.handleWheel(F.deltaX,F.deltaY)},onKeyDown:F=>A.current.handleKeyDown(F.nativeEvent),onKeyUp:F=>A.current.handleKeyUp(F.nativeEvent),onContextMenu:F=>F.preventDefault(),tabIndex:0,style:{...s,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:P?"auto":"none"}}),lt()]})});function ri(){const[m,t]=Lt.useState(null),s=Lt.useCallback((p,c)=>{m==null||m.setInputBool(p,c)},[m]),o=Lt.useCallback((p,c)=>{m==null||m.setInputNumber(p,c)},[m]),e=Lt.useCallback(p=>{m==null||m.fireTrigger(p)},[m]),i=Lt.useCallback((p,c)=>{m==null||m.setInputText(p,c)},[m]),n=Lt.useCallback((p,c)=>{m==null||m.setInputNumberArray(p,c)},[m]),a=Lt.useCallback((p,c)=>{m==null||m.setInputStringArray(p,c)},[m]),r=Lt.useCallback((p,c)=>{m==null||m.updateObjectOptions(p,c)},[m]),l=Lt.useCallback((p,c,d)=>{m==null||m.updateConstraint(p,c,d)},[m]),h=Lt.useCallback((p,c)=>{m==null||m.updateGraphData(p,c)},[m]),f=Lt.useCallback(p=>m==null?void 0:m.getInputValue(p),[m]);return{setEngine:t,engine:m,setInputBool:s,setInputNumber:o,fireTrigger:e,setInputText:i,setInputNumberArray:n,setInputStringArray:a,updateConstraint:l,updateGraphData:h,updateObjectOptions:r,getInputValue:f}}const li=({artboard:m,config:t})=>{const s={...m.seo,...t},o=s.enableSmartExtraction!==!1;Lt.useEffect(()=>{const a=s.title||m.name;a&&(document.title=a);let r=s.description;if(!r&&o){const f=m.objects.filter(p=>{var c;return((c=p.geometry)==null?void 0:c.type)==="Text"}).sort((p,c)=>{var d,u;return(((d=c.geometry.text)==null?void 0:d.length)||0)-(((u=p.geometry.text)==null?void 0:u.length)||0)});f.length>0&&(r=f[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||m.backgroundImage;l&&e("property","og:image",l),a&&e("property","og:title",a),e("property","og:type","website")},[s,m,o]);const e=(a,r,l)=>{let h=document.querySelector(`meta[${a}="${r}"]`);h||(h=document.createElement("meta"),h.setAttribute(a,r),document.head.appendChild(h)),h.setAttribute("content",l)},i=()=>{const a=[];return a.push(Dt.jsx("h1",{children:s.title||m.name},"artboard-title")),m.objects.forEach((l,h)=>{var f,p;if(!(l.visible===!1||l.isVisible===!1))if(((f=l.geometry)==null?void 0:f.type)==="Text"){const c=l.geometry.text;c&&(l.geometry.fontSize>24?a.push(Dt.jsx("h2",{children:c},l.id||h)):a.push(Dt.jsx("p",{children:c},l.id||h)))}else if(((p=l.geometry)==null?void 0:p.type)==="Image"){const c=l.geometry.src,d=l.altText||l.name||"Illustration";a.push(Dt.jsx("img",{src:c,alt:d},l.id||h))}else l.type==="Button"&&a.push(Dt.jsx("button",{children:l.name||"Button"},l.id||h))}),a},n=s.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:s.title||m.name,description:s.description,image:s.ogImage||m.backgroundImage,abstract:"Animated interface created with ExodeUI"};return Dt.jsxs("div",{id:`exode-seo-${m.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:[i(),Dt.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})]})},ci={version:"6.3.49"}.version;Nt.BehaviorSensor=te,Nt.BehaviorType=V,Nt.ConditionOp=je,Nt.ExodeSEO=li,Nt.ExodeUICanvas=ai,Nt.ExodeUIEngine=ys,Nt.LogicOp=Ct,Nt.RapierPhysics=is,Nt.VERSION=ci,Nt.useExodeUI=ri,Object.defineProperty(Nt,Symbol.toStringTag,{value:"Module"})}));