@bymos/agentkit-sdk 0.6.4 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -7
- package/agentkit-widget.iife.js +85 -34
- package/agentkit-widget.js +1775 -1729
- package/index.cjs +89 -38
- package/index.js +2140 -2094
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let En=require("preact/compat/client"),L=require("preact/compat"),o=require("preact/jsx-runtime");var E;(function(e){e.assertEqual=a=>{};function t(a){}e.assertIs=t;function r(a){throw new Error}e.assertNever=r,e.arrayToEnum=a=>{const i={};for(const s of a)i[s]=s;return i},e.getValidEnumValues=a=>{const i=e.objectKeys(a).filter(l=>typeof a[a[l]]!="number"),s={};for(const l of i)s[l]=a[l];return e.objectValues(s)},e.objectValues=a=>e.objectKeys(a).map(function(i){return a[i]}),e.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const i=[];for(const s in a)Object.prototype.hasOwnProperty.call(a,s)&&i.push(s);return i},e.find=(a,i)=>{for(const s of a)if(i(s))return s},e.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function n(a,i=" | "){return a.map(s=>typeof s=="string"?`'${s}'`:s).join(i)}e.joinValues=n,e.jsonStringifyReplacer=(a,i)=>typeof i=="bigint"?i.toString():i})(E||(E={}));var er;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(er||(er={}));var y=E.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ue=e=>{switch(typeof e){case"undefined":return y.undefined;case"string":return y.string;case"number":return Number.isNaN(e)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(e)?y.array:e===null?y.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?y.promise:typeof Map<"u"&&e instanceof Map?y.map:typeof Set<"u"&&e instanceof Set?y.set:typeof Date<"u"&&e instanceof Date?y.date:y.object;default:return y.unknown}},m=E.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"]),re=class Sr extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){const r=t||function(i){return i.message},n={_errors:[]},a=i=>{for(const s of i.issues)if(s.code==="invalid_union")s.unionErrors.map(a);else if(s.code==="invalid_return_type")a(s.returnTypeError);else if(s.code==="invalid_arguments")a(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let l=n,c=0;for(;c<s.path.length;){const d=s.path[c];c!==s.path.length-1?l[d]=l[d]||{_errors:[]}:(l[d]=l[d]||{_errors:[]},l[d]._errors.push(r(s))),l=l[d],c++}}};return a(this),n}static assert(t){if(!(t instanceof Sr))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,E.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){const r={},n=[];for(const a of this.issues)if(a.path.length>0){const i=a.path[0];r[i]=r[i]||[],r[i].push(t(a))}else n.push(t(a));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};re.create=e=>new re(e);var Me=(e,t)=>{let r;switch(e.code){case m.invalid_type:e.received===y.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case m.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,E.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:r=`Unrecognized key(s) in object: ${E.joinValues(e.keys,", ")}`;break;case m.invalid_union:r="Invalid input";break;case m.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${E.joinValues(e.options)}`;break;case m.invalid_enum_value:r=`Invalid enum value. Expected ${E.joinValues(e.options)}, received '${e.received}'`;break;case m.invalid_arguments:r="Invalid function arguments";break;case m.invalid_return_type:r="Invalid function return type";break;case m.invalid_date:r="Invalid date";break;case m.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:E.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case m.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case m.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case m.custom:r="Invalid input";break;case m.invalid_intersection_types:r="Intersection results could not be merged";break;case m.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case m.not_finite:r="Number must be finite";break;default:r=t.defaultError,E.assertNever(e)}return{message:r}},Mn=Me;function kt(){return Mn}var yt=e=>{const{data:t,path:r,errorMaps:n,issueData:a}=e,i=[...r,...a.path||[]],s={...a,path:i};if(a.message!==void 0)return{...a,path:i,message:a.message};let l="";const c=n.filter(d=>!!d).slice().reverse();for(const d of c)l=d(s,{data:t,defaultError:l}).message;return{...a,path:i,message:l}};function k(e,t){const r=kt(),n=yt({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Me?void 0:Me].filter(a=>!!a)});e.common.issues.push(n)}var Y=class Cr{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){const n=[];for(const a of r){if(a.status==="aborted")return j;a.status==="dirty"&&t.dirty(),n.push(a.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){const n=[];for(const a of r){const i=await a.key,s=await a.value;n.push({key:i,value:s})}return Cr.mergeObjectSync(t,n)}static mergeObjectSync(t,r){const n={};for(const a of r){const{key:i,value:s}=a;if(i.status==="aborted"||s.status==="aborted")return j;i.status==="dirty"&&t.dirty(),s.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof s.value<"u"||a.alwaysSet)&&(n[i.value]=s.value)}return{status:t.value,value:n}}},j=Object.freeze({status:"aborted"}),Le=e=>({status:"dirty",value:e}),z=e=>({status:"valid",value:e}),tr=e=>e.status==="aborted",rr=e=>e.status==="dirty",je=e=>e.status==="valid",Ye=e=>typeof Promise<"u"&&e instanceof Promise,b;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(b||(b={}));var ne=class{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},nr=(e,t)=>{if(je(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 r=new re(e.common.issues);return this._error=r,this._error}}};function N(e){if(!e)return{};const{errorMap:t,invalid_type_error:r,required_error:n,description:a}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:a}:{errorMap:(s,l)=>{const{message:c}=e;return s.code==="invalid_enum_value"?{message:c??l.defaultError}:typeof l.data>"u"?{message:c??n??l.defaultError}:s.code!=="invalid_type"?{message:l.defaultError}:{message:c??r??l.defaultError}},description:a}}var A=class{get description(){return this._def.description}_getType(e){return ue(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ue(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Y,ctx:{common:e.parent.common,data:e.data,parsedType:ue(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ye(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){const r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ue(e)};return nr(r,this._parseSync({data:e,path:r.path,parent:r}))}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ue(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:t});return je(r)?{value:r.value}:{issues:t.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(r=>je(r)?{value:r.value}:{issues:t.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ue(e)},n=this._parse({data:e,path:r.path,parent:r});return nr(r,await(Ye(n)?n:Promise.resolve(n)))}refine(e,t){const r=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const i=e(n),s=()=>a.addIssue({code:m.custom,...r(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(l=>l?!0:(s(),!1)):i?!0:(s(),!1)})}refinement(e,t){return this._refinement((r,n)=>e(r)?!0:(n.addIssue(typeof t=="function"?t(r,n):t),!1))}_refinement(e){return new ce({schema:this,typeName:S.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return le.create(this,this._def)}nullable(){return me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Se.create(this)}promise(){return Re.create(this,this._def)}or(e){return Ke.create([this,e],this._def)}and(e){return qe.create(this,e,this._def)}transform(e){return new ce({...N(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new nt({...N(this._def),innerType:this,defaultValue:t,typeName:S.ZodDefault})}brand(){return new Mr({typeName:S.ZodBranded,type:this,...N(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new at({...N(this._def),innerType:this,catchValue:t,typeName:S.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Rr.create(this,e)}readonly(){return it.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Rn=/^c[^\s-]{8,}$/i,Zn=/^[0-9a-z]+$/,On=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Fn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Pn=/^[a-z0-9_-]{21}$/i,$n=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Wn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Vn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Dn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",pt,zn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Un=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Bn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Gn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Hn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Yn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ir="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Xn=new RegExp(`^${Ir}$`);function Nr(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function Jn(e){return new RegExp(`^${Nr(e)}$`)}function Qn(e){let t=`${Ir}T${Nr(e)}`;const r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function Kn(e,t){return!!((t==="v4"||!t)&&zn.test(e)||(t==="v6"||!t)&&Bn.test(e))}function qn(e,t){if(!$n.test(e))return!1;try{const[r]=e.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),a=JSON.parse(atob(n));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||t&&a.alg!==t)}catch{return!1}}function ea(e,t){return!!((t==="v4"||!t)&&Un.test(e)||(t==="v6"||!t)&&Gn.test(e))}var Xe=class Ae extends A{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==y.string){const a=this._getOrReturnCtx(t);return k(a,{code:m.invalid_type,expected:y.string,received:a.parsedType}),j}const r=new Y;let n;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(n=this._getOrReturnCtx(t,n),k(n,{code:m.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")t.data.length>a.value&&(n=this._getOrReturnCtx(t,n),k(n,{code:m.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const i=t.data.length>a.value,s=t.data.length<a.value;(i||s)&&(n=this._getOrReturnCtx(t,n),i?k(n,{code:m.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&k(n,{code:m.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")Vn.test(t.data)||(n=this._getOrReturnCtx(t,n),k(n,{validation:"email",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")pt||(pt=new RegExp(Dn,"u")),pt.test(t.data)||(n=this._getOrReturnCtx(t,n),k(n,{validation:"emoji",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")Fn.test(t.data)||(n=this._getOrReturnCtx(t,n),k(n,{validation:"uuid",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")Pn.test(t.data)||(n=this._getOrReturnCtx(t,n),k(n,{validation:"nanoid",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")Rn.test(t.data)||(n=this._getOrReturnCtx(t,n),k(n,{validation:"cuid",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")Zn.test(t.data)||(n=this._getOrReturnCtx(t,n),k(n,{validation:"cuid2",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")On.test(t.data)||(n=this._getOrReturnCtx(t,n),k(n,{validation:"ulid",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{n=this._getOrReturnCtx(t,n),k(n,{validation:"url",code:m.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(n=this._getOrReturnCtx(t,n),k(n,{validation:"regex",code:m.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(t,n),k(n,{code:m.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(n=this._getOrReturnCtx(t,n),k(n,{code:m.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(n=this._getOrReturnCtx(t,n),k(n,{code:m.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?Qn(a).test(t.data)||(n=this._getOrReturnCtx(t,n),k(n,{code:m.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?Xn.test(t.data)||(n=this._getOrReturnCtx(t,n),k(n,{code:m.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?Jn(a).test(t.data)||(n=this._getOrReturnCtx(t,n),k(n,{code:m.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?Wn.test(t.data)||(n=this._getOrReturnCtx(t,n),k(n,{validation:"duration",code:m.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?Kn(t.data,a.version)||(n=this._getOrReturnCtx(t,n),k(n,{validation:"ip",code:m.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?qn(t.data,a.alg)||(n=this._getOrReturnCtx(t,n),k(n,{validation:"jwt",code:m.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?ea(t.data,a.version)||(n=this._getOrReturnCtx(t,n),k(n,{validation:"cidr",code:m.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?Hn.test(t.data)||(n=this._getOrReturnCtx(t,n),k(n,{validation:"base64",code:m.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?Yn.test(t.data)||(n=this._getOrReturnCtx(t,n),k(n,{validation:"base64url",code:m.invalid_string,message:a.message}),r.dirty()):E.assertNever(a);return{status:r.value,value:t.data}}_regex(t,r,n){return this.refinement(a=>t.test(a),{validation:r,code:m.invalid_string,...b.errToObj(n)})}_addCheck(t){return new Ae({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...b.errToObj(t)})}url(t){return this._addCheck({kind:"url",...b.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...b.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...b.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...b.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...b.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...b.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...b.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...b.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...b.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...b.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...b.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...b.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...b.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...b.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...b.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...b.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...b.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...b.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...b.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...b.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...b.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...b.errToObj(r)})}nonempty(t){return this.min(1,b.errToObj(t))}trim(){return new Ae({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ae({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ae({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}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 isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}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 isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Xe.create=e=>new Xe({checks:[],typeName:S.ZodString,coerce:e?.coerce??!1,...N(e)});function ta(e,t){const r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,a=r>n?r:n;return Number.parseInt(e.toFixed(a).replace(".",""))%Number.parseInt(t.toFixed(a).replace(".",""))/10**a}var bt=class _t extends A{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)!==y.number){const a=this._getOrReturnCtx(t);return k(a,{code:m.invalid_type,expected:y.number,received:a.parsedType}),j}let r;const n=new Y;for(const a of this._def.checks)a.kind==="int"?E.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),k(r,{code:m.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),k(r,{code:m.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),k(r,{code:m.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?ta(t.data,a.value)!==0&&(r=this._getOrReturnCtx(t,r),k(r,{code:m.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),k(r,{code:m.not_finite,message:a.message}),n.dirty()):E.assertNever(a);return{status:n.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,b.toString(r))}gt(t,r){return this.setLimit("min",t,!1,b.toString(r))}lte(t,r){return this.setLimit("max",t,!0,b.toString(r))}lt(t,r){return this.setLimit("max",t,!1,b.toString(r))}setLimit(t,r,n,a){return new _t({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:b.toString(a)}]})}_addCheck(t){return new _t({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:b.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:b.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:b.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString(t)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&E.isInteger(t.value))}get isFinite(){let t=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};bt.create=e=>new bt({checks:[],typeName:S.ZodNumber,coerce:e?.coerce||!1,...N(e)});var wt=class jt extends A{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==y.bigint)return this._getInvalidInput(t);let r;const n=new Y;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),k(r,{code:m.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),k(r,{code:m.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),k(r,{code:m.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):E.assertNever(a);return{status:n.value,value:t.data}}_getInvalidInput(t){const r=this._getOrReturnCtx(t);return k(r,{code:m.invalid_type,expected:y.bigint,received:r.parsedType}),j}gte(t,r){return this.setLimit("min",t,!0,b.toString(r))}gt(t,r){return this.setLimit("min",t,!1,b.toString(r))}lte(t,r){return this.setLimit("max",t,!0,b.toString(r))}lt(t,r){return this.setLimit("max",t,!1,b.toString(r))}setLimit(t,r,n,a){return new jt({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:b.toString(a)}]})}_addCheck(t){return new jt({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:b.toString(r)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};wt.create=e=>new wt({checks:[],typeName:S.ZodBigInt,coerce:e?.coerce??!1,...N(e)});var St=class extends A{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){const t=this._getOrReturnCtx(e);return k(t,{code:m.invalid_type,expected:y.boolean,received:t.parsedType}),j}return z(e.data)}};St.create=e=>new St({typeName:S.ZodBoolean,coerce:e?.coerce||!1,...N(e)});var Ct=class Tr extends A{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==y.date){const a=this._getOrReturnCtx(t);return k(a,{code:m.invalid_type,expected:y.date,received:a.parsedType}),j}if(Number.isNaN(t.data.getTime()))return k(this._getOrReturnCtx(t),{code:m.invalid_date}),j;const r=new Y;let n;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(n=this._getOrReturnCtx(t,n),k(n,{code:m.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(n=this._getOrReturnCtx(t,n),k(n,{code:m.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):E.assertNever(a);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Tr({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:b.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:b.toString(r)})}get minDate(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};Ct.create=e=>new Ct({checks:[],coerce:e?.coerce||!1,typeName:S.ZodDate,...N(e)});var It=class extends A{_parse(e){if(this._getType(e)!==y.symbol){const t=this._getOrReturnCtx(e);return k(t,{code:m.invalid_type,expected:y.symbol,received:t.parsedType}),j}return z(e.data)}};It.create=e=>new It({typeName:S.ZodSymbol,...N(e)});var Je=class extends A{_parse(e){if(this._getType(e)!==y.undefined){const t=this._getOrReturnCtx(e);return k(t,{code:m.invalid_type,expected:y.undefined,received:t.parsedType}),j}return z(e.data)}};Je.create=e=>new Je({typeName:S.ZodUndefined,...N(e)});var Qe=class extends A{_parse(e){if(this._getType(e)!==y.null){const t=this._getOrReturnCtx(e);return k(t,{code:m.invalid_type,expected:y.null,received:t.parsedType}),j}return z(e.data)}};Qe.create=e=>new Qe({typeName:S.ZodNull,...N(e)});var Nt=class extends A{constructor(){super(...arguments),this._any=!0}_parse(e){return z(e.data)}};Nt.create=e=>new Nt({typeName:S.ZodAny,...N(e)});var _e=class extends A{constructor(){super(...arguments),this._unknown=!0}_parse(e){return z(e.data)}};_e.create=e=>new _e({typeName:S.ZodUnknown,...N(e)});var fe=class extends A{_parse(e){const t=this._getOrReturnCtx(e);return k(t,{code:m.invalid_type,expected:y.never,received:t.parsedType}),j}};fe.create=e=>new fe({typeName:S.ZodNever,...N(e)});var Tt=class extends A{_parse(e){if(this._getType(e)!==y.undefined){const t=this._getOrReturnCtx(e);return k(t,{code:m.invalid_type,expected:y.void,received:t.parsedType}),j}return z(e.data)}};Tt.create=e=>new Tt({typeName:S.ZodVoid,...N(e)});var Se=class Be extends A{_parse(t){const{ctx:r,status:n}=this._processInputParams(t),a=this._def;if(r.parsedType!==y.array)return k(r,{code:m.invalid_type,expected:y.array,received:r.parsedType}),j;if(a.exactLength!==null){const s=r.data.length>a.exactLength.value,l=r.data.length<a.exactLength.value;(s||l)&&(k(r,{code:s?m.too_big:m.too_small,minimum:l?a.exactLength.value:void 0,maximum:s?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(a.minLength!==null&&r.data.length<a.minLength.value&&(k(r,{code:m.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),a.maxLength!==null&&r.data.length>a.maxLength.value&&(k(r,{code:m.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,l)=>a.type._parseAsync(new ne(r,s,r.path,l)))).then(s=>Y.mergeArray(n,s));const i=[...r.data].map((s,l)=>a.type._parseSync(new ne(r,s,r.path,l)));return Y.mergeArray(n,i)}get element(){return this._def.type}min(t,r){return new Be({...this._def,minLength:{value:t,message:b.toString(r)}})}max(t,r){return new Be({...this._def,maxLength:{value:t,message:b.toString(r)}})}length(t,r){return new Be({...this._def,exactLength:{value:t,message:b.toString(r)}})}nonempty(t){return this.min(1,t)}};Se.create=(e,t)=>new Se({type:e,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...N(t)});function be(e){if(e instanceof q){const t={};for(const r in e.shape){const n=e.shape[r];t[r]=le.create(be(n))}return new q({...e._def,shape:()=>t})}else return e instanceof Se?new Se({...e._def,type:be(e.element)}):e instanceof le?le.create(be(e.unwrap())):e instanceof me?me.create(be(e.unwrap())):e instanceof pe?pe.create(e.items.map(t=>be(t))):e}var q=class Q extends A{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(),r=E.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==y.object){const c=this._getOrReturnCtx(t);return k(c,{code:m.invalid_type,expected:y.object,received:c.parsedType}),j}const{status:r,ctx:n}=this._processInputParams(t),{shape:a,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof fe&&this._def.unknownKeys==="strip"))for(const c in n.data)i.includes(c)||s.push(c);const l=[];for(const c of i){const d=a[c],u=n.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new ne(n,u,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof fe){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of s)l.push({key:{status:"valid",value:d},value:{status:"valid",value:n.data[d]}});else if(c==="strict")s.length>0&&(k(n,{code:m.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 u=n.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new ne(n,u,n.path,d)),alwaysSet:d in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of l){const u=await d.key,f=await d.value;c.push({key:u,value:f,alwaysSet:d.alwaysSet})}return c}).then(c=>Y.mergeObjectSync(r,c)):Y.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return b.errToObj,new Q({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{const a=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:b.errToObj(t).message??a}:{message:a}}}:{}})}strip(){return new Q({...this._def,unknownKeys:"strip"})}passthrough(){return new Q({...this._def,unknownKeys:"passthrough"})}extend(t){return new Q({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Q({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:S.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new Q({...this._def,catchall:t})}pick(t){const r={};for(const n of E.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Q({...this._def,shape:()=>r})}omit(t){const r={};for(const n of E.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new Q({...this._def,shape:()=>r})}deepPartial(){return be(this)}partial(t){const r={};for(const n of E.objectKeys(this.shape)){const a=this.shape[n];t&&!t[n]?r[n]=a:r[n]=a.optional()}return new Q({...this._def,shape:()=>r})}required(t){const r={};for(const n of E.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof le;)a=a._def.innerType;r[n]=a}return new Q({...this._def,shape:()=>r})}keyof(){return Er(E.objectKeys(this.shape))}};q.create=(e,t)=>new q({shape:()=>e,unknownKeys:"strip",catchall:fe.create(),typeName:S.ZodObject,...N(t)});q.strictCreate=(e,t)=>new q({shape:()=>e,unknownKeys:"strict",catchall:fe.create(),typeName:S.ZodObject,...N(t)});q.lazycreate=(e,t)=>new q({shape:e,unknownKeys:"strip",catchall:fe.create(),typeName:S.ZodObject,...N(t)});var Ke=class extends A{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function n(a){for(const s of a)if(s.result.status==="valid")return s.result;for(const s of a)if(s.result.status==="dirty")return t.common.issues.push(...s.ctx.common.issues),s.result;const i=a.map(s=>new re(s.ctx.common.issues));return k(t,{code:m.invalid_union,unionErrors:i}),j}if(t.common.async)return Promise.all(r.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a;const i=[];for(const l of r){const c={...t,common:{...t.common,issues:[]},parent:null},d=l._parseSync({data:t.data,path:t.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!a&&(a={result:d,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const s=i.map(l=>new re(l));return k(t,{code:m.invalid_union,unionErrors:s}),j}}get options(){return this._def.options}};Ke.create=(e,t)=>new Ke({options:e,typeName:S.ZodUnion,...N(t)});var se=e=>e instanceof et?se(e.schema):e instanceof ce?se(e.innerType()):e instanceof tt?[e.value]:e instanceof ct?e.options:e instanceof rt?E.objectValues(e.enum):e instanceof nt?se(e._def.innerType):e instanceof Je?[void 0]:e instanceof Qe?[null]:e instanceof le?[void 0,...se(e.unwrap())]:e instanceof me?[null,...se(e.unwrap())]:e instanceof Mr||e instanceof it?se(e.unwrap()):e instanceof at?se(e._def.innerType):[],ra=class Lr extends A{_parse(t){const{ctx:r}=this._processInputParams(t);if(r.parsedType!==y.object)return k(r,{code:m.invalid_type,expected:y.object,received:r.parsedType}),j;const n=this.discriminator,a=r.data[n],i=this.optionsMap.get(a);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(k(r,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),j)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){const a=new Map;for(const i of r){const s=se(i.shape[t]);if(!s.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const l of s){if(a.has(l))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(l)}`);a.set(l,i)}}return new Lr({typeName:S.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:a,...N(n)})}};function Lt(e,t){const r=ue(e),n=ue(t);if(e===t)return{valid:!0,data:e};if(r===y.object&&n===y.object){const a=E.objectKeys(t),i=E.objectKeys(e).filter(l=>a.indexOf(l)!==-1),s={...e,...t};for(const l of i){const c=Lt(e[l],t[l]);if(!c.valid)return{valid:!1};s[l]=c.data}return{valid:!0,data:s}}else if(r===y.array&&n===y.array){if(e.length!==t.length)return{valid:!1};const a=[];for(let i=0;i<e.length;i++){const s=e[i],l=t[i],c=Lt(s,l);if(!c.valid)return{valid:!1};a.push(c.data)}return{valid:!0,data:a}}else return r===y.date&&n===y.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var qe=class extends A{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=(a,i)=>{if(tr(a)||tr(i))return j;const s=Lt(a.value,i.value);return s.valid?((rr(a)||rr(i))&&t.dirty(),{status:t.value,value:s.data}):(k(r,{code:m.invalid_intersection_types}),j)};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(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};qe.create=(e,t,r)=>new qe({left:e,right:t,typeName:S.ZodIntersection,...N(r)});var pe=class Ar extends A{_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==y.array)return k(n,{code:m.invalid_type,expected:y.array,received:n.parsedType}),j;if(n.data.length<this._def.items.length)return k(n,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),j;!this._def.rest&&n.data.length>this._def.items.length&&(k(n,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const a=[...n.data].map((i,s)=>{const l=this._def.items[s]||this._def.rest;return l?l._parse(new ne(n,i,n.path,s)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>Y.mergeArray(r,i)):Y.mergeArray(r,a)}get items(){return this._def.items}rest(t){return new Ar({...this._def,rest:t})}};pe.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new pe({items:e,typeName:S.ZodTuple,rest:null,...N(t)})};var na=class At extends A{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==y.object)return k(n,{code:m.invalid_type,expected:y.object,received:n.parsedType}),j;const a=[],i=this._def.keyType,s=this._def.valueType;for(const l in n.data)a.push({key:i._parse(new ne(n,l,n.path,l)),value:s._parse(new ne(n,n.data[l],n.path,l)),alwaysSet:l in n.data});return n.common.async?Y.mergeObjectAsync(r,a):Y.mergeObjectSync(r,a)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof A?new At({keyType:t,valueType:r,typeName:S.ZodRecord,...N(n)}):new At({keyType:Xe.create(),valueType:t,typeName:S.ZodRecord,...N(r)})}},Et=class extends A{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.map)return k(r,{code:m.invalid_type,expected:y.map,received:r.parsedType}),j;const n=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([s,l],c)=>({key:n._parse(new ne(r,s,r.path,[c,"key"])),value:a._parse(new ne(r,l,r.path,[c,"value"]))}));if(r.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const l of i){const c=await l.key,d=await l.value;if(c.status==="aborted"||d.status==="aborted")return j;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),s.set(c.value,d.value)}return{status:t.value,value:s}})}else{const s=new Map;for(const l of i){const c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return j;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),s.set(c.value,d.value)}return{status:t.value,value:s}}}};Et.create=(e,t,r)=>new Et({valueType:t,keyType:e,typeName:S.ZodMap,...N(r)});var Mt=class Rt extends A{_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==y.set)return k(n,{code:m.invalid_type,expected:y.set,received:n.parsedType}),j;const a=this._def;a.minSize!==null&&n.data.size<a.minSize.value&&(k(n,{code:m.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),r.dirty()),a.maxSize!==null&&n.data.size>a.maxSize.value&&(k(n,{code:m.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),r.dirty());const i=this._def.valueType;function s(c){const d=new Set;for(const u of c){if(u.status==="aborted")return j;u.status==="dirty"&&r.dirty(),d.add(u.value)}return{status:r.value,value:d}}const l=[...n.data.values()].map((c,d)=>i._parse(new ne(n,c,n.path,d)));return n.common.async?Promise.all(l).then(c=>s(c)):s(l)}min(t,r){return new Rt({...this._def,minSize:{value:t,message:b.toString(r)}})}max(t,r){return new Rt({...this._def,maxSize:{value:t,message:b.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};Mt.create=(e,t)=>new Mt({valueType:e,minSize:null,maxSize:null,typeName:S.ZodSet,...N(t)});var aa=class Ge extends A{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:r}=this._processInputParams(t);if(r.parsedType!==y.function)return k(r,{code:m.invalid_type,expected:y.function,received:r.parsedType}),j;function n(l,c){return yt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,kt(),Me].filter(d=>!!d),issueData:{code:m.invalid_arguments,argumentsError:c}})}function a(l,c){return yt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,kt(),Me].filter(d=>!!d),issueData:{code:m.invalid_return_type,returnTypeError:c}})}const i={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof Re){const l=this;return z(async function(...c){const d=new re([]),u=await l._def.args.parseAsync(c,i).catch(p=>{throw d.addIssue(n(c,p)),d}),f=await Reflect.apply(s,this,u);return await l._def.returns._def.type.parseAsync(f,i).catch(p=>{throw d.addIssue(a(f,p)),d})})}else{const l=this;return z(function(...c){const d=l._def.args.safeParse(c,i);if(!d.success)throw new re([n(c,d.error)]);const u=Reflect.apply(s,this,d.data),f=l._def.returns.safeParse(u,i);if(!f.success)throw new re([a(u,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new Ge({...this._def,args:pe.create(t).rest(_e.create())})}returns(t){return new Ge({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new Ge({args:t||pe.create([]).rest(_e.create()),returns:r||_e.create(),typeName:S.ZodFunction,...N(n)})}},et=class extends A{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};et.create=(e,t)=>new et({getter:e,typeName:S.ZodLazy,...N(t)});var tt=class extends A{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return k(t,{received:t.data,code:m.invalid_literal,expected:this._def.value}),j}return{status:"valid",value:e.data}}get value(){return this._def.value}};tt.create=(e,t)=>new tt({value:e,typeName:S.ZodLiteral,...N(t)});function Er(e,t){return new ct({values:e,typeName:S.ZodEnum,...N(t)})}var ct=class Zt extends A{_parse(t){if(typeof t.data!="string"){const r=this._getOrReturnCtx(t),n=this._def.values;return k(r,{expected:E.joinValues(n),received:r.parsedType,code:m.invalid_type}),j}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const r=this._getOrReturnCtx(t),n=this._def.values;return k(r,{received:r.data,code:m.invalid_enum_value,options:n}),j}return z(t.data)}get options(){return this._def.values}get enum(){const t={};for(const r of this._def.values)t[r]=r;return t}get Values(){const t={};for(const r of this._def.values)t[r]=r;return t}get Enum(){const t={};for(const r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return Zt.create(t,{...this._def,...r})}exclude(t,r=this._def){return Zt.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};ct.create=Er;var rt=class extends A{_parse(e){const t=E.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){const n=E.objectValues(t);return k(r,{expected:E.joinValues(n),received:r.parsedType,code:m.invalid_type}),j}if(this._cache||(this._cache=new Set(E.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const n=E.objectValues(t);return k(r,{received:r.data,code:m.invalid_enum_value,options:n}),j}return z(e.data)}get enum(){return this._def.values}};rt.create=(e,t)=>new rt({values:e,typeName:S.ZodNativeEnum,...N(t)});var Re=class extends A{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);return t.parsedType!==y.promise&&t.common.async===!1?(k(t,{code:m.invalid_type,expected:y.promise,received:t.parsedType}),j):z((t.parsedType===y.promise?t.data:Promise.resolve(t.data)).then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Re.create=(e,t)=>new Re({type:e,typeName:S.ZodPromise,...N(t)});var ce=class extends A{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{k(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const i=n.transform(r.data,a);if(r.common.async)return Promise.resolve(i).then(async s=>{if(t.value==="aborted")return j;const l=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return l.status==="aborted"?j:l.status==="dirty"||t.value==="dirty"?Le(l.value):l});{if(t.value==="aborted")return j;const s=this._def.schema._parseSync({data:i,path:r.path,parent:r});return s.status==="aborted"?j:s.status==="dirty"||t.value==="dirty"?Le(s.value):s}}if(n.type==="refinement"){const i=s=>{const l=n.refinement(s,a);if(r.common.async)return Promise.resolve(l);if(l 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"?j:(s.status==="dirty"&&t.dirty(),i(s.value),{status:t.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?j:(s.status==="dirty"&&t.dirty(),i(s.value).then(()=>({status:t.value,value:s.value}))))}if(n.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!je(i))return j;const s=n.transform(i.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>je(i)?Promise.resolve(n.transform(i.value,a)).then(s=>({status:t.value,value:s})):j);E.assertNever(n)}};ce.create=(e,t,r)=>new ce({schema:e,typeName:S.ZodEffects,effect:t,...N(r)});ce.createWithPreprocess=(e,t,r)=>new ce({schema:t,effect:{type:"preprocess",transform:e},typeName:S.ZodEffects,...N(r)});var le=class extends A{_parse(e){return this._getType(e)===y.undefined?z(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};le.create=(e,t)=>new le({innerType:e,typeName:S.ZodOptional,...N(t)});var me=class extends A{_parse(e){return this._getType(e)===y.null?z(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};me.create=(e,t)=>new me({innerType:e,typeName:S.ZodNullable,...N(t)});var nt=class extends A{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===y.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};nt.create=(e,t)=>new nt({innerType:e,typeName:S.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...N(t)});var at=class extends A{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ye(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new re(r.common.issues)},input:r.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new re(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};at.create=(e,t)=>new at({innerType:e,typeName:S.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...N(t)});var Ot=class extends A{_parse(e){if(this._getType(e)!==y.nan){const t=this._getOrReturnCtx(e);return k(t,{code:m.invalid_type,expected:y.nan,received:t.parsedType}),j}return{status:"valid",value:e.data}}};Ot.create=e=>new Ot({typeName:S.ZodNaN,...N(e)});var Mr=class extends A{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}},Rr=class Zr extends A{_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?j:i.status==="dirty"?(r.dirty(),Le(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?j:a.status==="dirty"?(r.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(t,r){return new Zr({in:t,out:r,typeName:S.ZodPipeline})}},it=class extends A{_parse(e){const t=this._def.innerType._parse(e),r=n=>(je(n)&&(n.value=Object.freeze(n.value)),n);return Ye(t)?t.then(n=>r(n)):r(t)}unwrap(){return this._def.innerType}};it.create=(e,t)=>new it({innerType:e,typeName:S.ZodReadonly,...N(t)});var xo={object:q.lazycreate},S;(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"})(S||(S={}));var F=Xe.create,ko=bt.create,yo=Ot.create,bo=wt.create,mt=St.create,_o=Ct.create,wo=It.create,jo=Je.create,So=Qe.create,Co=Nt.create,ia=_e.create,Io=fe.create,No=Tt.create,To=Se.create,Bt=q.create,Lo=q.strictCreate,Ao=Ke.create,Eo=ra.create,Mo=qe.create,Ro=pe.create,sa=na.create,Zo=Et.create,Oo=Mt.create,Fo=aa.create,Po=et.create,$o=tt.create,Ft=ct.create,Wo=rt.create,Vo=Re.create,Do=ce.create,zo=le.create,Uo=me.create,Bo=ce.createWithPreprocess,Go=Rr.create,oa=Bt({mode:Ft(["light","dark","system"]).optional(),accentColor:F().optional(),fontFamily:F().optional(),borderRadius:F().optional()}),la=Bt({externalId:F().optional(),authId:F().optional(),name:F().optional(),email:F().optional()}),Or=Bt({agentId:F().min(1,"agentId is required"),apiBaseUrl:F().url("apiBaseUrl must be a valid URL"),tenantId:F().optional(),user:la.optional(),sessionId:F().optional(),mode:Ft(["floating","inline"]).optional(),title:F().optional(),subtitle:F().optional(),description:F().optional(),avatarUrl:F().optional(),privacyPolicyUrl:F().optional(),termsOfServiceUrl:F().optional(),disclosureText:F().optional(),streaming:mt().optional(),preview:mt().optional(),skipServerConfigFetch:mt().optional(),configChannel:Ft(["draft","published"]).optional(),metadata:sa(ia()).optional(),theme:oa.optional()}),ca=Or.omit({agentId:!0,apiBaseUrl:!0}).partial();var he={mode:"floating",streaming:!0,title:"AI Assistant",theme:{mode:"light",accentColor:"#6366f1",fontFamily:"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",borderRadius:"12px"}};function Ce(e,t){Or.parse(e);let r;const n=t?{...t}:void 0;n&&typeof n.theme=="object"&&n.theme!==null?(r=n.theme,delete n.theme):n&&typeof n.theme=="string"&&(r={mode:n.theme},delete n.theme);const a=n?ca.passthrough().safeParse(n).data:void 0,i=a?Fr(a,e):e,s={mode:i.theme?.mode??r?.mode??he.theme.mode,accentColor:i.theme?.accentColor??r?.accentColor??he.theme.accentColor,fontFamily:i.theme?.fontFamily??r?.fontFamily??he.theme.fontFamily,borderRadius:i.theme?.borderRadius??r?.borderRadius??he.theme.borderRadius};return{agentId:i.agentId,apiBaseUrl:i.apiBaseUrl.replace(/\/$/,""),tenantId:i.tenantId,user:{externalId:i.user?.externalId,authId:i.user?.authId,name:i.user?.name,email:i.user?.email},sessionId:i.sessionId,mode:i.mode??he.mode,title:i.title??he.title,subtitle:i.subtitle,description:i.description,suggestedQuestions:(()=>{const l=a?.suggestedQuestions;return Array.isArray(l)?l:[]})(),avatarUrl:i.avatarUrl,privacyPolicyUrl:i.privacyPolicyUrl,termsOfServiceUrl:i.termsOfServiceUrl,disclosureText:i.disclosureText??"This chat may be processed by AI and stored to provide support and improve your experience.",streaming:i.streaming??he.streaming,preview:i.preview===!0,skipServerConfigFetch:i.skipServerConfigFetch===!0,configChannel:i.configChannel,metadata:i.metadata??{},theme:s,photoSendingEnabled:a?.photoSendingEnabled===!0,fileUploadEnabled:a?.fileUploadEnabled===!0,attachmentMaxCount:(()=>{const l=a?.attachmentMaxCount;return typeof l=="number"&&Number.isFinite(l)?l:5})(),attachmentMaxFileSizeMb:(()=>{const l=a?.attachmentMaxFileSizeMb;return typeof l=="number"&&Number.isFinite(l)?l:1})()}}function Fr(e,t){const r={...e};for(const n of Object.keys(t)){const a=t[n];a!=null&&(typeof a=="object"&&!Array.isArray(a)&&r[n]!==null&&typeof r[n]=="object"?r[n]=Fr(r[n],a):r[n]=a)}return r}var Pt=function(){return Pt=Object.assign||function(t){for(var r,n=1,a=arguments.length;n<a;n++){r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},Pt.apply(this,arguments)};function ae(e,t,r,n){function a(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function l(u){try{d(n.next(u))}catch(f){s(f)}}function c(u){try{d(n.throw(u))}catch(f){s(f)}}function d(u){u.done?i(u.value):a(u.value).then(l,c)}d((n=n.apply(e,t||[])).next())})}function ie(e,t){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,a,i,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=l(0),s.throw=l(1),s.return=l(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(d){return function(u){return c([d,u])}}function c(d){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,d[0]&&(r=0)),r;)try{if(n=1,a&&(i=d[0]&2?a.return:d[0]?a.throw||((i=a.return)&&i.call(a),0):a.next)&&!(i=i.call(a,d[1])).done)return i;switch(a=0,i&&(d=[d[0]&2,i.value]),d[0]){case 0:case 1:i=d;break;case 4:return r.label++,{value:d[1],done:!1};case 5:r.label++,a=d[1],d=[0];continue;case 7:d=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!(i=i.length>0&&i[i.length-1])&&(d[0]===6||d[0]===2)){r=0;continue}if(d[0]===3&&(!i||d[1]>i[0]&&d[1]<i[3])){r.label=d[1];break}if(d[0]===6&&r.label<i[1]){r.label=i[1],i=d;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(d);break}i[2]&&r.ops.pop(),r.trys.pop();continue}d=t.call(e,r)}catch(u){d=[6,u],a=0}finally{n=i=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}function Pr(e,t,r){if(r||arguments.length===2)for(var n=0,a=t.length,i;n<a;n++)(i||!(n in t))&&(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))}var $r="4.6.2";function st(e,t){return new Promise(function(r){return setTimeout(r,e,t)})}function da(){return new Promise(function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})}function ua(e,t){t===void 0&&(t=1/0);var r=window.requestIdleCallback;return r?new Promise(function(n){return r.call(window,function(){return n()},{timeout:t})}):st(Math.min(e,t))}function Wr(e){return!!e&&typeof e.then=="function"}function ar(e,t){try{var r=e();Wr(r)?r.then(function(n){return t(!0,n)},function(n){return t(!1,n)}):t(!0,r)}catch(n){t(!1,n)}}function ir(e,t,r){return r===void 0&&(r=16),ae(this,void 0,void 0,function(){var n,a,i,s;return ie(this,function(l){switch(l.label){case 0:n=Array(e.length),a=Date.now(),i=0,l.label=1;case 1:return i<e.length?(n[i]=t(e[i],i),s=Date.now(),s>=a+r?(a=s,[4,da()]):[3,3]):[3,4];case 2:l.sent(),l.label=3;case 3:return++i,[3,1];case 4:return[2,n]}})})}function Ze(e){return e.then(void 0,function(){}),e}function fa(e,t){for(var r=0,n=e.length;r<n;++r)if(e[r]===t)return!0;return!1}function ha(e,t){return!fa(e,t)}function Gt(e){return parseInt(e)}function K(e){return parseFloat(e)}function oe(e,t){return typeof e=="number"&&isNaN(e)?t:e}function V(e){return e.reduce(function(t,r){return t+(r?1:0)},0)}function Vr(e,t){if(t===void 0&&(t=1),Math.abs(t)>=1)return Math.round(e/t)*t;var r=1/t;return Math.round(e*r)/r}function pa(e){for(var t,r,n="Unexpected syntax '".concat(e,"'"),a=/^\s*([a-z-]*)(.*)$/i.exec(e),i=a[1]||void 0,s={},l=/([.:#][\w-]+|\[.+?\])/gi,c=function(p,h){s[p]=s[p]||[],s[p].push(h)};;){var d=l.exec(a[2]);if(!d)break;var u=d[0];switch(u[0]){case".":c("class",u.slice(1));break;case"#":c("id",u.slice(1));break;case"[":var f=/^\[([\w-]+)([~|^$*]?=("(.*?)"|([\w-]+)))?(\s+[is])?\]$/.exec(u);if(f)c(f[1],(r=(t=f[4])!==null&&t!==void 0?t:f[5])!==null&&r!==void 0?r:"");else throw new Error(n);break;default:throw new Error(n)}}return[i,s]}function ma(e){for(var t=new Uint8Array(e.length),r=0;r<e.length;r++){var n=e.charCodeAt(r);if(n>127)return new TextEncoder().encode(e);t[r]=n}return t}function de(e,t){var r=e[0]>>>16,n=e[0]&65535,a=e[1]>>>16,i=e[1]&65535,s=t[0]>>>16,l=t[0]&65535,c=t[1]>>>16,d=t[1]&65535,u=0,f=0,p=0,h=0;h+=i+d,p+=h>>>16,h&=65535,p+=a+c,f+=p>>>16,p&=65535,f+=n+l,u+=f>>>16,f&=65535,u+=r+s,u&=65535,e[0]=u<<16|f,e[1]=p<<16|h}function X(e,t){var r=e[0]>>>16,n=e[0]&65535,a=e[1]>>>16,i=e[1]&65535,s=t[0]>>>16,l=t[0]&65535,c=t[1]>>>16,d=t[1]&65535,u=0,f=0,p=0,h=0;h+=i*d,p+=h>>>16,h&=65535,p+=a*d,f+=p>>>16,p&=65535,p+=i*c,f+=p>>>16,p&=65535,f+=n*d,u+=f>>>16,f&=65535,f+=a*c,u+=f>>>16,f&=65535,f+=i*l,u+=f>>>16,f&=65535,u+=r*d+n*c+a*l+i*s,u&=65535,e[0]=u<<16|f,e[1]=p<<16|h}function ve(e,t){var r=e[0];t%=64,t===32?(e[0]=e[1],e[1]=r):t<32?(e[0]=r<<t|e[1]>>>32-t,e[1]=e[1]<<t|r>>>32-t):(t-=32,e[0]=e[1]<<t|r>>>32-t,e[1]=r<<t|e[1]>>>32-t)}function G(e,t){t%=64,t!==0&&(t<32?(e[0]=e[1]>>>32-t,e[1]=e[1]<<t):(e[0]=e[1]<<t-32,e[1]=0))}function Z(e,t){e[0]^=t[0],e[1]^=t[1]}var ga=[4283543511,3981806797],va=[3301882366,444984403];function sr(e){var t=[0,e[0]>>>1];Z(e,t),X(e,ga),t[1]=e[0]>>>1,Z(e,t),X(e,va),t[1]=e[0]>>>1,Z(e,t)}var ze=[2277735313,289559509],Ue=[1291169091,658871167],or=[0,5],xa=[0,1390208809],ka=[0,944331445];function ya(e,t){var r=ma(e);t=t||0;var n=[0,r.length],a=n[1]%16,i=n[1]-a,s=[0,t],l=[0,t],c=[0,0],d=[0,0],u;for(u=0;u<i;u=u+16)c[0]=r[u+4]|r[u+5]<<8|r[u+6]<<16|r[u+7]<<24,c[1]=r[u]|r[u+1]<<8|r[u+2]<<16|r[u+3]<<24,d[0]=r[u+12]|r[u+13]<<8|r[u+14]<<16|r[u+15]<<24,d[1]=r[u+8]|r[u+9]<<8|r[u+10]<<16|r[u+11]<<24,X(c,ze),ve(c,31),X(c,Ue),Z(s,c),ve(s,27),de(s,l),X(s,or),de(s,xa),X(d,Ue),ve(d,33),X(d,ze),Z(l,d),ve(l,31),de(l,s),X(l,or),de(l,ka);c[0]=0,c[1]=0,d[0]=0,d[1]=0;var f=[0,0];switch(a){case 15:f[1]=r[u+14],G(f,48),Z(d,f);case 14:f[1]=r[u+13],G(f,40),Z(d,f);case 13:f[1]=r[u+12],G(f,32),Z(d,f);case 12:f[1]=r[u+11],G(f,24),Z(d,f);case 11:f[1]=r[u+10],G(f,16),Z(d,f);case 10:f[1]=r[u+9],G(f,8),Z(d,f);case 9:f[1]=r[u+8],Z(d,f),X(d,Ue),ve(d,33),X(d,ze),Z(l,d);case 8:f[1]=r[u+7],G(f,56),Z(c,f);case 7:f[1]=r[u+6],G(f,48),Z(c,f);case 6:f[1]=r[u+5],G(f,40),Z(c,f);case 5:f[1]=r[u+4],G(f,32),Z(c,f);case 4:f[1]=r[u+3],G(f,24),Z(c,f);case 3:f[1]=r[u+2],G(f,16),Z(c,f);case 2:f[1]=r[u+1],G(f,8),Z(c,f);case 1:f[1]=r[u],Z(c,f),X(c,ze),ve(c,31),X(c,Ue),Z(s,c)}return Z(s,n),Z(l,n),de(s,l),de(l,s),sr(s),sr(l),de(s,l),de(l,s),("00000000"+(s[0]>>>0).toString(16)).slice(-8)+("00000000"+(s[1]>>>0).toString(16)).slice(-8)+("00000000"+(l[0]>>>0).toString(16)).slice(-8)+("00000000"+(l[1]>>>0).toString(16)).slice(-8)}function ba(e){var t;return Pt({name:e.name,message:e.message,stack:(t=e.stack)===null||t===void 0?void 0:t.split(`
|
|
2
|
-
`)},e)}function _a(e){return/^function\s.*?\{\s*\[native code]\s*}$/.test(String(e))}function wa(e){return typeof e!="function"}function ja(e,t){var r=Ze(new Promise(function(n){var a=Date.now();ar(e.bind(null,t),function(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];var l=Date.now()-a;if(!i[0])return n(function(){return{error:i[1],duration:l}});var c=i[1];if(wa(c))return n(function(){return{value:c,duration:l}});n(function(){return new Promise(function(d){var u=Date.now();ar(c,function(){for(var f=[],p=0;p<arguments.length;p++)f[p]=arguments[p];var h=l+Date.now()-u;if(!f[0])return d({error:f[1],duration:h});d({value:f[1],duration:h})})})})})}));return function(){return r.then(function(a){return a()})}}function Sa(e,t,r,n){var a=Object.keys(e).filter(function(s){return ha(r,s)}),i=Ze(ir(a,function(s){return ja(e[s],t)},n));return function(){return ae(this,void 0,void 0,function(){var l,c,d,u,f;return ie(this,function(p){switch(p.label){case 0:return[4,i];case 1:return l=p.sent(),[4,ir(l,function(h){return Ze(h())},n)];case 2:return c=p.sent(),[4,Promise.all(c)];case 3:for(d=p.sent(),u={},f=0;f<a.length;++f)u[a[f]]=d[f];return[2,u]}})})}}function Dr(){var e=window,t=navigator;return V(["MSCSSMatrix"in e,"msSetImmediate"in e,"msIndexedDB"in e,"msMaxTouchPoints"in t,"msPointerEnabled"in t])>=4}function Ca(){var e=window,t=navigator;return V(["msWriteProfilerMark"in e,"MSStream"in e,"msLaunchUri"in t,"msSaveBlob"in t])>=3&&!Dr()}function Fe(){var e=window,t=navigator;return V(["webkitPersistentStorage"in t,"webkitTemporaryStorage"in t,(t.vendor||"").indexOf("Google")===0,"webkitResolveLocalFileSystemURL"in e,"BatteryManager"in e,"webkitMediaStream"in e,"webkitSpeechGrammar"in e])>=5}function ee(){var e=window,t=navigator;return V(["ApplePayError"in e,"CSSPrimitiveValue"in e,"Counter"in e,t.vendor.indexOf("Apple")===0,"RGBColor"in e,"WebKitMediaKeys"in e])>=4}function Ht(){var e=window,t=e.HTMLElement,r=e.Document;return V(["safari"in e,!("ongestureend"in e),!("TouchEvent"in e),!("orientation"in e),t&&!("autocapitalize"in t.prototype),r&&"pointerLockElement"in r.prototype])>=4}function Pe(){var e=window;return _a(e.print)&&String(e.browser)==="[object WebPageNamespace]"}function zr(){var e,t,r=window;return V(["buildID"in navigator,"MozAppearance"in((t=(e=document.documentElement)===null||e===void 0?void 0:e.style)!==null&&t!==void 0?t:{}),"onmozfullscreenchange"in r,"mozInnerScreenX"in r,"CSSMozDocumentRule"in r,"CanvasCaptureMediaStream"in r])>=4}function Ia(){var e=window;return V([!("MediaSettingsRange"in e),"RTCEncodedAudioFrame"in e,""+e.Intl=="[object Intl]",""+e.Reflect=="[object Reflect]"])>=3}function Na(){var e=window,t=e.URLPattern;return V(["union"in Set.prototype,"Iterator"in e,t&&"hasRegExpGroups"in t.prototype,"RGB8"in WebGLRenderingContext.prototype])>=3}function Ta(){var e=window;return V(["DOMRectList"in e,"RTCPeerConnectionIceEvent"in e,"SVGGeometryElement"in e,"ontransitioncancel"in e])>=3}function $e(){var e=window,t=navigator,r=e.CSS,n=e.HTMLButtonElement;return V([!("getStorageUpdates"in t),n&&"popover"in n.prototype,"CSSCounterStyleRule"in e,r.supports("font-size-adjust: ex-height 0.5"),r.supports("text-transform: full-width")])>=4}function La(){if(navigator.platform==="iPad")return!0;var e=screen,t=e.width/e.height;return V(["MediaSource"in window,!!Element.prototype.webkitRequestFullscreen,t>.65&&t<1.53])>=2}function Aa(){var e=document;return e.fullscreenElement||e.msFullscreenElement||e.mozFullScreenElement||e.webkitFullscreenElement||null}function Ea(){var e=document;return(e.exitFullscreen||e.msExitFullscreen||e.mozCancelFullScreen||e.webkitExitFullscreen).call(e)}function Yt(){var e=Fe(),t=zr(),r=window,n=navigator,a="connection";return e?V([!("SharedWorker"in r),n[a]&&"ontypechange"in n[a],!("sinkId"in new Audio)])>=2:t?V(["onorientationchange"in r,"orientation"in r,/android/i.test(n.appVersion)])>=2:!1}function Ma(){var e=navigator,t=window,r=Audio.prototype,n=t.visualViewport;return V(["srLatency"in r,"srChannelCount"in r,"devicePosture"in e,n&&"segments"in n,"getTextInformation"in Image.prototype])>=3}function Ra(){return Fa()?-4:Za()}function Za(){var e=window,t=e.OfflineAudioContext||e.webkitOfflineAudioContext;if(!t)return-2;if(Oa())return-1;var r=4500,n=new t(1,5e3,44100),a=n.createOscillator();a.type="triangle",a.frequency.value=1e4;var i=n.createDynamicsCompressor();i.threshold.value=-50,i.knee.value=40,i.ratio.value=12,i.attack.value=0,i.release.value=.25,a.connect(i),i.connect(n.destination),a.start(0);var s=Pa(n),l=s[0],c=s[1],d=Ze(l.then(function(u){return $a(u.getChannelData(0).subarray(r))},function(u){if(u.name==="timeout"||u.name==="suspended")return-3;throw u}));return function(){return c(),d}}function Oa(){return ee()&&!Ht()&&!Ta()}function Fa(){return ee()&&$e()&&Pe()||Fe()&&Ma()&&Na()}function Pa(e){var t=3,r=500,n=500,a=5e3,i=function(){};return[new Promise(function(s,l){var c=!1,d=0,u=0;e.oncomplete=function(h){return s(h.renderedBuffer)};var f=function(){setTimeout(function(){return l(lr("timeout"))},Math.min(n,u+a-Date.now()))},p=function(){try{var h=e.startRendering();switch(Wr(h)&&Ze(h),e.state){case"running":u=Date.now(),c&&f();break;case"suspended":document.hidden||d++,c&&d>=t?l(lr("suspended")):setTimeout(p,r);break}}catch(x){l(x)}};p(),i=function(){c||(c=!0,u>0&&f())}}),i]}function $a(e){for(var t=0,r=0;r<e.length;++r)t+=Math.abs(e[r]);return t}function lr(e){var t=new Error(e);return t.name=e,t}function Ur(e,t,r){var n,a,i;return r===void 0&&(r=50),ae(this,void 0,void 0,function(){var s,l;return ie(this,function(c){switch(c.label){case 0:s=document,c.label=1;case 1:return s.body?[3,3]:[4,st(r)];case 2:return c.sent(),[3,1];case 3:l=s.createElement("iframe"),c.label=4;case 4:return c.trys.push([4,,10,11]),[4,new Promise(function(d,u){var f=!1,p=function(){f=!0,d()},h=function(w){f=!0,u(w)};l.onload=p,l.onerror=h;var x=l.style;x.setProperty("display","block","important"),x.position="absolute",x.top="0",x.left="0",x.visibility="hidden",t&&"srcdoc"in l?l.srcdoc=t:l.src="about:blank",s.body.appendChild(l);var v=function(){var w,g;f||(((g=(w=l.contentWindow)===null||w===void 0?void 0:w.document)===null||g===void 0?void 0:g.readyState)==="complete"?p():setTimeout(v,10))};v()})];case 5:c.sent(),c.label=6;case 6:return!((a=(n=l.contentWindow)===null||n===void 0?void 0:n.document)===null||a===void 0)&&a.body?[3,8]:[4,st(r)];case 7:return c.sent(),[3,6];case 8:return[4,e(l,l.contentWindow)];case 9:return[2,c.sent()];case 10:return(i=l.parentNode)===null||i===void 0||i.removeChild(l),[7];case 11:return[2]}})})}function Wa(e){for(var t=pa(e),r=t[0],n=t[1],a=document.createElement(r??"div"),i=0,s=Object.keys(n);i<s.length;i++){var l=s[i],c=n[l].join(" ");l==="style"?Va(a.style,c):a.setAttribute(l,c)}return a}function Va(e,t){for(var r=0,n=t.split(";");r<n.length;r++){var a=n[r],i=/^\s*([\w-]+)\s*:\s*(.+?)(\s*!([\w-]+))?\s*$/.exec(a);if(i){var s=i[1],l=i[2],c=i[4];e.setProperty(s,l,c||"")}}}function Da(){for(var e=window;;){var t=e.parent;if(!t||t===e)return!1;try{if(t.location.origin!==e.location.origin)return!0}catch(r){if(r instanceof Error&&r.name==="SecurityError")return!0;throw r}e=t}}var za="mmMwWLliI0O&1",Ua="48px",xe=["monospace","sans-serif","serif"],cr=["sans-serif-thin","ARNO PRO","Agency FB","Arabic Typesetting","Arial Unicode MS","AvantGarde Bk BT","BankGothic Md BT","Batang","Bitstream Vera Sans Mono","Calibri","Century","Century Gothic","Clarendon","EUROSTILE","Franklin Gothic","Futura Bk BT","Futura Md BT","GOTHAM","Gill Sans","HELV","Haettenschweiler","Helvetica Neue","Humanst521 BT","Leelawadee","Letter Gothic","Levenim MT","Lucida Bright","Lucida Sans","Menlo","MS Mincho","MS Outlook","MS Reference Specialty","MS UI Gothic","MT Extra","MYRIAD PRO","Marlett","Meiryo UI","Microsoft Uighur","Minion Pro","Monotype Corsiva","PMingLiU","Pristina","SCRIPTINA","Segoe UI Light","Serifa","SimHei","Small Fonts","Staccato222 BT","TRAJAN PRO","Univers CE 55 Medium","Vrinda","ZWAdobeF"];function Ba(){var e=this;return Ur(function(t,r){var n=r.document;return ae(e,void 0,void 0,function(){var a,i,s,l,c,d,u,f,p,h,x,v;return ie(this,function(w){for(a=n.body,a.style.fontSize=Ua,i=n.createElement("div"),i.style.setProperty("visibility","hidden","important"),s={},l={},c=function(g){var I=n.createElement("span"),R=I.style;return R.position="absolute",R.top="0",R.left="0",R.fontFamily=g,I.textContent=za,i.appendChild(I),I},d=function(g,I){return c("'".concat(g,"',").concat(I))},u=function(){return xe.map(c)},f=function(){for(var g={},I=function(D){g[D]=xe.map(function(_){return d(D,_)})},R=0,P=cr;R<P.length;R++){var U=P[R];I(U)}return g},p=function(g){return xe.some(function(I,R){return g[R].offsetWidth!==s[I]||g[R].offsetHeight!==l[I]})},h=u(),x=f(),a.appendChild(i),v=0;v<xe.length;v++)s[xe[v]]=h[v].offsetWidth,l[xe[v]]=h[v].offsetHeight;return[2,cr.filter(function(g){return p(x[g])})]})})})}function Ga(){var e=navigator.plugins;if(e){for(var t=[],r=0;r<e.length;++r){var n=e[r];if(n){for(var a=[],i=0;i<n.length;++i){var s=n[i];a.push({type:s.type,suffixes:s.suffixes})}t.push({name:n.name,description:n.description,mimeTypes:a})}}return t}}function Ha(){return Ya(ti())}function Ya(e){var t,r=!1,n,a,i=Xa(),s=i[0],l=i[1];return Ja(s,l)?(r=Qa(l),e?n=a="skipped":(t=Ka(s,l),n=t[0],a=t[1])):n=a="unsupported",{winding:r,geometry:n,text:a}}function Xa(){var e=document.createElement("canvas");return e.width=1,e.height=1,[e,e.getContext("2d")]}function Ja(e,t){return!!(t&&e.toDataURL)}function Qa(e){return e.rect(0,0,10,10),e.rect(2,2,6,6),!e.isPointInPath(5,5,"evenodd")}function Ka(e,t){qa(e,t);var r=gt(e);return r!==gt(e)?["unstable","unstable"]:(ei(e,t),[gt(e),r])}function qa(e,t){e.width=240,e.height=60,t.textBaseline="alphabetic",t.fillStyle="#f60",t.fillRect(100,1,62,20),t.fillStyle="#069",t.font='11pt "Times New Roman"';var r="Cwm fjordbank gly ".concat("😃");t.fillText(r,2,15),t.fillStyle="rgba(102, 204, 0, 0.2)",t.font="18pt Arial",t.fillText(r,4,45)}function ei(e,t){e.width=122,e.height=110,t.globalCompositeOperation="multiply";for(var r=0,n=[["#f2f",40,40],["#2ff",80,40],["#ff2",60,80]];r<n.length;r++){var a=n[r],i=a[0],s=a[1],l=a[2];t.fillStyle=i,t.beginPath(),t.arc(s,l,40,0,Math.PI*2,!0),t.closePath(),t.fill()}t.fillStyle="#f9c",t.arc(60,60,60,0,Math.PI*2,!0),t.arc(60,60,20,0,Math.PI*2,!0),t.fill("evenodd")}function gt(e){return e.toDataURL()}function ti(){return ee()&&$e()&&Pe()}function ri(){var e=navigator,t=0,r;e.maxTouchPoints!==void 0?t=Gt(e.maxTouchPoints):e.msMaxTouchPoints!==void 0&&(t=e.msMaxTouchPoints);try{document.createEvent("TouchEvent"),r=!0}catch{r=!1}var n="ontouchstart"in window;return{maxTouchPoints:t,touchEvent:r,touchStart:n}}function ni(){return navigator.oscpu}function ai(){var e=navigator,t=[],r=e.language||e.userLanguage||e.browserLanguage||e.systemLanguage;if(r!==void 0&&t.push([r]),Array.isArray(e.languages))Fe()&&Ia()||t.push(e.languages);else if(typeof e.languages=="string"){var n=e.languages;n&&t.push(n.split(","))}return t}function ii(){return window.screen.colorDepth}function si(){return oe(K(navigator.deviceMemory),void 0)}function oi(){if(!(ee()&&$e()&&Pe()))return li()}function li(){var e=screen,t=function(n){return oe(Gt(n),null)},r=[t(e.width),t(e.height)];return r.sort().reverse(),r}var ci=2500,di=10,He,vt;function ui(){if(vt===void 0){var e=function(){var t=$t();Wt(t)?vt=setTimeout(e,ci):(He=t,vt=void 0)};e()}}function fi(){var e=this;return ui(),function(){return ae(e,void 0,void 0,function(){var t;return ie(this,function(r){switch(r.label){case 0:return t=$t(),Wt(t)?He?[2,Pr([],He,!0)]:Aa()?[4,Ea()]:[3,2]:[3,2];case 1:r.sent(),t=$t(),r.label=2;case 2:return Wt(t)||(He=t),[2,t]}})})}}function hi(){var e=this;if(ee()&&$e()&&Pe())return function(){return Promise.resolve(void 0)};var t=fi();return function(){return ae(e,void 0,void 0,function(){var r,n;return ie(this,function(a){switch(a.label){case 0:return[4,t()];case 1:return r=a.sent(),n=function(i){return i===null?null:Vr(i,di)},[2,[n(r[0]),n(r[1]),n(r[2]),n(r[3])]]}})})}}function $t(){var e=screen;return[oe(K(e.availTop),null),oe(K(e.width)-K(e.availWidth)-oe(K(e.availLeft),0),null),oe(K(e.height)-K(e.availHeight)-oe(K(e.availTop),0),null),oe(K(e.availLeft),null)]}function Wt(e){for(var t=0;t<4;++t)if(e[t])return!1;return!0}function pi(){return oe(Gt(navigator.hardwareConcurrency),void 0)}function mi(){var e,t=(e=window.Intl)===null||e===void 0?void 0:e.DateTimeFormat;if(t){var r=new t().resolvedOptions().timeZone;if(r)return r}var n=-gi();return"UTC".concat(n>=0?"+":"").concat(n)}function gi(){var e=new Date().getFullYear();return Math.max(K(new Date(e,0,1).getTimezoneOffset()),K(new Date(e,6,1).getTimezoneOffset()))}function vi(){try{return!!window.sessionStorage}catch{return!0}}function xi(){try{return!!window.localStorage}catch{return!0}}function ki(){if(!(Dr()||Ca()))try{return!!window.indexedDB}catch{return!0}}function yi(){return!!window.openDatabase}function bi(){return navigator.cpuClass}function _i(){var e=navigator.platform;return e==="MacIntel"&&ee()&&!Ht()?La()?"iPad":"iPhone":e}function wi(){return navigator.vendor||""}function ji(){for(var e=[],t=0,r=["chrome","safari","__crWeb","__gCrWeb","yandex","__yb","__ybro","__firefox__","__edgeTrackingPreventionStatistics","webkit","oprt","samsungAr","ucweb","UCShellJava","puffinDevice"];t<r.length;t++){var n=r[t],a=window[n];a&&typeof a=="object"&&e.push(n)}return e.sort()}function Si(){var e=document;try{e.cookie="cookietest=1; SameSite=Strict;";var t=e.cookie.indexOf("cookietest=")!==-1;return e.cookie="cookietest=1; SameSite=Strict; expires=Thu, 01-Jan-1970 00:00:01 GMT",t}catch{return!1}}function Ci(){var e=atob;return{abpIndo:["#Iklan-Melayang","#Kolom-Iklan-728","#SidebarIklan-wrapper",'[title="ALIENBOLA" i]',e("I0JveC1CYW5uZXItYWRz")],abpvn:[".quangcao","#mobileCatfish",e("LmNsb3NlLWFkcw=="),'[id^="bn_bottom_fixed_"]',"#pmadv"],adBlockFinland:[".mainostila",e("LnNwb25zb3JpdA=="),".ylamainos",e("YVtocmVmKj0iL2NsaWNrdGhyZ2guYXNwPyJd"),e("YVtocmVmXj0iaHR0cHM6Ly9hcHAucmVhZHBlYWsuY29tL2FkcyJd")],adBlockPersian:["#navbar_notice_50",".kadr",'TABLE[width="140px"]',"#divAgahi",e("YVtocmVmXj0iaHR0cDovL2cxLnYuZndtcm0ubmV0L2FkLyJd")],adBlockWarningRemoval:["#adblock-honeypot",".adblocker-root",".wp_adblock_detect",e("LmhlYWRlci1ibG9ja2VkLWFk"),e("I2FkX2Jsb2NrZXI=")],adGuardAnnoyances:[".hs-sosyal","#cookieconsentdiv",'div[class^="app_gdpr"]',".as-oil",'[data-cypress="soft-push-notification-modal"]'],adGuardBase:[".BetterJsPopOverlay",e("I2FkXzMwMFgyNTA="),e("I2Jhbm5lcmZsb2F0MjI="),e("I2NhbXBhaWduLWJhbm5lcg=="),e("I0FkLUNvbnRlbnQ=")],adGuardChinese:[e("LlppX2FkX2FfSA=="),e("YVtocmVmKj0iLmh0aGJldDM0LmNvbSJd"),"#widget-quan",e("YVtocmVmKj0iLzg0OTkyMDIwLnh5eiJd"),e("YVtocmVmKj0iLjE5NTZobC5jb20vIl0=")],adGuardFrench:["#pavePub",e("LmFkLWRlc2t0b3AtcmVjdGFuZ2xl"),".mobile_adhesion",".widgetadv",e("LmFkc19iYW4=")],adGuardGerman:['aside[data-portal-id="leaderboard"]'],adGuardJapanese:["#kauli_yad_1",e("YVtocmVmXj0iaHR0cDovL2FkMi50cmFmZmljZ2F0ZS5uZXQvIl0="),e("Ll9wb3BJbl9pbmZpbml0ZV9hZA=="),e("LmFkZ29vZ2xl"),e("Ll9faXNib29zdFJldHVybkFk")],adGuardMobile:[e("YW1wLWF1dG8tYWRz"),e("LmFtcF9hZA=="),'amp-embed[type="24smi"]',"#mgid_iframe1",e("I2FkX2ludmlld19hcmVh")],adGuardRussian:[e("YVtocmVmXj0iaHR0cHM6Ly9hZC5sZXRtZWFkcy5jb20vIl0="),e("LnJlY2xhbWE="),'div[id^="smi2adblock"]',e("ZGl2W2lkXj0iQWRGb3hfYmFubmVyXyJd"),"#psyduckpockeball"],adGuardSocial:[e("YVtocmVmXj0iLy93d3cuc3R1bWJsZXVwb24uY29tL3N1Ym1pdD91cmw9Il0="),e("YVtocmVmXj0iLy90ZWxlZ3JhbS5tZS9zaGFyZS91cmw/Il0="),".etsy-tweet","#inlineShare",".popup-social"],adGuardSpanishPortuguese:["#barraPublicidade","#Publicidade","#publiEspecial","#queTooltip",".cnt-publi"],adGuardTrackingProtection:["#qoo-counter",e("YVtocmVmXj0iaHR0cDovL2NsaWNrLmhvdGxvZy5ydS8iXQ=="),e("YVtocmVmXj0iaHR0cDovL2hpdGNvdW50ZXIucnUvdG9wL3N0YXQucGhwIl0="),e("YVtocmVmXj0iaHR0cDovL3RvcC5tYWlsLnJ1L2p1bXAiXQ=="),"#top100counter"],adGuardTurkish:["#backkapat",e("I3Jla2xhbWk="),e("YVtocmVmXj0iaHR0cDovL2Fkc2Vydi5vbnRlay5jb20udHIvIl0="),e("YVtocmVmXj0iaHR0cDovL2l6bGVuemkuY29tL2NhbXBhaWduLyJd"),e("YVtocmVmXj0iaHR0cDovL3d3dy5pbnN0YWxsYWRzLm5ldC8iXQ==")],bulgarian:[e("dGQjZnJlZW5ldF90YWJsZV9hZHM="),"#ea_intext_div",".lapni-pop-over","#xenium_hot_offers"],easyList:[".yb-floorad",e("LndpZGdldF9wb19hZHNfd2lkZ2V0"),e("LnRyYWZmaWNqdW5reS1hZA=="),".textad_headline",e("LnNwb25zb3JlZC10ZXh0LWxpbmtz")],easyListChina:[e("LmFwcGd1aWRlLXdyYXBbb25jbGljayo9ImJjZWJvcy5jb20iXQ=="),e("LmZyb250cGFnZUFkdk0="),"#taotaole","#aafoot.top_box",".cfa_popup"],easyListCookie:[".ezmob-footer",".cc-CookieWarning","[data-cookie-number]",e("LmF3LWNvb2tpZS1iYW5uZXI="),".sygnal24-gdpr-modal-wrap"],easyListCzechSlovak:["#onlajny-stickers",e("I3Jla2xhbW5pLWJveA=="),e("LnJla2xhbWEtbWVnYWJvYXJk"),".sklik",e("W2lkXj0ic2tsaWtSZWtsYW1hIl0=")],easyListDutch:[e("I2FkdmVydGVudGll"),e("I3ZpcEFkbWFya3RCYW5uZXJCbG9jaw=="),".adstekst",e("YVtocmVmXj0iaHR0cHM6Ly94bHR1YmUubmwvY2xpY2svIl0="),"#semilo-lrectangle"],easyListGermany:["#SSpotIMPopSlider",e("LnNwb25zb3JsaW5rZ3J1ZW4="),e("I3dlcmJ1bmdza3k="),e("I3Jla2xhbWUtcmVjaHRzLW1pdHRl"),e("YVtocmVmXj0iaHR0cHM6Ly9iZDc0Mi5jb20vIl0=")],easyListItaly:[e("LmJveF9hZHZfYW5udW5jaQ=="),".sb-box-pubbliredazionale",e("YVtocmVmXj0iaHR0cDovL2FmZmlsaWF6aW9uaWFkcy5zbmFpLml0LyJd"),e("YVtocmVmXj0iaHR0cHM6Ly9hZHNlcnZlci5odG1sLml0LyJd"),e("YVtocmVmXj0iaHR0cHM6Ly9hZmZpbGlhemlvbmlhZHMuc25haS5pdC8iXQ==")],easyListLithuania:[e("LnJla2xhbW9zX3RhcnBhcw=="),e("LnJla2xhbW9zX251b3JvZG9z"),e("aW1nW2FsdD0iUmVrbGFtaW5pcyBza3lkZWxpcyJd"),e("aW1nW2FsdD0iRGVkaWt1b3RpLmx0IHNlcnZlcmlhaSJd"),e("aW1nW2FsdD0iSG9zdGluZ2FzIFNlcnZlcmlhaS5sdCJd")],estonian:[e("QVtocmVmKj0iaHR0cDovL3BheTRyZXN1bHRzMjQuZXUiXQ==")],fanboyAnnoyances:["#ac-lre-player",".navigate-to-top","#subscribe_popup",".newsletter_holder","#back-top"],fanboyAntiFacebook:[".util-bar-module-firefly-visible"],fanboyEnhancedTrackers:[".open.pushModal","#issuem-leaky-paywall-articles-zero-remaining-nag","#sovrn_container",'div[class$="-hide"][zoompage-fontsize][style="display: block;"]',".BlockNag__Card"],fanboySocial:["#FollowUs","#meteored_share","#social_follow",".article-sharer",".community__social-desc"],frellwitSwedish:[e("YVtocmVmKj0iY2FzaW5vcHJvLnNlIl1bdGFyZ2V0PSJfYmxhbmsiXQ=="),e("YVtocmVmKj0iZG9rdG9yLXNlLm9uZWxpbmsubWUiXQ=="),"article.category-samarbete",e("ZGl2LmhvbGlkQWRz"),"ul.adsmodern"],greekAdBlock:[e("QVtocmVmKj0iYWRtYW4ub3RlbmV0LmdyL2NsaWNrPyJd"),e("QVtocmVmKj0iaHR0cDovL2F4aWFiYW5uZXJzLmV4b2R1cy5nci8iXQ=="),e("QVtocmVmKj0iaHR0cDovL2ludGVyYWN0aXZlLmZvcnRobmV0LmdyL2NsaWNrPyJd"),"DIV.agores300","TABLE.advright"],hungarian:["#cemp_doboz",".optimonk-iframe-container",e("LmFkX19tYWlu"),e("W2NsYXNzKj0iR29vZ2xlQWRzIl0="),"#hirdetesek_box"],iDontCareAboutCookies:['.alert-info[data-block-track*="CookieNotice"]',".ModuleTemplateCookieIndicator",".o--cookies--container","#cookies-policy-sticky","#stickyCookieBar"],icelandicAbp:[e("QVtocmVmXj0iL2ZyYW1ld29yay9yZXNvdXJjZXMvZm9ybXMvYWRzLmFzcHgiXQ==")],latvian:[e("YVtocmVmPSJodHRwOi8vd3d3LnNhbGlkemluaS5sdi8iXVtzdHlsZT0iZGlzcGxheTogYmxvY2s7IHdpZHRoOiAxMjBweDsgaGVpZ2h0OiA0MHB4OyBvdmVyZmxvdzogaGlkZGVuOyBwb3NpdGlvbjogcmVsYXRpdmU7Il0="),e("YVtocmVmPSJodHRwOi8vd3d3LnNhbGlkemluaS5sdi8iXVtzdHlsZT0iZGlzcGxheTogYmxvY2s7IHdpZHRoOiA4OHB4OyBoZWlnaHQ6IDMxcHg7IG92ZXJmbG93OiBoaWRkZW47IHBvc2l0aW9uOiByZWxhdGl2ZTsiXQ==")],listKr:[e("YVtocmVmKj0iLy9hZC5wbGFuYnBsdXMuY28ua3IvIl0="),e("I2xpdmVyZUFkV3JhcHBlcg=="),e("YVtocmVmKj0iLy9hZHYuaW1hZHJlcC5jby5rci8iXQ=="),e("aW5zLmZhc3R2aWV3LWFk"),".revenue_unit_item.dable"],listeAr:[e("LmdlbWluaUxCMUFk"),".right-and-left-sponsers",e("YVtocmVmKj0iLmFmbGFtLmluZm8iXQ=="),e("YVtocmVmKj0iYm9vcmFxLm9yZyJd"),e("YVtocmVmKj0iZHViaXp6bGUuY29tL2FyLz91dG1fc291cmNlPSJd")],listeFr:[e("YVtocmVmXj0iaHR0cDovL3Byb21vLnZhZG9yLmNvbS8iXQ=="),e("I2FkY29udGFpbmVyX3JlY2hlcmNoZQ=="),e("YVtocmVmKj0id2Vib3JhbWEuZnIvZmNnaS1iaW4vIl0="),".site-pub-interstitiel",'div[id^="crt-"][data-criteo-id]'],officialPolish:["#ceneo-placeholder-ceneo-12",e("W2hyZWZePSJodHRwczovL2FmZi5zZW5kaHViLnBsLyJd"),e("YVtocmVmXj0iaHR0cDovL2Fkdm1hbmFnZXIudGVjaGZ1bi5wbC9yZWRpcmVjdC8iXQ=="),e("YVtocmVmXj0iaHR0cDovL3d3dy50cml6ZXIucGwvP3V0bV9zb3VyY2UiXQ=="),e("ZGl2I3NrYXBpZWNfYWQ=")],ro:[e("YVtocmVmXj0iLy9hZmZ0cmsuYWx0ZXgucm8vQ291bnRlci9DbGljayJd"),e("YVtocmVmXj0iaHR0cHM6Ly9ibGFja2ZyaWRheXNhbGVzLnJvL3Ryay9zaG9wLyJd"),e("YVtocmVmXj0iaHR0cHM6Ly9ldmVudC4ycGVyZm9ybWFudC5jb20vZXZlbnRzL2NsaWNrIl0="),e("YVtocmVmXj0iaHR0cHM6Ly9sLnByb2ZpdHNoYXJlLnJvLyJd"),'a[href^="/url/"]'],ruAd:[e("YVtocmVmKj0iLy9mZWJyYXJlLnJ1LyJd"),e("YVtocmVmKj0iLy91dGltZy5ydS8iXQ=="),e("YVtocmVmKj0iOi8vY2hpa2lkaWtpLnJ1Il0="),"#pgeldiz",".yandex-rtb-block"],thaiAds:["a[href*=macau-uta-popup]",e("I2Fkcy1nb29nbGUtbWlkZGxlX3JlY3RhbmdsZS1ncm91cA=="),e("LmFkczMwMHM="),".bumq",".img-kosana"],webAnnoyancesUltralist:["#mod-social-share-2","#social-tools",e("LmN0cGwtZnVsbGJhbm5lcg=="),".zergnet-recommend",".yt.btn-link.btn-md.btn"]}}function Ii(e){var t=(e===void 0?{}:e).debug;return ae(this,void 0,void 0,function(){var r,n,a,i,s,l;return ie(this,function(c){switch(c.label){case 0:return Ni()?(r=Ci(),n=Object.keys(r),a=(l=[]).concat.apply(l,n.map(function(d){return r[d]})),[4,Ti(a)]):[2,void 0];case 1:return i=c.sent(),t&&Li(r,i),s=n.filter(function(d){var u=r[d];return V(u.map(function(f){return i[f]}))>u.length*.6}),s.sort(),[2,s]}})})}function Ni(){return ee()||Yt()}function Ti(e){var t;return ae(this,void 0,void 0,function(){var r,n,a,i,c,s,l,c;return ie(this,function(d){switch(d.label){case 0:for(r=document,n=r.createElement("div"),a=new Array(e.length),i={},dr(n),c=0;c<e.length;++c)s=Wa(e[c]),s.tagName==="DIALOG"&&s.show(),l=r.createElement("div"),dr(l),l.appendChild(s),n.appendChild(l),a[c]=s;d.label=1;case 1:return r.body?[3,3]:[4,st(50)];case 2:return d.sent(),[3,1];case 3:r.body.appendChild(n);try{for(c=0;c<e.length;++c)a[c].offsetParent||(i[e[c]]=!0)}finally{(t=n.parentNode)===null||t===void 0||t.removeChild(n)}return[2,i]}})})}function dr(e){e.style.setProperty("visibility","hidden","important"),e.style.setProperty("display","block","important")}function Li(e,t){for(var r="DOM blockers debug:\n```",n=0,a=Object.keys(e);n<a.length;n++){var i=a[n];r+=`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let Na=require("preact/compat/client"),E=require("preact/compat"),o=require("preact/jsx-runtime");var T;(function(e){e.assertEqual=n=>{};function t(n){}e.assertIs=t;function r(n){throw new Error}e.assertNever=r,e.arrayToEnum=n=>{const i={};for(const s of n)i[s]=s;return i},e.getValidEnumValues=n=>{const i=e.objectKeys(n).filter(l=>typeof n[n[l]]!="number"),s={};for(const l of i)s[l]=n[l];return e.objectValues(s)},e.objectValues=n=>e.objectKeys(n).map(function(i){return n[i]}),e.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const i=[];for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&i.push(s);return i},e.find=(n,i)=>{for(const s of n)if(i(s))return s},e.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function a(n,i=" | "){return n.map(s=>typeof s=="string"?`'${s}'`:s).join(i)}e.joinValues=a,e.jsonStringifyReplacer=(n,i)=>typeof i=="bigint"?i.toString():i})(T||(T={}));var qt;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(qt||(qt={}));var y=T.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),fe=e=>{switch(typeof e){case"undefined":return y.undefined;case"string":return y.string;case"number":return Number.isNaN(e)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(e)?y.array:e===null?y.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?y.promise:typeof Map<"u"&&e instanceof Map?y.map:typeof Set<"u"&&e instanceof Set?y.set:typeof Date<"u"&&e instanceof Date?y.date:y.object;default:return y.unknown}},m=T.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"]),ae=class jr extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){const r=t||function(i){return i.message},a={_errors:[]},n=i=>{for(const s of i.issues)if(s.code==="invalid_union")s.unionErrors.map(n);else if(s.code==="invalid_return_type")n(s.returnTypeError);else if(s.code==="invalid_arguments")n(s.argumentsError);else if(s.path.length===0)a._errors.push(r(s));else{let l=a,c=0;for(;c<s.path.length;){const d=s.path[c];c!==s.path.length-1?l[d]=l[d]||{_errors:[]}:(l[d]=l[d]||{_errors:[]},l[d]._errors.push(r(s))),l=l[d],c++}}};return n(this),a}static assert(t){if(!(t instanceof jr))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,T.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){const r={},a=[];for(const n of this.issues)if(n.path.length>0){const i=n.path[0];r[i]=r[i]||[],r[i].push(t(n))}else a.push(t(n));return{formErrors:a,fieldErrors:r}}get formErrors(){return this.flatten()}};ae.create=e=>new ae(e);var Re=(e,t)=>{let r;switch(e.code){case m.invalid_type:e.received===y.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case m.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,T.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:r=`Unrecognized key(s) in object: ${T.joinValues(e.keys,", ")}`;break;case m.invalid_union:r="Invalid input";break;case m.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${T.joinValues(e.options)}`;break;case m.invalid_enum_value:r=`Invalid enum value. Expected ${T.joinValues(e.options)}, received '${e.received}'`;break;case m.invalid_arguments:r="Invalid function arguments";break;case m.invalid_return_type:r="Invalid function return type";break;case m.invalid_date:r="Invalid date";break;case m.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:T.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case m.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case m.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case m.custom:r="Invalid input";break;case m.invalid_intersection_types:r="Intersection results could not be merged";break;case m.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case m.not_finite:r="Number must be finite";break;default:r=t.defaultError,T.assertNever(e)}return{message:r}},Ea=Re;function xt(){return Ea}var yt=e=>{const{data:t,path:r,errorMaps:a,issueData:n}=e,i=[...r,...n.path||[]],s={...n,path:i};if(n.message!==void 0)return{...n,path:i,message:n.message};let l="";const c=a.filter(d=>!!d).slice().reverse();for(const d of c)l=d(s,{data:t,defaultError:l}).message;return{...n,path:i,message:l}};function x(e,t){const r=xt(),a=yt({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Re?void 0:Re].filter(n=>!!n)});e.common.issues.push(a)}var X=class Sr{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){const a=[];for(const n of r){if(n.status==="aborted")return _;n.status==="dirty"&&t.dirty(),a.push(n.value)}return{status:t.value,value:a}}static async mergeObjectAsync(t,r){const a=[];for(const n of r){const i=await n.key,s=await n.value;a.push({key:i,value:s})}return Sr.mergeObjectSync(t,a)}static mergeObjectSync(t,r){const a={};for(const n of r){const{key:i,value:s}=n;if(i.status==="aborted"||s.status==="aborted")return _;i.status==="dirty"&&t.dirty(),s.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof s.value<"u"||n.alwaysSet)&&(a[i.value]=s.value)}return{status:t.value,value:a}}},_=Object.freeze({status:"aborted"}),Le=e=>({status:"dirty",value:e}),U=e=>({status:"valid",value:e}),er=e=>e.status==="aborted",tr=e=>e.status==="dirty",Se=e=>e.status==="valid",Ye=e=>typeof Promise<"u"&&e instanceof Promise,b;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(b||(b={}));var ne=class{constructor(e,t,r,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},rr=(e,t)=>{if(Se(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 r=new ae(e.common.issues);return this._error=r,this._error}}};function I(e){if(!e)return{};const{errorMap:t,invalid_type_error:r,required_error:a,description:n}=e;if(t&&(r||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:n}:{errorMap:(s,l)=>{const{message:c}=e;return s.code==="invalid_enum_value"?{message:c??l.defaultError}:typeof l.data>"u"?{message:c??a??l.defaultError}:s.code!=="invalid_type"?{message:l.defaultError}:{message:c??r??l.defaultError}},description:n}}var M=class{get description(){return this._def.description}_getType(e){return fe(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:fe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new X,ctx:{common:e.parent.common,data:e.data,parsedType:fe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ye(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){const r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:fe(e)};return rr(r,this._parseSync({data:e,path:r.path,parent:r}))}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:fe(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:t});return Se(r)?{value:r.value}:{issues:t.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(r=>Se(r)?{value:r.value}:{issues:t.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:fe(e)},a=this._parse({data:e,path:r.path,parent:r});return rr(r,await(Ye(a)?a:Promise.resolve(a)))}refine(e,t){const r=a=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(a):t;return this._refinement((a,n)=>{const i=e(a),s=()=>n.addIssue({code:m.custom,...r(a)});return typeof Promise<"u"&&i instanceof Promise?i.then(l=>l?!0:(s(),!1)):i?!0:(s(),!1)})}refinement(e,t){return this._refinement((r,a)=>e(r)?!0:(a.addIssue(typeof t=="function"?t(r,a):t),!1))}_refinement(e){return new ue({schema:this,typeName:w.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return de.create(this,this._def)}nullable(){return ve.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ce.create(this)}promise(){return Ze.create(this,this._def)}or(e){return Ke.create([this,e],this._def)}and(e){return qe.create(this,e,this._def)}transform(e){return new ue({...I(this._def),schema:this,typeName:w.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new at({...I(this._def),innerType:this,defaultValue:t,typeName:w.ZodDefault})}brand(){return new Tr({typeName:w.ZodBranded,type:this,...I(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new nt({...I(this._def),innerType:this,catchValue:t,typeName:w.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ar.create(this,e)}readonly(){return it.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Ma=/^c[^\s-]{8,}$/i,La=/^[0-9a-z]+$/,Ta=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Aa=/^[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,Ra=/^[a-z0-9_-]{21}$/i,Za=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Oa=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Fa=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Pa="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",pt,Wa=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,$a=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Va=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,za=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Da=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ua=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Cr="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Ba=new RegExp(`^${Cr}$`);function Ir(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function Ga(e){return new RegExp(`^${Ir(e)}$`)}function Ha(e){let t=`${Cr}T${Ir(e)}`;const r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function Ya(e,t){return!!((t==="v4"||!t)&&Wa.test(e)||(t==="v6"||!t)&&Va.test(e))}function Xa(e,t){if(!Za.test(e))return!1;try{const[r]=e.split(".");if(!r)return!1;const a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(a));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||t&&n.alg!==t)}catch{return!1}}function Ja(e,t){return!!((t==="v4"||!t)&&$a.test(e)||(t==="v6"||!t)&&za.test(e))}var Xe=class Te extends M{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==y.string){const n=this._getOrReturnCtx(t);return x(n,{code:m.invalid_type,expected:y.string,received:n.parsedType}),_}const r=new X;let a;for(const n of this._def.checks)if(n.kind==="min")t.data.length<n.value&&(a=this._getOrReturnCtx(t,a),x(a,{code:m.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind==="max")t.data.length>n.value&&(a=this._getOrReturnCtx(t,a),x(a,{code:m.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind==="length"){const i=t.data.length>n.value,s=t.data.length<n.value;(i||s)&&(a=this._getOrReturnCtx(t,a),i?x(a,{code:m.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):s&&x(a,{code:m.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),r.dirty())}else if(n.kind==="email")Fa.test(t.data)||(a=this._getOrReturnCtx(t,a),x(a,{validation:"email",code:m.invalid_string,message:n.message}),r.dirty());else if(n.kind==="emoji")pt||(pt=new RegExp(Pa,"u")),pt.test(t.data)||(a=this._getOrReturnCtx(t,a),x(a,{validation:"emoji",code:m.invalid_string,message:n.message}),r.dirty());else if(n.kind==="uuid")Aa.test(t.data)||(a=this._getOrReturnCtx(t,a),x(a,{validation:"uuid",code:m.invalid_string,message:n.message}),r.dirty());else if(n.kind==="nanoid")Ra.test(t.data)||(a=this._getOrReturnCtx(t,a),x(a,{validation:"nanoid",code:m.invalid_string,message:n.message}),r.dirty());else if(n.kind==="cuid")Ma.test(t.data)||(a=this._getOrReturnCtx(t,a),x(a,{validation:"cuid",code:m.invalid_string,message:n.message}),r.dirty());else if(n.kind==="cuid2")La.test(t.data)||(a=this._getOrReturnCtx(t,a),x(a,{validation:"cuid2",code:m.invalid_string,message:n.message}),r.dirty());else if(n.kind==="ulid")Ta.test(t.data)||(a=this._getOrReturnCtx(t,a),x(a,{validation:"ulid",code:m.invalid_string,message:n.message}),r.dirty());else if(n.kind==="url")try{new URL(t.data)}catch{a=this._getOrReturnCtx(t,a),x(a,{validation:"url",code:m.invalid_string,message:n.message}),r.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(t.data)||(a=this._getOrReturnCtx(t,a),x(a,{validation:"regex",code:m.invalid_string,message:n.message}),r.dirty())):n.kind==="trim"?t.data=t.data.trim():n.kind==="includes"?t.data.includes(n.value,n.position)||(a=this._getOrReturnCtx(t,a),x(a,{code:m.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),r.dirty()):n.kind==="toLowerCase"?t.data=t.data.toLowerCase():n.kind==="toUpperCase"?t.data=t.data.toUpperCase():n.kind==="startsWith"?t.data.startsWith(n.value)||(a=this._getOrReturnCtx(t,a),x(a,{code:m.invalid_string,validation:{startsWith:n.value},message:n.message}),r.dirty()):n.kind==="endsWith"?t.data.endsWith(n.value)||(a=this._getOrReturnCtx(t,a),x(a,{code:m.invalid_string,validation:{endsWith:n.value},message:n.message}),r.dirty()):n.kind==="datetime"?Ha(n).test(t.data)||(a=this._getOrReturnCtx(t,a),x(a,{code:m.invalid_string,validation:"datetime",message:n.message}),r.dirty()):n.kind==="date"?Ba.test(t.data)||(a=this._getOrReturnCtx(t,a),x(a,{code:m.invalid_string,validation:"date",message:n.message}),r.dirty()):n.kind==="time"?Ga(n).test(t.data)||(a=this._getOrReturnCtx(t,a),x(a,{code:m.invalid_string,validation:"time",message:n.message}),r.dirty()):n.kind==="duration"?Oa.test(t.data)||(a=this._getOrReturnCtx(t,a),x(a,{validation:"duration",code:m.invalid_string,message:n.message}),r.dirty()):n.kind==="ip"?Ya(t.data,n.version)||(a=this._getOrReturnCtx(t,a),x(a,{validation:"ip",code:m.invalid_string,message:n.message}),r.dirty()):n.kind==="jwt"?Xa(t.data,n.alg)||(a=this._getOrReturnCtx(t,a),x(a,{validation:"jwt",code:m.invalid_string,message:n.message}),r.dirty()):n.kind==="cidr"?Ja(t.data,n.version)||(a=this._getOrReturnCtx(t,a),x(a,{validation:"cidr",code:m.invalid_string,message:n.message}),r.dirty()):n.kind==="base64"?Da.test(t.data)||(a=this._getOrReturnCtx(t,a),x(a,{validation:"base64",code:m.invalid_string,message:n.message}),r.dirty()):n.kind==="base64url"?Ua.test(t.data)||(a=this._getOrReturnCtx(t,a),x(a,{validation:"base64url",code:m.invalid_string,message:n.message}),r.dirty()):T.assertNever(n);return{status:r.value,value:t.data}}_regex(t,r,a){return this.refinement(n=>t.test(n),{validation:r,code:m.invalid_string,...b.errToObj(a)})}_addCheck(t){return new Te({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...b.errToObj(t)})}url(t){return this._addCheck({kind:"url",...b.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...b.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...b.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...b.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...b.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...b.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...b.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...b.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...b.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...b.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...b.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...b.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...b.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...b.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...b.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...b.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...b.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...b.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...b.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...b.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...b.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...b.errToObj(r)})}nonempty(t){return this.min(1,b.errToObj(t))}trim(){return new Te({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Te({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Te({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}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 isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}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 isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Xe.create=e=>new Xe({checks:[],typeName:w.ZodString,coerce:e?.coerce??!1,...I(e)});function Qa(e,t){const r=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,n=r>a?r:a;return Number.parseInt(e.toFixed(n).replace(".",""))%Number.parseInt(t.toFixed(n).replace(".",""))/10**n}var bt=class _t extends M{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)!==y.number){const n=this._getOrReturnCtx(t);return x(n,{code:m.invalid_type,expected:y.number,received:n.parsedType}),_}let r;const a=new X;for(const n of this._def.checks)n.kind==="int"?T.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),x(r,{code:m.invalid_type,expected:"integer",received:"float",message:n.message}),a.dirty()):n.kind==="min"?(n.inclusive?t.data<n.value:t.data<=n.value)&&(r=this._getOrReturnCtx(t,r),x(r,{code:m.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind==="max"?(n.inclusive?t.data>n.value:t.data>=n.value)&&(r=this._getOrReturnCtx(t,r),x(r,{code:m.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind==="multipleOf"?Qa(t.data,n.value)!==0&&(r=this._getOrReturnCtx(t,r),x(r,{code:m.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):n.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),x(r,{code:m.not_finite,message:n.message}),a.dirty()):T.assertNever(n);return{status:a.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,b.toString(r))}gt(t,r){return this.setLimit("min",t,!1,b.toString(r))}lte(t,r){return this.setLimit("max",t,!0,b.toString(r))}lt(t,r){return this.setLimit("max",t,!1,b.toString(r))}setLimit(t,r,a,n){return new _t({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:b.toString(n)}]})}_addCheck(t){return new _t({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:b.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:b.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:b.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString(t)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&T.isInteger(t.value))}get isFinite(){let t=null,r=null;for(const a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(r===null||a.value>r)&&(r=a.value):a.kind==="max"&&(t===null||a.value<t)&&(t=a.value)}return Number.isFinite(r)&&Number.isFinite(t)}};bt.create=e=>new bt({checks:[],typeName:w.ZodNumber,coerce:e?.coerce||!1,...I(e)});var wt=class jt extends M{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==y.bigint)return this._getInvalidInput(t);let r;const a=new X;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?t.data<n.value:t.data<=n.value)&&(r=this._getOrReturnCtx(t,r),x(r,{code:m.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty()):n.kind==="max"?(n.inclusive?t.data>n.value:t.data>=n.value)&&(r=this._getOrReturnCtx(t,r),x(r,{code:m.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty()):n.kind==="multipleOf"?t.data%n.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),x(r,{code:m.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):T.assertNever(n);return{status:a.value,value:t.data}}_getInvalidInput(t){const r=this._getOrReturnCtx(t);return x(r,{code:m.invalid_type,expected:y.bigint,received:r.parsedType}),_}gte(t,r){return this.setLimit("min",t,!0,b.toString(r))}gt(t,r){return this.setLimit("min",t,!1,b.toString(r))}lte(t,r){return this.setLimit("max",t,!0,b.toString(r))}lt(t,r){return this.setLimit("max",t,!1,b.toString(r))}setLimit(t,r,a,n){return new jt({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:b.toString(n)}]})}_addCheck(t){return new jt({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:b.toString(r)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};wt.create=e=>new wt({checks:[],typeName:w.ZodBigInt,coerce:e?.coerce??!1,...I(e)});var St=class extends M{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){const t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:y.boolean,received:t.parsedType}),_}return U(e.data)}};St.create=e=>new St({typeName:w.ZodBoolean,coerce:e?.coerce||!1,...I(e)});var Ct=class Nr extends M{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==y.date){const n=this._getOrReturnCtx(t);return x(n,{code:m.invalid_type,expected:y.date,received:n.parsedType}),_}if(Number.isNaN(t.data.getTime()))return x(this._getOrReturnCtx(t),{code:m.invalid_date}),_;const r=new X;let a;for(const n of this._def.checks)n.kind==="min"?t.data.getTime()<n.value&&(a=this._getOrReturnCtx(t,a),x(a,{code:m.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),r.dirty()):n.kind==="max"?t.data.getTime()>n.value&&(a=this._getOrReturnCtx(t,a),x(a,{code:m.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),r.dirty()):T.assertNever(n);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Nr({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:b.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:b.toString(r)})}get minDate(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};Ct.create=e=>new Ct({checks:[],coerce:e?.coerce||!1,typeName:w.ZodDate,...I(e)});var It=class extends M{_parse(e){if(this._getType(e)!==y.symbol){const t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:y.symbol,received:t.parsedType}),_}return U(e.data)}};It.create=e=>new It({typeName:w.ZodSymbol,...I(e)});var Je=class extends M{_parse(e){if(this._getType(e)!==y.undefined){const t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:y.undefined,received:t.parsedType}),_}return U(e.data)}};Je.create=e=>new Je({typeName:w.ZodUndefined,...I(e)});var Qe=class extends M{_parse(e){if(this._getType(e)!==y.null){const t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:y.null,received:t.parsedType}),_}return U(e.data)}};Qe.create=e=>new Qe({typeName:w.ZodNull,...I(e)});var Nt=class extends M{constructor(){super(...arguments),this._any=!0}_parse(e){return U(e.data)}};Nt.create=e=>new Nt({typeName:w.ZodAny,...I(e)});var we=class extends M{constructor(){super(...arguments),this._unknown=!0}_parse(e){return U(e.data)}};we.create=e=>new we({typeName:w.ZodUnknown,...I(e)});var pe=class extends M{_parse(e){const t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:y.never,received:t.parsedType}),_}};pe.create=e=>new pe({typeName:w.ZodNever,...I(e)});var Et=class extends M{_parse(e){if(this._getType(e)!==y.undefined){const t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:y.void,received:t.parsedType}),_}return U(e.data)}};Et.create=e=>new Et({typeName:w.ZodVoid,...I(e)});var Ce=class Be extends M{_parse(t){const{ctx:r,status:a}=this._processInputParams(t),n=this._def;if(r.parsedType!==y.array)return x(r,{code:m.invalid_type,expected:y.array,received:r.parsedType}),_;if(n.exactLength!==null){const s=r.data.length>n.exactLength.value,l=r.data.length<n.exactLength.value;(s||l)&&(x(r,{code:s?m.too_big:m.too_small,minimum:l?n.exactLength.value:void 0,maximum:s?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),a.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(x(r,{code:m.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),a.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(x(r,{code:m.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),a.dirty()),r.common.async)return Promise.all([...r.data].map((s,l)=>n.type._parseAsync(new ne(r,s,r.path,l)))).then(s=>X.mergeArray(a,s));const i=[...r.data].map((s,l)=>n.type._parseSync(new ne(r,s,r.path,l)));return X.mergeArray(a,i)}get element(){return this._def.type}min(t,r){return new Be({...this._def,minLength:{value:t,message:b.toString(r)}})}max(t,r){return new Be({...this._def,maxLength:{value:t,message:b.toString(r)}})}length(t,r){return new Be({...this._def,exactLength:{value:t,message:b.toString(r)}})}nonempty(t){return this.min(1,t)}};Ce.create=(e,t)=>new Ce({type:e,minLength:null,maxLength:null,exactLength:null,typeName:w.ZodArray,...I(t)});function _e(e){if(e instanceof ee){const t={};for(const r in e.shape){const a=e.shape[r];t[r]=de.create(_e(a))}return new ee({...e._def,shape:()=>t})}else return e instanceof Ce?new Ce({...e._def,type:_e(e.element)}):e instanceof de?de.create(_e(e.unwrap())):e instanceof ve?ve.create(_e(e.unwrap())):e instanceof ge?ge.create(e.items.map(t=>_e(t))):e}var ee=class K extends M{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(),r=T.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==y.object){const c=this._getOrReturnCtx(t);return x(c,{code:m.invalid_type,expected:y.object,received:c.parsedType}),_}const{status:r,ctx:a}=this._processInputParams(t),{shape:n,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof pe&&this._def.unknownKeys==="strip"))for(const c in a.data)i.includes(c)||s.push(c);const l=[];for(const c of i){const d=n[c],u=a.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new ne(a,u,a.path,c)),alwaysSet:c in a.data})}if(this._def.catchall instanceof pe){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of s)l.push({key:{status:"valid",value:d},value:{status:"valid",value:a.data[d]}});else if(c==="strict")s.length>0&&(x(a,{code:m.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 u=a.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new ne(a,u,a.path,d)),alwaysSet:d in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of l){const u=await d.key,h=await d.value;c.push({key:u,value:h,alwaysSet:d.alwaysSet})}return c}).then(c=>X.mergeObjectSync(r,c)):X.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return b.errToObj,new K({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,a)=>{const n=this._def.errorMap?.(r,a).message??a.defaultError;return r.code==="unrecognized_keys"?{message:b.errToObj(t).message??n}:{message:n}}}:{}})}strip(){return new K({...this._def,unknownKeys:"strip"})}passthrough(){return new K({...this._def,unknownKeys:"passthrough"})}extend(t){return new K({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new K({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:w.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new K({...this._def,catchall:t})}pick(t){const r={};for(const a of T.objectKeys(t))t[a]&&this.shape[a]&&(r[a]=this.shape[a]);return new K({...this._def,shape:()=>r})}omit(t){const r={};for(const a of T.objectKeys(this.shape))t[a]||(r[a]=this.shape[a]);return new K({...this._def,shape:()=>r})}deepPartial(){return _e(this)}partial(t){const r={};for(const a of T.objectKeys(this.shape)){const n=this.shape[a];t&&!t[a]?r[a]=n:r[a]=n.optional()}return new K({...this._def,shape:()=>r})}required(t){const r={};for(const a of T.objectKeys(this.shape))if(t&&!t[a])r[a]=this.shape[a];else{let n=this.shape[a];for(;n instanceof de;)n=n._def.innerType;r[a]=n}return new K({...this._def,shape:()=>r})}keyof(){return Lr(T.objectKeys(this.shape))}};ee.create=(e,t)=>new ee({shape:()=>e,unknownKeys:"strip",catchall:pe.create(),typeName:w.ZodObject,...I(t)});ee.strictCreate=(e,t)=>new ee({shape:()=>e,unknownKeys:"strict",catchall:pe.create(),typeName:w.ZodObject,...I(t)});ee.lazycreate=(e,t)=>new ee({shape:e,unknownKeys:"strip",catchall:pe.create(),typeName:w.ZodObject,...I(t)});var Ke=class extends M{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function a(n){for(const s of n)if(s.result.status==="valid")return s.result;for(const s of n)if(s.result.status==="dirty")return t.common.issues.push(...s.ctx.common.issues),s.result;const i=n.map(s=>new ae(s.ctx.common.issues));return x(t,{code:m.invalid_union,unionErrors:i}),_}if(t.common.async)return Promise.all(r.map(async n=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await n._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(a);{let n;const i=[];for(const l of r){const c={...t,common:{...t.common,issues:[]},parent:null},d=l._parseSync({data:t.data,path:t.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!n&&(n={result:d,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;const s=i.map(l=>new ae(l));return x(t,{code:m.invalid_union,unionErrors:s}),_}}get options(){return this._def.options}};Ke.create=(e,t)=>new Ke({options:e,typeName:w.ZodUnion,...I(t)});var le=e=>e instanceof et?le(e.schema):e instanceof ue?le(e.innerType()):e instanceof tt?[e.value]:e instanceof ct?e.options:e instanceof rt?T.objectValues(e.enum):e instanceof at?le(e._def.innerType):e instanceof Je?[void 0]:e instanceof Qe?[null]:e instanceof de?[void 0,...le(e.unwrap())]:e instanceof ve?[null,...le(e.unwrap())]:e instanceof Tr||e instanceof it?le(e.unwrap()):e instanceof nt?le(e._def.innerType):[],Ka=class Er extends M{_parse(t){const{ctx:r}=this._processInputParams(t);if(r.parsedType!==y.object)return x(r,{code:m.invalid_type,expected:y.object,received:r.parsedType}),_;const a=this.discriminator,n=r.data[a],i=this.optionsMap.get(n);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(x(r,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),_)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,a){const n=new Map;for(const i of r){const s=le(i.shape[t]);if(!s.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const l of s){if(n.has(l))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(l)}`);n.set(l,i)}}return new Er({typeName:w.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:n,...I(a)})}};function Mt(e,t){const r=fe(e),a=fe(t);if(e===t)return{valid:!0,data:e};if(r===y.object&&a===y.object){const n=T.objectKeys(t),i=T.objectKeys(e).filter(l=>n.indexOf(l)!==-1),s={...e,...t};for(const l of i){const c=Mt(e[l],t[l]);if(!c.valid)return{valid:!1};s[l]=c.data}return{valid:!0,data:s}}else if(r===y.array&&a===y.array){if(e.length!==t.length)return{valid:!1};const n=[];for(let i=0;i<e.length;i++){const s=e[i],l=t[i],c=Mt(s,l);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return r===y.date&&a===y.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var qe=class extends M{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),a=(n,i)=>{if(er(n)||er(i))return _;const s=Mt(n.value,i.value);return s.valid?((tr(n)||tr(i))&&t.dirty(),{status:t.value,value:s.data}):(x(r,{code:m.invalid_intersection_types}),_)};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(([n,i])=>a(n,i)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};qe.create=(e,t,r)=>new qe({left:e,right:t,typeName:w.ZodIntersection,...I(r)});var ge=class Mr extends M{_parse(t){const{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==y.array)return x(a,{code:m.invalid_type,expected:y.array,received:a.parsedType}),_;if(a.data.length<this._def.items.length)return x(a,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),_;!this._def.rest&&a.data.length>this._def.items.length&&(x(a,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const n=[...a.data].map((i,s)=>{const l=this._def.items[s]||this._def.rest;return l?l._parse(new ne(a,i,a.path,s)):null}).filter(i=>!!i);return a.common.async?Promise.all(n).then(i=>X.mergeArray(r,i)):X.mergeArray(r,n)}get items(){return this._def.items}rest(t){return new Mr({...this._def,rest:t})}};ge.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ge({items:e,typeName:w.ZodTuple,rest:null,...I(t)})};var qa=class Lt extends M{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==y.object)return x(a,{code:m.invalid_type,expected:y.object,received:a.parsedType}),_;const n=[],i=this._def.keyType,s=this._def.valueType;for(const l in a.data)n.push({key:i._parse(new ne(a,l,a.path,l)),value:s._parse(new ne(a,a.data[l],a.path,l)),alwaysSet:l in a.data});return a.common.async?X.mergeObjectAsync(r,n):X.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(t,r,a){return r instanceof M?new Lt({keyType:t,valueType:r,typeName:w.ZodRecord,...I(a)}):new Lt({keyType:Xe.create(),valueType:t,typeName:w.ZodRecord,...I(r)})}},Tt=class extends M{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.map)return x(r,{code:m.invalid_type,expected:y.map,received:r.parsedType}),_;const a=this._def.keyType,n=this._def.valueType,i=[...r.data.entries()].map(([s,l],c)=>({key:a._parse(new ne(r,s,r.path,[c,"key"])),value:n._parse(new ne(r,l,r.path,[c,"value"]))}));if(r.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const l of i){const c=await l.key,d=await l.value;if(c.status==="aborted"||d.status==="aborted")return _;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),s.set(c.value,d.value)}return{status:t.value,value:s}})}else{const s=new Map;for(const l of i){const c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return _;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),s.set(c.value,d.value)}return{status:t.value,value:s}}}};Tt.create=(e,t,r)=>new Tt({valueType:t,keyType:e,typeName:w.ZodMap,...I(r)});var At=class Rt extends M{_parse(t){const{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==y.set)return x(a,{code:m.invalid_type,expected:y.set,received:a.parsedType}),_;const n=this._def;n.minSize!==null&&a.data.size<n.minSize.value&&(x(a,{code:m.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&a.data.size>n.maxSize.value&&(x(a,{code:m.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());const i=this._def.valueType;function s(c){const d=new Set;for(const u of c){if(u.status==="aborted")return _;u.status==="dirty"&&r.dirty(),d.add(u.value)}return{status:r.value,value:d}}const l=[...a.data.values()].map((c,d)=>i._parse(new ne(a,c,a.path,d)));return a.common.async?Promise.all(l).then(c=>s(c)):s(l)}min(t,r){return new Rt({...this._def,minSize:{value:t,message:b.toString(r)}})}max(t,r){return new Rt({...this._def,maxSize:{value:t,message:b.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};At.create=(e,t)=>new At({valueType:e,minSize:null,maxSize:null,typeName:w.ZodSet,...I(t)});var en=class Ge extends M{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:r}=this._processInputParams(t);if(r.parsedType!==y.function)return x(r,{code:m.invalid_type,expected:y.function,received:r.parsedType}),_;function a(l,c){return yt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,xt(),Re].filter(d=>!!d),issueData:{code:m.invalid_arguments,argumentsError:c}})}function n(l,c){return yt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,xt(),Re].filter(d=>!!d),issueData:{code:m.invalid_return_type,returnTypeError:c}})}const i={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof Ze){const l=this;return U(async function(...c){const d=new ae([]),u=await l._def.args.parseAsync(c,i).catch(p=>{throw d.addIssue(a(c,p)),d}),h=await Reflect.apply(s,this,u);return await l._def.returns._def.type.parseAsync(h,i).catch(p=>{throw d.addIssue(n(h,p)),d})})}else{const l=this;return U(function(...c){const d=l._def.args.safeParse(c,i);if(!d.success)throw new ae([a(c,d.error)]);const u=Reflect.apply(s,this,d.data),h=l._def.returns.safeParse(u,i);if(!h.success)throw new ae([n(u,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new Ge({...this._def,args:ge.create(t).rest(we.create())})}returns(t){return new Ge({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,a){return new Ge({args:t||ge.create([]).rest(we.create()),returns:r||we.create(),typeName:w.ZodFunction,...I(a)})}},et=class extends M{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};et.create=(e,t)=>new et({getter:e,typeName:w.ZodLazy,...I(t)});var tt=class extends M{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return x(t,{received:t.data,code:m.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:e.data}}get value(){return this._def.value}};tt.create=(e,t)=>new tt({value:e,typeName:w.ZodLiteral,...I(t)});function Lr(e,t){return new ct({values:e,typeName:w.ZodEnum,...I(t)})}var ct=class Zt extends M{_parse(t){if(typeof t.data!="string"){const r=this._getOrReturnCtx(t),a=this._def.values;return x(r,{expected:T.joinValues(a),received:r.parsedType,code:m.invalid_type}),_}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const r=this._getOrReturnCtx(t),a=this._def.values;return x(r,{received:r.data,code:m.invalid_enum_value,options:a}),_}return U(t.data)}get options(){return this._def.values}get enum(){const t={};for(const r of this._def.values)t[r]=r;return t}get Values(){const t={};for(const r of this._def.values)t[r]=r;return t}get Enum(){const t={};for(const r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return Zt.create(t,{...this._def,...r})}exclude(t,r=this._def){return Zt.create(this.options.filter(a=>!t.includes(a)),{...this._def,...r})}};ct.create=Lr;var rt=class extends M{_parse(e){const t=T.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){const a=T.objectValues(t);return x(r,{expected:T.joinValues(a),received:r.parsedType,code:m.invalid_type}),_}if(this._cache||(this._cache=new Set(T.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=T.objectValues(t);return x(r,{received:r.data,code:m.invalid_enum_value,options:a}),_}return U(e.data)}get enum(){return this._def.values}};rt.create=(e,t)=>new rt({values:e,typeName:w.ZodNativeEnum,...I(t)});var Ze=class extends M{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);return t.parsedType!==y.promise&&t.common.async===!1?(x(t,{code:m.invalid_type,expected:y.promise,received:t.parsedType}),_):U((t.parsedType===y.promise?t.data:Promise.resolve(t.data)).then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Ze.create=(e,t)=>new Ze({type:e,typeName:w.ZodPromise,...I(t)});var ue=class extends M{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===w.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),a=this._def.effect||null,n={addIssue:i=>{x(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(n.addIssue=n.addIssue.bind(n),a.type==="preprocess"){const i=a.transform(r.data,n);if(r.common.async)return Promise.resolve(i).then(async s=>{if(t.value==="aborted")return _;const l=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return l.status==="aborted"?_:l.status==="dirty"||t.value==="dirty"?Le(l.value):l});{if(t.value==="aborted")return _;const s=this._def.schema._parseSync({data:i,path:r.path,parent:r});return s.status==="aborted"?_:s.status==="dirty"||t.value==="dirty"?Le(s.value):s}}if(a.type==="refinement"){const i=s=>{const l=a.refinement(s,n);if(r.common.async)return Promise.resolve(l);if(l 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"?_:(s.status==="dirty"&&t.dirty(),i(s.value),{status:t.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?_:(s.status==="dirty"&&t.dirty(),i(s.value).then(()=>({status:t.value,value:s.value}))))}if(a.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Se(i))return _;const s=a.transform(i.value,n);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>Se(i)?Promise.resolve(a.transform(i.value,n)).then(s=>({status:t.value,value:s})):_);T.assertNever(a)}};ue.create=(e,t,r)=>new ue({schema:e,typeName:w.ZodEffects,effect:t,...I(r)});ue.createWithPreprocess=(e,t,r)=>new ue({schema:t,effect:{type:"preprocess",transform:e},typeName:w.ZodEffects,...I(r)});var de=class extends M{_parse(e){return this._getType(e)===y.undefined?U(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};de.create=(e,t)=>new de({innerType:e,typeName:w.ZodOptional,...I(t)});var ve=class extends M{_parse(e){return this._getType(e)===y.null?U(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ve.create=(e,t)=>new ve({innerType:e,typeName:w.ZodNullable,...I(t)});var at=class extends M{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===y.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};at.create=(e,t)=>new at({innerType:e,typeName:w.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...I(t)});var nt=class extends M{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ye(a)?a.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new ae(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new ae(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};nt.create=(e,t)=>new nt({innerType:e,typeName:w.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...I(t)});var Ot=class extends M{_parse(e){if(this._getType(e)!==y.nan){const t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:y.nan,received:t.parsedType}),_}return{status:"valid",value:e.data}}};Ot.create=e=>new Ot({typeName:w.ZodNaN,...I(e)});var Tr=class extends M{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}},Ar=class Rr extends M{_parse(t){const{status:r,ctx:a}=this._processInputParams(t);if(a.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?_:i.status==="dirty"?(r.dirty(),Le(i.value)):this._def.out._parseAsync({data:i.value,path:a.path,parent:a})})();{const n=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return n.status==="aborted"?_:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:a.path,parent:a})}}static create(t,r){return new Rr({in:t,out:r,typeName:w.ZodPipeline})}},it=class extends M{_parse(e){const t=this._def.innerType._parse(e),r=a=>(Se(a)&&(a.value=Object.freeze(a.value)),a);return Ye(t)?t.then(a=>r(a)):r(t)}unwrap(){return this._def.innerType}};it.create=(e,t)=>new it({innerType:e,typeName:w.ZodReadonly,...I(t)});var vo={object:ee.lazycreate},w;(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"})(w||(w={}));var V=Xe.create,ko=bt.create,xo=Ot.create,yo=wt.create,mt=St.create,bo=Ct.create,_o=It.create,wo=Je.create,jo=Qe.create,So=Nt.create,tn=we.create,Co=pe.create,Io=Et.create,No=Ce.create,Bt=ee.create,Eo=ee.strictCreate,Mo=Ke.create,Lo=Ka.create,To=qe.create,Ao=ge.create,rn=qa.create,Ro=Tt.create,Zo=At.create,Oo=en.create,Fo=et.create,Po=tt.create,Ft=ct.create,Wo=rt.create,$o=Ze.create,Vo=ue.create,zo=de.create,Do=ve.create,Uo=ue.createWithPreprocess,Bo=Ar.create,an=Bt({mode:Ft(["light","dark","system"]).optional(),accentColor:V().optional(),fontFamily:V().optional(),borderRadius:V().optional()}),nn=Bt({externalId:V().optional(),authId:V().optional(),name:V().optional(),email:V().optional()}),Zr=Bt({agentId:V().min(1,"agentId is required"),apiBaseUrl:V().url("apiBaseUrl must be a valid URL"),tenantId:V().optional(),user:nn.optional(),sessionId:V().optional(),mode:Ft(["floating","inline"]).optional(),title:V().optional(),subtitle:V().optional(),description:V().optional(),avatarUrl:V().optional(),streaming:mt().optional(),preview:mt().optional(),skipServerConfigFetch:mt().optional(),configChannel:Ft(["draft","published"]).optional(),metadata:rn(tn()).optional(),theme:an.optional()}),sn=Zr.omit({agentId:!0,apiBaseUrl:!0}).partial(),me={mode:"floating",streaming:!0,title:"AI Assistant",theme:{mode:"light",accentColor:"#6366f1",fontFamily:"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",borderRadius:"12px"}};function Ie(e,t){Zr.parse(e);let r;const a=t?{...t}:void 0;a&&typeof a.theme=="object"&&a.theme!==null?(r=a.theme,delete a.theme):a&&typeof a.theme=="string"&&(r={mode:a.theme},delete a.theme);const n=a?sn.passthrough().safeParse(a).data:void 0,i=n?Or(n,e):e,s={mode:i.theme?.mode??r?.mode??me.theme.mode,accentColor:i.theme?.accentColor??r?.accentColor??me.theme.accentColor,fontFamily:i.theme?.fontFamily??r?.fontFamily??me.theme.fontFamily,borderRadius:i.theme?.borderRadius??r?.borderRadius??me.theme.borderRadius};return{agentId:i.agentId,apiBaseUrl:i.apiBaseUrl.replace(/\/$/,""),tenantId:i.tenantId,user:{externalId:i.user?.externalId,authId:i.user?.authId,name:i.user?.name,email:i.user?.email},sessionId:i.sessionId,mode:i.mode??me.mode,title:i.title??me.title,subtitle:i.subtitle,description:i.description,suggestedQuestions:(()=>{const l=n?.suggestedQuestions;return Array.isArray(l)?l:[]})(),avatarUrl:i.avatarUrl,streaming:i.streaming??me.streaming,preview:i.preview===!0,skipServerConfigFetch:i.skipServerConfigFetch===!0,configChannel:i.configChannel,metadata:i.metadata??{},theme:s,photoSendingEnabled:n?.photoSendingEnabled===!0,fileUploadEnabled:n?.fileUploadEnabled===!0,attachmentMaxCount:(()=>{const l=n?.attachmentMaxCount;return typeof l=="number"&&Number.isFinite(l)?l:5})(),attachmentMaxFileSizeMb:(()=>{const l=n?.attachmentMaxFileSizeMb;return typeof l=="number"&&Number.isFinite(l)?l:1})()}}function Or(e,t){const r={...e};for(const a of Object.keys(t)){const n=t[a];n!=null&&(typeof n=="object"&&!Array.isArray(n)&&r[a]!==null&&typeof r[a]=="object"?r[a]=Or(r[a],n):r[a]=n)}return r}var Pt=function(){return Pt=Object.assign||function(t){for(var r,a=1,n=arguments.length;a<n;a++){r=arguments[a];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},Pt.apply(this,arguments)};function ie(e,t,r,a){function n(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function l(u){try{d(a.next(u))}catch(h){s(h)}}function c(u){try{d(a.throw(u))}catch(h){s(h)}}function d(u){u.done?i(u.value):n(u.value).then(l,c)}d((a=a.apply(e,t||[])).next())})}function se(e,t){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},a,n,i,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=l(0),s.throw=l(1),s.return=l(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(d){return function(u){return c([d,u])}}function c(d){if(a)throw new TypeError("Generator is already executing.");for(;s&&(s=0,d[0]&&(r=0)),r;)try{if(a=1,n&&(i=d[0]&2?n.return:d[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,d[1])).done)return i;switch(n=0,i&&(d=[d[0]&2,i.value]),d[0]){case 0:case 1:i=d;break;case 4:return r.label++,{value:d[1],done:!1};case 5:r.label++,n=d[1],d=[0];continue;case 7:d=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!(i=i.length>0&&i[i.length-1])&&(d[0]===6||d[0]===2)){r=0;continue}if(d[0]===3&&(!i||d[1]>i[0]&&d[1]<i[3])){r.label=d[1];break}if(d[0]===6&&r.label<i[1]){r.label=i[1],i=d;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(d);break}i[2]&&r.ops.pop(),r.trys.pop();continue}d=t.call(e,r)}catch(u){d=[6,u],n=0}finally{a=i=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}function Fr(e,t,r){if(r||arguments.length===2)for(var a=0,n=t.length,i;a<n;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))}var Pr="4.6.2";function st(e,t){return new Promise(function(r){return setTimeout(r,e,t)})}function on(){return new Promise(function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})}function ln(e,t){t===void 0&&(t=1/0);var r=window.requestIdleCallback;return r?new Promise(function(a){return r.call(window,function(){return a()},{timeout:t})}):st(Math.min(e,t))}function Wr(e){return!!e&&typeof e.then=="function"}function ar(e,t){try{var r=e();Wr(r)?r.then(function(a){return t(!0,a)},function(a){return t(!1,a)}):t(!0,r)}catch(a){t(!1,a)}}function nr(e,t,r){return r===void 0&&(r=16),ie(this,void 0,void 0,function(){var a,n,i,s;return se(this,function(l){switch(l.label){case 0:a=Array(e.length),n=Date.now(),i=0,l.label=1;case 1:return i<e.length?(a[i]=t(e[i],i),s=Date.now(),s>=n+r?(n=s,[4,on()]):[3,3]):[3,4];case 2:l.sent(),l.label=3;case 3:return++i,[3,1];case 4:return[2,a]}})})}function Oe(e){return e.then(void 0,function(){}),e}function cn(e,t){for(var r=0,a=e.length;r<a;++r)if(e[r]===t)return!0;return!1}function dn(e,t){return!cn(e,t)}function Gt(e){return parseInt(e)}function q(e){return parseFloat(e)}function ce(e,t){return typeof e=="number"&&isNaN(e)?t:e}function z(e){return e.reduce(function(t,r){return t+(r?1:0)},0)}function $r(e,t){if(t===void 0&&(t=1),Math.abs(t)>=1)return Math.round(e/t)*t;var r=1/t;return Math.round(e*r)/r}function un(e){for(var t,r,a="Unexpected syntax '".concat(e,"'"),n=/^\s*([a-z-]*)(.*)$/i.exec(e),i=n[1]||void 0,s={},l=/([.:#][\w-]+|\[.+?\])/gi,c=function(p,f){s[p]=s[p]||[],s[p].push(f)};;){var d=l.exec(n[2]);if(!d)break;var u=d[0];switch(u[0]){case".":c("class",u.slice(1));break;case"#":c("id",u.slice(1));break;case"[":var h=/^\[([\w-]+)([~|^$*]?=("(.*?)"|([\w-]+)))?(\s+[is])?\]$/.exec(u);if(h)c(h[1],(r=(t=h[4])!==null&&t!==void 0?t:h[5])!==null&&r!==void 0?r:"");else throw new Error(a);break;default:throw new Error(a)}}return[i,s]}function hn(e){for(var t=new Uint8Array(e.length),r=0;r<e.length;r++){var a=e.charCodeAt(r);if(a>127)return new TextEncoder().encode(e);t[r]=a}return t}function he(e,t){var r=e[0]>>>16,a=e[0]&65535,n=e[1]>>>16,i=e[1]&65535,s=t[0]>>>16,l=t[0]&65535,c=t[1]>>>16,d=t[1]&65535,u=0,h=0,p=0,f=0;f+=i+d,p+=f>>>16,f&=65535,p+=n+c,h+=p>>>16,p&=65535,h+=a+l,u+=h>>>16,h&=65535,u+=r+s,u&=65535,e[0]=u<<16|h,e[1]=p<<16|f}function J(e,t){var r=e[0]>>>16,a=e[0]&65535,n=e[1]>>>16,i=e[1]&65535,s=t[0]>>>16,l=t[0]&65535,c=t[1]>>>16,d=t[1]&65535,u=0,h=0,p=0,f=0;f+=i*d,p+=f>>>16,f&=65535,p+=n*d,h+=p>>>16,p&=65535,p+=i*c,h+=p>>>16,p&=65535,h+=a*d,u+=h>>>16,h&=65535,h+=n*c,u+=h>>>16,h&=65535,h+=i*l,u+=h>>>16,h&=65535,u+=r*d+a*c+n*l+i*s,u&=65535,e[0]=u<<16|h,e[1]=p<<16|f}function ke(e,t){var r=e[0];t%=64,t===32?(e[0]=e[1],e[1]=r):t<32?(e[0]=r<<t|e[1]>>>32-t,e[1]=e[1]<<t|r>>>32-t):(t-=32,e[0]=e[1]<<t|r>>>32-t,e[1]=r<<t|e[1]>>>32-t)}function H(e,t){t%=64,t!==0&&(t<32?(e[0]=e[1]>>>32-t,e[1]=e[1]<<t):(e[0]=e[1]<<t-32,e[1]=0))}function Z(e,t){e[0]^=t[0],e[1]^=t[1]}var fn=[4283543511,3981806797],pn=[3301882366,444984403];function ir(e){var t=[0,e[0]>>>1];Z(e,t),J(e,fn),t[1]=e[0]>>>1,Z(e,t),J(e,pn),t[1]=e[0]>>>1,Z(e,t)}var De=[2277735313,289559509],Ue=[1291169091,658871167],sr=[0,5],mn=[0,1390208809],gn=[0,944331445];function vn(e,t){var r=hn(e);t=t||0;var a=[0,r.length],n=a[1]%16,i=a[1]-n,s=[0,t],l=[0,t],c=[0,0],d=[0,0],u;for(u=0;u<i;u=u+16)c[0]=r[u+4]|r[u+5]<<8|r[u+6]<<16|r[u+7]<<24,c[1]=r[u]|r[u+1]<<8|r[u+2]<<16|r[u+3]<<24,d[0]=r[u+12]|r[u+13]<<8|r[u+14]<<16|r[u+15]<<24,d[1]=r[u+8]|r[u+9]<<8|r[u+10]<<16|r[u+11]<<24,J(c,De),ke(c,31),J(c,Ue),Z(s,c),ke(s,27),he(s,l),J(s,sr),he(s,mn),J(d,Ue),ke(d,33),J(d,De),Z(l,d),ke(l,31),he(l,s),J(l,sr),he(l,gn);c[0]=0,c[1]=0,d[0]=0,d[1]=0;var h=[0,0];switch(n){case 15:h[1]=r[u+14],H(h,48),Z(d,h);case 14:h[1]=r[u+13],H(h,40),Z(d,h);case 13:h[1]=r[u+12],H(h,32),Z(d,h);case 12:h[1]=r[u+11],H(h,24),Z(d,h);case 11:h[1]=r[u+10],H(h,16),Z(d,h);case 10:h[1]=r[u+9],H(h,8),Z(d,h);case 9:h[1]=r[u+8],Z(d,h),J(d,Ue),ke(d,33),J(d,De),Z(l,d);case 8:h[1]=r[u+7],H(h,56),Z(c,h);case 7:h[1]=r[u+6],H(h,48),Z(c,h);case 6:h[1]=r[u+5],H(h,40),Z(c,h);case 5:h[1]=r[u+4],H(h,32),Z(c,h);case 4:h[1]=r[u+3],H(h,24),Z(c,h);case 3:h[1]=r[u+2],H(h,16),Z(c,h);case 2:h[1]=r[u+1],H(h,8),Z(c,h);case 1:h[1]=r[u],Z(c,h),J(c,De),ke(c,31),J(c,Ue),Z(s,c)}return Z(s,a),Z(l,a),he(s,l),he(l,s),ir(s),ir(l),he(s,l),he(l,s),("00000000"+(s[0]>>>0).toString(16)).slice(-8)+("00000000"+(s[1]>>>0).toString(16)).slice(-8)+("00000000"+(l[0]>>>0).toString(16)).slice(-8)+("00000000"+(l[1]>>>0).toString(16)).slice(-8)}function kn(e){var t;return Pt({name:e.name,message:e.message,stack:(t=e.stack)===null||t===void 0?void 0:t.split(`
|
|
2
|
+
`)},e)}function xn(e){return/^function\s.*?\{\s*\[native code]\s*}$/.test(String(e))}function yn(e){return typeof e!="function"}function bn(e,t){var r=Oe(new Promise(function(a){var n=Date.now();ar(e.bind(null,t),function(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];var l=Date.now()-n;if(!i[0])return a(function(){return{error:i[1],duration:l}});var c=i[1];if(yn(c))return a(function(){return{value:c,duration:l}});a(function(){return new Promise(function(d){var u=Date.now();ar(c,function(){for(var h=[],p=0;p<arguments.length;p++)h[p]=arguments[p];var f=l+Date.now()-u;if(!h[0])return d({error:h[1],duration:f});d({value:h[1],duration:f})})})})})}));return function(){return r.then(function(n){return n()})}}function _n(e,t,r,a){var n=Object.keys(e).filter(function(s){return dn(r,s)}),i=Oe(nr(n,function(s){return bn(e[s],t)},a));return function(){return ie(this,void 0,void 0,function(){var l,c,d,u,h;return se(this,function(p){switch(p.label){case 0:return[4,i];case 1:return l=p.sent(),[4,nr(l,function(f){return Oe(f())},a)];case 2:return c=p.sent(),[4,Promise.all(c)];case 3:for(d=p.sent(),u={},h=0;h<n.length;++h)u[n[h]]=d[h];return[2,u]}})})}}function Vr(){var e=window,t=navigator;return z(["MSCSSMatrix"in e,"msSetImmediate"in e,"msIndexedDB"in e,"msMaxTouchPoints"in t,"msPointerEnabled"in t])>=4}function wn(){var e=window,t=navigator;return z(["msWriteProfilerMark"in e,"MSStream"in e,"msLaunchUri"in t,"msSaveBlob"in t])>=3&&!Vr()}function Pe(){var e=window,t=navigator;return z(["webkitPersistentStorage"in t,"webkitTemporaryStorage"in t,(t.vendor||"").indexOf("Google")===0,"webkitResolveLocalFileSystemURL"in e,"BatteryManager"in e,"webkitMediaStream"in e,"webkitSpeechGrammar"in e])>=5}function te(){var e=window,t=navigator;return z(["ApplePayError"in e,"CSSPrimitiveValue"in e,"Counter"in e,t.vendor.indexOf("Apple")===0,"RGBColor"in e,"WebKitMediaKeys"in e])>=4}function Ht(){var e=window,t=e.HTMLElement,r=e.Document;return z(["safari"in e,!("ongestureend"in e),!("TouchEvent"in e),!("orientation"in e),t&&!("autocapitalize"in t.prototype),r&&"pointerLockElement"in r.prototype])>=4}function We(){var e=window;return xn(e.print)&&String(e.browser)==="[object WebPageNamespace]"}function zr(){var e,t,r=window;return z(["buildID"in navigator,"MozAppearance"in((t=(e=document.documentElement)===null||e===void 0?void 0:e.style)!==null&&t!==void 0?t:{}),"onmozfullscreenchange"in r,"mozInnerScreenX"in r,"CSSMozDocumentRule"in r,"CanvasCaptureMediaStream"in r])>=4}function jn(){var e=window;return z([!("MediaSettingsRange"in e),"RTCEncodedAudioFrame"in e,""+e.Intl=="[object Intl]",""+e.Reflect=="[object Reflect]"])>=3}function Sn(){var e=window,t=e.URLPattern;return z(["union"in Set.prototype,"Iterator"in e,t&&"hasRegExpGroups"in t.prototype,"RGB8"in WebGLRenderingContext.prototype])>=3}function Cn(){var e=window;return z(["DOMRectList"in e,"RTCPeerConnectionIceEvent"in e,"SVGGeometryElement"in e,"ontransitioncancel"in e])>=3}function $e(){var e=window,t=navigator,r=e.CSS,a=e.HTMLButtonElement;return z([!("getStorageUpdates"in t),a&&"popover"in a.prototype,"CSSCounterStyleRule"in e,r.supports("font-size-adjust: ex-height 0.5"),r.supports("text-transform: full-width")])>=4}function In(){if(navigator.platform==="iPad")return!0;var e=screen,t=e.width/e.height;return z(["MediaSource"in window,!!Element.prototype.webkitRequestFullscreen,t>.65&&t<1.53])>=2}function Nn(){var e=document;return e.fullscreenElement||e.msFullscreenElement||e.mozFullScreenElement||e.webkitFullscreenElement||null}function En(){var e=document;return(e.exitFullscreen||e.msExitFullscreen||e.mozCancelFullScreen||e.webkitExitFullscreen).call(e)}function Yt(){var e=Pe(),t=zr(),r=window,a=navigator,n="connection";return e?z([!("SharedWorker"in r),a[n]&&"ontypechange"in a[n],!("sinkId"in new Audio)])>=2:t?z(["onorientationchange"in r,"orientation"in r,/android/i.test(a.appVersion)])>=2:!1}function Mn(){var e=navigator,t=window,r=Audio.prototype,a=t.visualViewport;return z(["srLatency"in r,"srChannelCount"in r,"devicePosture"in e,a&&"segments"in a,"getTextInformation"in Image.prototype])>=3}function Ln(){return Rn()?-4:Tn()}function Tn(){var e=window,t=e.OfflineAudioContext||e.webkitOfflineAudioContext;if(!t)return-2;if(An())return-1;var r=4500,a=new t(1,5e3,44100),n=a.createOscillator();n.type="triangle",n.frequency.value=1e4;var i=a.createDynamicsCompressor();i.threshold.value=-50,i.knee.value=40,i.ratio.value=12,i.attack.value=0,i.release.value=.25,n.connect(i),i.connect(a.destination),n.start(0);var s=Zn(a),l=s[0],c=s[1],d=Oe(l.then(function(u){return On(u.getChannelData(0).subarray(r))},function(u){if(u.name==="timeout"||u.name==="suspended")return-3;throw u}));return function(){return c(),d}}function An(){return te()&&!Ht()&&!Cn()}function Rn(){return te()&&$e()&&We()||Pe()&&Mn()&&Sn()}function Zn(e){var t=3,r=500,a=500,n=5e3,i=function(){};return[new Promise(function(s,l){var c=!1,d=0,u=0;e.oncomplete=function(f){return s(f.renderedBuffer)};var h=function(){setTimeout(function(){return l(or("timeout"))},Math.min(a,u+n-Date.now()))},p=function(){try{var f=e.startRendering();switch(Wr(f)&&Oe(f),e.state){case"running":u=Date.now(),c&&h();break;case"suspended":document.hidden||d++,c&&d>=t?l(or("suspended")):setTimeout(p,r);break}}catch(v){l(v)}};p(),i=function(){c||(c=!0,u>0&&h())}}),i]}function On(e){for(var t=0,r=0;r<e.length;++r)t+=Math.abs(e[r]);return t}function or(e){var t=new Error(e);return t.name=e,t}function Dr(e,t,r){var a,n,i;return r===void 0&&(r=50),ie(this,void 0,void 0,function(){var s,l;return se(this,function(c){switch(c.label){case 0:s=document,c.label=1;case 1:return s.body?[3,3]:[4,st(r)];case 2:return c.sent(),[3,1];case 3:l=s.createElement("iframe"),c.label=4;case 4:return c.trys.push([4,,10,11]),[4,new Promise(function(d,u){var h=!1,p=function(){h=!0,d()},f=function(S){h=!0,u(S)};l.onload=p,l.onerror=f;var v=l.style;v.setProperty("display","block","important"),v.position="absolute",v.top="0",v.left="0",v.visibility="hidden",t&&"srcdoc"in l?l.srcdoc=t:l.src="about:blank",s.body.appendChild(l);var k=function(){var S,g;h||(((g=(S=l.contentWindow)===null||S===void 0?void 0:S.document)===null||g===void 0?void 0:g.readyState)==="complete"?p():setTimeout(k,10))};k()})];case 5:c.sent(),c.label=6;case 6:return!((n=(a=l.contentWindow)===null||a===void 0?void 0:a.document)===null||n===void 0)&&n.body?[3,8]:[4,st(r)];case 7:return c.sent(),[3,6];case 8:return[4,e(l,l.contentWindow)];case 9:return[2,c.sent()];case 10:return(i=l.parentNode)===null||i===void 0||i.removeChild(l),[7];case 11:return[2]}})})}function Fn(e){for(var t=un(e),r=t[0],a=t[1],n=document.createElement(r??"div"),i=0,s=Object.keys(a);i<s.length;i++){var l=s[i],c=a[l].join(" ");l==="style"?Pn(n.style,c):n.setAttribute(l,c)}return n}function Pn(e,t){for(var r=0,a=t.split(";");r<a.length;r++){var n=a[r],i=/^\s*([\w-]+)\s*:\s*(.+?)(\s*!([\w-]+))?\s*$/.exec(n);if(i){var s=i[1],l=i[2],c=i[4];e.setProperty(s,l,c||"")}}}function Wn(){for(var e=window;;){var t=e.parent;if(!t||t===e)return!1;try{if(t.location.origin!==e.location.origin)return!0}catch(r){if(r instanceof Error&&r.name==="SecurityError")return!0;throw r}e=t}}var $n="mmMwWLliI0O&1",Vn="48px",xe=["monospace","sans-serif","serif"],lr=["sans-serif-thin","ARNO PRO","Agency FB","Arabic Typesetting","Arial Unicode MS","AvantGarde Bk BT","BankGothic Md BT","Batang","Bitstream Vera Sans Mono","Calibri","Century","Century Gothic","Clarendon","EUROSTILE","Franklin Gothic","Futura Bk BT","Futura Md BT","GOTHAM","Gill Sans","HELV","Haettenschweiler","Helvetica Neue","Humanst521 BT","Leelawadee","Letter Gothic","Levenim MT","Lucida Bright","Lucida Sans","Menlo","MS Mincho","MS Outlook","MS Reference Specialty","MS UI Gothic","MT Extra","MYRIAD PRO","Marlett","Meiryo UI","Microsoft Uighur","Minion Pro","Monotype Corsiva","PMingLiU","Pristina","SCRIPTINA","Segoe UI Light","Serifa","SimHei","Small Fonts","Staccato222 BT","TRAJAN PRO","Univers CE 55 Medium","Vrinda","ZWAdobeF"];function zn(){var e=this;return Dr(function(t,r){var a=r.document;return ie(e,void 0,void 0,function(){var n,i,s,l,c,d,u,h,p,f,v,k;return se(this,function(S){for(n=a.body,n.style.fontSize=Vn,i=a.createElement("div"),i.style.setProperty("visibility","hidden","important"),s={},l={},c=function(g){var C=a.createElement("span"),R=C.style;return R.position="absolute",R.top="0",R.left="0",R.fontFamily=g,C.textContent=$n,i.appendChild(C),C},d=function(g,C){return c("'".concat(g,"',").concat(C))},u=function(){return xe.map(c)},h=function(){for(var g={},C=function(D){g[D]=xe.map(function(re){return d(D,re)})},R=0,P=lr;R<P.length;R++){var B=P[R];C(B)}return g},p=function(g){return xe.some(function(C,R){return g[R].offsetWidth!==s[C]||g[R].offsetHeight!==l[C]})},f=u(),v=h(),n.appendChild(i),k=0;k<xe.length;k++)s[xe[k]]=f[k].offsetWidth,l[xe[k]]=f[k].offsetHeight;return[2,lr.filter(function(g){return p(v[g])})]})})})}function Dn(){var e=navigator.plugins;if(e){for(var t=[],r=0;r<e.length;++r){var a=e[r];if(a){for(var n=[],i=0;i<a.length;++i){var s=a[i];n.push({type:s.type,suffixes:s.suffixes})}t.push({name:a.name,description:a.description,mimeTypes:n})}}return t}}function Un(){return Bn(Kn())}function Bn(e){var t,r=!1,a,n,i=Gn(),s=i[0],l=i[1];return Hn(s,l)?(r=Yn(l),e?a=n="skipped":(t=Xn(s,l),a=t[0],n=t[1])):a=n="unsupported",{winding:r,geometry:a,text:n}}function Gn(){var e=document.createElement("canvas");return e.width=1,e.height=1,[e,e.getContext("2d")]}function Hn(e,t){return!!(t&&e.toDataURL)}function Yn(e){return e.rect(0,0,10,10),e.rect(2,2,6,6),!e.isPointInPath(5,5,"evenodd")}function Xn(e,t){Jn(e,t);var r=gt(e);return r!==gt(e)?["unstable","unstable"]:(Qn(e,t),[gt(e),r])}function Jn(e,t){e.width=240,e.height=60,t.textBaseline="alphabetic",t.fillStyle="#f60",t.fillRect(100,1,62,20),t.fillStyle="#069",t.font='11pt "Times New Roman"';var r="Cwm fjordbank gly ".concat("😃");t.fillText(r,2,15),t.fillStyle="rgba(102, 204, 0, 0.2)",t.font="18pt Arial",t.fillText(r,4,45)}function Qn(e,t){e.width=122,e.height=110,t.globalCompositeOperation="multiply";for(var r=0,a=[["#f2f",40,40],["#2ff",80,40],["#ff2",60,80]];r<a.length;r++){var n=a[r],i=n[0],s=n[1],l=n[2];t.fillStyle=i,t.beginPath(),t.arc(s,l,40,0,Math.PI*2,!0),t.closePath(),t.fill()}t.fillStyle="#f9c",t.arc(60,60,60,0,Math.PI*2,!0),t.arc(60,60,20,0,Math.PI*2,!0),t.fill("evenodd")}function gt(e){return e.toDataURL()}function Kn(){return te()&&$e()&&We()}function qn(){var e=navigator,t=0,r;e.maxTouchPoints!==void 0?t=Gt(e.maxTouchPoints):e.msMaxTouchPoints!==void 0&&(t=e.msMaxTouchPoints);try{document.createEvent("TouchEvent"),r=!0}catch{r=!1}var a="ontouchstart"in window;return{maxTouchPoints:t,touchEvent:r,touchStart:a}}function ei(){return navigator.oscpu}function ti(){var e=navigator,t=[],r=e.language||e.userLanguage||e.browserLanguage||e.systemLanguage;if(r!==void 0&&t.push([r]),Array.isArray(e.languages))Pe()&&jn()||t.push(e.languages);else if(typeof e.languages=="string"){var a=e.languages;a&&t.push(a.split(","))}return t}function ri(){return window.screen.colorDepth}function ai(){return ce(q(navigator.deviceMemory),void 0)}function ni(){if(!(te()&&$e()&&We()))return ii()}function ii(){var e=screen,t=function(a){return ce(Gt(a),null)},r=[t(e.width),t(e.height)];return r.sort().reverse(),r}var si=2500,oi=10,He,vt;function li(){if(vt===void 0){var e=function(){var t=Wt();$t(t)?vt=setTimeout(e,si):(He=t,vt=void 0)};e()}}function ci(){var e=this;return li(),function(){return ie(e,void 0,void 0,function(){var t;return se(this,function(r){switch(r.label){case 0:return t=Wt(),$t(t)?He?[2,Fr([],He,!0)]:Nn()?[4,En()]:[3,2]:[3,2];case 1:r.sent(),t=Wt(),r.label=2;case 2:return $t(t)||(He=t),[2,t]}})})}}function di(){var e=this;if(te()&&$e()&&We())return function(){return Promise.resolve(void 0)};var t=ci();return function(){return ie(e,void 0,void 0,function(){var r,a;return se(this,function(n){switch(n.label){case 0:return[4,t()];case 1:return r=n.sent(),a=function(i){return i===null?null:$r(i,oi)},[2,[a(r[0]),a(r[1]),a(r[2]),a(r[3])]]}})})}}function Wt(){var e=screen;return[ce(q(e.availTop),null),ce(q(e.width)-q(e.availWidth)-ce(q(e.availLeft),0),null),ce(q(e.height)-q(e.availHeight)-ce(q(e.availTop),0),null),ce(q(e.availLeft),null)]}function $t(e){for(var t=0;t<4;++t)if(e[t])return!1;return!0}function ui(){return ce(Gt(navigator.hardwareConcurrency),void 0)}function hi(){var e,t=(e=window.Intl)===null||e===void 0?void 0:e.DateTimeFormat;if(t){var r=new t().resolvedOptions().timeZone;if(r)return r}var a=-fi();return"UTC".concat(a>=0?"+":"").concat(a)}function fi(){var e=new Date().getFullYear();return Math.max(q(new Date(e,0,1).getTimezoneOffset()),q(new Date(e,6,1).getTimezoneOffset()))}function pi(){try{return!!window.sessionStorage}catch{return!0}}function mi(){try{return!!window.localStorage}catch{return!0}}function gi(){if(!(Vr()||wn()))try{return!!window.indexedDB}catch{return!0}}function vi(){return!!window.openDatabase}function ki(){return navigator.cpuClass}function xi(){var e=navigator.platform;return e==="MacIntel"&&te()&&!Ht()?In()?"iPad":"iPhone":e}function yi(){return navigator.vendor||""}function bi(){for(var e=[],t=0,r=["chrome","safari","__crWeb","__gCrWeb","yandex","__yb","__ybro","__firefox__","__edgeTrackingPreventionStatistics","webkit","oprt","samsungAr","ucweb","UCShellJava","puffinDevice"];t<r.length;t++){var a=r[t],n=window[a];n&&typeof n=="object"&&e.push(a)}return e.sort()}function _i(){var e=document;try{e.cookie="cookietest=1; SameSite=Strict;";var t=e.cookie.indexOf("cookietest=")!==-1;return e.cookie="cookietest=1; SameSite=Strict; expires=Thu, 01-Jan-1970 00:00:01 GMT",t}catch{return!1}}function wi(){var e=atob;return{abpIndo:["#Iklan-Melayang","#Kolom-Iklan-728","#SidebarIklan-wrapper",'[title="ALIENBOLA" i]',e("I0JveC1CYW5uZXItYWRz")],abpvn:[".quangcao","#mobileCatfish",e("LmNsb3NlLWFkcw=="),'[id^="bn_bottom_fixed_"]',"#pmadv"],adBlockFinland:[".mainostila",e("LnNwb25zb3JpdA=="),".ylamainos",e("YVtocmVmKj0iL2NsaWNrdGhyZ2guYXNwPyJd"),e("YVtocmVmXj0iaHR0cHM6Ly9hcHAucmVhZHBlYWsuY29tL2FkcyJd")],adBlockPersian:["#navbar_notice_50",".kadr",'TABLE[width="140px"]',"#divAgahi",e("YVtocmVmXj0iaHR0cDovL2cxLnYuZndtcm0ubmV0L2FkLyJd")],adBlockWarningRemoval:["#adblock-honeypot",".adblocker-root",".wp_adblock_detect",e("LmhlYWRlci1ibG9ja2VkLWFk"),e("I2FkX2Jsb2NrZXI=")],adGuardAnnoyances:[".hs-sosyal","#cookieconsentdiv",'div[class^="app_gdpr"]',".as-oil",'[data-cypress="soft-push-notification-modal"]'],adGuardBase:[".BetterJsPopOverlay",e("I2FkXzMwMFgyNTA="),e("I2Jhbm5lcmZsb2F0MjI="),e("I2NhbXBhaWduLWJhbm5lcg=="),e("I0FkLUNvbnRlbnQ=")],adGuardChinese:[e("LlppX2FkX2FfSA=="),e("YVtocmVmKj0iLmh0aGJldDM0LmNvbSJd"),"#widget-quan",e("YVtocmVmKj0iLzg0OTkyMDIwLnh5eiJd"),e("YVtocmVmKj0iLjE5NTZobC5jb20vIl0=")],adGuardFrench:["#pavePub",e("LmFkLWRlc2t0b3AtcmVjdGFuZ2xl"),".mobile_adhesion",".widgetadv",e("LmFkc19iYW4=")],adGuardGerman:['aside[data-portal-id="leaderboard"]'],adGuardJapanese:["#kauli_yad_1",e("YVtocmVmXj0iaHR0cDovL2FkMi50cmFmZmljZ2F0ZS5uZXQvIl0="),e("Ll9wb3BJbl9pbmZpbml0ZV9hZA=="),e("LmFkZ29vZ2xl"),e("Ll9faXNib29zdFJldHVybkFk")],adGuardMobile:[e("YW1wLWF1dG8tYWRz"),e("LmFtcF9hZA=="),'amp-embed[type="24smi"]',"#mgid_iframe1",e("I2FkX2ludmlld19hcmVh")],adGuardRussian:[e("YVtocmVmXj0iaHR0cHM6Ly9hZC5sZXRtZWFkcy5jb20vIl0="),e("LnJlY2xhbWE="),'div[id^="smi2adblock"]',e("ZGl2W2lkXj0iQWRGb3hfYmFubmVyXyJd"),"#psyduckpockeball"],adGuardSocial:[e("YVtocmVmXj0iLy93d3cuc3R1bWJsZXVwb24uY29tL3N1Ym1pdD91cmw9Il0="),e("YVtocmVmXj0iLy90ZWxlZ3JhbS5tZS9zaGFyZS91cmw/Il0="),".etsy-tweet","#inlineShare",".popup-social"],adGuardSpanishPortuguese:["#barraPublicidade","#Publicidade","#publiEspecial","#queTooltip",".cnt-publi"],adGuardTrackingProtection:["#qoo-counter",e("YVtocmVmXj0iaHR0cDovL2NsaWNrLmhvdGxvZy5ydS8iXQ=="),e("YVtocmVmXj0iaHR0cDovL2hpdGNvdW50ZXIucnUvdG9wL3N0YXQucGhwIl0="),e("YVtocmVmXj0iaHR0cDovL3RvcC5tYWlsLnJ1L2p1bXAiXQ=="),"#top100counter"],adGuardTurkish:["#backkapat",e("I3Jla2xhbWk="),e("YVtocmVmXj0iaHR0cDovL2Fkc2Vydi5vbnRlay5jb20udHIvIl0="),e("YVtocmVmXj0iaHR0cDovL2l6bGVuemkuY29tL2NhbXBhaWduLyJd"),e("YVtocmVmXj0iaHR0cDovL3d3dy5pbnN0YWxsYWRzLm5ldC8iXQ==")],bulgarian:[e("dGQjZnJlZW5ldF90YWJsZV9hZHM="),"#ea_intext_div",".lapni-pop-over","#xenium_hot_offers"],easyList:[".yb-floorad",e("LndpZGdldF9wb19hZHNfd2lkZ2V0"),e("LnRyYWZmaWNqdW5reS1hZA=="),".textad_headline",e("LnNwb25zb3JlZC10ZXh0LWxpbmtz")],easyListChina:[e("LmFwcGd1aWRlLXdyYXBbb25jbGljayo9ImJjZWJvcy5jb20iXQ=="),e("LmZyb250cGFnZUFkdk0="),"#taotaole","#aafoot.top_box",".cfa_popup"],easyListCookie:[".ezmob-footer",".cc-CookieWarning","[data-cookie-number]",e("LmF3LWNvb2tpZS1iYW5uZXI="),".sygnal24-gdpr-modal-wrap"],easyListCzechSlovak:["#onlajny-stickers",e("I3Jla2xhbW5pLWJveA=="),e("LnJla2xhbWEtbWVnYWJvYXJk"),".sklik",e("W2lkXj0ic2tsaWtSZWtsYW1hIl0=")],easyListDutch:[e("I2FkdmVydGVudGll"),e("I3ZpcEFkbWFya3RCYW5uZXJCbG9jaw=="),".adstekst",e("YVtocmVmXj0iaHR0cHM6Ly94bHR1YmUubmwvY2xpY2svIl0="),"#semilo-lrectangle"],easyListGermany:["#SSpotIMPopSlider",e("LnNwb25zb3JsaW5rZ3J1ZW4="),e("I3dlcmJ1bmdza3k="),e("I3Jla2xhbWUtcmVjaHRzLW1pdHRl"),e("YVtocmVmXj0iaHR0cHM6Ly9iZDc0Mi5jb20vIl0=")],easyListItaly:[e("LmJveF9hZHZfYW5udW5jaQ=="),".sb-box-pubbliredazionale",e("YVtocmVmXj0iaHR0cDovL2FmZmlsaWF6aW9uaWFkcy5zbmFpLml0LyJd"),e("YVtocmVmXj0iaHR0cHM6Ly9hZHNlcnZlci5odG1sLml0LyJd"),e("YVtocmVmXj0iaHR0cHM6Ly9hZmZpbGlhemlvbmlhZHMuc25haS5pdC8iXQ==")],easyListLithuania:[e("LnJla2xhbW9zX3RhcnBhcw=="),e("LnJla2xhbW9zX251b3JvZG9z"),e("aW1nW2FsdD0iUmVrbGFtaW5pcyBza3lkZWxpcyJd"),e("aW1nW2FsdD0iRGVkaWt1b3RpLmx0IHNlcnZlcmlhaSJd"),e("aW1nW2FsdD0iSG9zdGluZ2FzIFNlcnZlcmlhaS5sdCJd")],estonian:[e("QVtocmVmKj0iaHR0cDovL3BheTRyZXN1bHRzMjQuZXUiXQ==")],fanboyAnnoyances:["#ac-lre-player",".navigate-to-top","#subscribe_popup",".newsletter_holder","#back-top"],fanboyAntiFacebook:[".util-bar-module-firefly-visible"],fanboyEnhancedTrackers:[".open.pushModal","#issuem-leaky-paywall-articles-zero-remaining-nag","#sovrn_container",'div[class$="-hide"][zoompage-fontsize][style="display: block;"]',".BlockNag__Card"],fanboySocial:["#FollowUs","#meteored_share","#social_follow",".article-sharer",".community__social-desc"],frellwitSwedish:[e("YVtocmVmKj0iY2FzaW5vcHJvLnNlIl1bdGFyZ2V0PSJfYmxhbmsiXQ=="),e("YVtocmVmKj0iZG9rdG9yLXNlLm9uZWxpbmsubWUiXQ=="),"article.category-samarbete",e("ZGl2LmhvbGlkQWRz"),"ul.adsmodern"],greekAdBlock:[e("QVtocmVmKj0iYWRtYW4ub3RlbmV0LmdyL2NsaWNrPyJd"),e("QVtocmVmKj0iaHR0cDovL2F4aWFiYW5uZXJzLmV4b2R1cy5nci8iXQ=="),e("QVtocmVmKj0iaHR0cDovL2ludGVyYWN0aXZlLmZvcnRobmV0LmdyL2NsaWNrPyJd"),"DIV.agores300","TABLE.advright"],hungarian:["#cemp_doboz",".optimonk-iframe-container",e("LmFkX19tYWlu"),e("W2NsYXNzKj0iR29vZ2xlQWRzIl0="),"#hirdetesek_box"],iDontCareAboutCookies:['.alert-info[data-block-track*="CookieNotice"]',".ModuleTemplateCookieIndicator",".o--cookies--container","#cookies-policy-sticky","#stickyCookieBar"],icelandicAbp:[e("QVtocmVmXj0iL2ZyYW1ld29yay9yZXNvdXJjZXMvZm9ybXMvYWRzLmFzcHgiXQ==")],latvian:[e("YVtocmVmPSJodHRwOi8vd3d3LnNhbGlkemluaS5sdi8iXVtzdHlsZT0iZGlzcGxheTogYmxvY2s7IHdpZHRoOiAxMjBweDsgaGVpZ2h0OiA0MHB4OyBvdmVyZmxvdzogaGlkZGVuOyBwb3NpdGlvbjogcmVsYXRpdmU7Il0="),e("YVtocmVmPSJodHRwOi8vd3d3LnNhbGlkemluaS5sdi8iXVtzdHlsZT0iZGlzcGxheTogYmxvY2s7IHdpZHRoOiA4OHB4OyBoZWlnaHQ6IDMxcHg7IG92ZXJmbG93OiBoaWRkZW47IHBvc2l0aW9uOiByZWxhdGl2ZTsiXQ==")],listKr:[e("YVtocmVmKj0iLy9hZC5wbGFuYnBsdXMuY28ua3IvIl0="),e("I2xpdmVyZUFkV3JhcHBlcg=="),e("YVtocmVmKj0iLy9hZHYuaW1hZHJlcC5jby5rci8iXQ=="),e("aW5zLmZhc3R2aWV3LWFk"),".revenue_unit_item.dable"],listeAr:[e("LmdlbWluaUxCMUFk"),".right-and-left-sponsers",e("YVtocmVmKj0iLmFmbGFtLmluZm8iXQ=="),e("YVtocmVmKj0iYm9vcmFxLm9yZyJd"),e("YVtocmVmKj0iZHViaXp6bGUuY29tL2FyLz91dG1fc291cmNlPSJd")],listeFr:[e("YVtocmVmXj0iaHR0cDovL3Byb21vLnZhZG9yLmNvbS8iXQ=="),e("I2FkY29udGFpbmVyX3JlY2hlcmNoZQ=="),e("YVtocmVmKj0id2Vib3JhbWEuZnIvZmNnaS1iaW4vIl0="),".site-pub-interstitiel",'div[id^="crt-"][data-criteo-id]'],officialPolish:["#ceneo-placeholder-ceneo-12",e("W2hyZWZePSJodHRwczovL2FmZi5zZW5kaHViLnBsLyJd"),e("YVtocmVmXj0iaHR0cDovL2Fkdm1hbmFnZXIudGVjaGZ1bi5wbC9yZWRpcmVjdC8iXQ=="),e("YVtocmVmXj0iaHR0cDovL3d3dy50cml6ZXIucGwvP3V0bV9zb3VyY2UiXQ=="),e("ZGl2I3NrYXBpZWNfYWQ=")],ro:[e("YVtocmVmXj0iLy9hZmZ0cmsuYWx0ZXgucm8vQ291bnRlci9DbGljayJd"),e("YVtocmVmXj0iaHR0cHM6Ly9ibGFja2ZyaWRheXNhbGVzLnJvL3Ryay9zaG9wLyJd"),e("YVtocmVmXj0iaHR0cHM6Ly9ldmVudC4ycGVyZm9ybWFudC5jb20vZXZlbnRzL2NsaWNrIl0="),e("YVtocmVmXj0iaHR0cHM6Ly9sLnByb2ZpdHNoYXJlLnJvLyJd"),'a[href^="/url/"]'],ruAd:[e("YVtocmVmKj0iLy9mZWJyYXJlLnJ1LyJd"),e("YVtocmVmKj0iLy91dGltZy5ydS8iXQ=="),e("YVtocmVmKj0iOi8vY2hpa2lkaWtpLnJ1Il0="),"#pgeldiz",".yandex-rtb-block"],thaiAds:["a[href*=macau-uta-popup]",e("I2Fkcy1nb29nbGUtbWlkZGxlX3JlY3RhbmdsZS1ncm91cA=="),e("LmFkczMwMHM="),".bumq",".img-kosana"],webAnnoyancesUltralist:["#mod-social-share-2","#social-tools",e("LmN0cGwtZnVsbGJhbm5lcg=="),".zergnet-recommend",".yt.btn-link.btn-md.btn"]}}function ji(e){var t=(e===void 0?{}:e).debug;return ie(this,void 0,void 0,function(){var r,a,n,i,s,l;return se(this,function(c){switch(c.label){case 0:return Si()?(r=wi(),a=Object.keys(r),n=(l=[]).concat.apply(l,a.map(function(d){return r[d]})),[4,Ci(n)]):[2,void 0];case 1:return i=c.sent(),t&&Ii(r,i),s=a.filter(function(d){var u=r[d];return z(u.map(function(h){return i[h]}))>u.length*.6}),s.sort(),[2,s]}})})}function Si(){return te()||Yt()}function Ci(e){var t;return ie(this,void 0,void 0,function(){var r,a,n,i,c,s,l,c;return se(this,function(d){switch(d.label){case 0:for(r=document,a=r.createElement("div"),n=new Array(e.length),i={},cr(a),c=0;c<e.length;++c)s=Fn(e[c]),s.tagName==="DIALOG"&&s.show(),l=r.createElement("div"),cr(l),l.appendChild(s),a.appendChild(l),n[c]=s;d.label=1;case 1:return r.body?[3,3]:[4,st(50)];case 2:return d.sent(),[3,1];case 3:r.body.appendChild(a);try{for(c=0;c<e.length;++c)n[c].offsetParent||(i[e[c]]=!0)}finally{(t=a.parentNode)===null||t===void 0||t.removeChild(a)}return[2,i]}})})}function cr(e){e.style.setProperty("visibility","hidden","important"),e.style.setProperty("display","block","important")}function Ii(e,t){for(var r="DOM blockers debug:\n```",a=0,n=Object.keys(e);a<n.length;a++){var i=n[a];r+=`
|
|
3
3
|
`.concat(i,":");for(var s=0,l=e[i];s<l.length;s++){var c=l[s];r+=`
|
|
4
|
-
`.concat(t[c]?"🚫":"➡️"," ").concat(c)}}}function Ai(){for(var e=0,t=["rec2020","p3","srgb"];e<t.length;e++){var r=t[e];if(matchMedia("(color-gamut: ".concat(r,")")).matches)return r}}function Ei(){if(ur("inverted"))return!0;if(ur("none"))return!1}function ur(e){return matchMedia("(inverted-colors: ".concat(e,")")).matches}function Mi(){if(fr("active"))return!0;if(fr("none"))return!1}function fr(e){return matchMedia("(forced-colors: ".concat(e,")")).matches}var Ri=100;function Zi(){if(matchMedia("(min-monochrome: 0)").matches){for(var e=0;e<=Ri;++e)if(matchMedia("(max-monochrome: ".concat(e,")")).matches)return e;throw new Error("Too high value")}}function Oi(){if(ke("no-preference"))return 0;if(ke("high")||ke("more"))return 1;if(ke("low")||ke("less"))return-1;if(ke("forced"))return 10}function ke(e){return matchMedia("(prefers-contrast: ".concat(e,")")).matches}function Fi(){if(hr("reduce"))return!0;if(hr("no-preference"))return!1}function hr(e){return matchMedia("(prefers-reduced-motion: ".concat(e,")")).matches}function Pi(){if(pr("reduce"))return!0;if(pr("no-preference"))return!1}function pr(e){return matchMedia("(prefers-reduced-transparency: ".concat(e,")")).matches}function $i(){if(mr("high"))return!0;if(mr("standard"))return!1}function mr(e){return matchMedia("(dynamic-range: ".concat(e,")")).matches}var M=Math,W=function(){return 0};function Wi(){var e=M.acos||W,t=M.acosh||W,r=M.asin||W,n=M.asinh||W,a=M.atanh||W,i=M.atan||W,s=M.sin||W,l=M.sinh||W,c=M.cos||W,d=M.cosh||W,u=M.tan||W,f=M.tanh||W,p=M.exp||W,h=M.expm1||W,x=M.log1p||W,v=function(C){return M.pow(M.PI,C)},w=function(C){return M.log(C+M.sqrt(C*C-1))},g=function(C){return M.log(C+M.sqrt(C*C+1))},I=function(C){return M.log((1+C)/(1-C))/2},R=function(C){return M.exp(C)-1/M.exp(C)/2},P=function(C){return(M.exp(C)+1/M.exp(C))/2},U=function(C){return M.exp(C)-1},D=function(C){return(M.exp(2*C)-1)/(M.exp(2*C)+1)},_=function(C){return M.log(1+C)};return{acos:e(.12312423423423424),acosh:t(1e308),acoshPf:w(1e154),asin:r(.12312423423423424),asinh:n(1),asinhPf:g(1),atanh:a(.5),atanhPf:I(.5),atan:i(.5),sin:s(-1e300),sinh:l(1),sinhPf:R(1),cos:c(10.000000000123),cosh:d(1),coshPf:P(1),tan:u(-1e300),tanh:f(1),tanhPf:D(1),exp:p(1),expm1:h(1),expm1Pf:U(1),log1p:x(10),log1pPf:_(10),powPI:v(-100)}}var Vi="mmMwWLliI0fiflO&1",xt={default:[],apple:[{font:"-apple-system-body"}],serif:[{fontFamily:"serif"}],sans:[{fontFamily:"sans-serif"}],mono:[{fontFamily:"monospace"}],min:[{fontSize:"1px"}],system:[{fontFamily:"system-ui"}]};function Di(){return zi(function(e,t){for(var r={},n={},a=0,i=Object.keys(xt);a<i.length;a++){var s=i[a],l=xt[s],c=l[0],d=c===void 0?{}:c,u=l[1],f=u===void 0?Vi:u,p=e.createElement("span");p.textContent=f,p.style.whiteSpace="nowrap";for(var h=0,x=Object.keys(d);h<x.length;h++){var v=x[h],w=d[v];w!==void 0&&(p.style[v]=w)}r[s]=p,t.append(e.createElement("br"),p)}for(var g=0,I=Object.keys(xt);g<I.length;g++){var s=I[g];n[s]=r[s].getBoundingClientRect().width}return n})}function zi(e,t){return t===void 0&&(t=4e3),Ur(function(r,n){var a=n.document,i=a.body,s=i.style;s.width="".concat(t,"px"),s.webkitTextSizeAdjust=s.textSizeAdjust="none",Fe()?i.style.zoom="".concat(1/n.devicePixelRatio):ee()&&(i.style.zoom="reset");var l=a.createElement("div");return l.textContent=Pr([],Array(t/20<<0),!0).map(function(){return"word"}).join(" "),i.appendChild(l),e(a,i)},'<!doctype html><html><head><meta name="viewport" content="width=device-width, initial-scale=1">')}function Ui(){return navigator.pdfViewerEnabled}function Bi(){var e=new Float32Array(1),t=new Uint8Array(e.buffer);return e[0]=1/0,e[0]=e[0]-e[0],t[3]}function Gi(){var e=window.ApplePaySession;if(typeof e?.canMakePayments!="function")return-1;if(Hi())return-3;try{return e.canMakePayments()?1:0}catch(t){return Yi(t)}}var Hi=Da;function Yi(e){if(e instanceof Error&&e.name==="InvalidAccessError"&&/\bfrom\b.*\binsecure\b/i.test(e.message))return-2;throw e}function Xi(){var e,t=document.createElement("a"),r=(e=t.attributionSourceId)!==null&&e!==void 0?e:t.attributionsourceid;return r===void 0?void 0:String(r)}var Br=-1,Gr=-2,Ji=new Set([10752,2849,2884,2885,2886,2928,2929,2930,2931,2932,2960,2961,2962,2963,2964,2965,2966,2967,2968,2978,3024,3042,3088,3089,3106,3107,32773,32777,32777,32823,32824,32936,32937,32938,32939,32968,32969,32970,32971,3317,33170,3333,3379,3386,33901,33902,34016,34024,34076,3408,3410,3411,3412,3413,3414,3415,34467,34816,34817,34818,34819,34877,34921,34930,35660,35661,35724,35738,35739,36003,36004,36005,36347,36348,36349,37440,37441,37443,7936,7937,7938]),Qi=new Set([34047,35723,36063,34852,34853,34854,34229,36392,36795,38449]),Ki=["FRAGMENT_SHADER","VERTEX_SHADER"],qi=["LOW_FLOAT","MEDIUM_FLOAT","HIGH_FLOAT","LOW_INT","MEDIUM_INT","HIGH_INT"],Hr="WEBGL_debug_renderer_info",es="WEBGL_polygon_mode";function ts(e){var t,r,n,a,i,s,l=e.cache,c=Yr(l);if(!c)return Br;if(!Jr(c))return Gr;var d=Xr()?null:c.getExtension(Hr);return{version:((t=c.getParameter(c.VERSION))===null||t===void 0?void 0:t.toString())||"",vendor:((r=c.getParameter(c.VENDOR))===null||r===void 0?void 0:r.toString())||"",vendorUnmasked:d?(n=c.getParameter(d.UNMASKED_VENDOR_WEBGL))===null||n===void 0?void 0:n.toString():"",renderer:((a=c.getParameter(c.RENDERER))===null||a===void 0?void 0:a.toString())||"",rendererUnmasked:d?(i=c.getParameter(d.UNMASKED_RENDERER_WEBGL))===null||i===void 0?void 0:i.toString():"",shadingLanguageVersion:((s=c.getParameter(c.SHADING_LANGUAGE_VERSION))===null||s===void 0?void 0:s.toString())||""}}function rs(e){var t=e.cache,r=Yr(t);if(!r)return Br;if(!Jr(r))return Gr;var n=r.getSupportedExtensions(),a=r.getContextAttributes(),i=[],s=[],l=[],c=[],d=[];if(a)for(var u=0,f=Object.keys(a);u<f.length;u++){var p=f[u];s.push("".concat(p,"=").concat(a[p]))}for(var h=gr(r),x=0,v=h;x<v.length;x++){var w=v[x],g=r[w];l.push("".concat(w,"=").concat(g).concat(Ji.has(g)?"=".concat(r.getParameter(g)):""))}if(n)for(var I=0,R=n;I<R.length;I++){var P=R[I];if(!(P===Hr&&Xr()||P===es&&is())){var U=r.getExtension(P);if(!U){i.push(P);continue}for(var D=0,_=gr(U);D<_.length;D++){var w=_[D],g=U[w];c.push("".concat(w,"=").concat(g).concat(Qi.has(g)?"=".concat(r.getParameter(g)):""))}}}for(var C=0,te=Ki;C<te.length;C++)for(var We=te[C],ge=0,Ie=qi;ge<Ie.length;ge++){var Ve=Ie[ge],ft=ns(r,We,Ve);d.push("".concat(We,".").concat(Ve,"=").concat(ft.join(",")))}return c.sort(),l.sort(),{contextAttributes:s,parameters:l,shaderPrecisions:d,extensions:n,extensionParameters:c,unsupportedExtensions:i}}function Yr(e){if(e.webgl)return e.webgl.context;var t=document.createElement("canvas"),r;t.addEventListener("webglCreateContextError",function(){r=void 0});for(var n=0,a=["webgl","experimental-webgl"];n<a.length;n++){var i=a[n];try{r=t.getContext(i)}catch{}if(r)break}return e.webgl={context:r},r}function ns(e,t,r){var n=e.getShaderPrecisionFormat(e[t],e[r]);return n?[n.rangeMin,n.rangeMax,n.precision]:[]}function gr(e){return Object.keys(e.__proto__).filter(as)}function as(e){return typeof e=="string"&&!e.match(/[^A-Z0-9_x]/)}function Xr(){return zr()}function is(){return Fe()||ee()}function Jr(e){return typeof e.getParameter=="function"}function ss(){if(!(Yt()||ee()))return-2;if(!window.AudioContext)return-1;var e=new AudioContext().baseLatency;return e==null?-1:isFinite(e)?e:-3}function os(){if(!window.Intl)return-1;var e=window.Intl.DateTimeFormat;if(!e)return-2;var t=e().resolvedOptions().locale;return!t&&t!==""?-3:t}var ls={fonts:Ba,domBlockers:Ii,fontPreferences:Di,audio:Ra,screenFrame:hi,canvas:Ha,osCpu:ni,languages:ai,colorDepth:ii,deviceMemory:si,screenResolution:oi,hardwareConcurrency:pi,timezone:mi,sessionStorage:vi,localStorage:xi,indexedDB:ki,openDatabase:yi,cpuClass:bi,platform:_i,plugins:Ga,touchSupport:ri,vendor:wi,vendorFlavors:ji,cookiesEnabled:Si,colorGamut:Ai,invertedColors:Ei,forcedColors:Mi,monochrome:Zi,contrast:Oi,reducedMotion:Fi,reducedTransparency:Pi,hdr:$i,math:Wi,pdfViewerEnabled:Ui,architecture:Bi,applePay:Gi,privateClickMeasurement:Xi,audioBaseLatency:ss,dateTimeLocale:os,webGlBasics:ts,webGlExtensions:rs};function cs(e){return Sa(ls,e,[])}var ds="$ if upgrade to Pro: https://fpjs.dev/pro";function us(e){var t=fs(e),r=hs(t);return{score:t,comment:ds.replace(/\$/g,"".concat(r))}}function fs(e){if(Yt())return .4;if(ee())return Ht()&&!($e()&&Pe())?.5:.3;var t="value"in e.platform?e.platform.value:"";return/^Win/.test(t)?.6:/^Mac/.test(t)?.5:.7}function hs(e){return Vr(.99+.01*e,1e-4)}function ps(e){for(var t="",r=0,n=Object.keys(e).sort();r<n.length;r++){var a=n[r],i=e[a],s="error"in i?"error":JSON.stringify(i.value);t+="".concat(t?"|":"").concat(a.replace(/([:|\\])/g,"\\$1"),":").concat(s)}return t}function ms(e){return JSON.stringify(e,function(t,r){return r instanceof Error?ba(r):r},2)}function Qr(e){return ya(ps(e))}function gs(e){var t;return{get visitorId(){return t===void 0&&(t=Qr(this.components)),t},set visitorId(r){t=r},confidence:us(e),components:e,version:$r}}function vs(e){return e===void 0&&(e=50),ua(e,e*2)}function xs(e,t){var r=Date.now();return{get:function(n){return ae(this,void 0,void 0,function(){var a,i,s;return ie(this,function(l){switch(l.label){case 0:return a=Date.now(),[4,e()];case 1:return i=l.sent(),s=gs(i),t||n?.debug,[2,s]}})})}}}function ks(){if(!(window.__fpjs_d_m||Math.random()>=.001))try{var e=new XMLHttpRequest;e.open("get","https://m1.openfpcdn.io/fingerprintjs/v".concat($r,"/npm-monitoring"),!0),e.send()}catch{}}function ys(e){var t;return e===void 0&&(e={}),ae(this,void 0,void 0,function(){var r,n,a;return ie(this,function(i){switch(i.label){case 0:return(!((t=e.monitoring)!==null&&t!==void 0)||t)&&ks(),r=e.delayFallback,n=e.debug,[4,vs(r)];case 1:return i.sent(),a=cs({cache:{},debug:n}),[2,xs(a,n)]}})})}var bs={load:ys,hashComponents:Qr,componentsToDebugString:ms};function Kr(e){return e.preview?"include":"same-origin"}function qr(e,t){return t.configChannel!=="draft"?e:`${e}${e.includes("?")?"&":"?"}configChannel=draft`}var en=class{baseUrl;options;constructor(e,t={}){this.baseUrl=e,this.options=t}get credentials(){return Kr(this.options)}channel(e){return qr(e,this.options)}async validateWidget(e,t){if(!t)return{valid:!1,error:"Widget is not configured: tenantId is required"};try{const r=new URLSearchParams({agentId:e,tenantId:t}),n=await fetch(this.channel(`${this.baseUrl}/v1/widget/validate?${r}`),{credentials:this.credentials}),a=await n.json();if(n.ok&&a.success)return{valid:!0,agentId:a.data.agentId,tenantId:a.data.tenantId};const i=a?.code==="AGENT_DISABLED"?"AGENT_DISABLED":n.status===404?"AGENT_NOT_FOUND":void 0;return{valid:!1,error:a.error??`Widget configuration is invalid (${n.status})`,...i?{code:i}:{}}}catch{return{valid:!1,error:"Unable to reach the KlicForge API to validate widget configuration"}}}async chat(e){const t=await fetch(this.channel(`${this.baseUrl}/v1/agents/${encodeURIComponent(e.agentId)}/responses`),{method:"POST",credentials:this.credentials,headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e.message,sessionId:e.sessionId,tenantId:e.tenantId,externalId:e.externalId,name:e.name,email:e.email,authId:e.authId,fingerprint:e.fingerprint,metadata:e.metadata,imageUrl:e.imageUrl,attachments:e.attachments})});if(!t.ok)throw new Error(`API error: ${t.status} ${t.statusText}`);const r=await t.json();if(!r.success)throw new Error(r.error??"Unknown API error");return{content:r.data?.text??"",sessionId:r.data?.sessionId,images:r.data?.images,documents:r.data?.documents,queued:!!r.data?.queued,controlMode:r.data?.controlMode}}async fetchSessionMessages(e,t){try{const r=t?`?tenantId=${encodeURIComponent(t)}`:"",n=await fetch(`${this.baseUrl}/v1/sessions/${encodeURIComponent(e)}/messages${r}`,{credentials:this.credentials});if(n.status===410||!n.ok)return null;const a=await n.json();return a.success?a.data?.messages??null:null}catch{return null}}async uploadImage(e,t,r,n,a){const i=await fetch(this.channel(`${this.baseUrl}/v1/upload`),{method:"POST",credentials:this.credentials,headers:{"Content-Type":"application/json"},body:JSON.stringify({file:e,mimeType:t,fileName:r,agentId:n,tenantId:a})});if(!i.ok)throw new Error(`Upload error: ${i.status} ${i.statusText}`);const s=await i.json();if(!s.success)throw new Error(s.error??"Upload failed");return{url:s.data.url}}async uploadFile(e,t,r,n,a){const i=await fetch(this.channel(`${this.baseUrl}/v1/upload`),{method:"POST",credentials:this.credentials,headers:{"Content-Type":"application/json"},body:JSON.stringify({file:e,mimeType:t,fileName:r,agentId:n,tenantId:a,kind:"file"})});if(!i.ok)throw new Error(`Upload error: ${i.status} ${i.statusText}`);const s=await i.json();if(!s.success)throw new Error(s.error??"Upload failed");return{url:s.data.url}}async fetchWidgetConfig(e,t){try{const r=t?`?tenantId=${encodeURIComponent(t)}`:"",n=await fetch(this.channel(`${this.baseUrl}/v1/agents/${encodeURIComponent(e)}/widget-config${r}`),{credentials:this.credentials});if(!n.ok)return null;const a=await n.json();return a.success?a.data:null}catch{return null}}async endSession(e,t,r,n,a,i){const s=await fetch(`${this.baseUrl}/v1/sessions/${encodeURIComponent(e)}/end`,{method:"POST",credentials:this.credentials,headers:{"Content-Type":"application/json"},body:JSON.stringify({tenantId:t,agentId:r,fingerprint:n,externalId:a,skipMemory:i})});if(!s.ok)throw new Error(`Failed to end session: ${s.status} ${s.statusText}`);const l=await s.json();if(!l.success)throw new Error(l.error??"Failed to end session")}};async function*_s(e,t){if(!e.body)return;const r=e.body.getReader(),n=new TextDecoder;let a="";const i=()=>{if(!t)return r.read();let s;return Promise.race([r.read(),new Promise((l,c)=>{s=setTimeout(()=>c(new Error(`Stream timed out — no data received for ${t}ms`)),t)})]).finally(()=>clearTimeout(s))};for(;;){const{value:s,done:l}=await i();if(l)break;a+=n.decode(s,{stream:!0});const c=a.lastIndexOf(`
|
|
5
|
-
`);if(c===-1)continue;const d=
|
|
6
|
-
`)){const
|
|
4
|
+
`.concat(t[c]?"🚫":"➡️"," ").concat(c)}}}function Ni(){for(var e=0,t=["rec2020","p3","srgb"];e<t.length;e++){var r=t[e];if(matchMedia("(color-gamut: ".concat(r,")")).matches)return r}}function Ei(){if(dr("inverted"))return!0;if(dr("none"))return!1}function dr(e){return matchMedia("(inverted-colors: ".concat(e,")")).matches}function Mi(){if(ur("active"))return!0;if(ur("none"))return!1}function ur(e){return matchMedia("(forced-colors: ".concat(e,")")).matches}var Li=100;function Ti(){if(matchMedia("(min-monochrome: 0)").matches){for(var e=0;e<=Li;++e)if(matchMedia("(max-monochrome: ".concat(e,")")).matches)return e;throw new Error("Too high value")}}function Ai(){if(ye("no-preference"))return 0;if(ye("high")||ye("more"))return 1;if(ye("low")||ye("less"))return-1;if(ye("forced"))return 10}function ye(e){return matchMedia("(prefers-contrast: ".concat(e,")")).matches}function Ri(){if(hr("reduce"))return!0;if(hr("no-preference"))return!1}function hr(e){return matchMedia("(prefers-reduced-motion: ".concat(e,")")).matches}function Zi(){if(fr("reduce"))return!0;if(fr("no-preference"))return!1}function fr(e){return matchMedia("(prefers-reduced-transparency: ".concat(e,")")).matches}function Oi(){if(pr("high"))return!0;if(pr("standard"))return!1}function pr(e){return matchMedia("(dynamic-range: ".concat(e,")")).matches}var A=Math,$=function(){return 0};function Fi(){var e=A.acos||$,t=A.acosh||$,r=A.asin||$,a=A.asinh||$,n=A.atanh||$,i=A.atan||$,s=A.sin||$,l=A.sinh||$,c=A.cos||$,d=A.cosh||$,u=A.tan||$,h=A.tanh||$,p=A.exp||$,f=A.expm1||$,v=A.log1p||$,k=function(L){return A.pow(A.PI,L)},S=function(L){return A.log(L+A.sqrt(L*L-1))},g=function(L){return A.log(L+A.sqrt(L*L+1))},C=function(L){return A.log((1+L)/(1-L))/2},R=function(L){return A.exp(L)-1/A.exp(L)/2},P=function(L){return(A.exp(L)+1/A.exp(L))/2},B=function(L){return A.exp(L)-1},D=function(L){return(A.exp(2*L)-1)/(A.exp(2*L)+1)},re=function(L){return A.log(1+L)};return{acos:e(.12312423423423424),acosh:t(1e308),acoshPf:S(1e154),asin:r(.12312423423423424),asinh:a(1),asinhPf:g(1),atanh:n(.5),atanhPf:C(.5),atan:i(.5),sin:s(-1e300),sinh:l(1),sinhPf:R(1),cos:c(10.000000000123),cosh:d(1),coshPf:P(1),tan:u(-1e300),tanh:h(1),tanhPf:D(1),exp:p(1),expm1:f(1),expm1Pf:B(1),log1p:v(10),log1pPf:re(10),powPI:k(-100)}}var Pi="mmMwWLliI0fiflO&1",kt={default:[],apple:[{font:"-apple-system-body"}],serif:[{fontFamily:"serif"}],sans:[{fontFamily:"sans-serif"}],mono:[{fontFamily:"monospace"}],min:[{fontSize:"1px"}],system:[{fontFamily:"system-ui"}]};function Wi(){return $i(function(e,t){for(var r={},a={},n=0,i=Object.keys(kt);n<i.length;n++){var s=i[n],l=kt[s],c=l[0],d=c===void 0?{}:c,u=l[1],h=u===void 0?Pi:u,p=e.createElement("span");p.textContent=h,p.style.whiteSpace="nowrap";for(var f=0,v=Object.keys(d);f<v.length;f++){var k=v[f],S=d[k];S!==void 0&&(p.style[k]=S)}r[s]=p,t.append(e.createElement("br"),p)}for(var g=0,C=Object.keys(kt);g<C.length;g++){var s=C[g];a[s]=r[s].getBoundingClientRect().width}return a})}function $i(e,t){return t===void 0&&(t=4e3),Dr(function(r,a){var n=a.document,i=n.body,s=i.style;s.width="".concat(t,"px"),s.webkitTextSizeAdjust=s.textSizeAdjust="none",Pe()?i.style.zoom="".concat(1/a.devicePixelRatio):te()&&(i.style.zoom="reset");var l=n.createElement("div");return l.textContent=Fr([],Array(t/20<<0),!0).map(function(){return"word"}).join(" "),i.appendChild(l),e(n,i)},'<!doctype html><html><head><meta name="viewport" content="width=device-width, initial-scale=1">')}function Vi(){return navigator.pdfViewerEnabled}function zi(){var e=new Float32Array(1),t=new Uint8Array(e.buffer);return e[0]=1/0,e[0]=e[0]-e[0],t[3]}function Di(){var e=window.ApplePaySession;if(typeof e?.canMakePayments!="function")return-1;if(Ui())return-3;try{return e.canMakePayments()?1:0}catch(t){return Bi(t)}}var Ui=Wn;function Bi(e){if(e instanceof Error&&e.name==="InvalidAccessError"&&/\bfrom\b.*\binsecure\b/i.test(e.message))return-2;throw e}function Gi(){var e,t=document.createElement("a"),r=(e=t.attributionSourceId)!==null&&e!==void 0?e:t.attributionsourceid;return r===void 0?void 0:String(r)}var Ur=-1,Br=-2,Hi=new Set([10752,2849,2884,2885,2886,2928,2929,2930,2931,2932,2960,2961,2962,2963,2964,2965,2966,2967,2968,2978,3024,3042,3088,3089,3106,3107,32773,32777,32777,32823,32824,32936,32937,32938,32939,32968,32969,32970,32971,3317,33170,3333,3379,3386,33901,33902,34016,34024,34076,3408,3410,3411,3412,3413,3414,3415,34467,34816,34817,34818,34819,34877,34921,34930,35660,35661,35724,35738,35739,36003,36004,36005,36347,36348,36349,37440,37441,37443,7936,7937,7938]),Yi=new Set([34047,35723,36063,34852,34853,34854,34229,36392,36795,38449]),Xi=["FRAGMENT_SHADER","VERTEX_SHADER"],Ji=["LOW_FLOAT","MEDIUM_FLOAT","HIGH_FLOAT","LOW_INT","MEDIUM_INT","HIGH_INT"],Gr="WEBGL_debug_renderer_info",Qi="WEBGL_polygon_mode";function Ki(e){var t,r,a,n,i,s,l=e.cache,c=Hr(l);if(!c)return Ur;if(!Xr(c))return Br;var d=Yr()?null:c.getExtension(Gr);return{version:((t=c.getParameter(c.VERSION))===null||t===void 0?void 0:t.toString())||"",vendor:((r=c.getParameter(c.VENDOR))===null||r===void 0?void 0:r.toString())||"",vendorUnmasked:d?(a=c.getParameter(d.UNMASKED_VENDOR_WEBGL))===null||a===void 0?void 0:a.toString():"",renderer:((n=c.getParameter(c.RENDERER))===null||n===void 0?void 0:n.toString())||"",rendererUnmasked:d?(i=c.getParameter(d.UNMASKED_RENDERER_WEBGL))===null||i===void 0?void 0:i.toString():"",shadingLanguageVersion:((s=c.getParameter(c.SHADING_LANGUAGE_VERSION))===null||s===void 0?void 0:s.toString())||""}}function qi(e){var t=e.cache,r=Hr(t);if(!r)return Ur;if(!Xr(r))return Br;var a=r.getSupportedExtensions(),n=r.getContextAttributes(),i=[],s=[],l=[],c=[],d=[];if(n)for(var u=0,h=Object.keys(n);u<h.length;u++){var p=h[u];s.push("".concat(p,"=").concat(n[p]))}for(var f=mr(r),v=0,k=f;v<k.length;v++){var S=k[v],g=r[S];l.push("".concat(S,"=").concat(g).concat(Hi.has(g)?"=".concat(r.getParameter(g)):""))}if(a)for(var C=0,R=a;C<R.length;C++){var P=R[C];if(!(P===Gr&&Yr()||P===Qi&&rs())){var B=r.getExtension(P);if(!B){i.push(P);continue}for(var D=0,re=mr(B);D<re.length;D++){var S=re[D],g=B[S];c.push("".concat(S,"=").concat(g).concat(Yi.has(g)?"=".concat(r.getParameter(g)):""))}}}for(var L=0,j=Xi;L<j.length;L++)for(var F=j[L],oe=0,Ne=Ji;oe<Ne.length;oe++){var Ve=Ne[oe],ht=es(r,F,Ve);d.push("".concat(F,".").concat(Ve,"=").concat(ht.join(",")))}return c.sort(),l.sort(),{contextAttributes:s,parameters:l,shaderPrecisions:d,extensions:a,extensionParameters:c,unsupportedExtensions:i}}function Hr(e){if(e.webgl)return e.webgl.context;var t=document.createElement("canvas"),r;t.addEventListener("webglCreateContextError",function(){r=void 0});for(var a=0,n=["webgl","experimental-webgl"];a<n.length;a++){var i=n[a];try{r=t.getContext(i)}catch{}if(r)break}return e.webgl={context:r},r}function es(e,t,r){var a=e.getShaderPrecisionFormat(e[t],e[r]);return a?[a.rangeMin,a.rangeMax,a.precision]:[]}function mr(e){return Object.keys(e.__proto__).filter(ts)}function ts(e){return typeof e=="string"&&!e.match(/[^A-Z0-9_x]/)}function Yr(){return zr()}function rs(){return Pe()||te()}function Xr(e){return typeof e.getParameter=="function"}function as(){if(!(Yt()||te()))return-2;if(!window.AudioContext)return-1;var e=new AudioContext().baseLatency;return e==null?-1:isFinite(e)?e:-3}function ns(){if(!window.Intl)return-1;var e=window.Intl.DateTimeFormat;if(!e)return-2;var t=e().resolvedOptions().locale;return!t&&t!==""?-3:t}var is={fonts:zn,domBlockers:ji,fontPreferences:Wi,audio:Ln,screenFrame:di,canvas:Un,osCpu:ei,languages:ti,colorDepth:ri,deviceMemory:ai,screenResolution:ni,hardwareConcurrency:ui,timezone:hi,sessionStorage:pi,localStorage:mi,indexedDB:gi,openDatabase:vi,cpuClass:ki,platform:xi,plugins:Dn,touchSupport:qn,vendor:yi,vendorFlavors:bi,cookiesEnabled:_i,colorGamut:Ni,invertedColors:Ei,forcedColors:Mi,monochrome:Ti,contrast:Ai,reducedMotion:Ri,reducedTransparency:Zi,hdr:Oi,math:Fi,pdfViewerEnabled:Vi,architecture:zi,applePay:Di,privateClickMeasurement:Gi,audioBaseLatency:as,dateTimeLocale:ns,webGlBasics:Ki,webGlExtensions:qi};function ss(e){return _n(is,e,[])}var os="$ if upgrade to Pro: https://fpjs.dev/pro";function ls(e){var t=cs(e),r=ds(t);return{score:t,comment:os.replace(/\$/g,"".concat(r))}}function cs(e){if(Yt())return .4;if(te())return Ht()&&!($e()&&We())?.5:.3;var t="value"in e.platform?e.platform.value:"";return/^Win/.test(t)?.6:/^Mac/.test(t)?.5:.7}function ds(e){return $r(.99+.01*e,1e-4)}function us(e){for(var t="",r=0,a=Object.keys(e).sort();r<a.length;r++){var n=a[r],i=e[n],s="error"in i?"error":JSON.stringify(i.value);t+="".concat(t?"|":"").concat(n.replace(/([:|\\])/g,"\\$1"),":").concat(s)}return t}function hs(e){return JSON.stringify(e,function(t,r){return r instanceof Error?kn(r):r},2)}function Jr(e){return vn(us(e))}function fs(e){var t;return{get visitorId(){return t===void 0&&(t=Jr(this.components)),t},set visitorId(r){t=r},confidence:ls(e),components:e,version:Pr}}function ps(e){return e===void 0&&(e=50),ln(e,e*2)}function ms(e,t){var r=Date.now();return{get:function(a){return ie(this,void 0,void 0,function(){var n,i,s;return se(this,function(l){switch(l.label){case 0:return n=Date.now(),[4,e()];case 1:return i=l.sent(),s=fs(i),t||a?.debug,[2,s]}})})}}}function gs(){if(!(window.__fpjs_d_m||Math.random()>=.001))try{var e=new XMLHttpRequest;e.open("get","https://m1.openfpcdn.io/fingerprintjs/v".concat(Pr,"/npm-monitoring"),!0),e.send()}catch{}}function vs(e){var t;return e===void 0&&(e={}),ie(this,void 0,void 0,function(){var r,a,n;return se(this,function(i){switch(i.label){case 0:return(!((t=e.monitoring)!==null&&t!==void 0)||t)&&gs(),r=e.delayFallback,a=e.debug,[4,ps(r)];case 1:return i.sent(),n=ss({cache:{},debug:a}),[2,ms(n,a)]}})})}var ks={load:vs,hashComponents:Jr,componentsToDebugString:hs};function Qr(e){return e.preview?"include":"same-origin"}function Kr(e,t){return t.configChannel!=="draft"?e:`${e}${e.includes("?")?"&":"?"}configChannel=draft`}var qr=class{baseUrl;options;constructor(e,t={}){this.baseUrl=e,this.options=t}get credentials(){return Qr(this.options)}channel(e){return Kr(e,this.options)}async validateWidget(e,t){if(!t)return{valid:!1,error:"Widget is not configured: tenantId is required"};try{const r=new URLSearchParams({agentId:e,tenantId:t}),a=await fetch(this.channel(`${this.baseUrl}/v1/widget/validate?${r}`),{credentials:this.credentials}),n=await a.json();if(a.ok&&n.success)return{valid:!0,agentId:n.data.agentId,tenantId:n.data.tenantId};const i=n?.code==="AGENT_DISABLED"?"AGENT_DISABLED":a.status===404?"AGENT_NOT_FOUND":void 0;return{valid:!1,error:n.error??`Widget configuration is invalid (${a.status})`,...i?{code:i}:{}}}catch{return{valid:!1,error:"Unable to reach the KlicForge API to validate widget configuration"}}}async chat(e){const t=await fetch(this.channel(`${this.baseUrl}/v1/agents/${encodeURIComponent(e.agentId)}/responses`),{method:"POST",credentials:this.credentials,headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e.message,sessionId:e.sessionId,tenantId:e.tenantId,externalId:e.externalId,name:e.name,email:e.email,authId:e.authId,fingerprint:e.fingerprint,metadata:e.metadata,imageUrl:e.imageUrl,attachments:e.attachments})});if(!t.ok)throw new Error(`API error: ${t.status} ${t.statusText}`);const r=await t.json();if(!r.success)throw new Error(r.error??"Unknown API error");return{content:r.data?.text??"",sessionId:r.data?.sessionId,images:r.data?.images,documents:r.data?.documents,queued:!!r.data?.queued,controlMode:r.data?.controlMode}}async fetchSessionMessages(e,t){try{const r=t?`?tenantId=${encodeURIComponent(t)}`:"",a=await fetch(`${this.baseUrl}/v1/sessions/${encodeURIComponent(e)}/messages${r}`,{credentials:this.credentials});if(a.status===410||!a.ok)return null;const n=await a.json();return n.success?n.data?.messages??null:null}catch{return null}}async uploadImage(e,t,r,a,n){const i=await fetch(this.channel(`${this.baseUrl}/v1/upload`),{method:"POST",credentials:this.credentials,headers:{"Content-Type":"application/json"},body:JSON.stringify({file:e,mimeType:t,fileName:r,agentId:a,tenantId:n})});if(!i.ok)throw new Error(`Upload error: ${i.status} ${i.statusText}`);const s=await i.json();if(!s.success)throw new Error(s.error??"Upload failed");return{url:s.data.url}}async uploadFile(e,t,r,a,n){const i=await fetch(this.channel(`${this.baseUrl}/v1/upload`),{method:"POST",credentials:this.credentials,headers:{"Content-Type":"application/json"},body:JSON.stringify({file:e,mimeType:t,fileName:r,agentId:a,tenantId:n,kind:"file"})});if(!i.ok)throw new Error(`Upload error: ${i.status} ${i.statusText}`);const s=await i.json();if(!s.success)throw new Error(s.error??"Upload failed");return{url:s.data.url}}async fetchWidgetConfig(e,t){try{const r=t?`?tenantId=${encodeURIComponent(t)}`:"",a=await fetch(this.channel(`${this.baseUrl}/v1/agents/${encodeURIComponent(e)}/widget-config${r}`),{credentials:this.credentials});if(!a.ok)return null;const n=await a.json();return n.success?n.data:null}catch{return null}}async endSession(e,t,r,a,n,i){const s=await fetch(`${this.baseUrl}/v1/sessions/${encodeURIComponent(e)}/end`,{method:"POST",credentials:this.credentials,headers:{"Content-Type":"application/json"},body:JSON.stringify({tenantId:t,agentId:r,fingerprint:a,externalId:n,skipMemory:i})});if(!s.ok)throw new Error(`Failed to end session: ${s.status} ${s.statusText}`);const l=await s.json();if(!l.success)throw new Error(l.error??"Failed to end session")}};async function*xs(e,t){if(!e.body)return;const r=e.body.getReader(),a=new TextDecoder;let n="";const i=()=>{if(!t)return r.read();let s;return Promise.race([r.read(),new Promise((l,c)=>{s=setTimeout(()=>c(new Error(`Stream timed out — no data received for ${t}ms`)),t)})]).finally(()=>clearTimeout(s))};for(;;){const{value:s,done:l}=await i();if(l)break;n+=a.decode(s,{stream:!0});const c=n.lastIndexOf(`
|
|
5
|
+
`);if(c===-1)continue;const d=n.slice(0,c);n=n.slice(c+1);for(const u of d.split(`
|
|
6
|
+
`)){const h=u.trim();if(!h.startsWith("data:"))continue;const p=h.slice(5).trim();p&&(yield p)}}}var ys=12e4;async function ea(e,t,r,a={}){let n="",i=!1;try{const s=await fetch(Kr(`${e}/v1/agents/${encodeURIComponent(t.agentId)}/responses:stream`,a),{method:"POST",credentials:Qr(a),headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t.message,sessionId:t.sessionId,tenantId:t.tenantId,externalId:t.externalId,name:t.name,email:t.email,authId:t.authId,fingerprint:t.fingerprint,metadata:t.metadata,imageUrl:t.imageUrl,attachments:t.attachments})});if(!s.ok||!s.body){let u=`${s.status} ${s.statusText}`;try{const h=await s.json();h.error&&(u=h.error)}catch{}throw Object.assign(new Error(u),{status:s.status})}const l=s.headers.get("x-session-id");l&&r.onSession&&r.onSession(l);const c=s.headers.get("x-run-id");c&&r.onRunId&&(i=!0,r.onRunId(c));const d=u=>{if(u==="[DONE]")return r.onEnd(n),!0;try{const h=JSON.parse(u);if(!i&&typeof h.runId=="string"&&r.onRunId&&(i=!0,r.onRunId(h.runId)),h.type==="session"){const f=h.sessionId;return f&&r.onSession&&r.onSession(f),!1}if(h.type==="done"||h.type==="stop")return r.onEnd(n),!0;if(h.type==="error")throw new Error(h.message??"Stream error");if(h.type==="images"){const f=h.images;return f&&r.onImages&&r.onImages(f),!1}if(h.type==="documents"){const f=h.documents;return f&&r.onDocuments&&r.onDocuments(f),!1}if(h.type==="control_mode"){const f=h.mode,v=!!h.queued;return f&&r.onControlMode&&r.onControlMode(f,v),v?(r.onEnd(n),!0):!1}if(h.type==="tool_calls_started"){const f=h.toolNames??[];return n.length>0&&!n.endsWith(`
|
|
7
7
|
|
|
8
|
-
`)&&(
|
|
8
|
+
`)&&(n=n.replace(/\s+$/,"")+`
|
|
9
9
|
|
|
10
10
|
`,r.onDelta(`
|
|
11
11
|
|
|
12
|
-
`,a)),r.onToolCallsStarted?.(h,f.activityMode),!1}if(f.type==="assistant_ack"){const h=f.text;return h&&r.onAck&&r.onAck(h),!1}if(f.type==="progress"){const h=f.stage,x=f.text,v=f.mode;return h&&x&&r.onProgress&&r.onProgress(h,x,v),!1}if(f.type==="tool_start"){const h=f.toolId,x=f.text,v=f.toolName,w=f.mode;return h&&x&&r.onToolStart&&r.onToolStart(h,x,v,w),!1}if(f.type==="tool_complete"){const h=f.toolId,x=f.text,v=f.durationMs,w=f.ok;return h&&x&&r.onToolComplete&&r.onToolComplete(h,x,v??0,w),!1}if(f.type==="model_start"||f.type==="final_meta"){if(f.type==="final_meta"&&r.onFinalMeta){const h=f.metrics;r.onFinalMeta(h??{},{mode:f.mode,collapseAfterFinal:f.collapseAfterFinal})}return!1}const p=js(f);p&&(a+=p,r.onDelta(p,a))}catch(f){if(!(f instanceof SyntaxError))throw f}return!1};for await(const u of _s(s,ws))if(d(u))break;r.onEnd(a)}catch(s){r.onError(s instanceof Error?s:new Error(String(s)))}}function js(e){const t=e.choices;if(Array.isArray(t)&&t.length>0){const a=t[0]?.delta,i=a?.content??a?.text??"";if(i)return i}const r=e.delta;if(r){const a=r.content??r.text??"";if(a)return a}const n=e.response;return n||(e.text??e.content??"")}function Ss(e,t,r){const n=t*Math.pow(2,e-1),a=Math.min(n,r),i=a*.3;return Math.floor(a-i+Math.random()*(i*2))}async function Cs(e,t,r,n={}){const a=await fetch(`${e}/v1/sessions/${encodeURIComponent(t)}/runs/${encodeURIComponent(r)}`,{credentials:n.preview?"include":"same-origin"});if(!a.ok)throw new Error(`Failed to fetch run ${r}: ${a.status}`);const i=await a.json();if(!i.success||!i.data)throw new Error(i.error??`Failed to fetch run ${r}`);return i.data}async function Is(e,t,r,n={}){const a=n.maxAttempts??3;let i;for(let s=1;s<=a;s++){if(s>1){const l=Ss(s-1,500,4e3);await new Promise(c=>setTimeout(c,l))}try{const l=await Cs(e,t,r,n);if(l.status!=="running"||s===a)return l}catch(l){if(i=l instanceof Error?l:new Error(String(l)),s===a)throw i}}throw i??new Error(`Failed to fetch run ${r}`)}var rn=class{listeners=new Map;on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(...e){const[t,r]=e;this.listeners.get(t)?.forEach(n=>n(r))}removeAllListeners(){this.listeners.clear()}},Ns="agentforge";function Xt(e){return`${Ns}:session:${e}`}function nn(e){try{return sessionStorage.getItem(Xt(e))??void 0}catch{return}}function Ee(e,t){try{sessionStorage.setItem(Xt(e),t)}catch{}}function Vt(e){try{sessionStorage.removeItem(Xt(e))}catch{}}function vr(e,t){return e.map(r=>r.status==="active"&&r.stage!=="calling_tool"?{...r,status:"done",durationMs:r.durationMs??(r.startedAtMs?t-r.startedAtMs:void 0)}:r)}function Ts(e){const t=Date.now();return e.map(r=>r.status==="active"?{...r,status:"done",durationMs:r.durationMs??(r.startedAtMs?t-r.startedAtMs:void 0)}:r)}function ot(e){if(e==null||e<1e3)return null;if(e<1e4)return`${(e/1e3).toFixed(1)}s`;if(e<6e4)return`${Math.round(e/1e3)}s`;const t=Math.floor(e/6e4),r=Math.round(e%6e4/1e3);return r>0?`${t}m ${r}s`:`${t}m`}function ye(){return`msg-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`}var an=class{hostConfig;onStateChange;config;apiClient;state;fingerprint;eventSource=null;emitter;constructor(e,t,r){this.hostConfig=t,this.onStateChange=r,this.config=e,this.apiClient=new en(e.apiBaseUrl,{preview:e.preview,configChannel:e.configChannel}),this.emitter=new rn,this.initializeFingerprint();const n=e.sessionId??nn(e.agentId);e.sessionId&&Ee(e.agentId,e.sessionId);const a=e.mode==="inline";this.state={isOpen:a,messages:[],isLoading:!1,error:null,sessionId:n,initStatus:"validating",initError:null},a&&queueMicrotask(()=>this.openWithGreeting())}reportError(e,t){try{fetch(`${this.config.apiBaseUrl.replace(/\/$/,"")}/v1/widget/errors`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e,stack:t?.stack,agentId:this.config.agentId,tenantId:this.config.tenantId,sessionId:this.state.sessionId??this.fingerprint,url:typeof location<"u"?location.href:void 0})}).catch(()=>{})}catch{}}async initializeFingerprint(){try{const e=await(await bs.load()).get();this.fingerprint=e.visitorId}catch{this.fingerprint=void 0}}getState(){return{...this.state,messages:[...this.state.messages]}}setOpen(e){e?this.openWithGreeting():this.setState({isOpen:!1})}openWithGreeting(){this.state.initStatus==="error"||this.state.initStatus==="disabled"||this.setState({isOpen:!0})}async hydrate(){const e=await this.apiClient.validateWidget(this.config.agentId,this.config.tenantId);if(!e.valid){if(e.code==="AGENT_DISABLED"){this.setState({initStatus:"disabled",initError:null});return}this.setState({initStatus:"error",initError:e.error});return}if(!this.config.skipServerConfigFetch){const n=await this.apiClient.fetchWidgetConfig(this.config.agentId,this.config.tenantId);n&&(this.config=Ce(this.hostConfig,n),this.onStateChange(this.getState(),this.config))}if(this.setState({initStatus:"ready"}),!this.state.sessionId)return;this.openEventStream();const t=await this.apiClient.fetchSessionMessages(this.state.sessionId,this.config.tenantId);if(t===null){this.handleSessionExpired();return}if(t.length===0)return;const r=t.map(n=>{const a=n.direction==="human",i=n.role==="user",s=i?(n.media??[]).map(l=>({url:l.url,mimeType:l.mimeType,fileName:l.fileName,kind:l.mimeType.startsWith("image/")?"image":"file"})):void 0;return{id:ye(),role:n.role,content:n.content,images:!i&&n.images&&n.images.length>0?n.images:void 0,uploadedAttachments:s&&s.length>0?s:void 0,uploadedImageUrl:n.imageUrl||void 0,createdAt:n.createdAt??new Date().toISOString(),status:"sent",...a?{isHuman:!0,senderDisplay:n.senderDisplay??null}:{}}});this.setState({messages:[...this.state.messages,...r]})}openEventStream(){if(typeof EventSource>"u"||!this.state.sessionId||this.eventSource)return;const e=`${this.config.apiBaseUrl.replace(/\/$/,"")}/v1/sessions/${encodeURIComponent(this.state.sessionId)}/events`,t=new EventSource(e);t.onmessage=r=>{try{const n=JSON.parse(r.data);if(n.type==="control_mode"){const a=n.mode;this.setState({controlMode:a}),this.emitter.emit("control_mode_changed",{mode:a});return}if(n.type==="execution_state"){const a=n.state;a==="ai_thinking"||a==="ai_streaming"||a==="tool_running"?this.setState({isLoading:!0}):a==="idle"&&this.setState({isLoading:!1});return}if(n.type==="message"&&n.message&&typeof n.message=="object"){const a=n.message;if(typeof a.content!="string"||a.id&&this.state.messages.some(i=>i.id===a.id))return;if(a.direction==="human"){const i={id:a.id??ye(),role:"assistant",content:a.content,createdAt:a.createdAt??new Date().toISOString(),status:"sent",isHuman:!0,senderDisplay:a.senderDisplay??null};this.setState({messages:[...this.state.messages,i],isLoading:!1}),this.emitter.emit("message:received",i);return}if(a.direction==="ai"){const i={id:a.id??ye(),role:"assistant",content:a.content,createdAt:a.createdAt??new Date().toISOString(),status:"sent"};this.setState({messages:[...this.state.messages,i],isLoading:!1}),this.emitter.emit("message:received",i);return}}}catch{}},t.onerror=()=>{},this.eventSource=t}closeEventStream(){this.eventSource&&(this.eventSource.close(),this.eventSource=null)}setState(e){this.state={...this.state,...e},this.onStateChange(this.getState(),this.config)}updateMessage(e,t){this.state={...this.state,messages:this.state.messages.map(r=>r.id===e?{...r,...t}:r)},this.onStateChange(this.getState(),this.config)}async resetConversation(){if(this.state.sessionId)try{await this.apiClient.endSession(this.state.sessionId,this.config.tenantId,this.config.agentId,this.fingerprint,this.config.user.externalId,!0)}catch{}Vt(this.config.agentId),this.closeEventStream(),this.setState({sessionId:void 0,messages:[],isLoading:!1,error:null,controlMode:void 0}),this.emitter.emit("reset",void 0),this.state.isOpen&&this.openWithGreeting()}handleSessionExpired(){Vt(this.config.agentId),this.closeEventStream(),this.setState({sessionId:void 0,controlMode:void 0})}async sendMessage(e,t){const r=!!e.trim()||t&&t.length>0;if(this.state.isLoading||!r||this.state.initStatus!=="ready")return;const n=[];if(t&&t.length>0)for(const c of t)try{const d=await As(c.file);if(c.kind==="image"){const u=await this.apiClient.uploadImage(d,c.file.type,c.file.name,this.config.agentId,this.config.tenantId);n.push({url:u.url,mimeType:c.file.type,fileName:c.file.name,kind:"image"})}else{const u=await this.apiClient.uploadFile(d,c.file.type||"application/octet-stream",c.file.name,this.config.agentId,this.config.tenantId);n.push({url:u.url,mimeType:c.file.type||"application/octet-stream",fileName:c.file.name,kind:"file"})}}catch(d){const u=d instanceof Error?d.message:"Attachment upload failed";this.setState({error:u});return}const a=n.filter(c=>c.kind==="image"),i={id:ye(),role:"user",content:e.trim(),uploadedImageUrl:a[0]?.url,uploadedAttachments:n.length>0?n:void 0,createdAt:new Date().toISOString(),status:"sent"},s=!this.state.messages.some(c=>c.role==="user");this.setState({messages:[...this.state.messages,i],isLoading:!0,error:null}),this.emitter.emit("message:sent",i),s&&this.emitter.emit("conversation:started",{sessionId:this.state.sessionId});const l=n.length>0?n:void 0;this.config.streaming?await this.sendStreaming(e.trim(),void 0,l):await this.sendNonStreaming(e.trim(),void 0,l)}async sendNonStreaming(e,t,r,n=!1){try{const a=await this.apiClient.chat({agentId:this.config.agentId,message:e,sessionId:this.state.sessionId,tenantId:this.config.tenantId,externalId:this.config.user.externalId,name:this.config.user.name,email:this.config.user.email,authId:this.config.user.authId,fingerprint:this.fingerprint,metadata:this.config.metadata,imageUrl:t,attachments:r});if(a.queued&&a.controlMode==="human"){this.setState({isLoading:!1,controlMode:"human_takeover",...a.sessionId?{sessionId:a.sessionId}:{}}),a.sessionId&&(Ee(this.config.agentId,a.sessionId),this.openEventStream());return}const i={id:ye(),role:"assistant",content:a.content,images:a.images,documents:a.documents,createdAt:new Date().toISOString(),status:"sent"};this.setState({messages:[...this.state.messages,i],isLoading:!1,...a.sessionId?{sessionId:a.sessionId}:{}}),a.sessionId&&(Ee(this.config.agentId,a.sessionId),this.openEventStream()),this.emitter.emit("message:received",i)}catch(a){const i=a instanceof Error?a.message:"Failed to send message";if(!n&&i.includes("410"))return this.handleSessionExpired(),this.sendNonStreaming(e,t,r,!0);this.setState({isLoading:!1,error:i}),this.emitter.emit("message:error",{error:i,message:null}),this.reportError(i)}}async sendStreaming(e,t,r,n=!1){const a=ye(),i={id:a,role:"assistant",content:"",createdAt:new Date().toISOString(),status:"streaming",toolStatus:"Thinking..."};this.setState({messages:[...this.state.messages,i]}),this.emitter.emit("stream:start");let s=!1,l=!1,c=null,d=null,u=null;const f=Date.now();await tn(this.config.apiBaseUrl,{agentId:this.config.agentId,message:e,sessionId:this.state.sessionId,tenantId:this.config.tenantId,externalId:this.config.user.externalId,name:this.config.user.name,email:this.config.user.email,authId:this.config.user.authId,fingerprint:this.fingerprint,metadata:this.config.metadata,imageUrl:t,attachments:r},{onSession:p=>{this.setState({sessionId:p}),Ee(this.config.agentId,p),this.openEventStream()},onRunId:p=>{this.updateMessage(a,{runId:p})},onImages:p=>{this.updateMessage(a,{images:p})},onDocuments:p=>{this.updateMessage(a,{documents:p})},onToolCallsStarted:(p,h)=>{h&&d===null&&(d=h),(h??d)!=="off"&&this.updateMessage(a,{toolStatus:Ls(p)})},onAck:p=>{this.updateMessage(a,{ackText:p})},onProgress:(p,h,x)=>{const v=this.state.messages.find(g=>g.id===a)?.progressEvents??[],w=Date.now();x&&d===null&&(d=x,this.updateMessage(a,{turnMeta:{totalMs:null,collapseAfterFinal:null,mode:x}})),this.updateMessage(a,{progressEvents:[...vr(v,w),{stage:p,text:h,timestamp:new Date().toISOString(),status:"active",startedAtMs:w}]})},onToolStart:(p,h,x,v)=>{const w=this.state.messages.find(I=>I.id===a)?.progressEvents??[],g=Date.now();v&&d===null&&(d=v,this.updateMessage(a,{turnMeta:{totalMs:null,collapseAfterFinal:null,mode:v}})),this.updateMessage(a,{progressEvents:[...vr(w,g),{stage:"calling_tool",toolId:p,toolName:x,text:h,timestamp:new Date().toISOString(),status:"active",startedAtMs:g}]})},onToolComplete:(p,h,x,v)=>{const w=this.state.messages.find(g=>g.id===a)?.progressEvents??[];this.updateMessage(a,{progressEvents:w.map(g=>g.stage==="calling_tool"&&g.status==="active"&&g.toolId===p?{...g,status:"done",text:h,durationMs:x,ok:v}:g)})},onFinalMeta:(p,h)=>{c=p.totalMs??null,d=h?.mode??d,u=h?.collapseAfterFinal??null},onDelta:(p,h)=>{h.trim()&&(this.updateMessage(a,{content:h,toolStatus:void 0}),this.emitter.emit("stream:delta",{delta:p,accumulated:h}))},onEnd:p=>{if(l){this.setState({messages:this.state.messages.filter(g=>g.id!==a),isLoading:!1,controlMode:"human_takeover"}),this.emitter.emit("stream:end",{content:""});return}const h=this.state.messages.find(g=>g.id===a),x=d==="detailed",v=x||d==="standard";this.updateMessage(a,{content:p,status:"sent",toolStatus:void 0,progressEvents:x&&h?.progressEvents?.length?Ts(h.progressEvents):void 0,progressCollapsed:x?u??!0:void 0,turnMeta:v?{totalMs:c??Date.now()-f,collapseAfterFinal:u,mode:d}:void 0}),this.setState({isLoading:!1}),this.emitter.emit("stream:end",{content:p});const w=this.state.messages.find(g=>g.id===a);w&&this.emitter.emit("message:received",w)},onControlMode:(p,h)=>{h&&p==="human"&&(l=!0)},onError:p=>{if(!n&&p.status===410){s=!0,this.setState({messages:this.state.messages.filter(g=>g.id!==a),isLoading:!1});return}const h=g=>{const I=this.state.messages.find(R=>R.id===a)?.content??"";this.updateMessage(a,{content:I||g,status:"error"}),this.setState({isLoading:!1,error:g}),this.emitter.emit("message:error",{error:g,message:null}),this.reportError(g,{stack:p.stack})},x=g=>{this.updateMessage(a,{content:g,status:"sent",toolStatus:void 0,progressEvents:void 0}),this.setState({isLoading:!1}),this.emitter.emit("stream:end",{content:g});const I=this.state.messages.find(R=>R.id===a);I&&this.emitter.emit("message:received",I)},v=this.state.messages.find(g=>g.id===a)?.runId,w=this.state.sessionId;if(v&&w){Is(this.config.apiBaseUrl,w,v,{preview:this.config.preview}).then(g=>{g.status==="done"&&g.finalText?x(g.finalText):h(g.errorMessage||p.message||"Something went wrong. Please try again.")}).catch(()=>h(p.message||"Something went wrong. Please try again."));return}h(p.message||"Something went wrong. Please try again.")}},{preview:this.config.preview,configChannel:this.config.configChannel}),s&&(this.handleSessionExpired(),await this.sendStreaming(e,t,r,!0))}};function Ls(e){const t=e[0];if(!t)return"Working...";const r=t.indexOf(".");return r>0?`Using ${t.slice(0,r).replace(/_/g," ")}: ${t.slice(r+1).replace(/_/g," ")}${e.length>1?` +${e.length-1}`:""}`:`Using ${t.replace(/_/g," ")}`}function As(e){return new Promise((t,r)=>{const n=new FileReader;n.onload=()=>{const a=n.result;t(a.split(",")[1]??"")},n.onerror=()=>r(new Error("Failed to read file")),n.readAsDataURL(e)})}function sn(e){const t=document.createElement("div");t.setAttribute("data-agentkit-widget",""),e.appendChild(t);const r=t.attachShadow({mode:"open"}),n=document.createElement("style");r.appendChild(n);const a=document.createElement("div");return a.style.cssText="display: contents;",r.appendChild(a),{host:t,shadowRoot:r,styleSlot:n,mountPoint:a}}function on(e,t){e.textContent=t}function ln(e){e.remove()}function cn(){const e=document.createElement("div");return e.setAttribute("data-agentkit-root","floating"),e.style.cssText=["position: fixed","bottom: 24px","right: 24px","z-index: 2147483647","pointer-events: none"].join("; "),document.body.appendChild(e),e}function Es(e){getComputedStyle(e).position==="static"&&(e.style.position="relative");const t=document.createElement("div");return t.setAttribute("data-agentkit-root","floating"),t.style.cssText=["position: absolute","bottom: 24px","right: 24px","z-index: 2147483647","pointer-events: none"].join("; "),e.appendChild(t),t}function dn(e){return e.setAttribute("data-agentkit-root","inline"),getComputedStyle(e).position==="static"&&(e.style.position="relative"),e}function Ms(e){e.remove()}function Rs(e){e.removeAttribute("data-agentkit-root")}function dt(e,t,r,n,a){const i=e.mode==="inline";let s=!1;const l=i&&a?dn(a):!i&&a?Es(a):cn(),c=sn(l);on(c.styleSlot,n);const d=new an(e,t,(p,h)=>{s||u.update(p,h)}),u=r(c.mountPoint,e,d.getState(),{onOpen:()=>f.open(),onClose:()=>f.close(),onSendMessage:(p,h)=>{d.sendMessage(p,h)},onReset:()=>{d.resetConversation()}});d.hydrate(),setTimeout(()=>{s||d.emitter.emit("ready",d.getState())},0);const f={open(){s||(d.setOpen(!0),d.emitter.emit("open"))},close(){s||(d.setOpen(!1),d.emitter.emit("close"))},toggle(){d.getState().isOpen?f.close():f.open()},async sendMessage(p,h){await d.sendMessage(p,h)},reset(){s||(d.resetConversation(),d.emitter.emit("reset"))},destroy(){s||(s=!0,d.closeEventStream(),u.destroy(),ln(c.host),i&&a?Rs(a):Ms(l),d.emitter.emit("destroy"),d.emitter.removeAllListeners())},on(p,h){d.emitter.on(p,h)},off(p,h){d.emitter.off(p,h)},getState(){return d.getState()}};return f}var we=new Map,Zs=0;function Jt(e){const t=`agentkit-widget-${++Zs}`,r=e.destroy.bind(e);return e.destroy=()=>{we.delete(t),r()},we.set(t,e),t}function Os(e,t,r){const n={...e,mode:"floating"},a=dt(Ce(n),n,t,r);return Jt(a),a}function Fs(e,t,r,n){const a={...t,mode:"floating"},i=dt(Ce(a),a,r,n,e);return Jt(i),i}function Ps(e,t,r,n){const a={...t,mode:"inline"},i=dt(Ce(a),a,r,n,e);return Jt(i),i}function un(e){e?we.get(e)?.destroy():(we.forEach(t=>t.destroy()),we.clear())}function $s(){return Array.from(we.keys())}function fn(e){const{theme:t}=e,r=[`--ak-accent: ${t.accentColor}`,`--ak-font: ${t.fontFamily}`,`--ak-radius: ${t.borderRadius}`];return r.push(`--ak-accent-hover: color-mix(in srgb, ${t.accentColor} 85%, black)`),`:host { ${r.join("; ")} }`}function hn(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var pn=`
|
|
12
|
+
`,n)),r.onToolCallsStarted?.(f,h.activityMode),!1}if(h.type==="assistant_ack"){const f=h.text;return f&&r.onAck&&r.onAck(f),!1}if(h.type==="progress"){const f=h.stage,v=h.text,k=h.mode;return f&&v&&r.onProgress&&r.onProgress(f,v,k),!1}if(h.type==="tool_start"){const f=h.toolId,v=h.text,k=h.toolName,S=h.mode;return f&&v&&r.onToolStart&&r.onToolStart(f,v,k,S),!1}if(h.type==="tool_complete"){const f=h.toolId,v=h.text,k=h.durationMs,S=h.ok;return f&&v&&r.onToolComplete&&r.onToolComplete(f,v,k??0,S),!1}if(h.type==="model_start"||h.type==="final_meta"){if(h.type==="final_meta"&&r.onFinalMeta){const f=h.metrics;r.onFinalMeta(f??{},{mode:h.mode,collapseAfterFinal:h.collapseAfterFinal})}return!1}const p=bs(h);p&&(n+=p,r.onDelta(p,n))}catch(h){if(!(h instanceof SyntaxError))throw h}return!1};for await(const u of xs(s,ys))if(d(u))break;r.onEnd(n)}catch(s){r.onError(s instanceof Error?s:new Error(String(s)))}}function bs(e){const t=e.choices;if(Array.isArray(t)&&t.length>0){const n=t[0]?.delta,i=n?.content??n?.text??"";if(i)return i}const r=e.delta;if(r){const n=r.content??r.text??"";if(n)return n}const a=e.response;return a||(e.text??e.content??"")}function _s(e,t,r){const a=t*Math.pow(2,e-1),n=Math.min(a,r),i=n*.3;return Math.floor(n-i+Math.random()*(i*2))}async function ws(e,t,r,a={}){const n=await fetch(`${e}/v1/sessions/${encodeURIComponent(t)}/runs/${encodeURIComponent(r)}`,{credentials:a.preview?"include":"same-origin"});if(!n.ok)throw new Error(`Failed to fetch run ${r}: ${n.status}`);const i=await n.json();if(!i.success||!i.data)throw new Error(i.error??`Failed to fetch run ${r}`);return i.data}async function js(e,t,r,a={}){const n=a.maxAttempts??3;let i;for(let s=1;s<=n;s++){if(s>1){const l=_s(s-1,500,4e3);await new Promise(c=>setTimeout(c,l))}try{const l=await ws(e,t,r,a);if(l.status!=="running"||s===n)return l}catch(l){if(i=l instanceof Error?l:new Error(String(l)),s===n)throw i}}throw i??new Error(`Failed to fetch run ${r}`)}var ta=class{listeners=new Map;on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(...e){const[t,r]=e;this.listeners.get(t)?.forEach(a=>a(r))}removeAllListeners(){this.listeners.clear()}},Ss="agentforge";function Xt(e){return`${Ss}:session:${e}`}function ra(e){try{return sessionStorage.getItem(Xt(e))??void 0}catch{return}}function Ae(e,t){try{sessionStorage.setItem(Xt(e),t)}catch{}}function Vt(e){try{sessionStorage.removeItem(Xt(e))}catch{}}function gr(e,t){return e.map(r=>r.status==="active"&&r.stage!=="calling_tool"?{...r,status:"done",durationMs:r.durationMs??(r.startedAtMs?t-r.startedAtMs:void 0)}:r)}function Cs(e){const t=Date.now();return e.map(r=>r.status==="active"?{...r,status:"done",durationMs:r.durationMs??(r.startedAtMs?t-r.startedAtMs:void 0)}:r)}function ot(e){if(e==null||e<1e3)return null;if(e<1e4)return`${(e/1e3).toFixed(1)}s`;if(e<6e4)return`${Math.round(e/1e3)}s`;const t=Math.floor(e/6e4),r=Math.round(e%6e4/1e3);return r>0?`${t}m ${r}s`:`${t}m`}function be(){return`msg-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`}var aa=class{hostConfig;onStateChange;config;apiClient;state;fingerprint;eventSource=null;emitter;constructor(e,t,r){this.hostConfig=t,this.onStateChange=r,this.config=e,this.apiClient=new qr(e.apiBaseUrl,{preview:e.preview,configChannel:e.configChannel}),this.emitter=new ta,this.initializeFingerprint();const a=e.sessionId??ra(e.agentId);e.sessionId&&Ae(e.agentId,e.sessionId);const n=e.mode==="inline";this.state={isOpen:n,messages:[],isLoading:!1,error:null,sessionId:a,initStatus:"validating",initError:null},n&&queueMicrotask(()=>this.openWithGreeting())}reportError(e,t){try{fetch(`${this.config.apiBaseUrl.replace(/\/$/,"")}/v1/widget/errors`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e,stack:t?.stack,agentId:this.config.agentId,tenantId:this.config.tenantId,sessionId:this.state.sessionId??this.fingerprint,url:typeof location<"u"?location.href:void 0})}).catch(()=>{})}catch{}}async initializeFingerprint(){try{const e=await(await ks.load()).get();this.fingerprint=e.visitorId}catch{this.fingerprint=void 0}}getState(){return{...this.state,messages:[...this.state.messages]}}setOpen(e){e?this.openWithGreeting():this.setState({isOpen:!1})}openWithGreeting(){this.state.initStatus==="error"||this.state.initStatus==="disabled"||this.setState({isOpen:!0})}async hydrate(){const e=await this.apiClient.validateWidget(this.config.agentId,this.config.tenantId);if(!e.valid){if(e.code==="AGENT_DISABLED"){this.setState({initStatus:"disabled",initError:null});return}this.setState({initStatus:"error",initError:e.error});return}if(!this.config.skipServerConfigFetch){const a=await this.apiClient.fetchWidgetConfig(this.config.agentId,this.config.tenantId);a&&(this.config=Ie(this.hostConfig,a),this.onStateChange(this.getState(),this.config))}if(this.setState({initStatus:"ready"}),!this.state.sessionId)return;this.openEventStream();const t=await this.apiClient.fetchSessionMessages(this.state.sessionId,this.config.tenantId);if(t===null){this.handleSessionExpired();return}if(t.length===0)return;const r=t.map(a=>{const n=a.direction==="human",i=a.role==="user",s=i?(a.media??[]).map(l=>({url:l.url,mimeType:l.mimeType,fileName:l.fileName,kind:l.mimeType.startsWith("image/")?"image":"file"})):void 0;return{id:be(),role:a.role,content:a.content,images:!i&&a.images&&a.images.length>0?a.images:void 0,uploadedAttachments:s&&s.length>0?s:void 0,uploadedImageUrl:a.imageUrl||void 0,createdAt:a.createdAt??new Date().toISOString(),status:"sent",...n?{isHuman:!0,senderDisplay:a.senderDisplay??null}:{}}});this.setState({messages:[...this.state.messages,...r]})}openEventStream(){if(typeof EventSource>"u"||!this.state.sessionId||this.eventSource)return;const e=`${this.config.apiBaseUrl.replace(/\/$/,"")}/v1/sessions/${encodeURIComponent(this.state.sessionId)}/events`,t=new EventSource(e);t.onmessage=r=>{try{const a=JSON.parse(r.data);if(a.type==="control_mode"){const n=a.mode;this.setState({controlMode:n}),this.emitter.emit("control_mode_changed",{mode:n});return}if(a.type==="execution_state"){const n=a.state;n==="ai_thinking"||n==="ai_streaming"||n==="tool_running"?this.setState({isLoading:!0}):n==="idle"&&this.setState({isLoading:!1});return}if(a.type==="message"&&a.message&&typeof a.message=="object"){const n=a.message;if(typeof n.content!="string"||n.id&&this.state.messages.some(i=>i.id===n.id))return;if(n.direction==="human"){const i={id:n.id??be(),role:"assistant",content:n.content,createdAt:n.createdAt??new Date().toISOString(),status:"sent",isHuman:!0,senderDisplay:n.senderDisplay??null};this.setState({messages:[...this.state.messages,i],isLoading:!1}),this.emitter.emit("message:received",i);return}if(n.direction==="ai"){const i={id:n.id??be(),role:"assistant",content:n.content,createdAt:n.createdAt??new Date().toISOString(),status:"sent"};this.setState({messages:[...this.state.messages,i],isLoading:!1}),this.emitter.emit("message:received",i);return}}}catch{}},t.onerror=()=>{},this.eventSource=t}closeEventStream(){this.eventSource&&(this.eventSource.close(),this.eventSource=null)}setState(e){this.state={...this.state,...e},this.onStateChange(this.getState(),this.config)}updateMessage(e,t){this.state={...this.state,messages:this.state.messages.map(r=>r.id===e?{...r,...t}:r)},this.onStateChange(this.getState(),this.config)}async resetConversation(){if(this.state.sessionId)try{await this.apiClient.endSession(this.state.sessionId,this.config.tenantId,this.config.agentId,this.fingerprint,this.config.user.externalId,!0)}catch{}Vt(this.config.agentId),this.closeEventStream(),this.setState({sessionId:void 0,messages:[],isLoading:!1,error:null,controlMode:void 0}),this.emitter.emit("reset",void 0),this.state.isOpen&&this.openWithGreeting()}handleSessionExpired(){Vt(this.config.agentId),this.closeEventStream(),this.setState({sessionId:void 0,controlMode:void 0})}async sendMessage(e,t){const r=!!e.trim()||t&&t.length>0;if(this.state.isLoading||!r||this.state.initStatus!=="ready")return;const a=[];if(t&&t.length>0)for(const c of t)try{const d=await Ns(c.file);if(c.kind==="image"){const u=await this.apiClient.uploadImage(d,c.file.type,c.file.name,this.config.agentId,this.config.tenantId);a.push({url:u.url,mimeType:c.file.type,fileName:c.file.name,kind:"image"})}else{const u=await this.apiClient.uploadFile(d,c.file.type||"application/octet-stream",c.file.name,this.config.agentId,this.config.tenantId);a.push({url:u.url,mimeType:c.file.type||"application/octet-stream",fileName:c.file.name,kind:"file"})}}catch(d){const u=d instanceof Error?d.message:"Attachment upload failed";this.setState({error:u});return}const n=a.filter(c=>c.kind==="image"),i={id:be(),role:"user",content:e.trim(),uploadedImageUrl:n[0]?.url,uploadedAttachments:a.length>0?a:void 0,createdAt:new Date().toISOString(),status:"sent"},s=!this.state.messages.some(c=>c.role==="user");this.setState({messages:[...this.state.messages,i],isLoading:!0,error:null}),this.emitter.emit("message:sent",i),s&&this.emitter.emit("conversation:started",{sessionId:this.state.sessionId});const l=a.length>0?a:void 0;this.config.streaming?await this.sendStreaming(e.trim(),void 0,l):await this.sendNonStreaming(e.trim(),void 0,l)}async sendNonStreaming(e,t,r,a=!1){try{const n=await this.apiClient.chat({agentId:this.config.agentId,message:e,sessionId:this.state.sessionId,tenantId:this.config.tenantId,externalId:this.config.user.externalId,name:this.config.user.name,email:this.config.user.email,authId:this.config.user.authId,fingerprint:this.fingerprint,metadata:this.config.metadata,imageUrl:t,attachments:r});if(n.queued&&n.controlMode==="human"){this.setState({isLoading:!1,controlMode:"human_takeover",...n.sessionId?{sessionId:n.sessionId}:{}}),n.sessionId&&(Ae(this.config.agentId,n.sessionId),this.openEventStream());return}const i={id:be(),role:"assistant",content:n.content,images:n.images,documents:n.documents,createdAt:new Date().toISOString(),status:"sent"};this.setState({messages:[...this.state.messages,i],isLoading:!1,...n.sessionId?{sessionId:n.sessionId}:{}}),n.sessionId&&(Ae(this.config.agentId,n.sessionId),this.openEventStream()),this.emitter.emit("message:received",i)}catch(n){const i=n instanceof Error?n.message:"Failed to send message";if(!a&&i.includes("410"))return this.handleSessionExpired(),this.sendNonStreaming(e,t,r,!0);this.setState({isLoading:!1,error:i}),this.emitter.emit("message:error",{error:i,message:null}),this.reportError(i)}}async sendStreaming(e,t,r,a=!1){const n=be(),i={id:n,role:"assistant",content:"",createdAt:new Date().toISOString(),status:"streaming"};this.setState({messages:[...this.state.messages,i]}),this.emitter.emit("stream:start");let s=!1,l=!1,c=null,d=null,u=null;const h=Date.now();await ea(this.config.apiBaseUrl,{agentId:this.config.agentId,message:e,sessionId:this.state.sessionId,tenantId:this.config.tenantId,externalId:this.config.user.externalId,name:this.config.user.name,email:this.config.user.email,authId:this.config.user.authId,fingerprint:this.fingerprint,metadata:this.config.metadata,imageUrl:t,attachments:r},{onSession:p=>{this.setState({sessionId:p}),Ae(this.config.agentId,p),this.openEventStream()},onRunId:p=>{this.updateMessage(n,{runId:p})},onImages:p=>{this.updateMessage(n,{images:p})},onDocuments:p=>{this.updateMessage(n,{documents:p})},onToolCallsStarted:(p,f)=>{f&&d===null&&(d=f),(f??d)!=="off"&&this.updateMessage(n,{toolStatus:Is(p)})},onAck:p=>{this.updateMessage(n,{ackText:p})},onProgress:(p,f,v)=>{const k=this.state.messages.find(g=>g.id===n)?.progressEvents??[],S=Date.now();v&&d===null&&(d=v,this.updateMessage(n,{turnMeta:{totalMs:null,collapseAfterFinal:null,mode:v}})),this.updateMessage(n,{progressEvents:[...gr(k,S),{stage:p,text:f,timestamp:new Date().toISOString(),status:"active",startedAtMs:S}]})},onToolStart:(p,f,v,k)=>{const S=this.state.messages.find(C=>C.id===n)?.progressEvents??[],g=Date.now();k&&d===null&&(d=k,this.updateMessage(n,{turnMeta:{totalMs:null,collapseAfterFinal:null,mode:k}})),this.updateMessage(n,{progressEvents:[...gr(S,g),{stage:"calling_tool",toolId:p,toolName:v,text:f,timestamp:new Date().toISOString(),status:"active",startedAtMs:g}]})},onToolComplete:(p,f,v,k)=>{const S=this.state.messages.find(g=>g.id===n)?.progressEvents??[];this.updateMessage(n,{progressEvents:S.map(g=>g.stage==="calling_tool"&&g.status==="active"&&g.toolId===p?{...g,status:"done",text:f,durationMs:v,ok:k}:g)})},onFinalMeta:(p,f)=>{c=p.totalMs??null,d=f?.mode??d,u=f?.collapseAfterFinal??null},onDelta:(p,f)=>{f.trim()&&(this.updateMessage(n,{content:f,toolStatus:void 0}),this.emitter.emit("stream:delta",{delta:p,accumulated:f}))},onEnd:p=>{if(l){this.setState({messages:this.state.messages.filter(g=>g.id!==n),isLoading:!1,controlMode:"human_takeover"}),this.emitter.emit("stream:end",{content:""});return}const f=this.state.messages.find(g=>g.id===n),v=d==="detailed",k=v||d==="standard";this.updateMessage(n,{content:p,status:"sent",toolStatus:void 0,progressEvents:v&&f?.progressEvents?.length?Cs(f.progressEvents):void 0,progressCollapsed:v?u??!0:void 0,turnMeta:k?{totalMs:c??Date.now()-h,collapseAfterFinal:u,mode:d}:void 0}),this.setState({isLoading:!1}),this.emitter.emit("stream:end",{content:p});const S=this.state.messages.find(g=>g.id===n);S&&this.emitter.emit("message:received",S)},onControlMode:(p,f)=>{f&&p==="human"&&(l=!0)},onError:p=>{if(!a&&p.status===410){s=!0,this.setState({messages:this.state.messages.filter(g=>g.id!==n),isLoading:!1});return}const f=g=>{const C=this.state.messages.find(R=>R.id===n)?.content??"";this.updateMessage(n,{content:C||g,status:"error"}),this.setState({isLoading:!1,error:g}),this.emitter.emit("message:error",{error:g,message:null}),this.reportError(g,{stack:p.stack})},v=g=>{this.updateMessage(n,{content:g,status:"sent",toolStatus:void 0,progressEvents:void 0}),this.setState({isLoading:!1}),this.emitter.emit("stream:end",{content:g});const C=this.state.messages.find(R=>R.id===n);C&&this.emitter.emit("message:received",C)},k=this.state.messages.find(g=>g.id===n)?.runId,S=this.state.sessionId;if(k&&S){js(this.config.apiBaseUrl,S,k,{preview:this.config.preview}).then(g=>{g.status==="done"&&g.finalText?v(g.finalText):f(g.errorMessage||p.message||"Something went wrong. Please try again.")}).catch(()=>f(p.message||"Something went wrong. Please try again."));return}f(p.message||"Something went wrong. Please try again.")}},{preview:this.config.preview,configChannel:this.config.configChannel}),s&&(this.handleSessionExpired(),await this.sendStreaming(e,t,r,!0))}};function Is(e){const t=e[0];if(!t)return"Working...";const r=t.indexOf(".");return r>0?`Using ${t.slice(0,r).replace(/_/g," ")}: ${t.slice(r+1).replace(/_/g," ")}${e.length>1?` +${e.length-1}`:""}`:`Using ${t.replace(/_/g," ")}`}function Ns(e){return new Promise((t,r)=>{const a=new FileReader;a.onload=()=>{const n=a.result;t(n.split(",")[1]??"")},a.onerror=()=>r(new Error("Failed to read file")),a.readAsDataURL(e)})}function na(e){const t=document.createElement("div");t.setAttribute("data-agentkit-widget",""),e.appendChild(t);const r=t.attachShadow({mode:"open"}),a=document.createElement("style");r.appendChild(a);const n=document.createElement("div");return n.style.cssText="display: contents;",r.appendChild(n),{host:t,shadowRoot:r,styleSlot:a,mountPoint:n}}function ia(e,t){e.textContent=t}function sa(e){e.remove()}function oa(){const e=document.createElement("div");return e.setAttribute("data-agentkit-root","floating"),e.style.cssText=["position: fixed","bottom: 24px","right: 24px","z-index: 2147483647","pointer-events: none"].join("; "),document.body.appendChild(e),e}function Es(e){getComputedStyle(e).position==="static"&&(e.style.position="relative");const t=document.createElement("div");return t.setAttribute("data-agentkit-root","floating"),t.style.cssText=["position: absolute","bottom: 24px","right: 24px","z-index: 2147483647","pointer-events: none"].join("; "),e.appendChild(t),t}function la(e){return e.setAttribute("data-agentkit-root","inline"),getComputedStyle(e).position==="static"&&(e.style.position="relative"),e}function Ms(e){e.remove()}function Ls(e){e.removeAttribute("data-agentkit-root")}function dt(e,t,r,a,n){const i=e.mode==="inline";let s=!1;const l=i&&n?la(n):!i&&n?Es(n):oa(),c=na(l);ia(c.styleSlot,a);const d=new aa(e,t,(p,f)=>{s||u.update(p,f)}),u=r(c.mountPoint,e,d.getState(),{onOpen:()=>h.open(),onClose:()=>h.close(),onSendMessage:(p,f)=>{d.sendMessage(p,f)},onReset:()=>{d.resetConversation()}});d.hydrate(),setTimeout(()=>{s||d.emitter.emit("ready",d.getState())},0);const h={open(){s||(d.setOpen(!0),d.emitter.emit("open"))},close(){s||(d.setOpen(!1),d.emitter.emit("close"))},toggle(){d.getState().isOpen?h.close():h.open()},async sendMessage(p,f){await d.sendMessage(p,f)},reset(){s||(d.resetConversation(),d.emitter.emit("reset"))},destroy(){s||(s=!0,d.closeEventStream(),u.destroy(),sa(c.host),i&&n?Ls(n):Ms(l),d.emitter.emit("destroy"),d.emitter.removeAllListeners())},on(p,f){d.emitter.on(p,f)},off(p,f){d.emitter.off(p,f)},getState(){return d.getState()}};return h}var je=new Map,Ts=0;function Jt(e){const t=`agentkit-widget-${++Ts}`,r=e.destroy.bind(e);return e.destroy=()=>{je.delete(t),r()},je.set(t,e),t}function As(e,t,r){const a={...e,mode:"floating"},n=dt(Ie(a),a,t,r);return Jt(n),n}function Rs(e,t,r,a){const n={...t,mode:"floating"},i=dt(Ie(n),n,r,a,e);return Jt(i),i}function Zs(e,t,r,a){const n={...t,mode:"inline"},i=dt(Ie(n),n,r,a,e);return Jt(i),i}function ca(e){e?je.get(e)?.destroy():(je.forEach(t=>t.destroy()),je.clear())}function Os(){return Array.from(je.keys())}function da(e){const{theme:t}=e,r=[`--ak-accent: ${t.accentColor}`,`--ak-font: ${t.fontFamily}`,`--ak-radius: ${t.borderRadius}`];return r.push(`--ak-accent-hover: color-mix(in srgb, ${t.accentColor} 85%, black)`),`:host { ${r.join("; ")} }`}function ua(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var ha=`
|
|
13
13
|
*, *::before, *::after {
|
|
14
14
|
box-sizing: border-box;
|
|
15
15
|
margin: 0;
|
|
@@ -33,6 +33,11 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let En=requir
|
|
|
33
33
|
--ak-maintenance-halo: #fcd34d;
|
|
34
34
|
--ak-font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
35
35
|
--ak-radius: 12px;
|
|
36
|
+
/* Chat surface texture — scattered line doodles, tiled. Neutral stroke (not accent-tinted)
|
|
37
|
+
so it stays a texture rather than competing with brand colour. Alpha is baked into the
|
|
38
|
+
SVG stroke, so the light/dark variants differ only in stroke rgba. */
|
|
39
|
+
--ak-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220' fill='none' stroke='rgba(0,0,0,0.045)' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 30c5-8 14-8 19 0s14 8 19 0'/%3E%3Ccircle cx='96' cy='22' r='8'/%3E%3Cpath d='M150 34l6-11 6 11z'/%3E%3Cpath d='M196 18v14M189 25h14'/%3E%3Cpath d='M28 74h22M28 81h14'/%3E%3Cpath d='M84 68l8-8 8 8-8 8z'/%3E%3Cpath d='M186 76c0 7-6 12-13 12h-10l-6 6v-6c-5-1-8-6-8-12 0-7 6-12 13-12h11c7 0 13 5 13 12z'/%3E%3Ccircle cx='124' cy='104' r='5'/%3E%3Cpath d='M18 122c7-5 14-5 21 0'/%3E%3Cpath d='M62 132l7-13 7 13z'/%3E%3Cpath d='M106 156h20M106 163h12'/%3E%3Ccircle cx='176' cy='140' r='8'/%3E%3Cpath d='M32 170l6-6 6 6-6 6z'/%3E%3Cpath d='M148 196c5-7 13-7 18 0'/%3E%3Cpath d='M74 196v12M68 202h12'/%3E%3Ccircle cx='206' cy='178' r='4.5'/%3E%3Ccircle cx='58' cy='48' r='4'/%3E%3Cpath d='M128 56h16M128 62h10'/%3E%3Cpath d='M40 100l5-5 5 5-5 5z'/%3E%3Cpath d='M150 116c5-6 12-6 17 0'/%3E%3Ccircle cx='92' cy='128' r='4'/%3E%3Cpath d='M198 108v11M193 113h11'/%3E%3Cpath d='M8 148c5-7 12-7 17 0'/%3E%3Ccircle cx='142' cy='176' r='4'/%3E%3Cpath d='M76 166h16M76 172h9'/%3E%3Cpath d='M186 208l5-9 5 9z'/%3E%3Cpath d='M110 190l6-6 6 6-6 6z'/%3E%3Ccircle cx='46' cy='206' r='5'/%3E%3C/svg%3E");
|
|
40
|
+
--ak-pattern-size: 210px;
|
|
36
41
|
--ak-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 8px 24px rgba(0, 0, 0, 0.08);
|
|
37
42
|
--ak-launcher-size: 56px;
|
|
38
43
|
font-family: var(--ak-font);
|
|
@@ -49,6 +54,8 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let En=requir
|
|
|
49
54
|
--ak-border: #334155; /* slate-700 */
|
|
50
55
|
--ak-bot-bg: #1e293b; /* slate-800 — assistant bubble */
|
|
51
56
|
--ak-bot-text: #f1f5f9; /* slate-100 */
|
|
57
|
+
/* Same doodle tile, white stroke — dark surfaces need ~1.5x the alpha to read the same */
|
|
58
|
+
--ak-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220' fill='none' stroke='rgba(255,255,255,0.07)' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 30c5-8 14-8 19 0s14 8 19 0'/%3E%3Ccircle cx='96' cy='22' r='8'/%3E%3Cpath d='M150 34l6-11 6 11z'/%3E%3Cpath d='M196 18v14M189 25h14'/%3E%3Cpath d='M28 74h22M28 81h14'/%3E%3Cpath d='M84 68l8-8 8 8-8 8z'/%3E%3Cpath d='M186 76c0 7-6 12-13 12h-10l-6 6v-6c-5-1-8-6-8-12 0-7 6-12 13-12h11c7 0 13 5 13 12z'/%3E%3Ccircle cx='124' cy='104' r='5'/%3E%3Cpath d='M18 122c7-5 14-5 21 0'/%3E%3Cpath d='M62 132l7-13 7 13z'/%3E%3Cpath d='M106 156h20M106 163h12'/%3E%3Ccircle cx='176' cy='140' r='8'/%3E%3Cpath d='M32 170l6-6 6 6-6 6z'/%3E%3Cpath d='M148 196c5-7 13-7 18 0'/%3E%3Cpath d='M74 196v12M68 202h12'/%3E%3Ccircle cx='206' cy='178' r='4.5'/%3E%3Ccircle cx='58' cy='48' r='4'/%3E%3Cpath d='M128 56h16M128 62h10'/%3E%3Cpath d='M40 100l5-5 5 5-5 5z'/%3E%3Cpath d='M150 116c5-6 12-6 17 0'/%3E%3Ccircle cx='92' cy='128' r='4'/%3E%3Cpath d='M198 108v11M193 113h11'/%3E%3Cpath d='M8 148c5-7 12-7 17 0'/%3E%3Ccircle cx='142' cy='176' r='4'/%3E%3Cpath d='M76 166h16M76 172h9'/%3E%3Cpath d='M186 208l5-9 5 9z'/%3E%3Cpath d='M110 190l6-6 6 6-6 6z'/%3E%3Ccircle cx='46' cy='206' r='5'/%3E%3C/svg%3E");
|
|
52
59
|
--ak-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.4);
|
|
53
60
|
--ak-maintenance-fg: #fde68a;
|
|
54
61
|
--ak-maintenance-bg: rgba(253, 230, 138, 0.06);
|
|
@@ -364,6 +371,11 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let En=requir
|
|
|
364
371
|
gap: 10px;
|
|
365
372
|
scroll-behavior: smooth;
|
|
366
373
|
min-height: 0; /* Allow flex child to shrink below its content height */
|
|
374
|
+
/* Faint doodle texture so bubbles read as objects on a surface, not floating on flat colour.
|
|
375
|
+
background-attachment defaults to scroll = anchored to the padding box, so the
|
|
376
|
+
pattern stays put while messages scroll. */
|
|
377
|
+
background-image: var(--ak-pattern);
|
|
378
|
+
background-size: var(--ak-pattern-size) var(--ak-pattern-size);
|
|
367
379
|
}
|
|
368
380
|
.ak-messages::-webkit-scrollbar { width: 4px; }
|
|
369
381
|
.ak-messages::-webkit-scrollbar-track { background: transparent; }
|
|
@@ -386,10 +398,16 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let En=requir
|
|
|
386
398
|
overflow-y: auto;
|
|
387
399
|
overflow-x: hidden;
|
|
388
400
|
min-height: 0;
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
401
|
+
/* Glow layer is translucent so the same doodle texture as .ak-messages shows through —
|
|
402
|
+
keeps empty state and message list on one continuous surface. */
|
|
403
|
+
background-color: var(--ak-bg);
|
|
404
|
+
background-image:
|
|
405
|
+
radial-gradient(ellipse 110% 55% at 50% 0%,
|
|
406
|
+
color-mix(in srgb, var(--ak-accent) 10%, transparent),
|
|
407
|
+
transparent 72%
|
|
408
|
+
),
|
|
409
|
+
var(--ak-pattern);
|
|
410
|
+
background-size: auto, var(--ak-pattern-size) var(--ak-pattern-size);
|
|
393
411
|
}
|
|
394
412
|
/* Decorative blurred orb behind the avatar */
|
|
395
413
|
.ak-empty-state__glow {
|
|
@@ -1283,6 +1301,39 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let En=requir
|
|
|
1283
1301
|
.ak-cursor__dot:nth-child(2) { animation-delay: 0.2s; }
|
|
1284
1302
|
.ak-cursor__dot:nth-child(3) { animation-delay: 0.4s; }
|
|
1285
1303
|
|
|
1304
|
+
/* Pre-first-chunk wait — deliberately shares the metrics of .ak-progress__item
|
|
1305
|
+
and .ak-progress__summary so dots → activity line → summary never reflow. */
|
|
1306
|
+
.ak-typing-row {
|
|
1307
|
+
display: inline-flex;
|
|
1308
|
+
align-items: center;
|
|
1309
|
+
gap: 5px;
|
|
1310
|
+
padding: 2px 0;
|
|
1311
|
+
margin: 0 0 4px;
|
|
1312
|
+
/* One text line at the shared row metrics, so the dots occupy exactly the
|
|
1313
|
+
box the activity line and summary will occupy (border-box). */
|
|
1314
|
+
min-height: calc(0.76rem * 1.4 + 4px);
|
|
1315
|
+
animation: ak-msg-in 0.15s ease-out;
|
|
1316
|
+
}
|
|
1317
|
+
.ak-typing-row__dot {
|
|
1318
|
+
width: 6px;
|
|
1319
|
+
height: 6px;
|
|
1320
|
+
border-radius: 50%;
|
|
1321
|
+
background: var(--ak-bot-text);
|
|
1322
|
+
opacity: 0.5;
|
|
1323
|
+
animation: ak-bounce 1.3s infinite ease-in-out;
|
|
1324
|
+
}
|
|
1325
|
+
.ak-typing-row__dot:nth-child(2) { animation-delay: 0.2s; }
|
|
1326
|
+
.ak-typing-row__dot:nth-child(3) { animation-delay: 0.4s; }
|
|
1327
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1328
|
+
.ak-typing-row__dot,
|
|
1329
|
+
.ak-cursor__dot,
|
|
1330
|
+
.ak-typing__dot,
|
|
1331
|
+
.ak-progress__item--active,
|
|
1332
|
+
.ak-agent-status__icon {
|
|
1333
|
+
animation: none;
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1286
1337
|
/* ── Markdown rendering ──────────────────────────────────────── */
|
|
1287
1338
|
.ak-message__bubble--md {
|
|
1288
1339
|
white-space: normal;
|
|
@@ -1573,19 +1624,18 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let En=requir
|
|
|
1573
1624
|
}
|
|
1574
1625
|
|
|
1575
1626
|
/* ── Agent status indicator ──────────────────────────────────── */
|
|
1627
|
+
/* Same bare row as .ak-progress__item / .ak-typing-row — activity-off tenants
|
|
1628
|
+
see the tool status swap in without the surrounding box changing size. */
|
|
1576
1629
|
.ak-agent-status {
|
|
1577
1630
|
display: inline-flex;
|
|
1578
1631
|
align-items: center;
|
|
1579
|
-
gap:
|
|
1632
|
+
gap: 6px;
|
|
1580
1633
|
margin-bottom: 4px;
|
|
1581
|
-
padding:
|
|
1582
|
-
border-radius: 14px;
|
|
1583
|
-
background: var(--ak-bot-bg);
|
|
1584
|
-
border: 1px solid var(--ak-border);
|
|
1634
|
+
padding: 2px 0;
|
|
1585
1635
|
color: var(--ak-bot-text);
|
|
1586
|
-
font-size: 0.
|
|
1587
|
-
|
|
1588
|
-
opacity: 0.
|
|
1636
|
+
font-size: 0.76rem;
|
|
1637
|
+
line-height: 1.4;
|
|
1638
|
+
opacity: 0.6;
|
|
1589
1639
|
animation: ak-msg-in 0.15s ease-out;
|
|
1590
1640
|
}
|
|
1591
1641
|
.ak-agent-status__icon {
|
|
@@ -1594,7 +1644,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let En=requir
|
|
|
1594
1644
|
animation: ak-sparkle-pulse 2.5s ease-in-out infinite;
|
|
1595
1645
|
}
|
|
1596
1646
|
.ak-agent-status__text {
|
|
1597
|
-
line-height: 1;
|
|
1647
|
+
line-height: 1.4;
|
|
1598
1648
|
}
|
|
1599
1649
|
@keyframes ak-sparkle-pulse {
|
|
1600
1650
|
0%, 100% { opacity: 1; transform: scale(1) rotate(0deg); }
|
|
@@ -1661,9 +1711,8 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let En=requir
|
|
|
1661
1711
|
}
|
|
1662
1712
|
.ak-progress__toggle--collapsed:hover { opacity: 0.85; }
|
|
1663
1713
|
.ak-progress__text {
|
|
1664
|
-
font-size: 0.
|
|
1714
|
+
font-size: 0.76rem;
|
|
1665
1715
|
color: var(--ak-bot-text);
|
|
1666
|
-
opacity: 0.75;
|
|
1667
1716
|
line-height: 1.4;
|
|
1668
1717
|
margin: 0;
|
|
1669
1718
|
}
|
|
@@ -1673,18 +1722,17 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let En=requir
|
|
|
1673
1722
|
margin: 0 0 4px;
|
|
1674
1723
|
padding: 0;
|
|
1675
1724
|
}
|
|
1725
|
+
/* Bare row, not a pill — identical metrics to .ak-progress__summary so the
|
|
1726
|
+
live line and the post-turn "Worked for Ns" swap without a size change. */
|
|
1676
1727
|
.ak-progress__item {
|
|
1677
1728
|
display: flex;
|
|
1678
1729
|
align-items: center;
|
|
1679
|
-
gap:
|
|
1680
|
-
padding:
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
border: 1px solid var(--ak-border);
|
|
1684
|
-
font-size: 0.8rem;
|
|
1730
|
+
gap: 6px;
|
|
1731
|
+
padding: 2px 0;
|
|
1732
|
+
font-size: 0.76rem;
|
|
1733
|
+
line-height: 1.4;
|
|
1685
1734
|
color: var(--ak-bot-text);
|
|
1686
|
-
|
|
1687
|
-
opacity: 0.8;
|
|
1735
|
+
opacity: 0.6;
|
|
1688
1736
|
animation: ak-msg-in 0.15s ease-out;
|
|
1689
1737
|
}
|
|
1690
1738
|
.ak-progress__item--active {
|
|
@@ -1692,8 +1740,8 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let En=requir
|
|
|
1692
1740
|
animation: ak-msg-in 0.15s ease-out, ak-active-pulse 2s ease-in-out infinite;
|
|
1693
1741
|
}
|
|
1694
1742
|
@keyframes ak-active-pulse {
|
|
1695
|
-
0%, 100% { opacity: 0.
|
|
1696
|
-
50% { opacity:
|
|
1743
|
+
0%, 100% { opacity: 0.6; }
|
|
1744
|
+
50% { opacity: 0.9; }
|
|
1697
1745
|
}
|
|
1698
1746
|
/* Claude-style step list (detailed mode) */
|
|
1699
1747
|
.ak-progress__steps {
|
|
@@ -1736,6 +1784,9 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let En=requir
|
|
|
1736
1784
|
gap: 6px;
|
|
1737
1785
|
padding: 2px 0;
|
|
1738
1786
|
margin: 0 0 4px;
|
|
1787
|
+
/* Shrink-to-fit as a column flex item would otherwise break "Worked for 8.4s"
|
|
1788
|
+
onto two lines, doubling the row height as the turn ends. */
|
|
1789
|
+
white-space: nowrap;
|
|
1739
1790
|
border: none;
|
|
1740
1791
|
background: transparent;
|
|
1741
1792
|
font-size: 0.76rem;
|
|
@@ -1850,11 +1901,11 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let En=requir
|
|
|
1850
1901
|
display: none;
|
|
1851
1902
|
}
|
|
1852
1903
|
}
|
|
1853
|
-
`;function Ws(){return(0,o.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),(0,o.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,o.jsx)("path",{d:"M12 7v4"}),(0,o.jsx)("line",{x1:"8",y1:"16",x2:"8",y2:"16"}),(0,o.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"16"})]})}function Vs(){return(0,o.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[(0,o.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,o.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Ds(){return(0,o.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,o.jsx)("path",{d:"M3 3v5h5"})]})}function mn({title:e,subtitle:t,avatarUrl:r,onClose:n,onReset:a,hideClose:i=!1}){const[s,l]=(0,L.useState)(!1);return(0,o.jsxs)("div",{className:`ak-header${s?" ak-header--confirming":""}`,children:[(0,o.jsxs)("div",{className:"ak-header__row",children:[r?(0,o.jsx)("img",{src:r,alt:"",className:"ak-header__avatar","aria-hidden":"true"}):(0,o.jsx)("span",{className:"ak-header__bot-icon","aria-hidden":"true",children:(0,o.jsx)(Ws,{})}),(0,o.jsxs)("div",{className:"ak-header__title-group",children:[(0,o.jsx)("span",{className:"ak-header__title",children:e}),t&&(0,o.jsx)("span",{className:"ak-header__subtitle",children:t})]}),(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,o.jsx)("span",{className:"ak-header__status","aria-hidden":"true"}),a&&(0,o.jsx)("button",{className:`ak-header__button${s?" ak-header__button--active":""}`,onClick:()=>l(!0),"aria-label":"New conversation",type:"button",title:"Start a new conversation (Retains current conversation to memory)",children:(0,o.jsx)(Ds,{})}),!i&&(0,o.jsx)("button",{className:"ak-header__close",onClick:n,"aria-label":"Close chat",type:"button",children:(0,o.jsx)(Vs,{})})]})]}),s&&(0,o.jsxs)("div",{className:"ak-header__confirm",role:"alert",children:[(0,o.jsxs)("div",{className:"ak-header__confirm-text",children:[(0,o.jsx)("span",{className:"ak-header__confirm-title",children:"End this conversation?"}),(0,o.jsx)("span",{className:"ak-header__confirm-sub",children:"All messages will be removed"})]}),(0,o.jsxs)("div",{className:"ak-header__confirm-actions",children:[(0,o.jsx)("button",{className:"ak-header__confirm-cancel",type:"button",onClick:()=>l(!1),children:"Cancel"}),(0,o.jsx)("button",{className:"ak-header__confirm-ok",type:"button",onClick:()=>{a?.(),l(!1)},children:"End chat"})]})]})]})}function Oe(e){if(!e)return null;const t=e.trim();if(!t)return null;if(/^(\/|\.{1,2}\/|#|\?)/.test(t))return t;const r=/^([a-z][a-z0-9+.-]*):/i.exec(t)?.[1]?.toLowerCase();return r?["http","https","mailto","tel"].includes(r)?t:null:t}function gn(e){const[,t]=(0,L.useState)(0);(0,L.useEffect)(()=>{if(!e)return;const r=setInterval(()=>t(n=>n+1),1e3);return()=>clearInterval(r)},[e])}var zs=800;function Us({up:e}){return(0,o.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,o.jsx)("polyline",{points:e?"18 15 12 9 6 15":"6 9 12 15 18 9"})})}function lt({event:e,active:t}){return t?(0,o.jsx)("span",{className:"ak-progress__spinner","aria-hidden":"true"}):(0,o.jsx)("svg",{className:e.ok===!1?"ak-progress__step-icon ak-progress__step-icon--fail":"ak-progress__step-icon",width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.ok===!1?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,o.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}):(0,o.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function xr({events:e,live:t}){gn(t&&e.some(i=>i.status==="active"));const r=Date.now(),n=e[0]?.startedAtMs,a=e.reduce((i,s,l)=>s.status==="active"?l:i,-1);return(0,o.jsx)("ul",{className:"ak-progress__steps",role:"list",children:e.map((i,s)=>{const l=t&&i.status==="active",c=l&&s===a?ot(n?r-n:void 0):l?null:ot(i.durationMs);return(0,o.jsxs)("li",{className:l?"ak-progress__step ak-progress__step--active":"ak-progress__step",children:[(0,o.jsx)(lt,{event:i,active:l}),(0,o.jsx)("span",{className:"ak-progress__step-text",children:i.text}),c&&(0,o.jsxs)("span",{className:"ak-progress__step-dur",children:["· ",c]})]},`${i.toolId??i.stage}-${s}`)})})}function Bs({events:e}){const[t,r]=(0,L.useState)(0),n=Math.min(t,e.length-1),a=n<e.length-1;(0,L.useEffect)(()=>{if(!a)return;const d=setTimeout(()=>r(u=>Math.min(u+1,e.length-1)),zs);return()=>clearTimeout(d)},[a,n,e.length]);const i=e[n],s=!a&&i.status==="done";gn(!s);const l=e[0]?.startedAtMs,c=s?null:ot(l?Date.now()-l:void 0);return(0,o.jsx)("ul",{className:"ak-progress__list",role:"list",children:(0,o.jsxs)("li",{className:"ak-progress__item ak-progress__item--active",children:[s?(0,o.jsx)(lt,{event:i,active:!1}):(0,o.jsx)("span",{className:"ak-progress__spinner","aria-hidden":"true"}),(0,o.jsx)("span",{className:"ak-progress__text",children:i.text}),c&&(0,o.jsxs)("span",{className:"ak-progress__step-dur",children:["· ",c]})]})})}function Gs({ackText:e,events:t=[],collapsed:r=!0,isComplete:n=!1,turnMeta:a}){const[i,s]=(0,L.useState)(!r);(0,L.useEffect)(()=>{n&&s(!r)},[n]);const l=a?.mode;if(!n)return t.length===0?e?(0,o.jsx)("ul",{className:"ak-progress__list",role:"list",children:(0,o.jsxs)("li",{className:"ak-progress__item ak-progress__item--active",children:[(0,o.jsx)("span",{className:"ak-progress__spinner","aria-hidden":"true"}),(0,o.jsx)("span",{className:"ak-progress__text",children:e})]})}):null:l==="detailed"?(0,o.jsx)(xr,{events:t,live:!0}):(0,o.jsx)(Bs,{events:t});const c=ot(a?.totalMs),d=c?`Worked for ${c}`:"Finished working";return l==="detailed"&&t.length>0?(0,o.jsxs)("div",{className:"ak-progress",children:[(0,o.jsxs)("button",{type:"button",onClick:()=>s(u=>!u),className:"ak-progress__summary","aria-expanded":i,"aria-label":i?"Hide working steps":"Show working steps",children:[(0,o.jsx)(lt,{event:{stage:"",text:"",timestamp:"",status:"done"},active:!1}),(0,o.jsx)("span",{children:d}),(0,o.jsxs)("span",{className:"ak-progress__step-dur",children:["· ",t.length," step",t.length===1?"":"s"]}),(0,o.jsx)(Us,{up:i})]}),i&&(0,o.jsx)(xr,{events:t,live:!1})]}):l==="standard"&&a?(0,o.jsx)("div",{className:"ak-progress",children:(0,o.jsxs)("p",{className:"ak-progress__summary ak-progress__summary--static",children:[(0,o.jsx)(lt,{event:{stage:"",text:"",timestamp:"",status:"done"},active:!1}),(0,o.jsx)("span",{children:d})]})}):null}function Hs(){return(0,o.jsx)("svg",{className:"ak-agent-status__icon",width:"13",height:"13",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{d:"M12 2C12 2 12.7 8.1 14.5 9.5C16.3 10.9 22 12 22 12C22 12 16.3 13.1 14.5 14.5C12.7 15.9 12 22 12 22C12 22 11.3 15.9 9.5 14.5C7.7 13.1 2 12 2 12C2 12 7.7 10.9 9.5 9.5C11.3 8.1 12 2 12 2Z"})})}function Ys({status:e}){return(0,o.jsxs)("div",{className:"ak-agent-status",role:"status","aria-live":"polite",children:[(0,o.jsx)(Hs,{}),(0,o.jsx)("span",{className:"ak-agent-status__text",children:e})]})}function kr({messageId:e,images:t,onCellClick:r}){if(t.length===0)return null;const n=t.length;if(n===1){const s=t[0];return(0,o.jsxs)("div",{className:"ak-gallery ak-gallery--single",children:[(0,o.jsx)("button",{type:"button",onClick:()=>r(0),className:"ak-gallery__cell ak-gallery__cell--hero","aria-label":"Open image preview",children:(0,o.jsx)("img",{src:s.src,alt:s.alt,className:"ak-gallery__img ak-gallery__img--contain"})}),(0,o.jsx)("a",{href:Oe(s.downloadHref)??void 0,download:!0,className:"ak-message__image-dl-icon",title:"Download image",onClick:l=>l.stopPropagation(),children:(0,o.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,o.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,o.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})})]})}if(n===2)return(0,o.jsx)("div",{className:"ak-gallery ak-gallery--two",children:t.map((s,l)=>(0,o.jsx)(Te,{src:s.src,alt:s.alt,onClick:()=>r(l)},s.key??`${e}-${l}`))});if(n===3)return(0,o.jsxs)("div",{className:"ak-gallery ak-gallery--three",children:[(0,o.jsx)(Te,{src:t[0].src,alt:t[0].alt,onClick:()=>r(0)},t[0].key??`${e}-0`),(0,o.jsxs)("div",{className:"ak-gallery__col",children:[(0,o.jsx)(Te,{src:t[1].src,alt:t[1].alt,onClick:()=>r(1)},t[1].key??`${e}-1`),(0,o.jsx)(Te,{src:t[2].src,alt:t[2].alt,onClick:()=>r(2)},t[2].key??`${e}-2`)]})]});const a=t.slice(0,4),i=n>4?n-4:0;return(0,o.jsx)("div",{className:"ak-gallery ak-gallery--grid",children:a.map((s,l)=>{const c=l===a.length-1;return(0,o.jsx)(Te,{src:s.src,alt:s.alt,overlayCount:c&&i>0?i:0,onClick:()=>r(l)},s.key??`${e}-${l}`)})})}function Te({src:e,alt:t,overlayCount:r=0,onClick:n}){return(0,o.jsxs)("button",{type:"button",onClick:n,className:"ak-gallery__cell","aria-label":"Open image preview",children:[(0,o.jsx)("img",{src:e,alt:t,className:"ak-gallery__img",loading:"lazy"}),r>0&&(0,o.jsxs)("span",{className:"ak-gallery__overlay",children:["+",r]})]})}function yr({images:e,index:t,onClose:r,onIndexChange:n}){const a=t!==null,i=a&&t!==null?Math.min(Math.max(0,t),e.length-1):0,s=a?e[i]:null;return(0,L.useEffect)(()=>{if(!a)return;const l=c=>{c.key==="Escape"?(c.stopPropagation(),r()):c.key==="ArrowLeft"&&e.length>1?(c.preventDefault(),n((i-1+e.length)%e.length)):c.key==="ArrowRight"&&e.length>1&&(c.preventDefault(),n((i+1)%e.length))};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[a,i,e.length,r,n]),!a||!s?null:(0,o.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":"Image preview",className:"ak-lightbox",onClick:r,children:[(0,o.jsxs)("div",{className:"ak-lightbox__toolbar",onClick:l=>l.stopPropagation(),children:[e.length>1&&(0,o.jsxs)("span",{className:"ak-lightbox__counter",children:[i+1," / ",e.length]}),(0,o.jsx)("a",{href:Oe(s.downloadHref)??void 0,download:!0,target:"_blank",rel:"noopener noreferrer",className:"ak-lightbox__btn",title:"Download image","aria-label":"Download image",children:(0,o.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,o.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,o.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),(0,o.jsx)("button",{type:"button",onClick:r,className:"ak-lightbox__btn",title:"Close","aria-label":"Close image preview",children:(0,o.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,o.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.length>1&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("button",{type:"button",onClick:l=>{l.stopPropagation(),n((i-1+e.length)%e.length)},className:"ak-lightbox__nav ak-lightbox__nav--prev","aria-label":"Previous image",children:(0,o.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,o.jsx)("polyline",{points:"15 18 9 12 15 6"})})}),(0,o.jsx)("button",{type:"button",onClick:l=>{l.stopPropagation(),n((i+1)%e.length)},className:"ak-lightbox__nav ak-lightbox__nav--next","aria-label":"Next image",children:(0,o.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,o.jsx)("polyline",{points:"9 18 15 12 9 6"})})})]}),(0,o.jsx)("img",{src:s.src,alt:s.alt??"Image preview",className:"ak-lightbox__img",onClick:l=>l.stopPropagation()})]})}function br({url:e,mimeType:t,fileName:r}){const n=(()=>{if(r)return r;try{const s=new URL(e).pathname.split("/");return(s[s.length-1]||"attachment").replace(/^\d{10,}-/,"")}catch{return"attachment"}})(),a=n.split(".").pop()?.toUpperCase()??"",i=t==="application/pdf"||a==="PDF"?{variant:"pdf",label:"PDF"}:t==="text/csv"||a==="CSV"?{variant:"csv",label:"CSV"}:t==="text/markdown"||a==="MD"?{variant:"md",label:"MD"}:t==="text/plain"||a==="TXT"?{variant:"txt",label:"TXT"}:{variant:"default",label:a||"FILE"};return(0,o.jsxs)("a",{href:Oe(e)??void 0,target:"_blank",rel:"noopener noreferrer",className:"ak-file-chip",title:n,children:[(0,o.jsx)("span",{className:`ak-file-chip__icon ak-file-chip__icon--${i.variant}`,"aria-hidden":!0,children:(0,o.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,o.jsx)("polyline",{points:"14 2 14 8 20 8"})]})}),(0,o.jsxs)("span",{className:"ak-file-chip__body",children:[(0,o.jsx)("span",{className:"ak-file-chip__name",children:n}),(0,o.jsx)("span",{className:"ak-file-chip__label",children:i.label})]})]})}function Xs(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}var _r=/(`[^`\n]+`|\*\*[^*\n]+\*\*|\*[^*\n]+\*|!\[[^\]\n]*\]\([^)\n]+\)|\[[^\]\n]+\]\([^)\n]+\))/g;function H(e){const t=[];let r=0,n=0;_r.lastIndex=0;let a;for(;(a=_r.exec(e))!==null;){a.index>r&&t.push(e.slice(r,a.index));const i=a[0];if(i.startsWith("`"))t.push((0,o.jsx)("code",{className:"ak-md-ic",children:i.slice(1,-1)},n++));else if(i.startsWith("**"))t.push((0,o.jsx)("strong",{children:i.slice(2,-2)},n++));else if(i.startsWith("*"))t.push((0,o.jsx)("em",{children:i.slice(1,-1)},n++));else if(i.startsWith("![")){const s=i.match(/!\[([^\]]*)\]\(([^)]+)\)/),l=Oe(s?.[2]);s&&l?t.push((0,o.jsx)("a",{href:l,target:"_blank",rel:"noopener noreferrer",children:s[1]||"image"},n++)):s&&t.push(s[1]||"image")}else{const s=i.match(/\[(.+?)\]\((.+?)\)/),l=Oe(s?.[2]);s&&l?t.push((0,o.jsx)("a",{href:l,target:"_blank",rel:"noopener noreferrer",children:s[1]},n++)):s?t.push(s[1]):t.push(i)}r=a.index+i.length}return r<e.length&&t.push(e.slice(r)),t}function Js(e){e=e.replace(/\\text\{([^}]*)\}/g,"$1").replace(/\\implies/g,"→").replace(/\\Rightarrow/g,"⟹").replace(/\\times/g,"×").replace(/\\div/g,"÷").replace(/\\cdot/g,"·").replace(/\\quad/g," ").replace(/\\qquad/g," ").replace(/\\leq/g,"≤").replace(/\\geq/g,"≥").replace(/\\neq/g,"≠").replace(/\\approx/g,"≈").replace(/\\infty/g,"∞").replace(/\\\((.+?)\\\)/gs,"$1").replace(/\\\[[\s\S]+?\\\]/g,"").replace(/\\\$/g,"\0DOLLAR\0").replace(/\$\$[\s\S]+?\$\$/g,"").replace(/\$([^$]+)\$/g,"$1").replace(/\x00DOLLAR\x00/g,"$").replace(/\\[a-zA-Z]+\*?/g,"").replace(/\n{3,}/g,`
|
|
1904
|
+
`;function Fs(){return(0,o.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),(0,o.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,o.jsx)("path",{d:"M12 7v4"}),(0,o.jsx)("line",{x1:"8",y1:"16",x2:"8",y2:"16"}),(0,o.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"16"})]})}function Ps(){return(0,o.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[(0,o.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,o.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Ws(){return(0,o.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,o.jsx)("path",{d:"M3 3v5h5"})]})}function fa({title:e,subtitle:t,avatarUrl:r,onClose:a,onReset:n,hideClose:i=!1}){const[s,l]=(0,E.useState)(!1);return(0,o.jsxs)("div",{className:`ak-header${s?" ak-header--confirming":""}`,children:[(0,o.jsxs)("div",{className:"ak-header__row",children:[r?(0,o.jsx)("img",{src:r,alt:"",className:"ak-header__avatar","aria-hidden":"true"}):(0,o.jsx)("span",{className:"ak-header__bot-icon","aria-hidden":"true",children:(0,o.jsx)(Fs,{})}),(0,o.jsxs)("div",{className:"ak-header__title-group",children:[(0,o.jsx)("span",{className:"ak-header__title",children:e}),t&&(0,o.jsx)("span",{className:"ak-header__subtitle",children:t})]}),(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,o.jsx)("span",{className:"ak-header__status","aria-hidden":"true"}),n&&(0,o.jsx)("button",{className:`ak-header__button${s?" ak-header__button--active":""}`,onClick:()=>l(!0),"aria-label":"New conversation",type:"button",title:"Start a new conversation (Retains current conversation to memory)",children:(0,o.jsx)(Ws,{})}),!i&&(0,o.jsx)("button",{className:"ak-header__close",onClick:a,"aria-label":"Close chat",type:"button",children:(0,o.jsx)(Ps,{})})]})]}),s&&(0,o.jsxs)("div",{className:"ak-header__confirm",role:"alert",children:[(0,o.jsxs)("div",{className:"ak-header__confirm-text",children:[(0,o.jsx)("span",{className:"ak-header__confirm-title",children:"End this conversation?"}),(0,o.jsx)("span",{className:"ak-header__confirm-sub",children:"All messages will be removed"})]}),(0,o.jsxs)("div",{className:"ak-header__confirm-actions",children:[(0,o.jsx)("button",{className:"ak-header__confirm-cancel",type:"button",onClick:()=>l(!1),children:"Cancel"}),(0,o.jsx)("button",{className:"ak-header__confirm-ok",type:"button",onClick:()=>{n?.(),l(!1)},children:"End chat"})]})]})]})}function Fe(e){if(!e)return null;const t=e.trim();if(!t)return null;if(/^(\/|\.{1,2}\/|#|\?)/.test(t))return t;const r=/^([a-z][a-z0-9+.-]*):/i.exec(t)?.[1]?.toLowerCase();return r?["http","https","mailto","tel"].includes(r)?t:null:t}function pa(e){const[,t]=(0,E.useState)(0);(0,E.useEffect)(()=>{if(!e)return;const r=setInterval(()=>t(a=>a+1),1e3);return()=>clearInterval(r)},[e])}var $s=800;function Vs({up:e}){return(0,o.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,o.jsx)("polyline",{points:e?"18 15 12 9 6 15":"6 9 12 15 18 9"})})}function lt({event:e,active:t}){return t?(0,o.jsx)("span",{className:"ak-progress__spinner","aria-hidden":"true"}):(0,o.jsx)("svg",{className:e.ok===!1?"ak-progress__step-icon ak-progress__step-icon--fail":"ak-progress__step-icon",width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.ok===!1?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,o.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}):(0,o.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function vr({events:e,live:t}){pa(t&&e.some(i=>i.status==="active"));const r=Date.now(),a=e[0]?.startedAtMs,n=e.reduce((i,s,l)=>s.status==="active"?l:i,-1);return(0,o.jsx)("ul",{className:"ak-progress__steps",role:"list",children:e.map((i,s)=>{const l=t&&i.status==="active",c=l&&s===n?ot(a?r-a:void 0):l?null:ot(i.durationMs);return(0,o.jsxs)("li",{className:l?"ak-progress__step ak-progress__step--active":"ak-progress__step",children:[(0,o.jsx)(lt,{event:i,active:l}),(0,o.jsx)("span",{className:"ak-progress__step-text",children:i.text}),c&&(0,o.jsxs)("span",{className:"ak-progress__step-dur",children:["· ",c]})]},`${i.toolId??i.stage}-${s}`)})})}function zs({events:e}){const[t,r]=(0,E.useState)(0),a=Math.min(t,e.length-1),n=a<e.length-1;(0,E.useEffect)(()=>{if(!n)return;const d=setTimeout(()=>r(u=>Math.min(u+1,e.length-1)),$s);return()=>clearTimeout(d)},[n,a,e.length]);const i=e[a],s=!n&&i.status==="done";pa(!s);const l=e[0]?.startedAtMs,c=s?null:ot(l?Date.now()-l:void 0);return(0,o.jsx)("ul",{className:"ak-progress__list",role:"list",children:(0,o.jsxs)("li",{className:"ak-progress__item ak-progress__item--active",children:[s?(0,o.jsx)(lt,{event:i,active:!1}):(0,o.jsx)("span",{className:"ak-progress__spinner","aria-hidden":"true"}),(0,o.jsx)("span",{className:"ak-progress__text",children:i.text}),c&&(0,o.jsxs)("span",{className:"ak-progress__step-dur",children:["· ",c]})]})})}function Ds({ackText:e,events:t=[],collapsed:r=!0,isComplete:a=!1,turnMeta:n}){const[i,s]=(0,E.useState)(!r);(0,E.useEffect)(()=>{a&&s(!r)},[a]);const l=n?.mode;if(!a)return t.length===0?e?(0,o.jsx)("ul",{className:"ak-progress__list",role:"list",children:(0,o.jsxs)("li",{className:"ak-progress__item ak-progress__item--active",children:[(0,o.jsx)("span",{className:"ak-progress__spinner","aria-hidden":"true"}),(0,o.jsx)("span",{className:"ak-progress__text",children:e})]})}):null:l==="detailed"?(0,o.jsx)(vr,{events:t,live:!0}):(0,o.jsx)(zs,{events:t});const c=ot(n?.totalMs),d=c?`Worked for ${c}`:"Finished working";return l==="detailed"&&t.length>0?(0,o.jsxs)("div",{className:"ak-progress",children:[(0,o.jsxs)("button",{type:"button",onClick:()=>s(u=>!u),className:"ak-progress__summary","aria-expanded":i,"aria-label":i?"Hide working steps":"Show working steps",children:[(0,o.jsx)(lt,{event:{stage:"",text:"",timestamp:"",status:"done"},active:!1}),(0,o.jsx)("span",{children:d}),(0,o.jsxs)("span",{className:"ak-progress__step-dur",children:["· ",t.length," step",t.length===1?"":"s"]}),(0,o.jsx)(Vs,{up:i})]}),i&&(0,o.jsx)(vr,{events:t,live:!1})]}):l==="standard"&&n?(0,o.jsx)("div",{className:"ak-progress",children:(0,o.jsxs)("p",{className:"ak-progress__summary ak-progress__summary--static",children:[(0,o.jsx)(lt,{event:{stage:"",text:"",timestamp:"",status:"done"},active:!1}),(0,o.jsx)("span",{children:d})]})}):null}function Us(){return(0,o.jsx)("svg",{className:"ak-agent-status__icon",width:"13",height:"13",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{d:"M12 2C12 2 12.7 8.1 14.5 9.5C16.3 10.9 22 12 22 12C22 12 16.3 13.1 14.5 14.5C12.7 15.9 12 22 12 22C12 22 11.3 15.9 9.5 14.5C7.7 13.1 2 12 2 12C2 12 7.7 10.9 9.5 9.5C11.3 8.1 12 2 12 2Z"})})}function Bs({status:e}){return(0,o.jsxs)("div",{className:"ak-agent-status",role:"status","aria-live":"polite",children:[(0,o.jsx)(Us,{}),(0,o.jsx)("span",{className:"ak-agent-status__text",children:e})]})}function kr({messageId:e,images:t,onCellClick:r}){if(t.length===0)return null;const a=t.length;if(a===1){const s=t[0];return(0,o.jsxs)("div",{className:"ak-gallery ak-gallery--single",children:[(0,o.jsx)("button",{type:"button",onClick:()=>r(0),className:"ak-gallery__cell ak-gallery__cell--hero","aria-label":"Open image preview",children:(0,o.jsx)("img",{src:s.src,alt:s.alt,className:"ak-gallery__img ak-gallery__img--contain"})}),(0,o.jsx)("a",{href:Fe(s.downloadHref)??void 0,download:!0,className:"ak-message__image-dl-icon",title:"Download image",onClick:l=>l.stopPropagation(),children:(0,o.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,o.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,o.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})})]})}if(a===2)return(0,o.jsx)("div",{className:"ak-gallery ak-gallery--two",children:t.map((s,l)=>(0,o.jsx)(Me,{src:s.src,alt:s.alt,onClick:()=>r(l)},s.key??`${e}-${l}`))});if(a===3)return(0,o.jsxs)("div",{className:"ak-gallery ak-gallery--three",children:[(0,o.jsx)(Me,{src:t[0].src,alt:t[0].alt,onClick:()=>r(0)},t[0].key??`${e}-0`),(0,o.jsxs)("div",{className:"ak-gallery__col",children:[(0,o.jsx)(Me,{src:t[1].src,alt:t[1].alt,onClick:()=>r(1)},t[1].key??`${e}-1`),(0,o.jsx)(Me,{src:t[2].src,alt:t[2].alt,onClick:()=>r(2)},t[2].key??`${e}-2`)]})]});const n=t.slice(0,4),i=a>4?a-4:0;return(0,o.jsx)("div",{className:"ak-gallery ak-gallery--grid",children:n.map((s,l)=>{const c=l===n.length-1;return(0,o.jsx)(Me,{src:s.src,alt:s.alt,overlayCount:c&&i>0?i:0,onClick:()=>r(l)},s.key??`${e}-${l}`)})})}function Me({src:e,alt:t,overlayCount:r=0,onClick:a}){return(0,o.jsxs)("button",{type:"button",onClick:a,className:"ak-gallery__cell","aria-label":"Open image preview",children:[(0,o.jsx)("img",{src:e,alt:t,className:"ak-gallery__img",loading:"lazy"}),r>0&&(0,o.jsxs)("span",{className:"ak-gallery__overlay",children:["+",r]})]})}function xr({images:e,index:t,onClose:r,onIndexChange:a}){const n=t!==null,i=n&&t!==null?Math.min(Math.max(0,t),e.length-1):0,s=n?e[i]:null;return(0,E.useEffect)(()=>{if(!n)return;const l=c=>{c.key==="Escape"?(c.stopPropagation(),r()):c.key==="ArrowLeft"&&e.length>1?(c.preventDefault(),a((i-1+e.length)%e.length)):c.key==="ArrowRight"&&e.length>1&&(c.preventDefault(),a((i+1)%e.length))};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[n,i,e.length,r,a]),!n||!s?null:(0,o.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":"Image preview",className:"ak-lightbox",onClick:r,children:[(0,o.jsxs)("div",{className:"ak-lightbox__toolbar",onClick:l=>l.stopPropagation(),children:[e.length>1&&(0,o.jsxs)("span",{className:"ak-lightbox__counter",children:[i+1," / ",e.length]}),(0,o.jsx)("a",{href:Fe(s.downloadHref)??void 0,download:!0,target:"_blank",rel:"noopener noreferrer",className:"ak-lightbox__btn",title:"Download image","aria-label":"Download image",children:(0,o.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,o.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,o.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),(0,o.jsx)("button",{type:"button",onClick:r,className:"ak-lightbox__btn",title:"Close","aria-label":"Close image preview",children:(0,o.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,o.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.length>1&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("button",{type:"button",onClick:l=>{l.stopPropagation(),a((i-1+e.length)%e.length)},className:"ak-lightbox__nav ak-lightbox__nav--prev","aria-label":"Previous image",children:(0,o.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,o.jsx)("polyline",{points:"15 18 9 12 15 6"})})}),(0,o.jsx)("button",{type:"button",onClick:l=>{l.stopPropagation(),a((i+1)%e.length)},className:"ak-lightbox__nav ak-lightbox__nav--next","aria-label":"Next image",children:(0,o.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,o.jsx)("polyline",{points:"9 18 15 12 9 6"})})})]}),(0,o.jsx)("img",{src:s.src,alt:s.alt??"Image preview",className:"ak-lightbox__img",onClick:l=>l.stopPropagation()})]})}function yr({url:e,mimeType:t,fileName:r}){const a=(()=>{if(r)return r;try{const s=new URL(e).pathname.split("/");return(s[s.length-1]||"attachment").replace(/^\d{10,}-/,"")}catch{return"attachment"}})(),n=a.split(".").pop()?.toUpperCase()??"",i=t==="application/pdf"||n==="PDF"?{variant:"pdf",label:"PDF"}:t==="text/csv"||n==="CSV"?{variant:"csv",label:"CSV"}:t==="text/markdown"||n==="MD"?{variant:"md",label:"MD"}:t==="text/plain"||n==="TXT"?{variant:"txt",label:"TXT"}:{variant:"default",label:n||"FILE"};return(0,o.jsxs)("a",{href:Fe(e)??void 0,target:"_blank",rel:"noopener noreferrer",className:"ak-file-chip",title:a,children:[(0,o.jsx)("span",{className:`ak-file-chip__icon ak-file-chip__icon--${i.variant}`,"aria-hidden":!0,children:(0,o.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,o.jsx)("polyline",{points:"14 2 14 8 20 8"})]})}),(0,o.jsxs)("span",{className:"ak-file-chip__body",children:[(0,o.jsx)("span",{className:"ak-file-chip__name",children:a}),(0,o.jsx)("span",{className:"ak-file-chip__label",children:i.label})]})]})}function Gs(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}var br=/(`[^`\n]+`|\*\*[^*\n]+\*\*|\*[^*\n]+\*|!\[[^\]\n]*\]\([^)\n]+\)|\[[^\]\n]+\]\([^)\n]+\))/g;function Y(e){const t=[];let r=0,a=0;br.lastIndex=0;let n;for(;(n=br.exec(e))!==null;){n.index>r&&t.push(e.slice(r,n.index));const i=n[0];if(i.startsWith("`"))t.push((0,o.jsx)("code",{className:"ak-md-ic",children:i.slice(1,-1)},a++));else if(i.startsWith("**"))t.push((0,o.jsx)("strong",{children:i.slice(2,-2)},a++));else if(i.startsWith("*"))t.push((0,o.jsx)("em",{children:i.slice(1,-1)},a++));else if(i.startsWith("![")){const s=i.match(/!\[([^\]]*)\]\(([^)]+)\)/),l=Fe(s?.[2]);s&&l?t.push((0,o.jsx)("a",{href:l,target:"_blank",rel:"noopener noreferrer",children:s[1]||"image"},a++)):s&&t.push(s[1]||"image")}else{const s=i.match(/\[(.+?)\]\((.+?)\)/),l=Fe(s?.[2]);s&&l?t.push((0,o.jsx)("a",{href:l,target:"_blank",rel:"noopener noreferrer",children:s[1]},a++)):s?t.push(s[1]):t.push(i)}r=n.index+i.length}return r<e.length&&t.push(e.slice(r)),t}function Hs(e){e=e.replace(/\\text\{([^}]*)\}/g,"$1").replace(/\\implies/g,"→").replace(/\\Rightarrow/g,"⟹").replace(/\\times/g,"×").replace(/\\div/g,"÷").replace(/\\cdot/g,"·").replace(/\\quad/g," ").replace(/\\qquad/g," ").replace(/\\leq/g,"≤").replace(/\\geq/g,"≥").replace(/\\neq/g,"≠").replace(/\\approx/g,"≈").replace(/\\infty/g,"∞").replace(/\\\((.+?)\\\)/gs,"$1").replace(/\\\[[\s\S]+?\\\]/g,"").replace(/\\\$/g,"\0DOLLAR\0").replace(/\$\$[\s\S]+?\$\$/g,"").replace(/\$([^$]+)\$/g,"$1").replace(/\x00DOLLAR\x00/g,"$").replace(/\\[a-zA-Z]+\*?/g,"").replace(/\n{3,}/g,`
|
|
1854
1905
|
|
|
1855
1906
|
`);const t=e.split(`
|
|
1856
|
-
`),r=[];let
|
|
1857
|
-
`)})})]},a++));continue}const l=i.match(/^(#{1,6})(\s+.*)?$/);if(l){const d=l[1].length,u=l[2]?H(l[2].trim()):"";d===1?r.push((0,o.jsx)("h1",{className:"ak-md-h1",children:u},a++)):d===2?r.push((0,o.jsx)("h2",{className:"ak-md-h2",children:u},a++)):d===3?r.push((0,o.jsx)("h3",{className:"ak-md-h3",children:u},a++)):d===4?r.push((0,o.jsx)("h4",{className:"ak-md-h4",children:u},a++)):d===5?r.push((0,o.jsx)("h5",{className:"ak-md-h5",children:u},a++)):r.push((0,o.jsx)("h6",{className:"ak-md-h6",children:u},a++)),n++;continue}if(/^[-*_]{3,}$/.test(i.trim())){r.push((0,o.jsx)("hr",{className:"ak-md-hr"},a++)),n++;continue}if(/^[-*+]\s/.test(i)){const d=[];let u=n;for(;u<t.length&&(/^[-*+]\s/.test(t[u])||t[u].trim()==="");){if(t[u].trim()===""){u++;continue}const f=t[u].length-t[u].trimStart().length,p=t[u].replace(/^[-*+]\s+/,""),h=[],x=[];let v=u+1;for(;v<t.length&&v<u+20;){const g=t[v];if(g.length-g.trimStart().length>f&&g.trim()!==""){const I=g.trim();/^[-*+]\s/.test(I)?h.push((0,o.jsx)("li",{children:H(I.replace(/^[-*+]\s+/,""))},`nested-${v}`)):x.push((0,o.jsx)("p",{style:{margin:"0.2em 0 0"},children:H(I)},`cont-${v}`)),v++}else break}const w=x.length>0||h.length>0?(0,o.jsxs)(o.Fragment,{children:[H(p),x,h.length>0&&(0,o.jsx)("ul",{style:{margin:"0.2em 0 0",paddingLeft:"1.2em"},children:h})]}):H(p);d.push((0,o.jsx)("li",{children:w},`item-${u}`)),u=v}r.push((0,o.jsx)("ul",{className:"ak-md-ul",children:d},a++)),n=u;continue}if(/^\d+\.\s/.test(i)){const d=[];let u=n;for(;u<t.length&&(/^\d+\.\s/.test(t[u])||t[u].trim()==="");){if(t[u].trim()===""){u++;continue}const f=t[u].length-t[u].trimStart().length,p=t[u].replace(/^\d+\.\s+/,""),h=[],x=[];let v=u+1;for(;v<t.length&&v<u+20;){const g=t[v];if(g.length-g.trimStart().length>f&&g.trim()!==""){const I=g.trim();/^\d+\.\s/.test(I)?h.push((0,o.jsx)("li",{children:H(I.replace(/^\d+\.\s+/,""))},`nested-order-${v}`)):/^[-*+]\s/.test(I)?h.push((0,o.jsx)("li",{children:H(I.replace(/^[-*+]\s+/,""))},`nested-unorder-${v}`)):x.push((0,o.jsx)("p",{style:{margin:"0.2em 0 0"},children:H(I)},`cont-${v}`)),v++}else break}const w=x.length>0||h.length>0?(0,o.jsxs)(o.Fragment,{children:[H(p),x,h.length>0&&(0,o.jsx)("ol",{style:{margin:"0.2em 0 0",paddingLeft:"1.2em"},children:h})]}):H(p);d.push((0,o.jsx)("li",{children:w},`order-item-${u}`)),u=v}r.push((0,o.jsx)("ol",{className:"ak-md-ol",children:d},a++)),n=u;continue}if(i.trim()===""){n++;continue}if(i.includes("|")&&n+1<t.length&&t[n+1].includes("|")){const d=t[n+1];if(/^\s*\|?[\s:|*-]+\|[\s:|*-|]+\|?[\s:|*-]*$/.test(d)){const u=i.split("|").map(x=>x.trim()).filter(x=>x.length>0),f=d.split("|").map(x=>{const v=x.trim();return v.startsWith(":")&&v.endsWith(":")?"center":v.endsWith(":")?"right":(v.startsWith(":"),"left")}).filter((x,v)=>v>0&&v<=u.length),p=[];let h=n+2;for(;h<t.length&&t[h].includes("|")&&t[h].trim()!=="";){const x=t[h].split("|").map(v=>v.trim()).filter(v=>v.length>0);if(x.length>0)p.push(x),h++;else break}r.push((0,o.jsxs)("table",{className:"ak-md-table",children:[(0,o.jsx)("thead",{children:(0,o.jsx)("tr",{children:u.map((x,v)=>(0,o.jsx)("th",{style:{textAlign:f[v]||"left"},className:"ak-md-th",children:H(x)},`th-${v}`))})}),(0,o.jsx)("tbody",{children:p.map((x,v)=>(0,o.jsx)("tr",{children:u.map((w,g)=>(0,o.jsx)("td",{style:{textAlign:f[g]||"left"},className:"ak-md-td",children:x[g]?H(x[g]):""},`td-${v}-${g}`))},`tr-${v}`))})]},a++)),n=h;continue}}const c=[];for(;n<t.length&&t[n].trim()!==""&&!t[n].startsWith("#")&&!/^\s*```/.test(t[n])&&!/^[-*+]\s/.test(t[n])&&!/^\d+\.\s/.test(t[n])&&!/^[-*_]{3,}$/.test(t[n].trim());)c.push(t[n]),n++;if(c.length>0){const d=[];c.forEach((u,f)=>{d.push(...H(u)),f<c.length-1&&d.push((0,o.jsx)("br",{},`br-${f}`))}),r.push((0,o.jsx)("p",{className:"ak-md-p",children:d},a++))}}return(0,o.jsx)(o.Fragment,{children:r})}function vn({message:e}){const[t,r]=(0,L.useState)(null),[n,a]=(0,L.useState)(null),i=e.role==="user",s=e.status==="error",l=e.status==="streaming",c=!!(e.images&&e.images.length>0),d=!!(e.documents&&e.documents.length>0),u=(()=>{if(!i)return[];const _=(e.uploadedAttachments??[]).filter(C=>C.kind==="image").map(C=>({url:C.url,mimeType:C.mimeType,fileName:C.fileName}));return _.length>0?_:e.uploadedImageUrl?[{url:e.uploadedImageUrl,mimeType:"image/jpeg"}]:[]})(),f=i?(e.uploadedAttachments??[]).filter(_=>_.kind==="file"):[],p=u.length>0,h=f.length>0,x=c||p,v=!i&&!s,w=!!e.isHuman&&!i,g=i?"ak-message--user":s?"ak-message--assistant ak-message--error":w?"ak-message--assistant ak-message--operator":"ak-message--assistant",I=["ak-message__bubble",v?"ak-message__bubble--md":"",x?"ak-message__bubble--has-image":"",w?"ak-message__bubble--operator":""].filter(Boolean).join(" "),R=w?e.senderDisplay?.trim()||"Operator":null,P=R?R.charAt(0).toUpperCase():"",U=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:I,children:[p&&(0,o.jsx)(kr,{messageId:`${e.id}-up`,images:u.map(_=>({src:_.url,alt:_.fileName??"Uploaded image",downloadHref:_.url})),onCellClick:_=>r(_)}),h&&(0,o.jsx)("div",{className:"ak-message__files",children:f.map((_,C)=>(0,o.jsx)(br,{url:_.url,mimeType:_.mimeType,fileName:_.fileName},`${e.id}-up-file-${C}`))}),c&&(0,o.jsx)(kr,{messageId:`${e.id}-asst`,images:e.images.map((_,C)=>{const te=_.url??(_.base64?`data:${_.mimeType};base64,${_.base64}`:null);return te?{src:te,alt:"Generated image",downloadHref:_.url??te,key:`gen-${C}`}:null}).filter(_=>_!==null),onCellClick:_=>a(_)}),d&&(0,o.jsx)("div",{className:"ak-message__files",children:e.documents.map((_,C)=>_.url?(0,o.jsx)(br,{url:_.url,mimeType:_.mimeType,fileName:_.fileName},`${e.id}-asst-doc-${C}`):null)}),(e.content||l&&!e.toolStatus)&&(0,o.jsxs)("div",{className:x?"ak-message__image-caption":void 0,children:[v?Js(e.content):e.content,l&&(!!e.content||!e.toolStatus)&&(0,o.jsxs)("span",{className:"ak-cursor","aria-hidden":"true",children:[(0,o.jsx)("span",{className:"ak-cursor__dot"}),(0,o.jsx)("span",{className:"ak-cursor__dot"}),(0,o.jsx)("span",{className:"ak-cursor__dot"})]})]})]}),(0,o.jsx)("span",{className:"ak-message__time",children:Xs(e.createdAt)})]}),D=!!e.content||!e.toolStatus;return(0,o.jsxs)("div",{className:`ak-message ${g}`,children:[!i&&(e.ackText||e.progressEvents&&e.progressEvents.length>0||e.turnMeta)&&(0,o.jsx)(Gs,{ackText:e.ackText,events:e.progressEvents,collapsed:e.progressCollapsed,isComplete:!l,turnMeta:e.turnMeta}),!i&&e.toolStatus&&!(e.progressEvents&&e.progressEvents.length>0)&&(0,o.jsx)(Ys,{status:e.toolStatus}),w&&(0,o.jsxs)("span",{className:"ak-message__sender-label",children:[(0,o.jsx)("span",{className:"ak-message__operator-avatar","aria-hidden":"true",children:P}),(0,o.jsx)("span",{className:"ak-message__operator-name",children:R})]}),D&&U,u.length>0&&(0,o.jsx)(yr,{images:u.map(_=>({src:_.url,alt:_.fileName??"Uploaded image",downloadHref:_.url})),index:t,onClose:()=>r(null),onIndexChange:r}),c&&(0,o.jsx)(yr,{images:e.images.map(_=>{const C=_.url??(_.base64?`data:${_.mimeType};base64,${_.base64}`:null);return C?{src:C,alt:"Generated image",downloadHref:_.url??C}:null}).filter(_=>_!==null),index:n,onClose:()=>a(null),onIndexChange:a})]})}function xn(){return(0,o.jsxs)("div",{className:"ak-typing","aria-label":"Assistant is typing",children:[(0,o.jsx)("span",{className:"ak-typing__dot"}),(0,o.jsx)("span",{className:"ak-typing__dot"}),(0,o.jsx)("span",{className:"ak-typing__dot"})]})}function Qs(e,t){const r=[];let n=null;for(const a of e){if(a.role==="assistant"){const i=!!a.isHuman;n!==null&&n!==i&&r.push({kind:"divider",id:`divider-${a.id}`,label:i?`${a.senderDisplay?.trim()||t} joined the chat`:`${t} left — AI is back`}),n=i}r.push({kind:"message",message:a})}return r}function kn({messages:e,isLoading:t,operatorFallbackLabel:r="Operator"}){const n=(0,L.useRef)(null),a=(0,L.useRef)(null),i=(0,L.useRef)(!0),s=(0,L.useMemo)(()=>Qs(e,r),[e,r]);return(0,L.useEffect)(()=>{if(!(n.current?.parentElement??n.current))return;const l=u=>{i.current=u.scrollHeight-u.scrollTop-u.clientHeight<120};let c=n.current;for(;c&&getComputedStyle(c).overflowY==="visible";)c=c.parentElement;if(!c)return;const d=()=>l(c);return c.addEventListener("scroll",d,{passive:!0}),()=>c.removeEventListener("scroll",d)},[]),(0,L.useEffect)(()=>{e[e.length-1]?.role==="user"&&(i.current=!0),i.current&&a.current?.scrollIntoView({behavior:"smooth"})},[e]),(0,L.useEffect)(()=>{i.current&&a.current?.scrollIntoView({behavior:"smooth"})},[t,e.find(l=>l.status==="streaming")?.content??""]),(0,o.jsxs)("div",{ref:n,className:"ak-messages",role:"log","aria-live":"polite","aria-label":"Conversation",children:[s.map(l=>l.kind==="divider"?(0,o.jsx)("div",{className:"ak-handoff-divider",role:"separator",children:(0,o.jsx)("span",{className:"ak-handoff-divider__label",children:l.label})},l.id):(0,o.jsx)(vn,{message:l.message},l.message.id)),t&&!e.some(l=>l.status==="streaming")&&(0,o.jsx)(xn,{}),(0,o.jsx)("div",{ref:a})]})}function Ks(){return(0,o.jsxs)("svg",{width:"30",height:"30",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,o.jsx)("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),(0,o.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,o.jsx)("path",{d:"M12 7v4"}),(0,o.jsx)("line",{x1:"8",y1:"16",x2:"8",y2:"16"}),(0,o.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"16"})]})}function qs({title:e,description:t,suggestedQuestions:r,avatarUrl:n,onSelect:a}){const i=(r??[]).filter(s=>(s.title??"").trim().length>0);return(0,o.jsxs)("div",{className:"ak-empty-state","aria-label":"Start a conversation",children:[(0,o.jsx)("div",{className:"ak-empty-state__glow","aria-hidden":"true"}),(0,o.jsxs)("div",{className:"ak-empty-state__body",children:[(0,o.jsx)("div",{className:"ak-empty-state__avatar",children:n?(0,o.jsx)("img",{src:n,alt:"",className:"ak-empty-state__avatar-img","aria-hidden":"true"}):(0,o.jsx)("span",{className:"ak-empty-state__bot-icon","aria-hidden":"true",children:(0,o.jsx)(Ks,{})})}),(0,o.jsx)("p",{className:"ak-empty-state__title",children:e}),t&&(0,o.jsx)("p",{className:"ak-empty-state__description",children:t})]}),i.length>0&&(0,o.jsx)("div",{className:"ak-empty-state__suggestions",children:i.map((s,l)=>(0,o.jsxs)("button",{className:"ak-empty-state__suggestion",onClick:()=>a?.(s.prompt??s.title),type:"button",children:[(0,o.jsx)("span",{className:"ak-empty-state__suggestion-title",children:s.title}),s.description&&(0,o.jsx)("span",{className:"ak-empty-state__suggestion-desc",children:s.description})]},l))})]})}function eo(){return(0,o.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,o.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function to(){return(0,o.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[(0,o.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,o.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function ro(){return(0,o.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("path",{d:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"}),(0,o.jsx)("circle",{cx:"12",cy:"13",r:"4"})]})}function wr(){return(0,o.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,o.jsx)("polyline",{points:"14 2 14 8 20 8"})]})}function jr(){return(0,o.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,o.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}var yn=["application/pdf","text/markdown","text/plain","text/csv"],bn=[".pdf",".md",".txt",".csv"],no=[...bn,...yn].join(","),_n=["image/jpeg","image/png","image/gif","image/webp"],ao=_n.join(",");function io(e){if(yn.includes(e.type))return!0;const t=e.name.toLowerCase();return bn.some(r=>t.endsWith(r))}function so(e){return _n.includes(e.type)}function wn({onSend:e,disabled:t=!1,placeholder:r="Type a message…",privacyPolicyUrl:n,termsOfServiceUrl:a,disclosureText:i,photoSendingEnabled:s=!1,fileUploadEnabled:l=!1,attachmentMaxCount:c=5,attachmentMaxFileSizeMb:d=1}){const[u,f]=(0,L.useState)(""),[p,h]=(0,L.useState)([]),[x,v]=(0,L.useState)(new Map),[w,g]=(0,L.useState)(!1),I=(0,L.useRef)(null),R=(0,L.useRef)(null),P=(0,L.useRef)(null),U=(0,L.useRef)(null),D=(0,L.useRef)(null),_=s||l,C=(0,L.useMemo)(()=>d*1024*1024,[d]);(0,L.useEffect)(()=>()=>{x.forEach(T=>URL.revokeObjectURL(T))},[]),(0,L.useEffect)(()=>{t||I.current?.focus()},[t]);const te=(0,L.useCallback)(T=>{if(!w)return;const O=T.composedPath?T.composedPath():[],J=!!U.current&&O.includes(U.current),$=!!D.current&&O.includes(D.current);!J&&!$&&g(!1)},[w]);(0,L.useEffect)(()=>{if(w)return document.addEventListener("click",te),()=>document.removeEventListener("click",te)},[w,te]),(0,L.useEffect)(()=>{_||g(!1)},[_]);function We(){x.forEach(T=>URL.revokeObjectURL(T)),v(new Map),h([]),R.current&&(R.current.value=""),P.current&&(P.current.value="")}function ge(T){h(O=>{const J=O[T];if(J){const $=x.get(J.file);$&&(URL.revokeObjectURL($),v(B=>{const Ne=new Map(B);return Ne.delete(J.file),Ne}))}return O.filter(($,B)=>B!==T)})}function Ie(){const T=u.trim();!T&&p.length===0||t||(e(T,p),f(""),We(),I.current&&(I.current.style.height="auto"))}function Ve(T){T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),Ie())}function ft(T){const O=T.currentTarget;f(O.value),O.style.height="auto",O.style.height=`${O.scrollHeight}px`}function Kt(T,O){if(T.length===0)return;const J=[],$=[];for(const B of T){if(O==="image"&&!so(B)){$.push(`${B.name} (image type not supported)`);continue}if(O==="file"&&!io(B)){$.push(`${B.name} (file type not supported)`);continue}if(B.size>C){$.push(`${B.name} (over ${d} MB)`);continue}J.push({file:B,kind:O})}h(B=>{const Ne=[...B,...J],qt=Ne.slice(0,c);return Ne.length>c&&$.push(`max ${c} attachments allowed`),v(An=>{const ht=new Map(An);for(const De of qt)De.kind==="image"&&!ht.has(De.file)&&ht.set(De.file,URL.createObjectURL(De.file));return ht}),qt}),$.length>0&&alert(`Some attachments were not added:
|
|
1858
|
-
• ${
|
|
1859
|
-
• `)}`)}function
|
|
1860
|
-
`+
|
|
1907
|
+
`),r=[];let a=0,n=0;for(;a<t.length;){const i=t[a],s=i.match(/^(\s*)```/);if(s){const d=s[1],u=i.trimStart().match(/^```(\w+)?\s*$/)?.[1]||"",h=[];for(a++;a<t.length&&!t[a].trimStart().startsWith("```");)h.push(t[a].startsWith(d)?t[a].slice(d.length):t[a]),a++;a<t.length&&t[a].trimStart().startsWith("```")&&a++,r.push((0,o.jsxs)("div",{className:"ak-md-pre-wrap",children:[u&&(0,o.jsx)("span",{className:"ak-md-pre-lang",children:u}),(0,o.jsx)("pre",{className:`ak-md-pre${u?` ak-md-pre--${u}`:""}`,children:(0,o.jsx)("code",{className:"ak-md-code",children:h.join(`
|
|
1908
|
+
`)})})]},n++));continue}const l=i.match(/^(#{1,6})(\s+.*)?$/);if(l){const d=l[1].length,u=l[2]?Y(l[2].trim()):"";d===1?r.push((0,o.jsx)("h1",{className:"ak-md-h1",children:u},n++)):d===2?r.push((0,o.jsx)("h2",{className:"ak-md-h2",children:u},n++)):d===3?r.push((0,o.jsx)("h3",{className:"ak-md-h3",children:u},n++)):d===4?r.push((0,o.jsx)("h4",{className:"ak-md-h4",children:u},n++)):d===5?r.push((0,o.jsx)("h5",{className:"ak-md-h5",children:u},n++)):r.push((0,o.jsx)("h6",{className:"ak-md-h6",children:u},n++)),a++;continue}if(/^[-*_]{3,}$/.test(i.trim())){r.push((0,o.jsx)("hr",{className:"ak-md-hr"},n++)),a++;continue}if(/^[-*+]\s/.test(i)){const d=[];let u=a;for(;u<t.length&&(/^[-*+]\s/.test(t[u])||t[u].trim()==="");){if(t[u].trim()===""){u++;continue}const h=t[u].length-t[u].trimStart().length,p=t[u].replace(/^[-*+]\s+/,""),f=[],v=[];let k=u+1;for(;k<t.length&&k<u+20;){const g=t[k];if(g.length-g.trimStart().length>h&&g.trim()!==""){const C=g.trim();/^[-*+]\s/.test(C)?f.push((0,o.jsx)("li",{children:Y(C.replace(/^[-*+]\s+/,""))},`nested-${k}`)):v.push((0,o.jsx)("p",{style:{margin:"0.2em 0 0"},children:Y(C)},`cont-${k}`)),k++}else break}const S=v.length>0||f.length>0?(0,o.jsxs)(o.Fragment,{children:[Y(p),v,f.length>0&&(0,o.jsx)("ul",{style:{margin:"0.2em 0 0",paddingLeft:"1.2em"},children:f})]}):Y(p);d.push((0,o.jsx)("li",{children:S},`item-${u}`)),u=k}r.push((0,o.jsx)("ul",{className:"ak-md-ul",children:d},n++)),a=u;continue}if(/^\d+\.\s/.test(i)){const d=[];let u=a;for(;u<t.length&&(/^\d+\.\s/.test(t[u])||t[u].trim()==="");){if(t[u].trim()===""){u++;continue}const h=t[u].length-t[u].trimStart().length,p=t[u].replace(/^\d+\.\s+/,""),f=[],v=[];let k=u+1;for(;k<t.length&&k<u+20;){const g=t[k];if(g.length-g.trimStart().length>h&&g.trim()!==""){const C=g.trim();/^\d+\.\s/.test(C)?f.push((0,o.jsx)("li",{children:Y(C.replace(/^\d+\.\s+/,""))},`nested-order-${k}`)):/^[-*+]\s/.test(C)?f.push((0,o.jsx)("li",{children:Y(C.replace(/^[-*+]\s+/,""))},`nested-unorder-${k}`)):v.push((0,o.jsx)("p",{style:{margin:"0.2em 0 0"},children:Y(C)},`cont-${k}`)),k++}else break}const S=v.length>0||f.length>0?(0,o.jsxs)(o.Fragment,{children:[Y(p),v,f.length>0&&(0,o.jsx)("ol",{style:{margin:"0.2em 0 0",paddingLeft:"1.2em"},children:f})]}):Y(p);d.push((0,o.jsx)("li",{children:S},`order-item-${u}`)),u=k}r.push((0,o.jsx)("ol",{className:"ak-md-ol",children:d},n++)),a=u;continue}if(i.trim()===""){a++;continue}if(i.includes("|")&&a+1<t.length&&t[a+1].includes("|")){const d=t[a+1];if(/^\s*\|?[\s:|*-]+\|[\s:|*-|]+\|?[\s:|*-]*$/.test(d)){const u=i.split("|").map(v=>v.trim()).filter(v=>v.length>0),h=d.split("|").map(v=>{const k=v.trim();return k.startsWith(":")&&k.endsWith(":")?"center":k.endsWith(":")?"right":(k.startsWith(":"),"left")}).filter((v,k)=>k>0&&k<=u.length),p=[];let f=a+2;for(;f<t.length&&t[f].includes("|")&&t[f].trim()!=="";){const v=t[f].split("|").map(k=>k.trim()).filter(k=>k.length>0);if(v.length>0)p.push(v),f++;else break}r.push((0,o.jsxs)("table",{className:"ak-md-table",children:[(0,o.jsx)("thead",{children:(0,o.jsx)("tr",{children:u.map((v,k)=>(0,o.jsx)("th",{style:{textAlign:h[k]||"left"},className:"ak-md-th",children:Y(v)},`th-${k}`))})}),(0,o.jsx)("tbody",{children:p.map((v,k)=>(0,o.jsx)("tr",{children:u.map((S,g)=>(0,o.jsx)("td",{style:{textAlign:h[g]||"left"},className:"ak-md-td",children:v[g]?Y(v[g]):""},`td-${k}-${g}`))},`tr-${k}`))})]},n++)),a=f;continue}}const c=[];for(;a<t.length&&t[a].trim()!==""&&!t[a].startsWith("#")&&!/^\s*```/.test(t[a])&&!/^[-*+]\s/.test(t[a])&&!/^\d+\.\s/.test(t[a])&&!/^[-*_]{3,}$/.test(t[a].trim());)c.push(t[a]),a++;if(c.length>0){const d=[];c.forEach((u,h)=>{d.push(...Y(u)),h<c.length-1&&d.push((0,o.jsx)("br",{},`br-${h}`))}),r.push((0,o.jsx)("p",{className:"ak-md-p",children:d},n++))}}return(0,o.jsx)(o.Fragment,{children:r})}function ma({message:e}){const[t,r]=(0,E.useState)(null),[a,n]=(0,E.useState)(null),i=e.role==="user",s=e.status==="error",l=e.status==="streaming",c=!!(e.images&&e.images.length>0),d=!!(e.documents&&e.documents.length>0),u=(()=>{if(!i)return[];const j=(e.uploadedAttachments??[]).filter(F=>F.kind==="image").map(F=>({url:F.url,mimeType:F.mimeType,fileName:F.fileName}));return j.length>0?j:e.uploadedImageUrl?[{url:e.uploadedImageUrl,mimeType:"image/jpeg"}]:[]})(),h=i?(e.uploadedAttachments??[]).filter(j=>j.kind==="file"):[],p=u.length>0,f=h.length>0,v=c||p,k=!!e.progressEvents&&e.progressEvents.length>0,S=l&&!e.content&&!e.toolStatus&&!k,g=!i&&!s,C=!!e.isHuman&&!i,R=i?"ak-message--user":s?"ak-message--assistant ak-message--error":C?"ak-message--assistant ak-message--operator":"ak-message--assistant",P=["ak-message__bubble",g?"ak-message__bubble--md":"",v?"ak-message__bubble--has-image":"",C?"ak-message__bubble--operator":""].filter(Boolean).join(" "),B=C?e.senderDisplay?.trim()||"Operator":null,D=B?B.charAt(0).toUpperCase():"",re=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:P,children:[p&&(0,o.jsx)(kr,{messageId:`${e.id}-up`,images:u.map(j=>({src:j.url,alt:j.fileName??"Uploaded image",downloadHref:j.url})),onCellClick:j=>r(j)}),f&&(0,o.jsx)("div",{className:"ak-message__files",children:h.map((j,F)=>(0,o.jsx)(yr,{url:j.url,mimeType:j.mimeType,fileName:j.fileName},`${e.id}-up-file-${F}`))}),c&&(0,o.jsx)(kr,{messageId:`${e.id}-asst`,images:e.images.map((j,F)=>{const oe=j.url??(j.base64?`data:${j.mimeType};base64,${j.base64}`:null);return oe?{src:oe,alt:"Generated image",downloadHref:j.url??oe,key:`gen-${F}`}:null}).filter(j=>j!==null),onCellClick:j=>n(j)}),d&&(0,o.jsx)("div",{className:"ak-message__files",children:e.documents.map((j,F)=>j.url?(0,o.jsx)(yr,{url:j.url,mimeType:j.mimeType,fileName:j.fileName},`${e.id}-asst-doc-${F}`):null)}),e.content&&(0,o.jsxs)("div",{className:v?"ak-message__image-caption":void 0,children:[g?Hs(e.content):e.content,l&&(0,o.jsxs)("span",{className:"ak-cursor","aria-hidden":"true",children:[(0,o.jsx)("span",{className:"ak-cursor__dot"}),(0,o.jsx)("span",{className:"ak-cursor__dot"}),(0,o.jsx)("span",{className:"ak-cursor__dot"})]})]})]}),(0,o.jsx)("span",{className:"ak-message__time",children:Gs(e.createdAt)})]}),L=!!e.content||v||f||d||!l&&!e.toolStatus;return(0,o.jsxs)("div",{className:`ak-message ${R}`,children:[!i&&(e.ackText||e.progressEvents&&e.progressEvents.length>0||e.turnMeta)&&(0,o.jsx)(Ds,{ackText:e.ackText,events:e.progressEvents,collapsed:e.progressCollapsed,isComplete:!l,turnMeta:e.turnMeta}),S&&(0,o.jsxs)("div",{className:"ak-typing-row",role:"status","aria-label":"Assistant is typing",children:[(0,o.jsx)("span",{className:"ak-typing-row__dot"}),(0,o.jsx)("span",{className:"ak-typing-row__dot"}),(0,o.jsx)("span",{className:"ak-typing-row__dot"})]}),!i&&e.toolStatus&&!(e.progressEvents&&e.progressEvents.length>0)&&(0,o.jsx)(Bs,{status:e.toolStatus}),C&&(0,o.jsxs)("span",{className:"ak-message__sender-label",children:[(0,o.jsx)("span",{className:"ak-message__operator-avatar","aria-hidden":"true",children:D}),(0,o.jsx)("span",{className:"ak-message__operator-name",children:B})]}),L&&re,u.length>0&&(0,o.jsx)(xr,{images:u.map(j=>({src:j.url,alt:j.fileName??"Uploaded image",downloadHref:j.url})),index:t,onClose:()=>r(null),onIndexChange:r}),c&&(0,o.jsx)(xr,{images:e.images.map(j=>{const F=j.url??(j.base64?`data:${j.mimeType};base64,${j.base64}`:null);return F?{src:F,alt:"Generated image",downloadHref:j.url??F}:null}).filter(j=>j!==null),index:a,onClose:()=>n(null),onIndexChange:n})]})}function ga(){return(0,o.jsxs)("div",{className:"ak-typing","aria-label":"Assistant is typing",children:[(0,o.jsx)("span",{className:"ak-typing__dot"}),(0,o.jsx)("span",{className:"ak-typing__dot"}),(0,o.jsx)("span",{className:"ak-typing__dot"})]})}function Ys(e,t){const r=[];let a=null;for(const n of e){if(n.role==="assistant"){const i=!!n.isHuman;a!==null&&a!==i&&r.push({kind:"divider",id:`divider-${n.id}`,label:i?`${n.senderDisplay?.trim()||t} joined the chat`:`${t} left — AI is back`}),a=i}r.push({kind:"message",message:n})}return r}function va({messages:e,isLoading:t,operatorFallbackLabel:r="Operator"}){const a=(0,E.useRef)(null),n=(0,E.useRef)(null),i=(0,E.useRef)(!0),s=(0,E.useMemo)(()=>Ys(e,r),[e,r]);return(0,E.useEffect)(()=>{if(!(a.current?.parentElement??a.current))return;const l=u=>{i.current=u.scrollHeight-u.scrollTop-u.clientHeight<120};let c=a.current;for(;c&&getComputedStyle(c).overflowY==="visible";)c=c.parentElement;if(!c)return;const d=()=>l(c);return c.addEventListener("scroll",d,{passive:!0}),()=>c.removeEventListener("scroll",d)},[]),(0,E.useEffect)(()=>{e[e.length-1]?.role==="user"&&(i.current=!0),i.current&&n.current?.scrollIntoView({behavior:"smooth"})},[e]),(0,E.useEffect)(()=>{i.current&&n.current?.scrollIntoView({behavior:"smooth"})},[t,e.find(l=>l.status==="streaming")?.content??""]),(0,o.jsxs)("div",{ref:a,className:"ak-messages",role:"log","aria-live":"polite","aria-label":"Conversation",children:[s.map(l=>l.kind==="divider"?(0,o.jsx)("div",{className:"ak-handoff-divider",role:"separator",children:(0,o.jsx)("span",{className:"ak-handoff-divider__label",children:l.label})},l.id):(0,o.jsx)(ma,{message:l.message},l.message.id)),t&&!e.some(l=>l.status==="streaming")&&(0,o.jsx)(ga,{}),(0,o.jsx)("div",{ref:n})]})}function Xs(){return(0,o.jsxs)("svg",{width:"30",height:"30",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,o.jsx)("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),(0,o.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,o.jsx)("path",{d:"M12 7v4"}),(0,o.jsx)("line",{x1:"8",y1:"16",x2:"8",y2:"16"}),(0,o.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"16"})]})}function Js({title:e,description:t,suggestedQuestions:r,avatarUrl:a,onSelect:n}){const i=(r??[]).filter(s=>(s.title??"").trim().length>0);return(0,o.jsxs)("div",{className:"ak-empty-state","aria-label":"Start a conversation",children:[(0,o.jsx)("div",{className:"ak-empty-state__glow","aria-hidden":"true"}),(0,o.jsxs)("div",{className:"ak-empty-state__body",children:[(0,o.jsx)("div",{className:"ak-empty-state__avatar",children:a?(0,o.jsx)("img",{src:a,alt:"",className:"ak-empty-state__avatar-img","aria-hidden":"true"}):(0,o.jsx)("span",{className:"ak-empty-state__bot-icon","aria-hidden":"true",children:(0,o.jsx)(Xs,{})})}),(0,o.jsx)("p",{className:"ak-empty-state__title",children:e}),t&&(0,o.jsx)("p",{className:"ak-empty-state__description",children:t})]}),i.length>0&&(0,o.jsx)("div",{className:"ak-empty-state__suggestions",children:i.map((s,l)=>(0,o.jsxs)("button",{className:"ak-empty-state__suggestion",onClick:()=>n?.(s.prompt??s.title),type:"button",children:[(0,o.jsx)("span",{className:"ak-empty-state__suggestion-title",children:s.title}),s.description&&(0,o.jsx)("span",{className:"ak-empty-state__suggestion-desc",children:s.description})]},l))})]})}var Qs="https://klicforge.ai/privacy-policy",Ks="https://klicforge.ai/terms-of-service";function qs(){return(0,o.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,o.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function eo(){return(0,o.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[(0,o.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,o.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function to(){return(0,o.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("path",{d:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"}),(0,o.jsx)("circle",{cx:"12",cy:"13",r:"4"})]})}function _r(){return(0,o.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,o.jsx)("polyline",{points:"14 2 14 8 20 8"})]})}function wr(){return(0,o.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,o.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}var ka=["application/pdf","text/markdown","text/plain","text/csv"],xa=[".pdf",".md",".txt",".csv"],ro=[...xa,...ka].join(","),ya=["image/jpeg","image/png","image/gif","image/webp"],ao=ya.join(",");function no(e){if(ka.includes(e.type))return!0;const t=e.name.toLowerCase();return xa.some(r=>t.endsWith(r))}function io(e){return ya.includes(e.type)}function ba({onSend:e,disabled:t=!1,placeholder:r="Type a message…",photoSendingEnabled:a=!1,fileUploadEnabled:n=!1,attachmentMaxCount:i=5,attachmentMaxFileSizeMb:s=1}){const[l,c]=(0,E.useState)(""),[d,u]=(0,E.useState)([]),[h,p]=(0,E.useState)(new Map),[f,v]=(0,E.useState)(!1),k=(0,E.useRef)(null),S=(0,E.useRef)(null),g=(0,E.useRef)(null),C=(0,E.useRef)(null),R=(0,E.useRef)(null),P=a||n,B=(0,E.useMemo)(()=>s*1024*1024,[s]);(0,E.useEffect)(()=>()=>{h.forEach(N=>URL.revokeObjectURL(N))},[]),(0,E.useEffect)(()=>{t||k.current?.focus()},[t]);const D=(0,E.useCallback)(N=>{if(!f)return;const O=N.composedPath?N.composedPath():[],Q=!!C.current&&O.includes(C.current),W=!!R.current&&O.includes(R.current);!Q&&!W&&v(!1)},[f]);(0,E.useEffect)(()=>{if(f)return document.addEventListener("click",D),()=>document.removeEventListener("click",D)},[f,D]),(0,E.useEffect)(()=>{P||v(!1)},[P]);function re(){h.forEach(N=>URL.revokeObjectURL(N)),p(new Map),u([]),S.current&&(S.current.value=""),g.current&&(g.current.value="")}function L(N){u(O=>{const Q=O[N];if(Q){const W=h.get(Q.file);W&&(URL.revokeObjectURL(W),p(G=>{const Ee=new Map(G);return Ee.delete(Q.file),Ee}))}return O.filter((W,G)=>G!==N)})}function j(){const N=l.trim();!N&&d.length===0||t||(e(N,d),c(""),re(),k.current&&(k.current.style.height="auto"))}function F(N){N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),j())}function oe(N){const O=N.currentTarget;c(O.value),O.style.height="auto",O.style.height=`${O.scrollHeight}px`}function Ne(N,O){if(N.length===0)return;const Q=[],W=[];for(const G of N){if(O==="image"&&!io(G)){W.push(`${G.name} (image type not supported)`);continue}if(O==="file"&&!no(G)){W.push(`${G.name} (file type not supported)`);continue}if(G.size>B){W.push(`${G.name} (over ${s} MB)`);continue}Q.push({file:G,kind:O})}u(G=>{const Ee=[...G,...Q],Kt=Ee.slice(0,i);return Ee.length>i&&W.push(`max ${i} attachments allowed`),p(Ia=>{const ft=new Map(Ia);for(const ze of Kt)ze.kind==="image"&&!ft.has(ze.file)&&ft.set(ze.file,URL.createObjectURL(ze.file));return ft}),Kt}),W.length>0&&alert(`Some attachments were not added:
|
|
1909
|
+
• ${W.join(`
|
|
1910
|
+
• `)}`)}function Ve(N){const O=Array.from(N.currentTarget.files??[]);N.currentTarget.value="",Ne(O,"image")}function ht(N){const O=Array.from(N.currentTarget.files??[]);N.currentTarget.value="",Ne(O,"file")}function ja(){v(!1),S.current?.click()}function Sa(){v(!1),g.current?.click()}const Ca=!t&&(!!l.trim()||d.length>0);return(0,o.jsxs)("div",{className:"ak-composer",children:[P&&f&&(0,o.jsxs)("div",{ref:C,className:"ak-composer__attach-menu",role:"menu",children:[a&&(0,o.jsxs)("button",{className:"ak-composer__attach-menu-item",onClick:ja,type:"button",role:"menuitem",disabled:t,children:[(0,o.jsx)(to,{}),(0,o.jsx)("span",{children:"Photo"})]}),n&&(0,o.jsxs)("button",{className:"ak-composer__attach-menu-item",onClick:Sa,type:"button",role:"menuitem",disabled:t,children:[(0,o.jsx)(_r,{}),(0,o.jsx)("span",{children:"File"})]})]}),d.length>0&&(0,o.jsx)("div",{className:"ak-composer__attachments",role:"list",children:d.map((N,O)=>{const Q=`${N.file.name}-${O}`;if(N.kind==="image"){const W=h.get(N.file);return(0,o.jsxs)("div",{className:"ak-composer__preview-wrap",role:"listitem",children:[W&&(0,o.jsx)("img",{src:W,alt:N.file.name,className:"ak-composer__preview-img"}),(0,o.jsx)("button",{className:"ak-composer__preview-remove",onClick:()=>L(O),type:"button","aria-label":`Remove ${N.file.name}`,disabled:t,children:(0,o.jsx)(wr,{})})]},Q)}return(0,o.jsxs)("span",{className:"ak-composer__file-chip",role:"listitem",children:[(0,o.jsx)(_r,{}),(0,o.jsx)("span",{className:"ak-composer__file-chip-name",title:N.file.name,children:N.file.name}),(0,o.jsx)("button",{className:"ak-composer__file-chip-remove",onClick:()=>L(O),type:"button","aria-label":`Remove ${N.file.name}`,disabled:t,children:(0,o.jsx)(wr,{})})]},Q)})}),(0,o.jsxs)("div",{className:"ak-composer__input-wrap",children:[P&&(0,o.jsxs)(o.Fragment,{children:[a&&(0,o.jsx)("input",{ref:S,type:"file",multiple:!0,accept:ao,className:"ak-composer__file-input",onChange:Ve,disabled:t,"aria-label":"Attach images"}),n&&(0,o.jsx)("input",{ref:g,type:"file",multiple:!0,accept:ro,className:"ak-composer__file-input",onChange:ht,disabled:t,"aria-label":"Attach files"}),(0,o.jsx)("div",{className:"ak-composer__attach-wrap",children:(0,o.jsx)("button",{ref:R,className:`ak-composer__attach${f?" ak-composer__attach--open":""}`,onClick:()=>v(N=>!N),disabled:t,"aria-label":"Attachment options","aria-haspopup":"true","aria-expanded":f,type:"button",children:(0,o.jsx)(eo,{})})})]}),(0,o.jsx)("textarea",{ref:k,className:"ak-composer__input",value:l,onInput:oe,onKeyDown:F,placeholder:r,disabled:t,rows:1,"aria-label":"Message input"}),(0,o.jsx)("button",{className:"ak-composer__send",onClick:j,disabled:!Ca,"aria-label":"Send message",type:"button",children:(0,o.jsx)(qs,{})})]}),(0,o.jsxs)("p",{className:"ak-composer__disclaimer",children:["By chatting you agree to our"," ",(0,o.jsx)("a",{href:Qs,target:"_blank",rel:"noopener noreferrer",children:"Privacy Policy"})," ","and"," ",(0,o.jsx)("a",{href:Ks,target:"_blank",rel:"noopener noreferrer",children:"Terms of Service"}),". ","AI can make mistakes. Verify important information."]})]})}function zt({message:e}){return e.includes("Origin not allowed")?(0,o.jsxs)("div",{className:"ak-error ak-error--origin",role:"alert",children:[(0,o.jsx)("div",{className:"ak-error__icon",children:"🔒"}),(0,o.jsxs)("div",{className:"ak-error__content",children:[(0,o.jsx)("h3",{className:"ak-error__title",children:"Access Restricted"}),(0,o.jsx)("p",{className:"ak-error__description",children:"This widget has been restricted to specific websites only. Contact the website administrator if you believe this is an error."})]})]}):(0,o.jsxs)("div",{className:"ak-error",role:"alert",children:[(0,o.jsx)("div",{className:"ak-error__icon",children:"⚠️"}),(0,o.jsx)("div",{className:"ak-error__content",children:(0,o.jsx)("p",{className:"ak-error__message",children:e})})]})}function so(){return(0,o.jsxs)("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,o.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,o.jsx)("path",{d:"M12 7v5l3 2"})]})}function oo(){return(0,o.jsxs)("div",{className:"ak-maintenance",role:"status","aria-live":"polite",children:[(0,o.jsx)("div",{className:"ak-maintenance__halo","aria-hidden":"true"}),(0,o.jsx)("div",{className:"ak-maintenance__icon",children:(0,o.jsx)(so,{})}),(0,o.jsx)("p",{className:"ak-maintenance__title",children:"Under maintenance"}),(0,o.jsx)("p",{className:"ak-maintenance__description",children:"This assistant is temporarily unavailable. Please check back in a little while."})]})}function lo(){return(0,o.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"ak-branding__logo",children:[(0,o.jsx)("rect",{width:"24",height:"24",rx:"5",fill:"currentColor"}),(0,o.jsx)("path",{d:"M12 5L7 13h3.5v6l6.5-9H13.5V5z",fill:"white"})]})}function co(){return(0,o.jsxs)("div",{className:"ak-branding",children:[(0,o.jsx)(lo,{}),(0,o.jsx)("span",{className:"ak-branding__label",children:"Powered by"}),(0,o.jsx)("span",{className:"ak-branding__name",children:"KlicForge"})]})}function Dt({config:e,messages:t,isLoading:r,error:a,isInline:n,initStatus:i,initError:s,callbacks:l}){return(0,o.jsxs)("div",{className:n?"ak-shell-wrap":"ak-shell-wrap ak-shell-enter",children:[(0,o.jsxs)("div",{className:n?"ak-shell ak-shell--inline":"ak-shell ak-shell--floating",role:"dialog","aria-label":e.title,children:[(0,o.jsx)(fa,{title:e.title,subtitle:e.subtitle,avatarUrl:e.avatarUrl,onClose:l.onClose,onReset:i==="ready"?l.onReset:void 0,hideClose:n}),i==="validating"&&(0,o.jsx)("div",{className:"ak-init-status",children:(0,o.jsx)("div",{className:"ak-init-spinner","aria-label":"Connecting…"})}),i==="error"&&(0,o.jsx)("div",{className:"ak-init-status ak-init-status--error",children:(0,o.jsx)(zt,{message:s??"Widget configuration is invalid."})}),i==="disabled"&&(0,o.jsx)("div",{className:"ak-init-status ak-init-status--maintenance",children:(0,o.jsx)(oo,{})}),i==="ready"&&(0,o.jsxs)(o.Fragment,{children:[t.length===0?(0,o.jsx)(Js,{title:e.title,description:e.description??e.subtitle,suggestedQuestions:e.suggestedQuestions,avatarUrl:e.avatarUrl,onSelect:c=>l.onSendMessage(c,[])}):(0,o.jsx)(va,{messages:t,isLoading:r}),a&&(0,o.jsx)(zt,{message:a}),(0,o.jsx)(ba,{onSend:l.onSendMessage,disabled:r,placeholder:"Type a message…",photoSendingEnabled:e.photoSendingEnabled,fileUploadEnabled:e.fileUploadEnabled,attachmentMaxCount:e.attachmentMaxCount,attachmentMaxFileSizeMb:e.attachmentMaxFileSizeMb})]})]}),!n&&(0,o.jsx)(co,{})]})}function uo(){return(0,o.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,o.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function ho(){return(0,o.jsx)("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,o.jsx)("polyline",{points:"6,9 12,15 18,9"})})}function _a({isOpen:e,onClick:t,avatarUrl:r,ariaLabel:a="Toggle chat"}){const n=!e&&!!r;return(0,o.jsx)("button",{className:`ak-launcher${n?" ak-launcher--avatar":""}`,onClick:t,"aria-label":a,"aria-expanded":e,type:"button",children:e?(0,o.jsx)(ho,{}):n?(0,o.jsx)("img",{src:r,alt:"",className:"ak-launcher__avatar-img","aria-hidden":"true"}):(0,o.jsx)(uo,{})})}function Ut({config:e,state:t,callbacks:r}){const a=e.mode==="inline",n=(0,E.useRef)(null);return(0,E.useEffect)(()=>{const i=n.current?.getRootNode()?.host;if(!i)return;const s=ua(e.theme.mode);i.setAttribute("data-theme",s)},[e.theme.mode]),(0,E.useEffect)(()=>{if(a)return;const i=n.current?.getRootNode()?.host;i&&(t.isOpen?i.setAttribute("data-open",""):i.removeAttribute("data-open"))},[a,t.isOpen]),a?(0,o.jsx)("div",{ref:n,className:"ak-inline",children:(0,o.jsx)(Dt,{config:e,messages:t.messages,isLoading:t.isLoading,error:t.error,isInline:!0,initStatus:t.initStatus,initError:t.initError,callbacks:r})}):(0,o.jsxs)("div",{ref:n,className:"ak-floating",children:[t.isOpen&&(0,o.jsx)(Dt,{config:e,messages:t.messages,isLoading:t.isLoading,error:t.error,isInline:!1,initStatus:t.initStatus,initError:t.initError,callbacks:r}),(0,o.jsx)(_a,{isOpen:t.isOpen,onClick:t.isOpen?r.onClose:r.onOpen,avatarUrl:e.avatarUrl})]})}var ut=(e,t,r,a)=>{const n=(0,Na.createRoot)(e);return n.render((0,E.createElement)(Ut,{config:t,state:r,callbacks:a})),{update(i,s){n.render((0,E.createElement)(Ut,{config:s,state:i,callbacks:a}))},destroy(){setTimeout(()=>{n.unmount()},0)}}};function wa(e){return ha+`
|
|
1911
|
+
`+da(e)}function Qt(e,t){return wa(Ie({...e,mode:t}))}function fo(e,t=ut,r){return As(e,t,r??Qt(e,"floating"))}function po(e,t,r=ut,a){return Zs(e,t,r,a??Qt(t,"inline"))}function mo(e,t,r=ut,a){return Rs(e,t,r,a??Qt(t,"floating"))}function go(e){ca(e)}exports.ApiClient=qr;exports.Composer=ba;exports.ErrorState=zt;exports.EventEmitter=ta;exports.Header=fa;exports.Launcher=_a;exports.MessageBubble=ma;exports.MessageList=va;exports.TypingIndicator=ga;exports.WidgetApp=Ut;exports.WidgetClient=aa;exports.WidgetShell=Dt;exports.buildThemeVars=da;exports.buildWidgetCSS=wa;exports.clearSession=Vt;exports.createFloatingContainer=oa;exports.createShadowHost=na;exports.createWidget=dt;exports.destroy=go;exports.destroyWidget=ca;exports.getSessionId=ra;exports.init=fo;exports.injectStyles=ia;exports.listWidgets=Os;exports.mount=po;exports.mountFloating=mo;exports.normalizeConfig=Ie;exports.prepareInlineContainer=la;exports.removeShadowHost=sa;exports.renderWidget=ut;exports.resolveThemeMode=ua;exports.setSessionId=Ae;exports.streamChat=ea;exports.widgetCSS=ha;
|