@usefillo/dom 0.3.2 → 0.4.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.
@@ -1 +1 @@
1
- "use strict";var Fillo=(()=>{var ze=Object.defineProperty;var Vt=Object.getOwnPropertyDescriptor;var Dt=Object.getOwnPropertyNames;var Ut=Object.prototype.hasOwnProperty;var ct=(t,e)=>{for(var r in e)ze(t,r,{get:e[r],enumerable:!0})},zt=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Dt(e))!Ut.call(t,n)&&n!==r&&ze(t,n,{get:()=>e[n],enumerable:!(s=Vt(e,n))||s.enumerable});return t};var Zt=t=>zt(ze({},"__esModule",{value:!0}),t);var Vs={};ct(Vs,{FilloClient:()=>Me,FilloError:()=>S,createClient:()=>Oe,createFormElement:()=>Rt,defineForm:()=>et,registerFilloElement:()=>at,renderForm:()=>Ue});var w={};ct(w,{BRAND:()=>mr,DIRTY:()=>te,EMPTY_PATH:()=>Wt,INVALID:()=>y,NEVER:()=>Gr,OK:()=>A,ParseStatus:()=>F,Schema:()=>_,ZodAny:()=>G,ZodArray:()=>Y,ZodBigInt:()=>se,ZodBoolean:()=>ne,ZodBranded:()=>Ee,ZodCatch:()=>me,ZodDate:()=>ie,ZodDefault:()=>pe,ZodDiscriminatedUnion:()=>$e,ZodEffects:()=>M,ZodEnum:()=>fe,ZodError:()=>R,ZodFirstPartyTypeKind:()=>v,ZodFunction:()=>je,ZodIntersection:()=>de,ZodIssueCode:()=>u,ZodLazy:()=>ce,ZodLiteral:()=>ue,ZodMap:()=>we,ZodNaN:()=>Te,ZodNativeEnum:()=>he,ZodNever:()=>U,ZodNull:()=>oe,ZodNullable:()=>H,ZodNumber:()=>re,ZodObject:()=>I,ZodOptional:()=>j,ZodParsedType:()=>p,ZodPipeline:()=>Fe,ZodPromise:()=>ee,ZodReadonly:()=>ge,ZodRecord:()=>Le,ZodSchema:()=>_,ZodSet:()=>Ce,ZodString:()=>X,ZodSymbol:()=>xe,ZodTransformer:()=>M,ZodTuple:()=>B,ZodType:()=>_,ZodUndefined:()=>ae,ZodUnion:()=>le,ZodUnknown:()=>K,ZodVoid:()=>ke,addIssueToContext:()=>h,any:()=>Cr,array:()=>Er,bigint:()=>br,boolean:()=>xt,coerce:()=>Xr,custom:()=>vt,date:()=>_r,datetimeRegex:()=>gt,defaultErrorMap:()=>W,discriminatedUnion:()=>Rr,effect:()=>Br,enum:()=>Ur,function:()=>Mr,getErrorMap:()=>ve,getParsedType:()=>Z,instanceof:()=>yr,intersection:()=>Ir,isAborted:()=>Re,isAsync:()=>be,isDirty:()=>Ie,isValid:()=>Q,late:()=>gr,lazy:()=>Vr,literal:()=>Dr,makeIssue:()=>Se,map:()=>jr,nan:()=>vr,nativeEnum:()=>zr,never:()=>Nr,null:()=>wr,nullable:()=>qr,number:()=>_t,object:()=>Fr,objectUtil:()=>Ze,oboolean:()=>Qr,onumber:()=>Yr,optional:()=>Hr,ostring:()=>Kr,pipeline:()=>Jr,preprocess:()=>Wr,promise:()=>Zr,quotelessJson:()=>Bt,record:()=>Lr,set:()=>Pr,setErrorMap:()=>qt,strictObject:()=>Ar,string:()=>bt,symbol:()=>xr,transformer:()=>Br,tuple:()=>$r,undefined:()=>kr,union:()=>Or,unknown:()=>Tr,util:()=>k,void:()=>Sr});var k;(function(t){t.assertEqual=n=>{};function e(n){}t.assertIs=e;function r(n){throw new Error}t.assertNever=r,t.arrayToEnum=n=>{let i={};for(let a of n)i[a]=a;return i},t.getValidEnumValues=n=>{let i=t.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),a={};for(let o of i)a[o]=n[o];return t.objectValues(a)},t.objectValues=n=>t.objectKeys(n).map(function(i){return n[i]}),t.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let i=[];for(let a in n)Object.prototype.hasOwnProperty.call(n,a)&&i.push(a);return i},t.find=(n,i)=>{for(let a of n)if(i(a))return a},t.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function s(n,i=" | "){return n.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}t.joinValues=s,t.jsonStringifyReplacer=(n,i)=>typeof i=="bigint"?i.toString():i})(k||(k={}));var Ze;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Ze||(Ze={}));var p=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Z=t=>{switch(typeof t){case"undefined":return p.undefined;case"string":return p.string;case"number":return Number.isNaN(t)?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(t)?p.array:t===null?p.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?p.promise:typeof Map<"u"&&t instanceof Map?p.map:typeof Set<"u"&&t instanceof Set?p.set:typeof Date<"u"&&t instanceof Date?p.date:p.object;default:return p.unknown}};var u=k.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Bt=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),R=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(i){return i.message},s={_errors:[]},n=i=>{for(let a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(n);else if(a.code==="invalid_return_type")n(a.returnTypeError);else if(a.code==="invalid_arguments")n(a.argumentsError);else if(a.path.length===0)s._errors.push(r(a));else{let o=s,l=0;for(;l<a.path.length;){let d=a.path[l];l===a.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(r(a))):o[d]=o[d]||{_errors:[]},o=o[d],l++}}};return n(this),s}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,k.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},s=[];for(let n of this.issues)if(n.path.length>0){let i=n.path[0];r[i]=r[i]||[],r[i].push(e(n))}else s.push(e(n));return{formErrors:s,fieldErrors:r}}get formErrors(){return this.flatten()}};R.create=t=>new R(t);var Ht=(t,e)=>{let r;switch(t.code){case u.invalid_type:t.received===p.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case u.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,k.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:r=`Unrecognized key(s) in object: ${k.joinValues(t.keys,", ")}`;break;case u.invalid_union:r="Invalid input";break;case u.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${k.joinValues(t.options)}`;break;case u.invalid_enum_value:r=`Invalid enum value. Expected ${k.joinValues(t.options)}, received '${t.received}'`;break;case u.invalid_arguments:r="Invalid function arguments";break;case u.invalid_return_type:r="Invalid function return type";break;case u.invalid_date:r="Invalid date";break;case u.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:k.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case u.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case u.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case u.custom:r="Invalid input";break;case u.invalid_intersection_types:r="Intersection results could not be merged";break;case u.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case u.not_finite:r="Number must be finite";break;default:r=e.defaultError,k.assertNever(t)}return{message:r}},W=Ht;var ut=W;function qt(t){ut=t}function ve(){return ut}var Se=t=>{let{data:e,path:r,errorMaps:s,issueData:n}=t,i=[...r,...n.path||[]],a={...n,path:i};if(n.message!==void 0)return{...n,path:i,message:n.message};let o="",l=s.filter(d=>!!d).slice().reverse();for(let d of l)o=d(a,{data:e,defaultError:o}).message;return{...n,path:i,message:o}},Wt=[];function h(t,e){let r=ve(),s=Se({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===W?void 0:W].filter(n=>!!n)});t.common.issues.push(s)}var F=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let s=[];for(let n of r){if(n.status==="aborted")return y;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,r){let s=[];for(let n of r){let i=await n.key,a=await n.value;s.push({key:i,value:a})}return t.mergeObjectSync(e,s)}static mergeObjectSync(e,r){let s={};for(let n of r){let{key:i,value:a}=n;if(i.status==="aborted"||a.status==="aborted")return y;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||n.alwaysSet)&&(s[i.value]=a.value)}return{status:e.value,value:s}}},y=Object.freeze({status:"aborted"}),te=t=>({status:"dirty",value:t}),A=t=>({status:"valid",value:t}),Re=t=>t.status==="aborted",Ie=t=>t.status==="dirty",Q=t=>t.status==="valid",be=t=>typeof Promise<"u"&&t instanceof Promise;var m;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(m||(m={}));var P=class{constructor(e,r,s,n){this._cachedPath=[],this.parent=e,this.data=r,this._path=s,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}},ft=(t,e)=>{if(Q(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new R(t.common.issues);return this._error=r,this._error}}};function b(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:s,description:n}=t;if(e&&(r||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(a,o)=>{let{message:l}=t;return a.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:l??s??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:l??r??o.defaultError}},description:n}}var _=class{get description(){return this._def.description}_getType(e){return Z(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new F,ctx:{common:e.parent.common,data:e.data,parsedType:Z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(be(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let s=this.safeParse(e,r);if(s.success)return s.data;throw s.error}safeParse(e,r){let s={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Z(e)},n=this._parseSync({data:e,path:s.path,parent:s});return ft(s,n)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Z(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:r});return Q(s)?{value:s.value}:{issues:r.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(s=>Q(s)?{value:s.value}:{issues:r.common.issues})}async parseAsync(e,r){let s=await this.safeParseAsync(e,r);if(s.success)return s.data;throw s.error}async safeParseAsync(e,r){let s={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Z(e)},n=this._parse({data:e,path:s.path,parent:s}),i=await(be(n)?n:Promise.resolve(n));return ft(s,i)}refine(e,r){let s=n=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(n):r;return this._refinement((n,i)=>{let a=e(n),o=()=>i.addIssue({code:u.custom,...s(n)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,r){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof r=="function"?r(s,n):r),!1))}_refinement(e){return new M({schema:this,typeName:v.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:r=>this["~validate"](r)}}optional(){return j.create(this,this._def)}nullable(){return H.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Y.create(this)}promise(){return ee.create(this,this._def)}or(e){return le.create([this,e],this._def)}and(e){return de.create(this,e,this._def)}transform(e){return new M({...b(this._def),schema:this,typeName:v.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new pe({...b(this._def),innerType:this,defaultValue:r,typeName:v.ZodDefault})}brand(){return new Ee({typeName:v.ZodBranded,type:this,...b(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new me({...b(this._def),innerType:this,catchValue:r,typeName:v.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Fe.create(this,e)}readonly(){return ge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Jt=/^c[^\s-]{8,}$/i,Kt=/^[0-9a-z]+$/,Yt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Qt=/^[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,Xt=/^[a-z0-9_-]{21}$/i,Gt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,er=/^[-+]?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)?)??$/,tr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,rr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Be,sr=/^(?:(?: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])$/,nr=/^(?:(?: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])$/,ir=/^(([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]))$/,ar=/^(([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])$/,or=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,lr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,pt="((\\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])))",dr=new RegExp(`^${pt}$`);function mt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function cr(t){return new RegExp(`^${mt(t)}$`)}function gt(t){let e=`${pt}T${mt(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function ur(t,e){return!!((e==="v4"||!e)&&sr.test(t)||(e==="v6"||!e)&&ir.test(t))}function fr(t,e){if(!Gt.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let s=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(s));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function hr(t,e){return!!((e==="v4"||!e)&&nr.test(t)||(e==="v6"||!e)&&ar.test(t))}var X=class t extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){let i=this._getOrReturnCtx(e);return h(i,{code:u.invalid_type,expected:p.string,received:i.parsedType}),y}let s=new F,n;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),h(n,{code:u.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),s.dirty());else if(i.kind==="max")e.data.length>i.value&&(n=this._getOrReturnCtx(e,n),h(n,{code:u.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),s.dirty());else if(i.kind==="length"){let a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(n=this._getOrReturnCtx(e,n),a?h(n,{code:u.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&h(n,{code:u.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),s.dirty())}else if(i.kind==="email")tr.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"email",code:u.invalid_string,message:i.message}),s.dirty());else if(i.kind==="emoji")Be||(Be=new RegExp(rr,"u")),Be.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"emoji",code:u.invalid_string,message:i.message}),s.dirty());else if(i.kind==="uuid")Qt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"uuid",code:u.invalid_string,message:i.message}),s.dirty());else if(i.kind==="nanoid")Xt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"nanoid",code:u.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid")Jt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"cuid",code:u.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid2")Kt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"cuid2",code:u.invalid_string,message:i.message}),s.dirty());else if(i.kind==="ulid")Yt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"ulid",code:u.invalid_string,message:i.message}),s.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),h(n,{validation:"url",code:u.invalid_string,message:i.message}),s.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"regex",code:u.invalid_string,message:i.message}),s.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(e,n),h(n,{code:u.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),s.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(n=this._getOrReturnCtx(e,n),h(n,{code:u.invalid_string,validation:{startsWith:i.value},message:i.message}),s.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),h(n,{code:u.invalid_string,validation:{endsWith:i.value},message:i.message}),s.dirty()):i.kind==="datetime"?gt(i).test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:u.invalid_string,validation:"datetime",message:i.message}),s.dirty()):i.kind==="date"?dr.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:u.invalid_string,validation:"date",message:i.message}),s.dirty()):i.kind==="time"?cr(i).test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:u.invalid_string,validation:"time",message:i.message}),s.dirty()):i.kind==="duration"?er.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"duration",code:u.invalid_string,message:i.message}),s.dirty()):i.kind==="ip"?ur(e.data,i.version)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"ip",code:u.invalid_string,message:i.message}),s.dirty()):i.kind==="jwt"?fr(e.data,i.alg)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"jwt",code:u.invalid_string,message:i.message}),s.dirty()):i.kind==="cidr"?hr(e.data,i.version)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"cidr",code:u.invalid_string,message:i.message}),s.dirty()):i.kind==="base64"?or.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"base64",code:u.invalid_string,message:i.message}),s.dirty()):i.kind==="base64url"?lr.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"base64url",code:u.invalid_string,message:i.message}),s.dirty()):k.assertNever(i);return{status:s.value,value:e.data}}_regex(e,r,s){return this.refinement(n=>e.test(n),{validation:r,code:u.invalid_string,...m.errToObj(s)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...m.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...m.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...m.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...m.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...m.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,...m.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,...m.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...m.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...m.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...m.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...m.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...m.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...m.errToObj(r)})}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};X.create=t=>new X({checks:[],typeName:v.ZodString,coerce:t?.coerce??!1,...b(t)});function pr(t,e){let r=(t.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=r>s?r:s,i=Number.parseInt(t.toFixed(n).replace(".","")),a=Number.parseInt(e.toFixed(n).replace(".",""));return i%a/10**n}var re=class t extends _{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){let i=this._getOrReturnCtx(e);return h(i,{code:u.invalid_type,expected:p.number,received:i.parsedType}),y}let s,n=new F;for(let i of this._def.checks)i.kind==="int"?k.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:u.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(s=this._getOrReturnCtx(e,s),h(s,{code:u.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(s=this._getOrReturnCtx(e,s),h(s,{code:u.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?pr(e.data,i.value)!==0&&(s=this._getOrReturnCtx(e,s),h(s,{code:u.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:u.not_finite,message:i.message}),n.dirty()):k.assertNever(i);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,m.toString(r))}gt(e,r){return this.setLimit("min",e,!1,m.toString(r))}lte(e,r){return this.setLimit("max",e,!0,m.toString(r))}lt(e,r){return this.setLimit("max",e,!1,m.toString(r))}setLimit(e,r,s,n){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:s,message:m.toString(n)}]})}_addCheck(e){return new t({...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,r){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(r)})}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(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&k.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(r===null||s.value>r)&&(r=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(r)&&Number.isFinite(e)}};re.create=t=>new re({checks:[],typeName:v.ZodNumber,coerce:t?.coerce||!1,...b(t)});var se=class t extends _{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)!==p.bigint)return this._getInvalidInput(e);let s,n=new F;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(s=this._getOrReturnCtx(e,s),h(s,{code:u.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(s=this._getOrReturnCtx(e,s),h(s,{code:u.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),h(s,{code:u.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):k.assertNever(i);return{status:n.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return h(r,{code:u.invalid_type,expected:p.bigint,received:r.parsedType}),y}gte(e,r){return this.setLimit("min",e,!0,m.toString(r))}gt(e,r){return this.setLimit("min",e,!1,m.toString(r))}lte(e,r){return this.setLimit("max",e,!0,m.toString(r))}lt(e,r){return this.setLimit("max",e,!1,m.toString(r))}setLimit(e,r,s,n){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:s,message:m.toString(n)}]})}_addCheck(e){return new t({...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,r){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};se.create=t=>new se({checks:[],typeName:v.ZodBigInt,coerce:t?.coerce??!1,...b(t)});var ne=class extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){let s=this._getOrReturnCtx(e);return h(s,{code:u.invalid_type,expected:p.boolean,received:s.parsedType}),y}return A(e.data)}};ne.create=t=>new ne({typeName:v.ZodBoolean,coerce:t?.coerce||!1,...b(t)});var ie=class t extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){let i=this._getOrReturnCtx(e);return h(i,{code:u.invalid_type,expected:p.date,received:i.parsedType}),y}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return h(i,{code:u.invalid_date}),y}let s=new F,n;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),h(n,{code:u.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),s.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(n=this._getOrReturnCtx(e,n),h(n,{code:u.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),s.dirty()):k.assertNever(i);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};ie.create=t=>new ie({checks:[],coerce:t?.coerce||!1,typeName:v.ZodDate,...b(t)});var xe=class extends _{_parse(e){if(this._getType(e)!==p.symbol){let s=this._getOrReturnCtx(e);return h(s,{code:u.invalid_type,expected:p.symbol,received:s.parsedType}),y}return A(e.data)}};xe.create=t=>new xe({typeName:v.ZodSymbol,...b(t)});var ae=class extends _{_parse(e){if(this._getType(e)!==p.undefined){let s=this._getOrReturnCtx(e);return h(s,{code:u.invalid_type,expected:p.undefined,received:s.parsedType}),y}return A(e.data)}};ae.create=t=>new ae({typeName:v.ZodUndefined,...b(t)});var oe=class extends _{_parse(e){if(this._getType(e)!==p.null){let s=this._getOrReturnCtx(e);return h(s,{code:u.invalid_type,expected:p.null,received:s.parsedType}),y}return A(e.data)}};oe.create=t=>new oe({typeName:v.ZodNull,...b(t)});var G=class extends _{constructor(){super(...arguments),this._any=!0}_parse(e){return A(e.data)}};G.create=t=>new G({typeName:v.ZodAny,...b(t)});var K=class extends _{constructor(){super(...arguments),this._unknown=!0}_parse(e){return A(e.data)}};K.create=t=>new K({typeName:v.ZodUnknown,...b(t)});var U=class extends _{_parse(e){let r=this._getOrReturnCtx(e);return h(r,{code:u.invalid_type,expected:p.never,received:r.parsedType}),y}};U.create=t=>new U({typeName:v.ZodNever,...b(t)});var ke=class extends _{_parse(e){if(this._getType(e)!==p.undefined){let s=this._getOrReturnCtx(e);return h(s,{code:u.invalid_type,expected:p.void,received:s.parsedType}),y}return A(e.data)}};ke.create=t=>new ke({typeName:v.ZodVoid,...b(t)});var Y=class t extends _{_parse(e){let{ctx:r,status:s}=this._processInputParams(e),n=this._def;if(r.parsedType!==p.array)return h(r,{code:u.invalid_type,expected:p.array,received:r.parsedType}),y;if(n.exactLength!==null){let a=r.data.length>n.exactLength.value,o=r.data.length<n.exactLength.value;(a||o)&&(h(r,{code:a?u.too_big:u.too_small,minimum:o?n.exactLength.value:void 0,maximum:a?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(h(r,{code:u.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(h(r,{code:u.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),r.common.async)return Promise.all([...r.data].map((a,o)=>n.type._parseAsync(new P(r,a,r.path,o)))).then(a=>F.mergeArray(s,a));let i=[...r.data].map((a,o)=>n.type._parseSync(new P(r,a,r.path,o)));return F.mergeArray(s,i)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:m.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:m.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:m.toString(r)}})}nonempty(e){return this.min(1,e)}};Y.create=(t,e)=>new Y({type:t,minLength:null,maxLength:null,exactLength:null,typeName:v.ZodArray,...b(e)});function _e(t){if(t instanceof I){let e={};for(let r in t.shape){let s=t.shape[r];e[r]=j.create(_e(s))}return new I({...t._def,shape:()=>e})}else return t instanceof Y?new Y({...t._def,type:_e(t.element)}):t instanceof j?j.create(_e(t.unwrap())):t instanceof H?H.create(_e(t.unwrap())):t instanceof B?B.create(t.items.map(e=>_e(e))):t}var I=class t extends _{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(),r=k.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==p.object){let d=this._getOrReturnCtx(e);return h(d,{code:u.invalid_type,expected:p.object,received:d.parsedType}),y}let{status:s,ctx:n}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof U&&this._def.unknownKeys==="strip"))for(let d in n.data)a.includes(d)||o.push(d);let l=[];for(let d of a){let f=i[d],g=n.data[d];l.push({key:{status:"valid",value:d},value:f._parse(new P(n,g,n.path,d)),alwaysSet:d in n.data})}if(this._def.catchall instanceof U){let d=this._def.unknownKeys;if(d==="passthrough")for(let f of o)l.push({key:{status:"valid",value:f},value:{status:"valid",value:n.data[f]}});else if(d==="strict")o.length>0&&(h(n,{code:u.unrecognized_keys,keys:o}),s.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let f of o){let g=n.data[f];l.push({key:{status:"valid",value:f},value:d._parse(new P(n,g,n.path,f)),alwaysSet:f in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let d=[];for(let f of l){let g=await f.key,T=await f.value;d.push({key:g,value:T,alwaysSet:f.alwaysSet})}return d}).then(d=>F.mergeObjectSync(s,d)):F.mergeObjectSync(s,l)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,s)=>{let n=this._def.errorMap?.(r,s).message??s.defaultError;return r.code==="unrecognized_keys"?{message:m.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:v.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let s of k.objectKeys(e))e[s]&&this.shape[s]&&(r[s]=this.shape[s]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let s of k.objectKeys(this.shape))e[s]||(r[s]=this.shape[s]);return new t({...this._def,shape:()=>r})}deepPartial(){return _e(this)}partial(e){let r={};for(let s of k.objectKeys(this.shape)){let n=this.shape[s];e&&!e[s]?r[s]=n:r[s]=n.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let s of k.objectKeys(this.shape))if(e&&!e[s])r[s]=this.shape[s];else{let i=this.shape[s];for(;i instanceof j;)i=i._def.innerType;r[s]=i}return new t({...this._def,shape:()=>r})}keyof(){return yt(k.objectKeys(this.shape))}};I.create=(t,e)=>new I({shape:()=>t,unknownKeys:"strip",catchall:U.create(),typeName:v.ZodObject,...b(e)});I.strictCreate=(t,e)=>new I({shape:()=>t,unknownKeys:"strict",catchall:U.create(),typeName:v.ZodObject,...b(e)});I.lazycreate=(t,e)=>new I({shape:t,unknownKeys:"strip",catchall:U.create(),typeName:v.ZodObject,...b(e)});var le=class extends _{_parse(e){let{ctx:r}=this._processInputParams(e),s=this._def.options;function n(i){for(let o of i)if(o.result.status==="valid")return o.result;for(let o of i)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;let a=i.map(o=>new R(o.ctx.common.issues));return h(r,{code:u.invalid_union,unionErrors:a}),y}if(r.common.async)return Promise.all(s.map(async i=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(n);{let i,a=[];for(let l of s){let d={...r,common:{...r.common,issues:[]},parent:null},f=l._parseSync({data:r.data,path:r.path,parent:d});if(f.status==="valid")return f;f.status==="dirty"&&!i&&(i={result:f,ctx:d}),d.common.issues.length&&a.push(d.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let o=a.map(l=>new R(l));return h(r,{code:u.invalid_union,unionErrors:o}),y}}get options(){return this._def.options}};le.create=(t,e)=>new le({options:t,typeName:v.ZodUnion,...b(e)});var J=t=>t instanceof ce?J(t.schema):t instanceof M?J(t.innerType()):t instanceof ue?[t.value]:t instanceof fe?t.options:t instanceof he?k.objectValues(t.enum):t instanceof pe?J(t._def.innerType):t instanceof ae?[void 0]:t instanceof oe?[null]:t instanceof j?[void 0,...J(t.unwrap())]:t instanceof H?[null,...J(t.unwrap())]:t instanceof Ee||t instanceof ge?J(t.unwrap()):t instanceof me?J(t._def.innerType):[],$e=class t extends _{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.object)return h(r,{code:u.invalid_type,expected:p.object,received:r.parsedType}),y;let s=this.discriminator,n=r.data[s],i=this.optionsMap.get(n);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(h(r,{code:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,s){let n=new Map;for(let i of r){let a=J(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of a){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,i)}}return new t({typeName:v.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:n,...b(s)})}};function He(t,e){let r=Z(t),s=Z(e);if(t===e)return{valid:!0,data:t};if(r===p.object&&s===p.object){let n=k.objectKeys(e),i=k.objectKeys(t).filter(o=>n.indexOf(o)!==-1),a={...t,...e};for(let o of i){let l=He(t[o],e[o]);if(!l.valid)return{valid:!1};a[o]=l.data}return{valid:!0,data:a}}else if(r===p.array&&s===p.array){if(t.length!==e.length)return{valid:!1};let n=[];for(let i=0;i<t.length;i++){let a=t[i],o=e[i],l=He(a,o);if(!l.valid)return{valid:!1};n.push(l.data)}return{valid:!0,data:n}}else return r===p.date&&s===p.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var de=class extends _{_parse(e){let{status:r,ctx:s}=this._processInputParams(e),n=(i,a)=>{if(Re(i)||Re(a))return y;let o=He(i.value,a.value);return o.valid?((Ie(i)||Ie(a))&&r.dirty(),{status:r.value,value:o.data}):(h(s,{code:u.invalid_intersection_types}),y)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([i,a])=>n(i,a)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};de.create=(t,e,r)=>new de({left:t,right:e,typeName:v.ZodIntersection,...b(r)});var B=class t extends _{_parse(e){let{status:r,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.array)return h(s,{code:u.invalid_type,expected:p.array,received:s.parsedType}),y;if(s.data.length<this._def.items.length)return h(s,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&s.data.length>this._def.items.length&&(h(s,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...s.data].map((a,o)=>{let l=this._def.items[o]||this._def.rest;return l?l._parse(new P(s,a,s.path,o)):null}).filter(a=>!!a);return s.common.async?Promise.all(i).then(a=>F.mergeArray(r,a)):F.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};B.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new B({items:t,typeName:v.ZodTuple,rest:null,...b(e)})};var Le=class t extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.object)return h(s,{code:u.invalid_type,expected:p.object,received:s.parsedType}),y;let n=[],i=this._def.keyType,a=this._def.valueType;for(let o in s.data)n.push({key:i._parse(new P(s,o,s.path,o)),value:a._parse(new P(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?F.mergeObjectAsync(r,n):F.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(e,r,s){return r instanceof _?new t({keyType:e,valueType:r,typeName:v.ZodRecord,...b(s)}):new t({keyType:X.create(),valueType:e,typeName:v.ZodRecord,...b(r)})}},we=class extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.map)return h(s,{code:u.invalid_type,expected:p.map,received:s.parsedType}),y;let n=this._def.keyType,i=this._def.valueType,a=[...s.data.entries()].map(([o,l],d)=>({key:n._parse(new P(s,o,s.path,[d,"key"])),value:i._parse(new P(s,l,s.path,[d,"value"]))}));if(s.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let l of a){let d=await l.key,f=await l.value;if(d.status==="aborted"||f.status==="aborted")return y;(d.status==="dirty"||f.status==="dirty")&&r.dirty(),o.set(d.value,f.value)}return{status:r.value,value:o}})}else{let o=new Map;for(let l of a){let d=l.key,f=l.value;if(d.status==="aborted"||f.status==="aborted")return y;(d.status==="dirty"||f.status==="dirty")&&r.dirty(),o.set(d.value,f.value)}return{status:r.value,value:o}}}};we.create=(t,e,r)=>new we({valueType:e,keyType:t,typeName:v.ZodMap,...b(r)});var Ce=class t extends _{_parse(e){let{status:r,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.set)return h(s,{code:u.invalid_type,expected:p.set,received:s.parsedType}),y;let n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(h(s,{code:u.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(h(s,{code:u.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());let i=this._def.valueType;function a(l){let d=new Set;for(let f of l){if(f.status==="aborted")return y;f.status==="dirty"&&r.dirty(),d.add(f.value)}return{status:r.value,value:d}}let o=[...s.data.values()].map((l,d)=>i._parse(new P(s,l,s.path,d)));return s.common.async?Promise.all(o).then(l=>a(l)):a(o)}min(e,r){return new t({...this._def,minSize:{value:e,message:m.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:m.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Ce.create=(t,e)=>new Ce({valueType:t,minSize:null,maxSize:null,typeName:v.ZodSet,...b(e)});var je=class t extends _{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.function)return h(r,{code:u.invalid_type,expected:p.function,received:r.parsedType}),y;function s(o,l){return Se({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ve(),W].filter(d=>!!d),issueData:{code:u.invalid_arguments,argumentsError:l}})}function n(o,l){return Se({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ve(),W].filter(d=>!!d),issueData:{code:u.invalid_return_type,returnTypeError:l}})}let i={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof ee){let o=this;return A(async function(...l){let d=new R([]),f=await o._def.args.parseAsync(l,i).catch(C=>{throw d.addIssue(s(l,C)),d}),g=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(g,i).catch(C=>{throw d.addIssue(n(g,C)),d})})}else{let o=this;return A(function(...l){let d=o._def.args.safeParse(l,i);if(!d.success)throw new R([s(l,d.error)]);let f=Reflect.apply(a,this,d.data),g=o._def.returns.safeParse(f,i);if(!g.success)throw new R([n(f,g.error)]);return g.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:B.create(e).rest(K.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,s){return new t({args:e||B.create([]).rest(K.create()),returns:r||K.create(),typeName:v.ZodFunction,...b(s)})}},ce=class extends _{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};ce.create=(t,e)=>new ce({getter:t,typeName:v.ZodLazy,...b(e)});var ue=class extends _{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return h(r,{received:r.data,code:u.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:e.data}}get value(){return this._def.value}};ue.create=(t,e)=>new ue({value:t,typeName:v.ZodLiteral,...b(e)});function yt(t,e){return new fe({values:t,typeName:v.ZodEnum,...b(e)})}var fe=class t extends _{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),s=this._def.values;return h(r,{expected:k.joinValues(s),received:r.parsedType,code:u.invalid_type}),y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),s=this._def.values;return h(r,{received:r.data,code:u.invalid_enum_value,options:s}),y}return A(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(s=>!e.includes(s)),{...this._def,...r})}};fe.create=yt;var he=class extends _{_parse(e){let r=k.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==p.string&&s.parsedType!==p.number){let n=k.objectValues(r);return h(s,{expected:k.joinValues(n),received:s.parsedType,code:u.invalid_type}),y}if(this._cache||(this._cache=new Set(k.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let n=k.objectValues(r);return h(s,{received:s.data,code:u.invalid_enum_value,options:n}),y}return A(e.data)}get enum(){return this._def.values}};he.create=(t,e)=>new he({values:t,typeName:v.ZodNativeEnum,...b(e)});var ee=class extends _{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.promise&&r.common.async===!1)return h(r,{code:u.invalid_type,expected:p.promise,received:r.parsedType}),y;let s=r.parsedType===p.promise?r.data:Promise.resolve(r.data);return A(s.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}};ee.create=(t,e)=>new ee({type:t,typeName:v.ZodPromise,...b(e)});var M=class extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===v.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:s}=this._processInputParams(e),n=this._def.effect||null,i={addIssue:a=>{h(s,a),a.fatal?r.abort():r.dirty()},get path(){return s.path}};if(i.addIssue=i.addIssue.bind(i),n.type==="preprocess"){let a=n.transform(s.data,i);if(s.common.async)return Promise.resolve(a).then(async o=>{if(r.value==="aborted")return y;let l=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return l.status==="aborted"?y:l.status==="dirty"?te(l.value):r.value==="dirty"?te(l.value):l});{if(r.value==="aborted")return y;let o=this._def.schema._parseSync({data:a,path:s.path,parent:s});return o.status==="aborted"?y:o.status==="dirty"?te(o.value):r.value==="dirty"?te(o.value):o}}if(n.type==="refinement"){let a=o=>{let l=n.refinement(o,i);if(s.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){let o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?y:(o.status==="dirty"&&r.dirty(),a(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?y:(o.status==="dirty"&&r.dirty(),a(o.value).then(()=>({status:r.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){let a=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!Q(a))return y;let o=n.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(a=>Q(a)?Promise.resolve(n.transform(a.value,i)).then(o=>({status:r.value,value:o})):y);k.assertNever(n)}};M.create=(t,e,r)=>new M({schema:t,typeName:v.ZodEffects,effect:e,...b(r)});M.createWithPreprocess=(t,e,r)=>new M({schema:e,effect:{type:"preprocess",transform:t},typeName:v.ZodEffects,...b(r)});var j=class extends _{_parse(e){return this._getType(e)===p.undefined?A(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};j.create=(t,e)=>new j({innerType:t,typeName:v.ZodOptional,...b(e)});var H=class extends _{_parse(e){return this._getType(e)===p.null?A(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};H.create=(t,e)=>new H({innerType:t,typeName:v.ZodNullable,...b(e)});var pe=class extends _{_parse(e){let{ctx:r}=this._processInputParams(e),s=r.data;return r.parsedType===p.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};pe.create=(t,e)=>new pe({innerType:t,typeName:v.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});var me=class extends _{_parse(e){let{ctx:r}=this._processInputParams(e),s={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return be(n)?n.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new R(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new R(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};me.create=(t,e)=>new me({innerType:t,typeName:v.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});var Te=class extends _{_parse(e){if(this._getType(e)!==p.nan){let s=this._getOrReturnCtx(e);return h(s,{code:u.invalid_type,expected:p.nan,received:s.parsedType}),y}return{status:"valid",value:e.data}}};Te.create=t=>new Te({typeName:v.ZodNaN,...b(t)});var mr=Symbol("zod_brand"),Ee=class extends _{_parse(e){let{ctx:r}=this._processInputParams(e),s=r.data;return this._def.type._parse({data:s,path:r.path,parent:r})}unwrap(){return this._def.type}},Fe=class t extends _{_parse(e){let{status:r,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?y:i.status==="dirty"?(r.dirty(),te(i.value)):this._def.out._parseAsync({data:i.value,path:s.path,parent:s})})();{let n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?y:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,r){return new t({in:e,out:r,typeName:v.ZodPipeline})}},ge=class extends _{_parse(e){let r=this._def.innerType._parse(e),s=n=>(Q(n)&&(n.value=Object.freeze(n.value)),n);return be(r)?r.then(n=>s(n)):s(r)}unwrap(){return this._def.innerType}};ge.create=(t,e)=>new ge({innerType:t,typeName:v.ZodReadonly,...b(e)});function ht(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function vt(t,e={},r){return t?G.create().superRefine((s,n)=>{let i=t(s);if(i instanceof Promise)return i.then(a=>{if(!a){let o=ht(e,s),l=o.fatal??r??!0;n.addIssue({code:"custom",...o,fatal:l})}});if(!i){let a=ht(e,s),o=a.fatal??r??!0;n.addIssue({code:"custom",...a,fatal:o})}}):G.create()}var gr={object:I.lazycreate},v;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(v||(v={}));var yr=(t,e={message:`Input not instance of ${t.name}`})=>vt(r=>r instanceof t,e),bt=X.create,_t=re.create,vr=Te.create,br=se.create,xt=ne.create,_r=ie.create,xr=xe.create,kr=ae.create,wr=oe.create,Cr=G.create,Tr=K.create,Nr=U.create,Sr=ke.create,Er=Y.create,Fr=I.create,Ar=I.strictCreate,Or=le.create,Rr=$e.create,Ir=de.create,$r=B.create,Lr=Le.create,jr=we.create,Pr=Ce.create,Mr=je.create,Vr=ce.create,Dr=ue.create,Ur=fe.create,zr=he.create,Zr=ee.create,Br=M.create,Hr=j.create,qr=H.create,Wr=M.createWithPreprocess,Jr=Fe.create,Kr=()=>bt().optional(),Yr=()=>_t().optional(),Qr=()=>xt().optional(),Xr={string:(t=>X.create({...t,coerce:!0})),number:(t=>re.create({...t,coerce:!0})),boolean:(t=>ne.create({...t,coerce:!0})),bigint:(t=>se.create({...t,coerce:!0})),date:(t=>ie.create({...t,coerce:!0}))};var Gr=y;var es=["heading","paragraph","divider"];function Ae(t){return!es.includes(t.kind)}function kt(t){return t==null?!1:typeof t=="string"?t.trim()!=="":Array.isArray(t)?t.length>0:typeof t=="boolean"?t:typeof t=="object"?Object.keys(t).length>0:!0}function ts(t,e){let r=e[t.fieldId];switch(t.op){case"answered":return kt(r);case"not_answered":return!kt(r);case"eq":return Array.isArray(r)?r.some(s=>s===t.value):r===t.value;case"neq":return Array.isArray(r)?!r.some(s=>s===t.value):r!==t.value;case"contains":return typeof r=="string"?r.toLowerCase().includes(String(t.value??"").toLowerCase()):Array.isArray(r)?r.some(s=>s===t.value):!1;case"gt":return typeof r=="number"&&r>Number(t.value);case"lt":return typeof r=="number"&&r<Number(t.value)}}function rs(t,e){return!t.visibleIf||t.visibleIf.length===0?!0:t.visibleIf.every(r=>ts(r,e))}function Qe(t,e){return t.blocks.filter(r=>rs(r,e))}function ss(t){return t.pages.flatMap(e=>e.blocks.filter(Ae))}function ns(t,e){return t.pages.flatMap(r=>Qe(r,e).filter(Ae))}var is=w.object({fileId:w.string().min(1),name:w.string(),size:w.number().nonnegative(),mime:w.string(),url:w.string().optional()});function Ct(t){return t==null?!0:typeof t=="string"?t.trim()==="":Array.isArray(t)?t.length===0:typeof t=="boolean"?t===!1:typeof t=="object"?Object.keys(t).length===0:!1}function Tt(t,e){if(Ct(e))return t.required?"This field is required":null;switch(t.kind){case"short_text":case"long_text":{if(typeof e!="string")return"Expected text";if(t.maxLength&&e.length>t.maxLength)return`Must be at most ${t.maxLength} characters`;let r=t.kind==="long_text"?2e4:2e3;return!t.maxLength&&e.length>r?"Answer is too long":null}case"email":return w.string().email().safeParse(e).success?null:"Enter a valid email address";case"url":{if(typeof e!="string")return"Enter a valid URL (including https://)";try{let r=new URL(e);if(r.protocol!=="http:"&&r.protocol!=="https:")return"Enter an http(s) URL"}catch{return"Enter a valid URL (including https://)"}return null}case"phone":return typeof e!="string"||!/^[+\d][\d\s\-().]{4,}$/.test(e)?"Enter a valid phone number":null;case"number":{let r=typeof e=="string"?Number(e):e;return typeof r!="number"||Number.isNaN(r)?"Enter a number":t.min!==void 0&&r<t.min?`Must be at least ${t.min}`:t.max!==void 0&&r>t.max?`Must be at most ${t.max}`:null}case"select":case"dropdown":return typeof e!="string"||e===""?"Pick an option":t.options.some(r=>r.id===e)||t.allowOther&&e.length<=500?null:"Pick a valid option";case"multi_select":{if(!Array.isArray(e))return"Pick at least one option";let r=new Set(t.options.map(i=>i.id)),s=e,n=0;for(let i of s)if(!r.has(i)){if(t.allowOther!==!0||typeof i!="string"||i.length===0||i.length>500)return"Pick valid options";if(++n>1)return"Only one 'Other' answer is allowed"}return null}case"checkbox":return typeof e=="boolean"?null:"Invalid value";case"rating":{let r=t.max??5,s=typeof e=="string"?Number(e):e;return typeof s!="number"||!Number.isInteger(s)||s<1||s>r?`Pick a rating between 1 and ${r}`:null}case"linear_scale":{let r=t.min??1,s=t.max??10,n=typeof e=="string"?Number(e):e;return typeof n!="number"||!Number.isInteger(n)||n<r||n>s?`Pick a value between ${r} and ${s}`:null}case"ranking":{if(!Array.isArray(e))return"Drag the options into order";let r=t.options.map(n=>n.id).sort(),s=[...e].sort();return r.length!==s.length||r.some((n,i)=>n!==s[i])?"Rank every option":null}case"matrix":{if(typeof e!="object"||e===null||Array.isArray(e))return"Answer the grid";let r=e,s=new Set(t.columns.map(i=>i.id)),n=new Set(t.rows.map(i=>i.id));for(let[i,a]of Object.entries(r))if(!n.has(i)||!s.has(a))return"Invalid grid answer";return t.required&&Object.keys(r).length<t.rows.length?"Answer every row":null}case"signature":return typeof e!="string"||!e.startsWith("data:image/")?"Sign in the box":null;case"hidden":return typeof e=="string"?null:"Invalid value";case"custom":return null;case"date":return typeof e!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(e)?"Enter a valid date":null;case"file_upload":{let r=w.array(is).safeParse(e);if(!r.success)return"Upload did not complete";let s=t.maxFiles??1;return r.data.length>s?`At most ${s} file${s===1?"":"s"}`:null}}}function as(t,e){let r=ns(t,e),s={},n={};for(let i of r){let a=os(i,e[i.id]),o=Tt(i,a);o?s[i.id]=o:Ct(a)||(n[i.id]=a)}return{ok:Object.keys(s).length===0,errors:s,data:n}}function os(t,e){if(e==null)return e;if(t.kind==="number"&&typeof e=="string"&&e.trim()!==""){let r=Number(e);return Number.isNaN(r)?e:r}if(t.kind==="rating"&&typeof e=="string"){let r=Number(e);return Number.isNaN(r)?e:r}return typeof e=="string"?e.trim():e}var ls=["short_text","long_text","email","url","phone","number","select","multi_select","dropdown","checkbox","rating","linear_scale","ranking","matrix","signature","date","file_upload","hidden","custom"],ds=["heading","paragraph","divider"],cs=[...ls,...ds],Xe=w.string().min(1).max(128),qe=w.object({id:Xe,label:w.string().max(1e3)}).passthrough(),us=w.object({id:Xe,kind:w.enum(cs),label:w.string().max(2e3).optional(),options:w.array(qe).max(200).optional(),rows:w.array(qe).max(200).optional(),columns:w.array(qe).max(200).optional()}).passthrough(),fs=w.object({id:Xe,title:w.string().max(500).optional(),blocks:w.array(us).max(500)}),gn=w.object({version:w.literal(1),title:w.string().max(2e3).optional().default(""),description:w.string().max(5e3).optional(),pages:w.array(fs).min(1).max(50),settings:w.record(w.unknown()).optional().default({})});var hs="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",yn=256-256%hs.length;var Nt=class{h0=1732584193;h1=4023233417;h2=2562383102;h3=271733878;h4=3285377520;block=new Uint8Array(64);blockLen=0;totalLen=0;w=new Int32Array(80);update(t){this.totalLen+=t.length;let e=0;if(this.blockLen>0){for(;e<t.length&&this.blockLen<64;)this.block[this.blockLen++]=t[e++];this.blockLen===64&&(this.process(this.block),this.blockLen=0)}for(;e+64<=t.length;)this.process(t.subarray(e,e+64)),e+=64;for(;e<t.length;)this.block[this.blockLen++]=t[e++];return this}digest(){let t=Math.floor(this.totalLen/536870912),e=this.totalLen*8>>>0,r=[128],s=this.blockLen+1;for(;s%64!==56;)r.push(0),s++;r.push(t>>>24&255,t>>>16&255,t>>>8&255,t&255),r.push(e>>>24&255,e>>>16&255,e>>>8&255,e&255),this.update(new Uint8Array(r));let n=new Uint8Array(20),i=[this.h0,this.h1,this.h2,this.h3,this.h4];for(let a=0;a<5;a++)n[a*4]=i[a]>>>24&255,n[a*4+1]=i[a]>>>16&255,n[a*4+2]=i[a]>>>8&255,n[a*4+3]=i[a]&255;return n}process(t){let e=this.w;for(let o=0;o<16;o++)e[o]=t[o*4]<<24|t[o*4+1]<<16|t[o*4+2]<<8|t[o*4+3];for(let o=16;o<80;o++){let l=e[o-3]^e[o-8]^e[o-14]^e[o-16];e[o]=l<<1|l>>>31}let r=this.h0,s=this.h1,n=this.h2,i=this.h3,a=this.h4;for(let o=0;o<80;o++){let l,d;o<20?(l=s&n|~s&i,d=1518500249):o<40?(l=s^n^i,d=1859775393):o<60?(l=s&n|s&i|n&i,d=2400959708):(l=s^n^i,d=3395469782);let f=(r<<5|r>>>27)+l+a+d+e[o]|0;a=i,i=n,n=s<<30|s>>>2,s=r,r=f}this.h0=this.h0+r|0,this.h1=this.h1+s|0,this.h2=this.h2+n|0,this.h3=this.h3+i|0,this.h4=this.h4+a|0}},Pe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Ge(t){let e="";for(let r=0;r<t.length;r+=3){let s=t[r],n=r+1<t.length?t[r+1]:0,i=r+2<t.length?t[r+2]:0;e+=Pe[s>>2],e+=Pe[(s&3)<<4|n>>4],e+=r+1<t.length?Pe[(n&15)<<2|i>>6]:"=",e+=r+2<t.length?Pe[i&63]:"="}return e}var ps=t=>Ge(new Nt().update(t).digest()),S=class extends Error{constructor(t,e){super(t),this.status=e,this.name="FilloError"}status},We=3;function Je(t,e){return r=>e.onProgress?.({uploadedBytes:r,totalBytes:t,fraction:t===0?1:r/t})}async function ms(t){let e=globalThis.crypto?.subtle;if(e){let r=await e.digest("SHA-1",t);return Ge(new Uint8Array(r))}return ps(t)}var gs="https://fillo.so",Me=class{baseUrl;fetch;key;constructor(t={}){this.baseUrl=t.sameOrigin?"":gs,this.key=t.key,this.fetch=t.fetch??((...e)=>globalThis.fetch(...e))}url(t){return`${this.baseUrl}/api/v1${t}`}async json(t,e){let r=await this.fetch(this.url(t),{...e,headers:{"Content-Type":"application/json",...e?.headers}});if(!r.ok){let s=await r.text().catch(()=>"");throw new S(s||`Request failed: ${r.status}`,r.status)}return await r.json()}getForm(t){return this.json(`/forms/${encodeURIComponent(t)}`)}syncForm(t,e,r){return this.key?this.json("/forms/sync",{method:"POST",body:JSON.stringify({key:this.key,id:t,schema:e,theme:r})}):Promise.reject(new S("createClient needs a `key` (pk_\u2026) to sync code-defined forms",401))}async submit(t,e,r){let s=await this.fetch(this.url(`/forms/${encodeURIComponent(t)}/responses`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:e,meta:r})});if(s.status===422)return{ok:!1,errors:(await s.json()).errors};if(!s.ok)throw new S(`Submit failed: ${s.status}`,s.status);return{ok:!0,responseId:(await s.json()).id}}async startSession(t,e){try{let r=await this.fetch(this.url(`/forms/${encodeURIComponent(t)}/sessions`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pageCount:e})});return r.ok?(await r.json()).id:null}catch{return null}}reportProgress(t,e){try{this.fetch(this.url(`/sessions/${encodeURIComponent(t)}/progress`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})}catch{}}getUploadSession(t,e){return this.json(`/uploads/${encodeURIComponent(t)}`,e?{headers:{"X-Fillo-Upload-Token":e}}:void 0)}async uploadFile(t,e,r){let s=e instanceof File?e.name:"upload.bin",n=e.type||"application/octet-stream",i;r.sessionId?i=await this.getUploadSession(r.sessionId,r.uploadToken):i=await this.json(`/forms/${encodeURIComponent(t)}/uploads`,{method:"POST",body:JSON.stringify({fieldId:r.fieldId,fileName:s,size:e.size,mime:n})});let a;if(i.transport?.type==="gdrive")await this.driveUploadLoop(i,i.transport.uploadUrl,e,r);else if(i.transport?.type==="s3-put")await this.s3PutUpload(i.transport.uploadUrl,e,r);else if(i.transport?.type==="box")a=await this.boxUpload(i.transport,e,r);else throw new S("This form's storage doesn't support uploads \u2014 connect Drive, S3, or Box.");let o=await this.json(`/uploads/${encodeURIComponent(i.id)}/complete`,{method:"POST",headers:i.token?{"X-Fillo-Upload-Token":i.token}:void 0,...a?{body:JSON.stringify(a)}:{}});if(!o.file)throw new S("Upload completed but no file was returned");return o.file}async boxUpload(t,e,r){let s=Je(e.size,r);s(0);let n={Authorization:`Bearer ${t.token}`};if(t.mode==="simple"){let T=new FormData;T.append("attributes",JSON.stringify({name:t.fileName,parent:{id:t.folderId}})),T.append("file",e,t.fileName);let C=await this.retry(r,()=>this.fetch(t.uploadUrl,{method:"POST",headers:n,body:T,signal:r.signal}));if(!C.ok)throw new S(`Box upload failed: ${C.status}`,C.status);let D=await C.json();return s(e.size),{providerFileId:D.entries?.[0]?.id}}if(t.size!==e.size)throw new S(`File size changed since the upload was requested (${e.size} vs ${t.size}).`,400);let i=await this.retry(r,()=>this.fetch(t.sessionUrl,{method:"POST",headers:{...n,"Content-Type":"application/json"},body:JSON.stringify({folder_id:t.folderId,file_size:t.size,file_name:t.fileName}),signal:r.signal}));if(!i.ok)throw new S(`Box session failed: ${i.status}`,i.status);let a=await i.json(),o=new Nt,l=[],d=0;for(;d<e.size;){r.signal?.throwIfAborted();let T=Math.min(d+a.part_size,e.size),C=new Uint8Array(await e.slice(d,T).arrayBuffer());o.update(C);let D=await ms(C),$=await this.retry(r,()=>this.fetch(a.session_endpoints.upload_part,{method:"PUT",headers:{...n,"Content-Type":"application/octet-stream",Digest:`sha=${D}`,"Content-Range":`bytes ${d}-${T-1}/${e.size}`},body:C,signal:r.signal}));if(!$.ok)throw new S(`Box part failed: ${$.status}`,$.status);l.push((await $.json()).part),d=T,s(d)}let f=await this.retry(r,()=>this.fetch(a.session_endpoints.commit,{method:"POST",headers:{...n,"Content-Type":"application/json",Digest:`sha=${Ge(o.digest())}`},body:JSON.stringify({parts:l}),signal:r.signal}));if(!f.ok)throw new S(`Box commit failed: ${f.status}`,f.status);return{providerFileId:(await f.json()).entries?.[0]?.id}}async retry(t,e){let r=0;for(;;)try{return await e()}catch(s){if(t.signal?.aborted||(r+=1,r>=We))throw s;await new Promise(n=>setTimeout(n,500*2**r))}}async driveUploadLoop(t,e,r,s){let n=t.uploadedBytes,i=Je(r.size,s);for(i(n);n<r.size;){s.signal?.throwIfAborted();let a=Math.min(n+t.chunkSize,r.size),o=r.slice(n,a),l=0;for(;;)try{let d=await this.fetch(e,{method:"PUT",headers:{"Content-Range":`bytes ${n}-${a-1}/${r.size}`},body:o,signal:s.signal});if(d.status===308){let f=d.headers.get("Range")??d.headers.get("range"),g=f?.match(/bytes=0-(\d+)/);g?n=Number(g[1])+1:f==null?n=0:n=(await this.getUploadSession(t.id,t.token)).uploadedBytes;break}if(d.ok){n=r.size;break}throw new S(`Drive chunk failed: ${d.status}`,d.status)}catch(d){if(s.signal?.aborted||(l+=1,l>=We))throw d;await new Promise(g=>setTimeout(g,500*2**l)),n=(await this.getUploadSession(t.id,t.token)).uploadedBytes}i(n)}}async s3PutUpload(t,e,r){let s=Je(e.size,r);s(0);let n=0;for(;;)try{let i=await this.fetch(t,{method:"PUT",headers:{"Content-Type":e.type||"application/octet-stream"},body:e,signal:r.signal});if(!i.ok)throw new S(`S3 upload failed: ${i.status}`,i.status);s(e.size);return}catch(i){if(r.signal?.aborted||(n+=1,n>=We))throw i;await new Promise(a=>setTimeout(a,500*2**n))}}};function Oe(t={}){return new Me(t)}var ys={id:"empty",blocks:[]},wt=!1;function vs(){wt||(wt=!0,console.warn("[fillo] This form has no `client`, so responses can't be submitted \u2014 it's render-only. Pass a client (createClient) to collect responses in Fillo, or forward them to your own backend with webhooks: https://fillo.so/docs"))}function St(t){let{onChange:e,onSubmitted:r}=t,s=t.form,n=t.formId,i=t.client,a={...t.initialData??{}},o={},l=0,d="idle",f=new Set,g=new Set,T=Date.now(),C=null,D=!1;function $(){let x=s.pages.length,N=Math.min(l,Math.max(x-1,0)),E=s.pages[N]??ys;return{data:a,errors:o,status:d,pageIndex:N,pageCount:x,page:E,blocks:Qe(E,a),isFirstPage:N===0,isLastPage:N===x-1,uploading:f.size>0}}let ot=$();function L(){ot=$();for(let x of g)x()}function lt(x,N){try{r?.(x,N)}catch(E){console.error("[fillo] onSubmitted handler threw:",E)}}function It(x){let N=s.pages[x];if(!N)return{};let E={};for(let ye of Qe(N,a)){if(!Ae(ye))continue;let dt=Tt(ye,a[ye.id]);dt&&(E[ye.id]=dt)}return E}function $t(x,N){!D&&i&&n&&(D=!0,i.startSession(n,s.pages.length).then(E=>C=E)),a={...a,[x]:N},e?.(a),x in o&&(o=Object.fromEntries(Object.entries(o).filter(([E])=>E!==x))),L()}function Lt(x,N){N?f.add(x):f.delete(x),L()}function jt(){let x=s.pages.length,N=Math.min(l,Math.max(x-1,0));if(!t.skipValidation){let E=It(N);if(o=E,Object.keys(E).length>0){L();return}}l=Math.min(N+1,x-1),C&&i&&i.reportProgress(C,{furthestPage:l}),L()}function Pt(){o={},l=Math.max(Math.min(l,s.pages.length-1)-1,0),L()}async function Mt(){if(d==="submitting"||d==="submitted")return;let x=as(s,a);if(!x.ok){o=x.errors;let N=s.pages.findIndex(E=>E.blocks.some(ye=>ye.id in x.errors));N>=0&&(l=N),L();return}if(i&&n){d="submitting",L();let N;try{N=await i.submit(n,x.data,{hp:t.getHoneypot?.()??"",elapsedMs:Date.now()-T,surface:t.surface??"default"})}catch(E){throw d="idle",L(),E}if(!N.ok){o=N.errors??{},d="idle",L();return}C&&i.reportProgress(C,{completed:!0}),d="submitted",L(),lt(N.responseId,x.data);return}if(t.skipValidation){d="submitted",L(),lt(void 0,x.data);return}vs(),d="error",L()}return{getState:()=>ot,subscribe(x){return g.add(x),()=>{g.delete(x)}},setValue:$t,setUploading:Lt,next:jt,back:Pt,submit:Mt,setContext(x){"formId"in x&&(n=x.formId),"client"in x&&(i=x.client),x.form&&x.form!==s&&(s=x.form,L())},destroy(){g.clear()}}}function et(t){return{id:t.id,theme:t.theme,schema:{version:1,title:t.title??"",description:t.description,pages:t.pages,settings:t.settings??{}},__filloCodeForm:!0}}function tt(t){return typeof t=="object"&&t!==null&&"__filloCodeForm"in t}var Ke=new Map;function bs(t){let e=5381;for(let r=0;r<t.length;r++)e=(e<<5)+e+t.charCodeAt(r)|0;return(e>>>0).toString(36)}function Et(t,e){let r=JSON.stringify(e.schema)+JSON.stringify(e.theme??null),s=`${t.baseUrl}:${t.key}:${e.id}:${bs(r)}`,n=Ke.get(s);return n||(n=t.syncForm(e.id,e.schema,e.theme??null),Ke.set(s,n),n.catch(()=>Ke.delete(s))),n}var _s=/\{\{\s*([\w-]+)\s*\}\}/g;function Ye(t,e,r){if(!t.includes("{{"))return t;let s=ss(r);return t.replace(_s,(n,i)=>{let a=s.find(d=>d.id===i),o=e[i];if(o==null||o==="")return"";let l=d=>a&&"options"in a?a.options.find(f=>f.id===d)?.label??d:d;return Array.isArray(o)?o.map(d=>l(String(d))).join(", "):typeof o=="string"?l(o):String(o)})}function Ft(t,e,r){let s=n=>n===void 0?n:Ye(n,e,r);switch(t.kind){case"heading":case"paragraph":return{...t,text:Ye(t.text,e,r)};case"divider":return t;default:return{...t,label:Ye(t.label,e,r),description:s(t.description)}}}var O="fillo-";function c(t,e={}){let r=document.createElement(t);e.className&&(r.className=e.className),e.text!==void 0&&(r.textContent=e.text);for(let[s,n]of Object.entries(e.attrs??{}))r.setAttribute(s,n);return r}function Ve(t,e){e&&(e.primary&&t.style.setProperty("--fillo-primary",e.primary),e.background&&t.style.setProperty("--fillo-bg",e.background),e.text&&t.style.setProperty("--fillo-text",e.text),e.radius&&t.style.setProperty("--fillo-radius",e.radius),e.fontFamily&&t.style.setProperty("--fillo-font",e.fontFamily))}function xs(t){return typeof t=="string"||typeof t=="number"?String(t):""}function V(t,e){for(let r of e)r&&t.appendChild(r);return t}function q(t,e,r){r&&t.setAttribute("aria-invalid","true"),e.required&&t.setAttribute("aria-required","true");let s=[e.description?`${O}${e.id}-desc`:null,r?`${O}${e.id}-error`:null].filter(Boolean).join(" ");s&&t.setAttribute("aria-describedby",s)}function z(t,e,r){let s=c("div",{className:`fillo-field fillo-field--${t.kind}${e?" fillo-field--error":""}`,attrs:{"data-field":t.id}}),n=c("label",{className:"fillo-label",text:t.label,attrs:{id:`${O}${t.id}-label`,for:`${O}${t.id}`}});return t.required||n.appendChild(c("span",{className:"fillo-optional",text:" (optional)"})),s.appendChild(n),t.description&&s.appendChild(c("p",{className:"fillo-description",text:t.description,attrs:{id:`${O}${t.id}-desc`}})),s.appendChild(r),e&&s.appendChild(c("p",{className:"fillo-error",text:e,attrs:{role:"alert",id:`${O}${t.id}-error`}})),s}function Ne(t,e){let r=c("input",{className:"fillo-input",attrs:{id:`${O}${e.field.id}`,type:t}});return r.value=xs(e.value),e.field.placeholder&&(r.placeholder=e.field.placeholder),r.addEventListener("input",()=>e.setValue(r.value,{render:!1})),r.addEventListener("change",()=>e.setValue(r.value)),q(r,e.field,e.error),z(e.field,e.error,r)}function ks(t){let e=c("textarea",{className:"fillo-input fillo-textarea",attrs:{id:`${O}${t.field.id}`,rows:"4"}});return e.value=typeof t.value=="string"?t.value:"",t.field.placeholder&&(e.placeholder=t.field.placeholder),e.addEventListener("input",()=>t.setValue(e.value,{render:!1})),e.addEventListener("change",()=>t.setValue(e.value)),q(e,t.field,t.error),z(t.field,t.error,e)}function ws(t){let e=t.field,r=it(e),s=typeof t.value=="string"?t.value:"",n=s!==""&&!e.options.some(a=>a.id===s),i=c("div",{className:"fillo-options",attrs:{role:"radiogroup","aria-labelledby":`${O}${e.id}-label`}});q(i,e,t.error);for(let a of r){let o=c("label",{className:`fillo-option${s===a.id?" fillo-option--selected":""}`,attrs:{"data-option":a.id}}),l=c("input",{className:"fillo-option-input",attrs:{type:"radio",name:`fillo-${e.id}`}});l.checked=s===a.id,l.addEventListener("change",()=>t.setValue(a.id)),V(o,[l,c("span",{className:"fillo-option-label",text:a.label})]),i.appendChild(o)}if(e.allowOther){let a=c("label",{className:`fillo-option${n?" fillo-option--selected":""}`}),o=c("input",{className:"fillo-option-input",attrs:{type:"radio",name:`fillo-${e.id}`}});if(o.checked=n,o.addEventListener("change",()=>t.setValue("",{render:!0})),a.appendChild(o),a.appendChild(c("span",{className:"fillo-option-label",text:"Other"})),n){let l=c("input",{className:"fillo-input fillo-other-input",attrs:{type:"text"}});l.value=s,l.placeholder="Your answer",l.addEventListener("input",()=>t.setValue(l.value,{render:!1})),l.addEventListener("change",()=>t.setValue(l.value)),a.appendChild(l)}i.appendChild(a)}return z(e,t.error,i)}function Cs(t){let e=t.field,r=it(e),s=Array.isArray(t.value)?t.value:[],n=new Set(e.options.map(l=>l.id)),i=s.find(l=>!n.has(l)),a=c("div",{className:"fillo-options",attrs:{role:"group","aria-labelledby":`${O}${e.id}-label`}});q(a,e,t.error);let o=l=>t.setValue(l);for(let l of r){let d=c("label",{className:`fillo-option${s.includes(l.id)?" fillo-option--selected":""}`,attrs:{"data-option":l.id}}),f=c("input",{className:"fillo-option-input",attrs:{type:"checkbox"}});f.checked=s.includes(l.id),f.addEventListener("change",()=>{o(f.checked?[...s,l.id]:s.filter(g=>g!==l.id))}),V(d,[f,c("span",{className:"fillo-option-label",text:l.label})]),a.appendChild(d)}if(e.allowOther){let l=i!==void 0,d=c("label",{className:`fillo-option${l?" fillo-option--selected":""}`}),f=c("input",{className:"fillo-option-input",attrs:{type:"checkbox"}});if(f.checked=l,f.addEventListener("change",()=>{let g=s.filter(T=>n.has(T));o(f.checked?[...g,i??""]:g)}),V(d,[f,c("span",{className:"fillo-option-label",text:"Other"})]),l){let g=c("input",{className:"fillo-input fillo-other-input",attrs:{type:"text"}});g.value=i??"",g.placeholder="Your answer",g.addEventListener("input",()=>{let T=s.filter(C=>n.has(C));t.setValue(g.value?[...T,g.value]:T,{render:!1})}),g.addEventListener("change",()=>{let T=s.filter(C=>n.has(C));t.setValue(g.value?[...T,g.value]:T)}),d.appendChild(g)}a.appendChild(d)}return z(e,t.error,a)}var rt="__fillo_other__";function Ts(t){let e=t.field,r=typeof t.value=="string"?t.value:"",s=r!==""&&!e.options.some(a=>a.id===r),n=c("div"),i=c("select",{className:"fillo-input fillo-select",attrs:{id:`${O}${e.id}`}});i.appendChild(c("option",{text:e.placeholder??"Choose...",attrs:{value:""}}));for(let a of it(e))i.appendChild(c("option",{text:a.label,attrs:{value:a.id}}));if(e.allowOther&&i.appendChild(c("option",{text:"Other...",attrs:{value:rt}})),i.value=s?rt:r,i.addEventListener("change",()=>{t.setValue(i.value===rt?"":i.value||null)}),q(i,e,t.error),n.appendChild(i),s){let a=c("input",{className:"fillo-input fillo-other-input fillo-other-input--block",attrs:{type:"text"}});a.value=r,a.placeholder="Your answer",a.addEventListener("input",()=>t.setValue(a.value,{render:!1})),a.addEventListener("change",()=>t.setValue(a.value)),n.appendChild(a)}return z(e,t.error,n)}function Ns(t){let e=c("div",{className:`fillo-field fillo-field--checkbox${t.error?" fillo-field--error":""}`,attrs:{"data-field":t.field.id}}),r=c("label",{className:"fillo-option"}),s=c("input",{className:"fillo-option-input",attrs:{id:`${O}${t.field.id}`,type:"checkbox"}});s.checked=t.value===!0,s.addEventListener("change",()=>t.setValue(s.checked)),q(s,t.field,t.error);let n=c("span",{className:"fillo-option-label",text:t.field.label});return t.field.required||n.appendChild(c("span",{className:"fillo-optional",text:" (optional)"})),V(r,[s,n]),e.appendChild(r),t.field.description&&e.appendChild(c("p",{className:"fillo-description",text:t.field.description,attrs:{id:`${O}${t.field.id}-desc`}})),t.error&&e.appendChild(c("p",{className:"fillo-error",text:t.error,attrs:{role:"alert",id:`${O}${t.field.id}-error`}})),e}function Ss(t){if(t.field.kind!=="rating")return c("div");let e=typeof t.field.max=="number"?t.field.max:5,r=typeof t.value=="number"?t.value:0,s=c("div",{className:"fillo-rating",attrs:{role:"radiogroup","aria-label":t.field.label}});q(s,t.field,t.error);for(let n=1;n<=e;n++){let i=c("button",{className:`fillo-star${n<=r?" fillo-star--active":""}`,text:"*",attrs:{type:"button","aria-label":`${n} of ${e}`,"aria-pressed":String(n===r)}});i.addEventListener("click",()=>t.setValue(n===r?null:n)),s.appendChild(i)}return z(t.field,t.error,s)}function Es(t){if(t.field.kind!=="linear_scale")return c("div");let e=typeof t.field.min=="number"?t.field.min:1,r=typeof t.field.max=="number"?t.field.max:10,s=c("div"),n=c("div",{className:"fillo-scale",attrs:{role:"radiogroup","aria-label":t.field.label}});q(n,t.field,t.error);for(let i=e;i<=r;i++){let a=c("button",{className:`fillo-scale-step${t.value===i?" fillo-scale-step--active":""}`,text:String(i),attrs:{type:"button","aria-pressed":String(t.value===i)}});a.addEventListener("click",()=>t.setValue(t.value===i?null:i)),n.appendChild(a)}return s.appendChild(n),("minLabel"in t.field||"maxLabel"in t.field)&&V(s,[V(c("div",{className:"fillo-scale-labels"}),[c("span",{text:String(t.field.minLabel??"")}),c("span",{text:String(t.field.maxLabel??"")})])]),z(t.field,t.error,s)}function Fs(t){let e=t.field;if(e.kind!=="ranking")return null;let r=Array.isArray(t.value)?t.value:[],s=[...r.filter(i=>e.options.some(a=>a.id===i)),...e.options.map(i=>i.id).filter(i=>!r.includes(i))],n=c("ol",{className:"fillo-ranking"});for(let[i,a]of s.entries()){let o=e.options.find(C=>C.id===a);if(!o)continue;let l=c("li",{className:"fillo-ranking-item"}),d=c("span",{className:"fillo-ranking-controls"}),f=C=>{let D=i+C;if(D<0||D>=s.length)return;let $=[...s];[$[i],$[D]]=[$[D],$[i]],t.setValue($)},g=c("button",{className:"fillo-ranking-move",text:"Up",attrs:{type:"button"}});g.toggleAttribute("disabled",i===0),g.addEventListener("click",()=>f(-1));let T=c("button",{className:"fillo-ranking-move",text:"Down",attrs:{type:"button"}});T.toggleAttribute("disabled",i===s.length-1),T.addEventListener("click",()=>f(1)),V(d,[g,T]),V(l,[c("span",{className:"fillo-ranking-index",text:String(i+1)}),c("span",{className:"fillo-ranking-label",text:o.label}),d]),n.appendChild(l)}return z(t.field,t.error,n)}function As(t){let e=t.field;if(e.kind!=="matrix")return null;let r=t.value&&typeof t.value=="object"&&!Array.isArray(t.value)?t.value:{},s=c("table",{className:"fillo-matrix"}),n=document.createElement("thead"),i=document.createElement("tr");i.appendChild(document.createElement("th"));for(let o of e.columns)i.appendChild(c("th",{text:o.label,attrs:{scope:"col"}}));n.appendChild(i),s.appendChild(n);let a=document.createElement("tbody");for(let o of e.rows){let l=document.createElement("tr");l.appendChild(c("th",{text:o.label,attrs:{scope:"row"}}));for(let d of e.columns){let f=document.createElement("td"),g=c("input",{className:"fillo-option-input",attrs:{type:"radio",name:`fillo-${e.id}-${o.id}`,"aria-label":`${o.label}: ${d.label}`}});g.checked=r[o.id]===d.id,g.addEventListener("change",()=>t.setValue({...r,[o.id]:d.id})),f.appendChild(g),l.appendChild(f)}a.appendChild(l)}return s.appendChild(a),z(t.field,t.error,V(c("div",{className:"fillo-matrix-wrap"}),[s]))}function Os(t){let e=c("div",{className:"fillo-signature"}),r=c("canvas",{className:"fillo-signature-canvas",attrs:{id:`${O}${t.field.id}`}});q(r,t.field,t.error);let s=c("button",{className:"fillo-signature-clear",text:"Clear",attrs:{type:"button"}}),n=c("div",{className:"fillo-signature-hint",text:"Sign here"});r.width=720,r.height=220;let i=r.getContext("2d"),a=!1,o=typeof t.value=="string"&&t.value.startsWith("data:image/");if(o&&i){let f=new Image;f.onload=()=>i.drawImage(f,0,0,r.width,r.height),f.src=String(t.value),n.style.display="none"}let l=f=>{let g=r.getBoundingClientRect();return{x:(f.clientX-g.left)/g.width*r.width,y:(f.clientY-g.top)/g.height*r.height}};r.addEventListener("pointerdown",f=>{if(!i)return;a=!0,o=!0,n.style.display="none",r.setPointerCapture(f.pointerId);let g=l(f);i.beginPath(),i.moveTo(g.x,g.y)}),r.addEventListener("pointermove",f=>{if(!a||!i)return;let g=l(f);i.lineWidth=2.4,i.lineCap="round",i.strokeStyle=getComputedStyle(r).color||"#18181b",i.lineTo(g.x,g.y),i.stroke()});let d=()=>{a&&(a=!1,o&&t.setValue(r.toDataURL("image/png")))};return r.addEventListener("pointerup",d),r.addEventListener("pointercancel",d),s.addEventListener("click",()=>{i?.clearRect(0,0,r.width,r.height),o=!1,n.style.display="",t.setValue(null)}),V(e,[r,n,s]),z(t.field,t.error,e)}function Rs(t){let e=t.field;if(e.kind!=="file_upload")return null;let r=c("input",{className:"fillo-input",attrs:{id:`${O}${e.id}`,type:"file"}});(e.maxFiles??1)>1&&(r.multiple=!0),e.accept?.length&&(r.accept=e.accept.join(",")),q(r,e,t.error),r.addEventListener("change",()=>{let a=Array.from(r.files??[]);t.uploadFiles?.(e,a)});let s=c("div");s.appendChild(r);let n=t.uploadProgress?.get(e.id);if(n!==void 0){let a=c("div",{className:"fillo-upload-progress"});a.appendChild(c("div",{className:"fillo-upload-progress-fill"})),a.firstElementChild?.style.setProperty("width",`${Math.round(n*100)}%`),s.appendChild(a)}let i=Array.isArray(t.value)?t.value:[];for(let a of i)s.appendChild(c("p",{className:"fillo-description",text:`${a.name} (${Math.round(a.size/1024)} KB)`}));return z(e,t.error,s)}var At=new Map;function it(t){if(!t.shuffleOptions)return t.options;let e=`${t.id}|${t.options.map(i=>i.id).join(",")}`,r=At.get(e);if(!r){r=t.options.map(i=>i.id);for(let i=r.length-1;i>0;i--){let a=Math.floor(Math.random()*(i+1));[r[i],r[a]]=[r[a],r[i]]}At.set(e,r)}let s=new Map(t.options.map(i=>[i.id,i])),n=r.flatMap(i=>s.get(i)??[]);return n.length===t.options.length?n:t.options}var Is={short_text:t=>Ne("text",t),email:t=>Ne("email",t),url:t=>Ne("url",t),phone:t=>Ne("tel",t),number:t=>Ne("number",t),date:t=>Ne("date",t),long_text:ks,select:ws,multi_select:Cs,dropdown:Ts,checkbox:Ns,rating:Ss,linear_scale:Es,ranking:Fs,matrix:As,signature:Os,file_upload:Rs};function $s(t){if(t.field.kind==="hidden"||t.field.kind==="custom")return null;let e=Is[t.field.kind];return e?e(t):null}var st=class{constructor(e,r){this.target=e;this.options=r;this.element.className="fillo-dom-root",e.replaceChildren(this.element),this.resolve()}target;options;element=c("div");schema=null;theme;formId;closed=!1;fetchedPoweredBy=null;fetchedBrandLabel;fetchedBrandHref;phase="loading";engine=null;destroyed=!1;renderQueued=!1;hpValue="";uploadProgress=new Map;get status(){return this.phase==="ready"?this.engine?.getState().status??"idle":this.phase}get data(){return this.engine?.getState().data??this.options.initialData??{}}get form(){return this.schema}get mutableData(){return this.engine?.getState().data??this.options.initialData??{}}api(){let e=this.schema??{version:1,title:"",pages:[],settings:{}},r=this.engine?.getState(),s=r?.pageCount??e.pages.length;return{form:e,formId:this.formId,client:this.options.client,data:r?.data??this.mutableData,errors:r?.errors??{},status:this.status,pageIndex:r?.pageIndex??0,pageCount:s,page:r?.page??e.pages[0]??{id:"empty",blocks:[]},blocks:r?.blocks??[],isFirstPage:r?.isFirstPage??!0,isLastPage:r?.isLastPage??s<=1,setValue:(n,i,a)=>this.setValueInternal(n,i,a),next:()=>this.next(),back:()=>this.back(),submit:()=>this.submit()}}async resolve(){try{let e=tt(this.options.form)?this.options.form:null;if(e){this.setSchema(e.schema,this.options.theme??e.theme,this.options.formId),this.options.client?.key&&Et(this.options.client,e).then(({formId:n,branding:i})=>{this.formId=n,this.engine?.setContext({formId:n}),i&&(this.fetchedPoweredBy=i.poweredBy,this.fetchedBrandLabel=i.label,this.fetchedBrandHref=i.href,this.render())}).catch(n=>this.handleError(De(n)));return}let r=this.options.form&&!tt(this.options.form)?this.options.form:null;if(r){this.setSchema(r,this.options.theme,this.options.formId);return}if(!this.options.formId)throw new S("Provide either `form`, or a `formId`.",0);this.options.client??=Oe(),this.render();let s=await this.options.client.getForm(this.options.formId);this.closed=!!s.closed,this.fetchedPoweredBy=s.branding?.poweredBy??null,this.fetchedBrandLabel=s.branding?.label,this.fetchedBrandHref=s.branding?.href,this.setSchema(s.schema,this.options.theme??s.theme??void 0,s.id)}catch(e){this.handleError(De(e))}}setSchema(e,r,s){this.schema=e,this.theme=r,this.formId=s,this.engine=St({form:e,formId:s,client:this.options.client,initialData:this.options.initialData,onChange:this.options.onChange,onSubmitted:this.options.onSubmitted,getHoneypot:()=>this.hpValue,surface:"default"}),this.phase=this.closed?"closed":"ready",this.render()}setValue(e,r){this.setValueInternal(e,r)}setValueInternal(e,r,s={}){this.engine?.setValue(e,r),s.render!==!1&&this.queueRender()}next(){this.engine&&(this.engine.next(),this.render())}back(){this.engine&&(this.engine.back(),this.render())}async submit(){if(!this.engine||this.phase!=="ready")return;let e=this.engine.submit();this.render();try{await e}catch(r){this.handleError(De(r));return}this.render()}async uploadFiles(e,r){if(!this.schema)return;let s=e.maxFiles??1,n=r.slice(0,s);this.uploadProgress.set(e.id,0),this.queueRender();try{let i=[];for(let[a,o]of n.entries())this.options.client&&this.formId?i.push(await this.options.client.uploadFile(this.formId,o,{fieldId:e.id,onProgress:l=>{this.uploadProgress.set(e.id,(a+l.fraction)/n.length),this.queueRender()}})):i.push({fileId:`local:${o.name}:${o.size}`,name:o.name,size:o.size,mime:o.type||"application/octet-stream"});this.uploadProgress.delete(e.id),this.setValueInternal(e.id,i)}catch(i){this.uploadProgress.delete(e.id),this.handleError(De(i))}}destroy(){this.destroyed=!0,this.target.replaceChildren()}handleError(e){this.phase="error",this.options.onError?.(e),this.render(e)}queueRender(){this.renderQueued||this.destroyed||(this.renderQueued=!0,queueMicrotask(()=>{this.renderQueued=!1,this.render()}))}render(e){if(!this.destroyed){if(this.element.replaceChildren(),this.phase==="loading"){let r=c("div",{className:`fillo-form fillo-form--loading ${this.options.className??""}`,attrs:{"aria-busy":"true"}});Ve(r,this.theme),V(r,[c("div",{className:"fillo-skeleton"}),c("div",{className:"fillo-skeleton"}),c("div",{className:"fillo-skeleton fillo-skeleton--short"})]),this.element.appendChild(r);return}if(this.phase==="error"&&e){this.element.appendChild(this.options.renderError?.(e)??c("div",{className:"fillo-form fillo-form--error",text:e.message}));return}if(this.phase==="closed"){let r=c("div",{className:`fillo-form fillo-form--closed ${this.options.className??""}`});Ve(r,this.theme),r.appendChild(c("p",{className:"fillo-closed",text:"This form is no longer accepting responses."})),this.element.appendChild(r);return}if(this.schema){if(this.engine?.getState().status==="submitted"){let r=this.api(),s=this.options.renderSuccess?.(r)??js(this.schema);Ve(s,this.theme),this.element.appendChild(s),this.brandingVisible()&&this.element.appendChild(Ot(this.fetchedBrandLabel,this.fetchedBrandHref));return}!this.options.client&&Ps()&&this.element.appendChild(Ms()),this.element.appendChild(this.renderForm()),this.brandingVisible()&&this.element.appendChild(Ot())}}}brandingVisible(){return this.options.poweredBy??this.fetchedPoweredBy??!0}renderForm(){let e=this.api(),r=c("form",{className:`fillo-form ${this.options.className??""}`});Ve(r,this.theme),r.noValidate=!0;let s=()=>{e.isLastPage?this.submit():this.next()};if(r.addEventListener("submit",l=>{l.preventDefault(),s()}),e.pageCount>1&&this.schema?.settings.showProgress!==!1){let l=c("div",{className:"fillo-progress-track",attrs:{role:"progressbar","aria-valuemin":"0","aria-valuemax":String(e.pageCount),"aria-valuenow":String(e.pageIndex+1)}});l.appendChild(c("div",{className:"fillo-progress-fill"})),l.firstElementChild?.style.setProperty("width",`${(e.pageIndex+1)/e.pageCount*100}%`),r.appendChild(l)}if(e.pageIndex===0){let l=c("header",{className:"fillo-header"});l.appendChild(c("h1",{className:"fillo-title",text:e.form.title})),e.form.description&&l.appendChild(c("p",{className:"fillo-form-description",text:e.form.description})),r.appendChild(l)}else e.page.title&&r.appendChild(c("h2",{className:"fillo-page-title",text:e.page.title}));let n=c("div",{className:"fillo-blocks"});for(let l of e.blocks){let d=this.renderBlock(Ft(l,this.mutableData,e.form),e);d&&n.appendChild(d)}r.appendChild(n);let i=c("input",{className:"fillo-hp",attrs:{type:"text",name:"fillo_hp_field",tabindex:"-1",autocomplete:"off","aria-hidden":"true"}});i.addEventListener("input",()=>{this.hpValue=i.value}),r.appendChild(i);let a=c("footer",{className:"fillo-footer"});if(e.pageCount>1&&!e.isFirstPage){let l=c("button",{className:"fillo-button fillo-button--ghost",text:"Back",attrs:{type:"button"}});l.addEventListener("click",()=>this.back()),a.appendChild(l)}let o=c("button",{className:"fillo-button fillo-button--primary",text:e.status==="submitting"?"Submitting...":e.isLastPage?e.form.settings.submitLabel??"Submit":"Next",attrs:{type:"submit"}});return o.toggleAttribute("disabled",e.status==="submitting"||this.uploadProgress.size>0),o.addEventListener("click",l=>{l.preventDefault(),s()}),a.appendChild(o),r.appendChild(a),r}renderBlock(e,r){if(!Ae(e))return Ls(e);let s=(a,o)=>this.setValueInternal(e.id,a,o),n={field:e,value:r.data[e.id],error:r.errors[e.id],api:r,setValue:s,uploadFiles:(a,o)=>this.uploadFiles(a,o),uploadProgress:this.uploadProgress};return(e.kind==="custom"?this.options.customComponents?.[e.component]??this.options.components?.custom:this.options.components?.[e.kind]??$s)?.(n)??null}};function Ls(t){switch(t.kind){case"heading":return c("h3",{className:"fillo-heading",text:t.text});case"paragraph":return c("p",{className:"fillo-paragraph",text:t.text});case"divider":return c("hr",{className:"fillo-divider"})}return c("div")}function js(t){let e=c("div",{className:"fillo-form fillo-form--success"}),r=c("div",{className:"fillo-success"});return V(r,[c("div",{className:"fillo-success-mark",text:"\u2713",attrs:{"aria-hidden":"true"}}),c("h2",{className:"fillo-success-title",text:t.settings.successTitle??"Thanks!"}),c("p",{className:"fillo-success-message",text:t.settings.successMessage??"Your response has been recorded."})]),e.appendChild(r),e}function Ot(t,e){let r=e??"https://fillo.so",s=`${r}${r.includes("?")?"&":"?"}utm_source=form_badge`;return c("a",{className:"fillo-powered",text:t??"Powered by Fillo",attrs:{href:s,target:"_blank",rel:"noopener"}})}function Ps(){return typeof process<"u"&&process.env?.NODE_ENV!=="production"}function Ms(){return c("div",{className:"fillo-devwarning",text:"No Fillo client connected \u2014 this form is render-only and won't save responses. Pass a client to collect them in Fillo, or forward with webhooks. (Shown only in development.)",attrs:{role:"alert"}})}function De(t){return t instanceof S?t:new S(t instanceof Error?t.message:String(t),0)}function Ue(t,e){let r=typeof t=="string"?document.querySelector(t):t;if(!r)throw new S(`Fillo mount target not found: ${String(t)}`,0);return new st(r,{...e,initialData:e.initialData??{}})}function Rt(t){let e=c("div");return Ue(e,t),e}var nt=class extends HTMLElement{instance=null;assignedForm;assignedClient;assignedTheme;assignedInitialData;static get observedAttributes(){return["publishable-key","form-id"]}connectedCallback(){this.mount()}disconnectedCallback(){this.instance?.destroy(),this.instance=null}attributeChangedCallback(){this.isConnected&&this.mount()}set form(e){this.assignedForm=e,this.isConnected&&this.mount()}get form(){return this.assignedForm}set client(e){this.assignedClient=e,this.isConnected&&this.mount()}set theme(e){this.assignedTheme=e,this.isConnected&&this.mount()}set initialData(e){this.assignedInitialData=e,this.isConnected&&this.mount()}mount(){this.instance?.destroy();let e=this.getAttribute("publishable-key")??void 0,r=this.getAttribute("form-id")??void 0,s=this.assignedClient??(r||e?Oe({key:e}):void 0);this.instance=Ue(this,{form:this.assignedForm,client:s,formId:r,theme:this.assignedTheme,initialData:this.assignedInitialData,onChange:n=>this.dispatchEvent(new CustomEvent("fillo-change",{detail:{data:n}})),onSubmitted:(n,i)=>this.dispatchEvent(new CustomEvent("fillo-submit",{detail:{responseId:n,data:i}})),onError:n=>this.dispatchEvent(new CustomEvent("fillo-error",{detail:{error:n}}))})}};function at(t="fillo-form"){customElements.get(t)||customElements.define(t,nt)}at();return Zt(Vs);})();
1
+ "use strict";var Fillo=(()=>{var ht=Object.defineProperty;var vr=Object.getOwnPropertyDescriptor;var br=Object.getOwnPropertyNames;var _r=Object.prototype.hasOwnProperty;var jt=(t,e)=>{for(var r in e)ht(t,r,{get:e[r],enumerable:!0})},kr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of br(e))!_r.call(t,s)&&s!==r&&ht(t,s,{get:()=>e[s],enumerable:!(n=vr(e,s))||n.enumerable});return t};var xr=t=>kr(ht({},"__esModule",{value:!0}),t);var zs={};jt(zs,{FilloClient:()=>lt,FilloError:()=>O,createClient:()=>Ye,createFormElement:()=>yr,defineForm:()=>It,registerFilloElement:()=>Pt,renderForm:()=>ut});var F={};jt(F,{BRAND:()=>Kr,DIRTY:()=>me,EMPTY_PATH:()=>Nr,INVALID:()=>v,NEVER:()=>Rn,OK:()=>j,ParseStatus:()=>M,Schema:()=>w,ZodAny:()=>fe,ZodArray:()=>ae,ZodBigInt:()=>ye,ZodBoolean:()=>ve,ZodBranded:()=>Ze,ZodCatch:()=>Fe,ZodDate:()=>be,ZodDefault:()=>Ee,ZodDiscriminatedUnion:()=>et,ZodEffects:()=>q,ZodEnum:()=>Ne,ZodError:()=>D,ZodFirstPartyTypeKind:()=>b,ZodFunction:()=>rt,ZodIntersection:()=>we,ZodIssueCode:()=>f,ZodLazy:()=>Ce,ZodLiteral:()=>Se,ZodMap:()=>Ve,ZodNaN:()=>Ue,ZodNativeEnum:()=>Te,ZodNever:()=>J,ZodNull:()=>ke,ZodNullable:()=>X,ZodNumber:()=>ge,ZodObject:()=>U,ZodOptional:()=>Z,ZodParsedType:()=>p,ZodPipeline:()=>He,ZodPromise:()=>he,ZodReadonly:()=>Ie,ZodRecord:()=>tt,ZodSchema:()=>w,ZodSet:()=>De,ZodString:()=>ue,ZodSymbol:()=>Pe,ZodTransformer:()=>q,ZodTuple:()=>Q,ZodType:()=>w,ZodUndefined:()=>_e,ZodUnion:()=>xe,ZodUnknown:()=>ie,ZodVoid:()=>je,addIssueToContext:()=>h,any:()=>nn,array:()=>ln,bigint:()=>Qr,boolean:()=>Jt,coerce:()=>On,custom:()=>qt,date:()=>Xr,datetimeRegex:()=>Zt,defaultErrorMap:()=>ne,discriminatedUnion:()=>fn,effect:()=>Cn,enum:()=>kn,function:()=>vn,getErrorMap:()=>Le,getParsedType:()=>G,instanceof:()=>Yr,intersection:()=>hn,isAborted:()=>Qe,isAsync:()=>$e,isDirty:()=>Xe,isValid:()=>ce,late:()=>Jr,lazy:()=>bn,literal:()=>_n,makeIssue:()=>Be,map:()=>gn,nan:()=>Gr,nativeEnum:()=>xn,never:()=>an,null:()=>rn,nullable:()=>Nn,number:()=>Kt,object:()=>dn,objectUtil:()=>pt,oboolean:()=>An,onumber:()=>In,optional:()=>Sn,ostring:()=>Fn,pipeline:()=>En,preprocess:()=>Tn,promise:()=>wn,quotelessJson:()=>wr,record:()=>mn,set:()=>yn,setErrorMap:()=>Sr,strictObject:()=>cn,string:()=>Wt,symbol:()=>en,transformer:()=>Cn,tuple:()=>pn,undefined:()=>tn,union:()=>un,unknown:()=>sn,util:()=>N,void:()=>on});var N;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let i={};for(let a of s)i[a]=a;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(let o of i)a[o]=s[o];return t.objectValues(a)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},t.find=(s,i)=>{for(let a of s)if(i(a))return a},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}t.joinValues=n,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(N||(N={}));var pt;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(pt||(pt={}));var p=N.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),G=t=>{switch(typeof t){case"undefined":return p.undefined;case"string":return p.string;case"number":return Number.isNaN(t)?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(t)?p.array:t===null?p.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?p.promise:typeof Map<"u"&&t instanceof Map?p.map:typeof Set<"u"&&t instanceof Set?p.set:typeof Date<"u"&&t instanceof Date?p.date:p.object;default:return p.unknown}};var f=N.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"]),wr=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),D=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(i){return i.message},n={_errors:[]},s=i=>{for(let a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let o=n,d=0;for(;d<a.path.length;){let l=a.path[d];d===a.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(a))):o[l]=o[l]||{_errors:[]},o=o[l],d++}}};return s(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,N.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];r[i]=r[i]||[],r[i].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};D.create=t=>new D(t);var Cr=(t,e)=>{let r;switch(t.code){case f.invalid_type:t.received===p.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case f.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,N.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:r=`Unrecognized key(s) in object: ${N.joinValues(t.keys,", ")}`;break;case f.invalid_union:r="Invalid input";break;case f.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${N.joinValues(t.options)}`;break;case f.invalid_enum_value:r=`Invalid enum value. Expected ${N.joinValues(t.options)}, received '${t.received}'`;break;case f.invalid_arguments:r="Invalid function arguments";break;case f.invalid_return_type:r="Invalid function return type";break;case f.invalid_date:r="Invalid date";break;case f.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:N.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case f.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case f.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case f.custom:r="Invalid input";break;case f.invalid_intersection_types:r="Intersection results could not be merged";break;case f.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case f.not_finite:r="Number must be finite";break;default:r=e.defaultError,N.assertNever(t)}return{message:r}},ne=Cr;var Vt=ne;function Sr(t){Vt=t}function Le(){return Vt}var Be=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,i=[...r,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="",d=n.filter(l=>!!l).slice().reverse();for(let l of d)o=l(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},Nr=[];function h(t,e){let r=Le(),n=Be({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===ne?void 0:ne].filter(s=>!!s)});t.common.issues.push(n)}var M=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return v;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r){let i=await s.key,a=await s.value;n.push({key:i,value:a})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return v;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}},v=Object.freeze({status:"aborted"}),me=t=>({status:"dirty",value:t}),j=t=>({status:"valid",value:t}),Qe=t=>t.status==="aborted",Xe=t=>t.status==="dirty",ce=t=>t.status==="valid",$e=t=>typeof Promise<"u"&&t instanceof Promise;var g;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(g||(g={}));var H=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}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}},Dt=(t,e)=>{if(ce(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new D(t.common.issues);return this._error=r,this._error}}};function k(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))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:(a,o)=>{let{message:d}=t;return a.code==="invalid_enum_value"?{message:d??o.defaultError}:typeof o.data>"u"?{message:d??n??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:d??r??o.defaultError}},description:s}}var w=class{get description(){return this._def.description}_getType(e){return G(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:G(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new M,ctx:{common:e.parent.common,data:e.data,parsedType:G(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if($e(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:G(e)},s=this._parseSync({data:e,path:n.path,parent:n});return Dt(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:G(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return ce(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>ce(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:G(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await($e(s)?s:Promise.resolve(s));return Dt(n,i)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,i)=>{let a=e(s),o=()=>i.addIssue({code:f.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(d=>d?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new q({schema:this,typeName:b.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:r=>this["~validate"](r)}}optional(){return Z.create(this,this._def)}nullable(){return X.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ae.create(this)}promise(){return he.create(this,this._def)}or(e){return xe.create([this,e],this._def)}and(e){return we.create(this,e,this._def)}transform(e){return new q({...k(this._def),schema:this,typeName:b.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Ee({...k(this._def),innerType:this,defaultValue:r,typeName:b.ZodDefault})}brand(){return new Ze({typeName:b.ZodBranded,type:this,...k(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Fe({...k(this._def),innerType:this,catchValue:r,typeName:b.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return He.create(this,e)}readonly(){return Ie.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Tr=/^c[^\s-]{8,}$/i,Er=/^[0-9a-z]+$/,Fr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ir=/^[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,Ar=/^[a-z0-9_-]{21}$/i,Or=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Rr=/^[-+]?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)?)??$/,Lr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,$r="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",mt,Mr=/^(?:(?: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])$/,Pr=/^(?:(?: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])$/,jr=/^(([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]))$/,Vr=/^(([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])$/,Dr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ur=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,zt="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",zr=new RegExp(`^${zt}$`);function Bt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function Br(t){return new RegExp(`^${Bt(t)}$`)}function Zt(t){let e=`${zt}T${Bt(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function Zr(t,e){return!!((e==="v4"||!e)&&Mr.test(t)||(e==="v6"||!e)&&jr.test(t))}function Hr(t,e){if(!Or.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function qr(t,e){return!!((e==="v4"||!e)&&Pr.test(t)||(e==="v6"||!e)&&Vr.test(t))}var ue=class t extends w{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){let i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_type,expected:p.string,received:i.parsedType}),v}let n=new M,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:f.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?h(s,{code:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&h(s,{code:f.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Lr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"email",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")mt||(mt=new RegExp($r,"u")),mt.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"emoji",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Ir.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"uuid",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")Ar.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"nanoid",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")Tr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cuid",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")Er.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cuid2",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Fr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"ulid",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),h(s,{validation:"url",code:f.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"regex",code:f.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Zt(i).test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?zr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?Br(i).test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?Rr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"duration",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?Zr(e.data,i.version)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"ip",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?Hr(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"jwt",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?qr(e.data,i.version)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cidr",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?Dr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?Ur.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64url",code:f.invalid_string,message:i.message}),n.dirty()):N.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:f.invalid_string,...g.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...g.errToObj(e)})}url(e){return this._addCheck({kind:"url",...g.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...g.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...g.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...g.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...g.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...g.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...g.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...g.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...g.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...g.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...g.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...g.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,...g.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,...g.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...g.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...g.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...g.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...g.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...g.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...g.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...g.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...g.errToObj(r)})}nonempty(e){return this.min(1,g.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};ue.create=t=>new ue({checks:[],typeName:b.ZodString,coerce:t?.coerce??!1,...k(t)});function Wr(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return i%a/10**s}var ge=class t 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){let i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_type,expected:p.number,received:i.parsedType}),v}let n,s=new M;for(let i of this._def.checks)i.kind==="int"?N.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:f.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),h(n,{code:f.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),h(n,{code:f.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Wr(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),h(n,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:f.not_finite,message:i.message}),s.dirty()):N.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,g.toString(r))}gt(e,r){return this.setLimit("min",e,!1,g.toString(r))}lte(e,r){return this.setLimit("max",e,!0,g.toString(r))}lt(e,r){return this.setLimit("max",e,!1,g.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:g.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:g.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:g.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:g.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:g.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:g.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&N.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};ge.create=t=>new ge({checks:[],typeName:b.ZodNumber,coerce:t?.coerce||!1,...k(t)});var ye=class t 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{return this._getInvalidInput(e)}if(this._getType(e)!==p.bigint)return this._getInvalidInput(e);let n,s=new M;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),h(n,{code:f.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),h(n,{code:f.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),h(n,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):N.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:p.bigint,received:r.parsedType}),v}gte(e,r){return this.setLimit("min",e,!0,g.toString(r))}gt(e,r){return this.setLimit("min",e,!1,g.toString(r))}lte(e,r){return this.setLimit("max",e,!0,g.toString(r))}lt(e,r){return this.setLimit("max",e,!1,g.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:g.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:g.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};ye.create=t=>new ye({checks:[],typeName:b.ZodBigInt,coerce:t?.coerce??!1,...k(t)});var ve=class extends w{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){let n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:p.boolean,received:n.parsedType}),v}return j(e.data)}};ve.create=t=>new ve({typeName:b.ZodBoolean,coerce:t?.coerce||!1,...k(t)});var be=class t extends w{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){let i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_type,expected:p.date,received:i.parsedType}),v}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_date}),v}let n=new M,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:f.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:f.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):N.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:g.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:g.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};be.create=t=>new be({checks:[],coerce:t?.coerce||!1,typeName:b.ZodDate,...k(t)});var Pe=class extends w{_parse(e){if(this._getType(e)!==p.symbol){let n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:p.symbol,received:n.parsedType}),v}return j(e.data)}};Pe.create=t=>new Pe({typeName:b.ZodSymbol,...k(t)});var _e=class extends w{_parse(e){if(this._getType(e)!==p.undefined){let n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:p.undefined,received:n.parsedType}),v}return j(e.data)}};_e.create=t=>new _e({typeName:b.ZodUndefined,...k(t)});var ke=class extends w{_parse(e){if(this._getType(e)!==p.null){let n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:p.null,received:n.parsedType}),v}return j(e.data)}};ke.create=t=>new ke({typeName:b.ZodNull,...k(t)});var fe=class extends w{constructor(){super(...arguments),this._any=!0}_parse(e){return j(e.data)}};fe.create=t=>new fe({typeName:b.ZodAny,...k(t)});var ie=class extends w{constructor(){super(...arguments),this._unknown=!0}_parse(e){return j(e.data)}};ie.create=t=>new ie({typeName:b.ZodUnknown,...k(t)});var J=class extends w{_parse(e){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:p.never,received:r.parsedType}),v}};J.create=t=>new J({typeName:b.ZodNever,...k(t)});var je=class extends w{_parse(e){if(this._getType(e)!==p.undefined){let n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:p.void,received:n.parsedType}),v}return j(e.data)}};je.create=t=>new je({typeName:b.ZodVoid,...k(t)});var ae=class t extends w{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==p.array)return h(r,{code:f.invalid_type,expected:p.array,received:r.parsedType}),v;if(s.exactLength!==null){let a=r.data.length>s.exactLength.value,o=r.data.length<s.exactLength.value;(a||o)&&(h(r,{code:a?f.too_big:f.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(h(r,{code:f.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(h(r,{code:f.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,o)=>s.type._parseAsync(new H(r,a,r.path,o)))).then(a=>M.mergeArray(n,a));let i=[...r.data].map((a,o)=>s.type._parseSync(new H(r,a,r.path,o)));return M.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:g.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:g.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:g.toString(r)}})}nonempty(e){return this.min(1,e)}};ae.create=(t,e)=>new ae({type:t,minLength:null,maxLength:null,exactLength:null,typeName:b.ZodArray,...k(e)});function Me(t){if(t instanceof U){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=Z.create(Me(n))}return new U({...t._def,shape:()=>e})}else return t instanceof ae?new ae({...t._def,type:Me(t.element)}):t instanceof Z?Z.create(Me(t.unwrap())):t instanceof X?X.create(Me(t.unwrap())):t instanceof Q?Q.create(t.items.map(e=>Me(e))):t}var U=class t extends w{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(),r=N.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==p.object){let l=this._getOrReturnCtx(e);return h(l,{code:f.invalid_type,expected:p.object,received:l.parsedType}),v}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof J&&this._def.unknownKeys==="strip"))for(let l in s.data)a.includes(l)||o.push(l);let d=[];for(let l of a){let c=i[l],y=s.data[l];d.push({key:{status:"valid",value:l},value:c._parse(new H(s,y,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof J){let l=this._def.unknownKeys;if(l==="passthrough")for(let c of o)d.push({key:{status:"valid",value:c},value:{status:"valid",value:s.data[c]}});else if(l==="strict")o.length>0&&(h(s,{code:f.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let c of o){let y=s.data[c];d.push({key:{status:"valid",value:c},value:l._parse(new H(s,y,s.path,c)),alwaysSet:c in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let c of d){let y=await c.key,T=await c.value;l.push({key:y,value:T,alwaysSet:c.alwaysSet})}return l}).then(l=>M.mergeObjectSync(n,l)):M.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return g.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:g.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:b.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of N.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of N.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Me(this)}partial(e){let r={};for(let n of N.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of N.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof Z;)i=i._def.innerType;r[n]=i}return new t({...this._def,shape:()=>r})}keyof(){return Ht(N.objectKeys(this.shape))}};U.create=(t,e)=>new U({shape:()=>t,unknownKeys:"strip",catchall:J.create(),typeName:b.ZodObject,...k(e)});U.strictCreate=(t,e)=>new U({shape:()=>t,unknownKeys:"strict",catchall:J.create(),typeName:b.ZodObject,...k(e)});U.lazycreate=(t,e)=>new U({shape:t,unknownKeys:"strip",catchall:J.create(),typeName:b.ZodObject,...k(e)});var xe=class extends w{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(i){for(let o of i)if(o.result.status==="valid")return o.result;for(let o of i)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;let a=i.map(o=>new D(o.ctx.common.issues));return h(r,{code:f.invalid_union,unionErrors:a}),v}if(r.common.async)return Promise.all(n.map(async i=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(s);{let i,a=[];for(let d of n){let l={...r,common:{...r.common,issues:[]},parent:null},c=d._parseSync({data:r.data,path:r.path,parent:l});if(c.status==="valid")return c;c.status==="dirty"&&!i&&(i={result:c,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let o=a.map(d=>new D(d));return h(r,{code:f.invalid_union,unionErrors:o}),v}}get options(){return this._def.options}};xe.create=(t,e)=>new xe({options:t,typeName:b.ZodUnion,...k(e)});var se=t=>t instanceof Ce?se(t.schema):t instanceof q?se(t.innerType()):t instanceof Se?[t.value]:t instanceof Ne?t.options:t instanceof Te?N.objectValues(t.enum):t instanceof Ee?se(t._def.innerType):t instanceof _e?[void 0]:t instanceof ke?[null]:t instanceof Z?[void 0,...se(t.unwrap())]:t instanceof X?[null,...se(t.unwrap())]:t instanceof Ze||t instanceof Ie?se(t.unwrap()):t instanceof Fe?se(t._def.innerType):[],et=class t extends w{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.object)return h(r,{code:f.invalid_type,expected:p.object,received:r.parsedType}),v;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(h(r,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=new Map;for(let i of r){let a=se(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new t({typeName:b.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...k(n)})}};function gt(t,e){let r=G(t),n=G(e);if(t===e)return{valid:!0,data:t};if(r===p.object&&n===p.object){let s=N.objectKeys(e),i=N.objectKeys(t).filter(o=>s.indexOf(o)!==-1),a={...t,...e};for(let o of i){let d=gt(t[o],e[o]);if(!d.valid)return{valid:!1};a[o]=d.data}return{valid:!0,data:a}}else if(r===p.array&&n===p.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let a=t[i],o=e[i],d=gt(a,o);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return r===p.date&&n===p.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var we=class extends w{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Qe(i)||Qe(a))return v;let o=gt(i.value,a.value);return o.valid?((Xe(i)||Xe(a))&&r.dirty(),{status:r.value,value:o.data}):(h(n,{code:f.invalid_intersection_types}),v)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};we.create=(t,e,r)=>new we({left:t,right:e,typeName:b.ZodIntersection,...k(r)});var Q=class t extends w{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.array)return h(n,{code:f.invalid_type,expected:p.array,received:n.parsedType}),v;if(n.data.length<this._def.items.length)return h(n,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&n.data.length>this._def.items.length&&(h(n,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((a,o)=>{let d=this._def.items[o]||this._def.rest;return d?d._parse(new H(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>M.mergeArray(r,a)):M.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Q.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Q({items:t,typeName:b.ZodTuple,rest:null,...k(e)})};var tt=class t extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.object)return h(n,{code:f.invalid_type,expected:p.object,received:n.parsedType}),v;let s=[],i=this._def.keyType,a=this._def.valueType;for(let o in n.data)s.push({key:i._parse(new H(n,o,n.path,o)),value:a._parse(new H(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?M.mergeObjectAsync(r,s):M.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof w?new t({keyType:e,valueType:r,typeName:b.ZodRecord,...k(n)}):new t({keyType:ue.create(),valueType:e,typeName:b.ZodRecord,...k(r)})}},Ve=class extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.map)return h(n,{code:f.invalid_type,expected:p.map,received:n.parsedType}),v;let s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,d],l)=>({key:s._parse(new H(n,o,n.path,[l,"key"])),value:i._parse(new H(n,d,n.path,[l,"value"]))}));if(n.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let d of a){let l=await d.key,c=await d.value;if(l.status==="aborted"||c.status==="aborted")return v;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}})}else{let o=new Map;for(let d of a){let l=d.key,c=d.value;if(l.status==="aborted"||c.status==="aborted")return v;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}}}};Ve.create=(t,e,r)=>new Ve({valueType:e,keyType:t,typeName:b.ZodMap,...k(r)});var De=class t extends w{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.set)return h(n,{code:f.invalid_type,expected:p.set,received:n.parsedType}),v;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(h(n,{code:f.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(h(n,{code:f.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function a(d){let l=new Set;for(let c of d){if(c.status==="aborted")return v;c.status==="dirty"&&r.dirty(),l.add(c.value)}return{status:r.value,value:l}}let o=[...n.data.values()].map((d,l)=>i._parse(new H(n,d,n.path,l)));return n.common.async?Promise.all(o).then(d=>a(d)):a(o)}min(e,r){return new t({...this._def,minSize:{value:e,message:g.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:g.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};De.create=(t,e)=>new De({valueType:t,minSize:null,maxSize:null,typeName:b.ZodSet,...k(e)});var rt=class t extends w{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.function)return h(r,{code:f.invalid_type,expected:p.function,received:r.parsedType}),v;function n(o,d){return Be({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Le(),ne].filter(l=>!!l),issueData:{code:f.invalid_arguments,argumentsError:d}})}function s(o,d){return Be({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Le(),ne].filter(l=>!!l),issueData:{code:f.invalid_return_type,returnTypeError:d}})}let i={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof he){let o=this;return j(async function(...d){let l=new D([]),c=await o._def.args.parseAsync(d,i).catch(x=>{throw l.addIssue(n(d,x)),l}),y=await Reflect.apply(a,this,c);return await o._def.returns._def.type.parseAsync(y,i).catch(x=>{throw l.addIssue(s(y,x)),l})})}else{let o=this;return j(function(...d){let l=o._def.args.safeParse(d,i);if(!l.success)throw new D([n(d,l.error)]);let c=Reflect.apply(a,this,l.data),y=o._def.returns.safeParse(c,i);if(!y.success)throw new D([s(c,y.error)]);return y.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Q.create(e).rest(ie.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||Q.create([]).rest(ie.create()),returns:r||ie.create(),typeName:b.ZodFunction,...k(n)})}},Ce=class extends w{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Ce.create=(t,e)=>new Ce({getter:t,typeName:b.ZodLazy,...k(e)});var Se=class extends w{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return h(r,{received:r.data,code:f.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}};Se.create=(t,e)=>new Se({value:t,typeName:b.ZodLiteral,...k(e)});function Ht(t,e){return new Ne({values:t,typeName:b.ZodEnum,...k(e)})}var Ne=class t extends w{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return h(r,{expected:N.joinValues(n),received:r.parsedType,code:f.invalid_type}),v}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return h(r,{received:r.data,code:f.invalid_enum_value,options:n}),v}return j(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};Ne.create=Ht;var Te=class extends w{_parse(e){let r=N.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==p.string&&n.parsedType!==p.number){let s=N.objectValues(r);return h(n,{expected:N.joinValues(s),received:n.parsedType,code:f.invalid_type}),v}if(this._cache||(this._cache=new Set(N.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=N.objectValues(r);return h(n,{received:n.data,code:f.invalid_enum_value,options:s}),v}return j(e.data)}get enum(){return this._def.values}};Te.create=(t,e)=>new Te({values:t,typeName:b.ZodNativeEnum,...k(e)});var he=class extends w{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.promise&&r.common.async===!1)return h(r,{code:f.invalid_type,expected:p.promise,received:r.parsedType}),v;let n=r.parsedType===p.promise?r.data:Promise.resolve(r.data);return j(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};he.create=(t,e)=>new he({type:t,typeName:b.ZodPromise,...k(e)});var q=class extends w{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===b.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{h(n,a),a.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(r.value==="aborted")return v;let d=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return d.status==="aborted"?v:d.status==="dirty"?me(d.value):r.value==="dirty"?me(d.value):d});{if(r.value==="aborted")return v;let o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?v:o.status==="dirty"?me(o.value):r.value==="dirty"?me(o.value):o}}if(s.type==="refinement"){let a=o=>{let d=s.refinement(o,i);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?v:(o.status==="dirty"&&r.dirty(),a(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?v:(o.status==="dirty"&&r.dirty(),a(o.value).then(()=>({status:r.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ce(a))return v;let o=s.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>ce(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:r.value,value:o})):v);N.assertNever(s)}};q.create=(t,e,r)=>new q({schema:t,typeName:b.ZodEffects,effect:e,...k(r)});q.createWithPreprocess=(t,e,r)=>new q({schema:e,effect:{type:"preprocess",transform:t},typeName:b.ZodEffects,...k(r)});var Z=class extends w{_parse(e){return this._getType(e)===p.undefined?j(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Z.create=(t,e)=>new Z({innerType:t,typeName:b.ZodOptional,...k(e)});var X=class extends w{_parse(e){return this._getType(e)===p.null?j(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};X.create=(t,e)=>new X({innerType:t,typeName:b.ZodNullable,...k(e)});var Ee=class extends w{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===p.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Ee.create=(t,e)=>new Ee({innerType:t,typeName:b.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...k(e)});var Fe=class extends w{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return $e(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new D(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new D(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Fe.create=(t,e)=>new Fe({innerType:t,typeName:b.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...k(e)});var Ue=class extends w{_parse(e){if(this._getType(e)!==p.nan){let n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:p.nan,received:n.parsedType}),v}return{status:"valid",value:e.data}}};Ue.create=t=>new Ue({typeName:b.ZodNaN,...k(t)});var Kr=Symbol("zod_brand"),Ze=class extends w{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},He=class t extends w{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?v:i.status==="dirty"?(r.dirty(),me(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?v:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:b.ZodPipeline})}},Ie=class extends w{_parse(e){let r=this._def.innerType._parse(e),n=s=>(ce(s)&&(s.value=Object.freeze(s.value)),s);return $e(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};Ie.create=(t,e)=>new Ie({innerType:t,typeName:b.ZodReadonly,...k(e)});function Ut(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function qt(t,e={},r){return t?fe.create().superRefine((n,s)=>{let i=t(n);if(i instanceof Promise)return i.then(a=>{if(!a){let o=Ut(e,n),d=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:d})}});if(!i){let a=Ut(e,n),o=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:o})}}):fe.create()}var Jr={object:U.lazycreate},b;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(b||(b={}));var Yr=(t,e={message:`Input not instance of ${t.name}`})=>qt(r=>r instanceof t,e),Wt=ue.create,Kt=ge.create,Gr=Ue.create,Qr=ye.create,Jt=ve.create,Xr=be.create,en=Pe.create,tn=_e.create,rn=ke.create,nn=fe.create,sn=ie.create,an=J.create,on=je.create,ln=ae.create,dn=U.create,cn=U.strictCreate,un=xe.create,fn=et.create,hn=we.create,pn=Q.create,mn=tt.create,gn=Ve.create,yn=De.create,vn=rt.create,bn=Ce.create,_n=Se.create,kn=Ne.create,xn=Te.create,wn=he.create,Cn=q.create,Sn=Z.create,Nn=X.create,Tn=q.createWithPreprocess,En=He.create,Fn=()=>Wt().optional(),In=()=>Kt().optional(),An=()=>Jt().optional(),On={string:(t=>ue.create({...t,coerce:!0})),number:(t=>ge.create({...t,coerce:!0})),boolean:(t=>ve.create({...t,coerce:!0})),bigint:(t=>ye.create({...t,coerce:!0})),date:(t=>be.create({...t,coerce:!0}))};var Rn=v;var Ln=["heading","paragraph","divider"];function Oe(t){return!Ln.includes(t.kind)}function Yt(t){return t==null?!1:typeof t=="string"?t.trim()!=="":Array.isArray(t)?t.length>0:typeof t=="boolean"?t:typeof t=="object"?Object.keys(t).length>0:!0}function $n(t,e){let r=e[t.fieldId];switch(t.op){case"answered":return Yt(r);case"not_answered":return!Yt(r);case"eq":return Array.isArray(r)?r.some(n=>n===t.value):r===t.value;case"neq":return Array.isArray(r)?!r.some(n=>n===t.value):r!==t.value;case"contains":return typeof r=="string"?r.toLowerCase().includes(String(t.value??"").toLowerCase()):Array.isArray(r)?r.some(n=>n===t.value):!1;case"gt":return typeof r=="number"&&r>Number(t.value);case"lt":return typeof r=="number"&&r<Number(t.value)}}function Mn(t,e){return!t.visibleIf||t.visibleIf.length===0?!0:t.visibleIf.every(r=>$n(r,e))}function it(t,e){return t.blocks.filter(r=>Mn(r,e))}function Pn(t){return t.pages.flatMap(e=>e.blocks.filter(Oe))}function jn(t,e){return t.pages.flatMap(r=>it(r,e).filter(Oe))}var m=(t,e,r,n=[],s=[],i="")=>({iso2:t,name:e,dialCode:r,lengths:n,groups:s,example:i}),oe=[m("US","United States","1",[10],[3,3,4],"2015550123"),m("CA","Canada","1",[10],[3,3,4],"5145550123"),m("GB","United Kingdom","44",[10],[4,6],"7400123456"),m("AU","Australia","61",[9],[3,3,3],"412345678"),m("DE","Germany","49",[10,11],[4,7],"15123456789"),m("FR","France","33",[9],[1,2,2,2,2],"612345678"),m("IN","India","91",[10],[5,5],"8123456789"),m("DK","Denmark","45",[8],[2,2,2,2],"32123456"),m("SE","Sweden","46",[9],[2,3,4],"701234567"),m("NO","Norway","47",[8],[3,2,3],"40612345"),m("FI","Finland","358",[9,10],[2,3,4],"412345678"),m("NL","Netherlands","31",[9],[1,4,4],"612345678"),m("BE","Belgium","32",[9],[3,2,2,2],"470123456"),m("ES","Spain","34",[9],[3,3,3],"612345678"),m("IT","Italy","39",[9,10],[3,3,4],"3123456789"),m("PT","Portugal","351",[9],[3,3,3],"912345678"),m("IE","Ireland","353",[9],[2,3,4],"851234567"),m("CH","Switzerland","41",[9],[2,3,2,2],"781234567"),m("AT","Austria","43",[10,11],[3,7],"6641234567"),m("PL","Poland","48",[9],[3,3,3],"512345678"),m("CZ","Czechia","420",[9],[3,3,3],"601123456"),m("GR","Greece","30",[10],[3,3,4],"6912345678"),m("RO","Romania","40",[9],[3,3,3],"712345678"),m("HU","Hungary","36",[9],[2,3,4],"201234567"),m("UA","Ukraine","380",[9],[2,3,2,2],"501234567"),m("RU","Russia","7",[10],[3,3,2,2],"9123456789"),m("TR","Turkey","90",[10],[3,3,2,2],"5012345678"),m("IL","Israel","972",[9],[2,3,4],"501234567"),m("AE","United Arab Emirates","971",[9],[2,3,4],"501234567"),m("SA","Saudi Arabia","966",[9],[2,3,4],"512345678"),m("ZA","South Africa","27",[9],[2,3,4],"711234567"),m("NG","Nigeria","234",[10],[3,3,4],"8021234567"),m("KE","Kenya","254",[9],[3,3,3],"712123456"),m("EG","Egypt","20",[10],[3,3,4],"1001234567"),m("BR","Brazil","55",[10,11],[2,5,4],"11961234567"),m("MX","Mexico","52",[10],[3,3,4],"2221234567"),m("AR","Argentina","54",[10],[4,6],"1123456789"),m("CL","Chile","56",[9],[1,4,4],"221234567"),m("CO","Colombia","57",[10],[3,3,4],"3211234567"),m("PE","Peru","51",[9],[3,3,3],"912345678"),m("CN","China","86",[11],[3,4,4],"13123456789"),m("JP","Japan","81",[10],[2,4,4],"9012345678"),m("KR","South Korea","82",[9,10],[2,4,4],"1023456789"),m("SG","Singapore","65",[8],[4,4],"81234567"),m("HK","Hong Kong","852",[8],[4,4],"51234567"),m("TW","Taiwan","886",[9],[3,3,3],"912345678"),m("MY","Malaysia","60",[9,10],[2,3,4],"123456789"),m("ID","Indonesia","62",[10,11],[3,4,4],"81234567890"),m("TH","Thailand","66",[9],[2,3,4],"812345678"),m("PH","Philippines","63",[10],[3,3,4],"9171234567"),m("VN","Vietnam","84",[9],[3,3,3],"912345678"),m("PK","Pakistan","92",[10],[3,3,4],"3012345678"),m("BD","Bangladesh","880",[10],[2,4,4],"1812345678"),m("NZ","New Zealand","64",[9,10],[2,3,4],"211234567"),m("SK","Slovakia","421",[9],[3,3,3],"912123456"),m("BG","Bulgaria","359",[9],[2,3,4],"481234567"),m("HR","Croatia","385",[8,9],[2,3,4],"921234567"),m("RS","Serbia","381",[8,9],[2,3,4],"601234567"),m("SI","Slovenia","386",[8],[2,3,3],"31234567"),m("LT","Lithuania","370",[8],[3,2,3],"61234567"),m("LV","Latvia","371",[8],[2,3,3],"21234567"),m("EE","Estonia","372",[7,8],[3,4],"51234567"),m("IS","Iceland","354",[7],[3,4],"6111234"),m("LU","Luxembourg","352",[9],[3,3,3],"628123456"),m("MA","Morocco","212",[9],[3,3,3],"650123456"),m("CR","Costa Rica","506",[8],[4,4],"83123456"),m("EC","Ecuador","593",[9],[2,3,4],"991234567"),m("UY","Uruguay","598",[8],[1,3,4],"94231234"),m("QA","Qatar","974",[8],[4,4],"33123456"),m("KW","Kuwait","965",[8],[4,4],"50012345")],Vn=new Map(oe.map(t=>[t.iso2,t]));function wt(t){let e=t.toUpperCase();return/^[A-Z]{2}$/.test(e)?String.fromCodePoint(...[...e].map(r=>127462+r.charCodeAt(0)-65)):"\u{1F3F3}\uFE0F"}function Ct(t){return t?Vn.get(t.toUpperCase()):void 0}function Dn(t){let e;for(let r of oe)t.startsWith(r.dialCode)&&(!e||r.dialCode.length>e.dialCode.length)&&(e=r);return e}function le(t){return t.replace(/[^\d]/g,"")}function at(t,e){let r=le(e);if(!r)return"";let n=t?.groups?.length?t.groups:[],s=[],i=0;for(let a of n){if(i>=r.length)break;s.push(r.slice(i,i+a)),i+=a}for(;i<r.length;)s.push(r.slice(i,i+3)),i+=3;return s.join(" ")}function er(t,e){let r=le(e);return r?`+${t.dialCode}${r}`:""}function ot(t,e){let r=(t??"").trim(),n=r.startsWith("+"),s=le(r);if(!s)return{country:e,national:"",e164:""};if(n){let i=Dn(s);if(i){let a=s.slice(i.dialCode.length);return{country:i,national:a,e164:`+${s}`}}return{national:s,e164:`+${s}`}}if(e){let i=s.startsWith(e.dialCode)?s.slice(e.dialCode.length):s;return{country:e,national:i,e164:`+${e.dialCode}${i}`}}return{national:s,e164:`+${s}`}}function Un(t){let{country:e,national:r,e164:n}=ot(t);if(!n)return!1;let s=le(n).length;return s<8||s>15?!1:e?.lengths.length?e.lengths.includes(r.length):r.length>=4}var zn=F.object({fileId:F.string().min(1),name:F.string(),size:F.number().nonnegative(),mime:F.string(),url:F.string().optional()});function tr(t){return t==null?!0:typeof t=="string"?t.trim()==="":Array.isArray(t)?t.length===0:typeof t=="boolean"?t===!1:typeof t=="object"?Object.keys(t).length===0:!1}function rr(t,e){if(tr(e))return t.required?"This field is required":null;switch(t.kind){case"short_text":case"long_text":{if(typeof e!="string")return"Expected text";if(t.maxLength&&e.length>t.maxLength)return`Must be at most ${t.maxLength} characters`;let r=t.kind==="long_text"?2e4:2e3;return!t.maxLength&&e.length>r?"Answer is too long":null}case"email":return F.string().email().safeParse(e).success?null:"Enter a valid email address";case"url":{if(typeof e!="string")return"Enter a valid URL (including https://)";try{let r=new URL(e);if(r.protocol!=="http:"&&r.protocol!=="https:")return"Enter an http(s) URL"}catch{return"Enter a valid URL (including https://)"}return null}case"phone":return typeof e!="string"||!Un(e)?"Enter a valid phone number":null;case"number":{let r=typeof e=="string"?Number(e):e;return typeof r!="number"||Number.isNaN(r)?"Enter a number":t.min!==void 0&&r<t.min?`Must be at least ${t.min}`:t.max!==void 0&&r>t.max?`Must be at most ${t.max}`:null}case"select":case"dropdown":return typeof e!="string"||e===""?"Pick an option":t.options.some(r=>r.id===e)||t.allowOther&&e.length<=500?null:"Pick a valid option";case"multi_select":{if(!Array.isArray(e))return"Pick at least one option";let r=new Set(t.options.map(i=>i.id)),n=e,s=0;for(let i of n)if(!r.has(i)){if(t.allowOther!==!0||typeof i!="string"||i.length===0||i.length>500)return"Pick valid options";if(++s>1)return"Only one 'Other' answer is allowed"}return null}case"checkbox":return typeof e=="boolean"?null:"Invalid value";case"rating":{let r=t.max??5,n=typeof e=="string"?Number(e):e;return typeof n!="number"||!Number.isInteger(n)||n<1||n>r?`Pick a rating between 1 and ${r}`:null}case"linear_scale":{let r=t.min??1,n=t.max??10,s=typeof e=="string"?Number(e):e;return typeof s!="number"||!Number.isInteger(s)||s<r||s>n?`Pick a value between ${r} and ${n}`:null}case"ranking":{if(!Array.isArray(e))return"Drag the options into order";let r=t.options.map(s=>s.id).sort(),n=[...e].sort();return r.length!==n.length||r.some((s,i)=>s!==n[i])?"Rank every option":null}case"matrix":{if(typeof e!="object"||e===null||Array.isArray(e))return"Answer the grid";let r=e,n=new Set(t.columns.map(i=>i.id)),s=new Set(t.rows.map(i=>i.id));for(let[i,a]of Object.entries(r))if(!s.has(i)||!n.has(a))return"Invalid grid answer";return t.required&&Object.keys(r).length<t.rows.length?"Answer every row":null}case"signature":return typeof e!="string"||!e.startsWith("data:image/")?"Sign in the box":null;case"hidden":return typeof e=="string"?null:"Invalid value";case"custom":return null;case"date":return typeof e!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(e)?"Enter a valid date":null;case"file_upload":{let r=F.array(zn).safeParse(e);if(!r.success)return"Upload did not complete";let n=t.maxFiles??1;return r.data.length>n?`At most ${n} file${n===1?"":"s"}`:null}}}function St(t,e){let r=jn(t,e),n={},s={};for(let i of r){let a=Bn(i,e[i.id]),o=rr(i,a);o?n[i.id]=o:tr(a)||(s[i.id]=a)}return{ok:Object.keys(n).length===0,errors:n,data:s}}function Bn(t,e){if(e==null)return e;if(t.kind==="number"&&typeof e=="string"&&e.trim()!==""){let r=Number(e);return Number.isNaN(r)?e:r}if(t.kind==="rating"&&typeof e=="string"){let r=Number(e);return Number.isNaN(r)?e:r}return typeof e=="string"?e.trim():e}var Zn=["short_text","long_text","email","url","phone","number","select","multi_select","dropdown","checkbox","rating","linear_scale","ranking","matrix","signature","date","file_upload","hidden","custom"],Hn=["heading","paragraph","divider"],qn=[...Zn,...Hn],Nt=F.string().min(1).max(128),yt=F.object({id:Nt,label:F.string().max(1e3),icon:F.unknown().optional()}).passthrough(),Wn=F.object({id:Nt,kind:F.enum(qn),label:F.string().max(2e3).optional(),options:F.array(yt).max(200).optional(),rows:F.array(yt).max(200).optional(),columns:F.array(yt).max(200).optional()}).passthrough(),Kn=F.object({id:Nt,title:F.string().max(500).optional(),blocks:F.array(Wn).max(500)}),Jn=F.object({version:F.literal(1),title:F.string().max(2e3).optional().default(""),description:F.string().max(5e3).optional(),pages:F.array(Kn).min(1).max(50),settings:F.record(F.unknown()).optional().default({})}),Yn=1,xt=1,Gt="0.4.0";function ee(t,e,r=""){return typeof t=="string"?t.trim().slice(0,e):r}function V(t,e){let r=ee(t,e);return r===""?void 0:r}function Ke(t){return typeof t=="boolean"?t:void 0}function We(t){return typeof t=="number"&&Number.isFinite(t)?t:void 0}function Ae(t,e,r,n){let s=We(t);return s===void 0?n:Math.max(e,Math.min(r,Math.round(s)))}function nt(t,e=200){return Array.isArray(t)?t.slice(0,e).flatMap(r=>{if(!r||typeof r!="object")return[];let n=r,s=ee(n.id,128),i=ee(n.label,1e3),a=n.icon==="thumbs_up"||n.icon==="thumbs_down"?n.icon:void 0;return s&&i?[L({id:s,label:i,icon:a})]:[]}):[]}function Gn(t){if(!Array.isArray(t))return;let e=t.slice(0,20).flatMap(r=>{if(!r||typeof r!="object")return[];let n=r,s=n.op;if(s!=="eq"&&s!=="neq"&&s!=="contains"&&s!=="gt"&&s!=="lt"&&s!=="answered"&&s!=="not_answered")return[];let i=ee(n.fieldId,128);if(!i)return[];let a=n.value,o=typeof a=="string"||typeof a=="number"||typeof a=="boolean"?a:void 0;return[{fieldId:i,op:s,...o!==void 0?{value:o}:{}}]});return e.length?e:void 0}function nr(t){return{id:ee(t.id,128),visibleIf:Gn(t.visibleIf)}}function z(t,e){return{...nr(t),kind:e,label:ee(t.label,2e3,"Untitled field"),description:V(t.description,5e3),required:Ke(t.required),placeholder:V(t.placeholder,500)}}function Qn(t){let e=V(t,2e3);if(e)try{let r=new URL(e);return r.protocol==="http:"||r.protocol==="https:"?e:void 0}catch{return}}function Xn(t){let e=t&&typeof t=="object"?t:{},r=e.submitMode==="button"||e.submitMode==="auto"?e.submitMode:void 0,n=e.submissionLimit==="once_per_visitor"||e.submissionLimit==="multiple"?e.submissionLimit:void 0;return{submitMode:r,submitLabel:V(e.submitLabel,100),successTitle:V(e.successTitle,200),successMessage:V(e.successMessage,5e3),redirectUrl:Qn(e.redirectUrl),showProgress:Ke(e.showProgress),submissionLimit:n,notifyEmail:F.string().email().max(254).safeParse(e.notifyEmail).success?e.notifyEmail:void 0,sendReceipt:Ke(e.sendReceipt)}}function L(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}function es(t){if(!t||typeof t!="object")return null;let e=t,r=e.kind,n=nr(e);if(!n.id||typeof r!="string")return null;switch(r){case"heading":return L({...n,kind:r,text:ee(e.text,2e3,"Section")});case"paragraph":return L({...n,kind:r,text:ee(e.text,5e3)});case"divider":return L({...n,kind:r});case"short_text":case"email":case"url":return L({...z(e,r),maxLength:We(e.maxLength)===void 0?void 0:Ae(e.maxLength,1,2e3,2e3)});case"phone":{let s=V(e.defaultCountry,2)?.toUpperCase();return L({...z(e,r),defaultCountry:s&&/^[A-Z]{2}$/.test(s)?s:void 0})}case"long_text":return L({...z(e,r),maxLength:We(e.maxLength)===void 0?void 0:Ae(e.maxLength,1,2e4,2e4)});case"number":return L({...z(e,r),min:We(e.min),max:We(e.max)});case"select":case"multi_select":case"dropdown":{let s=nt(e.options);return s.length===0?null:L({...z(e,r),options:s,allowOther:Ke(e.allowOther),shuffleOptions:Ke(e.shuffleOptions)})}case"checkbox":{let s=e.appearance==="toggle"?"toggle":void 0;return L({...z(e,r),appearance:s})}case"signature":case"date":return L(z(e,r));case"rating":return L({...z(e,r),max:Ae(e.max,1,10,5)});case"linear_scale":{let s=Ae(e.min,0,9,1),i=Ae(e.max,s+1,10,10);return L({...z(e,r),min:s,max:i,minLabel:V(e.minLabel,100),maxLabel:V(e.maxLabel,100)})}case"ranking":{let s=nt(e.options);return s.length<2?null:L({...z(e,r),options:s})}case"matrix":{let s=nt(e.rows),i=nt(e.columns);return s.length===0||i.length===0?null:L({...z(e,r),rows:s,columns:i})}case"hidden":return L({...z(e,r),required:!1,paramName:V(e.paramName,128),defaultValue:V(e.defaultValue,1e3)});case"file_upload":return L({...z(e,r),maxFiles:Ae(e.maxFiles,1,20,1),maxFileSizeMb:Ae(e.maxFileSizeMb,1,5e3,500),accept:Array.isArray(e.accept)?e.accept.flatMap(s=>{let i=V(s,100);return i?[i]:[]}).slice(0,50):void 0});case"custom":return L({...z(e,r),component:ee(e.component,128),config:e.config&&typeof e.config=="object"&&!Array.isArray(e.config)?e.config:void 0});default:return null}}function Je(t){let e=Jn.safeParse(t);if(!e.success){let a=e.error.issues[0],o=a?.path.join(".");return{ok:!1,error:a?`${o?`${o}: `:""}${a.message}`:"Invalid schema"}}if(e.data.version>Yn)return{ok:!1,error:`Unsupported schema version: ${e.data.version}`};let r=e.data.pages.map(a=>{let o=a.blocks.flatMap(d=>{let l=es(d);return l?[l]:[]});return L({id:a.id,title:V(a.title,500),blocks:o})}),n=new Set;for(let a of r)for(let o of a.blocks){if(n.has(o.id))return{ok:!1,error:`Duplicate block id: ${o.id}`};n.add(o.id)}if(r.every(a=>a.blocks.length===0))return{ok:!1,error:"Schema must contain at least one valid block"};let s={version:xt,title:ee(e.data.title,2e3),pages:r,settings:Xn(e.data.settings)},i=V(e.data.description,5e3);return i&&(s.description=i),{ok:!0,schema:s}}function qe(t,e){let r=V(t,e);if(r&&!(/[;{}<>]/.test(r)||/url\s*\(/i.test(r)))return r}function Tt(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t,r=e.colorScheme==="light"||e.colorScheme==="dark"||e.colorScheme==="auto"?e.colorScheme:void 0,n=L({colorScheme:r,primary:qe(e.primary,200),background:qe(e.background,200),text:qe(e.text,200),radius:qe(e.radius,64),fontFamily:qe(e.fontFamily,200)});return Object.keys(n).length>0?n:null}var ts="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",vi=256-256%ts.length;var sr=class{h0=1732584193;h1=4023233417;h2=2562383102;h3=271733878;h4=3285377520;block=new Uint8Array(64);blockLen=0;totalLen=0;w=new Int32Array(80);update(t){this.totalLen+=t.length;let e=0;if(this.blockLen>0){for(;e<t.length&&this.blockLen<64;)this.block[this.blockLen++]=t[e++];this.blockLen===64&&(this.process(this.block),this.blockLen=0)}for(;e+64<=t.length;)this.process(t.subarray(e,e+64)),e+=64;for(;e<t.length;)this.block[this.blockLen++]=t[e++];return this}digest(){let t=Math.floor(this.totalLen/536870912),e=this.totalLen*8>>>0,r=[128],n=this.blockLen+1;for(;n%64!==56;)r.push(0),n++;r.push(t>>>24&255,t>>>16&255,t>>>8&255,t&255),r.push(e>>>24&255,e>>>16&255,e>>>8&255,e&255),this.update(new Uint8Array(r));let s=new Uint8Array(20),i=[this.h0,this.h1,this.h2,this.h3,this.h4];for(let a=0;a<5;a++)s[a*4]=i[a]>>>24&255,s[a*4+1]=i[a]>>>16&255,s[a*4+2]=i[a]>>>8&255,s[a*4+3]=i[a]&255;return s}process(t){let e=this.w;for(let o=0;o<16;o++)e[o]=t[o*4]<<24|t[o*4+1]<<16|t[o*4+2]<<8|t[o*4+3];for(let o=16;o<80;o++){let d=e[o-3]^e[o-8]^e[o-14]^e[o-16];e[o]=d<<1|d>>>31}let r=this.h0,n=this.h1,s=this.h2,i=this.h3,a=this.h4;for(let o=0;o<80;o++){let d,l;o<20?(d=n&s|~n&i,l=1518500249):o<40?(d=n^s^i,l=1859775393):o<60?(d=n&s|n&i|s&i,l=2400959708):(d=n^s^i,l=3395469782);let c=(r<<5|r>>>27)+d+a+l+e[o]|0;a=i,i=s,s=n<<30|n>>>2,n=r,r=c}this.h0=this.h0+r|0,this.h1=this.h1+n|0,this.h2=this.h2+s|0,this.h3=this.h3+i|0,this.h4=this.h4+a|0}},st="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Et(t){let e="";for(let r=0;r<t.length;r+=3){let n=t[r],s=r+1<t.length?t[r+1]:0,i=r+2<t.length?t[r+2]:0;e+=st[n>>2],e+=st[(n&3)<<4|s>>4],e+=r+1<t.length?st[(s&15)<<2|i>>6]:"=",e+=r+2<t.length?st[i&63]:"="}return e}var rs=t=>Et(new sr().update(t).digest()),O=class extends Error{constructor(t,e){super(t),this.status=e,this.name="FilloError"}status},vt=3;function ns(t,e){let r=t.split(".").map(s=>Number(s)||0),n=e.split(".").map(s=>Number(s)||0);for(let s=0;s<Math.max(r.length,n.length);s++){let i=(r[s]??0)-(n[s]??0);if(i!==0)return i}return 0}function ss(t){if(t.schemaVersion!==void 0&&t.schemaVersion!==xt)throw new O(`This form uses schema version ${t.schemaVersion}; this SDK supports version ${xt}. Update @usefillo/* to render it.`,426);if(t.minSdkVersion&&ns(Gt,t.minSdkVersion)<0)throw new O(`This form requires @usefillo/* ${t.minSdkVersion} or newer. Current SDK is ${Gt}.`,426)}function bt(t,e){return r=>e.onProgress?.({uploadedBytes:r,totalBytes:t,fraction:t===0?1:r/t})}async function is(t){let e=globalThis.crypto?.subtle;if(e){let r=await e.digest("SHA-1",t);return Et(new Uint8Array(r))}return rs(t)}var as="https://fillo.so",lt=class{baseUrl;fetch;key;constructor(t={}){this.baseUrl=t.sameOrigin?"":as,this.key=t.key,this.fetch=t.fetch??((...e)=>globalThis.fetch(...e))}url(t){return`${this.baseUrl}/api/v1${t}`}async json(t,e){let r=await this.fetch(this.url(t),{...e,headers:{"Content-Type":"application/json",...e?.headers}});if(!r.ok){let n=await r.text().catch(()=>"");throw new O(n||`Request failed: ${r.status}`,r.status)}return await r.json()}async getForm(t){let e=await this.json(`/forms/${encodeURIComponent(t)}`);return ss(e),e}syncForm(t,e,r){if(!this.key)return Promise.reject(new O("createClient needs a `key` (pk_\u2026) to sync code-defined forms",401));let n=Je(e);return n.ok?this.json("/forms/sync",{method:"POST",body:JSON.stringify({key:this.key,id:t,schema:n.schema,theme:Tt(r)})}):Promise.reject(new O(`Invalid form schema: ${n.error}`,400))}async submit(t,e,r){let n=await this.fetch(this.url(`/forms/${encodeURIComponent(t)}/responses`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:e,meta:r})});if(n.status===422)return{ok:!1,errors:(await n.json()).errors};if(!n.ok)throw new O(`Submit failed: ${n.status}`,n.status);let s=await n.json();return{ok:!0,responseId:s.id,duplicate:s.duplicate}}async startSession(t,e){try{let r=await this.fetch(this.url(`/forms/${encodeURIComponent(t)}/sessions`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pageCount:e})});return r.ok?(await r.json()).id:null}catch{return null}}reportProgress(t,e){try{this.fetch(this.url(`/sessions/${encodeURIComponent(t)}/progress`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})}catch{}}getUploadSession(t,e){return this.json(`/uploads/${encodeURIComponent(t)}`,e?{headers:{"X-Fillo-Upload-Token":e}}:void 0)}async uploadFile(t,e,r){let n=e instanceof File?e.name:"upload.bin",s=e.type||"application/octet-stream",i;r.sessionId?i=await this.getUploadSession(r.sessionId,r.uploadToken):i=await this.json(`/forms/${encodeURIComponent(t)}/uploads`,{method:"POST",body:JSON.stringify({fieldId:r.fieldId,fileName:n,size:e.size,mime:s})});let a;if(i.transport?.type==="gdrive")await this.driveUploadLoop(i,i.transport.uploadUrl,e,r);else if(i.transport?.type==="s3-put")await this.s3PutUpload(i.transport.uploadUrl,e,r);else if(i.transport?.type==="box")a=await this.boxUpload(i.transport,e,r);else throw new O("This form's storage doesn't support uploads \u2014 connect Drive, S3, or Box.");let o=await this.json(`/uploads/${encodeURIComponent(i.id)}/complete`,{method:"POST",headers:i.token?{"X-Fillo-Upload-Token":i.token}:void 0,...a?{body:JSON.stringify(a)}:{}});if(!o.file)throw new O("Upload completed but no file was returned");return o.file}async boxUpload(t,e,r){let n=bt(e.size,r);n(0);let s={Authorization:`Bearer ${t.token}`};if(t.mode==="simple"){let T=new FormData;T.append("attributes",JSON.stringify({name:t.fileName,parent:{id:t.folderId}})),T.append("file",e,t.fileName);let x=await this.retry(r,()=>this.fetch(t.uploadUrl,{method:"POST",headers:s,body:T,signal:r.signal}));if(!x.ok)throw new O(`Box upload failed: ${x.status}`,x.status);let C=await x.json();return n(e.size),{providerFileId:C.entries?.[0]?.id}}if(t.size!==e.size)throw new O(`File size changed since the upload was requested (${e.size} vs ${t.size}).`,400);let i=await this.retry(r,()=>this.fetch(t.sessionUrl,{method:"POST",headers:{...s,"Content-Type":"application/json"},body:JSON.stringify({folder_id:t.folderId,file_size:t.size,file_name:t.fileName}),signal:r.signal}));if(!i.ok)throw new O(`Box session failed: ${i.status}`,i.status);let a=await i.json(),o=new sr,d=[],l=0;for(;l<e.size;){r.signal?.throwIfAborted();let T=Math.min(l+a.part_size,e.size),x=new Uint8Array(await e.slice(l,T).arrayBuffer());o.update(x);let C=await is(x),I=await this.retry(r,()=>this.fetch(a.session_endpoints.upload_part,{method:"PUT",headers:{...s,"Content-Type":"application/octet-stream",Digest:`sha=${C}`,"Content-Range":`bytes ${l}-${T-1}/${e.size}`},body:x,signal:r.signal}));if(!I.ok)throw new O(`Box part failed: ${I.status}`,I.status);d.push((await I.json()).part),l=T,n(l)}let c=await this.retry(r,()=>this.fetch(a.session_endpoints.commit,{method:"POST",headers:{...s,"Content-Type":"application/json",Digest:`sha=${Et(o.digest())}`},body:JSON.stringify({parts:d}),signal:r.signal}));if(!c.ok)throw new O(`Box commit failed: ${c.status}`,c.status);return{providerFileId:(await c.json()).entries?.[0]?.id}}async retry(t,e){let r=0;for(;;)try{return await e()}catch(n){if(t.signal?.aborted||(r+=1,r>=vt))throw n;await new Promise(s=>setTimeout(s,500*2**r))}}async driveUploadLoop(t,e,r,n){let s=t.uploadedBytes,i=bt(r.size,n);for(i(s);s<r.size;){n.signal?.throwIfAborted();let a=Math.min(s+t.chunkSize,r.size),o=r.slice(s,a),d=0;for(;;)try{let l=await this.fetch(e,{method:"PUT",headers:{"Content-Range":`bytes ${s}-${a-1}/${r.size}`},body:o,signal:n.signal});if(l.status===308){let c=l.headers.get("Range")??l.headers.get("range"),y=c?.match(/bytes=0-(\d+)/);y?s=Number(y[1])+1:c==null?s=0:s=(await this.getUploadSession(t.id,t.token)).uploadedBytes;break}if(l.ok){s=r.size;break}throw new O(`Drive chunk failed: ${l.status}`,l.status)}catch(l){if(n.signal?.aborted||(d+=1,d>=vt))throw l;await new Promise(y=>setTimeout(y,500*2**d)),s=(await this.getUploadSession(t.id,t.token)).uploadedBytes}i(s)}}async s3PutUpload(t,e,r){let n=bt(e.size,r);n(0);let s=0;for(;;)try{let i=await this.fetch(t,{method:"PUT",headers:{"Content-Type":e.type||"application/octet-stream"},body:e,signal:r.signal});if(!i.ok)throw new O(`S3 upload failed: ${i.status}`,i.status);n(e.size);return}catch(i){if(r.signal?.aborted||(s+=1,s>=vt))throw i;await new Promise(a=>setTimeout(a,500*2**s))}}};function Ye(t={}){return new lt(t)}var os={id:"empty",blocks:[]},Qt=!1;function ls(){Qt||(Qt=!0,console.warn("[fillo] This form has no `client`, so responses can't be submitted \u2014 it's render-only. Pass a client (createClient) to collect responses in Fillo, or forward them to your own backend with webhooks: https://fillo.so/docs"))}var ir=new Map;function ar(){try{return globalThis.localStorage??null}catch{return null}}function or(t){return`fillo:submission:${t}`}function lr(){let t=globalThis.crypto;if(t?.randomUUID)return t.randomUUID();let e=new Uint8Array(16);return t?.getRandomValues?(t.getRandomValues(e),Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")):`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function Ft(t){let e=ar();if(!e)return ir.get(t)??null;try{let r=JSON.parse(e.getItem(or(t))??"null");if(r&&typeof r.key=="string")return r}catch{}return null}function dr(t,e){ir.set(t,e);let r=ar();if(r)try{r.setItem(or(t),JSON.stringify(e))}catch{}}function ds(t){let e=Ft(t);if(e?.key)return e.key;let r={key:lr()};return dr(t,r),r.key}function cs(t,e){let r=Ft(t);dr(t,{key:r?.key??lr(),submittedAt:new Date().toISOString(),responseId:e})}function Xt(t,e){return t.settings.submissionLimit!=="once_per_visitor"||!e?!1:!!Ft(e)?.submittedAt}function cr(t){let{onChange:e,onSubmitted:r}=t,n=Je(t.form);if(!n.ok)throw new Error(`Invalid form schema: ${n.error}`);let s=n.schema,i=t.formId,a=t.client,o={...t.initialData??{}},d={},l=0,c=Xt(s,i)?"submitted":"idle",y=new Set,T=new Set,x=Date.now(),C=null,I=!1;function Y(){let S=s.pages.length,_=Math.min(l,Math.max(S-1,0)),E=s.pages[_]??os;return{data:o,errors:d,status:c,pageIndex:_,pageCount:S,page:E,blocks:it(E,o),isFirstPage:_===0,isLastPage:_===S-1,uploading:y.size>0}}let pe=Y();function P(){pe=Y();for(let S of T)S()}function ze(S,_){try{r?.(S,_)}catch(E){console.error("[fillo] onSubmitted handler threw:",E)}}function ft(S){let _=s.pages[S];if(!_)return{};let E={};for(let $ of it(_,o)){if(!Oe($))continue;let de=rr($,o[$.id]);de&&(E[$.id]=de)}return E}function A(S,_){!I&&a&&i&&(I=!0,a.startSession(i,s.pages.length).then(E=>C=E)),o={...o,[S]:_},e?.(o),S in d&&(d=Object.fromEntries(Object.entries(d).filter(([E])=>E!==S))),P()}function B(S,_){_?y.add(S):y.delete(S),P()}function te(){let S=s.pages.length,_=Math.min(l,Math.max(S-1,0));if(!t.skipValidation){let E=ft(_);if(d=E,Object.keys(E).length>0){P();return}}l=Math.min(_+1,S-1),C&&a&&a.reportProgress(C,{furthestPage:l}),P()}function re(){d={},l=Math.max(Math.min(l,s.pages.length-1)-1,0),P()}async function Re(){if(c==="submitting"||c==="submitted")return;let S=St(s,o);if(!S.ok){d=S.errors;let _=s.pages.findIndex(E=>it(E,o).some($=>$.id in S.errors));_>=0&&(l=_),P();return}if(a&&i){let _=s.settings.submissionLimit==="once_per_visitor"?ds(i):void 0;c="submitting",P();let E;try{E=await a.submit(i,S.data,{hp:t.getHoneypot?.()??"",elapsedMs:Date.now()-x,surface:t.surface??"default",submissionKey:_})}catch($){throw c="idle",P(),$}if(!E.ok){d=E.errors??{},c="idle",P();return}C&&a.reportProgress(C,{completed:!0}),_&&cs(i,E.responseId),c="submitted",P(),ze(E.responseId,S.data);return}if(t.skipValidation){c="submitted",P(),ze(void 0,S.data);return}ls(),c="error",P()}return{getState:()=>pe,subscribe(S){return T.add(S),()=>{T.delete(S)}},setValue:A,setUploading:B,next:te,back:re,submit:Re,setContext(S){if("formId"in S&&(i=S.formId),"client"in S&&(a=S.client),S.form&&S.form!==s){let _=Je(S.form);if(!_.ok)throw new Error(`Invalid form schema: ${_.error}`);s=_.schema}c==="idle"&&Xt(s,i)&&(c="submitted"),P()},destroy(){T.clear()}}}function It(t){return{id:t.id,theme:t.theme,schema:{version:1,title:t.title??"",description:t.description,pages:t.pages,settings:t.settings??{}},__filloCodeForm:!0}}function At(t){return typeof t=="object"&&t!==null&&"__filloCodeForm"in t}var _t=new Map;function us(t){let e=5381;for(let r=0;r<t.length;r++)e=(e<<5)+e+t.charCodeAt(r)|0;return(e>>>0).toString(36)}function ur(t,e){let r=JSON.stringify(e.schema)+JSON.stringify(e.theme??null),n=`${t.baseUrl}:${t.key}:${e.id}:${us(r)}`,s=_t.get(n);return s||(s=t.syncForm(e.id,e.schema,e.theme??null),_t.set(n,s),s.catch(()=>_t.delete(n))),s}var fs=/\{\{\s*([\w-]+)\s*\}\}/g;function kt(t,e,r){if(!t.includes("{{"))return t;let n=Pn(r);return t.replace(fs,(s,i)=>{let a=n.find(l=>l.id===i),o=e[i];if(o==null||o==="")return"";let d=l=>a&&"options"in a?a.options.find(c=>c.id===l)?.label??l:l;return Array.isArray(o)?o.map(l=>d(String(l))).join(", "):typeof o=="string"?d(o):String(o)})}function fr(t,e,r){let n=s=>s===void 0?s:kt(s,e,r);switch(t.kind){case"heading":case"paragraph":return{...t,text:kt(t.text,e,r)};case"divider":return t;default:return{...t,label:kt(t.label,e,r),description:n(t.description)}}}var hs="fillo-",ps=0;function ms(t,e){let r=`${hs}${t}-${e}`;return{inputId:r,labelId:`${r}-label`,descriptionId:`${r}-desc`,errorId:`${r}-error`,name:r}}function u(t,e={}){let r=document.createElement(t);e.className&&(r.className=e.className),e.text!==void 0&&(r.textContent=e.text);for(let[n,s]of Object.entries(e.attrs??{}))r.setAttribute(n,s);return r}function dt(t,e){let r=Tt(e);r&&(r.colorScheme&&t.setAttribute("data-fillo-color-scheme",r.colorScheme),r.primary&&t.style.setProperty("--fillo-primary",r.primary),r.background&&t.style.setProperty("--fillo-bg",r.background),r.text&&t.style.setProperty("--fillo-text",r.text),r.radius&&t.style.setProperty("--fillo-radius",r.radius),r.fontFamily&&t.style.setProperty("--fillo-font",r.fontFamily),(r.primary||r.background||r.text)&&t.setAttribute("data-fillo-has-color-theme",""))}function gs(t){try{if(!t)return null;let e=new URL(t);return e.protocol!=="http:"&&e.protocol!=="https:"?null:e.toString()}catch{return null}}function ys(t){let e=new URL(gs(t)??"https://fillo.so");return e.searchParams.set("utm_source","form_badge"),e.toString()}function Rt(t){return typeof t=="string"||typeof t=="number"?String(t):""}function R(t,e){for(let r of e)r&&t.appendChild(r);return t}var hr="http://www.w3.org/2000/svg",vs={thumbs_up:"M7 10v10M7 10l4.8-6.1a2 2 0 0 1 3.5 1.7L14.6 10h4.8a2.1 2.1 0 0 1 2 2.5l-1.1 5.4A3 3 0 0 1 17.4 20H7M3 10h4v10H3z",thumbs_down:"M7 14V4M7 14l4.8 6.1a2 2 0 0 0 3.5-1.7L14.6 14h4.8a2.1 2.1 0 0 0 2-2.5l-1.1-5.4A3 3 0 0 0 17.4 4H7M3 4h4v10H3z"};function gr(t){if(!t)return null;let e=document.createElementNS(hr,"svg");e.setAttribute("class","fillo-option-icon"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","1.8"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.setAttribute("aria-hidden","true");let r=document.createElementNS(hr,"path");return r.setAttribute("d",vs[t]),e.appendChild(r),e}function W(t,e,r,n){r&&t.setAttribute("aria-invalid","true"),e.required&&t.setAttribute("aria-required","true");let s=[e.description?n.descriptionId:null,r?n.errorId:null].filter(Boolean).join(" ");s&&t.setAttribute("aria-describedby",s)}function K(t,e,r,n){let s=u("div",{className:`fillo-field fillo-field--${t.kind}${e?" fillo-field--error":""}`,attrs:{"data-field":t.id}}),i=u("label",{className:"fillo-label",text:t.label,attrs:{id:n.labelId,for:n.inputId}});return t.required||i.appendChild(u("span",{className:"fillo-optional",text:" (optional)"})),s.appendChild(i),t.description&&s.appendChild(u("p",{className:"fillo-description",text:t.description,attrs:{id:n.descriptionId}})),s.appendChild(r),e&&s.appendChild(u("p",{className:"fillo-error",text:e,attrs:{role:"alert",id:n.errorId}})),s}function Ge(t,e){let r=u("input",{className:"fillo-input",attrs:{id:e.ids.inputId,type:t}});return r.value=Rt(e.value),e.field.placeholder&&(r.placeholder=e.field.placeholder),r.addEventListener("input",()=>e.setValue(r.value,{render:!1})),r.addEventListener("change",()=>e.setValue(r.value)),W(r,e.field,e.error,e.ids),K(e.field,e.error,r,e.ids)}function bs(){if(typeof navigator>"u")return;let e=(navigator.languages?.[0]||navigator.language||"").split("-")[1];return e&&/^[A-Za-z]{2}$/.test(e)?e.toUpperCase():void 0}function _s(t,e){if(e<=0)return t.setSelectionRange(0,0);let r=t.value,n=0,s=r.length;for(let i=0;i<r.length;i++)if(/\d/.test(r[i])&&++n===e){s=i+1;break}t.setSelectionRange(s,s)}function ks(t){let e=t.field,r=ot(Rt(t.value)).country??Ct(e.defaultCountry)??Ct(bs())??oe[0],n=u("div",{className:"fillo-phone"}),s=u("div",{className:"fillo-phone-country"}),i=u("button",{className:"fillo-phone-flag",attrs:{type:"button","aria-haspopup":"listbox","aria-expanded":"false"}}),a=u("span",{className:"fillo-phone-flag-emoji",attrs:{"aria-hidden":"true"}}),o=u("span",{className:"fillo-phone-dial"});R(i,[a,o,u("span",{className:"fillo-phone-caret",text:"\u25BE",attrs:{"aria-hidden":"true"}})]),R(s,[i]);let d=u("input",{className:"fillo-input fillo-phone-input",attrs:{id:t.ids.inputId,type:"tel",inputmode:"tel",autocomplete:"tel-national"}});W(d,t.field,t.error,t.ids);let l=()=>{let A=le(Rt(t.value));return A.startsWith(r.dialCode)?A.slice(r.dialCode.length):A},c=()=>{a.textContent=wt(r.iso2),o.textContent=`+${r.dialCode}`,i.setAttribute("aria-label",`Country: ${r.name} (+${r.dialCode})`)},y=()=>{d.value=at(r,l()),d.placeholder=at(r,r.example)},T=A=>t.setValue(A?er(r,A):"",{render:!1});c(),y(),d.addEventListener("input",()=>{let A=d.value,B=d.selectionStart??A.length,te=le(A.slice(0,B)).length;if(A.trimStart().startsWith("+")){let re=ot(A);re.country&&(r=re.country,c()),T(re.country?re.national:le(A))}else T(le(A));d.value=at(r,l()),_s(d,te)});let x=null,C=0,I=oe,Y=`${t.ids.inputId}-countries`,pe=()=>{x?.remove(),x=null,i.setAttribute("aria-expanded","false"),document.removeEventListener("mousedown",P)},P=A=>{s.contains(A.target)||pe()},ze=A=>{A&&(r=A,c(),T(l()),y(),pe(),d.focus())},ft=()=>{let A=u("div",{className:"fillo-phone-popover"}),B=u("input",{className:"fillo-phone-search",attrs:{type:"text",role:"combobox","aria-expanded":"true","aria-controls":Y,"aria-autocomplete":"list",placeholder:"Search country or code"}}),te=u("ul",{className:"fillo-phone-list",attrs:{role:"listbox",id:Y,"aria-label":"Country"}}),re=()=>{if(te.replaceChildren(),I.length===0){te.appendChild(u("li",{className:"fillo-phone-empty",text:"No matches"}));return}I.forEach((_,E)=>{let $=u("li",{className:`fillo-phone-option${E===C?" fillo-phone-option--active":""}`,attrs:{id:`${Y}-opt-${E}`,role:"option","aria-selected":String(_.iso2===r.iso2)}});R($,[u("span",{className:"fillo-phone-flag-emoji",text:wt(_.iso2),attrs:{"aria-hidden":"true"}}),u("span",{className:"fillo-phone-option-name",text:_.name}),u("span",{className:"fillo-phone-option-dial",text:`+${_.dialCode}`})]),$.addEventListener("mouseenter",()=>{C=E,B.setAttribute("aria-activedescendant",$.id),Re()}),$.addEventListener("mousedown",de=>{de.preventDefault(),ze(_)}),te.appendChild($)}),B.setAttribute("aria-activedescendant",`${Y}-opt-${C}`)},Re=()=>{[...te.children].forEach((_,E)=>_.classList.toggle("fillo-phone-option--active",E===C)),document.getElementById(`${Y}-opt-${C}`)?.scrollIntoView({block:"nearest"})},S=_=>{let E=_.trim().toLowerCase(),$=E.replace(/[^\d]/g,"");I=E?oe.filter(de=>de.name.toLowerCase().includes(E)||de.iso2.toLowerCase()===E||$.length>0&&de.dialCode.startsWith($)):oe,C=0,re()};B.addEventListener("input",()=>S(B.value)),B.addEventListener("keydown",_=>{_.key==="ArrowDown"?(_.preventDefault(),C=Math.min(C+1,I.length-1),Re(),B.setAttribute("aria-activedescendant",`${Y}-opt-${C}`)):_.key==="ArrowUp"?(_.preventDefault(),C=Math.max(C-1,0),Re(),B.setAttribute("aria-activedescendant",`${Y}-opt-${C}`)):_.key==="Enter"?(_.preventDefault(),ze(I[C])):_.key==="Escape"&&(_.preventDefault(),pe(),i.focus())}),R(A,[B,te]),x=A,s.appendChild(A),i.setAttribute("aria-expanded","true"),I=oe,C=Math.max(0,oe.indexOf(r)),re(),Re(),document.addEventListener("mousedown",P),requestAnimationFrame(()=>B.focus())};return i.addEventListener("click",()=>x?pe():ft()),R(n,[s,d]),K(t.field,t.error,n,t.ids)}function xs(t){let e=u("textarea",{className:"fillo-input fillo-textarea",attrs:{id:t.ids.inputId,rows:"4"}});return e.value=typeof t.value=="string"?t.value:"",t.field.placeholder&&(e.placeholder=t.field.placeholder),e.addEventListener("input",()=>t.setValue(e.value,{render:!1})),e.addEventListener("change",()=>t.setValue(e.value)),W(e,t.field,t.error,t.ids),K(t.field,t.error,e,t.ids)}function ws(t){let e=t.field,r=Mt(e),n=typeof t.value=="string"?t.value:"",s=t.activeOtherFields,i=n!==""&&!e.options.some(d=>d.id===n),a=i||n===""&&s?.has(e.id)===!0,o=u("div",{className:"fillo-options",attrs:{role:"radiogroup","aria-labelledby":t.ids.labelId}});W(o,e,t.error,t.ids);for(let d of r){let l=u("label",{className:`fillo-option${d.icon?" fillo-option--has-icon":""}${n===d.id?" fillo-option--selected":""}`,attrs:{"data-option":d.id}}),c=u("input",{className:"fillo-option-input",attrs:{type:"radio",name:t.ids.name}});c.checked=n===d.id,c.addEventListener("change",()=>{s?.delete(e.id),t.setValue(d.id)}),R(l,[c,gr(d.icon),u("span",{className:"fillo-option-label",text:d.label})]),o.appendChild(l)}if(e.allowOther){let d=u("label",{className:`fillo-option fillo-option--other${a?" fillo-option--selected fillo-option--with-other":""}`}),l=u("input",{className:"fillo-option-input",attrs:{type:"radio",name:t.ids.name}});if(l.checked=a,l.addEventListener("change",()=>{s?.add(e.id),t.setValue("",{render:!0})}),R(d,[R(u("span",{className:"fillo-option-main"}),[l,u("span",{className:"fillo-option-label",text:"Other"})])]),a){let c=u("input",{className:"fillo-input fillo-other-input",attrs:{type:"text"}});c.value=i?n:"",c.placeholder="Your answer",c.addEventListener("input",()=>{s?.add(e.id),t.setValue(c.value,{render:!1})}),c.addEventListener("change",()=>{s?.add(e.id),t.setValue(c.value)}),d.appendChild(c),i||queueMicrotask(()=>c.focus())}o.appendChild(d)}return K(e,t.error,o,t.ids)}function Cs(t){let e=t.field,r=Mt(e),n=Array.isArray(t.value)?t.value:[],s=new Set(e.options.map(c=>c.id)),i=n.find(c=>!s.has(c)),a=t.activeOtherFields,o=()=>{let c=t.getValue?.()??t.value;return Array.isArray(c)?c:[]},d=u("div",{className:"fillo-options",attrs:{role:"group","aria-labelledby":t.ids.labelId}});W(d,e,t.error,t.ids);let l=c=>t.setValue(c);for(let c of r){let y=u("label",{className:`fillo-option${c.icon?" fillo-option--has-icon":""}${n.includes(c.id)?" fillo-option--selected":""}`,attrs:{"data-option":c.id}}),T=u("input",{className:"fillo-option-input",attrs:{type:"checkbox"}});T.checked=n.includes(c.id),T.addEventListener("change",()=>{let x=o();l(T.checked?[...x,c.id]:x.filter(C=>C!==c.id))}),R(y,[T,gr(c.icon),u("span",{className:"fillo-option-label",text:c.label})]),d.appendChild(y)}if(e.allowOther){let c=i!==void 0||a?.has(e.id)===!0,y=u("label",{className:`fillo-option fillo-option--other${c?" fillo-option--selected fillo-option--with-other":""}`}),T=u("input",{className:"fillo-option-input",attrs:{type:"checkbox"}});if(T.checked=c,T.addEventListener("change",()=>{let x=o().filter(C=>s.has(C));T.checked?(a?.add(e.id),l(x)):(a?.delete(e.id),l(x))}),R(y,[R(u("span",{className:"fillo-option-main"}),[T,u("span",{className:"fillo-option-label",text:"Other"})])]),c){let x=u("input",{className:"fillo-input fillo-other-input",attrs:{type:"text"}});x.value=i??"",x.placeholder="Your answer",x.addEventListener("input",()=>{a?.add(e.id);let C=o().filter(I=>s.has(I));t.setValue(x.value?[...C,x.value]:C,{render:!1})}),x.addEventListener("change",()=>{a?.add(e.id);let C=o().filter(I=>s.has(I));t.setValue(x.value?[...C,x.value]:C)}),y.appendChild(x),i===void 0&&queueMicrotask(()=>x.focus())}d.appendChild(y)}return K(e,t.error,d,t.ids)}var Ot="__fillo_other__";function Ss(t){let e=t.field,r=typeof t.value=="string"?t.value:"",n=t.activeOtherFields,s=r!==""&&!e.options.some(l=>l.id===r),i=s||r===""&&n?.has(e.id)===!0,a=u("div"),o=u("div",{className:"fillo-select-wrap"}),d=u("select",{className:"fillo-input fillo-select",attrs:{id:t.ids.inputId}});d.appendChild(u("option",{text:e.placeholder??"Choose...",attrs:{value:""}}));for(let l of Mt(e))d.appendChild(u("option",{text:l.label,attrs:{value:l.id}}));if(e.allowOther&&d.appendChild(u("option",{text:"Other...",attrs:{value:Ot}})),d.value=i?Ot:r,d.addEventListener("change",()=>{d.value===Ot?(n?.add(e.id),t.setValue("",{render:!0})):(n?.delete(e.id),t.setValue(d.value||null))}),W(d,e,t.error,t.ids),R(o,[d,u("span",{className:"fillo-select-icon",attrs:{"aria-hidden":"true"}})]),a.appendChild(o),i){let l=u("input",{className:"fillo-input fillo-other-input fillo-other-input--block",attrs:{type:"text"}});l.value=s?r:"",l.placeholder="Your answer",l.addEventListener("input",()=>{n?.add(e.id),t.setValue(l.value,{render:!1})}),l.addEventListener("change",()=>{n?.add(e.id),t.setValue(l.value)}),a.appendChild(l),s||queueMicrotask(()=>l.focus())}return K(e,t.error,a,t.ids)}function Ns(t){if(t.field.kind==="checkbox"&&t.field.appearance==="toggle"){let i=u("div",{className:`fillo-field fillo-field--checkbox fillo-field--toggle${t.error?" fillo-field--error":""}`,attrs:{"data-field":t.field.id}}),a=u("label",{className:"fillo-toggle"}),o=u("span",{className:"fillo-option-label",text:t.field.label});t.field.required||o.appendChild(u("span",{className:"fillo-optional",text:" (optional)"}));let d=u("span",{className:"fillo-toggle-copy"});d.appendChild(o);let l=u("input",{className:"fillo-toggle-input",attrs:{id:t.ids.inputId,type:"checkbox",role:"switch","aria-checked":String(t.value===!0)}});return l.checked=t.value===!0,l.addEventListener("change",()=>{l.setAttribute("aria-checked",String(l.checked)),t.setValue(l.checked)}),W(l,t.field,t.error,t.ids),R(a,[d,l,R(u("span",{className:"fillo-toggle-track",attrs:{"aria-hidden":"true"}}),[u("span",{className:"fillo-toggle-thumb"})])]),i.appendChild(a),t.field.description&&i.appendChild(u("p",{className:"fillo-description",text:t.field.description,attrs:{id:t.ids.descriptionId}})),t.error&&i.appendChild(u("p",{className:"fillo-error",text:t.error,attrs:{role:"alert",id:t.ids.errorId}})),i}let e=u("div",{className:`fillo-field fillo-field--checkbox${t.error?" fillo-field--error":""}`,attrs:{"data-field":t.field.id}}),r=u("label",{className:"fillo-option"}),n=u("input",{className:"fillo-option-input",attrs:{id:t.ids.inputId,type:"checkbox"}});n.checked=t.value===!0,n.addEventListener("change",()=>t.setValue(n.checked)),W(n,t.field,t.error,t.ids);let s=u("span",{className:"fillo-option-label",text:t.field.label});return t.field.required||s.appendChild(u("span",{className:"fillo-optional",text:" (optional)"})),R(r,[n,s]),e.appendChild(r),t.field.description&&e.appendChild(u("p",{className:"fillo-description",text:t.field.description,attrs:{id:t.ids.descriptionId}})),t.error&&e.appendChild(u("p",{className:"fillo-error",text:t.error,attrs:{role:"alert",id:t.ids.errorId}})),e}function Ts(t){if(t.field.kind!=="rating")return u("div");let e=typeof t.field.max=="number"?t.field.max:5,r=typeof t.value=="number"?t.value:0,n=u("div",{className:"fillo-rating",attrs:{role:"group","aria-label":t.field.label}});W(n,t.field,t.error,t.ids);for(let s=1;s<=e;s++){let i=u("button",{className:`fillo-star${s<=r?" fillo-star--active":""}`,text:"*",attrs:{type:"button","aria-label":`${s} of ${e}`,"aria-pressed":String(s===r)}});i.addEventListener("click",()=>t.setValue(s===r?null:s)),n.appendChild(i)}return K(t.field,t.error,n,t.ids)}function Es(t){if(t.field.kind!=="linear_scale")return u("div");let e=typeof t.field.min=="number"?t.field.min:1,r=typeof t.field.max=="number"?t.field.max:10,n=u("div"),s=u("div",{className:"fillo-scale",attrs:{role:"group","aria-label":t.field.label}});W(s,t.field,t.error,t.ids);for(let i=e;i<=r;i++){let a=u("button",{className:`fillo-scale-step${t.value===i?" fillo-scale-step--active":""}`,text:String(i),attrs:{type:"button","aria-pressed":String(t.value===i)}});a.addEventListener("click",()=>t.setValue(t.value===i?null:i)),s.appendChild(a)}return n.appendChild(s),("minLabel"in t.field||"maxLabel"in t.field)&&R(n,[R(u("div",{className:"fillo-scale-labels"}),[u("span",{text:String(t.field.minLabel??"")}),u("span",{text:String(t.field.maxLabel??"")})])]),K(t.field,t.error,n,t.ids)}function Fs(t){let e=t.field;if(e.kind!=="ranking")return null;let r=Array.isArray(t.value)?t.value:[],n=[...r.filter(i=>e.options.some(a=>a.id===i)),...e.options.map(i=>i.id).filter(i=>!r.includes(i))],s=u("ol",{className:"fillo-ranking"});for(let[i,a]of n.entries()){let o=e.options.find(x=>x.id===a);if(!o)continue;let d=u("li",{className:"fillo-ranking-item"}),l=u("span",{className:"fillo-ranking-controls"}),c=x=>{let C=i+x;if(C<0||C>=n.length)return;let I=[...n];[I[i],I[C]]=[I[C],I[i]],t.setValue(I)},y=u("button",{className:"fillo-ranking-move",text:"Up",attrs:{type:"button"}});y.toggleAttribute("disabled",i===0),y.addEventListener("click",()=>c(-1));let T=u("button",{className:"fillo-ranking-move",text:"Down",attrs:{type:"button"}});T.toggleAttribute("disabled",i===n.length-1),T.addEventListener("click",()=>c(1)),R(l,[y,T]),R(d,[u("span",{className:"fillo-ranking-index",text:String(i+1)}),u("span",{className:"fillo-ranking-label",text:o.label}),l]),s.appendChild(d)}return K(t.field,t.error,s,t.ids)}function Is(t){let e=t.field;if(e.kind!=="matrix")return null;let r=t.value&&typeof t.value=="object"&&!Array.isArray(t.value)?t.value:{},n=u("table",{className:"fillo-matrix"}),s=document.createElement("thead"),i=document.createElement("tr");i.appendChild(document.createElement("th"));for(let o of e.columns)i.appendChild(u("th",{text:o.label,attrs:{scope:"col"}}));s.appendChild(i),n.appendChild(s);let a=document.createElement("tbody");for(let o of e.rows){let d=document.createElement("tr");d.appendChild(u("th",{text:o.label,attrs:{scope:"row"}}));for(let l of e.columns){let c=document.createElement("td"),y=u("input",{className:"fillo-option-input",attrs:{type:"radio",name:`${t.ids.name}-${o.id}`,"aria-label":`${o.label}: ${l.label}`}});y.checked=r[o.id]===l.id,y.addEventListener("change",()=>t.setValue({...r,[o.id]:l.id})),c.appendChild(y),d.appendChild(c)}a.appendChild(d)}return n.appendChild(a),K(t.field,t.error,R(u("div",{className:"fillo-matrix-wrap"}),[n]),t.ids)}function As(t){let e=u("div",{className:"fillo-signature"}),r=u("canvas",{className:"fillo-signature-canvas",attrs:{id:t.ids.inputId}});W(r,t.field,t.error,t.ids);let n=u("button",{className:"fillo-signature-clear",text:"Clear",attrs:{type:"button"}}),s=u("div",{className:"fillo-signature-hint",text:"Sign here"});r.width=720,r.height=220;let i=r.getContext("2d"),a=!1,o=typeof t.value=="string"&&t.value.startsWith("data:image/");if(o&&i){let c=new Image;c.onload=()=>i.drawImage(c,0,0,r.width,r.height),c.src=String(t.value),s.style.display="none"}let d=c=>{let y=r.getBoundingClientRect();return{x:(c.clientX-y.left)/y.width*r.width,y:(c.clientY-y.top)/y.height*r.height}};r.addEventListener("pointerdown",c=>{if(!i)return;a=!0,o=!0,s.style.display="none",r.setPointerCapture(c.pointerId);let y=d(c);i.beginPath(),i.moveTo(y.x,y.y)}),r.addEventListener("pointermove",c=>{if(!a||!i)return;let y=d(c);i.lineWidth=2.4,i.lineCap="round",i.strokeStyle=getComputedStyle(r).color||"#18181b",i.lineTo(y.x,y.y),i.stroke()});let l=()=>{a&&(a=!1,o&&t.setValue(r.toDataURL("image/png")))};return r.addEventListener("pointerup",l),r.addEventListener("pointercancel",l),n.addEventListener("click",()=>{i?.clearRect(0,0,r.width,r.height),o=!1,s.style.display="",t.setValue(null)}),R(e,[r,s,n]),K(t.field,t.error,e,t.ids)}function Os(t){let e=t.field;if(e.kind!=="file_upload")return null;let r=u("input",{className:"fillo-input",attrs:{id:t.ids.inputId,type:"file"}});(e.maxFiles??1)>1&&(r.multiple=!0),e.accept?.length&&(r.accept=e.accept.join(",")),W(r,e,t.error,t.ids),r.addEventListener("change",()=>{let a=Array.from(r.files??[]);t.uploadFiles?.(e,a)});let n=u("div");n.appendChild(r);let s=t.uploadProgress?.get(e.id);if(s!==void 0){let a=u("div",{className:"fillo-upload-progress"});a.appendChild(u("div",{className:"fillo-upload-progress-fill"})),a.firstElementChild?.style.setProperty("width",`${Math.round(s*100)}%`),n.appendChild(a)}let i=Array.isArray(t.value)?t.value:[];for(let a of i)n.appendChild(u("p",{className:"fillo-description",text:`${a.name} (${Math.round(a.size/1024)} KB)`}));return K(e,t.error,n,t.ids)}var pr=new Map;function Mt(t){if(!t.shuffleOptions)return t.options;let e=`${t.id}|${t.options.map(i=>i.id).join(",")}`,r=pr.get(e);if(!r){r=t.options.map(i=>i.id);for(let i=r.length-1;i>0;i--){let a=Math.floor(Math.random()*(i+1));[r[i],r[a]]=[r[a],r[i]]}pr.set(e,r)}let n=new Map(t.options.map(i=>[i.id,i])),s=r.flatMap(i=>n.get(i)??[]);return s.length===t.options.length?s:t.options}var Rs={short_text:t=>Ge("text",t),email:t=>Ge("email",t),url:t=>Ge("url",t),phone:ks,number:t=>Ge("number",t),date:t=>Ge("date",t),long_text:xs,select:ws,multi_select:Cs,dropdown:Ss,checkbox:Ns,rating:Ts,linear_scale:Es,ranking:Fs,matrix:Is,signature:As,file_upload:Os};function Ls(t){return Oe(t)&&(t.kind==="select"||t.kind==="dropdown"||t.kind==="checkbox"||t.kind==="rating"||t.kind==="linear_scale")}function $s(t){return t.some(e=>Oe(e)&&e.kind!=="hidden"&&!Ls(e))}function Ms(t){if(t.field.kind==="hidden"||t.field.kind==="custom")return null;let e=Rs[t.field.kind];return e?e(t):null}function Ps(t,e,r,n){return r.form.settings.submitMode!=="auto"||!r.isLastPage||r.status!=="idle"||n?!1:(()=>{switch(t.kind){case"select":case"dropdown":return typeof e=="string"&&t.options.some(i=>i.id===e);case"checkbox":return e===!0;case"rating":case"linear_scale":return typeof e=="number";default:return!1}})()&&St(r.form,{...r.data,[t.id]:e}).ok}var Lt=class{constructor(e,r){this.target=e;this.options=r;this.element.className="fillo-dom-root",e.replaceChildren(this.element),this.resolve()}target;options;element=u("div");instanceId=`d${++ps}`;schema=null;theme;formId;closed=!1;fetchedPoweredBy=null;fetchedBrandLabel;fetchedBrandHref;phase="loading";engine=null;destroyed=!1;renderQueued=!1;hpValue="";activeOtherFields=new Set;uploadProgress=new Map;get status(){return this.phase==="ready"?this.engine?.getState().status??"idle":this.phase}get data(){return this.engine?.getState().data??this.options.initialData??{}}get form(){return this.schema}get mutableData(){return this.engine?.getState().data??this.options.initialData??{}}api(){let e=this.schema??{version:1,title:"",pages:[],settings:{}},r=this.engine?.getState(),n=r?.pageCount??e.pages.length;return{form:e,formId:this.formId,client:this.options.client,data:r?.data??this.mutableData,errors:r?.errors??{},status:this.status,pageIndex:r?.pageIndex??0,pageCount:n,page:r?.page??e.pages[0]??{id:"empty",blocks:[]},blocks:r?.blocks??[],isFirstPage:r?.isFirstPage??!0,isLastPage:r?.isLastPage??n<=1,setValue:(s,i,a)=>this.setValueInternal(s,i,a),next:()=>this.next(),back:()=>this.back(),submit:()=>this.submit()}}async resolve(){try{let e=At(this.options.form)?this.options.form:null;if(e){this.setSchema(e.schema,this.options.theme??e.theme,this.options.formId),this.options.client?.key&&ur(this.options.client,e).then(({formId:s,branding:i})=>{this.formId=s,this.engine?.setContext({formId:s}),i&&(this.fetchedPoweredBy=i.poweredBy,this.fetchedBrandLabel=i.label,this.fetchedBrandHref=i.href,this.render())}).catch(s=>this.handleError(ct(s)));return}let r=this.options.form&&!At(this.options.form)?this.options.form:null;if(r){this.setSchema(r,this.options.theme,this.options.formId);return}if(!this.options.formId)throw new O("Provide either `form`, or a `formId`.",0);this.options.client??=Ye(),this.render();let n=await this.options.client.getForm(this.options.formId);this.closed=!!n.closed,this.fetchedPoweredBy=n.branding?.poweredBy??null,this.fetchedBrandLabel=n.branding?.label,this.fetchedBrandHref=n.branding?.href,this.setSchema(n.schema,this.options.theme??n.theme??void 0,n.id)}catch(e){this.handleError(ct(e))}}setSchema(e,r,n){let s=Je(e);if(!s.ok)throw new O(`This form could not be rendered: ${s.error}`,422);let i=s.schema;this.schema=i,this.theme=r,this.formId=n,this.engine=cr({form:i,formId:n,client:this.options.client,initialData:this.options.initialData,onChange:this.options.onChange,onSubmitted:this.options.onSubmitted,getHoneypot:()=>this.hpValue,surface:"default"}),this.phase=this.closed?"closed":"ready",this.render()}setValue(e,r){this.setValueInternal(e,r)}setValueInternal(e,r,n={}){this.engine?.setValue(e,r),n.render!==!1&&this.queueRender()}next(){this.engine&&(this.engine.next(),this.render())}back(){this.engine&&(this.engine.back(),this.render())}async submit(){if(!this.engine||this.phase!=="ready")return;let e=this.engine.submit();this.render();try{await e}catch(r){this.handleError(ct(r));return}this.render()}async uploadFiles(e,r){if(!this.schema)return;let n=e.maxFiles??1,s=r.slice(0,n);this.uploadProgress.set(e.id,0),this.queueRender();try{let i=[];for(let[a,o]of s.entries())this.options.client&&this.formId?i.push(await this.options.client.uploadFile(this.formId,o,{fieldId:e.id,onProgress:d=>{this.uploadProgress.set(e.id,(a+d.fraction)/s.length),this.queueRender()}})):i.push({fileId:`local:${o.name}:${o.size}`,name:o.name,size:o.size,mime:o.type||"application/octet-stream"});this.uploadProgress.delete(e.id),this.setValueInternal(e.id,i)}catch(i){this.uploadProgress.delete(e.id),this.handleError(ct(i))}}destroy(){this.destroyed=!0,this.target.replaceChildren()}handleError(e){this.phase="error",this.options.onError?.(e),this.render(e)}queueRender(){this.renderQueued||this.destroyed||(this.renderQueued=!0,queueMicrotask(()=>{this.renderQueued=!1,this.render()}))}render(e){if(!this.destroyed){if(this.element.replaceChildren(),this.phase==="loading"){let r=u("div",{className:`fillo-form fillo-form--loading ${this.options.className??""}`,attrs:{"aria-busy":"true"}});dt(r,this.theme),R(r,[u("div",{className:"fillo-skeleton"}),u("div",{className:"fillo-skeleton"}),u("div",{className:"fillo-skeleton fillo-skeleton--short"})]),this.element.appendChild(r);return}if(this.phase==="error"&&e){this.element.appendChild(this.options.renderError?.(e)??u("div",{className:"fillo-form fillo-form--error",text:e.message}));return}if(this.phase==="closed"){let r=u("div",{className:`fillo-form fillo-form--closed ${this.options.className??""}`});dt(r,this.theme),r.appendChild(u("p",{className:"fillo-closed",text:"This form is no longer accepting responses."})),this.element.appendChild(r);return}if(this.schema){if(this.engine?.getState().status==="submitted"){let r=this.api(),n=this.options.renderSuccess?.(r)??Vs(this.schema);dt(n,this.theme),this.element.appendChild(n),this.brandingVisible()&&this.element.appendChild(mr(this.fetchedBrandLabel,this.fetchedBrandHref));return}!this.options.client&&Ds()&&this.element.appendChild(Us()),this.element.appendChild(this.renderForm()),this.brandingVisible()&&this.element.appendChild(mr(this.fetchedBrandLabel,this.fetchedBrandHref))}}}brandingVisible(){return this.fetchedPoweredBy??!0}renderForm(){let e=this.api(),r=u("form",{className:`fillo-form ${this.options.className??""}`});dt(r,this.theme),r.noValidate=!0;let n=()=>{e.isLastPage?this.submit():this.next()};if(r.addEventListener("submit",l=>{l.preventDefault(),n()}),e.pageCount>1&&this.schema?.settings.showProgress!==!1){let l=u("div",{className:"fillo-progress-track",attrs:{role:"progressbar","aria-valuemin":"0","aria-valuemax":String(e.pageCount),"aria-valuenow":String(e.pageIndex+1)}});l.appendChild(u("div",{className:"fillo-progress-fill"})),l.firstElementChild?.style.setProperty("width",`${(e.pageIndex+1)/e.pageCount*100}%`),r.appendChild(l)}if(e.pageIndex===0){let l=u("header",{className:"fillo-header"});l.appendChild(u("h1",{className:"fillo-title",text:e.form.title})),e.form.description&&l.appendChild(u("p",{className:"fillo-form-description",text:e.form.description})),r.appendChild(l)}else e.page.title&&r.appendChild(u("h2",{className:"fillo-page-title",text:e.page.title}));let s=u("div",{className:"fillo-blocks"});for(let l of e.blocks){let c=this.renderBlock(fr(l,this.mutableData,e.form),e);c&&s.appendChild(c)}r.appendChild(s);let i=u("input",{className:"fillo-hp",attrs:{type:"text",name:"fillo_hp_field",tabindex:"-1",autocomplete:"off","aria-hidden":"true"}});i.addEventListener("input",()=>{this.hpValue=i.value}),r.appendChild(i);let o=!(e.form.settings.submitMode==="auto")||!e.isLastPage||$s(e.blocks);if(o||e.pageCount>1&&!e.isFirstPage){let l=u("footer",{className:"fillo-footer"});if(e.pageCount>1&&!e.isFirstPage){let c=u("button",{className:"fillo-button fillo-button--ghost",text:"Back",attrs:{type:"button"}});c.addEventListener("click",()=>this.back()),l.appendChild(c)}if(o){let c=u("button",{className:"fillo-button fillo-button--primary",text:e.status==="submitting"?"Submitting...":e.isLastPage?e.form.settings.submitLabel??"Submit":"Next",attrs:{type:"submit"}});c.toggleAttribute("disabled",e.status==="submitting"||this.uploadProgress.size>0),c.addEventListener("click",y=>{y.preventDefault(),n()}),l.appendChild(c)}r.appendChild(l)}return r}renderBlock(e,r){if(!Oe(e))return js(e);let n=(a,o)=>{this.setValueInternal(e.id,a,o),o?.render!==!1&&Ps(e,a,r,this.uploadProgress.size>0)&&this.submit()},s={field:e,value:r.data[e.id],error:r.errors[e.id],ids:ms(this.instanceId,e.id),api:r,setValue:n,uploadFiles:(a,o)=>this.uploadFiles(a,o),uploadProgress:this.uploadProgress,activeOtherFields:this.activeOtherFields,getValue:()=>this.engine?.getState().data[e.id]};return(e.kind==="custom"?this.options.customComponents?.[e.component]??this.options.components?.custom:this.options.components?.[e.kind]??Ms)?.(s)??null}};function js(t){switch(t.kind){case"heading":return u("h3",{className:"fillo-heading",text:t.text});case"paragraph":return u("p",{className:"fillo-paragraph",text:t.text});case"divider":return u("hr",{className:"fillo-divider"})}return u("div")}function Vs(t){let e=u("div",{className:"fillo-form fillo-form--success"}),r=u("div",{className:"fillo-success"});return R(r,[u("div",{className:"fillo-success-mark",text:"\u2713",attrs:{"aria-hidden":"true"}}),u("h2",{className:"fillo-success-title",text:t.settings.successTitle??"Thanks!"}),u("p",{className:"fillo-success-message",text:t.settings.successMessage??"Your response has been recorded."})]),e.appendChild(r),e}function mr(t,e){return u("a",{className:"fillo-powered",text:t??"Powered by Fillo",attrs:{href:ys(e),target:"_blank",rel:"noopener noreferrer"}})}function Ds(){return typeof process<"u"&&process.env?.NODE_ENV!=="production"}function Us(){return u("div",{className:"fillo-devwarning",text:"No Fillo client connected \u2014 this form is render-only and won't save responses. Pass a client to collect them in Fillo, or forward with webhooks. (Shown only in development.)",attrs:{role:"alert"}})}function ct(t){return t instanceof O?t:new O(t instanceof Error?t.message:String(t),0)}function ut(t,e){let r=typeof t=="string"?document.querySelector(t):t;if(!r)throw new O(`Fillo mount target not found: ${String(t)}`,0);return new Lt(r,{...e,initialData:e.initialData??{}})}function yr(t){let e=u("div");return ut(e,t),e}var $t=class extends HTMLElement{instance=null;assignedForm;assignedClient;assignedTheme;assignedInitialData;static get observedAttributes(){return["publishable-key","form-id"]}connectedCallback(){this.mount()}disconnectedCallback(){this.instance?.destroy(),this.instance=null}attributeChangedCallback(){this.isConnected&&this.mount()}set form(e){this.assignedForm=e,this.isConnected&&this.mount()}get form(){return this.assignedForm}set client(e){this.assignedClient=e,this.isConnected&&this.mount()}set theme(e){this.assignedTheme=e,this.isConnected&&this.mount()}set initialData(e){this.assignedInitialData=e,this.isConnected&&this.mount()}mount(){this.instance?.destroy();let e=this.getAttribute("publishable-key")??void 0,r=this.getAttribute("form-id")??void 0,n=this.assignedClient??(r||e?Ye({key:e}):void 0);this.instance=ut(this,{form:this.assignedForm,client:n,formId:r,theme:this.assignedTheme,initialData:this.assignedInitialData,onChange:s=>this.dispatchEvent(new CustomEvent("fillo-change",{detail:{data:s}})),onSubmitted:(s,i)=>this.dispatchEvent(new CustomEvent("fillo-submit",{detail:{responseId:s,data:i}})),onError:s=>this.dispatchEvent(new CustomEvent("fillo-error",{detail:{error:s}}))})}};function Pt(t="fillo-form"){customElements.get(t)||customElements.define(t,$t)}Pt();return xr(zs);})();