@animaapp/anima-sdk 0.6.34 → 0.7.0

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