@animaapp/anima-sdk-react 0.6.34 → 0.7.1

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,8 +1,29 @@
1
- "use strict";var ws=Object.defineProperty,ks=Object.defineProperties;var xs=Object.getOwnPropertyDescriptors;var gr=Object.getOwnPropertySymbols;var Es=Object.prototype.hasOwnProperty,Ss=Object.prototype.propertyIsEnumerable;var vr=(n,e,t)=>e in n?ws(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,H=(n,e)=>{for(var t in e||(e={}))Es.call(e,t)&&vr(n,t,e[t]);if(gr)for(var t of gr(e))Ss.call(e,t)&&vr(n,t,e[t]);return n},_r=(n,e)=>ks(n,xs(e));var Pe=(n,e,t)=>new Promise((r,s)=>{var a=c=>{try{o(t.next(c))}catch(u){s(u)}},i=c=>{try{o(t.throw(c))}catch(u){s(u)}},o=c=>c.done?r(c.value):Promise.resolve(c.value).then(a,i);o((t=t.apply(n,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("react");var Os=Object.defineProperty,Ts=Object.defineProperties,As=Object.getOwnPropertyDescriptors,br=Object.getOwnPropertySymbols,Cs=Object.prototype.hasOwnProperty,Rs=Object.prototype.propertyIsEnumerable,wr=(n,e,t)=>e in n?Os(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,d=(n,e)=>{for(var t in e||(e={}))Cs.call(e,t)&&wr(n,t,e[t]);if(br)for(var t of br(e))Rs.call(e,t)&&wr(n,t,e[t]);return n},S=(n,e)=>Ts(n,As(e)),Ee=(n,e,t)=>new Promise((r,s)=>{var a=c=>{try{o(t.next(c))}catch(u){s(u)}},i=c=>{try{o(t.throw(c))}catch(u){s(u)}},o=c=>c.done?r(c.value):Promise.resolve(c.value).then(a,i);o((t=t.apply(n,e)).next())});class ln extends Error{constructor({name:e,reason:t,status:r,detail:s}){super(),this.name=e,this.message=t,this.detail=s,this.status=r}}const js="Figma Token Issue";class Ns extends Error{constructor({fileKey:e,reason:t,cause:r}){super(js),this.fileKey=e,this.reason=t,this.cause=r}}const Is="Rate Limit Exceeded";class Zs extends Error{constructor({fileKey:e,cause:t}){super(Is),this.fileKey=e,this.cause=t}}const Ps="Request Too Large";class Ls extends Error{constructor({fileKey:e,cause:t}){super(Ps),this.fileKey=e,this.cause=t}}const Ms="Not Found";class Ds extends Error{constructor({fileKey:e,cause:t}){super(Ms),this.fileKey=e,this.cause=t}}const $s="Unknown Figma API Exception";class Fs extends Error{constructor({fileKey:e,cause:t}){super($s),this.name="UnknownFigmaApiException",this.fileKey=e,this.cause=t}}const Ws=(n,e)=>{var t;if(((t=n==null?void 0:n.cause)==null?void 0:t.message)==="Fetch Error"){const{err:r,status:s}=n.cause.body;if(s===403)return new Ns({fileKey:e,reason:r,cause:n});if(s===429)return new Zs({fileKey:e,cause:n});if(s===404)return new Ds({fileKey:e,cause:n});if(s===400&&r.includes("Request too large"))return new Ls({fileKey:e,cause:n})}return new Fs({fileKey:e,cause:n})};var Vs=Object.defineProperty,Us=Object.defineProperties,qs=Object.getOwnPropertyDescriptors,kr=Object.getOwnPropertySymbols,Ks=Object.prototype.hasOwnProperty,zs=Object.prototype.propertyIsEnumerable,xr=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),Br=n=>{throw TypeError(n)},Er=(n,e,t)=>e in n?Vs(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,oe=(n,e)=>{for(var t in e||(e={}))Ks.call(e,t)&&Er(n,t,e[t]);if(kr)for(var t of kr(e))zs.call(e,t)&&Er(n,t,e[t]);return n},er=(n,e)=>Us(n,qs(e)),tr=(n,e,t)=>e.has(n)||Br("Cannot "+t),I=(n,e,t)=>(tr(n,e,"read from private field"),t?t.call(n):e.get(n)),he=(n,e,t)=>e.has(n)?Br("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),Q=(n,e,t,r)=>(tr(n,e,"write to private field"),e.set(n,t),t),we=(n,e,t)=>(tr(n,e,"access private method"),t),B=(n,e,t)=>new Promise((r,s)=>{var a=c=>{try{o(t.next(c))}catch(u){s(u)}},i=c=>{try{o(t.throw(c))}catch(u){s(u)}},o=c=>c.done?r(c.value):Promise.resolve(c.value).then(a,i);o((t=t.apply(n,e)).next())}),Bs=(n,e,t)=>(e=n[xr("asyncIterator")])?e.call(n):(n=n[xr("iterator")](),e={},t=(r,s)=>(s=n[r])&&(e[r]=a=>new Promise((i,o,c)=>(a=s.call(n,a),c=a.done,Promise.resolve(a.value).then(u=>i({value:u,done:c}),o)))),t("next"),t("return"),e),Hs=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Gs(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Sn={exports:{}},Js=Sn.exports,Sr;function Xs(){return Sr||(Sr=1,function(n,e){(function(t,r){n.exports=r()})(Js,function(){var t=typeof Promise=="function",r=typeof self=="object"?self:Hs,s=typeof Symbol!="undefined",a=typeof Map!="undefined",i=typeof Set!="undefined",o=typeof WeakMap!="undefined",c=typeof WeakSet!="undefined",u=typeof DataView!="undefined",f=s&&typeof Symbol.iterator!="undefined",p=s&&typeof Symbol.toStringTag!="undefined",w=i&&typeof Set.prototype.entries=="function",_=a&&typeof Map.prototype.entries=="function",b=w&&Object.getPrototypeOf(new Set().entries()),m=_&&Object.getPrototypeOf(new Map().entries()),v=f&&typeof Array.prototype[Symbol.iterator]=="function",h=v&&Object.getPrototypeOf([][Symbol.iterator]()),x=f&&typeof String.prototype[Symbol.iterator]=="function",L=x&&Object.getPrototypeOf(""[Symbol.iterator]()),V=8,$=-1;function z(M){var Z=typeof M;if(Z!=="object")return Z;if(M===null)return"null";if(M===r)return"global";if(Array.isArray(M)&&(p===!1||!(Symbol.toStringTag in M)))return"Array";if(typeof window=="object"&&window!==null){if(typeof window.location=="object"&&M===window.location)return"Location";if(typeof window.document=="object"&&M===window.document)return"Document";if(typeof window.navigator=="object"){if(typeof window.navigator.mimeTypes=="object"&&M===window.navigator.mimeTypes)return"MimeTypeArray";if(typeof window.navigator.plugins=="object"&&M===window.navigator.plugins)return"PluginArray"}if((typeof window.HTMLElement=="function"||typeof window.HTMLElement=="object")&&M instanceof window.HTMLElement){if(M.tagName==="BLOCKQUOTE")return"HTMLQuoteElement";if(M.tagName==="TD")return"HTMLTableDataCellElement";if(M.tagName==="TH")return"HTMLTableHeaderCellElement"}}var ue=p&&M[Symbol.toStringTag];if(typeof ue=="string")return ue;var P=Object.getPrototypeOf(M);return P===RegExp.prototype?"RegExp":P===Date.prototype?"Date":t&&P===Promise.prototype?"Promise":i&&P===Set.prototype?"Set":a&&P===Map.prototype?"Map":c&&P===WeakSet.prototype?"WeakSet":o&&P===WeakMap.prototype?"WeakMap":u&&P===DataView.prototype?"DataView":a&&P===m?"Map Iterator":i&&P===b?"Set Iterator":v&&P===h?"Array Iterator":x&&P===L?"String Iterator":P===null?"Object":Object.prototype.toString.call(M).slice(V,$)}return z})}(Sn)),Sn.exports}var Ys=Xs();const Qs=Gs(Ys),nr=typeof Buffer!="undefined",ea=nr&&typeof Buffer.from!="undefined",ta=nr?function(n){return Buffer.isBuffer(n)}:function(){return!1},na=ea?function(n){return Buffer.from(n)}:nr?function(n){return new Buffer(n)}:function(n){return n};function ut(n){return ta(n)?"Buffer":Qs(n)}const ra=new Set(["Arguments","Array","Map","Object","Set"]);function sa(n,e,t=null){switch(t||ut(n)){case"Arguments":case"Array":case"Object":return n[e];case"Map":return n.get(e);case"Set":return e}}function On(n){return ra.has(n)}function Or(n,e,t,r=null){switch(r||ut(n)){case"Arguments":case"Array":case"Object":n[e]=t;break;case"Map":n.set(e,t);break;case"Set":n.add(t);break}return n}const aa=typeof globalThis!="undefined"&&globalThis!==null&&globalThis.Object===Object&&globalThis,ia=typeof global!="undefined"&&global!==null&&global.Object===Object&&global,oa=typeof self!="undefined"&&self!==null&&self.Object===Object&&self,hn=aa||ia||oa||Function("return this")();function ca(n){return n.slice(0)}function ua(n){return new Boolean(n.valueOf())}function da(n){return new DataView(n.buffer)}function la(n){return na(n)}function ha(n){return new Date(n.getTime())}function fa(n){return new Number(n)}function pa(n){return new RegExp(n.source,n.flags)}function ma(n){return new String(n)}function Re(n,e){return hn[e].from?hn[e].from(n):new hn[e](n)}function ne(n){return n}function Tr(){return[]}function ya(){return new Map}function ga(){return{}}function va(){return new Set}const _a=new Map([["ArrayBuffer",ca],["Boolean",ua],["Buffer",la],["DataView",da],["Date",ha],["Number",fa],["RegExp",pa],["String",ma],["Float32Array",Re],["Float64Array",Re],["Int16Array",Re],["Int32Array",Re],["Int8Array",Re],["Uint16Array",Re],["Uint32Array",Re],["Uint8Array",Re],["Uint8ClampedArray",Re],["Array Iterator",ne],["Map Iterator",ne],["Promise",ne],["Set Iterator",ne],["String Iterator",ne],["function",ne],["global",ne],["WeakMap",ne],["WeakSet",ne],["boolean",ne],["null",ne],["number",ne],["string",ne],["symbol",ne],["undefined",ne],["Arguments",Tr],["Array",Tr],["Map",ya],["Object",ga],["Set",va]]);function ba(){}function Tn(n,e=null,t=ba){arguments.length===2&&typeof e=="function"&&(t=e,e=null);const r=e||ut(n),s=_a.get(r);if(r==="Object"){const a=t(n,r);if(a!==void 0)return a}return s?s(n,r):n}function pt(n,e={}){typeof e=="function"&&(e={customizer:e});const{customizer:t}=e,r=ut(n);if(!On(r))return An(n,null,null,null);const s=Tn(n,r,t),a=new WeakMap([[n,s]]),i=new WeakSet([n]);return An(n,s,a,i)}function An(n,e,t,r,s){const a=ut(n),i=Tn(n,a);if(!On(a))return i;let o;switch(a){case"Arguments":case"Array":o=Object.keys(n);break;case"Object":o=Object.keys(n),o.push(...Object.getOwnPropertySymbols(n));break;case"Map":case"Set":o=n.keys();break}for(let c of o){const u=sa(n,c,a);if(r.has(u))Or(e,c,t.get(u),a);else{const f=ut(u),p=Tn(u,f);On(f)&&(t.set(u,p),r.add(u)),Or(e,c,An(u,p,t,r),a)}}return e}const wa=n=>new Promise(e=>setTimeout(e,n));var zt,ze,Bt,Cn,Hr;class ka{constructor({maxAttempts:e=3,func:t}){he(this,Cn),he(this,zt),he(this,ze),he(this,Bt),Q(this,zt,e),Q(this,Bt,t),Q(this,ze,0)}run(){return B(this,null,function*(){try{return yield I(this,Bt).call(this)}catch(e){if(Q(this,ze,I(this,ze)+1),I(this,ze)>I(this,zt))throw console.error("Max attempts reached"),e;const t=we(this,Cn,Hr).call(this);return yield wa(t),yield this.run()}})}}zt=new WeakMap,ze=new WeakMap,Bt=new WeakMap,Cn=new WeakSet,Hr=function(){return I(this,ze)*1e3*1.5};function xa(){return typeof CompressionStream!="undefined"}function Ea(n){return B(this,null,function*(){const e=new Blob([n]).stream().pipeThrough(new CompressionStream("gzip")),t=[];try{for(var r=Bs(e),s,a,i;s=!(a=yield r.next()).done;s=!1){const o=a.value;t.push(o)}}catch(o){i=[o]}finally{try{s&&(a=r.return)&&(yield a.call(r))}finally{if(i)throw i[0]}}return yield Sa(t)})}function Sa(n){return B(this,null,function*(){const e=yield new Blob(n).arrayBuffer();return new Uint8Array(e)})}class Oa extends Error{constructor({resource:e,api:t,args:r,cause:s}){if(super(`API Error on resource "${e}" at api "${t}"`),this.causeProperties={},this.name="API Error",this.resource=e,this.api=t,this.cause=s,this.args=r,s instanceof Error)for(const[i,o]of Object.entries(s))if(typeof Headers!="undefined"&&o instanceof Headers){const c={};o.forEach((u,f)=>{c[f]=u}),this.causeProperties[i]=c}else this.causeProperties[i]=o;const a=this.causeProperties.body;a&&typeof a=="object"&&"code"in a&&(this.code=a.code)}}class Ar extends Error{constructor({url:e,method:t,statusCode:r,requestHeaders:s,responseHeaders:a,body:i}){if(super("Fetch Error"),this.name="Fetch Error",this.url=e,this.method=t,this.statusNumber=r,this.requestHeaders=s,this.responseHeaders=a,i)try{const o=JSON.parse(i);this.body=o}catch(o){this.body=i}}}class mt extends Error{constructor(e={}){const{canceled:t=!1}=e;super("Abort Error"),this.name="Abort Error",this.canceled=t}}class Ta extends Error{constructor(e){super(`Async API Error: ${JSON.stringify(e)}`),this.name="Async API Error",this.body=e}}class fn extends Error{constructor(e){super(e),this.name="Request Validation Error"}}function Gr(){return Array.from({length:32},()=>Math.floor(Math.random()*256).toString(16).padStart(2,"0")).join("")}function Rn(){return Math.floor(Date.now()/1e3).toString()}const Aa=5*60*1e3,Ca=1*1e3;var Be,ae,_e,jn,Nn,yt;class Ra{constructor({fetch:e=globalThis.fetch.bind(globalThis),baseAddress:t}){he(this,_e),he(this,Be),he(this,ae),this.baseAddress=t,Q(this,Be,e),Q(this,ae,{}),this.plugins=[]}get headers(){throw new Error("Missing implementation")}addPlugin(e){this.plugins.push(e)}removePlugin(e){this.plugins=this.plugins.filter(t=>t.name!==e)}withOptions(e={}){return Q(this,ae,e),this}get(e){return B(this,arguments,function*(t,r={}){const{overrideBaseAddress:s,overrideDefaultHeaders:a}=r,i=s!=null?s:this.baseAddress;let o=a!=null?a:this.headers;const c=pt(I(this,ae));return Q(this,ae,{}),c.extraHeaders&&(o=oe(oe({},o),c.extraHeaders)),c.requestValidation&&(o=er(oe({},o),{"X-Request-Nonce":Gr(),"X-Request-Timestamp":Rn()})),c.async?yield we(this,_e,Nn).call(this,`${i}${t}`,c.async,{headers:o}):yield we(this,_e,jn).call(this,`${i}${t}`,c,{headers:o})})}post(e,t){return B(this,arguments,function*(r,s,a={}){const i=pt(I(this,ae));return Q(this,ae,{}),we(this,_e,yt).call(this,r,"POST",s,a,i)})}put(e,t){return B(this,arguments,function*(r,s,a={}){const i=pt(I(this,ae));return Q(this,ae,{}),we(this,_e,yt).call(this,r,"PUT",s,a,i)})}delete(e,t){return B(this,arguments,function*(r,s,a={}){const i=pt(I(this,ae));return Q(this,ae,{}),we(this,_e,yt).call(this,r,"DELETE",s,a,i)})}patch(e,t){return B(this,arguments,function*(r,s,a={}){const i=pt(I(this,ae));return Q(this,ae,{}),we(this,_e,yt).call(this,r,"PATCH",s,a,i)})}}Be=new WeakMap,ae=new WeakMap,_e=new WeakSet,jn=function(n,e,t){return B(this,null,function*(){const r=()=>B(this,null,function*(){var c,u;try{return yield I(this,Be).call(this,n,oe(oe({},t),e.abortSignal&&{signal:e.abortSignal}))}catch(f){throw f instanceof Error&&f.name==="AbortError"?new mt({canceled:(u=(c=e.abortSignal)==null?void 0:c.aborted)!=null?u:!1}):f}}),{headers:s}=t!=null?t:{},a=(c,u)=>{var f,p;return((f=c==null?void 0:c.headers)==null?void 0:f.get(u))||((p=c==null?void 0:c.headersObject)==null?void 0:p[u])||""},i=c=>B(this,null,function*(){var u;if(!c.ok){const p=yield c.text().catch();throw new Ar({url:n,method:(u=t==null?void 0:t.method)!=null?u:"GET",statusCode:c.status,requestHeaders:s,responseHeaders:c.headers,body:p})}if(e.requestValidation&&process.env.UI_TESTS!==!0)try{const p=a(c,"x-response-nonce"),w=s==null?void 0:s["X-Request-Nonce"];if(!p||p!==w)throw new fn("Response nonce mismatch");const _=Number(a(c,"x-response-timestamp")),b=Number(Rn()),m=60*60*24;if(isNaN(_)||Math.abs(b-_)>m)throw new fn("Invalid response timestamp")}catch(p){const w=p instanceof Error?p.message:"Request validation failed";throw new fn(w)}let f=yield c.text();try{f=JSON.parse(f)}catch(p){}return f});if(e.retry){const c=yield new ka({maxAttempts:e.retry,func:r}).run();return yield i(c)}const o=yield r();return yield i(o)})},Nn=function(n,e,t){return B(this,null,function*(){var r,s;const{onProgress:a,abortSignal:i,pollingInterval:o=()=>Ca,maxTimeout:c=Aa}=e,u=`${n}/async`,f=`${n}/async/job`;let p;try{p=yield I(this,Be).call(this,u,oe(oe({},t),i&&{signal:i}))}catch(b){throw b instanceof Error&&b.name==="AbortError"?new mt({canceled:(r=i==null?void 0:i.aborted)!=null?r:!1}):b}if(!p.ok){const b=yield p.text().catch();throw new Ar({url:n,method:(s=t==null?void 0:t.method)!=null?s:"GET",statusCode:p.status,requestHeaders:this.headers,responseHeaders:p.headers,body:b})}const w=yield p.json(),{job_id:_}=w;if(!_)throw new Error("Job ID not found in response");return new Promise((b,m)=>B(this,null,function*(){const v=setTimeout(()=>{m(new Error("Job timed out"))},c),h=(x=0)=>B(this,null,function*(){if(i!=null&&i.aborted){clearTimeout(v),I(this,Be).call(this,`${f}/${_}/cancel`,{method:"POST",headers:this.headers}).then(()=>{m(new mt({canceled:!0}))}).catch(L=>{m(new mt({canceled:!1}))});return}try{const L=yield(yield I(this,Be).call(this,`${f}/${_}`,{headers:this.headers})).json();if(L.status==="success"){clearTimeout(v);const V=L.response_json;b(V)}else if(L.status==="failed")clearTimeout(v),m(new Ta(L.response_json));else{a&&a(L.response_json);const V=o(x);setTimeout(()=>h(x+1),V)}}catch(L){m(L)}});h()}))})},yt=function(n,e,t,r,s){return B(this,null,function*(){const{overrideBaseAddress:a,overrideDefaultHeaders:i}=r,o=a!=null?a:this.baseAddress;let c=i!=null?i:this.headers;s.extraHeaders&&(c=oe(oe({},c),s.extraHeaders)),s.requestValidation&&(c=er(oe({},c),{"X-Request-Nonce":Gr(),"X-Request-Timestamp":Rn()}));let u=t;return typeof FormData!="undefined"&&t instanceof FormData?delete c["Content-Type"]:(u=r.skipBodyJsonStringify?t:JSON.stringify(t),s.compress&&xa()&&(c["Content-Encoding"]="gzip",u=yield Ea(u))),s.async?yield we(this,_e,Nn).call(this,`${o}${n}`,s.async,{method:e,headers:c,body:u}):yield we(this,_e,jn).call(this,`${o}${n}`,s,{method:e,headers:c,body:u})})};const Cr=(n,e,t,r)=>n instanceof mt?n:new Oa({resource:e,api:String(t),args:r,cause:n}),pn=(n,e)=>new Proxy(e,{get(t,r){return(...s)=>{var a;for(const o of n.plugins){const c=(a=o.beforeApi)==null?void 0:a.call(o,{resource:t.resourceName,api:r,args:s});if(c!==void 0)return c}let i;try{i=t[r](...s)}catch(o){throw Cr(o,t.resourceName,r,s)}return i instanceof Promise?i.catch(o=>{throw Cr(o,t.resourceName,r,s)}):i}}});var gt;class ja{constructor(e){he(this,gt),this.resourceName="Files",Q(this,gt,e)}get(e){return B(this,arguments,function*({fileKey:t,params:r={}}){const s=new URLSearchParams(oe({plugin_data:"857346721138427857"},r)).toString(),a=`v1/files/${t}?${s}`;return yield I(this,gt).get(a)})}getImageFills(e){return B(this,arguments,function*({fileKey:t}){var r,s;const a=`v1/files/${t}/images`;return(s=(r=(yield I(this,gt).get(a)).meta)==null?void 0:r.images)!=null?s:{}})}}gt=new WeakMap;const Na=(n,e,t)=>{const r=e.sort();return`${n}-${r.join("-")}-${t}`},Ia=n=>n?n.ts>Date.now()-1e3*30:!1;var be,In,Jr;class Za{constructor(e){he(this,In),he(this,be),this.resourceName="Images",Q(this,be,e)}get(e){return B(this,arguments,function*({fileKey:t,nodeIds:r,format:s="jpg",scale:a}){const i=Na(t,r,s),o=I(this,be).cache.images.entries.get(i);if(Ia(o))return o.result;o&&I(this,be).cache.images.entries.delete(i);const c=I(this,be).cache.images.pendingRequests.get(i);if(c)return c;const u=we(this,In,Jr).call(this,i,t,r,s,a);I(this,be).cache.images.pendingRequests.set(i,u);try{return yield u}finally{I(this,be).cache.images.pendingRequests.delete(i)}})}}be=new WeakMap,In=new WeakSet,Jr=function(n,e,t,r,s){return B(this,null,function*(){const a=yield I(this,be).get(`v1/images/${e}?ids=${t}&format=${r}${s?`&scale=${s}`:""}`);return I(this,be).cache.images.entries.set(n,{result:a,ts:Date.now()}),a})};var Ht;class Pa{constructor(e){he(this,Ht),this.resourceName="Nodes",Q(this,Ht,e)}get(e){return B(this,arguments,function*({fileKey:t,nodeIds:r,params:s={}}){const a=er(oe({},s),{ids:r.join(",")}),i=new URLSearchParams(oe({plugin_data:"857346721138427857"},a)).toString(),o=`v1/files/${t}/nodes?${i}`;return yield I(this,Ht).get(o)})}}Ht=new WeakMap;var Le;class La extends Ra{constructor({baseAddress:e="https://api.figma.com/",fetch:t=globalThis.fetch.bind(globalThis)}={}){super({fetch:t,baseAddress:e}),he(this,Le,""),this.cache={images:{entries:new Map,pendingRequests:new Map}},this.files=pn(this,new ja(this)),this.nodes=pn(this,new Pa(this)),this.images=pn(this,new Za(this))}set token(e){if(!e.startsWith("figd_")&&!e.startsWith("figu_"))throw new Error("Invalid Figma access token");Q(this,Le,e)}get token(){return I(this,Le)}get headers(){const e={"Content-Type":"application/json"};return I(this,Le).startsWith("figd_")?e["X-FIGMA-TOKEN"]=I(this,Le):I(this,Le).startsWith("figu_")&&(e.Authorization=`Bearer ${I(this,Le)}`),e}}Le=new WeakMap;const Ma=n=>Ee(void 0,[n],function*({fileKey:e,authToken:t,figmaRestApi:r=new La,params:s={},signal:a}){t&&(r.token=t);try{return yield r.withOptions({abortSignal:a}).files.get({fileKey:e,params:s})}catch(i){throw i instanceof Error&&i.name==="AbortError"?i:(console.error(i),Ws(i,e))}});var R;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},n.getValidEnumValues=s=>{const a=n.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return n.objectValues(i)},n.objectValues=s=>n.objectKeys(s).map(function(a){return s[a]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},n.find=(s,a)=>{for(const i of s)if(a(i))return i},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(R||(R={}));var Zn;(function(n){n.mergeShapes=(e,t)=>d(d({},e),t)})(Zn||(Zn={}));const g=R.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ne=n=>{switch(typeof n){case"undefined":return g.undefined;case"string":return g.string;case"number":return isNaN(n)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(n)?g.array:n===null?g.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?g.promise:typeof Map!="undefined"&&n instanceof Map?g.map:typeof Set!="undefined"&&n instanceof Set?g.set:typeof Date!="undefined"&&n instanceof Date?g.date:g.object;default:return g.unknown}},l=R.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Da=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class ce extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},r={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let o=r,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),r}static assert(e){if(!(e instanceof ce))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,R.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}ce.create=n=>new ce(n);const dt=(n,e)=>{let t;switch(n.code){case l.invalid_type:n.received===g.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case l.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,R.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:t=`Unrecognized key(s) in object: ${R.joinValues(n.keys,", ")}`;break;case l.invalid_union:t="Invalid input";break;case l.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${R.joinValues(n.options)}`;break;case l.invalid_enum_value:t=`Invalid enum value. Expected ${R.joinValues(n.options)}, received '${n.received}'`;break;case l.invalid_arguments:t="Invalid function arguments";break;case l.invalid_return_type:t="Invalid function return type";break;case l.invalid_date:t="Invalid date";break;case l.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:R.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case l.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case l.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case l.custom:t="Invalid input";break;case l.invalid_intersection_types:t="Intersection results could not be merged";break;case l.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case l.not_finite:t="Number must be finite";break;default:t=e.defaultError,R.assertNever(n)}return{message:t}};let Xr=dt;function $a(n){Xr=n}function Xt(){return Xr}const Yt=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,a=[...t,...s.path||[]],i=S(d({},s),{path:a});if(s.message!==void 0)return S(d({},s),{path:a,message:s.message});let o="";const c=r.filter(u=>!!u).slice().reverse();for(const u of c)o=u(i,{data:e,defaultError:o}).message;return S(d({},s),{path:a,message:o})},Fa=[];function y(n,e){const t=Xt(),r=Yt({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===dt?void 0:dt].filter(s=>!!s)});n.common.issues.push(r)}class ee{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return O;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static mergeObjectAsync(e,t){return Ee(this,null,function*(){const r=[];for(const s of t){const a=yield s.key,i=yield s.value;r.push({key:a,value:i})}return ee.mergeObjectSync(e,r)})}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return O;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value!="undefined"||s.alwaysSet)&&(r[a.value]=i.value)}return{status:e.value,value:r}}}const O=Object.freeze({status:"aborted"}),Qt=n=>({status:"dirty",value:n}),se=n=>({status:"valid",value:n}),Pn=n=>n.status==="aborted",Ln=n=>n.status==="dirty",Je=n=>n.status==="valid",Et=n=>typeof Promise!="undefined"&&n instanceof Promise;function en(n,e,t,r){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Yr(n,e,t,r,s){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}var k;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(k||(k={}));var vt,_t;class Se{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Rr=(n,e)=>{if(Je(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new ce(n.common.issues);return this._error=t,this._error}}};function T(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,i)=>{var o,c;const{message:u}=n;return a.code==="invalid_enum_value"?{message:u!=null?u:i.defaultError}:typeof i.data=="undefined"?{message:(o=u!=null?u:r)!==null&&o!==void 0?o:i.defaultError}:a.code!=="invalid_type"?{message:i.defaultError}:{message:(c=u!=null?u:t)!==null&&c!==void 0?c:i.defaultError}},description:s}}class A{get description(){return this._def.description}_getType(e){return Ne(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ne(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ee,ctx:{common:e.parent.common,data:e.data,parsedType:Ne(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Et(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ne(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Rr(s,a)}"~validate"(e){var t,r;const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ne(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:s});return Je(a)?{value:a.value}:{issues:s.common.issues}}catch(a){!((r=(t=a==null?void 0:a.message)===null||t===void 0?void 0:t.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:s}).then(a=>Je(a)?{value:a.value}:{issues:s.common.issues})}parseAsync(e,t){return Ee(this,null,function*(){const r=yield this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error})}safeParseAsync(e,t){return Ee(this,null,function*(){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ne(e)},s=this._parse({data:e,path:r.path,parent:r}),a=yield Et(s)?s:Promise.resolve(s);return Rr(r,a)})}refine(e,t){const r=s=>typeof t=="string"||typeof t=="undefined"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue(d({code:l.custom},r(s)));return typeof Promise!="undefined"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new ge({schema:this,typeName:E.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return xe.create(this,this._def)}nullable(){return Ue.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ye.create(this)}promise(){return ht.create(this,this._def)}or(e){return At.create([this,e],this._def)}and(e){return Ct.create(this,e,this._def)}transform(e){return new ge(S(d({},T(this._def)),{schema:this,typeName:E.ZodEffects,effect:{type:"transform",transform:e}}))}default(e){const t=typeof e=="function"?e:()=>e;return new Zt(S(d({},T(this._def)),{innerType:this,defaultValue:t,typeName:E.ZodDefault}))}brand(){return new rr(d({typeName:E.ZodBranded,type:this},T(this._def)))}catch(e){const t=typeof e=="function"?e:()=>e;return new Pt(S(d({},T(this._def)),{innerType:this,catchValue:t,typeName:E.ZodCatch}))}describe(e){const t=this.constructor;return new t(S(d({},this._def),{description:e}))}pipe(e){return Dt.create(this,e)}readonly(){return Lt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Wa=/^c[^\s-]{8,}$/i,Va=/^[0-9a-z]+$/,Ua=/^[0-9A-HJKMNP-TV-Z]{26}$/i,qa=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ka=/^[a-z0-9_-]{21}$/i,za=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ba=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ha=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ga="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let mn;const Ja=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Xa=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Ya=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Qa=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ei=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ti=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Qr="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ni=new RegExp(`^${Qr}$`);function es(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function ri(n){return new RegExp(`^${es(n)}$`)}function ts(n){let e=`${Qr}T${es(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function si(n,e){return!!((e==="v4"||!e)&&Ja.test(n)||(e==="v6"||!e)&&Ya.test(n))}function ai(n,e){if(!za.test(n))return!1;try{const[t]=n.split("."),r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||!s.typ||!s.alg||e&&s.alg!==e)}catch(t){return!1}}function ii(n,e){return!!((e==="v4"||!e)&&Xa.test(n)||(e==="v6"||!e)&&Qa.test(n))}class me extends A{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){const s=this._getOrReturnCtx(e);return y(s,{code:l.invalid_type,expected:g.string,received:s.parsedType}),O}const t=new ee;let r;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(r=this._getOrReturnCtx(e,r),y(r,{code:l.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(r=this._getOrReturnCtx(e,r),y(r,{code:l.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,i=e.data.length<s.value;(a||i)&&(r=this._getOrReturnCtx(e,r),a?y(r,{code:l.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&y(r,{code:l.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")Ha.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"email",code:l.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")mn||(mn=new RegExp(Ga,"u")),mn.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"emoji",code:l.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")qa.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"uuid",code:l.invalid_string,message:s.message}),t.dirty());else if(s.kind==="nanoid")Ka.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"nanoid",code:l.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")Wa.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"cuid",code:l.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")Va.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"cuid2",code:l.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")Ua.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"ulid",code:l.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch(a){r=this._getOrReturnCtx(e,r),y(r,{validation:"url",code:l.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"regex",code:l.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(r=this._getOrReturnCtx(e,r),y(r,{code:l.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(r=this._getOrReturnCtx(e,r),y(r,{code:l.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(r=this._getOrReturnCtx(e,r),y(r,{code:l.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?ts(s).test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{code:l.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="date"?ni.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{code:l.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?ri(s).test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{code:l.invalid_string,validation:"time",message:s.message}),t.dirty()):s.kind==="duration"?Ba.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"duration",code:l.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?si(e.data,s.version)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"ip",code:l.invalid_string,message:s.message}),t.dirty()):s.kind==="jwt"?ai(e.data,s.alg)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"jwt",code:l.invalid_string,message:s.message}),t.dirty()):s.kind==="cidr"?ii(e.data,s.version)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"cidr",code:l.invalid_string,message:s.message}),t.dirty()):s.kind==="base64"?ei.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"base64",code:l.invalid_string,message:s.message}),t.dirty()):s.kind==="base64url"?ti.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"base64url",code:l.invalid_string,message:s.message}),t.dirty()):R.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),d({validation:t,code:l.invalid_string},k.errToObj(r)))}_addCheck(e){return new me(S(d({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(d({kind:"email"},k.errToObj(e)))}url(e){return this._addCheck(d({kind:"url"},k.errToObj(e)))}emoji(e){return this._addCheck(d({kind:"emoji"},k.errToObj(e)))}uuid(e){return this._addCheck(d({kind:"uuid"},k.errToObj(e)))}nanoid(e){return this._addCheck(d({kind:"nanoid"},k.errToObj(e)))}cuid(e){return this._addCheck(d({kind:"cuid"},k.errToObj(e)))}cuid2(e){return this._addCheck(d({kind:"cuid2"},k.errToObj(e)))}ulid(e){return this._addCheck(d({kind:"ulid"},k.errToObj(e)))}base64(e){return this._addCheck(d({kind:"base64"},k.errToObj(e)))}base64url(e){return this._addCheck(d({kind:"base64url"},k.errToObj(e)))}jwt(e){return this._addCheck(d({kind:"jwt"},k.errToObj(e)))}ip(e){return this._addCheck(d({kind:"ip"},k.errToObj(e)))}cidr(e){return this._addCheck(d({kind:"cidr"},k.errToObj(e)))}datetime(e){var t,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck(d({kind:"datetime",precision:typeof(e==null?void 0:e.precision)=="undefined"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1},k.errToObj(e==null?void 0:e.message)))}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck(d({kind:"time",precision:typeof(e==null?void 0:e.precision)=="undefined"?null:e==null?void 0:e.precision},k.errToObj(e==null?void 0:e.message)))}duration(e){return this._addCheck(d({kind:"duration"},k.errToObj(e)))}regex(e,t){return this._addCheck(d({kind:"regex",regex:e},k.errToObj(t)))}includes(e,t){return this._addCheck(d({kind:"includes",value:e,position:t==null?void 0:t.position},k.errToObj(t==null?void 0:t.message)))}startsWith(e,t){return this._addCheck(d({kind:"startsWith",value:e},k.errToObj(t)))}endsWith(e,t){return this._addCheck(d({kind:"endsWith",value:e},k.errToObj(t)))}min(e,t){return this._addCheck(d({kind:"min",value:e},k.errToObj(t)))}max(e,t){return this._addCheck(d({kind:"max",value:e},k.errToObj(t)))}length(e,t){return this._addCheck(d({kind:"length",value:e},k.errToObj(t)))}nonempty(e){return this.min(1,k.errToObj(e))}trim(){return new me(S(d({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}toLowerCase(){return new me(S(d({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new me(S(d({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}me.create=n=>{var e;return new me(d({checks:[],typeName:E.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1},T(n)))};function oi(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,a=parseInt(n.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class Fe extends A{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==g.number){const s=this._getOrReturnCtx(e);return y(s,{code:l.invalid_type,expected:g.number,received:s.parsedType}),O}let t;const r=new ee;for(const s of this._def.checks)s.kind==="int"?R.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),y(t,{code:l.invalid_type,expected:"integer",received:"float",message:s.message}),r.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),y(t,{code:l.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),y(t,{code:l.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="multipleOf"?oi(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),y(t,{code:l.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),y(t,{code:l.not_finite,message:s.message}),r.dirty()):R.assertNever(s);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,r,s){return new Fe(S(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:k.toString(s)}]}))}_addCheck(e){return new Fe(S(d({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:k.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:k.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:k.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:k.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&R.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Fe.create=n=>new Fe(d({checks:[],typeName:E.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1},T(n)));class We extends A{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch(s){return this._getInvalidInput(e)}if(this._getType(e)!==g.bigint)return this._getInvalidInput(e);let t;const r=new ee;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),y(t,{code:l.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),y(t,{code:l.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),y(t,{code:l.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):R.assertNever(s);return{status:r.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return y(t,{code:l.invalid_type,expected:g.bigint,received:t.parsedType}),O}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,r,s){return new We(S(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:k.toString(s)}]}))}_addCheck(e){return new We(S(d({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}We.create=n=>{var e;return new We(d({checks:[],typeName:E.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1},T(n)))};class St extends A{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){const t=this._getOrReturnCtx(e);return y(t,{code:l.invalid_type,expected:g.boolean,received:t.parsedType}),O}return se(e.data)}}St.create=n=>new St(d({typeName:E.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1},T(n)));class Xe extends A{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){const s=this._getOrReturnCtx(e);return y(s,{code:l.invalid_type,expected:g.date,received:s.parsedType}),O}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return y(s,{code:l.invalid_date}),O}const t=new ee;let r;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(r=this._getOrReturnCtx(e,r),y(r,{code:l.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(r=this._getOrReturnCtx(e,r),y(r,{code:l.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):R.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Xe(S(d({},this._def),{checks:[...this._def.checks,e]}))}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:k.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:k.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Xe.create=n=>new Xe(d({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:E.ZodDate},T(n)));class tn extends A{_parse(e){if(this._getType(e)!==g.symbol){const t=this._getOrReturnCtx(e);return y(t,{code:l.invalid_type,expected:g.symbol,received:t.parsedType}),O}return se(e.data)}}tn.create=n=>new tn(d({typeName:E.ZodSymbol},T(n)));class Ot extends A{_parse(e){if(this._getType(e)!==g.undefined){const t=this._getOrReturnCtx(e);return y(t,{code:l.invalid_type,expected:g.undefined,received:t.parsedType}),O}return se(e.data)}}Ot.create=n=>new Ot(d({typeName:E.ZodUndefined},T(n)));class Tt extends A{_parse(e){if(this._getType(e)!==g.null){const t=this._getOrReturnCtx(e);return y(t,{code:l.invalid_type,expected:g.null,received:t.parsedType}),O}return se(e.data)}}Tt.create=n=>new Tt(d({typeName:E.ZodNull},T(n)));class lt extends A{constructor(){super(...arguments),this._any=!0}_parse(e){return se(e.data)}}lt.create=n=>new lt(d({typeName:E.ZodAny},T(n)));class Ge extends A{constructor(){super(...arguments),this._unknown=!0}_parse(e){return se(e.data)}}Ge.create=n=>new Ge(d({typeName:E.ZodUnknown},T(n)));class Ze extends A{_parse(e){const t=this._getOrReturnCtx(e);return y(t,{code:l.invalid_type,expected:g.never,received:t.parsedType}),O}}Ze.create=n=>new Ze(d({typeName:E.ZodNever},T(n)));class nn extends A{_parse(e){if(this._getType(e)!==g.undefined){const t=this._getOrReturnCtx(e);return y(t,{code:l.invalid_type,expected:g.void,received:t.parsedType}),O}return se(e.data)}}nn.create=n=>new nn(d({typeName:E.ZodVoid},T(n)));class ye extends A{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==g.array)return y(t,{code:l.invalid_type,expected:g.array,received:t.parsedType}),O;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(y(t,{code:i?l.too_big:l.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(y(t,{code:l.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(y(t,{code:l.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new Se(t,i,t.path,o)))).then(i=>ee.mergeArray(r,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new Se(t,i,t.path,o)));return ee.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new ye(S(d({},this._def),{minLength:{value:e,message:k.toString(t)}}))}max(e,t){return new ye(S(d({},this._def),{maxLength:{value:e,message:k.toString(t)}}))}length(e,t){return new ye(S(d({},this._def),{exactLength:{value:e,message:k.toString(t)}}))}nonempty(e){return this.min(1,e)}}ye.create=(n,e)=>new ye(d({type:n,minLength:null,maxLength:null,exactLength:null,typeName:E.ZodArray},T(e)));function nt(n){if(n instanceof q){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=xe.create(nt(r))}return new q(S(d({},n._def),{shape:()=>e}))}else return n instanceof ye?new ye(S(d({},n._def),{type:nt(n.element)})):n instanceof xe?xe.create(nt(n.unwrap())):n instanceof Ue?Ue.create(nt(n.unwrap())):n instanceof Oe?Oe.create(n.items.map(e=>nt(e))):n}class q extends A{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=R.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==g.object){const c=this._getOrReturnCtx(e);return y(c,{code:l.invalid_type,expected:g.object,received:c.parsedType}),O}const{status:t,ctx:r}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Ze&&this._def.unknownKeys==="strip"))for(const c in r.data)a.includes(c)||i.push(c);const o=[];for(const c of a){const u=s[c],f=r.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new Se(r,f,r.path,c)),alwaysSet:c in r.data})}if(this._def.catchall instanceof Ze){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of i)o.push({key:{status:"valid",value:u},value:{status:"valid",value:r.data[u]}});else if(c==="strict")i.length>0&&(y(r,{code:l.unrecognized_keys,keys:i}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of i){const f=r.data[u];o.push({key:{status:"valid",value:u},value:c._parse(new Se(r,f,r.path,u)),alwaysSet:u in r.data})}}return r.common.async?Promise.resolve().then(()=>Ee(this,null,function*(){const c=[];for(const u of o){const f=yield u.key,p=yield u.value;c.push({key:f,value:p,alwaysSet:u.alwaysSet})}return c})).then(c=>ee.mergeObjectSync(t,c)):ee.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return k.errToObj,new q(d(S(d({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:(t,r)=>{var s,a,i,o;const c=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,r).message)!==null&&i!==void 0?i:r.defaultError;return t.code==="unrecognized_keys"?{message:(o=k.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}))}strip(){return new q(S(d({},this._def),{unknownKeys:"strip"}))}passthrough(){return new q(S(d({},this._def),{unknownKeys:"passthrough"}))}extend(e){return new q(S(d({},this._def),{shape:()=>d(d({},this._def.shape()),e)}))}merge(e){return new q({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>d(d({},this._def.shape()),e._def.shape()),typeName:E.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new q(S(d({},this._def),{catchall:e}))}pick(e){const t={};return R.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new q(S(d({},this._def),{shape:()=>t}))}omit(e){const t={};return R.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new q(S(d({},this._def),{shape:()=>t}))}deepPartial(){return nt(this)}partial(e){const t={};return R.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new q(S(d({},this._def),{shape:()=>t}))}required(e){const t={};return R.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof xe;)s=s._def.innerType;t[r]=s}}),new q(S(d({},this._def),{shape:()=>t}))}keyof(){return ns(R.objectKeys(this.shape))}}q.create=(n,e)=>new q(d({shape:()=>n,unknownKeys:"strip",catchall:Ze.create(),typeName:E.ZodObject},T(e)));q.strictCreate=(n,e)=>new q(d({shape:()=>n,unknownKeys:"strict",catchall:Ze.create(),typeName:E.ZodObject},T(e)));q.lazycreate=(n,e)=>new q(d({shape:n,unknownKeys:"strip",catchall:Ze.create(),typeName:E.ZodObject},T(e)));class At extends A{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new ce(o.ctx.common.issues));return y(t,{code:l.invalid_union,unionErrors:i}),O}if(t.common.async)return Promise.all(r.map(a=>Ee(this,null,function*(){const i=S(d({},t),{common:S(d({},t.common),{issues:[]}),parent:null});return{result:yield a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}}))).then(s);{let a;const i=[];for(const c of r){const u=S(d({},t),{common:S(d({},t.common),{issues:[]}),parent:null}),f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!a&&(a={result:f,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new ce(c));return y(t,{code:l.invalid_union,unionErrors:o}),O}}get options(){return this._def.options}}At.create=(n,e)=>new At(d({options:n,typeName:E.ZodUnion},T(e)));const Me=n=>n instanceof jt?Me(n.schema):n instanceof ge?Me(n.innerType()):n instanceof Nt?[n.value]:n instanceof Ve?n.options:n instanceof It?R.objectValues(n.enum):n instanceof Zt?Me(n._def.innerType):n instanceof Ot?[void 0]:n instanceof Tt?[null]:n instanceof xe?[void 0,...Me(n.unwrap())]:n instanceof Ue?[null,...Me(n.unwrap())]:n instanceof rr||n instanceof Lt?Me(n.unwrap()):n instanceof Pt?Me(n._def.innerType):[];class on extends A{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.object)return y(t,{code:l.invalid_type,expected:g.object,received:t.parsedType}),O;const r=this.discriminator,s=t.data[r],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(y(t,{code:l.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),O)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const a of t){const i=Me(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new on(d({typeName:E.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s},T(r)))}}function Mn(n,e){const t=Ne(n),r=Ne(e);if(n===e)return{valid:!0,data:n};if(t===g.object&&r===g.object){const s=R.objectKeys(e),a=R.objectKeys(n).filter(o=>s.indexOf(o)!==-1),i=d(d({},n),e);for(const o of a){const c=Mn(n[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===g.array&&r===g.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<n.length;a++){const i=n[a],o=e[a],c=Mn(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===g.date&&r===g.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Ct extends A{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(a,i)=>{if(Pn(a)||Pn(i))return O;const o=Mn(a.value,i.value);return o.valid?((Ln(a)||Ln(i))&&t.dirty(),{status:t.value,value:o.data}):(y(r,{code:l.invalid_intersection_types}),O)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Ct.create=(n,e,t)=>new Ct(d({left:n,right:e,typeName:E.ZodIntersection},T(t)));class Oe extends A{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.array)return y(r,{code:l.invalid_type,expected:g.array,received:r.parsedType}),O;if(r.data.length<this._def.items.length)return y(r,{code:l.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),O;!this._def.rest&&r.data.length>this._def.items.length&&(y(r,{code:l.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...r.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new Se(r,a,r.path,i)):null}).filter(a=>!!a);return r.common.async?Promise.all(s).then(a=>ee.mergeArray(t,a)):ee.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Oe(S(d({},this._def),{rest:e}))}}Oe.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Oe(d({items:n,typeName:E.ZodTuple,rest:null},T(e)))};class Rt extends A{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.object)return y(r,{code:l.invalid_type,expected:g.object,received:r.parsedType}),O;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in r.data)s.push({key:a._parse(new Se(r,o,r.path,o)),value:i._parse(new Se(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?ee.mergeObjectAsync(t,s):ee.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof A?new Rt(d({keyType:e,valueType:t,typeName:E.ZodRecord},T(r))):new Rt(d({keyType:me.create(),valueType:e,typeName:E.ZodRecord},T(t)))}}class rn extends A{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.map)return y(r,{code:l.invalid_type,expected:g.map,received:r.parsedType}),O;const s=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([o,c],u)=>({key:s._parse(new Se(r,o,r.path,[u,"key"])),value:a._parse(new Se(r,c,r.path,[u,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(()=>Ee(this,null,function*(){for(const c of i){const u=yield c.key,f=yield c.value;if(u.status==="aborted"||f.status==="aborted")return O;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}))}else{const o=new Map;for(const c of i){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return O;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}rn.create=(n,e,t)=>new rn(d({valueType:e,keyType:n,typeName:E.ZodMap},T(t)));class Ye extends A{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.set)return y(r,{code:l.invalid_type,expected:g.set,received:r.parsedType}),O;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(y(r,{code:l.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(y(r,{code:l.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const u=new Set;for(const f of c){if(f.status==="aborted")return O;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...r.data.values()].map((c,u)=>a._parse(new Se(r,c,r.path,u)));return r.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new Ye(S(d({},this._def),{minSize:{value:e,message:k.toString(t)}}))}max(e,t){return new Ye(S(d({},this._def),{maxSize:{value:e,message:k.toString(t)}}))}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ye.create=(n,e)=>new Ye(d({valueType:n,minSize:null,maxSize:null,typeName:E.ZodSet},T(e)));class ot extends A{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.function)return y(t,{code:l.invalid_type,expected:g.function,received:t.parsedType}),O;function r(o,c){return Yt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Xt(),dt].filter(u=>!!u),issueData:{code:l.invalid_arguments,argumentsError:c}})}function s(o,c){return Yt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Xt(),dt].filter(u=>!!u),issueData:{code:l.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof ht){const o=this;return se(function(...c){return Ee(this,null,function*(){const u=new ce([]),f=yield o._def.args.parseAsync(c,a).catch(w=>{throw u.addIssue(r(c,w)),u}),p=yield Reflect.apply(i,this,f);return yield o._def.returns._def.type.parseAsync(p,a).catch(w=>{throw u.addIssue(s(p,w)),u})})})}else{const o=this;return se(function(...c){const u=o._def.args.safeParse(c,a);if(!u.success)throw new ce([r(c,u.error)]);const f=Reflect.apply(i,this,u.data),p=o._def.returns.safeParse(f,a);if(!p.success)throw new ce([s(f,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ot(S(d({},this._def),{args:Oe.create(e).rest(Ge.create())}))}returns(e){return new ot(S(d({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new ot(d({args:e||Oe.create([]).rest(Ge.create()),returns:t||Ge.create(),typeName:E.ZodFunction},T(r)))}}class jt extends A{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}jt.create=(n,e)=>new jt(d({getter:n,typeName:E.ZodLazy},T(e)));class Nt extends A{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return y(t,{received:t.data,code:l.invalid_literal,expected:this._def.value}),O}return{status:"valid",value:e.data}}get value(){return this._def.value}}Nt.create=(n,e)=>new Nt(d({value:n,typeName:E.ZodLiteral},T(e)));function ns(n,e){return new Ve(d({values:n,typeName:E.ZodEnum},T(e)))}class Ve extends A{constructor(){super(...arguments),vt.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return y(t,{expected:R.joinValues(r),received:t.parsedType,code:l.invalid_type}),O}if(en(this,vt)||Yr(this,vt,new Set(this._def.values)),!en(this,vt).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return y(t,{received:t.data,code:l.invalid_enum_value,options:r}),O}return se(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Ve.create(e,d(d({},this._def),t))}exclude(e,t=this._def){return Ve.create(this.options.filter(r=>!e.includes(r)),d(d({},this._def),t))}}vt=new WeakMap;Ve.create=ns;class It extends A{constructor(){super(...arguments),_t.set(this,void 0)}_parse(e){const t=R.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==g.string&&r.parsedType!==g.number){const s=R.objectValues(t);return y(r,{expected:R.joinValues(s),received:r.parsedType,code:l.invalid_type}),O}if(en(this,_t)||Yr(this,_t,new Set(R.getValidEnumValues(this._def.values))),!en(this,_t).has(e.data)){const s=R.objectValues(t);return y(r,{received:r.data,code:l.invalid_enum_value,options:s}),O}return se(e.data)}get enum(){return this._def.values}}_t=new WeakMap;It.create=(n,e)=>new It(d({values:n,typeName:E.ZodNativeEnum},T(e)));class ht extends A{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.promise&&t.common.async===!1)return y(t,{code:l.invalid_type,expected:g.promise,received:t.parsedType}),O;const r=t.parsedType===g.promise?t.data:Promise.resolve(t.data);return se(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ht.create=(n,e)=>new ht(d({type:n,typeName:E.ZodPromise},T(e)));class ge extends A{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===E.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{y(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(r.data,a);if(r.common.async)return Promise.resolve(i).then(o=>Ee(this,null,function*(){if(t.value==="aborted")return O;const c=yield this._def.schema._parseAsync({data:o,path:r.path,parent:r});return c.status==="aborted"?O:c.status==="dirty"||t.value==="dirty"?Qt(c.value):c}));{if(t.value==="aborted")return O;const o=this._def.schema._parseSync({data:i,path:r.path,parent:r});return o.status==="aborted"?O:o.status==="dirty"||t.value==="dirty"?Qt(o.value):o}}if(s.type==="refinement"){const i=o=>{const c=s.refinement(o,a);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?O:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?O:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Je(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>Je(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);R.assertNever(s)}}ge.create=(n,e,t)=>new ge(d({schema:n,typeName:E.ZodEffects,effect:e},T(t)));ge.createWithPreprocess=(n,e,t)=>new ge(d({schema:e,effect:{type:"preprocess",transform:n},typeName:E.ZodEffects},T(t)));class xe extends A{_parse(e){return this._getType(e)===g.undefined?se(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}xe.create=(n,e)=>new xe(d({innerType:n,typeName:E.ZodOptional},T(e)));class Ue extends A{_parse(e){return this._getType(e)===g.null?se(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ue.create=(n,e)=>new Ue(d({innerType:n,typeName:E.ZodNullable},T(e)));class Zt extends A{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===g.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Zt.create=(n,e)=>new Zt(d({innerType:n,typeName:E.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default},T(e)));class Pt extends A{_parse(e){const{ctx:t}=this._processInputParams(e),r=S(d({},t),{common:S(d({},t.common),{issues:[]})}),s=this._def.innerType._parse({data:r.data,path:r.path,parent:d({},r)});return Et(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new ce(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ce(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Pt.create=(n,e)=>new Pt(d({innerType:n,typeName:E.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},T(e)));class sn extends A{_parse(e){if(this._getType(e)!==g.nan){const t=this._getOrReturnCtx(e);return y(t,{code:l.invalid_type,expected:g.nan,received:t.parsedType}),O}return{status:"valid",value:e.data}}}sn.create=n=>new sn(d({typeName:E.ZodNaN},T(n)));const ci=Symbol("zod_brand");class rr extends A{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class Dt extends A{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return Ee(this,null,function*(){const s=yield this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?O:s.status==="dirty"?(t.dirty(),Qt(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})});{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?O:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new Dt({in:e,out:t,typeName:E.ZodPipeline})}}class Lt extends A{_parse(e){const t=this._def.innerType._parse(e),r=s=>(Je(s)&&(s.value=Object.freeze(s.value)),s);return Et(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}Lt.create=(n,e)=>new Lt(d({innerType:n,typeName:E.ZodReadonly},T(e)));function jr(n,e){const t=typeof n=="function"?n(e):typeof n=="string"?{message:n}:n;return typeof t=="string"?{message:t}:t}function rs(n,e={},t){return n?lt.create().superRefine((r,s)=>{var a,i;const o=n(r);if(o instanceof Promise)return o.then(c=>{var u,f;if(!c){const p=jr(e,r),w=(f=(u=p.fatal)!==null&&u!==void 0?u:t)!==null&&f!==void 0?f:!0;s.addIssue(S(d({code:"custom"},p),{fatal:w}))}});if(!o){const c=jr(e,r),u=(i=(a=c.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0;s.addIssue(S(d({code:"custom"},c),{fatal:u}))}}):lt.create()}const ui={object:q.lazycreate};var E;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(E||(E={}));const di=(n,e={message:`Input not instance of ${n.name}`})=>rs(t=>t instanceof n,e),ss=me.create,as=Fe.create,li=sn.create,hi=We.create,is=St.create,fi=Xe.create,pi=tn.create,mi=Ot.create,yi=Tt.create,gi=lt.create,vi=Ge.create,_i=Ze.create,bi=nn.create,wi=ye.create,ki=q.create,xi=q.strictCreate,Ei=At.create,Si=on.create,Oi=Ct.create,Ti=Oe.create,Ai=Rt.create,Ci=rn.create,Ri=Ye.create,ji=ot.create,Ni=jt.create,Ii=Nt.create,Zi=Ve.create,Pi=It.create,Li=ht.create,Nr=ge.create,Mi=xe.create,Di=Ue.create,$i=ge.createWithPreprocess,Fi=Dt.create,Wi=()=>ss().optional(),Vi=()=>as().optional(),Ui=()=>is().optional(),qi={string:n=>me.create(S(d({},n),{coerce:!0})),number:n=>Fe.create(S(d({},n),{coerce:!0})),boolean:n=>St.create(S(d({},n),{coerce:!0})),bigint:n=>We.create(S(d({},n),{coerce:!0})),date:n=>Xe.create(S(d({},n),{coerce:!0}))},Ki=O;var N=Object.freeze({__proto__:null,defaultErrorMap:dt,setErrorMap:$a,getErrorMap:Xt,makeIssue:Yt,EMPTY_PATH:Fa,addIssueToContext:y,ParseStatus:ee,INVALID:O,DIRTY:Qt,OK:se,isAborted:Pn,isDirty:Ln,isValid:Je,isAsync:Et,get util(){return R},get objectUtil(){return Zn},ZodParsedType:g,getParsedType:Ne,ZodType:A,datetimeRegex:ts,ZodString:me,ZodNumber:Fe,ZodBigInt:We,ZodBoolean:St,ZodDate:Xe,ZodSymbol:tn,ZodUndefined:Ot,ZodNull:Tt,ZodAny:lt,ZodUnknown:Ge,ZodNever:Ze,ZodVoid:nn,ZodArray:ye,ZodObject:q,ZodUnion:At,ZodDiscriminatedUnion:on,ZodIntersection:Ct,ZodTuple:Oe,ZodRecord:Rt,ZodMap:rn,ZodSet:Ye,ZodFunction:ot,ZodLazy:jt,ZodLiteral:Nt,ZodEnum:Ve,ZodNativeEnum:It,ZodPromise:ht,ZodEffects:ge,ZodTransformer:ge,ZodOptional:xe,ZodNullable:Ue,ZodDefault:Zt,ZodCatch:Pt,ZodNaN:sn,BRAND:ci,ZodBranded:rr,ZodPipeline:Dt,ZodReadonly:Lt,custom:rs,Schema:A,ZodSchema:A,late:ui,get ZodFirstPartyTypeKind(){return E},coerce:qi,any:gi,array:wi,bigint:hi,boolean:is,date:fi,discriminatedUnion:Si,effect:Nr,enum:Zi,function:ji,instanceof:di,intersection:Oi,lazy:Ni,literal:Ii,map:Ci,nan:li,nativeEnum:Pi,never:_i,null:yi,nullable:Di,number:as,object:ki,oboolean:Ui,onumber:Vi,optional:Mi,ostring:Wi,pipeline:Fi,preprocess:$i,promise:Li,record:Ai,set:Ri,strictObject:xi,string:ss,symbol:pi,transformer:Nr,tuple:Ti,undefined:mi,union:Ei,unknown:vi,void:bi,NEVER:Ki,ZodIssueCode:l,quotelessJson:Da,ZodError:ce});N.object({language:N.enum(["typescript","javascript"]).optional(),disableMarkedForExport:N.boolean().optional(),allowAutoSelectFirstNode:N.boolean().optional().default(!0),enableDisplayDataId:N.boolean().optional(),enableDisplayDataName:N.boolean().optional()}).and(N.union([N.object({framework:N.literal("react"),model:N.string().optional(),styling:N.enum(["plain_css","css_modules","styled_components","tailwind","sass","scss","inline_styles"]),uiLibrary:N.enum(["mui","antd","radix","shadcn","clean_react"]).optional(),responsivePages:N.array(N.object({name:N.string(),framesId:N.array(N.string())})).optional(),enableUILibraryTheming:N.boolean().optional(),enableCompactStructure:N.boolean().optional(),enableDisplayScreenModelId:N.boolean().optional(),enableGeneratePackageLock:N.boolean().optional(),enableAnimationsPreset:N.boolean().optional(),enableAutoSplit:N.boolean().optional(),autoSplitThreshold:N.number().optional(),url:N.string().url().optional(),codegenSettings:N.record(N.unknown()).optional()}),N.object({framework:N.literal("html"),styling:N.enum(["plain_css","inline_styles","tailwind"]),enableTranslation:N.boolean().optional()})]));class Ir extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}function yn(n){}function zi(n){if(typeof n=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:e=yn,onError:t=yn,onRetry:r=yn,onComment:s}=n;let a="",i=!0,o,c="",u="";function f(m){const v=i?m.replace(/^\xEF\xBB\xBF/,""):m,[h,x]=Bi(`${a}${v}`);for(const L of h)p(L);a=x,i=!1}function p(m){if(m===""){_();return}if(m.startsWith(":")){s&&s(m.slice(m.startsWith(": ")?2:1));return}const v=m.indexOf(":");if(v!==-1){const h=m.slice(0,v),x=m[v+1]===" "?2:1,L=m.slice(v+x);w(h,L,m);return}w(m,"",m)}function w(m,v,h){switch(m){case"event":u=v;break;case"data":c=`${c}${v}
2
- `;break;case"id":o=v.includes("\0")?void 0:v;break;case"retry":/^\d+$/.test(v)?r(parseInt(v,10)):t(new Ir(`Invalid \`retry\` value: "${v}"`,{type:"invalid-retry",value:v,line:h}));break;default:t(new Ir(`Unknown field "${m.length>20?`${m.slice(0,20)}…`:m}"`,{type:"unknown-field",field:m,value:v,line:h}));break}}function _(){c.length>0&&e({id:o,event:u||void 0,data:c.endsWith(`
3
- `)?c.slice(0,-1):c}),o=void 0,c="",u=""}function b(m={}){a&&m.consume&&p(a),i=!0,o=void 0,c="",u="",a=""}return{feed:f,reset:b}}function Bi(n){const e=[];let t="",r=0;for(;r<n.length;){const s=n.indexOf("\r",r),a=n.indexOf(`
4
- `,r);let i=-1;if(s!==-1&&a!==-1?i=Math.min(s,a):s!==-1?i=s:a!==-1&&(i=a),i===-1){t=n.slice(r);break}else{const o=n.slice(r,i);e.push(o),r=i+1,n[r-1]==="\r"&&n[r]===`
5
- `&&r++}}return[e,t]}class Zr extends Event{constructor(e,t){var r,s;super(e),this.code=(r=t==null?void 0:t.code)!=null?r:void 0,this.message=(s=t==null?void 0:t.message)!=null?s:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,t,r){return r(Pr(this),t)}[Symbol.for("Deno.customInspect")](e,t){return e(Pr(this),t)}}function Hi(n){const e=globalThis.DOMException;return typeof e=="function"?new e(n,"SyntaxError"):new SyntaxError(n)}function Dn(n){return n instanceof Error?"errors"in n&&Array.isArray(n.errors)?n.errors.map(Dn).join(", "):"cause"in n&&n.cause instanceof Error?`${n}: ${Dn(n.cause)}`:n.message:`${n}`}function Pr(n){return{type:n.type,message:n.message,code:n.code,defaultPrevented:n.defaultPrevented,cancelable:n.cancelable,timeStamp:n.timeStamp}}var os=n=>{throw TypeError(n)},sr=(n,e,t)=>e.has(n)||os("Cannot "+t),C=(n,e,t)=>(sr(n,e,"read from private field"),t?t.call(n):e.get(n)),G=(n,e,t)=>e.has(n)?os("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),W=(n,e,t,r)=>(sr(n,e,"write to private field"),e.set(n,t),t),je=(n,e,t)=>(sr(n,e,"access private method"),t),ie,He,rt,Gt,an,kt,it,xt,De,st,ct,at,bt,pe,$n,Fn,Wn,Lr,Vn,Un,wt,qn,Kn;class Jt extends EventTarget{constructor(e,t){var r,s;super(),G(this,pe),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,G(this,ie),G(this,He),G(this,rt),G(this,Gt),G(this,an),G(this,kt),G(this,it),G(this,xt,null),G(this,De),G(this,st),G(this,ct,null),G(this,at,null),G(this,bt,null),G(this,Fn,a=>Pe(this,null,function*(){var i;C(this,st).reset();const{body:o,redirected:c,status:u,headers:f}=a;if(u===204){je(this,pe,wt).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?W(this,rt,new URL(a.url)):W(this,rt,void 0),u!==200){je(this,pe,wt).call(this,`Non-200 status code (${u})`,u);return}if(!(f.get("content-type")||"").startsWith("text/event-stream")){je(this,pe,wt).call(this,'Invalid content type, expected "text/event-stream"',u);return}if(C(this,ie)===this.CLOSED)return;W(this,ie,this.OPEN);const p=new Event("open");if((i=C(this,bt))==null||i.call(this,p),this.dispatchEvent(p),typeof o!="object"||!o||!("getReader"in o)){je(this,pe,wt).call(this,"Invalid response body, expected a web ReadableStream",u),this.close();return}const w=new TextDecoder,_=o.getReader();let b=!0;do{const{done:m,value:v}=yield _.read();v&&C(this,st).feed(w.decode(v,{stream:!m})),m&&(b=!1,C(this,st).reset(),je(this,pe,qn).call(this))}while(b)})),G(this,Wn,a=>{W(this,De,void 0),!(a.name==="AbortError"||a.type==="aborted")&&je(this,pe,qn).call(this,Dn(a))}),G(this,Vn,a=>{typeof a.id=="string"&&W(this,xt,a.id);const i=new MessageEvent(a.event||"message",{data:a.data,origin:C(this,rt)?C(this,rt).origin:C(this,He).origin,lastEventId:a.id||""});C(this,at)&&(!a.event||a.event==="message")&&C(this,at).call(this,i),this.dispatchEvent(i)}),G(this,Un,a=>{W(this,kt,a)}),G(this,Kn,()=>{W(this,it,void 0),C(this,ie)===this.CONNECTING&&je(this,pe,$n).call(this)});try{if(e instanceof URL)W(this,He,e);else if(typeof e=="string")W(this,He,new URL(e,Gi()));else throw new Error("Invalid URL")}catch(a){throw Hi("An invalid or illegal string was specified")}W(this,st,zi({onEvent:C(this,Vn),onRetry:C(this,Un)})),W(this,ie,this.CONNECTING),W(this,kt,3e3),W(this,an,(r=t==null?void 0:t.fetch)!=null?r:globalThis.fetch),W(this,Gt,(s=t==null?void 0:t.withCredentials)!=null?s:!1),je(this,pe,$n).call(this)}get readyState(){return C(this,ie)}get url(){return C(this,He).href}get withCredentials(){return C(this,Gt)}get onerror(){return C(this,ct)}set onerror(e){W(this,ct,e)}get onmessage(){return C(this,at)}set onmessage(e){W(this,at,e)}get onopen(){return C(this,bt)}set onopen(e){W(this,bt,e)}addEventListener(e,t,r){const s=t;super.addEventListener(e,s,r)}removeEventListener(e,t,r){const s=t;super.removeEventListener(e,s,r)}close(){C(this,it)&&clearTimeout(C(this,it)),C(this,ie)!==this.CLOSED&&(C(this,De)&&C(this,De).abort(),W(this,ie,this.CLOSED),W(this,De,void 0))}}ie=new WeakMap,He=new WeakMap,rt=new WeakMap,Gt=new WeakMap,an=new WeakMap,kt=new WeakMap,it=new WeakMap,xt=new WeakMap,De=new WeakMap,st=new WeakMap,ct=new WeakMap,at=new WeakMap,bt=new WeakMap,pe=new WeakSet,$n=function(){W(this,ie,this.CONNECTING),W(this,De,new AbortController),C(this,an)(C(this,He),je(this,pe,Lr).call(this)).then(C(this,Fn)).catch(C(this,Wn))},Fn=new WeakMap,Wn=new WeakMap,Lr=function(){var n;const e={mode:"cors",redirect:"follow",headers:H({Accept:"text/event-stream"},C(this,xt)?{"Last-Event-ID":C(this,xt)}:void 0),cache:"no-store",signal:(n=C(this,De))==null?void 0:n.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},Vn=new WeakMap,Un=new WeakMap,wt=function(n,e){var t;C(this,ie)!==this.CLOSED&&W(this,ie,this.CLOSED);const r=new Zr("error",{code:e,message:n});(t=C(this,ct))==null||t.call(this,r),this.dispatchEvent(r)},qn=function(n,e){var t;if(C(this,ie)===this.CLOSED)return;W(this,ie,this.CONNECTING);const r=new Zr("error",{code:e,message:n});(t=C(this,ct))==null||t.call(this,r),this.dispatchEvent(r),W(this,it,setTimeout(C(this,Kn),C(this,kt)))},Kn=new WeakMap,Jt.CONNECTING=0,Jt.OPEN=1,Jt.CLOSED=2;function Gi(){const n="document"in globalThis?globalThis.document:void 0;return n&&typeof n=="object"&&"baseURI"in n&&typeof n.baseURI=="string"?n.baseURI:void 0}const Ji=n=>{let e="";const t=new Uint8Array(n),r=t.byteLength;for(let s=0;s<r;s++)e+=String.fromCharCode(t[s]);return btoa(e)},ar={status:"idle",error:null,result:null,progressMessages:[],tasks:{fetchDesign:{status:"pending"},codeGeneration:{status:"pending",progress:0},uploadAssets:{status:"pending"}},jobSessionId:null,jobStatus:{}},Mr=10,Dr=n=>"path"in n?{filePath:n.path.replace(/^\//,""),referencePath:n.path==="/"?"":n.path}:{filePath:n.filePath.replace(/^\//,""),referencePath:n.referencePath==="/"?"":n.referencePath},cs=(n,e,t,r)=>Pe(exports,null,function*(){var u,f,p;const s=structuredClone(ar);s.status="pending",r(H({},s));const a=structuredClone(t);if(((u=t.assetsStorage)==null?void 0:u.strategy)==="local"){const{referencePath:w}=Dr(t.assetsStorage);t.assetsStorage={strategy:"external",url:w}}let i;const o=new Jt(n,{fetch:(w,_)=>(i=fetch(w,_r(H({},_),{method:e,body:JSON.stringify(t)})),i)}),c=new Promise((w,_)=>{const b={};o.addEventListener("start",v=>{const h=JSON.parse(v.data);b.sessionId=h.sessionId,s.tasks.fetchDesign.status="running",s.jobSessionId=h.sessionId,r(H({},s))}),o.addEventListener("queueing",v=>{const h=JSON.parse(v.data);s.jobSessionId=h.payload.sessionId,r(H({},s))}),o.addEventListener("pre_codegen",v=>{JSON.parse(v.data).message==="Anima model built"&&(s.tasks.fetchDesign.status="finished",s.tasks.codeGeneration.status="running",s.tasks.uploadAssets.status="running",r(H({},s)))}),o.addEventListener("figma_metadata",v=>{const h=JSON.parse(v.data);b.figmaFileName=h.figmaFileName,b.figmaSelectedFrameName=h.figmaSelectedFrameName}),o.addEventListener("aborted",()=>{const v=new ln({name:"Aborted",reason:"Unknown"});s.status="aborted",s.result=null,s.error=v,r(H({},s)),w({result:null,error:v})}),o.addEventListener("generating_code",v=>{const h=JSON.parse(v.data);h.payload.status==="success"&&(b.files=h.payload.files),s.tasks.codeGeneration.progress=h.payload.progress,s.tasks.codeGeneration.status="running",r(H({},s))}),o.addEventListener("progress_messages_updated",v=>{const h=JSON.parse(v.data);s.progressMessages=h.payload.progressMessages,r(H({},s))}),o.addEventListener("job_status_updated",v=>{const h=JSON.parse(v.data);s.jobStatus=h.payload.jobStatus,r(H({},s))}),o.addEventListener("codegen_completed",()=>{s.tasks.codeGeneration.status="finished",r(H({},s))}),o.addEventListener("generation_completed",()=>{s.tasks.codeGeneration.status="finished",r(H({},s))}),o.addEventListener("assets_uploaded",()=>{s.tasks.uploadAssets.status="finished",r(H({},s))}),o.addEventListener("assets_list",v=>{const h=JSON.parse(v.data);b.assets=h.payload.assets});let m=0;o.addEventListener("error",v=>Pe(exports,null,function*(){var z,M,Z,ue,P,Te,ve;const h=yield i;if(!h.ok){let J="";try{J=yield h.text();const de=JSON.parse(J);(z=de==null?void 0:de.payload)!=null&&z.message&&(J=de.payload.message)}catch(de){}_(new ln({name:"Request failed",reason:J,status:h.status})),o.close();return}console.warn(`Experienced error during code generation (attempt ${m+1} / ${Mr})`,v);let x,L=!1;if(v instanceof MessageEvent)try{x=JSON.parse(v.data)}catch(J){}(((M=x==null?void 0:x.payload)==null?void 0:M.name)==="Task Crashed"||((Z=x==null?void 0:x.payload)==null?void 0:Z.name)==="TimeoutError"||((ue=x==null?void 0:x.payload)==null?void 0:ue.name)==="Error"||((P=x==null?void 0:x.payload)==null?void 0:P.name)==="Unknown error")&&(L=!0);const V=new ln({name:(Te=x==null?void 0:x.payload.name)!=null?Te:"Unknown error",reason:(ve=x==null?void 0:x.payload.message)!=null?ve:"Unknown",status:x==null?void 0:x.payload.status,detail:x==null?void 0:x.payload.detail});m++;let $=!1;m>Mr?(console.error("Experienced too many errors, terminating request"),$=!0):L&&(console.error("Experienced unrecoverable error, terminating request"),$=!0),$&&(s.status="error",s.error=V,r(H({},s)),w({result:null,error:V}))})),o.addEventListener("done",v=>{const h=JSON.parse(v.data);b.tokenUsage=h.payload.tokenUsage,b.sessionId=h.payload.sessionId,s.status="success",s.result=b,r(H({},s)),w({result:b,error:null})})});try{const{result:w,error:_}=yield c,b=structuredClone(w);if(((f=a.assetsStorage)==null?void 0:f.strategy)==="local"&&((p=b==null?void 0:b.assets)!=null&&p.length)){const{filePath:m}=Dr(a.assetsStorage),v=b.assets.map(x=>Pe(exports,null,function*(){const V=yield(yield fetch(x.url)).arrayBuffer();return{assetName:x.name,base64:Ji(V)}})),h=yield Promise.allSettled(v);for(const x of h){const L={};if(x.status==="fulfilled"){const{assetName:V,base64:$}=x.value;L[V]=$;const z=m?`${m}/${V}`:V;b.files[z]={content:$,isBinary:!0}}}}return _?{result:null,error:_}:{result:b,error:_}}finally{o.close()}}),Xi=({url:n,method:e="POST"})=>{const[t,r]=U.useState(ar);return{getCode:U.useCallback(a=>cs(n,e,a,r),[n,e]),status:t.status,progressMessages:t.progressMessages,jobSessionId:t.jobSessionId,jobStatus:t.jobStatus,tasks:t.tasks,error:t.error,result:t.result}};var Ut={exports:{}},gn={};/**
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={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
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={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
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:
18
+ let props = %s;
19
+ <%s {...props} />
20
+ React keys must be passed directly to JSX without using spread:
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={};/**
6
27
  * @license React
7
28
  * use-sync-external-store-shim.production.js
8
29
  *
@@ -10,7 +31,7 @@
10
31
  *
11
32
  * This source code is licensed under the MIT license found in the
12
33
  * LICENSE file in the root directory of this source tree.
13
- */var $r;function Yi(){if($r)return gn;$r=1;var n=U;function e(p,w){return p===w&&(p!==0||1/p===1/w)||p!==p&&w!==w}var t=typeof Object.is=="function"?Object.is:e,r=n.useState,s=n.useEffect,a=n.useLayoutEffect,i=n.useDebugValue;function o(p,w){var _=w(),b=r({inst:{value:_,getSnapshot:w}}),m=b[0].inst,v=b[1];return a(function(){m.value=_,m.getSnapshot=w,c(m)&&v({inst:m})},[p,_,w]),s(function(){return c(m)&&v({inst:m}),p(function(){c(m)&&v({inst:m})})},[p]),i(_),_}function c(p){var w=p.getSnapshot;p=p.value;try{var _=w();return!t(p,_)}catch(b){return!0}}function u(p,w){return w()}var f=typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"?u:o;return gn.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:f,gn}var vn={};/**
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={};/**
14
35
  * @license React
15
36
  * use-sync-external-store-shim.development.js
16
37
  *
@@ -18,5 +39,5 @@
18
39
  *
19
40
  * This source code is licensed under the MIT license found in the
20
41
  * LICENSE file in the root directory of this source tree.
21
- */var Fr;function Qi(){return Fr||(Fr=1,process.env.NODE_ENV!=="production"&&function(){function n(_,b){return _===b&&(_!==0||1/_===1/b)||_!==_&&b!==b}function e(_,b){f||s.startTransition===void 0||(f=!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 m=b();if(!p){var v=b();a(m,v)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),p=!0)}v=i({inst:{value:m,getSnapshot:b}});var h=v[0].inst,x=v[1];return c(function(){h.value=m,h.getSnapshot=b,t(h)&&x({inst:h})},[_,m,b]),o(function(){return t(h)&&x({inst:h}),_(function(){t(h)&&x({inst:h})})},[_]),u(m),m}function t(_){var b=_.getSnapshot;_=_.value;try{var m=b();return!a(_,m)}catch(v){return!0}}function r(_,b){return b()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var s=U,a=typeof Object.is=="function"?Object.is:n,i=s.useState,o=s.useEffect,c=s.useLayoutEffect,u=s.useDebugValue,f=!1,p=!1,w=typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"?r:e;vn.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:w,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),vn}var Wr;function eo(){return Wr||(Wr=1,process.env.NODE_ENV==="production"?Ut.exports=Yi():Ut.exports=Qi()),Ut.exports}var to=eo();const us=0,ds=1,ls=2,Vr=3;var Ur=Object.prototype.hasOwnProperty;function zn(n,e){var t,r;if(n===e)return!0;if(n&&e&&(t=n.constructor)===e.constructor){if(t===Date)return n.getTime()===e.getTime();if(t===RegExp)return n.toString()===e.toString();if(t===Array){if((r=n.length)===e.length)for(;r--&&zn(n[r],e[r]););return r===-1}if(!t||typeof n=="object"){r=0;for(t in n)if(Ur.call(n,t)&&++r&&!Ur.call(e,t)||!(t in e)||!zn(n[t],e[t]))return!1;return Object.keys(e).length===r}}return n!==n&&e!==e}const Ie=new WeakMap,$e=()=>{},re=$e(),Bn=Object,j=n=>n===re,ke=n=>typeof n=="function",qe=(n,e)=>H(H({},n),e),hs=n=>ke(n.then),_n={},qt={},ir="undefined",$t=typeof window!=ir,Hn=typeof document!=ir,no=$t&&"Deno"in window,ro=()=>$t&&typeof window.requestAnimationFrame!=ir,fs=(n,e)=>{const t=Ie.get(n);return[()=>!j(e)&&n.get(e)||_n,r=>{if(!j(e)){const s=n.get(e);e in qt||(qt[e]=s),t[5](e,qe(s,r),s||_n)}},t[6],()=>!j(e)&&e in qt?qt[e]:!j(e)&&n.get(e)||_n]};let Gn=!0;const so=()=>Gn,[Jn,Xn]=$t&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[$e,$e],ao=()=>{const n=Hn&&document.visibilityState;return j(n)||n!=="hidden"},io=n=>(Hn&&document.addEventListener("visibilitychange",n),Jn("focus",n),()=>{Hn&&document.removeEventListener("visibilitychange",n),Xn("focus",n)}),oo=n=>{const e=()=>{Gn=!0,n()},t=()=>{Gn=!1};return Jn("online",e),Jn("offline",t),()=>{Xn("online",e),Xn("offline",t)}},co={isOnline:so,isVisible:ao},uo={initFocus:io,initReconnect:oo},qr=!U.useId,Mt=!$t||no,lo=n=>ro()?window.requestAnimationFrame(n):setTimeout(n,1),bn=Mt?U.useEffect:U.useLayoutEffect,wn=typeof navigator!="undefined"&&navigator.connection,Kr=!Mt&&wn&&(["slow-2g","2g"].includes(wn.effectiveType)||wn.saveData),Kt=new WeakMap,kn=(n,e)=>Bn.prototype.toString.call(n)===`[object ${e}]`;let ho=0;const Yn=n=>{const e=typeof n,t=kn(n,"Date"),r=kn(n,"RegExp"),s=kn(n,"Object");let a,i;if(Bn(n)===n&&!t&&!r){if(a=Kt.get(n),a)return a;if(a=++ho+"~",Kt.set(n,a),Array.isArray(n)){for(a="@",i=0;i<n.length;i++)a+=Yn(n[i])+",";Kt.set(n,a)}if(s){a="#";const o=Bn.keys(n).sort();for(;!j(i=o.pop());)j(n[i])||(a+=i+":"+Yn(n[i])+",");Kt.set(n,a)}}else a=t?n.toJSON():e=="symbol"?n.toString():e=="string"?JSON.stringify(n):""+n;return a},or=n=>{if(ke(n))try{n=n()}catch(t){n=""}const e=n;return n=typeof n=="string"?n:(Array.isArray(n)?n.length:n)?Yn(n):"",[n,e]};let fo=0;const Qn=()=>++fo;function ps(...n){return Pe(this,null,function*(){const[e,t,r,s]=n,a=qe({populateCache:!0,throwOnError:!0},typeof s=="boolean"?{revalidate:s}:s||{});let i=a.populateCache;const o=a.rollbackOnError;let c=a.optimisticData;const u=w=>typeof o=="function"?o(w):o!==!1,f=a.throwOnError;if(ke(t)){const w=t,_=[],b=e.keys();for(const m of b)!/^\$(inf|sub)\$/.test(m)&&w(e.get(m)._k)&&_.push(m);return Promise.all(_.map(p))}return p(t);function p(w){return Pe(this,null,function*(){const[_]=or(w);if(!_)return;const[b,m]=fs(e,_),[v,h,x,L]=Ie.get(e),V=()=>{const J=v[_];return(ke(a.revalidate)?a.revalidate(b().data,w):a.revalidate!==!1)&&(delete x[_],delete L[_],J&&J[0])?J[0](ls).then(()=>b().data):b().data};if(n.length<3)return V();let $=r,z;const M=Qn();h[_]=[M,0];const Z=!j(c),ue=b(),P=ue.data,Te=ue._c,ve=j(Te)?P:Te;if(Z&&(c=ke(c)?c(ve,P):c,m({data:c,_c:ve})),ke($))try{$=$(ve)}catch(J){z=J}if($&&hs($))if($=yield $.catch(J=>{z=J}),M!==h[_][0]){if(z)throw z;return $}else z&&Z&&u(z)&&(i=!0,m({data:ve,_c:re}));if(i&&!z)if(ke(i)){const J=i($,ve);m({data:J,error:re,_c:re})}else m({data:$,error:re,_c:re});if(h[_][1]=Qn(),Promise.resolve(V()).then(()=>{m({_c:re})}),z){if(f)throw z;return}return $})}})}const zr=(n,e)=>{for(const t in n)n[t][0]&&n[t][0](e)},po=(n,e)=>{if(!Ie.has(n)){const t=qe(uo,e),r=Object.create(null),s=ps.bind(re,n);let a=$e;const i=Object.create(null),o=(f,p)=>{const w=i[f]||[];return i[f]=w,w.push(p),()=>w.splice(w.indexOf(p),1)},c=(f,p,w)=>{n.set(f,p);const _=i[f];if(_)for(const b of _)b(p,w)},u=()=>{if(!Ie.has(n)&&(Ie.set(n,[r,Object.create(null),Object.create(null),Object.create(null),s,c,o]),!Mt)){const f=t.initFocus(setTimeout.bind(re,zr.bind(re,r,us))),p=t.initReconnect(setTimeout.bind(re,zr.bind(re,r,ds)));a=()=>{f&&f(),p&&p(),Ie.delete(n)}}};return u(),[n,s,u,a]}return[n,Ie.get(n)[4]]},mo=(n,e,t,r,s)=>{const a=t.errorRetryCount,i=s.retryCount,o=~~((Math.random()+.5)*(1<<(i<8?i:8)))*t.errorRetryInterval;!j(a)&&i>a||setTimeout(r,o,s)},yo=zn,[ms,go]=po(new Map),vo=qe({onLoadingSlow:$e,onSuccess:$e,onError:$e,onErrorRetry:mo,onDiscarded:$e,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Kr?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Kr?5e3:3e3,compare:yo,isPaused:()=>!1,cache:ms,mutate:go,fallback:{}},co),_o=(n,e)=>{const t=qe(n,e);if(e){const{use:r,fallback:s}=n,{use:a,fallback:i}=e;r&&a&&(t.use=r.concat(a)),s&&i&&(t.fallback=qe(s,i))}return t},bo=U.createContext({}),wo="$inf$",ys=$t&&window.__SWR_DEVTOOLS_USE__,ko=ys?window.__SWR_DEVTOOLS_USE__:[],xo=()=>{ys&&(window.__SWR_DEVTOOLS_REACT__=U)},Eo=n=>ke(n[1])?[n[0],n[1],n[2]||{}]:[n[0],null,(n[1]===null?n[2]:n[1])||{}],So=()=>qe(vo,U.useContext(bo)),Oo=n=>(e,t,r)=>n(e,t&&((...a)=>{const[i]=or(e),[,,,o]=Ie.get(ms);if(i.startsWith(wo))return t(...a);const c=o[i];return j(c)?t(...a):(delete o[i],c)}),r),To=ko.concat(Oo),Ao=n=>function(...t){const r=So(),[s,a,i]=Eo(t),o=_o(r,i);let c=n;const{use:u}=o,f=(u||[]).concat(To);for(let p=f.length;p--;)c=f[p](c);return c(s,a||o.fetcher||null,o)},Co=(n,e,t)=>{const r=e[n]||(e[n]=[]);return r.push(t),()=>{const s=r.indexOf(t);s>=0&&(r[s]=r[r.length-1],r.pop())}};xo();const xn=U.use||(n=>{switch(n.status){case"pending":throw n;case"fulfilled":return n.value;case"rejected":throw n.reason;default:throw n.status="pending",n.then(e=>{n.status="fulfilled",n.value=e},e=>{n.status="rejected",n.reason=e}),n}}),En={dedupe:!0},Ro=(n,e,t)=>{const{cache:r,compare:s,suspense:a,fallbackData:i,revalidateOnMount:o,revalidateIfStale:c,refreshInterval:u,refreshWhenHidden:f,refreshWhenOffline:p,keepPreviousData:w}=t,[_,b,m,v]=Ie.get(r),[h,x]=or(n),L=U.useRef(!1),V=U.useRef(!1),$=U.useRef(h),z=U.useRef(e),M=U.useRef(t),Z=()=>M.current,ue=()=>Z().isVisible()&&Z().isOnline(),[P,Te,ve,J]=fs(r,h),de=U.useRef({}).current,Ft=j(i)?j(t.fallback)?re:t.fallback[h]:i,cr=(F,D)=>{for(const Y in de){const K=Y;if(K==="data"){if(!s(F[K],D[K])&&(!j(F[K])||!s(Vt,D[K])))return!1}else if(D[K]!==F[K])return!1}return!0},ur=U.useMemo(()=>{const F=!h||!e?!1:j(o)?Z().isPaused()||a?!1:c!==!1:o,D=te=>{const Ae=qe(te);return delete Ae._k,F?H({isValidating:!0,isLoading:!0},Ae):Ae},Y=P(),K=J(),fe=D(Y),tt=Y===K?fe:D(K);let X=fe;return[()=>{const te=D(P());return cr(te,X)?(X.data=te.data,X.isLoading=te.isLoading,X.isValidating=te.isValidating,X.error=te.error,X):(X=te,te)},()=>tt]},[r,h]),Qe=to.useSyncExternalStore(U.useCallback(F=>ve(h,(D,Y)=>{cr(Y,D)||F()}),[r,h]),ur[0],ur[1]),dr=!L.current,gs=_[h]&&_[h].length>0,et=Qe.data,Ke=j(et)?Ft&&hs(Ft)?xn(Ft):Ft:et,Wt=Qe.error,cn=U.useRef(Ke),Vt=w?j(et)?j(cn.current)?Ke:cn.current:et:Ke,lr=gs&&!j(Wt)?!1:dr&&!j(o)?o:Z().isPaused()?!1:a?j(Ke)?!1:c:j(Ke)||c,hr=!!(h&&e&&dr&&lr),vs=j(Qe.isValidating)?hr:Qe.isValidating,_s=j(Qe.isLoading)?hr:Qe.isLoading,ft=U.useCallback(F=>Pe(exports,null,function*(){const D=z.current;if(!h||!D||V.current||Z().isPaused())return!1;let Y,K,fe=!0;const tt=F||{},X=!m[h]||!tt.dedupe,te=()=>qr?!V.current&&h===$.current&&L.current:h===$.current,Ae={isValidating:!1,isLoading:!1},pr=()=>{Te(Ae)},mr=()=>{const le=m[h];le&&le[1]===K&&delete m[h]},yr={isValidating:!0};j(P().data)&&(yr.isLoading=!0);try{if(X&&(Te(yr),t.loadingTimeout&&j(P().data)&&setTimeout(()=>{fe&&te()&&Z().onLoadingSlow(h,t)},t.loadingTimeout),m[h]=[D(x),Qn()]),[Y,K]=m[h],Y=yield Y,X&&setTimeout(mr,t.dedupingInterval),!m[h]||m[h][1]!==K)return X&&te()&&Z().onDiscarded(h),!1;Ae.error=re;const le=b[h];if(!j(le)&&(K<=le[0]||K<=le[1]||le[1]===0))return pr(),X&&te()&&Z().onDiscarded(h),!1;const Ce=P().data;Ae.data=s(Ce,Y)?Ce:Y,X&&te()&&Z().onSuccess(Y,h,t)}catch(le){mr();const Ce=Z(),{shouldRetryOnError:un}=Ce;Ce.isPaused()||(Ae.error=le,X&&te()&&(Ce.onError(le,h,Ce),(un===!0||ke(un)&&un(le))&&(!Z().revalidateOnFocus||!Z().revalidateOnReconnect||ue())&&Ce.onErrorRetry(le,h,Ce,bs=>{const dn=_[h];dn&&dn[0]&&dn[0](Vr,bs)},{retryCount:(tt.retryCount||0)+1,dedupe:!0})))}return fe=!1,pr(),!0}),[h,r]),fr=U.useCallback((...F)=>ps(r,$.current,...F),[]);if(bn(()=>{z.current=e,M.current=t,j(et)||(cn.current=et)}),bn(()=>{if(!h)return;const F=ft.bind(re,En);let D=0;Z().revalidateOnFocus&&(D=Date.now()+Z().focusThrottleInterval);const K=Co(h,_,(fe,tt={})=>{if(fe==us){const X=Date.now();Z().revalidateOnFocus&&X>D&&ue()&&(D=X+Z().focusThrottleInterval,F())}else if(fe==ds)Z().revalidateOnReconnect&&ue()&&F();else{if(fe==ls)return ft();if(fe==Vr)return ft(tt)}});return V.current=!1,$.current=h,L.current=!0,Te({_k:x}),lr&&(j(Ke)||Mt?F():lo(F)),()=>{V.current=!0,K()}},[h]),bn(()=>{let F;function D(){const K=ke(u)?u(P().data):u;K&&F!==-1&&(F=setTimeout(Y,K))}function Y(){!P().error&&(f||Z().isVisible())&&(p||Z().isOnline())?ft(En).then(D):D()}return D(),()=>{F&&(clearTimeout(F),F=-1)}},[u,f,p,h]),U.useDebugValue(Vt),a&&j(Ke)&&h){if(!qr&&Mt)throw new Error("Fallback data is required when using Suspense in SSR.");z.current=e,M.current=t,V.current=!1;const F=v[h];if(!j(F)){const D=fr(F);xn(D)}if(j(Wt)){const D=ft(En);j(Vt)||(D.status="fulfilled",D.value=!0),xn(D)}else throw Wt}return{mutate:fr,get data(){return de.data=!0,Vt},get error(){return de.error=!0,Wt},get isValidating(){return de.isValidating=!0,vs},get isLoading(){return de.isLoading=!0,_s}}},jo=Ao(Ro),No=({fileKey:n,authToken:e,enabled:t=!0,params:r={}})=>{const s=!!(t&&n&&e),{data:a,isLoading:i,error:o}=jo(["useFigmaFile",n,e,r],()=>s?Ma({fileKey:n,authToken:e,params:r}):null,{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1});return{data:a!=null?a:null,isLoading:i,error:o}};exports.createJob=cs;exports.initialProgress=ar;exports.useAnimaCodegen=Xi;exports.useFigmaFile=No;
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;
22
43
  //# sourceMappingURL=index.cjs.map