@animaapp/anima-sdk 0.3.4 → 0.3.5

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,6 +1,6 @@
1
- "use strict";var On=Object.defineProperty,Nn=Object.defineProperties;var In=Object.getOwnPropertyDescriptors;var Mt=Object.getOwnPropertySymbols;var jn=Object.prototype.hasOwnProperty,Rn=Object.prototype.propertyIsEnumerable;var $t=n=>{throw TypeError(n)};var Pt=(n,e,t)=>e in n?On(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,d=(n,e)=>{for(var t in e||(e={}))jn.call(e,t)&&Pt(n,t,e[t]);if(Mt)for(var t of Mt(e))Rn.call(e,t)&&Pt(n,t,e[t]);return n},g=(n,e)=>Nn(n,In(e));var lt=(n,e,t)=>e.has(n)||$t("Cannot "+t);var H=(n,e,t)=>(lt(n,e,"read from private field"),t?t.call(n):e.get(n)),Xe=(n,e,t)=>e.has(n)?$t("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),ft=(n,e,t,s)=>(lt(n,e,"write to private field"),s?s.call(n,t):e.set(n,t),t),Ft=(n,e,t)=>(lt(n,e,"access private method"),t);var M=(n,e,t)=>new Promise((s,r)=>{var a=c=>{try{o(t.next(c))}catch(u){r(u)}},i=c=>{try{o(t.throw(c))}catch(u){r(u)}},o=c=>c.done?s(c.value):Promise.resolve(c.value).then(a,i);o((t=t.apply(n,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class ie extends Error{constructor({name:e,reason:t,status:s,detail:r}){super(),this.name=e,this.message=t,this.detail=r,this.status=s}}const Kt="Figma Token Issue";class Xt extends Error{constructor({fileKey:e,reason:t}){super(Kt),this.fileKey=e,this.reason=t}}const Yt="Rate Limit Exceeded";class Qt extends Error{constructor({fileKey:e}){super(Yt),this.fileKey=e}}const en="Not Found";class tn extends Error{constructor({fileKey:e}){super(en),this.fileKey=e}}const nn=n=>n.message===en,sn="Unknown Figma API Exception";class rn extends Error{constructor({fileKey:e,cause:t}){super(sn),this.name="UnknownFigmaApiException",this.fileKey=e,this.cause=t}}const Zn=n=>n.message===sn,an=n=>n.message===Yt,on=n=>[Kt,...["Invalid Figma token","Figma token expired"]].includes(n.message),cn=(n,e)=>{var s,r,a,i;const t=((s=n==null?void 0:n.cause)==null?void 0:s.body)||n.body;throw(t==null?void 0:t.status)===403?new Xt({fileKey:e,reason:(((a=(r=n==null?void 0:n.cause)==null?void 0:r.body)==null?void 0:a.reason)||((i=n.body)==null?void 0:i.reason)||"Access denied").toString()}):(t==null?void 0:t.status)===429?new Qt({fileKey:e}):(t==null?void 0:t.status)===404?new tn({fileKey:e}):new rn({fileKey:e,cause:n})},Mn=n=>nn(n)?"NotFound":an(n)?"RateLimitExceeded":on(n)?"FigmaTokenIssue":"UnknownFigmaApiException";var Pn=Object.defineProperty,$n=Object.defineProperties,Fn=Object.getOwnPropertyDescriptors,Vt=Object.getOwnPropertySymbols,Vn=Object.prototype.hasOwnProperty,Ln=Object.prototype.propertyIsEnumerable,Lt=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),dn=n=>{throw TypeError(n)},Dt=(n,e,t)=>e in n?Pn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,U=(n,e)=>{for(var t in e||(e={}))Vn.call(e,t)&&Dt(n,t,e[t]);if(Vt)for(var t of Vt(e))Ln.call(e,t)&&Dt(n,t,e[t]);return n},Nt=(n,e)=>$n(n,Fn(e)),It=(n,e,t)=>e.has(n)||dn("Cannot "+t),T=(n,e,t)=>(It(n,e,"read from private field"),t?t.call(n):e.get(n)),W=(n,e,t)=>e.has(n)?dn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),j=(n,e,t,s)=>(It(n,e,"write to private field"),e.set(n,t),t),ee=(n,e,t)=>(It(n,e,"access private method"),t),A=(n,e,t)=>new Promise((s,r)=>{var a=c=>{try{o(t.next(c))}catch(u){r(u)}},i=c=>{try{o(t.throw(c))}catch(u){r(u)}},o=c=>c.done?s(c.value):Promise.resolve(c.value).then(a,i);o((t=t.apply(n,e)).next())}),Dn=(n,e,t)=>(e=n[Lt("asyncIterator")])?e.call(n):(n=n[Lt("iterator")](),e={},t=(s,r)=>(r=n[s])&&(e[s]=a=>new Promise((i,o,c)=>(a=r.call(n,a),c=a.done,Promise.resolve(a.value).then(u=>i({value:u,done:c}),o)))),t("next"),t("return"),e),Un=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function zn(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var yt={exports:{}},Wn=yt.exports,Ut;function Bn(){return Ut||(Ut=1,function(n,e){(function(t,s){n.exports=s()})(Wn,function(){var t=typeof Promise=="function",s=typeof self=="object"?self:Un,r=typeof Symbol!="undefined",a=typeof Map!="undefined",i=typeof Set!="undefined",o=typeof WeakMap!="undefined",c=typeof WeakSet!="undefined",u=typeof DataView!="undefined",f=r&&typeof Symbol.iterator!="undefined",_=r&&typeof Symbol.toStringTag!="undefined",I=i&&typeof Set.prototype.entries=="function",C=a&&typeof Map.prototype.entries=="function",O=I&&Object.getPrototypeOf(new Set().entries()),Z=C&&Object.getPrototypeOf(new Map().entries()),B=f&&typeof Array.prototype[Symbol.iterator]=="function",re=B&&Object.getPrototypeOf([][Symbol.iterator]()),ue=f&&typeof String.prototype[Symbol.iterator]=="function",V=ue&&Object.getPrototypeOf(""[Symbol.iterator]()),X=8,q=-1;function Oe(E){var k=typeof E;if(k!=="object")return k;if(E===null)return"null";if(E===s)return"global";if(Array.isArray(E)&&(_===!1||!(Symbol.toStringTag in E)))return"Array";if(typeof window=="object"&&window!==null){if(typeof window.location=="object"&&E===window.location)return"Location";if(typeof window.document=="object"&&E===window.document)return"Document";if(typeof window.navigator=="object"){if(typeof window.navigator.mimeTypes=="object"&&E===window.navigator.mimeTypes)return"MimeTypeArray";if(typeof window.navigator.plugins=="object"&&E===window.navigator.plugins)return"PluginArray"}if((typeof window.HTMLElement=="function"||typeof window.HTMLElement=="object")&&E instanceof window.HTMLElement){if(E.tagName==="BLOCKQUOTE")return"HTMLQuoteElement";if(E.tagName==="TD")return"HTMLTableDataCellElement";if(E.tagName==="TH")return"HTMLTableHeaderCellElement"}}var ut=_&&E[Symbol.toStringTag];if(typeof ut=="string")return ut;var L=Object.getPrototypeOf(E);return L===RegExp.prototype?"RegExp":L===Date.prototype?"Date":t&&L===Promise.prototype?"Promise":i&&L===Set.prototype?"Set":a&&L===Map.prototype?"Map":c&&L===WeakSet.prototype?"WeakSet":o&&L===WeakMap.prototype?"WeakMap":u&&L===DataView.prototype?"DataView":a&&L===Z?"Map Iterator":i&&L===O?"Set Iterator":B&&L===re?"Array Iterator":ue&&L===V?"String Iterator":L===null?"Object":Object.prototype.toString.call(E).slice(X,q)}return Oe})}(yt)),yt.exports}var qn=Bn();const Hn=zn(qn),jt=typeof Buffer!="undefined",Jn=jt&&typeof Buffer.from!="undefined",Gn=jt?function(n){return Buffer.isBuffer(n)}:function(){return!1},Kn=Jn?function(n){return Buffer.from(n)}:jt?function(n){return new Buffer(n)}:function(n){return n};function Se(n){return Gn(n)?"Buffer":Hn(n)}const Xn=new Set(["Arguments","Array","Map","Object","Set"]);function Yn(n,e,t=null){switch(t||Se(n)){case"Arguments":case"Array":case"Object":return n[e];case"Map":return n.get(e);case"Set":return e}}function vt(n){return Xn.has(n)}function zt(n,e,t,s=null){switch(s||Se(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 Qn=typeof globalThis!="undefined"&&globalThis!==null&&globalThis.Object===Object&&globalThis,es=typeof global!="undefined"&&global!==null&&global.Object===Object&&global,ts=typeof self!="undefined"&&self!==null&&self.Object===Object&&self,ht=Qn||es||ts||Function("return this")();function ns(n){return n.slice(0)}function ss(n){return new Boolean(n.valueOf())}function rs(n){return new DataView(n.buffer)}function as(n){return Kn(n)}function is(n){return new Date(n.getTime())}function os(n){return new Number(n)}function cs(n){return new RegExp(n.source,n.flags)}function ds(n){return new String(n)}function ae(n,e){return ht[e].from?ht[e].from(n):new ht[e](n)}function P(n){return n}function Wt(){return[]}function us(){return new Map}function ls(){return{}}function fs(){return new Set}const hs=new Map([["ArrayBuffer",ns],["Boolean",ss],["Buffer",as],["DataView",rs],["Date",is],["Number",os],["RegExp",cs],["String",ds],["Float32Array",ae],["Float64Array",ae],["Int16Array",ae],["Int32Array",ae],["Int8Array",ae],["Uint16Array",ae],["Uint32Array",ae],["Uint8Array",ae],["Uint8ClampedArray",ae],["Array Iterator",P],["Map Iterator",P],["Promise",P],["Set Iterator",P],["String Iterator",P],["function",P],["global",P],["WeakMap",P],["WeakSet",P],["boolean",P],["null",P],["number",P],["string",P],["symbol",P],["undefined",P],["Arguments",Wt],["Array",Wt],["Map",us],["Object",ls],["Set",fs]]);function ps(){}function _t(n,e=null,t=ps){arguments.length===2&&typeof e=="function"&&(t=e,e=null);const s=e||Se(n),r=hs.get(s);if(s==="Object"){const a=t(n,s);if(a!==void 0)return a}return r?r(n,s):n}function Ne(n,e={}){typeof e=="function"&&(e={customizer:e});const{customizer:t}=e,s=Se(n);if(!vt(s))return bt(n,null,null,null);const r=_t(n,s,t),a=new WeakMap([[n,r]]),i=new WeakSet([n]);return bt(n,r,a,i)}function bt(n,e,t,s,r){const a=Se(n),i=_t(n,a);if(!vt(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=Yn(n,c,a);if(s.has(u))zt(e,c,t.get(u),a);else{const f=Se(u),_=_t(u,f);vt(f)&&(t.set(u,_),s.add(u)),zt(e,c,bt(u,_,t,s),a)}}return e}const ms=n=>new Promise(e=>setTimeout(e,n));var Ye,ge,Qe,wt,un;class gs{constructor({maxAttempts:e=3,func:t}){W(this,wt),W(this,Ye),W(this,ge),W(this,Qe),j(this,Ye,e),j(this,Qe,t),j(this,ge,0)}run(){return A(this,null,function*(){try{return yield T(this,Qe).call(this)}catch(e){if(j(this,ge,T(this,ge)+1),T(this,ge)>T(this,Ye))throw console.error("Max attempts reached"),e;const t=ee(this,wt,un).call(this);return yield ms(t),yield this.run()}})}}Ye=new WeakMap,ge=new WeakMap,Qe=new WeakMap,wt=new WeakSet,un=function(){return T(this,ge)*1e3*1.5};function ys(){return typeof CompressionStream!="undefined"}function vs(n){return A(this,null,function*(){const e=new Blob([n]).stream().pipeThrough(new CompressionStream("gzip")),t=[];try{for(var s=Dn(e),r,a,i;r=!(a=yield s.next()).done;r=!1){const o=a.value;t.push(o)}}catch(o){i=[o]}finally{try{r&&(a=s.return)&&(yield a.call(s))}finally{if(i)throw i[0]}}return yield _s(t)})}function _s(n){return A(this,null,function*(){const e=yield new Blob(n).arrayBuffer();return new Uint8Array(e)})}class bs extends Error{constructor({resource:e,api:t,args:s,cause:r}){if(super(`API Error on resource "${e}" at api "${t}"`),this.causeProperties={},this.name="API Error",this.resource=e,this.api=t,this.cause=r,this.args=s,r instanceof Error)for(const[i,o]of Object.entries(r))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 Bt extends Error{constructor({url:e,method:t,statusCode:s,requestHeaders:r,responseHeaders:a,body:i}){if(super("Fetch Error"),this.name="Fetch Error",this.url=e,this.method=t,this.statusNumber=s,this.requestHeaders=r,this.responseHeaders=a,i)try{const o=JSON.parse(i);this.body=o}catch(o){this.body=i}}}class Ie extends Error{constructor(e={}){const{canceled:t=!1}=e;super("Abort Error"),this.name="Abort Error",this.canceled=t}}class ws extends Error{constructor(e){super(`Async API Error: ${JSON.stringify(e)}`),this.name="Async API Error",this.body=e}}class pt extends Error{constructor(e){super(e),this.name="Request Validation Error"}}function ln(){return Array.from({length:32},()=>Math.floor(Math.random()*256).toString(16).padStart(2,"0")).join("")}function xt(){return Math.floor(Date.now()/1e3).toString()}const xs=5*60*1e3,ks=1*1e3;var ye,F,Y,kt,Tt,je;class Ts{constructor({fetch:e=globalThis.fetch.bind(globalThis),baseAddress:t}){W(this,Y),W(this,ye),W(this,F),this.baseAddress=t,j(this,ye,e),j(this,F,{}),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 j(this,F,e),this}get(e){return A(this,arguments,function*(t,s={}){const{overrideBaseAddress:r,overrideDefaultHeaders:a}=s,i=r!=null?r:this.baseAddress;let o=a!=null?a:this.headers;const c=Ne(T(this,F));return j(this,F,{}),c.extraHeaders&&(o=U(U({},o),c.extraHeaders)),c.requestValidation&&(o=Nt(U({},o),{"X-Request-Nonce":ln(),"X-Request-Timestamp":xt()})),c.async?yield ee(this,Y,Tt).call(this,`${i}${t}`,c.async,{headers:o}):yield ee(this,Y,kt).call(this,`${i}${t}`,c,{headers:o})})}post(e,t){return A(this,arguments,function*(s,r,a={}){const i=Ne(T(this,F));return j(this,F,{}),ee(this,Y,je).call(this,s,"POST",r,a,i)})}put(e,t){return A(this,arguments,function*(s,r,a={}){const i=Ne(T(this,F));return j(this,F,{}),ee(this,Y,je).call(this,s,"PUT",r,a,i)})}delete(e,t){return A(this,arguments,function*(s,r,a={}){const i=Ne(T(this,F));return j(this,F,{}),ee(this,Y,je).call(this,s,"DELETE",r,a,i)})}patch(e,t){return A(this,arguments,function*(s,r,a={}){const i=Ne(T(this,F));return j(this,F,{}),ee(this,Y,je).call(this,s,"PATCH",r,a,i)})}}ye=new WeakMap,F=new WeakMap,Y=new WeakSet,kt=function(n,e,t){return A(this,null,function*(){const s=()=>A(this,null,function*(){var c,u;try{return yield T(this,ye).call(this,n,U(U({},t),e.abortSignal&&{signal:e.abortSignal}))}catch(f){throw f instanceof Error&&f.name==="AbortError"?new Ie({canceled:(u=(c=e.abortSignal)==null?void 0:c.aborted)!=null?u:!1}):f}}),{headers:r}=t!=null?t:{},a=(c,u)=>{var f,_;return((f=c==null?void 0:c.headers)==null?void 0:f.get(u))||((_=c==null?void 0:c.headersObject)==null?void 0:_[u])||""},i=c=>A(this,null,function*(){var u;if(!c.ok){const _=yield c.text().catch();throw new Bt({url:n,method:(u=t==null?void 0:t.method)!=null?u:"GET",statusCode:c.status,requestHeaders:r,responseHeaders:c.headers,body:_})}if(e.requestValidation&&process.env.UI_TESTS!==!0)try{const _=a(c,"x-response-nonce"),I=r==null?void 0:r["X-Request-Nonce"];if(!_||_!==I)throw new pt("Response nonce mismatch");const C=Number(a(c,"x-response-timestamp")),O=Number(xt()),Z=60*60*24;if(isNaN(C)||Math.abs(O-C)>Z)throw new pt("Invalid response timestamp")}catch(_){const I=_ instanceof Error?_.message:"Request validation failed";throw new pt(I)}let f=yield c.text();try{f=JSON.parse(f)}catch(_){}return f});if(e.retry){const c=yield new gs({maxAttempts:e.retry,func:s}).run();return yield i(c)}const o=yield s();return yield i(o)})},Tt=function(n,e,t){return A(this,null,function*(){var s,r;const{onProgress:a,abortSignal:i,pollingInterval:o=()=>ks,maxTimeout:c=xs}=e,u=`${n}/async`,f=`${n}/async/job`;let _;try{_=yield T(this,ye).call(this,u,U(U({},t),i&&{signal:i}))}catch(O){throw O instanceof Error&&O.name==="AbortError"?new Ie({canceled:(s=i==null?void 0:i.aborted)!=null?s:!1}):O}if(!_.ok){const O=yield _.text().catch();throw new Bt({url:n,method:(r=t==null?void 0:t.method)!=null?r:"GET",statusCode:_.status,requestHeaders:this.headers,responseHeaders:_.headers,body:O})}const I=yield _.json(),{job_id:C}=I;if(!C)throw new Error("Job ID not found in response");return new Promise((O,Z)=>A(this,null,function*(){const B=setTimeout(()=>{Z(new Error("Job timed out"))},c),re=(ue=0)=>A(this,null,function*(){if(i!=null&&i.aborted){clearTimeout(B),T(this,ye).call(this,`${f}/${C}/cancel`,{method:"POST",headers:this.headers}).then(()=>{Z(new Ie({canceled:!0}))}).catch(V=>{Z(new Ie({canceled:!1}))});return}try{const V=yield(yield T(this,ye).call(this,`${f}/${C}`,{headers:this.headers})).json();if(V.status==="success"){clearTimeout(B);const X=V.response_json;O(X)}else if(V.status==="failed")clearTimeout(B),Z(new ws(V.response_json));else{a&&a(V.response_json);const X=o(ue);setTimeout(()=>re(ue+1),X)}}catch(V){Z(V)}});re()}))})},je=function(n,e,t,s,r){return A(this,null,function*(){const{overrideBaseAddress:a,overrideDefaultHeaders:i}=s,o=a!=null?a:this.baseAddress;let c=i!=null?i:this.headers;r.extraHeaders&&(c=U(U({},c),r.extraHeaders)),r.requestValidation&&(c=Nt(U({},c),{"X-Request-Nonce":ln(),"X-Request-Timestamp":xt()}));let u=s.skipBodyJsonStringify?t:JSON.stringify(t);return r.compress&&ys()&&(c["Content-Encoding"]="gzip",u=yield vs(u)),r.async?yield ee(this,Y,Tt).call(this,`${o}${n}`,r.async,{method:e,headers:c,body:u}):yield ee(this,Y,kt).call(this,`${o}${n}`,r,{method:e,headers:c,body:u})})};const qt=(n,e,t,s)=>n instanceof Ie?n:new bs({resource:e,api:String(t),args:s,cause:n}),mt=(n,e)=>new Proxy(e,{get(t,s){return(...r)=>{var a;for(const o of n.plugins){const c=(a=o.beforeApi)==null?void 0:a.call(o,{resource:t.resourceName,api:s,args:r});if(c!==void 0)return c}let i;try{i=t[s](...r)}catch(o){throw qt(o,t.resourceName,s,r)}return i instanceof Promise?i.catch(o=>{throw qt(o,t.resourceName,s,r)}):i}}});var Re;class Ss{constructor(e){W(this,Re),this.resourceName="Files",j(this,Re,e)}get(e){return A(this,arguments,function*({fileKey:t,params:s={}}){const r=new URLSearchParams(U({plugin_data:"857346721138427857"},s)).toString(),a=`v1/files/${t}?${r}`;return yield T(this,Re).get(a)})}getImageFills(e){return A(this,arguments,function*({fileKey:t}){var s,r;const a=`v1/files/${t}/images`;return(r=(s=(yield T(this,Re).get(a)).meta)==null?void 0:s.images)!=null?r:{}})}}Re=new WeakMap;const Es=(n,e,t)=>{const s=e.sort();return`${n}-${s.join("-")}-${t}`},As=n=>n?n.ts>Date.now()-1e3*30:!1;var Q,St,fn;class Cs{constructor(e){W(this,St),W(this,Q),this.resourceName="Images",j(this,Q,e)}get(e){return A(this,arguments,function*({fileKey:t,nodeIds:s,format:r="jpg",scale:a}){const i=Es(t,s,r),o=T(this,Q).cache.images.entries.get(i);if(As(o))return o.result;o&&T(this,Q).cache.images.entries.delete(i);const c=T(this,Q).cache.images.pendingRequests.get(i);if(c)return c;const u=ee(this,St,fn).call(this,i,t,s,r,a);T(this,Q).cache.images.pendingRequests.set(i,u);try{return yield u}finally{T(this,Q).cache.images.pendingRequests.delete(i)}})}}Q=new WeakMap,St=new WeakSet,fn=function(n,e,t,s,r){return A(this,null,function*(){const a=yield T(this,Q).get(`v1/images/${e}?ids=${t}&format=${s}${r?`&scale=${r}`:""}`);return T(this,Q).cache.images.entries.set(n,{result:a,ts:Date.now()}),a})};var et;class Os{constructor(e){W(this,et),this.resourceName="Nodes",j(this,et,e)}get(e){return A(this,arguments,function*({fileKey:t,nodeIds:s,params:r={}}){const a=Nt(U({},r),{ids:s.join(",")}),i=new URLSearchParams(U({plugin_data:"857346721138427857"},a)).toString(),o=`v1/files/${t}/nodes?${i}`;return yield T(this,et).get(o)})}}et=new WeakMap;var le;class hn extends Ts{constructor({baseAddress:e="https://api.figma.com/",fetch:t=globalThis.fetch.bind(globalThis)}={}){super({fetch:t,baseAddress:e}),W(this,le,""),this.cache={images:{entries:new Map,pendingRequests:new Map}},this.files=mt(this,new Ss(this)),this.nodes=mt(this,new Os(this)),this.images=mt(this,new Cs(this))}set token(e){if(!e.startsWith("figd_")&&!e.startsWith("figu_"))throw new Error("Invalid Figma access token");j(this,le,e)}get token(){return T(this,le)}get headers(){const e={"Content-Type":"application/json"};return T(this,le).startsWith("figd_")?e["X-FIGMA-TOKEN"]=T(this,le):T(this,le).startsWith("figu_")&&(e.Authorization=`Bearer ${T(this,le)}`),e}}le=new WeakMap;const pn=r=>M(exports,[r],function*({fileKey:n,authToken:e,figmaRestApi:t=new hn,params:s={}}){e&&(t.token=e);try{return yield t.files.get({fileKey:n,params:s})}catch(a){throw console.error(a),a}}),Ns=a=>M(exports,[a],function*({fileKey:n,authToken:e,nodeIds:t,figmaRestApi:s=new hn,params:r={}}){e&&(s.token=e);try{return(yield s.nodes.get({fileKey:n,nodeIds:t,params:d({},r)})).nodes}catch(i){return cn(i,n)}}),Rt=(n,e)=>{if(n.id===e)return n;if("children"in n)for(const t of n.children){const s=Rt(t,e);if(s)return s}return null};var x;(function(n){n.assertEqual=r=>r;function e(r){}n.assertIs=e;function t(r){throw new Error}n.assertNever=t,n.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},n.getValidEnumValues=r=>{const a=n.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of a)i[o]=r[o];return n.objectValues(i)},n.objectValues=r=>n.objectKeys(r).map(function(a){return r[a]}),n.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},n.find=(r,a)=>{for(const i of r)if(a(i))return i},n.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function s(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}n.joinValues=s,n.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var Et;(function(n){n.mergeShapes=(e,t)=>d(d({},e),t)})(Et||(Et={}));const p=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ce=n=>{switch(typeof n){case"undefined":return p.undefined;case"string":return p.string;case"number":return isNaN(n)?p.nan:p.number;case"boolean":return p.boolean;case"function":return p.function;case"bigint":return p.bigint;case"symbol":return p.symbol;case"object":return Array.isArray(n)?p.array:n===null?p.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?p.promise:typeof Map!="undefined"&&n instanceof Map?p.map:typeof Set!="undefined"&&n instanceof Set?p.set:typeof Date!="undefined"&&n instanceof Date?p.date:p.object;default:return p.unknown}},l=x.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"]),Is=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class z extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};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},s={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,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 r(this),s}static assert(e){if(!(e instanceof z))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):s.push(e(r));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}z.create=n=>new z(n);const Ee=(n,e)=>{let t;switch(n.code){case l.invalid_type:n.received===p.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case l.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,x.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(n.keys,", ")}`;break;case l.invalid_union:t="Invalid input";break;case l.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(n.options)}`;break;case l.invalid_enum_value:t=`Invalid enum value. Expected ${x.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}"`:x.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,x.assertNever(n)}return{message:t}};let mn=Ee;function js(n){mn=n}function tt(){return mn}const nt=n=>{const{data:e,path:t,errorMaps:s,issueData:r}=n,a=[...t,...r.path||[]],i=g(d({},r),{path:a});if(r.message!==void 0)return g(d({},r),{path:a,message:r.message});let o="";const c=s.filter(u=>!!u).slice().reverse();for(const u of c)o=u(i,{data:e,defaultError:o}).message;return g(d({},r),{path:a,message:o})},Rs=[];function h(n,e){const t=tt(),s=nt({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===Ee?void 0:Ee].filter(r=>!!r)});n.common.issues.push(s)}class R{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const r of t){if(r.status==="aborted")return v;r.status==="dirty"&&e.dirty(),s.push(r.value)}return{status:e.value,value:s}}static mergeObjectAsync(e,t){return M(this,null,function*(){const s=[];for(const r of t){const a=yield r.key,i=yield r.value;s.push({key:a,value:i})}return R.mergeObjectSync(e,s)})}static mergeObjectSync(e,t){const s={};for(const r of t){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return v;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value!="undefined"||r.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}}const v=Object.freeze({status:"aborted"}),ke=n=>({status:"dirty",value:n}),$=n=>({status:"valid",value:n}),At=n=>n.status==="aborted",Ct=n=>n.status==="dirty",_e=n=>n.status==="valid",Pe=n=>typeof Promise!="undefined"&&n instanceof Promise;function st(n,e,t,s){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 gn(n,e,t,s,r){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 m;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(m||(m={}));var Ze,Me;class ne{constructor(e,t,s,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=r}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 Ht=(n,e)=>{if(_e(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 z(n.common.issues);return this._error=t,this._error}}};function b(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:r}=n;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(i,o)=>{var c,u;const{message:f}=n;return i.code==="invalid_enum_value"?{message:f!=null?f:o.defaultError}:typeof o.data=="undefined"?{message:(c=f!=null?f:s)!==null&&c!==void 0?c:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f!=null?f:t)!==null&&u!==void 0?u:o.defaultError}},description:r}}class w{get description(){return this._def.description}_getType(e){return ce(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new R,ctx:{common:e.parent.common,data:e.data,parsedType:ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Pe(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 s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const r={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ce(e)},a=this._parseSync({data:e,path:r.path,parent:r});return Ht(r,a)}"~validate"(e){var t,s;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ce(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:r});return _e(a)?{value:a.value}:{issues:r.common.issues}}catch(a){!((s=(t=a==null?void 0:a.message)===null||t===void 0?void 0:t.toLowerCase())===null||s===void 0)&&s.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(a=>_e(a)?{value:a.value}:{issues:r.common.issues})}parseAsync(e,t){return M(this,null,function*(){const s=yield this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error})}safeParseAsync(e,t){return M(this,null,function*(){const s={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:ce(e)},r=this._parse({data:e,path:s.path,parent:s}),a=yield Pe(r)?r:Promise.resolve(r);return Ht(s,a)})}refine(e,t){const s=r=>typeof t=="string"||typeof t=="undefined"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,a)=>{const i=e(r),o=()=>a.addIssue(d({code:l.custom},s(r)));return typeof Promise!="undefined"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,r)=>e(s)?!0:(r.addIssue(typeof t=="function"?t(s,r):t),!1))}_refinement(e){return new K({schema:this,typeName:y.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 te.create(this,this._def)}nullable(){return me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return G.create(this)}promise(){return Ce.create(this,this._def)}or(e){return Le.create([this,e],this._def)}and(e){return De.create(this,e,this._def)}transform(e){return new K(g(d({},b(this._def)),{schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}}))}default(e){const t=typeof e=="function"?e:()=>e;return new qe(g(d({},b(this._def)),{innerType:this,defaultValue:t,typeName:y.ZodDefault}))}brand(){return new Zt(d({typeName:y.ZodBranded,type:this},b(this._def)))}catch(e){const t=typeof e=="function"?e:()=>e;return new He(g(d({},b(this._def)),{innerType:this,catchValue:t,typeName:y.ZodCatch}))}describe(e){const t=this.constructor;return new t(g(d({},this._def),{description:e}))}pipe(e){return Ke.create(this,e)}readonly(){return Je.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Zs=/^c[^\s-]{8,}$/i,Ms=/^[0-9a-z]+$/,Ps=/^[0-9A-HJKMNP-TV-Z]{26}$/i,$s=/^[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,Fs=/^[a-z0-9_-]{21}$/i,Vs=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ls=/^[-+]?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)?)??$/,Ds=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Us="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let gt;const zs=/^(?:(?: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])$/,Ws=/^(?:(?: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])$/,Bs=/^(([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]))$/,qs=/^(([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])$/,Hs=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Js=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,yn="((\\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])))",Gs=new RegExp(`^${yn}$`);function vn(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 Ks(n){return new RegExp(`^${vn(n)}$`)}function _n(n){let e=`${yn}T${vn(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 Xs(n,e){return!!((e==="v4"||!e)&&zs.test(n)||(e==="v6"||!e)&&Bs.test(n))}function Ys(n,e){if(!Vs.test(n))return!1;try{const[t]=n.split("."),s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),r=JSON.parse(atob(s));return!(typeof r!="object"||r===null||!r.typ||!r.alg||e&&r.alg!==e)}catch(t){return!1}}function Qs(n,e){return!!((e==="v4"||!e)&&Ws.test(n)||(e==="v6"||!e)&&qs.test(n))}class J extends w{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_type,expected:p.string,received:a.parsedType}),v}const s=new R;let r;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(r=this._getOrReturnCtx(e,r),h(r,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(r=this._getOrReturnCtx(e,r),h(r,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(r=this._getOrReturnCtx(e,r),i?h(r,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&h(r,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")Ds.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"email",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")gt||(gt=new RegExp(Us,"u")),gt.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"emoji",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")$s.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"uuid",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")Fs.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"nanoid",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")Zs.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"cuid",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")Ms.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"cuid2",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")Ps.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"ulid",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch(i){r=this._getOrReturnCtx(e,r),h(r,{validation:"url",code:l.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"regex",code:l.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(r=this._getOrReturnCtx(e,r),h(r,{code:l.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(r=this._getOrReturnCtx(e,r),h(r,{code:l.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(r=this._getOrReturnCtx(e,r),h(r,{code:l.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?_n(a).test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:l.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?Gs.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:l.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?Ks(a).test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:l.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?Ls.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"duration",code:l.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?Xs(e.data,a.version)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"ip",code:l.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?Ys(e.data,a.alg)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"jwt",code:l.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?Qs(e.data,a.version)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"cidr",code:l.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?Hs.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"base64",code:l.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?Js.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"base64url",code:l.invalid_string,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(r=>e.test(r),d({validation:t,code:l.invalid_string},m.errToObj(s)))}_addCheck(e){return new J(g(d({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(d({kind:"email"},m.errToObj(e)))}url(e){return this._addCheck(d({kind:"url"},m.errToObj(e)))}emoji(e){return this._addCheck(d({kind:"emoji"},m.errToObj(e)))}uuid(e){return this._addCheck(d({kind:"uuid"},m.errToObj(e)))}nanoid(e){return this._addCheck(d({kind:"nanoid"},m.errToObj(e)))}cuid(e){return this._addCheck(d({kind:"cuid"},m.errToObj(e)))}cuid2(e){return this._addCheck(d({kind:"cuid2"},m.errToObj(e)))}ulid(e){return this._addCheck(d({kind:"ulid"},m.errToObj(e)))}base64(e){return this._addCheck(d({kind:"base64"},m.errToObj(e)))}base64url(e){return this._addCheck(d({kind:"base64url"},m.errToObj(e)))}jwt(e){return this._addCheck(d({kind:"jwt"},m.errToObj(e)))}ip(e){return this._addCheck(d({kind:"ip"},m.errToObj(e)))}cidr(e){return this._addCheck(d({kind:"cidr"},m.errToObj(e)))}datetime(e){var t,s;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:(s=e==null?void 0:e.local)!==null&&s!==void 0?s:!1},m.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},m.errToObj(e==null?void 0:e.message)))}duration(e){return this._addCheck(d({kind:"duration"},m.errToObj(e)))}regex(e,t){return this._addCheck(d({kind:"regex",regex:e},m.errToObj(t)))}includes(e,t){return this._addCheck(d({kind:"includes",value:e,position:t==null?void 0:t.position},m.errToObj(t==null?void 0:t.message)))}startsWith(e,t){return this._addCheck(d({kind:"startsWith",value:e},m.errToObj(t)))}endsWith(e,t){return this._addCheck(d({kind:"endsWith",value:e},m.errToObj(t)))}min(e,t){return this._addCheck(d({kind:"min",value:e},m.errToObj(t)))}max(e,t){return this._addCheck(d({kind:"max",value:e},m.errToObj(t)))}length(e,t){return this._addCheck(d({kind:"length",value:e},m.errToObj(t)))}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new J(g(d({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}toLowerCase(){return new J(g(d({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new J(g(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}}J.create=n=>{var e;return new J(d({checks:[],typeName:y.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1},b(n)))};function er(n,e){const t=(n.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,r=t>s?t:s,a=parseInt(n.toFixed(r).replace(".","")),i=parseInt(e.toFixed(r).replace(".",""));return a%i/Math.pow(10,r)}class fe extends w{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)!==p.number){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_type,expected:p.number,received:a.parsedType}),v}let s;const r=new R;for(const a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:l.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),h(s,{code:l.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),h(s,{code:l.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?er(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),h(s,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:l.not_finite,message:a.message}),r.dirty()):x.assertNever(a);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,s,r){return new fe(g(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:m.toString(r)}]}))}_addCheck(e){return new fe(g(d({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.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"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}fe.create=n=>new fe(d({checks:[],typeName:y.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1},b(n)));class he extends w{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch(a){return this._getInvalidInput(e)}if(this._getType(e)!==p.bigint)return this._getInvalidInput(e);let s;const r=new R;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),h(s,{code:l.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),h(s,{code:l.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),h(s,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):x.assertNever(a);return{status:r.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return h(t,{code:l.invalid_type,expected:p.bigint,received:t.parsedType}),v}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,s,r){return new he(g(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:m.toString(r)}]}))}_addCheck(e){return new he(g(d({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.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}}he.create=n=>{var e;return new he(d({checks:[],typeName:y.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1},b(n)))};class $e extends w{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.boolean,received:s.parsedType}),v}return $(e.data)}}$e.create=n=>new $e(d({typeName:y.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1},b(n)));class be extends w{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_type,expected:p.date,received:a.parsedType}),v}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_date}),v}const s=new R;let r;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(r=this._getOrReturnCtx(e,r),h(r,{code:l.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(r=this._getOrReturnCtx(e,r),h(r,{code:l.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):x.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new be(g(d({},this._def),{checks:[...this._def.checks,e]}))}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:m.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}}be.create=n=>new be(d({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:y.ZodDate},b(n)));class rt extends w{_parse(e){if(this._getType(e)!==p.symbol){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.symbol,received:s.parsedType}),v}return $(e.data)}}rt.create=n=>new rt(d({typeName:y.ZodSymbol},b(n)));class Fe extends w{_parse(e){if(this._getType(e)!==p.undefined){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.undefined,received:s.parsedType}),v}return $(e.data)}}Fe.create=n=>new Fe(d({typeName:y.ZodUndefined},b(n)));class Ve extends w{_parse(e){if(this._getType(e)!==p.null){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.null,received:s.parsedType}),v}return $(e.data)}}Ve.create=n=>new Ve(d({typeName:y.ZodNull},b(n)));class Ae extends w{constructor(){super(...arguments),this._any=!0}_parse(e){return $(e.data)}}Ae.create=n=>new Ae(d({typeName:y.ZodAny},b(n)));class ve extends w{constructor(){super(...arguments),this._unknown=!0}_parse(e){return $(e.data)}}ve.create=n=>new ve(d({typeName:y.ZodUnknown},b(n)));class de extends w{_parse(e){const t=this._getOrReturnCtx(e);return h(t,{code:l.invalid_type,expected:p.never,received:t.parsedType}),v}}de.create=n=>new de(d({typeName:y.ZodNever},b(n)));class at extends w{_parse(e){if(this._getType(e)!==p.undefined){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.void,received:s.parsedType}),v}return $(e.data)}}at.create=n=>new at(d({typeName:y.ZodVoid},b(n)));class G extends w{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),r=this._def;if(t.parsedType!==p.array)return h(t,{code:l.invalid_type,expected:p.array,received:t.parsedType}),v;if(r.exactLength!==null){const i=t.data.length>r.exactLength.value,o=t.data.length<r.exactLength.value;(i||o)&&(h(t,{code:i?l.too_big:l.too_small,minimum:o?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),s.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(h(t,{code:l.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),s.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(h(t,{code:l.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>r.type._parseAsync(new ne(t,i,t.path,o)))).then(i=>R.mergeArray(s,i));const a=[...t.data].map((i,o)=>r.type._parseSync(new ne(t,i,t.path,o)));return R.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new G(g(d({},this._def),{minLength:{value:e,message:m.toString(t)}}))}max(e,t){return new G(g(d({},this._def),{maxLength:{value:e,message:m.toString(t)}}))}length(e,t){return new G(g(d({},this._def),{exactLength:{value:e,message:m.toString(t)}}))}nonempty(e){return this.min(1,e)}}G.create=(n,e)=>new G(d({type:n,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray},b(e)));function xe(n){if(n instanceof S){const e={};for(const t in n.shape){const s=n.shape[t];e[t]=te.create(xe(s))}return new S(g(d({},n._def),{shape:()=>e}))}else return n instanceof G?new G(g(d({},n._def),{type:xe(n.element)})):n instanceof te?te.create(xe(n.unwrap())):n instanceof me?me.create(xe(n.unwrap())):n instanceof se?se.create(n.items.map(e=>xe(e))):n}class S extends w{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=x.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==p.object){const u=this._getOrReturnCtx(e);return h(u,{code:l.invalid_type,expected:p.object,received:u.parsedType}),v}const{status:s,ctx:r}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof de&&this._def.unknownKeys==="strip"))for(const u in r.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const f=a[u],_=r.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new ne(r,_,r.path,u)),alwaysSet:u in r.data})}if(this._def.catchall instanceof de){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:r.data[f]}});else if(u==="strict")o.length>0&&(h(r,{code:l.unrecognized_keys,keys:o}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const _=r.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new ne(r,_,r.path,f)),alwaysSet:f in r.data})}}return r.common.async?Promise.resolve().then(()=>M(this,null,function*(){const u=[];for(const f of c){const _=yield f.key,I=yield f.value;u.push({key:_,value:I,alwaysSet:f.alwaysSet})}return u})).then(u=>R.mergeObjectSync(s,u)):R.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new S(d(g(d({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:(t,s)=>{var r,a,i,o;const c=(i=(a=(r=this._def).errorMap)===null||a===void 0?void 0:a.call(r,t,s).message)!==null&&i!==void 0?i:s.defaultError;return t.code==="unrecognized_keys"?{message:(o=m.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}))}strip(){return new S(g(d({},this._def),{unknownKeys:"strip"}))}passthrough(){return new S(g(d({},this._def),{unknownKeys:"passthrough"}))}extend(e){return new S(g(d({},this._def),{shape:()=>d(d({},this._def.shape()),e)}))}merge(e){return new S({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>d(d({},this._def.shape()),e._def.shape()),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new S(g(d({},this._def),{catchall:e}))}pick(e){const t={};return x.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new S(g(d({},this._def),{shape:()=>t}))}omit(e){const t={};return x.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new S(g(d({},this._def),{shape:()=>t}))}deepPartial(){return xe(this)}partial(e){const t={};return x.objectKeys(this.shape).forEach(s=>{const r=this.shape[s];e&&!e[s]?t[s]=r:t[s]=r.optional()}),new S(g(d({},this._def),{shape:()=>t}))}required(e){const t={};return x.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof te;)a=a._def.innerType;t[s]=a}}),new S(g(d({},this._def),{shape:()=>t}))}keyof(){return bn(x.objectKeys(this.shape))}}S.create=(n,e)=>new S(d({shape:()=>n,unknownKeys:"strip",catchall:de.create(),typeName:y.ZodObject},b(e)));S.strictCreate=(n,e)=>new S(d({shape:()=>n,unknownKeys:"strict",catchall:de.create(),typeName:y.ZodObject},b(e)));S.lazycreate=(n,e)=>new S(d({shape:n,unknownKeys:"strip",catchall:de.create(),typeName:y.ZodObject},b(e)));class Le extends w{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function r(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 z(o.ctx.common.issues));return h(t,{code:l.invalid_union,unionErrors:i}),v}if(t.common.async)return Promise.all(s.map(a=>M(this,null,function*(){const i=g(d({},t),{common:g(d({},t.common),{issues:[]}),parent:null});return{result:yield a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}}))).then(r);{let a;const i=[];for(const c of s){const u=g(d({},t),{common:g(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 z(c));return h(t,{code:l.invalid_union,unionErrors:o}),v}}get options(){return this._def.options}}Le.create=(n,e)=>new Le(d({options:n,typeName:y.ZodUnion},b(e)));const oe=n=>n instanceof ze?oe(n.schema):n instanceof K?oe(n.innerType()):n instanceof We?[n.value]:n instanceof pe?n.options:n instanceof Be?x.objectValues(n.enum):n instanceof qe?oe(n._def.innerType):n instanceof Fe?[void 0]:n instanceof Ve?[null]:n instanceof te?[void 0,...oe(n.unwrap())]:n instanceof me?[null,...oe(n.unwrap())]:n instanceof Zt||n instanceof Je?oe(n.unwrap()):n instanceof He?oe(n._def.innerType):[];class dt extends w{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.object)return h(t,{code:l.invalid_type,expected:p.object,received:t.parsedType}),v;const s=this.discriminator,r=t.data[s],a=this.optionsMap.get(r);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}):(h(t,{code:l.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const r=new Map;for(const a of t){const i=oe(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(r.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);r.set(o,a)}}return new dt(d({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r},b(s)))}}function Ot(n,e){const t=ce(n),s=ce(e);if(n===e)return{valid:!0,data:n};if(t===p.object&&s===p.object){const r=x.objectKeys(e),a=x.objectKeys(n).filter(o=>r.indexOf(o)!==-1),i=d(d({},n),e);for(const o of a){const c=Ot(n[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===p.array&&s===p.array){if(n.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<n.length;a++){const i=n[a],o=e[a],c=Ot(i,o);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return t===p.date&&s===p.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class De extends w{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=(a,i)=>{if(At(a)||At(i))return v;const o=Ot(a.value,i.value);return o.valid?((Ct(a)||Ct(i))&&t.dirty(),{status:t.value,value:o.data}):(h(s,{code:l.invalid_intersection_types}),v)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>r(a,i)):r(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}De.create=(n,e,t)=>new De(d({left:n,right:e,typeName:y.ZodIntersection},b(t)));class se extends w{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.array)return h(s,{code:l.invalid_type,expected:p.array,received:s.parsedType}),v;if(s.data.length<this._def.items.length)return h(s,{code:l.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&s.data.length>this._def.items.length&&(h(s,{code:l.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...s.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new ne(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>R.mergeArray(t,i)):R.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new se(g(d({},this._def),{rest:e}))}}se.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new se(d({items:n,typeName:y.ZodTuple,rest:null},b(e)))};class Ue extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.object)return h(s,{code:l.invalid_type,expected:p.object,received:s.parsedType}),v;const r=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)r.push({key:a._parse(new ne(s,o,s.path,o)),value:i._parse(new ne(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?R.mergeObjectAsync(t,r):R.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof w?new Ue(d({keyType:e,valueType:t,typeName:y.ZodRecord},b(s))):new Ue(d({keyType:J.create(),valueType:e,typeName:y.ZodRecord},b(t)))}}class it extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.map)return h(s,{code:l.invalid_type,expected:p.map,received:s.parsedType}),v;const r=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],u)=>({key:r._parse(new ne(s,o,s.path,[u,"key"])),value:a._parse(new ne(s,c,s.path,[u,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(()=>M(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 v;(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 v;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}it.create=(n,e,t)=>new it(d({valueType:e,keyType:n,typeName:y.ZodMap},b(t)));class we extends w{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.set)return h(s,{code:l.invalid_type,expected:p.set,received:s.parsedType}),v;const r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&(h(s,{code:l.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&s.data.size>r.maxSize.value&&(h(s,{code:l.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.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 v;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...s.data.values()].map((c,u)=>a._parse(new ne(s,c,s.path,u)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new we(g(d({},this._def),{minSize:{value:e,message:m.toString(t)}}))}max(e,t){return new we(g(d({},this._def),{maxSize:{value:e,message:m.toString(t)}}))}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}we.create=(n,e)=>new we(d({valueType:n,minSize:null,maxSize:null,typeName:y.ZodSet},b(e)));class Te extends w{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.function)return h(t,{code:l.invalid_type,expected:p.function,received:t.parsedType}),v;function s(o,c){return nt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,tt(),Ee].filter(u=>!!u),issueData:{code:l.invalid_arguments,argumentsError:c}})}function r(o,c){return nt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,tt(),Ee].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 Ce){const o=this;return $(function(...c){return M(this,null,function*(){const u=new z([]),f=yield o._def.args.parseAsync(c,a).catch(C=>{throw u.addIssue(s(c,C)),u}),_=yield Reflect.apply(i,this,f);return yield o._def.returns._def.type.parseAsync(_,a).catch(C=>{throw u.addIssue(r(_,C)),u})})})}else{const o=this;return $(function(...c){const u=o._def.args.safeParse(c,a);if(!u.success)throw new z([s(c,u.error)]);const f=Reflect.apply(i,this,u.data),_=o._def.returns.safeParse(f,a);if(!_.success)throw new z([r(f,_.error)]);return _.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Te(g(d({},this._def),{args:se.create(e).rest(ve.create())}))}returns(e){return new Te(g(d({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new Te(d({args:e||se.create([]).rest(ve.create()),returns:t||ve.create(),typeName:y.ZodFunction},b(s)))}}class ze extends w{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})}}ze.create=(n,e)=>new ze(d({getter:n,typeName:y.ZodLazy},b(e)));class We extends w{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return h(t,{received:t.data,code:l.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}}We.create=(n,e)=>new We(d({value:n,typeName:y.ZodLiteral},b(e)));function bn(n,e){return new pe(d({values:n,typeName:y.ZodEnum},b(e)))}class pe extends w{constructor(){super(...arguments),Ze.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return h(t,{expected:x.joinValues(s),received:t.parsedType,code:l.invalid_type}),v}if(st(this,Ze)||gn(this,Ze,new Set(this._def.values)),!st(this,Ze).has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return h(t,{received:t.data,code:l.invalid_enum_value,options:s}),v}return $(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 pe.create(e,d(d({},this._def),t))}exclude(e,t=this._def){return pe.create(this.options.filter(s=>!e.includes(s)),d(d({},this._def),t))}}Ze=new WeakMap;pe.create=bn;class Be extends w{constructor(){super(...arguments),Me.set(this,void 0)}_parse(e){const t=x.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==p.string&&s.parsedType!==p.number){const r=x.objectValues(t);return h(s,{expected:x.joinValues(r),received:s.parsedType,code:l.invalid_type}),v}if(st(this,Me)||gn(this,Me,new Set(x.getValidEnumValues(this._def.values))),!st(this,Me).has(e.data)){const r=x.objectValues(t);return h(s,{received:s.data,code:l.invalid_enum_value,options:r}),v}return $(e.data)}get enum(){return this._def.values}}Me=new WeakMap;Be.create=(n,e)=>new Be(d({values:n,typeName:y.ZodNativeEnum},b(e)));class Ce extends w{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.promise&&t.common.async===!1)return h(t,{code:l.invalid_type,expected:p.promise,received:t.parsedType}),v;const s=t.parsedType===p.promise?t.data:Promise.resolve(t.data);return $(s.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ce.create=(n,e)=>new Ce(d({type:n,typeName:y.ZodPromise},b(e)));class K extends w{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{h(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(s.data,a);if(s.common.async)return Promise.resolve(i).then(o=>M(this,null,function*(){if(t.value==="aborted")return v;const c=yield this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?v:c.status==="dirty"||t.value==="dirty"?ke(c.value):c}));{if(t.value==="aborted")return v;const o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?v:o.status==="dirty"||t.value==="dirty"?ke(o.value):o}}if(r.type==="refinement"){const i=o=>{const c=r.refinement(o,a);if(s.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(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?v:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?v:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(r.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!_e(i))return i;const o=r.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:s.data,path:s.path,parent:s}).then(i=>_e(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);x.assertNever(r)}}K.create=(n,e,t)=>new K(d({schema:n,typeName:y.ZodEffects,effect:e},b(t)));K.createWithPreprocess=(n,e,t)=>new K(d({schema:e,effect:{type:"preprocess",transform:n},typeName:y.ZodEffects},b(t)));class te extends w{_parse(e){return this._getType(e)===p.undefined?$(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}te.create=(n,e)=>new te(d({innerType:n,typeName:y.ZodOptional},b(e)));class me extends w{_parse(e){return this._getType(e)===p.null?$(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}me.create=(n,e)=>new me(d({innerType:n,typeName:y.ZodNullable},b(e)));class qe extends w{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===p.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}qe.create=(n,e)=>new qe(d({innerType:n,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default},b(e)));class He extends w{_parse(e){const{ctx:t}=this._processInputParams(e),s=g(d({},t),{common:g(d({},t.common),{issues:[]})}),r=this._def.innerType._parse({data:s.data,path:s.path,parent:d({},s)});return Pe(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new z(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new z(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}He.create=(n,e)=>new He(d({innerType:n,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},b(e)));class ot extends w{_parse(e){if(this._getType(e)!==p.nan){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.nan,received:s.parsedType}),v}return{status:"valid",value:e.data}}}ot.create=n=>new ot(d({typeName:y.ZodNaN},b(n)));const tr=Symbol("zod_brand");class Zt extends w{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ke extends w{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return M(this,null,function*(){const a=yield this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?v:a.status==="dirty"?(t.dirty(),ke(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})});{const r=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?v:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:s.path,parent:s})}}static create(e,t){return new Ke({in:e,out:t,typeName:y.ZodPipeline})}}class Je extends w{_parse(e){const t=this._def.innerType._parse(e),s=r=>(_e(r)&&(r.value=Object.freeze(r.value)),r);return Pe(t)?t.then(r=>s(r)):s(t)}unwrap(){return this._def.innerType}}Je.create=(n,e)=>new Je(d({innerType:n,typeName:y.ZodReadonly},b(e)));function wn(n,e={},t){return n?Ae.create().superRefine((s,r)=>{var a,i;if(!n(s)){const o=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,u=typeof o=="string"?{message:o}:o;r.addIssue(g(d({code:"custom"},u),{fatal:c}))}}):Ae.create()}const nr={object:S.lazycreate};var y;(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"})(y||(y={}));const sr=(n,e={message:`Input not instance of ${n.name}`})=>wn(t=>t instanceof n,e),xn=J.create,kn=fe.create,rr=ot.create,ar=he.create,Tn=$e.create,ir=be.create,or=rt.create,cr=Fe.create,dr=Ve.create,ur=Ae.create,lr=ve.create,fr=de.create,hr=at.create,pr=G.create,mr=S.create,gr=S.strictCreate,yr=Le.create,vr=dt.create,_r=De.create,br=se.create,wr=Ue.create,xr=it.create,kr=we.create,Tr=Te.create,Sr=ze.create,Er=We.create,Ar=pe.create,Cr=Be.create,Or=Ce.create,Jt=K.create,Nr=te.create,Ir=me.create,jr=K.createWithPreprocess,Rr=Ke.create,Zr=()=>xn().optional(),Mr=()=>kn().optional(),Pr=()=>Tn().optional(),$r={string:n=>J.create(g(d({},n),{coerce:!0})),number:n=>fe.create(g(d({},n),{coerce:!0})),boolean:n=>$e.create(g(d({},n),{coerce:!0})),bigint:n=>he.create(g(d({},n),{coerce:!0})),date:n=>be.create(g(d({},n),{coerce:!0}))},Fr=v;var N=Object.freeze({__proto__:null,defaultErrorMap:Ee,setErrorMap:js,getErrorMap:tt,makeIssue:nt,EMPTY_PATH:Rs,addIssueToContext:h,ParseStatus:R,INVALID:v,DIRTY:ke,OK:$,isAborted:At,isDirty:Ct,isValid:_e,isAsync:Pe,get util(){return x},get objectUtil(){return Et},ZodParsedType:p,getParsedType:ce,ZodType:w,datetimeRegex:_n,ZodString:J,ZodNumber:fe,ZodBigInt:he,ZodBoolean:$e,ZodDate:be,ZodSymbol:rt,ZodUndefined:Fe,ZodNull:Ve,ZodAny:Ae,ZodUnknown:ve,ZodNever:de,ZodVoid:at,ZodArray:G,ZodObject:S,ZodUnion:Le,ZodDiscriminatedUnion:dt,ZodIntersection:De,ZodTuple:se,ZodRecord:Ue,ZodMap:it,ZodSet:we,ZodFunction:Te,ZodLazy:ze,ZodLiteral:We,ZodEnum:pe,ZodNativeEnum:Be,ZodPromise:Ce,ZodEffects:K,ZodTransformer:K,ZodOptional:te,ZodNullable:me,ZodDefault:qe,ZodCatch:He,ZodNaN:ot,BRAND:tr,ZodBranded:Zt,ZodPipeline:Ke,ZodReadonly:Je,custom:wn,Schema:w,ZodSchema:w,late:nr,get ZodFirstPartyTypeKind(){return y},coerce:$r,any:ur,array:pr,bigint:ar,boolean:Tn,date:ir,discriminatedUnion:vr,effect:Jt,enum:Ar,function:Tr,instanceof:sr,intersection:_r,lazy:Sr,literal:Er,map:xr,nan:rr,nativeEnum:Cr,never:fr,null:dr,nullable:Ir,number:kn,object:mr,oboolean:Pr,onumber:Mr,optional:Nr,ostring:Zr,pipeline:Rr,preprocess:jr,promise:Or,record:wr,set:kr,strictObject:gr,string:xn,symbol:or,transformer:Jt,tuple:br,undefined:cr,union:yr,unknown:lr,void:hr,NEVER:Fr,ZodIssueCode:l,quotelessJson:Is,ZodError:z});const Vr=N.object({language:N.enum(["typescript","javascript"]).optional(),disableMarkedForExport: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"]).optional(),enableUILibraryTheming:N.boolean().optional(),enableCompactStructure:N.boolean().optional(),enableAutoSplit:N.boolean().optional(),autoSplitThreshold:N.number().optional()}),N.object({framework:N.literal("html"),styling:N.enum(["plain_css","inline_styles"]),enableTranslation:N.boolean().optional()})])),Sn=n=>{const e=Vr.safeParse(n);if(e.success===!1){const t=new Error("Invalid codegen settings");throw t.cause=e.error,t}return e.data},Gt=new Set(["FRAME","INSTANCE","COMPONENT","COMPONENT_SET","GROUP"]),En=(n,e)=>{const t=Rt(n.document,e);if(!t)return{isValid:!1,reason:"There is no node with the given id"};if(t.type==="CANVAS"){const s=t.children.filter(r=>Gt.has(r.type));return s.length===1?{isValid:!0,node:s[0],note:"Selected node is a page with a single valid children - returning it instead"}:{isValid:!1,reason:"Selected node is a page with multiple children"}}return Gt.has(t.type)?{isValid:!0,node:t}:{isValid:!1,reason:"Selected node type is not supported"}};var D,Ge,ct,An;class Lr{constructor({auth:e,apiBaseAddress:t="https://public-api.animaapp.com"}={}){Xe(this,ct);Xe(this,D);Xe(this,Ge);ft(this,Ge,t),e&&(this.auth=e)}hasAuth(){return!!H(this,D)}set auth(e){ft(this,D,e)}get headers(){const e={"Content-Type":"application/json"};return H(this,D)&&(e.Authorization=`Bearer ${H(this,D).token}`,"teamId"in H(this,D)&&(e["X-Team-Id"]=H(this,D).teamId)),e}generateCode(s){return M(this,arguments,function*(e,t={}){var _,I,C,O,Z,B,re,ue,V;if(this.hasAuth()===!1)throw new Error('It needs to set "auth" before calling this method.');e.figmaToken&&(yield Ft(this,ct,An).call(this,e.fileKey,e.figmaToken,e.nodesId));const r={},a=Sn(e.settings);let i=e.tracking;H(this,D)&&"userId"in H(this,D)&&H(this,D).userId&&(i!=null&&i.externalId||(i={externalId:H(this,D).userId}));const o=yield fetch(`${H(this,Ge)}/v1/codegen`,{method:"POST",headers:g(d({},this.headers),{Accept:"text/event-stream"}),body:JSON.stringify({tracking:i,fileKey:e.fileKey,figmaToken:e.figmaToken,nodesId:e.nodesId,assetsStorage:e.assetsStorage,language:a.language,model:a.model,framework:a.framework,styling:a.styling,uiLibrary:a.uiLibrary,enableTranslation:a.enableTranslation,enableUILibraryTheming:a.enableUILibraryTheming,enableCompactStructure:a.enableCompactStructure,enableAutoSplit:a.enableAutoSplit,autoSplitThreshold:a.autoSplitThreshold,disableMarkedForExport:a.disableMarkedForExport})});if(!o.ok){const X=yield o.text();let q;try{q=JSON.parse(X)}catch(Oe){}throw((_=q==null?void 0:q.error)==null?void 0:_.name)==="ZodError"?new ie({name:"HTTP error from Anima API",reason:"Invalid body payload",detail:q.error.issues,status:o.status}):typeof q=="object"?new ie({name:`Error "${q}"`,reason:"Unknown",status:o.status}):new ie({name:"HTTP error from Anima API",reason:X,status:o.status})}if(!o.body)throw new ie({name:"Stream Error",reason:"Response body is null",status:o.status});const c=o.body.getReader(),u=new TextDecoder;let f="";try{for(;;){const{done:X,value:q}=yield c.read();if(X)break;f+=u.decode(q,{stream:!0});const Oe=f.split(`
2
- `);f=Oe.pop()||"";for(const E of Oe)if(!(!E.trim()||E.startsWith(":"))&&E.startsWith("data: ")){let k;try{k=JSON.parse(E.slice(6))}catch(ut){continue}switch(k.type){case"queueing":{typeof t=="function"?t(k):(I=t.onQueueing)==null||I.call(t);break}case"start":{r.sessionId=k.sessionId,typeof t=="function"?t(k):(C=t.onStart)==null||C.call(t,{sessionId:k.sessionId});break}case"pre_codegen":{typeof t=="function"?t(k):(O=t.onPreCodegen)==null||O.call(t,{message:k.message});break}case"assets_uploaded":{typeof t=="function"?t(k):(Z=t.onAssetsUploaded)==null||Z.call(t);break}case"assets_list":{r.assets=k.payload.assets,typeof t=="function"?t(k):(B=t.onAssetsList)==null||B.call(t,k.payload);break}case"figma_metadata":{r.figmaFileName=k.figmaFileName,r.figmaSelectedFrameName=k.figmaSelectedFrameName,typeof t=="function"?t(k):(re=t.onFigmaMetadata)==null||re.call(t,{figmaFileName:k.figmaFileName,figmaSelectedFrameName:k.figmaSelectedFrameName});break}case"generating_code":{k.payload.status==="success"&&(r.files=k.payload.files),typeof t=="function"?t(k):(ue=t.onGeneratingCode)==null||ue.call(t,{status:k.payload.status,progress:k.payload.progress,files:k.payload.files});break}case"codegen_completed":{typeof t=="function"?t(k):(V=t.onCodegenCompleted)==null||V.call(t);break}case"error":throw new ie({name:k.payload.errorName,reason:k.payload.reason});case"done":{if(!r.files)throw new ie({name:"Invalid response",reason:"No code generated"});return r.tokenUsage=k.payload.tokenUsage,r}}}}}finally{c.cancel()}throw new ie({name:"Connection",reason:"Connection closed before the 'done' message",status:500})})}}D=new WeakMap,Ge=new WeakMap,ct=new WeakSet,An=function(e,t,s){return M(this,null,function*(){let r;try{r=yield pn({fileKey:e,authToken:t,params:{geometry:"paths"}})}catch(o){return}const i=s.map(o=>En(r,o)).find(o=>!o.isValid);if(i)throw new ie({name:"Task Crashed",reason:i.reason})})};const Dr=n=>{var e;if(!n)return[!1,"",""];try{const t=new URL(n),s=t.pathname;if(t.origin!=="https://www.figma.com")return[!1,"",""];const r=((e=t.searchParams.get("node-id"))!=null?e:"").replace(/-/g,":"),a=s.split("/")[2];return[(s.startsWith("/file/")&&t.searchParams.get("type")!=="whiteboard"||s.startsWith("/design/"))&&a.length===22,a,r]}catch(t){return[!1,"",""]}},Ur=({fileKey:n,nodeId:e,duplicate:t})=>{const s=new URL("https://www.figma.com");return s.pathname=`design/${n}`,t&&(s.pathname=`${s.pathname}/duplicate`),e&&s.searchParams.set("node-id",e.replace(":","-")),s};class zr extends Error{constructor(e,t){super(e),this.response=t}}const Wr=({files:n,screenPath:e="src/screens"})=>{const t={},s=new Set;function r(a){if(s.has(a)||!n[a])return;s.add(a),t[a]=n[a],Br(n[a].content).forEach(o=>{try{const c=qr(a,o);if(c.startsWith("src/")){const u=c.split("/").slice(0,-1).join("/");Hr(n,u).forEach(_=>{s.has(_)||r(_)})}}catch(c){console.warn(`Failed to resolve import ${o} in ${a}:`,c)}})}return Object.entries(n).forEach(([a,i])=>{a.startsWith(e)?r(a):a.startsWith("src/")||(t[a]=i)}),t};function Br(n){const e=/import.*?["']([^"']+)["']/g,t=/export.*from\s+["']([^"']+)["']/g,s=[];let r;for(;(r=e.exec(n))!==null;)s.push(r[1]);for(;(r=t.exec(n))!==null;)s.push(r[1]);return[...new Set(s)]}function qr(n,e){if(!e.startsWith("."))return e;const t=n.split("/").slice(0,-1),s=e.split("/"),r=[...t];for(const a of s)a===".."?r.pop():a!=="."&&r.push(a);return r.join("/")}function Hr(n,e){return Object.keys(n).filter(t=>t.startsWith(e))}const Cn=(n,e)=>new ReadableStream({start(t){n.generateCode(e,s=>{s.type==="error"||t.enqueue(s),(s.type==="aborted"||s.type==="error")&&t.close()}).then(s=>{t.enqueue({type:"done",payload:{tokenUsage:s.tokenUsage,sessionId:s.sessionId}}),t.close()}).catch(s=>{t.enqueue({type:"error",payload:{name:"name"in s?s.name:"Unknown error",message:"message"in s?s.message:"Unknown",status:"status"in s?s.status:void 0,detail:"detail"in s?s.detail:void 0}}),t.close()})}}),Jr=(n,e)=>M(exports,null,function*(){var c,u,f,_,I,C,O;const t=Cn(n,e),[s,r]=t.tee(),a=yield s.getReader().read();if(a.done||!a.value||((c=a.value)==null?void 0:c.type)==="error"&&((f=(u=a.value)==null?void 0:u.payload)!=null&&f.status))return new Response(JSON.stringify(a.value),{status:((_=a.value)==null?void 0:_.type)==="error"&&(O=(C=(I=a.value)==null?void 0:I.payload)==null?void 0:C.status)!=null?O:500,headers:{"Content-Type":"application/json"}});const i=new TextEncoder,o=r.pipeThrough(new TransformStream({transform(Z,B){const re=`event: ${Z.type}
1
+ "use strict";var On=Object.defineProperty,Nn=Object.defineProperties;var In=Object.getOwnPropertyDescriptors;var Pt=Object.getOwnPropertySymbols;var jn=Object.prototype.hasOwnProperty,Rn=Object.prototype.propertyIsEnumerable;var Ft=n=>{throw TypeError(n)};var $t=(n,e,t)=>e in n?On(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,d=(n,e)=>{for(var t in e||(e={}))jn.call(e,t)&&$t(n,t,e[t]);if(Pt)for(var t of Pt(e))Rn.call(e,t)&&$t(n,t,e[t]);return n},g=(n,e)=>Nn(n,In(e));var lt=(n,e,t)=>e.has(n)||Ft("Cannot "+t);var H=(n,e,t)=>(lt(n,e,"read from private field"),t?t.call(n):e.get(n)),Xe=(n,e,t)=>e.has(n)?Ft("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),ft=(n,e,t,r)=>(lt(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),Vt=(n,e,t)=>(lt(n,e,"access private method"),t);var M=(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"});class ie 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 Xt="Figma Token Issue";class Yt extends Error{constructor({fileKey:e,reason:t,cause:r}){super(Xt),this.fileKey=e,this.reason=t,this.cause=r}}const Qt="Rate Limit Exceeded";class en extends Error{constructor({fileKey:e,cause:t}){super(Qt),this.fileKey=e,this.cause=t}}const tn="Not Found";class nn extends Error{constructor({fileKey:e,cause:t}){super(tn),this.fileKey=e,this.cause=t}}const rn=n=>n.message===tn,sn="Unknown Figma API Exception";class an extends Error{constructor({fileKey:e,cause:t}){super(sn),this.name="UnknownFigmaApiException",this.fileKey=e,this.cause=t}}const Zn=n=>n.message===sn,on=n=>n.message===Qt,cn=n=>[Xt,...["Invalid Figma token","Figma token expired"]].includes(n.message),Nt=(n,e)=>{var r;if(((r=n==null?void 0:n.cause)==null?void 0:r.message)==="Fetch Error"){const{err:s,status:a}=n.cause.body;if(a===403)return new Yt({fileKey:e,reason:s,cause:n});if(a===429)return new en({fileKey:e,cause:n});if(a===404)return new nn({fileKey:e,cause:n})}return new an({fileKey:e,cause:n})},Mn=n=>rn(n)?"NotFound":on(n)?"RateLimitExceeded":cn(n)?"FigmaTokenIssue":"UnknownFigmaApiException";var Pn=Object.defineProperty,$n=Object.defineProperties,Fn=Object.getOwnPropertyDescriptors,Lt=Object.getOwnPropertySymbols,Vn=Object.prototype.hasOwnProperty,Ln=Object.prototype.propertyIsEnumerable,Dt=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),dn=n=>{throw TypeError(n)},Ut=(n,e,t)=>e in n?Pn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,U=(n,e)=>{for(var t in e||(e={}))Vn.call(e,t)&&Ut(n,t,e[t]);if(Lt)for(var t of Lt(e))Ln.call(e,t)&&Ut(n,t,e[t]);return n},It=(n,e)=>$n(n,Fn(e)),jt=(n,e,t)=>e.has(n)||dn("Cannot "+t),T=(n,e,t)=>(jt(n,e,"read from private field"),t?t.call(n):e.get(n)),W=(n,e,t)=>e.has(n)?dn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),j=(n,e,t,r)=>(jt(n,e,"write to private field"),e.set(n,t),t),ee=(n,e,t)=>(jt(n,e,"access private method"),t),A=(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())}),Dn=(n,e,t)=>(e=n[Dt("asyncIterator")])?e.call(n):(n=n[Dt("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),Un=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function zn(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var yt={exports:{}},Wn=yt.exports,zt;function Bn(){return zt||(zt=1,function(n,e){(function(t,r){n.exports=r()})(Wn,function(){var t=typeof Promise=="function",r=typeof self=="object"?self:Un,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",_=s&&typeof Symbol.toStringTag!="undefined",I=i&&typeof Set.prototype.entries=="function",C=a&&typeof Map.prototype.entries=="function",O=I&&Object.getPrototypeOf(new Set().entries()),Z=C&&Object.getPrototypeOf(new Map().entries()),B=f&&typeof Array.prototype[Symbol.iterator]=="function",se=B&&Object.getPrototypeOf([][Symbol.iterator]()),ue=f&&typeof String.prototype[Symbol.iterator]=="function",V=ue&&Object.getPrototypeOf(""[Symbol.iterator]()),X=8,q=-1;function Oe(E){var k=typeof E;if(k!=="object")return k;if(E===null)return"null";if(E===r)return"global";if(Array.isArray(E)&&(_===!1||!(Symbol.toStringTag in E)))return"Array";if(typeof window=="object"&&window!==null){if(typeof window.location=="object"&&E===window.location)return"Location";if(typeof window.document=="object"&&E===window.document)return"Document";if(typeof window.navigator=="object"){if(typeof window.navigator.mimeTypes=="object"&&E===window.navigator.mimeTypes)return"MimeTypeArray";if(typeof window.navigator.plugins=="object"&&E===window.navigator.plugins)return"PluginArray"}if((typeof window.HTMLElement=="function"||typeof window.HTMLElement=="object")&&E instanceof window.HTMLElement){if(E.tagName==="BLOCKQUOTE")return"HTMLQuoteElement";if(E.tagName==="TD")return"HTMLTableDataCellElement";if(E.tagName==="TH")return"HTMLTableHeaderCellElement"}}var ut=_&&E[Symbol.toStringTag];if(typeof ut=="string")return ut;var L=Object.getPrototypeOf(E);return L===RegExp.prototype?"RegExp":L===Date.prototype?"Date":t&&L===Promise.prototype?"Promise":i&&L===Set.prototype?"Set":a&&L===Map.prototype?"Map":c&&L===WeakSet.prototype?"WeakSet":o&&L===WeakMap.prototype?"WeakMap":u&&L===DataView.prototype?"DataView":a&&L===Z?"Map Iterator":i&&L===O?"Set Iterator":B&&L===se?"Array Iterator":ue&&L===V?"String Iterator":L===null?"Object":Object.prototype.toString.call(E).slice(X,q)}return Oe})}(yt)),yt.exports}var qn=Bn();const Hn=zn(qn),Rt=typeof Buffer!="undefined",Jn=Rt&&typeof Buffer.from!="undefined",Gn=Rt?function(n){return Buffer.isBuffer(n)}:function(){return!1},Kn=Jn?function(n){return Buffer.from(n)}:Rt?function(n){return new Buffer(n)}:function(n){return n};function Se(n){return Gn(n)?"Buffer":Hn(n)}const Xn=new Set(["Arguments","Array","Map","Object","Set"]);function Yn(n,e,t=null){switch(t||Se(n)){case"Arguments":case"Array":case"Object":return n[e];case"Map":return n.get(e);case"Set":return e}}function vt(n){return Xn.has(n)}function Wt(n,e,t,r=null){switch(r||Se(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 Qn=typeof globalThis!="undefined"&&globalThis!==null&&globalThis.Object===Object&&globalThis,er=typeof global!="undefined"&&global!==null&&global.Object===Object&&global,tr=typeof self!="undefined"&&self!==null&&self.Object===Object&&self,ht=Qn||er||tr||Function("return this")();function nr(n){return n.slice(0)}function rr(n){return new Boolean(n.valueOf())}function sr(n){return new DataView(n.buffer)}function ar(n){return Kn(n)}function ir(n){return new Date(n.getTime())}function or(n){return new Number(n)}function cr(n){return new RegExp(n.source,n.flags)}function dr(n){return new String(n)}function ae(n,e){return ht[e].from?ht[e].from(n):new ht[e](n)}function P(n){return n}function Bt(){return[]}function ur(){return new Map}function lr(){return{}}function fr(){return new Set}const hr=new Map([["ArrayBuffer",nr],["Boolean",rr],["Buffer",ar],["DataView",sr],["Date",ir],["Number",or],["RegExp",cr],["String",dr],["Float32Array",ae],["Float64Array",ae],["Int16Array",ae],["Int32Array",ae],["Int8Array",ae],["Uint16Array",ae],["Uint32Array",ae],["Uint8Array",ae],["Uint8ClampedArray",ae],["Array Iterator",P],["Map Iterator",P],["Promise",P],["Set Iterator",P],["String Iterator",P],["function",P],["global",P],["WeakMap",P],["WeakSet",P],["boolean",P],["null",P],["number",P],["string",P],["symbol",P],["undefined",P],["Arguments",Bt],["Array",Bt],["Map",ur],["Object",lr],["Set",fr]]);function pr(){}function _t(n,e=null,t=pr){arguments.length===2&&typeof e=="function"&&(t=e,e=null);const r=e||Se(n),s=hr.get(r);if(r==="Object"){const a=t(n,r);if(a!==void 0)return a}return s?s(n,r):n}function Ne(n,e={}){typeof e=="function"&&(e={customizer:e});const{customizer:t}=e,r=Se(n);if(!vt(r))return bt(n,null,null,null);const s=_t(n,r,t),a=new WeakMap([[n,s]]),i=new WeakSet([n]);return bt(n,s,a,i)}function bt(n,e,t,r,s){const a=Se(n),i=_t(n,a);if(!vt(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=Yn(n,c,a);if(r.has(u))Wt(e,c,t.get(u),a);else{const f=Se(u),_=_t(u,f);vt(f)&&(t.set(u,_),r.add(u)),Wt(e,c,bt(u,_,t,r),a)}}return e}const mr=n=>new Promise(e=>setTimeout(e,n));var Ye,ge,Qe,wt,un;class gr{constructor({maxAttempts:e=3,func:t}){W(this,wt),W(this,Ye),W(this,ge),W(this,Qe),j(this,Ye,e),j(this,Qe,t),j(this,ge,0)}run(){return A(this,null,function*(){try{return yield T(this,Qe).call(this)}catch(e){if(j(this,ge,T(this,ge)+1),T(this,ge)>T(this,Ye))throw console.error("Max attempts reached"),e;const t=ee(this,wt,un).call(this);return yield mr(t),yield this.run()}})}}Ye=new WeakMap,ge=new WeakMap,Qe=new WeakMap,wt=new WeakSet,un=function(){return T(this,ge)*1e3*1.5};function yr(){return typeof CompressionStream!="undefined"}function vr(n){return A(this,null,function*(){const e=new Blob([n]).stream().pipeThrough(new CompressionStream("gzip")),t=[];try{for(var r=Dn(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 _r(t)})}function _r(n){return A(this,null,function*(){const e=yield new Blob(n).arrayBuffer();return new Uint8Array(e)})}class br 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 qt 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 Ie extends Error{constructor(e={}){const{canceled:t=!1}=e;super("Abort Error"),this.name="Abort Error",this.canceled=t}}class wr extends Error{constructor(e){super(`Async API Error: ${JSON.stringify(e)}`),this.name="Async API Error",this.body=e}}class pt extends Error{constructor(e){super(e),this.name="Request Validation Error"}}function ln(){return Array.from({length:32},()=>Math.floor(Math.random()*256).toString(16).padStart(2,"0")).join("")}function xt(){return Math.floor(Date.now()/1e3).toString()}const xr=5*60*1e3,kr=1*1e3;var ye,F,Y,kt,Tt,je;class Tr{constructor({fetch:e=globalThis.fetch.bind(globalThis),baseAddress:t}){W(this,Y),W(this,ye),W(this,F),this.baseAddress=t,j(this,ye,e),j(this,F,{}),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 j(this,F,e),this}get(e){return A(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=Ne(T(this,F));return j(this,F,{}),c.extraHeaders&&(o=U(U({},o),c.extraHeaders)),c.requestValidation&&(o=It(U({},o),{"X-Request-Nonce":ln(),"X-Request-Timestamp":xt()})),c.async?yield ee(this,Y,Tt).call(this,`${i}${t}`,c.async,{headers:o}):yield ee(this,Y,kt).call(this,`${i}${t}`,c,{headers:o})})}post(e,t){return A(this,arguments,function*(r,s,a={}){const i=Ne(T(this,F));return j(this,F,{}),ee(this,Y,je).call(this,r,"POST",s,a,i)})}put(e,t){return A(this,arguments,function*(r,s,a={}){const i=Ne(T(this,F));return j(this,F,{}),ee(this,Y,je).call(this,r,"PUT",s,a,i)})}delete(e,t){return A(this,arguments,function*(r,s,a={}){const i=Ne(T(this,F));return j(this,F,{}),ee(this,Y,je).call(this,r,"DELETE",s,a,i)})}patch(e,t){return A(this,arguments,function*(r,s,a={}){const i=Ne(T(this,F));return j(this,F,{}),ee(this,Y,je).call(this,r,"PATCH",s,a,i)})}}ye=new WeakMap,F=new WeakMap,Y=new WeakSet,kt=function(n,e,t){return A(this,null,function*(){const r=()=>A(this,null,function*(){var c,u;try{return yield T(this,ye).call(this,n,U(U({},t),e.abortSignal&&{signal:e.abortSignal}))}catch(f){throw f instanceof Error&&f.name==="AbortError"?new Ie({canceled:(u=(c=e.abortSignal)==null?void 0:c.aborted)!=null?u:!1}):f}}),{headers:s}=t!=null?t:{},a=(c,u)=>{var f,_;return((f=c==null?void 0:c.headers)==null?void 0:f.get(u))||((_=c==null?void 0:c.headersObject)==null?void 0:_[u])||""},i=c=>A(this,null,function*(){var u;if(!c.ok){const _=yield c.text().catch();throw new qt({url:n,method:(u=t==null?void 0:t.method)!=null?u:"GET",statusCode:c.status,requestHeaders:s,responseHeaders:c.headers,body:_})}if(e.requestValidation&&process.env.UI_TESTS!==!0)try{const _=a(c,"x-response-nonce"),I=s==null?void 0:s["X-Request-Nonce"];if(!_||_!==I)throw new pt("Response nonce mismatch");const C=Number(a(c,"x-response-timestamp")),O=Number(xt()),Z=60*60*24;if(isNaN(C)||Math.abs(O-C)>Z)throw new pt("Invalid response timestamp")}catch(_){const I=_ instanceof Error?_.message:"Request validation failed";throw new pt(I)}let f=yield c.text();try{f=JSON.parse(f)}catch(_){}return f});if(e.retry){const c=yield new gr({maxAttempts:e.retry,func:r}).run();return yield i(c)}const o=yield r();return yield i(o)})},Tt=function(n,e,t){return A(this,null,function*(){var r,s;const{onProgress:a,abortSignal:i,pollingInterval:o=()=>kr,maxTimeout:c=xr}=e,u=`${n}/async`,f=`${n}/async/job`;let _;try{_=yield T(this,ye).call(this,u,U(U({},t),i&&{signal:i}))}catch(O){throw O instanceof Error&&O.name==="AbortError"?new Ie({canceled:(r=i==null?void 0:i.aborted)!=null?r:!1}):O}if(!_.ok){const O=yield _.text().catch();throw new qt({url:n,method:(s=t==null?void 0:t.method)!=null?s:"GET",statusCode:_.status,requestHeaders:this.headers,responseHeaders:_.headers,body:O})}const I=yield _.json(),{job_id:C}=I;if(!C)throw new Error("Job ID not found in response");return new Promise((O,Z)=>A(this,null,function*(){const B=setTimeout(()=>{Z(new Error("Job timed out"))},c),se=(ue=0)=>A(this,null,function*(){if(i!=null&&i.aborted){clearTimeout(B),T(this,ye).call(this,`${f}/${C}/cancel`,{method:"POST",headers:this.headers}).then(()=>{Z(new Ie({canceled:!0}))}).catch(V=>{Z(new Ie({canceled:!1}))});return}try{const V=yield(yield T(this,ye).call(this,`${f}/${C}`,{headers:this.headers})).json();if(V.status==="success"){clearTimeout(B);const X=V.response_json;O(X)}else if(V.status==="failed")clearTimeout(B),Z(new wr(V.response_json));else{a&&a(V.response_json);const X=o(ue);setTimeout(()=>se(ue+1),X)}}catch(V){Z(V)}});se()}))})},je=function(n,e,t,r,s){return A(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=U(U({},c),s.extraHeaders)),s.requestValidation&&(c=It(U({},c),{"X-Request-Nonce":ln(),"X-Request-Timestamp":xt()}));let u=r.skipBodyJsonStringify?t:JSON.stringify(t);return s.compress&&yr()&&(c["Content-Encoding"]="gzip",u=yield vr(u)),s.async?yield ee(this,Y,Tt).call(this,`${o}${n}`,s.async,{method:e,headers:c,body:u}):yield ee(this,Y,kt).call(this,`${o}${n}`,s,{method:e,headers:c,body:u})})};const Ht=(n,e,t,r)=>n instanceof Ie?n:new br({resource:e,api:String(t),args:r,cause:n}),mt=(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 Ht(o,t.resourceName,r,s)}return i instanceof Promise?i.catch(o=>{throw Ht(o,t.resourceName,r,s)}):i}}});var Re;class Sr{constructor(e){W(this,Re),this.resourceName="Files",j(this,Re,e)}get(e){return A(this,arguments,function*({fileKey:t,params:r={}}){const s=new URLSearchParams(U({plugin_data:"857346721138427857"},r)).toString(),a=`v1/files/${t}?${s}`;return yield T(this,Re).get(a)})}getImageFills(e){return A(this,arguments,function*({fileKey:t}){var r,s;const a=`v1/files/${t}/images`;return(s=(r=(yield T(this,Re).get(a)).meta)==null?void 0:r.images)!=null?s:{}})}}Re=new WeakMap;const Er=(n,e,t)=>{const r=e.sort();return`${n}-${r.join("-")}-${t}`},Ar=n=>n?n.ts>Date.now()-1e3*30:!1;var Q,St,fn;class Cr{constructor(e){W(this,St),W(this,Q),this.resourceName="Images",j(this,Q,e)}get(e){return A(this,arguments,function*({fileKey:t,nodeIds:r,format:s="jpg",scale:a}){const i=Er(t,r,s),o=T(this,Q).cache.images.entries.get(i);if(Ar(o))return o.result;o&&T(this,Q).cache.images.entries.delete(i);const c=T(this,Q).cache.images.pendingRequests.get(i);if(c)return c;const u=ee(this,St,fn).call(this,i,t,r,s,a);T(this,Q).cache.images.pendingRequests.set(i,u);try{return yield u}finally{T(this,Q).cache.images.pendingRequests.delete(i)}})}}Q=new WeakMap,St=new WeakSet,fn=function(n,e,t,r,s){return A(this,null,function*(){const a=yield T(this,Q).get(`v1/images/${e}?ids=${t}&format=${r}${s?`&scale=${s}`:""}`);return T(this,Q).cache.images.entries.set(n,{result:a,ts:Date.now()}),a})};var et;class Or{constructor(e){W(this,et),this.resourceName="Nodes",j(this,et,e)}get(e){return A(this,arguments,function*({fileKey:t,nodeIds:r,params:s={}}){const a=It(U({},s),{ids:r.join(",")}),i=new URLSearchParams(U({plugin_data:"857346721138427857"},a)).toString(),o=`v1/files/${t}/nodes?${i}`;return yield T(this,et).get(o)})}}et=new WeakMap;var le;class hn extends Tr{constructor({baseAddress:e="https://api.figma.com/",fetch:t=globalThis.fetch.bind(globalThis)}={}){super({fetch:t,baseAddress:e}),W(this,le,""),this.cache={images:{entries:new Map,pendingRequests:new Map}},this.files=mt(this,new Sr(this)),this.nodes=mt(this,new Or(this)),this.images=mt(this,new Cr(this))}set token(e){if(!e.startsWith("figd_")&&!e.startsWith("figu_"))throw new Error("Invalid Figma access token");j(this,le,e)}get token(){return T(this,le)}get headers(){const e={"Content-Type":"application/json"};return T(this,le).startsWith("figd_")?e["X-FIGMA-TOKEN"]=T(this,le):T(this,le).startsWith("figu_")&&(e.Authorization=`Bearer ${T(this,le)}`),e}}le=new WeakMap;const pn=s=>M(exports,[s],function*({fileKey:n,authToken:e,figmaRestApi:t=new hn,params:r={}}){e&&(t.token=e);try{return yield t.files.get({fileKey:n,params:r})}catch(a){throw console.error(a),Nt(a,n)}}),Nr=a=>M(exports,[a],function*({fileKey:n,authToken:e,nodeIds:t,figmaRestApi:r=new hn,params:s={}}){e&&(r.token=e);try{return(yield r.nodes.get({fileKey:n,nodeIds:t,params:d({},s)})).nodes}catch(i){throw Nt(i,n)}}),Zt=(n,e)=>{if(n.id===e)return n;if("children"in n)for(const t of n.children){const r=Zt(t,e);if(r)return r}return null};var x;(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})(x||(x={}));var Et;(function(n){n.mergeShapes=(e,t)=>d(d({},e),t)})(Et||(Et={}));const p=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ce=n=>{switch(typeof n){case"undefined":return p.undefined;case"string":return p.string;case"number":return isNaN(n)?p.nan:p.number;case"boolean":return p.boolean;case"function":return p.function;case"bigint":return p.bigint;case"symbol":return p.symbol;case"object":return Array.isArray(n)?p.array:n===null?p.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?p.promise:typeof Map!="undefined"&&n instanceof Map?p.map:typeof Set!="undefined"&&n instanceof Set?p.set:typeof Date!="undefined"&&n instanceof Date?p.date:p.object;default:return p.unknown}},l=x.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"]),Ir=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class z 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 z))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.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()}}z.create=n=>new z(n);const Ee=(n,e)=>{let t;switch(n.code){case l.invalid_type:n.received===p.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case l.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,x.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(n.keys,", ")}`;break;case l.invalid_union:t="Invalid input";break;case l.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(n.options)}`;break;case l.invalid_enum_value:t=`Invalid enum value. Expected ${x.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}"`:x.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,x.assertNever(n)}return{message:t}};let mn=Ee;function jr(n){mn=n}function tt(){return mn}const nt=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,a=[...t,...s.path||[]],i=g(d({},s),{path:a});if(s.message!==void 0)return g(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 g(d({},s),{path:a,message:o})},Rr=[];function h(n,e){const t=tt(),r=nt({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===Ee?void 0:Ee].filter(s=>!!s)});n.common.issues.push(r)}class R{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 v;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static mergeObjectAsync(e,t){return M(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 R.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 v;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 v=Object.freeze({status:"aborted"}),ke=n=>({status:"dirty",value:n}),$=n=>({status:"valid",value:n}),At=n=>n.status==="aborted",Ct=n=>n.status==="dirty",_e=n=>n.status==="valid",Pe=n=>typeof Promise!="undefined"&&n instanceof Promise;function rt(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 gn(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 m;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(m||(m={}));var Ze,Me;class ne{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 Jt=(n,e)=>{if(_e(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 z(n.common.issues);return this._error=t,this._error}}};function b(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:(i,o)=>{var c,u;const{message:f}=n;return i.code==="invalid_enum_value"?{message:f!=null?f:o.defaultError}:typeof o.data=="undefined"?{message:(c=f!=null?f:r)!==null&&c!==void 0?c:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f!=null?f:t)!==null&&u!==void 0?u:o.defaultError}},description:s}}class w{get description(){return this._def.description}_getType(e){return ce(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new R,ctx:{common:e.parent.common,data:e.data,parsedType:ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Pe(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:ce(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Jt(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:ce(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:s});return _e(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=>_e(a)?{value:a.value}:{issues:s.common.issues})}parseAsync(e,t){return M(this,null,function*(){const r=yield this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error})}safeParseAsync(e,t){return M(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:ce(e)},s=this._parse({data:e,path:r.path,parent:r}),a=yield Pe(s)?s:Promise.resolve(s);return Jt(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 K({schema:this,typeName:y.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 te.create(this,this._def)}nullable(){return me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return G.create(this)}promise(){return Ce.create(this,this._def)}or(e){return Le.create([this,e],this._def)}and(e){return De.create(this,e,this._def)}transform(e){return new K(g(d({},b(this._def)),{schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}}))}default(e){const t=typeof e=="function"?e:()=>e;return new qe(g(d({},b(this._def)),{innerType:this,defaultValue:t,typeName:y.ZodDefault}))}brand(){return new Mt(d({typeName:y.ZodBranded,type:this},b(this._def)))}catch(e){const t=typeof e=="function"?e:()=>e;return new He(g(d({},b(this._def)),{innerType:this,catchValue:t,typeName:y.ZodCatch}))}describe(e){const t=this.constructor;return new t(g(d({},this._def),{description:e}))}pipe(e){return Ke.create(this,e)}readonly(){return Je.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Zr=/^c[^\s-]{8,}$/i,Mr=/^[0-9a-z]+$/,Pr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,$r=/^[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,Fr=/^[a-z0-9_-]{21}$/i,Vr=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Lr=/^[-+]?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)?)??$/,Dr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ur="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let gt;const zr=/^(?:(?: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])$/,Wr=/^(?:(?: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])$/,Br=/^(([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]))$/,qr=/^(([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])$/,Hr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Jr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,yn="((\\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])))",Gr=new RegExp(`^${yn}$`);function vn(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 Kr(n){return new RegExp(`^${vn(n)}$`)}function _n(n){let e=`${yn}T${vn(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 Xr(n,e){return!!((e==="v4"||!e)&&zr.test(n)||(e==="v6"||!e)&&Br.test(n))}function Yr(n,e){if(!Vr.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 Qr(n,e){return!!((e==="v4"||!e)&&Wr.test(n)||(e==="v6"||!e)&&qr.test(n))}class J extends w{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_type,expected:p.string,received:a.parsedType}),v}const r=new R;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?h(s,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&h(s,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")Dr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"email",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")gt||(gt=new RegExp(Ur,"u")),gt.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"emoji",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")$r.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"uuid",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")Fr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"nanoid",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")Zr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cuid",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")Mr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cuid2",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")Pr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"ulid",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch(i){s=this._getOrReturnCtx(e,s),h(s,{validation:"url",code:l.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"regex",code:l.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),h(s,{code:l.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),h(s,{code:l.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),h(s,{code:l.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?_n(a).test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:l.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?Gr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:l.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?Kr(a).test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:l.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?Lr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"duration",code:l.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?Xr(e.data,a.version)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"ip",code:l.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?Yr(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"jwt",code:l.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?Qr(e.data,a.version)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cidr",code:l.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?Hr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64",code:l.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?Jr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64url",code:l.invalid_string,message:a.message}),r.dirty()):x.assertNever(a);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),d({validation:t,code:l.invalid_string},m.errToObj(r)))}_addCheck(e){return new J(g(d({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(d({kind:"email"},m.errToObj(e)))}url(e){return this._addCheck(d({kind:"url"},m.errToObj(e)))}emoji(e){return this._addCheck(d({kind:"emoji"},m.errToObj(e)))}uuid(e){return this._addCheck(d({kind:"uuid"},m.errToObj(e)))}nanoid(e){return this._addCheck(d({kind:"nanoid"},m.errToObj(e)))}cuid(e){return this._addCheck(d({kind:"cuid"},m.errToObj(e)))}cuid2(e){return this._addCheck(d({kind:"cuid2"},m.errToObj(e)))}ulid(e){return this._addCheck(d({kind:"ulid"},m.errToObj(e)))}base64(e){return this._addCheck(d({kind:"base64"},m.errToObj(e)))}base64url(e){return this._addCheck(d({kind:"base64url"},m.errToObj(e)))}jwt(e){return this._addCheck(d({kind:"jwt"},m.errToObj(e)))}ip(e){return this._addCheck(d({kind:"ip"},m.errToObj(e)))}cidr(e){return this._addCheck(d({kind:"cidr"},m.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},m.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},m.errToObj(e==null?void 0:e.message)))}duration(e){return this._addCheck(d({kind:"duration"},m.errToObj(e)))}regex(e,t){return this._addCheck(d({kind:"regex",regex:e},m.errToObj(t)))}includes(e,t){return this._addCheck(d({kind:"includes",value:e,position:t==null?void 0:t.position},m.errToObj(t==null?void 0:t.message)))}startsWith(e,t){return this._addCheck(d({kind:"startsWith",value:e},m.errToObj(t)))}endsWith(e,t){return this._addCheck(d({kind:"endsWith",value:e},m.errToObj(t)))}min(e,t){return this._addCheck(d({kind:"min",value:e},m.errToObj(t)))}max(e,t){return this._addCheck(d({kind:"max",value:e},m.errToObj(t)))}length(e,t){return this._addCheck(d({kind:"length",value:e},m.errToObj(t)))}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new J(g(d({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}toLowerCase(){return new J(g(d({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new J(g(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}}J.create=n=>{var e;return new J(d({checks:[],typeName:y.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1},b(n)))};function es(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 w{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)!==p.number){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_type,expected:p.number,received:a.parsedType}),v}let r;const s=new R;for(const a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:l.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:l.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:l.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?es(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),h(r,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:l.not_finite,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,r,s){return new fe(g(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:m.toString(s)}]}))}_addCheck(e){return new fe(g(d({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.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"&&x.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:y.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1},b(n)));class he extends w{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch(a){return this._getInvalidInput(e)}if(this._getType(e)!==p.bigint)return this._getInvalidInput(e);let r;const s=new R;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:l.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:l.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),h(r,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return h(t,{code:l.invalid_type,expected:p.bigint,received:t.parsedType}),v}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,r,s){return new he(g(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:m.toString(s)}]}))}_addCheck(e){return new he(g(d({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.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}}he.create=n=>{var e;return new he(d({checks:[],typeName:y.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1},b(n)))};class $e extends w{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){const r=this._getOrReturnCtx(e);return h(r,{code:l.invalid_type,expected:p.boolean,received:r.parsedType}),v}return $(e.data)}}$e.create=n=>new $e(d({typeName:y.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1},b(n)));class be extends w{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_type,expected:p.date,received:a.parsedType}),v}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_date}),v}const r=new R;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:l.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:l.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):x.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new be(g(d({},this._def),{checks:[...this._def.checks,e]}))}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:m.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}}be.create=n=>new be(d({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:y.ZodDate},b(n)));class st extends w{_parse(e){if(this._getType(e)!==p.symbol){const r=this._getOrReturnCtx(e);return h(r,{code:l.invalid_type,expected:p.symbol,received:r.parsedType}),v}return $(e.data)}}st.create=n=>new st(d({typeName:y.ZodSymbol},b(n)));class Fe extends w{_parse(e){if(this._getType(e)!==p.undefined){const r=this._getOrReturnCtx(e);return h(r,{code:l.invalid_type,expected:p.undefined,received:r.parsedType}),v}return $(e.data)}}Fe.create=n=>new Fe(d({typeName:y.ZodUndefined},b(n)));class Ve extends w{_parse(e){if(this._getType(e)!==p.null){const r=this._getOrReturnCtx(e);return h(r,{code:l.invalid_type,expected:p.null,received:r.parsedType}),v}return $(e.data)}}Ve.create=n=>new Ve(d({typeName:y.ZodNull},b(n)));class Ae extends w{constructor(){super(...arguments),this._any=!0}_parse(e){return $(e.data)}}Ae.create=n=>new Ae(d({typeName:y.ZodAny},b(n)));class ve extends w{constructor(){super(...arguments),this._unknown=!0}_parse(e){return $(e.data)}}ve.create=n=>new ve(d({typeName:y.ZodUnknown},b(n)));class de extends w{_parse(e){const t=this._getOrReturnCtx(e);return h(t,{code:l.invalid_type,expected:p.never,received:t.parsedType}),v}}de.create=n=>new de(d({typeName:y.ZodNever},b(n)));class at extends w{_parse(e){if(this._getType(e)!==p.undefined){const r=this._getOrReturnCtx(e);return h(r,{code:l.invalid_type,expected:p.void,received:r.parsedType}),v}return $(e.data)}}at.create=n=>new at(d({typeName:y.ZodVoid},b(n)));class G extends w{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==p.array)return h(t,{code:l.invalid_type,expected:p.array,received:t.parsedType}),v;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(h(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&&(h(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&&(h(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 ne(t,i,t.path,o)))).then(i=>R.mergeArray(r,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new ne(t,i,t.path,o)));return R.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new G(g(d({},this._def),{minLength:{value:e,message:m.toString(t)}}))}max(e,t){return new G(g(d({},this._def),{maxLength:{value:e,message:m.toString(t)}}))}length(e,t){return new G(g(d({},this._def),{exactLength:{value:e,message:m.toString(t)}}))}nonempty(e){return this.min(1,e)}}G.create=(n,e)=>new G(d({type:n,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray},b(e)));function xe(n){if(n instanceof S){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=te.create(xe(r))}return new S(g(d({},n._def),{shape:()=>e}))}else return n instanceof G?new G(g(d({},n._def),{type:xe(n.element)})):n instanceof te?te.create(xe(n.unwrap())):n instanceof me?me.create(xe(n.unwrap())):n instanceof re?re.create(n.items.map(e=>xe(e))):n}class S extends w{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=x.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==p.object){const u=this._getOrReturnCtx(e);return h(u,{code:l.invalid_type,expected:p.object,received:u.parsedType}),v}const{status:r,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof de&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const f=a[u],_=s.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new ne(s,_,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof de){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:s.data[f]}});else if(u==="strict")o.length>0&&(h(s,{code:l.unrecognized_keys,keys:o}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const _=s.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new ne(s,_,s.path,f)),alwaysSet:f in s.data})}}return s.common.async?Promise.resolve().then(()=>M(this,null,function*(){const u=[];for(const f of c){const _=yield f.key,I=yield f.value;u.push({key:_,value:I,alwaysSet:f.alwaysSet})}return u})).then(u=>R.mergeObjectSync(r,u)):R.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new S(d(g(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=m.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}))}strip(){return new S(g(d({},this._def),{unknownKeys:"strip"}))}passthrough(){return new S(g(d({},this._def),{unknownKeys:"passthrough"}))}extend(e){return new S(g(d({},this._def),{shape:()=>d(d({},this._def.shape()),e)}))}merge(e){return new S({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>d(d({},this._def.shape()),e._def.shape()),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new S(g(d({},this._def),{catchall:e}))}pick(e){const t={};return x.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new S(g(d({},this._def),{shape:()=>t}))}omit(e){const t={};return x.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new S(g(d({},this._def),{shape:()=>t}))}deepPartial(){return xe(this)}partial(e){const t={};return x.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new S(g(d({},this._def),{shape:()=>t}))}required(e){const t={};return x.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof te;)a=a._def.innerType;t[r]=a}}),new S(g(d({},this._def),{shape:()=>t}))}keyof(){return bn(x.objectKeys(this.shape))}}S.create=(n,e)=>new S(d({shape:()=>n,unknownKeys:"strip",catchall:de.create(),typeName:y.ZodObject},b(e)));S.strictCreate=(n,e)=>new S(d({shape:()=>n,unknownKeys:"strict",catchall:de.create(),typeName:y.ZodObject},b(e)));S.lazycreate=(n,e)=>new S(d({shape:n,unknownKeys:"strip",catchall:de.create(),typeName:y.ZodObject},b(e)));class Le extends w{_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 z(o.ctx.common.issues));return h(t,{code:l.invalid_union,unionErrors:i}),v}if(t.common.async)return Promise.all(r.map(a=>M(this,null,function*(){const i=g(d({},t),{common:g(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=g(d({},t),{common:g(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 z(c));return h(t,{code:l.invalid_union,unionErrors:o}),v}}get options(){return this._def.options}}Le.create=(n,e)=>new Le(d({options:n,typeName:y.ZodUnion},b(e)));const oe=n=>n instanceof ze?oe(n.schema):n instanceof K?oe(n.innerType()):n instanceof We?[n.value]:n instanceof pe?n.options:n instanceof Be?x.objectValues(n.enum):n instanceof qe?oe(n._def.innerType):n instanceof Fe?[void 0]:n instanceof Ve?[null]:n instanceof te?[void 0,...oe(n.unwrap())]:n instanceof me?[null,...oe(n.unwrap())]:n instanceof Mt||n instanceof Je?oe(n.unwrap()):n instanceof He?oe(n._def.innerType):[];class dt extends w{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.object)return h(t,{code:l.invalid_type,expected:p.object,received:t.parsedType}),v;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}):(h(t,{code:l.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),v)}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=oe(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 dt(d({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s},b(r)))}}function Ot(n,e){const t=ce(n),r=ce(e);if(n===e)return{valid:!0,data:n};if(t===p.object&&r===p.object){const s=x.objectKeys(e),a=x.objectKeys(n).filter(o=>s.indexOf(o)!==-1),i=d(d({},n),e);for(const o of a){const c=Ot(n[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===p.array&&r===p.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=Ot(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===p.date&&r===p.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class De extends w{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(a,i)=>{if(At(a)||At(i))return v;const o=Ot(a.value,i.value);return o.valid?((Ct(a)||Ct(i))&&t.dirty(),{status:t.value,value:o.data}):(h(r,{code:l.invalid_intersection_types}),v)};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}))}}De.create=(n,e,t)=>new De(d({left:n,right:e,typeName:y.ZodIntersection},b(t)));class re extends w{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.array)return h(r,{code:l.invalid_type,expected:p.array,received:r.parsedType}),v;if(r.data.length<this._def.items.length)return h(r,{code:l.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&r.data.length>this._def.items.length&&(h(r,{code:l.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...r.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new ne(r,i,r.path,o)):null}).filter(i=>!!i);return r.common.async?Promise.all(a).then(i=>R.mergeArray(t,i)):R.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new re(g(d({},this._def),{rest:e}))}}re.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new re(d({items:n,typeName:y.ZodTuple,rest:null},b(e)))};class Ue extends w{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!==p.object)return h(r,{code:l.invalid_type,expected:p.object,received:r.parsedType}),v;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in r.data)s.push({key:a._parse(new ne(r,o,r.path,o)),value:i._parse(new ne(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?R.mergeObjectAsync(t,s):R.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof w?new Ue(d({keyType:e,valueType:t,typeName:y.ZodRecord},b(r))):new Ue(d({keyType:J.create(),valueType:e,typeName:y.ZodRecord},b(t)))}}class it extends w{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!==p.map)return h(r,{code:l.invalid_type,expected:p.map,received:r.parsedType}),v;const s=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([o,c],u)=>({key:s._parse(new ne(r,o,r.path,[u,"key"])),value:a._parse(new ne(r,c,r.path,[u,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(()=>M(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 v;(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 v;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}it.create=(n,e,t)=>new it(d({valueType:e,keyType:n,typeName:y.ZodMap},b(t)));class we extends w{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.set)return h(r,{code:l.invalid_type,expected:p.set,received:r.parsedType}),v;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(h(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&&(h(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 v;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 ne(r,c,r.path,u)));return r.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new we(g(d({},this._def),{minSize:{value:e,message:m.toString(t)}}))}max(e,t){return new we(g(d({},this._def),{maxSize:{value:e,message:m.toString(t)}}))}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}we.create=(n,e)=>new we(d({valueType:n,minSize:null,maxSize:null,typeName:y.ZodSet},b(e)));class Te extends w{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.function)return h(t,{code:l.invalid_type,expected:p.function,received:t.parsedType}),v;function r(o,c){return nt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,tt(),Ee].filter(u=>!!u),issueData:{code:l.invalid_arguments,argumentsError:c}})}function s(o,c){return nt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,tt(),Ee].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 Ce){const o=this;return $(function(...c){return M(this,null,function*(){const u=new z([]),f=yield o._def.args.parseAsync(c,a).catch(C=>{throw u.addIssue(r(c,C)),u}),_=yield Reflect.apply(i,this,f);return yield o._def.returns._def.type.parseAsync(_,a).catch(C=>{throw u.addIssue(s(_,C)),u})})})}else{const o=this;return $(function(...c){const u=o._def.args.safeParse(c,a);if(!u.success)throw new z([r(c,u.error)]);const f=Reflect.apply(i,this,u.data),_=o._def.returns.safeParse(f,a);if(!_.success)throw new z([s(f,_.error)]);return _.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Te(g(d({},this._def),{args:re.create(e).rest(ve.create())}))}returns(e){return new Te(g(d({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new Te(d({args:e||re.create([]).rest(ve.create()),returns:t||ve.create(),typeName:y.ZodFunction},b(r)))}}class ze extends w{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})}}ze.create=(n,e)=>new ze(d({getter:n,typeName:y.ZodLazy},b(e)));class We extends w{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return h(t,{received:t.data,code:l.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}}We.create=(n,e)=>new We(d({value:n,typeName:y.ZodLiteral},b(e)));function bn(n,e){return new pe(d({values:n,typeName:y.ZodEnum},b(e)))}class pe extends w{constructor(){super(...arguments),Ze.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{expected:x.joinValues(r),received:t.parsedType,code:l.invalid_type}),v}if(rt(this,Ze)||gn(this,Ze,new Set(this._def.values)),!rt(this,Ze).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{received:t.data,code:l.invalid_enum_value,options:r}),v}return $(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 pe.create(e,d(d({},this._def),t))}exclude(e,t=this._def){return pe.create(this.options.filter(r=>!e.includes(r)),d(d({},this._def),t))}}Ze=new WeakMap;pe.create=bn;class Be extends w{constructor(){super(...arguments),Me.set(this,void 0)}_parse(e){const t=x.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==p.string&&r.parsedType!==p.number){const s=x.objectValues(t);return h(r,{expected:x.joinValues(s),received:r.parsedType,code:l.invalid_type}),v}if(rt(this,Me)||gn(this,Me,new Set(x.getValidEnumValues(this._def.values))),!rt(this,Me).has(e.data)){const s=x.objectValues(t);return h(r,{received:r.data,code:l.invalid_enum_value,options:s}),v}return $(e.data)}get enum(){return this._def.values}}Me=new WeakMap;Be.create=(n,e)=>new Be(d({values:n,typeName:y.ZodNativeEnum},b(e)));class Ce extends w{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.promise&&t.common.async===!1)return h(t,{code:l.invalid_type,expected:p.promise,received:t.parsedType}),v;const r=t.parsedType===p.promise?t.data:Promise.resolve(t.data);return $(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ce.create=(n,e)=>new Ce(d({type:n,typeName:y.ZodPromise},b(e)));class K extends w{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.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=>{h(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=>M(this,null,function*(){if(t.value==="aborted")return v;const c=yield this._def.schema._parseAsync({data:o,path:r.path,parent:r});return c.status==="aborted"?v:c.status==="dirty"||t.value==="dirty"?ke(c.value):c}));{if(t.value==="aborted")return v;const o=this._def.schema._parseSync({data:i,path:r.path,parent:r});return o.status==="aborted"?v:o.status==="dirty"||t.value==="dirty"?ke(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"?v:(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"?v:(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(!_e(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=>_e(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);x.assertNever(s)}}K.create=(n,e,t)=>new K(d({schema:n,typeName:y.ZodEffects,effect:e},b(t)));K.createWithPreprocess=(n,e,t)=>new K(d({schema:e,effect:{type:"preprocess",transform:n},typeName:y.ZodEffects},b(t)));class te extends w{_parse(e){return this._getType(e)===p.undefined?$(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}te.create=(n,e)=>new te(d({innerType:n,typeName:y.ZodOptional},b(e)));class me extends w{_parse(e){return this._getType(e)===p.null?$(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}me.create=(n,e)=>new me(d({innerType:n,typeName:y.ZodNullable},b(e)));class qe extends w{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===p.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}qe.create=(n,e)=>new qe(d({innerType:n,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default},b(e)));class He extends w{_parse(e){const{ctx:t}=this._processInputParams(e),r=g(d({},t),{common:g(d({},t.common),{issues:[]})}),s=this._def.innerType._parse({data:r.data,path:r.path,parent:d({},r)});return Pe(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new z(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new z(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}He.create=(n,e)=>new He(d({innerType:n,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},b(e)));class ot extends w{_parse(e){if(this._getType(e)!==p.nan){const r=this._getOrReturnCtx(e);return h(r,{code:l.invalid_type,expected:p.nan,received:r.parsedType}),v}return{status:"valid",value:e.data}}}ot.create=n=>new ot(d({typeName:y.ZodNaN},b(n)));const ts=Symbol("zod_brand");class Mt extends w{_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 Ke extends w{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return M(this,null,function*(){const a=yield this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?v:a.status==="dirty"?(t.dirty(),ke(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})});{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?v: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 Ke({in:e,out:t,typeName:y.ZodPipeline})}}class Je extends w{_parse(e){const t=this._def.innerType._parse(e),r=s=>(_e(s)&&(s.value=Object.freeze(s.value)),s);return Pe(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}Je.create=(n,e)=>new Je(d({innerType:n,typeName:y.ZodReadonly},b(e)));function wn(n,e={},t){return n?Ae.create().superRefine((r,s)=>{var a,i;if(!n(r)){const o=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,u=typeof o=="string"?{message:o}:o;s.addIssue(g(d({code:"custom"},u),{fatal:c}))}}):Ae.create()}const ns={object:S.lazycreate};var y;(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"})(y||(y={}));const rs=(n,e={message:`Input not instance of ${n.name}`})=>wn(t=>t instanceof n,e),xn=J.create,kn=fe.create,ss=ot.create,as=he.create,Tn=$e.create,is=be.create,os=st.create,cs=Fe.create,ds=Ve.create,us=Ae.create,ls=ve.create,fs=de.create,hs=at.create,ps=G.create,ms=S.create,gs=S.strictCreate,ys=Le.create,vs=dt.create,_s=De.create,bs=re.create,ws=Ue.create,xs=it.create,ks=we.create,Ts=Te.create,Ss=ze.create,Es=We.create,As=pe.create,Cs=Be.create,Os=Ce.create,Gt=K.create,Ns=te.create,Is=me.create,js=K.createWithPreprocess,Rs=Ke.create,Zs=()=>xn().optional(),Ms=()=>kn().optional(),Ps=()=>Tn().optional(),$s={string:n=>J.create(g(d({},n),{coerce:!0})),number:n=>fe.create(g(d({},n),{coerce:!0})),boolean:n=>$e.create(g(d({},n),{coerce:!0})),bigint:n=>he.create(g(d({},n),{coerce:!0})),date:n=>be.create(g(d({},n),{coerce:!0}))},Fs=v;var N=Object.freeze({__proto__:null,defaultErrorMap:Ee,setErrorMap:jr,getErrorMap:tt,makeIssue:nt,EMPTY_PATH:Rr,addIssueToContext:h,ParseStatus:R,INVALID:v,DIRTY:ke,OK:$,isAborted:At,isDirty:Ct,isValid:_e,isAsync:Pe,get util(){return x},get objectUtil(){return Et},ZodParsedType:p,getParsedType:ce,ZodType:w,datetimeRegex:_n,ZodString:J,ZodNumber:fe,ZodBigInt:he,ZodBoolean:$e,ZodDate:be,ZodSymbol:st,ZodUndefined:Fe,ZodNull:Ve,ZodAny:Ae,ZodUnknown:ve,ZodNever:de,ZodVoid:at,ZodArray:G,ZodObject:S,ZodUnion:Le,ZodDiscriminatedUnion:dt,ZodIntersection:De,ZodTuple:re,ZodRecord:Ue,ZodMap:it,ZodSet:we,ZodFunction:Te,ZodLazy:ze,ZodLiteral:We,ZodEnum:pe,ZodNativeEnum:Be,ZodPromise:Ce,ZodEffects:K,ZodTransformer:K,ZodOptional:te,ZodNullable:me,ZodDefault:qe,ZodCatch:He,ZodNaN:ot,BRAND:ts,ZodBranded:Mt,ZodPipeline:Ke,ZodReadonly:Je,custom:wn,Schema:w,ZodSchema:w,late:ns,get ZodFirstPartyTypeKind(){return y},coerce:$s,any:us,array:ps,bigint:as,boolean:Tn,date:is,discriminatedUnion:vs,effect:Gt,enum:As,function:Ts,instanceof:rs,intersection:_s,lazy:Ss,literal:Es,map:xs,nan:ss,nativeEnum:Cs,never:fs,null:ds,nullable:Is,number:kn,object:ms,oboolean:Ps,onumber:Ms,optional:Ns,ostring:Zs,pipeline:Rs,preprocess:js,promise:Os,record:ws,set:ks,strictObject:gs,string:xn,symbol:os,transformer:Gt,tuple:bs,undefined:cs,union:ys,unknown:ls,void:hs,NEVER:Fs,ZodIssueCode:l,quotelessJson:Ir,ZodError:z});const Vs=N.object({language:N.enum(["typescript","javascript"]).optional(),disableMarkedForExport: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"]).optional(),enableUILibraryTheming:N.boolean().optional(),enableCompactStructure:N.boolean().optional(),enableAutoSplit:N.boolean().optional(),autoSplitThreshold:N.number().optional()}),N.object({framework:N.literal("html"),styling:N.enum(["plain_css","inline_styles"]),enableTranslation:N.boolean().optional()})])),Sn=n=>{const e=Vs.safeParse(n);if(e.success===!1){const t=new Error("Invalid codegen settings");throw t.cause=e.error,t}return e.data},Kt=new Set(["FRAME","INSTANCE","COMPONENT","COMPONENT_SET","GROUP"]),En=(n,e)=>{const t=Zt(n.document,e);if(!t)return{isValid:!1,reason:"There is no node with the given id"};if(t.type==="CANVAS"){const r=t.children.filter(s=>Kt.has(s.type));return r.length===1?{isValid:!0,node:r[0],note:"Selected node is a page with a single valid children - returning it instead"}:{isValid:!1,reason:"Selected node is a page with multiple children"}}return Kt.has(t.type)?{isValid:!0,node:t}:{isValid:!1,reason:"Selected node type is not supported"}};var D,Ge,ct,An;class Ls{constructor({auth:e,apiBaseAddress:t="https://public-api.animaapp.com"}={}){Xe(this,ct);Xe(this,D);Xe(this,Ge);ft(this,Ge,t),e&&(this.auth=e)}hasAuth(){return!!H(this,D)}set auth(e){ft(this,D,e)}get headers(){const e={"Content-Type":"application/json"};return H(this,D)&&(e.Authorization=`Bearer ${H(this,D).token}`,"teamId"in H(this,D)&&(e["X-Team-Id"]=H(this,D).teamId)),e}generateCode(r){return M(this,arguments,function*(e,t={}){var _,I,C,O,Z,B,se,ue,V;if(this.hasAuth()===!1)throw new Error('It needs to set "auth" before calling this method.');e.figmaToken&&(yield Vt(this,ct,An).call(this,e.fileKey,e.figmaToken,e.nodesId));const s={},a=Sn(e.settings);let i=e.tracking;H(this,D)&&"userId"in H(this,D)&&H(this,D).userId&&(i!=null&&i.externalId||(i={externalId:H(this,D).userId}));const o=yield fetch(`${H(this,Ge)}/v1/codegen`,{method:"POST",headers:g(d({},this.headers),{Accept:"text/event-stream"}),body:JSON.stringify({tracking:i,fileKey:e.fileKey,figmaToken:e.figmaToken,nodesId:e.nodesId,assetsStorage:e.assetsStorage,language:a.language,model:a.model,framework:a.framework,styling:a.styling,uiLibrary:a.uiLibrary,enableTranslation:a.enableTranslation,enableUILibraryTheming:a.enableUILibraryTheming,enableCompactStructure:a.enableCompactStructure,enableAutoSplit:a.enableAutoSplit,autoSplitThreshold:a.autoSplitThreshold,disableMarkedForExport:a.disableMarkedForExport})});if(!o.ok){const X=yield o.text();let q;try{q=JSON.parse(X)}catch(Oe){}throw((_=q==null?void 0:q.error)==null?void 0:_.name)==="ZodError"?new ie({name:"HTTP error from Anima API",reason:"Invalid body payload",detail:q.error.issues,status:o.status}):typeof q=="object"?new ie({name:`Error "${q}"`,reason:"Unknown",status:o.status}):new ie({name:"HTTP error from Anima API",reason:X,status:o.status})}if(!o.body)throw new ie({name:"Stream Error",reason:"Response body is null",status:o.status});const c=o.body.getReader(),u=new TextDecoder;let f="";try{for(;;){const{done:X,value:q}=yield c.read();if(X)break;f+=u.decode(q,{stream:!0});const Oe=f.split(`
2
+ `);f=Oe.pop()||"";for(const E of Oe)if(!(!E.trim()||E.startsWith(":"))&&E.startsWith("data: ")){let k;try{k=JSON.parse(E.slice(6))}catch(ut){continue}switch(k.type){case"queueing":{typeof t=="function"?t(k):(I=t.onQueueing)==null||I.call(t);break}case"start":{s.sessionId=k.sessionId,typeof t=="function"?t(k):(C=t.onStart)==null||C.call(t,{sessionId:k.sessionId});break}case"pre_codegen":{typeof t=="function"?t(k):(O=t.onPreCodegen)==null||O.call(t,{message:k.message});break}case"assets_uploaded":{typeof t=="function"?t(k):(Z=t.onAssetsUploaded)==null||Z.call(t);break}case"assets_list":{s.assets=k.payload.assets,typeof t=="function"?t(k):(B=t.onAssetsList)==null||B.call(t,k.payload);break}case"figma_metadata":{s.figmaFileName=k.figmaFileName,s.figmaSelectedFrameName=k.figmaSelectedFrameName,typeof t=="function"?t(k):(se=t.onFigmaMetadata)==null||se.call(t,{figmaFileName:k.figmaFileName,figmaSelectedFrameName:k.figmaSelectedFrameName});break}case"generating_code":{k.payload.status==="success"&&(s.files=k.payload.files),typeof t=="function"?t(k):(ue=t.onGeneratingCode)==null||ue.call(t,{status:k.payload.status,progress:k.payload.progress,files:k.payload.files});break}case"codegen_completed":{typeof t=="function"?t(k):(V=t.onCodegenCompleted)==null||V.call(t);break}case"error":throw new ie({name:k.payload.errorName,reason:k.payload.reason});case"done":{if(!s.files)throw new ie({name:"Invalid response",reason:"No code generated"});return s.tokenUsage=k.payload.tokenUsage,s}}}}}finally{c.cancel()}throw new ie({name:"Connection",reason:"Connection closed before the 'done' message",status:500})})}}D=new WeakMap,Ge=new WeakMap,ct=new WeakSet,An=function(e,t,r){return M(this,null,function*(){let s;try{s=yield pn({fileKey:e,authToken:t,params:{geometry:"paths"}})}catch(o){return}const i=r.map(o=>En(s,o)).find(o=>!o.isValid);if(i)throw new ie({name:"Task Crashed",reason:i.reason})})};const Ds=n=>{var e;if(!n)return[!1,"",""];try{const t=new URL(n),r=t.pathname;if(t.origin!=="https://www.figma.com")return[!1,"",""];const s=((e=t.searchParams.get("node-id"))!=null?e:"").replace(/-/g,":"),a=r.split("/")[2];return[(r.startsWith("/file/")&&t.searchParams.get("type")!=="whiteboard"||r.startsWith("/design/"))&&a.length===22,a,s]}catch(t){return[!1,"",""]}},Us=({fileKey:n,nodeId:e,duplicate:t})=>{const r=new URL("https://www.figma.com");return r.pathname=`design/${n}`,t&&(r.pathname=`${r.pathname}/duplicate`),e&&r.searchParams.set("node-id",e.replace(":","-")),r};class zs extends Error{constructor(e,t){super(e),this.response=t}}const Ws=({files:n,screenPath:e="src/screens"})=>{const t={},r=new Set;function s(a){if(r.has(a)||!n[a])return;r.add(a),t[a]=n[a],Bs(n[a].content).forEach(o=>{try{const c=qs(a,o);if(c.startsWith("src/")){const u=c.split("/").slice(0,-1).join("/");Hs(n,u).forEach(_=>{r.has(_)||s(_)})}}catch(c){console.warn(`Failed to resolve import ${o} in ${a}:`,c)}})}return Object.entries(n).forEach(([a,i])=>{a.startsWith(e)?s(a):a.startsWith("src/")||(t[a]=i)}),t};function Bs(n){const e=/import.*?["']([^"']+)["']/g,t=/export.*from\s+["']([^"']+)["']/g,r=[];let s;for(;(s=e.exec(n))!==null;)r.push(s[1]);for(;(s=t.exec(n))!==null;)r.push(s[1]);return[...new Set(r)]}function qs(n,e){if(!e.startsWith("."))return e;const t=n.split("/").slice(0,-1),r=e.split("/"),s=[...t];for(const a of r)a===".."?s.pop():a!=="."&&s.push(a);return s.join("/")}function Hs(n,e){return Object.keys(n).filter(t=>t.startsWith(e))}const Cn=(n,e)=>new ReadableStream({start(t){n.generateCode(e,r=>{r.type==="error"||t.enqueue(r),(r.type==="aborted"||r.type==="error")&&t.close()}).then(r=>{t.enqueue({type:"done",payload:{tokenUsage:r.tokenUsage,sessionId:r.sessionId}}),t.close()}).catch(r=>{t.enqueue({type:"error",payload:{name:"name"in r?r.name:"Unknown error",message:"message"in r?r.message:"Unknown",status:"status"in r?r.status:void 0,detail:"detail"in r?r.detail:void 0}}),t.close()})}}),Js=(n,e)=>M(exports,null,function*(){var c,u,f,_,I,C,O;const t=Cn(n,e),[r,s]=t.tee(),a=yield r.getReader().read();if(a.done||!a.value||((c=a.value)==null?void 0:c.type)==="error"&&((f=(u=a.value)==null?void 0:u.payload)!=null&&f.status))return new Response(JSON.stringify(a.value),{status:((_=a.value)==null?void 0:_.type)==="error"&&(O=(C=(I=a.value)==null?void 0:I.payload)==null?void 0:C.status)!=null?O:500,headers:{"Content-Type":"application/json"}});const i=new TextEncoder,o=s.pipeThrough(new TransformStream({transform(Z,B){const se=`event: ${Z.type}
3
3
  data: ${JSON.stringify(Z)}
4
4
 
5
- `;B.enqueue(i.encode(re))}}));return new Response(o,{status:200,headers:{"Content-Type":"text/event-stream; charset=utf-8",Connection:"keep-alive","Cache-Control":"no-cache"}})});exports.Anima=Lr;exports.CodegenError=ie;exports.FigmaTokenIssue=Xt;exports.NotFound=tn;exports.RateLimitExceeded=Qt;exports.ResponseError=zr;exports.UnknownFigmaApiException=rn;exports.createCodegenResponseEventStream=Jr;exports.createCodegenStream=Cn;exports.findChildrenNode=Rt;exports.formatToFigmaLink=Ur;exports.getFigmaApiErrorType=Mn;exports.getFigmaFile=pn;exports.getFileNodes=Ns;exports.getRelatedScreenFiles=Wr;exports.handleFigmaApiError=cn;exports.isFigmaTokenIssue=on;exports.isNodeCodegenCompatible=En;exports.isNotFound=nn;exports.isRateLimitExceeded=an;exports.isUnknownFigmaApiException=Zn;exports.isValidFigmaUrl=Dr;exports.validateSettings=Sn;
5
+ `;B.enqueue(i.encode(se))}}));return new Response(o,{status:200,headers:{"Content-Type":"text/event-stream; charset=utf-8",Connection:"keep-alive","Cache-Control":"no-cache"}})});exports.Anima=Ls;exports.CodegenError=ie;exports.FigmaTokenIssue=Yt;exports.NotFound=nn;exports.RateLimitExceeded=en;exports.ResponseError=zs;exports.UnknownFigmaApiException=an;exports.createCodegenResponseEventStream=Js;exports.createCodegenStream=Cn;exports.findChildrenNode=Zt;exports.formatToFigmaLink=Us;exports.getFigmaApiErrorType=Mn;exports.getFigmaFile=pn;exports.getFileNodes=Nr;exports.getRelatedScreenFiles=Ws;exports.isFigmaTokenIssue=cn;exports.isNodeCodegenCompatible=En;exports.isNotFound=rn;exports.isRateLimitExceeded=on;exports.isUnknownFigmaApiException=Zn;exports.isValidFigmaUrl=Ds;exports.validateSettings=Sn;exports.wrapFigmaApiError=Nt;
6
6
  //# sourceMappingURL=index.cjs.map