@bymos/agentkit-sdk 0.6.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -33
- package/agentkit-widget.iife.js +119 -94
- package/agentkit-widget.js +2239 -1994
- package/index.cjs +120 -95
- package/index.d.ts +22 -4
- package/index.js +3033 -2767
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let va=require("preact/compat/client"),E=require("preact/compat"),o=require("preact/jsx-runtime");var A;(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(c=>typeof n[n[c]]!="number"),s={};for(const c of i)s[c]=n[c];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})(A||(A={}));var Gt;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Gt||(Gt={}));var x=A.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 x.undefined;case"string":return x.string;case"number":return Number.isNaN(e)?x.nan:x.number;case"boolean":return x.boolean;case"function":return x.function;case"bigint":return x.bigint;case"symbol":return x.symbol;case"object":return Array.isArray(e)?x.array:e===null?x.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?x.promise:typeof Map<"u"&&e instanceof Map?x.map:typeof Set<"u"&&e instanceof Set?x.set:typeof Date<"u"&&e instanceof Date?x.date:x.object;default:return x.unknown}},f=A.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"]),te=class pr 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 c=a,l=0;for(;l<s.path.length;){const d=s.path[l];l!==s.path.length-1?c[d]=c[d]||{_errors:[]}:(c[d]=c[d]||{_errors:[]},c[d]._errors.push(r(s))),c=c[d],l++}}};return n(this),a}static assert(t){if(!(t instanceof pr))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,A.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()}};te.create=e=>new te(e);var Ae=(e,t)=>{let r;switch(e.code){case f.invalid_type:e.received===x.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case f.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,A.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:r=`Unrecognized key(s) in object: ${A.joinValues(e.keys,", ")}`;break;case f.invalid_union:r="Invalid input";break;case f.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${A.joinValues(e.options)}`;break;case f.invalid_enum_value:r=`Invalid enum value. Expected ${A.joinValues(e.options)}, received '${e.received}'`;break;case f.invalid_arguments:r="Invalid function arguments";break;case f.invalid_return_type:r="Invalid function return type";break;case f.invalid_date:r="Invalid date";break;case f.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}"`:A.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case f.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 f.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 f.custom:r="Invalid input";break;case f.invalid_intersection_types:r="Intersection results could not be merged";break;case f.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case f.not_finite:r="Number must be finite";break;default:r=t.defaultError,A.assertNever(e)}return{message:r}},ka=Ae;function pt(){return ka}var mt=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 c="";const l=a.filter(d=>!!d).slice().reverse();for(const d of l)c=d(s,{data:t,defaultError:c}).message;return{...n,path:i,message:c}};function v(e,t){const r=pt(),a=mt({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Ae?void 0:Ae].filter(n=>!!n)});e.common.issues.push(a)}var Y=class mr{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 w;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 mr.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 w;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}}},w=Object.freeze({status:"aborted"}),Te=e=>({status:"dirty",value:e}),D=e=>({status:"valid",value:e}),Ht=e=>e.status==="aborted",Yt=e=>e.status==="dirty",je=e=>e.status==="valid",He=e=>typeof Promise<"u"&&e instanceof Promise,_;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(_||(_={}));var re=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}},Xt=(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 te(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,c)=>{const{message:l}=e;return s.code==="invalid_enum_value"?{message:l??c.defaultError}:typeof c.data>"u"?{message:l??a??c.defaultError}:s.code!=="invalid_type"?{message:c.defaultError}:{message:l??r??c.defaultError}},description:n}}var L=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(He(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 Xt(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)},a=this._parse({data:e,path:r.path,parent:r});return Xt(r,await(He(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:f.custom,...r(a)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!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 le({schema:this,typeName:j.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 oe.create(this,this._def)}nullable(){return me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Se.create(this)}promise(){return Me.create(this,this._def)}or(e){return Qe.create([this,e],this._def)}and(e){return Ke.create(this,e,this._def)}transform(e){return new le({...I(this._def),schema:this,typeName:j.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new rt({...I(this._def),innerType:this,defaultValue:t,typeName:j.ZodDefault})}brand(){return new _r({typeName:j.ZodBranded,type:this,...I(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new at({...I(this._def),innerType:this,catchValue:t,typeName:j.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return wr.create(this,e)}readonly(){return nt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},xa=/^c[^\s-]{8,}$/i,ba=/^[0-9a-z]+$/,ya=/^[0-9A-HJKMNP-TV-Z]{26}$/i,_a=/^[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,wa=/^[a-z0-9_-]{21}$/i,ja=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Sa=/^[-+]?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)?)??$/,Ca=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ia="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ct,Na=/^(?:(?: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])$/,Ta=/^(?:(?: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])$/,La=/^(([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]))$/,Ea=/^(([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])$/,Aa=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ma=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,gr="((\\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])))",Ra=new RegExp(`^${gr}$`);function vr(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 Za(e){return new RegExp(`^${vr(e)}$`)}function Oa(e){let t=`${gr}T${vr(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 Fa(e,t){return!!((t==="v4"||!t)&&Na.test(e)||(t==="v6"||!t)&&La.test(e))}function Pa(e,t){if(!ja.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 Va(e,t){return!!((t==="v4"||!t)&&Ta.test(e)||(t==="v6"||!t)&&Ea.test(e))}var Ye=class Le extends L{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==x.string){const n=this._getOrReturnCtx(t);return v(n,{code:f.invalid_type,expected:x.string,received:n.parsedType}),w}const r=new Y;let a;for(const n of this._def.checks)if(n.kind==="min")t.data.length<n.value&&(a=this._getOrReturnCtx(t,a),v(a,{code:f.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),v(a,{code:f.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?v(a,{code:f.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):s&&v(a,{code:f.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),r.dirty())}else if(n.kind==="email")Ca.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"email",code:f.invalid_string,message:n.message}),r.dirty());else if(n.kind==="emoji")ct||(ct=new RegExp(Ia,"u")),ct.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"emoji",code:f.invalid_string,message:n.message}),r.dirty());else if(n.kind==="uuid")_a.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"uuid",code:f.invalid_string,message:n.message}),r.dirty());else if(n.kind==="nanoid")wa.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"nanoid",code:f.invalid_string,message:n.message}),r.dirty());else if(n.kind==="cuid")xa.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"cuid",code:f.invalid_string,message:n.message}),r.dirty());else if(n.kind==="cuid2")ba.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"cuid2",code:f.invalid_string,message:n.message}),r.dirty());else if(n.kind==="ulid")ya.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"ulid",code:f.invalid_string,message:n.message}),r.dirty());else if(n.kind==="url")try{new URL(t.data)}catch{a=this._getOrReturnCtx(t,a),v(a,{validation:"url",code:f.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),v(a,{validation:"regex",code:f.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),v(a,{code:f.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),v(a,{code:f.invalid_string,validation:{startsWith:n.value},message:n.message}),r.dirty()):n.kind==="endsWith"?t.data.endsWith(n.value)||(a=this._getOrReturnCtx(t,a),v(a,{code:f.invalid_string,validation:{endsWith:n.value},message:n.message}),r.dirty()):n.kind==="datetime"?Oa(n).test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{code:f.invalid_string,validation:"datetime",message:n.message}),r.dirty()):n.kind==="date"?Ra.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{code:f.invalid_string,validation:"date",message:n.message}),r.dirty()):n.kind==="time"?Za(n).test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{code:f.invalid_string,validation:"time",message:n.message}),r.dirty()):n.kind==="duration"?Sa.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"duration",code:f.invalid_string,message:n.message}),r.dirty()):n.kind==="ip"?Fa(t.data,n.version)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"ip",code:f.invalid_string,message:n.message}),r.dirty()):n.kind==="jwt"?Pa(t.data,n.alg)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"jwt",code:f.invalid_string,message:n.message}),r.dirty()):n.kind==="cidr"?Va(t.data,n.version)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"cidr",code:f.invalid_string,message:n.message}),r.dirty()):n.kind==="base64"?Aa.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"base64",code:f.invalid_string,message:n.message}),r.dirty()):n.kind==="base64url"?Ma.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"base64url",code:f.invalid_string,message:n.message}),r.dirty()):A.assertNever(n);return{status:r.value,value:t.data}}_regex(t,r,a){return this.refinement(n=>t.test(n),{validation:r,code:f.invalid_string,..._.errToObj(a)})}_addCheck(t){return new Le({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",..._.errToObj(t)})}url(t){return this._addCheck({kind:"url",..._.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",..._.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",..._.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",..._.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",..._.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",..._.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",..._.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",..._.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",..._.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",..._.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",..._.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",..._.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,..._.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,..._.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",..._.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,..._.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,..._.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,..._.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,..._.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,..._.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,..._.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,..._.errToObj(r)})}nonempty(t){return this.min(1,_.errToObj(t))}trim(){return new Le({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Le({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Le({...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}};Ye.create=e=>new Ye({checks:[],typeName:j.ZodString,coerce:e?.coerce??!1,...I(e)});function Wa(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 gt=class vt extends L{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)!==x.number){const n=this._getOrReturnCtx(t);return v(n,{code:f.invalid_type,expected:x.number,received:n.parsedType}),w}let r;const a=new Y;for(const n of this._def.checks)n.kind==="int"?A.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),v(r,{code:f.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),v(r,{code:f.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),v(r,{code:f.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind==="multipleOf"?Wa(t.data,n.value)!==0&&(r=this._getOrReturnCtx(t,r),v(r,{code:f.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):n.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),v(r,{code:f.not_finite,message:n.message}),a.dirty()):A.assertNever(n);return{status:a.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,_.toString(r))}gt(t,r){return this.setLimit("min",t,!1,_.toString(r))}lte(t,r){return this.setLimit("max",t,!0,_.toString(r))}lt(t,r){return this.setLimit("max",t,!1,_.toString(r))}setLimit(t,r,a,n){return new vt({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:_.toString(n)}]})}_addCheck(t){return new vt({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:_.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:_.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:_.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_.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"&&A.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)}};gt.create=e=>new gt({checks:[],typeName:j.ZodNumber,coerce:e?.coerce||!1,...I(e)});var kt=class xt extends L{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)!==x.bigint)return this._getInvalidInput(t);let r;const a=new Y;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),v(r,{code:f.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),v(r,{code:f.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),v(r,{code:f.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):A.assertNever(n);return{status:a.value,value:t.data}}_getInvalidInput(t){const r=this._getOrReturnCtx(t);return v(r,{code:f.invalid_type,expected:x.bigint,received:r.parsedType}),w}gte(t,r){return this.setLimit("min",t,!0,_.toString(r))}gt(t,r){return this.setLimit("min",t,!1,_.toString(r))}lte(t,r){return this.setLimit("max",t,!0,_.toString(r))}lt(t,r){return this.setLimit("max",t,!1,_.toString(r))}setLimit(t,r,a,n){return new xt({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:_.toString(n)}]})}_addCheck(t){return new xt({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:_.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:_.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}};kt.create=e=>new kt({checks:[],typeName:j.ZodBigInt,coerce:e?.coerce??!1,...I(e)});var bt=class extends L{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==x.boolean){const t=this._getOrReturnCtx(e);return v(t,{code:f.invalid_type,expected:x.boolean,received:t.parsedType}),w}return D(e.data)}};bt.create=e=>new bt({typeName:j.ZodBoolean,coerce:e?.coerce||!1,...I(e)});var yt=class kr extends L{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==x.date){const n=this._getOrReturnCtx(t);return v(n,{code:f.invalid_type,expected:x.date,received:n.parsedType}),w}if(Number.isNaN(t.data.getTime()))return v(this._getOrReturnCtx(t),{code:f.invalid_date}),w;const r=new Y;let a;for(const n of this._def.checks)n.kind==="min"?t.data.getTime()<n.value&&(a=this._getOrReturnCtx(t,a),v(a,{code:f.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),v(a,{code:f.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),r.dirty()):A.assertNever(n);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new kr({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:_.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:_.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}};yt.create=e=>new yt({checks:[],coerce:e?.coerce||!1,typeName:j.ZodDate,...I(e)});var _t=class extends L{_parse(e){if(this._getType(e)!==x.symbol){const t=this._getOrReturnCtx(e);return v(t,{code:f.invalid_type,expected:x.symbol,received:t.parsedType}),w}return D(e.data)}};_t.create=e=>new _t({typeName:j.ZodSymbol,...I(e)});var Xe=class extends L{_parse(e){if(this._getType(e)!==x.undefined){const t=this._getOrReturnCtx(e);return v(t,{code:f.invalid_type,expected:x.undefined,received:t.parsedType}),w}return D(e.data)}};Xe.create=e=>new Xe({typeName:j.ZodUndefined,...I(e)});var Je=class extends L{_parse(e){if(this._getType(e)!==x.null){const t=this._getOrReturnCtx(e);return v(t,{code:f.invalid_type,expected:x.null,received:t.parsedType}),w}return D(e.data)}};Je.create=e=>new Je({typeName:j.ZodNull,...I(e)});var wt=class extends L{constructor(){super(...arguments),this._any=!0}_parse(e){return D(e.data)}};wt.create=e=>new wt({typeName:j.ZodAny,...I(e)});var _e=class extends L{constructor(){super(...arguments),this._unknown=!0}_parse(e){return D(e.data)}};_e.create=e=>new _e({typeName:j.ZodUnknown,...I(e)});var he=class extends L{_parse(e){const t=this._getOrReturnCtx(e);return v(t,{code:f.invalid_type,expected:x.never,received:t.parsedType}),w}};he.create=e=>new he({typeName:j.ZodNever,...I(e)});var jt=class extends L{_parse(e){if(this._getType(e)!==x.undefined){const t=this._getOrReturnCtx(e);return v(t,{code:f.invalid_type,expected:x.void,received:t.parsedType}),w}return D(e.data)}};jt.create=e=>new jt({typeName:j.ZodVoid,...I(e)});var Se=class Ue extends L{_parse(t){const{ctx:r,status:a}=this._processInputParams(t),n=this._def;if(r.parsedType!==x.array)return v(r,{code:f.invalid_type,expected:x.array,received:r.parsedType}),w;if(n.exactLength!==null){const s=r.data.length>n.exactLength.value,c=r.data.length<n.exactLength.value;(s||c)&&(v(r,{code:s?f.too_big:f.too_small,minimum:c?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&&(v(r,{code:f.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&&(v(r,{code:f.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,c)=>n.type._parseAsync(new re(r,s,r.path,c)))).then(s=>Y.mergeArray(a,s));const i=[...r.data].map((s,c)=>n.type._parseSync(new re(r,s,r.path,c)));return Y.mergeArray(a,i)}get element(){return this._def.type}min(t,r){return new Ue({...this._def,minLength:{value:t,message:_.toString(r)}})}max(t,r){return new Ue({...this._def,maxLength:{value:t,message:_.toString(r)}})}length(t,r){return new Ue({...this._def,exactLength:{value:t,message:_.toString(r)}})}nonempty(t){return this.min(1,t)}};Se.create=(e,t)=>new Se({type:e,minLength:null,maxLength:null,exactLength:null,typeName:j.ZodArray,...I(t)});function ye(e){if(e instanceof q){const t={};for(const r in e.shape){const a=e.shape[r];t[r]=oe.create(ye(a))}return new q({...e._def,shape:()=>t})}else return e instanceof Se?new Se({...e._def,type:ye(e.element)}):e instanceof oe?oe.create(ye(e.unwrap())):e instanceof me?me.create(ye(e.unwrap())):e instanceof pe?pe.create(e.items.map(t=>ye(t))):e}var q=class Q extends L{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=A.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==x.object){const l=this._getOrReturnCtx(t);return v(l,{code:f.invalid_type,expected:x.object,received:l.parsedType}),w}const{status:r,ctx:a}=this._processInputParams(t),{shape:n,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof he&&this._def.unknownKeys==="strip"))for(const l in a.data)i.includes(l)||s.push(l);const c=[];for(const l of i){const d=n[l],u=a.data[l];c.push({key:{status:"valid",value:l},value:d._parse(new re(a,u,a.path,l)),alwaysSet:l in a.data})}if(this._def.catchall instanceof he){const l=this._def.unknownKeys;if(l==="passthrough")for(const d of s)c.push({key:{status:"valid",value:d},value:{status:"valid",value:a.data[d]}});else if(l==="strict")s.length>0&&(v(a,{code:f.unrecognized_keys,keys:s}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const d of s){const u=a.data[d];c.push({key:{status:"valid",value:d},value:l._parse(new re(a,u,a.path,d)),alwaysSet:d in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const l=[];for(const d of c){const u=await d.key,h=await d.value;l.push({key:u,value:h,alwaysSet:d.alwaysSet})}return l}).then(l=>Y.mergeObjectSync(r,l)):Y.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(t){return _.errToObj,new Q({...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:_.errToObj(t).message??n}:{message:n}}}:{}})}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:j.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new Q({...this._def,catchall:t})}pick(t){const r={};for(const a of A.objectKeys(t))t[a]&&this.shape[a]&&(r[a]=this.shape[a]);return new Q({...this._def,shape:()=>r})}omit(t){const r={};for(const a of A.objectKeys(this.shape))t[a]||(r[a]=this.shape[a]);return new Q({...this._def,shape:()=>r})}deepPartial(){return ye(this)}partial(t){const r={};for(const a of A.objectKeys(this.shape)){const n=this.shape[a];t&&!t[a]?r[a]=n:r[a]=n.optional()}return new Q({...this._def,shape:()=>r})}required(t){const r={};for(const a of A.objectKeys(this.shape))if(t&&!t[a])r[a]=this.shape[a];else{let n=this.shape[a];for(;n instanceof oe;)n=n._def.innerType;r[a]=n}return new Q({...this._def,shape:()=>r})}keyof(){return yr(A.objectKeys(this.shape))}};q.create=(e,t)=>new q({shape:()=>e,unknownKeys:"strip",catchall:he.create(),typeName:j.ZodObject,...I(t)});q.strictCreate=(e,t)=>new q({shape:()=>e,unknownKeys:"strict",catchall:he.create(),typeName:j.ZodObject,...I(t)});q.lazycreate=(e,t)=>new q({shape:e,unknownKeys:"strip",catchall:he.create(),typeName:j.ZodObject,...I(t)});var Qe=class extends L{_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 te(s.ctx.common.issues));return v(t,{code:f.invalid_union,unionErrors:i}),w}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 c of r){const l={...t,common:{...t.common,issues:[]},parent:null},d=c._parseSync({data:t.data,path:t.path,parent:l});if(d.status==="valid")return d;d.status==="dirty"&&!n&&(n={result:d,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;const s=i.map(c=>new te(c));return v(t,{code:f.invalid_union,unionErrors:s}),w}}get options(){return this._def.options}};Qe.create=(e,t)=>new Qe({options:e,typeName:j.ZodUnion,...I(t)});var ie=e=>e instanceof qe?ie(e.schema):e instanceof le?ie(e.innerType()):e instanceof et?[e.value]:e instanceof st?e.options:e instanceof tt?A.objectValues(e.enum):e instanceof rt?ie(e._def.innerType):e instanceof Xe?[void 0]:e instanceof Je?[null]:e instanceof oe?[void 0,...ie(e.unwrap())]:e instanceof me?[null,...ie(e.unwrap())]:e instanceof _r||e instanceof nt?ie(e.unwrap()):e instanceof at?ie(e._def.innerType):[],$a=class xr extends L{_parse(t){const{ctx:r}=this._processInputParams(t);if(r.parsedType!==x.object)return v(r,{code:f.invalid_type,expected:x.object,received:r.parsedType}),w;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}):(v(r,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),w)}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=ie(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 c of s){if(n.has(c))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(c)}`);n.set(c,i)}}return new xr({typeName:j.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:n,...I(a)})}};function St(e,t){const r=ue(e),a=ue(t);if(e===t)return{valid:!0,data:e};if(r===x.object&&a===x.object){const n=A.objectKeys(t),i=A.objectKeys(e).filter(c=>n.indexOf(c)!==-1),s={...e,...t};for(const c of i){const l=St(e[c],t[c]);if(!l.valid)return{valid:!1};s[c]=l.data}return{valid:!0,data:s}}else if(r===x.array&&a===x.array){if(e.length!==t.length)return{valid:!1};const n=[];for(let i=0;i<e.length;i++){const s=e[i],c=t[i],l=St(s,c);if(!l.valid)return{valid:!1};n.push(l.data)}return{valid:!0,data:n}}else return r===x.date&&a===x.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Ke=class extends L{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),a=(n,i)=>{if(Ht(n)||Ht(i))return w;const s=St(n.value,i.value);return s.valid?((Yt(n)||Yt(i))&&t.dirty(),{status:t.value,value:s.data}):(v(r,{code:f.invalid_intersection_types}),w)};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}))}};Ke.create=(e,t,r)=>new Ke({left:e,right:t,typeName:j.ZodIntersection,...I(r)});var pe=class br extends L{_parse(t){const{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==x.array)return v(a,{code:f.invalid_type,expected:x.array,received:a.parsedType}),w;if(a.data.length<this._def.items.length)return v(a,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),w;!this._def.rest&&a.data.length>this._def.items.length&&(v(a,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const n=[...a.data].map((i,s)=>{const c=this._def.items[s]||this._def.rest;return c?c._parse(new re(a,i,a.path,s)):null}).filter(i=>!!i);return a.common.async?Promise.all(n).then(i=>Y.mergeArray(r,i)):Y.mergeArray(r,n)}get items(){return this._def.items}rest(t){return new br({...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:j.ZodTuple,rest:null,...I(t)})};var za=class Ct extends L{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!==x.object)return v(a,{code:f.invalid_type,expected:x.object,received:a.parsedType}),w;const n=[],i=this._def.keyType,s=this._def.valueType;for(const c in a.data)n.push({key:i._parse(new re(a,c,a.path,c)),value:s._parse(new re(a,a.data[c],a.path,c)),alwaysSet:c in a.data});return a.common.async?Y.mergeObjectAsync(r,n):Y.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(t,r,a){return r instanceof L?new Ct({keyType:t,valueType:r,typeName:j.ZodRecord,...I(a)}):new Ct({keyType:Ye.create(),valueType:t,typeName:j.ZodRecord,...I(r)})}},It=class extends L{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!==x.map)return v(r,{code:f.invalid_type,expected:x.map,received:r.parsedType}),w;const a=this._def.keyType,n=this._def.valueType,i=[...r.data.entries()].map(([s,c],l)=>({key:a._parse(new re(r,s,r.path,[l,"key"])),value:n._parse(new re(r,c,r.path,[l,"value"]))}));if(r.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,d=await c.value;if(l.status==="aborted"||d.status==="aborted")return w;(l.status==="dirty"||d.status==="dirty")&&t.dirty(),s.set(l.value,d.value)}return{status:t.value,value:s}})}else{const s=new Map;for(const c of i){const l=c.key,d=c.value;if(l.status==="aborted"||d.status==="aborted")return w;(l.status==="dirty"||d.status==="dirty")&&t.dirty(),s.set(l.value,d.value)}return{status:t.value,value:s}}}};It.create=(e,t,r)=>new It({valueType:t,keyType:e,typeName:j.ZodMap,...I(r)});var Nt=class Tt extends L{_parse(t){const{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==x.set)return v(a,{code:f.invalid_type,expected:x.set,received:a.parsedType}),w;const n=this._def;n.minSize!==null&&a.data.size<n.minSize.value&&(v(a,{code:f.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&&(v(a,{code:f.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(l){const d=new Set;for(const u of l){if(u.status==="aborted")return w;u.status==="dirty"&&r.dirty(),d.add(u.value)}return{status:r.value,value:d}}const c=[...a.data.values()].map((l,d)=>i._parse(new re(a,l,a.path,d)));return a.common.async?Promise.all(c).then(l=>s(l)):s(c)}min(t,r){return new Tt({...this._def,minSize:{value:t,message:_.toString(r)}})}max(t,r){return new Tt({...this._def,maxSize:{value:t,message:_.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};Nt.create=(e,t)=>new Nt({valueType:e,minSize:null,maxSize:null,typeName:j.ZodSet,...I(t)});var Da=class Be extends L{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:r}=this._processInputParams(t);if(r.parsedType!==x.function)return v(r,{code:f.invalid_type,expected:x.function,received:r.parsedType}),w;function a(c,l){return mt({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,pt(),Ae].filter(d=>!!d),issueData:{code:f.invalid_arguments,argumentsError:l}})}function n(c,l){return mt({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,pt(),Ae].filter(d=>!!d),issueData:{code:f.invalid_return_type,returnTypeError:l}})}const i={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof Me){const c=this;return D(async function(...l){const d=new te([]),u=await c._def.args.parseAsync(l,i).catch(p=>{throw d.addIssue(a(l,p)),d}),h=await Reflect.apply(s,this,u);return await c._def.returns._def.type.parseAsync(h,i).catch(p=>{throw d.addIssue(n(h,p)),d})})}else{const c=this;return D(function(...l){const d=c._def.args.safeParse(l,i);if(!d.success)throw new te([a(l,d.error)]);const u=Reflect.apply(s,this,d.data),h=c._def.returns.safeParse(u,i);if(!h.success)throw new te([n(u,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new Be({...this._def,args:pe.create(t).rest(_e.create())})}returns(t){return new Be({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,a){return new Be({args:t||pe.create([]).rest(_e.create()),returns:r||_e.create(),typeName:j.ZodFunction,...I(a)})}},qe=class extends L{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})}};qe.create=(e,t)=>new qe({getter:e,typeName:j.ZodLazy,...I(t)});var et=class extends L{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return v(t,{received:t.data,code:f.invalid_literal,expected:this._def.value}),w}return{status:"valid",value:e.data}}get value(){return this._def.value}};et.create=(e,t)=>new et({value:e,typeName:j.ZodLiteral,...I(t)});function yr(e,t){return new st({values:e,typeName:j.ZodEnum,...I(t)})}var st=class Lt extends L{_parse(t){if(typeof t.data!="string"){const r=this._getOrReturnCtx(t),a=this._def.values;return v(r,{expected:A.joinValues(a),received:r.parsedType,code:f.invalid_type}),w}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 v(r,{received:r.data,code:f.invalid_enum_value,options:a}),w}return D(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 Lt.create(t,{...this._def,...r})}exclude(t,r=this._def){return Lt.create(this.options.filter(a=>!t.includes(a)),{...this._def,...r})}};st.create=yr;var tt=class extends L{_parse(e){const t=A.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==x.string&&r.parsedType!==x.number){const a=A.objectValues(t);return v(r,{expected:A.joinValues(a),received:r.parsedType,code:f.invalid_type}),w}if(this._cache||(this._cache=new Set(A.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=A.objectValues(t);return v(r,{received:r.data,code:f.invalid_enum_value,options:a}),w}return D(e.data)}get enum(){return this._def.values}};tt.create=(e,t)=>new tt({values:e,typeName:j.ZodNativeEnum,...I(t)});var Me=class extends L{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);return t.parsedType!==x.promise&&t.common.async===!1?(v(t,{code:f.invalid_type,expected:x.promise,received:t.parsedType}),w):D((t.parsedType===x.promise?t.data:Promise.resolve(t.data)).then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Me.create=(e,t)=>new Me({type:e,typeName:j.ZodPromise,...I(t)});var le=class extends L{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===j.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=>{v(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 w;const c=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return c.status==="aborted"?w:c.status==="dirty"||t.value==="dirty"?Te(c.value):c});{if(t.value==="aborted")return w;const s=this._def.schema._parseSync({data:i,path:r.path,parent:r});return s.status==="aborted"?w:s.status==="dirty"||t.value==="dirty"?Te(s.value):s}}if(a.type==="refinement"){const i=s=>{const c=a.refinement(s,n);if(r.common.async)return Promise.resolve(c);if(c 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"?w:(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"?w:(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(!je(i))return w;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=>je(i)?Promise.resolve(a.transform(i.value,n)).then(s=>({status:t.value,value:s})):w);A.assertNever(a)}};le.create=(e,t,r)=>new le({schema:e,typeName:j.ZodEffects,effect:t,...I(r)});le.createWithPreprocess=(e,t,r)=>new le({schema:t,effect:{type:"preprocess",transform:e},typeName:j.ZodEffects,...I(r)});var oe=class extends L{_parse(e){return this._getType(e)===x.undefined?D(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};oe.create=(e,t)=>new oe({innerType:e,typeName:j.ZodOptional,...I(t)});var me=class extends L{_parse(e){return this._getType(e)===x.null?D(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};me.create=(e,t)=>new me({innerType:e,typeName:j.ZodNullable,...I(t)});var rt=class extends L{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===x.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};rt.create=(e,t)=>new rt({innerType:e,typeName:j.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...I(t)});var at=class extends L{_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 He(a)?a.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new te(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new te(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};at.create=(e,t)=>new at({innerType:e,typeName:j.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...I(t)});var Et=class extends L{_parse(e){if(this._getType(e)!==x.nan){const t=this._getOrReturnCtx(e);return v(t,{code:f.invalid_type,expected:x.nan,received:t.parsedType}),w}return{status:"valid",value:e.data}}};Et.create=e=>new Et({typeName:j.ZodNaN,...I(e)});var _r=class extends L{_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}},wr=class jr extends L{_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"?w:i.status==="dirty"?(r.dirty(),Te(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"?w: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 jr({in:t,out:r,typeName:j.ZodPipeline})}},nt=class extends L{_parse(e){const t=this._def.innerType._parse(e),r=a=>(je(a)&&(a.value=Object.freeze(a.value)),a);return He(t)?t.then(a=>r(a)):r(t)}unwrap(){return this._def.innerType}};nt.create=(e,t)=>new nt({innerType:e,typeName:j.ZodReadonly,...I(t)});var Js={object:q.lazycreate},j;(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"})(j||(j={}));var F=Ye.create,Qs=gt.create,Ks=Et.create,qs=kt.create,dt=bt.create,eo=yt.create,to=_t.create,ro=Xe.create,ao=Je.create,no=wt.create,Ua=_e.create,io=he.create,so=jt.create,oo=Se.create,Vt=q.create,lo=q.strictCreate,co=Qe.create,uo=$a.create,ho=Ke.create,fo=pe.create,Ba=za.create,po=It.create,mo=Nt.create,go=Da.create,vo=qe.create,ko=et.create,Sr=st.create,xo=tt.create,bo=Me.create,yo=le.create,_o=oe.create,wo=me.create,jo=le.createWithPreprocess,So=wr.create,Ga=Vt({mode:Sr(["light","dark","system"]).optional(),accentColor:F().optional(),fontFamily:F().optional(),borderRadius:F().optional()}),Ha=Vt({externalId:F().optional(),authId:F().optional(),name:F().optional(),email:F().optional()}),Cr=Vt({agentId:F().min(1,"agentId is required"),apiBaseUrl:F().url("apiBaseUrl must be a valid URL"),tenantId:F().optional(),user:Ha.optional(),sessionId:F().optional(),mode:Sr(["floating","inline"]).optional(),title:F().optional(),subtitle:F().optional(),description:F().optional(),greeting:F().optional(),avatarUrl:F().optional(),privacyPolicyUrl:F().optional(),termsOfServiceUrl:F().optional(),streaming:dt().optional(),preview:dt().optional(),skipServerConfigFetch:dt().optional(),metadata:Ba(Ua()).optional(),theme:Ga.optional()}),Ya=Cr.omit({agentId:!0,apiBaseUrl:!0}).partial(),fe={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 ot(e,t){Cr.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?Ya.passthrough().safeParse(a).data:void 0,i=n?Ir(n,e):e,s={mode:i.theme?.mode??r?.mode??fe.theme.mode,accentColor:i.theme?.accentColor??r?.accentColor??fe.theme.accentColor,fontFamily:i.theme?.fontFamily??r?.fontFamily??fe.theme.fontFamily,borderRadius:i.theme?.borderRadius??r?.borderRadius??fe.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??fe.mode,title:i.title??fe.title,subtitle:i.subtitle,description:i.description,greeting:i.greeting,avatarUrl:i.avatarUrl,privacyPolicyUrl:i.privacyPolicyUrl,termsOfServiceUrl:i.termsOfServiceUrl,streaming:i.streaming??fe.streaming,preview:i.preview===!0,skipServerConfigFetch:i.skipServerConfigFetch===!0,metadata:i.metadata??{},theme:s,thinkingEnabled:n?.thinkingEnabled===!0,thinkingViewable:n?.thinkingViewable===!0,photoSendingEnabled:n?.photoSendingEnabled===!0,fileUploadEnabled:n?.fileUploadEnabled===!0,attachmentMaxCount:(()=>{const c=n?.attachmentMaxCount;return typeof c=="number"&&Number.isFinite(c)?c:5})(),attachmentMaxFileSizeMb:(()=>{const c=n?.attachmentMaxFileSizeMb;return typeof c=="number"&&Number.isFinite(c)?c:1})()}}function Ir(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]=Ir(r[a],n):r[a]=n)}return r}var At=function(){return At=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},At.apply(this,arguments)};function ae(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 c(u){try{d(a.next(u))}catch(h){s(h)}}function l(u){try{d(a.throw(u))}catch(h){s(h)}}function d(u){u.done?i(u.value):n(u.value).then(c,l)}d((a=a.apply(e,t||[])).next())})}function ne(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=c(0),s.throw=c(1),s.return=c(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(d){return function(u){return l([d,u])}}function l(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 Nr(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 Tr="4.6.2";function it(e,t){return new Promise(function(r){return setTimeout(r,e,t)})}function Xa(){return new Promise(function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})}function Ja(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})}):it(Math.min(e,t))}function Lr(e){return!!e&&typeof e.then=="function"}function Jt(e,t){try{var r=e();Lr(r)?r.then(function(a){return t(!0,a)},function(a){return t(!1,a)}):t(!0,r)}catch(a){t(!1,a)}}function Qt(e,t,r){return r===void 0&&(r=16),ae(this,void 0,void 0,function(){var a,n,i,s;return ne(this,function(c){switch(c.label){case 0:a=Array(e.length),n=Date.now(),i=0,c.label=1;case 1:return i<e.length?(a[i]=t(e[i],i),s=Date.now(),s>=n+r?(n=s,[4,Xa()]):[3,3]):[3,4];case 2:c.sent(),c.label=3;case 3:return++i,[3,1];case 4:return[2,a]}})})}function Re(e){return e.then(void 0,function(){}),e}function Qa(e,t){for(var r=0,a=e.length;r<a;++r)if(e[r]===t)return!0;return!1}function Ka(e,t){return!Qa(e,t)}function Wt(e){return parseInt(e)}function K(e){return parseFloat(e)}function se(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 Er(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 qa(e){for(var t,r,a="Unexpected syntax '".concat(e,"'"),n=/^\s*([a-z-]*)(.*)$/i.exec(e),i=n[1]||void 0,s={},c=/([.:#][\w-]+|\[.+?\])/gi,l=function(p,g){s[p]=s[p]||[],s[p].push(g)};;){var d=c.exec(n[2]);if(!d)break;var u=d[0];switch(u[0]){case".":l("class",u.slice(1));break;case"#":l("id",u.slice(1));break;case"[":var h=/^\[([\w-]+)([~|^$*]?=("(.*?)"|([\w-]+)))?(\s+[is])?\]$/.exec(u);if(h)l(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 en(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 de(e,t){var r=e[0]>>>16,a=e[0]&65535,n=e[1]>>>16,i=e[1]&65535,s=t[0]>>>16,c=t[0]&65535,l=t[1]>>>16,d=t[1]&65535,u=0,h=0,p=0,g=0;g+=i+d,p+=g>>>16,g&=65535,p+=n+l,h+=p>>>16,p&=65535,h+=a+c,u+=h>>>16,h&=65535,u+=r+s,u&=65535,e[0]=u<<16|h,e[1]=p<<16|g}function X(e,t){var r=e[0]>>>16,a=e[0]&65535,n=e[1]>>>16,i=e[1]&65535,s=t[0]>>>16,c=t[0]&65535,l=t[1]>>>16,d=t[1]&65535,u=0,h=0,p=0,g=0;g+=i*d,p+=g>>>16,g&=65535,p+=n*d,h+=p>>>16,p&=65535,p+=i*l,h+=p>>>16,p&=65535,h+=a*d,u+=h>>>16,h&=65535,h+=n*l,u+=h>>>16,h&=65535,h+=i*c,u+=h>>>16,h&=65535,u+=r*d+a*l+n*c+i*s,u&=65535,e[0]=u<<16|h,e[1]=p<<16|g}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 tn=[4283543511,3981806797],rn=[3301882366,444984403];function Kt(e){var t=[0,e[0]>>>1];Z(e,t),X(e,tn),t[1]=e[0]>>>1,Z(e,t),X(e,rn),t[1]=e[0]>>>1,Z(e,t)}var ze=[2277735313,289559509],De=[1291169091,658871167],qt=[0,5],an=[0,1390208809],nn=[0,944331445];function sn(e,t){var r=en(e);t=t||0;var a=[0,r.length],n=a[1]%16,i=a[1]-n,s=[0,t],c=[0,t],l=[0,0],d=[0,0],u;for(u=0;u<i;u=u+16)l[0]=r[u+4]|r[u+5]<<8|r[u+6]<<16|r[u+7]<<24,l[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(l,ze),ve(l,31),X(l,De),Z(s,l),ve(s,27),de(s,c),X(s,qt),de(s,an),X(d,De),ve(d,33),X(d,ze),Z(c,d),ve(c,31),de(c,s),X(c,qt),de(c,nn);l[0]=0,l[1]=0,d[0]=0,d[1]=0;var h=[0,0];switch(n){case 15:h[1]=r[u+14],G(h,48),Z(d,h);case 14:h[1]=r[u+13],G(h,40),Z(d,h);case 13:h[1]=r[u+12],G(h,32),Z(d,h);case 12:h[1]=r[u+11],G(h,24),Z(d,h);case 11:h[1]=r[u+10],G(h,16),Z(d,h);case 10:h[1]=r[u+9],G(h,8),Z(d,h);case 9:h[1]=r[u+8],Z(d,h),X(d,De),ve(d,33),X(d,ze),Z(c,d);case 8:h[1]=r[u+7],G(h,56),Z(l,h);case 7:h[1]=r[u+6],G(h,48),Z(l,h);case 6:h[1]=r[u+5],G(h,40),Z(l,h);case 5:h[1]=r[u+4],G(h,32),Z(l,h);case 4:h[1]=r[u+3],G(h,24),Z(l,h);case 3:h[1]=r[u+2],G(h,16),Z(l,h);case 2:h[1]=r[u+1],G(h,8),Z(l,h);case 1:h[1]=r[u],Z(l,h),X(l,ze),ve(l,31),X(l,De),Z(s,l)}return Z(s,a),Z(c,a),de(s,c),de(c,s),Kt(s),Kt(c),de(s,c),de(c,s),("00000000"+(s[0]>>>0).toString(16)).slice(-8)+("00000000"+(s[1]>>>0).toString(16)).slice(-8)+("00000000"+(c[0]>>>0).toString(16)).slice(-8)+("00000000"+(c[1]>>>0).toString(16)).slice(-8)}function on(e){var t;return At({name:e.name,message:e.message,stack:(t=e.stack)===null||t===void 0?void 0:t.split(`
|
|
2
|
-
`)},e)}function ln(e){return/^function\s.*?\{\s*\[native code]\s*}$/.test(String(e))}function cn(e){return typeof e!="function"}function dn(e,t){var r=Re(new Promise(function(a){var n=Date.now();Jt(e.bind(null,t),function(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];var c=Date.now()-n;if(!i[0])return a(function(){return{error:i[1],duration:c}});var l=i[1];if(cn(l))return a(function(){return{value:l,duration:c}});a(function(){return new Promise(function(d){var u=Date.now();Jt(l,function(){for(var h=[],p=0;p<arguments.length;p++)h[p]=arguments[p];var g=c+Date.now()-u;if(!h[0])return d({error:h[1],duration:g});d({value:h[1],duration:g})})})})})}));return function(){return r.then(function(n){return n()})}}function un(e,t,r,a){var n=Object.keys(e).filter(function(s){return Ka(r,s)}),i=Re(Qt(n,function(s){return dn(e[s],t)},a));return function(){return ae(this,void 0,void 0,function(){var c,l,d,u,h;return ne(this,function(p){switch(p.label){case 0:return[4,i];case 1:return c=p.sent(),[4,Qt(c,function(g){return Re(g())},a)];case 2:return l=p.sent(),[4,Promise.all(l)];case 3:for(d=p.sent(),u={},h=0;h<n.length;++h)u[n[h]]=d[h];return[2,u]}})})}}function Ar(){var e=window,t=navigator;return z(["MSCSSMatrix"in e,"msSetImmediate"in e,"msIndexedDB"in e,"msMaxTouchPoints"in t,"msPointerEnabled"in t])>=4}function hn(){var e=window,t=navigator;return z(["msWriteProfilerMark"in e,"MSStream"in e,"msLaunchUri"in t,"msSaveBlob"in t])>=3&&!Ar()}function Ze(){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 ee(){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 $t(){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 Oe(){var e=window;return ln(e.print)&&String(e.browser)==="[object WebPageNamespace]"}function Mr(){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 fn(){var e=window;return z([!("MediaSettingsRange"in e),"RTCEncodedAudioFrame"in e,""+e.Intl=="[object Intl]",""+e.Reflect=="[object Reflect]"])>=3}function pn(){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 mn(){var e=window;return z(["DOMRectList"in e,"RTCPeerConnectionIceEvent"in e,"SVGGeometryElement"in e,"ontransitioncancel"in e])>=3}function Fe(){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 gn(){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 vn(){var e=document;return e.fullscreenElement||e.msFullscreenElement||e.mozFullScreenElement||e.webkitFullscreenElement||null}function kn(){var e=document;return(e.exitFullscreen||e.msExitFullscreen||e.mozCancelFullScreen||e.webkitExitFullscreen).call(e)}function zt(){var e=Ze(),t=Mr(),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 xn(){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 bn(){return wn()?-4:yn()}function yn(){var e=window,t=e.OfflineAudioContext||e.webkitOfflineAudioContext;if(!t)return-2;if(_n())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=jn(a),c=s[0],l=s[1],d=Re(c.then(function(u){return Sn(u.getChannelData(0).subarray(r))},function(u){if(u.name==="timeout"||u.name==="suspended")return-3;throw u}));return function(){return l(),d}}function _n(){return ee()&&!$t()&&!mn()}function wn(){return ee()&&Fe()&&Oe()||Ze()&&xn()&&pn()}function jn(e){var t=3,r=500,a=500,n=5e3,i=function(){};return[new Promise(function(s,c){var l=!1,d=0,u=0;e.oncomplete=function(g){return s(g.renderedBuffer)};var h=function(){setTimeout(function(){return c(er("timeout"))},Math.min(a,u+n-Date.now()))},p=function(){try{var g=e.startRendering();switch(Lr(g)&&Re(g),e.state){case"running":u=Date.now(),l&&h();break;case"suspended":document.hidden||d++,l&&d>=t?c(er("suspended")):setTimeout(p,r);break}}catch(m){c(m)}};p(),i=function(){l||(l=!0,u>0&&h())}}),i]}function Sn(e){for(var t=0,r=0;r<e.length;++r)t+=Math.abs(e[r]);return t}function er(e){var t=new Error(e);return t.name=e,t}function Rr(e,t,r){var a,n,i;return r===void 0&&(r=50),ae(this,void 0,void 0,function(){var s,c;return ne(this,function(l){switch(l.label){case 0:s=document,l.label=1;case 1:return s.body?[3,3]:[4,it(r)];case 2:return l.sent(),[3,1];case 3:c=s.createElement("iframe"),l.label=4;case 4:return l.trys.push([4,,10,11]),[4,new Promise(function(d,u){var h=!1,p=function(){h=!0,d()},g=function(b){h=!0,u(b)};c.onload=p,c.onerror=g;var m=c.style;m.setProperty("display","block","important"),m.position="absolute",m.top="0",m.left="0",m.visibility="hidden",t&&"srcdoc"in c?c.srcdoc=t:c.src="about:blank",s.body.appendChild(c);var k=function(){var b,y;h||(((y=(b=c.contentWindow)===null||b===void 0?void 0:b.document)===null||y===void 0?void 0:y.readyState)==="complete"?p():setTimeout(k,10))};k()})];case 5:l.sent(),l.label=6;case 6:return!((n=(a=c.contentWindow)===null||a===void 0?void 0:a.document)===null||n===void 0)&&n.body?[3,8]:[4,it(r)];case 7:return l.sent(),[3,6];case 8:return[4,e(c,c.contentWindow)];case 9:return[2,l.sent()];case 10:return(i=c.parentNode)===null||i===void 0||i.removeChild(c),[7];case 11:return[2]}})})}function Cn(e){for(var t=qa(e),r=t[0],a=t[1],n=document.createElement(r??"div"),i=0,s=Object.keys(a);i<s.length;i++){var c=s[i],l=a[c].join(" ");c==="style"?In(n.style,l):n.setAttribute(c,l)}return n}function In(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],c=i[2],l=i[4];e.setProperty(s,c,l||"")}}}function Nn(){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 Tn="mmMwWLliI0O&1",Ln="48px",ke=["monospace","sans-serif","serif"],tr=["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 En(){var e=this;return Rr(function(t,r){var a=r.document;return ae(e,void 0,void 0,function(){var n,i,s,c,l,d,u,h,p,g,m,k;return ne(this,function(b){for(n=a.body,n.style.fontSize=Ln,i=a.createElement("div"),i.style.setProperty("visibility","hidden","important"),s={},c={},l=function(y){var N=a.createElement("span"),R=N.style;return R.position="absolute",R.top="0",R.left="0",R.fontFamily=y,N.textContent=Tn,i.appendChild(N),N},d=function(y,N){return l("'".concat(y,"',").concat(N))},u=function(){return ke.map(l)},h=function(){for(var y={},N=function(V){y[V]=ke.map(function(C){return d(V,C)})},R=0,P=tr;R<P.length;R++){var U=P[R];N(U)}return y},p=function(y){return ke.some(function(N,R){return y[R].offsetWidth!==s[N]||y[R].offsetHeight!==c[N]})},g=u(),m=h(),n.appendChild(i),k=0;k<ke.length;k++)s[ke[k]]=g[k].offsetWidth,c[ke[k]]=g[k].offsetHeight;return[2,tr.filter(function(y){return p(m[y])})]})})})}function An(){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 Mn(){return Rn($n())}function Rn(e){var t,r=!1,a,n,i=Zn(),s=i[0],c=i[1];return On(s,c)?(r=Fn(c),e?a=n="skipped":(t=Pn(s,c),a=t[0],n=t[1])):a=n="unsupported",{winding:r,geometry:a,text:n}}function Zn(){var e=document.createElement("canvas");return e.width=1,e.height=1,[e,e.getContext("2d")]}function On(e,t){return!!(t&&e.toDataURL)}function Fn(e){return e.rect(0,0,10,10),e.rect(2,2,6,6),!e.isPointInPath(5,5,"evenodd")}function Pn(e,t){Vn(e,t);var r=ut(e);return r!==ut(e)?["unstable","unstable"]:(Wn(e,t),[ut(e),r])}function Vn(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 Wn(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],c=n[2];t.fillStyle=i,t.beginPath(),t.arc(s,c,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 ut(e){return e.toDataURL()}function $n(){return ee()&&Fe()&&Oe()}function zn(){var e=navigator,t=0,r;e.maxTouchPoints!==void 0?t=Wt(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 Dn(){return navigator.oscpu}function Un(){var e=navigator,t=[],r=e.language||e.userLanguage||e.browserLanguage||e.systemLanguage;if(r!==void 0&&t.push([r]),Array.isArray(e.languages))Ze()&&fn()||t.push(e.languages);else if(typeof e.languages=="string"){var a=e.languages;a&&t.push(a.split(","))}return t}function Bn(){return window.screen.colorDepth}function Gn(){return se(K(navigator.deviceMemory),void 0)}function Hn(){if(!(ee()&&Fe()&&Oe()))return Yn()}function Yn(){var e=screen,t=function(a){return se(Wt(a),null)},r=[t(e.width),t(e.height)];return r.sort().reverse(),r}var Xn=2500,Jn=10,Ge,ht;function Qn(){if(ht===void 0){var e=function(){var t=Mt();Rt(t)?ht=setTimeout(e,Xn):(Ge=t,ht=void 0)};e()}}function Kn(){var e=this;return Qn(),function(){return ae(e,void 0,void 0,function(){var t;return ne(this,function(r){switch(r.label){case 0:return t=Mt(),Rt(t)?Ge?[2,Nr([],Ge,!0)]:vn()?[4,kn()]:[3,2]:[3,2];case 1:r.sent(),t=Mt(),r.label=2;case 2:return Rt(t)||(Ge=t),[2,t]}})})}}function qn(){var e=this;if(ee()&&Fe()&&Oe())return function(){return Promise.resolve(void 0)};var t=Kn();return function(){return ae(e,void 0,void 0,function(){var r,a;return ne(this,function(n){switch(n.label){case 0:return[4,t()];case 1:return r=n.sent(),a=function(i){return i===null?null:Er(i,Jn)},[2,[a(r[0]),a(r[1]),a(r[2]),a(r[3])]]}})})}}function Mt(){var e=screen;return[se(K(e.availTop),null),se(K(e.width)-K(e.availWidth)-se(K(e.availLeft),0),null),se(K(e.height)-K(e.availHeight)-se(K(e.availTop),0),null),se(K(e.availLeft),null)]}function Rt(e){for(var t=0;t<4;++t)if(e[t])return!1;return!0}function ei(){return se(Wt(navigator.hardwareConcurrency),void 0)}function ti(){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=-ri();return"UTC".concat(a>=0?"+":"").concat(a)}function ri(){var e=new Date().getFullYear();return Math.max(K(new Date(e,0,1).getTimezoneOffset()),K(new Date(e,6,1).getTimezoneOffset()))}function ai(){try{return!!window.sessionStorage}catch{return!0}}function ni(){try{return!!window.localStorage}catch{return!0}}function ii(){if(!(Ar()||hn()))try{return!!window.indexedDB}catch{return!0}}function si(){return!!window.openDatabase}function oi(){return navigator.cpuClass}function li(){var e=navigator.platform;return e==="MacIntel"&&ee()&&!$t()?gn()?"iPad":"iPhone":e}function ci(){return navigator.vendor||""}function di(){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 ui(){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 hi(){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 fi(e){var t=(e===void 0?{}:e).debug;return ae(this,void 0,void 0,function(){var r,a,n,i,s,c;return ne(this,function(l){switch(l.label){case 0:return pi()?(r=hi(),a=Object.keys(r),n=(c=[]).concat.apply(c,a.map(function(d){return r[d]})),[4,mi(n)]):[2,void 0];case 1:return i=l.sent(),t&&gi(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 pi(){return ee()||zt()}function mi(e){var t;return ae(this,void 0,void 0,function(){var r,a,n,i,l,s,c,l;return ne(this,function(d){switch(d.label){case 0:for(r=document,a=r.createElement("div"),n=new Array(e.length),i={},rr(a),l=0;l<e.length;++l)s=Cn(e[l]),s.tagName==="DIALOG"&&s.show(),c=r.createElement("div"),rr(c),c.appendChild(s),a.appendChild(c),n[l]=s;d.label=1;case 1:return r.body?[3,3]:[4,it(50)];case 2:return d.sent(),[3,1];case 3:r.body.appendChild(a);try{for(l=0;l<e.length;++l)n[l].offsetParent||(i[e[l]]=!0)}finally{(t=a.parentNode)===null||t===void 0||t.removeChild(a)}return[2,i]}})})}function rr(e){e.style.setProperty("visibility","hidden","important"),e.style.setProperty("display","block","important")}function gi(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
|
-
`.concat(i,":");for(var s=0,
|
|
4
|
-
`.concat(t[l]?"🚫":"➡️"," ").concat(l)}}}function vi(){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 ki(){if(ar("inverted"))return!0;if(ar("none"))return!1}function ar(e){return matchMedia("(inverted-colors: ".concat(e,")")).matches}function xi(){if(nr("active"))return!0;if(nr("none"))return!1}function nr(e){return matchMedia("(forced-colors: ".concat(e,")")).matches}var bi=100;function yi(){if(matchMedia("(min-monochrome: 0)").matches){for(var e=0;e<=bi;++e)if(matchMedia("(max-monochrome: ".concat(e,")")).matches)return e;throw new Error("Too high value")}}function _i(){if(xe("no-preference"))return 0;if(xe("high")||xe("more"))return 1;if(xe("low")||xe("less"))return-1;if(xe("forced"))return 10}function xe(e){return matchMedia("(prefers-contrast: ".concat(e,")")).matches}function wi(){if(ir("reduce"))return!0;if(ir("no-preference"))return!1}function ir(e){return matchMedia("(prefers-reduced-motion: ".concat(e,")")).matches}function ji(){if(sr("reduce"))return!0;if(sr("no-preference"))return!1}function sr(e){return matchMedia("(prefers-reduced-transparency: ".concat(e,")")).matches}function Si(){if(or("high"))return!0;if(or("standard"))return!1}function or(e){return matchMedia("(dynamic-range: ".concat(e,")")).matches}var M=Math,$=function(){return 0};function Ci(){var e=M.acos||$,t=M.acosh||$,r=M.asin||$,a=M.asinh||$,n=M.atanh||$,i=M.atan||$,s=M.sin||$,c=M.sinh||$,l=M.cos||$,d=M.cosh||$,u=M.tan||$,h=M.tanh||$,p=M.exp||$,g=M.expm1||$,m=M.log1p||$,k=function(S){return M.pow(M.PI,S)},b=function(S){return M.log(S+M.sqrt(S*S-1))},y=function(S){return M.log(S+M.sqrt(S*S+1))},N=function(S){return M.log((1+S)/(1-S))/2},R=function(S){return M.exp(S)-1/M.exp(S)/2},P=function(S){return(M.exp(S)+1/M.exp(S))/2},U=function(S){return M.exp(S)-1},V=function(S){return(M.exp(2*S)-1)/(M.exp(2*S)+1)},C=function(S){return M.log(1+S)};return{acos:e(.12312423423423424),acosh:t(1e308),acoshPf:b(1e154),asin:r(.12312423423423424),asinh:a(1),asinhPf:y(1),atanh:n(.5),atanhPf:N(.5),atan:i(.5),sin:s(-1e300),sinh:c(1),sinhPf:R(1),cos:l(10.000000000123),cosh:d(1),coshPf:P(1),tan:u(-1e300),tanh:h(1),tanhPf:V(1),exp:p(1),expm1:g(1),expm1Pf:U(1),log1p:m(10),log1pPf:C(10),powPI:k(-100)}}var Ii="mmMwWLliI0fiflO&1",ft={default:[],apple:[{font:"-apple-system-body"}],serif:[{fontFamily:"serif"}],sans:[{fontFamily:"sans-serif"}],mono:[{fontFamily:"monospace"}],min:[{fontSize:"1px"}],system:[{fontFamily:"system-ui"}]};function Ni(){return Ti(function(e,t){for(var r={},a={},n=0,i=Object.keys(ft);n<i.length;n++){var s=i[n],c=ft[s],l=c[0],d=l===void 0?{}:l,u=c[1],h=u===void 0?Ii:u,p=e.createElement("span");p.textContent=h,p.style.whiteSpace="nowrap";for(var g=0,m=Object.keys(d);g<m.length;g++){var k=m[g],b=d[k];b!==void 0&&(p.style[k]=b)}r[s]=p,t.append(e.createElement("br"),p)}for(var y=0,N=Object.keys(ft);y<N.length;y++){var s=N[y];a[s]=r[s].getBoundingClientRect().width}return a})}function Ti(e,t){return t===void 0&&(t=4e3),Rr(function(r,a){var n=a.document,i=n.body,s=i.style;s.width="".concat(t,"px"),s.webkitTextSizeAdjust=s.textSizeAdjust="none",Ze()?i.style.zoom="".concat(1/a.devicePixelRatio):ee()&&(i.style.zoom="reset");var c=n.createElement("div");return c.textContent=Nr([],Array(t/20<<0),!0).map(function(){return"word"}).join(" "),i.appendChild(c),e(n,i)},'<!doctype html><html><head><meta name="viewport" content="width=device-width, initial-scale=1">')}function Li(){return navigator.pdfViewerEnabled}function Ei(){var e=new Float32Array(1),t=new Uint8Array(e.buffer);return e[0]=1/0,e[0]=e[0]-e[0],t[3]}function Ai(){var e=window.ApplePaySession;if(typeof e?.canMakePayments!="function")return-1;if(Mi())return-3;try{return e.canMakePayments()?1:0}catch(t){return Ri(t)}}var Mi=Nn;function Ri(e){if(e instanceof Error&&e.name==="InvalidAccessError"&&/\bfrom\b.*\binsecure\b/i.test(e.message))return-2;throw e}function Zi(){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 Zr=-1,Or=-2,Oi=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]),Fi=new Set([34047,35723,36063,34852,34853,34854,34229,36392,36795,38449]),Pi=["FRAGMENT_SHADER","VERTEX_SHADER"],Vi=["LOW_FLOAT","MEDIUM_FLOAT","HIGH_FLOAT","LOW_INT","MEDIUM_INT","HIGH_INT"],Fr="WEBGL_debug_renderer_info",Wi="WEBGL_polygon_mode";function $i(e){var t,r,a,n,i,s,c=e.cache,l=Pr(c);if(!l)return Zr;if(!Wr(l))return Or;var d=Vr()?null:l.getExtension(Fr);return{version:((t=l.getParameter(l.VERSION))===null||t===void 0?void 0:t.toString())||"",vendor:((r=l.getParameter(l.VENDOR))===null||r===void 0?void 0:r.toString())||"",vendorUnmasked:d?(a=l.getParameter(d.UNMASKED_VENDOR_WEBGL))===null||a===void 0?void 0:a.toString():"",renderer:((n=l.getParameter(l.RENDERER))===null||n===void 0?void 0:n.toString())||"",rendererUnmasked:d?(i=l.getParameter(d.UNMASKED_RENDERER_WEBGL))===null||i===void 0?void 0:i.toString():"",shadingLanguageVersion:((s=l.getParameter(l.SHADING_LANGUAGE_VERSION))===null||s===void 0?void 0:s.toString())||""}}function zi(e){var t=e.cache,r=Pr(t);if(!r)return Zr;if(!Wr(r))return Or;var a=r.getSupportedExtensions(),n=r.getContextAttributes(),i=[],s=[],c=[],l=[],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 g=lr(r),m=0,k=g;m<k.length;m++){var b=k[m],y=r[b];c.push("".concat(b,"=").concat(y).concat(Oi.has(y)?"=".concat(r.getParameter(y)):""))}if(a)for(var N=0,R=a;N<R.length;N++){var P=R[N];if(!(P===Fr&&Vr()||P===Wi&&Bi())){var U=r.getExtension(P);if(!U){i.push(P);continue}for(var V=0,C=lr(U);V<C.length;V++){var b=C[V],y=U[b];l.push("".concat(b,"=").concat(y).concat(Fi.has(y)?"=".concat(r.getParameter(y)):""))}}}for(var S=0,ce=Pi;S<ce.length;S++)for(var Ce=ce[S],ge=0,Pe=Vi;ge<Pe.length;ge++){var Ve=Pe[ge],We=Di(r,Ce,Ve);d.push("".concat(Ce,".").concat(Ve,"=").concat(We.join(",")))}return l.sort(),c.sort(),{contextAttributes:s,parameters:c,shaderPrecisions:d,extensions:a,extensionParameters:l,unsupportedExtensions:i}}function Pr(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 Di(e,t,r){var a=e.getShaderPrecisionFormat(e[t],e[r]);return a?[a.rangeMin,a.rangeMax,a.precision]:[]}function lr(e){return Object.keys(e.__proto__).filter(Ui)}function Ui(e){return typeof e=="string"&&!e.match(/[^A-Z0-9_x]/)}function Vr(){return Mr()}function Bi(){return Ze()||ee()}function Wr(e){return typeof e.getParameter=="function"}function Gi(){if(!(zt()||ee()))return-2;if(!window.AudioContext)return-1;var e=new AudioContext().baseLatency;return e==null?-1:isFinite(e)?e:-3}function Hi(){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 Yi={fonts:En,domBlockers:fi,fontPreferences:Ni,audio:bn,screenFrame:qn,canvas:Mn,osCpu:Dn,languages:Un,colorDepth:Bn,deviceMemory:Gn,screenResolution:Hn,hardwareConcurrency:ei,timezone:ti,sessionStorage:ai,localStorage:ni,indexedDB:ii,openDatabase:si,cpuClass:oi,platform:li,plugins:An,touchSupport:zn,vendor:ci,vendorFlavors:di,cookiesEnabled:ui,colorGamut:vi,invertedColors:ki,forcedColors:xi,monochrome:yi,contrast:_i,reducedMotion:wi,reducedTransparency:ji,hdr:Si,math:Ci,pdfViewerEnabled:Li,architecture:Ei,applePay:Ai,privateClickMeasurement:Zi,audioBaseLatency:Gi,dateTimeLocale:Hi,webGlBasics:$i,webGlExtensions:zi};function Xi(e){return un(Yi,e,[])}var Ji="$ if upgrade to Pro: https://fpjs.dev/pro";function Qi(e){var t=Ki(e),r=qi(t);return{score:t,comment:Ji.replace(/\$/g,"".concat(r))}}function Ki(e){if(zt())return .4;if(ee())return $t()&&!(Fe()&&Oe())?.5:.3;var t="value"in e.platform?e.platform.value:"";return/^Win/.test(t)?.6:/^Mac/.test(t)?.5:.7}function qi(e){return Er(.99+.01*e,1e-4)}function es(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 ts(e){return JSON.stringify(e,function(t,r){return r instanceof Error?on(r):r},2)}function $r(e){return sn(es(e))}function rs(e){var t;return{get visitorId(){return t===void 0&&(t=$r(this.components)),t},set visitorId(r){t=r},confidence:Qi(e),components:e,version:Tr}}function as(e){return e===void 0&&(e=50),Ja(e,e*2)}function ns(e,t){var r=Date.now();return{get:function(a){return ae(this,void 0,void 0,function(){var n,i,s;return ne(this,function(c){switch(c.label){case 0:return n=Date.now(),[4,e()];case 1:return i=c.sent(),s=rs(i),t||a?.debug,[2,s]}})})}}}function is(){if(!(window.__fpjs_d_m||Math.random()>=.001))try{var e=new XMLHttpRequest;e.open("get","https://m1.openfpcdn.io/fingerprintjs/v".concat(Tr,"/npm-monitoring"),!0),e.send()}catch{}}function ss(e){var t;return e===void 0&&(e={}),ae(this,void 0,void 0,function(){var r,a,n;return ne(this,function(i){switch(i.label){case 0:return(!((t=e.monitoring)!==null&&t!==void 0)||t)&&is(),r=e.delayFallback,a=e.debug,[4,as(r)];case 1:return i.sent(),n=Xi({cache:{},debug:a}),[2,ns(n,a)]}})})}var os={load:ss,hashComponents:$r,componentsToDebugString:ts},zr=class{baseUrl;options;constructor(e,t={}){this.baseUrl=e,this.options=t}get credentials(){return this.options.preview?"include":"same-origin"}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.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.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,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.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.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.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){const i=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})});if(!i.ok)throw new Error(`Failed to end session: ${i.status} ${i.statusText}`);const s=await i.json();if(!s.success)throw new Error(s.error??"Failed to end session")}},ls=12e4;function cs(e){return Promise.race([e.read(),new Promise((t,r)=>setTimeout(()=>r(new Error("Stream timed out — no data received for 120s")),ls))])}async function Dr(e,t,r,a={}){let n="",i="";try{const s=await fetch(`${e}/v1/agents/${encodeURIComponent(t.agentId)}/responses:stream`,{method:"POST",credentials:a.preview?"include":"same-origin",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 p=`${s.status} ${s.statusText}`;try{const g=await s.json();g.error&&(p=g.error)}catch{}throw new Error(p)}const c=s.headers.get("x-session-id");c&&r.onSession&&r.onSession(c);const l=s.body.getReader(),d=new TextDecoder;let u="";const h=p=>{if(!p.startsWith("data: "))return!1;const g=p.slice(6).trim();if(!g)return!1;if(g==="[DONE]")return r.onEnd(n),!0;try{const m=JSON.parse(g);if(m.type==="session"){const b=m.sessionId;return b&&r.onSession&&r.onSession(b),!1}if(m.type==="done"||m.type==="stop")return r.onEnd(n),!0;if(m.type==="error")throw new Error(m.message??"Stream error");if(m.type==="images"){const b=m.images;return b&&r.onImages&&r.onImages(b),!1}if(m.type==="control_mode"){const b=m.mode,y=!!m.queued;return b&&r.onControlMode&&r.onControlMode(b,y),y?(r.onEnd(n),!0):!1}if(m.type==="thinking_chunk"){const b=m.content;return b&&r.onThinkingDelta&&(i+=b,r.onThinkingDelta(b,i)),!1}if(m.type==="tool_calls_started"){const b=m.toolNames??[];return n.length>0&&!n.endsWith(`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let Na=require("preact/compat/client"),M=require("preact/compat"),o=require("preact/jsx-runtime");var L;(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})(L||(L={}));var qt;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(qt||(qt={}));var y=L.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=L.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"]),te=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,L.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()}};te.create=e=>new te(e);var Ae=(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,L.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:r=`Unrecognized key(s) in object: ${L.joinValues(e.keys,", ")}`;break;case m.invalid_union:r="Invalid input";break;case m.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${L.joinValues(e.options)}`;break;case m.invalid_enum_value:r=`Invalid enum value. Expected ${L.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}"`:L.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,L.assertNever(e)}return{message:r}},Ea=Ae;function kt(){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 k(e,t){const r=kt(),a=yt({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Ae?void 0:Ae].filter(n=>!!n)});e.common.issues.push(a)}var H=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 S;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 S;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}}},S=Object.freeze({status:"aborted"}),Me=e=>({status:"dirty",value:e}),D=e=>({status:"valid",value:e}),er=e=>e.status==="aborted",tr=e=>e.status==="dirty",we=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 re=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(we(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 te(e.common.issues);return this._error=r,this._error}}};function N(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 T=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 H,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 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:ue(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:t});return we(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=>we(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)},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 ce({schema:this,typeName:C.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 je.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:C.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new at({...N(this._def),innerType:this,defaultValue:t,typeName:C.ZodDefault})}brand(){return new Lr({typeName:C.ZodBranded,type:this,...N(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new nt({...N(this._def),innerType:this,catchValue:t,typeName:C.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,Ta=/^[0-9a-z]+$/,La=/^[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 T{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==y.string){const n=this._getOrReturnCtx(t);return k(n,{code:m.invalid_type,expected:y.string,received:n.parsedType}),S}const r=new H;let a;for(const n of this._def.checks)if(n.kind==="min")t.data.length<n.value&&(a=this._getOrReturnCtx(t,a),k(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),k(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?k(a,{code:m.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):s&&k(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),k(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),k(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),k(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),k(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),k(a,{validation:"cuid",code:m.invalid_string,message:n.message}),r.dirty());else if(n.kind==="cuid2")Ta.test(t.data)||(a=this._getOrReturnCtx(t,a),k(a,{validation:"cuid2",code:m.invalid_string,message:n.message}),r.dirty());else if(n.kind==="ulid")La.test(t.data)||(a=this._getOrReturnCtx(t,a),k(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),k(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),k(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),k(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),k(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),k(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),k(a,{code:m.invalid_string,validation:"datetime",message:n.message}),r.dirty()):n.kind==="date"?Ba.test(t.data)||(a=this._getOrReturnCtx(t,a),k(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),k(a,{code:m.invalid_string,validation:"time",message:n.message}),r.dirty()):n.kind==="duration"?Oa.test(t.data)||(a=this._getOrReturnCtx(t,a),k(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),k(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),k(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),k(a,{validation:"cidr",code:m.invalid_string,message:n.message}),r.dirty()):n.kind==="base64"?Da.test(t.data)||(a=this._getOrReturnCtx(t,a),k(a,{validation:"base64",code:m.invalid_string,message:n.message}),r.dirty()):n.kind==="base64url"?Ua.test(t.data)||(a=this._getOrReturnCtx(t,a),k(a,{validation:"base64url",code:m.invalid_string,message:n.message}),r.dirty()):L.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:C.ZodString,coerce:e?.coerce??!1,...N(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 T{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 k(n,{code:m.invalid_type,expected:y.number,received:n.parsedType}),S}let r;const a=new H;for(const n of this._def.checks)n.kind==="int"?L.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),k(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),k(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),k(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),k(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),k(r,{code:m.not_finite,message:n.message}),a.dirty()):L.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"&&L.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:C.ZodNumber,coerce:e?.coerce||!1,...N(e)});var wt=class jt extends T{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 H;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),k(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),k(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),k(r,{code:m.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):L.assertNever(n);return{status:a.value,value:t.data}}_getInvalidInput(t){const r=this._getOrReturnCtx(t);return k(r,{code:m.invalid_type,expected:y.bigint,received:r.parsedType}),S}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:C.ZodBigInt,coerce:e?.coerce??!1,...N(e)});var St=class extends T{_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}),S}return D(e.data)}};St.create=e=>new St({typeName:C.ZodBoolean,coerce:e?.coerce||!1,...N(e)});var Ct=class Nr extends T{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==y.date){const n=this._getOrReturnCtx(t);return k(n,{code:m.invalid_type,expected:y.date,received:n.parsedType}),S}if(Number.isNaN(t.data.getTime()))return k(this._getOrReturnCtx(t),{code:m.invalid_date}),S;const r=new H;let a;for(const n of this._def.checks)n.kind==="min"?t.data.getTime()<n.value&&(a=this._getOrReturnCtx(t,a),k(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),k(a,{code:m.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),r.dirty()):L.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:C.ZodDate,...N(e)});var It=class extends T{_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}),S}return D(e.data)}};It.create=e=>new It({typeName:C.ZodSymbol,...N(e)});var Je=class extends T{_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}),S}return D(e.data)}};Je.create=e=>new Je({typeName:C.ZodUndefined,...N(e)});var Qe=class extends T{_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}),S}return D(e.data)}};Qe.create=e=>new Qe({typeName:C.ZodNull,...N(e)});var Nt=class extends T{constructor(){super(...arguments),this._any=!0}_parse(e){return D(e.data)}};Nt.create=e=>new Nt({typeName:C.ZodAny,...N(e)});var be=class extends T{constructor(){super(...arguments),this._unknown=!0}_parse(e){return D(e.data)}};be.create=e=>new be({typeName:C.ZodUnknown,...N(e)});var he=class extends T{_parse(e){const t=this._getOrReturnCtx(e);return k(t,{code:m.invalid_type,expected:y.never,received:t.parsedType}),S}};he.create=e=>new he({typeName:C.ZodNever,...N(e)});var Et=class extends T{_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}),S}return D(e.data)}};Et.create=e=>new Et({typeName:C.ZodVoid,...N(e)});var je=class Be extends T{_parse(t){const{ctx:r,status:a}=this._processInputParams(t),n=this._def;if(r.parsedType!==y.array)return k(r,{code:m.invalid_type,expected:y.array,received:r.parsedType}),S;if(n.exactLength!==null){const s=r.data.length>n.exactLength.value,l=r.data.length<n.exactLength.value;(s||l)&&(k(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&&(k(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&&(k(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 re(r,s,r.path,l)))).then(s=>H.mergeArray(a,s));const i=[...r.data].map((s,l)=>n.type._parseSync(new re(r,s,r.path,l)));return H.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)}};je.create=(e,t)=>new je({type:e,minLength:null,maxLength:null,exactLength:null,typeName:C.ZodArray,...N(t)});function ye(e){if(e instanceof q){const t={};for(const r in e.shape){const a=e.shape[r];t[r]=le.create(ye(a))}return new q({...e._def,shape:()=>t})}else return e instanceof je?new je({...e._def,type:ye(e.element)}):e instanceof le?le.create(ye(e.unwrap())):e instanceof me?me.create(ye(e.unwrap())):e instanceof pe?pe.create(e.items.map(t=>ye(t))):e}var q=class Q extends T{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=L.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}),S}const{status:r,ctx:a}=this._processInputParams(t),{shape:n,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof he&&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 re(a,u,a.path,c)),alwaysSet:c in a.data})}if(this._def.catchall instanceof he){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&&(k(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 re(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=>H.mergeObjectSync(r,c)):H.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,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 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:C.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new Q({...this._def,catchall:t})}pick(t){const r={};for(const a of L.objectKeys(t))t[a]&&this.shape[a]&&(r[a]=this.shape[a]);return new Q({...this._def,shape:()=>r})}omit(t){const r={};for(const a of L.objectKeys(this.shape))t[a]||(r[a]=this.shape[a]);return new Q({...this._def,shape:()=>r})}deepPartial(){return ye(this)}partial(t){const r={};for(const a of L.objectKeys(this.shape)){const n=this.shape[a];t&&!t[a]?r[a]=n:r[a]=n.optional()}return new Q({...this._def,shape:()=>r})}required(t){const r={};for(const a of L.objectKeys(this.shape))if(t&&!t[a])r[a]=this.shape[a];else{let n=this.shape[a];for(;n instanceof le;)n=n._def.innerType;r[a]=n}return new Q({...this._def,shape:()=>r})}keyof(){return Tr(L.objectKeys(this.shape))}};q.create=(e,t)=>new q({shape:()=>e,unknownKeys:"strip",catchall:he.create(),typeName:C.ZodObject,...N(t)});q.strictCreate=(e,t)=>new q({shape:()=>e,unknownKeys:"strict",catchall:he.create(),typeName:C.ZodObject,...N(t)});q.lazycreate=(e,t)=>new q({shape:e,unknownKeys:"strip",catchall:he.create(),typeName:C.ZodObject,...N(t)});var Ke=class extends T{_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 te(s.ctx.common.issues));return k(t,{code:m.invalid_union,unionErrors:i}),S}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 te(l));return k(t,{code:m.invalid_union,unionErrors:s}),S}}get options(){return this._def.options}};Ke.create=(e,t)=>new Ke({options:e,typeName:C.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?L.objectValues(e.enum):e instanceof at?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 Lr||e instanceof it?se(e.unwrap()):e instanceof nt?se(e._def.innerType):[],Ka=class Er extends T{_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}),S;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}):(k(r,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),S)}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=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(n.has(l))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(l)}`);n.set(l,i)}}return new Er({typeName:C.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:n,...N(a)})}};function Mt(e,t){const r=ue(e),a=ue(t);if(e===t)return{valid:!0,data:e};if(r===y.object&&a===y.object){const n=L.objectKeys(t),i=L.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 T{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),a=(n,i)=>{if(er(n)||er(i))return S;const s=Mt(n.value,i.value);return s.valid?((tr(n)||tr(i))&&t.dirty(),{status:t.value,value:s.data}):(k(r,{code:m.invalid_intersection_types}),S)};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:C.ZodIntersection,...N(r)});var pe=class Mr extends T{_parse(t){const{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==y.array)return k(a,{code:m.invalid_type,expected:y.array,received:a.parsedType}),S;if(a.data.length<this._def.items.length)return k(a,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),S;!this._def.rest&&a.data.length>this._def.items.length&&(k(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 re(a,i,a.path,s)):null}).filter(i=>!!i);return a.common.async?Promise.all(n).then(i=>H.mergeArray(r,i)):H.mergeArray(r,n)}get items(){return this._def.items}rest(t){return new Mr({...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:C.ZodTuple,rest:null,...N(t)})};var qa=class Tt extends T{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 k(a,{code:m.invalid_type,expected:y.object,received:a.parsedType}),S;const n=[],i=this._def.keyType,s=this._def.valueType;for(const l in a.data)n.push({key:i._parse(new re(a,l,a.path,l)),value:s._parse(new re(a,a.data[l],a.path,l)),alwaysSet:l in a.data});return a.common.async?H.mergeObjectAsync(r,n):H.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(t,r,a){return r instanceof T?new Tt({keyType:t,valueType:r,typeName:C.ZodRecord,...N(a)}):new Tt({keyType:Xe.create(),valueType:t,typeName:C.ZodRecord,...N(r)})}},Lt=class extends T{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}),S;const a=this._def.keyType,n=this._def.valueType,i=[...r.data.entries()].map(([s,l],c)=>({key:a._parse(new re(r,s,r.path,[c,"key"])),value:n._parse(new re(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 S;(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 S;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),s.set(c.value,d.value)}return{status:t.value,value:s}}}};Lt.create=(e,t,r)=>new Lt({valueType:t,keyType:e,typeName:C.ZodMap,...N(r)});var At=class Rt extends T{_parse(t){const{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==y.set)return k(a,{code:m.invalid_type,expected:y.set,received:a.parsedType}),S;const n=this._def;n.minSize!==null&&a.data.size<n.minSize.value&&(k(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&&(k(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 S;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 re(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:C.ZodSet,...N(t)});var en=class Ge extends T{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}),S;function a(l,c){return yt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,kt(),Ae].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,kt(),Ae].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 D(async function(...c){const d=new te([]),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 D(function(...c){const d=l._def.args.safeParse(c,i);if(!d.success)throw new te([a(c,d.error)]);const u=Reflect.apply(s,this,d.data),h=l._def.returns.safeParse(u,i);if(!h.success)throw new te([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:pe.create(t).rest(be.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||pe.create([]).rest(be.create()),returns:r||be.create(),typeName:C.ZodFunction,...N(a)})}},et=class extends T{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:C.ZodLazy,...N(t)});var tt=class extends T{_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}),S}return{status:"valid",value:e.data}}get value(){return this._def.value}};tt.create=(e,t)=>new tt({value:e,typeName:C.ZodLiteral,...N(t)});function Tr(e,t){return new ct({values:e,typeName:C.ZodEnum,...N(t)})}var ct=class Zt extends T{_parse(t){if(typeof t.data!="string"){const r=this._getOrReturnCtx(t),a=this._def.values;return k(r,{expected:L.joinValues(a),received:r.parsedType,code:m.invalid_type}),S}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 k(r,{received:r.data,code:m.invalid_enum_value,options:a}),S}return D(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=Tr;var rt=class extends T{_parse(e){const t=L.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){const a=L.objectValues(t);return k(r,{expected:L.joinValues(a),received:r.parsedType,code:m.invalid_type}),S}if(this._cache||(this._cache=new Set(L.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=L.objectValues(t);return k(r,{received:r.data,code:m.invalid_enum_value,options:a}),S}return D(e.data)}get enum(){return this._def.values}};rt.create=(e,t)=>new rt({values:e,typeName:C.ZodNativeEnum,...N(t)});var Re=class extends T{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}),S):D((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:C.ZodPromise,...N(t)});var ce=class extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===C.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=>{k(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 S;const l=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return l.status==="aborted"?S:l.status==="dirty"||t.value==="dirty"?Me(l.value):l});{if(t.value==="aborted")return S;const s=this._def.schema._parseSync({data:i,path:r.path,parent:r});return s.status==="aborted"?S:s.status==="dirty"||t.value==="dirty"?Me(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:(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:(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(!we(i))return S;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=>we(i)?Promise.resolve(a.transform(i.value,n)).then(s=>({status:t.value,value:s})):S);L.assertNever(a)}};ce.create=(e,t,r)=>new ce({schema:e,typeName:C.ZodEffects,effect:t,...N(r)});ce.createWithPreprocess=(e,t,r)=>new ce({schema:t,effect:{type:"preprocess",transform:e},typeName:C.ZodEffects,...N(r)});var le=class extends T{_parse(e){return this._getType(e)===y.undefined?D(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};le.create=(e,t)=>new le({innerType:e,typeName:C.ZodOptional,...N(t)});var me=class extends T{_parse(e){return this._getType(e)===y.null?D(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};me.create=(e,t)=>new me({innerType:e,typeName:C.ZodNullable,...N(t)});var at=class extends T{_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:C.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...N(t)});var nt=class extends T{_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 te(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new te(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};nt.create=(e,t)=>new nt({innerType:e,typeName:C.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...N(t)});var Ot=class extends T{_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}),S}return{status:"valid",value:e.data}}};Ot.create=e=>new Ot({typeName:C.ZodNaN,...N(e)});var Lr=class extends T{_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 T{_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"?S:i.status==="dirty"?(r.dirty(),Me(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"?S: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:C.ZodPipeline})}},it=class extends T{_parse(e){const t=this._def.innerType._parse(e),r=a=>(we(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:C.ZodReadonly,...N(t)});var vo={object:q.lazycreate},C;(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"})(C||(C={}));var $=Xe.create,xo=bt.create,ko=Ot.create,yo=wt.create,mt=St.create,bo=Ct.create,_o=It.create,wo=Je.create,jo=Qe.create,So=Nt.create,tn=be.create,Co=he.create,Io=Et.create,No=je.create,Bt=q.create,Eo=q.strictCreate,Mo=Ke.create,To=Ka.create,Lo=qe.create,Ao=pe.create,rn=qa.create,Ro=Lt.create,Zo=At.create,Oo=en.create,Fo=et.create,Po=tt.create,Ft=ct.create,Wo=rt.create,$o=Re.create,Vo=ce.create,zo=le.create,Do=me.create,Uo=ce.createWithPreprocess,Bo=Ar.create,an=Bt({mode:Ft(["light","dark","system"]).optional(),accentColor:$().optional(),fontFamily:$().optional(),borderRadius:$().optional()}),nn=Bt({externalId:$().optional(),authId:$().optional(),name:$().optional(),email:$().optional()}),Zr=Bt({agentId:$().min(1,"agentId is required"),apiBaseUrl:$().url("apiBaseUrl must be a valid URL"),tenantId:$().optional(),user:nn.optional(),sessionId:$().optional(),mode:Ft(["floating","inline"]).optional(),title:$().optional(),subtitle:$().optional(),description:$().optional(),avatarUrl:$().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(),fe={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 Se(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??fe.theme.mode,accentColor:i.theme?.accentColor??r?.accentColor??fe.theme.accentColor,fontFamily:i.theme?.fontFamily??r?.fontFamily??fe.theme.fontFamily,borderRadius:i.theme?.borderRadius??r?.borderRadius??fe.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??fe.mode,title:i.title??fe.title,subtitle:i.subtitle,description:i.description,suggestedQuestions:(()=>{const l=n?.suggestedQuestions;return Array.isArray(l)?l:[]})(),avatarUrl:i.avatarUrl,streaming:i.streaming??fe.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 ae(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 ne(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),ae(this,void 0,void 0,function(){var a,n,i,s;return ne(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 Ze(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 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 $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 de(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 Y(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 ge(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 B(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),Y(e,fn),t[1]=e[0]>>>1,Z(e,t),Y(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,Y(c,De),ge(c,31),Y(c,Ue),Z(s,c),ge(s,27),de(s,l),Y(s,sr),de(s,mn),Y(d,Ue),ge(d,33),Y(d,De),Z(l,d),ge(l,31),de(l,s),Y(l,sr),de(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],B(h,48),Z(d,h);case 14:h[1]=r[u+13],B(h,40),Z(d,h);case 13:h[1]=r[u+12],B(h,32),Z(d,h);case 12:h[1]=r[u+11],B(h,24),Z(d,h);case 11:h[1]=r[u+10],B(h,16),Z(d,h);case 10:h[1]=r[u+9],B(h,8),Z(d,h);case 9:h[1]=r[u+8],Z(d,h),Y(d,Ue),ge(d,33),Y(d,De),Z(l,d);case 8:h[1]=r[u+7],B(h,56),Z(c,h);case 7:h[1]=r[u+6],B(h,48),Z(c,h);case 6:h[1]=r[u+5],B(h,40),Z(c,h);case 5:h[1]=r[u+4],B(h,32),Z(c,h);case 4:h[1]=r[u+3],B(h,24),Z(c,h);case 3:h[1]=r[u+2],B(h,16),Z(c,h);case 2:h[1]=r[u+1],B(h,8),Z(c,h);case 1:h[1]=r[u],Z(c,h),Y(c,De),ge(c,31),Y(c,Ue),Z(s,c)}return Z(s,a),Z(l,a),de(s,l),de(l,s),ir(s),ir(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 xn(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 kn(e){return/^function\s.*?\{\s*\[native code]\s*}$/.test(String(e))}function yn(e){return typeof e!="function"}function bn(e,t){var r=Ze(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=Ze(nr(n,function(s){return bn(e[s],t)},a));return function(){return ae(this,void 0,void 0,function(){var l,c,d,u,h;return ne(this,function(p){switch(p.label){case 0:return[4,i];case 1:return l=p.sent(),[4,nr(l,function(f){return Ze(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 V(["MSCSSMatrix"in e,"msSetImmediate"in e,"msIndexedDB"in e,"msMaxTouchPoints"in t,"msPointerEnabled"in t])>=4}function wn(){var e=window,t=navigator;return V(["msWriteProfilerMark"in e,"MSStream"in e,"msLaunchUri"in t,"msSaveBlob"in t])>=3&&!Vr()}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 kn(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 jn(){var e=window;return V([!("MediaSettingsRange"in e),"RTCEncodedAudioFrame"in e,""+e.Intl=="[object Intl]",""+e.Reflect=="[object Reflect]"])>=3}function Sn(){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 Cn(){var e=window;return V(["DOMRectList"in e,"RTCPeerConnectionIceEvent"in e,"SVGGeometryElement"in e,"ontransitioncancel"in e])>=3}function We(){var e=window,t=navigator,r=e.CSS,a=e.HTMLButtonElement;return V([!("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 V(["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=Fe(),t=zr(),r=window,a=navigator,n="connection";return e?V([!("SharedWorker"in r),a[n]&&"ontypechange"in a[n],!("sinkId"in new Audio)])>=2:t?V(["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 V(["srLatency"in r,"srChannelCount"in r,"devicePosture"in e,a&&"segments"in a,"getTextInformation"in Image.prototype])>=3}function Tn(){return Rn()?-4:Ln()}function Ln(){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=Ze(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 ee()&&!Ht()&&!Cn()}function Rn(){return ee()&&We()&&Pe()||Fe()&&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)&&Ze(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(x){l(x)}};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),ae(this,void 0,void 0,function(){var s,l;return ne(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(w){h=!0,u(w)};l.onload=p,l.onerror=f;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;h||(((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!((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",ve=["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 ae(e,void 0,void 0,function(){var n,i,s,l,c,d,u,h,p,f,x,v;return ne(this,function(w){for(n=a.body,n.style.fontSize=Vn,i=a.createElement("div"),i.style.setProperty("visibility","hidden","important"),s={},l={},c=function(g){var I=a.createElement("span"),R=I.style;return R.position="absolute",R.top="0",R.left="0",R.fontFamily=g,I.textContent=$n,i.appendChild(I),I},d=function(g,I){return c("'".concat(g,"',").concat(I))},u=function(){return ve.map(c)},h=function(){for(var g={},I=function(z){g[z]=ve.map(function(_){return d(z,_)})},R=0,F=lr;R<F.length;R++){var X=F[R];I(X)}return g},p=function(g){return ve.some(function(I,R){return g[R].offsetWidth!==s[I]||g[R].offsetHeight!==l[I]})},f=u(),x=h(),n.appendChild(i),v=0;v<ve.length;v++)s[ve[v]]=f[v].offsetWidth,l[ve[v]]=f[v].offsetHeight;return[2,lr.filter(function(g){return p(x[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 ee()&&We()&&Pe()}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))Fe()&&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 oe(K(navigator.deviceMemory),void 0)}function ni(){if(!(ee()&&We()&&Pe()))return ii()}function ii(){var e=screen,t=function(a){return oe(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 ae(e,void 0,void 0,function(){var t;return ne(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(ee()&&We()&&Pe())return function(){return Promise.resolve(void 0)};var t=ci();return function(){return ae(e,void 0,void 0,function(){var r,a;return ne(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[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 $t(e){for(var t=0;t<4;++t)if(e[t])return!1;return!0}function ui(){return oe(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(K(new Date(e,0,1).getTimezoneOffset()),K(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 xi(){return navigator.cpuClass}function ki(){var e=navigator.platform;return e==="MacIntel"&&ee()&&!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 ae(this,void 0,void 0,function(){var r,a,n,i,s,l;return ne(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 V(u.map(function(h){return i[h]}))>u.length*.6}),s.sort(),[2,s]}})})}function Si(){return ee()||Yt()}function Ci(e){var t;return ae(this,void 0,void 0,function(){var r,a,n,i,c,s,l,c;return ne(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
|
+
`.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 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 Ti=100;function Li(){if(matchMedia("(min-monochrome: 0)").matches){for(var e=0;e<=Ti;++e)if(matchMedia("(max-monochrome: ".concat(e,")")).matches)return e;throw new Error("Too high value")}}function Ai(){if(xe("no-preference"))return 0;if(xe("high")||xe("more"))return 1;if(xe("low")||xe("less"))return-1;if(xe("forced"))return 10}function xe(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,W=function(){return 0};function Fi(){var e=A.acos||W,t=A.acosh||W,r=A.asin||W,a=A.asinh||W,n=A.atanh||W,i=A.atan||W,s=A.sin||W,l=A.sinh||W,c=A.cos||W,d=A.cosh||W,u=A.tan||W,h=A.tanh||W,p=A.exp||W,f=A.expm1||W,x=A.log1p||W,v=function(j){return A.pow(A.PI,j)},w=function(j){return A.log(j+A.sqrt(j*j-1))},g=function(j){return A.log(j+A.sqrt(j*j+1))},I=function(j){return A.log((1+j)/(1-j))/2},R=function(j){return A.exp(j)-1/A.exp(j)/2},F=function(j){return(A.exp(j)+1/A.exp(j))/2},X=function(j){return A.exp(j)-1},z=function(j){return(A.exp(2*j)-1)/(A.exp(2*j)+1)},_=function(j){return A.log(1+j)};return{acos:e(.12312423423423424),acosh:t(1e308),acoshPf:w(1e154),asin:r(.12312423423423424),asinh:a(1),asinhPf:g(1),atanh:n(.5),atanhPf:I(.5),atan:i(.5),sin:s(-1e300),sinh:l(1),sinhPf:R(1),cos:c(10.000000000123),cosh:d(1),coshPf:F(1),tan:u(-1e300),tanh:h(1),tanhPf:z(1),exp:p(1),expm1:f(1),expm1Pf:X(1),log1p:x(10),log1pPf:_(10),powPI:v(-100)}}var Pi="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 Wi(){return $i(function(e,t){for(var r={},a={},n=0,i=Object.keys(xt);n<i.length;n++){var s=i[n],l=xt[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,x=Object.keys(d);f<x.length;f++){var v=x[f],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];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",Fe()?i.style.zoom="".concat(1/a.devicePixelRatio):ee()&&(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),x=0,v=f;x<v.length;x++){var w=v[x],g=r[w];l.push("".concat(w,"=").concat(g).concat(Hi.has(g)?"=".concat(r.getParameter(g)):""))}if(a)for(var I=0,R=a;I<R.length;I++){var F=R[I];if(!(F===Gr&&Yr()||F===Qi&&rs())){var X=r.getExtension(F);if(!X){i.push(F);continue}for(var z=0,_=mr(X);z<_.length;z++){var w=_[z],g=X[w];c.push("".concat(w,"=").concat(g).concat(Yi.has(g)?"=".concat(r.getParameter(g)):""))}}}for(var j=0,ie=Xi;j<ie.length;j++)for(var $e=ie[j],Ce=0,Ie=Ji;Ce<Ie.length;Ce++){var Ve=Ie[Ce],ht=es(r,$e,Ve);d.push("".concat($e,".").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 Fe()||ee()}function Xr(e){return typeof e.getParameter=="function"}function as(){if(!(Yt()||ee()))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:Tn,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:xi,platform:ki,plugins:Dn,touchSupport:qn,vendor:yi,vendorFlavors:bi,cookiesEnabled:_i,colorGamut:Ni,invertedColors:Ei,forcedColors:Mi,monochrome:Li,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(ee())return Ht()&&!(We()&&Pe())?.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?xn(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 ae(this,void 0,void 0,function(){var n,i,s;return ne(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={}),ae(this,void 0,void 0,function(){var r,a,n;return ne(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 xs={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*ks(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,x=!!h.queued;return f&&r.onControlMode&&r.onControlMode(f,x),x?(r.onEnd(n),!0):!1}if(h.type==="tool_calls_started"){const f=h.toolNames??[];return n.length>0&&!n.endsWith(`
|
|
5
7
|
|
|
6
8
|
`)&&(n=n.replace(/\s+$/,"")+`
|
|
7
9
|
|
|
8
10
|
`,r.onDelta(`
|
|
9
11
|
|
|
10
|
-
`,n)),r.onToolCallsStarted?.(b),!1}if(m.type==="assistant_ack"){const b=m.text;return b&&r.onAck&&r.onAck(b),!1}if(m.type==="progress"){const b=m.stage,y=m.text;return b&&y&&r.onProgress&&r.onProgress(b,y),!1}if(m.type==="tool_start"){const b=m.toolId,y=m.text;return b&&y&&r.onToolStart&&r.onToolStart(b,y),!1}if(m.type==="tool_complete"){const b=m.toolId,y=m.text,N=m.durationMs;return b&&y&&r.onToolComplete&&r.onToolComplete(b,y,N??0),!1}if(m.type==="model_start"||m.type==="final_meta"){if(m.type==="final_meta"&&r.onFinalMeta){const b=m.metrics;r.onFinalMeta(b??{})}return!1}const k=ds(m);k&&(n+=k,r.onDelta(k,n))}catch(m){if(!(m instanceof SyntaxError))throw m}return!1};e:for(;;){const{done:p,value:g}=await cs(l);if(p)break;u+=d.decode(g,{stream:!0});const m=u.lastIndexOf(`
|
|
11
|
-
`);if(m===-1)continue;const k=u.slice(0,m);u=u.slice(m+1);for(const b of k.split(`
|
|
12
|
-
`))if(h(b))break e}r.onEnd(n)}catch(s){r.onError(s instanceof Error?s:new Error(String(s)))}}function ds(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??"")}var Ur=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()}},us="agentforge";function Dt(e){return`${us}:session:${e}`}function Br(e){try{return sessionStorage.getItem(Dt(e))??void 0}catch{return}}function Ee(e,t){try{sessionStorage.setItem(Dt(e),t)}catch{}}function Zt(e){try{sessionStorage.removeItem(Dt(e))}catch{}}function be(){return`msg-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`}var Gr=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 zr(e.apiBaseUrl,{preview:e.preview}),this.emitter=new Ur,this.initializeFingerprint();const a=e.sessionId??Br(e.agentId);e.sessionId&&Ee(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())}async initializeFingerprint(){try{const e=await(await os.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=ot(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";return{id:be(),role:a.role,content:a.content,images:a.images&&a.images.length>0?a.images: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)}catch{}Zt(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(){Zt(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 l of t)try{const d=await fs(l.file);if(l.kind==="image"){const u=await this.apiClient.uploadImage(d,l.file.type,l.file.name,this.config.agentId,this.config.tenantId);a.push({url:u.url,mimeType:l.file.type,fileName:l.file.name,kind:"image"})}else{const u=await this.apiClient.uploadFile(d,l.file.type||"application/octet-stream",l.file.name,this.config.agentId,this.config.tenantId);a.push({url:u.url,mimeType:l.file.type||"application/octet-stream",fileName:l.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(l=>l.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(l=>l.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 c=a.length>0?a:void 0;this.config.streaming?await this.sendStreaming(e.trim(),void 0,c):await this.sendNonStreaming(e.trim(),void 0,c)}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&&(Ee(this.config.agentId,n.sessionId),this.openEventStream());return}const i={id:be(),role:"assistant",content:n.content,images:n.images,createdAt:new Date().toISOString(),status:"sent"};this.setState({messages:[...this.state.messages,i],isLoading:!1,...n.sessionId?{sessionId:n.sessionId}:{}}),n.sessionId&&(Ee(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})}}async sendStreaming(e,t,r,a=!1){const n=be(),i={id:n,role:"assistant",content:"",createdAt:new Date().toISOString(),status:"streaming",isThinking:this.config.thinkingEnabled?!0:void 0,toolStatus:this.config.thinkingEnabled?void 0:"Thinking..."};this.setState({messages:[...this.state.messages,i]}),this.emitter.emit("stream:start");let s=!1,c=!1;await Dr(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:l=>{this.setState({sessionId:l}),Ee(this.config.agentId,l),this.openEventStream()},onImages:l=>{this.updateMessage(n,{images:l})},onThinkingDelta:(l,d)=>{this.updateMessage(n,{thinking:d,isThinking:!0}),this.emitter.emit("thinking:delta",{delta:l,accumulated:d})},onToolCallsStarted:l=>{this.updateMessage(n,{isThinking:!1,toolStatus:hs(l)})},onAck:l=>{this.updateMessage(n,{ackText:l})},onProgress:(l,d)=>{const u=this.state.messages.find(h=>h.id===n)?.progressEvents??[];this.updateMessage(n,{progressEvents:[...u.map(h=>({...h,status:"done"})),{stage:l,text:d,timestamp:new Date().toISOString(),status:"active"}]})},onToolStart:(l,d)=>{const u=this.state.messages.find(h=>h.id===n)?.progressEvents??[];this.updateMessage(n,{progressEvents:[...u.map(h=>({...h,status:"done"})),{stage:l,text:d,timestamp:new Date().toISOString(),status:"active"}]})},onToolComplete:(l,d,u)=>{const h=[...this.state.messages.find(g=>g.id===n)?.progressEvents??[]];let p=-1;for(let g=h.length-1;g>=0;g--)if(h[g].stage===l&&h[g].status==="active"){p=g;break}p>=0&&(h[p]={...h[p],status:"done",text:u>0?`${d} (${u}ms)`:d}),this.updateMessage(n,{progressEvents:h})},onFinalMeta:()=>{setTimeout(()=>{this.updateMessage(n,{progressCollapsed:!0})},2e3)},onDelta:(l,d)=>{d.trim()&&(this.updateMessage(n,{content:d,isThinking:!1,toolStatus:void 0}),this.emitter.emit("stream:delta",{delta:l,accumulated:d}))},onEnd:l=>{if(c){this.setState({messages:this.state.messages.filter(h=>h.id!==n),isLoading:!1,controlMode:"human_takeover"}),this.emitter.emit("stream:end",{content:""});return}const d=this.state.messages.find(h=>h.id===n);this.updateMessage(n,{content:l,status:"sent",isThinking:!1,toolStatus:void 0,progressEvents:d?.progressEvents?.map(h=>({...h,status:"done"}))}),this.setState({isLoading:!1}),this.emitter.emit("stream:end",{content:l});const u=this.state.messages.find(h=>h.id===n);u&&(u.thinking&&this.emitter.emit("thinking:end",{content:u.thinking}),this.emitter.emit("message:received",u))},onControlMode:(l,d)=>{d&&l==="human"&&(c=!0)},onError:l=>{if(!a&&l.message.includes("410")){s=!0,this.setState({messages:this.state.messages.filter(h=>h.id!==n),isLoading:!1});return}const d=this.state.messages.find(h=>h.id===n)?.content??"",u=l.message||"Something went wrong. Please try again.";this.updateMessage(n,{content:d||u,status:"error"}),this.setState({isLoading:!1,error:u}),this.emitter.emit("message:error",{error:l.message,message:null})}},{preview:this.config.preview}),s&&(this.handleSessionExpired(),await this.sendStreaming(e,t,r,!0))}};function hs(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 fs(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 Hr(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 Yr(e,t){e.textContent=t}function Xr(e){e.remove()}function Jr(){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 ps(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 Qr(e){return e.setAttribute("data-agentkit-root","inline"),getComputedStyle(e).position==="static"&&(e.style.position="relative"),e}function ms(e){e.remove()}function gs(e){e.removeAttribute("data-agentkit-root")}function Ut(e,t,r,a,n){const i=e.mode==="inline";let s=!1;const c=i&&n?Qr(n):!i&&n?ps(n):Jr(),l=Hr(c);Yr(l.styleSlot,a);const d=new Gr(e,t,(p,g)=>{s||u.update(p,g)}),u=r(l.mountPoint,e,d.getState(),{onOpen:()=>h.open(),onClose:()=>h.close(),onSendMessage:(p,g)=>{d.sendMessage(p,g)},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,g){await d.sendMessage(p,g)},reset(){s||(d.resetConversation(),d.emitter.emit("reset"))},destroy(){s||(s=!0,u.destroy(),Xr(l.host),i&&n?gs(n):ms(c),d.emitter.emit("destroy"),d.emitter.removeAllListeners())},on(p,g){d.emitter.on(p,g)},off(p,g){d.emitter.off(p,g)},getState(){return d.getState()}};return h}var we=new Map,vs=0;function Kr(e){const t=`agentkit-widget-${++vs}`,r=e.destroy.bind(e);return e.destroy=()=>{we.delete(t),r()},we.set(t,e),t}function ks(e,t,r){const a={...e,mode:"floating"},n=Ut(ot(a),a,t,r);return Kr(n),n}function xs(e,t,r,a){const n={...t,mode:"inline"},i=Ut(ot(n),n,r,a,e);return Kr(i),i}function bs(e){e?we.get(e)?.destroy():(we.forEach(t=>t.destroy()),we.clear())}function ys(){return Array.from(we.keys())}function qr(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 ea(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var ta=`
|
|
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,x=h.text,v=h.mode;return f&&x&&r.onProgress&&r.onProgress(f,x,v),!1}if(h.type==="tool_start"){const f=h.toolId,x=h.text,v=h.toolName,w=h.mode;return f&&x&&r.onToolStart&&r.onToolStart(f,x,v,w),!1}if(h.type==="tool_complete"){const f=h.toolId,x=h.text,v=h.durationMs,w=h.ok;return f&&x&&r.onToolComplete&&r.onToolComplete(f,x,v??0,w),!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 ks(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 Le(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 ke(){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&&Le(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 xs.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=Se(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:ke(),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??ke(),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??ke(),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:ke(),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&&(Le(this.config.agentId,n.sessionId),this.openEventStream());return}const i={id:ke(),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&&(Le(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=ke(),i={id:n,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 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}),Le(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,x)=>{const v=this.state.messages.find(g=>g.id===n)?.progressEvents??[],w=Date.now();x&&d===null&&(d=x,this.updateMessage(n,{turnMeta:{totalMs:null,collapseAfterFinal:null,mode:x}})),this.updateMessage(n,{progressEvents:[...gr(v,w),{stage:p,text:f,timestamp:new Date().toISOString(),status:"active",startedAtMs:w}]})},onToolStart:(p,f,x,v)=>{const w=this.state.messages.find(I=>I.id===n)?.progressEvents??[],g=Date.now();v&&d===null&&(d=v,this.updateMessage(n,{turnMeta:{totalMs:null,collapseAfterFinal:null,mode:v}})),this.updateMessage(n,{progressEvents:[...gr(w,g),{stage:"calling_tool",toolId:p,toolName:x,text:f,timestamp:new Date().toISOString(),status:"active",startedAtMs:g}]})},onToolComplete:(p,f,x,v)=>{const w=this.state.messages.find(g=>g.id===n)?.progressEvents??[];this.updateMessage(n,{progressEvents:w.map(g=>g.stage==="calling_tool"&&g.status==="active"&&g.toolId===p?{...g,status:"done",text:f,durationMs:x,ok:v}: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),x=d==="detailed",v=x||d==="standard";this.updateMessage(n,{content:p,status:"sent",toolStatus:void 0,progressEvents:x&&f?.progressEvents?.length?Cs(f.progressEvents):void 0,progressCollapsed:x?u??!0:void 0,turnMeta:v?{totalMs:c??Date.now()-h,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===n);w&&this.emitter.emit("message:received",w)},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 I=this.state.messages.find(R=>R.id===n)?.content??"";this.updateMessage(n,{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(n,{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===n);I&&this.emitter.emit("message:received",I)},v=this.state.messages.find(g=>g.id===n)?.runId,w=this.state.sessionId;if(v&&w){js(this.config.apiBaseUrl,w,v,{preview:this.config.preview}).then(g=>{g.status==="done"&&g.finalText?x(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 Ts(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?Ts(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 _e=new Map,Ls=0;function Jt(e){const t=`agentkit-widget-${++Ls}`,r=e.destroy.bind(e);return e.destroy=()=>{_e.delete(t),r()},_e.set(t,e),t}function As(e,t,r){const a={...e,mode:"floating"},n=dt(Se(a),a,t,r);return Jt(n),n}function Rs(e,t,r,a){const n={...t,mode:"floating"},i=dt(Se(n),n,r,a,e);return Jt(i),i}function Zs(e,t,r,a){const n={...t,mode:"inline"},i=dt(Se(n),n,r,a,e);return Jt(i),i}function ca(e){e?_e.get(e)?.destroy():(_e.forEach(t=>t.destroy()),_e.clear())}function Os(){return Array.from(_e.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 va=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 va=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 va=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 va=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 {
|
|
@@ -454,31 +472,44 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let va=requir
|
|
|
454
472
|
line-height: 1.55;
|
|
455
473
|
width: 100%;
|
|
456
474
|
}
|
|
457
|
-
/*
|
|
458
|
-
.ak-empty-
|
|
459
|
-
|
|
475
|
+
/* Suggested question chips — 2-column grid */
|
|
476
|
+
.ak-empty-state__suggestions {
|
|
477
|
+
display: grid;
|
|
478
|
+
grid-template-columns: 1fr 1fr;
|
|
479
|
+
gap: 8px;
|
|
460
480
|
width: 100%;
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
481
|
+
}
|
|
482
|
+
.ak-empty-state__suggestion {
|
|
483
|
+
display: flex;
|
|
484
|
+
flex-direction: column;
|
|
485
|
+
align-items: flex-start;
|
|
486
|
+
background: color-mix(in srgb, var(--ak-accent) 5%, var(--ak-bg));
|
|
487
|
+
border: 1px solid color-mix(in srgb, var(--ak-accent) 16%, var(--ak-border));
|
|
488
|
+
border-radius: 10px;
|
|
489
|
+
padding: 10px 12px;
|
|
490
|
+
cursor: pointer;
|
|
465
491
|
text-align: left;
|
|
492
|
+
transition: background 0.15s ease, border-color 0.15s ease;
|
|
466
493
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
line-height: 1;
|
|
471
|
-
color: var(--ak-accent);
|
|
472
|
-
margin-bottom: 2px;
|
|
473
|
-
font-family: Georgia, serif;
|
|
474
|
-
opacity: 0.7;
|
|
494
|
+
/* Odd last item spans both columns so the grid doesn't look lopsided */
|
|
495
|
+
.ak-empty-state__suggestion:last-child:nth-child(odd) {
|
|
496
|
+
grid-column: 1 / -1;
|
|
475
497
|
}
|
|
476
|
-
.ak-empty-
|
|
477
|
-
|
|
498
|
+
.ak-empty-state__suggestion:hover {
|
|
499
|
+
background: color-mix(in srgb, var(--ak-accent) 10%, var(--ak-bg));
|
|
500
|
+
border-color: color-mix(in srgb, var(--ak-accent) 30%, var(--ak-border));
|
|
501
|
+
}
|
|
502
|
+
.ak-empty-state__suggestion-title {
|
|
478
503
|
font-size: 13px;
|
|
504
|
+
font-weight: 700;
|
|
505
|
+
color: var(--ak-text);
|
|
506
|
+
line-height: 1.4;
|
|
507
|
+
}
|
|
508
|
+
.ak-empty-state__suggestion-desc {
|
|
509
|
+
font-size: 12px;
|
|
479
510
|
color: var(--ak-text-muted);
|
|
480
|
-
line-height: 1.
|
|
481
|
-
|
|
511
|
+
line-height: 1.4;
|
|
512
|
+
margin-top: 2px;
|
|
482
513
|
}
|
|
483
514
|
|
|
484
515
|
/* ── Message bubbles ─────────────────────────────────────────── */
|
|
@@ -1559,66 +1590,6 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let va=requir
|
|
|
1559
1590
|
border-top: 1px solid #fbbf24;
|
|
1560
1591
|
}
|
|
1561
1592
|
|
|
1562
|
-
/* ── Thinking bubble ─────────────────────────────────────────── */
|
|
1563
|
-
.ak-thinking {
|
|
1564
|
-
margin-bottom: 4px;
|
|
1565
|
-
max-width: 80%;
|
|
1566
|
-
}
|
|
1567
|
-
.ak-thinking__indicator {
|
|
1568
|
-
display: inline-flex;
|
|
1569
|
-
align-items: center;
|
|
1570
|
-
gap: 4px;
|
|
1571
|
-
padding: 6px 12px;
|
|
1572
|
-
border-radius: 14px;
|
|
1573
|
-
background: var(--ak-bot-bg);
|
|
1574
|
-
color: var(--ak-bot-text);
|
|
1575
|
-
font-size: 0.8rem;
|
|
1576
|
-
opacity: 0.75;
|
|
1577
|
-
}
|
|
1578
|
-
.ak-thinking__label {
|
|
1579
|
-
font-style: italic;
|
|
1580
|
-
}
|
|
1581
|
-
.ak-thinking--done {
|
|
1582
|
-
/* no extra styles needed — contained within toggle */
|
|
1583
|
-
}
|
|
1584
|
-
.ak-thinking__toggle {
|
|
1585
|
-
display: inline-flex;
|
|
1586
|
-
align-items: center;
|
|
1587
|
-
gap: 5px;
|
|
1588
|
-
padding: 5px 10px;
|
|
1589
|
-
border: 1px solid var(--ak-border);
|
|
1590
|
-
border-radius: 12px;
|
|
1591
|
-
background: transparent;
|
|
1592
|
-
color: var(--ak-bot-text);
|
|
1593
|
-
font-size: 0.78rem;
|
|
1594
|
-
cursor: pointer;
|
|
1595
|
-
opacity: 0.65;
|
|
1596
|
-
transition: opacity 0.15s;
|
|
1597
|
-
}
|
|
1598
|
-
.ak-thinking__toggle:hover {
|
|
1599
|
-
opacity: 0.9;
|
|
1600
|
-
}
|
|
1601
|
-
.ak-thinking__chevron {
|
|
1602
|
-
flex-shrink: 0;
|
|
1603
|
-
transition: transform 0.15s;
|
|
1604
|
-
}
|
|
1605
|
-
.ak-thinking__chevron--open {
|
|
1606
|
-
transform: rotate(180deg);
|
|
1607
|
-
}
|
|
1608
|
-
.ak-thinking__content {
|
|
1609
|
-
margin-top: 6px;
|
|
1610
|
-
padding: 8px 12px;
|
|
1611
|
-
border-left: 2px solid var(--ak-border);
|
|
1612
|
-
font-size: 0.78rem;
|
|
1613
|
-
color: var(--ak-bot-text);
|
|
1614
|
-
opacity: 0.7;
|
|
1615
|
-
white-space: pre-wrap;
|
|
1616
|
-
word-break: break-word;
|
|
1617
|
-
max-height: 200px;
|
|
1618
|
-
overflow-y: auto;
|
|
1619
|
-
line-height: 1.5;
|
|
1620
|
-
}
|
|
1621
|
-
|
|
1622
1593
|
/* ── Agent status indicator ──────────────────────────────────── */
|
|
1623
1594
|
.ak-agent-status {
|
|
1624
1595
|
display: inline-flex;
|
|
@@ -1742,6 +1713,60 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let va=requir
|
|
|
1742
1713
|
0%, 100% { opacity: 0.8; }
|
|
1743
1714
|
50% { opacity: 1; }
|
|
1744
1715
|
}
|
|
1716
|
+
/* Claude-style step list (detailed mode) */
|
|
1717
|
+
.ak-progress__steps {
|
|
1718
|
+
list-style: none;
|
|
1719
|
+
margin: 0 0 4px;
|
|
1720
|
+
padding: 2px 0;
|
|
1721
|
+
}
|
|
1722
|
+
.ak-progress__step {
|
|
1723
|
+
display: flex;
|
|
1724
|
+
align-items: center;
|
|
1725
|
+
gap: 6px;
|
|
1726
|
+
padding: 2px 0;
|
|
1727
|
+
font-size: 0.76rem;
|
|
1728
|
+
color: var(--ak-bot-text);
|
|
1729
|
+
opacity: 0.6;
|
|
1730
|
+
line-height: 1.4;
|
|
1731
|
+
}
|
|
1732
|
+
.ak-progress__step--active {
|
|
1733
|
+
opacity: 0.9;
|
|
1734
|
+
}
|
|
1735
|
+
.ak-progress__step-text {
|
|
1736
|
+
min-width: 0;
|
|
1737
|
+
}
|
|
1738
|
+
.ak-progress__step-dur {
|
|
1739
|
+
opacity: 0.65;
|
|
1740
|
+
flex-shrink: 0;
|
|
1741
|
+
}
|
|
1742
|
+
.ak-progress__step-icon {
|
|
1743
|
+
flex-shrink: 0;
|
|
1744
|
+
opacity: 0.55;
|
|
1745
|
+
}
|
|
1746
|
+
.ak-progress__step-icon--fail {
|
|
1747
|
+
color: #ef4444;
|
|
1748
|
+
opacity: 0.9;
|
|
1749
|
+
}
|
|
1750
|
+
/* Post-turn summary row ("Worked for Ns · N steps") */
|
|
1751
|
+
.ak-progress__summary {
|
|
1752
|
+
display: inline-flex;
|
|
1753
|
+
align-items: center;
|
|
1754
|
+
gap: 6px;
|
|
1755
|
+
padding: 2px 0;
|
|
1756
|
+
margin: 0 0 4px;
|
|
1757
|
+
border: none;
|
|
1758
|
+
background: transparent;
|
|
1759
|
+
font-size: 0.76rem;
|
|
1760
|
+
color: var(--ak-bot-text);
|
|
1761
|
+
opacity: 0.6;
|
|
1762
|
+
cursor: pointer;
|
|
1763
|
+
transition: opacity 0.15s;
|
|
1764
|
+
}
|
|
1765
|
+
.ak-progress__summary:hover { opacity: 0.85; }
|
|
1766
|
+
.ak-progress__summary--static {
|
|
1767
|
+
cursor: default;
|
|
1768
|
+
}
|
|
1769
|
+
.ak-progress__summary--static:hover { opacity: 0.6; }
|
|
1745
1770
|
.ak-progress__spinner {
|
|
1746
1771
|
display: inline-block;
|
|
1747
1772
|
width: 11px;
|
|
@@ -1843,11 +1868,11 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let va=requir
|
|
|
1843
1868
|
display: none;
|
|
1844
1869
|
}
|
|
1845
1870
|
}
|
|
1846
|
-
`;function _s(){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 ws(){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 js(){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 ra({title:e,subtitle:t,avatarUrl:r,onClose:a,onReset:n,hideClose:i=!1}){const[s,c]=(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)(_s,{})}),(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:()=>c(!0),"aria-label":"New conversation",type:"button",title:"Start a new conversation (Retains current conversation to memory)",children:(0,o.jsx)(js,{})}),!i&&(0,o.jsx)("button",{className:"ak-header__close",onClick:a,"aria-label":"Close chat",type:"button",children:(0,o.jsx)(ws,{})})]})]}),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:()=>c(!1),children:"Cancel"}),(0,o.jsx)("button",{className:"ak-header__confirm-ok",type:"button",onClick:()=>{n?.(),c(!1)},children:"End chat"})]})]})]})}function Ss({ackText:e,events:t=[],collapsed:r=!1,onToggle:a,isComplete:n=!1}){const[i,s]=(0,E.useState)(!1),c=t[t.length-1]?.text??e;if(!c)return null;const l=a?r:i,d=a??(()=>s(u=>!u));return n&&l?(0,o.jsxs)("button",{type:"button",onClick:d,className:"ak-progress__toggle ak-progress__toggle--collapsed","aria-label":"Show working details",children:[(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:"6 9 12 15 18 9"})}),"Show working details"]}):n?(0,o.jsx)("div",{className:"ak-progress",children:(0,o.jsxs)("div",{className:"ak-progress__block",children:[(0,o.jsxs)("div",{className:"ak-progress__header",children:[(0,o.jsx)("span",{className:"ak-progress__label",children:"Done"}),(0,o.jsxs)("button",{type:"button",onClick:d,className:"ak-progress__toggle","aria-label":"Hide working details",children:[(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:"18 15 12 9 6 15"})}),"Hide"]})]}),(0,o.jsx)("p",{className:"ak-progress__text",children:c})]})}):(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:c})]})})}function Cs({thinking:e,isThinking:t,thinkingViewable:r}){const[a,n]=(0,E.useState)(!1);return!t&&!e?null:t?(0,o.jsx)("div",{className:"ak-thinking",children:(0,o.jsxs)("div",{className:"ak-thinking__indicator",children:[(0,o.jsx)("span",{className:"ak-thinking__label",children:"Thinking"}),(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"})]})]})}):!r||!e?null:(0,o.jsxs)("div",{className:"ak-thinking ak-thinking--done",children:[(0,o.jsxs)("button",{className:"ak-thinking__toggle",onClick:()=>n(i=>!i),"aria-expanded":a,type:"button",children:[(0,o.jsx)("svg",{className:`ak-thinking__chevron${a?" ak-thinking__chevron--open":""}`,width:"12",height:"12",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:"6 9 12 15 18 9"})}),(0,o.jsx)("span",{children:"Thought for a moment"})]}),a&&(0,o.jsx)("div",{className:"ak-thinking__content",children:e})]})}function Is(){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 Ns({status:e}){return(0,o.jsxs)("div",{className:"ak-agent-status",role:"status","aria-live":"polite",children:[(0,o.jsx)(Is,{}),(0,o.jsx)("span",{className:"ak-agent-status__text",children:e})]})}function cr({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:s.downloadHref,download:!0,className:"ak-message__image-dl-icon",title:"Download image",onClick:c=>c.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,c)=>(0,o.jsx)(Ne,{src:s.src,alt:s.alt,onClick:()=>r(c)},s.key??`${e}-${c}`))});if(a===3)return(0,o.jsxs)("div",{className:"ak-gallery ak-gallery--three",children:[(0,o.jsx)(Ne,{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)(Ne,{src:t[1].src,alt:t[1].alt,onClick:()=>r(1)},t[1].key??`${e}-1`),(0,o.jsx)(Ne,{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,c)=>{const l=c===n.length-1;return(0,o.jsx)(Ne,{src:s.src,alt:s.alt,overlayCount:l&&i>0?i:0,onClick:()=>r(c)},s.key??`${e}-${c}`)})})}function Ne({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 dr({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 c=l=>{l.key==="Escape"?(l.stopPropagation(),r()):l.key==="ArrowLeft"&&e.length>1?(l.preventDefault(),a((i-1+e.length)%e.length)):l.key==="ArrowRight"&&e.length>1&&(l.preventDefault(),a((i+1)%e.length))};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[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:c=>c.stopPropagation(),children:[e.length>1&&(0,o.jsxs)("span",{className:"ak-lightbox__counter",children:[i+1," / ",e.length]}),(0,o.jsx)("a",{href:s.downloadHref,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:c=>{c.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:c=>{c.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:c=>c.stopPropagation()})]})}function Ts({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:e,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 Ls(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}var ur=/(`[^`\n]+`|\*\*[^*\n]+\*\*|\*[^*\n]+\*|!\[[^\]\n]*\]\([^)\n]+\)|\[[^\]\n]+\]\([^)\n]+\))/g;function H(e){const t=[];let r=0,a=0;ur.lastIndex=0;let n;for(;(n=ur.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(/!\[([^\]]*)\]\(([^)]+)\)/);s&&t.push((0,o.jsx)("a",{href:s[2],target:"_blank",rel:"noopener noreferrer",children:s[1]||"image"},a++))}else{const s=i.match(/\[(.+?)\]\((.+?)\)/);s?t.push((0,o.jsx)("a",{href:s[2],target:"_blank",rel:"noopener noreferrer",children:s[1]},a++)):t.push(i)}r=n.index+i.length}return r<e.length&&t.push(e.slice(r)),t}function Es(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,`
|
|
1871
|
+
`;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,M.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 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 pa(e){const[,t]=(0,M.useState)(0);(0,M.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,M.useState)(0),a=Math.min(t,e.length-1),n=a<e.length-1;(0,M.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,M.useState)(!r);(0,M.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 xr({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: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(a===2)return(0,o.jsx)("div",{className:"ak-gallery ak-gallery--two",children:t.map((s,l)=>(0,o.jsx)(Ee,{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)(Ee,{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)(Ee,{src:t[1].src,alt:t[1].alt,onClick:()=>r(1)},t[1].key??`${e}-1`),(0,o.jsx)(Ee,{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)(Ee,{src:s.src,alt:s.alt,overlayCount:c&&i>0?i:0,onClick:()=>r(l)},s.key??`${e}-${l}`)})})}function Ee({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 kr({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,M.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: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(),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:Oe(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 G(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=Oe(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=Oe(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,`
|
|
1847
1872
|
|
|
1848
1873
|
`);const t=e.split(`
|
|
1849
1874
|
`),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(`
|
|
1850
|
-
`)})})]},n++));continue}const c=i.match(/^(#{1,6})(\s+.*)?$/);if(c){const d=c[1].length,u=c[2]?H(c[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+/,""),g=[],m=[];let k=u+1;for(;k<t.length&&k<u+20;){const y=t[k];if(y.length-y.trimStart().length>h&&y.trim()!==""){const N=y.trim();/^[-*+]\s/.test(N)?g.push((0,o.jsx)("li",{children:H(N.replace(/^[-*+]\s+/,""))},`nested-${k}`)):m.push((0,o.jsx)("p",{style:{margin:"0.2em 0 0"},children:H(N)},`cont-${k}`)),k++}else break}const b=m.length>0||g.length>0?(0,o.jsxs)(o.Fragment,{children:[H(p),m,g.length>0&&(0,o.jsx)("ul",{style:{margin:"0.2em 0 0",paddingLeft:"1.2em"},children:g})]}):H(p);d.push((0,o.jsx)("li",{children:b},`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+/,""),g=[],m=[];let k=u+1;for(;k<t.length&&k<u+20;){const y=t[k];if(y.length-y.trimStart().length>h&&y.trim()!==""){const N=y.trim();/^\d+\.\s/.test(N)?g.push((0,o.jsx)("li",{children:H(N.replace(/^\d+\.\s+/,""))},`nested-order-${k}`)):/^[-*+]\s/.test(N)?g.push((0,o.jsx)("li",{children:H(N.replace(/^[-*+]\s+/,""))},`nested-unorder-${k}`)):m.push((0,o.jsx)("p",{style:{margin:"0.2em 0 0"},children:H(N)},`cont-${k}`)),k++}else break}const b=m.length>0||g.length>0?(0,o.jsxs)(o.Fragment,{children:[H(p),m,g.length>0&&(0,o.jsx)("ol",{style:{margin:"0.2em 0 0",paddingLeft:"1.2em"},children:g})]}):H(p);d.push((0,o.jsx)("li",{children:b},`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(m=>m.trim()).filter(m=>m.length>0),h=d.split("|").map(m=>{const k=m.trim();return k.startsWith(":")&&k.endsWith(":")?"center":k.endsWith(":")?"right":(k.startsWith(":"),"left")}).filter((m,k)=>k>0&&k<=u.length),p=[];let g=a+2;for(;g<t.length&&t[g].includes("|")&&t[g].trim()!=="";){const m=t[g].split("|").map(k=>k.trim()).filter(k=>k.length>0);if(m.length>0)p.push(m),g++;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((m,k)=>(0,o.jsx)("th",{style:{textAlign:h[k]||"left"},className:"ak-md-th",children:H(m)},`th-${k}`))})}),(0,o.jsx)("tbody",{children:p.map((m,k)=>(0,o.jsx)("tr",{children:u.map((b,y)=>(0,o.jsx)("td",{style:{textAlign:h[y]||"left"},className:"ak-md-td",children:m[y]?H(m[y]):""},`td-${k}-${y}`))},`tr-${k}`))})]},n++)),a=g;continue}}const l=[];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());)l.push(t[a]),a++;if(l.length>0){const d=[];l.forEach((u,h)=>{d.push(...H(u)),h<l.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 aa({message:e,thinkingViewable:t=!1}){const[r,a]=(0,E.useState)(null),[n,i]=(0,E.useState)(null),s=e.role==="user",c=e.status==="error",l=e.status==="streaming",d=!!(e.images&&e.images.length>0),u=(()=>{if(!s)return[];const C=(e.uploadedAttachments??[]).filter(S=>S.kind==="image").map(S=>({url:S.url,mimeType:S.mimeType,fileName:S.fileName}));return C.length>0?C:e.uploadedImageUrl?[{url:e.uploadedImageUrl,mimeType:"image/jpeg"}]:[]})(),h=s?(e.uploadedAttachments??[]).filter(C=>C.kind==="file"):[],p=u.length>0,g=h.length>0,m=d||p,k=!s&&!c,b=!!e.isHuman&&!s,y=s?"ak-message--user":c?"ak-message--assistant ak-message--error":b?"ak-message--assistant ak-message--operator":"ak-message--assistant",N=["ak-message__bubble",k?"ak-message__bubble--md":"",m?"ak-message__bubble--has-image":"",b?"ak-message__bubble--operator":""].filter(Boolean).join(" "),R=b?e.senderDisplay?.trim()||"Operator":null,P=R?R.charAt(0).toUpperCase():"",U=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:N,children:[p&&(0,o.jsx)(cr,{messageId:`${e.id}-up`,images:u.map(C=>({src:C.url,alt:C.fileName??"Uploaded image",downloadHref:C.url})),onCellClick:C=>a(C)}),g&&(0,o.jsx)("div",{className:"ak-message__files",children:h.map((C,S)=>(0,o.jsx)(Ts,{url:C.url,mimeType:C.mimeType,fileName:C.fileName},`${e.id}-up-file-${S}`))}),d&&(0,o.jsx)(cr,{messageId:`${e.id}-asst`,images:e.images.map((C,S)=>{const ce=C.url??(C.base64?`data:${C.mimeType};base64,${C.base64}`:null);return ce?{src:ce,alt:"Generated image",downloadHref:C.url??ce,key:`gen-${S}`}:null}).filter(C=>C!==null),onCellClick:C=>i(C)}),(e.content||l&&!e.isThinking&&!e.toolStatus)&&(0,o.jsxs)("div",{className:m?"ak-message__image-caption":void 0,children:[k?Es(e.content):e.content,l&&!e.isThinking&&!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:Ls(e.createdAt)})]}),V=!!e.content||!e.isThinking&&!e.toolStatus;return(0,o.jsxs)("div",{className:`ak-message ${y}`,children:[!s&&(e.ackText||e.progressEvents&&e.progressEvents.length>0)&&(0,o.jsx)(Ss,{ackText:e.ackText,events:e.progressEvents,collapsed:e.progressCollapsed,isComplete:!l}),!s&&(0,o.jsx)(Cs,{thinking:e.thinking,isThinking:e.isThinking??!1,thinkingViewable:t}),!s&&e.toolStatus&&!(e.progressEvents&&e.progressEvents.length>0)&&(0,o.jsx)(Ns,{status:e.toolStatus}),b&&(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})]}),V&&U,u.length>0&&(0,o.jsx)(dr,{images:u.map(C=>({src:C.url,alt:C.fileName??"Uploaded image",downloadHref:C.url})),index:r,onClose:()=>a(null),onIndexChange:a}),d&&(0,o.jsx)(dr,{images:e.images.map(C=>{const S=C.url??(C.base64?`data:${C.mimeType};base64,${C.base64}`:null);return S?{src:S,alt:"Generated image",downloadHref:C.url??S}:null}).filter(C=>C!==null),index:n,onClose:()=>i(null),onIndexChange:i})]})}function na(){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 As(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 ia({messages:e,isLoading:t,thinkingViewable:r,operatorFallbackLabel:a="Operator"}){const n=(0,E.useRef)(null),i=(0,E.useRef)(null),s=(0,E.useRef)(!0),c=(0,E.useMemo)(()=>As(e,a),[e,a]);return(0,E.useEffect)(()=>{if(!(n.current?.parentElement??n.current))return;const l=h=>{s.current=h.scrollHeight-h.scrollTop-h.clientHeight<120};let d=n.current;for(;d&&getComputedStyle(d).overflowY==="visible";)d=d.parentElement;if(!d)return;const u=()=>l(d);return d.addEventListener("scroll",u,{passive:!0}),()=>d.removeEventListener("scroll",u)},[]),(0,E.useEffect)(()=>{e[e.length-1]?.role==="user"&&(s.current=!0),s.current&&i.current?.scrollIntoView({behavior:"smooth"})},[e]),(0,E.useEffect)(()=>{s.current&&i.current?.scrollIntoView({behavior:"smooth"})},[t,e.find(l=>l.status==="streaming")?.content??"",e.find(l=>l.isThinking)?.thinking??""]),(0,o.jsxs)("div",{ref:n,className:"ak-messages",role:"log","aria-live":"polite","aria-label":"Conversation",children:[c.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)(aa,{message:l.message,thinkingViewable:r},l.message.id)),t&&!e.some(l=>l.status==="streaming")&&(0,o.jsx)(na,{}),(0,o.jsx)("div",{ref:i})]})}function Ms(){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 Rs({title:e,description:t,greeting:r,avatarUrl:a}){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)(Ms,{})})}),(0,o.jsx)("p",{className:"ak-empty-state__title",children:e}),t&&(0,o.jsx)("p",{className:"ak-empty-state__description",children:t})]}),r&&(0,o.jsxs)("div",{className:"ak-empty-state__quote",children:[(0,o.jsx)("span",{className:"ak-empty-state__quote-mark","aria-hidden":"true",children:'"'}),(0,o.jsx)("p",{className:"ak-empty-state__quote-text",children:r})]})]})}function Zs(){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 Os(){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 Fs(){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 hr(){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 fr(){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 sa=["application/pdf","text/markdown","text/plain","text/csv"],oa=[".pdf",".md",".txt",".csv"],Ps=[...oa,...sa].join(","),la=["image/jpeg","image/png","image/gif","image/webp"],Vs=la.join(",");function Ws(e){if(sa.includes(e.type))return!0;const t=e.name.toLowerCase();return oa.some(r=>t.endsWith(r))}function $s(e){return la.includes(e.type)}function ca({onSend:e,disabled:t=!1,placeholder:r="Type a message…",privacyPolicyUrl:a,termsOfServiceUrl:n,photoSendingEnabled:i=!1,fileUploadEnabled:s=!1,attachmentMaxCount:c=5,attachmentMaxFileSizeMb:l=1}){const[d,u]=(0,E.useState)(""),[h,p]=(0,E.useState)([]),[g,m]=(0,E.useState)(new Map),[k,b]=(0,E.useState)(!1),y=(0,E.useRef)(null),N=(0,E.useRef)(null),R=(0,E.useRef)(null),P=(0,E.useRef)(null),U=(0,E.useRef)(null),V=i||s,C=(0,E.useMemo)(()=>l*1024*1024,[l]);(0,E.useEffect)(()=>()=>{g.forEach(T=>URL.revokeObjectURL(T))},[]),(0,E.useEffect)(()=>{t||y.current?.focus()},[t]);const S=(0,E.useCallback)(T=>{if(!k)return;const O=T.composedPath?T.composedPath():[],J=!!P.current&&O.includes(P.current),W=!!U.current&&O.includes(U.current);!J&&!W&&b(!1)},[k]);(0,E.useEffect)(()=>{if(k)return document.addEventListener("click",S),()=>document.removeEventListener("click",S)},[k,S]),(0,E.useEffect)(()=>{V||b(!1)},[V]);function ce(){g.forEach(T=>URL.revokeObjectURL(T)),m(new Map),p([]),N.current&&(N.current.value=""),R.current&&(R.current.value="")}function Ce(T){p(O=>{const J=O[T];if(J){const W=g.get(J.file);W&&(URL.revokeObjectURL(W),m(B=>{const Ie=new Map(B);return Ie.delete(J.file),Ie}))}return O.filter((W,B)=>B!==T)})}function ge(){const T=d.trim();!T&&h.length===0||t||(e(T,h),u(""),ce(),y.current&&(y.current.style.height="auto"))}function Pe(T){T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),ge())}function Ve(T){const O=T.currentTarget;u(O.value),O.style.height="auto",O.style.height=`${O.scrollHeight}px`}function We(T,O){if(T.length===0)return;const J=[],W=[];for(const B of T){if(O==="image"&&!$s(B)){W.push(`${B.name} (image type not supported)`);continue}if(O==="file"&&!Ws(B)){W.push(`${B.name} (file type not supported)`);continue}if(B.size>C){W.push(`${B.name} (over ${l} MB)`);continue}J.push({file:B,kind:O})}p(B=>{const Ie=[...B,...J],Bt=Ie.slice(0,c);return Ie.length>c&&W.push(`max ${c} attachments allowed`),m(ga=>{const lt=new Map(ga);for(const $e of Bt)$e.kind==="image"&&!lt.has($e.file)&<.set($e.file,URL.createObjectURL($e.file));return lt}),Bt}),W.length>0&&alert(`Some attachments were not added:
|
|
1851
|
-
• ${
|
|
1852
|
-
• `)}`)}function
|
|
1853
|
-
`+
|
|
1875
|
+
`)})})]},n++));continue}const l=i.match(/^(#{1,6})(\s+.*)?$/);if(l){const d=l[1].length,u=l[2]?G(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=[],x=[];let v=u+1;for(;v<t.length&&v<u+20;){const g=t[v];if(g.length-g.trimStart().length>h&&g.trim()!==""){const I=g.trim();/^[-*+]\s/.test(I)?f.push((0,o.jsx)("li",{children:G(I.replace(/^[-*+]\s+/,""))},`nested-${v}`)):x.push((0,o.jsx)("p",{style:{margin:"0.2em 0 0"},children:G(I)},`cont-${v}`)),v++}else break}const w=x.length>0||f.length>0?(0,o.jsxs)(o.Fragment,{children:[G(p),x,f.length>0&&(0,o.jsx)("ul",{style:{margin:"0.2em 0 0",paddingLeft:"1.2em"},children:f})]}):G(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},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=[],x=[];let v=u+1;for(;v<t.length&&v<u+20;){const g=t[v];if(g.length-g.trimStart().length>h&&g.trim()!==""){const I=g.trim();/^\d+\.\s/.test(I)?f.push((0,o.jsx)("li",{children:G(I.replace(/^\d+\.\s+/,""))},`nested-order-${v}`)):/^[-*+]\s/.test(I)?f.push((0,o.jsx)("li",{children:G(I.replace(/^[-*+]\s+/,""))},`nested-unorder-${v}`)):x.push((0,o.jsx)("p",{style:{margin:"0.2em 0 0"},children:G(I)},`cont-${v}`)),v++}else break}const w=x.length>0||f.length>0?(0,o.jsxs)(o.Fragment,{children:[G(p),x,f.length>0&&(0,o.jsx)("ol",{style:{margin:"0.2em 0 0",paddingLeft:"1.2em"},children:f})]}):G(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},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(x=>x.trim()).filter(x=>x.length>0),h=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 f=a+2;for(;f<t.length&&t[f].includes("|")&&t[f].trim()!=="";){const x=t[f].split("|").map(v=>v.trim()).filter(v=>v.length>0);if(x.length>0)p.push(x),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((x,v)=>(0,o.jsx)("th",{style:{textAlign:h[v]||"left"},className:"ak-md-th",children:G(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:h[g]||"left"},className:"ak-md-td",children:x[g]?G(x[g]):""},`td-${v}-${g}`))},`tr-${v}`))})]},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(...G(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,M.useState)(null),[a,n]=(0,M.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(j=>j.kind==="image").map(j=>({url:j.url,mimeType:j.mimeType,fileName:j.fileName}));return _.length>0?_:e.uploadedImageUrl?[{url:e.uploadedImageUrl,mimeType:"image/jpeg"}]:[]})(),h=i?(e.uploadedAttachments??[]).filter(_=>_.kind==="file"):[],p=u.length>0,f=h.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,F=R?R.charAt(0).toUpperCase():"",X=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:I,children:[p&&(0,o.jsx)(xr,{messageId:`${e.id}-up`,images:u.map(_=>({src:_.url,alt:_.fileName??"Uploaded image",downloadHref:_.url})),onCellClick:_=>r(_)}),f&&(0,o.jsx)("div",{className:"ak-message__files",children:h.map((_,j)=>(0,o.jsx)(yr,{url:_.url,mimeType:_.mimeType,fileName:_.fileName},`${e.id}-up-file-${j}`))}),c&&(0,o.jsx)(xr,{messageId:`${e.id}-asst`,images:e.images.map((_,j)=>{const ie=_.url??(_.base64?`data:${_.mimeType};base64,${_.base64}`:null);return ie?{src:ie,alt:"Generated image",downloadHref:_.url??ie,key:`gen-${j}`}:null}).filter(_=>_!==null),onCellClick:_=>n(_)}),d&&(0,o.jsx)("div",{className:"ak-message__files",children:e.documents.map((_,j)=>_.url?(0,o.jsx)(yr,{url:_.url,mimeType:_.mimeType,fileName:_.fileName},`${e.id}-asst-doc-${j}`):null)}),(e.content||l&&!e.toolStatus)&&(0,o.jsxs)("div",{className:x?"ak-message__image-caption":void 0,children:[v?Hs(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:Gs(e.createdAt)})]}),z=!!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)(Ds,{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)(Bs,{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:F}),(0,o.jsx)("span",{className:"ak-message__operator-name",children:R})]}),z&&X,u.length>0&&(0,o.jsx)(kr,{images:u.map(_=>({src:_.url,alt:_.fileName??"Uploaded image",downloadHref:_.url})),index:t,onClose:()=>r(null),onIndexChange:r}),c&&(0,o.jsx)(kr,{images:e.images.map(_=>{const j=_.url??(_.base64?`data:${_.mimeType};base64,${_.base64}`:null);return j?{src:j,alt:"Generated image",downloadHref:_.url??j}:null}).filter(_=>_!==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,M.useRef)(null),n=(0,M.useRef)(null),i=(0,M.useRef)(!0),s=(0,M.useMemo)(()=>Ys(e,r),[e,r]);return(0,M.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,M.useEffect)(()=>{e[e.length-1]?.role==="user"&&(i.current=!0),i.current&&n.current?.scrollIntoView({behavior:"smooth"})},[e]),(0,M.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 xa=["application/pdf","text/markdown","text/plain","text/csv"],ka=[".pdf",".md",".txt",".csv"],ro=[...ka,...xa].join(","),ya=["image/jpeg","image/png","image/gif","image/webp"],ao=ya.join(",");function no(e){if(xa.includes(e.type))return!0;const t=e.name.toLowerCase();return ka.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,M.useState)(""),[d,u]=(0,M.useState)([]),[h,p]=(0,M.useState)(new Map),[f,x]=(0,M.useState)(!1),v=(0,M.useRef)(null),w=(0,M.useRef)(null),g=(0,M.useRef)(null),I=(0,M.useRef)(null),R=(0,M.useRef)(null),F=a||n,X=(0,M.useMemo)(()=>s*1024*1024,[s]);(0,M.useEffect)(()=>()=>{h.forEach(E=>URL.revokeObjectURL(E))},[]),(0,M.useEffect)(()=>{t||v.current?.focus()},[t]);const z=(0,M.useCallback)(E=>{if(!f)return;const O=E.composedPath?E.composedPath():[],J=!!I.current&&O.includes(I.current),P=!!R.current&&O.includes(R.current);!J&&!P&&x(!1)},[f]);(0,M.useEffect)(()=>{if(f)return document.addEventListener("click",z),()=>document.removeEventListener("click",z)},[f,z]),(0,M.useEffect)(()=>{F||x(!1)},[F]);function _(){h.forEach(E=>URL.revokeObjectURL(E)),p(new Map),u([]),w.current&&(w.current.value=""),g.current&&(g.current.value="")}function j(E){u(O=>{const J=O[E];if(J){const P=h.get(J.file);P&&(URL.revokeObjectURL(P),p(U=>{const Ne=new Map(U);return Ne.delete(J.file),Ne}))}return O.filter((P,U)=>U!==E)})}function ie(){const E=l.trim();!E&&d.length===0||t||(e(E,d),c(""),_(),v.current&&(v.current.style.height="auto"))}function $e(E){E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),ie())}function Ce(E){const O=E.currentTarget;c(O.value),O.style.height="auto",O.style.height=`${O.scrollHeight}px`}function Ie(E,O){if(E.length===0)return;const J=[],P=[];for(const U of E){if(O==="image"&&!io(U)){P.push(`${U.name} (image type not supported)`);continue}if(O==="file"&&!no(U)){P.push(`${U.name} (file type not supported)`);continue}if(U.size>X){P.push(`${U.name} (over ${s} MB)`);continue}J.push({file:U,kind:O})}u(U=>{const Ne=[...U,...J],Kt=Ne.slice(0,i);return Ne.length>i&&P.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}),P.length>0&&alert(`Some attachments were not added:
|
|
1876
|
+
• ${P.join(`
|
|
1877
|
+
• `)}`)}function Ve(E){const O=Array.from(E.currentTarget.files??[]);E.currentTarget.value="",Ie(O,"image")}function ht(E){const O=Array.from(E.currentTarget.files??[]);E.currentTarget.value="",Ie(O,"file")}function ja(){x(!1),w.current?.click()}function Sa(){x(!1),g.current?.click()}const Ca=!t&&(!!l.trim()||d.length>0);return(0,o.jsxs)("div",{className:"ak-composer",children:[F&&f&&(0,o.jsxs)("div",{ref:I,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((E,O)=>{const J=`${E.file.name}-${O}`;if(E.kind==="image"){const P=h.get(E.file);return(0,o.jsxs)("div",{className:"ak-composer__preview-wrap",role:"listitem",children:[P&&(0,o.jsx)("img",{src:P,alt:E.file.name,className:"ak-composer__preview-img"}),(0,o.jsx)("button",{className:"ak-composer__preview-remove",onClick:()=>j(O),type:"button","aria-label":`Remove ${E.file.name}`,disabled:t,children:(0,o.jsx)(wr,{})})]},J)}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:E.file.name,children:E.file.name}),(0,o.jsx)("button",{className:"ak-composer__file-chip-remove",onClick:()=>j(O),type:"button","aria-label":`Remove ${E.file.name}`,disabled:t,children:(0,o.jsx)(wr,{})})]},J)})}),(0,o.jsxs)("div",{className:"ak-composer__input-wrap",children:[F&&(0,o.jsxs)(o.Fragment,{children:[a&&(0,o.jsx)("input",{ref:w,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:()=>x(E=>!E),disabled:t,"aria-label":"Attachment options","aria-haspopup":"true","aria-expanded":f,type:"button",children:(0,o.jsx)(eo,{})})})]}),(0,o.jsx)("textarea",{ref:v,className:"ak-composer__input",value:l,onInput:Ce,onKeyDown:$e,placeholder:r,disabled:t,rows:1,"aria-label":"Message input"}),(0,o.jsx)("button",{className:"ak-composer__send",onClick:ie,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,M.useRef)(null);return(0,M.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,M.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,M.createElement)(Ut,{config:t,state:r,callbacks:a})),{update(i,s){n.render((0,M.createElement)(Ut,{config:s,state:i,callbacks:a}))},destroy(){setTimeout(()=>{n.unmount()},0)}}};function wa(e){return ha+`
|
|
1878
|
+
`+da(e)}function Qt(e,t){return wa(Se({...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=Se;exports.prepareInlineContainer=la;exports.removeShadowHost=sa;exports.renderWidget=ut;exports.resolveThemeMode=ua;exports.setSessionId=Le;exports.streamChat=ea;exports.widgetCSS=ha;
|