@botpress/webchat 1.3.4 → 1.3.5

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.
@@ -468,7 +468,7 @@ ${d}`:d,{ast:c,isPatternProperty:!1,isRequired:(0,to.includes)(e.required||[],u)
468
468
  `.charCodeAt(0)||pn==="\r".charCodeAt(0))&&(At=On)}var Mn=(At!==-1?Rn:"")+St.slice(0,At+1);Rn=(At===-1?Rn:"")+St.slice(At+1),St!==""&&(J=Date.now(),fe+=St.length);for(var yn=0;yn<Mn.length;yn+=1){var pn=Mn.charCodeAt(yn);if(Fn===I&&pn===`
469
469
  `.charCodeAt(0))Fn=le;else if(Fn===I&&(Fn=le),pn==="\r".charCodeAt(0)||pn===`
470
470
  `.charCodeAt(0)){if(Fn!==le){Fn===De&&(D=yn+1);var wr=Mn.slice(Ni,D-1),Pr=Mn.slice(D+(D<yn&&Mn.charCodeAt(D)===" ".charCodeAt(0)?1:0),yn);wr==="data"?(Hn+=`
471
- `,Hn+=Pr):wr==="id"?gn=Pr:wr==="event"?Cn=Pr:wr==="retry"?(Be=pt(Pr,Be),vt=Be):wr==="heartbeatTimeout"&&(st=pt(Pr,st),Xt!==0&&(i(Xt),Xt=r(function(){rt()},st)))}if(Fn===le){if(Hn!==""){Mt=gn,Cn===""&&(Cn="message");var fo=new Y(Cn,{data:Hn.slice(1),lastEventId:gn});if(Z.dispatchEvent(fo),Cn==="open"?Le(Z,Z.onopen,fo):Cn==="message"?Le(Z,Z.onmessage,fo):Cn==="error"&&Le(Z,Z.onerror,fo),xn===ke)return}Hn="",Cn=""}Fn=pn==="\r".charCodeAt(0)?I:le}else Fn===le&&(Ni=yn,Fn=De),Fn===De?pn===":".charCodeAt(0)&&(D=yn+1,Fn=M):Fn===M&&(Fn=Fe)}}},Et=function(St){if(xn===ie||xn===ae){xn=Q,Xt!==0&&(i(Xt),Xt=0),Xt=r(function(){rt()},vt),vt=at(Math.min(Be*16,vt*2)),Z.readyState=ae;var At=new K("error",{error:St});Z.dispatchEvent(At),Le(Z,Z.onerror,At),St!=null&&console.error(St)}},it=function(){xn=ke,rn!=null&&(rn.abort(),rn=void 0),Xt!==0&&(i(Xt),Xt=0),Z.readyState=ke},rt=function(){if(Xt=0,xn!==Q){if(!J&&rn!=null)Et(new Error("No activity within "+st+" milliseconds. "+(xn===ae?"No response received.":fe+" chars received.")+" Reconnecting.")),rn!=null&&(rn.abort(),rn=void 0);else{var St=Math.max((J||Date.now())+st-Date.now(),1);J=!1,Xt=r(function(){rt()},St)}return}J=!1,fe=0,Xt=r(function(){rt()},st),xn=ae,Hn="",Cn="",gn=Mt,Rn="",Ni=0,D=0,Fn=le;var At=pe;if(pe.slice(0,5)!=="data:"&&pe.slice(0,5)!=="blob:"&&Mt!==""){var On=pe.indexOf("?");At=On===-1?pe:pe.slice(0,On+1)+pe.slice(On+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,function(Pr,fo){return fo===tt?"":Pr}),At+=(pe.indexOf("?")===-1?"?":"&")+tt+"="+encodeURIComponent(Mt)}var pn=Z.withCredentials,Mn={};Mn.Accept="text/event-stream";var yn=Z.headers;if(yn!=null)for(var wr in yn)Object.prototype.hasOwnProperty.call(yn,wr)&&(Mn[wr]=yn[wr]);try{rn=dn.open(bt,Ue,Ye,Et,At,pn,Mn)}catch(Pr){throw it(),Pr}};Z.url=pe,Z.readyState=ae,Z.withCredentials=Te,Z.headers=Ce,Z._close=it,rt()}Ie.prototype=Object.create($.prototype),Ie.prototype.CONNECTING=ae,Ie.prototype.OPEN=ie,Ie.prototype.CLOSED=ke,Ie.prototype.close=function(){this._close()},Ie.CONNECTING=ae,Ie.OPEN=ie,Ie.CLOSED=ke,Ie.prototype.withCredentials=void 0;var ht=u;o!=null&&(u==null||!("withCredentials"in u.prototype))&&(ht=Ie),function(Z){{var pe=Z(t);pe!==void 0&&(e.exports=pe)}}(function(Z){Z.EventSourcePolyfill=Ie,Z.NativeEventSource=u,Z.EventSource=ht})})(typeof globalThis>"u"?typeof window<"u"?window:typeof self<"u"?self:re:globalThis)})(P_,P_.exports);var Wfe=P_.exports;const Hfe=ta(Wfe),Vfe=(e,t={})=>{const n=new Hfe.EventSourcePolyfill(e,{headers:t.headers}),r=new zM;return n.onopen=i=>r.emit("open",i),n.onmessage=i=>r.emit("message",i),n.onerror=i=>r.emit("error",i),{emitter:r,source:n}},Kfe=async(e,t={})=>{const{emitter:n,source:r}=Vfe(e,t);return await new Promise((i,o)=>{n.on("open",()=>{i()}),n.on("error",a=>{o(a)})}).finally(()=>n.cleanup()),{on:n.on.bind(n),close:()=>{n.cleanup(),r.close()}}};var nn;(function(e){e.assertEqual=i=>i;function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const o={};for(const a of i)o[a]=a;return o},e.getValidEnumValues=i=>{const o=e.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),a={};for(const s of o)a[s]=i[s];return e.objectValues(a)},e.objectValues=i=>e.objectKeys(i).map(function(o){return i[o]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const o=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&o.push(a);return o},e.find=(i,o)=>{for(const a of i)if(o(a))return a},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function r(i,o=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}e.joinValues=r,e.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(nn||(nn={}));var I_;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(I_||(I_={}));const Je=nn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Pa=e=>{switch(typeof e){case"undefined":return Je.undefined;case"string":return Je.string;case"number":return isNaN(e)?Je.nan:Je.number;case"boolean":return Je.boolean;case"function":return Je.function;case"bigint":return Je.bigint;case"symbol":return Je.symbol;case"object":return Array.isArray(e)?Je.array:e===null?Je.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Je.promise:typeof Map<"u"&&e instanceof Map?Je.map:typeof Set<"u"&&e instanceof Set?Je.set:typeof Date<"u"&&e instanceof Date?Je.date:Je.object;default:return Je.unknown}},Ne=nn.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"]),Gfe=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class Ii extends Error{constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}get errors(){return this.issues}format(t){const n=t||function(o){return o.message},r={_errors:[]},i=o=>{for(const a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let s=r,u=0;for(;u<a.path.length;){const c=a.path[u];u===a.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(n(a))):s[c]=s[c]||{_errors:[]},s=s[c],u++}}};return i(this),r}toString(){return this.message}get message(){return JSON.stringify(this.issues,nn.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const i of this.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Ii.create=e=>new Ii(e);const _f=(e,t)=>{let n;switch(e.code){case Ne.invalid_type:e.received===Je.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Ne.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,nn.jsonStringifyReplacer)}`;break;case Ne.unrecognized_keys:n=`Unrecognized key(s) in object: ${nn.joinValues(e.keys,", ")}`;break;case Ne.invalid_union:n="Invalid input";break;case Ne.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${nn.joinValues(e.options)}`;break;case Ne.invalid_enum_value:n=`Invalid enum value. Expected ${nn.joinValues(e.options)}, received '${e.received}'`;break;case Ne.invalid_arguments:n="Invalid function arguments";break;case Ne.invalid_return_type:n="Invalid function return type";break;case Ne.invalid_date:n="Invalid date";break;case Ne.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:nn.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case Ne.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case Ne.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case Ne.custom:n="Invalid input";break;case Ne.invalid_intersection_types:n="Intersection results could not be merged";break;case Ne.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Ne.not_finite:n="Number must be finite";break;default:n=t.defaultError,nn.assertNever(e)}return{message:n}};let qM=_f;function Yfe(e){qM=e}function Pm(){return qM}const Im=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,o=[...n,...i.path||[]],a={...i,path:o};let s="";const u=r.filter(c=>!!c).slice().reverse();for(const c of u)s=c(a,{data:t,defaultError:s}).message;return{...i,path:o,message:i.message||s}},Jfe=[];function Qe(e,t){const n=Im({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,Pm(),_f].filter(r=>!!r)});e.common.issues.push(n)}class _r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const i of n){if(i.status==="aborted")return Pt;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const i of n)r.push({key:await i.key,value:await i.value});return _r.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const i of n){const{key:o,value:a}=i;if(o.status==="aborted"||a.status==="aborted")return Pt;o.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(r[o.value]=a.value)}return{status:t.value,value:r}}}const Pt=Object.freeze({status:"aborted"}),ZM=e=>({status:"dirty",value:e}),Ar=e=>({status:"valid",value:e}),$_=e=>e.status==="aborted",R_=e=>e.status==="dirty",wf=e=>e.status==="valid",$m=e=>typeof Promise<"u"&&e instanceof Promise;var ft;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(ft||(ft={}));class uo{constructor(t,n,r,i){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=i}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 WM=(e,t)=>{if(wf(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ii(e.common.issues);return this._error=n,this._error}}};function Rt(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(a,s)=>a.code!=="invalid_type"?{message:s.defaultError}:typeof s.data>"u"?{message:r??s.defaultError}:{message:n??s.defaultError},description:i}}class jt{constructor(t){this.spa=this.safeParseAsync,this._def=t,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(t){return Pa(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Pa(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new _r,ctx:{common:t.parent.common,data:t.data,parsedType:Pa(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if($m(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){var r;const i={common:{issues:[],async:(r=n==null?void 0:n.async)!==null&&r!==void 0?r:!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Pa(t)},o=this._parseSync({data:t,path:i.path,parent:i});return WM(i,o)}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Pa(t)},i=this._parse({data:t,path:r.path,parent:r}),o=await($m(i)?i:Promise.resolve(i));return WM(r,o)}refine(t,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,o)=>{const a=t(i),s=()=>o.addIssue({code:Ne.custom,...r(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(u=>u?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(t,n){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(t){return new Mi({schema:this,typeName:xt.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}optional(){return qo.create(this,this._def)}nullable(){return Is.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ri.create(this,this._def)}promise(){return iu.create(this,this._def)}or(t){return Cf.create([this,t],this._def)}and(t){return Of.create(this,t,this._def)}transform(t){return new Mi({...Rt(this._def),schema:this,typeName:xt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new If({...Rt(this._def),innerType:this,defaultValue:n,typeName:xt.ZodDefault})}brand(){return new VM({typeName:xt.ZodBranded,type:this,...Rt(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new jm({...Rt(this._def),innerType:this,catchValue:n,typeName:xt.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return $f.create(this,t)}readonly(){return Um.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Qfe=/^c[^\s-]{8,}$/i,Xfe=/^[a-z][a-z0-9]*$/,ede=/^[0-9A-HJKMNP-TV-Z]{26}$/,tde=/^[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,nde=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,rde="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let M_;const ide=/^(((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}))$/,ode=/^(([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})))$/,ade=e=>e.precision?e.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${e.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${e.precision}}Z$`):e.precision===0?e.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$"):e.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 sde(e,t){return!!((t==="v4"||!t)&&ide.test(e)||(t==="v6"||!t)&&ode.test(e))}class $i extends jt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Je.string){const o=this._getOrReturnCtx(t);return Qe(o,{code:Ne.invalid_type,expected:Je.string,received:o.parsedType}),Pt}const r=new _r;let i;for(const o of this._def.checks)if(o.kind==="min")t.data.length<o.value&&(i=this._getOrReturnCtx(t,i),Qe(i,{code:Ne.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="max")t.data.length>o.value&&(i=this._getOrReturnCtx(t,i),Qe(i,{code:Ne.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="length"){const a=t.data.length>o.value,s=t.data.length<o.value;(a||s)&&(i=this._getOrReturnCtx(t,i),a?Qe(i,{code:Ne.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):s&&Qe(i,{code:Ne.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),r.dirty())}else if(o.kind==="email")nde.test(t.data)||(i=this._getOrReturnCtx(t,i),Qe(i,{validation:"email",code:Ne.invalid_string,message:o.message}),r.dirty());else if(o.kind==="emoji")M_||(M_=new RegExp(rde,"u")),M_.test(t.data)||(i=this._getOrReturnCtx(t,i),Qe(i,{validation:"emoji",code:Ne.invalid_string,message:o.message}),r.dirty());else if(o.kind==="uuid")tde.test(t.data)||(i=this._getOrReturnCtx(t,i),Qe(i,{validation:"uuid",code:Ne.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid")Qfe.test(t.data)||(i=this._getOrReturnCtx(t,i),Qe(i,{validation:"cuid",code:Ne.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid2")Xfe.test(t.data)||(i=this._getOrReturnCtx(t,i),Qe(i,{validation:"cuid2",code:Ne.invalid_string,message:o.message}),r.dirty());else if(o.kind==="ulid")ede.test(t.data)||(i=this._getOrReturnCtx(t,i),Qe(i,{validation:"ulid",code:Ne.invalid_string,message:o.message}),r.dirty());else if(o.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),Qe(i,{validation:"url",code:Ne.invalid_string,message:o.message}),r.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),Qe(i,{validation:"regex",code:Ne.invalid_string,message:o.message}),r.dirty())):o.kind==="trim"?t.data=t.data.trim():o.kind==="includes"?t.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(t,i),Qe(i,{code:Ne.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),r.dirty()):o.kind==="toLowerCase"?t.data=t.data.toLowerCase():o.kind==="toUpperCase"?t.data=t.data.toUpperCase():o.kind==="startsWith"?t.data.startsWith(o.value)||(i=this._getOrReturnCtx(t,i),Qe(i,{code:Ne.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()):o.kind==="endsWith"?t.data.endsWith(o.value)||(i=this._getOrReturnCtx(t,i),Qe(i,{code:Ne.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()):o.kind==="datetime"?ade(o).test(t.data)||(i=this._getOrReturnCtx(t,i),Qe(i,{code:Ne.invalid_string,validation:"datetime",message:o.message}),r.dirty()):o.kind==="ip"?sde(t.data,o.version)||(i=this._getOrReturnCtx(t,i),Qe(i,{validation:"ip",code:Ne.invalid_string,message:o.message}),r.dirty()):nn.assertNever(o);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:Ne.invalid_string,...ft.errToObj(r)})}_addCheck(t){return new $i({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...ft.errToObj(t)})}url(t){return this._addCheck({kind:"url",...ft.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...ft.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...ft.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...ft.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...ft.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...ft.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...ft.errToObj(t)})}datetime(t){var n;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(n=t==null?void 0:t.offset)!==null&&n!==void 0?n:!1,...ft.errToObj(t==null?void 0:t.message)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...ft.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...ft.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...ft.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...ft.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...ft.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...ft.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...ft.errToObj(n)})}nonempty(t){return this.min(1,ft.errToObj(t))}trim(){return new $i({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new $i({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new $i({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}$i.create=e=>{var t;return new $i({checks:[],typeName:xt.ZodString,coerce:(t=e==null?void 0:e.coerce)!==null&&t!==void 0?t:!1,...Rt(e)})};function lde(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,o=parseInt(e.toFixed(i).replace(".","")),a=parseInt(t.toFixed(i).replace(".",""));return o%a/Math.pow(10,i)}class Ia extends jt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Je.number){const o=this._getOrReturnCtx(t);return Qe(o,{code:Ne.invalid_type,expected:Je.number,received:o.parsedType}),Pt}let r;const i=new _r;for(const o of this._def.checks)o.kind==="int"?nn.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),Qe(r,{code:Ne.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(r=this._getOrReturnCtx(t,r),Qe(r,{code:Ne.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(r=this._getOrReturnCtx(t,r),Qe(r,{code:Ne.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?lde(t.data,o.value)!==0&&(r=this._getOrReturnCtx(t,r),Qe(r,{code:Ne.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),Qe(r,{code:Ne.not_finite,message:o.message}),i.dirty()):nn.assertNever(o);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,ft.toString(n))}gt(t,n){return this.setLimit("min",t,!1,ft.toString(n))}lte(t,n){return this.setLimit("max",t,!0,ft.toString(n))}lt(t,n){return this.setLimit("max",t,!1,ft.toString(n))}setLimit(t,n,r,i){return new Ia({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ft.toString(i)}]})}_addCheck(t){return new Ia({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:ft.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ft.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ft.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ft.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ft.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:ft.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:ft.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ft.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ft.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&nn.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Ia.create=e=>new Ia({checks:[],typeName:xt.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Rt(e)});class $a extends jt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce&&(t.data=BigInt(t.data)),this._getType(t)!==Je.bigint){const o=this._getOrReturnCtx(t);return Qe(o,{code:Ne.invalid_type,expected:Je.bigint,received:o.parsedType}),Pt}let r;const i=new _r;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(r=this._getOrReturnCtx(t,r),Qe(r,{code:Ne.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(r=this._getOrReturnCtx(t,r),Qe(r,{code:Ne.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),Qe(r,{code:Ne.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):nn.assertNever(o);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,ft.toString(n))}gt(t,n){return this.setLimit("min",t,!1,ft.toString(n))}lte(t,n){return this.setLimit("max",t,!0,ft.toString(n))}lt(t,n){return this.setLimit("max",t,!1,ft.toString(n))}setLimit(t,n,r,i){return new $a({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ft.toString(i)}]})}_addCheck(t){return new $a({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ft.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ft.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ft.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ft.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:ft.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}$a.create=e=>{var t;return new $a({checks:[],typeName:xt.ZodBigInt,coerce:(t=e==null?void 0:e.coerce)!==null&&t!==void 0?t:!1,...Rt(e)})};class xf extends jt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Je.boolean){const r=this._getOrReturnCtx(t);return Qe(r,{code:Ne.invalid_type,expected:Je.boolean,received:r.parsedType}),Pt}return Ar(t.data)}}xf.create=e=>new xf({typeName:xt.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Rt(e)});class ks extends jt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Je.date){const o=this._getOrReturnCtx(t);return Qe(o,{code:Ne.invalid_type,expected:Je.date,received:o.parsedType}),Pt}if(isNaN(t.data.getTime())){const o=this._getOrReturnCtx(t);return Qe(o,{code:Ne.invalid_date}),Pt}const r=new _r;let i;for(const o of this._def.checks)o.kind==="min"?t.data.getTime()<o.value&&(i=this._getOrReturnCtx(t,i),Qe(i,{code:Ne.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),r.dirty()):o.kind==="max"?t.data.getTime()>o.value&&(i=this._getOrReturnCtx(t,i),Qe(i,{code:Ne.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):nn.assertNever(o);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new ks({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:ft.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:ft.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}ks.create=e=>new ks({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:xt.ZodDate,...Rt(e)});class Rm extends jt{_parse(t){if(this._getType(t)!==Je.symbol){const r=this._getOrReturnCtx(t);return Qe(r,{code:Ne.invalid_type,expected:Je.symbol,received:r.parsedType}),Pt}return Ar(t.data)}}Rm.create=e=>new Rm({typeName:xt.ZodSymbol,...Rt(e)});class Sf extends jt{_parse(t){if(this._getType(t)!==Je.undefined){const r=this._getOrReturnCtx(t);return Qe(r,{code:Ne.invalid_type,expected:Je.undefined,received:r.parsedType}),Pt}return Ar(t.data)}}Sf.create=e=>new Sf({typeName:xt.ZodUndefined,...Rt(e)});class Ef extends jt{_parse(t){if(this._getType(t)!==Je.null){const r=this._getOrReturnCtx(t);return Qe(r,{code:Ne.invalid_type,expected:Je.null,received:r.parsedType}),Pt}return Ar(t.data)}}Ef.create=e=>new Ef({typeName:xt.ZodNull,...Rt(e)});class tu extends jt{constructor(){super(...arguments),this._any=!0}_parse(t){return Ar(t.data)}}tu.create=e=>new tu({typeName:xt.ZodAny,...Rt(e)});class As extends jt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Ar(t.data)}}As.create=e=>new As({typeName:xt.ZodUnknown,...Rt(e)});class zo extends jt{_parse(t){const n=this._getOrReturnCtx(t);return Qe(n,{code:Ne.invalid_type,expected:Je.never,received:n.parsedType}),Pt}}zo.create=e=>new zo({typeName:xt.ZodNever,...Rt(e)});class Mm extends jt{_parse(t){if(this._getType(t)!==Je.undefined){const r=this._getOrReturnCtx(t);return Qe(r,{code:Ne.invalid_type,expected:Je.void,received:r.parsedType}),Pt}return Ar(t.data)}}Mm.create=e=>new Mm({typeName:xt.ZodVoid,...Rt(e)});class Ri extends jt{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==Je.array)return Qe(n,{code:Ne.invalid_type,expected:Je.array,received:n.parsedType}),Pt;if(i.exactLength!==null){const a=n.data.length>i.exactLength.value,s=n.data.length<i.exactLength.value;(a||s)&&(Qe(n,{code:a?Ne.too_big:Ne.too_small,minimum:s?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(Qe(n,{code:Ne.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(Qe(n,{code:Ne.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,s)=>i.type._parseAsync(new uo(n,a,n.path,s)))).then(a=>_r.mergeArray(r,a));const o=[...n.data].map((a,s)=>i.type._parseSync(new uo(n,a,n.path,s)));return _r.mergeArray(r,o)}get element(){return this._def.type}min(t,n){return new Ri({...this._def,minLength:{value:t,message:ft.toString(n)}})}max(t,n){return new Ri({...this._def,maxLength:{value:t,message:ft.toString(n)}})}length(t,n){return new Ri({...this._def,exactLength:{value:t,message:ft.toString(n)}})}nonempty(t){return this.min(1,t)}}Ri.create=(e,t)=>new Ri({type:e,minLength:null,maxLength:null,exactLength:null,typeName:xt.ZodArray,...Rt(t)});function nu(e){if(e instanceof An){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=qo.create(nu(r))}return new An({...e._def,shape:()=>t})}else return e instanceof Ri?new Ri({...e._def,type:nu(e.element)}):e instanceof qo?qo.create(nu(e.unwrap())):e instanceof Is?Is.create(nu(e.unwrap())):e instanceof co?co.create(e.items.map(t=>nu(t))):e}class An extends jt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=nn.objectKeys(t);return this._cached={shape:t,keys:n}}_parse(t){if(this._getType(t)!==Je.object){const c=this._getOrReturnCtx(t);return Qe(c,{code:Ne.invalid_type,expected:Je.object,received:c.parsedType}),Pt}const{status:r,ctx:i}=this._processInputParams(t),{shape:o,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof zo&&this._def.unknownKeys==="strip"))for(const c in i.data)a.includes(c)||s.push(c);const u=[];for(const c of a){const d=o[c],p=i.data[c];u.push({key:{status:"valid",value:c},value:d._parse(new uo(i,p,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof zo){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of s)u.push({key:{status:"valid",value:d},value:{status:"valid",value:i.data[d]}});else if(c==="strict")s.length>0&&(Qe(i,{code:Ne.unrecognized_keys,keys:s}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of s){const p=i.data[d];u.push({key:{status:"valid",value:d},value:c._parse(new uo(i,p,i.path,d)),alwaysSet:d in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of u){const p=await d.key;c.push({key:p,value:await d.value,alwaysSet:d.alwaysSet})}return c}).then(c=>_r.mergeObjectSync(r,c)):_r.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(t){return ft.errToObj,new An({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var i,o,a,s;const u=(a=(o=(i=this._def).errorMap)===null||o===void 0?void 0:o.call(i,n,r).message)!==null&&a!==void 0?a:r.defaultError;return n.code==="unrecognized_keys"?{message:(s=ft.errToObj(t).message)!==null&&s!==void 0?s:u}:{message:u}}}:{}})}strip(){return new An({...this._def,unknownKeys:"strip"})}passthrough(){return new An({...this._def,unknownKeys:"passthrough"})}extend(t){return new An({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new An({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:xt.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new An({...this._def,catchall:t})}pick(t){const n={};return nn.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new An({...this._def,shape:()=>n})}omit(t){const n={};return nn.objectKeys(this.shape).forEach(r=>{t[r]||(n[r]=this.shape[r])}),new An({...this._def,shape:()=>n})}deepPartial(){return nu(this)}partial(t){const n={};return nn.objectKeys(this.shape).forEach(r=>{const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}),new An({...this._def,shape:()=>n})}required(t){const n={};return nn.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])n[r]=this.shape[r];else{let o=this.shape[r];for(;o instanceof qo;)o=o._def.innerType;n[r]=o}}),new An({...this._def,shape:()=>n})}keyof(){return HM(nn.objectKeys(this.shape))}}An.create=(e,t)=>new An({shape:()=>e,unknownKeys:"strip",catchall:zo.create(),typeName:xt.ZodObject,...Rt(t)}),An.strictCreate=(e,t)=>new An({shape:()=>e,unknownKeys:"strict",catchall:zo.create(),typeName:xt.ZodObject,...Rt(t)}),An.lazycreate=(e,t)=>new An({shape:e,unknownKeys:"strip",catchall:zo.create(),typeName:xt.ZodObject,...Rt(t)});class Cf extends jt{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function i(o){for(const s of o)if(s.result.status==="valid")return s.result;for(const s of o)if(s.result.status==="dirty")return n.common.issues.push(...s.ctx.common.issues),s.result;const a=o.map(s=>new Ii(s.ctx.common.issues));return Qe(n,{code:Ne.invalid_union,unionErrors:a}),Pt}if(n.common.async)return Promise.all(r.map(async o=>{const a={...n,common:{...n.common,issues:[]},parent:null};return{result:await o._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(i);{let o;const a=[];for(const u of r){const c={...n,common:{...n.common,issues:[]},parent:null},d=u._parseSync({data:n.data,path:n.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!o&&(o={result:d,ctx:c}),c.common.issues.length&&a.push(c.common.issues)}if(o)return n.common.issues.push(...o.ctx.common.issues),o.result;const s=a.map(u=>new Ii(u));return Qe(n,{code:Ne.invalid_union,unionErrors:s}),Pt}}get options(){return this._def.options}}Cf.create=(e,t)=>new Cf({options:e,typeName:xt.ZodUnion,...Rt(t)});const Nm=e=>e instanceof kf?Nm(e.schema):e instanceof Mi?Nm(e.innerType()):e instanceof Af?[e.value]:e instanceof Ra?e.options:e instanceof Pf?Object.keys(e.enum):e instanceof If?Nm(e._def.innerType):e instanceof Sf?[void 0]:e instanceof Ef?[null]:null;class Dm extends jt{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Je.object)return Qe(n,{code:Ne.invalid_type,expected:Je.object,received:n.parsedType}),Pt;const r=this.discriminator,i=n.data[r],o=this.optionsMap.get(i);return o?n.common.async?o._parseAsync({data:n.data,path:n.path,parent:n}):o._parseSync({data:n.data,path:n.path,parent:n}):(Qe(n,{code:Ne.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Pt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const i=new Map;for(const o of n){const a=Nm(o.shape[t]);if(!a)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const s of a){if(i.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);i.set(s,o)}}return new Dm({typeName:xt.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Rt(r)})}}function N_(e,t){const n=Pa(e),r=Pa(t);if(e===t)return{valid:!0,data:e};if(n===Je.object&&r===Je.object){const i=nn.objectKeys(t),o=nn.objectKeys(e).filter(s=>i.indexOf(s)!==-1),a={...e,...t};for(const s of o){const u=N_(e[s],t[s]);if(!u.valid)return{valid:!1};a[s]=u.data}return{valid:!0,data:a}}else if(n===Je.array&&r===Je.array){if(e.length!==t.length)return{valid:!1};const i=[];for(let o=0;o<e.length;o++){const a=e[o],s=t[o],u=N_(a,s);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return n===Je.date&&r===Je.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Of extends jt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(o,a)=>{if($_(o)||$_(a))return Pt;const s=N_(o.value,a.value);return s.valid?((R_(o)||R_(a))&&n.dirty(),{status:n.value,value:s.data}):(Qe(r,{code:Ne.invalid_intersection_types}),Pt)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,a])=>i(o,a)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Of.create=(e,t,n)=>new Of({left:e,right:t,typeName:xt.ZodIntersection,...Rt(n)});class co extends jt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Je.array)return Qe(r,{code:Ne.invalid_type,expected:Je.array,received:r.parsedType}),Pt;if(r.data.length<this._def.items.length)return Qe(r,{code:Ne.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Pt;!this._def.rest&&r.data.length>this._def.items.length&&(Qe(r,{code:Ne.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const o=[...r.data].map((a,s)=>{const u=this._def.items[s]||this._def.rest;return u?u._parse(new uo(r,a,r.path,s)):null}).filter(a=>!!a);return r.common.async?Promise.all(o).then(a=>_r.mergeArray(n,a)):_r.mergeArray(n,o)}get items(){return this._def.items}rest(t){return new co({...this._def,rest:t})}}co.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new co({items:e,typeName:xt.ZodTuple,rest:null,...Rt(t)})};class Tf extends jt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Je.object)return Qe(r,{code:Ne.invalid_type,expected:Je.object,received:r.parsedType}),Pt;const i=[],o=this._def.keyType,a=this._def.valueType;for(const s in r.data)i.push({key:o._parse(new uo(r,s,r.path,s)),value:a._parse(new uo(r,r.data[s],r.path,s))});return r.common.async?_r.mergeObjectAsync(n,i):_r.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof jt?new Tf({keyType:t,valueType:n,typeName:xt.ZodRecord,...Rt(r)}):new Tf({keyType:$i.create(),valueType:t,typeName:xt.ZodRecord,...Rt(n)})}}class Lm extends jt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Je.map)return Qe(r,{code:Ne.invalid_type,expected:Je.map,received:r.parsedType}),Pt;const i=this._def.keyType,o=this._def.valueType,a=[...r.data.entries()].map(([s,u],c)=>({key:i._parse(new uo(r,s,r.path,[c,"key"])),value:o._parse(new uo(r,u,r.path,[c,"value"]))}));if(r.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const u of a){const c=await u.key,d=await u.value;if(c.status==="aborted"||d.status==="aborted")return Pt;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),s.set(c.value,d.value)}return{status:n.value,value:s}})}else{const s=new Map;for(const u of a){const c=u.key,d=u.value;if(c.status==="aborted"||d.status==="aborted")return Pt;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),s.set(c.value,d.value)}return{status:n.value,value:s}}}}Lm.create=(e,t,n)=>new Lm({valueType:t,keyType:e,typeName:xt.ZodMap,...Rt(n)});class Ps extends jt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Je.set)return Qe(r,{code:Ne.invalid_type,expected:Je.set,received:r.parsedType}),Pt;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(Qe(r,{code:Ne.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(Qe(r,{code:Ne.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const o=this._def.valueType;function a(u){const c=new Set;for(const d of u){if(d.status==="aborted")return Pt;d.status==="dirty"&&n.dirty(),c.add(d.value)}return{status:n.value,value:c}}const s=[...r.data.values()].map((u,c)=>o._parse(new uo(r,u,r.path,c)));return r.common.async?Promise.all(s).then(u=>a(u)):a(s)}min(t,n){return new Ps({...this._def,minSize:{value:t,message:ft.toString(n)}})}max(t,n){return new Ps({...this._def,maxSize:{value:t,message:ft.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Ps.create=(e,t)=>new Ps({valueType:e,minSize:null,maxSize:null,typeName:xt.ZodSet,...Rt(t)});class ru extends jt{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Je.function)return Qe(n,{code:Ne.invalid_type,expected:Je.function,received:n.parsedType}),Pt;function r(s,u){return Im({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Pm(),_f].filter(c=>!!c),issueData:{code:Ne.invalid_arguments,argumentsError:u}})}function i(s,u){return Im({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Pm(),_f].filter(c=>!!c),issueData:{code:Ne.invalid_return_type,returnTypeError:u}})}const o={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof iu){const s=this;return Ar(async function(...u){const c=new Ii([]),d=await s._def.args.parseAsync(u,o).catch(h=>{throw c.addIssue(r(u,h)),c}),p=await Reflect.apply(a,this,d);return await s._def.returns._def.type.parseAsync(p,o).catch(h=>{throw c.addIssue(i(p,h)),c})})}else{const s=this;return Ar(function(...u){const c=s._def.args.safeParse(u,o);if(!c.success)throw new Ii([r(u,c.error)]);const d=Reflect.apply(a,this,c.data),p=s._def.returns.safeParse(d,o);if(!p.success)throw new Ii([i(d,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new ru({...this._def,args:co.create(t).rest(As.create())})}returns(t){return new ru({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new ru({args:t||co.create([]).rest(As.create()),returns:n||As.create(),typeName:xt.ZodFunction,...Rt(r)})}}class kf extends jt{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}kf.create=(e,t)=>new kf({getter:e,typeName:xt.ZodLazy,...Rt(t)});class Af extends jt{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return Qe(n,{received:n.data,code:Ne.invalid_literal,expected:this._def.value}),Pt}return{status:"valid",value:t.data}}get value(){return this._def.value}}Af.create=(e,t)=>new Af({value:e,typeName:xt.ZodLiteral,...Rt(t)});function HM(e,t){return new Ra({values:e,typeName:xt.ZodEnum,...Rt(t)})}class Ra extends jt{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return Qe(n,{expected:nn.joinValues(r),received:n.parsedType,code:Ne.invalid_type}),Pt}if(this._def.values.indexOf(t.data)===-1){const n=this._getOrReturnCtx(t),r=this._def.values;return Qe(n,{received:n.data,code:Ne.invalid_enum_value,options:r}),Pt}return Ar(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t){return Ra.create(t)}exclude(t){return Ra.create(this.options.filter(n=>!t.includes(n)))}}Ra.create=HM;class Pf extends jt{_parse(t){const n=nn.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==Je.string&&r.parsedType!==Je.number){const i=nn.objectValues(n);return Qe(r,{expected:nn.joinValues(i),received:r.parsedType,code:Ne.invalid_type}),Pt}if(n.indexOf(t.data)===-1){const i=nn.objectValues(n);return Qe(r,{received:r.data,code:Ne.invalid_enum_value,options:i}),Pt}return Ar(t.data)}get enum(){return this._def.values}}Pf.create=(e,t)=>new Pf({values:e,typeName:xt.ZodNativeEnum,...Rt(t)});class iu extends jt{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Je.promise&&n.common.async===!1)return Qe(n,{code:Ne.invalid_type,expected:Je.promise,received:n.parsedType}),Pt;const r=n.parsedType===Je.promise?n.data:Promise.resolve(n.data);return Ar(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}iu.create=(e,t)=>new iu({type:e,typeName:xt.ZodPromise,...Rt(t)});class Mi extends jt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===xt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,o={addIssue:a=>{Qe(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){const a=i.transform(r.data,o);return r.common.issues.length?{status:"dirty",value:r.data}:r.common.async?Promise.resolve(a).then(s=>this._def.schema._parseAsync({data:s,path:r.path,parent:r})):this._def.schema._parseSync({data:a,path:r.path,parent:r})}if(i.type==="refinement"){const a=s=>{const u=i.refinement(s,o);if(r.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){const s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Pt:(s.status==="dirty"&&n.dirty(),a(s.value),{status:n.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?Pt:(s.status==="dirty"&&n.dirty(),a(s.value).then(()=>({status:n.value,value:s.value}))))}if(i.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!wf(a))return a;const s=i.transform(a.value,o);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>wf(a)?Promise.resolve(i.transform(a.value,o)).then(s=>({status:n.value,value:s})):a);nn.assertNever(i)}}Mi.create=(e,t,n)=>new Mi({schema:e,typeName:xt.ZodEffects,effect:t,...Rt(n)}),Mi.createWithPreprocess=(e,t,n)=>new Mi({schema:t,effect:{type:"preprocess",transform:e},typeName:xt.ZodEffects,...Rt(n)});class qo extends jt{_parse(t){return this._getType(t)===Je.undefined?Ar(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}qo.create=(e,t)=>new qo({innerType:e,typeName:xt.ZodOptional,...Rt(t)});class Is extends jt{_parse(t){return this._getType(t)===Je.null?Ar(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Is.create=(e,t)=>new Is({innerType:e,typeName:xt.ZodNullable,...Rt(t)});class If extends jt{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===Je.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}If.create=(e,t)=>new If({innerType:e,typeName:xt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Rt(t)});class jm extends jt{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return $m(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ii(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ii(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}jm.create=(e,t)=>new jm({innerType:e,typeName:xt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Rt(t)});class Fm extends jt{_parse(t){if(this._getType(t)!==Je.nan){const r=this._getOrReturnCtx(t);return Qe(r,{code:Ne.invalid_type,expected:Je.nan,received:r.parsedType}),Pt}return{status:"valid",value:t.data}}}Fm.create=e=>new Fm({typeName:xt.ZodNaN,...Rt(e)});const ude=Symbol("zod_brand");class VM extends jt{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class $f extends jt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?Pt:o.status==="dirty"?(n.dirty(),ZM(o.value)):this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Pt:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,n){return new $f({in:t,out:n,typeName:xt.ZodPipeline})}}class Um extends jt{_parse(t){const n=this._def.innerType._parse(t);return wf(n)&&(n.value=Object.freeze(n.value)),n}}Um.create=(e,t)=>new Um({innerType:e,typeName:xt.ZodReadonly,...Rt(t)});const KM=(e,t={},n)=>e?tu.create().superRefine((r,i)=>{var o,a;if(!e(r)){const s=typeof t=="function"?t(r):typeof t=="string"?{message:t}:t,u=(a=(o=s.fatal)!==null&&o!==void 0?o:n)!==null&&a!==void 0?a:!0,c=typeof s=="string"?{message:s}:s;i.addIssue({code:"custom",...c,fatal:u})}}):tu.create(),cde={object:An.lazycreate};var xt;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(xt||(xt={}));const fde=(e,t={message:`Input not instance of ${e.name}`})=>KM(n=>n instanceof e,t),GM=$i.create,YM=Ia.create,dde=Fm.create,pde=$a.create,JM=xf.create,hde=ks.create,mde=Rm.create,gde=Sf.create,yde=Ef.create,vde=tu.create,bde=As.create,_de=zo.create,wde=Mm.create,xde=Ri.create,Sde=An.create,Ede=An.strictCreate,Cde=Cf.create,Ode=Dm.create,Tde=Of.create,kde=co.create,Ade=Tf.create,Pde=Lm.create,Ide=Ps.create,$de=ru.create,Rde=kf.create,Mde=Af.create,Nde=Ra.create,Dde=Pf.create,Lde=iu.create,QM=Mi.create,jde=qo.create,Fde=Is.create,Ude=Mi.createWithPreprocess,Bde=$f.create;var ne=Object.freeze({__proto__:null,defaultErrorMap:_f,setErrorMap:Yfe,getErrorMap:Pm,makeIssue:Im,EMPTY_PATH:Jfe,addIssueToContext:Qe,ParseStatus:_r,INVALID:Pt,DIRTY:ZM,OK:Ar,isAborted:$_,isDirty:R_,isValid:wf,isAsync:$m,get util(){return nn},get objectUtil(){return I_},ZodParsedType:Je,getParsedType:Pa,ZodType:jt,ZodString:$i,ZodNumber:Ia,ZodBigInt:$a,ZodBoolean:xf,ZodDate:ks,ZodSymbol:Rm,ZodUndefined:Sf,ZodNull:Ef,ZodAny:tu,ZodUnknown:As,ZodNever:zo,ZodVoid:Mm,ZodArray:Ri,ZodObject:An,ZodUnion:Cf,ZodDiscriminatedUnion:Dm,ZodIntersection:Of,ZodTuple:co,ZodRecord:Tf,ZodMap:Lm,ZodSet:Ps,ZodFunction:ru,ZodLazy:kf,ZodLiteral:Af,ZodEnum:Ra,ZodNativeEnum:Pf,ZodPromise:iu,ZodEffects:Mi,ZodTransformer:Mi,ZodOptional:qo,ZodNullable:Is,ZodDefault:If,ZodCatch:jm,ZodNaN:Fm,BRAND:ude,ZodBranded:VM,ZodPipeline:$f,ZodReadonly:Um,custom:KM,Schema:jt,ZodSchema:jt,late:cde,get ZodFirstPartyTypeKind(){return xt},coerce:{string:e=>$i.create({...e,coerce:!0}),number:e=>Ia.create({...e,coerce:!0}),boolean:e=>xf.create({...e,coerce:!0}),bigint:e=>$a.create({...e,coerce:!0}),date:e=>ks.create({...e,coerce:!0})},any:vde,array:xde,bigint:pde,boolean:JM,date:hde,discriminatedUnion:Ode,effect:QM,enum:Nde,function:$de,instanceof:fde,intersection:Tde,lazy:Rde,literal:Mde,map:Pde,nan:dde,nativeEnum:Dde,never:_de,null:yde,nullable:Fde,number:YM,object:Sde,oboolean:()=>JM().optional(),onumber:()=>YM().optional(),optional:jde,ostring:()=>GM().optional(),pipeline:Bde,preprocess:Ude,promise:Lde,record:Ade,set:Ide,strictObject:Ede,string:GM,symbol:mde,transformer:QM,tuple:kde,undefined:gde,union:Cde,unknown:bde,void:wde,NEVER:Pt,ZodIssueCode:Ne,quotelessJson:Gfe,ZodError:Ii});const zde=ne.object({type:ne.literal("message_created"),data:ne.object({id:ne.string(),createdAt:ne.string().datetime(),payload:ne.union([ne.object({audioUrl:ne.string().min(1),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("audio")}),ne.object({title:ne.string().min(1),subtitle:ne.string().optional(),imageUrl:ne.string().optional(),actions:ne.array(ne.object({action:ne.enum(["postback","url","say"]),label:ne.string().min(1),value:ne.string().min(1)})),type:ne.literal("card"),className:ne.string().describe("CSS className to apply to the message").optional()}),ne.object({items:ne.array(ne.object({title:ne.string().min(1),subtitle:ne.string().optional(),imageUrl:ne.string().optional(),actions:ne.array(ne.object({action:ne.enum(["postback","url","say"]),label:ne.string().min(1),value:ne.string().min(1)})),className:ne.string().describe("CSS className to apply to the message").optional()})),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("carousel")}),ne.object({text:ne.string(),options:ne.array(ne.object({label:ne.string().min(1),value:ne.string().min(1)})),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("choice"),disableFreeText:ne.boolean().optional()}),ne.object({text:ne.string(),options:ne.array(ne.object({label:ne.string().min(1),value:ne.string().min(1)})),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("dropdown")}),ne.object({fileUrl:ne.string().min(1),title:ne.string().min(1).optional(),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("file")}),ne.object({imageUrl:ne.string().min(1),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("image")}),ne.object({latitude:ne.number(),longitude:ne.number(),address:ne.string().optional(),title:ne.string().optional(),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("location")}),ne.object({markdown:ne.string().min(1),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("markdown")}),ne.object({text:ne.string().min(1),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("text")}),ne.object({videoUrl:ne.string().min(1),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("video")})]),userId:ne.string(),conversationId:ne.string()})}),qde=ne.object({type:ne.literal("webchat_visibility"),data:ne.object({visibility:ne.enum(["show","hide","toggle"])})}),Zde=ne.object({type:ne.literal("webchat_config"),data:ne.object({config:ne.record(ne.any())})}),Wde=ne.object({type:ne.literal("custom"),data:ne.object({event:ne.record(ne.any())})}),Hde={messageCreated:zde,webchatVisibility:qde,webchatConfig:Zde,custom:Wde},XM="unknown error",eg=class eg extends zM{constructor(n){super();R(this,"_state",{status:"disconnected"});R(this,"connect",async()=>{if(this._state.status==="connected")return;if(this._state.status==="connecting"){await this._state.connectionPromise;return}const n=this._connect();this._state={status:"connecting",connectionPromise:n},await n});R(this,"disconnect",async()=>{if(this._state.status==="disconnected")return;let n;this._state.status==="connecting"?n=await this._state.connectionPromise:n=this._state.source,this._disconnectSync(n)});R(this,"_connect",async()=>{const n=await Kfe(`${this._props.url}/conversations/${this._props.conversationId}/listen`,{headers:{"x-user-key":this._props.userKey}});return n.on("message",this._handleMessage),n.on("error",this._handleError(n)),this._state={status:"connected",source:n},n});R(this,"_disconnectSync",n=>{n.close(),this._state={status:"disconnected"}});R(this,"_handleMessage",n=>{const r=this._parseSignal(n.data);this.emit(r.type,r.data)});R(this,"_handleError",n=>r=>{this._disconnectSync(n);const i=this._toError(r);this.emit("error",i)});R(this,"_parseSignal",n=>{for(const r of Object.values(Hde)){const i=this._safeJsonParse(n),o=r.safeParse(i);if(o.success)return o.data}return{type:"unknown",data:n}});R(this,"_safeJsonParse",n=>{try{return JSON.parse(n)}catch{return n}});R(this,"_toError",n=>{if(n instanceof Error)return n;if(typeof n=="string")return new Error(n);if(n===null)return new Error(XM);if(typeof n=="object"&&"message"in n)return this._toError(n.message);try{const r=JSON.stringify(n);return new Error(r)}catch{return new Error(XM)}});this._props=n}get status(){return this._state.status}};R(eg,"listen",async n=>{const r=new eg(n);return await r.connect(),r});let D_=eg;const eN=100*1024*1024,Vde=eN,Kde=eN,Gde=6e4;class Yde{constructor(t){R(this,"_auto");R(this,"createConversation",t=>this._auto.createConversation(t));R(this,"getConversation",t=>this._auto.getConversation(t));R(this,"deleteConversation",t=>this._auto.deleteConversation(t));R(this,"listConversations",t=>this._auto.listConversations(t));R(this,"listConversationMessages",t=>this._auto.listConversationMessages(t));R(this,"addParticipant",t=>this._auto.addParticipant(t));R(this,"removeParticipant",t=>this._auto.removeParticipant(t));R(this,"getParticipant",t=>this._auto.getParticipant(t));R(this,"listParticipants",t=>this._auto.listParticipants(t));R(this,"createMessage",t=>this._auto.createMessage(t));R(this,"getMessage",t=>this._auto.getMessage(t));R(this,"deleteMessage",t=>this._auto.deleteMessage(t));R(this,"createUser",t=>this._auto.createUser(t));R(this,"getUser",t=>this._auto.getUser(t));R(this,"updateUser",t=>this._auto.updateUser(t));R(this,"deleteUser",t=>this._auto.deleteUser(t));R(this,"createEvent",t=>this._auto.createEvent(t));R(this,"getEvent",t=>this._auto.getEvent(t));R(this,"listenConversation",async({id:t,"x-user-key":n})=>await D_.listen({url:this.props.apiUrl,conversationId:t,userKey:n}));this.props=t;const{apiUrl:n}=t,r={...t.headers},i=t.timeout??Gde,o=aM.create({baseURL:n,headers:r,withCredentials:!0,timeout:i,maxBodyLength:Vde,maxContentLength:Kde});this._auto=new qfe(o)}}const Bm={disconnected:0,user_creating:1,user_created:2,conversation_creating:3,conversation_created:4},hi=(e,t)=>e.status===t,$s=(e,t)=>Bm[e.status]<Bm[t],tN=(e,t)=>Bm[e.status]>=Bm[t];class ou extends Error{constructor(t){super(`Unexpected state: ${t.status}`),this.state=t}}class nN extends Kg{constructor(n){super();R(this,"_client");R(this,"_webhookId");R(this,"_state",{status:"disconnected"});R(this,"mode","pushpin");R(this,"_initialConnect",async n=>{if(tN(this._state,"user_created"))throw new Error("Client is already connected. Please disconnect first.");if(hi(this._state,"user_creating"))return;this._state={status:"user_creating"},console.log("createUser");const{user:{id:r},key:i}=await this._client.createUser({name:void 0,pictureUrl:void 0,userData:n});return this._state={status:"user_created",userId:r,userKey:i},{userId:r,userToken:i}});R(this,"_reConnect",async(n,r)=>{if(tN(this._state,"user_created")){if(this._state.userId!==n.userId)throw new Error("Client is already connected. Please disconnect first.");return n}return hi(this._state,"user_creating")||(this._state={status:"user_created",userId:n.userId,userKey:n.userToken},console.log("updateUser"),await this._client.updateUser({"x-user-key":n.userToken,name:void 0,pictureUrl:void 0,userData:r})),n});R(this,"_mapMessage",n=>{const{payload:r,disableInput:i}=Gse(n.payload);return{id:n.id,conversationId:n.conversationId,authorId:n.userId,sentOn:new Date(n.createdAt),payload:r,disableInput:i}});const r=`${n.apiUrl}/${n.clientId}`;this._webhookId=n.clientId,this._client=new Yde({apiUrl:r})}get clientId(){return this._webhookId}get userId(){if(!$s(this._state,"user_created"))return this._state.userId}get conversationId(){if(!$s(this._state,"conversation_created"))return this._state.conversationId}async connect(n,r){return n?await this.userExists(n)?this._reConnect(n,r):this._initialConnect(r):this._initialConnect(r)}async disconnect(){hi(this._state,"conversation_created")?this._state.signalEmitter.cleanup():hi(this._state,"conversation_creating")&&console.warn("zombie conversation..."),this._state={status:"disconnected"}}async sendMessage(n){if($s(this._state,"user_created"))throw new ou(this._state);if(hi(this._state,"conversation_creating"))throw new ou(this._state);let r;hi(this._state,"conversation_created")?r=this._state:(this._state={status:"conversation_creating",userId:this._state.userId,userKey:this._state.userKey},r=await this._createNewConversation(this._state)),console.log("createMessage"),await this._client.createMessage({"x-user-key":r.userKey,conversationId:r.conversationId,payload:{type:"text",text:n}}),this.emit("messageSent",n)}async sendEvent(n){if($s(this._state,"user_created"))throw new ou(this._state);if(hi(this._state,"conversation_creating"))throw new ou(this._state);let r;hi(this._state,"conversation_created")?r=this._state:(this._state={status:"conversation_creating",userId:this._state.userId,userKey:this._state.userKey},r=await this._createNewConversation(this._state)),console.log("createEvent"),await this._client.createEvent({"x-user-key":r.userKey,conversationId:r.conversationId,payload:{type:"custom",data:n}})}async switchConversation(n){if($s(this._state,"user_created"))throw new ou(this._state);hi(this._state,"conversation_created")&&this._state.conversationId===n||hi(this._state,"conversation_creating")||(this._state={status:"conversation_creating",userId:this._state.userId,userKey:this._state.userKey},await this._connectConversation(this._state,n))}async conversationExists(n){if($s(this._state,"user_created"))return!1;try{return await this._client.getConversation({"x-user-key":this._state.userKey,id:n}),!0}catch(r){if(A_(r)&&r.code===404)return!1;throw r}}async userExists({userToken:n}){try{return await this._client.getUser({"x-user-key":n}),!0}catch(r){const i=o=>o.code===404||o.code===401;if(A_(r)&&i(r))return!1;throw r}}async newConversation(){if($s(this._state,"user_created"))throw new ou(this._state);hi(this._state,"conversation_creating")||(this._state={status:"conversation_creating",userId:this._state.userId,userKey:this._state.userKey},await this._createNewConversation(this._state))}async _createNewConversation(n){console.log("createConversation");const{conversation:{id:r}}=await this._client.createConversation({"x-user-key":n.userKey}),i=await this._connectConversation(n,r);return await this._client.createEvent({"x-user-key":n.userKey,conversationId:r,payload:{type:"conversation_started",data:{}}}),i}async listMessages(){if(!hi(this._state,"conversation_created"))return[];const{conversationId:n,userKey:r}=this._state,i=[];let o;do{const a=await this._client.listConversationMessages({id:n,"x-user-key":r,nextToken:o});i.push(...a.messages),o=a.meta.nextToken}while(o);return i.map(this._mapMessage)}async _connectConversation(n,r){const i=await this._client.listenConversation({id:r,"x-user-key":n.userKey});return i.on("unknown",o=>console.log("unknown event",o)),i.on("message_created",o=>{o.userId!==n.userId&&this.emit("message",this._mapMessage(o))}),i.on("error",()=>{this._state={status:"user_created",userId:n.userId,userKey:n.userKey},this.emit("error",new Error("Connection to conversation lost"))}),i.on("webchat_visibility",o=>{this.emit("webchatVisibility",o.visibility)}),i.on("webchat_config",o=>{this.emit("webchatConfig",o.config)}),i.on("custom",o=>{this.emit("customEvent",o.event)}),this.emit("conversation",r),this._state={status:"conversation_created",userId:n.userId,userKey:n.userKey,conversationId:r,signalEmitter:i},this._state}}const Jde=({clientId:e,apiUrl:t,mode:n="messaging"})=>{const[r,i]=T.useState();return T.useEffect(()=>{const o=n==="messaging"?new PR({url:t,clientId:e}):new nN({apiUrl:t,clientId:e});i(o)},[e,t,n]),r},rN=T.memo(T.forwardRef((e,t)=>{const{state:n,theme:{composer:r},client:i}=fn(),[o,a]=T.useState(""),[s,u]=T.useState(-1);if(n.isReadOnly||!i)return null;const c=()=>{o&&(i.sendMessage(o),a(""),u(-1))};return X.jsx(OS.Provider,{value:{value:o,setValue:a,historyIndex:s,setHistoryIndex:u,sendMessage:c},children:X.jsx("div",{"data-disabled":n.disableComposer,...e,...r==null?void 0:r.container,ref:t})})})),iN=T.memo(({...e})=>{const{state:t,theme:{composer:n}}=fn(),{value:r,setValue:i,historyIndex:o,setHistoryIndex:a,sendMessage:s}=TS(),u=T.useRef(null),c=ha(p=>p.user),d=ha(p=>p.messageHistory);return T.useEffect(()=>{u.current&&(u.current.selectionStart=u.current.value.length,u.current.selectionEnd=u.current.value.length)},[r]),X.jsx("textarea",{...n==null?void 0:n.input,disabled:t.disableComposer,ref:u,value:r,"data-has-value":!!r,onChange:p=>i(p.target.value),onKeyDown:p=>{if(!t.disableComposer){if(p.key==="Enter"&&(p.preventDefault(),s()),p.key==="ArrowUp"){p.preventDefault();const m=d[(c==null?void 0:c.userId)??""]??[];o<m.length-1&&i(m[o+1]),a(()=>Math.min(o+1,m.length-1))}if(p.key==="ArrowDown"){p.preventDefault();const m=d[(c==null?void 0:c.userId)??""]??[];i(o===0?"":m[o-1]),a(()=>Math.max(o-1,-1))}}},...e})}),oN=T.memo(T.forwardRef(({icon:e=X4,...t},n)=>{var a,s;const{value:r,sendMessage:i}=TS(),{theme:{composer:o}}=fn();return X.jsx("button",{ref:n,...t,...(a=o==null?void 0:o.button)==null?void 0:a.container,disabled:!r,onClick:i,children:X.jsx(e,{...(s=o==null?void 0:o.button)==null?void 0:s.icon})})})),aN=({children:e})=>{const[t,n]=T.useState(!1),[r,i]=T.useState(""),[o,a]=T.useState(null),s=({title:c,content:d})=>{i(c),a(d),n(!0)},u=()=>{n(!1)};return X.jsxs(AS.Provider,{value:{hideModal:u,showModal:s,title:r,content:o,open:t},children:[X.jsx(Na,{open:t,onOpenChange:n,children:X.jsx(Na.Content,{title:r,children:o})}),e]})},Qde=({theme:e={},renderers:t,client:n,children:r,configuration:i={},userData:o,closeWindow:a,...s})=>{const[u,c]=T.useState(0),[d,p]=T.useState([]),[m,h]=T.useState({disableComposer:!1,...s.defaultState,connected:!0}),[y,v]=T.useState(i),[x,b]=T.useState(e),w=ha($=>$.addMessageToHistory),S=ha($=>$.setConversationId),P=ha($=>$.user),k=ha($=>$.conversationId),C=ha($=>$.setUser),L=ha($=>$.setClientMode),q=T.useRef(null),G={...s,value:{theme:x,renderers:{...vv,...t},messages:d,messageContainerRef:q,setMessages:p,eventEmitter:VL,configuration:i,setConfiguration:v,state:m,closeWindow:a,setState:$=>h({...m,...$}),setTheme:$=>{b($)},client:n?{...n,sendMessage:async $=>{await n.sendMessage($),p(z=>[...z,{direction:"outgoing",sender:{name:"You"},timestamp:new Date,disableInput:!1,block:{type:"bubble",block:{type:"text",text:$}}}]),n.userId&&w({message:$,userId:n.userId})},on:n.on,restartConversation:async()=>{await n.newConversation(),p([])}}:void 0}};return ts(()=>{n&&L(n.mode)}),ts(()=>{if(n)return n.on("message",$=>{try{const{payload:z,disableInput:ee}=$;p(Y=>[...Y,{direction:"incoming",sender:{name:y.botName??"Bot",avatar:y.botAvatar},timestamp:new Date($.sentOn),block:z,disableInput:ee}])}catch{console.error("Invalid message payload")}})}),Ov(async()=>{if(n)return n.on("error",()=>{console.log("client disconnected"),c($=>$+1)})}),ts(()=>{if(n)return n.on("conversation",$=>{S($)})}),Ov(async()=>{if(!n)return;let $;try{$=await n.connect(P,o),h(ee=>({...ee,connected:!0}))}catch{h(Y=>({...Y,connected:!1}));return}C($),k&&await n.conversationExists(k)?await n.switchConversation(k):await n.newConversation();const z=[];for(const ee of await n.listMessages())try{const{payload:Y,authorId:te,sentOn:K,disableInput:Q}=ee,ae=te===n.userId?"outgoing":"incoming";z.push({direction:ae,sender:ae==="outgoing"?{name:"You"}:{name:y.botName??"Bot",avatar:y.botAvatar},timestamp:new Date(K),block:Y,disableInput:Q})}catch{console.error("Invalid message payload")}return p(z.reverse()),()=>{n.disconnect()}},[u]),X.jsx(IS.Provider,{...G,children:typeof r=="function"?r(y):r})};function Zo(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}const Xde=F["useId".toString()]||(()=>{});let epe=0;function zm(e){const[t,n]=F.useState(Xde());return Tu(()=>{e||n(r=>r??String(epe++))},[e]),e||(t?`radix-${t}`:"")}function sN({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,i]=tpe({defaultProp:t,onChange:n}),o=e!==void 0,a=o?e:r,s=na(n),u=T.useCallback(c=>{if(o){const p=typeof c=="function"?c(e):c;p!==e&&s(p)}else i(c)},[o,e,i,s]);return[a,u]}function tpe({defaultProp:e,onChange:t}){const n=T.useState(e),[r]=n,i=T.useRef(r),o=na(t);return T.useEffect(()=>{i.current!==r&&(o(r),i.current=r)},[r,i,o]),n}function npe(e,t=globalThis==null?void 0:globalThis.document){const n=na(e);T.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return t.addEventListener("keydown",r),()=>t.removeEventListener("keydown",r)},[n,t])}const L_="dismissableLayer.update",rpe="dismissableLayer.pointerDownOutside",ipe="dismissableLayer.focusOutside";let lN;const ope=T.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ape=T.forwardRef((e,t)=>{var n;const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:s,onDismiss:u,...c}=e,d=T.useContext(ope),[p,m]=T.useState(null),h=(n=p==null?void 0:p.ownerDocument)!==null&&n!==void 0?n:globalThis==null?void 0:globalThis.document,[,y]=T.useState({}),v=Wa(t,q=>m(q)),x=Array.from(d.layers),[b]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),w=x.indexOf(b),S=p?x.indexOf(p):-1,P=d.layersWithOutsidePointerEventsDisabled.size>0,k=S>=w,C=spe(q=>{const G=q.target,$=[...d.branches].some(z=>z.contains(G));!k||$||(o==null||o(q),s==null||s(q),q.defaultPrevented||u==null||u())},h),L=lpe(q=>{const G=q.target;[...d.branches].some(z=>z.contains(G))||(a==null||a(q),s==null||s(q),q.defaultPrevented||u==null||u())},h);return npe(q=>{S===d.layers.size-1&&(i==null||i(q),!q.defaultPrevented&&u&&(q.preventDefault(),u()))},h),T.useEffect(()=>{if(p)return r&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(lN=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(p)),d.layers.add(p),uN(),()=>{r&&d.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=lN)}},[p,h,r,d]),T.useEffect(()=>()=>{p&&(d.layers.delete(p),d.layersWithOutsidePointerEventsDisabled.delete(p),uN())},[p,d]),T.useEffect(()=>{const q=()=>y({});return document.addEventListener(L_,q),()=>document.removeEventListener(L_,q)},[]),T.createElement(ai.div,En({},c,{ref:v,style:{pointerEvents:P?k?"auto":"none":void 0,...e.style},onFocusCapture:Zo(e.onFocusCapture,L.onFocusCapture),onBlurCapture:Zo(e.onBlurCapture,L.onBlurCapture),onPointerDownCapture:Zo(e.onPointerDownCapture,C.onPointerDownCapture)}))});function spe(e,t=globalThis==null?void 0:globalThis.document){const n=na(e),r=T.useRef(!1),i=T.useRef(()=>{});return T.useEffect(()=>{const o=s=>{if(s.target&&!r.current){let c=function(){cN(rpe,n,u,{discrete:!0})};const u={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",i.current),i.current=c,t.addEventListener("click",i.current,{once:!0})):c()}r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",o),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function lpe(e,t=globalThis==null?void 0:globalThis.document){const n=na(e),r=T.useRef(!1);return T.useEffect(()=>{const i=o=>{o.target&&!r.current&&cN(ipe,n,{originalEvent:o},{discrete:!1})};return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function uN(){const e=new CustomEvent(L_);document.dispatchEvent(e)}function cN(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?BL(i,o):i.dispatchEvent(o)}const j_="focusScope.autoFocusOnMount",F_="focusScope.autoFocusOnUnmount",fN={bubbles:!1,cancelable:!0},upe=T.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:o,...a}=e,[s,u]=T.useState(null),c=na(i),d=na(o),p=T.useRef(null),m=Wa(t,v=>u(v)),h=T.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;T.useEffect(()=>{if(r){let v=function(S){if(h.paused||!s)return;const P=S.target;s.contains(P)?p.current=P:Ma(p.current,{select:!0})},x=function(S){if(h.paused||!s)return;const P=S.relatedTarget;P!==null&&(s.contains(P)||Ma(p.current,{select:!0}))},b=function(S){const P=document.activeElement;for(const k of S)k.removedNodes.length>0&&(s!=null&&s.contains(P)||Ma(s))};document.addEventListener("focusin",v),document.addEventListener("focusout",x);const w=new MutationObserver(b);return s&&w.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",x),w.disconnect()}}},[r,s,h.paused]),T.useEffect(()=>{if(s){hN.add(h);const v=document.activeElement;if(!s.contains(v)){const b=new CustomEvent(j_,fN);s.addEventListener(j_,c),s.dispatchEvent(b),b.defaultPrevented||(cpe(mpe(dN(s)),{select:!0}),document.activeElement===v&&Ma(s))}return()=>{s.removeEventListener(j_,c),setTimeout(()=>{const b=new CustomEvent(F_,fN);s.addEventListener(F_,d),s.dispatchEvent(b),b.defaultPrevented||Ma(v??document.body,{select:!0}),s.removeEventListener(F_,d),hN.remove(h)},0)}}},[s,c,d,h]);const y=T.useCallback(v=>{if(!n&&!r||h.paused)return;const x=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,b=document.activeElement;if(x&&b){const w=v.currentTarget,[S,P]=fpe(w);S&&P?!v.shiftKey&&b===P?(v.preventDefault(),n&&Ma(S,{select:!0})):v.shiftKey&&b===S&&(v.preventDefault(),n&&Ma(P,{select:!0})):b===w&&v.preventDefault()}},[n,r,h.paused]);return T.createElement(ai.div,En({tabIndex:-1},a,{ref:m,onKeyDown:y}))});function cpe(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ma(r,{select:t}),document.activeElement!==n)return}function fpe(e){const t=dN(e),n=pN(t,e),r=pN(t.reverse(),e);return[n,r]}function dN(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function pN(e,t){for(const n of e)if(!dpe(n,{upTo:t}))return n}function dpe(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function ppe(e){return e instanceof HTMLInputElement&&"select"in e}function Ma(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&ppe(e)&&t&&e.select()}}const hN=hpe();function hpe(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=mN(e,t),e.unshift(t)},remove(t){var n;e=mN(e,t),(n=e[0])===null||n===void 0||n.resume()}}}function mN(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function mpe(e){return e.filter(t=>t.tagName!=="A")}function gpe(e,t){return T.useReducer((n,r)=>{const i=t[n][r];return i??n},e)}const qm=e=>{const{present:t,children:n}=e,r=ype(t),i=typeof n=="function"?n({present:r.isPresent}):T.Children.only(n),o=Wa(r.ref,i.ref);return typeof n=="function"||r.isPresent?T.cloneElement(i,{ref:o}):null};qm.displayName="Presence";function ype(e){const[t,n]=T.useState(),r=T.useRef({}),i=T.useRef(e),o=T.useRef("none"),a=e?"mounted":"unmounted",[s,u]=gpe(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return T.useEffect(()=>{const c=Zm(r.current);o.current=s==="mounted"?c:"none"},[s]),Tu(()=>{const c=r.current,d=i.current;if(d!==e){const m=o.current,h=Zm(c);e?u("MOUNT"):h==="none"||(c==null?void 0:c.display)==="none"?u("UNMOUNT"):u(d&&m!==h?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,u]),Tu(()=>{if(t){const c=p=>{const h=Zm(r.current).includes(p.animationName);p.target===t&&h&&zi.flushSync(()=>u("ANIMATION_END"))},d=p=>{p.target===t&&(o.current=Zm(r.current))};return t.addEventListener("animationstart",d),t.addEventListener("animationcancel",c),t.addEventListener("animationend",c),()=>{t.removeEventListener("animationstart",d),t.removeEventListener("animationcancel",c),t.removeEventListener("animationend",c)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:T.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function Zm(e){return(e==null?void 0:e.animationName)||"none"}let U_=0;function vpe(){T.useEffect(()=>{var e,t;const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",(e=n[0])!==null&&e!==void 0?e:gN()),document.body.insertAdjacentElement("beforeend",(t=n[1])!==null&&t!==void 0?t:gN()),U_++,()=>{U_===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(r=>r.remove()),U_--}},[])}function gN(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.cssText="outline: none; opacity: 0; position: fixed; pointer-events: none",e}var Wm="right-scroll-bar-position",Hm="width-before-scroll-bar",bpe="with-scroll-bars-hidden",_pe="--removed-body-scroll-bar-size";function wpe(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function xpe(e,t){var n=T.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=t,n.facade}function Spe(e,t){return xpe(t||null,function(n){return e.forEach(function(r){return wpe(r,n)})})}function Epe(e){return e}function Cpe(e,t){t===void 0&&(t=Epe);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(o){var a=t(o,r);return n.push(a),function(){n=n.filter(function(s){return s!==a})}},assignSyncMedium:function(o){for(r=!0;n.length;){var a=n;n=[],a.forEach(o)}n={push:function(s){return o(s)},filter:function(){return n}}},assignMedium:function(o){r=!0;var a=[];if(n.length){var s=n;n=[],s.forEach(o),a=n}var u=function(){var d=a;a=[],d.forEach(o)},c=function(){return Promise.resolve().then(u)};c(),n={push:function(d){a.push(d),c()},filter:function(d){return a=a.filter(d),n}}}};return i}function Ope(e){e===void 0&&(e={});var t=Cpe(null);return t.options=ui({async:!0,ssr:!1},e),t}var yN=function(e){var t=e.sideCar,n=oC(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return F.createElement(r,ui({},n))};yN.isSideCarExport=!0;function Tpe(e,t){return e.useMedium(t),yN}var vN=Ope(),B_=function(){},Vm=F.forwardRef(function(e,t){var n=F.useRef(null),r=F.useState({onScrollCapture:B_,onWheelCapture:B_,onTouchMoveCapture:B_}),i=r[0],o=r[1],a=e.forwardProps,s=e.children,u=e.className,c=e.removeScrollBar,d=e.enabled,p=e.shards,m=e.sideCar,h=e.noIsolation,y=e.inert,v=e.allowPinchZoom,x=e.as,b=x===void 0?"div":x,w=oC(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as"]),S=m,P=Spe([n,t]),k=ui(ui({},w),i);return F.createElement(F.Fragment,null,d&&F.createElement(S,{sideCar:vN,removeScrollBar:c,shards:p,noIsolation:h,inert:y,setCallbacks:o,allowPinchZoom:!!v,lockRef:n}),a?F.cloneElement(F.Children.only(s),ui(ui({},k),{ref:P})):F.createElement(b,ui({},k,{className:u,ref:P}),s))});Vm.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Vm.classNames={fullWidth:Hm,zeroRight:Wm};var bN,kpe=function(){if(bN)return bN;if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Ape(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=kpe();return t&&e.setAttribute("nonce",t),e}function Ppe(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ipe(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var $pe=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Ape())&&(Ppe(t,n),Ipe(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Rpe=function(){var e=$pe();return function(t,n){F.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},_N=function(){var e=Rpe(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},Mpe={left:0,top:0,right:0,gap:0},z_=function(e){return parseInt(e||"",10)||0},Npe=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[z_(n),z_(r),z_(i)]},Dpe=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Mpe;var t=Npe(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Lpe=_N(),jpe=function(e,t,n,r){var i=e.left,o=e.top,a=e.right,s=e.gap;return n===void 0&&(n="margin"),`
471
+ `,Hn+=Pr):wr==="id"?gn=Pr:wr==="event"?Cn=Pr:wr==="retry"?(Be=pt(Pr,Be),vt=Be):wr==="heartbeatTimeout"&&(st=pt(Pr,st),Xt!==0&&(i(Xt),Xt=r(function(){rt()},st)))}if(Fn===le){if(Hn!==""){Mt=gn,Cn===""&&(Cn="message");var fo=new Y(Cn,{data:Hn.slice(1),lastEventId:gn});if(Z.dispatchEvent(fo),Cn==="open"?Le(Z,Z.onopen,fo):Cn==="message"?Le(Z,Z.onmessage,fo):Cn==="error"&&Le(Z,Z.onerror,fo),xn===ke)return}Hn="",Cn=""}Fn=pn==="\r".charCodeAt(0)?I:le}else Fn===le&&(Ni=yn,Fn=De),Fn===De?pn===":".charCodeAt(0)&&(D=yn+1,Fn=M):Fn===M&&(Fn=Fe)}}},Et=function(St){if(xn===ie||xn===ae){xn=Q,Xt!==0&&(i(Xt),Xt=0),Xt=r(function(){rt()},vt),vt=at(Math.min(Be*16,vt*2)),Z.readyState=ae;var At=new K("error",{error:St});Z.dispatchEvent(At),Le(Z,Z.onerror,At),St!=null&&console.error(St)}},it=function(){xn=ke,rn!=null&&(rn.abort(),rn=void 0),Xt!==0&&(i(Xt),Xt=0),Z.readyState=ke},rt=function(){if(Xt=0,xn!==Q){if(!J&&rn!=null)Et(new Error("No activity within "+st+" milliseconds. "+(xn===ae?"No response received.":fe+" chars received.")+" Reconnecting.")),rn!=null&&(rn.abort(),rn=void 0);else{var St=Math.max((J||Date.now())+st-Date.now(),1);J=!1,Xt=r(function(){rt()},St)}return}J=!1,fe=0,Xt=r(function(){rt()},st),xn=ae,Hn="",Cn="",gn=Mt,Rn="",Ni=0,D=0,Fn=le;var At=pe;if(pe.slice(0,5)!=="data:"&&pe.slice(0,5)!=="blob:"&&Mt!==""){var On=pe.indexOf("?");At=On===-1?pe:pe.slice(0,On+1)+pe.slice(On+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,function(Pr,fo){return fo===tt?"":Pr}),At+=(pe.indexOf("?")===-1?"?":"&")+tt+"="+encodeURIComponent(Mt)}var pn=Z.withCredentials,Mn={};Mn.Accept="text/event-stream";var yn=Z.headers;if(yn!=null)for(var wr in yn)Object.prototype.hasOwnProperty.call(yn,wr)&&(Mn[wr]=yn[wr]);try{rn=dn.open(bt,Ue,Ye,Et,At,pn,Mn)}catch(Pr){throw it(),Pr}};Z.url=pe,Z.readyState=ae,Z.withCredentials=Te,Z.headers=Ce,Z._close=it,rt()}Ie.prototype=Object.create($.prototype),Ie.prototype.CONNECTING=ae,Ie.prototype.OPEN=ie,Ie.prototype.CLOSED=ke,Ie.prototype.close=function(){this._close()},Ie.CONNECTING=ae,Ie.OPEN=ie,Ie.CLOSED=ke,Ie.prototype.withCredentials=void 0;var ht=u;o!=null&&(u==null||!("withCredentials"in u.prototype))&&(ht=Ie),function(Z){{var pe=Z(t);pe!==void 0&&(e.exports=pe)}}(function(Z){Z.EventSourcePolyfill=Ie,Z.NativeEventSource=u,Z.EventSource=ht})})(typeof globalThis>"u"?typeof window<"u"?window:typeof self<"u"?self:re:globalThis)})(P_,P_.exports);var Wfe=P_.exports;const Hfe=ta(Wfe),Vfe=(e,t={})=>{const n=new Hfe.EventSourcePolyfill(e,{headers:t.headers}),r=new zM;return n.onopen=i=>r.emit("open",i),n.onmessage=i=>r.emit("message",i),n.onerror=i=>r.emit("error",i),{emitter:r,source:n}},Kfe=async(e,t={})=>{const{emitter:n,source:r}=Vfe(e,t);return await new Promise((i,o)=>{n.on("open",()=>{i()}),n.on("error",a=>{o(a)})}).finally(()=>n.cleanup()),{on:n.on.bind(n),close:()=>{n.cleanup(),r.close()}}};var nn;(function(e){e.assertEqual=i=>i;function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const o={};for(const a of i)o[a]=a;return o},e.getValidEnumValues=i=>{const o=e.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),a={};for(const s of o)a[s]=i[s];return e.objectValues(a)},e.objectValues=i=>e.objectKeys(i).map(function(o){return i[o]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const o=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&o.push(a);return o},e.find=(i,o)=>{for(const a of i)if(o(a))return a},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function r(i,o=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}e.joinValues=r,e.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(nn||(nn={}));var I_;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(I_||(I_={}));const Je=nn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Pa=e=>{switch(typeof e){case"undefined":return Je.undefined;case"string":return Je.string;case"number":return isNaN(e)?Je.nan:Je.number;case"boolean":return Je.boolean;case"function":return Je.function;case"bigint":return Je.bigint;case"symbol":return Je.symbol;case"object":return Array.isArray(e)?Je.array:e===null?Je.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Je.promise:typeof Map<"u"&&e instanceof Map?Je.map:typeof Set<"u"&&e instanceof Set?Je.set:typeof Date<"u"&&e instanceof Date?Je.date:Je.object;default:return Je.unknown}},Ne=nn.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"]),Gfe=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class Ii extends Error{constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}get errors(){return this.issues}format(t){const n=t||function(o){return o.message},r={_errors:[]},i=o=>{for(const a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let s=r,u=0;for(;u<a.path.length;){const c=a.path[u];u===a.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(n(a))):s[c]=s[c]||{_errors:[]},s=s[c],u++}}};return i(this),r}toString(){return this.message}get message(){return JSON.stringify(this.issues,nn.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const i of this.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Ii.create=e=>new Ii(e);const _f=(e,t)=>{let n;switch(e.code){case Ne.invalid_type:e.received===Je.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Ne.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,nn.jsonStringifyReplacer)}`;break;case Ne.unrecognized_keys:n=`Unrecognized key(s) in object: ${nn.joinValues(e.keys,", ")}`;break;case Ne.invalid_union:n="Invalid input";break;case Ne.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${nn.joinValues(e.options)}`;break;case Ne.invalid_enum_value:n=`Invalid enum value. Expected ${nn.joinValues(e.options)}, received '${e.received}'`;break;case Ne.invalid_arguments:n="Invalid function arguments";break;case Ne.invalid_return_type:n="Invalid function return type";break;case Ne.invalid_date:n="Invalid date";break;case Ne.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:nn.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case Ne.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case Ne.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case Ne.custom:n="Invalid input";break;case Ne.invalid_intersection_types:n="Intersection results could not be merged";break;case Ne.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Ne.not_finite:n="Number must be finite";break;default:n=t.defaultError,nn.assertNever(e)}return{message:n}};let qM=_f;function Yfe(e){qM=e}function Pm(){return qM}const Im=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,o=[...n,...i.path||[]],a={...i,path:o};let s="";const u=r.filter(c=>!!c).slice().reverse();for(const c of u)s=c(a,{data:t,defaultError:s}).message;return{...i,path:o,message:i.message||s}},Jfe=[];function Qe(e,t){const n=Im({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,Pm(),_f].filter(r=>!!r)});e.common.issues.push(n)}class _r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const i of n){if(i.status==="aborted")return Pt;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const i of n)r.push({key:await i.key,value:await i.value});return _r.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const i of n){const{key:o,value:a}=i;if(o.status==="aborted"||a.status==="aborted")return Pt;o.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(r[o.value]=a.value)}return{status:t.value,value:r}}}const Pt=Object.freeze({status:"aborted"}),ZM=e=>({status:"dirty",value:e}),Ar=e=>({status:"valid",value:e}),$_=e=>e.status==="aborted",R_=e=>e.status==="dirty",wf=e=>e.status==="valid",$m=e=>typeof Promise<"u"&&e instanceof Promise;var ft;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(ft||(ft={}));class uo{constructor(t,n,r,i){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=i}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 WM=(e,t)=>{if(wf(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ii(e.common.issues);return this._error=n,this._error}}};function Rt(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(a,s)=>a.code!=="invalid_type"?{message:s.defaultError}:typeof s.data>"u"?{message:r??s.defaultError}:{message:n??s.defaultError},description:i}}class jt{constructor(t){this.spa=this.safeParseAsync,this._def=t,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(t){return Pa(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Pa(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new _r,ctx:{common:t.parent.common,data:t.data,parsedType:Pa(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if($m(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){var r;const i={common:{issues:[],async:(r=n==null?void 0:n.async)!==null&&r!==void 0?r:!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Pa(t)},o=this._parseSync({data:t,path:i.path,parent:i});return WM(i,o)}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Pa(t)},i=this._parse({data:t,path:r.path,parent:r}),o=await($m(i)?i:Promise.resolve(i));return WM(r,o)}refine(t,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,o)=>{const a=t(i),s=()=>o.addIssue({code:Ne.custom,...r(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(u=>u?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(t,n){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(t){return new Mi({schema:this,typeName:xt.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}optional(){return qo.create(this,this._def)}nullable(){return Is.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ri.create(this,this._def)}promise(){return iu.create(this,this._def)}or(t){return Cf.create([this,t],this._def)}and(t){return Of.create(this,t,this._def)}transform(t){return new Mi({...Rt(this._def),schema:this,typeName:xt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new If({...Rt(this._def),innerType:this,defaultValue:n,typeName:xt.ZodDefault})}brand(){return new VM({typeName:xt.ZodBranded,type:this,...Rt(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new jm({...Rt(this._def),innerType:this,catchValue:n,typeName:xt.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return $f.create(this,t)}readonly(){return Um.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Qfe=/^c[^\s-]{8,}$/i,Xfe=/^[a-z][a-z0-9]*$/,ede=/^[0-9A-HJKMNP-TV-Z]{26}$/,tde=/^[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,nde=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,rde="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let M_;const ide=/^(((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}))$/,ode=/^(([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})))$/,ade=e=>e.precision?e.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${e.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${e.precision}}Z$`):e.precision===0?e.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$"):e.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 sde(e,t){return!!((t==="v4"||!t)&&ide.test(e)||(t==="v6"||!t)&&ode.test(e))}class $i extends jt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Je.string){const o=this._getOrReturnCtx(t);return Qe(o,{code:Ne.invalid_type,expected:Je.string,received:o.parsedType}),Pt}const r=new _r;let i;for(const o of this._def.checks)if(o.kind==="min")t.data.length<o.value&&(i=this._getOrReturnCtx(t,i),Qe(i,{code:Ne.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="max")t.data.length>o.value&&(i=this._getOrReturnCtx(t,i),Qe(i,{code:Ne.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="length"){const a=t.data.length>o.value,s=t.data.length<o.value;(a||s)&&(i=this._getOrReturnCtx(t,i),a?Qe(i,{code:Ne.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):s&&Qe(i,{code:Ne.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),r.dirty())}else if(o.kind==="email")nde.test(t.data)||(i=this._getOrReturnCtx(t,i),Qe(i,{validation:"email",code:Ne.invalid_string,message:o.message}),r.dirty());else if(o.kind==="emoji")M_||(M_=new RegExp(rde,"u")),M_.test(t.data)||(i=this._getOrReturnCtx(t,i),Qe(i,{validation:"emoji",code:Ne.invalid_string,message:o.message}),r.dirty());else if(o.kind==="uuid")tde.test(t.data)||(i=this._getOrReturnCtx(t,i),Qe(i,{validation:"uuid",code:Ne.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid")Qfe.test(t.data)||(i=this._getOrReturnCtx(t,i),Qe(i,{validation:"cuid",code:Ne.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid2")Xfe.test(t.data)||(i=this._getOrReturnCtx(t,i),Qe(i,{validation:"cuid2",code:Ne.invalid_string,message:o.message}),r.dirty());else if(o.kind==="ulid")ede.test(t.data)||(i=this._getOrReturnCtx(t,i),Qe(i,{validation:"ulid",code:Ne.invalid_string,message:o.message}),r.dirty());else if(o.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),Qe(i,{validation:"url",code:Ne.invalid_string,message:o.message}),r.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),Qe(i,{validation:"regex",code:Ne.invalid_string,message:o.message}),r.dirty())):o.kind==="trim"?t.data=t.data.trim():o.kind==="includes"?t.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(t,i),Qe(i,{code:Ne.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),r.dirty()):o.kind==="toLowerCase"?t.data=t.data.toLowerCase():o.kind==="toUpperCase"?t.data=t.data.toUpperCase():o.kind==="startsWith"?t.data.startsWith(o.value)||(i=this._getOrReturnCtx(t,i),Qe(i,{code:Ne.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()):o.kind==="endsWith"?t.data.endsWith(o.value)||(i=this._getOrReturnCtx(t,i),Qe(i,{code:Ne.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()):o.kind==="datetime"?ade(o).test(t.data)||(i=this._getOrReturnCtx(t,i),Qe(i,{code:Ne.invalid_string,validation:"datetime",message:o.message}),r.dirty()):o.kind==="ip"?sde(t.data,o.version)||(i=this._getOrReturnCtx(t,i),Qe(i,{validation:"ip",code:Ne.invalid_string,message:o.message}),r.dirty()):nn.assertNever(o);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:Ne.invalid_string,...ft.errToObj(r)})}_addCheck(t){return new $i({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...ft.errToObj(t)})}url(t){return this._addCheck({kind:"url",...ft.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...ft.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...ft.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...ft.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...ft.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...ft.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...ft.errToObj(t)})}datetime(t){var n;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(n=t==null?void 0:t.offset)!==null&&n!==void 0?n:!1,...ft.errToObj(t==null?void 0:t.message)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...ft.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...ft.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...ft.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...ft.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...ft.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...ft.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...ft.errToObj(n)})}nonempty(t){return this.min(1,ft.errToObj(t))}trim(){return new $i({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new $i({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new $i({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}$i.create=e=>{var t;return new $i({checks:[],typeName:xt.ZodString,coerce:(t=e==null?void 0:e.coerce)!==null&&t!==void 0?t:!1,...Rt(e)})};function lde(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,o=parseInt(e.toFixed(i).replace(".","")),a=parseInt(t.toFixed(i).replace(".",""));return o%a/Math.pow(10,i)}class Ia extends jt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Je.number){const o=this._getOrReturnCtx(t);return Qe(o,{code:Ne.invalid_type,expected:Je.number,received:o.parsedType}),Pt}let r;const i=new _r;for(const o of this._def.checks)o.kind==="int"?nn.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),Qe(r,{code:Ne.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(r=this._getOrReturnCtx(t,r),Qe(r,{code:Ne.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(r=this._getOrReturnCtx(t,r),Qe(r,{code:Ne.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?lde(t.data,o.value)!==0&&(r=this._getOrReturnCtx(t,r),Qe(r,{code:Ne.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),Qe(r,{code:Ne.not_finite,message:o.message}),i.dirty()):nn.assertNever(o);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,ft.toString(n))}gt(t,n){return this.setLimit("min",t,!1,ft.toString(n))}lte(t,n){return this.setLimit("max",t,!0,ft.toString(n))}lt(t,n){return this.setLimit("max",t,!1,ft.toString(n))}setLimit(t,n,r,i){return new Ia({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ft.toString(i)}]})}_addCheck(t){return new Ia({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:ft.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ft.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ft.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ft.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ft.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:ft.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:ft.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ft.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ft.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&nn.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Ia.create=e=>new Ia({checks:[],typeName:xt.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Rt(e)});class $a extends jt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce&&(t.data=BigInt(t.data)),this._getType(t)!==Je.bigint){const o=this._getOrReturnCtx(t);return Qe(o,{code:Ne.invalid_type,expected:Je.bigint,received:o.parsedType}),Pt}let r;const i=new _r;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(r=this._getOrReturnCtx(t,r),Qe(r,{code:Ne.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(r=this._getOrReturnCtx(t,r),Qe(r,{code:Ne.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),Qe(r,{code:Ne.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):nn.assertNever(o);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,ft.toString(n))}gt(t,n){return this.setLimit("min",t,!1,ft.toString(n))}lte(t,n){return this.setLimit("max",t,!0,ft.toString(n))}lt(t,n){return this.setLimit("max",t,!1,ft.toString(n))}setLimit(t,n,r,i){return new $a({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ft.toString(i)}]})}_addCheck(t){return new $a({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ft.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ft.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ft.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ft.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:ft.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}$a.create=e=>{var t;return new $a({checks:[],typeName:xt.ZodBigInt,coerce:(t=e==null?void 0:e.coerce)!==null&&t!==void 0?t:!1,...Rt(e)})};class xf extends jt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Je.boolean){const r=this._getOrReturnCtx(t);return Qe(r,{code:Ne.invalid_type,expected:Je.boolean,received:r.parsedType}),Pt}return Ar(t.data)}}xf.create=e=>new xf({typeName:xt.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Rt(e)});class ks extends jt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Je.date){const o=this._getOrReturnCtx(t);return Qe(o,{code:Ne.invalid_type,expected:Je.date,received:o.parsedType}),Pt}if(isNaN(t.data.getTime())){const o=this._getOrReturnCtx(t);return Qe(o,{code:Ne.invalid_date}),Pt}const r=new _r;let i;for(const o of this._def.checks)o.kind==="min"?t.data.getTime()<o.value&&(i=this._getOrReturnCtx(t,i),Qe(i,{code:Ne.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),r.dirty()):o.kind==="max"?t.data.getTime()>o.value&&(i=this._getOrReturnCtx(t,i),Qe(i,{code:Ne.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):nn.assertNever(o);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new ks({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:ft.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:ft.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}ks.create=e=>new ks({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:xt.ZodDate,...Rt(e)});class Rm extends jt{_parse(t){if(this._getType(t)!==Je.symbol){const r=this._getOrReturnCtx(t);return Qe(r,{code:Ne.invalid_type,expected:Je.symbol,received:r.parsedType}),Pt}return Ar(t.data)}}Rm.create=e=>new Rm({typeName:xt.ZodSymbol,...Rt(e)});class Sf extends jt{_parse(t){if(this._getType(t)!==Je.undefined){const r=this._getOrReturnCtx(t);return Qe(r,{code:Ne.invalid_type,expected:Je.undefined,received:r.parsedType}),Pt}return Ar(t.data)}}Sf.create=e=>new Sf({typeName:xt.ZodUndefined,...Rt(e)});class Ef extends jt{_parse(t){if(this._getType(t)!==Je.null){const r=this._getOrReturnCtx(t);return Qe(r,{code:Ne.invalid_type,expected:Je.null,received:r.parsedType}),Pt}return Ar(t.data)}}Ef.create=e=>new Ef({typeName:xt.ZodNull,...Rt(e)});class tu extends jt{constructor(){super(...arguments),this._any=!0}_parse(t){return Ar(t.data)}}tu.create=e=>new tu({typeName:xt.ZodAny,...Rt(e)});class As extends jt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Ar(t.data)}}As.create=e=>new As({typeName:xt.ZodUnknown,...Rt(e)});class zo extends jt{_parse(t){const n=this._getOrReturnCtx(t);return Qe(n,{code:Ne.invalid_type,expected:Je.never,received:n.parsedType}),Pt}}zo.create=e=>new zo({typeName:xt.ZodNever,...Rt(e)});class Mm extends jt{_parse(t){if(this._getType(t)!==Je.undefined){const r=this._getOrReturnCtx(t);return Qe(r,{code:Ne.invalid_type,expected:Je.void,received:r.parsedType}),Pt}return Ar(t.data)}}Mm.create=e=>new Mm({typeName:xt.ZodVoid,...Rt(e)});class Ri extends jt{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==Je.array)return Qe(n,{code:Ne.invalid_type,expected:Je.array,received:n.parsedType}),Pt;if(i.exactLength!==null){const a=n.data.length>i.exactLength.value,s=n.data.length<i.exactLength.value;(a||s)&&(Qe(n,{code:a?Ne.too_big:Ne.too_small,minimum:s?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(Qe(n,{code:Ne.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(Qe(n,{code:Ne.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,s)=>i.type._parseAsync(new uo(n,a,n.path,s)))).then(a=>_r.mergeArray(r,a));const o=[...n.data].map((a,s)=>i.type._parseSync(new uo(n,a,n.path,s)));return _r.mergeArray(r,o)}get element(){return this._def.type}min(t,n){return new Ri({...this._def,minLength:{value:t,message:ft.toString(n)}})}max(t,n){return new Ri({...this._def,maxLength:{value:t,message:ft.toString(n)}})}length(t,n){return new Ri({...this._def,exactLength:{value:t,message:ft.toString(n)}})}nonempty(t){return this.min(1,t)}}Ri.create=(e,t)=>new Ri({type:e,minLength:null,maxLength:null,exactLength:null,typeName:xt.ZodArray,...Rt(t)});function nu(e){if(e instanceof An){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=qo.create(nu(r))}return new An({...e._def,shape:()=>t})}else return e instanceof Ri?new Ri({...e._def,type:nu(e.element)}):e instanceof qo?qo.create(nu(e.unwrap())):e instanceof Is?Is.create(nu(e.unwrap())):e instanceof co?co.create(e.items.map(t=>nu(t))):e}class An extends jt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=nn.objectKeys(t);return this._cached={shape:t,keys:n}}_parse(t){if(this._getType(t)!==Je.object){const c=this._getOrReturnCtx(t);return Qe(c,{code:Ne.invalid_type,expected:Je.object,received:c.parsedType}),Pt}const{status:r,ctx:i}=this._processInputParams(t),{shape:o,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof zo&&this._def.unknownKeys==="strip"))for(const c in i.data)a.includes(c)||s.push(c);const u=[];for(const c of a){const d=o[c],p=i.data[c];u.push({key:{status:"valid",value:c},value:d._parse(new uo(i,p,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof zo){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of s)u.push({key:{status:"valid",value:d},value:{status:"valid",value:i.data[d]}});else if(c==="strict")s.length>0&&(Qe(i,{code:Ne.unrecognized_keys,keys:s}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of s){const p=i.data[d];u.push({key:{status:"valid",value:d},value:c._parse(new uo(i,p,i.path,d)),alwaysSet:d in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of u){const p=await d.key;c.push({key:p,value:await d.value,alwaysSet:d.alwaysSet})}return c}).then(c=>_r.mergeObjectSync(r,c)):_r.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(t){return ft.errToObj,new An({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var i,o,a,s;const u=(a=(o=(i=this._def).errorMap)===null||o===void 0?void 0:o.call(i,n,r).message)!==null&&a!==void 0?a:r.defaultError;return n.code==="unrecognized_keys"?{message:(s=ft.errToObj(t).message)!==null&&s!==void 0?s:u}:{message:u}}}:{}})}strip(){return new An({...this._def,unknownKeys:"strip"})}passthrough(){return new An({...this._def,unknownKeys:"passthrough"})}extend(t){return new An({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new An({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:xt.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new An({...this._def,catchall:t})}pick(t){const n={};return nn.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new An({...this._def,shape:()=>n})}omit(t){const n={};return nn.objectKeys(this.shape).forEach(r=>{t[r]||(n[r]=this.shape[r])}),new An({...this._def,shape:()=>n})}deepPartial(){return nu(this)}partial(t){const n={};return nn.objectKeys(this.shape).forEach(r=>{const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}),new An({...this._def,shape:()=>n})}required(t){const n={};return nn.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])n[r]=this.shape[r];else{let o=this.shape[r];for(;o instanceof qo;)o=o._def.innerType;n[r]=o}}),new An({...this._def,shape:()=>n})}keyof(){return HM(nn.objectKeys(this.shape))}}An.create=(e,t)=>new An({shape:()=>e,unknownKeys:"strip",catchall:zo.create(),typeName:xt.ZodObject,...Rt(t)}),An.strictCreate=(e,t)=>new An({shape:()=>e,unknownKeys:"strict",catchall:zo.create(),typeName:xt.ZodObject,...Rt(t)}),An.lazycreate=(e,t)=>new An({shape:e,unknownKeys:"strip",catchall:zo.create(),typeName:xt.ZodObject,...Rt(t)});class Cf extends jt{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function i(o){for(const s of o)if(s.result.status==="valid")return s.result;for(const s of o)if(s.result.status==="dirty")return n.common.issues.push(...s.ctx.common.issues),s.result;const a=o.map(s=>new Ii(s.ctx.common.issues));return Qe(n,{code:Ne.invalid_union,unionErrors:a}),Pt}if(n.common.async)return Promise.all(r.map(async o=>{const a={...n,common:{...n.common,issues:[]},parent:null};return{result:await o._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(i);{let o;const a=[];for(const u of r){const c={...n,common:{...n.common,issues:[]},parent:null},d=u._parseSync({data:n.data,path:n.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!o&&(o={result:d,ctx:c}),c.common.issues.length&&a.push(c.common.issues)}if(o)return n.common.issues.push(...o.ctx.common.issues),o.result;const s=a.map(u=>new Ii(u));return Qe(n,{code:Ne.invalid_union,unionErrors:s}),Pt}}get options(){return this._def.options}}Cf.create=(e,t)=>new Cf({options:e,typeName:xt.ZodUnion,...Rt(t)});const Nm=e=>e instanceof kf?Nm(e.schema):e instanceof Mi?Nm(e.innerType()):e instanceof Af?[e.value]:e instanceof Ra?e.options:e instanceof Pf?Object.keys(e.enum):e instanceof If?Nm(e._def.innerType):e instanceof Sf?[void 0]:e instanceof Ef?[null]:null;class Dm extends jt{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Je.object)return Qe(n,{code:Ne.invalid_type,expected:Je.object,received:n.parsedType}),Pt;const r=this.discriminator,i=n.data[r],o=this.optionsMap.get(i);return o?n.common.async?o._parseAsync({data:n.data,path:n.path,parent:n}):o._parseSync({data:n.data,path:n.path,parent:n}):(Qe(n,{code:Ne.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Pt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const i=new Map;for(const o of n){const a=Nm(o.shape[t]);if(!a)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const s of a){if(i.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);i.set(s,o)}}return new Dm({typeName:xt.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Rt(r)})}}function N_(e,t){const n=Pa(e),r=Pa(t);if(e===t)return{valid:!0,data:e};if(n===Je.object&&r===Je.object){const i=nn.objectKeys(t),o=nn.objectKeys(e).filter(s=>i.indexOf(s)!==-1),a={...e,...t};for(const s of o){const u=N_(e[s],t[s]);if(!u.valid)return{valid:!1};a[s]=u.data}return{valid:!0,data:a}}else if(n===Je.array&&r===Je.array){if(e.length!==t.length)return{valid:!1};const i=[];for(let o=0;o<e.length;o++){const a=e[o],s=t[o],u=N_(a,s);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return n===Je.date&&r===Je.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Of extends jt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(o,a)=>{if($_(o)||$_(a))return Pt;const s=N_(o.value,a.value);return s.valid?((R_(o)||R_(a))&&n.dirty(),{status:n.value,value:s.data}):(Qe(r,{code:Ne.invalid_intersection_types}),Pt)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,a])=>i(o,a)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Of.create=(e,t,n)=>new Of({left:e,right:t,typeName:xt.ZodIntersection,...Rt(n)});class co extends jt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Je.array)return Qe(r,{code:Ne.invalid_type,expected:Je.array,received:r.parsedType}),Pt;if(r.data.length<this._def.items.length)return Qe(r,{code:Ne.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Pt;!this._def.rest&&r.data.length>this._def.items.length&&(Qe(r,{code:Ne.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const o=[...r.data].map((a,s)=>{const u=this._def.items[s]||this._def.rest;return u?u._parse(new uo(r,a,r.path,s)):null}).filter(a=>!!a);return r.common.async?Promise.all(o).then(a=>_r.mergeArray(n,a)):_r.mergeArray(n,o)}get items(){return this._def.items}rest(t){return new co({...this._def,rest:t})}}co.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new co({items:e,typeName:xt.ZodTuple,rest:null,...Rt(t)})};class Tf extends jt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Je.object)return Qe(r,{code:Ne.invalid_type,expected:Je.object,received:r.parsedType}),Pt;const i=[],o=this._def.keyType,a=this._def.valueType;for(const s in r.data)i.push({key:o._parse(new uo(r,s,r.path,s)),value:a._parse(new uo(r,r.data[s],r.path,s))});return r.common.async?_r.mergeObjectAsync(n,i):_r.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof jt?new Tf({keyType:t,valueType:n,typeName:xt.ZodRecord,...Rt(r)}):new Tf({keyType:$i.create(),valueType:t,typeName:xt.ZodRecord,...Rt(n)})}}class Lm extends jt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Je.map)return Qe(r,{code:Ne.invalid_type,expected:Je.map,received:r.parsedType}),Pt;const i=this._def.keyType,o=this._def.valueType,a=[...r.data.entries()].map(([s,u],c)=>({key:i._parse(new uo(r,s,r.path,[c,"key"])),value:o._parse(new uo(r,u,r.path,[c,"value"]))}));if(r.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const u of a){const c=await u.key,d=await u.value;if(c.status==="aborted"||d.status==="aborted")return Pt;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),s.set(c.value,d.value)}return{status:n.value,value:s}})}else{const s=new Map;for(const u of a){const c=u.key,d=u.value;if(c.status==="aborted"||d.status==="aborted")return Pt;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),s.set(c.value,d.value)}return{status:n.value,value:s}}}}Lm.create=(e,t,n)=>new Lm({valueType:t,keyType:e,typeName:xt.ZodMap,...Rt(n)});class Ps extends jt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Je.set)return Qe(r,{code:Ne.invalid_type,expected:Je.set,received:r.parsedType}),Pt;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(Qe(r,{code:Ne.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(Qe(r,{code:Ne.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const o=this._def.valueType;function a(u){const c=new Set;for(const d of u){if(d.status==="aborted")return Pt;d.status==="dirty"&&n.dirty(),c.add(d.value)}return{status:n.value,value:c}}const s=[...r.data.values()].map((u,c)=>o._parse(new uo(r,u,r.path,c)));return r.common.async?Promise.all(s).then(u=>a(u)):a(s)}min(t,n){return new Ps({...this._def,minSize:{value:t,message:ft.toString(n)}})}max(t,n){return new Ps({...this._def,maxSize:{value:t,message:ft.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Ps.create=(e,t)=>new Ps({valueType:e,minSize:null,maxSize:null,typeName:xt.ZodSet,...Rt(t)});class ru extends jt{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Je.function)return Qe(n,{code:Ne.invalid_type,expected:Je.function,received:n.parsedType}),Pt;function r(s,u){return Im({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Pm(),_f].filter(c=>!!c),issueData:{code:Ne.invalid_arguments,argumentsError:u}})}function i(s,u){return Im({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Pm(),_f].filter(c=>!!c),issueData:{code:Ne.invalid_return_type,returnTypeError:u}})}const o={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof iu){const s=this;return Ar(async function(...u){const c=new Ii([]),d=await s._def.args.parseAsync(u,o).catch(h=>{throw c.addIssue(r(u,h)),c}),p=await Reflect.apply(a,this,d);return await s._def.returns._def.type.parseAsync(p,o).catch(h=>{throw c.addIssue(i(p,h)),c})})}else{const s=this;return Ar(function(...u){const c=s._def.args.safeParse(u,o);if(!c.success)throw new Ii([r(u,c.error)]);const d=Reflect.apply(a,this,c.data),p=s._def.returns.safeParse(d,o);if(!p.success)throw new Ii([i(d,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new ru({...this._def,args:co.create(t).rest(As.create())})}returns(t){return new ru({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new ru({args:t||co.create([]).rest(As.create()),returns:n||As.create(),typeName:xt.ZodFunction,...Rt(r)})}}class kf extends jt{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}kf.create=(e,t)=>new kf({getter:e,typeName:xt.ZodLazy,...Rt(t)});class Af extends jt{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return Qe(n,{received:n.data,code:Ne.invalid_literal,expected:this._def.value}),Pt}return{status:"valid",value:t.data}}get value(){return this._def.value}}Af.create=(e,t)=>new Af({value:e,typeName:xt.ZodLiteral,...Rt(t)});function HM(e,t){return new Ra({values:e,typeName:xt.ZodEnum,...Rt(t)})}class Ra extends jt{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return Qe(n,{expected:nn.joinValues(r),received:n.parsedType,code:Ne.invalid_type}),Pt}if(this._def.values.indexOf(t.data)===-1){const n=this._getOrReturnCtx(t),r=this._def.values;return Qe(n,{received:n.data,code:Ne.invalid_enum_value,options:r}),Pt}return Ar(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t){return Ra.create(t)}exclude(t){return Ra.create(this.options.filter(n=>!t.includes(n)))}}Ra.create=HM;class Pf extends jt{_parse(t){const n=nn.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==Je.string&&r.parsedType!==Je.number){const i=nn.objectValues(n);return Qe(r,{expected:nn.joinValues(i),received:r.parsedType,code:Ne.invalid_type}),Pt}if(n.indexOf(t.data)===-1){const i=nn.objectValues(n);return Qe(r,{received:r.data,code:Ne.invalid_enum_value,options:i}),Pt}return Ar(t.data)}get enum(){return this._def.values}}Pf.create=(e,t)=>new Pf({values:e,typeName:xt.ZodNativeEnum,...Rt(t)});class iu extends jt{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Je.promise&&n.common.async===!1)return Qe(n,{code:Ne.invalid_type,expected:Je.promise,received:n.parsedType}),Pt;const r=n.parsedType===Je.promise?n.data:Promise.resolve(n.data);return Ar(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}iu.create=(e,t)=>new iu({type:e,typeName:xt.ZodPromise,...Rt(t)});class Mi extends jt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===xt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,o={addIssue:a=>{Qe(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){const a=i.transform(r.data,o);return r.common.issues.length?{status:"dirty",value:r.data}:r.common.async?Promise.resolve(a).then(s=>this._def.schema._parseAsync({data:s,path:r.path,parent:r})):this._def.schema._parseSync({data:a,path:r.path,parent:r})}if(i.type==="refinement"){const a=s=>{const u=i.refinement(s,o);if(r.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){const s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Pt:(s.status==="dirty"&&n.dirty(),a(s.value),{status:n.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?Pt:(s.status==="dirty"&&n.dirty(),a(s.value).then(()=>({status:n.value,value:s.value}))))}if(i.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!wf(a))return a;const s=i.transform(a.value,o);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>wf(a)?Promise.resolve(i.transform(a.value,o)).then(s=>({status:n.value,value:s})):a);nn.assertNever(i)}}Mi.create=(e,t,n)=>new Mi({schema:e,typeName:xt.ZodEffects,effect:t,...Rt(n)}),Mi.createWithPreprocess=(e,t,n)=>new Mi({schema:t,effect:{type:"preprocess",transform:e},typeName:xt.ZodEffects,...Rt(n)});class qo extends jt{_parse(t){return this._getType(t)===Je.undefined?Ar(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}qo.create=(e,t)=>new qo({innerType:e,typeName:xt.ZodOptional,...Rt(t)});class Is extends jt{_parse(t){return this._getType(t)===Je.null?Ar(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Is.create=(e,t)=>new Is({innerType:e,typeName:xt.ZodNullable,...Rt(t)});class If extends jt{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===Je.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}If.create=(e,t)=>new If({innerType:e,typeName:xt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Rt(t)});class jm extends jt{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return $m(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ii(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ii(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}jm.create=(e,t)=>new jm({innerType:e,typeName:xt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Rt(t)});class Fm extends jt{_parse(t){if(this._getType(t)!==Je.nan){const r=this._getOrReturnCtx(t);return Qe(r,{code:Ne.invalid_type,expected:Je.nan,received:r.parsedType}),Pt}return{status:"valid",value:t.data}}}Fm.create=e=>new Fm({typeName:xt.ZodNaN,...Rt(e)});const ude=Symbol("zod_brand");class VM extends jt{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class $f extends jt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?Pt:o.status==="dirty"?(n.dirty(),ZM(o.value)):this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Pt:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,n){return new $f({in:t,out:n,typeName:xt.ZodPipeline})}}class Um extends jt{_parse(t){const n=this._def.innerType._parse(t);return wf(n)&&(n.value=Object.freeze(n.value)),n}}Um.create=(e,t)=>new Um({innerType:e,typeName:xt.ZodReadonly,...Rt(t)});const KM=(e,t={},n)=>e?tu.create().superRefine((r,i)=>{var o,a;if(!e(r)){const s=typeof t=="function"?t(r):typeof t=="string"?{message:t}:t,u=(a=(o=s.fatal)!==null&&o!==void 0?o:n)!==null&&a!==void 0?a:!0,c=typeof s=="string"?{message:s}:s;i.addIssue({code:"custom",...c,fatal:u})}}):tu.create(),cde={object:An.lazycreate};var xt;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(xt||(xt={}));const fde=(e,t={message:`Input not instance of ${e.name}`})=>KM(n=>n instanceof e,t),GM=$i.create,YM=Ia.create,dde=Fm.create,pde=$a.create,JM=xf.create,hde=ks.create,mde=Rm.create,gde=Sf.create,yde=Ef.create,vde=tu.create,bde=As.create,_de=zo.create,wde=Mm.create,xde=Ri.create,Sde=An.create,Ede=An.strictCreate,Cde=Cf.create,Ode=Dm.create,Tde=Of.create,kde=co.create,Ade=Tf.create,Pde=Lm.create,Ide=Ps.create,$de=ru.create,Rde=kf.create,Mde=Af.create,Nde=Ra.create,Dde=Pf.create,Lde=iu.create,QM=Mi.create,jde=qo.create,Fde=Is.create,Ude=Mi.createWithPreprocess,Bde=$f.create;var ne=Object.freeze({__proto__:null,defaultErrorMap:_f,setErrorMap:Yfe,getErrorMap:Pm,makeIssue:Im,EMPTY_PATH:Jfe,addIssueToContext:Qe,ParseStatus:_r,INVALID:Pt,DIRTY:ZM,OK:Ar,isAborted:$_,isDirty:R_,isValid:wf,isAsync:$m,get util(){return nn},get objectUtil(){return I_},ZodParsedType:Je,getParsedType:Pa,ZodType:jt,ZodString:$i,ZodNumber:Ia,ZodBigInt:$a,ZodBoolean:xf,ZodDate:ks,ZodSymbol:Rm,ZodUndefined:Sf,ZodNull:Ef,ZodAny:tu,ZodUnknown:As,ZodNever:zo,ZodVoid:Mm,ZodArray:Ri,ZodObject:An,ZodUnion:Cf,ZodDiscriminatedUnion:Dm,ZodIntersection:Of,ZodTuple:co,ZodRecord:Tf,ZodMap:Lm,ZodSet:Ps,ZodFunction:ru,ZodLazy:kf,ZodLiteral:Af,ZodEnum:Ra,ZodNativeEnum:Pf,ZodPromise:iu,ZodEffects:Mi,ZodTransformer:Mi,ZodOptional:qo,ZodNullable:Is,ZodDefault:If,ZodCatch:jm,ZodNaN:Fm,BRAND:ude,ZodBranded:VM,ZodPipeline:$f,ZodReadonly:Um,custom:KM,Schema:jt,ZodSchema:jt,late:cde,get ZodFirstPartyTypeKind(){return xt},coerce:{string:e=>$i.create({...e,coerce:!0}),number:e=>Ia.create({...e,coerce:!0}),boolean:e=>xf.create({...e,coerce:!0}),bigint:e=>$a.create({...e,coerce:!0}),date:e=>ks.create({...e,coerce:!0})},any:vde,array:xde,bigint:pde,boolean:JM,date:hde,discriminatedUnion:Ode,effect:QM,enum:Nde,function:$de,instanceof:fde,intersection:Tde,lazy:Rde,literal:Mde,map:Pde,nan:dde,nativeEnum:Dde,never:_de,null:yde,nullable:Fde,number:YM,object:Sde,oboolean:()=>JM().optional(),onumber:()=>YM().optional(),optional:jde,ostring:()=>GM().optional(),pipeline:Bde,preprocess:Ude,promise:Lde,record:Ade,set:Ide,strictObject:Ede,string:GM,symbol:mde,transformer:QM,tuple:kde,undefined:gde,union:Cde,unknown:bde,void:wde,NEVER:Pt,ZodIssueCode:Ne,quotelessJson:Gfe,ZodError:Ii});const zde=ne.object({type:ne.literal("message_created"),data:ne.object({id:ne.string(),createdAt:ne.string().datetime(),payload:ne.union([ne.object({audioUrl:ne.string().min(1),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("audio")}),ne.object({title:ne.string().min(1),subtitle:ne.string().optional(),imageUrl:ne.string().optional(),actions:ne.array(ne.object({action:ne.enum(["postback","url","say"]),label:ne.string().min(1),value:ne.string().min(1)})),type:ne.literal("card"),className:ne.string().describe("CSS className to apply to the message").optional()}),ne.object({items:ne.array(ne.object({title:ne.string().min(1),subtitle:ne.string().optional(),imageUrl:ne.string().optional(),actions:ne.array(ne.object({action:ne.enum(["postback","url","say"]),label:ne.string().min(1),value:ne.string().min(1)})),className:ne.string().describe("CSS className to apply to the message").optional()})),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("carousel")}),ne.object({text:ne.string(),options:ne.array(ne.object({label:ne.string().min(1),value:ne.string().min(1)})),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("choice"),disableFreeText:ne.boolean().optional()}),ne.object({text:ne.string(),options:ne.array(ne.object({label:ne.string().min(1),value:ne.string().min(1)})),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("dropdown")}),ne.object({fileUrl:ne.string().min(1),title:ne.string().min(1).optional(),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("file")}),ne.object({imageUrl:ne.string().min(1),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("image")}),ne.object({latitude:ne.number(),longitude:ne.number(),address:ne.string().optional(),title:ne.string().optional(),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("location")}),ne.object({markdown:ne.string().min(1),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("markdown")}),ne.object({text:ne.string().min(1),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("text")}),ne.object({videoUrl:ne.string().min(1),className:ne.string().describe("CSS className to apply to the message").optional(),type:ne.literal("video")})]),userId:ne.string(),conversationId:ne.string()})}),qde=ne.object({type:ne.literal("webchat_visibility"),data:ne.object({visibility:ne.enum(["show","hide","toggle"])})}),Zde=ne.object({type:ne.literal("webchat_config"),data:ne.object({config:ne.record(ne.any())})}),Wde=ne.object({type:ne.literal("custom"),data:ne.object({event:ne.record(ne.any())})}),Hde={messageCreated:zde,webchatVisibility:qde,webchatConfig:Zde,custom:Wde},XM="unknown error",eg=class eg extends zM{constructor(n){super();R(this,"_state",{status:"disconnected"});R(this,"connect",async()=>{if(this._state.status==="connected")return;if(this._state.status==="connecting"){await this._state.connectionPromise;return}const n=this._connect();this._state={status:"connecting",connectionPromise:n},await n});R(this,"disconnect",async()=>{if(this._state.status==="disconnected")return;let n;this._state.status==="connecting"?n=await this._state.connectionPromise:n=this._state.source,this._disconnectSync(n)});R(this,"_connect",async()=>{const n=await Kfe(`${this._props.url}/conversations/${this._props.conversationId}/listen`,{headers:{"x-user-key":this._props.userKey}});return n.on("message",this._handleMessage),n.on("error",this._handleError(n)),this._state={status:"connected",source:n},n});R(this,"_disconnectSync",n=>{n.close(),this._state={status:"disconnected"}});R(this,"_handleMessage",n=>{const r=this._parseSignal(n.data);this.emit(r.type,r.data)});R(this,"_handleError",n=>r=>{this._disconnectSync(n);const i=this._toError(r);this.emit("error",i)});R(this,"_parseSignal",n=>{for(const r of Object.values(Hde)){const i=this._safeJsonParse(n),o=r.safeParse(i);if(o.success)return o.data}return{type:"unknown",data:n}});R(this,"_safeJsonParse",n=>{try{return JSON.parse(n)}catch{return n}});R(this,"_toError",n=>{if(n instanceof Error)return n;if(typeof n=="string")return new Error(n);if(n===null)return new Error(XM);if(typeof n=="object"&&"message"in n)return this._toError(n.message);try{const r=JSON.stringify(n);return new Error(r)}catch{return new Error(XM)}});this._props=n}get status(){return this._state.status}};R(eg,"listen",async n=>{const r=new eg(n);return await r.connect(),r});let D_=eg;const eN=100*1024*1024,Vde=eN,Kde=eN,Gde=6e4;class Yde{constructor(t){R(this,"_auto");R(this,"createConversation",t=>this._auto.createConversation(t));R(this,"getConversation",t=>this._auto.getConversation(t));R(this,"deleteConversation",t=>this._auto.deleteConversation(t));R(this,"listConversations",t=>this._auto.listConversations(t));R(this,"listConversationMessages",t=>this._auto.listConversationMessages(t));R(this,"addParticipant",t=>this._auto.addParticipant(t));R(this,"removeParticipant",t=>this._auto.removeParticipant(t));R(this,"getParticipant",t=>this._auto.getParticipant(t));R(this,"listParticipants",t=>this._auto.listParticipants(t));R(this,"createMessage",t=>this._auto.createMessage(t));R(this,"getMessage",t=>this._auto.getMessage(t));R(this,"deleteMessage",t=>this._auto.deleteMessage(t));R(this,"createUser",t=>this._auto.createUser(t));R(this,"getUser",t=>this._auto.getUser(t));R(this,"updateUser",t=>this._auto.updateUser(t));R(this,"deleteUser",t=>this._auto.deleteUser(t));R(this,"createEvent",t=>this._auto.createEvent(t));R(this,"getEvent",t=>this._auto.getEvent(t));R(this,"listenConversation",async({id:t,"x-user-key":n})=>await D_.listen({url:this.props.apiUrl,conversationId:t,userKey:n}));this.props=t;const{apiUrl:n}=t,r={...t.headers},i=t.timeout??Gde,o=aM.create({baseURL:n,headers:r,withCredentials:!0,timeout:i,maxBodyLength:Vde,maxContentLength:Kde});this._auto=new qfe(o)}}const Bm={disconnected:0,user_creating:1,user_created:2,conversation_creating:3,conversation_created:4},hi=(e,t)=>e.status===t,$s=(e,t)=>Bm[e.status]<Bm[t],tN=(e,t)=>Bm[e.status]>=Bm[t];class ou extends Error{constructor(t){super(`Unexpected state: ${t.status}`),this.state=t}}class nN extends Kg{constructor(n){super();R(this,"_client");R(this,"_webhookId");R(this,"_state",{status:"disconnected"});R(this,"mode","pushpin");R(this,"_initialConnect",async n=>{if(tN(this._state,"user_created"))throw new Error("Client is already connected. Please disconnect first.");if(hi(this._state,"user_creating"))return;this._state={status:"user_creating"},console.log("createUser");const{user:{id:r},key:i}=await this._client.createUser({name:void 0,pictureUrl:void 0,userData:n});return this._state={status:"user_created",userId:r,userKey:i},{userId:r,userToken:i}});R(this,"_reConnect",async(n,r)=>{if(tN(this._state,"user_created")){if(this._state.userId!==n.userId)throw new Error("Client is already connected. Please disconnect first.");return n}return hi(this._state,"user_creating")||(this._state={status:"user_created",userId:n.userId,userKey:n.userToken},console.log("updateUser"),await this._client.updateUser({"x-user-key":n.userToken,name:void 0,pictureUrl:void 0,userData:r})),n});R(this,"_mapMessage",n=>{const{payload:r,disableInput:i}=Gse(n.payload);return{id:n.id,conversationId:n.conversationId,authorId:n.userId,sentOn:new Date(n.createdAt),payload:r,disableInput:i}});const r=`${n.apiUrl}/${n.clientId}`;this._webhookId=n.clientId,this._client=new Yde({apiUrl:r})}get clientId(){return this._webhookId}get userId(){if(!$s(this._state,"user_created"))return this._state.userId}get conversationId(){if(!$s(this._state,"conversation_created"))return this._state.conversationId}async connect(n,r){return n?await this.userExists(n)?this._reConnect(n,r):this._initialConnect(r):this._initialConnect(r)}async disconnect(){hi(this._state,"conversation_created")?this._state.signalEmitter.cleanup():hi(this._state,"conversation_creating")&&console.warn("zombie conversation..."),this._state={status:"disconnected"}}async sendMessage(n){if($s(this._state,"user_created"))throw new ou(this._state);if(hi(this._state,"conversation_creating"))throw new ou(this._state);let r;hi(this._state,"conversation_created")?r=this._state:(this._state={status:"conversation_creating",userId:this._state.userId,userKey:this._state.userKey},r=await this._createNewConversation(this._state)),console.log("createMessage"),await this._client.createMessage({"x-user-key":r.userKey,conversationId:r.conversationId,payload:{type:"text",text:n}}),this.emit("messageSent",n)}async sendEvent(n){if($s(this._state,"user_created"))throw new ou(this._state);if(hi(this._state,"conversation_creating"))throw new ou(this._state);let r;hi(this._state,"conversation_created")?r=this._state:(this._state={status:"conversation_creating",userId:this._state.userId,userKey:this._state.userKey},r=await this._createNewConversation(this._state)),console.log("createEvent"),await this._client.createEvent({"x-user-key":r.userKey,conversationId:r.conversationId,payload:{type:"custom",data:n}})}async switchConversation(n){if($s(this._state,"user_created"))throw new ou(this._state);hi(this._state,"conversation_created")&&this._state.conversationId===n||hi(this._state,"conversation_creating")||(this._state={status:"conversation_creating",userId:this._state.userId,userKey:this._state.userKey},await this._connectConversation(this._state,n))}async conversationExists(n){if($s(this._state,"user_created"))return!1;try{return await this._client.getConversation({"x-user-key":this._state.userKey,id:n}),!0}catch(r){if(A_(r)&&r.code===404)return!1;throw r}}async userExists({userToken:n}){try{return await this._client.getUser({"x-user-key":n}),!0}catch(r){const i=o=>o.code===404||o.code===401;if(A_(r)&&i(r))return!1;throw r}}async newConversation(){if($s(this._state,"user_created"))throw new ou(this._state);hi(this._state,"conversation_creating")||(this._state={status:"conversation_creating",userId:this._state.userId,userKey:this._state.userKey},await this._createNewConversation(this._state))}async _createNewConversation(n){console.log("createConversation");const{conversation:{id:r}}=await this._client.createConversation({"x-user-key":n.userKey}),i=await this._connectConversation(n,r);return await this._client.createEvent({"x-user-key":n.userKey,conversationId:r,payload:{type:"conversation_started",data:{}}}),i}async listMessages(){if(!hi(this._state,"conversation_created"))return[];const{conversationId:n,userKey:r}=this._state,i=[];let o;do{const a=await this._client.listConversationMessages({id:n,"x-user-key":r,nextToken:o});i.push(...a.messages),o=a.meta.nextToken}while(o);return i.map(this._mapMessage)}async _connectConversation(n,r){const i=await this._client.listenConversation({id:r,"x-user-key":n.userKey});return i.on("unknown",o=>console.log("unknown event",o)),i.on("message_created",o=>{o.userId!==n.userId&&this.emit("message",this._mapMessage(o))}),i.on("error",()=>{this._state={status:"user_created",userId:n.userId,userKey:n.userKey},this.emit("error",new Error("Connection to conversation lost"))}),i.on("webchat_visibility",o=>{this.emit("webchatVisibility",o.visibility)}),i.on("webchat_config",o=>{this.emit("webchatConfig",o.config)}),i.on("custom",o=>{this.emit("customEvent",o.event)}),this.emit("conversation",r),this._state={status:"conversation_created",userId:n.userId,userKey:n.userKey,conversationId:r,signalEmitter:i},this._state}}const Jde=({clientId:e,apiUrl:t="https://webchat.botpress.cloud",mode:n="pushpin"})=>{const[r,i]=T.useState();return T.useEffect(()=>{const o=n==="messaging"?new PR({url:t,clientId:e}):new nN({apiUrl:t,clientId:e});i(o)},[e,t,n]),r},rN=T.memo(T.forwardRef((e,t)=>{const{state:n,theme:{composer:r},client:i}=fn(),[o,a]=T.useState(""),[s,u]=T.useState(-1);if(n.isReadOnly||!i)return null;const c=()=>{o&&(i.sendMessage(o),a(""),u(-1))};return X.jsx(OS.Provider,{value:{value:o,setValue:a,historyIndex:s,setHistoryIndex:u,sendMessage:c},children:X.jsx("div",{"data-disabled":n.disableComposer,...e,...r==null?void 0:r.container,ref:t})})})),iN=T.memo(({...e})=>{const{state:t,theme:{composer:n}}=fn(),{value:r,setValue:i,historyIndex:o,setHistoryIndex:a,sendMessage:s}=TS(),u=T.useRef(null),c=ha(p=>p.user),d=ha(p=>p.messageHistory);return T.useEffect(()=>{u.current&&(u.current.selectionStart=u.current.value.length,u.current.selectionEnd=u.current.value.length)},[r]),X.jsx("textarea",{...n==null?void 0:n.input,disabled:t.disableComposer,ref:u,value:r,"data-has-value":!!r,onChange:p=>i(p.target.value),onKeyDown:p=>{if(!t.disableComposer){if(p.key==="Enter"&&(p.preventDefault(),s()),p.key==="ArrowUp"){p.preventDefault();const m=d[(c==null?void 0:c.userId)??""]??[];o<m.length-1&&i(m[o+1]),a(()=>Math.min(o+1,m.length-1))}if(p.key==="ArrowDown"){p.preventDefault();const m=d[(c==null?void 0:c.userId)??""]??[];i(o===0?"":m[o-1]),a(()=>Math.max(o-1,-1))}}},...e})}),oN=T.memo(T.forwardRef(({icon:e=X4,...t},n)=>{var a,s;const{value:r,sendMessage:i}=TS(),{theme:{composer:o}}=fn();return X.jsx("button",{ref:n,...t,...(a=o==null?void 0:o.button)==null?void 0:a.container,disabled:!r,onClick:i,children:X.jsx(e,{...(s=o==null?void 0:o.button)==null?void 0:s.icon})})})),aN=({children:e})=>{const[t,n]=T.useState(!1),[r,i]=T.useState(""),[o,a]=T.useState(null),s=({title:c,content:d})=>{i(c),a(d),n(!0)},u=()=>{n(!1)};return X.jsxs(AS.Provider,{value:{hideModal:u,showModal:s,title:r,content:o,open:t},children:[X.jsx(Na,{open:t,onOpenChange:n,children:X.jsx(Na.Content,{title:r,children:o})}),e]})},Qde=({theme:e={},renderers:t,client:n,children:r,configuration:i={},userData:o,closeWindow:a,...s})=>{const[u,c]=T.useState(0),[d,p]=T.useState([]),[m,h]=T.useState({disableComposer:!1,...s.defaultState,connected:!0}),[y,v]=T.useState(i),[x,b]=T.useState(e),w=ha($=>$.addMessageToHistory),S=ha($=>$.setConversationId),P=ha($=>$.user),k=ha($=>$.conversationId),C=ha($=>$.setUser),L=ha($=>$.setClientMode),q=T.useRef(null),G={...s,value:{theme:x,renderers:{...vv,...t},messages:d,messageContainerRef:q,setMessages:p,eventEmitter:VL,configuration:i,setConfiguration:v,state:m,closeWindow:a,setState:$=>h({...m,...$}),setTheme:$=>{b($)},client:n?{...n,sendMessage:async $=>{await n.sendMessage($),p(z=>[...z,{direction:"outgoing",sender:{name:"You"},timestamp:new Date,disableInput:!1,block:{type:"bubble",block:{type:"text",text:$}}}]),n.userId&&w({message:$,userId:n.userId})},on:n.on,restartConversation:async()=>{await n.newConversation(),p([])}}:void 0}};return ts(()=>{n&&L(n.mode)}),ts(()=>{if(n)return n.on("message",$=>{try{const{payload:z,disableInput:ee}=$;p(Y=>[...Y,{direction:"incoming",sender:{name:y.botName??"Bot",avatar:y.botAvatar},timestamp:new Date($.sentOn),block:z,disableInput:ee}])}catch{console.error("Invalid message payload")}})}),Ov(async()=>{if(n)return n.on("error",()=>{console.log("client disconnected"),c($=>$+1)})}),ts(()=>{if(n)return n.on("conversation",$=>{S($)})}),Ov(async()=>{if(!n)return;let $;try{$=await n.connect(P,o),h(ee=>({...ee,connected:!0}))}catch{h(Y=>({...Y,connected:!1}));return}C($),k&&await n.conversationExists(k)?await n.switchConversation(k):await n.newConversation();const z=[];for(const ee of await n.listMessages())try{const{payload:Y,authorId:te,sentOn:K,disableInput:Q}=ee,ae=te===n.userId?"outgoing":"incoming";z.push({direction:ae,sender:ae==="outgoing"?{name:"You"}:{name:y.botName??"Bot",avatar:y.botAvatar},timestamp:new Date(K),block:Y,disableInput:Q})}catch{console.error("Invalid message payload")}return p(z.reverse()),()=>{n.disconnect()}},[u]),X.jsx(IS.Provider,{...G,children:typeof r=="function"?r(y):r})};function Zo(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}const Xde=F["useId".toString()]||(()=>{});let epe=0;function zm(e){const[t,n]=F.useState(Xde());return Tu(()=>{e||n(r=>r??String(epe++))},[e]),e||(t?`radix-${t}`:"")}function sN({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,i]=tpe({defaultProp:t,onChange:n}),o=e!==void 0,a=o?e:r,s=na(n),u=T.useCallback(c=>{if(o){const p=typeof c=="function"?c(e):c;p!==e&&s(p)}else i(c)},[o,e,i,s]);return[a,u]}function tpe({defaultProp:e,onChange:t}){const n=T.useState(e),[r]=n,i=T.useRef(r),o=na(t);return T.useEffect(()=>{i.current!==r&&(o(r),i.current=r)},[r,i,o]),n}function npe(e,t=globalThis==null?void 0:globalThis.document){const n=na(e);T.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return t.addEventListener("keydown",r),()=>t.removeEventListener("keydown",r)},[n,t])}const L_="dismissableLayer.update",rpe="dismissableLayer.pointerDownOutside",ipe="dismissableLayer.focusOutside";let lN;const ope=T.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ape=T.forwardRef((e,t)=>{var n;const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:s,onDismiss:u,...c}=e,d=T.useContext(ope),[p,m]=T.useState(null),h=(n=p==null?void 0:p.ownerDocument)!==null&&n!==void 0?n:globalThis==null?void 0:globalThis.document,[,y]=T.useState({}),v=Wa(t,q=>m(q)),x=Array.from(d.layers),[b]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),w=x.indexOf(b),S=p?x.indexOf(p):-1,P=d.layersWithOutsidePointerEventsDisabled.size>0,k=S>=w,C=spe(q=>{const G=q.target,$=[...d.branches].some(z=>z.contains(G));!k||$||(o==null||o(q),s==null||s(q),q.defaultPrevented||u==null||u())},h),L=lpe(q=>{const G=q.target;[...d.branches].some(z=>z.contains(G))||(a==null||a(q),s==null||s(q),q.defaultPrevented||u==null||u())},h);return npe(q=>{S===d.layers.size-1&&(i==null||i(q),!q.defaultPrevented&&u&&(q.preventDefault(),u()))},h),T.useEffect(()=>{if(p)return r&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(lN=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(p)),d.layers.add(p),uN(),()=>{r&&d.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=lN)}},[p,h,r,d]),T.useEffect(()=>()=>{p&&(d.layers.delete(p),d.layersWithOutsidePointerEventsDisabled.delete(p),uN())},[p,d]),T.useEffect(()=>{const q=()=>y({});return document.addEventListener(L_,q),()=>document.removeEventListener(L_,q)},[]),T.createElement(ai.div,En({},c,{ref:v,style:{pointerEvents:P?k?"auto":"none":void 0,...e.style},onFocusCapture:Zo(e.onFocusCapture,L.onFocusCapture),onBlurCapture:Zo(e.onBlurCapture,L.onBlurCapture),onPointerDownCapture:Zo(e.onPointerDownCapture,C.onPointerDownCapture)}))});function spe(e,t=globalThis==null?void 0:globalThis.document){const n=na(e),r=T.useRef(!1),i=T.useRef(()=>{});return T.useEffect(()=>{const o=s=>{if(s.target&&!r.current){let c=function(){cN(rpe,n,u,{discrete:!0})};const u={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",i.current),i.current=c,t.addEventListener("click",i.current,{once:!0})):c()}r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",o),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function lpe(e,t=globalThis==null?void 0:globalThis.document){const n=na(e),r=T.useRef(!1);return T.useEffect(()=>{const i=o=>{o.target&&!r.current&&cN(ipe,n,{originalEvent:o},{discrete:!1})};return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function uN(){const e=new CustomEvent(L_);document.dispatchEvent(e)}function cN(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?BL(i,o):i.dispatchEvent(o)}const j_="focusScope.autoFocusOnMount",F_="focusScope.autoFocusOnUnmount",fN={bubbles:!1,cancelable:!0},upe=T.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:o,...a}=e,[s,u]=T.useState(null),c=na(i),d=na(o),p=T.useRef(null),m=Wa(t,v=>u(v)),h=T.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;T.useEffect(()=>{if(r){let v=function(S){if(h.paused||!s)return;const P=S.target;s.contains(P)?p.current=P:Ma(p.current,{select:!0})},x=function(S){if(h.paused||!s)return;const P=S.relatedTarget;P!==null&&(s.contains(P)||Ma(p.current,{select:!0}))},b=function(S){const P=document.activeElement;for(const k of S)k.removedNodes.length>0&&(s!=null&&s.contains(P)||Ma(s))};document.addEventListener("focusin",v),document.addEventListener("focusout",x);const w=new MutationObserver(b);return s&&w.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",x),w.disconnect()}}},[r,s,h.paused]),T.useEffect(()=>{if(s){hN.add(h);const v=document.activeElement;if(!s.contains(v)){const b=new CustomEvent(j_,fN);s.addEventListener(j_,c),s.dispatchEvent(b),b.defaultPrevented||(cpe(mpe(dN(s)),{select:!0}),document.activeElement===v&&Ma(s))}return()=>{s.removeEventListener(j_,c),setTimeout(()=>{const b=new CustomEvent(F_,fN);s.addEventListener(F_,d),s.dispatchEvent(b),b.defaultPrevented||Ma(v??document.body,{select:!0}),s.removeEventListener(F_,d),hN.remove(h)},0)}}},[s,c,d,h]);const y=T.useCallback(v=>{if(!n&&!r||h.paused)return;const x=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,b=document.activeElement;if(x&&b){const w=v.currentTarget,[S,P]=fpe(w);S&&P?!v.shiftKey&&b===P?(v.preventDefault(),n&&Ma(S,{select:!0})):v.shiftKey&&b===S&&(v.preventDefault(),n&&Ma(P,{select:!0})):b===w&&v.preventDefault()}},[n,r,h.paused]);return T.createElement(ai.div,En({tabIndex:-1},a,{ref:m,onKeyDown:y}))});function cpe(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ma(r,{select:t}),document.activeElement!==n)return}function fpe(e){const t=dN(e),n=pN(t,e),r=pN(t.reverse(),e);return[n,r]}function dN(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function pN(e,t){for(const n of e)if(!dpe(n,{upTo:t}))return n}function dpe(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function ppe(e){return e instanceof HTMLInputElement&&"select"in e}function Ma(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&ppe(e)&&t&&e.select()}}const hN=hpe();function hpe(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=mN(e,t),e.unshift(t)},remove(t){var n;e=mN(e,t),(n=e[0])===null||n===void 0||n.resume()}}}function mN(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function mpe(e){return e.filter(t=>t.tagName!=="A")}function gpe(e,t){return T.useReducer((n,r)=>{const i=t[n][r];return i??n},e)}const qm=e=>{const{present:t,children:n}=e,r=ype(t),i=typeof n=="function"?n({present:r.isPresent}):T.Children.only(n),o=Wa(r.ref,i.ref);return typeof n=="function"||r.isPresent?T.cloneElement(i,{ref:o}):null};qm.displayName="Presence";function ype(e){const[t,n]=T.useState(),r=T.useRef({}),i=T.useRef(e),o=T.useRef("none"),a=e?"mounted":"unmounted",[s,u]=gpe(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return T.useEffect(()=>{const c=Zm(r.current);o.current=s==="mounted"?c:"none"},[s]),Tu(()=>{const c=r.current,d=i.current;if(d!==e){const m=o.current,h=Zm(c);e?u("MOUNT"):h==="none"||(c==null?void 0:c.display)==="none"?u("UNMOUNT"):u(d&&m!==h?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,u]),Tu(()=>{if(t){const c=p=>{const h=Zm(r.current).includes(p.animationName);p.target===t&&h&&zi.flushSync(()=>u("ANIMATION_END"))},d=p=>{p.target===t&&(o.current=Zm(r.current))};return t.addEventListener("animationstart",d),t.addEventListener("animationcancel",c),t.addEventListener("animationend",c),()=>{t.removeEventListener("animationstart",d),t.removeEventListener("animationcancel",c),t.removeEventListener("animationend",c)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:T.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function Zm(e){return(e==null?void 0:e.animationName)||"none"}let U_=0;function vpe(){T.useEffect(()=>{var e,t;const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",(e=n[0])!==null&&e!==void 0?e:gN()),document.body.insertAdjacentElement("beforeend",(t=n[1])!==null&&t!==void 0?t:gN()),U_++,()=>{U_===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(r=>r.remove()),U_--}},[])}function gN(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.cssText="outline: none; opacity: 0; position: fixed; pointer-events: none",e}var Wm="right-scroll-bar-position",Hm="width-before-scroll-bar",bpe="with-scroll-bars-hidden",_pe="--removed-body-scroll-bar-size";function wpe(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function xpe(e,t){var n=T.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=t,n.facade}function Spe(e,t){return xpe(t||null,function(n){return e.forEach(function(r){return wpe(r,n)})})}function Epe(e){return e}function Cpe(e,t){t===void 0&&(t=Epe);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(o){var a=t(o,r);return n.push(a),function(){n=n.filter(function(s){return s!==a})}},assignSyncMedium:function(o){for(r=!0;n.length;){var a=n;n=[],a.forEach(o)}n={push:function(s){return o(s)},filter:function(){return n}}},assignMedium:function(o){r=!0;var a=[];if(n.length){var s=n;n=[],s.forEach(o),a=n}var u=function(){var d=a;a=[],d.forEach(o)},c=function(){return Promise.resolve().then(u)};c(),n={push:function(d){a.push(d),c()},filter:function(d){return a=a.filter(d),n}}}};return i}function Ope(e){e===void 0&&(e={});var t=Cpe(null);return t.options=ui({async:!0,ssr:!1},e),t}var yN=function(e){var t=e.sideCar,n=oC(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return F.createElement(r,ui({},n))};yN.isSideCarExport=!0;function Tpe(e,t){return e.useMedium(t),yN}var vN=Ope(),B_=function(){},Vm=F.forwardRef(function(e,t){var n=F.useRef(null),r=F.useState({onScrollCapture:B_,onWheelCapture:B_,onTouchMoveCapture:B_}),i=r[0],o=r[1],a=e.forwardProps,s=e.children,u=e.className,c=e.removeScrollBar,d=e.enabled,p=e.shards,m=e.sideCar,h=e.noIsolation,y=e.inert,v=e.allowPinchZoom,x=e.as,b=x===void 0?"div":x,w=oC(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as"]),S=m,P=Spe([n,t]),k=ui(ui({},w),i);return F.createElement(F.Fragment,null,d&&F.createElement(S,{sideCar:vN,removeScrollBar:c,shards:p,noIsolation:h,inert:y,setCallbacks:o,allowPinchZoom:!!v,lockRef:n}),a?F.cloneElement(F.Children.only(s),ui(ui({},k),{ref:P})):F.createElement(b,ui({},k,{className:u,ref:P}),s))});Vm.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Vm.classNames={fullWidth:Hm,zeroRight:Wm};var bN,kpe=function(){if(bN)return bN;if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Ape(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=kpe();return t&&e.setAttribute("nonce",t),e}function Ppe(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ipe(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var $pe=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Ape())&&(Ppe(t,n),Ipe(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Rpe=function(){var e=$pe();return function(t,n){F.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},_N=function(){var e=Rpe(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},Mpe={left:0,top:0,right:0,gap:0},z_=function(e){return parseInt(e||"",10)||0},Npe=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[z_(n),z_(r),z_(i)]},Dpe=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Mpe;var t=Npe(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Lpe=_N(),jpe=function(e,t,n,r){var i=e.left,o=e.top,a=e.right,s=e.gap;return n===void 0&&(n="margin"),`
472
472
  .`.concat(bpe,` {
473
473
  overflow: hidden `).concat(r,`;
474
474
  padding-right: `).concat(s,"px ").concat(r,`;
@@ -508,4 +508,4 @@ ${d}`:d,{ast:c,isPatternProperty:!1,isRequired:(0,to.includes)(e.required||[],u)
508
508
  `)},Fpe=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r,o=F.useMemo(function(){return Dpe(i)},[i]);return F.createElement(Lpe,{styles:jpe(o,!t,i,n?"":"!important")})},q_=!1;if(typeof window<"u")try{var Km=Object.defineProperty({},"passive",{get:function(){return q_=!0,!0}});window.addEventListener("test",Km,Km),window.removeEventListener("test",Km,Km)}catch{q_=!1}var au=q_?{passive:!1}:!1,Upe=function(e){return e.tagName==="TEXTAREA"},wN=function(e,t){var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Upe(e)&&n[t]==="visible")},Bpe=function(e){return wN(e,"overflowY")},zpe=function(e){return wN(e,"overflowX")},xN=function(e,t){var n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var r=SN(e,n);if(r){var i=EN(e,n),o=i[1],a=i[2];if(o>a)return!0}n=n.parentNode}while(n&&n!==document.body);return!1},qpe=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Zpe=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},SN=function(e,t){return e==="v"?Bpe(t):zpe(t)},EN=function(e,t){return e==="v"?qpe(t):Zpe(t)},Wpe=function(e,t){return e==="h"&&t==="rtl"?-1:1},Hpe=function(e,t,n,r,i){var o=Wpe(e,window.getComputedStyle(t).direction),a=o*r,s=n.target,u=t.contains(s),c=!1,d=a>0,p=0,m=0;do{var h=EN(e,s),y=h[0],v=h[1],x=h[2],b=v-x-o*y;(y||b)&&SN(e,s)&&(p+=b,m+=y),s=s.parentNode}while(!u&&s!==document.body||u&&(t.contains(s)||t===s));return(d&&(i&&p===0||!i&&a>p)||!d&&(i&&m===0||!i&&-a>m))&&(c=!0),c},Gm=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},CN=function(e){return[e.deltaX,e.deltaY]},ON=function(e){return e&&"current"in e?e.current:e},Vpe=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Kpe=function(e){return`
509
509
  .block-interactivity-`.concat(e,` {pointer-events: none;}
510
510
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
511
- `)},Gpe=0,su=[];function Ype(e){var t=F.useRef([]),n=F.useRef([0,0]),r=F.useRef(),i=F.useState(Gpe++)[0],o=F.useState(function(){return _N()})[0],a=F.useRef(e);F.useEffect(function(){a.current=e},[e]),F.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var v=Vq([e.lockRef.current],(e.shards||[]).map(ON),!0).filter(Boolean);return v.forEach(function(x){return x.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),v.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var s=F.useCallback(function(v,x){if("touches"in v&&v.touches.length===2)return!a.current.allowPinchZoom;var b=Gm(v),w=n.current,S="deltaX"in v?v.deltaX:w[0]-b[0],P="deltaY"in v?v.deltaY:w[1]-b[1],k,C=v.target,L=Math.abs(S)>Math.abs(P)?"h":"v";if("touches"in v&&L==="h"&&C.type==="range")return!1;var q=xN(L,C);if(!q)return!0;if(q?k=L:(k=L==="v"?"h":"v",q=xN(L,C)),!q)return!1;if(!r.current&&"changedTouches"in v&&(S||P)&&(r.current=k),!k)return!0;var G=r.current||k;return Hpe(G,x,v,G==="h"?S:P,!0)},[]),u=F.useCallback(function(v){var x=v;if(!(!su.length||su[su.length-1]!==o)){var b="deltaY"in x?CN(x):Gm(x),w=t.current.filter(function(k){return k.name===x.type&&k.target===x.target&&Vpe(k.delta,b)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var S=(a.current.shards||[]).map(ON).filter(Boolean).filter(function(k){return k.contains(x.target)}),P=S.length>0?s(x,S[0]):!a.current.noIsolation;P&&x.cancelable&&x.preventDefault()}}},[]),c=F.useCallback(function(v,x,b,w){var S={name:v,delta:x,target:b,should:w};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(P){return P!==S})},1)},[]),d=F.useCallback(function(v){n.current=Gm(v),r.current=void 0},[]),p=F.useCallback(function(v){c(v.type,CN(v),v.target,s(v,e.lockRef.current))},[]),m=F.useCallback(function(v){c(v.type,Gm(v),v.target,s(v,e.lockRef.current))},[]);F.useEffect(function(){return su.push(o),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",u,au),document.addEventListener("touchmove",u,au),document.addEventListener("touchstart",d,au),function(){su=su.filter(function(v){return v!==o}),document.removeEventListener("wheel",u,au),document.removeEventListener("touchmove",u,au),document.removeEventListener("touchstart",d,au)}},[]);var h=e.removeScrollBar,y=e.inert;return F.createElement(F.Fragment,null,y?F.createElement(o,{styles:Kpe(i)}):null,h?F.createElement(Fpe,{gapMode:"margin"}):null)}const Jpe=Tpe(vN,Ype);var TN=F.forwardRef(function(e,t){return F.createElement(Vm,ui({},e,{ref:t,sideCar:Jpe}))});TN.classNames=Vm.classNames;const Qpe=TN;var Xpe=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},lu=new WeakMap,Ym=new WeakMap,Jm={},Z_=0,kN=function(e){return e&&(e.host||kN(e.parentNode))},ehe=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=kN(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},the=function(e,t,n,r){var i=ehe(t,Array.isArray(e)?e:[e]);Jm[n]||(Jm[n]=new WeakMap);var o=Jm[n],a=[],s=new Set,u=new Set(i),c=function(p){!p||s.has(p)||(s.add(p),c(p.parentNode))};i.forEach(c);var d=function(p){!p||u.has(p)||Array.prototype.forEach.call(p.children,function(m){if(s.has(m))d(m);else{var h=m.getAttribute(r),y=h!==null&&h!=="false",v=(lu.get(m)||0)+1,x=(o.get(m)||0)+1;lu.set(m,v),o.set(m,x),a.push(m),v===1&&y&&Ym.set(m,!0),x===1&&m.setAttribute(n,"true"),y||m.setAttribute(r,"true")}})};return d(t),s.clear(),Z_++,function(){a.forEach(function(p){var m=lu.get(p)-1,h=o.get(p)-1;lu.set(p,m),o.set(p,h),m||(Ym.has(p)||p.removeAttribute(r),Ym.delete(p)),h||p.removeAttribute(n)}),Z_--,Z_||(lu=new WeakMap,lu=new WeakMap,Ym=new WeakMap,Jm={})}},nhe=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=t||Xpe(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live]"))),the(r,i,n,"aria-hidden")):function(){return null}};const AN="Dialog",[PN,wxe]=Wg(AN),[rhe,Wo]=PN(AN),ihe=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:a=!0}=e,s=T.useRef(null),u=T.useRef(null),[c=!1,d]=sN({prop:r,defaultProp:i,onChange:o});return T.createElement(rhe,{scope:t,triggerRef:s,contentRef:u,contentId:zm(),titleId:zm(),descriptionId:zm(),open:c,onOpenChange:d,onOpenToggle:T.useCallback(()=>d(p=>!p),[d]),modal:a},n)},ohe="DialogTrigger",ahe=T.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Wo(ohe,n),o=Wa(t,i.triggerRef);return T.createElement(ai.button,En({type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":H_(i.open)},r,{ref:o,onClick:Zo(e.onClick,i.onOpenToggle)}))}),she="DialogPortal",[xxe,IN]=PN(she,{forceMount:void 0}),W_="DialogOverlay",lhe=T.forwardRef((e,t)=>{const n=IN(W_,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=Wo(W_,e.__scopeDialog);return o.modal?T.createElement(qm,{present:r||o.open},T.createElement(uhe,En({},i,{ref:t}))):null}),uhe=T.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Wo(W_,n);return T.createElement(Qpe,{as:Hg,allowPinchZoom:!0,shards:[i.contentRef]},T.createElement(ai.div,En({"data-state":H_(i.open)},r,{ref:t,style:{pointerEvents:"auto",...r.style}})))}),Rf="DialogContent",che=T.forwardRef((e,t)=>{const n=IN(Rf,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=Wo(Rf,e.__scopeDialog);return T.createElement(qm,{present:r||o.open},o.modal?T.createElement(fhe,En({},i,{ref:t})):T.createElement(dhe,En({},i,{ref:t})))}),fhe=T.forwardRef((e,t)=>{const n=Wo(Rf,e.__scopeDialog),r=T.useRef(null),i=Wa(t,n.contentRef,r);return T.useEffect(()=>{const o=r.current;if(o)return nhe(o)},[]),T.createElement($N,En({},e,{ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Zo(e.onCloseAutoFocus,o=>{var a;o.preventDefault(),(a=n.triggerRef.current)===null||a===void 0||a.focus()}),onPointerDownOutside:Zo(e.onPointerDownOutside,o=>{const a=o.detail.originalEvent,s=a.button===0&&a.ctrlKey===!0;(a.button===2||s)&&o.preventDefault()}),onFocusOutside:Zo(e.onFocusOutside,o=>o.preventDefault())}))}),dhe=T.forwardRef((e,t)=>{const n=Wo(Rf,e.__scopeDialog),r=T.useRef(!1),i=T.useRef(!1);return T.createElement($N,En({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var a;if((a=e.onCloseAutoFocus)===null||a===void 0||a.call(e,o),!o.defaultPrevented){var s;r.current||(s=n.triggerRef.current)===null||s===void 0||s.focus(),o.preventDefault()}r.current=!1,i.current=!1},onInteractOutside:o=>{var a,s;(a=e.onInteractOutside)===null||a===void 0||a.call(e,o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const u=o.target;((s=n.triggerRef.current)===null||s===void 0?void 0:s.contains(u))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}}))}),$N=T.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,...a}=e,s=Wo(Rf,n),u=T.useRef(null),c=Wa(t,u);return vpe(),T.createElement(T.Fragment,null,T.createElement(upe,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o},T.createElement(ape,En({role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":H_(s.open)},a,{ref:c,onDismiss:()=>s.onOpenChange(!1)}))),!1)}),phe="DialogTitle",hhe=T.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Wo(phe,n);return T.createElement(ai.h2,En({id:i.titleId},r,{ref:t}))}),mhe="DialogClose",ghe=T.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Wo(mhe,n);return T.createElement(ai.button,En({type:"button"},r,{ref:t,onClick:Zo(e.onClick,()=>i.onOpenChange(!1))}))});function H_(e){return e?"open":"closed"}const yhe=ihe,vhe=ahe,bhe=lhe,_he=che,whe=hhe,RN=ghe;function xhe({title:e,titleId:t,...n},r){return F.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",ref:r,"aria-labelledby":t},n),e?F.createElement("title",{id:t},e):null,F.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"}))}const MN=F.forwardRef(xhe);function Na({open:e,onOpenChange:t,children:n}){return X.jsx(yhe,{open:e,onOpenChange:t,children:n})}function She({title:e,children:t}){var r,i,o,a,s,u,c,d;const{theme:{modal:n}}=fn();return X.jsxs(X.Fragment,{children:[X.jsx(bhe,{...n==null?void 0:n.overlay}),X.jsx("div",{...n==null?void 0:n.container,children:X.jsxs(_he,{...(r=n==null?void 0:n.dialog)==null?void 0:r.container,children:[X.jsxs("div",{...(o=(i=n==null?void 0:n.dialog)==null?void 0:i.title)==null?void 0:o.container,children:[X.jsx(whe,{...(s=(a=n==null?void 0:n.dialog)==null?void 0:a.title)==null?void 0:s.text,children:e}),X.jsx(RN,{children:X.jsx(MN,{role:"button",tabIndex:0,...(c=(u=n==null?void 0:n.dialog)==null?void 0:u.title)==null?void 0:c.closeIcon})})]}),X.jsx("div",{...(d=n==null?void 0:n.dialog)==null?void 0:d.content,children:t})]})})]})}Na.Button=vhe,Na.Close=RN,Na.Content=She;const NN=T.forwardRef(({children:e,...t},n)=>{const{theme:{container:r}}=fn();return X.jsxs("div",{...t,...r,ref:n,children:[X.jsx(m4,{}),X.jsxs(aN,{children:[X.jsx(Ehe,{}),e]})]})}),Ehe=()=>{const{theme:{modal:e},state:{connected:t}}=fn(),{showModal:n}=PS();return T.useEffect(()=>{var r,i,o,a;t||n({title:"Connection Error",content:X.jsxs(X.Fragment,{children:[X.jsx("p",{...(i=(r=e==null?void 0:e.dialog)==null?void 0:r.newConversation)==null?void 0:i.text,children:"There was an error connecting to the server. Please check your internet connection and try again."}),X.jsx(Na.Close,{asChild:!0,children:X.jsx("button",{...(a=(o=e==null?void 0:e.dialog)==null?void 0:o.newConversation)==null?void 0:a.button,onClick:()=>window.location.reload(),children:"Restart"})})]})})},[t]),X.jsx(X.Fragment,{})},Che=T.forwardRef(({children:e,onClick:t,...n},r)=>{const{theme:{fab:i}}=fn(),{container:o,icon:a}=i??{};return X.jsx("div",{...n,...o,ref:r,onClick:t,children:X.jsx("div",{...a})})}),DN="Collapsible",[Ohe,Exe]=Wg(DN),[The,V_]=Ohe(DN),khe=T.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:o,onOpenChange:a,...s}=e,[u=!1,c]=sN({prop:r,defaultProp:i,onChange:a});return T.createElement(The,{scope:n,disabled:o,contentId:zm(),open:u,onOpenToggle:T.useCallback(()=>c(d=>!d),[c])},T.createElement(ai.div,En({"data-state":K_(u),"data-disabled":o?"":void 0},s,{ref:t})))}),Ahe="CollapsibleTrigger",Phe=T.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=V_(Ahe,n);return T.createElement(ai.button,En({type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":K_(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled},r,{ref:t,onClick:Zo(e.onClick,i.onOpenToggle)}))}),LN="CollapsibleContent",Ihe=T.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=V_(LN,e.__scopeCollapsible);return T.createElement(qm,{present:n||i.open},({present:o})=>T.createElement($he,En({},r,{ref:t,present:o})))}),$he=T.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...o}=e,a=V_(LN,n),[s,u]=T.useState(r),c=T.useRef(null),d=Wa(t,c),p=T.useRef(0),m=p.current,h=T.useRef(0),y=h.current,v=a.open||s,x=T.useRef(v),b=T.useRef();return T.useEffect(()=>{const w=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(w)},[]),Tu(()=>{const w=c.current;if(w){b.current=b.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const S=w.getBoundingClientRect();p.current=S.height,h.current=S.width,x.current||(w.style.transitionDuration=b.current.transitionDuration,w.style.animationName=b.current.animationName),u(r)}},[a.open,r]),T.createElement(ai.div,En({"data-state":K_(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!v},o,{ref:d,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":y?`${y}px`:void 0,...e.style}}),v&&i)});function K_(e){return e?"open":"closed"}const Rhe=khe,Mhe=Phe,Nhe=Ihe,Dhe=e=>F.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16",...e},F.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",d:"M15.5 5.5v-5m0 0h-5m5 0L8.833 7.167m-2.5-5H4.5c-1.4 0-2.1 0-2.635.272A2.5 2.5 0 0 0 .772 3.532C.5 4.066.5 4.767.5 6.167V11.5c0 1.4 0 2.1.272 2.635a2.5 2.5 0 0 0 1.093 1.092C2.4 15.5 3.1 15.5 4.5 15.5h5.333c1.4 0 2.1 0 2.635-.273a2.5 2.5 0 0 0 1.093-1.092c.272-.535.272-1.235.272-2.635V9.667"})),Lhe=T.memo(T.forwardRef(({defaultOpen:e,...t},n)=>{const{theme:{header:r}}=fn(),[i,o]=T.useState(!!e);return X.jsx(Rhe,{open:i,onOpenChange:o,...t,...r==null?void 0:r.container,ref:n})})),jhe=T.forwardRef((e,t)=>{var r;const{theme:{header:n}}=fn();return X.jsx(Mhe,{...e,...(r=n==null?void 0:n.content)==null?void 0:r.container,ref:t})}),Fhe=T.forwardRef((e,t)=>{var r;const{theme:{header:n}}=fn();return X.jsx(Nhe,{...e,...(r=n==null?void 0:n.expandedContent)==null?void 0:r.container,ref:t})}),Uhe=T.forwardRef(({src:e,children:t},n)=>{var o;const{theme:{header:r},client:i}=fn();return X.jsx(Gg,{ref:n,userId:i==null?void 0:i.clientId,children:t,src:e,...(o=r==null?void 0:r.content)==null?void 0:o.avatar})}),Bhe=T.forwardRef((e,t)=>{var r;const{theme:{header:n}}=fn();return X.jsx("h2",{...e,...(r=n==null?void 0:n.content)==null?void 0:r.title,ref:t})}),zhe=T.forwardRef((e,t)=>{var r;const{theme:{header:n}}=fn();return X.jsx("p",{...e,...(r=n==null?void 0:n.content)==null?void 0:r.description,ref:t})}),qhe=T.forwardRef((e,t)=>{var r,i;const{theme:{header:n}}=fn();return X.jsx("div",{...e,...(i=(r=n==null?void 0:n.content)==null?void 0:r.actions)==null?void 0:i.container,ref:t})}),Xr=Object.assign(Lhe,{Content:jhe,ExpandedContent:Fhe,Avatar:Uhe,Description:zhe,Title:Bhe,Actions:qhe,DescriptionItem:({icon:e,title:t,link:n,...r})=>{var s,u,c,d,p,m,h,y,v,x,b,w;const{theme:{header:i}}=fn(),o=e??Dhe,a=S=>{S&&E5(S)};return!n&&!t?null:n?X.jsxs("a",{...r,...(u=(s=i==null?void 0:i.expandedContent)==null?void 0:s.descriptionItems)==null?void 0:u.container,href:n,target:"_blank",rel:"noopener",children:[X.jsx(o,{...(d=(c=i==null?void 0:i.expandedContent)==null?void 0:c.descriptionItems)==null?void 0:d.icon}),X.jsx("p",{...(m=(p=i==null?void 0:i.expandedContent)==null?void 0:p.descriptionItems)==null?void 0:m.link,children:t})]}):X.jsxs("div",{...r,...(y=(h=i==null?void 0:i.expandedContent)==null?void 0:h.descriptionItems)==null?void 0:y.container,onClick:S=>{a(S.currentTarget.textContent)},children:[X.jsx(o,{...(x=(v=i==null?void 0:i.expandedContent)==null?void 0:v.descriptionItems)==null?void 0:x.icon}),X.jsx("p",{...(w=(b=i==null?void 0:i.expandedContent)==null?void 0:b.descriptionItems)==null?void 0:w.text,children:t})]})}}),jN=T.memo(({...e})=>{const{theme:{loadingIndicator:t}}=fn();return X.jsx("div",{...e,...t==null?void 0:t.container,children:X.jsx("div",{...t==null?void 0:t.loader})})}),G_=T.forwardRef(({direction:e,block:t,scroll:n,disableInput:r,children:i,sender:o,...a},s)=>{var v,x,b,w;const[u,c]=T.useState([]),{theme:{message:d},configuration:{botAvatar:p,botName:m},client:h}=fn();e7(()=>{n()}),T.useEffect(()=>{u.length===0&&n()},[u.length]);const y=Sx((h==null?void 0:h.clientId)??"",15);return X.jsx(kS.Provider,{value:{isLoading:u,setIsLoading:c},children:X.jsxs("div",{...a,...d==null?void 0:d.container,"data-loaded":u.length===0,"data-disable-input":!!r,"data-direction":e,ref:s,children:[X.jsxs(_x,{"data-color":y,...(v=d==null?void 0:d.avatar)==null?void 0:v.container,children:[X.jsx(wx,{...(x=d==null?void 0:d.avatar)==null?void 0:x.image,src:(o==null?void 0:o.avatar)??p}),X.jsx(xx,{...(b=d==null?void 0:d.avatar)==null?void 0:b.fallback,children:(o==null?void 0:o.name[0])??((w=m??"Bot")==null?void 0:w[0])})]}),t&&X.jsx(tl,{block:t,styles:d==null?void 0:d.blocks}),i]})})});var FN={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(re,function(){var n=1e3,r=6e4,i=36e5,o="millisecond",a="second",s="minute",u="hour",c="day",d="week",p="month",m="quarter",h="year",y="date",v="Invalid Date",x=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,b=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,w={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(te){var K=["th","st","nd","rd"],Q=te%100;return"["+te+(K[(Q-20)%10]||K[Q]||K[0])+"]"}},S=function(te,K,Q){var ae=String(te);return!ae||ae.length>=K?te:""+Array(K+1-ae.length).join(Q)+te},P={s:S,z:function(te){var K=-te.utcOffset(),Q=Math.abs(K),ae=Math.floor(Q/60),ie=Q%60;return(K<=0?"+":"-")+S(ae,2,"0")+":"+S(ie,2,"0")},m:function te(K,Q){if(K.date()<Q.date())return-te(Q,K);var ae=12*(Q.year()-K.year())+(Q.month()-K.month()),ie=K.clone().add(ae,p),ke=Q-ie<0,I=K.clone().add(ae+(ke?-1:1),p);return+(-(ae+(Q-ie)/(ke?ie-I:I-ie))||0)},a:function(te){return te<0?Math.ceil(te)||0:Math.floor(te)},p:function(te){return{M:p,y:h,w:d,d:c,D:y,h:u,m:s,s:a,ms:o,Q:m}[te]||String(te||"").toLowerCase().replace(/s$/,"")},u:function(te){return te===void 0}},k="en",C={};C[k]=w;var L="$isDayjsObject",q=function(te){return te instanceof ee||!(!te||!te[L])},G=function te(K,Q,ae){var ie;if(!K)return k;if(typeof K=="string"){var ke=K.toLowerCase();C[ke]&&(ie=ke),Q&&(C[ke]=Q,ie=ke);var I=K.split("-");if(!ie&&I.length>1)return te(I[0])}else{var le=K.name;C[le]=K,ie=le}return!ae&&ie&&(k=ie),ie||!ae&&k},$=function(te,K){if(q(te))return te.clone();var Q=typeof K=="object"?K:{};return Q.date=te,Q.args=arguments,new ee(Q)},z=P;z.l=G,z.i=q,z.w=function(te,K){return $(te,{locale:K.$L,utc:K.$u,x:K.$x,$offset:K.$offset})};var ee=function(){function te(Q){this.$L=G(Q.locale,null,!0),this.parse(Q),this.$x=this.$x||Q.x||{},this[L]=!0}var K=te.prototype;return K.parse=function(Q){this.$d=function(ae){var ie=ae.date,ke=ae.utc;if(ie===null)return new Date(NaN);if(z.u(ie))return new Date;if(ie instanceof Date)return new Date(ie);if(typeof ie=="string"&&!/Z$/i.test(ie)){var I=ie.match(x);if(I){var le=I[2]-1||0,De=(I[7]||"0").substring(0,3);return ke?new Date(Date.UTC(I[1],le,I[3]||1,I[4]||0,I[5]||0,I[6]||0,De)):new Date(I[1],le,I[3]||1,I[4]||0,I[5]||0,I[6]||0,De)}}return new Date(ie)}(Q),this.init()},K.init=function(){var Q=this.$d;this.$y=Q.getFullYear(),this.$M=Q.getMonth(),this.$D=Q.getDate(),this.$W=Q.getDay(),this.$H=Q.getHours(),this.$m=Q.getMinutes(),this.$s=Q.getSeconds(),this.$ms=Q.getMilliseconds()},K.$utils=function(){return z},K.isValid=function(){return this.$d.toString()!==v},K.isSame=function(Q,ae){var ie=$(Q);return this.startOf(ae)<=ie&&ie<=this.endOf(ae)},K.isAfter=function(Q,ae){return $(Q)<this.startOf(ae)},K.isBefore=function(Q,ae){return this.endOf(ae)<$(Q)},K.$g=function(Q,ae,ie){return z.u(Q)?this[ae]:this.set(ie,Q)},K.unix=function(){return Math.floor(this.valueOf()/1e3)},K.valueOf=function(){return this.$d.getTime()},K.startOf=function(Q,ae){var ie=this,ke=!!z.u(ae)||ae,I=z.p(Q),le=function(at,Le){var Ie=z.w(ie.$u?Date.UTC(ie.$y,Le,at):new Date(ie.$y,Le,at),ie);return ke?Ie:Ie.endOf(c)},De=function(at,Le){return z.w(ie.toDate()[at].apply(ie.toDate("s"),(ke?[0,0,0,0]:[23,59,59,999]).slice(Le)),ie)},M=this.$W,Fe=this.$M,nt=this.$D,et="set"+(this.$u?"UTC":"");switch(I){case h:return ke?le(1,0):le(31,11);case p:return ke?le(1,Fe):le(0,Fe+1);case d:var ut=this.$locale().weekStart||0,pt=(M<ut?M+7:M)-ut;return le(ke?nt-pt:nt+(6-pt),Fe);case c:case y:return De(et+"Hours",0);case u:return De(et+"Minutes",1);case s:return De(et+"Seconds",2);case a:return De(et+"Milliseconds",3);default:return this.clone()}},K.endOf=function(Q){return this.startOf(Q,!1)},K.$set=function(Q,ae){var ie,ke=z.p(Q),I="set"+(this.$u?"UTC":""),le=(ie={},ie[c]=I+"Date",ie[y]=I+"Date",ie[p]=I+"Month",ie[h]=I+"FullYear",ie[u]=I+"Hours",ie[s]=I+"Minutes",ie[a]=I+"Seconds",ie[o]=I+"Milliseconds",ie)[ke],De=ke===c?this.$D+(ae-this.$W):ae;if(ke===p||ke===h){var M=this.clone().set(y,1);M.$d[le](De),M.init(),this.$d=M.set(y,Math.min(this.$D,M.daysInMonth())).$d}else le&&this.$d[le](De);return this.init(),this},K.set=function(Q,ae){return this.clone().$set(Q,ae)},K.get=function(Q){return this[z.p(Q)]()},K.add=function(Q,ae){var ie,ke=this;Q=Number(Q);var I=z.p(ae),le=function(Fe){var nt=$(ke);return z.w(nt.date(nt.date()+Math.round(Fe*Q)),ke)};if(I===p)return this.set(p,this.$M+Q);if(I===h)return this.set(h,this.$y+Q);if(I===c)return le(1);if(I===d)return le(7);var De=(ie={},ie[s]=r,ie[u]=i,ie[a]=n,ie)[I]||1,M=this.$d.getTime()+Q*De;return z.w(M,this)},K.subtract=function(Q,ae){return this.add(-1*Q,ae)},K.format=function(Q){var ae=this,ie=this.$locale();if(!this.isValid())return ie.invalidDate||v;var ke=Q||"YYYY-MM-DDTHH:mm:ssZ",I=z.z(this),le=this.$H,De=this.$m,M=this.$M,Fe=ie.weekdays,nt=ie.months,et=ie.meridiem,ut=function(Le,Ie,We,je){return Le&&(Le[Ie]||Le(ae,ke))||We[Ie].slice(0,je)},pt=function(Le){return z.s(le%12||12,Le,"0")},at=et||function(Le,Ie,We){var je=Le<12?"AM":"PM";return We?je.toLowerCase():je};return ke.replace(b,function(Le,Ie){return Ie||function(We){switch(We){case"YY":return String(ae.$y).slice(-2);case"YYYY":return z.s(ae.$y,4,"0");case"M":return M+1;case"MM":return z.s(M+1,2,"0");case"MMM":return ut(ie.monthsShort,M,nt,3);case"MMMM":return ut(nt,M);case"D":return ae.$D;case"DD":return z.s(ae.$D,2,"0");case"d":return String(ae.$W);case"dd":return ut(ie.weekdaysMin,ae.$W,Fe,2);case"ddd":return ut(ie.weekdaysShort,ae.$W,Fe,3);case"dddd":return Fe[ae.$W];case"H":return String(le);case"HH":return z.s(le,2,"0");case"h":return pt(1);case"hh":return pt(2);case"a":return at(le,De,!0);case"A":return at(le,De,!1);case"m":return String(De);case"mm":return z.s(De,2,"0");case"s":return String(ae.$s);case"ss":return z.s(ae.$s,2,"0");case"SSS":return z.s(ae.$ms,3,"0");case"Z":return I}return null}(Le)||I.replace(":","")})},K.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},K.diff=function(Q,ae,ie){var ke,I=this,le=z.p(ae),De=$(Q),M=(De.utcOffset()-this.utcOffset())*r,Fe=this-De,nt=function(){return z.m(I,De)};switch(le){case h:ke=nt()/12;break;case p:ke=nt();break;case m:ke=nt()/3;break;case d:ke=(Fe-M)/6048e5;break;case c:ke=(Fe-M)/864e5;break;case u:ke=Fe/i;break;case s:ke=Fe/r;break;case a:ke=Fe/n;break;default:ke=Fe}return ie?ke:z.a(ke)},K.daysInMonth=function(){return this.endOf(p).$D},K.$locale=function(){return C[this.$L]},K.locale=function(Q,ae){if(!Q)return this.$L;var ie=this.clone(),ke=G(Q,ae,!0);return ke&&(ie.$L=ke),ie},K.clone=function(){return z.w(this.$d,this)},K.toDate=function(){return new Date(this.valueOf())},K.toJSON=function(){return this.isValid()?this.toISOString():null},K.toISOString=function(){return this.$d.toISOString()},K.toString=function(){return this.$d.toUTCString()},te}(),Y=ee.prototype;return $.prototype=Y,[["$ms",o],["$s",a],["$m",s],["$H",u],["$W",c],["$M",p],["$y",h],["$D",y]].forEach(function(te){Y[te[1]]=function(K){return this.$g(K,te[0],te[1])}}),$.extend=function(te,K){return te.$i||(te(K,ee,$),te.$i=!0),$},$.locale=G,$.isDayjs=q,$.unix=function(te){return $(1e3*te)},$.en=C[k],$.Ls=C,$.p={},$})})(FN);var Zhe=FN.exports;const Qm=ta(Zhe);var UN={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(re,function(){return function(n,r,i){r.prototype.isToday=function(){var o="YYYY-MM-DD",a=i();return this.format(o)===a.format(o)}}})})(UN);var Whe=UN.exports;const Hhe=ta(Whe);var BN={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(re,function(){return function(n,r,i){r.prototype.isYesterday=function(){var o="YYYY-MM-DD",a=i().subtract(1,"day");return this.format(o)===a.format(o)}}})})(BN);var Vhe=BN.exports;const Khe=ta(Vhe);Qm.extend(Hhe),Qm.extend(Khe);function Ghe(e,t="day"){if(!e||e.length===0)return[];const n=[];n.push(zN(e[0].timestamp));for(let r=0;r<e.length;r++)if(n.push(e[r]),r+1<e.length){const i=e[r].timestamp,o=e[r+1].timestamp;Qm(i).isSame(o,t)||n.push(zN(o))}return n}function zN(e){return{direction:"system",sender:{name:"system"},timestamp:e,block:{type:"text",text:Yhe(e)}}}function Yhe(e,t=!1){const n=Qm(e),r="h:mma";return n.isToday()?t?`Today • ${n.format(r)}`:"Today":n.isYesterday()?t?`Yesterday • ${n.format(r)}`:"Yesterday":t?n.format(`YYYY-MM-DD • ${r}`):n.format("YYYY-MM-DD")}const qN=10*1e3,ZN=T.memo(({scrollDownButton:e,...t})=>{var w,S,P,k,C,L,q,G;const{messages:n,setState:r,client:i,configuration:o,messageContainerRef:a,theme:{messageList:s}}=fn(),u=T.useMemo(()=>Ghe(n),[n]),[c,d]=T.useState(!0),{y:p}=a7(a),[m,h]=T.useState(!1),[y,v]=l7(),x=()=>{if(!a.current)return;const{scrollHeight:$}=a.current;c&&a.current.scrollTo({top:$})};T.useEffect(()=>{const $=new Date(Date.now()-qN+2e3);n.length>0&&n[n.length-1].timestamp<$&&h(!1)},[y]),ts(()=>i==null?void 0:i.on("messageSent",()=>{h(!0),v(new Date(Date.now()+qN))})),ts(()=>i==null?void 0:i.on("message",()=>{h(!1)})),T.useEffect(()=>{const $=n[n.length-1];r({disableComposer:!!($!=null&&$.disableInput)})},[n.length]),T.useEffect(()=>{if(!a.current)return;const{offsetHeight:$,scrollHeight:z,scrollTop:ee}=a.current;d(z<=ee+$+100)},[p]);const b=e!=null&&e.icon?e==null?void 0:e.icon:G4;return X.jsxs("ul",{...t,...s==null?void 0:s.container,ref:a,children:[X.jsx("li",{...(w=s==null?void 0:s.scrollDownButton)==null?void 0:w.container,children:!!n.length&&X.jsxs("button",{"data-is-at-bottom":c,...(S=s==null?void 0:s.scrollDownButton)==null?void 0:S.button,onClick:()=>{var $,z;return(z=a.current)==null?void 0:z.scrollBy({top:($=a.current)==null?void 0:$.scrollHeight})},children:[(e==null?void 0:e.text)??"Back"," ",X.jsx(b,{...(P=s==null?void 0:s.scrollDownButton)==null?void 0:P.icon})]})}),X.jsxs("li",{...(k=s==null?void 0:s.marquee)==null?void 0:k.container,children:[X.jsx(Gg,{userId:i==null?void 0:i.clientId,src:o.botAvatar,...(C=s==null?void 0:s.marquee)==null?void 0:C.avatar,children:(o.botName||"Bot").slice(0,1)}),X.jsxs("div",{...(L=s==null?void 0:s.marquee)==null?void 0:L.content,children:[X.jsx("h1",{...(q=s==null?void 0:s.marquee)==null?void 0:q.title,children:o.botName||"Bot"}),X.jsx("p",{...(G=s==null?void 0:s.marquee)==null?void 0:G.description,children:o.botDescription})]})]}),u.map(($,z)=>X.jsx(G_,{scroll:x,...$},z)),m&&X.jsx(G_,{scroll:x,direction:"incoming",children:X.jsx(jN,{})})]})}),WN=({...e})=>{var a,s;const{theme:{header:t,modal:n},client:r}=fn(),{showModal:i}=PS(),o=u=>{var c,d,p,m;u.stopPropagation(),i({title:"Restart Conversation",content:X.jsxs(X.Fragment,{children:[X.jsx("p",{...(d=(c=n==null?void 0:n.dialog)==null?void 0:c.newConversation)==null?void 0:d.text,children:"Are you sure you want to restart a new conversation?"}),X.jsx(Na.Close,{asChild:!0,children:X.jsx("button",{...(m=(p=n==null?void 0:n.dialog)==null?void 0:p.newConversation)==null?void 0:m.button,onClick:r==null?void 0:r.restartConversation,children:"Restart"})})]})})};return X.jsx(J4,{...e,...(s=(a=t==null?void 0:t.content)==null?void 0:a.actions)==null?void 0:s.icons,role:"button",tabIndex:0,onClick:o,onKeyDown:u=>{u.key==="Enter"&&o(u)}})},Jhe=({...e})=>{var i,o;const{theme:{header:t},closeWindow:n}=fn(),r=a=>{a.stopPropagation(),n==null||n()};return X.jsx(MN,{...e,...(o=(i=t==null?void 0:t.content)==null?void 0:i.actions)==null?void 0:o.icons,role:"button",tabIndex:0,onClick:r,onKeyDown:a=>{a.key==="Enter"&&r(a)}})},Qhe=()=>{var r,i,o,a,s,u,c,d,p,m,h,y,v,x,b;const{configuration:e,closeWindow:t}=fn(),n=!!((r=e.email)!=null&&r.title)||!!((i=e.phone)!=null&&i.title)||!!((o=e.website)!=null&&o.title)||!!((a=e.termsOfService)!=null&&a.link)||!!((s=e.privacyPolicy)!=null&&s.link);return X.jsxs(NN,{children:[X.jsxs(Xr,{open:n?void 0:!1,"data-disabled":n?void 0:"",children:[X.jsxs(Xr.Content,{children:[X.jsx(Xr.Avatar,{src:e.botAvatar,children:e.botName||"Bot"}),X.jsx(Xr.Title,{children:e.botName||"Bot"}),X.jsx(Xr.Description,{children:e.botDescription}),X.jsxs(Xr.Actions,{children:[X.jsx(WN,{}),t&&X.jsx(Jhe,{})]})]}),X.jsxs(Xr.ExpandedContent,{children:[X.jsx(Xr.DescriptionItem,{"data-email":"",icon:V6,title:(u=e.email)==null?void 0:u.title,link:(c=e.email)==null?void 0:c.link}),X.jsx(Xr.DescriptionItem,{"data-phone":"",icon:X6,title:(d=e.phone)==null?void 0:d.title,link:(p=e.phone)==null?void 0:p.link}),X.jsx(Xr.DescriptionItem,{"data-website":"",link:(m=e.website)==null?void 0:m.link,icon:G6,title:(h=e.website)==null?void 0:h.title}),X.jsx(Xr.DescriptionItem,{"data-terms":"",link:(y=e.termsOfService)==null?void 0:y.link,icon:W6,title:(v=e.termsOfService)==null?void 0:v.title}),X.jsx(Xr.DescriptionItem,{"data-privacy":"",link:(x=e.privacyPolicy)==null?void 0:x.link,icon:J6,title:(b=e.privacyPolicy)==null?void 0:b.title})]})]}),X.jsx(ZN,{}),X.jsxs(rN,{children:[X.jsx(iN,{placeholder:e.composerPlaceholder||"Type your message"}),X.jsx(oN,{})]})]})},uu=ne.object({title:ne.string(),link:ne.string().optional()}),HN=ne.object({composerPlaceholder:ne.string().optional(),botName:ne.string().optional(),botAvatar:ne.string().optional(),botDescription:ne.string().optional(),website:uu.optional(),email:uu.optional(),phone:uu.optional(),privacyPolicy:uu.optional(),termsOfService:uu.optional()}),VN=ne.enum(["heading1","heading2","heading3","text","horizontalRule","link","italic","bold","orderedList","unorderedList","listItem","lineBreak","pre"]),KN=ne.object({}).passthrough().transform(e=>e),ze=ne.object({className:ne.string().optional(),style:KN.optional()}),Xm=ne.object({container:ze.optional(),image:ze.optional(),fallback:ze.optional()}),GN=ne.object({button:ze.optional(),text:ne.record(VN,ze.optional()),image:ne.object({image:ze.optional(),placeholder:ze.optional()}).optional(),audio:ze.optional(),video:ze.optional(),file:ne.object({container:ze.optional(),title:ze.optional(),icon:ze.optional()}).optional(),location:ne.object({container:ze.optional(),title:ze.optional(),icon:ze.optional()}).optional(),column:ze.optional(),row:ze.optional(),bubble:ze.optional(),carousel:ne.object({container:ze.optional(),slidesContainer:ze.optional(),backButton:ze.optional(),nextButton:ze.optional()}).optional(),dropdown:ne.object({button:ne.object({container:ze.optional(),icon:ze.optional(),text:ze.optional()}).optional(),content:ne.object({container:ze.optional(),item:ze.optional()}).optional()}).optional()}),YN=ne.object({container:ze.optional(),modal:ne.object({overlay:ze.optional(),container:ze.optional(),dialog:ne.object({container:ze.optional(),title:ne.object({container:ze.optional(),text:ze.optional(),closeIcon:ze.optional()}).optional(),content:ze.optional(),newConversation:ne.object({text:ze.optional(),button:ze.optional()}).optional()}).optional()}).optional(),notification:ne.object({container:ze.optional(),title:ze.optional(),description:ze.optional(),icon:ze.optional(),closeIcon:ze.optional()}).optional(),header:ne.object({container:ze.optional(),content:ne.object({container:ze.optional(),title:ze.optional(),description:ze.optional(),avatar:Xm.optional(),actions:ne.object({container:ze.optional(),icons:ze.optional()}).optional()}),expandedContent:ne.object({container:ze.optional(),descriptionItems:ne.object({container:ze.optional(),icon:ze.optional(),text:ze.optional(),link:ze.optional()}).optional()}).optional(),description:ne.object({container:ze.optional(),title:ze.optional(),subtitle:ze.optional()}).optional(),newConversationIcon:ze.optional()}).optional(),composer:ne.object({container:ze.optional(),input:ze.optional(),button:ne.object({container:ze.optional(),icon:ze.optional()}).optional()}).optional(),fab:ne.object({icon:ze.optional(),container:ze.optional()}).optional(),messageList:ne.object({container:ze.optional(),marquee:ne.object({content:ze.optional(),title:ze.optional(),description:ze.optional(),avatar:Xm.optional(),container:ze.optional()}).optional(),scrollDownButton:ne.object({container:ze.optional(),button:ze.optional(),icon:ze.optional()}).optional()}).optional(),message:ne.object({container:ze.optional(),avatar:Xm.optional(),blocks:GN.optional()}).optional(),loadingIndicator:ne.object({container:ze.optional(),loader:ze.optional()}).optional()}),JN=ne.enum(["opened","closed","initial"]),QN=ne.object({data:ne.record(ne.string()).optional()}),XN=ne.enum(["messaging","pushpin"]),eD=ne.object({configuration:HN.optional().catch(void 0),theme:YN.optional().catch(void 0),style:ne.string().optional().catch(void 0),user:QN.optional().catch(void 0)}),Xhe=eD.extend({clientId:ne.string(),botId:ne.string(),selector:ne.string().optional().catch(void 0),webchatScriptUrl:ne.string().optional().catch(void 0),fabScriptUrl:ne.string().optional().catch(void 0),messagingUrl:ne.string().optional().catch(void 0),pushpinUrl:ne.string().optional().catch(void 0),clientMode:XN.optional().catch(void 0),defaultState:JN.optional().catch(void 0)}),eme=({clientId:e,apiUrl:t,mode:n="messaging"})=>n==="messaging"?new PR({url:t,clientId:e}):new nN({apiUrl:t,clientId:e});Tt.Avatar=Gg,Tt.Block=tl,Tt.Composer=rN,Tt.ComposerButton=oN,Tt.ComposerInput=iN,Tt.Container=NN,Tt.Fab=Che,Tt.Header=Xr,Tt.LoadingIndicator=jN,Tt.Message=G_,Tt.MessageList=ZN,Tt.Modal=Na,Tt.ModalProvider=aN,Tt.RestartConversation=WN,Tt.Webchat=Qhe,Tt.WebchatProvider=Qde,Tt.avatarThemeSchema=Xm,Tt.blockThemeSchema=GN,Tt.clientModePropsSchema=XN,Tt.configPropsSchema=eD,Tt.configurationSchema=HN,Tt.cssStyleSchema=KN,Tt.descriptionItemSchema=uu,Tt.getClient=eme,Tt.initPropsSchema=Xhe,Tt.markdownTypeSchema=VN,Tt.renderers=vv,Tt.statePropsSchema=JN,Tt.styleOptionSchema=ze,Tt.themeSchema=YN,Tt.useClient=Jde,Tt.useWebchatContext=fn,Tt.userPropsSchema=QN,Object.defineProperty(Tt,Symbol.toStringTag,{value:"Module"})});
511
+ `)},Gpe=0,su=[];function Ype(e){var t=F.useRef([]),n=F.useRef([0,0]),r=F.useRef(),i=F.useState(Gpe++)[0],o=F.useState(function(){return _N()})[0],a=F.useRef(e);F.useEffect(function(){a.current=e},[e]),F.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var v=Vq([e.lockRef.current],(e.shards||[]).map(ON),!0).filter(Boolean);return v.forEach(function(x){return x.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),v.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var s=F.useCallback(function(v,x){if("touches"in v&&v.touches.length===2)return!a.current.allowPinchZoom;var b=Gm(v),w=n.current,S="deltaX"in v?v.deltaX:w[0]-b[0],P="deltaY"in v?v.deltaY:w[1]-b[1],k,C=v.target,L=Math.abs(S)>Math.abs(P)?"h":"v";if("touches"in v&&L==="h"&&C.type==="range")return!1;var q=xN(L,C);if(!q)return!0;if(q?k=L:(k=L==="v"?"h":"v",q=xN(L,C)),!q)return!1;if(!r.current&&"changedTouches"in v&&(S||P)&&(r.current=k),!k)return!0;var G=r.current||k;return Hpe(G,x,v,G==="h"?S:P,!0)},[]),u=F.useCallback(function(v){var x=v;if(!(!su.length||su[su.length-1]!==o)){var b="deltaY"in x?CN(x):Gm(x),w=t.current.filter(function(k){return k.name===x.type&&k.target===x.target&&Vpe(k.delta,b)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var S=(a.current.shards||[]).map(ON).filter(Boolean).filter(function(k){return k.contains(x.target)}),P=S.length>0?s(x,S[0]):!a.current.noIsolation;P&&x.cancelable&&x.preventDefault()}}},[]),c=F.useCallback(function(v,x,b,w){var S={name:v,delta:x,target:b,should:w};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(P){return P!==S})},1)},[]),d=F.useCallback(function(v){n.current=Gm(v),r.current=void 0},[]),p=F.useCallback(function(v){c(v.type,CN(v),v.target,s(v,e.lockRef.current))},[]),m=F.useCallback(function(v){c(v.type,Gm(v),v.target,s(v,e.lockRef.current))},[]);F.useEffect(function(){return su.push(o),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",u,au),document.addEventListener("touchmove",u,au),document.addEventListener("touchstart",d,au),function(){su=su.filter(function(v){return v!==o}),document.removeEventListener("wheel",u,au),document.removeEventListener("touchmove",u,au),document.removeEventListener("touchstart",d,au)}},[]);var h=e.removeScrollBar,y=e.inert;return F.createElement(F.Fragment,null,y?F.createElement(o,{styles:Kpe(i)}):null,h?F.createElement(Fpe,{gapMode:"margin"}):null)}const Jpe=Tpe(vN,Ype);var TN=F.forwardRef(function(e,t){return F.createElement(Vm,ui({},e,{ref:t,sideCar:Jpe}))});TN.classNames=Vm.classNames;const Qpe=TN;var Xpe=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},lu=new WeakMap,Ym=new WeakMap,Jm={},Z_=0,kN=function(e){return e&&(e.host||kN(e.parentNode))},ehe=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=kN(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},the=function(e,t,n,r){var i=ehe(t,Array.isArray(e)?e:[e]);Jm[n]||(Jm[n]=new WeakMap);var o=Jm[n],a=[],s=new Set,u=new Set(i),c=function(p){!p||s.has(p)||(s.add(p),c(p.parentNode))};i.forEach(c);var d=function(p){!p||u.has(p)||Array.prototype.forEach.call(p.children,function(m){if(s.has(m))d(m);else{var h=m.getAttribute(r),y=h!==null&&h!=="false",v=(lu.get(m)||0)+1,x=(o.get(m)||0)+1;lu.set(m,v),o.set(m,x),a.push(m),v===1&&y&&Ym.set(m,!0),x===1&&m.setAttribute(n,"true"),y||m.setAttribute(r,"true")}})};return d(t),s.clear(),Z_++,function(){a.forEach(function(p){var m=lu.get(p)-1,h=o.get(p)-1;lu.set(p,m),o.set(p,h),m||(Ym.has(p)||p.removeAttribute(r),Ym.delete(p)),h||p.removeAttribute(n)}),Z_--,Z_||(lu=new WeakMap,lu=new WeakMap,Ym=new WeakMap,Jm={})}},nhe=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=t||Xpe(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live]"))),the(r,i,n,"aria-hidden")):function(){return null}};const AN="Dialog",[PN,wxe]=Wg(AN),[rhe,Wo]=PN(AN),ihe=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:a=!0}=e,s=T.useRef(null),u=T.useRef(null),[c=!1,d]=sN({prop:r,defaultProp:i,onChange:o});return T.createElement(rhe,{scope:t,triggerRef:s,contentRef:u,contentId:zm(),titleId:zm(),descriptionId:zm(),open:c,onOpenChange:d,onOpenToggle:T.useCallback(()=>d(p=>!p),[d]),modal:a},n)},ohe="DialogTrigger",ahe=T.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Wo(ohe,n),o=Wa(t,i.triggerRef);return T.createElement(ai.button,En({type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":H_(i.open)},r,{ref:o,onClick:Zo(e.onClick,i.onOpenToggle)}))}),she="DialogPortal",[xxe,IN]=PN(she,{forceMount:void 0}),W_="DialogOverlay",lhe=T.forwardRef((e,t)=>{const n=IN(W_,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=Wo(W_,e.__scopeDialog);return o.modal?T.createElement(qm,{present:r||o.open},T.createElement(uhe,En({},i,{ref:t}))):null}),uhe=T.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Wo(W_,n);return T.createElement(Qpe,{as:Hg,allowPinchZoom:!0,shards:[i.contentRef]},T.createElement(ai.div,En({"data-state":H_(i.open)},r,{ref:t,style:{pointerEvents:"auto",...r.style}})))}),Rf="DialogContent",che=T.forwardRef((e,t)=>{const n=IN(Rf,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=Wo(Rf,e.__scopeDialog);return T.createElement(qm,{present:r||o.open},o.modal?T.createElement(fhe,En({},i,{ref:t})):T.createElement(dhe,En({},i,{ref:t})))}),fhe=T.forwardRef((e,t)=>{const n=Wo(Rf,e.__scopeDialog),r=T.useRef(null),i=Wa(t,n.contentRef,r);return T.useEffect(()=>{const o=r.current;if(o)return nhe(o)},[]),T.createElement($N,En({},e,{ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Zo(e.onCloseAutoFocus,o=>{var a;o.preventDefault(),(a=n.triggerRef.current)===null||a===void 0||a.focus()}),onPointerDownOutside:Zo(e.onPointerDownOutside,o=>{const a=o.detail.originalEvent,s=a.button===0&&a.ctrlKey===!0;(a.button===2||s)&&o.preventDefault()}),onFocusOutside:Zo(e.onFocusOutside,o=>o.preventDefault())}))}),dhe=T.forwardRef((e,t)=>{const n=Wo(Rf,e.__scopeDialog),r=T.useRef(!1),i=T.useRef(!1);return T.createElement($N,En({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var a;if((a=e.onCloseAutoFocus)===null||a===void 0||a.call(e,o),!o.defaultPrevented){var s;r.current||(s=n.triggerRef.current)===null||s===void 0||s.focus(),o.preventDefault()}r.current=!1,i.current=!1},onInteractOutside:o=>{var a,s;(a=e.onInteractOutside)===null||a===void 0||a.call(e,o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const u=o.target;((s=n.triggerRef.current)===null||s===void 0?void 0:s.contains(u))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}}))}),$N=T.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,...a}=e,s=Wo(Rf,n),u=T.useRef(null),c=Wa(t,u);return vpe(),T.createElement(T.Fragment,null,T.createElement(upe,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o},T.createElement(ape,En({role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":H_(s.open)},a,{ref:c,onDismiss:()=>s.onOpenChange(!1)}))),!1)}),phe="DialogTitle",hhe=T.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Wo(phe,n);return T.createElement(ai.h2,En({id:i.titleId},r,{ref:t}))}),mhe="DialogClose",ghe=T.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Wo(mhe,n);return T.createElement(ai.button,En({type:"button"},r,{ref:t,onClick:Zo(e.onClick,()=>i.onOpenChange(!1))}))});function H_(e){return e?"open":"closed"}const yhe=ihe,vhe=ahe,bhe=lhe,_he=che,whe=hhe,RN=ghe;function xhe({title:e,titleId:t,...n},r){return F.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",ref:r,"aria-labelledby":t},n),e?F.createElement("title",{id:t},e):null,F.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"}))}const MN=F.forwardRef(xhe);function Na({open:e,onOpenChange:t,children:n}){return X.jsx(yhe,{open:e,onOpenChange:t,children:n})}function She({title:e,children:t}){var r,i,o,a,s,u,c,d;const{theme:{modal:n}}=fn();return X.jsxs(X.Fragment,{children:[X.jsx(bhe,{...n==null?void 0:n.overlay}),X.jsx("div",{...n==null?void 0:n.container,children:X.jsxs(_he,{...(r=n==null?void 0:n.dialog)==null?void 0:r.container,children:[X.jsxs("div",{...(o=(i=n==null?void 0:n.dialog)==null?void 0:i.title)==null?void 0:o.container,children:[X.jsx(whe,{...(s=(a=n==null?void 0:n.dialog)==null?void 0:a.title)==null?void 0:s.text,children:e}),X.jsx(RN,{children:X.jsx(MN,{role:"button",tabIndex:0,...(c=(u=n==null?void 0:n.dialog)==null?void 0:u.title)==null?void 0:c.closeIcon})})]}),X.jsx("div",{...(d=n==null?void 0:n.dialog)==null?void 0:d.content,children:t})]})})]})}Na.Button=vhe,Na.Close=RN,Na.Content=She;const NN=T.forwardRef(({children:e,...t},n)=>{const{theme:{container:r}}=fn();return X.jsxs("div",{...t,...r,ref:n,children:[X.jsx(m4,{}),X.jsxs(aN,{children:[X.jsx(Ehe,{}),e]})]})}),Ehe=()=>{const{theme:{modal:e},state:{connected:t}}=fn(),{showModal:n}=PS();return T.useEffect(()=>{var r,i,o,a;t||n({title:"Connection Error",content:X.jsxs(X.Fragment,{children:[X.jsx("p",{...(i=(r=e==null?void 0:e.dialog)==null?void 0:r.newConversation)==null?void 0:i.text,children:"There was an error connecting to the server. Please check your internet connection and try again."}),X.jsx(Na.Close,{asChild:!0,children:X.jsx("button",{...(a=(o=e==null?void 0:e.dialog)==null?void 0:o.newConversation)==null?void 0:a.button,onClick:()=>window.location.reload(),children:"Restart"})})]})})},[t]),X.jsx(X.Fragment,{})},Che=T.forwardRef(({children:e,onClick:t,...n},r)=>{const{theme:{fab:i}}=fn(),{container:o,icon:a}=i??{};return X.jsx("div",{...n,...o,ref:r,onClick:t,children:X.jsx("div",{...a})})}),DN="Collapsible",[Ohe,Exe]=Wg(DN),[The,V_]=Ohe(DN),khe=T.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:o,onOpenChange:a,...s}=e,[u=!1,c]=sN({prop:r,defaultProp:i,onChange:a});return T.createElement(The,{scope:n,disabled:o,contentId:zm(),open:u,onOpenToggle:T.useCallback(()=>c(d=>!d),[c])},T.createElement(ai.div,En({"data-state":K_(u),"data-disabled":o?"":void 0},s,{ref:t})))}),Ahe="CollapsibleTrigger",Phe=T.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=V_(Ahe,n);return T.createElement(ai.button,En({type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":K_(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled},r,{ref:t,onClick:Zo(e.onClick,i.onOpenToggle)}))}),LN="CollapsibleContent",Ihe=T.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=V_(LN,e.__scopeCollapsible);return T.createElement(qm,{present:n||i.open},({present:o})=>T.createElement($he,En({},r,{ref:t,present:o})))}),$he=T.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...o}=e,a=V_(LN,n),[s,u]=T.useState(r),c=T.useRef(null),d=Wa(t,c),p=T.useRef(0),m=p.current,h=T.useRef(0),y=h.current,v=a.open||s,x=T.useRef(v),b=T.useRef();return T.useEffect(()=>{const w=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(w)},[]),Tu(()=>{const w=c.current;if(w){b.current=b.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const S=w.getBoundingClientRect();p.current=S.height,h.current=S.width,x.current||(w.style.transitionDuration=b.current.transitionDuration,w.style.animationName=b.current.animationName),u(r)}},[a.open,r]),T.createElement(ai.div,En({"data-state":K_(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!v},o,{ref:d,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":y?`${y}px`:void 0,...e.style}}),v&&i)});function K_(e){return e?"open":"closed"}const Rhe=khe,Mhe=Phe,Nhe=Ihe,Dhe=e=>F.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16",...e},F.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",d:"M15.5 5.5v-5m0 0h-5m5 0L8.833 7.167m-2.5-5H4.5c-1.4 0-2.1 0-2.635.272A2.5 2.5 0 0 0 .772 3.532C.5 4.066.5 4.767.5 6.167V11.5c0 1.4 0 2.1.272 2.635a2.5 2.5 0 0 0 1.093 1.092C2.4 15.5 3.1 15.5 4.5 15.5h5.333c1.4 0 2.1 0 2.635-.273a2.5 2.5 0 0 0 1.093-1.092c.272-.535.272-1.235.272-2.635V9.667"})),Lhe=T.memo(T.forwardRef(({defaultOpen:e,...t},n)=>{const{theme:{header:r}}=fn(),[i,o]=T.useState(!!e);return X.jsx(Rhe,{open:i,onOpenChange:o,...t,...r==null?void 0:r.container,ref:n})})),jhe=T.forwardRef((e,t)=>{var r;const{theme:{header:n}}=fn();return X.jsx(Mhe,{...e,...(r=n==null?void 0:n.content)==null?void 0:r.container,ref:t})}),Fhe=T.forwardRef((e,t)=>{var r;const{theme:{header:n}}=fn();return X.jsx(Nhe,{...e,...(r=n==null?void 0:n.expandedContent)==null?void 0:r.container,ref:t})}),Uhe=T.forwardRef(({src:e,children:t},n)=>{var o;const{theme:{header:r},client:i}=fn();return X.jsx(Gg,{ref:n,userId:i==null?void 0:i.clientId,children:t,src:e,...(o=r==null?void 0:r.content)==null?void 0:o.avatar})}),Bhe=T.forwardRef((e,t)=>{var r;const{theme:{header:n}}=fn();return X.jsx("h2",{...e,...(r=n==null?void 0:n.content)==null?void 0:r.title,ref:t})}),zhe=T.forwardRef((e,t)=>{var r;const{theme:{header:n}}=fn();return X.jsx("p",{...e,...(r=n==null?void 0:n.content)==null?void 0:r.description,ref:t})}),qhe=T.forwardRef((e,t)=>{var r,i;const{theme:{header:n}}=fn();return X.jsx("div",{...e,...(i=(r=n==null?void 0:n.content)==null?void 0:r.actions)==null?void 0:i.container,ref:t})}),Xr=Object.assign(Lhe,{Content:jhe,ExpandedContent:Fhe,Avatar:Uhe,Description:zhe,Title:Bhe,Actions:qhe,DescriptionItem:({icon:e,title:t,link:n,...r})=>{var s,u,c,d,p,m,h,y,v,x,b,w;const{theme:{header:i}}=fn(),o=e??Dhe,a=S=>{S&&E5(S)};return!n&&!t?null:n?X.jsxs("a",{...r,...(u=(s=i==null?void 0:i.expandedContent)==null?void 0:s.descriptionItems)==null?void 0:u.container,href:n,target:"_blank",rel:"noopener",children:[X.jsx(o,{...(d=(c=i==null?void 0:i.expandedContent)==null?void 0:c.descriptionItems)==null?void 0:d.icon}),X.jsx("p",{...(m=(p=i==null?void 0:i.expandedContent)==null?void 0:p.descriptionItems)==null?void 0:m.link,children:t})]}):X.jsxs("div",{...r,...(y=(h=i==null?void 0:i.expandedContent)==null?void 0:h.descriptionItems)==null?void 0:y.container,onClick:S=>{a(S.currentTarget.textContent)},children:[X.jsx(o,{...(x=(v=i==null?void 0:i.expandedContent)==null?void 0:v.descriptionItems)==null?void 0:x.icon}),X.jsx("p",{...(w=(b=i==null?void 0:i.expandedContent)==null?void 0:b.descriptionItems)==null?void 0:w.text,children:t})]})}}),jN=T.memo(({...e})=>{const{theme:{loadingIndicator:t}}=fn();return X.jsx("div",{...e,...t==null?void 0:t.container,children:X.jsx("div",{...t==null?void 0:t.loader})})}),G_=T.forwardRef(({direction:e,block:t,scroll:n,disableInput:r,children:i,sender:o,...a},s)=>{var v,x,b,w;const[u,c]=T.useState([]),{theme:{message:d},configuration:{botAvatar:p,botName:m},client:h}=fn();e7(()=>{n()}),T.useEffect(()=>{u.length===0&&n()},[u.length]);const y=Sx((h==null?void 0:h.clientId)??"",15);return X.jsx(kS.Provider,{value:{isLoading:u,setIsLoading:c},children:X.jsxs("div",{...a,...d==null?void 0:d.container,"data-loaded":u.length===0,"data-disable-input":!!r,"data-direction":e,ref:s,children:[X.jsxs(_x,{"data-color":y,...(v=d==null?void 0:d.avatar)==null?void 0:v.container,children:[X.jsx(wx,{...(x=d==null?void 0:d.avatar)==null?void 0:x.image,src:(o==null?void 0:o.avatar)??p}),X.jsx(xx,{...(b=d==null?void 0:d.avatar)==null?void 0:b.fallback,children:(o==null?void 0:o.name[0])??((w=m??"Bot")==null?void 0:w[0])})]}),t&&X.jsx(tl,{block:t,styles:d==null?void 0:d.blocks}),i]})})});var FN={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(re,function(){var n=1e3,r=6e4,i=36e5,o="millisecond",a="second",s="minute",u="hour",c="day",d="week",p="month",m="quarter",h="year",y="date",v="Invalid Date",x=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,b=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,w={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(te){var K=["th","st","nd","rd"],Q=te%100;return"["+te+(K[(Q-20)%10]||K[Q]||K[0])+"]"}},S=function(te,K,Q){var ae=String(te);return!ae||ae.length>=K?te:""+Array(K+1-ae.length).join(Q)+te},P={s:S,z:function(te){var K=-te.utcOffset(),Q=Math.abs(K),ae=Math.floor(Q/60),ie=Q%60;return(K<=0?"+":"-")+S(ae,2,"0")+":"+S(ie,2,"0")},m:function te(K,Q){if(K.date()<Q.date())return-te(Q,K);var ae=12*(Q.year()-K.year())+(Q.month()-K.month()),ie=K.clone().add(ae,p),ke=Q-ie<0,I=K.clone().add(ae+(ke?-1:1),p);return+(-(ae+(Q-ie)/(ke?ie-I:I-ie))||0)},a:function(te){return te<0?Math.ceil(te)||0:Math.floor(te)},p:function(te){return{M:p,y:h,w:d,d:c,D:y,h:u,m:s,s:a,ms:o,Q:m}[te]||String(te||"").toLowerCase().replace(/s$/,"")},u:function(te){return te===void 0}},k="en",C={};C[k]=w;var L="$isDayjsObject",q=function(te){return te instanceof ee||!(!te||!te[L])},G=function te(K,Q,ae){var ie;if(!K)return k;if(typeof K=="string"){var ke=K.toLowerCase();C[ke]&&(ie=ke),Q&&(C[ke]=Q,ie=ke);var I=K.split("-");if(!ie&&I.length>1)return te(I[0])}else{var le=K.name;C[le]=K,ie=le}return!ae&&ie&&(k=ie),ie||!ae&&k},$=function(te,K){if(q(te))return te.clone();var Q=typeof K=="object"?K:{};return Q.date=te,Q.args=arguments,new ee(Q)},z=P;z.l=G,z.i=q,z.w=function(te,K){return $(te,{locale:K.$L,utc:K.$u,x:K.$x,$offset:K.$offset})};var ee=function(){function te(Q){this.$L=G(Q.locale,null,!0),this.parse(Q),this.$x=this.$x||Q.x||{},this[L]=!0}var K=te.prototype;return K.parse=function(Q){this.$d=function(ae){var ie=ae.date,ke=ae.utc;if(ie===null)return new Date(NaN);if(z.u(ie))return new Date;if(ie instanceof Date)return new Date(ie);if(typeof ie=="string"&&!/Z$/i.test(ie)){var I=ie.match(x);if(I){var le=I[2]-1||0,De=(I[7]||"0").substring(0,3);return ke?new Date(Date.UTC(I[1],le,I[3]||1,I[4]||0,I[5]||0,I[6]||0,De)):new Date(I[1],le,I[3]||1,I[4]||0,I[5]||0,I[6]||0,De)}}return new Date(ie)}(Q),this.init()},K.init=function(){var Q=this.$d;this.$y=Q.getFullYear(),this.$M=Q.getMonth(),this.$D=Q.getDate(),this.$W=Q.getDay(),this.$H=Q.getHours(),this.$m=Q.getMinutes(),this.$s=Q.getSeconds(),this.$ms=Q.getMilliseconds()},K.$utils=function(){return z},K.isValid=function(){return this.$d.toString()!==v},K.isSame=function(Q,ae){var ie=$(Q);return this.startOf(ae)<=ie&&ie<=this.endOf(ae)},K.isAfter=function(Q,ae){return $(Q)<this.startOf(ae)},K.isBefore=function(Q,ae){return this.endOf(ae)<$(Q)},K.$g=function(Q,ae,ie){return z.u(Q)?this[ae]:this.set(ie,Q)},K.unix=function(){return Math.floor(this.valueOf()/1e3)},K.valueOf=function(){return this.$d.getTime()},K.startOf=function(Q,ae){var ie=this,ke=!!z.u(ae)||ae,I=z.p(Q),le=function(at,Le){var Ie=z.w(ie.$u?Date.UTC(ie.$y,Le,at):new Date(ie.$y,Le,at),ie);return ke?Ie:Ie.endOf(c)},De=function(at,Le){return z.w(ie.toDate()[at].apply(ie.toDate("s"),(ke?[0,0,0,0]:[23,59,59,999]).slice(Le)),ie)},M=this.$W,Fe=this.$M,nt=this.$D,et="set"+(this.$u?"UTC":"");switch(I){case h:return ke?le(1,0):le(31,11);case p:return ke?le(1,Fe):le(0,Fe+1);case d:var ut=this.$locale().weekStart||0,pt=(M<ut?M+7:M)-ut;return le(ke?nt-pt:nt+(6-pt),Fe);case c:case y:return De(et+"Hours",0);case u:return De(et+"Minutes",1);case s:return De(et+"Seconds",2);case a:return De(et+"Milliseconds",3);default:return this.clone()}},K.endOf=function(Q){return this.startOf(Q,!1)},K.$set=function(Q,ae){var ie,ke=z.p(Q),I="set"+(this.$u?"UTC":""),le=(ie={},ie[c]=I+"Date",ie[y]=I+"Date",ie[p]=I+"Month",ie[h]=I+"FullYear",ie[u]=I+"Hours",ie[s]=I+"Minutes",ie[a]=I+"Seconds",ie[o]=I+"Milliseconds",ie)[ke],De=ke===c?this.$D+(ae-this.$W):ae;if(ke===p||ke===h){var M=this.clone().set(y,1);M.$d[le](De),M.init(),this.$d=M.set(y,Math.min(this.$D,M.daysInMonth())).$d}else le&&this.$d[le](De);return this.init(),this},K.set=function(Q,ae){return this.clone().$set(Q,ae)},K.get=function(Q){return this[z.p(Q)]()},K.add=function(Q,ae){var ie,ke=this;Q=Number(Q);var I=z.p(ae),le=function(Fe){var nt=$(ke);return z.w(nt.date(nt.date()+Math.round(Fe*Q)),ke)};if(I===p)return this.set(p,this.$M+Q);if(I===h)return this.set(h,this.$y+Q);if(I===c)return le(1);if(I===d)return le(7);var De=(ie={},ie[s]=r,ie[u]=i,ie[a]=n,ie)[I]||1,M=this.$d.getTime()+Q*De;return z.w(M,this)},K.subtract=function(Q,ae){return this.add(-1*Q,ae)},K.format=function(Q){var ae=this,ie=this.$locale();if(!this.isValid())return ie.invalidDate||v;var ke=Q||"YYYY-MM-DDTHH:mm:ssZ",I=z.z(this),le=this.$H,De=this.$m,M=this.$M,Fe=ie.weekdays,nt=ie.months,et=ie.meridiem,ut=function(Le,Ie,We,je){return Le&&(Le[Ie]||Le(ae,ke))||We[Ie].slice(0,je)},pt=function(Le){return z.s(le%12||12,Le,"0")},at=et||function(Le,Ie,We){var je=Le<12?"AM":"PM";return We?je.toLowerCase():je};return ke.replace(b,function(Le,Ie){return Ie||function(We){switch(We){case"YY":return String(ae.$y).slice(-2);case"YYYY":return z.s(ae.$y,4,"0");case"M":return M+1;case"MM":return z.s(M+1,2,"0");case"MMM":return ut(ie.monthsShort,M,nt,3);case"MMMM":return ut(nt,M);case"D":return ae.$D;case"DD":return z.s(ae.$D,2,"0");case"d":return String(ae.$W);case"dd":return ut(ie.weekdaysMin,ae.$W,Fe,2);case"ddd":return ut(ie.weekdaysShort,ae.$W,Fe,3);case"dddd":return Fe[ae.$W];case"H":return String(le);case"HH":return z.s(le,2,"0");case"h":return pt(1);case"hh":return pt(2);case"a":return at(le,De,!0);case"A":return at(le,De,!1);case"m":return String(De);case"mm":return z.s(De,2,"0");case"s":return String(ae.$s);case"ss":return z.s(ae.$s,2,"0");case"SSS":return z.s(ae.$ms,3,"0");case"Z":return I}return null}(Le)||I.replace(":","")})},K.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},K.diff=function(Q,ae,ie){var ke,I=this,le=z.p(ae),De=$(Q),M=(De.utcOffset()-this.utcOffset())*r,Fe=this-De,nt=function(){return z.m(I,De)};switch(le){case h:ke=nt()/12;break;case p:ke=nt();break;case m:ke=nt()/3;break;case d:ke=(Fe-M)/6048e5;break;case c:ke=(Fe-M)/864e5;break;case u:ke=Fe/i;break;case s:ke=Fe/r;break;case a:ke=Fe/n;break;default:ke=Fe}return ie?ke:z.a(ke)},K.daysInMonth=function(){return this.endOf(p).$D},K.$locale=function(){return C[this.$L]},K.locale=function(Q,ae){if(!Q)return this.$L;var ie=this.clone(),ke=G(Q,ae,!0);return ke&&(ie.$L=ke),ie},K.clone=function(){return z.w(this.$d,this)},K.toDate=function(){return new Date(this.valueOf())},K.toJSON=function(){return this.isValid()?this.toISOString():null},K.toISOString=function(){return this.$d.toISOString()},K.toString=function(){return this.$d.toUTCString()},te}(),Y=ee.prototype;return $.prototype=Y,[["$ms",o],["$s",a],["$m",s],["$H",u],["$W",c],["$M",p],["$y",h],["$D",y]].forEach(function(te){Y[te[1]]=function(K){return this.$g(K,te[0],te[1])}}),$.extend=function(te,K){return te.$i||(te(K,ee,$),te.$i=!0),$},$.locale=G,$.isDayjs=q,$.unix=function(te){return $(1e3*te)},$.en=C[k],$.Ls=C,$.p={},$})})(FN);var Zhe=FN.exports;const Qm=ta(Zhe);var UN={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(re,function(){return function(n,r,i){r.prototype.isToday=function(){var o="YYYY-MM-DD",a=i();return this.format(o)===a.format(o)}}})})(UN);var Whe=UN.exports;const Hhe=ta(Whe);var BN={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(re,function(){return function(n,r,i){r.prototype.isYesterday=function(){var o="YYYY-MM-DD",a=i().subtract(1,"day");return this.format(o)===a.format(o)}}})})(BN);var Vhe=BN.exports;const Khe=ta(Vhe);Qm.extend(Hhe),Qm.extend(Khe);function Ghe(e,t="day"){if(!e||e.length===0)return[];const n=[];n.push(zN(e[0].timestamp));for(let r=0;r<e.length;r++)if(n.push(e[r]),r+1<e.length){const i=e[r].timestamp,o=e[r+1].timestamp;Qm(i).isSame(o,t)||n.push(zN(o))}return n}function zN(e){return{direction:"system",sender:{name:"system"},timestamp:e,block:{type:"text",text:Yhe(e)}}}function Yhe(e,t=!1){const n=Qm(e),r="h:mma";return n.isToday()?t?`Today • ${n.format(r)}`:"Today":n.isYesterday()?t?`Yesterday • ${n.format(r)}`:"Yesterday":t?n.format(`YYYY-MM-DD • ${r}`):n.format("YYYY-MM-DD")}const qN=10*1e3,ZN=T.memo(({scrollDownButton:e,...t})=>{var w,S,P,k,C,L,q,G;const{messages:n,setState:r,client:i,configuration:o,messageContainerRef:a,theme:{messageList:s}}=fn(),u=T.useMemo(()=>Ghe(n),[n]),[c,d]=T.useState(!0),{y:p}=a7(a),[m,h]=T.useState(!1),[y,v]=l7(),x=()=>{if(!a.current)return;const{scrollHeight:$}=a.current;c&&a.current.scrollTo({top:$})};T.useEffect(()=>{const $=new Date(Date.now()-qN+2e3);n.length>0&&n[n.length-1].timestamp<$&&h(!1)},[y]),ts(()=>i==null?void 0:i.on("messageSent",()=>{h(!0),v(new Date(Date.now()+qN))})),ts(()=>i==null?void 0:i.on("message",()=>{h(!1)})),T.useEffect(()=>{const $=n[n.length-1];r({disableComposer:!!($!=null&&$.disableInput)})},[n.length]),T.useEffect(()=>{if(!a.current)return;const{offsetHeight:$,scrollHeight:z,scrollTop:ee}=a.current;d(z<=ee+$+100)},[p]);const b=e!=null&&e.icon?e==null?void 0:e.icon:G4;return X.jsxs("ul",{...t,...s==null?void 0:s.container,ref:a,children:[X.jsx("li",{...(w=s==null?void 0:s.scrollDownButton)==null?void 0:w.container,children:!!n.length&&X.jsxs("button",{"data-is-at-bottom":c,...(S=s==null?void 0:s.scrollDownButton)==null?void 0:S.button,onClick:()=>{var $,z;return(z=a.current)==null?void 0:z.scrollBy({top:($=a.current)==null?void 0:$.scrollHeight})},children:[(e==null?void 0:e.text)??"Back"," ",X.jsx(b,{...(P=s==null?void 0:s.scrollDownButton)==null?void 0:P.icon})]})}),X.jsxs("li",{...(k=s==null?void 0:s.marquee)==null?void 0:k.container,children:[X.jsx(Gg,{userId:i==null?void 0:i.clientId,src:o.botAvatar,...(C=s==null?void 0:s.marquee)==null?void 0:C.avatar,children:(o.botName||"Bot").slice(0,1)}),X.jsxs("div",{...(L=s==null?void 0:s.marquee)==null?void 0:L.content,children:[X.jsx("h1",{...(q=s==null?void 0:s.marquee)==null?void 0:q.title,children:o.botName||"Bot"}),X.jsx("p",{...(G=s==null?void 0:s.marquee)==null?void 0:G.description,children:o.botDescription})]})]}),u.map(($,z)=>X.jsx(G_,{scroll:x,...$},z)),m&&X.jsx(G_,{scroll:x,direction:"incoming",children:X.jsx(jN,{})})]})}),WN=({...e})=>{var a,s;const{theme:{header:t,modal:n},client:r}=fn(),{showModal:i}=PS(),o=u=>{var c,d,p,m;u.stopPropagation(),i({title:"Restart Conversation",content:X.jsxs(X.Fragment,{children:[X.jsx("p",{...(d=(c=n==null?void 0:n.dialog)==null?void 0:c.newConversation)==null?void 0:d.text,children:"Are you sure you want to restart a new conversation?"}),X.jsx(Na.Close,{asChild:!0,children:X.jsx("button",{...(m=(p=n==null?void 0:n.dialog)==null?void 0:p.newConversation)==null?void 0:m.button,onClick:r==null?void 0:r.restartConversation,children:"Restart"})})]})})};return X.jsx(J4,{...e,...(s=(a=t==null?void 0:t.content)==null?void 0:a.actions)==null?void 0:s.icons,role:"button",tabIndex:0,onClick:o,onKeyDown:u=>{u.key==="Enter"&&o(u)}})},Jhe=({...e})=>{var i,o;const{theme:{header:t},closeWindow:n}=fn(),r=a=>{a.stopPropagation(),n==null||n()};return X.jsx(MN,{...e,...(o=(i=t==null?void 0:t.content)==null?void 0:i.actions)==null?void 0:o.icons,role:"button",tabIndex:0,onClick:r,onKeyDown:a=>{a.key==="Enter"&&r(a)}})},Qhe=()=>{var r,i,o,a,s,u,c,d,p,m,h,y,v,x,b;const{configuration:e,closeWindow:t}=fn(),n=!!((r=e.email)!=null&&r.title)||!!((i=e.phone)!=null&&i.title)||!!((o=e.website)!=null&&o.title)||!!((a=e.termsOfService)!=null&&a.link)||!!((s=e.privacyPolicy)!=null&&s.link);return X.jsxs(NN,{children:[X.jsxs(Xr,{open:n?void 0:!1,"data-disabled":n?void 0:"",children:[X.jsxs(Xr.Content,{children:[X.jsx(Xr.Avatar,{src:e.botAvatar,children:e.botName||"Bot"}),X.jsx(Xr.Title,{children:e.botName||"Bot"}),X.jsx(Xr.Description,{children:e.botDescription}),X.jsxs(Xr.Actions,{children:[X.jsx(WN,{}),t&&X.jsx(Jhe,{})]})]}),X.jsxs(Xr.ExpandedContent,{children:[X.jsx(Xr.DescriptionItem,{"data-email":"",icon:V6,title:(u=e.email)==null?void 0:u.title,link:(c=e.email)==null?void 0:c.link}),X.jsx(Xr.DescriptionItem,{"data-phone":"",icon:X6,title:(d=e.phone)==null?void 0:d.title,link:(p=e.phone)==null?void 0:p.link}),X.jsx(Xr.DescriptionItem,{"data-website":"",link:(m=e.website)==null?void 0:m.link,icon:G6,title:(h=e.website)==null?void 0:h.title}),X.jsx(Xr.DescriptionItem,{"data-terms":"",link:(y=e.termsOfService)==null?void 0:y.link,icon:W6,title:(v=e.termsOfService)==null?void 0:v.title}),X.jsx(Xr.DescriptionItem,{"data-privacy":"",link:(x=e.privacyPolicy)==null?void 0:x.link,icon:J6,title:(b=e.privacyPolicy)==null?void 0:b.title})]})]}),X.jsx(ZN,{}),X.jsxs(rN,{children:[X.jsx(iN,{placeholder:e.composerPlaceholder||"Type your message"}),X.jsx(oN,{})]})]})},uu=ne.object({title:ne.string(),link:ne.string().optional()}),HN=ne.object({composerPlaceholder:ne.string().optional(),botName:ne.string().optional(),botAvatar:ne.string().optional(),botDescription:ne.string().optional(),website:uu.optional(),email:uu.optional(),phone:uu.optional(),privacyPolicy:uu.optional(),termsOfService:uu.optional()}),VN=ne.enum(["heading1","heading2","heading3","text","horizontalRule","link","italic","bold","orderedList","unorderedList","listItem","lineBreak","pre"]),KN=ne.object({}).passthrough().transform(e=>e),ze=ne.object({className:ne.string().optional(),style:KN.optional()}),Xm=ne.object({container:ze.optional(),image:ze.optional(),fallback:ze.optional()}),GN=ne.object({button:ze.optional(),text:ne.record(VN,ze.optional()),image:ne.object({image:ze.optional(),placeholder:ze.optional()}).optional(),audio:ze.optional(),video:ze.optional(),file:ne.object({container:ze.optional(),title:ze.optional(),icon:ze.optional()}).optional(),location:ne.object({container:ze.optional(),title:ze.optional(),icon:ze.optional()}).optional(),column:ze.optional(),row:ze.optional(),bubble:ze.optional(),carousel:ne.object({container:ze.optional(),slidesContainer:ze.optional(),backButton:ze.optional(),nextButton:ze.optional()}).optional(),dropdown:ne.object({button:ne.object({container:ze.optional(),icon:ze.optional(),text:ze.optional()}).optional(),content:ne.object({container:ze.optional(),item:ze.optional()}).optional()}).optional()}),YN=ne.object({container:ze.optional(),modal:ne.object({overlay:ze.optional(),container:ze.optional(),dialog:ne.object({container:ze.optional(),title:ne.object({container:ze.optional(),text:ze.optional(),closeIcon:ze.optional()}).optional(),content:ze.optional(),newConversation:ne.object({text:ze.optional(),button:ze.optional()}).optional()}).optional()}).optional(),notification:ne.object({container:ze.optional(),title:ze.optional(),description:ze.optional(),icon:ze.optional(),closeIcon:ze.optional()}).optional(),header:ne.object({container:ze.optional(),content:ne.object({container:ze.optional(),title:ze.optional(),description:ze.optional(),avatar:Xm.optional(),actions:ne.object({container:ze.optional(),icons:ze.optional()}).optional()}),expandedContent:ne.object({container:ze.optional(),descriptionItems:ne.object({container:ze.optional(),icon:ze.optional(),text:ze.optional(),link:ze.optional()}).optional()}).optional(),description:ne.object({container:ze.optional(),title:ze.optional(),subtitle:ze.optional()}).optional(),newConversationIcon:ze.optional()}).optional(),composer:ne.object({container:ze.optional(),input:ze.optional(),button:ne.object({container:ze.optional(),icon:ze.optional()}).optional()}).optional(),fab:ne.object({icon:ze.optional(),container:ze.optional()}).optional(),messageList:ne.object({container:ze.optional(),marquee:ne.object({content:ze.optional(),title:ze.optional(),description:ze.optional(),avatar:Xm.optional(),container:ze.optional()}).optional(),scrollDownButton:ne.object({container:ze.optional(),button:ze.optional(),icon:ze.optional()}).optional()}).optional(),message:ne.object({container:ze.optional(),avatar:Xm.optional(),blocks:GN.optional()}).optional(),loadingIndicator:ne.object({container:ze.optional(),loader:ze.optional()}).optional()}),JN=ne.enum(["opened","closed","initial"]),QN=ne.object({data:ne.record(ne.string()).optional()}),XN=ne.enum(["messaging","pushpin"]),eD=ne.object({configuration:HN.optional().catch(void 0),theme:YN.optional().catch(void 0),style:ne.string().optional().catch(void 0),user:QN.optional().catch(void 0)}),Xhe=eD.extend({clientId:ne.string(),botId:ne.string(),selector:ne.string().optional().catch(void 0),webchatScriptUrl:ne.string().optional().catch(void 0),fabScriptUrl:ne.string().optional().catch(void 0),messagingUrl:ne.string().optional().catch(void 0),pushpinUrl:ne.string().optional().catch(void 0),clientMode:XN.optional().catch(void 0),defaultState:JN.optional().catch(void 0)}),eme=({clientId:e,apiUrl:t="https://webchat.botpress.cloud",mode:n="pushpin"})=>n==="messaging"?new PR({url:t,clientId:e}):new nN({apiUrl:t,clientId:e});Tt.Avatar=Gg,Tt.Block=tl,Tt.Composer=rN,Tt.ComposerButton=oN,Tt.ComposerInput=iN,Tt.Container=NN,Tt.Fab=Che,Tt.Header=Xr,Tt.LoadingIndicator=jN,Tt.Message=G_,Tt.MessageList=ZN,Tt.Modal=Na,Tt.ModalProvider=aN,Tt.RestartConversation=WN,Tt.Webchat=Qhe,Tt.WebchatProvider=Qde,Tt.avatarThemeSchema=Xm,Tt.blockThemeSchema=GN,Tt.clientModePropsSchema=XN,Tt.configPropsSchema=eD,Tt.configurationSchema=HN,Tt.cssStyleSchema=KN,Tt.descriptionItemSchema=uu,Tt.getClient=eme,Tt.initPropsSchema=Xhe,Tt.markdownTypeSchema=VN,Tt.renderers=vv,Tt.statePropsSchema=JN,Tt.styleOptionSchema=ze,Tt.themeSchema=YN,Tt.useClient=Jde,Tt.useWebchatContext=fn,Tt.userPropsSchema=QN,Object.defineProperty(Tt,Symbol.toStringTag,{value:"Module"})});