@animaapp/anima-sdk-react 0.7.3 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var rn=Object.defineProperty,on=Object.defineProperties;var an=Object.getOwnPropertyDescriptors;var bt=Object.getOwnPropertySymbols;var cn=Object.prototype.hasOwnProperty,un=Object.prototype.propertyIsEnumerable;var yt=(e,t,n)=>t in e?rn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,j=(e,t)=>{for(var n in t||(t={}))cn.call(t,n)&&yt(e,n,t[n]);if(bt)for(var n of bt(t))un.call(t,n)&&yt(e,n,t[n]);return e},Tt=(e,t)=>on(e,an(t));var ae=(e,t,n)=>new Promise((r,s)=>{var c=m=>{try{a(n.next(m))}catch(S){s(S)}},l=m=>{try{a(n.throw(m))}catch(S){s(S)}},a=m=>m.done?r(m.value):Promise.resolve(m.value).then(c,l);a((n=n.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react"),We=require("@animaapp/anima-sdk");var je={exports:{}},Te={};/**
1
+ "use strict";var on=Object.defineProperty,an=Object.defineProperties;var cn=Object.getOwnPropertyDescriptors;var bt=Object.getOwnPropertySymbols;var un=Object.prototype.hasOwnProperty,ln=Object.prototype.propertyIsEnumerable;var yt=(e,t,n)=>t in e?on(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,j=(e,t)=>{for(var n in t||(t={}))un.call(t,n)&&yt(e,n,t[n]);if(bt)for(var n of bt(t))ln.call(t,n)&&yt(e,n,t[n]);return e},Tt=(e,t)=>an(e,cn(t));var ae=(e,t,n)=>new Promise((r,s)=>{var i=f=>{try{l(n.next(f))}catch(S){s(S)}},u=f=>{try{l(n.throw(f))}catch(S){s(S)}},l=f=>f.done?r(f.value):Promise.resolve(f.value).then(i,u);l((n=n.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react"),Je=require("@animaapp/anima-sdk");var je={exports:{}},Te={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var Ct;function ln(){if(Ct)return Te;Ct=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,s,c){var l=null;if(c!==void 0&&(l=""+c),s.key!==void 0&&(l=""+s.key),"key"in s){c={};for(var a in s)a!=="key"&&(c[a]=s[a])}else c=s;return s=c.ref,{$$typeof:e,type:r,key:l,ref:s!==void 0?s:null,props:c}}return Te.Fragment=t,Te.jsx=n,Te.jsxs=n,Te}var Ce={};/**
9
+ */var Ct;function dn(){if(Ct)return Te;Ct=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,s,i){var u=null;if(i!==void 0&&(u=""+i),s.key!==void 0&&(u=""+s.key),"key"in s){i={};for(var l in s)l!=="key"&&(i[l]=s[l])}else i=s;return s=i.ref,{$$typeof:e,type:r,key:u,ref:s!==void 0?s:null,props:i}}return Te.Fragment=t,Te.jsx=n,Te.jsxs=n,Te}var Ce={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,16 +14,16 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var At;function fn(){return At||(At=1,process.env.NODE_ENV!=="production"&&(function(){function e(o){if(o==null)return null;if(typeof o=="function")return o.$$typeof===q?null:o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case u:return"Fragment";case i:return"Profiler";case f:return"StrictMode";case C:return"Suspense";case V:return"SuspenseList";case X:return"Activity"}if(typeof o=="object")switch(typeof o.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),o.$$typeof){case h:return"Portal";case I:return(o.displayName||"Context")+".Provider";case g:return(o._context.displayName||"Context")+".Consumer";case D:var v=o.render;return o=o.displayName,o||(o=v.displayName||v.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case U:return v=o.displayName||null,v!==null?v:e(o.type)||"Memo";case T:v=o._payload,o=o._init;try{return e(o(v))}catch(O){}}return null}function t(o){return""+o}function n(o){try{t(o);var v=!1}catch(z){v=!0}if(v){v=console;var O=v.error,x=typeof Symbol=="function"&&Symbol.toStringTag&&o[Symbol.toStringTag]||o.constructor.name||"Object";return O.call(v,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",x),t(o)}}function r(o){if(o===u)return"<>";if(typeof o=="object"&&o!==null&&o.$$typeof===T)return"<...>";try{var v=e(o);return v?"<"+v+">":"<...>"}catch(O){return"<...>"}}function s(){var o=H.A;return o===null?null:o.getOwner()}function c(){return Error("react-stack-top-frame")}function l(o){if(ee.call(o,"key")){var v=Object.getOwnPropertyDescriptor(o,"key").get;if(v&&v.isReactWarning)return!1}return o.key!==void 0}function a(o,v){function O(){ue||(ue=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",v))}O.isReactWarning=!0,Object.defineProperty(o,"key",{get:O,configurable:!0})}function m(){var o=e(this.type);return Oe[o]||(Oe[o]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),o=this.props.ref,o!==void 0?o:null}function S(o,v,O,x,z,G,Ee,me){return O=G.ref,o={$$typeof:d,type:o,key:v,props:G,_owner:z},(O!==void 0?O:null)!==null?Object.defineProperty(o,"ref",{enumerable:!1,get:m}):Object.defineProperty(o,"ref",{enumerable:!1,value:null}),o._store={},Object.defineProperty(o._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(o,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(o,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Ee}),Object.defineProperty(o,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:me}),Object.freeze&&(Object.freeze(o.props),Object.freeze(o)),o}function w(o,v,O,x,z,G,Ee,me){var M=v.children;if(M!==void 0)if(x)if(J(M)){for(x=0;x<M.length;x++)E(M[x]);Object.freeze&&Object.freeze(M)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else E(M);if(ee.call(v,"key")){M=e(o);var le=Object.keys(v).filter(function(De){return De!=="key"});x=0<le.length?"{key: someKey, "+le.join(": ..., ")+": ...}":"{key: someKey}",ye[M+x]||(le=0<le.length?"{"+le.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
17
+ */var At;function fn(){return At||(At=1,process.env.NODE_ENV!=="production"&&(function(){function e(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===q?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case c:return"Fragment";case o:return"Profiler";case d:return"StrictMode";case C:return"Suspense";case V:return"SuspenseList";case X:return"Activity"}if(typeof a=="object")switch(typeof a.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),a.$$typeof){case p:return"Portal";case D:return(a.displayName||"Context")+".Provider";case g:return(a._context.displayName||"Context")+".Consumer";case x:var v=a.render;return a=a.displayName,a||(a=v.displayName||v.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case U:return v=a.displayName||null,v!==null?v:e(a.type)||"Memo";case T:v=a._payload,a=a._init;try{return e(a(v))}catch(O){}}return null}function t(a){return""+a}function n(a){try{t(a);var v=!1}catch(z){v=!0}if(v){v=console;var O=v.error,I=typeof Symbol=="function"&&Symbol.toStringTag&&a[Symbol.toStringTag]||a.constructor.name||"Object";return O.call(v,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",I),t(a)}}function r(a){if(a===c)return"<>";if(typeof a=="object"&&a!==null&&a.$$typeof===T)return"<...>";try{var v=e(a);return v?"<"+v+">":"<...>"}catch(O){return"<...>"}}function s(){var a=H.A;return a===null?null:a.getOwner()}function i(){return Error("react-stack-top-frame")}function u(a){if(ee.call(a,"key")){var v=Object.getOwnPropertyDescriptor(a,"key").get;if(v&&v.isReactWarning)return!1}return a.key!==void 0}function l(a,v){function O(){ue||(ue=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",v))}O.isReactWarning=!0,Object.defineProperty(a,"key",{get:O,configurable:!0})}function f(){var a=e(this.type);return Oe[a]||(Oe[a]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),a=this.props.ref,a!==void 0?a:null}function S(a,v,O,I,z,G,Ee,me){return O=G.ref,a={$$typeof:h,type:a,key:v,props:G,_owner:z},(O!==void 0?O:null)!==null?Object.defineProperty(a,"ref",{enumerable:!1,get:f}):Object.defineProperty(a,"ref",{enumerable:!1,value:null}),a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(a,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(a,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Ee}),Object.defineProperty(a,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:me}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a}function w(a,v,O,I,z,G,Ee,me){var M=v.children;if(M!==void 0)if(I)if(J(M)){for(I=0;I<M.length;I++)m(M[I]);Object.freeze&&Object.freeze(M)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else m(M);if(ee.call(v,"key")){M=e(a);var le=Object.keys(v).filter(function(De){return De!=="key"});I=0<le.length?"{key: someKey, "+le.join(": ..., ")+": ...}":"{key: someKey}",ye[M+I]||(le=0<le.length?"{"+le.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
18
  let props = %s;
19
19
  <%s {...props} />
20
20
  React keys must be passed directly to JSX without using spread:
21
21
  let props = %s;
22
- <%s key={someKey} {...props} />`,x,M,le,M),ye[M+x]=!0)}if(M=null,O!==void 0&&(n(O),M=""+O),l(v)&&(n(v.key),M=""+v.key),"key"in v){O={};for(var se in v)se!=="key"&&(O[se]=v[se])}else O=v;return M&&a(O,typeof o=="function"?o.displayName||o.name||"Unknown":o),S(o,M,G,z,s(),O,Ee,me)}function E(o){typeof o=="object"&&o!==null&&o.$$typeof===d&&o._store&&(o._store.validated=1)}var p=b,d=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),u=Symbol.for("react.fragment"),f=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),g=Symbol.for("react.consumer"),I=Symbol.for("react.context"),D=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),V=Symbol.for("react.suspense_list"),U=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),q=Symbol.for("react.client.reference"),H=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee=Object.prototype.hasOwnProperty,J=Array.isArray,A=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(o){return o()}};var ue,Oe={},be=p.react_stack_bottom_frame.bind(p,c)(),ne=A(r(c)),ye={};Ce.Fragment=u,Ce.jsx=function(o,v,O,x,z){var G=1e4>H.recentlyCreatedOwnerStacks++;return w(o,v,O,!1,x,z,G?Error("react-stack-top-frame"):be,G?A(r(o)):ne)},Ce.jsxs=function(o,v,O,x,z){var G=1e4>H.recentlyCreatedOwnerStacks++;return w(o,v,O,!0,x,z,G?Error("react-stack-top-frame"):be,G?A(r(o)):ne)}})()),Ce}var Lt;function dn(){return Lt||(Lt=1,process.env.NODE_ENV==="production"?je.exports=ln():je.exports=fn()),je.exports}var hn=dn();class kt extends Error{constructor(t,n){super(t),this.name="ParseError",this.type=n.type,this.field=n.field,this.value=n.value,this.line=n.line}}function Ge(e){}function pn(e){if(typeof e=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=Ge,onError:n=Ge,onRetry:r=Ge,onComment:s}=e;let c="",l=!0,a,m="",S="";function w(u){const f=l?u.replace(/^\xEF\xBB\xBF/,""):u,[i,g]=En(`${c}${f}`);for(const I of i)E(I);c=g,l=!1}function E(u){if(u===""){d();return}if(u.startsWith(":")){s&&s(u.slice(u.startsWith(": ")?2:1));return}const f=u.indexOf(":");if(f!==-1){const i=u.slice(0,f),g=u[f+1]===" "?2:1,I=u.slice(f+g);p(i,I,u);return}p(u,"",u)}function p(u,f,i){switch(u){case"event":S=f;break;case"data":m=`${m}${f}
23
- `;break;case"id":a=f.includes("\0")?void 0:f;break;case"retry":/^\d+$/.test(f)?r(parseInt(f,10)):n(new kt(`Invalid \`retry\` value: "${f}"`,{type:"invalid-retry",value:f,line:i}));break;default:n(new kt(`Unknown field "${u.length>20?`${u.slice(0,20)}…`:u}"`,{type:"unknown-field",field:u,value:f,line:i}));break}}function d(){m.length>0&&t({id:a,event:S||void 0,data:m.endsWith(`
24
- `)?m.slice(0,-1):m}),a=void 0,m="",S=""}function h(u={}){c&&u.consume&&E(c),l=!0,a=void 0,m="",S="",c=""}return{feed:w,reset:h}}function En(e){const t=[];let n="",r=0;for(;r<e.length;){const s=e.indexOf("\r",r),c=e.indexOf(`
25
- `,r);let l=-1;if(s!==-1&&c!==-1?l=Math.min(s,c):s!==-1?s===e.length-1?l=-1:l=s:c!==-1&&(l=c),l===-1){n=e.slice(r);break}else{const a=e.slice(r,l);t.push(a),r=l+1,e[r-1]==="\r"&&e[r]===`
26
- `&&r++}}return[t,n]}class Nt extends Event{constructor(t,n){var r,s;super(t),this.code=(r=n==null?void 0:n.code)!=null?r:void 0,this.message=(s=n==null?void 0:n.message)!=null?s:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,n,r){return r(xt(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(xt(this),n)}}function mn(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function et(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(et).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${et(e.cause)}`:e.message:`${e}`}function xt(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var Gt=e=>{throw TypeError(e)},mt=(e,t,n)=>t.has(e)||Gt("Cannot "+n),_=(e,t,n)=>(mt(e,t,"read from private field"),n?n.call(e):t.get(e)),P=(e,t,n)=>t.has(e)?Gt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),k=(e,t,n,r)=>(mt(e,t,"write to private field"),t.set(e,n),n),ie=(e,t,n)=>(mt(e,t,"access private method"),n),B,pe,ve,Ve,Ue,ke,we,Ne,fe,Se,Re,_e,Ae,Q,tt,nt,st,It,rt,ot,Le,at,it;class $e extends EventTarget{constructor(t,n){var r,s;super(),P(this,Q),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,P(this,B),P(this,pe),P(this,ve),P(this,Ve),P(this,Ue),P(this,ke),P(this,we),P(this,Ne,null),P(this,fe),P(this,Se),P(this,Re,null),P(this,_e,null),P(this,Ae,null),P(this,nt,c=>ae(this,null,function*(){var l;_(this,Se).reset();const{body:a,redirected:m,status:S,headers:w}=c;if(S===204){ie(this,Q,Le).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(m?k(this,ve,new URL(c.url)):k(this,ve,void 0),S!==200){ie(this,Q,Le).call(this,`Non-200 status code (${S})`,S);return}if(!(w.get("content-type")||"").startsWith("text/event-stream")){ie(this,Q,Le).call(this,'Invalid content type, expected "text/event-stream"',S);return}if(_(this,B)===this.CLOSED)return;k(this,B,this.OPEN);const E=new Event("open");if((l=_(this,Ae))==null||l.call(this,E),this.dispatchEvent(E),typeof a!="object"||!a||!("getReader"in a)){ie(this,Q,Le).call(this,"Invalid response body, expected a web ReadableStream",S),this.close();return}const p=new TextDecoder,d=a.getReader();let h=!0;do{const{done:u,value:f}=yield d.read();f&&_(this,Se).feed(p.decode(f,{stream:!u})),u&&(h=!1,_(this,Se).reset(),ie(this,Q,at).call(this))}while(h)})),P(this,st,c=>{k(this,fe,void 0),!(c.name==="AbortError"||c.type==="aborted")&&ie(this,Q,at).call(this,et(c))}),P(this,rt,c=>{typeof c.id=="string"&&k(this,Ne,c.id);const l=new MessageEvent(c.event||"message",{data:c.data,origin:_(this,ve)?_(this,ve).origin:_(this,pe).origin,lastEventId:c.id||""});_(this,_e)&&(!c.event||c.event==="message")&&_(this,_e).call(this,l),this.dispatchEvent(l)}),P(this,ot,c=>{k(this,ke,c)}),P(this,it,()=>{k(this,we,void 0),_(this,B)===this.CONNECTING&&ie(this,Q,tt).call(this)});try{if(t instanceof URL)k(this,pe,t);else if(typeof t=="string")k(this,pe,new URL(t,gn()));else throw new Error("Invalid URL")}catch(c){throw mn("An invalid or illegal string was specified")}k(this,Se,pn({onEvent:_(this,rt),onRetry:_(this,ot)})),k(this,B,this.CONNECTING),k(this,ke,3e3),k(this,Ue,(r=n==null?void 0:n.fetch)!=null?r:globalThis.fetch),k(this,Ve,(s=n==null?void 0:n.withCredentials)!=null?s:!1),ie(this,Q,tt).call(this)}get readyState(){return _(this,B)}get url(){return _(this,pe).href}get withCredentials(){return _(this,Ve)}get onerror(){return _(this,Re)}set onerror(t){k(this,Re,t)}get onmessage(){return _(this,_e)}set onmessage(t){k(this,_e,t)}get onopen(){return _(this,Ae)}set onopen(t){k(this,Ae,t)}addEventListener(t,n,r){const s=n;super.addEventListener(t,s,r)}removeEventListener(t,n,r){const s=n;super.removeEventListener(t,s,r)}close(){_(this,we)&&clearTimeout(_(this,we)),_(this,B)!==this.CLOSED&&(_(this,fe)&&_(this,fe).abort(),k(this,B,this.CLOSED),k(this,fe,void 0))}}B=new WeakMap,pe=new WeakMap,ve=new WeakMap,Ve=new WeakMap,Ue=new WeakMap,ke=new WeakMap,we=new WeakMap,Ne=new WeakMap,fe=new WeakMap,Se=new WeakMap,Re=new WeakMap,_e=new WeakMap,Ae=new WeakMap,Q=new WeakSet,tt=function(){k(this,B,this.CONNECTING),k(this,fe,new AbortController),_(this,Ue)(_(this,pe),ie(this,Q,It).call(this)).then(_(this,nt)).catch(_(this,st))},nt=new WeakMap,st=new WeakMap,It=function(){var e;const t={mode:"cors",redirect:"follow",headers:j({Accept:"text/event-stream"},_(this,Ne)?{"Last-Event-ID":_(this,Ne)}:void 0),cache:"no-store",signal:(e=_(this,fe))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},rt=new WeakMap,ot=new WeakMap,Le=function(e,t){var n;_(this,B)!==this.CLOSED&&k(this,B,this.CLOSED);const r=new Nt("error",{code:t,message:e});(n=_(this,Re))==null||n.call(this,r),this.dispatchEvent(r)},at=function(e,t){var n;if(_(this,B)===this.CLOSED)return;k(this,B,this.CONNECTING);const r=new Nt("error",{code:t,message:e});(n=_(this,Re))==null||n.call(this,r),this.dispatchEvent(r),k(this,we,setTimeout(_(this,it),_(this,ke)))},it=new WeakMap,$e.CONNECTING=0,$e.OPEN=1,$e.CLOSED=2;function gn(){const e="document"in globalThis?globalThis.document:void 0;return e&&typeof e=="object"&&"baseURI"in e&&typeof e.baseURI=="string"?e.baseURI:void 0}const vn=e=>{let t="";const n=new Uint8Array(e),r=n.byteLength;for(let s=0;s<r;s++)t+=String.fromCharCode(n[s]);return btoa(t)},gt={status:"idle",error:null,result:null,progressMessages:[],tasks:{fetchDesign:{status:"pending"},codeGeneration:{status:"pending",progress:0},uploadAssets:{status:"pending"}},jobSessionId:null,jobStatus:{}},Dt=10,jt=e=>"path"in e?{filePath:e.path.replace(/^\//,""),referencePath:e.path==="/"?"":e.path}:{filePath:e.filePath.replace(/^\//,""),referencePath:e.referencePath==="/"?"":e.referencePath},Yt=(e,t,n,r)=>ae(null,null,function*(){var S,w,E;const s=structuredClone(gt);s.status="pending",r(j({},s));const c=structuredClone(n);if(((S=n.assetsStorage)==null?void 0:S.strategy)==="local"){const{referencePath:p}=jt(n.assetsStorage);n.assetsStorage={strategy:"external",url:p}}let l;const a=new $e(e,{fetch:(p,d)=>(l=fetch(p,Tt(j({},d),{method:t,body:JSON.stringify(n)})),l)}),m=new Promise((p,d)=>{const h={};a.addEventListener("start",f=>{const i=JSON.parse(f.data);h.sessionId=i.sessionId,s.tasks.fetchDesign.status="running",s.jobSessionId=i.sessionId,r(j({},s))}),a.addEventListener("queueing",f=>{const i=JSON.parse(f.data);s.jobSessionId=i.payload.sessionId,r(j({},s))}),a.addEventListener("pre_codegen",f=>{JSON.parse(f.data).message==="Anima model built"&&(s.tasks.fetchDesign.status="finished",s.tasks.codeGeneration.status="running",s.tasks.uploadAssets.status="running",r(j({},s)))}),a.addEventListener("figma_metadata",f=>{const i=JSON.parse(f.data);h.figmaFileName=i.figmaFileName,h.figmaSelectedFrameName=i.figmaSelectedFrameName}),a.addEventListener("aborted",()=>{const f=new We.CodegenError({name:"Aborted",reason:"Unknown"});s.status="aborted",s.result=null,s.error=f,r(j({},s)),p({result:null,error:f})}),a.addEventListener("generating_code",f=>{const i=JSON.parse(f.data);i.payload.status==="success"&&(h.files=i.payload.files),s.tasks.codeGeneration.progress=i.payload.progress,s.tasks.codeGeneration.status="running",r(j({},s))}),a.addEventListener("progress_messages_updated",f=>{const i=JSON.parse(f.data);s.progressMessages=i.payload.progressMessages,r(j({},s))}),a.addEventListener("job_status_updated",f=>{const i=JSON.parse(f.data);s.jobStatus=i.payload.jobStatus,r(j({},s))}),a.addEventListener("codegen_completed",()=>{s.tasks.codeGeneration.status="finished",r(j({},s))}),a.addEventListener("generation_completed",()=>{s.tasks.codeGeneration.status="finished",r(j({},s))}),a.addEventListener("assets_uploaded",()=>{s.tasks.uploadAssets.status="finished",r(j({},s))}),a.addEventListener("assets_list",f=>{const i=JSON.parse(f.data);h.assets=i.payload.assets});let u=0;a.addEventListener("error",f=>ae(null,null,function*(){var V,U,T,X,q,H,ee;const i=yield l;if(!i.ok){let J="";try{J=yield i.text();const A=JSON.parse(J);(V=A==null?void 0:A.payload)!=null&&V.message&&(J=A.payload.message)}catch(A){}d(new We.CodegenError({name:"Request failed",reason:J,status:i.status})),a.close();return}console.warn(`Experienced error during code generation (attempt ${u+1} / ${Dt})`,f);let g,I=!1;if(f instanceof MessageEvent)try{g=JSON.parse(f.data)}catch(J){}(((U=g==null?void 0:g.payload)==null?void 0:U.name)==="Task Crashed"||((T=g==null?void 0:g.payload)==null?void 0:T.name)==="TimeoutError"||((X=g==null?void 0:g.payload)==null?void 0:X.name)==="Error"||((q=g==null?void 0:g.payload)==null?void 0:q.name)==="Unknown error")&&(I=!0);const D=new We.CodegenError({name:(H=g==null?void 0:g.payload.name)!=null?H:"Unknown error",reason:(ee=g==null?void 0:g.payload.message)!=null?ee:"Unknown",status:g==null?void 0:g.payload.status,detail:g==null?void 0:g.payload.detail});u++;let C=!1;u>Dt?(console.error("Experienced too many errors, terminating request"),C=!0):I&&(console.error("Experienced unrecoverable error, terminating request"),C=!0),C&&(s.status="error",s.error=D,r(j({},s)),p({result:null,error:D}))})),a.addEventListener("done",f=>{const i=JSON.parse(f.data);h.tokenUsage=i.payload.tokenUsage,h.sessionId=i.payload.sessionId,s.status="success",s.result=h,r(j({},s)),p({result:h,error:null})})});try{const{result:p,error:d}=yield m,h=structuredClone(p);if(((w=c.assetsStorage)==null?void 0:w.strategy)==="local"&&((E=h==null?void 0:h.assets)!=null&&E.length)){const{filePath:u}=jt(c.assetsStorage),f=h.assets.map(g=>ae(null,null,function*(){const D=yield(yield fetch(g.url)).arrayBuffer();return{assetName:g.name,base64:vn(D)}})),i=yield Promise.allSettled(f);for(const g of i){const I={};if(g.status==="fulfilled"){const{assetName:D,base64:C}=g.value;I[D]=C;const V=u?`${u}/${D}`:D;h.files[V]={content:C,isBinary:!0}}}}return d?{result:null,error:d}:{result:h,error:d}}finally{a.close()}});class Bt extends Error{constructor(t,n){super(t),this.name="CreateJobError",this.cause=n}}class Ht extends Error{constructor(){super(""),this.name="UnknownCodegenError"}}const vt=b.createContext(null);function Sn({f2cUrl:e,l2cUrl:t,p2cUrl:n,children:r}){const[s,c]=b.useState({status:"idle"}),l=b.useRef(null),[a,m]=b.useState(gt),S={f2c:e,l2c:t,p2c:n},w=(E,p)=>ae(null,null,function*(){var d;if(s.status==="pending")throw new Error("A job is already in progress");l.current=E;try{const h=S[E],{result:u}=yield Yt(h,"POST",p,f=>m(f));if(u){const f=u.sessionId,i=u.files,g=u.assets;c(I=>({status:"success",type:E,params:"params"in I?I.params:{},sessionId:f,payload:a.jobStatus,assets:g,files:i,progressMessages:a.progressMessages}));return}}catch(h){l.current=null;const u=h instanceof Error?h.message:"Unknown error",f=new Bt(u,h);throw c({status:"error",type:E,params:p,error:f,sessionId:(d=a.jobSessionId)!=null?d:null,payload:a.jobStatus,progressMessages:a.progressMessages}),f}});return b.useEffect(()=>{var p;if(!l.current)return;const E=l.current;if(a.status==="error"){const d=(p=a.error)!=null?p:new Ht;c(h=>{var u;return{status:"error",type:E,params:"params"in h?h.params:{},error:d,sessionId:(u=a.jobSessionId)!=null?u:null,payload:a.jobStatus,progressMessages:a.progressMessages}});return}if(a.status==="pending"){c(d=>({status:"pending",type:E,params:"params"in d?d.params:{},sessionId:a.jobSessionId,payload:a.jobStatus,progressMessages:a.progressMessages}));return}},[a]),hn.jsx(vt.Provider,{value:{createJob:w,job:s},children:r})}function _n(){const e=b.useContext(vt);if(!e)throw new Error("useAnimaSDK must be used within AnimaSDKProvider");return e}const wn=({url:e,method:t="POST"})=>{const[n,r]=b.useState(gt);return{getCode:b.useCallback(c=>Yt(e,t,c,r),[e,t]),status:n.status,progressMessages:n.progressMessages,jobSessionId:n.jobSessionId,jobStatus:n.jobStatus,tasks:n.tasks,error:n.error,result:n.result}};var Pe={exports:{}},Ye={};/**
22
+ <%s key={someKey} {...props} />`,I,M,le,M),ye[M+I]=!0)}if(M=null,O!==void 0&&(n(O),M=""+O),u(v)&&(n(v.key),M=""+v.key),"key"in v){O={};for(var se in v)se!=="key"&&(O[se]=v[se])}else O=v;return M&&l(O,typeof a=="function"?a.displayName||a.name||"Unknown":a),S(a,M,G,z,s(),O,Ee,me)}function m(a){typeof a=="object"&&a!==null&&a.$$typeof===h&&a._store&&(a._store.validated=1)}var E=b,h=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),c=Symbol.for("react.fragment"),d=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),g=Symbol.for("react.consumer"),D=Symbol.for("react.context"),x=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),V=Symbol.for("react.suspense_list"),U=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),q=Symbol.for("react.client.reference"),H=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee=Object.prototype.hasOwnProperty,J=Array.isArray,A=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(a){return a()}};var ue,Oe={},be=E.react_stack_bottom_frame.bind(E,i)(),ne=A(r(i)),ye={};Ce.Fragment=c,Ce.jsx=function(a,v,O,I,z){var G=1e4>H.recentlyCreatedOwnerStacks++;return w(a,v,O,!1,I,z,G?Error("react-stack-top-frame"):be,G?A(r(a)):ne)},Ce.jsxs=function(a,v,O,I,z){var G=1e4>H.recentlyCreatedOwnerStacks++;return w(a,v,O,!0,I,z,G?Error("react-stack-top-frame"):be,G?A(r(a)):ne)}})()),Ce}var Lt;function hn(){return Lt||(Lt=1,process.env.NODE_ENV==="production"?je.exports=dn():je.exports=fn()),je.exports}var pn=hn();class kt extends Error{constructor(t,n){super(t),this.name="ParseError",this.type=n.type,this.field=n.field,this.value=n.value,this.line=n.line}}function Ge(e){}function En(e){if(typeof e=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=Ge,onError:n=Ge,onRetry:r=Ge,onComment:s}=e;let i="",u=!0,l,f="",S="";function w(c){const d=u?c.replace(/^\xEF\xBB\xBF/,""):c,[o,g]=mn(`${i}${d}`);for(const D of o)m(D);i=g,u=!1}function m(c){if(c===""){h();return}if(c.startsWith(":")){s&&s(c.slice(c.startsWith(": ")?2:1));return}const d=c.indexOf(":");if(d!==-1){const o=c.slice(0,d),g=c[d+1]===" "?2:1,D=c.slice(d+g);E(o,D,c);return}E(c,"",c)}function E(c,d,o){switch(c){case"event":S=d;break;case"data":f=`${f}${d}
23
+ `;break;case"id":l=d.includes("\0")?void 0:d;break;case"retry":/^\d+$/.test(d)?r(parseInt(d,10)):n(new kt(`Invalid \`retry\` value: "${d}"`,{type:"invalid-retry",value:d,line:o}));break;default:n(new kt(`Unknown field "${c.length>20?`${c.slice(0,20)}…`:c}"`,{type:"unknown-field",field:c,value:d,line:o}));break}}function h(){f.length>0&&t({id:l,event:S||void 0,data:f.endsWith(`
24
+ `)?f.slice(0,-1):f}),l=void 0,f="",S=""}function p(c={}){i&&c.consume&&m(i),u=!0,l=void 0,f="",S="",i=""}return{feed:w,reset:p}}function mn(e){const t=[];let n="",r=0;for(;r<e.length;){const s=e.indexOf("\r",r),i=e.indexOf(`
25
+ `,r);let u=-1;if(s!==-1&&i!==-1?u=Math.min(s,i):s!==-1?s===e.length-1?u=-1:u=s:i!==-1&&(u=i),u===-1){n=e.slice(r);break}else{const l=e.slice(r,u);t.push(l),r=u+1,e[r-1]==="\r"&&e[r]===`
26
+ `&&r++}}return[t,n]}class Nt extends Event{constructor(t,n){var r,s;super(t),this.code=(r=n==null?void 0:n.code)!=null?r:void 0,this.message=(s=n==null?void 0:n.message)!=null?s:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,n,r){return r(xt(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(xt(this),n)}}function gn(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function et(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(et).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${et(e.cause)}`:e.message:`${e}`}function xt(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var Gt=e=>{throw TypeError(e)},mt=(e,t,n)=>t.has(e)||Gt("Cannot "+n),_=(e,t,n)=>(mt(e,t,"read from private field"),n?n.call(e):t.get(e)),P=(e,t,n)=>t.has(e)?Gt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),k=(e,t,n,r)=>(mt(e,t,"write to private field"),t.set(e,n),n),ie=(e,t,n)=>(mt(e,t,"access private method"),n),B,pe,ve,We,$e,ke,we,Ne,de,Se,Re,_e,Ae,Q,tt,nt,st,It,rt,ot,Le,at,it;class Ve extends EventTarget{constructor(t,n){var r,s;super(),P(this,Q),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,P(this,B),P(this,pe),P(this,ve),P(this,We),P(this,$e),P(this,ke),P(this,we),P(this,Ne,null),P(this,de),P(this,Se),P(this,Re,null),P(this,_e,null),P(this,Ae,null),P(this,nt,i=>ae(this,null,function*(){var u;_(this,Se).reset();const{body:l,redirected:f,status:S,headers:w}=i;if(S===204){ie(this,Q,Le).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(f?k(this,ve,new URL(i.url)):k(this,ve,void 0),S!==200){ie(this,Q,Le).call(this,`Non-200 status code (${S})`,S);return}if(!(w.get("content-type")||"").startsWith("text/event-stream")){ie(this,Q,Le).call(this,'Invalid content type, expected "text/event-stream"',S);return}if(_(this,B)===this.CLOSED)return;k(this,B,this.OPEN);const m=new Event("open");if((u=_(this,Ae))==null||u.call(this,m),this.dispatchEvent(m),typeof l!="object"||!l||!("getReader"in l)){ie(this,Q,Le).call(this,"Invalid response body, expected a web ReadableStream",S),this.close();return}const E=new TextDecoder,h=l.getReader();let p=!0;do{const{done:c,value:d}=yield h.read();d&&_(this,Se).feed(E.decode(d,{stream:!c})),c&&(p=!1,_(this,Se).reset(),ie(this,Q,at).call(this))}while(p)})),P(this,st,i=>{k(this,de,void 0),!(i.name==="AbortError"||i.type==="aborted")&&ie(this,Q,at).call(this,et(i))}),P(this,rt,i=>{typeof i.id=="string"&&k(this,Ne,i.id);const u=new MessageEvent(i.event||"message",{data:i.data,origin:_(this,ve)?_(this,ve).origin:_(this,pe).origin,lastEventId:i.id||""});_(this,_e)&&(!i.event||i.event==="message")&&_(this,_e).call(this,u),this.dispatchEvent(u)}),P(this,ot,i=>{k(this,ke,i)}),P(this,it,()=>{k(this,we,void 0),_(this,B)===this.CONNECTING&&ie(this,Q,tt).call(this)});try{if(t instanceof URL)k(this,pe,t);else if(typeof t=="string")k(this,pe,new URL(t,vn()));else throw new Error("Invalid URL")}catch(i){throw gn("An invalid or illegal string was specified")}k(this,Se,En({onEvent:_(this,rt),onRetry:_(this,ot)})),k(this,B,this.CONNECTING),k(this,ke,3e3),k(this,$e,(r=n==null?void 0:n.fetch)!=null?r:globalThis.fetch),k(this,We,(s=n==null?void 0:n.withCredentials)!=null?s:!1),ie(this,Q,tt).call(this)}get readyState(){return _(this,B)}get url(){return _(this,pe).href}get withCredentials(){return _(this,We)}get onerror(){return _(this,Re)}set onerror(t){k(this,Re,t)}get onmessage(){return _(this,_e)}set onmessage(t){k(this,_e,t)}get onopen(){return _(this,Ae)}set onopen(t){k(this,Ae,t)}addEventListener(t,n,r){const s=n;super.addEventListener(t,s,r)}removeEventListener(t,n,r){const s=n;super.removeEventListener(t,s,r)}close(){_(this,we)&&clearTimeout(_(this,we)),_(this,B)!==this.CLOSED&&(_(this,de)&&_(this,de).abort(),k(this,B,this.CLOSED),k(this,de,void 0))}}B=new WeakMap,pe=new WeakMap,ve=new WeakMap,We=new WeakMap,$e=new WeakMap,ke=new WeakMap,we=new WeakMap,Ne=new WeakMap,de=new WeakMap,Se=new WeakMap,Re=new WeakMap,_e=new WeakMap,Ae=new WeakMap,Q=new WeakSet,tt=function(){k(this,B,this.CONNECTING),k(this,de,new AbortController),_(this,$e)(_(this,pe),ie(this,Q,It).call(this)).then(_(this,nt)).catch(_(this,st))},nt=new WeakMap,st=new WeakMap,It=function(){var e;const t={mode:"cors",redirect:"follow",headers:j({Accept:"text/event-stream"},_(this,Ne)?{"Last-Event-ID":_(this,Ne)}:void 0),cache:"no-store",signal:(e=_(this,de))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},rt=new WeakMap,ot=new WeakMap,Le=function(e,t){var n;_(this,B)!==this.CLOSED&&k(this,B,this.CLOSED);const r=new Nt("error",{code:t,message:e});(n=_(this,Re))==null||n.call(this,r),this.dispatchEvent(r)},at=function(e,t){var n;if(_(this,B)===this.CLOSED)return;k(this,B,this.CONNECTING);const r=new Nt("error",{code:t,message:e});(n=_(this,Re))==null||n.call(this,r),this.dispatchEvent(r),k(this,we,setTimeout(_(this,it),_(this,ke)))},it=new WeakMap,Ve.CONNECTING=0,Ve.OPEN=1,Ve.CLOSED=2;function vn(){const e="document"in globalThis?globalThis.document:void 0;return e&&typeof e=="object"&&"baseURI"in e&&typeof e.baseURI=="string"?e.baseURI:void 0}const Sn=e=>{let t="";const n=new Uint8Array(e),r=n.byteLength;for(let s=0;s<r;s++)t+=String.fromCharCode(n[s]);return btoa(t)},gt={status:"idle",error:null,result:null,progressMessages:[],tasks:{fetchDesign:{status:"pending"},codeGeneration:{status:"pending",progress:0},uploadAssets:{status:"pending"}},jobSessionId:null,jobStatus:{}},Dt=10,jt=e=>"path"in e?{filePath:e.path.replace(/^\//,""),referencePath:e.path==="/"?"":e.path}:{filePath:e.filePath.replace(/^\//,""),referencePath:e.referencePath==="/"?"":e.referencePath},Yt=(e,t,n,r)=>ae(null,null,function*(){var S,w,m;const s=structuredClone(gt);s.status="pending",r(j({},s));const i=structuredClone(n);if(((S=n.assetsStorage)==null?void 0:S.strategy)==="local"){const{referencePath:E}=jt(n.assetsStorage);n.assetsStorage={strategy:"external",url:E}}let u;const l=new Ve(e,{fetch:(E,h)=>(u=fetch(E,Tt(j({},h),{method:t,body:JSON.stringify(n)})),u)}),f=new Promise((E,h)=>{const p={};l.addEventListener("start",d=>{const o=JSON.parse(d.data);p.sessionId=o.sessionId,s.tasks.fetchDesign.status="running",s.jobSessionId=o.sessionId,r(j({},s))}),l.addEventListener("queueing",d=>{const o=JSON.parse(d.data);s.jobSessionId=o.payload.sessionId,r(j({},s))}),l.addEventListener("pre_codegen",d=>{JSON.parse(d.data).message==="Anima model built"&&(s.tasks.fetchDesign.status="finished",s.tasks.codeGeneration.status="running",s.tasks.uploadAssets.status="running",r(j({},s)))}),l.addEventListener("figma_metadata",d=>{const o=JSON.parse(d.data);p.figmaFileName=o.figmaFileName,p.figmaSelectedFrameName=o.figmaSelectedFrameName}),l.addEventListener("aborted",()=>{const d=new Je.CodegenError({name:"Aborted",reason:"Unknown"});s.status="aborted",s.result=null,s.error=d,r(j({},s)),E({result:null,error:d})}),l.addEventListener("generating_code",d=>{const o=JSON.parse(d.data);o.payload.status==="success"&&(p.files=o.payload.files),s.tasks.codeGeneration.progress=o.payload.progress,s.tasks.codeGeneration.status="running",r(j({},s))}),l.addEventListener("progress_messages_updated",d=>{const o=JSON.parse(d.data);s.progressMessages=o.payload.progressMessages,r(j({},s))}),l.addEventListener("job_status_updated",d=>{const o=JSON.parse(d.data);s.jobStatus=o.payload.jobStatus,r(j({},s))}),l.addEventListener("codegen_completed",()=>{s.tasks.codeGeneration.status="finished",r(j({},s))}),l.addEventListener("generation_completed",()=>{s.tasks.codeGeneration.status="finished",r(j({},s))}),l.addEventListener("assets_uploaded",()=>{s.tasks.uploadAssets.status="finished",r(j({},s))}),l.addEventListener("assets_list",d=>{const o=JSON.parse(d.data);p.assets=o.payload.assets});let c=0;l.addEventListener("error",d=>ae(null,null,function*(){var V,U,T,X,q,H,ee;const o=yield u;if(!o.ok){let J="";try{J=yield o.text();const A=JSON.parse(J);(V=A==null?void 0:A.payload)!=null&&V.message&&(J=A.payload.message)}catch(A){}h(new Je.CodegenError({name:"Request failed",reason:J,status:o.status})),l.close();return}console.warn(`Experienced error during code generation (attempt ${c+1} / ${Dt})`,d);let g,D=!1;if(d instanceof MessageEvent)try{g=JSON.parse(d.data)}catch(J){}(((U=g==null?void 0:g.payload)==null?void 0:U.name)==="Task Crashed"||((T=g==null?void 0:g.payload)==null?void 0:T.name)==="TimeoutError"||((X=g==null?void 0:g.payload)==null?void 0:X.name)==="Error"||((q=g==null?void 0:g.payload)==null?void 0:q.name)==="Unknown error")&&(D=!0);const x=new Je.CodegenError({name:(H=g==null?void 0:g.payload.name)!=null?H:"Unknown error",reason:(ee=g==null?void 0:g.payload.message)!=null?ee:"Unknown",status:g==null?void 0:g.payload.status,detail:g==null?void 0:g.payload.detail});c++;let C=!1;c>Dt?(console.error("Experienced too many errors, terminating request"),C=!0):D&&(console.error("Experienced unrecoverable error, terminating request"),C=!0),C&&(s.status="error",s.error=x,r(j({},s)),E({result:null,error:x}))})),l.addEventListener("done",d=>{const o=JSON.parse(d.data);p.tokenUsage=o.payload.tokenUsage,p.sessionId=o.payload.sessionId,s.status="success",s.result=p,r(j({},s)),E({result:p,error:null})})});try{const{result:E,error:h}=yield f,p=structuredClone(E);if(((w=i.assetsStorage)==null?void 0:w.strategy)==="local"&&((m=p==null?void 0:p.assets)!=null&&m.length)){const{filePath:c}=jt(i.assetsStorage),d=p.assets.map(g=>ae(null,null,function*(){const x=yield(yield fetch(g.url)).arrayBuffer();return{assetName:g.name,base64:Sn(x)}})),o=yield Promise.allSettled(d);for(const g of o){const D={};if(g.status==="fulfilled"){const{assetName:x,base64:C}=g.value;D[x]=C;const V=c?`${c}/${x}`:x;p.files[V]={content:C,isBinary:!0}}}}return h?{result:null,error:h}:{result:p,error:h}}finally{l.close()}});class Bt extends Error{constructor(t,n){super(t),this.name="CreateJobError",this.cause=n}}class Ht extends Error{constructor(){super(""),this.name="UnknownCodegenError"}}const vt=b.createContext(null);function _n({figmaRestApi:e,f2cUrl:t,l2cUrl:n,p2cUrl:r,children:s}){const[i,u]=b.useState({status:"idle"}),l=b.useRef(null),[f,S]=b.useState(gt),w={f2c:t,l2c:n,p2c:r},m=(E,h)=>ae(null,null,function*(){var p;if(i.status==="pending")throw new Error("A job is already in progress");l.current=E;try{const c=w[E],{result:d}=yield Yt(c,"POST",h,o=>S(o));if(d){const o=d.sessionId,g=d.files,D=d.assets;u(x=>({status:"success",type:E,params:"params"in x?x.params:{},sessionId:o,payload:f.jobStatus,assets:D,files:g,progressMessages:f.progressMessages}));return}}catch(c){l.current=null;const d=c instanceof Error?c.message:"Unknown error",o=new Bt(d,c);throw u({status:"error",type:E,params:h,error:o,sessionId:(p=f.jobSessionId)!=null?p:null,payload:f.jobStatus,progressMessages:f.progressMessages}),o}});return b.useEffect(()=>{var h;if(!l.current)return;const E=l.current;if(f.status==="error"){const p=(h=f.error)!=null?h:new Ht;u(c=>{var d;return{status:"error",type:E,params:"params"in c?c.params:{},error:p,sessionId:(d=f.jobSessionId)!=null?d:null,payload:f.jobStatus,progressMessages:f.progressMessages}});return}if(f.status==="pending"){u(p=>({status:"pending",type:E,params:"params"in p?p.params:{},sessionId:f.jobSessionId,payload:f.jobStatus,progressMessages:f.progressMessages}));return}},[f]),pn.jsx(vt.Provider,{value:{createJob:m,job:i,figmaRestApi:e},children:s})}function zt(){const e=b.useContext(vt);if(!e)throw new Error("useAnimaSDK must be used within AnimaSDKProvider");return e}const wn=({url:e,method:t="POST"})=>{const[n,r]=b.useState(gt);return{getCode:b.useCallback(i=>Yt(e,t,i,r),[e,t]),status:n.status,progressMessages:n.progressMessages,jobSessionId:n.jobSessionId,jobStatus:n.jobStatus,tasks:n.tasks,error:n.error,result:n.result}};var Pe={exports:{}},Ye={};/**
27
27
  * @license React
28
28
  * use-sync-external-store-shim.production.js
29
29
  *
@@ -31,7 +31,7 @@ React keys must be passed directly to JSX without using spread:
31
31
  *
32
32
  * This source code is licensed under the MIT license found in the
33
33
  * LICENSE file in the root directory of this source tree.
34
- */var Pt;function Rn(){if(Pt)return Ye;Pt=1;var e=b;function t(E,p){return E===p&&(E!==0||1/E===1/p)||E!==E&&p!==p}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,s=e.useEffect,c=e.useLayoutEffect,l=e.useDebugValue;function a(E,p){var d=p(),h=r({inst:{value:d,getSnapshot:p}}),u=h[0].inst,f=h[1];return c(function(){u.value=d,u.getSnapshot=p,m(u)&&f({inst:u})},[E,d,p]),s(function(){return m(u)&&f({inst:u}),E(function(){m(u)&&f({inst:u})})},[E]),l(d),d}function m(E){var p=E.getSnapshot;E=E.value;try{var d=p();return!n(E,d)}catch(h){return!0}}function S(E,p){return p()}var w=typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"?S:a;return Ye.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:w,Ye}var Be={};/**
34
+ */var Pt;function Rn(){if(Pt)return Ye;Pt=1;var e=b;function t(m,E){return m===E&&(m!==0||1/m===1/E)||m!==m&&E!==E}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,s=e.useEffect,i=e.useLayoutEffect,u=e.useDebugValue;function l(m,E){var h=E(),p=r({inst:{value:h,getSnapshot:E}}),c=p[0].inst,d=p[1];return i(function(){c.value=h,c.getSnapshot=E,f(c)&&d({inst:c})},[m,h,E]),s(function(){return f(c)&&d({inst:c}),m(function(){f(c)&&d({inst:c})})},[m]),u(h),h}function f(m){var E=m.getSnapshot;m=m.value;try{var h=E();return!n(m,h)}catch(p){return!0}}function S(m,E){return E()}var w=typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"?S:l;return Ye.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:w,Ye}var Be={};/**
35
35
  * @license React
36
36
  * use-sync-external-store-shim.development.js
37
37
  *
@@ -39,5 +39,5 @@ React keys must be passed directly to JSX without using spread:
39
39
  *
40
40
  * This source code is licensed under the MIT license found in the
41
41
  * LICENSE file in the root directory of this source tree.
42
- */var Mt;function On(){return Mt||(Mt=1,process.env.NODE_ENV!=="production"&&(function(){function e(d,h){return d===h&&(d!==0||1/d===1/h)||d!==d&&h!==h}function t(d,h){w||s.startTransition===void 0||(w=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var u=h();if(!E){var f=h();c(u,f)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),E=!0)}f=l({inst:{value:u,getSnapshot:h}});var i=f[0].inst,g=f[1];return m(function(){i.value=u,i.getSnapshot=h,n(i)&&g({inst:i})},[d,u,h]),a(function(){return n(i)&&g({inst:i}),d(function(){n(i)&&g({inst:i})})},[d]),S(u),u}function n(d){var h=d.getSnapshot;d=d.value;try{var u=h();return!c(d,u)}catch(f){return!0}}function r(d,h){return h()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var s=b,c=typeof Object.is=="function"?Object.is:e,l=s.useState,a=s.useEffect,m=s.useLayoutEffect,S=s.useDebugValue,w=!1,E=!1,p=typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"?r:t;Be.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:p,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Be}var Ft;function bn(){return Ft||(Ft=1,process.env.NODE_ENV==="production"?Pe.exports=Rn():Pe.exports=On()),Pe.exports}var yn=bn();const zt=0,Kt=1,Xt=2,Wt=3;var Vt=Object.prototype.hasOwnProperty;function ct(e,t){var n,r;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&ct(e[r],t[r]););return r===-1}if(!n||typeof e=="object"){r=0;for(n in e)if(Vt.call(e,n)&&++r&&!Vt.call(t,n)||!(n in t)||!ct(e[n],t[n]))return!1;return Object.keys(t).length===r}}return e!==e&&t!==t}const ce=new WeakMap,de=()=>{},$=de(),ut=Object,R=e=>e===$,te=e=>typeof e=="function",he=(e,t)=>j(j({},e),t),Zt=e=>te(e.then),He={},Me={},St="undefined",Ie=typeof window!=St,lt=typeof document!=St,Tn=Ie&&"Deno"in window,Cn=()=>Ie&&typeof window.requestAnimationFrame!=St,Qt=(e,t)=>{const n=ce.get(e);return[()=>!R(t)&&e.get(t)||He,r=>{if(!R(t)){const s=e.get(t);t in Me||(Me[t]=s),n[5](t,he(s,r),s||He)}},n[6],()=>!R(t)&&t in Me?Me[t]:!R(t)&&e.get(t)||He]};let ft=!0;const An=()=>ft,[dt,ht]=Ie&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[de,de],Ln=()=>{const e=lt&&document.visibilityState;return R(e)||e!=="hidden"},kn=e=>(lt&&document.addEventListener("visibilitychange",e),dt("focus",e),()=>{lt&&document.removeEventListener("visibilitychange",e),ht("focus",e)}),Nn=e=>{const t=()=>{ft=!0,e()},n=()=>{ft=!1};return dt("online",t),dt("offline",n),()=>{ht("online",t),ht("offline",n)}},xn={isOnline:An,isVisible:Ln},In={initFocus:kn,initReconnect:Nn},$t=!b.useId,xe=!Ie||Tn,Dn=e=>Cn()?window.requestAnimationFrame(e):setTimeout(e,1),ze=xe?b.useEffect:b.useLayoutEffect,Ke=typeof navigator!="undefined"&&navigator.connection,Ut=!xe&&Ke&&(["slow-2g","2g"].includes(Ke.effectiveType)||Ke.saveData),Fe=new WeakMap,jn=e=>ut.prototype.toString.call(e),Xe=(e,t)=>e===`[object ${t}]`;let Pn=0;const pt=e=>{const t=typeof e,n=jn(e),r=Xe(n,"Date"),s=Xe(n,"RegExp"),c=Xe(n,"Object");let l,a;if(ut(e)===e&&!r&&!s){if(l=Fe.get(e),l)return l;if(l=++Pn+"~",Fe.set(e,l),Array.isArray(e)){for(l="@",a=0;a<e.length;a++)l+=pt(e[a])+",";Fe.set(e,l)}if(c){l="#";const m=ut.keys(e).sort();for(;!R(a=m.pop());)R(e[a])||(l+=a+":"+pt(e[a])+",");Fe.set(e,l)}}else l=r?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return l},_t=e=>{if(te(e))try{e=e()}catch(n){e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?pt(e):"",[e,t]};let Mn=0;const Et=()=>++Mn;function en(...e){return ae(this,null,function*(){const[t,n,r,s]=e,c=he({populateCache:!0,throwOnError:!0},typeof s=="boolean"?{revalidate:s}:s||{});let l=c.populateCache;const a=c.rollbackOnError;let m=c.optimisticData;const S=p=>typeof a=="function"?a(p):a!==!1,w=c.throwOnError;if(te(n)){const p=n,d=[],h=t.keys();for(const u of h)!/^\$(inf|sub)\$/.test(u)&&p(t.get(u)._k)&&d.push(u);return Promise.all(d.map(E))}return E(n);function E(p){return ae(this,null,function*(){const[d]=_t(p);if(!d)return;const[h,u]=Qt(t,d),[f,i,g,I]=ce.get(t),D=()=>{const A=f[d];return(te(c.revalidate)?c.revalidate(h().data,p):c.revalidate!==!1)&&(delete g[d],delete I[d],A&&A[0])?A[0](Xt).then(()=>h().data):h().data};if(e.length<3)return D();let C=r,V,U=!1;const T=Et();i[d]=[T,0];const X=!R(m),q=h(),H=q.data,ee=q._c,J=R(ee)?H:ee;if(X&&(m=te(m)?m(J,H):m,u({data:m,_c:J})),te(C))try{C=C(J)}catch(A){V=A,U=!0}if(C&&Zt(C))if(C=yield C.catch(A=>{V=A,U=!0}),T!==i[d][0]){if(U)throw V;return C}else U&&X&&S(V)&&(l=!0,u({data:J,_c:$}));if(l&&!U)if(te(l)){const A=l(C,J);u({data:A,error:$,_c:$})}else u({data:C,error:$,_c:$});if(i[d][1]=Et(),Promise.resolve(D()).then(()=>{u({_c:$})}),U){if(w)throw V;return}return C})}})}const qt=(e,t)=>{for(const n in e)e[n][0]&&e[n][0](t)},Fn=(e,t)=>{if(!ce.has(e)){const n=he(In,t),r=Object.create(null),s=en.bind($,e);let c=de;const l=Object.create(null),a=(w,E)=>{const p=l[w]||[];return l[w]=p,p.push(E),()=>p.splice(p.indexOf(E),1)},m=(w,E,p)=>{e.set(w,E);const d=l[w];if(d)for(const h of d)h(E,p)},S=()=>{if(!ce.has(e)&&(ce.set(e,[r,Object.create(null),Object.create(null),Object.create(null),s,m,a]),!xe)){const w=n.initFocus(setTimeout.bind($,qt.bind($,r,zt))),E=n.initReconnect(setTimeout.bind($,qt.bind($,r,Kt)));c=()=>{w&&w(),E&&E(),ce.delete(e)}}};return S(),[e,s,S,c]}return[e,ce.get(e)[4]]},Wn=(e,t,n,r,s)=>{const c=n.errorRetryCount,l=s.retryCount,a=~~((Math.random()+.5)*(1<<(l<8?l:8)))*n.errorRetryInterval;!R(c)&&l>c||setTimeout(r,a,s)},Vn=ct,[tn,$n]=Fn(new Map),Un=he({onLoadingSlow:de,onSuccess:de,onError:de,onErrorRetry:Wn,onDiscarded:de,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Ut?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Ut?5e3:3e3,compare:Vn,isPaused:()=>!1,cache:tn,mutate:$n,fallback:{}},xn),qn=(e,t)=>{const n=he(e,t);if(t){const{use:r,fallback:s}=e,{use:c,fallback:l}=t;r&&c&&(n.use=r.concat(c)),s&&l&&(n.fallback=he(s,l))}return n},Jn=b.createContext({}),Gn="$inf$",nn=Ie&&window.__SWR_DEVTOOLS_USE__,Yn=nn?window.__SWR_DEVTOOLS_USE__:[],Bn=()=>{nn&&(window.__SWR_DEVTOOLS_REACT__=b)},Hn=e=>te(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],zn=()=>{const e=b.useContext(Jn);return b.useMemo(()=>he(Un,e),[e])},Kn=e=>(t,n,r)=>e(t,n&&((...c)=>{const[l]=_t(t),[,,,a]=ce.get(tn);if(l.startsWith(Gn))return n(...c);const m=a[l];return R(m)?n(...c):(delete a[l],m)}),r),Xn=Yn.concat(Kn),Zn=e=>function(...n){const r=zn(),[s,c,l]=Hn(n),a=qn(r,l);let m=e;const{use:S}=a,w=(S||[]).concat(Xn);for(let E=w.length;E--;)m=w[E](m);return m(s,c||a.fetcher||null,a)},Qn=(e,t,n)=>{const r=t[e]||(t[e]=[]);return r.push(n),()=>{const s=r.indexOf(n);s>=0&&(r[s]=r[r.length-1],r.pop())}};Bn();const Ze=b.use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e}}),Qe={dedupe:!0},Jt=Promise.resolve($),es=(e,t,n)=>{const{cache:r,compare:s,suspense:c,fallbackData:l,revalidateOnMount:a,revalidateIfStale:m,refreshInterval:S,refreshWhenHidden:w,refreshWhenOffline:E,keepPreviousData:p}=n,[d,h,u,f]=ce.get(r),[i,g]=_t(e),I=b.useRef(!1),D=b.useRef(!1),C=b.useRef(i),V=b.useRef(t),U=b.useRef(n),T=()=>U.current,X=()=>T().isVisible()&&T().isOnline(),[q,H,ee,J]=Qt(r,i),A=b.useRef({}).current,ue=R(l)?R(n.fallback)?$:n.fallback[i]:l,Oe=(y,N)=>{for(const F in A){const L=F;if(L==="data"){if(!s(y[L],N[L])&&(!R(y[L])||!s(G,N[L])))return!1}else if(N[L]!==y[L])return!1}return!0},be=b.useMemo(()=>{const y=!i||!t?!1:R(a)?T().isPaused()||c?!1:m!==!1:a,N=Y=>{const re=he(Y);return delete re._k,y?j({isValidating:!0,isLoading:!0},re):re},F=q(),L=J(),Z=N(F),ge=F===L?Z:N(L);let W=Z;return[()=>{const Y=N(q());return Oe(Y,W)?(W.data=Y.data,W.isLoading=Y.isLoading,W.isValidating=Y.isValidating,W.error=Y.error,W):(W=Y,Y)},()=>ge]},[r,i]),ne=yn.useSyncExternalStore(b.useCallback(y=>ee(i,(N,F)=>{Oe(F,N)||y()}),[r,i]),be[0],be[1]),ye=!I.current,o=d[i]&&d[i].length>0,v=ne.data,O=R(v)?ue&&Zt(ue)?Ze(ue):ue:v,x=ne.error,z=b.useRef(O),G=p?R(v)?R(z.current)?O:z.current:v:O,Ee=o&&!R(x)?!1:ye&&!R(a)?a:T().isPaused()?!1:c?R(O)?!1:m:R(O)||m,me=!!(i&&t&&ye&&Ee),M=R(ne.isValidating)?me:ne.isValidating,le=R(ne.isLoading)?me:ne.isLoading,se=b.useCallback(y=>ae(null,null,function*(){const N=V.current;if(!i||!N||D.current||T().isPaused())return!1;let F,L,Z=!0;const ge=y||{},W=!u[i]||!ge.dedupe,Y=()=>$t?!D.current&&i===C.current&&I.current:i===C.current,re={isValidating:!1,isLoading:!1},wt=()=>{H(re)},Rt=()=>{const K=u[i];K&&K[1]===L&&delete u[i]},Ot={isValidating:!0};R(q().data)&&(Ot.isLoading=!0);try{if(W&&(H(Ot),n.loadingTimeout&&R(q().data)&&setTimeout(()=>{Z&&Y()&&T().onLoadingSlow(i,n)},n.loadingTimeout),u[i]=[N(g),Et()]),[F,L]=u[i],F=yield F,W&&setTimeout(Rt,n.dedupingInterval),!u[i]||u[i][1]!==L)return W&&Y()&&T().onDiscarded(i),!1;re.error=$;const K=h[i];if(!R(K)&&(L<=K[0]||L<=K[1]||K[1]===0))return wt(),W&&Y()&&T().onDiscarded(i),!1;const oe=q().data;re.data=s(oe,F)?oe:F,W&&Y()&&T().onSuccess(F,i,n)}catch(K){Rt();const oe=T(),{shouldRetryOnError:qe}=oe;oe.isPaused()||(re.error=K,W&&Y()&&(oe.onError(K,i,oe),(qe===!0||te(qe)&&qe(K))&&(!T().revalidateOnFocus||!T().revalidateOnReconnect||X())&&oe.onErrorRetry(K,i,oe,sn=>{const Je=d[i];Je&&Je[0]&&Je[0](Wt,sn)},{retryCount:(ge.retryCount||0)+1,dedupe:!0})))}return Z=!1,wt(),!0}),[i,r]),De=b.useCallback((...y)=>en(r,C.current,...y),[]);if(ze(()=>{V.current=t,U.current=n,R(v)||(z.current=v)}),ze(()=>{if(!i)return;const y=se.bind($,Qe);let N=0;T().revalidateOnFocus&&(N=Date.now()+T().focusThrottleInterval);const L=Qn(i,d,(Z,ge={})=>{if(Z==zt){const W=Date.now();T().revalidateOnFocus&&W>N&&X()&&(N=W+T().focusThrottleInterval,y())}else if(Z==Kt)T().revalidateOnReconnect&&X()&&y();else{if(Z==Xt)return se();if(Z==Wt)return se(ge)}});return D.current=!1,C.current=i,I.current=!0,H({_k:g}),Ee&&(u[i]||(R(O)||xe?y():Dn(y))),()=>{D.current=!0,L()}},[i]),ze(()=>{let y;function N(){const L=te(S)?S(q().data):S;L&&y!==-1&&(y=setTimeout(F,L))}function F(){!q().error&&(w||T().isVisible())&&(E||T().isOnline())?se(Qe).then(N):N()}return N(),()=>{y&&(clearTimeout(y),y=-1)}},[S,w,E,i]),b.useDebugValue(G),c){const y=i&&R(O);if(!$t&&xe&&y)throw new Error("Fallback data is required when using Suspense in SSR.");y&&(V.current=t,U.current=n,D.current=!1);const N=f[i],F=!R(N)&&y?De(N):Jt;if(Ze(F),!R(x)&&y)throw x;const L=y?se(Qe):Jt;!R(G)&&y&&(L.status="fulfilled",L.value=!0),Ze(L)}return{mutate:De,get data(){return A.data=!0,G},get error(){return A.error=!0,x},get isValidating(){return A.isValidating=!0,M},get isLoading(){return A.isLoading=!0,le}}},ts=Zn(es),ns=({fileKey:e,authToken:t,enabled:n=!0,params:r={}})=>{const s=!!(n&&e&&t),{data:c,isLoading:l,error:a}=ts(["useFigmaFile",e,t,r],()=>s?We.getFigmaFile({fileKey:e,authToken:t,params:r}):null,{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1});return{data:c!=null?c:null,isLoading:l,error:a}};exports.AnimaSdkContext=vt;exports.AnimaSdkProvider=Sn;exports.CreateJobError=Bt;exports.UnknownCodegenError=Ht;exports.useAnimaCodegen=wn;exports.useAnimaSDK=_n;exports.useFigmaFile=ns;
42
+ */var Mt;function On(){return Mt||(Mt=1,process.env.NODE_ENV!=="production"&&(function(){function e(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}function t(h,p){w||s.startTransition===void 0||(w=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var c=p();if(!m){var d=p();i(c,d)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),m=!0)}d=u({inst:{value:c,getSnapshot:p}});var o=d[0].inst,g=d[1];return f(function(){o.value=c,o.getSnapshot=p,n(o)&&g({inst:o})},[h,c,p]),l(function(){return n(o)&&g({inst:o}),h(function(){n(o)&&g({inst:o})})},[h]),S(c),c}function n(h){var p=h.getSnapshot;h=h.value;try{var c=p();return!i(h,c)}catch(d){return!0}}function r(h,p){return p()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var s=b,i=typeof Object.is=="function"?Object.is:e,u=s.useState,l=s.useEffect,f=s.useLayoutEffect,S=s.useDebugValue,w=!1,m=!1,E=typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"?r:t;Be.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:E,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Be}var Ft;function bn(){return Ft||(Ft=1,process.env.NODE_ENV==="production"?Pe.exports=Rn():Pe.exports=On()),Pe.exports}var yn=bn();const Kt=0,Xt=1,Zt=2,Wt=3;var Vt=Object.prototype.hasOwnProperty;function ct(e,t){var n,r;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&ct(e[r],t[r]););return r===-1}if(!n||typeof e=="object"){r=0;for(n in e)if(Vt.call(e,n)&&++r&&!Vt.call(t,n)||!(n in t)||!ct(e[n],t[n]))return!1;return Object.keys(t).length===r}}return e!==e&&t!==t}const ce=new WeakMap,fe=()=>{},$=fe(),ut=Object,R=e=>e===$,te=e=>typeof e=="function",he=(e,t)=>j(j({},e),t),Qt=e=>te(e.then),He={},Me={},St="undefined",Ie=typeof window!=St,lt=typeof document!=St,Tn=Ie&&"Deno"in window,Cn=()=>Ie&&typeof window.requestAnimationFrame!=St,en=(e,t)=>{const n=ce.get(e);return[()=>!R(t)&&e.get(t)||He,r=>{if(!R(t)){const s=e.get(t);t in Me||(Me[t]=s),n[5](t,he(s,r),s||He)}},n[6],()=>!R(t)&&t in Me?Me[t]:!R(t)&&e.get(t)||He]};let dt=!0;const An=()=>dt,[ft,ht]=Ie&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[fe,fe],Ln=()=>{const e=lt&&document.visibilityState;return R(e)||e!=="hidden"},kn=e=>(lt&&document.addEventListener("visibilitychange",e),ft("focus",e),()=>{lt&&document.removeEventListener("visibilitychange",e),ht("focus",e)}),Nn=e=>{const t=()=>{dt=!0,e()},n=()=>{dt=!1};return ft("online",t),ft("offline",n),()=>{ht("online",t),ht("offline",n)}},xn={isOnline:An,isVisible:Ln},In={initFocus:kn,initReconnect:Nn},$t=!b.useId,xe=!Ie||Tn,Dn=e=>Cn()?window.requestAnimationFrame(e):setTimeout(e,1),ze=xe?b.useEffect:b.useLayoutEffect,Ke=typeof navigator!="undefined"&&navigator.connection,Ut=!xe&&Ke&&(["slow-2g","2g"].includes(Ke.effectiveType)||Ke.saveData),Fe=new WeakMap,jn=e=>ut.prototype.toString.call(e),Xe=(e,t)=>e===`[object ${t}]`;let Pn=0;const pt=e=>{const t=typeof e,n=jn(e),r=Xe(n,"Date"),s=Xe(n,"RegExp"),i=Xe(n,"Object");let u,l;if(ut(e)===e&&!r&&!s){if(u=Fe.get(e),u)return u;if(u=++Pn+"~",Fe.set(e,u),Array.isArray(e)){for(u="@",l=0;l<e.length;l++)u+=pt(e[l])+",";Fe.set(e,u)}if(i){u="#";const f=ut.keys(e).sort();for(;!R(l=f.pop());)R(e[l])||(u+=l+":"+pt(e[l])+",");Fe.set(e,u)}}else u=r?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return u},_t=e=>{if(te(e))try{e=e()}catch(n){e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?pt(e):"",[e,t]};let Mn=0;const Et=()=>++Mn;function tn(...e){return ae(this,null,function*(){const[t,n,r,s]=e,i=he({populateCache:!0,throwOnError:!0},typeof s=="boolean"?{revalidate:s}:s||{});let u=i.populateCache;const l=i.rollbackOnError;let f=i.optimisticData;const S=E=>typeof l=="function"?l(E):l!==!1,w=i.throwOnError;if(te(n)){const E=n,h=[],p=t.keys();for(const c of p)!/^\$(inf|sub)\$/.test(c)&&E(t.get(c)._k)&&h.push(c);return Promise.all(h.map(m))}return m(n);function m(E){return ae(this,null,function*(){const[h]=_t(E);if(!h)return;const[p,c]=en(t,h),[d,o,g,D]=ce.get(t),x=()=>{const A=d[h];return(te(i.revalidate)?i.revalidate(p().data,E):i.revalidate!==!1)&&(delete g[h],delete D[h],A&&A[0])?A[0](Zt).then(()=>p().data):p().data};if(e.length<3)return x();let C=r,V,U=!1;const T=Et();o[h]=[T,0];const X=!R(f),q=p(),H=q.data,ee=q._c,J=R(ee)?H:ee;if(X&&(f=te(f)?f(J,H):f,c({data:f,_c:J})),te(C))try{C=C(J)}catch(A){V=A,U=!0}if(C&&Qt(C))if(C=yield C.catch(A=>{V=A,U=!0}),T!==o[h][0]){if(U)throw V;return C}else U&&X&&S(V)&&(u=!0,c({data:J,_c:$}));if(u&&!U)if(te(u)){const A=u(C,J);c({data:A,error:$,_c:$})}else c({data:C,error:$,_c:$});if(o[h][1]=Et(),Promise.resolve(x()).then(()=>{c({_c:$})}),U){if(w)throw V;return}return C})}})}const qt=(e,t)=>{for(const n in e)e[n][0]&&e[n][0](t)},Fn=(e,t)=>{if(!ce.has(e)){const n=he(In,t),r=Object.create(null),s=tn.bind($,e);let i=fe;const u=Object.create(null),l=(w,m)=>{const E=u[w]||[];return u[w]=E,E.push(m),()=>E.splice(E.indexOf(m),1)},f=(w,m,E)=>{e.set(w,m);const h=u[w];if(h)for(const p of h)p(m,E)},S=()=>{if(!ce.has(e)&&(ce.set(e,[r,Object.create(null),Object.create(null),Object.create(null),s,f,l]),!xe)){const w=n.initFocus(setTimeout.bind($,qt.bind($,r,Kt))),m=n.initReconnect(setTimeout.bind($,qt.bind($,r,Xt)));i=()=>{w&&w(),m&&m(),ce.delete(e)}}};return S(),[e,s,S,i]}return[e,ce.get(e)[4]]},Wn=(e,t,n,r,s)=>{const i=n.errorRetryCount,u=s.retryCount,l=~~((Math.random()+.5)*(1<<(u<8?u:8)))*n.errorRetryInterval;!R(i)&&u>i||setTimeout(r,l,s)},Vn=ct,[nn,$n]=Fn(new Map),Un=he({onLoadingSlow:fe,onSuccess:fe,onError:fe,onErrorRetry:Wn,onDiscarded:fe,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Ut?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Ut?5e3:3e3,compare:Vn,isPaused:()=>!1,cache:nn,mutate:$n,fallback:{}},xn),qn=(e,t)=>{const n=he(e,t);if(t){const{use:r,fallback:s}=e,{use:i,fallback:u}=t;r&&i&&(n.use=r.concat(i)),s&&u&&(n.fallback=he(s,u))}return n},Jn=b.createContext({}),Gn="$inf$",sn=Ie&&window.__SWR_DEVTOOLS_USE__,Yn=sn?window.__SWR_DEVTOOLS_USE__:[],Bn=()=>{sn&&(window.__SWR_DEVTOOLS_REACT__=b)},Hn=e=>te(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],zn=()=>{const e=b.useContext(Jn);return b.useMemo(()=>he(Un,e),[e])},Kn=e=>(t,n,r)=>e(t,n&&((...i)=>{const[u]=_t(t),[,,,l]=ce.get(nn);if(u.startsWith(Gn))return n(...i);const f=l[u];return R(f)?n(...i):(delete l[u],f)}),r),Xn=Yn.concat(Kn),Zn=e=>function(...n){const r=zn(),[s,i,u]=Hn(n),l=qn(r,u);let f=e;const{use:S}=l,w=(S||[]).concat(Xn);for(let m=w.length;m--;)f=w[m](f);return f(s,i||l.fetcher||null,l)},Qn=(e,t,n)=>{const r=t[e]||(t[e]=[]);return r.push(n),()=>{const s=r.indexOf(n);s>=0&&(r[s]=r[r.length-1],r.pop())}};Bn();const Ze=b.use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e}}),Qe={dedupe:!0},Jt=Promise.resolve($),es=(e,t,n)=>{const{cache:r,compare:s,suspense:i,fallbackData:u,revalidateOnMount:l,revalidateIfStale:f,refreshInterval:S,refreshWhenHidden:w,refreshWhenOffline:m,keepPreviousData:E}=n,[h,p,c,d]=ce.get(r),[o,g]=_t(e),D=b.useRef(!1),x=b.useRef(!1),C=b.useRef(o),V=b.useRef(t),U=b.useRef(n),T=()=>U.current,X=()=>T().isVisible()&&T().isOnline(),[q,H,ee,J]=en(r,o),A=b.useRef({}).current,ue=R(u)?R(n.fallback)?$:n.fallback[o]:u,Oe=(y,N)=>{for(const F in A){const L=F;if(L==="data"){if(!s(y[L],N[L])&&(!R(y[L])||!s(G,N[L])))return!1}else if(N[L]!==y[L])return!1}return!0},be=b.useMemo(()=>{const y=!o||!t?!1:R(l)?T().isPaused()||i?!1:f!==!1:l,N=Y=>{const re=he(Y);return delete re._k,y?j({isValidating:!0,isLoading:!0},re):re},F=q(),L=J(),Z=N(F),ge=F===L?Z:N(L);let W=Z;return[()=>{const Y=N(q());return Oe(Y,W)?(W.data=Y.data,W.isLoading=Y.isLoading,W.isValidating=Y.isValidating,W.error=Y.error,W):(W=Y,Y)},()=>ge]},[r,o]),ne=yn.useSyncExternalStore(b.useCallback(y=>ee(o,(N,F)=>{Oe(F,N)||y()}),[r,o]),be[0],be[1]),ye=!D.current,a=h[o]&&h[o].length>0,v=ne.data,O=R(v)?ue&&Qt(ue)?Ze(ue):ue:v,I=ne.error,z=b.useRef(O),G=E?R(v)?R(z.current)?O:z.current:v:O,Ee=a&&!R(I)?!1:ye&&!R(l)?l:T().isPaused()?!1:i?R(O)?!1:f:R(O)||f,me=!!(o&&t&&ye&&Ee),M=R(ne.isValidating)?me:ne.isValidating,le=R(ne.isLoading)?me:ne.isLoading,se=b.useCallback(y=>ae(null,null,function*(){const N=V.current;if(!o||!N||x.current||T().isPaused())return!1;let F,L,Z=!0;const ge=y||{},W=!c[o]||!ge.dedupe,Y=()=>$t?!x.current&&o===C.current&&D.current:o===C.current,re={isValidating:!1,isLoading:!1},wt=()=>{H(re)},Rt=()=>{const K=c[o];K&&K[1]===L&&delete c[o]},Ot={isValidating:!0};R(q().data)&&(Ot.isLoading=!0);try{if(W&&(H(Ot),n.loadingTimeout&&R(q().data)&&setTimeout(()=>{Z&&Y()&&T().onLoadingSlow(o,n)},n.loadingTimeout),c[o]=[N(g),Et()]),[F,L]=c[o],F=yield F,W&&setTimeout(Rt,n.dedupingInterval),!c[o]||c[o][1]!==L)return W&&Y()&&T().onDiscarded(o),!1;re.error=$;const K=p[o];if(!R(K)&&(L<=K[0]||L<=K[1]||K[1]===0))return wt(),W&&Y()&&T().onDiscarded(o),!1;const oe=q().data;re.data=s(oe,F)?oe:F,W&&Y()&&T().onSuccess(F,o,n)}catch(K){Rt();const oe=T(),{shouldRetryOnError:Ue}=oe;oe.isPaused()||(re.error=K,W&&Y()&&(oe.onError(K,o,oe),(Ue===!0||te(Ue)&&Ue(K))&&(!T().revalidateOnFocus||!T().revalidateOnReconnect||X())&&oe.onErrorRetry(K,o,oe,rn=>{const qe=h[o];qe&&qe[0]&&qe[0](Wt,rn)},{retryCount:(ge.retryCount||0)+1,dedupe:!0})))}return Z=!1,wt(),!0}),[o,r]),De=b.useCallback((...y)=>tn(r,C.current,...y),[]);if(ze(()=>{V.current=t,U.current=n,R(v)||(z.current=v)}),ze(()=>{if(!o)return;const y=se.bind($,Qe);let N=0;T().revalidateOnFocus&&(N=Date.now()+T().focusThrottleInterval);const L=Qn(o,h,(Z,ge={})=>{if(Z==Kt){const W=Date.now();T().revalidateOnFocus&&W>N&&X()&&(N=W+T().focusThrottleInterval,y())}else if(Z==Xt)T().revalidateOnReconnect&&X()&&y();else{if(Z==Zt)return se();if(Z==Wt)return se(ge)}});return x.current=!1,C.current=o,D.current=!0,H({_k:g}),Ee&&(c[o]||(R(O)||xe?y():Dn(y))),()=>{x.current=!0,L()}},[o]),ze(()=>{let y;function N(){const L=te(S)?S(q().data):S;L&&y!==-1&&(y=setTimeout(F,L))}function F(){!q().error&&(w||T().isVisible())&&(m||T().isOnline())?se(Qe).then(N):N()}return N(),()=>{y&&(clearTimeout(y),y=-1)}},[S,w,m,o]),b.useDebugValue(G),i){const y=o&&R(O);if(!$t&&xe&&y)throw new Error("Fallback data is required when using Suspense in SSR.");y&&(V.current=t,U.current=n,x.current=!1);const N=d[o],F=!R(N)&&y?De(N):Jt;if(Ze(F),!R(I)&&y)throw I;const L=y?se(Qe):Jt;!R(G)&&y&&(L.status="fulfilled",L.value=!0),Ze(L)}return{mutate:De,get data(){return A.data=!0,G},get error(){return A.error=!0,I},get isValidating(){return A.isValidating=!0,M},get isLoading(){return A.isLoading=!0,le}}},ts=Zn(es),ns=({fileKey:e,authToken:t,enabled:n=!0,params:r={}})=>{const{figmaRestApi:s}=zt(),i=!!(n&&e&&t),{data:u,isLoading:l,error:f}=ts(["useFigmaFile",e,t,r],()=>i?s.withOptions(t?{token:t}:{}).getFile({fileKey:e,depth:r.depth}):null,{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1});return{data:u!=null?u:null,isLoading:l,error:f}};exports.AnimaSdkContext=vt;exports.AnimaSdkProvider=_n;exports.CreateJobError=Bt;exports.UnknownCodegenError=Ht;exports.useAnimaCodegen=wn;exports.useAnimaSDK=zt;exports.useFigmaFile=ns;
43
43
  //# sourceMappingURL=index.cjs.map