exodeui 6.3.39 → 6.3.41

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.
Files changed (3) hide show
  1. package/dist/index.js +17 -17
  2. package/dist/index.mjs +645 -642
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
- (function(Gt,Xt){typeof exports=="object"&&typeof module<"u"?Xt(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"],Xt):(Gt=typeof globalThis<"u"?globalThis:Gt||self,Xt(Gt.ExodeUIReact={},Gt.jsxRuntime,Gt.React,Gt.pretext,Gt.Rapier,Gt.LZString))})(this,(function(Gt,Xt,xt,ze,Jt,bs){"use strict";var li=Object.defineProperty;var ci=(Gt,Xt,xt)=>Xt in Gt?li(Gt,Xt,{enumerable:!0,configurable:!0,writable:!0,value:xt}):Gt[Xt]=xt;var lt=(Gt,Xt,xt)=>ci(Gt,typeof Xt!="symbol"?Xt+"":Xt,xt);function vs(g){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(g){for(const i in g)if(i!=="default"){const o=Object.getOwnPropertyDescriptor(g,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:()=>g[i]})}}return t.default=g,Object.freeze(t)}const Ss=vs(bs);var H=(g=>(g.Proximity="Proximity",g.Magnetic="Magnetic",g.Repel="Repel",g.Orbit="Orbit",g.Vortex="Vortex",g.Fluid="Fluid",g.Elastic="Elastic",g.Holographic="Holographic",g.Sticky="Sticky",g.Dilation="Dilation",g.Parallax="Parallax",g.Noise="Noise",g.Float="Float",g.Pulse="Pulse",g.Draggable="Draggable",g.Scroll="Scroll",g.LookAt="LookAt",g.Glint="Glint",g.Scan="Scan",g.Ratchet="Ratchet",g.Jitter="Jitter",g.Follower="Follower",g.Wrap="Wrap",g.Typewriter="Typewriter",g.Scramble="Scramble",g.Wave="Wave",g.Bounce="Bounce",g.TextTrail="TextTrail",g.Reveal3D="Reveal3D",g.RevealSlide="RevealSlide",g.RevealBlur="RevealBlur",g.TextLiquid="TextLiquid",g.TextVortex="TextVortex",g.TextExplosion="TextExplosion",g.TextRain="TextRain",g.TextGravity="TextGravity",g.TextMatrix="TextMatrix",g.TextNeon="TextNeon",g.TextDissolve="TextDissolve",g.TextOrganic="TextOrganic",g.TextBreathe="TextBreathe",g.TextSpin="TextSpin",g.TextMagnet="TextMagnet",g.TextPerspective="TextPerspective",g.TextMirror="TextMirror",g.TextFloral="TextFloral",g.TextSmoke="TextSmoke",g.TextVariable="TextVariable",g.TextZing="TextZing",g.TextElastic="TextElastic",g.TextGlitch3D="TextGlitch3D",g.GlitchText="GlitchText",g.TextCounter="TextCounter",g.Squash="Squash",g.Spotlight="Spotlight",g.Lens="Lens",g.Gravity="Gravity",g.Velocity="Velocity",g.Shear="Shear",g.LayoutAnimation="LayoutAnimation",g.SpringChain="SpringChain",g.ParticleEmitter="ParticleEmitter",g.StateReactive="StateReactive",g.Fold="Fold",g.Crumple="Crumple",g))(H||{}),Qt=(g=>(g.Scale="Scale",g.Opacity="Opacity",g.RotateZ="RotateZ",g.RotateX="RotateX",g.RotateY="RotateY",g.PositionX="PositionX",g.PositionY="PositionY",g.SkewX="SkewX",g.Blur="Blur",g.Exposure="Exposure",g.HueShift="HueShift",g.Negative="Negative",g.CornerRadius="CornerRadius",g.StrokeWidth="StrokeWidth",g.BoxShadow="BoxShadow",g.FontSize="FontSize",g.LetterSpacing="LetterSpacing",g))(Qt||{}),je=(g=>(g.Equal="Equal",g.NotEqual="NotEqual",g.GreaterThan="GreaterThan",g.LessThan="LessThan",g.GreaterEqual="GreaterEqual",g.LessEqual="LessEqual",g.IsTrue="IsTrue",g.IsFalse="IsFalse",g))(je||{}),wt=(g=>(g.AND="AND",g.OR="OR",g.NOT="NOT",g.XOR="XOR",g.OBJECT="OBJECT",g.PROPERTY="PROPERTY",g.GET_PROPERTY="GET_PROPERTY",g.SET_PROPERTY="SET_PROPERTY",g.ADD="ADD",g.SUB="SUB",g.MUL="MUL",g.DIV="DIV",g.MOD="MOD",g.POW="POW",g.ABS="ABS",g.ROUND="ROUND",g.FLOOR="FLOOR",g.CEIL="CEIL",g.SIN="SIN",g.COS="COS",g.TAN="TAN",g.CLAMP="CLAMP",g.REMAP="REMAP",g.EQ="EQ",g.NEQ="NEQ",g.GT="GT",g.LT="LT",g.GTE="GTE",g.LTE="LTE",g.IF_ELSE="IF_ELSE",g.VALUE="VALUE",g.INPUT="INPUT",g.LOG="LOG",g.SCROLL_X="SCROLL_X",g.SCROLL_Y="SCROLL_Y",g.MOUSE_X="MOUSE_X",g.MOUSE_Y="MOUSE_Y",g.IS_MOUSE_DOWN="IS_MOUSE_DOWN",g.EFFECTOR="EFFECTOR",g.MONITOR="MONITOR",g.DELAY="DELAY",g.SPRING_PULL="SPRING_PULL",g.SPRING_SETTLE="SPRING_SETTLE",g.EMIT="EMIT",g))(wt||{});function Cs(g){if(g.length<5)return g;const t=new Set("aeiouyAEIOUY".split(""));if(/[\u4E00-\u9FFF\u3400-\u4DBF]/.test(g))return g;let o="";for(let e=0;e<g.length;e++){if(o+=g[e],e>=g.length-2)continue;const s=t.has(g[e]),n=t.has(g[e+1]),a=t.has(g[e+2]);s&&!n&&a&&(o+="­"),s&&!n&&!a&&e>=1&&(o+="­")}return o}function ws(g){return g.replace(/\b([a-zA-Z]{4,})\b/g,(t,i)=>Cs(i))}function Ms(g,t,i){return g}function Is(g,t,i){return g}const We=new Map;function ts(g){var I;const{text:t,fontFamily:i="Inter",fontSize:o=16,fontWeight:e=400,fontStyle:s="normal",lineHeight:n=1.2,width:a=200,letterSpacing:r=0,paragraphSpacing:f=0,paragraphIndent:h=0,textCase:l="none",segments:p=[],enableSegments:c=!1}=g;let d=String(t||"");l==="uppercase"?d=d.toUpperCase():l==="lowercase"?d=d.toLowerCase():l==="capitalize"&&(d=d.replace(/\b\w/g,k=>k.toUpperCase())),g.hyphenation===!0&&(d=ws(d));const u=`${s} ${e} ${o}px "${i}", sans-serif`,v=`${d}|${u}|${r}|${f}|${h}|${c}|${JSON.stringify(p)}|hyp:${!!g.hyphenation}|comp:${g.composer}|bal:${!!g.balanceRaggedLines}`;let b=We.get(v);const m=typeof CanvasRenderingContext2D<"u"?CanvasRenderingContext2D.prototype.measureText:null,y=function(k){if(!m)return{width:0,fontBoundingBoxAscent:0,fontBoundingBoxDescent:0};const T=m.call(this,k);return r!==0&&k&&k.length>0?{...T,width:T.width+(k.length-1)*r}:T};if(!b){try{if(r!==0&&typeof CanvasRenderingContext2D<"u"&&(CanvasRenderingContext2D.prototype.measureText=y),c&&p&&p.length>0){const k=p.map(T=>{let O=T.text||"";const P=T.textCase||l||"none";return P==="uppercase"?O.toUpperCase():P==="lowercase"?O.toLowerCase():P==="capitalize"?O.replace(/\b\w/g,_=>_.toUpperCase()):O}).join("");if(b=ze.prepareWithSegments(k,u),b){let T=0,O=o;for(const P of p){let _=P.text||"";if(!_)continue;const E=P.textCase||l||"none";E==="uppercase"?_=_.toUpperCase():E==="lowercase"?_=_.toLowerCase():E==="capitalize"&&(_=_.replace(/\b\w/g,Y=>Y.toUpperCase()));const A=P.fontSize||o;A>O&&(O=A);const W=`${P.fontStyle||s} ${P.fontWeight||e} ${A}px "${P.fontFamily||i}", sans-serif`,z=ze.prepareWithSegments(_,W);if(z&&z.widths)for(let Y=0;Y<z.widths.length;Y++){const G=T+Y;if(G<b.widths.length){b.widths[G]=z.widths[Y];const N=z.kinds[Y];if(N===2){const J=_[Y];J===`
2
- `||J==="\r"?b.kinds[G]=2:b.kinds[G]=0}else b.kinds[G]=N}}T+=_.length}b.fullText=k,b.maxFontSize=O}}else b=ze.prepareWithSegments(d,u);b&&We.set(v,b)}catch(k){return console.error("[ExodeUI] Pretext prepare failed:",k),{width:a,height:0,lineCount:0,lines:[]}}finally{r!==0&&typeof CanvasRenderingContext2D<"u"&&m&&(CanvasRenderingContext2D.prototype.measureText=m)}if(We.size>500){const k=We.keys().next().value;k&&We.delete(k)}}if(h>0&&b&&b.widths&&!b.indentApplied){const k=[...b.widths],T=b.fullText||d;let O=!0;for(let P=0;P<T.length;P++)O&&k[P]!==void 0&&(k[P]+=h,O=!1),(T[P]===`
1
+ (function(zt,Xt){typeof exports=="object"&&typeof module<"u"?Xt(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"],Xt):(zt=typeof globalThis<"u"?globalThis:zt||self,Xt(zt.ExodeUIReact={},zt.jsxRuntime,zt.React,zt.pretext,zt.Rapier,zt.LZString))})(this,(function(zt,Xt,xt,ze,Jt,bs){"use strict";var li=Object.defineProperty;var ci=(zt,Xt,xt)=>Xt in zt?li(zt,Xt,{enumerable:!0,configurable:!0,writable:!0,value:xt}):zt[Xt]=xt;var lt=(zt,Xt,xt)=>ci(zt,typeof Xt!="symbol"?Xt+"":Xt,xt);function vs(g){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(g){for(const i in g)if(i!=="default"){const o=Object.getOwnPropertyDescriptor(g,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:()=>g[i]})}}return t.default=g,Object.freeze(t)}const Ss=vs(bs);var H=(g=>(g.Proximity="Proximity",g.Magnetic="Magnetic",g.Repel="Repel",g.Orbit="Orbit",g.Vortex="Vortex",g.Fluid="Fluid",g.Elastic="Elastic",g.Holographic="Holographic",g.Sticky="Sticky",g.Dilation="Dilation",g.Parallax="Parallax",g.Noise="Noise",g.Float="Float",g.Pulse="Pulse",g.Draggable="Draggable",g.Scroll="Scroll",g.LookAt="LookAt",g.Glint="Glint",g.Scan="Scan",g.Ratchet="Ratchet",g.Jitter="Jitter",g.Follower="Follower",g.Wrap="Wrap",g.Typewriter="Typewriter",g.Scramble="Scramble",g.Wave="Wave",g.Bounce="Bounce",g.TextTrail="TextTrail",g.Reveal3D="Reveal3D",g.RevealSlide="RevealSlide",g.RevealBlur="RevealBlur",g.TextLiquid="TextLiquid",g.TextVortex="TextVortex",g.TextExplosion="TextExplosion",g.TextRain="TextRain",g.TextGravity="TextGravity",g.TextMatrix="TextMatrix",g.TextNeon="TextNeon",g.TextDissolve="TextDissolve",g.TextOrganic="TextOrganic",g.TextBreathe="TextBreathe",g.TextSpin="TextSpin",g.TextMagnet="TextMagnet",g.TextPerspective="TextPerspective",g.TextMirror="TextMirror",g.TextFloral="TextFloral",g.TextSmoke="TextSmoke",g.TextVariable="TextVariable",g.TextZing="TextZing",g.TextElastic="TextElastic",g.TextGlitch3D="TextGlitch3D",g.GlitchText="GlitchText",g.TextCounter="TextCounter",g.Squash="Squash",g.Spotlight="Spotlight",g.Lens="Lens",g.Gravity="Gravity",g.Velocity="Velocity",g.Shear="Shear",g.LayoutAnimation="LayoutAnimation",g.SpringChain="SpringChain",g.ParticleEmitter="ParticleEmitter",g.StateReactive="StateReactive",g.Fold="Fold",g.Crumple="Crumple",g))(H||{}),Qt=(g=>(g.Scale="Scale",g.Opacity="Opacity",g.RotateZ="RotateZ",g.RotateX="RotateX",g.RotateY="RotateY",g.PositionX="PositionX",g.PositionY="PositionY",g.SkewX="SkewX",g.Blur="Blur",g.Exposure="Exposure",g.HueShift="HueShift",g.Negative="Negative",g.CornerRadius="CornerRadius",g.StrokeWidth="StrokeWidth",g.BoxShadow="BoxShadow",g.FontSize="FontSize",g.LetterSpacing="LetterSpacing",g))(Qt||{}),je=(g=>(g.Equal="Equal",g.NotEqual="NotEqual",g.GreaterThan="GreaterThan",g.LessThan="LessThan",g.GreaterEqual="GreaterEqual",g.LessEqual="LessEqual",g.IsTrue="IsTrue",g.IsFalse="IsFalse",g))(je||{}),wt=(g=>(g.AND="AND",g.OR="OR",g.NOT="NOT",g.XOR="XOR",g.OBJECT="OBJECT",g.PROPERTY="PROPERTY",g.GET_PROPERTY="GET_PROPERTY",g.SET_PROPERTY="SET_PROPERTY",g.ADD="ADD",g.SUB="SUB",g.MUL="MUL",g.DIV="DIV",g.MOD="MOD",g.POW="POW",g.ABS="ABS",g.ROUND="ROUND",g.FLOOR="FLOOR",g.CEIL="CEIL",g.SIN="SIN",g.COS="COS",g.TAN="TAN",g.CLAMP="CLAMP",g.REMAP="REMAP",g.EQ="EQ",g.NEQ="NEQ",g.GT="GT",g.LT="LT",g.GTE="GTE",g.LTE="LTE",g.IF_ELSE="IF_ELSE",g.VALUE="VALUE",g.INPUT="INPUT",g.LOG="LOG",g.SCROLL_X="SCROLL_X",g.SCROLL_Y="SCROLL_Y",g.MOUSE_X="MOUSE_X",g.MOUSE_Y="MOUSE_Y",g.IS_MOUSE_DOWN="IS_MOUSE_DOWN",g.EFFECTOR="EFFECTOR",g.MONITOR="MONITOR",g.DELAY="DELAY",g.SPRING_PULL="SPRING_PULL",g.SPRING_SETTLE="SPRING_SETTLE",g.EMIT="EMIT",g))(wt||{});function Cs(g){if(g.length<5)return g;const t=new Set("aeiouyAEIOUY".split(""));if(/[\u4E00-\u9FFF\u3400-\u4DBF]/.test(g))return g;let o="";for(let e=0;e<g.length;e++){if(o+=g[e],e>=g.length-2)continue;const s=t.has(g[e]),n=t.has(g[e+1]),a=t.has(g[e+2]);s&&!n&&a&&(o+="­"),s&&!n&&!a&&e>=1&&(o+="­")}return o}function ws(g){return g.replace(/\b([a-zA-Z]{4,})\b/g,(t,i)=>Cs(i))}function Ms(g,t,i){return g}function Is(g,t,i){return g}const We=new Map;function ts(g){var I;const{text:t,fontFamily:i="Inter",fontSize:o=16,fontWeight:e=400,fontStyle:s="normal",lineHeight:n=1.2,width:a=200,letterSpacing:r=0,paragraphSpacing:f=0,paragraphIndent:h=0,textCase:l="none",segments:p=[],enableSegments:c=!1}=g;let d=String(t||"");l==="uppercase"?d=d.toUpperCase():l==="lowercase"?d=d.toLowerCase():l==="capitalize"&&(d=d.replace(/\b\w/g,k=>k.toUpperCase())),g.hyphenation===!0&&(d=ws(d));const u=`${s} ${e} ${o}px "${i}", sans-serif`,v=`${d}|${u}|${r}|${f}|${h}|${c}|${JSON.stringify(p)}|hyp:${!!g.hyphenation}|comp:${g.composer}|bal:${!!g.balanceRaggedLines}`;let b=We.get(v);const y=typeof CanvasRenderingContext2D<"u"?CanvasRenderingContext2D.prototype.measureText:null,m=function(k){if(!y)return{width:0,fontBoundingBoxAscent:0,fontBoundingBoxDescent:0};const T=y.call(this,k);return r!==0&&k&&k.length>0?{...T,width:T.width+(k.length-1)*r}:T};if(!b){try{if(r!==0&&typeof CanvasRenderingContext2D<"u"&&(CanvasRenderingContext2D.prototype.measureText=m),c&&p&&p.length>0){const k=p.map(T=>{let O=T.text||"";const P=T.textCase||l||"none";return P==="uppercase"?O.toUpperCase():P==="lowercase"?O.toLowerCase():P==="capitalize"?O.replace(/\b\w/g,_=>_.toUpperCase()):O}).join("");if(b=ze.prepareWithSegments(k,u),b){let T=0,O=o;for(const P of p){let _=P.text||"";if(!_)continue;const E=P.textCase||l||"none";E==="uppercase"?_=_.toUpperCase():E==="lowercase"?_=_.toLowerCase():E==="capitalize"&&(_=_.replace(/\b\w/g,Y=>Y.toUpperCase()));const A=P.fontSize||o;A>O&&(O=A);const W=`${P.fontStyle||s} ${P.fontWeight||e} ${A}px "${P.fontFamily||i}", sans-serif`,z=ze.prepareWithSegments(_,W);if(z&&z.widths)for(let Y=0;Y<z.widths.length;Y++){const G=T+Y;if(G<b.widths.length){b.widths[G]=z.widths[Y];const N=z.kinds[Y];if(N===2){const J=_[Y];J===`
2
+ `||J==="\r"?b.kinds[G]=2:b.kinds[G]=0}else b.kinds[G]=N}}T+=_.length}b.fullText=k,b.maxFontSize=O}}else b=ze.prepareWithSegments(d,u);b&&We.set(v,b)}catch(k){return console.error("[ExodeUI] Pretext prepare failed:",k),{width:a,height:0,lineCount:0,lines:[]}}finally{r!==0&&typeof CanvasRenderingContext2D<"u"&&y&&(CanvasRenderingContext2D.prototype.measureText=y)}if(We.size>500){const k=We.keys().next().value;k&&We.delete(k)}}if(h>0&&b&&b.widths&&!b.indentApplied){const k=[...b.widths],T=b.fullText||d;let O=!0;for(let P=0;P<T.length;P++)O&&k[P]!==void 0&&(k[P]+=h,O=!1),(T[P]===`
3
3
  `||T[P]==="\r")&&(O=!0,T[P]==="\r"&&T[P+1]===`
4
- `&&P++);b={...b,widths:k,indentApplied:!0}}if(!b)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=y);let C;try{const k=b.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=ze.layoutWithLines(b,a,S*k)}finally{r!==0&&m&&(CanvasRenderingContext2D.prototype.measureText=m)}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(f>0&&C&&C.lines&&C.lines.length>1){let k=0;const T=b.fullText||t;for(let O=0;O<C.lines.length-1;O++)k+=C.lines[O].text.length,(T[k]===`
4
+ `&&P++);b={...b,widths:k,indentApplied:!0}}if(!b)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=m);let C;try{const k=b.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=ze.layoutWithLines(b,a,S*k)}finally{r!==0&&y&&(CanvasRenderingContext2D.prototype.measureText=y)}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(f>0&&C&&C.lines&&C.lines.length>1){let k=0;const T=b.fullText||t;for(let O=0;O<C.lines.length-1;O++)k+=C.lines[O].text.length,(T[k]===`
5
5
  `||T[k]==="\r")&&(w+=f,k++,T[k-1]==="\r"&&T[k]===`
6
- `&&k++)}let M=(C==null?void 0:C.lines)||[];return g.composer==="every-line"&&M.length>1&&(M=Ms(M)),g.balanceRaggedLines===!0&&M.length>1&&(M=Is(M)),{width:a,height:w,lineCount:M.length,lines:M}}function es(g,t,i){let o=String(g||"").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),s=new Array(e.length).fill(0);let n=t-(e.length-1)*i,a=0;if(e.forEach((r,f)=>{if(r.endsWith("px")){const h=parseFloat(r);s[f]=h,n-=h}else r.endsWith("fr")?a+=parseFloat(r):r==="auto"&&(s[f]=100,n-=100)}),a>0&&n>0){const r=n/a;e.forEach((f,h)=>{f.endsWith("fr")&&(s[h]=r*parseFloat(f))})}return s}function ss(g,t,i){try{const o=g.autoLayout;return!o||!o.enabled?{childUpdates:[]}:(o.mode||"linear")==="grid"?Ts(g,t,i):ks(g,t,i)}catch(o){return console.error("Layout Engine Error:",o),{childUpdates:[]}}}function ks(g,t,i){var _,E;const o=g.autoLayout,{direction:e,spacing:s,padding:n,align:a,wrap:r}=o,f=e==="vertical",h=t.map(A=>{const W=i(A.id),z=A.geometry;let Y=(W==null?void 0:W.width)??z.width??100,G=(W==null?void 0:W.height)??z.height??100;if(z.type==="Ellipse"||z.type==="Polygon"||z.type==="Star"){const N=(W==null?void 0:W.radius)??z.radius??(W==null?void 0:W.outer_radius)??z.outer_radius??50;Y=N*2,G=N*2}else if(z.type==="Text"){const N=ts({text:(W==null?void 0:W.text)??z.text??"",fontFamily:z.fontFamily,fontSize:z.fontSize,fontWeight:z.fontWeight,fontStyle:z.fontStyle,lineHeight:z.lineHeight,width:z.width||200,letterSpacing:z.letterSpacing,paragraphSpacing:z.paragraphSpacing,paragraphIndent:z.paragraphIndent,textCase:z.textCase,segments:z.segments,enableSegments:z.enableSegments});G=N.height,z.width||(Y=N.width)}return Y*=A.transform.scale_x||1,G*=A.transform.scale_y||1,{id:A.id,w:Y,h:G,original:A}});let l=g.width,p=g.height;const c=((_=g.layoutProps)==null?void 0:_.width)==="hug",d=((E=g.layoutProps)==null?void 0:E.height)==="hug",u=[];let v=[],b=0,m=0;const y=l-n.left-n.right,S=p-n.top-n.bottom;h.forEach(A=>{r&&v.length>0&&(f?m+s+A.h>S:b+s+A.w>y)?(u.push({children:v,width:b,height:m}),v=[A],b=A.w,m=A.h):(v.push(A),f?(b=Math.max(b,A.w),m+=(v.length>1?s:0)+A.h):(b+=(v.length>1?s:0)+A.w,m=Math.max(m,A.h)))}),v.length>0&&u.push({children:v,width:b,height:m}),c&&!f&&(l=Math.max(...u.map(A=>A.width),0)+n.left+n.right),d&&f&&(p=Math.max(...u.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-"),P=I.startsWith("bottom-");return u.forEach(A=>{let W=w,z=M;f?O?z=n.top+(p-n.top-n.bottom-A.height)/2:P&&(z=p-n.bottom-A.height):k?W=n.left+(l-n.left-n.right-A.width)/2:T&&(W=l-n.right-A.width),A.children.forEach(Y=>{var R,j;let G=W,N=z;f?k?G+=(A.width-Y.w)/2:T&&(G+=A.width-Y.w):O?N+=(A.height-Y.h)/2:P&&(N+=A.height-Y.h);const J=((R=Y.original.layoutProps)==null?void 0:R.width)==="fill",x=((j=Y.original.layoutProps)==null?void 0:j.height)==="fill";C.push({id:Y.id,x:G+Y.w/2-l/2,y:N+Y.h/2-p/2,width:J&&f?A.width:void 0,height:x?f?void 0:A.height:void 0}),f?z+=Y.h+s:W+=Y.w+s}),f?w+=A.width+s:M+=A.height+s}),{frameWidth:c?l:void 0,frameHeight:d?p:void 0,childUpdates:C}}function Ts(g,t,i){const o=g.autoLayout;if(!o)return{childUpdates:[]};const{gridColumns:e,gridRows:s,columnGap:n=0,rowGap:a=0,padding:r,align:f}=o;let h=g.width,l=g.height;const p=h-r.left-r.right,c=l-r.top-r.bottom,d=es(e||"1fr",p,n),u=es(s||"auto",c,a),v=d.length>0?d.reduce((T,O)=>T+O,0)+(d.length-1)*n:0,b=u.length>0?u.reduce((T,O)=>T+O,0)+(u.length-1)*a:0,m=f.toLowerCase(),y=m==="center"||m.endsWith("-center"),S=m.endsWith("-right"),C=m==="center"||m.startsWith("center-"),w=m.startsWith("bottom-");let M=0,I=0;y?M=(p-v)/2:S&&(M=p-v),C?I=(c-b)/2:w&&(I=c-b);const k=[];return t.forEach((T,O)=>{var j,X;const P=O%d.length||0,_=Math.floor(O/d.length)||0;_>=u.length&&u.push(100);const E=d[P],A=u[_];let W=r.left+M+d.slice(0,P).reduce((tt,L)=>tt+L+n,0),z=r.top+I+u.slice(0,_).reduce((tt,L)=>tt+L+a,0);const Y=i(T.id),G=T.geometry;let N=(Y==null?void 0:Y.width)??G.width??100,J=(Y==null?void 0:Y.height)??G.height??100;if(G.type==="Ellipse"||G.type==="Polygon"||G.type==="Star"){const tt=(Y==null?void 0:Y.radius)??G.radius??(Y==null?void 0:Y.outer_radius)??G.outer_radius??50;N=tt*2,J=tt*2}N*=T.transform.scale_x||1,J*=T.transform.scale_y||1;let x=W,R=z;y?x+=(E-N)/2:S&&(x+=E-N),C?R+=(A-J)/2:w&&(R+=A-J),k.push({id:T.id,x:x+N/2-h/2,y:R+J/2-l/2,width:((j=T.layoutProps)==null?void 0:j.width)==="fill"?E:void 0,height:((X=T.layoutProps)==null?void 0:X.height)==="fill"?A:void 0})}),{childUpdates:k}}class is{constructor(){lt(this,"world",null);lt(this,"bodies",new Map);lt(this,"colliders",new Map);lt(this,"joints",new Map);lt(this,"initialized",!1);lt(this,"bodyIdByCollider",new Map);lt(this,"onCollisionCB",null);lt(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 i=t.isStatic?Jt.RigidBodyDesc.fixed():Jt.RigidBodyDesc.dynamic();i.setTranslation(t.x,t.y),t.rotation!==void 0&&i.setRotation(t.rotation);const o=this.world.createRigidBody(i);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 s=this.world.createCollider(e,o);this.bodyIdByCollider.set(s.handle,t.id),t.frictionAir!==void 0&&o.setLinearDamping(t.frictionAir*10),this.bodies.set(t.id,o),this.colliders.set(t.id,s)}removeBody(t){const i=this.bodies.get(t),o=this.colliders.get(t);o&&this.bodyIdByCollider.delete(o.handle),i&&this.world&&(this.world.removeRigidBody(i),this.bodies.delete(t),this.colliders.delete(t))}step(t){if(!this.world)return;this.world.step(this.eventQueue);const i=this.onCollisionCB,o=this.eventQueue;i&&o&&o.drainContactEvents((e,s,n)=>{const a=this.bodyIdByCollider.get(e),r=this.bodyIdByCollider.get(s);a&&r&&i(a,r,n)})}getPosition(t){const i=this.bodies.get(t);if(!i)return null;const o=i.translation();return{x:o.x,y:o.y}}getRotation(t){const i=this.bodies.get(t);return i?i.rotation():null}getVelocity(t){const i=this.bodies.get(t);if(!i)return null;const o=i.linvel();return{x:o.x,y:o.y}}setPosition(t,i,o){const e=this.bodies.get(t);e&&e.setTranslation(new Jt.Vector2(i,o),!0)}setRotation(t,i){const o=this.bodies.get(t);o&&o.setRotation(i,!0)}setVelocity(t,i,o){const e=this.bodies.get(t);e&&e.setLinvel(new Jt.Vector2(i,o),!0)}setAngularVelocity(t,i){const o=this.bodies.get(t);o&&o.setAngvel(i,!0)}applyForce(t,i,o){const e=this.bodies.get(t);e&&e.addForce(new Jt.Vector2(i,o),!0)}applyImpulse(t,i,o){const e=this.bodies.get(t);e&&e.applyImpulse(new Jt.Vector2(i,o),!0)}createJoint(t){if(!this.world){console.warn("[RapierPhysics] World not initialized");return}this.joints.has(t.id)&&this.removeJoint(t.id);const i=this.bodies.get(t.bodyA),o=this.bodies.get(t.bodyB);if(!i||!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),s=new Jt.Vector2(t.anchorB.x,t.anchorB.y);let n;if(t.type==="Distance"){const a=t.length??100,r=t.stiffness??100,f=t.damping??10;n=Jt.JointData.spring(a,r,f,e,s)}else n=Jt.JointData.revolute(e,s);try{const a=this.world.createImpulseJoint(n,i,o,!0);this.joints.set(t.id,a)}catch(a){console.error(`[RapierPhysics] Failed to create joint ${t.id}:`,a)}}removeJoint(t){const i=this.joints.get(t);if(i&&this.world){try{this.world.removeImpulseJoint(i,!0)}catch(o){console.error(`[RapierPhysics] Failed to remove joint ${t}:`,o)}this.joints.delete(t)}}}const ns=g=>g,_s=g=>g>0?1:0,Ps=g=>g<1?0:1,os=g=>g*g,as=g=>g*(2-g),rs=g=>g<.5?2*g*g:-1+(4-2*g)*g,Es=g=>g*g*g,As=g=>--g*g*g+1,xs=g=>g<.5?4*g*g*g:(g-1)*(2*g-2)*(2*g-2)+1,Os=g=>g*g*g*g,Ls=g=>1- --g*g*g*g,Fs=g=>g<.5?8*g*g*g*g:1-8*--g*g*g*g,Rs=g=>g*g*g*g*g,$s=g=>1+--g*g*g*g*g,Bs=g=>g<.5?16*g*g*g*g*g:1+16*--g*g*g*g*g,Ws=g=>1-Math.cos(g*Math.PI/2),Ys=g=>Math.sin(g*Math.PI/2),Xs=g=>-(Math.cos(Math.PI*g)-1)/2,Ds=g=>g===0?0:Math.pow(2,10*(g-1)),Gs=g=>g===1?1:1-Math.pow(2,-10*g),zs=g=>g===0?0:g===1?1:g<.5?Math.pow(2,20*g-10)/2:(2-Math.pow(2,-20*g+10))/2,Vs=g=>1-Math.sqrt(1-g*g),Ns=g=>Math.sqrt(1- --g*g),Hs=g=>g<.5?(1-Math.sqrt(1-4*g*g))/2:(Math.sqrt(1-(-2*g+2)*(-2*g+2))+1)/2,Ve=1.70158,Ne=Ve*1.525,ls=Ve+1,Us=g=>ls*g*g*g-Ve*g*g,qs=g=>1+ls*Math.pow(g-1,3)+Ve*Math.pow(g-1,2),Ks=g=>g<.5?Math.pow(2*g,2)*((Ne+1)*2*g-Ne)/2:(Math.pow(2*g-2,2)*((Ne+1)*(g*2-2)+Ne)+2)/2,cs=2*Math.PI/3,fs=2*Math.PI/4.5,Js=g=>g===0?0:g===1?1:-Math.pow(2,10*g-10)*Math.sin((g*10-10.75)*cs),Qs=g=>g===0?0:g===1?1:Math.pow(2,-10*g)*Math.sin((g*10-.75)*cs)+1,Zs=g=>g===0?0:g===1?1:g<.5?-(Math.pow(2,20*g-10)*Math.sin((20*g-11.125)*fs))/2:Math.pow(2,-20*g+10)*Math.sin((20*g-11.125)*fs)/2+1,He=g=>g<1/2.75?7.5625*g*g:g<2/2.75?7.5625*(g-=1.5/2.75)*g+.75:g<2.5/2.75?7.5625*(g-=2.25/2.75)*g+.9375:7.5625*(g-=2.625/2.75)*g+.984375,js=g=>1-He(1-g),ti=He,ei=g=>g<.5?(1-He(1-2*g))/2:(1+He(2*g-1))/2,Ze=new Map,Ye=(g,t,i,o)=>{const e=`${g},${t},${i},${o}`;if(Ze.has(e))return Ze.get(e);const s=h=>(1-3*i+3*g)*h*h*h+(3*i-6*g)*h*h+3*g*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*i+3*g)*h*h+2*(3*i-6*g)*h+3*g,r=h=>{let l=h;for(let p=0;p<8;p++){const c=s(l)-h;if(Math.abs(c)<1e-6)return l;const d=a(l);if(Math.abs(d)<1e-6)break;l=l-c/d}return l},f=h=>h===0?0:h===1?1:n(r(h));return Ze.set(e,f),f},hs=g=>{const t=g.match(/cubic-bezier\s*\(\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*\)/);if(!t)return null;const[,i,o,e,s]=t.map(Number);return Ye(i,o,e,s)},ds={ease:Ye(.25,.1,.25,1),"ease-in":Ye(.42,0,1,1),"ease-out":Ye(0,0,.58,1),"ease-in-out":Ye(.42,0,.58,1)},Ue={Linear:ns,EaseInQuad:os,EaseOutQuad:as,EaseInOutQuad:rs,EaseInCubic:Es,EaseOutCubic:As,EaseInOutCubic:xs,EaseInQuart:Os,EaseOutQuart:Ls,EaseInOutQuart:Fs,EaseInQuint:Rs,EaseOutQuint:$s,EaseInOutQuint:Bs,EaseInSine:Ws,EaseOutSine:Ys,EaseInOutSine:Xs,EaseInExpo:Ds,EaseOutExpo:Gs,EaseInOutExpo:zs,EaseInCirc:Vs,EaseOutCirc:Ns,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:_s,StepEnd:Ps},si=g=>{const t=g.trim(),i=t.toLowerCase();if(Ue[t])return Ue[t];const o=Object.keys(Ue).find(s=>s.toLowerCase()===i);if(o)return Ue[o];const e=Object.keys(us).find(s=>s.toLowerCase()===i);if(e){const s=hs(us[e].value);if(s)return s}if(ds[i])return ds[i];if(i.startsWith("cubic-bezier")){const s=hs(t);if(s)return s}return ns},us={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=(g,t,i,o,e)=>{if(!g||!t||!i)return g;const s=o.scale_x??1,n=o.scale_y??1,a=(r,f,h)=>{let l=0,p=0;const c=o.rotation*Math.PI/180,d=Math.cos(c),u=Math.sin(c),v=r*s*d-f*n*u+o.x,b=r*s*u+f*n*d+o.y;h.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=i[I.boneId]||[1,0,0,1,0,0],P=v*O[0]+b*O[2]+O[4],_=v*O[1]+b*O[3]+O[5],E=T.rotation*Math.PI/180,A=Math.cos(E),W=Math.sin(E),z=P*T.scaleX*A-_*T.scaleY*W+T.x,Y=P*T.scaleX*W+_*T.scaleY*A+T.y;l+=z*I.amount,p+=Y*I.amount});const m=[...h].sort((I,k)=>k.amount-I.amount);if(m.length>=2&&m[0].amount>0&&m[1].amount>0){const I=e(m[0].boneId),k=e(m[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,P=I.x-T*Math.sin(O),_=I.y+T*Math.cos(O),E=k.length*(k.scale_y??1),A=k.rotation*Math.PI/180,W=k.x-E*Math.sin(A),z=k.y+E*Math.cos(A);let Y=null,G=null,N=!1;const J=1;if(Math.hypot(I.x-k.x,I.y-k.y)<J||Math.hypot(I.x-W,I.y-z)<J?(Y=I.x,G=I.y):(Math.hypot(P-k.x,_-k.y)<J||Math.hypot(P-W,_-z)<J)&&(Y=P,G=_,N=!0),Y!==null&&G!==null){const x=i[m[0].boneId]||[1,0,0,1,0,0],R=x[0]*x[3]-x[1]*x[2];let j=0,X=0;if(R!==0){const tt=(x[2]*x[5]-x[3]*x[4])/R,L=(x[1]*x[4]-x[0]*x[5])/R,F=Math.atan2(-x[1],x[3]);if(!N)j=tt,X=L;else{const ot=-x[2]/R,yt=x[0]/R,bt=Math.hypot(ot,yt),gt=I.length*bt;j=tt-gt*Math.sin(F),X=L+gt*Math.cos(F)}const D=Math.hypot(v-j,b-X),q=Math.hypot(l-Y,p-G);if(q>0&&D>0){const ot=Math.max(q,.01),yt=Math.min(D/ot,3),bt=Y+(l-Y)*yt,gt=G+(p-G)*yt,Et=m[0].amount,It=m[1].amount,St=Math.min(Et,It)*2,zt=1-Math.pow(1-St,4);l=l*(1-zt)+bt*zt,p=p*(1-zt)+gt*zt}}}}}const y=o.rotation*Math.PI/180,S=Math.cos(y),C=Math.sin(y),w=l-o.x,M=p-o.y;return{x:(w*S+M*C)/s,y:(-w*C+M*S)/n}};return g.map((r,f)=>{const h=t[f];if(!h||h.length===0)return{...r};const l={...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);l.in_x=p.x,l.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);l.out_x=p.x,l.out_y=p.y}return l})},ps={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 ms{constructor(){lt(this,"artboard",null);lt(this,"objectStates",new Map);lt(this,"physicsEngine",null);lt(this,"activeStateMachine",null);lt(this,"inputs",new Map);lt(this,"inputNameMap",new Map);lt(this,"layerStates",new Map);lt(this,"pretextCache",new Map);lt(this,"pointerHistory",[]);lt(this,"MAX_HISTORY",200);lt(this,"imageCache",new Map);lt(this,"lastValidSvgImgMap",new Map);lt(this,"maskBuffer",null);lt(this,"maskCtx",null);lt(this,"lumaBuffer",null);lt(this,"lumaCtx",null);lt(this,"_noiseTileCanvas",null);lt(this,"layout",{fit:"Contain",alignment:"Center"});lt(this,"onTrigger");lt(this,"onInputUpdate");lt(this,"onComponentChange");lt(this,"onToggle");lt(this,"onInputChange");lt(this,"onInputFocus");lt(this,"onInputBlur");lt(this,"onLog");lt(this,"onButtonClick");lt(this,"onGraphPointClick");lt(this,"justFiredTriggers",new Set);lt(this,"rootTransform",null);lt(this,"canvasWidth",0);lt(this,"canvasHeight",0);lt(this,"lastHoveredObjectId",null);lt(this,"_lastPointerPos",null);lt(this,"_prevPointerPos",null);lt(this,"_mouseDelta",{dx:0,dy:0});lt(this,"focusedId",null);lt(this,"draggingSliderId",null);lt(this,"draggingJoystickId",null);lt(this,"activeDropdownId",null);lt(this,"activeObjectId",null);lt(this,"draggingListViewId",null);lt(this,"scrollOffset",{x:0,y:0});lt(this,"_totalScroll",{x:0,y:0});lt(this,"draggingBehaviors",new Set);lt(this,"isMouseDown",!1);lt(this,"activeKeys",new Set);lt(this,"_layoutAnimCache",new Map);lt(this,"_springChainState",new Map);lt(this,"_emitterPools",new Map);lt(this,"objectVelocities",new Map);lt(this,"currentTime",0);lt(this,"frameCount",0);lt(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});lt(this,"onLogicUpdate");lt(this,"logicNodeValues",new Map);lt(this,"logicNodeState",new Map);lt(this,"pointerDownTimes",new Map);lt(this,"activeHoverIds",new Set);lt(this,"onNavigation");lt(this,"periodicTriggerTimes",new Map);lt(this,"wasInView",new Set);lt(this,"scrollProgressLastValue",new Map);lt(this,"debug_objectsRendered",0);lt(this,"debug_objectsTotal",0);lt(this,"lastRenderTime",0);lt(this,"debugMode",!1);lt(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:i,isClosed:o}=this.svgPathToPoints(t.data);t.points=i,t.is_closed===void 0&&(t.is_closed=o)}svgPathToPoints(t){const i=/([MLHVCSQTAZmlhvcsqtaz])([^MLHVCSQTAZmlhvcsqtaz]*)/g,o=/[-+]?(?:\d*\.\d+|\d+)(?:[eE][-+]?\d+)?/g,e=[];let s=!1,n=0,a=0,r=0,f=0,h=0,l=0,p;for(;(p=i.exec(t))!==null;){const c=p[1],d=(p[2].match(o)||[]).map(parseFloat),u=c===c.toLowerCase(),v=c.toUpperCase();let b=0;const m=S=>{let C=d[b++];return u&&(C+=S?n:a),C},y=()=>({x:m(!0),y:m(!1)});switch(v){case"M":{const S=y();for(h=n=S.x,l=a=S.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a,moveTo:!0});b<d.length;){const C=y();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(;b<d.length;){const S=y();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(;b<d.length;)n=m(!0),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"V":for(;b<d.length;)a=m(!1),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"C":for(;b<d.length;){const S=y(),C=y(),w=y();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,f=C.y}break;case"S":for(;b<d.length;){const S={x:2*n-r,y:2*a-f},C=y(),w=y();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,f=C.y}break;case"Q":for(;b<d.length;){const S=y(),C=y();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,f=S.y}break;case"T":for(;b<d.length;){const S={x:2*n-r,y:2*a-f},C=y();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,f=S.y}break;case"Z":if(s=!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=l;break;default:if(d.length>=2){const S=y();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:s}}setOnLogCallback(t){this.onLog=t}debugLog(t){this.onLog&&this.onLog(t)}setInputFocusCallback(t){this.onInputFocus=t}setInputBlurCallback(t){this.onInputBlur=t}updateConstraint(t,i,o){var s;const e=(s=this.artboard)==null?void 0:s.objects.find(n=>n.id===t);e&&e.constraints&&e.constraints[i]&&(e.constraints[i]={...e.constraints[i],...o},o.useSpring===!1&&this.objectVelocities.delete(t))}log(...t){this.debugMode&&console.log(...t)}warn(...t){this.debugMode&&console.warn(...t)}setInternalInput(t,i){this.inputs.set(t,i),this.onInputUpdate&&this.onInputUpdate(t,i)}setLayout(t,i){this.layout={fit:t,alignment:i}}getActiveStateIds(t="Base Layer"){const i=this.layerStates.get(t);return i?i.currentStateIds:[]}getObjectState(t){return this.objectStates.get(t)}updateObjectOptions(t,i){const o=this.objectStates.get(t);o&&(o.options={...o.options,...i})}updateGraphData(t,i){var e,s;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:i,lineColor:"#3b82f6",lineWidth:2,showArea:!1}]:n.datasets[0].data=i;const a=this.objectStates.get(o.id);a&&((s=a.geometry)==null?void 0:s.type)==="LineGraph"&&(!a.geometry.datasets||a.geometry.datasets.length===0?a.geometry.datasets=JSON.parse(JSON.stringify(n.datasets)):a.geometry.datasets[0].data=[...i]),n.datasets[0].inputId&&this.updateInput(n.datasets[0].inputId,i)}else this.updateInput(t,i)}load(t){var n,a;if(!t)return;let i=this.decompressStrings(t);const o=[],e=new Set,s=r=>{r&&r.forEach(f=>{if(e.has(f.id))return;const h={...f},l=h.childrenObjects||[];e.add(h.id),o.push(h),s(l)})};if(s(i.objects||[]),o.length>(i.objects||[]).length&&this.log(`[Engine] Flattened artboard from ${(i.objects||[]).length} to ${o.length} objects.`),i.objects=o,this.artboard=i,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(f=>{r.set(f.id,f),f.children||(f.children=[])}),this.artboard.objects.forEach(f=>{if(f.parentId){const h=r.get(f.parentId);h&&(h.children||(h.children=[]),h.children.includes(f.id)||h.children.push(f.id))}})}this.loadFonts(),this.preloadImages(this.artboard),this.reset(),this.advance(0)}preloadImages(t){if(!t||!t.objects)return;const i=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=s=>{console.error("[ExodeUI Preload] failed:",s,`Src: ${o.substring(0,80)}...`)},e.src=o,this.imageCache.set(o,e)};t.objects.forEach(o=>{var e,s,n;(e=o.geometry)!=null&&e.src&&i(o.geometry.src),(n=(s=o.style)==null?void 0:s.fill)!=null&&n.src&&i(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 i={};for(const[o,e]of Object.entries(t))i[o]=this.decompressStrings(e);return i}return Array.isArray(t)?t.map(i=>this.decompressStrings(i)):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(i=>{var n,a,r,f,h,l,p;const o=i.width??((n=i.geometry)==null?void 0:n.width)??0,e=i.height??((a=i.geometry)==null?void 0:a.height)??0,s=i.cornerRadius??i.corner_radius??((r=i.geometry)==null?void 0:r.corner_radius)??((f=i.geometry)==null?void 0:f.cornerRadius)??0;this.objectStates.set(i.id,{...i.transform||{},x:((h=i.transform)==null?void 0:h.x)??i.x??0,y:((l=i.transform)==null?void 0:l.y)??i.y??0,width:o,height:e,cornerRadius:s,corner_radius:s,clipContent:i.clipContent??!1,autoLayout:i.autoLayout?JSON.parse(JSON.stringify(i.autoLayout)):void 0,layoutProps:i.layoutProps?JSON.parse(JSON.stringify(i.layoutProps)):void 0,opacity:((p=i.transform)==null?void 0:p.opacity)!==void 0?i.transform.opacity:i.opacity!==void 0?i.opacity:100,visible:i.visible!==void 0?i.visible:i.isVisible!==void 0?i.isVisible:!0,blendMode:i.blendMode||"Normal",style:JSON.parse(JSON.stringify(i.style||{})),geometry:JSON.parse(JSON.stringify(i.geometry||{})),options:i.options?JSON.parse(JSON.stringify(i.options)):{},masks:i.masks?JSON.parse(JSON.stringify(i.masks)):[],zIndex:i.zIndex!==void 0?i.zIndex:void 0})}),this.artboard.objects.some(i=>{var o;return(o=i.physics)==null?void 0:o.enabled})){this.physicsEngine=new is;const i=this.artboard.physics?{x:this.artboard.physics.gravity.x,y:this.artboard.physics.gravity.y}:{x:0,y:1};this.physicsEngine.init(i).then(()=>{var o;this.physicsEngine&&((o=this.artboard)==null||o.objects.forEach(e=>{var s,n;if((s=e.physics)!=null&&s.enabled&&e.type==="Shape"){const a=this.objectStates.get(e.id);if(!a)return;const r=e.geometry.width||100,f=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:f,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(i=>{this.inputs.set(i.id,i.value);const o=this.inputNameMap.get(i.name)||[];o.includes(i.id)||o.push(i.id),this.inputNameMap.set(i.name,o)}),this.artboard.stateMachine&&(this.activeStateMachine=this.artboard.stateMachine,this.activeStateMachine.inputs.forEach(i=>{this.inputs.set(i.id,i.value.value);const o=this.inputNameMap.get(i.name)||[];o.push(i.id),this.inputNameMap.set(i.name,o)}),this.activeStateMachine.layers.forEach(i=>{let o=i.states.find(e=>e.id===i.entryStateId);!o&&i.states.length>0&&(console.warn(`[ExodeUI] Invalid entryStateId "${i.entryStateId}" in layer "${i.name}". Falling back to first state.`),o=i.states[0]),o&&this.enterStates(i.name,[o.id])}),this.evaluateTransitions()),this.initGlobalAnimationTriggers(),this.updateAutoLayout(!0),this.loadFonts()}updateAutoLayout(t=!1){var s;if(!this.artboard)return;const i=new Map;this.artboard.objects.forEach(n=>i.set(n.id,n));const o=.15,e=n=>{n.forEach(a=>{const r=this.objectStates.get(a.id);if(r){const f=Math.abs(r.x-a.x),h=Math.abs(r.y-a.y);!t&&(f>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((s=this.artboard.autoLayout)!=null&&s.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(l=>i.get(l)).filter(l=>!!l),f=this.objectStates.get(n.id);if(!f)return;const h=ss(f,r,l=>this.objectStates.get(l));h.frameWidth!==void 0&&(f.width=h.frameWidth),h.frameHeight!==void 0&&(f.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 i="";t.forEach(n=>{const a=n.replace(/ /g,"+");i+=`&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(i.length>0){const n=`https://fonts.googleapis.com/css2?display=swap${i}`;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 s=[];if(t.forEach(n=>{n.toLowerCase().includes("clash display")&&s.push("clash-display@200,300,400,500,600,700")}),s.length>0){const n=`https://api.fontshare.com/v2/css?f[]=${s.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,i){var n;if(i.length===0)return;const o=this.layerStates.get(t);if(o&&o.currentStateIds.length===i.length&&i.every(r=>o.currentStateIds.includes(r))&&this.justFiredTriggers.size===0)return;const e=[];let s=0;if(this.artboard&&this.activeStateMachine){const a=this.activeStateMachine.layers.find(r=>r.name===t);if(a)for(const r of i){const f=a.states.find(h=>h.id===r);if(f)if(f.isBlendState&&f.blendAnimations&&f.blendAnimations.length>0)e.push({animation:null,state:f}),f.blendAnimations.forEach(h=>{const l=this.artboard.animations.find(p=>p.id===h.animationId);l&&(s=Math.max(s,l.duration))});else{let h=null;f.animationId&&(h=this.artboard.animations.find(l=>l.id===f.animationId)||null),h||(h=this.artboard.animations.find(l=>{var p,c;return l.name===f.name||l.id===f.name||(f.name==="Entry"||f.id==="entry")&&(((p=l.name)==null?void 0:p.toLowerCase())==="onload"||((c=l.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:f}),s=Math.max(s,h.duration)))}}}this.layerStates.set(t,{currentStateIds:i,animations:e,time:0,duration:s})}setInputBool(t,i){this.updateInput(t,i)}setInputNumber(t,i){this.updateInput(t,i)}fireTrigger(t){this.updateInput(t,!0)}setInputText(t,i){this.updateInput(t,i)}setInputNumberArray(t,i){this.updateInput(t,i)}setInputStringArray(t,i){this.updateInput(t,i)}updateObjectProperty(t,i,o){const e=this.objectStates.get(t);if(e)if(i.includes(".")){const s=i.split(".");let n=e;for(let a=0;a<s.length-1;a++)n[s[a]]||(n[s[a]]={}),n=n[s[a]];n[s[s.length-1]]=o}else e[i]=o}updateInput(t,i){var n,a,r;let o;if(this.inputs.has(t)){const f=(n=this.activeStateMachine)==null?void 0:n.inputs.find(h=>h.id===t);f&&typeof f.value=="object"&&(o=f.value.type)}else{const f=this.inputNameMap.get(t);if(f&&f.length>0){const h=(a=this.activeStateMachine)==null?void 0:a.inputs.find(l=>l.id===f[0]);h&&typeof h.value=="object"&&(o=h.value.type)}}let e=i;o==="Trigger"&&(i===1?e=!0:i===0&&(e=!1)),this.inputs.has(t)&&this.setInternalInput(t,e);const s=this.inputNameMap.get(t);s&&s.forEach(f=>this.setInternalInput(f,e)),o==="Trigger"&&e===!0&&(this.justFiredTriggers.add(t),s&&s.forEach(f=>this.justFiredTriggers.add(f))),Array.isArray(e)&&((r=this.artboard)==null||r.objects.forEach(f=>{if(f.inputId===t||f.name===t){const h=this.objectStates.get(f.id);h&&h.options&&(f.type==="ListView"||f.variant==="listview"?h.options.items=e:(f.type==="Dropdown"||f.variant==="dropdown")&&(h.options.optionsList=e))}})),this.evaluateTransitions(),this.evaluateVariableTriggers(t,e)}evaluateVariableTriggers(t,i){if(!this.artboard)return;const o=this.artboard.animationFlow||[],e=this.inputNameMap.get(t);o.forEach(s=>{if(s.trigger==="variable"&&s.conditionVariableId&&s.targetAnimationId&&(s.conditionVariableId===t||e&&e.includes(s.conditionVariableId))){const a=s.conditionOperator||"IsTrue",r=s.conditionValue;let f=!1;switch(a){case"Equal":case"==":f=i==r;break;case"NotEqual":case"!=":f=i!=r;break;case"GreaterThan":case">":f=i>r;break;case"LessThan":case"<":f=i<r;break;case"GreaterEqual":case">=":f=i>=r;break;case"LessEqual":case"<=":f=i<=r;break;case"IsTrue":f=!!i;break;case"IsFalse":f=!i;break}if(f){const h=s.delay||0;h<=0?this.triggerGlobalAnimation(s.targetAnimationId,s.subAnimationIds,s.loop,s.id):setTimeout(()=>this.triggerGlobalAnimation(s.targetAnimationId,s.subAnimationIds,s.loop,s.id),h)}}})}evaluateTransitions(){this.activeStateMachine&&(this.activeStateMachine.layers.forEach(t=>{const i=this.layerStates.get(t.name);if(!i||i.currentStateIds.length===0)return;const o=[];let e=!1;for(const s of i.currentStateIds){const n=t.states.find(r=>r.id===s);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(s)}if(!e){const s=this.findGlobalTransition(t,i.currentStateIds);s&&(o.length=0,o.push(s.targetStateId),e=!0,s.conditions&&(s.conditions||[]).forEach(n=>{var r;const a=(r=this.activeStateMachine)==null?void 0:r.inputs.find(f=>f.id===n.inputId);a&&typeof a.value=="object"&&a.value.type==="Trigger"&&this.setInternalInput(n.inputId,!1)}))}if(e){const s=Array.from(new Set(o));this.enterStates(t.name,s)}}),this.justFiredTriggers.size>0&&(this.justFiredTriggers.forEach(t=>{var o,e;this.setInternalInput(t,!1);const i=(o=this.activeStateMachine)==null?void 0:o.inputs.find(s=>s.id===t);i&&this.inputNameMap.has(i.name)&&((e=this.inputNameMap.get(i.name))==null||e.forEach(s=>this.setInternalInput(s,!1)))}),this.justFiredTriggers.clear()))}findGlobalTransition(t,i){for(const o of t.states)if(!(i.includes(o.id)&&this.justFiredTriggers.size===0)){for(const s of o.transitions||[])if(!(i.includes(s.targetStateId)&&this.justFiredTriggers.size===0)&&this.checkConditions(s.conditions))return s}return null}checkConditions(t){return!t||t.length===0?!0:t.every(i=>{const o=i.inputId,e=i.op,s=i.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==s;break;case"NotEqual":case"!=":a=n!=s;break;case"GreaterThan":case">":a=n>s;break;case"LessThan":case"<":a=n<s;break;case"GreaterEqual":case">=":a=n>=s;break;case"LessEqual":case"<=":a=n<=s;break;case"IsTrue":a=!!n;break;case"IsFalse":a=!n;break;default:a=!1}return a||this.justFiredTriggers.has(o),a})}evaluateLogicTree(t,i=null,o=new Set){var a,r,f,h,l,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,v)=>{const b=e.inputs.find(m=>m.id===u);return b?b.sourceId?this.evaluateLogicTree(b.sourceId,b.sourceHandleId,o):b.value!==void 0?b.value:v:v};let d=0;switch(e.op){case wt.AND:d=c("a",!1)&&c("b",!1);break;case wt.OR:d=c("a",!1)||c("b",!1);break;case wt.NOT:d=!c("in",!1);break;case wt.XOR:d=!!c("a",!1)!=!!c("b",!1);break;case wt.OBJECT:d=e.name;break;case wt.PROPERTY:case wt.GET_PROPERTY:{const u=c("id","");if(!u){d=0;break}const v=e.name;if(!v||v==="GET_PROPERTY"||v==="PROPERTY"){d=0;break}const b=this.objectStates.get(u);if(!b){d=0;break}v in b?d=b[v]:d=this.resolvePath(b,v);break}case wt.SET_PROPERTY:{const u=c("id",""),v=c("value",void 0);if(!u||v===void 0){d=0;break}const b=e.name;if(!b||b==="SET_PROPERTY"){d=0;break}const m=this.objectStates.get(u);if(!m){d=0;break}if(["x","y","rotation","scale_x","scale_y","opacity","width","height","cornerRadius","visible","zIndex"].includes(b))m[b]=v,d=v;else{const S=b.split(".");let C=m;for(let M=0;M<S.length-1;M++){const I=S[M];C[I]===void 0&&(C[I]={}),C=C[I]}const w=S[S.length-1];C[w]=v,d=v}break}case wt.ADD:d=c("a",0)+c("b",0);break;case wt.SUB:d=c("a",0)-c("b",0);break;case wt.MUL:d=c("a",0)*c("b",0);break;case wt.DIV:{const u=c("b",1);d=u===0?0:c("a",0)/u;break}case wt.MOD:d=c("a",0)%c("b",1);break;case wt.POW:d=Math.pow(c("a",0),c("b",1));break;case wt.ABS:d=Math.abs(c("in",0));break;case wt.ROUND:d=Math.round(c("in",0));break;case wt.FLOOR:d=Math.floor(c("in",0));break;case wt.CEIL:d=Math.ceil(c("in",0));break;case wt.SIN:d=Math.sin(c("in",0));break;case wt.COS:d=Math.cos(c("in",0));break;case wt.TAN:d=Math.tan(c("in",0));break;case wt.CLAMP:{const u=c("in",0),v=c("min",0),b=c("max",1);d=Math.max(v,Math.min(b,u));break}case wt.REMAP:{const u=c("in",0),v=c("inMin",0),b=c("inMax",100),m=c("outMin",0),y=c("outMax",1);d=b===v?m:m+(u-v)*(y-m)/(b-v);break}case wt.EQ:d=c("a",0)==c("b",0);break;case wt.NEQ:d=c("a",0)!=c("b",0);break;case wt.GT:d=c("a",0)>c("b",0);break;case wt.LT:d=c("a",0)<c("b",0);break;case wt.GTE:d=c("a",0)>=c("b",0);break;case wt.LTE:d=c("a",0)<=c("b",0);break;case wt.IF_ELSE:d=c("cond",!1)?c("then",0):c("else",0);break;case wt.VALUE:d=e.value!==void 0?e.value:0;break;case wt.INPUT:d=this.inputs.get(e.name)??0;break;case wt.LOG:{const u=c("in","");this.debugLog(`[User Logic] ${u}`),d=u;break}case wt.SCROLL_X:d=this.inputs.get("scrollX")??0;break;case wt.SCROLL_Y:d=this.inputs.get("scrollY")??0;break;case wt.MOUSE_X:d=this.inputs.get("mouseX")??0;break;case wt.MOUSE_Y:d=this.inputs.get("mouseY")??0;break;case wt.IS_MOUSE_DOWN:d=this.inputs.get("isMouseDown")??!1;break;case wt.EFFECTOR:{const u=c("id",""),v=c("intensity",1),b=c("trigger",!0);if(!u||!b){d=0;break}const m=e.name;if(!m){d=0;break}const y=this.objectStates.get(u);if(!y){d=0;break}if(["glitch","halftone","pixelate","noise","acid_gradient","acid_rave","shimmer"].includes(m))y.style||(y.style={}),y.style.artEffect={enabled:!0,type:m,intensity:v},d=1;else{y.behaviors||(y.behaviors=[]);let C=y.behaviors.find(w=>w.type===m);C?(C.enabled=!0,C.settings||(C.settings={}),C.settings.intensity=v):(C={id:`eff_${Date.now()}_${m}`,type:m,enabled:!0,sensors:[],settings:{intensity:v}},y.behaviors.push(C)),d=1}break}case wt.MONITOR:{d=c("in",0);break}case wt.SPRING_PULL:{const u=c("objectId",""),v=c("forceX",0),b=c("forceY",0);u&&((f=this.artboard)==null||f.objects.forEach(m=>{m.behaviors&&m.behaviors.forEach(y=>{var S;if(y.type===H.SpringChain&&((S=y.settings)!=null&&S.connections)&&(y.settings.connections.some(w=>w.targetId===u)||m.id===u)){this._springChainState.has(m.id)||this._springChainState.set(m.id,new Map);const w=this._springChainState.get(m.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+=v,M.vy+=b)}})})),d=1;break}case wt.SPRING_SETTLE:{const u=c("objectId","");let v=!0;if(u){const b=c("threshold",1);this._springChainState.forEach(m=>{const y=m.get(u);y&&(Math.abs(y.vx)>b||Math.abs(y.vy)>b)&&(v=!1)})}d=v;break}case wt.EMIT:{const u=c("objectId",""),v=c("count",20);u&&((h=this.artboard)==null||h.objects.forEach(b=>{b.behaviors&&b.behaviors.forEach(m=>{m.type===H.ParticleEmitter&&b.id===u&&(m._pendingBurst=(m._pendingBurst||0)+v)})})),d=1;break}default:d=0;break}if(this.logicNodeValues.set(t,d),e.op===wt.DELAY){const u=c("delay",0),v=c("in",0);let b=this.logicNodeState.get(t);for(b||(b={queue:[]},this.logicNodeState.set(t,b)),b.queue.push({time:this.currentTime+u,value:v});b.queue.length>0&&b.queue[0].time<=this.currentTime;)b.lastValue=b.queue.shift().value;d=b.lastValue??0}return d}const s=(l=this.activeStateMachine)==null?void 0:l.inputs.find(c=>c.id===t||c.name===t);if(s&&s.sourceId&&!o.has(s.sourceId)){const c=this.evaluateLogicTree(s.sourceId,s.sourceHandleId,o);return this.inputs.set(s.id,c),c}let n=this.inputs.get(t)??(s?this.inputs.get(s.id):void 0);if((this.justFiredTriggers.has(t)||s&&this.justFiredTriggers.has(s.id))&&(n=!0),i&&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(i==="source-greater")return n>d;if(i==="source-less")return n<d;if(i==="source-equal")return n===d}if(i==="source-true")return n===!0;if(i==="source-false")return n===!1;if(i==="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===wt.SET_PROPERTY||t.op===wt.EFFECTOR)&&this.evaluateLogicTree(t.id)})}resolvePath(t,i){const o=i.split(".");let e=t;for(const s of o)if(e&&typeof e=="object"&&s in e)e=e[s];else return;return e}seek(t){this.artboard&&(this.currentTime=t,this.layerStates.forEach(i=>{i.time=t,i.time>(i.duration||0)&&(i.animations.some(e=>{var s;return((s=e.state)==null?void 0:s.loop)===!0})?i.time%=i.duration||1:i.time=i.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 s=this.physicsEngine.getPosition(o.id),n=this.physicsEngine.getRotation(o.id),a=this.objectStates.get(o.id);a&&s!==null&&n!==null&&(a.x=s.x,a.y=s.y,a.rotation=n*(180/Math.PI))}})),this.activeStateMachine&&(this.runLogicNodes(),this.evaluateTransitions());const i=[];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_")&&i.push(e))}o.animations.forEach(s=>{var n;(n=s.state)!=null&&n.isBlendState&&s.state.blendAnimations?this.applyBlendState(s.state,o.time):s.animation&&this.applyAnimation(s.animation,o.time,s.filterObjectIds)})}}),i.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 s,n,a,r,f,h,l;if(o.phase==="entry")o.time+=t,o.time>=o.animation.duration&&((a=(n=(s=this.artboard)==null?void 0:s.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=(f=(r=this.artboard)==null?void 0:r.objects.find(u=>u.id===e))==null?void 0:f.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=(l=this.artboard)==null?void 0:l.animations.find(v=>v.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(i=>{var e,s,n;const o=(e=i.style)==null?void 0:e.analytics;if(o&&o.isEnabled&&o.triggerType==="visible"){const a=this.objectStates.get(i.id);if(a&&a.visible!==!1){const r=this.getGlobalTransform(i.id),f=(((s=i.geometry)==null?void 0:s.width)||100)*(r.scale_x||1),h=(((n=i.geometry)==null?void 0:n.height)||100)*(r.scale_y||1),l=50,p=r.x+f/2>=-this.canvasWidth/2-l&&r.x-f/2<=this.canvasWidth/2+l&&r.y+h/2>=-this.canvasHeight/2-l&&r.y-h/2<=this.canvasHeight/2+l,c=`analytics_${i.id}`,d=this.wasInView.has(c);p&&!d&&this.fireAnalyticsEvent(i.id,"visible"),p?this.wasInView.add(c):this.wasInView.delete(c)}}}),this.artboard.objects.forEach(i=>{const o=i.interactions||[];o.length!==0&&o.forEach(e=>{const s=e.triggers||[e.event||e.trigger];s&&s.forEach(n=>{var r,f,h;const a=n.toLowerCase();if(a==="on interval"||a==="oninterval"){const l=e.intervalValue||2e3,p=this.periodicTriggerTimes.get(e.id)||0;this.currentTime*1e3-p>=l&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(i.id,"On Interval"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="on delay"||a==="ondelay"){const l=e.delayValue||1e3;!this.periodicTriggerTimes.has(e.id)&&this.currentTime*1e3>=l&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(i.id,"On Delay"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="scroll into view"||a==="scrollintoview"){const l=this.objectStates.get(i.id);if(l&&l.visible!==!1){const p=this.getGlobalTransform(i.id),c=(((r=i.geometry)==null?void 0:r.width)||100)*(p.scale_x||1),d=(((f=i.geometry)==null?void 0:f.height)||100)*(p.scale_y||1),u=50,v=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,b=this.wasInView.has(i.id);v&&!b&&(!e.conditions||this.checkConditions(e.conditions))&&this.fireEventForObject(i.id,"Scroll Into View"),v?this.wasInView.add(i.id):this.wasInView.delete(i.id)}}if(a==="scroll progress"||a==="scrollprogress"){const l=Math.abs(this.scrollOffset.y)/(((h=this.artboard)==null?void 0:h.height)||1e3),p=this.scrollProgressLastValue.get(e.id)||0;Math.abs(l-p)>.001&&(this.scrollProgressLastValue.set(e.id,l),(e.action==="Set Input"||e.action==="setInput")&&this.updateInput(e.targetInputId,l))}})})}))}solveConstraints(t){this.artboard&&this.artboard.objects.forEach(i=>{if(!i.constraints||i.constraints.length===0)return;const o=this.objectStates.get(i.id);if(!o)return;const e=this.getGlobalTransform(i.id);if(i.constraints.forEach((s,n)=>{var h,l,p,c,d,u,v,b,m;const a=((h=o.constraints)==null?void 0:h[n])||{},r={...s,...a},f=r.strength??1;if(r.type==="Translation"){const y=this.getGlobalTransform(r.targetId);if(y){const S=r.offsetX||0,C=r.offsetY||0,w=y.x+S,M=y.y+C,I=r.useSpring;if(I){const T=this.objectVelocities.get(i.id)||{vx:0,vy:0},{x:O,y:P,vx:_,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)*f),r.copyY&&(e.y=e.y+(P-e.y)*f),this.objectVelocities.set(i.id,{vx:_,vy:E})}else r.copyX&&(e.x=e.x+(w-e.x)*f),r.copyY&&(e.y=e.y+(M-e.y)*f);let k=!1;if((l=r.limitX)!=null&&l.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((p=r.limitY)!=null&&p.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(i.id,{vx:0,vy:0})}}else if(r.type==="Rotation"){const y=this.getGlobalTransform(r.targetId);if(y){let C=(y.rotation+(r.offset||0)-e.rotation)%360;C>180&&(C-=360),C<-180&&(C+=360),e.rotation=e.rotation+C*f}}else if(r.type==="Scale"){const y=this.getGlobalTransform(r.targetId);y&&(r.copyX&&(e.scale_x=e.scale_x+(y.scale_x-e.scale_x)*f),r.copyY&&(e.scale_y=e.scale_y+(y.scale_y-e.scale_y)*f))}else if(r.type==="Transform"){const y=this.getGlobalTransform(r.targetId);if(y){e.x=e.x+(y.x-e.x)*f,e.y=e.y+(y.y-e.y)*f;let S=(y.rotation-e.rotation)%360;S>180&&(S-=360),S<-180&&(S+=360),e.rotation=e.rotation+S*f,e.scale_x=e.scale_x+(y.scale_x-e.scale_x)*f,e.scale_y=e.scale_y+(y.scale_y-e.scale_y)*f}}else if(r.type==="FollowPointer"){const y=((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(i.id)||{vx:0,vy:0},{x:I,y:k,vx:T,vy:O}=this.computeSpring(e.x,e.y,M.vx,M.vy,y,S,r,t);e.x=I,e.y=k,this.objectVelocities.set(i.id,{vx:T,vy:O})}else e.x=e.x+(y-e.x)*f,e.y=e.y+(S-e.y)*f;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((v=r.limitY)!=null&&v.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(i.id,{vx:0,vy:0})}else if(r.type==="Distance"){const y=this.getGlobalTransform(r.targetId);if(y){const S=e.x-y.x,C=e.y-y.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===y.x&&e.y===y.y?1:I/w;e.x=e.x+(y.x+S*k-e.x)*f,e.y=e.y+(y.y+C*k-e.y)*f}}}else if(r.type==="FollowPath"){const y=(b=this.artboard)==null?void 0:b.objects.find(S=>S.id===r.targetId);if(y){const S=this.getGlobalTransform(y.id);if(S){let C=y.geometry;if(y.type==="Frame"||y.type==="Group"||!C||C.type!=="Path"&&C.type!=="Ellipse"&&C.type!=="Rectangle"){const R=(m=this.artboard)==null?void 0:m.objects.find(j=>j.parentId===y.id&&j.type==="Shape"&&j.geometry&&(j.geometry.type==="Path"||j.geometry.type==="Ellipse"||j.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),P=Math.sin(T),_=k.x*S.scale_x*O-k.y*S.scale_y*P,E=k.x*S.scale_x*P+k.y*S.scale_y*O;let A=S.rotation+(r.offsetRotation||0);if(r.orient){const R=Math.cos(k.angle),j=Math.sin(k.angle),X=R*S.scale_x*O-j*S.scale_y*P,tt=R*S.scale_x*P+j*S.scale_y*O;A=Math.atan2(tt,X)*180/Math.PI+(r.offsetRotation||0)}const W=A*Math.PI/180,z=Math.cos(W),Y=Math.sin(W),G=(r.offsetX||0)*z-(r.offsetY||0)*Y,N=(r.offsetX||0)*Y+(r.offsetY||0)*z,J=S.x+_+G,x=S.y+E+N;if(e.x=e.x+(J-e.x)*f,e.y=e.y+(x-e.y)*f,r.orient){let R=(A-e.rotation)%360;R>180&&(R-=360),R<-180&&(R+=360),e.rotation=e.rotation+R*f}}}}else if(r.type==="IK"){const y=this.getGlobalTransform(r.targetId);y&&this.solveIK(i,y,r.boneCount||2,f)}}),i.constraints.some(s=>s.type!=="IK")){const s=this.globalToLocal(i.parentId,e);o.x=s.x,o.y=s.y,o.rotation=s.rotation,o.flip_x=s.scale_x<0,o.scale_x=Math.abs(s.scale_x),o.flip_y=s.scale_y<0,o.scale_y=Math.abs(s.scale_y)}})}getGlobalTransform(t){var l,p;const i=this.objectStates.get(t);if(!i)return{x:0,y:0,rotation:0,scale_x:1,scale_y:1};const o=(l=this.artboard)==null?void 0:l.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:i.x,y:i.y,rotation:i.rotation,scale_x:(i.scale_x??1)*(i.flip_x?-1:1),scale_y:(i.scale_y??1)*(i.flip_y?-1:1),length:e};const s=this.getGlobalTransform(o.parentId),n=s.rotation*Math.PI/180,a=Math.cos(n),r=Math.sin(n),f=s.x+(i.x*s.scale_x*a-i.y*s.scale_y*r),h=s.y+(i.x*s.scale_x*r+i.y*s.scale_y*a);return{x:f,y:h,rotation:s.rotation+i.rotation,scale_x:s.scale_x*(i.scale_x??1)*(i.flip_x?-1:1),scale_y:s.scale_y*(i.scale_y??1)*(i.flip_y?-1:1),length:e}}globalToLocal(t,i){if(!t)return i;const o=this.getGlobalTransform(t),e=o.scale_x===0?0:1/o.scale_x,s=o.scale_y===0?0:1/o.scale_y,n=-o.rotation*Math.PI/180,a=Math.cos(n),r=Math.sin(n),f=i.x-o.x,h=i.y-o.y,l=(f*a-h*r)*e,p=(f*r+h*a)*s;return{x:l,y:p,rotation:i.rotation-o.rotation,scale_x:i.scale_x/(o.scale_x||1),scale_y:i.scale_y/(o.scale_y||1)}}solveIK(t,i,o,e){var f;const s=[];let n=t.id;for(let h=0;h<o&&n;h++){const l=(f=this.artboard)==null?void 0:f.objects.find(p=>p.id===n);if(!l)break;s.push({id:n,local:this.objectStates.get(n),global:this.getGlobalTransform(n)}),n=l.parentId}if(s.length<2)return;const a=s.reverse(),r=5;for(let h=0;h<r;h++){const l=this.getGlobalTransform(t.id);for(let p=a.length-2;p>=0;p--){const c=a[p],d=this.getGlobalTransform(c.id),u=l.x-d.x,v=l.y-d.y,b=i.x-d.x,m=i.y-d.y,y=Math.sqrt(u*u+v*v),S=Math.sqrt(b*b+m*m);if(y>.001&&S>.001){const C=Math.atan2(v,u);let M=(Math.atan2(m,b)-C)*180/Math.PI;M*=e;const I=this.objectStates.get(c.id);I&&(I.rotation+=M)}}}}computeSpring(t,i,o,e,s,n,a,r){const f=a.stiffness??100,h=a.damping??10,l=a.mass??1,p=-f*(t-s),c=-f*(i-n),d=-h*o,u=-h*e,v=(p+d)/l,b=(c+u)/l,m=o+v*r,y=e+b*r,S=t+m*r,C=i+y*r;return{x:S,y:C,vx:m,vy:y}}handlePointerInput(t,i,o,e,s){if(!this.artboard)return;const n=this.calculateTransform(e,s,this.artboard.width,this.artboard.height,this.layout.fit,this.layout.alignment),a=(i-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,i){const o=this.scrollOffset.x,e=this.scrollOffset.y;this.scrollOffset={x:t,y:i},this._totalScroll.x+=t-o,this._totalScroll.y+=i-e,this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}handleWheel(t,i){this._totalScroll.x+=t,this._totalScroll.y+=i,this.scrollOffset={x:this._totalScroll.x,y:this._totalScroll.y},this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}handlePointerEvent(t,i,o){var r,f,h,l,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 s=(c,d)=>{var S;let u=d;d==="click"?u="onClick":d==="down"?u="onPointerDown":d==="up"?u="onPointerUp":d==="blur"&&(u="onPointerLeave");const v=new Set([u]);d==="move"&&v.add("onPointerEnter").add("hover").add("onPointerLeave").add("blur"),u==="onClick"&&v.add("click"),u==="onPointerDown"&&v.add("pointerDown"),u==="onPointerUp"&&v.add("pointerUp");const b=["button","toggle","toggle_button","dropdown","listview","inputbox","slider","checkbox","radiogroup","joystick"];return!!(c.type==="Component"&&b.includes(c.variant)||c.type==="Joystick"||b.includes((S=c.type)==null?void 0:S.toLowerCase())||(c.interactions||[]).some(C=>v.has(C.event))||(c.triggers||[]).some(C=>v.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,i,o)&&(n||(n=d),s(d,t))){e=d;break}}!e&&n&&(e=n),this.pointerHistory.push({x:i,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,i,o);return}if(this.draggingJoystickId){const c=this.artboard.objects.find(d=>d.id===this.draggingJoystickId);c&&this.updateJoystickValueFromPointer(c,i,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,i,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===H.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||{},v=c.geometry||{},b=v.width??c.width??200,m=v.height??c.height??40,y=u.optionsList||[],S=u.itemHeight||32,C=u.listPadding??4,w=y.length*S+C*2,M=this.getWorldTransform(c.id),I=b*Math.abs(M.scaleX),k=m*Math.abs(M.scaleY),T=M.y+k/2+4,O=Math.abs(i-M.x)<=I/2,P=o>=T&&o<=T+w*Math.abs(M.scaleY);if(O&&P){const _=Math.abs(M.scaleY),E=o-(T+C*_),A=Math.floor(E/(S*_));if(A>=0&&A<y.length){const W=y[A];u.selectedOption=W,u.isOpen=!1,this.activeDropdownId=null,c.inputId&&this.setInternalInput(c.inputId,W),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"dropdown",property:"selectedOption",value:W})}return}else a!==this.activeDropdownId&&(u.isOpen=!1,this.activeDropdownId=null)}}if(e){let c=e,d=e;for(;d&&d.parentId;){const v=this.artboard.objects.find(b=>b.id===d.parentId);if(v&&v.type==="Component"){c=v;break}d=v}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 v=this.objectStates.get(c.id),b=(v==null?void 0:v.options)||c.options||{};b.checked=!b.checked,c.inputId&&this.setInternalInput(c.inputId,b.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"toggle_button",property:"checked",value:b.checked}),this.fireEventForObject(c.id,"Toggle"),this.fireEventForObject(c.id,b.checked?"Toggle True":"Toggle False")}if(c.type==="Component"&&c.variant==="toggle"&&t==="down"){const v=this.objectStates.get(c.id),b=(v==null?void 0:v.options)||c.options||{};b.checked=!b.checked,c.inputId&&this.setInternalInput(c.inputId,b.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"toggle",property:"checked",value:b.checked}),this.onToggle&&this.onToggle(c.name,b.checked),this.fireEventForObject(c.id,"Toggle"),this.fireEventForObject(c.id,b.checked?"Toggle True":"Toggle False")}if(c.type==="Component"&&c.variant==="dropdown"&&t==="down"){const v=this.objectStates.get(c.id),b=(v==null?void 0:v.options)||c.options||{},m=!b.isOpen;if(m&&this.activeDropdownId&&this.activeDropdownId!==c.id){const y=this.artboard.objects.find(S=>S.id===this.activeDropdownId);y&&y.options&&(y.options.isOpen=!1)}b.isOpen=m,this.activeDropdownId=m?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 v=this.getListViewItemIndexAtPointer(c,i,o);if(v!==null){const b=c.options||{};b.activeItemIndex=v;const m=this.objectStates.get(c.id);m&&m.options&&(m.options.activeItemIndex=v);const y=(b.items||[])[v],S=typeof y=="string"?y:y.label||y.value||v;m&&m.options&&(m.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:v}),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,i,o)),c.type==="Joystick"||c.type==="Component"&&c.variant==="joystick"){if(t==="down")this.draggingJoystickId=c.id,this.updateJoystickValueFromPointer(c,i,o);else if(t==="up"||t==="blur"){const v=this.objectStates.get(c.id);v&&c.isSpringReturn!==!1&&(v.handleX=0,v.handleY=0),c.isSpringReturn!==!1&&(c.handleX=0,c.handleY=0)}}if(c.type==="Component"&&c.variant==="checkbox"&&t==="down"){const v=this.objectStates.get(c.id),b=(v==null?void 0:v.options)||c.options||{};b.checked=!b.checked,c.inputId&&this.setInternalInput(c.inputId,b.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"checkbox",property:"checked",value:b.checked}),this.fireEventForObject(c.id,"Click"),this.fireEventForObject(c.id,b.checked?"Checked":"Unchecked")}if(c.type==="Component"&&c.variant==="radiogroup"&&t==="down"){const v=this.objectStates.get(c.id),b=(v==null?void 0:v.options)||c.options||{},m=b.optionsList||[],y=this.getRadioGroupItemIndexAtPointer(c,i,o);if(y!==null&&y>=0&&y<m.length){const S=m[y];b.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 v=c.geometry,b=(v==null?void 0:v.datasets)||[],m=this.objectStates.get(c.id),y=(m==null?void 0:m.width)||(v==null?void 0:v.width)||200,S=(m==null?void 0:m.height)||(v==null?void 0:v.height)||150,C=this.getWorldTransform(c.id),w=30,M=20,I=y-w,k=S-M;let T=1;b.forEach(_=>{const E=Math.max(..._.data||[0]);E>T&&(T=E)});let O=1/0,P=null;b.forEach((_,E)=>{const A=_.data||[],W=I/Math.max(A.length-1,1);A.forEach((z,Y)=>{const G=C.x-y/2+w+Y*W,N=C.y+S/2-M-z/T*k,J=Math.sqrt((i-G)**2+(o-N)**2);J<O&&(O=J,P={dIdx:E,pIdx:Y,val:z,label:_.label||`Dataset ${E+1}`})})}),P&&O<20&&this.onGraphPointClick&&this.onGraphPointClick({objectId:c.id,componentName:c.name,datasetIndex:P.dIdx,pointIndex:P.pIdx,value:P.val,label:P.label}),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"linegraph",property:"click",value:(P==null?void 0:P.val)??null})}if(t==="click"){const v=(f=this.artboard)==null?void 0:f.objects.find(y=>y.id===e.id),b=this.focusedId,m=(v==null?void 0:v.type)==="InputBox"||(v==null?void 0:v.type)==="Component"&&v.variant==="inputbox";if(v&&m){if(this.focusedId=e.id,this.log(`[Engine] Focus set to: ${e.id}`),b!==this.focusedId){if(b){const y=(h=this.artboard)==null?void 0:h.objects.find(S=>S.id===b);y&&this.onInputBlur&&this.onInputBlur(y.name)}this.onInputFocus&&this.onInputFocus(v.name)}}else if(this.focusedId=null,b){const y=(l=this.artboard)==null?void 0:l.objects.find(S=>S.id===b);y&&this.onInputBlur&&this.onInputBlur(y.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 i=this.artboard.objects.find(a=>a.id===this.focusedId),o=(i==null?void 0:i.type)==="InputBox"||(i==null?void 0:i.type)==="Component"&&i.variant==="inputbox";if(!i||!o)return;const e=i.options||{};let s=e.text||"";if(t.key==="Backspace")s=s.slice(0,-1);else if(t.key==="Enter")if(e.multiline)s+=`
7
- `;else{this.focusedId=null;return}else if(t.key.length===1)s+=t.key;else return;e.text=s;const n=i.geometry;n.textInputId&&this.updateInput(n.textInputId,s),this.onComponentChange&&this.onComponentChange({objectId:i.id,componentName:i.name,variant:"inputbox",property:"text",value:s}),this.onInputChange&&this.onInputChange(i.name,s),this.onInputUpdate&&this.onInputUpdate(this.focusedId,s)}handleKeyUp(t){this.artboard&&(this.activeKeys.delete(t.key.toLowerCase()),this.activeKeys.delete(t.code))}fireEventForObject(t,i){var h,l,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([i,i.toLowerCase()]),s=i.toLowerCase();s==="onclick"||s==="click"||s==="onpointerdown"||s==="pointerdown"?this.fireAnalyticsEvent(t,"click"):(s==="onpointerenter"||s==="hover"||s==="move")&&this.fireAnalyticsEvent(t,"hover"),s==="onclick"||s==="click"?(e.add("click"),e.add("onclick")):s==="onpointerdown"||s==="pointerdown"?(e.add("pointerdown"),e.add("onpointerdown")):s==="onpointerup"||s==="pointerup"?(e.add("pointerup"),e.add("onpointerup")):s==="onpointerenter"||s==="hover"||s==="move"?(e.add("hover"),e.add("onpointerenter")):s==="onpointerleave"||s==="blur"?(e.add("onpointerleave"),e.add("blur")):s==="drag"||s==="ondrag"?(e.add("drag"),e.add("ondrag")):s==="toggle"||s==="ontoggle"?(e.add("toggle"),e.add("ontoggle")):s==="toggle true"||s==="toggle_true"||s==="toggletrue"?(e.add("toggle true"),e.add("toggle_true"),e.add("toggletrue")):(s==="toggle false"||s==="toggle_false"||s==="togglefalse")&&(e.add("toggle false"),e.add("toggle_false"),e.add("togglefalse"));const a=(o.interactions||[]).find(u=>{const v=u.triggers||[u.event||u.trigger||"click"];return((u.triggerLogic||"OR")==="AND"?v.every(y=>e.has(y.toLowerCase())):v.some(y=>e.has(y.toLowerCase())))?u.conditions&&u.conditions.length>0?this.checkConditions(u.conditions):!0:!1});if(a){if(this.log(`[Engine] Interaction matched: ${i} -> 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,v=a.targetProperty;v&&this.updateObjectProperty(u,v,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,v=!a.playMode||a.playMode==="all"?void 0:a.subAnimationIds;u==="__all__"?(p=(l=this.artboard)==null?void 0:l.animations)==null||p.forEach(b=>{this.triggerGlobalAnimation(b.id,v)}):u&&this.triggerGlobalAnimation(u,v)}else if(a.action==="setState"||a.action==="Set State"){const u=a.targetObjectId||o.id,b={...this.objectStates.get(u)||{},...a.value||{}};this.objectStates.set(u,b),this.log(`[Engine] State updated for ${u}:`,b)}else if(a.action==="Stop Animation"||a.action==="Pause Animation"){const u=a.targetAnimationId;u==="__all__"?this.layerStates.forEach((v,b)=>{b.startsWith("global_")&&this.layerStates.delete(b)}):u&&this.layerStates.forEach((v,b)=>{b.startsWith(`global_${u}_`)&&this.layerStates.delete(b)})}else if(a.action==="Switch to State"&&this.activeStateMachine){const u=a.targetState,v=this.activeStateMachine.layers.find(b=>b.states.some(m=>m.id===u||m.name===u));v&&(this.log(`[Engine] Switching Layer ${v.name} to State ${u}`),this.enterStates(v.name,[u]))}this.onTrigger&&this.onTrigger(i,a.action)}const f=(o.triggers||[]).find(u=>{const v=u.eventType.toLowerCase();let b=!1;return(e.has(v)||v==="click"&&e.has("onclick")||v==="hover"&&(e.has("onpointerenter")||e.has("hover"))||v==="pointerdown"&&e.has("onpointerdown")||v==="pointerup"&&e.has("onpointerup"))&&(b=!0),b&&u.conditions&&u.conditions.length>0?this.checkConditions(u.conditions):b});if(f&&f.entryAnimationId){this.log(`[Engine] Trigger matched: ${i} (as ${f.eventType}) -> Animation ${f.entryAnimationId}`);const u=(d=(c=this.artboard)==null?void 0:c.animations)==null?void 0:d.find(v=>v.id===f.entryAnimationId);u&&(this.activeTriggers.set(o.id,{triggerId:f.id,animation:u,time:0,phase:"entry",elapsedHold:0,filterObjectId:f.targetObjectId}),this.onTrigger&&this.onTrigger(f.name,u.name))}}fireAnalyticsEvent(t,i){var r,f;const o=(r=this.artboard)==null?void 0:r.objects.find(h=>h.id===t);if(!o)return;const e=(f=o.style)==null?void 0:f.analytics;if(!e||!e.isEnabled||e.triggerType!==i)return;const s=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 l=this.inputs.get(h.value);n[h.key]=l!==void 0?l:""}}),this.log(`[ExodeUI Analytics] Dispatching event "${s}" via ${i} 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",s,n),this.log(`[ExodeUI Analytics] GA4: Event "${s}" sent successfully.`)):this.warn(`[ExodeUI Analytics] GA4: window.gtag is not a function. Event "${s}" skipped.`)}if(a.meta){const h=window;typeof h.fbq=="function"?(h.fbq("track",s,n),this.log(`[ExodeUI Analytics] Meta Pixel: Event "${s}" sent successfully.`)):this.warn(`[ExodeUI Analytics] Meta Pixel: window.fbq is not a function. Event "${s}" skipped.`)}if(a.mixpanel){const h=window;h.mixpanel&&typeof h.mixpanel.track=="function"?(h.mixpanel.track(s,n),this.log(`[ExodeUI Analytics] Mixpanel: Event "${s}" sent successfully.`)):this.warn(`[ExodeUI Analytics] Mixpanel: window.mixpanel.track is not a function. Event "${s}" skipped.`)}}initGlobalAnimationTriggers(){if(!this.artboard)return;const t=this.artboard.animationFlow||[];let i=!1;t.forEach(o=>{if((o.trigger==="on_load"||o.trigger==="after_delay")&&o.targetAnimationId){i=!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)}}),!i&&this.artboard.startupAnimationId&&this.triggerGlobalAnimation(this.artboard.startupAnimationId,this.artboard.startupSubAnimationIds)}triggerGlobalAnimation(t,i,o=!1,e){if(!this.artboard)return;const s=this.artboard.animations.find(a=>a.id===t);if(!s)return;const n=`global_${t}_${Math.random().toString(36).substr(2,5)}`;this.layerStates.set(n,{currentStateIds:[t],animations:[{animation:s,state:{loop:o},filterObjectIds:i}],time:0,duration:s.duration,ruleId:e}),this.debugLog(`[Engine] Triggered global animation: ${s.name} (Loop: ${o}, Sub-Anims: ${(i==null?void 0:i.length)||"All"})`)}handleAnimationFinished(t,i){if(!this.artboard)return;(this.artboard.animationFlow||[]).forEach(e=>{if(e.trigger==="after_anim"&&e.targetAnimationId&&(e.afterAnim===t||i&&e.afterAnim===i)){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 i=this.objectStates.get(t);if(!i)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:i.x,y:i.y,scaleX:i.scale_x??1,scaleY:i.scale_y??1,rotation:i.rotation??0};const e=this.getWorldTransform(o.parentId),s=e.rotation*(Math.PI/180),n=Math.cos(s),a=Math.sin(s),r=i.x*e.scaleX,f=i.y*e.scaleY,h=e.x+(r*n-f*a),l=e.y+(r*a+f*n);return{x:h,y:l,scaleX:(i.scale_x??1)*e.scaleX,scaleY:(i.scale_y??1)*e.scaleY,rotation:e.rotation+(i.rotation??0)}}hitTest(t,i,o){var y,S;if(!this.objectStates.get(t.id))return!1;const s=((y=t.geometry)==null?void 0:y.width)??t.width??100,n=((S=t.geometry)==null?void 0:S.height)??t.height??100,a=this.getWorldTransform(t.id),r=i-a.x,f=o-a.y,h=-a.rotation*(Math.PI/180),l=Math.cos(h),p=Math.sin(h),c=r*l-f*p,d=r*p+f*l,u=a.scaleX,v=a.scaleY,b=s*Math.abs(u),m=n*Math.abs(v);return Math.abs(c)<=b/2&&Math.abs(d)<=m/2}updateSliderValueFromPointer(t,i,o){var M;const e=this.objectStates.get(t.id);if(!e)return;const s=t.options||{},n=((M=t.geometry)==null?void 0:M.width)??t.width??200,a=this.getWorldTransform(t.id),r=i-a.x,f=o-a.y,h=-a.rotation*(Math.PI/180),l=Math.cos(h),p=Math.sin(h),c=r*l-f*p,d=s.thumbWidth??16,u=n-d;let b=(c+u/2)/u;b=Math.max(0,Math.min(1,b));const m=s.min??0,y=s.max??100,S=s.step||1;let C=m+b*(y-m);S>0&&(C=Math.round(C/S)*S),C=Math.max(m,Math.min(y,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,i,o){var M,I;const e=this.objectStates.get(t.id);if(!e)return;const s=(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=i-a.x,f=o-a.y,h=-a.rotation*(Math.PI/180),l=Math.cos(h),p=Math.sin(h);let c=(r*l-f*p)/Math.max(.001,Math.abs(a.scaleX||1)),d=(r*p+f*l)/Math.max(.001,Math.abs(a.scaleY||1));t.handleOrigin==="top-left"?(c-=s/2,d-=n/2):t.handleOrigin==="bottom-right"&&(c+=s/2,d+=n/2);const u=Math.min(s,n)*.45,v=Math.min(s,n)*.15,b=u-v;let m=c/b,y=d/b;const S=Math.sqrt(m*m+y*y);t.boundsShape==="square"?(m=Math.max(-1,Math.min(1,m)),y=Math.max(-1,Math.min(1,y))):S>1&&(m/=S,y/=S),t.deadzone!==void 0&&S<t.deadzone?(m=0,y=0):(t.stepX!==void 0&&t.stepX>0&&(m=Math.round(m/t.stepX)*t.stepX),t.stepY!==void 0&&t.stepY>0&&(y=Math.round(y/t.stepY)*t.stepY)),t.joystickType==="1D_X"?y=0:t.joystickType==="1D_Y"&&(m=0);const C=e.handleX,w=e.handleY;(C!==m||w!==y)&&(e.handleX=m,e.handleY=y,t.handleX=m,t.handleY=y)}processJoysticks(t){this.artboard&&(this.artboard.objects.forEach(i=>{var a,r;if(i.type!=="Joystick"&&!(i.type==="Component"&&i.variant==="joystick"))return;const o=i,e=this.objectStates.get(o.id);if(!e)return;let s=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 f=o.inputBinding.keyboardConfig;let h=s,l=n;const c=(f.speed||5)*t;let d=!1;this.activeKeys.has(f.upKey.toLowerCase())&&(l-=c,d=!0),this.activeKeys.has(f.downKey.toLowerCase())&&(l+=c,d=!0),this.activeKeys.has(f.leftKey.toLowerCase())&&(h-=c,d=!0),this.activeKeys.has(f.rightKey.toLowerCase())&&(h+=c,d=!0),o.joystickType==="1D_X"&&(l=0),o.joystickType==="1D_Y"&&(h=0);const u=Math.sqrt(h*h+l*l);u>1&&(h/=u,l/=u),!d&&o.isSpringReturn!==!1&&(h+=(0-h)*(10*t),l+=(0-l)*(10*t),Math.abs(h)<.01&&(h=0),Math.abs(l)<.01&&(l=0)),s=h,n=l}else if(((r=o.inputBinding)==null?void 0:r.type)==="mouse"&&o.inputBinding.mouseConfig){const f=o.inputBinding.mouseConfig;let h=s,l=n;const p=f.sensitivity||.01,c=Math.abs(this._mouseDelta.dx)>0||Math.abs(this._mouseDelta.dy)>0;f.axisX&&(h+=this._mouseDelta.dx*p),f.axisY&&(l+=this._mouseDelta.dy*p),o.joystickType==="1D_X"&&(l=0),o.joystickType==="1D_Y"&&(h=0);const d=Math.sqrt(h*h+l*l);d>1&&(h/=d,l/=d),!c&&o.isSpringReturn!==!1&&(h+=(0-h)*(10*t),l+=(0-l)*(10*t),Math.abs(h)<.01&&(h=0),Math.abs(l)<.01&&(l=0)),s=h,n=l}if(e.handleX=s,e.handleY=n,o.handleX=s,o.handleY=n,o.bindings&&o.bindings.length>0){const f=Math.sqrt(s*s+n*n);let h=Math.atan2(n,s)*(180/Math.PI);h<0&&(h+=360),o.bindings.forEach(l=>{var d,u,v,b,m,y,S,C;let p=0;l.sourceAxis==="x"?p=o.invertX?-s:s:l.sourceAxis==="y"?p=o.invertY?-n:n:l.sourceAxis==="distance"?p=f:l.sourceAxis==="angle"&&(p=h);const c=(d=this.artboard)==null?void 0:d.objects.find(w=>w.id===l.targetObjectId);if(c){if(l.actionType==="bind"&&l.targetProperty&&l.isContinuous!==!1){const w=l.sourceMin??-1,M=l.sourceMax??1,I=l.targetMin??0,k=l.targetMax??100;let T=!!l.isContinuous,O=0,P=0;if(T){if((l.sourceAxis==="x"||l.sourceAxis==="y")&&I>=0){const E=Math.max(Math.abs(w),Math.abs(M))||1;P=p/E*k}else{let E=(p-w)/(M-w);E=Math.max(0,Math.min(1,E)),P=I+E*(k-I)}Math.abs(p)<.05&&(P=0)}else{const E=(p-w)/(M-w),A=Math.max(0,Math.min(1,E));O=I+A*(k-I),l.step&&l.step>0&&(O=Math.round(O/l.step)*l.step)}const _=this.objectStates.get(c.id);if(_){const E=l.isRelative!==!1,A=E?((u=c.transform)==null?void 0:u.x)??0:0,W=E?((v=c.transform)==null?void 0:v.y)??0:0,z=E?((b=c.transform)==null?void 0:b.rotation)??0:0,Y=E?((m=c.transform)==null?void 0:m.scale_x)??1:0,G=E?((y=c.transform)==null?void 0:y.scale_y)??1:0,N=E?((S=c.style)==null?void 0:S.opacity)??100:0,J=t*60,x=(R,j)=>{let X=O;if(T){const tt=`_internal_${R}_${l.id}`;let L=_[tt];L===void 0&&(L=_[R]??j),X=L+P*J,_[tt]=X,l.step&&l.step>0&&(X=Math.round(X/l.step)*l.step)}else X=j+O;_[R]=X};l.targetProperty==="x"||l.targetProperty==="transform.x"?x("x",A):l.targetProperty==="y"||l.targetProperty==="transform.y"?x("y",W):l.targetProperty==="rotation"||l.targetProperty==="r"||l.targetProperty==="transform.rotation"?x("rotation",z):l.targetProperty==="scaleX"||l.targetProperty==="transform.scale_x"?x("scale_x",Y):l.targetProperty==="scaleY"||l.targetProperty==="transform.scale_y"?x("scale_y",G):(l.targetProperty==="opacity"||l.targetProperty==="transform.opacity")&&x("opacity",N)}(C=c.physics)!=null&&C.enabled&&this.physicsEngine&&(l.targetProperty==="x"||l.targetProperty==="transform.x"||l.targetProperty==="y"||l.targetProperty==="transform.y")&&(l.targetProperty==="x"||l.targetProperty==="transform.x"?this.physicsEngine.applyForce(c.id,(O-((_==null?void 0:_.x)||0))*10,0):(l.targetProperty==="y"||l.targetProperty==="transform.y")&&this.physicsEngine.applyForce(c.id,0,(O-((_==null?void 0:_.y)||0))*10))}else if(l.actionType==="playAnimation"||l.actionType==="stopAnimation"||l.actionType==="pauseAnimation"){let w=!1;const M=l.threshold??0;l.condition==="always"?w=!0:l.condition===">"?w=p>M:l.condition==="<"?w=p<M:l.condition==="=="&&(w=Math.abs(p-M)<.01);const I=e[`_prev_src_${l.id}`]??p;let k=!1;l.condition==="always"?k=!0:l.condition===">"?k=I>M:l.condition==="<"?k=I<M:l.condition==="=="&&(k=Math.abs(I-M)<.01),e[`_prev_src_${l.id}`]=p,w&&!k&&l.targetAnimationId&&(l.actionType==="playAnimation"||l.actionType)}}})}}),this._mouseDelta.dx=0,this._mouseDelta.dy=0)}applyBlendState(t,i){var f,h,l,p,c,d,u,v;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 s=[];let n=0;if(t.blendType==="1D"){const b=[...t.blendAnimations].sort((m,y)=>m.position[0]-y.position[0]);if(b.length===1){const m=(h=(f=this.artboard)==null?void 0:f.animations)==null?void 0:h.find(y=>y.id===b[0].animationId);m&&(s.push({anim:m,weight:1}),n=1)}else{let m=0;for(;m<b.length-1&&b[m+1].position[0]<o;)m++;if(m===b.length-1&&o>b[m].position[0]){const y=(p=(l=this.artboard)==null?void 0:l.animations)==null?void 0:p.find(S=>S.id===b[m].animationId);y&&(s.push({anim:y,weight:1}),n=1)}else{const y=b[m].position[0],S=b[m+1].position[0],C=(d=(c=this.artboard)==null?void 0:c.animations)==null?void 0:d.find(T=>T.id===b[m].animationId),w=(v=(u=this.artboard)==null?void 0:u.animations)==null?void 0:v.find(T=>T.id===b[m+1].animationId),M=Math.max(.001,S-y);let I=(o-y)/M;I=Math.max(0,Math.min(1,I));const k=1-I;C&&(s.push({anim:C,weight:k}),n+=k),w&&(s.push({anim:w,weight:I}),n+=I)}}}else t.blendAnimations.forEach(b=>{var w,M;const m=(M=(w=this.artboard)==null?void 0:w.animations)==null?void 0:M.find(I=>I.id===b.animationId);if(!m)return;const y=b.position[0]-o,S=b.position[1]-e,C=y*y+S*S;if(C<1e-4)s.push({anim:m,weight:1e4}),n+=1e4;else{const I=1/C;s.push({anim:m,weight:I}),n+=I}});if(n===0)return;s.forEach(b=>b.weight/=n);const a=new Map,r=b=>{let m=b.startsWith("#")?b.substring(1):b;return m.length===3&&(m=[m[0],m[0],m[1],m[1],m[2],m[2]].join("")),m="0x"+m,{r:m>>16&255,g:m>>8&255,b:m&255,a:1}};s.forEach(({anim:b,weight:m})=>{b.tracks&&b.tracks.forEach(y=>{var O,P;const S=y.object_id||y.objectId,C=y.property,w=(O=this.artboard)==null?void 0:O.objects.find(_=>_.id===S);if(((P=w==null?void 0:w.physics)==null?void 0:P.enabled)&&w.physics.bodyType!=="Static"&&(C==="x"||C==="y"||C==="rotation"))return;const I=this.interpolate(y.keyframes,i);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},m<.5)return;k.set(C,T)}if(T.type==="number"&&typeof I=="number")T.value+=I*m;else if(T.type==="color"&&typeof I=="string"&&T.colorAcc){const _=r(I);_&&(T.colorAcc.r+=_.r*m,T.colorAcc.g+=_.g*m,T.colorAcc.b+=_.b*m,T.colorAcc.a+=_.a*m)}else m>.5&&(T.value=I)})}),a.forEach((b,m)=>{var C;const y=this.objectStates.get(m),S=(C=this.artboard)==null?void 0:C.objects.find(w=>w.id===m);!y||!S||b.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(".")){const k=(M||"").split(".");let T=y;for(let O=0;O<k.length-1;O++){if(typeof T[k[O]]!="object"||T[k[O]]===null){let P=S;for(let _=0;_<=O;_++)P=P?P[k[_]]:null;if(k[O]==="corner_radius"||k[O]==="cornerRadius"){const _=typeof T[k[O]]=="number"?T[k[O]]:typeof P=="number"?P:0;T[k[O]]={tl:_,tr:_,bl:_,br:_}}else T[k[O]]=P?JSON.parse(JSON.stringify(P)):{}}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"?(y.style||(y.style={}),y.style.fill=I):M==="stroke"?(y.style||(y.style={}),y.style.stroke=I):y[M]=I})})}applyAnimation(t,i,o){!t||!t.tracks||t.tracks.forEach(e=>{var l,p,c;const s=e.object_id||e.objectId;if(o){if(Array.isArray(o)){if(!o.includes(s))return}else if(s!==o)return}const n=(l=this.artboard)==null?void 0:l.objects.find(d=>d.id===s),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 f=this.objectStates.get(s);if(!f){this.frameCount%600===0&&this.debugLog(`Skipping track: Object ${s} not found in state`);return}const h=this.interpolate(e.keyframes,i);if(h!==void 0){if(this.frameCount%240===0){const d=(n==null?void 0:n.name)||s,u=typeof h=="object"?JSON.stringify(h).slice(0,50):h;this.debugLog(`[Anim] Applying ${r} = ${u} to ${d}`)}if(r.includes(".")){const d=(r||"").split(".");let u=f;for(let v=0;v<d.length-1;v++){if(typeof u[d[v]]!="object"||u[d[v]]===null){let b=n;for(let m=0;m<=v;m++)b=b?b[d[m]]:null;if(d[v]==="corner_radius"||d[v]==="cornerRadius"){const m=typeof u[d[v]]=="number"?u[d[v]]:typeof b=="number"?b:0;u[d[v]]={tl:m,tr:m,bl:m,br:m}}else u[d[v]]=b?JSON.parse(JSON.stringify(b)):{}}u=u[d[v]]}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"?(f.style||(f.style={}),f.style.fill=h):r==="stroke"?(f.style||(f.style={}),f.style.stroke=h):f[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(s);d&&this.physicsEngine.setPosition(s,h,d.y)}else if(r==="y"){const d=this.physicsEngine.getPosition(s);d&&this.physicsEngine.setPosition(s,d.x,h)}else r==="rotation"&&this.physicsEngine.setRotation(s,h*(Math.PI/180))}})}interpolate(t,i){if(t.length===0)return;let o=t[0],e=t[t.length-1];if(i<=o.time)return o.value;if(i>=e.time)return e.value;for(let a=0;a<t.length-1;a++)if(i>=t[a].time&&i<t[a+1].time){o=t[a],e=t[a+1];break}const s=e.time-o.time;let n=(i-o.time)/s;if(o.easing&&(n=si(o.easing)(n)),typeof o.value=="string"){if(o.value.startsWith("#"))return this.interpolateColor(o.value,e.value,n);const a=parseFloat(o.value),r=parseFloat(e.value);return!isNaN(a)&&!isNaN(r)?Math.round(a+(r-a)*n).toString():o.value}if(Array.isArray(o.value)&&Array.isArray(e.value))return o.value.length===e.value.length?o.value.map((a,r)=>{const f=e.value[r];return typeof a=="number"&&typeof f=="number"?a+(f-a)*n:n<.5?a:f}):n<.5?o.value:e.value;if(typeof o.value=="object"&&typeof e.value=="object"&&o.value!==null&&e.value!==null){if(o.value.width!==void 0&&o.value.color!==void 0)return this.interpolateStroke(o.value,e.value,n);if(o.value.type&&e.value.type)return this.interpolateFill(o.value,e.value,n);const a={};return new Set([...Object.keys(o.value),...Object.keys(e.value)]).forEach(f=>{const h=o.value[f],l=e.value[f];typeof h=="number"&&typeof l=="number"?a[f]=h+(l-h)*n:h===void 0?a[f]=l:l===void 0?a[f]=h:a[f]=n<.5?h:l}),a}return typeof o.value=="number"&&typeof e.value=="number"?o.value+(e.value-o.value)*n:n<.5?o.value:e.value}interpolateColor(t,i,o){var d,u;const e=((u=(d=this.artboard)==null?void 0:d.tokens)==null?void 0:u.colors)||{},s=e[t]||t,n=e[i]||i,a=v=>{if(!v)return{r:0,g:0,b:0};const b=v.startsWith("#")?v.replace("#",""):"000000";return b.length===3?{r:parseInt(b[0]+b[0],16),g:parseInt(b[1]+b[1],16),b:parseInt(b[2]+b[2],16)}:{r:parseInt(b.substring(0,2),16),g:parseInt(b.substring(2,4),16),b:parseInt(b.substring(4,6),16)}},r=a(s),f=a(n),h=Math.round(r.r+(f.r-r.r)*o),l=Math.round(r.g+(f.g-r.g)*o),p=Math.round(r.b+(f.b-r.b)*o),c=v=>{const b=Math.max(0,Math.min(255,v)).toString(16);return b.length===1?"0"+b:b};return`#${c(h)}${c(l)}${c(p)}`}interpolateStops(t,i,o){return!t||!i||t.length!==i.length?o<.5?t:i:t.map((e,s)=>{const n=i[s];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,i,o){if(!t||!i||t.type!==i.type)return o<.5?t:i;const e={...t,opacity:(t.opacity??1)+((i.opacity??1)-(t.opacity??1))*o};return t.type==="Solid"?e.color=this.interpolateColor(t.color,i.color,o):(t.type==="LinearGradient"||t.type==="RadialGradient")&&(t.start&&i.start&&(e.start=[t.start[0]+(i.start[0]-t.start[0])*o,t.start[1]+(i.start[1]-t.start[1])*o]),t.end&&i.end&&(e.end=[t.end[0]+(i.end[0]-t.end[0])*o,t.end[1]+(i.end[1]-t.end[1])*o]),t.center&&i.center&&(e.center=[t.center[0]+(i.center[0]-t.center[0])*o,t.center[1]+(i.center[1]-t.center[1])*o]),t.radius!==void 0&&i.radius!==void 0&&(e.radius=t.radius+(i.radius-t.radius)*o),e.stops=this.interpolateStops(t.stops,i.stops,o)),e}interpolateStroke(t,i,o){if(!t||!i)return o<.5?t:i;const e={...t};return e.width=(t.width??0)+((i.width??0)-(t.width??0))*o,e.opacity=(t.opacity??1)+((i.opacity??1)-(t.opacity??1))*o,t.fill&&i.fill?e.fill=this.interpolateFill(t.fill,i.fill,o):t.color&&i.color&&t.color.startsWith("#")&&i.color.startsWith("#")&&(e.color=this.interpolateColor(t.color,i.color,o)),e.trimStart=(t.trimStart??0)+((i.trimStart??0)-(t.trimStart??0))*o,e.trimEnd=(t.trimEnd??1)+((i.trimEnd??1)-(t.trimEnd??1))*o,e.trimOffset=(t.trimOffset??0)+((i.trimOffset??0)-(t.trimOffset??0))*o,e.dashOffset=(t.dashOffset??0)+((i.dashOffset??0)-(t.dashOffset??0))*o,e}render(t,i,o){var l;this.debug_objectsTotal=((l=this.artboard)==null?void 0:l.objects.length)||0,this.debug_objectsRendered=0;const e=performance.now();if(this.canvasWidth=i,this.canvasHeight=o,!this.artboard)return;t.clearRect(0,0,i,o);const s=this.artboard.width,n=this.artboard.height,a=this.calculateTransform(i,o,s,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,s,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=s/n;let v,b,m,y;u>d?(v=s,b=s/d):(b=n,v=n*d),m=(s-v)/2,y=(n-b)/2,t.drawImage(c,m,y,v,b),t.restore()}}(this.artboard.clipContent===!0||this.artboard.clip_content===!0)&&(t.beginPath(),t.rect(0,0,s,n),t.clip());const f=new Map;this.artboard.objects.forEach(p=>f.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,f)}),this._emitterPools.forEach((p,c)=>{if(!(p.length===0||!f.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,i,o,e,s,n=0){const a=t.getTransform(),r=i*a.a+o*a.c+a.e,f=i*a.b+o*a.d+a.f,h=Math.sqrt(a.a*a.a+a.b*a.b),l=Math.sqrt(a.c*a.c+a.d*a.d),p=(e/2+n)*h,c=(s/2+n)*l;return r+p>=0&&r-p<=this.canvasWidth&&f+c>=0&&f-c<=this.canvasHeight}calculateTransform(t,i,o,e,s,n){let a=1,r=1,f=1;const h=o/e,l=t/i;switch(s){case"Contain":l>h?f=i/e:f=t/o,a=r=f;break;case"Cover":l>h?f=t/o:f=i/e,a=r=f;break;case"Fill":a=t/o,r=i/e;break;case"FitWidth":f=t/o,a=r=f;break;case"FitHeight":f=i/e,a=r=f;break;case"None":a=r=1;break;case"ScaleDown":f=Math.min(t/o,i/e),f>1&&(f=1),a=r=f;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=i-c:u=(i-c)/2,{scaleX:a,scaleY:r,tx:d,ty:u}}mapFontWeight(t){const i=t.toLowerCase();return i==="thin"||i==="100"?"100":i==="extralight"||i==="200"?"200":i==="light"||i==="300"?"300":i==="regular"||i==="normal"||i==="400"?"400":i==="medium"||i==="500"?"500":i==="semibold"||i==="600"?"600":i==="bold"||i==="700"?"700":i==="extrabold"||i==="800"?"800":i==="black"||i==="900"?"900":t}drawTextDecoration(t,i,o,e,s,n){t.beginPath();const a=Math.max(1,n/14);let r=e;i==="underline"?r=e+n*.12:i==="line-through"&&(r=e-n*.3),t.lineWidth=a,t.strokeStyle=t.fillStyle,t.moveTo(o-s/2,r),t.lineTo(o+s/2,r),t.stroke()}renderObject(t,i,o){var u,v,b,m,y,S,C,w,M,I,k,T,O,P,_,E,A,W,z,Y,G,N,J,x,R,j;const e=this.objectStates.get(i.id);if(!e){this.warn("No state for object:",i.id);return}this.frameCount%60,t.roundRect||(t.roundRect=(X,tt,L,F,D)=>(this.drawRoundRect(t,X,tt,L,F,D),t));const s=e.geometry?this.deepMerge(i.geometry,e.geometry):i.geometry;let n=e.style?this.deepMerge(i.style,e.style):i.style,a=(s==null?void 0:s.width)||((u=i.geometry)==null?void 0:u.width)||i.width||0,r=(s==null?void 0:s.height)||((v=i.geometry)==null?void 0:v.height)||i.height||0;if((a===0||r===0)&&(s!=null&&s.points)&&Array.isArray(s.points)&&s.points.length>0){let X=1/0,tt=-1/0,L=1/0,F=-1/0;s.points.forEach(D=>{X=Math.min(X,D.x),tt=Math.max(tt,D.x),L=Math.min(L,D.y),F=Math.max(F,D.y)}),a===0&&(a=tt-X),r===0&&(r=F-L)}const f=X=>{if(X)return X.corner_radius??X.cornerRadius},h=f(e)??f(n)??f(s)??f(i.style)??f(i.geometry)??0;let l={...s,width:a,height:r};if(delete l.cornerRadius,l.corner_radius=h,l.type==="Path"&&i.weights&&i.bindMatrices&&l.points){const X=this.getGlobalTransform(i.id);if(X){const tt=ii(l.points,i.weights,i.bindMatrices,X,L=>this.getGlobalTransform(L));l={...l,points:tt}}}if(e.visible===!1)return;const p=i.repeaterConfig,c=p&&p.isEnabled&&p.count>1,d=c?p.count:1;for(let X=0;X<d;X++){let tt=e.x!==void 0?e.x:((b=e.transform)==null?void 0:b.x)??0,L=e.y!==void 0?e.y:((m=e.transform)==null?void 0:m.y)??0,F=e.rotation!==void 0?e.rotation:((y=e.transform)==null?void 0:y.rotation)??0,D=e.scale_x!==void 0?e.scale_x:((S=e.transform)==null?void 0:S.scale_x)??1,q=e.scale_y!==void 0?e.scale_y:((C=e.transform)==null?void 0:C.scale_y)??1;if(c&&X>0){if(p.type==="Linear"){const ft=p.offsetX||0,pt=p.offsetY||0,at=p.rotation||0,B=p.scale!==void 0?p.scale:1;tt+=X*ft,L+=X*pt,F+=X*at,D*=Math.pow(B,X),q*=Math.pow(B,X)}else if(p.type==="Grid"){const ft=p.cols||Math.ceil(Math.sqrt(p.count)),pt=p.gapX||0,at=p.gapY||0,B=Math.floor(X/ft),nt=X%ft,Z=a+pt,Pt=r+at;tt+=nt*Z,L+=B*Pt}else if(p.type==="Radial"){const ft=p.radius||100,pt=p.startAngle||0,B=(p.endAngle||360)-pt,nt=p.count>1?B/(B===360?p.count:p.count-1):0,Z=pt+X*nt,Pt=Z*Math.PI/180;tt=e.x+ft*Math.cos(Pt),L=e.y+ft*Math.sin(Pt),F+=Z}}const ot=i.type==="Group"||i.type==="Frame"||i.type==="Component",yt=a>0&&r>0;if(!ot&&yt){const ft=(((w=n.shadow)==null?void 0:w.isEnabled)!==!1?(((M=n.shadow)==null?void 0:M.blur)||0)+10:0)+(((I=n.blur)==null?void 0:I.isEnabled)!==!1&&((k=n.blur)==null?void 0:k.radius)||0)+20;if(!this.isObjectInView(t,tt,L,a,r,ft))continue}this.debug_objectsRendered++,t.save();const bt=[],gt=n.blur||((T=i.style)==null?void 0:T.blur);gt&&gt.amount>0&&bt.push(`blur(${gt.amount}px)`);const Et=n.effects||((O=i.style)==null?void 0:O.effects)||[];let It=Et.find(ft=>ft.isEnabled!==!1&&(ft.type==="BackgroundBlur"||ft.type==="LayerBlur"));It||(It=n.effect||((P=i.style)==null?void 0:P.effect)||Et.find(ft=>ft.isEnabled!==!1));const St=It,zt=(St==null?void 0:St.isEnabled)!==!1,he=St==null?void 0:St.type,pe=(St==null?void 0:St.radius)??10;zt&&he==="LayerBlur"?bt.push(`blur(${pe}px)`):zt&&he==="BackgroundBlur"&&(n===i.style&&(n={...n}),n.fill={type:"None"});const et=((_=s==null?void 0:s.type)==null?void 0:_.toLowerCase().includes("image"))||((E=i.type)==null?void 0:E.toLowerCase().includes("image")),mt=n.adjustments&&Object.keys(n.adjustments).length>0?n.adjustments:null,Ft=s!=null&&s.adjustments&&Object.keys(s.adjustments).length>0?s.adjustments:null,_t=et?Ft||mt:mt||Ft,dt=et&&!_t?{exposure:0,contrast:0,saturation:100,temperature:0,tint:0,highlights:0,shadows:0,blur:0,negative:0,hue:0}:_t;if(e&&dt&&(e.geometry=e.geometry||{},e.geometry.adjustments={...dt}),dt){const ft=(dt.exposure||0)/100,pt=dt.contrast||0,at=1+(dt.saturation||0)/100,B=(dt.temperature||0)/200,nt=(dt.tint||0)/200,Z=(dt.highlights||0)/500,Pt=(dt.shadows||0)/500;let Ot="",kt="SourceGraphic";if(ft!==0&&(Ot+=`
6
+ `&&k++)}let M=(C==null?void 0:C.lines)||[];return g.composer==="every-line"&&M.length>1&&(M=Ms(M)),g.balanceRaggedLines===!0&&M.length>1&&(M=Is(M)),{width:a,height:w,lineCount:M.length,lines:M}}function es(g,t,i){let o=String(g||"").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),s=new Array(e.length).fill(0);let n=t-(e.length-1)*i,a=0;if(e.forEach((r,f)=>{if(r.endsWith("px")){const h=parseFloat(r);s[f]=h,n-=h}else r.endsWith("fr")?a+=parseFloat(r):r==="auto"&&(s[f]=100,n-=100)}),a>0&&n>0){const r=n/a;e.forEach((f,h)=>{f.endsWith("fr")&&(s[h]=r*parseFloat(f))})}return s}function ss(g,t,i){try{const o=g.autoLayout;return!o||!o.enabled?{childUpdates:[]}:(o.mode||"linear")==="grid"?Ts(g,t,i):ks(g,t,i)}catch(o){return console.error("Layout Engine Error:",o),{childUpdates:[]}}}function ks(g,t,i){var _,E;const o=g.autoLayout,{direction:e,spacing:s,padding:n,align:a,wrap:r}=o,f=e==="vertical",h=t.map(A=>{const W=i(A.id),z=A.geometry;let Y=(W==null?void 0:W.width)??z.width??100,G=(W==null?void 0:W.height)??z.height??100;if(z.type==="Ellipse"||z.type==="Polygon"||z.type==="Star"){const N=(W==null?void 0:W.radius)??z.radius??(W==null?void 0:W.outer_radius)??z.outer_radius??50;Y=N*2,G=N*2}else if(z.type==="Text"){const N=ts({text:(W==null?void 0:W.text)??z.text??"",fontFamily:z.fontFamily,fontSize:z.fontSize,fontWeight:z.fontWeight,fontStyle:z.fontStyle,lineHeight:z.lineHeight,width:z.width||200,letterSpacing:z.letterSpacing,paragraphSpacing:z.paragraphSpacing,paragraphIndent:z.paragraphIndent,textCase:z.textCase,segments:z.segments,enableSegments:z.enableSegments});G=N.height,z.width||(Y=N.width)}return Y*=A.transform.scale_x||1,G*=A.transform.scale_y||1,{id:A.id,w:Y,h:G,original:A}});let l=g.width,p=g.height;const c=((_=g.layoutProps)==null?void 0:_.width)==="hug",d=((E=g.layoutProps)==null?void 0:E.height)==="hug",u=[];let v=[],b=0,y=0;const m=l-n.left-n.right,S=p-n.top-n.bottom;h.forEach(A=>{r&&v.length>0&&(f?y+s+A.h>S:b+s+A.w>m)?(u.push({children:v,width:b,height:y}),v=[A],b=A.w,y=A.h):(v.push(A),f?(b=Math.max(b,A.w),y+=(v.length>1?s:0)+A.h):(b+=(v.length>1?s:0)+A.w,y=Math.max(y,A.h)))}),v.length>0&&u.push({children:v,width:b,height:y}),c&&!f&&(l=Math.max(...u.map(A=>A.width),0)+n.left+n.right),d&&f&&(p=Math.max(...u.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-"),P=I.startsWith("bottom-");return u.forEach(A=>{let W=w,z=M;f?O?z=n.top+(p-n.top-n.bottom-A.height)/2:P&&(z=p-n.bottom-A.height):k?W=n.left+(l-n.left-n.right-A.width)/2:T&&(W=l-n.right-A.width),A.children.forEach(Y=>{var F,j;let G=W,N=z;f?k?G+=(A.width-Y.w)/2:T&&(G+=A.width-Y.w):O?N+=(A.height-Y.h)/2:P&&(N+=A.height-Y.h);const J=((F=Y.original.layoutProps)==null?void 0:F.width)==="fill",x=((j=Y.original.layoutProps)==null?void 0:j.height)==="fill";C.push({id:Y.id,x:G+Y.w/2-l/2,y:N+Y.h/2-p/2,width:J&&f?A.width:void 0,height:x?f?void 0:A.height:void 0}),f?z+=Y.h+s:W+=Y.w+s}),f?w+=A.width+s:M+=A.height+s}),{frameWidth:c?l:void 0,frameHeight:d?p:void 0,childUpdates:C}}function Ts(g,t,i){const o=g.autoLayout;if(!o)return{childUpdates:[]};const{gridColumns:e,gridRows:s,columnGap:n=0,rowGap:a=0,padding:r,align:f}=o;let h=g.width,l=g.height;const p=h-r.left-r.right,c=l-r.top-r.bottom,d=es(e||"1fr",p,n),u=es(s||"auto",c,a),v=d.length>0?d.reduce((T,O)=>T+O,0)+(d.length-1)*n:0,b=u.length>0?u.reduce((T,O)=>T+O,0)+(u.length-1)*a:0,y=f.toLowerCase(),m=y==="center"||y.endsWith("-center"),S=y.endsWith("-right"),C=y==="center"||y.startsWith("center-"),w=y.startsWith("bottom-");let M=0,I=0;m?M=(p-v)/2:S&&(M=p-v),C?I=(c-b)/2:w&&(I=c-b);const k=[];return t.forEach((T,O)=>{var j,X;const P=O%d.length||0,_=Math.floor(O/d.length)||0;_>=u.length&&u.push(100);const E=d[P],A=u[_];let W=r.left+M+d.slice(0,P).reduce((tt,L)=>tt+L+n,0),z=r.top+I+u.slice(0,_).reduce((tt,L)=>tt+L+a,0);const Y=i(T.id),G=T.geometry;let N=(Y==null?void 0:Y.width)??G.width??100,J=(Y==null?void 0:Y.height)??G.height??100;if(G.type==="Ellipse"||G.type==="Polygon"||G.type==="Star"){const tt=(Y==null?void 0:Y.radius)??G.radius??(Y==null?void 0:Y.outer_radius)??G.outer_radius??50;N=tt*2,J=tt*2}N*=T.transform.scale_x||1,J*=T.transform.scale_y||1;let x=W,F=z;m?x+=(E-N)/2:S&&(x+=E-N),C?F+=(A-J)/2:w&&(F+=A-J),k.push({id:T.id,x:x+N/2-h/2,y:F+J/2-l/2,width:((j=T.layoutProps)==null?void 0:j.width)==="fill"?E:void 0,height:((X=T.layoutProps)==null?void 0:X.height)==="fill"?A:void 0})}),{childUpdates:k}}class is{constructor(){lt(this,"world",null);lt(this,"bodies",new Map);lt(this,"colliders",new Map);lt(this,"joints",new Map);lt(this,"initialized",!1);lt(this,"bodyIdByCollider",new Map);lt(this,"onCollisionCB",null);lt(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 i=t.isStatic?Jt.RigidBodyDesc.fixed():Jt.RigidBodyDesc.dynamic();i.setTranslation(t.x,t.y),t.rotation!==void 0&&i.setRotation(t.rotation);const o=this.world.createRigidBody(i);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 s=this.world.createCollider(e,o);this.bodyIdByCollider.set(s.handle,t.id),t.frictionAir!==void 0&&o.setLinearDamping(t.frictionAir*10),this.bodies.set(t.id,o),this.colliders.set(t.id,s)}removeBody(t){const i=this.bodies.get(t),o=this.colliders.get(t);o&&this.bodyIdByCollider.delete(o.handle),i&&this.world&&(this.world.removeRigidBody(i),this.bodies.delete(t),this.colliders.delete(t))}step(t){if(!this.world)return;this.world.step(this.eventQueue);const i=this.onCollisionCB,o=this.eventQueue;i&&o&&o.drainContactEvents((e,s,n)=>{const a=this.bodyIdByCollider.get(e),r=this.bodyIdByCollider.get(s);a&&r&&i(a,r,n)})}getPosition(t){const i=this.bodies.get(t);if(!i)return null;const o=i.translation();return{x:o.x,y:o.y}}getRotation(t){const i=this.bodies.get(t);return i?i.rotation():null}getVelocity(t){const i=this.bodies.get(t);if(!i)return null;const o=i.linvel();return{x:o.x,y:o.y}}setPosition(t,i,o){const e=this.bodies.get(t);e&&e.setTranslation(new Jt.Vector2(i,o),!0)}setRotation(t,i){const o=this.bodies.get(t);o&&o.setRotation(i,!0)}setVelocity(t,i,o){const e=this.bodies.get(t);e&&e.setLinvel(new Jt.Vector2(i,o),!0)}setAngularVelocity(t,i){const o=this.bodies.get(t);o&&o.setAngvel(i,!0)}applyForce(t,i,o){const e=this.bodies.get(t);e&&e.addForce(new Jt.Vector2(i,o),!0)}applyImpulse(t,i,o){const e=this.bodies.get(t);e&&e.applyImpulse(new Jt.Vector2(i,o),!0)}createJoint(t){if(!this.world){console.warn("[RapierPhysics] World not initialized");return}this.joints.has(t.id)&&this.removeJoint(t.id);const i=this.bodies.get(t.bodyA),o=this.bodies.get(t.bodyB);if(!i||!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),s=new Jt.Vector2(t.anchorB.x,t.anchorB.y);let n;if(t.type==="Distance"){const a=t.length??100,r=t.stiffness??100,f=t.damping??10;n=Jt.JointData.spring(a,r,f,e,s)}else n=Jt.JointData.revolute(e,s);try{const a=this.world.createImpulseJoint(n,i,o,!0);this.joints.set(t.id,a)}catch(a){console.error(`[RapierPhysics] Failed to create joint ${t.id}:`,a)}}removeJoint(t){const i=this.joints.get(t);if(i&&this.world){try{this.world.removeImpulseJoint(i,!0)}catch(o){console.error(`[RapierPhysics] Failed to remove joint ${t}:`,o)}this.joints.delete(t)}}}const ns=g=>g,_s=g=>g>0?1:0,Ps=g=>g<1?0:1,os=g=>g*g,as=g=>g*(2-g),rs=g=>g<.5?2*g*g:-1+(4-2*g)*g,Es=g=>g*g*g,As=g=>--g*g*g+1,xs=g=>g<.5?4*g*g*g:(g-1)*(2*g-2)*(2*g-2)+1,Os=g=>g*g*g*g,Ls=g=>1- --g*g*g*g,Rs=g=>g<.5?8*g*g*g*g:1-8*--g*g*g*g,Fs=g=>g*g*g*g*g,$s=g=>1+--g*g*g*g*g,Bs=g=>g<.5?16*g*g*g*g*g:1+16*--g*g*g*g*g,Ws=g=>1-Math.cos(g*Math.PI/2),Ys=g=>Math.sin(g*Math.PI/2),Xs=g=>-(Math.cos(Math.PI*g)-1)/2,Ds=g=>g===0?0:Math.pow(2,10*(g-1)),Gs=g=>g===1?1:1-Math.pow(2,-10*g),zs=g=>g===0?0:g===1?1:g<.5?Math.pow(2,20*g-10)/2:(2-Math.pow(2,-20*g+10))/2,Vs=g=>1-Math.sqrt(1-g*g),Ns=g=>Math.sqrt(1- --g*g),Hs=g=>g<.5?(1-Math.sqrt(1-4*g*g))/2:(Math.sqrt(1-(-2*g+2)*(-2*g+2))+1)/2,Ve=1.70158,Ne=Ve*1.525,ls=Ve+1,Us=g=>ls*g*g*g-Ve*g*g,qs=g=>1+ls*Math.pow(g-1,3)+Ve*Math.pow(g-1,2),Ks=g=>g<.5?Math.pow(2*g,2)*((Ne+1)*2*g-Ne)/2:(Math.pow(2*g-2,2)*((Ne+1)*(g*2-2)+Ne)+2)/2,cs=2*Math.PI/3,fs=2*Math.PI/4.5,Js=g=>g===0?0:g===1?1:-Math.pow(2,10*g-10)*Math.sin((g*10-10.75)*cs),Qs=g=>g===0?0:g===1?1:Math.pow(2,-10*g)*Math.sin((g*10-.75)*cs)+1,Zs=g=>g===0?0:g===1?1:g<.5?-(Math.pow(2,20*g-10)*Math.sin((20*g-11.125)*fs))/2:Math.pow(2,-20*g+10)*Math.sin((20*g-11.125)*fs)/2+1,He=g=>g<1/2.75?7.5625*g*g:g<2/2.75?7.5625*(g-=1.5/2.75)*g+.75:g<2.5/2.75?7.5625*(g-=2.25/2.75)*g+.9375:7.5625*(g-=2.625/2.75)*g+.984375,js=g=>1-He(1-g),ti=He,ei=g=>g<.5?(1-He(1-2*g))/2:(1+He(2*g-1))/2,Ze=new Map,Ye=(g,t,i,o)=>{const e=`${g},${t},${i},${o}`;if(Ze.has(e))return Ze.get(e);const s=h=>(1-3*i+3*g)*h*h*h+(3*i-6*g)*h*h+3*g*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*i+3*g)*h*h+2*(3*i-6*g)*h+3*g,r=h=>{let l=h;for(let p=0;p<8;p++){const c=s(l)-h;if(Math.abs(c)<1e-6)return l;const d=a(l);if(Math.abs(d)<1e-6)break;l=l-c/d}return l},f=h=>h===0?0:h===1?1:n(r(h));return Ze.set(e,f),f},hs=g=>{const t=g.match(/cubic-bezier\s*\(\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*\)/);if(!t)return null;const[,i,o,e,s]=t.map(Number);return Ye(i,o,e,s)},ds={ease:Ye(.25,.1,.25,1),"ease-in":Ye(.42,0,1,1),"ease-out":Ye(0,0,.58,1),"ease-in-out":Ye(.42,0,.58,1)},Ue={Linear:ns,EaseInQuad:os,EaseOutQuad:as,EaseInOutQuad:rs,EaseInCubic:Es,EaseOutCubic:As,EaseInOutCubic:xs,EaseInQuart:Os,EaseOutQuart:Ls,EaseInOutQuart:Rs,EaseInQuint:Fs,EaseOutQuint:$s,EaseInOutQuint:Bs,EaseInSine:Ws,EaseOutSine:Ys,EaseInOutSine:Xs,EaseInExpo:Ds,EaseOutExpo:Gs,EaseInOutExpo:zs,EaseInCirc:Vs,EaseOutCirc:Ns,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:_s,StepEnd:Ps},si=g=>{const t=g.trim(),i=t.toLowerCase();if(Ue[t])return Ue[t];const o=Object.keys(Ue).find(s=>s.toLowerCase()===i);if(o)return Ue[o];const e=Object.keys(us).find(s=>s.toLowerCase()===i);if(e){const s=hs(us[e].value);if(s)return s}if(ds[i])return ds[i];if(i.startsWith("cubic-bezier")){const s=hs(t);if(s)return s}return ns},us={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=(g,t,i,o,e)=>{if(!g||!t||!i)return g;const s=o.scale_x??1,n=o.scale_y??1,a=(r,f,h)=>{let l=0,p=0;const c=o.rotation*Math.PI/180,d=Math.cos(c),u=Math.sin(c),v=r*s*d-f*n*u+o.x,b=r*s*u+f*n*d+o.y;h.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=i[I.boneId]||[1,0,0,1,0,0],P=v*O[0]+b*O[2]+O[4],_=v*O[1]+b*O[3]+O[5],E=T.rotation*Math.PI/180,A=Math.cos(E),W=Math.sin(E),z=P*T.scaleX*A-_*T.scaleY*W+T.x,Y=P*T.scaleX*W+_*T.scaleY*A+T.y;l+=z*I.amount,p+=Y*I.amount});const y=[...h].sort((I,k)=>k.amount-I.amount);if(y.length>=2&&y[0].amount>0&&y[1].amount>0){const I=e(y[0].boneId),k=e(y[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,P=I.x-T*Math.sin(O),_=I.y+T*Math.cos(O),E=k.length*(k.scale_y??1),A=k.rotation*Math.PI/180,W=k.x-E*Math.sin(A),z=k.y+E*Math.cos(A);let Y=null,G=null,N=!1;const J=1;if(Math.hypot(I.x-k.x,I.y-k.y)<J||Math.hypot(I.x-W,I.y-z)<J?(Y=I.x,G=I.y):(Math.hypot(P-k.x,_-k.y)<J||Math.hypot(P-W,_-z)<J)&&(Y=P,G=_,N=!0),Y!==null&&G!==null){const x=i[y[0].boneId]||[1,0,0,1,0,0],F=x[0]*x[3]-x[1]*x[2];let j=0,X=0;if(F!==0){const tt=(x[2]*x[5]-x[3]*x[4])/F,L=(x[1]*x[4]-x[0]*x[5])/F,R=Math.atan2(-x[1],x[3]);if(!N)j=tt,X=L;else{const ot=-x[2]/F,mt=x[0]/F,bt=Math.hypot(ot,mt),gt=I.length*bt;j=tt-gt*Math.sin(R),X=L+gt*Math.cos(R)}const D=Math.hypot(v-j,b-X),q=Math.hypot(l-Y,p-G);if(q>0&&D>0){const ot=Math.max(q,.01),mt=Math.min(D/ot,3),bt=Y+(l-Y)*mt,gt=G+(p-G)*mt,Et=y[0].amount,It=y[1].amount,vt=Math.min(Et,It)*2,Dt=1-Math.pow(1-vt,4);l=l*(1-Dt)+bt*Dt,p=p*(1-Dt)+gt*Dt}}}}}const m=o.rotation*Math.PI/180,S=Math.cos(m),C=Math.sin(m),w=l-o.x,M=p-o.y;return{x:(w*S+M*C)/s,y:(-w*C+M*S)/n}};return g.map((r,f)=>{const h=t[f];if(!h||h.length===0)return{...r};const l={...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);l.in_x=p.x,l.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);l.out_x=p.x,l.out_y=p.y}return l})},ps={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(){lt(this,"artboard",null);lt(this,"objectStates",new Map);lt(this,"physicsEngine",null);lt(this,"activeStateMachine",null);lt(this,"inputs",new Map);lt(this,"inputNameMap",new Map);lt(this,"layerStates",new Map);lt(this,"pretextCache",new Map);lt(this,"pointerHistory",[]);lt(this,"MAX_HISTORY",200);lt(this,"imageCache",new Map);lt(this,"lastValidSvgImgMap",new Map);lt(this,"maskBuffer",null);lt(this,"maskCtx",null);lt(this,"lumaBuffer",null);lt(this,"lumaCtx",null);lt(this,"_noiseTileCanvas",null);lt(this,"layout",{fit:"Contain",alignment:"Center"});lt(this,"onTrigger");lt(this,"onInputUpdate");lt(this,"onComponentChange");lt(this,"onToggle");lt(this,"onInputChange");lt(this,"onInputFocus");lt(this,"onInputBlur");lt(this,"onLog");lt(this,"onButtonClick");lt(this,"onGraphPointClick");lt(this,"justFiredTriggers",new Set);lt(this,"rootTransform",null);lt(this,"canvasWidth",0);lt(this,"canvasHeight",0);lt(this,"lastHoveredObjectId",null);lt(this,"_lastPointerPos",null);lt(this,"_prevPointerPos",null);lt(this,"_mouseDelta",{dx:0,dy:0});lt(this,"focusedId",null);lt(this,"draggingSliderId",null);lt(this,"draggingJoystickId",null);lt(this,"activeDropdownId",null);lt(this,"activeObjectId",null);lt(this,"draggingListViewId",null);lt(this,"scrollOffset",{x:0,y:0});lt(this,"_totalScroll",{x:0,y:0});lt(this,"draggingBehaviors",new Set);lt(this,"isMouseDown",!1);lt(this,"activeKeys",new Set);lt(this,"_layoutAnimCache",new Map);lt(this,"_springChainState",new Map);lt(this,"_emitterPools",new Map);lt(this,"objectVelocities",new Map);lt(this,"currentTime",0);lt(this,"frameCount",0);lt(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});lt(this,"onLogicUpdate");lt(this,"logicNodeValues",new Map);lt(this,"logicNodeState",new Map);lt(this,"pointerDownTimes",new Map);lt(this,"activeHoverIds",new Set);lt(this,"onNavigation");lt(this,"periodicTriggerTimes",new Map);lt(this,"wasInView",new Set);lt(this,"scrollProgressLastValue",new Map);lt(this,"debug_objectsRendered",0);lt(this,"debug_objectsTotal",0);lt(this,"lastRenderTime",0);lt(this,"debugMode",!1);lt(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:i,isClosed:o}=this.svgPathToPoints(t.data);t.points=i,t.is_closed===void 0&&(t.is_closed=o)}svgPathToPoints(t){const i=/([MLHVCSQTAZmlhvcsqtaz])([^MLHVCSQTAZmlhvcsqtaz]*)/g,o=/[-+]?(?:\d*\.\d+|\d+)(?:[eE][-+]?\d+)?/g,e=[];let s=!1,n=0,a=0,r=0,f=0,h=0,l=0,p;for(;(p=i.exec(t))!==null;){const c=p[1],d=(p[2].match(o)||[]).map(parseFloat),u=c===c.toLowerCase(),v=c.toUpperCase();let b=0;const y=S=>{let C=d[b++];return u&&(C+=S?n:a),C},m=()=>({x:y(!0),y:y(!1)});switch(v){case"M":{const S=m();for(h=n=S.x,l=a=S.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a,moveTo:!0});b<d.length;){const C=m();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(;b<d.length;){const S=m();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(;b<d.length;)n=y(!0),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"V":for(;b<d.length;)a=y(!1),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"C":for(;b<d.length;){const S=m(),C=m(),w=m();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,f=C.y}break;case"S":for(;b<d.length;){const S={x:2*n-r,y:2*a-f},C=m(),w=m();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,f=C.y}break;case"Q":for(;b<d.length;){const S=m(),C=m();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,f=S.y}break;case"T":for(;b<d.length;){const S={x:2*n-r,y:2*a-f},C=m();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,f=S.y}break;case"Z":if(s=!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=l;break;default:if(d.length>=2){const S=m();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:s}}setOnLogCallback(t){this.onLog=t}debugLog(t){this.onLog&&this.onLog(t)}setInputFocusCallback(t){this.onInputFocus=t}setInputBlurCallback(t){this.onInputBlur=t}updateConstraint(t,i,o){var s;const e=(s=this.artboard)==null?void 0:s.objects.find(n=>n.id===t);e&&e.constraints&&e.constraints[i]&&(e.constraints[i]={...e.constraints[i],...o},o.useSpring===!1&&this.objectVelocities.delete(t))}log(...t){this.debugMode&&console.log(...t)}warn(...t){this.debugMode&&console.warn(...t)}setInternalInput(t,i){this.inputs.set(t,i),this.onInputUpdate&&this.onInputUpdate(t,i)}setLayout(t,i){this.layout={fit:t,alignment:i}}getActiveStateIds(t="Base Layer"){const i=this.layerStates.get(t);return i?i.currentStateIds:[]}getObjectState(t){return this.objectStates.get(t)}updateObjectOptions(t,i){const o=this.objectStates.get(t);o&&(o.options={...o.options,...i})}updateGraphData(t,i){var e,s;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:i,lineColor:"#3b82f6",lineWidth:2,showArea:!1}]:n.datasets[0].data=i;const a=this.objectStates.get(o.id);a&&((s=a.geometry)==null?void 0:s.type)==="LineGraph"&&(!a.geometry.datasets||a.geometry.datasets.length===0?a.geometry.datasets=JSON.parse(JSON.stringify(n.datasets)):a.geometry.datasets[0].data=[...i]),n.datasets[0].inputId&&this.updateInput(n.datasets[0].inputId,i)}else this.updateInput(t,i)}load(t){var n,a;if(!t)return;let i=this.decompressStrings(t);const o=[],e=new Set,s=r=>{r&&r.forEach(f=>{if(e.has(f.id))return;const h={...f},l=h.childrenObjects||[];e.add(h.id),o.push(h),s(l)})};if(s(i.objects||[]),o.length>(i.objects||[]).length&&this.log(`[Engine] Flattened artboard from ${(i.objects||[]).length} to ${o.length} objects.`),i.objects=o,this.artboard=i,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(f=>{r.set(f.id,f),f.children||(f.children=[])}),this.artboard.objects.forEach(f=>{if(f.parentId){const h=r.get(f.parentId);h&&(h.children||(h.children=[]),h.children.includes(f.id)||h.children.push(f.id))}})}this.loadFonts(),this.preloadImages(this.artboard),this.reset(),this.advance(0)}preloadImages(t){if(!t||!t.objects)return;const i=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=s=>{console.error("[ExodeUI Preload] failed:",s,`Src: ${o.substring(0,80)}...`)},e.src=o,this.imageCache.set(o,e)};t.objects.forEach(o=>{var e,s,n;(e=o.geometry)!=null&&e.src&&i(o.geometry.src),(n=(s=o.style)==null?void 0:s.fill)!=null&&n.src&&i(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 i={};for(const[o,e]of Object.entries(t))i[o]=this.decompressStrings(e);return i}return Array.isArray(t)?t.map(i=>this.decompressStrings(i)):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(i=>{var n,a,r,f,h,l,p;const o=i.width??((n=i.geometry)==null?void 0:n.width)??0,e=i.height??((a=i.geometry)==null?void 0:a.height)??0,s=i.cornerRadius??i.corner_radius??((r=i.geometry)==null?void 0:r.corner_radius)??((f=i.geometry)==null?void 0:f.cornerRadius)??0;this.objectStates.set(i.id,{...i.transform||{},x:((h=i.transform)==null?void 0:h.x)??i.x??0,y:((l=i.transform)==null?void 0:l.y)??i.y??0,width:o,height:e,cornerRadius:s,corner_radius:s,clipContent:i.clipContent??!1,autoLayout:i.autoLayout?JSON.parse(JSON.stringify(i.autoLayout)):void 0,layoutProps:i.layoutProps?JSON.parse(JSON.stringify(i.layoutProps)):void 0,opacity:((p=i.transform)==null?void 0:p.opacity)!==void 0?i.transform.opacity:i.opacity!==void 0?i.opacity:100,visible:i.visible!==void 0?i.visible:i.isVisible!==void 0?i.isVisible:!0,blendMode:i.blendMode||"Normal",style:JSON.parse(JSON.stringify(i.style||{})),geometry:JSON.parse(JSON.stringify(i.geometry||{})),options:i.options?JSON.parse(JSON.stringify(i.options)):{},masks:i.masks?JSON.parse(JSON.stringify(i.masks)):[],zIndex:i.zIndex!==void 0?i.zIndex:void 0})}),this.artboard.objects.some(i=>{var o;return(o=i.physics)==null?void 0:o.enabled})){this.physicsEngine=new is;const i=this.artboard.physics?{x:this.artboard.physics.gravity.x,y:this.artboard.physics.gravity.y}:{x:0,y:1};this.physicsEngine.init(i).then(()=>{var o;this.physicsEngine&&((o=this.artboard)==null||o.objects.forEach(e=>{var s,n;if((s=e.physics)!=null&&s.enabled&&e.type==="Shape"){const a=this.objectStates.get(e.id);if(!a)return;const r=e.geometry.width||100,f=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:f,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(i=>{this.inputs.set(i.id,i.value);const o=this.inputNameMap.get(i.name)||[];o.includes(i.id)||o.push(i.id),this.inputNameMap.set(i.name,o)}),this.artboard.stateMachine&&(this.activeStateMachine=this.artboard.stateMachine,this.activeStateMachine.inputs.forEach(i=>{this.inputs.set(i.id,i.value.value);const o=this.inputNameMap.get(i.name)||[];o.push(i.id),this.inputNameMap.set(i.name,o)}),this.activeStateMachine.layers.forEach(i=>{let o=i.states.find(e=>e.id===i.entryStateId);!o&&i.states.length>0&&(console.warn(`[ExodeUI] Invalid entryStateId "${i.entryStateId}" in layer "${i.name}". Falling back to first state.`),o=i.states[0]),o&&this.enterStates(i.name,[o.id])}),this.evaluateTransitions()),this.initGlobalAnimationTriggers(),this.updateAutoLayout(!0),this.loadFonts()}updateAutoLayout(t=!1){var s;if(!this.artboard)return;const i=new Map;this.artboard.objects.forEach(n=>i.set(n.id,n));const o=.15,e=n=>{n.forEach(a=>{const r=this.objectStates.get(a.id);if(r){const f=Math.abs(r.x-a.x),h=Math.abs(r.y-a.y);!t&&(f>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((s=this.artboard.autoLayout)!=null&&s.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(l=>i.get(l)).filter(l=>!!l),f=this.objectStates.get(n.id);if(!f)return;const h=ss(f,r,l=>this.objectStates.get(l));h.frameWidth!==void 0&&(f.width=h.frameWidth),h.frameHeight!==void 0&&(f.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 i="";t.forEach(n=>{const a=n.replace(/ /g,"+");i+=`&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(i.length>0){const n=`https://fonts.googleapis.com/css2?display=swap${i}`;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 s=[];if(t.forEach(n=>{n.toLowerCase().includes("clash display")&&s.push("clash-display@200,300,400,500,600,700")}),s.length>0){const n=`https://api.fontshare.com/v2/css?f[]=${s.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,i){var n;if(i.length===0)return;const o=this.layerStates.get(t);if(o&&o.currentStateIds.length===i.length&&i.every(r=>o.currentStateIds.includes(r))&&this.justFiredTriggers.size===0)return;const e=[];let s=0;if(this.artboard&&this.activeStateMachine){const a=this.activeStateMachine.layers.find(r=>r.name===t);if(a)for(const r of i){const f=a.states.find(h=>h.id===r);if(f)if(f.isBlendState&&f.blendAnimations&&f.blendAnimations.length>0)e.push({animation:null,state:f}),f.blendAnimations.forEach(h=>{const l=this.artboard.animations.find(p=>p.id===h.animationId);l&&(s=Math.max(s,l.duration))});else{let h=null;f.animationId&&(h=this.artboard.animations.find(l=>l.id===f.animationId)||null),h||(h=this.artboard.animations.find(l=>{var p,c;return l.name===f.name||l.id===f.name||(f.name==="Entry"||f.id==="entry")&&(((p=l.name)==null?void 0:p.toLowerCase())==="onload"||((c=l.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:f}),s=Math.max(s,h.duration)))}}}this.layerStates.set(t,{currentStateIds:i,animations:e,time:0,duration:s})}setInputBool(t,i){this.updateInput(t,i)}setInputNumber(t,i){this.updateInput(t,i)}fireTrigger(t){this.updateInput(t,!0)}setInputText(t,i){this.updateInput(t,i)}setInputNumberArray(t,i){this.updateInput(t,i)}setInputStringArray(t,i){this.updateInput(t,i)}updateObjectProperty(t,i,o){const e=this.objectStates.get(t);if(e)if(i.includes(".")){const s=i.split(".");let n=e;for(let a=0;a<s.length-1;a++)n[s[a]]||(n[s[a]]={}),n=n[s[a]];n[s[s.length-1]]=o}else e[i]=o}updateInput(t,i){var n,a,r;let o;if(this.inputs.has(t)){const f=(n=this.activeStateMachine)==null?void 0:n.inputs.find(h=>h.id===t);f&&typeof f.value=="object"&&(o=f.value.type)}else{const f=this.inputNameMap.get(t);if(f&&f.length>0){const h=(a=this.activeStateMachine)==null?void 0:a.inputs.find(l=>l.id===f[0]);h&&typeof h.value=="object"&&(o=h.value.type)}}let e=i;o==="Trigger"&&(i===1?e=!0:i===0&&(e=!1)),this.inputs.has(t)&&this.setInternalInput(t,e);const s=this.inputNameMap.get(t);s&&s.forEach(f=>this.setInternalInput(f,e)),o==="Trigger"&&e===!0&&(this.justFiredTriggers.add(t),s&&s.forEach(f=>this.justFiredTriggers.add(f))),Array.isArray(e)&&((r=this.artboard)==null||r.objects.forEach(f=>{if(f.inputId===t||f.name===t){const h=this.objectStates.get(f.id);h&&h.options&&(f.type==="ListView"||f.variant==="listview"?h.options.items=e:(f.type==="Dropdown"||f.variant==="dropdown")&&(h.options.optionsList=e))}})),this.evaluateTransitions(),this.evaluateVariableTriggers(t,e)}evaluateVariableTriggers(t,i){if(!this.artboard)return;const o=this.artboard.animationFlow||[],e=this.inputNameMap.get(t);o.forEach(s=>{if(s.trigger==="variable"&&s.conditionVariableId&&s.targetAnimationId&&(s.conditionVariableId===t||e&&e.includes(s.conditionVariableId))){const a=s.conditionOperator||"IsTrue",r=s.conditionValue;let f=!1;switch(a){case"Equal":case"==":f=i==r;break;case"NotEqual":case"!=":f=i!=r;break;case"GreaterThan":case">":f=i>r;break;case"LessThan":case"<":f=i<r;break;case"GreaterEqual":case">=":f=i>=r;break;case"LessEqual":case"<=":f=i<=r;break;case"IsTrue":f=!!i;break;case"IsFalse":f=!i;break}if(f){const h=s.delay||0;h<=0?this.triggerGlobalAnimation(s.targetAnimationId,s.subAnimationIds,s.loop,s.id):setTimeout(()=>this.triggerGlobalAnimation(s.targetAnimationId,s.subAnimationIds,s.loop,s.id),h)}}})}evaluateTransitions(){this.activeStateMachine&&(this.activeStateMachine.layers.forEach(t=>{const i=this.layerStates.get(t.name);if(!i||i.currentStateIds.length===0)return;const o=[];let e=!1;for(const s of i.currentStateIds){const n=t.states.find(r=>r.id===s);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(s)}if(!e){const s=this.findGlobalTransition(t,i.currentStateIds);s&&(o.length=0,o.push(s.targetStateId),e=!0,s.conditions&&(s.conditions||[]).forEach(n=>{var r;const a=(r=this.activeStateMachine)==null?void 0:r.inputs.find(f=>f.id===n.inputId);a&&typeof a.value=="object"&&a.value.type==="Trigger"&&this.setInternalInput(n.inputId,!1)}))}if(e){const s=Array.from(new Set(o));this.enterStates(t.name,s)}}),this.justFiredTriggers.size>0&&(this.justFiredTriggers.forEach(t=>{var o,e;this.setInternalInput(t,!1);const i=(o=this.activeStateMachine)==null?void 0:o.inputs.find(s=>s.id===t);i&&this.inputNameMap.has(i.name)&&((e=this.inputNameMap.get(i.name))==null||e.forEach(s=>this.setInternalInput(s,!1)))}),this.justFiredTriggers.clear()))}findGlobalTransition(t,i){for(const o of t.states)if(!(i.includes(o.id)&&this.justFiredTriggers.size===0)){for(const s of o.transitions||[])if(!(i.includes(s.targetStateId)&&this.justFiredTriggers.size===0)&&this.checkConditions(s.conditions))return s}return null}checkConditions(t){return!t||t.length===0?!0:t.every(i=>{const o=i.inputId,e=i.op,s=i.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==s;break;case"NotEqual":case"!=":a=n!=s;break;case"GreaterThan":case">":a=n>s;break;case"LessThan":case"<":a=n<s;break;case"GreaterEqual":case">=":a=n>=s;break;case"LessEqual":case"<=":a=n<=s;break;case"IsTrue":a=!!n;break;case"IsFalse":a=!n;break;default:a=!1}return a||this.justFiredTriggers.has(o),a})}evaluateLogicTree(t,i=null,o=new Set){var a,r,f,h,l,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,v)=>{const b=e.inputs.find(y=>y.id===u);return b?b.sourceId?this.evaluateLogicTree(b.sourceId,b.sourceHandleId,o):b.value!==void 0?b.value:v:v};let d=0;switch(e.op){case wt.AND:d=c("a",!1)&&c("b",!1);break;case wt.OR:d=c("a",!1)||c("b",!1);break;case wt.NOT:d=!c("in",!1);break;case wt.XOR:d=!!c("a",!1)!=!!c("b",!1);break;case wt.OBJECT:d=e.name;break;case wt.PROPERTY:case wt.GET_PROPERTY:{const u=c("id","");if(!u){d=0;break}const v=e.name;if(!v||v==="GET_PROPERTY"||v==="PROPERTY"){d=0;break}const b=this.objectStates.get(u);if(!b){d=0;break}v in b?d=b[v]:d=this.resolvePath(b,v);break}case wt.SET_PROPERTY:{const u=c("id",""),v=c("value",void 0);if(!u||v===void 0){d=0;break}const b=e.name;if(!b||b==="SET_PROPERTY"){d=0;break}const y=this.objectStates.get(u);if(!y){d=0;break}if(["x","y","rotation","scale_x","scale_y","opacity","width","height","cornerRadius","visible","zIndex"].includes(b))y[b]=v,d=v;else{const S=b.split(".");let C=y;for(let M=0;M<S.length-1;M++){const I=S[M];C[I]===void 0&&(C[I]={}),C=C[I]}const w=S[S.length-1];C[w]=v,d=v}break}case wt.ADD:d=c("a",0)+c("b",0);break;case wt.SUB:d=c("a",0)-c("b",0);break;case wt.MUL:d=c("a",0)*c("b",0);break;case wt.DIV:{const u=c("b",1);d=u===0?0:c("a",0)/u;break}case wt.MOD:d=c("a",0)%c("b",1);break;case wt.POW:d=Math.pow(c("a",0),c("b",1));break;case wt.ABS:d=Math.abs(c("in",0));break;case wt.ROUND:d=Math.round(c("in",0));break;case wt.FLOOR:d=Math.floor(c("in",0));break;case wt.CEIL:d=Math.ceil(c("in",0));break;case wt.SIN:d=Math.sin(c("in",0));break;case wt.COS:d=Math.cos(c("in",0));break;case wt.TAN:d=Math.tan(c("in",0));break;case wt.CLAMP:{const u=c("in",0),v=c("min",0),b=c("max",1);d=Math.max(v,Math.min(b,u));break}case wt.REMAP:{const u=c("in",0),v=c("inMin",0),b=c("inMax",100),y=c("outMin",0),m=c("outMax",1);d=b===v?y:y+(u-v)*(m-y)/(b-v);break}case wt.EQ:d=c("a",0)==c("b",0);break;case wt.NEQ:d=c("a",0)!=c("b",0);break;case wt.GT:d=c("a",0)>c("b",0);break;case wt.LT:d=c("a",0)<c("b",0);break;case wt.GTE:d=c("a",0)>=c("b",0);break;case wt.LTE:d=c("a",0)<=c("b",0);break;case wt.IF_ELSE:d=c("cond",!1)?c("then",0):c("else",0);break;case wt.VALUE:d=e.value!==void 0?e.value:0;break;case wt.INPUT:d=this.inputs.get(e.name)??0;break;case wt.LOG:{const u=c("in","");this.debugLog(`[User Logic] ${u}`),d=u;break}case wt.SCROLL_X:d=this.inputs.get("scrollX")??0;break;case wt.SCROLL_Y:d=this.inputs.get("scrollY")??0;break;case wt.MOUSE_X:d=this.inputs.get("mouseX")??0;break;case wt.MOUSE_Y:d=this.inputs.get("mouseY")??0;break;case wt.IS_MOUSE_DOWN:d=this.inputs.get("isMouseDown")??!1;break;case wt.EFFECTOR:{const u=c("id",""),v=c("intensity",1),b=c("trigger",!0);if(!u||!b){d=0;break}const y=e.name;if(!y){d=0;break}const m=this.objectStates.get(u);if(!m){d=0;break}if(["glitch","halftone","pixelate","noise","acid_gradient","acid_rave","shimmer"].includes(y))m.style||(m.style={}),m.style.artEffect={enabled:!0,type:y,intensity:v},d=1;else{m.behaviors||(m.behaviors=[]);let C=m.behaviors.find(w=>w.type===y);C?(C.enabled=!0,C.settings||(C.settings={}),C.settings.intensity=v):(C={id:`eff_${Date.now()}_${y}`,type:y,enabled:!0,sensors:[],settings:{intensity:v}},m.behaviors.push(C)),d=1}break}case wt.MONITOR:{d=c("in",0);break}case wt.SPRING_PULL:{const u=c("objectId",""),v=c("forceX",0),b=c("forceY",0);u&&((f=this.artboard)==null||f.objects.forEach(y=>{y.behaviors&&y.behaviors.forEach(m=>{var S;if(m.type===H.SpringChain&&((S=m.settings)!=null&&S.connections)&&(m.settings.connections.some(w=>w.targetId===u)||y.id===u)){this._springChainState.has(y.id)||this._springChainState.set(y.id,new Map);const w=this._springChainState.get(y.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+=v,M.vy+=b)}})})),d=1;break}case wt.SPRING_SETTLE:{const u=c("objectId","");let v=!0;if(u){const b=c("threshold",1);this._springChainState.forEach(y=>{const m=y.get(u);m&&(Math.abs(m.vx)>b||Math.abs(m.vy)>b)&&(v=!1)})}d=v;break}case wt.EMIT:{const u=c("objectId",""),v=c("count",20);u&&((h=this.artboard)==null||h.objects.forEach(b=>{b.behaviors&&b.behaviors.forEach(y=>{y.type===H.ParticleEmitter&&b.id===u&&(y._pendingBurst=(y._pendingBurst||0)+v)})})),d=1;break}default:d=0;break}if(this.logicNodeValues.set(t,d),e.op===wt.DELAY){const u=c("delay",0),v=c("in",0);let b=this.logicNodeState.get(t);for(b||(b={queue:[]},this.logicNodeState.set(t,b)),b.queue.push({time:this.currentTime+u,value:v});b.queue.length>0&&b.queue[0].time<=this.currentTime;)b.lastValue=b.queue.shift().value;d=b.lastValue??0}return d}const s=(l=this.activeStateMachine)==null?void 0:l.inputs.find(c=>c.id===t||c.name===t);if(s&&s.sourceId&&!o.has(s.sourceId)){const c=this.evaluateLogicTree(s.sourceId,s.sourceHandleId,o);return this.inputs.set(s.id,c),c}let n=this.inputs.get(t)??(s?this.inputs.get(s.id):void 0);if((this.justFiredTriggers.has(t)||s&&this.justFiredTriggers.has(s.id))&&(n=!0),i&&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(i==="source-greater")return n>d;if(i==="source-less")return n<d;if(i==="source-equal")return n===d}if(i==="source-true")return n===!0;if(i==="source-false")return n===!1;if(i==="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===wt.SET_PROPERTY||t.op===wt.EFFECTOR)&&this.evaluateLogicTree(t.id)})}resolvePath(t,i){const o=i.split(".");let e=t;for(const s of o)if(e&&typeof e=="object"&&s in e)e=e[s];else return;return e}seek(t){this.artboard&&(this.currentTime=t,this.layerStates.forEach(i=>{i.time=t,i.time>(i.duration||0)&&(i.animations.some(e=>{var s;return((s=e.state)==null?void 0:s.loop)===!0})?i.time%=i.duration||1:i.time=i.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 s=this.physicsEngine.getPosition(o.id),n=this.physicsEngine.getRotation(o.id),a=this.objectStates.get(o.id);a&&s!==null&&n!==null&&(a.x=s.x,a.y=s.y,a.rotation=n*(180/Math.PI))}})),this.activeStateMachine&&(this.runLogicNodes(),this.evaluateTransitions());const i=[];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_")&&i.push(e))}o.animations.forEach(s=>{var n;(n=s.state)!=null&&n.isBlendState&&s.state.blendAnimations?this.applyBlendState(s.state,o.time):s.animation&&this.applyAnimation(s.animation,o.time,s.filterObjectIds)})}}),i.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 s,n,a,r,f,h,l;if(o.phase==="entry")o.time+=t,o.time>=o.animation.duration&&((a=(n=(s=this.artboard)==null?void 0:s.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=(f=(r=this.artboard)==null?void 0:r.objects.find(u=>u.id===e))==null?void 0:f.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=(l=this.artboard)==null?void 0:l.animations.find(v=>v.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(i=>{var e,s,n;const o=(e=i.style)==null?void 0:e.analytics;if(o&&o.isEnabled&&o.triggerType==="visible"){const a=this.objectStates.get(i.id);if(a&&a.visible!==!1){const r=this.getGlobalTransform(i.id),f=(((s=i.geometry)==null?void 0:s.width)||100)*(r.scale_x||1),h=(((n=i.geometry)==null?void 0:n.height)||100)*(r.scale_y||1),l=50,p=r.x+f/2>=-this.canvasWidth/2-l&&r.x-f/2<=this.canvasWidth/2+l&&r.y+h/2>=-this.canvasHeight/2-l&&r.y-h/2<=this.canvasHeight/2+l,c=`analytics_${i.id}`,d=this.wasInView.has(c);p&&!d&&this.fireAnalyticsEvent(i.id,"visible"),p?this.wasInView.add(c):this.wasInView.delete(c)}}}),this.artboard.objects.forEach(i=>{const o=i.interactions||[];o.length!==0&&o.forEach(e=>{const s=e.triggers||[e.event||e.trigger];s&&s.forEach(n=>{var r,f,h;const a=n.toLowerCase();if(a==="on interval"||a==="oninterval"){const l=e.intervalValue||2e3,p=this.periodicTriggerTimes.get(e.id)||0;this.currentTime*1e3-p>=l&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(i.id,"On Interval"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="on delay"||a==="ondelay"){const l=e.delayValue||1e3;!this.periodicTriggerTimes.has(e.id)&&this.currentTime*1e3>=l&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(i.id,"On Delay"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="scroll into view"||a==="scrollintoview"){const l=this.objectStates.get(i.id);if(l&&l.visible!==!1){const p=this.getGlobalTransform(i.id),c=(((r=i.geometry)==null?void 0:r.width)||100)*(p.scale_x||1),d=(((f=i.geometry)==null?void 0:f.height)||100)*(p.scale_y||1),u=50,v=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,b=this.wasInView.has(i.id);v&&!b&&(!e.conditions||this.checkConditions(e.conditions))&&this.fireEventForObject(i.id,"Scroll Into View"),v?this.wasInView.add(i.id):this.wasInView.delete(i.id)}}if(a==="scroll progress"||a==="scrollprogress"){const l=Math.abs(this.scrollOffset.y)/(((h=this.artboard)==null?void 0:h.height)||1e3),p=this.scrollProgressLastValue.get(e.id)||0;Math.abs(l-p)>.001&&(this.scrollProgressLastValue.set(e.id,l),(e.action==="Set Input"||e.action==="setInput")&&this.updateInput(e.targetInputId,l))}})})}))}solveConstraints(t){this.artboard&&this.artboard.objects.forEach(i=>{if(!i.constraints||i.constraints.length===0)return;const o=this.objectStates.get(i.id);if(!o)return;const e=this.getGlobalTransform(i.id);if(i.constraints.forEach((s,n)=>{var h,l,p,c,d,u,v,b,y;const a=((h=o.constraints)==null?void 0:h[n])||{},r={...s,...a},f=r.strength??1;if(r.type==="Translation"){const m=this.getGlobalTransform(r.targetId);if(m){const S=r.offsetX||0,C=r.offsetY||0,w=m.x+S,M=m.y+C,I=r.useSpring;if(I){const T=this.objectVelocities.get(i.id)||{vx:0,vy:0},{x:O,y:P,vx:_,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)*f),r.copyY&&(e.y=e.y+(P-e.y)*f),this.objectVelocities.set(i.id,{vx:_,vy:E})}else r.copyX&&(e.x=e.x+(w-e.x)*f),r.copyY&&(e.y=e.y+(M-e.y)*f);let k=!1;if((l=r.limitX)!=null&&l.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((p=r.limitY)!=null&&p.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(i.id,{vx:0,vy:0})}}else if(r.type==="Rotation"){const m=this.getGlobalTransform(r.targetId);if(m){let C=(m.rotation+(r.offset||0)-e.rotation)%360;C>180&&(C-=360),C<-180&&(C+=360),e.rotation=e.rotation+C*f}}else if(r.type==="Scale"){const m=this.getGlobalTransform(r.targetId);m&&(r.copyX&&(e.scale_x=e.scale_x+(m.scale_x-e.scale_x)*f),r.copyY&&(e.scale_y=e.scale_y+(m.scale_y-e.scale_y)*f))}else if(r.type==="Transform"){const m=this.getGlobalTransform(r.targetId);if(m){e.x=e.x+(m.x-e.x)*f,e.y=e.y+(m.y-e.y)*f;let S=(m.rotation-e.rotation)%360;S>180&&(S-=360),S<-180&&(S+=360),e.rotation=e.rotation+S*f,e.scale_x=e.scale_x+(m.scale_x-e.scale_x)*f,e.scale_y=e.scale_y+(m.scale_y-e.scale_y)*f}}else if(r.type==="FollowPointer"){const m=((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(i.id)||{vx:0,vy:0},{x:I,y:k,vx:T,vy:O}=this.computeSpring(e.x,e.y,M.vx,M.vy,m,S,r,t);e.x=I,e.y=k,this.objectVelocities.set(i.id,{vx:T,vy:O})}else e.x=e.x+(m-e.x)*f,e.y=e.y+(S-e.y)*f;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((v=r.limitY)!=null&&v.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(i.id,{vx:0,vy:0})}else if(r.type==="Distance"){const m=this.getGlobalTransform(r.targetId);if(m){const S=e.x-m.x,C=e.y-m.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===m.x&&e.y===m.y?1:I/w;e.x=e.x+(m.x+S*k-e.x)*f,e.y=e.y+(m.y+C*k-e.y)*f}}}else if(r.type==="FollowPath"){const m=(b=this.artboard)==null?void 0:b.objects.find(S=>S.id===r.targetId);if(m){const S=this.getGlobalTransform(m.id);if(S){let C=m.geometry;if(m.type==="Frame"||m.type==="Group"||!C||C.type!=="Path"&&C.type!=="Ellipse"&&C.type!=="Rectangle"){const F=(y=this.artboard)==null?void 0:y.objects.find(j=>j.parentId===m.id&&j.type==="Shape"&&j.geometry&&(j.geometry.type==="Path"||j.geometry.type==="Ellipse"||j.geometry.type==="Rectangle"));F&&(C=F.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),P=Math.sin(T),_=k.x*S.scale_x*O-k.y*S.scale_y*P,E=k.x*S.scale_x*P+k.y*S.scale_y*O;let A=S.rotation+(r.offsetRotation||0);if(r.orient){const F=Math.cos(k.angle),j=Math.sin(k.angle),X=F*S.scale_x*O-j*S.scale_y*P,tt=F*S.scale_x*P+j*S.scale_y*O;A=Math.atan2(tt,X)*180/Math.PI+(r.offsetRotation||0)}const W=A*Math.PI/180,z=Math.cos(W),Y=Math.sin(W),G=(r.offsetX||0)*z-(r.offsetY||0)*Y,N=(r.offsetX||0)*Y+(r.offsetY||0)*z,J=S.x+_+G,x=S.y+E+N;if(e.x=e.x+(J-e.x)*f,e.y=e.y+(x-e.y)*f,r.orient){let F=(A-e.rotation)%360;F>180&&(F-=360),F<-180&&(F+=360),e.rotation=e.rotation+F*f}}}}else if(r.type==="IK"){const m=this.getGlobalTransform(r.targetId);m&&this.solveIK(i,m,r.boneCount||2,f)}}),i.constraints.some(s=>s.type!=="IK")){const s=this.globalToLocal(i.parentId,e);o.x=s.x,o.y=s.y,o.rotation=s.rotation,o.flip_x=s.scale_x<0,o.scale_x=Math.abs(s.scale_x),o.flip_y=s.scale_y<0,o.scale_y=Math.abs(s.scale_y)}})}getGlobalTransform(t){var l,p;const i=this.objectStates.get(t);if(!i)return{x:0,y:0,rotation:0,scale_x:1,scale_y:1};const o=(l=this.artboard)==null?void 0:l.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:i.x,y:i.y,rotation:i.rotation,scale_x:(i.scale_x??1)*(i.flip_x?-1:1),scale_y:(i.scale_y??1)*(i.flip_y?-1:1),length:e};const s=this.getGlobalTransform(o.parentId),n=s.rotation*Math.PI/180,a=Math.cos(n),r=Math.sin(n),f=s.x+(i.x*s.scale_x*a-i.y*s.scale_y*r),h=s.y+(i.x*s.scale_x*r+i.y*s.scale_y*a);return{x:f,y:h,rotation:s.rotation+i.rotation,scale_x:s.scale_x*(i.scale_x??1)*(i.flip_x?-1:1),scale_y:s.scale_y*(i.scale_y??1)*(i.flip_y?-1:1),length:e}}globalToLocal(t,i){if(!t)return i;const o=this.getGlobalTransform(t),e=o.scale_x===0?0:1/o.scale_x,s=o.scale_y===0?0:1/o.scale_y,n=-o.rotation*Math.PI/180,a=Math.cos(n),r=Math.sin(n),f=i.x-o.x,h=i.y-o.y,l=(f*a-h*r)*e,p=(f*r+h*a)*s;return{x:l,y:p,rotation:i.rotation-o.rotation,scale_x:i.scale_x/(o.scale_x||1),scale_y:i.scale_y/(o.scale_y||1)}}solveIK(t,i,o,e){var f;const s=[];let n=t.id;for(let h=0;h<o&&n;h++){const l=(f=this.artboard)==null?void 0:f.objects.find(p=>p.id===n);if(!l)break;s.push({id:n,local:this.objectStates.get(n),global:this.getGlobalTransform(n)}),n=l.parentId}if(s.length<2)return;const a=s.reverse(),r=5;for(let h=0;h<r;h++){const l=this.getGlobalTransform(t.id);for(let p=a.length-2;p>=0;p--){const c=a[p],d=this.getGlobalTransform(c.id),u=l.x-d.x,v=l.y-d.y,b=i.x-d.x,y=i.y-d.y,m=Math.sqrt(u*u+v*v),S=Math.sqrt(b*b+y*y);if(m>.001&&S>.001){const C=Math.atan2(v,u);let M=(Math.atan2(y,b)-C)*180/Math.PI;M*=e;const I=this.objectStates.get(c.id);I&&(I.rotation+=M)}}}}computeSpring(t,i,o,e,s,n,a,r){const f=a.stiffness??100,h=a.damping??10,l=a.mass??1,p=-f*(t-s),c=-f*(i-n),d=-h*o,u=-h*e,v=(p+d)/l,b=(c+u)/l,y=o+v*r,m=e+b*r,S=t+y*r,C=i+m*r;return{x:S,y:C,vx:y,vy:m}}handlePointerInput(t,i,o,e,s){if(!this.artboard)return;const n=this.calculateTransform(e,s,this.artboard.width,this.artboard.height,this.layout.fit,this.layout.alignment),a=(i-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,i){const o=this.scrollOffset.x,e=this.scrollOffset.y;this.scrollOffset={x:t,y:i},this._totalScroll.x+=t-o,this._totalScroll.y+=i-e,this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}handleWheel(t,i){this._totalScroll.x+=t,this._totalScroll.y+=i,this.scrollOffset={x:this._totalScroll.x,y:this._totalScroll.y},this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}handlePointerEvent(t,i,o){var r,f,h,l,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 s=(c,d)=>{var S;let u=d;d==="click"?u="onClick":d==="down"?u="onPointerDown":d==="up"?u="onPointerUp":d==="blur"&&(u="onPointerLeave");const v=new Set([u]);d==="move"&&v.add("onPointerEnter").add("hover").add("onPointerLeave").add("blur"),u==="onClick"&&v.add("click"),u==="onPointerDown"&&v.add("pointerDown"),u==="onPointerUp"&&v.add("pointerUp");const b=["button","toggle","toggle_button","dropdown","listview","inputbox","slider","checkbox","radiogroup","joystick"];return!!(c.type==="Component"&&b.includes(c.variant)||c.type==="Joystick"||b.includes((S=c.type)==null?void 0:S.toLowerCase())||(c.interactions||[]).some(C=>v.has(C.event))||(c.triggers||[]).some(C=>v.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,i,o)&&(n||(n=d),s(d,t))){e=d;break}}!e&&n&&(e=n),this.pointerHistory.push({x:i,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,i,o);return}if(this.draggingJoystickId){const c=this.artboard.objects.find(d=>d.id===this.draggingJoystickId);c&&this.updateJoystickValueFromPointer(c,i,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,i,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===H.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||{},v=c.geometry||{},b=v.width??c.width??200,y=v.height??c.height??40,m=u.optionsList||[],S=u.itemHeight||32,C=u.listPadding??4,w=m.length*S+C*2,M=this.getWorldTransform(c.id),I=b*Math.abs(M.scaleX),k=y*Math.abs(M.scaleY),T=M.y+k/2+4,O=Math.abs(i-M.x)<=I/2,P=o>=T&&o<=T+w*Math.abs(M.scaleY);if(O&&P){const _=Math.abs(M.scaleY),E=o-(T+C*_),A=Math.floor(E/(S*_));if(A>=0&&A<m.length){const W=m[A];u.selectedOption=W,u.isOpen=!1,this.activeDropdownId=null,c.inputId&&this.setInternalInput(c.inputId,W),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"dropdown",property:"selectedOption",value:W})}return}else a!==this.activeDropdownId&&(u.isOpen=!1,this.activeDropdownId=null)}}if(e){let c=e,d=e;for(;d&&d.parentId;){const v=this.artboard.objects.find(b=>b.id===d.parentId);if(v&&v.type==="Component"){c=v;break}d=v}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 v=this.objectStates.get(c.id),b=(v==null?void 0:v.options)||c.options||{};b.checked=!b.checked,c.inputId&&this.setInternalInput(c.inputId,b.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"toggle_button",property:"checked",value:b.checked}),this.fireEventForObject(c.id,"Toggle"),this.fireEventForObject(c.id,b.checked?"Toggle True":"Toggle False")}if(c.type==="Component"&&c.variant==="toggle"&&t==="down"){const v=this.objectStates.get(c.id),b=(v==null?void 0:v.options)||c.options||{};b.checked=!b.checked,c.inputId&&this.setInternalInput(c.inputId,b.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"toggle",property:"checked",value:b.checked}),this.onToggle&&this.onToggle(c.name,b.checked),this.fireEventForObject(c.id,"Toggle"),this.fireEventForObject(c.id,b.checked?"Toggle True":"Toggle False")}if(c.type==="Component"&&c.variant==="dropdown"&&t==="down"){const v=this.objectStates.get(c.id),b=(v==null?void 0:v.options)||c.options||{},y=!b.isOpen;if(y&&this.activeDropdownId&&this.activeDropdownId!==c.id){const m=this.artboard.objects.find(S=>S.id===this.activeDropdownId);m&&m.options&&(m.options.isOpen=!1)}b.isOpen=y,this.activeDropdownId=y?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 v=this.getListViewItemIndexAtPointer(c,i,o);if(v!==null){const b=c.options||{};b.activeItemIndex=v;const y=this.objectStates.get(c.id);y&&y.options&&(y.options.activeItemIndex=v);const m=(b.items||[])[v],S=typeof m=="string"?m:m.label||m.value||v;y&&y.options&&(y.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:v}),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,i,o)),c.type==="Joystick"||c.type==="Component"&&c.variant==="joystick"){if(t==="down")this.draggingJoystickId=c.id,this.updateJoystickValueFromPointer(c,i,o);else if(t==="up"||t==="blur"){const v=this.objectStates.get(c.id);v&&c.isSpringReturn!==!1&&(v.handleX=0,v.handleY=0),c.isSpringReturn!==!1&&(c.handleX=0,c.handleY=0)}}if(c.type==="Component"&&c.variant==="checkbox"&&t==="down"){const v=this.objectStates.get(c.id),b=(v==null?void 0:v.options)||c.options||{};b.checked=!b.checked,c.inputId&&this.setInternalInput(c.inputId,b.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"checkbox",property:"checked",value:b.checked}),this.fireEventForObject(c.id,"Click"),this.fireEventForObject(c.id,b.checked?"Checked":"Unchecked")}if(c.type==="Component"&&c.variant==="radiogroup"&&t==="down"){const v=this.objectStates.get(c.id),b=(v==null?void 0:v.options)||c.options||{},y=b.optionsList||[],m=this.getRadioGroupItemIndexAtPointer(c,i,o);if(m!==null&&m>=0&&m<y.length){const S=y[m];b.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 v=c.geometry,b=(v==null?void 0:v.datasets)||[],y=this.objectStates.get(c.id),m=(y==null?void 0:y.width)||(v==null?void 0:v.width)||200,S=(y==null?void 0:y.height)||(v==null?void 0:v.height)||150,C=this.getWorldTransform(c.id),w=30,M=20,I=m-w,k=S-M;let T=1;b.forEach(_=>{const E=Math.max(..._.data||[0]);E>T&&(T=E)});let O=1/0,P=null;b.forEach((_,E)=>{const A=_.data||[],W=I/Math.max(A.length-1,1);A.forEach((z,Y)=>{const G=C.x-m/2+w+Y*W,N=C.y+S/2-M-z/T*k,J=Math.sqrt((i-G)**2+(o-N)**2);J<O&&(O=J,P={dIdx:E,pIdx:Y,val:z,label:_.label||`Dataset ${E+1}`})})}),P&&O<20&&this.onGraphPointClick&&this.onGraphPointClick({objectId:c.id,componentName:c.name,datasetIndex:P.dIdx,pointIndex:P.pIdx,value:P.val,label:P.label}),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"linegraph",property:"click",value:(P==null?void 0:P.val)??null})}if(t==="click"){const v=(f=this.artboard)==null?void 0:f.objects.find(m=>m.id===e.id),b=this.focusedId,y=(v==null?void 0:v.type)==="InputBox"||(v==null?void 0:v.type)==="Component"&&v.variant==="inputbox";if(v&&y){if(this.focusedId=e.id,this.log(`[Engine] Focus set to: ${e.id}`),b!==this.focusedId){if(b){const m=(h=this.artboard)==null?void 0:h.objects.find(S=>S.id===b);m&&this.onInputBlur&&this.onInputBlur(m.name)}this.onInputFocus&&this.onInputFocus(v.name)}}else if(this.focusedId=null,b){const m=(l=this.artboard)==null?void 0:l.objects.find(S=>S.id===b);m&&this.onInputBlur&&this.onInputBlur(m.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 i=this.artboard.objects.find(a=>a.id===this.focusedId),o=(i==null?void 0:i.type)==="InputBox"||(i==null?void 0:i.type)==="Component"&&i.variant==="inputbox";if(!i||!o)return;const e=i.options||{};let s=e.text||"";if(t.key==="Backspace")s=s.slice(0,-1);else if(t.key==="Enter")if(e.multiline)s+=`
7
+ `;else{this.focusedId=null;return}else if(t.key.length===1)s+=t.key;else return;e.text=s;const n=i.geometry;n.textInputId&&this.updateInput(n.textInputId,s),this.onComponentChange&&this.onComponentChange({objectId:i.id,componentName:i.name,variant:"inputbox",property:"text",value:s}),this.onInputChange&&this.onInputChange(i.name,s),this.onInputUpdate&&this.onInputUpdate(this.focusedId,s)}handleKeyUp(t){this.artboard&&(this.activeKeys.delete(t.key.toLowerCase()),this.activeKeys.delete(t.code))}fireEventForObject(t,i){var h,l,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([i,i.toLowerCase()]),s=i.toLowerCase();s==="onclick"||s==="click"||s==="onpointerdown"||s==="pointerdown"?this.fireAnalyticsEvent(t,"click"):(s==="onpointerenter"||s==="hover"||s==="move")&&this.fireAnalyticsEvent(t,"hover"),s==="onclick"||s==="click"?(e.add("click"),e.add("onclick")):s==="onpointerdown"||s==="pointerdown"?(e.add("pointerdown"),e.add("onpointerdown")):s==="onpointerup"||s==="pointerup"?(e.add("pointerup"),e.add("onpointerup")):s==="onpointerenter"||s==="hover"||s==="move"?(e.add("hover"),e.add("onpointerenter")):s==="onpointerleave"||s==="blur"?(e.add("onpointerleave"),e.add("blur")):s==="drag"||s==="ondrag"?(e.add("drag"),e.add("ondrag")):s==="toggle"||s==="ontoggle"?(e.add("toggle"),e.add("ontoggle")):s==="toggle true"||s==="toggle_true"||s==="toggletrue"?(e.add("toggle true"),e.add("toggle_true"),e.add("toggletrue")):(s==="toggle false"||s==="toggle_false"||s==="togglefalse")&&(e.add("toggle false"),e.add("toggle_false"),e.add("togglefalse"));const a=(o.interactions||[]).find(u=>{const v=u.triggers||[u.event||u.trigger||"click"];return((u.triggerLogic||"OR")==="AND"?v.every(m=>e.has(m.toLowerCase())):v.some(m=>e.has(m.toLowerCase())))?u.conditions&&u.conditions.length>0?this.checkConditions(u.conditions):!0:!1});if(a){if(this.log(`[Engine] Interaction matched: ${i} -> 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,v=a.targetProperty;v&&this.updateObjectProperty(u,v,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,v=!a.playMode||a.playMode==="all"?void 0:a.subAnimationIds;u==="__all__"?(p=(l=this.artboard)==null?void 0:l.animations)==null||p.forEach(b=>{this.triggerGlobalAnimation(b.id,v)}):u&&this.triggerGlobalAnimation(u,v)}else if(a.action==="setState"||a.action==="Set State"){const u=a.targetObjectId||o.id,b={...this.objectStates.get(u)||{},...a.value||{}};this.objectStates.set(u,b),this.log(`[Engine] State updated for ${u}:`,b)}else if(a.action==="Stop Animation"||a.action==="Pause Animation"){const u=a.targetAnimationId;u==="__all__"?this.layerStates.forEach((v,b)=>{b.startsWith("global_")&&this.layerStates.delete(b)}):u&&this.layerStates.forEach((v,b)=>{b.startsWith(`global_${u}_`)&&this.layerStates.delete(b)})}else if(a.action==="Switch to State"&&this.activeStateMachine){const u=a.targetState,v=this.activeStateMachine.layers.find(b=>b.states.some(y=>y.id===u||y.name===u));v&&(this.log(`[Engine] Switching Layer ${v.name} to State ${u}`),this.enterStates(v.name,[u]))}this.onTrigger&&this.onTrigger(i,a.action)}const f=(o.triggers||[]).find(u=>{const v=u.eventType.toLowerCase();let b=!1;return(e.has(v)||v==="click"&&e.has("onclick")||v==="hover"&&(e.has("onpointerenter")||e.has("hover"))||v==="pointerdown"&&e.has("onpointerdown")||v==="pointerup"&&e.has("onpointerup"))&&(b=!0),b&&u.conditions&&u.conditions.length>0?this.checkConditions(u.conditions):b});if(f&&f.entryAnimationId){this.log(`[Engine] Trigger matched: ${i} (as ${f.eventType}) -> Animation ${f.entryAnimationId}`);const u=(d=(c=this.artboard)==null?void 0:c.animations)==null?void 0:d.find(v=>v.id===f.entryAnimationId);u&&(this.activeTriggers.set(o.id,{triggerId:f.id,animation:u,time:0,phase:"entry",elapsedHold:0,filterObjectId:f.targetObjectId}),this.onTrigger&&this.onTrigger(f.name,u.name))}}fireAnalyticsEvent(t,i){var r,f;const o=(r=this.artboard)==null?void 0:r.objects.find(h=>h.id===t);if(!o)return;const e=(f=o.style)==null?void 0:f.analytics;if(!e||!e.isEnabled||e.triggerType!==i)return;const s=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 l=this.inputs.get(h.value);n[h.key]=l!==void 0?l:""}}),this.log(`[ExodeUI Analytics] Dispatching event "${s}" via ${i} 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",s,n),this.log(`[ExodeUI Analytics] GA4: Event "${s}" sent successfully.`)):this.warn(`[ExodeUI Analytics] GA4: window.gtag is not a function. Event "${s}" skipped.`)}if(a.meta){const h=window;typeof h.fbq=="function"?(h.fbq("track",s,n),this.log(`[ExodeUI Analytics] Meta Pixel: Event "${s}" sent successfully.`)):this.warn(`[ExodeUI Analytics] Meta Pixel: window.fbq is not a function. Event "${s}" skipped.`)}if(a.mixpanel){const h=window;h.mixpanel&&typeof h.mixpanel.track=="function"?(h.mixpanel.track(s,n),this.log(`[ExodeUI Analytics] Mixpanel: Event "${s}" sent successfully.`)):this.warn(`[ExodeUI Analytics] Mixpanel: window.mixpanel.track is not a function. Event "${s}" skipped.`)}}initGlobalAnimationTriggers(){if(!this.artboard)return;const t=this.artboard.animationFlow||[];let i=!1;t.forEach(o=>{if((o.trigger==="on_load"||o.trigger==="after_delay")&&o.targetAnimationId){i=!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)}}),!i&&this.artboard.startupAnimationId&&this.triggerGlobalAnimation(this.artboard.startupAnimationId,this.artboard.startupSubAnimationIds)}triggerGlobalAnimation(t,i,o=!1,e){if(!this.artboard)return;const s=this.artboard.animations.find(a=>a.id===t);if(!s)return;const n=`global_${t}_${Math.random().toString(36).substr(2,5)}`;this.layerStates.set(n,{currentStateIds:[t],animations:[{animation:s,state:{loop:o},filterObjectIds:i}],time:0,duration:s.duration,ruleId:e}),this.debugLog(`[Engine] Triggered global animation: ${s.name} (Loop: ${o}, Sub-Anims: ${(i==null?void 0:i.length)||"All"})`)}handleAnimationFinished(t,i){if(!this.artboard)return;(this.artboard.animationFlow||[]).forEach(e=>{if(e.trigger==="after_anim"&&e.targetAnimationId&&(e.afterAnim===t||i&&e.afterAnim===i)){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 i=this.objectStates.get(t);if(!i)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:i.x,y:i.y,scaleX:i.scale_x??1,scaleY:i.scale_y??1,rotation:i.rotation??0};const e=this.getWorldTransform(o.parentId),s=e.rotation*(Math.PI/180),n=Math.cos(s),a=Math.sin(s),r=i.x*e.scaleX,f=i.y*e.scaleY,h=e.x+(r*n-f*a),l=e.y+(r*a+f*n);return{x:h,y:l,scaleX:(i.scale_x??1)*e.scaleX,scaleY:(i.scale_y??1)*e.scaleY,rotation:e.rotation+(i.rotation??0)}}hitTest(t,i,o){var m,S;if(!this.objectStates.get(t.id))return!1;const s=((m=t.geometry)==null?void 0:m.width)??t.width??100,n=((S=t.geometry)==null?void 0:S.height)??t.height??100,a=this.getWorldTransform(t.id),r=i-a.x,f=o-a.y,h=-a.rotation*(Math.PI/180),l=Math.cos(h),p=Math.sin(h),c=r*l-f*p,d=r*p+f*l,u=a.scaleX,v=a.scaleY,b=s*Math.abs(u),y=n*Math.abs(v);return Math.abs(c)<=b/2&&Math.abs(d)<=y/2}updateSliderValueFromPointer(t,i,o){var M;const e=this.objectStates.get(t.id);if(!e)return;const s=t.options||{},n=((M=t.geometry)==null?void 0:M.width)??t.width??200,a=this.getWorldTransform(t.id),r=i-a.x,f=o-a.y,h=-a.rotation*(Math.PI/180),l=Math.cos(h),p=Math.sin(h),c=r*l-f*p,d=s.thumbWidth??16,u=n-d;let b=(c+u/2)/u;b=Math.max(0,Math.min(1,b));const y=s.min??0,m=s.max??100,S=s.step||1;let C=y+b*(m-y);S>0&&(C=Math.round(C/S)*S),C=Math.max(y,Math.min(m,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,i,o){var M,I;const e=this.objectStates.get(t.id);if(!e)return;const s=(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=i-a.x,f=o-a.y,h=-a.rotation*(Math.PI/180),l=Math.cos(h),p=Math.sin(h);let c=(r*l-f*p)/Math.max(.001,Math.abs(a.scaleX||1)),d=(r*p+f*l)/Math.max(.001,Math.abs(a.scaleY||1));t.handleOrigin==="top-left"?(c-=s/2,d-=n/2):t.handleOrigin==="bottom-right"&&(c+=s/2,d+=n/2);const u=Math.min(s,n)*.45,v=Math.min(s,n)*.15,b=u-v;let y=c/b,m=d/b;const S=Math.sqrt(y*y+m*m);t.boundsShape==="square"?(y=Math.max(-1,Math.min(1,y)),m=Math.max(-1,Math.min(1,m))):S>1&&(y/=S,m/=S),t.deadzone!==void 0&&S<t.deadzone?(y=0,m=0):(t.stepX!==void 0&&t.stepX>0&&(y=Math.round(y/t.stepX)*t.stepX),t.stepY!==void 0&&t.stepY>0&&(m=Math.round(m/t.stepY)*t.stepY)),t.joystickType==="1D_X"?m=0:t.joystickType==="1D_Y"&&(y=0);const C=e.handleX,w=e.handleY;(C!==y||w!==m)&&(e.handleX=y,e.handleY=m,t.handleX=y,t.handleY=m)}processJoysticks(t){this.artboard&&(this.artboard.objects.forEach(i=>{var a,r;if(i.type!=="Joystick"&&!(i.type==="Component"&&i.variant==="joystick"))return;const o=i,e=this.objectStates.get(o.id);if(!e)return;let s=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 f=o.inputBinding.keyboardConfig;let h=s,l=n;const c=(f.speed||5)*t;let d=!1;this.activeKeys.has(f.upKey.toLowerCase())&&(l-=c,d=!0),this.activeKeys.has(f.downKey.toLowerCase())&&(l+=c,d=!0),this.activeKeys.has(f.leftKey.toLowerCase())&&(h-=c,d=!0),this.activeKeys.has(f.rightKey.toLowerCase())&&(h+=c,d=!0),o.joystickType==="1D_X"&&(l=0),o.joystickType==="1D_Y"&&(h=0);const u=Math.sqrt(h*h+l*l);u>1&&(h/=u,l/=u),!d&&o.isSpringReturn!==!1&&(h+=(0-h)*(10*t),l+=(0-l)*(10*t),Math.abs(h)<.01&&(h=0),Math.abs(l)<.01&&(l=0)),s=h,n=l}else if(((r=o.inputBinding)==null?void 0:r.type)==="mouse"&&o.inputBinding.mouseConfig){const f=o.inputBinding.mouseConfig;let h=s,l=n;const p=f.sensitivity||.01,c=Math.abs(this._mouseDelta.dx)>0||Math.abs(this._mouseDelta.dy)>0;f.axisX&&(h+=this._mouseDelta.dx*p),f.axisY&&(l+=this._mouseDelta.dy*p),o.joystickType==="1D_X"&&(l=0),o.joystickType==="1D_Y"&&(h=0);const d=Math.sqrt(h*h+l*l);d>1&&(h/=d,l/=d),!c&&o.isSpringReturn!==!1&&(h+=(0-h)*(10*t),l+=(0-l)*(10*t),Math.abs(h)<.01&&(h=0),Math.abs(l)<.01&&(l=0)),s=h,n=l}if(e.handleX=s,e.handleY=n,o.handleX=s,o.handleY=n,o.bindings&&o.bindings.length>0){const f=Math.sqrt(s*s+n*n);let h=Math.atan2(n,s)*(180/Math.PI);h<0&&(h+=360),o.bindings.forEach(l=>{var d,u,v,b,y,m,S,C;let p=0;l.sourceAxis==="x"?p=o.invertX?-s:s:l.sourceAxis==="y"?p=o.invertY?-n:n:l.sourceAxis==="distance"?p=f:l.sourceAxis==="angle"&&(p=h);const c=(d=this.artboard)==null?void 0:d.objects.find(w=>w.id===l.targetObjectId);if(c){if(l.actionType==="bind"&&l.targetProperty&&l.isContinuous!==!1){const w=l.sourceMin??-1,M=l.sourceMax??1,I=l.targetMin??0,k=l.targetMax??100;let T=!!l.isContinuous,O=0,P=0;if(T){if((l.sourceAxis==="x"||l.sourceAxis==="y")&&I>=0){const E=Math.max(Math.abs(w),Math.abs(M))||1;P=p/E*k}else{let E=(p-w)/(M-w);E=Math.max(0,Math.min(1,E)),P=I+E*(k-I)}Math.abs(p)<.05&&(P=0)}else{const E=(p-w)/(M-w),A=Math.max(0,Math.min(1,E));O=I+A*(k-I),l.step&&l.step>0&&(O=Math.round(O/l.step)*l.step)}const _=this.objectStates.get(c.id);if(_){const E=l.isRelative!==!1,A=E?((u=c.transform)==null?void 0:u.x)??0:0,W=E?((v=c.transform)==null?void 0:v.y)??0:0,z=E?((b=c.transform)==null?void 0:b.rotation)??0:0,Y=E?((y=c.transform)==null?void 0:y.scale_x)??1:0,G=E?((m=c.transform)==null?void 0:m.scale_y)??1:0,N=E?((S=c.style)==null?void 0:S.opacity)??100:0,J=t*60,x=(F,j)=>{let X=O;if(T){const tt=`_internal_${F}_${l.id}`;let L=_[tt];L===void 0&&(L=_[F]??j),X=L+P*J,_[tt]=X,l.step&&l.step>0&&(X=Math.round(X/l.step)*l.step)}else X=j+O;_[F]=X};l.targetProperty==="x"||l.targetProperty==="transform.x"?x("x",A):l.targetProperty==="y"||l.targetProperty==="transform.y"?x("y",W):l.targetProperty==="rotation"||l.targetProperty==="r"||l.targetProperty==="transform.rotation"?x("rotation",z):l.targetProperty==="scaleX"||l.targetProperty==="transform.scale_x"?x("scale_x",Y):l.targetProperty==="scaleY"||l.targetProperty==="transform.scale_y"?x("scale_y",G):(l.targetProperty==="opacity"||l.targetProperty==="transform.opacity")&&x("opacity",N)}(C=c.physics)!=null&&C.enabled&&this.physicsEngine&&(l.targetProperty==="x"||l.targetProperty==="transform.x"||l.targetProperty==="y"||l.targetProperty==="transform.y")&&(l.targetProperty==="x"||l.targetProperty==="transform.x"?this.physicsEngine.applyForce(c.id,(O-((_==null?void 0:_.x)||0))*10,0):(l.targetProperty==="y"||l.targetProperty==="transform.y")&&this.physicsEngine.applyForce(c.id,0,(O-((_==null?void 0:_.y)||0))*10))}else if(l.actionType==="playAnimation"||l.actionType==="stopAnimation"||l.actionType==="pauseAnimation"){let w=!1;const M=l.threshold??0;l.condition==="always"?w=!0:l.condition===">"?w=p>M:l.condition==="<"?w=p<M:l.condition==="=="&&(w=Math.abs(p-M)<.01);const I=e[`_prev_src_${l.id}`]??p;let k=!1;l.condition==="always"?k=!0:l.condition===">"?k=I>M:l.condition==="<"?k=I<M:l.condition==="=="&&(k=Math.abs(I-M)<.01),e[`_prev_src_${l.id}`]=p,w&&!k&&l.targetAnimationId&&(l.actionType==="playAnimation"||l.actionType)}}})}}),this._mouseDelta.dx=0,this._mouseDelta.dy=0)}applyBlendState(t,i){var f,h,l,p,c,d,u,v;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 s=[];let n=0;if(t.blendType==="1D"){const b=[...t.blendAnimations].sort((y,m)=>y.position[0]-m.position[0]);if(b.length===1){const y=(h=(f=this.artboard)==null?void 0:f.animations)==null?void 0:h.find(m=>m.id===b[0].animationId);y&&(s.push({anim:y,weight:1}),n=1)}else{let y=0;for(;y<b.length-1&&b[y+1].position[0]<o;)y++;if(y===b.length-1&&o>b[y].position[0]){const m=(p=(l=this.artboard)==null?void 0:l.animations)==null?void 0:p.find(S=>S.id===b[y].animationId);m&&(s.push({anim:m,weight:1}),n=1)}else{const m=b[y].position[0],S=b[y+1].position[0],C=(d=(c=this.artboard)==null?void 0:c.animations)==null?void 0:d.find(T=>T.id===b[y].animationId),w=(v=(u=this.artboard)==null?void 0:u.animations)==null?void 0:v.find(T=>T.id===b[y+1].animationId),M=Math.max(.001,S-m);let I=(o-m)/M;I=Math.max(0,Math.min(1,I));const k=1-I;C&&(s.push({anim:C,weight:k}),n+=k),w&&(s.push({anim:w,weight:I}),n+=I)}}}else t.blendAnimations.forEach(b=>{var w,M;const y=(M=(w=this.artboard)==null?void 0:w.animations)==null?void 0:M.find(I=>I.id===b.animationId);if(!y)return;const m=b.position[0]-o,S=b.position[1]-e,C=m*m+S*S;if(C<1e-4)s.push({anim:y,weight:1e4}),n+=1e4;else{const I=1/C;s.push({anim:y,weight:I}),n+=I}});if(n===0)return;s.forEach(b=>b.weight/=n);const a=new Map,r=b=>{let y=b.startsWith("#")?b.substring(1):b;return y.length===3&&(y=[y[0],y[0],y[1],y[1],y[2],y[2]].join("")),y="0x"+y,{r:y>>16&255,g:y>>8&255,b:y&255,a:1}};s.forEach(({anim:b,weight:y})=>{b.tracks&&b.tracks.forEach(m=>{var O,P;const S=m.object_id||m.objectId,C=m.property,w=(O=this.artboard)==null?void 0:O.objects.find(_=>_.id===S);if(((P=w==null?void 0:w.physics)==null?void 0:P.enabled)&&w.physics.bodyType!=="Static"&&(C==="x"||C==="y"||C==="rotation"))return;const I=this.interpolate(m.keyframes,i);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},y<.5)return;k.set(C,T)}if(T.type==="number"&&typeof I=="number")T.value+=I*y;else if(T.type==="color"&&typeof I=="string"&&T.colorAcc){const _=r(I);_&&(T.colorAcc.r+=_.r*y,T.colorAcc.g+=_.g*y,T.colorAcc.b+=_.b*y,T.colorAcc.a+=_.a*y)}else y>.5&&(T.value=I)})}),a.forEach((b,y)=>{var C;const m=this.objectStates.get(y),S=(C=this.artboard)==null?void 0:C.objects.find(w=>w.id===y);!m||!S||b.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(".")){const k=(M||"").split(".");let T=m;for(let O=0;O<k.length-1;O++){if(typeof T[k[O]]!="object"||T[k[O]]===null){let P=S;for(let _=0;_<=O;_++)P=P?P[k[_]]:null;if(k[O]==="corner_radius"||k[O]==="cornerRadius"){const _=typeof T[k[O]]=="number"?T[k[O]]:typeof P=="number"?P:0;T[k[O]]={tl:_,tr:_,bl:_,br:_}}else T[k[O]]=P?JSON.parse(JSON.stringify(P)):{}}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"?(m.style||(m.style={}),m.style.fill=I):M==="stroke"?(m.style||(m.style={}),m.style.stroke=I):m[M]=I})})}applyAnimation(t,i,o){!t||!t.tracks||t.tracks.forEach(e=>{var l,p,c;const s=e.object_id||e.objectId;if(o){if(Array.isArray(o)){if(!o.includes(s))return}else if(s!==o)return}const n=(l=this.artboard)==null?void 0:l.objects.find(d=>d.id===s),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 f=this.objectStates.get(s);if(!f){this.frameCount%600===0&&this.debugLog(`Skipping track: Object ${s} not found in state`);return}const h=this.interpolate(e.keyframes,i);if(h!==void 0){if(this.frameCount%240===0){const d=(n==null?void 0:n.name)||s,u=typeof h=="object"?JSON.stringify(h).slice(0,50):h;this.debugLog(`[Anim] Applying ${r} = ${u} to ${d}`)}if(r.includes(".")){const d=(r||"").split(".");let u=f;for(let v=0;v<d.length-1;v++){if(typeof u[d[v]]!="object"||u[d[v]]===null){let b=n;for(let y=0;y<=v;y++)b=b?b[d[y]]:null;if(d[v]==="corner_radius"||d[v]==="cornerRadius"){const y=typeof u[d[v]]=="number"?u[d[v]]:typeof b=="number"?b:0;u[d[v]]={tl:y,tr:y,bl:y,br:y}}else u[d[v]]=b?JSON.parse(JSON.stringify(b)):{}}u=u[d[v]]}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"?(f.style||(f.style={}),f.style.fill=h):r==="stroke"?(f.style||(f.style={}),f.style.stroke=h):f[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(s);d&&this.physicsEngine.setPosition(s,h,d.y)}else if(r==="y"){const d=this.physicsEngine.getPosition(s);d&&this.physicsEngine.setPosition(s,d.x,h)}else r==="rotation"&&this.physicsEngine.setRotation(s,h*(Math.PI/180))}})}interpolate(t,i){if(t.length===0)return;let o=t[0],e=t[t.length-1];if(i<=o.time)return o.value;if(i>=e.time)return e.value;for(let a=0;a<t.length-1;a++)if(i>=t[a].time&&i<t[a+1].time){o=t[a],e=t[a+1];break}const s=e.time-o.time;let n=(i-o.time)/s;if(o.easing&&(n=si(o.easing)(n)),typeof o.value=="string"){if(o.value.startsWith("#"))return this.interpolateColor(o.value,e.value,n);const a=parseFloat(o.value),r=parseFloat(e.value);return!isNaN(a)&&!isNaN(r)?Math.round(a+(r-a)*n).toString():o.value}if(Array.isArray(o.value)&&Array.isArray(e.value))return o.value.length===e.value.length?o.value.map((a,r)=>{const f=e.value[r];return typeof a=="number"&&typeof f=="number"?a+(f-a)*n:n<.5?a:f}):n<.5?o.value:e.value;if(typeof o.value=="object"&&typeof e.value=="object"&&o.value!==null&&e.value!==null){if(o.value.width!==void 0&&o.value.color!==void 0)return this.interpolateStroke(o.value,e.value,n);if(o.value.type&&e.value.type)return this.interpolateFill(o.value,e.value,n);const a={};return new Set([...Object.keys(o.value),...Object.keys(e.value)]).forEach(f=>{const h=o.value[f],l=e.value[f];typeof h=="number"&&typeof l=="number"?a[f]=h+(l-h)*n:h===void 0?a[f]=l:l===void 0?a[f]=h:a[f]=n<.5?h:l}),a}return typeof o.value=="number"&&typeof e.value=="number"?o.value+(e.value-o.value)*n:n<.5?o.value:e.value}interpolateColor(t,i,o){var d,u;const e=((u=(d=this.artboard)==null?void 0:d.tokens)==null?void 0:u.colors)||{},s=e[t]||t,n=e[i]||i,a=v=>{if(!v)return{r:0,g:0,b:0};const b=v.startsWith("#")?v.replace("#",""):"000000";return b.length===3?{r:parseInt(b[0]+b[0],16),g:parseInt(b[1]+b[1],16),b:parseInt(b[2]+b[2],16)}:{r:parseInt(b.substring(0,2),16),g:parseInt(b.substring(2,4),16),b:parseInt(b.substring(4,6),16)}},r=a(s),f=a(n),h=Math.round(r.r+(f.r-r.r)*o),l=Math.round(r.g+(f.g-r.g)*o),p=Math.round(r.b+(f.b-r.b)*o),c=v=>{const b=Math.max(0,Math.min(255,v)).toString(16);return b.length===1?"0"+b:b};return`#${c(h)}${c(l)}${c(p)}`}interpolateStops(t,i,o){return!t||!i||t.length!==i.length?o<.5?t:i:t.map((e,s)=>{const n=i[s];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,i,o){if(!t||!i||t.type!==i.type)return o<.5?t:i;const e={...t,opacity:(t.opacity??1)+((i.opacity??1)-(t.opacity??1))*o};return t.type==="Solid"?e.color=this.interpolateColor(t.color,i.color,o):(t.type==="LinearGradient"||t.type==="RadialGradient")&&(t.start&&i.start&&(e.start=[t.start[0]+(i.start[0]-t.start[0])*o,t.start[1]+(i.start[1]-t.start[1])*o]),t.end&&i.end&&(e.end=[t.end[0]+(i.end[0]-t.end[0])*o,t.end[1]+(i.end[1]-t.end[1])*o]),t.center&&i.center&&(e.center=[t.center[0]+(i.center[0]-t.center[0])*o,t.center[1]+(i.center[1]-t.center[1])*o]),t.radius!==void 0&&i.radius!==void 0&&(e.radius=t.radius+(i.radius-t.radius)*o),e.stops=this.interpolateStops(t.stops,i.stops,o)),e}interpolateStroke(t,i,o){if(!t||!i)return o<.5?t:i;const e={...t};return e.width=(t.width??0)+((i.width??0)-(t.width??0))*o,e.opacity=(t.opacity??1)+((i.opacity??1)-(t.opacity??1))*o,t.fill&&i.fill?e.fill=this.interpolateFill(t.fill,i.fill,o):t.color&&i.color&&t.color.startsWith("#")&&i.color.startsWith("#")&&(e.color=this.interpolateColor(t.color,i.color,o)),e.trimStart=(t.trimStart??0)+((i.trimStart??0)-(t.trimStart??0))*o,e.trimEnd=(t.trimEnd??1)+((i.trimEnd??1)-(t.trimEnd??1))*o,e.trimOffset=(t.trimOffset??0)+((i.trimOffset??0)-(t.trimOffset??0))*o,e.dashOffset=(t.dashOffset??0)+((i.dashOffset??0)-(t.dashOffset??0))*o,e}render(t,i,o){var l;this.debug_objectsTotal=((l=this.artboard)==null?void 0:l.objects.length)||0,this.debug_objectsRendered=0;const e=performance.now();if(this.canvasWidth=i,this.canvasHeight=o,!this.artboard)return;t.clearRect(0,0,i,o);const s=this.artboard.width,n=this.artboard.height,a=this.calculateTransform(i,o,s,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,s,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=s/n;let v,b,y,m;u>d?(v=s,b=s/d):(b=n,v=n*d),y=(s-v)/2,m=(n-b)/2,t.drawImage(c,y,m,v,b),t.restore()}}(this.artboard.clipContent===!0||this.artboard.clip_content===!0)&&(t.beginPath(),t.rect(0,0,s,n),t.clip());const f=new Map;this.artboard.objects.forEach(p=>f.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,f)}),this._emitterPools.forEach((p,c)=>{if(!(p.length===0||!f.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,i,o,e,s,n=0){const a=t.getTransform(),r=i*a.a+o*a.c+a.e,f=i*a.b+o*a.d+a.f,h=Math.sqrt(a.a*a.a+a.b*a.b),l=Math.sqrt(a.c*a.c+a.d*a.d),p=(e/2+n)*h,c=(s/2+n)*l;return r+p>=0&&r-p<=this.canvasWidth&&f+c>=0&&f-c<=this.canvasHeight}calculateTransform(t,i,o,e,s,n){let a=1,r=1,f=1;const h=o/e,l=t/i;switch(s){case"Contain":l>h?f=i/e:f=t/o,a=r=f;break;case"Cover":l>h?f=t/o:f=i/e,a=r=f;break;case"Fill":a=t/o,r=i/e;break;case"FitWidth":f=t/o,a=r=f;break;case"FitHeight":f=i/e,a=r=f;break;case"None":a=r=1;break;case"ScaleDown":f=Math.min(t/o,i/e),f>1&&(f=1),a=r=f;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=i-c:u=(i-c)/2,{scaleX:a,scaleY:r,tx:d,ty:u}}mapFontWeight(t){const i=t.toLowerCase();return i==="thin"||i==="100"?"100":i==="extralight"||i==="200"?"200":i==="light"||i==="300"?"300":i==="regular"||i==="normal"||i==="400"?"400":i==="medium"||i==="500"?"500":i==="semibold"||i==="600"?"600":i==="bold"||i==="700"?"700":i==="extrabold"||i==="800"?"800":i==="black"||i==="900"?"900":t}drawTextDecoration(t,i,o,e,s,n){t.beginPath();const a=Math.max(1,n/14);let r=e;i==="underline"?r=e+n*.12:i==="line-through"&&(r=e-n*.3),t.lineWidth=a,t.strokeStyle=t.fillStyle,t.moveTo(o-s/2,r),t.lineTo(o+s/2,r),t.stroke()}renderObject(t,i,o){var u,v,b,y,m,S,C,w,M,I,k,T,O,P,_,E,A,W,z,Y,G,N,J,x,F,j;const e=this.objectStates.get(i.id);if(!e){this.warn("No state for object:",i.id);return}this.frameCount%60,t.roundRect||(t.roundRect=(X,tt,L,R,D)=>(this.drawRoundRect(t,X,tt,L,R,D),t));const s=e.geometry?this.deepMerge(i.geometry,e.geometry):i.geometry;let n=e.style?this.deepMerge(i.style,e.style):i.style,a=(s==null?void 0:s.width)||((u=i.geometry)==null?void 0:u.width)||i.width||0,r=(s==null?void 0:s.height)||((v=i.geometry)==null?void 0:v.height)||i.height||0;if((a===0||r===0)&&(s!=null&&s.points)&&Array.isArray(s.points)&&s.points.length>0){let X=1/0,tt=-1/0,L=1/0,R=-1/0;s.points.forEach(D=>{X=Math.min(X,D.x),tt=Math.max(tt,D.x),L=Math.min(L,D.y),R=Math.max(R,D.y)}),a===0&&(a=tt-X),r===0&&(r=R-L)}const f=X=>{if(X)return X.corner_radius??X.cornerRadius},h=f(e)??f(n)??f(s)??f(i.style)??f(i.geometry)??0;let l={...s,width:a,height:r};if(delete l.cornerRadius,l.corner_radius=h,l.type==="Path"&&i.weights&&i.bindMatrices&&l.points){const X=this.getGlobalTransform(i.id);if(X){const tt=ii(l.points,i.weights,i.bindMatrices,X,L=>this.getGlobalTransform(L));l={...l,points:tt}}}if(e.visible===!1)return;const p=i.repeaterConfig,c=p&&p.isEnabled&&p.count>1,d=c?p.count:1;for(let X=0;X<d;X++){let tt=e.x!==void 0?e.x:((b=e.transform)==null?void 0:b.x)??0,L=e.y!==void 0?e.y:((y=e.transform)==null?void 0:y.y)??0,R=e.rotation!==void 0?e.rotation:((m=e.transform)==null?void 0:m.rotation)??0,D=e.scale_x!==void 0?e.scale_x:((S=e.transform)==null?void 0:S.scale_x)??1,q=e.scale_y!==void 0?e.scale_y:((C=e.transform)==null?void 0:C.scale_y)??1;if(c&&X>0){if(p.type==="Linear"){const ft=p.offsetX||0,ut=p.offsetY||0,at=p.rotation||0,B=p.scale!==void 0?p.scale:1;tt+=X*ft,L+=X*ut,R+=X*at,D*=Math.pow(B,X),q*=Math.pow(B,X)}else if(p.type==="Grid"){const ft=p.cols||Math.ceil(Math.sqrt(p.count)),ut=p.gapX||0,at=p.gapY||0,B=Math.floor(X/ft),et=X%ft,Q=a+ut,Pt=r+at;tt+=et*Q,L+=B*Pt}else if(p.type==="Radial"){const ft=p.radius||100,ut=p.startAngle||0,B=(p.endAngle||360)-ut,et=p.count>1?B/(B===360?p.count:p.count-1):0,Q=ut+X*et,Pt=Q*Math.PI/180;tt=e.x+ft*Math.cos(Pt),L=e.y+ft*Math.sin(Pt),R+=Q}}const ot=i.type==="Group"||i.type==="Frame"||i.type==="Component",mt=a>0&&r>0;if(!ot&&mt){const ft=(((w=n.shadow)==null?void 0:w.isEnabled)!==!1?(((M=n.shadow)==null?void 0:M.blur)||0)+10:0)+(((I=n.blur)==null?void 0:I.isEnabled)!==!1&&((k=n.blur)==null?void 0:k.radius)||0)+20;if(!this.isObjectInView(t,tt,L,a,r,ft))continue}this.debug_objectsRendered++,t.save();const bt=[],gt=n.blur||((T=i.style)==null?void 0:T.blur);gt&&gt.amount>0&&bt.push(`blur(${gt.amount}px)`);const Et=n.effects||((O=i.style)==null?void 0:O.effects)||[];let It=Et.find(ft=>ft.isEnabled!==!1&&(ft.type==="BackgroundBlur"||ft.type==="LayerBlur"));It||(It=n.effect||((P=i.style)==null?void 0:P.effect)||Et.find(ft=>ft.isEnabled!==!1));const vt=It,Dt=(vt==null?void 0:vt.isEnabled)!==!1,ae=vt==null?void 0:vt.type,pe=(vt==null?void 0:vt.radius)??10;Dt&&ae==="LayerBlur"?bt.push(`blur(${pe}px)`):Dt&&ae==="BackgroundBlur"&&(n===i.style&&(n={...n}),n.fill={type:"None"});const st=((_=s==null?void 0:s.type)==null?void 0:_.toLowerCase().includes("image"))||((E=i.type)==null?void 0:E.toLowerCase().includes("image")),yt=n.adjustments&&Object.keys(n.adjustments).length>0?n.adjustments:null,Rt=s!=null&&s.adjustments&&Object.keys(s.adjustments).length>0?s.adjustments:null,_t=st?Rt||yt:yt||Rt,dt=st&&!_t?{exposure:0,contrast:0,saturation:100,temperature:0,tint:0,highlights:0,shadows:0,blur:0,negative:0,hue:0}:_t;if(e&&dt&&(e.geometry=e.geometry||{},e.geometry.adjustments={...dt}),dt){const ft=(dt.exposure||0)/100,ut=dt.contrast||0,at=1+(dt.saturation||0)/100,B=(dt.temperature||0)/200,et=(dt.tint||0)/200,Q=(dt.highlights||0)/500,Pt=(dt.shadows||0)/500;let Ot="",kt="SourceGraphic";if(ft!==0&&(Ot+=`
8
8
  <feComponentTransfer in="${kt}" result="exposure">
9
9
  <feFuncR type="linear" slope="1" intercept="${ft}"/>
10
10
  <feFuncG type="linear" slope="1" intercept="${ft}"/>
11
11
  <feFuncB type="linear" slope="1" intercept="${ft}"/>
12
- </feComponentTransfer>`,kt="exposure"),pt!==0){const Mt=(pt+100)/100,$=.5*(1-Mt);Ot+=`
12
+ </feComponentTransfer>`,kt="exposure"),ut!==0){const Mt=(ut+100)/100,$=.5*(1-Mt);Ot+=`
13
13
  <feComponentTransfer in="${kt}" result="contrast">
14
14
  <feFuncR type="linear" slope="${Mt}" intercept="${$}"/>
15
15
  <feFuncG type="linear" slope="${Mt}" intercept="${$}"/>
@@ -19,16 +19,16 @@
19
19
  values="${Mt} 0 0 0 ${1-Mt}
20
20
  0 ${Mt} 0 0 ${1-Mt}
21
21
  0 0 ${Mt} 0 ${1-Mt}
22
- 0 0 0 1 0"/>`,kt="invert"}if(B!==0||nt!==0||Z!==0||Pt!==0){const Mt=1+Z+Pt,$=Mt*(1+B-nt/2),Yt=Mt*(1+nt),jt=Mt*(1-B-nt/2),ie=dt.shadows*.1/255,te=[$,0,0,0,ie,0,Yt,0,0,ie,0,0,jt,0,ie,0,0,0,1,0].join(" ");Ot+=`<feColorMatrix in="${kt}" type="matrix" values="${te}" result="advanced"/>`,kt="advanced"}if(dt.blur&&(Ot+=`<feGaussianBlur in="${kt}" stdDeviation="${dt.blur}" result="blur"/>`,kt="blur"),Ot){const Mt=`<svg xmlns="http://www.w3.org/2000/svg"><filter id="f" color-interpolation-filters="sRGB">${Ot}</filter></svg>`,$=btoa(Mt);bt.push(`url('data:image/svg+xml;base64,${$}#f')`)}}bt.length>0?t.filter=bt.join(" "):t.filter="none",t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high";const $t=t.globalAlpha,Vt=this.normalizeOpacity(e.opacity!==void 0?e.opacity:100);t.globalAlpha=$t*Vt;const Bt=e.compositeOperation||e.blendMode;if(Bt&&Bt!=="Normal"){const ft=Bt.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(ft)&&(t.globalCompositeOperation=ft)}const Rt=t,Ut=e.masks||(i.maskedBy?[{maskId:i.maskedBy,inverted:i.maskInverted===!0,type:i.maskType||"alpha",opacity:i.maskOpacity!==void 0?i.maskOpacity/100:1,feather:i.maskFeather||0,isVisible:!0}]:[]);let ae=!1;const be=Ut.filter(ft=>ft.isVisible!==!1&&o.has(ft.maskId));if(be.length>0){const ft=be[0],pt=o.get(ft.maskId),at=this.objectStates.get(pt.id);at&&at.visible!==!1&&(ae=!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),i.parentId&&this.applyAbsoluteTransform(this.maskCtx,i.parentId,o),this.maskCtx.save(),this.maskCtx.globalAlpha=1,t=this.maskCtx,t.filter=Rt.filter)}t.translate(Math.round(tt),Math.round(L)),t.rotate(F*Math.PI/180);const ve=e.skew_x||0,Zt=e.skew_y||0;if(ve!==0||Zt!==0){const ft=Math.tan(ve*Math.PI/180),pt=Math.tan(Zt*Math.PI/180);t.transform(1+ft*pt,pt,ft,1,0,0)}const Ce=e.rotate_x!==void 0?e.rotate_x:((A=e.transform)==null?void 0:A.rotate_x)??0,_e=e.rotate_y!==void 0?e.rotate_y:((W=e.transform)==null?void 0:W.rotate_y)??0,we=1+(e.translate_z!==void 0?e.translate_z:((z=e.transform)==null?void 0:z.translate_z)??0)/1e3,Ee=(e.flip_x===!0?-1:1)*Math.cos(_e*Math.PI/180)*we,Ae=(e.flip_y===!0?-1:1)*Math.cos(Ce*Math.PI/180)*we;t.scale(D*Ee,q*Ae),n.shadow&&n.shadow.isEnabled!==!0&&((n.shadow.blur||0)>0||Math.abs(n.shadow.offsetX||0)>0||Math.abs(n.shadow.offsetY||0)>0)&&(n.shadow.isEnabled=!0);const oe=n.shadow;if(oe&&oe.isEnabled!==!1){let ft=oe.color||"#000000";(G=(Y=this.artboard)==null?void 0:Y.tokens)!=null&&G.colors&&this.artboard.tokens.colors[ft]&&(ft=this.artboard.tokens.colors[ft]);const pt=this.normalizeOpacity(oe.opacity??100),at=oe.spread||0,nt=(oe.blur||0)+at*1.5;let Z=ft;if(ft.startsWith("#")){const kt=ft.replace("#",""),At=parseInt(kt.substring(0,2),16),Mt=parseInt(kt.substring(2,4),16),$=parseInt(kt.substring(4,6),16);Z=`rgba(${At}, ${Mt}, ${$}, ${pt})`}else if(ft.startsWith("rgba")){const kt=ft.match(/[\d.]+/g);if(kt&&kt.length>=4){const At=kt[0],Mt=kt[1],$=kt[2],Yt=kt[3];Z=`rgba(${At}, ${Mt}, ${$}, ${parseFloat(Yt)*pt})`}}const Pt=t.getTransform(),Ot=Math.sqrt(Pt.a*Pt.a+Pt.b*Pt.b)||1;t.shadowColor=Z,t.shadowBlur=nt*Ot,t.shadowOffsetX=(oe.offsetX||0)*Ot,t.shadowOffsetY=(oe.offsetY||0)*Ot}else t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;const se=i.liquidFill||((N=i.style)==null?void 0:N.liquidFill);if(se&&se.enabled){t.save();const ft=se.fillLevel??.5;t.beginPath();const pt=r/2-r*ft;t.rect(-a/2,pt,a,r*ft),t.clip(),t.fillStyle=se.color||"#3b82f6",t.globalAlpha=t.globalAlpha*(se.opacity??1)}if((s==null?void 0:s.type)==="Text")this._renderText(t,i,l,n,e,a,r,!1,!1,D,q);else if((s==null?void 0:s.type)==="Image"){const ft=s.originalSrc||s.src;if(ft){let pt=this.imageCache.get(ft);pt||(pt=new Image,pt.onload=()=>{this.log(`[ExodeUI] Image loaded successfully, size: ${pt.naturalWidth}x${pt.naturalHeight}`)},pt.onerror=nt=>{console.error("[ExodeUI] Image load failed:",nt,`Src preview: ${ft.substring(0,100)}...`)},pt.src=ft,this.imageCache.set(ft,pt));const at=n.stroke&&n.stroke.width>0&&n.stroke.isEnabled!==!1,B=(((J=n.stroke)==null?void 0:J.alignment)||"center").toLowerCase();if(at&&(B==="outside"||B==="center")&&this.applyStrokeAlignment(t,n,l,a,r,h,D,q),n.fill&&n.fill.type!=="None"){t.save();const nt=t.globalAlpha,Z=this.createCanvasFill(t,n.fill,a,r);t.fillStyle=Z||n.fill.color||"transparent",t.globalAlpha=nt*this.normalizeOpacity(n.fill.opacity??100),h!==0?(this.drawRoundRect(t,-a/2,-r/2,a,r,h),t.fill()):t.fillRect(-a/2,-r/2,a,r),t.globalAlpha=nt,t.restore()}pt.complete&&pt.naturalWidth>0?(h!==0?(t.save(),this.drawRoundRect(t,-a/2,-r/2,a,r,h),t.clip(),t.drawImage(pt,-a/2,-r/2,a,r),t.restore()):t.drawImage(pt,-a/2,-r/2,a,r),at&&B==="inside"&&this.applyStrokeAlignment(t,n,l,a,r,h,D,q)):at&&B==="inside"&&this.applyStrokeAlignment(t,n,l,a,r,h,D,q)}}else if(s.type==="SVG"){const ft=s.svgContent;if(ft){const pt=n.palette||[],at=n.fill,B=n.stroke,nt=at?this.normalizeOpacity(at.opacity??100):1,Z=(at==null?void 0:at.type)==="Solid"&&(!B||B.isEnabled===!1||B.type==="Solid"&&B.color===at.color),Pt=at&&at.type!=="None"?Z?"monochrome":at.type==="Solid"?(at.color||"")+"|opacity:"+nt:JSON.stringify(at.stops||[])+"|opacity:"+nt:"",Ot=B&&B.isEnabled!==!1&&(B.width||0)>0?Z?["monochrome",B.width||0,B.trimStart??0,B.trimEnd??1,B.trimOffset??0,B.dashOffset??0].join("|"):[B.width||0,B.fill?B.fill.type==="Solid"?B.fill.color||"":JSON.stringify(B.fill.stops||[]):B.color||"",B.opacity??1,B.lineCap||"",B.lineJoin||"",(B.dashArray||[]).join(","),B.trimStart??0,B.trimEnd??1,B.trimOffset??0,B.dashOffset??0].join("|"):"nostroke",kt=[i.id,pt.join("_"),Pt,Ot,e.opacity??100,e.visible!==!1?"v":"h"].join("_");let At=this.imageCache.get(kt);if(!At){At=new Image,At.crossOrigin="anonymous";let $=ft;$.match(/xmlns=["']http:\/\/www\.w3\.org\/2000\/svg["']/i)||($=$.replace(/<svg([^>]*)>/i,(rt,V)=>`<svg xmlns="http://www.w3.org/2000/svg"${V}>`));let Yt=s.width||a||100,jt=s.height||r||100;const ie=$.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(ie&&(Yt=parseFloat(ie[1]),jt=parseFloat(ie[2])),$=$.replace(/<svg([^>]*)>/i,(rt,V)=>{let st=V.replace(/\b(?:width|height)=["'][^"']*["']/gi," ");return st.match(/\bviewBox=/i)||(st+=` viewBox="0 0 ${Yt} ${jt}"`),st.match(/\bpreserveAspectRatio=/i)||(st+=' preserveAspectRatio="none"'),st+=' width="100%" height="100%"',`<svg${st}>`}),s.colors&&s.colors.length>0&&pt.length>0&&s.colors.forEach((rt,V)=>{if(pt[V]){const st=rt.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),it=new RegExp(st,"gi");$=$.replace(it,pt[V])}}),at&&at.type&&at.type!=="None"){if(at.type==="Solid"&&at.color){const rt=Z?"#FFFFFF":at.color,V=Z?1:this.normalizeOpacity(at.opacity??100);$=$.replace(/\bfill\s*=\s*["'][^"']*["']/gi,st=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(st)?st:`fill="${rt}"`),$=$.replace(/fill\s*:\s*[^;"')]+/gi,st=>/fill\s*:\s*(none|transparent)/i.test(st)?st:`fill:${rt}`),V<1&&($=$.replace(/\bfill-opacity\s*=\s*["'][^"']*["']/gi,`fill-opacity="${V}"`),$=$.replace(/fill-opacity\s*:\s*[^;"')]+/gi,`fill-opacity:${V}`),$.match(/\bfill-opacity\s*=/i)||($=$.replace(/(<svg[^>]*>)/i,`$1<g fill-opacity="${V}">`),$=$.replace(/<\/svg>/i,"</g></svg>")))}else if(at.type==="LinearGradient"||at.type==="RadialGradient"||at.type==="Linear"||at.type==="Radial"){const rt="exode-fill",V=this.normalizeOpacity(at.opacity??100),st=(at.stops||[]).map(vt=>{const Dt=vt.offset!==void 0?vt.offset:vt.pos??0,ee=this.normalizeOpacity(vt.opacity??100)*V;return`<stop offset="${Dt*100}%" stop-color="${vt.color||"#000"}" stop-opacity="${ee}"/>`}).join("");let it="";if(at.type==="LinearGradient"||at.type==="Linear"){const vt=(Kt,qt)=>Array.isArray(Kt)?Kt[qt]??(qt===0?0:1):Kt&&typeof Kt=="object"?Kt[qt===0?"x":"y"]??(qt===0?0:1):qt===0?0:1,Dt=vt(at.start,0)*100,ee=vt(at.start,1)*100,re=vt(at.end,0)*100,Nt=vt(at.end,1)*100;it=`<linearGradient id="${rt}" x1="${Dt}%" y1="${ee}%" x2="${re}%" y2="${Nt}%" gradientUnits="objectBoundingBox">${st}</linearGradient>`}else{const vt=(Nt,Kt)=>Array.isArray(Nt)?Nt[Kt]??.5:Nt&&typeof Nt=="object"?Nt[Kt===0?"x":"y"]??.5:.5,Dt=vt(at.center,0)*100,ee=vt(at.center,1)*100,re=(at.radius??.5)*100;it=`<radialGradient id="${rt}" cx="${Dt}%" cy="${ee}%" r="${re}%" gradientUnits="objectBoundingBox">${st}</radialGradient>`}/<defs>/i.test($)?$=$.replace(/<defs>/i,`<defs>${it}`):$=$.replace(/<svg([^>]*)>/i,`<svg$1><defs>${it}</defs>`),$=$.replace(/\bfill\s*=\s*["'][^"']*["']/gi,vt=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(vt)?vt:`fill="url(#${rt})"`),$=$.replace(/fill\s*:\s*[^;"')]+/gi,vt=>/fill\s*:\s*(none|transparent)/i.test(vt)?vt:`fill:url(#${rt})`)}}const te=(rt,V,st=1)=>{const it=(rt.stops||[]).map(Nt=>{const Kt=Nt.offset!==void 0?Nt.offset:Nt.pos??0,qt=this.normalizeOpacity(Nt.opacity??100)*st;return`<stop offset="${Kt*100}%" stop-color="${Nt.color||"#000"}" stop-opacity="${qt}"/>`}).join(""),vt=(Nt,Kt,qt=.5)=>Array.isArray(Nt)?Nt[Kt]??qt:Nt&&typeof Nt=="object"?Nt[Kt===0?"x":"y"]??qt:qt;if(rt.type==="LinearGradient"||rt.type==="Linear"){const Nt=vt(rt.start,0,0)*100,Kt=vt(rt.start,1,0)*100,qt=vt(rt.end,0,1)*100,Ie=vt(rt.end,1,1)*100;return`<linearGradient id="${V}" x1="${Nt}%" y1="${Kt}%" x2="${qt}%" y2="${Ie}%" gradientUnits="objectBoundingBox">${it}</linearGradient>`}const Dt=vt(rt.center,0,.5)*100,ee=vt(rt.center,1,.5)*100,re=(rt.radius??.5)*100;return`<radialGradient id="${V}" cx="${Dt}%" cy="${ee}%" r="${re}%" gradientUnits="objectBoundingBox">${it}</radialGradient>`},ut=(rt,V)=>/<defs>/i.test(rt)?rt.replace(/<defs>/i,`<defs>${V}`):rt.replace(/(<svg[^>]*>)/i,`$1<defs>${V}</defs>`);if(B&&B.isEnabled!==!1&&(B.width||0)>0){const rt=Z?1:this.normalizeOpacity(B.opacity??100),V=Z?"#FFFFFF":B.color||(at==null?void 0:at.color)||"#000000";let st="";const it=B.fill;if(it&&it.type){if(it.type==="Solid")st=it.color||B.color||"#000000";else if(it.type==="LinearGradient"||it.type==="RadialGradient"||it.type==="Linear"||it.type==="Radial"){const Ht="exode-stroke";$=ut($,te(it,Ht,rt)),st=`url(#${Ht})`}}st||(st=V),$.match(/\bstroke\s*=\s*["']/i)?$=$.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,Ht=>/stroke\s*=\s*["']\s*(none|transparent)\s*["']/i.test(Ht)?Ht:`stroke="${st}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke="${st}"`),$=$.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),`stroke:${st}`);let vt=s.width||a||100,Dt=s.height||r||100;const ee=ft.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(ee){const Ht=parseFloat(ee[1]),le=parseFloat(ee[2]);!isNaN(Ht)&&!isNaN(le)&&(vt=Ht,Dt=le)}const re=Math.max(.001,a/vt),Nt=Math.max(.001,r/Dt),Kt=(re+Nt)/2,qt=(B.width||1)/Kt;$.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="${rt}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-opacity="${rt}"`),$=$.replace(/stroke-opacity\s*:\s*[^;"')]+/gi,`stroke-opacity:${rt}`);const Ie=B.lineCap||"round";$.match(/\bstroke-linecap\s*=\s*["']/i)?$=$.replace(/\bstroke-linecap\s*=\s*["'][^"']*["']/gi,`stroke-linecap="${Ie}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linecap="${Ie}"`),$=$.replace(/stroke-linecap\s*:\s*[^;"')]+/gi,`stroke-linecap:${Ie}`);const xe=B.lineJoin||"round";$.match(/\bstroke-linejoin\s*=\s*["']/i)?$=$.replace(/\bstroke-linejoin\s*=\s*["'][^"']*["']/gi,`stroke-linejoin="${xe}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linejoin="${xe}"`),$=$.replace(/stroke-linejoin\s*:\s*[^;"')]+/gi,`stroke-linejoin:${xe}`);const Oe=B.trimStart??0,Le=B.trimEnd??1,Fe=B.trimOffset??0,Re=B.dashOffset??0,Xe=Oe!==0||Le!==1||Fe!==0||Re!==0;if(Xe){const Ht=Math.max(0,Math.min(1,Oe)),le=Math.max(0,Math.min(1,Le));this.frameCount%600===0&&this.debugLog(`SVG Trim - Object: ${i.name||i.id}, Start: ${Ht}, End: ${le}`);const Me=(vt+Dt)*2,$e=(Fe%1+1)%1,Be=(Re%1+1)%1;let ge="",de=0;if(Ht>=le)ge=`0 ${Me}`,de=0;else{const ue=Me*(le-Ht),ke=Me-ue;de=-(Me*(Ht+$e+Be)),ge=`${ue} ${ke}`}$.match(/\bstroke-dasharray\s*=/i)?$=$.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${ge}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dasharray="${ge}"`),$=$.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${ge}`),$.match(/\bstroke-dashoffset\s*=/i)?$=$.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${de}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dashoffset="${de}"`),$=$.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${de}`)}else if(B.dashArray&&B.dashArray.length>0){const Ht=B.dashArray.join(" ");$=$.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${Ht}"`),$=$.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${Ht}`),B.dashOffset&&($=$.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${B.dashOffset}"`),$=$.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${B.dashOffset}`))}if(!/\bstroke\s*=\s*["']/i.test(ft)&&!new RegExp("(?<![a-z-])stroke\\s*:","i").test(ft)){let Ht="",le="";if(Xe){const ge=s.width||a||100,de=s.height||r||100,ue=(ge+de)*2,ke=Math.max(0,Math.min(1,Oe)),De=Math.max(0,Math.min(1,Le)),qe=(Fe%1+1)%1,Ke=(Re%1+1)%1;if(ke>=De)Ht=` stroke-dasharray="0 ${ue}"`,le=' stroke-dashoffset="0"';else{const Ge=ue*(De-ke),Je=ue-Ge,U=-(ue*(ke+qe+Ke));Ht=` stroke-dasharray="${Ge} ${Je}"`,le=` stroke-dashoffset="${U}"`}}else(x=B.dashArray)!=null&&x.length&&(Ht=` stroke-dasharray="${B.dashArray.join(" ")}"`,B.dashOffset&&(le=` stroke-dashoffset="${B.dashOffset}"`));const Me=` stroke-linecap="${B.lineCap||"round"}"`,$e=` stroke-linejoin="${B.lineJoin||"round"}"`,Be=`stroke="${st}" stroke-width="${qt}" stroke-opacity="${rt}"${Me}${$e}${Ht}${le}`;$=$.replace(/(<svg[^>]*>)(\s*(?:<defs>[\s\S]*?<\/defs>)?)/i,(ge,de,ue)=>`${de}${ue}<g ${Be}>`),$=$.replace(/<\/svg>/i,"</g></svg>")}}else B&&B.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"}),Ct=URL.createObjectURL(ct);At.onload=()=>{if(URL.revokeObjectURL(Ct),this.frameCount%900===0){const rt=this.imageCache.get(kt);rt&&this.debugLog(`SVG Payload Ready: ${i.name||i.id} (${rt.naturalWidth}x${rt.naturalHeight})`)}},At.onerror=()=>{URL.revokeObjectURL(Ct),this.debugLog(`SVG Error: Failed to load payload for ${i.name||i.id}`)},At.src=Ct,this.imageCache.set(kt,At)}let Mt=null;if(At.complete&&At.naturalWidth>0?(Mt=At,this.lastValidSvgImgMap.set(i.id,At)):Mt=this.lastValidSvgImgMap.get(i.id)||null,Mt&&Mt.complete&&Mt.naturalWidth>0){const $=Math.max(1,a),Yt=Math.max(1,r);if(Z&&(at==null?void 0:at.type)==="Solid"){this.maskBuffer||(this.maskBuffer=document.createElement("canvas"),this.maskCtx=this.maskBuffer.getContext("2d")),this.maskBuffer.width=$,this.maskBuffer.height=Yt,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,$,Yt),this.maskCtx.drawImage(Mt,0,0,$,Yt),this.maskCtx.globalCompositeOperation="source-in";const jt=at.color||"#000000",ie=this.normalizeOpacity(at.opacity??100);this.maskCtx.fillStyle=jt,this.maskCtx.globalAlpha=ie,this.maskCtx.fillRect(0,0,$,Yt),t.drawImage(this.maskBuffer,-$/2,-Yt/2,$,Yt)}else h!==0?(t.save(),this.drawRoundRect(t,-$/2,-Yt/2,$,Yt,h),t.clip(),t.drawImage(Mt,-$/2,-Yt/2,$,Yt),t.restore()):t.drawImage(Mt,-$/2,-Yt/2,$,Yt)}}}else if(l.type==="LineGraph")this.renderLineGraph(t,l,a,r);else if(i.type==="Shape"){if(this.applyPath(t,l,a,r,h),t.save(),n.blur&&n.blur.amount>0&&(t.filter=`blur(${n.blur.amount}px)`),n.fill){const ft=t.globalAlpha;if(((R=n.fill)==null?void 0:R.type)==="Image"&&(n.fill.originalSrc||n.fill.src)){const pt=n.fill.originalSrc||n.fill.src;let at=this.imageCache.get(pt);at||(at=new Image,at.src=pt,this.imageCache.set(pt,at)),at.complete&&at.naturalWidth>0&&(t.save(),this.applyPath(t,l,a,r,h),t.clip(),this.renderFittedImage(t,at,-a/2,-r/2,a,r,n.fill.fillMode),t.restore())}else{const pt=this.createCanvasFill(t,n.fill,a,r);t.fillStyle=pt||(typeof n.fill=="string"?n.fill:n.fill.color||"transparent"),t.globalAlpha=ft*this.normalizeOpacity(n.fill.opacity??100),this.applyPath(t,l,a,r,h),t.fill()}t.globalAlpha=ft}t.restore(),n.stroke&&n.stroke.width>0&&this.applyStrokeAlignment(t,n,l,a,r,h,D,q)}else if(i.type==="Frame"||i.type==="Group"&&!i.isStructuralGroup){const ft=e.width??s.width??i.width??a,pt=e.height??s.height??i.height??r,at=h;if(t.save(),t.beginPath(),this.drawRoundRect(t,-ft/2,-pt/2,ft,pt,at),n.fill&&n.fill.type!=="None"){const B=t.globalAlpha,nt=this.createCanvasFill(t,n.fill,ft,pt);t.fillStyle=nt||n.fill.color||"transparent",t.globalAlpha=B*this.normalizeOpacity(n.fill.opacity??100),t.fill(),t.globalAlpha=B}if(t.restore(),n.stroke&&n.stroke.width>0&&n.stroke.isEnabled!==!1){const B={type:"Rectangle"};this.applyStrokeAlignment(t,n,B,ft,pt,at,D,q)}}else i.type==="Group"&&i.isStructuralGroup||(i.type==="Component"&&i.variant==="inputbox"?this.renderInputBox(t,i):i.type==="Component"&&i.variant==="button"?this.renderButton(t,i):i.type==="Component"&&i.variant==="toggle_button"?this.renderToggleButton(t,i):i.type==="Toggle"||i.type==="Component"&&i.variant==="toggle"?this.renderToggle(t,i):i.type==="Slider"||i.type==="Component"&&i.variant==="slider"?this.renderSlider(t,i):i.type==="Dropdown"||i.type==="Component"&&i.variant==="dropdown"?this.renderDropdown(t,i):i.type==="ListView"||i.type==="Component"&&i.variant==="listview"?this.renderListView(t,i):i.type==="Checkbox"||i.type==="Component"&&i.variant==="checkbox"?this.renderCheckbox(t,i):i.type==="RadioGroup"||i.type==="Component"&&i.variant==="radiogroup"?this.renderRadioGroup(t,i):i.type==="BarChart"||i.type==="Component"&&i.variant==="barchart"?this.renderBarChart(t,i):i.type==="PieChart"||i.type==="Component"&&i.variant==="piechart"?this.renderPieChart(t,i):i.type==="Joystick"||i.type==="Component"&&i.variant==="joystick"?this.renderJoystick(t,i):this.frameCount%300===0&&this.warn("[Engine] Unhandled object type in renderObject:",i.type,"Geo:",(j=i.geometry)==null?void 0:j.type));if(this.applyArtEffectOverlay(t,i,l,a,r,h),zt&&he==="BackgroundBlur"&&this.applyBackgroundBlurGlass(t,l,a,r,h,St),se&&se.enabled&&t.restore(),i.children&&i.children.length>0){const pt=i.type==="Frame",at=i.clipsContent!==void 0?i.clipsContent:i.clipContent!==void 0?i.clipContent:pt;if(t.save(),at){t.beginPath();const nt=e.width??(s==null?void 0:s.width)??i.width??0,Z=e.height??(s==null?void 0:s.height)??i.height??0,Pt=e.cornerRadius??(s==null?void 0:s.corner_radius)??i.cornerRadius??0;this.drawRoundRect(t,-nt/2,-Z/2,nt,Z,Pt),t.clip()}let B=0;for(i.children.forEach(nt=>{const Z=o.get(nt);if(!Z)return;const Pt=this.objectStates.get(nt),Ot=(Pt==null?void 0:Pt.geometry)||Z.geometry;if(Ot&&Ot.isMask&&(Pt==null?void 0:Pt.visible)!==!1){const kt=Ot.width||0,At=Ot.height||0;this.applyObjectTransform(t,nt);const Mt=(Pt==null?void 0:Pt.corner_radius)??(Ot==null?void 0:Ot.corner_radius)??0;this.applyPath(t,Ot,kt,At,Mt),t.clip(),B++}else this.renderObject(t,Z,o)});B>0;)t.restore(),B--;t.restore()}if(ae){this.maskCtx.restore(),(e.masks||(i.maskedBy?[{maskId:i.maskedBy,inverted:i.maskInverted===!0,type:i.maskType||"alpha",opacity:i.maskOpacity!==void 0?i.maskOpacity/100:1,feather:i.maskFeather||0,isVisible:!0}]:[])).filter(B=>B.isVisible!==!1&&o.has(B.maskId)).forEach(B=>{var Mt,$,Yt,jt,ie,te;const nt=o.get(B.maskId),Z=this.objectStates.get(nt.id),Pt=B.feather||0,Ot=B.inverted===!0,kt=B.opacity!==void 0?typeof B.opacity=="number"?B.opacity:B.opacity/100:1;if((B.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,nt.id,o),Pt>0&&(this.lumaCtx.filter=`blur(${Pt}px)`),this.lumaCtx.globalAlpha=kt;const ut=(Z==null?void 0:Z.width)||nt.geometry.width||0,ct=(Z==null?void 0:Z.height)||nt.geometry.height||0,Ct=(Z==null?void 0:Z.corner_radius)??nt.corner_radius??0;if(((Mt=nt.geometry)==null?void 0:Mt.type)==="Text"){const it=Z!=null&&Z.geometry?this.deepMerge(nt.geometry,Z.geometry):nt.geometry,vt=Z!=null&&Z.style?this.deepMerge(nt.style,Z.style):nt.style;this._renderText(this.lumaCtx,nt,{...it,width:ut,height:ct,corner_radius:Ct},vt,Z,ut,ct,!0,!1,D,q)}else if((($=nt.geometry)==null?void 0:$.type)==="Image"){const it=nt.geometry.src;if(it){let vt=this.imageCache.get(it);vt||(vt=new Image,vt.src=it,this.imageCache.set(it,vt)),vt.complete&&vt.naturalWidth>0?this.lumaCtx.drawImage(vt,-ut/2,-ct/2,ut,ct):(this.applyPath(this.lumaCtx,nt.geometry,ut,ct,Ct),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else if(((Yt=nt.geometry)==null?void 0:Yt.type)==="SVG"){const it=nt.geometry.svgContent;if(it){const vt=`__lumamask_${nt.id}`;let Dt=this.imageCache.get(vt);if(!Dt){Dt=new Image;const ee=new Blob([it],{type:"image/svg+xml"});Dt.src=URL.createObjectURL(ee),Dt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(vt,Dt)}Dt.complete&&Dt.naturalWidth>0?this.lumaCtx.drawImage(Dt,-ut/2,-ct/2,ut,ct):(this.applyPath(this.lumaCtx,nt.geometry,ut,ct,Ct),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else this.applyPath(this.lumaCtx,nt.geometry,ut,ct,Ct),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill();this.lumaCtx.restore();const rt=this.maskCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight),V=this.lumaCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight).data,st=rt.data;for(let it=0;it<st.length;it+=4){const vt=V[it],Dt=V[it+1],ee=V[it+2];let re=(.299*vt+.587*Dt+.114*ee)/255;Ot&&(re=1-re),st[it+3]*=re}this.maskCtx.putImageData(rt,0,0)}else{this.maskCtx.save(),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),this.maskCtx.globalCompositeOperation=Ot?"destination-out":"destination-in",Pt>0&&(this.maskCtx.filter=`blur(${Pt}px)`),this.maskCtx.globalAlpha=kt,this.applyAbsoluteTransform(this.maskCtx,nt.id,o);const ut=(Z==null?void 0:Z.width)||nt.geometry.width||0,ct=(Z==null?void 0:Z.height)||nt.geometry.height||0,Ct=(Z==null?void 0:Z.corner_radius)??nt.corner_radius??0;if(((jt=nt.geometry)==null?void 0:jt.type)==="Text"){const rt=Z!=null&&Z.geometry?this.deepMerge(nt.geometry,Z.geometry):nt.geometry,V=Z!=null&&Z.style?this.deepMerge(nt.style,Z.style):nt.style;this._renderText(this.maskCtx,nt,{...rt,width:ut,height:ct,corner_radius:Ct},V,Z,ut,ct,!0,!1,D,q)}else if(((ie=nt.geometry)==null?void 0:ie.type)==="Image"){const rt=nt.geometry.src;if(rt){let V=this.imageCache.get(rt);V||(V=new Image,V.src=rt,this.imageCache.set(rt,V)),V.complete&&V.naturalWidth>0?this.maskCtx.drawImage(V,-ut/2,-ct/2,ut,ct):(this.applyPath(this.maskCtx,nt.geometry,ut,ct,Ct),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else if(((te=nt.geometry)==null?void 0:te.type)==="SVG"){const rt=nt.geometry.svgContent;if(rt){const V=`__alphamask_${nt.id}`;let st=this.imageCache.get(V);if(!st){st=new Image;const it=new Blob([rt],{type:"image/svg+xml"});st.src=URL.createObjectURL(it),st.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(V,st)}st.complete&&st.naturalWidth>0?this.maskCtx.drawImage(st,-ut/2,-ct/2,ut,ct):(this.applyPath(this.maskCtx,nt.geometry,ut,ct,Ct),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else this.applyPath(this.maskCtx,nt.geometry,ut,ct,Ct),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill();this.maskCtx.restore()}}),Rt.save(),Rt.setTransform(1,0,0,1,0,0);const at=i.maskBlendMode||i.blendMode;at&&at!=="Normal"&&(Rt.globalCompositeOperation=at.toLowerCase()),Rt.drawImage(this.maskBuffer,0,0),Rt.restore(),Rt.restore()}else t.restore()}}_renderText(t,i,o,e,s,n,a,r=!1,f=!1,h=1,l=1){var yt,bt,gt,Et,It,St,zt,he,pe;let p=o.text||"";if(o.textInputId&&!r){const et=this.inputs.get(o.textInputId);et!==void 0&&(p=String(et),s.geometry&&s.geometry.type==="Text"&&(s.geometry.text=p))}if(o.svgPath){const et=o.svgPath;t.save();const mt=((yt=e==null?void 0:e.fill)==null?void 0:yt.color)||"#000000",Ft=((bt=e==null?void 0:e.fill)==null?void 0:bt.opacity)!==void 0?(gt=e==null?void 0:e.fill)==null?void 0:gt.opacity:1;t.fillStyle=mt,t.globalAlpha*=Ft;const _t=new Path2D(et);t.fill(_t),t.restore();return}let c=p||"";o.enableSegments===!0&&o.segments&&Array.isArray(o.segments)&&(c=o.segments.map(et=>et&&et.text?et.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,et=>et.toUpperCase()));let u=((Et=o.fontWeight)==null?void 0:Et.toString())||"400",v=o.fontStyle||"normal";u.toLowerCase().includes("italic")&&(v="italic",u=u.replace(/italic/gi,"").trim()||"400");const b=this.mapFontWeight(u),m=Math.max(1,o.fontSize||32);let y=o.fontFamily||"Inter";const S=["Bold","SemiBold","Medium","Regular","Light","Thin","ExtraBold","Black","Italic"];S.forEach(et=>{const mt=new RegExp(`[\\s-]${et}$`,"i");mt.test(y)&&(y=y.replace(mt,"").trim())});const M=`${o.smallCaps===!0?"small-caps ":""}${v} ${b} ${m}px "${y}", 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 et=o.letterSpacing;T=et.unit==="PERCENT"?et.value/100*m:et.value}t.letterSpacing!==void 0&&(t.letterSpacing=`${T}px`);const O=o.kerning||"auto",P=o.kerningValue||0;O==="manual"&&P!==0&&(t.letterSpacing=`${T+P}px`);const _=o.paragraphSpacing||0;let E=o.lineHeight??1.2;typeof E=="string"&&(E=parseFloat(E)),E>5&&m>0&&(E=E/m);const A=(E||1.2)*m,W=o.isPointText===!0||!o.width||o.width<=0,z=((It=o.padding)==null?void 0:It.left)||((St=o.padding)==null?void 0:St.right)||0,Y=W?1e5:o.width&&o.width>0?Math.ceil(o.width)-z*2:1e5;o.autoHeight;const G=ts({text:c,fontFamily:y,fontSize:m,fontWeight:b,fontStyle:v,lineHeight:E,width:Y,letterSpacing:T,paragraphSpacing:_,paragraphIndent:o.paragraphIndent||0,segments:o.segments,enableSegments:o.enableSegments,textCase:d,hyphenation:o.hyphenation,composer:o.composer,balanceRaggedLines:o.balanceRaggedLines}),N=G.lines||[],J=G.maxFontSize||m,x=this.fontLeadingFactors[y]??.5,R=(A-m)*x;let j=G.height,X=n,tt=a;if(X===0||tt===0||X>=1e5){let et=0,mt=0;const Ft=G.fullText||c;(N||[]).forEach(_t=>{const dt=_t.text||"",$t=t.measureText(dt).width+(dt.length>0?(dt.length-1)*T:0);$t>et&&(et=$t),mt+=dt.length,mt<Ft.length&&(Ft[mt]===`
23
- `||Ft[mt]==="\r")&&(mt++,Ft[mt-1]==="\r"&&Ft[mt]===`
24
- `&&mt++)}),(X===0||X>=1e5)&&(X=et),tt===0&&(tt=j||0)}let L=-j/2;a>0&&a>j&&(I==="top"?L=-a/2:I==="middle"||I==="center"?L=-j/2:I==="bottom"&&(L=a/2-j)),L+=R;let F=null,D=0;if(o.pathId&&this.artboard){const et=this.artboard.objects.find(mt=>mt.id===o.pathId);if(et&&et.type==="Shape"&&((zt=et.geometry)==null?void 0:zt.type)==="Path"){const mt=this.objectStates.get(et.id),Ft=mt!=null&&mt.geometry?this.deepMerge(et.geometry,mt.geometry):et.geometry,_t=(mt==null?void 0:mt.scale_x)!==void 0?(et.width||0)*mt.scale_x:et.width||0,dt=(mt==null?void 0:mt.scale_y)!==void 0?(et.height||0)*mt.scale_y:et.height||0;F={geo:Ft,obj:et,w:_t,h:dt},D=this.getPerimeter(Ft,_t,dt)}}const q=(et,mt)=>{var _t,dt;if(T===0&&(!o.enableSegments||!((_t=o.segments)!=null&&_t.length)))return t.measureText(et).width;let Ft=0;for(let $t=0;$t<et.length;$t++){const Vt=mt+$t;let Bt=0;if(o.enableSegments===!0&&((dt=o.segments)==null?void 0:dt.length)>0){let Rt=0,Ut=null;for(const ae of o.segments){if(Vt<Rt+(ae.text||"").length){Ut=ae;break}Rt+=(ae.text||"").length}if(Ut){t.save();let ae=Ut.fontFamily||o.fontFamily||"Inter";const be=this.mapFontWeight((Ut.fontWeight||o.fontWeight||"400").toString()),ve=Ut.fontStyle||v,Zt=Ut.fontSize||m;t.font=`${ve} ${be} ${Zt}px "${ae}", sans-serif`,Bt=t.measureText(et[$t]).width,t.restore()}else Bt=t.measureText(et[$t]).width}else Bt=t.measureText(et[$t]).width;Ft+=Bt+T}return Ft-(et.length>0?T:0)},ot=(et,mt,Ft,_t,dt)=>{var be,ve;const Vt=(dt===0||c[dt-1]===`
25
- `||c[dt-1]==="\r")&&o.paragraphIndent?o.paragraphIndent:0,Bt=(!r||f)&&(i.behaviors||[]).some(Zt=>Zt.enabled&&(Zt.type.toString().includes("Text")||["Typewriter","Scramble","Wave","Bounce","GlitchText","Reveal3D","RevealSlide","RevealBlur"].includes(Zt.type))),Rt=!o.pathId&&!Bt&&(o.enableSegments!==!0||!o.segments||o.segments.length===0),Ut=o.baselineShift||0,ae=Ft+Ut;if(Rt)t.font=M,_t?t.strokeText(et,mt+Vt,ae):t.fillText(et,mt+Vt,ae);else{const Zt=q(et,dt);let Ce=mt+Vt;k==="center"?Ce-=Zt/2:k==="right"&&(Ce-=Zt);const _e=dt+et.length>=c.length||c[dt+et.length]===`
26
- `||c[dt+et.length]==="\r";let Pe=0,we=0;const Ee=o.justifyMinWordSpacing,Ae=o.justifyMaxWordSpacing;if(k==="justify"&&!_e&&Zt>0&&!o.pathId){const pt=W?Zt:Y-z*2+0,at=Math.max(0,pt-Zt);for(let B=0;B<et.length;B++)et[B]===" "&&we++;if(we>0){const B=t.measureText(" ").width;let nt=Ee||B*.5,Z=Ae||B*2.5;Pe=Math.max(0,Math.min(at/we,Z-nt))}}let oe=o.pathOffset||0;o.pathId&&D>0&&F&&(k==="center"?oe+=D/2-Zt/2:k==="right"&&(oe+=D-Zt));let se=Ce;const ft=r&&!f?[]:((be=i.behaviors)==null?void 0:be.filter(pt=>[H.Typewriter,H.Scramble,H.Wave,H.Bounce,H.GlitchText,H.TextTrail,H.Reveal3D,H.RevealSlide,H.RevealBlur,H.TextLiquid,H.TextVortex,H.TextExplosion,H.TextRain,H.TextGravity,H.TextElastic,H.TextMatrix,H.TextNeon,H.TextGlitch3D,H.TextDissolve,H.TextOrganic,H.TextBreathe,H.TextFloral,H.TextSmoke,H.TextVariable,H.TextMagnet,H.TextSpin,H.TextZing,H.TextPerspective,H.TextMirror].includes(pt.type)&&pt.enabled))||[];for(let pt=0;pt<et.length;pt++){let at=et[pt];const B=dt+pt;let nt=0,Z=0,Pt=1,Ot=1,kt=0,At=1,Mt=at;ft.forEach(ut=>{const ct=ut.settings||{},Ct=ct.strength||1,rt=Date.now();if(ut.type===H.Typewriter)this.currentTime*(ct.speed||1)-B*(ct.stagger||.05)<0&&(At=0);else if(ut.type===H.Scramble)Math.max(0,Math.min(1,this.currentTime/(ct.duration||1.5))-B*.02)<1&&Math.random()<.3&&(Mt="$%#@!*&"[Math.floor(Math.random()*7)]);else if(ut.type===H.Wave)Z+=Math.sin(this.currentTime*5*(ct.speed||1)+B*(ct.frequency||1))*(ct.amplitude||20)*Ct;else if(ut.type===H.Bounce){const V=Math.max(0,this.currentTime%2-B*(ct.stagger||.1));V<1&&(Z-=Math.abs(Math.sin(V*Math.PI))*(ct.height||50)*Ct)}else if(ut.type===H.TextTrail){const V=this.pointerHistory[Math.max(0,this.pointerHistory.length-1-B*(ct.delay||5))];V&&(nt+=(V.x-(s.x+se))*Ct*.2,Z+=(V.y-(s.y+Ft+Z))*Ct*.2)}else if(ut.type===H.Reveal3D){const V=Math.max(0,Math.min(1,this.currentTime*(ct.speed||1)-B*(ct.stagger||.1)));Pt*=V,Ot*=V,At=V}else if(ut.type===H.RevealSlide){const V=Math.max(0,Math.min(1,this.currentTime*1.5-B*.05)),st=(1-V)*(ct.distance||40)*Ct,it=ct.direction||"up";it==="up"?Z-=st:it==="down"?Z+=st:it==="left"?nt-=st:it==="right"&&(nt+=st),At=V}else if(ut.type===H.RevealBlur){const V=Math.max(0,Math.min(1,this.currentTime*1.2-B*.1));At=V,nt+=(1-V)*5}else if(ut.type===H.TextLiquid){const V=Math.max(0,Math.sin(rt*.001*(ct.speed||1)+B*.5));Z+=V*(ct.amplitude||10)*Ct,Ot*=1+V*.2}else if(ut.type===H.TextVortex){const V=rt*.002*(ct.speed||1)+B*.2,st=(1-(Math.sin(rt*.001)*.5+.5))*(ct.radius||50);nt+=Math.cos(V)*st*Ct,Z+=Math.sin(V)*st*Ct}else if(ut.type===H.TextExplosion){const V=ct.force||1,st=this.currentTime%2;if(st<1){const it=(B/et.length-.5)*Math.PI*2,vt=st*100*V;nt+=Math.cos(it)*vt*Ct,Z+=Math.sin(it)*vt*Ct,At=1-st}}else if(ut.type===H.TextRain){const V=ct.speed||1,st=ct.height||100,it=(rt*.001*V+B*.1)%1;Z-=(1-it)*st*Ct,At=it>.1?1:it*10}else if(ut.type===H.TextGravity){const V=ct.gravity||9.8,st=this.currentTime%3/3,it=.5*V*Math.pow(st*10,2);it<100?Z+=it*Ct:Z+=100*Ct}else if(ut.type===H.TextMatrix){const V=ct.speed||1;if(Math.random()<.1*V){const it="0123456789ABCDEF!@#$%^&*";Mt=it[Math.floor(Math.random()*it.length)]}At=.3+(Math.sin(rt*.01*V+B)+1)/2*.7}else if(ut.type===H.TextNeon){const V=Math.random()>.95?.5:1;At=(.7+(Math.sin(rt*.005)+1)/2*.3)*V}else if(ut.type===H.TextDissolve)Math.sin(B*1.5+rt*.002*(ct.speed||1))>.5&&(At=0);else if(ut.type===H.TextOrganic){const V=ct.speed||1,st=ct.amplitude||10;nt+=Math.sin(rt*.002*V+B)*st*Ct,Z+=Math.cos(rt*.0015*V+B*.7)*st*Ct}else if(ut.type===H.TextBreathe){const st=1+(Math.sin(rt*.003+B*.2)+1)/2*.2*Ct;Pt*=st,Ot*=st}else if(ut.type===H.TextSpin){const V=ct.speed||1;kt+=rt*.01*V+B}else if(ut.type===H.TextMagnet){const V=this.pointerHistory[this.pointerHistory.length-1];if(V){const st=V.x-(s.x+se),it=V.y-(s.y+Ft);kt=Math.atan2(it,st)}}else if(ut.type===H.TextPerspective){const V=et.length/2,st=(B-V)/V,it=1-Math.abs(st)*.3*Ct;Pt*=it,Ot*=it,nt+=st*20*Ct}else if(ut.type===H.TextMirror)At*=.8;else if(ut.type===H.TextFloral){const V=ct.speed||1,st=ct.stagger||.1,it=(rt*.001*V+B*st)%2;it<1&&(Pt*=it,Ot*=it,kt+=it*Math.PI)}else if(ut.type===H.TextSmoke){const V=ct.speed||1,st=ct.height||50,it=(rt*5e-4*V+B*.2)%1;Z-=it*st*Ct,nt+=Math.sin(rt*.002+B)*5*Ct,At=1-it}else if(ut.type===H.TextVariable){const V=ct.speed||1,st=ct.intensity||1.5,it=(Math.sin(rt*.004*V+B*.3)+1)/2;Pt*=1+it*(st-1)*Ct}else if(ut.type===H.TextZing){const V=ct.speed||2,st=ct.distance||100,it=(rt*.002*V+B*.05)%1;nt+=(1-it)*st*Ct,At=it}else if(ut.type===H.TextElastic){const V=ct.stiffness||.2,st=ct.damping||.1,it=Math.sin(rt*.01)*Math.exp(-rt*.001*st);Ot*=1+it*V*Ct}else if(ut.type===H.TextGlitch3D){const V=ct.intensity||5;Math.random()<.2&&(nt+=(Math.random()-.5)*V,Z+=(Math.random()-.5)*V,At=.8)}else if(ut.type===H.GlitchText){const V=ct.intensity||5;Math.random()<.1&&(nt+=(Math.random()-.5)*V,Z+=(Math.random()-.5)*V,Math.random()<.05&&(At=.5))}});let $=null,Yt=o.textDecoration||"none",jt=m;if(o.enableSegments===!0&&((ve=o.segments)==null?void 0:ve.length)>0){let ut=0,ct=null;for(const Ct of o.segments){if(B<ut+(Ct.text||"").length){ct=Ct;break}ut+=(Ct.text||"").length}if(ct){let Ct=ct.fontFamily||o.fontFamily||"Inter";S.forEach(st=>{const it=new RegExp(`[\\s-]${st}$`,"i");it.test(Ct)&&(Ct=Ct.replace(it,"").trim())});const rt=this.mapFontWeight((ct.fontWeight||o.fontWeight||"400").toString()),V=ct.fontStyle||v;jt=ct.fontSize||m,t.font=`${V} ${rt} ${jt}px "${Ct}", sans-serif`,ct.fill&&($=ct.fill),ct.textDecoration&&(Yt=ct.textDecoration),jt<J&&(Z+=(J-jt)*.85)}}else t.font=M;const ie=t.globalAlpha;t.globalAlpha*=At,t.save();const te=t.measureText(Mt).width;if(F&&D>0){const ut=se-Ce+te/2,Ct=(oe+ut)/D,rt=this.getPointOnPath(F.geo,F.w,F.h,Math.abs(Ct%1)),V=rt.angle,st=Ft+Z+(o.pathOffsetY||0),it=o.pathSide==="right"?-1:1,vt=Math.cos(V+Math.PI/2)*st*it,Dt=Math.sin(V+Math.PI/2)*st*it;t.translate(rt.x+vt+nt,rt.y+Dt),t.rotate(V+kt+(it===-1?Math.PI:0))}else t.translate(se+nt+te/2,Ft+Z),kt!==0&&t.rotate(kt);if(t.scale(Pt,Ot),$&&!r&&!f){const ut=this.createCanvasFill(t,$,X,tt);t.fillStyle=ut||$.color||"#000000"}else if(!r&&!f){const ut=this.createCanvasFill(t,e.fill,X,tt);t.fillStyle=ut||e.fill.color||"#000000"}if(At>0)if(r||f){const ut=f?"#000000":this.createCanvasFill(t,e.fill,X,tt);t.fillStyle=ut||e.fill.color||"#ffffff",t.fillText(Mt,-te/2,0)}else _t?t.strokeText(Mt,-te/2,0):t.fillText(Mt,-te/2,0);Yt!=="none"&&!r&&this.drawTextDecoration(t,Yt,0,0,te,jt),t.restore(),t.globalAlpha=ie,k==="justify"&&Pe>0&&Mt===" "&&!_e?se+=te+T+Pe:se+=te+T}}};if(r){let et=0,mt=L;(N||[]).forEach(Ft=>{const _t=Ft.text||"",dt=c.indexOf(_t,et);dt!==-1&&(et=dt);let $t=-X/2;k==="center"?$t=0:k==="right"&&($t=X/2),ot(_t,$t,mt,!1,et),et+=_t.length,mt+=A})}else if(f){let et=0,mt=L;(N||[]).forEach(Ft=>{const _t=Ft.text||"";let dt=-X/2;k==="center"?dt=0:k==="right"&&(dt=X/2),ot(_t,dt,mt,!1,et),et+=_t.length,et<c.length&&(c[et]===`
27
- `||c[et]==="\r")&&(et++,c[et-1]==="\r"&&c[et]===`
28
- `&&et++),mt+=A})}else{if(e.fill){const mt=t.globalAlpha,Ft=this.createCanvasFill(t,e.fill,X,tt);t.fillStyle=Ft||e.fill.color||"#000000",t.globalAlpha=mt*this.normalizeOpacity(e.fill.opacity??100);const _t=G.fullText||(o.enableSegments?(o.segments||[]).map(Vt=>{let Bt=Vt.text||"";const Rt=Vt.textCase||o.textCase||"none";return Rt==="uppercase"?Bt.toUpperCase():Rt==="lowercase"?Bt.toLowerCase():Rt==="capitalize"?Bt.replace(/\b\w/g,Ut=>Ut.toUpperCase()):Bt}).join(""):c);let dt=0,$t=L;(N||[]).forEach(Vt=>{const Bt=Vt.text||"";let Rt=-X/2;k==="center"?Rt=0:k==="right"&&(Rt=X/2),ot(Bt,Rt,$t,!1,dt),dt+=Bt.length,$t+=A,dt<_t.length&&(_t[dt]===`
22
+ 0 0 0 1 0"/>`,kt="invert"}if(B!==0||et!==0||Q!==0||Pt!==0){const Mt=1+Q+Pt,$=Mt*(1+B-et/2),Yt=Mt*(1+et),jt=Mt*(1-B-et/2),ie=dt.shadows*.1/255,te=[$,0,0,0,ie,0,Yt,0,0,ie,0,0,jt,0,ie,0,0,0,1,0].join(" ");Ot+=`<feColorMatrix in="${kt}" type="matrix" values="${te}" result="advanced"/>`,kt="advanced"}if(dt.blur&&(Ot+=`<feGaussianBlur in="${kt}" stdDeviation="${dt.blur}" result="blur"/>`,kt="blur"),Ot){const Mt=`<svg xmlns="http://www.w3.org/2000/svg"><filter id="f" color-interpolation-filters="sRGB">${Ot}</filter></svg>`,$=btoa(Mt);bt.push(`url('data:image/svg+xml;base64,${$}#f')`)}}bt.length>0?t.filter=bt.join(" "):t.filter="none",t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high";const $t=t.globalAlpha,Vt=this.normalizeOpacity(e.opacity!==void 0?e.opacity:100);t.globalAlpha=$t*Vt;const Bt=e.compositeOperation||e.blendMode;if(Bt&&Bt!=="Normal"){const ft=Bt.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(ft)&&(t.globalCompositeOperation=ft)}const Ft=t,Ut=e.masks||(i.maskedBy?[{maskId:i.maskedBy,inverted:i.maskInverted===!0,type:i.maskType||"alpha",opacity:i.maskOpacity!==void 0?i.maskOpacity/100:1,feather:i.maskFeather||0,isVisible:!0}]:[]);let re=!1;const be=Ut.filter(ft=>ft.isVisible!==!1&&o.has(ft.maskId));if(be.length>0){const ft=be[0],ut=o.get(ft.maskId),at=this.objectStates.get(ut.id);at&&at.visible!==!1&&(re=!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),i.parentId&&this.applyAbsoluteTransform(this.maskCtx,i.parentId,o),this.maskCtx.save(),this.maskCtx.globalAlpha=1,t=this.maskCtx,t.filter=Ft.filter)}t.translate(Math.round(tt),Math.round(L)),t.rotate(R*Math.PI/180);const ve=e.skew_x||0,Zt=e.skew_y||0;if(ve!==0||Zt!==0){const ft=Math.tan(ve*Math.PI/180),ut=Math.tan(Zt*Math.PI/180);t.transform(1+ft*ut,ut,ft,1,0,0)}const Ce=e.rotate_x!==void 0?e.rotate_x:((A=e.transform)==null?void 0:A.rotate_x)??0,_e=e.rotate_y!==void 0?e.rotate_y:((W=e.transform)==null?void 0:W.rotate_y)??0,we=1+(e.translate_z!==void 0?e.translate_z:((z=e.transform)==null?void 0:z.translate_z)??0)/1e3,Ee=(e.flip_x===!0?-1:1)*Math.cos(_e*Math.PI/180)*we,Ae=(e.flip_y===!0?-1:1)*Math.cos(Ce*Math.PI/180)*we;t.scale(D*Ee,q*Ae),n.shadow&&n.shadow.isEnabled!==!0&&((n.shadow.blur||0)>0||Math.abs(n.shadow.offsetX||0)>0||Math.abs(n.shadow.offsetY||0)>0)&&(n.shadow.isEnabled=!0);const oe=n.shadow;if(oe&&oe.isEnabled!==!1){let ft=oe.color||"#000000";(G=(Y=this.artboard)==null?void 0:Y.tokens)!=null&&G.colors&&this.artboard.tokens.colors[ft]&&(ft=this.artboard.tokens.colors[ft]);const ut=this.normalizeOpacity(oe.opacity??100),at=oe.spread||0,et=(oe.blur||0)+at*1.5;let Q=ft;if(ft.startsWith("#")){const kt=ft.replace("#",""),At=parseInt(kt.substring(0,2),16),Mt=parseInt(kt.substring(2,4),16),$=parseInt(kt.substring(4,6),16);Q=`rgba(${At}, ${Mt}, ${$}, ${ut})`}else if(ft.startsWith("rgba")){const kt=ft.match(/[\d.]+/g);if(kt&&kt.length>=4){const At=kt[0],Mt=kt[1],$=kt[2],Yt=kt[3];Q=`rgba(${At}, ${Mt}, ${$}, ${parseFloat(Yt)*ut})`}}const Pt=t.getTransform(),Ot=Math.sqrt(Pt.a*Pt.a+Pt.b*Pt.b)||1;t.shadowColor=Q,t.shadowBlur=et*Ot,t.shadowOffsetX=(oe.offsetX||0)*Ot,t.shadowOffsetY=(oe.offsetY||0)*Ot}const se=i.liquidFill||((N=i.style)==null?void 0:N.liquidFill);if(se&&se.enabled){t.save();const ft=se.fillLevel??.5;t.beginPath();const ut=r/2-r*ft;t.rect(-a/2,ut,a,r*ft),t.clip(),t.fillStyle=se.color||"#3b82f6",t.globalAlpha=t.globalAlpha*(se.opacity??1)}if((s==null?void 0:s.type)==="Text")this._renderText(t,i,l,n,e,a,r,!1,!1,D,q);else if((s==null?void 0:s.type)==="Image"){const ft=s.originalSrc||s.src;if(ft){let ut=this.imageCache.get(ft);ut||(ut=new Image,ut.onload=()=>{this.log(`[ExodeUI] Image loaded successfully, size: ${ut.naturalWidth}x${ut.naturalHeight}`)},ut.onerror=et=>{console.error("[ExodeUI] Image load failed:",et,`Src preview: ${ft.substring(0,100)}...`)},ut.src=ft,this.imageCache.set(ft,ut));const at=n.stroke&&n.stroke.width>0&&n.stroke.isEnabled!==!1,B=(((J=n.stroke)==null?void 0:J.alignment)||"center").toLowerCase();if(at&&(B==="outside"||B==="center")&&this.applyStrokeAlignment(t,n,l,a,r,h,D,q),n.fill&&n.fill.type!=="None"){t.save();const et=t.globalAlpha,Q=this.createCanvasFill(t,n.fill,a,r);t.fillStyle=Q||n.fill.color||"transparent",t.globalAlpha=et*this.normalizeOpacity(n.fill.opacity??100),h!==0?(this.drawRoundRect(t,-a/2,-r/2,a,r,h),t.fill()):t.fillRect(-a/2,-r/2,a,r),t.globalAlpha=et,t.restore()}ut.complete&&ut.naturalWidth>0?(h!==0?(t.save(),this.drawRoundRect(t,-a/2,-r/2,a,r,h),t.clip(),t.drawImage(ut,-a/2,-r/2,a,r),t.restore()):t.drawImage(ut,-a/2,-r/2,a,r),at&&B==="inside"&&this.applyStrokeAlignment(t,n,l,a,r,h,D,q)):at&&B==="inside"&&this.applyStrokeAlignment(t,n,l,a,r,h,D,q)}}else if(s.type==="SVG"){const ft=s.svgContent;if(ft){const ut=n.palette||[],at=n.fill,B=n.stroke,et=at?this.normalizeOpacity(at.opacity??100):1,Q=(at==null?void 0:at.type)==="Solid"&&(!B||B.isEnabled===!1||B.type==="Solid"&&B.color===at.color),Pt=at&&at.type!=="None"?Q?"monochrome":at.type==="Solid"?(at.color||"")+"|opacity:"+et:JSON.stringify(at.stops||[])+"|opacity:"+et:"",Ot=B&&B.isEnabled!==!1&&(B.width||0)>0?Q?["monochrome",B.width||0,B.trimStart??0,B.trimEnd??1,B.trimOffset??0,B.dashOffset??0].join("|"):[B.width||0,B.fill?B.fill.type==="Solid"?B.fill.color||"":JSON.stringify(B.fill.stops||[]):B.color||"",B.opacity??1,B.lineCap||"",B.lineJoin||"",(B.dashArray||[]).join(","),B.trimStart??0,B.trimEnd??1,B.trimOffset??0,B.dashOffset??0].join("|"):"nostroke",kt=[i.id,ut.join("_"),Pt,Ot,e.opacity??100,e.visible!==!1?"v":"h"].join("_");let At=this.imageCache.get(kt);if(!At){At=new Image,At.crossOrigin="anonymous";let $=ft;$.match(/xmlns=["']http:\/\/www\.w3\.org\/2000\/svg["']/i)||($=$.replace(/<svg([^>]*)>/i,(rt,V)=>`<svg xmlns="http://www.w3.org/2000/svg"${V}>`));let Yt=s.width||a||100,jt=s.height||r||100;const ie=$.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(ie&&(Yt=parseFloat(ie[1]),jt=parseFloat(ie[2])),$=$.replace(/<svg([^>]*)>/i,(rt,V)=>{let it=V.replace(/\b(?:width|height)=["'][^"']*["']/gi," ");return it.match(/\bviewBox=/i)||(it+=` viewBox="0 0 ${Yt} ${jt}"`),it.match(/\bpreserveAspectRatio=/i)||(it+=' preserveAspectRatio="none"'),it+=' width="100%" height="100%"',`<svg${it}>`}),s.colors&&s.colors.length>0&&ut.length>0&&s.colors.forEach((rt,V)=>{if(ut[V]){const it=rt.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),nt=new RegExp(it,"gi");$=$.replace(nt,ut[V])}}),at&&at.type&&at.type!=="None"){if(at.type==="Solid"&&at.color){const rt=Q?"#FFFFFF":at.color,V=Q?1:this.normalizeOpacity(at.opacity??100);$=$.replace(/\bfill\s*=\s*["'][^"']*["']/gi,it=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(it)?it:`fill="${rt}"`),$=$.replace(/fill\s*:\s*[^;"')]+/gi,it=>/fill\s*:\s*(none|transparent)/i.test(it)?it:`fill:${rt}`),V<1&&($=$.replace(/\bfill-opacity\s*=\s*["'][^"']*["']/gi,`fill-opacity="${V}"`),$=$.replace(/fill-opacity\s*:\s*[^;"')]+/gi,`fill-opacity:${V}`),$.match(/\bfill-opacity\s*=/i)||($=$.replace(/(<svg[^>]*>)/i,`$1<g fill-opacity="${V}">`),$=$.replace(/<\/svg>/i,"</g></svg>")))}else if(at.type==="LinearGradient"||at.type==="RadialGradient"||at.type==="Linear"||at.type==="Radial"){const rt="exode-fill",V=this.normalizeOpacity(at.opacity??100),it=(at.stops||[]).map(St=>{const Gt=St.offset!==void 0?St.offset:St.pos??0,ee=this.normalizeOpacity(St.opacity??100)*V;return`<stop offset="${Gt*100}%" stop-color="${St.color||"#000"}" stop-opacity="${ee}"/>`}).join("");let nt="";if(at.type==="LinearGradient"||at.type==="Linear"){const St=(Kt,qt)=>Array.isArray(Kt)?Kt[qt]??(qt===0?0:1):Kt&&typeof Kt=="object"?Kt[qt===0?"x":"y"]??(qt===0?0:1):qt===0?0:1,Gt=St(at.start,0)*100,ee=St(at.start,1)*100,le=St(at.end,0)*100,Nt=St(at.end,1)*100;nt=`<linearGradient id="${rt}" x1="${Gt}%" y1="${ee}%" x2="${le}%" y2="${Nt}%" gradientUnits="objectBoundingBox">${it}</linearGradient>`}else{const St=(Nt,Kt)=>Array.isArray(Nt)?Nt[Kt]??.5:Nt&&typeof Nt=="object"?Nt[Kt===0?"x":"y"]??.5:.5,Gt=St(at.center,0)*100,ee=St(at.center,1)*100,le=(at.radius??.5)*100;nt=`<radialGradient id="${rt}" cx="${Gt}%" cy="${ee}%" r="${le}%" gradientUnits="objectBoundingBox">${it}</radialGradient>`}/<defs>/i.test($)?$=$.replace(/<defs>/i,`<defs>${nt}`):$=$.replace(/<svg([^>]*)>/i,`<svg$1><defs>${nt}</defs>`),$=$.replace(/\bfill\s*=\s*["'][^"']*["']/gi,St=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(St)?St:`fill="url(#${rt})"`),$=$.replace(/fill\s*:\s*[^;"')]+/gi,St=>/fill\s*:\s*(none|transparent)/i.test(St)?St:`fill:url(#${rt})`)}}const te=(rt,V,it=1)=>{const nt=(rt.stops||[]).map(Nt=>{const Kt=Nt.offset!==void 0?Nt.offset:Nt.pos??0,qt=this.normalizeOpacity(Nt.opacity??100)*it;return`<stop offset="${Kt*100}%" stop-color="${Nt.color||"#000"}" stop-opacity="${qt}"/>`}).join(""),St=(Nt,Kt,qt=.5)=>Array.isArray(Nt)?Nt[Kt]??qt:Nt&&typeof Nt=="object"?Nt[Kt===0?"x":"y"]??qt:qt;if(rt.type==="LinearGradient"||rt.type==="Linear"){const Nt=St(rt.start,0,0)*100,Kt=St(rt.start,1,0)*100,qt=St(rt.end,0,1)*100,Ie=St(rt.end,1,1)*100;return`<linearGradient id="${V}" x1="${Nt}%" y1="${Kt}%" x2="${qt}%" y2="${Ie}%" gradientUnits="objectBoundingBox">${nt}</linearGradient>`}const Gt=St(rt.center,0,.5)*100,ee=St(rt.center,1,.5)*100,le=(rt.radius??.5)*100;return`<radialGradient id="${V}" cx="${Gt}%" cy="${ee}%" r="${le}%" gradientUnits="objectBoundingBox">${nt}</radialGradient>`},pt=(rt,V)=>/<defs>/i.test(rt)?rt.replace(/<defs>/i,`<defs>${V}`):rt.replace(/(<svg[^>]*>)/i,`$1<defs>${V}</defs>`);if(B&&B.isEnabled!==!1&&(B.width||0)>0){const rt=Q?1:this.normalizeOpacity(B.opacity??100),V=Q?"#FFFFFF":B.color||(at==null?void 0:at.color)||"#000000";let it="";const nt=B.fill;if(nt&&nt.type){if(nt.type==="Solid")it=nt.color||B.color||"#000000";else if(nt.type==="LinearGradient"||nt.type==="RadialGradient"||nt.type==="Linear"||nt.type==="Radial"){const Ht="exode-stroke";$=pt($,te(nt,Ht,rt)),it=`url(#${Ht})`}}it||(it=V),$.match(/\bstroke\s*=\s*["']/i)?$=$.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,Ht=>/stroke\s*=\s*["']\s*(none|transparent)\s*["']/i.test(Ht)?Ht:`stroke="${it}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke="${it}"`),$=$.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),`stroke:${it}`);let St=s.width||a||100,Gt=s.height||r||100;const ee=ft.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(ee){const Ht=parseFloat(ee[1]),ce=parseFloat(ee[2]);!isNaN(Ht)&&!isNaN(ce)&&(St=Ht,Gt=ce)}const le=Math.max(.001,a/St),Nt=Math.max(.001,r/Gt),Kt=(le+Nt)/2,qt=(B.width||1)/Kt;$.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="${rt}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-opacity="${rt}"`),$=$.replace(/stroke-opacity\s*:\s*[^;"')]+/gi,`stroke-opacity:${rt}`);const Ie=B.lineCap||"round";$.match(/\bstroke-linecap\s*=\s*["']/i)?$=$.replace(/\bstroke-linecap\s*=\s*["'][^"']*["']/gi,`stroke-linecap="${Ie}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linecap="${Ie}"`),$=$.replace(/stroke-linecap\s*:\s*[^;"')]+/gi,`stroke-linecap:${Ie}`);const xe=B.lineJoin||"round";$.match(/\bstroke-linejoin\s*=\s*["']/i)?$=$.replace(/\bstroke-linejoin\s*=\s*["'][^"']*["']/gi,`stroke-linejoin="${xe}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linejoin="${xe}"`),$=$.replace(/stroke-linejoin\s*:\s*[^;"')]+/gi,`stroke-linejoin:${xe}`);const Oe=B.trimStart??0,Le=B.trimEnd??1,Re=B.trimOffset??0,Fe=B.dashOffset??0,Xe=Oe!==0||Le!==1||Re!==0||Fe!==0;if(Xe){const Ht=Math.max(0,Math.min(1,Oe)),ce=Math.max(0,Math.min(1,Le));this.frameCount%600===0&&this.debugLog(`SVG Trim - Object: ${i.name||i.id}, Start: ${Ht}, End: ${ce}`);const Me=(St+Gt)*2,$e=(Re%1+1)%1,Be=(Fe%1+1)%1;let ge="",de=0;if(Ht>=ce)ge=`0 ${Me}`,de=0;else{const ue=Me*(ce-Ht),ke=Me-ue;de=-(Me*(Ht+$e+Be)),ge=`${ue} ${ke}`}$.match(/\bstroke-dasharray\s*=/i)?$=$.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${ge}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dasharray="${ge}"`),$=$.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${ge}`),$.match(/\bstroke-dashoffset\s*=/i)?$=$.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${de}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dashoffset="${de}"`),$=$.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${de}`)}else if(B.dashArray&&B.dashArray.length>0){const Ht=B.dashArray.join(" ");$=$.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${Ht}"`),$=$.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${Ht}`),B.dashOffset&&($=$.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${B.dashOffset}"`),$=$.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${B.dashOffset}`))}if(!/\bstroke\s*=\s*["']/i.test(ft)&&!new RegExp("(?<![a-z-])stroke\\s*:","i").test(ft)){let Ht="",ce="";if(Xe){const ge=s.width||a||100,de=s.height||r||100,ue=(ge+de)*2,ke=Math.max(0,Math.min(1,Oe)),De=Math.max(0,Math.min(1,Le)),qe=(Re%1+1)%1,Ke=(Fe%1+1)%1;if(ke>=De)Ht=` stroke-dasharray="0 ${ue}"`,ce=' stroke-dashoffset="0"';else{const Ge=ue*(De-ke),Je=ue-Ge,U=-(ue*(ke+qe+Ke));Ht=` stroke-dasharray="${Ge} ${Je}"`,ce=` stroke-dashoffset="${U}"`}}else(x=B.dashArray)!=null&&x.length&&(Ht=` stroke-dasharray="${B.dashArray.join(" ")}"`,B.dashOffset&&(ce=` stroke-dashoffset="${B.dashOffset}"`));const Me=` stroke-linecap="${B.lineCap||"round"}"`,$e=` stroke-linejoin="${B.lineJoin||"round"}"`,Be=`stroke="${it}" stroke-width="${qt}" stroke-opacity="${rt}"${Me}${$e}${Ht}${ce}`;$=$.replace(/(<svg[^>]*>)(\s*(?:<defs>[\s\S]*?<\/defs>)?)/i,(ge,de,ue)=>`${de}${ue}<g ${Be}>`),$=$.replace(/<\/svg>/i,"</g></svg>")}}else B&&B.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"}),Ct=URL.createObjectURL(ct);At.onload=()=>{if(URL.revokeObjectURL(Ct),this.frameCount%900===0){const rt=this.imageCache.get(kt);rt&&this.debugLog(`SVG Payload Ready: ${i.name||i.id} (${rt.naturalWidth}x${rt.naturalHeight})`)}},At.onerror=()=>{URL.revokeObjectURL(Ct),this.debugLog(`SVG Error: Failed to load payload for ${i.name||i.id}`)},At.src=Ct,this.imageCache.set(kt,At)}let Mt=null;if(At.complete&&At.naturalWidth>0?(Mt=At,this.lastValidSvgImgMap.set(i.id,At)):Mt=this.lastValidSvgImgMap.get(i.id)||null,Mt&&Mt.complete&&Mt.naturalWidth>0){const $=Math.max(1,a),Yt=Math.max(1,r);if(Q&&(at==null?void 0:at.type)==="Solid"){this.maskBuffer||(this.maskBuffer=document.createElement("canvas"),this.maskCtx=this.maskBuffer.getContext("2d")),this.maskBuffer.width=$,this.maskBuffer.height=Yt,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,$,Yt),this.maskCtx.drawImage(Mt,0,0,$,Yt),this.maskCtx.globalCompositeOperation="source-in";const jt=at.color||"#000000",ie=this.normalizeOpacity(at.opacity??100);this.maskCtx.fillStyle=jt,this.maskCtx.globalAlpha=ie,this.maskCtx.fillRect(0,0,$,Yt),t.drawImage(this.maskBuffer,-$/2,-Yt/2,$,Yt)}else h!==0?(t.save(),this.drawRoundRect(t,-$/2,-Yt/2,$,Yt,h),t.clip(),t.drawImage(Mt,-$/2,-Yt/2,$,Yt),t.restore()):t.drawImage(Mt,-$/2,-Yt/2,$,Yt)}}}else if(l.type==="LineGraph")this.renderLineGraph(t,l,a,r);else if(i.type==="Shape"){if(this.applyPath(t,l,a,r,h),t.save(),n.blur&&n.blur.amount>0&&(t.filter=`blur(${n.blur.amount}px)`),Dt&&ae==="BackgroundBlur")this.applyBackgroundBlurGlass(t,l,a,r,h,vt);else if(n.fill){const ut=t.globalAlpha;if(((F=n.fill)==null?void 0:F.type)==="Image"&&(n.fill.originalSrc||n.fill.src)){const at=n.fill.originalSrc||n.fill.src;let B=this.imageCache.get(at);B||(B=new Image,B.src=at,this.imageCache.set(at,B)),B.complete&&B.naturalWidth>0&&(t.save(),this.applyPath(t,l,a,r,h),t.clip(),this.renderFittedImage(t,B,-a/2,-r/2,a,r,n.fill.fillMode),t.restore())}else{const at=this.createCanvasFill(t,n.fill,a,r);t.fillStyle=at||(typeof n.fill=="string"?n.fill:n.fill.color||"transparent"),t.globalAlpha=ut*this.normalizeOpacity(n.fill.opacity??100),this.applyPath(t,l,a,r,h),t.fill()}t.globalAlpha=ut}t.restore(),n.stroke&&n.stroke.width>0&&(this.applyPath(t,l,a,r,h),this.applyStrokeAlignment(t,n,l,a,r,h,D,q))}else if(i.type==="Frame"||i.type==="Group"&&!i.isStructuralGroup){const ft=e.width??s.width??i.width??a,ut=e.height??s.height??i.height??r,at=h;if(t.save(),t.beginPath(),this.drawRoundRect(t,-ft/2,-ut/2,ft,ut,at),Dt&&ae==="BackgroundBlur")this.applyBackgroundBlurGlass(t,l,ft,ut,at,vt);else if(n.fill&&n.fill.type!=="None"){const et=t.globalAlpha,Q=this.createCanvasFill(t,n.fill,ft,ut);t.fillStyle=Q||n.fill.color||"transparent",t.globalAlpha=et*this.normalizeOpacity(n.fill.opacity??100),t.beginPath(),this.drawRoundRect(t,-ft/2,-ut/2,ft,ut,at),t.fill(),t.globalAlpha=et}if(t.restore(),n.stroke&&n.stroke.width>0&&n.stroke.isEnabled!==!1){const et={type:"Rectangle"};t.beginPath(),this.drawRoundRect(t,-ft/2,-ut/2,ft,ut,at),this.applyStrokeAlignment(t,n,et,ft,ut,at,D,q)}}else i.type==="Group"&&i.isStructuralGroup||(i.type==="Component"&&i.variant==="inputbox"?this.renderInputBox(t,i):i.type==="Component"&&i.variant==="button"?this.renderButton(t,i):i.type==="Component"&&i.variant==="toggle_button"?this.renderToggleButton(t,i):i.type==="Toggle"||i.type==="Component"&&i.variant==="toggle"?this.renderToggle(t,i):i.type==="Slider"||i.type==="Component"&&i.variant==="slider"?this.renderSlider(t,i):i.type==="Dropdown"||i.type==="Component"&&i.variant==="dropdown"?this.renderDropdown(t,i):i.type==="ListView"||i.type==="Component"&&i.variant==="listview"?this.renderListView(t,i):i.type==="Checkbox"||i.type==="Component"&&i.variant==="checkbox"?this.renderCheckbox(t,i):i.type==="RadioGroup"||i.type==="Component"&&i.variant==="radiogroup"?this.renderRadioGroup(t,i):i.type==="BarChart"||i.type==="Component"&&i.variant==="barchart"?this.renderBarChart(t,i):i.type==="PieChart"||i.type==="Component"&&i.variant==="piechart"?this.renderPieChart(t,i):i.type==="Joystick"||i.type==="Component"&&i.variant==="joystick"?this.renderJoystick(t,i):this.frameCount%300===0&&this.warn("[Engine] Unhandled object type in renderObject:",i.type,"Geo:",(j=i.geometry)==null?void 0:j.type));if(this.applyArtEffectOverlay(t,i,l,a,r,h),se&&se.enabled&&t.restore(),i.children&&i.children.length>0){const ut=i.type==="Frame",at=i.clipsContent!==void 0?i.clipsContent:i.clipContent!==void 0?i.clipContent:ut;if(t.save(),at){t.beginPath();const et=e.width??(s==null?void 0:s.width)??i.width??0,Q=e.height??(s==null?void 0:s.height)??i.height??0,Pt=e.cornerRadius??(s==null?void 0:s.corner_radius)??i.cornerRadius??0;this.drawRoundRect(t,-et/2,-Q/2,et,Q,Pt),t.clip()}let B=0;for(i.children.forEach(et=>{const Q=o.get(et);if(!Q)return;const Pt=this.objectStates.get(et),Ot=(Pt==null?void 0:Pt.geometry)||Q.geometry;if(Ot&&Ot.isMask&&(Pt==null?void 0:Pt.visible)!==!1){const kt=Ot.width||0,At=Ot.height||0;this.applyObjectTransform(t,et);const Mt=(Pt==null?void 0:Pt.corner_radius)??(Ot==null?void 0:Ot.corner_radius)??0;this.applyPath(t,Ot,kt,At,Mt),t.clip(),B++}else this.renderObject(t,Q,o)});B>0;)t.restore(),B--;t.restore()}if(re){this.maskCtx.restore(),(e.masks||(i.maskedBy?[{maskId:i.maskedBy,inverted:i.maskInverted===!0,type:i.maskType||"alpha",opacity:i.maskOpacity!==void 0?i.maskOpacity/100:1,feather:i.maskFeather||0,isVisible:!0}]:[])).filter(B=>B.isVisible!==!1&&o.has(B.maskId)).forEach(B=>{var Mt,$,Yt,jt,ie,te;const et=o.get(B.maskId),Q=this.objectStates.get(et.id),Pt=B.feather||0,Ot=B.inverted===!0,kt=B.opacity!==void 0?typeof B.opacity=="number"?B.opacity:B.opacity/100:1;if((B.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,et.id,o),Pt>0&&(this.lumaCtx.filter=`blur(${Pt}px)`),this.lumaCtx.globalAlpha=kt;const pt=(Q==null?void 0:Q.width)||et.geometry.width||0,ct=(Q==null?void 0:Q.height)||et.geometry.height||0,Ct=(Q==null?void 0:Q.corner_radius)??et.corner_radius??0;if(((Mt=et.geometry)==null?void 0:Mt.type)==="Text"){const nt=Q!=null&&Q.geometry?this.deepMerge(et.geometry,Q.geometry):et.geometry,St=Q!=null&&Q.style?this.deepMerge(et.style,Q.style):et.style;this._renderText(this.lumaCtx,et,{...nt,width:pt,height:ct,corner_radius:Ct},St,Q,pt,ct,!0,!1,D,q)}else if((($=et.geometry)==null?void 0:$.type)==="Image"){const nt=et.geometry.src;if(nt){let St=this.imageCache.get(nt);St||(St=new Image,St.src=nt,this.imageCache.set(nt,St)),St.complete&&St.naturalWidth>0?this.lumaCtx.drawImage(St,-pt/2,-ct/2,pt,ct):(this.applyPath(this.lumaCtx,et.geometry,pt,ct,Ct),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else if(((Yt=et.geometry)==null?void 0:Yt.type)==="SVG"){const nt=et.geometry.svgContent;if(nt){const St=`__lumamask_${et.id}`;let Gt=this.imageCache.get(St);if(!Gt){Gt=new Image;const ee=new Blob([nt],{type:"image/svg+xml"});Gt.src=URL.createObjectURL(ee),Gt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(St,Gt)}Gt.complete&&Gt.naturalWidth>0?this.lumaCtx.drawImage(Gt,-pt/2,-ct/2,pt,ct):(this.applyPath(this.lumaCtx,et.geometry,pt,ct,Ct),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else this.applyPath(this.lumaCtx,et.geometry,pt,ct,Ct),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill();this.lumaCtx.restore();const rt=this.maskCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight),V=this.lumaCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight).data,it=rt.data;for(let nt=0;nt<it.length;nt+=4){const St=V[nt],Gt=V[nt+1],ee=V[nt+2];let le=(.299*St+.587*Gt+.114*ee)/255;Ot&&(le=1-le),it[nt+3]*=le}this.maskCtx.putImageData(rt,0,0)}else{this.maskCtx.save(),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),this.maskCtx.globalCompositeOperation=Ot?"destination-out":"destination-in",Pt>0&&(this.maskCtx.filter=`blur(${Pt}px)`),this.maskCtx.globalAlpha=kt,this.applyAbsoluteTransform(this.maskCtx,et.id,o);const pt=(Q==null?void 0:Q.width)||et.geometry.width||0,ct=(Q==null?void 0:Q.height)||et.geometry.height||0,Ct=(Q==null?void 0:Q.corner_radius)??et.corner_radius??0;if(((jt=et.geometry)==null?void 0:jt.type)==="Text"){const rt=Q!=null&&Q.geometry?this.deepMerge(et.geometry,Q.geometry):et.geometry,V=Q!=null&&Q.style?this.deepMerge(et.style,Q.style):et.style;this._renderText(this.maskCtx,et,{...rt,width:pt,height:ct,corner_radius:Ct},V,Q,pt,ct,!0,!1,D,q)}else if(((ie=et.geometry)==null?void 0:ie.type)==="Image"){const rt=et.geometry.src;if(rt){let V=this.imageCache.get(rt);V||(V=new Image,V.src=rt,this.imageCache.set(rt,V)),V.complete&&V.naturalWidth>0?this.maskCtx.drawImage(V,-pt/2,-ct/2,pt,ct):(this.applyPath(this.maskCtx,et.geometry,pt,ct,Ct),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else if(((te=et.geometry)==null?void 0:te.type)==="SVG"){const rt=et.geometry.svgContent;if(rt){const V=`__alphamask_${et.id}`;let it=this.imageCache.get(V);if(!it){it=new Image;const nt=new Blob([rt],{type:"image/svg+xml"});it.src=URL.createObjectURL(nt),it.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(V,it)}it.complete&&it.naturalWidth>0?this.maskCtx.drawImage(it,-pt/2,-ct/2,pt,ct):(this.applyPath(this.maskCtx,et.geometry,pt,ct,Ct),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else this.applyPath(this.maskCtx,et.geometry,pt,ct,Ct),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill();this.maskCtx.restore()}}),Ft.save(),Ft.setTransform(1,0,0,1,0,0);const at=i.maskBlendMode||i.blendMode;at&&at!=="Normal"&&(Ft.globalCompositeOperation=at.toLowerCase()),Ft.drawImage(this.maskBuffer,0,0),Ft.restore(),Ft.restore()}else t.restore()}}_renderText(t,i,o,e,s,n,a,r=!1,f=!1,h=1,l=1){var mt,bt,gt,Et,It,vt,Dt,ae,pe;let p=o.text||"";if(o.textInputId&&!r){const st=this.inputs.get(o.textInputId);st!==void 0&&(p=String(st),s.geometry&&s.geometry.type==="Text"&&(s.geometry.text=p))}if(o.svgPath){const st=o.svgPath;t.save();const yt=((mt=e==null?void 0:e.fill)==null?void 0:mt.color)||"#000000",Rt=((bt=e==null?void 0:e.fill)==null?void 0:bt.opacity)!==void 0?(gt=e==null?void 0:e.fill)==null?void 0:gt.opacity:1;t.fillStyle=yt,t.globalAlpha*=Rt;const _t=new Path2D(st);t.fill(_t),t.restore();return}let c=p||"";o.enableSegments===!0&&o.segments&&Array.isArray(o.segments)&&(c=o.segments.map(st=>st&&st.text?st.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,st=>st.toUpperCase()));let u=((Et=o.fontWeight)==null?void 0:Et.toString())||"400",v=o.fontStyle||"normal";u.toLowerCase().includes("italic")&&(v="italic",u=u.replace(/italic/gi,"").trim()||"400");const b=this.mapFontWeight(u),y=Math.max(1,o.fontSize||32);let m=o.fontFamily||"Inter";const S=["Bold","SemiBold","Medium","Regular","Light","Thin","ExtraBold","Black","Italic"];S.forEach(st=>{const yt=new RegExp(`[\\s-]${st}$`,"i");yt.test(m)&&(m=m.replace(yt,"").trim())});const M=`${o.smallCaps===!0?"small-caps ":""}${v} ${b} ${y}px "${m}", 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 st=o.letterSpacing;T=st.unit==="PERCENT"?st.value/100*y:st.value}t.letterSpacing!==void 0&&(t.letterSpacing=`${T}px`);const O=o.kerning||"auto",P=o.kerningValue||0;O==="manual"&&P!==0&&(t.letterSpacing=`${T+P}px`);const _=o.paragraphSpacing||0;let E=o.lineHeight??1.2;typeof E=="string"&&(E=parseFloat(E)),E>5&&y>0&&(E=E/y);const A=(E||1.2)*y,W=o.isPointText===!0||!o.width||o.width<=0,z=((It=o.padding)==null?void 0:It.left)||((vt=o.padding)==null?void 0:vt.right)||0,Y=W?1e5:o.width&&o.width>0?Math.ceil(o.width)-z*2:1e5;o.autoHeight;const G=ts({text:c,fontFamily:m,fontSize:y,fontWeight:b,fontStyle:v,lineHeight:E,width:Y,letterSpacing:T,paragraphSpacing:_,paragraphIndent:o.paragraphIndent||0,segments:o.segments,enableSegments:o.enableSegments,textCase:d,hyphenation:o.hyphenation,composer:o.composer,balanceRaggedLines:o.balanceRaggedLines}),N=G.lines||[],J=G.maxFontSize||y,x=this.fontLeadingFactors[m]??.5,F=(A-y)*x;let j=G.height,X=n,tt=a;if(X===0||tt===0||X>=1e5){let st=0,yt=0;const Rt=G.fullText||c;(N||[]).forEach(_t=>{const dt=_t.text||"",$t=t.measureText(dt).width+(dt.length>0?(dt.length-1)*T:0);$t>st&&(st=$t),yt+=dt.length,yt<Rt.length&&(Rt[yt]===`
23
+ `||Rt[yt]==="\r")&&(yt++,Rt[yt-1]==="\r"&&Rt[yt]===`
24
+ `&&yt++)}),(X===0||X>=1e5)&&(X=st),tt===0&&(tt=j||0)}let L=-j/2;a>0&&a>j&&(I==="top"?L=-a/2:I==="middle"||I==="center"?L=-j/2:I==="bottom"&&(L=a/2-j)),L+=F;let R=null,D=0;if(o.pathId&&this.artboard){const st=this.artboard.objects.find(yt=>yt.id===o.pathId);if(st&&st.type==="Shape"&&((Dt=st.geometry)==null?void 0:Dt.type)==="Path"){const yt=this.objectStates.get(st.id),Rt=yt!=null&&yt.geometry?this.deepMerge(st.geometry,yt.geometry):st.geometry,_t=(yt==null?void 0:yt.scale_x)!==void 0?(st.width||0)*yt.scale_x:st.width||0,dt=(yt==null?void 0:yt.scale_y)!==void 0?(st.height||0)*yt.scale_y:st.height||0;R={geo:Rt,obj:st,w:_t,h:dt},D=this.getPerimeter(Rt,_t,dt)}}const q=(st,yt)=>{var _t,dt;if(T===0&&(!o.enableSegments||!((_t=o.segments)!=null&&_t.length)))return t.measureText(st).width;let Rt=0;for(let $t=0;$t<st.length;$t++){const Vt=yt+$t;let Bt=0;if(o.enableSegments===!0&&((dt=o.segments)==null?void 0:dt.length)>0){let Ft=0,Ut=null;for(const re of o.segments){if(Vt<Ft+(re.text||"").length){Ut=re;break}Ft+=(re.text||"").length}if(Ut){t.save();let re=Ut.fontFamily||o.fontFamily||"Inter";const be=this.mapFontWeight((Ut.fontWeight||o.fontWeight||"400").toString()),ve=Ut.fontStyle||v,Zt=Ut.fontSize||y;t.font=`${ve} ${be} ${Zt}px "${re}", sans-serif`,Bt=t.measureText(st[$t]).width,t.restore()}else Bt=t.measureText(st[$t]).width}else Bt=t.measureText(st[$t]).width;Rt+=Bt+T}return Rt-(st.length>0?T:0)},ot=(st,yt,Rt,_t,dt)=>{var be,ve;const Vt=(dt===0||c[dt-1]===`
25
+ `||c[dt-1]==="\r")&&o.paragraphIndent?o.paragraphIndent:0,Bt=(!r||f)&&(i.behaviors||[]).some(Zt=>Zt.enabled&&(Zt.type.toString().includes("Text")||["Typewriter","Scramble","Wave","Bounce","GlitchText","Reveal3D","RevealSlide","RevealBlur"].includes(Zt.type))),Ft=!o.pathId&&!Bt&&(o.enableSegments!==!0||!o.segments||o.segments.length===0),Ut=o.baselineShift||0,re=Rt+Ut;if(Ft)t.font=M,_t?t.strokeText(st,yt+Vt,re):t.fillText(st,yt+Vt,re);else{const Zt=q(st,dt);let Ce=yt+Vt;k==="center"?Ce-=Zt/2:k==="right"&&(Ce-=Zt);const _e=dt+st.length>=c.length||c[dt+st.length]===`
26
+ `||c[dt+st.length]==="\r";let Pe=0,we=0;const Ee=o.justifyMinWordSpacing,Ae=o.justifyMaxWordSpacing;if(k==="justify"&&!_e&&Zt>0&&!o.pathId){const ut=W?Zt:Y-z*2+0,at=Math.max(0,ut-Zt);for(let B=0;B<st.length;B++)st[B]===" "&&we++;if(we>0){const B=t.measureText(" ").width;let et=Ee||B*.5,Q=Ae||B*2.5;Pe=Math.max(0,Math.min(at/we,Q-et))}}let oe=o.pathOffset||0;o.pathId&&D>0&&R&&(k==="center"?oe+=D/2-Zt/2:k==="right"&&(oe+=D-Zt));let se=Ce;const ft=r&&!f?[]:((be=i.behaviors)==null?void 0:be.filter(ut=>[H.Typewriter,H.Scramble,H.Wave,H.Bounce,H.GlitchText,H.TextTrail,H.Reveal3D,H.RevealSlide,H.RevealBlur,H.TextLiquid,H.TextVortex,H.TextExplosion,H.TextRain,H.TextGravity,H.TextElastic,H.TextMatrix,H.TextNeon,H.TextGlitch3D,H.TextDissolve,H.TextOrganic,H.TextBreathe,H.TextFloral,H.TextSmoke,H.TextVariable,H.TextMagnet,H.TextSpin,H.TextZing,H.TextPerspective,H.TextMirror].includes(ut.type)&&ut.enabled))||[];for(let ut=0;ut<st.length;ut++){let at=st[ut];const B=dt+ut;let et=0,Q=0,Pt=1,Ot=1,kt=0,At=1,Mt=at;ft.forEach(pt=>{const ct=pt.settings||{},Ct=ct.strength||1,rt=Date.now();if(pt.type===H.Typewriter)this.currentTime*(ct.speed||1)-B*(ct.stagger||.05)<0&&(At=0);else if(pt.type===H.Scramble)Math.max(0,Math.min(1,this.currentTime/(ct.duration||1.5))-B*.02)<1&&Math.random()<.3&&(Mt="$%#@!*&"[Math.floor(Math.random()*7)]);else if(pt.type===H.Wave)Q+=Math.sin(this.currentTime*5*(ct.speed||1)+B*(ct.frequency||1))*(ct.amplitude||20)*Ct;else if(pt.type===H.Bounce){const V=Math.max(0,this.currentTime%2-B*(ct.stagger||.1));V<1&&(Q-=Math.abs(Math.sin(V*Math.PI))*(ct.height||50)*Ct)}else if(pt.type===H.TextTrail){const V=this.pointerHistory[Math.max(0,this.pointerHistory.length-1-B*(ct.delay||5))];V&&(et+=(V.x-(s.x+se))*Ct*.2,Q+=(V.y-(s.y+Rt+Q))*Ct*.2)}else if(pt.type===H.Reveal3D){const V=Math.max(0,Math.min(1,this.currentTime*(ct.speed||1)-B*(ct.stagger||.1)));Pt*=V,Ot*=V,At=V}else if(pt.type===H.RevealSlide){const V=Math.max(0,Math.min(1,this.currentTime*1.5-B*.05)),it=(1-V)*(ct.distance||40)*Ct,nt=ct.direction||"up";nt==="up"?Q-=it:nt==="down"?Q+=it:nt==="left"?et-=it:nt==="right"&&(et+=it),At=V}else if(pt.type===H.RevealBlur){const V=Math.max(0,Math.min(1,this.currentTime*1.2-B*.1));At=V,et+=(1-V)*5}else if(pt.type===H.TextLiquid){const V=Math.max(0,Math.sin(rt*.001*(ct.speed||1)+B*.5));Q+=V*(ct.amplitude||10)*Ct,Ot*=1+V*.2}else if(pt.type===H.TextVortex){const V=rt*.002*(ct.speed||1)+B*.2,it=(1-(Math.sin(rt*.001)*.5+.5))*(ct.radius||50);et+=Math.cos(V)*it*Ct,Q+=Math.sin(V)*it*Ct}else if(pt.type===H.TextExplosion){const V=ct.force||1,it=this.currentTime%2;if(it<1){const nt=(B/st.length-.5)*Math.PI*2,St=it*100*V;et+=Math.cos(nt)*St*Ct,Q+=Math.sin(nt)*St*Ct,At=1-it}}else if(pt.type===H.TextRain){const V=ct.speed||1,it=ct.height||100,nt=(rt*.001*V+B*.1)%1;Q-=(1-nt)*it*Ct,At=nt>.1?1:nt*10}else if(pt.type===H.TextGravity){const V=ct.gravity||9.8,it=this.currentTime%3/3,nt=.5*V*Math.pow(it*10,2);nt<100?Q+=nt*Ct:Q+=100*Ct}else if(pt.type===H.TextMatrix){const V=ct.speed||1;if(Math.random()<.1*V){const nt="0123456789ABCDEF!@#$%^&*";Mt=nt[Math.floor(Math.random()*nt.length)]}At=.3+(Math.sin(rt*.01*V+B)+1)/2*.7}else if(pt.type===H.TextNeon){const V=Math.random()>.95?.5:1;At=(.7+(Math.sin(rt*.005)+1)/2*.3)*V}else if(pt.type===H.TextDissolve)Math.sin(B*1.5+rt*.002*(ct.speed||1))>.5&&(At=0);else if(pt.type===H.TextOrganic){const V=ct.speed||1,it=ct.amplitude||10;et+=Math.sin(rt*.002*V+B)*it*Ct,Q+=Math.cos(rt*.0015*V+B*.7)*it*Ct}else if(pt.type===H.TextBreathe){const it=1+(Math.sin(rt*.003+B*.2)+1)/2*.2*Ct;Pt*=it,Ot*=it}else if(pt.type===H.TextSpin){const V=ct.speed||1;kt+=rt*.01*V+B}else if(pt.type===H.TextMagnet){const V=this.pointerHistory[this.pointerHistory.length-1];if(V){const it=V.x-(s.x+se),nt=V.y-(s.y+Rt);kt=Math.atan2(nt,it)}}else if(pt.type===H.TextPerspective){const V=st.length/2,it=(B-V)/V,nt=1-Math.abs(it)*.3*Ct;Pt*=nt,Ot*=nt,et+=it*20*Ct}else if(pt.type===H.TextMirror)At*=.8;else if(pt.type===H.TextFloral){const V=ct.speed||1,it=ct.stagger||.1,nt=(rt*.001*V+B*it)%2;nt<1&&(Pt*=nt,Ot*=nt,kt+=nt*Math.PI)}else if(pt.type===H.TextSmoke){const V=ct.speed||1,it=ct.height||50,nt=(rt*5e-4*V+B*.2)%1;Q-=nt*it*Ct,et+=Math.sin(rt*.002+B)*5*Ct,At=1-nt}else if(pt.type===H.TextVariable){const V=ct.speed||1,it=ct.intensity||1.5,nt=(Math.sin(rt*.004*V+B*.3)+1)/2;Pt*=1+nt*(it-1)*Ct}else if(pt.type===H.TextZing){const V=ct.speed||2,it=ct.distance||100,nt=(rt*.002*V+B*.05)%1;et+=(1-nt)*it*Ct,At=nt}else if(pt.type===H.TextElastic){const V=ct.stiffness||.2,it=ct.damping||.1,nt=Math.sin(rt*.01)*Math.exp(-rt*.001*it);Ot*=1+nt*V*Ct}else if(pt.type===H.TextGlitch3D){const V=ct.intensity||5;Math.random()<.2&&(et+=(Math.random()-.5)*V,Q+=(Math.random()-.5)*V,At=.8)}else if(pt.type===H.GlitchText){const V=ct.intensity||5;Math.random()<.1&&(et+=(Math.random()-.5)*V,Q+=(Math.random()-.5)*V,Math.random()<.05&&(At=.5))}});let $=null,Yt=o.textDecoration||"none",jt=y;if(o.enableSegments===!0&&((ve=o.segments)==null?void 0:ve.length)>0){let pt=0,ct=null;for(const Ct of o.segments){if(B<pt+(Ct.text||"").length){ct=Ct;break}pt+=(Ct.text||"").length}if(ct){let Ct=ct.fontFamily||o.fontFamily||"Inter";S.forEach(it=>{const nt=new RegExp(`[\\s-]${it}$`,"i");nt.test(Ct)&&(Ct=Ct.replace(nt,"").trim())});const rt=this.mapFontWeight((ct.fontWeight||o.fontWeight||"400").toString()),V=ct.fontStyle||v;jt=ct.fontSize||y,t.font=`${V} ${rt} ${jt}px "${Ct}", sans-serif`,ct.fill&&($=ct.fill),ct.textDecoration&&(Yt=ct.textDecoration),jt<J&&(Q+=(J-jt)*.85)}}else t.font=M;const ie=t.globalAlpha;t.globalAlpha*=At,t.save();const te=t.measureText(Mt).width;if(R&&D>0){const pt=se-Ce+te/2,Ct=(oe+pt)/D,rt=this.getPointOnPath(R.geo,R.w,R.h,Math.abs(Ct%1)),V=rt.angle,it=Rt+Q+(o.pathOffsetY||0),nt=o.pathSide==="right"?-1:1,St=Math.cos(V+Math.PI/2)*it*nt,Gt=Math.sin(V+Math.PI/2)*it*nt;t.translate(rt.x+St+et,rt.y+Gt),t.rotate(V+kt+(nt===-1?Math.PI:0))}else t.translate(se+et+te/2,Rt+Q),kt!==0&&t.rotate(kt);if(t.scale(Pt,Ot),$&&!r&&!f){const pt=this.createCanvasFill(t,$,X,tt);t.fillStyle=pt||$.color||"#000000"}else if(!r&&!f){const pt=this.createCanvasFill(t,e.fill,X,tt);t.fillStyle=pt||e.fill.color||"#000000"}if(At>0)if(r||f){const pt=f?"#000000":this.createCanvasFill(t,e.fill,X,tt);t.fillStyle=pt||e.fill.color||"#ffffff",t.fillText(Mt,-te/2,0)}else _t?t.strokeText(Mt,-te/2,0):t.fillText(Mt,-te/2,0);Yt!=="none"&&!r&&this.drawTextDecoration(t,Yt,0,0,te,jt),t.restore(),t.globalAlpha=ie,k==="justify"&&Pe>0&&Mt===" "&&!_e?se+=te+T+Pe:se+=te+T}}};if(r){let st=0,yt=L;(N||[]).forEach(Rt=>{const _t=Rt.text||"",dt=c.indexOf(_t,st);dt!==-1&&(st=dt);let $t=-X/2;k==="center"?$t=0:k==="right"&&($t=X/2),ot(_t,$t,yt,!1,st),st+=_t.length,yt+=A})}else if(f){let st=0,yt=L;(N||[]).forEach(Rt=>{const _t=Rt.text||"";let dt=-X/2;k==="center"?dt=0:k==="right"&&(dt=X/2),ot(_t,dt,yt,!1,st),st+=_t.length,st<c.length&&(c[st]===`
27
+ `||c[st]==="\r")&&(st++,c[st-1]==="\r"&&c[st]===`
28
+ `&&st++),yt+=A})}else{if(e.fill){const yt=t.globalAlpha,Rt=this.createCanvasFill(t,e.fill,X,tt);t.fillStyle=Rt||e.fill.color||"#000000",t.globalAlpha=yt*this.normalizeOpacity(e.fill.opacity??100);const _t=G.fullText||(o.enableSegments?(o.segments||[]).map(Vt=>{let Bt=Vt.text||"";const Ft=Vt.textCase||o.textCase||"none";return Ft==="uppercase"?Bt.toUpperCase():Ft==="lowercase"?Bt.toLowerCase():Ft==="capitalize"?Bt.replace(/\b\w/g,Ut=>Ut.toUpperCase()):Bt}).join(""):c);let dt=0,$t=L;(N||[]).forEach(Vt=>{const Bt=Vt.text||"";let Ft=-X/2;k==="center"?Ft=0:k==="right"&&(Ft=X/2),ot(Bt,Ft,$t,!1,dt),dt+=Bt.length,$t+=A,dt<_t.length&&(_t[dt]===`
29
29
  `||_t[dt]==="\r")&&(_>0&&($t+=_),dt++,_t[dt-1]==="\r"&&_t[dt]===`
30
- `&&dt++)}),t.globalAlpha=mt}const et=o.paragraphRule;if(et&&(((he=et.top)==null?void 0:he.width)>0||((pe=et.bottom)==null?void 0:pe.width)>0)){let mt=0;(N||[]).forEach((Ft,_t)=>{var Vt,Bt;const $t=mt===0||mt<c.length&&(c[mt]===`
31
- `||c[mt]==="\r");if($t&&_t>0&&mt++,$t){if(((Vt=et.top)==null?void 0:Vt.width)>0){const Rt=L+_t*A-et.top.offset;t.strokeStyle=et.top.color||"#000000",t.lineWidth=et.top.width,t.beginPath();const Ut=-n/2+A*.2;t.moveTo(Ut,Rt),t.lineTo(n/2-A*.2,Rt),t.stroke()}if(((Bt=et.bottom)==null?void 0:Bt.width)>0){const Rt=L+(_t+1)*A-et.bottom.offset;t.strokeStyle=et.bottom.color||"#000000",t.lineWidth=et.bottom.width,t.beginPath();const Ut=-n/2+A*.2;t.moveTo(Ut,Rt),t.lineTo(n/2-A*.2,Rt),t.stroke()}}mt+=(Ft.text||"").length})}if(e.stroke&&e.stroke.width>0){const mt=t.globalAlpha;e.fill&&e.fill.type!=="None"&&e.fill.isEnabled!==!1&&e.fill.opacity!==0&&e.fill.color!=="transparent"&&e.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.strokeStyle=e.stroke.color;let _t=1;if(this.rootTransform){const Vt=t.getTransform(),Bt=Math.sqrt(Vt.a*Vt.a+Vt.b*Vt.b)||1,Rt=this.rootTransform,Ut=Math.sqrt(Rt.a*Rt.a+Rt.b*Rt.b)||1;_t=Bt/Ut}else _t=(Math.abs(h)+Math.abs(l))/2||1;t.lineWidth=(e.stroke.width||1)/(_t||1),t.globalAlpha=mt*this.normalizeOpacity(e.stroke.opacity??100);let dt=0,$t=L;(N||[]).forEach(Vt=>{let Bt=-X/2;k==="center"?Bt=0:k==="right"&&(Bt=X/2),ot(Vt.text,Bt,$t,!0,dt),dt+=(Vt.text||"").length,$t+=A,dt<c.length&&(c[dt]===`
30
+ `&&dt++)}),t.globalAlpha=yt}const st=o.paragraphRule;if(st&&(((ae=st.top)==null?void 0:ae.width)>0||((pe=st.bottom)==null?void 0:pe.width)>0)){let yt=0;(N||[]).forEach((Rt,_t)=>{var Vt,Bt;const $t=yt===0||yt<c.length&&(c[yt]===`
31
+ `||c[yt]==="\r");if($t&&_t>0&&yt++,$t){if(((Vt=st.top)==null?void 0:Vt.width)>0){const Ft=L+_t*A-st.top.offset;t.strokeStyle=st.top.color||"#000000",t.lineWidth=st.top.width,t.beginPath();const Ut=-n/2+A*.2;t.moveTo(Ut,Ft),t.lineTo(n/2-A*.2,Ft),t.stroke()}if(((Bt=st.bottom)==null?void 0:Bt.width)>0){const Ft=L+(_t+1)*A-st.bottom.offset;t.strokeStyle=st.bottom.color||"#000000",t.lineWidth=st.bottom.width,t.beginPath();const Ut=-n/2+A*.2;t.moveTo(Ut,Ft),t.lineTo(n/2-A*.2,Ft),t.stroke()}}yt+=(Rt.text||"").length})}if(e.stroke&&e.stroke.width>0){const yt=t.globalAlpha;e.fill&&e.fill.type!=="None"&&e.fill.isEnabled!==!1&&e.fill.opacity!==0&&e.fill.color!=="transparent"&&e.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.strokeStyle=e.stroke.color;let _t=1;if(this.rootTransform){const Vt=t.getTransform(),Bt=Math.sqrt(Vt.a*Vt.a+Vt.b*Vt.b)||1,Ft=this.rootTransform,Ut=Math.sqrt(Ft.a*Ft.a+Ft.b*Ft.b)||1;_t=Bt/Ut}else _t=(Math.abs(h)+Math.abs(l))/2||1;t.lineWidth=(e.stroke.width||1)/(_t||1),t.globalAlpha=yt*this.normalizeOpacity(e.stroke.opacity??100);let dt=0,$t=L;(N||[]).forEach(Vt=>{let Bt=-X/2;k==="center"?Bt=0:k==="right"&&(Bt=X/2),ot(Vt.text,Bt,$t,!0,dt),dt+=(Vt.text||"").length,$t+=A,dt<c.length&&(c[dt]===`
32
32
  `||c[dt]==="\r")&&(_>0&&($t+=_),dt++,c[dt-1]==="\r"&&c[dt]===`
33
- `&&dt++)}),t.globalAlpha=mt}}}applyStrokeAlignment(t,i,o,e,s,n,a=1,r=1){if(!i.stroke||i.stroke.width<=0||i.stroke.isEnabled===!1)return;const f=i.stroke;let h=1;if(this.rootTransform){const S=t.getTransform(),C=Math.sqrt(S.a*S.a+S.b*S.b)||1,w=this.rootTransform,M=Math.sqrt(w.a*w.a+w.b*w.b)||1;h=C/M}else h=(Math.abs(a)+Math.abs(r))/2||1;const l=(f.width||1)/(h||1),p=(f.alignment||"center").toLowerCase();if(t.save(),i.fill&&i.fill.type!=="None"&&i.fill.isEnabled!==!1&&i.fill.opacity!==0&&i.fill.color!=="transparent"&&i.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),f.fill){const S=this.createCanvasFill(t,f.fill,e,s);S?t.strokeStyle=S:t.strokeStyle=f.color||"#000000"}else t.strokeStyle=f.color||"#000000";const d=t.globalAlpha;t.globalAlpha=d*this.normalizeOpacity(f.opacity??100),t.lineWidth=l,t.lineCap=f.lineCap||"round",t.lineJoin=f.lineJoin||"round",f.miterLimit!==void 0&&(t.miterLimit=f.miterLimit);const u=f.trimStart??0,v=f.trimEnd??1,b=f.trimOffset??0,m=f.dashOffset??0,y=f.dashArray||[];if(u!==0||v!==1||b!==0){const S=this.getPerimeter(o,e,s);if(S>0){const C=Math.max(0,Math.min(1,u)),w=Math.max(0,Math.min(1,v));if(C<w){const M=S*(w-C),I=S-M,k=-(S*(C+b%1));t.setLineDash([M,I]),t.lineDashOffset=k+m*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+m*S}}}else y.length>0&&(t.setLineDash(y),t.lineDashOffset=m);(o==null?void 0:o.type)==="Line"||e===0||s===0?(this.applyPath(t,o,e,s,n),t.stroke()):p==="inside"?(t.lineWidth=l*2,t.save(),this.applyPath(t,o,e,s,n),t.clip(),t.stroke(),t.restore()):p==="outside"?(t.lineWidth=l*2,t.save(),t.beginPath(),t.rect(-99999,-99999,199998,199998),this._tracePath(t,o,e,s,n),t.clip("evenodd"),this.applyPath(t,o,e,s,n),t.stroke(),t.restore()):(t.lineWidth=l,this.applyPath(t,o,e,s,n),t.stroke()),t.restore()}getPerimeter(t,i,o){switch(this.ensurePathPoints(t),t==null?void 0:t.type){case"Rectangle":return(i+o)*2;case"Ellipse":{const e=Math.abs(i)/2,s=Math.abs(o)/2,n=Math.abs(t.sweepAngle??360),a=t.ratio||0,r=Math.PI*(3*(e+s)-Math.sqrt((3*e+s)*(e+3*s)));if(n>=360&&a<=0)return r;let f=n/360*r;if(a>0){const h=Math.PI*(3*(e*a+s*a)-Math.sqrt((3*e*a+s*a)*(e*a+3*s*a)));f+=n/360*h,n<360&&(f+=2*Math.sqrt((e-e*a)**2+(s-s*a)**2))}else n<360&&(f+=2*Math.max(e,s));return isNaN(f)?0:f}case"Line":return t.length||Math.sqrt(i*i+o*o);case"Triangle":return i+Math.sqrt((i/2)**2+o**2)*2;case"Polygon":{const e=t.sides||3,s=t.radius||Math.min(i,o)/2;return 2*e*s*Math.sin(Math.PI/e)}case"Star":{const e=t.points||5,s=t.outer_radius||Math.min(i,o)/2,n=t.inner_radius||s/2,a=Math.PI/e;return Math.sqrt(s*s+n*n-2*s*n*Math.cos(a))*e*2}case"Path":{const e=t.points||[];if(e.length<2)return t.length||0;let s=0,n=e[0].x,a=e[0].y;for(let r=1;r<e.length;r++){const f=e[r];if(f.moveTo){n=f.x,a=f.y;continue}const h=n,l=a,p=e[r-1].out_x,c=e[r-1].out_y;if(p!==void 0||f.in_x!==void 0?s+=this.getBezierLength(h,l,p??h,c??l,f.in_x??f.x,f.in_y??f.y,f.x,f.y):s+=Math.sqrt((f.x-h)**2+(f.y-l)**2),n=f.x,a=f.y,f.closePath||r===e.length-1&&(t.is_closed||t.isClosed)){const d=n,u=a,v=[...e.slice(0,r+1)].reverse().find(M=>M.moveTo)||e[0],b=v.x,m=v.y,y=e[r].out_x,S=e[r].out_y,C=v.in_x,w=v.in_y;y!==void 0||C!==void 0?s+=this.getBezierLength(d,u,y??d,S??u,C??b,w??m,b,m):s+=Math.sqrt((b-d)**2+(m-u)**2)}}return s}default:return(i+o)*2}}getBezierLength(t,i,o,e,s,n,a,r,f=10){let h=0,l=t,p=i;for(let c=1;c<=f;c++){const d=c/f,u=1-d,v=d*d,b=u*u,m=b*u,y=v*d,S=m*t+3*b*d*o+3*u*v*s+y*a,C=m*i+3*b*d*e+3*u*v*n+y*r,w=S-l,M=C-p;h+=Math.sqrt(w*w+M*M),l=S,p=C}return h}getBezierTAtLength(t,i,o,e,s,n,a,r,f,h=20){if(t<=0)return 0;let l=0,p=i,c=o;for(let d=1;d<=h;d++){const u=d/h,v=1-u,b=u*u,m=v*v,y=m*v,S=b*u,C=y*i+3*m*u*e+3*v*b*n+S*r,w=y*o+3*m*u*s+3*v*b*a+S*f,M=C-p,I=w-c,k=Math.sqrt(M*M+I*I);if(l+k>=t){const T=t-l,O=k===0?0:T/k;return(d-1+O)/h}l+=k,p=C,c=w}return 1}getPointOnPath(t,i,o,e){if(this.ensurePathPoints(t),(t==null?void 0:t.type)==="Path"){const s=t.points||[];if(s.length<2)return{x:0,y:0,angle:0};let n=1/0,a=-1/0,r=1/0,f=-1/0;s.forEach(m=>{typeof m.x=="number"&&typeof m.y=="number"&&(n=Math.min(n,m.x),a=Math.max(a,m.x),r=Math.min(r,m.y),f=Math.max(f,m.y),m.out_x!==void 0&&(n=Math.min(n,m.out_x),a=Math.max(a,m.out_x)),m.out_y!==void 0&&(r=Math.min(r,m.out_y),f=Math.max(f,m.out_y)),m.in_x!==void 0&&(n=Math.min(n,m.in_x),a=Math.max(a,m.in_x)),m.in_y!==void 0&&(r=Math.min(r,m.in_y),f=Math.max(f,m.in_y)))});const h=(n+a)/2,l=(r+f)/2,c=this.getPerimeter(t,i,o)*e;let d=0;const u=[];let v=s[0],b=s[0];for(let m=1;m<s.length;m++){const y=s[m];if(y.moveTo){v=y,b=y;continue}u.push({p0:v,p1:y}),(y.closePath||m===s.length-1&&(t.is_closed||t.isClosed))&&u.push({p0:y,p1:b}),v=y}for(const m of u){const y=m.p0,S=m.p1;let C=0;const w=y.out_x!==void 0||S.in_x!==void 0;if(w?C=this.getBezierLength(y.x,y.y,y.out_x??y.x,y.out_y??y.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y):C=Math.sqrt((S.x-y.x)**2+(S.y-y.y)**2),d+C>=c||m===u[u.length-1]){let M=0;if(w)return M=this.getBezierTAtLength(c-d,y.x,y.y,y.out_x??y.x,y.out_y??y.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y,20),this.getBezierPointAndAngle(M,y,S,h,l);{M=C===0?0:(c-d)/C;const I=y.x+(S.x-y.x)*M-h,k=y.y+(S.y-y.y)*M-l,T=Math.atan2(S.y-y.y,S.x-y.x);return{x:I,y:k,angle:T}}}d+=C}}else if(t.type==="Ellipse"){const s=Math.abs(i)/2,n=Math.abs(o)/2,a=t.sweepAngle??360,f=((t.startAngle??0)+a*e)*Math.PI/180,h=s*Math.cos(f),l=n*Math.sin(f),p=-s*Math.sin(f),c=n*Math.cos(f),d=Math.atan2(c,p);return{x:h,y:l,angle:d}}else if((t==null?void 0:t.type)==="Rectangle"){const s=Math.abs(i),n=Math.abs(o),r=(s+n)*2*e;let f=0,h=0,l=0;return r<s?(f=-s/2+r,h=-n/2,l=0):r<s+n?(f=s/2,h=-n/2+(r-s),l=Math.PI/2):r<2*s+n?(f=s/2-(r-(s+n)),h=n/2,l=Math.PI):(f=-s/2,h=n/2-(r-(2*s+n)),l=-Math.PI/2),{x:f,y:h,angle:l}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(t,i,o,e,s){const n=i.x,a=i.y,r=i.out_x??i.x,f=i.out_y??i.y,h=o.in_x??o.x,l=o.in_y??o.y,p=o.x,c=o.y,d=1-t,u=t*t,v=d*d,b=v*d,m=u*t,y=b*n+3*v*t*r+3*d*u*h+m*p-e,S=b*a+3*v*t*f+3*d*u*l+m*c-s,C=3*v*(r-n)+6*d*t*(h-r)+3*u*(p-h),w=3*v*(f-a)+6*d*t*(l-f)+3*u*(c-l),M=Math.atan2(w,C);return{x:y,y:S,angle:M}}applyAbsoluteTransform(t,i,o){if(!o.get(i))return;const s=[];let n=i;for(;n;){s.unshift(n);const a=o.get(n);n=a==null?void 0:a.parentId}s.forEach(a=>{this.applyObjectTransform(t,a)})}applyObjectTransform(t,i){var d,u,v;const o=this.objectStates.get(i);if(!o)return;t.translate(o.x,o.y),t.rotate((o.rotation??0)*Math.PI/180);const e=o.skew_x||0,s=o.skew_y||0;if(e!==0||s!==0){const b=Math.tan(e*Math.PI/180),m=Math.tan(s*Math.PI/180);t.transform(1+b*m,m,b,1,0,0)}const n=o.rotate_x!==void 0?o.rotate_x:((d=o.transform)==null?void 0:d.rotate_x)??0,a=o.rotate_y!==void 0?o.rotate_y:((u=o.transform)==null?void 0:u.rotate_y)??0,f=1+(o.translate_z!==void 0?o.translate_z:((v=o.transform)==null?void 0:v.translate_z)??0)/1e3,h=(o.flip_x===!0?-1:1)*Math.cos(a*Math.PI/180)*f,l=(o.flip_y===!0?-1:1)*Math.cos(n*Math.PI/180)*f,p=(o.scale_x??1)*h,c=(o.scale_y??1)*l;t.scale(p,c)}applyArtEffectOverlay(t,i,o,e,s,n){var c,d,u,v,b;const a=this.objectStates.get(i.id),r=((c=a==null?void 0:a.style)==null?void 0:c.artEffect)||i.artEffect||((d=i.style)==null?void 0:d.artEffect);if(!r||!r.enabled)return;const f=r.type,h=r.intensity??.5,l=r.speed??1,p=r.scale??10;if(f==="acid_gradient"||f==="acid_rave"||f==="shimmer"||f==="glint_overlay"||f==="halftone"||f==="noise"||f==="scanlines"||f==="chromatic_aberration"||f==="pixelate"||f==="glitch"||f==="fold_overlay"||f==="crumple_overlay"){if(t.save(),this.applyPath(t,o,e,s,n),t.clip(),f==="shimmer"){const y=this.currentTime*l%2/2,S=t.createLinearGradient(-e,-s,e,s);S.addColorStop(Math.max(0,y-.2),"rgba(255,255,255,0)"),S.addColorStop(y,`rgba(255,255,255,${h*.8})`),S.addColorStop(Math.min(1,y+.2),"rgba(255,255,255,0)"),t.fillStyle=S,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over"}else if(f==="glint_overlay"){let S=((this._lastPointerPos||{x:0}).x-(((u=i.transform)==null?void 0:u.x)??0)+300)/600;S=Math.max(-.2,Math.min(1.2,S));const C=t.createLinearGradient(-e,-s,e,s);C.addColorStop(Math.max(0,S-.15),"rgba(255,255,255,0)"),C.addColorStop(Math.max(0,Math.min(1,S)),`rgba(255,255,255,${h})`),C.addColorStop(Math.min(1,S+.15),"rgba(255,255,255,0)"),t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over"}else if(f==="fold_overlay"){const m=this._lastPointerPos||{x:0,y:0},y=m.x-(((v=i.transform)==null?void 0:v.x)??0),S=m.y-(((b=i.transform)==null?void 0:b.y)??0),C=t.createLinearGradient(y>0?-e/2:e/2,S>0?-s/2:s/2,y>0?e/2:-e/2,S>0?s/2:-s/2);C.addColorStop(0,`rgba(0,0,0,${h*.6})`),C.addColorStop(.4,"rgba(0,0,0,0)"),C.addColorStop(.5,`rgba(255,255,255,${h*.4})`),C.addColorStop(1,`rgba(0,0,0,${h*.2})`),t.fillStyle=C,t.globalCompositeOperation="overlay",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over",t.beginPath(),y>0&&S>0?(t.moveTo(e/2-40,s/2),t.lineTo(e/2,s/2-40),t.lineTo(e/2-40,s/2-40)):y<0&&S>0?(t.moveTo(-e/2+40,s/2),t.lineTo(-e/2,s/2-40),t.lineTo(-e/2+40,s/2-40)):y>0&&S<0?(t.moveTo(e/2-40,-s/2),t.lineTo(e/2,-s/2+40),t.lineTo(e/2-40,-s/2+40)):(t.moveTo(-e/2+40,-s/2),t.lineTo(-e/2,-s/2+40),t.lineTo(-e/2+40,-s/2+40)),t.closePath(),t.fillStyle="#ffffff",t.shadowColor="rgba(0,0,0,0.5)",t.shadowBlur=10,t.shadowOffsetX=y>0?-2:2,t.shadowOffsetY=S>0?-2:2,t.fill()}else if(f==="crumple_overlay"){const m=Math.floor(e/p),y=document.createElement("canvas");y.width=m,y.height=Math.floor(s/p);const S=y.getContext("2d"),C=S.createImageData(y.width,y.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(y,-e/2,-s/2,e,s)}else if(f==="acid_gradient"||f==="acid_rave"){const m=this.currentTime*l,y=r.color1,S=r.color2,C=t.createLinearGradient(-e/2,-s/2,e/2,s/2);if(y&&S){const w=m*60%360;C.addColorStop(0,this._shiftHue(y,w,h*.7)),C.addColorStop(1,this._shiftHue(S,(w+180)%360,h*.7))}else{const w=m*100%360,M=(w+180)%360;C.addColorStop(0,`hsla(${w}, 80%, 50%, ${h*.5})`),C.addColorStop(1,`hsla(${M}, 80%, 50%, ${h*.5})`)}t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s)}else if(f==="halftone"){const m=Math.max(2,p*(1-h*.8)),y=document.createElement("canvas");y.width=m,y.height=m;const S=y.getContext("2d");if(S){S.fillStyle="black",S.beginPath(),S.arc(m/2,m/2,m/2*h,0,Math.PI*2),S.fill();const C=t.createPattern(y,"repeat");C&&(t.globalAlpha=.3*h,t.fillStyle=C,t.fillRect(-e/2,-s/2,e,s))}}else if(f==="noise"){const m=Math.floor(e*s*h*.02);t.globalAlpha=.4*h;for(let y=0;y<m;y++){const S=Math.random()>.5?255:0;t.fillStyle=`rgba(${S}, ${S}, ${S}, ${.5+Math.random()*.5})`,t.fillRect(-e/2+Math.random()*e,-s/2+Math.random()*s,2,2)}}else if(f==="scanlines"){t.globalAlpha=.2*h,t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1;for(let m=-s/2;m<s/2;m+=4)t.beginPath(),t.moveTo(-e/2,m),t.lineTo(e/2,m),t.stroke()}else if(f==="chromatic_aberration"){const m=5*h;t.globalCompositeOperation="screen",t.globalAlpha=.5,t.fillStyle="cyan",t.fillRect(-e/2-m,-s/2,e,s),t.fillStyle="magenta",t.fillRect(-e/2+m,-s/2,e,s)}else if(f==="pixelate"){const m=Math.max(2,Math.round(p*(1-h*.5))),y=document.createElement("canvas"),S=Math.max(1,Math.ceil(e/m)),C=Math.max(1,Math.ceil(s/m));y.width=S,y.height=C;const w=y.getContext("2d");if(w){w.imageSmoothingEnabled=!1;const M=t.getTransform(),I=M.e-e/2,k=M.f-s/2;w.drawImage(t.canvas,I,k,e,s,0,0,S,C),t.imageSmoothingEnabled=!1,t.drawImage(y,0,0,S,C,-e/2,-s/2,e,s),t.imageSmoothingEnabled=!0}}else if(f==="glitch"){const m=this.currentTime*l,y=r.chaosAmount??.2,S=Math.max(3,Math.floor(8*h)),C=h*e*.15;t.globalCompositeOperation="screen",t.globalAlpha=h*.4;const w=C*.3;t.fillStyle="rgba(255, 0, 0, 0.4)",t.fillRect(-e/2+w,-s/2,e,s),t.fillStyle="rgba(0, 255, 255, 0.4)",t.fillRect(-e/2-w,-s/2,e,s),t.globalCompositeOperation="source-over",t.globalAlpha=1;const M=s/S;for(let I=0;I<S;I++){const k=Math.sin(I*127.1+m*311.7*l)*43758.5,T=k-Math.floor(k);if(T>1-y){const O=(T-(1-y))/y*C*(Math.random()>.5?1:-1),P=-s/2+I*M,_=t.getTransform(),E=_.e-e/2+O,A=_.f+P;t.save(),t.beginPath(),t.rect(-e/2,P,e,M),t.clip(),t.globalAlpha=.8,t.drawImage(t.canvas,E,A,e,M,-e/2+O,P,e,M),t.restore()}}}t.restore()}}_shiftHue(t,i,o){let e=0,s=0,n=0;if(t.startsWith("#")){const c=t.replace("#","");e=parseInt(c.substring(0,2),16)/255,s=parseInt(c.substring(2,4),16)/255,n=parseInt(c.substring(4,6),16)/255}const a=Math.max(e,s,n),r=Math.min(e,s,n);let f=0,h=0,l=(a+r)/2;if(a!==r){const c=a-r;switch(h=l>.5?c/(2-a-r):c/(a+r),a){case e:f=((s-n)/c+(s<n?6:0))/6;break;case s:f=((n-e)/c+2)/6;break;case n:f=((e-s)/c+4)/6;break}}return`hsla(${(((f*360+i)%360+360)%360).toFixed(0)}, ${(h*100).toFixed(0)}%, ${(l*100).toFixed(0)}%, ${o})`}applyBackgroundBlurGlass(t,i,o,e,s,n){const a=n.radius??10,r=n.color??"rgba(255,255,255,0.2)",f=n.opacity!==void 0?this.normalizeOpacity(n.opacity):.5,h=n.noise??0;t.save(),this.applyPath(t,i,o,e,s),t.clip();const l=t.getTransform(),p=t.canvas;try{const d=document.createElement("canvas");d.width=Math.max(1,Math.ceil(o)),d.height=Math.max(1,Math.ceil(e));const u=d.getContext("2d");if(u){u.save(),u.translate(o/2,e/2);const v=n.magnification||1;if(v!==1&&u.scale(v,v),typeof l.inverse=="function"){const y=l.inverse();u.transform(y.a,y.b,y.c,y.d,y.e,y.f)}else{const y=l.a*l.d-l.b*l.c;y!==0&&u.transform(l.d/y,-l.b/y,-l.c/y,l.a/y,(l.c*l.f-l.d*l.e)/y,(l.b*l.e-l.a*l.f)/y)}u.drawImage(p,0,0),u.restore(),u.filter=`blur(${a}px)`;const b=document.createElement("canvas");b.width=d.width,b.height=d.height;const m=b.getContext("2d");m.filter=`blur(${a}px)`,m.drawImage(d,0,0),t.globalCompositeOperation="source-over",t.globalAlpha=1,t.drawImage(b,-o/2,-e/2,o,e)}}catch{}t.globalCompositeOperation="source-over",t.globalAlpha=f,t.fillStyle=r,t.fillRect(-o/2,-e/2,o,e),t.globalAlpha=1,t.globalCompositeOperation="source-atop";const c=t.createLinearGradient(-o/2,-e/2,o/2,e/2);if(c.addColorStop(0,"rgba(255,255,255,0.12)"),c.addColorStop(.3,"rgba(255,255,255,0.04)"),c.addColorStop(.5,"rgba(255,255,255,0.0)"),c.addColorStop(1,"rgba(255,255,255,0.0)"),t.fillStyle=c,t.fillRect(-o/2,-e/2,o,e),h>0){if(t.globalAlpha=h/100,!this._noiseTileCanvas){const u=document.createElement("canvas");u.width=64,u.height=64;const v=u.getContext("2d"),b=v.createImageData(64,64),m=b.data;for(let y=0;y<m.length;y+=4){const S=Math.floor(Math.random()*255);m[y]=S,m[y+1]=S,m[y+2]=S,m[y+3]=18}v.putImageData(b,0,0),this._noiseTileCanvas=u}const d=t.createPattern(this._noiseTileCanvas,"repeat");d&&(t.fillStyle=d,t.fillRect(-o/2,-e/2,o,e))}t.restore(),t.save(),t.globalAlpha=1,t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1.5,this.applyPath(t,i,o,e,s),t.stroke(),t.restore()}applyPath(t,i,o,e,s){i!=null&&i.data&&(i.type==="Path"||i.type==="Subtract"||i.type==="Union"||i.type==="Intersect"||i.type==="Exclude"||i.type),t.beginPath(),this._tracePath(t,i,o,e,s)}_tracePath(t,i,o,e,s){if(i){if(this.ensurePathPoints(i),(i==null?void 0:i.type)==="Rectangle"||i.type==="Image"){const n=s!==void 0?s:i.corner_radius??0;this.drawRoundRect(t,-o/2,-e/2,o,e,n)}else if(i.type==="Line")t.moveTo(-o/2,0),t.lineTo(o/2,0);else if(i.type==="Ellipse"){const{startAngle:n=0,sweepAngle:a=360,ratio:r=0}=i,f=o/2,h=e/2,l=n*Math.PI/180,p=a*Math.PI/180,c=l+p;a>=360&&r<=0?t.ellipse(0,0,f,h,0,0,Math.PI*2):(t.ellipse(0,0,f,h,0,l,c,!1),r>0?t.ellipse(0,0,f*r,h*r,0,c,l,!0):t.lineTo(0,0),t.closePath())}else if(i.type==="Triangle")t.moveTo(0,-e/2),t.lineTo(o/2,e/2),t.lineTo(-o/2,e/2),t.closePath();else if(i.type==="Polygon"){const n=i.sides||3,a=i.radius||Math.min(o,e)/2;for(let r=0;r<n;r++){const f=r*2*Math.PI/n-Math.PI/2,h=a*Math.cos(f),l=a*Math.sin(f);r===0?t.moveTo(h,l):t.lineTo(h,l)}t.closePath()}else if(i.type==="Star"){const n=i.points||5,a=i.outer_radius||Math.min(o,e)/2;let r=i.inner_radius;r==null?r=a*.382:r<=1&&(r=a*r);for(let f=0;f<n*2;f++){const h=f*Math.PI/n-Math.PI/2,l=f%2===0?a:r,p=l*Math.cos(h),c=l*Math.sin(h);f===0?t.moveTo(p,c):t.lineTo(p,c)}t.closePath()}else if(((i==null?void 0:i.type)==="Path"||i.type==="Subtract"||i.type==="Union"||i.type==="Intersect"||i.type==="Exclude"||i.type==="BooleanOperation")&&i.points){this.frameCount%300===0&&this.log("[Engine] Tracing Path:",i.points.length,"points");let n=1/0,a=-1/0,r=1/0,f=-1/0;if(i.points.forEach(p=>{typeof p.x=="number"&&typeof p.y=="number"&&(n=Math.min(n,p.x),a=Math.max(a,p.x),r=Math.min(r,p.y),f=Math.max(f,p.y),p.out_x!==void 0&&(n=Math.min(n,p.out_x),a=Math.max(a,p.out_x)),p.out_y!==void 0&&(r=Math.min(r,p.out_y),f=Math.max(f,p.out_y)),p.in_x!==void 0&&(n=Math.min(n,p.in_x),a=Math.max(a,p.in_x)),p.in_y!==void 0&&(r=Math.min(r,p.in_y),f=Math.max(f,p.in_y)))}),n===1/0)return;const h=(n+a)/2,l=(r+f)/2;if(isNaN(h)||isNaN(l)){this.warn("[Engine] Invalid path center:",h,l);return}i.points.forEach((p,c)=>{if(c===0||p.moveTo)t.moveTo(p.x-h,p.y-l);else{const d=i.points[c-1];if(!d)return;const u=(d.out_x??d.x)-h,v=(d.out_y??d.y)-l,b=(p.in_x??p.x)-h,m=(p.in_y??p.y)-l;isNaN(u)||isNaN(b)||isNaN(p.x)?t.lineTo(p.x-h,p.y-l):t.bezierCurveTo(u,v,b,m,p.x-h,p.y-l)}if(p.closePath||c===i.points.length-1&&(i.is_closed||i.isClosed)){const d=[...i.points.slice(0,c+1)].reverse().find(u=>u.moveTo)||i.points[0];d&&(p.out_x!==void 0||d.in_x!==void 0)&&t.bezierCurveTo((p.out_x??p.x)-h,(p.out_y??p.y)-l,(d.in_x??d.x)-h,(d.in_y??d.y)-l,d.x-h,d.y-l),t.closePath()}})}else if(i.points&&Array.isArray(i.points)){let n=1/0,a=-1/0,r=1/0,f=-1/0;i.points.forEach(p=>{n=Math.min(n,p.x),a=Math.max(a,p.x),r=Math.min(r,p.y),f=Math.max(f,p.y)});const h=(n+a)/2,l=(r+f)/2;i.points.forEach((p,c)=>{if(c===0)t.moveTo(p.x-h,p.y-l);else{const d=i.points[c-1];d.out_x!==void 0||p.in_x!==void 0?t.bezierCurveTo((d.out_x??d.x)-h,(d.out_y??d.y)-l,(p.in_x??p.x)-h,(p.in_y??p.y)-l,p.x-h,p.y-l):t.lineTo(p.x-h,p.y-l)}(p.closePath||c===i.points.length-1&&(i.is_closed||i.isClosed))&&t.closePath()})}}}renderInputBox(t,i){var L,F;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((L=i.geometry)==null?void 0:L.width)||250,n=((F=i.geometry)==null?void 0:F.height)||45,a=this.focusedId===i.id,r=this.lastHoveredObjectId===i.id,f=e.previewState||"default",h=f!=="default"?f:a?"focused":r?"hovered":"default",l=e.label||{visible:!0,text:"Label"},p=e.helperText||{visible:!1,text:"Helper text"},c=e.leftIcon||{visible:!1},d=e.rightIcon||{visible:!1},u=e.multiline===!0,v=e.corner_radius??8,b=e.corners||{tl:v,tr:v,bl:v,br:v},m=[b.tl,b.tr,b.br,b.bl];let y=e.backgroundColor||"rgba(31, 41, 55, 1)",S=e.borderColor||"rgba(55, 65, 81, 1)",C=e.borderWidth??1.5,w=e.color||"#ffffff",M=e.placeholderColor||"rgba(156, 163, 175, 1)",I=e.fontSize||14;const k=`${h}Style`,T=e[k];T?(T.backgroundColor!==void 0&&(y=T.backgroundColor),T.borderColor!==void 0&&(S=T.borderColor),T.borderWidth!==void 0&&(C=T.borderWidth),T.color!==void 0&&(w=T.color),T.placeholderColor!==void 0&&(M=T.placeholderColor),T.fontSize!==void 0&&(I=T.fontSize)):h==="focused"?(S=e.focusBorderColor||"rgba(59, 130, 246, 1)",C=Math.max(C,2)):h==="hovered"||h==="hover"?(S=e.hoverBorderColor||S,y=e.hoverBackgroundColor||y):h==="disabled"?(y=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",S=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):h==="error"&&(S="rgba(239, 68, 68, 1)",C=Math.max(C,2)),t.beginPath(),this.drawRoundRect(t,-s/2,-n/2,s,n,m);const O=this.createCanvasFill(t,y,s,n);if(O&&(t.fillStyle=O,t.fill()),C>0){const D=this.createCanvasFill(t,S,s,n);if(D&&(t.strokeStyle=D,t.lineWidth=C,t.stroke()),h==="focused"||h==="focus"){t.save(),t.beginPath();const q=m.map(ot=>ot+2);this.drawRoundRect(t,-s/2-2,-n/2-2,s+4,n+4,q),t.strokeStyle="rgba(59, 130, 246, 0.3)",t.lineWidth=2,t.stroke(),t.restore()}}const P=(D,q)=>{if(!D.visible||!D.svgPath)return;const ot=D.size||14,yt=D.offset??16,bt=D.color||"#ffffff",gt=q?-(s/2)+yt:s/2-yt,Et=D.svgPath;if(t.save(),t.translate(gt,0),!Et.startsWith("<svg")){const It=new Path2D(Et),St=ot/24;t.scale(St,St),t.translate(-12,-12),t.fillStyle=bt,t.fill(It)}t.restore()};P(c,!0),P(d,!1);const _=e.text||"",E=e.placeholder||"Enter text...",A=!_,W=_||E,z=A?M:w,Y=I,G=e.fontFamily||"Inter",N=e.fontWeight||400;t.font=`${N} ${Y}px "${G}", sans-serif`,t.fillStyle=z,t.textAlign="left",t.textBaseline=u?"top":"middle";const J=e.inputPadding??16,x=c.visible?(c.offset??16)+(c.size||14)/2+8:J,R=d.visible?(d.offset??16)+(d.size||14)/2+8:J,j=-(s/2)+x,X=s-x-R,tt=e.inputType==="password"?"•".repeat(W.length):W;if(t.save(),t.beginPath(),t.rect(j-2,-n/2+4,X+4,n-8),t.clip(),u){const D=tt.split(`
34
- `);let q=-n/2+J;const ot=Y*1.2;let yt=0;D.forEach((bt,gt)=>{const Et=bt.split(" ");let It="";for(let St=0;St<Et.length;St++){const zt=It+Et[St]+" ";t.measureText(zt).width>X&&St>0?(t.fillText(It,j,q),It=Et[St]+" ",q+=ot):It=zt}t.fillText(It,j,q),yt=t.measureText(It).width,gt<D.length-1&&(q+=ot,yt=0)}),a&&!A&&Math.floor(performance.now()/500)%2===0&&t.fillRect(j+yt,q,1.5,Y)}else{const q=t.measureText(tt).width;let ot=0;if(q>X&&(ot=q-X),t.fillText(tt,j-ot,0),a&&!A&&Math.floor(performance.now()/500)%2===0){const bt=j+q-ot;t.fillRect(bt,-(Y/2),1.5,Y)}}if(t.restore(),l.visible!==!1){const D=l.text||"Label",q=l.fontSize||12,ot=l.color||"rgba(156, 163, 175, 1)",yt=l.offset??8;t.font=`600 ${q}px "${G}", sans-serif`,t.fillStyle=ot,t.textAlign="left",t.textBaseline="bottom";const bt=-(s/2),gt=-(n/2)-yt;t.fillText(D,bt,gt)}if(p.visible===!0){const D=p.text||"Helper text",q=p.fontSize||11,ot=h==="error"?"rgba(239, 68, 68, 1)":p.color||"rgba(156, 163, 175, 1)",yt=p.offset??6;t.font=`400 ${q}px "${G}", sans-serif`,t.fillStyle=ot,t.textAlign="left",t.textBaseline="top";const bt=-(s/2),gt=n/2+yt;t.fillText(D,bt,gt)}}renderSlider(t,i){const o=this.objectStates.get(i.id),e=(o==null?void 0:o.geometry)||i.geometry,s=(o==null?void 0:o.options)||i.options||{},n=e.width||200,a=s.value??50,r=s.min??0,h=(s.max??100)-r,l=h===0?0:(a-r)/h,p=s.trackHeight||4,c=s.trackRoundedness??2,d=s.trackShape??"Rectangle",u=s.trackPath||"",v=s.accentColor||"#3b82f6",b=s.inactiveColor||"#374151",m=s.thumbShape||"Ellipse",y=s.thumbWidth??16,S=s.thumbHeight??16,C=s.thumbRoundedness??0,w=s.thumbColor||"#ffffff",M=s.thumbPath||"",I=s.thumbIcon||"",k=s.showValueTooltip??!1,T=s.tooltipBgColor||"#333333",O=s.tooltipColor||"#ffffff",P=s.tooltipOffsetX??0,_=s.tooltipOffsetY??-25,E=(X,tt,L,F,D,q,ot)=>{if((X==="Custom"||X==="Icon")&&ot)try{const yt=new Path2D(ot);if(t.save(),t.translate(tt,L),X==="Icon"){const bt=Math.min(F,D)/24;t.scale(bt,bt),t.translate(-12,-12)}t.fill(yt),t.restore();return}catch(yt){console.error("Error drawing slider shape in engine:",yt)}if(t.beginPath(),X==="Ellipse")t.ellipse(tt,L,F/2,D/2,0,0,Math.PI*2);else if(X==="Rectangle")this.drawRoundRect(t,tt-F/2,L-D/2,F,D,q);else if(X==="Triangle")t.moveTo(tt,L-D/2),t.lineTo(tt+F/2,L+D/2),t.lineTo(tt-F/2,L+D/2),t.closePath();else if(X==="Diamond")t.moveTo(tt,L-D/2),t.lineTo(tt+F/2,L),t.lineTo(tt,L+D/2),t.lineTo(tt-F/2,L),t.closePath();else if(X==="Polygon"){const yt=i.geometry.sides||3,bt=i.geometry.radius||Math.min(F,D)/2;for(let gt=0;gt<yt;gt++){const Et=gt*2*Math.PI/yt-Math.PI/2,It=tt+bt*Math.cos(Et),St=L+bt*Math.sin(Et);gt===0?t.moveTo(It,St):t.lineTo(It,St)}t.closePath()}else if(X==="Star"){const bt=Math.min(F,D)/2,gt=bt/2;for(let Et=0;Et<10;Et++){const It=Et%2===0?bt:gt,St=Et*Math.PI/5-Math.PI/2;t.lineTo(tt+It*Math.cos(St),L+It*Math.sin(St))}t.closePath()}else X==="Line"&&(t.moveTo(tt-F/2,L),t.lineTo(tt+F/2,L));t.fill()},A=this.createCanvasFill(t,b,n,p);A&&(t.fillStyle=A,t.strokeStyle=A),d==="Line"?(t.lineWidth=p,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(n/2,0),t.stroke()):E(d,0,0,n,p,c,u);const W=n-y,z=-n/2+y/2+l*W,Y=z- -n/2;if(Y>0){const X=this.createCanvasFill(t,v,n,p);X&&(t.fillStyle=X,t.strokeStyle=X),d==="Line"?(t.lineWidth=p,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(z,0),t.stroke()):d==="Rectangle"&&(t.beginPath(),this.drawRoundRect(t,-n/2,-p/2,Y,p,c),t.fill())}t.save(),t.translate(z,0);const G=t.getTransform(),N=Math.sqrt(G.a*G.a+G.b*G.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*N,t.shadowOffsetY=1*N;const J=this.createCanvasFill(t,w,y,S);if(J&&(t.fillStyle=J),E(m,0,0,y,S,C,m==="Icon"?I:M),t.restore(),k){t.save(),t.translate(z+P,_);const X=Math.round(a).toString();t.font="10px Inter, sans-serif";const tt=t.measureText(X),L=6,F=4,D=tt.width+L*2,q=14+F;t.beginPath(),this.drawRoundRect(t,-D/2,-q/2,D,q,4),t.fillStyle=T,t.fill(),t.fillStyle=O,t.textAlign="center",t.textBaseline="middle",t.fillText(X,0,0),t.restore()}const x=s.label||{},R=s.helperText||{},j=s.fontFamily||"Inter";if(x.visible!==!1){const X=x.text||"Label",tt=x.fontSize||12,L=x.color||"rgba(156, 163, 175, 1)",F=x.offset??8;t.font=`600 ${tt}px "${j}", sans-serif`,t.fillStyle=L,t.textAlign="left",t.textBaseline="bottom";const D=-(n/2),q=-(p/2)-F;t.fillText(X,D,q)}if(R.visible===!0){const X=R.text||"Helper text",tt=R.fontSize||11,L=R.color||"rgba(156, 163, 175, 1)",F=R.offset??6;t.font=`400 ${tt}px "${j}", sans-serif`,t.fillStyle=L,t.textAlign="left",t.textBaseline="top";const D=-(n/2),q=p/2+F;t.fillText(X,D,q)}}renderDropdown(t,i){var _;const o=this.objectStates.get(i.id);if(!o)return;const e=o.options||i.options||{},s=i.geometry.width||160,n=i.geometry.height||40,a=-s/2,r=-n/2,f=e.corner_radius??6,h=e.disabled||e.previewState==="disabled",l=this.lastHoveredObjectId===i.id||e.previewState==="hover",p=(e.isOpen||e.previewState==="active")&&!h;let c=e.backgroundColor,d=e.borderColor,u=e.color||"#333333";h?(c=e.disabledBackgroundColor||"#f3f4f6",d=e.disabledBorderColor||"#e5e7eb",u=e.disabledColor||"#9ca3af"):p?(c=e.activeBackgroundColor||c,d=e.activeBorderColor||d,u=e.activeColor||u):l&&(c=e.hoverBackgroundColor||c,d=e.hoverBorderColor||d,u=e.hoverColor||u),c||(c="#ffffff"),d||(d="#e5e7eb");const v=t.globalAlpha;t.globalAlpha=v*(e.opacity??1),this.drawRoundRect(t,a,r,s,n,f),t.fillStyle=this.createCanvasFill(t,typeof c=="string"?{type:"Solid",color:c}:c,s,n)||"#ffffff",t.fill();const b=e.borderWidth??1;b>0&&(t.strokeStyle=this.createCanvasFill(t,typeof d=="string"?{type:"Solid",color:d}:d,s,n)||"#e5e7eb",t.lineWidth=b,t.stroke());const m=12,y=e.chevronType||"chevron",S=e.chevronSize||16,C=(p?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(y!=="none"){const E=a+s-m-S/2;t.save(),t.translate(E,0);const A=p?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(A*Math.PI/180),t.strokeStyle=C,t.fillStyle=C,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",y==="chevron")t.beginPath(),t.moveTo(-S/2,-S*.2),t.lineTo(0,S*.2),t.lineTo(S/2,-S*.2),t.stroke();else if(y==="custom"||y==="path"){const W=p&&e.openIconPath||e.closedIconPath;if(W){const z=new Path2D(W);t.save();const Y=S/24;t.scale(Y,Y),t.translate(-12,-12),t.fill(z),t.restore()}}t.restore()}const w=e.selectedOption||e.placeholder||"Select...",M=e.fontSize||14,I=e.fontWeight||400,k=e.fontFamily||"Inter, sans-serif";t.font=`${I} ${M}px ${k}`;const T=h?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":u;t.fillStyle=this.createCanvasFill(t,typeof T=="string"?{type:"Solid",color:T}:T,s,n)||"#333333",t.textAlign="left",t.textBaseline="middle";const O=y==="none"?0:S+8,P=s-m*2-O;if(t.save(),t.beginPath(),t.rect(a+m,r,P,n),t.clip(),t.fillText(w,a+m,0),t.restore(),p&&!h){const E=r+n+4,A=e.optionsList||[],W=e.itemHeight||32,z=e.listPadding??4,Y=A.length*W+z*2,G=e.listCornerRadius??f;t.save();const N=e.listShadow||{},J=t.getTransform(),x=Math.sqrt(J.a*J.a+J.b*J.b)||1;t.shadowColor=typeof N.color=="string"?N.color:((_=N.color)==null?void 0:_.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(N.blur??12)*x,t.shadowOffsetY=(N.offsetY??6)*x,t.shadowOffsetX=(N.offsetX??0)*x,t.beginPath(),this.drawRoundRect(t,a,E,s,Y,G),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},s,Y)||"#ffffff",t.fill();const 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},s,Y)||"#e5e7eb",t.lineWidth=R,t.stroke()),t.restore();const j=e.itemFontSize||M,X=e.itemFontFamily||k;t.font=`${I} ${j}px ${X}`,A.forEach((tt,L)=>{const F=E+z+L*W;if(tt===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},s,W)||"#f3f4f6",t.fillRect(a+R,F,s-R*2,W),t.fillStyle=e.itemSelectedColor||e.accentColor||u||"#374151";else if(t.fillStyle=e.listTextColor||u||"#333333",this.activeDropdownId===i.id&&this._lastPointerPos){const q=this._lastPointerPos.y-(E+z),ot=Math.floor(q/W);L===ot&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},s,W)||"#f9fafb",t.fillRect(a+R,F,s-R*2,W),t.fillStyle=e.itemHoverColor||u)}t.fillText(tt,a+m,F+W/2)})}t.globalAlpha=v}renderButton(t,i){if(i.children&&i.children.length>0)return;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=i.geometry||{},n=s.width||120,a=s.height||40,r=this.lastHoveredObjectId===i.id,f=this.activeObjectId===i.id,h=e.label||{},l=e.hoverStyle||{},p=e.activeStyle||{},c=e.icon||{enabled:!1};let d=e.backgroundColor||"#3b82f6",u=h.color||"#ffffff",v=h.text||"Button",b=s.cornerRadius??8,m=e.borderColor||"transparent",y=e.borderWidth||0,S=1;f&&p?(d=p.backgroundColor||d,u=p.color||u,v=p.text||v,S=p.scale??.95,b=p.cornerRadius??b):r&&l&&(d=l.backgroundColor||d,u=l.color||u,v=l.text||v,S=l.scale??1,b=l.cornerRadius??b,m=l.borderColor||m);const C=-n/2,w=-a/2;t.save(),t.scale(S,S),t.beginPath(),this.drawRoundRect(t,C,w,n,a,b);const M=this.createCanvasFill(t,d,n,a);M&&(t.fillStyle=M,t.fill()),(y>0||r&&l.borderColor)&&(t.strokeStyle=m,t.lineWidth=y||(r?1:0),t.stroke());const I=h.fontSize||14,k=h.fontFamily||"Inter",T=h.fontWeight||600;t.font=`${T} ${I}px "${k}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=u,t.textAlign="center",t.textBaseline="middle";let O=0;if(c.enabled&&c.svgPath){const P=I*1.1,_=c.gap||8,E=t.measureText(v),W=-(E.width+P+_)/2,z=c.position==="left"?W+P/2:W+E.width+_+P/2;O=c.position==="left"?W+P+_+E.width/2:W+E.width/2,t.save(),t.translate(z,0);const Y=new Path2D(c.svgPath),G=P/24;t.scale(G,G),t.translate(-12,-12),t.fillStyle=u,t.fill(Y),t.restore()}t.fillText(v,O,0),t.restore()}renderToggleButton(t,i){var v,b;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=e.checked??!1,n=((v=i.geometry)==null?void 0:v.width)||120,a=((b=i.geometry)==null?void 0:b.height)||40,r=-n/2,f=-a/2,h=e.corner_radius??8,l=e.label||{},p=s?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",c=s?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,r,f,n,a,h),t.fillStyle=p,t.fill();const d=l.fontSize||14,u=l.fontFamily||"Inter";t.font=`${l.fontWeight||600} ${d}px "${u}", sans-serif`,t.fillStyle=c,t.textAlign="center",t.textBaseline="middle",t.fillText(l.text||"Toggle",0,0),t.restore()}renderToggle(t,i){var G,N,J,x,R,j,X,tt,L,F,D,q;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((G=i.geometry)==null?void 0:G.width)||52,n=((N=i.geometry)==null?void 0:N.height)||30,a=-s/2,r=-n/2,f=e.checked??!1,h=e.cornerRadius??e.corner_radius??n/2,l=e.toggleStyle||{},p=l.backgroundColor||e.activeColor||"#10b981",c=l.borderColor||e.borderColor||"transparent",d=l.borderWidth??e.borderWidth??0,u=l.knobColor||e.knobColor||"#ffffff",v=f?p:e.inactiveColor||"#374151",b=f?c:e.borderColor||"transparent",m=f?d:e.borderWidth??0,y=f?u:e.knobColor||"#ffffff";e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,s,n,h);const S=this.createCanvasFill(t,v,s,n);if(S&&(t.fillStyle=S,t.fill()),m>0){t.lineWidth=m;const ot=this.createCanvasFill(t,b,s,n);ot&&(t.strokeStyle=ot,t.stroke())}const C=2,w=n-C*2,M=w/2,I=a+C,k=a+s-C-w,T=f?k:I,O=r+C;t.beginPath(),t.arc(T+M,O+M,M,0,Math.PI*2);const P=this.createCanvasFill(t,y,w,w);P&&(t.fillStyle=P,t.fill()),e.disabled&&(t.globalAlpha*=2);let _=!1,E=!1;const A=(f?(J=l.leftLabel)==null?void 0:J.text:null)||((x=e.leftLabel)==null?void 0:x.text)||"",W=(f?(R=l.leftLabel)==null?void 0:R.color:null)||((j=e.leftLabel)==null?void 0:j.color)||"#f3f4f6";if((X=e.leftLabel)!=null&&X.enabled&&A){const ot=e.leftLabel;t.font=`${ot.fontWeight||400} ${ot.fontSize||12}px "${ot.fontFamily||"Inter"}", sans-serif`,t.fillStyle=W,t.textBaseline="middle",t.textAlign="right",t.fillText(A,a-(ot.gap||8),0),_=!0}const z=(f?(tt=l.rightLabel)==null?void 0:tt.text:null)||((L=e.rightLabel)==null?void 0:L.text)||"",Y=(f?(F=l.rightLabel)==null?void 0:F.color:null)||((D=e.rightLabel)==null?void 0:D.color)||"#f3f4f6";if((q=e.rightLabel)!=null&&q.enabled&&z){const ot=e.rightLabel;t.font=`${ot.fontWeight||400} ${ot.fontSize||12}px "${ot.fontFamily||"Inter"}", sans-serif`,t.fillStyle=Y,t.textBaseline="middle",t.textAlign="left",t.fillText(z,a+s+(ot.gap||8),0),E=!0}if(!_&&!E&&e.label&&e.label.text){const ot=e.label,yt=ot.fontSize||14,bt=ot.fontWeight||400,gt=ot.fontFamily||"Inter";t.font=`${bt} ${yt}px "${gt}", sans-serif`,t.fillStyle=ot.color||"#f3f4f6",t.textBaseline="middle";const Et=ot.gap||10;let It=0,St=0;ot.position==="left"?(t.textAlign="right",It=a-Et,St=0):ot.position==="right"?(t.textAlign="left",It=a+s+Et,St=0):ot.position==="top"?(t.textAlign="center",It=0,St=r-Et,t.textBaseline="bottom"):ot.position==="bottom"?(t.textAlign="center",It=0,St=r+n+Et,t.textBaseline="top"):(t.textAlign="left",It=a+s+Et,St=0),t.fillText(ot.text,It,St)}}renderCheckbox(t,i){var S,C;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((S=i.geometry)==null?void 0:S.width)||20,n=((C=i.geometry)==null?void 0:C.height)||20,a=-s/2,r=-n/2,f=e.cornerRadius??4,h=e.checked??!1,l=e.activeColor||"#3b82f6",p=e.inactiveColor||"transparent",c=e.checkColor||"#ffffff",d=e.borderColor||"#4b5563",u=e.borderWidth??2,v=h?l:p,b=h?"transparent":d,m=h?0:u;e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,s,n,f);const y=this.createCanvasFill(t,v,s,n);if(y&&(t.fillStyle=y,t.fill()),m>0){t.lineWidth=m;const w=this.createCanvasFill(t,b,s,n);w&&(t.strokeStyle=w,t.stroke())}else if(h){t.lineWidth=1;const w=this.createCanvasFill(t,l,s,n);w&&(t.strokeStyle=w,t.stroke())}if(h){t.save(),t.beginPath();const w=this.createCanvasFill(t,c,s,n);t.strokeStyle=w||c,t.lineWidth=Math.max(2,s*.12),t.lineCap="round",t.lineJoin="round";const M=a+s*.25,I=r+n*.5,k=a+s*.45,T=r+n*.7,O=a+s*.75,P=r+n*.25;t.moveTo(M,I),t.lineTo(k,T),t.lineTo(O,P),t.stroke(),t.restore()}if(e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const w=e.label;t.save(),t.font=`${w.fontWeight||400} ${w.fontSize||14}px "${w.fontFamily||"Inter"}", sans-serif`,t.fillStyle=w.color||"#f3f4f6",t.textBaseline="middle";const M=w.gap||8;let I=0,k=0;w.position==="left"?(t.textAlign="right",I=a-M,k=0):w.position==="right"?(t.textAlign="left",I=a+s+M,k=0):w.position==="top"?(t.textAlign="center",I=0,k=r-M,t.textBaseline="bottom"):w.position==="bottom"&&(t.textAlign="center",I=0,k=r+n+M,t.textBaseline="top"),t.fillText(w.text,I,k),t.restore()}}renderRadioGroup(t,i){var C,w;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((C=i.geometry)==null?void 0:C.width)||180,n=((w=i.geometry)==null?void 0:w.height)||100,a=-s/2,r=-n/2,f=e.selectedValue,h=e.optionsList||["Option 1","Option 2","Option 3"],l=e.orientation||"vertical",p=e.itemGap!==void 0?e.itemGap:16,c=e.activeColor||"#3b82f6",d=e.inactiveColor||"#4b5563",u=e.textColor||"#ffffff",v=e.fontSize||14,b=e.fontFamily||"Inter",m=e.fontWeight||400;e.disabled&&(t.globalAlpha*=.5);const y=8,S=y*2;if(t.save(),t.font=`${m} ${v}px "${b}", sans-serif`,t.textBaseline="middle",t.textAlign="left",l==="vertical"){const M=Math.max(S,v)+p;h.forEach((I,k)=>{const T=r+k*M+y;t.beginPath(),t.arc(a+y,T,y,0,Math.PI*2);const O=f===I,P=this.createCanvasFill(t,c,S,S),_=this.createCanvasFill(t,d,S,S);O?(t.strokeStyle=P||c,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(a+y,T,y/2,0,Math.PI*2),t.fillStyle=P||c,t.fill()):(t.strokeStyle=_||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(I,a+S+8,T)})}else{let M=a;h.forEach(I=>{const k=f===I,T=t.measureText(I).width;t.beginPath(),t.arc(M+y,0,y,0,Math.PI*2);const O=this.createCanvasFill(t,c,S,S),P=this.createCanvasFill(t,d,S,S);k?(t.strokeStyle=O||c,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(M+y,0,y/2,0,Math.PI*2),t.fillStyle=O||c,t.fill()):(t.strokeStyle=P||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(I,M+S+6,0),M+=S+6+T+p})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const M=e.label;t.save(),t.font=`${M.fontWeight||400} ${M.fontSize||14}px "${M.fontFamily||"Inter"}", sans-serif`,t.fillStyle=M.color||"#9ca3af",t.textBaseline="middle";const I=M.gap||8;let k=0,T=0;M.position==="left"?(t.textAlign="right",k=a-I,T=0):M.position==="right"?(t.textAlign="left",k=a+s+I,T=0):M.position==="top"?(t.textAlign="center",k=0,T=r-I,t.textBaseline="bottom"):M.position==="bottom"&&(t.textAlign="center",k=0,T=r+n+I,t.textBaseline="top"),t.fillText(M.text,k,T),t.restore()}}renderBarChart(t,i){var T,O;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s={width:((T=i.geometry)==null?void 0:T.width)||300,height:((O=i.geometry)==null?void 0:O.height)||180,chartType:e.chartType||"grouped",stylePreset:e.stylePreset||"default",datasets:e.datasets||[{id:"ds-1",label:"Revenue",data:[42,67,31,55,78,48],color:"#6366f1"}],categories:e.categories||["Jan","Feb","Mar","Apr","May","Jun"],orientation:e.orientation||"vertical",barWidth:e.barWidth!==void 0?e.barWidth:14,barGap:e.barGap!==void 0?e.barGap:4,barCornerRadius:e.barCornerRadius!==void 0?e.barCornerRadius:5,showXAxis:!!e.showXAxis,showYAxis:!!e.showYAxis,xAxisColor:e.xAxisColor||"rgba(255,255,255,0.12)",yAxisColor:e.yAxisColor||"rgba(255,255,255,0.12)",showXLabels:e.showXLabels!==void 0?!!e.showXLabels:!0,showYLabels:!!e.showYLabels,axisLabelColor:e.axisLabelColor||"rgba(255,255,255,0.5)",axisLabelFontSize:e.axisLabelFontSize||9,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.7)",legendFontSize:e.legendFontSize||9,showGridLines:e.showGridLines!==void 0?!!e.showGridLines:!0,gridColor:e.gridColor||"rgba(255,255,255,0.06)",cardBackground:e.cardBackground||"rgba(255,255,255,0.04)",cardBorderColor:e.cardBorderColor||"rgba(255,255,255,0.08)",barGradient:e.barGradient!==void 0?!!e.barGradient:!0,showValueOnTop:!!e.showValueOnTop,chartBackground:e.chartBackground||"transparent",barStyle:e.barStyle||"solid",barBorderWidth:e.barBorderWidth!==void 0?e.barBorderWidth:1,barBorderColor:e.barBorderColor||"auto",enableShadows:!!e.enableShadows,shadowColor:e.shadowColor||"rgba(0,0,0,0.5)",shadowBlur:e.shadowBlur!==void 0?e.shadowBlur:4,shadowOffsetY:e.shadowOffsetY!==void 0?e.shadowOffsetY:2,valueFontSize:e.valueFontSize||10,valueColor:e.valueColor||"auto",valueFontWeight:e.valueFontWeight||"bold",xAxisLineWidth:e.xAxisLineWidth!==void 0?e.xAxisLineWidth:1,yAxisLineWidth:e.yAxisLineWidth!==void 0?e.yAxisLineWidth:1,gridLineWidth:e.gridLineWidth!==void 0?e.gridLineWidth:1,gridLineDash:e.gridLineDash||[3,4],_getPreset:function(){return ps[this.stylePreset]||ps.default},_resolveColor:function(P,_){const E=this._getPreset();return["#6366f1","#f59e0b","#10b981","#3b82f6","#a855f7"].includes(P)?E.colors[_%E.colors.length]:typeof P=="string"?P:E.colors[_%E.colors.length]},_makeGradient:function(P,_,E,A,W,z){if(!this._getPreset().barGradient&&!this.barGradient)return _;const G=P.createLinearGradient(E,A,W,z);return G.addColorStop(0,_),G.addColorStop(1,_+"44"),G},_drawRoundedBar:function(P,_,E,A,W,z,Y){if(z=Math.min(z,Math.min(Math.abs(A),Math.abs(W))/2),z<=0||A===0||W===0){P.rect(_,E,A,W);return}P.beginPath(),Y?(P.moveTo(_,E+W),P.lineTo(_,E+z),P.quadraticCurveTo(_,E,_+z,E),P.lineTo(_+A-z,E),P.quadraticCurveTo(_+A,E,_+A,E+z),P.lineTo(_+A,E+W),P.lineTo(_,E+W)):(P.moveTo(_,E),P.lineTo(_+A-z,E),P.quadraticCurveTo(_+A,E,_+A,E+z),P.lineTo(_+A,E+W-z),P.quadraticCurveTo(_+A,E+W,_+A-z,E+W),P.lineTo(_,E+W),P.lineTo(_,E)),P.closePath()}},n=s.width,a=s.height,r=-n/2,f=-a/2;if(!s.datasets||s.datasets.length===0||s.categories.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.7)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO CHART DATA",0,0),t.restore();return}const h=s._getPreset();let l=-1/0,p=1/0;const c=s.categories.length,d=s.datasets.length;if(s.chartType==="stacked")for(let P=0;P<c;P++){let _=0,E=0;s.datasets.forEach(A=>{const W=A.data[P]??0;W>=0?_+=W:E+=W}),_>l&&(l=_),E<p&&(p=E)}else s.datasets.forEach(P=>{P.data&&P.data.forEach(_=>{_>l&&(l=_),_<p&&(p=_)})});isFinite(l)||(l=10),isFinite(p)||(p=0),l=Math.max(l,0),p=Math.min(p,0);const u=l-p||10;t.save(),s.enableShadows&&(t.shadowColor=s.shadowColor,t.shadowBlur=s.shadowBlur,t.shadowOffsetY=s.shadowOffsetY),t.font=s.axisLabelFontSize+"px Inter, sans-serif";const v=s.showYLabels?t.measureText(l.toFixed(0)).width+14:10,b=s.showXLabels?s.axisLabelFontSize+12:8,y=(s.showLegend&&d>0?s.legendFontSize+10:0)+8,S=10,C=r+v,w=f+y,M=n-v-S,I=a-y-b;if(s.enableShadows&&(t.shadowColor="transparent"),t.beginPath(),t.roundRect(r,f,n,a,10),t.fillStyle=h.cardBackground,t.fill(),t.strokeStyle=h.cardBorderColor,t.lineWidth=1,t.stroke(),s.chartBackground&&s.chartBackground!=="transparent"&&(t.beginPath(),t.rect(C,w,M,I),t.fillStyle=s.chartBackground,t.fill()),s.showLegend&&d>0){t.font=s.legendFontSize+"px Inter, sans-serif",t.textBaseline="middle";const P=f+12;let _=C;s.datasets.forEach((E,A)=>{const W=s._resolveColor(E.color,A),z=E.label||"Series "+(A+1),Y=7;t.beginPath(),t.roundRect(_,P-Y/2,Y,Y,2),t.fillStyle=W,t.fill(),t.fillStyle=h.legendColor,t.textAlign="left",t.fillText(z,_+Y+4,P),_+=t.measureText(z).width+Y+16})}const k=4;if(s.showGridLines){t.setLineDash(s.gridLineDash||[]),t.lineWidth=s.gridLineWidth||1,t.strokeStyle=h.gridColor;for(let P=0;P<=k;P++)if(s.orientation==="horizontal"){const _=C+P/k*M;t.beginPath(),t.moveTo(_,w),t.lineTo(_,w+I),t.stroke()}else{const _=w+P/k*I;t.beginPath(),t.moveTo(C,_),t.lineTo(C+M,_),t.stroke()}t.setLineDash([])}if(s.showYLabels){t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor;for(let P=0;P<=k;P++)if(s.orientation==="horizontal"){const _=p+P/k*u,E=C+P/k*M;t.textAlign="center",t.fillText(_.toFixed(0),E,w+I+s.axisLabelFontSize)}else{const _=l-P/k*u,E=w+P/k*I;t.textAlign="right",t.fillText(_.toFixed(0),C-6,E)}}if(t.setLineDash([]),s.showXAxis&&(t.lineWidth=s.xAxisLineWidth||1,t.strokeStyle=s.xAxisColor,t.beginPath(),t.moveTo(C,w+I),t.lineTo(C+M,w+I),t.stroke()),s.showYAxis&&(t.lineWidth=s.yAxisLineWidth||1,t.strokeStyle=s.yAxisColor,t.beginPath(),t.moveTo(C,w),t.lineTo(C,w+I),t.stroke()),s.enableShadows&&(t.shadowColor=s.shadowColor),s.chartType==="stacked")if(s.orientation==="horizontal"){const P=I/c;for(let _=0;_<c;_++){const E=w+_*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[_]||"",C-5,E),s.enableShadows&&(t.shadowColor=s.shadowColor));let A=C;s.datasets.forEach((W,z)=>{const Y=W.data[_]??0;if(Y===0)return;const G=Y/u*M,N=Math.min(s.barWidth*d+s.barGap,P-8),J=E-N/2,x=A;A+=G;const R=s._resolveColor(W.color,z);t.beginPath(),t.fillStyle=s._makeGradient(t,R,x,J,x+G,J),s._drawRoundedBar(t,x,J,G,N,z===d-1?s.barCornerRadius:0,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?R:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else{const P=M/c;for(let _=0;_<c;_++){const E=C+_*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[_]||"",E,w+I+5),s.enableShadows&&(t.shadowColor=s.shadowColor));let A=w+I;s.datasets.forEach((W,z)=>{const Y=W.data[_]??0;if(Y===0)return;const G=Y/u*I,N=Math.min(s.barWidth*d+s.barGap,P-8),J=E-N/2,x=A-G;A-=G;const R=s._resolveColor(W.color,z);t.beginPath(),t.fillStyle=s._makeGradient(t,R,J,x,J,x+G),s._drawRoundedBar(t,J,x,N,G,z===d-1?s.barCornerRadius:0,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?R:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else if(s.orientation==="horizontal"){const P=I/c,_=d*s.barWidth+Math.max(0,(d-1)*s.barGap),E=C+(0-p)/u*M;for(let A=0;A<c;A++){const W=w+A*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[A]||"",C-5,W),s.enableShadows&&(t.shadowColor=s.shadowColor));const z=W-_/2;s.datasets.forEach((Y,G)=>{const N=Y.data[A]??0,J=Math.abs(N/u*M);if(J<1)return;const x=z+G*(s.barWidth+s.barGap),R=N>=0?E:E-J,j=s._resolveColor(Y.color,G);t.beginPath(),t.fillStyle=s._makeGradient(t,j,R,x,R+J,x),s._drawRoundedBar(t,R,x,J,s.barWidth,s.barCornerRadius,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?j:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&N!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign=N>=0?"left":"right",t.textBaseline="middle",t.fillStyle=s.valueColor==="auto"?j:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(N.toString(),N>=0?R+J+4:R-4,x+s.barWidth/2),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}else{const P=M/c,_=d*s.barWidth+Math.max(0,(d-1)*s.barGap),E=w+I-(0-p)/u*I;for(let A=0;A<c;A++){const W=C+A*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[A]||"",W,w+I+5),s.enableShadows&&(t.shadowColor=s.shadowColor));const z=W-_/2;s.datasets.forEach((Y,G)=>{const N=Y.data[A]??0,J=Math.abs(N/u*I);if(J<1)return;const x=z+G*(s.barWidth+s.barGap),R=N>=0?E-J:E,j=s._resolveColor(Y.color,G);t.beginPath(),t.fillStyle=s._makeGradient(t,j,x,R,x,R+J),s._drawRoundedBar(t,x,R,s.barWidth,J,s.barCornerRadius,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?j:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&N!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign="center",t.textBaseline=N>=0?"bottom":"top",t.fillStyle=s.valueColor==="auto"?j:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(N.toString(),x+s.barWidth/2,N>=0?R-4:R+J+4),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}t.restore()}renderPieChart(t,i){var v,b;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s={width:((v=i.geometry)==null?void 0:v.width)||180,height:((b=i.geometry)==null?void 0:b.height)||180,chartType:e.chartType||"donut",stylePreset:e.stylePreset||"default",slices:e.slices||[{id:"slice-1",label:"Item 1",value:45,color:"#6366f1"}],innerRadius:e.innerRadius!==void 0?e.innerRadius:.55,sliceGap:e.sliceGap!==void 0?e.sliceGap:3,showLabels:!!e.showLabels,labelColor:e.labelColor||"#ffffff",labelFontSize:e.labelFontSize||10,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.65)",legendFontSize:e.legendFontSize||9,showCenterText:e.showCenterText!==void 0?!!e.showCenterText:!0,centerLabel:e.centerLabel||"Total",centerTextColor:e.centerTextColor||"#ffffff",centerLabelColor:e.centerLabelColor||"rgba(255,255,255,0.4)",_getPreset:function(){return gs[this.stylePreset]||gs.default},_resolveSliceColor:function(m,y){const S=m.color,C=y,w=this._getPreset();return["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399","#a855f7","#f87171"].includes(S)?w.colors[C%w.colors.length]:typeof S=="string"?S:w.colors[C%w.colors.length]}},n=s.width,a=s.height;if(!s.slices||s.slices.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO PIE DATA",0,0),t.restore();return}const r=s.slices.reduce((m,y)=>m+(y.value||0),0);if(r<=0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("EMPTY DATA",0,0),t.restore();return}const f=s._getPreset();t.save(),t.beginPath(),t.roundRect(-n/2,-a/2,n,a,10),t.fillStyle=f.cardBackground,t.fill(),t.strokeStyle=f.cardBorderColor,t.lineWidth=1,t.stroke();const h=s.showLegend?Math.ceil(s.slices.length/2):0,l=h>0?h*(s.legendFontSize+8)+10:0,p=a-l-16,c=Math.min(n-24,p)/2,d=0,u=-l/2;if(s.chartType==="rose"){const m=Math.max(...s.slices.map(C=>C.value||0)),y=Math.PI*2/s.slices.length,S=c>0?s.sliceGap/c:0;s.slices.forEach((C,w)=>{const M=C.value||0;if(M===0)return;const I=M/m*c,k=-Math.PI/2+w*y+S/2,T=k+y-S,O=s._resolveSliceColor(C,w);if(t.beginPath(),t.moveTo(d,u),t.arc(d,u,I,k,T),t.closePath(),t.fillStyle=O+"cc",t.fill(),t.strokeStyle=O,t.lineWidth=1.5,t.stroke(),s.showLabels){const P=k+(T-k)/2,_=d+I*.65*Math.cos(P),E=u+I*.65*Math.sin(P),A=Math.round(M/r*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=f.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${A}%`,_,E),t.restore()}})}else{const m=s.chartType==="pie"?0:s.innerRadius,y=c*Math.max(0,m),S=c>0?s.sliceGap/c:0;let C=-Math.PI/2;if(s.slices.forEach((w,M)=>{const I=w.value||0;if(I===0){C+=I/r*Math.PI*2;return}const k=I/r*Math.PI*2,T=C+S/2,O=C+k-S/2;if(O<=T){C+=k;return}const P=s._resolveSliceColor(w,M);if(t.beginPath(),t.fillStyle=P,y<=0?(t.moveTo(d,u),t.arc(d,u,c,T,O),t.lineTo(d,u)):(t.moveTo(d+c*Math.cos(T),u+c*Math.sin(T)),t.arc(d,u,c,T,O),t.arc(d,u,y,O,T,!0),t.closePath()),t.fill(),s.showLabels){const _=T+(O-T)/2,E=y+(c-y)/2,A=d+E*Math.cos(_),W=u+E*Math.sin(_),z=Math.round(I/r*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=f.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${z}%`,A,W),t.restore()}C+=k}),s.chartType==="donut"&&s.showCenterText&&y>14){const w=Math.round(r),M=Math.min(Math.floor(y*.52),20),I=Math.min(Math.floor(y*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${M}px Inter, sans-serif`,t.fillStyle=f.centerTextColor,t.fillText(w.toString(),d,u-I*.5),s.centerLabel&&(t.font=`${I}px Inter, sans-serif`,t.fillStyle=f.centerLabelColor,t.fillText(s.centerLabel,d,u+M*.6))}}if(s.showLegend&&s.slices.length>0){t.font=`${s.legendFontSize}px Inter, sans-serif`;const m=2,y=n/m,S=s.legendFontSize+8,C=a/2-l+10,w=-n/2+10;s.slices.forEach((M,I)=>{const k=I%m,T=Math.floor(I/m),O=w+k*y,P=C+T*S,_=s._resolveSliceColor(M,I),E=7;t.beginPath(),t.roundRect(O,P-E/2,E,E,2),t.fillStyle=_,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=f.legendColor;const A=Math.round((M.value||0)/r*100),W=`${M.label||"Item"} ${A}%`,z=y-E-20;let Y=W;for(;t.measureText(Y).width>z&&Y.length>4;)Y=Y.slice(0,-4)+"…";t.fillText(Y,O+E+4,P)})}t.restore()}renderJoystick(t,i){var u,v,b,m,y;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.width)!==void 0?o.width:((u=i.geometry)==null?void 0:u.width)??i.width??100,s=(o==null?void 0:o.height)!==void 0?o.height:((v=i.geometry)==null?void 0:v.height)??i.height??100,n=Math.min(e,s)*.45,a=Math.min(e,s)*.15;let r=i.handleX||0,f=i.handleY||0;o&&o.handleX!==void 0&&(r=o.handleX),o&&o.handleY!==void 0&&(f=o.handleY),t.save();let h=0,l=0;i.handleOrigin==="top-left"?(h=e/2,l=s/2):i.handleOrigin==="bottom-right"&&(h=-e/2,l=-s/2),t.translate(h,l),t.beginPath(),i.boundsShape==="square"?t.rect(-n,-n,n*2,n*2):t.arc(0,0,n,0,Math.PI*2),t.fillStyle="rgba(0,0,0,0.2)",(b=i.style)!=null&&b.fill&&typeof i.style.fill=="string"?t.fillStyle=i.style.fill:(m=i.style)!=null&&m.fill&&i.style.fill.type==="solid"&&(t.fillStyle=i.style.fill.color),t.fill(),(y=i.style)!=null&&y.stroke&&i.style.stroke.isEnabled!==!1&&(t.lineWidth=i.style.stroke.width||1,t.strokeStyle=i.style.stroke.color||"#000",t.stroke());const p=n-a;let c=0,d=0;i.joystickType==="2D"?(c=r*p,d=f*p):i.joystickType==="1D_X"?(c=r*p,d=0):i.joystickType==="1D_Y"&&(c=0,d=f*p),t.beginPath(),t.arc(c,d,a,0,Math.PI*2),t.fillStyle="#fff",t.fill(),t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1,t.stroke(),t.restore()}getRadioGroupItemIndexAtPointer(t,i,o){var I,k;const e=t.options||{},s=this.objectStates.get(t.id)||{},n=e.optionsList||[];if(n.length===0)return null;const a=s.width!==void 0?s.width:((I=t.geometry)==null?void 0:I.width)||180,r=s.height!==void 0?s.height:((k=t.geometry)==null?void 0:k.height)||100,f=e.orientation||"vertical",h=e.itemGap!==void 0?e.itemGap:16,l=e.fontSize||14,p=this.getWorldTransform(t.id),c=i-p.x,d=o-p.y,u=-p.rotation*(Math.PI/180),v=Math.cos(u),b=Math.sin(u),m=c*v-d*b,y=c*b+d*v,C=8*2,w=-a/2,M=-r/2;if(f==="vertical"){const T=Math.max(C,l)+h;for(let O=0;O<n.length;O++){const P=M+O*T;if(m>=w&&m<=w+a&&y>=P&&y<=P+T)return O}}else{let T=w;for(let O=0;O<n.length;O++){const _=n[O].length*8,E=C+6+_+h;if(m>=T&&m<=T+E&&y>=M&&y<=M+r)return O;T+=E}}return null}renderLineGraph(t,i,o,e){let s=i.datasets||[];if((!s||s.length===0)&&(i.data||i.graphData)&&(s=[{id:"line-1",label:"Series 1",data:i.data||i.graphData||[],lineColor:i.lineColor||"#3b82f6",lineWidth:i.lineWidth||2,showArea:i.showArea||!1,areaColor:i.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:i.smoothing||!1,showPoints:i.showPoints!==void 0?i.showPoints:!0,pointSize:i.pointSize||6,pointFill:i.pointFill||"#ffffff",pointStrokeColor:i.pointStrokeColor||i.lineColor||"#3b82f6",pointStrokeWidth:i.pointStrokeWidth||2}]),!s||s.length===0||!s.some(u=>u.data&&u.data.length>=2)){t.save(),t.fillStyle="#6366f1",t.font="12px Inter, system-ui, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO DATA",0,0),t.restore();return}let n=1/0,a=-1/0,r=0;if(s.forEach(u=>{let v=u.data;if(u.isVarEnabled&&u.inputId){let b=this.inputs.get(u.inputId);if(b===void 0){const m=this.inputNameMap.get(u.inputId);m&&m.length>0&&(b=this.inputs.get(m[0]))}b&&Array.isArray(b)&&(v=b)}if(v&&v.length>0){const b=v.filter(m=>typeof m=="number"&&!isNaN(m));b.length>0&&(n=Math.min(n,...b),a=Math.max(a,...b),r=Math.max(r,v.length))}u._resolvedData=v}),r<2)return;const f=a-n,h=o/(r-1),l=u=>{const v=f===0?.5:(u-n)/f;return e/2-v*e},p=u=>u*h-o/2,c=i.axisColor||"#333333";if(i.showXAxis&&(t.beginPath(),t.strokeStyle=i.xAxisColor||c,t.lineWidth=1,t.moveTo(-o/2,e/2),t.lineTo(o/2,e/2),t.stroke()),i.showYAxis&&(t.beginPath(),t.strokeStyle=i.yAxisColor||c,t.lineWidth=1,t.moveTo(-o/2,-e/2),t.lineTo(-o/2,e/2),t.stroke()),t.fillStyle=i.axisLabelColor||"#333333",t.font=`${i.axisLabelFontSize||10}px Inter, sans-serif`,i.showXLabels){t.textAlign="center",t.textBaseline="top";for(let u=0;u<r;u++){const v=p(u);t.fillText(`${u+1}`,v,e/2+5)}}if(i.showYLabels){t.textAlign="right",t.textBaseline="middle";const u=-o/2-5,v=(a+n)/2;t.fillText(a.toFixed(1),u,l(a)),t.fillText(v.toFixed(1),u,l(v)),t.fillText(n.toFixed(1),u,l(n))}const d=10;if(s.forEach(u=>{const v=u._resolvedData;if(!(!v||v.length<2)){if(u.showArea){if(t.beginPath(),t.moveTo(p(0),e/2),t.lineTo(p(0),l(v[0])),u.smoothing&&v.length>2)for(let m=0;m<v.length-1;m++){const y=v[m===0?m:m-1],S=v[m],C=v[m+1],w=v[m+1===v.length-1?m+1:m+2];for(let M=1;M<=d;M++){const I=M/d,k=this._catmullRom(y,S,C,w,I);t.lineTo(p(m+I),l(k))}}else for(let m=1;m<v.length;m++)t.lineTo(p(m),l(v[m]));t.lineTo(p(v.length-1),e/2),t.closePath();const b=t.globalAlpha;t.globalAlpha=b*(i.areaOpacity??.3),t.fillStyle=u.areaColor||"rgba(139, 92, 246, 0.2)",t.fill(),t.globalAlpha=b}if(t.beginPath(),t.strokeStyle=u.lineColor||"#3b82f6",t.lineWidth=u.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.moveTo(p(0),l(v[0])),u.smoothing&&v.length>2)for(let b=0;b<v.length-1;b++){const m=v[b===0?b:b-1],y=v[b],S=v[b+1],C=v[b+1===v.length-1?b+1:b+2];for(let w=1;w<=d;w++){const M=w/d,I=this._catmullRom(m,y,S,C,M);t.lineTo(p(b+M),l(I))}}else for(let b=1;b<v.length;b++)t.lineTo(p(b),l(v[b]));t.stroke(),u.showPoints&&v.forEach((b,m)=>{const y=p(m),S=l(b);t.beginPath(),t.arc(y,S,(u.pointSize||6)/2,0,Math.PI*2),t.fillStyle=u.pointFill||"#ffffff",t.fill(),t.strokeStyle=u.pointStrokeColor||u.lineColor||"#3b82f6",t.lineWidth=u.pointStrokeWidth||1,t.stroke()})}}),i.showLegend&&s.length>0){const u=o/2-10;let v=-e/2+15;const b=i.legendFontSize||10,m=b+5;t.font=`${b}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",s.forEach(y=>{const C=y.label||"Series",w=t.measureText(C).width;t.beginPath(),t.rect(u-w-8-5,v-(8/2+2),8,8),t.fillStyle=y.lineColor||"#3b82f6",t.fill(),t.fillStyle=i.legendColor||"#333333",t.fillText(C,u,v),v+=m})}}_catmullRom(t,i,o,e,s){const n=(o-t)*.5,a=(e-i)*.5,r=s*s,f=s*r;return(2*i-2*o+n+a)*f+(-3*i+3*o-2*n-a)*r+n*s+i}normalizeOpacity(t){const i=typeof t=="number"?t:parseFloat(String(t));return isNaN(i)?1:i>1?Math.min(1,i/100):Math.max(0,Math.min(1,i))}createCanvasFill(t,i,o,e){var s,n,a;if(!i||i.type==="None")return null;if(typeof i=="string")return i;if(i.type==="Solid"&&i.color){const r=i.color,h=(((n=(s=this.artboard)==null?void 0:s.tokens)==null?void 0:n.colors)||{})[r]||r;return t.fillStyle=h,h}if((i.type==="LinearGradient"||i.type==="RadialGradient"||i.type==="AngularGradient"||i.type==="DiamondGradient")&&i.stops){const r=(f,h=100)=>{var S,C;const p=(((C=(S=this.artboard)==null?void 0:S.tokens)==null?void 0:C.colors)||{})[f]||f,c=this.normalizeOpacity(i.opacity??100),u=this.normalizeOpacity(h)*c;if(u>=1&&p.startsWith("#"))return p;const v=p.startsWith("#")?p.replace("#",""):"ffffff",b=parseInt(v.substring(0,2),16),m=parseInt(v.substring(2,4),16),y=parseInt(v.substring(4,6),16);return`rgba(${b}, ${m}, ${y}, ${u})`};if(i.type==="LinearGradient"){const f=(u,v,b)=>Array.isArray(u)?u[v]??(v===0?0:1):u&&typeof u=="object"?u[b]??(v===0?0:1):v===0?0:1,h=f(i.start,0,"x")*o-o/2,l=f(i.start,1,"y")*e-e/2,p=f(i.end,0,"x")*o-o/2,c=f(i.end,1,"y")*e-e/2,d=t.createLinearGradient(h,l,p,c);if(i.stops.forEach(u=>{const v=u.offset!==void 0?u.offset:u.pos!==void 0?u.pos:u.position!==void 0?u.position:0,b=r(u.color||"#000000",u.opacity??100);d.addColorStop(Math.max(0,Math.min(1,v)),b)}),i.gradientTransform&&d.setTransform){const[u,v,b,m,y,S]=i.gradientTransform;d.setTransform({a:u,b:v,c:b,d:m,e:y,f:S})}return d}else if(i.type==="RadialGradient"){const f=(d,u,v)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[v]??.5:.5,h=f(i.center,0,"x")*o-o/2,l=f(i.center,1,"y")*e-e/2,p=(i.radius??.5)*Math.max(o,e),c=t.createRadialGradient(h,l,0,h,l,p);if(i.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,v=r(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,u)),v)}),i.gradientTransform&&c.setTransform){const[d,u,v,b,m,y]=i.gradientTransform;c.setTransform({a:d,b:u,c:v,d:b,e:m,f:y})}return c}else if(i.type==="AngularGradient"){const f=(d,u,v)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[v]??.5:.5,h=f(i.center||[.5,.5],0,"x")*o-o/2,l=f(i.center||[.5,.5],1,"y")*e-e/2,p=(i.degree||i.angle||0)*(Math.PI/180),c=(a=t.createConicGradient)==null?void 0:a.call(t,p,h,l);if(c){if(i.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,v=r(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,u)),v)}),i.gradientTransform&&c.setTransform){const[d,u,v,b,m,y]=i.gradientTransform;c.setTransform({a:d,b:u,c:v,d:b,e:m,f:y})}return c}}else if(i.type==="DiamondGradient"){const f=(d,u,v)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[v]??.5:.5,h=f(i.center||[.5,.5],0,"x")*o-o/2,l=f(i.center||[.5,.5],1,"y")*e-e/2,p=(i.radius??.5)*Math.max(o,e);t.save(),t.translate(h,l),t.rotate(Math.PI/4);const c=t.createRadialGradient(0,0,0,0,0,p);if(i.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,v=r(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,u)),v)}),i.gradientTransform&&c.setTransform){const[d,u,v,b,m,y]=i.gradientTransform;c.setTransform({a:d,b:u,c:v,d:b,e:m,f:y})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=c,t.restore(),c}}if(i.type==="Pattern"&&i.url){let r=this.imageCache.get(i.url);if(r||(r=new Image,r.src=i.url,this.imageCache.set(i.url,r)),r.complete&&r.naturalWidth>0){const f=t.createPattern(r,"repeat");if(f&&(i.scaleX!==void 0||i.offsetX!==void 0)){const h=new DOMMatrix,l=i.scaleX??1,p=i.scaleY??1,c=i.offsetX??0,d=i.offsetY??0,u=i.rotation??0;h.translateSelf(c,d),h.rotateSelf(u),h.scaleSelf(l,p),f.setTransform(h)}return f}}return i.color||null}drawRoundRect(t,i,o,e,s,n){if(n===0||n===void 0||n===null){t.rect(i,o,e,s);return}let a=n;if(typeof a=="string")try{a=JSON.parse(a)}catch{a=parseFloat(a)||0}let r=0,f=0,h=0,l=0;typeof a=="number"?r=f=h=l=a:Array.isArray(a)?a.length===1?r=f=h=l=a[0]:a.length===2?(r=h=a[0],f=l=a[1]):a.length===3?(r=a[0],f=l=a[1],h=a[2]):a.length>=4&&(r=a[0],f=a[1],h=a[2],l=a[3]):a&&typeof a=="object"&&(r=a.tl??a.corner_radius??a.cornerRadius??0,f=a.tr??a.corner_radius??a.cornerRadius??0,h=a.br??a.corner_radius??a.cornerRadius??0,l=a.bl??a.corner_radius??a.cornerRadius??0);const p=Math.min(Math.abs(e)/2,Math.abs(s)/2);if(r=Math.min(Math.max(0,r),p),f=Math.min(Math.max(0,f),p),h=Math.min(Math.max(0,h),p),l=Math.min(Math.max(0,l),p),t.roundRect){t.roundRect(i,o,e,s,[r,f,h,l]);return}t.moveTo(i+r,o),t.lineTo(i+e-f,o),t.arcTo(i+e,o,i+e,o+f,f),t.lineTo(i+e,o+s-h),t.arcTo(i+e,o+s,i+e-h,o+s,h),t.lineTo(i+l,o+s),t.arcTo(i,o+s,i,o+s-l,l),t.lineTo(i,o+r),t.arcTo(i,o,i+r,o,r),t.closePath()}renderListView(t,i){var A,W,z,Y;const o=this.objectStates.get(i.id)||{},e=o.options||i.options||{},s=o.width!==void 0?o.width:((A=i.geometry)==null?void 0:A.width)||200,n=o.height!==void 0?o.height:((W=i.geometry)==null?void 0:W.height)||300,a=-s/2,r=-n/2,f=o.corner_radius!==void 0?o.corner_radius:e.corner_radius??0,h=e.orientation||"vertical",l=e.items||[],p=e.itemGap??10,c=e.itemHeight??50,d=e.itemWidth??200,u=e.scrollOffset??0,v=e.padding??0,b=e.glassEffect!==!1,m=e.accentColor||"#3b82f6",y=e.itemTextColor||"#333333",S=e.itemBackgroundColor||"#ffffff",C=e.hoveredIndex??null,w=e.activeItemIndex??null,M=e.glowIntensity??0,I=e.glowColor||"#3b82f6",k=typeof I=="string"?I:I.color||((Y=(z=I.stops)==null?void 0:z[0])==null?void 0:Y.color)||"#3b82f6",T=e.opacity!==void 0?e.opacity:i.opacity!==void 0?i.opacity:1;if(t.save(),t.globalAlpha*=T,M>0){const G=t.getTransform(),N=Math.sqrt(G.a*G.a+G.b*G.b)||1;t.shadowColor=k,t.shadowBlur=M*2*N,t.shadowOffsetX=0,t.shadowOffsetY=0}if(b){const G=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",N=this.createCanvasFill(t,G,s,n);t.fillStyle=N||"rgba(31, 41, 55, 0.4)",t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f)||t.fill();const x=t.createLinearGradient(a,r,a+s,r+n);x.addColorStop(0,"rgba(255, 255, 255, 0.15)"),x.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),x.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=x,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f)||t.fill(),t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f)||t.stroke()}else{const G=e.backgroundColor||e.listBackgroundColor||"transparent",N=this.createCanvasFill(t,G,s,n);if(N){t.fillStyle=N,t.beginPath();const x=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f);t.fill()}const J=e.borderWidth??0;if(J>0){t.strokeStyle=e.borderColor||"#cccccc",t.lineWidth=J,t.beginPath();const x=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f);t.stroke()}}t.shadowBlur=0,t.save(),t.beginPath();const O=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f);if(e.listLayout!=="circular")if(O&&e.containerShape==="custom")try{const G=new Path2D(e.containerPath);t.translate(a,r),t.scale(s/100,n/100),t.clip(G),t.scale(100/s,100/n),t.translate(-a,-r)}catch{}else t.clip();const P=typeof v=="number"?v:h==="vertical"?v[0]:v[3];let _=(h==="vertical"?r:a)+u+P;if(t.textBaseline="middle",l.forEach((G,N)=>{const J=e.listLayout||"linear",x=J==="circular"?d:h==="vertical"?s:d,R=J==="circular"||h==="vertical"?c:n;let j=0,X=0,tt=0;if(J==="circular"){const St=l.length||1,zt=Math.PI*2/St,he=e.circularStartAngle||0,pe=e.circularRadius||100,et=u*.01+he*Math.PI/180,mt=N*zt+et,Ft=a+s/2,_t=r+n/2;j=Ft+Math.cos(mt)*pe-x/2,X=_t+Math.sin(mt)*pe-R/2,tt=mt+(e.itemRotation||0)*Math.PI/180}else j=h==="vertical"?a:_,X=h==="vertical"?_:r,tt=(e.itemRotation||0)*Math.PI/180;const L=C===N,F=w===N,D=F&&e.activeItemShape?e.activeItemShape:e.itemShape||"rectangle",q=F&&e.activeItemShape?e.activeItemPath:e.itemPath||"",ot=e.itemCornerRadius||0;if(t.save(),tt!==0&&(t.translate(j+x/2,X+R/2),t.rotate(tt),t.translate(-(j+x/2),-(X+R/2))),F){const St=this.createCanvasFill(t,m,x,R);t.fillStyle=St||m;const zt=t.globalAlpha;t.globalAlpha=zt*.8,t.beginPath(),this.drawCustomShape(t,D,q,j,X,x,R,ot)||(t.rect(j,X,x,R),t.fill()),t.globalAlpha=zt}else if(L)t.fillStyle=b?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",t.beginPath(),this.drawCustomShape(t,D,q,j,X,x,R,ot)||(t.rect(j,X,x,R),t.fill());else if(S!=="transparent"){const St=this.createCanvasFill(t,S,x,R);t.fillStyle=St||S,t.beginPath(),this.drawCustomShape(t,D,q,j,X,x,R,ot)||(t.rect(j,X,x,R),t.fill())}if(F||L){const St=this.createCanvasFill(t,m,h==="vertical"?3:x,h==="vertical"?R:3);t.fillStyle=St||m,h==="vertical"?t.fillRect(j,X,3,R):t.fillRect(j,X+R-3,x,3)}const yt=F?"#ffffff":b?"rgba(255, 255, 255, 0.9)":y;t.fillStyle=yt,t.font=F||L?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const bt=typeof G=="string"?G:(G==null?void 0:G.label)||`Item ${N+1}`,gt=j+(h==="vertical"?16:x/2),Et=X+R/2;h==="horizontal"||J==="circular"?t.textAlign="center":t.textAlign="left";const It=J==="circular"?j+x/2:gt;t.fillText(bt,It,Et),t.restore(),_+=(h==="vertical"?c:d)+p}),t.restore(),e.showScrollbar!==!1){const G=(l.length||0)*(h==="vertical"?c:d)+((l.length||0)-1)*p,N=h==="vertical"?n:s,J=e.listLayout||"linear",x=e.containerShape==="circle"||J==="circular";if(G>N||J==="circular"&&l.length>0){const R=e.scrollbarColor||"rgba(255,255,255,0.3)",j=e.scrollbarWidth||4;if(x){const X=Math.min(s,n)/2-j/2-2,tt=a+s/2,L=r+n/2;if(t.strokeStyle=R,t.lineWidth=j,t.lineCap="round",t.beginPath(),J==="circular"){const F=Math.PI/4,D=-(u*.01)-Math.PI/2;t.arc(tt,L,X,D,D+F)}else{const F=Math.PI/2,D=N/G,q=F*D,ot=-u/G*F,bt=-Math.PI/4+ot;t.arc(tt,L,X,bt,bt+q)}t.stroke()}else{const X=N/G,tt=N*X,L=-u/G*N;t.fillStyle=R,h==="vertical"?t.fillRect(a+s-j-2,r+L,j,tt):t.fillRect(a+L,r+n-j-2,tt,j)}}}t.restore()}drawCustomShape(t,i,o,e,s,n,a,r){if(i==="circle"){const f=Math.min(n,a)/2;return t.arc(e+n/2,s+a/2,f,0,Math.PI*2),!1}else if(i==="pill"){const f=Math.min(n,a)/2;return this.drawListViewRect(t,e,s,n,a,f),!1}else if(i==="custom"&&o)try{const f=new Path2D(o);return t.save(),t.translate(e,s),t.scale(n/100,a/100),t.fill(f),t.restore(),!0}catch{return this.drawListViewRect(t,e,s,n,a,r),!1}return this.drawListViewRect(t,e,s,n,a,r),!1}updateListViewScrollFromPointer(t){var b,m;if(!this._lastPointerPos||!this._prevPointerPos)return;const i=t.options||{},o=i.orientation||"vertical",e=this._lastPointerPos.x-this._prevPointerPos.x,s=this._lastPointerPos.y-this._prevPointerPos.y;o==="vertical"?i.scrollOffset=(i.scrollOffset||0)+s:i.scrollOffset=(i.scrollOffset||0)+e;const n=i.listLayout||"linear",a=this.objectStates.get(t.id)||{},r=i.items||[],f=i.itemGap??10,h=i.itemHeight??50,l=i.itemWidth??200,p=a.width!==void 0?a.width:((b=t.geometry)==null?void 0:b.width)||200,c=a.height!==void 0?a.height:((m=t.geometry)==null?void 0:m.height)||300;if(n==="circular")return;const d=(r.length||0)*(o==="vertical"?h:l)+((r.length||0)-1)*f,v=Math.max(0,d-(o==="vertical"?c:p)+(i.padding*2||0));i.scrollOffset>0&&(i.scrollOffset=0),i.scrollOffset<-v&&(i.scrollOffset=-v)}updateListViewHoverFromPointer(t,i,o){const e=this.getListViewItemIndexAtPointer(t,i,o),s=t.options||{};s.hoveredIndex!==e&&(s.hoveredIndex=e)}getListViewItemIndexAtPointer(t,i,o){var z,Y;const e=t.options||{},s=this.objectStates.get(t.id)||{},n=e.items||[];if(n.length===0)return null;const a=s.width!==void 0?s.width:((z=t.geometry)==null?void 0:z.width)||200,r=s.height!==void 0?s.height:((Y=t.geometry)==null?void 0:Y.height)||300,f=e.orientation||"vertical",h=e.itemGap??10,l=e.itemHeight??50,p=e.itemWidth??200,c=e.scrollOffset??0,d=e.padding??0,u=this.getWorldTransform(t.id),v=i-u.x,b=o-u.y,m=-u.rotation*(Math.PI/180),y=Math.cos(m),S=Math.sin(m),C=v*y-b*S,w=v*S+b*y,M=-a/2,I=-r/2,k=typeof d=="number"?d:f==="vertical"?d[0]:d[3];let T=(f==="vertical"?I:M)+c+k;const O=e.listLayout||"linear",P=n.length||1,_=Math.PI*2/P,E=e.circularStartAngle||0,A=e.circularRadius||100,W=c*.01+E*Math.PI/180;for(let G=0;G<n.length;G++){const N=O==="circular"?p:f==="vertical"?a:p,J=O==="circular"||f==="vertical"?l:r;let x=0,R=0,j=0;if(O==="circular"){const X=G*_+W,tt=M+a/2,L=I+r/2;x=tt+Math.cos(X)*A-N/2,R=L+Math.sin(X)*A-J/2,j=X+(e.itemRotation||0)*Math.PI/180}else x=f==="vertical"?M:T,R=f==="vertical"?T:I,j=(e.itemRotation||0)*Math.PI/180;if(j!==0){const X=x+N/2,tt=R+J/2,L=C-X,F=w-tt,D=-j,q=L*Math.cos(D)-F*Math.sin(D)+X,ot=L*Math.sin(D)+F*Math.cos(D)+tt;if(q>=x&&q<=x+N&&ot>=R&&ot<=R+J)return G}else if(C>=x&&C<=x+N&&w>=R&&w<=R+J)return G;T+=(f==="vertical"?l:p)+h}return null}drawListViewRect(t,i,o,e,s,n){t.beginPath(),this.drawRoundRect(t,i,o,e,s,n),t.fill()}solveBehaviors(t){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:i,y:o}=this._lastPointerPos;this.artboard.objects.forEach(e=>{if(!e.behaviors||e.behaviors.length===0)return;const s=this.objectStates.get(e.id);s&&e.behaviors.forEach(n=>{var p,c,d,u,v,b,m,y,S,C,w,M,I,k,T,O,P,_,E,A,W,z,Y,G,N,J,x,R,j,X,tt,L,F,D,q,ot,yt,bt,gt,Et,It,St,zt,he,pe,et,mt,Ft,_t,dt,$t,Vt,Bt,Rt,Ut,ae,be,ve,Zt,Ce,_e,Pe,we,Ee,Ae,oe,se,ft,pt,at,B,nt,Z,Pt,Ot,kt,At,Mt,$,Yt,jt,ie,te,ut,ct,Ct,rt,V,st,it,vt,Dt,ee,re,Nt,Kt,qt,Ie,xe,Oe,Le,Fe,Re,Xe,Ht,le,Me,$e,Be,ge,de,ue,ke,De,qe,Ke,Ge,Je;if(!n.enabled)return;const a=n.startTime||0,r=n.endTime||1/0;if(this.currentTime<a||this.currentTime>r)return;const f=s.x-i,h=s.y-o,l=Math.sqrt(f*f+h*h);if(this.frameCount%240===0&&Math.random()<.1&&this.log(`[ExodeUI] Executing ${n.type} on ${e.name}`),n.type===H.Proximity){const U=((p=n.settings)==null?void 0:p.radius)||300,Q=((c=n.settings)==null?void 0:c.falloff)||"smooth";let K=0;l<U&&(Q==="linear"?K=1-l/U:K=Math.pow(1-l/U,2)),n.sensors.forEach(ht=>{this.applyBehaviorSensor(s,ht,K,t,n.settings,e,f,h,l)})}else if(n.type===H.Magnetic){const U=((d=n.settings)==null?void 0:d.radius)||400,Q=((u=n.settings)==null?void 0:u.strength)||.5;if(l<U&&l>5){const K=1-l/U,ht=f*K*Q,Tt=h*K*Q;s.x-=ht*t*10,s.y-=Tt*t*10}}else if(n.type===H.Repel){const U=((v=n.settings)==null?void 0:v.radius)||300,Q=((b=n.settings)==null?void 0:b.strength)||1;if(l<U){const K=Math.pow(1-l/U,2);s.x+=f/(l||1)*K*60*Q*t*5,s.y+=h/(l||1)*K*60*Q*t*5}}else if(n.type===H.Orbit){const U=((m=n.settings)==null?void 0:m.speed)||1,Q=((y=n.settings)==null?void 0:y.radius)||30,K=this.currentTime*U*Math.PI*2;s.x+=Math.cos(K)*Q*t*5,s.y+=Math.sin(K)*Q*t*5,s.rotation+=2*t*5}else if(n.type===H.Vortex){const U=((S=n.settings)==null?void 0:S.radius)||400,Q=((C=n.settings)==null?void 0:C.speed)||2,K=((w=n.settings)==null?void 0:w.strength)||1;if(l<U){const ht=Math.pow(1-l/U,1.5),Tt=this.currentTime*Q*Math.PI*2,Lt=Math.cos(Tt)*30-f*.4,Wt=Math.sin(Tt)*30-h*.4;s.x+=Lt*ht*K*t*5,s.y+=Wt*ht*K*t*5,s.rotation+=5*ht*K*t*5,s.scale_x*=1-ht*.1*K*t,s.scale_y*=1-ht*.1*K*t}}else if(n.type===H.Fluid){const U=((M=n.settings)==null?void 0:M.radius)||300,Q=((I=n.settings)==null?void 0:I.strength)||1;if(l<U){const K=Math.pow(1-l/U,1.2),ht=f/(l||1)*K*1.2*Q,Tt=h/(l||1)*K*1.2*Q;s.x+=ht*10*t*5,s.y+=Tt*10*t*5,s.scale_x*=1+K*.3*Q*t,s.scale_y*=1+K*.3*Q*t}}else if(n.type===H.Elastic){const U=((k=n.settings)==null?void 0:k.radius)||300,Q=((T=n.settings)==null?void 0:T.strength)||1;if(l<U){const K=1-l/U;s.scale_x*=1+K*.4*Q*t,s.scale_y*=1+K*.4*Q*t}}else if(n.type===H.Holographic){const U=s.x-this.canvasWidth/2,Q=s.y-this.canvasHeight/2,K=((O=n.settings)==null?void 0:O.factor)||25;if(s.x-=U/1e3*K*t*5,s.y-=Q/1e3*K*t*5,s.style){const ht=1-Math.min(1,l/400);s.style.exposure=(s.style.exposure||1)+ht*.5*t}}else if(n.type===H.Sticky){const U=((P=n.settings)==null?void 0:P.radius)||80,Q=((_=n.settings)==null?void 0:_.strength)||1;if(l<U){const K=Math.pow(1-l/U,2);s.x-=f*K*Q*t*10,s.y-=h*K*Q*t*10,s.scale_x*=1-K*.1*Q*t,s.scale_y*=1-K*.1*Q*t}}else if(n.type===H.Dilation){const U=((E=n.settings)==null?void 0:E.size)||120,Q=((A=n.settings)==null?void 0:A.strength)||1;if(l<U){const K=1-l/U;s.scale_x*=1+K*.5*Q*t,s.scale_y*=1+K*.5*Q*t}}else if(n.type===H.Parallax){const U=((W=n.settings)==null?void 0:W.factor)||15,Q=((z=n.settings)==null?void 0:z.strength)||1,K=this.canvasWidth/2,ht=this.canvasHeight/2,Tt=this._lastPointerPos||{x:K,y:ht},Lt=(Tt.x-K)/K,Wt=(Tt.y-ht)/ht,ne=(((Y=e.transform)==null?void 0:Y.x)??0)+Lt*U*Q,me=(((G=e.transform)==null?void 0:G.y)??0)+Wt*U*Q,Te=(((N=e.transform)==null?void 0:N.rotate_x)??0)-Wt*U*1.5*Q,ce=(((J=e.transform)==null?void 0:J.rotate_y)??0)+Lt*U*1.5*Q,Se=Math.min(1,10*t);s.x=this.lerp(s.x??((x=e.transform)==null?void 0:x.x)??0,ne,Se),s.y=this.lerp(s.y??((R=e.transform)==null?void 0:R.y)??0,me,Se),s.rotate_x=this.lerp(s.rotate_x??((j=e.transform)==null?void 0:j.rotate_x)??0,Te,Se),s.rotate_y=this.lerp(s.rotate_y??((X=e.transform)==null?void 0:X.rotate_y)??0,ce,Se)}else if(n.type===H.Fold){if(l<300){const U=1-l/300,Q=(f>0?-1:1)*U*10,K=1-U*.1,ht=h/300*U*20,Tt=-(f/300)*U*20,Lt=Math.min(1,10*t);s.skew_x=this.lerp(s.skew_x??((tt=e.transform)==null?void 0:tt.skew_x)??0,Q,Lt),s.scale_y=this.lerp(s.scale_y??((L=e.transform)==null?void 0:L.scale_y)??1,(((F=e.transform)==null?void 0:F.scale_y)??1)*K,Lt),s.rotate_x=this.lerp(s.rotate_x??((D=e.transform)==null?void 0:D.rotate_x)??0,ht,Lt),s.rotate_y=this.lerp(s.rotate_y??((q=e.transform)==null?void 0:q.rotate_y)??0,Tt,Lt),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((ot=n.settings)==null?void 0:ot.opacity)??.5}}}else if(n.type===H.Crumple){if(l<300){const U=1-l/300,Q=U*(Math.random()-.5)*5,K=U*(Math.random()-.5)*.05,ht=Math.min(1,15*t);s.skew_x=this.lerp(s.skew_x??((yt=e.transform)==null?void 0:yt.skew_x)??0,Q,ht),s.scale_x=this.lerp(s.scale_x??((bt=e.transform)==null?void 0:bt.scale_x)??1,(((gt=e.transform)==null?void 0:gt.scale_x)??1)*(1+K),ht),s.scale_y=this.lerp(s.scale_y??((Et=e.transform)==null?void 0:Et.scale_y)??1,(((It=e.transform)==null?void 0:It.scale_y)??1)*(1+K),ht),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((St=n.settings)==null?void 0:St.intensity)??1,scale:((zt=n.settings)==null?void 0:zt.scale)??2}}}else if(n.type===H.Squash){const U=((he=n.settings)==null?void 0:he.strength)||.8;l<(e.width||100)&&this.isMouseDown?(s.scale_y=this.lerp(s.scale_y??1,(((pe=e.transform)==null?void 0:pe.scale_y)??1)*U,.3),s.scale_x=this.lerp(s.scale_x??1,(((et=e.transform)==null?void 0:et.scale_x)??1)*(1+(1-U)*.4),.3)):(s.scale_y=this.lerp(s.scale_y??1,((mt=e.transform)==null?void 0:mt.scale_y)??1,.2),s.scale_x=this.lerp(s.scale_x??1,((Ft=e.transform)==null?void 0:Ft.scale_x)??1,.2))}else if(n.type===H.TextCounter){const U=((_t=n.settings)==null?void 0:_t.duration)||2,Q=((dt=n.settings)==null?void 0:dt.from)||0,K=(($t=n.settings)==null?void 0:$t.to)||100;n._runtimeStart===void 0&&(n._runtimeStart=this.currentTime);const ht=this.currentTime-n._runtimeStart,Tt=Math.min(1,ht/U),Lt=Math.floor(Q+(K-Q)*Tt);if(((Vt=e.geometry)==null?void 0:Vt.type)==="Text"){const Wt=((Bt=n.settings)==null?void 0:Bt.prefix)||"",ne=((Rt=n.settings)==null?void 0:Rt.suffix)||"";s.geometry||(s.geometry={...e.geometry}),s.geometry.text=`${Wt}${Lt}${ne}`}}else if(n.type===H.Spotlight){const U=((Ut=n.settings)==null?void 0:Ut.radius)||250,Q=((ae=n.settings)==null?void 0:ae.strength)||1.5;if(l<U){const K=Math.pow(1-l/U,2);s.style||(s.style={...e.style}),s.style.adjustments||(s.style.adjustments={...(be=e.style)==null?void 0:be.adjustments}),s.style.adjustments.exposure=(((Zt=(ve=e.style)==null?void 0:ve.adjustments)==null?void 0:Zt.exposure)||0)+K*Q*50}else(Ce=s.style)!=null&&Ce.adjustments&&(s.style.adjustments.exposure=this.lerp(s.style.adjustments.exposure||0,((Pe=(_e=e.style)==null?void 0:_e.adjustments)==null?void 0:Pe.exposure)||0,.1))}else if(n.type===H.Noise||n.type===H.Float){const U=(((we=n.settings)==null?void 0:we.frequency)||((Ee=n.settings)==null?void 0:Ee.speed)||1)*.002,Q=(((Ae=n.settings)==null?void 0:Ae.amplitude)||((oe=n.settings)==null?void 0:oe.range)||50)*(((se=n.settings)==null?void 0:se.strength)||1),K=Date.now();s.x+=Math.sin(K*U)*Q*t,s.y+=Math.cos(K*U*.8)*Q*t,s.rotation+=Math.sin(K*U*.5)*5*t}else if(n.type===H.Pulse){const U=(((ft=n.settings)==null?void 0:ft.speed)||1)*.005,Q=(((pt=n.settings)==null?void 0:pt.scale)||1.2)-1,K=Math.sin(Date.now()*U),ht=((at=n.settings)==null?void 0:at.strength)||1;s.scale_x*=1+K*Q*ht*t,s.scale_y*=1+K*Q*ht*t,s.style&&(s.style.exposure=(s.style.exposure||1)+Math.max(0,K)*.1*ht*t)}else if(n.type===H.Draggable){const U=((B=n.settings)==null?void 0:B.radius)||150,Q=this.draggingBehaviors.has(e.id);if(l<U||Q){const K=((nt=n.settings)==null?void 0:nt.strength)||1,ht=Q?1:Math.max(0,1-l/U);this.applyBehaviorSensor(s,Qt.PositionX,ht*K,t,n.settings),this.applyBehaviorSensor(s,Qt.PositionY,ht*K,t,n.settings)}}else if(n.type===H.Scroll){const U=((Z=n.settings)==null?void 0:Z.axis)||"vertical",Q=((Pt=n.settings)==null?void 0:Pt.factor)||.5,K=((Ot=n.settings)==null?void 0:Ot.strength)||1,ht=((kt=n.settings)==null?void 0:kt.scaleFactor)||0;(U==="vertical"||U==="both")&&(s.y+=this.scrollOffset.y*Q*K*t),(U==="horizontal"||U==="both")&&(s.x+=this.scrollOffset.x*Q*K*t),ht!==0&&(s.scale_x*=1+this.scrollOffset.y*ht*t,s.scale_y*=1+this.scrollOffset.y*ht*t)}else if(n.type===H.LookAt){const U=((At=n.settings)==null?void 0:At.factor)||1,Q=((Mt=n.settings)==null?void 0:Mt.strength)||1,K=Math.atan2(-h,-f)*(180/Math.PI),ht=s.rotation,Tt=(K-ht+180)%360-180;s.rotation+=Tt*U*Q*t*10}else if(n.type===H.Scan){const U=((($=n.settings)==null?void 0:$.speed)||1)*.004,Q=((Yt=n.settings)==null?void 0:Yt.strength)||1,K=(Math.sin(Date.now()*U)+1)/2;s.style&&(s.style.exposure=(s.style.exposure||1)+K*Q*t*5),s.x+=(K-.5)*20*Q*t}else if(n.type===H.Glint)s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"glint_overlay",intensity:((jt=n.settings)==null?void 0:jt.strength)??.8};else if(n.type===H.Ratchet){const U=((ie=n.settings)==null?void 0:ie.steps)||12,Q=(((te=n.settings)==null?void 0:te.speed)||1)*30,K=Math.floor(s.rotation/(360/U))*(360/U);s.rotation=this.lerp(s.rotation,K+Q*t,.1)}else if(n.type===H.Jitter&&l<300){const U=((ut=n.settings)==null?void 0:ut.strength)||1,Q=(((ct=n.settings)==null?void 0:ct.intensity)||5)*U;s.x+=(Math.random()-.5)*Q*t*60,s.y+=(Math.random()-.5)*Q*t*60,s.rotation+=(Math.random()-.5)*Q*t*120}else if(n.type===H.Follower){const U=(Ct=n.settings)==null?void 0:Ct.targetId;if(U){const Q=this.objectStates.get(U);if(Q){const K=((rt=n.settings)==null?void 0:rt.stiffness)||.1,ht=Q.x-s.x,Tt=Q.y-s.y;s.x+=ht*K*t*60,s.y+=Tt*K*t*60}}}else if(n.type===H.Wrap)s.x<0?s.x=this.canvasWidth:s.x>this.canvasWidth&&(s.x=0),s.y<0?s.y=this.canvasHeight:s.y>this.canvasHeight&&(s.y=0);else if(n.type===H.Gravity){const U=((V=n.settings)==null?void 0:V.strength)||9.8;s.y+=U*t*10}else if(n.type===H.Velocity){const U=((st=n.settings)==null?void 0:st.vx)||0,Q=((it=n.settings)==null?void 0:it.vy)||0;s.x+=U*t*10,s.y+=Q*t*10}else if(n.type===H.Shear){const U=((vt=n.settings)==null?void 0:vt.strength)||1,Q=((Dt=n.settings)==null?void 0:Dt.radius)||300;if(l<Q){const K=1-l/Q;s.skew_x=this.lerp(s.skew_x||0,(((ee=e.transform)==null?void 0:ee.skew_x)||0)+K*U*30,.1)}else s.skew_x=this.lerp(s.skew_x||0,((re=e.transform)==null?void 0:re.skew_x)||0,.05)}else if(n.type===H.Lens){const U=((Nt=n.settings)==null?void 0:Nt.radius)||200,Q=((Kt=n.settings)==null?void 0:Kt.strength)||.5;if(l<U){const K=Math.pow(1-l/U,2);s.scale_x=this.lerp(s.scale_x??1,(((qt=e.transform)==null?void 0:qt.scale_x)??1)*(1+K*Q),.2),s.scale_y=this.lerp(s.scale_y??1,(((Ie=e.transform)==null?void 0:Ie.scale_y)??1)*(1+K*Q),.2)}else s.scale_x=this.lerp(s.scale_x??1,((xe=e.transform)==null?void 0:xe.scale_x)??1,.1),s.scale_y=this.lerp(s.scale_y??1,((Oe=e.transform)==null?void 0:Oe.scale_y)??1,.1)}else if(n.type===H.LayoutAnimation){const U=((Le=n.settings)==null?void 0:Le.watchProperties)||["x","y","scale_x","scale_y","opacity","rotation"],Q=((Fe=n.settings)==null?void 0:Fe.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const K=this._layoutAnimCache.get(e.id);for(const ht of U){const Tt=this.getObjectProperty(s,e,ht);if(Tt===void 0)continue;const Lt=K.get(ht);if(!Lt)K.set(ht,{from:Tt,to:Tt,startTime:this.currentTime,duration:0});else if(Lt.to!==Tt){const ne=this.getObjectProperty(s,e,ht);K.set(ht,{from:ne??Lt.from,to:Tt,startTime:this.currentTime,duration:((Re=n.settings)==null?void 0:Re.duration)??Q})}const Wt=K.get(ht);if(Wt.duration>0&&Wt.from!==Wt.to){const ne=this.currentTime-Wt.startTime,me=Math.min(1,ne/Wt.duration),Te=this.applyEasing(me,((Xe=n.settings)==null?void 0:Xe.easing)||"easeOutCubic"),ce=Wt.from+(Wt.to-Wt.from)*Te;this.setObjectProperty(s,e,ht,ce)}}}else if(n.type===H.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const U=this._layoutAnimCache.get(e.id),Q=((Ht=n.settings)==null?void 0:Ht.defaultDuration)||.3,K=["x","y","scale_x","scale_y","opacity","rotation","style.fill.color","style.stroke.width","geometry.cornerRadius","style.blur.value","style.shadow.blur","style.shadow.offsetX","style.shadow.offsetY"];for(const ht of K){const Tt=this.getObjectProperty(s,e,ht);if(Tt===void 0||typeof Tt!="number")continue;const Lt=U.get(ht);if(!Lt)U.set(ht,{from:Tt,to:Tt,startTime:this.currentTime,duration:0});else if(Lt.to!==Tt){const ne=this.getObjectProperty(s,e,ht);U.set(ht,{from:ne??Lt.from,to:Tt,startTime:this.currentTime,duration:Q})}const Wt=U.get(ht);if(Wt.duration>0&&Wt.from!==Wt.to){const ne=this.currentTime-Wt.startTime,me=Math.min(1,ne/Wt.duration),Te=this.applyEasing(me,((le=n.settings)==null?void 0:le.defaultEasing)||"easeOutCubic"),ce=Wt.from+(Wt.to-Wt.from)*Te;this.setObjectProperty(s,e,ht,ce)}}}else if(n.type===H.SpringChain){const U=((Me=n.settings)==null?void 0:Me.connections)||[],Q=(($e=n.settings)==null?void 0:$e.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const K=this._springChainState.get(e.id);for(const Tt of U){if(!K.has(Tt.targetId)){const Lt=this.objectStates.get(Tt.targetId);K.set(Tt.targetId,{x:(Lt==null?void 0:Lt.x)??0,y:(Lt==null?void 0:Lt.y)??0,vx:0,vy:0})}K.has(e.id)||K.set(e.id,{x:s.x,y:s.y,vx:0,vy:0})}const ht=K.get(e.id);if(ht){ht.x=s.x,ht.y=s.y;for(const Tt of U){const Lt=K.get(Tt.targetId);if(!Lt)continue;const Wt=Lt.x-ht.x,ne=Lt.y-ht.y,me=Math.sqrt(Wt*Wt+ne*ne)||.001,ce=(me-(Tt.restLength||50))*(Tt.stiffness||.8),Se=Wt/me*ce,Qe=ne/me*ce;ht.vx+=Se*t*10,ht.vy+=Qe*t*10,Lt.vx-=Se*t*10,Lt.vy-=Qe*t*10,ht.vx*=1-Q*t*10,ht.vy*=1-Q*t*10,Lt.vx*=1-Q*t*10,Lt.vy*=1-Q*t*10;const ye=this.objectStates.get(Tt.targetId);ye&&(ye.x+=Lt.vx*t,ye.y+=Lt.vy*t)}s.x+=ht.vx*t,s.y+=ht.vy*t}}else if(n.type===H.ParticleEmitter){const U=((Be=n.settings)==null?void 0:Be.rate)||10,Q=((ge=n.settings)==null?void 0:ge.speed)||100,K=((de=n.settings)==null?void 0:de.size)||5,ht=((ue=n.settings)==null?void 0:ue.lifetime)||2,Tt=((ke=n.settings)==null?void 0:ke.gravity)||0,Lt=((De=n.settings)==null?void 0:De.color)||"#ffffff",Wt=((qe=n.settings)==null?void 0:qe.maxParticles)||200,ne=(Ke=n.settings)!=null&&Ke.rateInputId?this.inputs.get(n.settings.rateInputId)??U:U,me=(Ge=n.settings)!=null&&Ge.gravityInputId?this.inputs.get(n.settings.gravityInputId)??Tt:Tt,Te=(Je=n.settings)!=null&&Je.speedInputId?this.inputs.get(n.settings.speedInputId)??Q:Q;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const ce=this._emitterPools.get(e.id);let Se=0;n._pendingBurst&&n._pendingBurst>0&&(Se=n._pendingBurst,n._pendingBurst=0);const Qe=Math.floor(ne*t)+(Se||0);for(let ye=0;ye<Math.min(Qe,Wt-ce.length);ye++){const fe=Math.random()*Math.PI*2,ys=Te*(.5+Math.random()*.5);ce.push({x:s.x,y:s.y,vx:Math.cos(fe)*ys,vy:Math.sin(fe)*ys,life:0,maxLife:ht*(.5+Math.random()*.5),size:K*(.5+Math.random()),color:Lt,opacity:1})}for(let ye=ce.length-1;ye>=0;ye--){const fe=ce[ye];fe.vy+=me*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(ye,1)}}})})}applyBehaviorSensor(t,i,o,e,s,n,a=0,r=0,f=1){var d,u,v,b,m,y,S,C,w,M,I,k,T,O,P,_,E,A,W,z,Y,G,N,J;const h=(s==null?void 0:s.intensity)||(s==null?void 0:s.strength)||1,l=Math.min(1,15*e),p=f>0?a/f:0,c=f>0?r/f:0;switch(i){case Qt.Scale:{const x=((d=n==null?void 0:n.transform)==null?void 0:d.scale_x)??1,R=((u=n==null?void 0:n.transform)==null?void 0:u.scale_y)??1,j=x*(1+o*h*.4),X=R*(1+o*h*.4);t.scale_x=(t.scale_x??x)*(1-l)+j*l,t.scale_y=(t.scale_y??R)*(1-l)+X*l;break}case Qt.Opacity:{const x=((v=n==null?void 0:n.transform)==null?void 0:v.opacity)??100,R=Math.max(0,Math.min(100,x-o*h*100));t.opacity=(t.opacity??x)*(1-l)+R*l;break}case Qt.RotateZ:{const x=((b=n==null?void 0:n.transform)==null?void 0:b.rotation)??0,R=x+o*h*45;t.rotation=(t.rotation??x)*(1-l)+R*l;break}case Qt.RotateX:{const x=((m=n==null?void 0:n.transform)==null?void 0:m.rotate_x)??0,R=x-c*o*h*60;t.rotate_x=(t.rotate_x??x)*(1-l)+R*l;break}case Qt.RotateY:{const x=((y=n==null?void 0:n.transform)==null?void 0:y.rotate_y)??0,R=x+p*o*h*60;t.rotate_y=(t.rotate_y??x)*(1-l)+R*l;break}case Qt.PositionX:{const x=((S=n==null?void 0:n.transform)==null?void 0:S.x)??0,R=x-p*o*h*40;t.x=(t.x??x)*(1-l)+R*l;break}case Qt.PositionY:{const x=((C=n==null?void 0:n.transform)==null?void 0:C.y)??0,R=x-c*o*h*40;t.y=(t.y??x)*(1-l)+R*l;break}case Qt.SkewX:{const x=((w=n==null?void 0:n.transform)==null?void 0:w.skew_x)??0,R=x+p*o*h*45;t.skew_x=(t.skew_x??x)*(1-l)+R*l,t.skew_x>85&&(t.skew_x=85),t.skew_x<-85&&(t.skew_x=-85);break}case Qt.Blur:{t.style||(t.style={...n==null?void 0:n.style}),t.style.blur||(t.style.blur={...(M=n==null?void 0:n.style)==null?void 0:M.blur});const x=((k=(I=n==null?void 0:n.style)==null?void 0:I.blur)==null?void 0:k.amount)||0,R=x+o*((s==null?void 0:s.blur)||20)*h;t.style.blur.amount=(t.style.blur.amount??x)*(1-l)+R*l;break}case Qt.Exposure:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(T=n==null?void 0:n.style)==null?void 0:T.adjustments});const x=((P=(O=n==null?void 0:n.style)==null?void 0:O.adjustments)==null?void 0:P.exposure)||0,R=x+o*((s==null?void 0:s.exposure)||50)*h;t.style.adjustments.exposure=(t.style.adjustments.exposure??x)*(1-l)+R*l;break}case Qt.HueShift:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(_=n==null?void 0:n.style)==null?void 0:_.adjustments});const x=((A=(E=n==null?void 0:n.style)==null?void 0:E.adjustments)==null?void 0:A.hue)||0,R=x+o*((s==null?void 0:s.hue)||180)*h;t.style.adjustments.hue=(t.style.adjustments.hue??x)*(1-l)+R*l;break}case Qt.Negative:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(W=n==null?void 0:n.style)==null?void 0:W.adjustments});const x=((Y=(z=n==null?void 0:n.style)==null?void 0:z.adjustments)==null?void 0:Y.negative)||0,R=x+o*((s==null?void 0:s.negative)||100)*h;t.style.adjustments.negative=(t.style.adjustments.negative??x)*(1-l)+R*l;break}case Qt.CornerRadius:{const x=((G=n==null?void 0:n.transform)==null?void 0:G.corner_radius)||0,R=x+o*h*50;t.corner_radius=(t.corner_radius??x)*(1-l)+R*l;break}case Qt.StrokeWidth:{t.style||(t.style={...n==null?void 0:n.style});const x=((N=n==null?void 0:n.style)==null?void 0:N.borderWidth)||0,R=x+o*h*10;t.style.borderWidth=(t.style.borderWidth??x)*(1-l)+R*l;break}case Qt.LetterSpacing:{t.geometry||(t.geometry={});const x=((J=n==null?void 0:n.geometry)==null?void 0:J.letterSpacing)||0,R=x+o*h*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??x)*(1-l)+R*l;break}}}getObjectProperty(t,i,o){const e=o.split(".");let s=t;for(const n of e){if(s==null||typeof s!="object")return;if(n==="style"&&t.style===void 0){s=i.style;continue}s=s[n]}return typeof s=="number"?s:void 0}setObjectProperty(t,i,o,e){const s=o.split(".");let n=t;for(let r=0;r<s.length-1;r++){const f=s[r];if(n[f]===void 0||n[f]===null){const h=i,l=s.slice(0,r+1).reduce((p,c)=>p==null?void 0:p[c],h);n[f]=l!==void 0?{...l}:{}}n=n[f]}const a=s[s.length-1];n!=null&&(n[a]=e)}applyEasing(t,i){switch(i){case"easeOutCubic":return 1-Math.pow(1-t,3);case"easeInCubic":return t*t*t;case"easeInOutCubic":return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;case"easeOutQuad":return t*(2-t);case"easeInQuad":return t*t;case"easeInOutQuad":return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2;case"easeOutExpo":return t===1?1:1-Math.pow(2,-10*t);case"easeOutBack":return 1+2.70158*Math.pow(t-1,3)+1.70158*Math.pow(t-1,2);case"easeOutElastic":{const o=2*Math.PI/3;return t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*o)+1}case"easeOutBounce":return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375;case"linear":return t;default:return 1-Math.pow(1-t,3)}}lerp(t,i,o){return t*(1-o)+i*o}deepMerge(t,i){if(!t)return i;if(!i)return t;if(typeof t!="object"||typeof i!="object"||t===null||i===null)return i;const o={...t};for(const e in i)Object.prototype.hasOwnProperty.call(i,e)&&(i[e]&&typeof i[e]=="object"&&!Array.isArray(i[e])?o[e]=this.deepMerge(t[e],i[e]):o[e]=i[e]);return o}renderFittedImage(t,i,o,e,s,n,a="cover"){const r=i.naturalWidth,f=i.naturalHeight,h=r/f,l=s/n;let p=s,c=n,d=o,u=e;a==="cover"?h>l?(p=n*h,d=o-(p-s)/2):(c=s/h,u=e-(c-n)/2):a==="contain"&&(h>l?(c=s/h,u=e+(n-c)/2):(p=n*h,d=o+(s-p)/2)),t.drawImage(i,d,u,p,c)}}const ni=xt.forwardRef(({artboard:g,src:t,style:i,autoPlay:o=!0,fit:e="Contain",alignment:s="Center",onReady:n,onTrigger:a,onInputUpdate:r,onComponentChange:f,onToggle:h,onInputChange:l,onInputFocus:p,onInputBlur:c,onLog:d,onLogicUpdate:u,onButtonClick:v,onGraphPointClick:b,currentTime:m,revision:y=0,scrollY:S,scrollX:C,mouseX:w,mouseY:M,isMouseDown:I,inputs:k,interactive:T=!0,onNavigation:O},P)=>{const _=xt.useRef(null),E=xt.useRef(null);E.current||(E.current=new ms);const A=xt.useRef(void 0),W=xt.useRef(0),z=xt.useRef(null),Y=xt.useRef(y),G=xt.useRef(null),[,N]=xt.useState(g||null),J=xt.useRef(!0);xt.useImperativeHandle(P,()=>_.current),xt.useEffect(()=>(J.current=!0,()=>{J.current=!1,A.current&&cancelAnimationFrame(A.current)}),[]),xt.useEffect(()=>{E.current.setLayout(e,s)},[e,s]),xt.useEffect(()=>{const L=E.current;a&&L.setTriggerCallback(a),r&&L.setInputUpdateCallback((F,D)=>r({[F]:D})),f&&L.setComponentChangeCallback(F=>f(F)),h&&L.setToggleCallback(h),l&&L.setInputChangeCallback(l),p&&L.setInputFocusCallback(p),c&&L.setInputBlurCallback(c),d&&L.setOnLogCallback(F=>d(F,"info")),u&&L.setLogicUpdateCallback(u),v&&L.setButtonClickCallback(v),b&&L.setGraphPointClickCallback(F=>b(F.objectId,F)),O&&L.setNavigationCallback(O)},[a,r,f,h,l,p,c,d,u,v,b,O]),xt.useEffect(()=>{(async()=>{let F=g;if(t&&!g)try{t.startsWith("{")?F=JSON.parse(t):F=await(await fetch(t)).json()}catch(D){console.error("[ExodeUI] Failed to load src:",D)}if(F){const D=E.current,q=F.id||F.name||"default";(z.current!==q||Y.current!==y||G.current!==F)&&(D.load(F),z.current=q,Y.current=y,G.current=F,N(F),W.current=0,D.advance(0)),n&&n(D)}})()},[g,t,y]),xt.useEffect(()=>{const L=F=>{if(!E.current||!J.current)return;const D=E.current,q=_.current;if(!q)return;const ot=q.getContext("2d");if(!ot)return;const yt=F/1e3;W.current===0&&(W.current=yt);let bt=yt-W.current;bt>.1&&(bt=.1),W.current=yt;const gt=q.getBoundingClientRect(),Et=window.devicePixelRatio||1,It=Math.round(gt.width*Et),St=Math.round(gt.height*Et);(q.width!==It||q.height!==St)&&(q.width=It,q.height=St);try{o?D.advance(bt):m!==void 0&&D.seek(m),D.render(ot,q.width,q.height)}catch(zt){console.error("[ExodeUICanvas] Error in animation loop:",zt),d&&d(`[Error] Animation loop crashed: ${zt}`,"error")}A.current=requestAnimationFrame(L)};return A.current=requestAnimationFrame(L),()=>{A.current&&cancelAnimationFrame(A.current)}},[o,m]),xt.useEffect(()=>{const L=E.current;S!==void 0&&L.updateInput("scrollY",S),C!==void 0&&L.updateInput("scrollX",C),w!==void 0&&L.updateInput("mouseX",w),M!==void 0&&L.updateInput("mouseY",M),I!==void 0&&L.updateInput("isMouseDown",I),k&&Object.entries(k).forEach(([F,D])=>L.updateInput(F,D))},[S,C,w,M,I,k]);const x=(L,F)=>{if(!T||!_.current)return;L.stopPropagation(),"nativeEvent"in L&&L.nativeEvent&&typeof L.nativeEvent.stopImmediatePropagation=="function"?L.nativeEvent.stopImmediatePropagation():typeof L.stopImmediatePropagation=="function"&&L.stopImmediatePropagation();const D=_.current,q=D.getBoundingClientRect(),ot=L.clientX-q.left,yt=L.clientY-q.top,bt=window.devicePixelRatio||1;(F==="click"||F==="down"||F==="up")&&d&&d(`[Canvas] Pointer ${F} at rect(${Math.round(ot)},${Math.round(yt)}) mapped to buffer(${Math.round(ot*bt)},${Math.round(yt*bt)})`,"info"),E.current.handlePointerInput(F,ot*bt,yt*bt,D.width,D.height)};xt.useEffect(()=>{if(!T)return;const L=D=>{var q,ot,yt;((q=document.activeElement)==null?void 0:q.tagName)==="INPUT"||((ot=document.activeElement)==null?void 0:ot.tagName)==="TEXTAREA"||(yt=E.current)==null||yt.handleKeyDown(D)},F=D=>{var q,ot,yt;((q=document.activeElement)==null?void 0:q.tagName)==="INPUT"||((ot=document.activeElement)==null?void 0:ot.tagName)==="TEXTAREA"||(yt=E.current)==null||yt.handleKeyUp(D)};return window.addEventListener("keydown",L),window.addEventListener("keyup",F),()=>{window.removeEventListener("keydown",L),window.removeEventListener("keyup",F)}},[T]);const[R,j]=xt.useState([]);xt.useEffect(()=>{if(g&&g.objects){const L=g.objects.filter(F=>{var D,q;return F.type==="Joystick"&&((D=F.inputBinding)==null?void 0:D.type)==="keyboard"&&((q=F.inputBinding.keyboardConfig)==null?void 0:q.showVirtualKeyboard)});j(L)}},[g]);const[,X]=xt.useState(0);xt.useEffect(()=>{if(R.length===0)return;let L;const F=()=>{X(D=>D+1),L=requestAnimationFrame(F)};return L=requestAnimationFrame(F),()=>cancelAnimationFrame(L)},[R.length]);const tt=()=>R.map(L=>{const F=L.inputBinding.keyboardConfig,D=gt=>{var It;const Et={key:gt,code:gt,preventDefault:()=>{}};(It=E.current)==null||It.handleKeyDown(Et)},q=gt=>{var It;const Et={key:gt,code:gt,preventDefault:()=>{}};(It=E.current)==null||It.handleKeyUp(Et)},ot=E.current,yt=gt=>ot&&ot.activeKeys?ot.activeKeys.has(gt.toLowerCase()):!1,bt=gt=>({width:"50px",height:"50px",background:gt?"rgba(255, 255, 255, 0.4)":"rgba(0, 0, 0, 0.4)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontWeight:"bold",fontSize:"18px",userSelect:"none",cursor:"pointer",backdropFilter:"blur(8px)",transition:"background 0.1s",boxShadow:gt?"none":"0 4px 6px rgba(0,0,0,0.1)"});return Xt.jsxs("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",pointerEvents:"auto",zIndex:100},children:[Xt.jsx("div",{style:bt(yt(F.upKey)),onMouseDown:()=>D(F.upKey),onMouseUp:()=>q(F.upKey),onMouseLeave:()=>q(F.upKey),onTouchStart:gt=>{gt.preventDefault(),D(F.upKey)},onTouchEnd:gt=>{gt.preventDefault(),q(F.upKey)},children:F.upKey.toUpperCase()}),Xt.jsxs("div",{style:{display:"flex",gap:"8px"},children:[Xt.jsx("div",{style:bt(yt(F.leftKey)),onMouseDown:()=>D(F.leftKey),onMouseUp:()=>q(F.leftKey),onMouseLeave:()=>q(F.leftKey),onTouchStart:gt=>{gt.preventDefault(),D(F.leftKey)},onTouchEnd:gt=>{gt.preventDefault(),q(F.leftKey)},children:F.leftKey.toUpperCase()}),Xt.jsx("div",{style:bt(yt(F.downKey)),onMouseDown:()=>D(F.downKey),onMouseUp:()=>q(F.downKey),onMouseLeave:()=>q(F.downKey),onTouchStart:gt=>{gt.preventDefault(),D(F.downKey)},onTouchEnd:gt=>{gt.preventDefault(),q(F.downKey)},children:F.downKey.toUpperCase()}),Xt.jsx("div",{style:bt(yt(F.rightKey)),onMouseDown:()=>D(F.rightKey),onMouseUp:()=>q(F.rightKey),onMouseLeave:()=>q(F.rightKey),onTouchStart:gt=>{gt.preventDefault(),D(F.rightKey)},onTouchEnd:gt=>{gt.preventDefault(),q(F.rightKey)},children:F.rightKey.toUpperCase()})]})]},L.id)});return Xt.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[Xt.jsx("canvas",{ref:_,onPointerDown:L=>{var F;x(L,"down"),(F=_.current)==null||F.focus()},onPointerMove:L=>x(L,"move"),onPointerUp:L=>x(L,"up"),onPointerCancel:L=>x(L,"up"),onClick:L=>x(L,"click"),onWheel:L=>{E.current.handleWheel(L.deltaX,L.deltaY)},onKeyDown:L=>E.current.handleKeyDown(L.nativeEvent),onKeyUp:L=>E.current.handleKeyUp(L.nativeEvent),onContextMenu:L=>L.preventDefault(),tabIndex:0,style:{...i,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:T?"auto":"none"}}),tt()]})});function oi(){const[g,t]=xt.useState(null),i=xt.useCallback((l,p)=>{g==null||g.setInputBool(l,p)},[g]),o=xt.useCallback((l,p)=>{g==null||g.setInputNumber(l,p)},[g]),e=xt.useCallback(l=>{g==null||g.fireTrigger(l)},[g]),s=xt.useCallback((l,p)=>{g==null||g.setInputText(l,p)},[g]),n=xt.useCallback((l,p)=>{g==null||g.setInputNumberArray(l,p)},[g]),a=xt.useCallback((l,p)=>{g==null||g.setInputStringArray(l,p)},[g]),r=xt.useCallback((l,p)=>{g==null||g.updateObjectOptions(l,p)},[g]),f=xt.useCallback((l,p,c)=>{g==null||g.updateConstraint(l,p,c)},[g]),h=xt.useCallback((l,p)=>{g==null||g.updateGraphData(l,p)},[g]);return{setEngine:t,engine:g,setInputBool:i,setInputNumber:o,fireTrigger:e,setInputText:s,setInputNumberArray:n,setInputStringArray:a,updateConstraint:f,updateGraphData:h,updateObjectOptions:r}}const ai=({artboard:g,config:t})=>{const i={...g.seo,...t},o=i.enableSmartExtraction!==!1;xt.useEffect(()=>{const a=i.title||g.name;a&&(document.title=a);let r=i.description;if(!r&&o){const l=g.objects.filter(p=>{var c;return((c=p.geometry)==null?void 0:c.type)==="Text"}).sort((p,c)=>{var d,u;return(((d=c.geometry.text)==null?void 0:d.length)||0)-(((u=p.geometry.text)==null?void 0:u.length)||0)});l.length>0&&(r=l[0].geometry.text)}r&&(e("name","description",r),e("property","og:description",r)),i.keywords&&i.keywords.length>0&&e("name","keywords",i.keywords.join(", "));const f=i.ogImage||g.backgroundImage;f&&e("property","og:image",f),a&&e("property","og:title",a),e("property","og:type","website")},[i,g,o]);const e=(a,r,f)=>{let h=document.querySelector(`meta[${a}="${r}"]`);h||(h=document.createElement("meta"),h.setAttribute(a,r),document.head.appendChild(h)),h.setAttribute("content",f)},s=()=>{const a=[];return a.push(Xt.jsx("h1",{children:i.title||g.name},"artboard-title")),g.objects.forEach((f,h)=>{var l,p;if(!(f.visible===!1||f.isVisible===!1))if(((l=f.geometry)==null?void 0:l.type)==="Text"){const c=f.geometry.text;c&&(f.geometry.fontSize>24?a.push(Xt.jsx("h2",{children:c},f.id||h)):a.push(Xt.jsx("p",{children:c},f.id||h)))}else if(((p=f.geometry)==null?void 0:p.type)==="Image"){const c=f.geometry.src,d=f.altText||f.name||"Illustration";a.push(Xt.jsx("img",{src:c,alt:d},f.id||h))}else f.type==="Button"&&a.push(Xt.jsx("button",{children:f.name||"Button"},f.id||h))}),a},n=i.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:i.title||g.name,description:i.description,image:i.ogImage||g.backgroundImage,abstract:"Animated interface created with ExodeUI"};return Xt.jsxs("div",{id:`exode-seo-${g.id||"default"}`,"aria-hidden":"false",style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0",zIndex:-1},children:[s(),Xt.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})]})},ri={version:"6.3.38"}.version;Gt.BehaviorSensor=Qt,Gt.BehaviorType=H,Gt.ConditionOp=je,Gt.ExodeSEO=ai,Gt.ExodeUICanvas=ni,Gt.ExodeUIEngine=ms,Gt.LogicOp=wt,Gt.RapierPhysics=is,Gt.VERSION=ri,Gt.useExodeUI=oi,Object.defineProperty(Gt,Symbol.toStringTag,{value:"Module"})}));
33
+ `&&dt++)}),t.globalAlpha=yt}}}applyStrokeAlignment(t,i,o,e,s,n,a=1,r=1){if(!i.stroke||i.stroke.width<=0||i.stroke.isEnabled===!1)return;const f=i.stroke;let h=1;if(this.rootTransform){const S=t.getTransform(),C=Math.sqrt(S.a*S.a+S.b*S.b)||1,w=this.rootTransform,M=Math.sqrt(w.a*w.a+w.b*w.b)||1;h=C/M}else h=(Math.abs(a)+Math.abs(r))/2||1;const l=(f.width||1)/(h||1),p=(f.alignment||"center").toLowerCase();if(t.save(),i.fill&&i.fill.type!=="None"&&i.fill.isEnabled!==!1&&i.fill.opacity!==0&&i.fill.color!=="transparent"&&i.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),f.fill){const S=this.createCanvasFill(t,f.fill,e,s);S?t.strokeStyle=S:t.strokeStyle=f.color||"#000000"}else t.strokeStyle=f.color||"#000000";const d=t.globalAlpha;t.globalAlpha=d*this.normalizeOpacity(f.opacity??100),t.lineWidth=l,t.lineCap=f.lineCap||"round",t.lineJoin=f.lineJoin||"round",f.miterLimit!==void 0&&(t.miterLimit=f.miterLimit);const u=f.trimStart??0,v=f.trimEnd??1,b=f.trimOffset??0,y=f.dashOffset??0,m=f.dashArray||[];if(u!==0||v!==1||b!==0){const S=this.getPerimeter(o,e,s);if(S>0){const C=Math.max(0,Math.min(1,u)),w=Math.max(0,Math.min(1,v));if(C<w){const M=S*(w-C),I=S-M,k=-(S*(C+b%1));t.setLineDash([M,I]),t.lineDashOffset=k+y*S}else if(C===w)t.setLineDash([0,S]);else{const M=S*(1-C+w),I=S-M,k=-(S*C);t.setLineDash([M,I]),t.lineDashOffset=k+y*S}}}else m.length>0&&(t.setLineDash(m),t.lineDashOffset=y);(o==null?void 0:o.type)==="Line"||e===0||s===0?(this.applyPath(t,o,e,s,n),t.stroke()):p==="inside"?(t.lineWidth=l*2,t.save(),this.applyPath(t,o,e,s,n),t.clip(),t.stroke(),t.restore()):p==="outside"?(t.lineWidth=l*2,this.applyPath(t,o,e,s,n),t.stroke(),t.save(),t.globalCompositeOperation="destination-out",this.applyPath(t,o,e,s,n),t.fill(),t.restore()):(t.lineWidth=l,this.applyPath(t,o,e,s,n),t.stroke()),t.restore()}getPerimeter(t,i,o){switch(this.ensurePathPoints(t),t==null?void 0:t.type){case"Rectangle":return(i+o)*2;case"Ellipse":{const e=Math.abs(i)/2,s=Math.abs(o)/2,n=Math.abs(t.sweepAngle??360),a=t.ratio||0,r=Math.PI*(3*(e+s)-Math.sqrt((3*e+s)*(e+3*s)));if(n>=360&&a<=0)return r;let f=n/360*r;if(a>0){const h=Math.PI*(3*(e*a+s*a)-Math.sqrt((3*e*a+s*a)*(e*a+3*s*a)));f+=n/360*h,n<360&&(f+=2*Math.sqrt((e-e*a)**2+(s-s*a)**2))}else n<360&&(f+=2*Math.max(e,s));return isNaN(f)?0:f}case"Line":return t.length||Math.sqrt(i*i+o*o);case"Triangle":return i+Math.sqrt((i/2)**2+o**2)*2;case"Polygon":{const e=t.sides||3,s=t.radius||Math.min(i,o)/2;return 2*e*s*Math.sin(Math.PI/e)}case"Star":{const e=t.points||5,s=t.outer_radius||Math.min(i,o)/2,n=t.inner_radius||s/2,a=Math.PI/e;return Math.sqrt(s*s+n*n-2*s*n*Math.cos(a))*e*2}case"Path":{const e=t.points||[];if(e.length<2)return t.length||0;let s=0,n=e[0].x,a=e[0].y;for(let r=1;r<e.length;r++){const f=e[r];if(f.moveTo){n=f.x,a=f.y;continue}const h=n,l=a,p=e[r-1].out_x,c=e[r-1].out_y;if(p!==void 0||f.in_x!==void 0?s+=this.getBezierLength(h,l,p??h,c??l,f.in_x??f.x,f.in_y??f.y,f.x,f.y):s+=Math.sqrt((f.x-h)**2+(f.y-l)**2),n=f.x,a=f.y,f.closePath||r===e.length-1&&(t.is_closed||t.isClosed)){const d=n,u=a,v=[...e.slice(0,r+1)].reverse().find(M=>M.moveTo)||e[0],b=v.x,y=v.y,m=e[r].out_x,S=e[r].out_y,C=v.in_x,w=v.in_y;m!==void 0||C!==void 0?s+=this.getBezierLength(d,u,m??d,S??u,C??b,w??y,b,y):s+=Math.sqrt((b-d)**2+(y-u)**2)}}return s}default:return(i+o)*2}}getBezierLength(t,i,o,e,s,n,a,r,f=10){let h=0,l=t,p=i;for(let c=1;c<=f;c++){const d=c/f,u=1-d,v=d*d,b=u*u,y=b*u,m=v*d,S=y*t+3*b*d*o+3*u*v*s+m*a,C=y*i+3*b*d*e+3*u*v*n+m*r,w=S-l,M=C-p;h+=Math.sqrt(w*w+M*M),l=S,p=C}return h}getBezierTAtLength(t,i,o,e,s,n,a,r,f,h=20){if(t<=0)return 0;let l=0,p=i,c=o;for(let d=1;d<=h;d++){const u=d/h,v=1-u,b=u*u,y=v*v,m=y*v,S=b*u,C=m*i+3*y*u*e+3*v*b*n+S*r,w=m*o+3*y*u*s+3*v*b*a+S*f,M=C-p,I=w-c,k=Math.sqrt(M*M+I*I);if(l+k>=t){const T=t-l,O=k===0?0:T/k;return(d-1+O)/h}l+=k,p=C,c=w}return 1}getPointOnPath(t,i,o,e){if(this.ensurePathPoints(t),(t==null?void 0:t.type)==="Path"){const s=t.points||[];if(s.length<2)return{x:0,y:0,angle:0};let n=1/0,a=-1/0,r=1/0,f=-1/0;s.forEach(y=>{typeof y.x=="number"&&typeof y.y=="number"&&(n=Math.min(n,y.x),a=Math.max(a,y.x),r=Math.min(r,y.y),f=Math.max(f,y.y),y.out_x!==void 0&&(n=Math.min(n,y.out_x),a=Math.max(a,y.out_x)),y.out_y!==void 0&&(r=Math.min(r,y.out_y),f=Math.max(f,y.out_y)),y.in_x!==void 0&&(n=Math.min(n,y.in_x),a=Math.max(a,y.in_x)),y.in_y!==void 0&&(r=Math.min(r,y.in_y),f=Math.max(f,y.in_y)))});const h=(n+a)/2,l=(r+f)/2,c=this.getPerimeter(t,i,o)*e;let d=0;const u=[];let v=s[0],b=s[0];for(let y=1;y<s.length;y++){const m=s[y];if(m.moveTo){v=m,b=m;continue}u.push({p0:v,p1:m}),(m.closePath||y===s.length-1&&(t.is_closed||t.isClosed))&&u.push({p0:m,p1:b}),v=m}for(const y of u){const m=y.p0,S=y.p1;let C=0;const w=m.out_x!==void 0||S.in_x!==void 0;if(w?C=this.getBezierLength(m.x,m.y,m.out_x??m.x,m.out_y??m.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y):C=Math.sqrt((S.x-m.x)**2+(S.y-m.y)**2),d+C>=c||y===u[u.length-1]){let M=0;if(w)return M=this.getBezierTAtLength(c-d,m.x,m.y,m.out_x??m.x,m.out_y??m.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y,20),this.getBezierPointAndAngle(M,m,S,h,l);{M=C===0?0:(c-d)/C;const I=m.x+(S.x-m.x)*M-h,k=m.y+(S.y-m.y)*M-l,T=Math.atan2(S.y-m.y,S.x-m.x);return{x:I,y:k,angle:T}}}d+=C}}else if(t.type==="Ellipse"){const s=Math.abs(i)/2,n=Math.abs(o)/2,a=t.sweepAngle??360,f=((t.startAngle??0)+a*e)*Math.PI/180,h=s*Math.cos(f),l=n*Math.sin(f),p=-s*Math.sin(f),c=n*Math.cos(f),d=Math.atan2(c,p);return{x:h,y:l,angle:d}}else if((t==null?void 0:t.type)==="Rectangle"){const s=Math.abs(i),n=Math.abs(o),r=(s+n)*2*e;let f=0,h=0,l=0;return r<s?(f=-s/2+r,h=-n/2,l=0):r<s+n?(f=s/2,h=-n/2+(r-s),l=Math.PI/2):r<2*s+n?(f=s/2-(r-(s+n)),h=n/2,l=Math.PI):(f=-s/2,h=n/2-(r-(2*s+n)),l=-Math.PI/2),{x:f,y:h,angle:l}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(t,i,o,e,s){const n=i.x,a=i.y,r=i.out_x??i.x,f=i.out_y??i.y,h=o.in_x??o.x,l=o.in_y??o.y,p=o.x,c=o.y,d=1-t,u=t*t,v=d*d,b=v*d,y=u*t,m=b*n+3*v*t*r+3*d*u*h+y*p-e,S=b*a+3*v*t*f+3*d*u*l+y*c-s,C=3*v*(r-n)+6*d*t*(h-r)+3*u*(p-h),w=3*v*(f-a)+6*d*t*(l-f)+3*u*(c-l),M=Math.atan2(w,C);return{x:m,y:S,angle:M}}applyAbsoluteTransform(t,i,o){if(!o.get(i))return;const s=[];let n=i;for(;n;){s.unshift(n);const a=o.get(n);n=a==null?void 0:a.parentId}s.forEach(a=>{this.applyObjectTransform(t,a)})}applyObjectTransform(t,i){var d,u,v;const o=this.objectStates.get(i);if(!o)return;t.translate(o.x,o.y),t.rotate((o.rotation??0)*Math.PI/180);const e=o.skew_x||0,s=o.skew_y||0;if(e!==0||s!==0){const b=Math.tan(e*Math.PI/180),y=Math.tan(s*Math.PI/180);t.transform(1+b*y,y,b,1,0,0)}const n=o.rotate_x!==void 0?o.rotate_x:((d=o.transform)==null?void 0:d.rotate_x)??0,a=o.rotate_y!==void 0?o.rotate_y:((u=o.transform)==null?void 0:u.rotate_y)??0,f=1+(o.translate_z!==void 0?o.translate_z:((v=o.transform)==null?void 0:v.translate_z)??0)/1e3,h=(o.flip_x===!0?-1:1)*Math.cos(a*Math.PI/180)*f,l=(o.flip_y===!0?-1:1)*Math.cos(n*Math.PI/180)*f,p=(o.scale_x??1)*h,c=(o.scale_y??1)*l;t.scale(p,c)}applyArtEffectOverlay(t,i,o,e,s,n){var c,d,u,v,b;const a=this.objectStates.get(i.id),r=((c=a==null?void 0:a.style)==null?void 0:c.artEffect)||i.artEffect||((d=i.style)==null?void 0:d.artEffect);if(!r||!r.enabled)return;const f=r.type,h=r.intensity??.5,l=r.speed??1,p=r.scale??10;if(f==="acid_gradient"||f==="acid_rave"||f==="shimmer"||f==="glint_overlay"||f==="halftone"||f==="noise"||f==="scanlines"||f==="chromatic_aberration"||f==="pixelate"||f==="glitch"||f==="fold_overlay"||f==="crumple_overlay"){if(t.save(),this.applyPath(t,o,e,s,n),t.clip(),f==="shimmer"){const m=this.currentTime*l%2/2,S=t.createLinearGradient(-e,-s,e,s);S.addColorStop(Math.max(0,m-.2),"rgba(255,255,255,0)"),S.addColorStop(m,`rgba(255,255,255,${h*.8})`),S.addColorStop(Math.min(1,m+.2),"rgba(255,255,255,0)"),t.fillStyle=S,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over"}else if(f==="glint_overlay"){let S=((this._lastPointerPos||{x:0}).x-(((u=i.transform)==null?void 0:u.x)??0)+300)/600;S=Math.max(-.2,Math.min(1.2,S));const C=t.createLinearGradient(-e,-s,e,s);C.addColorStop(Math.max(0,S-.15),"rgba(255,255,255,0)"),C.addColorStop(Math.max(0,Math.min(1,S)),`rgba(255,255,255,${h})`),C.addColorStop(Math.min(1,S+.15),"rgba(255,255,255,0)"),t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over"}else if(f==="fold_overlay"){const y=this._lastPointerPos||{x:0,y:0},m=y.x-(((v=i.transform)==null?void 0:v.x)??0),S=y.y-(((b=i.transform)==null?void 0:b.y)??0),C=t.createLinearGradient(m>0?-e/2:e/2,S>0?-s/2:s/2,m>0?e/2:-e/2,S>0?s/2:-s/2);C.addColorStop(0,`rgba(0,0,0,${h*.6})`),C.addColorStop(.4,"rgba(0,0,0,0)"),C.addColorStop(.5,`rgba(255,255,255,${h*.4})`),C.addColorStop(1,`rgba(0,0,0,${h*.2})`),t.fillStyle=C,t.globalCompositeOperation="overlay",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over",t.beginPath(),m>0&&S>0?(t.moveTo(e/2-40,s/2),t.lineTo(e/2,s/2-40),t.lineTo(e/2-40,s/2-40)):m<0&&S>0?(t.moveTo(-e/2+40,s/2),t.lineTo(-e/2,s/2-40),t.lineTo(-e/2+40,s/2-40)):m>0&&S<0?(t.moveTo(e/2-40,-s/2),t.lineTo(e/2,-s/2+40),t.lineTo(e/2-40,-s/2+40)):(t.moveTo(-e/2+40,-s/2),t.lineTo(-e/2,-s/2+40),t.lineTo(-e/2+40,-s/2+40)),t.closePath(),t.fillStyle="#ffffff",t.shadowColor="rgba(0,0,0,0.5)",t.shadowBlur=10,t.shadowOffsetX=m>0?-2:2,t.shadowOffsetY=S>0?-2:2,t.fill()}else if(f==="crumple_overlay"){const y=Math.floor(e/p),m=document.createElement("canvas");m.width=y,m.height=Math.floor(s/p);const S=m.getContext("2d"),C=S.createImageData(m.width,m.height);for(let w=0;w<C.data.length;w+=4){const M=Math.random()>.95?150:255;C.data[w]=M,C.data[w+1]=M,C.data[w+2]=M,C.data[w+3]=255*h}S.putImageData(C,0,0),t.globalCompositeOperation="multiply",t.imageSmoothingEnabled=!1,t.drawImage(m,-e/2,-s/2,e,s)}else if(f==="acid_gradient"||f==="acid_rave"){const y=this.currentTime*l,m=r.color1,S=r.color2,C=t.createLinearGradient(-e/2,-s/2,e/2,s/2);if(m&&S){const w=y*60%360;C.addColorStop(0,this._shiftHue(m,w,h*.7)),C.addColorStop(1,this._shiftHue(S,(w+180)%360,h*.7))}else{const w=y*100%360,M=(w+180)%360;C.addColorStop(0,`hsla(${w}, 80%, 50%, ${h*.5})`),C.addColorStop(1,`hsla(${M}, 80%, 50%, ${h*.5})`)}t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s)}else if(f==="halftone"){const y=Math.max(2,p*(1-h*.8)),m=document.createElement("canvas");m.width=y,m.height=y;const S=m.getContext("2d");if(S){S.fillStyle="black",S.beginPath(),S.arc(y/2,y/2,y/2*h,0,Math.PI*2),S.fill();const C=t.createPattern(m,"repeat");C&&(t.globalAlpha=.3*h,t.fillStyle=C,t.fillRect(-e/2,-s/2,e,s))}}else if(f==="noise"){const y=Math.floor(e*s*h*.02);t.globalAlpha=.4*h;for(let m=0;m<y;m++){const S=Math.random()>.5?255:0;t.fillStyle=`rgba(${S}, ${S}, ${S}, ${.5+Math.random()*.5})`,t.fillRect(-e/2+Math.random()*e,-s/2+Math.random()*s,2,2)}}else if(f==="scanlines"){t.globalAlpha=.2*h,t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1;for(let y=-s/2;y<s/2;y+=4)t.beginPath(),t.moveTo(-e/2,y),t.lineTo(e/2,y),t.stroke()}else if(f==="chromatic_aberration"){const y=5*h;t.globalCompositeOperation="screen",t.globalAlpha=.5,t.fillStyle="cyan",t.fillRect(-e/2-y,-s/2,e,s),t.fillStyle="magenta",t.fillRect(-e/2+y,-s/2,e,s)}else if(f==="pixelate"){const y=Math.max(2,Math.round(p*(1-h*.5))),m=document.createElement("canvas"),S=Math.max(1,Math.ceil(e/y)),C=Math.max(1,Math.ceil(s/y));m.width=S,m.height=C;const w=m.getContext("2d");if(w){w.imageSmoothingEnabled=!1;const M=t.getTransform(),I=M.e-e/2,k=M.f-s/2;w.drawImage(t.canvas,I,k,e,s,0,0,S,C),t.imageSmoothingEnabled=!1,t.drawImage(m,0,0,S,C,-e/2,-s/2,e,s),t.imageSmoothingEnabled=!0}}else if(f==="glitch"){const y=this.currentTime*l,m=r.chaosAmount??.2,S=Math.max(3,Math.floor(8*h)),C=h*e*.15;t.globalCompositeOperation="screen",t.globalAlpha=h*.4;const w=C*.3;t.fillStyle="rgba(255, 0, 0, 0.4)",t.fillRect(-e/2+w,-s/2,e,s),t.fillStyle="rgba(0, 255, 255, 0.4)",t.fillRect(-e/2-w,-s/2,e,s),t.globalCompositeOperation="source-over",t.globalAlpha=1;const M=s/S;for(let I=0;I<S;I++){const k=Math.sin(I*127.1+y*311.7*l)*43758.5,T=k-Math.floor(k);if(T>1-m){const O=(T-(1-m))/m*C*(Math.random()>.5?1:-1),P=-s/2+I*M,_=t.getTransform(),E=_.e-e/2+O,A=_.f+P;t.save(),t.beginPath(),t.rect(-e/2,P,e,M),t.clip(),t.globalAlpha=.8,t.drawImage(t.canvas,E,A,e,M,-e/2+O,P,e,M),t.restore()}}}t.restore()}}_shiftHue(t,i,o){let e=0,s=0,n=0;if(t.startsWith("#")){const c=t.replace("#","");e=parseInt(c.substring(0,2),16)/255,s=parseInt(c.substring(2,4),16)/255,n=parseInt(c.substring(4,6),16)/255}const a=Math.max(e,s,n),r=Math.min(e,s,n);let f=0,h=0,l=(a+r)/2;if(a!==r){const c=a-r;switch(h=l>.5?c/(2-a-r):c/(a+r),a){case e:f=((s-n)/c+(s<n?6:0))/6;break;case s:f=((n-e)/c+2)/6;break;case n:f=((e-s)/c+4)/6;break}}return`hsla(${(((f*360+i)%360+360)%360).toFixed(0)}, ${(h*100).toFixed(0)}%, ${(l*100).toFixed(0)}%, ${o})`}applyBackgroundBlurGlass(t,i,o,e,s,n){const a=n.radius??10,r=n.color??"rgba(255,255,255,0.2)",f=n.opacity!==void 0?this.normalizeOpacity(n.opacity):.5,h=n.noise??0;t.save(),this.applyPath(t,i,o,e,s),t.clip();const l=t.getTransform(),p=t.canvas;try{const d=document.createElement("canvas");d.width=Math.max(1,Math.ceil(o)),d.height=Math.max(1,Math.ceil(e));const u=d.getContext("2d");if(u){u.save(),u.translate(o/2,e/2);const v=n.magnification||1;if(v!==1&&u.scale(v,v),typeof l.inverse=="function"){const m=l.inverse();u.transform(m.a,m.b,m.c,m.d,m.e,m.f)}else{const m=l.a*l.d-l.b*l.c;m!==0&&u.transform(l.d/m,-l.b/m,-l.c/m,l.a/m,(l.c*l.f-l.d*l.e)/m,(l.b*l.e-l.a*l.f)/m)}u.drawImage(p,0,0),u.restore(),u.filter=`blur(${a}px)`;const b=document.createElement("canvas");b.width=d.width,b.height=d.height;const y=b.getContext("2d");y.filter=`blur(${a}px)`,y.drawImage(d,0,0),t.globalCompositeOperation="source-over",t.globalAlpha=1,t.drawImage(b,-o/2,-e/2,o,e)}}catch{}t.globalCompositeOperation="source-over",t.globalAlpha=f,t.fillStyle=r,t.fillRect(-o/2,-e/2,o,e),t.globalAlpha=1,t.globalCompositeOperation="source-atop";const c=t.createLinearGradient(-o/2,-e/2,o/2,e/2);if(c.addColorStop(0,"rgba(255,255,255,0.12)"),c.addColorStop(.3,"rgba(255,255,255,0.04)"),c.addColorStop(.5,"rgba(255,255,255,0.0)"),c.addColorStop(1,"rgba(255,255,255,0.0)"),t.fillStyle=c,t.fillRect(-o/2,-e/2,o,e),h>0){if(t.globalAlpha=h/100,!this._noiseTileCanvas){const u=document.createElement("canvas");u.width=64,u.height=64;const v=u.getContext("2d"),b=v.createImageData(64,64),y=b.data;for(let m=0;m<y.length;m+=4){const S=Math.floor(Math.random()*255);y[m]=S,y[m+1]=S,y[m+2]=S,y[m+3]=18}v.putImageData(b,0,0),this._noiseTileCanvas=u}const d=t.createPattern(this._noiseTileCanvas,"repeat");d&&(t.fillStyle=d,t.fillRect(-o/2,-e/2,o,e))}t.restore(),t.save(),t.globalAlpha=1,t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1.5,this.applyPath(t,i,o,e,s),t.stroke(),t.restore()}applyPath(t,i,o,e,s){i!=null&&i.data&&(i.type==="Path"||i.type==="Subtract"||i.type==="Union"||i.type==="Intersect"||i.type==="Exclude"||i.type),t.beginPath(),this._tracePath(t,i,o,e,s)}_tracePath(t,i,o,e,s){if(i){if(this.ensurePathPoints(i),(i==null?void 0:i.type)==="Rectangle"||i.type==="Image"){const n=s!==void 0?s:i.corner_radius??0;this.drawRoundRect(t,-o/2,-e/2,o,e,n)}else if(i.type==="Line")t.moveTo(-o/2,0),t.lineTo(o/2,0);else if(i.type==="Ellipse"){const{startAngle:n=0,sweepAngle:a=360,ratio:r=0}=i,f=o/2,h=e/2,l=n*Math.PI/180,p=a*Math.PI/180,c=l+p;a>=360&&r<=0?t.ellipse(0,0,f,h,0,0,Math.PI*2):(t.ellipse(0,0,f,h,0,l,c,!1),r>0?t.ellipse(0,0,f*r,h*r,0,c,l,!0):t.lineTo(0,0),t.closePath())}else if(i.type==="Triangle")t.moveTo(0,-e/2),t.lineTo(o/2,e/2),t.lineTo(-o/2,e/2),t.closePath();else if(i.type==="Polygon"){const n=i.sides||3,a=i.radius||Math.min(o,e)/2;for(let r=0;r<n;r++){const f=r*2*Math.PI/n-Math.PI/2,h=a*Math.cos(f),l=a*Math.sin(f);r===0?t.moveTo(h,l):t.lineTo(h,l)}t.closePath()}else if(i.type==="Star"){const n=i.points||5,a=i.outer_radius||Math.min(o,e)/2;let r=i.inner_radius;r==null?r=a*.382:r<=1&&(r=a*r);for(let f=0;f<n*2;f++){const h=f*Math.PI/n-Math.PI/2,l=f%2===0?a:r,p=l*Math.cos(h),c=l*Math.sin(h);f===0?t.moveTo(p,c):t.lineTo(p,c)}t.closePath()}else if(((i==null?void 0:i.type)==="Path"||i.type==="Subtract"||i.type==="Union"||i.type==="Intersect"||i.type==="Exclude"||i.type==="BooleanOperation")&&i.points){this.frameCount%300===0&&this.log("[Engine] Tracing Path:",i.points.length,"points");let n=1/0,a=-1/0,r=1/0,f=-1/0;if(i.points.forEach(p=>{typeof p.x=="number"&&typeof p.y=="number"&&(n=Math.min(n,p.x),a=Math.max(a,p.x),r=Math.min(r,p.y),f=Math.max(f,p.y),p.out_x!==void 0&&(n=Math.min(n,p.out_x),a=Math.max(a,p.out_x)),p.out_y!==void 0&&(r=Math.min(r,p.out_y),f=Math.max(f,p.out_y)),p.in_x!==void 0&&(n=Math.min(n,p.in_x),a=Math.max(a,p.in_x)),p.in_y!==void 0&&(r=Math.min(r,p.in_y),f=Math.max(f,p.in_y)))}),n===1/0)return;const h=(n+a)/2,l=(r+f)/2;if(isNaN(h)||isNaN(l)){this.warn("[Engine] Invalid path center:",h,l);return}i.points.forEach((p,c)=>{if(c===0||p.moveTo)t.moveTo(p.x-h,p.y-l);else{const d=i.points[c-1];if(!d)return;const u=(d.out_x??d.x)-h,v=(d.out_y??d.y)-l,b=(p.in_x??p.x)-h,y=(p.in_y??p.y)-l;isNaN(u)||isNaN(b)||isNaN(p.x)?t.lineTo(p.x-h,p.y-l):t.bezierCurveTo(u,v,b,y,p.x-h,p.y-l)}if(p.closePath||c===i.points.length-1&&(i.is_closed||i.isClosed)){const d=[...i.points.slice(0,c+1)].reverse().find(u=>u.moveTo)||i.points[0];d&&(p.out_x!==void 0||d.in_x!==void 0)&&t.bezierCurveTo((p.out_x??p.x)-h,(p.out_y??p.y)-l,(d.in_x??d.x)-h,(d.in_y??d.y)-l,d.x-h,d.y-l),t.closePath()}})}else if(i.points&&Array.isArray(i.points)){let n=1/0,a=-1/0,r=1/0,f=-1/0;i.points.forEach(p=>{n=Math.min(n,p.x),a=Math.max(a,p.x),r=Math.min(r,p.y),f=Math.max(f,p.y)});const h=(n+a)/2,l=(r+f)/2;i.points.forEach((p,c)=>{if(c===0)t.moveTo(p.x-h,p.y-l);else{const d=i.points[c-1];d.out_x!==void 0||p.in_x!==void 0?t.bezierCurveTo((d.out_x??d.x)-h,(d.out_y??d.y)-l,(p.in_x??p.x)-h,(p.in_y??p.y)-l,p.x-h,p.y-l):t.lineTo(p.x-h,p.y-l)}(p.closePath||c===i.points.length-1&&(i.is_closed||i.isClosed))&&t.closePath()})}}}renderInputBox(t,i){var L,R;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((L=i.geometry)==null?void 0:L.width)||250,n=((R=i.geometry)==null?void 0:R.height)||45,a=this.focusedId===i.id,r=this.lastHoveredObjectId===i.id,f=e.previewState||"default",h=f!=="default"?f:a?"focused":r?"hovered":"default",l=e.label||{visible:!0,text:"Label"},p=e.helperText||{visible:!1,text:"Helper text"},c=e.leftIcon||{visible:!1},d=e.rightIcon||{visible:!1},u=e.multiline===!0,v=e.corner_radius??8,b=e.corners||{tl:v,tr:v,bl:v,br:v},y=[b.tl,b.tr,b.br,b.bl];let m=e.backgroundColor||"rgba(31, 41, 55, 1)",S=e.borderColor||"rgba(55, 65, 81, 1)",C=e.borderWidth??1.5,w=e.color||"#ffffff",M=e.placeholderColor||"rgba(156, 163, 175, 1)",I=e.fontSize||14;const k=`${h}Style`,T=e[k];T?(T.backgroundColor!==void 0&&(m=T.backgroundColor),T.borderColor!==void 0&&(S=T.borderColor),T.borderWidth!==void 0&&(C=T.borderWidth),T.color!==void 0&&(w=T.color),T.placeholderColor!==void 0&&(M=T.placeholderColor),T.fontSize!==void 0&&(I=T.fontSize)):h==="focused"?(S=e.focusBorderColor||"rgba(59, 130, 246, 1)",C=Math.max(C,2)):h==="hovered"||h==="hover"?(S=e.hoverBorderColor||S,m=e.hoverBackgroundColor||m):h==="disabled"?(m=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",S=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):h==="error"&&(S="rgba(239, 68, 68, 1)",C=Math.max(C,2)),t.beginPath(),this.drawRoundRect(t,-s/2,-n/2,s,n,y);const O=this.createCanvasFill(t,m,s,n);if(O&&(t.fillStyle=O,t.fill()),C>0){const D=this.createCanvasFill(t,S,s,n);if(D&&(t.strokeStyle=D,t.lineWidth=C,t.stroke()),h==="focused"||h==="focus"){t.save(),t.beginPath();const q=y.map(ot=>ot+2);this.drawRoundRect(t,-s/2-2,-n/2-2,s+4,n+4,q),t.strokeStyle="rgba(59, 130, 246, 0.3)",t.lineWidth=2,t.stroke(),t.restore()}}const P=(D,q)=>{if(!D.visible||!D.svgPath)return;const ot=D.size||14,mt=D.offset??16,bt=D.color||"#ffffff",gt=q?-(s/2)+mt:s/2-mt,Et=D.svgPath;if(t.save(),t.translate(gt,0),!Et.startsWith("<svg")){const It=new Path2D(Et),vt=ot/24;t.scale(vt,vt),t.translate(-12,-12),t.fillStyle=bt,t.fill(It)}t.restore()};P(c,!0),P(d,!1);const _=e.text||"",E=e.placeholder||"Enter text...",A=!_,W=_||E,z=A?M:w,Y=I,G=e.fontFamily||"Inter",N=e.fontWeight||400;t.font=`${N} ${Y}px "${G}", sans-serif`,t.fillStyle=z,t.textAlign="left",t.textBaseline=u?"top":"middle";const J=e.inputPadding??16,x=c.visible?(c.offset??16)+(c.size||14)/2+8:J,F=d.visible?(d.offset??16)+(d.size||14)/2+8:J,j=-(s/2)+x,X=s-x-F,tt=e.inputType==="password"?"•".repeat(W.length):W;if(t.save(),t.beginPath(),t.rect(j-2,-n/2+4,X+4,n-8),t.clip(),u){const D=tt.split(`
34
+ `);let q=-n/2+J;const ot=Y*1.2;let mt=0;D.forEach((bt,gt)=>{const Et=bt.split(" ");let It="";for(let vt=0;vt<Et.length;vt++){const Dt=It+Et[vt]+" ";t.measureText(Dt).width>X&&vt>0?(t.fillText(It,j,q),It=Et[vt]+" ",q+=ot):It=Dt}t.fillText(It,j,q),mt=t.measureText(It).width,gt<D.length-1&&(q+=ot,mt=0)}),a&&!A&&Math.floor(performance.now()/500)%2===0&&t.fillRect(j+mt,q,1.5,Y)}else{const q=t.measureText(tt).width;let ot=0;if(q>X&&(ot=q-X),t.fillText(tt,j-ot,0),a&&!A&&Math.floor(performance.now()/500)%2===0){const bt=j+q-ot;t.fillRect(bt,-(Y/2),1.5,Y)}}if(t.restore(),l.visible!==!1){const D=l.text||"Label",q=l.fontSize||12,ot=l.color||"rgba(156, 163, 175, 1)",mt=l.offset??8;t.font=`600 ${q}px "${G}", sans-serif`,t.fillStyle=ot,t.textAlign="left",t.textBaseline="bottom";const bt=-(s/2),gt=-(n/2)-mt;t.fillText(D,bt,gt)}if(p.visible===!0){const D=p.text||"Helper text",q=p.fontSize||11,ot=h==="error"?"rgba(239, 68, 68, 1)":p.color||"rgba(156, 163, 175, 1)",mt=p.offset??6;t.font=`400 ${q}px "${G}", sans-serif`,t.fillStyle=ot,t.textAlign="left",t.textBaseline="top";const bt=-(s/2),gt=n/2+mt;t.fillText(D,bt,gt)}}renderSlider(t,i){const o=this.objectStates.get(i.id),e=(o==null?void 0:o.geometry)||i.geometry,s=(o==null?void 0:o.options)||i.options||{},n=e.width||200,a=s.value??50,r=s.min??0,h=(s.max??100)-r,l=h===0?0:(a-r)/h,p=s.trackHeight||4,c=s.trackRoundedness??2,d=s.trackShape??"Rectangle",u=s.trackPath||"",v=s.accentColor||"#3b82f6",b=s.inactiveColor||"#374151",y=s.thumbShape||"Ellipse",m=s.thumbWidth??16,S=s.thumbHeight??16,C=s.thumbRoundedness??0,w=s.thumbColor||"#ffffff",M=s.thumbPath||"",I=s.thumbIcon||"",k=s.showValueTooltip??!1,T=s.tooltipBgColor||"#333333",O=s.tooltipColor||"#ffffff",P=s.tooltipOffsetX??0,_=s.tooltipOffsetY??-25,E=(X,tt,L,R,D,q,ot)=>{if((X==="Custom"||X==="Icon")&&ot)try{const mt=new Path2D(ot);if(t.save(),t.translate(tt,L),X==="Icon"){const bt=Math.min(R,D)/24;t.scale(bt,bt),t.translate(-12,-12)}t.fill(mt),t.restore();return}catch(mt){console.error("Error drawing slider shape in engine:",mt)}if(t.beginPath(),X==="Ellipse")t.ellipse(tt,L,R/2,D/2,0,0,Math.PI*2);else if(X==="Rectangle")this.drawRoundRect(t,tt-R/2,L-D/2,R,D,q);else if(X==="Triangle")t.moveTo(tt,L-D/2),t.lineTo(tt+R/2,L+D/2),t.lineTo(tt-R/2,L+D/2),t.closePath();else if(X==="Diamond")t.moveTo(tt,L-D/2),t.lineTo(tt+R/2,L),t.lineTo(tt,L+D/2),t.lineTo(tt-R/2,L),t.closePath();else if(X==="Polygon"){const mt=i.geometry.sides||3,bt=i.geometry.radius||Math.min(R,D)/2;for(let gt=0;gt<mt;gt++){const Et=gt*2*Math.PI/mt-Math.PI/2,It=tt+bt*Math.cos(Et),vt=L+bt*Math.sin(Et);gt===0?t.moveTo(It,vt):t.lineTo(It,vt)}t.closePath()}else if(X==="Star"){const bt=Math.min(R,D)/2,gt=bt/2;for(let Et=0;Et<10;Et++){const It=Et%2===0?bt:gt,vt=Et*Math.PI/5-Math.PI/2;t.lineTo(tt+It*Math.cos(vt),L+It*Math.sin(vt))}t.closePath()}else X==="Line"&&(t.moveTo(tt-R/2,L),t.lineTo(tt+R/2,L));t.fill()},A=this.createCanvasFill(t,b,n,p);A&&(t.fillStyle=A,t.strokeStyle=A),d==="Line"?(t.lineWidth=p,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(n/2,0),t.stroke()):E(d,0,0,n,p,c,u);const W=n-m,z=-n/2+m/2+l*W,Y=z- -n/2;if(Y>0){const X=this.createCanvasFill(t,v,n,p);X&&(t.fillStyle=X,t.strokeStyle=X),d==="Line"?(t.lineWidth=p,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(z,0),t.stroke()):d==="Rectangle"&&(t.beginPath(),this.drawRoundRect(t,-n/2,-p/2,Y,p,c),t.fill())}t.save(),t.translate(z,0);const G=t.getTransform(),N=Math.sqrt(G.a*G.a+G.b*G.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*N,t.shadowOffsetY=1*N;const J=this.createCanvasFill(t,w,m,S);if(J&&(t.fillStyle=J),E(y,0,0,m,S,C,y==="Icon"?I:M),t.restore(),k){t.save(),t.translate(z+P,_);const X=Math.round(a).toString();t.font="10px Inter, sans-serif";const tt=t.measureText(X),L=6,R=4,D=tt.width+L*2,q=14+R;t.beginPath(),this.drawRoundRect(t,-D/2,-q/2,D,q,4),t.fillStyle=T,t.fill(),t.fillStyle=O,t.textAlign="center",t.textBaseline="middle",t.fillText(X,0,0),t.restore()}const x=s.label||{},F=s.helperText||{},j=s.fontFamily||"Inter";if(x.visible!==!1){const X=x.text||"Label",tt=x.fontSize||12,L=x.color||"rgba(156, 163, 175, 1)",R=x.offset??8;t.font=`600 ${tt}px "${j}", sans-serif`,t.fillStyle=L,t.textAlign="left",t.textBaseline="bottom";const D=-(n/2),q=-(p/2)-R;t.fillText(X,D,q)}if(F.visible===!0){const X=F.text||"Helper text",tt=F.fontSize||11,L=F.color||"rgba(156, 163, 175, 1)",R=F.offset??6;t.font=`400 ${tt}px "${j}", sans-serif`,t.fillStyle=L,t.textAlign="left",t.textBaseline="top";const D=-(n/2),q=p/2+R;t.fillText(X,D,q)}}renderDropdown(t,i){var _;const o=this.objectStates.get(i.id);if(!o)return;const e=o.options||i.options||{},s=i.geometry.width||160,n=i.geometry.height||40,a=-s/2,r=-n/2,f=e.corner_radius??6,h=e.disabled||e.previewState==="disabled",l=this.lastHoveredObjectId===i.id||e.previewState==="hover",p=(e.isOpen||e.previewState==="active")&&!h;let c=e.backgroundColor,d=e.borderColor,u=e.color||"#333333";h?(c=e.disabledBackgroundColor||"#f3f4f6",d=e.disabledBorderColor||"#e5e7eb",u=e.disabledColor||"#9ca3af"):p?(c=e.activeBackgroundColor||c,d=e.activeBorderColor||d,u=e.activeColor||u):l&&(c=e.hoverBackgroundColor||c,d=e.hoverBorderColor||d,u=e.hoverColor||u),c||(c="#ffffff"),d||(d="#e5e7eb");const v=t.globalAlpha;t.globalAlpha=v*(e.opacity??1),this.drawRoundRect(t,a,r,s,n,f),t.fillStyle=this.createCanvasFill(t,typeof c=="string"?{type:"Solid",color:c}:c,s,n)||"#ffffff",t.fill();const b=e.borderWidth??1;b>0&&(t.strokeStyle=this.createCanvasFill(t,typeof d=="string"?{type:"Solid",color:d}:d,s,n)||"#e5e7eb",t.lineWidth=b,t.stroke());const y=12,m=e.chevronType||"chevron",S=e.chevronSize||16,C=(p?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(m!=="none"){const E=a+s-y-S/2;t.save(),t.translate(E,0);const A=p?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(A*Math.PI/180),t.strokeStyle=C,t.fillStyle=C,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",m==="chevron")t.beginPath(),t.moveTo(-S/2,-S*.2),t.lineTo(0,S*.2),t.lineTo(S/2,-S*.2),t.stroke();else if(m==="custom"||m==="path"){const W=p&&e.openIconPath||e.closedIconPath;if(W){const z=new Path2D(W);t.save();const Y=S/24;t.scale(Y,Y),t.translate(-12,-12),t.fill(z),t.restore()}}t.restore()}const w=e.selectedOption||e.placeholder||"Select...",M=e.fontSize||14,I=e.fontWeight||400,k=e.fontFamily||"Inter, sans-serif";t.font=`${I} ${M}px ${k}`;const T=h?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":u;t.fillStyle=this.createCanvasFill(t,typeof T=="string"?{type:"Solid",color:T}:T,s,n)||"#333333",t.textAlign="left",t.textBaseline="middle";const O=m==="none"?0:S+8,P=s-y*2-O;if(t.save(),t.beginPath(),t.rect(a+y,r,P,n),t.clip(),t.fillText(w,a+y,0),t.restore(),p&&!h){const E=r+n+4,A=e.optionsList||[],W=e.itemHeight||32,z=e.listPadding??4,Y=A.length*W+z*2,G=e.listCornerRadius??f;t.save();const N=e.listShadow||{},J=t.getTransform(),x=Math.sqrt(J.a*J.a+J.b*J.b)||1;t.shadowColor=typeof N.color=="string"?N.color:((_=N.color)==null?void 0:_.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(N.blur??12)*x,t.shadowOffsetY=(N.offsetY??6)*x,t.shadowOffsetX=(N.offsetX??0)*x,t.beginPath(),this.drawRoundRect(t,a,E,s,Y,G),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},s,Y)||"#ffffff",t.fill();const F=e.listBorderWidth??1;F>0&&(t.shadowColor="transparent",t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:d},s,Y)||"#e5e7eb",t.lineWidth=F,t.stroke()),t.restore();const j=e.itemFontSize||M,X=e.itemFontFamily||k;t.font=`${I} ${j}px ${X}`,A.forEach((tt,L)=>{const R=E+z+L*W;if(tt===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},s,W)||"#f3f4f6",t.fillRect(a+F,R,s-F*2,W),t.fillStyle=e.itemSelectedColor||e.accentColor||u||"#374151";else if(t.fillStyle=e.listTextColor||u||"#333333",this.activeDropdownId===i.id&&this._lastPointerPos){const q=this._lastPointerPos.y-(E+z),ot=Math.floor(q/W);L===ot&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},s,W)||"#f9fafb",t.fillRect(a+F,R,s-F*2,W),t.fillStyle=e.itemHoverColor||u)}t.fillText(tt,a+y,R+W/2)})}t.globalAlpha=v}renderButton(t,i){if(i.children&&i.children.length>0)return;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=i.geometry||{},n=s.width||120,a=s.height||40,r=this.lastHoveredObjectId===i.id,f=this.activeObjectId===i.id,h=e.label||{},l=e.hoverStyle||{},p=e.activeStyle||{},c=e.icon||{enabled:!1};let d=e.backgroundColor||"#3b82f6",u=h.color||"#ffffff",v=h.text||"Button",b=s.cornerRadius??8,y=e.borderColor||"transparent",m=e.borderWidth||0,S=1;f&&p?(d=p.backgroundColor||d,u=p.color||u,v=p.text||v,S=p.scale??.95,b=p.cornerRadius??b):r&&l&&(d=l.backgroundColor||d,u=l.color||u,v=l.text||v,S=l.scale??1,b=l.cornerRadius??b,y=l.borderColor||y);const C=-n/2,w=-a/2;t.save(),t.scale(S,S),t.beginPath(),this.drawRoundRect(t,C,w,n,a,b);const M=this.createCanvasFill(t,d,n,a);M&&(t.fillStyle=M,t.fill()),(m>0||r&&l.borderColor)&&(t.strokeStyle=y,t.lineWidth=m||(r?1:0),t.stroke());const I=h.fontSize||14,k=h.fontFamily||"Inter",T=h.fontWeight||600;t.font=`${T} ${I}px "${k}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=u,t.textAlign="center",t.textBaseline="middle";let O=0;if(c.enabled&&c.svgPath){const P=I*1.1,_=c.gap||8,E=t.measureText(v),W=-(E.width+P+_)/2,z=c.position==="left"?W+P/2:W+E.width+_+P/2;O=c.position==="left"?W+P+_+E.width/2:W+E.width/2,t.save(),t.translate(z,0);const Y=new Path2D(c.svgPath),G=P/24;t.scale(G,G),t.translate(-12,-12),t.fillStyle=u,t.fill(Y),t.restore()}t.fillText(v,O,0),t.restore()}renderToggleButton(t,i){var v,b;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=e.checked??!1,n=((v=i.geometry)==null?void 0:v.width)||120,a=((b=i.geometry)==null?void 0:b.height)||40,r=-n/2,f=-a/2,h=e.corner_radius??8,l=e.label||{},p=s?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",c=s?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,r,f,n,a,h),t.fillStyle=p,t.fill();const d=l.fontSize||14,u=l.fontFamily||"Inter";t.font=`${l.fontWeight||600} ${d}px "${u}", sans-serif`,t.fillStyle=c,t.textAlign="center",t.textBaseline="middle",t.fillText(l.text||"Toggle",0,0),t.restore()}renderToggle(t,i){var G,N,J,x,F,j,X,tt,L,R,D,q;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((G=i.geometry)==null?void 0:G.width)||52,n=((N=i.geometry)==null?void 0:N.height)||30,a=-s/2,r=-n/2,f=e.checked??!1,h=e.cornerRadius??e.corner_radius??n/2,l=e.toggleStyle||{},p=l.backgroundColor||e.activeColor||"#10b981",c=l.borderColor||e.borderColor||"transparent",d=l.borderWidth??e.borderWidth??0,u=l.knobColor||e.knobColor||"#ffffff",v=f?p:e.inactiveColor||"#374151",b=f?c:e.borderColor||"transparent",y=f?d:e.borderWidth??0,m=f?u:e.knobColor||"#ffffff";e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,s,n,h);const S=this.createCanvasFill(t,v,s,n);if(S&&(t.fillStyle=S,t.fill()),y>0){t.lineWidth=y;const ot=this.createCanvasFill(t,b,s,n);ot&&(t.strokeStyle=ot,t.stroke())}const C=2,w=n-C*2,M=w/2,I=a+C,k=a+s-C-w,T=f?k:I,O=r+C;t.beginPath(),t.arc(T+M,O+M,M,0,Math.PI*2);const P=this.createCanvasFill(t,m,w,w);P&&(t.fillStyle=P,t.fill()),e.disabled&&(t.globalAlpha*=2);let _=!1,E=!1;const A=(f?(J=l.leftLabel)==null?void 0:J.text:null)||((x=e.leftLabel)==null?void 0:x.text)||"",W=(f?(F=l.leftLabel)==null?void 0:F.color:null)||((j=e.leftLabel)==null?void 0:j.color)||"#f3f4f6";if((X=e.leftLabel)!=null&&X.enabled&&A){const ot=e.leftLabel;t.font=`${ot.fontWeight||400} ${ot.fontSize||12}px "${ot.fontFamily||"Inter"}", sans-serif`,t.fillStyle=W,t.textBaseline="middle",t.textAlign="right",t.fillText(A,a-(ot.gap||8),0),_=!0}const z=(f?(tt=l.rightLabel)==null?void 0:tt.text:null)||((L=e.rightLabel)==null?void 0:L.text)||"",Y=(f?(R=l.rightLabel)==null?void 0:R.color:null)||((D=e.rightLabel)==null?void 0:D.color)||"#f3f4f6";if((q=e.rightLabel)!=null&&q.enabled&&z){const ot=e.rightLabel;t.font=`${ot.fontWeight||400} ${ot.fontSize||12}px "${ot.fontFamily||"Inter"}", sans-serif`,t.fillStyle=Y,t.textBaseline="middle",t.textAlign="left",t.fillText(z,a+s+(ot.gap||8),0),E=!0}if(!_&&!E&&e.label&&e.label.text){const ot=e.label,mt=ot.fontSize||14,bt=ot.fontWeight||400,gt=ot.fontFamily||"Inter";t.font=`${bt} ${mt}px "${gt}", sans-serif`,t.fillStyle=ot.color||"#f3f4f6",t.textBaseline="middle";const Et=ot.gap||10;let It=0,vt=0;ot.position==="left"?(t.textAlign="right",It=a-Et,vt=0):ot.position==="right"?(t.textAlign="left",It=a+s+Et,vt=0):ot.position==="top"?(t.textAlign="center",It=0,vt=r-Et,t.textBaseline="bottom"):ot.position==="bottom"?(t.textAlign="center",It=0,vt=r+n+Et,t.textBaseline="top"):(t.textAlign="left",It=a+s+Et,vt=0),t.fillText(ot.text,It,vt)}}renderCheckbox(t,i){var S,C;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((S=i.geometry)==null?void 0:S.width)||20,n=((C=i.geometry)==null?void 0:C.height)||20,a=-s/2,r=-n/2,f=e.cornerRadius??4,h=e.checked??!1,l=e.activeColor||"#3b82f6",p=e.inactiveColor||"transparent",c=e.checkColor||"#ffffff",d=e.borderColor||"#4b5563",u=e.borderWidth??2,v=h?l:p,b=h?"transparent":d,y=h?0:u;e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,s,n,f);const m=this.createCanvasFill(t,v,s,n);if(m&&(t.fillStyle=m,t.fill()),y>0){t.lineWidth=y;const w=this.createCanvasFill(t,b,s,n);w&&(t.strokeStyle=w,t.stroke())}else if(h){t.lineWidth=1;const w=this.createCanvasFill(t,l,s,n);w&&(t.strokeStyle=w,t.stroke())}if(h){t.save(),t.beginPath();const w=this.createCanvasFill(t,c,s,n);t.strokeStyle=w||c,t.lineWidth=Math.max(2,s*.12),t.lineCap="round",t.lineJoin="round";const M=a+s*.25,I=r+n*.5,k=a+s*.45,T=r+n*.7,O=a+s*.75,P=r+n*.25;t.moveTo(M,I),t.lineTo(k,T),t.lineTo(O,P),t.stroke(),t.restore()}if(e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const w=e.label;t.save(),t.font=`${w.fontWeight||400} ${w.fontSize||14}px "${w.fontFamily||"Inter"}", sans-serif`,t.fillStyle=w.color||"#f3f4f6",t.textBaseline="middle";const M=w.gap||8;let I=0,k=0;w.position==="left"?(t.textAlign="right",I=a-M,k=0):w.position==="right"?(t.textAlign="left",I=a+s+M,k=0):w.position==="top"?(t.textAlign="center",I=0,k=r-M,t.textBaseline="bottom"):w.position==="bottom"&&(t.textAlign="center",I=0,k=r+n+M,t.textBaseline="top"),t.fillText(w.text,I,k),t.restore()}}renderRadioGroup(t,i){var C,w;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((C=i.geometry)==null?void 0:C.width)||180,n=((w=i.geometry)==null?void 0:w.height)||100,a=-s/2,r=-n/2,f=e.selectedValue,h=e.optionsList||["Option 1","Option 2","Option 3"],l=e.orientation||"vertical",p=e.itemGap!==void 0?e.itemGap:16,c=e.activeColor||"#3b82f6",d=e.inactiveColor||"#4b5563",u=e.textColor||"#ffffff",v=e.fontSize||14,b=e.fontFamily||"Inter",y=e.fontWeight||400;e.disabled&&(t.globalAlpha*=.5);const m=8,S=m*2;if(t.save(),t.font=`${y} ${v}px "${b}", sans-serif`,t.textBaseline="middle",t.textAlign="left",l==="vertical"){const M=Math.max(S,v)+p;h.forEach((I,k)=>{const T=r+k*M+m;t.beginPath(),t.arc(a+m,T,m,0,Math.PI*2);const O=f===I,P=this.createCanvasFill(t,c,S,S),_=this.createCanvasFill(t,d,S,S);O?(t.strokeStyle=P||c,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(a+m,T,m/2,0,Math.PI*2),t.fillStyle=P||c,t.fill()):(t.strokeStyle=_||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(I,a+S+8,T)})}else{let M=a;h.forEach(I=>{const k=f===I,T=t.measureText(I).width;t.beginPath(),t.arc(M+m,0,m,0,Math.PI*2);const O=this.createCanvasFill(t,c,S,S),P=this.createCanvasFill(t,d,S,S);k?(t.strokeStyle=O||c,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(M+m,0,m/2,0,Math.PI*2),t.fillStyle=O||c,t.fill()):(t.strokeStyle=P||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(I,M+S+6,0),M+=S+6+T+p})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const M=e.label;t.save(),t.font=`${M.fontWeight||400} ${M.fontSize||14}px "${M.fontFamily||"Inter"}", sans-serif`,t.fillStyle=M.color||"#9ca3af",t.textBaseline="middle";const I=M.gap||8;let k=0,T=0;M.position==="left"?(t.textAlign="right",k=a-I,T=0):M.position==="right"?(t.textAlign="left",k=a+s+I,T=0):M.position==="top"?(t.textAlign="center",k=0,T=r-I,t.textBaseline="bottom"):M.position==="bottom"&&(t.textAlign="center",k=0,T=r+n+I,t.textBaseline="top"),t.fillText(M.text,k,T),t.restore()}}renderBarChart(t,i){var T,O;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s={width:((T=i.geometry)==null?void 0:T.width)||300,height:((O=i.geometry)==null?void 0:O.height)||180,chartType:e.chartType||"grouped",stylePreset:e.stylePreset||"default",datasets:e.datasets||[{id:"ds-1",label:"Revenue",data:[42,67,31,55,78,48],color:"#6366f1"}],categories:e.categories||["Jan","Feb","Mar","Apr","May","Jun"],orientation:e.orientation||"vertical",barWidth:e.barWidth!==void 0?e.barWidth:14,barGap:e.barGap!==void 0?e.barGap:4,barCornerRadius:e.barCornerRadius!==void 0?e.barCornerRadius:5,showXAxis:!!e.showXAxis,showYAxis:!!e.showYAxis,xAxisColor:e.xAxisColor||"rgba(255,255,255,0.12)",yAxisColor:e.yAxisColor||"rgba(255,255,255,0.12)",showXLabels:e.showXLabels!==void 0?!!e.showXLabels:!0,showYLabels:!!e.showYLabels,axisLabelColor:e.axisLabelColor||"rgba(255,255,255,0.5)",axisLabelFontSize:e.axisLabelFontSize||9,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.7)",legendFontSize:e.legendFontSize||9,showGridLines:e.showGridLines!==void 0?!!e.showGridLines:!0,gridColor:e.gridColor||"rgba(255,255,255,0.06)",cardBackground:e.cardBackground||"rgba(255,255,255,0.04)",cardBorderColor:e.cardBorderColor||"rgba(255,255,255,0.08)",barGradient:e.barGradient!==void 0?!!e.barGradient:!0,showValueOnTop:!!e.showValueOnTop,chartBackground:e.chartBackground||"transparent",barStyle:e.barStyle||"solid",barBorderWidth:e.barBorderWidth!==void 0?e.barBorderWidth:1,barBorderColor:e.barBorderColor||"auto",enableShadows:!!e.enableShadows,shadowColor:e.shadowColor||"rgba(0,0,0,0.5)",shadowBlur:e.shadowBlur!==void 0?e.shadowBlur:4,shadowOffsetY:e.shadowOffsetY!==void 0?e.shadowOffsetY:2,valueFontSize:e.valueFontSize||10,valueColor:e.valueColor||"auto",valueFontWeight:e.valueFontWeight||"bold",xAxisLineWidth:e.xAxisLineWidth!==void 0?e.xAxisLineWidth:1,yAxisLineWidth:e.yAxisLineWidth!==void 0?e.yAxisLineWidth:1,gridLineWidth:e.gridLineWidth!==void 0?e.gridLineWidth:1,gridLineDash:e.gridLineDash||[3,4],_getPreset:function(){return ps[this.stylePreset]||ps.default},_resolveColor:function(P,_){const E=this._getPreset();return["#6366f1","#f59e0b","#10b981","#3b82f6","#a855f7"].includes(P)?E.colors[_%E.colors.length]:typeof P=="string"?P:E.colors[_%E.colors.length]},_makeGradient:function(P,_,E,A,W,z){if(!this._getPreset().barGradient&&!this.barGradient)return _;const G=P.createLinearGradient(E,A,W,z);return G.addColorStop(0,_),G.addColorStop(1,_+"44"),G},_drawRoundedBar:function(P,_,E,A,W,z,Y){if(z=Math.min(z,Math.min(Math.abs(A),Math.abs(W))/2),z<=0||A===0||W===0){P.rect(_,E,A,W);return}P.beginPath(),Y?(P.moveTo(_,E+W),P.lineTo(_,E+z),P.quadraticCurveTo(_,E,_+z,E),P.lineTo(_+A-z,E),P.quadraticCurveTo(_+A,E,_+A,E+z),P.lineTo(_+A,E+W),P.lineTo(_,E+W)):(P.moveTo(_,E),P.lineTo(_+A-z,E),P.quadraticCurveTo(_+A,E,_+A,E+z),P.lineTo(_+A,E+W-z),P.quadraticCurveTo(_+A,E+W,_+A-z,E+W),P.lineTo(_,E+W),P.lineTo(_,E)),P.closePath()}},n=s.width,a=s.height,r=-n/2,f=-a/2;if(!s.datasets||s.datasets.length===0||s.categories.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.7)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO CHART DATA",0,0),t.restore();return}const h=s._getPreset();let l=-1/0,p=1/0;const c=s.categories.length,d=s.datasets.length;if(s.chartType==="stacked")for(let P=0;P<c;P++){let _=0,E=0;s.datasets.forEach(A=>{const W=A.data[P]??0;W>=0?_+=W:E+=W}),_>l&&(l=_),E<p&&(p=E)}else s.datasets.forEach(P=>{P.data&&P.data.forEach(_=>{_>l&&(l=_),_<p&&(p=_)})});isFinite(l)||(l=10),isFinite(p)||(p=0),l=Math.max(l,0),p=Math.min(p,0);const u=l-p||10;t.save(),s.enableShadows&&(t.shadowColor=s.shadowColor,t.shadowBlur=s.shadowBlur,t.shadowOffsetY=s.shadowOffsetY),t.font=s.axisLabelFontSize+"px Inter, sans-serif";const v=s.showYLabels?t.measureText(l.toFixed(0)).width+14:10,b=s.showXLabels?s.axisLabelFontSize+12:8,m=(s.showLegend&&d>0?s.legendFontSize+10:0)+8,S=10,C=r+v,w=f+m,M=n-v-S,I=a-m-b;if(s.enableShadows&&(t.shadowColor="transparent"),t.beginPath(),t.roundRect(r,f,n,a,10),t.fillStyle=h.cardBackground,t.fill(),t.strokeStyle=h.cardBorderColor,t.lineWidth=1,t.stroke(),s.chartBackground&&s.chartBackground!=="transparent"&&(t.beginPath(),t.rect(C,w,M,I),t.fillStyle=s.chartBackground,t.fill()),s.showLegend&&d>0){t.font=s.legendFontSize+"px Inter, sans-serif",t.textBaseline="middle";const P=f+12;let _=C;s.datasets.forEach((E,A)=>{const W=s._resolveColor(E.color,A),z=E.label||"Series "+(A+1),Y=7;t.beginPath(),t.roundRect(_,P-Y/2,Y,Y,2),t.fillStyle=W,t.fill(),t.fillStyle=h.legendColor,t.textAlign="left",t.fillText(z,_+Y+4,P),_+=t.measureText(z).width+Y+16})}const k=4;if(s.showGridLines){t.setLineDash(s.gridLineDash||[]),t.lineWidth=s.gridLineWidth||1,t.strokeStyle=h.gridColor;for(let P=0;P<=k;P++)if(s.orientation==="horizontal"){const _=C+P/k*M;t.beginPath(),t.moveTo(_,w),t.lineTo(_,w+I),t.stroke()}else{const _=w+P/k*I;t.beginPath(),t.moveTo(C,_),t.lineTo(C+M,_),t.stroke()}t.setLineDash([])}if(s.showYLabels){t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor;for(let P=0;P<=k;P++)if(s.orientation==="horizontal"){const _=p+P/k*u,E=C+P/k*M;t.textAlign="center",t.fillText(_.toFixed(0),E,w+I+s.axisLabelFontSize)}else{const _=l-P/k*u,E=w+P/k*I;t.textAlign="right",t.fillText(_.toFixed(0),C-6,E)}}if(t.setLineDash([]),s.showXAxis&&(t.lineWidth=s.xAxisLineWidth||1,t.strokeStyle=s.xAxisColor,t.beginPath(),t.moveTo(C,w+I),t.lineTo(C+M,w+I),t.stroke()),s.showYAxis&&(t.lineWidth=s.yAxisLineWidth||1,t.strokeStyle=s.yAxisColor,t.beginPath(),t.moveTo(C,w),t.lineTo(C,w+I),t.stroke()),s.enableShadows&&(t.shadowColor=s.shadowColor),s.chartType==="stacked")if(s.orientation==="horizontal"){const P=I/c;for(let _=0;_<c;_++){const E=w+_*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[_]||"",C-5,E),s.enableShadows&&(t.shadowColor=s.shadowColor));let A=C;s.datasets.forEach((W,z)=>{const Y=W.data[_]??0;if(Y===0)return;const G=Y/u*M,N=Math.min(s.barWidth*d+s.barGap,P-8),J=E-N/2,x=A;A+=G;const F=s._resolveColor(W.color,z);t.beginPath(),t.fillStyle=s._makeGradient(t,F,x,J,x+G,J),s._drawRoundedBar(t,x,J,G,N,z===d-1?s.barCornerRadius:0,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?F:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else{const P=M/c;for(let _=0;_<c;_++){const E=C+_*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[_]||"",E,w+I+5),s.enableShadows&&(t.shadowColor=s.shadowColor));let A=w+I;s.datasets.forEach((W,z)=>{const Y=W.data[_]??0;if(Y===0)return;const G=Y/u*I,N=Math.min(s.barWidth*d+s.barGap,P-8),J=E-N/2,x=A-G;A-=G;const F=s._resolveColor(W.color,z);t.beginPath(),t.fillStyle=s._makeGradient(t,F,J,x,J,x+G),s._drawRoundedBar(t,J,x,N,G,z===d-1?s.barCornerRadius:0,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?F:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else if(s.orientation==="horizontal"){const P=I/c,_=d*s.barWidth+Math.max(0,(d-1)*s.barGap),E=C+(0-p)/u*M;for(let A=0;A<c;A++){const W=w+A*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[A]||"",C-5,W),s.enableShadows&&(t.shadowColor=s.shadowColor));const z=W-_/2;s.datasets.forEach((Y,G)=>{const N=Y.data[A]??0,J=Math.abs(N/u*M);if(J<1)return;const x=z+G*(s.barWidth+s.barGap),F=N>=0?E:E-J,j=s._resolveColor(Y.color,G);t.beginPath(),t.fillStyle=s._makeGradient(t,j,F,x,F+J,x),s._drawRoundedBar(t,F,x,J,s.barWidth,s.barCornerRadius,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?j:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&N!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign=N>=0?"left":"right",t.textBaseline="middle",t.fillStyle=s.valueColor==="auto"?j:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(N.toString(),N>=0?F+J+4:F-4,x+s.barWidth/2),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}else{const P=M/c,_=d*s.barWidth+Math.max(0,(d-1)*s.barGap),E=w+I-(0-p)/u*I;for(let A=0;A<c;A++){const W=C+A*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[A]||"",W,w+I+5),s.enableShadows&&(t.shadowColor=s.shadowColor));const z=W-_/2;s.datasets.forEach((Y,G)=>{const N=Y.data[A]??0,J=Math.abs(N/u*I);if(J<1)return;const x=z+G*(s.barWidth+s.barGap),F=N>=0?E-J:E,j=s._resolveColor(Y.color,G);t.beginPath(),t.fillStyle=s._makeGradient(t,j,x,F,x,F+J),s._drawRoundedBar(t,x,F,s.barWidth,J,s.barCornerRadius,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?j:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&N!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign="center",t.textBaseline=N>=0?"bottom":"top",t.fillStyle=s.valueColor==="auto"?j:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(N.toString(),x+s.barWidth/2,N>=0?F-4:F+J+4),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}t.restore()}renderPieChart(t,i){var v,b;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s={width:((v=i.geometry)==null?void 0:v.width)||180,height:((b=i.geometry)==null?void 0:b.height)||180,chartType:e.chartType||"donut",stylePreset:e.stylePreset||"default",slices:e.slices||[{id:"slice-1",label:"Item 1",value:45,color:"#6366f1"}],innerRadius:e.innerRadius!==void 0?e.innerRadius:.55,sliceGap:e.sliceGap!==void 0?e.sliceGap:3,showLabels:!!e.showLabels,labelColor:e.labelColor||"#ffffff",labelFontSize:e.labelFontSize||10,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.65)",legendFontSize:e.legendFontSize||9,showCenterText:e.showCenterText!==void 0?!!e.showCenterText:!0,centerLabel:e.centerLabel||"Total",centerTextColor:e.centerTextColor||"#ffffff",centerLabelColor:e.centerLabelColor||"rgba(255,255,255,0.4)",_getPreset:function(){return gs[this.stylePreset]||gs.default},_resolveSliceColor:function(y,m){const S=y.color,C=m,w=this._getPreset();return["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399","#a855f7","#f87171"].includes(S)?w.colors[C%w.colors.length]:typeof S=="string"?S:w.colors[C%w.colors.length]}},n=s.width,a=s.height;if(!s.slices||s.slices.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO PIE DATA",0,0),t.restore();return}const r=s.slices.reduce((y,m)=>y+(m.value||0),0);if(r<=0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("EMPTY DATA",0,0),t.restore();return}const f=s._getPreset();t.save(),t.beginPath(),t.roundRect(-n/2,-a/2,n,a,10),t.fillStyle=f.cardBackground,t.fill(),t.strokeStyle=f.cardBorderColor,t.lineWidth=1,t.stroke();const h=s.showLegend?Math.ceil(s.slices.length/2):0,l=h>0?h*(s.legendFontSize+8)+10:0,p=a-l-16,c=Math.min(n-24,p)/2,d=0,u=-l/2;if(s.chartType==="rose"){const y=Math.max(...s.slices.map(C=>C.value||0)),m=Math.PI*2/s.slices.length,S=c>0?s.sliceGap/c:0;s.slices.forEach((C,w)=>{const M=C.value||0;if(M===0)return;const I=M/y*c,k=-Math.PI/2+w*m+S/2,T=k+m-S,O=s._resolveSliceColor(C,w);if(t.beginPath(),t.moveTo(d,u),t.arc(d,u,I,k,T),t.closePath(),t.fillStyle=O+"cc",t.fill(),t.strokeStyle=O,t.lineWidth=1.5,t.stroke(),s.showLabels){const P=k+(T-k)/2,_=d+I*.65*Math.cos(P),E=u+I*.65*Math.sin(P),A=Math.round(M/r*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=f.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${A}%`,_,E),t.restore()}})}else{const y=s.chartType==="pie"?0:s.innerRadius,m=c*Math.max(0,y),S=c>0?s.sliceGap/c:0;let C=-Math.PI/2;if(s.slices.forEach((w,M)=>{const I=w.value||0;if(I===0){C+=I/r*Math.PI*2;return}const k=I/r*Math.PI*2,T=C+S/2,O=C+k-S/2;if(O<=T){C+=k;return}const P=s._resolveSliceColor(w,M);if(t.beginPath(),t.fillStyle=P,m<=0?(t.moveTo(d,u),t.arc(d,u,c,T,O),t.lineTo(d,u)):(t.moveTo(d+c*Math.cos(T),u+c*Math.sin(T)),t.arc(d,u,c,T,O),t.arc(d,u,m,O,T,!0),t.closePath()),t.fill(),s.showLabels){const _=T+(O-T)/2,E=m+(c-m)/2,A=d+E*Math.cos(_),W=u+E*Math.sin(_),z=Math.round(I/r*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=f.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${z}%`,A,W),t.restore()}C+=k}),s.chartType==="donut"&&s.showCenterText&&m>14){const w=Math.round(r),M=Math.min(Math.floor(m*.52),20),I=Math.min(Math.floor(m*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${M}px Inter, sans-serif`,t.fillStyle=f.centerTextColor,t.fillText(w.toString(),d,u-I*.5),s.centerLabel&&(t.font=`${I}px Inter, sans-serif`,t.fillStyle=f.centerLabelColor,t.fillText(s.centerLabel,d,u+M*.6))}}if(s.showLegend&&s.slices.length>0){t.font=`${s.legendFontSize}px Inter, sans-serif`;const y=2,m=n/y,S=s.legendFontSize+8,C=a/2-l+10,w=-n/2+10;s.slices.forEach((M,I)=>{const k=I%y,T=Math.floor(I/y),O=w+k*m,P=C+T*S,_=s._resolveSliceColor(M,I),E=7;t.beginPath(),t.roundRect(O,P-E/2,E,E,2),t.fillStyle=_,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=f.legendColor;const A=Math.round((M.value||0)/r*100),W=`${M.label||"Item"} ${A}%`,z=m-E-20;let Y=W;for(;t.measureText(Y).width>z&&Y.length>4;)Y=Y.slice(0,-4)+"…";t.fillText(Y,O+E+4,P)})}t.restore()}renderJoystick(t,i){var u,v,b,y,m;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.width)!==void 0?o.width:((u=i.geometry)==null?void 0:u.width)??i.width??100,s=(o==null?void 0:o.height)!==void 0?o.height:((v=i.geometry)==null?void 0:v.height)??i.height??100,n=Math.min(e,s)*.45,a=Math.min(e,s)*.15;let r=i.handleX||0,f=i.handleY||0;o&&o.handleX!==void 0&&(r=o.handleX),o&&o.handleY!==void 0&&(f=o.handleY),t.save();let h=0,l=0;i.handleOrigin==="top-left"?(h=e/2,l=s/2):i.handleOrigin==="bottom-right"&&(h=-e/2,l=-s/2),t.translate(h,l),t.beginPath(),i.boundsShape==="square"?t.rect(-n,-n,n*2,n*2):t.arc(0,0,n,0,Math.PI*2),t.fillStyle="rgba(0,0,0,0.2)",(b=i.style)!=null&&b.fill&&typeof i.style.fill=="string"?t.fillStyle=i.style.fill:(y=i.style)!=null&&y.fill&&i.style.fill.type==="solid"&&(t.fillStyle=i.style.fill.color),t.fill(),(m=i.style)!=null&&m.stroke&&i.style.stroke.isEnabled!==!1&&(t.lineWidth=i.style.stroke.width||1,t.strokeStyle=i.style.stroke.color||"#000",t.stroke());const p=n-a;let c=0,d=0;i.joystickType==="2D"?(c=r*p,d=f*p):i.joystickType==="1D_X"?(c=r*p,d=0):i.joystickType==="1D_Y"&&(c=0,d=f*p),t.beginPath(),t.arc(c,d,a,0,Math.PI*2),t.fillStyle="#fff",t.fill(),t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1,t.stroke(),t.restore()}getRadioGroupItemIndexAtPointer(t,i,o){var I,k;const e=t.options||{},s=this.objectStates.get(t.id)||{},n=e.optionsList||[];if(n.length===0)return null;const a=s.width!==void 0?s.width:((I=t.geometry)==null?void 0:I.width)||180,r=s.height!==void 0?s.height:((k=t.geometry)==null?void 0:k.height)||100,f=e.orientation||"vertical",h=e.itemGap!==void 0?e.itemGap:16,l=e.fontSize||14,p=this.getWorldTransform(t.id),c=i-p.x,d=o-p.y,u=-p.rotation*(Math.PI/180),v=Math.cos(u),b=Math.sin(u),y=c*v-d*b,m=c*b+d*v,C=8*2,w=-a/2,M=-r/2;if(f==="vertical"){const T=Math.max(C,l)+h;for(let O=0;O<n.length;O++){const P=M+O*T;if(y>=w&&y<=w+a&&m>=P&&m<=P+T)return O}}else{let T=w;for(let O=0;O<n.length;O++){const _=n[O].length*8,E=C+6+_+h;if(y>=T&&y<=T+E&&m>=M&&m<=M+r)return O;T+=E}}return null}renderLineGraph(t,i,o,e){let s=i.datasets||[];if((!s||s.length===0)&&(i.data||i.graphData)&&(s=[{id:"line-1",label:"Series 1",data:i.data||i.graphData||[],lineColor:i.lineColor||"#3b82f6",lineWidth:i.lineWidth||2,showArea:i.showArea||!1,areaColor:i.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:i.smoothing||!1,showPoints:i.showPoints!==void 0?i.showPoints:!0,pointSize:i.pointSize||6,pointFill:i.pointFill||"#ffffff",pointStrokeColor:i.pointStrokeColor||i.lineColor||"#3b82f6",pointStrokeWidth:i.pointStrokeWidth||2}]),!s||s.length===0||!s.some(u=>u.data&&u.data.length>=2)){t.save(),t.fillStyle="#6366f1",t.font="12px Inter, system-ui, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO DATA",0,0),t.restore();return}let n=1/0,a=-1/0,r=0;if(s.forEach(u=>{let v=u.data;if(u.isVarEnabled&&u.inputId){let b=this.inputs.get(u.inputId);if(b===void 0){const y=this.inputNameMap.get(u.inputId);y&&y.length>0&&(b=this.inputs.get(y[0]))}b&&Array.isArray(b)&&(v=b)}if(v&&v.length>0){const b=v.filter(y=>typeof y=="number"&&!isNaN(y));b.length>0&&(n=Math.min(n,...b),a=Math.max(a,...b),r=Math.max(r,v.length))}u._resolvedData=v}),r<2)return;const f=a-n,h=o/(r-1),l=u=>{const v=f===0?.5:(u-n)/f;return e/2-v*e},p=u=>u*h-o/2,c=i.axisColor||"#333333";if(i.showXAxis&&(t.beginPath(),t.strokeStyle=i.xAxisColor||c,t.lineWidth=1,t.moveTo(-o/2,e/2),t.lineTo(o/2,e/2),t.stroke()),i.showYAxis&&(t.beginPath(),t.strokeStyle=i.yAxisColor||c,t.lineWidth=1,t.moveTo(-o/2,-e/2),t.lineTo(-o/2,e/2),t.stroke()),t.fillStyle=i.axisLabelColor||"#333333",t.font=`${i.axisLabelFontSize||10}px Inter, sans-serif`,i.showXLabels){t.textAlign="center",t.textBaseline="top";for(let u=0;u<r;u++){const v=p(u);t.fillText(`${u+1}`,v,e/2+5)}}if(i.showYLabels){t.textAlign="right",t.textBaseline="middle";const u=-o/2-5,v=(a+n)/2;t.fillText(a.toFixed(1),u,l(a)),t.fillText(v.toFixed(1),u,l(v)),t.fillText(n.toFixed(1),u,l(n))}const d=10;if(s.forEach(u=>{const v=u._resolvedData;if(!(!v||v.length<2)){if(u.showArea){if(t.beginPath(),t.moveTo(p(0),e/2),t.lineTo(p(0),l(v[0])),u.smoothing&&v.length>2)for(let y=0;y<v.length-1;y++){const m=v[y===0?y:y-1],S=v[y],C=v[y+1],w=v[y+1===v.length-1?y+1:y+2];for(let M=1;M<=d;M++){const I=M/d,k=this._catmullRom(m,S,C,w,I);t.lineTo(p(y+I),l(k))}}else for(let y=1;y<v.length;y++)t.lineTo(p(y),l(v[y]));t.lineTo(p(v.length-1),e/2),t.closePath();const b=t.globalAlpha;t.globalAlpha=b*(i.areaOpacity??.3),t.fillStyle=u.areaColor||"rgba(139, 92, 246, 0.2)",t.fill(),t.globalAlpha=b}if(t.beginPath(),t.strokeStyle=u.lineColor||"#3b82f6",t.lineWidth=u.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.moveTo(p(0),l(v[0])),u.smoothing&&v.length>2)for(let b=0;b<v.length-1;b++){const y=v[b===0?b:b-1],m=v[b],S=v[b+1],C=v[b+1===v.length-1?b+1:b+2];for(let w=1;w<=d;w++){const M=w/d,I=this._catmullRom(y,m,S,C,M);t.lineTo(p(b+M),l(I))}}else for(let b=1;b<v.length;b++)t.lineTo(p(b),l(v[b]));t.stroke(),u.showPoints&&v.forEach((b,y)=>{const m=p(y),S=l(b);t.beginPath(),t.arc(m,S,(u.pointSize||6)/2,0,Math.PI*2),t.fillStyle=u.pointFill||"#ffffff",t.fill(),t.strokeStyle=u.pointStrokeColor||u.lineColor||"#3b82f6",t.lineWidth=u.pointStrokeWidth||1,t.stroke()})}}),i.showLegend&&s.length>0){const u=o/2-10;let v=-e/2+15;const b=i.legendFontSize||10,y=b+5;t.font=`${b}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",s.forEach(m=>{const C=m.label||"Series",w=t.measureText(C).width;t.beginPath(),t.rect(u-w-8-5,v-(8/2+2),8,8),t.fillStyle=m.lineColor||"#3b82f6",t.fill(),t.fillStyle=i.legendColor||"#333333",t.fillText(C,u,v),v+=y})}}_catmullRom(t,i,o,e,s){const n=(o-t)*.5,a=(e-i)*.5,r=s*s,f=s*r;return(2*i-2*o+n+a)*f+(-3*i+3*o-2*n-a)*r+n*s+i}normalizeOpacity(t){const i=typeof t=="number"?t:parseFloat(String(t));return isNaN(i)?1:i>1?Math.min(1,i/100):Math.max(0,Math.min(1,i))}createCanvasFill(t,i,o,e){var s,n,a;if(!i||i.type==="None")return null;if(typeof i=="string")return i;if(i.type==="Solid"&&i.color){const r=i.color,h=(((n=(s=this.artboard)==null?void 0:s.tokens)==null?void 0:n.colors)||{})[r]||r;return t.fillStyle=h,h}if((i.type==="LinearGradient"||i.type==="RadialGradient"||i.type==="AngularGradient"||i.type==="DiamondGradient")&&i.stops){const r=(f,h=100)=>{var S,C;const p=(((C=(S=this.artboard)==null?void 0:S.tokens)==null?void 0:C.colors)||{})[f]||f,c=this.normalizeOpacity(i.opacity??100),u=this.normalizeOpacity(h)*c;if(u>=1&&p.startsWith("#"))return p;const v=p.startsWith("#")?p.replace("#",""):"ffffff",b=parseInt(v.substring(0,2),16),y=parseInt(v.substring(2,4),16),m=parseInt(v.substring(4,6),16);return`rgba(${b}, ${y}, ${m}, ${u})`};if(i.type==="LinearGradient"){const f=(u,v,b)=>Array.isArray(u)?u[v]??(v===0?0:1):u&&typeof u=="object"?u[b]??(v===0?0:1):v===0?0:1,h=f(i.start,0,"x")*o-o/2,l=f(i.start,1,"y")*e-e/2,p=f(i.end,0,"x")*o-o/2,c=f(i.end,1,"y")*e-e/2,d=t.createLinearGradient(h,l,p,c);if(i.stops.forEach(u=>{const v=u.offset!==void 0?u.offset:u.pos!==void 0?u.pos:u.position!==void 0?u.position:0,b=r(u.color||"#000000",u.opacity??100);d.addColorStop(Math.max(0,Math.min(1,v)),b)}),i.gradientTransform&&d.setTransform){const[u,v,b,y,m,S]=i.gradientTransform;d.setTransform({a:u,b:v,c:b,d:y,e:m,f:S})}return d}else if(i.type==="RadialGradient"){const f=(d,u,v)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[v]??.5:.5,h=f(i.center,0,"x")*o-o/2,l=f(i.center,1,"y")*e-e/2,p=(i.radius??.5)*Math.max(o,e),c=t.createRadialGradient(h,l,0,h,l,p);if(i.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,v=r(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,u)),v)}),i.gradientTransform&&c.setTransform){const[d,u,v,b,y,m]=i.gradientTransform;c.setTransform({a:d,b:u,c:v,d:b,e:y,f:m})}return c}else if(i.type==="AngularGradient"){const f=(d,u,v)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[v]??.5:.5,h=f(i.center||[.5,.5],0,"x")*o-o/2,l=f(i.center||[.5,.5],1,"y")*e-e/2,p=(i.degree||i.angle||0)*(Math.PI/180),c=(a=t.createConicGradient)==null?void 0:a.call(t,p,h,l);if(c){if(i.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,v=r(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,u)),v)}),i.gradientTransform&&c.setTransform){const[d,u,v,b,y,m]=i.gradientTransform;c.setTransform({a:d,b:u,c:v,d:b,e:y,f:m})}return c}}else if(i.type==="DiamondGradient"){const f=(d,u,v)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[v]??.5:.5,h=f(i.center||[.5,.5],0,"x")*o-o/2,l=f(i.center||[.5,.5],1,"y")*e-e/2,p=(i.radius??.5)*Math.max(o,e);t.save(),t.translate(h,l),t.rotate(Math.PI/4);const c=t.createRadialGradient(0,0,0,0,0,p);if(i.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,v=r(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,u)),v)}),i.gradientTransform&&c.setTransform){const[d,u,v,b,y,m]=i.gradientTransform;c.setTransform({a:d,b:u,c:v,d:b,e:y,f:m})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=c,t.restore(),c}}if(i.type==="Pattern"&&i.url){let r=this.imageCache.get(i.url);if(r||(r=new Image,r.src=i.url,this.imageCache.set(i.url,r)),r.complete&&r.naturalWidth>0){const f=t.createPattern(r,"repeat");if(f&&(i.scaleX!==void 0||i.offsetX!==void 0)){const h=new DOMMatrix,l=i.scaleX??1,p=i.scaleY??1,c=i.offsetX??0,d=i.offsetY??0,u=i.rotation??0;h.translateSelf(c,d),h.rotateSelf(u),h.scaleSelf(l,p),f.setTransform(h)}return f}}return i.color||null}drawRoundRect(t,i,o,e,s,n){if(n===0||n===void 0||n===null){t.rect(i,o,e,s);return}let a=n;if(typeof a=="string")try{a=JSON.parse(a)}catch{a=parseFloat(a)||0}let r=0,f=0,h=0,l=0;typeof a=="number"?r=f=h=l=a:Array.isArray(a)?a.length===1?r=f=h=l=a[0]:a.length===2?(r=h=a[0],f=l=a[1]):a.length===3?(r=a[0],f=l=a[1],h=a[2]):a.length>=4&&(r=a[0],f=a[1],h=a[2],l=a[3]):a&&typeof a=="object"&&(r=a.tl??a.corner_radius??a.cornerRadius??0,f=a.tr??a.corner_radius??a.cornerRadius??0,h=a.br??a.corner_radius??a.cornerRadius??0,l=a.bl??a.corner_radius??a.cornerRadius??0);const p=Math.min(Math.abs(e)/2,Math.abs(s)/2);if(r=Math.min(Math.max(0,r),p),f=Math.min(Math.max(0,f),p),h=Math.min(Math.max(0,h),p),l=Math.min(Math.max(0,l),p),t.roundRect){t.roundRect(i,o,e,s,[r,f,h,l]);return}t.moveTo(i+r,o),t.lineTo(i+e-f,o),t.arcTo(i+e,o,i+e,o+f,f),t.lineTo(i+e,o+s-h),t.arcTo(i+e,o+s,i+e-h,o+s,h),t.lineTo(i+l,o+s),t.arcTo(i,o+s,i,o+s-l,l),t.lineTo(i,o+r),t.arcTo(i,o,i+r,o,r),t.closePath()}renderListView(t,i){var A,W,z,Y;const o=this.objectStates.get(i.id)||{},e=o.options||i.options||{},s=o.width!==void 0?o.width:((A=i.geometry)==null?void 0:A.width)||200,n=o.height!==void 0?o.height:((W=i.geometry)==null?void 0:W.height)||300,a=-s/2,r=-n/2,f=o.corner_radius!==void 0?o.corner_radius:e.corner_radius??0,h=e.orientation||"vertical",l=e.items||[],p=e.itemGap??10,c=e.itemHeight??50,d=e.itemWidth??200,u=e.scrollOffset??0,v=e.padding??0,b=e.glassEffect!==!1,y=e.accentColor||"#3b82f6",m=e.itemTextColor||"#333333",S=e.itemBackgroundColor||"#ffffff",C=e.hoveredIndex??null,w=e.activeItemIndex??null,M=e.glowIntensity??0,I=e.glowColor||"#3b82f6",k=typeof I=="string"?I:I.color||((Y=(z=I.stops)==null?void 0:z[0])==null?void 0:Y.color)||"#3b82f6",T=e.opacity!==void 0?e.opacity:i.opacity!==void 0?i.opacity:1;if(t.save(),t.globalAlpha*=T,M>0){const G=t.getTransform(),N=Math.sqrt(G.a*G.a+G.b*G.b)||1;t.shadowColor=k,t.shadowBlur=M*2*N,t.shadowOffsetX=0,t.shadowOffsetY=0}if(b){const G=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",N=this.createCanvasFill(t,G,s,n);t.fillStyle=N||"rgba(31, 41, 55, 0.4)",t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f)||t.fill();const x=t.createLinearGradient(a,r,a+s,r+n);x.addColorStop(0,"rgba(255, 255, 255, 0.15)"),x.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),x.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=x,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f)||t.fill(),t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f)||t.stroke()}else{const G=e.backgroundColor||e.listBackgroundColor||"transparent",N=this.createCanvasFill(t,G,s,n);if(N){t.fillStyle=N,t.beginPath();const x=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f);t.fill()}const J=e.borderWidth??0;if(J>0){t.strokeStyle=e.borderColor||"#cccccc",t.lineWidth=J,t.beginPath();const x=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f);t.stroke()}}t.shadowBlur=0,t.save(),t.beginPath();const O=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,f);if(e.listLayout!=="circular")if(O&&e.containerShape==="custom")try{const G=new Path2D(e.containerPath);t.translate(a,r),t.scale(s/100,n/100),t.clip(G),t.scale(100/s,100/n),t.translate(-a,-r)}catch{}else t.clip();const P=typeof v=="number"?v:h==="vertical"?v[0]:v[3];let _=(h==="vertical"?r:a)+u+P;if(t.textBaseline="middle",l.forEach((G,N)=>{const J=e.listLayout||"linear",x=J==="circular"?d:h==="vertical"?s:d,F=J==="circular"||h==="vertical"?c:n;let j=0,X=0,tt=0;if(J==="circular"){const vt=l.length||1,Dt=Math.PI*2/vt,ae=e.circularStartAngle||0,pe=e.circularRadius||100,st=u*.01+ae*Math.PI/180,yt=N*Dt+st,Rt=a+s/2,_t=r+n/2;j=Rt+Math.cos(yt)*pe-x/2,X=_t+Math.sin(yt)*pe-F/2,tt=yt+(e.itemRotation||0)*Math.PI/180}else j=h==="vertical"?a:_,X=h==="vertical"?_:r,tt=(e.itemRotation||0)*Math.PI/180;const L=C===N,R=w===N,D=R&&e.activeItemShape?e.activeItemShape:e.itemShape||"rectangle",q=R&&e.activeItemShape?e.activeItemPath:e.itemPath||"",ot=e.itemCornerRadius||0;if(t.save(),tt!==0&&(t.translate(j+x/2,X+F/2),t.rotate(tt),t.translate(-(j+x/2),-(X+F/2))),R){const vt=this.createCanvasFill(t,y,x,F);t.fillStyle=vt||y;const Dt=t.globalAlpha;t.globalAlpha=Dt*.8,t.beginPath(),this.drawCustomShape(t,D,q,j,X,x,F,ot)||(t.rect(j,X,x,F),t.fill()),t.globalAlpha=Dt}else if(L)t.fillStyle=b?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",t.beginPath(),this.drawCustomShape(t,D,q,j,X,x,F,ot)||(t.rect(j,X,x,F),t.fill());else if(S!=="transparent"){const vt=this.createCanvasFill(t,S,x,F);t.fillStyle=vt||S,t.beginPath(),this.drawCustomShape(t,D,q,j,X,x,F,ot)||(t.rect(j,X,x,F),t.fill())}if(R||L){const vt=this.createCanvasFill(t,y,h==="vertical"?3:x,h==="vertical"?F:3);t.fillStyle=vt||y,h==="vertical"?t.fillRect(j,X,3,F):t.fillRect(j,X+F-3,x,3)}const mt=R?"#ffffff":b?"rgba(255, 255, 255, 0.9)":m;t.fillStyle=mt,t.font=R||L?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const bt=typeof G=="string"?G:(G==null?void 0:G.label)||`Item ${N+1}`,gt=j+(h==="vertical"?16:x/2),Et=X+F/2;h==="horizontal"||J==="circular"?t.textAlign="center":t.textAlign="left";const It=J==="circular"?j+x/2:gt;t.fillText(bt,It,Et),t.restore(),_+=(h==="vertical"?c:d)+p}),t.restore(),e.showScrollbar!==!1){const G=(l.length||0)*(h==="vertical"?c:d)+((l.length||0)-1)*p,N=h==="vertical"?n:s,J=e.listLayout||"linear",x=e.containerShape==="circle"||J==="circular";if(G>N||J==="circular"&&l.length>0){const F=e.scrollbarColor||"rgba(255,255,255,0.3)",j=e.scrollbarWidth||4;if(x){const X=Math.min(s,n)/2-j/2-2,tt=a+s/2,L=r+n/2;if(t.strokeStyle=F,t.lineWidth=j,t.lineCap="round",t.beginPath(),J==="circular"){const R=Math.PI/4,D=-(u*.01)-Math.PI/2;t.arc(tt,L,X,D,D+R)}else{const R=Math.PI/2,D=N/G,q=R*D,ot=-u/G*R,bt=-Math.PI/4+ot;t.arc(tt,L,X,bt,bt+q)}t.stroke()}else{const X=N/G,tt=N*X,L=-u/G*N;t.fillStyle=F,h==="vertical"?t.fillRect(a+s-j-2,r+L,j,tt):t.fillRect(a+L,r+n-j-2,tt,j)}}}t.restore()}drawCustomShape(t,i,o,e,s,n,a,r){if(i==="circle"){const f=Math.min(n,a)/2;return t.arc(e+n/2,s+a/2,f,0,Math.PI*2),!1}else if(i==="pill"){const f=Math.min(n,a)/2;return this.drawListViewRect(t,e,s,n,a,f),!1}else if(i==="custom"&&o)try{const f=new Path2D(o);return t.save(),t.translate(e,s),t.scale(n/100,a/100),t.fill(f),t.restore(),!0}catch{return this.drawListViewRect(t,e,s,n,a,r),!1}return this.drawListViewRect(t,e,s,n,a,r),!1}updateListViewScrollFromPointer(t){var b,y;if(!this._lastPointerPos||!this._prevPointerPos)return;const i=t.options||{},o=i.orientation||"vertical",e=this._lastPointerPos.x-this._prevPointerPos.x,s=this._lastPointerPos.y-this._prevPointerPos.y;o==="vertical"?i.scrollOffset=(i.scrollOffset||0)+s:i.scrollOffset=(i.scrollOffset||0)+e;const n=i.listLayout||"linear",a=this.objectStates.get(t.id)||{},r=i.items||[],f=i.itemGap??10,h=i.itemHeight??50,l=i.itemWidth??200,p=a.width!==void 0?a.width:((b=t.geometry)==null?void 0:b.width)||200,c=a.height!==void 0?a.height:((y=t.geometry)==null?void 0:y.height)||300;if(n==="circular")return;const d=(r.length||0)*(o==="vertical"?h:l)+((r.length||0)-1)*f,v=Math.max(0,d-(o==="vertical"?c:p)+(i.padding*2||0));i.scrollOffset>0&&(i.scrollOffset=0),i.scrollOffset<-v&&(i.scrollOffset=-v)}updateListViewHoverFromPointer(t,i,o){const e=this.getListViewItemIndexAtPointer(t,i,o),s=t.options||{};s.hoveredIndex!==e&&(s.hoveredIndex=e)}getListViewItemIndexAtPointer(t,i,o){var z,Y;const e=t.options||{},s=this.objectStates.get(t.id)||{},n=e.items||[];if(n.length===0)return null;const a=s.width!==void 0?s.width:((z=t.geometry)==null?void 0:z.width)||200,r=s.height!==void 0?s.height:((Y=t.geometry)==null?void 0:Y.height)||300,f=e.orientation||"vertical",h=e.itemGap??10,l=e.itemHeight??50,p=e.itemWidth??200,c=e.scrollOffset??0,d=e.padding??0,u=this.getWorldTransform(t.id),v=i-u.x,b=o-u.y,y=-u.rotation*(Math.PI/180),m=Math.cos(y),S=Math.sin(y),C=v*m-b*S,w=v*S+b*m,M=-a/2,I=-r/2,k=typeof d=="number"?d:f==="vertical"?d[0]:d[3];let T=(f==="vertical"?I:M)+c+k;const O=e.listLayout||"linear",P=n.length||1,_=Math.PI*2/P,E=e.circularStartAngle||0,A=e.circularRadius||100,W=c*.01+E*Math.PI/180;for(let G=0;G<n.length;G++){const N=O==="circular"?p:f==="vertical"?a:p,J=O==="circular"||f==="vertical"?l:r;let x=0,F=0,j=0;if(O==="circular"){const X=G*_+W,tt=M+a/2,L=I+r/2;x=tt+Math.cos(X)*A-N/2,F=L+Math.sin(X)*A-J/2,j=X+(e.itemRotation||0)*Math.PI/180}else x=f==="vertical"?M:T,F=f==="vertical"?T:I,j=(e.itemRotation||0)*Math.PI/180;if(j!==0){const X=x+N/2,tt=F+J/2,L=C-X,R=w-tt,D=-j,q=L*Math.cos(D)-R*Math.sin(D)+X,ot=L*Math.sin(D)+R*Math.cos(D)+tt;if(q>=x&&q<=x+N&&ot>=F&&ot<=F+J)return G}else if(C>=x&&C<=x+N&&w>=F&&w<=F+J)return G;T+=(f==="vertical"?l:p)+h}return null}drawListViewRect(t,i,o,e,s,n){t.beginPath(),this.drawRoundRect(t,i,o,e,s,n),t.fill()}solveBehaviors(t){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:i,y:o}=this._lastPointerPos;this.artboard.objects.forEach(e=>{if(!e.behaviors||e.behaviors.length===0)return;const s=this.objectStates.get(e.id);s&&e.behaviors.forEach(n=>{var p,c,d,u,v,b,y,m,S,C,w,M,I,k,T,O,P,_,E,A,W,z,Y,G,N,J,x,F,j,X,tt,L,R,D,q,ot,mt,bt,gt,Et,It,vt,Dt,ae,pe,st,yt,Rt,_t,dt,$t,Vt,Bt,Ft,Ut,re,be,ve,Zt,Ce,_e,Pe,we,Ee,Ae,oe,se,ft,ut,at,B,et,Q,Pt,Ot,kt,At,Mt,$,Yt,jt,ie,te,pt,ct,Ct,rt,V,it,nt,St,Gt,ee,le,Nt,Kt,qt,Ie,xe,Oe,Le,Re,Fe,Xe,Ht,ce,Me,$e,Be,ge,de,ue,ke,De,qe,Ke,Ge,Je;if(!n.enabled)return;const a=n.startTime||0,r=n.endTime||1/0;if(this.currentTime<a||this.currentTime>r)return;const f=s.x-i,h=s.y-o,l=Math.sqrt(f*f+h*h);if(this.frameCount%240===0&&Math.random()<.1&&this.log(`[ExodeUI] Executing ${n.type} on ${e.name}`),n.type===H.Proximity){const U=((p=n.settings)==null?void 0:p.radius)||300,Z=((c=n.settings)==null?void 0:c.falloff)||"smooth";let K=0;l<U&&(Z==="linear"?K=1-l/U:K=Math.pow(1-l/U,2)),n.sensors.forEach(ht=>{this.applyBehaviorSensor(s,ht,K,t,n.settings,e,f,h,l)})}else if(n.type===H.Magnetic){const U=((d=n.settings)==null?void 0:d.radius)||400,Z=((u=n.settings)==null?void 0:u.strength)||.5;if(l<U&&l>5){const K=1-l/U,ht=f*K*Z,Tt=h*K*Z;s.x-=ht*t*10,s.y-=Tt*t*10}}else if(n.type===H.Repel){const U=((v=n.settings)==null?void 0:v.radius)||300,Z=((b=n.settings)==null?void 0:b.strength)||1;if(l<U){const K=Math.pow(1-l/U,2);s.x+=f/(l||1)*K*60*Z*t*5,s.y+=h/(l||1)*K*60*Z*t*5}}else if(n.type===H.Orbit){const U=((y=n.settings)==null?void 0:y.speed)||1,Z=((m=n.settings)==null?void 0:m.radius)||30,K=this.currentTime*U*Math.PI*2;s.x+=Math.cos(K)*Z*t*5,s.y+=Math.sin(K)*Z*t*5,s.rotation+=2*t*5}else if(n.type===H.Vortex){const U=((S=n.settings)==null?void 0:S.radius)||400,Z=((C=n.settings)==null?void 0:C.speed)||2,K=((w=n.settings)==null?void 0:w.strength)||1;if(l<U){const ht=Math.pow(1-l/U,1.5),Tt=this.currentTime*Z*Math.PI*2,Lt=Math.cos(Tt)*30-f*.4,Wt=Math.sin(Tt)*30-h*.4;s.x+=Lt*ht*K*t*5,s.y+=Wt*ht*K*t*5,s.rotation+=5*ht*K*t*5,s.scale_x*=1-ht*.1*K*t,s.scale_y*=1-ht*.1*K*t}}else if(n.type===H.Fluid){const U=((M=n.settings)==null?void 0:M.radius)||300,Z=((I=n.settings)==null?void 0:I.strength)||1;if(l<U){const K=Math.pow(1-l/U,1.2),ht=f/(l||1)*K*1.2*Z,Tt=h/(l||1)*K*1.2*Z;s.x+=ht*10*t*5,s.y+=Tt*10*t*5,s.scale_x*=1+K*.3*Z*t,s.scale_y*=1+K*.3*Z*t}}else if(n.type===H.Elastic){const U=((k=n.settings)==null?void 0:k.radius)||300,Z=((T=n.settings)==null?void 0:T.strength)||1;if(l<U){const K=1-l/U;s.scale_x*=1+K*.4*Z*t,s.scale_y*=1+K*.4*Z*t}}else if(n.type===H.Holographic){const U=s.x-this.canvasWidth/2,Z=s.y-this.canvasHeight/2,K=((O=n.settings)==null?void 0:O.factor)||25;if(s.x-=U/1e3*K*t*5,s.y-=Z/1e3*K*t*5,s.style){const ht=1-Math.min(1,l/400);s.style.exposure=(s.style.exposure||1)+ht*.5*t}}else if(n.type===H.Sticky){const U=((P=n.settings)==null?void 0:P.radius)||80,Z=((_=n.settings)==null?void 0:_.strength)||1;if(l<U){const K=Math.pow(1-l/U,2);s.x-=f*K*Z*t*10,s.y-=h*K*Z*t*10,s.scale_x*=1-K*.1*Z*t,s.scale_y*=1-K*.1*Z*t}}else if(n.type===H.Dilation){const U=((E=n.settings)==null?void 0:E.size)||120,Z=((A=n.settings)==null?void 0:A.strength)||1;if(l<U){const K=1-l/U;s.scale_x*=1+K*.5*Z*t,s.scale_y*=1+K*.5*Z*t}}else if(n.type===H.Parallax){const U=((W=n.settings)==null?void 0:W.factor)||15,Z=((z=n.settings)==null?void 0:z.strength)||1,K=this.canvasWidth/2,ht=this.canvasHeight/2,Tt=this._lastPointerPos||{x:K,y:ht},Lt=(Tt.x-K)/K,Wt=(Tt.y-ht)/ht,ne=(((Y=e.transform)==null?void 0:Y.x)??0)+Lt*U*Z,ye=(((G=e.transform)==null?void 0:G.y)??0)+Wt*U*Z,Te=(((N=e.transform)==null?void 0:N.rotate_x)??0)-Wt*U*1.5*Z,fe=(((J=e.transform)==null?void 0:J.rotate_y)??0)+Lt*U*1.5*Z,Se=Math.min(1,10*t);s.x=this.lerp(s.x??((x=e.transform)==null?void 0:x.x)??0,ne,Se),s.y=this.lerp(s.y??((F=e.transform)==null?void 0:F.y)??0,ye,Se),s.rotate_x=this.lerp(s.rotate_x??((j=e.transform)==null?void 0:j.rotate_x)??0,Te,Se),s.rotate_y=this.lerp(s.rotate_y??((X=e.transform)==null?void 0:X.rotate_y)??0,fe,Se)}else if(n.type===H.Fold){if(l<300){const U=1-l/300,Z=(f>0?-1:1)*U*10,K=1-U*.1,ht=h/300*U*20,Tt=-(f/300)*U*20,Lt=Math.min(1,10*t);s.skew_x=this.lerp(s.skew_x??((tt=e.transform)==null?void 0:tt.skew_x)??0,Z,Lt),s.scale_y=this.lerp(s.scale_y??((L=e.transform)==null?void 0:L.scale_y)??1,(((R=e.transform)==null?void 0:R.scale_y)??1)*K,Lt),s.rotate_x=this.lerp(s.rotate_x??((D=e.transform)==null?void 0:D.rotate_x)??0,ht,Lt),s.rotate_y=this.lerp(s.rotate_y??((q=e.transform)==null?void 0:q.rotate_y)??0,Tt,Lt),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((ot=n.settings)==null?void 0:ot.opacity)??.5}}}else if(n.type===H.Crumple){if(l<300){const U=1-l/300,Z=U*(Math.random()-.5)*5,K=U*(Math.random()-.5)*.05,ht=Math.min(1,15*t);s.skew_x=this.lerp(s.skew_x??((mt=e.transform)==null?void 0:mt.skew_x)??0,Z,ht),s.scale_x=this.lerp(s.scale_x??((bt=e.transform)==null?void 0:bt.scale_x)??1,(((gt=e.transform)==null?void 0:gt.scale_x)??1)*(1+K),ht),s.scale_y=this.lerp(s.scale_y??((Et=e.transform)==null?void 0:Et.scale_y)??1,(((It=e.transform)==null?void 0:It.scale_y)??1)*(1+K),ht),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((vt=n.settings)==null?void 0:vt.intensity)??1,scale:((Dt=n.settings)==null?void 0:Dt.scale)??2}}}else if(n.type===H.Squash){const U=((ae=n.settings)==null?void 0:ae.strength)||.8;l<(e.width||100)&&this.isMouseDown?(s.scale_y=this.lerp(s.scale_y??1,(((pe=e.transform)==null?void 0:pe.scale_y)??1)*U,.3),s.scale_x=this.lerp(s.scale_x??1,(((st=e.transform)==null?void 0:st.scale_x)??1)*(1+(1-U)*.4),.3)):(s.scale_y=this.lerp(s.scale_y??1,((yt=e.transform)==null?void 0:yt.scale_y)??1,.2),s.scale_x=this.lerp(s.scale_x??1,((Rt=e.transform)==null?void 0:Rt.scale_x)??1,.2))}else if(n.type===H.TextCounter){const U=((_t=n.settings)==null?void 0:_t.duration)||2,Z=((dt=n.settings)==null?void 0:dt.from)||0,K=(($t=n.settings)==null?void 0:$t.to)||100;n._runtimeStart===void 0&&(n._runtimeStart=this.currentTime);const ht=this.currentTime-n._runtimeStart,Tt=Math.min(1,ht/U),Lt=Math.floor(Z+(K-Z)*Tt);if(((Vt=e.geometry)==null?void 0:Vt.type)==="Text"){const Wt=((Bt=n.settings)==null?void 0:Bt.prefix)||"",ne=((Ft=n.settings)==null?void 0:Ft.suffix)||"";s.geometry||(s.geometry={...e.geometry}),s.geometry.text=`${Wt}${Lt}${ne}`}}else if(n.type===H.Spotlight){const U=((Ut=n.settings)==null?void 0:Ut.radius)||250,Z=((re=n.settings)==null?void 0:re.strength)||1.5;if(l<U){const K=Math.pow(1-l/U,2);s.style||(s.style={...e.style}),s.style.adjustments||(s.style.adjustments={...(be=e.style)==null?void 0:be.adjustments}),s.style.adjustments.exposure=(((Zt=(ve=e.style)==null?void 0:ve.adjustments)==null?void 0:Zt.exposure)||0)+K*Z*50}else(Ce=s.style)!=null&&Ce.adjustments&&(s.style.adjustments.exposure=this.lerp(s.style.adjustments.exposure||0,((Pe=(_e=e.style)==null?void 0:_e.adjustments)==null?void 0:Pe.exposure)||0,.1))}else if(n.type===H.Noise||n.type===H.Float){const U=(((we=n.settings)==null?void 0:we.frequency)||((Ee=n.settings)==null?void 0:Ee.speed)||1)*.002,Z=(((Ae=n.settings)==null?void 0:Ae.amplitude)||((oe=n.settings)==null?void 0:oe.range)||50)*(((se=n.settings)==null?void 0:se.strength)||1),K=Date.now();s.x+=Math.sin(K*U)*Z*t,s.y+=Math.cos(K*U*.8)*Z*t,s.rotation+=Math.sin(K*U*.5)*5*t}else if(n.type===H.Pulse){const U=(((ft=n.settings)==null?void 0:ft.speed)||1)*.005,Z=(((ut=n.settings)==null?void 0:ut.scale)||1.2)-1,K=Math.sin(Date.now()*U),ht=((at=n.settings)==null?void 0:at.strength)||1;s.scale_x*=1+K*Z*ht*t,s.scale_y*=1+K*Z*ht*t,s.style&&(s.style.exposure=(s.style.exposure||1)+Math.max(0,K)*.1*ht*t)}else if(n.type===H.Draggable){const U=((B=n.settings)==null?void 0:B.radius)||150,Z=this.draggingBehaviors.has(e.id);if(l<U||Z){const K=((et=n.settings)==null?void 0:et.strength)||1,ht=Z?1:Math.max(0,1-l/U);this.applyBehaviorSensor(s,Qt.PositionX,ht*K,t,n.settings),this.applyBehaviorSensor(s,Qt.PositionY,ht*K,t,n.settings)}}else if(n.type===H.Scroll){const U=((Q=n.settings)==null?void 0:Q.axis)||"vertical",Z=((Pt=n.settings)==null?void 0:Pt.factor)||.5,K=((Ot=n.settings)==null?void 0:Ot.strength)||1,ht=((kt=n.settings)==null?void 0:kt.scaleFactor)||0;(U==="vertical"||U==="both")&&(s.y+=this.scrollOffset.y*Z*K*t),(U==="horizontal"||U==="both")&&(s.x+=this.scrollOffset.x*Z*K*t),ht!==0&&(s.scale_x*=1+this.scrollOffset.y*ht*t,s.scale_y*=1+this.scrollOffset.y*ht*t)}else if(n.type===H.LookAt){const U=((At=n.settings)==null?void 0:At.factor)||1,Z=((Mt=n.settings)==null?void 0:Mt.strength)||1,K=Math.atan2(-h,-f)*(180/Math.PI),ht=s.rotation,Tt=(K-ht+180)%360-180;s.rotation+=Tt*U*Z*t*10}else if(n.type===H.Scan){const U=((($=n.settings)==null?void 0:$.speed)||1)*.004,Z=((Yt=n.settings)==null?void 0:Yt.strength)||1,K=(Math.sin(Date.now()*U)+1)/2;s.style&&(s.style.exposure=(s.style.exposure||1)+K*Z*t*5),s.x+=(K-.5)*20*Z*t}else if(n.type===H.Glint)s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"glint_overlay",intensity:((jt=n.settings)==null?void 0:jt.strength)??.8};else if(n.type===H.Ratchet){const U=((ie=n.settings)==null?void 0:ie.steps)||12,Z=(((te=n.settings)==null?void 0:te.speed)||1)*30,K=Math.floor(s.rotation/(360/U))*(360/U);s.rotation=this.lerp(s.rotation,K+Z*t,.1)}else if(n.type===H.Jitter&&l<300){const U=((pt=n.settings)==null?void 0:pt.strength)||1,Z=(((ct=n.settings)==null?void 0:ct.intensity)||5)*U;s.x+=(Math.random()-.5)*Z*t*60,s.y+=(Math.random()-.5)*Z*t*60,s.rotation+=(Math.random()-.5)*Z*t*120}else if(n.type===H.Follower){const U=(Ct=n.settings)==null?void 0:Ct.targetId;if(U){const Z=this.objectStates.get(U);if(Z){const K=((rt=n.settings)==null?void 0:rt.stiffness)||.1,ht=Z.x-s.x,Tt=Z.y-s.y;s.x+=ht*K*t*60,s.y+=Tt*K*t*60}}}else if(n.type===H.Wrap)s.x<0?s.x=this.canvasWidth:s.x>this.canvasWidth&&(s.x=0),s.y<0?s.y=this.canvasHeight:s.y>this.canvasHeight&&(s.y=0);else if(n.type===H.Gravity){const U=((V=n.settings)==null?void 0:V.strength)||9.8;s.y+=U*t*10}else if(n.type===H.Velocity){const U=((it=n.settings)==null?void 0:it.vx)||0,Z=((nt=n.settings)==null?void 0:nt.vy)||0;s.x+=U*t*10,s.y+=Z*t*10}else if(n.type===H.Shear){const U=((St=n.settings)==null?void 0:St.strength)||1,Z=((Gt=n.settings)==null?void 0:Gt.radius)||300;if(l<Z){const K=1-l/Z;s.skew_x=this.lerp(s.skew_x||0,(((ee=e.transform)==null?void 0:ee.skew_x)||0)+K*U*30,.1)}else s.skew_x=this.lerp(s.skew_x||0,((le=e.transform)==null?void 0:le.skew_x)||0,.05)}else if(n.type===H.Lens){const U=((Nt=n.settings)==null?void 0:Nt.radius)||200,Z=((Kt=n.settings)==null?void 0:Kt.strength)||.5;if(l<U){const K=Math.pow(1-l/U,2);s.scale_x=this.lerp(s.scale_x??1,(((qt=e.transform)==null?void 0:qt.scale_x)??1)*(1+K*Z),.2),s.scale_y=this.lerp(s.scale_y??1,(((Ie=e.transform)==null?void 0:Ie.scale_y)??1)*(1+K*Z),.2)}else s.scale_x=this.lerp(s.scale_x??1,((xe=e.transform)==null?void 0:xe.scale_x)??1,.1),s.scale_y=this.lerp(s.scale_y??1,((Oe=e.transform)==null?void 0:Oe.scale_y)??1,.1)}else if(n.type===H.LayoutAnimation){const U=((Le=n.settings)==null?void 0:Le.watchProperties)||["x","y","scale_x","scale_y","opacity","rotation"],Z=((Re=n.settings)==null?void 0:Re.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const K=this._layoutAnimCache.get(e.id);for(const ht of U){const Tt=this.getObjectProperty(s,e,ht);if(Tt===void 0)continue;const Lt=K.get(ht);if(!Lt)K.set(ht,{from:Tt,to:Tt,startTime:this.currentTime,duration:0});else if(Lt.to!==Tt){const ne=this.getObjectProperty(s,e,ht);K.set(ht,{from:ne??Lt.from,to:Tt,startTime:this.currentTime,duration:((Fe=n.settings)==null?void 0:Fe.duration)??Z})}const Wt=K.get(ht);if(Wt.duration>0&&Wt.from!==Wt.to){const ne=this.currentTime-Wt.startTime,ye=Math.min(1,ne/Wt.duration),Te=this.applyEasing(ye,((Xe=n.settings)==null?void 0:Xe.easing)||"easeOutCubic"),fe=Wt.from+(Wt.to-Wt.from)*Te;this.setObjectProperty(s,e,ht,fe)}}}else if(n.type===H.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const U=this._layoutAnimCache.get(e.id),Z=((Ht=n.settings)==null?void 0:Ht.defaultDuration)||.3,K=["x","y","scale_x","scale_y","opacity","rotation","style.fill.color","style.stroke.width","geometry.cornerRadius","style.blur.value","style.shadow.blur","style.shadow.offsetX","style.shadow.offsetY"];for(const ht of K){const Tt=this.getObjectProperty(s,e,ht);if(Tt===void 0||typeof Tt!="number")continue;const Lt=U.get(ht);if(!Lt)U.set(ht,{from:Tt,to:Tt,startTime:this.currentTime,duration:0});else if(Lt.to!==Tt){const ne=this.getObjectProperty(s,e,ht);U.set(ht,{from:ne??Lt.from,to:Tt,startTime:this.currentTime,duration:Z})}const Wt=U.get(ht);if(Wt.duration>0&&Wt.from!==Wt.to){const ne=this.currentTime-Wt.startTime,ye=Math.min(1,ne/Wt.duration),Te=this.applyEasing(ye,((ce=n.settings)==null?void 0:ce.defaultEasing)||"easeOutCubic"),fe=Wt.from+(Wt.to-Wt.from)*Te;this.setObjectProperty(s,e,ht,fe)}}}else if(n.type===H.SpringChain){const U=((Me=n.settings)==null?void 0:Me.connections)||[],Z=(($e=n.settings)==null?void 0:$e.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const K=this._springChainState.get(e.id);for(const Tt of U){if(!K.has(Tt.targetId)){const Lt=this.objectStates.get(Tt.targetId);K.set(Tt.targetId,{x:(Lt==null?void 0:Lt.x)??0,y:(Lt==null?void 0:Lt.y)??0,vx:0,vy:0})}K.has(e.id)||K.set(e.id,{x:s.x,y:s.y,vx:0,vy:0})}const ht=K.get(e.id);if(ht){ht.x=s.x,ht.y=s.y;for(const Tt of U){const Lt=K.get(Tt.targetId);if(!Lt)continue;const Wt=Lt.x-ht.x,ne=Lt.y-ht.y,ye=Math.sqrt(Wt*Wt+ne*ne)||.001,fe=(ye-(Tt.restLength||50))*(Tt.stiffness||.8),Se=Wt/ye*fe,Qe=ne/ye*fe;ht.vx+=Se*t*10,ht.vy+=Qe*t*10,Lt.vx-=Se*t*10,Lt.vy-=Qe*t*10,ht.vx*=1-Z*t*10,ht.vy*=1-Z*t*10,Lt.vx*=1-Z*t*10,Lt.vy*=1-Z*t*10;const me=this.objectStates.get(Tt.targetId);me&&(me.x+=Lt.vx*t,me.y+=Lt.vy*t)}s.x+=ht.vx*t,s.y+=ht.vy*t}}else if(n.type===H.ParticleEmitter){const U=((Be=n.settings)==null?void 0:Be.rate)||10,Z=((ge=n.settings)==null?void 0:ge.speed)||100,K=((de=n.settings)==null?void 0:de.size)||5,ht=((ue=n.settings)==null?void 0:ue.lifetime)||2,Tt=((ke=n.settings)==null?void 0:ke.gravity)||0,Lt=((De=n.settings)==null?void 0:De.color)||"#ffffff",Wt=((qe=n.settings)==null?void 0:qe.maxParticles)||200,ne=(Ke=n.settings)!=null&&Ke.rateInputId?this.inputs.get(n.settings.rateInputId)??U:U,ye=(Ge=n.settings)!=null&&Ge.gravityInputId?this.inputs.get(n.settings.gravityInputId)??Tt:Tt,Te=(Je=n.settings)!=null&&Je.speedInputId?this.inputs.get(n.settings.speedInputId)??Z:Z;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const fe=this._emitterPools.get(e.id);let Se=0;n._pendingBurst&&n._pendingBurst>0&&(Se=n._pendingBurst,n._pendingBurst=0);const Qe=Math.floor(ne*t)+(Se||0);for(let me=0;me<Math.min(Qe,Wt-fe.length);me++){const he=Math.random()*Math.PI*2,ms=Te*(.5+Math.random()*.5);fe.push({x:s.x,y:s.y,vx:Math.cos(he)*ms,vy:Math.sin(he)*ms,life:0,maxLife:ht*(.5+Math.random()*.5),size:K*(.5+Math.random()),color:Lt,opacity:1})}for(let me=fe.length-1;me>=0;me--){const he=fe[me];he.vy+=ye*t*10,he.x+=he.vx*t,he.y+=he.vy*t,he.life+=t,he.opacity=Math.max(0,1-he.life/he.maxLife),he.life>=he.maxLife&&fe.splice(me,1)}}})})}applyBehaviorSensor(t,i,o,e,s,n,a=0,r=0,f=1){var d,u,v,b,y,m,S,C,w,M,I,k,T,O,P,_,E,A,W,z,Y,G,N,J;const h=(s==null?void 0:s.intensity)||(s==null?void 0:s.strength)||1,l=Math.min(1,15*e),p=f>0?a/f:0,c=f>0?r/f:0;switch(i){case Qt.Scale:{const x=((d=n==null?void 0:n.transform)==null?void 0:d.scale_x)??1,F=((u=n==null?void 0:n.transform)==null?void 0:u.scale_y)??1,j=x*(1+o*h*.4),X=F*(1+o*h*.4);t.scale_x=(t.scale_x??x)*(1-l)+j*l,t.scale_y=(t.scale_y??F)*(1-l)+X*l;break}case Qt.Opacity:{const x=((v=n==null?void 0:n.transform)==null?void 0:v.opacity)??100,F=Math.max(0,Math.min(100,x-o*h*100));t.opacity=(t.opacity??x)*(1-l)+F*l;break}case Qt.RotateZ:{const x=((b=n==null?void 0:n.transform)==null?void 0:b.rotation)??0,F=x+o*h*45;t.rotation=(t.rotation??x)*(1-l)+F*l;break}case Qt.RotateX:{const x=((y=n==null?void 0:n.transform)==null?void 0:y.rotate_x)??0,F=x-c*o*h*60;t.rotate_x=(t.rotate_x??x)*(1-l)+F*l;break}case Qt.RotateY:{const x=((m=n==null?void 0:n.transform)==null?void 0:m.rotate_y)??0,F=x+p*o*h*60;t.rotate_y=(t.rotate_y??x)*(1-l)+F*l;break}case Qt.PositionX:{const x=((S=n==null?void 0:n.transform)==null?void 0:S.x)??0,F=x-p*o*h*40;t.x=(t.x??x)*(1-l)+F*l;break}case Qt.PositionY:{const x=((C=n==null?void 0:n.transform)==null?void 0:C.y)??0,F=x-c*o*h*40;t.y=(t.y??x)*(1-l)+F*l;break}case Qt.SkewX:{const x=((w=n==null?void 0:n.transform)==null?void 0:w.skew_x)??0,F=x+p*o*h*45;t.skew_x=(t.skew_x??x)*(1-l)+F*l,t.skew_x>85&&(t.skew_x=85),t.skew_x<-85&&(t.skew_x=-85);break}case Qt.Blur:{t.style||(t.style={...n==null?void 0:n.style}),t.style.blur||(t.style.blur={...(M=n==null?void 0:n.style)==null?void 0:M.blur});const x=((k=(I=n==null?void 0:n.style)==null?void 0:I.blur)==null?void 0:k.amount)||0,F=x+o*((s==null?void 0:s.blur)||20)*h;t.style.blur.amount=(t.style.blur.amount??x)*(1-l)+F*l;break}case Qt.Exposure:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(T=n==null?void 0:n.style)==null?void 0:T.adjustments});const x=((P=(O=n==null?void 0:n.style)==null?void 0:O.adjustments)==null?void 0:P.exposure)||0,F=x+o*((s==null?void 0:s.exposure)||50)*h;t.style.adjustments.exposure=(t.style.adjustments.exposure??x)*(1-l)+F*l;break}case Qt.HueShift:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(_=n==null?void 0:n.style)==null?void 0:_.adjustments});const x=((A=(E=n==null?void 0:n.style)==null?void 0:E.adjustments)==null?void 0:A.hue)||0,F=x+o*((s==null?void 0:s.hue)||180)*h;t.style.adjustments.hue=(t.style.adjustments.hue??x)*(1-l)+F*l;break}case Qt.Negative:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(W=n==null?void 0:n.style)==null?void 0:W.adjustments});const x=((Y=(z=n==null?void 0:n.style)==null?void 0:z.adjustments)==null?void 0:Y.negative)||0,F=x+o*((s==null?void 0:s.negative)||100)*h;t.style.adjustments.negative=(t.style.adjustments.negative??x)*(1-l)+F*l;break}case Qt.CornerRadius:{const x=((G=n==null?void 0:n.transform)==null?void 0:G.corner_radius)||0,F=x+o*h*50;t.corner_radius=(t.corner_radius??x)*(1-l)+F*l;break}case Qt.StrokeWidth:{t.style||(t.style={...n==null?void 0:n.style});const x=((N=n==null?void 0:n.style)==null?void 0:N.borderWidth)||0,F=x+o*h*10;t.style.borderWidth=(t.style.borderWidth??x)*(1-l)+F*l;break}case Qt.LetterSpacing:{t.geometry||(t.geometry={});const x=((J=n==null?void 0:n.geometry)==null?void 0:J.letterSpacing)||0,F=x+o*h*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??x)*(1-l)+F*l;break}}}getObjectProperty(t,i,o){const e=o.split(".");let s=t;for(const n of e){if(s==null||typeof s!="object")return;if(n==="style"&&t.style===void 0){s=i.style;continue}s=s[n]}return typeof s=="number"?s:void 0}setObjectProperty(t,i,o,e){const s=o.split(".");let n=t;for(let r=0;r<s.length-1;r++){const f=s[r];if(n[f]===void 0||n[f]===null){const h=i,l=s.slice(0,r+1).reduce((p,c)=>p==null?void 0:p[c],h);n[f]=l!==void 0?{...l}:{}}n=n[f]}const a=s[s.length-1];n!=null&&(n[a]=e)}applyEasing(t,i){switch(i){case"easeOutCubic":return 1-Math.pow(1-t,3);case"easeInCubic":return t*t*t;case"easeInOutCubic":return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;case"easeOutQuad":return t*(2-t);case"easeInQuad":return t*t;case"easeInOutQuad":return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2;case"easeOutExpo":return t===1?1:1-Math.pow(2,-10*t);case"easeOutBack":return 1+2.70158*Math.pow(t-1,3)+1.70158*Math.pow(t-1,2);case"easeOutElastic":{const o=2*Math.PI/3;return t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*o)+1}case"easeOutBounce":return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375;case"linear":return t;default:return 1-Math.pow(1-t,3)}}lerp(t,i,o){return t*(1-o)+i*o}deepMerge(t,i){if(!t)return i;if(!i)return t;if(typeof t!="object"||typeof i!="object"||t===null||i===null)return i;const o={...t};for(const e in i)Object.prototype.hasOwnProperty.call(i,e)&&(i[e]&&typeof i[e]=="object"&&!Array.isArray(i[e])?o[e]=this.deepMerge(t[e],i[e]):o[e]=i[e]);return o}renderFittedImage(t,i,o,e,s,n,a="cover"){const r=i.naturalWidth,f=i.naturalHeight,h=r/f,l=s/n;let p=s,c=n,d=o,u=e;a==="cover"?h>l?(p=n*h,d=o-(p-s)/2):(c=s/h,u=e-(c-n)/2):a==="contain"&&(h>l?(c=s/h,u=e+(n-c)/2):(p=n*h,d=o+(s-p)/2)),t.drawImage(i,d,u,p,c)}}const ni=xt.forwardRef(({artboard:g,src:t,style:i,autoPlay:o=!0,fit:e="Contain",alignment:s="Center",onReady:n,onTrigger:a,onInputUpdate:r,onComponentChange:f,onToggle:h,onInputChange:l,onInputFocus:p,onInputBlur:c,onLog:d,onLogicUpdate:u,onButtonClick:v,onGraphPointClick:b,currentTime:y,revision:m=0,scrollY:S,scrollX:C,mouseX:w,mouseY:M,isMouseDown:I,inputs:k,interactive:T=!0,onNavigation:O},P)=>{const _=xt.useRef(null),E=xt.useRef(null);E.current||(E.current=new ys);const A=xt.useRef(void 0),W=xt.useRef(0),z=xt.useRef(null),Y=xt.useRef(m),G=xt.useRef(null),[,N]=xt.useState(g||null),J=xt.useRef(!0);xt.useImperativeHandle(P,()=>_.current),xt.useEffect(()=>(J.current=!0,()=>{J.current=!1,A.current&&cancelAnimationFrame(A.current)}),[]),xt.useEffect(()=>{E.current.setLayout(e,s)},[e,s]),xt.useEffect(()=>{const L=E.current;a&&L.setTriggerCallback(a),r&&L.setInputUpdateCallback((R,D)=>r({[R]:D})),f&&L.setComponentChangeCallback(R=>f(R)),h&&L.setToggleCallback(h),l&&L.setInputChangeCallback(l),p&&L.setInputFocusCallback(p),c&&L.setInputBlurCallback(c),d&&L.setOnLogCallback(R=>d(R,"info")),u&&L.setLogicUpdateCallback(u),v&&L.setButtonClickCallback(v),b&&L.setGraphPointClickCallback(R=>b(R.objectId,R)),O&&L.setNavigationCallback(O)},[a,r,f,h,l,p,c,d,u,v,b,O]),xt.useEffect(()=>{(async()=>{let R=g;if(t&&!g)try{t.startsWith("{")?R=JSON.parse(t):R=await(await fetch(t)).json()}catch(D){console.error("[ExodeUI] Failed to load src:",D)}if(R){const D=E.current,q=R.id||R.name||"default";(z.current!==q||Y.current!==m||G.current!==R)&&(D.load(R),z.current=q,Y.current=m,G.current=R,N(R),W.current=0,D.advance(0)),n&&n(D)}})()},[g,t,m]),xt.useEffect(()=>{const L=R=>{if(!E.current||!J.current)return;const D=E.current,q=_.current;if(!q)return;const ot=q.getContext("2d");if(!ot)return;const mt=R/1e3;W.current===0&&(W.current=mt);let bt=mt-W.current;bt>.1&&(bt=.1),W.current=mt;const gt=q.getBoundingClientRect(),Et=window.devicePixelRatio||1,It=Math.round(gt.width*Et),vt=Math.round(gt.height*Et);(q.width!==It||q.height!==vt)&&(q.width=It,q.height=vt);try{o?D.advance(bt):y!==void 0&&D.seek(y),D.render(ot,q.width,q.height)}catch(Dt){console.error("[ExodeUICanvas] Error in animation loop:",Dt),d&&d(`[Error] Animation loop crashed: ${Dt}`,"error")}A.current=requestAnimationFrame(L)};return A.current=requestAnimationFrame(L),()=>{A.current&&cancelAnimationFrame(A.current)}},[o,y]),xt.useEffect(()=>{const L=E.current;S!==void 0&&L.updateInput("scrollY",S),C!==void 0&&L.updateInput("scrollX",C),w!==void 0&&L.updateInput("mouseX",w),M!==void 0&&L.updateInput("mouseY",M),I!==void 0&&L.updateInput("isMouseDown",I),k&&Object.entries(k).forEach(([R,D])=>L.updateInput(R,D))},[S,C,w,M,I,k]);const x=(L,R)=>{if(!T||!_.current)return;L.stopPropagation(),"nativeEvent"in L&&L.nativeEvent&&typeof L.nativeEvent.stopImmediatePropagation=="function"?L.nativeEvent.stopImmediatePropagation():typeof L.stopImmediatePropagation=="function"&&L.stopImmediatePropagation();const D=_.current,q=D.getBoundingClientRect(),ot=L.clientX-q.left,mt=L.clientY-q.top,bt=window.devicePixelRatio||1;(R==="click"||R==="down"||R==="up")&&d&&d(`[Canvas] Pointer ${R} at rect(${Math.round(ot)},${Math.round(mt)}) mapped to buffer(${Math.round(ot*bt)},${Math.round(mt*bt)})`,"info"),E.current.handlePointerInput(R,ot*bt,mt*bt,D.width,D.height)};xt.useEffect(()=>{if(!T)return;const L=D=>{var q,ot,mt;((q=document.activeElement)==null?void 0:q.tagName)==="INPUT"||((ot=document.activeElement)==null?void 0:ot.tagName)==="TEXTAREA"||(mt=E.current)==null||mt.handleKeyDown(D)},R=D=>{var q,ot,mt;((q=document.activeElement)==null?void 0:q.tagName)==="INPUT"||((ot=document.activeElement)==null?void 0:ot.tagName)==="TEXTAREA"||(mt=E.current)==null||mt.handleKeyUp(D)};return window.addEventListener("keydown",L),window.addEventListener("keyup",R),()=>{window.removeEventListener("keydown",L),window.removeEventListener("keyup",R)}},[T]);const[F,j]=xt.useState([]);xt.useEffect(()=>{if(g&&g.objects){const L=g.objects.filter(R=>{var D,q;return R.type==="Joystick"&&((D=R.inputBinding)==null?void 0:D.type)==="keyboard"&&((q=R.inputBinding.keyboardConfig)==null?void 0:q.showVirtualKeyboard)});j(L)}},[g]);const[,X]=xt.useState(0);xt.useEffect(()=>{if(F.length===0)return;let L;const R=()=>{X(D=>D+1),L=requestAnimationFrame(R)};return L=requestAnimationFrame(R),()=>cancelAnimationFrame(L)},[F.length]);const tt=()=>F.map(L=>{const R=L.inputBinding.keyboardConfig,D=gt=>{var It;const Et={key:gt,code:gt,preventDefault:()=>{}};(It=E.current)==null||It.handleKeyDown(Et)},q=gt=>{var It;const Et={key:gt,code:gt,preventDefault:()=>{}};(It=E.current)==null||It.handleKeyUp(Et)},ot=E.current,mt=gt=>ot&&ot.activeKeys?ot.activeKeys.has(gt.toLowerCase()):!1,bt=gt=>({width:"50px",height:"50px",background:gt?"rgba(255, 255, 255, 0.4)":"rgba(0, 0, 0, 0.4)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontWeight:"bold",fontSize:"18px",userSelect:"none",cursor:"pointer",backdropFilter:"blur(8px)",transition:"background 0.1s",boxShadow:gt?"none":"0 4px 6px rgba(0,0,0,0.1)"});return Xt.jsxs("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",pointerEvents:"auto",zIndex:100},children:[Xt.jsx("div",{style:bt(mt(R.upKey)),onMouseDown:()=>D(R.upKey),onMouseUp:()=>q(R.upKey),onMouseLeave:()=>q(R.upKey),onTouchStart:gt=>{gt.preventDefault(),D(R.upKey)},onTouchEnd:gt=>{gt.preventDefault(),q(R.upKey)},children:R.upKey.toUpperCase()}),Xt.jsxs("div",{style:{display:"flex",gap:"8px"},children:[Xt.jsx("div",{style:bt(mt(R.leftKey)),onMouseDown:()=>D(R.leftKey),onMouseUp:()=>q(R.leftKey),onMouseLeave:()=>q(R.leftKey),onTouchStart:gt=>{gt.preventDefault(),D(R.leftKey)},onTouchEnd:gt=>{gt.preventDefault(),q(R.leftKey)},children:R.leftKey.toUpperCase()}),Xt.jsx("div",{style:bt(mt(R.downKey)),onMouseDown:()=>D(R.downKey),onMouseUp:()=>q(R.downKey),onMouseLeave:()=>q(R.downKey),onTouchStart:gt=>{gt.preventDefault(),D(R.downKey)},onTouchEnd:gt=>{gt.preventDefault(),q(R.downKey)},children:R.downKey.toUpperCase()}),Xt.jsx("div",{style:bt(mt(R.rightKey)),onMouseDown:()=>D(R.rightKey),onMouseUp:()=>q(R.rightKey),onMouseLeave:()=>q(R.rightKey),onTouchStart:gt=>{gt.preventDefault(),D(R.rightKey)},onTouchEnd:gt=>{gt.preventDefault(),q(R.rightKey)},children:R.rightKey.toUpperCase()})]})]},L.id)});return Xt.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[Xt.jsx("canvas",{ref:_,onPointerDown:L=>{var R;x(L,"down"),(R=_.current)==null||R.focus()},onPointerMove:L=>x(L,"move"),onPointerUp:L=>x(L,"up"),onPointerCancel:L=>x(L,"up"),onClick:L=>x(L,"click"),onWheel:L=>{E.current.handleWheel(L.deltaX,L.deltaY)},onKeyDown:L=>E.current.handleKeyDown(L.nativeEvent),onKeyUp:L=>E.current.handleKeyUp(L.nativeEvent),onContextMenu:L=>L.preventDefault(),tabIndex:0,style:{...i,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:T?"auto":"none"}}),tt()]})});function oi(){const[g,t]=xt.useState(null),i=xt.useCallback((l,p)=>{g==null||g.setInputBool(l,p)},[g]),o=xt.useCallback((l,p)=>{g==null||g.setInputNumber(l,p)},[g]),e=xt.useCallback(l=>{g==null||g.fireTrigger(l)},[g]),s=xt.useCallback((l,p)=>{g==null||g.setInputText(l,p)},[g]),n=xt.useCallback((l,p)=>{g==null||g.setInputNumberArray(l,p)},[g]),a=xt.useCallback((l,p)=>{g==null||g.setInputStringArray(l,p)},[g]),r=xt.useCallback((l,p)=>{g==null||g.updateObjectOptions(l,p)},[g]),f=xt.useCallback((l,p,c)=>{g==null||g.updateConstraint(l,p,c)},[g]),h=xt.useCallback((l,p)=>{g==null||g.updateGraphData(l,p)},[g]);return{setEngine:t,engine:g,setInputBool:i,setInputNumber:o,fireTrigger:e,setInputText:s,setInputNumberArray:n,setInputStringArray:a,updateConstraint:f,updateGraphData:h,updateObjectOptions:r}}const ai=({artboard:g,config:t})=>{const i={...g.seo,...t},o=i.enableSmartExtraction!==!1;xt.useEffect(()=>{const a=i.title||g.name;a&&(document.title=a);let r=i.description;if(!r&&o){const l=g.objects.filter(p=>{var c;return((c=p.geometry)==null?void 0:c.type)==="Text"}).sort((p,c)=>{var d,u;return(((d=c.geometry.text)==null?void 0:d.length)||0)-(((u=p.geometry.text)==null?void 0:u.length)||0)});l.length>0&&(r=l[0].geometry.text)}r&&(e("name","description",r),e("property","og:description",r)),i.keywords&&i.keywords.length>0&&e("name","keywords",i.keywords.join(", "));const f=i.ogImage||g.backgroundImage;f&&e("property","og:image",f),a&&e("property","og:title",a),e("property","og:type","website")},[i,g,o]);const e=(a,r,f)=>{let h=document.querySelector(`meta[${a}="${r}"]`);h||(h=document.createElement("meta"),h.setAttribute(a,r),document.head.appendChild(h)),h.setAttribute("content",f)},s=()=>{const a=[];return a.push(Xt.jsx("h1",{children:i.title||g.name},"artboard-title")),g.objects.forEach((f,h)=>{var l,p;if(!(f.visible===!1||f.isVisible===!1))if(((l=f.geometry)==null?void 0:l.type)==="Text"){const c=f.geometry.text;c&&(f.geometry.fontSize>24?a.push(Xt.jsx("h2",{children:c},f.id||h)):a.push(Xt.jsx("p",{children:c},f.id||h)))}else if(((p=f.geometry)==null?void 0:p.type)==="Image"){const c=f.geometry.src,d=f.altText||f.name||"Illustration";a.push(Xt.jsx("img",{src:c,alt:d},f.id||h))}else f.type==="Button"&&a.push(Xt.jsx("button",{children:f.name||"Button"},f.id||h))}),a},n=i.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:i.title||g.name,description:i.description,image:i.ogImage||g.backgroundImage,abstract:"Animated interface created with ExodeUI"};return Xt.jsxs("div",{id:`exode-seo-${g.id||"default"}`,"aria-hidden":"false",style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0",zIndex:-1},children:[s(),Xt.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})]})},ri={version:"6.3.40"}.version;zt.BehaviorSensor=Qt,zt.BehaviorType=H,zt.ConditionOp=je,zt.ExodeSEO=ai,zt.ExodeUICanvas=ni,zt.ExodeUIEngine=ys,zt.LogicOp=wt,zt.RapierPhysics=is,zt.VERSION=ri,zt.useExodeUI=oi,Object.defineProperty(zt,Symbol.toStringTag,{value:"Module"})}));