@usefillo/dom 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -4
- package/dist/standalone.global.js +1 -1
- package/dist/styles.css +3 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Field, FieldValue, FormSchema, FilloClient, ResponseData, FormPage, Block, CodeForm, FormTheme, FieldKind, FilloError } from '@usefillo/core';
|
|
2
|
-
export { CodeForm, Field, FieldKind, FieldValue, FileValue, FilloClient, FilloClientOptions, FilloError, FormController, FormControllerOptions, FormControllerState, FormSchema, FormTheme, ResponseData, createClient, createFormController, defineForm } from '@usefillo/core';
|
|
2
|
+
export { CodeForm, Field, FieldKind, FieldValue, FileValue, FilloClient, FilloClientOptions, FilloError, FormController, FormControllerOptions, FormControllerState, FormSchema, FormTheme, ProvisionWorkspaceResult, ResponseData, createClient, createFormController, defineForm, provisionWorkspace } from '@usefillo/core';
|
|
3
3
|
|
|
4
4
|
type FormStatus = "loading" | "idle" | "submitting" | "submitted" | "error" | "closed";
|
|
5
5
|
interface FilloDomApi {
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
isCodeForm,
|
|
9
9
|
isField,
|
|
10
10
|
pipeBlock,
|
|
11
|
+
provisionWorkspace,
|
|
11
12
|
syncCodeForm
|
|
12
13
|
} from "@usefillo/core";
|
|
13
14
|
var FIELD_INPUT_PREFIX = "fillo-";
|
|
@@ -54,8 +55,8 @@ function shell(field, error, child) {
|
|
|
54
55
|
text: field.label,
|
|
55
56
|
attrs: { id: `${FIELD_INPUT_PREFIX}${field.id}-label`, for: `${FIELD_INPUT_PREFIX}${field.id}` }
|
|
56
57
|
});
|
|
57
|
-
if (field.required)
|
|
58
|
-
label.appendChild(el("span", { className: "fillo-
|
|
58
|
+
if (!field.required)
|
|
59
|
+
label.appendChild(el("span", { className: "fillo-optional", text: " (optional)" }));
|
|
59
60
|
wrap.appendChild(label);
|
|
60
61
|
if (field.description)
|
|
61
62
|
wrap.appendChild(
|
|
@@ -241,8 +242,8 @@ function checkbox(context) {
|
|
|
241
242
|
input.addEventListener("change", () => context.setValue(input.checked));
|
|
242
243
|
applyFieldAria(input, context.field, context.error);
|
|
243
244
|
const labelText = el("span", { className: "fillo-option-label", text: context.field.label });
|
|
244
|
-
if (context.field.required)
|
|
245
|
-
labelText.appendChild(el("span", { className: "fillo-
|
|
245
|
+
if (!context.field.required)
|
|
246
|
+
labelText.appendChild(el("span", { className: "fillo-optional", text: " (optional)" }));
|
|
246
247
|
appendChildren(label, [input, labelText]);
|
|
247
248
|
wrap.appendChild(label);
|
|
248
249
|
if (context.field.description)
|
|
@@ -924,6 +925,7 @@ export {
|
|
|
924
925
|
createFormController,
|
|
925
926
|
createFormElement,
|
|
926
927
|
defineForm,
|
|
928
|
+
provisionWorkspace,
|
|
927
929
|
registerFilloElement,
|
|
928
930
|
renderForm
|
|
929
931
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Fillo=(()=>{var Ue=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var Lt=Object.getOwnPropertyNames;var jt=Object.prototype.hasOwnProperty;var lt=(t,e)=>{for(var r in e)Ue(t,r,{get:e[r],enumerable:!0})},Mt=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Lt(e))!jt.call(t,n)&&n!==r&&Ue(t,n,{get:()=>e[n],enumerable:!(s=$t(e,n))||s.enumerable});return t};var Pt=t=>Mt(Ue({},"__esModule",{value:!0}),t);var Fs={};lt(Fs,{FilloClient:()=>Me,FilloError:()=>R,createClient:()=>Oe,createFormElement:()=>St,defineForm:()=>Qe,registerFilloElement:()=>nt,renderForm:()=>De});var w={};lt(w,{BRAND:()=>cr,DIRTY:()=>te,EMPTY_PATH:()=>Zt,INVALID:()=>y,NEVER:()=>Jr,OK:()=>S,ParseStatus:()=>N,Schema:()=>_,ZodAny:()=>G,ZodArray:()=>K,ZodBigInt:()=>se,ZodBoolean:()=>ne,ZodBranded:()=>Ee,ZodCatch:()=>me,ZodDate:()=>ie,ZodDefault:()=>he,ZodDiscriminatedUnion:()=>$e,ZodEffects:()=>M,ZodEnum:()=>fe,ZodError:()=>A,ZodFirstPartyTypeKind:()=>v,ZodFunction:()=>je,ZodIntersection:()=>de,ZodIssueCode:()=>c,ZodLazy:()=>ce,ZodLiteral:()=>ue,ZodMap:()=>we,ZodNaN:()=>Te,ZodNativeEnum:()=>pe,ZodNever:()=>V,ZodNull:()=>oe,ZodNullable:()=>H,ZodNumber:()=>re,ZodObject:()=>O,ZodOptional:()=>L,ZodParsedType:()=>h,ZodPipeline:()=>Fe,ZodPromise:()=>ee,ZodReadonly:()=>ge,ZodRecord:()=>Le,ZodSchema:()=>_,ZodSet:()=>Ce,ZodString:()=>Q,ZodSymbol:()=>xe,ZodTransformer:()=>M,ZodTuple:()=>z,ZodType:()=>_,ZodUndefined:()=>ae,ZodUnion:()=>le,ZodUnknown:()=>J,ZodVoid:()=>ke,addIssueToContext:()=>p,any:()=>br,array:()=>wr,bigint:()=>hr,boolean:()=>bt,coerce:()=>Wr,custom:()=>gt,date:()=>mr,datetimeRegex:()=>ht,defaultErrorMap:()=>q,discriminatedUnion:()=>Sr,effect:()=>Vr,enum:()=>jr,function:()=>Ir,getErrorMap:()=>ve,getParsedType:()=>Z,instanceof:()=>fr,intersection:()=>Er,isAborted:()=>Re,isAsync:()=>be,isDirty:()=>Ie,isValid:()=>X,late:()=>ur,lazy:()=>$r,literal:()=>Lr,makeIssue:()=>Se,map:()=>Or,nan:()=>pr,nativeEnum:()=>Mr,never:()=>xr,null:()=>vr,nullable:()=>Ur,number:()=>vt,object:()=>Cr,objectUtil:()=>Ze,oboolean:()=>qr,onumber:()=>Br,optional:()=>Dr,ostring:()=>Hr,pipeline:()=>zr,preprocess:()=>Zr,promise:()=>Pr,quotelessJson:()=>Vt,record:()=>Ar,set:()=>Rr,setErrorMap:()=>Ut,strictObject:()=>Tr,string:()=>yt,symbol:()=>gr,transformer:()=>Vr,tuple:()=>Fr,undefined:()=>yr,union:()=>Nr,unknown:()=>_r,util:()=>k,void:()=>kr});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 h=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 h.undefined;case"string":return h.string;case"number":return Number.isNaN(t)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(t)?h.array:t===null?h.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?h.promise:typeof Map<"u"&&t instanceof Map?h.map:typeof Set<"u"&&t instanceof Set?h.set:typeof Date<"u"&&t instanceof Date?h.date:h.object;default:return h.unknown}};var c=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"]),Vt=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),A=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()}};A.create=t=>new A(t);var Dt=(t,e)=>{let r;switch(t.code){case c.invalid_type:t.received===h.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case c.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,k.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:r=`Unrecognized key(s) in object: ${k.joinValues(t.keys,", ")}`;break;case c.invalid_union:r="Invalid input";break;case c.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${k.joinValues(t.options)}`;break;case c.invalid_enum_value:r=`Invalid enum value. Expected ${k.joinValues(t.options)}, received '${t.received}'`;break;case c.invalid_arguments:r="Invalid function arguments";break;case c.invalid_return_type:r="Invalid function return type";break;case c.invalid_date:r="Invalid date";break;case c.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 c.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 c.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 c.custom:r="Invalid input";break;case c.invalid_intersection_types:r="Intersection results could not be merged";break;case c.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case c.not_finite:r="Number must be finite";break;default:r=e.defaultError,k.assertNever(t)}return{message:r}},q=Dt;var dt=q;function Ut(t){dt=t}function ve(){return dt}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}},Zt=[];function p(t,e){let r=ve(),s=Se({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===q?void 0:q].filter(n=>!!n)});t.common.issues.push(s)}var N=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}),S=t=>({status:"valid",value:t}),Re=t=>t.status==="aborted",Ie=t=>t.status==="dirty",X=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 j=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}},ct=(t,e)=>{if(X(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 A(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 N,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 ct(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 X(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=>X(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 ct(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:c.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 L.create(this,this._def)}nullable(){return H.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return K.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 he({...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}},zt=/^c[^\s-]{8,}$/i,Ht=/^[0-9a-z]+$/,Bt=/^[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,Wt=/^[a-z0-9_-]{21}$/i,Jt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Kt=/^[-+]?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)?)??$/,Yt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Xt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ze,Qt=/^(?:(?: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])$/,Gt=/^(?:(?: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])$/,er=/^(([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]))$/,tr=/^(([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])$/,rr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,sr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ft="((\\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])))",nr=new RegExp(`^${ft}$`);function pt(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 ir(t){return new RegExp(`^${pt(t)}$`)}function ht(t){let e=`${ft}T${pt(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 ar(t,e){return!!((e==="v4"||!e)&&Qt.test(t)||(e==="v6"||!e)&&er.test(t))}function or(t,e){if(!Jt.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 lr(t,e){return!!((e==="v4"||!e)&&Gt.test(t)||(e==="v6"||!e)&&tr.test(t))}var Q=class t extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){let i=this._getOrReturnCtx(e);return p(i,{code:c.invalid_type,expected:h.string,received:i.parsedType}),y}let s=new N,n;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),p(n,{code:c.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),p(n,{code:c.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?p(n,{code:c.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&p(n,{code:c.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),s.dirty())}else if(i.kind==="email")Yt.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"email",code:c.invalid_string,message:i.message}),s.dirty());else if(i.kind==="emoji")ze||(ze=new RegExp(Xt,"u")),ze.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"emoji",code:c.invalid_string,message:i.message}),s.dirty());else if(i.kind==="uuid")qt.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"uuid",code:c.invalid_string,message:i.message}),s.dirty());else if(i.kind==="nanoid")Wt.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"nanoid",code:c.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid")zt.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"cuid",code:c.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid2")Ht.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"cuid2",code:c.invalid_string,message:i.message}),s.dirty());else if(i.kind==="ulid")Bt.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"ulid",code:c.invalid_string,message:i.message}),s.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),p(n,{validation:"url",code:c.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),p(n,{validation:"regex",code:c.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),p(n,{code:c.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),p(n,{code:c.invalid_string,validation:{startsWith:i.value},message:i.message}),s.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),p(n,{code:c.invalid_string,validation:{endsWith:i.value},message:i.message}),s.dirty()):i.kind==="datetime"?ht(i).test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:c.invalid_string,validation:"datetime",message:i.message}),s.dirty()):i.kind==="date"?nr.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:c.invalid_string,validation:"date",message:i.message}),s.dirty()):i.kind==="time"?ir(i).test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:c.invalid_string,validation:"time",message:i.message}),s.dirty()):i.kind==="duration"?Kt.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"duration",code:c.invalid_string,message:i.message}),s.dirty()):i.kind==="ip"?ar(e.data,i.version)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"ip",code:c.invalid_string,message:i.message}),s.dirty()):i.kind==="jwt"?or(e.data,i.alg)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"jwt",code:c.invalid_string,message:i.message}),s.dirty()):i.kind==="cidr"?lr(e.data,i.version)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"cidr",code:c.invalid_string,message:i.message}),s.dirty()):i.kind==="base64"?rr.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"base64",code:c.invalid_string,message:i.message}),s.dirty()):i.kind==="base64url"?sr.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"base64url",code:c.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:c.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}};Q.create=t=>new Q({checks:[],typeName:v.ZodString,coerce:t?.coerce??!1,...b(t)});function dr(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)!==h.number){let i=this._getOrReturnCtx(e);return p(i,{code:c.invalid_type,expected:h.number,received:i.parsedType}),y}let s,n=new N;for(let i of this._def.checks)i.kind==="int"?k.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:c.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),p(s,{code:c.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),p(s,{code:c.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?dr(e.data,i.value)!==0&&(s=this._getOrReturnCtx(e,s),p(s,{code:c.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:c.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)!==h.bigint)return this._getInvalidInput(e);let s,n=new N;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),p(s,{code:c.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),p(s,{code:c.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),p(s,{code:c.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 p(r,{code:c.invalid_type,expected:h.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)!==h.boolean){let s=this._getOrReturnCtx(e);return p(s,{code:c.invalid_type,expected:h.boolean,received:s.parsedType}),y}return S(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)!==h.date){let i=this._getOrReturnCtx(e);return p(i,{code:c.invalid_type,expected:h.date,received:i.parsedType}),y}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return p(i,{code:c.invalid_date}),y}let s=new N,n;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),p(n,{code:c.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),p(n,{code:c.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)!==h.symbol){let s=this._getOrReturnCtx(e);return p(s,{code:c.invalid_type,expected:h.symbol,received:s.parsedType}),y}return S(e.data)}};xe.create=t=>new xe({typeName:v.ZodSymbol,...b(t)});var ae=class extends _{_parse(e){if(this._getType(e)!==h.undefined){let s=this._getOrReturnCtx(e);return p(s,{code:c.invalid_type,expected:h.undefined,received:s.parsedType}),y}return S(e.data)}};ae.create=t=>new ae({typeName:v.ZodUndefined,...b(t)});var oe=class extends _{_parse(e){if(this._getType(e)!==h.null){let s=this._getOrReturnCtx(e);return p(s,{code:c.invalid_type,expected:h.null,received:s.parsedType}),y}return S(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 S(e.data)}};G.create=t=>new G({typeName:v.ZodAny,...b(t)});var J=class extends _{constructor(){super(...arguments),this._unknown=!0}_parse(e){return S(e.data)}};J.create=t=>new J({typeName:v.ZodUnknown,...b(t)});var V=class extends _{_parse(e){let r=this._getOrReturnCtx(e);return p(r,{code:c.invalid_type,expected:h.never,received:r.parsedType}),y}};V.create=t=>new V({typeName:v.ZodNever,...b(t)});var ke=class extends _{_parse(e){if(this._getType(e)!==h.undefined){let s=this._getOrReturnCtx(e);return p(s,{code:c.invalid_type,expected:h.void,received:s.parsedType}),y}return S(e.data)}};ke.create=t=>new ke({typeName:v.ZodVoid,...b(t)});var K=class t extends _{_parse(e){let{ctx:r,status:s}=this._processInputParams(e),n=this._def;if(r.parsedType!==h.array)return p(r,{code:c.invalid_type,expected:h.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)&&(p(r,{code:a?c.too_big:c.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&&(p(r,{code:c.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&&(p(r,{code:c.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 j(r,a,r.path,o)))).then(a=>N.mergeArray(s,a));let i=[...r.data].map((a,o)=>n.type._parseSync(new j(r,a,r.path,o)));return N.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)}};K.create=(t,e)=>new K({type:t,minLength:null,maxLength:null,exactLength:null,typeName:v.ZodArray,...b(e)});function _e(t){if(t instanceof O){let e={};for(let r in t.shape){let s=t.shape[r];e[r]=L.create(_e(s))}return new O({...t._def,shape:()=>e})}else return t instanceof K?new K({...t._def,type:_e(t.element)}):t instanceof L?L.create(_e(t.unwrap())):t instanceof H?H.create(_e(t.unwrap())):t instanceof z?z.create(t.items.map(e=>_e(e))):t}var O=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)!==h.object){let d=this._getOrReturnCtx(e);return p(d,{code:c.invalid_type,expected:h.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 V&&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 j(n,g,n.path,d)),alwaysSet:d in n.data})}if(this._def.catchall instanceof V){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&&(p(n,{code:c.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 j(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=>N.mergeObjectSync(s,d)):N.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 L;)i=i._def.innerType;r[s]=i}return new t({...this._def,shape:()=>r})}keyof(){return mt(k.objectKeys(this.shape))}};O.create=(t,e)=>new O({shape:()=>t,unknownKeys:"strip",catchall:V.create(),typeName:v.ZodObject,...b(e)});O.strictCreate=(t,e)=>new O({shape:()=>t,unknownKeys:"strict",catchall:V.create(),typeName:v.ZodObject,...b(e)});O.lazycreate=(t,e)=>new O({shape:t,unknownKeys:"strip",catchall:V.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 A(o.ctx.common.issues));return p(r,{code:c.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 A(l));return p(r,{code:c.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 W=t=>t instanceof ce?W(t.schema):t instanceof M?W(t.innerType()):t instanceof ue?[t.value]:t instanceof fe?t.options:t instanceof pe?k.objectValues(t.enum):t instanceof he?W(t._def.innerType):t instanceof ae?[void 0]:t instanceof oe?[null]:t instanceof L?[void 0,...W(t.unwrap())]:t instanceof H?[null,...W(t.unwrap())]:t instanceof Ee||t instanceof ge?W(t.unwrap()):t instanceof me?W(t._def.innerType):[],$e=class t extends _{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==h.object)return p(r,{code:c.invalid_type,expected:h.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}):(p(r,{code:c.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=W(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===h.object&&s===h.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===h.array&&s===h.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===h.date&&s===h.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}):(p(s,{code:c.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 z=class t extends _{_parse(e){let{status:r,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.array)return p(s,{code:c.invalid_type,expected:h.array,received:s.parsedType}),y;if(s.data.length<this._def.items.length)return p(s,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&s.data.length>this._def.items.length&&(p(s,{code:c.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 j(s,a,s.path,o)):null}).filter(a=>!!a);return s.common.async?Promise.all(i).then(a=>N.mergeArray(r,a)):N.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};z.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new z({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!==h.object)return p(s,{code:c.invalid_type,expected:h.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 j(s,o,s.path,o)),value:a._parse(new j(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?N.mergeObjectAsync(r,n):N.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:Q.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!==h.map)return p(s,{code:c.invalid_type,expected:h.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 j(s,o,s.path,[d,"key"])),value:i._parse(new j(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!==h.set)return p(s,{code:c.invalid_type,expected:h.set,received:s.parsedType}),y;let n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(p(s,{code:c.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&&(p(s,{code:c.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 j(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!==h.function)return p(r,{code:c.invalid_type,expected:h.function,received:r.parsedType}),y;function s(o,l){return Se({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ve(),q].filter(d=>!!d),issueData:{code:c.invalid_arguments,argumentsError:l}})}function n(o,l){return Se({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ve(),q].filter(d=>!!d),issueData:{code:c.invalid_return_type,returnTypeError:l}})}let i={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof ee){let o=this;return S(async function(...l){let d=new A([]),f=await o._def.args.parseAsync(l,i).catch(I=>{throw d.addIssue(s(l,I)),d}),g=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(g,i).catch(I=>{throw d.addIssue(n(g,I)),d})})}else{let o=this;return S(function(...l){let d=o._def.args.safeParse(l,i);if(!d.success)throw new A([s(l,d.error)]);let f=Reflect.apply(a,this,d.data),g=o._def.returns.safeParse(f,i);if(!g.success)throw new A([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:z.create(e).rest(J.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||z.create([]).rest(J.create()),returns:r||J.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 p(r,{received:r.data,code:c.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 mt(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 p(r,{expected:k.joinValues(s),received:r.parsedType,code:c.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 p(r,{received:r.data,code:c.invalid_enum_value,options:s}),y}return S(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=mt;var pe=class extends _{_parse(e){let r=k.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==h.string&&s.parsedType!==h.number){let n=k.objectValues(r);return p(s,{expected:k.joinValues(n),received:s.parsedType,code:c.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 p(s,{received:s.data,code:c.invalid_enum_value,options:n}),y}return S(e.data)}get enum(){return this._def.values}};pe.create=(t,e)=>new pe({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!==h.promise&&r.common.async===!1)return p(r,{code:c.invalid_type,expected:h.promise,received:r.parsedType}),y;let s=r.parsedType===h.promise?r.data:Promise.resolve(r.data);return S(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=>{p(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(!X(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=>X(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 L=class extends _{_parse(e){return this._getType(e)===h.undefined?S(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};L.create=(t,e)=>new L({innerType:t,typeName:v.ZodOptional,...b(e)});var H=class extends _{_parse(e){return this._getType(e)===h.null?S(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 he=class extends _{_parse(e){let{ctx:r}=this._processInputParams(e),s=r.data;return r.parsedType===h.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};he.create=(t,e)=>new he({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 A(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new A(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)!==h.nan){let s=this._getOrReturnCtx(e);return p(s,{code:c.invalid_type,expected:h.nan,received:s.parsedType}),y}return{status:"valid",value:e.data}}};Te.create=t=>new Te({typeName:v.ZodNaN,...b(t)});var cr=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=>(X(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 ut(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function gt(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=ut(e,s),l=o.fatal??r??!0;n.addIssue({code:"custom",...o,fatal:l})}});if(!i){let a=ut(e,s),o=a.fatal??r??!0;n.addIssue({code:"custom",...a,fatal:o})}}):G.create()}var ur={object:O.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 fr=(t,e={message:`Input not instance of ${t.name}`})=>gt(r=>r instanceof t,e),yt=Q.create,vt=re.create,pr=Te.create,hr=se.create,bt=ne.create,mr=ie.create,gr=xe.create,yr=ae.create,vr=oe.create,br=G.create,_r=J.create,xr=V.create,kr=ke.create,wr=K.create,Cr=O.create,Tr=O.strictCreate,Nr=le.create,Sr=$e.create,Er=de.create,Fr=z.create,Ar=Le.create,Or=we.create,Rr=Ce.create,Ir=je.create,$r=ce.create,Lr=ue.create,jr=fe.create,Mr=pe.create,Pr=ee.create,Vr=M.create,Dr=L.create,Ur=H.create,Zr=M.createWithPreprocess,zr=Fe.create,Hr=()=>yt().optional(),Br=()=>vt().optional(),qr=()=>bt().optional(),Wr={string:(t=>Q.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 Jr=y;var Kr=["heading","paragraph","divider"];function Ae(t){return!Kr.includes(t.kind)}function _t(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 Yr(t,e){let r=e[t.fieldId];switch(t.op){case"answered":return _t(r);case"not_answered":return!_t(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 Xr(t,e){return!t.visibleIf||t.visibleIf.length===0?!0:t.visibleIf.every(r=>Yr(r,e))}function Ye(t,e){return t.blocks.filter(r=>Xr(r,e))}function Qr(t){return t.pages.flatMap(e=>e.blocks.filter(Ae))}function Gr(t,e){return t.pages.flatMap(r=>Ye(r,e).filter(Ae))}var es=w.object({fileId:w.string().min(1),name:w.string(),size:w.number().nonnegative(),mime:w.string(),url:w.string().optional()});function xt(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 kt(t,e){if(xt(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(es).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 ts(t,e){let r=Gr(t,e),s={},n={};for(let i of r){let a=rs(i,e[i.id]),o=kt(i,a);o?s[i.id]=o:xt(a)||(n[i.id]=a)}return{ok:Object.keys(s).length===0,errors:s,data:n}}function rs(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 ss=["short_text","long_text","email","url","phone","number","select","multi_select","dropdown","checkbox","rating","linear_scale","ranking","matrix","signature","date","file_upload","hidden","custom"],ns=["heading","paragraph","divider"],is=[...ss,...ns],Xe=w.string().min(1).max(128),Be=w.object({id:Xe,label:w.string().max(1e3)}).passthrough(),as=w.object({id:Xe,kind:w.enum(is),label:w.string().max(2e3).optional(),options:w.array(Be).max(200).optional(),rows:w.array(Be).max(200).optional(),columns:w.array(Be).max(200).optional()}).passthrough(),os=w.object({id:Xe,title:w.string().max(500).optional(),blocks:w.array(as).max(500)}),an=w.object({version:w.literal(1),title:w.string().max(2e3).optional().default(""),description:w.string().max(5e3).optional(),pages:w.array(os).min(1).max(50),settings:w.record(w.unknown()).optional().default({})});var ls="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",on=256-256%ls.length;var R=class extends Error{constructor(t,e){super(t),this.status=e,this.name="FilloError"}status},qe=3;function We(t,e){return r=>e.onProgress?.({uploadedBytes:r,totalBytes:t,fraction:t===0?1:r/t})}var ds="https://fillo.so",Me=class{baseUrl;fetch;key;constructor(t={}){this.baseUrl=(t.baseUrl??ds).replace(/\/$/,""),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 R(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 R("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 R(`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})}),i.transport?.type==="gdrive"?await this.driveUploadLoop(i,i.transport.uploadUrl,e,r):i.transport?.type==="s3-put"?await this.s3PutUpload(i.transport.uploadUrl,e,r):await this.formworkUploadLoop(i,e,r);let a=await this.json(`/uploads/${encodeURIComponent(i.id)}/complete`,{method:"POST",headers:i.token?{"X-Fillo-Upload-Token":i.token}:void 0});if(!a.file)throw new R("Upload completed but no file was returned");return a.file}async formworkUploadLoop(t,e,r){let s=t.uploadedBytes,n=We(e.size,r);for(n(s);s<e.size;){r.signal?.throwIfAborted();let i=e.slice(s,s+t.chunkSize),a=0;for(;;)try{let o=await this.fetch(this.url(`/uploads/${encodeURIComponent(t.id)}/chunk`),{method:"PUT",headers:{"Content-Type":"application/octet-stream","X-Upload-Offset":String(s),...t.token?{"X-Fillo-Upload-Token":t.token}:{}},body:i,signal:r.signal});if(o.status===409){s=(await o.json()).uploadedBytes;break}if(!o.ok)throw new R(`Chunk failed: ${o.status}`,o.status);s=(await o.json()).uploadedBytes;break}catch(o){if(r.signal?.aborted||(a+=1,a>=qe))throw o;await new Promise(d=>setTimeout(d,500*2**a)),s=(await this.getUploadSession(t.id,t.token)).uploadedBytes}n(s)}}async driveUploadLoop(t,e,r,s){let n=t.uploadedBytes,i=We(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 g=(d.headers.get("Range")??d.headers.get("range"))?.match(/bytes=0-(\d+)/);n=g?Number(g[1])+1:0;break}if(d.ok){n=r.size;break}throw new R(`Drive chunk failed: ${d.status}`,d.status)}catch(d){if(s.signal?.aborted||(l+=1,l>=qe))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=We(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 R(`S3 upload failed: ${i.status}`,i.status);s(e.size);return}catch(i){if(r.signal?.aborted||(n+=1,n>=qe))throw i;await new Promise(a=>setTimeout(a,500*2**n))}}};function Oe(t={}){return new Me(t)}var cs={id:"empty",blocks:[]};function wt(t){let{onChange:e,onSubmitted:r,onSubmit:s}=t,n=t.form,i=t.formId,a=t.client,o={...t.initialData??{}},l={},d=0,f="idle",g=new Set,T=new Set,I=Date.now(),U=null,Y=!1;function it(){let x=n.pages.length,C=Math.min(d,Math.max(x-1,0)),F=n.pages[C]??cs;return{data:o,errors:l,status:f,pageIndex:C,pageCount:x,page:F,blocks:Ye(F,o),isFirstPage:C===0,isLastPage:C===x-1,uploading:g.size>0}}let at=it();function $(){at=it();for(let x of T)x()}function Et(x){let C=n.pages[x];if(!C)return{};let F={};for(let ye of Ye(C,o)){if(!Ae(ye))continue;let ot=kt(ye,o[ye.id]);ot&&(F[ye.id]=ot)}return F}function Ft(x,C){!Y&&a&&i&&(Y=!0,a.startSession(i,n.pages.length).then(F=>U=F)),o={...o,[x]:C},e?.(o),x in l&&(l=Object.fromEntries(Object.entries(l).filter(([F])=>F!==x))),$()}function At(x,C){C?g.add(x):g.delete(x),$()}function Ot(){let x=n.pages.length,C=Math.min(d,Math.max(x-1,0)),F=Et(C);if(l=F,Object.keys(F).length>0){$();return}d=Math.min(C+1,x-1),U&&a&&a.reportProgress(U,{furthestPage:d}),$()}function Rt(){l={},d=Math.max(Math.min(d,n.pages.length-1)-1,0),$()}async function It(){if(f==="submitting"||f==="submitted")return;let x=ts(n,o);if(!x.ok){l=x.errors;let C=n.pages.findIndex(F=>F.blocks.some(ye=>ye.id in x.errors));C>=0&&(d=C),$();return}f="submitting",$();try{if(s)await s(x.data),f="submitted",$(),r?.(void 0,x.data);else if(a&&i){let C=await a.submit(i,x.data,{hp:t.getHoneypot?.()??"",elapsedMs:Date.now()-I});if(!C.ok){l=C.errors??{},f="idle",$();return}U&&a.reportProgress(U,{completed:!0}),f="submitted",$(),r?.(C.responseId,x.data)}else f="submitted",$(),r?.(void 0,x.data)}catch(C){throw f="idle",$(),C}}return{getState:()=>at,subscribe(x){return T.add(x),()=>{T.delete(x)}},setValue:Ft,setUploading:At,next:Ot,back:Rt,submit:It,setContext(x){"formId"in x&&(i=x.formId),"client"in x&&(a=x.client),x.form&&x.form!==n&&(n=x.form,$())},destroy(){T.clear()}}}function Qe(t){return{id:t.id,theme:t.theme,schema:{version:1,title:t.title??"",description:t.description,pages:t.pages,settings:t.settings??{}},__formworkCodeForm:!0}}function Ge(t){return typeof t=="object"&&t!==null&&"__formworkCodeForm"in t}var Je=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 Ct(t,e){let r=JSON.stringify(e.schema)+JSON.stringify(e.theme??null),s=`${t.baseUrl}:${t.key}:${e.id}:${us(r)}`,n=Je.get(s);return n||(n=t.syncForm(e.id,e.schema,e.theme??null),Je.set(s,n),n.catch(()=>Je.delete(s))),n}var fs=/\{\{\s*([\w-]+)\s*\}\}/g;function Ke(t,e,r){if(!t.includes("{{"))return t;let s=Qr(r);return t.replace(fs,(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 Tt(t,e,r){let s=n=>n===void 0?n:Ke(n,e,r);switch(t.kind){case"heading":case"paragraph":return{...t,text:Ke(t.text,e,r)};case"divider":return t;default:return{...t,label:Ke(t.label,e,r),description:s(t.description)}}}var E="fillo-";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[s,n]of Object.entries(e.attrs??{}))r.setAttribute(s,n);return r}function Pe(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 ps(t){return typeof t=="string"||typeof t=="number"?String(t):""}function P(t,e){for(let r of e)r&&t.appendChild(r);return t}function B(t,e,r){r&&t.setAttribute("aria-invalid","true"),e.required&&t.setAttribute("aria-required","true");let s=[e.description?`${E}${e.id}-desc`:null,r?`${E}${e.id}-error`:null].filter(Boolean).join(" ");s&&t.setAttribute("aria-describedby",s)}function D(t,e,r){let s=u("div",{className:`fillo-field fillo-field--${t.kind}${e?" fillo-field--error":""}`,attrs:{"data-field":t.id}}),n=u("label",{className:"fillo-label",text:t.label,attrs:{id:`${E}${t.id}-label`,for:`${E}${t.id}`}});return t.required&&n.appendChild(u("span",{className:"fillo-required",text:" *",attrs:{"aria-hidden":"true"}})),s.appendChild(n),t.description&&s.appendChild(u("p",{className:"fillo-description",text:t.description,attrs:{id:`${E}${t.id}-desc`}})),s.appendChild(r),e&&s.appendChild(u("p",{className:"fillo-error",text:e,attrs:{role:"alert",id:`${E}${t.id}-error`}})),s}function Ne(t,e){let r=u("input",{className:"fillo-input",attrs:{id:`${E}${e.field.id}`,type:t}});return r.value=ps(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)),B(r,e.field,e.error),D(e.field,e.error,r)}function hs(t){let e=u("textarea",{className:"fillo-input fillo-textarea",attrs:{id:`${E}${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)),B(e,t.field,t.error),D(t.field,t.error,e)}function ms(t){let e=t.field,r=st(e),s=typeof t.value=="string"?t.value:"",n=s!==""&&!e.options.some(a=>a.id===s),i=u("div",{className:"fillo-options",attrs:{role:"radiogroup","aria-labelledby":`${E}${e.id}-label`}});B(i,e,t.error);for(let a of r){let o=u("label",{className:`fillo-option${s===a.id?" fillo-option--selected":""}`,attrs:{"data-option":a.id}}),l=u("input",{className:"fillo-option-input",attrs:{type:"radio",name:`fillo-${e.id}`}});l.checked=s===a.id,l.addEventListener("change",()=>t.setValue(a.id)),P(o,[l,u("span",{className:"fillo-option-label",text:a.label})]),i.appendChild(o)}if(e.allowOther){let a=u("label",{className:`fillo-option${n?" fillo-option--selected":""}`}),o=u("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(u("span",{className:"fillo-option-label",text:"Other"})),n){let l=u("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 D(e,t.error,i)}function gs(t){let e=t.field,r=st(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=u("div",{className:"fillo-options",attrs:{role:"group","aria-labelledby":`${E}${e.id}-label`}});B(a,e,t.error);let o=l=>t.setValue(l);for(let l of r){let d=u("label",{className:`fillo-option${s.includes(l.id)?" fillo-option--selected":""}`,attrs:{"data-option":l.id}}),f=u("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))}),P(d,[f,u("span",{className:"fillo-option-label",text:l.label})]),a.appendChild(d)}if(e.allowOther){let l=i!==void 0,d=u("label",{className:`fillo-option${l?" fillo-option--selected":""}`}),f=u("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)}),P(d,[f,u("span",{className:"fillo-option-label",text:"Other"})]),l){let g=u("input",{className:"fillo-input fillo-other-input",attrs:{type:"text"}});g.value=i??"",g.placeholder="Your answer",g.addEventListener("input",()=>{let T=s.filter(I=>n.has(I));t.setValue(g.value?[...T,g.value]:T,{render:!1})}),g.addEventListener("change",()=>{let T=s.filter(I=>n.has(I));t.setValue(g.value?[...T,g.value]:T)}),d.appendChild(g)}a.appendChild(d)}return D(e,t.error,a)}var et="__fw_other__";function ys(t){let e=t.field,r=typeof t.value=="string"?t.value:"",s=r!==""&&!e.options.some(a=>a.id===r),n=u("div"),i=u("select",{className:"fillo-input fillo-select",attrs:{id:`${E}${e.id}`}});i.appendChild(u("option",{text:e.placeholder??"Choose...",attrs:{value:""}}));for(let a of st(e))i.appendChild(u("option",{text:a.label,attrs:{value:a.id}}));if(e.allowOther&&i.appendChild(u("option",{text:"Other...",attrs:{value:et}})),i.value=s?et:r,i.addEventListener("change",()=>{t.setValue(i.value===et?"":i.value||null)}),B(i,e,t.error),n.appendChild(i),s){let a=u("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 D(e,t.error,n)}function vs(t){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"}),s=u("input",{className:"fillo-option-input",attrs:{id:`${E}${t.field.id}`,type:"checkbox"}});s.checked=t.value===!0,s.addEventListener("change",()=>t.setValue(s.checked)),B(s,t.field,t.error);let n=u("span",{className:"fillo-option-label",text:t.field.label});return t.field.required&&n.appendChild(u("span",{className:"fillo-required",text:" *",attrs:{"aria-hidden":"true"}})),P(r,[s,n]),e.appendChild(r),t.field.description&&e.appendChild(u("p",{className:"fillo-description",text:t.field.description,attrs:{id:`${E}${t.field.id}-desc`}})),t.error&&e.appendChild(u("p",{className:"fillo-error",text:t.error,attrs:{role:"alert",id:`${E}${t.field.id}-error`}})),e}function bs(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,s=u("div",{className:"fillo-rating",attrs:{role:"radiogroup","aria-label":t.field.label}});B(s,t.field,t.error);for(let n=1;n<=e;n++){let i=u("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 D(t.field,t.error,s)}function _s(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,s=u("div"),n=u("div",{className:"fillo-scale",attrs:{role:"radiogroup","aria-label":t.field.label}});B(n,t.field,t.error);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)),n.appendChild(a)}return s.appendChild(n),("minLabel"in t.field||"maxLabel"in t.field)&&P(s,[P(u("div",{className:"fillo-scale-labels"}),[u("span",{text:String(t.field.minLabel??"")}),u("span",{text:String(t.field.maxLabel??"")})])]),D(t.field,t.error,s)}function xs(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=u("ol",{className:"fillo-ranking"});for(let[i,a]of s.entries()){let o=e.options.find(I=>I.id===a);if(!o)continue;let l=u("li",{className:"fillo-ranking-item"}),d=u("span",{className:"fillo-ranking-controls"}),f=I=>{let U=i+I;if(U<0||U>=s.length)return;let Y=[...s];[Y[i],Y[U]]=[Y[U],Y[i]],t.setValue(Y)},g=u("button",{className:"fillo-ranking-move",text:"Up",attrs:{type:"button"}});g.toggleAttribute("disabled",i===0),g.addEventListener("click",()=>f(-1));let T=u("button",{className:"fillo-ranking-move",text:"Down",attrs:{type:"button"}});T.toggleAttribute("disabled",i===s.length-1),T.addEventListener("click",()=>f(1)),P(d,[g,T]),P(l,[u("span",{className:"fillo-ranking-index",text:String(i+1)}),u("span",{className:"fillo-ranking-label",text:o.label}),d]),n.appendChild(l)}return D(t.field,t.error,n)}function ks(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=u("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(u("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(u("th",{text:o.label,attrs:{scope:"row"}}));for(let d of e.columns){let f=document.createElement("td"),g=u("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),D(t.field,t.error,P(u("div",{className:"fillo-matrix-wrap"}),[s]))}function ws(t){let e=u("div",{className:"fillo-signature"}),r=u("canvas",{className:"fillo-signature-canvas",attrs:{id:`${E}${t.field.id}`}});B(r,t.field,t.error);let s=u("button",{className:"fillo-signature-clear",text:"Clear",attrs:{type:"button"}}),n=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 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)}),P(e,[r,n,s]),D(t.field,t.error,e)}function Cs(t){let e=t.field;if(e.kind!=="file_upload")return null;let r=u("input",{className:"fillo-input",attrs:{id:`${E}${e.id}`,type:"file"}});(e.maxFiles??1)>1&&(r.multiple=!0),e.accept?.length&&(r.accept=e.accept.join(",")),B(r,e,t.error),r.addEventListener("change",()=>{let a=Array.from(r.files??[]);t.uploadFiles?.(e,a)});let s=u("div");s.appendChild(r);let n=t.uploadProgress?.get(e.id);if(n!==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(n*100)}%`),s.appendChild(a)}let i=Array.isArray(t.value)?t.value:[];for(let a of i)s.appendChild(u("p",{className:"fillo-description",text:`${a.name} (${Math.round(a.size/1024)} KB)`}));return D(e,t.error,s)}var Nt=new Map;function st(t){if(!t.shuffleOptions)return t.options;let e=`${t.id}|${t.options.map(i=>i.id).join(",")}`,r=Nt.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]]}Nt.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 Ts={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:hs,select:ms,multi_select:gs,dropdown:ys,checkbox:vs,rating:bs,linear_scale:_s,ranking:xs,matrix:ks,signature:ws,file_upload:Cs};function Ns(t){if(t.field.kind==="hidden"||t.field.kind==="custom")return null;let e=Ts[t.field.kind];return e?e(t):null}var tt=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");schema=null;theme;formId;closed=!1;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=Ge(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&&Ct(this.options.client,e).then(({formId:n})=>{this.formId=n,this.engine?.setContext({formId:n})}).catch(n=>this.handleError(Ve(n)));return}let r=this.options.form&&!Ge(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 R("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.setSchema(s.schema,this.options.theme??s.theme??void 0,s.id)}catch(e){this.handleError(Ve(e))}}setSchema(e,r,s){this.schema=e,this.theme=r,this.formId=s,this.engine=wt({form:e,formId:s,client:this.options.client,initialData:this.options.initialData,onChange:this.options.onChange,onSubmitted:this.options.onSubmitted,onSubmit:this.options.onSubmit,getHoneypot:()=>this.hpValue}),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(Ve(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(Ve(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"}});Pe(r,this.theme),P(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??""}`});Pe(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(),s=this.options.renderSuccess?.(r)??Es(this.schema);Pe(s,this.theme),this.element.appendChild(s);return}this.element.appendChild(this.renderForm())}}}renderForm(){let e=this.api(),r=u("form",{className:`fillo-form ${this.options.className??""}`});Pe(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=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 n=u("div",{className:"fillo-blocks"});for(let l of e.blocks){let d=this.renderBlock(Tt(l,this.mutableData,e.form),e);d&&n.appendChild(d)}r.appendChild(n);let i=u("input",{className:"fillo-hp",attrs:{type:"text",name:"fw_hp_field",tabindex:"-1",autocomplete:"off","aria-hidden":"true"}});i.addEventListener("input",()=>{this.hpValue=i.value}),r.appendChild(i);let a=u("footer",{className:"fillo-footer"});if(e.pageCount>1&&!e.isFirstPage){let l=u("button",{className:"fillo-button fillo-button--ghost",text:"Back",attrs:{type:"button"}});l.addEventListener("click",()=>this.back()),a.appendChild(l)}let o=u("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 Ss(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]??Ns)?.(n)??null}};function Ss(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 Es(t){let e=u("div",{className:"fillo-form fillo-form--success"}),r=u("div",{className:"fillo-success"});return P(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 Ve(t){return t instanceof R?t:new R(t instanceof Error?t.message:String(t),0)}function De(t,e){let r=typeof t=="string"?document.querySelector(t):t;if(!r)throw new R(`Fillo mount target not found: ${String(t)}`,0);return new tt(r,{...e,initialData:e.initialData??{}})}function St(t){let e=u("div");return De(e,t),e}var rt=class extends HTMLElement{instance=null;assignedForm;assignedClient;assignedTheme;assignedInitialData;static get observedAttributes(){return["base-url","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("base-url"),r=this.getAttribute("publishable-key")??void 0,s=this.getAttribute("form-id")??void 0,n=this.assignedClient??(s||r||e?Oe({baseUrl:e??void 0,key:r}):void 0);this.instance=De(this,{form:this.assignedForm,client:n,formId:s,theme:this.assignedTheme,initialData:this.assignedInitialData,onChange:i=>this.dispatchEvent(new CustomEvent("fillo-change",{detail:{data:i}})),onSubmitted:(i,a)=>this.dispatchEvent(new CustomEvent("fillo-submit",{detail:{responseId:i,data:a}})),onError:i=>this.dispatchEvent(new CustomEvent("fillo-error",{detail:{error:i}}))})}};function nt(t="fillo-form"){customElements.get(t)||customElements.define(t,rt)}nt();return Pt(Fs);})();
|
|
1
|
+
"use strict";var Fillo=(()=>{var Ue=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Lt=Object.prototype.hasOwnProperty;var lt=(t,e)=>{for(var r in e)Ue(t,r,{get:e[r],enumerable:!0})},Mt=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of jt(e))!Lt.call(t,n)&&n!==r&&Ue(t,n,{get:()=>e[n],enumerable:!(s=$t(e,n))||s.enumerable});return t};var Pt=t=>Mt(Ue({},"__esModule",{value:!0}),t);var Fs={};lt(Fs,{FilloClient:()=>Me,FilloError:()=>R,createClient:()=>Oe,createFormElement:()=>St,defineForm:()=>Qe,registerFilloElement:()=>nt,renderForm:()=>De});var w={};lt(w,{BRAND:()=>cr,DIRTY:()=>te,EMPTY_PATH:()=>Zt,INVALID:()=>y,NEVER:()=>Jr,OK:()=>S,ParseStatus:()=>N,Schema:()=>_,ZodAny:()=>G,ZodArray:()=>K,ZodBigInt:()=>se,ZodBoolean:()=>ne,ZodBranded:()=>Ee,ZodCatch:()=>me,ZodDate:()=>ie,ZodDefault:()=>he,ZodDiscriminatedUnion:()=>$e,ZodEffects:()=>M,ZodEnum:()=>fe,ZodError:()=>A,ZodFirstPartyTypeKind:()=>v,ZodFunction:()=>Le,ZodIntersection:()=>de,ZodIssueCode:()=>c,ZodLazy:()=>ce,ZodLiteral:()=>ue,ZodMap:()=>we,ZodNaN:()=>Te,ZodNativeEnum:()=>pe,ZodNever:()=>V,ZodNull:()=>oe,ZodNullable:()=>H,ZodNumber:()=>re,ZodObject:()=>O,ZodOptional:()=>j,ZodParsedType:()=>h,ZodPipeline:()=>Fe,ZodPromise:()=>ee,ZodReadonly:()=>ge,ZodRecord:()=>je,ZodSchema:()=>_,ZodSet:()=>Ce,ZodString:()=>Q,ZodSymbol:()=>xe,ZodTransformer:()=>M,ZodTuple:()=>z,ZodType:()=>_,ZodUndefined:()=>ae,ZodUnion:()=>le,ZodUnknown:()=>J,ZodVoid:()=>ke,addIssueToContext:()=>p,any:()=>br,array:()=>wr,bigint:()=>hr,boolean:()=>bt,coerce:()=>Wr,custom:()=>gt,date:()=>mr,datetimeRegex:()=>ht,defaultErrorMap:()=>q,discriminatedUnion:()=>Sr,effect:()=>Vr,enum:()=>Lr,function:()=>Ir,getErrorMap:()=>ve,getParsedType:()=>Z,instanceof:()=>fr,intersection:()=>Er,isAborted:()=>Re,isAsync:()=>be,isDirty:()=>Ie,isValid:()=>X,late:()=>ur,lazy:()=>$r,literal:()=>jr,makeIssue:()=>Se,map:()=>Or,nan:()=>pr,nativeEnum:()=>Mr,never:()=>xr,null:()=>vr,nullable:()=>Ur,number:()=>vt,object:()=>Cr,objectUtil:()=>Ze,oboolean:()=>qr,onumber:()=>Br,optional:()=>Dr,ostring:()=>Hr,pipeline:()=>zr,preprocess:()=>Zr,promise:()=>Pr,quotelessJson:()=>Vt,record:()=>Ar,set:()=>Rr,setErrorMap:()=>Ut,strictObject:()=>Tr,string:()=>yt,symbol:()=>gr,transformer:()=>Vr,tuple:()=>Fr,undefined:()=>yr,union:()=>Nr,unknown:()=>_r,util:()=>k,void:()=>kr});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 h=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 h.undefined;case"string":return h.string;case"number":return Number.isNaN(t)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(t)?h.array:t===null?h.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?h.promise:typeof Map<"u"&&t instanceof Map?h.map:typeof Set<"u"&&t instanceof Set?h.set:typeof Date<"u"&&t instanceof Date?h.date:h.object;default:return h.unknown}};var c=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"]),Vt=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),A=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()}};A.create=t=>new A(t);var Dt=(t,e)=>{let r;switch(t.code){case c.invalid_type:t.received===h.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case c.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,k.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:r=`Unrecognized key(s) in object: ${k.joinValues(t.keys,", ")}`;break;case c.invalid_union:r="Invalid input";break;case c.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${k.joinValues(t.options)}`;break;case c.invalid_enum_value:r=`Invalid enum value. Expected ${k.joinValues(t.options)}, received '${t.received}'`;break;case c.invalid_arguments:r="Invalid function arguments";break;case c.invalid_return_type:r="Invalid function return type";break;case c.invalid_date:r="Invalid date";break;case c.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 c.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 c.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 c.custom:r="Invalid input";break;case c.invalid_intersection_types:r="Intersection results could not be merged";break;case c.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case c.not_finite:r="Number must be finite";break;default:r=e.defaultError,k.assertNever(t)}return{message:r}},q=Dt;var dt=q;function Ut(t){dt=t}function ve(){return dt}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}},Zt=[];function p(t,e){let r=ve(),s=Se({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===q?void 0:q].filter(n=>!!n)});t.common.issues.push(s)}var N=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}),S=t=>({status:"valid",value:t}),Re=t=>t.status==="aborted",Ie=t=>t.status==="dirty",X=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 L=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}},ct=(t,e)=>{if(X(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 A(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 N,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 ct(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 X(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=>X(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 ct(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:c.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 K.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 he({...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}},zt=/^c[^\s-]{8,}$/i,Ht=/^[0-9a-z]+$/,Bt=/^[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,Wt=/^[a-z0-9_-]{21}$/i,Jt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Kt=/^[-+]?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)?)??$/,Yt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Xt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ze,Qt=/^(?:(?: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])$/,Gt=/^(?:(?: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])$/,er=/^(([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]))$/,tr=/^(([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])$/,rr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,sr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ft="((\\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])))",nr=new RegExp(`^${ft}$`);function pt(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 ir(t){return new RegExp(`^${pt(t)}$`)}function ht(t){let e=`${ft}T${pt(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 ar(t,e){return!!((e==="v4"||!e)&&Qt.test(t)||(e==="v6"||!e)&&er.test(t))}function or(t,e){if(!Jt.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 lr(t,e){return!!((e==="v4"||!e)&&Gt.test(t)||(e==="v6"||!e)&&tr.test(t))}var Q=class t extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){let i=this._getOrReturnCtx(e);return p(i,{code:c.invalid_type,expected:h.string,received:i.parsedType}),y}let s=new N,n;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),p(n,{code:c.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),p(n,{code:c.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?p(n,{code:c.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&p(n,{code:c.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),s.dirty())}else if(i.kind==="email")Yt.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"email",code:c.invalid_string,message:i.message}),s.dirty());else if(i.kind==="emoji")ze||(ze=new RegExp(Xt,"u")),ze.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"emoji",code:c.invalid_string,message:i.message}),s.dirty());else if(i.kind==="uuid")qt.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"uuid",code:c.invalid_string,message:i.message}),s.dirty());else if(i.kind==="nanoid")Wt.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"nanoid",code:c.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid")zt.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"cuid",code:c.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid2")Ht.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"cuid2",code:c.invalid_string,message:i.message}),s.dirty());else if(i.kind==="ulid")Bt.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"ulid",code:c.invalid_string,message:i.message}),s.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),p(n,{validation:"url",code:c.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),p(n,{validation:"regex",code:c.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),p(n,{code:c.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),p(n,{code:c.invalid_string,validation:{startsWith:i.value},message:i.message}),s.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),p(n,{code:c.invalid_string,validation:{endsWith:i.value},message:i.message}),s.dirty()):i.kind==="datetime"?ht(i).test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:c.invalid_string,validation:"datetime",message:i.message}),s.dirty()):i.kind==="date"?nr.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:c.invalid_string,validation:"date",message:i.message}),s.dirty()):i.kind==="time"?ir(i).test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:c.invalid_string,validation:"time",message:i.message}),s.dirty()):i.kind==="duration"?Kt.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"duration",code:c.invalid_string,message:i.message}),s.dirty()):i.kind==="ip"?ar(e.data,i.version)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"ip",code:c.invalid_string,message:i.message}),s.dirty()):i.kind==="jwt"?or(e.data,i.alg)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"jwt",code:c.invalid_string,message:i.message}),s.dirty()):i.kind==="cidr"?lr(e.data,i.version)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"cidr",code:c.invalid_string,message:i.message}),s.dirty()):i.kind==="base64"?rr.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"base64",code:c.invalid_string,message:i.message}),s.dirty()):i.kind==="base64url"?sr.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"base64url",code:c.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:c.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}};Q.create=t=>new Q({checks:[],typeName:v.ZodString,coerce:t?.coerce??!1,...b(t)});function dr(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)!==h.number){let i=this._getOrReturnCtx(e);return p(i,{code:c.invalid_type,expected:h.number,received:i.parsedType}),y}let s,n=new N;for(let i of this._def.checks)i.kind==="int"?k.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:c.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),p(s,{code:c.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),p(s,{code:c.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?dr(e.data,i.value)!==0&&(s=this._getOrReturnCtx(e,s),p(s,{code:c.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:c.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)!==h.bigint)return this._getInvalidInput(e);let s,n=new N;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),p(s,{code:c.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),p(s,{code:c.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),p(s,{code:c.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 p(r,{code:c.invalid_type,expected:h.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)!==h.boolean){let s=this._getOrReturnCtx(e);return p(s,{code:c.invalid_type,expected:h.boolean,received:s.parsedType}),y}return S(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)!==h.date){let i=this._getOrReturnCtx(e);return p(i,{code:c.invalid_type,expected:h.date,received:i.parsedType}),y}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return p(i,{code:c.invalid_date}),y}let s=new N,n;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),p(n,{code:c.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),p(n,{code:c.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)!==h.symbol){let s=this._getOrReturnCtx(e);return p(s,{code:c.invalid_type,expected:h.symbol,received:s.parsedType}),y}return S(e.data)}};xe.create=t=>new xe({typeName:v.ZodSymbol,...b(t)});var ae=class extends _{_parse(e){if(this._getType(e)!==h.undefined){let s=this._getOrReturnCtx(e);return p(s,{code:c.invalid_type,expected:h.undefined,received:s.parsedType}),y}return S(e.data)}};ae.create=t=>new ae({typeName:v.ZodUndefined,...b(t)});var oe=class extends _{_parse(e){if(this._getType(e)!==h.null){let s=this._getOrReturnCtx(e);return p(s,{code:c.invalid_type,expected:h.null,received:s.parsedType}),y}return S(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 S(e.data)}};G.create=t=>new G({typeName:v.ZodAny,...b(t)});var J=class extends _{constructor(){super(...arguments),this._unknown=!0}_parse(e){return S(e.data)}};J.create=t=>new J({typeName:v.ZodUnknown,...b(t)});var V=class extends _{_parse(e){let r=this._getOrReturnCtx(e);return p(r,{code:c.invalid_type,expected:h.never,received:r.parsedType}),y}};V.create=t=>new V({typeName:v.ZodNever,...b(t)});var ke=class extends _{_parse(e){if(this._getType(e)!==h.undefined){let s=this._getOrReturnCtx(e);return p(s,{code:c.invalid_type,expected:h.void,received:s.parsedType}),y}return S(e.data)}};ke.create=t=>new ke({typeName:v.ZodVoid,...b(t)});var K=class t extends _{_parse(e){let{ctx:r,status:s}=this._processInputParams(e),n=this._def;if(r.parsedType!==h.array)return p(r,{code:c.invalid_type,expected:h.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)&&(p(r,{code:a?c.too_big:c.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&&(p(r,{code:c.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&&(p(r,{code:c.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 L(r,a,r.path,o)))).then(a=>N.mergeArray(s,a));let i=[...r.data].map((a,o)=>n.type._parseSync(new L(r,a,r.path,o)));return N.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)}};K.create=(t,e)=>new K({type:t,minLength:null,maxLength:null,exactLength:null,typeName:v.ZodArray,...b(e)});function _e(t){if(t instanceof O){let e={};for(let r in t.shape){let s=t.shape[r];e[r]=j.create(_e(s))}return new O({...t._def,shape:()=>e})}else return t instanceof K?new K({...t._def,type:_e(t.element)}):t instanceof j?j.create(_e(t.unwrap())):t instanceof H?H.create(_e(t.unwrap())):t instanceof z?z.create(t.items.map(e=>_e(e))):t}var O=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)!==h.object){let d=this._getOrReturnCtx(e);return p(d,{code:c.invalid_type,expected:h.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 V&&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 L(n,g,n.path,d)),alwaysSet:d in n.data})}if(this._def.catchall instanceof V){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&&(p(n,{code:c.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 L(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=>N.mergeObjectSync(s,d)):N.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 mt(k.objectKeys(this.shape))}};O.create=(t,e)=>new O({shape:()=>t,unknownKeys:"strip",catchall:V.create(),typeName:v.ZodObject,...b(e)});O.strictCreate=(t,e)=>new O({shape:()=>t,unknownKeys:"strict",catchall:V.create(),typeName:v.ZodObject,...b(e)});O.lazycreate=(t,e)=>new O({shape:t,unknownKeys:"strip",catchall:V.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 A(o.ctx.common.issues));return p(r,{code:c.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 A(l));return p(r,{code:c.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 W=t=>t instanceof ce?W(t.schema):t instanceof M?W(t.innerType()):t instanceof ue?[t.value]:t instanceof fe?t.options:t instanceof pe?k.objectValues(t.enum):t instanceof he?W(t._def.innerType):t instanceof ae?[void 0]:t instanceof oe?[null]:t instanceof j?[void 0,...W(t.unwrap())]:t instanceof H?[null,...W(t.unwrap())]:t instanceof Ee||t instanceof ge?W(t.unwrap()):t instanceof me?W(t._def.innerType):[],$e=class t extends _{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==h.object)return p(r,{code:c.invalid_type,expected:h.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}):(p(r,{code:c.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=W(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===h.object&&s===h.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===h.array&&s===h.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===h.date&&s===h.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}):(p(s,{code:c.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 z=class t extends _{_parse(e){let{status:r,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.array)return p(s,{code:c.invalid_type,expected:h.array,received:s.parsedType}),y;if(s.data.length<this._def.items.length)return p(s,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&s.data.length>this._def.items.length&&(p(s,{code:c.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 L(s,a,s.path,o)):null}).filter(a=>!!a);return s.common.async?Promise.all(i).then(a=>N.mergeArray(r,a)):N.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};z.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new z({items:t,typeName:v.ZodTuple,rest:null,...b(e)})};var je=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!==h.object)return p(s,{code:c.invalid_type,expected:h.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 L(s,o,s.path,o)),value:a._parse(new L(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?N.mergeObjectAsync(r,n):N.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:Q.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!==h.map)return p(s,{code:c.invalid_type,expected:h.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 L(s,o,s.path,[d,"key"])),value:i._parse(new L(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!==h.set)return p(s,{code:c.invalid_type,expected:h.set,received:s.parsedType}),y;let n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(p(s,{code:c.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&&(p(s,{code:c.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 L(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 Le=class t extends _{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==h.function)return p(r,{code:c.invalid_type,expected:h.function,received:r.parsedType}),y;function s(o,l){return Se({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ve(),q].filter(d=>!!d),issueData:{code:c.invalid_arguments,argumentsError:l}})}function n(o,l){return Se({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ve(),q].filter(d=>!!d),issueData:{code:c.invalid_return_type,returnTypeError:l}})}let i={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof ee){let o=this;return S(async function(...l){let d=new A([]),f=await o._def.args.parseAsync(l,i).catch(I=>{throw d.addIssue(s(l,I)),d}),g=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(g,i).catch(I=>{throw d.addIssue(n(g,I)),d})})}else{let o=this;return S(function(...l){let d=o._def.args.safeParse(l,i);if(!d.success)throw new A([s(l,d.error)]);let f=Reflect.apply(a,this,d.data),g=o._def.returns.safeParse(f,i);if(!g.success)throw new A([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:z.create(e).rest(J.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||z.create([]).rest(J.create()),returns:r||J.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 p(r,{received:r.data,code:c.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 mt(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 p(r,{expected:k.joinValues(s),received:r.parsedType,code:c.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 p(r,{received:r.data,code:c.invalid_enum_value,options:s}),y}return S(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=mt;var pe=class extends _{_parse(e){let r=k.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==h.string&&s.parsedType!==h.number){let n=k.objectValues(r);return p(s,{expected:k.joinValues(n),received:s.parsedType,code:c.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 p(s,{received:s.data,code:c.invalid_enum_value,options:n}),y}return S(e.data)}get enum(){return this._def.values}};pe.create=(t,e)=>new pe({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!==h.promise&&r.common.async===!1)return p(r,{code:c.invalid_type,expected:h.promise,received:r.parsedType}),y;let s=r.parsedType===h.promise?r.data:Promise.resolve(r.data);return S(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=>{p(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(!X(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=>X(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)===h.undefined?S(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)===h.null?S(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 he=class extends _{_parse(e){let{ctx:r}=this._processInputParams(e),s=r.data;return r.parsedType===h.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};he.create=(t,e)=>new he({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 A(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new A(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)!==h.nan){let s=this._getOrReturnCtx(e);return p(s,{code:c.invalid_type,expected:h.nan,received:s.parsedType}),y}return{status:"valid",value:e.data}}};Te.create=t=>new Te({typeName:v.ZodNaN,...b(t)});var cr=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=>(X(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 ut(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function gt(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=ut(e,s),l=o.fatal??r??!0;n.addIssue({code:"custom",...o,fatal:l})}});if(!i){let a=ut(e,s),o=a.fatal??r??!0;n.addIssue({code:"custom",...a,fatal:o})}}):G.create()}var ur={object:O.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 fr=(t,e={message:`Input not instance of ${t.name}`})=>gt(r=>r instanceof t,e),yt=Q.create,vt=re.create,pr=Te.create,hr=se.create,bt=ne.create,mr=ie.create,gr=xe.create,yr=ae.create,vr=oe.create,br=G.create,_r=J.create,xr=V.create,kr=ke.create,wr=K.create,Cr=O.create,Tr=O.strictCreate,Nr=le.create,Sr=$e.create,Er=de.create,Fr=z.create,Ar=je.create,Or=we.create,Rr=Ce.create,Ir=Le.create,$r=ce.create,jr=ue.create,Lr=fe.create,Mr=pe.create,Pr=ee.create,Vr=M.create,Dr=j.create,Ur=H.create,Zr=M.createWithPreprocess,zr=Fe.create,Hr=()=>yt().optional(),Br=()=>vt().optional(),qr=()=>bt().optional(),Wr={string:(t=>Q.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 Jr=y;var Kr=["heading","paragraph","divider"];function Ae(t){return!Kr.includes(t.kind)}function _t(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 Yr(t,e){let r=e[t.fieldId];switch(t.op){case"answered":return _t(r);case"not_answered":return!_t(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 Xr(t,e){return!t.visibleIf||t.visibleIf.length===0?!0:t.visibleIf.every(r=>Yr(r,e))}function Ye(t,e){return t.blocks.filter(r=>Xr(r,e))}function Qr(t){return t.pages.flatMap(e=>e.blocks.filter(Ae))}function Gr(t,e){return t.pages.flatMap(r=>Ye(r,e).filter(Ae))}var es=w.object({fileId:w.string().min(1),name:w.string(),size:w.number().nonnegative(),mime:w.string(),url:w.string().optional()});function xt(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 kt(t,e){if(xt(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(es).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 ts(t,e){let r=Gr(t,e),s={},n={};for(let i of r){let a=rs(i,e[i.id]),o=kt(i,a);o?s[i.id]=o:xt(a)||(n[i.id]=a)}return{ok:Object.keys(s).length===0,errors:s,data:n}}function rs(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 ss=["short_text","long_text","email","url","phone","number","select","multi_select","dropdown","checkbox","rating","linear_scale","ranking","matrix","signature","date","file_upload","hidden","custom"],ns=["heading","paragraph","divider"],is=[...ss,...ns],Xe=w.string().min(1).max(128),Be=w.object({id:Xe,label:w.string().max(1e3)}).passthrough(),as=w.object({id:Xe,kind:w.enum(is),label:w.string().max(2e3).optional(),options:w.array(Be).max(200).optional(),rows:w.array(Be).max(200).optional(),columns:w.array(Be).max(200).optional()}).passthrough(),os=w.object({id:Xe,title:w.string().max(500).optional(),blocks:w.array(as).max(500)}),an=w.object({version:w.literal(1),title:w.string().max(2e3).optional().default(""),description:w.string().max(5e3).optional(),pages:w.array(os).min(1).max(50),settings:w.record(w.unknown()).optional().default({})});var ls="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",on=256-256%ls.length;var R=class extends Error{constructor(t,e){super(t),this.status=e,this.name="FilloError"}status},qe=3;function We(t,e){return r=>e.onProgress?.({uploadedBytes:r,totalBytes:t,fraction:t===0?1:r/t})}var ds="https://fillo.so",Me=class{baseUrl;fetch;key;constructor(t={}){this.baseUrl=(t.baseUrl??ds).replace(/\/$/,""),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 R(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 R("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 R(`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})}),i.transport?.type==="gdrive"?await this.driveUploadLoop(i,i.transport.uploadUrl,e,r):i.transport?.type==="s3-put"?await this.s3PutUpload(i.transport.uploadUrl,e,r):await this.formworkUploadLoop(i,e,r);let a=await this.json(`/uploads/${encodeURIComponent(i.id)}/complete`,{method:"POST",headers:i.token?{"X-Fillo-Upload-Token":i.token}:void 0});if(!a.file)throw new R("Upload completed but no file was returned");return a.file}async formworkUploadLoop(t,e,r){let s=t.uploadedBytes,n=We(e.size,r);for(n(s);s<e.size;){r.signal?.throwIfAborted();let i=e.slice(s,s+t.chunkSize),a=0;for(;;)try{let o=await this.fetch(this.url(`/uploads/${encodeURIComponent(t.id)}/chunk`),{method:"PUT",headers:{"Content-Type":"application/octet-stream","X-Upload-Offset":String(s),...t.token?{"X-Fillo-Upload-Token":t.token}:{}},body:i,signal:r.signal});if(o.status===409){s=(await o.json()).uploadedBytes;break}if(!o.ok)throw new R(`Chunk failed: ${o.status}`,o.status);s=(await o.json()).uploadedBytes;break}catch(o){if(r.signal?.aborted||(a+=1,a>=qe))throw o;await new Promise(d=>setTimeout(d,500*2**a)),s=(await this.getUploadSession(t.id,t.token)).uploadedBytes}n(s)}}async driveUploadLoop(t,e,r,s){let n=t.uploadedBytes,i=We(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 g=(d.headers.get("Range")??d.headers.get("range"))?.match(/bytes=0-(\d+)/);n=g?Number(g[1])+1:0;break}if(d.ok){n=r.size;break}throw new R(`Drive chunk failed: ${d.status}`,d.status)}catch(d){if(s.signal?.aborted||(l+=1,l>=qe))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=We(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 R(`S3 upload failed: ${i.status}`,i.status);s(e.size);return}catch(i){if(r.signal?.aborted||(n+=1,n>=qe))throw i;await new Promise(a=>setTimeout(a,500*2**n))}}};function Oe(t={}){return new Me(t)}var cs={id:"empty",blocks:[]};function wt(t){let{onChange:e,onSubmitted:r,onSubmit:s}=t,n=t.form,i=t.formId,a=t.client,o={...t.initialData??{}},l={},d=0,f="idle",g=new Set,T=new Set,I=Date.now(),U=null,Y=!1;function it(){let x=n.pages.length,C=Math.min(d,Math.max(x-1,0)),F=n.pages[C]??cs;return{data:o,errors:l,status:f,pageIndex:C,pageCount:x,page:F,blocks:Ye(F,o),isFirstPage:C===0,isLastPage:C===x-1,uploading:g.size>0}}let at=it();function $(){at=it();for(let x of T)x()}function Et(x){let C=n.pages[x];if(!C)return{};let F={};for(let ye of Ye(C,o)){if(!Ae(ye))continue;let ot=kt(ye,o[ye.id]);ot&&(F[ye.id]=ot)}return F}function Ft(x,C){!Y&&a&&i&&(Y=!0,a.startSession(i,n.pages.length).then(F=>U=F)),o={...o,[x]:C},e?.(o),x in l&&(l=Object.fromEntries(Object.entries(l).filter(([F])=>F!==x))),$()}function At(x,C){C?g.add(x):g.delete(x),$()}function Ot(){let x=n.pages.length,C=Math.min(d,Math.max(x-1,0)),F=Et(C);if(l=F,Object.keys(F).length>0){$();return}d=Math.min(C+1,x-1),U&&a&&a.reportProgress(U,{furthestPage:d}),$()}function Rt(){l={},d=Math.max(Math.min(d,n.pages.length-1)-1,0),$()}async function It(){if(f==="submitting"||f==="submitted")return;let x=ts(n,o);if(!x.ok){l=x.errors;let C=n.pages.findIndex(F=>F.blocks.some(ye=>ye.id in x.errors));C>=0&&(d=C),$();return}f="submitting",$();try{if(s)await s(x.data),f="submitted",$(),r?.(void 0,x.data);else if(a&&i){let C=await a.submit(i,x.data,{hp:t.getHoneypot?.()??"",elapsedMs:Date.now()-I});if(!C.ok){l=C.errors??{},f="idle",$();return}U&&a.reportProgress(U,{completed:!0}),f="submitted",$(),r?.(C.responseId,x.data)}else f="submitted",$(),r?.(void 0,x.data)}catch(C){throw f="idle",$(),C}}return{getState:()=>at,subscribe(x){return T.add(x),()=>{T.delete(x)}},setValue:Ft,setUploading:At,next:Ot,back:Rt,submit:It,setContext(x){"formId"in x&&(i=x.formId),"client"in x&&(a=x.client),x.form&&x.form!==n&&(n=x.form,$())},destroy(){T.clear()}}}function Qe(t){return{id:t.id,theme:t.theme,schema:{version:1,title:t.title??"",description:t.description,pages:t.pages,settings:t.settings??{}},__formworkCodeForm:!0}}function Ge(t){return typeof t=="object"&&t!==null&&"__formworkCodeForm"in t}var Je=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 Ct(t,e){let r=JSON.stringify(e.schema)+JSON.stringify(e.theme??null),s=`${t.baseUrl}:${t.key}:${e.id}:${us(r)}`,n=Je.get(s);return n||(n=t.syncForm(e.id,e.schema,e.theme??null),Je.set(s,n),n.catch(()=>Je.delete(s))),n}var fs=/\{\{\s*([\w-]+)\s*\}\}/g;function Ke(t,e,r){if(!t.includes("{{"))return t;let s=Qr(r);return t.replace(fs,(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 Tt(t,e,r){let s=n=>n===void 0?n:Ke(n,e,r);switch(t.kind){case"heading":case"paragraph":return{...t,text:Ke(t.text,e,r)};case"divider":return t;default:return{...t,label:Ke(t.label,e,r),description:s(t.description)}}}var E="fillo-";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[s,n]of Object.entries(e.attrs??{}))r.setAttribute(s,n);return r}function Pe(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 ps(t){return typeof t=="string"||typeof t=="number"?String(t):""}function P(t,e){for(let r of e)r&&t.appendChild(r);return t}function B(t,e,r){r&&t.setAttribute("aria-invalid","true"),e.required&&t.setAttribute("aria-required","true");let s=[e.description?`${E}${e.id}-desc`:null,r?`${E}${e.id}-error`:null].filter(Boolean).join(" ");s&&t.setAttribute("aria-describedby",s)}function D(t,e,r){let s=u("div",{className:`fillo-field fillo-field--${t.kind}${e?" fillo-field--error":""}`,attrs:{"data-field":t.id}}),n=u("label",{className:"fillo-label",text:t.label,attrs:{id:`${E}${t.id}-label`,for:`${E}${t.id}`}});return t.required||n.appendChild(u("span",{className:"fillo-optional",text:" (optional)"})),s.appendChild(n),t.description&&s.appendChild(u("p",{className:"fillo-description",text:t.description,attrs:{id:`${E}${t.id}-desc`}})),s.appendChild(r),e&&s.appendChild(u("p",{className:"fillo-error",text:e,attrs:{role:"alert",id:`${E}${t.id}-error`}})),s}function Ne(t,e){let r=u("input",{className:"fillo-input",attrs:{id:`${E}${e.field.id}`,type:t}});return r.value=ps(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)),B(r,e.field,e.error),D(e.field,e.error,r)}function hs(t){let e=u("textarea",{className:"fillo-input fillo-textarea",attrs:{id:`${E}${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)),B(e,t.field,t.error),D(t.field,t.error,e)}function ms(t){let e=t.field,r=st(e),s=typeof t.value=="string"?t.value:"",n=s!==""&&!e.options.some(a=>a.id===s),i=u("div",{className:"fillo-options",attrs:{role:"radiogroup","aria-labelledby":`${E}${e.id}-label`}});B(i,e,t.error);for(let a of r){let o=u("label",{className:`fillo-option${s===a.id?" fillo-option--selected":""}`,attrs:{"data-option":a.id}}),l=u("input",{className:"fillo-option-input",attrs:{type:"radio",name:`fillo-${e.id}`}});l.checked=s===a.id,l.addEventListener("change",()=>t.setValue(a.id)),P(o,[l,u("span",{className:"fillo-option-label",text:a.label})]),i.appendChild(o)}if(e.allowOther){let a=u("label",{className:`fillo-option${n?" fillo-option--selected":""}`}),o=u("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(u("span",{className:"fillo-option-label",text:"Other"})),n){let l=u("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 D(e,t.error,i)}function gs(t){let e=t.field,r=st(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=u("div",{className:"fillo-options",attrs:{role:"group","aria-labelledby":`${E}${e.id}-label`}});B(a,e,t.error);let o=l=>t.setValue(l);for(let l of r){let d=u("label",{className:`fillo-option${s.includes(l.id)?" fillo-option--selected":""}`,attrs:{"data-option":l.id}}),f=u("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))}),P(d,[f,u("span",{className:"fillo-option-label",text:l.label})]),a.appendChild(d)}if(e.allowOther){let l=i!==void 0,d=u("label",{className:`fillo-option${l?" fillo-option--selected":""}`}),f=u("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)}),P(d,[f,u("span",{className:"fillo-option-label",text:"Other"})]),l){let g=u("input",{className:"fillo-input fillo-other-input",attrs:{type:"text"}});g.value=i??"",g.placeholder="Your answer",g.addEventListener("input",()=>{let T=s.filter(I=>n.has(I));t.setValue(g.value?[...T,g.value]:T,{render:!1})}),g.addEventListener("change",()=>{let T=s.filter(I=>n.has(I));t.setValue(g.value?[...T,g.value]:T)}),d.appendChild(g)}a.appendChild(d)}return D(e,t.error,a)}var et="__fw_other__";function ys(t){let e=t.field,r=typeof t.value=="string"?t.value:"",s=r!==""&&!e.options.some(a=>a.id===r),n=u("div"),i=u("select",{className:"fillo-input fillo-select",attrs:{id:`${E}${e.id}`}});i.appendChild(u("option",{text:e.placeholder??"Choose...",attrs:{value:""}}));for(let a of st(e))i.appendChild(u("option",{text:a.label,attrs:{value:a.id}}));if(e.allowOther&&i.appendChild(u("option",{text:"Other...",attrs:{value:et}})),i.value=s?et:r,i.addEventListener("change",()=>{t.setValue(i.value===et?"":i.value||null)}),B(i,e,t.error),n.appendChild(i),s){let a=u("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 D(e,t.error,n)}function vs(t){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"}),s=u("input",{className:"fillo-option-input",attrs:{id:`${E}${t.field.id}`,type:"checkbox"}});s.checked=t.value===!0,s.addEventListener("change",()=>t.setValue(s.checked)),B(s,t.field,t.error);let n=u("span",{className:"fillo-option-label",text:t.field.label});return t.field.required||n.appendChild(u("span",{className:"fillo-optional",text:" (optional)"})),P(r,[s,n]),e.appendChild(r),t.field.description&&e.appendChild(u("p",{className:"fillo-description",text:t.field.description,attrs:{id:`${E}${t.field.id}-desc`}})),t.error&&e.appendChild(u("p",{className:"fillo-error",text:t.error,attrs:{role:"alert",id:`${E}${t.field.id}-error`}})),e}function bs(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,s=u("div",{className:"fillo-rating",attrs:{role:"radiogroup","aria-label":t.field.label}});B(s,t.field,t.error);for(let n=1;n<=e;n++){let i=u("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 D(t.field,t.error,s)}function _s(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,s=u("div"),n=u("div",{className:"fillo-scale",attrs:{role:"radiogroup","aria-label":t.field.label}});B(n,t.field,t.error);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)),n.appendChild(a)}return s.appendChild(n),("minLabel"in t.field||"maxLabel"in t.field)&&P(s,[P(u("div",{className:"fillo-scale-labels"}),[u("span",{text:String(t.field.minLabel??"")}),u("span",{text:String(t.field.maxLabel??"")})])]),D(t.field,t.error,s)}function xs(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=u("ol",{className:"fillo-ranking"});for(let[i,a]of s.entries()){let o=e.options.find(I=>I.id===a);if(!o)continue;let l=u("li",{className:"fillo-ranking-item"}),d=u("span",{className:"fillo-ranking-controls"}),f=I=>{let U=i+I;if(U<0||U>=s.length)return;let Y=[...s];[Y[i],Y[U]]=[Y[U],Y[i]],t.setValue(Y)},g=u("button",{className:"fillo-ranking-move",text:"Up",attrs:{type:"button"}});g.toggleAttribute("disabled",i===0),g.addEventListener("click",()=>f(-1));let T=u("button",{className:"fillo-ranking-move",text:"Down",attrs:{type:"button"}});T.toggleAttribute("disabled",i===s.length-1),T.addEventListener("click",()=>f(1)),P(d,[g,T]),P(l,[u("span",{className:"fillo-ranking-index",text:String(i+1)}),u("span",{className:"fillo-ranking-label",text:o.label}),d]),n.appendChild(l)}return D(t.field,t.error,n)}function ks(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=u("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(u("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(u("th",{text:o.label,attrs:{scope:"row"}}));for(let d of e.columns){let f=document.createElement("td"),g=u("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),D(t.field,t.error,P(u("div",{className:"fillo-matrix-wrap"}),[s]))}function ws(t){let e=u("div",{className:"fillo-signature"}),r=u("canvas",{className:"fillo-signature-canvas",attrs:{id:`${E}${t.field.id}`}});B(r,t.field,t.error);let s=u("button",{className:"fillo-signature-clear",text:"Clear",attrs:{type:"button"}}),n=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 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)}),P(e,[r,n,s]),D(t.field,t.error,e)}function Cs(t){let e=t.field;if(e.kind!=="file_upload")return null;let r=u("input",{className:"fillo-input",attrs:{id:`${E}${e.id}`,type:"file"}});(e.maxFiles??1)>1&&(r.multiple=!0),e.accept?.length&&(r.accept=e.accept.join(",")),B(r,e,t.error),r.addEventListener("change",()=>{let a=Array.from(r.files??[]);t.uploadFiles?.(e,a)});let s=u("div");s.appendChild(r);let n=t.uploadProgress?.get(e.id);if(n!==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(n*100)}%`),s.appendChild(a)}let i=Array.isArray(t.value)?t.value:[];for(let a of i)s.appendChild(u("p",{className:"fillo-description",text:`${a.name} (${Math.round(a.size/1024)} KB)`}));return D(e,t.error,s)}var Nt=new Map;function st(t){if(!t.shuffleOptions)return t.options;let e=`${t.id}|${t.options.map(i=>i.id).join(",")}`,r=Nt.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]]}Nt.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 Ts={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:hs,select:ms,multi_select:gs,dropdown:ys,checkbox:vs,rating:bs,linear_scale:_s,ranking:xs,matrix:ks,signature:ws,file_upload:Cs};function Ns(t){if(t.field.kind==="hidden"||t.field.kind==="custom")return null;let e=Ts[t.field.kind];return e?e(t):null}var tt=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");schema=null;theme;formId;closed=!1;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=Ge(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&&Ct(this.options.client,e).then(({formId:n})=>{this.formId=n,this.engine?.setContext({formId:n})}).catch(n=>this.handleError(Ve(n)));return}let r=this.options.form&&!Ge(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 R("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.setSchema(s.schema,this.options.theme??s.theme??void 0,s.id)}catch(e){this.handleError(Ve(e))}}setSchema(e,r,s){this.schema=e,this.theme=r,this.formId=s,this.engine=wt({form:e,formId:s,client:this.options.client,initialData:this.options.initialData,onChange:this.options.onChange,onSubmitted:this.options.onSubmitted,onSubmit:this.options.onSubmit,getHoneypot:()=>this.hpValue}),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(Ve(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(Ve(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"}});Pe(r,this.theme),P(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??""}`});Pe(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(),s=this.options.renderSuccess?.(r)??Es(this.schema);Pe(s,this.theme),this.element.appendChild(s);return}this.element.appendChild(this.renderForm())}}}renderForm(){let e=this.api(),r=u("form",{className:`fillo-form ${this.options.className??""}`});Pe(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=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 n=u("div",{className:"fillo-blocks"});for(let l of e.blocks){let d=this.renderBlock(Tt(l,this.mutableData,e.form),e);d&&n.appendChild(d)}r.appendChild(n);let i=u("input",{className:"fillo-hp",attrs:{type:"text",name:"fw_hp_field",tabindex:"-1",autocomplete:"off","aria-hidden":"true"}});i.addEventListener("input",()=>{this.hpValue=i.value}),r.appendChild(i);let a=u("footer",{className:"fillo-footer"});if(e.pageCount>1&&!e.isFirstPage){let l=u("button",{className:"fillo-button fillo-button--ghost",text:"Back",attrs:{type:"button"}});l.addEventListener("click",()=>this.back()),a.appendChild(l)}let o=u("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 Ss(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]??Ns)?.(n)??null}};function Ss(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 Es(t){let e=u("div",{className:"fillo-form fillo-form--success"}),r=u("div",{className:"fillo-success"});return P(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 Ve(t){return t instanceof R?t:new R(t instanceof Error?t.message:String(t),0)}function De(t,e){let r=typeof t=="string"?document.querySelector(t):t;if(!r)throw new R(`Fillo mount target not found: ${String(t)}`,0);return new tt(r,{...e,initialData:e.initialData??{}})}function St(t){let e=u("div");return De(e,t),e}var rt=class extends HTMLElement{instance=null;assignedForm;assignedClient;assignedTheme;assignedInitialData;static get observedAttributes(){return["base-url","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("base-url"),r=this.getAttribute("publishable-key")??void 0,s=this.getAttribute("form-id")??void 0,n=this.assignedClient??(s||r||e?Oe({baseUrl:e??void 0,key:r}):void 0);this.instance=De(this,{form:this.assignedForm,client:n,formId:s,theme:this.assignedTheme,initialData:this.assignedInitialData,onChange:i=>this.dispatchEvent(new CustomEvent("fillo-change",{detail:{data:i}})),onSubmitted:(i,a)=>this.dispatchEvent(new CustomEvent("fillo-submit",{detail:{responseId:i,data:a}})),onError:i=>this.dispatchEvent(new CustomEvent("fillo-error",{detail:{error:i}}))})}};function nt(t="fillo-form"){customElements.get(t)||customElements.define(t,rt)}nt();return Pt(Fs);})();
|
package/dist/styles.css
CHANGED
|
@@ -43,7 +43,9 @@
|
|
|
43
43
|
/* ---------- Field chrome ---------- */
|
|
44
44
|
.fillo-field { display: flex; flex-direction: column; gap: 0.45rem; }
|
|
45
45
|
.fillo-label { font-weight: 550; font-size: 0.95rem; }
|
|
46
|
-
|
|
46
|
+
/* Fillo marks the few optional fields rather than starring the many required
|
|
47
|
+
ones — so a clean label reads as required by default. */
|
|
48
|
+
.fillo-optional { color: var(--fillo-muted); font-weight: 400; font-size: 0.85em; }
|
|
47
49
|
.fillo-description { color: var(--fillo-muted); font-size: 0.85rem; margin: 0; line-height: 1.5; }
|
|
48
50
|
.fillo-error { color: var(--fillo-error); font-size: 0.85rem; margin: 0; }
|
|
49
51
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usefillo/dom",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Framework-agnostic DOM renderer and web component for embedding Fillo forms.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@usefillo/core": "^0.2.
|
|
41
|
+
"@usefillo/core": "^0.2.3"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"jsdom": "^25.0.1",
|