@locale-labs/miniapp-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.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/dist/sdk.js +1 -0
  3. package/package.json +28 -0
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # locale-miniapp-sdk
package/dist/sdk.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(()=>{var ot=Object.create;var je=Object.defineProperty;var dt=Object.getOwnPropertyDescriptor;var ut=Object.getOwnPropertyNames;var ct=Object.getPrototypeOf,lt=Object.prototype.hasOwnProperty;var O=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var ft=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ut(e))!lt.call(s,n)&&n!==t&&je(s,n,{get:()=>e[n],enumerable:!(r=dt(e,n))||r.enumerable});return s};var ht=(s,e,t)=>(t=s!=null?ot(ct(s)):{},ft(e||!s||!s.__esModule?je(t,"default",{value:s,enumerable:!0}):t,s));var fe=O(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.getParsedType=T.ZodParsedType=T.objectUtil=T.util=void 0;var ke;(function(s){s.assertEqual=n=>{};function e(n){}s.assertIs=e;function t(n){throw new Error}s.assertNever=t,s.arrayToEnum=n=>{let a={};for(let d of n)a[d]=d;return a},s.getValidEnumValues=n=>{let a=s.objectKeys(n).filter(u=>typeof n[n[u]]!="number"),d={};for(let u of a)d[u]=n[u];return s.objectValues(d)},s.objectValues=n=>s.objectKeys(n).map(function(a){return n[a]}),s.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let a=[];for(let d in n)Object.prototype.hasOwnProperty.call(n,d)&&a.push(d);return a},s.find=(n,a)=>{for(let d of n)if(a(d))return d},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(d=>typeof d=="string"?`'${d}'`:d).join(a)}s.joinValues=r,s.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(ke||(T.util=ke={}));var Le;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(Le||(T.objectUtil=Le={}));T.ZodParsedType=ke.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);var pt=s=>{switch(typeof s){case"undefined":return T.ZodParsedType.undefined;case"string":return T.ZodParsedType.string;case"number":return Number.isNaN(s)?T.ZodParsedType.nan:T.ZodParsedType.number;case"boolean":return T.ZodParsedType.boolean;case"function":return T.ZodParsedType.function;case"bigint":return T.ZodParsedType.bigint;case"symbol":return T.ZodParsedType.symbol;case"object":return Array.isArray(s)?T.ZodParsedType.array:s===null?T.ZodParsedType.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?T.ZodParsedType.promise:typeof Map<"u"&&s instanceof Map?T.ZodParsedType.map:typeof Set<"u"&&s instanceof Set?T.ZodParsedType.set:typeof Date<"u"&&s instanceof Date?T.ZodParsedType.date:T.ZodParsedType.object;default:return T.ZodParsedType.unknown}};T.getParsedType=pt});var ye=O(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.ZodError=U.quotelessJson=U.ZodIssueCode=void 0;var Re=fe();U.ZodIssueCode=Re.util.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"]);var mt=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:");U.quotelessJson=mt;var he=class s 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]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(a){return a.message},r={_errors:[]},n=a=>{for(let d of a.issues)if(d.code==="invalid_union")d.unionErrors.map(n);else if(d.code==="invalid_return_type")n(d.returnTypeError);else if(d.code==="invalid_arguments")n(d.argumentsError);else if(d.path.length===0)r._errors.push(t(d));else{let u=r,l=0;for(;l<d.path.length;){let h=d.path[l];l===d.path.length-1?(u[h]=u[h]||{_errors:[]},u[h]._errors.push(t(d))):u[h]=u[h]||{_errors:[]},u=u[h],l++}}};return n(this),r}static assert(e){if(!(e instanceof s))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Re.util.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},r=[];for(let n of this.issues)if(n.path.length>0){let 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()}};U.ZodError=he;he.create=s=>new he(s)});var Ce=O(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});var b=ye(),q=fe(),yt=(s,e)=>{let t;switch(s.code){case b.ZodIssueCode.invalid_type:s.received===q.ZodParsedType.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case b.ZodIssueCode.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,q.util.jsonStringifyReplacer)}`;break;case b.ZodIssueCode.unrecognized_keys:t=`Unrecognized key(s) in object: ${q.util.joinValues(s.keys,", ")}`;break;case b.ZodIssueCode.invalid_union:t="Invalid input";break;case b.ZodIssueCode.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${q.util.joinValues(s.options)}`;break;case b.ZodIssueCode.invalid_enum_value:t=`Invalid enum value. Expected ${q.util.joinValues(s.options)}, received '${s.received}'`;break;case b.ZodIssueCode.invalid_arguments:t="Invalid function arguments";break;case b.ZodIssueCode.invalid_return_type:t="Invalid function return type";break;case b.ZodIssueCode.invalid_date:t="Invalid date";break;case b.ZodIssueCode.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}"`:q.util.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case b.ZodIssueCode.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 b.ZodIssueCode.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 b.ZodIssueCode.custom:t="Invalid input";break;case b.ZodIssueCode.invalid_intersection_types:t="Intersection results could not be merged";break;case b.ZodIssueCode.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case b.ZodIssueCode.not_finite:t="Number must be finite";break;default:t=e.defaultError,q.util.assertNever(s)}return{message:t}};Ze.default=yt});var _e=O(V=>{"use strict";var _t=V&&V.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(V,"__esModule",{value:!0});V.defaultErrorMap=void 0;V.setErrorMap=gt;V.getErrorMap=vt;var De=_t(Ce());V.defaultErrorMap=De.default;var Ue=De.default;function gt(s){Ue=s}function vt(){return Ue}});var Ae=O(x=>{"use strict";var It=x&&x.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(x,"__esModule",{value:!0});x.isAsync=x.isValid=x.isDirty=x.isAborted=x.OK=x.DIRTY=x.INVALID=x.ParseStatus=x.EMPTY_PATH=x.makeIssue=void 0;x.addIssueToContext=bt;var xt=_e(),Ve=It(Ce()),Tt=s=>{let{data:e,path:t,errorMaps:r,issueData:n}=s,a=[...t,...n.path||[]],d={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let u="",l=r.filter(h=>!!h).slice().reverse();for(let h of l)u=h(d,{data:e,defaultError:u}).message;return{...n,path:a,message:u}};x.makeIssue=Tt;x.EMPTY_PATH=[];function bt(s,e){let t=(0,xt.getErrorMap)(),r=(0,x.makeIssue)({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,t,t===Ve.default?void 0:Ve.default].filter(n=>!!n)});s.common.issues.push(r)}var we=class s{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let r=[];for(let n of t){if(n.status==="aborted")return x.INVALID;n.status==="dirty"&&e.dirty(),r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let n of t){let a=await n.key,d=await n.value;r.push({key:a,value:d})}return s.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let n of t){let{key:a,value:d}=n;if(a.status==="aborted"||d.status==="aborted")return x.INVALID;a.status==="dirty"&&e.dirty(),d.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof d.value<"u"||n.alwaysSet)&&(r[a.value]=d.value)}return{status:e.value,value:r}}};x.ParseStatus=we;x.INVALID=Object.freeze({status:"aborted"});var kt=s=>({status:"dirty",value:s});x.DIRTY=kt;var Zt=s=>({status:"valid",value:s});x.OK=Zt;var Ct=s=>s.status==="aborted";x.isAborted=Ct;var wt=s=>s.status==="dirty";x.isDirty=wt;var At=s=>s.status==="valid";x.isValid=At;var Pt=s=>typeof Promise<"u"&&s instanceof Promise;x.isAsync=Pt});var ze=O(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0})});var qe=O(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.errorUtil=void 0;var $e;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e?.message})($e||(ge.errorUtil=$e={}))});var tt=O(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});i.discriminatedUnion=i.date=i.boolean=i.bigint=i.array=i.any=i.coerce=i.ZodFirstPartyTypeKind=i.late=i.ZodSchema=i.Schema=i.ZodReadonly=i.ZodPipeline=i.ZodBranded=i.BRAND=i.ZodNaN=i.ZodCatch=i.ZodDefault=i.ZodNullable=i.ZodOptional=i.ZodTransformer=i.ZodEffects=i.ZodPromise=i.ZodNativeEnum=i.ZodEnum=i.ZodLiteral=i.ZodLazy=i.ZodFunction=i.ZodSet=i.ZodMap=i.ZodRecord=i.ZodTuple=i.ZodIntersection=i.ZodDiscriminatedUnion=i.ZodUnion=i.ZodObject=i.ZodArray=i.ZodVoid=i.ZodNever=i.ZodUnknown=i.ZodAny=i.ZodNull=i.ZodUndefined=i.ZodSymbol=i.ZodDate=i.ZodBoolean=i.ZodBigInt=i.ZodNumber=i.ZodString=i.ZodType=void 0;i.NEVER=i.void=i.unknown=i.union=i.undefined=i.tuple=i.transformer=i.symbol=i.string=i.strictObject=i.set=i.record=i.promise=i.preprocess=i.pipeline=i.ostring=i.optional=i.onumber=i.oboolean=i.object=i.number=i.nullable=i.null=i.never=i.nativeEnum=i.nan=i.map=i.literal=i.lazy=i.intersection=i.instanceof=i.function=i.enum=i.effect=void 0;i.datetimeRegex=Ye;i.custom=Ge;var c=ye(),ve=_e(),p=qe(),o=Ae(),f=fe(),P=class{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}},Be=(s,e)=>{if((0,o.isValid)(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;let t=new c.ZodError(s.common.issues);return this._error=t,this._error}}};function _(s){if(!s)return{};let{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:(d,u)=>{let{message:l}=s;return d.code==="invalid_enum_value"?{message:l??u.defaultError}:typeof u.data>"u"?{message:l??r??u.defaultError}:d.code!=="invalid_type"?{message:u.defaultError}:{message:l??t??u.defaultError}},description:n}}var g=class{get description(){return this._def.description}_getType(e){return(0,f.getParsedType)(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:(0,f.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new o.ParseStatus,ctx:{common:e.parent.common,data:e.data,parsedType:(0,f.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if((0,o.isAsync)(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){let r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,f.getParsedType)(e)},n=this._parseSync({data:e,path:r.path,parent:r});return Be(r,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,f.getParsedType)(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return(0,o.isValid)(r)?{value:r.value}:{issues:t.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(r=>(0,o.isValid)(r)?{value:r.value}:{issues:t.common.issues})}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,f.getParsedType)(e)},n=this._parse({data:e,path:r.path,parent:r}),a=await((0,o.isAsync)(n)?n:Promise.resolve(n));return Be(r,a)}refine(e,t){let r=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{let d=e(n),u=()=>a.addIssue({code:c.ZodIssueCode.custom,...r(n)});return typeof Promise<"u"&&d instanceof Promise?d.then(l=>l?!0:(u(),!1)):d?!0:(u(),!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 C({schema:this,typeName:m.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 A.create(this,this._def)}nullable(){return j.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return D.create(this)}promise(){return $.create(this,this._def)}or(e){return G.create([this,e],this._def)}and(e){return J.create(this,e,this._def)}transform(e){return new C({..._(this._def),schema:this,typeName:m.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new se({..._(this._def),innerType:this,defaultValue:t,typeName:m.ZodDefault})}brand(){return new pe({typeName:m.ZodBranded,type:this,..._(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new re({..._(this._def),innerType:this,catchValue:t,typeName:m.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return me.create(this,e)}readonly(){return ne.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};i.ZodType=g;i.Schema=g;i.ZodSchema=g;var St=/^c[^\s-]{8,}$/i,Ot=/^[0-9a-z]+$/,Nt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Et=/^[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,jt=/^[a-z0-9_-]{21}$/i,Lt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Rt=/^[-+]?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)?)??$/,Dt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ut="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Pe,Vt=/^(?:(?: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])$/,Mt=/^(?:(?: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])$/,zt=/^(([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]))$/,$t=/^(([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])$/,qt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Bt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ke="((\\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])))",Ft=new RegExp(`^${Ke}$`);function We(s){let e="[0-5]\\d";s.precision?e=`${e}\\.\\d{${s.precision}}`:s.precision==null&&(e=`${e}(\\.\\d+)?`);let t=s.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function Kt(s){return new RegExp(`^${We(s)}$`)}function Ye(s){let e=`${Ke}T${We(s)}`,t=[];return t.push(s.local?"Z?":"Z"),s.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Wt(s,e){return!!((e==="v4"||!e)&&Vt.test(s)||(e==="v6"||!e)&&zt.test(s))}function Yt(s,e){if(!Lt.test(s))return!1;try{let[t]=s.split(".");if(!t)return!1;let 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?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function Ht(s,e){return!!((e==="v4"||!e)&&Mt.test(s)||(e==="v6"||!e)&&$t.test(s))}var M=class s extends g{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.ZodParsedType.string){let a=this._getOrReturnCtx(e);return(0,o.addIssueToContext)(a,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.string,received:a.parsedType}),o.INVALID}let r=new o.ParseStatus,n;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{code:c.ZodIssueCode.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),(0,o.addIssueToContext)(n,{code:c.ZodIssueCode.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){let d=e.data.length>a.value,u=e.data.length<a.value;(d||u)&&(n=this._getOrReturnCtx(e,n),d?(0,o.addIssueToContext)(n,{code:c.ZodIssueCode.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):u&&(0,o.addIssueToContext)(n,{code:c.ZodIssueCode.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")Dt.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{validation:"email",code:c.ZodIssueCode.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")Pe||(Pe=new RegExp(Ut,"u")),Pe.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{validation:"emoji",code:c.ZodIssueCode.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")Et.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{validation:"uuid",code:c.ZodIssueCode.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")jt.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{validation:"nanoid",code:c.ZodIssueCode.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")St.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{validation:"cuid",code:c.ZodIssueCode.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")Ot.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{validation:"cuid2",code:c.ZodIssueCode.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")Nt.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{validation:"ulid",code:c.ZodIssueCode.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{validation:"url",code:c.ZodIssueCode.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),(0,o.addIssueToContext)(n,{validation:"regex",code:c.ZodIssueCode.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),(0,o.addIssueToContext)(n,{code:c.ZodIssueCode.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),(0,o.addIssueToContext)(n,{code:c.ZodIssueCode.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{code:c.ZodIssueCode.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?Ye(a).test(e.data)||(n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{code:c.ZodIssueCode.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?Ft.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{code:c.ZodIssueCode.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?Kt(a).test(e.data)||(n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{code:c.ZodIssueCode.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?Rt.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{validation:"duration",code:c.ZodIssueCode.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?Wt(e.data,a.version)||(n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{validation:"ip",code:c.ZodIssueCode.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?Yt(e.data,a.alg)||(n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{validation:"jwt",code:c.ZodIssueCode.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?Ht(e.data,a.version)||(n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{validation:"cidr",code:c.ZodIssueCode.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?qt.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{validation:"base64",code:c.ZodIssueCode.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?Bt.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{validation:"base64url",code:c.ZodIssueCode.invalid_string,message:a.message}),r.dirty()):f.util.assertNever(a);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(n=>e.test(n),{validation:t,code:c.ZodIssueCode.invalid_string,...p.errorUtil.errToObj(r)})}_addCheck(e){return new s({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errorUtil.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errorUtil.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errorUtil.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errorUtil.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errorUtil.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errorUtil.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errorUtil.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errorUtil.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errorUtil.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errorUtil.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errorUtil.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errorUtil.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.errorUtil.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...p.errorUtil.errToObj(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({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...p.errorUtil.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...p.errorUtil.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...p.errorUtil.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...p.errorUtil.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...p.errorUtil.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...p.errorUtil.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...p.errorUtil.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...p.errorUtil.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...p.errorUtil.errToObj(t)})}nonempty(e){return this.min(1,p.errorUtil.errToObj(e))}trim(){return new s({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new s({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new s({...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(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};i.ZodString=M;M.create=s=>new M({checks:[],typeName:m.ZodString,coerce:s?.coerce??!1,..._(s)});function Gt(s,e){let t=(s.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,n=t>r?t:r,a=Number.parseInt(s.toFixed(n).replace(".","")),d=Number.parseInt(e.toFixed(n).replace(".",""));return a%d/10**n}var B=class s extends g{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)!==f.ZodParsedType.number){let a=this._getOrReturnCtx(e);return(0,o.addIssueToContext)(a,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.number,received:a.parsedType}),o.INVALID}let r,n=new o.ParseStatus;for(let a of this._def.checks)a.kind==="int"?f.util.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),(0,o.addIssueToContext)(r,{code:c.ZodIssueCode.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),(0,o.addIssueToContext)(r,{code:c.ZodIssueCode.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),(0,o.addIssueToContext)(r,{code:c.ZodIssueCode.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?Gt(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),(0,o.addIssueToContext)(r,{code:c.ZodIssueCode.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),(0,o.addIssueToContext)(r,{code:c.ZodIssueCode.not_finite,message:a.message}),n.dirty()):f.util.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,p.errorUtil.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.errorUtil.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.errorUtil.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.errorUtil.toString(t))}setLimit(e,t,r,n){return new s({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:p.errorUtil.toString(n)}]})}_addCheck(e){return new s({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.errorUtil.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.errorUtil.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.errorUtil.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:p.errorUtil.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.errorUtil.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.errorUtil.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let 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"&&f.util.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let 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)}};i.ZodNumber=B;B.create=s=>new B({checks:[],typeName:m.ZodNumber,coerce:s?.coerce||!1,..._(s)});var F=class s extends g{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==f.ZodParsedType.bigint)return this._getInvalidInput(e);let r,n=new o.ParseStatus;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),(0,o.addIssueToContext)(r,{code:c.ZodIssueCode.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),(0,o.addIssueToContext)(r,{code:c.ZodIssueCode.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),(0,o.addIssueToContext)(r,{code:c.ZodIssueCode.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):f.util.assertNever(a);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return(0,o.addIssueToContext)(t,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.bigint,received:t.parsedType}),o.INVALID}gte(e,t){return this.setLimit("min",e,!0,p.errorUtil.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.errorUtil.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.errorUtil.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.errorUtil.toString(t))}setLimit(e,t,r,n){return new s({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:p.errorUtil.toString(n)}]})}_addCheck(e){return new s({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.errorUtil.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.errorUtil.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};i.ZodBigInt=F;F.create=s=>new F({checks:[],typeName:m.ZodBigInt,coerce:s?.coerce??!1,..._(s)});var K=class extends g{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.ZodParsedType.boolean){let r=this._getOrReturnCtx(e);return(0,o.addIssueToContext)(r,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.boolean,received:r.parsedType}),o.INVALID}return(0,o.OK)(e.data)}};i.ZodBoolean=K;K.create=s=>new K({typeName:m.ZodBoolean,coerce:s?.coerce||!1,..._(s)});var W=class s extends g{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.ZodParsedType.date){let a=this._getOrReturnCtx(e);return(0,o.addIssueToContext)(a,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.date,received:a.parsedType}),o.INVALID}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return(0,o.addIssueToContext)(a,{code:c.ZodIssueCode.invalid_date}),o.INVALID}let r=new o.ParseStatus,n;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),(0,o.addIssueToContext)(n,{code:c.ZodIssueCode.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),(0,o.addIssueToContext)(n,{code:c.ZodIssueCode.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):f.util.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new s({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:p.errorUtil.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:p.errorUtil.toString(t)})}get minDate(){let e=null;for(let 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(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};i.ZodDate=W;W.create=s=>new W({checks:[],coerce:s?.coerce||!1,typeName:m.ZodDate,..._(s)});var ie=class extends g{_parse(e){if(this._getType(e)!==f.ZodParsedType.symbol){let r=this._getOrReturnCtx(e);return(0,o.addIssueToContext)(r,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.symbol,received:r.parsedType}),o.INVALID}return(0,o.OK)(e.data)}};i.ZodSymbol=ie;ie.create=s=>new ie({typeName:m.ZodSymbol,..._(s)});var Y=class extends g{_parse(e){if(this._getType(e)!==f.ZodParsedType.undefined){let r=this._getOrReturnCtx(e);return(0,o.addIssueToContext)(r,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.undefined,received:r.parsedType}),o.INVALID}return(0,o.OK)(e.data)}};i.ZodUndefined=Y;Y.create=s=>new Y({typeName:m.ZodUndefined,..._(s)});var H=class extends g{_parse(e){if(this._getType(e)!==f.ZodParsedType.null){let r=this._getOrReturnCtx(e);return(0,o.addIssueToContext)(r,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.null,received:r.parsedType}),o.INVALID}return(0,o.OK)(e.data)}};i.ZodNull=H;H.create=s=>new H({typeName:m.ZodNull,..._(s)});var z=class extends g{constructor(){super(...arguments),this._any=!0}_parse(e){return(0,o.OK)(e.data)}};i.ZodAny=z;z.create=s=>new z({typeName:m.ZodAny,..._(s)});var R=class extends g{constructor(){super(...arguments),this._unknown=!0}_parse(e){return(0,o.OK)(e.data)}};i.ZodUnknown=R;R.create=s=>new R({typeName:m.ZodUnknown,..._(s)});var N=class extends g{_parse(e){let t=this._getOrReturnCtx(e);return(0,o.addIssueToContext)(t,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.never,received:t.parsedType}),o.INVALID}};i.ZodNever=N;N.create=s=>new N({typeName:m.ZodNever,..._(s)});var oe=class extends g{_parse(e){if(this._getType(e)!==f.ZodParsedType.undefined){let r=this._getOrReturnCtx(e);return(0,o.addIssueToContext)(r,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.void,received:r.parsedType}),o.INVALID}return(0,o.OK)(e.data)}};i.ZodVoid=oe;oe.create=s=>new oe({typeName:m.ZodVoid,..._(s)});var D=class s extends g{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==f.ZodParsedType.array)return(0,o.addIssueToContext)(t,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.array,received:t.parsedType}),o.INVALID;if(n.exactLength!==null){let d=t.data.length>n.exactLength.value,u=t.data.length<n.exactLength.value;(d||u)&&((0,o.addIssueToContext)(t,{code:d?c.ZodIssueCode.too_big:c.ZodIssueCode.too_small,minimum:u?n.exactLength.value:void 0,maximum:d?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&&((0,o.addIssueToContext)(t,{code:c.ZodIssueCode.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&&((0,o.addIssueToContext)(t,{code:c.ZodIssueCode.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((d,u)=>n.type._parseAsync(new P(t,d,t.path,u)))).then(d=>o.ParseStatus.mergeArray(r,d));let a=[...t.data].map((d,u)=>n.type._parseSync(new P(t,d,t.path,u)));return o.ParseStatus.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new s({...this._def,minLength:{value:e,message:p.errorUtil.toString(t)}})}max(e,t){return new s({...this._def,maxLength:{value:e,message:p.errorUtil.toString(t)}})}length(e,t){return new s({...this._def,exactLength:{value:e,message:p.errorUtil.toString(t)}})}nonempty(e){return this.min(1,e)}};i.ZodArray=D;D.create=(s,e)=>new D({type:s,minLength:null,maxLength:null,exactLength:null,typeName:m.ZodArray,..._(e)});function ae(s){if(s instanceof k){let e={};for(let t in s.shape){let r=s.shape[t];e[t]=A.create(ae(r))}return new k({...s._def,shape:()=>e})}else return s instanceof D?new D({...s._def,type:ae(s.element)}):s instanceof A?A.create(ae(s.unwrap())):s instanceof j?j.create(ae(s.unwrap())):s instanceof E?E.create(s.items.map(e=>ae(e))):s}var k=class s extends g{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=f.util.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==f.ZodParsedType.object){let h=this._getOrReturnCtx(e);return(0,o.addIssueToContext)(h,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.object,received:h.parsedType}),o.INVALID}let{status:r,ctx:n}=this._processInputParams(e),{shape:a,keys:d}=this._getCached(),u=[];if(!(this._def.catchall instanceof N&&this._def.unknownKeys==="strip"))for(let h in n.data)d.includes(h)||u.push(h);let l=[];for(let h of d){let v=a[h],w=n.data[h];l.push({key:{status:"valid",value:h},value:v._parse(new P(n,w,n.path,h)),alwaysSet:h in n.data})}if(this._def.catchall instanceof N){let h=this._def.unknownKeys;if(h==="passthrough")for(let v of u)l.push({key:{status:"valid",value:v},value:{status:"valid",value:n.data[v]}});else if(h==="strict")u.length>0&&((0,o.addIssueToContext)(n,{code:c.ZodIssueCode.unrecognized_keys,keys:u}),r.dirty());else if(h!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let h=this._def.catchall;for(let v of u){let w=n.data[v];l.push({key:{status:"valid",value:v},value:h._parse(new P(n,w,n.path,v)),alwaysSet:v in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let h=[];for(let v of l){let w=await v.key,Ee=await v.value;h.push({key:w,value:Ee,alwaysSet:v.alwaysSet})}return h}).then(h=>o.ParseStatus.mergeObjectSync(r,h)):o.ParseStatus.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return p.errorUtil.errToObj,new s({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{let n=this._def.errorMap?.(t,r).message??r.defaultError;return t.code==="unrecognized_keys"?{message:p.errorUtil.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new s({...this._def,unknownKeys:"strip"})}passthrough(){return new s({...this._def,unknownKeys:"passthrough"})}extend(e){return new s({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new s({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:m.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new s({...this._def,catchall:e})}pick(e){let t={};for(let r of f.util.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new s({...this._def,shape:()=>t})}omit(e){let t={};for(let r of f.util.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new s({...this._def,shape:()=>t})}deepPartial(){return ae(this)}partial(e){let t={};for(let r of f.util.objectKeys(this.shape)){let n=this.shape[r];e&&!e[r]?t[r]=n:t[r]=n.optional()}return new s({...this._def,shape:()=>t})}required(e){let t={};for(let r of f.util.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof A;)a=a._def.innerType;t[r]=a}return new s({...this._def,shape:()=>t})}keyof(){return He(f.util.objectKeys(this.shape))}};i.ZodObject=k;k.create=(s,e)=>new k({shape:()=>s,unknownKeys:"strip",catchall:N.create(),typeName:m.ZodObject,..._(e)});k.strictCreate=(s,e)=>new k({shape:()=>s,unknownKeys:"strict",catchall:N.create(),typeName:m.ZodObject,..._(e)});k.lazycreate=(s,e)=>new k({shape:s,unknownKeys:"strip",catchall:N.create(),typeName:m.ZodObject,..._(e)});var G=class extends g{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;function n(a){for(let u of a)if(u.result.status==="valid")return u.result;for(let u of a)if(u.result.status==="dirty")return t.common.issues.push(...u.ctx.common.issues),u.result;let d=a.map(u=>new c.ZodError(u.ctx.common.issues));return(0,o.addIssueToContext)(t,{code:c.ZodIssueCode.invalid_union,unionErrors:d}),o.INVALID}if(t.common.async)return Promise.all(r.map(async a=>{let d={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:d}),ctx:d}})).then(n);{let a,d=[];for(let l of r){let h={...t,common:{...t.common,issues:[]},parent:null},v=l._parseSync({data:t.data,path:t.path,parent:h});if(v.status==="valid")return v;v.status==="dirty"&&!a&&(a={result:v,ctx:h}),h.common.issues.length&&d.push(h.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let u=d.map(l=>new c.ZodError(l));return(0,o.addIssueToContext)(t,{code:c.ZodIssueCode.invalid_union,unionErrors:u}),o.INVALID}}get options(){return this._def.options}};i.ZodUnion=G;G.create=(s,e)=>new G({options:s,typeName:m.ZodUnion,..._(e)});var L=s=>s instanceof Q?L(s.schema):s instanceof C?L(s.innerType()):s instanceof X?[s.value]:s instanceof ee?s.options:s instanceof te?f.util.objectValues(s.enum):s instanceof se?L(s._def.innerType):s instanceof Y?[void 0]:s instanceof H?[null]:s instanceof A?[void 0,...L(s.unwrap())]:s instanceof j?[null,...L(s.unwrap())]:s instanceof pe||s instanceof ne?L(s.unwrap()):s instanceof re?L(s._def.innerType):[],Ie=class s extends g{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.ZodParsedType.object)return(0,o.addIssueToContext)(t,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.object,received:t.parsedType}),o.INVALID;let r=this.discriminator,n=t.data[r],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}):((0,o.addIssueToContext)(t,{code:c.ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),o.INVALID)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let n=new Map;for(let a of t){let d=L(a.shape[e]);if(!d.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let u of d){if(n.has(u))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(u)}`);n.set(u,a)}}return new s({typeName:m.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,..._(r)})}};i.ZodDiscriminatedUnion=Ie;function Se(s,e){let t=(0,f.getParsedType)(s),r=(0,f.getParsedType)(e);if(s===e)return{valid:!0,data:s};if(t===f.ZodParsedType.object&&r===f.ZodParsedType.object){let n=f.util.objectKeys(e),a=f.util.objectKeys(s).filter(u=>n.indexOf(u)!==-1),d={...s,...e};for(let u of a){let l=Se(s[u],e[u]);if(!l.valid)return{valid:!1};d[u]=l.data}return{valid:!0,data:d}}else if(t===f.ZodParsedType.array&&r===f.ZodParsedType.array){if(s.length!==e.length)return{valid:!1};let n=[];for(let a=0;a<s.length;a++){let d=s[a],u=e[a],l=Se(d,u);if(!l.valid)return{valid:!1};n.push(l.data)}return{valid:!0,data:n}}else return t===f.ZodParsedType.date&&r===f.ZodParsedType.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}var J=class extends g{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=(a,d)=>{if((0,o.isAborted)(a)||(0,o.isAborted)(d))return o.INVALID;let u=Se(a.value,d.value);return u.valid?(((0,o.isDirty)(a)||(0,o.isDirty)(d))&&t.dirty(),{status:t.value,value:u.data}):((0,o.addIssueToContext)(r,{code:c.ZodIssueCode.invalid_intersection_types}),o.INVALID)};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,d])=>n(a,d)):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}))}};i.ZodIntersection=J;J.create=(s,e,t)=>new J({left:s,right:e,typeName:m.ZodIntersection,..._(t)});var E=class s extends g{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.ZodParsedType.array)return(0,o.addIssueToContext)(r,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.array,received:r.parsedType}),o.INVALID;if(r.data.length<this._def.items.length)return(0,o.addIssueToContext)(r,{code:c.ZodIssueCode.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),o.INVALID;!this._def.rest&&r.data.length>this._def.items.length&&((0,o.addIssueToContext)(r,{code:c.ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...r.data].map((d,u)=>{let l=this._def.items[u]||this._def.rest;return l?l._parse(new P(r,d,r.path,u)):null}).filter(d=>!!d);return r.common.async?Promise.all(a).then(d=>o.ParseStatus.mergeArray(t,d)):o.ParseStatus.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new s({...this._def,rest:e})}};i.ZodTuple=E;E.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new E({items:s,typeName:m.ZodTuple,rest:null,..._(e)})};var xe=class s extends g{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.ZodParsedType.object)return(0,o.addIssueToContext)(r,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.object,received:r.parsedType}),o.INVALID;let n=[],a=this._def.keyType,d=this._def.valueType;for(let u in r.data)n.push({key:a._parse(new P(r,u,r.path,u)),value:d._parse(new P(r,r.data[u],r.path,u)),alwaysSet:u in r.data});return r.common.async?o.ParseStatus.mergeObjectAsync(t,n):o.ParseStatus.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof g?new s({keyType:e,valueType:t,typeName:m.ZodRecord,..._(r)}):new s({keyType:M.create(),valueType:e,typeName:m.ZodRecord,..._(t)})}};i.ZodRecord=xe;var de=class extends g{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.ZodParsedType.map)return(0,o.addIssueToContext)(r,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.map,received:r.parsedType}),o.INVALID;let n=this._def.keyType,a=this._def.valueType,d=[...r.data.entries()].map(([u,l],h)=>({key:n._parse(new P(r,u,r.path,[h,"key"])),value:a._parse(new P(r,l,r.path,[h,"value"]))}));if(r.common.async){let u=new Map;return Promise.resolve().then(async()=>{for(let l of d){let h=await l.key,v=await l.value;if(h.status==="aborted"||v.status==="aborted")return o.INVALID;(h.status==="dirty"||v.status==="dirty")&&t.dirty(),u.set(h.value,v.value)}return{status:t.value,value:u}})}else{let u=new Map;for(let l of d){let h=l.key,v=l.value;if(h.status==="aborted"||v.status==="aborted")return o.INVALID;(h.status==="dirty"||v.status==="dirty")&&t.dirty(),u.set(h.value,v.value)}return{status:t.value,value:u}}}};i.ZodMap=de;de.create=(s,e,t)=>new de({valueType:e,keyType:s,typeName:m.ZodMap,..._(t)});var ue=class s extends g{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.ZodParsedType.set)return(0,o.addIssueToContext)(r,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.set,received:r.parsedType}),o.INVALID;let n=this._def;n.minSize!==null&&r.data.size<n.minSize.value&&((0,o.addIssueToContext)(r,{code:c.ZodIssueCode.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&&((0,o.addIssueToContext)(r,{code:c.ZodIssueCode.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let a=this._def.valueType;function d(l){let h=new Set;for(let v of l){if(v.status==="aborted")return o.INVALID;v.status==="dirty"&&t.dirty(),h.add(v.value)}return{status:t.value,value:h}}let u=[...r.data.values()].map((l,h)=>a._parse(new P(r,l,r.path,h)));return r.common.async?Promise.all(u).then(l=>d(l)):d(u)}min(e,t){return new s({...this._def,minSize:{value:e,message:p.errorUtil.toString(t)}})}max(e,t){return new s({...this._def,maxSize:{value:e,message:p.errorUtil.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};i.ZodSet=ue;ue.create=(s,e)=>new ue({valueType:s,minSize:null,maxSize:null,typeName:m.ZodSet,..._(e)});var Te=class s extends g{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.ZodParsedType.function)return(0,o.addIssueToContext)(t,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.function,received:t.parsedType}),o.INVALID;function r(u,l){return(0,o.makeIssue)({data:u,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,(0,ve.getErrorMap)(),ve.defaultErrorMap].filter(h=>!!h),issueData:{code:c.ZodIssueCode.invalid_arguments,argumentsError:l}})}function n(u,l){return(0,o.makeIssue)({data:u,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,(0,ve.getErrorMap)(),ve.defaultErrorMap].filter(h=>!!h),issueData:{code:c.ZodIssueCode.invalid_return_type,returnTypeError:l}})}let a={errorMap:t.common.contextualErrorMap},d=t.data;if(this._def.returns instanceof $){let u=this;return(0,o.OK)(async function(...l){let h=new c.ZodError([]),v=await u._def.args.parseAsync(l,a).catch(be=>{throw h.addIssue(r(l,be)),h}),w=await Reflect.apply(d,this,v);return await u._def.returns._def.type.parseAsync(w,a).catch(be=>{throw h.addIssue(n(w,be)),h})})}else{let u=this;return(0,o.OK)(function(...l){let h=u._def.args.safeParse(l,a);if(!h.success)throw new c.ZodError([r(l,h.error)]);let v=Reflect.apply(d,this,h.data),w=u._def.returns.safeParse(v,a);if(!w.success)throw new c.ZodError([n(v,w.error)]);return w.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new s({...this._def,args:E.create(e).rest(R.create())})}returns(e){return new s({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new s({args:e||E.create([]).rest(R.create()),returns:t||R.create(),typeName:m.ZodFunction,..._(r)})}};i.ZodFunction=Te;var Q=class extends g{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};i.ZodLazy=Q;Q.create=(s,e)=>new Q({getter:s,typeName:m.ZodLazy,..._(e)});var X=class extends g{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return(0,o.addIssueToContext)(t,{received:t.data,code:c.ZodIssueCode.invalid_literal,expected:this._def.value}),o.INVALID}return{status:"valid",value:e.data}}get value(){return this._def.value}};i.ZodLiteral=X;X.create=(s,e)=>new X({value:s,typeName:m.ZodLiteral,..._(e)});function He(s,e){return new ee({values:s,typeName:m.ZodEnum,..._(e)})}var ee=class s extends g{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),r=this._def.values;return(0,o.addIssueToContext)(t,{expected:f.util.joinValues(r),received:t.parsedType,code:c.ZodIssueCode.invalid_type}),o.INVALID}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return(0,o.addIssueToContext)(t,{received:t.data,code:c.ZodIssueCode.invalid_enum_value,options:r}),o.INVALID}return(0,o.OK)(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return s.create(e,{...this._def,...t})}exclude(e,t=this._def){return s.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}};i.ZodEnum=ee;ee.create=He;var te=class extends g{_parse(e){let t=f.util.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==f.ZodParsedType.string&&r.parsedType!==f.ZodParsedType.number){let n=f.util.objectValues(t);return(0,o.addIssueToContext)(r,{expected:f.util.joinValues(n),received:r.parsedType,code:c.ZodIssueCode.invalid_type}),o.INVALID}if(this._cache||(this._cache=new Set(f.util.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let n=f.util.objectValues(t);return(0,o.addIssueToContext)(r,{received:r.data,code:c.ZodIssueCode.invalid_enum_value,options:n}),o.INVALID}return(0,o.OK)(e.data)}get enum(){return this._def.values}};i.ZodNativeEnum=te;te.create=(s,e)=>new te({values:s,typeName:m.ZodNativeEnum,..._(e)});var $=class extends g{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.ZodParsedType.promise&&t.common.async===!1)return(0,o.addIssueToContext)(t,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.promise,received:t.parsedType}),o.INVALID;let r=t.parsedType===f.ZodParsedType.promise?t.data:Promise.resolve(t.data);return(0,o.OK)(r.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};i.ZodPromise=$;$.create=(s,e)=>new $({type:s,typeName:m.ZodPromise,..._(e)});var C=class extends g{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===m.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:d=>{(0,o.addIssueToContext)(r,d),d.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){let d=n.transform(r.data,a);if(r.common.async)return Promise.resolve(d).then(async u=>{if(t.value==="aborted")return o.INVALID;let l=await this._def.schema._parseAsync({data:u,path:r.path,parent:r});return l.status==="aborted"?o.INVALID:l.status==="dirty"||t.value==="dirty"?(0,o.DIRTY)(l.value):l});{if(t.value==="aborted")return o.INVALID;let u=this._def.schema._parseSync({data:d,path:r.path,parent:r});return u.status==="aborted"?o.INVALID:u.status==="dirty"||t.value==="dirty"?(0,o.DIRTY)(u.value):u}}if(n.type==="refinement"){let d=u=>{let l=n.refinement(u,a);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return u};if(r.common.async===!1){let u=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return u.status==="aborted"?o.INVALID:(u.status==="dirty"&&t.dirty(),d(u.value),{status:t.value,value:u.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(u=>u.status==="aborted"?o.INVALID:(u.status==="dirty"&&t.dirty(),d(u.value).then(()=>({status:t.value,value:u.value}))))}if(n.type==="transform")if(r.common.async===!1){let d=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!(0,o.isValid)(d))return o.INVALID;let u=n.transform(d.value,a);if(u instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:u}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(d=>(0,o.isValid)(d)?Promise.resolve(n.transform(d.value,a)).then(u=>({status:t.value,value:u})):o.INVALID);f.util.assertNever(n)}};i.ZodEffects=C;i.ZodTransformer=C;C.create=(s,e,t)=>new C({schema:s,typeName:m.ZodEffects,effect:e,..._(t)});C.createWithPreprocess=(s,e,t)=>new C({schema:e,effect:{type:"preprocess",transform:s},typeName:m.ZodEffects,..._(t)});var A=class extends g{_parse(e){return this._getType(e)===f.ZodParsedType.undefined?(0,o.OK)(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};i.ZodOptional=A;A.create=(s,e)=>new A({innerType:s,typeName:m.ZodOptional,..._(e)});var j=class extends g{_parse(e){return this._getType(e)===f.ZodParsedType.null?(0,o.OK)(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};i.ZodNullable=j;j.create=(s,e)=>new j({innerType:s,typeName:m.ZodNullable,..._(e)});var se=class extends g{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===f.ZodParsedType.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};i.ZodDefault=se;se.create=(s,e)=>new se({innerType:s,typeName:m.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});var re=class extends g{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return(0,o.isAsync)(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new c.ZodError(r.common.issues)},input:r.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new c.ZodError(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};i.ZodCatch=re;re.create=(s,e)=>new re({innerType:s,typeName:m.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});var ce=class extends g{_parse(e){if(this._getType(e)!==f.ZodParsedType.nan){let r=this._getOrReturnCtx(e);return(0,o.addIssueToContext)(r,{code:c.ZodIssueCode.invalid_type,expected:f.ZodParsedType.nan,received:r.parsedType}),o.INVALID}return{status:"valid",value:e.data}}};i.ZodNaN=ce;ce.create=s=>new ce({typeName:m.ZodNaN,..._(s)});i.BRAND=Symbol("zod_brand");var pe=class extends g{_parse(e){let{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}};i.ZodBranded=pe;var me=class s extends g{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?o.INVALID:a.status==="dirty"?(t.dirty(),(0,o.DIRTY)(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{let n=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return n.status==="aborted"?o.INVALID: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 s({in:e,out:t,typeName:m.ZodPipeline})}};i.ZodPipeline=me;var ne=class extends g{_parse(e){let t=this._def.innerType._parse(e),r=n=>((0,o.isValid)(n)&&(n.value=Object.freeze(n.value)),n);return(0,o.isAsync)(t)?t.then(n=>r(n)):r(t)}unwrap(){return this._def.innerType}};i.ZodReadonly=ne;ne.create=(s,e)=>new ne({innerType:s,typeName:m.ZodReadonly,..._(e)});function Fe(s,e){let t=typeof s=="function"?s(e):typeof s=="string"?{message:s}:s;return typeof t=="string"?{message:t}:t}function Ge(s,e={},t){return s?z.create().superRefine((r,n)=>{let a=s(r);if(a instanceof Promise)return a.then(d=>{if(!d){let u=Fe(e,r),l=u.fatal??t??!0;n.addIssue({code:"custom",...u,fatal:l})}});if(!a){let d=Fe(e,r),u=d.fatal??t??!0;n.addIssue({code:"custom",...d,fatal:u})}}):z.create()}i.late={object:k.lazycreate};var m;(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"})(m||(i.ZodFirstPartyTypeKind=m={}));var Jt=(s,e={message:`Input not instance of ${s.name}`})=>Ge(t=>t instanceof s,e);i.instanceof=Jt;var Je=M.create;i.string=Je;var Qe=B.create;i.number=Qe;var Qt=ce.create;i.nan=Qt;var Xt=F.create;i.bigint=Xt;var Xe=K.create;i.boolean=Xe;var es=W.create;i.date=es;var ts=ie.create;i.symbol=ts;var ss=Y.create;i.undefined=ss;var rs=H.create;i.null=rs;var ns=z.create;i.any=ns;var as=R.create;i.unknown=as;var is=N.create;i.never=is;var os=oe.create;i.void=os;var ds=D.create;i.array=ds;var us=k.create;i.object=us;var cs=k.strictCreate;i.strictObject=cs;var ls=G.create;i.union=ls;var fs=Ie.create;i.discriminatedUnion=fs;var hs=J.create;i.intersection=hs;var ps=E.create;i.tuple=ps;var ms=xe.create;i.record=ms;var ys=de.create;i.map=ys;var _s=ue.create;i.set=_s;var gs=Te.create;i.function=gs;var vs=Q.create;i.lazy=vs;var Is=X.create;i.literal=Is;var xs=ee.create;i.enum=xs;var Ts=te.create;i.nativeEnum=Ts;var bs=$.create;i.promise=bs;var et=C.create;i.effect=et;i.transformer=et;var ks=A.create;i.optional=ks;var Zs=j.create;i.nullable=Zs;var Cs=C.createWithPreprocess;i.preprocess=Cs;var ws=me.create;i.pipeline=ws;var As=()=>Je().optional();i.ostring=As;var Ps=()=>Qe().optional();i.onumber=Ps;var Ss=()=>Xe().optional();i.oboolean=Ss;i.coerce={string:s=>M.create({...s,coerce:!0}),number:s=>B.create({...s,coerce:!0}),boolean:s=>K.create({...s,coerce:!0}),bigint:s=>F.create({...s,coerce:!0}),date:s=>W.create({...s,coerce:!0})};i.NEVER=o.INVALID});var Oe=O(S=>{"use strict";var Os=S&&S.__createBinding||(Object.create?function(s,e,t,r){r===void 0&&(r=t);var n=Object.getOwnPropertyDescriptor(e,t);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(s,r,n)}:function(s,e,t,r){r===void 0&&(r=t),s[r]=e[t]}),le=S&&S.__exportStar||function(s,e){for(var t in s)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Os(e,s,t)};Object.defineProperty(S,"__esModule",{value:!0});le(_e(),S);le(Ae(),S);le(ze(),S);le(fe(),S);le(tt(),S);le(ye(),S)});var nt=O(Z=>{"use strict";var st=Z&&Z.__createBinding||(Object.create?function(s,e,t,r){r===void 0&&(r=t);var n=Object.getOwnPropertyDescriptor(e,t);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(s,r,n)}:function(s,e,t,r){r===void 0&&(r=t),s[r]=e[t]}),Ns=Z&&Z.__setModuleDefault||(Object.create?function(s,e){Object.defineProperty(s,"default",{enumerable:!0,value:e})}:function(s,e){s.default=e}),Es=Z&&Z.__importStar||function(s){if(s&&s.__esModule)return s;var e={};if(s!=null)for(var t in s)t!=="default"&&Object.prototype.hasOwnProperty.call(s,t)&&st(e,s,t);return Ns(e,s),e},js=Z&&Z.__exportStar||function(s,e){for(var t in s)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&st(e,s,t)};Object.defineProperty(Z,"__esModule",{value:!0});Z.z=void 0;var rt=Es(Oe());Z.z=rt;js(Oe(),Z);Z.default=rt});var at=O(I=>{"use strict";Object.defineProperty(I,"__esModule",{value:!0});I.KernelResponseSchema=I.KernelMessageSchema=I.MessageTypeSchema=I.UrlUpdatePayloadSchema=I.AuthLoginPayloadSchema=I.ScrollDirectionPayloadSchema=I.ScrollDirectionSchema=I.SelectedLocationSchema=I.LocationPickerOptionsSchema=I.AlertPayloadSchema=I.AlertButtonSchema=I.AuthTokenPayloadSchema=I.LocationPayloadSchema=I.UserPayloadSchema=void 0;var y=nt();I.UserPayloadSchema=y.z.object({id:y.z.string(),email:y.z.string().optional(),name:y.z.string().optional(),role:y.z.string().optional(),place_id:y.z.string().nullable().optional()});I.LocationPayloadSchema=y.z.object({city:y.z.string().optional(),country:y.z.string().optional(),coords:y.z.object({lat:y.z.number(),lng:y.z.number()}),latitude:y.z.number().optional(),longitude:y.z.number().optional()});I.AuthTokenPayloadSchema=y.z.object({token:y.z.string()});I.AlertButtonSchema=y.z.object({text:y.z.string().optional(),style:y.z.enum(["default","cancel","destructive"]).optional()});I.AlertPayloadSchema=y.z.object({title:y.z.string(),message:y.z.string().optional(),buttons:y.z.array(I.AlertButtonSchema).optional()});I.LocationPickerOptionsSchema=y.z.object({readonly:y.z.boolean().optional(),lat:y.z.number().optional(),lng:y.z.number().optional()});I.SelectedLocationSchema=y.z.object({lat:y.z.number(),lng:y.z.number()});I.ScrollDirectionSchema=y.z.enum(["up","down"]);I.ScrollDirectionPayloadSchema=y.z.object({direction:I.ScrollDirectionSchema});I.AuthLoginPayloadSchema=y.z.object({intendedView:y.z.string().optional()});I.UrlUpdatePayloadSchema=y.z.object({slug:y.z.string().optional()});I.MessageTypeSchema=y.z.enum(["LOCALE_INIT","GET_USER","GET_LOCATION","GET_AUTH_TOKEN","UI_ALERT","UI_PICK_LOCATION","SCROLL_DIRECTION","AUTH_LOGIN","URL_UPDATE"]);I.KernelMessageSchema=y.z.object({type:y.z.string(),payload:y.z.unknown(),requestId:y.z.number()});I.KernelResponseSchema=y.z.object({type:y.z.literal("LOCALE_RESPONSE"),requestId:y.z.number(),payload:y.z.unknown(),error:y.z.string().nullable().optional()})});var it=ht(at()),Ne=class{constructor(e={}){this._lastScrollY=0;this._lastReportedDirection=null;this._scrollListener=null;this.debugEnabled=!0;this.requestId=0,this.requests=new Map,this.kernelOrigin=e.kernelOrigin||"*",typeof window<"u"&&window.LOCALE_SDK_DEBUG===!0&&(this.debugEnabled=!0),window.addEventListener("message",t=>{if(this.kernelOrigin!=="*"&&t.origin!==this.kernelOrigin)return;let r=t.data,n=it.KernelResponseSchema.safeParse(r);if(!n.success)return;let{type:a,payload:d,requestId:u,error:l}=n.data;if(a==="LOCALE_RESPONSE"&&this.requests.has(u)){let h=this.requests.get(u);if(!h)return;this.requests.delete(u),this._log("Received response:",a,{requestId:u,error:l,payload:d}),l?h.reject(new Error(l)):h.resolve(d)}}),this._send("LOCALE_INIT",{})}_log(...e){this.debugEnabled&&console.log("[Locale SDK]",...e)}_send(e,t){return new Promise((r,n)=>{let a=++this.requestId;this.requests.set(a,{resolve:r,reject:n}),this._log("Sending message:",e,{requestId:a,payload:t});let d={type:e,payload:t,requestId:a};window.parent.postMessage(d,this.kernelOrigin)})}async init(){try{let[e,t,r]=await Promise.all([this.getUser().catch(n=>(this._log("Failed to fetch user:",n),console.warn("[SDK] Failed to fetch user:",n),null)),this.getLocation().catch(n=>(this._log("Failed to fetch location:",n),console.warn("[SDK] Failed to fetch location:",n),null)),this.getAuthToken().catch(n=>(this._log("Failed to fetch auth token:",n),console.warn("[SDK] Failed to fetch auth token:",n),null))]);return{user:e,location:t,token:r?r.token:null}}catch(e){throw console.error("[SDK] Init failed:",e),e}}enableAutoScrollSync(e=50,t=10){this._scrollListener||(this._lastScrollY=0,this._lastReportedDirection=null,this._scrollListener=r=>{let n=r.target;if(!n||typeof n.scrollTop!="number")return;let a=n.scrollTop,d=n.scrollHeight-n.clientHeight;if(a<0||a>d)return;if(a>d-100){this._lastScrollY=a;return}let u=a-this._lastScrollY;if(Math.abs(u)<t){this._lastScrollY=a;return}let l;if(u>0&&a>e)l="down";else if(u<0)l="up";else if(a<=e)l="up";else{this._lastScrollY=a;return}l!==this._lastReportedDirection&&(this._lastReportedDirection=l,this.reportScrollDirection(l)),this._lastScrollY=a},window.addEventListener("scroll",this._scrollListener,{passive:!0,capture:!0}),this._log("Auto-scroll sync enabled"))}async getUser(){return this._send("GET_USER",{})}async getAuthToken(){return this._send("GET_AUTH_TOKEN",{})}async connectSupabase(e){let{token:t}=await this.getAuthToken(),{error:r}=await e.auth.setSession({access_token:t,refresh_token:t});if(r)throw new Error("Failed to connect Supabase with Local\xE9: "+r.message);return{token:t}}async getLocation(){return this._send("GET_LOCATION",{})}async alert(e,t,r,n){let a=r&&r.length>0?r:[{text:"OK",style:"default"}],d=a.map(h=>({text:h.text||"Button",style:h.style||"default"})),u={title:e,message:t,buttons:d},l=await this._send("UI_ALERT",u);if(l!==null&&l>=0&&l<a.length){let h=a[l];h.onPress&&h.onPress()}else n?.onDismiss&&n.onDismiss()}async pickLocation(e){let t=e||{};return this._send("UI_PICK_LOCATION",t)}reportScrollDirection(e){let t={direction:e};this._send("SCROLL_DIRECTION",t)}async login(e){let t={intendedView:e};await this._send("AUTH_LOGIN",t)}async updateUrlPath(e){let t={slug:e};await this._send("URL_UPDATE",t)}};window.LocaleApp=Ne;})();
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@locale-labs/miniapp-sdk",
3
+ "version": "0.1.0",
4
+ "description": "SDK for Localé Mini-Apps - Bridge between Mini-Apps and the Localé Kernel",
5
+ "main": "dist/sdk.js",
6
+ "types": "dist/sdk.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "esbuild src/sdk.ts --bundle --minify --format=iife --target=es2020 --outfile=dist/sdk.js",
12
+ "build:types": "tsc --emitDeclarationOnly --declaration --outDir dist"
13
+ },
14
+ "dependencies": {
15
+ "@locale-labs/protocol": "^0.1.3"
16
+ },
17
+ "devDependencies": {
18
+ "esbuild": "^0.23.0",
19
+ "typescript": "^5.0.0"
20
+ },
21
+ "keywords": [
22
+ "locale",
23
+ "miniapp",
24
+ "sdk",
25
+ "iframe",
26
+ "postmessage"
27
+ ]
28
+ }