@usefillo/dom 0.24.1 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var Fillo=(()=>{var Vt=Object.defineProperty;var _o=Object.getOwnPropertyDescriptor;var xo=Object.getOwnPropertyNames;var ko=Object.prototype.hasOwnProperty;var $o=(e,t)=>{for(var n in t)Vt(e,n,{get:t[n],enumerable:!0})},So=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of xo(t))!ko.call(e,i)&&i!==n&&Vt(e,i,{get:()=>t[i],enumerable:!(r=_o(t,i))||r.enumerable});return e};var Ao=e=>So(Vt({},"__esModule",{value:!0}),e);var pl={};$o(pl,{FilloClient:()=>Mt,FilloError:()=>S,createClient:()=>Le,createFormElement:()=>fo,defineForm:()=>jn,registerFilloElement:()=>Yn,renderForm:()=>Zt});var or;function E(e,t,n){function r(s,l){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:l,constr:a,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,l);let c=a.prototype,u=Object.keys(c);for(let f=0;f<u.length;f++){let p=u[f];p in s||(s[p]=c[p].bind(s))}}let i=n?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function a(s){var l;let c=n?.Parent?new o:this;r(c,s),(l=c._zod).deferred??(l.deferred=[]);for(let u of c._zod.deferred)u();return c}return Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>n?.Parent&&s instanceof n.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var be=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(or=globalThis).__zod_globalConfig??(or.__zod_globalConfig={});var Ht=globalThis.__zod_globalConfig;function we(e){return e&&Object.assign(Ht,e),Ht}function ar(e){let t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function lr(e,t){return typeof t=="bigint"?t.toString():t}function cr(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw new Error("cached value already set")}}}function qt(e){return e==null}function ur(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var sr=Symbol("evaluating");function _e(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==sr)return r===void 0&&(r=sr,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}var Wt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function vt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Kt(e){if(vt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(vt(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Jt(e){return Kt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var dr=new Set(["string","number","symbol"]);function We(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Xt(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function G(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function pr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var zo={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ke(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function fr(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function xe(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function bt(e){return typeof e=="string"?e:e?.message}function ke(e,t,n){let r=e.message?e.message:bt(e.inst?._zod.def?.error?.(e))??bt(t?.error?.(e))??bt(n.customError?.(e))??bt(n.localeError?.(e))??"Invalid input",{inst:i,continue:o,input:a,...s}=e;return s.path??(s.path=[]),s.message=r,t?.reportInput&&(s.input=a),s}function Yt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}var hr=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,lr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},mr=E("$ZodError",hr),Je=E("$ZodError",hr,{Parent:Error});var Fo=e=>(t,n,r,i)=>{let o=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},o);if(a instanceof Promise)throw new be;if(a.issues.length){let s=new(i?.Err??e)(a.issues.map(l=>ke(l,o,we())));throw Wt(s,i?.callee),s}return a.value},yt=Fo(Je),Co=e=>async(t,n,r,i)=>{let o=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){let s=new(i?.Err??e)(a.issues.map(l=>ke(l,o,we())));throw Wt(s,i?.callee),s}return a.value},wt=Co(Je),Io=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new be;return o.issues.length?{success:!1,error:new(e??mr)(o.issues.map(a=>ke(a,i,we())))}:{success:!0,data:o.value}},Xe=Io(Je),No=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(a=>ke(a,i,we())))}:{success:!0,data:o.value}},Ye=No(Je);var gr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Lo="(?:(?:\\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])))",Mo=new RegExp(`^${Lo}$`);var br=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Qt=/^-?\d+(?:\.\d+)?$/;var Fe=E("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),To={number:"number",bigint:"bigint",object:"date"};var yr=E("$ZodCheckGreaterThan",(e,t)=>{Fe.init(e,t);let n=To[typeof t.value];e._zod.onattach.push(r=>{let i=r._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}});var wr=E("$ZodCheckMaxLength",(e,t)=>{var n;Fe.init(e,t),(n=e._zod.def).when??(n.when=r=>{let i=r.value;return!qt(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{let i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let i=r.value;if(i.length<=t.maximum)return;let a=Yt(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),_r=E("$ZodCheckMinLength",(e,t)=>{var n;Fe.init(e,t),(n=e._zod.def).when??(n.when=r=>{let i=r.value;return!qt(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{let i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let i=r.value;if(i.length>=t.minimum)return;let a=Yt(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}});var xr=E("$ZodCheckStringFormat",(e,t)=>{var n,r;Fe.init(e,t),e._zod.onattach.push(i=>{let o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})});var $r={major:4,minor:4,patch:3};var ie=E("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=$r;let r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(let i of r)for(let o of i._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,s,l)=>{let c=Ke(a),u;for(let f of s){if(f._zod.def.when){if(fr(a)||!f._zod.def.when(a))continue}else if(c)continue;let p=a.issues.length,m=f._zod.check(a);if(m instanceof Promise&&l?.async===!1)throw new be;if(u||m instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await m,a.issues.length!==p&&(c||(c=Ke(a,p)))});else{if(a.issues.length===p)continue;c||(c=Ke(a,p))}}return u?u.then(()=>a):a},o=(a,s,l)=>{if(Ke(a))return a.aborted=!0,a;let c=i(s,r,l);if(c instanceof Promise){if(l.async===!1)throw new be;return c.then(u=>e._zod.parse(u,l))}return e._zod.parse(c,l)};e._zod.run=(a,s)=>{if(s.skipChecks)return e._zod.parse(a,s);if(s.direction==="backward"){let c=e._zod.parse({value:a.value,issues:[]},{...s,skipChecks:!0});return c instanceof Promise?c.then(u=>o(u,a,s)):o(c,a,s)}let l=e._zod.parse(a,s);if(l instanceof Promise){if(s.async===!1)throw new be;return l.then(c=>i(c,r,s))}return i(l,r,s)}}_e(e,"~standard",()=>({validate:i=>{try{let o=Xe(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return Ye(e,i).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),en=E("$ZodString",(e,t)=>{ie.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??br(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),tn=E("$ZodStringFormat",(e,t)=>{xr.init(e,t),en.init(e,t)});var Er=E("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=gr),tn.init(e,t)});var Fr=E("$ZodNumber",(e,t)=>{ie.init(e,t),e._zod.pattern=e._zod.bag.pattern??Qt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;let o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}});var Cr=E("$ZodUnknown",(e,t)=>{ie.init(e,t),e._zod.parse=n=>n});function Sr(e,t,n){e.issues.length&&t.issues.push(...xe(n,e.issues)),t.value[n]=e.value}var Ir=E("$ZodArray",(e,t)=>{ie.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);let o=[];for(let a=0;a<i.length;a++){let s=i[a],l=t.element._zod.run({value:s,issues:[]},r);l instanceof Promise?o.push(l.then(c=>Sr(c,n,a))):Sr(l,n,a)}return o.length?Promise.all(o).then(()=>n):n}});function _t(e,t,n,r,i,o){let a=n in r;if(e.issues.length){if(i&&o&&!a)return;t.issues.push(...xe(n,e.issues))}if(!a&&!i){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?a&&(t.value[n]=void 0):t.value[n]=e.value}function Ro(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);let n=pr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Oo(e,t,n,r,i,o){let a=[],s=i.keySet,l=i.catchall._zod,c=l.def.type,u=l.optin==="optional",f=l.optout==="optional";for(let p in t){if(p==="__proto__"||s.has(p))continue;if(c==="never"){a.push(p);continue}let m=l.run({value:t[p],issues:[]},r);m instanceof Promise?e.push(m.then(h=>_t(h,n,p,t,u,f))):_t(m,n,p,t,u,f)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}var Nr=E("$ZodObject",(e,t)=>{if(ie.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let s=t.shape;Object.defineProperty(t,"shape",{get:()=>{let l={...s};return Object.defineProperty(t,"shape",{value:l}),l}})}let r=cr(()=>Ro(t));_e(e._zod,"propValues",()=>{let s=t.shape,l={};for(let c in s){let u=s[c]._zod;if(u.values){l[c]??(l[c]=new Set);for(let f of u.values)l[c].add(f)}}return l});let i=vt,o=t.catchall,a;e._zod.parse=(s,l)=>{a??(a=r.value);let c=s.value;if(!i(c))return s.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),s;s.value={};let u=[],f=a.shape;for(let p of a.keys){let m=f[p],h=m._zod.optin==="optional",v=m._zod.optout==="optional",b=m._zod.run({value:c[p],issues:[]},l);b instanceof Promise?u.push(b.then(g=>_t(g,s,p,c,h,v))):_t(b,s,p,c,h,v)}return o?Oo(u,c,s,l,r.value,e):u.length?Promise.all(u).then(()=>s):s}});var Lr=E("$ZodRecord",(e,t)=>{ie.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Kt(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;let o=[],a=t.keyType._zod.values;if(a){n.value={};let s=new Set;for(let c of a)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){s.add(typeof c=="number"?c.toString():c);let u=t.keyType._zod.run({value:c,issues:[]},r);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(u.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(m=>ke(m,r,we())),input:c,path:[c],inst:e});continue}let f=u.value,p=t.valueType._zod.run({value:i[c],issues:[]},r);p instanceof Promise?o.push(p.then(m=>{m.issues.length&&n.issues.push(...xe(c,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(...xe(c,p.issues)),n.value[f]=p.value)}let l;for(let c in i)s.has(c)||(l=l??[],l.push(c));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l})}else{n.value={};for(let s of Reflect.ownKeys(i)){if(s==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,s))continue;let l=t.keyType._zod.run({value:s,issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof s=="string"&&Qt.test(s)&&l.issues.length){let f=t.keyType._zod.run({value:Number(s),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(l=f)}if(l.issues.length){t.mode==="loose"?n.value[s]=i[s]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>ke(f,r,we())),input:s,path:[s],inst:e});continue}let u=t.valueType._zod.run({value:i[s],issues:[]},r);u instanceof Promise?o.push(u.then(f=>{f.issues.length&&n.issues.push(...xe(s,f.issues)),n.value[l.value]=f.value})):(u.issues.length&&n.issues.push(...xe(s,u.issues)),n.value[l.value]=u.value)}}return o.length?Promise.all(o).then(()=>n):n}});var Mr=E("$ZodEnum",(e,t)=>{ie.init(e,t);let n=ar(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(i=>dr.has(typeof i)).map(i=>typeof i=="string"?We(i):i.toString()).join("|")})$`),e._zod.parse=(i,o)=>{let a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:n,input:a,inst:e}),i}}),Tr=E("$ZodLiteral",(e,t)=>{if(ie.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?We(r):r?We(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,i)=>{let o=r.value;return n.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}});function Ar(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Pr=E("$ZodOptional",(e,t)=>{ie.init(e,t),e._zod.optin="optional",e._zod.optout="optional",_e(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),_e(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${ur(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){let i=n.value,o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(a=>Ar(a,i)):Ar(o,i)}return n.value===void 0?n:t.innerType._zod.run(n,r)}});var Rr=E("$ZodDefault",(e,t)=>{ie.init(e,t),e._zod.optin="optional",_e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>zr(o,t)):zr(i,t)}});function zr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function Or(e,t){return new e({type:"string",...G(t)})}function Zr(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...G(t)})}function Dr(e,t){return new e({type:"number",checks:[],...G(t)})}function Ur(e){return new e({type:"unknown"})}function nn(e,t){return new yr({check:"greater_than",...G(t),value:e,inclusive:!0})}function rn(e){return nn(0,e)}function K(e,t){return new wr({check:"max_length",...G(t),maximum:e})}function Ze(e,t){return new _r({check:"min_length",...G(t),minimum:e})}var ue=E("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");ie.init(e,t),e.def=t,e.type=t.type,e.parse=(n,r)=>yt(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>Xe(e,n,r),e.parseAsync=async(n,r)=>wt(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Ye(e,n,r),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]},{parent:!0}),e.with=e.check,e.clone=(n,r)=>Xt(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.apply=n=>n(e)}),jr=E("ZodMiniString",(e,t)=>{en.init(e,t),ue.init(e,t)});function J(e){return Or(jr,e)}var Do=E("ZodMiniStringFormat",(e,t)=>{tn.init(e,t),jr.init(e,t)}),Uo=E("ZodMiniEmail",(e,t)=>{Er.init(e,t),Do.init(e,t)});function xt(e){return Zr(Uo,e)}var Bo=E("ZodMiniNumber",(e,t)=>{Fr.init(e,t),ue.init(e,t)});function Vr(e){return Dr(Bo,e)}var jo=E("ZodMiniUnknown",(e,t)=>{Cr.init(e,t),ue.init(e,t)});function Qe(){return Ur(jo)}var Vo=E("ZodMiniArray",(e,t)=>{Ir.init(e,t),ue.init(e,t)});function $e(e,t){return new Vo({type:"array",element:e,...G(t)})}var Hr=E("ZodMiniObject",(e,t)=>{Nr.init(e,t),ue.init(e,t),_e(e,"shape",()=>t.shape)});function et(e,t){let n={type:"object",shape:e??{},...G(t)};return new Hr(n)}function on(e,t){return new Hr({type:"object",shape:e,catchall:Qe(),...G(t)})}var Br=E("ZodMiniRecord",(e,t)=>{Lr.init(e,t),ue.init(e,t)});function Gr(e,t,n){return!t||!t._zod?new Br({type:"record",keyType:J(),valueType:e,...G(t)}):new Br({type:"record",keyType:e,valueType:t,...G(n)})}var Ho=E("ZodMiniEnum",(e,t)=>{Mr.init(e,t),ue.init(e,t),e.options=Object.values(t.entries)});function qr(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Ho({type:"enum",entries:n,...G(t)})}var Go=E("ZodMiniLiteral",(e,t)=>{Tr.init(e,t),ue.init(e,t)});function Wr(e,t){return new Go({type:"literal",values:Array.isArray(e)?e:[e],...G(t)})}var qo=E("ZodMiniOptional",(e,t)=>{Pr.init(e,t),ue.init(e,t)});function Q(e){return new qo({type:"optional",innerType:e})}var Wo=E("ZodMiniDefault",(e,t)=>{Rr.init(e,t),ue.init(e,t)});function sn(e,t){return new Wo({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Jt(t)}})}var Xo=200,Yo=["heading","paragraph","divider"];function X(e){return!Yo.includes(e.kind)}function Nt(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:typeof e=="boolean"?e===!1:typeof e=="object"?Object.keys(e).length===0:!1}function Qo(e,t){if(!Array.isArray(t))return;let n=new Map(e.fields.map(o=>[o.id,o])),r=!1,i=t.map(o=>{if(!o||typeof o!="object"||Array.isArray(o))return o;let a=!1,s={};for(let[l,c]of Object.entries(o)){let u=n.get(l);if(!u){a=!0;continue}let f=mi(u,c);if(f===void 0){a=!0;continue}s[l]=f,f!==c&&(a=!0)}return a?(r=!0,s):o});return r?i:t}function hi(e,t){if(t==null||e.kind==="custom")return t;if(e.kind==="repeating_group")return Qo(e,t);if(e.kind==="number"&&typeof t=="string"&&t.trim()!==""){let n=Number(t);return Number.isNaN(n)?t:n}if((e.kind==="rating"||e.kind==="linear_scale")&&typeof t=="string"){let n=Number(t);return Number.isNaN(n)?t:n}return typeof t=="string"?t.trim():t}function mi(e,t){let n=hi(e,t);return Nt(n)?void 0:n}function gi(e){return e===void 0||!Number.isFinite(e)?0:Math.max(0,Math.min(6,Math.round(e)))}function bi(e,t){let n=10**t,r=Math.round(Math.abs(e)*n)/n;return e<0?-r:r}function Ce(e){return Number.isFinite(e)?e:null}function Be(e,t){switch(e.op){case"value":return _n(t(e.fieldId));case"const":return Ce(e.value);case"add":case"mul":case"min":case"max":{if(e.args.length===0)return null;let n=[];for(let r of e.args){let i=Be(r,t);if(i===null)return null;n.push(i)}return e.op==="add"?Ce(n.reduce((r,i)=>r+i,0)):e.op==="mul"?Ce(n.reduce((r,i)=>r*i,1)):e.op==="min"?Math.min(...n):Math.max(...n)}case"sub":case"div":{let n=Be(e.left,t);if(n===null)return null;let r=Be(e.right,t);return r===null?null:e.op==="sub"?Ce(n-r):r===0?null:Ce(n/r)}case"round":{let n=Be(e.arg,t);return n===null?null:Ce(bi(n,gi(e.decimals)))}case"if":return Be(Fn(e.when,t)?e.then:e.else,t)}}function es(e,t){let n=Be(e.calc,t);return n===null||e.decimals===void 0?n:Ce(bi(n,gi(e.decimals)))}function De(e,t){let n=ye(e);if(!n.some(s=>s.kind==="calculated"))return t;let r=t,i=kn(e,r);for(let s=0;s<=n.length;s++){let l={},c=!1;for(let[u,f]of Object.entries(r))i.has(u)?l[u]=f:c=!0;if(!c)break;r=l,i=kn(e,r)}let o=it(n,r),a={};for(let[s,l]of Object.entries(t))o.calcIds.has(s)||(a[s]=l);for(let[s,l]of Object.entries(o.calc))i.has(s)&&(a[s]=l);return a}function an(e){return e==null?!1:typeof e=="string"?e.trim()!=="":Array.isArray(e)?e.length>0:typeof e=="boolean"?e:typeof e=="object"?Object.keys(e).length>0:!0}function Kr(e,t){return e===t?!0:typeof e=="number"&&typeof t=="string"&&t.trim()!==""?Number(t)===e:typeof t=="number"&&typeof e=="string"&&e.trim()!==""?Number(e)===t:!1}function _n(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e!="string"||e.trim()==="")return null;let t=Number(e);return Number.isFinite(t)?t:null}function ts(e,t){let n=t(e.fieldId);switch(e.op){case"answered":return an(n);case"not_answered":return!an(n);case"eq":return Array.isArray(n)?n.some(r=>r===e.value):Kr(n,e.value);case"neq":return an(n)?Array.isArray(n)?!n.some(r=>r===e.value):!Kr(n,e.value):!1;case"contains":return typeof n=="string"?n.toLowerCase().includes(String(e.value??"").toLowerCase()):Array.isArray(n)?n.some(r=>r===e.value):!1;case"gt":case"lt":{let r=_n(n),i=_n(e.value);return r!==null&&i!==null&&(e.op==="gt"?r>i:r<i)}}}function Fn(e,t){return e.length===0?!0:e.every(n=>ts(n,t))}function vi(e,t){return!e.visibleIf||e.visibleIf.length===0?!0:Fn(e.visibleIf,t)}function ln(e,t,n,r,i,o){return a=>n.has(a)?r.has(a)?i.has(a)?o[a]:e[a]:void 0:t[a]}function it(e,t){let n=new Set(e.map(l=>l.id)),r=e.filter(l=>l.kind==="calculated"),i=new Set(r.map(l=>l.id)),o={};for(let l of e){if(l.kind==="calculated")continue;let c=mi(l,t[l.id]);c!==void 0&&(l.kind==="repeating_group"&&(Array.isArray(c)?c.length:0)<Math.max(1,l.minInstances??1)||(o[l.id]=c))}let a=n,s={};for(let l=0;l<=e.length;l++){let c=s;if(r.length>0){c={...s};let m=ln(o,t,n,a,i,c);for(let h of r){let v=a.has(h.id)?es(h,m):null;v===null?delete c[h.id]:c[h.id]=v}}let u=ln(o,t,n,a,i,c),f=new Set;for(let m of e)vi(m,u)&&f.add(m.id);let p=f.size===a.size&&[...f].every(m=>a.has(m))&&ns(s,c);if(a=f,s=c,p)break}return{visible:a,calc:s,calcIds:i,resolve:ln(o,t,n,a,i,s)}}function ns(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(r=>e[r]===t[r])}function yi(e,t){return it(e,t).visible}function kt(e,t,n){let r=it(ye(e),n);return t.blocks.filter(i=>X(i)?r.visible.has(i.id):vi(i,r.resolve))}function ye(e){return e.pages.flatMap(t=>t.blocks.filter(X))}function wi(e,t){let n=e.responseLimit?.scopeField;if(!n)return null;let r=t[n];return typeof r=="number"?Number.isFinite(r)?String(r):null:typeof r!="string"?null:r.trim()||null}function _i(e,t){let n=ye(e),r=yi(n,t);return n.filter(i=>r.has(i.id))}function Cn(e,t){let n=t&&typeof t=="object"&&!Array.isArray(t)?t:{},r=it(e.fields,n);return e.fields.filter(i=>r.visible.has(i.id))}function rs(e,t){return it(ye(e),t).resolve}function xi(e,t,n){let i=e.pages.find(a=>a.id===t)?.next;if(!i||i.length===0)return{linear:!0};let o=rs(e,n);for(let a of i)if(Fn(a.when,o))return a.to==="end"?{end:!0}:{to:a.to};return{linear:!0}}function je(e,t,n){let r=[];if(e.pages.length===0)return r;let i=new Set,o=n===void 0?0:e.pages.findIndex(a=>a.id===n);for(let a=0;a<=e.pages.length;a++){let s=e.pages[o];if(!s||i.has(s.id))break;i.add(s.id),r.push(s.id);let l=xi(e,s.id,t);if("end"in l)break;if("to"in l){let c=e.pages.findIndex(u=>u.id===l.to);if(c<0)break;o=c}else if(o+=1,o>=e.pages.length)break}return r}function is(e,t){return new Set(je(e,t))}function xn(e,t,n){if("end"in xi(e,t,n))return!0;let r=je(e,n);return r.length>0&&r[r.length-1]===t}function kn(e,t){let n=is(e,t),r=yi(ye(e),t),i=new Set;for(let o of e.pages)if(n.has(o.id))for(let a of o.blocks)X(a)&&r.has(a.id)&&i.add(a.id);return i}function ki(e,t){let n=kn(e,t);return ye(e).filter(r=>n.has(r.id))}var Ue;function os(){if(Ue!==void 0)return Ue??void 0;if(typeof Intl>"u"||typeof Intl.DisplayNames>"u"){Ue=null;return}try{Ue=new Intl.DisplayNames(void 0,{type:"region"})}catch{Ue=null}return Ue??void 0}function $i(e){try{return os()?.of(e)??e}catch{return e}}var w=(e,t,n=[],r=[],i="")=>({iso2:e,name:$i(e),dialCode:t,lengths:n,groups:r,example:i}),ss=[w("US","1",[10],[3,3,4],"2015550123"),w("CA","1",[10],[3,3,4],"5145550123"),w("GB","44",[10],[4,6],"7400123456"),w("AU","61",[9],[3,3,3],"412345678"),w("DE","49",[10,11],[4,7],"15123456789"),w("FR","33",[9],[1,2,2,2,2],"612345678"),w("IN","91",[10],[5,5],"8123456789"),w("DK","45",[8],[2,2,2,2],"32123456"),w("SE","46",[9],[2,3,4],"701234567"),w("NO","47",[8],[3,2,3],"40612345"),w("FI","358",[9,10],[2,3,4],"412345678"),w("NL","31",[9],[1,4,4],"612345678"),w("BE","32",[9],[3,2,2,2],"470123456"),w("ES","34",[9],[3,3,3],"612345678"),w("IT","39",[9,10],[3,3,4],"3123456789"),w("PT","351",[9],[3,3,3],"912345678"),w("IE","353",[9],[2,3,4],"851234567"),w("CH","41",[9],[2,3,2,2],"781234567"),w("AT","43",[10,11],[3,7],"6641234567"),w("PL","48",[9],[3,3,3],"512345678"),w("CZ","420",[9],[3,3,3],"601123456"),w("GR","30",[10],[3,3,4],"6912345678"),w("RO","40",[9],[3,3,3],"712345678"),w("HU","36",[9],[2,3,4],"201234567"),w("UA","380",[9],[2,3,2,2],"501234567"),w("RU","7",[10],[3,3,2,2],"9123456789"),w("TR","90",[10],[3,3,2,2],"5012345678"),w("IL","972",[9],[2,3,4],"501234567"),w("AE","971",[9],[2,3,4],"501234567"),w("SA","966",[9],[2,3,4],"512345678"),w("ZA","27",[9],[2,3,4],"711234567"),w("NG","234",[10],[3,3,4],"8021234567"),w("KE","254",[9],[3,3,3],"712123456"),w("EG","20",[10],[3,3,4],"1001234567"),w("BR","55",[10,11],[2,5,4],"11961234567"),w("MX","52",[10],[3,3,4],"2221234567"),w("AR","54",[10],[4,6],"1123456789"),w("CL","56",[9],[1,4,4],"221234567"),w("CO","57",[10],[3,3,4],"3211234567"),w("PE","51",[9],[3,3,3],"912345678"),w("CN","86",[11],[3,4,4],"13123456789"),w("JP","81",[10],[2,4,4],"9012345678"),w("KR","82",[9,10],[2,4,4],"1023456789"),w("SG","65",[8],[4,4],"81234567"),w("HK","852",[8],[4,4],"51234567"),w("TW","886",[9],[3,3,3],"912345678"),w("MY","60",[9,10],[2,3,4],"123456789"),w("ID","62",[10,11],[3,4,4],"81234567890"),w("TH","66",[9],[2,3,4],"812345678"),w("PH","63",[10],[3,3,4],"9171234567"),w("VN","84",[9],[3,3,3],"912345678"),w("PK","92",[10],[3,3,4],"3012345678"),w("BD","880",[10],[2,4,4],"1812345678"),w("NZ","64",[9,10],[2,3,4],"211234567"),w("SK","421",[9],[3,3,3],"912123456"),w("BG","359",[9],[2,3,4],"481234567"),w("HR","385",[8,9],[2,3,4],"921234567"),w("RS","381",[8,9],[2,3,4],"601234567"),w("SI","386",[8],[2,3,3],"31234567"),w("LT","370",[8],[3,2,3],"61234567"),w("LV","371",[8],[2,3,3],"21234567"),w("EE","372",[7,8],[3,4],"51234567"),w("IS","354",[7],[3,4],"6111234"),w("LU","352",[9],[3,3,3],"628123456"),w("MA","212",[9],[3,3,3],"650123456"),w("CR","506",[8],[4,4],"83123456"),w("EC","593",[9],[2,3,4],"991234567"),w("UY","598",[8],[1,3,4],"94231234"),w("QA","974",[8],[4,4],"33123456"),w("KW","965",[8],[4,4],"50012345")],as="AD376 AF93 AG1 AI1 AL355 AM374 AO244 AS1 AW297 AX358 AZ994 BA387 BB1 BF226 BH973 BI257 BJ229 BL590 BM1 BN673 BO591 BQ599 BS1 BT975 BV47 BW267 BY375 BZ501 CC61 CD243 CF236 CG242 CI225 CK682 CM237 CU53 CV238 CW599 CX61 CY357 DJ253 DM1 DO1 DZ213 EH212 ER291 ET251 FJ679 FK500 FM691 FO298 GA241 GD1 GE995 GF594 GG44 GH233 GI350 GL299 GM220 GN224 GP590 GQ240 GS500 GT502 GU1 GW245 GY592 HN504 HT509 IM44 IO246 IQ964 IR98 JE44 JM1 JO962 KG996 KH855 KI686 KM269 KN1 KP850 KY1 KZ7 LA856 LB961 LC1 LI423 LK94 LR231 LS266 LY218 MC377 MD373 ME382 MF590 MG261 MH692 MK389 ML223 MM95 MN976 MO853 MP1 MQ596 MR222 MS1 MT356 MU230 MV960 MW265 MZ258 NA264 NC687 NE227 NF672 NI505 NP977 NR674 NU683 OM968 PA507 PF689 PG675 PM508 PN64 PR1 PS970 PW680 PY595 RE262 RW250 SB677 SC248 SD249 SH290 SJ47 SL232 SM378 SN221 SO252 SR597 SS211 ST239 SV503 SX1 SY963 SZ268 TC1 TD235 TF262 TG228 TJ992 TK690 TL670 TM993 TN216 TO676 TT1 TV688 TZ255 UG256 UZ998 VA379 VC1 VE58 VG1 VI1 VU678 WF681 WS685 XK383 YE967 YT262 ZM260 ZW263";function ls(e){let t=[];for(let n of e.trim().split(/\s+/)){let r=n.slice(0,2),i=n.slice(2);t.push({iso2:r,name:$i(r),dialCode:i,lengths:[],groups:[],example:""})}return t}var ot=[...ss,...ls(as)],Ve=cs(ot);function cs(e){if(typeof Intl>"u"||typeof Intl.Collator>"u")return[...e].sort((n,r)=>n.iso2<r.iso2?-1:n.iso2>r.iso2?1:0);let t=new Intl.Collator(void 0,{sensitivity:"base"});return[...e].sort((n,r)=>t.compare(n.name,r.name))}var us=new Map(ot.map(e=>[e.iso2,e])),ds={"Africa/Cairo":"EG","Africa/Casablanca":"MA","Africa/Johannesburg":"ZA","Africa/Lagos":"NG","Africa/Nairobi":"KE","America/Adak":"US","America/Anchorage":"US","America/Argentina/Buenos_Aires":"AR","America/Argentina/Cordoba":"AR","America/Argentina/Mendoza":"AR","America/Bahia":"BR","America/Belem":"BR","America/Bogota":"CO","America/Boise":"US","America/Boa_Vista":"BR","America/Cancun":"MX","America/Chicago":"US","America/Chihuahua":"MX","America/Campo_Grande":"BR","America/Costa_Rica":"CR","America/Cuiaba":"BR","America/Denver":"US","America/Detroit":"US","America/Edmonton":"CA","America/Fortaleza":"BR","America/Guayaquil":"EC","America/Halifax":"CA","America/Hermosillo":"MX","America/Indiana/Indianapolis":"US","America/Indianapolis":"US","America/Juneau":"US","America/Kentucky/Louisville":"US","America/Lima":"PE","America/Los_Angeles":"US","America/Maceio":"BR","America/Manaus":"BR","America/Matamoros":"MX","America/Mazatlan":"MX","America/Merida":"MX","America/Mexico_City":"MX","America/Moncton":"CA","America/Monterrey":"MX","America/Montevideo":"UY","America/New_York":"US","America/Noronha":"BR","America/Nome":"US","America/North_Dakota/Center":"US","America/Ojinaga":"MX","America/Phoenix":"US","America/Porto_Velho":"BR","America/Punta_Arenas":"CL","America/Recife":"BR","America/Regina":"CA","America/Rio_Branco":"BR","America/Santiago":"CL","America/Sao_Paulo":"BR","America/Sitka":"US","America/St_Johns":"CA","America/Tijuana":"MX","America/Toronto":"CA","America/Vancouver":"CA","America/Whitehorse":"CA","America/Winnipeg":"CA","America/Yakutat":"US","Asia/Bangkok":"TH","Asia/Calcutta":"IN","Asia/Dacca":"BD","Asia/Dhaka":"BD","Asia/Dubai":"AE","Asia/Hong_Kong":"HK","Asia/Ho_Chi_Minh":"VN","Asia/Jakarta":"ID","Asia/Jerusalem":"IL","Asia/Karachi":"PK","Asia/Kolkata":"IN","Asia/Kuala_Lumpur":"MY","Asia/Kuwait":"KW","Asia/Manila":"PH","Asia/Qatar":"QA","Asia/Riyadh":"SA","Asia/Seoul":"KR","Asia/Shanghai":"CN","Asia/Saigon":"VN","Asia/Singapore":"SG","Asia/Taipei":"TW","Asia/Tel_Aviv":"IL","Asia/Tokyo":"JP","Asia/Urumqi":"CN","Atlantic/Reykjavik":"IS","Australia/Adelaide":"AU","Australia/Brisbane":"AU","Australia/Darwin":"AU","Australia/Hobart":"AU","Australia/Melbourne":"AU","Australia/Perth":"AU","Australia/Sydney":"AU","Europe/Amsterdam":"NL","Europe/Athens":"GR","Europe/Belgrade":"RS","Europe/Berlin":"DE","Europe/Bratislava":"SK","Europe/Brussels":"BE","Europe/Bucharest":"RO","Europe/Budapest":"HU","Europe/Copenhagen":"DK","Europe/Dublin":"IE","Europe/Helsinki":"FI","Europe/Zagreb":"HR","Europe/Istanbul":"TR","Europe/Kiev":"UA","Europe/Kyiv":"UA","Europe/Lisbon":"PT","Europe/Ljubljana":"SI","Europe/London":"GB","Europe/Luxembourg":"LU","Europe/Madrid":"ES","Europe/Moscow":"RU","Europe/Oslo":"NO","Europe/Paris":"FR","Europe/Prague":"CZ","Europe/Riga":"LV","Europe/Rome":"IT","Europe/Sofia":"BG","Europe/Stockholm":"SE","Europe/Tallinn":"EE","Europe/Vienna":"AT","Europe/Vilnius":"LT","Europe/Warsaw":"PL","Europe/Zurich":"CH","Pacific/Auckland":"NZ"};function In(e){let t=e.toUpperCase();return/^[A-Z]{2}$/.test(t)?String.fromCodePoint(...[...t].map(n=>127462+n.charCodeAt(0)-65)):"\u{1F3F3}\uFE0F"}function Lt(e){return e?us.get(e.toUpperCase()):void 0}function Si(e){return Lt(e?ds[e]:void 0)}function ps(e){let t;for(let n of ot)e.startsWith(n.dialCode)&&(!t||n.dialCode.length>t.dialCode.length)&&(t=n);return t}function fe(e){return e.replace(/[^\d]/g,"")}function st(e,t){let n=fe(t);if(!n)return"";let r=e?.groups?.length?e.groups:[],i=[],o=0;for(let a of r){if(o>=n.length)break;i.push(n.slice(o,o+a)),o+=a}for(;o<n.length;)i.push(n.slice(o,o+3)),o+=3;return i.join(" ")}function Ai(e,t){let n=fe(t);return n?`+${e.dialCode}${n}`:""}function at(e,t,n){let r=(e??"").trim(),i=r.startsWith("+"),o=fe(r);if(i){if(!o)return{national:"",e164:"",pending:!0,raw:r};let a=n?.previousDigits?fe(n.previousDigits):"";if(a&&o===a)return{national:o,e164:`+${o}`,pending:!0,raw:r};let s=ps(o);if(s){let l=o.slice(s.dialCode.length);return{country:s,national:l,e164:`+${o}`}}return{national:o,e164:`+${o}`,pending:!0,raw:r}}if(!o)return{country:t,national:"",e164:""};if(t){let a=o.startsWith(t.dialCode)?o.slice(t.dialCode.length):o;return{country:t,national:a,e164:`+${t.dialCode}${a}`}}return{national:o,e164:`+${o}`}}function fs(e){let{country:t,national:n,e164:r}=at(e);if(!r)return!1;let i=fe(r).length;return i<8||i>15?!1:t?.lengths.length?t.lengths.includes(n.length):n.length>=4}var hs=8;function zi(e,t){if(!e||!t||typeof window>"u")return"below";let n=hs,r=document.documentElement.clientWidth||window.innerWidth,i=document.documentElement.clientHeight||window.innerHeight,o=e.getBoundingClientRect(),a=Math.max(0,i-o.bottom-n),s=Math.max(0,o.top-n),l=a<t.scrollHeight&&s>a?"above":"below",u=Math.max(0,Math.min(l==="above"?s:a,i-n*2)),f=Math.max(0,r-n*2);t.style.setProperty("--fillo-phone-popover-max-height",`${Math.floor(u)}px`),t.style.setProperty("--fillo-phone-popover-max-width",`${Math.floor(f)}px`),t.style.setProperty("--fillo-phone-popover-offset-x","0px");let p=Math.min(t.offsetWidth,f),h=getComputedStyle(e).direction==="rtl"?o.right-p:o.left,v=0,b=h+p-(r-n);b>0&&(v-=b);let g=n-(h+v);return g>0&&(v+=g),t.style.setProperty("--fillo-phone-popover-offset-x",`${Math.round(v)}px`),l}var lt="This field is required",L={back:"Back",next:"Next",submit:"Submit",submitting:"Submitting\u2026",uploading:"Uploading\u2026",optional:" (optional)",other:"Other",otherPrompt:"Other \u2014 please specify",otherPlaceholder:"Your answer",choosePlaceholder:"Choose\u2026",successTitle:"Thanks!",successMessage:"Your response has been recorded.",closed:"This form is no longer accepting responses.",notLive:"This form isn't live yet.",notOpenTitle:"This form isn't open yet",notOpenBody:"The form owner is still setting things up. Please check back soon.",closedTitle:"Responses are closed",submitFailed:"This form can't submit right now. Please try again in a moment.",loadFailedNotFound:"Form not found. Check the link or ask the form owner for help.",loadFailedNetwork:"Couldn't reach the server \u2014 check your connection and try again.",loadFailed:"This form could not be loaded.",renderFailed:"This form could not be rendered.",resumeNotice:"Picked up where you left off.",editNotice:"You're updating your earlier response.",resumeStartOver:"Start over",challengeUnavailable:"The verification check couldn't load. Refresh the page and try again."},Jr={submitFailed:L.submitFailed,loadFailedNotFound:L.loadFailedNotFound,loadFailedNetwork:L.loadFailedNetwork,formUnavailable:"This form is unavailable.",formClosed:L.closed,submitRateLimited:"Too many responses are being submitted right now. Wait a moment, then try again.",respondentUnrecognized:"This form couldn't verify who is responding. Ask the form owner for help.",fileUnavailable:"One of the uploaded files is no longer available. Remove it and upload it again.",scopeMissing:"We couldn't tell which entry this response belongs to. Answer the required field and try again.",challengeIncomplete:"Please complete the verification check, then submit.",challengeRetry:"That verification didn't go through. Please complete the check again and resubmit.",reviewAnswers:"We couldn't submit \u2014 please review your answers."};var ms={short_text:"Enter your answer",long_text:"Enter your answer",email:"Enter an email address",url:"Enter a URL",phone:"Enter a phone number",number:"Enter a number",select:"Choose an option",dropdown:"Choose an option",multi_select:"Select at least one option",checkbox:"Select this checkbox",rating:"Choose a rating",linear_scale:"Choose a value",ranking:"Rank every option",matrix:"Answer every row",signature:"Add your signature",date:"Enter a date",file_upload:"Add a file"};function gs(e){return ms[e.kind]??lt}var T={previewSkip:"Skip",required:lt,requiredForField:gs,resumeLinkExpired:"That saved-progress link expired or was already used \u2014 start again below.",alreadyAnswered:"You've already answered this form.",uploadRetry:"Retry",uploadCancel:"Cancel",uploadRemove:"Remove",uploadDismiss:"Dismiss",uploadingFile:(e,t)=>`Uploading \xB7 ${e}% \xB7 ${t}`,uploadedFile:e=>`Uploaded \xB7 ${e}`,uploadsDisabled:"Connect this form to Fillo to enable uploads",uploadsRenderOnly:"Uploads are unavailable in this render-only preview",uploadsUnavailable:"Uploads are temporarily unavailable",uploadUnavailable:"We couldn't upload this file right now. Try again in a moment.",uploadFailed:"Upload failed \u2014 try again",dropzoneTitle:e=>`Drop ${e?"files":"a file"} here or click to browse`,dropzoneHint:e=>`Up to ${e} MB per file`,fileTooLarge:e=>`Larger than ${e} MB limit`,filesUploading:e=>`Uploading ${e} ${e===1?"file":"files"}, please wait\u2026`,uploadsFailed:e=>`${e} ${e===1?"upload":"uploads"} failed.`,filesUploaded:e=>`${e} ${e===1?"file":"files"} uploaded.`,submittingAnnouncement:"Submitting your response\u2026",errorSummaryTitle:"Check these fields",rankingPosition:(e,t,n)=>`${e}, position ${t} of ${n}`,groupAdd:"Add another",groupInstanceLabel:(e,t,n)=>`${e} ${t} of ${n}`,groupRemoveLabel:(e,t)=>`Remove ${e} ${t}`,groupInstanceAdded:(e,t,n)=>`${e} ${t} added, ${t} of ${n}`,groupInstanceRemoved:(e,t)=>t===0?`${e} removed, none left`:`${e} removed, ${t} remaining`,phoneCountrySelected:e=>`${e} selected`,phoneResultsCount:e=>`${e} ${e===1?"result":"results"}`,signatureEmpty:"No signature yet",signatureSigned:"Signature saved"};function Ei(e,t){return t.requiredForField?.(e)??t.required}var bs=et({fileId:J().check(Ze(1)),name:J(),size:Vr().check(rn()),mime:J(),url:Q(J())});function cn(e,t){let n=Math.max(0,e.minInstances??1);return t<n?`Add at least ${n} ${n===1?"entry":"entries"}`:Number.isFinite(e.maxInstances)&&t>e.maxInstances?`At most ${e.maxInstances} ${e.maxInstances===1?"entry":"entries"}`:null}function It(e,t){if(Nt(t))return e.kind==="calculated"?null:e.kind==="repeating_group"?cn(e,0):e.required?lt:null;switch(e.kind){case"short_text":case"long_text":{if(typeof t!="string")return"Expected text";if(e.maxLength&&t.length>e.maxLength)return`Must be at most ${e.maxLength} characters`;let n=e.kind==="long_text"?2e4:2e3;return!e.maxLength&&t.length>n?"Answer is too long":null}case"email":return typeof t!="string"?"Enter a valid email address":e.maxLength&&t.length>e.maxLength?`Must be at most ${e.maxLength} characters`:xt().safeParse(t).success?null:"Enter a valid email address";case"url":{if(typeof t!="string")return"Enter a valid URL (including https://)";if(e.maxLength&&t.length>e.maxLength)return`Must be at most ${e.maxLength} characters`;try{let n=new URL(t);if(n.protocol!=="http:"&&n.protocol!=="https:")return"Enter an http(s) URL"}catch{return"Enter a valid URL (including https://)"}return null}case"phone":return typeof t!="string"||!fs(t)?"Enter a valid phone number":null;case"number":{let n=typeof t=="string"?Number(t):t;return typeof n!="number"||!Number.isFinite(n)?"Enter a number":e.min!==void 0&&n<e.min?`Must be at least ${e.min}`:e.max!==void 0&&n>e.max?`Must be at most ${e.max}`:null}case"select":case"dropdown":return typeof t!="string"||t===""?"Pick an option":e.options.some(n=>n.id===t)||e.allowOther&&t.length<=500?null:"Pick a valid option";case"multi_select":{if(!Array.isArray(t))return"Pick at least one option";let n=new Set(e.options.map(a=>a.id)),r=t,i=0,o=new Set;for(let a of r){if(typeof a!="string")return"Pick valid options";if(o.has(a))return"Pick each option only once";if(o.add(a),!n.has(a)){if(e.allowOther!==!0||a.length===0||a.length>500)return"Pick valid options";if(++i>1)return"Only one 'Other' answer is allowed"}}return null}case"checkbox":return typeof t=="boolean"?null:"Invalid value";case"rating":{let n=e.max??5,r=typeof t=="string"?Number(t):t;return typeof r!="number"||!Number.isInteger(r)||r<1||r>n?`Pick a rating between 1 and ${n}`:null}case"linear_scale":{let n=e.min??1,r=e.max??10,i=typeof t=="string"?Number(t):t;return typeof i!="number"||!Number.isInteger(i)||i<n||i>r?`Pick a value between ${n} and ${r}`:null}case"ranking":{if(!Array.isArray(t))return"Drag the options into order";let n=e.options.map(i=>i.id).sort(),r=[...t].sort();return n.length!==r.length||n.some((i,o)=>i!==r[o])?"Rank every option":null}case"matrix":{if(typeof t!="object"||t===null||Array.isArray(t))return"Answer the grid";let n=t,r=new Set(e.columns.map(o=>o.id)),i=new Set(e.rows.map(o=>o.id));for(let[o,a]of Object.entries(n))if(!i.has(o)||!r.has(a))return"Invalid grid answer";return e.required&&Object.keys(n).length<e.rows.length?"Answer every row":null}case"signature":return typeof t!="string"||!t.startsWith("data:image/")?"Sign in the box":null;case"hidden":return typeof t=="string"?null:"Invalid value";case"calculated":return null;case"repeating_group":{if(!Array.isArray(t))return cn(e,0);let n=t;for(let r of n)if(!r||typeof r!="object"||Array.isArray(r))return"Invalid value";return cn(e,n.length)}case"custom":return null;case"date":{if(typeof t!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(t))return"Enter a valid date";let[n,r,i]=t.split("-").map(Number),o=new Date(Date.UTC(n,r-1,i));return o.getUTCFullYear()!==n||o.getUTCMonth()!==r-1||o.getUTCDate()!==i?"Enter a valid date":null}case"file_upload":{let n=$e(bs).safeParse(t);if(!n.success)return"Upload did not complete";let r=e.maxFiles??1;return n.data.length>r?`At most ${r} file${r===1?"":"s"}`:null}}}function Fi(e,t){let n=ki(e,t),r={},i={};for(let o of n){if(o.kind==="calculated")continue;let a=hi(o,t[o.id]);if(o.kind==="repeating_group"){vs(o,a,r,i);continue}let s=It(o,a);s?r[o.id]=s:Nt(a)||(i[o.id]=a)}return{ok:Object.keys(r).length===0,errors:r,data:i}}function vs(e,t,n,r){let i=It(e,t);if(i&&(n[e.id]=i),!Array.isArray(t))return;let o=t,a=[];for(let s=0;s<o.length;s++){let l=o[s];if(!l||typeof l!="object"||Array.isArray(l))continue;let c={};for(let u of Cn(e,l)){let f=l[u.id],p=It(u,f);p?n[`${e.id}.${s}.${u.id}`]=p:Nt(f)||(c[u.id]=f)}a.push(c)}!i&&a.length>0&&(r[e.id]=a)}var ys=["short_text","long_text","email","url","phone","number","select","multi_select","dropdown","checkbox","rating","linear_scale","ranking","matrix","signature","date","file_upload","hidden","calculated","repeating_group","custom"],ws=["heading","paragraph","divider"],_s=[...ys,...ws],Nn=J().check(Ze(1),K(128)),un=on({id:Nn,label:J().check(K(1e3)),icon:Q(Qe())}),xs=on({id:Nn,kind:qr(_s),label:Q(J().check(K(2e3))),options:Q($e(un).check(K(200))),rows:Q($e(un).check(K(200))),columns:Q($e(un).check(K(200)))}),ks=et({id:Nn,title:Q(J().check(K(500))),blocks:$e(xs).check(K(500)),next:Q(Qe())}),$s=et({version:Wr(1),title:sn(Q(J().check(K(2e3))),""),description:Q(J().check(K(5e3))),pages:$e(ks).check(Ze(1),K(50)),settings:sn(Q(Gr(J(),Qe())),{})}),Ss=1,$n=1,Sn="0.24.1";function oe(e,t,n=""){return typeof e=="string"?e.trim().slice(0,t):n}function B(e,t){let n=oe(e,t);return n===""?void 0:n}function $t(e,t){if(typeof e!="string")return;let n=e.slice(0,t);return n.trim()===""?void 0:n}function ve(e){return typeof e=="boolean"?e:void 0}function se(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function pe(e,t,n,r){let i=se(e);return i===void 0?r:Math.max(t,Math.min(n,Math.round(i)))}function St(e,t=200){return Array.isArray(e)?e.slice(0,t).flatMap(n=>{if(!n||typeof n!="object")return[];let r=n,i=oe(r.id,128),o=oe(r.label,1e3),a=r.icon==="thumbs_up"||r.icon==="thumbs_down"?r.icon:void 0;return i&&o?[O({id:i,label:o,icon:a})]:[]}):[]}function Ct(e){let t=new Set;for(let{id:n}of e){if(t.has(n))return n;t.add(n)}}function Ln(e){if(!Array.isArray(e))return;let t=e.slice(0,20).flatMap(n=>{if(!n||typeof n!="object")return[];let r=n,i=r.op;if(i!=="eq"&&i!=="neq"&&i!=="contains"&&i!=="gt"&&i!=="lt"&&i!=="answered"&&i!=="not_answered")return[];let o=oe(r.fieldId,128);if(!o)return[];let a=r.value,s=typeof a=="string"||typeof a=="number"||typeof a=="boolean"?a:void 0;return[{fieldId:o,op:i,...s!==void 0?{value:s}:{}}]});return t.length?t:void 0}function Ci(e,t,n,r){let i=t.get(e);if(i===void 0)return n.has(e);if(r.has(e))return!0;r.add(e);for(let o of i)if(!Ci(o,t,n,r))return!1;return!0}function As(e,t,n,r,i){if(!Array.isArray(e))return;let o=e.slice(0,50).flatMap(a=>{if(!a||typeof a!="object")return[];let s=a,l=typeof s.to=="string"?s.to:void 0;if(!l||l!=="end"&&!t.has(l))return[];if(l===n)return[];let c=s.when;if(c!==void 0&&!Array.isArray(c))return[];let u=Ln(c);return Array.isArray(c)&&c.length>0&&u===void 0?[]:u&&u.some(f=>!Ci(f.fieldId,i,r,new Set))?[]:[{when:u??[],to:l}]});return o.length?o:void 0}var zs=["number","rating","linear_scale","calculated"];function Ae(e,t=0){if(t>32||!e||typeof e!="object"||Array.isArray(e))return null;let n=e;switch(n.op){case"value":{let r=oe(n.fieldId,128);return r?{op:"value",fieldId:r}:null}case"const":{let r=se(n.value);return r===void 0?null:{op:"const",value:r}}case"add":case"mul":case"min":case"max":{if(!Array.isArray(n.args)||n.args.length<1||n.args.length>50)return null;let r=[];for(let i of n.args){let o=Ae(i,t+1);if(!o)return null;r.push(o)}return{op:n.op,args:r}}case"sub":case"div":{let r=Ae(n.left,t+1),i=Ae(n.right,t+1);return r&&i?{op:n.op,left:r,right:i}:null}case"round":{let r=Ae(n.arg,t+1);return r?O({op:"round",arg:r,decimals:se(n.decimals)===void 0?void 0:pe(n.decimals,0,6,0)}):null}case"if":{if(!Array.isArray(n.when))return null;let r=Ln(n.when)??[];if(r.length!==n.when.length)return null;let i=Ae(n.then,t+1),o=Ae(n.else,t+1);return i&&o?{op:"if",when:r,then:i,else:o}:null}default:return null}}function ze(e,t,n){switch(e.op){case"value":t.add(e.fieldId);return;case"const":return;case"add":case"mul":case"min":case"max":for(let r of e.args)ze(r,t,n);return;case"sub":case"div":ze(e.left,t,n),ze(e.right,t,n);return;case"round":ze(e.arg,t,n);return;case"if":for(let r of e.when)n.add(r.fieldId);ze(e.then,t,n),ze(e.else,t,n);return}}function Es(e,t){let n=new Map;for(let a of e)for(let s of a.blocks)X(s)&&n.set(s.id,s.kind);let r=new Map;for(let a of e)for(let s of a.blocks){if(s.kind!=="calculated")continue;let l=Ae(s.calc);if(!l)return`Field ${s.id} has a malformed calc expression \u2014 build it from value/const/add/sub/mul/div/min/max/round/if nodes`;s.calc=l;let c=new Set,u=new Set;ze(l,c,u);for(let f of c){let p=n.get(f);if(p===void 0){let m=t.get(f);return m!==void 0?`Calculated field ${s.id} references ${f}, which is a child of repeating group ${m} \u2014 calculations can't reach inside a repeating group (calc operands must be top-level fields)`:`Calculated field ${s.id} references a missing field: ${f} \u2014 remove the reference or restore that field`}if(!zs.includes(p))return`Calculated field ${s.id} references non-numeric field ${f} (${p}) \u2014 calculations can read number, rating, linear_scale, and calculated fields only`}r.set(s.id,[...c,...u].filter(f=>n.get(f)==="calculated"))}let i=new Map,o=(a,s)=>{let l=i.get(a);if(l==="done")return null;if(l==="visiting"){let c=[...s.slice(s.indexOf(a)),a].join(" \u2192 ");return`Calculated field ${a} depends on its own result (${c}) \u2014 break the cycle so the value can be computed`}i.set(a,"visiting");for(let c of r.get(a)??[]){let u=o(c,[...s,a]);if(u)return u}return i.set(a,"done"),null};for(let a of r.keys()){let s=o(a,[]);if(s)return s}return null}var Xr=100,Yr=5e3;function Ie(e){switch(e.op){case"value":case"const":return 1;case"add":case"mul":case"min":case"max":return 1+e.args.reduce((t,n)=>t+Ie(n),0);case"sub":case"div":return 1+Ie(e.left)+Ie(e.right);case"round":return 1+Ie(e.arg);case"if":return 1+Ie(e.then)+Ie(e.else)}}function Fs(e){let t=0,n=0;for(let r of e)for(let i of r.blocks)i.kind==="calculated"&&(t+=1,n+=Ie(i.calc));return t>Xr?`Form has ${t} calculated fields \u2014 the maximum is ${Xr}; remove some or consolidate them into fewer expressions`:n>Yr?`Calculated expressions total ${n} operations \u2014 the maximum is ${Yr} across the form; simplify or split up the calculations`:null}var Qr=["short_text","long_text","email","url","phone","number","select","multi_select","dropdown","checkbox","date","rating","linear_scale"],ei=12,ti=18e4;function Cs(e){let t=e.id.length+20;switch(e.kind){case"short_text":case"email":case"url":return t+(e.maxLength??2e3);case"long_text":return t+(e.maxLength??2e4);case"phone":return t+32;case"number":return t+32;case"select":case"dropdown":{let n=e.options.reduce((r,i)=>Math.max(r,i.id.length),0);return t+Math.max(n,e.allowOther?500:0)}case"multi_select":{let n=e.options.reduce((r,i)=>r+i.id.length+3,0);return t+n+(e.allowOther?500:0)}case"checkbox":return t+8;case"date":return t+16;case"rating":case"linear_scale":return t+8;default:return t+64}}function Is(e){return e.fields.reduce((n,r)=>n+Cs(r),24)*(Number.isFinite(e.maxInstances)?e.maxInstances:0)}function Ns(e){for(let t of e)for(let n of t.blocks){if(n.kind!=="repeating_group")continue;if(!Number.isInteger(n.maxInstances)||n.maxInstances<1||n.maxInstances>20)return`Repeating group ${n.id} needs maxInstances to be a whole number between 1 and 20`;let r=n.minInstances??1;if(!Number.isInteger(r)||r<0||r>n.maxInstances)return`Repeating group ${n.id} needs minInstances to be a whole number between 0 and maxInstances (${n.maxInstances})`;if(n.minInstances=r,n.fields.length===0)return`Repeating group ${n.id} has no template fields \u2014 add at least one field to repeat`;if(n.fields.length>ei)return`Repeating group ${n.id} has ${n.fields.length} template fields \u2014 the maximum is ${ei}; split it into fewer fields`;for(let s of n.fields)if(!Qr.includes(s.kind))return`Repeating group ${n.id} has a "${s.kind}" child (${s.id}) \u2014 allowed child kinds are ${Qr.join(", ")}`;let i=Ct(n.fields);if(i)return`Duplicate child id in repeating group ${n.id}: ${i}`;let o=new Set(n.fields.map(s=>s.id));for(let s of n.fields)for(let l of s.visibleIf??[])if(!o.has(l.fieldId))return`Field ${s.id} in repeating group ${n.id} has a visibleIf referencing "${l.fieldId}" \u2014 a child's visibleIf can only reference another field in the SAME group`;let a=Is(n);if(a>ti)return`Repeating group ${n.id} could reach ~${Math.ceil(a/1e3)}KB at ${n.maxInstances} instances \u2014 the maximum is ~${Math.round(ti/1e3)}KB; lower maxInstances, shorten text limits, or trim the template`}return null}function Ls(e){let t=new Set;for(let r of e)for(let i of r.blocks)X(i)&&t.add(i.id);let n=new Map;for(let r of e)for(let i of r.blocks)if(i.kind==="repeating_group")for(let o of i.fields)!t.has(o.id)&&!n.has(o.id)&&n.set(o.id,i.id);return n}function Ms(e,t,n){for(let r of e)for(let i of r.blocks)for(let o of i.visibleIf??[]){let a=n.get(o.fieldId);if(a!==void 0)return`Field ${i.id}'s visibleIf references "${o.fieldId}", which is a child of repeating group ${a} \u2014 fields outside a repeating group can't reference its children`}for(let r of t)if(Array.isArray(r.next))for(let i of r.next){if(!i||typeof i!="object")continue;let o=i.when;if(Array.isArray(o))for(let a of o){if(!a||typeof a!="object")continue;let s=a.fieldId;if(typeof s!="string")continue;let l=n.get(s);if(l!==void 0)return`A jump rule on page ${r.id} references "${s}", which is a child of repeating group ${l} \u2014 jumps can't reference a repeating group's children`}}return null}function Ii(e){return{id:oe(e.id,128),visibleIf:Ln(e.visibleIf)}}function H(e,t){return{...Ii(e),kind:t,label:oe(e.label,2e3,"Untitled field"),description:B(e.description,5e3),required:ve(e.required),placeholder:B(e.placeholder,500)}}function ni(e){let t=B(e,2e3);if(t)try{let n=new URL(t);return n.protocol==="http:"||n.protocol==="https:"?t:void 0}catch{return}}function Ts(e){if(!e||typeof e!="object")return;let t=e,n=t.by==="browser"||t.by==="field"||t.by==="identify"?t.by:void 0;if(!n)return;let r=n==="field"?B(t.field,128):void 0;if(n==="field"&&!r)return;let i=B(t.scopeField,128),o=t.onRepeat==="update"&&n==="identify"?"update":"keep";return{by:n,...r?{field:r}:{},...i?{scopeField:i}:{},onRepeat:o}}function Ps(e){if(!e||typeof e!="object")return;let t=e,n=t.unverified==="allow"||t.unverified==="quarantine"?t.unverified:void 0,r=t.challenge==="turnstile"?"turnstile":void 0;if(!(!n&&!r))return{...n?{unverified:n}:{},...r?{challenge:r}:{}}}function Rs(e){let t=e&&typeof e=="object"?e:{};return{submitMode:t.submitMode==="button"||t.submitMode==="auto"?t.submitMode:void 0,submitLabel:B(t.submitLabel,100),successTitle:B(t.successTitle,200),successMessage:B(t.successMessage,5e3),redirectUrl:ni(t.redirectUrl),showProgress:ve(t.showProgress),responseLimit:Ts(t.responseLimit),trust:Ps(t.trust),notifyEmail:xt().check(K(254)).safeParse(t.notifyEmail).success?t.notifyEmail:void 0,sendReceipt:ve(t.sendReceipt),saveProgress:ve(t.saveProgress),draftAnswersVisible:ve(t.draftAnswersVisible),resumeEmails:ve(t.resumeEmails),resumeUrl:ni(t.resumeUrl),draftDigest:ve(t.draftDigest)}}function O(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function Ni(e){if(!e||typeof e!="object")return null;let t=e,n=t.kind,r=Ii(t);if(!r.id||typeof n!="string")return null;switch(n){case"heading":return O({...r,kind:n,text:oe(t.text,2e3,"Section")});case"paragraph":return O({...r,kind:n,text:oe(t.text,5e3)});case"divider":return O({...r,kind:n});case"short_text":case"email":case"url":return O({...H(t,n),maxLength:se(t.maxLength)===void 0?void 0:pe(t.maxLength,1,2e3,2e3)});case"phone":{let i=B(t.defaultCountry,2)?.toUpperCase();return O({...H(t,n),defaultCountry:i&&/^[A-Z]{2}$/.test(i)?i:void 0})}case"long_text":return O({...H(t,n),maxLength:se(t.maxLength)===void 0?void 0:pe(t.maxLength,1,2e4,2e4)});case"number":return O({...H(t,n),min:se(t.min),max:se(t.max),decimals:se(t.decimals)===void 0?void 0:pe(t.decimals,0,6,0),prefix:$t(t.prefix,100),suffix:$t(t.suffix,100),notation:t.notation==="grouped"?"grouped":t.notation==="grouped-comma"?"grouped-comma":t.notation==="grouped-dot"?"grouped-dot":void 0});case"select":case"multi_select":case"dropdown":{let i=St(t.options);return i.length===0?null:O({...H(t,n),options:i,allowOther:ve(t.allowOther),shuffleOptions:ve(t.shuffleOptions)})}case"checkbox":{let i=t.appearance==="toggle"?"toggle":void 0;return O({...H(t,n),appearance:i})}case"signature":case"date":return O(H(t,n));case"rating":{let i=pe(t.max,1,10,5);return O({...H(t,n),max:i,insightsMetric:t.insightsMetric==="csat"&&i===5?"csat":void 0})}case"linear_scale":{let i=pe(t.min,0,9,1),o=pe(t.max,i+1,10,10),a=t.insightsMetric==="nps"&&i===0&&o===10?"nps":t.insightsMetric==="csat"&&i===1&&o===5?"csat":void 0;return O({...H(t,n),min:i,max:o,minLabel:B(t.minLabel,100),maxLabel:B(t.maxLabel,100),insightsMetric:a})}case"ranking":{let i=St(t.options);return i.length<2?null:O({...H(t,n),options:i})}case"matrix":{let i=St(t.rows),o=St(t.columns);return i.length===0||o.length===0?null:O({...H(t,n),rows:i,columns:o})}case"hidden":return O({...H(t,n),required:!1,paramName:B(t.paramName,128),defaultValue:B(t.defaultValue,1e3)});case"calculated":return O({...H(t,n),required:!1,calc:t.calc,decimals:se(t.decimals)===void 0?void 0:pe(t.decimals,0,6,0),prefix:$t(t.prefix,100),suffix:$t(t.suffix,100)});case"file_upload":return O({...H(t,n),maxFiles:pe(t.maxFiles,1,Xo,1),maxFileSizeMb:pe(t.maxFileSizeMb,1,5e3,500),accept:Array.isArray(t.accept)?t.accept.flatMap(i=>{let o=B(i,100);return o?[o]:[]}).slice(0,50):void 0});case"repeating_group":{let o=(Array.isArray(t.fields)?t.fields:[]).slice(0,50).flatMap(a=>{let s=Ni(a);return s&&X(s)?[s]:[]});return O({...H(t,n),required:!1,fields:o,maxInstances:se(t.maxInstances)??Number.NaN,minInstances:se(t.minInstances),addLabel:B(t.addLabel,100),itemLabel:B(t.itemLabel,100)})}case"custom":return O({...H(t,n),component:oe(t.component,128),config:t.config&&typeof t.config=="object"&&!Array.isArray(t.config)?t.config:void 0});default:return null}}function Ne(e){let t=$s.safeParse(e);if(!t.success){let b=t.error.issues[0],g=b?.path.join(".");return{ok:!1,error:b?`${g?`${g}: `:""}${b.message}`:"Invalid schema"}}if(t.data.version>Ss)return{ok:!1,error:`Unsupported schema version: ${t.data.version}`};let n=t.data.pages.map(b=>{let g=b.blocks.flatMap(A=>{let z=Ni(A);return z?[z]:[]});return{id:oe(b.id,128),title:B(b.title,500),blocks:g,next:b.next}}),r=new Set(n.map(b=>b.id)),i=new Map;for(let b of n)for(let g of b.blocks){if(g.kind!=="calculated")continue;let A=new Set,z=Ae(g.calc);if(z){let P=new Set,ne=new Set;ze(z,P,ne);for(let W of P)A.add(W);for(let W of ne)A.add(W)}i.set(g.id,A)}let o=new Set,a=n.map(b=>{for(let g of b.blocks)X(g)&&o.add(g.id);return O({id:b.id,title:b.title,blocks:b.blocks,next:As(b.next,r,b.id,new Set(o),i)})}),s=new Set,l=new Set;for(let b of a){if(!b.id)return{ok:!1,error:"Page ids cannot be blank"};if(s.has(b.id))return{ok:!1,error:`Duplicate page id: ${b.id}`};s.add(b.id);for(let g of b.blocks){if(l.has(g.id))return{ok:!1,error:`Duplicate block id: ${g.id}`};if(l.add(g.id),g.kind==="number"&&g.min!==void 0&&g.max!==void 0&&g.min>g.max)return{ok:!1,error:`Field ${g.id} has min greater than max`};if(g.kind==="select"||g.kind==="multi_select"||g.kind==="dropdown"||g.kind==="ranking"){let A=Ct(g.options);if(A)return{ok:!1,error:`Duplicate option id in field ${g.id}: ${A}`}}else if(g.kind==="matrix"){let A=Ct(g.rows);if(A)return{ok:!1,error:`Duplicate matrix row id in field ${g.id}: ${A}`};let z=Ct(g.columns);if(z)return{ok:!1,error:`Duplicate matrix column id in field ${g.id}: ${z}`}}}}let c=Ns(a);if(c)return{ok:!1,error:c};let u=Ls(a),f=Ms(a,n,u);if(f)return{ok:!1,error:f};let p=Es(a,u);if(p)return{ok:!1,error:p};let m=Fs(a);if(m)return{ok:!1,error:m};if(a.every(b=>b.blocks.length===0))return{ok:!1,error:"Schema must contain at least one valid block"};let h={version:$n,title:oe(t.data.title,2e3),pages:a,settings:Rs(t.data.settings)},v=B(t.data.description,5e3);return v&&(h.description=v),{ok:!0,schema:h}}function tt(e,t){let n=B(e,t);if(n&&!(/[;{}<>]/.test(n)||/url\s*\(/i.test(n)))return n}function Mn(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,n=t.colorScheme==="light"||t.colorScheme==="dark"||t.colorScheme==="auto"?t.colorScheme:void 0,r=O({colorScheme:n,primary:tt(t.primary,200),background:tt(t.background,200),text:tt(t.text,200),radius:tt(t.radius,64),fontFamily:tt(t.fontFamily,200)});return Object.keys(r).length>0?r:null}function Os(e){throw new Error(`Unhandled field kind: ${JSON.stringify(e)}`)}function Tn(e,t){if(t==null||t==="")return"";switch(e.kind){case"file_upload":return Array.isArray(t)?t.map(n=>n.name).join(", "):String(t);case"select":case"dropdown":return e.options.find(n=>n.id===t)?.label??String(t);case"multi_select":return Array.isArray(t)?t.map(n=>e.options.find(r=>r.id===n)?.label??n).join(", "):String(t);case"ranking":return Array.isArray(t)?t.map((n,r)=>`${r+1}. ${e.options.find(i=>i.id===n)?.label??n}`).join(", "):String(t);case"matrix":{if(typeof t!="object"||t===null||Array.isArray(t))return String(t);let n=t;return e.rows.filter(r=>n[r.id]).map(r=>`${r.label}: ${e.columns.find(i=>i.id===n[r.id])?.label??""}`).join(", ")}case"signature":return typeof t=="string"&&t.startsWith("data:image/")?"\u270D signed":"";case"checkbox":return t===!0?"Yes":"No";case"rating":case"linear_scale":return String(t);case"number":{let n=typeof t=="number"?t:Number(t);if(!Number.isFinite(n))return String(t);let r=e.decimals===void 0?String(n):n.toFixed(Math.max(0,Math.min(6,e.decimals)));return`${e.prefix??""}${r}${e.suffix??""}`}case"calculated":{let n=typeof t=="number"?t:Number(t);if(!Number.isFinite(n))return String(t);let r=e.decimals===void 0?String(n):n.toFixed(Math.max(0,Math.min(6,e.decimals)));return`${e.prefix??""}${r}${e.suffix??""}`}case"repeating_group":{if(!Array.isArray(t))return String(t);let n=t;if(n.length===0)return"";let r=e.itemLabel??e.label,i=`${n.length} \xD7 ${r}`,o=e.fields[0];if(!o)return i;let a=n.map(s=>s&&typeof s=="object"&&!Array.isArray(s)?Tn(o,s[o.id]):"").filter(s=>s!=="");return a.length>0?`${i}: ${a.join(", ")}`:i}case"phone":{let{country:n,national:r,e164:i}=at(String(t));if(!i)return String(t);let o=st(n,r),a=n?`+${n.dialCode}`:i.replace(r,"");return o?`${a} ${o}`:i}case"short_text":case"long_text":case"email":case"url":case"date":case"hidden":return String(t);case"custom":return typeof t=="object"?JSON.stringify(t):String(t);default:return Os(e)}}function Zs(e){return Math.max(0,Math.min(6,Math.round(e)))}function Li(e){switch(e){case"grouped-comma":return"en-US";case"grouped-dot":return"de-DE";case"grouped":case void 0:return}}function Mi(e,t){if(!Number.isFinite(e))return String(e);let n=t?.decimals===void 0?void 0:Zs(t.decimals);if(typeof Intl>"u")return n===void 0?String(e):e.toFixed(n);let r={useGrouping:!0};return n===void 0?r.maximumFractionDigits=20:(r.minimumFractionDigits=n,r.maximumFractionDigits=n),new Intl.NumberFormat(t?.locale,r).format(e)}function Ti(e,t){return t?e.split(t).join(""):e}function ri(e,t){return t==="."?e:e.split(t).join(".")}function Ds(e,t,n){if(n!==t&&e.includes(n)){let o=e.lastIndexOf(n),a=Ti(e.slice(0,o),t),s=e.slice(o+n.length);return`${a}.${s}`}let r=e.split(t);return r.length===1?e:r.every((o,a)=>a===0?/^[1-9]\d{0,2}$/.test(o):/^\d{3}$/.test(o))?r.join(""):`${r.slice(0,-1).join("")}.${r.at(-1)??""}`}function Pn(e,t){if(typeof Intl>"u"||e.trim()==="")return e;let n=new Intl.NumberFormat(t).formatToParts(12345678e-1),r=n.find(s=>s.type==="group")?.value??",",i=n.find(s=>s.type==="decimal")?.value??".",o=e.trim(),a=o.startsWith("-");return a&&(o=o.slice(1)),/^\s$/.test(r)?o=ri(o.replace(/\s/g,""),i):r==="."||r===","?o=Ds(o,r,i):o=ri(Ti(o,r),i),o===""||o==="."||!/^\d*\.?\d*$/.test(o)?e:a?`-${o}`:o}function ct(e,t){let r=e.startsWith("-")?e.slice(1):e;if(r.includes("-"))return!1;if(r==="")return!0;if(typeof Intl>"u")return/^[\d.,]*$/.test(r);let i=new Intl.NumberFormat(t).formatToParts(12345678e-1),o=i.find(f=>f.type==="group")?.value??",",a=i.find(f=>f.type==="decimal")?.value??".",s=o===".",l=/^\s$/.test(o),c=s?[a]:Array.from(new Set([".",a])),u=0;for(let f of r)if(!/\d/.test(f)){if(c.includes(f)){if(++u>1)return!1;continue}if(!(l?/\s/.test(f):f===o))return!1}return!0}var An="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",Us=256-256%An.length;function ii(e=12){if(!Number.isSafeInteger(e)||e<=0)throw new RangeError("createId size must be a positive safe integer");let t=globalThis.crypto;if(typeof t>"u"||typeof t.getRandomValues!="function")throw new Error("createId requires Web Crypto (globalThis.crypto.getRandomValues)");let n="";for(;n.length<e;){let r=new Uint8Array(e);t.getRandomValues(r);for(let i=0;i<e&&n.length<e;i++){let o=r[i];o<Us&&(n+=An[o%An.length])}}return n}var Pi=class{h0=1732584193;h1=4023233417;h2=2562383102;h3=271733878;h4=3285377520;block=new Uint8Array(64);blockLen=0;totalLen=0;w=new Int32Array(80);update(e){this.totalLen+=e.length;let t=0;if(this.blockLen>0){for(;t<e.length&&this.blockLen<64;)this.block[this.blockLen++]=e[t++];this.blockLen===64&&(this.process(this.block),this.blockLen=0)}for(;t+64<=e.length;)this.process(e.subarray(t,t+64)),t+=64;for(;t<e.length;)this.block[this.blockLen++]=e[t++];return this}digest(){let e=Math.floor(this.totalLen/536870912),t=this.totalLen*8>>>0,n=[128],r=this.blockLen+1;for(;r%64!==56;)n.push(0),r++;n.push(e>>>24&255,e>>>16&255,e>>>8&255,e&255),n.push(t>>>24&255,t>>>16&255,t>>>8&255,t&255),this.update(new Uint8Array(n));let i=new Uint8Array(20),o=[this.h0,this.h1,this.h2,this.h3,this.h4];for(let a=0;a<5;a++)i[a*4]=o[a]>>>24&255,i[a*4+1]=o[a]>>>16&255,i[a*4+2]=o[a]>>>8&255,i[a*4+3]=o[a]&255;return i}process(e){let t=this.w;for(let s=0;s<16;s++)t[s]=e[s*4]<<24|e[s*4+1]<<16|e[s*4+2]<<8|e[s*4+3];for(let s=16;s<80;s++){let l=t[s-3]^t[s-8]^t[s-14]^t[s-16];t[s]=l<<1|l>>>31}let n=this.h0,r=this.h1,i=this.h2,o=this.h3,a=this.h4;for(let s=0;s<80;s++){let l,c;s<20?(l=r&i|~r&o,c=1518500249):s<40?(l=r^i^o,c=1859775393):s<60?(l=r&i|r&o|i&o,c=2400959708):(l=r^i^o,c=3395469782);let u=(n<<5|n>>>27)+l+a+c+t[s]|0;a=o,o=i,i=r<<30|r>>>2,r=n,n=u}this.h0=this.h0+n|0,this.h1=this.h1+r|0,this.h2=this.h2+i|0,this.h3=this.h3+o|0,this.h4=this.h4+a|0}},At="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Rn(e){let t="";for(let n=0;n<e.length;n+=3){let r=e[n],i=n+1<e.length?e[n+1]:0,o=n+2<e.length?e[n+2]:0;t+=At[r>>2],t+=At[(r&3)<<4|i>>4],t+=n+1<e.length?At[(i&15)<<2|o>>6]:"=",t+=n+2<e.length?At[o&63]:"="}return t}var Bs=e=>Rn(new Pi().update(e).digest()),S=class extends Error{constructor(e,t,n,r){super(e),this.status=t,this.retryAfterSec=n,this.code=r,this.name="FilloError"}status;retryAfterSec;code};function ee(e){return e instanceof Error&&e.name==="FilloError"}async function oi(e,t){try{let n=await e.json();return{message:typeof n.error=="string"&&n.error?n.error:t,code:typeof n.code=="string"&&n.code?n.code:void 0}}catch{}return{message:t}}function dn(e){let t=Number(e.headers.get("retry-after"));return Number.isFinite(t)&&t>0?t:void 0}var nt=3,js=4,rt=3e4,Vs=5*6e4,de=10*6e4;function si(e,t){return t?.throwIfAborted(),new Promise((n,r)=>{let i=()=>{clearTimeout(o),r(t?.reason)},o=setTimeout(()=>{t?.removeEventListener("abort",i),n()},e);t?.addEventListener("abort",i,{once:!0})})}function pn(e,t=!1){let n=ee(e)?e.status??0:0;return n===0||n===503||n===504||t&&n===409&&ee(e)&&e.retryAfterSec!==void 0}function zt(e){return e>=500||e===429||e===408}function ai(e){return typeof DOMException<"u"&&e instanceof DOMException&&e.name==="TimeoutError"?new S("Request timed out",0):e}function Hs(e,t){let n=e.split(".").map(i=>Number(i)||0),r=t.split(".").map(i=>Number(i)||0);for(let i=0;i<Math.max(n.length,r.length);i++){let o=(n[i]??0)-(r[i]??0);if(o!==0)return o}return 0}function Gs(e){if(e.schemaVersion!==void 0&&e.schemaVersion!==$n)throw new S(`This form uses schema version ${e.schemaVersion}; this SDK supports version ${$n}. Update @usefillo/* to render it.`,426);if(e.minSdkVersion&&Hs(Sn,e.minSdkVersion)<0)throw new S(`This form requires @usefillo/* ${e.minSdkVersion} or newer. Current SDK is ${Sn}.`,426)}function Et(e,t){return n=>t.onProgress?.({uploadedBytes:n,totalBytes:e,fraction:e===0?1:n/e})}async function qs(e){let t=globalThis.crypto?.subtle;if(t){let n=await t.digest("SHA-1",e);return Rn(new Uint8Array(n))}return Bs(e)}var Ws="https://fillo.so",li={"X-Fillo-Client":`@usefillo/core@${Sn}`},Mt=class{baseUrl;fetch;activeUploads=0;uploadQueue=new Set;key;constructor(e={}){this.baseUrl=e.baseUrl?e.baseUrl.replace(/\/$/,""):e.sameOrigin?"":Ws,this.key=e.key,this.fetch=e.fetch??((...t)=>globalThis.fetch(...t))}url(e){return`${this.baseUrl}/api/v1${e}`}async json(e,t){let n=t?.body!=null?{"Content-Type":"application/json",...li,...t?.headers}:t?.headers,r;try{r=await this.fetch(this.url(e),{...t,headers:n,signal:t?.signal??AbortSignal.timeout(rt)})}catch(i){throw ai(i)}if(!r.ok){let{message:i,code:o}=await oi(r,`Request failed: ${r.status}`);throw new S(i,r.status,dn(r),o)}return await r.json()}async getForm(e){let t=await this.json(`/forms/${encodeURIComponent(e)}`);return Gs(t),t}syncForm(e,t,n){if(!this.key)return Promise.reject(new S("createClient needs a `key` (pk_\u2026) to sync code-defined forms",401));let r=Ne(t);return r.ok?this.json("/forms/sync",{method:"POST",body:JSON.stringify({key:this.key,id:e,schema:r.schema,theme:Mn(n)})}):Promise.reject(new S(`Invalid form schema: ${r.error}`,400))}async submit(e,t,n){let r;try{r=await this.fetch(this.url(`/forms/${encodeURIComponent(e)}/responses`),{method:"POST",headers:{"Content-Type":"application/json",...li},body:JSON.stringify({data:t,meta:n}),signal:AbortSignal.timeout(rt)})}catch(o){throw ai(o)}if(r.status===422){let o=await r.json().catch(()=>null);if(o?.errors&&typeof o.errors=="object"&&!Array.isArray(o.errors))return{ok:!1,errors:o.errors};throw new S(typeof o?.error=="string"&&o.error?o.error:"Submit failed: 422",422,dn(r),typeof o?.code=="string"&&o.code?o.code:void 0)}if(!r.ok){let{message:o,code:a}=await oi(r,`Submit failed: ${r.status}`);throw new S(o,r.status,dn(r),a)}let i=await r.json();return{ok:!0,responseId:i.id,duplicate:i.duplicate,updated:i.updated}}async fetchOwnResponse(e,t,n){try{return await this.json(`/forms/${encodeURIComponent(e)}/respondent-response`,{method:"POST",body:JSON.stringify({respondent:t,scopeValue:n})})}catch(r){if(ee(r)&&(r.status===404||r.status===403))return null;throw r}}async startSession(e,t){try{let n=await this.fetch(this.url(`/forms/${encodeURIComponent(e)}/sessions`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pageCount:t}),signal:AbortSignal.timeout(rt)});return n.ok?(await n.json()).id:null}catch{return null}}reportProgress(e,t){try{this.fetch(this.url(`/sessions/${encodeURIComponent(e)}/progress`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),keepalive:!0,signal:AbortSignal.timeout(rt)}).catch(()=>{})}catch{}}createDraft(e,t){return this.json(`/forms/${encodeURIComponent(e)}/drafts`,{method:"POST",body:JSON.stringify(t)})}getDraft(e,t,n){return this.json(`/drafts/${encodeURIComponent(e)}`,{headers:n?{"X-Fillo-Draft-Token":t,"X-Fillo-Draft-Adopt":"1"}:{"X-Fillo-Draft-Token":t}})}async saveDraft(e,t,n,r){await this.json(`/drafts/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"X-Fillo-Draft-Token":t},body:JSON.stringify(n),...r?.keepalive?{keepalive:!0}:{}})}async deleteDraft(e,t){await this.json(`/drafts/${encodeURIComponent(e)}`,{method:"DELETE",headers:{"X-Fillo-Draft-Token":t}})}getUploadSession(e,t,n=AbortSignal.timeout(de)){return this.json(`/uploads/${encodeURIComponent(e)}`,{...t?{headers:{"X-Fillo-Upload-Token":t}}:{},signal:n})}async uploadFile(e,t,n){await this.acquireUploadSlot(n.signal);try{return n.signal?.throwIfAborted(),await this.performUpload(e,t,n)}finally{this.activeUploads-=1;let r=this.uploadQueue.values().next().value;r&&(this.uploadQueue.delete(r),r())}}async acquireUploadSlot(e){if(e?.throwIfAborted(),this.activeUploads<js){this.activeUploads+=1;return}await new Promise((t,n)=>{let r=()=>{e?.removeEventListener("abort",i),this.activeUploads+=1,t()},i=()=>{this.uploadQueue.delete(r),n(e?.reason)};this.uploadQueue.add(r),e?.addEventListener("abort",i,{once:!0})})}async performUpload(e,t,n){let r=typeof File<"u"&&t instanceof File?t.name:"upload.bin",i=(t.type||"application/octet-stream").trim().toLowerCase(),o;if(n.sessionId){let c=await this.getUploadSession(n.sessionId,n.uploadToken,this.uploadSignal(n,de));if(c.formId!==e||c.fieldId!==n.fieldId||c.fileName!==r||c.size!==t.size||c.mime.trim().toLowerCase()!==i)throw new S("File does not match this upload session",400);o=c,o.token||=n.uploadToken}else{let c=ii(24),u=ii(32),f=()=>this.json(`/forms/${encodeURIComponent(e)}/uploads`,{method:"POST",body:JSON.stringify({requestId:c,uploadToken:u,fieldId:n.fieldId,fileName:r,size:t.size,mime:i}),signal:this.uploadSignal(n,de)}),p=Date.now()+de,m=250;for(;;)try{o=await f();break}catch(h){if(n.signal?.aborted||!pn(h,!0))throw h;let v=p-Date.now();if(v<=0)throw h;await si(Math.min(m,v),n.signal),m=Math.min(m*2,5e3)}}if(n.onSession?.({sessionId:o.id,uploadToken:o.token}),o.status==="complete"&&o.file)return o.file;if(o.status==="aborted")throw new S("This upload session was cancelled",409);let a;if(o.transport?.type==="gdrive")await this.driveUploadLoop(o,o.transport.uploadUrl,t,n);else if(o.transport?.type==="s3-multipart")await this.s3MultipartUploadLoop(o,t,n);else if(o.transport?.type==="s3-put")await this.s3PutUpload(o.transport.uploadUrl,t,n);else if(o.transport?.type==="box")a=await this.boxUpload(o.transport,t,n);else throw new S("This form's storage doesn't support uploads \u2014 connect Drive, S3, or Box.");let s=()=>this.json(`/uploads/${encodeURIComponent(o.id)}/complete`,{method:"POST",headers:o.token?{"X-Fillo-Upload-Token":o.token}:void 0,...a?{body:JSON.stringify(a)}:{},signal:this.uploadSignal(n,de)}),l;try{l=await s()}catch(c){if(n.signal?.aborted||!pn(c))throw c;let u=Date.now()+de,f=250;for(;;){let p=await this.getUploadSession(o.id,o.token,this.uploadSignal(n,Math.max(1,u-Date.now())));if(p.status==="complete"&&p.file)return p.file;if(p.status==="aborted")throw c;try{l=await s();break}catch(h){if(n.signal?.aborted||!pn(h,!0))throw h}let m=u-Date.now();if(m<=0)throw c;await si(Math.min(f,m),n.signal),f=Math.min(f*2,5e3)}}if(!l.file)throw new S("Upload completed but no file was returned");return l.file}async boxUpload(e,t,n){let r=Et(t.size,n);r(0);let i={Authorization:`Bearer ${e.token}`};if(e.mode==="simple"){let p=new FormData;p.append("attributes",JSON.stringify({name:e.fileName,parent:{id:e.folderId}})),p.append("file",t,e.fileName);let m=await this.retry(n,async()=>{let v=await this.fetch(e.uploadUrl,{method:"POST",headers:i,body:p,signal:this.uploadSignal(n)});if(!v.ok&&zt(v.status))throw new S(`Box upload failed: ${v.status}`,v.status);return v});if(!m.ok)throw new S(`Box upload failed: ${m.status}`,m.status);let h=await m.json();return r(t.size),{providerFileId:h.entries?.[0]?.id}}if(e.size!==t.size)throw new S(`File size changed since the upload was requested (${t.size} vs ${e.size}).`,400);let o=await this.retry(n,async()=>{let p=await this.fetch(e.sessionUrl,{method:"POST",headers:{...i,"Content-Type":"application/json"},body:JSON.stringify({folder_id:e.folderId,file_size:e.size,file_name:e.fileName}),signal:this.uploadSignal(n)});if(!p.ok&&zt(p.status))throw new S(`Box session failed: ${p.status}`,p.status);return p});if(!o.ok)throw new S(`Box session failed: ${o.status}`,o.status);let a=await o.json(),s=new Pi,l=[],c=0;for(;c<t.size;){n.signal?.throwIfAborted();let p=Math.min(c+a.part_size,t.size),m=new Uint8Array(await t.slice(c,p).arrayBuffer());s.update(m);let h=await qs(m),v=await this.retry(n,async()=>{let b=await this.fetch(a.session_endpoints.upload_part,{method:"PUT",headers:{...i,"Content-Type":"application/octet-stream",Digest:`sha=${h}`,"Content-Range":`bytes ${c}-${p-1}/${t.size}`},body:m,signal:this.uploadSignal(n)});if(!b.ok&&zt(b.status))throw new S(`Box part failed: ${b.status}`,b.status);return b});if(!v.ok)throw new S(`Box part failed: ${v.status}`,v.status);l.push((await v.json()).part),c=p,r(c)}let u=await this.retry(n,async()=>{let p=await this.fetch(a.session_endpoints.commit,{method:"POST",headers:{...i,"Content-Type":"application/json",Digest:`sha=${Rn(s.digest())}`},body:JSON.stringify({parts:l}),signal:this.uploadSignal(n)});if(!p.ok&&zt(p.status))throw new S(`Box commit failed: ${p.status}`,p.status);return p});if(!u.ok)throw new S(`Box commit failed: ${u.status}`,u.status);return{providerFileId:(await u.json()).entries?.[0]?.id}}uploadSignal(e,t=rt){let n=AbortSignal.timeout(t);return e.signal?AbortSignal.any([e.signal,n]):n}async retry(e,t){let n=0;for(;;)try{return await t()}catch(r){if(e.signal?.aborted||(n+=1,n>=nt))throw r;await new Promise(i=>setTimeout(i,500*2**n))}}async driveUploadLoop(e,t,n,r){let i=e.uploadedBytes,o=Et(n.size,r);o(i);let a=0;for(;i<n.size;){r.signal?.throwIfAborted();let s=i,l=Math.min(i+e.chunkSize,n.size),c=n.slice(i,l),u=0;for(;;)try{let f=await this.fetch(t,{method:"PUT",headers:{"Content-Range":`bytes ${i}-${l-1}/${n.size}`},body:c,signal:this.uploadSignal(r)});if(f.status===308){let p=f.headers.get("Range")??f.headers.get("range"),m=p?.match(/bytes=0-(\d+)/);m?i=Number(m[1])+1:p==null?i=0:i=(await this.getUploadSession(e.id,e.token,this.uploadSignal(r,de))).uploadedBytes;break}if(f.ok){i=n.size;break}throw new S(`Drive chunk failed: ${f.status}`,f.status)}catch(f){if(r.signal?.aborted||(u+=1,u>=nt))throw f;if(await new Promise(m=>setTimeout(m,500*2**u)),i=(await this.getUploadSession(e.id,e.token,this.uploadSignal(r,de))).uploadedBytes,i>=n.size)break;l=Math.min(i+e.chunkSize,n.size),c=n.slice(i,l)}if(o(i),i<=s){if(++a>=nt)throw new S("Drive upload stalled \u2014 the storage endpoint stopped accepting progress",0)}else a=0}}async s3MultipartUploadLoop(e,t,n){if(!Number.isSafeInteger(e.chunkSize)||e.chunkSize<=0||!Number.isSafeInteger(e.uploadedBytes)||e.uploadedBytes<0||e.uploadedBytes>t.size||e.uploadedBytes<t.size&&e.uploadedBytes%e.chunkSize!==0)throw new S("S3 upload session returned invalid progress",502);let r=Et(t.size,n),i=e.uploadedBytes;for(r(i);i<t.size;){n.signal?.throwIfAborted();let o=Math.floor(i/e.chunkSize)+1;if(o>1e4)throw new S("S3 upload needs too many parts",413);let a=Math.min(i+e.chunkSize,t.size),s=t.slice(i,a),l=0;for(;;){let c;try{let u=await this.json(`/uploads/${encodeURIComponent(e.id)}/parts`,{method:"POST",headers:e.token?{"X-Fillo-Upload-Token":e.token}:void 0,body:JSON.stringify({partNumber:o}),signal:this.uploadSignal(n,de)});if(typeof u.uploadUrl!="string"||!u.uploadUrl)throw new S("S3 part URL was unavailable",502);c=u.uploadUrl;let f=await this.fetch(c,{method:"PUT",body:s,signal:this.uploadSignal(n,Vs)});if(!f.ok)throw new S(`S3 part upload failed: ${f.status}`,f.status);i=a,r(i);break}catch(u){if(n.signal?.aborted)throw u;let f=await this.getUploadSession(e.id,e.token,this.uploadSignal(n,de));if(f.status==="aborted")throw new S("This upload session was cancelled",409);if(!Number.isSafeInteger(f.uploadedBytes)||f.uploadedBytes<i||f.uploadedBytes>t.size||f.uploadedBytes<t.size&&f.uploadedBytes%e.chunkSize!==0)throw new S("S3 upload session returned invalid progress",502);if(f.uploadedBytes>i){i=f.uploadedBytes,r(i);break}if(l+=1,l>=nt)throw u;await new Promise(p=>setTimeout(p,500*2**l))}}}}async s3PutUpload(e,t,n){let r=Et(t.size,n);r(0);let i=0;for(;;)try{let o=await this.fetch(e,{method:"PUT",headers:{"Content-Type":t.type||"application/octet-stream"},body:t,signal:this.uploadSignal(n)});if(!o.ok)throw new S(`S3 upload failed: ${o.status}`,o.status);r(t.size);return}catch(o){if(n.signal?.aborted||(i+=1,i>=nt))throw o;await new Promise(a=>setTimeout(a,500*2**i))}}};function Le(e={}){return new Mt(e)}function fn(e){let t=e.trim();if(!/^-?\d*\.?\d+$/.test(t))return null;let n=Number(t);return Number.isFinite(n)?n:null}function ci(e,t){let n={};for(let r of ye(e)){let i=r.kind==="hidden"?t[r.paramName??r.id]??r.defaultValue:t[r.id];if(!(i===void 0||i===""))switch(r.kind){case"number":{let o=fn(i);if(o===null||r.min!==void 0&&o<r.min||r.max!==void 0&&o>r.max)break;n[r.id]=o;break}case"rating":{let o=fn(i);o!==null&&Number.isInteger(o)&&o>=1&&o<=(r.max??5)&&(n[r.id]=o);break}case"linear_scale":{let o=fn(i),a=r.min??1,s=r.max??10;o!==null&&Number.isInteger(o)&&o>=a&&o<=s&&(n[r.id]=o);break}case"checkbox":n[r.id]=i==="true"||i==="1"||i==="yes";break;case"select":case"dropdown":{r.options.some(o=>o.id===i)&&(n[r.id]=i);break}case"multi_select":{let o=new Set(r.options.map(s=>s.id)),a=[...new Set(i.split(",").filter(s=>o.has(s)))];a.length>0&&(n[r.id]=a);break}case"file_upload":case"ranking":case"matrix":case"signature":case"custom":break;case"calculated":break;case"repeating_group":break;default:n[r.id]=i}}return n}function Ks(){if(!(typeof document>"u"||typeof window>"u"))try{let e=new URL(window.location.href);e.hash="";let t=document.cookie.split(";").map(r=>r.trim()).find(r=>r.startsWith("hubspotutk="))?.slice(11),n={pageUri:e.href.slice(0,2048),pageName:document.title.trim().slice(0,200)||void 0,hubspotutk:t&&/^[a-f0-9]{32}$/i.test(t)?t:void 0};return Object.values(n).some(Boolean)?n:void 0}catch{return}}var Js={id:"empty",blocks:[]},ui=!1,di=!1;function Xs(){di||(di=!0,console.warn("[fillo] This form has a client but no submission target \u2014 a bare schema can't sync. Wrap it in defineForm({ id, pages }) (or author it with <Fillo.Form id=\u2026>) so it gets a project handle, or pass formId for a dashboard-built form: https://fillo.so/docs"))}function Ys(){ui||(ui=!0,console.warn("[fillo] This form has no `client`, so responses can't be submitted \u2014 it's render-only. Pass a client (createClient) to collect responses in Fillo, or forward them to your own backend with webhooks: https://fillo.so/docs"))}var Ri=new Map;function On(){try{return globalThis.localStorage??null}catch{return null}}function Oi(e){return`fillo:submission:${e}`}function Zn(){let e=globalThis.crypto;if(e?.randomUUID)return e.randomUUID();let t=new Uint8Array(16);return e?.getRandomValues?(e.getRandomValues(t),Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")):`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function Zi(e,t,n,r){let i=On();if(!i)return e.get(n)??null;try{let o=JSON.parse(i.getItem(t)??"null");if(o&&r(o))return o}catch{}return null}function Di(e,t,n,r){e.set(n,r);let i=On();if(i)try{i.setItem(t,JSON.stringify(r))}catch{}}function Dn(e){return Zi(Ri,Oi(e),e,t=>typeof t.key=="string")}function Ui(e,t){Di(Ri,Oi(e),e,t)}function Qs(e){let t=Dn(e);if(t?.key)return t.key;let n={key:Zn()};return Ui(e,n),n.key}function ea(e,t){let n=Dn(e);Ui(e,{key:n?.key??Zn(),submittedAt:new Date().toISOString(),responseId:t})}function zn(e,t,n){let r=wi(e.settings,n);return r===null?t:`${t}::${r}`}function pi(e,t,n){return e.settings.responseLimit?.by!=="browser"||!t?!1:!!Dn(zn(e,t,n))?.submittedAt}var Un=new Map;function Bn(e){return`fillo:draft:${e}`}function Ft(e){return Zi(Un,Bn(e),e,t=>{let n=t;return typeof n.id=="string"&&typeof n.token=="string"})}function hn(e,t){Di(Un,Bn(e),e,t)}function mn(e){Un.delete(e);let t=On();if(t)try{t.removeItem(Bn(e))}catch{}}function gn(e){return ee(e)&&(e.status===401||e.status===403||e.status===404)}var ta=1500;function Bi(e,t){if(ee(e)){let n=e.status??0;if(n===404)return t.loadFailedNotFound;switch(e.code){case"submit_rate_limited":return t.submitRateLimited;case"workspace_unavailable":case"provision_closed":return t.formClosed;case"respondent_unrecognized":return t.respondentUnrecognized;case"invalid_file_reference":return t.fileUnavailable;case"response_scope_missing":return t.scopeMissing}if(n>0)return t.submitFailed}return t.loadFailedNetwork}function na(e,t,n){if(ee(e)){let r=e.status??0;if(t&&r>0&&e.message)return e.code?`${e.message} (${e.code})`:e.message;if(r>0&&r<500&&r!==408&&r!==429)return n.formUnavailable;if(r>0)return n.submitFailed}return Bi(e,n)}function ji(e){let{onChange:t,onSubmitted:n}=e,r={...Jr,...e.respondentErrorStrings},i=Ne(e.form);if(!i.ok)throw new Error(`Invalid form schema: ${i.error}`);let o=i.schema,a=e.formId,s=e.client,l=e.respondent,c=De(o,{...e.initialData??{}}),u={},f=0,p,m=[];function h(){return e.previewNavigation===!0&&e.skipValidation===!0&&!s&&!a&&!e.resolveFormId}function v(){return je(o,c,h()?p:void 0)}function b(){h()&&m.push({pageIndex:f,startPageId:p})}let g="idle",A=!1,z=!1;queueMicrotask(()=>{if(typeof location<"u"&&location.search){let $=Object.fromEntries(new URLSearchParams(location.search)),x=null;for(let[k,C]of Object.entries(ci(o,$)))c[k]===void 0&&(x=x??{...c},x[k]=C);x&&g==="idle"&&(c=De(o,x),F())}g==="idle"&&pi(o,a,c)&&(g="submitted",A=!0,F());let y=!1;if(o.settings.saveProgress&&a&&s&&typeof location<"u"&&location.hash.includes("fillo-draft=")){let $=/fillo-draft=([^&]+)/.exec(location.hash),x=$?.[1]?decodeURIComponent($[1]):"",k=x.indexOf(".");if(k>0){y=!0;let C=x.slice(0,k),N=x.slice(k+1);s.getDraft(C,N,!0).then(M=>{hn(a,{id:C,token:M.token??N});try{history.replaceState(null,"",location.pathname+location.search)}catch{}}).catch(M=>{gn(M)&&(z=!0,F())}).finally(()=>Ut())}}y||Ut()});let P,ne=new Set,W=new Set,re=Date.now(),he=Zn(),ae=null,le=!1,V=!1,ce=!1,Te="created",Pe=!1,_=null,Z=null,j=Promise.resolve(),U=!1,qe=!1,Ee=!1,Re=!1;function R(){let y=o.pages.length,$=Math.min(f,Math.max(y-1,0)),x=o.pages[$]??Js;return{data:c,errors:u,status:g,pageIndex:$,pageCount:y,page:x,blocks:kt(o,x,c),isFirstPage:$===0,isLastPage:h()&&p!==void 0?v().at(-1)===x.id:xn(o,x.id,c),uploading:ne.size>0,submitError:P,restoredSubmission:A,resumedDraft:V,editingPrevious:ce,duplicateSubmission:Te==="duplicate",updatedSubmission:Te==="updated",resumeLinkFailed:z}}let Y=R();function F(){Y=R();for(let y of W)y()}function me(y,$){try{n?.(y,$)}catch(x){console.error("[fillo] onSubmitted handler threw:",x)}}function Qn(y){let $=o.pages[y];if(!$)return{};let x={};for(let k of kt(o,$,c)){if(!X(k)||h()&&k.kind==="file_upload")continue;let C=It(k,c[k.id]);C&&(x[k.id]=C)}return x}function gt(){return!!(o.settings.saveProgress&&s&&a&&!qe)}function ho(){let y=new Set;for(let $ of o.pages)for(let x of $.blocks)X(x)&&y.add(x.id);return y}function Dt(y){if(g!=="idle"||le)return;let $=ho(),x=null;for(let[N,M]of Object.entries(y.data??{}))c[N]===void 0&&$.has(N)&&(x=x??{...c},x[N]=M);let k=typeof y.page=="number"&&Number.isFinite(y.page)?Math.max(0,Math.min(Math.floor(y.page),o.pages.length-1)):0,C=k>0&&f===0;!x&&!C||(x&&(c=De(o,x)),C&&(f=k),V=!0,F())}function Ut(){if(g!=="idle")return;if(!gt()){er();return}let y=a,$=s,x=_??Ft(y);if(x&&!Ee){Ee=!0,_=x,$.getDraft(x.id,x.token).then(Dt).catch(k=>{gn(k)&&(mn(y),_=null)});return}!x&&!Re&&l?.hash&&(Re=!0,$.createDraft(y,{data:{},page:0,respondent:l}).then(k=>{if(!_){if(_={id:k.id,token:k.token},hn(y,_),k.existing)return $.getDraft(k.id,k.token).then(Dt);er()}}).catch(k=>{ee(k)&&k.status!==void 0&&k.status>=400&&k.status<500||(Re=!1)}))}function er(){if(Pe||o.settings.responseLimit?.onRepeat!=="update"||!s||!a||!l?.hash||g!=="idle")return;Pe=!0;let y=s,$=wi(o.settings,c)??void 0;y.fetchOwnResponse(a,l,$).then(x=>{!x||g!=="idle"||le||V||(Dt({data:x.data,page:0}),V&&(V=!1,ce=!0,F()))}).catch(()=>{})}function Bt(y=!1){if(Z&&(clearTimeout(Z),Z=null),!gt()||g!=="idle"||!U)return;let $=a,x=s;U=!1,j=j.then(async()=>{let k={data:c,page:Math.max(0,Math.min(f,o.pages.length-1))},C=_??Ft($);try{if(C)try{await x.saveDraft(C.id,C.token,k,y?{keepalive:!0}:void 0),_=C;return}catch(M){if(!gn(M))throw M;mn($),_=null}let N=await x.createDraft($,l?.hash?{...k,respondent:l}:k);_={id:N.id,token:N.token},hn($,_),N.existing&&(U=!0)}catch(N){ee(N)&&N.status!==void 0&&N.status>=400&&N.status<500&&N.status!==429?qe=!0:U=!0}})}function mo(){!gt()||g!=="idle"||(U=!0,Z&&clearTimeout(Z),Z=setTimeout(()=>{Z=null,Bt()},ta))}function tr(){!gt()||!le&&!_||(U=!0,Bt())}function nr(){Z&&(clearTimeout(Z),Z=null),U=!1,a&&mn(a),_=null}function go(y,$){!le&&s&&a&&(le=!0,s.startSession(a,o.pages.length).then(k=>ae=k)),c=De(o,{...c,[y]:$}),t?.(c),P=void 0;let x=`${y}.`;(y in u||Object.keys(u).some(k=>k.startsWith(x)))&&(u=Object.fromEntries(Object.entries(u).filter(([k])=>k!==y&&!k.startsWith(x)))),F(),mo()}function bo(y,$){$?(ne.add(y),y in u&&(u=Object.fromEntries(Object.entries(u).filter(([x])=>x!==y)))):ne.delete(y),F()}function rr(y){if(y.length===0)return-1;let $=o.pages.length,x=Math.min(f,Math.max($-1,0)),k=o.pages[x]?.id,C=k===void 0?-1:y.indexOf(k);if(C>=0)return C;let N=0;for(let M=0;M<y.length;M++){let ge=o.pages.findIndex(jt=>jt.id===y[M]);ge>=0&&ge<=x&&(N=M)}return N}function vo(){let y=o.pages.length,$=Math.min(f,Math.max(y-1,0));if(!e.skipValidation||e.previewNavigation===!0){let ge=Qn($);if(u=ge,Object.keys(ge).length>0){F();return}}let x=o.pages[$],k=v(),C=rr(k);if((h()&&p!==void 0?k.at(-1)===x?.id:x?xn(o,x.id,c):!0)||C<0||C+1>=k.length){ir();return}let M=o.pages.findIndex(ge=>ge.id===k[C+1]);b(),f=M>=0?M:Math.min($+1,y-1),ae&&s&&s.reportProgress(ae,{furthestPage:f}),F(),tr()}function yo(){u={};let y=h()?m.pop():void 0;if(y){f=Math.min(y.pageIndex,o.pages.length-1),p=y.startPageId,P=void 0,F();return}let $=je(o,c),x=rr($);if(x>0){let k=o.pages.findIndex(C=>C.id===$[x-1]);f=k>=0?k:Math.max(Math.min(f,o.pages.length-1)-1,0)}else if($.length>0){let k=o.pages.findIndex(C=>C.id===$[0]);f=k>=0?k:0}F(),tr()}function wo(){!h()||g==="submitting"||g==="submitted"||f>=o.pages.length-1||(b(),f+=1,p=o.pages[f]?.id,u={},P=void 0,F())}async function ir(){if(g==="submitting"||g==="submitted")return;if(h()&&(u=Qn(f),Object.keys(u).length>0)){F();return}let y=Fi(o,c);if(!y.ok){let $=e.skipValidation&&!(s&&a),x=$?Object.fromEntries(Object.entries(y.errors).filter(([C])=>o.pages.every(N=>N.blocks.every(M=>!(X(M)&&M.id===C&&M.kind==="file_upload"))))):y.errors;if($&&Object.keys(x).length===0){u={},g="submitted",F(),me(void 0,c);return}u=x;let k=o.pages.findIndex(C=>kt(o,C,c).some(N=>N.id in x));k>=0&&(f=k,p=void 0,m.length=0),F();return}if(s&&e.resolveFormId){g="submitting",P=void 0,F();try{a=await e.resolveFormId()}catch($){throw g="idle",P=na($,e.verboseResolutionErrors===!0,r),F(),$}}if(s&&a){let $=o.settings.responseLimit?.by==="browser"?Qs(zn(o,a,y.data)):void 0,x=$??he,k=o.settings.saveProgress?_??Ft(a):null,C=e.challengeRequired?e.getChallengeToken?.():void 0;if(e.challengeRequired&&!C){g="idle",P=r.challengeIncomplete,F();return}g="submitting",P=void 0,F();let N;try{N=await s.submit(a,y.data,{hp:e.getHoneypot?.()??"",elapsedMs:Date.now()-re,surface:e.surface??"headless",attribution:Ks(),submissionKey:x,draft:k?{id:k.id,token:k.token}:void 0,respondent:l,challengeToken:C})}catch(M){if(g="idle",ee(M)&&M.code==="challenge_failed"){P=r.challengeRetry,e.onChallengeFailed?.(),F();return}throw P=Bi(M,r),F(),M}if(!N.ok){u=N.errors??{};let M=o.pages.findIndex(ge=>kt(o,ge,c).some(jt=>jt.id in u));M>=0?f=M:P=r.reviewAnswers,g="idle",F();return}Te=N.duplicate?"duplicate":N.updated?"updated":"created",ae&&s.reportProgress(ae,{completed:!0}),$&&ea(zn(o,a,y.data),N.responseId),nr(),g="submitted",F(),me(N.responseId,y.data);return}if(e.skipValidation){g="submitted",F(),me(void 0,y.data);return}s&&!a?Xs():Ys(),g="error",F()}return{getState:()=>Y,subscribe(y){return W.add(y),()=>{W.delete(y)}},setValue:go,setUploading:bo,next:vo,skipPreviewPage:wo,back:yo,submit:ir,setContext(y){if("formId"in y&&(a=y.formId),"client"in y&&(s=y.client),"respondent"in y&&(l=y.respondent),y.respondentErrorStrings&&(r={...Jr,...y.respondentErrorStrings}),y.form&&y.form!==o){let $=Ne(y.form);if(!$.ok)throw new Error(`Invalid form schema: ${$.error}`);o=$.schema,c=De(o,c)}g==="idle"&&pi(o,a,c)&&(g="submitted",A=!0),Ut(),F()},flushDraft(){Bt(!0)},resetDraft(){if(g==="submitting")return;let y=_??(a?Ft(a):null);if(nr(),y&&s&&s.deleteDraft(y.id,y.token).catch(()=>{}),c={...e.initialData??{}},typeof location<"u"&&location.search){let $=Object.fromEntries(new URLSearchParams(location.search));for(let[x,k]of Object.entries(ci(o,$)))c[x]===void 0&&(c[x]=k)}c=De(o,c),u={},f=0,p=void 0,m.length=0,P=void 0,V=!1,ce=!1,F()},destroy(){Z&&(clearTimeout(Z),Z=null),W.clear()}}}function ra(e){return X(e)&&(e.kind==="select"||e.kind==="dropdown"||e.kind==="checkbox"||e.kind==="rating"||e.kind==="linear_scale")}function Vi(e){let t=e.filter(n=>X(n)&&n.kind!=="hidden"&&n.kind!=="calculated");return t.length!==1?!0:!ra(t[0])}function Hi(e,t,n){if(n.form.settings.submitMode!=="auto"||n.status!=="idle"||n.uploading||!(()=>{switch(e.kind){case"select":case"dropdown":return typeof t=="string"&&e.options.some(s=>s.id===t);case"checkbox":return t===!0;case"rating":case"linear_scale":return typeof t=="number";default:return!1}})()||t===n.data[e.id])return!1;let i={...n.data,[e.id]:t},o=n.form.pages.find(s=>s.blocks.some(l=>l.id===e.id));if(!o||!xn(n.form,o.id,i))return!1;let a=ki(n.form,i).filter(s=>s.kind!=="hidden"&&s.kind!=="calculated");return a.length!==1||a[0]?.id!==e.id?!1:Fi(n.form,i).ok}function Gi(e,t,n,r){if(n<=0)return null;let i=r?.rtl??!1;if(e==="Home")return 0;if(e==="End")return n-1;let o;switch(e){case"ArrowRight":o=i?-1:1;break;case"ArrowLeft":o=i?1:-1;break;case"ArrowDown":o=1;break;case"ArrowUp":o=-1;break;default:return null}let a=t+o;return Math.min(n-1,Math.max(0,a))}var ia=Math.sqrt(1.05*.05)-.05,oa=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i,sa=/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i;function bn(e){let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function aa(e){let t=e.trim(),n=null,r=oa.exec(t);if(r)n=`${r[1]}${r[2]}${r[3]}`;else{let s=sa.exec(t);s&&(n=`${s[1]}${s[1]}${s[2]}${s[2]}${s[3]}${s[3]}`)}if(!n)return null;let i=parseInt(n.slice(0,2),16),o=parseInt(n.slice(2,4),16),a=parseInt(n.slice(4,6),16);return .2126*bn(i)+.7152*bn(o)+.0722*bn(a)}function qi(e){if(!e||e.colorScheme==="light"||e.colorScheme==="dark"||!e.background)return e;let t=aa(e.background);return t==null?e:{...e,colorScheme:t>ia?"light":"dark"}}function jn(e){return{id:e.id,theme:e.theme,schema:{version:1,title:e.title??"",description:e.description,pages:e.pages,settings:e.settings??{}},__filloCodeForm:!0}}function Vn(e){return typeof e=="object"&&e!==null&&"__filloCodeForm"in e}var Se=new Map,la=e=>new Promise(t=>setTimeout(t,e));function ca(e){if(!ee(e))return!0;let t=e.status??0;return t===0||t===408||t===429||t>=500}async function ua(e,t){let n=800;for(let r=0;;r++)try{return await e.syncForm(t.id,t.schema,t.theme??null)}catch(i){if(!ca(i)||r>=2)throw i;let o=ee(i)?i.retryAfterSec:void 0;await la(Math.min(o?o*1e3:n*(1+Math.random()*.5),15e3)),n*=2}}function da(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)|0;return(t>>>0).toString(36)}function Wi(e,t){let n=r=>{if(Array.isArray(r))return r.map(n);if(r&&typeof r=="object"){let i=r;return Object.fromEntries(Object.keys(i).sort().map(o=>[o,n(i[o])]))}return r};return JSON.stringify(n(e))===JSON.stringify(n(t))}var En=e=>e==="published"?36e5:6e4,pa=e=>!!(e.staged||e.resolvedSchema||e.syncError||e.accepting===!1||e.uploadsAvailable===!1);function Ki(e,t){return`fillo:sync:v5:${e.baseUrl}|${e.key}|${t}`}function fa(e,t,n){try{let r=globalThis.localStorage?.getItem(Ki(e,t));if(!r)return null;let i=JSON.parse(r);if(typeof i.formId!="string"||typeof i.slug!="string"||i.hash!==n||typeof i.ts!="number"||i.uploadFileSizeLimitMb!==void 0&&(typeof i.uploadFileSizeLimitMb!="number"||!Number.isFinite(i.uploadFileSizeLimitMb)||i.uploadFileSizeLimitMb<=0)||i.manageUrl!==void 0&&typeof i.manageUrl!="string"||i.status!==void 0&&i.status!=="draft"&&i.status!=="published")return null;let o=En(i.status);return Date.now()-i.ts>o?null:i}catch{return null}}function ha(e,t,n,r){if(!(r.staged||r.resolvedSchema||r.syncError||r.accepting===!1)&&!r.challenge)try{globalThis.localStorage?.setItem(Ki(e,t),JSON.stringify({formId:r.formId,slug:r.slug,manageUrl:r.manageUrl,status:r.status,uploadFileSizeLimitMb:r.uploadFileSizeLimitMb,hash:n,ts:Date.now()}))}catch{}}function Hn(e,t,n){let r=JSON.stringify(t.schema)+JSON.stringify(t.theme??null),i=da(r),o=`${e.baseUrl}:${e.key}:${t.id}:${i}`,a=ye(t.schema).some(u=>u.kind==="file_upload"),s=Se.get(o);if(s&&!n?.bypassCache){if(s.expiresAt===null||!a&&s.expiresAt>Date.now())return s.promise;Se.delete(o)}if(!n?.bypassCache&&!a){let u=fa(e,t.id,i);if(u){let f=Promise.resolve({formId:u.formId,slug:u.slug,manageUrl:u.manageUrl,status:u.status,uploadFileSizeLimitMb:u.uploadFileSizeLimitMb});return Se.set(o,{promise:f,expiresAt:u.ts+En(u.status)}),f}}let l=ua(e,t),c={promise:l,expiresAt:null};return Se.set(o,c),l.then(u=>{if(Se.get(o)===c){if(a||pa(u)){Se.delete(o);return}c.expiresAt=Date.now()+En(u.status),ha(e,t.id,i,u)}},()=>{Se.get(o)===c&&Se.delete(o)}),l}var ma=class extends Error{constructor(e,t){super(`[fillo] ${t} \u2014 https://fillo.so/docs/troubleshooting#jsx-${e.toLowerCase()}`),this.code=e,this.name="FilloJsxError"}code},ga=Symbol.for("fillo.block");var ba=["label","description","required","placeholder"],D=(e,t,n,r={})=>({name:e,kind:t,props:[...ba,...n],...r}),fi=(e,t,n)=>({name:e,kind:t,props:n?["text"]:[],textChildren:n,content:!0}),vn=["options","allowOther","shuffleOptions"],va=[D("Text","short_text",["maxLength"]),D("LongText","long_text",["maxLength"]),D("Email","email",["maxLength"]),D("Url","url",["maxLength"]),D("Phone","phone",["defaultCountry"]),D("Number","number",["min","max","decimals","prefix","suffix","notation"]),D("Select","select",vn,{optionChildren:!0}),D("MultiSelect","multi_select",vn,{optionChildren:!0}),D("Dropdown","dropdown",vn,{optionChildren:!0}),D("Checkbox","checkbox",["appearance"]),D("Rating","rating",["max","insightsMetric"]),D("Scale","linear_scale",["min","max","minLabel","maxLabel","insightsMetric"]),D("Ranking","ranking",["options"],{optionChildren:!0}),D("Matrix","matrix",["rows","columns"]),D("Signature","signature",[]),D("Date","date",[]),D("FileUpload","file_upload",["maxFiles","maxFileSizeMb","accept"]),D("Hidden","hidden",["paramName","defaultValue"]),D("Calculated","calculated",["calc","decimals","prefix","suffix"]),D("RepeatingGroup","repeating_group",["minInstances","maxInstances","addLabel","itemLabel"],{blockChildren:!0}),D("Custom","custom",["component","config"]),fi("Heading","heading",!0),fi("Paragraph","paragraph",!0),{name:"Divider",kind:"divider",props:[],content:!0}],ya={name:"Page",kind:"__page",props:["title"]},wa={name:"Option",kind:"__option",props:["label","icon"]};function yn(e){let t=()=>{throw new ma("RENDERED_INERT",`<Fillo.${e.name}> was rendered by React. Fillo fields are schema declarations, valid only inside <Fillo.Form> or Fillo.defineForm(). If this form lives in a server component, move it to a client module ("use client")`)};return t[ga]=e,t}var ep=Object.fromEntries([...va.map(e=>[e.name,yn(e)]),["Page",yn(ya)],["Option",yn(wa)]]);function _a(e){let t=e.toLowerCase();return t==="localhost"||t.endsWith(".localhost")||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)||t==="::1"||t==="[::1]"||t==="0.0.0.0"}function Gn(){return typeof process<"u"&&process.env?.NODE_ENV!=="production"}function Ji(){if(Gn())return!0;if(typeof window>"u")return!1;let e=window.location?.hostname;return typeof e=="string"&&_a(e)}var xa=/\{\{\s*([\w-]+)\s*\}\}/g;function wn(e,t,n){if(!e.includes("{{"))return e;let r=ye(n);return e.replace(xa,(i,o)=>{let a=r.find(c=>c.id===o),s=t[o];if(s==null||s==="")return"";let l=c=>a&&"options"in a?a.options.find(u=>u.id===c)?.label??c:c;return Array.isArray(s)?s.map(c=>l(String(c))).join(", "):typeof s=="string"?l(s):String(s)})}function Xi(e,t,n){let r=i=>i===void 0?i:wn(i,t,n);switch(e.kind){case"heading":case"paragraph":return{...e,text:wn(e.text,t,n)};case"divider":return e;default:return{...e,label:wn(e.label,t,n),description:r(e.description)}}}var ka="fillo-",$a=0,ht='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function Sa(e){return e.matches(ht)?e:e.querySelector(ht)}function Aa(e){return Array.from(e.querySelectorAll(ht)).find(n=>!n.closest(".fillo-group-instance-header"))??null}function ao(e,t){let n=`${ka}${e}-${t}`;return{inputId:n,labelId:`${n}-label`,descriptionId:`${n}-desc`,errorId:`${n}-error`,name:n}}function d(e,t={}){let n=document.createElement(e);t.className&&(n.className=t.className),t.text!==void 0&&(n.textContent=t.text);for(let[r,i]of Object.entries(t.attrs??{}))n.setAttribute(r,i);return n}function He(e,t){let n=qi(Mn(t));n&&(n.colorScheme&&e.setAttribute("data-fillo-color-scheme",n.colorScheme),n.primary&&e.style.setProperty("--fillo-primary",n.primary),n.background&&e.style.setProperty("--fillo-bg",n.background),n.text&&e.style.setProperty("--fillo-text",n.text),n.radius&&e.style.setProperty("--fillo-radius",n.radius),n.fontFamily&&e.style.setProperty("--fillo-font",n.fontFamily),(n.primary||n.background||n.text)&&e.setAttribute("data-fillo-has-color-theme",""))}function Me(e){try{if(!e)return null;let t=new URL(e);return t.protocol!=="http:"&&t.protocol!=="https:"?null:t.toString()}catch{return null}}function za(e){let t=new URL(Me(e)??"https://fillo.so");return t.searchParams.set("utm_source","form_badge"),t.toString()}function Rt(e){return typeof e=="string"||typeof e=="number"?String(e):""}function Yi(e,t,n){let r=Rt(e);if(r==="")return r;let i=Number(r);return Number.isFinite(i)?Mi(i,{locale:n,decimals:t}):r}function I(e,t){for(let n of t)n&&e.appendChild(n);return e}var Ot="http://www.w3.org/2000/svg",Ea={thumbs_up:"M7 10v10M7 10l4.8-6.1a2 2 0 0 1 3.5 1.7L14.6 10h4.8a2.1 2.1 0 0 1 2 2.5l-1.1 5.4A3 3 0 0 1 17.4 20H7M3 10h4v10H3z",thumbs_down:"M7 14V4M7 14l4.8 6.1a2 2 0 0 0 3.5-1.7L14.6 14h4.8a2.1 2.1 0 0 0 2-2.5l-1.1-5.4A3 3 0 0 0 17.4 4H7M3 4h4v10H3z"};function lo(e){if(!e)return null;let t=document.createElementNS(Ot,"svg");t.setAttribute("class","fillo-option-icon"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.8"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("aria-hidden","true");let n=document.createElementNS(Ot,"path");return n.setAttribute("d",Ea[e]),t.appendChild(n),t}function co(){let e=document.createElementNS(Ot,"svg");e.setAttribute("class","fillo-option-check"),e.setAttribute("width","1em"),e.setAttribute("height","1em"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","2"),e.setAttribute("stroke-linecap","square"),e.setAttribute("stroke-linejoin","miter"),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false");let t=document.createElementNS(Ot,"path");return t.setAttribute("d","M4 12l5 5L20 6"),e.appendChild(t),e}function q(e,t,n,r,i={}){n&&e.setAttribute("aria-invalid","true"),(i.requiredSupported??!0)&&t.required&&e.setAttribute("aria-required","true");let o=[t.description?r.descriptionId:null,n?r.errorId:null].filter(Boolean).join(" ");o&&e.setAttribute("aria-describedby",o)}function uo(e,t,n,r){e.addEventListener("keydown",i=>{let o=getComputedStyle(e).direction==="rtl",a=n===null?-1:t.indexOf(n),s=Gi(i.key,a,t.length,{rtl:o});if(s===null)return;i.preventDefault();let l=t[s];l!==void 0&&(r(l),e.querySelectorAll('[role="radio"]')[s]?.focus())})}function te(e,t,n,r){let i=d("div",{className:`fillo-field fillo-field--${e.kind}${t?" fillo-field--error":""}`,attrs:{"data-fillo":"field","data-field":e.id,"data-kind":e.kind}});i.toggleAttribute("data-invalid",!!t),i.toggleAttribute("data-required",!!e.required);let o=d("label",{className:"fillo-label",text:e.label,attrs:{id:r.labelId,for:r.inputId,"data-fillo":"label"}});return!e.required&&!(e.kind==="repeating_group"&&(e.minInstances??1)>0)&&o.appendChild(d("span",{className:"fillo-optional",text:" (optional)"})),i.appendChild(o),e.description&&i.appendChild(d("p",{className:"fillo-description",text:e.description,attrs:{id:r.descriptionId,"data-fillo":"fieldDescription"}})),i.appendChild(n),t&&i.appendChild(d("p",{className:"fillo-error",text:t,attrs:{id:r.errorId,"data-fillo":"error"}})),i}function ut(e,t){let n=t.field,r=n.kind==="number"?n:void 0,i=r?.notation!==void 0,o=Li(r?.notation),a=i||!!r?.prefix||!!r?.suffix,s=d("input",{className:"fillo-input",attrs:{id:t.ids.inputId,type:a?"text":e,"data-fillo":"control"}});if(a&&s.setAttribute("inputmode","decimal"),e==="email"?s.setAttribute("autocomplete","email"):e==="url"&&s.setAttribute("autocomplete","url"),s.value=i?Yi(t.value,r?.decimals,o):Rt(t.value),n.placeholder&&(s.placeholder=n.placeholder),"maxLength"in n&&n.maxLength!==void 0&&(s.maxLength=n.maxLength),r&&!a&&(r.min!==void 0&&(s.min=String(r.min)),r.max!==void 0&&(s.max=String(r.max))),a){let c=s.value,u=s.value.length,f=()=>{s.value=c,s.setSelectionRange(u,u)};i?(s.addEventListener("input",()=>{if(!ct(s.value,o))return f();c=s.value,u=s.selectionStart??s.value.length,t.setValue(Pn(s.value,o),{render:!1})}),s.addEventListener("change",()=>{if(!ct(s.value,o))return f();c=s.value,t.setValue(Pn(s.value,o))}),s.addEventListener("blur",()=>{let p=t.getValue?.()??t.value;s.value=Yi(p,r?.decimals,o),c=s.value,u=s.value.length})):(s.addEventListener("input",()=>{if(!ct(s.value,o))return f();c=s.value,u=s.selectionStart??s.value.length,t.setValue(s.value,{render:!1})}),s.addEventListener("change",()=>{if(!ct(s.value,o))return f();c=s.value,t.setValue(s.value)}))}else s.addEventListener("input",()=>t.setValue(s.value,{render:!1})),s.addEventListener("change",()=>t.setValue(s.value));q(s,n,t.error,t.ids);let l=s;return r&&(r.prefix||r.suffix)&&(l=I(d("div",{className:"fillo-number"}),[r.prefix?d("span",{className:"fillo-number-prefix",text:r.prefix}):null,s,r.suffix?d("span",{className:"fillo-number-suffix",text:r.suffix}):null])),te(n,t.error,l,t.ids)}function Fa(){if(typeof navigator>"u")return;let t=(navigator.languages?.[0]||navigator.language||"").split("-")[1];return t&&/^[A-Za-z]{2}$/.test(t)?t.toUpperCase():void 0}function Ca(){if(!(typeof Intl>"u"))try{let e=Intl.DateTimeFormat().resolvedOptions().timeZone;return typeof e=="string"&&e?e:void 0}catch{return}}function Ia(e,t){if(t<=0)return e.setSelectionRange(0,0);let n=e.value,r=0,i=n.length;for(let o=0;o<n.length;o++)if(/\d/.test(n[o])&&++r===t){i=o+1;break}e.setSelectionRange(i,i)}function Na(e){let t=e.field,n=at(Rt(e.value)).country??Lt(t.defaultCountry)??Si(Ca())??Lt(Fa())??ot[0],r=d("div",{className:"fillo-phone"}),i=d("div",{className:"fillo-phone-country"}),o=d("button",{className:"fillo-phone-flag",attrs:{type:"button","aria-haspopup":"listbox","aria-expanded":"false"}}),a=d("span",{className:"fillo-phone-flag-emoji",attrs:{"aria-hidden":"true"}}),s=d("span",{className:"fillo-phone-dial"});I(o,[a,s,d("span",{className:"fillo-phone-caret",text:"\u25BE",attrs:{"aria-hidden":"true"}})]),I(i,[o]);let l=d("input",{className:"fillo-input fillo-phone-input",attrs:{id:e.ids.inputId,type:"tel",inputmode:"tel",autocomplete:"tel-national","data-fillo":"control"}});q(l,e.field,e.error,e.ids);let c=()=>e.getValue?.()??e.value,u=()=>{let _=fe(Rt(c()));return _.startsWith(n.dialCode)?_.slice(n.dialCode.length):_},f=()=>{a.textContent=In(n.iso2),s.textContent=`+${n.dialCode}`,o.setAttribute("aria-label",`Country: ${n.name} (+${n.dialCode})`)},p=()=>{l.value=st(n,u()),l.placeholder=st(n,n.example)},m=_=>e.setValue(_?Ai(n,_):"",{render:!1}),h=_=>e.setValue(_,{render:!1});f(),p(),l.addEventListener("input",()=>{let _=l.value,Z=l.selectionStart??_.length,j=fe(_.slice(0,Z)).length;if(_.trimStart().startsWith("+")){let U=at(_,n,{previousDigits:u()});if(U.pending){h(U.raw??_);return}U.country&&(n=U.country,f()),m(U.country?U.national:fe(_))}else m(fe(_));l.value=st(n,u()),Ia(l,j)});let v=e.registerOverlay,b=e.announce,g=null,A=0,z=Ve,P=null,ne=null,W,re=`${e.ids.inputId}-countries`,he=()=>{if(!g)return;let _=zi(i,g);g.classList.toggle("fillo-phone-popover--above",_==="above"),g.classList.toggle("fillo-phone-popover--below",_==="below")},ae=()=>{P?.();let _=()=>he();he(),window.addEventListener("resize",_),window.addEventListener("scroll",_,!0),P=()=>{window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0)}},le=_=>{let Z=_.relatedTarget;if(Z){i.contains(Z)||V();return}queueMicrotask(()=>{g&&!i.contains(document.activeElement)&&V()})},V=()=>{clearTimeout(W),P?.(),P=null,g?.remove(),g=null,o.setAttribute("aria-expanded","false"),o.removeAttribute("aria-controls"),document.removeEventListener("mousedown",ce),i.removeEventListener("focusout",le),ne?.(),ne=null},ce=_=>{i.contains(_.target)||V()},Te=_=>{_&&(n=_,f(),m(u()),p(),V(),b?.(T.phoneCountrySelected(_.name)),l.focus())},Pe=_=>{let Z=d("div",{className:"fillo-phone-popover fillo-phone-popover--below"}),j=d("input",{className:"fillo-phone-search",attrs:{type:"text",role:"combobox","aria-expanded":"true","aria-controls":re,"aria-autocomplete":"list","aria-label":"Search country or code",placeholder:"Search country or code"}});_&&(j.value=_);let U=d("ul",{className:"fillo-phone-list",attrs:{role:"listbox",id:re,"aria-label":"Country"}}),qe=()=>{if(U.replaceChildren(),z.length===0){U.appendChild(d("li",{className:"fillo-phone-empty",text:"No matches",attrs:{role:"option","aria-disabled":"true"}})),j.removeAttribute("aria-activedescendant"),he();return}z.forEach((R,Y)=>{let F=d("li",{className:`fillo-phone-option${Y===A?" fillo-phone-option--active":""}`,attrs:{id:`${re}-opt-${Y}`,role:"option","aria-selected":String(R.iso2===n.iso2)}});I(F,[d("span",{className:"fillo-phone-flag-emoji",text:In(R.iso2),attrs:{"aria-hidden":"true"}}),d("span",{className:"fillo-phone-option-name",text:R.name}),d("span",{className:"fillo-phone-option-dial",text:`+${R.dialCode}`})]),F.addEventListener("mouseenter",()=>{A=Y,j.setAttribute("aria-activedescendant",F.id),Ee()}),F.addEventListener("mousedown",me=>{me.preventDefault(),Te(R)}),U.appendChild(F)}),j.setAttribute("aria-activedescendant",`${re}-opt-${A}`),he()},Ee=()=>{[...U.children].forEach((R,Y)=>R.classList.toggle("fillo-phone-option--active",Y===A)),document.getElementById(`${re}-opt-${A}`)?.scrollIntoView({block:"nearest"})},Re=R=>{let Y=R.trim().toLowerCase(),F=Y.replace(/[^\d]/g,"");z=Y?Ve.filter(me=>me.name.toLowerCase().includes(Y)||me.iso2.toLowerCase()===Y||F.length>0&&me.dialCode.startsWith(F)):Ve,A=0,qe(),clearTimeout(W),W=setTimeout(()=>b?.(T.phoneResultsCount(z.length)),300)};j.addEventListener("input",()=>Re(j.value)),j.addEventListener("keydown",R=>{if(R.key==="ArrowDown"){if(R.preventDefault(),z.length===0)return;A=Math.min(A+1,z.length-1),Ee(),j.setAttribute("aria-activedescendant",`${re}-opt-${A}`)}else if(R.key==="ArrowUp"){if(R.preventDefault(),z.length===0)return;A=Math.max(A-1,0),Ee(),j.setAttribute("aria-activedescendant",`${re}-opt-${A}`)}else R.key==="Enter"?(R.preventDefault(),Te(z[A])):R.key==="Escape"&&(R.preventDefault(),V(),o.focus())}),I(Z,[j,U]),g=Z,i.appendChild(Z),o.setAttribute("aria-expanded","true"),o.setAttribute("aria-controls",re),_?Re(_):(z=Ve,A=Math.max(0,Ve.indexOf(n)),qe()),ae(),Ee(),document.addEventListener("mousedown",ce),i.addEventListener("focusout",le),ne=v?.(V)??null,requestAnimationFrame(()=>{if(j.focus(),_){let R=j.value.length;j.setSelectionRange(R,R)}})};return o.addEventListener("click",()=>g?V():Pe()),o.addEventListener("keydown",_=>{if(!g){if(_.key==="ArrowDown"||_.key==="ArrowUp"){_.preventDefault(),Pe();return}_.key.length===1&&_.key!==" "&&!_.ctrlKey&&!_.metaKey&&!_.altKey&&(_.preventDefault(),Pe(_.key))}}),I(r,[i,l]),te(e.field,e.error,r,e.ids)}function La(e){let t=d("textarea",{className:"fillo-input fillo-textarea",attrs:{id:e.ids.inputId,rows:"4","data-fillo":"control"}});return t.value=typeof e.value=="string"?e.value:"",e.field.placeholder&&(t.placeholder=e.field.placeholder),"maxLength"in e.field&&e.field.maxLength!==void 0&&(t.maxLength=e.field.maxLength),t.addEventListener("input",()=>e.setValue(t.value,{render:!1})),t.addEventListener("change",()=>e.setValue(t.value)),q(t,e.field,e.error,e.ids),te(e.field,e.error,t,e.ids)}function Ma(e){let t=e.field,n=Xn(t),r=typeof e.value=="string"?e.value:"",i=e.activeOtherFields,o=r!==""&&!t.options.some(l=>l.id===r),a=o||r===""&&i?.has(t.id)===!0,s=d("div",{className:"fillo-options",attrs:{role:"radiogroup","aria-labelledby":e.ids.labelId,"data-fillo":"options"}});q(s,t,e.error,e.ids);for(let l of n){let c=d("label",{className:`fillo-option${l.icon?" fillo-option--has-icon":""}${r===l.id?" fillo-option--selected":""}`,attrs:{"data-option":l.id,"data-fillo":"option"}});c.toggleAttribute("data-selected",r===l.id);let u=d("input",{className:"fillo-option-input",attrs:{type:"radio",name:e.ids.name}});u.checked=r===l.id,u.addEventListener("change",()=>{i?.delete(t.id),e.setValue(l.id)}),I(c,[u,lo(l.icon),d("span",{className:"fillo-option-label",text:l.label,attrs:{"data-fillo":"optionLabel"}}),l.icon&&r===l.id?co():null]),s.appendChild(c)}if(t.allowOther){let l=d("label",{className:`fillo-option fillo-option--other${a?" fillo-option--selected fillo-option--with-other":""}`,attrs:{"data-fillo":"option"}});l.toggleAttribute("data-selected",a);let c=d("input",{className:"fillo-option-input",attrs:{type:"radio",name:e.ids.name}});if(c.checked=a,c.addEventListener("change",()=>{i?.add(t.id),e.setValue("",{render:!0})}),I(l,[I(d("span",{className:"fillo-option-main"}),[c,d("span",{className:"fillo-option-label",text:L.other,attrs:{"data-fillo":"optionLabel"}})])]),a){let u=d("input",{className:"fillo-input fillo-other-input",attrs:{type:"text","aria-label":L.otherPrompt}});u.value=o?r:"",u.placeholder=L.otherPlaceholder,u.addEventListener("input",()=>{i?.add(t.id),e.setValue(u.value,{render:!1})}),u.addEventListener("change",()=>{i?.add(t.id),e.setValue(u.value)}),l.appendChild(u),o||queueMicrotask(()=>u.focus())}s.appendChild(l)}return te(t,e.error,s,e.ids)}function Ta(e){let t=e.field,n=Xn(t),r=Array.isArray(e.value)?e.value:[],i=new Set(t.options.map(u=>u.id)),o=r.find(u=>!i.has(u)),a=e.activeOtherFields,s=()=>{let u=e.getValue?.()??e.value;return Array.isArray(u)?u:[]},l=d("div",{className:"fillo-options",attrs:{role:"group","aria-labelledby":e.ids.labelId,"data-fillo":"options"}});q(l,t,e.error,e.ids,{requiredSupported:!1});let c=u=>e.setValue(u);for(let u of n){let f=d("label",{className:`fillo-option${u.icon?" fillo-option--has-icon":""}${r.includes(u.id)?" fillo-option--selected":""}`,attrs:{"data-option":u.id,"data-fillo":"option"}});f.toggleAttribute("data-selected",r.includes(u.id));let p=d("input",{className:"fillo-option-input",attrs:{type:"checkbox"}});p.checked=r.includes(u.id),p.addEventListener("change",()=>{let m=s();c(p.checked?[...m,u.id]:m.filter(h=>h!==u.id))}),I(f,[p,lo(u.icon),d("span",{className:"fillo-option-label",text:u.label,attrs:{"data-fillo":"optionLabel"}}),u.icon&&r.includes(u.id)?co():null]),l.appendChild(f)}if(t.allowOther){let u=o!==void 0||a?.has(t.id)===!0,f=d("label",{className:`fillo-option fillo-option--other${u?" fillo-option--selected fillo-option--with-other":""}`,attrs:{"data-fillo":"option"}});f.toggleAttribute("data-selected",u);let p=d("input",{className:"fillo-option-input",attrs:{type:"checkbox"}});if(p.checked=u,p.addEventListener("change",()=>{let m=s().filter(h=>i.has(h));p.checked?(a?.add(t.id),c(m)):(a?.delete(t.id),c(m))}),I(f,[I(d("span",{className:"fillo-option-main"}),[p,d("span",{className:"fillo-option-label",text:L.other,attrs:{"data-fillo":"optionLabel"}})])]),u){let m=d("input",{className:"fillo-input fillo-other-input",attrs:{type:"text","aria-label":L.otherPrompt}});m.value=o??"",m.placeholder=L.otherPlaceholder,m.addEventListener("input",()=>{a?.add(t.id);let h=s().filter(v=>i.has(v));e.setValue(m.value?[...h,m.value]:h,{render:!1})}),m.addEventListener("change",()=>{a?.add(t.id);let h=s().filter(v=>i.has(v));e.setValue(m.value?[...h,m.value]:h)}),f.appendChild(m),o===void 0&&queueMicrotask(()=>m.focus())}l.appendChild(f)}return te(t,e.error,l,e.ids)}function Pa(e){let t="__fillo_other__",n=new Set(e.options.map(r=>r.id));for(;n.has(t);)t+="_";return t}function Ra(e){let t=e.field,n=typeof e.value=="string"?e.value:"",r=Pa(t),i=e.activeOtherFields,o=n!==""&&!t.options.some(u=>u.id===n),a=o||n===""&&i?.has(t.id)===!0,s=d("div"),l=d("div",{className:"fillo-select-wrap"}),c=d("select",{className:"fillo-input fillo-select",attrs:{id:e.ids.inputId,"data-fillo":"control"}});c.appendChild(d("option",{text:t.placeholder??"Choose...",attrs:{value:""}}));for(let u of Xn(t))c.appendChild(d("option",{text:u.label,attrs:{value:u.id}}));if(t.allowOther&&c.appendChild(d("option",{text:`${L.other}\u2026`,attrs:{value:r}})),c.value=a?r:n,c.addEventListener("change",()=>{c.value===r?(i?.add(t.id),e.setValue("",{render:!0})):(i?.delete(t.id),e.setValue(c.value||null))}),q(c,t,e.error,e.ids),I(l,[c,d("span",{className:"fillo-select-icon",attrs:{"aria-hidden":"true"}})]),s.appendChild(l),a){let u=d("input",{className:"fillo-input fillo-other-input fillo-other-input--block",attrs:{type:"text","aria-label":L.otherPrompt}});u.value=o?n:"",u.placeholder=L.otherPlaceholder,u.addEventListener("input",()=>{i?.add(t.id),e.setValue(u.value,{render:!1})}),u.addEventListener("change",()=>{i?.add(t.id),e.setValue(u.value)}),s.appendChild(u),o||queueMicrotask(()=>u.focus())}return te(t,e.error,s,e.ids)}function Oa(e){if(e.field.kind==="checkbox"&&e.field.appearance==="toggle"){let o=d("div",{className:`fillo-field fillo-field--checkbox fillo-field--toggle${e.error?" fillo-field--error":""}`,attrs:{"data-fillo":"field","data-field":e.field.id,"data-kind":e.field.kind}});o.toggleAttribute("data-invalid",!!e.error),o.toggleAttribute("data-required",!!e.field.required);let a=d("label",{className:"fillo-toggle",attrs:{"data-fillo":"option"}});a.toggleAttribute("data-checked",e.value===!0);let s=d("span",{className:"fillo-option-label",text:e.field.label,attrs:{"data-fillo":"optionLabel"}});e.field.required||s.appendChild(d("span",{className:"fillo-optional",text:" (optional)"}));let l=d("span",{className:"fillo-toggle-copy"});l.appendChild(s);let c=d("input",{className:"fillo-toggle-input",attrs:{id:e.ids.inputId,type:"checkbox"}});return c.checked=e.value===!0,c.addEventListener("change",()=>{e.setValue(c.checked)}),q(c,e.field,e.error,e.ids),I(a,[l,c,I(d("span",{className:"fillo-toggle-track",attrs:{"aria-hidden":"true"}}),[d("span",{className:"fillo-toggle-thumb"})])]),o.appendChild(a),e.field.description&&o.appendChild(d("p",{className:"fillo-description",text:e.field.description,attrs:{id:e.ids.descriptionId,"data-fillo":"fieldDescription"}})),e.error&&o.appendChild(d("p",{className:"fillo-error",text:e.error,attrs:{id:e.ids.errorId,"data-fillo":"error"}})),o}let t=d("div",{className:`fillo-field fillo-field--checkbox${e.error?" fillo-field--error":""}`,attrs:{"data-fillo":"field","data-field":e.field.id,"data-kind":e.field.kind}});t.toggleAttribute("data-invalid",!!e.error),t.toggleAttribute("data-required",!!e.field.required);let n=d("label",{className:"fillo-option",attrs:{"data-fillo":"option"}});n.toggleAttribute("data-checked",e.value===!0);let r=d("input",{className:"fillo-option-input",attrs:{id:e.ids.inputId,type:"checkbox"}});r.checked=e.value===!0,r.addEventListener("change",()=>e.setValue(r.checked)),q(r,e.field,e.error,e.ids);let i=d("span",{className:"fillo-option-label",text:e.field.label,attrs:{"data-fillo":"optionLabel"}});return e.field.required||i.appendChild(d("span",{className:"fillo-optional",text:" (optional)"})),I(n,[r,i]),t.appendChild(n),e.field.description&&t.appendChild(d("p",{className:"fillo-description",text:e.field.description,attrs:{id:e.ids.descriptionId,"data-fillo":"fieldDescription"}})),e.error&&t.appendChild(d("p",{className:"fillo-error",text:e.error,attrs:{id:e.ids.errorId,"data-fillo":"error"}})),t}function Za(e){if(e.field.kind!=="rating")return d("div");let t=typeof e.field.max=="number"?e.field.max:5,n=typeof e.value=="number"?e.value:0,r=Array.from({length:t},(s,l)=>l+1),i=n>0?n:null,o=i===null?0:Math.max(0,r.indexOf(i)),a=d("div",{className:"fillo-rating",attrs:{id:e.ids.inputId,role:"radiogroup","aria-labelledby":e.ids.labelId,"data-fillo":"control"}});q(a,e.field,e.error,e.ids);for(let[s,l]of r.entries()){let c=d("button",{className:`fillo-star${l<=n?" fillo-star--active":""}`,text:l<=n?"\u2605":"\u2606",attrs:{type:"button",role:"radio","aria-label":`${l} of ${t}`,"aria-checked":String(l===n),tabindex:String(s===o?0:-1),"data-fillo":"option"}});c.toggleAttribute("data-selected",l<=n),c.addEventListener("click",u=>{u.detail===0&&l===n||e.setValue(l===n?null:l)}),a.appendChild(c)}return uo(a,r,i,s=>e.setValue(s)),te(e.field,e.error,a,e.ids)}function Da(e){if(e.field.kind!=="linear_scale")return d("div");let t=typeof e.field.min=="number"?e.field.min:1,n=typeof e.field.max=="number"?e.field.max:10,r=typeof e.value=="number"?e.value:null,i=Array.from({length:n-t+1},(f,p)=>t+p),o=r===null?0:Math.max(0,i.indexOf(r)),a=`${e.ids.inputId}-min`,s=`${e.ids.inputId}-max`,l=d("div"),c=d("div",{className:"fillo-scale",attrs:{id:e.ids.inputId,role:"radiogroup","aria-labelledby":e.ids.labelId,"data-fillo":"control"}});q(c,e.field,e.error,e.ids);let u=[e.field.minLabel?a:null,e.field.maxLabel?s:null,c.getAttribute("aria-describedby")].filter(Boolean).join(" ");u&&c.setAttribute("aria-describedby",u);for(let[f,p]of i.entries()){let m=d("button",{className:`fillo-scale-step${e.value===p?" fillo-scale-step--active":""}`,text:String(p),attrs:{type:"button",role:"radio","aria-label":String(p),"aria-checked":String(e.value===p),tabindex:String(f===o?0:-1),"data-fillo":"option"}});m.toggleAttribute("data-selected",e.value===p),m.addEventListener("click",h=>{h.detail===0&&e.value===p||e.setValue(e.value===p?null:p)}),c.appendChild(m)}return uo(c,i,r,f=>e.setValue(f)),l.appendChild(c),("minLabel"in e.field||"maxLabel"in e.field)&&I(l,[I(d("div",{className:"fillo-scale-labels"}),[d("span",{text:String(e.field.minLabel??""),attrs:{id:a}}),d("span",{text:String(e.field.maxLabel??""),attrs:{id:s}})])]),te(e.field,e.error,l,e.ids)}function Ua(e){let t=e.field;if(t.kind!=="ranking")return null;let n=e.announce,r=Array.isArray(e.value)?e.value:[],i=[...r.filter(s=>t.options.some(l=>l.id===s)),...t.options.map(s=>s.id).filter(s=>!r.includes(s))],o=d("div",{attrs:{id:e.ids.inputId,role:"group","aria-labelledby":e.ids.labelId,"data-fillo":"control"}});q(o,e.field,e.error,e.ids,{requiredSupported:!1});let a=d("ol",{className:"fillo-ranking"});for(let[s,l]of i.entries()){let c=t.options.find(v=>v.id===l);if(!c)continue;let u=d("li",{className:"fillo-ranking-item"}),f=d("span",{className:"fillo-ranking-controls"}),p=v=>{let b=s+v;if(b<0||b>=i.length)return;let g=[...i];[g[s],g[b]]=[g[b],g[s]],e.setValue(g),n?.(T.rankingPosition(c.label,b+1,i.length))},m=d("button",{className:"fillo-ranking-move",text:"\u2191",attrs:{type:"button","data-fillo-rank-opt":l,"data-fillo-rank-dir":"up","aria-label":`Move ${c.label} up`}});m.toggleAttribute("disabled",s===0),m.addEventListener("click",()=>p(-1));let h=d("button",{className:"fillo-ranking-move",text:"\u2193",attrs:{type:"button","data-fillo-rank-opt":l,"data-fillo-rank-dir":"down","aria-label":`Move ${c.label} down`}});h.toggleAttribute("disabled",s===i.length-1),h.addEventListener("click",()=>p(1)),I(f,[m,h]),I(u,[d("span",{className:"fillo-ranking-index",text:String(s+1)}),d("span",{className:"fillo-ranking-label",text:c.label}),f]),a.appendChild(u)}return o.appendChild(a),te(e.field,e.error,o,e.ids)}function Ba(e){let t=e.field;if(t.kind!=="matrix")return null;let n=e.value&&typeof e.value=="object"&&!Array.isArray(e.value)?e.value:{},r=d("table",{className:"fillo-matrix"}),i=document.createElement("thead"),o=document.createElement("tr");o.appendChild(document.createElement("td"));for(let l of t.columns)o.appendChild(d("th",{text:l.label,attrs:{scope:"col"}}));i.appendChild(o),r.appendChild(i);let a=document.createElement("tbody");for(let l of t.rows){let c=`${e.ids.inputId}-${l.id}`,u=n[l.id]!==void 0,f=!!e.error&&!!t.required&&!u,p=b=>`${e.ids.inputId}-${l.id}-${b.id}`,m=document.createElement("tr"),h=d("th",{attrs:{scope:"row"}}),v=d("div",{attrs:{role:"radiogroup","aria-labelledby":`${e.ids.labelId} ${c}`,"aria-owns":t.columns.map(p).join(" ")}});v.appendChild(d("span",{text:l.label,attrs:{id:c}})),h.appendChild(v),m.appendChild(h);for(let b of t.columns){let g=d("td",{attrs:{"data-label":b.label}}),A=d("label",{className:"fillo-matrix-cell"}),z=d("input",{className:"fillo-option-input",attrs:{id:p(b),type:"radio",name:`${e.ids.name}-${l.id}`,"aria-label":`${l.label}: ${b.label}`}});t.required&&z.setAttribute("aria-required","true"),f&&z.setAttribute("aria-invalid","true"),z.checked=n[l.id]===b.id,z.addEventListener("change",()=>e.setValue({...n,[l.id]:b.id})),A.appendChild(z),g.appendChild(A),m.appendChild(g)}a.appendChild(m)}r.appendChild(a);let s=d("div",{className:"fillo-matrix-wrap",attrs:{id:e.ids.inputId,role:"group","aria-labelledby":e.ids.labelId,"data-fillo":"control"}});return q(s,e.field,e.error,e.ids,{requiredSupported:!1}),s.appendChild(r),te(e.field,e.error,s,e.ids)}function ja(e){let t=d("div",{className:"fillo-signature-field"}),n=d("div",{className:"fillo-signature",attrs:{"data-fillo":"control"}}),r=d("canvas",{className:"fillo-signature-canvas",attrs:{role:"img"}}),i=d("button",{className:"fillo-signature-clear",text:"Clear",attrs:{type:"button"}}),o=d("div",{className:"fillo-signature-hint",text:"Sign here",attrs:{"aria-hidden":"true"}});r.width=720,r.height=220;let a=r.getContext("2d"),s=!1,l=typeof e.value=="string"&&e.value.startsWith("data:image/"),c=()=>{r.setAttribute("aria-label",l?T.signatureSigned:T.signatureEmpty)};if(c(),l&&a){let b=new Image;b.onload=()=>a.drawImage(b,0,0,r.width,r.height),b.src=String(e.value),o.style.display="none"}let u=d("input",{className:"fillo-input fillo-signature-type-input",attrs:{id:e.ids.inputId,type:"text",autocomplete:"name"}});q(u,e.field,e.error,e.ids);let f=b=>{a&&(a.clearRect(0,0,r.width,r.height),b.trim()?(a.fillStyle=getComputedStyle(r).color||"#18181b",a.font=`italic ${Math.min(96,r.height*.45)}px "Segoe Script", "Brush Script MT", cursive`,a.textBaseline="middle",a.fillText(b,24,r.height/2),l=!0,o.style.display="none",e.setValue(r.toDataURL("image/png"),{render:!1})):(l=!1,o.style.display="",e.setValue(null,{render:!1})),c())};u.addEventListener("input",()=>f(u.value));let p=b=>{let g=r.getBoundingClientRect();return{x:(b.clientX-g.left)/g.width*r.width,y:(b.clientY-g.top)/g.height*r.height}};r.addEventListener("pointerdown",b=>{if(!a)return;s=!0,l=!0,o.style.display="none",c(),u.value&&(u.value=""),r.setPointerCapture(b.pointerId);let g=p(b);a.beginPath(),a.moveTo(g.x,g.y)}),r.addEventListener("pointermove",b=>{if(!s||!a)return;let g=p(b);a.lineWidth=2.4,a.lineCap="round",a.strokeStyle=getComputedStyle(r).color||"#18181b",a.lineTo(g.x,g.y),a.stroke()});let m=()=>{s&&(s=!1,l&&e.setValue(r.toDataURL("image/png"),{render:!1}))};r.addEventListener("pointerup",m),r.addEventListener("pointercancel",m),i.addEventListener("click",()=>{a?.clearRect(0,0,r.width,r.height),l=!1,o.style.display="",u.value="",c(),e.setValue(null,{render:!1})}),I(n,[r,o,i]);let h=d("div",{className:"fillo-signature-type"}),v=d("label",{className:"fillo-signature-type-label",text:"Or type your full name to sign",attrs:{for:e.ids.inputId}});return I(h,[v,u]),I(t,[n,h]),te(e.field,e.error,t,e.ids)}function Qi(e){return e<1024?`${e} B`:e<1024**2?`${(e/1024).toFixed(0)} KB`:e<1024**3?`${(e/1024**2).toFixed(1)} MB`:`${(e/1024**3).toFixed(2)} GB`}function Pt(e,t=22){let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("class","fillo-file-state-icon"),n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("width",String(t)),n.setAttribute("height",String(t)),n.setAttribute("fill","none"),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false");for(let r of e){let i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d",r),n.appendChild(i)}return n}function eo(e){let t=d("span",{className:`fillo-file-state fillo-file-state--${e}`,attrs:{"aria-hidden":"true"}});return t.appendChild(Pt(e==="done"?["M3.75 12a8.25 8.25 0 1 0 16.5 0 8.25 8.25 0 1 0-16.5 0","m8.5 12 2.25 2.25 4.75-5"]:e==="failed"?["M3.75 12a8.25 8.25 0 1 0 16.5 0 8.25 8.25 0 1 0-16.5 0","M12 7.75v5.5","M12 16.5h.01"]:["M7.25 3.75h6.5l3 3v13.5h-9.5z","M13.75 3.75v3h3"])),t}function qn(){let e=Pt(["m7 7 10 10M17 7 7 17"],16);return e.setAttribute("class","fillo-file-action-icon"),e}function Tt(e,t,n,r){let i=d("button",{className:e,attrs:{type:"button","aria-label":t}});return i.append(n),i.addEventListener("click",r),i}function Va(e){let t=e.field;if(t.kind!=="file_upload")return null;let n=e,r=n.uploadDisabledReason,i=r===void 0,o=t.maxFiles??1,a=t.maxFileSizeMb??500,s=Array.isArray(e.value)?e.value:[],l=n.uploadRows??[],c=o-s.length-l.filter(p=>p.error===void 0).length,u=d("div");if(c>0){let p=d("input",{className:"fillo-input",attrs:{id:e.ids.inputId,type:"file",hidden:""}});o>1&&(p.multiple=!0),t.accept?.length&&(p.accept=t.accept.join(",")),p.disabled=!i,p.addEventListener("change",()=>{if(!i)return;let h=Array.from(p.files??[]);p.value="",e.uploadFiles?.(t,h)});let m=d("div",{className:`fillo-dropzone${i?"":" fillo-dropzone--disabled"}`,attrs:{role:"button",tabindex:"0","aria-labelledby":e.ids.labelId,"data-fillo":"control"}});if(q(m,t,e.error,e.ids,{requiredSupported:!1}),i||m.setAttribute("aria-disabled","true"),m.addEventListener("dragover",h=>{h.preventDefault(),m.classList.add("fillo-dropzone--over"),m.setAttribute("data-drag-over","")}),m.addEventListener("dragleave",()=>{m.classList.remove("fillo-dropzone--over"),m.removeAttribute("data-drag-over")}),m.addEventListener("drop",h=>{h.preventDefault(),m.classList.remove("fillo-dropzone--over"),m.removeAttribute("data-drag-over"),i&&e.uploadFiles?.(t,Array.from(h.dataTransfer?.files??[]))}),m.addEventListener("click",()=>{i&&p.click()}),m.addEventListener("keydown",h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),i&&p.click())}),m.appendChild(p),i)I(m,[d("span",{className:"fillo-dropzone-title",text:T.dropzoneTitle(o>1)}),d("span",{className:"fillo-dropzone-hint",text:T.dropzoneHint(a)})]);else if(r==="render_only")m.appendChild(d("span",{className:"fillo-dropzone-hint",text:T.uploadsRenderOnly}));else if(n.storageFixUrl){let h=d("span",{className:"fillo-dropzone-hint",text:"Connect file storage to enable uploads"});h.append(" \u2014 "),h.appendChild(d("a",{text:n.storageFixUrl,attrs:{href:n.storageFixUrl,target:"_blank",rel:"noopener noreferrer"}})),m.appendChild(h)}else m.appendChild(d("span",{className:"fillo-dropzone-hint",text:T.uploadsUnavailable}));u.appendChild(m)}if(s.length>0||l.length>0){let p=d("ul",{className:"fillo-files"});for(let m of s){let h=d("li",{className:"fillo-file fillo-file--done"}),v=d("span",{className:"fillo-file-content"});I(v,[d("span",{className:"fillo-file-name",text:m.name}),d("span",{className:"fillo-file-meta",text:T.uploadedFile(Qi(m.size))})]);let b=d("span",{className:"fillo-file-actions"});b.appendChild(Tt("fillo-file-remove",`${T.uploadRemove} ${m.name}`,qn(),()=>e.setValue(s.filter(g=>g.fileId!==m.fileId)))),I(h,[eo("done"),v,b]),p.appendChild(h)}for(let m of l){let h=m.error!==void 0,v=d("li",{className:`fillo-file${h?" fillo-file--failed":""}`});v.appendChild(eo(h?"failed":"uploading"));let b=d("span",{className:"fillo-file-content"});if(b.appendChild(d("span",{className:"fillo-file-name",text:m.name})),h){let g=d("span",{className:"fillo-file-actions"});b.appendChild(d("span",{className:"fillo-file-error",text:m.error??""})),v.appendChild(b),!m.tooLarge&&c>0&&g.appendChild(Tt("fillo-file-retry",`${T.uploadRetry} ${m.name}`,T.uploadRetry,()=>n.uploadAction?.(m.key,"retry"))),g.appendChild(Tt("fillo-file-remove",`${T.uploadDismiss} ${m.name}`,qn(),()=>n.uploadAction?.(m.key,"dismiss"))),v.appendChild(g)}else{let g=d("span",{className:"fillo-progress-bar"});g.style.width=`${m.fraction*100}%`,b.appendChild(d("span",{className:"fillo-file-meta",text:T.uploadingFile(Math.round(m.fraction*100),Qi(m.size))}));let A=d("span",{className:"fillo-file-actions"});A.appendChild(Tt("fillo-file-remove",`${T.uploadCancel} ${m.name}`,qn(),()=>n.uploadAction?.(m.key,"cancel"))),I(v,[b,A,I(d("span",{className:"fillo-progress",attrs:{role:"progressbar","aria-label":`Uploading ${m.name}`,"aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":String(Math.round(m.fraction*100))}}),[g])])}p.appendChild(v)}u.appendChild(p)}let f=n.uploadNotice;return f&&u.appendChild(d("p",{className:"fillo-upload-notice",text:f})),te(t,e.error,u,e.ids)}function Ha(e){let t=e.field,n=d("div",{className:"fillo-field fillo-field--calculated fillo-calculated",attrs:{"data-fillo":"calculated","data-field":t.id,"data-kind":t.kind}});n.appendChild(d("label",{className:"fillo-label",text:t.label,attrs:{id:e.ids.labelId,for:e.ids.inputId,"data-fillo":"label"}})),t.description&&n.appendChild(d("p",{className:"fillo-description",text:t.description,attrs:{id:e.ids.descriptionId,"data-fillo":"fieldDescription"}}));let r=e.value,i=r!=null&&r!=="",o=d("output",{className:`fillo-calculated-value${i?"":" fillo-calculated-value--empty"}`,text:i?Tn(t,r):"\u2014",attrs:{id:e.ids.inputId}});return t.description&&o.setAttribute("aria-describedby",e.ids.descriptionId),n.appendChild(o),n}var to=new Map;function Xn(e){if(!e.shuffleOptions)return e.options;let t=`${e.id}|${e.options.map(o=>o.id).join(",")}`,n=to.get(t);if(!n){n=e.options.map(o=>o.id);for(let o=n.length-1;o>0;o--){let a=Math.floor(Math.random()*(o+1));[n[o],n[a]]=[n[a],n[o]]}to.set(t,n)}let r=new Map(e.options.map(o=>[o.id,o])),i=n.flatMap(o=>r.get(o)??[]);return i.length===e.options.length?i:e.options}function dt(e){let t=e.getValue?.()??e.value;return Array.isArray(t)?t:[]}function Ga(e,t){return Math.max(t.length,e.minInstances??1)}function qa(e){return Math.max(e.minInstances??1,0)}function Wn(e,t){let n=[...e];for(;n.length<t;)n.push({});return n}function Wa(e){let t=e.field;if(t.kind!=="repeating_group")return null;let n=e,r=n.announce,i=n.instanceId??"",o=t.itemLabel||t.label,a=dt(e),s=Ga(t,a),l=qa(t),c=d("div",{className:"fillo-group",attrs:{id:e.ids.inputId,"data-fillo":"control"}});q(c,t,e.error,e.ids,{requiredSupported:!1});for(let p=0;p<s;p++){let m=a[p]??{},h=T.groupInstanceLabel(o,p+1,s),v=d("div",{className:"fillo-group-instance",attrs:{role:"group","aria-label":h,tabindex:"-1"}}),b=d("div",{className:"fillo-group-instance-header"}),g=d("button",{className:"fillo-group-remove",text:"\xD7",attrs:{type:"button","aria-label":T.groupRemoveLabel(o,p+1)}}),A=s>l;g.toggleAttribute("disabled",!A),A||(g.setAttribute("aria-disabled","true"),g.setAttribute("title",`At least ${l} ${l===1?"entry":"entries"} required`)),g.addEventListener("click",()=>{if(s<=l)return;let z=Wn(dt(e),s);z.splice(p,1),e.setValue(z),n.setGroupFocus?.({groupId:t.id,cardIndex:p-1,intoControl:!1}),r?.(T.groupInstanceRemoved(o,z.length))}),I(b,[d("p",{className:"fillo-group-instance-title",text:h}),g]),v.appendChild(b);for(let z of Cn(t,m)){let P=`${t.id}.${p}.${z.id}`,ne={...z,id:P},W=ao(i,P),re=(le,V)=>{let ce=Wn(dt(e),s);ce[p]={...ce[p]??{},[z.id]:le},e.setValue(ce,V)},he={field:ne,value:m[z.id],error:e.api.errors[P],ids:W,api:e.api,setValue:re,getValue:()=>dt(e)[p]?.[z.id],announce:n.announce,announceAlert:n.announceAlert,registerOverlay:n.registerOverlay,activeOtherFields:n.activeOtherFields},ae=n.renderChildField?.(he)??po(he);ae&&v.appendChild(ae)}c.appendChild(v)}let u=s>=t.maxInstances,f=d("button",{className:"fillo-group-add",text:t.addLabel||T.groupAdd,attrs:{type:"button"}});return f.toggleAttribute("disabled",u),u&&(f.setAttribute("aria-disabled","true"),f.setAttribute("title",`Maximum ${t.maxInstances} ${t.maxInstances===1?"entry":"entries"}`)),f.addEventListener("click",()=>{if(s>=t.maxInstances)return;let p=Wn(dt(e),s);p.push({}),e.setValue(p),n.setGroupFocus?.({groupId:t.id,cardIndex:p.length-1,intoControl:!0}),r?.(T.groupInstanceAdded(o,p.length,p.length))}),c.appendChild(f),te(t,e.error,c,e.ids)}var Ka={short_text:e=>ut("text",e),email:e=>ut("email",e),url:e=>ut("url",e),phone:Na,number:e=>ut("number",e),date:e=>ut("date",e),long_text:La,select:Ma,multi_select:Ta,dropdown:Ra,checkbox:Oa,rating:Za,linear_scale:Da,ranking:Ua,matrix:Ba,signature:ja,file_upload:Va,calculated:Ha,repeating_group:Wa};function po(e){if(e.field.kind==="hidden"||e.field.kind==="custom")return null;let t=Ka[e.field.kind];return t?t(e):null}var Ja="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit",no="fillo-turnstile-script",Xa=2e4,Ya=/^[A-Za-z0-9_-]{1,255}$/,pt=null;function Ge(){return globalThis.turnstile}function Qa(){return typeof window>"u"||typeof document>"u"?Promise.reject(new Error("Turnstile needs a browser")):Ge()?Promise.resolve():pt||(pt=new Promise((e,t)=>{let n=()=>{Ge()?e():t(new Error("Turnstile loaded without its global"))},r=document.getElementById(no);if(r){if(Ge()){e();return}r.addEventListener("load",n,{once:!0}),r.addEventListener("error",()=>t(new Error("Turnstile script failed to load")),{once:!0});return}let i=document.createElement("script");i.id=no,i.src=Ja,i.async=!0,i.defer=!0,i.addEventListener("load",n,{once:!0}),i.addEventListener("error",()=>{i.remove(),pt=null,t(new Error("Turnstile script failed to load"))},{once:!0}),document.head.appendChild(i)}),pt)}function ro(){return d("div",{className:"fillo-turnstile",attrs:{"data-fillo":"turnstile"}})}var mt=class{constructor(t,n){this.target=t;this.options=n;this.element.className="fillo-dom-root",n.preview===!0&&ll(),t.replaceChildren(this.element,this.statusEl,this.alertEl),this.resolve()}target;options;element=d("div");statusEl=d("span",{className:"fillo-sr-only",attrs:{role:"status","aria-live":"polite","data-fillo":"announce"}});alertEl=d("span",{className:"fillo-sr-only",attrs:{role:"alert","data-fillo":"announce-alert"}});instanceId=`d${++$a}`;schema=null;theme;formId;closed=!1;fetchedPoweredBy=null;fetchedBrandLabel;fetchedBrandHref;phase="loading";engine=null;destroyed=!1;renderQueued=!1;hpValue="";liveSubmissionHandled=!1;activeOtherFields=new Set;inFlight=new Map;uploadNotices=new Map;focusIntent=null;overlays=new Set;challenge;challengeToken;challengeError=!1;turnstileContainer=ro();turnstileWidgetId=null;turnstileSiteKey;turnstileLoadInFlight=!1;turnstileAttempt=0;challengeFrame=null;challengeFrameSrc=null;challengeFrameOrigin=null;challengeMessageHandler=null;challengeWatchdog=null;announce=t=>{this.statusEl.textContent="",requestAnimationFrame(()=>{this.statusEl.textContent=t})};announceAlert=t=>{this.alertEl.textContent="",requestAnimationFrame(()=>{this.alertEl.textContent=t})};devChrome(){return this.options.preview===!0||nl()}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 t=this.schema??{version:1,title:"",pages:[],settings:{}},n=this.engine?.getState(),r=n?.pageCount??t.pages.length;return{form:t,formId:this.formId,client:this.options.renderOnly?void 0:this.options.client,data:n?.data??this.mutableData,errors:n?.errors??{},status:this.status,pageIndex:n?.pageIndex??0,pageCount:r,page:n?.page??t.pages[0]??{id:"empty",blocks:[]},blocks:n?.blocks??[],isFirstPage:n?.isFirstPage??!0,isLastPage:n?.isLastPage??r<=1,setValue:(i,o,a)=>this.setValueInternal(i,o,a),next:()=>this.next(),back:()=>this.back(),submit:()=>this.submit()}}resolveFormIdFn;notOpenVariant=null;fatalError=null;genericUnavailable=!1;syncErrorNotice=null;stagedNotice=!1;draftNotice=!1;syncWarningCode;syncWarningUrl;syncFormUrl;uploadsAvailable;uploadFileSizeLimitMb;resolutionFailureCode=null;async resolve(){try{this.challenge=this.options.renderOnly?void 0:this.options.challenge;let t=Vn(this.options.form)?this.options.form:null;if(t){if(this.options.renderOnly){this.setSchema(t.schema,this.options.theme??t.theme,void 0);return}!this.options.client&&this.options.formId&&(this.options.client=Le());let i=this.options.client;if(i?.key&&(this.resolveFormIdFn=async()=>{try{let o=await Hn(i,t,{bypassCache:!0});if(this.syncWarningCode=o.warningCode,this.syncWarningUrl=o.warningUrl,this.syncFormUrl=o.manageUrl,this.uploadsAvailable=o.uploadsAvailable,this.uploadFileSizeLimitMb=o.uploadFileSizeLimitMb,o.status==="draft")throw new S("This form is no longer published. Submission was stopped before sending answers.",403,void 0,"form_not_published");if(o.accepting===!1)throw new S("This form is no longer accepting responses. Submission was stopped before sending answers.",403,void 0,o.acceptingReason??"form_not_accepting");let a=Ne(o.resolvedSchema??t.schema);if(!a.ok)throw new S(`The canonical form schema was invalid: ${a.error}`,502,void 0,"invalid_sync_schema");if(this.schema&&!Wi(this.schema,a.schema))throw new S("The live form changed after this page loaded. Submission stopped before incompatible answers were sent. Reload to use the published schema.",409,void 0,"form_schema_changed");return o.syncError&&this.reportSyncNotice(new S(o.syncError.message,403,void 0,o.syncError.code)),this.resolutionFailureCode=null,o.formId}catch(o){let a=ft(o);throw this.resolutionFailureCode=a.code??"sync_failed",this.reportSubmitSyncFailure(a),a}}),!i?.key&&this.options.formId&&this.setSchema(t.schema,this.options.theme??t.theme,this.options.formId),!i&&!this.options.formId)throw this.genericUnavailable=!this.devChrome(),so();if(i&&!i.key&&!this.options.formId){this.reportSyncFailure(new S('Code forms need createClient({ key: "pk_\u2026" }) to resolve the live form. Pass a publishable key or a published formId.',401,void 0,"sync_key_required"));return}if(!i?.key)return;this.devChrome()?this.setSchema(t.schema,this.options.theme??t.theme,this.options.formId):(this.theme=this.options.theme??t.theme,this.render());try{let o=await Hn(i,t);if(this.destroyed)return;if((o.staged||o.syncError)&&!o.resolvedSchema)throw new S("Sync did not return the live schema needed to render safely. Publish changes before deploy, and update @usefillo/* or your API.",409,void 0,"sync_snapshot_required");let a=this.devChrome();if(this.notOpenVariant=a?null:o.status==="draft"?"notOpen":o.accepting===!1?io(o.acceptingReason):null,this.stagedNotice=!!o.staged,this.draftNotice=o.status==="draft",this.syncWarningCode=o.warningCode,this.syncWarningUrl=o.warningUrl,this.syncFormUrl=o.manageUrl,this.uploadsAvailable=o.uploadsAvailable,this.uploadFileSizeLimitMb=o.uploadFileSizeLimitMb,this.challenge=this.options.challenge??o.challenge,o.branding&&(this.fetchedPoweredBy=o.branding.poweredBy,this.fetchedBrandLabel=o.branding.label,this.fetchedBrandHref=o.branding.href),a&&o.resolvedSchema)this.formId=o.formId,this.engine?.setContext({formId:o.formId}),this.render();else{let l=o.resolvedSchema??t.schema,c=this.options.theme??(o.resolvedSchema?o.resolvedTheme??void 0:t.theme);this.applyCanonicalSchema(l,c,o.formId)}o.warning&&console.warn(`[fillo] ${o.warning}`),o.syncError&&this.reportSyncNotice(new S(o.syncError.message,403,void 0,o.syncError.code));let s=o.warningUrl?` \u2014 connect storage to publish: ${o.warningUrl}`:"";o.staged?console.info(`[fillo] "${t.id}" changes staged as a draft \u2014 rendering the live version until you publish them in your Fillo dashboard${s}`):o.status==="draft"&&console.info(`[fillo] "${t.id}" is a draft \u2014 it renders here but won't accept responses until published${s}`)}catch(o){if(this.destroyed)return;this.reportSyncFailure(ft(o))}return}let n=this.options.form&&!Vn(this.options.form)?this.options.form:null;if(n){if(this.options.renderOnly){this.setSchema(n,this.options.theme,void 0);return}if(!this.options.formId)throw this.genericUnavailable=!this.devChrome(),so();this.options.client??=Le(),this.setSchema(n,this.options.theme,this.options.formId);return}if(!this.options.formId)throw new S("Provide either `form`, or a `formId`.",0);this.options.client??=Le(),this.render();let r=await this.options.client.getForm(this.options.formId);if(this.destroyed)return;if(r.accepting===!1?this.notOpenVariant=io(r.acceptingReason):this.closed=!!r.closed,this.uploadsAvailable=r.uploadsAvailable,this.uploadFileSizeLimitMb=r.uploadFileSizeLimitMb,this.fetchedPoweredBy=r.branding?.poweredBy??null,this.fetchedBrandLabel=r.branding?.label,this.fetchedBrandHref=r.branding?.href,this.challenge=this.options.challenge??r.challenge,r.accepting===!1&&this.options.renderError){let i=this.notOpenVariant==="closed"?"This form is no longer accepting responses.":"This form isn't accepting responses yet.";this.fatalError=new S(i,403,void 0,r.acceptingReason),this.phase="error",this.render(this.fatalError);return}this.setSchema(r.schema,this.options.theme??r.theme??void 0,r.id)}catch(t){if(this.destroyed)return;this.handleError(ft(t))}}setSchema(t,n,r){if(this.destroyed)return;let i=Ne(t);if(!i.ok)throw new S(`This form could not be rendered: ${i.error}`,422);let o=i.schema;this.schema=o,this.theme=n;let a=this.options.renderOnly===!0;this.formId=a?void 0:r;let s=this.notOpenVariant!==null,l=s||a;this.engine=ji({form:o,formId:l?void 0:r,client:l?void 0:this.options.client,initialData:this.options.initialData,onChange:s?void 0:this.options.onChange,onSubmitted:l?void 0:this.options.onSubmitted,getHoneypot:()=>this.element.querySelector('input[name="fillo_hp_field"]')?.value??this.hpValue,surface:"default",resolveFormId:l?void 0:this.resolveFormIdFn,skipValidation:a,verboseResolutionErrors:this.devChrome(),respondent:l?void 0:this.options.respondent,challengeRequired:l?!1:!!this.challenge,getChallengeToken:()=>this.challengeToken,onChallengeFailed:()=>this.resetChallengeWidget()});let c=this.engine.getState().status,u=this.engine.getState().resumedDraft,f=this.engine.getState().editingPrevious;this.engine.subscribe(()=>{let p=this.engine?.getState();p&&(p.status!==c||p.resumedDraft!==u||p.editingPrevious!==f)&&(p.editingPrevious&&!f?this.announce(L.editNotice):p.resumedDraft&&!u&&this.announce(L.resumeNotice),c=p.status,u=p.resumedDraft,f=p.editingPrevious,this.queueRender())}),l||this.configureDraftFlush(o),this.phase=this.closed?"closed":"ready",this.render()}applyCanonicalSchema(t,n,r){if(!this.engine){this.setSchema(t,n,r);return}let i=Ne(t);if(!i.ok)throw new S(`This form could not be rendered: ${i.error}`,422);let o=i.schema;this.schema=o,this.theme=n,this.formId=r,this.engine.setContext({form:o,formId:r}),this.notOpenVariant===null&&this.configureDraftFlush(o),this.phase=this.closed?"closed":"ready",this.render()}draftFlushWired=!1;flushDraftBound=()=>this.engine?.flushDraft();visibilityFlushBound=()=>{document.visibilityState==="hidden"&&this.engine?.flushDraft()};configureDraftFlush(t){this.teardownDraftFlush(),t.settings.saveProgress&&typeof window<"u"&&(window.addEventListener("pagehide",this.flushDraftBound),document.addEventListener("visibilitychange",this.visibilityFlushBound),this.draftFlushWired=!0)}teardownDraftFlush(){!this.draftFlushWired||typeof window>"u"||(window.removeEventListener("pagehide",this.flushDraftBound),document.removeEventListener("visibilitychange",this.visibilityFlushBound),this.draftFlushWired=!1)}flushDraft(){this.engine?.flushDraft()}resetDraft(){this.engine?.resetDraft(),this.queueRender()}setValue(t,n){this.setValueInternal(t,n)}setValueInternal(t,n,r={}){this.notOpenVariant||(this.engine?.setValue(t,n),r.render!==!1&&this.queueRender())}next(){if(!this.engine||this.notOpenVariant)return;let t=this.engine.getState().pageIndex;this.engine.next(),this.focusIntent=this.engine.getState().pageIndex!==t?"page":"error",this.render()}back(){!this.engine||this.notOpenVariant||(this.engine.back(),this.focusIntent="page",this.render())}async submit(){if(!this.engine||this.phase!=="ready"||this.notOpenVariant)return;let t=this.engine.submit();this.hasErrors()?this.focusIntent="error":this.engine.getState().status==="submitting"&&this.announce(T.submittingAnnouncement),this.render();try{await t}catch(n){this.options.onError?.(ft(n)),this.focusIntent="error",this.render();return}this.hasErrors()&&(this.focusIntent="error"),this.render()}hasErrors(){return Object.keys(this.engine?.getState().errors??{}).length>0}setTheme(t){this.options.theme=t,this.theme=t,this.render()}setClient(t){this.options.client=t,this.engine?.setContext({client:t}),this.render()}setRespondent(t){this.options.respondent=t,this.engine?.setContext({respondent:t})}fieldActive(t){let n=0;for(let r of this.inFlight.values())r.fieldId===t&&r.error===void 0&&n++;return n}uploadRowsFor(t){let n=[];for(let[r,i]of this.inFlight)i.fieldId===t&&n.push({key:r,name:i.name,size:i.size,fraction:i.fraction,error:i.error,tooLarge:i.tooLarge});return n}uploadAction=(t,n)=>{let r=this.inFlight.get(t);if(r){if(n==="cancel")r.controller.abort(),this.inFlight.delete(t);else if(n==="dismiss")this.inFlight.delete(t);else{if(r.tooLarge)return;this.inFlight.delete(t),this.startUpload(r.fieldId,r.file,r.maxFiles)}this.fieldActive(r.fieldId)===0&&this.engine?.setUploading(r.fieldId,!1),this.queueRender()}};async startUpload(t,n,r){let i=`${n.name}-${n.size}-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,o=new AbortController;this.inFlight.set(i,{fieldId:t,name:n.name,size:n.size,fraction:0,file:n,controller:o,maxFiles:r}),this.engine?.setUploading(t,!0),this.queueRender();try{let a=this.options.client&&this.formId?await this.options.client.uploadFile(this.formId,n,{fieldId:t,signal:o.signal,onProgress:l=>{let c=this.inFlight.get(i);c&&(c.fraction=l.fraction,this.queueRender())}}):{fileId:`local:${n.name}:${n.size}`,name:n.name,size:n.size,mime:n.type||"application/octet-stream"};if(this.destroyed)return;this.inFlight.delete(i);let s=r>1&&Array.isArray(this.mutableData[t])?this.mutableData[t]:[];this.setValueInternal(t,[...s,a])}catch(a){if(this.destroyed||o.signal.aborted)return;let s=ft(a),l=s.status===0||s.status!==void 0&&s.status>=500?T.uploadUnavailable:T.uploadFailed,c=this.inFlight.get(i);c&&(c.error=l),this.announceAlert(l),this.options.onError?.(s)}finally{this.fieldActive(t)===0&&this.engine?.setUploading(t,!1),this.queueRender()}}async uploadFiles(t,n){if(!this.schema||this.notOpenVariant)return;let r=t.maxFiles??1,i=r>1&&Array.isArray(this.mutableData[t.id])?this.mutableData[t.id].length:0,o=Math.max(0,r-i-this.fieldActive(t.id)),a=n.slice(0,o),s=t.maxFileSizeMb??500,l=this.uploadFileSizeLimitMb?Math.min(s,this.uploadFileSizeLimitMb):s,c=l*1024*1024,u=a.filter(h=>h.size<=c),f=a.filter(h=>h.size>c),p=n.length-a.length,m=a.length-u.length;if(p>0||m>0){let h=[];p>0&&h.push(`You can attach up to ${r} file${r===1?"":"s"}. ${p} ${p===1?"file was":"files were"} not added.`);let v=h.join(" ");v?this.uploadNotices.set(t.id,v):this.uploadNotices.delete(t.id),v&&this.announce(v)}else this.uploadNotices.delete(t.id);for(let h of f){let v=T.fileTooLarge(l),b=`${h.name}-${h.size}-${Date.now()}-${Math.random().toString(36).slice(2,7)}`;this.inFlight.set(b,{fieldId:t.id,name:h.name,size:h.size,fraction:0,error:v,tooLarge:!0,file:h,controller:new AbortController,maxFiles:r}),this.announceAlert(v)}if(u.length===0){this.queueRender();return}await Promise.all(u.map(h=>this.startUpload(t.id,h,r)))}destroy(){this.destroyed=!0,this.teardownDraftFlush(),this.closeOverlays(),this.teardownTurnstileWidget();for(let t of this.inFlight.values())t.controller.abort();this.inFlight.clear(),this.engine?.destroy(),this.engine=null,this.target.replaceChildren()}storageBlocked(){return this.uploadsAvailable===!1}registerOverlay=t=>(this.overlays.add(t),()=>this.overlays.delete(t));closeOverlays(){if(this.overlays.size!==0){for(let t of Array.from(this.overlays))try{t()}catch{}this.overlays.clear()}}ensureChallengeWidget(t){t.bridgeUrl?this.ensureChallengeBridge(t.bridgeUrl):this.ensureTurnstileWidget(t.siteKey)}ensureChallengeBridge(t){if(typeof window>"u")return;let n;try{n=new URL(t)}catch{this.handleChallengeError();return}if(n.protocol!=="https:"&&n.protocol!=="http:"){this.handleChallengeError();return}n.searchParams.set("origin",window.location.origin),n.searchParams.set("theme",this.options.challengeTheme??"auto"),this.formId&&Ya.test(this.formId)&&n.searchParams.set("cdata",this.formId),n.searchParams.set("appearance",(this.options.challengeAppearance??"interaction-only")==="interaction-only"?"interaction-only":"always");let r=n.toString();if(this.challengeFrame&&this.challengeFrameSrc===r)return;this.teardownTurnstileWidget();let i=++this.turnstileAttempt,o=d("iframe",{className:"fillo-turnstile-frame",attrs:{src:r,title:"Human verification",width:"300",height:"65",referrerpolicy:"no-referrer"}});this.challengeFrame=o,this.challengeFrameSrc=r,this.challengeFrameOrigin=n.origin,this.turnstileContainer.appendChild(o),this.setChallengeFrameVisible((this.options.challengeAppearance??"interaction-only")!=="interaction-only");let a=s=>{if(i!==this.turnstileAttempt||this.destroyed||s.origin!==this.challengeFrameOrigin||!this.challengeFrame||s.source!==this.challengeFrame.contentWindow)return;let l=s.data;switch(l?.type){case"fillo:challenge:ready":this.settleChallengeWatchdog();break;case"fillo:challenge:token":this.settleChallengeWatchdog(),typeof l.token=="string"&&l.token.length>0&&this.handleChallengeToken(l.token),(this.options.challengeAppearance??"interaction-only")==="interaction-only"&&this.setChallengeFrameVisible(!1);break;case"fillo:challenge:interactive":this.setChallengeFrameVisible(!0);break;case"fillo:challenge:interactive-done":(this.options.challengeAppearance??"interaction-only")==="interaction-only"&&this.setChallengeFrameVisible(!1);break;case"fillo:challenge:expired":this.handleChallengeToken(void 0);break;case"fillo:challenge:error":this.settleChallengeWatchdog(),this.handleChallengeToken(void 0),this.handleChallengeError();break}};this.challengeMessageHandler=a,window.addEventListener("message",a),this.challengeWatchdog=window.setTimeout(()=>{i!==this.turnstileAttempt||this.destroyed||(this.handleChallengeToken(void 0),this.handleChallengeError())},Xa)}setChallengeFrameVisible(t){let n=this.challengeFrame;n&&(n.setAttribute("height",t?"65":"0"),t?(n.removeAttribute("aria-hidden"),n.removeAttribute("tabindex")):(n.setAttribute("aria-hidden","true"),n.setAttribute("tabindex","-1")),this.turnstileContainer.setAttribute("data-fillo-challenge-visible",t?"true":"false"))}settleChallengeWatchdog(){this.challengeWatchdog!==null&&typeof window<"u"&&window.clearTimeout(this.challengeWatchdog),this.challengeWatchdog=null}teardownChallengeBridge(){this.challengeMessageHandler&&typeof window<"u"&&window.removeEventListener("message",this.challengeMessageHandler),this.challengeMessageHandler=null,this.settleChallengeWatchdog(),this.challengeFrame?.remove(),this.challengeFrame=null,this.challengeFrameSrc=null,this.challengeFrameOrigin=null}ensureTurnstileWidget(t){if(this.turnstileSiteKey!==t&&(this.teardownTurnstileWidget(),this.turnstileSiteKey=t),this.turnstileWidgetId!==null||this.turnstileLoadInFlight||this.challengeError)return;this.turnstileLoadInFlight=!0;let n=++this.turnstileAttempt;Qa().then(()=>{if(this.destroyed||n!==this.turnstileAttempt)return;let r=Ge();if(!r){this.turnstileLoadInFlight=!1,this.handleChallengeError();return}this.turnstileWidgetId=r.render(this.turnstileContainer,{sitekey:t,theme:"auto",callback:i=>this.handleChallengeToken(i),"error-callback":()=>{this.handleChallengeToken(void 0),this.handleChallengeError()},"expired-callback":()=>this.resetChallengeWidget(),"timeout-callback":()=>this.resetChallengeWidget()}),this.turnstileLoadInFlight=!1}).catch(()=>{this.destroyed||n!==this.turnstileAttempt||(this.turnstileLoadInFlight=!1,this.handleChallengeError())})}handleChallengeToken(t){this.challengeToken=t,t&&(this.challengeError=!1),this.queueRender()}handleChallengeError(){this.challengeError=!0,this.announceAlert(L.challengeUnavailable),this.queueRender()}resetChallengeWidget(){this.challengeToken=void 0,this.challengeFrame&&this.challengeFrameOrigin?this.challengeFrame.contentWindow?.postMessage({type:"fillo:challenge:reset"},this.challengeFrameOrigin):this.turnstileWidgetId&&Ge()?.reset(this.turnstileWidgetId),this.queueRender()}teardownTurnstileWidget(){if(this.turnstileWidgetId===null&&!this.turnstileLoadInFlight&&this.challengeFrame===null)return;this.turnstileAttempt++,this.teardownChallengeBridge();let t=Ge();if(this.turnstileWidgetId&&t)try{t.remove(this.turnstileWidgetId)}catch{}this.turnstileWidgetId=null,this.turnstileLoadInFlight=!1,this.challengeError=!1,this.turnstileContainer=ro(),this.challengeToken=void 0}captureFocus(){if(typeof document>"u")return null;let t=document.activeElement;if(!t||!this.element.contains(t))return null;let n={};t.id&&(n.id=t.id);let r=t.getAttribute("data-fillo-rank-opt");r&&(n.rankOpt=r,n.rankDir=t.getAttribute("data-fillo-rank-dir")??void 0);let i=t.closest("[data-field]");if(i&&(n.fieldId=i.getAttribute("data-field")??void 0,n.controlIndex=Array.from(i.querySelectorAll(ht)).indexOf(t)),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)try{n.selStart=t.selectionStart,n.selEnd=t.selectionEnd}catch{}return n.id||n.rankOpt||n.fieldId?n:null}restoreFocus(t){if(typeof document>"u")return;let n=null;if(t.rankOpt){let r=Array.from(this.element.querySelectorAll("[data-fillo-rank-opt]")).filter(i=>i.getAttribute("data-fillo-rank-opt")===t.rankOpt);n=r.find(i=>i.getAttribute("data-fillo-rank-dir")===t.rankDir&&!i.disabled)??r.find(i=>!i.disabled)??null}if(!n&&t.id&&(n=document.getElementById(t.id)),!n&&t.fieldId!=null&&t.controlIndex!=null&&t.controlIndex>=0){let r=Array.from(this.element.querySelectorAll("[data-field]")).find(i=>i.getAttribute("data-field")===t.fieldId);r&&(n=Array.from(r.querySelectorAll(ht))[t.controlIndex]??null)}if(!(!n||typeof n.focus!="function")&&(n.focus(),(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)&&t.selStart!=null))try{n.setSelectionRange(t.selStart,t.selEnd??t.selStart)}catch{}}applyFocus(t,n){if(!(typeof document>"u")){if(t==="error"){let r=this.element.querySelector('[aria-invalid="true"]');r&&Sa(r)?.focus();return}if(t==="page"){let i=this.element.querySelector(".fillo-page-title, .fillo-title")??this.element.querySelector(".fillo-blocks");i&&(i.hasAttribute("tabindex")||i.setAttribute("tabindex","-1"),i.focus?.());return}if(t){this.applyGroupFocus(t);return}n&&this.restoreFocus(n)}}applyGroupFocus(t){let n=Array.from(this.element.querySelectorAll("[data-field]")).find(o=>o.getAttribute("data-field")===t.groupId),r=n?Array.from(n.querySelectorAll(".fillo-group-instance")):[],i=t.cardIndex>=0?r[t.cardIndex]:void 0;if(i){(t.intoControl?Aa(i)??i:i).focus();return}n?.querySelector(".fillo-group-add")?.focus()}handleError(t){this.destroyed||(this.fatalError=t,this.phase="error",this.options.onError?.(t),this.render(t))}reportSyncFailure(t){if(this.destroyed)return;console.warn(`[fillo] form sync failed${t.code?` (${t.code})`:""}: ${t.message}`),this.syncErrorNotice=t;let n=this.devChrome();if(!n||this.options.renderError){this.genericUnavailable=!n,this.handleError(t);return}this.options.onError?.(t),n&&this.render()}reportSyncNotice(t){this.destroyed||(console.warn(`[fillo] form sync needs attention${t.code?` (${t.code})`:""}: ${t.message}`),this.syncErrorNotice=t,this.options.onError?.(t),this.devChrome()&&this.render())}reportSubmitSyncFailure(t){this.destroyed||(console.warn(`[fillo] form sync failed${t.code?` (${t.code})`:""}: ${t.message}`),this.syncErrorNotice=t)}queueRender(){this.renderQueued||this.destroyed||(this.renderQueued=!0,setTimeout(()=>{this.renderQueued=!1,this.render()},0))}render(t){if(this.destroyed)return;let n=this.focusIntent;this.focusIntent=null;let r=n?null:this.captureFocus();if(this.closeOverlays(),this.phase==="ready"&&this.engine?.getState().status!=="submitted"||this.teardownTurnstileWidget(),this.element.replaceChildren(),this.phase==="loading"){let a=d("div",{className:`fillo-form fillo-form--loading ${this.options.className??""}`,attrs:{"aria-busy":"true","data-fillo":"root","data-state":"loading"}});He(a,this.theme),I(a,[d("div",{className:"fillo-skeleton"}),d("div",{className:"fillo-skeleton"}),d("div",{className:"fillo-skeleton fillo-skeleton--short"})]),this.element.appendChild(a);return}let o=t??this.fatalError;if(this.phase==="error"&&o){let a=o.code==="form_target_required"&&this.devChrome()?`${o.message} (${o.code})`:null,s=this.options.renderError?.(o)??d("div",{className:"fillo-form fillo-form--error",text:a??(this.genericUnavailable?"This form is unavailable.":ul(o))});s.hasAttribute("data-fillo")||s.setAttribute("data-fillo","root"),s.hasAttribute("data-state")||s.setAttribute("data-state","error"),o.code&&!s.hasAttribute("data-error-code")&&s.setAttribute("data-error-code",o.code),s.hasAttribute("role")||s.setAttribute("role","alert"),He(s,this.theme),this.element.appendChild(s);return}if(this.phase==="closed"){let a=d("div",{className:`fillo-form fillo-form--closed ${this.options.className??""}`,attrs:{"data-fillo":"root","data-state":"closed"}});He(a,this.theme),a.appendChild(d("p",{className:"fillo-closed",text:"This form is no longer accepting responses."})),this.element.appendChild(a);return}if(this.notOpenVariant&&this.schema){this.element.appendChild(this.renderNotOpen(this.notOpenVariant)),this.brandingVisible()&&this.element.appendChild(Kn(this.fetchedBrandLabel,this.fetchedBrandHref));return}if(this.schema){if(this.engine?.getState().status==="submitted"){let a=this.api(),s=this.engine.getState(),l=this.options.renderSuccess?.(a)??tl(this.schema);if(l.setAttribute("data-fillo",l.getAttribute("data-fillo")??"root"),this.formId&&!l.hasAttribute("data-fillo-form-id")&&l.setAttribute("data-fillo-form-id",this.formId),l.setAttribute("data-state",l.getAttribute("data-state")??"submitted"),l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1"),He(l,this.theme),this.element.appendChild(l),this.brandingVisible()&&this.element.appendChild(Kn(this.fetchedBrandLabel,this.fetchedBrandHref)),!s.restoredSubmission&&!this.liveSubmissionHandled){this.liveSubmissionHandled=!0;let c=Me(this.schema.settings.redirectUrl);c&&typeof window<"u"?window.location.assign(c):(l.focus(),this.announce(l.textContent??""))}return}this.devChrome()&&I(this.element,cl({preview:this.options.preview===!0,devNotices:this.options.devNotices,syncError:this.syncErrorNotice,staged:this.stagedNotice,draft:this.draftNotice,warningUrl:this.syncWarningUrl,formUrl:this.syncFormUrl,noClient:!this.options.client&&!this.options.renderOnly})),this.element.appendChild(this.renderForm()),this.brandingVisible()&&this.element.appendChild(Kn(this.fetchedBrandLabel,this.fetchedBrandHref)),this.applyFocus(n,r)}}brandingVisible(){return this.fetchedPoweredBy??!0}renderNotOpen(t){let n=d("div",{className:`fillo-form fillo-form--not-open ${this.options.className??""}`,attrs:{"data-fillo":"root","data-state":"closed"}});He(n,this.theme);let r=d("div",{className:"fillo-not-open-preview",attrs:{"aria-hidden":"true",inert:""}});r.appendChild(this.renderForm());let i=d("div",{className:"fillo-not-open-card",attrs:{role:"status","data-fillo":"not-open-card"}});return i.appendChild(d("h2",{className:"fillo-not-open-title",text:t==="closed"?L.closedTitle:L.notOpenTitle})),i.appendChild(d("p",{className:"fillo-not-open-body",text:t==="closed"?L.closed:L.notOpenBody})),I(n,[r,i]),n}renderForm(){let t=this.api(),n=this.notOpenVariant!==null,r=!!this.challenge,i=!n&&r&&t.isLastPage,o=d(n?"div":"form",{className:`fillo-form ${this.options.className??""}`,attrs:{"data-fillo":n?"preview-form":"root","data-state":n?"preview":t.status,"data-page":String(t.pageIndex+1)}});!n&&this.formId&&o.setAttribute("data-fillo-form-id",this.formId),o.toggleAttribute("data-last-page",t.isLastPage),He(o,this.theme);let a=()=>{t.isLastPage?this.submit():this.next()};if(!n){let h=o;h.noValidate=!0,h.addEventListener("submit",v=>{v.preventDefault(),a()})}let s=n?o.appendChild(d("fieldset",{className:"fillo-not-open-fields",attrs:{disabled:""}})):o,l=this.engine?.getState();if(l?.resumedDraft||l?.editingPrevious){let h=d("div",{className:"fillo-resume",attrs:{"data-fillo":"resume"}});h.appendChild(d("span",{className:"fillo-resume-text",text:l.editingPrevious?L.editNotice:L.resumeNotice}));let v=d("button",{className:"fillo-resume-clear",text:L.resumeStartOver,attrs:{type:"button"}});v.addEventListener("click",()=>this.resetDraft()),h.appendChild(v),s.appendChild(h)}if(t.pageCount>1&&this.schema?.settings.showProgress!==!1){let h=je(t.form,t.data),v=Math.max(h.length,1),b=h.indexOf(t.page.id),g=b>=0?b+1:Math.min(t.pageIndex+1,v),A=d("div",{className:"fillo-progress-track",attrs:{role:"progressbar","data-fillo":"progress","aria-label":t.form.title||"Form progress","aria-valuemin":"1","aria-valuemax":String(v),"aria-valuenow":String(g)}});A.appendChild(d("div",{className:"fillo-progress-fill",attrs:{"data-fillo":"progressFill"}})),A.firstElementChild?.style.setProperty("--fillo-progress-value",`${g/v*100}%`),s.appendChild(A)}if(t.pageIndex===0){let h=d("header",{className:"fillo-header",attrs:{"data-fillo":"header"}});t.form.title&&h.appendChild(d("h1",{className:"fillo-title",text:t.form.title,attrs:{"data-fillo":"title"}})),t.form.description&&h.appendChild(d("p",{className:"fillo-form-description",text:t.form.description,attrs:{"data-fillo":"description"}})),s.appendChild(h)}else t.page.title&&s.appendChild(d("h2",{className:"fillo-page-title",text:t.page.title,attrs:{"data-fillo":"pageTitle"}}));let c=d("div",{className:"fillo-blocks",attrs:{"data-fillo":"blocks"}});for(let h of t.blocks){let v=this.renderBlock(Xi(h,this.mutableData,t.form),t);v&&c.appendChild(v)}if(s.appendChild(c),!n){let h=d("input",{className:"fillo-hp",attrs:{type:"text",name:"fillo_hp_field",tabindex:"-1",autocomplete:"off","aria-hidden":"true"}});h.style.position="absolute",h.style.left="-9999px",h.style.top="auto",h.style.width="1px",h.style.height="1px",h.style.opacity="0",h.style.overflow="hidden",h.style.pointerEvents="none",h.addEventListener("input",()=>{this.hpValue=h.value}),s.appendChild(h)}if(i){let h=d("div",{className:"fillo-turnstile-slot",attrs:{"data-fillo":"turnstile-slot"}});h.appendChild(this.turnstileContainer),this.challengeError&&h.appendChild(d("p",{className:"fillo-turnstile-error",attrs:{role:"alert"},text:L.challengeUnavailable})),s.appendChild(h),this.ensureChallengeWidget(this.challenge)}else(this.turnstileWidgetId!==null||this.turnstileLoadInFlight||this.challengeFrame!==null)&&this.teardownTurnstileWidget();let u=t.status==="error"?"This form can't submit right now. Please try again in a moment.":this.engine?.getState().submitError;if(u){let h=d("p",{className:"fillo-submit-error",attrs:{role:"alert"},text:u}),v=this.devChrome()&&this.resolutionFailureCode==="form_not_published"&&this.syncWarningCode==="storage_required"?Me(this.syncWarningUrl):null;v&&(h.append(" Connect storage: "),h.appendChild(d("a",{text:v,attrs:{href:v,target:"_blank",rel:"noopener noreferrer"}}))),s.appendChild(h)}let p=!(t.form.settings.submitMode==="auto")||!t.isLastPage||Vi(_i(t.form,t.data))||i;if(p||t.pageCount>1&&!t.isFirstPage){let h=d("footer",{className:"fillo-footer",attrs:{"data-fillo":"footer"}});if(t.pageCount>1&&!t.isFirstPage){let v=d("button",{className:"fillo-button fillo-button--ghost",text:"Back",attrs:{type:"button","data-fillo":"button"}});v.addEventListener("click",()=>this.back()),h.appendChild(v)}if(p){let v=d("button",{className:"fillo-button fillo-button--primary",text:t.status==="submitting"?"Submitting...":t.isLastPage?t.form.settings.submitLabel??"Submit":"Next",attrs:{type:"submit","data-fillo":"button"}});v.toggleAttribute("disabled",t.status==="submitting"||this.engine?.getState().uploading===!0||i&&!this.challengeToken),v.addEventListener("click",b=>{b.preventDefault(),a()}),h.appendChild(v)}s.appendChild(h)}return o}fieldRenderer(t){return t.kind==="custom"?this.options.customComponents?.[t.component]??this.options.components?.custom:this.options.components?.[t.kind]??po}renderChildField=t=>this.fieldRenderer(t.field)?.(t)??null;setGroupFocus=t=>{this.focusIntent=t};renderBlock(t,n){if(!X(t))return el(t);let r=(o,a)=>{if(this.setValueInternal(t.id,o,a),a?.render===!1)return;let s={form:n.form,data:n.data,status:n.status,isLastPage:n.isLastPage,uploading:this.engine?.getState().uploading===!0};Hi(t,o,s)&&this.submit()},i={field:t,value:n.data[t.id],error:n.errors[t.id]===lt?Ei(t,T):n.errors[t.id],ids:ao(this.instanceId,t.id),api:n,setValue:r,uploadFiles:(o,a)=>this.uploadFiles(o,a),uploadRows:this.uploadRowsFor(t.id),uploadAction:this.uploadAction,activeOtherFields:this.activeOtherFields,getValue:()=>this.engine?.getState().data[t.id],registerOverlay:this.registerOverlay,uploadNotice:this.uploadNotices.get(t.id),uploadDisabledReason:this.options.renderOnly?"render_only":this.storageBlocked()?"storage_unavailable":void 0,storageFixUrl:this.storageBlocked()&&this.devChrome()?Me(this.syncWarningUrl):null,announce:this.announce,announceAlert:this.announceAlert,instanceId:this.instanceId,renderChildField:this.renderChildField,setGroupFocus:this.setGroupFocus};return this.fieldRenderer(t)?.(i)??null}};function el(e){switch(e.kind){case"heading":return d("h3",{className:"fillo-heading",text:e.text});case"paragraph":return d("p",{className:"fillo-paragraph",text:e.text});case"divider":return d("hr",{className:"fillo-divider"})}return d("div")}function tl(e){let t=d("div",{className:"fillo-form fillo-form--success"}),n=d("div",{className:"fillo-success"});return I(n,[d("div",{className:"fillo-success-mark",attrs:{"aria-hidden":"true"}}),d("h2",{className:"fillo-success-title",text:e.settings.successTitle??"Thanks!"}),d("p",{className:"fillo-success-message",text:e.settings.successMessage??"Your response has been recorded."})]),t.appendChild(n),t}function Kn(e,t){return d("a",{className:"fillo-powered",text:e??"Powered by Fillo",attrs:{href:za(t),target:"_blank",rel:"nofollow noopener noreferrer"}})}function io(e){return e==="expired"||e==="capped"||e==="storage_full"?"closed":"notOpen"}function nl(){return Ji()}function rl(){return d("div",{className:"fillo-devwarning",text:"No Fillo client connected \u2014 this form is render-only and won't save responses. Pass a client to collect them in Fillo, or forward with webhooks. (Shown only in development and preview.)",attrs:{role:"alert"}})}function il(e){return d("div",{className:"fillo-devwarning",text:`Form sync needs attention${e.code?` (${e.code})`:""}: ${e.message} The safe form remains available for development.`,attrs:{role:"alert"}})}function ol(e){let t=d("div",{className:"fillo-devwarning",attrs:{role:"alert"}});t.append("Code changes are staged, not live. This page shows your draft, while respondents still get the live version. ");let n=Me(e);return n?(t.appendChild(d("a",{text:"Review and publish in Fillo",attrs:{href:n,target:"_blank",rel:"noopener noreferrer"}})),t.append(".")):t.append("Review and publish the changes in Fillo."),t}function sl(e,t){let n=d("div",{className:"fillo-devwarning",attrs:{role:"alert"}});n.append("Draft form preview \u2014 the form renders for local testing, but Fillo will reject the submission and save no response until you publish it. ");let r=Me(e),i=Me(t);return r?(n.appendChild(d("a",{text:"Connect storage to publish",attrs:{href:r,target:"_blank",rel:"noopener noreferrer"}})),n.append(". ")):i&&(n.appendChild(d("a",{text:"Open in Fillo to publish",attrs:{href:i,target:"_blank",rel:"noopener noreferrer"}})),n.append(". ")),n.append("(Shown only in development and preview.)"),n}function al(){return d("span",{className:"fillo-preview-badge",text:"Preview",attrs:{"data-fillo":"preview-badge"}})}var oo=!1;function ll(){oo||Gn()||(oo=!0,console.warn("[fillo] `preview` is enabled in a production build. Preview is cosmetic only \u2014 it shows developer chrome and never changes where submissions go or whether they are accepted \u2014 but remove it before respondents see this page."))}function cl(e){let t=[];return e.preview&&t.push(al()),e.devNotices===!1||(e.syncError?t.push(il(e.syncError)):e.staged?t.push(ol(e.formUrl)):e.draft?t.push(sl(e.warningUrl,e.formUrl)):e.noClient&&t.push(rl())),t}function ul(e){return e.status===404?L.loadFailedNotFound:e.status===0?L.loadFailedNetwork:e.status===422?L.renderFailed:L.loadFailed}function so(){return new S("This form has no Fillo target. Pass formId with the schema, use a defineForm() value with client, or set renderOnly for a non-submitting preview.",422,void 0,"form_target_required")}function ft(e){return ee(e)?e:new S(e instanceof Error?e.message:String(e),0)}function Zt(e,t){let n=typeof e=="string"?document.querySelector(e):e;if(!n)throw new S(`Fillo mount target not found: ${String(e)}`,0);let r={...t,initialData:t.initialData??{}};return new mt(n,r)}function fo(e){let t=d("div");return Zt(t,e),t}var dl=typeof HTMLElement<"u"?HTMLElement:class{},Jn=class extends dl{instance=null;assignedForm;assignedClient;assignedTheme;assignedInitialData;mounted=!1;mountScheduled=!1;static get observedAttributes(){return["publishable-key","form-id","data-preview","data-render-only"]}connectedCallback(){this.scheduleMount()}disconnectedCallback(){this.instance?.destroy(),this.instance=null,this.mounted=!1}attributeChangedCallback(){this.mounted&&this.isConnected&&this.scheduleMount()}set form(t){this.assignedForm=t,this.mounted&&this.scheduleMount()}get form(){return this.assignedForm}set client(t){this.assignedClient=t,this.mounted&&this.instance instanceof mt&&this.instance.setClient(t)}set theme(t){this.assignedTheme=t,this.mounted&&this.instance instanceof mt&&this.instance.setTheme(t)}set initialData(t){this.assignedInitialData=t,this.mounted&&this.scheduleMount()}scheduleMount(){this.mountScheduled||(this.mountScheduled=!0,queueMicrotask(()=>{this.mountScheduled=!1,this.isConnected&&this.mount()}))}previewAttrEnabled(){let t=this.getAttribute("data-preview");return t!==null&&t!=="false"&&t!=="0"}renderOnlyAttrEnabled(){let t=this.getAttribute("data-render-only");return t!==null&&t!=="false"&&t!=="0"}mount(){this.instance?.destroy();let t=this.getAttribute("publishable-key")??void 0,n=this.getAttribute("form-id")??void 0,r=this.assignedClient??(n||t?Le({key:t}):void 0);this.instance=Zt(this,{form:this.assignedForm,client:r,formId:n,theme:this.assignedTheme,initialData:this.assignedInitialData,preview:this.previewAttrEnabled()?!0:void 0,renderOnly:this.renderOnlyAttrEnabled()?!0:void 0,onChange:i=>this.dispatchEvent(new CustomEvent("fillo-change",{detail:{data:i}})),onSubmitted:(i,o)=>this.dispatchEvent(new CustomEvent("fillo-submit",{detail:{responseId:i,data:o}})),onError:i=>this.dispatchEvent(new CustomEvent("fillo-error",{detail:{error:i}}))}),this.mounted=!0}};function Yn(e="fillo-form"){typeof customElements>"u"||customElements.get(e)||customElements.define(e,Jn)}typeof customElements<"u"&&Yn();return Ao(pl);})();
1
+ "use strict";var Fillo=(()=>{var Ht=Object.defineProperty;var zo=Object.getOwnPropertyDescriptor;var Fo=Object.getOwnPropertyNames;var Co=Object.prototype.hasOwnProperty;var Io=(e,t)=>{for(var n in t)Ht(e,n,{get:t[n],enumerable:!0})},No=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Fo(t))!Co.call(e,i)&&i!==n&&Ht(e,i,{get:()=>t[i],enumerable:!(r=zo(t,i))||r.enumerable});return e};var To=e=>No(Ht({},"__esModule",{value:!0}),e);var kl={};Io(kl,{FilloClient:()=>Pt,FilloError:()=>S,createClient:()=>Le,createFormElement:()=>wo,defineForm:()=>Hn,registerFilloElement:()=>er,renderForm:()=>Dt});var ar;function F(e,t,n){function r(s,l){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:l,constr:a,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,l);let c=a.prototype,u=Object.keys(c);for(let f=0;f<u.length;f++){let p=u[f];p in s||(s[p]=c[p].bind(s))}}let i=n?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function a(s){var l;let c=n?.Parent?new o:this;r(c,s),(l=c._zod).deferred??(l.deferred=[]);for(let u of c._zod.deferred)u();return c}return Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>n?.Parent&&s instanceof n.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var ve=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(ar=globalThis).__zod_globalConfig??(ar.__zod_globalConfig={});var Gt=globalThis.__zod_globalConfig;function we(e){return e&&Object.assign(Gt,e),Gt}function cr(e){let t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function ur(e,t){return typeof t=="bigint"?t.toString():t}function dr(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw new Error("cached value already set")}}}function Wt(e){return e==null}function pr(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var lr=Symbol("evaluating");function _e(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==lr)return r===void 0&&(r=lr,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}var Kt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function yt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Jt(e){if(yt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(yt(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Xt(e){return Jt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var fr=new Set(["string","number","symbol"]);function We(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Yt(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function G(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function hr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Lo={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ke(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function mr(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function xe(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function vt(e){return typeof e=="string"?e:e?.message}function ke(e,t,n){let r=e.message?e.message:vt(e.inst?._zod.def?.error?.(e))??vt(t?.error?.(e))??vt(n.customError?.(e))??vt(n.localeError?.(e))??"Invalid input",{inst:i,continue:o,input:a,...s}=e;return s.path??(s.path=[]),s.message=r,t?.reportInput&&(s.input=a),s}function Qt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}var gr=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ur,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},br=F("$ZodError",gr),Je=F("$ZodError",gr,{Parent:Error});var Po=e=>(t,n,r,i)=>{let o=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},o);if(a instanceof Promise)throw new ve;if(a.issues.length){let s=new(i?.Err??e)(a.issues.map(l=>ke(l,o,we())));throw Kt(s,i?.callee),s}return a.value},wt=Po(Je),Ro=e=>async(t,n,r,i)=>{let o=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){let s=new(i?.Err??e)(a.issues.map(l=>ke(l,o,we())));throw Kt(s,i?.callee),s}return a.value},_t=Ro(Je),Oo=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new ve;return o.issues.length?{success:!1,error:new(e??br)(o.issues.map(a=>ke(a,i,we())))}:{success:!0,data:o.value}},Xe=Oo(Je),Zo=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(a=>ke(a,i,we())))}:{success:!0,data:o.value}},Ye=Zo(Je);var vr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Do="(?:(?:\\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])))",Uo=new RegExp(`^${Do}$`);var yr=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var en=/^-?\d+(?:\.\d+)?$/;var Fe=F("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Bo={number:"number",bigint:"bigint",object:"date"};var _r=F("$ZodCheckGreaterThan",(e,t)=>{Fe.init(e,t);let n=Bo[typeof t.value];e._zod.onattach.push(r=>{let i=r._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}});var xr=F("$ZodCheckMaxLength",(e,t)=>{var n;Fe.init(e,t),(n=e._zod.def).when??(n.when=r=>{let i=r.value;return!Wt(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{let i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let i=r.value;if(i.length<=t.maximum)return;let a=Qt(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),kr=F("$ZodCheckMinLength",(e,t)=>{var n;Fe.init(e,t),(n=e._zod.def).when??(n.when=r=>{let i=r.value;return!Wt(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{let i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let i=r.value;if(i.length>=t.minimum)return;let a=Qt(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}});var $r=F("$ZodCheckStringFormat",(e,t)=>{var n,r;Fe.init(e,t),e._zod.onattach.push(i=>{let o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})});var Ar={major:4,minor:4,patch:3};var oe=F("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ar;let r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(let i of r)for(let o of i._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,s,l)=>{let c=Ke(a),u;for(let f of s){if(f._zod.def.when){if(mr(a)||!f._zod.def.when(a))continue}else if(c)continue;let p=a.issues.length,m=f._zod.check(a);if(m instanceof Promise&&l?.async===!1)throw new ve;if(u||m instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await m,a.issues.length!==p&&(c||(c=Ke(a,p)))});else{if(a.issues.length===p)continue;c||(c=Ke(a,p))}}return u?u.then(()=>a):a},o=(a,s,l)=>{if(Ke(a))return a.aborted=!0,a;let c=i(s,r,l);if(c instanceof Promise){if(l.async===!1)throw new ve;return c.then(u=>e._zod.parse(u,l))}return e._zod.parse(c,l)};e._zod.run=(a,s)=>{if(s.skipChecks)return e._zod.parse(a,s);if(s.direction==="backward"){let c=e._zod.parse({value:a.value,issues:[]},{...s,skipChecks:!0});return c instanceof Promise?c.then(u=>o(u,a,s)):o(c,a,s)}let l=e._zod.parse(a,s);if(l instanceof Promise){if(s.async===!1)throw new ve;return l.then(c=>i(c,r,s))}return i(l,r,s)}}_e(e,"~standard",()=>({validate:i=>{try{let o=Xe(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return Ye(e,i).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),tn=F("$ZodString",(e,t)=>{oe.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??yr(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),nn=F("$ZodStringFormat",(e,t)=>{$r.init(e,t),tn.init(e,t)});var Cr=F("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=vr),nn.init(e,t)});var Ir=F("$ZodNumber",(e,t)=>{oe.init(e,t),e._zod.pattern=e._zod.bag.pattern??en,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;let o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}});var Nr=F("$ZodUnknown",(e,t)=>{oe.init(e,t),e._zod.parse=n=>n});function Er(e,t,n){e.issues.length&&t.issues.push(...xe(n,e.issues)),t.value[n]=e.value}var Tr=F("$ZodArray",(e,t)=>{oe.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);let o=[];for(let a=0;a<i.length;a++){let s=i[a],l=t.element._zod.run({value:s,issues:[]},r);l instanceof Promise?o.push(l.then(c=>Er(c,n,a))):Er(l,n,a)}return o.length?Promise.all(o).then(()=>n):n}});function xt(e,t,n,r,i,o){let a=n in r;if(e.issues.length){if(i&&o&&!a)return;t.issues.push(...xe(n,e.issues))}if(!a&&!i){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?a&&(t.value[n]=void 0):t.value[n]=e.value}function Vo(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);let n=hr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ho(e,t,n,r,i,o){let a=[],s=i.keySet,l=i.catchall._zod,c=l.def.type,u=l.optin==="optional",f=l.optout==="optional";for(let p in t){if(p==="__proto__"||s.has(p))continue;if(c==="never"){a.push(p);continue}let m=l.run({value:t[p],issues:[]},r);m instanceof Promise?e.push(m.then(h=>xt(h,n,p,t,u,f))):xt(m,n,p,t,u,f)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}var Lr=F("$ZodObject",(e,t)=>{if(oe.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let s=t.shape;Object.defineProperty(t,"shape",{get:()=>{let l={...s};return Object.defineProperty(t,"shape",{value:l}),l}})}let r=dr(()=>Vo(t));_e(e._zod,"propValues",()=>{let s=t.shape,l={};for(let c in s){let u=s[c]._zod;if(u.values){l[c]??(l[c]=new Set);for(let f of u.values)l[c].add(f)}}return l});let i=yt,o=t.catchall,a;e._zod.parse=(s,l)=>{a??(a=r.value);let c=s.value;if(!i(c))return s.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),s;s.value={};let u=[],f=a.shape;for(let p of a.keys){let m=f[p],h=m._zod.optin==="optional",v=m._zod.optout==="optional",b=m._zod.run({value:c[p],issues:[]},l);b instanceof Promise?u.push(b.then(g=>xt(g,s,p,c,h,v))):xt(b,s,p,c,h,v)}return o?Ho(u,c,s,l,r.value,e):u.length?Promise.all(u).then(()=>s):s}});var Mr=F("$ZodRecord",(e,t)=>{oe.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Jt(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;let o=[],a=t.keyType._zod.values;if(a){n.value={};let s=new Set;for(let c of a)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){s.add(typeof c=="number"?c.toString():c);let u=t.keyType._zod.run({value:c,issues:[]},r);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(u.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(m=>ke(m,r,we())),input:c,path:[c],inst:e});continue}let f=u.value,p=t.valueType._zod.run({value:i[c],issues:[]},r);p instanceof Promise?o.push(p.then(m=>{m.issues.length&&n.issues.push(...xe(c,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(...xe(c,p.issues)),n.value[f]=p.value)}let l;for(let c in i)s.has(c)||(l=l??[],l.push(c));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l})}else{n.value={};for(let s of Reflect.ownKeys(i)){if(s==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,s))continue;let l=t.keyType._zod.run({value:s,issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof s=="string"&&en.test(s)&&l.issues.length){let f=t.keyType._zod.run({value:Number(s),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(l=f)}if(l.issues.length){t.mode==="loose"?n.value[s]=i[s]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>ke(f,r,we())),input:s,path:[s],inst:e});continue}let u=t.valueType._zod.run({value:i[s],issues:[]},r);u instanceof Promise?o.push(u.then(f=>{f.issues.length&&n.issues.push(...xe(s,f.issues)),n.value[l.value]=f.value})):(u.issues.length&&n.issues.push(...xe(s,u.issues)),n.value[l.value]=u.value)}}return o.length?Promise.all(o).then(()=>n):n}});var Pr=F("$ZodEnum",(e,t)=>{oe.init(e,t);let n=cr(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(i=>fr.has(typeof i)).map(i=>typeof i=="string"?We(i):i.toString()).join("|")})$`),e._zod.parse=(i,o)=>{let a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:n,input:a,inst:e}),i}}),Rr=F("$ZodLiteral",(e,t)=>{if(oe.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?We(r):r?We(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,i)=>{let o=r.value;return n.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}});function zr(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Or=F("$ZodOptional",(e,t)=>{oe.init(e,t),e._zod.optin="optional",e._zod.optout="optional",_e(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),_e(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${pr(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){let i=n.value,o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(a=>zr(a,i)):zr(o,i)}return n.value===void 0?n:t.innerType._zod.run(n,r)}});var Zr=F("$ZodDefault",(e,t)=>{oe.init(e,t),e._zod.optin="optional",_e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>Fr(o,t)):Fr(i,t)}});function Fr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function Dr(e,t){return new e({type:"string",...G(t)})}function Ur(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...G(t)})}function Br(e,t){return new e({type:"number",checks:[],...G(t)})}function jr(e){return new e({type:"unknown"})}function rn(e,t){return new _r({check:"greater_than",...G(t),value:e,inclusive:!0})}function on(e){return rn(0,e)}function K(e,t){return new xr({check:"max_length",...G(t),maximum:e})}function De(e,t){return new kr({check:"min_length",...G(t),minimum:e})}var de=F("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");oe.init(e,t),e.def=t,e.type=t.type,e.parse=(n,r)=>wt(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>Xe(e,n,r),e.parseAsync=async(n,r)=>_t(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Ye(e,n,r),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]},{parent:!0}),e.with=e.check,e.clone=(n,r)=>Yt(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.apply=n=>n(e)}),Hr=F("ZodMiniString",(e,t)=>{tn.init(e,t),de.init(e,t)});function J(e){return Dr(Hr,e)}var qo=F("ZodMiniStringFormat",(e,t)=>{nn.init(e,t),Hr.init(e,t)}),Wo=F("ZodMiniEmail",(e,t)=>{Cr.init(e,t),qo.init(e,t)});function kt(e){return Ur(Wo,e)}var Ko=F("ZodMiniNumber",(e,t)=>{Ir.init(e,t),de.init(e,t)});function Gr(e){return Br(Ko,e)}var Jo=F("ZodMiniUnknown",(e,t)=>{Nr.init(e,t),de.init(e,t)});function Qe(){return jr(Jo)}var Xo=F("ZodMiniArray",(e,t)=>{Tr.init(e,t),de.init(e,t)});function $e(e,t){return new Xo({type:"array",element:e,...G(t)})}var qr=F("ZodMiniObject",(e,t)=>{Lr.init(e,t),de.init(e,t),_e(e,"shape",()=>t.shape)});function et(e,t){let n={type:"object",shape:e??{},...G(t)};return new qr(n)}function sn(e,t){return new qr({type:"object",shape:e,catchall:Qe(),...G(t)})}var Vr=F("ZodMiniRecord",(e,t)=>{Mr.init(e,t),de.init(e,t)});function Wr(e,t,n){return!t||!t._zod?new Vr({type:"record",keyType:J(),valueType:e,...G(t)}):new Vr({type:"record",keyType:e,valueType:t,...G(n)})}var Yo=F("ZodMiniEnum",(e,t)=>{Pr.init(e,t),de.init(e,t),e.options=Object.values(t.entries)});function Kr(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Yo({type:"enum",entries:n,...G(t)})}var Qo=F("ZodMiniLiteral",(e,t)=>{Rr.init(e,t),de.init(e,t)});function Jr(e,t){return new Qo({type:"literal",values:Array.isArray(e)?e:[e],...G(t)})}var es=F("ZodMiniOptional",(e,t)=>{Or.init(e,t),de.init(e,t)});function ee(e){return new es({type:"optional",innerType:e})}var ts=F("ZodMiniDefault",(e,t)=>{Zr.init(e,t),de.init(e,t)});function an(e,t){return new ts({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Xt(t)}})}var is=200,os=["heading","paragraph","divider"];function X(e){return!os.includes(e.kind)}function Lt(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:typeof e=="boolean"?e===!1:typeof e=="object"?Object.keys(e).length===0:!1}function ss(e,t){if(!Array.isArray(t))return;let n=new Map(e.fields.map(o=>[o.id,o])),r=!1,i=t.map(o=>{if(!o||typeof o!="object"||Array.isArray(o))return o;let a=!1,s={};for(let[l,c]of Object.entries(o)){let u=n.get(l);if(!u){a=!0;continue}let f=yi(u,c);if(f===void 0){a=!0;continue}s[l]=f,f!==c&&(a=!0)}return a?(r=!0,s):o});return r?i:t}function vi(e,t){if(t==null||e.kind==="custom")return t;if(e.kind==="repeating_group")return ss(e,t);if(e.kind==="number"&&typeof t=="string"&&t.trim()!==""){let n=Number(t);return Number.isNaN(n)?t:n}if((e.kind==="rating"||e.kind==="linear_scale")&&typeof t=="string"){let n=Number(t);return Number.isNaN(n)?t:n}return typeof t=="string"?t.trim():t}function yi(e,t){let n=vi(e,t);return Lt(n)?void 0:n}function wi(e){return e===void 0||!Number.isFinite(e)?0:Math.max(0,Math.min(6,Math.round(e)))}function _i(e,t){let n=10**t,r=Math.round(Math.abs(e)*n)/n;return e<0?-r:r}function Ie(e){return Number.isFinite(e)?e:null}function Be(e,t){switch(e.op){case"value":return kn(t(e.fieldId));case"const":return Ie(e.value);case"add":case"mul":case"min":case"max":{if(e.args.length===0)return null;let n=[];for(let r of e.args){let i=Be(r,t);if(i===null)return null;n.push(i)}return e.op==="add"?Ie(n.reduce((r,i)=>r+i,0)):e.op==="mul"?Ie(n.reduce((r,i)=>r*i,1)):e.op==="min"?Math.min(...n):Math.max(...n)}case"sub":case"div":{let n=Be(e.left,t);if(n===null)return null;let r=Be(e.right,t);return r===null?null:e.op==="sub"?Ie(n-r):r===0?null:Ie(n/r)}case"round":{let n=Be(e.arg,t);return n===null?null:Ie(_i(n,wi(e.decimals)))}case"if":return Be(Nn(e.when,t)?e.then:e.else,t)}}function as(e,t){let n=Be(e.calc,t);return n===null||e.decimals===void 0?n:Ie(_i(n,wi(e.decimals)))}function Ce(e,t){let n=me(e);if(!n.some(s=>s.kind==="calculated"))return t;let r=t,i=Sn(e,r);for(let s=0;s<=n.length;s++){let l={},c=!1;for(let[u,f]of Object.entries(r))i.has(u)?l[u]=f:c=!0;if(!c)break;r=l,i=Sn(e,r)}let o=it(n,r),a={};for(let[s,l]of Object.entries(t))o.calcIds.has(s)||(a[s]=l);for(let[s,l]of Object.entries(o.calc))i.has(s)&&(a[s]=l);return a}function ln(e){return e==null?!1:typeof e=="string"?e.trim()!=="":Array.isArray(e)?e.length>0:typeof e=="boolean"?e:typeof e=="object"?Object.keys(e).length>0:!0}function Xr(e,t){return e===t?!0:typeof e=="number"&&typeof t=="string"&&t.trim()!==""?Number(t)===e:typeof t=="number"&&typeof e=="string"&&e.trim()!==""?Number(e)===t:!1}function kn(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e!="string"||e.trim()==="")return null;let t=Number(e);return Number.isFinite(t)?t:null}function ls(e,t){let n=t(e.fieldId);switch(e.op){case"answered":return ln(n);case"not_answered":return!ln(n);case"eq":return Array.isArray(n)?n.some(r=>r===e.value):Xr(n,e.value);case"neq":return ln(n)?Array.isArray(n)?!n.some(r=>r===e.value):!Xr(n,e.value):!1;case"contains":return typeof n=="string"?n.toLowerCase().includes(String(e.value??"").toLowerCase()):Array.isArray(n)?n.some(r=>r===e.value):!1;case"gt":case"lt":{let r=kn(n),i=kn(e.value);return r!==null&&i!==null&&(e.op==="gt"?r>i:r<i)}}}function Nn(e,t){return e.length===0?!0:e.every(n=>ls(n,t))}function xi(e,t){return!e.visibleIf||e.visibleIf.length===0?!0:Nn(e.visibleIf,t)}function cn(e,t,n,r,i,o){return a=>n.has(a)?r.has(a)?i.has(a)?o[a]:e[a]:void 0:t[a]}function it(e,t){let n=new Set(e.map(l=>l.id)),r=e.filter(l=>l.kind==="calculated"),i=new Set(r.map(l=>l.id)),o={};for(let l of e){if(l.kind==="calculated")continue;let c=yi(l,t[l.id]);c!==void 0&&(l.kind==="repeating_group"&&(Array.isArray(c)?c.length:0)<Math.max(1,l.minInstances??1)||(o[l.id]=c))}let a=n,s={};for(let l=0;l<=e.length;l++){let c=s;if(r.length>0){c={...s};let m=cn(o,t,n,a,i,c);for(let h of r){let v=a.has(h.id)?as(h,m):null;v===null?delete c[h.id]:c[h.id]=v}}let u=cn(o,t,n,a,i,c),f=new Set;for(let m of e)xi(m,u)&&f.add(m.id);let p=f.size===a.size&&[...f].every(m=>a.has(m))&&cs(s,c);if(a=f,s=c,p)break}return{visible:a,calc:s,calcIds:i,resolve:cn(o,t,n,a,i,s)}}function cs(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(r=>e[r]===t[r])}function ki(e,t){return it(e,t).visible}function $t(e,t,n){let r=it(me(e),n);return t.blocks.filter(i=>X(i)?r.visible.has(i.id):xi(i,r.resolve))}function me(e){return e.pages.flatMap(t=>t.blocks.filter(X))}function $i(e,t){let n=e.responseLimit?.scopeField;if(!n)return null;let r=t[n];return typeof r=="number"?Number.isFinite(r)?String(r):null:typeof r!="string"?null:r.trim()||null}function Si(e,t){let n=me(e),r=ki(n,t);return n.filter(i=>r.has(i.id))}function Tn(e,t){let n=t&&typeof t=="object"&&!Array.isArray(t)?t:{},r=it(e.fields,n);return e.fields.filter(i=>r.visible.has(i.id))}function us(e,t){return it(me(e),t).resolve}function Ai(e,t,n){let i=e.pages.find(a=>a.id===t)?.next;if(!i||i.length===0)return{linear:!0};let o=us(e,n);for(let a of i)if(Nn(a.when,o))return a.to==="end"?{end:!0}:{to:a.to};return{linear:!0}}function je(e,t,n){let r=[];if(e.pages.length===0)return r;let i=new Set,o=n===void 0?0:e.pages.findIndex(a=>a.id===n);for(let a=0;a<=e.pages.length;a++){let s=e.pages[o];if(!s||i.has(s.id))break;i.add(s.id),r.push(s.id);let l=Ai(e,s.id,t);if("end"in l)break;if("to"in l){let c=e.pages.findIndex(u=>u.id===l.to);if(c<0)break;o=c}else if(o+=1,o>=e.pages.length)break}return r}function ds(e,t){return new Set(je(e,t))}function $n(e,t,n){if("end"in Ai(e,t,n))return!0;let r=je(e,n);return r.length>0&&r[r.length-1]===t}function Sn(e,t){let n=ds(e,t),r=ki(me(e),t),i=new Set;for(let o of e.pages)if(n.has(o.id))for(let a of o.blocks)X(a)&&r.has(a.id)&&i.add(a.id);return i}function Ei(e,t){let n=Sn(e,t);return me(e).filter(r=>n.has(r.id))}var Ue;function ps(){if(Ue!==void 0)return Ue??void 0;if(typeof Intl>"u"||typeof Intl.DisplayNames>"u"){Ue=null;return}try{Ue=new Intl.DisplayNames(void 0,{type:"region"})}catch{Ue=null}return Ue??void 0}function zi(e){try{return ps()?.of(e)??e}catch{return e}}var w=(e,t,n=[],r=[],i="")=>({iso2:e,name:zi(e),dialCode:t,lengths:n,groups:r,example:i}),fs=[w("US","1",[10],[3,3,4],"2015550123"),w("CA","1",[10],[3,3,4],"5145550123"),w("GB","44",[10],[4,6],"7400123456"),w("AU","61",[9],[3,3,3],"412345678"),w("DE","49",[10,11],[4,7],"15123456789"),w("FR","33",[9],[1,2,2,2,2],"612345678"),w("IN","91",[10],[5,5],"8123456789"),w("DK","45",[8],[2,2,2,2],"32123456"),w("SE","46",[9],[2,3,4],"701234567"),w("NO","47",[8],[3,2,3],"40612345"),w("FI","358",[9,10],[2,3,4],"412345678"),w("NL","31",[9],[1,4,4],"612345678"),w("BE","32",[9],[3,2,2,2],"470123456"),w("ES","34",[9],[3,3,3],"612345678"),w("IT","39",[9,10],[3,3,4],"3123456789"),w("PT","351",[9],[3,3,3],"912345678"),w("IE","353",[9],[2,3,4],"851234567"),w("CH","41",[9],[2,3,2,2],"781234567"),w("AT","43",[10,11],[3,7],"6641234567"),w("PL","48",[9],[3,3,3],"512345678"),w("CZ","420",[9],[3,3,3],"601123456"),w("GR","30",[10],[3,3,4],"6912345678"),w("RO","40",[9],[3,3,3],"712345678"),w("HU","36",[9],[2,3,4],"201234567"),w("UA","380",[9],[2,3,2,2],"501234567"),w("RU","7",[10],[3,3,2,2],"9123456789"),w("TR","90",[10],[3,3,2,2],"5012345678"),w("IL","972",[9],[2,3,4],"501234567"),w("AE","971",[9],[2,3,4],"501234567"),w("SA","966",[9],[2,3,4],"512345678"),w("ZA","27",[9],[2,3,4],"711234567"),w("NG","234",[10],[3,3,4],"8021234567"),w("KE","254",[9],[3,3,3],"712123456"),w("EG","20",[10],[3,3,4],"1001234567"),w("BR","55",[10,11],[2,5,4],"11961234567"),w("MX","52",[10],[3,3,4],"2221234567"),w("AR","54",[10],[4,6],"1123456789"),w("CL","56",[9],[1,4,4],"221234567"),w("CO","57",[10],[3,3,4],"3211234567"),w("PE","51",[9],[3,3,3],"912345678"),w("CN","86",[11],[3,4,4],"13123456789"),w("JP","81",[10],[2,4,4],"9012345678"),w("KR","82",[9,10],[2,4,4],"1023456789"),w("SG","65",[8],[4,4],"81234567"),w("HK","852",[8],[4,4],"51234567"),w("TW","886",[9],[3,3,3],"912345678"),w("MY","60",[9,10],[2,3,4],"123456789"),w("ID","62",[10,11],[3,4,4],"81234567890"),w("TH","66",[9],[2,3,4],"812345678"),w("PH","63",[10],[3,3,4],"9171234567"),w("VN","84",[9],[3,3,3],"912345678"),w("PK","92",[10],[3,3,4],"3012345678"),w("BD","880",[10],[2,4,4],"1812345678"),w("NZ","64",[9,10],[2,3,4],"211234567"),w("SK","421",[9],[3,3,3],"912123456"),w("BG","359",[9],[2,3,4],"481234567"),w("HR","385",[8,9],[2,3,4],"921234567"),w("RS","381",[8,9],[2,3,4],"601234567"),w("SI","386",[8],[2,3,3],"31234567"),w("LT","370",[8],[3,2,3],"61234567"),w("LV","371",[8],[2,3,3],"21234567"),w("EE","372",[7,8],[3,4],"51234567"),w("IS","354",[7],[3,4],"6111234"),w("LU","352",[9],[3,3,3],"628123456"),w("MA","212",[9],[3,3,3],"650123456"),w("CR","506",[8],[4,4],"83123456"),w("EC","593",[9],[2,3,4],"991234567"),w("UY","598",[8],[1,3,4],"94231234"),w("QA","974",[8],[4,4],"33123456"),w("KW","965",[8],[4,4],"50012345")],hs="AD376 AF93 AG1 AI1 AL355 AM374 AO244 AS1 AW297 AX358 AZ994 BA387 BB1 BF226 BH973 BI257 BJ229 BL590 BM1 BN673 BO591 BQ599 BS1 BT975 BV47 BW267 BY375 BZ501 CC61 CD243 CF236 CG242 CI225 CK682 CM237 CU53 CV238 CW599 CX61 CY357 DJ253 DM1 DO1 DZ213 EH212 ER291 ET251 FJ679 FK500 FM691 FO298 GA241 GD1 GE995 GF594 GG44 GH233 GI350 GL299 GM220 GN224 GP590 GQ240 GS500 GT502 GU1 GW245 GY592 HN504 HT509 IM44 IO246 IQ964 IR98 JE44 JM1 JO962 KG996 KH855 KI686 KM269 KN1 KP850 KY1 KZ7 LA856 LB961 LC1 LI423 LK94 LR231 LS266 LY218 MC377 MD373 ME382 MF590 MG261 MH692 MK389 ML223 MM95 MN976 MO853 MP1 MQ596 MR222 MS1 MT356 MU230 MV960 MW265 MZ258 NA264 NC687 NE227 NF672 NI505 NP977 NR674 NU683 OM968 PA507 PF689 PG675 PM508 PN64 PR1 PS970 PW680 PY595 RE262 RW250 SB677 SC248 SD249 SH290 SJ47 SL232 SM378 SN221 SO252 SR597 SS211 ST239 SV503 SX1 SY963 SZ268 TC1 TD235 TF262 TG228 TJ992 TK690 TL670 TM993 TN216 TO676 TT1 TV688 TZ255 UG256 UZ998 VA379 VC1 VE58 VG1 VI1 VU678 WF681 WS685 XK383 YE967 YT262 ZM260 ZW263";function ms(e){let t=[];for(let n of e.trim().split(/\s+/)){let r=n.slice(0,2),i=n.slice(2);t.push({iso2:r,name:zi(r),dialCode:i,lengths:[],groups:[],example:""})}return t}var ot=[...fs,...ms(hs)],Ve=gs(ot);function gs(e){if(typeof Intl>"u"||typeof Intl.Collator>"u")return[...e].sort((n,r)=>n.iso2<r.iso2?-1:n.iso2>r.iso2?1:0);let t=new Intl.Collator(void 0,{sensitivity:"base"});return[...e].sort((n,r)=>t.compare(n.name,r.name))}var bs=new Map(ot.map(e=>[e.iso2,e])),vs={"Africa/Cairo":"EG","Africa/Casablanca":"MA","Africa/Johannesburg":"ZA","Africa/Lagos":"NG","Africa/Nairobi":"KE","America/Adak":"US","America/Anchorage":"US","America/Argentina/Buenos_Aires":"AR","America/Argentina/Cordoba":"AR","America/Argentina/Mendoza":"AR","America/Bahia":"BR","America/Belem":"BR","America/Bogota":"CO","America/Boise":"US","America/Boa_Vista":"BR","America/Cancun":"MX","America/Chicago":"US","America/Chihuahua":"MX","America/Campo_Grande":"BR","America/Costa_Rica":"CR","America/Cuiaba":"BR","America/Denver":"US","America/Detroit":"US","America/Edmonton":"CA","America/Fortaleza":"BR","America/Guayaquil":"EC","America/Halifax":"CA","America/Hermosillo":"MX","America/Indiana/Indianapolis":"US","America/Indianapolis":"US","America/Juneau":"US","America/Kentucky/Louisville":"US","America/Lima":"PE","America/Los_Angeles":"US","America/Maceio":"BR","America/Manaus":"BR","America/Matamoros":"MX","America/Mazatlan":"MX","America/Merida":"MX","America/Mexico_City":"MX","America/Moncton":"CA","America/Monterrey":"MX","America/Montevideo":"UY","America/New_York":"US","America/Noronha":"BR","America/Nome":"US","America/North_Dakota/Center":"US","America/Ojinaga":"MX","America/Phoenix":"US","America/Porto_Velho":"BR","America/Punta_Arenas":"CL","America/Recife":"BR","America/Regina":"CA","America/Rio_Branco":"BR","America/Santiago":"CL","America/Sao_Paulo":"BR","America/Sitka":"US","America/St_Johns":"CA","America/Tijuana":"MX","America/Toronto":"CA","America/Vancouver":"CA","America/Whitehorse":"CA","America/Winnipeg":"CA","America/Yakutat":"US","Asia/Bangkok":"TH","Asia/Calcutta":"IN","Asia/Dacca":"BD","Asia/Dhaka":"BD","Asia/Dubai":"AE","Asia/Hong_Kong":"HK","Asia/Ho_Chi_Minh":"VN","Asia/Jakarta":"ID","Asia/Jerusalem":"IL","Asia/Karachi":"PK","Asia/Kolkata":"IN","Asia/Kuala_Lumpur":"MY","Asia/Kuwait":"KW","Asia/Manila":"PH","Asia/Qatar":"QA","Asia/Riyadh":"SA","Asia/Seoul":"KR","Asia/Shanghai":"CN","Asia/Saigon":"VN","Asia/Singapore":"SG","Asia/Taipei":"TW","Asia/Tel_Aviv":"IL","Asia/Tokyo":"JP","Asia/Urumqi":"CN","Atlantic/Reykjavik":"IS","Australia/Adelaide":"AU","Australia/Brisbane":"AU","Australia/Darwin":"AU","Australia/Hobart":"AU","Australia/Melbourne":"AU","Australia/Perth":"AU","Australia/Sydney":"AU","Europe/Amsterdam":"NL","Europe/Athens":"GR","Europe/Belgrade":"RS","Europe/Berlin":"DE","Europe/Bratislava":"SK","Europe/Brussels":"BE","Europe/Bucharest":"RO","Europe/Budapest":"HU","Europe/Copenhagen":"DK","Europe/Dublin":"IE","Europe/Helsinki":"FI","Europe/Zagreb":"HR","Europe/Istanbul":"TR","Europe/Kiev":"UA","Europe/Kyiv":"UA","Europe/Lisbon":"PT","Europe/Ljubljana":"SI","Europe/London":"GB","Europe/Luxembourg":"LU","Europe/Madrid":"ES","Europe/Moscow":"RU","Europe/Oslo":"NO","Europe/Paris":"FR","Europe/Prague":"CZ","Europe/Riga":"LV","Europe/Rome":"IT","Europe/Sofia":"BG","Europe/Stockholm":"SE","Europe/Tallinn":"EE","Europe/Vienna":"AT","Europe/Vilnius":"LT","Europe/Warsaw":"PL","Europe/Zurich":"CH","Pacific/Auckland":"NZ"};function Ln(e){let t=e.toUpperCase();return/^[A-Z]{2}$/.test(t)?String.fromCodePoint(...[...t].map(n=>127462+n.charCodeAt(0)-65)):"\u{1F3F3}\uFE0F"}function Mt(e){return e?bs.get(e.toUpperCase()):void 0}function Fi(e){return Mt(e?vs[e]:void 0)}function ys(e){let t;for(let n of ot)e.startsWith(n.dialCode)&&(!t||n.dialCode.length>t.dialCode.length)&&(t=n);return t}function he(e){return e.replace(/[^\d]/g,"")}function st(e,t){let n=he(t);if(!n)return"";let r=e?.groups?.length?e.groups:[],i=[],o=0;for(let a of r){if(o>=n.length)break;i.push(n.slice(o,o+a)),o+=a}for(;o<n.length;)i.push(n.slice(o,o+3)),o+=3;return i.join(" ")}function Ci(e,t){let n=he(t);return n?`+${e.dialCode}${n}`:""}function at(e,t,n){let r=(e??"").trim(),i=r.startsWith("+"),o=he(r);if(i){if(!o)return{national:"",e164:"",pending:!0,raw:r};let a=n?.previousDigits?he(n.previousDigits):"";if(a&&o===a)return{national:o,e164:`+${o}`,pending:!0,raw:r};let s=ys(o);if(s){let l=o.slice(s.dialCode.length);return{country:s,national:l,e164:`+${o}`}}return{national:o,e164:`+${o}`,pending:!0,raw:r}}if(!o)return{country:t,national:"",e164:""};if(t){let a=o.startsWith(t.dialCode)?o.slice(t.dialCode.length):o;return{country:t,national:a,e164:`+${t.dialCode}${a}`}}return{national:o,e164:`+${o}`}}function ws(e){let{country:t,national:n,e164:r}=at(e);if(!r)return!1;let i=he(r).length;return i<8||i>15?!1:t?.lengths.length?t.lengths.includes(n.length):n.length>=4}var _s=8;function Ii(e,t){if(!e||!t||typeof window>"u")return"below";let n=_s,r=document.documentElement.clientWidth||window.innerWidth,i=document.documentElement.clientHeight||window.innerHeight,o=e.getBoundingClientRect(),a=Math.max(0,i-o.bottom-n),s=Math.max(0,o.top-n),l=a<t.scrollHeight&&s>a?"above":"below",u=Math.max(0,Math.min(l==="above"?s:a,i-n*2)),f=Math.max(0,r-n*2);t.style.setProperty("--fillo-phone-popover-max-height",`${Math.floor(u)}px`),t.style.setProperty("--fillo-phone-popover-max-width",`${Math.floor(f)}px`),t.style.setProperty("--fillo-phone-popover-offset-x","0px");let p=Math.min(t.offsetWidth,f),h=getComputedStyle(e).direction==="rtl"?o.right-p:o.left,v=0,b=h+p-(r-n);b>0&&(v-=b);let g=n-(h+v);return g>0&&(v+=g),t.style.setProperty("--fillo-phone-popover-offset-x",`${Math.round(v)}px`),l}var lt="This field is required",T={back:"Back",next:"Next",submit:"Submit",submitting:"Submitting\u2026",uploading:"Uploading\u2026",optional:" (optional)",other:"Other",otherPrompt:"Other \u2014 please specify",otherPlaceholder:"Your answer",choosePlaceholder:"Choose\u2026",successTitle:"Thanks!",successMessage:"Your response has been recorded.",closed:"This form is no longer accepting responses.",notLive:"This form isn't live yet.",notOpenTitle:"This form isn't open yet",notOpenBody:"The form owner is still setting things up. Please check back soon.",closedTitle:"Responses are closed",submitFailed:"This form can't submit right now. Please try again in a moment.",loadFailedNotFound:"Form not found. Check the link or ask the form owner for help.",loadFailedNetwork:"Couldn't reach the server \u2014 check your connection and try again.",loadFailed:"This form could not be loaded.",renderFailed:"This form could not be rendered.",resumeNotice:"Picked up where you left off.",editNotice:"You're updating your earlier response.",resumeStartOver:"Start over",challengeUnavailable:"The verification check couldn't load. Refresh the page and try again."},Yr={submitFailed:T.submitFailed,loadFailedNotFound:T.loadFailedNotFound,loadFailedNetwork:T.loadFailedNetwork,formUnavailable:"This form is unavailable.",formClosed:T.closed,submitRateLimited:"Too many responses are being submitted right now. Wait a moment, then try again.",respondentUnrecognized:"This form couldn't verify who is responding. Ask the form owner for help.",fileUnavailable:"One of the uploaded files is no longer available. Remove it and upload it again.",scopeMissing:"We couldn't tell which entry this response belongs to. Answer the required field and try again.",challengeIncomplete:"Please complete the verification check, then submit.",challengeRetry:"That verification didn't go through. Please complete the check again and resubmit.",reviewAnswers:"We couldn't submit \u2014 please review your answers."};var xs={short_text:"Enter your answer",long_text:"Enter your answer",email:"Enter an email address",url:"Enter a URL",phone:"Enter a phone number",number:"Enter a number",select:"Choose an option",dropdown:"Choose an option",multi_select:"Select at least one option",checkbox:"Select this checkbox",rating:"Choose a rating",linear_scale:"Choose a value",ranking:"Rank every option",matrix:"Answer every row",signature:"Add your signature",date:"Enter a date",file_upload:"Add a file"};function ks(e){return xs[e.kind]??lt}var M={previewSkip:"Skip",required:lt,requiredForField:ks,resumeLinkExpired:"That saved-progress link expired or was already used \u2014 start again below.",alreadyAnswered:"You've already answered this form.",uploadRetry:"Retry",uploadCancel:"Cancel",uploadRemove:"Remove",uploadDismiss:"Dismiss",uploadingFile:(e,t)=>`Uploading \xB7 ${e}% \xB7 ${t}`,uploadedFile:e=>`Uploaded \xB7 ${e}`,uploadsDisabled:"Connect this form to Fillo to enable uploads",uploadsRenderOnly:"Uploads are unavailable in this render-only preview",uploadsUnavailable:"Uploads are temporarily unavailable",uploadUnavailable:"We couldn't upload this file right now. Try again in a moment.",uploadFailed:"Upload failed \u2014 try again",dropzoneTitle:e=>`Drop ${e?"files":"a file"} here or click to browse`,dropzoneHint:e=>`Up to ${e} MB per file`,fileTooLarge:e=>`Larger than ${e} MB limit`,filesUploading:e=>`Uploading ${e} ${e===1?"file":"files"}, please wait\u2026`,uploadsFailed:e=>`${e} ${e===1?"upload":"uploads"} failed.`,filesUploaded:e=>`${e} ${e===1?"file":"files"} uploaded.`,submittingAnnouncement:"Submitting your response\u2026",errorSummaryTitle:"Check these fields",rankingPosition:(e,t,n)=>`${e}, position ${t} of ${n}`,groupAdd:"Add another",groupInstanceLabel:(e,t,n)=>`${e} ${t} of ${n}`,groupRemoveLabel:(e,t)=>`Remove ${e} ${t}`,groupInstanceAdded:(e,t,n)=>`${e} ${t} added, ${t} of ${n}`,groupInstanceRemoved:(e,t)=>t===0?`${e} removed, none left`:`${e} removed, ${t} remaining`,phoneCountrySelected:e=>`${e} selected`,phoneResultsCount:e=>`${e} ${e===1?"result":"results"}`,signatureEmpty:"No signature yet",signatureSigned:"Signature saved"};function Ni(e,t){return t.requiredForField?.(e)??t.required}var $s=et({fileId:J().check(De(1)),name:J(),size:Gr().check(on()),mime:J(),url:ee(J())});function un(e,t){let n=Math.max(0,e.minInstances??1);return t<n?`Add at least ${n} ${n===1?"entry":"entries"}`:Number.isFinite(e.maxInstances)&&t>e.maxInstances?`At most ${e.maxInstances} ${e.maxInstances===1?"entry":"entries"}`:null}function Tt(e,t){if(Lt(t))return e.kind==="calculated"?null:e.kind==="repeating_group"?un(e,0):e.required?lt:null;switch(e.kind){case"short_text":case"long_text":{if(typeof t!="string")return"Expected text";if(e.maxLength&&t.length>e.maxLength)return`Must be at most ${e.maxLength} characters`;let n=e.kind==="long_text"?2e4:2e3;return!e.maxLength&&t.length>n?"Answer is too long":null}case"email":return typeof t!="string"?"Enter a valid email address":e.maxLength&&t.length>e.maxLength?`Must be at most ${e.maxLength} characters`:kt().safeParse(t).success?null:"Enter a valid email address";case"url":{if(typeof t!="string")return"Enter a valid URL (including https://)";if(e.maxLength&&t.length>e.maxLength)return`Must be at most ${e.maxLength} characters`;try{let n=new URL(t);if(n.protocol!=="http:"&&n.protocol!=="https:")return"Enter an http(s) URL"}catch{return"Enter a valid URL (including https://)"}return null}case"phone":return typeof t!="string"||!ws(t)?"Enter a valid phone number":null;case"number":{let n=typeof t=="string"?Number(t):t;return typeof n!="number"||!Number.isFinite(n)?"Enter a number":e.min!==void 0&&n<e.min?`Must be at least ${e.min}`:e.max!==void 0&&n>e.max?`Must be at most ${e.max}`:null}case"select":case"dropdown":return typeof t!="string"||t===""?"Pick an option":e.options.some(n=>n.id===t)||e.allowOther&&t.length<=500?null:"Pick a valid option";case"multi_select":{if(!Array.isArray(t))return"Pick at least one option";let n=new Set(e.options.map(a=>a.id)),r=t,i=0,o=new Set;for(let a of r){if(typeof a!="string")return"Pick valid options";if(o.has(a))return"Pick each option only once";if(o.add(a),!n.has(a)){if(e.allowOther!==!0||a.length===0||a.length>500)return"Pick valid options";if(++i>1)return"Only one 'Other' answer is allowed"}}return null}case"checkbox":return typeof t=="boolean"?null:"Invalid value";case"rating":{let n=e.max??5,r=typeof t=="string"?Number(t):t;return typeof r!="number"||!Number.isInteger(r)||r<1||r>n?`Pick a rating between 1 and ${n}`:null}case"linear_scale":{let n=e.min??1,r=e.max??10,i=typeof t=="string"?Number(t):t;return typeof i!="number"||!Number.isInteger(i)||i<n||i>r?`Pick a value between ${n} and ${r}`:null}case"ranking":{if(!Array.isArray(t))return"Drag the options into order";let n=e.options.map(i=>i.id).sort(),r=[...t].sort();return n.length!==r.length||n.some((i,o)=>i!==r[o])?"Rank every option":null}case"matrix":{if(typeof t!="object"||t===null||Array.isArray(t))return"Answer the grid";let n=t,r=new Set(e.columns.map(o=>o.id)),i=new Set(e.rows.map(o=>o.id));for(let[o,a]of Object.entries(n))if(!i.has(o)||!r.has(a))return"Invalid grid answer";return e.required&&Object.keys(n).length<e.rows.length?"Answer every row":null}case"signature":return typeof t!="string"||!t.startsWith("data:image/")?"Sign in the box":null;case"hidden":return typeof t=="string"?null:"Invalid value";case"calculated":return null;case"repeating_group":{if(!Array.isArray(t))return un(e,0);let n=t;for(let r of n)if(!r||typeof r!="object"||Array.isArray(r))return"Invalid value";return un(e,n.length)}case"custom":return null;case"date":{if(typeof t!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(t))return"Enter a valid date";let[n,r,i]=t.split("-").map(Number),o=new Date(Date.UTC(n,r-1,i));return o.getUTCFullYear()!==n||o.getUTCMonth()!==r-1||o.getUTCDate()!==i?"Enter a valid date":null}case"file_upload":{let n=$e($s).safeParse(t);if(!n.success)return"Upload did not complete";let r=e.maxFiles??1;return n.data.length>r?`At most ${r} file${r===1?"":"s"}`:null}}}function Ti(e,t){let n=Ei(e,t),r={},i={};for(let o of n){if(o.kind==="calculated")continue;let a=vi(o,t[o.id]);if(o.kind==="repeating_group"){Ss(o,a,r,i);continue}let s=Tt(o,a);s?r[o.id]=s:Lt(a)||(i[o.id]=a)}return{ok:Object.keys(r).length===0,errors:r,data:i}}function Ss(e,t,n,r){let i=Tt(e,t);if(i&&(n[e.id]=i),!Array.isArray(t))return;let o=t,a=[];for(let s=0;s<o.length;s++){let l=o[s];if(!l||typeof l!="object"||Array.isArray(l))continue;let c={};for(let u of Tn(e,l)){let f=l[u.id],p=Tt(u,f);p?n[`${e.id}.${s}.${u.id}`]=p:Lt(f)||(c[u.id]=f)}a.push(c)}!i&&a.length>0&&(r[e.id]=a)}var As=["short_text","long_text","email","url","phone","number","select","multi_select","dropdown","checkbox","rating","linear_scale","ranking","matrix","signature","date","file_upload","hidden","calculated","repeating_group","custom"],Es=["heading","paragraph","divider"],zs=[...As,...Es],Mn=J().check(De(1),K(128)),dn=sn({id:Mn,label:J().check(K(1e3)),icon:ee(Qe())}),Fs=sn({id:Mn,kind:Kr(zs),label:ee(J().check(K(2e3))),options:ee($e(dn).check(K(200))),rows:ee($e(dn).check(K(200))),columns:ee($e(dn).check(K(200)))}),Cs=et({id:Mn,title:ee(J().check(K(500))),blocks:$e(Fs).check(K(500)),next:ee(Qe())}),Is=et({version:Jr(1),title:an(ee(J().check(K(2e3))),""),description:ee(J().check(K(5e3))),pages:$e(Cs).check(De(1),K(50)),settings:an(ee(Wr(J(),Qe())),{})}),Ns=1,An=1,En="0.26.0";function se(e,t,n=""){return typeof e=="string"?e.trim().slice(0,t):n}function B(e,t){let n=se(e,t);return n===""?void 0:n}function St(e,t){if(typeof e!="string")return;let n=e.slice(0,t);return n.trim()===""?void 0:n}function ye(e){return typeof e=="boolean"?e:void 0}function ae(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function fe(e,t,n,r){let i=ae(e);return i===void 0?r:Math.max(t,Math.min(n,Math.round(i)))}function At(e,t=200){return Array.isArray(e)?e.slice(0,t).flatMap(n=>{if(!n||typeof n!="object")return[];let r=n,i=se(r.id,128),o=se(r.label,1e3),a=r.icon==="thumbs_up"||r.icon==="thumbs_down"?r.icon:void 0;return i&&o?[P({id:i,label:o,icon:a})]:[]}):[]}function Nt(e){let t=new Set;for(let{id:n}of e){if(t.has(n))return n;t.add(n)}}function Pn(e){if(!Array.isArray(e))return;let t=e.slice(0,20).flatMap(n=>{if(!n||typeof n!="object")return[];let r=n,i=r.op;if(i!=="eq"&&i!=="neq"&&i!=="contains"&&i!=="gt"&&i!=="lt"&&i!=="answered"&&i!=="not_answered")return[];let o=se(r.fieldId,128);if(!o)return[];let a=r.value,s=typeof a=="string"||typeof a=="number"||typeof a=="boolean"?a:void 0;return[{fieldId:o,op:i,...s!==void 0?{value:s}:{}}]});return t.length?t:void 0}function Li(e,t,n,r){let i=t.get(e);if(i===void 0)return n.has(e);if(r.has(e))return!0;r.add(e);for(let o of i)if(!Li(o,t,n,r))return!1;return!0}function Ts(e,t,n,r,i){if(!Array.isArray(e))return;let o=e.slice(0,50).flatMap(a=>{if(!a||typeof a!="object")return[];let s=a,l=typeof s.to=="string"?s.to:void 0;if(!l||l!=="end"&&!t.has(l))return[];if(l===n)return[];let c=s.when;if(c!==void 0&&!Array.isArray(c))return[];let u=Pn(c);return Array.isArray(c)&&c.length>0&&u===void 0?[]:u&&u.some(f=>!Li(f.fieldId,i,r,new Set))?[]:[{when:u??[],to:l}]});return o.length?o:void 0}var Ls=["number","rating","linear_scale","calculated"];function Ae(e,t=0){if(t>32||!e||typeof e!="object"||Array.isArray(e))return null;let n=e;switch(n.op){case"value":{let r=se(n.fieldId,128);return r?{op:"value",fieldId:r}:null}case"const":{let r=ae(n.value);return r===void 0?null:{op:"const",value:r}}case"add":case"mul":case"min":case"max":{if(!Array.isArray(n.args)||n.args.length<1||n.args.length>50)return null;let r=[];for(let i of n.args){let o=Ae(i,t+1);if(!o)return null;r.push(o)}return{op:n.op,args:r}}case"sub":case"div":{let r=Ae(n.left,t+1),i=Ae(n.right,t+1);return r&&i?{op:n.op,left:r,right:i}:null}case"round":{let r=Ae(n.arg,t+1);return r?P({op:"round",arg:r,decimals:ae(n.decimals)===void 0?void 0:fe(n.decimals,0,6,0)}):null}case"if":{if(!Array.isArray(n.when))return null;let r=Pn(n.when)??[];if(r.length!==n.when.length)return null;let i=Ae(n.then,t+1),o=Ae(n.else,t+1);return i&&o?{op:"if",when:r,then:i,else:o}:null}default:return null}}function Ee(e,t,n){switch(e.op){case"value":t.add(e.fieldId);return;case"const":return;case"add":case"mul":case"min":case"max":for(let r of e.args)Ee(r,t,n);return;case"sub":case"div":Ee(e.left,t,n),Ee(e.right,t,n);return;case"round":Ee(e.arg,t,n);return;case"if":for(let r of e.when)n.add(r.fieldId);Ee(e.then,t,n),Ee(e.else,t,n);return}}function Ms(e,t){let n=new Map;for(let a of e)for(let s of a.blocks)X(s)&&n.set(s.id,s.kind);let r=new Map;for(let a of e)for(let s of a.blocks){if(s.kind!=="calculated")continue;let l=Ae(s.calc);if(!l)return`Field ${s.id} has a malformed calc expression \u2014 build it from value/const/add/sub/mul/div/min/max/round/if nodes`;s.calc=l;let c=new Set,u=new Set;Ee(l,c,u);for(let f of c){let p=n.get(f);if(p===void 0){let m=t.get(f);return m!==void 0?`Calculated field ${s.id} references ${f}, which is a child of repeating group ${m} \u2014 calculations can't reach inside a repeating group (calc operands must be top-level fields)`:`Calculated field ${s.id} references a missing field: ${f} \u2014 remove the reference or restore that field`}if(!Ls.includes(p))return`Calculated field ${s.id} references non-numeric field ${f} (${p}) \u2014 calculations can read number, rating, linear_scale, and calculated fields only`}r.set(s.id,[...c,...u].filter(f=>n.get(f)==="calculated"))}let i=new Map,o=(a,s)=>{let l=i.get(a);if(l==="done")return null;if(l==="visiting"){let c=[...s.slice(s.indexOf(a)),a].join(" \u2192 ");return`Calculated field ${a} depends on its own result (${c}) \u2014 break the cycle so the value can be computed`}i.set(a,"visiting");for(let c of r.get(a)??[]){let u=o(c,[...s,a]);if(u)return u}return i.set(a,"done"),null};for(let a of r.keys()){let s=o(a,[]);if(s)return s}return null}var Qr=100,ei=5e3;function Ne(e){switch(e.op){case"value":case"const":return 1;case"add":case"mul":case"min":case"max":return 1+e.args.reduce((t,n)=>t+Ne(n),0);case"sub":case"div":return 1+Ne(e.left)+Ne(e.right);case"round":return 1+Ne(e.arg);case"if":return 1+Ne(e.then)+Ne(e.else)}}function Ps(e){let t=0,n=0;for(let r of e)for(let i of r.blocks)i.kind==="calculated"&&(t+=1,n+=Ne(i.calc));return t>Qr?`Form has ${t} calculated fields \u2014 the maximum is ${Qr}; remove some or consolidate them into fewer expressions`:n>ei?`Calculated expressions total ${n} operations \u2014 the maximum is ${ei} across the form; simplify or split up the calculations`:null}var ti=["short_text","long_text","email","url","phone","number","select","multi_select","dropdown","checkbox","date","rating","linear_scale"],ni=12,ri=18e4;function Rs(e){let t=e.id.length+20;switch(e.kind){case"short_text":case"email":case"url":return t+(e.maxLength??2e3);case"long_text":return t+(e.maxLength??2e4);case"phone":return t+32;case"number":return t+32;case"select":case"dropdown":{let n=e.options.reduce((r,i)=>Math.max(r,i.id.length),0);return t+Math.max(n,e.allowOther?500:0)}case"multi_select":{let n=e.options.reduce((r,i)=>r+i.id.length+3,0);return t+n+(e.allowOther?500:0)}case"checkbox":return t+8;case"date":return t+16;case"rating":case"linear_scale":return t+8;default:return t+64}}function Os(e){return e.fields.reduce((n,r)=>n+Rs(r),24)*(Number.isFinite(e.maxInstances)?e.maxInstances:0)}function Zs(e){for(let t of e)for(let n of t.blocks){if(n.kind!=="repeating_group")continue;if(!Number.isInteger(n.maxInstances)||n.maxInstances<1||n.maxInstances>20)return`Repeating group ${n.id} needs maxInstances to be a whole number between 1 and 20`;let r=n.minInstances??1;if(!Number.isInteger(r)||r<0||r>n.maxInstances)return`Repeating group ${n.id} needs minInstances to be a whole number between 0 and maxInstances (${n.maxInstances})`;if(n.minInstances=r,n.fields.length===0)return`Repeating group ${n.id} has no template fields \u2014 add at least one field to repeat`;if(n.fields.length>ni)return`Repeating group ${n.id} has ${n.fields.length} template fields \u2014 the maximum is ${ni}; split it into fewer fields`;for(let s of n.fields)if(!ti.includes(s.kind))return`Repeating group ${n.id} has a "${s.kind}" child (${s.id}) \u2014 allowed child kinds are ${ti.join(", ")}`;let i=Nt(n.fields);if(i)return`Duplicate child id in repeating group ${n.id}: ${i}`;let o=new Set(n.fields.map(s=>s.id));for(let s of n.fields)for(let l of s.visibleIf??[])if(!o.has(l.fieldId))return`Field ${s.id} in repeating group ${n.id} has a visibleIf referencing "${l.fieldId}" \u2014 a child's visibleIf can only reference another field in the SAME group`;let a=Os(n);if(a>ri)return`Repeating group ${n.id} could reach ~${Math.ceil(a/1e3)}KB at ${n.maxInstances} instances \u2014 the maximum is ~${Math.round(ri/1e3)}KB; lower maxInstances, shorten text limits, or trim the template`}return null}function Ds(e){let t=new Set;for(let r of e)for(let i of r.blocks)X(i)&&t.add(i.id);let n=new Map;for(let r of e)for(let i of r.blocks)if(i.kind==="repeating_group")for(let o of i.fields)!t.has(o.id)&&!n.has(o.id)&&n.set(o.id,i.id);return n}function Us(e,t,n){for(let r of e)for(let i of r.blocks)for(let o of i.visibleIf??[]){let a=n.get(o.fieldId);if(a!==void 0)return`Field ${i.id}'s visibleIf references "${o.fieldId}", which is a child of repeating group ${a} \u2014 fields outside a repeating group can't reference its children`}for(let r of t)if(Array.isArray(r.next))for(let i of r.next){if(!i||typeof i!="object")continue;let o=i.when;if(Array.isArray(o))for(let a of o){if(!a||typeof a!="object")continue;let s=a.fieldId;if(typeof s!="string")continue;let l=n.get(s);if(l!==void 0)return`A jump rule on page ${r.id} references "${s}", which is a child of repeating group ${l} \u2014 jumps can't reference a repeating group's children`}}return null}function Mi(e){return{id:se(e.id,128),visibleIf:Pn(e.visibleIf)}}function V(e,t){return{...Mi(e),kind:t,label:se(e.label,2e3,"Untitled field"),description:B(e.description,5e3),required:ye(e.required),placeholder:B(e.placeholder,500)}}function ii(e){let t=B(e,2e3);if(t)try{let n=new URL(t);return n.protocol==="http:"||n.protocol==="https:"?t:void 0}catch{return}}function Bs(e){if(!e||typeof e!="object")return;let t=e,n=t.by==="browser"||t.by==="field"||t.by==="identify"||t.by==="email"?t.by:void 0;if(!n)return;let r=n==="field"?B(t.field,128):void 0;if(n==="field"&&!r)return;let i=B(t.scopeField,128),o=t.onRepeat==="update"&&(n==="identify"||n==="email")?"update":"keep";return{by:n,...r?{field:r}:{},...i?{scopeField:i}:{},onRepeat:o}}function js(e){if(!e||typeof e!="object")return;let t=e,n=t.unverified==="allow"||t.unverified==="quarantine"?t.unverified:void 0,r=t.challenge==="turnstile"?"turnstile":void 0;if(!(!n&&!r))return{...n?{unverified:n}:{},...r?{challenge:r}:{}}}function Vs(e){let t=e&&typeof e=="object"?e:{};return{submitMode:t.submitMode==="button"||t.submitMode==="auto"?t.submitMode:void 0,submitLabel:B(t.submitLabel,100),successTitle:B(t.successTitle,200),successMessage:B(t.successMessage,5e3),redirectUrl:ii(t.redirectUrl),showProgress:ye(t.showProgress),responseLimit:Bs(t.responseLimit),trust:js(t.trust),notifyEmail:kt().check(K(254)).safeParse(t.notifyEmail).success?t.notifyEmail:void 0,sendReceipt:ye(t.sendReceipt),saveProgress:ye(t.saveProgress),draftAnswersVisible:ye(t.draftAnswersVisible),resumeEmails:ye(t.resumeEmails),resumeUrl:ii(t.resumeUrl),draftDigest:ye(t.draftDigest)}}function P(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function Pi(e){if(!e||typeof e!="object")return null;let t=e,n=t.kind,r=Mi(t);if(!r.id||typeof n!="string")return null;switch(n){case"heading":return P({...r,kind:n,text:se(t.text,2e3,"Section")});case"paragraph":return P({...r,kind:n,text:se(t.text,5e3)});case"divider":return P({...r,kind:n});case"short_text":case"email":case"url":return P({...V(t,n),maxLength:ae(t.maxLength)===void 0?void 0:fe(t.maxLength,1,2e3,2e3)});case"phone":{let i=B(t.defaultCountry,2)?.toUpperCase();return P({...V(t,n),defaultCountry:i&&/^[A-Z]{2}$/.test(i)?i:void 0})}case"long_text":return P({...V(t,n),maxLength:ae(t.maxLength)===void 0?void 0:fe(t.maxLength,1,2e4,2e4)});case"number":return P({...V(t,n),min:ae(t.min),max:ae(t.max),decimals:ae(t.decimals)===void 0?void 0:fe(t.decimals,0,6,0),prefix:St(t.prefix,100),suffix:St(t.suffix,100),notation:t.notation==="grouped"?"grouped":t.notation==="grouped-comma"?"grouped-comma":t.notation==="grouped-dot"?"grouped-dot":void 0});case"select":case"multi_select":case"dropdown":{let i=At(t.options);return i.length===0?null:P({...V(t,n),options:i,allowOther:ye(t.allowOther),shuffleOptions:ye(t.shuffleOptions)})}case"checkbox":{let i=t.appearance==="toggle"?"toggle":void 0;return P({...V(t,n),appearance:i})}case"signature":return P(V(t,n));case"date":return P({...V(t,n),defaultToday:t.defaultToday===!0?!0:void 0});case"rating":{let i=fe(t.max,1,10,5);return P({...V(t,n),max:i,insightsMetric:t.insightsMetric==="csat"&&i===5?"csat":void 0})}case"linear_scale":{let i=fe(t.min,0,9,1),o=fe(t.max,i+1,10,10),a=t.insightsMetric==="nps"&&i===0&&o===10?"nps":t.insightsMetric==="csat"&&i===1&&o===5?"csat":void 0;return P({...V(t,n),min:i,max:o,minLabel:B(t.minLabel,100),maxLabel:B(t.maxLabel,100),insightsMetric:a})}case"ranking":{let i=At(t.options);return i.length<2?null:P({...V(t,n),options:i})}case"matrix":{let i=At(t.rows),o=At(t.columns);return i.length===0||o.length===0?null:P({...V(t,n),rows:i,columns:o})}case"hidden":return P({...V(t,n),required:!1,paramName:B(t.paramName,128),defaultValue:B(t.defaultValue,1e3)});case"calculated":return P({...V(t,n),required:!1,calc:t.calc,decimals:ae(t.decimals)===void 0?void 0:fe(t.decimals,0,6,0),prefix:St(t.prefix,100),suffix:St(t.suffix,100)});case"file_upload":return P({...V(t,n),maxFiles:fe(t.maxFiles,1,is,1),maxFileSizeMb:fe(t.maxFileSizeMb,1,5e3,500),accept:Array.isArray(t.accept)?t.accept.flatMap(i=>{let o=B(i,100);return o?[o]:[]}).slice(0,50):void 0});case"repeating_group":{let o=(Array.isArray(t.fields)?t.fields:[]).slice(0,50).flatMap(a=>{let s=Pi(a);return s&&X(s)?[s]:[]});return P({...V(t,n),required:!1,fields:o,maxInstances:ae(t.maxInstances)??Number.NaN,minInstances:ae(t.minInstances),addLabel:B(t.addLabel,100),itemLabel:B(t.itemLabel,100)})}case"custom":return P({...V(t,n),component:se(t.component,128),config:t.config&&typeof t.config=="object"&&!Array.isArray(t.config)?t.config:void 0});default:return null}}function Te(e){let t=Is.safeParse(e);if(!t.success){let b=t.error.issues[0],g=b?.path.join(".");return{ok:!1,error:b?`${g?`${g}: `:""}${b.message}`:"Invalid schema"}}if(t.data.version>Ns)return{ok:!1,error:`Unsupported schema version: ${t.data.version}`};let n=t.data.pages.map(b=>{let g=b.blocks.flatMap(A=>{let E=Pi(A);return E?[E]:[]});return{id:se(b.id,128),title:B(b.title,500),blocks:g,next:b.next}}),r=new Set(n.map(b=>b.id)),i=new Map;for(let b of n)for(let g of b.blocks){if(g.kind!=="calculated")continue;let A=new Set,E=Ae(g.calc);if(E){let R=new Set,re=new Set;Ee(E,R,re);for(let W of R)A.add(W);for(let W of re)A.add(W)}i.set(g.id,A)}let o=new Set,a=n.map(b=>{for(let g of b.blocks)X(g)&&o.add(g.id);return P({id:b.id,title:b.title,blocks:b.blocks,next:Ts(b.next,r,b.id,new Set(o),i)})}),s=new Set,l=new Set;for(let b of a){if(!b.id)return{ok:!1,error:"Page ids cannot be blank"};if(s.has(b.id))return{ok:!1,error:`Duplicate page id: ${b.id}`};s.add(b.id);for(let g of b.blocks){if(l.has(g.id))return{ok:!1,error:`Duplicate block id: ${g.id}`};if(l.add(g.id),g.kind==="number"&&g.min!==void 0&&g.max!==void 0&&g.min>g.max)return{ok:!1,error:`Field ${g.id} has min greater than max`};if(g.kind==="select"||g.kind==="multi_select"||g.kind==="dropdown"||g.kind==="ranking"){let A=Nt(g.options);if(A)return{ok:!1,error:`Duplicate option id in field ${g.id}: ${A}`}}else if(g.kind==="matrix"){let A=Nt(g.rows);if(A)return{ok:!1,error:`Duplicate matrix row id in field ${g.id}: ${A}`};let E=Nt(g.columns);if(E)return{ok:!1,error:`Duplicate matrix column id in field ${g.id}: ${E}`}}}}let c=Zs(a);if(c)return{ok:!1,error:c};let u=Ds(a),f=Us(a,n,u);if(f)return{ok:!1,error:f};let p=Ms(a,u);if(p)return{ok:!1,error:p};let m=Ps(a);if(m)return{ok:!1,error:m};if(a.every(b=>b.blocks.length===0))return{ok:!1,error:"Schema must contain at least one valid block"};let h={version:An,title:se(t.data.title,2e3),pages:a,settings:Vs(t.data.settings)},v=B(t.data.description,5e3);return v&&(h.description=v),{ok:!0,schema:h}}function rt(e,t){let n=B(e,t);if(n&&!(/[;{}<>]/.test(n)||/url\s*\(/i.test(n)))return n}function Hs(e){return typeof e=="string"&&/^[A-Za-z0-9_-]{8,64}$/.test(e)?e:void 0}function oi(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,n=P({primary:rt(t.primary,200),background:rt(t.background,200),text:rt(t.text,200),logo:Hs(t.logo)});return Object.keys(n).length>0?n:void 0}function Ri(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,n=t.colorScheme==="light"||t.colorScheme==="dark"||t.colorScheme==="auto"?t.colorScheme:void 0,r=P({colorScheme:n,...oi(t),radius:rt(t.radius,64),fontFamily:rt(t.fontFamily,200),dark:oi(t.dark)});return Object.keys(r).length>0?r:null}function Gs(e){throw new Error(`Unhandled field kind: ${JSON.stringify(e)}`)}function Rn(e,t){if(t==null||t==="")return"";switch(e.kind){case"file_upload":return Array.isArray(t)?t.map(n=>n.name).join(", "):String(t);case"select":case"dropdown":return e.options.find(n=>n.id===t)?.label??String(t);case"multi_select":return Array.isArray(t)?t.map(n=>e.options.find(r=>r.id===n)?.label??n).join(", "):String(t);case"ranking":return Array.isArray(t)?t.map((n,r)=>`${r+1}. ${e.options.find(i=>i.id===n)?.label??n}`).join(", "):String(t);case"matrix":{if(typeof t!="object"||t===null||Array.isArray(t))return String(t);let n=t;return e.rows.filter(r=>n[r.id]).map(r=>`${r.label}: ${e.columns.find(i=>i.id===n[r.id])?.label??""}`).join(", ")}case"signature":return typeof t=="string"&&t.startsWith("data:image/")?"\u270D signed":"";case"checkbox":return t===!0?"Yes":"No";case"rating":case"linear_scale":return String(t);case"number":{let n=typeof t=="number"?t:Number(t);if(!Number.isFinite(n))return String(t);let r=e.decimals===void 0?String(n):n.toFixed(Math.max(0,Math.min(6,e.decimals)));return`${e.prefix??""}${r}${e.suffix??""}`}case"calculated":{let n=typeof t=="number"?t:Number(t);if(!Number.isFinite(n))return String(t);let r=e.decimals===void 0?String(n):n.toFixed(Math.max(0,Math.min(6,e.decimals)));return`${e.prefix??""}${r}${e.suffix??""}`}case"repeating_group":{if(!Array.isArray(t))return String(t);let n=t;if(n.length===0)return"";let r=e.itemLabel??e.label,i=`${n.length} \xD7 ${r}`,o=e.fields[0];if(!o)return i;let a=n.map(s=>s&&typeof s=="object"&&!Array.isArray(s)?Rn(o,s[o.id]):"").filter(s=>s!=="");return a.length>0?`${i}: ${a.join(", ")}`:i}case"phone":{let{country:n,national:r,e164:i}=at(String(t));if(!i)return String(t);let o=st(n,r),a=n?`+${n.dialCode}`:i.replace(r,"");return o?`${a} ${o}`:i}case"short_text":case"long_text":case"email":case"url":case"date":case"hidden":return String(t);case"custom":return typeof t=="object"?JSON.stringify(t):String(t);default:return Gs(e)}}function qs(e){return Math.max(0,Math.min(6,Math.round(e)))}function Oi(e){switch(e){case"grouped-comma":return"en-US";case"grouped-dot":return"de-DE";case"grouped":case void 0:return}}function Zi(e,t){if(!Number.isFinite(e))return String(e);let n=t?.decimals===void 0?void 0:qs(t.decimals);if(typeof Intl>"u")return n===void 0?String(e):e.toFixed(n);let r={useGrouping:!0};return n===void 0?r.maximumFractionDigits=20:(r.minimumFractionDigits=n,r.maximumFractionDigits=n),new Intl.NumberFormat(t?.locale,r).format(e)}function Di(e,t){return t?e.split(t).join(""):e}function si(e,t){return t==="."?e:e.split(t).join(".")}function Ws(e,t,n){if(n!==t&&e.includes(n)){let o=e.lastIndexOf(n),a=Di(e.slice(0,o),t),s=e.slice(o+n.length);return`${a}.${s}`}let r=e.split(t);return r.length===1?e:r.every((o,a)=>a===0?/^[1-9]\d{0,2}$/.test(o):/^\d{3}$/.test(o))?r.join(""):`${r.slice(0,-1).join("")}.${r.at(-1)??""}`}function On(e,t){if(typeof Intl>"u"||e.trim()==="")return e;let n=new Intl.NumberFormat(t).formatToParts(12345678e-1),r=n.find(s=>s.type==="group")?.value??",",i=n.find(s=>s.type==="decimal")?.value??".",o=e.trim(),a=o.startsWith("-");return a&&(o=o.slice(1)),/^\s$/.test(r)?o=si(o.replace(/\s/g,""),i):r==="."||r===","?o=Ws(o,r,i):o=si(Di(o,r),i),o===""||o==="."||!/^\d*\.?\d*$/.test(o)?e:a?`-${o}`:o}function ct(e,t){let r=e.startsWith("-")?e.slice(1):e;if(r.includes("-"))return!1;if(r==="")return!0;if(typeof Intl>"u")return/^[\d.,]*$/.test(r);let i=new Intl.NumberFormat(t).formatToParts(12345678e-1),o=i.find(f=>f.type==="group")?.value??",",a=i.find(f=>f.type==="decimal")?.value??".",s=o===".",l=/^\s$/.test(o),c=s?[a]:Array.from(new Set([".",a])),u=0;for(let f of r)if(!/\d/.test(f)){if(c.includes(f)){if(++u>1)return!1;continue}if(!(l?/\s/.test(f):f===o))return!1}return!0}var zn="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",Ks=256-256%zn.length;function ai(e=12){if(!Number.isSafeInteger(e)||e<=0)throw new RangeError("createId size must be a positive safe integer");let t=globalThis.crypto;if(typeof t>"u"||typeof t.getRandomValues!="function")throw new Error("createId requires Web Crypto (globalThis.crypto.getRandomValues)");let n="";for(;n.length<e;){let r=new Uint8Array(e);t.getRandomValues(r);for(let i=0;i<e&&n.length<e;i++){let o=r[i];o<Ks&&(n+=zn[o%zn.length])}}return n}var Ui=class{h0=1732584193;h1=4023233417;h2=2562383102;h3=271733878;h4=3285377520;block=new Uint8Array(64);blockLen=0;totalLen=0;w=new Int32Array(80);update(e){this.totalLen+=e.length;let t=0;if(this.blockLen>0){for(;t<e.length&&this.blockLen<64;)this.block[this.blockLen++]=e[t++];this.blockLen===64&&(this.process(this.block),this.blockLen=0)}for(;t+64<=e.length;)this.process(e.subarray(t,t+64)),t+=64;for(;t<e.length;)this.block[this.blockLen++]=e[t++];return this}digest(){let e=Math.floor(this.totalLen/536870912),t=this.totalLen*8>>>0,n=[128],r=this.blockLen+1;for(;r%64!==56;)n.push(0),r++;n.push(e>>>24&255,e>>>16&255,e>>>8&255,e&255),n.push(t>>>24&255,t>>>16&255,t>>>8&255,t&255),this.update(new Uint8Array(n));let i=new Uint8Array(20),o=[this.h0,this.h1,this.h2,this.h3,this.h4];for(let a=0;a<5;a++)i[a*4]=o[a]>>>24&255,i[a*4+1]=o[a]>>>16&255,i[a*4+2]=o[a]>>>8&255,i[a*4+3]=o[a]&255;return i}process(e){let t=this.w;for(let s=0;s<16;s++)t[s]=e[s*4]<<24|e[s*4+1]<<16|e[s*4+2]<<8|e[s*4+3];for(let s=16;s<80;s++){let l=t[s-3]^t[s-8]^t[s-14]^t[s-16];t[s]=l<<1|l>>>31}let n=this.h0,r=this.h1,i=this.h2,o=this.h3,a=this.h4;for(let s=0;s<80;s++){let l,c;s<20?(l=r&i|~r&o,c=1518500249):s<40?(l=r^i^o,c=1859775393):s<60?(l=r&i|r&o|i&o,c=2400959708):(l=r^i^o,c=3395469782);let u=(n<<5|n>>>27)+l+a+c+t[s]|0;a=o,o=i,i=r<<30|r>>>2,r=n,n=u}this.h0=this.h0+n|0,this.h1=this.h1+r|0,this.h2=this.h2+i|0,this.h3=this.h3+o|0,this.h4=this.h4+a|0}},Et="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Zn(e){let t="";for(let n=0;n<e.length;n+=3){let r=e[n],i=n+1<e.length?e[n+1]:0,o=n+2<e.length?e[n+2]:0;t+=Et[r>>2],t+=Et[(r&3)<<4|i>>4],t+=n+1<e.length?Et[(i&15)<<2|o>>6]:"=",t+=n+2<e.length?Et[o&63]:"="}return t}var Js=e=>Zn(new Ui().update(e).digest()),S=class extends Error{constructor(e,t,n,r){super(e),this.status=t,this.retryAfterSec=n,this.code=r,this.name="FilloError"}status;retryAfterSec;code};function te(e){return e instanceof Error&&e.name==="FilloError"}async function li(e,t){try{let n=await e.json();return{message:typeof n.error=="string"&&n.error?n.error:t,code:typeof n.code=="string"&&n.code?n.code:void 0}}catch{}return{message:t}}function pn(e){let t=Number(e.headers.get("retry-after"));return Number.isFinite(t)&&t>0?t:void 0}var tt=3,Xs=4,nt=3e4,Ys=5*6e4,pe=10*6e4;function ci(e,t){return t?.throwIfAborted(),new Promise((n,r)=>{let i=()=>{clearTimeout(o),r(t?.reason)},o=setTimeout(()=>{t?.removeEventListener("abort",i),n()},e);t?.addEventListener("abort",i,{once:!0})})}function fn(e,t=!1){let n=te(e)?e.status??0:0;return n===0||n===503||n===504||t&&n===409&&te(e)&&e.retryAfterSec!==void 0}function zt(e){return e>=500||e===429||e===408}function ui(e){return typeof DOMException<"u"&&e instanceof DOMException&&e.name==="TimeoutError"?new S("Request timed out",0):e}function Qs(e,t){let n=e.split(".").map(i=>Number(i)||0),r=t.split(".").map(i=>Number(i)||0);for(let i=0;i<Math.max(n.length,r.length);i++){let o=(n[i]??0)-(r[i]??0);if(o!==0)return o}return 0}function ea(e){if(e.schemaVersion!==void 0&&e.schemaVersion!==An)throw new S(`This form uses schema version ${e.schemaVersion}; this SDK supports version ${An}. Update @usefillo/* to render it.`,426);if(e.minSdkVersion&&Qs(En,e.minSdkVersion)<0)throw new S(`This form requires @usefillo/* ${e.minSdkVersion} or newer. Current SDK is ${En}.`,426)}function Ft(e,t){return n=>t.onProgress?.({uploadedBytes:n,totalBytes:e,fraction:e===0?1:n/e})}async function ta(e){let t=globalThis.crypto?.subtle;if(t){let n=await t.digest("SHA-1",e);return Zn(new Uint8Array(n))}return Js(e)}var na="https://fillo.so",di={"X-Fillo-Client":`@usefillo/core@${En}`},Pt=class{baseUrl;fetch;activeUploads=0;uploadQueue=new Set;key;constructor(e={}){this.baseUrl=e.baseUrl?e.baseUrl.replace(/\/$/,""):e.sameOrigin?"":na,this.key=e.key,this.fetch=e.fetch??((...t)=>globalThis.fetch(...t))}url(e){return`${this.baseUrl}/api/v1${e}`}async json(e,t){let n=t?.body!=null?{"Content-Type":"application/json",...di,...t?.headers}:t?.headers,r;try{r=await this.fetch(this.url(e),{...t,headers:n,signal:t?.signal??AbortSignal.timeout(nt)})}catch(i){throw ui(i)}if(!r.ok){let{message:i,code:o}=await li(r,`Request failed: ${r.status}`);throw new S(i,r.status,pn(r),o)}return await r.json()}async getForm(e){let t=await this.json(`/forms/${encodeURIComponent(e)}`);return ea(t),t}syncForm(e,t,n){if(!this.key)return Promise.reject(new S("createClient needs a `key` (pk_\u2026) to sync code-defined forms",401));let r=Te(t);return r.ok?this.json("/forms/sync",{method:"POST",body:JSON.stringify({key:this.key,id:e,schema:r.schema,theme:Ri(n)})}):Promise.reject(new S(`Invalid form schema: ${r.error}`,400))}async submit(e,t,n){let r;try{r=await this.fetch(this.url(`/forms/${encodeURIComponent(e)}/responses`),{method:"POST",headers:{"Content-Type":"application/json",...di},body:JSON.stringify({data:t,meta:n}),signal:AbortSignal.timeout(nt)})}catch(o){throw ui(o)}if(r.status===422){let o=await r.json().catch(()=>null);if(o?.errors&&typeof o.errors=="object"&&!Array.isArray(o.errors))return{ok:!1,errors:o.errors};throw new S(typeof o?.error=="string"&&o.error?o.error:"Submit failed: 422",422,pn(r),typeof o?.code=="string"&&o.code?o.code:void 0)}if(!r.ok){let{message:o,code:a}=await li(r,`Submit failed: ${r.status}`);throw new S(o,r.status,pn(r),a)}let i=await r.json();return{ok:!0,responseId:i.id,duplicate:i.duplicate,updated:i.updated}}async fetchOwnResponse(e,t,n){try{return await this.json(`/forms/${encodeURIComponent(e)}/respondent-response`,{method:"POST",body:JSON.stringify({respondent:t,scopeValue:n})})}catch(r){if(te(r)&&(r.status===404||r.status===403))return null;throw r}}async startSession(e,t){try{let n=await this.fetch(this.url(`/forms/${encodeURIComponent(e)}/sessions`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pageCount:t}),signal:AbortSignal.timeout(nt)});return n.ok?(await n.json()).id:null}catch{return null}}reportProgress(e,t){try{this.fetch(this.url(`/sessions/${encodeURIComponent(e)}/progress`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),keepalive:!0,signal:AbortSignal.timeout(nt)}).catch(()=>{})}catch{}}createDraft(e,t){return this.json(`/forms/${encodeURIComponent(e)}/drafts`,{method:"POST",body:JSON.stringify(t)})}getDraft(e,t,n){return this.json(`/drafts/${encodeURIComponent(e)}`,{headers:n?{"X-Fillo-Draft-Token":t,"X-Fillo-Draft-Adopt":"1"}:{"X-Fillo-Draft-Token":t}})}async saveDraft(e,t,n,r){await this.json(`/drafts/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"X-Fillo-Draft-Token":t},body:JSON.stringify(n),...r?.keepalive?{keepalive:!0}:{}})}async deleteDraft(e,t){await this.json(`/drafts/${encodeURIComponent(e)}`,{method:"DELETE",headers:{"X-Fillo-Draft-Token":t}})}getUploadSession(e,t,n=AbortSignal.timeout(pe)){return this.json(`/uploads/${encodeURIComponent(e)}`,{...t?{headers:{"X-Fillo-Upload-Token":t}}:{},signal:n})}async uploadFile(e,t,n){await this.acquireUploadSlot(n.signal);try{return n.signal?.throwIfAborted(),await this.performUpload(e,t,n)}finally{this.activeUploads-=1;let r=this.uploadQueue.values().next().value;r&&(this.uploadQueue.delete(r),r())}}async acquireUploadSlot(e){if(e?.throwIfAborted(),this.activeUploads<Xs){this.activeUploads+=1;return}await new Promise((t,n)=>{let r=()=>{e?.removeEventListener("abort",i),this.activeUploads+=1,t()},i=()=>{this.uploadQueue.delete(r),n(e?.reason)};this.uploadQueue.add(r),e?.addEventListener("abort",i,{once:!0})})}async performUpload(e,t,n){let r=typeof File<"u"&&t instanceof File?t.name:"upload.bin",i=(t.type||"application/octet-stream").trim().toLowerCase(),o;if(n.sessionId){let c=await this.getUploadSession(n.sessionId,n.uploadToken,this.uploadSignal(n,pe));if(c.formId!==e||c.fieldId!==n.fieldId||c.fileName!==r||c.size!==t.size||c.mime.trim().toLowerCase()!==i)throw new S("File does not match this upload session",400);o=c,o.token||=n.uploadToken}else{let c=ai(24),u=ai(32),f=()=>this.json(`/forms/${encodeURIComponent(e)}/uploads`,{method:"POST",body:JSON.stringify({requestId:c,uploadToken:u,fieldId:n.fieldId,fileName:r,size:t.size,mime:i}),signal:this.uploadSignal(n,pe)}),p=Date.now()+pe,m=250;for(;;)try{o=await f();break}catch(h){if(n.signal?.aborted||!fn(h,!0))throw h;let v=p-Date.now();if(v<=0)throw h;await ci(Math.min(m,v),n.signal),m=Math.min(m*2,5e3)}}if(n.onSession?.({sessionId:o.id,uploadToken:o.token}),o.status==="complete"&&o.file)return o.file;if(o.status==="aborted")throw new S("This upload session was cancelled",409);let a;if(o.transport?.type==="gdrive")await this.driveUploadLoop(o,o.transport.uploadUrl,t,n);else if(o.transport?.type==="s3-multipart")await this.s3MultipartUploadLoop(o,t,n);else if(o.transport?.type==="s3-put")await this.s3PutUpload(o.transport.uploadUrl,t,n);else if(o.transport?.type==="box")a=await this.boxUpload(o.transport,t,n);else throw new S("This form's storage doesn't support uploads \u2014 connect Drive, S3, or Box.");let s=()=>this.json(`/uploads/${encodeURIComponent(o.id)}/complete`,{method:"POST",headers:o.token?{"X-Fillo-Upload-Token":o.token}:void 0,...a?{body:JSON.stringify(a)}:{},signal:this.uploadSignal(n,pe)}),l;try{l=await s()}catch(c){if(n.signal?.aborted||!fn(c))throw c;let u=Date.now()+pe,f=250;for(;;){let p=await this.getUploadSession(o.id,o.token,this.uploadSignal(n,Math.max(1,u-Date.now())));if(p.status==="complete"&&p.file)return p.file;if(p.status==="aborted")throw c;try{l=await s();break}catch(h){if(n.signal?.aborted||!fn(h,!0))throw h}let m=u-Date.now();if(m<=0)throw c;await ci(Math.min(f,m),n.signal),f=Math.min(f*2,5e3)}}if(!l.file)throw new S("Upload completed but no file was returned");return l.file}async boxUpload(e,t,n){let r=Ft(t.size,n);r(0);let i={Authorization:`Bearer ${e.token}`};if(e.mode==="simple"){let p=new FormData;p.append("attributes",JSON.stringify({name:e.fileName,parent:{id:e.folderId}})),p.append("file",t,e.fileName);let m=await this.retry(n,async()=>{let v=await this.fetch(e.uploadUrl,{method:"POST",headers:i,body:p,signal:this.uploadSignal(n)});if(!v.ok&&zt(v.status))throw new S(`Box upload failed: ${v.status}`,v.status);return v});if(!m.ok)throw new S(`Box upload failed: ${m.status}`,m.status);let h=await m.json();return r(t.size),{providerFileId:h.entries?.[0]?.id}}if(e.size!==t.size)throw new S(`File size changed since the upload was requested (${t.size} vs ${e.size}).`,400);let o=await this.retry(n,async()=>{let p=await this.fetch(e.sessionUrl,{method:"POST",headers:{...i,"Content-Type":"application/json"},body:JSON.stringify({folder_id:e.folderId,file_size:e.size,file_name:e.fileName}),signal:this.uploadSignal(n)});if(!p.ok&&zt(p.status))throw new S(`Box session failed: ${p.status}`,p.status);return p});if(!o.ok)throw new S(`Box session failed: ${o.status}`,o.status);let a=await o.json(),s=new Ui,l=[],c=0;for(;c<t.size;){n.signal?.throwIfAborted();let p=Math.min(c+a.part_size,t.size),m=new Uint8Array(await t.slice(c,p).arrayBuffer());s.update(m);let h=await ta(m),v=await this.retry(n,async()=>{let b=await this.fetch(a.session_endpoints.upload_part,{method:"PUT",headers:{...i,"Content-Type":"application/octet-stream",Digest:`sha=${h}`,"Content-Range":`bytes ${c}-${p-1}/${t.size}`},body:m,signal:this.uploadSignal(n)});if(!b.ok&&zt(b.status))throw new S(`Box part failed: ${b.status}`,b.status);return b});if(!v.ok)throw new S(`Box part failed: ${v.status}`,v.status);l.push((await v.json()).part),c=p,r(c)}let u=await this.retry(n,async()=>{let p=await this.fetch(a.session_endpoints.commit,{method:"POST",headers:{...i,"Content-Type":"application/json",Digest:`sha=${Zn(s.digest())}`},body:JSON.stringify({parts:l}),signal:this.uploadSignal(n)});if(!p.ok&&zt(p.status))throw new S(`Box commit failed: ${p.status}`,p.status);return p});if(!u.ok)throw new S(`Box commit failed: ${u.status}`,u.status);return{providerFileId:(await u.json()).entries?.[0]?.id}}uploadSignal(e,t=nt){let n=AbortSignal.timeout(t);return e.signal?AbortSignal.any([e.signal,n]):n}async retry(e,t){let n=0;for(;;)try{return await t()}catch(r){if(e.signal?.aborted||(n+=1,n>=tt))throw r;await new Promise(i=>setTimeout(i,500*2**n))}}async driveUploadLoop(e,t,n,r){let i=e.uploadedBytes,o=Ft(n.size,r);o(i);let a=0;for(;i<n.size;){r.signal?.throwIfAborted();let s=i,l=Math.min(i+e.chunkSize,n.size),c=n.slice(i,l),u=0;for(;;)try{let f=await this.fetch(t,{method:"PUT",headers:{"Content-Range":`bytes ${i}-${l-1}/${n.size}`},body:c,signal:this.uploadSignal(r)});if(f.status===308){let p=f.headers.get("Range")??f.headers.get("range"),m=p?.match(/bytes=0-(\d+)/);m?i=Number(m[1])+1:p==null?i=0:i=(await this.getUploadSession(e.id,e.token,this.uploadSignal(r,pe))).uploadedBytes;break}if(f.ok){i=n.size;break}throw new S(`Drive chunk failed: ${f.status}`,f.status)}catch(f){if(r.signal?.aborted||(u+=1,u>=tt))throw f;if(await new Promise(m=>setTimeout(m,500*2**u)),i=(await this.getUploadSession(e.id,e.token,this.uploadSignal(r,pe))).uploadedBytes,i>=n.size)break;l=Math.min(i+e.chunkSize,n.size),c=n.slice(i,l)}if(o(i),i<=s){if(++a>=tt)throw new S("Drive upload stalled \u2014 the storage endpoint stopped accepting progress",0)}else a=0}}async s3MultipartUploadLoop(e,t,n){if(!Number.isSafeInteger(e.chunkSize)||e.chunkSize<=0||!Number.isSafeInteger(e.uploadedBytes)||e.uploadedBytes<0||e.uploadedBytes>t.size||e.uploadedBytes<t.size&&e.uploadedBytes%e.chunkSize!==0)throw new S("S3 upload session returned invalid progress",502);let r=Ft(t.size,n),i=e.uploadedBytes;for(r(i);i<t.size;){n.signal?.throwIfAborted();let o=Math.floor(i/e.chunkSize)+1;if(o>1e4)throw new S("S3 upload needs too many parts",413);let a=Math.min(i+e.chunkSize,t.size),s=t.slice(i,a),l=0;for(;;){let c;try{let u=await this.json(`/uploads/${encodeURIComponent(e.id)}/parts`,{method:"POST",headers:e.token?{"X-Fillo-Upload-Token":e.token}:void 0,body:JSON.stringify({partNumber:o}),signal:this.uploadSignal(n,pe)});if(typeof u.uploadUrl!="string"||!u.uploadUrl)throw new S("S3 part URL was unavailable",502);c=u.uploadUrl;let f=await this.fetch(c,{method:"PUT",body:s,signal:this.uploadSignal(n,Ys)});if(!f.ok)throw new S(`S3 part upload failed: ${f.status}`,f.status);i=a,r(i);break}catch(u){if(n.signal?.aborted)throw u;let f=await this.getUploadSession(e.id,e.token,this.uploadSignal(n,pe));if(f.status==="aborted")throw new S("This upload session was cancelled",409);if(!Number.isSafeInteger(f.uploadedBytes)||f.uploadedBytes<i||f.uploadedBytes>t.size||f.uploadedBytes<t.size&&f.uploadedBytes%e.chunkSize!==0)throw new S("S3 upload session returned invalid progress",502);if(f.uploadedBytes>i){i=f.uploadedBytes,r(i);break}if(l+=1,l>=tt)throw u;await new Promise(p=>setTimeout(p,500*2**l))}}}}async s3PutUpload(e,t,n){let r=Ft(t.size,n);r(0);let i=0;for(;;)try{let o=await this.fetch(e,{method:"PUT",headers:{"Content-Type":t.type||"application/octet-stream"},body:t,signal:this.uploadSignal(n)});if(!o.ok)throw new S(`S3 upload failed: ${o.status}`,o.status);r(t.size);return}catch(o){if(n.signal?.aborted||(i+=1,i>=tt))throw o;await new Promise(a=>setTimeout(a,500*2**i))}}};function Le(e={}){return new Pt(e)}function hn(e){let t=e.trim();if(!/^-?\d*\.?\d+$/.test(t))return null;let n=Number(t);return Number.isFinite(n)?n:null}function ra(e=new Date){let t=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${e.getFullYear()}-${t}-${n}`}function pi(e,t,n=new Date){let r=null;for(let i of me(e))i.kind!=="date"||!i.defaultToday||t[i.id]!==void 0||(r=r??{...t},r[i.id]=ra(n));return r??t}function fi(e,t){let n={};for(let r of me(e)){let i=r.kind==="hidden"?t[r.paramName??r.id]??r.defaultValue:t[r.id];if(!(i===void 0||i===""))switch(r.kind){case"number":{let o=hn(i);if(o===null||r.min!==void 0&&o<r.min||r.max!==void 0&&o>r.max)break;n[r.id]=o;break}case"rating":{let o=hn(i);o!==null&&Number.isInteger(o)&&o>=1&&o<=(r.max??5)&&(n[r.id]=o);break}case"linear_scale":{let o=hn(i),a=r.min??1,s=r.max??10;o!==null&&Number.isInteger(o)&&o>=a&&o<=s&&(n[r.id]=o);break}case"checkbox":n[r.id]=i==="true"||i==="1"||i==="yes";break;case"select":case"dropdown":{r.options.some(o=>o.id===i)&&(n[r.id]=i);break}case"multi_select":{let o=new Set(r.options.map(s=>s.id)),a=[...new Set(i.split(",").filter(s=>o.has(s)))];a.length>0&&(n[r.id]=a);break}case"file_upload":case"ranking":case"matrix":case"signature":case"custom":break;case"calculated":break;case"repeating_group":break;default:n[r.id]=i}}return n}function ia(){if(!(typeof document>"u"||typeof window>"u"))try{let e=new URL(window.location.href);e.hash="";let t=document.cookie.split(";").map(r=>r.trim()).find(r=>r.startsWith("hubspotutk="))?.slice(11),n={pageUri:e.href.slice(0,2048),pageName:document.title.trim().slice(0,200)||void 0,hubspotutk:t&&/^[a-f0-9]{32}$/i.test(t)?t:void 0};return Object.values(n).some(Boolean)?n:void 0}catch{return}}var oa={id:"empty",blocks:[]},hi=!1,mi=!1;function sa(){mi||(mi=!0,console.warn("[fillo] This form has a client but no submission target \u2014 a bare schema can't sync. Wrap it in defineForm({ id, pages }) (or author it with <Fillo.Form id=\u2026>) so it gets a project handle, or pass formId for a dashboard-built form: https://fillo.so/docs"))}function aa(){hi||(hi=!0,console.warn("[fillo] This form has no `client`, so responses can't be submitted \u2014 it's render-only. Pass a client (createClient) to collect responses in Fillo, or forward them to your own backend with webhooks: https://fillo.so/docs"))}var Bi=new Map;function Dn(){try{return globalThis.localStorage??null}catch{return null}}function ji(e){return`fillo:submission:${e}`}function Un(){let e=globalThis.crypto;if(e?.randomUUID)return e.randomUUID();let t=new Uint8Array(16);return e?.getRandomValues?(e.getRandomValues(t),Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")):`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function Vi(e,t,n,r){let i=Dn();if(!i)return e.get(n)??null;try{let o=JSON.parse(i.getItem(t)??"null");if(o&&r(o))return o}catch{}return null}function Hi(e,t,n,r){e.set(n,r);let i=Dn();if(i)try{i.setItem(t,JSON.stringify(r))}catch{}}function Bn(e){return Vi(Bi,ji(e),e,t=>typeof t.key=="string")}function Gi(e,t){Hi(Bi,ji(e),e,t)}function la(e){let t=Bn(e);if(t?.key)return t.key;let n={key:Un()};return Gi(e,n),n.key}function ca(e,t){let n=Bn(e);Gi(e,{key:n?.key??Un(),submittedAt:new Date().toISOString(),responseId:t})}function Fn(e,t,n){let r=$i(e.settings,n);return r===null?t:`${t}::${r}`}function gi(e,t,n){return e.settings.responseLimit?.by!=="browser"||!t?!1:!!Bn(Fn(e,t,n))?.submittedAt}var jn=new Map;function Vn(e){return`fillo:draft:${e}`}function Ct(e){return Vi(jn,Vn(e),e,t=>{let n=t;return typeof n.id=="string"&&typeof n.token=="string"})}function mn(e,t){Hi(jn,Vn(e),e,t)}function gn(e){jn.delete(e);let t=Dn();if(t)try{t.removeItem(Vn(e))}catch{}}function bn(e){return te(e)&&(e.status===401||e.status===403||e.status===404)}var ua=1500;function qi(e,t){if(te(e)){let n=e.status??0;if(n===404)return t.loadFailedNotFound;switch(e.code){case"submit_rate_limited":return t.submitRateLimited;case"workspace_unavailable":case"provision_closed":return t.formClosed;case"respondent_unrecognized":return t.respondentUnrecognized;case"invalid_file_reference":return t.fileUnavailable;case"response_scope_missing":return t.scopeMissing}if(n>0)return t.submitFailed}return t.loadFailedNetwork}function da(e,t,n){if(te(e)){let r=e.status??0;if(t&&r>0&&e.message)return e.code?`${e.message} (${e.code})`:e.message;if(r>0&&r<500&&r!==408&&r!==429)return n.formUnavailable;if(r>0)return n.submitFailed}return qi(e,n)}function Wi(e){let{onChange:t,onSubmitted:n}=e,r={...Yr,...e.respondentErrorStrings},i=Te(e.form);if(!i.ok)throw new Error(`Invalid form schema: ${i.error}`);let o=i.schema,a=e.formId,s=e.client,l=e.respondent,c=Ce(o,{...e.initialData??{}}),u={},f=0,p,m=[];function h(){return e.previewNavigation===!0&&e.skipValidation===!0&&!s&&!a&&!e.resolveFormId}function v(){return je(o,c,h()?p:void 0)}function b(){h()&&m.push({pageIndex:f,startPageId:p})}let g="idle",A=!1,E=!1;queueMicrotask(()=>{if(typeof location<"u"&&location.search){let k=Object.fromEntries(new URLSearchParams(location.search)),x=null;for(let[C,I]of Object.entries(fi(o,k)))c[C]===void 0&&(x=x??{...c},x[C]=I);x&&g==="idle"&&(c=Ce(o,x),z())}let y=pi(o,c);y!==c&&g==="idle"&&(c=Ce(o,y),z()),g==="idle"&&gi(o,a,c)&&(g="submitted",A=!0,z());let $=!1;if(o.settings.saveProgress&&a&&s&&typeof location<"u"&&location.hash.includes("fillo-draft=")){let k=/fillo-draft=([^&]+)/.exec(location.hash),x=k?.[1]?decodeURIComponent(k[1]):"",C=x.indexOf(".");if(C>0){$=!0;let I=x.slice(0,C),L=x.slice(C+1);s.getDraft(I,L,!0).then(Q=>{mn(a,{id:I,token:Q.token??L});try{history.replaceState(null,"",location.pathname+location.search)}catch{}}).catch(Q=>{bn(Q)&&(E=!0,z())}).finally(()=>Bt())}}$||Bt()});let R,re=new Set,W=new Set,ie=Date.now(),ge=Un(),le=null,ce=!1,H=!1,ue=!1,Pe="created",Re=!1,_=null,Z=null,j=Promise.resolve(),U=!1,qe=!1,ze=!1,Oe=!1;function O(){let y=o.pages.length,$=Math.min(f,Math.max(y-1,0)),k=o.pages[$]??oa;return{data:c,errors:u,status:g,pageIndex:$,pageCount:y,page:k,blocks:$t(o,k,c),isFirstPage:$===0,isLastPage:h()&&p!==void 0?v().at(-1)===k.id:$n(o,k.id,c),uploading:re.size>0,submitError:R,restoredSubmission:A,resumedDraft:H,editingPrevious:ue,duplicateSubmission:Pe==="duplicate",updatedSubmission:Pe==="updated",resumeLinkFailed:E}}let Y=O();function z(){Y=O();for(let y of W)y()}function be(y,$){try{n?.(y,$)}catch(k){console.error("[fillo] onSubmitted handler threw:",k)}}function tr(y){let $=o.pages[y];if(!$)return{};let k={};for(let x of $t(o,$,c)){if(!X(x)||h()&&x.kind==="file_upload")continue;let C=Tt(x,c[x.id]);C&&(k[x.id]=C)}return k}function bt(){return!!(o.settings.saveProgress&&s&&a&&!qe)}function _o(){let y=new Set;for(let $ of o.pages)for(let k of $.blocks)X(k)&&y.add(k.id);return y}function Ut(y){if(g!=="idle"||ce)return;let $=_o(),k=null;for(let[I,L]of Object.entries(y.data??{}))c[I]===void 0&&$.has(I)&&(k=k??{...c},k[I]=L);let x=typeof y.page=="number"&&Number.isFinite(y.page)?Math.max(0,Math.min(Math.floor(y.page),o.pages.length-1)):0,C=x>0&&f===0;!k&&!C||(k&&(c=Ce(o,k)),C&&(f=x),H=!0,z())}function Bt(){if(g!=="idle")return;if(!bt()){nr();return}let y=a,$=s,k=_??Ct(y);if(k&&!ze){ze=!0,_=k,$.getDraft(k.id,k.token).then(Ut).catch(x=>{bn(x)&&(gn(y),_=null)});return}!k&&!Oe&&l?.hash&&(Oe=!0,$.createDraft(y,{data:{},page:0,respondent:l}).then(x=>{if(!_){if(_={id:x.id,token:x.token},mn(y,_),x.existing)return $.getDraft(x.id,x.token).then(Ut);nr()}}).catch(x=>{te(x)&&x.status!==void 0&&x.status>=400&&x.status<500||(Oe=!1)}))}function nr(){if(Re||o.settings.responseLimit?.onRepeat!=="update"||!s||!a||!l?.hash||g!=="idle")return;Re=!0;let y=s,$=$i(o.settings,c)??void 0;y.fetchOwnResponse(a,l,$).then(k=>{!k||g!=="idle"||ce||H||(Ut({data:k.data,page:0}),H&&(H=!1,ue=!0,z()))}).catch(()=>{})}function jt(y=!1){if(Z&&(clearTimeout(Z),Z=null),!bt()||g!=="idle"||!U)return;let $=a,k=s;U=!1,j=j.then(async()=>{let x={data:c,page:Math.max(0,Math.min(f,o.pages.length-1))},C=_??Ct($);try{if(C)try{await k.saveDraft(C.id,C.token,x,y?{keepalive:!0}:void 0),_=C;return}catch(L){if(!bn(L))throw L;gn($),_=null}let I=await k.createDraft($,l?.hash?{...x,respondent:l}:x);_={id:I.id,token:I.token},mn($,_),I.existing&&(U=!0)}catch(I){te(I)&&I.status!==void 0&&I.status>=400&&I.status<500&&I.status!==429?qe=!0:U=!0}})}function xo(){!bt()||g!=="idle"||(U=!0,Z&&clearTimeout(Z),Z=setTimeout(()=>{Z=null,jt()},ua))}function rr(){!bt()||!ce&&!_||(U=!0,jt())}function ir(){Z&&(clearTimeout(Z),Z=null),U=!1,a&&gn(a),_=null}function ko(y,$){!ce&&s&&a&&(ce=!0,s.startSession(a,o.pages.length).then(x=>le=x)),c=Ce(o,{...c,[y]:$}),t?.(c),R=void 0;let k=`${y}.`;(y in u||Object.keys(u).some(x=>x.startsWith(k)))&&(u=Object.fromEntries(Object.entries(u).filter(([x])=>x!==y&&!x.startsWith(k)))),z(),xo()}function $o(y,$){$?(re.add(y),y in u&&(u=Object.fromEntries(Object.entries(u).filter(([k])=>k!==y)))):re.delete(y),z()}function or(y){if(y.length===0)return-1;let $=o.pages.length,k=Math.min(f,Math.max($-1,0)),x=o.pages[k]?.id,C=x===void 0?-1:y.indexOf(x);if(C>=0)return C;let I=0;for(let L=0;L<y.length;L++){let Q=o.pages.findIndex(Vt=>Vt.id===y[L]);Q>=0&&Q<=k&&(I=L)}return I}function So(){let y=o.pages.length,$=Math.min(f,Math.max(y-1,0));if(!e.skipValidation||e.previewNavigation===!0){let Q=tr($);if(u=Q,Object.keys(Q).length>0){z();return}}let k=o.pages[$],x=v(),C=or(x);if((h()&&p!==void 0?x.at(-1)===k?.id:k?$n(o,k.id,c):!0)||C<0||C+1>=x.length){sr();return}let L=o.pages.findIndex(Q=>Q.id===x[C+1]);b(),f=L>=0?L:Math.min($+1,y-1),le&&s&&s.reportProgress(le,{furthestPage:f}),z(),rr()}function Ao(){u={};let y=h()?m.pop():void 0;if(y){f=Math.min(y.pageIndex,o.pages.length-1),p=y.startPageId,R=void 0,z();return}let $=je(o,c),k=or($);if(k>0){let x=o.pages.findIndex(C=>C.id===$[k-1]);f=x>=0?x:Math.max(Math.min(f,o.pages.length-1)-1,0)}else if($.length>0){let x=o.pages.findIndex(C=>C.id===$[0]);f=x>=0?x:0}z(),rr()}function Eo(){!h()||g==="submitting"||g==="submitted"||f>=o.pages.length-1||(b(),f+=1,p=o.pages[f]?.id,u={},R=void 0,z())}async function sr(){if(g==="submitting"||g==="submitted")return;if(h()&&(u=tr(f),Object.keys(u).length>0)){z();return}let y=Ti(o,c);if(!y.ok){let $=e.skipValidation&&!(s&&a),k=$?Object.fromEntries(Object.entries(y.errors).filter(([C])=>o.pages.every(I=>I.blocks.every(L=>!(X(L)&&L.id===C&&L.kind==="file_upload"))))):y.errors;if($&&Object.keys(k).length===0){u={},g="submitted",z(),be(void 0,c);return}u=k;let x=o.pages.findIndex(C=>$t(o,C,c).some(I=>I.id in k));x>=0&&(f=x,p=void 0,m.length=0),z();return}if(s&&e.resolveFormId){g="submitting",R=void 0,z();try{a=await e.resolveFormId()}catch($){throw g="idle",R=da($,e.verboseResolutionErrors===!0,r),z(),$}}if(s&&a){let $=o.settings.responseLimit?.by==="browser"?la(Fn(o,a,y.data)):void 0,k=$??ge,x=o.settings.saveProgress?_??Ct(a):null,C=e.challengeRequired?e.getChallengeToken?.():void 0;if(e.challengeRequired&&!C){g="idle",R=r.challengeIncomplete,z();return}g="submitting",R=void 0,z();let I;try{I=await s.submit(a,y.data,{hp:e.getHoneypot?.()??"",elapsedMs:Date.now()-ie,surface:e.surface??"headless",attribution:ia(),submissionKey:k,draft:x?{id:x.id,token:x.token}:void 0,respondent:l,challengeToken:C})}catch(L){if(g="idle",te(L)&&L.code==="challenge_failed"){R=r.challengeRetry,e.onChallengeFailed?.(),z();return}throw R=qi(L,r),z(),L}if(!I.ok){u=I.errors??{};let L=o.pages.findIndex(Q=>$t(o,Q,c).some(Vt=>Vt.id in u));L>=0?f=L:R=r.reviewAnswers,g="idle",z();return}Pe=I.duplicate?"duplicate":I.updated?"updated":"created",le&&s.reportProgress(le,{completed:!0}),$&&ca(Fn(o,a,y.data),I.responseId),ir(),g="submitted",z(),be(I.responseId,y.data);return}if(e.skipValidation){g="submitted",z(),be(void 0,y.data);return}s&&!a?sa():aa(),g="error",z()}return{getState:()=>Y,subscribe(y){return W.add(y),()=>{W.delete(y)}},setValue:ko,setUploading:$o,next:So,skipPreviewPage:Eo,back:Ao,submit:sr,setContext(y){if("formId"in y&&(a=y.formId),"client"in y&&(s=y.client),"respondent"in y&&(l=y.respondent),y.respondentErrorStrings&&(r={...Yr,...y.respondentErrorStrings}),y.form&&y.form!==o){let $=Te(y.form);if(!$.ok)throw new Error(`Invalid form schema: ${$.error}`);o=$.schema,c=Ce(o,c)}g==="idle"&&gi(o,a,c)&&(g="submitted",A=!0),Bt(),z()},flushDraft(){jt(!0)},resetDraft(){if(g==="submitting")return;let y=_??(a?Ct(a):null);if(ir(),y&&s&&s.deleteDraft(y.id,y.token).catch(()=>{}),c={...e.initialData??{}},typeof location<"u"&&location.search){let $=Object.fromEntries(new URLSearchParams(location.search));for(let[k,x]of Object.entries(fi(o,$)))c[k]===void 0&&(c[k]=x)}c=pi(o,c),c=Ce(o,c),u={},f=0,p=void 0,m.length=0,R=void 0,H=!1,ue=!1,z()},destroy(){Z&&(clearTimeout(Z),Z=null),W.clear()}}}function pa(e){return X(e)&&(e.kind==="select"||e.kind==="dropdown"||e.kind==="checkbox"||e.kind==="rating"||e.kind==="linear_scale")}function Ki(e){let t=e.filter(n=>X(n)&&n.kind!=="hidden"&&n.kind!=="calculated");return t.length!==1?!0:!pa(t[0])}function Ji(e,t,n){if(n.form.settings.submitMode!=="auto"||n.status!=="idle"||n.uploading||!(()=>{switch(e.kind){case"select":case"dropdown":return typeof t=="string"&&e.options.some(s=>s.id===t);case"checkbox":return t===!0;case"rating":case"linear_scale":return typeof t=="number";default:return!1}})()||t===n.data[e.id])return!1;let i={...n.data,[e.id]:t},o=n.form.pages.find(s=>s.blocks.some(l=>l.id===e.id));if(!o||!$n(n.form,o.id,i))return!1;let a=Ei(n.form,i).filter(s=>s.kind!=="hidden"&&s.kind!=="calculated");return a.length!==1||a[0]?.id!==e.id?!1:Ti(n.form,i).ok}function Xi(e,t,n,r){if(n<=0)return null;let i=r?.rtl??!1;if(e==="Home")return 0;if(e==="End")return n-1;let o;switch(e){case"ArrowRight":o=i?-1:1;break;case"ArrowLeft":o=i?1:-1;break;case"ArrowDown":o=1;break;case"ArrowUp":o=-1;break;default:return null}let a=t+o;return Math.min(n-1,Math.max(0,a))}var fa=Math.sqrt(1.05*.05)-.05,ha=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i,ma=/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i;function vn(e){let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function Cn(e){let t=e.trim(),n=null,r=ha.exec(t);if(r)n=`${r[1]}${r[2]}${r[3]}`;else{let s=ma.exec(t);s&&(n=`${s[1]}${s[1]}${s[2]}${s[2]}${s[3]}${s[3]}`)}if(!n)return null;let i=parseInt(n.slice(0,2),16),o=parseInt(n.slice(2,4),16),a=parseInt(n.slice(4,6),16);return .2126*vn(i)+.7152*vn(o)+.0722*vn(a)}function ga(e){if(!e||e.colorScheme==="light"||e.colorScheme==="dark"||!e.background||Yi(e))return e;let t=Cn(e.background);return t==null?e:{...e,colorScheme:t>fa?"light":"dark"}}function Yi(e){if(!e||e.colorScheme==="light"||e.colorScheme==="dark")return!1;let t=e.dark;return!!(t&&(t.primary||t.background||t.text))}var ba="#18181b";function yn(e){let t=Cn(e);if(t==null)return null;let n=1.05/(t+.05),r=(t+.05)/((Cn(ba)??0)+.05);return n>=r?"light":"dark"}var va=[["primary","--fillo-primary"],["background","--fillo-bg"],["text","--fillo-text"]],It={light:{primary:"#18181b",background:"transparent",text:"#18181b"},dark:{primary:"#fafafa",background:"transparent",text:"#f4f4f5"}};function Qi(e){let t=ga(Ri(e));if(!t)return null;let n={},r={};t.colorScheme&&(r["data-fillo-color-scheme"]=t.colorScheme);let i=Yi(t)?t.dark:void 0;for(let[o,a]of va){let s=t[o];if(!i){s&&(n[a]=s);continue}let l=i[o];!s&&!l||(n[a]=`light-dark(${s??It.light[o]}, ${l??It.dark[o]})`)}if(t.radius&&(n["--fillo-radius"]=t.radius),t.fontFamily&&(n["--fillo-font"]=t.fontFamily),i){let o=yn(t.primary??It.light.primary),a=yn(i.primary??It.dark.primary);o&&a&&(r["data-fillo-on-primary"]=o,r["data-fillo-on-primary-dark"]=a)}else if(t.primary){let o=yn(t.primary);o&&(r["data-fillo-on-primary"]=o)}return(t.primary||t.background||t.text||i)&&(r["data-fillo-has-color-theme"]=""),{vars:n,attrs:r}}function Hn(e){return{id:e.id,theme:e.theme,schema:{version:1,title:e.title??"",description:e.description,pages:e.pages,settings:e.settings??{}},__filloCodeForm:!0}}function Gn(e){return typeof e=="object"&&e!==null&&"__filloCodeForm"in e}var Se=new Map,ya=e=>new Promise(t=>setTimeout(t,e));function wa(e){if(!te(e))return!0;let t=e.status??0;return t===0||t===408||t===429||t>=500}async function _a(e,t){let n=800;for(let r=0;;r++)try{return await e.syncForm(t.id,t.schema,t.theme??null)}catch(i){if(!wa(i)||r>=2)throw i;let o=te(i)?i.retryAfterSec:void 0;await ya(Math.min(o?o*1e3:n*(1+Math.random()*.5),15e3)),n*=2}}function xa(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)|0;return(t>>>0).toString(36)}function eo(e,t){let n=r=>{if(Array.isArray(r))return r.map(n);if(r&&typeof r=="object"){let i=r;return Object.fromEntries(Object.keys(i).sort().map(o=>[o,n(i[o])]))}return r};return JSON.stringify(n(e))===JSON.stringify(n(t))}var In=e=>e==="published"?36e5:6e4,ka=e=>!!(e.staged||e.resolvedSchema||e.syncError||e.accepting===!1||e.uploadsAvailable===!1);function to(e,t){return`fillo:sync:v5:${e.baseUrl}|${e.key}|${t}`}function $a(e,t,n){try{let r=globalThis.localStorage?.getItem(to(e,t));if(!r)return null;let i=JSON.parse(r);if(typeof i.formId!="string"||typeof i.slug!="string"||i.hash!==n||typeof i.ts!="number"||i.uploadFileSizeLimitMb!==void 0&&(typeof i.uploadFileSizeLimitMb!="number"||!Number.isFinite(i.uploadFileSizeLimitMb)||i.uploadFileSizeLimitMb<=0)||i.manageUrl!==void 0&&typeof i.manageUrl!="string"||i.status!==void 0&&i.status!=="draft"&&i.status!=="published")return null;let o=In(i.status);return Date.now()-i.ts>o?null:i}catch{return null}}function Sa(e,t,n,r){if(!(r.staged||r.resolvedSchema||r.syncError||r.accepting===!1)&&!r.challenge)try{globalThis.localStorage?.setItem(to(e,t),JSON.stringify({formId:r.formId,slug:r.slug,manageUrl:r.manageUrl,status:r.status,uploadFileSizeLimitMb:r.uploadFileSizeLimitMb,hash:n,ts:Date.now()}))}catch{}}function qn(e,t,n){let r=JSON.stringify(t.schema)+JSON.stringify(t.theme??null),i=xa(r),o=`${e.baseUrl}:${e.key}:${t.id}:${i}`,a=me(t.schema).some(u=>u.kind==="file_upload"),s=Se.get(o);if(s&&!n?.bypassCache){if(s.expiresAt===null||!a&&s.expiresAt>Date.now())return s.promise;Se.delete(o)}if(!n?.bypassCache&&!a){let u=$a(e,t.id,i);if(u){let f=Promise.resolve({formId:u.formId,slug:u.slug,manageUrl:u.manageUrl,status:u.status,uploadFileSizeLimitMb:u.uploadFileSizeLimitMb});return Se.set(o,{promise:f,expiresAt:u.ts+In(u.status)}),f}}let l=_a(e,t),c={promise:l,expiresAt:null};return Se.set(o,c),l.then(u=>{if(Se.get(o)===c){if(a||ka(u)){Se.delete(o);return}c.expiresAt=Date.now()+In(u.status),Sa(e,t.id,i,u)}},()=>{Se.get(o)===c&&Se.delete(o)}),l}var Aa=class extends Error{constructor(e,t){super(`[fillo] ${t} \u2014 https://fillo.so/docs/troubleshooting#jsx-${e.toLowerCase()}`),this.code=e,this.name="FilloJsxError"}code},Ea=Symbol.for("fillo.block");var za=["label","description","required","placeholder"],D=(e,t,n,r={})=>({name:e,kind:t,props:[...za,...n],...r}),bi=(e,t,n)=>({name:e,kind:t,props:n?["text"]:[],textChildren:n,content:!0}),wn=["options","allowOther","shuffleOptions"],Fa=[D("Text","short_text",["maxLength"]),D("LongText","long_text",["maxLength"]),D("Email","email",["maxLength"]),D("Url","url",["maxLength"]),D("Phone","phone",["defaultCountry"]),D("Number","number",["min","max","decimals","prefix","suffix","notation"]),D("Select","select",wn,{optionChildren:!0}),D("MultiSelect","multi_select",wn,{optionChildren:!0}),D("Dropdown","dropdown",wn,{optionChildren:!0}),D("Checkbox","checkbox",["appearance"]),D("Rating","rating",["max","insightsMetric"]),D("Scale","linear_scale",["min","max","minLabel","maxLabel","insightsMetric"]),D("Ranking","ranking",["options"],{optionChildren:!0}),D("Matrix","matrix",["rows","columns"]),D("Signature","signature",[]),D("Date","date",["defaultToday"]),D("FileUpload","file_upload",["maxFiles","maxFileSizeMb","accept"]),D("Hidden","hidden",["paramName","defaultValue"]),D("Calculated","calculated",["calc","decimals","prefix","suffix"]),D("RepeatingGroup","repeating_group",["minInstances","maxInstances","addLabel","itemLabel"],{blockChildren:!0}),D("Custom","custom",["component","config"]),bi("Heading","heading",!0),bi("Paragraph","paragraph",!0),{name:"Divider",kind:"divider",props:[],content:!0}],Ca={name:"Page",kind:"__page",props:["title"]},Ia={name:"Option",kind:"__option",props:["label","icon"]};function _n(e){let t=()=>{throw new Aa("RENDERED_INERT",`<Fillo.${e.name}> was rendered by React. Fillo fields are schema declarations, valid only inside <Fillo.Form> or Fillo.defineForm(). If this form lives in a server component, move it to a client module ("use client")`)};return t[Ea]=e,t}var dp=Object.fromEntries([...Fa.map(e=>[e.name,_n(e)]),["Page",_n(Ca)],["Option",_n(Ia)]]);function Na(e){let t=e.toLowerCase();return t==="localhost"||t.endsWith(".localhost")||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)||t==="::1"||t==="[::1]"||t==="0.0.0.0"}function Wn(){return typeof process<"u"&&process.env?.NODE_ENV!=="production"}function no(){if(Wn())return!0;if(typeof window>"u")return!1;let e=window.location?.hostname;return typeof e=="string"&&Na(e)}var Ta=/\{\{\s*([\w-]+)\s*\}\}/g;function xn(e,t,n){if(!e.includes("{{"))return e;let r=me(n);return e.replace(Ta,(i,o)=>{let a=r.find(c=>c.id===o),s=t[o];if(s==null||s==="")return"";let l=c=>a&&"options"in a?a.options.find(u=>u.id===c)?.label??c:c;return Array.isArray(s)?s.map(c=>l(String(c))).join(", "):typeof s=="string"?l(s):String(s)})}function ro(e,t,n){let r=i=>i===void 0?i:xn(i,t,n);switch(e.kind){case"heading":case"paragraph":return{...e,text:xn(e.text,t,n)};case"divider":return e;default:return{...e,label:xn(e.label,t,n),description:r(e.description)}}}var La="fillo-",Ma=0,mt='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function Pa(e){return e.matches(mt)?e:e.querySelector(mt)}function Ra(e){return Array.from(e.querySelectorAll(mt)).find(n=>!n.closest(".fillo-group-instance-header"))??null}function mo(e,t){let n=`${La}${e}-${t}`;return{inputId:n,labelId:`${n}-label`,descriptionId:`${n}-desc`,errorId:`${n}-error`,name:n}}function d(e,t={}){let n=document.createElement(e);t.className&&(n.className=t.className),t.text!==void 0&&(n.textContent=t.text);for(let[r,i]of Object.entries(t.attrs??{}))n.setAttribute(r,i);return n}function He(e,t){let n=Qi(t);if(n){for(let[r,i]of Object.entries(n.attrs))e.setAttribute(r,i);for(let[r,i]of Object.entries(n.vars))e.style.setProperty(r,i)}}function Me(e){try{if(!e)return null;let t=new URL(e);return t.protocol!=="http:"&&t.protocol!=="https:"?null:t.toString()}catch{return null}}function Oa(e){let t=new URL(Me(e)??"https://fillo.so");return t.searchParams.set("utm_source","form_badge"),t.toString()}function Ot(e){return typeof e=="string"||typeof e=="number"?String(e):""}function io(e,t,n){let r=Ot(e);if(r==="")return r;let i=Number(r);return Number.isFinite(i)?Zi(i,{locale:n,decimals:t}):r}function N(e,t){for(let n of t)n&&e.appendChild(n);return e}var Zt="http://www.w3.org/2000/svg",Za={thumbs_up:"M7 10v10M7 10l4.8-6.1a2 2 0 0 1 3.5 1.7L14.6 10h4.8a2.1 2.1 0 0 1 2 2.5l-1.1 5.4A3 3 0 0 1 17.4 20H7M3 10h4v10H3z",thumbs_down:"M7 14V4M7 14l4.8 6.1a2 2 0 0 0 3.5-1.7L14.6 14h4.8a2.1 2.1 0 0 0 2-2.5l-1.1-5.4A3 3 0 0 0 17.4 4H7M3 4h4v10H3z"};function go(e){if(!e)return null;let t=document.createElementNS(Zt,"svg");t.setAttribute("class","fillo-option-icon"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.8"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("aria-hidden","true");let n=document.createElementNS(Zt,"path");return n.setAttribute("d",Za[e]),t.appendChild(n),t}function bo(){let e=document.createElementNS(Zt,"svg");e.setAttribute("class","fillo-option-check"),e.setAttribute("width","1em"),e.setAttribute("height","1em"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","2"),e.setAttribute("stroke-linecap","square"),e.setAttribute("stroke-linejoin","miter"),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false");let t=document.createElementNS(Zt,"path");return t.setAttribute("d","M4 12l5 5L20 6"),e.appendChild(t),e}function q(e,t,n,r,i={}){n&&e.setAttribute("aria-invalid","true"),(i.requiredSupported??!0)&&t.required&&e.setAttribute("aria-required","true");let o=[t.description?r.descriptionId:null,n?r.errorId:null].filter(Boolean).join(" ");o&&e.setAttribute("aria-describedby",o)}function vo(e,t,n,r){e.addEventListener("keydown",i=>{let o=getComputedStyle(e).direction==="rtl",a=n===null?-1:t.indexOf(n),s=Xi(i.key,a,t.length,{rtl:o});if(s===null)return;i.preventDefault();let l=t[s];l!==void 0&&(r(l),e.querySelectorAll('[role="radio"]')[s]?.focus())})}function ne(e,t,n,r){let i=d("div",{className:`fillo-field fillo-field--${e.kind}${t?" fillo-field--error":""}`,attrs:{"data-fillo":"field","data-field":e.id,"data-kind":e.kind}});i.toggleAttribute("data-invalid",!!t),i.toggleAttribute("data-required",!!e.required);let o=d("label",{className:"fillo-label",text:e.label,attrs:{id:r.labelId,for:r.inputId,"data-fillo":"label"}});return!e.required&&!(e.kind==="repeating_group"&&(e.minInstances??1)>0)&&o.appendChild(d("span",{className:"fillo-optional",text:" (optional)"})),i.appendChild(o),e.description&&i.appendChild(d("p",{className:"fillo-description",text:e.description,attrs:{id:r.descriptionId,"data-fillo":"fieldDescription"}})),i.appendChild(n),t&&i.appendChild(d("p",{className:"fillo-error",text:t,attrs:{id:r.errorId,"data-fillo":"error"}})),i}function ut(e,t){let n=t.field,r=n.kind==="number"?n:void 0,i=r?.notation!==void 0,o=Oi(r?.notation),a=i||!!r?.prefix||!!r?.suffix,s=d("input",{className:"fillo-input",attrs:{id:t.ids.inputId,type:a?"text":e,"data-fillo":"control"}});if(a&&s.setAttribute("inputmode","decimal"),e==="email"?s.setAttribute("autocomplete","email"):e==="url"&&s.setAttribute("autocomplete","url"),s.value=i?io(t.value,r?.decimals,o):Ot(t.value),n.placeholder&&(s.placeholder=n.placeholder),"maxLength"in n&&n.maxLength!==void 0&&(s.maxLength=n.maxLength),r&&!a&&(r.min!==void 0&&(s.min=String(r.min)),r.max!==void 0&&(s.max=String(r.max))),a){let c=s.value,u=s.value.length,f=()=>{s.value=c,s.setSelectionRange(u,u)};i?(s.addEventListener("input",()=>{if(!ct(s.value,o))return f();c=s.value,u=s.selectionStart??s.value.length,t.setValue(On(s.value,o),{render:!1})}),s.addEventListener("change",()=>{if(!ct(s.value,o))return f();c=s.value,t.setValue(On(s.value,o))}),s.addEventListener("blur",()=>{let p=t.getValue?.()??t.value;s.value=io(p,r?.decimals,o),c=s.value,u=s.value.length})):(s.addEventListener("input",()=>{if(!ct(s.value,o))return f();c=s.value,u=s.selectionStart??s.value.length,t.setValue(s.value,{render:!1})}),s.addEventListener("change",()=>{if(!ct(s.value,o))return f();c=s.value,t.setValue(s.value)}))}else s.addEventListener("input",()=>t.setValue(s.value,{render:!1})),s.addEventListener("change",()=>t.setValue(s.value));q(s,n,t.error,t.ids);let l=s;return r&&(r.prefix||r.suffix)&&(l=N(d("div",{className:"fillo-number"}),[r.prefix?d("span",{className:"fillo-number-prefix",text:r.prefix}):null,s,r.suffix?d("span",{className:"fillo-number-suffix",text:r.suffix}):null])),ne(n,t.error,l,t.ids)}function Da(){if(typeof navigator>"u")return;let t=(navigator.languages?.[0]||navigator.language||"").split("-")[1];return t&&/^[A-Za-z]{2}$/.test(t)?t.toUpperCase():void 0}function Ua(){if(!(typeof Intl>"u"))try{let e=Intl.DateTimeFormat().resolvedOptions().timeZone;return typeof e=="string"&&e?e:void 0}catch{return}}function Ba(e,t){if(t<=0)return e.setSelectionRange(0,0);let n=e.value,r=0,i=n.length;for(let o=0;o<n.length;o++)if(/\d/.test(n[o])&&++r===t){i=o+1;break}e.setSelectionRange(i,i)}function ja(e){let t=e.field,n=at(Ot(e.value)).country??Mt(t.defaultCountry)??Fi(Ua())??Mt(Da())??ot[0],r=d("div",{className:"fillo-phone"}),i=d("div",{className:"fillo-phone-country"}),o=d("button",{className:"fillo-phone-flag",attrs:{type:"button","aria-haspopup":"listbox","aria-expanded":"false"}}),a=d("span",{className:"fillo-phone-flag-emoji",attrs:{"aria-hidden":"true"}}),s=d("span",{className:"fillo-phone-dial"});N(o,[a,s,d("span",{className:"fillo-phone-caret",text:"\u25BE",attrs:{"aria-hidden":"true"}})]),N(i,[o]);let l=d("input",{className:"fillo-input fillo-phone-input",attrs:{id:e.ids.inputId,type:"tel",inputmode:"tel",autocomplete:"tel-national","data-fillo":"control"}});q(l,e.field,e.error,e.ids);let c=()=>e.getValue?.()??e.value,u=()=>{let _=he(Ot(c()));return _.startsWith(n.dialCode)?_.slice(n.dialCode.length):_},f=()=>{a.textContent=Ln(n.iso2),s.textContent=`+${n.dialCode}`,o.setAttribute("aria-label",`Country: ${n.name} (+${n.dialCode})`)},p=()=>{l.value=st(n,u()),l.placeholder=st(n,n.example)},m=_=>e.setValue(_?Ci(n,_):"",{render:!1}),h=_=>e.setValue(_,{render:!1});f(),p(),l.addEventListener("input",()=>{let _=l.value,Z=l.selectionStart??_.length,j=he(_.slice(0,Z)).length;if(_.trimStart().startsWith("+")){let U=at(_,n,{previousDigits:u()});if(U.pending){h(U.raw??_);return}U.country&&(n=U.country,f()),m(U.country?U.national:he(_))}else m(he(_));l.value=st(n,u()),Ba(l,j)});let v=e.registerOverlay,b=e.announce,g=null,A=0,E=Ve,R=null,re=null,W,ie=`${e.ids.inputId}-countries`,ge=()=>{if(!g)return;let _=Ii(i,g);g.classList.toggle("fillo-phone-popover--above",_==="above"),g.classList.toggle("fillo-phone-popover--below",_==="below")},le=()=>{R?.();let _=()=>ge();ge(),window.addEventListener("resize",_),window.addEventListener("scroll",_,!0),R=()=>{window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0)}},ce=_=>{let Z=_.relatedTarget;if(Z){i.contains(Z)||H();return}queueMicrotask(()=>{g&&!i.contains(document.activeElement)&&H()})},H=()=>{clearTimeout(W),R?.(),R=null,g?.remove(),g=null,o.setAttribute("aria-expanded","false"),o.removeAttribute("aria-controls"),document.removeEventListener("mousedown",ue),i.removeEventListener("focusout",ce),re?.(),re=null},ue=_=>{i.contains(_.target)||H()},Pe=_=>{_&&(n=_,f(),m(u()),p(),H(),b?.(M.phoneCountrySelected(_.name)),l.focus())},Re=_=>{let Z=d("div",{className:"fillo-phone-popover fillo-phone-popover--below"}),j=d("input",{className:"fillo-phone-search",attrs:{type:"text",role:"combobox","aria-expanded":"true","aria-controls":ie,"aria-autocomplete":"list","aria-label":"Search country or code",placeholder:"Search country or code"}});_&&(j.value=_);let U=d("ul",{className:"fillo-phone-list",attrs:{role:"listbox",id:ie,"aria-label":"Country"}}),qe=()=>{if(U.replaceChildren(),E.length===0){U.appendChild(d("li",{className:"fillo-phone-empty",text:"No matches",attrs:{role:"option","aria-disabled":"true"}})),j.removeAttribute("aria-activedescendant"),ge();return}E.forEach((O,Y)=>{let z=d("li",{className:`fillo-phone-option${Y===A?" fillo-phone-option--active":""}`,attrs:{id:`${ie}-opt-${Y}`,role:"option","aria-selected":String(O.iso2===n.iso2)}});N(z,[d("span",{className:"fillo-phone-flag-emoji",text:Ln(O.iso2),attrs:{"aria-hidden":"true"}}),d("span",{className:"fillo-phone-option-name",text:O.name}),d("span",{className:"fillo-phone-option-dial",text:`+${O.dialCode}`})]),z.addEventListener("mouseenter",()=>{A=Y,j.setAttribute("aria-activedescendant",z.id),ze()}),z.addEventListener("mousedown",be=>{be.preventDefault(),Pe(O)}),U.appendChild(z)}),j.setAttribute("aria-activedescendant",`${ie}-opt-${A}`),ge()},ze=()=>{[...U.children].forEach((O,Y)=>O.classList.toggle("fillo-phone-option--active",Y===A)),document.getElementById(`${ie}-opt-${A}`)?.scrollIntoView({block:"nearest"})},Oe=O=>{let Y=O.trim().toLowerCase(),z=Y.replace(/[^\d]/g,"");E=Y?Ve.filter(be=>be.name.toLowerCase().includes(Y)||be.iso2.toLowerCase()===Y||z.length>0&&be.dialCode.startsWith(z)):Ve,A=0,qe(),clearTimeout(W),W=setTimeout(()=>b?.(M.phoneResultsCount(E.length)),300)};j.addEventListener("input",()=>Oe(j.value)),j.addEventListener("keydown",O=>{if(O.key==="ArrowDown"){if(O.preventDefault(),E.length===0)return;A=Math.min(A+1,E.length-1),ze(),j.setAttribute("aria-activedescendant",`${ie}-opt-${A}`)}else if(O.key==="ArrowUp"){if(O.preventDefault(),E.length===0)return;A=Math.max(A-1,0),ze(),j.setAttribute("aria-activedescendant",`${ie}-opt-${A}`)}else O.key==="Enter"?(O.preventDefault(),Pe(E[A])):O.key==="Escape"&&(O.preventDefault(),H(),o.focus())}),N(Z,[j,U]),g=Z,i.appendChild(Z),o.setAttribute("aria-expanded","true"),o.setAttribute("aria-controls",ie),_?Oe(_):(E=Ve,A=Math.max(0,Ve.indexOf(n)),qe()),le(),ze(),document.addEventListener("mousedown",ue),i.addEventListener("focusout",ce),re=v?.(H)??null,requestAnimationFrame(()=>{if(j.focus(),_){let O=j.value.length;j.setSelectionRange(O,O)}})};return o.addEventListener("click",()=>g?H():Re()),o.addEventListener("keydown",_=>{if(!g){if(_.key==="ArrowDown"||_.key==="ArrowUp"){_.preventDefault(),Re();return}_.key.length===1&&_.key!==" "&&!_.ctrlKey&&!_.metaKey&&!_.altKey&&(_.preventDefault(),Re(_.key))}}),N(r,[i,l]),ne(e.field,e.error,r,e.ids)}function Va(e){let t=d("textarea",{className:"fillo-input fillo-textarea",attrs:{id:e.ids.inputId,rows:"4","data-fillo":"control"}});return t.value=typeof e.value=="string"?e.value:"",e.field.placeholder&&(t.placeholder=e.field.placeholder),"maxLength"in e.field&&e.field.maxLength!==void 0&&(t.maxLength=e.field.maxLength),t.addEventListener("input",()=>e.setValue(t.value,{render:!1})),t.addEventListener("change",()=>e.setValue(t.value)),q(t,e.field,e.error,e.ids),ne(e.field,e.error,t,e.ids)}function Ha(e){let t=e.field,n=Qn(t),r=typeof e.value=="string"?e.value:"",i=e.activeOtherFields,o=r!==""&&!t.options.some(l=>l.id===r),a=o||r===""&&i?.has(t.id)===!0,s=d("div",{className:"fillo-options",attrs:{role:"radiogroup","aria-labelledby":e.ids.labelId,"data-fillo":"options"}});q(s,t,e.error,e.ids);for(let l of n){let c=d("label",{className:`fillo-option${l.icon?" fillo-option--has-icon":""}${r===l.id?" fillo-option--selected":""}`,attrs:{"data-option":l.id,"data-fillo":"option"}});c.toggleAttribute("data-selected",r===l.id);let u=d("input",{className:"fillo-option-input",attrs:{type:"radio",name:e.ids.name}});u.checked=r===l.id,u.addEventListener("change",()=>{i?.delete(t.id),e.setValue(l.id)}),N(c,[u,go(l.icon),d("span",{className:"fillo-option-label",text:l.label,attrs:{"data-fillo":"optionLabel"}}),l.icon&&r===l.id?bo():null]),s.appendChild(c)}if(t.allowOther){let l=d("label",{className:`fillo-option fillo-option--other${a?" fillo-option--selected fillo-option--with-other":""}`,attrs:{"data-fillo":"option"}});l.toggleAttribute("data-selected",a);let c=d("input",{className:"fillo-option-input",attrs:{type:"radio",name:e.ids.name}});if(c.checked=a,c.addEventListener("change",()=>{i?.add(t.id),e.setValue("",{render:!0})}),N(l,[N(d("span",{className:"fillo-option-main"}),[c,d("span",{className:"fillo-option-label",text:T.other,attrs:{"data-fillo":"optionLabel"}})])]),a){let u=d("input",{className:"fillo-input fillo-other-input",attrs:{type:"text","aria-label":T.otherPrompt}});u.value=o?r:"",u.placeholder=T.otherPlaceholder,u.addEventListener("input",()=>{i?.add(t.id),e.setValue(u.value,{render:!1})}),u.addEventListener("change",()=>{i?.add(t.id),e.setValue(u.value)}),l.appendChild(u),o||queueMicrotask(()=>u.focus())}s.appendChild(l)}return ne(t,e.error,s,e.ids)}function Ga(e){let t=e.field,n=Qn(t),r=Array.isArray(e.value)?e.value:[],i=new Set(t.options.map(u=>u.id)),o=r.find(u=>!i.has(u)),a=e.activeOtherFields,s=()=>{let u=e.getValue?.()??e.value;return Array.isArray(u)?u:[]},l=d("div",{className:"fillo-options",attrs:{role:"group","aria-labelledby":e.ids.labelId,"data-fillo":"options"}});q(l,t,e.error,e.ids,{requiredSupported:!1});let c=u=>e.setValue(u);for(let u of n){let f=d("label",{className:`fillo-option${u.icon?" fillo-option--has-icon":""}${r.includes(u.id)?" fillo-option--selected":""}`,attrs:{"data-option":u.id,"data-fillo":"option"}});f.toggleAttribute("data-selected",r.includes(u.id));let p=d("input",{className:"fillo-option-input",attrs:{type:"checkbox"}});p.checked=r.includes(u.id),p.addEventListener("change",()=>{let m=s();c(p.checked?[...m,u.id]:m.filter(h=>h!==u.id))}),N(f,[p,go(u.icon),d("span",{className:"fillo-option-label",text:u.label,attrs:{"data-fillo":"optionLabel"}}),u.icon&&r.includes(u.id)?bo():null]),l.appendChild(f)}if(t.allowOther){let u=o!==void 0||a?.has(t.id)===!0,f=d("label",{className:`fillo-option fillo-option--other${u?" fillo-option--selected fillo-option--with-other":""}`,attrs:{"data-fillo":"option"}});f.toggleAttribute("data-selected",u);let p=d("input",{className:"fillo-option-input",attrs:{type:"checkbox"}});if(p.checked=u,p.addEventListener("change",()=>{let m=s().filter(h=>i.has(h));p.checked?(a?.add(t.id),c(m)):(a?.delete(t.id),c(m))}),N(f,[N(d("span",{className:"fillo-option-main"}),[p,d("span",{className:"fillo-option-label",text:T.other,attrs:{"data-fillo":"optionLabel"}})])]),u){let m=d("input",{className:"fillo-input fillo-other-input",attrs:{type:"text","aria-label":T.otherPrompt}});m.value=o??"",m.placeholder=T.otherPlaceholder,m.addEventListener("input",()=>{a?.add(t.id);let h=s().filter(v=>i.has(v));e.setValue(m.value?[...h,m.value]:h,{render:!1})}),m.addEventListener("change",()=>{a?.add(t.id);let h=s().filter(v=>i.has(v));e.setValue(m.value?[...h,m.value]:h)}),f.appendChild(m),o===void 0&&queueMicrotask(()=>m.focus())}l.appendChild(f)}return ne(t,e.error,l,e.ids)}function qa(e){let t="__fillo_other__",n=new Set(e.options.map(r=>r.id));for(;n.has(t);)t+="_";return t}function Wa(e){let t=e.field,n=typeof e.value=="string"?e.value:"",r=qa(t),i=e.activeOtherFields,o=n!==""&&!t.options.some(u=>u.id===n),a=o||n===""&&i?.has(t.id)===!0,s=d("div"),l=d("div",{className:"fillo-select-wrap"}),c=d("select",{className:"fillo-input fillo-select",attrs:{id:e.ids.inputId,"data-fillo":"control"}});c.appendChild(d("option",{text:t.placeholder??"Choose...",attrs:{value:""}}));for(let u of Qn(t))c.appendChild(d("option",{text:u.label,attrs:{value:u.id}}));if(t.allowOther&&c.appendChild(d("option",{text:`${T.other}\u2026`,attrs:{value:r}})),c.value=a?r:n,c.addEventListener("change",()=>{c.value===r?(i?.add(t.id),e.setValue("",{render:!0})):(i?.delete(t.id),e.setValue(c.value||null))}),q(c,t,e.error,e.ids),N(l,[c,d("span",{className:"fillo-select-icon",attrs:{"aria-hidden":"true"}})]),s.appendChild(l),a){let u=d("input",{className:"fillo-input fillo-other-input fillo-other-input--block",attrs:{type:"text","aria-label":T.otherPrompt}});u.value=o?n:"",u.placeholder=T.otherPlaceholder,u.addEventListener("input",()=>{i?.add(t.id),e.setValue(u.value,{render:!1})}),u.addEventListener("change",()=>{i?.add(t.id),e.setValue(u.value)}),s.appendChild(u),o||queueMicrotask(()=>u.focus())}return ne(t,e.error,s,e.ids)}function Ka(e){if(e.field.kind==="checkbox"&&e.field.appearance==="toggle"){let o=d("div",{className:`fillo-field fillo-field--checkbox fillo-field--toggle${e.error?" fillo-field--error":""}`,attrs:{"data-fillo":"field","data-field":e.field.id,"data-kind":e.field.kind}});o.toggleAttribute("data-invalid",!!e.error),o.toggleAttribute("data-required",!!e.field.required);let a=d("label",{className:"fillo-toggle",attrs:{"data-fillo":"option"}});a.toggleAttribute("data-checked",e.value===!0);let s=d("span",{className:"fillo-option-label",text:e.field.label,attrs:{"data-fillo":"optionLabel"}});e.field.required||s.appendChild(d("span",{className:"fillo-optional",text:" (optional)"}));let l=d("span",{className:"fillo-toggle-copy"});l.appendChild(s);let c=d("input",{className:"fillo-toggle-input",attrs:{id:e.ids.inputId,type:"checkbox"}});return c.checked=e.value===!0,c.addEventListener("change",()=>{e.setValue(c.checked)}),q(c,e.field,e.error,e.ids),N(a,[l,c,N(d("span",{className:"fillo-toggle-track",attrs:{"aria-hidden":"true"}}),[d("span",{className:"fillo-toggle-thumb"})])]),o.appendChild(a),e.field.description&&o.appendChild(d("p",{className:"fillo-description",text:e.field.description,attrs:{id:e.ids.descriptionId,"data-fillo":"fieldDescription"}})),e.error&&o.appendChild(d("p",{className:"fillo-error",text:e.error,attrs:{id:e.ids.errorId,"data-fillo":"error"}})),o}let t=d("div",{className:`fillo-field fillo-field--checkbox${e.error?" fillo-field--error":""}`,attrs:{"data-fillo":"field","data-field":e.field.id,"data-kind":e.field.kind}});t.toggleAttribute("data-invalid",!!e.error),t.toggleAttribute("data-required",!!e.field.required);let n=d("label",{className:"fillo-option",attrs:{"data-fillo":"option"}});n.toggleAttribute("data-checked",e.value===!0);let r=d("input",{className:"fillo-option-input",attrs:{id:e.ids.inputId,type:"checkbox"}});r.checked=e.value===!0,r.addEventListener("change",()=>e.setValue(r.checked)),q(r,e.field,e.error,e.ids);let i=d("span",{className:"fillo-option-label",text:e.field.label,attrs:{"data-fillo":"optionLabel"}});return e.field.required||i.appendChild(d("span",{className:"fillo-optional",text:" (optional)"})),N(n,[r,i]),t.appendChild(n),e.field.description&&t.appendChild(d("p",{className:"fillo-description",text:e.field.description,attrs:{id:e.ids.descriptionId,"data-fillo":"fieldDescription"}})),e.error&&t.appendChild(d("p",{className:"fillo-error",text:e.error,attrs:{id:e.ids.errorId,"data-fillo":"error"}})),t}function Ja(e){if(e.field.kind!=="rating")return d("div");let t=typeof e.field.max=="number"?e.field.max:5,n=typeof e.value=="number"?e.value:0,r=Array.from({length:t},(s,l)=>l+1),i=n>0?n:null,o=i===null?0:Math.max(0,r.indexOf(i)),a=d("div",{className:"fillo-rating",attrs:{id:e.ids.inputId,role:"radiogroup","aria-labelledby":e.ids.labelId,"data-fillo":"control"}});q(a,e.field,e.error,e.ids);for(let[s,l]of r.entries()){let c=d("button",{className:`fillo-star${l<=n?" fillo-star--active":""}`,text:l<=n?"\u2605":"\u2606",attrs:{type:"button",role:"radio","aria-label":`${l} of ${t}`,"aria-checked":String(l===n),tabindex:String(s===o?0:-1),"data-fillo":"option"}});c.toggleAttribute("data-selected",l<=n),c.addEventListener("click",u=>{u.detail===0&&l===n||e.setValue(l===n?null:l)}),a.appendChild(c)}return vo(a,r,i,s=>e.setValue(s)),ne(e.field,e.error,a,e.ids)}function Xa(e){if(e.field.kind!=="linear_scale")return d("div");let t=typeof e.field.min=="number"?e.field.min:1,n=typeof e.field.max=="number"?e.field.max:10,r=typeof e.value=="number"?e.value:null,i=Array.from({length:n-t+1},(f,p)=>t+p),o=r===null?0:Math.max(0,i.indexOf(r)),a=`${e.ids.inputId}-min`,s=`${e.ids.inputId}-max`,l=d("div"),c=d("div",{className:"fillo-scale",attrs:{id:e.ids.inputId,role:"radiogroup","aria-labelledby":e.ids.labelId,"data-fillo":"control"}});q(c,e.field,e.error,e.ids);let u=[e.field.minLabel?a:null,e.field.maxLabel?s:null,c.getAttribute("aria-describedby")].filter(Boolean).join(" ");u&&c.setAttribute("aria-describedby",u);for(let[f,p]of i.entries()){let m=d("button",{className:`fillo-scale-step${e.value===p?" fillo-scale-step--active":""}`,text:String(p),attrs:{type:"button",role:"radio","aria-label":String(p),"aria-checked":String(e.value===p),tabindex:String(f===o?0:-1),"data-fillo":"option"}});m.toggleAttribute("data-selected",e.value===p),m.addEventListener("click",h=>{h.detail===0&&e.value===p||e.setValue(e.value===p?null:p)}),c.appendChild(m)}return vo(c,i,r,f=>e.setValue(f)),l.appendChild(c),("minLabel"in e.field||"maxLabel"in e.field)&&N(l,[N(d("div",{className:"fillo-scale-labels"}),[d("span",{text:String(e.field.minLabel??""),attrs:{id:a}}),d("span",{text:String(e.field.maxLabel??""),attrs:{id:s}})])]),ne(e.field,e.error,l,e.ids)}function Ya(e){let t=e.field;if(t.kind!=="ranking")return null;let n=e.announce,r=Array.isArray(e.value)?e.value:[],i=[...r.filter(s=>t.options.some(l=>l.id===s)),...t.options.map(s=>s.id).filter(s=>!r.includes(s))],o=d("div",{attrs:{id:e.ids.inputId,role:"group","aria-labelledby":e.ids.labelId,"data-fillo":"control"}});q(o,e.field,e.error,e.ids,{requiredSupported:!1});let a=d("ol",{className:"fillo-ranking"});for(let[s,l]of i.entries()){let c=t.options.find(v=>v.id===l);if(!c)continue;let u=d("li",{className:"fillo-ranking-item"}),f=d("span",{className:"fillo-ranking-controls"}),p=v=>{let b=s+v;if(b<0||b>=i.length)return;let g=[...i];[g[s],g[b]]=[g[b],g[s]],e.setValue(g),n?.(M.rankingPosition(c.label,b+1,i.length))},m=d("button",{className:"fillo-ranking-move",text:"\u2191",attrs:{type:"button","data-fillo-rank-opt":l,"data-fillo-rank-dir":"up","aria-label":`Move ${c.label} up`}});m.toggleAttribute("disabled",s===0),m.addEventListener("click",()=>p(-1));let h=d("button",{className:"fillo-ranking-move",text:"\u2193",attrs:{type:"button","data-fillo-rank-opt":l,"data-fillo-rank-dir":"down","aria-label":`Move ${c.label} down`}});h.toggleAttribute("disabled",s===i.length-1),h.addEventListener("click",()=>p(1)),N(f,[m,h]),N(u,[d("span",{className:"fillo-ranking-index",text:String(s+1)}),d("span",{className:"fillo-ranking-label",text:c.label}),f]),a.appendChild(u)}return o.appendChild(a),ne(e.field,e.error,o,e.ids)}function Qa(e){let t=e.field;if(t.kind!=="matrix")return null;let n=e.value&&typeof e.value=="object"&&!Array.isArray(e.value)?e.value:{},r=d("table",{className:"fillo-matrix"}),i=document.createElement("thead"),o=document.createElement("tr");o.appendChild(document.createElement("td"));for(let l of t.columns)o.appendChild(d("th",{text:l.label,attrs:{scope:"col"}}));i.appendChild(o),r.appendChild(i);let a=document.createElement("tbody");for(let l of t.rows){let c=`${e.ids.inputId}-${l.id}`,u=n[l.id]!==void 0,f=!!e.error&&!!t.required&&!u,p=b=>`${e.ids.inputId}-${l.id}-${b.id}`,m=document.createElement("tr"),h=d("th",{attrs:{scope:"row"}}),v=d("div",{attrs:{role:"radiogroup","aria-labelledby":`${e.ids.labelId} ${c}`,"aria-owns":t.columns.map(p).join(" ")}});v.appendChild(d("span",{text:l.label,attrs:{id:c}})),h.appendChild(v),m.appendChild(h);for(let b of t.columns){let g=d("td",{attrs:{"data-label":b.label}}),A=d("label",{className:"fillo-matrix-cell"}),E=d("input",{className:"fillo-option-input",attrs:{id:p(b),type:"radio",name:`${e.ids.name}-${l.id}`,"aria-label":`${l.label}: ${b.label}`}});t.required&&E.setAttribute("aria-required","true"),f&&E.setAttribute("aria-invalid","true"),E.checked=n[l.id]===b.id,E.addEventListener("change",()=>e.setValue({...n,[l.id]:b.id})),A.appendChild(E),g.appendChild(A),m.appendChild(g)}a.appendChild(m)}r.appendChild(a);let s=d("div",{className:"fillo-matrix-wrap",attrs:{id:e.ids.inputId,role:"group","aria-labelledby":e.ids.labelId,"data-fillo":"control"}});return q(s,e.field,e.error,e.ids,{requiredSupported:!1}),s.appendChild(r),ne(e.field,e.error,s,e.ids)}function el(e){let t=d("div",{className:"fillo-signature-field"}),n=d("div",{className:"fillo-signature",attrs:{"data-fillo":"control"}}),r=d("canvas",{className:"fillo-signature-canvas",attrs:{role:"img"}}),i=d("button",{className:"fillo-signature-clear",text:"Clear",attrs:{type:"button"}}),o=d("div",{className:"fillo-signature-hint",text:"Sign here",attrs:{"aria-hidden":"true"}});r.width=720,r.height=220;let a=r.getContext("2d"),s=!1,l=typeof e.value=="string"&&e.value.startsWith("data:image/"),c=()=>{r.setAttribute("aria-label",l?M.signatureSigned:M.signatureEmpty)};if(c(),l&&a){let b=new Image;b.onload=()=>a.drawImage(b,0,0,r.width,r.height),b.src=String(e.value),o.style.display="none"}let u=d("input",{className:"fillo-input fillo-signature-type-input",attrs:{id:e.ids.inputId,type:"text",autocomplete:"name"}});q(u,e.field,e.error,e.ids);let f=b=>{a&&(a.clearRect(0,0,r.width,r.height),b.trim()?(a.fillStyle=getComputedStyle(r).color||"#18181b",a.font=`italic ${Math.min(96,r.height*.45)}px "Segoe Script", "Brush Script MT", cursive`,a.textBaseline="middle",a.fillText(b,24,r.height/2),l=!0,o.style.display="none",e.setValue(r.toDataURL("image/png"),{render:!1})):(l=!1,o.style.display="",e.setValue(null,{render:!1})),c())};u.addEventListener("input",()=>f(u.value));let p=b=>{let g=r.getBoundingClientRect();return{x:(b.clientX-g.left)/g.width*r.width,y:(b.clientY-g.top)/g.height*r.height}};r.addEventListener("pointerdown",b=>{if(!a)return;s=!0,l=!0,o.style.display="none",c(),u.value&&(u.value=""),r.setPointerCapture(b.pointerId);let g=p(b);a.beginPath(),a.moveTo(g.x,g.y)}),r.addEventListener("pointermove",b=>{if(!s||!a)return;let g=p(b);a.lineWidth=2.4,a.lineCap="round",a.strokeStyle=getComputedStyle(r).color||"#18181b",a.lineTo(g.x,g.y),a.stroke()});let m=()=>{s&&(s=!1,l&&e.setValue(r.toDataURL("image/png"),{render:!1}))};r.addEventListener("pointerup",m),r.addEventListener("pointercancel",m),i.addEventListener("click",()=>{a?.clearRect(0,0,r.width,r.height),l=!1,o.style.display="",u.value="",c(),e.setValue(null,{render:!1})}),N(n,[r,o,i]);let h=d("div",{className:"fillo-signature-type"}),v=d("label",{className:"fillo-signature-type-label",text:"Or type your full name to sign",attrs:{for:e.ids.inputId}});return N(h,[v,u]),N(t,[n,h]),ne(e.field,e.error,t,e.ids)}function oo(e){return e<1024?`${e} B`:e<1024**2?`${(e/1024).toFixed(0)} KB`:e<1024**3?`${(e/1024**2).toFixed(1)} MB`:`${(e/1024**3).toFixed(2)} GB`}function ht(e,t=22){let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("class","fillo-file-state-icon"),n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("width",String(t)),n.setAttribute("height",String(t)),n.setAttribute("fill","none"),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false");for(let r of e){let i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d",r),n.appendChild(i)}return n}function so(e){let t=d("span",{className:`fillo-file-state fillo-file-state--${e}`,attrs:{"aria-hidden":"true"}});return t.appendChild(ht(e==="done"?["M3.75 12a8.25 8.25 0 1 0 16.5 0 8.25 8.25 0 1 0-16.5 0","m8.5 12 2.25 2.25 4.75-5"]:e==="failed"?["M3.75 12a8.25 8.25 0 1 0 16.5 0 8.25 8.25 0 1 0-16.5 0","M12 7.75v5.5","M12 16.5h.01"]:["M7.25 3.75h6.5l3 3v13.5h-9.5z","M13.75 3.75v3h3"])),t}function Kn(){let e=ht(["m7 7 10 10M17 7 7 17"],16);return e.setAttribute("class","fillo-file-action-icon"),e}function ao(e){let t=ht([e],16);return t.setAttribute("class","fillo-group-icon"),t}function Rt(e,t,n,r){let i=d("button",{className:e,attrs:{type:"button","aria-label":t}});return i.append(n),i.addEventListener("click",r),i}function tl(e){let t=e.field;if(t.kind!=="file_upload")return null;let n=e,r=n.uploadDisabledReason,i=r===void 0,o=t.maxFiles??1,a=t.maxFileSizeMb??500,s=Array.isArray(e.value)?e.value:[],l=n.uploadRows??[],c=o-s.length-l.filter(p=>p.error===void 0).length,u=d("div");if(c>0){let p=d("input",{className:"fillo-input",attrs:{id:e.ids.inputId,type:"file",hidden:""}});o>1&&(p.multiple=!0),t.accept?.length&&(p.accept=t.accept.join(",")),p.disabled=!i,p.addEventListener("change",()=>{if(!i)return;let h=Array.from(p.files??[]);p.value="",e.uploadFiles?.(t,h)});let m=d("div",{className:`fillo-dropzone${i?"":" fillo-dropzone--disabled"}`,attrs:{role:"button",tabindex:"0","aria-labelledby":e.ids.labelId,"data-fillo":"control"}});if(q(m,t,e.error,e.ids,{requiredSupported:!1}),i||m.setAttribute("aria-disabled","true"),m.addEventListener("dragover",h=>{h.preventDefault(),m.classList.add("fillo-dropzone--over"),m.setAttribute("data-drag-over","")}),m.addEventListener("dragleave",()=>{m.classList.remove("fillo-dropzone--over"),m.removeAttribute("data-drag-over")}),m.addEventListener("drop",h=>{h.preventDefault(),m.classList.remove("fillo-dropzone--over"),m.removeAttribute("data-drag-over"),i&&e.uploadFiles?.(t,Array.from(h.dataTransfer?.files??[]))}),m.addEventListener("click",()=>{i&&p.click()}),m.addEventListener("keydown",h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),i&&p.click())}),m.appendChild(p),i)N(m,[d("span",{className:"fillo-dropzone-title",text:M.dropzoneTitle(o>1)}),d("span",{className:"fillo-dropzone-hint",text:M.dropzoneHint(a)})]);else if(r==="render_only")m.appendChild(d("span",{className:"fillo-dropzone-hint",text:M.uploadsRenderOnly}));else if(n.storageFixUrl){let h=d("span",{className:"fillo-dropzone-hint",text:"Connect file storage to enable uploads"});h.append(" \u2014 "),h.appendChild(d("a",{text:n.storageFixUrl,attrs:{href:n.storageFixUrl,target:"_blank",rel:"noopener noreferrer"}})),m.appendChild(h)}else m.appendChild(d("span",{className:"fillo-dropzone-hint",text:M.uploadsUnavailable}));u.appendChild(m)}if(s.length>0||l.length>0){let p=d("ul",{className:"fillo-files"});for(let m of s){let h=d("li",{className:"fillo-file fillo-file--done"}),v=d("span",{className:"fillo-file-content"});N(v,[d("span",{className:"fillo-file-name",text:m.name}),d("span",{className:"fillo-file-meta",text:M.uploadedFile(oo(m.size))})]);let b=d("span",{className:"fillo-file-actions"});b.appendChild(Rt("fillo-file-remove",`${M.uploadRemove} ${m.name}`,Kn(),()=>e.setValue(s.filter(g=>g.fileId!==m.fileId)))),N(h,[so("done"),v,b]),p.appendChild(h)}for(let m of l){let h=m.error!==void 0,v=d("li",{className:`fillo-file${h?" fillo-file--failed":""}`});v.appendChild(so(h?"failed":"uploading"));let b=d("span",{className:"fillo-file-content"});if(b.appendChild(d("span",{className:"fillo-file-name",text:m.name})),h){let g=d("span",{className:"fillo-file-actions"});b.appendChild(d("span",{className:"fillo-file-error",text:m.error??""})),v.appendChild(b),!m.tooLarge&&c>0&&g.appendChild(Rt("fillo-file-retry",`${M.uploadRetry} ${m.name}`,M.uploadRetry,()=>n.uploadAction?.(m.key,"retry"))),g.appendChild(Rt("fillo-file-remove",`${M.uploadDismiss} ${m.name}`,Kn(),()=>n.uploadAction?.(m.key,"dismiss"))),v.appendChild(g)}else{let g=d("span",{className:"fillo-progress-bar"});g.style.width=`${m.fraction*100}%`,b.appendChild(d("span",{className:"fillo-file-meta",text:M.uploadingFile(Math.round(m.fraction*100),oo(m.size))}));let A=d("span",{className:"fillo-file-actions"});A.appendChild(Rt("fillo-file-remove",`${M.uploadCancel} ${m.name}`,Kn(),()=>n.uploadAction?.(m.key,"cancel"))),N(v,[b,A,N(d("span",{className:"fillo-progress",attrs:{role:"progressbar","aria-label":`Uploading ${m.name}`,"aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":String(Math.round(m.fraction*100))}}),[g])])}p.appendChild(v)}u.appendChild(p)}let f=n.uploadNotice;return f&&u.appendChild(d("p",{className:"fillo-upload-notice",text:f})),ne(t,e.error,u,e.ids)}function nl(e){let t=e.field,n=d("div",{className:"fillo-field fillo-field--calculated fillo-calculated",attrs:{"data-fillo":"calculated","data-field":t.id,"data-kind":t.kind}});n.appendChild(d("label",{className:"fillo-label",text:t.label,attrs:{id:e.ids.labelId,for:e.ids.inputId,"data-fillo":"label"}})),t.description&&n.appendChild(d("p",{className:"fillo-description",text:t.description,attrs:{id:e.ids.descriptionId,"data-fillo":"fieldDescription"}}));let r=e.value,i=r!=null&&r!=="",o=d("output",{className:`fillo-calculated-value${i?"":" fillo-calculated-value--empty"}`,text:i?Rn(t,r):"\u2014",attrs:{id:e.ids.inputId}});return t.description&&o.setAttribute("aria-describedby",e.ids.descriptionId),n.appendChild(o),n}var lo=new Map;function Qn(e){if(!e.shuffleOptions)return e.options;let t=`${e.id}|${e.options.map(o=>o.id).join(",")}`,n=lo.get(t);if(!n){n=e.options.map(o=>o.id);for(let o=n.length-1;o>0;o--){let a=Math.floor(Math.random()*(o+1));[n[o],n[a]]=[n[a],n[o]]}lo.set(t,n)}let r=new Map(e.options.map(o=>[o.id,o])),i=n.flatMap(o=>r.get(o)??[]);return i.length===e.options.length?i:e.options}function dt(e){let t=e.getValue?.()??e.value;return Array.isArray(t)?t:[]}function rl(e,t){return Math.max(t.length,e.minInstances??1)}function il(e){return Math.max(e.minInstances??1,0)}function Jn(e,t){let n=[...e];for(;n.length<t;)n.push({});return n}function ol(e){let t=e.field;if(t.kind!=="repeating_group")return null;let n=e,r=n.announce,i=n.instanceId??"",o=t.itemLabel||t.label,a=dt(e),s=rl(t,a),l=il(t),c=d("div",{className:"fillo-group",attrs:{id:e.ids.inputId,"data-fillo":"control"}});q(c,t,e.error,e.ids,{requiredSupported:!1});for(let p=0;p<s;p++){let m=a[p]??{},h=M.groupInstanceLabel(o,p+1,s),v=d("div",{className:"fillo-group-instance",attrs:{role:"group","aria-label":h,tabindex:"-1"}}),b=d("div",{className:"fillo-group-instance-header"}),g=d("button",{className:"fillo-group-remove",attrs:{type:"button","aria-label":M.groupRemoveLabel(o,p+1)}});g.appendChild(ao("M6 6l12 12M18 6 6 18"));let A=s>l;g.toggleAttribute("disabled",!A),A||(g.setAttribute("aria-disabled","true"),g.setAttribute("title",`At least ${l} ${l===1?"entry":"entries"} required`)),g.addEventListener("click",()=>{if(s<=l)return;let E=Jn(dt(e),s);E.splice(p,1),e.setValue(E),n.setGroupFocus?.({groupId:t.id,cardIndex:p-1,intoControl:!1}),r?.(M.groupInstanceRemoved(o,E.length))}),N(b,[d("p",{className:"fillo-group-instance-title",text:h}),g]),v.appendChild(b);for(let E of Tn(t,m)){let R=`${t.id}.${p}.${E.id}`,re={...E,id:R},W=mo(i,R),ie=(ce,H)=>{let ue=Jn(dt(e),s);ue[p]={...ue[p]??{},[E.id]:ce},e.setValue(ue,H)},ge={field:re,value:m[E.id],error:e.api.errors[R],ids:W,api:e.api,setValue:ie,getValue:()=>dt(e)[p]?.[E.id],announce:n.announce,announceAlert:n.announceAlert,registerOverlay:n.registerOverlay,activeOtherFields:n.activeOtherFields},le=n.renderChildField?.(ge)??yo(ge);le&&v.appendChild(le)}c.appendChild(v)}let u=s>=t.maxInstances,f=d("button",{className:"fillo-group-add",attrs:{type:"button"}});return f.append(ao("M12 5v14M5 12h14"),t.addLabel||M.groupAdd),f.toggleAttribute("disabled",u),u&&(f.setAttribute("aria-disabled","true"),f.setAttribute("title",`Maximum ${t.maxInstances} ${t.maxInstances===1?"entry":"entries"}`)),f.addEventListener("click",()=>{if(s>=t.maxInstances)return;let p=Jn(dt(e),s);p.push({}),e.setValue(p),n.setGroupFocus?.({groupId:t.id,cardIndex:p.length-1,intoControl:!0}),r?.(M.groupInstanceAdded(o,p.length,p.length))}),c.appendChild(f),ne(t,e.error,c,e.ids)}var sl={short_text:e=>ut("text",e),email:e=>ut("email",e),url:e=>ut("url",e),phone:ja,number:e=>ut("number",e),date:e=>ut("date",e),long_text:Va,select:Ha,multi_select:Ga,dropdown:Wa,checkbox:Ka,rating:Ja,linear_scale:Xa,ranking:Ya,matrix:Qa,signature:el,file_upload:tl,calculated:nl,repeating_group:ol};function yo(e){if(e.field.kind==="hidden"||e.field.kind==="custom")return null;let t=sl[e.field.kind];return t?t(e):null}var al="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit",co="fillo-turnstile-script",ll=2e4,cl=/^[A-Za-z0-9_-]{1,255}$/,pt=null;function Ge(){return globalThis.turnstile}function ul(){return typeof window>"u"||typeof document>"u"?Promise.reject(new Error("Turnstile needs a browser")):Ge()?Promise.resolve():pt||(pt=new Promise((e,t)=>{let n=()=>{Ge()?e():t(new Error("Turnstile loaded without its global"))},r=document.getElementById(co);if(r){if(Ge()){e();return}r.addEventListener("load",n,{once:!0}),r.addEventListener("error",()=>t(new Error("Turnstile script failed to load")),{once:!0});return}let i=document.createElement("script");i.id=co,i.src=al,i.async=!0,i.defer=!0,i.addEventListener("load",n,{once:!0}),i.addEventListener("error",()=>{i.remove(),pt=null,t(new Error("Turnstile script failed to load"))},{once:!0}),document.head.appendChild(i)}),pt)}function uo(){return d("div",{className:"fillo-turnstile",attrs:{"data-fillo":"turnstile"}})}var gt=class{constructor(t,n){this.target=t;this.options=n;this.element.className="fillo-dom-root",n.preview===!0&&yl(),t.replaceChildren(this.element,this.statusEl,this.alertEl),this.resolve()}target;options;element=d("div");statusEl=d("span",{className:"fillo-sr-only",attrs:{role:"status","aria-live":"polite","data-fillo":"announce"}});alertEl=d("span",{className:"fillo-sr-only",attrs:{role:"alert","data-fillo":"announce-alert"}});instanceId=`d${++Ma}`;schema=null;theme;formId;closed=!1;fetchedPoweredBy=null;fetchedBrandLabel;fetchedBrandHref;phase="loading";engine=null;destroyed=!1;renderQueued=!1;hpValue="";liveSubmissionHandled=!1;activeOtherFields=new Set;inFlight=new Map;uploadNotices=new Map;focusIntent=null;overlays=new Set;challenge;challengeToken;challengeError=!1;turnstileContainer=uo();turnstileWidgetId=null;turnstileSiteKey;turnstileLoadInFlight=!1;turnstileAttempt=0;challengeFrame=null;challengeFrameSrc=null;challengeFrameOrigin=null;challengeMessageHandler=null;challengeWatchdog=null;announce=t=>{this.statusEl.textContent="",requestAnimationFrame(()=>{this.statusEl.textContent=t})};announceAlert=t=>{this.alertEl.textContent="",requestAnimationFrame(()=>{this.alertEl.textContent=t})};devChrome(){return this.options.preview===!0||fl()}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 t=this.schema??{version:1,title:"",pages:[],settings:{}},n=this.engine?.getState(),r=n?.pageCount??t.pages.length;return{form:t,formId:this.formId,client:this.options.renderOnly?void 0:this.options.client,data:n?.data??this.mutableData,errors:n?.errors??{},status:this.status,pageIndex:n?.pageIndex??0,pageCount:r,page:n?.page??t.pages[0]??{id:"empty",blocks:[]},blocks:n?.blocks??[],isFirstPage:n?.isFirstPage??!0,isLastPage:n?.isLastPage??r<=1,setValue:(i,o,a)=>this.setValueInternal(i,o,a),next:()=>this.next(),back:()=>this.back(),submit:()=>this.submit()}}resolveFormIdFn;notOpenVariant=null;fatalError=null;genericUnavailable=!1;syncErrorNotice=null;stagedNotice=!1;draftNotice=!1;syncWarningCode;syncWarningUrl;syncFormUrl;uploadsAvailable;uploadFileSizeLimitMb;resolutionFailureCode=null;async resolve(){try{this.challenge=this.options.renderOnly?void 0:this.options.challenge;let t=Gn(this.options.form)?this.options.form:null;if(t){if(this.options.renderOnly){this.setSchema(t.schema,this.options.theme??t.theme,void 0);return}!this.options.client&&this.options.formId&&(this.options.client=Le());let i=this.options.client;if(i?.key&&(this.resolveFormIdFn=async()=>{try{let o=await qn(i,t,{bypassCache:!0});if(this.syncWarningCode=o.warningCode,this.syncWarningUrl=o.warningUrl,this.syncFormUrl=o.manageUrl,this.uploadsAvailable=o.uploadsAvailable,this.uploadFileSizeLimitMb=o.uploadFileSizeLimitMb,o.status==="draft")throw new S("This form is no longer published. Submission was stopped before sending answers.",403,void 0,"form_not_published");if(o.accepting===!1)throw new S("This form is no longer accepting responses. Submission was stopped before sending answers.",403,void 0,o.acceptingReason??"form_not_accepting");let a=Te(o.resolvedSchema??t.schema);if(!a.ok)throw new S(`The canonical form schema was invalid: ${a.error}`,502,void 0,"invalid_sync_schema");if(this.schema&&!eo(this.schema,a.schema))throw new S("The live form changed after this page loaded. Submission stopped before incompatible answers were sent. Reload to use the published schema.",409,void 0,"form_schema_changed");return o.syncError&&this.reportSyncNotice(new S(o.syncError.message,403,void 0,o.syncError.code)),this.resolutionFailureCode=null,o.formId}catch(o){let a=ft(o);throw this.resolutionFailureCode=a.code??"sync_failed",this.reportSubmitSyncFailure(a),a}}),!i?.key&&this.options.formId&&this.setSchema(t.schema,this.options.theme??t.theme,this.options.formId),!i&&!this.options.formId)throw this.genericUnavailable=!this.devChrome(),ho();if(i&&!i.key&&!this.options.formId){this.reportSyncFailure(new S('Code forms need createClient({ key: "pk_\u2026" }) to resolve the live form. Pass a publishable key or a published formId.',401,void 0,"sync_key_required"));return}if(!i?.key)return;this.devChrome()?this.setSchema(t.schema,this.options.theme??t.theme,this.options.formId):(this.theme=this.options.theme??t.theme,this.render());try{let o=await qn(i,t);if(this.destroyed)return;if((o.staged||o.syncError)&&!o.resolvedSchema)throw new S("Sync did not return the live schema needed to render safely. Publish changes before deploy, and update @usefillo/* or your API.",409,void 0,"sync_snapshot_required");let a=this.devChrome();if(this.notOpenVariant=a?null:o.status==="draft"?"notOpen":o.accepting===!1?po(o.acceptingReason):null,this.stagedNotice=!!o.staged,this.draftNotice=o.status==="draft",this.syncWarningCode=o.warningCode,this.syncWarningUrl=o.warningUrl,this.syncFormUrl=o.manageUrl,this.uploadsAvailable=o.uploadsAvailable,this.uploadFileSizeLimitMb=o.uploadFileSizeLimitMb,this.challenge=this.options.challenge??o.challenge,o.branding&&(this.fetchedPoweredBy=o.branding.poweredBy,this.fetchedBrandLabel=o.branding.label,this.fetchedBrandHref=o.branding.href),a&&o.resolvedSchema)this.formId=o.formId,this.engine?.setContext({formId:o.formId}),this.render();else{let l=o.resolvedSchema??t.schema,c=this.options.theme??(o.resolvedSchema?o.resolvedTheme??void 0:t.theme);this.applyCanonicalSchema(l,c,o.formId)}o.warning&&console.warn(`[fillo] ${o.warning}`),o.syncError&&this.reportSyncNotice(new S(o.syncError.message,403,void 0,o.syncError.code));let s=o.warningUrl?` \u2014 connect storage to publish: ${o.warningUrl}`:"";o.staged?console.info(`[fillo] "${t.id}" changes staged as a draft \u2014 rendering the live version until you publish them in your Fillo dashboard${s}`):o.status==="draft"&&console.info(`[fillo] "${t.id}" is a draft \u2014 it renders here but won't accept responses until published${s}`)}catch(o){if(this.destroyed)return;this.reportSyncFailure(ft(o))}return}let n=this.options.form&&!Gn(this.options.form)?this.options.form:null;if(n){if(this.options.renderOnly){this.setSchema(n,this.options.theme,void 0);return}if(!this.options.formId)throw this.genericUnavailable=!this.devChrome(),ho();this.options.client??=Le(),this.setSchema(n,this.options.theme,this.options.formId);return}if(!this.options.formId)throw new S("Provide either `form`, or a `formId`.",0);this.options.client??=Le(),this.render();let r=await this.options.client.getForm(this.options.formId);if(this.destroyed)return;if(r.accepting===!1?this.notOpenVariant=po(r.acceptingReason):this.closed=!!r.closed,this.uploadsAvailable=r.uploadsAvailable,this.uploadFileSizeLimitMb=r.uploadFileSizeLimitMb,this.fetchedPoweredBy=r.branding?.poweredBy??null,this.fetchedBrandLabel=r.branding?.label,this.fetchedBrandHref=r.branding?.href,this.challenge=this.options.challenge??r.challenge,r.accepting===!1&&this.options.renderError){let i=this.notOpenVariant==="closed"?"This form is no longer accepting responses.":"This form isn't accepting responses yet.";this.fatalError=new S(i,403,void 0,r.acceptingReason),this.phase="error",this.render(this.fatalError);return}this.setSchema(r.schema,this.options.theme??r.theme??void 0,r.id)}catch(t){if(this.destroyed)return;this.handleError(ft(t))}}setSchema(t,n,r){if(this.destroyed)return;let i=Te(t);if(!i.ok)throw new S(`This form could not be rendered: ${i.error}`,422);let o=i.schema;this.schema=o,this.theme=n;let a=this.options.renderOnly===!0;this.formId=a?void 0:r;let s=this.notOpenVariant!==null,l=s||a;this.engine=Wi({form:o,formId:l?void 0:r,client:l?void 0:this.options.client,initialData:this.options.initialData,onChange:s?void 0:this.options.onChange,onSubmitted:l?void 0:this.options.onSubmitted,getHoneypot:()=>this.element.querySelector('input[name="fillo_hp_field"]')?.value??this.hpValue,surface:"default",resolveFormId:l?void 0:this.resolveFormIdFn,skipValidation:a,verboseResolutionErrors:this.devChrome(),respondent:l?void 0:this.options.respondent,challengeRequired:l?!1:!!this.challenge,getChallengeToken:()=>this.challengeToken,onChallengeFailed:()=>this.resetChallengeWidget()});let c=this.engine.getState().status,u=this.engine.getState().resumedDraft,f=this.engine.getState().editingPrevious;this.engine.subscribe(()=>{let p=this.engine?.getState();p&&(p.status!==c||p.resumedDraft!==u||p.editingPrevious!==f)&&(p.editingPrevious&&!f?this.announce(T.editNotice):p.resumedDraft&&!u&&this.announce(T.resumeNotice),c=p.status,u=p.resumedDraft,f=p.editingPrevious,this.queueRender())}),l||this.configureDraftFlush(o),this.phase=this.closed?"closed":"ready",this.render()}applyCanonicalSchema(t,n,r){if(!this.engine){this.setSchema(t,n,r);return}let i=Te(t);if(!i.ok)throw new S(`This form could not be rendered: ${i.error}`,422);let o=i.schema;this.schema=o,this.theme=n,this.formId=r,this.engine.setContext({form:o,formId:r}),this.notOpenVariant===null&&this.configureDraftFlush(o),this.phase=this.closed?"closed":"ready",this.render()}draftFlushWired=!1;flushDraftBound=()=>this.engine?.flushDraft();visibilityFlushBound=()=>{document.visibilityState==="hidden"&&this.engine?.flushDraft()};configureDraftFlush(t){this.teardownDraftFlush(),t.settings.saveProgress&&typeof window<"u"&&(window.addEventListener("pagehide",this.flushDraftBound),document.addEventListener("visibilitychange",this.visibilityFlushBound),this.draftFlushWired=!0)}teardownDraftFlush(){!this.draftFlushWired||typeof window>"u"||(window.removeEventListener("pagehide",this.flushDraftBound),document.removeEventListener("visibilitychange",this.visibilityFlushBound),this.draftFlushWired=!1)}flushDraft(){this.engine?.flushDraft()}resetDraft(){this.engine?.resetDraft(),this.queueRender()}setValue(t,n){this.setValueInternal(t,n)}setValueInternal(t,n,r={}){this.notOpenVariant||(this.engine?.setValue(t,n),r.render!==!1&&this.queueRender())}next(){if(!this.engine||this.notOpenVariant)return;let t=this.engine.getState().pageIndex;this.engine.next(),this.focusIntent=this.engine.getState().pageIndex!==t?"page":"error",this.render()}back(){!this.engine||this.notOpenVariant||(this.engine.back(),this.focusIntent="page",this.render())}async submit(){if(!this.engine||this.phase!=="ready"||this.notOpenVariant)return;let t=this.engine.submit();this.hasErrors()?this.focusIntent="error":this.engine.getState().status==="submitting"&&this.announce(M.submittingAnnouncement),this.render();try{await t}catch(n){this.options.onError?.(ft(n)),this.focusIntent="error",this.render();return}this.hasErrors()&&(this.focusIntent="error"),this.render()}hasErrors(){return Object.keys(this.engine?.getState().errors??{}).length>0}setTheme(t){this.options.theme=t,this.theme=t,this.render()}setClient(t){this.options.client=t,this.engine?.setContext({client:t}),this.render()}setRespondent(t){this.options.respondent=t,this.engine?.setContext({respondent:t})}fieldActive(t){let n=0;for(let r of this.inFlight.values())r.fieldId===t&&r.error===void 0&&n++;return n}uploadRowsFor(t){let n=[];for(let[r,i]of this.inFlight)i.fieldId===t&&n.push({key:r,name:i.name,size:i.size,fraction:i.fraction,error:i.error,tooLarge:i.tooLarge});return n}uploadAction=(t,n)=>{let r=this.inFlight.get(t);if(r){if(n==="cancel")r.controller.abort(),this.inFlight.delete(t);else if(n==="dismiss")this.inFlight.delete(t);else{if(r.tooLarge)return;this.inFlight.delete(t),this.startUpload(r.fieldId,r.file,r.maxFiles)}this.fieldActive(r.fieldId)===0&&this.engine?.setUploading(r.fieldId,!1),this.queueRender()}};async startUpload(t,n,r){let i=`${n.name}-${n.size}-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,o=new AbortController;this.inFlight.set(i,{fieldId:t,name:n.name,size:n.size,fraction:0,file:n,controller:o,maxFiles:r}),this.engine?.setUploading(t,!0),this.queueRender();try{let a=this.options.client&&this.formId?await this.options.client.uploadFile(this.formId,n,{fieldId:t,signal:o.signal,onProgress:l=>{let c=this.inFlight.get(i);c&&(c.fraction=l.fraction,this.queueRender())}}):{fileId:`local:${n.name}:${n.size}`,name:n.name,size:n.size,mime:n.type||"application/octet-stream"};if(this.destroyed)return;this.inFlight.delete(i);let s=r>1&&Array.isArray(this.mutableData[t])?this.mutableData[t]:[];this.setValueInternal(t,[...s,a])}catch(a){if(this.destroyed||o.signal.aborted)return;let s=ft(a),l=s.status===0||s.status!==void 0&&s.status>=500?M.uploadUnavailable:M.uploadFailed,c=this.inFlight.get(i);c&&(c.error=l),this.announceAlert(l),this.options.onError?.(s)}finally{this.fieldActive(t)===0&&this.engine?.setUploading(t,!1),this.queueRender()}}async uploadFiles(t,n){if(!this.schema||this.notOpenVariant)return;let r=t.maxFiles??1,i=r>1&&Array.isArray(this.mutableData[t.id])?this.mutableData[t.id].length:0,o=Math.max(0,r-i-this.fieldActive(t.id)),a=n.slice(0,o),s=t.maxFileSizeMb??500,l=this.uploadFileSizeLimitMb?Math.min(s,this.uploadFileSizeLimitMb):s,c=l*1024*1024,u=a.filter(h=>h.size<=c),f=a.filter(h=>h.size>c),p=n.length-a.length,m=a.length-u.length;if(p>0||m>0){let h=[];p>0&&h.push(`You can attach up to ${r} file${r===1?"":"s"}. ${p} ${p===1?"file was":"files were"} not added.`);let v=h.join(" ");v?this.uploadNotices.set(t.id,v):this.uploadNotices.delete(t.id),v&&this.announce(v)}else this.uploadNotices.delete(t.id);for(let h of f){let v=M.fileTooLarge(l),b=`${h.name}-${h.size}-${Date.now()}-${Math.random().toString(36).slice(2,7)}`;this.inFlight.set(b,{fieldId:t.id,name:h.name,size:h.size,fraction:0,error:v,tooLarge:!0,file:h,controller:new AbortController,maxFiles:r}),this.announceAlert(v)}if(u.length===0){this.queueRender();return}await Promise.all(u.map(h=>this.startUpload(t.id,h,r)))}destroy(){this.destroyed=!0,this.teardownDraftFlush(),this.closeOverlays(),this.teardownTurnstileWidget();for(let t of this.inFlight.values())t.controller.abort();this.inFlight.clear(),this.engine?.destroy(),this.engine=null,this.target.replaceChildren()}storageBlocked(){return this.uploadsAvailable===!1}registerOverlay=t=>(this.overlays.add(t),()=>this.overlays.delete(t));closeOverlays(){if(this.overlays.size!==0){for(let t of Array.from(this.overlays))try{t()}catch{}this.overlays.clear()}}ensureChallengeWidget(t){t.bridgeUrl?this.ensureChallengeBridge(t.bridgeUrl):this.ensureTurnstileWidget(t.siteKey)}ensureChallengeBridge(t){if(typeof window>"u")return;let n;try{n=new URL(t)}catch{this.handleChallengeError();return}if(n.protocol!=="https:"&&n.protocol!=="http:"){this.handleChallengeError();return}n.searchParams.set("origin",window.location.origin),n.searchParams.set("theme",this.options.challengeTheme??"auto"),this.formId&&cl.test(this.formId)&&n.searchParams.set("cdata",this.formId),n.searchParams.set("appearance",(this.options.challengeAppearance??"interaction-only")==="interaction-only"?"interaction-only":"always");let r=n.toString();if(this.challengeFrame&&this.challengeFrameSrc===r)return;this.teardownTurnstileWidget();let i=++this.turnstileAttempt,o=d("iframe",{className:"fillo-turnstile-frame",attrs:{src:r,title:"Human verification",width:"300",height:"65",referrerpolicy:"no-referrer"}});this.challengeFrame=o,this.challengeFrameSrc=r,this.challengeFrameOrigin=n.origin,this.turnstileContainer.appendChild(o),this.setChallengeFrameVisible((this.options.challengeAppearance??"interaction-only")!=="interaction-only");let a=s=>{if(i!==this.turnstileAttempt||this.destroyed||s.origin!==this.challengeFrameOrigin||!this.challengeFrame||s.source!==this.challengeFrame.contentWindow)return;let l=s.data;switch(l?.type){case"fillo:challenge:ready":this.settleChallengeWatchdog();break;case"fillo:challenge:token":this.settleChallengeWatchdog(),typeof l.token=="string"&&l.token.length>0&&this.handleChallengeToken(l.token),(this.options.challengeAppearance??"interaction-only")==="interaction-only"&&this.setChallengeFrameVisible(!1);break;case"fillo:challenge:interactive":this.setChallengeFrameVisible(!0);break;case"fillo:challenge:interactive-done":(this.options.challengeAppearance??"interaction-only")==="interaction-only"&&this.setChallengeFrameVisible(!1);break;case"fillo:challenge:expired":this.handleChallengeToken(void 0);break;case"fillo:challenge:error":this.settleChallengeWatchdog(),this.handleChallengeToken(void 0),this.handleChallengeError();break}};this.challengeMessageHandler=a,window.addEventListener("message",a),this.challengeWatchdog=window.setTimeout(()=>{i!==this.turnstileAttempt||this.destroyed||(this.handleChallengeToken(void 0),this.handleChallengeError())},ll)}setChallengeFrameVisible(t){let n=this.challengeFrame;n&&(n.setAttribute("height",t?"65":"0"),t?(n.removeAttribute("aria-hidden"),n.removeAttribute("tabindex")):(n.setAttribute("aria-hidden","true"),n.setAttribute("tabindex","-1")),this.turnstileContainer.setAttribute("data-fillo-challenge-visible",t?"true":"false"))}settleChallengeWatchdog(){this.challengeWatchdog!==null&&typeof window<"u"&&window.clearTimeout(this.challengeWatchdog),this.challengeWatchdog=null}teardownChallengeBridge(){this.challengeMessageHandler&&typeof window<"u"&&window.removeEventListener("message",this.challengeMessageHandler),this.challengeMessageHandler=null,this.settleChallengeWatchdog(),this.challengeFrame?.remove(),this.challengeFrame=null,this.challengeFrameSrc=null,this.challengeFrameOrigin=null}ensureTurnstileWidget(t){if(this.turnstileSiteKey!==t&&(this.teardownTurnstileWidget(),this.turnstileSiteKey=t),this.turnstileWidgetId!==null||this.turnstileLoadInFlight||this.challengeError)return;this.turnstileLoadInFlight=!0;let n=++this.turnstileAttempt;ul().then(()=>{if(this.destroyed||n!==this.turnstileAttempt)return;let r=Ge();if(!r){this.turnstileLoadInFlight=!1,this.handleChallengeError();return}this.turnstileWidgetId=r.render(this.turnstileContainer,{sitekey:t,theme:"auto",callback:i=>this.handleChallengeToken(i),"error-callback":()=>{this.handleChallengeToken(void 0),this.handleChallengeError()},"expired-callback":()=>this.resetChallengeWidget(),"timeout-callback":()=>this.resetChallengeWidget()}),this.turnstileLoadInFlight=!1}).catch(()=>{this.destroyed||n!==this.turnstileAttempt||(this.turnstileLoadInFlight=!1,this.handleChallengeError())})}handleChallengeToken(t){this.challengeToken=t,t&&(this.challengeError=!1),this.queueRender()}handleChallengeError(){this.challengeError=!0,this.announceAlert(T.challengeUnavailable),this.queueRender()}resetChallengeWidget(){this.challengeToken=void 0,this.challengeFrame&&this.challengeFrameOrigin?this.challengeFrame.contentWindow?.postMessage({type:"fillo:challenge:reset"},this.challengeFrameOrigin):this.turnstileWidgetId&&Ge()?.reset(this.turnstileWidgetId),this.queueRender()}teardownTurnstileWidget(){if(this.turnstileWidgetId===null&&!this.turnstileLoadInFlight&&this.challengeFrame===null)return;this.turnstileAttempt++,this.teardownChallengeBridge();let t=Ge();if(this.turnstileWidgetId&&t)try{t.remove(this.turnstileWidgetId)}catch{}this.turnstileWidgetId=null,this.turnstileLoadInFlight=!1,this.challengeError=!1,this.turnstileContainer=uo(),this.challengeToken=void 0}captureFocus(){if(typeof document>"u")return null;let t=document.activeElement;if(!t||!this.element.contains(t))return null;let n={};t.id&&(n.id=t.id);let r=t.getAttribute("data-fillo-rank-opt");r&&(n.rankOpt=r,n.rankDir=t.getAttribute("data-fillo-rank-dir")??void 0);let i=t.closest("[data-field]");if(i&&(n.fieldId=i.getAttribute("data-field")??void 0,n.controlIndex=Array.from(i.querySelectorAll(mt)).indexOf(t)),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)try{n.selStart=t.selectionStart,n.selEnd=t.selectionEnd}catch{}return n.id||n.rankOpt||n.fieldId?n:null}restoreFocus(t){if(typeof document>"u")return;let n=null;if(t.rankOpt){let r=Array.from(this.element.querySelectorAll("[data-fillo-rank-opt]")).filter(i=>i.getAttribute("data-fillo-rank-opt")===t.rankOpt);n=r.find(i=>i.getAttribute("data-fillo-rank-dir")===t.rankDir&&!i.disabled)??r.find(i=>!i.disabled)??null}if(!n&&t.id&&(n=document.getElementById(t.id)),!n&&t.fieldId!=null&&t.controlIndex!=null&&t.controlIndex>=0){let r=Array.from(this.element.querySelectorAll("[data-field]")).find(i=>i.getAttribute("data-field")===t.fieldId);r&&(n=Array.from(r.querySelectorAll(mt))[t.controlIndex]??null)}if(!(!n||typeof n.focus!="function")&&(n.focus(),(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)&&t.selStart!=null))try{n.setSelectionRange(t.selStart,t.selEnd??t.selStart)}catch{}}applyFocus(t,n){if(!(typeof document>"u")){if(t==="error"){let r=this.element.querySelector('[aria-invalid="true"]');r&&Pa(r)?.focus();return}if(t==="page"){let i=this.element.querySelector(".fillo-page-title, .fillo-title")??this.element.querySelector(".fillo-blocks");i&&(i.hasAttribute("tabindex")||i.setAttribute("tabindex","-1"),i.focus?.());return}if(t){this.applyGroupFocus(t);return}n&&this.restoreFocus(n)}}applyGroupFocus(t){let n=Array.from(this.element.querySelectorAll("[data-field]")).find(o=>o.getAttribute("data-field")===t.groupId),r=n?Array.from(n.querySelectorAll(".fillo-group-instance")):[],i=t.cardIndex>=0?r[t.cardIndex]:void 0;if(i){(t.intoControl?Ra(i)??i:i).focus();return}n?.querySelector(".fillo-group-add")?.focus()}handleError(t){this.destroyed||(this.fatalError=t,this.phase="error",this.options.onError?.(t),this.render(t))}reportSyncFailure(t){if(this.destroyed)return;console.warn(`[fillo] form sync failed${t.code?` (${t.code})`:""}: ${t.message}`),this.syncErrorNotice=t;let n=this.devChrome();if(!n||this.options.renderError){this.genericUnavailable=!n,this.handleError(t);return}this.options.onError?.(t),n&&this.render()}reportSyncNotice(t){this.destroyed||(console.warn(`[fillo] form sync needs attention${t.code?` (${t.code})`:""}: ${t.message}`),this.syncErrorNotice=t,this.options.onError?.(t),this.devChrome()&&this.render())}reportSubmitSyncFailure(t){this.destroyed||(console.warn(`[fillo] form sync failed${t.code?` (${t.code})`:""}: ${t.message}`),this.syncErrorNotice=t)}queueRender(){this.renderQueued||this.destroyed||(this.renderQueued=!0,setTimeout(()=>{this.renderQueued=!1,this.render()},0))}render(t){if(this.destroyed)return;let n=this.focusIntent;this.focusIntent=null;let r=n?null:this.captureFocus();if(this.closeOverlays(),this.phase==="ready"&&this.engine?.getState().status!=="submitted"||this.teardownTurnstileWidget(),this.element.replaceChildren(),this.phase==="loading"){let a=d("div",{className:`fillo-form fillo-form--loading ${this.options.className??""}`,attrs:{"aria-busy":"true","data-fillo":"root","data-state":"loading"}});He(a,this.theme),N(a,[d("div",{className:"fillo-skeleton"}),d("div",{className:"fillo-skeleton"}),d("div",{className:"fillo-skeleton fillo-skeleton--short"})]),this.element.appendChild(a);return}let o=t??this.fatalError;if(this.phase==="error"&&o){let a=o.code==="form_target_required"&&this.devChrome()?`${o.message} (${o.code})`:null,s=this.options.renderError?.(o)??d("div",{className:"fillo-form fillo-form--error",text:a??(this.genericUnavailable?"This form is unavailable.":_l(o))});s.hasAttribute("data-fillo")||s.setAttribute("data-fillo","root"),s.hasAttribute("data-state")||s.setAttribute("data-state","error"),o.code&&!s.hasAttribute("data-error-code")&&s.setAttribute("data-error-code",o.code),s.hasAttribute("role")||s.setAttribute("role","alert"),He(s,this.theme),this.element.appendChild(s);return}if(this.phase==="closed"){let a=d("div",{className:`fillo-form fillo-form--closed ${this.options.className??""}`,attrs:{"data-fillo":"root","data-state":"closed"}});He(a,this.theme),a.appendChild(d("p",{className:"fillo-closed",text:"This form is no longer accepting responses."})),this.element.appendChild(a);return}if(this.notOpenVariant&&this.schema){this.element.appendChild(this.renderNotOpen(this.notOpenVariant)),this.brandingVisible()&&this.element.appendChild(Xn(this.fetchedBrandLabel,this.fetchedBrandHref));return}if(this.schema){if(this.engine?.getState().status==="submitted"){let a=this.api(),s=this.engine.getState(),l=this.options.renderSuccess?.(a)??pl(this.schema);if(l.setAttribute("data-fillo",l.getAttribute("data-fillo")??"root"),this.formId&&!l.hasAttribute("data-fillo-form-id")&&l.setAttribute("data-fillo-form-id",this.formId),l.setAttribute("data-state",l.getAttribute("data-state")??"submitted"),l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1"),He(l,this.theme),this.element.appendChild(l),this.brandingVisible()&&this.element.appendChild(Xn(this.fetchedBrandLabel,this.fetchedBrandHref)),!s.restoredSubmission&&!this.liveSubmissionHandled){this.liveSubmissionHandled=!0;let c=Me(this.schema.settings.redirectUrl);c&&typeof window<"u"?window.location.assign(c):(l.focus(),this.announce(l.textContent??""))}return}this.devChrome()&&N(this.element,wl({preview:this.options.preview===!0,devNotices:this.options.devNotices,syncError:this.syncErrorNotice,staged:this.stagedNotice,draft:this.draftNotice,warningUrl:this.syncWarningUrl,formUrl:this.syncFormUrl,noClient:!this.options.client&&!this.options.renderOnly})),this.element.appendChild(this.renderForm()),this.brandingVisible()&&this.element.appendChild(Xn(this.fetchedBrandLabel,this.fetchedBrandHref)),this.applyFocus(n,r)}}brandingVisible(){return this.fetchedPoweredBy??!0}renderNotOpen(t){let n=d("div",{className:`fillo-form fillo-form--not-open ${this.options.className??""}`,attrs:{"data-fillo":"root","data-state":"closed"}});He(n,this.theme);let r=d("div",{className:"fillo-not-open-preview",attrs:{"aria-hidden":"true",inert:""}});r.appendChild(this.renderForm());let i=d("div",{className:"fillo-not-open-card",attrs:{role:"status","data-fillo":"not-open-card"}});return i.appendChild(d("h2",{className:"fillo-not-open-title",text:t==="closed"?T.closedTitle:T.notOpenTitle})),i.appendChild(d("p",{className:"fillo-not-open-body",text:t==="closed"?T.closed:T.notOpenBody})),N(n,[r,i]),n}renderForm(){let t=this.api(),n=this.notOpenVariant!==null,r=!!this.challenge,i=!n&&r&&t.isLastPage,o=d(n?"div":"form",{className:`fillo-form ${this.options.className??""}`,attrs:{"data-fillo":n?"preview-form":"root","data-state":n?"preview":t.status,"data-page":String(t.pageIndex+1)}});!n&&this.formId&&o.setAttribute("data-fillo-form-id",this.formId),o.toggleAttribute("data-last-page",t.isLastPage),He(o,this.theme);let a=()=>{t.isLastPage?this.submit():this.next()};if(!n){let h=o;h.noValidate=!0,h.addEventListener("submit",v=>{v.preventDefault(),a()})}let s=n?o.appendChild(d("fieldset",{className:"fillo-not-open-fields",attrs:{disabled:""}})):o,l=this.engine?.getState();if(l?.resumedDraft||l?.editingPrevious){let h=d("div",{className:"fillo-resume",attrs:{"data-fillo":"resume"}});h.appendChild(d("span",{className:"fillo-resume-text",text:l.editingPrevious?T.editNotice:T.resumeNotice}));let v=d("button",{className:"fillo-resume-clear",text:T.resumeStartOver,attrs:{type:"button"}});v.addEventListener("click",()=>this.resetDraft()),h.appendChild(v),s.appendChild(h)}if(t.pageCount>1&&this.schema?.settings.showProgress!==!1){let h=je(t.form,t.data),v=Math.max(h.length,1),b=h.indexOf(t.page.id),g=b>=0?b+1:Math.min(t.pageIndex+1,v),A=d("div",{className:"fillo-progress-track",attrs:{role:"progressbar","data-fillo":"progress","aria-label":t.form.title||"Form progress","aria-valuemin":"1","aria-valuemax":String(v),"aria-valuenow":String(g)}});A.appendChild(d("div",{className:"fillo-progress-fill",attrs:{"data-fillo":"progressFill"}})),A.firstElementChild?.style.setProperty("--fillo-progress-value",`${g/v*100}%`),s.appendChild(A)}if(t.pageIndex===0){let h=d("header",{className:"fillo-header",attrs:{"data-fillo":"header"}});t.form.title&&h.appendChild(d("h1",{className:"fillo-title",text:t.form.title,attrs:{"data-fillo":"title"}})),t.form.description&&h.appendChild(d("p",{className:"fillo-form-description",text:t.form.description,attrs:{"data-fillo":"description"}})),s.appendChild(h)}else t.page.title&&s.appendChild(d("h2",{className:"fillo-page-title",text:t.page.title,attrs:{"data-fillo":"pageTitle"}}));let c=d("div",{className:"fillo-blocks",attrs:{"data-fillo":"blocks"}});for(let h of t.blocks){let v=this.renderBlock(ro(h,this.mutableData,t.form),t);v&&c.appendChild(v)}if(s.appendChild(c),!n){let h=d("input",{className:"fillo-hp",attrs:{type:"text",name:"fillo_hp_field",tabindex:"-1",autocomplete:"off","aria-hidden":"true"}});h.style.position="absolute",h.style.left="-9999px",h.style.top="auto",h.style.width="1px",h.style.height="1px",h.style.opacity="0",h.style.overflow="hidden",h.style.pointerEvents="none",h.addEventListener("input",()=>{this.hpValue=h.value}),s.appendChild(h)}if(i){let h=d("div",{className:"fillo-turnstile-slot",attrs:{"data-fillo":"turnstile-slot"}});h.appendChild(this.turnstileContainer),this.challengeError&&h.appendChild(d("p",{className:"fillo-turnstile-error",attrs:{role:"alert"},text:T.challengeUnavailable})),s.appendChild(h),this.ensureChallengeWidget(this.challenge)}else(this.turnstileWidgetId!==null||this.turnstileLoadInFlight||this.challengeFrame!==null)&&this.teardownTurnstileWidget();let u=t.status==="error"?"This form can't submit right now. Please try again in a moment.":this.engine?.getState().submitError;if(u){let h=d("p",{className:"fillo-submit-error",attrs:{role:"alert"},text:u}),v=this.devChrome()&&this.resolutionFailureCode==="form_not_published"&&this.syncWarningCode==="storage_required"?Me(this.syncWarningUrl):null;v&&(h.append(" Connect storage: "),h.appendChild(d("a",{text:v,attrs:{href:v,target:"_blank",rel:"noopener noreferrer"}}))),s.appendChild(h)}let p=!(t.form.settings.submitMode==="auto")||!t.isLastPage||Ki(Si(t.form,t.data))||i;if(p||t.pageCount>1&&!t.isFirstPage){let h=d("footer",{className:"fillo-footer",attrs:{"data-fillo":"footer"}});if(t.pageCount>1&&!t.isFirstPage){let v=d("button",{className:"fillo-button fillo-button--ghost",text:"Back",attrs:{type:"button","data-fillo":"button"}});v.addEventListener("click",()=>this.back()),h.appendChild(v)}if(p){let v=d("button",{className:"fillo-button fillo-button--primary",text:t.status==="submitting"?"Submitting...":t.isLastPage?t.form.settings.submitLabel??"Submit":"Next",attrs:{type:"submit","data-fillo":"button"}});v.toggleAttribute("disabled",t.status==="submitting"||this.engine?.getState().uploading===!0||i&&!this.challengeToken),v.addEventListener("click",b=>{b.preventDefault(),a()}),h.appendChild(v)}s.appendChild(h)}return o}fieldRenderer(t){return t.kind==="custom"?this.options.customComponents?.[t.component]??this.options.components?.custom:this.options.components?.[t.kind]??yo}renderChildField=t=>this.fieldRenderer(t.field)?.(t)??null;setGroupFocus=t=>{this.focusIntent=t};renderBlock(t,n){if(!X(t))return dl(t);let r=(o,a)=>{if(this.setValueInternal(t.id,o,a),a?.render===!1)return;let s={form:n.form,data:n.data,status:n.status,isLastPage:n.isLastPage,uploading:this.engine?.getState().uploading===!0};Ji(t,o,s)&&this.submit()},i={field:t,value:n.data[t.id],error:n.errors[t.id]===lt?Ni(t,M):n.errors[t.id],ids:mo(this.instanceId,t.id),api:n,setValue:r,uploadFiles:(o,a)=>this.uploadFiles(o,a),uploadRows:this.uploadRowsFor(t.id),uploadAction:this.uploadAction,activeOtherFields:this.activeOtherFields,getValue:()=>this.engine?.getState().data[t.id],registerOverlay:this.registerOverlay,uploadNotice:this.uploadNotices.get(t.id),uploadDisabledReason:this.options.renderOnly?"render_only":this.storageBlocked()?"storage_unavailable":void 0,storageFixUrl:this.storageBlocked()&&this.devChrome()?Me(this.syncWarningUrl):null,announce:this.announce,announceAlert:this.announceAlert,instanceId:this.instanceId,renderChildField:this.renderChildField,setGroupFocus:this.setGroupFocus};return this.fieldRenderer(t)?.(i)??null}};function dl(e){switch(e.kind){case"heading":return d("h3",{className:"fillo-heading",text:e.text});case"paragraph":return d("p",{className:"fillo-paragraph",text:e.text});case"divider":return d("hr",{className:"fillo-divider"})}return d("div")}function pl(e){let t=d("div",{className:"fillo-form fillo-form--success"}),n=d("div",{className:"fillo-success"});return N(n,[d("div",{className:"fillo-success-mark",attrs:{"aria-hidden":"true"}}),d("h2",{className:"fillo-success-title",text:e.settings.successTitle??"Thanks!"}),d("p",{className:"fillo-success-message",text:e.settings.successMessage??"Your response has been recorded."})]),t.appendChild(n),t}function Xn(e,t){return d("a",{className:"fillo-powered",text:e??"Powered by Fillo",attrs:{href:Oa(t),target:"_blank",rel:"nofollow noopener noreferrer"}})}function po(e){return e==="expired"||e==="capped"||e==="storage_full"?"closed":"notOpen"}function fl(){return no()}function hl(){return d("div",{className:"fillo-devwarning",text:"No Fillo client connected \u2014 this form is render-only and won't save responses. Pass a client to collect them in Fillo, or forward with webhooks. (Shown only in development and preview.)",attrs:{role:"alert"}})}function ml(e){return d("div",{className:"fillo-devwarning",text:`Form sync needs attention${e.code?` (${e.code})`:""}: ${e.message} The safe form remains available for development.`,attrs:{role:"alert"}})}function gl(e){let t=d("div",{className:"fillo-devwarning",attrs:{role:"alert"}});t.append("Code changes are staged, not live. This page shows your draft, while respondents still get the live version. ");let n=Me(e);return n?(t.appendChild(d("a",{text:"Review and publish in Fillo",attrs:{href:n,target:"_blank",rel:"noopener noreferrer"}})),t.append(".")):t.append("Review and publish the changes in Fillo."),t}function bl(e,t){let n=d("div",{className:"fillo-devwarning",attrs:{role:"alert"}});n.append("Draft form preview \u2014 the form renders for local testing, but Fillo will reject the submission and save no response until you publish it. ");let r=Me(e),i=Me(t);return r?(n.appendChild(d("a",{text:"Connect storage to publish",attrs:{href:r,target:"_blank",rel:"noopener noreferrer"}})),n.append(". ")):i&&(n.appendChild(d("a",{text:"Open in Fillo to publish",attrs:{href:i,target:"_blank",rel:"noopener noreferrer"}})),n.append(". ")),n.append("(Shown only in development and preview.)"),n}function vl(){return d("span",{className:"fillo-preview-badge",text:"Preview",attrs:{"data-fillo":"preview-badge"}})}var fo=!1;function yl(){fo||Wn()||(fo=!0,console.warn("[fillo] `preview` is enabled in a production build. Preview is cosmetic only \u2014 it shows developer chrome and never changes where submissions go or whether they are accepted \u2014 but remove it before respondents see this page."))}function wl(e){let t=[];return e.preview&&t.push(vl()),e.devNotices===!1||(e.syncError?t.push(ml(e.syncError)):e.staged?t.push(gl(e.formUrl)):e.draft?t.push(bl(e.warningUrl,e.formUrl)):e.noClient&&t.push(hl())),t}function _l(e){return e.status===404?T.loadFailedNotFound:e.status===0?T.loadFailedNetwork:e.status===422?T.renderFailed:T.loadFailed}function ho(){return new S("This form has no Fillo target. Pass formId with the schema, use a defineForm() value with client, or set renderOnly for a non-submitting preview.",422,void 0,"form_target_required")}function ft(e){return te(e)?e:new S(e instanceof Error?e.message:String(e),0)}function Dt(e,t){let n=typeof e=="string"?document.querySelector(e):e;if(!n)throw new S(`Fillo mount target not found: ${String(e)}`,0);let r={...t,initialData:t.initialData??{}};return new gt(n,r)}function wo(e){let t=d("div");return Dt(t,e),t}var xl=typeof HTMLElement<"u"?HTMLElement:class{},Yn=class extends xl{instance=null;assignedForm;assignedClient;assignedTheme;assignedInitialData;mounted=!1;mountScheduled=!1;static get observedAttributes(){return["publishable-key","form-id","data-preview","data-render-only"]}connectedCallback(){this.scheduleMount()}disconnectedCallback(){this.instance?.destroy(),this.instance=null,this.mounted=!1}attributeChangedCallback(){this.mounted&&this.isConnected&&this.scheduleMount()}set form(t){this.assignedForm=t,this.mounted&&this.scheduleMount()}get form(){return this.assignedForm}set client(t){this.assignedClient=t,this.mounted&&this.instance instanceof gt&&this.instance.setClient(t)}set theme(t){this.assignedTheme=t,this.mounted&&this.instance instanceof gt&&this.instance.setTheme(t)}set initialData(t){this.assignedInitialData=t,this.mounted&&this.scheduleMount()}scheduleMount(){this.mountScheduled||(this.mountScheduled=!0,queueMicrotask(()=>{this.mountScheduled=!1,this.isConnected&&this.mount()}))}previewAttrEnabled(){let t=this.getAttribute("data-preview");return t!==null&&t!=="false"&&t!=="0"}renderOnlyAttrEnabled(){let t=this.getAttribute("data-render-only");return t!==null&&t!=="false"&&t!=="0"}mount(){this.instance?.destroy();let t=this.getAttribute("publishable-key")??void 0,n=this.getAttribute("form-id")??void 0,r=this.assignedClient??(n||t?Le({key:t}):void 0);this.instance=Dt(this,{form:this.assignedForm,client:r,formId:n,theme:this.assignedTheme,initialData:this.assignedInitialData,preview:this.previewAttrEnabled()?!0:void 0,renderOnly:this.renderOnlyAttrEnabled()?!0:void 0,onChange:i=>this.dispatchEvent(new CustomEvent("fillo-change",{detail:{data:i}})),onSubmitted:(i,o)=>this.dispatchEvent(new CustomEvent("fillo-submit",{detail:{responseId:i,data:o}})),onError:i=>this.dispatchEvent(new CustomEvent("fillo-error",{detail:{error:i}}))}),this.mounted=!0}};function er(e="fillo-form"){typeof customElements>"u"||customElements.get(e)||customElements.define(e,Yn)}typeof customElements<"u"&&er();return To(kl);})();