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