@animaapp/anima-sdk 0.6.21 → 0.6.23

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 Dr=Object.getOwnPropertyDescriptors;var Dt=Object.getOwnPropertySymbols;var Vr=Object.prototype.hasOwnProperty,Ur=Object.prototype.propertyIsEnumerable;var Ut=r=>{throw TypeError(r)};var Vt=(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={}))Vr.call(e,t)&&Vt(r,t,e[t]);if(Dt)for(var t of Dt(e))Ur.call(e,t)&&Vt(r,t,e[t]);return r},g=(r,e)=>Lr(r,Dr(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)),tt=(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),Se=(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 ue 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)),q=(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),Y=(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()),re=f&&typeof Array.prototype[Symbol.iterator]=="function",ge=re&&Object.getPrototypeOf([][Symbol.iterator]()),ce=f&&typeof String.prototype[Symbol.iterator]=="function",V=ce&&Object.getPrototypeOf(""[Symbol.iterator]()),de=8,Te=-1;function B(O){var ye=typeof O;if(ye!=="object")return ye;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 x=v&&O[Symbol.toStringTag];if(typeof x=="string")return x;var L=Object.getPrototypeOf(O);return L===RegExp.prototype?"RegExp":L===Date.prototype?"Date":t&&L===Promise.prototype?"Promise":i&&L===Set.prototype?"Set":a&&L===Map.prototype?"Map":c&&L===WeakSet.prototype?"WeakSet":o&&L===WeakMap.prototype?"WeakMap":d&&L===DataView.prototype?"DataView":a&&L===z?"Map Iterator":i&&L===$?"Set Iterator":re&&L===ge?"Array Iterator":ce&&L===V?"String Iterator":L===null?"Object":Object.prototype.toString.call(O).slice(de,Te)}return B})}(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 Ie(r){return ns(r)?"Buffer":rs(r)}const is=new Set(["Arguments","Array","Map","Object","Set"]);function os(r,e,t=null){switch(t||Ie(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||Ie(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 se(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",se],["Float64Array",se],["Int16Array",se],["Int32Array",se],["Int8Array",se],["Uint16Array",se],["Uint32Array",se],["Uint8Array",se],["Uint8ClampedArray",se],["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||Ie(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 je(r,e={}){typeof e=="function"&&(e={customizer:e});const{customizer:t}=e,s=Ie(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=Ie(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=Ie(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 rt,ve,st,St,gr;class Ss{constructor({maxAttempts:e=3,func:t}){q(this,St),q(this,rt),q(this,ve),q(this,st),j(this,rt,e),j(this,st,t),j(this,ve,0)}run(){return N(this,null,function*(){try{return yield S(this,st).call(this)}catch(e){if(j(this,ve,S(this,ve)+1),S(this,ve)>S(this,rt))throw console.error("Max attempts reached"),e;const t=Y(this,St,gr).call(this);return yield Ts(t),yield this.run()}})}}rt=new WeakMap,ve=new WeakMap,st=new WeakMap,St=new WeakSet,gr=function(){return S(this,ve)*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 Ze 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 _e,D,K,At,Ct,Me;class js{constructor({fetch:e=globalThis.fetch.bind(globalThis),baseAddress:t}){q(this,K),q(this,_e),q(this,D),this.baseAddress=t,j(this,_e,e),j(this,D,{}),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,D,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=je(S(this,D));return j(this,D,{}),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 Y(this,K,Ct).call(this,`${i}${t}`,c.async,{headers:o}):yield Y(this,K,At).call(this,`${i}${t}`,c,{headers:o})})}post(e,t){return N(this,arguments,function*(s,n,a={}){const i=je(S(this,D));return j(this,D,{}),Y(this,K,Me).call(this,s,"POST",n,a,i)})}put(e,t){return N(this,arguments,function*(s,n,a={}){const i=je(S(this,D));return j(this,D,{}),Y(this,K,Me).call(this,s,"PUT",n,a,i)})}delete(e,t){return N(this,arguments,function*(s,n,a={}){const i=je(S(this,D));return j(this,D,{}),Y(this,K,Me).call(this,s,"DELETE",n,a,i)})}patch(e,t){return N(this,arguments,function*(s,n,a={}){const i=je(S(this,D));return j(this,D,{}),Y(this,K,Me).call(this,s,"PATCH",n,a,i)})}}_e=new WeakMap,D=new WeakMap,K=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,_e).call(this,r,U(U({},t),e.abortSignal&&{signal:e.abortSignal}))}catch(f){throw f instanceof Error&&f.name==="AbortError"?new Ze({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,_e).call(this,d,U(U({},t),i&&{signal:i}))}catch($){throw $ instanceof Error&&$.name==="AbortError"?new Ze({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 re=setTimeout(()=>{z(new Error("Job timed out"))},c),ge=(ce=0)=>N(this,null,function*(){if(i!=null&&i.aborted){clearTimeout(re),S(this,_e).call(this,`${f}/${M}/cancel`,{method:"POST",headers:this.headers}).then(()=>{z(new Ze({canceled:!0}))}).catch(V=>{z(new Ze({canceled:!1}))});return}try{const V=yield(yield S(this,_e).call(this,`${f}/${M}`,{headers:this.headers})).json();if(V.status==="success"){clearTimeout(re);const de=V.response_json;$(de)}else if(V.status==="failed")clearTimeout(re),z(new Os(V.response_json));else{a&&a(V.response_json);const de=o(ce);setTimeout(()=>ge(ce+1),de)}}catch(V){z(V)}});ge()}))})},Me=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 Y(this,K,Ct).call(this,`${o}${r}`,n.async,{method:e,headers:c,body:d}):yield Y(this,K,At).call(this,`${o}${r}`,n,{method:e,headers:c,body:d})})};const Kt=(r,e,t,s)=>r instanceof Ze?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 Pe;class Zs{constructor(e){q(this,Pe),this.resourceName="Files",j(this,Pe,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,Pe).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,Pe).get(a)).meta)==null?void 0:s.images)!=null?n:{}})}}Pe=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 X,It,vr;class Fs{constructor(e){q(this,It),q(this,X),this.resourceName="Images",j(this,X,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,X).cache.images.entries.get(i);if(Ps(o))return o.result;o&&S(this,X).cache.images.entries.delete(i);const c=S(this,X).cache.images.pendingRequests.get(i);if(c)return c;const d=Y(this,It,vr).call(this,i,t,s,n,a);S(this,X).cache.images.pendingRequests.set(i,d);try{return yield d}finally{S(this,X).cache.images.pendingRequests.delete(i)}})}}X=new WeakMap,It=new WeakSet,vr=function(r,e,t,s,n){return N(this,null,function*(){const a=yield S(this,X).get(`v1/images/${e}?ids=${t}&format=${s}${n?`&scale=${n}`:""}`);return S(this,X).cache.images.entries.set(r,{result:a,ts:Date.now()}),a})};var nt;class $s{constructor(e){q(this,nt),this.resourceName="Nodes",j(this,nt,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,nt).get(o)})}}nt=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}),q(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"]),ae=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"]),Ds=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 Oe=(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=Oe;function Vs(r){wr=r}function at(){return wr}const it=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=at(),s=it({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Oe?void 0:Oe].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"}),Ae=r=>({status:"dirty",value:r}),F=r=>({status:"valid",value:r}),Nt=r=>r.status==="aborted",Rt=r=>r.status==="dirty",we=r=>r.status==="valid",De=r=>typeof Promise!="undefined"&&r instanceof Promise;function ot(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 Fe,$e;class ee{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(we(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 ae(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ae(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:ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(De(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:ae(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:ae(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:n});return we(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=>we(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:ae(e)},n=this._parse({data:e,path:s.path,parent:s}),a=yield De(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 Q.create(this,this._def)}nullable(){return me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return J.create(this)}promise(){return Re.create(this,this._def)}or(e){return ze.create([this,e],this._def)}and(e){return Be.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 Ke(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 Xe(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 et.create(this,e)}readonly(){return Ye.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 ke 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 ke(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}}ke.create=r=>new ke(u({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:y.ZodDate},b(r)));class ct 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)}}ct.create=r=>new ct(u({typeName:y.ZodSymbol},b(r)));class Ue 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)}}Ue.create=r=>new Ue(u({typeName:y.ZodUndefined},b(r)));class We 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)}}We.create=r=>new We(u({typeName:y.ZodNull},b(r)));class Ne extends w{constructor(){super(...arguments),this._any=!0}_parse(e){return F(e.data)}}Ne.create=r=>new Ne(u({typeName:y.ZodAny},b(r)));class be extends w{constructor(){super(...arguments),this._unknown=!0}_parse(e){return F(e.data)}}be.create=r=>new be(u({typeName:y.ZodUnknown},b(r)));class oe extends w{_parse(e){const t=this._getOrReturnCtx(e);return h(t,{code:l.invalid_type,expected:p.never,received:t.parsedType}),_}}oe.create=r=>new oe(u({typeName:y.ZodNever},b(r)));class dt 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)}}dt.create=r=>new dt(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 ee(t,i,t.path,o)))).then(i=>Z.mergeArray(s,i));const a=[...t.data].map((i,o)=>n.type._parseSync(new ee(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 Ee(r){if(r instanceof I){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=Q.create(Ee(s))}return new I(g(u({},r._def),{shape:()=>e}))}else return r instanceof J?new J(g(u({},r._def),{type:Ee(r.element)})):r instanceof Q?Q.create(Ee(r.unwrap())):r instanceof me?me.create(Ee(r.unwrap())):r instanceof te?te.create(r.items.map(e=>Ee(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 oe&&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 ee(n,v,n.path,d)),alwaysSet:d in n.data})}if(this._def.catchall instanceof oe){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 ee(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 Ee(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 Q;)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:oe.create(),typeName:y.ZodObject},b(e)));I.strictCreate=(r,e)=>new I(u({shape:()=>r,unknownKeys:"strict",catchall:oe.create(),typeName:y.ZodObject},b(e)));I.lazycreate=(r,e)=>new I(u({shape:r,unknownKeys:"strip",catchall:oe.create(),typeName:y.ZodObject},b(e)));class ze 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}}ze.create=(r,e)=>new ze(u({options:r,typeName:y.ZodUnion},b(e)));const ne=r=>r instanceof He?ne(r.schema):r instanceof G?ne(r.innerType()):r instanceof Je?[r.value]:r instanceof pe?r.options:r instanceof Ge?k.objectValues(r.enum):r instanceof Ke?ne(r._def.innerType):r instanceof Ue?[void 0]:r instanceof We?[null]:r instanceof Q?[void 0,...ne(r.unwrap())]:r instanceof me?[null,...ne(r.unwrap())]:r instanceof Lt||r instanceof Ye?ne(r.unwrap()):r instanceof Xe?ne(r._def.innerType):[];class ft 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=ne(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 ft(u({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n},b(s)))}}function jt(r,e){const t=ae(r),s=ae(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 Be 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}))}}Be.create=(r,e,t)=>new Be(u({left:r,right:e,typeName:y.ZodIntersection},b(t)));class te 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 ee(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 te(g(u({},this._def),{rest:e}))}}te.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new te(u({items:r,typeName:y.ZodTuple,rest:null},b(e)))};class qe 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 ee(s,o,s.path,o)),value:i._parse(new ee(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 qe(u({keyType:e,valueType:t,typeName:y.ZodRecord},b(s))):new qe(u({keyType:H.create(),valueType:e,typeName:y.ZodRecord},b(t)))}}class ut 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 ee(s,o,s.path,[d,"key"])),value:a._parse(new ee(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}}}}ut.create=(r,e,t)=>new ut(u({valueType:e,keyType:r,typeName:y.ZodMap},b(t)));class xe 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 ee(s,c,s.path,d)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new xe(g(u({},this._def),{minSize:{value:e,message:m.toString(t)}}))}max(e,t){return new xe(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)}}xe.create=(r,e)=>new xe(u({valueType:r,minSize:null,maxSize:null,typeName:y.ZodSet},b(e)));class Ce 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 it({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,at(),Oe].filter(d=>!!d),issueData:{code:l.invalid_arguments,argumentsError:c}})}function n(o,c){return it({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,at(),Oe].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 Re){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 Ce(g(u({},this._def),{args:te.create(e).rest(be.create())}))}returns(e){return new Ce(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 Ce(u({args:e||te.create([]).rest(be.create()),returns:t||be.create(),typeName:y.ZodFunction},b(s)))}}class He 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})}}He.create=(r,e)=>new He(u({getter:r,typeName:y.ZodLazy},b(e)));class Je 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}}Je.create=(r,e)=>new Je(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),Fe.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(ot(this,Fe)||kr(this,Fe,new Set(this._def.values)),!ot(this,Fe).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))}}Fe=new WeakMap;pe.create=Er;class Ge extends w{constructor(){super(...arguments),$e.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(ot(this,$e)||kr(this,$e,new Set(k.getValidEnumValues(this._def.values))),!ot(this,$e).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}}$e=new WeakMap;Ge.create=(r,e)=>new Ge(u({values:r,typeName:y.ZodNativeEnum},b(e)));class Re 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})))}}Re.create=(r,e)=>new Re(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"?Ae(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"?Ae(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(!we(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=>we(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 Q extends w{_parse(e){return this._getType(e)===p.undefined?F(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Q.create=(r,e)=>new Q(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 Ke 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}}Ke.create=(r,e)=>new Ke(u({innerType:r,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default},b(e)));class Xe 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 De(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}}Xe.create=(r,e)=>new Xe(u({innerType:r,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},b(e)));class lt 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}}}lt.create=r=>new lt(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 et 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(),Ae(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 et({in:e,out:t,typeName:y.ZodPipeline})}}class Ye extends w{_parse(e){const t=this._def.innerType._parse(e),s=n=>(we(n)&&(n.value=Object.freeze(n.value)),n);return De(t)?t.then(n=>s(n)):s(t)}unwrap(){return this._def.innerType}}Ye.create=(r,e)=>new Ye(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?Ne.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}))}}):Ne.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=lt.create,mn=he.create,Or=Ve.create,gn=ke.create,yn=ct.create,vn=Ue.create,_n=We.create,bn=Ne.create,wn=be.create,kn=oe.create,xn=dt.create,Tn=J.create,Sn=I.create,En=I.strictCreate,An=ze.create,Cn=ft.create,In=Be.create,On=te.create,Nn=qe.create,Rn=ut.create,jn=xe.create,Zn=Ce.create,Mn=He.create,Pn=Je.create,Fn=pe.create,$n=Ge.create,Ln=Re.create,Qt=G.create,Dn=Q.create,Vn=me.create,Un=G.createWithPreprocess,Wn=et.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=>ke.create(g(u({},r),{coerce:!0}))},Jn=_;var T=Object.freeze({__proto__:null,defaultErrorMap:Oe,setErrorMap:Vs,getErrorMap:at,makeIssue:it,EMPTY_PATH:Us,addIssueToContext:h,ParseStatus:Z,INVALID:_,DIRTY:Ae,OK:F,isAborted:Nt,isDirty:Rt,isValid:we,isAsync:De,get util(){return k},get objectUtil(){return Ot},ZodParsedType:p,getParsedType:ae,ZodType:w,datetimeRegex:Sr,ZodString:H,ZodNumber:fe,ZodBigInt:he,ZodBoolean:Ve,ZodDate:ke,ZodSymbol:ct,ZodUndefined:Ue,ZodNull:We,ZodAny:Ne,ZodUnknown:be,ZodNever:oe,ZodVoid:dt,ZodArray:J,ZodObject:I,ZodUnion:ze,ZodDiscriminatedUnion:ft,ZodIntersection:Be,ZodTuple:te,ZodRecord:qe,ZodMap:ut,ZodSet:xe,ZodFunction:Ce,ZodLazy:He,ZodLiteral:Je,ZodEnum:pe,ZodNativeEnum:Ge,ZodPromise:Re,ZodEffects:G,ZodTransformer:G,ZodOptional:Q,ZodNullable:me,ZodDefault:Ke,ZodCatch:Xe,ZodNaN:lt,BRAND:ln,ZodBranded:Lt,ZodPipeline:et,ZodReadonly:Ye,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:Vn,number:Ir,object:Sn,oboolean:qn,onumber:Bn,optional:Dn,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:Ds,ZodError:W});const Gn=T.object({language:T.enum(["typescript","javascript"]).optional(),disableMarkedForExport:T.boolean().optional(),allowAutoSelectFirstNode:T.boolean().optional().default(!0),enableDisplayDataId:T.boolean().optional(),enableDisplayDataName:T.boolean().optional()}).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,Qe,ie,jr,Le;class Kn{constructor({auth:e,apiBaseAddress:t="https://public-api.animaapp.com"}={}){tt(this,ie);tt(this,E);tt(this,Qe);gt(this,Qe,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 Se(this,ie,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,enableDisplayDataId:a.enableDisplayDataId,enableDisplayDataName:a.enableDisplayDataName,codegenSettings:a.codegenSettings,webhookUrl:e.webhookUrl};return Se(this,ie,Le).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}));let i;if(e.mhtml)i={type:"mhtml",mhtml:e.mhtml,url:e.url};else if(e.url)i={type:"url",url:e.url};else throw new Error("Either 'url' or 'mhtml' must be provided");const o={tracking:a,assetsStorage:e.assetsStorage,params:{input:i,conventions:{framework:e.settings.framework,language:e.settings.language,styling:e.settings.styling},assetsStorage:{type:"bundled"}}};return Se(this,ie,Le).call(this,"/v1/l2c",o,t,"l2c",s)})}generateCodeFromPrompt(n){return C(this,arguments,function*(e,t={},s){var o;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:u({prompt:e.prompt,conventions:{language:e.settings.language,framework:e.settings.framework,styling:e.settings.styling,uiLibrary:e.settings.uiLibrary}},(o=e.settings.codegenSettings)!=null?o:{}),webhookUrl:e.webhookUrl};return console.log("P2C Request Body:",JSON.stringify(i,null,2)),Se(this,ie,Le).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 Se(this,ie,Le).call(this,"/v1/l2c",i,t,"l2c",s)})}}E=new WeakMap,Qe=new WeakMap,ie=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 ue({name:"Task Crashed",reason:c.reason})})},Le=function(e,t,s,n,a){return C(this,null,function*(){var v,R,M,$,z,re,ge,ce,V,de;if(this.hasAuth()===!1)throw new Error('It needs to set "auth" before calling this method.');const i={},o=yield fetch(`${A(this,Qe)}${e}`,{method:"POST",headers:g(u({},this.headers),{Accept:"text/event-stream"}),body:JSON.stringify(t),signal:a});if(!o.ok){const Te=yield o.text();let B;try{B=JSON.parse(Te)}catch(O){}throw((v=B==null?void 0:B.error)==null?void 0:v.name)==="ZodError"?(console.log("Zod validation error:",JSON.stringify(B.error.issues,null,2)),new ue({name:"HTTP error from Anima API",reason:"Invalid body payload",detail:B.error.issues,status:o.status})):typeof B=="object"?new ue({name:`Error "${B}"`,reason:"Unknown",status:o.status}):new ue({name:"HTTP error from Anima API",reason:Te,status:o.status})}if(!o.body)throw new ue({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:Te,value:B}=yield c.read();if(Te)break;f+=d.decode(B,{stream:!0});const O=f.split(`
2
- `);f=O.pop()||"";for(const ye of O)if(!(!ye.trim()||ye.startsWith(":"))&&ye.startsWith("data: ")){let x;try{x=JSON.parse(ye.slice(6))}catch(L){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):(re=s.onAssetsList)==null||re.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):(ce=s.onGeneratingCode)==null||ce.call(s,{status:x.payload.status,progress:x.payload.progress,files:x.payload.files});break}case"progress_messages_updated":{typeof s=="function"?s(x):(V=s.onProgressMessagesUpdated)==null||V.call(s,x.payload.progressMessages);break}case"codegen_completed":case"generation_completed":{typeof s=="function"?s(x):(de=s.onCodegenCompleted)==null||de.call(s);break}case"error":throw new ue({name:x.payload.errorName,reason:x.payload.reason});case"done":return i.tokenUsage=x.payload.tokenUsage,i.sessionId=x.payload.sessionId,i}}}}finally{c.cancel()}throw new ue({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 ht(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)=>ht(r,e,r.generateCode);function pt(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 $r=Object.defineProperty,Lr=Object.defineProperties;var Dr=Object.getOwnPropertyDescriptors;var Dt=Object.getOwnPropertySymbols;var Vr=Object.prototype.hasOwnProperty,Ur=Object.prototype.propertyIsEnumerable;var Ut=r=>{throw TypeError(r)};var Vt=(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={}))Vr.call(e,t)&&Vt(r,t,e[t]);if(Dt)for(var t of Dt(e))Ur.call(e,t)&&Vt(r,t,e[t]);return r},g=(r,e)=>Lr(r,Dr(e));var mt=(r,e,t)=>e.has(r)||Ut("Cannot "+t);var C=(r,e,t)=>(mt(r,e,"read from private field"),t?t.call(r):e.get(r)),tt=(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),Te=(r,e,t)=>(mt(r,e,"access private method"),t);var I=(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 ce 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,V=(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)),z=(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),K=(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()),W=M&&Object.getPrototypeOf(new Map().entries()),ee=f&&typeof Array.prototype[Symbol.iterator]=="function",pe=ee&&Object.getPrototypeOf([][Symbol.iterator]()),ie=f&&typeof String.prototype[Symbol.iterator]=="function",D=ie&&Object.getPrototypeOf(""[Symbol.iterator]()),oe=8,et=-1;function ke(E){var xe=typeof E;if(xe!=="object")return xe;if(E===null)return"null";if(E===s)return"global";if(Array.isArray(E)&&(v===!1||!(Symbol.toStringTag in E)))return"Array";if(typeof window=="object"&&window!==null){if(typeof window.location=="object"&&E===window.location)return"Location";if(typeof window.document=="object"&&E===window.document)return"Document";if(typeof window.navigator=="object"){if(typeof window.navigator.mimeTypes=="object"&&E===window.navigator.mimeTypes)return"MimeTypeArray";if(typeof window.navigator.plugins=="object"&&E===window.navigator.plugins)return"PluginArray"}if((typeof window.HTMLElement=="function"||typeof window.HTMLElement=="object")&&E instanceof window.HTMLElement){if(E.tagName==="BLOCKQUOTE")return"HTMLQuoteElement";if(E.tagName==="TD")return"HTMLTableDataCellElement";if(E.tagName==="TH")return"HTMLTableHeaderCellElement"}}var me=v&&E[Symbol.toStringTag];if(typeof me=="string")return me;var b=Object.getPrototypeOf(E);return b===RegExp.prototype?"RegExp":b===Date.prototype?"Date":t&&b===Promise.prototype?"Promise":i&&b===Set.prototype?"Set":a&&b===Map.prototype?"Map":c&&b===WeakSet.prototype?"WeakSet":o&&b===WeakMap.prototype?"WeakMap":d&&b===DataView.prototype?"DataView":a&&b===W?"Map Iterator":i&&b===$?"Set Iterator":ee&&b===pe?"Array Iterator":ie&&b===D?"String Iterator":b===null?"Object":Object.prototype.toString.call(E).slice(oe,et)}return ke})}(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 Ce(r){return ns(r)?"Buffer":rs(r)}const is=new Set(["Arguments","Array","Map","Object","Set"]);function os(r,e,t=null){switch(t||Ce(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||Ce(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 te(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",te],["Float64Array",te],["Int16Array",te],["Int32Array",te],["Int8Array",te],["Uint16Array",te],["Uint32Array",te],["Uint8Array",te],["Uint8ClampedArray",te],["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||Ce(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=Ce(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=Ce(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=Ce(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 rt,ge,st,St,gr;class Ss{constructor({maxAttempts:e=3,func:t}){z(this,St),z(this,rt),z(this,ge),z(this,st),j(this,rt,e),j(this,st,t),j(this,ge,0)}run(){return N(this,null,function*(){try{return yield S(this,st).call(this)}catch(e){if(j(this,ge,S(this,ge)+1),S(this,ge)>S(this,rt))throw console.error("Max attempts reached"),e;const t=K(this,St,gr).call(this);return yield Ts(t),yield this.run()}})}}rt=new WeakMap,ge=new WeakMap,st=new WeakMap,St=new WeakSet,gr=function(){return S(this,ge)*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 ye,L,J,At,Ct,Ze;class js{constructor({fetch:e=globalThis.fetch.bind(globalThis),baseAddress:t}){z(this,J),z(this,ye),z(this,L),this.baseAddress=t,j(this,ye,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=V(V({},o),c.extraHeaders)),c.requestValidation&&(o=Mt(V({},o),{"X-Request-Nonce":yr(),"X-Request-Timestamp":Et()})),c.async?yield K(this,J,Ct).call(this,`${i}${t}`,c.async,{headers:o}):yield K(this,J,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,{}),K(this,J,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,{}),K(this,J,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,{}),K(this,J,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,{}),K(this,J,Ze).call(this,s,"PATCH",n,a,i)})}}ye=new WeakMap,L=new WeakMap,J=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,ye).call(this,r,V(V({},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()),W=60*60*24;if(isNaN(M)||Math.abs($-M)>W)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,ye).call(this,d,V(V({},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(($,W)=>N(this,null,function*(){const ee=setTimeout(()=>{W(new Error("Job timed out"))},c),pe=(ie=0)=>N(this,null,function*(){if(i!=null&&i.aborted){clearTimeout(ee),S(this,ye).call(this,`${f}/${M}/cancel`,{method:"POST",headers:this.headers}).then(()=>{W(new je({canceled:!0}))}).catch(D=>{W(new je({canceled:!1}))});return}try{const D=yield(yield S(this,ye).call(this,`${f}/${M}`,{headers:this.headers})).json();if(D.status==="success"){clearTimeout(ee);const oe=D.response_json;$(oe)}else if(D.status==="failed")clearTimeout(ee),W(new Os(D.response_json));else{a&&a(D.response_json);const oe=o(ie);setTimeout(()=>pe(ie+1),oe)}}catch(D){W(D)}});pe()}))})},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=V(V({},c),n.extraHeaders)),n.requestValidation&&(c=Mt(V({},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 K(this,J,Ct).call(this,`${o}${r}`,n.async,{method:e,headers:c,body:d}):yield K(this,J,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){z(this,Me),this.resourceName="Files",j(this,Me,e)}get(e){return N(this,arguments,function*({fileKey:t,params:s={}}){const n=new URLSearchParams(V({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 G,It,vr;class Fs{constructor(e){z(this,It),z(this,G),this.resourceName="Images",j(this,G,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,G).cache.images.entries.get(i);if(Ps(o))return o.result;o&&S(this,G).cache.images.entries.delete(i);const c=S(this,G).cache.images.pendingRequests.get(i);if(c)return c;const d=K(this,It,vr).call(this,i,t,s,n,a);S(this,G).cache.images.pendingRequests.set(i,d);try{return yield d}finally{S(this,G).cache.images.pendingRequests.delete(i)}})}}G=new WeakMap,It=new WeakSet,vr=function(r,e,t,s,n){return N(this,null,function*(){const a=yield S(this,G).get(`v1/images/${e}?ids=${t}&format=${s}${n?`&scale=${n}`:""}`);return S(this,G).cache.images.entries.set(r,{result:a,ts:Date.now()}),a})};var nt;class $s{constructor(e){z(this,nt),this.resourceName="Nodes",j(this,nt,e)}get(e){return N(this,arguments,function*({fileKey:t,nodeIds:s,params:n={}}){const a=Mt(V({},n),{ids:s.join(",")}),i=new URLSearchParams(V({plugin_data:"857346721138427857"},a)).toString(),o=`v1/files/${t}/nodes?${i}`;return yield S(this,nt).get(o)})}}nt=new WeakMap;var de;class _r extends js{constructor({baseAddress:e="https://api.figma.com/",fetch:t=globalThis.fetch.bind(globalThis)}={}){super({fetch:t,baseAddress:e}),z(this,de,""),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,de,e)}get token(){return S(this,de)}get headers(){const e={"Content-Type":"application/json"};return S(this,de).startsWith("figd_")?e["X-FIGMA-TOKEN"]=S(this,de):S(this,de).startsWith("figu_")&&(e.Authorization=`Bearer ${S(this,de)}`),e}}de=new WeakMap;const br=a=>I(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=>I(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 x;(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})(x||(x={}));var Ot;(function(r){r.mergeShapes=(e,t)=>u(u({},e),t)})(Ot||(Ot={}));const p=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),se=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=x.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Ds=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class U 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 U))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const 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()}}U.create=r=>new U(r);const Ie=(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,x.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(r.keys,", ")}`;break;case l.invalid_union:t="Invalid input";break;case l.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(r.options)}`;break;case l.invalid_enum_value:t=`Invalid enum value. Expected ${x.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}"`:x.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,x.assertNever(r)}return{message:t}};let wr=Ie;function Vs(r){wr=r}function at(){return wr}const it=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=at(),s=it({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Ie?void 0:Ie].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 I(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"}),Ee=r=>({status:"dirty",value:r}),F=r=>({status:"valid",value:r}),Nt=r=>r.status==="aborted",Rt=r=>r.status==="dirty",_e=r=>r.status==="valid",Le=r=>typeof Promise!="undefined"&&r instanceof Promise;function ot(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 Y{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(_e(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 U(r.common.issues);return this._error=t,this._error}}};function w(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 k{get description(){return this._def.description}_getType(e){return se(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:se(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:se(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:se(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:se(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:n});return _e(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=>_e(a)?{value:a.value}:{issues:n.common.issues})}parseAsync(e,t){return I(this,null,function*(){const s=yield this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error})}safeParseAsync(e,t){return I(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:se(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 H({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 X.create(this,this._def)}nullable(){return he.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return q.create(this)}promise(){return Ne.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 H(g(u({},w(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({},w(this._def)),{innerType:this,defaultValue:t,typeName:y.ZodDefault}))}brand(){return new Lt(u({typeName:y.ZodBranded,type:this},w(this._def)))}catch(e){const t=typeof e=="function"?e:()=>e;return new Ke(g(u({},w(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 B extends k{_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()):x.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 B(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 B(g(u({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}toLowerCase(){return new B(g(u({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new B(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}}B.create=r=>{var e;return new B(u({checks:[],typeName:y.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1},w(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 ue extends k{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"?x.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()):x.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 ue(g(u({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:m.toString(n)}]}))}_addCheck(e){return new ue(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"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ue.create=r=>new ue(u({checks:[],typeName:y.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1},w(r)));class le extends k{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()):x.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 le(g(u({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:m.toString(n)}]}))}_addCheck(e){return new le(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}}le.create=r=>{var e;return new le(u({checks:[],typeName:y.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1},w(r)))};class De extends k{_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)}}De.create=r=>new De(u({typeName:y.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1},w(r)));class be extends k{_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()):x.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new be(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}}be.create=r=>new be(u({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:y.ZodDate},w(r)));class ct extends k{_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)}}ct.create=r=>new ct(u({typeName:y.ZodSymbol},w(r)));class Ve extends k{_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},w(r)));class Ue extends k{_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},w(r)));class Oe extends k{constructor(){super(...arguments),this._any=!0}_parse(e){return F(e.data)}}Oe.create=r=>new Oe(u({typeName:y.ZodAny},w(r)));class ve extends k{constructor(){super(...arguments),this._unknown=!0}_parse(e){return F(e.data)}}ve.create=r=>new ve(u({typeName:y.ZodUnknown},w(r)));class ae extends k{_parse(e){const t=this._getOrReturnCtx(e);return h(t,{code:l.invalid_type,expected:p.never,received:t.parsedType}),_}}ae.create=r=>new ae(u({typeName:y.ZodNever},w(r)));class dt extends k{_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)}}dt.create=r=>new dt(u({typeName:y.ZodVoid},w(r)));class q extends k{_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 Y(t,i,t.path,o)))).then(i=>Z.mergeArray(s,i));const a=[...t.data].map((i,o)=>n.type._parseSync(new Y(t,i,t.path,o)));return Z.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new q(g(u({},this._def),{minLength:{value:e,message:m.toString(t)}}))}max(e,t){return new q(g(u({},this._def),{maxLength:{value:e,message:m.toString(t)}}))}length(e,t){return new q(g(u({},this._def),{exactLength:{value:e,message:m.toString(t)}}))}nonempty(e){return this.min(1,e)}}q.create=(r,e)=>new q(u({type:r,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray},w(e)));function Se(r){if(r instanceof O){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=X.create(Se(s))}return new O(g(u({},r._def),{shape:()=>e}))}else return r instanceof q?new q(g(u({},r._def),{type:Se(r.element)})):r instanceof X?X.create(Se(r.unwrap())):r instanceof he?he.create(Se(r.unwrap())):r instanceof Q?Q.create(r.items.map(e=>Se(e))):r}class O extends k{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=x.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==p.object){const 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 ae&&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 Y(n,v,n.path,d)),alwaysSet:d in n.data})}if(this._def.catchall instanceof ae){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 Y(n,v,n.path,f)),alwaysSet:f in n.data})}}return n.common.async?Promise.resolve().then(()=>I(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 O(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 O(g(u({},this._def),{unknownKeys:"strip"}))}passthrough(){return new O(g(u({},this._def),{unknownKeys:"passthrough"}))}extend(e){return new O(g(u({},this._def),{shape:()=>u(u({},this._def.shape()),e)}))}merge(e){return new O({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 O(g(u({},this._def),{catchall:e}))}pick(e){const t={};return x.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new O(g(u({},this._def),{shape:()=>t}))}omit(e){const t={};return x.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new O(g(u({},this._def),{shape:()=>t}))}deepPartial(){return Se(this)}partial(e){const t={};return x.objectKeys(this.shape).forEach(s=>{const n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}),new O(g(u({},this._def),{shape:()=>t}))}required(e){const t={};return x.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof X;)a=a._def.innerType;t[s]=a}}),new O(g(u({},this._def),{shape:()=>t}))}keyof(){return Er(x.objectKeys(this.shape))}}O.create=(r,e)=>new O(u({shape:()=>r,unknownKeys:"strip",catchall:ae.create(),typeName:y.ZodObject},w(e)));O.strictCreate=(r,e)=>new O(u({shape:()=>r,unknownKeys:"strict",catchall:ae.create(),typeName:y.ZodObject},w(e)));O.lazycreate=(r,e)=>new O(u({shape:r,unknownKeys:"strip",catchall:ae.create(),typeName:y.ZodObject},w(e)));class We extends k{_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 U(o.ctx.common.issues));return h(t,{code:l.invalid_union,unionErrors:i}),_}if(t.common.async)return Promise.all(s.map(a=>I(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 U(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},w(e)));const re=r=>r instanceof qe?re(r.schema):r instanceof H?re(r.innerType()):r instanceof He?[r.value]:r instanceof fe?r.options:r instanceof Je?x.objectValues(r.enum):r instanceof Ge?re(r._def.innerType):r instanceof Ve?[void 0]:r instanceof Ue?[null]:r instanceof X?[void 0,...re(r.unwrap())]:r instanceof he?[null,...re(r.unwrap())]:r instanceof Lt||r instanceof Xe?re(r.unwrap()):r instanceof Ke?re(r._def.innerType):[];class ft extends k{_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=re(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 ft(u({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n},w(s)))}}function jt(r,e){const t=se(r),s=se(e);if(r===e)return{valid:!0,data:r};if(t===p.object&&s===p.object){const n=x.objectKeys(e),a=x.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 k{_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},w(t)));class Q extends k{_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 Y(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 Q(g(u({},this._def),{rest:e}))}}Q.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Q(u({items:r,typeName:y.ZodTuple,rest:null},w(e)))};class Be extends k{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 Y(s,o,s.path,o)),value:i._parse(new Y(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 k?new Be(u({keyType:e,valueType:t,typeName:y.ZodRecord},w(s))):new Be(u({keyType:B.create(),valueType:e,typeName:y.ZodRecord},w(t)))}}class ut extends k{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 Y(s,o,s.path,[d,"key"])),value:a._parse(new Y(s,c,s.path,[d,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(()=>I(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}}}}ut.create=(r,e,t)=>new ut(u({valueType:e,keyType:r,typeName:y.ZodMap},w(t)));class we extends k{_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 Y(s,c,s.path,d)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new we(g(u({},this._def),{minSize:{value:e,message:m.toString(t)}}))}max(e,t){return new we(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)}}we.create=(r,e)=>new we(u({valueType:r,minSize:null,maxSize:null,typeName:y.ZodSet},w(e)));class Ae extends k{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 it({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,at(),Ie].filter(d=>!!d),issueData:{code:l.invalid_arguments,argumentsError:c}})}function n(o,c){return it({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,at(),Ie].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 Ne){const o=this;return F(function(...c){return I(this,null,function*(){const d=new U([]),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 U([s(c,d.error)]);const f=Reflect.apply(i,this,d.data),v=o._def.returns.safeParse(f,a);if(!v.success)throw new U([n(f,v.error)]);return v.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ae(g(u({},this._def),{args:Q.create(e).rest(ve.create())}))}returns(e){return new Ae(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 Ae(u({args:e||Q.create([]).rest(ve.create()),returns:t||ve.create(),typeName:y.ZodFunction},w(s)))}}class qe extends k{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},w(e)));class He extends k{_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},w(e)));function Er(r,e){return new fe(u({values:r,typeName:y.ZodEnum},w(e)))}class fe extends k{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:x.joinValues(s),received:t.parsedType,code:l.invalid_type}),_}if(ot(this,Pe)||kr(this,Pe,new Set(this._def.values)),!ot(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 fe.create(e,u(u({},this._def),t))}exclude(e,t=this._def){return fe.create(this.options.filter(s=>!e.includes(s)),u(u({},this._def),t))}}Pe=new WeakMap;fe.create=Er;class Je extends k{constructor(){super(...arguments),Fe.set(this,void 0)}_parse(e){const t=x.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==p.string&&s.parsedType!==p.number){const n=x.objectValues(t);return h(s,{expected:x.joinValues(n),received:s.parsedType,code:l.invalid_type}),_}if(ot(this,Fe)||kr(this,Fe,new Set(x.getValidEnumValues(this._def.values))),!ot(this,Fe).has(e.data)){const n=x.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},w(e)));class Ne extends k{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})))}}Ne.create=(r,e)=>new Ne(u({type:r,typeName:y.ZodPromise},w(e)));class H extends k{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=>I(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"?Ee(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"?Ee(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(!_e(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=>_e(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);x.assertNever(n)}}H.create=(r,e,t)=>new H(u({schema:r,typeName:y.ZodEffects,effect:e},w(t)));H.createWithPreprocess=(r,e,t)=>new H(u({schema:e,effect:{type:"preprocess",transform:r},typeName:y.ZodEffects},w(t)));class X extends k{_parse(e){return this._getType(e)===p.undefined?F(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}X.create=(r,e)=>new X(u({innerType:r,typeName:y.ZodOptional},w(e)));class he extends k{_parse(e){return this._getType(e)===p.null?F(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}he.create=(r,e)=>new he(u({innerType:r,typeName:y.ZodNullable},w(e)));class Ge extends k{_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},w(e)));class Ke extends k{_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 U(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new U(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},w(e)));class lt extends k{_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}}}lt.create=r=>new lt(u({typeName:y.ZodNaN},w(r)));const ln=Symbol("zod_brand");class Lt extends k{_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 k{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return I(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(),Ee(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 k{_parse(e){const t=this._def.innerType._parse(e),s=n=>(_e(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},w(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?Oe.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}))}}):Oe.create()}const fn={object:O.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=B.create,Ir=ue.create,pn=lt.create,mn=le.create,Or=De.create,gn=be.create,yn=ct.create,vn=Ve.create,_n=Ue.create,bn=Oe.create,wn=ve.create,kn=ae.create,xn=dt.create,Tn=q.create,Sn=O.create,En=O.strictCreate,An=We.create,Cn=ft.create,In=ze.create,On=Q.create,Nn=Be.create,Rn=ut.create,jn=we.create,Zn=Ae.create,Mn=qe.create,Pn=He.create,Fn=fe.create,$n=Je.create,Ln=Ne.create,Qt=H.create,Dn=X.create,Vn=he.create,Un=H.createWithPreprocess,Wn=Qe.create,zn=()=>Cr().optional(),Bn=()=>Ir().optional(),qn=()=>Or().optional(),Hn={string:r=>B.create(g(u({},r),{coerce:!0})),number:r=>ue.create(g(u({},r),{coerce:!0})),boolean:r=>De.create(g(u({},r),{coerce:!0})),bigint:r=>le.create(g(u({},r),{coerce:!0})),date:r=>be.create(g(u({},r),{coerce:!0}))},Jn=_;var T=Object.freeze({__proto__:null,defaultErrorMap:Ie,setErrorMap:Vs,getErrorMap:at,makeIssue:it,EMPTY_PATH:Us,addIssueToContext:h,ParseStatus:Z,INVALID:_,DIRTY:Ee,OK:F,isAborted:Nt,isDirty:Rt,isValid:_e,isAsync:Le,get util(){return x},get objectUtil(){return Ot},ZodParsedType:p,getParsedType:se,ZodType:k,datetimeRegex:Sr,ZodString:B,ZodNumber:ue,ZodBigInt:le,ZodBoolean:De,ZodDate:be,ZodSymbol:ct,ZodUndefined:Ve,ZodNull:Ue,ZodAny:Oe,ZodUnknown:ve,ZodNever:ae,ZodVoid:dt,ZodArray:q,ZodObject:O,ZodUnion:We,ZodDiscriminatedUnion:ft,ZodIntersection:ze,ZodTuple:Q,ZodRecord:Be,ZodMap:ut,ZodSet:we,ZodFunction:Ae,ZodLazy:qe,ZodLiteral:He,ZodEnum:fe,ZodNativeEnum:Je,ZodPromise:Ne,ZodEffects:H,ZodTransformer:H,ZodOptional:X,ZodNullable:he,ZodDefault:Ge,ZodCatch:Ke,ZodNaN:lt,BRAND:ln,ZodBranded:Lt,ZodPipeline:Qe,ZodReadonly:Xe,custom:Ar,Schema:k,ZodSchema:k,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:Vn,number:Ir,object:Sn,oboolean:qn,onumber:Bn,optional:Dn,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:Ds,ZodError:U});const Gn=T.object({language:T.enum(["typescript","javascript"]).optional(),disableMarkedForExport:T.boolean().optional(),allowAutoSelectFirstNode:T.boolean().optional().default(!0),enableDisplayDataId:T.boolean().optional(),enableDisplayDataName:T.boolean().optional()}).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 A,Ye,ne,jr,$e;class Kn{constructor({auth:e,apiBaseAddress:t="https://public-api.animaapp.com"}={}){tt(this,ne);tt(this,A);tt(this,Ye);gt(this,Ye,t),e&&(this.auth=e)}hasAuth(){return!!C(this,A)}set auth(e){gt(this,A,e)}get headers(){const e={"Content-Type":"application/json"};return C(this,A)&&(e.Authorization=`Bearer ${C(this,A).token}`,"teamId"in C(this,A)&&(e["X-Team-Id"]=C(this,A).teamId)),e}generateCode(n){return I(this,arguments,function*(e,t={},s){var c;const a=Nr(e.settings);e.figmaToken&&(yield Te(this,ne,jr).call(this,e.fileKey,e.figmaToken,e.nodesId,{allowAutoSelectFirstNode:(c=a.allowAutoSelectFirstNode)!=null?c:!0},s));let i=e.tracking;C(this,A)&&"userId"in C(this,A)&&C(this,A).userId&&(i!=null&&i.externalId||(i={externalId:C(this,A).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,enableDisplayDataId:a.enableDisplayDataId,enableDisplayDataName:a.enableDisplayDataName,codegenSettings:a.codegenSettings,webhookUrl:e.webhookUrl};return Te(this,ne,$e).call(this,"/v1/codegen",o,t,"codegen",s)})}generateCodeFromWebsite(n){return I(this,arguments,function*(e,t={},s){let a=e.tracking;C(this,A)&&"userId"in C(this,A)&&C(this,A).userId&&(a!=null&&a.externalId||(a={externalId:C(this,A).userId}));let i;if(e.mhtml)i={type:"mhtml",mhtml:e.mhtml,url:e.url};else if(e.url)i={type:"url",url:e.url};else throw new Error("Either 'url' or 'mhtml' must be provided");const o={tracking:a,assetsStorage:e.assetsStorage,params:{input:i,conventions:{framework:e.settings.framework,language:e.settings.language,styling:e.settings.styling},assetsStorage:{type:"bundled"}}};return Te(this,ne,$e).call(this,"/v1/l2c",o,t,"l2c",s)})}generateCodeFromPrompt(n){return I(this,arguments,function*(e,t={},s){var o;let a=e.tracking;C(this,A)&&"userId"in C(this,A)&&C(this,A).userId&&(a!=null&&a.externalId||(a={externalId:C(this,A).userId}));const i={tracking:a,assetsStorage:e.assetsStorage,params:u({prompt:e.prompt,conventions:{language:e.settings.language,framework:e.settings.framework,styling:e.settings.styling,uiLibrary:e.settings.uiLibrary}},(o=e.settings.codegenSettings)!=null?o:{}),webhookUrl:e.webhookUrl};return console.log("P2C Request Body:",JSON.stringify(i,null,2)),Te(this,ne,$e).call(this,"/v1/p2c",i,t,"p2c",s)})}generateLink2Code(n){return I(this,arguments,function*(e,t={},s){let a=e.tracking;C(this,A)&&"userId"in C(this,A)&&C(this,A).userId&&(a!=null&&a.externalId||(a={externalId:C(this,A).userId}));const i={tracking:a,assetsStorage:e.assetsStorage,params:e.params};return Te(this,ne,$e).call(this,"/v1/l2c",i,t,"l2c",s)})}}A=new WeakMap,Ye=new WeakMap,ne=new WeakSet,jr=function(e,t,s,n,a){return I(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 ce({name:"Task Crashed",reason:c.reason})})},$e=function(e,t,s,n,a){return I(this,null,function*(){var v,R,M,$,W,ee,pe,ie,D,oe,et;if(this.hasAuth()===!1)throw new Error('It needs to set "auth" before calling this method.');const i={},o=yield fetch(`${C(this,Ye)}${e}`,{method:"POST",headers:g(u({},this.headers),{Accept:"text/event-stream"}),body:JSON.stringify(t),signal:a});if(!o.ok){const ke=yield o.text();let E;try{E=JSON.parse(ke)}catch(xe){}throw((v=E==null?void 0:E.error)==null?void 0:v.name)==="ZodError"?(console.log("Zod validation error:",JSON.stringify(E.error.issues,null,2)),new ce({name:"HTTP error from Anima API",reason:"Invalid body payload",detail:E.error.issues,status:o.status})):typeof E=="object"?new ce({name:`Error "${E}"`,reason:"Unknown",status:o.status}):new ce({name:"HTTP error from Anima API",reason:ke,status:o.status})}if(!o.body)throw new ce({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:ke,value:E}=yield c.read();if(ke)break;f+=d.decode(E,{stream:!0});const xe=f.split(`
2
+ `);f=xe.pop()||"";for(const me of xe)if(!(!me.trim()||me.startsWith(":"))&&me.startsWith("data: ")){let b;try{b=JSON.parse(me.slice(6))}catch(ca){continue}switch(b.type){case"queueing":{typeof s=="function"?s(b):(R=s.onQueueing)==null||R.call(s,{sessionId:b.sessionId});break}case"start":{i.sessionId=b.sessionId,typeof s=="function"?s(b):(M=s.onStart)==null||M.call(s,{sessionId:b.sessionId});break}case"pre_codegen":{n==="codegen"&&(typeof s=="function"?s(b):($=s.onPreCodegen)==null||$.call(s,{message:b.message}));break}case"assets_uploaded":{typeof s=="function"?s(b):(W=s.onAssetsUploaded)==null||W.call(s);break}case"assets_list":{i.assets=b.payload.assets,typeof s=="function"?s(b):(ee=s.onAssetsList)==null||ee.call(s,b.payload);break}case"figma_metadata":{n==="codegen"&&(i.figmaFileName=b.figmaFileName,i.figmaSelectedFrameName=b.figmaSelectedFrameName,typeof s=="function"?s(b):(pe=s.onFigmaMetadata)==null||pe.call(s,{figmaFileName:b.figmaFileName,figmaSelectedFrameName:b.figmaSelectedFrameName}));break}case"generating_code":{b.payload.status==="success"&&(i.files=b.payload.files),typeof s=="function"?s(b):(ie=s.onGeneratingCode)==null||ie.call(s,{status:b.payload.status,progress:b.payload.progress,files:b.payload.files});break}case"progress_messages_updated":{typeof s=="function"?s(b):(D=s.onProgressMessagesUpdated)==null||D.call(s,b.payload.progressMessages);break}case"job_status_updated":{typeof s=="function"?s(b):(oe=s.onJobStatusUpdated)==null||oe.call(s,b.payload.jobStatus);break}case"codegen_completed":case"generation_completed":{typeof s=="function"?s(b):(et=s.onCodegenCompleted)==null||et.call(s);break}case"error":throw new ce({name:b.payload.errorName,reason:b.payload.reason});case"done":return i.tokenUsage=b.payload.tokenUsage,i.sessionId=b.payload.sessionId,i}}}}finally{c.cancel()}throw new ce({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 ht(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)=>ht(r,e,r.generateCode);function pt(r){return I(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 pt(t)}),Mr=(r,e)=>ht(r,e,r.generateCodeFromWebsite),aa=(r,e)=>C(exports,null,function*(){const t=Mr(r,e);return pt(t)}),Pr=(r,e)=>ht(r,e,r.generateCodeFromPrompt),ia=(r,e)=>C(exports,null,function*(){const t=Pr(r,e);return pt(t)}),Fr=(r,e)=>ht(r,e,r.generateLink2Code),oa=(r,e)=>C(exports,null,function*(){const t=Fr(r,e);return pt(t)});exports.Anima=Kn;exports.CodegenError=ue;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 na=(r,e)=>I(exports,null,function*(){const t=Zr(r,e);return pt(t)}),Mr=(r,e)=>ht(r,e,r.generateCodeFromWebsite),aa=(r,e)=>I(exports,null,function*(){const t=Mr(r,e);return pt(t)}),Pr=(r,e)=>ht(r,e,r.generateCodeFromPrompt),ia=(r,e)=>I(exports,null,function*(){const t=Pr(r,e);return pt(t)}),Fr=(r,e)=>ht(r,e,r.generateLink2Code),oa=(r,e)=>I(exports,null,function*(){const t=Fr(r,e);return pt(t)});exports.Anima=Kn;exports.CodegenError=ce;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;
6
6
  //# sourceMappingURL=index.cjs.map