@animaapp/anima-sdk 0.6.12-beta.0 → 0.6.16

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