@iai-lib/any-chat-widget 0.1.0-alpha.17 → 0.1.0-alpha.19

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.
@@ -3517,6 +3517,7 @@ const hs = b.object({
3517
3517
  inactivityWarningMessage: b.string().default("Are you still there? The chat will end soon if we don't hear from you."),
3518
3518
  chatEndedMessage: b.string().default("The chat has ended. Please restart the chat to continue."),
3519
3519
  initialReplyMessage: b.string().nullable().default(null),
3520
+ simulateDelays: b.boolean().default(!0),
3520
3521
  placement: b.enum(["left", "right"]).default("right"),
3521
3522
  openChatButton: b.object({
3522
3523
  imageSrc: b.string().optional(),
@@ -3962,7 +3963,7 @@ class Vr {
3962
3963
  async respondToFunctionCall(e, t, i) {
3963
3964
  this.simulateDelay(1800).then(() => this.setTyping(!0));
3964
3965
  const n = this.simulateDelay(2e3);
3965
- await this.insertMessagesWithSimulatedDelays(
3966
+ this.keepAlive(), await this.insertMessagesWithSimulatedDelays(
3966
3967
  Promise.all([
3967
3968
  Wr(this.threadId, e, t, i),
3968
3969
  n
@@ -3974,7 +3975,7 @@ class Vr {
3974
3975
  this.addMessage({
3975
3976
  role: "user",
3976
3977
  content: e
3977
- }), this.simulateDelay(1800).then(() => this._emitter.emit("typing", !0)), this.simulateDelay(1800).then(() => this.setTyping(!0));
3978
+ }), this.simulateDelay(1800).then(() => this.setTyping(!0));
3978
3979
  let t = this.simulateDelay(4800);
3979
3980
  if (!this.chatStarted) {
3980
3981
  const { initialReplyMessage: r } = this.options;
@@ -4016,7 +4017,6 @@ class Vr {
4016
4017
  this.chatEndingWarningSent || (this._emitter.emit("inactivityWarning"), this.setChatEndingWarningSent(!0));
4017
4018
  }
4018
4019
  async insertMessagesWithSimulatedDelays(e) {
4019
- this._emitter.emit("typing", !0);
4020
4020
  const t = await e;
4021
4021
  if (t.error)
4022
4022
  throw new Error(t.message);
@@ -4277,7 +4277,7 @@ let oe = class extends Q {
4277
4277
  const { assistantId: s, params: e, config: t } = this.cleanOptions;
4278
4278
  Oi(this, Se, new Vr(s, {
4279
4279
  params: e,
4280
- simulateDelays: !0,
4280
+ simulateDelays: t.simulateDelays,
4281
4281
  historyKey: t.historyKey,
4282
4282
  initialReplyMessage: t.initialReplyMessage
4283
4283
  })), this.updateMessages(Xe(this, Se).messages), this.showTyping = Xe(this, Se).isTyping, this.disableInput = Xe(this, Se).inputDisabled, this.chatManager.on("functionCall", ({ id: i, name: n, params: r }) => {
@@ -48,7 +48,7 @@
48
48
  * @license
49
49
  * Copyright 2018 Google LLC
50
50
  * SPDX-License-Identifier: BSD-3-Clause
51
- */const _i="important",Sn=" !"+_i,at=Kt(class extends Jt{constructor(s){var e;if(super(s),s.type!==Vt.ATTRIBUTE||s.name!=="style"||((e=s.strings)==null?void 0:e.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(s){return Object.keys(s).reduce((e,t)=>{const i=s[t];return i==null?e:e+`${t=t.includes("-")?t:t.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(s,[e]){const{style:t}=s.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(e)),this.render(e);for(const i of this.ft)e[i]==null&&(this.ft.delete(i),i.includes("-")?t.removeProperty(i):t[i]=null);for(const i in e){const n=e[i];if(n!=null){this.ft.add(i);const r=typeof n=="string"&&n.endsWith(Sn);i.includes("-")||r?t.setProperty(i,r?n.slice(0,-11):n,r?_i:""):t[i]=n}}return ue}});var j;(function(s){s.assertEqual=n=>n;function e(n){}s.assertIs=e;function t(n){throw new Error}s.assertNever=t,s.arrayToEnum=n=>{const r={};for(const a of n)r[a]=a;return r},s.getValidEnumValues=n=>{const r=s.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),a={};for(const o of r)a[o]=n[o];return s.objectValues(a)},s.objectValues=n=>s.objectKeys(n).map(function(r){return n[r]}),s.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const r=[];for(const a in n)Object.prototype.hasOwnProperty.call(n,a)&&r.push(a);return r},s.find=(n,r)=>{for(const a of n)if(r(a))return a},s.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function i(n,r=" | "){return n.map(a=>typeof a=="string"?`'${a}'`:a).join(r)}s.joinValues=i,s.jsonStringifyReplacer=(n,r)=>typeof r=="bigint"?r.toString():r})(j||(j={}));var _s;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(_s||(_s={}));const f=j.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ae=s=>{switch(typeof s){case"undefined":return f.undefined;case"string":return f.string;case"number":return isNaN(s)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(s)?f.array:s===null?f.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?f.promise:typeof Map<"u"&&s instanceof Map?f.map:typeof Set<"u"&&s instanceof Set?f.set:typeof Date<"u"&&s instanceof Date?f.date:f.object;default:return f.unknown}},p=j.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Cn=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:");class ie extends Error{constructor(e){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(r){return r.message},i={_errors:[]},n=r=>{for(const a of r.issues)if(a.code==="invalid_union")a.unionErrors.map(n);else if(a.code==="invalid_return_type")n(a.returnTypeError);else if(a.code==="invalid_arguments")n(a.argumentsError);else if(a.path.length===0)i._errors.push(t(a));else{let o=i,c=0;for(;c<a.path.length;){const l=a.path[c];c===a.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(a))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return n(this),i}toString(){return this.message}get message(){return JSON.stringify(this.issues,j.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},i=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):i.push(e(n));return{formErrors:i,fieldErrors:t}}get formErrors(){return this.flatten()}}ie.create=s=>new ie(s);const _t=(s,e)=>{let t;switch(s.code){case p.invalid_type:s.received===f.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case p.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,j.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:t=`Unrecognized key(s) in object: ${j.joinValues(s.keys,", ")}`;break;case p.invalid_union:t="Invalid input";break;case p.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${j.joinValues(s.options)}`;break;case p.invalid_enum_value:t=`Invalid enum value. Expected ${j.joinValues(s.options)}, received '${s.received}'`;break;case p.invalid_arguments:t="Invalid function arguments";break;case p.invalid_return_type:t="Invalid function return type";break;case p.invalid_date:t="Invalid date";break;case p.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:j.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case p.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case p.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case p.custom:t="Invalid input";break;case p.invalid_intersection_types:t="Intersection results could not be merged";break;case p.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case p.not_finite:t="Number must be finite";break;default:t=e.defaultError,j.assertNever(s)}return{message:t}};let xi=_t;function $n(s){xi=s}function qt(){return xi}const Gt=s=>{const{data:e,path:t,errorMaps:i,issueData:n}=s,r=[...t,...n.path||[]],a={...n,path:r};let o="";const c=i.filter(l=>!!l).slice().reverse();for(const l of c)o=l(a,{data:e,defaultError:o}).message;return{...n,path:r,message:n.message||o}},An=[];function g(s,e){const t=Gt({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,qt(),_t].filter(i=>!!i)});s.common.issues.push(t)}class q{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const i=[];for(const n of t){if(n.status==="aborted")return C;n.status==="dirty"&&e.dirty(),i.push(n.value)}return{status:e.value,value:i}}static async mergeObjectAsync(e,t){const i=[];for(const n of t)i.push({key:await n.key,value:await n.value});return q.mergeObjectSync(e,i)}static mergeObjectSync(e,t){const i={};for(const n of t){const{key:r,value:a}=n;if(r.status==="aborted"||a.status==="aborted")return C;r.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),r.value!=="__proto__"&&(typeof a.value<"u"||n.alwaysSet)&&(i[r.value]=a.value)}return{status:e.value,value:i}}}const C=Object.freeze({status:"aborted"}),ki=s=>({status:"dirty",value:s}),Y=s=>({status:"valid",value:s}),xs=s=>s.status==="aborted",ks=s=>s.status==="dirty",xt=s=>s.status==="valid",Yt=s=>typeof Promise<"u"&&s instanceof Promise;var _;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(_||(_={}));class he{constructor(e,t,i,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=i,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ei=(s,e)=>{if(xt(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new ie(s.common.issues);return this._error=t,this._error}}};function $(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:i,description:n}=s;if(e&&(t||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(r,a)=>r.code!=="invalid_type"?{message:a.defaultError}:typeof a.data>"u"?{message:i??a.defaultError}:{message:t??a.defaultError},description:n}}class I{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Ae(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new q,ctx:{common:e.parent.common,data:e.data,parsedType:Ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Yt(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const i=this.safeParse(e,t);if(i.success)return i.data;throw i.error}safeParse(e,t){var i;const n={common:{issues:[],async:(i=t==null?void 0:t.async)!==null&&i!==void 0?i:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ae(e)},r=this._parseSync({data:e,path:n.path,parent:n});return Ei(n,r)}async parseAsync(e,t){const i=await this.safeParseAsync(e,t);if(i.success)return i.data;throw i.error}async safeParseAsync(e,t){const i={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ae(e)},n=this._parse({data:e,path:i.path,parent:i}),r=await(Yt(n)?n:Promise.resolve(n));return Ei(i,r)}refine(e,t){const i=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,r)=>{const a=e(n),o=()=>r.addIssue({code:p.custom,...i(n)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((i,n)=>e(i)?!0:(n.addIssue(typeof t=="function"?t(i,n):t),!1))}_refinement(e){return new ae({schema:this,typeName:T.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ve.create(this,this._def)}nullable(){return Fe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return re.create(this,this._def)}promise(){return lt.create(this,this._def)}or(e){return St.create([this,e],this._def)}and(e){return Ct.create(this,e,this._def)}transform(e){return new ae({...$(this._def),schema:this,typeName:T.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Mt({...$(this._def),innerType:this,defaultValue:t,typeName:T.ZodDefault})}brand(){return new Si({typeName:T.ZodBranded,type:this,...$(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new is({...$(this._def),innerType:this,catchValue:t,typeName:T.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Nt.create(this,e)}readonly(){return rs.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const On=/^c[^\s-]{8,}$/i,In=/^[a-z][a-z0-9]*$/,Mn=/^[0-9A-HJKMNP-TV-Z]{26}$/,Nn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Pn=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,jn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Es;const Rn=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Zn=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Dn=s=>s.precision?s.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}Z$`):s.precision===0?s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Ln(s,e){return!!((e==="v4"||!e)&&Rn.test(s)||(e==="v6"||!e)&&Zn.test(s))}class ne extends I{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:f.string,received:n.parsedType}),C}const t=new q;let i;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(i=this._getOrReturnCtx(e,i),g(i,{code:p.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="max")e.data.length>n.value&&(i=this._getOrReturnCtx(e,i),g(i,{code:p.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="length"){const r=e.data.length>n.value,a=e.data.length<n.value;(r||a)&&(i=this._getOrReturnCtx(e,i),r?g(i,{code:p.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):a&&g(i,{code:p.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if(n.kind==="email")Pn.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"email",code:p.invalid_string,message:n.message}),t.dirty());else if(n.kind==="emoji")Es||(Es=new RegExp(jn,"u")),Es.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"emoji",code:p.invalid_string,message:n.message}),t.dirty());else if(n.kind==="uuid")Nn.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"uuid",code:p.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid")On.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"cuid",code:p.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid2")In.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"cuid2",code:p.invalid_string,message:n.message}),t.dirty());else if(n.kind==="ulid")Mn.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"ulid",code:p.invalid_string,message:n.message}),t.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),g(i,{validation:"url",code:p.invalid_string,message:n.message}),t.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"regex",code:p.invalid_string,message:n.message}),t.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(i=this._getOrReturnCtx(e,i),g(i,{code:p.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(i=this._getOrReturnCtx(e,i),g(i,{code:p.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(i=this._getOrReturnCtx(e,i),g(i,{code:p.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty()):n.kind==="datetime"?Dn(n).test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{code:p.invalid_string,validation:"datetime",message:n.message}),t.dirty()):n.kind==="ip"?Ln(e.data,n.version)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"ip",code:p.invalid_string,message:n.message}),t.dirty()):j.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,i){return this.refinement(n=>e.test(n),{validation:t,code:p.invalid_string,..._.errToObj(i)})}_addCheck(e){return new ne({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",..._.errToObj(e)})}url(e){return this._addCheck({kind:"url",..._.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",..._.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",..._.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",..._.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",..._.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",..._.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",..._.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,..._.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,..._.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,..._.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,..._.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,..._.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,..._.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,..._.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,..._.errToObj(t)})}nonempty(e){return this.min(1,_.errToObj(e))}trim(){return new ne({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ne({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ne({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ne.create=s=>{var e;return new ne({checks:[],typeName:T.ZodString,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...$(s)})};function zn(s,e){const t=(s.toString().split(".")[1]||"").length,i=(e.toString().split(".")[1]||"").length,n=t>i?t:i,r=parseInt(s.toFixed(n).replace(".","")),a=parseInt(e.toFixed(n).replace(".",""));return r%a/Math.pow(10,n)}class Oe extends I{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){const n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:f.number,received:n.parsedType}),C}let t;const i=new q;for(const n of this._def.checks)n.kind==="int"?j.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),g(t,{code:p.invalid_type,expected:"integer",received:"float",message:n.message}),i.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:p.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),i.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:p.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),i.dirty()):n.kind==="multipleOf"?zn(e.data,n.value)!==0&&(t=this._getOrReturnCtx(e,t),g(t,{code:p.not_multiple_of,multipleOf:n.value,message:n.message}),i.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),g(t,{code:p.not_finite,message:n.message}),i.dirty()):j.assertNever(n);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,_.toString(t))}gt(e,t){return this.setLimit("min",e,!1,_.toString(t))}lte(e,t){return this.setLimit("max",e,!0,_.toString(t))}lt(e,t){return this.setLimit("max",e,!1,_.toString(t))}setLimit(e,t,i,n){return new Oe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:i,message:_.toString(n)}]})}_addCheck(e){return new Oe({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:_.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:_.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&j.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(t===null||i.value>t)&&(t=i.value):i.kind==="max"&&(e===null||i.value<e)&&(e=i.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Oe.create=s=>new Oe({checks:[],typeName:T.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...$(s)});class Ie extends I{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==f.bigint){const n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:f.bigint,received:n.parsedType}),C}let t;const i=new q;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:p.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),i.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:p.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),i.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),g(t,{code:p.not_multiple_of,multipleOf:n.value,message:n.message}),i.dirty()):j.assertNever(n);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,_.toString(t))}gt(e,t){return this.setLimit("min",e,!1,_.toString(t))}lte(e,t){return this.setLimit("max",e,!0,_.toString(t))}lt(e,t){return this.setLimit("max",e,!1,_.toString(t))}setLimit(e,t,i,n){return new Ie({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:i,message:_.toString(n)}]})}_addCheck(e){return new Ie({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Ie.create=s=>{var e;return new Ie({checks:[],typeName:T.ZodBigInt,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...$(s)})};class kt extends I{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.boolean,received:t.parsedType}),C}return Y(e.data)}}kt.create=s=>new kt({typeName:T.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...$(s)});class He extends I{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:f.date,received:n.parsedType}),C}if(isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_date}),C}const t=new q;let i;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(i=this._getOrReturnCtx(e,i),g(i,{code:p.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(i=this._getOrReturnCtx(e,i),g(i,{code:p.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):j.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new He({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:_.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:_.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}He.create=s=>new He({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:T.ZodDate,...$(s)});class Xt extends I{_parse(e){if(this._getType(e)!==f.symbol){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.symbol,received:t.parsedType}),C}return Y(e.data)}}Xt.create=s=>new Xt({typeName:T.ZodSymbol,...$(s)});class Et extends I{_parse(e){if(this._getType(e)!==f.undefined){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.undefined,received:t.parsedType}),C}return Y(e.data)}}Et.create=s=>new Et({typeName:T.ZodUndefined,...$(s)});class Tt extends I{_parse(e){if(this._getType(e)!==f.null){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.null,received:t.parsedType}),C}return Y(e.data)}}Tt.create=s=>new Tt({typeName:T.ZodNull,...$(s)});class ot extends I{constructor(){super(...arguments),this._any=!0}_parse(e){return Y(e.data)}}ot.create=s=>new ot({typeName:T.ZodAny,...$(s)});class Be extends I{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Y(e.data)}}Be.create=s=>new Be({typeName:T.ZodUnknown,...$(s)});class ye extends I{_parse(e){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.never,received:t.parsedType}),C}}ye.create=s=>new ye({typeName:T.ZodNever,...$(s)});class Qt extends I{_parse(e){if(this._getType(e)!==f.undefined){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.void,received:t.parsedType}),C}return Y(e.data)}}Qt.create=s=>new Qt({typeName:T.ZodVoid,...$(s)});class re extends I{_parse(e){const{ctx:t,status:i}=this._processInputParams(e),n=this._def;if(t.parsedType!==f.array)return g(t,{code:p.invalid_type,expected:f.array,received:t.parsedType}),C;if(n.exactLength!==null){const a=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(a||o)&&(g(t,{code:a?p.too_big:p.too_small,minimum:o?n.exactLength.value:void 0,maximum:a?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),i.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(g(t,{code:p.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),i.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(g(t,{code:p.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),i.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>n.type._parseAsync(new he(t,a,t.path,o)))).then(a=>q.mergeArray(i,a));const r=[...t.data].map((a,o)=>n.type._parseSync(new he(t,a,t.path,o)));return q.mergeArray(i,r)}get element(){return this._def.type}min(e,t){return new re({...this._def,minLength:{value:e,message:_.toString(t)}})}max(e,t){return new re({...this._def,maxLength:{value:e,message:_.toString(t)}})}length(e,t){return new re({...this._def,exactLength:{value:e,message:_.toString(t)}})}nonempty(e){return this.min(1,e)}}re.create=(s,e)=>new re({type:s,minLength:null,maxLength:null,exactLength:null,typeName:T.ZodArray,...$(e)});function ct(s){if(s instanceof U){const e={};for(const t in s.shape){const i=s.shape[t];e[t]=ve.create(ct(i))}return new U({...s._def,shape:()=>e})}else return s instanceof re?new re({...s._def,type:ct(s.element)}):s instanceof ve?ve.create(ct(s.unwrap())):s instanceof Fe?Fe.create(ct(s.unwrap())):s instanceof pe?pe.create(s.items.map(e=>ct(e))):s}class U extends I{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=j.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==f.object){const c=this._getOrReturnCtx(e);return g(c,{code:p.invalid_type,expected:f.object,received:c.parsedType}),C}const{status:t,ctx:i}=this._processInputParams(e),{shape:n,keys:r}=this._getCached(),a=[];if(!(this._def.catchall instanceof ye&&this._def.unknownKeys==="strip"))for(const c in i.data)r.includes(c)||a.push(c);const o=[];for(const c of r){const l=n[c],h=i.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new he(i,h,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof ye){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of a)o.push({key:{status:"valid",value:l},value:{status:"valid",value:i.data[l]}});else if(c==="strict")a.length>0&&(g(i,{code:p.unrecognized_keys,keys:a}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of a){const h=i.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new he(i,h,i.path,l)),alwaysSet:l in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const h=await l.key;c.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>q.mergeObjectSync(t,c)):q.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return _.errToObj,new U({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,i)=>{var n,r,a,o;const c=(a=(r=(n=this._def).errorMap)===null||r===void 0?void 0:r.call(n,t,i).message)!==null&&a!==void 0?a:i.defaultError;return t.code==="unrecognized_keys"?{message:(o=_.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new U({...this._def,unknownKeys:"strip"})}passthrough(){return new U({...this._def,unknownKeys:"passthrough"})}extend(e){return new U({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new U({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:T.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new U({...this._def,catchall:e})}pick(e){const t={};return j.objectKeys(e).forEach(i=>{e[i]&&this.shape[i]&&(t[i]=this.shape[i])}),new U({...this._def,shape:()=>t})}omit(e){const t={};return j.objectKeys(this.shape).forEach(i=>{e[i]||(t[i]=this.shape[i])}),new U({...this._def,shape:()=>t})}deepPartial(){return ct(this)}partial(e){const t={};return j.objectKeys(this.shape).forEach(i=>{const n=this.shape[i];e&&!e[i]?t[i]=n:t[i]=n.optional()}),new U({...this._def,shape:()=>t})}required(e){const t={};return j.objectKeys(this.shape).forEach(i=>{if(e&&!e[i])t[i]=this.shape[i];else{let n=this.shape[i];for(;n instanceof ve;)n=n._def.innerType;t[i]=n}}),new U({...this._def,shape:()=>t})}keyof(){return Ti(j.objectKeys(this.shape))}}U.create=(s,e)=>new U({shape:()=>s,unknownKeys:"strip",catchall:ye.create(),typeName:T.ZodObject,...$(e)}),U.strictCreate=(s,e)=>new U({shape:()=>s,unknownKeys:"strict",catchall:ye.create(),typeName:T.ZodObject,...$(e)}),U.lazycreate=(s,e)=>new U({shape:s,unknownKeys:"strip",catchall:ye.create(),typeName:T.ZodObject,...$(e)});class St extends I{_parse(e){const{ctx:t}=this._processInputParams(e),i=this._def.options;function n(r){for(const o of r)if(o.result.status==="valid")return o.result;for(const o of r)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=r.map(o=>new ie(o.ctx.common.issues));return g(t,{code:p.invalid_union,unionErrors:a}),C}if(t.common.async)return Promise.all(i.map(async r=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await r._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(n);{let r;const a=[];for(const c of i){const l={...t,common:{...t.common,issues:[]},parent:null},h=c._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!r&&(r={result:h,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(r)return t.common.issues.push(...r.ctx.common.issues),r.result;const o=a.map(c=>new ie(c));return g(t,{code:p.invalid_union,unionErrors:o}),C}}get options(){return this._def.options}}St.create=(s,e)=>new St({options:s,typeName:T.ZodUnion,...$(e)});const es=s=>s instanceof At?es(s.schema):s instanceof ae?es(s.innerType()):s instanceof Ot?[s.value]:s instanceof Me?s.options:s instanceof It?Object.keys(s.enum):s instanceof Mt?es(s._def.innerType):s instanceof Et?[void 0]:s instanceof Tt?[null]:null;class ts extends I{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return g(t,{code:p.invalid_type,expected:f.object,received:t.parsedType}),C;const i=this.discriminator,n=t.data[i],r=this.optionsMap.get(n);return r?t.common.async?r._parseAsync({data:t.data,path:t.path,parent:t}):r._parseSync({data:t.data,path:t.path,parent:t}):(g(t,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),C)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,i){const n=new Map;for(const r of t){const a=es(r.shape[e]);if(!a)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,r)}}return new ts({typeName:T.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...$(i)})}}function Ts(s,e){const t=Ae(s),i=Ae(e);if(s===e)return{valid:!0,data:s};if(t===f.object&&i===f.object){const n=j.objectKeys(e),r=j.objectKeys(s).filter(o=>n.indexOf(o)!==-1),a={...s,...e};for(const o of r){const c=Ts(s[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===f.array&&i===f.array){if(s.length!==e.length)return{valid:!1};const n=[];for(let r=0;r<s.length;r++){const a=s[r],o=e[r],c=Ts(a,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===f.date&&i===f.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}class Ct extends I{_parse(e){const{status:t,ctx:i}=this._processInputParams(e),n=(r,a)=>{if(xs(r)||xs(a))return C;const o=Ts(r.value,a.value);return o.valid?((ks(r)||ks(a))&&t.dirty(),{status:t.value,value:o.data}):(g(i,{code:p.invalid_intersection_types}),C)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([r,a])=>n(r,a)):n(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}}Ct.create=(s,e,t)=>new Ct({left:s,right:e,typeName:T.ZodIntersection,...$(t)});class pe extends I{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==f.array)return g(i,{code:p.invalid_type,expected:f.array,received:i.parsedType}),C;if(i.data.length<this._def.items.length)return g(i,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),C;!this._def.rest&&i.data.length>this._def.items.length&&(g(i,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...i.data].map((r,a)=>{const o=this._def.items[a]||this._def.rest;return o?o._parse(new he(i,r,i.path,a)):null}).filter(r=>!!r);return i.common.async?Promise.all(n).then(r=>q.mergeArray(t,r)):q.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new pe({...this._def,rest:e})}}pe.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new pe({items:s,typeName:T.ZodTuple,rest:null,...$(e)})};class $t extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==f.object)return g(i,{code:p.invalid_type,expected:f.object,received:i.parsedType}),C;const n=[],r=this._def.keyType,a=this._def.valueType;for(const o in i.data)n.push({key:r._parse(new he(i,o,i.path,o)),value:a._parse(new he(i,i.data[o],i.path,o))});return i.common.async?q.mergeObjectAsync(t,n):q.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,i){return t instanceof I?new $t({keyType:e,valueType:t,typeName:T.ZodRecord,...$(i)}):new $t({keyType:ne.create(),valueType:e,typeName:T.ZodRecord,...$(t)})}}class ss extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==f.map)return g(i,{code:p.invalid_type,expected:f.map,received:i.parsedType}),C;const n=this._def.keyType,r=this._def.valueType,a=[...i.data.entries()].map(([o,c],l)=>({key:n._parse(new he(i,o,i.path,[l,"key"])),value:r._parse(new he(i,c,i.path,[l,"value"]))}));if(i.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return C;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return C;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}}ss.create=(s,e,t)=>new ss({valueType:e,keyType:s,typeName:T.ZodMap,...$(t)});class We extends I{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==f.set)return g(i,{code:p.invalid_type,expected:f.set,received:i.parsedType}),C;const n=this._def;n.minSize!==null&&i.data.size<n.minSize.value&&(g(i,{code:p.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&i.data.size>n.maxSize.value&&(g(i,{code:p.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const r=this._def.valueType;function a(c){const l=new Set;for(const h of c){if(h.status==="aborted")return C;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...i.data.values()].map((c,l)=>r._parse(new he(i,c,i.path,l)));return i.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new We({...this._def,minSize:{value:e,message:_.toString(t)}})}max(e,t){return new We({...this._def,maxSize:{value:e,message:_.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}We.create=(s,e)=>new We({valueType:s,minSize:null,maxSize:null,typeName:T.ZodSet,...$(e)});class dt extends I{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return g(t,{code:p.invalid_type,expected:f.function,received:t.parsedType}),C;function i(o,c){return Gt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,qt(),_t].filter(l=>!!l),issueData:{code:p.invalid_arguments,argumentsError:c}})}function n(o,c){return Gt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,qt(),_t].filter(l=>!!l),issueData:{code:p.invalid_return_type,returnTypeError:c}})}const r={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof lt){const o=this;return Y(async function(...c){const l=new ie([]),h=await o._def.args.parseAsync(c,r).catch(d=>{throw l.addIssue(i(c,d)),l}),m=await Reflect.apply(a,this,h);return await o._def.returns._def.type.parseAsync(m,r).catch(d=>{throw l.addIssue(n(m,d)),l})})}else{const o=this;return Y(function(...c){const l=o._def.args.safeParse(c,r);if(!l.success)throw new ie([i(c,l.error)]);const h=Reflect.apply(a,this,l.data),m=o._def.returns.safeParse(h,r);if(!m.success)throw new ie([n(h,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new dt({...this._def,args:pe.create(e).rest(Be.create())})}returns(e){return new dt({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,i){return new dt({args:e||pe.create([]).rest(Be.create()),returns:t||Be.create(),typeName:T.ZodFunction,...$(i)})}}class At extends I{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}At.create=(s,e)=>new At({getter:s,typeName:T.ZodLazy,...$(e)});class Ot extends I{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return g(t,{received:t.data,code:p.invalid_literal,expected:this._def.value}),C}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ot.create=(s,e)=>new Ot({value:s,typeName:T.ZodLiteral,...$(e)});function Ti(s,e){return new Me({values:s,typeName:T.ZodEnum,...$(e)})}class Me extends I{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),i=this._def.values;return g(t,{expected:j.joinValues(i),received:t.parsedType,code:p.invalid_type}),C}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),i=this._def.values;return g(t,{received:t.data,code:p.invalid_enum_value,options:i}),C}return Y(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Me.create(e)}exclude(e){return Me.create(this.options.filter(t=>!e.includes(t)))}}Me.create=Ti;class It extends I{_parse(e){const t=j.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==f.string&&i.parsedType!==f.number){const n=j.objectValues(t);return g(i,{expected:j.joinValues(n),received:i.parsedType,code:p.invalid_type}),C}if(t.indexOf(e.data)===-1){const n=j.objectValues(t);return g(i,{received:i.data,code:p.invalid_enum_value,options:n}),C}return Y(e.data)}get enum(){return this._def.values}}It.create=(s,e)=>new It({values:s,typeName:T.ZodNativeEnum,...$(e)});class lt extends I{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return g(t,{code:p.invalid_type,expected:f.promise,received:t.parsedType}),C;const i=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return Y(i.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}lt.create=(s,e)=>new lt({type:s,typeName:T.ZodPromise,...$(e)});class ae extends I{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===T.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:i}=this._processInputParams(e),n=this._def.effect||null,r={addIssue:a=>{g(i,a),a.fatal?t.abort():t.dirty()},get path(){return i.path}};if(r.addIssue=r.addIssue.bind(r),n.type==="preprocess"){const a=n.transform(i.data,r);return i.common.issues.length?{status:"dirty",value:i.data}:i.common.async?Promise.resolve(a).then(o=>this._def.schema._parseAsync({data:o,path:i.path,parent:i})):this._def.schema._parseSync({data:a,path:i.path,parent:i})}if(n.type==="refinement"){const a=o=>{const c=n.refinement(o,r);if(i.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(i.common.async===!1){const o=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return o.status==="aborted"?C:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(o=>o.status==="aborted"?C:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(i.common.async===!1){const a=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!xt(a))return a;const o=n.transform(a.value,r);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(a=>xt(a)?Promise.resolve(n.transform(a.value,r)).then(o=>({status:t.value,value:o})):a);j.assertNever(n)}}ae.create=(s,e,t)=>new ae({schema:s,typeName:T.ZodEffects,effect:e,...$(t)}),ae.createWithPreprocess=(s,e,t)=>new ae({schema:e,effect:{type:"preprocess",transform:s},typeName:T.ZodEffects,...$(t)});class ve extends I{_parse(e){return this._getType(e)===f.undefined?Y(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ve.create=(s,e)=>new ve({innerType:s,typeName:T.ZodOptional,...$(e)});class Fe extends I{_parse(e){return this._getType(e)===f.null?Y(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Fe.create=(s,e)=>new Fe({innerType:s,typeName:T.ZodNullable,...$(e)});class Mt extends I{_parse(e){const{ctx:t}=this._processInputParams(e);let i=t.data;return t.parsedType===f.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Mt.create=(s,e)=>new Mt({innerType:s,typeName:T.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...$(e)});class is extends I{_parse(e){const{ctx:t}=this._processInputParams(e),i={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return Yt(n)?n.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new ie(i.common.issues)},input:i.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new ie(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}}is.create=(s,e)=>new is({innerType:s,typeName:T.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...$(e)});class ns extends I{_parse(e){if(this._getType(e)!==f.nan){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.nan,received:t.parsedType}),C}return{status:"valid",value:e.data}}}ns.create=s=>new ns({typeName:T.ZodNaN,...$(s)});const Un=Symbol("zod_brand");class Si extends I{_parse(e){const{ctx:t}=this._processInputParams(e),i=t.data;return this._def.type._parse({data:i,path:t.path,parent:t})}unwrap(){return this._def.type}}class Nt extends I{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?C:n.status==="dirty"?(t.dirty(),ki(n.value)):this._def.out._parseAsync({data:n.value,path:i.path,parent:i})})();{const n=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?C:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:i.path,parent:i})}}static create(e,t){return new Nt({in:e,out:t,typeName:T.ZodPipeline})}}class rs extends I{_parse(e){const t=this._def.innerType._parse(e);return xt(t)&&(t.value=Object.freeze(t.value)),t}}rs.create=(s,e)=>new rs({innerType:s,typeName:T.ZodReadonly,...$(e)});const Ci=(s,e={},t)=>s?ot.create().superRefine((i,n)=>{var r,a;if(!s(i)){const o=typeof e=="function"?e(i):typeof e=="string"?{message:e}:e,c=(a=(r=o.fatal)!==null&&r!==void 0?r:t)!==null&&a!==void 0?a:!0,l=typeof o=="string"?{message:o}:o;n.addIssue({code:"custom",...l,fatal:c})}}):ot.create(),Hn={object:U.lazycreate};var T;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(T||(T={}));const Bn=(s,e={message:`Input not instance of ${s.name}`})=>Ci(t=>t instanceof s,e),$i=ne.create,Ai=Oe.create,Wn=ns.create,Fn=Ie.create,Oi=kt.create,Vn=He.create,Kn=Xt.create,Jn=Et.create,qn=Tt.create,Gn=ot.create,Yn=Be.create,Xn=ye.create,Qn=Qt.create,er=re.create,tr=U.create,sr=U.strictCreate,ir=St.create,nr=ts.create,rr=Ct.create,ar=pe.create,or=$t.create,cr=ss.create,dr=We.create,lr=dt.create,ur=At.create,hr=Ot.create,pr=Me.create,mr=It.create,fr=lt.create,Ii=ae.create,gr=ve.create,yr=Fe.create,vr=ae.createWithPreprocess,br=Nt.create;var b=Object.freeze({__proto__:null,defaultErrorMap:_t,setErrorMap:$n,getErrorMap:qt,makeIssue:Gt,EMPTY_PATH:An,addIssueToContext:g,ParseStatus:q,INVALID:C,DIRTY:ki,OK:Y,isAborted:xs,isDirty:ks,isValid:xt,isAsync:Yt,get util(){return j},get objectUtil(){return _s},ZodParsedType:f,getParsedType:Ae,ZodType:I,ZodString:ne,ZodNumber:Oe,ZodBigInt:Ie,ZodBoolean:kt,ZodDate:He,ZodSymbol:Xt,ZodUndefined:Et,ZodNull:Tt,ZodAny:ot,ZodUnknown:Be,ZodNever:ye,ZodVoid:Qt,ZodArray:re,ZodObject:U,ZodUnion:St,ZodDiscriminatedUnion:ts,ZodIntersection:Ct,ZodTuple:pe,ZodRecord:$t,ZodMap:ss,ZodSet:We,ZodFunction:dt,ZodLazy:At,ZodLiteral:Ot,ZodEnum:Me,ZodNativeEnum:It,ZodPromise:lt,ZodEffects:ae,ZodTransformer:ae,ZodOptional:ve,ZodNullable:Fe,ZodDefault:Mt,ZodCatch:is,ZodNaN:ns,BRAND:Un,ZodBranded:Si,ZodPipeline:Nt,ZodReadonly:rs,custom:Ci,Schema:I,ZodSchema:I,late:Hn,get ZodFirstPartyTypeKind(){return T},coerce:{string:s=>ne.create({...s,coerce:!0}),number:s=>Oe.create({...s,coerce:!0}),boolean:s=>kt.create({...s,coerce:!0}),bigint:s=>Ie.create({...s,coerce:!0}),date:s=>He.create({...s,coerce:!0})},any:Gn,array:er,bigint:Fn,boolean:Oi,date:Vn,discriminatedUnion:nr,effect:Ii,enum:pr,function:lr,instanceof:Bn,intersection:rr,lazy:ur,literal:hr,map:cr,nan:Wn,nativeEnum:mr,never:Xn,null:qn,nullable:yr,number:Ai,object:tr,oboolean:()=>Oi().optional(),onumber:()=>Ai().optional(),optional:gr,ostring:()=>$i().optional(),pipeline:br,preprocess:vr,promise:fr,record:or,set:dr,strictObject:sr,string:$i,symbol:Kn,transformer:Ii,tuple:ar,undefined:Jn,union:ir,unknown:Yn,void:Qn,NEVER:C,ZodIssueCode:p,quotelessJson:Cn,ZodError:ie});const as=b.object({assistantId:b.string(),params:b.record(b.any()).default({}),config:b.object({historyKey:b.string().refine(s=>s.replace(/-/g,"_")).nullable().default("main"),welcomeMessage:b.string().default("Hello! How can I help you today?"),inactivityWarningMessage:b.string().default("Are you still there? The chat will end soon if we don't hear from you."),chatEndedMessage:b.string().default("The chat has ended. Please restart the chat to continue."),initialReplyMessage:b.string().nullable().default(null),placement:b.enum(["left","right"]).default("right"),openChatButton:b.object({imageSrc:b.string().optional(),width:b.union([b.string(),b.number()]).default("48px"),height:b.union([b.string(),b.number()]).default("48px"),cta:b.string().optional()}).default({}),chatWindow:b.object({header:b.object({text:b.string().nullable().default("AI Chat"),imageSrc:b.string().optional()}).default({}),showCloseButton:b.boolean().default(!0)}).default({}),styles:b.object({primaryColor:b.string().optional(),textColor:b.string().optional(),openChatButton:b.object({backgroundColor:b.string().optional(),iconColor:b.string().optional()}).optional(),header:b.object({backgroundColor:b.string().optional(),textColor:b.string().optional()}).optional(),button:b.object({backgroundColor:b.string().optional(),textColor:b.string().optional()}).optional(),messages:b.object({user:b.object({backgroundColor:b.string().optional(),textColor:b.string().optional()}).optional(),assistant:b.object({backgroundColor:b.string().optional(),textColor:b.string().optional()}).optional()}).optional()}).default({})}).default({}),handlers:b.object({functionCalls:b.record(b.function().returns(b.union([b.any(),b.promise(b.any())]))).default({}),enhancedContent:b.record(b.function().returns(b.union([b.any(),b.promise(b.any())]))).default({})}).default({})});function wr(s){if(Array.isArray(s)){for(var e=0,t=Array(s.length);e<s.length;e++)t[e]=s[e];return t}else return Array.from(s)}var Ss=!1;if(typeof window<"u"){var Mi={get passive(){Ss=!0}};window.addEventListener("testPassive",null,Mi),window.removeEventListener("testPassive",null,Mi)}var os=typeof window<"u"&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||window.navigator.platform==="MacIntel"&&window.navigator.maxTouchPoints>1),Ve=[],cs=!1,Ni=-1,Pt=void 0,Ke=void 0,jt=void 0,Pi=function(s){return Ve.some(function(e){return!!(e.options.allowTouchMove&&e.options.allowTouchMove(s))})},Cs=function(s){var e=s||window.event;return Pi(e.target)||e.touches.length>1?!0:(e.preventDefault&&e.preventDefault(),!1)},_r=function(s){if(jt===void 0){var e=!!s&&s.reserveScrollBarGap===!0,t=window.innerWidth-document.documentElement.clientWidth;if(e&&t>0){var i=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);jt=document.body.style.paddingRight,document.body.style.paddingRight=i+t+"px"}}Pt===void 0&&(Pt=document.body.style.overflow,document.body.style.overflow="hidden")},xr=function(){jt!==void 0&&(document.body.style.paddingRight=jt,jt=void 0),Pt!==void 0&&(document.body.style.overflow=Pt,Pt=void 0)},kr=function(){return window.requestAnimationFrame(function(){if(Ke===void 0){Ke={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left};var s=window,e=s.scrollY,t=s.scrollX,i=s.innerHeight;document.body.style.position="fixed",document.body.style.top=-e,document.body.style.left=-t,setTimeout(function(){return window.requestAnimationFrame(function(){var n=i-window.innerHeight;n&&e>=i&&(document.body.style.top=-(e+n))})},300)}})},Er=function(){if(Ke!==void 0){var s=-parseInt(document.body.style.top,10),e=-parseInt(document.body.style.left,10);document.body.style.position=Ke.position,document.body.style.top=Ke.top,document.body.style.left=Ke.left,window.scrollTo(e,s),Ke=void 0}},Tr=function(s){return s?s.scrollHeight-s.scrollTop<=s.clientHeight:!1},Sr=function(s,e){var t=s.targetTouches[0].clientY-Ni;return Pi(s.target)?!1:e&&e.scrollTop===0&&t>0||Tr(e)&&t<0?Cs(s):(s.stopPropagation(),!0)},Cr=function(s,e){if(!s){console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");return}if(!Ve.some(function(i){return i.targetElement===s})){var t={targetElement:s,options:e||{}};Ve=[].concat(wr(Ve),[t]),os?kr():_r(e),os&&(s.ontouchstart=function(i){i.targetTouches.length===1&&(Ni=i.targetTouches[0].clientY)},s.ontouchmove=function(i){i.targetTouches.length===1&&Sr(i,s)},cs||(document.addEventListener("touchmove",Cs,Ss?{passive:!1}:void 0),cs=!0))}},ji=function(s){if(!s){console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");return}Ve=Ve.filter(function(e){return e.targetElement!==s}),os&&(s.ontouchstart=null,s.ontouchmove=null,cs&&Ve.length===0&&(document.removeEventListener("touchmove",Cs,Ss?{passive:!1}:void 0),cs=!1)),os?Er():xr()},$r=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ri(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var $s={};(function(s){function e(o){o&&o.options&&clearTimeout(o.options.timer)}function t(o,c,l,h){var m={timer:void 0,lastArgs:[]},d=function(){for(var w=this,N=[],H=0;H<arguments.length;H++)N[H]=arguments[H];m.lastArgs=N,m.timer?clearTimeout(m.timer):c&&l.apply(this,m.lastArgs),m.timer=setTimeout(function(){c||l.apply(w,m.lastArgs),m.timer=void 0},o)};return h&&(d=d.bind(h)),d.options=m,d}function i(o,c,l,h){var m;Object.defineProperty(l,h,{configurable:!0,enumerable:!1,get:function(){return m},set:function(d){m=t(o,c,d,this)}})}function n(o,c,l){var h=l.value;return l.value=t(o,c,h),l}function r(o,c){for(var l=[],h=2;h<arguments.length;h++)l[h-2]=arguments[h];if(l.length===0)throw new Error("function applied debounce decorator should be a method");if(l.length===1)throw new Error("method applied debounce decorator should have valid name");var m=l[0],d=l[1],w=l.length===3&&l[2]?l[2]:Object.getOwnPropertyDescriptor(m,d);if(w)return n(o,c,w);i(o,c,m,d)}function a(){for(var o=[],c=0;c<arguments.length;c++)o[c]=arguments[c];var l=500,h=!1;if(o.length&&(typeof o[0]=="number"||typeof o[0]=="object"&&o[0].leading!==void 0)){typeof o[0]=="number"&&(l=o[0]);var m=void 0;return typeof o[0]=="object"&&o[0].leading!==void 0&&(m=o[0]),1<o.length&&typeof o[1]=="object"&&o[1].leading!==void 0&&(m=o[1]),m&&(h=m.leading),function(){for(var d=[],w=0;w<arguments.length;w++)d[w]=arguments[w];return r.apply(void 0,[l,h].concat(d))}}return r.apply(void 0,[l,h].concat(o))}Object.defineProperty(s,"__esModule",{value:!0}),s.cancel=e,s.debounce=a})($s);var Ar=Object.defineProperty,Or=Object.getOwnPropertyDescriptor,Rt=(s,e,t,i)=>{for(var n=i>1?void 0:i?Or(e,t):e,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Ar(e,t,n),n};let Je=class extends se{constructor(){super(...arguments),this.isOpen=!0,this.onResizeHandler=()=>{this.isOpen&&window.innerWidth<768?Cr(this):ji(this)}}connectedCallback(){super.connectedCallback(),this.cleanOptions=as.parse(this.options),this.onResizeHandler(),window.addEventListener("resize",this.onResizeHandler,{passive:!0})}disconnectedCallback(){super.disconnectedCallback(),ji(this),window.removeEventListener("resize",this.onResizeHandler)}render(){const s=this.cleanOptions.config.placement!=="left",e=wi({fixed:!0,"bottom-0":!0,"w-full":this.isOpen,"h-full":this.isOpen,...s&&{"right-0":!0,"md:right-8":!0},...!s&&{"left-0":!0,"md:left-8":!0},"md:bottom-8":!0,"md:w-fit":!0,"md:h-fit":!0}),t=wi({"mt-4":!0,"px-8":!0,"pb-8":!0,"w-full":!0,hidden:this.isOpen,flex:!this.isOpen,"md:px-0":!0,"md:pb-0":!0,"md:w-[350px]":!0,"md:flex":!0});return D`
51
+ */const _i="important",Sn=" !"+_i,at=Kt(class extends Jt{constructor(s){var e;if(super(s),s.type!==Vt.ATTRIBUTE||s.name!=="style"||((e=s.strings)==null?void 0:e.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(s){return Object.keys(s).reduce((e,t)=>{const i=s[t];return i==null?e:e+`${t=t.includes("-")?t:t.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(s,[e]){const{style:t}=s.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(e)),this.render(e);for(const i of this.ft)e[i]==null&&(this.ft.delete(i),i.includes("-")?t.removeProperty(i):t[i]=null);for(const i in e){const n=e[i];if(n!=null){this.ft.add(i);const r=typeof n=="string"&&n.endsWith(Sn);i.includes("-")||r?t.setProperty(i,r?n.slice(0,-11):n,r?_i:""):t[i]=n}}return ue}});var j;(function(s){s.assertEqual=n=>n;function e(n){}s.assertIs=e;function t(n){throw new Error}s.assertNever=t,s.arrayToEnum=n=>{const r={};for(const a of n)r[a]=a;return r},s.getValidEnumValues=n=>{const r=s.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),a={};for(const o of r)a[o]=n[o];return s.objectValues(a)},s.objectValues=n=>s.objectKeys(n).map(function(r){return n[r]}),s.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const r=[];for(const a in n)Object.prototype.hasOwnProperty.call(n,a)&&r.push(a);return r},s.find=(n,r)=>{for(const a of n)if(r(a))return a},s.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function i(n,r=" | "){return n.map(a=>typeof a=="string"?`'${a}'`:a).join(r)}s.joinValues=i,s.jsonStringifyReplacer=(n,r)=>typeof r=="bigint"?r.toString():r})(j||(j={}));var _s;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(_s||(_s={}));const f=j.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ae=s=>{switch(typeof s){case"undefined":return f.undefined;case"string":return f.string;case"number":return isNaN(s)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(s)?f.array:s===null?f.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?f.promise:typeof Map<"u"&&s instanceof Map?f.map:typeof Set<"u"&&s instanceof Set?f.set:typeof Date<"u"&&s instanceof Date?f.date:f.object;default:return f.unknown}},p=j.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Cn=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:");class ie extends Error{constructor(e){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(r){return r.message},i={_errors:[]},n=r=>{for(const a of r.issues)if(a.code==="invalid_union")a.unionErrors.map(n);else if(a.code==="invalid_return_type")n(a.returnTypeError);else if(a.code==="invalid_arguments")n(a.argumentsError);else if(a.path.length===0)i._errors.push(t(a));else{let o=i,c=0;for(;c<a.path.length;){const l=a.path[c];c===a.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(a))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return n(this),i}toString(){return this.message}get message(){return JSON.stringify(this.issues,j.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},i=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):i.push(e(n));return{formErrors:i,fieldErrors:t}}get formErrors(){return this.flatten()}}ie.create=s=>new ie(s);const _t=(s,e)=>{let t;switch(s.code){case p.invalid_type:s.received===f.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case p.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,j.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:t=`Unrecognized key(s) in object: ${j.joinValues(s.keys,", ")}`;break;case p.invalid_union:t="Invalid input";break;case p.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${j.joinValues(s.options)}`;break;case p.invalid_enum_value:t=`Invalid enum value. Expected ${j.joinValues(s.options)}, received '${s.received}'`;break;case p.invalid_arguments:t="Invalid function arguments";break;case p.invalid_return_type:t="Invalid function return type";break;case p.invalid_date:t="Invalid date";break;case p.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:j.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case p.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case p.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case p.custom:t="Invalid input";break;case p.invalid_intersection_types:t="Intersection results could not be merged";break;case p.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case p.not_finite:t="Number must be finite";break;default:t=e.defaultError,j.assertNever(s)}return{message:t}};let xi=_t;function $n(s){xi=s}function qt(){return xi}const Gt=s=>{const{data:e,path:t,errorMaps:i,issueData:n}=s,r=[...t,...n.path||[]],a={...n,path:r};let o="";const c=i.filter(l=>!!l).slice().reverse();for(const l of c)o=l(a,{data:e,defaultError:o}).message;return{...n,path:r,message:n.message||o}},An=[];function g(s,e){const t=Gt({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,qt(),_t].filter(i=>!!i)});s.common.issues.push(t)}class q{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const i=[];for(const n of t){if(n.status==="aborted")return C;n.status==="dirty"&&e.dirty(),i.push(n.value)}return{status:e.value,value:i}}static async mergeObjectAsync(e,t){const i=[];for(const n of t)i.push({key:await n.key,value:await n.value});return q.mergeObjectSync(e,i)}static mergeObjectSync(e,t){const i={};for(const n of t){const{key:r,value:a}=n;if(r.status==="aborted"||a.status==="aborted")return C;r.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),r.value!=="__proto__"&&(typeof a.value<"u"||n.alwaysSet)&&(i[r.value]=a.value)}return{status:e.value,value:i}}}const C=Object.freeze({status:"aborted"}),ki=s=>({status:"dirty",value:s}),Y=s=>({status:"valid",value:s}),xs=s=>s.status==="aborted",ks=s=>s.status==="dirty",xt=s=>s.status==="valid",Yt=s=>typeof Promise<"u"&&s instanceof Promise;var _;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(_||(_={}));class he{constructor(e,t,i,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=i,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ei=(s,e)=>{if(xt(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new ie(s.common.issues);return this._error=t,this._error}}};function $(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:i,description:n}=s;if(e&&(t||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(r,a)=>r.code!=="invalid_type"?{message:a.defaultError}:typeof a.data>"u"?{message:i??a.defaultError}:{message:t??a.defaultError},description:n}}class I{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Ae(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new q,ctx:{common:e.parent.common,data:e.data,parsedType:Ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Yt(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const i=this.safeParse(e,t);if(i.success)return i.data;throw i.error}safeParse(e,t){var i;const n={common:{issues:[],async:(i=t==null?void 0:t.async)!==null&&i!==void 0?i:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ae(e)},r=this._parseSync({data:e,path:n.path,parent:n});return Ei(n,r)}async parseAsync(e,t){const i=await this.safeParseAsync(e,t);if(i.success)return i.data;throw i.error}async safeParseAsync(e,t){const i={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ae(e)},n=this._parse({data:e,path:i.path,parent:i}),r=await(Yt(n)?n:Promise.resolve(n));return Ei(i,r)}refine(e,t){const i=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,r)=>{const a=e(n),o=()=>r.addIssue({code:p.custom,...i(n)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((i,n)=>e(i)?!0:(n.addIssue(typeof t=="function"?t(i,n):t),!1))}_refinement(e){return new ae({schema:this,typeName:T.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ve.create(this,this._def)}nullable(){return Fe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return re.create(this,this._def)}promise(){return lt.create(this,this._def)}or(e){return St.create([this,e],this._def)}and(e){return Ct.create(this,e,this._def)}transform(e){return new ae({...$(this._def),schema:this,typeName:T.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Mt({...$(this._def),innerType:this,defaultValue:t,typeName:T.ZodDefault})}brand(){return new Si({typeName:T.ZodBranded,type:this,...$(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new is({...$(this._def),innerType:this,catchValue:t,typeName:T.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Nt.create(this,e)}readonly(){return rs.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const On=/^c[^\s-]{8,}$/i,In=/^[a-z][a-z0-9]*$/,Mn=/^[0-9A-HJKMNP-TV-Z]{26}$/,Nn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Pn=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,jn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Es;const Rn=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Zn=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Dn=s=>s.precision?s.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}Z$`):s.precision===0?s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Ln(s,e){return!!((e==="v4"||!e)&&Rn.test(s)||(e==="v6"||!e)&&Zn.test(s))}class ne extends I{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:f.string,received:n.parsedType}),C}const t=new q;let i;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(i=this._getOrReturnCtx(e,i),g(i,{code:p.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="max")e.data.length>n.value&&(i=this._getOrReturnCtx(e,i),g(i,{code:p.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="length"){const r=e.data.length>n.value,a=e.data.length<n.value;(r||a)&&(i=this._getOrReturnCtx(e,i),r?g(i,{code:p.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):a&&g(i,{code:p.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if(n.kind==="email")Pn.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"email",code:p.invalid_string,message:n.message}),t.dirty());else if(n.kind==="emoji")Es||(Es=new RegExp(jn,"u")),Es.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"emoji",code:p.invalid_string,message:n.message}),t.dirty());else if(n.kind==="uuid")Nn.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"uuid",code:p.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid")On.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"cuid",code:p.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid2")In.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"cuid2",code:p.invalid_string,message:n.message}),t.dirty());else if(n.kind==="ulid")Mn.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"ulid",code:p.invalid_string,message:n.message}),t.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),g(i,{validation:"url",code:p.invalid_string,message:n.message}),t.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"regex",code:p.invalid_string,message:n.message}),t.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(i=this._getOrReturnCtx(e,i),g(i,{code:p.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(i=this._getOrReturnCtx(e,i),g(i,{code:p.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(i=this._getOrReturnCtx(e,i),g(i,{code:p.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty()):n.kind==="datetime"?Dn(n).test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{code:p.invalid_string,validation:"datetime",message:n.message}),t.dirty()):n.kind==="ip"?Ln(e.data,n.version)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"ip",code:p.invalid_string,message:n.message}),t.dirty()):j.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,i){return this.refinement(n=>e.test(n),{validation:t,code:p.invalid_string,..._.errToObj(i)})}_addCheck(e){return new ne({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",..._.errToObj(e)})}url(e){return this._addCheck({kind:"url",..._.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",..._.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",..._.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",..._.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",..._.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",..._.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",..._.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,..._.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,..._.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,..._.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,..._.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,..._.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,..._.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,..._.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,..._.errToObj(t)})}nonempty(e){return this.min(1,_.errToObj(e))}trim(){return new ne({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ne({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ne({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ne.create=s=>{var e;return new ne({checks:[],typeName:T.ZodString,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...$(s)})};function zn(s,e){const t=(s.toString().split(".")[1]||"").length,i=(e.toString().split(".")[1]||"").length,n=t>i?t:i,r=parseInt(s.toFixed(n).replace(".","")),a=parseInt(e.toFixed(n).replace(".",""));return r%a/Math.pow(10,n)}class Oe extends I{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){const n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:f.number,received:n.parsedType}),C}let t;const i=new q;for(const n of this._def.checks)n.kind==="int"?j.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),g(t,{code:p.invalid_type,expected:"integer",received:"float",message:n.message}),i.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:p.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),i.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:p.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),i.dirty()):n.kind==="multipleOf"?zn(e.data,n.value)!==0&&(t=this._getOrReturnCtx(e,t),g(t,{code:p.not_multiple_of,multipleOf:n.value,message:n.message}),i.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),g(t,{code:p.not_finite,message:n.message}),i.dirty()):j.assertNever(n);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,_.toString(t))}gt(e,t){return this.setLimit("min",e,!1,_.toString(t))}lte(e,t){return this.setLimit("max",e,!0,_.toString(t))}lt(e,t){return this.setLimit("max",e,!1,_.toString(t))}setLimit(e,t,i,n){return new Oe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:i,message:_.toString(n)}]})}_addCheck(e){return new Oe({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:_.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:_.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&j.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(t===null||i.value>t)&&(t=i.value):i.kind==="max"&&(e===null||i.value<e)&&(e=i.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Oe.create=s=>new Oe({checks:[],typeName:T.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...$(s)});class Ie extends I{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==f.bigint){const n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:f.bigint,received:n.parsedType}),C}let t;const i=new q;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:p.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),i.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:p.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),i.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),g(t,{code:p.not_multiple_of,multipleOf:n.value,message:n.message}),i.dirty()):j.assertNever(n);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,_.toString(t))}gt(e,t){return this.setLimit("min",e,!1,_.toString(t))}lte(e,t){return this.setLimit("max",e,!0,_.toString(t))}lt(e,t){return this.setLimit("max",e,!1,_.toString(t))}setLimit(e,t,i,n){return new Ie({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:i,message:_.toString(n)}]})}_addCheck(e){return new Ie({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Ie.create=s=>{var e;return new Ie({checks:[],typeName:T.ZodBigInt,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...$(s)})};class kt extends I{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.boolean,received:t.parsedType}),C}return Y(e.data)}}kt.create=s=>new kt({typeName:T.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...$(s)});class He extends I{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:f.date,received:n.parsedType}),C}if(isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_date}),C}const t=new q;let i;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(i=this._getOrReturnCtx(e,i),g(i,{code:p.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(i=this._getOrReturnCtx(e,i),g(i,{code:p.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):j.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new He({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:_.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:_.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}He.create=s=>new He({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:T.ZodDate,...$(s)});class Xt extends I{_parse(e){if(this._getType(e)!==f.symbol){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.symbol,received:t.parsedType}),C}return Y(e.data)}}Xt.create=s=>new Xt({typeName:T.ZodSymbol,...$(s)});class Et extends I{_parse(e){if(this._getType(e)!==f.undefined){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.undefined,received:t.parsedType}),C}return Y(e.data)}}Et.create=s=>new Et({typeName:T.ZodUndefined,...$(s)});class Tt extends I{_parse(e){if(this._getType(e)!==f.null){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.null,received:t.parsedType}),C}return Y(e.data)}}Tt.create=s=>new Tt({typeName:T.ZodNull,...$(s)});class ot extends I{constructor(){super(...arguments),this._any=!0}_parse(e){return Y(e.data)}}ot.create=s=>new ot({typeName:T.ZodAny,...$(s)});class Be extends I{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Y(e.data)}}Be.create=s=>new Be({typeName:T.ZodUnknown,...$(s)});class ye extends I{_parse(e){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.never,received:t.parsedType}),C}}ye.create=s=>new ye({typeName:T.ZodNever,...$(s)});class Qt extends I{_parse(e){if(this._getType(e)!==f.undefined){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.void,received:t.parsedType}),C}return Y(e.data)}}Qt.create=s=>new Qt({typeName:T.ZodVoid,...$(s)});class re extends I{_parse(e){const{ctx:t,status:i}=this._processInputParams(e),n=this._def;if(t.parsedType!==f.array)return g(t,{code:p.invalid_type,expected:f.array,received:t.parsedType}),C;if(n.exactLength!==null){const a=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(a||o)&&(g(t,{code:a?p.too_big:p.too_small,minimum:o?n.exactLength.value:void 0,maximum:a?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),i.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(g(t,{code:p.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),i.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(g(t,{code:p.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),i.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>n.type._parseAsync(new he(t,a,t.path,o)))).then(a=>q.mergeArray(i,a));const r=[...t.data].map((a,o)=>n.type._parseSync(new he(t,a,t.path,o)));return q.mergeArray(i,r)}get element(){return this._def.type}min(e,t){return new re({...this._def,minLength:{value:e,message:_.toString(t)}})}max(e,t){return new re({...this._def,maxLength:{value:e,message:_.toString(t)}})}length(e,t){return new re({...this._def,exactLength:{value:e,message:_.toString(t)}})}nonempty(e){return this.min(1,e)}}re.create=(s,e)=>new re({type:s,minLength:null,maxLength:null,exactLength:null,typeName:T.ZodArray,...$(e)});function ct(s){if(s instanceof U){const e={};for(const t in s.shape){const i=s.shape[t];e[t]=ve.create(ct(i))}return new U({...s._def,shape:()=>e})}else return s instanceof re?new re({...s._def,type:ct(s.element)}):s instanceof ve?ve.create(ct(s.unwrap())):s instanceof Fe?Fe.create(ct(s.unwrap())):s instanceof pe?pe.create(s.items.map(e=>ct(e))):s}class U extends I{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=j.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==f.object){const c=this._getOrReturnCtx(e);return g(c,{code:p.invalid_type,expected:f.object,received:c.parsedType}),C}const{status:t,ctx:i}=this._processInputParams(e),{shape:n,keys:r}=this._getCached(),a=[];if(!(this._def.catchall instanceof ye&&this._def.unknownKeys==="strip"))for(const c in i.data)r.includes(c)||a.push(c);const o=[];for(const c of r){const l=n[c],h=i.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new he(i,h,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof ye){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of a)o.push({key:{status:"valid",value:l},value:{status:"valid",value:i.data[l]}});else if(c==="strict")a.length>0&&(g(i,{code:p.unrecognized_keys,keys:a}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of a){const h=i.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new he(i,h,i.path,l)),alwaysSet:l in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const h=await l.key;c.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>q.mergeObjectSync(t,c)):q.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return _.errToObj,new U({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,i)=>{var n,r,a,o;const c=(a=(r=(n=this._def).errorMap)===null||r===void 0?void 0:r.call(n,t,i).message)!==null&&a!==void 0?a:i.defaultError;return t.code==="unrecognized_keys"?{message:(o=_.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new U({...this._def,unknownKeys:"strip"})}passthrough(){return new U({...this._def,unknownKeys:"passthrough"})}extend(e){return new U({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new U({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:T.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new U({...this._def,catchall:e})}pick(e){const t={};return j.objectKeys(e).forEach(i=>{e[i]&&this.shape[i]&&(t[i]=this.shape[i])}),new U({...this._def,shape:()=>t})}omit(e){const t={};return j.objectKeys(this.shape).forEach(i=>{e[i]||(t[i]=this.shape[i])}),new U({...this._def,shape:()=>t})}deepPartial(){return ct(this)}partial(e){const t={};return j.objectKeys(this.shape).forEach(i=>{const n=this.shape[i];e&&!e[i]?t[i]=n:t[i]=n.optional()}),new U({...this._def,shape:()=>t})}required(e){const t={};return j.objectKeys(this.shape).forEach(i=>{if(e&&!e[i])t[i]=this.shape[i];else{let n=this.shape[i];for(;n instanceof ve;)n=n._def.innerType;t[i]=n}}),new U({...this._def,shape:()=>t})}keyof(){return Ti(j.objectKeys(this.shape))}}U.create=(s,e)=>new U({shape:()=>s,unknownKeys:"strip",catchall:ye.create(),typeName:T.ZodObject,...$(e)}),U.strictCreate=(s,e)=>new U({shape:()=>s,unknownKeys:"strict",catchall:ye.create(),typeName:T.ZodObject,...$(e)}),U.lazycreate=(s,e)=>new U({shape:s,unknownKeys:"strip",catchall:ye.create(),typeName:T.ZodObject,...$(e)});class St extends I{_parse(e){const{ctx:t}=this._processInputParams(e),i=this._def.options;function n(r){for(const o of r)if(o.result.status==="valid")return o.result;for(const o of r)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=r.map(o=>new ie(o.ctx.common.issues));return g(t,{code:p.invalid_union,unionErrors:a}),C}if(t.common.async)return Promise.all(i.map(async r=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await r._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(n);{let r;const a=[];for(const c of i){const l={...t,common:{...t.common,issues:[]},parent:null},h=c._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!r&&(r={result:h,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(r)return t.common.issues.push(...r.ctx.common.issues),r.result;const o=a.map(c=>new ie(c));return g(t,{code:p.invalid_union,unionErrors:o}),C}}get options(){return this._def.options}}St.create=(s,e)=>new St({options:s,typeName:T.ZodUnion,...$(e)});const es=s=>s instanceof At?es(s.schema):s instanceof ae?es(s.innerType()):s instanceof Ot?[s.value]:s instanceof Me?s.options:s instanceof It?Object.keys(s.enum):s instanceof Mt?es(s._def.innerType):s instanceof Et?[void 0]:s instanceof Tt?[null]:null;class ts extends I{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return g(t,{code:p.invalid_type,expected:f.object,received:t.parsedType}),C;const i=this.discriminator,n=t.data[i],r=this.optionsMap.get(n);return r?t.common.async?r._parseAsync({data:t.data,path:t.path,parent:t}):r._parseSync({data:t.data,path:t.path,parent:t}):(g(t,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),C)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,i){const n=new Map;for(const r of t){const a=es(r.shape[e]);if(!a)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,r)}}return new ts({typeName:T.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...$(i)})}}function Ts(s,e){const t=Ae(s),i=Ae(e);if(s===e)return{valid:!0,data:s};if(t===f.object&&i===f.object){const n=j.objectKeys(e),r=j.objectKeys(s).filter(o=>n.indexOf(o)!==-1),a={...s,...e};for(const o of r){const c=Ts(s[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===f.array&&i===f.array){if(s.length!==e.length)return{valid:!1};const n=[];for(let r=0;r<s.length;r++){const a=s[r],o=e[r],c=Ts(a,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===f.date&&i===f.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}class Ct extends I{_parse(e){const{status:t,ctx:i}=this._processInputParams(e),n=(r,a)=>{if(xs(r)||xs(a))return C;const o=Ts(r.value,a.value);return o.valid?((ks(r)||ks(a))&&t.dirty(),{status:t.value,value:o.data}):(g(i,{code:p.invalid_intersection_types}),C)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([r,a])=>n(r,a)):n(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}}Ct.create=(s,e,t)=>new Ct({left:s,right:e,typeName:T.ZodIntersection,...$(t)});class pe extends I{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==f.array)return g(i,{code:p.invalid_type,expected:f.array,received:i.parsedType}),C;if(i.data.length<this._def.items.length)return g(i,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),C;!this._def.rest&&i.data.length>this._def.items.length&&(g(i,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...i.data].map((r,a)=>{const o=this._def.items[a]||this._def.rest;return o?o._parse(new he(i,r,i.path,a)):null}).filter(r=>!!r);return i.common.async?Promise.all(n).then(r=>q.mergeArray(t,r)):q.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new pe({...this._def,rest:e})}}pe.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new pe({items:s,typeName:T.ZodTuple,rest:null,...$(e)})};class $t extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==f.object)return g(i,{code:p.invalid_type,expected:f.object,received:i.parsedType}),C;const n=[],r=this._def.keyType,a=this._def.valueType;for(const o in i.data)n.push({key:r._parse(new he(i,o,i.path,o)),value:a._parse(new he(i,i.data[o],i.path,o))});return i.common.async?q.mergeObjectAsync(t,n):q.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,i){return t instanceof I?new $t({keyType:e,valueType:t,typeName:T.ZodRecord,...$(i)}):new $t({keyType:ne.create(),valueType:e,typeName:T.ZodRecord,...$(t)})}}class ss extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==f.map)return g(i,{code:p.invalid_type,expected:f.map,received:i.parsedType}),C;const n=this._def.keyType,r=this._def.valueType,a=[...i.data.entries()].map(([o,c],l)=>({key:n._parse(new he(i,o,i.path,[l,"key"])),value:r._parse(new he(i,c,i.path,[l,"value"]))}));if(i.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return C;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return C;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}}ss.create=(s,e,t)=>new ss({valueType:e,keyType:s,typeName:T.ZodMap,...$(t)});class We extends I{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==f.set)return g(i,{code:p.invalid_type,expected:f.set,received:i.parsedType}),C;const n=this._def;n.minSize!==null&&i.data.size<n.minSize.value&&(g(i,{code:p.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&i.data.size>n.maxSize.value&&(g(i,{code:p.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const r=this._def.valueType;function a(c){const l=new Set;for(const h of c){if(h.status==="aborted")return C;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...i.data.values()].map((c,l)=>r._parse(new he(i,c,i.path,l)));return i.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new We({...this._def,minSize:{value:e,message:_.toString(t)}})}max(e,t){return new We({...this._def,maxSize:{value:e,message:_.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}We.create=(s,e)=>new We({valueType:s,minSize:null,maxSize:null,typeName:T.ZodSet,...$(e)});class dt extends I{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return g(t,{code:p.invalid_type,expected:f.function,received:t.parsedType}),C;function i(o,c){return Gt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,qt(),_t].filter(l=>!!l),issueData:{code:p.invalid_arguments,argumentsError:c}})}function n(o,c){return Gt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,qt(),_t].filter(l=>!!l),issueData:{code:p.invalid_return_type,returnTypeError:c}})}const r={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof lt){const o=this;return Y(async function(...c){const l=new ie([]),h=await o._def.args.parseAsync(c,r).catch(d=>{throw l.addIssue(i(c,d)),l}),m=await Reflect.apply(a,this,h);return await o._def.returns._def.type.parseAsync(m,r).catch(d=>{throw l.addIssue(n(m,d)),l})})}else{const o=this;return Y(function(...c){const l=o._def.args.safeParse(c,r);if(!l.success)throw new ie([i(c,l.error)]);const h=Reflect.apply(a,this,l.data),m=o._def.returns.safeParse(h,r);if(!m.success)throw new ie([n(h,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new dt({...this._def,args:pe.create(e).rest(Be.create())})}returns(e){return new dt({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,i){return new dt({args:e||pe.create([]).rest(Be.create()),returns:t||Be.create(),typeName:T.ZodFunction,...$(i)})}}class At extends I{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}At.create=(s,e)=>new At({getter:s,typeName:T.ZodLazy,...$(e)});class Ot extends I{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return g(t,{received:t.data,code:p.invalid_literal,expected:this._def.value}),C}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ot.create=(s,e)=>new Ot({value:s,typeName:T.ZodLiteral,...$(e)});function Ti(s,e){return new Me({values:s,typeName:T.ZodEnum,...$(e)})}class Me extends I{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),i=this._def.values;return g(t,{expected:j.joinValues(i),received:t.parsedType,code:p.invalid_type}),C}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),i=this._def.values;return g(t,{received:t.data,code:p.invalid_enum_value,options:i}),C}return Y(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Me.create(e)}exclude(e){return Me.create(this.options.filter(t=>!e.includes(t)))}}Me.create=Ti;class It extends I{_parse(e){const t=j.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==f.string&&i.parsedType!==f.number){const n=j.objectValues(t);return g(i,{expected:j.joinValues(n),received:i.parsedType,code:p.invalid_type}),C}if(t.indexOf(e.data)===-1){const n=j.objectValues(t);return g(i,{received:i.data,code:p.invalid_enum_value,options:n}),C}return Y(e.data)}get enum(){return this._def.values}}It.create=(s,e)=>new It({values:s,typeName:T.ZodNativeEnum,...$(e)});class lt extends I{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return g(t,{code:p.invalid_type,expected:f.promise,received:t.parsedType}),C;const i=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return Y(i.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}lt.create=(s,e)=>new lt({type:s,typeName:T.ZodPromise,...$(e)});class ae extends I{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===T.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:i}=this._processInputParams(e),n=this._def.effect||null,r={addIssue:a=>{g(i,a),a.fatal?t.abort():t.dirty()},get path(){return i.path}};if(r.addIssue=r.addIssue.bind(r),n.type==="preprocess"){const a=n.transform(i.data,r);return i.common.issues.length?{status:"dirty",value:i.data}:i.common.async?Promise.resolve(a).then(o=>this._def.schema._parseAsync({data:o,path:i.path,parent:i})):this._def.schema._parseSync({data:a,path:i.path,parent:i})}if(n.type==="refinement"){const a=o=>{const c=n.refinement(o,r);if(i.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(i.common.async===!1){const o=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return o.status==="aborted"?C:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(o=>o.status==="aborted"?C:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(i.common.async===!1){const a=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!xt(a))return a;const o=n.transform(a.value,r);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(a=>xt(a)?Promise.resolve(n.transform(a.value,r)).then(o=>({status:t.value,value:o})):a);j.assertNever(n)}}ae.create=(s,e,t)=>new ae({schema:s,typeName:T.ZodEffects,effect:e,...$(t)}),ae.createWithPreprocess=(s,e,t)=>new ae({schema:e,effect:{type:"preprocess",transform:s},typeName:T.ZodEffects,...$(t)});class ve extends I{_parse(e){return this._getType(e)===f.undefined?Y(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ve.create=(s,e)=>new ve({innerType:s,typeName:T.ZodOptional,...$(e)});class Fe extends I{_parse(e){return this._getType(e)===f.null?Y(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Fe.create=(s,e)=>new Fe({innerType:s,typeName:T.ZodNullable,...$(e)});class Mt extends I{_parse(e){const{ctx:t}=this._processInputParams(e);let i=t.data;return t.parsedType===f.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Mt.create=(s,e)=>new Mt({innerType:s,typeName:T.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...$(e)});class is extends I{_parse(e){const{ctx:t}=this._processInputParams(e),i={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return Yt(n)?n.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new ie(i.common.issues)},input:i.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new ie(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}}is.create=(s,e)=>new is({innerType:s,typeName:T.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...$(e)});class ns extends I{_parse(e){if(this._getType(e)!==f.nan){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.nan,received:t.parsedType}),C}return{status:"valid",value:e.data}}}ns.create=s=>new ns({typeName:T.ZodNaN,...$(s)});const Un=Symbol("zod_brand");class Si extends I{_parse(e){const{ctx:t}=this._processInputParams(e),i=t.data;return this._def.type._parse({data:i,path:t.path,parent:t})}unwrap(){return this._def.type}}class Nt extends I{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?C:n.status==="dirty"?(t.dirty(),ki(n.value)):this._def.out._parseAsync({data:n.value,path:i.path,parent:i})})();{const n=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?C:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:i.path,parent:i})}}static create(e,t){return new Nt({in:e,out:t,typeName:T.ZodPipeline})}}class rs extends I{_parse(e){const t=this._def.innerType._parse(e);return xt(t)&&(t.value=Object.freeze(t.value)),t}}rs.create=(s,e)=>new rs({innerType:s,typeName:T.ZodReadonly,...$(e)});const Ci=(s,e={},t)=>s?ot.create().superRefine((i,n)=>{var r,a;if(!s(i)){const o=typeof e=="function"?e(i):typeof e=="string"?{message:e}:e,c=(a=(r=o.fatal)!==null&&r!==void 0?r:t)!==null&&a!==void 0?a:!0,l=typeof o=="string"?{message:o}:o;n.addIssue({code:"custom",...l,fatal:c})}}):ot.create(),Hn={object:U.lazycreate};var T;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(T||(T={}));const Bn=(s,e={message:`Input not instance of ${s.name}`})=>Ci(t=>t instanceof s,e),$i=ne.create,Ai=Oe.create,Wn=ns.create,Fn=Ie.create,Oi=kt.create,Vn=He.create,Kn=Xt.create,Jn=Et.create,qn=Tt.create,Gn=ot.create,Yn=Be.create,Xn=ye.create,Qn=Qt.create,er=re.create,tr=U.create,sr=U.strictCreate,ir=St.create,nr=ts.create,rr=Ct.create,ar=pe.create,or=$t.create,cr=ss.create,dr=We.create,lr=dt.create,ur=At.create,hr=Ot.create,pr=Me.create,mr=It.create,fr=lt.create,Ii=ae.create,gr=ve.create,yr=Fe.create,vr=ae.createWithPreprocess,br=Nt.create;var b=Object.freeze({__proto__:null,defaultErrorMap:_t,setErrorMap:$n,getErrorMap:qt,makeIssue:Gt,EMPTY_PATH:An,addIssueToContext:g,ParseStatus:q,INVALID:C,DIRTY:ki,OK:Y,isAborted:xs,isDirty:ks,isValid:xt,isAsync:Yt,get util(){return j},get objectUtil(){return _s},ZodParsedType:f,getParsedType:Ae,ZodType:I,ZodString:ne,ZodNumber:Oe,ZodBigInt:Ie,ZodBoolean:kt,ZodDate:He,ZodSymbol:Xt,ZodUndefined:Et,ZodNull:Tt,ZodAny:ot,ZodUnknown:Be,ZodNever:ye,ZodVoid:Qt,ZodArray:re,ZodObject:U,ZodUnion:St,ZodDiscriminatedUnion:ts,ZodIntersection:Ct,ZodTuple:pe,ZodRecord:$t,ZodMap:ss,ZodSet:We,ZodFunction:dt,ZodLazy:At,ZodLiteral:Ot,ZodEnum:Me,ZodNativeEnum:It,ZodPromise:lt,ZodEffects:ae,ZodTransformer:ae,ZodOptional:ve,ZodNullable:Fe,ZodDefault:Mt,ZodCatch:is,ZodNaN:ns,BRAND:Un,ZodBranded:Si,ZodPipeline:Nt,ZodReadonly:rs,custom:Ci,Schema:I,ZodSchema:I,late:Hn,get ZodFirstPartyTypeKind(){return T},coerce:{string:s=>ne.create({...s,coerce:!0}),number:s=>Oe.create({...s,coerce:!0}),boolean:s=>kt.create({...s,coerce:!0}),bigint:s=>Ie.create({...s,coerce:!0}),date:s=>He.create({...s,coerce:!0})},any:Gn,array:er,bigint:Fn,boolean:Oi,date:Vn,discriminatedUnion:nr,effect:Ii,enum:pr,function:lr,instanceof:Bn,intersection:rr,lazy:ur,literal:hr,map:cr,nan:Wn,nativeEnum:mr,never:Xn,null:qn,nullable:yr,number:Ai,object:tr,oboolean:()=>Oi().optional(),onumber:()=>Ai().optional(),optional:gr,ostring:()=>$i().optional(),pipeline:br,preprocess:vr,promise:fr,record:or,set:dr,strictObject:sr,string:$i,symbol:Kn,transformer:Ii,tuple:ar,undefined:Jn,union:ir,unknown:Yn,void:Qn,NEVER:C,ZodIssueCode:p,quotelessJson:Cn,ZodError:ie});const as=b.object({assistantId:b.string(),params:b.record(b.any()).default({}),config:b.object({historyKey:b.string().refine(s=>s.replace(/-/g,"_")).nullable().default("main"),welcomeMessage:b.string().default("Hello! How can I help you today?"),inactivityWarningMessage:b.string().default("Are you still there? The chat will end soon if we don't hear from you."),chatEndedMessage:b.string().default("The chat has ended. Please restart the chat to continue."),initialReplyMessage:b.string().nullable().default(null),simulateDelays:b.boolean().default(!0),placement:b.enum(["left","right"]).default("right"),openChatButton:b.object({imageSrc:b.string().optional(),width:b.union([b.string(),b.number()]).default("48px"),height:b.union([b.string(),b.number()]).default("48px"),cta:b.string().optional()}).default({}),chatWindow:b.object({header:b.object({text:b.string().nullable().default("AI Chat"),imageSrc:b.string().optional()}).default({}),showCloseButton:b.boolean().default(!0)}).default({}),styles:b.object({primaryColor:b.string().optional(),textColor:b.string().optional(),openChatButton:b.object({backgroundColor:b.string().optional(),iconColor:b.string().optional()}).optional(),header:b.object({backgroundColor:b.string().optional(),textColor:b.string().optional()}).optional(),button:b.object({backgroundColor:b.string().optional(),textColor:b.string().optional()}).optional(),messages:b.object({user:b.object({backgroundColor:b.string().optional(),textColor:b.string().optional()}).optional(),assistant:b.object({backgroundColor:b.string().optional(),textColor:b.string().optional()}).optional()}).optional()}).default({})}).default({}),handlers:b.object({functionCalls:b.record(b.function().returns(b.union([b.any(),b.promise(b.any())]))).default({}),enhancedContent:b.record(b.function().returns(b.union([b.any(),b.promise(b.any())]))).default({})}).default({})});function wr(s){if(Array.isArray(s)){for(var e=0,t=Array(s.length);e<s.length;e++)t[e]=s[e];return t}else return Array.from(s)}var Ss=!1;if(typeof window<"u"){var Mi={get passive(){Ss=!0}};window.addEventListener("testPassive",null,Mi),window.removeEventListener("testPassive",null,Mi)}var os=typeof window<"u"&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||window.navigator.platform==="MacIntel"&&window.navigator.maxTouchPoints>1),Ve=[],cs=!1,Ni=-1,Pt=void 0,Ke=void 0,jt=void 0,Pi=function(s){return Ve.some(function(e){return!!(e.options.allowTouchMove&&e.options.allowTouchMove(s))})},Cs=function(s){var e=s||window.event;return Pi(e.target)||e.touches.length>1?!0:(e.preventDefault&&e.preventDefault(),!1)},_r=function(s){if(jt===void 0){var e=!!s&&s.reserveScrollBarGap===!0,t=window.innerWidth-document.documentElement.clientWidth;if(e&&t>0){var i=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);jt=document.body.style.paddingRight,document.body.style.paddingRight=i+t+"px"}}Pt===void 0&&(Pt=document.body.style.overflow,document.body.style.overflow="hidden")},xr=function(){jt!==void 0&&(document.body.style.paddingRight=jt,jt=void 0),Pt!==void 0&&(document.body.style.overflow=Pt,Pt=void 0)},kr=function(){return window.requestAnimationFrame(function(){if(Ke===void 0){Ke={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left};var s=window,e=s.scrollY,t=s.scrollX,i=s.innerHeight;document.body.style.position="fixed",document.body.style.top=-e,document.body.style.left=-t,setTimeout(function(){return window.requestAnimationFrame(function(){var n=i-window.innerHeight;n&&e>=i&&(document.body.style.top=-(e+n))})},300)}})},Er=function(){if(Ke!==void 0){var s=-parseInt(document.body.style.top,10),e=-parseInt(document.body.style.left,10);document.body.style.position=Ke.position,document.body.style.top=Ke.top,document.body.style.left=Ke.left,window.scrollTo(e,s),Ke=void 0}},Tr=function(s){return s?s.scrollHeight-s.scrollTop<=s.clientHeight:!1},Sr=function(s,e){var t=s.targetTouches[0].clientY-Ni;return Pi(s.target)?!1:e&&e.scrollTop===0&&t>0||Tr(e)&&t<0?Cs(s):(s.stopPropagation(),!0)},Cr=function(s,e){if(!s){console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");return}if(!Ve.some(function(i){return i.targetElement===s})){var t={targetElement:s,options:e||{}};Ve=[].concat(wr(Ve),[t]),os?kr():_r(e),os&&(s.ontouchstart=function(i){i.targetTouches.length===1&&(Ni=i.targetTouches[0].clientY)},s.ontouchmove=function(i){i.targetTouches.length===1&&Sr(i,s)},cs||(document.addEventListener("touchmove",Cs,Ss?{passive:!1}:void 0),cs=!0))}},ji=function(s){if(!s){console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");return}Ve=Ve.filter(function(e){return e.targetElement!==s}),os&&(s.ontouchstart=null,s.ontouchmove=null,cs&&Ve.length===0&&(document.removeEventListener("touchmove",Cs,Ss?{passive:!1}:void 0),cs=!1)),os?Er():xr()},$r=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ri(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var $s={};(function(s){function e(o){o&&o.options&&clearTimeout(o.options.timer)}function t(o,c,l,h){var m={timer:void 0,lastArgs:[]},d=function(){for(var w=this,N=[],H=0;H<arguments.length;H++)N[H]=arguments[H];m.lastArgs=N,m.timer?clearTimeout(m.timer):c&&l.apply(this,m.lastArgs),m.timer=setTimeout(function(){c||l.apply(w,m.lastArgs),m.timer=void 0},o)};return h&&(d=d.bind(h)),d.options=m,d}function i(o,c,l,h){var m;Object.defineProperty(l,h,{configurable:!0,enumerable:!1,get:function(){return m},set:function(d){m=t(o,c,d,this)}})}function n(o,c,l){var h=l.value;return l.value=t(o,c,h),l}function r(o,c){for(var l=[],h=2;h<arguments.length;h++)l[h-2]=arguments[h];if(l.length===0)throw new Error("function applied debounce decorator should be a method");if(l.length===1)throw new Error("method applied debounce decorator should have valid name");var m=l[0],d=l[1],w=l.length===3&&l[2]?l[2]:Object.getOwnPropertyDescriptor(m,d);if(w)return n(o,c,w);i(o,c,m,d)}function a(){for(var o=[],c=0;c<arguments.length;c++)o[c]=arguments[c];var l=500,h=!1;if(o.length&&(typeof o[0]=="number"||typeof o[0]=="object"&&o[0].leading!==void 0)){typeof o[0]=="number"&&(l=o[0]);var m=void 0;return typeof o[0]=="object"&&o[0].leading!==void 0&&(m=o[0]),1<o.length&&typeof o[1]=="object"&&o[1].leading!==void 0&&(m=o[1]),m&&(h=m.leading),function(){for(var d=[],w=0;w<arguments.length;w++)d[w]=arguments[w];return r.apply(void 0,[l,h].concat(d))}}return r.apply(void 0,[l,h].concat(o))}Object.defineProperty(s,"__esModule",{value:!0}),s.cancel=e,s.debounce=a})($s);var Ar=Object.defineProperty,Or=Object.getOwnPropertyDescriptor,Rt=(s,e,t,i)=>{for(var n=i>1?void 0:i?Or(e,t):e,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Ar(e,t,n),n};let Je=class extends se{constructor(){super(...arguments),this.isOpen=!0,this.onResizeHandler=()=>{this.isOpen&&window.innerWidth<768?Cr(this):ji(this)}}connectedCallback(){super.connectedCallback(),this.cleanOptions=as.parse(this.options),this.onResizeHandler(),window.addEventListener("resize",this.onResizeHandler,{passive:!0})}disconnectedCallback(){super.disconnectedCallback(),ji(this),window.removeEventListener("resize",this.onResizeHandler)}render(){const s=this.cleanOptions.config.placement!=="left",e=wi({fixed:!0,"bottom-0":!0,"w-full":this.isOpen,"h-full":this.isOpen,...s&&{"right-0":!0,"md:right-8":!0},...!s&&{"left-0":!0,"md:left-8":!0},"md:bottom-8":!0,"md:w-fit":!0,"md:h-fit":!0}),t=wi({"mt-4":!0,"px-8":!0,"pb-8":!0,"w-full":!0,hidden:this.isOpen,flex:!this.isOpen,"md:px-0":!0,"md:pb-0":!0,"md:w-[350px]":!0,"md:flex":!0});return D`
52
52
  <div
53
53
  class=${e}
54
54
  >
@@ -73,7 +73,7 @@
73
73
  />
74
74
  </div>
75
75
  </div>
76
- `}toggleChat(){this.isOpen=!this.isOpen,this.onResizeHandler()}};Je.styles=[Ce],Rt([V({type:Object})],Je.prototype,"options",2),Rt([rt()],Je.prototype,"isOpen",2),Rt([Tn("iai-chat")],Je.prototype,"chatWindow",2),Rt([$s.debounce(250)],Je.prototype,"onResizeHandler",2),Je=Rt([$e("iai-chat-popup")],Je);const As="https://ai-dev.anyonehome.xyz";async function Ir(s,e={}){return await(await fetch(`${As}/threads`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({assistantId:s,params:e})})).json()}async function Mr(s,e){return await(await fetch(`${As}/threads/${s}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:e})})).json()}async function Nr(s,e,t,i=!1){return await(await fetch(`${As}/threads/${s}/functions/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({params:t,rerunLLM:i})})).json()}function Pr(s){return{all:s=s||new Map,on:function(e,t){var i=s.get(e);i?i.push(t):s.set(e,[t])},off:function(e,t){var i=s.get(e);i&&(t?i.splice(i.indexOf(t)>>>0,1):s.set(e,[]))},emit:function(e,t){var i=s.get(e);i&&i.slice().map(function(n){n(t)}),(i=s.get("*"))&&i.slice().map(function(n){n(e,t)})}}}class jr{constructor(e,t={}){if(this._assistantId="",this._conversationDetails=null,this._messages=[],this.isTyping=!1,this.inputDisabled=!1,this.chatEndingWarningSent=!1,this.chatEnded=!1,this.onStorageEvent=i=>{var n;const[r,a,o]=((n=i.key)==null?void 0:n.split("-"))||[];if(!(r!=="iaiChat"||a!==this.options.historyKey))switch(o){case"messageHistory":this.onMessageHistoryStorageEvent(i);break;case"conversation":this.setConversationDetails(JSON.parse(i.newValue||"null"),!0);break;case"lastActivity":this.keepAlive(JSON.parse(i.newValue||"null"),!0);break;case"chatEndingWarningSent":this.setChatEndingWarningSent(JSON.parse(i.newValue||"false"),!0);break;case"chatEnded":this.setChatEnded(JSON.parse(i.newValue||"false"),!0);break;case"typing":this.setTyping(JSON.parse(i.newValue||"false"),!0);break;case"inputDisabled":this.setInputDisabled(JSON.parse(i.newValue||"false"),!0);break}},this._assistantId=e,this.options={params:{},simulateDelays:!1,historyKey:"main",...t},this._emitter=Pr(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),t.events&&Object.entries(t.events).forEach(([i,n])=>{this._emitter.on(i,n)}),t.historyKey){this._messages=this.storageGet("messageHistory",[]);const i=this.storageGet("conversation");i&&this.setConversationDetails(i,!0);const n=this.storageGet("chatEndingWarningSent");n&&this.setChatEndingWarningSent(n,!0);const r=this.storageGet("chatEnded");r&&this.setChatEnded(r,!0);const a=this.storageGet("typing");a&&this.setTyping(a,!0);const o=this.storageGet("inputDisabled");o&&this.setInputDisabled(o,!0);const c=this.storageGet("lastActivity");c&&setTimeout(()=>this.keepAlive(c,!0),0),window.addEventListener("storage",this.onStorageEvent)}}onMessageHistoryStorageEvent(e){if(!e.newValue){this.reset();return}const t=JSON.parse(e.newValue),i=this._messages.map(r=>r.id),n=t.map(r=>r.id);this._messages.forEach(r=>{n.includes(r.id)||this._emitter.emit("messageRemoved",r.id)}),t.forEach(r=>{i.includes(r.id)||this._emitter.emit("message",r)}),this._messages=t}reset(){this._messages=[],this.setConversationDetails(null),this.setTyping(!1),this.setInputDisabled(!1),this.setChatEnded(!1),this.stopInactivityTimers(),this.storageRemoveAll(),this._emitter.emit("reset")}destroy(){this._emitter.all.clear(),window.removeEventListener("storage",this.onStorageEvent),this.stopInactivityTimers(),this._emitter.emit("destroy")}stopInactivityTimers(){this._inactivityTimeout&&(clearTimeout(this._inactivityTimeout),this._inactivityTimeout=null),this._inactivityWarningTimeout&&(clearTimeout(this._inactivityWarningTimeout),this._inactivityWarningTimeout=null)}keepAlive(e=Date.now(),t=!1){if(this.stopInactivityTimers(),this.chatEnded||!e)return;const{timeUntilChatEnds:i,timeUntilWarnAboutChatEnding:n}=this;if(!i)return;t||this.storageSet("lastActivity",e);const r=Date.now()-e;r>i?(this.chatEnded||this._emitter.emit("chatEnded"),this.setChatEnded(!0)):r>n?(this.sendChatEndingWarning(),this._inactivityTimeout=setTimeout(()=>{this.chatEnded||this._emitter.emit("chatEnded"),this.setChatEnded(!0)},i-r)):(this.setChatEndingWarningSent(!1),this._inactivityWarningTimeout=setTimeout(()=>this.sendChatEndingWarning(),n-r),this._inactivityTimeout=setTimeout(()=>{this.chatEnded||this._emitter.emit("chatEnded"),this.setChatEnded(!0)},i-r))}async startChat(){if(this.chatStarted)return;const{id:e,inactivityWaitTime:t,inactivityWarningTime:i}=await Ir(this.assistantId,this.params);if(!e)throw new Error("Could not start chat");this.setConversationDetails({threadId:e,inactivityWaitTime:t,inactivityWarningTime:i})}addMessage(e){const t={...e,id:e.id||Math.random().toString(36).substring(7)};return this._messages.push(t),this.storageSet("messageHistory",this._messages),this._emitter.emit("message",t),t}removeMessage(e){this._messages=this._messages.filter(t=>t.id!==e),this.storageSet("messageHistory",this._messages),this._emitter.emit("messageRemoved",e)}async respondToFunctionCall(e,t,i){this.simulateDelay(1800).then(()=>this.setTyping(!0));const n=this.simulateDelay(2e3);await this.insertMessagesWithSimulatedDelays(Promise.all([Nr(this.threadId,e,t,i),n]).then(([r])=>r))}async sendUserMessage(e){try{this.addMessage({role:"user",content:e}),this.simulateDelay(1800).then(()=>this._emitter.emit("typing",!0)),this.simulateDelay(1800).then(()=>this.setTyping(!0));let t=this.simulateDelay(4800);if(!this.chatStarted){const{initialReplyMessage:r}=this.options;r&&(this.simulateDelay(3800).then(()=>{this.addMessage({role:"assistant",content:r}),this.setTyping(!1)}),this.simulateDelay(6200).then(()=>this.setTyping(!0)),t=this.simulateDelay(8200)),await this.startChat()}this.keepAlive();const{messages:i,functions:n}=await this.insertMessagesWithSimulatedDelays(Promise.all([Mr(this.threadId,e),t]).then(([r])=>r));return{messages:i,functions:n}}catch(t){throw console.error(t),new Error("There was an error sending the message")}}setTyping(e,t=!1){this.isTyping=e,this._emitter.emit("typing",e),t||this.storageSet("typing",e)}setConversationDetails(e,t=!1){this._conversationDetails=e,t||this.storageSet("conversation",e)}setInputDisabled(e,t=!1){this.inputDisabled=e,this._emitter.emit("inputDisabled",e),t||this.storageSet("inputDisabled",e)}setChatEnded(e,t=!1){this.chatEnded=e,t||this.storageSet("chatEnded",e)}setChatEndingWarningSent(e,t=!1){this.chatEndingWarningSent=e,t||this.storageSet("chatEndingWarningSent",e)}sendChatEndingWarning(){this.chatEndingWarningSent||(this._emitter.emit("inactivityWarning"),this.setChatEndingWarningSent(!0))}async insertMessagesWithSimulatedDelays(e){this._emitter.emit("typing",!0);const t=await e;if(t.error)throw new Error(t.message);const{messages:i,functions:n}=t;return await Promise.all(i.map(async(r,a)=>(await this.simulateDelay(1e3*a),this.addMessage(r)))),this.setTyping(!1),n.forEach(r=>this._emitter.emit("functionCall",r)),{messages:i,functions:n}}simulateDelay(e){return this.options.simulateDelays?new Promise(t=>setTimeout(t,e)):Promise.resolve()}get assistantId(){return this._assistantId}get params(){return this.options.params}get threadId(){var e;return(e=this._conversationDetails)==null?void 0:e.threadId}get timeUntilChatEnds(){const{inactivityWaitTime:e}=this._conversationDetails||{};return e?e*60*1e3:null}get timeUntilWarnAboutChatEnding(){const{inactivityWaitTime:e=0,inactivityWarningTime:t=0}=this._conversationDetails||{};return(e-t)*60*1e3}get messages(){return this._messages}get chatStarted(){return!!this.threadId}storageSet(e,t){this.options.historyKey&&localStorage.setItem(`iaiChat-${this.options.historyKey}-${e}`,JSON.stringify(t))}storageGet(e,t=null){if(!this.options.historyKey)return null;const i=localStorage.getItem(`iaiChat-${this.options.historyKey}-${e}`);return i?JSON.parse(i):t}storageRemove(e){localStorage.removeItem(`iaiChat-${this.options.historyKey}-${e}`)}storageRemoveAll(){this.options.historyKey&&Object.keys(localStorage).forEach(e=>{e.startsWith(`iaiChat-${this.options.historyKey}-`)&&localStorage.removeItem(e)})}}function Rr(s){return{all:s=s||new Map,on:function(e,t){var i=s.get(e);i?i.push(t):s.set(e,[t])},off:function(e,t){var i=s.get(e);i&&(t?i.splice(i.indexOf(t)>>>0,1):s.set(e,[]))},emit:function(e,t){var i=s.get(e);i&&i.slice().map(function(n){n(t)}),(i=s.get("*"))&&i.slice().map(function(n){n(e,t)})}}}/**
76
+ `}toggleChat(){this.isOpen=!this.isOpen,this.onResizeHandler()}};Je.styles=[Ce],Rt([V({type:Object})],Je.prototype,"options",2),Rt([rt()],Je.prototype,"isOpen",2),Rt([Tn("iai-chat")],Je.prototype,"chatWindow",2),Rt([$s.debounce(250)],Je.prototype,"onResizeHandler",2),Je=Rt([$e("iai-chat-popup")],Je);const As="https://ai-dev.anyonehome.xyz";async function Ir(s,e={}){return await(await fetch(`${As}/threads`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({assistantId:s,params:e})})).json()}async function Mr(s,e){return await(await fetch(`${As}/threads/${s}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:e})})).json()}async function Nr(s,e,t,i=!1){return await(await fetch(`${As}/threads/${s}/functions/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({params:t,rerunLLM:i})})).json()}function Pr(s){return{all:s=s||new Map,on:function(e,t){var i=s.get(e);i?i.push(t):s.set(e,[t])},off:function(e,t){var i=s.get(e);i&&(t?i.splice(i.indexOf(t)>>>0,1):s.set(e,[]))},emit:function(e,t){var i=s.get(e);i&&i.slice().map(function(n){n(t)}),(i=s.get("*"))&&i.slice().map(function(n){n(e,t)})}}}class jr{constructor(e,t={}){if(this._assistantId="",this._conversationDetails=null,this._messages=[],this.isTyping=!1,this.inputDisabled=!1,this.chatEndingWarningSent=!1,this.chatEnded=!1,this.onStorageEvent=i=>{var n;const[r,a,o]=((n=i.key)==null?void 0:n.split("-"))||[];if(!(r!=="iaiChat"||a!==this.options.historyKey))switch(o){case"messageHistory":this.onMessageHistoryStorageEvent(i);break;case"conversation":this.setConversationDetails(JSON.parse(i.newValue||"null"),!0);break;case"lastActivity":this.keepAlive(JSON.parse(i.newValue||"null"),!0);break;case"chatEndingWarningSent":this.setChatEndingWarningSent(JSON.parse(i.newValue||"false"),!0);break;case"chatEnded":this.setChatEnded(JSON.parse(i.newValue||"false"),!0);break;case"typing":this.setTyping(JSON.parse(i.newValue||"false"),!0);break;case"inputDisabled":this.setInputDisabled(JSON.parse(i.newValue||"false"),!0);break}},this._assistantId=e,this.options={params:{},simulateDelays:!1,historyKey:"main",...t},this._emitter=Pr(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),t.events&&Object.entries(t.events).forEach(([i,n])=>{this._emitter.on(i,n)}),t.historyKey){this._messages=this.storageGet("messageHistory",[]);const i=this.storageGet("conversation");i&&this.setConversationDetails(i,!0);const n=this.storageGet("chatEndingWarningSent");n&&this.setChatEndingWarningSent(n,!0);const r=this.storageGet("chatEnded");r&&this.setChatEnded(r,!0);const a=this.storageGet("typing");a&&this.setTyping(a,!0);const o=this.storageGet("inputDisabled");o&&this.setInputDisabled(o,!0);const c=this.storageGet("lastActivity");c&&setTimeout(()=>this.keepAlive(c,!0),0),window.addEventListener("storage",this.onStorageEvent)}}onMessageHistoryStorageEvent(e){if(!e.newValue){this.reset();return}const t=JSON.parse(e.newValue),i=this._messages.map(r=>r.id),n=t.map(r=>r.id);this._messages.forEach(r=>{n.includes(r.id)||this._emitter.emit("messageRemoved",r.id)}),t.forEach(r=>{i.includes(r.id)||this._emitter.emit("message",r)}),this._messages=t}reset(){this._messages=[],this.setConversationDetails(null),this.setTyping(!1),this.setInputDisabled(!1),this.setChatEnded(!1),this.stopInactivityTimers(),this.storageRemoveAll(),this._emitter.emit("reset")}destroy(){this._emitter.all.clear(),window.removeEventListener("storage",this.onStorageEvent),this.stopInactivityTimers(),this._emitter.emit("destroy")}stopInactivityTimers(){this._inactivityTimeout&&(clearTimeout(this._inactivityTimeout),this._inactivityTimeout=null),this._inactivityWarningTimeout&&(clearTimeout(this._inactivityWarningTimeout),this._inactivityWarningTimeout=null)}keepAlive(e=Date.now(),t=!1){if(this.stopInactivityTimers(),this.chatEnded||!e)return;const{timeUntilChatEnds:i,timeUntilWarnAboutChatEnding:n}=this;if(!i)return;t||this.storageSet("lastActivity",e);const r=Date.now()-e;r>i?(this.chatEnded||this._emitter.emit("chatEnded"),this.setChatEnded(!0)):r>n?(this.sendChatEndingWarning(),this._inactivityTimeout=setTimeout(()=>{this.chatEnded||this._emitter.emit("chatEnded"),this.setChatEnded(!0)},i-r)):(this.setChatEndingWarningSent(!1),this._inactivityWarningTimeout=setTimeout(()=>this.sendChatEndingWarning(),n-r),this._inactivityTimeout=setTimeout(()=>{this.chatEnded||this._emitter.emit("chatEnded"),this.setChatEnded(!0)},i-r))}async startChat(){if(this.chatStarted)return;const{id:e,inactivityWaitTime:t,inactivityWarningTime:i}=await Ir(this.assistantId,this.params);if(!e)throw new Error("Could not start chat");this.setConversationDetails({threadId:e,inactivityWaitTime:t,inactivityWarningTime:i})}addMessage(e){const t={...e,id:e.id||Math.random().toString(36).substring(7)};return this._messages.push(t),this.storageSet("messageHistory",this._messages),this._emitter.emit("message",t),t}removeMessage(e){this._messages=this._messages.filter(t=>t.id!==e),this.storageSet("messageHistory",this._messages),this._emitter.emit("messageRemoved",e)}async respondToFunctionCall(e,t,i){this.simulateDelay(1800).then(()=>this.setTyping(!0));const n=this.simulateDelay(2e3);this.keepAlive(),await this.insertMessagesWithSimulatedDelays(Promise.all([Nr(this.threadId,e,t,i),n]).then(([r])=>r))}async sendUserMessage(e){try{this.addMessage({role:"user",content:e}),this.simulateDelay(1800).then(()=>this.setTyping(!0));let t=this.simulateDelay(4800);if(!this.chatStarted){const{initialReplyMessage:r}=this.options;r&&(this.simulateDelay(3800).then(()=>{this.addMessage({role:"assistant",content:r}),this.setTyping(!1)}),this.simulateDelay(6200).then(()=>this.setTyping(!0)),t=this.simulateDelay(8200)),await this.startChat()}this.keepAlive();const{messages:i,functions:n}=await this.insertMessagesWithSimulatedDelays(Promise.all([Mr(this.threadId,e),t]).then(([r])=>r));return{messages:i,functions:n}}catch(t){throw console.error(t),new Error("There was an error sending the message")}}setTyping(e,t=!1){this.isTyping=e,this._emitter.emit("typing",e),t||this.storageSet("typing",e)}setConversationDetails(e,t=!1){this._conversationDetails=e,t||this.storageSet("conversation",e)}setInputDisabled(e,t=!1){this.inputDisabled=e,this._emitter.emit("inputDisabled",e),t||this.storageSet("inputDisabled",e)}setChatEnded(e,t=!1){this.chatEnded=e,t||this.storageSet("chatEnded",e)}setChatEndingWarningSent(e,t=!1){this.chatEndingWarningSent=e,t||this.storageSet("chatEndingWarningSent",e)}sendChatEndingWarning(){this.chatEndingWarningSent||(this._emitter.emit("inactivityWarning"),this.setChatEndingWarningSent(!0))}async insertMessagesWithSimulatedDelays(e){const t=await e;if(t.error)throw new Error(t.message);const{messages:i,functions:n}=t;return await Promise.all(i.map(async(r,a)=>(await this.simulateDelay(1e3*a),this.addMessage(r)))),this.setTyping(!1),n.forEach(r=>this._emitter.emit("functionCall",r)),{messages:i,functions:n}}simulateDelay(e){return this.options.simulateDelays?new Promise(t=>setTimeout(t,e)):Promise.resolve()}get assistantId(){return this._assistantId}get params(){return this.options.params}get threadId(){var e;return(e=this._conversationDetails)==null?void 0:e.threadId}get timeUntilChatEnds(){const{inactivityWaitTime:e}=this._conversationDetails||{};return e?e*60*1e3:null}get timeUntilWarnAboutChatEnding(){const{inactivityWaitTime:e=0,inactivityWarningTime:t=0}=this._conversationDetails||{};return(e-t)*60*1e3}get messages(){return this._messages}get chatStarted(){return!!this.threadId}storageSet(e,t){this.options.historyKey&&localStorage.setItem(`iaiChat-${this.options.historyKey}-${e}`,JSON.stringify(t))}storageGet(e,t=null){if(!this.options.historyKey)return null;const i=localStorage.getItem(`iaiChat-${this.options.historyKey}-${e}`);return i?JSON.parse(i):t}storageRemove(e){localStorage.removeItem(`iaiChat-${this.options.historyKey}-${e}`)}storageRemoveAll(){this.options.historyKey&&Object.keys(localStorage).forEach(e=>{e.startsWith(`iaiChat-${this.options.historyKey}-`)&&localStorage.removeItem(e)})}}function Rr(s){return{all:s=s||new Map,on:function(e,t){var i=s.get(e);i?i.push(t):s.set(e,[t])},off:function(e,t){var i=s.get(e);i&&(t?i.splice(i.indexOf(t)>>>0,1):s.set(e,[]))},emit:function(e,t){var i=s.get(e);i&&i.slice().map(function(n){n(t)}),(i=s.get("*"))&&i.slice().map(function(n){n(e,t)})}}}/**
77
77
  * @license
78
78
  * Copyright 2021 Google LLC
79
79
  * SPDX-License-Identifier: BSD-3-Clause
@@ -131,7 +131,7 @@
131
131
  <title>refresh</title>
132
132
  <path d="M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z" />
133
133
  </svg>
134
- `;var Fr=Object.defineProperty,Vr=Object.getOwnPropertyDescriptor,be=(s,e,t,i)=>{for(var n=i>1?void 0:i?Vr(e,t):e,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Fr(e,t,n),n},Li=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},ut=(s,e,t)=>(Li(s,e,"read from private field"),t?t.call(s):e.get(s)),zi=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},Ui=(s,e,t,i)=>(Li(s,e,"write to private field"),i?i.call(s,t):e.set(s,t),t),Pe,ds;let oe=class extends se{constructor(){super(),zi(this,Pe,void 0),zi(this,ds,Promise.resolve()),this.disableInput=!1,this.showTyping=!1,this.messages=[],this.inputValue="",this.internalDisableInput=!1,this.internalShowTyping=!1,this._emitter=Rr(),this._emitter.on("*",(s,e)=>this.dispatchEvent(new CustomEvent(`iai-chat-${s.toString()}`,{bubbles:!0,composed:!0,detail:e})))}connectedCallback(){super.connectedCallback(),this.cleanOptions=as.parse(this.options||{});const{assistantId:s,params:e,config:t}=this.cleanOptions;Ui(this,Pe,new jr(s,{params:e,simulateDelays:!0,historyKey:t.historyKey,initialReplyMessage:t.initialReplyMessage})),this.updateMessages(ut(this,Pe).messages),this.showTyping=ut(this,Pe).isTyping,this.disableInput=ut(this,Pe).inputDisabled,this.chatManager.on("functionCall",({id:i,name:n,params:r})=>{const a=this.cleanOptions.handlers.functionCalls[n];if(!a){console.warn(`No function call handler found for ${n}`);return}a.call(this,{id:i,params:r,html:D,chatWindow:this})}),this.chatManager.on("typing",i=>{this.showTyping=i}),this.chatManager.on("inputDisabled",i=>{this.disableInput=i}),this.chatManager.on("inactivityWarning",()=>{this.addMessage({role:"assistant",content:t.inactivityWarningMessage})}),this.chatManager.on("chatEnded",()=>{this.addMessage({role:"system",content:t.chatEndedMessage}),this.setInputDisabled(!0)}),this.chatManager.on("message",i=>{this.updateMessages([...this.messages,i])}),this.chatManager.on("messageRemoved",i=>{this.updateMessages(this.messages.filter(n=>n.id!==i))}),this.chatManager.on("reset",()=>{this.updateMessages([])}),this.chatManager.on("*",this._emitter.emit)}disconnectedCallback(){super.disconnectedCallback(),this._emitter.all.clear(),ut(this,Pe).destroy()}firstUpdated(){this.focusOnInput()}updateMessages(s){this.messages=[...s],this.scrollChatToBottom()}render(){const{header:s,showCloseButton:e}=this.cleanOptions.config.chatWindow;return D`
134
+ `;var Fr=Object.defineProperty,Vr=Object.getOwnPropertyDescriptor,be=(s,e,t,i)=>{for(var n=i>1?void 0:i?Vr(e,t):e,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Fr(e,t,n),n},Li=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},ut=(s,e,t)=>(Li(s,e,"read from private field"),t?t.call(s):e.get(s)),zi=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},Ui=(s,e,t,i)=>(Li(s,e,"write to private field"),i?i.call(s,t):e.set(s,t),t),Pe,ds;let oe=class extends se{constructor(){super(),zi(this,Pe,void 0),zi(this,ds,Promise.resolve()),this.disableInput=!1,this.showTyping=!1,this.messages=[],this.inputValue="",this.internalDisableInput=!1,this.internalShowTyping=!1,this._emitter=Rr(),this._emitter.on("*",(s,e)=>this.dispatchEvent(new CustomEvent(`iai-chat-${s.toString()}`,{bubbles:!0,composed:!0,detail:e})))}connectedCallback(){super.connectedCallback(),this.cleanOptions=as.parse(this.options||{});const{assistantId:s,params:e,config:t}=this.cleanOptions;Ui(this,Pe,new jr(s,{params:e,simulateDelays:t.simulateDelays,historyKey:t.historyKey,initialReplyMessage:t.initialReplyMessage})),this.updateMessages(ut(this,Pe).messages),this.showTyping=ut(this,Pe).isTyping,this.disableInput=ut(this,Pe).inputDisabled,this.chatManager.on("functionCall",({id:i,name:n,params:r})=>{const a=this.cleanOptions.handlers.functionCalls[n];if(!a){console.warn(`No function call handler found for ${n}`);return}a.call(this,{id:i,params:r,html:D,chatWindow:this})}),this.chatManager.on("typing",i=>{this.showTyping=i}),this.chatManager.on("inputDisabled",i=>{this.disableInput=i}),this.chatManager.on("inactivityWarning",()=>{this.addMessage({role:"assistant",content:t.inactivityWarningMessage})}),this.chatManager.on("chatEnded",()=>{this.addMessage({role:"system",content:t.chatEndedMessage}),this.setInputDisabled(!0)}),this.chatManager.on("message",i=>{this.updateMessages([...this.messages,i])}),this.chatManager.on("messageRemoved",i=>{this.updateMessages(this.messages.filter(n=>n.id!==i))}),this.chatManager.on("reset",()=>{this.updateMessages([])}),this.chatManager.on("*",this._emitter.emit)}disconnectedCallback(){super.disconnectedCallback(),this._emitter.all.clear(),ut(this,Pe).destroy()}firstUpdated(){this.focusOnInput()}updateMessages(s){this.messages=[...s],this.scrollChatToBottom()}render(){const{header:s,showCloseButton:e}=this.cleanOptions.config.chatWindow;return D`
135
135
  <div class="flex flex-col h-full rounded-lg shadow-lg bg-white">
136
136
  <div class="header rounded-t-lg text-lg p-2 flex justify-between items-center">
137
137
  <div class="flex flex-row h-full items-center">
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@iai-lib/any-chat-widget",
3
3
  "license": "SEE LICENSE IN LICENSE.md",
4
- "version": "0.1.0-alpha.17",
4
+ "version": "0.1.0-alpha.19",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -11,8 +11,8 @@
11
11
  "dev:build": "vite build --watch",
12
12
  "dev:build:delayed": "delay 10 && yarn dev:build",
13
13
  "build": "vite build",
14
- "lint": "eslint \"src/**/*.{js}\"",
15
- "lint:fix": "npm run lint -- --fix"
14
+ "lint": "eslint . --ignore-path .gitignore",
15
+ "lint:fix": "yarn lint --fix"
16
16
  },
17
17
  "main": "./dist/any-chat-widget.umd.js",
18
18
  "module": "./dist/any-chat-widget.es.js",
@@ -34,8 +34,8 @@
34
34
  "vite-plugin-static-copy": "^1.0.1"
35
35
  },
36
36
  "dependencies": {
37
- "@iai-lib/chat-widget": "^1.0.0-alpha.23",
37
+ "@iai-lib/chat-widget": "^1.0.0-alpha.25",
38
38
  "mitt": "^3.0.1"
39
39
  },
40
- "gitHead": "a58ddd97d9946b1a7991339b7f5b0483121753d6"
40
+ "gitHead": "c8550da7db90249b275efa27e34ca130cacfeff7"
41
41
  }