exodeui 6.0.28 → 6.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +29 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,10 +65,24 @@ Render beautiful, animated line graphs with zero extra code.
|
|
|
65
65
|
- **Line Graphs**: Supports multiple datasets, smoothing (Catmull-Rom splines), fill areas, and points.
|
|
66
66
|
- **Data Binding**: Bind graph data to runtime inputs or variables.
|
|
67
67
|
|
|
68
|
+
### 4. SEO & Metadata
|
|
69
|
+
Automatically manage page metadata and generate semantic HTML for search engines and screen readers.
|
|
70
|
+
- **Automatic Metadata**: Updates `document.title`, meta description, keywords, and OpenGraph tags based on your artboard configuration.
|
|
71
|
+
- **Semantic Overlay**: Generates a visually hidden but accessible HTML structure (H1, H2, P, buttons) based on the objects in your animation.
|
|
72
|
+
- **JSON-LD**: Injects structured data (schema.org) for advanced search engine rich results.
|
|
73
|
+
|
|
68
74
|
```tsx
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
import { ExodeUICanvas, ExodeSEO } from 'exodeui';
|
|
76
|
+
|
|
77
|
+
function MyPage({ artboard }) {
|
|
78
|
+
return (
|
|
79
|
+
<>
|
|
80
|
+
{/* ExodeSEO handles title, meta tags, and accessibility overlay */}
|
|
81
|
+
<ExodeSEO artboard={artboard} />
|
|
82
|
+
<ExodeUICanvas artboard={artboard} />
|
|
83
|
+
</>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
72
86
|
```
|
|
73
87
|
|
|
74
88
|
## API Reference
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
`):B.replace(/\r\n/g,`
|
|
4
4
|
`)}let QC=null,NB;function FB(){return QC===null&&(QC=new Intl.Segmenter(NB,{granularity:"word"})),QC}const MB=new RegExp("\\p{Script=Arabic}","u"),ig=new RegExp("\\p{M}","u"),FQ=new RegExp("\\p{Nd}","u");function BC(B){return MB.test(B)}function tI(B){for(const A of B){const I=A.codePointAt(0);if(I>=19968&&I<=40959||I>=13312&&I<=19903||I>=131072&&I<=173791||I>=173824&&I<=177983||I>=177984&&I<=178207||I>=178208&&I<=183983||I>=183984&&I<=191471||I>=196608&&I<=201551||I>=63744&&I<=64255||I>=194560&&I<=195103||I>=12288&&I<=12351||I>=12352&&I<=12447||I>=12448&&I<=12543||I>=44032&&I<=55215||I>=65280&&I<=65519)return!0}return!1}const MQ=new Set([",",".","!",":",";","?","、","。","・",")","〕","〉","》","」","』","】","〗","〙","〛","ー","々","〻","ゝ","ゞ","ヽ","ヾ"]),og=new Set(['"',"(","[","{","“","‘","«","‹","(","〔","〈","《","「","『","【","〖","〘","〚"]),EC=new Set(["'","’"]),uI=new Set([".",",","!","?",":",";","،","؛","؟","।","॥","၊","။","၌","၍","၏",")","]","}","%",'"',"”","’","»","›","…"]),eB=new Set([":",".","،","؛"]),cB=new Set(["၏"]),JB=new Set(["”","’","»","›","」","』","】","》","〉","〕",")"]);function RB(B){if(iC(B))return!0;let A=!1;for(const I of B){if(uI.has(I)){A=!0;continue}if(!(A&&ig.test(I)))return!1}return A}function UB(B){for(const A of B)if(!MQ.has(A)&&!uI.has(A))return!1;return B.length>0}function rB(B){if(iC(B))return!0;for(const A of B)if(!og.has(A)&&!EC.has(A)&&!ig.test(A))return!1;return B.length>0}function iC(B){let A=!1;for(const I of B)if(!(I==="\\"||ig.test(I))){if(og.has(I)||uI.has(I)||EC.has(I)){A=!0;continue}return!1}return A}function nB(B){const A=Array.from(B);let I=A.length;for(;I>0;){const C=A[I-1];if(ig.test(C)){I--;continue}if(og.has(C)||EC.has(C)){I--;continue}break}return I<=0||I===A.length?null:{head:A.slice(0,I).join(""),tail:A.slice(I).join("")}}function YB(B,A){if(B.length===0)return!1;for(const I of B)if(I!==A)return!1;return!0}function lB(B){return!BC(B)||B.length===0?!1:eB.has(B[B.length-1])}function LB(B){return B.length===0?!1:cB.has(B[B.length-1])}function qB(B){if(B.length<2||B[0]!==" ")return null;const A=B.slice(1);return new RegExp("^\\p{M}+$","u").test(A)?{space:" ",marks:A}:null}function eQ(B){for(let A=B.length-1;A>=0;A--){const I=B[A];if(JB.has(I))return!0;if(!uI.has(I))return!1}return!1}function pB(B,A){if(A.preserveOrdinarySpaces||A.preserveHardBreaks){if(B===" ")return"preserved-space";if(B===" ")return"tab";if(A.preserveHardBreaks&&B===`
|
|
5
5
|
`)return"hard-break"}return B===" "?"space":B===" "||B===" "||B===""||B==="\uFEFF"?"glue":B===""?"zero-width-break":B===""?"soft-hyphen":"text"}function HB(B,A,I,C){const g=[];let Q=null,E="",i=I,D=!1,o=0;for(const s of B){const h=pB(s,C),a=h==="text"&&A;if(Q!==null&&h===Q&&a===D){E+=s,o+=s.length;continue}Q!==null&&g.push({text:E,isWordLike:D,kind:Q,start:i}),Q=h,E=s,i=I+o,D=a,o+=s.length}return Q!==null&&g.push({text:E,isWordLike:D,kind:Q,start:i}),g}function oC(B){return B==="space"||B==="preserved-space"||B==="zero-width-break"||B==="hard-break"}const dB=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function fB(B,A){const I=B.texts[A];return I.startsWith("www.")?!0:dB.test(I)&&A+1<B.len&&B.kinds[A+1]==="text"&&B.texts[A+1]==="//"}function bB(B){return B.includes("?")&&(B.includes("://")||B.startsWith("www."))}function TB(B){const A=B.texts.slice(),I=B.isWordLike.slice(),C=B.kinds.slice(),g=B.starts.slice();for(let E=0;E<B.len;E++){if(C[E]!=="text"||!fB(B,E))continue;let i=E+1;for(;i<B.len&&!oC(C[i]);){A[E]+=A[i],I[E]=!0;const D=A[i].includes("?");if(C[i]="text",A[i]="",i++,D)break}}let Q=0;for(let E=0;E<A.length;E++){const i=A[E];i.length!==0&&(Q!==E&&(A[Q]=i,I[Q]=I[E],C[Q]=C[E],g[Q]=g[E]),Q++)}return A.length=Q,I.length=Q,C.length=Q,g.length=Q,{len:Q,texts:A,isWordLike:I,kinds:C,starts:g}}function uB(B){const A=[],I=[],C=[],g=[];for(let Q=0;Q<B.len;Q++){const E=B.texts[Q];if(A.push(E),I.push(B.isWordLike[Q]),C.push(B.kinds[Q]),g.push(B.starts[Q]),!bB(E))continue;const i=Q+1;if(i>=B.len||oC(B.kinds[i]))continue;let D="";const o=B.starts[i];let s=i;for(;s<B.len&&!oC(B.kinds[s]);)D+=B.texts[s],s++;D.length>0&&(A.push(D),I.push(!0),C.push("text"),g.push(o),Q=s-1)}return{len:A.length,texts:A,isWordLike:I,kinds:C,starts:g}}const mB=new Set([":","-","/","×",",",".","+","–","—"]),cQ=/^[A-Za-z0-9_]+[,:;]*$/,xB=/[,:;]+$/;function JQ(B){for(const A of B)if(FQ.test(A))return!0;return!1}function DC(B){if(B.length===0)return!1;for(const A of B)if(!(FQ.test(A)||mB.has(A)))return!1;return!0}function OB(B){const A=[],I=[],C=[],g=[];for(let Q=0;Q<B.len;Q++){const E=B.texts[Q],i=B.kinds[Q];if(i==="text"&&DC(E)&&JQ(E)){let D=E,o=Q+1;for(;o<B.len&&B.kinds[o]==="text"&&DC(B.texts[o]);)D+=B.texts[o],o++;A.push(D),I.push(!0),C.push("text"),g.push(B.starts[Q]),Q=o-1;continue}A.push(E),I.push(B.isWordLike[Q]),C.push(i),g.push(B.starts[Q])}return{len:A.length,texts:A,isWordLike:I,kinds:C,starts:g}}function WB(B){const A=[],I=[],C=[],g=[];for(let Q=0;Q<B.len;Q++){const E=B.texts[Q],i=B.kinds[Q],D=B.isWordLike[Q];if(i==="text"&&D&&cQ.test(E)){let o=E,s=Q+1;for(;xB.test(o)&&s<B.len&&B.kinds[s]==="text"&&B.isWordLike[s]&&cQ.test(B.texts[s]);)o+=B.texts[s],s++;A.push(o),I.push(!0),C.push("text"),g.push(B.starts[Q]),Q=s-1;continue}A.push(E),I.push(D),C.push(i),g.push(B.starts[Q])}return{len:A.length,texts:A,isWordLike:I,kinds:C,starts:g}}function ZB(B){const A=[],I=[],C=[],g=[];for(let Q=0;Q<B.len;Q++){const E=B.texts[Q];if(B.kinds[Q]==="text"&&E.includes("-")){const i=E.split("-");let D=i.length>1;for(let o=0;o<i.length;o++){const s=i[o];if(!D)break;(s.length===0||!JQ(s)||!DC(s))&&(D=!1)}if(D){let o=0;for(let s=0;s<i.length;s++){const h=i[s],a=s<i.length-1?`${h}-`:h;A.push(a),I.push(!0),C.push("text"),g.push(B.starts[Q]+o),o+=a.length}continue}}A.push(E),I.push(B.isWordLike[Q]),C.push(B.kinds[Q]),g.push(B.starts[Q])}return{len:A.length,texts:A,isWordLike:I,kinds:C,starts:g}}function jB(B){const A=[],I=[],C=[],g=[];let Q=0;for(;Q<B.len;){let E=B.texts[Q],i=B.isWordLike[Q],D=B.kinds[Q],o=B.starts[Q];if(D==="glue"){let s=E;const h=o;for(Q++;Q<B.len&&B.kinds[Q]==="glue";)s+=B.texts[Q],Q++;if(Q<B.len&&B.kinds[Q]==="text")E=s+B.texts[Q],i=B.isWordLike[Q],D="text",o=h,Q++;else{A.push(s),I.push(!1),C.push("glue"),g.push(h);continue}}else Q++;if(D==="text")for(;Q<B.len&&B.kinds[Q]==="glue";){let s="";for(;Q<B.len&&B.kinds[Q]==="glue";)s+=B.texts[Q],Q++;if(Q<B.len&&B.kinds[Q]==="text"){E+=s+B.texts[Q],i=i||B.isWordLike[Q],Q++;continue}E+=s}A.push(E),I.push(i),C.push(D),g.push(o)}return{len:A.length,texts:A,isWordLike:I,kinds:C,starts:g}}function XB(B){const A=B.texts.slice(),I=B.isWordLike.slice(),C=B.kinds.slice(),g=B.starts.slice();for(let Q=0;Q<A.length-1;Q++){if(C[Q]!=="text"||C[Q+1]!=="text"||!tI(A[Q])||!tI(A[Q+1]))continue;const E=nB(A[Q]);E!==null&&(A[Q]=E.head,A[Q+1]=E.tail+A[Q+1],g[Q+1]=g[Q]+E.head.length)}return{len:A.length,texts:A,isWordLike:I,kinds:C,starts:g}}function vB(B,A,I){const C=FB();let g=0;const Q=[],E=[],i=[],D=[];for(const a of C.segment(B))for(const G of HB(a.segment,a.isWordLike??!1,a.index,I)){const t=G.kind==="text";A.carryCJKAfterClosingQuote&&t&&g>0&&i[g-1]==="text"&&tI(G.text)&&tI(Q[g-1])&&eQ(Q[g-1])||t&&g>0&&i[g-1]==="text"&&UB(G.text)&&tI(Q[g-1])||t&&g>0&&i[g-1]==="text"&&LB(Q[g-1])?(Q[g-1]+=G.text,E[g-1]=E[g-1]||G.isWordLike):t&&g>0&&i[g-1]==="text"&&G.isWordLike&&BC(G.text)&&lB(Q[g-1])?(Q[g-1]+=G.text,E[g-1]=!0):t&&!G.isWordLike&&g>0&&i[g-1]==="text"&&G.text.length===1&&G.text!=="-"&&G.text!=="—"&&YB(Q[g-1],G.text)||t&&!G.isWordLike&&g>0&&i[g-1]==="text"&&(RB(G.text)||G.text==="-"&&E[g-1])?Q[g-1]+=G.text:(Q[g]=G.text,E[g]=G.isWordLike,i[g]=G.kind,D[g]=G.start,g++)}for(let a=1;a<g;a++)i[a]==="text"&&!E[a]&&iC(Q[a])&&i[a-1]==="text"&&(Q[a-1]+=Q[a],E[a-1]=E[a-1]||E[a],Q[a]="");for(let a=g-2;a>=0;a--)if(i[a]==="text"&&!E[a]&&rB(Q[a])){let G=a+1;for(;G<g&&Q[G]==="";)G++;G<g&&i[G]==="text"&&(Q[G]=Q[a]+Q[G],D[G]=D[a],Q[a]="")}let o=0;for(let a=0;a<g;a++){const G=Q[a];G.length!==0&&(o!==a&&(Q[o]=G,E[o]=E[a],i[o]=i[a],D[o]=D[a]),o++)}Q.length=o,E.length=o,i.length=o,D.length=o;const s=jB({len:o,texts:Q,isWordLike:E,kinds:i,starts:D}),h=XB(WB(ZB(OB(uB(TB(s))))));for(let a=0;a<h.len-1;a++){const G=qB(h.texts[a]);G!==null&&(h.kinds[a]!=="space"&&h.kinds[a]!=="preserved-space"||h.kinds[a+1]!=="text"||!BC(h.texts[a+1])||(h.texts[a]=G.space,h.isWordLike[a]=!1,h.kinds[a]=h.kinds[a]==="preserved-space"?"preserved-space":"space",h.texts[a+1]=G.marks+h.texts[a+1],h.starts[a+1]=h.starts[a]+G.space.length))}return h}function PB(B,A){if(B.len===0)return[];if(!A.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:B.len,consumedEndSegmentIndex:B.len}];const I=[];let C=0;for(let g=0;g<B.len;g++)B.kinds[g]==="hard-break"&&(I.push({startSegmentIndex:C,endSegmentIndex:g,consumedEndSegmentIndex:g+1}),C=g+1);return C<B.len&&I.push({startSegmentIndex:C,endSegmentIndex:B.len,consumedEndSegmentIndex:B.len}),I}function VB(B,A,I="normal"){const C=SB(I),g=C.mode==="pre-wrap"?kB(B):yB(B);if(g.length===0)return{normalized:g,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};const Q=vB(g,A,C);return{normalized:g,chunks:PB(Q,C),...Q}}let JI=null;const RQ=new Map;let RI=null;const zB=new RegExp("\\p{Emoji_Presentation}","u"),_B=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;let wC=null;const UQ=new Map;function sC(){if(JI!==null)return JI;if(typeof OffscreenCanvas<"u")return JI=new OffscreenCanvas(1,1).getContext("2d"),JI;if(typeof document<"u")return JI=document.createElement("canvas").getContext("2d"),JI;throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function $B(B){let A=RQ.get(B);return A||(A=new Map,RQ.set(B,A)),A}function KI(B,A){let I=A.get(B);return I===void 0&&(I={width:sC().measureText(B).width,containsCJK:tI(B)},A.set(B,I)),I}function Dg(){if(RI!==null)return RI;if(typeof navigator>"u")return RI={lineFitEpsilon:.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},RI;const B=navigator.userAgent,I=navigator.vendor==="Apple Computer, Inc."&&B.includes("Safari/")&&!B.includes("Chrome/")&&!B.includes("Chromium/")&&!B.includes("CriOS/")&&!B.includes("FxiOS/")&&!B.includes("EdgiOS/"),C=B.includes("Chrome/")||B.includes("Chromium/")||B.includes("CriOS/")||B.includes("Edg/");return RI={lineFitEpsilon:I?1/64:.005,carryCJKAfterClosingQuote:C,preferPrefixWidthsForBreakableRuns:I,preferEarlySoftHyphenBreak:I},RI}function AE(B){const A=B.match(/(\d+(?:\.\d+)?)\s*px/);return A?parseFloat(A[1]):16}function hC(){return wC===null&&(wC=new Intl.Segmenter(void 0,{granularity:"grapheme"})),wC}function IE(B){return zB.test(B)||B.includes("️")}function gE(B){return _B.test(B)}function CE(B,A){let I=UQ.get(B);if(I!==void 0)return I;const C=sC();C.font=B;const g=C.measureText("😀").width;if(I=0,g>A+.5&&typeof document<"u"&&document.body!==null){const Q=document.createElement("span");Q.style.font=B,Q.style.display="inline-block",Q.style.visibility="hidden",Q.style.position="absolute",Q.textContent="😀",document.body.appendChild(Q);const E=Q.getBoundingClientRect().width;document.body.removeChild(Q),g-E>.5&&(I=g-E)}return UQ.set(B,I),I}function QE(B){let A=0;const I=hC();for(const C of I.segment(B))IE(C.segment)&&A++;return A}function BE(B,A){return A.emojiCount===void 0&&(A.emojiCount=QE(B)),A.emojiCount}function SI(B,A,I){return I===0?A.width:A.width-BE(B,A)*I}function EE(B,A,I,C){if(A.graphemeWidths!==void 0)return A.graphemeWidths;const g=[],Q=hC();for(const E of Q.segment(B)){const i=KI(E.segment,I);g.push(SI(E.segment,i,C))}return A.graphemeWidths=g.length>1?g:null,A.graphemeWidths}function iE(B,A,I,C){if(A.graphemePrefixWidths!==void 0)return A.graphemePrefixWidths;const g=[],Q=hC();let E="";for(const i of Q.segment(B)){E+=i.segment;const D=KI(E,I);g.push(SI(E,D,C))}return A.graphemePrefixWidths=g.length>1?g:null,A.graphemePrefixWidths}function oE(B,A){const I=sC();I.font=B;const C=$B(B),g=AE(B),Q=A?CE(B,g):0;return{cache:C,fontSize:g,emojiCorrection:Q}}function wg(B){return B==="space"||B==="preserved-space"||B==="tab"||B==="zero-width-break"||B==="soft-hyphen"}function DE(B,A){if(A<=0)return 0;const I=B%A;return Math.abs(I)<=1e-6?A:A-I}function rQ(B,A,I,C){return!C||A===null?B[I]:A[I]-(I>0?A[I-1]:0)}function wE(B,A,I,C,g,Q){let E=0,i=A;for(;E<B.length;){const D=Q?A+B[E]:i+B[E];if((E+1<B.length?D+g:D)>I+C)break;i=D,E++}return{fitCount:E,fittedWidth:i}}function sE(B,A,I){const{widths:C,kinds:g,breakableWidths:Q,breakablePrefixWidths:E}=B;if(C.length===0)return 0;const i=Dg(),D=i.lineFitEpsilon;let o=0,s=0,h=!1,a=0,G=0,t=0,K=0,S=-1,y=0;function F(){S=-1,y=0}function e(U=t,T=K,AA=s){o++,I==null||I({startSegmentIndex:a,startGraphemeIndex:G,endSegmentIndex:U,endGraphemeIndex:T,width:AA}),s=0,h=!1,F()}function M(U,T){h=!0,a=U,G=0,t=U+1,K=0,s=T}function n(U,T,AA){h=!0,a=U,G=T,t=U,K=T+1,s=AA}function X(U,T){if(!h){M(U,T);return}s+=T,t=U+1,K=0}function Z(U,T){wg(g[U])&&(S=U+1,y=s-T)}function H(U){QA(U,0)}function QA(U,T){const AA=Q[U],IA=E[U]??null;for(let b=T;b<AA.length;b++){const P=rQ(AA,IA,b,i.preferPrefixWidthsForBreakableRuns);if(!h){n(U,b,P);continue}s+P>A+D?(e(),n(U,b,P)):(s+=P,t=U,K=b+1)}h&&t===U&&K===AA.length&&(t=U+1,K=0)}let L=0;for(;L<C.length;){const U=C[L],T=g[L];if(!h){U>A&&Q[L]!==null?H(L):M(L,U),Z(L,U),L++;continue}if(s+U>A+D){if(wg(T)){X(L,U),e(L+1,0,s-U),L++;continue}if(S>=0){e(S,0,y);continue}if(U>A&&Q[L]!==null){e(),H(L),L++;continue}e();continue}X(L,U),Z(L,U),L++}return h&&e(),o}function hE(B,A,I){if(B.simpleLineWalkFastPath)return sE(B,A,I);const{widths:C,lineEndFitAdvances:g,lineEndPaintAdvances:Q,kinds:E,breakableWidths:i,breakablePrefixWidths:D,discretionaryHyphenWidth:o,tabStopAdvance:s,chunks:h}=B;if(C.length===0||h.length===0)return 0;const a=Dg(),G=a.lineFitEpsilon;let t=0,K=0,S=!1,y=0,F=0,e=0,M=0,n=-1,X=0,Z=0,H=null;function QA(){n=-1,X=0,Z=0,H=null}function L(q=e,l=M,r=K){t++,I==null||I({startSegmentIndex:y,startGraphemeIndex:F,endSegmentIndex:q,endGraphemeIndex:l,width:r}),K=0,S=!1,QA()}function U(q,l){S=!0,y=q,F=0,e=q+1,M=0,K=l}function T(q,l,r){S=!0,y=q,F=l,e=q,M=l+1,K=r}function AA(q,l){if(!S){U(q,l);return}K+=l,e=q+1,M=0}function IA(q,l){if(!wg(E[q]))return;const r=E[q]==="tab"?0:g[q],z=E[q]==="tab"?l:Q[q];n=q+1,X=K-l+r,Z=K-l+z,H=E[q]}function b(q){P(q,0)}function P(q,l){const r=i[q],z=D[q]??null;for(let d=l;d<r.length;d++){const _=rQ(r,z,d,a.preferPrefixWidthsForBreakableRuns);if(!S){T(q,d,_);continue}K+_>A+G?(L(),T(q,d,_)):(K+=_,e=q,M=d+1)}S&&e===q&&M===r.length&&(e=q+1,M=0)}function gA(q){if(H!=="soft-hyphen")return!1;const l=i[q];if(l===null)return!1;const r=a.preferPrefixWidthsForBreakableRuns?D[q]??l:l,z=r!==l,{fitCount:d,fittedWidth:_}=wE(r,K,A,G,o,z);return d===0?!1:(K=_,e=q,M=d,QA(),d===l.length?(e=q+1,M=0,!0):(L(q,d,_+o),P(q,d),!0))}function u(q){t++,I==null||I({startSegmentIndex:q.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:q.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),QA()}for(let q=0;q<h.length;q++){const l=h[q];if(l.startSegmentIndex===l.endSegmentIndex){u(l);continue}S=!1,K=0,y=l.startSegmentIndex,F=0,e=l.startSegmentIndex,M=0,QA();let r=l.startSegmentIndex;for(;r<l.endSegmentIndex;){const z=E[r],d=z==="tab"?DE(K,s):C[r];if(z==="soft-hyphen"){S&&(e=r+1,M=0,n=r+1,X=K+o,Z=K+o,H=z),r++;continue}if(!S){d>A&&i[r]!==null?b(r):U(r,d),IA(r,d),r++;continue}if(K+d>A+G){const hA=K+(z==="tab"?0:g[r]),SA=K+(z==="tab"?d:Q[r]);if(H==="soft-hyphen"&&a.preferEarlySoftHyphenBreak&&X<=A+G){L(n,0,Z);continue}if(H==="soft-hyphen"&&gA(r)){r++;continue}if(wg(z)&&hA<=A+G){AA(r,d),L(r+1,0,SA),r++;continue}if(n>=0&&X<=A+G){L(n,0,Z);continue}if(d>A&&i[r]!==null){L(),b(r),r++;continue}L();continue}AA(r,d),IA(r,d),r++}if(S){const z=n===l.consumedEndSegmentIndex?Z:K;L(l.consumedEndSegmentIndex,0,z)}}return t}let aC=null,nQ=new WeakMap;function YQ(){return aC===null&&(aC=new Intl.Segmenter(void 0,{granularity:"grapheme"})),aC}function aE(B){return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]}}function GE(B,A,I){const C=YQ(),g=Dg(),{cache:Q,emojiCorrection:E}=oE(A,gE(B.normalized)),i=SI("-",KI("-",Q),E),o=SI(" ",KI(" ",Q),E)*8;if(B.len===0)return aE();const s=[],h=[],a=[],G=[];let t=B.chunks.length<=1;const K=[],S=[],y=[],F=I?[]:null,e=Array.from({length:B.len}),M=Array.from({length:B.len});function n(H,QA,L,U,T,AA,IA,b){T!=="text"&&T!=="space"&&T!=="zero-width-break"&&(t=!1),s.push(QA),h.push(L),a.push(U),G.push(T),K==null||K.push(AA),S.push(IA),y.push(b),F!==null&&F.push(H)}for(let H=0;H<B.len;H++){e[H]=s.length;const QA=B.texts[H],L=B.isWordLike[H],U=B.kinds[H],T=B.starts[H];if(U==="soft-hyphen"){n(QA,0,i,i,U,T,null,null),M[H]=s.length;continue}if(U==="hard-break"){n(QA,0,0,0,U,T,null,null),M[H]=s.length;continue}if(U==="tab"){n(QA,0,0,0,U,T,null,null),M[H]=s.length;continue}const AA=KI(QA,Q);if(U==="text"&&AA.containsCJK){let gA="",u=0;for(const q of C.segment(QA)){const l=q.segment;if(gA.length===0){gA=l,u=q.index;continue}if(og.has(gA)||MQ.has(l)||uI.has(l)||g.carryCJKAfterClosingQuote&&tI(l)&&eQ(gA)){gA+=l;continue}const r=KI(gA,Q),z=SI(gA,r,E);n(gA,z,z,z,"text",T+u,null,null),gA=l,u=q.index}if(gA.length>0){const q=KI(gA,Q),l=SI(gA,q,E);n(gA,l,l,l,"text",T+u,null,null)}M[H]=s.length;continue}const IA=SI(QA,AA,E),b=U==="space"||U==="preserved-space"||U==="zero-width-break"?0:IA,P=U==="space"||U==="zero-width-break"?0:IA;if(L&&QA.length>1){const gA=EE(QA,AA,Q,E),u=g.preferPrefixWidthsForBreakableRuns?iE(QA,AA,Q,E):null;n(QA,IA,b,P,U,T,gA,u)}else n(QA,IA,b,P,U,T,null,null);M[H]=s.length}const X=tE(B.chunks,e,M),Z=K===null?null:GB(B.normalized,K);return F!==null?{widths:s,lineEndFitAdvances:h,lineEndPaintAdvances:a,kinds:G,simpleLineWalkFastPath:t,segLevels:Z,breakableWidths:S,breakablePrefixWidths:y,discretionaryHyphenWidth:i,tabStopAdvance:o,chunks:X,segments:F}:{widths:s,lineEndFitAdvances:h,lineEndPaintAdvances:a,kinds:G,simpleLineWalkFastPath:t,segLevels:Z,breakableWidths:S,breakablePrefixWidths:y,discretionaryHyphenWidth:i,tabStopAdvance:o,chunks:X}}function tE(B,A,I){const C=[];for(let g=0;g<B.length;g++){const Q=B[g],E=Q.startSegmentIndex<A.length?A[Q.startSegmentIndex]:I[I.length-1]??0,i=Q.endSegmentIndex<A.length?A[Q.endSegmentIndex]:I[I.length-1]??0,D=Q.consumedEndSegmentIndex<A.length?A[Q.consumedEndSegmentIndex]:I[I.length-1]??0;C.push({startSegmentIndex:E,endSegmentIndex:i,consumedEndSegmentIndex:D})}return C}function KE(B,A,I,C){const g=VB(B,Dg(),C==null?void 0:C.whiteSpace);return GE(g,A,I)}function SE(B,A,I){return KE(B,A,!0,I)}function ii(B){return B}function lQ(B,A,I){let C=I.get(B);if(C!==void 0)return C;C=[];const g=YQ();for(const Q of g.segment(A[B]))C.push(Q.segment);return I.set(B,C),C}function yE(B){let A=nQ.get(B);return A!==void 0||(A=new Map,nQ.set(B,A)),A}function kE(B,A,I,C){return C>0&&B[C-1]==="soft-hyphen"&&!(A===C&&I>0)}function NE(B,A,I,C,g,Q,E){let i="";const D=kE(A,C,g,Q);for(let o=C;o<Q;o++)A[o]==="soft-hyphen"||A[o]==="hard-break"||(o===C&&g>0?i+=lQ(o,B,I).slice(g).join(""):i+=B[o]);return E>0?(D&&(i+="-"),i+=lQ(Q,B,I).slice(C===Q?g:0,E).join("")):D&&(i+="-"),i}function FE(B,A,I,C,g,Q,E){return{text:NE(B.segments,B.kinds,A,C,g,Q,E),width:I,start:{segmentIndex:C,graphemeIndex:g},end:{segmentIndex:Q,graphemeIndex:E}}}function ME(B,A,I){return FE(B,A,I.width,I.startSegmentIndex,I.startGraphemeIndex,I.endSegmentIndex,I.endGraphemeIndex)}function eE(B,A,I){const C=[];if(B.widths.length===0)return{lineCount:0,height:0,lines:C};const g=yE(B),Q=hE(B,A,E=>{C.push(ME(B,g,E))});return{lineCount:Q,height:Q*I,lines:C}}const LQ=B=>B,cE=B=>B>0?1:0,JE=B=>B<1?0:1,qQ=B=>B*B,pQ=B=>B*(2-B),HQ=B=>B<.5?2*B*B:-1+(4-2*B)*B,RE=B=>B*B*B,UE=B=>--B*B*B+1,rE=B=>B<.5?4*B*B*B:(B-1)*(2*B-2)*(2*B-2)+1,nE=B=>B*B*B*B,YE=B=>1- --B*B*B*B,lE=B=>B<.5?8*B*B*B*B:1-8*--B*B*B*B,LE=B=>B*B*B*B*B,qE=B=>1+--B*B*B*B*B,pE=B=>B<.5?16*B*B*B*B*B:1+16*--B*B*B*B*B,HE=B=>1-Math.cos(B*Math.PI/2),dE=B=>Math.sin(B*Math.PI/2),fE=B=>-(Math.cos(Math.PI*B)-1)/2,bE=B=>B===0?0:Math.pow(2,10*(B-1)),TE=B=>B===1?1:1-Math.pow(2,-10*B),uE=B=>B===0?0:B===1?1:B<.5?Math.pow(2,20*B-10)/2:(2-Math.pow(2,-20*B+10))/2,mE=B=>1-Math.sqrt(1-B*B),xE=B=>Math.sqrt(1- --B*B),OE=B=>B<.5?(1-Math.sqrt(1-4*B*B))/2:(Math.sqrt(1-(-2*B+2)*(-2*B+2))+1)/2,sg=1.70158,hg=sg*1.525,dQ=sg+1,WE=B=>dQ*B*B*B-sg*B*B,ZE=B=>1+dQ*Math.pow(B-1,3)+sg*Math.pow(B-1,2),jE=B=>B<.5?Math.pow(2*B,2)*((hg+1)*2*B-hg)/2:(Math.pow(2*B-2,2)*((hg+1)*(B*2-2)+hg)+2)/2,fQ=2*Math.PI/3,bQ=2*Math.PI/4.5,XE=B=>B===0?0:B===1?1:-Math.pow(2,10*B-10)*Math.sin((B*10-10.75)*fQ),vE=B=>B===0?0:B===1?1:Math.pow(2,-10*B)*Math.sin((B*10-.75)*fQ)+1,PE=B=>B===0?0:B===1?1:B<.5?-(Math.pow(2,20*B-10)*Math.sin((20*B-11.125)*bQ))/2:Math.pow(2,-20*B+10)*Math.sin((20*B-11.125)*bQ)/2+1,ag=B=>B<1/2.75?7.5625*B*B:B<2/2.75?7.5625*(B-=1.5/2.75)*B+.75:B<2.5/2.75?7.5625*(B-=2.25/2.75)*B+.9375:7.5625*(B-=2.625/2.75)*B+.984375,VE=B=>1-ag(1-B),zE=ag,_E=B=>B<.5?(1-ag(1-2*B))/2:(1+ag(2*B-1))/2,GC=new Map,mI=(B,A,I,C)=>{const g=`${B},${A},${I},${C}`;if(GC.has(g))return GC.get(g);const Q=s=>(1-3*I+3*B)*s*s*s+(3*I-6*B)*s*s+3*B*s,E=s=>(1-3*C+3*A)*s*s*s+(3*C-6*A)*s*s+3*A*s,i=s=>3*(1-3*I+3*B)*s*s+2*(3*I-6*B)*s+3*B,D=s=>{let h=s;for(let a=0;a<8;a++){const G=Q(h)-s;if(Math.abs(G)<1e-6)return h;const t=i(h);if(Math.abs(t)<1e-6)break;h=h-G/t}return h},o=s=>s===0?0:s===1?1:E(D(s));return GC.set(g,o),o},TQ=B=>{const A=B.match(/cubic-bezier\s*\(\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*\)/);if(!A)return null;const[,I,C,g,Q]=A.map(Number);return mI(I,C,g,Q)},uQ={ease:mI(.25,.1,.25,1),"ease-in":mI(.42,0,1,1),"ease-out":mI(0,0,.58,1),"ease-in-out":mI(.42,0,.58,1)},Gg={Linear:LQ,EaseInQuad:qQ,EaseOutQuad:pQ,EaseInOutQuad:HQ,EaseInCubic:RE,EaseOutCubic:UE,EaseInOutCubic:rE,EaseInQuart:nE,EaseOutQuart:YE,EaseInOutQuart:lE,EaseInQuint:LE,EaseOutQuint:qE,EaseInOutQuint:pE,EaseInSine:HE,EaseOutSine:dE,EaseInOutSine:fE,EaseInExpo:bE,EaseOutExpo:TE,EaseInOutExpo:uE,EaseInCirc:mE,EaseOutCirc:xE,EaseInOutCirc:OE,EaseInBack:WE,EaseOutBack:ZE,EaseInOutBack:jE,EaseInElastic:XE,EaseOutElastic:vE,EaseInOutElastic:PE,EaseInBounce:VE,EaseOutBounce:zE,EaseInOutBounce:_E,EaseIn:qQ,EaseOut:pQ,EaseInOut:HQ,StepStart:cE,StepEnd:JE},$E=B=>{const A=B.trim(),I=A.toLowerCase();if(Gg[A])return Gg[A];const C=Object.keys(Gg).find(Q=>Q.toLowerCase()===I);if(C)return Gg[C];const g=Object.keys(mQ).find(Q=>Q.toLowerCase()===I);if(g){const Q=TQ(mQ[g].value);if(Q)return Q}if(uQ[I])return uQ[I];if(I.startsWith("cubic-bezier")){const Q=TQ(A);if(Q)return Q}return LQ},mQ={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)"}};class xQ{constructor(){tA(this,"artboard",null);tA(this,"objectStates",new Map);tA(this,"physicsEngine",null);tA(this,"activeStateMachine",null);tA(this,"inputs",new Map);tA(this,"inputNameMap",new Map);tA(this,"layerStates",new Map);tA(this,"pretextCache",new Map);tA(this,"pointerHistory",[]);tA(this,"MAX_HISTORY",200);tA(this,"imageCache",new Map);tA(this,"lastValidSvgImgMap",new Map);tA(this,"maskBuffer",null);tA(this,"maskCtx",null);tA(this,"lumaBuffer",null);tA(this,"lumaCtx",null);tA(this,"layout",{fit:"Contain",alignment:"Center"});tA(this,"onTrigger");tA(this,"onInputUpdate");tA(this,"onComponentChange");tA(this,"onToggle");tA(this,"onInputChange");tA(this,"onInputFocus");tA(this,"onInputBlur");tA(this,"onLog");tA(this,"justFiredTriggers",new Set);tA(this,"rootTransform",null);tA(this,"canvasWidth",0);tA(this,"canvasHeight",0);tA(this,"lastHoveredObjectId",null);tA(this,"_lastPointerPos",null);tA(this,"_prevPointerPos",null);tA(this,"focusedId",null);tA(this,"draggingSliderId",null);tA(this,"activeDropdownId",null);tA(this,"draggingListViewId",null);tA(this,"scrollOffset",{x:0,y:0});tA(this,"draggingBehaviors",new Set);tA(this,"objectVelocities",new Map);tA(this,"currentTime",0);tA(this,"frameCount",0);tA(this,"fontLeadingFactors",{Inter:.35,Roboto:.45,Montserrat:.4,Outfit:.35,"Open Sans":.4,Poppins:.45,"Playfair Display":.35,Lora:.4});tA(this,"activeTriggers",new Map);console.info("%c[ExodeUI Engine] Pixel-Perfect Parity Active (v6.0.24) - SVG Fill & Gradient Parity Active","color: #3b82f6; font-weight: bold; padding: 2px 4px; border-radius: 4px; background: rgba(59, 130, 246, 0.1)")}setTriggerCallback(A){this.onTrigger=A}setInputUpdateCallback(A){this.onInputUpdate=A}setComponentChangeCallback(A){this.onComponentChange=A}setToggleCallback(A){this.onToggle=A}setInputChangeCallback(A){this.onInputChange=A}setOnLogCallback(A){this.onLog=A}debugLog(A){this.onLog&&this.onLog(A)}setInputFocusCallback(A){this.onInputFocus=A}setInputBlurCallback(A){this.onInputBlur=A}updateConstraint(A,I,C){var Q;const g=(Q=this.artboard)==null?void 0:Q.objects.find(E=>E.id===A);g&&g.constraints&&g.constraints[I]&&(g.constraints[I]={...g.constraints[I],...C},C.useSpring===!1&&this.objectVelocities.delete(A))}setInternalInput(A,I){this.inputs.set(A,I),this.onInputUpdate&&this.onInputUpdate(A,I)}setLayout(A,I){this.layout={fit:A,alignment:I}}getActiveStateIds(A="Base Layer"){const I=this.layerStates.get(A);return I?I.currentStateIds:[]}getObjectState(A){return this.objectStates.get(A)}updateObjectOptions(A,I){const C=this.objectStates.get(A);C&&(C.options={...C.options,...I})}updateGraphData(A,I){if(!this.artboard)return;const C=this.artboard.objects.find(g=>g.id===A||g.name===A);if(C&&C.geometry.type==="LineGraph"){const g=C.geometry;!g.datasets||g.datasets.length===0?g.datasets=[{id:"default",label:"Runtime Data",data:I,lineColor:"#3b82f6",lineWidth:2,showArea:!1}]:g.datasets[0].data=I;const Q=this.objectStates.get(C.id);Q&&Q.geometry&&Q.geometry.type==="LineGraph"&&(!Q.geometry.datasets||Q.geometry.datasets.length===0?Q.geometry.datasets=JSON.parse(JSON.stringify(g.datasets)):Q.geometry.datasets[0].data=[...I]),g.datasets[0].inputId&&this.updateInput(g.datasets[0].inputId,I)}else this.updateInput(A,I)}load(A){this.artboard=A,this.currentTime=0,this.loadFonts(),this.reset(),this.advance(0)}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.physicsEngine&&(this.physicsEngine.destroy(),this.physicsEngine=null),this.artboard.objects.forEach(I=>{var E,i,D,o;const C=I.width??((E=I.geometry)==null?void 0:E.width)??0,g=I.height??((i=I.geometry)==null?void 0:i.height)??0,Q=I.cornerRadius??I.corner_radius??((D=I.geometry)==null?void 0:D.corner_radius)??((o=I.geometry)==null?void 0:o.cornerRadius)??0;this.objectStates.set(I.id,{...I.transform,width:C,height:g,cornerRadius:Q,corner_radius:Q,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:I.transform.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)):[]})}),this.artboard.objects.some(I=>{var C;return(C=I.physics)==null?void 0:C.enabled})){this.physicsEngine=new DB;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 C;this.physicsEngine&&((C=this.artboard)==null||C.objects.forEach(g=>{var Q;if((Q=g.physics)!=null&&Q.enabled&&g.type==="Shape"){const E=this.objectStates.get(g.id);if(!E)return;const i=g.geometry.width||100,D=g.geometry.height||100;this.physicsEngine.createBody({id:g.id,type:g.geometry.type,x:E.x,y:E.y,width:i,height:D,rotation:E.rotation*(Math.PI/180),isStatic:g.physics.bodyType==="Static",mass:g.physics.mass,friction:g.physics.friction,restitution:g.physics.restitution,frictionAir:g.physics.frictionAir,density:g.physics.density,isSensor:g.physics.isSensor})}}))})}if(this.artboard.stateMachine&&(this.activeStateMachine=this.artboard.stateMachine,this.activeStateMachine.inputs.forEach(I=>{this.inputs.set(I.id,I.value.value);const C=this.inputNameMap.get(I.name)||[];C.push(I.id),this.inputNameMap.set(I.name,C)}),this.activeStateMachine.layers.forEach(I=>{const C=I.states.find(g=>g.id===I.entryStateId);C&&this.enterStates(I.name,[C.id])}),this.evaluateTransitions()),!this.artboard.stateMachine&&this.artboard.animations.length>0){const I=this.artboard.animations||[],C=I.find(g=>(g.name||"").toLowerCase()==="onload")||I[0];C&&(console.log(`[ExodeUI] Auto-starting fallback animation: ${C.name}`),this.layerStates.set("intro",{currentStateIds:["onLoad"],animations:[{animation:C,state:{loop:!0}}],time:0,duration:C.duration}))}this.updateAutoLayout(),this.loadFonts()}updateAutoLayout(){var g;if(!this.artboard)return;const A=new Map;this.artboard.objects.forEach(Q=>A.set(Q.id,Q));const I=.15,C=Q=>{Q.forEach(E=>{const i=this.objectStates.get(E.id);if(i){const D=Math.abs(i.x-E.x),o=Math.abs(i.y-E.y);D>20||o>20?(i.x+=(E.x-i.x)*I,i.y+=(E.y-i.y)*I):(i.x=E.x,i.y=E.y),E.width!==void 0&&(i.width=E.width),E.height!==void 0&&(i.height=E.height)}})};if((g=this.artboard.autoLayout)!=null&&g.enabled){const Q=this.artboard.objects.filter(i=>!i.parentId),E=SC(this.artboard,Q,i=>this.objectStates.get(i));C(E.childUpdates)}this.artboard.objects.forEach(Q=>{var E;if(Q.type==="Frame"&&((E=Q.autoLayout)!=null&&E.enabled)&&Q.children&&Q.children.length>0){const i=Q.children.map(s=>A.get(s)).filter(s=>!!s),D=this.objectStates.get(Q.id);if(!D)return;const o=SC(D,i,s=>this.objectStates.get(s));o.frameWidth!==void 0&&(D.width=o.frameWidth),o.frameHeight!==void 0&&(D.height=o.frameHeight),C(o.childUpdates)}})}loadFonts(){if(!this.artboard)return;const A=new Set;if(this.artboard.objects.forEach(E=>{E.geometry&&E.geometry.type==="Text"&&E.geometry.fontFamily&&A.add(E.geometry.fontFamily)}),this.artboard.animations.forEach(E=>{E.tracks.forEach(i=>{(i.property==="geometry.fontFamily"||i.property==="fontFamily")&&i.keyframes.forEach(D=>{D.value&&typeof D.value=="string"&&A.add(D.value)})})}),A.size===0)return;let I="";A.forEach(E=>{const i=E.replace(/ /g,"+");I+=`&family=${i}: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 C="exodeui-google-fonts",g="exodeui-fontshare-fonts";if(I.length>0){const E=`https://fonts.googleapis.com/css2?display=swap${I}`;let i=document.getElementById(C);i||(i=document.createElement("link"),i.id=C,i.rel="stylesheet",document.head.appendChild(i)),i.href!==E&&(i.href=E)}const Q=[];if(A.forEach(E=>{E.toLowerCase().includes("clash display")&&Q.push("clash-display@200,300,400,500,600,700")}),Q.length>0){const E=`https://api.fontshare.com/v2/css?f[]=${Q.join("&f[]=")}&display=swap`;let i=document.getElementById(g);i||(i=document.createElement("link"),i.id=g,i.rel="stylesheet",document.head.appendChild(i)),i.href!==E&&(i.href=E)}document.fonts&&document.fonts.ready&&document.fonts.ready.then(()=>{this.pretextCache.clear(),this.advance(0)})}enterStates(A,I){if(I.length===0)return;const C=this.layerStates.get(A);if(C&&C.currentStateIds.length===I.length&&I.every(i=>C.currentStateIds.includes(i))&&this.justFiredTriggers.size===0)return;const g=[];let Q=0;if(this.artboard&&this.activeStateMachine){const E=this.activeStateMachine.layers.find(i=>i.name===A);if(E)for(const i of I){const D=E.states.find(o=>o.id===i);if(D){let o=null;D.animationId&&(o=this.artboard.animations.find(s=>s.id===D.animationId)||null),o||(o=this.artboard.animations.find(s=>s.name===D.name||s.id===D.name||D.name==="Entry"&&s.name==="Rotate")||null),o&&(g.push({animation:o,state:D}),Q=Math.max(Q,o.duration))}}}this.layerStates.set(A,{currentStateIds:I,animations:g,time:0,duration:Q})}setInputBool(A,I){this.updateInput(A,I)}setInputNumber(A,I){this.updateInput(A,I)}fireTrigger(A){this.updateInput(A,!0)}setInputText(A,I){this.updateInput(A,I)}setInputNumberArray(A,I){this.updateInput(A,I)}setInputStringArray(A,I){this.updateInput(A,I)}updateInput(A,I){var E,i,D;let C;if(this.inputs.has(A)){const o=(E=this.activeStateMachine)==null?void 0:E.inputs.find(s=>s.id===A);o&&typeof o.value=="object"&&(C=o.value.type)}else{const o=this.inputNameMap.get(A);if(o&&o.length>0){const s=(i=this.activeStateMachine)==null?void 0:i.inputs.find(h=>h.id===o[0]);s&&typeof s.value=="object"&&(C=s.value.type)}}let g=I;C==="Trigger"&&(I===1?g=!0:I===0&&(g=!1)),this.inputs.has(A)&&this.setInternalInput(A,g);const Q=this.inputNameMap.get(A);Q&&Q.forEach(o=>this.setInternalInput(o,g)),C==="Trigger"&&g===!0&&(this.justFiredTriggers.add(A),Q&&Q.forEach(o=>this.justFiredTriggers.add(o))),Array.isArray(g)&&((D=this.artboard)==null||D.objects.forEach(o=>{if(o.inputId===A||o.name===A){const s=this.objectStates.get(o.id);s&&s.options&&(o.type==="ListView"||o.variant==="listview"?s.options.items=g:(o.type==="Dropdown"||o.variant==="dropdown")&&(s.options.optionsList=g))}})),this.evaluateTransitions()}evaluateTransitions(){this.activeStateMachine&&(this.activeStateMachine.layers.forEach(A=>{const I=this.layerStates.get(A.name);if(!I||I.currentStateIds.length===0)return;const C=[];let g=!1;for(const Q of I.currentStateIds){const E=A.states.find(D=>D.id===Q);if(!E)continue;let i=!1;for(const D of E.transitions)this.checkConditions(D.conditions)&&(C.push(D.targetStateId),i=!0,g=!0,D.conditions&&D.conditions.forEach(o=>{var h;const s=(h=this.activeStateMachine)==null?void 0:h.inputs.find(a=>a.id===o.inputId);if(s&&typeof s.value=="object"&&s.value.type==="Number"&&(this.setInternalInput(o.inputId,0),this.inputNameMap.has(s.name))){const a=this.inputNameMap.get(s.name);a==null||a.forEach(G=>this.setInternalInput(G,0))}}));i||C.push(Q)}if(!g){const Q=this.findGlobalTransition(A,I.currentStateIds);Q&&(C.length=0,C.push(Q.targetStateId),g=!0,Q.conditions&&Q.conditions.forEach(E=>{var D;const i=(D=this.activeStateMachine)==null?void 0:D.inputs.find(o=>o.id===E.inputId);if(i&&typeof i.value=="object"&&i.value.type==="Number"&&(this.setInternalInput(E.inputId,0),this.inputNameMap.has(i.name))){const o=this.inputNameMap.get(i.name);o==null||o.forEach(s=>this.setInternalInput(s,0))}}))}if(g){const Q=Array.from(new Set(C));this.enterStates(A.name,Q)}}),this.justFiredTriggers.size>0&&(this.justFiredTriggers.forEach(A=>{var C,g;this.setInternalInput(A,!1);const I=(C=this.activeStateMachine)==null?void 0:C.inputs.find(Q=>Q.id===A);I&&this.inputNameMap.has(I.name)&&((g=this.inputNameMap.get(I.name))==null||g.forEach(Q=>this.setInternalInput(Q,!1)))}),this.justFiredTriggers.clear()))}findGlobalTransition(A,I){for(const C of A.states)if(!(I.includes(C.id)&&this.justFiredTriggers.size===0)){for(const Q of C.transitions)if(!(I.includes(Q.targetStateId)&&this.justFiredTriggers.size===0)&&this.checkConditions(Q.conditions))return Q}return null}checkConditions(A){return!A||A.length===0?!0:A.every(I=>{const C=I.inputId,g=I.op,Q=I.value,E=this.evaluateLogicTree(C);if(E===void 0)return console.log(`[Engine] Condition Check Failed: Input ${C} is undefined`),!1;let i=!1;switch(g){case"Equal":i=E==Q;break;case"NotEqual":i=E!=Q;break;case"GreaterThan":i=E>Q;break;case"LessThan":i=E<Q;break;case"GreaterEqual":i=E>=Q;break;case"LessEqual":i=E<=Q;break;case"IsTrue":i=E===!0;break;case"IsFalse":i=E===!1;break;default:i=!1}return i||this.justFiredTriggers.has(C),i})}evaluateLogicTree(A,I,C=new Set){var E,i,D;if(C.has(A))return!1;C.add(A);const g=(i=(E=this.activeStateMachine)==null?void 0:E.logicNodes)==null?void 0:i.find(o=>o.id===A);if(g){const o=(s,h)=>{const a=g.inputs.find(G=>G.id===s);return a?a.sourceId?this.evaluateLogicTree(a.sourceId,a.sourceHandleId,C):a.value!==void 0?a.value:h:h};switch(g.op){case NI.AND:return o("a",!1)&&o("b",!1);case NI.OR:return o("a",!1)||o("b",!1);case NI.NOT:return!o("in",!1);case NI.XOR:return!!o("a",!1)!=!!o("b",!1);default:return 0}}let Q=this.inputs.get(A);if(this.justFiredTriggers.has(A)&&(Q=!0),I&&Q!==void 0){const o=(D=this.activeStateMachine)==null?void 0:D.inputs.find(s=>s.id===A);if(o&&o.value.type==="Number"&&typeof Q=="number"){const s=o.value.defaultValue??o.value.value;if(I==="source-greater")return Q>s;if(I==="source-less")return Q<s;if(I==="source-equal")return Q===s}if(I==="source-true")return Q===!0;if(I==="source-false")return Q===!1;if(I==="source-fire")return this.justFiredTriggers.has(A)}return Q!==void 0?Q:0}advance(A){this.artboard&&(this.currentTime+=A,this.frameCount++,this.physicsEngine&&(this.physicsEngine.step(A),this.artboard.objects.forEach(I=>{var C;if((C=I.physics)!=null&&C.enabled){const g=this.physicsEngine.getPosition(I.id),Q=this.physicsEngine.getRotation(I.id),E=this.objectStates.get(I.id);E&&g!==null&&Q!==null&&(E.x=g.x,E.y=g.y,E.rotation=Q*(180/Math.PI))}})),this.activeStateMachine&&(this.evaluateTransitions(),this.layerStates.forEach(I=>{I.animations.length>0&&(I.time+=A,this.frameCount%240===0&&this.debugLog(`Advancing Layer time: ${I.time.toFixed(3)} / ${I.duration.toFixed(3)}`),I.time>I.duration&&(I.animations.some(g=>{var Q;return((Q=g.state)==null?void 0:Q.loop)===!0})?I.time%=I.duration:I.time=I.duration),I.animations.forEach(C=>{this.applyAnimation(C.animation,I.time)}))})),this.solveConstraints(A),this.solveBehaviors(A),this.activeTriggers.forEach((I,C)=>{var g,Q,E,i,D,o,s;if(I.phase==="entry")I.time+=A,I.time>=I.animation.duration&&((E=(Q=(g=this.artboard)==null?void 0:g.objects.find(h=>h.id===C))==null?void 0:Q.triggers)==null||E.find(h=>h.id===I.triggerId),I.phase="hold",I.elapsedHold=0,I.time=I.animation.duration),this.applyAnimation(I.animation,I.time);else if(I.phase==="hold"){const h=(o=(D=(i=this.artboard)==null?void 0:i.objects.find(G=>G.id===C))==null?void 0:D.triggers)==null?void 0:o.find(G=>G.id===I.triggerId),a=(h==null?void 0:h.duration)||0;if(I.elapsedHold+=A*1e3,I.elapsedHold>=a)if(h!=null&&h.exitAnimationId){const G=(s=this.artboard)==null?void 0:s.animations.find(t=>t.id===h.exitAnimationId);G?(I.phase="exit",I.animation=G,I.time=0):this.activeTriggers.delete(C)}else this.activeTriggers.delete(C)}else I.phase==="exit"&&(I.time+=A,I.time>=I.animation.duration?this.activeTriggers.delete(C):this.applyAnimation(I.animation,I.time))}))}solveConstraints(A){this.artboard&&this.artboard.objects.forEach(I=>{if(!I.constraints||I.constraints.length===0)return;const C=this.objectStates.get(I.id);if(!C)return;const g=this.getGlobalTransform(I.id);if(I.constraints.forEach(Q=>{var i,D,o,s,h,a,G;const E=Q.strength??1;if(Q.type==="Translation"){const t=this.getGlobalTransform(Q.targetId);if(t){if(Q.useSpring){const S=this.objectVelocities.get(I.id)||{vx:0,vy:0},{x:y,y:F,vx:e,vy:M}=this.computeSpring(g.x,g.y,S.vx,S.vy,t.x,t.y,Q,A);Q.copyX&&(g.x=y),Q.copyY&&(g.y=F),this.objectVelocities.set(I.id,{vx:e,vy:M})}else Q.copyX&&(g.x=g.x+(t.x-g.x)*E),Q.copyY&&(g.y=g.y+(t.y-g.y)*E);(i=Q.limitX)!=null&&i.enabled&&(g.x=Math.max(Q.limitX.min,Math.min(Q.limitX.max,g.x))),(D=Q.limitY)!=null&&D.enabled&&(g.y=Math.max(Q.limitY.min,Math.min(Q.limitY.max,g.y)))}}else if(Q.type==="Rotation"){const t=this.getGlobalTransform(Q.targetId);if(t){let S=(t.rotation+(Q.offset||0)-g.rotation)%360;S>180&&(S-=360),S<-180&&(S+=360),g.rotation=g.rotation+S*E}}else if(Q.type==="Scale"){const t=this.getGlobalTransform(Q.targetId);t&&(Q.copyX&&(g.scale_x=g.scale_x+(t.scale_x-g.scale_x)*E),Q.copyY&&(g.scale_y=g.scale_y+(t.scale_y-g.scale_y)*E))}else if(Q.type==="Transform"){const t=this.getGlobalTransform(Q.targetId);if(t){g.x=g.x+(t.x-g.x)*E,g.y=g.y+(t.y-g.y)*E;let K=(t.rotation-g.rotation)%360;K>180&&(K-=360),K<-180&&(K+=360),g.rotation=g.rotation+K*E,g.scale_x=g.scale_x+(t.scale_x-g.scale_x)*E,g.scale_y=g.scale_y+(t.scale_y-g.scale_y)*E}}else if(Q.type==="FollowPointer"){const t=((o=this._lastPointerPos)==null?void 0:o.x)??g.x,K=((s=this._lastPointerPos)==null?void 0:s.y)??g.y;if(Q.useSpring){const y=this.objectVelocities.get(I.id)||{vx:0,vy:0},{x:F,y:e,vx:M,vy:n}=this.computeSpring(g.x,g.y,y.vx,y.vy,t,K,Q,A);g.x=F,g.y=e,this.objectVelocities.set(I.id,{vx:M,vy:n})}else g.x=g.x+(t-g.x)*E,g.y=g.y+(K-g.y)*E;(h=Q.limitX)!=null&&h.enabled&&(g.x=Math.max(Q.limitX.min,Math.min(Q.limitX.max,g.x))),(a=Q.limitY)!=null&&a.enabled&&(g.y=Math.max(Q.limitY.min,Math.min(Q.limitY.max,g.y)))}else if(Q.type==="Distance"){const t=this.getGlobalTransform(Q.targetId);if(t){const K=g.x-t.x,S=g.y-t.y,y=Math.sqrt(K*K+S*S),F=Q.distance||0;let e=y;switch(Q.mode){case"exact":e=F;break;case"minimum":e=Math.max(F,y);break;case"maximum":e=Math.min(F,y);break;case"clamped":e=Math.max(0,Math.min(F,y));break}if(y>0){const M=g.x===t.x&&g.y===t.y?1:e/y;g.x=g.x+(t.x+K*M-g.x)*E,g.y=g.y+(t.y+S*M-g.y)*E}}}else if(Q.type==="FollowPath"){const t=(G=this.artboard)==null?void 0:G.objects.find(K=>K.id===Q.targetId);if(t){const K=this.getGlobalTransform(t.id);if(K){const S=(Q.distance||0)/100,y=K.width||t.geometry.width||0,F=K.height||t.geometry.height||0,e=this.getPointOnPath(t.geometry,y,F,S),M=K.rotation*Math.PI/180,n=Math.cos(M),X=Math.sin(M),Z=e.x*K.scale_x*n-e.y*K.scale_y*X,H=e.x*K.scale_x*X+e.y*K.scale_y*n,QA=K.x+Z+(Q.offsetX||0),L=K.y+H+(Q.offsetY||0);if(g.x=g.x+(QA-g.x)*E,g.y=g.y+(L-g.y)*E,Q.orient){let T=(e.angle*180/Math.PI+K.rotation+(Q.offsetRotation||0)-g.rotation)%360;T>180&&(T-=360),T<-180&&(T+=360),g.rotation=g.rotation+T*E}}}}else if(Q.type==="IK"){const t=this.getGlobalTransform(Q.targetId);t&&this.solveIK(I,t,Q.boneCount||2,E)}}),I.constraints.some(Q=>Q.type!=="IK")){const Q=this.globalToLocal(I.parentId,g);C.x=Q.x,C.y=Q.y,C.rotation=Q.rotation,C.scale_x=Q.scale_x,C.scale_y=Q.scale_y}})}getGlobalTransform(A){var s;const I=this.objectStates.get(A);if(!I)return{x:0,y:0,rotation:0,scale_x:1,scale_y:1};const C=(s=this.artboard)==null?void 0:s.objects.find(h=>h.id===A);if(!C||!C.parentId)return{x:I.x,y:I.y,rotation:I.rotation,scale_x:I.scale_x??1,scale_y:I.scale_y??1};const g=this.getGlobalTransform(C.parentId),Q=g.rotation*Math.PI/180,E=Math.cos(Q),i=Math.sin(Q),D=g.x+(I.x*g.scale_x*E-I.y*g.scale_y*i),o=g.y+(I.x*g.scale_x*i+I.y*g.scale_y*E);return{x:D,y:o,rotation:g.rotation+I.rotation,scale_x:g.scale_x*(I.scale_x??1),scale_y:g.scale_y*(I.scale_y??1)}}globalToLocal(A,I){if(!A)return I;const C=this.getGlobalTransform(A),g=C.scale_x===0?0:1/C.scale_x,Q=C.scale_y===0?0:1/C.scale_y,E=-C.rotation*Math.PI/180,i=Math.cos(E),D=Math.sin(E),o=I.x-C.x,s=I.y-C.y,h=(o*i-s*D)*g,a=(o*D+s*i)*Q;return{x:h,y:a,rotation:I.rotation-C.rotation,scale_x:I.scale_x/(C.scale_x||1),scale_y:I.scale_y/(C.scale_y||1)}}solveIK(A,I,C,g){var o;const Q=[];let E=A.id;for(let s=0;s<C&&E;s++){const h=(o=this.artboard)==null?void 0:o.objects.find(a=>a.id===E);if(!h)break;Q.push({id:E,local:this.objectStates.get(E),global:this.getGlobalTransform(E)}),E=h.parentId}if(Q.length<2)return;const i=Q.reverse(),D=5;for(let s=0;s<D;s++){const h=this.getGlobalTransform(A.id);for(let a=i.length-2;a>=0;a--){const G=i[a],t=this.getGlobalTransform(G.id),K=h.x-t.x,S=h.y-t.y,y=I.x-t.x,F=I.y-t.y,e=Math.sqrt(K*K+S*S),M=Math.sqrt(y*y+F*F);if(e>.001&&M>.001){const n=Math.atan2(S,K);let Z=(Math.atan2(F,y)-n)*180/Math.PI;Z*=g;const H=this.objectStates.get(G.id);H&&(H.rotation+=Z)}}}}computeSpring(A,I,C,g,Q,E,i,D){const o=i.stiffness??100,s=i.damping??10,h=i.mass??1,a=-o*(A-Q),G=-o*(I-E),t=-s*C,K=-s*g,S=(a+t)/h,y=(G+K)/h,F=C+S*D,e=g+y*D,M=A+F*D,n=I+e*D;return{x:M,y:n,vx:F,vy:e}}handlePointerInput(A,I,C,g,Q){if(!this.artboard)return;const E=this.calculateTransform(g,Q,this.artboard.width,this.artboard.height,this.layout.fit,this.layout.alignment),i=(I-E.tx)/E.scaleX-this.artboard.width/2,D=(C-E.ty)/E.scaleY-this.artboard.height/2;this._prevPointerPos=this._lastPointerPos,this._lastPointerPos={x:i,y:D},this.updateInput("mouseX",i),this.updateInput("mouseY",D),this.handlePointerEvent(A,i,D)}handleScroll(A,I){this.scrollOffset={x:A,y:I}}handlePointerEvent(A,I,C){var D,o,s,h,a;if(!this.artboard)return;let g=null;const Q=(G,t)=>{var M;let K=t;t==="click"?K="onClick":t==="down"?K="onPointerDown":t==="up"?K="onPointerUp":t==="blur"&&(K="onPointerLeave");const S=new Set([K]);t==="move"&&S.add("onPointerEnter").add("hover").add("onPointerLeave").add("blur"),K==="onClick"&&S.add("click"),K==="onPointerDown"&&S.add("pointerDown"),K==="onPointerUp"&&S.add("pointerUp");const y=["button","toggle","toggle_button","dropdown","listview","inputbox","slider"];return!!(G.type==="Component"&&y.includes(G.variant)||y.includes((M=G.type)==null?void 0:M.toLowerCase())||(G.interactions||[]).some(n=>S.has(n.event))||(G.triggers||[]).some(n=>S.has(n.eventType)))};let E=null;for(let G=this.artboard.objects.length-1;G>=0;G--){const t=this.artboard.objects[G],K=this.objectStates.get(t.id);if(K&&K.visible!==!1&&K.opacity>0&&this.hitTest(t,I,C)&&(E||(E=t),Q(t,A))){g=t;break}}!g&&E&&(g=E),this.pointerHistory.push({x:I,y:C,time:Date.now()}),this.pointerHistory.length>this.MAX_HISTORY&&this.pointerHistory.shift();const i=(g==null?void 0:g.id)||null;if(A==="move"){if(this.draggingSliderId){const G=this.artboard.objects.find(t=>t.id===this.draggingSliderId);G&&this.updateSliderValueFromPointer(G,I,C);return}if(this.draggingListViewId){const G=this.artboard.objects.find(t=>t.id===this.draggingListViewId);G&&this.updateListViewScrollFromPointer(G);return}g&&g.type==="Component"&&g.variant==="listview"&&this.updateListViewHoverFromPointer(g,I,C),i!==this.lastHoveredObjectId&&(console.log(`[Engine] HOVER CHANGE: ${this.lastHoveredObjectId} -> ${i}`),this.lastHoveredObjectId&&this.fireEventForObject(this.lastHoveredObjectId,"onPointerLeave"),i&&this.fireEventForObject(i,"onPointerEnter"),this.lastHoveredObjectId=i);return}if((A==="up"||A==="blur")&&(this.draggingSliderId=null,this.draggingListViewId=null,this.draggingBehaviors.clear()),A==="down"&&g&&((D=g.behaviors)!=null&&D.some(G=>G.type===W.Draggable))&&this.draggingBehaviors.add(i),this.activeDropdownId&&A==="down"){const G=this.artboard.objects.find(t=>t.id===this.activeDropdownId);if(G&&(G.type==="Dropdown"||G.variant==="dropdown")){const t=this.objectStates.get(G.id),K=(t==null?void 0:t.options)||G.options||{},S=G.geometry||{},y=S.width??G.width??200,F=S.height??G.height??40,e=K.optionsList||[],M=K.itemHeight||32,n=K.listPadding??4,X=e.length*M+n*2,Z=this.getWorldTransform(G.id),H=y*Math.abs(Z.scaleX),QA=F*Math.abs(Z.scaleY),L=Z.y+QA/2+4,U=Math.abs(I-Z.x)<=H/2,T=C>=L&&C<=L+X*Math.abs(Z.scaleY);if(U&&T){const AA=Math.abs(Z.scaleY),IA=C-(L+n*AA),b=Math.floor(IA/(M*AA));if(b>=0&&b<e.length){const P=e[b];K.selectedOption=P,K.isOpen=!1,this.activeDropdownId=null,G.inputId&&this.setInternalInput(G.inputId,P),this.onComponentChange&&this.onComponentChange({objectId:G.id,componentName:G.name,variant:"dropdown",property:"selectedOption",value:P})}return}else i!==this.activeDropdownId&&(K.isOpen=!1,this.activeDropdownId=null)}}if(g){let G=g,t=g;for(;t&&t.parentId;){const S=this.artboard.objects.find(y=>y.id===t.parentId);if(S&&S.type==="Component"){G=S;break}t=S}let K=A;if(A==="click"?K="onClick":A==="down"?K="onPointerDown":A==="up"?K="onPointerUp":A==="blur"&&(K="onPointerLeave"),this.fireEventForObject(g.id,K),G!==g&&this.fireEventForObject(G.id,K),G.type==="Component"&&G.variant==="toggle_button"&&A==="down"){const S=this.objectStates.get(G.id),y=(S==null?void 0:S.options)||G.options||{};y.checked=!y.checked,G.inputId&&this.setInternalInput(G.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:G.id,componentName:G.name,variant:"toggle_button",property:"checked",value:y.checked})}if(G.type==="Component"&&G.variant==="toggle"&&A==="down"){const S=this.objectStates.get(G.id),y=(S==null?void 0:S.options)||G.options||{};y.checked=!y.checked,G.inputId&&this.setInternalInput(G.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:G.id,componentName:G.name,variant:"toggle",property:"checked",value:y.checked}),this.onToggle&&this.onToggle(G.name,y.checked)}if(G.type==="Component"&&G.variant==="dropdown"&&A==="down"){const S=this.objectStates.get(G.id),y=(S==null?void 0:S.options)||G.options||{},F=!y.isOpen;if(F&&this.activeDropdownId&&this.activeDropdownId!==G.id){const e=this.artboard.objects.find(M=>M.id===this.activeDropdownId);e&&e.options&&(e.options.isOpen=!1)}y.isOpen=F,this.activeDropdownId=F?G.id:null}if(g.type==="Component"&&g.variant==="button"&&A==="down"&&this.onComponentChange&&this.onComponentChange({objectId:g.id,componentName:g.name,variant:"button",property:"click",value:!0}),g.type==="Component"&&g.variant==="listview"&&A==="down"){this.draggingListViewId=g.id;const S=this.getListViewItemIndexAtPointer(g,I,C);if(S!==null){const y=g.options||{};y.activeItemIndex=S;const F=this.objectStates.get(g.id);F&&F.options&&(F.options.activeItemIndex=S);const e=(y.items||[])[S],M=typeof e=="string"?e:e.label||e.value||S;F&&F.options&&(F.options.selectedValue=M),g.inputId&&this.setInternalInput(g.inputId,M),this.onComponentChange&&(this.onComponentChange({objectId:g.id,componentName:g.name,variant:"listview",property:"activeItemIndex",value:S}),this.onComponentChange({objectId:g.id,componentName:g.name,variant:"listview",property:"selected",value:M}))}}if(g.type==="Component"&&g.variant==="slider"&&A==="down"&&(this.draggingSliderId=g.id,this.updateSliderValueFromPointer(g,I,C)),A==="click"){const S=(o=this.artboard)==null?void 0:o.objects.find(F=>F.id===g.id),y=this.focusedId;if((S==null?void 0:S.type)==="Component"&&S.variant==="inputbox"){if(this.focusedId=g.id,console.log(`[Engine] Focus set to: ${g.id}`),y!==this.focusedId){if(y){const F=(s=this.artboard)==null?void 0:s.objects.find(e=>e.id===y);F&&this.onInputBlur&&this.onInputBlur(F.name)}this.onInputFocus&&this.onInputFocus(S.name)}}else if(this.focusedId=null,y){const F=(h=this.artboard)==null?void 0:h.objects.find(e=>e.id===y);F&&this.onInputBlur&&this.onInputBlur(F.name)}}}else if(A==="click"){const G=this.focusedId;if(this.focusedId=null,G){const t=(a=this.artboard)==null?void 0:a.objects.find(K=>K.id===G);t&&this.onInputBlur&&this.onInputBlur(t.name)}}}handleKeyDown(A){if(!this.artboard||!this.focusedId)return;const I=this.artboard.objects.find(E=>E.id===this.focusedId);if(!I||I.type!=="Component"||I.variant!=="inputbox")return;const C=I.options||{};let g=C.text||"";if(A.key==="Backspace")g=g.slice(0,-1);else if(A.key==="Enter")if(C.multiline)g+=`
|
|
6
|
-
`;else{this.focusedId=null;return}else if(A.key.length===1)g+=A.key;else return;C.text=g;const Q=I.geometry;Q.textInputId&&this.updateInput(Q.textInputId,g),this.onComponentChange&&this.onComponentChange({objectId:I.id,componentName:I.name,variant:"inputbox",property:"text",value:g}),this.onInputChange&&this.onInputChange(I.name,g),this.onInputUpdate&&this.onInputUpdate(this.focusedId,g)}fireEventForObject(A,I){if(!this.artboard)return;const C=this.artboard.objects.find(o=>o.id===A);if(!C)return;console.log(`[Engine] Firing event ${I} on ${C.name}`);const g=new Set([I]);I==="onPointerEnter"&&g.add("hover"),I==="onPointerLeave"&&g.add("blur"),I==="onPointerDown"&&g.add("pointerDown"),I==="onPointerUp"&&g.add("pointerUp");const E=(C.interactions||[]).find(o=>g.has(o.event));if(E)if(console.log(`[Engine] Interaction matched: ${I} (as ${E.event}) -> ${E.targetInputId}`),E.action==="setInput"){let o=E.value;o==="toggle"&&(o=!this.inputs.get(E.targetInputId)),this.updateInput(E.targetInputId,o)}else E.action==="fireTrigger"&&this.updateInput(E.targetInputId,!0);const D=(C.triggers||[]).find(o=>g.has(o.eventType));if(D&&D.entryAnimationId){console.log(`[Engine] Trigger matched: ${I} (as ${D.eventType}) -> Animation ${D.entryAnimationId}`);const o=this.artboard.animations.find(s=>s.id===D.entryAnimationId);o&&(this.activeTriggers.set(C.id,{triggerId:D.id,animation:o,time:0,phase:"entry",elapsedHold:0}),this.onTrigger&&this.onTrigger(D.name,o.name))}}getWorldTransform(A){var a;const I=this.objectStates.get(A);if(!I)return{x:0,y:0,scaleX:1,scaleY:1,rotation:0};const C=(a=this.artboard)==null?void 0:a.objects.find(G=>G.id===A);if(!C||!C.parentId)return{x:I.x,y:I.y,scaleX:I.scale_x??1,scaleY:I.scale_y??1,rotation:I.rotation??0};const g=this.getWorldTransform(C.parentId),Q=g.rotation*(Math.PI/180),E=Math.cos(Q),i=Math.sin(Q),D=I.x*g.scaleX,o=I.y*g.scaleY,s=g.x+(D*E-o*i),h=g.y+(D*i+o*E);return{x:s,y:h,scaleX:(I.scale_x??1)*g.scaleX,scaleY:(I.scale_y??1)*g.scaleY,rotation:g.rotation+(I.rotation??0)}}hitTest(A,I,C){var e,M;if(!this.objectStates.get(A.id))return!1;const Q=((e=A.geometry)==null?void 0:e.width)??A.width??100,E=((M=A.geometry)==null?void 0:M.height)??A.height??100,i=this.getWorldTransform(A.id),D=I-i.x,o=C-i.y,s=-i.rotation*(Math.PI/180),h=Math.cos(s),a=Math.sin(s),G=D*h-o*a,t=D*a+o*h,K=i.scaleX,S=i.scaleY,y=Q*Math.abs(K),F=E*Math.abs(S);return Math.abs(G)<=y/2&&Math.abs(t)<=F/2}updateSliderValueFromPointer(A,I,C){var Z;const g=this.objectStates.get(A.id);if(!g)return;const Q=A.options||{},E=((Z=A.geometry)==null?void 0:Z.width)??A.width??200,i=this.getWorldTransform(A.id),D=I-i.x,o=C-i.y,s=-i.rotation*(Math.PI/180),h=Math.cos(s),a=Math.sin(s),G=D*h-o*a,t=Q.thumbWidth??16,K=E-t;let y=(G+K/2)/K;y=Math.max(0,Math.min(1,y));const F=Q.min??0,e=Q.max??100,M=Q.step||1;let n=F+y*(e-F);M>0&&(n=Math.round(n/M)*M),n=Math.max(F,Math.min(e,n));const X=g.options||{};X.value!==n&&(g.options={...X,value:n},A.inputId&&this.setInternalInput(A.inputId,n),this.onComponentChange&&this.onComponentChange({objectId:A.id,componentName:A.name,variant:"slider",property:"value",value:n}))}applyAnimation(A,I){A.tracks.forEach(C=>{var o,s,h;const g=(o=this.artboard)==null?void 0:o.objects.find(a=>a.id===C.object_id),Q=((s=g==null?void 0:g.physics)==null?void 0:s.enabled)&&g.physics.bodyType!=="Static";let E=C.property;if(E.startsWith("transform."))E=E.replace("transform.","");else if(E.startsWith("geometry.")){const a=E.replace("geometry.","");["width","height","corner_radius","cornerRadius"].includes(a)&&(E=a)}if(Q&&["x","y","rotation","opacity"].includes(E))return;const i=this.objectStates.get(C.object_id);if(!i){this.frameCount%600===0&&this.debugLog(`Skipping track: Object ${C.object_id} not found in state`);return}const D=this.interpolate(C.keyframes,I);if(this.frameCount%480===0){const a=(g==null?void 0:g.name)||C.object_id;this.debugLog(`Applying ${E} = ${typeof D=="object"?"OBJ":D} to ${a}`)}if(E.includes(".")){const a=(E||"").split(".");let G=i;for(let t=0;t<a.length-1;t++){if(typeof G[a[t]]!="object"||G[a[t]]===null){let K=g;for(let S=0;S<=t;S++)K=K?K[a[S]]:null;G[a[t]]=K?JSON.parse(JSON.stringify(K)):{}}G=G[a[t]]}G[a[a.length-1]]=D}else i[E]=D;if(this.physicsEngine&&((h=g==null?void 0:g.physics)!=null&&h.enabled)&&g.physics.bodyType==="Static")if(E==="x"){const a=this.physicsEngine.getPosition(C.object_id);a&&this.physicsEngine.setPosition(C.object_id,D,a.y)}else if(E==="y"){const a=this.physicsEngine.getPosition(C.object_id);a&&this.physicsEngine.setPosition(C.object_id,a.x,D)}else E==="rotation"&&this.physicsEngine.setRotation(C.object_id,D*(Math.PI/180))})}interpolate(A,I){if(A.length===0)return 0;let C=A[0],g=A[A.length-1];if(I<=C.time)return C.value;if(I>=g.time)return g.value;for(let i=0;i<A.length-1;i++)if(I>=A[i].time&&I<A[i+1].time){C=A[i],g=A[i+1];break}if(Math.abs(C.time-I)<.005)return C.value;if(Math.abs(g.time-I)<.005)return g.value;const Q=g.time-C.time;let E=(I-C.time)/Q;if(C.easing&&(E=$E(C.easing)(E)),typeof C.value=="string"){if(C.value.startsWith("#"))return this.interpolateColor(C.value,g.value,E);const i=parseFloat(C.value),D=parseFloat(g.value);return!isNaN(i)&&!isNaN(D)?Math.round(i+(D-i)*E).toString():C.value}return Array.isArray(C.value)&&Array.isArray(g.value)?C.value.length===g.value.length?C.value.map((i,D)=>{const o=g.value[D];return typeof i=="number"&&typeof o=="number"?i+(o-i)*E:E<.5?i:o}):E<.5?C.value:g.value:typeof C.value=="object"&&typeof g.value=="object"&&C.value!==null&&g.value!==null?C.value.width!==void 0&&C.value.color!==void 0?this.interpolateStroke(C.value,g.value,E):C.value.type&&g.value.type?this.interpolateFill(C.value,g.value,E):E<.5?C.value:g.value:typeof C.value=="number"&&typeof g.value=="number"?C.value+(g.value-C.value)*E:E<.5?C.value:g.value}interpolateColor(A,I,C){var t,K;const g=((K=(t=this.artboard)==null?void 0:t.tokens)==null?void 0:K.colors)||{},Q=g[A]||A,E=g[I]||I,i=S=>{if(!S)return{r:0,g:0,b:0};const y=S.startsWith("#")?S.replace("#",""):"000000";return y.length===3?{r:parseInt(y[0]+y[0],16),g:parseInt(y[1]+y[1],16),b:parseInt(y[2]+y[2],16)}:{r:parseInt(y.substring(0,2),16),g:parseInt(y.substring(2,4),16),b:parseInt(y.substring(4,6),16)}},D=i(Q),o=i(E),s=Math.round(D.r+(o.r-D.r)*C),h=Math.round(D.g+(o.g-D.g)*C),a=Math.round(D.b+(o.b-D.b)*C),G=S=>{const y=Math.max(0,Math.min(255,S)).toString(16);return y.length===1?"0"+y:y};return`#${G(s)}${G(h)}${G(a)}`}interpolateStops(A,I,C){return!A||!I||A.length!==I.length?C<.5?A:I:A.map((g,Q)=>{const E=I[Q];return{offset:g.offset+(E.offset-g.offset)*C,color:this.interpolateColor(g.color,E.color,C),opacity:(g.opacity??1)+((E.opacity??1)-(g.opacity??1))*C}})}interpolateFill(A,I,C){if(!A||!I||A.type!==I.type)return C<.5?A:I;const g={...A,opacity:(A.opacity??1)+((I.opacity??1)-(A.opacity??1))*C};return A.type==="Solid"?g.color=this.interpolateColor(A.color,I.color,C):(A.type==="LinearGradient"||A.type==="RadialGradient")&&(A.start&&I.start&&(g.start=[A.start[0]+(I.start[0]-A.start[0])*C,A.start[1]+(I.start[1]-A.start[1])*C]),A.end&&I.end&&(g.end=[A.end[0]+(I.end[0]-A.end[0])*C,A.end[1]+(I.end[1]-A.end[1])*C]),A.center&&I.center&&(g.center=[A.center[0]+(I.center[0]-A.center[0])*C,A.center[1]+(I.center[1]-A.center[1])*C]),A.radius!==void 0&&I.radius!==void 0&&(g.radius=A.radius+(I.radius-A.radius)*C),g.stops=this.interpolateStops(A.stops,I.stops,C)),g}interpolateStroke(A,I,C){if(!A||!I)return C<.5?A:I;const g={...A};return g.width=(A.width??0)+((I.width??0)-(A.width??0))*C,g.opacity=(A.opacity??1)+((I.opacity??1)-(A.opacity??1))*C,A.fill&&I.fill?g.fill=this.interpolateFill(A.fill,I.fill,C):A.color&&I.color&&A.color.startsWith("#")&&I.color.startsWith("#")&&(g.color=this.interpolateColor(A.color,I.color,C)),g.trimStart=(A.trimStart??0)+((I.trimStart??0)-(A.trimStart??0))*C,g.trimEnd=(A.trimEnd??1)+((I.trimEnd??1)-(A.trimEnd??1))*C,g.trimOffset=(A.trimOffset??0)+((I.trimOffset??0)-(A.trimOffset??0))*C,g.dashOffset=(A.dashOffset??0)+((I.dashOffset??0)-(A.dashOffset??0))*C,g}render(A,I,C){if(this.canvasWidth=I,this.canvasHeight=C,!this.artboard)return;A.clearRect(0,0,I,C);const g=this.artboard.width,Q=this.artboard.height,E=this.calculateTransform(I,C,g,Q,this.layout.fit,this.layout.alignment);if(A.save(),A.translate(Math.round(E.tx),Math.round(E.ty)),A.scale(E.scaleX,E.scaleY),A.translate(g/2,Q/2),this.rootTransform=A.getTransform(),this.artboard.backgroundVisible!==!1&&(A.fillStyle=this.artboard.backgroundColor||"#000000",A.fillRect(-g/2,-Q/2,g,Q)),this.artboard.backgroundImage){const D=this.artboard.backgroundImage;let o=this.imageCache.get(D);if(o||(o=new Image,o.src=D,this.imageCache.set(D,o)),o.complete&&o.naturalWidth>0){A.save(),A.globalAlpha=this.normalizeOpacity(this.artboard.backgroundOpacity??100);const s=o.naturalWidth/o.naturalHeight,h=g/Q;let a,G,t,K;h>s?(a=g,G=g/s):(G=Q,a=Q*s),t=-a/2,K=-G/2,A.drawImage(o,t,K,a,G),A.restore()}}A.beginPath(),A.rect(-g/2,-Q/2,g,Q),A.clip();const i=new Map;this.artboard.objects.forEach(D=>i.set(D.id,D)),this.artboard.objects.forEach(D=>{D.parentId||this.renderObject(A,D,i)}),A.restore()}calculateTransform(A,I,C,g,Q,E){let i=1,D=1,o=1;const s=C/g,h=A/I;switch(Q){case"Contain":h>s?o=I/g:o=A/C,i=D=o;break;case"Cover":h>s?o=A/C:o=I/g,i=D=o;break;case"Fill":i=A/C,D=I/g;break;case"FitWidth":o=A/C,i=D=o;break;case"FitHeight":o=I/g,i=D=o;break;case"None":i=D=1;break;case"ScaleDown":o=Math.min(A/C,I/g),o>1&&(o=1),i=D=o;break;default:i=D=1;break}const a=C*i,G=g*D;let t=0,K=0;return E.includes("Left")?t=0:E.includes("Right")?t=A-a:t=(A-a)/2,E.includes("Top")?K=0:E.includes("Bottom")?K=I-G:K=(I-G)/2,{scaleX:i,scaleY:D,tx:t,ty:K}}mapFontWeight(A){const I=A.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":A}getFontLeadingFactor(A){const I=(A||"Inter").trim();for(const[C,g]of Object.entries(this.fontLeadingFactors))if(I.toLowerCase()===C.toLowerCase())return g;return .5}renderObject(A,I,C){var u,q,l,r,z,d,_,hA,SA,FA,NA;const g=this.objectStates.get(I.id);if(!g){console.warn("No state for object:",I.id);return}A.roundRect||(A.roundRect=(m,O,Y,R,x)=>(this.drawRoundRect(A,m,O,Y,R,x),A));const Q=g.geometry?this.deepMerge(I.geometry,g.geometry):I.geometry,E=g.style?this.deepMerge(I.style,g.style):I.style;let i=(Q==null?void 0:Q.width)||((u=I.geometry)==null?void 0:u.width)||I.width||0,D=(Q==null?void 0:Q.height)||((q=I.geometry)==null?void 0:q.height)||I.height||0;if((i===0||D===0)&&(Q!=null&&Q.points)&&Array.isArray(Q.points)&&Q.points.length>0){let m=1/0,O=-1/0,Y=1/0,R=-1/0;Q.points.forEach(x=>{m=Math.min(m,x.x),O=Math.max(O,x.x),Y=Math.min(Y,x.y),R=Math.max(R,x.y)}),i===0&&(i=O-m),D===0&&(D=R-Y)}const o=m=>{if(m)return m.corner_radius??m.cornerRadius},s=o(g)??o(E)??o(Q)??o(I.style)??o(I.geometry)??0,h={...Q,width:i,height:D};if(delete h.cornerRadius,h.corner_radius=s,g.visible===!1)return;const a=g.x,G=g.y;A.save();const t=[],K=E.blur||((l=I.style)==null?void 0:l.blur);K&&K.amount>0&&t.push(`blur(${K.amount}px)`);const S=((r=Q==null?void 0:Q.type)==null?void 0:r.toLowerCase().includes("image"))||((z=I.type)==null?void 0:z.toLowerCase().includes("image")),y=E.adjustments&&Object.keys(E.adjustments).length>0?E.adjustments:null,F=Q!=null&&Q.adjustments&&Object.keys(Q.adjustments).length>0?Q.adjustments:null,e=S?F||y:y||F,M=S&&!e?{exposure:0,contrast:0,saturation:100,temperature:0,tint:0,highlights:0,shadows:0,blur:0,negative:0,hue:0}:e;if(g&&M&&(g.geometry=g.geometry||{},g.geometry.adjustments={...M}),M){const m=(M.exposure||0)/100,O=M.contrast||0,Y=1+(M.saturation||0)/100,R=(M.temperature||0)/200,x=(M.tint||0)/200,j=(M.highlights||0)/500,GA=(M.shadows||0)/500;let CA="",wA="SourceGraphic";if(m!==0&&(CA+=`
|
|
6
|
+
`;else{this.focusedId=null;return}else if(A.key.length===1)g+=A.key;else return;C.text=g;const Q=I.geometry;Q.textInputId&&this.updateInput(Q.textInputId,g),this.onComponentChange&&this.onComponentChange({objectId:I.id,componentName:I.name,variant:"inputbox",property:"text",value:g}),this.onInputChange&&this.onInputChange(I.name,g),this.onInputUpdate&&this.onInputUpdate(this.focusedId,g)}fireEventForObject(A,I){if(!this.artboard)return;const C=this.artboard.objects.find(o=>o.id===A);if(!C)return;console.log(`[Engine] Firing event ${I} on ${C.name}`);const g=new Set([I]);I==="onPointerEnter"&&g.add("hover"),I==="onPointerLeave"&&g.add("blur"),I==="onPointerDown"&&g.add("pointerDown"),I==="onPointerUp"&&g.add("pointerUp");const E=(C.interactions||[]).find(o=>g.has(o.event));if(E)if(console.log(`[Engine] Interaction matched: ${I} (as ${E.event}) -> ${E.targetInputId}`),E.action==="setInput"){let o=E.value;o==="toggle"&&(o=!this.inputs.get(E.targetInputId)),this.updateInput(E.targetInputId,o)}else E.action==="fireTrigger"&&this.updateInput(E.targetInputId,!0);const D=(C.triggers||[]).find(o=>g.has(o.eventType));if(D&&D.entryAnimationId){console.log(`[Engine] Trigger matched: ${I} (as ${D.eventType}) -> Animation ${D.entryAnimationId}`);const o=this.artboard.animations.find(s=>s.id===D.entryAnimationId);o&&(this.activeTriggers.set(C.id,{triggerId:D.id,animation:o,time:0,phase:"entry",elapsedHold:0}),this.onTrigger&&this.onTrigger(D.name,o.name))}}getWorldTransform(A){var a;const I=this.objectStates.get(A);if(!I)return{x:0,y:0,scaleX:1,scaleY:1,rotation:0};const C=(a=this.artboard)==null?void 0:a.objects.find(G=>G.id===A);if(!C||!C.parentId)return{x:I.x,y:I.y,scaleX:I.scale_x??1,scaleY:I.scale_y??1,rotation:I.rotation??0};const g=this.getWorldTransform(C.parentId),Q=g.rotation*(Math.PI/180),E=Math.cos(Q),i=Math.sin(Q),D=I.x*g.scaleX,o=I.y*g.scaleY,s=g.x+(D*E-o*i),h=g.y+(D*i+o*E);return{x:s,y:h,scaleX:(I.scale_x??1)*g.scaleX,scaleY:(I.scale_y??1)*g.scaleY,rotation:g.rotation+(I.rotation??0)}}hitTest(A,I,C){var e,M;if(!this.objectStates.get(A.id))return!1;const Q=((e=A.geometry)==null?void 0:e.width)??A.width??100,E=((M=A.geometry)==null?void 0:M.height)??A.height??100,i=this.getWorldTransform(A.id),D=I-i.x,o=C-i.y,s=-i.rotation*(Math.PI/180),h=Math.cos(s),a=Math.sin(s),G=D*h-o*a,t=D*a+o*h,K=i.scaleX,S=i.scaleY,y=Q*Math.abs(K),F=E*Math.abs(S);return Math.abs(G)<=y/2&&Math.abs(t)<=F/2}updateSliderValueFromPointer(A,I,C){var Z;const g=this.objectStates.get(A.id);if(!g)return;const Q=A.options||{},E=((Z=A.geometry)==null?void 0:Z.width)??A.width??200,i=this.getWorldTransform(A.id),D=I-i.x,o=C-i.y,s=-i.rotation*(Math.PI/180),h=Math.cos(s),a=Math.sin(s),G=D*h-o*a,t=Q.thumbWidth??16,K=E-t;let y=(G+K/2)/K;y=Math.max(0,Math.min(1,y));const F=Q.min??0,e=Q.max??100,M=Q.step||1;let n=F+y*(e-F);M>0&&(n=Math.round(n/M)*M),n=Math.max(F,Math.min(e,n));const X=g.options||{};X.value!==n&&(g.options={...X,value:n},A.inputId&&this.setInternalInput(A.inputId,n),this.onComponentChange&&this.onComponentChange({objectId:A.id,componentName:A.name,variant:"slider",property:"value",value:n}))}applyAnimation(A,I){A.tracks.forEach(C=>{var o,s,h;const g=(o=this.artboard)==null?void 0:o.objects.find(a=>a.id===C.object_id),Q=((s=g==null?void 0:g.physics)==null?void 0:s.enabled)&&g.physics.bodyType!=="Static";let E=C.property;if(E.startsWith("transform."))E=E.replace("transform.","");else if(E.startsWith("geometry.")){const a=E.replace("geometry.","");["width","height","corner_radius","cornerRadius"].includes(a)&&(E=a)}if(Q&&["x","y","rotation","opacity"].includes(E))return;const i=this.objectStates.get(C.object_id);if(!i){this.frameCount%600===0&&this.debugLog(`Skipping track: Object ${C.object_id} not found in state`);return}const D=this.interpolate(C.keyframes,I);if(D!==void 0){if(this.frameCount%480===0){const a=(g==null?void 0:g.name)||C.object_id;this.debugLog(`Applying ${E} = ${typeof D=="object"?"OBJ":D} to ${a}`)}if(E.includes(".")){const a=(E||"").split(".");let G=i;for(let t=0;t<a.length-1;t++){if(typeof G[a[t]]!="object"||G[a[t]]===null){let K=g;for(let S=0;S<=t;S++)K=K?K[a[S]]:null;G[a[t]]=K?JSON.parse(JSON.stringify(K)):{}}G=G[a[t]]}G[a[a.length-1]]=D}else i[E]=D;if(this.physicsEngine&&((h=g==null?void 0:g.physics)!=null&&h.enabled)&&g.physics.bodyType==="Static")if(E==="x"){const a=this.physicsEngine.getPosition(C.object_id);a&&this.physicsEngine.setPosition(C.object_id,D,a.y)}else if(E==="y"){const a=this.physicsEngine.getPosition(C.object_id);a&&this.physicsEngine.setPosition(C.object_id,a.x,D)}else E==="rotation"&&this.physicsEngine.setRotation(C.object_id,D*(Math.PI/180))}})}interpolate(A,I){if(A.length===0)return;let C=A[0],g=A[A.length-1];if(I<=C.time)return C.value;if(I>=g.time)return g.value;for(let i=0;i<A.length-1;i++)if(I>=A[i].time&&I<A[i+1].time){C=A[i],g=A[i+1];break}if(Math.abs(C.time-I)<.005)return C.value;if(Math.abs(g.time-I)<.005)return g.value;const Q=g.time-C.time;let E=(I-C.time)/Q;if(C.easing&&(E=$E(C.easing)(E)),typeof C.value=="string"){if(C.value.startsWith("#"))return this.interpolateColor(C.value,g.value,E);const i=parseFloat(C.value),D=parseFloat(g.value);return!isNaN(i)&&!isNaN(D)?Math.round(i+(D-i)*E).toString():C.value}return Array.isArray(C.value)&&Array.isArray(g.value)?C.value.length===g.value.length?C.value.map((i,D)=>{const o=g.value[D];return typeof i=="number"&&typeof o=="number"?i+(o-i)*E:E<.5?i:o}):E<.5?C.value:g.value:typeof C.value=="object"&&typeof g.value=="object"&&C.value!==null&&g.value!==null?C.value.width!==void 0&&C.value.color!==void 0?this.interpolateStroke(C.value,g.value,E):C.value.type&&g.value.type?this.interpolateFill(C.value,g.value,E):E<.5?C.value:g.value:typeof C.value=="number"&&typeof g.value=="number"?C.value+(g.value-C.value)*E:E<.5?C.value:g.value}interpolateColor(A,I,C){var t,K;const g=((K=(t=this.artboard)==null?void 0:t.tokens)==null?void 0:K.colors)||{},Q=g[A]||A,E=g[I]||I,i=S=>{if(!S)return{r:0,g:0,b:0};const y=S.startsWith("#")?S.replace("#",""):"000000";return y.length===3?{r:parseInt(y[0]+y[0],16),g:parseInt(y[1]+y[1],16),b:parseInt(y[2]+y[2],16)}:{r:parseInt(y.substring(0,2),16),g:parseInt(y.substring(2,4),16),b:parseInt(y.substring(4,6),16)}},D=i(Q),o=i(E),s=Math.round(D.r+(o.r-D.r)*C),h=Math.round(D.g+(o.g-D.g)*C),a=Math.round(D.b+(o.b-D.b)*C),G=S=>{const y=Math.max(0,Math.min(255,S)).toString(16);return y.length===1?"0"+y:y};return`#${G(s)}${G(h)}${G(a)}`}interpolateStops(A,I,C){return!A||!I||A.length!==I.length?C<.5?A:I:A.map((g,Q)=>{const E=I[Q];return{offset:g.offset+(E.offset-g.offset)*C,color:this.interpolateColor(g.color,E.color,C),opacity:(g.opacity??1)+((E.opacity??1)-(g.opacity??1))*C}})}interpolateFill(A,I,C){if(!A||!I||A.type!==I.type)return C<.5?A:I;const g={...A,opacity:(A.opacity??1)+((I.opacity??1)-(A.opacity??1))*C};return A.type==="Solid"?g.color=this.interpolateColor(A.color,I.color,C):(A.type==="LinearGradient"||A.type==="RadialGradient")&&(A.start&&I.start&&(g.start=[A.start[0]+(I.start[0]-A.start[0])*C,A.start[1]+(I.start[1]-A.start[1])*C]),A.end&&I.end&&(g.end=[A.end[0]+(I.end[0]-A.end[0])*C,A.end[1]+(I.end[1]-A.end[1])*C]),A.center&&I.center&&(g.center=[A.center[0]+(I.center[0]-A.center[0])*C,A.center[1]+(I.center[1]-A.center[1])*C]),A.radius!==void 0&&I.radius!==void 0&&(g.radius=A.radius+(I.radius-A.radius)*C),g.stops=this.interpolateStops(A.stops,I.stops,C)),g}interpolateStroke(A,I,C){if(!A||!I)return C<.5?A:I;const g={...A};return g.width=(A.width??0)+((I.width??0)-(A.width??0))*C,g.opacity=(A.opacity??1)+((I.opacity??1)-(A.opacity??1))*C,A.fill&&I.fill?g.fill=this.interpolateFill(A.fill,I.fill,C):A.color&&I.color&&A.color.startsWith("#")&&I.color.startsWith("#")&&(g.color=this.interpolateColor(A.color,I.color,C)),g.trimStart=(A.trimStart??0)+((I.trimStart??0)-(A.trimStart??0))*C,g.trimEnd=(A.trimEnd??1)+((I.trimEnd??1)-(A.trimEnd??1))*C,g.trimOffset=(A.trimOffset??0)+((I.trimOffset??0)-(A.trimOffset??0))*C,g.dashOffset=(A.dashOffset??0)+((I.dashOffset??0)-(A.dashOffset??0))*C,g}render(A,I,C){if(this.canvasWidth=I,this.canvasHeight=C,!this.artboard)return;A.clearRect(0,0,I,C);const g=this.artboard.width,Q=this.artboard.height,E=this.calculateTransform(I,C,g,Q,this.layout.fit,this.layout.alignment);if(A.save(),A.translate(Math.round(E.tx),Math.round(E.ty)),A.scale(E.scaleX,E.scaleY),A.translate(g/2,Q/2),this.rootTransform=A.getTransform(),this.artboard.backgroundVisible!==!1&&(A.fillStyle=this.artboard.backgroundColor||"#000000",A.fillRect(-g/2,-Q/2,g,Q)),this.artboard.backgroundImage){const D=this.artboard.backgroundImage;let o=this.imageCache.get(D);if(o||(o=new Image,o.src=D,this.imageCache.set(D,o)),o.complete&&o.naturalWidth>0){A.save(),A.globalAlpha=this.normalizeOpacity(this.artboard.backgroundOpacity??100);const s=o.naturalWidth/o.naturalHeight,h=g/Q;let a,G,t,K;h>s?(a=g,G=g/s):(G=Q,a=Q*s),t=-a/2,K=-G/2,A.drawImage(o,t,K,a,G),A.restore()}}A.beginPath(),A.rect(-g/2,-Q/2,g,Q),A.clip();const i=new Map;this.artboard.objects.forEach(D=>i.set(D.id,D)),this.artboard.objects.forEach(D=>{D.parentId||this.renderObject(A,D,i)}),A.restore()}calculateTransform(A,I,C,g,Q,E){let i=1,D=1,o=1;const s=C/g,h=A/I;switch(Q){case"Contain":h>s?o=I/g:o=A/C,i=D=o;break;case"Cover":h>s?o=A/C:o=I/g,i=D=o;break;case"Fill":i=A/C,D=I/g;break;case"FitWidth":o=A/C,i=D=o;break;case"FitHeight":o=I/g,i=D=o;break;case"None":i=D=1;break;case"ScaleDown":o=Math.min(A/C,I/g),o>1&&(o=1),i=D=o;break;default:i=D=1;break}const a=C*i,G=g*D;let t=0,K=0;return E.includes("Left")?t=0:E.includes("Right")?t=A-a:t=(A-a)/2,E.includes("Top")?K=0:E.includes("Bottom")?K=I-G:K=(I-G)/2,{scaleX:i,scaleY:D,tx:t,ty:K}}mapFontWeight(A){const I=A.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":A}getFontLeadingFactor(A){const I=(A||"Inter").trim();for(const[C,g]of Object.entries(this.fontLeadingFactors))if(I.toLowerCase()===C.toLowerCase())return g;return .5}renderObject(A,I,C){var u,q,l,r,z,d,_,hA,SA,FA,NA;const g=this.objectStates.get(I.id);if(!g){console.warn("No state for object:",I.id);return}A.roundRect||(A.roundRect=(m,O,Y,R,x)=>(this.drawRoundRect(A,m,O,Y,R,x),A));const Q=g.geometry?this.deepMerge(I.geometry,g.geometry):I.geometry,E=g.style?this.deepMerge(I.style,g.style):I.style;let i=(Q==null?void 0:Q.width)||((u=I.geometry)==null?void 0:u.width)||I.width||0,D=(Q==null?void 0:Q.height)||((q=I.geometry)==null?void 0:q.height)||I.height||0;if((i===0||D===0)&&(Q!=null&&Q.points)&&Array.isArray(Q.points)&&Q.points.length>0){let m=1/0,O=-1/0,Y=1/0,R=-1/0;Q.points.forEach(x=>{m=Math.min(m,x.x),O=Math.max(O,x.x),Y=Math.min(Y,x.y),R=Math.max(R,x.y)}),i===0&&(i=O-m),D===0&&(D=R-Y)}const o=m=>{if(m)return m.corner_radius??m.cornerRadius},s=o(g)??o(E)??o(Q)??o(I.style)??o(I.geometry)??0,h={...Q,width:i,height:D};if(delete h.cornerRadius,h.corner_radius=s,g.visible===!1)return;const a=g.x,G=g.y;A.save();const t=[],K=E.blur||((l=I.style)==null?void 0:l.blur);K&&K.amount>0&&t.push(`blur(${K.amount}px)`);const S=((r=Q==null?void 0:Q.type)==null?void 0:r.toLowerCase().includes("image"))||((z=I.type)==null?void 0:z.toLowerCase().includes("image")),y=E.adjustments&&Object.keys(E.adjustments).length>0?E.adjustments:null,F=Q!=null&&Q.adjustments&&Object.keys(Q.adjustments).length>0?Q.adjustments:null,e=S?F||y:y||F,M=S&&!e?{exposure:0,contrast:0,saturation:100,temperature:0,tint:0,highlights:0,shadows:0,blur:0,negative:0,hue:0}:e;if(g&&M&&(g.geometry=g.geometry||{},g.geometry.adjustments={...M}),M){const m=(M.exposure||0)/100,O=M.contrast||0,Y=1+(M.saturation||0)/100,R=(M.temperature||0)/200,x=(M.tint||0)/200,j=(M.highlights||0)/500,GA=(M.shadows||0)/500;let CA="",wA="SourceGraphic";if(m!==0&&(CA+=`
|
|
7
7
|
<feComponentTransfer in="${wA}" result="exposure">
|
|
8
8
|
<feFuncR type="linear" slope="1" intercept="${m}"/>
|
|
9
9
|
<feFuncG type="linear" slope="1" intercept="${m}"/>
|
package/dist/index.mjs
CHANGED
|
@@ -7437,37 +7437,39 @@ class ii {
|
|
|
7437
7437
|
return;
|
|
7438
7438
|
}
|
|
7439
7439
|
const D = this.interpolate(C.keyframes, I);
|
|
7440
|
-
if (
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
if (E.includes(".")) {
|
|
7445
|
-
const a = (E || "").split(".");
|
|
7446
|
-
let G = i;
|
|
7447
|
-
for (let t = 0; t < a.length - 1; t++) {
|
|
7448
|
-
if (typeof G[a[t]] != "object" || G[a[t]] === null) {
|
|
7449
|
-
let K = g;
|
|
7450
|
-
for (let S = 0; S <= t; S++)
|
|
7451
|
-
K = K ? K[a[S]] : null;
|
|
7452
|
-
G[a[t]] = K ? JSON.parse(JSON.stringify(K)) : {};
|
|
7453
|
-
}
|
|
7454
|
-
G = G[a[t]];
|
|
7440
|
+
if (D !== void 0) {
|
|
7441
|
+
if (this.frameCount % 480 === 0) {
|
|
7442
|
+
const a = (g == null ? void 0 : g.name) || C.object_id;
|
|
7443
|
+
this.debugLog(`Applying ${E} = ${typeof D == "object" ? "OBJ" : D} to ${a}`);
|
|
7455
7444
|
}
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7445
|
+
if (E.includes(".")) {
|
|
7446
|
+
const a = (E || "").split(".");
|
|
7447
|
+
let G = i;
|
|
7448
|
+
for (let t = 0; t < a.length - 1; t++) {
|
|
7449
|
+
if (typeof G[a[t]] != "object" || G[a[t]] === null) {
|
|
7450
|
+
let K = g;
|
|
7451
|
+
for (let S = 0; S <= t; S++)
|
|
7452
|
+
K = K ? K[a[S]] : null;
|
|
7453
|
+
G[a[t]] = K ? JSON.parse(JSON.stringify(K)) : {};
|
|
7454
|
+
}
|
|
7455
|
+
G = G[a[t]];
|
|
7456
|
+
}
|
|
7457
|
+
G[a[a.length - 1]] = D;
|
|
7458
|
+
} else
|
|
7459
|
+
i[E] = D;
|
|
7460
|
+
if (this.physicsEngine && ((h = g == null ? void 0 : g.physics) != null && h.enabled) && g.physics.bodyType === "Static")
|
|
7461
|
+
if (E === "x") {
|
|
7462
|
+
const a = this.physicsEngine.getPosition(C.object_id);
|
|
7463
|
+
a && this.physicsEngine.setPosition(C.object_id, D, a.y);
|
|
7464
|
+
} else if (E === "y") {
|
|
7465
|
+
const a = this.physicsEngine.getPosition(C.object_id);
|
|
7466
|
+
a && this.physicsEngine.setPosition(C.object_id, a.x, D);
|
|
7467
|
+
} else E === "rotation" && this.physicsEngine.setRotation(C.object_id, D * (Math.PI / 180));
|
|
7468
|
+
}
|
|
7467
7469
|
});
|
|
7468
7470
|
}
|
|
7469
7471
|
interpolate(A, I) {
|
|
7470
|
-
if (A.length === 0) return
|
|
7472
|
+
if (A.length === 0) return;
|
|
7471
7473
|
let C = A[0], g = A[A.length - 1];
|
|
7472
7474
|
if (I <= C.time) return C.value;
|
|
7473
7475
|
if (I >= g.time) return g.value;
|