@bymos/agentkit-sdk 0.9.3 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/agentkit-widget.iife.js +149 -126
- package/agentkit-widget.js +150 -127
- package/index.cjs +145 -122
- package/index.d.ts +1 -1
- package/index.js +165 -237
- package/package.json +1 -1
package/agentkit-widget.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
var e;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(e||={});var t;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(t||={});var n=e.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),r=e=>{switch(typeof e){case`undefined`:return n.undefined;case`string`:return n.string;case`number`:return Number.isNaN(e)?n.nan:n.number;case`boolean`:return n.boolean;case`function`:return n.function;case`bigint`:return n.bigint;case`symbol`:return n.symbol;case`object`:return Array.isArray(e)?n.array:e===null?n.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?n.promise:typeof Map<`u`&&e instanceof Map?n.map:typeof Set<`u`&&e instanceof Set?n.set:typeof Date<`u`&&e instanceof Date?n.date:n.object;default:return n.unknown}},i=e.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),a=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(e){if(!(e instanceof t))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,e.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};a.create=e=>new a(e);var o=(t,r)=>{let a;switch(t.code){case i.invalid_type:a=t.received===n.undefined?`Required`:`Expected ${t.expected}, received ${t.received}`;break;case i.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(t.expected,e.jsonStringifyReplacer)}`;break;case i.unrecognized_keys:a=`Unrecognized key(s) in object: ${e.joinValues(t.keys,`, `)}`;break;case i.invalid_union:a=`Invalid input`;break;case i.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${e.joinValues(t.options)}`;break;case i.invalid_enum_value:a=`Invalid enum value. Expected ${e.joinValues(t.options)}, received '${t.received}'`;break;case i.invalid_arguments:a=`Invalid function arguments`;break;case i.invalid_return_type:a=`Invalid function return type`;break;case i.invalid_date:a=`Invalid date`;break;case i.invalid_string:typeof t.validation==`object`?`includes`in t.validation?(a=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position==`number`&&(a=`${a} at one or more positions greater than or equal to ${t.validation.position}`)):`startsWith`in t.validation?a=`Invalid input: must start with "${t.validation.startsWith}"`:`endsWith`in t.validation?a=`Invalid input: must end with "${t.validation.endsWith}"`:e.assertNever(t.validation):a=t.validation===`regex`?`Invalid`:`Invalid ${t.validation}`;break;case i.too_small:a=t.type===`array`?`Array must contain ${t.exact?`exactly`:t.inclusive?`at least`:`more than`} ${t.minimum} element(s)`:t.type===`string`?`String must contain ${t.exact?`exactly`:t.inclusive?`at least`:`over`} ${t.minimum} character(s)`:t.type===`number`||t.type===`bigint`?`Number must be ${t.exact?`exactly equal to `:t.inclusive?`greater than or equal to `:`greater than `}${t.minimum}`:t.type===`date`?`Date must be ${t.exact?`exactly equal to `:t.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(t.minimum))}`:`Invalid input`;break;case i.too_big:a=t.type===`array`?`Array must contain ${t.exact?`exactly`:t.inclusive?`at most`:`less than`} ${t.maximum} element(s)`:t.type===`string`?`String must contain ${t.exact?`exactly`:t.inclusive?`at most`:`under`} ${t.maximum} character(s)`:t.type===`number`?`Number must be ${t.exact?`exactly`:t.inclusive?`less than or equal to`:`less than`} ${t.maximum}`:t.type===`bigint`?`BigInt must be ${t.exact?`exactly`:t.inclusive?`less than or equal to`:`less than`} ${t.maximum}`:t.type===`date`?`Date must be ${t.exact?`exactly`:t.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(t.maximum))}`:`Invalid input`;break;case i.custom:a=`Invalid input`;break;case i.invalid_intersection_types:a=`Intersection results could not be merged`;break;case i.not_multiple_of:a=`Number must be a multiple of ${t.multipleOf}`;break;case i.not_finite:a=`Number must be finite`;break;default:a=r.defaultError,e.assertNever(t)}return{message:a}},s=o;function c(){return s}var l=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function u(e,t){let n=c(),r=l({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===o?void 0:o].filter(e=>!!e)});e.common.issues.push(r)}var d=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return f;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return f;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},f=Object.freeze({status:`aborted`}),p=e=>({status:`dirty`,value:e}),m=e=>({status:`valid`,value:e}),h=e=>e.status===`aborted`,g=e=>e.status===`dirty`,_=e=>e.status===`valid`,v=e=>typeof Promise<`u`&&e instanceof Promise,y;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(y||={});var b=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}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}},x=(e,t)=>{if(_(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new a(e.common.issues);return this._error=t,this._error}}};function S(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var C=class{get description(){return this._def.description}_getType(e){return r(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:r(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new d,ctx:{common:e.parent.common,data:e.data,parsedType:r(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(v(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)};return x(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return _(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>_(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)},i=this._parse({data:e,path:n.path,parent:n});return x(n,await(v(i)?i:Promise.resolve(i)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let a=e(t),o=()=>r.addIssue({code:i.custom,...n(t)});return typeof Promise<`u`&&a instanceof Promise?a.then(e=>e?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new O({schema:this,typeName:A.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:e=>this[`~validate`](e)}}optional(){return k.create(this,this._def)}nullable(){return Qe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Pe.create(this)}promise(){return Ze.create(this,this._def)}or(e){return Ie.create([this,e],this._def)}and(e){return Be.create(this,e,this._def)}transform(e){return new O({...S(this._def),schema:this,typeName:A.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new $e({...S(this._def),innerType:this,defaultValue:t,typeName:A.ZodDefault})}brand(){return new nt({typeName:A.ZodBranded,type:this,...S(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new et({...S(this._def),innerType:this,catchValue:t,typeName:A.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return rt.create(this,e)}readonly(){return it.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},w=/^c[^\s-]{8,}$/i,T=/^[0-9a-z]+$/,ee=/^[0-9A-HJKMNP-TV-Z]{26}$/i,te=/^[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,E=/^[a-z0-9_-]{21}$/i,ne=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,re=/^[-+]?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)?)??$/,ie=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ae=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,oe,se=/^(?:(?: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])$/,ce=/^(?:(?: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])$/,le=/^(([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]))$/,ue=/^(([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])$/,de=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,fe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,pe=`((\\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])))`,me=RegExp(`^${pe}$`);function he(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function ge(e){return RegExp(`^${he(e)}$`)}function _e(e){let t=`${pe}T${he(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function ve(e,t){return!!((t===`v4`||!t)&&se.test(e)||(t===`v6`||!t)&&le.test(e))}function ye(e,t){if(!ne.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function be(e,t){return!!((t===`v4`||!t)&&ce.test(e)||(t===`v6`||!t)&&ue.test(e))}var xe=class t extends C{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==n.string){let e=this._getOrReturnCtx(t);return u(e,{code:i.invalid_type,expected:n.string,received:e.parsedType}),f}let r=new d,a;for(let n of this._def.checks)if(n.kind===`min`)t.data.length<n.value&&(a=this._getOrReturnCtx(t,a),u(a,{code:i.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),u(a,{code:i.too_big,maximum:n.value,type:`string`,inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind===`length`){let e=t.data.length>n.value,o=t.data.length<n.value;(e||o)&&(a=this._getOrReturnCtx(t,a),e?u(a,{code:i.too_big,maximum:n.value,type:`string`,inclusive:!0,exact:!0,message:n.message}):o&&u(a,{code:i.too_small,minimum:n.value,type:`string`,inclusive:!0,exact:!0,message:n.message}),r.dirty())}else if(n.kind===`email`)ie.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`email`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`emoji`)oe||=new RegExp(ae,`u`),oe.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`emoji`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`uuid`)te.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`uuid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`nanoid`)E.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`nanoid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`cuid`)w.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`cuid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`cuid2`)T.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`cuid2`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`ulid`)ee.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`ulid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`url`)try{new URL(t.data)}catch{a=this._getOrReturnCtx(t,a),u(a,{validation:`url`,code:i.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),u(a,{validation:`regex`,code:i.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),u(a,{code:i.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),u(a,{code:i.invalid_string,validation:{startsWith:n.value},message:n.message}),r.dirty()):n.kind===`endsWith`?t.data.endsWith(n.value)||(a=this._getOrReturnCtx(t,a),u(a,{code:i.invalid_string,validation:{endsWith:n.value},message:n.message}),r.dirty()):n.kind===`datetime`?_e(n).test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{code:i.invalid_string,validation:`datetime`,message:n.message}),r.dirty()):n.kind===`date`?me.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{code:i.invalid_string,validation:`date`,message:n.message}),r.dirty()):n.kind===`time`?ge(n).test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{code:i.invalid_string,validation:`time`,message:n.message}),r.dirty()):n.kind===`duration`?re.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`duration`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`ip`?ve(t.data,n.version)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`ip`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`jwt`?ye(t.data,n.alg)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`jwt`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`cidr`?be(t.data,n.version)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`cidr`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`base64`?de.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`base64`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`base64url`?fe.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`base64url`,code:i.invalid_string,message:n.message}),r.dirty()):e.assertNever(n);return{status:r.value,value:t.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:i.invalid_string,...y.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:`email`,...y.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...y.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...y.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...y.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...y.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...y.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...y.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...y.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...y.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...y.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...y.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...y.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...y.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...y.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...y.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...y.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...y.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...y.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...y.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...y.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...y.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...y.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...y.errToObj(t)})}nonempty(e){return this.min(1,y.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};xe.create=e=>new xe({checks:[],typeName:A.ZodString,coerce:e?.coerce??!1,...S(e)});function Se(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var Ce=class t extends C{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)!==n.number){let e=this._getOrReturnCtx(t);return u(e,{code:i.invalid_type,expected:n.number,received:e.parsedType}),f}let r,a=new d;for(let n of this._def.checks)n.kind===`int`?e.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{code:i.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),u(r,{code:i.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),u(r,{code:i.too_big,maximum:n.value,type:`number`,inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind===`multipleOf`?Se(t.data,n.value)!==0&&(r=this._getOrReturnCtx(t,r),u(r,{code:i.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):n.kind===`finite`?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{code:i.not_finite,message:n.message}),a.dirty()):e.assertNever(n);return{status:a.value,value:t.data}}gte(e,t){return this.setLimit(`min`,e,!0,y.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,y.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,y.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,y.toString(t))}setLimit(e,n,r,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:y.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:`int`,message:y.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:y.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:y.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:y.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:y.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(t=>t.kind===`int`||t.kind===`multipleOf`&&e.isInteger(t.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};Ce.create=e=>new Ce({checks:[],typeName:A.ZodNumber,coerce:e?.coerce||!1,...S(e)});var we=class t extends C{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)!==n.bigint)return this._getInvalidInput(t);let r,a=new d;for(let n of this._def.checks)n.kind===`min`?(n.inclusive?t.data<n.value:t.data<=n.value)&&(r=this._getOrReturnCtx(t,r),u(r,{code:i.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),u(r,{code:i.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),u(r,{code:i.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):e.assertNever(n);return{status:a.value,value:t.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.bigint,received:t.parsedType}),f}gte(e,t){return this.setLimit(`min`,e,!0,y.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,y.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,y.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,y.toString(t))}setLimit(e,n,r,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:y.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:y.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};we.create=e=>new we({checks:[],typeName:A.ZodBigInt,coerce:e?.coerce??!1,...S(e)});var Te=class extends C{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==n.boolean){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.boolean,received:t.parsedType}),f}return m(e.data)}};Te.create=e=>new Te({typeName:A.ZodBoolean,coerce:e?.coerce||!1,...S(e)});var Ee=class t extends C{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==n.date){let e=this._getOrReturnCtx(t);return u(e,{code:i.invalid_type,expected:n.date,received:e.parsedType}),f}if(Number.isNaN(t.data.getTime()))return u(this._getOrReturnCtx(t),{code:i.invalid_date}),f;let r=new d,a;for(let n of this._def.checks)n.kind===`min`?t.data.getTime()<n.value&&(a=this._getOrReturnCtx(t,a),u(a,{code:i.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),u(a,{code:i.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:`date`}),r.dirty()):e.assertNever(n);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:y.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:y.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};Ee.create=e=>new Ee({checks:[],coerce:e?.coerce||!1,typeName:A.ZodDate,...S(e)});var De=class extends C{_parse(e){if(this._getType(e)!==n.symbol){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.symbol,received:t.parsedType}),f}return m(e.data)}};De.create=e=>new De({typeName:A.ZodSymbol,...S(e)});var Oe=class extends C{_parse(e){if(this._getType(e)!==n.undefined){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.undefined,received:t.parsedType}),f}return m(e.data)}};Oe.create=e=>new Oe({typeName:A.ZodUndefined,...S(e)});var ke=class extends C{_parse(e){if(this._getType(e)!==n.null){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.null,received:t.parsedType}),f}return m(e.data)}};ke.create=e=>new ke({typeName:A.ZodNull,...S(e)});var Ae=class extends C{constructor(){super(...arguments),this._any=!0}_parse(e){return m(e.data)}};Ae.create=e=>new Ae({typeName:A.ZodAny,...S(e)});var je=class extends C{constructor(){super(...arguments),this._unknown=!0}_parse(e){return m(e.data)}};je.create=e=>new je({typeName:A.ZodUnknown,...S(e)});var Me=class extends C{_parse(e){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.never,received:t.parsedType}),f}};Me.create=e=>new Me({typeName:A.ZodNever,...S(e)});var Ne=class extends C{_parse(e){if(this._getType(e)!==n.undefined){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.void,received:t.parsedType}),f}return m(e.data)}};Ne.create=e=>new Ne({typeName:A.ZodVoid,...S(e)});var Pe=class e extends C{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),a=this._def;if(t.parsedType!==n.array)return u(t,{code:i.invalid_type,expected:n.array,received:t.parsedType}),f;if(a.exactLength!==null){let e=t.data.length>a.exactLength.value,n=t.data.length<a.exactLength.value;(e||n)&&(u(t,{code:e?i.too_big:i.too_small,minimum:n?a.exactLength.value:void 0,maximum:e?a.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(a.minLength!==null&&t.data.length<a.minLength.value&&(u(t,{code:i.too_small,minimum:a.minLength.value,type:`array`,inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),a.maxLength!==null&&t.data.length>a.maxLength.value&&(u(t,{code:i.too_big,maximum:a.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>a.type._parseAsync(new b(t,e,t.path,n)))).then(e=>d.mergeArray(r,e));let o=[...t.data].map((e,n)=>a.type._parseSync(new b(t,e,t.path,n)));return d.mergeArray(r,o)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:y.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:y.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:y.toString(n)}})}nonempty(e){return this.min(1,e)}};Pe.create=(e,t)=>new Pe({type:e,minLength:null,maxLength:null,exactLength:null,typeName:A.ZodArray,...S(t)});function Fe(e){if(e instanceof D){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=k.create(Fe(r))}return new D({...e._def,shape:()=>t})}else if(e instanceof Pe)return new Pe({...e._def,type:Fe(e.element)});else if(e instanceof k)return k.create(Fe(e.unwrap()));else if(e instanceof Qe)return Qe.create(Fe(e.unwrap()));else if(e instanceof Ve)return Ve.create(e.items.map(e=>Fe(e)));else return e}var D=class t extends C{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),n=e.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(e){if(this._getType(e)!==n.object){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.object,received:t.parsedType}),f}let{status:t,ctx:r}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof Me&&this._def.unknownKeys===`strip`))for(let e in r.data)o.includes(e)||s.push(e);let c=[];for(let e of o){let t=a[e],n=r.data[e];c.push({key:{status:`valid`,value:e},value:t._parse(new b(r,n,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof Me){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of s)c.push({key:{status:`valid`,value:e},value:{status:`valid`,value:r.data[e]}});else if(e===`strict`)s.length>0&&(u(r,{code:i.unrecognized_keys,keys:s}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of s){let n=r.data[t];c.push({key:{status:`valid`,value:t},value:e._parse(new b(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of c){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>d.mergeObjectSync(t,e)):d.mergeObjectSync(t,c)}get shape(){return this._def.shape()}strict(e){return y.errToObj,new t({...this._def,unknownKeys:`strict`,...e===void 0?{}:{errorMap:(t,n)=>{let r=this._def.errorMap?.(t,n).message??n.defaultError;return t.code===`unrecognized_keys`?{message:y.errToObj(e).message??r}:{message:r}}}})}strip(){return new t({...this._def,unknownKeys:`strip`})}passthrough(){return new t({...this._def,unknownKeys:`passthrough`})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:A.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new t({...this._def,catchall:e})}pick(n){let r={};for(let t of e.objectKeys(n))n[t]&&this.shape[t]&&(r[t]=this.shape[t]);return new t({...this._def,shape:()=>r})}omit(n){let r={};for(let t of e.objectKeys(this.shape))n[t]||(r[t]=this.shape[t]);return new t({...this._def,shape:()=>r})}deepPartial(){return Fe(this)}partial(n){let r={};for(let t of e.objectKeys(this.shape)){let e=this.shape[t];n&&!n[t]?r[t]=e:r[t]=e.optional()}return new t({...this._def,shape:()=>r})}required(n){let r={};for(let t of e.objectKeys(this.shape))if(n&&!n[t])r[t]=this.shape[t];else{let e=this.shape[t];for(;e instanceof k;)e=e._def.innerType;r[t]=e}return new t({...this._def,shape:()=>r})}keyof(){return Je(e.objectKeys(this.shape))}};D.create=(e,t)=>new D({shape:()=>e,unknownKeys:`strip`,catchall:Me.create(),typeName:A.ZodObject,...S(t)}),D.strictCreate=(e,t)=>new D({shape:()=>e,unknownKeys:`strict`,catchall:Me.create(),typeName:A.ZodObject,...S(t)}),D.lazycreate=(e,t)=>new D({shape:e,unknownKeys:`strip`,catchall:Me.create(),typeName:A.ZodObject,...S(t)});var Ie=class extends C{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new a(e.ctx.common.issues));return u(t,{code:i.invalid_union,unionErrors:n}),f}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let o=r.map(e=>new a(e));return u(t,{code:i.invalid_union,unionErrors:o}),f}}get options(){return this._def.options}};Ie.create=(e,t)=>new Ie({options:e,typeName:A.ZodUnion,...S(t)});var Le=t=>t instanceof Ke?Le(t.schema):t instanceof O?Le(t.innerType()):t instanceof qe?[t.value]:t instanceof Ye?t.options:t instanceof Xe?e.objectValues(t.enum):t instanceof $e?Le(t._def.innerType):t instanceof Oe?[void 0]:t instanceof ke?[null]:t instanceof k?[void 0,...Le(t.unwrap())]:t instanceof Qe?[null,...Le(t.unwrap())]:t instanceof nt||t instanceof it?Le(t.unwrap()):t instanceof et?Le(t._def.innerType):[],Re=class e extends C{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==n.object)return u(t,{code:i.invalid_type,expected:n.object,received:t.parsedType}),f;let r=this.discriminator,a=t.data[r],o=this.optionsMap.get(a);return o?t.common.async?o._parseAsync({data:t.data,path:t.path,parent:t}):o._parseSync({data:t.data,path:t.path,parent:t}):(u(t,{code:i.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),f)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=Le(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:A.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...S(r)})}};function ze(t,i){let a=r(t),o=r(i);if(t===i)return{valid:!0,data:t};if(a===n.object&&o===n.object){let n=e.objectKeys(i),r=e.objectKeys(t).filter(e=>n.indexOf(e)!==-1),a={...t,...i};for(let e of r){let n=ze(t[e],i[e]);if(!n.valid)return{valid:!1};a[e]=n.data}return{valid:!0,data:a}}else if(a===n.array&&o===n.array){if(t.length!==i.length)return{valid:!1};let e=[];for(let n=0;n<t.length;n++){let r=t[n],a=i[n],o=ze(r,a);if(!o.valid)return{valid:!1};e.push(o.data)}return{valid:!0,data:e}}else if(a===n.date&&o===n.date&&+t==+i)return{valid:!0,data:t};else return{valid:!1}}var Be=class extends C{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(h(e)||h(r))return f;let a=ze(e.value,r.value);return a.valid?((g(e)||g(r))&&t.dirty(),{status:t.value,value:a.data}):(u(n,{code:i.invalid_intersection_types}),f)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Be.create=(e,t,n)=>new Be({left:e,right:t,typeName:A.ZodIntersection,...S(n)});var Ve=class e extends C{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.array)return u(r,{code:i.invalid_type,expected:n.array,received:r.parsedType}),f;if(r.data.length<this._def.items.length)return u(r,{code:i.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),f;!this._def.rest&&r.data.length>this._def.items.length&&(u(r,{code:i.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let a=[...r.data].map((e,t)=>{let n=this._def.items[t]||this._def.rest;return n?n._parse(new b(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(a).then(e=>d.mergeArray(t,e)):d.mergeArray(t,a)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Ve.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Ve({items:e,typeName:A.ZodTuple,rest:null,...S(t)})};var He=class e extends C{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.object)return u(r,{code:i.invalid_type,expected:n.object,received:r.parsedType}),f;let a=[],o=this._def.keyType,s=this._def.valueType;for(let e in r.data)a.push({key:o._parse(new b(r,e,r.path,e)),value:s._parse(new b(r,r.data[e],r.path,e)),alwaysSet:e in r.data});return r.common.async?d.mergeObjectAsync(t,a):d.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof C?new e({keyType:t,valueType:n,typeName:A.ZodRecord,...S(r)}):new e({keyType:xe.create(),valueType:t,typeName:A.ZodRecord,...S(n)})}},Ue=class extends C{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.map)return u(r,{code:i.invalid_type,expected:n.map,received:r.parsedType}),f;let a=this._def.keyType,o=this._def.valueType,s=[...r.data.entries()].map(([e,t],n)=>({key:a._parse(new b(r,e,r.path,[n,`key`])),value:o._parse(new b(r,t,r.path,[n,`value`]))}));if(r.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of s){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return f;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of s){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return f;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Ue.create=(e,t,n)=>new Ue({valueType:t,keyType:e,typeName:A.ZodMap,...S(n)});var We=class e extends C{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.set)return u(r,{code:i.invalid_type,expected:n.set,received:r.parsedType}),f;let a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(u(r,{code:i.too_small,minimum:a.minSize.value,type:`set`,inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),a.maxSize!==null&&r.data.size>a.maxSize.value&&(u(r,{code:i.too_big,maximum:a.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());let o=this._def.valueType;function s(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return f;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let c=[...r.data.values()].map((e,t)=>o._parse(new b(r,e,r.path,t)));return r.common.async?Promise.all(c).then(e=>s(e)):s(c)}min(t,n){return new e({...this._def,minSize:{value:t,message:y.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:y.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};We.create=(e,t)=>new We({valueType:e,minSize:null,maxSize:null,typeName:A.ZodSet,...S(t)});var Ge=class e extends C{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==n.function)return u(t,{code:i.invalid_type,expected:n.function,received:t.parsedType}),f;function r(e,n){return l({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,c(),o].filter(e=>!!e),issueData:{code:i.invalid_arguments,argumentsError:n}})}function s(e,n){return l({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,c(),o].filter(e=>!!e),issueData:{code:i.invalid_return_type,returnTypeError:n}})}let d={errorMap:t.common.contextualErrorMap},p=t.data;if(this._def.returns instanceof Ze){let e=this;return m(async function(...t){let n=new a([]),i=await e._def.args.parseAsync(t,d).catch(e=>{throw n.addIssue(r(t,e)),n}),o=await Reflect.apply(p,this,i);return await e._def.returns._def.type.parseAsync(o,d).catch(e=>{throw n.addIssue(s(o,e)),n})})}else{let e=this;return m(function(...t){let n=e._def.args.safeParse(t,d);if(!n.success)throw new a([r(t,n.error)]);let i=Reflect.apply(p,this,n.data),o=e._def.returns.safeParse(i,d);if(!o.success)throw new a([s(i,o.error)]);return o.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Ve.create(t).rest(je.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Ve.create([]).rest(je.create()),returns:n||je.create(),typeName:A.ZodFunction,...S(r)})}},Ke=class extends C{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Ke.create=(e,t)=>new Ke({getter:e,typeName:A.ZodLazy,...S(t)});var qe=class extends C{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return u(t,{received:t.data,code:i.invalid_literal,expected:this._def.value}),f}return{status:`valid`,value:e.data}}get value(){return this._def.value}};qe.create=(e,t)=>new qe({value:e,typeName:A.ZodLiteral,...S(t)});function Je(e,t){return new Ye({values:e,typeName:A.ZodEnum,...S(t)})}var Ye=class t extends C{_parse(t){if(typeof t.data!=`string`){let n=this._getOrReturnCtx(t),r=this._def.values;return u(n,{expected:e.joinValues(r),received:n.parsedType,code:i.invalid_type}),f}if(this._cache||=new Set(this._def.values),!this._cache.has(t.data)){let e=this._getOrReturnCtx(t),n=this._def.values;return u(e,{received:e.data,code:i.invalid_enum_value,options:n}),f}return m(t.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(t=>!e.includes(t)),{...this._def,...n})}};Ye.create=Je;var Xe=class extends C{_parse(t){let r=e.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==n.string&&a.parsedType!==n.number){let t=e.objectValues(r);return u(a,{expected:e.joinValues(t),received:a.parsedType,code:i.invalid_type}),f}if(this._cache||=new Set(e.getValidEnumValues(this._def.values)),!this._cache.has(t.data)){let t=e.objectValues(r);return u(a,{received:a.data,code:i.invalid_enum_value,options:t}),f}return m(t.data)}get enum(){return this._def.values}};Xe.create=(e,t)=>new Xe({values:e,typeName:A.ZodNativeEnum,...S(t)});var Ze=class extends C{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==n.promise&&t.common.async===!1?(u(t,{code:i.invalid_type,expected:n.promise,received:t.parsedType}),f):m((t.parsedType===n.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Ze.create=(e,t)=>new Ze({type:e,typeName:A.ZodPromise,...S(t)});var O=class extends C{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===A.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,a={addIssue:e=>{u(r,e),e.fatal?n.abort():n.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),i.type===`preprocess`){let e=i.transform(r.data,a);if(r.common.async)return Promise.resolve(e).then(async e=>{if(n.value===`aborted`)return f;let t=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return t.status===`aborted`?f:t.status===`dirty`||n.value===`dirty`?p(t.value):t});{if(n.value===`aborted`)return f;let t=this._def.schema._parseSync({data:e,path:r.path,parent:r});return t.status===`aborted`?f:t.status===`dirty`||n.value===`dirty`?p(t.value):t}}if(i.type===`refinement`){let e=e=>{let t=i.refinement(e,a);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(r.common.async===!1){let t=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return t.status===`aborted`?f:(t.status===`dirty`&&n.dirty(),e(t.value),{status:n.value,value:t.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(t=>t.status===`aborted`?f:(t.status===`dirty`&&n.dirty(),e(t.value).then(()=>({status:n.value,value:t.value}))))}if(i.type===`transform`)if(r.common.async===!1){let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!_(e))return f;let t=i.transform(e.value,a);if(t instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:n.value,value:t}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>_(e)?Promise.resolve(i.transform(e.value,a)).then(e=>({status:n.value,value:e})):f);e.assertNever(i)}};O.create=(e,t,n)=>new O({schema:e,typeName:A.ZodEffects,effect:t,...S(n)}),O.createWithPreprocess=(e,t,n)=>new O({schema:t,effect:{type:`preprocess`,transform:e},typeName:A.ZodEffects,...S(n)});var k=class extends C{_parse(e){return this._getType(e)===n.undefined?m(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};k.create=(e,t)=>new k({innerType:e,typeName:A.ZodOptional,...S(t)});var Qe=class extends C{_parse(e){return this._getType(e)===n.null?m(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Qe.create=(e,t)=>new Qe({innerType:e,typeName:A.ZodNullable,...S(t)});var $e=class extends C{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===n.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};$e.create=(e,t)=>new $e({innerType:e,typeName:A.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...S(t)});var et=class extends C{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return v(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new a(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new a(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};et.create=(e,t)=>new et({innerType:e,typeName:A.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...S(t)});var tt=class extends C{_parse(e){if(this._getType(e)!==n.nan){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.nan,received:t.parsedType}),f}return{status:`valid`,value:e.data}}};tt.create=e=>new tt({typeName:A.ZodNaN,...S(e)});var nt=class extends C{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},rt=class e extends C{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?f:e.status===`dirty`?(t.dirty(),p(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?f:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:A.ZodPipeline})}},it=class extends C{_parse(e){let t=this._def.innerType._parse(e),n=e=>(_(e)&&(e.value=Object.freeze(e.value)),e);return v(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};it.create=(e,t)=>new it({innerType:e,typeName:A.ZodReadonly,...S(t)}),D.lazycreate;var A;(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`})(A||={});var j=xe.create;Ce.create,tt.create,we.create;var at=Te.create;Ee.create,De.create,Oe.create,ke.create,Ae.create;var ot=je.create;Me.create,Ne.create,Pe.create;var st=D.create;D.strictCreate,Ie.create,Re.create,Be.create,Ve.create;var ct=He.create;Ue.create,We.create,Ge.create,Ke.create,qe.create;var lt=Ye.create;Xe.create,Ze.create,O.create,k.create,Qe.create,O.createWithPreprocess,rt.create;var ut=st({mode:lt([`light`,`dark`,`system`]).optional(),accentColor:j().optional(),fontFamily:j().optional(),borderRadius:j().optional()}),dt=st({externalId:j().optional(),authId:j().optional(),name:j().optional(),email:j().optional()}),ft=st({agentId:j().min(1,`agentId is required`),apiBaseUrl:j().url(`apiBaseUrl must be a valid URL`),tenantId:j().optional(),user:dt.optional(),sessionId:j().optional(),mode:lt([`floating`,`inline`]).optional(),title:j().optional(),subtitle:j().optional(),description:j().optional(),avatarUrl:j().optional(),streaming:at().optional(),preview:at().optional(),skipServerConfigFetch:at().optional(),configChannel:lt([`draft`,`published`]).optional(),metadata:ct(ot()).optional(),theme:ut.optional()}),pt=ft.omit({agentId:!0,apiBaseUrl:!0}).partial(),mt={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 ht(e,t){ft.parse(e);let n,r=t?{...t}:void 0;r&&typeof r.theme==`object`&&r.theme!==null?(n=r.theme,delete r.theme):r&&typeof r.theme==`string`&&(n={mode:r.theme},delete r.theme);let i=r?pt.passthrough().safeParse(r).data:void 0,a=i?gt(i,e):e,o={mode:a.theme?.mode??n?.mode??mt.theme.mode,accentColor:a.theme?.accentColor??n?.accentColor??mt.theme.accentColor,fontFamily:a.theme?.fontFamily??n?.fontFamily??mt.theme.fontFamily,borderRadius:a.theme?.borderRadius??n?.borderRadius??mt.theme.borderRadius};return{agentId:a.agentId,apiBaseUrl:a.apiBaseUrl.replace(/\/$/,``),tenantId:a.tenantId,user:{externalId:a.user?.externalId,authId:a.user?.authId,name:a.user?.name,email:a.user?.email},sessionId:a.sessionId,mode:a.mode??mt.mode,title:a.title??mt.title,subtitle:a.subtitle,description:a.description,suggestedQuestions:(()=>{let e=i?.suggestedQuestions;return Array.isArray(e)?e:[]})(),avatarUrl:a.avatarUrl,streaming:a.streaming??mt.streaming,preview:a.preview===!0,skipServerConfigFetch:a.skipServerConfigFetch===!0,configChannel:a.configChannel,metadata:a.metadata??{},theme:o,photoSendingEnabled:i?.photoSendingEnabled===!0,fileUploadEnabled:i?.fileUploadEnabled===!0,voiceNoteEnabled:i?.voiceNoteEnabled===!0,voiceNoteMaxDurationSec:(()=>{let e=i?.voiceNoteMaxDurationSec;return typeof e==`number`&&Number.isFinite(e)?e:120})(),attachmentMaxCount:(()=>{let e=i?.attachmentMaxCount;return typeof e==`number`&&Number.isFinite(e)?e:5})(),attachmentMaxFileSizeMb:(()=>{let e=i?.attachmentMaxFileSizeMb;return typeof e==`number`&&Number.isFinite(e)?e:1})(),turnstileSiteKey:(()=>{let e=i?.turnstileSiteKey;return typeof e==`string`&&e.length>0?e:void 0})()}}function gt(e,t){let n={...e};for(let e of Object.keys(t)){let r=t[e];r!=null&&(typeof r==`object`&&!Array.isArray(r)&&n[e]!==null&&typeof n[e]==`object`?n[e]=gt(n[e],r):n[e]=r)}return n}var _t=function(){return _t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},_t.apply(this,arguments)};function M(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function N(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function vt(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var yt=`4.6.2`;function bt(e,t){return new Promise(function(n){return setTimeout(n,e,t)})}function xt(){return new Promise(function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})}function St(e,t){t===void 0&&(t=1/0);var n=window.requestIdleCallback;return n?new Promise(function(e){return n.call(window,function(){return e()},{timeout:t})}):bt(Math.min(e,t))}function Ct(e){return!!e&&typeof e.then==`function`}function wt(e,t){try{var n=e();Ct(n)?n.then(function(e){return t(!0,e)},function(e){return t(!1,e)}):t(!0,n)}catch(e){t(!1,e)}}function Tt(e,t,n){return n===void 0&&(n=16),M(this,void 0,void 0,function(){var r,i,a,o;return N(this,function(s){switch(s.label){case 0:r=Array(e.length),i=Date.now(),a=0,s.label=1;case 1:return a<e.length?(r[a]=t(e[a],a),o=Date.now(),o>=i+n?(i=o,[4,xt()]):[3,3]):[3,4];case 2:s.sent(),s.label=3;case 3:return++a,[3,1];case 4:return[2,r]}})})}function Et(e){return e.then(void 0,function(){}),e}function Dt(e,t){for(var n=0,r=e.length;n<r;++n)if(e[n]===t)return!0;return!1}function Ot(e,t){return!Dt(e,t)}function kt(e){return parseInt(e)}function P(e){return parseFloat(e)}function F(e,t){return typeof e==`number`&&isNaN(e)?t:e}function I(e){return e.reduce(function(e,t){return e+ +!!t},0)}function At(e,t){if(t===void 0&&(t=1),Math.abs(t)>=1)return Math.round(e/t)*t;var n=1/t;return Math.round(e*n)/n}function jt(e){for(var t=`Unexpected syntax '${e}'`,n=/^\s*([a-z-]*)(.*)$/i.exec(e),r=n[1]||void 0,i={},a=/([.:#][\w-]+|\[.+?\])/gi,o=function(e,t){i[e]=i[e]||[],i[e].push(t)};;){var s=a.exec(n[2]);if(!s)break;var c=s[0];switch(c[0]){case`.`:o(`class`,c.slice(1));break;case`#`:o(`id`,c.slice(1));break;case`[`:var l=/^\[([\w-]+)([~|^$*]?=("(.*?)"|([\w-]+)))?(\s+[is])?\]$/.exec(c);if(l)o(l[1],l[4]??l[5]??``);else throw Error(t);break;default:throw Error(t)}}return[r,i]}function Mt(e){for(var t=new Uint8Array(e.length),n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r>127)return new TextEncoder().encode(e);t[n]=r}return t}function Nt(e,t){var n=e[0]>>>16,r=e[0]&65535,i=e[1]>>>16,a=e[1]&65535,o=t[0]>>>16,s=t[0]&65535,c=t[1]>>>16,l=t[1]&65535,u=0,d=0,f=0,p=0;p+=a+l,f+=p>>>16,p&=65535,f+=i+c,d+=f>>>16,f&=65535,d+=r+s,u+=d>>>16,d&=65535,u+=n+o,u&=65535,e[0]=u<<16|d,e[1]=f<<16|p}function L(e,t){var n=e[0]>>>16,r=e[0]&65535,i=e[1]>>>16,a=e[1]&65535,o=t[0]>>>16,s=t[0]&65535,c=t[1]>>>16,l=t[1]&65535,u=0,d=0,f=0,p=0;p+=a*l,f+=p>>>16,p&=65535,f+=i*l,d+=f>>>16,f&=65535,f+=a*c,d+=f>>>16,f&=65535,d+=r*l,u+=d>>>16,d&=65535,d+=i*c,u+=d>>>16,d&=65535,d+=a*s,u+=d>>>16,d&=65535,u+=n*l+r*c+i*s+a*o,u&=65535,e[0]=u<<16|d,e[1]=f<<16|p}function Pt(e,t){var n=e[0];t%=64,t===32?(e[0]=e[1],e[1]=n):t<32?(e[0]=n<<t|e[1]>>>32-t,e[1]=e[1]<<t|n>>>32-t):(t-=32,e[0]=e[1]<<t|n>>>32-t,e[1]=n<<t|e[1]>>>32-t)}function R(e,t){t%=64,t!==0&&(t<32?(e[0]=e[1]>>>32-t,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 Ft=[4283543511,3981806797],It=[3301882366,444984403];function Lt(e){var t=[0,e[0]>>>1];z(e,t),L(e,Ft),t[1]=e[0]>>>1,z(e,t),L(e,It),t[1]=e[0]>>>1,z(e,t)}var Rt=[2277735313,289559509],zt=[1291169091,658871167],Bt=[0,5],Vt=[0,1390208809],Ht=[0,944331445];function Ut(e,t){var n=Mt(e);t||=0;var r=[0,n.length],i=r[1]%16,a=r[1]-i,o=[0,t],s=[0,t],c=[0,0],l=[0,0],u;for(u=0;u<a;u+=16)c[0]=n[u+4]|n[u+5]<<8|n[u+6]<<16|n[u+7]<<24,c[1]=n[u]|n[u+1]<<8|n[u+2]<<16|n[u+3]<<24,l[0]=n[u+12]|n[u+13]<<8|n[u+14]<<16|n[u+15]<<24,l[1]=n[u+8]|n[u+9]<<8|n[u+10]<<16|n[u+11]<<24,L(c,Rt),Pt(c,31),L(c,zt),z(o,c),Pt(o,27),Nt(o,s),L(o,Bt),Nt(o,Vt),L(l,zt),Pt(l,33),L(l,Rt),z(s,l),Pt(s,31),Nt(s,o),L(s,Bt),Nt(s,Ht);c[0]=0,c[1]=0,l[0]=0,l[1]=0;var d=[0,0];switch(i){case 15:d[1]=n[u+14],R(d,48),z(l,d);case 14:d[1]=n[u+13],R(d,40),z(l,d);case 13:d[1]=n[u+12],R(d,32),z(l,d);case 12:d[1]=n[u+11],R(d,24),z(l,d);case 11:d[1]=n[u+10],R(d,16),z(l,d);case 10:d[1]=n[u+9],R(d,8),z(l,d);case 9:d[1]=n[u+8],z(l,d),L(l,zt),Pt(l,33),L(l,Rt),z(s,l);case 8:d[1]=n[u+7],R(d,56),z(c,d);case 7:d[1]=n[u+6],R(d,48),z(c,d);case 6:d[1]=n[u+5],R(d,40),z(c,d);case 5:d[1]=n[u+4],R(d,32),z(c,d);case 4:d[1]=n[u+3],R(d,24),z(c,d);case 3:d[1]=n[u+2],R(d,16),z(c,d);case 2:d[1]=n[u+1],R(d,8),z(c,d);case 1:d[1]=n[u],z(c,d),L(c,Rt),Pt(c,31),L(c,zt),z(o,c)}return z(o,r),z(s,r),Nt(o,s),Nt(s,o),Lt(o),Lt(s),Nt(o,s),Nt(s,o),(`00000000`+(o[0]>>>0).toString(16)).slice(-8)+(`00000000`+(o[1]>>>0).toString(16)).slice(-8)+(`00000000`+(s[0]>>>0).toString(16)).slice(-8)+(`00000000`+(s[1]>>>0).toString(16)).slice(-8)}function Wt(e){return _t({name:e.name,message:e.message,stack:e.stack?.split(`
|
|
2
|
-
`)},e)}function Gt(e){return/^function\s.*?\{\s*\[native code]\s*}$/.test(String(e))}function Kt(e){return typeof e!=`function`}function qt(e,t){var n=Et(new Promise(function(n){var r=Date.now();wt(e.bind(null,t),function(){var e=[...arguments],t=Date.now()-r;if(!e[0])return n(function(){return{error:e[1],duration:t}});var i=e[1];if(Kt(i))return n(function(){return{value:i,duration:t}});n(function(){return new Promise(function(e){var n=Date.now();wt(i,function(){var r=[...arguments],i=t+Date.now()-n;if(!r[0])return e({error:r[1],duration:i});e({value:r[1],duration:i})})})})})}));return function(){return n.then(function(e){return e()})}}function Jt(e,t,n,r){var i=Object.keys(e).filter(function(e){return Ot(n,e)}),a=Et(Tt(i,function(n){return qt(e[n],t)},r));return function(){return M(this,void 0,void 0,function(){var e,t,n,o,s;return N(this,function(c){switch(c.label){case 0:return[4,a];case 1:return e=c.sent(),[4,Tt(e,function(e){return Et(e())},r)];case 2:return t=c.sent(),[4,Promise.all(t)];case 3:for(n=c.sent(),o={},s=0;s<i.length;++s)o[i[s]]=n[s];return[2,o]}})})}}function Yt(){var e=window,t=navigator;return I([`MSCSSMatrix`in e,`msSetImmediate`in e,`msIndexedDB`in e,`msMaxTouchPoints`in t,`msPointerEnabled`in t])>=4}function Xt(){var e=window,t=navigator;return I([`msWriteProfilerMark`in e,`MSStream`in e,`msLaunchUri`in t,`msSaveBlob`in t])>=3&&!Yt()}function Zt(){var e=window,t=navigator;return I([`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 B(){var e=window,t=navigator;return I([`ApplePayError`in e,`CSSPrimitiveValue`in e,`Counter`in e,t.vendor.indexOf(`Apple`)===0,`RGBColor`in e,`WebKitMediaKeys`in e])>=4}function Qt(){var e=window,t=e.HTMLElement,n=e.Document;return I([`safari`in e,!(`ongestureend`in e),!(`TouchEvent`in e),!(`orientation`in e),t&&!(`autocapitalize`in t.prototype),n&&`pointerLockElement`in n.prototype])>=4}function $t(){var e=window;return Gt(e.print)&&String(e.browser)===`[object WebPageNamespace]`}function en(){var e=window;return I([`buildID`in navigator,`MozAppearance`in(document.documentElement?.style??{}),`onmozfullscreenchange`in e,`mozInnerScreenX`in e,`CSSMozDocumentRule`in e,`CanvasCaptureMediaStream`in e])>=4}function tn(){var e=window;return I([!(`MediaSettingsRange`in e),`RTCEncodedAudioFrame`in e,``+e.Intl==`[object Intl]`,``+e.Reflect==`[object Reflect]`])>=3}function nn(){var e=window,t=e.URLPattern;return I([`union`in Set.prototype,`Iterator`in e,t&&`hasRegExpGroups`in t.prototype,`RGB8`in WebGLRenderingContext.prototype])>=3}function rn(){var e=window;return I([`DOMRectList`in e,`RTCPeerConnectionIceEvent`in e,`SVGGeometryElement`in e,`ontransitioncancel`in e])>=3}function an(){var e=window,t=navigator,n=e.CSS,r=e.HTMLButtonElement;return I([!(`getStorageUpdates`in t),r&&`popover`in r.prototype,`CSSCounterStyleRule`in e,n.supports(`font-size-adjust: ex-height 0.5`),n.supports(`text-transform: full-width`)])>=4}function on(){if(navigator.platform===`iPad`)return!0;var e=screen,t=e.width/e.height;return I([`MediaSource`in window,!!Element.prototype.webkitRequestFullscreen,t>.65&&t<1.53])>=2}function sn(){var e=document;return e.fullscreenElement||e.msFullscreenElement||e.mozFullScreenElement||e.webkitFullscreenElement||null}function cn(){var e=document;return(e.exitFullscreen||e.msExitFullscreen||e.mozCancelFullScreen||e.webkitExitFullscreen).call(e)}function ln(){var e=Zt(),t=en(),n=window,r=navigator,i=`connection`;return e?I([!(`SharedWorker`in n),r[i]&&`ontypechange`in r[i],!(`sinkId`in new Audio)])>=2:t?I([`onorientationchange`in n,`orientation`in n,/android/i.test(r.appVersion)])>=2:!1}function un(){var e=navigator,t=window,n=Audio.prototype,r=t.visualViewport;return I([`srLatency`in n,`srChannelCount`in n,`devicePosture`in e,r&&`segments`in r,`getTextInformation`in Image.prototype])>=3}function dn(){return mn()?-4:fn()}function fn(){var e=window,t=e.OfflineAudioContext||e.webkitOfflineAudioContext;if(!t)return-2;if(pn())return-1;var n=4500,r=new t(1,5e3,44100),i=r.createOscillator();i.type=`triangle`,i.frequency.value=1e4;var a=r.createDynamicsCompressor();a.threshold.value=-50,a.knee.value=40,a.ratio.value=12,a.attack.value=0,a.release.value=.25,i.connect(a),a.connect(r.destination),i.start(0);var o=hn(r),s=o[0],c=o[1],l=Et(s.then(function(e){return gn(e.getChannelData(0).subarray(n))},function(e){if(e.name===`timeout`||e.name===`suspended`)return-3;throw e}));return function(){return c(),l}}function pn(){return B()&&!Qt()&&!rn()}function mn(){return B()&&an()&&$t()||Zt()&&un()&&nn()}function hn(e){var t=3,n=500,r=500,i=5e3,a=function(){};return[new Promise(function(o,s){var c=!1,l=0,u=0;e.oncomplete=function(e){return o(e.renderedBuffer)};var d=function(){setTimeout(function(){return s(_n(`timeout`))},Math.min(r,u+i-Date.now()))},f=function(){try{var r=e.startRendering();switch(Ct(r)&&Et(r),e.state){case`running`:u=Date.now(),c&&d();break;case`suspended`:document.hidden||l++,c&&l>=t?s(_n(`suspended`)):setTimeout(f,n);break}}catch(e){s(e)}};f(),a=function(){c||(c=!0,u>0&&d())}}),a]}function gn(e){for(var t=0,n=0;n<e.length;++n)t+=Math.abs(e[n]);return t}function _n(e){var t=Error(e);return t.name=e,t}function vn(e,t,n){var r;return n===void 0&&(n=50),M(this,void 0,void 0,function(){var i,a;return N(this,function(o){switch(o.label){case 0:i=document,o.label=1;case 1:return i.body?[3,3]:[4,bt(n)];case 2:return o.sent(),[3,1];case 3:a=i.createElement(`iframe`),o.label=4;case 4:return o.trys.push([4,,10,11]),[4,new Promise(function(e,n){var r=!1,o=function(){r=!0,e()};a.onload=o,a.onerror=function(e){r=!0,n(e)};var s=a.style;s.setProperty(`display`,`block`,`important`),s.position=`absolute`,s.top=`0`,s.left=`0`,s.visibility=`hidden`,t&&`srcdoc`in a?a.srcdoc=t:a.src=`about:blank`,i.body.appendChild(a);var c=function(){r||(a.contentWindow?.document?.readyState===`complete`?o():setTimeout(c,10))};c()})];case 5:o.sent(),o.label=6;case 6:return a.contentWindow?.document?.body?[3,8]:[4,bt(n)];case 7:return o.sent(),[3,6];case 8:return[4,e(a,a.contentWindow)];case 9:return[2,o.sent()];case 10:return(r=a.parentNode)==null||r.removeChild(a),[7];case 11:return[2]}})})}function yn(e){for(var t=jt(e),n=t[0],r=t[1],i=document.createElement(n??`div`),a=0,o=Object.keys(r);a<o.length;a++){var s=o[a],c=r[s].join(` `);s===`style`?bn(i.style,c):i.setAttribute(s,c)}return i}function bn(e,t){for(var n=0,r=t.split(`;`);n<r.length;n++){var i=r[n],a=/^\s*([\w-]+)\s*:\s*(.+?)(\s*!([\w-]+))?\s*$/.exec(i);if(a){var o=a[1],s=a[2],c=a[4];e.setProperty(o,s,c||``)}}}function xn(){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(e){if(e instanceof Error&&e.name===`SecurityError`)return!0;throw e}e=t}}var Sn=`mmMwWLliI0O&1`,Cn=`48px`,wn=[`monospace`,`sans-serif`,`serif`],Tn=`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`.split(`.`);function En(){var e=this;return vn(function(t,n){var r=n.document;return M(e,void 0,void 0,function(){var e,t,n,i,a,o,s,c,l,u,d,f;return N(this,function(p){for(e=r.body,e.style.fontSize=Cn,t=r.createElement(`div`),t.style.setProperty(`visibility`,`hidden`,`important`),n={},i={},a=function(e){var n=r.createElement(`span`),i=n.style;return i.position=`absolute`,i.top=`0`,i.left=`0`,i.fontFamily=e,n.textContent=Sn,t.appendChild(n),n},o=function(e,t){return a(`'${e}',${t}`)},s=function(){return wn.map(a)},c=function(){for(var e={},t=function(t){e[t]=wn.map(function(e){return o(t,e)})},n=0,r=Tn;n<r.length;n++){var i=r[n];t(i)}return e},l=function(e){return wn.some(function(t,r){return e[r].offsetWidth!==n[t]||e[r].offsetHeight!==i[t]})},u=s(),d=c(),e.appendChild(t),f=0;f<wn.length;f++)n[wn[f]]=u[f].offsetWidth,i[wn[f]]=u[f].offsetHeight;return[2,Tn.filter(function(e){return l(d[e])})]})})})}function Dn(){var e=navigator.plugins;if(e){for(var t=[],n=0;n<e.length;++n){var r=e[n];if(r){for(var i=[],a=0;a<r.length;++a){var o=r[a];i.push({type:o.type,suffixes:o.suffixes})}t.push({name:r.name,description:r.description,mimeTypes:i})}}return t}}function On(){return kn(Ln())}function kn(e){var t,n=!1,r,i,a=An(),o=a[0],s=a[1];return jn(o,s)?(n=Mn(s),e?r=i=`skipped`:(t=Nn(o,s),r=t[0],i=t[1])):r=i=`unsupported`,{winding:n,geometry:r,text:i}}function An(){var e=document.createElement(`canvas`);return e.width=1,e.height=1,[e,e.getContext(`2d`)]}function jn(e,t){return!!(t&&e.toDataURL)}function Mn(e){return e.rect(0,0,10,10),e.rect(2,2,6,6),!e.isPointInPath(5,5,`evenodd`)}function Nn(e,t){Pn(e,t);var n=In(e);return n===In(e)?(Fn(e,t),[In(e),n]):[`unstable`,`unstable`]}function Pn(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 n=`Cwm fjordbank gly ${String.fromCharCode(55357,56835)}`;t.fillText(n,2,15),t.fillStyle=`rgba(102, 204, 0, 0.2)`,t.font=`18pt Arial`,t.fillText(n,4,45)}function Fn(e,t){e.width=122,e.height=110,t.globalCompositeOperation=`multiply`;for(var n=0,r=[[`#f2f`,40,40],[`#2ff`,80,40],[`#ff2`,60,80]];n<r.length;n++){var i=r[n],a=i[0],o=i[1],s=i[2];t.fillStyle=a,t.beginPath(),t.arc(o,s,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 In(e){return e.toDataURL()}function Ln(){return B()&&an()&&$t()}function Rn(){var e=navigator,t=0,n;e.maxTouchPoints===void 0?e.msMaxTouchPoints!==void 0&&(t=e.msMaxTouchPoints):t=kt(e.maxTouchPoints);try{document.createEvent(`TouchEvent`),n=!0}catch{n=!1}var r=`ontouchstart`in window;return{maxTouchPoints:t,touchEvent:n,touchStart:r}}function zn(){return navigator.oscpu}function Bn(){var e=navigator,t=[],n=e.language||e.userLanguage||e.browserLanguage||e.systemLanguage;if(n!==void 0&&t.push([n]),Array.isArray(e.languages))Zt()&&tn()||t.push(e.languages);else if(typeof e.languages==`string`){var r=e.languages;r&&t.push(r.split(`,`))}return t}function Vn(){return window.screen.colorDepth}function Hn(){return F(P(navigator.deviceMemory),void 0)}function Un(){if(!(B()&&an()&&$t()))return Wn()}function Wn(){var e=screen,t=function(e){return F(kt(e),null)},n=[t(e.width),t(e.height)];return n.sort().reverse(),n}var Gn=2500,Kn=10,qn,Jn;function Yn(){if(Jn===void 0){var e=function(){var t=Qn();$n(t)?Jn=setTimeout(e,Gn):(qn=t,Jn=void 0)};e()}}function Xn(){var e=this;return Yn(),function(){return M(e,void 0,void 0,function(){var e;return N(this,function(t){switch(t.label){case 0:return e=Qn(),$n(e)?qn?[2,vt([],qn,!0)]:sn()?[4,cn()]:[3,2]:[3,2];case 1:t.sent(),e=Qn(),t.label=2;case 2:return $n(e)||(qn=e),[2,e]}})})}}function Zn(){var e=this;if(B()&&an()&&$t())return function(){return Promise.resolve(void 0)};var t=Xn();return function(){return M(e,void 0,void 0,function(){var e,n;return N(this,function(r){switch(r.label){case 0:return[4,t()];case 1:return e=r.sent(),n=function(e){return e===null?null:At(e,Kn)},[2,[n(e[0]),n(e[1]),n(e[2]),n(e[3])]]}})})}}function Qn(){var e=screen;return[F(P(e.availTop),null),F(P(e.width)-P(e.availWidth)-F(P(e.availLeft),0),null),F(P(e.height)-P(e.availHeight)-F(P(e.availTop),0),null),F(P(e.availLeft),null)]}function $n(e){for(var t=0;t<4;++t)if(e[t])return!1;return!0}function er(){return F(kt(navigator.hardwareConcurrency),void 0)}function tr(){var e=window.Intl?.DateTimeFormat;if(e){var t=new e().resolvedOptions().timeZone;if(t)return t}var n=-nr();return`UTC${n>=0?`+`:``}${n}`}function nr(){var e=new Date().getFullYear();return Math.max(P(new Date(e,0,1).getTimezoneOffset()),P(new Date(e,6,1).getTimezoneOffset()))}function rr(){try{return!!window.sessionStorage}catch{return!0}}function ir(){try{return!!window.localStorage}catch{return!0}}function ar(){if(!(Yt()||Xt()))try{return!!window.indexedDB}catch{return!0}}function or(){return!!window.openDatabase}function sr(){return navigator.cpuClass}function cr(){var e=navigator.platform;return e===`MacIntel`&&B()&&!Qt()?on()?`iPad`:`iPhone`:e}function lr(){return navigator.vendor||``}function ur(){for(var e=[],t=0,n=[`chrome`,`safari`,`__crWeb`,`__gCrWeb`,`yandex`,`__yb`,`__ybro`,`__firefox__`,`__edgeTrackingPreventionStatistics`,`webkit`,`oprt`,`samsungAr`,`ucweb`,`UCShellJava`,`puffinDevice`];t<n.length;t++){var r=n[t],i=window[r];i&&typeof i==`object`&&e.push(r)}return e.sort()}function dr(){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 fr(){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 pr(e){var t=(e===void 0?{}:e).debug;return M(this,void 0,void 0,function(){var e,n,r,i,a,o;return N(this,function(s){switch(s.label){case 0:return mr()?(e=fr(),n=Object.keys(e),r=(o=[]).concat.apply(o,n.map(function(t){return e[t]})),[4,hr(r)]):[2,void 0];case 1:return i=s.sent(),t&&_r(e,i),a=n.filter(function(t){var n=e[t];return I(n.map(function(e){return i[e]}))>n.length*.6}),a.sort(),[2,a]}})})}function mr(){return B()||ln()}function hr(e){var t;return M(this,void 0,void 0,function(){var n,r,i,a,o,s,c,o;return N(this,function(l){switch(l.label){case 0:for(n=document,r=n.createElement(`div`),i=Array(e.length),a={},gr(r),o=0;o<e.length;++o)s=yn(e[o]),s.tagName===`DIALOG`&&s.show(),c=n.createElement(`div`),gr(c),c.appendChild(s),r.appendChild(c),i[o]=s;l.label=1;case 1:return n.body?[3,3]:[4,bt(50)];case 2:return l.sent(),[3,1];case 3:n.body.appendChild(r);try{for(o=0;o<e.length;++o)i[o].offsetParent||(a[e[o]]=!0)}finally{(t=r.parentNode)==null||t.removeChild(r)}return[2,a]}})})}function gr(e){e.style.setProperty(`visibility`,`hidden`,`important`),e.style.setProperty(`display`,`block`,`important`)}function _r(e,t){for(var n="DOM blockers debug:\n```",r=0,i=Object.keys(e);r<i.length;r++){var a=i[r];n+=`
|
|
1
|
+
var e;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(e||={});var t;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(t||={});var n=e.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),r=e=>{switch(typeof e){case`undefined`:return n.undefined;case`string`:return n.string;case`number`:return Number.isNaN(e)?n.nan:n.number;case`boolean`:return n.boolean;case`function`:return n.function;case`bigint`:return n.bigint;case`symbol`:return n.symbol;case`object`:return Array.isArray(e)?n.array:e===null?n.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?n.promise:typeof Map<`u`&&e instanceof Map?n.map:typeof Set<`u`&&e instanceof Set?n.set:typeof Date<`u`&&e instanceof Date?n.date:n.object;default:return n.unknown}},i=e.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),a=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(e){if(!(e instanceof t))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,e.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};a.create=e=>new a(e);var o=(t,r)=>{let a;switch(t.code){case i.invalid_type:a=t.received===n.undefined?`Required`:`Expected ${t.expected}, received ${t.received}`;break;case i.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(t.expected,e.jsonStringifyReplacer)}`;break;case i.unrecognized_keys:a=`Unrecognized key(s) in object: ${e.joinValues(t.keys,`, `)}`;break;case i.invalid_union:a=`Invalid input`;break;case i.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${e.joinValues(t.options)}`;break;case i.invalid_enum_value:a=`Invalid enum value. Expected ${e.joinValues(t.options)}, received '${t.received}'`;break;case i.invalid_arguments:a=`Invalid function arguments`;break;case i.invalid_return_type:a=`Invalid function return type`;break;case i.invalid_date:a=`Invalid date`;break;case i.invalid_string:typeof t.validation==`object`?`includes`in t.validation?(a=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position==`number`&&(a=`${a} at one or more positions greater than or equal to ${t.validation.position}`)):`startsWith`in t.validation?a=`Invalid input: must start with "${t.validation.startsWith}"`:`endsWith`in t.validation?a=`Invalid input: must end with "${t.validation.endsWith}"`:e.assertNever(t.validation):a=t.validation===`regex`?`Invalid`:`Invalid ${t.validation}`;break;case i.too_small:a=t.type===`array`?`Array must contain ${t.exact?`exactly`:t.inclusive?`at least`:`more than`} ${t.minimum} element(s)`:t.type===`string`?`String must contain ${t.exact?`exactly`:t.inclusive?`at least`:`over`} ${t.minimum} character(s)`:t.type===`number`||t.type===`bigint`?`Number must be ${t.exact?`exactly equal to `:t.inclusive?`greater than or equal to `:`greater than `}${t.minimum}`:t.type===`date`?`Date must be ${t.exact?`exactly equal to `:t.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(t.minimum))}`:`Invalid input`;break;case i.too_big:a=t.type===`array`?`Array must contain ${t.exact?`exactly`:t.inclusive?`at most`:`less than`} ${t.maximum} element(s)`:t.type===`string`?`String must contain ${t.exact?`exactly`:t.inclusive?`at most`:`under`} ${t.maximum} character(s)`:t.type===`number`?`Number must be ${t.exact?`exactly`:t.inclusive?`less than or equal to`:`less than`} ${t.maximum}`:t.type===`bigint`?`BigInt must be ${t.exact?`exactly`:t.inclusive?`less than or equal to`:`less than`} ${t.maximum}`:t.type===`date`?`Date must be ${t.exact?`exactly`:t.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(t.maximum))}`:`Invalid input`;break;case i.custom:a=`Invalid input`;break;case i.invalid_intersection_types:a=`Intersection results could not be merged`;break;case i.not_multiple_of:a=`Number must be a multiple of ${t.multipleOf}`;break;case i.not_finite:a=`Number must be finite`;break;default:a=r.defaultError,e.assertNever(t)}return{message:a}},s=o;function c(){return s}var l=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function u(e,t){let n=c(),r=l({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===o?void 0:o].filter(e=>!!e)});e.common.issues.push(r)}var d=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return f;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return f;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},f=Object.freeze({status:`aborted`}),p=e=>({status:`dirty`,value:e}),m=e=>({status:`valid`,value:e}),h=e=>e.status===`aborted`,g=e=>e.status===`dirty`,_=e=>e.status===`valid`,v=e=>typeof Promise<`u`&&e instanceof Promise,y;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(y||={});var b=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}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}},x=(e,t)=>{if(_(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new a(e.common.issues);return this._error=t,this._error}}};function S(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var C=class{get description(){return this._def.description}_getType(e){return r(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:r(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new d,ctx:{common:e.parent.common,data:e.data,parsedType:r(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(v(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)};return x(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return _(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>_(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)},i=this._parse({data:e,path:n.path,parent:n});return x(n,await(v(i)?i:Promise.resolve(i)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let a=e(t),o=()=>r.addIssue({code:i.custom,...n(t)});return typeof Promise<`u`&&a instanceof Promise?a.then(e=>e?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new k({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:e=>this[`~validate`](e)}}optional(){return A.create(this,this._def)}nullable(){return Ze.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ne.create(this)}promise(){return Xe.create(this,this._def)}or(e){return Fe.create([this,e],this._def)}and(e){return ze.create(this,e,this._def)}transform(e){return new k({...S(this._def),schema:this,typeName:j.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new Qe({...S(this._def),innerType:this,defaultValue:t,typeName:j.ZodDefault})}brand(){return new tt({typeName:j.ZodBranded,type:this,...S(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new $e({...S(this._def),innerType:this,catchValue:t,typeName:j.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return nt.create(this,e)}readonly(){return rt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},w=/^c[^\s-]{8,}$/i,T=/^[0-9a-z]+$/,E=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ee=/^[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,D=/^[a-z0-9_-]{21}$/i,te=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ne=/^[-+]?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)?)??$/,re=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ie=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,ae,oe=/^(?:(?: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])$/,se=/^(?:(?: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])$/,ce=/^(([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]))$/,le=/^(([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])$/,ue=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,de=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,fe=`((\\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])))`,pe=RegExp(`^${fe}$`);function me(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function he(e){return RegExp(`^${me(e)}$`)}function ge(e){let t=`${fe}T${me(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function _e(e,t){return!((t!==`v4`&&t||!oe.test(e))&&(t!==`v6`&&t||!ce.test(e)))}function ve(e,t){if(!te.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function ye(e,t){return!((t!==`v4`&&t||!se.test(e))&&(t!==`v6`&&t||!le.test(e)))}var be=class t extends C{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==n.string){let e=this._getOrReturnCtx(t);return u(e,{code:i.invalid_type,expected:n.string,received:e.parsedType}),f}let r=new d,a;for(let n of this._def.checks)if(n.kind===`min`)t.data.length<n.value&&(a=this._getOrReturnCtx(t,a),u(a,{code:i.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),u(a,{code:i.too_big,maximum:n.value,type:`string`,inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind===`length`){let e=t.data.length>n.value,o=t.data.length<n.value;(e||o)&&(a=this._getOrReturnCtx(t,a),e?u(a,{code:i.too_big,maximum:n.value,type:`string`,inclusive:!0,exact:!0,message:n.message}):o&&u(a,{code:i.too_small,minimum:n.value,type:`string`,inclusive:!0,exact:!0,message:n.message}),r.dirty())}else if(n.kind===`email`)re.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`email`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`emoji`)ae||=new RegExp(ie,`u`),ae.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`emoji`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`uuid`)ee.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`uuid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`nanoid`)D.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`nanoid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`cuid`)w.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`cuid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`cuid2`)T.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`cuid2`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`ulid`)E.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`ulid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`url`)try{new URL(t.data)}catch{a=this._getOrReturnCtx(t,a),u(a,{validation:`url`,code:i.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),u(a,{validation:`regex`,code:i.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),u(a,{code:i.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),u(a,{code:i.invalid_string,validation:{startsWith:n.value},message:n.message}),r.dirty()):n.kind===`endsWith`?t.data.endsWith(n.value)||(a=this._getOrReturnCtx(t,a),u(a,{code:i.invalid_string,validation:{endsWith:n.value},message:n.message}),r.dirty()):n.kind===`datetime`?ge(n).test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{code:i.invalid_string,validation:`datetime`,message:n.message}),r.dirty()):n.kind===`date`?pe.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{code:i.invalid_string,validation:`date`,message:n.message}),r.dirty()):n.kind===`time`?he(n).test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{code:i.invalid_string,validation:`time`,message:n.message}),r.dirty()):n.kind===`duration`?ne.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`duration`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`ip`?_e(t.data,n.version)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`ip`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`jwt`?ve(t.data,n.alg)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`jwt`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`cidr`?ye(t.data,n.version)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`cidr`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`base64`?ue.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`base64`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`base64url`?de.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`base64url`,code:i.invalid_string,message:n.message}),r.dirty()):e.assertNever(n);return{status:r.value,value:t.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:i.invalid_string,...y.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:`email`,...y.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...y.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...y.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...y.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...y.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...y.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...y.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...y.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...y.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...y.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...y.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...y.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...y.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...y.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...y.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...y.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...y.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...y.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...y.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...y.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...y.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...y.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...y.errToObj(t)})}nonempty(e){return this.min(1,y.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};be.create=e=>new be({checks:[],typeName:j.ZodString,coerce:e?.coerce??!1,...S(e)});function xe(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var Se=class t extends C{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)!==n.number){let e=this._getOrReturnCtx(t);return u(e,{code:i.invalid_type,expected:n.number,received:e.parsedType}),f}let r,a=new d;for(let n of this._def.checks)n.kind===`int`?e.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{code:i.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),u(r,{code:i.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),u(r,{code:i.too_big,maximum:n.value,type:`number`,inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind===`multipleOf`?xe(t.data,n.value)!==0&&(r=this._getOrReturnCtx(t,r),u(r,{code:i.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):n.kind===`finite`?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{code:i.not_finite,message:n.message}),a.dirty()):e.assertNever(n);return{status:a.value,value:t.data}}gte(e,t){return this.setLimit(`min`,e,!0,y.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,y.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,y.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,y.toString(t))}setLimit(e,n,r,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:y.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:`int`,message:y.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:y.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:y.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:y.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:y.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(t=>t.kind===`int`||t.kind===`multipleOf`&&e.isInteger(t.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};Se.create=e=>new Se({checks:[],typeName:j.ZodNumber,coerce:e?.coerce||!1,...S(e)});var Ce=class t extends C{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)!==n.bigint)return this._getInvalidInput(t);let r,a=new d;for(let n of this._def.checks)n.kind===`min`?(n.inclusive?t.data<n.value:t.data<=n.value)&&(r=this._getOrReturnCtx(t,r),u(r,{code:i.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),u(r,{code:i.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),u(r,{code:i.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):e.assertNever(n);return{status:a.value,value:t.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.bigint,received:t.parsedType}),f}gte(e,t){return this.setLimit(`min`,e,!0,y.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,y.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,y.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,y.toString(t))}setLimit(e,n,r,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:y.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:y.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Ce.create=e=>new Ce({checks:[],typeName:j.ZodBigInt,coerce:e?.coerce??!1,...S(e)});var we=class extends C{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==n.boolean){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.boolean,received:t.parsedType}),f}return m(e.data)}};we.create=e=>new we({typeName:j.ZodBoolean,coerce:e?.coerce||!1,...S(e)});var Te=class t extends C{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==n.date){let e=this._getOrReturnCtx(t);return u(e,{code:i.invalid_type,expected:n.date,received:e.parsedType}),f}if(Number.isNaN(t.data.getTime()))return u(this._getOrReturnCtx(t),{code:i.invalid_date}),f;let r=new d,a;for(let n of this._def.checks)n.kind===`min`?t.data.getTime()<n.value&&(a=this._getOrReturnCtx(t,a),u(a,{code:i.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),u(a,{code:i.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:`date`}),r.dirty()):e.assertNever(n);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:y.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:y.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};Te.create=e=>new Te({checks:[],coerce:e?.coerce||!1,typeName:j.ZodDate,...S(e)});var Ee=class extends C{_parse(e){if(this._getType(e)!==n.symbol){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.symbol,received:t.parsedType}),f}return m(e.data)}};Ee.create=e=>new Ee({typeName:j.ZodSymbol,...S(e)});var De=class extends C{_parse(e){if(this._getType(e)!==n.undefined){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.undefined,received:t.parsedType}),f}return m(e.data)}};De.create=e=>new De({typeName:j.ZodUndefined,...S(e)});var Oe=class extends C{_parse(e){if(this._getType(e)!==n.null){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.null,received:t.parsedType}),f}return m(e.data)}};Oe.create=e=>new Oe({typeName:j.ZodNull,...S(e)});var ke=class extends C{constructor(){super(...arguments),this._any=!0}_parse(e){return m(e.data)}};ke.create=e=>new ke({typeName:j.ZodAny,...S(e)});var Ae=class extends C{constructor(){super(...arguments),this._unknown=!0}_parse(e){return m(e.data)}};Ae.create=e=>new Ae({typeName:j.ZodUnknown,...S(e)});var je=class extends C{_parse(e){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.never,received:t.parsedType}),f}};je.create=e=>new je({typeName:j.ZodNever,...S(e)});var Me=class extends C{_parse(e){if(this._getType(e)!==n.undefined){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.void,received:t.parsedType}),f}return m(e.data)}};Me.create=e=>new Me({typeName:j.ZodVoid,...S(e)});var Ne=class e extends C{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),a=this._def;if(t.parsedType!==n.array)return u(t,{code:i.invalid_type,expected:n.array,received:t.parsedType}),f;if(a.exactLength!==null){let e=t.data.length>a.exactLength.value,n=t.data.length<a.exactLength.value;(e||n)&&(u(t,{code:e?i.too_big:i.too_small,minimum:n?a.exactLength.value:void 0,maximum:e?a.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(a.minLength!==null&&t.data.length<a.minLength.value&&(u(t,{code:i.too_small,minimum:a.minLength.value,type:`array`,inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),a.maxLength!==null&&t.data.length>a.maxLength.value&&(u(t,{code:i.too_big,maximum:a.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>a.type._parseAsync(new b(t,e,t.path,n)))).then(e=>d.mergeArray(r,e));let o=[...t.data].map((e,n)=>a.type._parseSync(new b(t,e,t.path,n)));return d.mergeArray(r,o)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:y.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:y.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:y.toString(n)}})}nonempty(e){return this.min(1,e)}};Ne.create=(e,t)=>new Ne({type:e,minLength:null,maxLength:null,exactLength:null,typeName:j.ZodArray,...S(t)});function Pe(e){if(e instanceof O){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=A.create(Pe(r))}return new O({...e._def,shape:()=>t})}return e instanceof Ne?new Ne({...e._def,type:Pe(e.element)}):e instanceof A?A.create(Pe(e.unwrap())):e instanceof Ze?Ze.create(Pe(e.unwrap())):e instanceof Be?Be.create(e.items.map(e=>Pe(e))):e}var O=class t extends C{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),n=e.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(e){if(this._getType(e)!==n.object){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.object,received:t.parsedType}),f}let{status:t,ctx:r}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof je&&this._def.unknownKeys===`strip`))for(let e in r.data)o.includes(e)||s.push(e);let c=[];for(let e of o){let t=a[e],n=r.data[e];c.push({key:{status:`valid`,value:e},value:t._parse(new b(r,n,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof je){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of s)c.push({key:{status:`valid`,value:e},value:{status:`valid`,value:r.data[e]}});else if(e===`strict`)s.length>0&&(u(r,{code:i.unrecognized_keys,keys:s}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of s){let n=r.data[t];c.push({key:{status:`valid`,value:t},value:e._parse(new b(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of c){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>d.mergeObjectSync(t,e)):d.mergeObjectSync(t,c)}get shape(){return this._def.shape()}strict(e){return y.errToObj,new t({...this._def,unknownKeys:`strict`,...e===void 0?{}:{errorMap:(t,n)=>{let r=this._def.errorMap?.(t,n).message??n.defaultError;return t.code===`unrecognized_keys`?{message:y.errToObj(e).message??r}:{message:r}}}})}strip(){return new t({...this._def,unknownKeys:`strip`})}passthrough(){return new t({...this._def,unknownKeys:`passthrough`})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:j.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new t({...this._def,catchall:e})}pick(n){let r={};for(let t of e.objectKeys(n))n[t]&&this.shape[t]&&(r[t]=this.shape[t]);return new t({...this._def,shape:()=>r})}omit(n){let r={};for(let t of e.objectKeys(this.shape))n[t]||(r[t]=this.shape[t]);return new t({...this._def,shape:()=>r})}deepPartial(){return Pe(this)}partial(n){let r={};for(let t of e.objectKeys(this.shape)){let e=this.shape[t];r[t]=n&&!n[t]?e:e.optional()}return new t({...this._def,shape:()=>r})}required(n){let r={};for(let t of e.objectKeys(this.shape))if(n&&!n[t])r[t]=this.shape[t];else{let e=this.shape[t];for(;e instanceof A;)e=e._def.innerType;r[t]=e}return new t({...this._def,shape:()=>r})}keyof(){return qe(e.objectKeys(this.shape))}};O.create=(e,t)=>new O({shape:()=>e,unknownKeys:`strip`,catchall:je.create(),typeName:j.ZodObject,...S(t)}),O.strictCreate=(e,t)=>new O({shape:()=>e,unknownKeys:`strict`,catchall:je.create(),typeName:j.ZodObject,...S(t)}),O.lazycreate=(e,t)=>new O({shape:e,unknownKeys:`strip`,catchall:je.create(),typeName:j.ZodObject,...S(t)});var Fe=class extends C{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new a(e.ctx.common.issues));return u(t,{code:i.invalid_union,unionErrors:n}),f}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let o=r.map(e=>new a(e));return u(t,{code:i.invalid_union,unionErrors:o}),f}}get options(){return this._def.options}};Fe.create=(e,t)=>new Fe({options:e,typeName:j.ZodUnion,...S(t)});var Ie=t=>t instanceof Ge?Ie(t.schema):t instanceof k?Ie(t.innerType()):t instanceof Ke?[t.value]:t instanceof Je?t.options:t instanceof Ye?e.objectValues(t.enum):t instanceof Qe?Ie(t._def.innerType):t instanceof De?[void 0]:t instanceof Oe?[null]:t instanceof A?[void 0,...Ie(t.unwrap())]:t instanceof Ze?[null,...Ie(t.unwrap())]:t instanceof tt||t instanceof rt?Ie(t.unwrap()):t instanceof $e?Ie(t._def.innerType):[],Le=class e extends C{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==n.object)return u(t,{code:i.invalid_type,expected:n.object,received:t.parsedType}),f;let r=this.discriminator,a=t.data[r],o=this.optionsMap.get(a);return o?t.common.async?o._parseAsync({data:t.data,path:t.path,parent:t}):o._parseSync({data:t.data,path:t.path,parent:t}):(u(t,{code:i.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),f)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=/* @__PURE__ */ new Map;for(let e of n){let n=Ie(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:j.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...S(r)})}};function Re(t,i){let a=r(t),o=r(i);if(t===i)return{valid:!0,data:t};if(a===n.object&&o===n.object){let n=e.objectKeys(i),r=e.objectKeys(t).filter(e=>n.indexOf(e)!==-1),a={...t,...i};for(let e of r){let n=Re(t[e],i[e]);if(!n.valid)return{valid:!1};a[e]=n.data}return{valid:!0,data:a}}if(a===n.array&&o===n.array){if(t.length!==i.length)return{valid:!1};let e=[];for(let n=0;n<t.length;n++){let r=t[n],a=i[n],o=Re(r,a);if(!o.valid)return{valid:!1};e.push(o.data)}return{valid:!0,data:e}}return a===n.date&&o===n.date&&+t==+i?{valid:!0,data:t}:{valid:!1}}var ze=class extends C{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(h(e)||h(r))return f;let a=Re(e.value,r.value);return a.valid?((g(e)||g(r))&&t.dirty(),{status:t.value,value:a.data}):(u(n,{code:i.invalid_intersection_types}),f)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};ze.create=(e,t,n)=>new ze({left:e,right:t,typeName:j.ZodIntersection,...S(n)});var Be=class e extends C{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.array)return u(r,{code:i.invalid_type,expected:n.array,received:r.parsedType}),f;if(r.data.length<this._def.items.length)return u(r,{code:i.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),f;!this._def.rest&&r.data.length>this._def.items.length&&(u(r,{code:i.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let a=[...r.data].map((e,t)=>{let n=this._def.items[t]||this._def.rest;return n?n._parse(new b(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(a).then(e=>d.mergeArray(t,e)):d.mergeArray(t,a)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Be.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Be({items:e,typeName:j.ZodTuple,rest:null,...S(t)})};var Ve=class e extends C{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.object)return u(r,{code:i.invalid_type,expected:n.object,received:r.parsedType}),f;let a=[],o=this._def.keyType,s=this._def.valueType;for(let e in r.data)a.push({key:o._parse(new b(r,e,r.path,e)),value:s._parse(new b(r,r.data[e],r.path,e)),alwaysSet:e in r.data});return r.common.async?d.mergeObjectAsync(t,a):d.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof C?new e({keyType:t,valueType:n,typeName:j.ZodRecord,...S(r)}):new e({keyType:be.create(),valueType:t,typeName:j.ZodRecord,...S(n)})}},He=class extends C{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.map)return u(r,{code:i.invalid_type,expected:n.map,received:r.parsedType}),f;let a=this._def.keyType,o=this._def.valueType,s=[...r.data.entries()].map(([e,t],n)=>({key:a._parse(new b(r,e,r.path,[n,`key`])),value:o._parse(new b(r,t,r.path,[n,`value`]))}));if(r.common.async){let e=/* @__PURE__ */ new Map;return Promise.resolve().then(async()=>{for(let n of s){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return f;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}{let e=/* @__PURE__ */ new Map;for(let n of s){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return f;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};He.create=(e,t,n)=>new He({valueType:t,keyType:e,typeName:j.ZodMap,...S(n)});var Ue=class e extends C{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.set)return u(r,{code:i.invalid_type,expected:n.set,received:r.parsedType}),f;let a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(u(r,{code:i.too_small,minimum:a.minSize.value,type:`set`,inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),a.maxSize!==null&&r.data.size>a.maxSize.value&&(u(r,{code:i.too_big,maximum:a.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());let o=this._def.valueType;function s(e){let n=/* @__PURE__ */ new Set;for(let r of e){if(r.status===`aborted`)return f;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let c=[...r.data.values()].map((e,t)=>o._parse(new b(r,e,r.path,t)));return r.common.async?Promise.all(c).then(e=>s(e)):s(c)}min(t,n){return new e({...this._def,minSize:{value:t,message:y.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:y.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Ue.create=(e,t)=>new Ue({valueType:e,minSize:null,maxSize:null,typeName:j.ZodSet,...S(t)});var We=class e extends C{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==n.function)return u(t,{code:i.invalid_type,expected:n.function,received:t.parsedType}),f;function r(e,n){return l({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,c(),o].filter(e=>!!e),issueData:{code:i.invalid_arguments,argumentsError:n}})}function s(e,n){return l({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,c(),o].filter(e=>!!e),issueData:{code:i.invalid_return_type,returnTypeError:n}})}let d={errorMap:t.common.contextualErrorMap},p=t.data;if(this._def.returns instanceof Xe){let e=this;return m(async function(...t){let n=new a([]),i=await e._def.args.parseAsync(t,d).catch(e=>{throw n.addIssue(r(t,e)),n}),o=await Reflect.apply(p,this,i);return await e._def.returns._def.type.parseAsync(o,d).catch(e=>{throw n.addIssue(s(o,e)),n})})}{let e=this;return m(function(...t){let n=e._def.args.safeParse(t,d);if(!n.success)throw new a([r(t,n.error)]);let i=Reflect.apply(p,this,n.data),o=e._def.returns.safeParse(i,d);if(!o.success)throw new a([s(i,o.error)]);return o.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Be.create(t).rest(Ae.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Be.create([]).rest(Ae.create()),returns:n||Ae.create(),typeName:j.ZodFunction,...S(r)})}},Ge=class extends C{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Ge.create=(e,t)=>new Ge({getter:e,typeName:j.ZodLazy,...S(t)});var Ke=class extends C{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return u(t,{received:t.data,code:i.invalid_literal,expected:this._def.value}),f}return{status:`valid`,value:e.data}}get value(){return this._def.value}};Ke.create=(e,t)=>new Ke({value:e,typeName:j.ZodLiteral,...S(t)});function qe(e,t){return new Je({values:e,typeName:j.ZodEnum,...S(t)})}var Je=class t extends C{_parse(t){if(typeof t.data!=`string`){let n=this._getOrReturnCtx(t),r=this._def.values;return u(n,{expected:e.joinValues(r),received:n.parsedType,code:i.invalid_type}),f}if(this._cache||=new Set(this._def.values),!this._cache.has(t.data)){let e=this._getOrReturnCtx(t),n=this._def.values;return u(e,{received:e.data,code:i.invalid_enum_value,options:n}),f}return m(t.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(t=>!e.includes(t)),{...this._def,...n})}};Je.create=qe;var Ye=class extends C{_parse(t){let r=e.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==n.string&&a.parsedType!==n.number){let t=e.objectValues(r);return u(a,{expected:e.joinValues(t),received:a.parsedType,code:i.invalid_type}),f}if(this._cache||=new Set(e.getValidEnumValues(this._def.values)),!this._cache.has(t.data)){let t=e.objectValues(r);return u(a,{received:a.data,code:i.invalid_enum_value,options:t}),f}return m(t.data)}get enum(){return this._def.values}};Ye.create=(e,t)=>new Ye({values:e,typeName:j.ZodNativeEnum,...S(t)});var Xe=class extends C{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==n.promise&&t.common.async===!1?(u(t,{code:i.invalid_type,expected:n.promise,received:t.parsedType}),f):m((t.parsedType===n.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Xe.create=(e,t)=>new Xe({type:e,typeName:j.ZodPromise,...S(t)});var k=class extends C{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===j.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,a={addIssue:e=>{u(r,e),e.fatal?n.abort():n.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),i.type===`preprocess`){let e=i.transform(r.data,a);if(r.common.async)return Promise.resolve(e).then(async e=>{if(n.value===`aborted`)return f;let t=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return t.status===`aborted`?f:t.status===`dirty`||n.value===`dirty`?p(t.value):t});{if(n.value===`aborted`)return f;let t=this._def.schema._parseSync({data:e,path:r.path,parent:r});return t.status===`aborted`?f:t.status===`dirty`||n.value===`dirty`?p(t.value):t}}if(i.type===`refinement`){let e=e=>{let t=i.refinement(e,a);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(r.common.async===!1){let t=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return t.status===`aborted`?f:(t.status===`dirty`&&n.dirty(),e(t.value),{status:n.value,value:t.value})}return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(t=>t.status===`aborted`?f:(t.status===`dirty`&&n.dirty(),e(t.value).then(()=>({status:n.value,value:t.value}))))}if(i.type===`transform`){if(r.common.async===!1){let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!_(e))return f;let t=i.transform(e.value,a);if(t instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:n.value,value:t}}return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>_(e)?Promise.resolve(i.transform(e.value,a)).then(e=>({status:n.value,value:e})):f)}e.assertNever(i)}};k.create=(e,t,n)=>new k({schema:e,typeName:j.ZodEffects,effect:t,...S(n)}),k.createWithPreprocess=(e,t,n)=>new k({schema:t,effect:{type:`preprocess`,transform:e},typeName:j.ZodEffects,...S(n)});var A=class extends C{_parse(e){return this._getType(e)===n.undefined?m(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};A.create=(e,t)=>new A({innerType:e,typeName:j.ZodOptional,...S(t)});var Ze=class extends C{_parse(e){return this._getType(e)===n.null?m(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ze.create=(e,t)=>new Ze({innerType:e,typeName:j.ZodNullable,...S(t)});var Qe=class extends C{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===n.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Qe.create=(e,t)=>new Qe({innerType:e,typeName:j.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...S(t)});var $e=class extends C{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return v(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new a(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new a(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};$e.create=(e,t)=>new $e({innerType:e,typeName:j.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...S(t)});var et=class extends C{_parse(e){if(this._getType(e)!==n.nan){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.nan,received:t.parsedType}),f}return{status:`valid`,value:e.data}}};et.create=e=>new et({typeName:j.ZodNaN,...S(e)});var tt=class extends C{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},nt=class e extends C{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?f:e.status===`dirty`?(t.dirty(),p(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?f:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:j.ZodPipeline})}},rt=class extends C{_parse(e){let t=this._def.innerType._parse(e),n=e=>(_(e)&&(e.value=Object.freeze(e.value)),e);return v(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};rt.create=(e,t)=>new rt({innerType:e,typeName:j.ZodReadonly,...S(t)}),O.lazycreate;var 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||={});var M=be.create;Se.create,et.create,Ce.create;var it=we.create;Te.create,Ee.create,De.create,Oe.create,ke.create;var at=Ae.create;je.create,Me.create,Ne.create;var ot=O.create;O.strictCreate,Fe.create,Le.create,ze.create,Be.create;var st=Ve.create;He.create,Ue.create,We.create,Ge.create,Ke.create;var ct=Je.create;Ye.create,Xe.create,k.create,A.create,Ze.create,k.createWithPreprocess,nt.create;var lt=ot({mode:ct([`light`,`dark`,`system`]).optional(),accentColor:M().optional(),fontFamily:M().optional(),borderRadius:M().optional()}),ut=ot({externalId:M().optional(),authId:M().optional(),name:M().optional(),email:M().optional()}),dt=ot({agentId:M().min(1,`agentId is required`),apiBaseUrl:M().url(`apiBaseUrl must be a valid URL`),tenantId:M().optional(),user:ut.optional(),sessionId:M().optional(),mode:ct([`floating`,`inline`]).optional(),title:M().optional(),subtitle:M().optional(),description:M().optional(),avatarUrl:M().optional(),streaming:it().optional(),preview:it().optional(),skipServerConfigFetch:it().optional(),configChannel:ct([`draft`,`published`]).optional(),metadata:st(at()).optional(),theme:lt.optional()}),ft=dt.omit({agentId:!0,apiBaseUrl:!0}).partial(),pt={mode:`floating`,streaming:!0,title:`AI Assistant`,theme:{mode:`light`,accentColor:`#4f46e5`,fontFamily:`system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif`,borderRadius:`12px`}};function mt(e,t){dt.parse(e);let n,r=t?{...t}:void 0;r&&typeof r.theme==`object`&&r.theme!==null?(n=r.theme,delete r.theme):r&&typeof r.theme==`string`&&(n={mode:r.theme},delete r.theme);let i=r?ft.passthrough().safeParse(r).data:void 0,a=i?ht(i,e):e,o={mode:a.theme?.mode??n?.mode??pt.theme.mode,accentColor:a.theme?.accentColor||n?.accentColor||pt.theme.accentColor,fontFamily:a.theme?.fontFamily??n?.fontFamily??pt.theme.fontFamily,borderRadius:a.theme?.borderRadius??n?.borderRadius??pt.theme.borderRadius};return{agentId:a.agentId,apiBaseUrl:a.apiBaseUrl.replace(/\/$/,``),tenantId:a.tenantId,user:{externalId:a.user?.externalId,authId:a.user?.authId,name:a.user?.name,email:a.user?.email},sessionId:a.sessionId,mode:a.mode??pt.mode,title:a.title??pt.title,subtitle:a.subtitle,description:a.description,suggestedQuestions:(()=>{let e=i?.suggestedQuestions;return Array.isArray(e)?e:[]})(),avatarUrl:a.avatarUrl,streaming:a.streaming??pt.streaming,preview:a.preview===!0,skipServerConfigFetch:a.skipServerConfigFetch===!0,configChannel:a.configChannel,metadata:a.metadata??{},theme:o,photoSendingEnabled:i?.photoSendingEnabled===!0,fileUploadEnabled:i?.fileUploadEnabled===!0,voiceNoteEnabled:i?.voiceNoteEnabled===!0,voiceNoteMaxDurationSec:(()=>{let e=i?.voiceNoteMaxDurationSec;return typeof e==`number`&&Number.isFinite(e)?e:120})(),attachmentMaxCount:(()=>{let e=i?.attachmentMaxCount;return typeof e==`number`&&Number.isFinite(e)?e:5})(),attachmentMaxFileSizeMb:(()=>{let e=i?.attachmentMaxFileSizeMb;return typeof e==`number`&&Number.isFinite(e)?e:1})(),turnstileSiteKey:(()=>{let e=i?.turnstileSiteKey;return typeof e==`string`&&e.length>0?e:void 0})()}}function ht(e,t){let n={...e};for(let e of Object.keys(t)){let r=t[e];r!=null&&(n[e]=typeof r==`object`&&!Array.isArray(r)&&n[e]!==null&&typeof n[e]==`object`?ht(n[e],r):r)}return n}var gt=function(){return gt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},gt.apply(this,arguments)};function N(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function P(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(a=n.trys,!(a=a.length>0&&a[a.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function _t(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var vt=`4.6.2`;function yt(e,t){return new Promise(function(n){return setTimeout(n,e,t)})}function bt(){return new Promise(function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})}function xt(e,t){t===void 0&&(t=1/0);var n=window.requestIdleCallback;return n?new Promise(function(e){return n.call(window,function(){return e()},{timeout:t})}):yt(Math.min(e,t))}function St(e){return!!e&&typeof e.then==`function`}function Ct(e,t){try{var n=e();St(n)?n.then(function(e){return t(!0,e)},function(e){return t(!1,e)}):t(!0,n)}catch(e){t(!1,e)}}function wt(e,t,n){return n===void 0&&(n=16),N(this,void 0,void 0,function(){var r,i,a,o;return P(this,function(s){switch(s.label){case 0:r=Array(e.length),i=Date.now(),a=0,s.label=1;case 1:return a<e.length?(r[a]=t(e[a],a),o=Date.now(),o>=i+n?(i=o,[4,bt()]):[3,3]):[3,4];case 2:s.sent(),s.label=3;case 3:return++a,[3,1];case 4:return[2,r]}})})}function Tt(e){return e.then(void 0,function(){}),e}function Et(e,t){for(var n=0,r=e.length;n<r;++n)if(e[n]===t)return!0;return!1}function Dt(e,t){return!Et(e,t)}function Ot(e){return parseInt(e)}function F(e){return parseFloat(e)}function I(e,t){return typeof e==`number`&&isNaN(e)?t:e}function L(e){return e.reduce(function(e,t){return e+ +!!t},0)}function kt(e,t){if(t===void 0&&(t=1),Math.abs(t)>=1)return Math.round(e/t)*t;var n=1/t;return Math.round(e*n)/n}function At(e){for(var t=`Unexpected syntax '${e}'`,n=/^\s*([a-z-]*)(.*)$/i.exec(e),r=n[1]||void 0,i={},a=/([.:#][\w-]+|\[.+?\])/gi,o=function(e,t){i[e]=i[e]||[],i[e].push(t)};;){var s=a.exec(n[2]);if(!s)break;var c=s[0];switch(c[0]){case`.`:o(`class`,c.slice(1));break;case`#`:o(`id`,c.slice(1));break;case`[`:var l=/^\[([\w-]+)([~|^$*]?=("(.*?)"|([\w-]+)))?(\s+[is])?\]$/.exec(c);if(l)o(l[1],l[4]??l[5]??``);else throw Error(t);break;default:throw Error(t)}}return[r,i]}function jt(e){for(var t=new Uint8Array(e.length),n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r>127)return new TextEncoder().encode(e);t[n]=r}return t}function Mt(e,t){var n=e[0]>>>16,r=e[0]&65535,i=e[1]>>>16,a=e[1]&65535,o=t[0]>>>16,s=t[0]&65535,c=t[1]>>>16,l=t[1]&65535,u=0,d=0,f=0,p=0;p+=a+l,f+=p>>>16,p&=65535,f+=i+c,d+=f>>>16,f&=65535,d+=r+s,u+=d>>>16,d&=65535,u+=n+o,u&=65535,e[0]=u<<16|d,e[1]=f<<16|p}function R(e,t){var n=e[0]>>>16,r=e[0]&65535,i=e[1]>>>16,a=e[1]&65535,o=t[0]>>>16,s=t[0]&65535,c=t[1]>>>16,l=t[1]&65535,u=0,d=0,f=0,p=0;p+=a*l,f+=p>>>16,p&=65535,f+=i*l,d+=f>>>16,f&=65535,f+=a*c,d+=f>>>16,f&=65535,d+=r*l,u+=d>>>16,d&=65535,d+=i*c,u+=d>>>16,d&=65535,d+=a*s,u+=d>>>16,d&=65535,u+=n*l+r*c+i*s+a*o,u&=65535,e[0]=u<<16|d,e[1]=f<<16|p}function Nt(e,t){var n=e[0];t%=64,t===32?(e[0]=e[1],e[1]=n):t<32?(e[0]=n<<t|e[1]>>>32-t,e[1]=e[1]<<t|n>>>32-t):(t-=32,e[0]=e[1]<<t|n>>>32-t,e[1]=n<<t|e[1]>>>32-t)}function z(e,t){t%=64,t!==0&&(t<32?(e[0]=e[1]>>>32-t,e[1]<<=t):(e[0]=e[1]<<t-32,e[1]=0))}function B(e,t){e[0]^=t[0],e[1]^=t[1]}var Pt=[4283543511,3981806797],Ft=[3301882366,444984403];function It(e){var t=[0,e[0]>>>1];B(e,t),R(e,Pt),t[1]=e[0]>>>1,B(e,t),R(e,Ft),t[1]=e[0]>>>1,B(e,t)}var Lt=[2277735313,289559509],Rt=[1291169091,658871167],zt=[0,5],Bt=[0,1390208809],Vt=[0,944331445];function Ht(e,t){var n=jt(e);t||=0;for(var r=[0,n.length],i=r[1]%16,a=r[1]-i,o=[0,t],s=[0,t],c=[0,0],l=[0,0],u=0;u<a;u+=16)c[0]=n[u+4]|n[u+5]<<8|n[u+6]<<16|n[u+7]<<24,c[1]=n[u]|n[u+1]<<8|n[u+2]<<16|n[u+3]<<24,l[0]=n[u+12]|n[u+13]<<8|n[u+14]<<16|n[u+15]<<24,l[1]=n[u+8]|n[u+9]<<8|n[u+10]<<16|n[u+11]<<24,R(c,Lt),Nt(c,31),R(c,Rt),B(o,c),Nt(o,27),Mt(o,s),R(o,zt),Mt(o,Bt),R(l,Rt),Nt(l,33),R(l,Lt),B(s,l),Nt(s,31),Mt(s,o),R(s,zt),Mt(s,Vt);c[0]=0,c[1]=0,l[0]=0,l[1]=0;var d=[0,0];switch(i){case 15:d[1]=n[u+14],z(d,48),B(l,d);case 14:d[1]=n[u+13],z(d,40),B(l,d);case 13:d[1]=n[u+12],z(d,32),B(l,d);case 12:d[1]=n[u+11],z(d,24),B(l,d);case 11:d[1]=n[u+10],z(d,16),B(l,d);case 10:d[1]=n[u+9],z(d,8),B(l,d);case 9:d[1]=n[u+8],B(l,d),R(l,Rt),Nt(l,33),R(l,Lt),B(s,l);case 8:d[1]=n[u+7],z(d,56),B(c,d);case 7:d[1]=n[u+6],z(d,48),B(c,d);case 6:d[1]=n[u+5],z(d,40),B(c,d);case 5:d[1]=n[u+4],z(d,32),B(c,d);case 4:d[1]=n[u+3],z(d,24),B(c,d);case 3:d[1]=n[u+2],z(d,16),B(c,d);case 2:d[1]=n[u+1],z(d,8),B(c,d);case 1:d[1]=n[u],B(c,d),R(c,Lt),Nt(c,31),R(c,Rt),B(o,c)}return B(o,r),B(s,r),Mt(o,s),Mt(s,o),It(o),It(s),Mt(o,s),Mt(s,o),(`00000000`+(o[0]>>>0).toString(16)).slice(-8)+(`00000000`+(o[1]>>>0).toString(16)).slice(-8)+(`00000000`+(s[0]>>>0).toString(16)).slice(-8)+(`00000000`+(s[1]>>>0).toString(16)).slice(-8)}function Ut(e){return gt({name:e.name,message:e.message,stack:e.stack?.split(`
|
|
2
|
+
`)},e)}function Wt(e){return/^function\s.*?\{\s*\[native code]\s*}$/.test(String(e))}function Gt(e){return typeof e!=`function`}function Kt(e,t){var n=Tt(new Promise(function(n){var r=Date.now();Ct(e.bind(null,t),function(){var e=[...arguments],t=Date.now()-r;if(!e[0])return n(function(){return{error:e[1],duration:t}});var i=e[1];if(Gt(i))return n(function(){return{value:i,duration:t}});n(function(){return new Promise(function(e){var n=Date.now();Ct(i,function(){var r=[...arguments],i=t+Date.now()-n;if(!r[0])return e({error:r[1],duration:i});e({value:r[1],duration:i})})})})})}));return function(){return n.then(function(e){return e()})}}function qt(e,t,n,r){var i=Object.keys(e).filter(function(e){return Dt(n,e)}),a=Tt(wt(i,function(n){return Kt(e[n],t)},r));return function(){return N(this,void 0,void 0,function(){var e,t,n,o,s;return P(this,function(c){switch(c.label){case 0:return[4,a];case 1:return e=c.sent(),[4,wt(e,function(e){return Tt(e())},r)];case 2:return t=c.sent(),[4,Promise.all(t)];case 3:for(n=c.sent(),o={},s=0;s<i.length;++s)o[i[s]]=n[s];return[2,o]}})})}}function Jt(){var e=window,t=navigator;return L([`MSCSSMatrix`in e,`msSetImmediate`in e,`msIndexedDB`in e,`msMaxTouchPoints`in t,`msPointerEnabled`in t])>=4}function Yt(){var e=window,t=navigator;return L([`msWriteProfilerMark`in e,`MSStream`in e,`msLaunchUri`in t,`msSaveBlob`in t])>=3&&!Jt()}function Xt(){var e=window,t=navigator;return L([`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 V(){var e=window,t=navigator;return L([`ApplePayError`in e,`CSSPrimitiveValue`in e,`Counter`in e,t.vendor.indexOf(`Apple`)===0,`RGBColor`in e,`WebKitMediaKeys`in e])>=4}function Zt(){var e=window,t=e.HTMLElement,n=e.Document;return L([`safari`in e,!(`ongestureend`in e),!(`TouchEvent`in e),!(`orientation`in e),t&&!(`autocapitalize`in t.prototype),n&&`pointerLockElement`in n.prototype])>=4}function Qt(){var e=window;return Wt(e.print)&&String(e.browser)===`[object WebPageNamespace]`}function $t(){var e=window;return L([`buildID`in navigator,`MozAppearance`in(document.documentElement?.style??{}),`onmozfullscreenchange`in e,`mozInnerScreenX`in e,`CSSMozDocumentRule`in e,`CanvasCaptureMediaStream`in e])>=4}function en(){var e=window;return L([!(`MediaSettingsRange`in e),`RTCEncodedAudioFrame`in e,``+e.Intl==`[object Intl]`,``+e.Reflect==`[object Reflect]`])>=3}function tn(){var e=window,t=e.URLPattern;return L([`union`in Set.prototype,`Iterator`in e,t&&`hasRegExpGroups`in t.prototype,`RGB8`in WebGLRenderingContext.prototype])>=3}function nn(){var e=window;return L([`DOMRectList`in e,`RTCPeerConnectionIceEvent`in e,`SVGGeometryElement`in e,`ontransitioncancel`in e])>=3}function rn(){var e=window,t=navigator,n=e.CSS,r=e.HTMLButtonElement;return L([!(`getStorageUpdates`in t),r&&`popover`in r.prototype,`CSSCounterStyleRule`in e,n.supports(`font-size-adjust: ex-height 0.5`),n.supports(`text-transform: full-width`)])>=4}function an(){if(navigator.platform===`iPad`)return!0;var e=screen,t=e.width/e.height;return L([`MediaSource`in window,!!Element.prototype.webkitRequestFullscreen,t>.65&&t<1.53])>=2}function on(){var e=document;return e.fullscreenElement||e.msFullscreenElement||e.mozFullScreenElement||e.webkitFullscreenElement||null}function sn(){var e=document;return(e.exitFullscreen||e.msExitFullscreen||e.mozCancelFullScreen||e.webkitExitFullscreen).call(e)}function cn(){var e=Xt(),t=$t(),n=window,r=navigator,i=`connection`;return e?L([!(`SharedWorker`in n),r[i]&&`ontypechange`in r[i],!(`sinkId`in new Audio)])>=2:t?L([`onorientationchange`in n,`orientation`in n,/android/i.test(r.appVersion)])>=2:!1}function ln(){var e=navigator,t=window,n=Audio.prototype,r=t.visualViewport;return L([`srLatency`in n,`srChannelCount`in n,`devicePosture`in e,r&&`segments`in r,`getTextInformation`in Image.prototype])>=3}function un(){return pn()?-4:dn()}function dn(){var e=window,t=e.OfflineAudioContext||e.webkitOfflineAudioContext;if(!t)return-2;if(fn())return-1;var n=4500,r=new t(1,5e3,44100),i=r.createOscillator();i.type=`triangle`,i.frequency.value=1e4;var a=r.createDynamicsCompressor();a.threshold.value=-50,a.knee.value=40,a.ratio.value=12,a.attack.value=0,a.release.value=.25,i.connect(a),a.connect(r.destination),i.start(0);var o=mn(r),s=o[0],c=o[1],l=Tt(s.then(function(e){return hn(e.getChannelData(0).subarray(n))},function(e){if(e.name===`timeout`||e.name===`suspended`)return-3;throw e}));return function(){return c(),l}}function fn(){return V()&&!Zt()&&!nn()}function pn(){return V()&&rn()&&Qt()||Xt()&&ln()&&tn()}function mn(e){var t=function(){};return[new Promise(function(n,r){var i=!1,a=0,o=0;e.oncomplete=function(e){return n(e.renderedBuffer)};var s=function(){setTimeout(function(){return r(gn(`timeout`))},Math.min(500,o+5e3-Date.now()))},c=function(){try{var t=e.startRendering();switch(St(t)&&Tt(t),e.state){case`running`:o=Date.now(),i&&s();break;case`suspended`:document.hidden||a++,i&&a>=3?r(gn(`suspended`)):setTimeout(c,500)}}catch(e){r(e)}};c(),t=function(){i||(i=!0,o>0&&s())}}),t]}function hn(e){for(var t=0,n=0;n<e.length;++n)t+=Math.abs(e[n]);return t}function gn(e){var t=Error(e);return t.name=e,t}function _n(e,t,n){var r;return n===void 0&&(n=50),N(this,void 0,void 0,function(){var i,a;return P(this,function(o){switch(o.label){case 0:i=document,o.label=1;case 1:return i.body?[3,3]:[4,yt(n)];case 2:return o.sent(),[3,1];case 3:a=i.createElement(`iframe`),o.label=4;case 4:return o.trys.push([4,,10,11]),[4,new Promise(function(e,n){var r=!1,o=function(){r=!0,e()};a.onload=o,a.onerror=function(e){r=!0,n(e)};var s=a.style;s.setProperty(`display`,`block`,`important`),s.position=`absolute`,s.top=`0`,s.left=`0`,s.visibility=`hidden`,t&&`srcdoc`in a?a.srcdoc=t:a.src=`about:blank`,i.body.appendChild(a);var c=function(){r||(a.contentWindow?.document?.readyState===`complete`?o():setTimeout(c,10))};c()})];case 5:o.sent(),o.label=6;case 6:return a.contentWindow?.document?.body?[3,8]:[4,yt(n)];case 7:return o.sent(),[3,6];case 8:return[4,e(a,a.contentWindow)];case 9:return[2,o.sent()];case 10:return(r=a.parentNode)==null||r.removeChild(a),[7];case 11:return[2]}})})}function vn(e){for(var t=At(e),n=t[0],r=t[1],i=document.createElement(n??`div`),a=0,o=Object.keys(r);a<o.length;a++){var s=o[a],c=r[s].join(` `);s===`style`?yn(i.style,c):i.setAttribute(s,c)}return i}function yn(e,t){for(var n=0,r=t.split(`;`);n<r.length;n++){var i=r[n],a=/^\s*([\w-]+)\s*:\s*(.+?)(\s*!([\w-]+))?\s*$/.exec(i);if(a){var o=a[1],s=a[2],c=a[4];e.setProperty(o,s,c||``)}}}function bn(){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(e){if(e instanceof Error&&e.name===`SecurityError`)return!0;throw e}e=t}}var xn=`mmMwWLliI0O&1`,Sn=`48px`,Cn=[`monospace`,`sans-serif`,`serif`],wn=/* @__PURE__ */ `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`.split(`.`);function Tn(){var e=this;return _n(function(t,n){var r=n.document;return N(e,void 0,void 0,function(){var e,t,n,i,a,o,s,c,l,u,d,f;return P(this,function(p){for(e=r.body,e.style.fontSize=Sn,t=r.createElement(`div`),t.style.setProperty(`visibility`,`hidden`,`important`),n={},i={},a=function(e){var n=r.createElement(`span`),i=n.style;return i.position=`absolute`,i.top=`0`,i.left=`0`,i.fontFamily=e,n.textContent=xn,t.appendChild(n),n},o=function(e,t){return a(`'${e}',${t}`)},s=function(){return Cn.map(a)},c=function(){for(var e={},t=function(t){e[t]=Cn.map(function(e){return o(t,e)})},n=0,r=wn;n<r.length;n++){var i=r[n];t(i)}return e},l=function(e){return Cn.some(function(t,r){return e[r].offsetWidth!==n[t]||e[r].offsetHeight!==i[t]})},u=s(),d=c(),e.appendChild(t),f=0;f<Cn.length;f++)n[Cn[f]]=u[f].offsetWidth,i[Cn[f]]=u[f].offsetHeight;return[2,wn.filter(function(e){return l(d[e])})]})})})}function En(){var e=navigator.plugins;if(e){for(var t=[],n=0;n<e.length;++n){var r=e[n];if(r){for(var i=[],a=0;a<r.length;++a){var o=r[a];i.push({type:o.type,suffixes:o.suffixes})}t.push({name:r.name,description:r.description,mimeTypes:i})}}return t}}function Dn(){return On(In())}function On(e){var t,n=!1,r,i,a=kn(),o=a[0],s=a[1];return An(o,s)?(n=jn(s),e?r=i=`skipped`:(t=Mn(o,s),r=t[0],i=t[1])):r=i=`unsupported`,{winding:n,geometry:r,text:i}}function kn(){var e=document.createElement(`canvas`);return e.width=1,e.height=1,[e,e.getContext(`2d`)]}function An(e,t){return!!(t&&e.toDataURL)}function jn(e){return e.rect(0,0,10,10),e.rect(2,2,6,6),!e.isPointInPath(5,5,`evenodd`)}function Mn(e,t){Nn(e,t);var n=Fn(e);return n===Fn(e)?(Pn(e,t),[Fn(e),n]):[`unstable`,`unstable`]}function Nn(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 n=`Cwm fjordbank gly 😃`;t.fillText(n,2,15),t.fillStyle=`rgba(102, 204, 0, 0.2)`,t.font=`18pt Arial`,t.fillText(n,4,45)}function Pn(e,t){e.width=122,e.height=110,t.globalCompositeOperation=`multiply`;for(var n=0,r=[[`#f2f`,40,40],[`#2ff`,80,40],[`#ff2`,60,80]];n<r.length;n++){var i=r[n],a=i[0],o=i[1],s=i[2];t.fillStyle=a,t.beginPath(),t.arc(o,s,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 Fn(e){return e.toDataURL()}function In(){return V()&&rn()&&Qt()}function Ln(){var e=navigator,t=0,n;e.maxTouchPoints===void 0?e.msMaxTouchPoints!==void 0&&(t=e.msMaxTouchPoints):t=Ot(e.maxTouchPoints);try{document.createEvent(`TouchEvent`),n=!0}catch{n=!1}var r=`ontouchstart`in window;return{maxTouchPoints:t,touchEvent:n,touchStart:r}}function Rn(){return navigator.oscpu}function zn(){var e=navigator,t=[],n=e.language||e.userLanguage||e.browserLanguage||e.systemLanguage;if(n!==void 0&&t.push([n]),Array.isArray(e.languages))Xt()&&en()||t.push(e.languages);else if(typeof e.languages==`string`){var r=e.languages;r&&t.push(r.split(`,`))}return t}function Bn(){return window.screen.colorDepth}function Vn(){return I(F(navigator.deviceMemory),void 0)}function Hn(){if(!(V()&&rn()&&Qt()))return Un()}function Un(){var e=screen,t=function(e){return I(Ot(e),null)},n=[t(e.width),t(e.height)];return n.sort().reverse(),n}var Wn=2500,Gn=10,Kn,qn;function Jn(){if(qn===void 0){var e=function(){var t=Zn();Qn(t)?qn=setTimeout(e,Wn):(Kn=t,qn=void 0)};e()}}function Yn(){var e=this;return Jn(),function(){return N(e,void 0,void 0,function(){var e;return P(this,function(t){switch(t.label){case 0:return e=Zn(),Qn(e)?Kn?[2,_t([],Kn,!0)]:on()?[4,sn()]:[3,2]:[3,2];case 1:t.sent(),e=Zn(),t.label=2;case 2:return Qn(e)||(Kn=e),[2,e]}})})}}function Xn(){var e=this;if(V()&&rn()&&Qt())return function(){return Promise.resolve(void 0)};var t=Yn();return function(){return N(e,void 0,void 0,function(){var e,n;return P(this,function(r){switch(r.label){case 0:return[4,t()];case 1:return e=r.sent(),n=function(e){return e===null?null:kt(e,Gn)},[2,[n(e[0]),n(e[1]),n(e[2]),n(e[3])]]}})})}}function Zn(){var e=screen;return[I(F(e.availTop),null),I(F(e.width)-F(e.availWidth)-I(F(e.availLeft),0),null),I(F(e.height)-F(e.availHeight)-I(F(e.availTop),0),null),I(F(e.availLeft),null)]}function Qn(e){for(var t=0;t<4;++t)if(e[t])return!1;return!0}function $n(){return I(Ot(navigator.hardwareConcurrency),void 0)}function er(){var e=window.Intl?.DateTimeFormat;if(e){var t=new e().resolvedOptions().timeZone;if(t)return t}var n=-tr();return`UTC${n>=0?`+`:``}${n}`}function tr(){var e=(/* @__PURE__ */ new Date()).getFullYear();return Math.max(F(new Date(e,0,1).getTimezoneOffset()),F(new Date(e,6,1).getTimezoneOffset()))}function nr(){try{return!!window.sessionStorage}catch{return!0}}function rr(){try{return!!window.localStorage}catch{return!0}}function ir(){if(!(Jt()||Yt()))try{return!!window.indexedDB}catch{return!0}}function ar(){return!!window.openDatabase}function or(){return navigator.cpuClass}function sr(){var e=navigator.platform;return e===`MacIntel`&&V()&&!Zt()?an()?`iPad`:`iPhone`:e}function cr(){return navigator.vendor||``}function lr(){for(var e=[],t=0,n=[`chrome`,`safari`,`__crWeb`,`__gCrWeb`,`yandex`,`__yb`,`__ybro`,`__firefox__`,`__edgeTrackingPreventionStatistics`,`webkit`,`oprt`,`samsungAr`,`ucweb`,`UCShellJava`,`puffinDevice`];t<n.length;t++){var r=n[t],i=window[r];i&&typeof i==`object`&&e.push(r)}return e.sort()}function ur(){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 dr(){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 fr(e){var t=(e===void 0?{}:e).debug;return N(this,void 0,void 0,function(){var e,n,r,i,a,o;return P(this,function(s){switch(s.label){case 0:return pr()?(e=dr(),n=Object.keys(e),r=(o=[]).concat.apply(o,n.map(function(t){return e[t]})),[4,mr(r)]):[2,void 0];case 1:return i=s.sent(),t&&gr(e,i),a=n.filter(function(t){var n=e[t];return L(n.map(function(e){return i[e]}))>n.length*.6}),a.sort(),[2,a]}})})}function pr(){return V()||cn()}function mr(e){var t;return N(this,void 0,void 0,function(){var n,r,i,a,o,s,c,o;return P(this,function(l){switch(l.label){case 0:for(n=document,r=n.createElement(`div`),i=Array(e.length),a={},hr(r),o=0;o<e.length;++o)s=vn(e[o]),s.tagName===`DIALOG`&&s.show(),c=n.createElement(`div`),hr(c),c.appendChild(s),r.appendChild(c),i[o]=s;l.label=1;case 1:return n.body?[3,3]:[4,yt(50)];case 2:return l.sent(),[3,1];case 3:n.body.appendChild(r);try{for(o=0;o<e.length;++o)i[o].offsetParent||(a[e[o]]=!0)}finally{(t=r.parentNode)==null||t.removeChild(r)}return[2,a]}})})}function hr(e){e.style.setProperty(`visibility`,`hidden`,`important`),e.style.setProperty(`display`,`block`,`important`)}function gr(e,t){for(var n="DOM blockers debug:\n```",r=0,i=Object.keys(e);r<i.length;r++){var a=i[r];n+=`
|
|
3
3
|
${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
4
|
-
${t[c]?`🚫`:`➡️`} ${c}`}}}function vr(){for(var e=0,t=[`rec2020`,`p3`,`srgb`];e<t.length;e++){var n=t[e];if(matchMedia(`(color-gamut: ${n})`).matches)return n}}function yr(){if(br(`inverted`))return!0;if(br(`none`))return!1}function br(e){return matchMedia(`(inverted-colors: ${e})`).matches}function xr(){if(Sr(`active`))return!0;if(Sr(`none`))return!1}function Sr(e){return matchMedia(`(forced-colors: ${e})`).matches}var Cr=100;function wr(){if(matchMedia(`(min-monochrome: 0)`).matches){for(var e=0;e<=Cr;++e)if(matchMedia(`(max-monochrome: ${e})`).matches)return e;throw Error(`Too high value`)}}function Tr(){if(Er(`no-preference`))return 0;if(Er(`high`)||Er(`more`))return 1;if(Er(`low`)||Er(`less`))return-1;if(Er(`forced`))return 10}function Er(e){return matchMedia(`(prefers-contrast: ${e})`).matches}function Dr(){if(Or(`reduce`))return!0;if(Or(`no-preference`))return!1}function Or(e){return matchMedia(`(prefers-reduced-motion: ${e})`).matches}function kr(){if(Ar(`reduce`))return!0;if(Ar(`no-preference`))return!1}function Ar(e){return matchMedia(`(prefers-reduced-transparency: ${e})`).matches}function jr(){if(Mr(`high`))return!0;if(Mr(`standard`))return!1}function Mr(e){return matchMedia(`(dynamic-range: ${e})`).matches}var V=Math,H=function(){return 0};function Nr(){var e=V.acos||H,t=V.acosh||H,n=V.asin||H,r=V.asinh||H,i=V.atanh||H,a=V.atan||H,o=V.sin||H,s=V.sinh||H,c=V.cos||H,l=V.cosh||H,u=V.tan||H,d=V.tanh||H,f=V.exp||H,p=V.expm1||H,m=V.log1p||H;return{acos:e(.12312423423423424),acosh:t(1e308),acoshPf:function(e){return V.log(e+V.sqrt(e*e-1))}(1e154),asin:n(.12312423423423424),asinh:r(1),asinhPf:function(e){return V.log(e+V.sqrt(e*e+1))}(1),atanh:i(.5),atanhPf:function(e){return V.log((1+e)/(1-e))/2}(.5),atan:a(.5),sin:o(-1e300),sinh:s(1),sinhPf:function(e){return V.exp(e)-1/V.exp(e)/2}(1),cos:c(10.000000000123),cosh:l(1),coshPf:function(e){return(V.exp(e)+1/V.exp(e))/2}(1),tan:u(-1e300),tanh:d(1),tanhPf:function(e){return(V.exp(2*e)-1)/(V.exp(2*e)+1)}(1),exp:f(1),expm1:p(1),expm1Pf:function(e){return V.exp(e)-1}(1),log1p:m(10),log1pPf:function(e){return V.log(1+e)}(10),powPI:function(e){return V.pow(V.PI,e)}(-100)}}var Pr=`mmMwWLliI0fiflO&1`,Fr={default:[],apple:[{font:`-apple-system-body`}],serif:[{fontFamily:`serif`}],sans:[{fontFamily:`sans-serif`}],mono:[{fontFamily:`monospace`}],min:[{fontSize:`1px`}],system:[{fontFamily:`system-ui`}]};function Ir(){return Lr(function(e,t){for(var n={},r={},i=0,a=Object.keys(Fr);i<a.length;i++){var o=a[i],s=Fr[o],c=s[0],l=c===void 0?{}:c,u=s[1],d=u===void 0?Pr:u,f=e.createElement(`span`);f.textContent=d,f.style.whiteSpace=`nowrap`;for(var p=0,m=Object.keys(l);p<m.length;p++){var h=m[p],g=l[h];g!==void 0&&(f.style[h]=g)}n[o]=f,t.append(e.createElement(`br`),f)}for(var _=0,v=Object.keys(Fr);_<v.length;_++){var o=v[_];r[o]=n[o].getBoundingClientRect().width}return r})}function Lr(e,t){return t===void 0&&(t=4e3),vn(function(n,r){var i=r.document,a=i.body,o=a.style;o.width=`${t}px`,o.webkitTextSizeAdjust=o.textSizeAdjust=`none`,Zt()?a.style.zoom=`${1/r.devicePixelRatio}`:B()&&(a.style.zoom=`reset`);var s=i.createElement(`div`);return s.textContent=vt([],Array(t/20<<0),!0).map(function(){return`word`}).join(` `),a.appendChild(s),e(i,a)},`<!doctype html><html><head><meta name="viewport" content="width=device-width, initial-scale=1">`)}function Rr(){return navigator.pdfViewerEnabled}function zr(){var e=new Float32Array(1),t=new Uint8Array(e.buffer);return e[0]=1/0,e[0]-=e[0],t[3]}function Br(){var e=window.ApplePaySession;if(typeof e?.canMakePayments!=`function`)return-1;if(Vr())return-3;try{return+!!e.canMakePayments()}catch(e){return Hr(e)}}var Vr=xn;function Hr(e){if(e instanceof Error&&e.name===`InvalidAccessError`&&/\bfrom\b.*\binsecure\b/i.test(e.message))return-2;throw e}function Ur(){var e=document.createElement(`a`),t=e.attributionSourceId??e.attributionsourceid;return t===void 0?void 0:String(t)}var Wr=-1,Gr=-2,Kr=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]),qr=new Set([34047,35723,36063,34852,34853,34854,34229,36392,36795,38449]),Jr=[`FRAGMENT_SHADER`,`VERTEX_SHADER`],Yr=[`LOW_FLOAT`,`MEDIUM_FLOAT`,`HIGH_FLOAT`,`LOW_INT`,`MEDIUM_INT`,`HIGH_INT`],Xr=`WEBGL_debug_renderer_info`,Zr=`WEBGL_polygon_mode`;function Qr(e){var t=e.cache,n=ei(t);if(!n)return Wr;if(!oi(n))return Gr;var r=ii()?null:n.getExtension(Xr);return{version:n.getParameter(n.VERSION)?.toString()||``,vendor:n.getParameter(n.VENDOR)?.toString()||``,vendorUnmasked:r?n.getParameter(r.UNMASKED_VENDOR_WEBGL)?.toString():``,renderer:n.getParameter(n.RENDERER)?.toString()||``,rendererUnmasked:r?n.getParameter(r.UNMASKED_RENDERER_WEBGL)?.toString():``,shadingLanguageVersion:n.getParameter(n.SHADING_LANGUAGE_VERSION)?.toString()||``}}function $r(e){var t=e.cache,n=ei(t);if(!n)return Wr;if(!oi(n))return Gr;var r=n.getSupportedExtensions(),i=n.getContextAttributes(),a=[],o=[],s=[],c=[],l=[];if(i)for(var u=0,d=Object.keys(i);u<d.length;u++){var f=d[u];o.push(`${f}=${i[f]}`)}for(var p=ni(n),m=0,h=p;m<h.length;m++){var g=h[m],_=n[g];s.push(`${g}=${_}${Kr.has(_)?`=${n.getParameter(_)}`:``}`)}if(r)for(var v=0,y=r;v<y.length;v++){var b=y[v];if(!(b===Xr&&ii()||b===Zr&&ai())){var x=n.getExtension(b);if(!x){a.push(b);continue}for(var S=0,C=ni(x);S<C.length;S++){var g=C[S],_=x[g];c.push(`${g}=${_}${qr.has(_)?`=${n.getParameter(_)}`:``}`)}}}for(var w=0,T=Jr;w<T.length;w++)for(var ee=T[w],te=0,E=Yr;te<E.length;te++){var ne=E[te],re=ti(n,ee,ne);l.push(`${ee}.${ne}=${re.join(`,`)}`)}return c.sort(),s.sort(),{contextAttributes:o,parameters:s,shaderPrecisions:l,extensions:r,extensionParameters:c,unsupportedExtensions:a}}function ei(e){if(e.webgl)return e.webgl.context;var t=document.createElement(`canvas`),n;t.addEventListener(`webglCreateContextError`,function(){n=void 0});for(var r=0,i=[`webgl`,`experimental-webgl`];r<i.length;r++){var a=i[r];try{n=t.getContext(a)}catch{}if(n)break}return e.webgl={context:n},n}function ti(e,t,n){var r=e.getShaderPrecisionFormat(e[t],e[n]);return r?[r.rangeMin,r.rangeMax,r.precision]:[]}function ni(e){return Object.keys(e.__proto__).filter(ri)}function ri(e){return typeof e==`string`&&!e.match(/[^A-Z0-9_x]/)}function ii(){return en()}function ai(){return Zt()||B()}function oi(e){return typeof e.getParameter==`function`}function si(){if(!(ln()||B()))return-2;if(!window.AudioContext)return-1;var e=new AudioContext().baseLatency;return e==null?-1:isFinite(e)?e:-3}function ci(){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 li={fonts:En,domBlockers:pr,fontPreferences:Ir,audio:dn,screenFrame:Zn,canvas:On,osCpu:zn,languages:Bn,colorDepth:Vn,deviceMemory:Hn,screenResolution:Un,hardwareConcurrency:er,timezone:tr,sessionStorage:rr,localStorage:ir,indexedDB:ar,openDatabase:or,cpuClass:sr,platform:cr,plugins:Dn,touchSupport:Rn,vendor:lr,vendorFlavors:ur,cookiesEnabled:dr,colorGamut:vr,invertedColors:yr,forcedColors:xr,monochrome:wr,contrast:Tr,reducedMotion:Dr,reducedTransparency:kr,hdr:jr,math:Nr,pdfViewerEnabled:Rr,architecture:zr,applePay:Br,privateClickMeasurement:Ur,audioBaseLatency:si,dateTimeLocale:ci,webGlBasics:Qr,webGlExtensions:$r};function ui(e){return Jt(li,e,[])}var di=`$ if upgrade to Pro: https://fpjs.dev/pro`;function fi(e){var t=pi(e),n=mi(t);return{score:t,comment:di.replace(/\$/g,`${n}`)}}function pi(e){if(ln())return .4;if(B())return Qt()&&!(an()&&$t())?.5:.3;var t=`value`in e.platform?e.platform.value:``;return/^Win/.test(t)?.6:/^Mac/.test(t)?.5:.7}function mi(e){return At(.99+.01*e,1e-4)}function hi(e){for(var t=``,n=0,r=Object.keys(e).sort();n<r.length;n++){var i=r[n],a=e[i],o=`error`in a?`error`:JSON.stringify(a.value);t+=`${t?`|`:``}${i.replace(/([:|\\])/g,`\\$1`)}:${o}`}return t}function gi(e){return JSON.stringify(e,function(e,t){return t instanceof Error?Wt(t):t},2)}function _i(e){return Ut(hi(e))}function vi(e){var t;return{get visitorId(){return t===void 0&&(t=_i(this.components)),t},set visitorId(e){t=e},confidence:fi(e),components:e,version:yt}}function yi(e){return e===void 0&&(e=50),St(e,e*2)}function bi(e,t){return{get:function(n){return M(this,void 0,void 0,function(){var r,i;return N(this,function(a){switch(a.label){case 0:return[4,e()];case 1:return r=a.sent(),i=vi(r),t||n?.debug,[2,i]}})})}}}function xi(){if(!(window.__fpjs_d_m||Math.random()>=.001))try{var e=new XMLHttpRequest;e.open(`get`,`https://m1.openfpcdn.io/fingerprintjs/v${yt}/npm-monitoring`,!0),e.send()}catch{}}function Si(e){return e===void 0&&(e={}),M(this,void 0,void 0,function(){var t,n,r;return N(this,function(i){switch(i.label){case 0:return(e.monitoring??!0)&&xi(),t=e.delayFallback,n=e.debug,[4,yi(t)];case 1:return i.sent(),r=ui({cache:{},debug:n}),[2,bi(r,n)]}})})}var Ci={load:Si,hashComponents:_i,componentsToDebugString:gi};function wi(e){return e.preview?`include`:`same-origin`}function Ti(e){return e.sessionToken?{"x-widget-session-token":e.sessionToken}:{}}function Ei(e,t){return t.configChannel===`draft`?`${e}${e.includes(`?`)?`&`:`?`}configChannel=draft`:e}var Di=class{baseUrl;options;sessionToken;sessionTokenExpiresAt;constructor(e,t={}){this.baseUrl=e,this.options=t}get credentials(){return wi(this.options)}channel(e){return Ei(e,this.options)}authHeaders(){return{"Content-Type":`application/json`,...Ti({sessionToken:this.sessionToken})}}getSessionToken(){return this.sessionToken}hasValidSessionToken(){return!!this.sessionToken&&!!this.sessionTokenExpiresAt&&this.sessionTokenExpiresAt-6e4>Date.now()}async establishSession(e,t,n){if(!t)return!1;try{let r=await fetch(this.channel(`${this.baseUrl}/v1/widget/session`),{method:`POST`,credentials:this.credentials,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentId:e,tenantId:t,turnstileToken:n})});if(!r.ok)return!1;let i=await r.json();if(!i.success||typeof i.data?.token!=`string`)return!1;this.sessionToken=i.data.token;let a=typeof i.data.expiresIn==`number`?i.data.expiresIn:0;return this.sessionTokenExpiresAt=Date.now()+a*1e3,!0}catch{return!1}}async validateWidget(e,t){if(!t)return{valid:!1,error:`Widget is not configured: tenantId is required`};try{let n=new URLSearchParams({agentId:e,tenantId:t}),r=await fetch(this.channel(`${this.baseUrl}/v1/widget/validate?${n}`),{credentials:this.credentials}),i=await r.json();if(r.ok&&i.success)return{valid:!0,agentId:i.data.agentId,tenantId:i.data.tenantId};let a=i?.code===`AGENT_DISABLED`?`AGENT_DISABLED`:r.status===404?`AGENT_NOT_FOUND`:void 0;return{valid:!1,error:i.error??`Widget configuration is invalid (${r.status})`,...a?{code:a}:{}}}catch{return{valid:!1,error:`Unable to reach the KlicForge API to validate widget configuration`}}}async chat(e){let t=await fetch(this.channel(`${this.baseUrl}/v1/agents/${encodeURIComponent(e.agentId)}/responses`),{method:`POST`,credentials:this.credentials,headers:this.authHeaders(),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 Error(`API error: ${t.status} ${t.statusText}`);let n=await t.json();if(!n.success)throw Error(n.error??`Unknown API error`);return{content:n.data?.text??``,sessionId:n.data?.sessionId,images:n.data?.images,documents:n.data?.documents,queued:!!n.data?.queued,controlMode:n.data?.controlMode}}async fetchSessionMessages(e,t){try{let n=t?`?tenantId=${encodeURIComponent(t)}`:``,r=await fetch(`${this.baseUrl}/v1/sessions/${encodeURIComponent(e)}/messages${n}`,{credentials:this.credentials});if(r.status===410||!r.ok)return null;let i=await r.json();return i.success?i.data?.messages??null:null}catch{return null}}async uploadImage(e,t,n,r,i){let a=await fetch(this.channel(`${this.baseUrl}/v1/upload`),{method:`POST`,credentials:this.credentials,headers:this.authHeaders(),body:JSON.stringify({file:e,mimeType:t,fileName:n,agentId:r,tenantId:i})});if(!a.ok)throw Error(`Upload error: ${a.status} ${a.statusText}`);let o=await a.json();if(!o.success)throw Error(o.error??`Upload failed`);return{url:o.data.url}}async uploadFile(e,t,n,r,i){let a=await fetch(this.channel(`${this.baseUrl}/v1/upload`),{method:`POST`,credentials:this.credentials,headers:this.authHeaders(),body:JSON.stringify({file:e,mimeType:t,fileName:n,agentId:r,tenantId:i,kind:`file`})});if(!a.ok)throw Error(`Upload error: ${a.status} ${a.statusText}`);let o=await a.json();if(!o.success)throw Error(o.error??`Upload failed`);return{url:o.data.url}}async uploadVoiceNote(e,t,n,r,i){let a=await fetch(this.channel(`${this.baseUrl}/v1/upload`),{method:`POST`,credentials:this.credentials,headers:this.authHeaders(),body:JSON.stringify({file:e,mimeType:t,fileName:n,agentId:r,tenantId:i,kind:`audio`})});if(!a.ok)throw Error(`Upload error: ${a.status} ${a.statusText}`);let o=await a.json();if(!o.success)throw Error(o.error??`Upload failed`);return{url:o.data.url}}async fetchWidgetConfig(e,t){try{let n=t?`?tenantId=${encodeURIComponent(t)}`:``,r=await fetch(this.channel(`${this.baseUrl}/v1/agents/${encodeURIComponent(e)}/widget-config${n}`),{credentials:this.credentials});if(!r.ok)return null;let i=await r.json();return i.success?i.data:null}catch{return null}}async endSession(e,t,n,r,i,a){let o=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:n,fingerprint:r,externalId:i,skipMemory:a})});if(!o.ok)throw Error(`Failed to end session: ${o.status} ${o.statusText}`);let s=await o.json();if(!s.success)throw Error(s.error??`Failed to end session`)}};async function*Oi(e,t){if(!e.body)return;let n=e.body.getReader(),r=new TextDecoder,i=``,a=()=>{if(!t)return n.read();let e;return Promise.race([n.read(),new Promise((n,r)=>{e=setTimeout(()=>r(Error(`Stream timed out — no data received for ${t}ms`)),t)})]).finally(()=>clearTimeout(e))};for(;;){let{value:e,done:t}=await a();if(t)break;i+=r.decode(e,{stream:!0});let n=i.lastIndexOf(`
|
|
4
|
+
${t[c]?`🚫`:`➡️`} ${c}`}}}function _r(){for(var e=0,t=[`rec2020`,`p3`,`srgb`];e<t.length;e++){var n=t[e];if(matchMedia(`(color-gamut: ${n})`).matches)return n}}function vr(){if(yr(`inverted`))return!0;if(yr(`none`))return!1}function yr(e){return matchMedia(`(inverted-colors: ${e})`).matches}function br(){if(xr(`active`))return!0;if(xr(`none`))return!1}function xr(e){return matchMedia(`(forced-colors: ${e})`).matches}var Sr=100;function Cr(){if(matchMedia(`(min-monochrome: 0)`).matches){for(var e=0;e<=Sr;++e)if(matchMedia(`(max-monochrome: ${e})`).matches)return e;throw Error(`Too high value`)}}function wr(){if(Tr(`no-preference`))return 0;if(Tr(`high`)||Tr(`more`))return 1;if(Tr(`low`)||Tr(`less`))return-1;if(Tr(`forced`))return 10}function Tr(e){return matchMedia(`(prefers-contrast: ${e})`).matches}function Er(){if(Dr(`reduce`))return!0;if(Dr(`no-preference`))return!1}function Dr(e){return matchMedia(`(prefers-reduced-motion: ${e})`).matches}function Or(){if(kr(`reduce`))return!0;if(kr(`no-preference`))return!1}function kr(e){return matchMedia(`(prefers-reduced-transparency: ${e})`).matches}function Ar(){if(jr(`high`))return!0;if(jr(`standard`))return!1}function jr(e){return matchMedia(`(dynamic-range: ${e})`).matches}var H=Math,U=function(){return 0};function Mr(){var e=H.acos||U,t=H.acosh||U,n=H.asin||U,r=H.asinh||U,i=H.atanh||U,a=H.atan||U,o=H.sin||U,s=H.sinh||U,c=H.cos||U,l=H.cosh||U,u=H.tan||U,d=H.tanh||U,f=H.exp||U,p=H.expm1||U,m=H.log1p||U;return{acos:e(.12312423423423424),acosh:t(1e308),acoshPf:function(e){return H.log(e+H.sqrt(e*e-1))}(1e154),asin:n(.12312423423423424),asinh:r(1),asinhPf:function(e){return H.log(e+H.sqrt(2))}(1),atanh:i(.5),atanhPf:function(e){return H.log(3)/2}(.5),atan:a(.5),sin:o(-1e300),sinh:s(1),sinhPf:function(e){return H.exp(e)-1/H.exp(e)/2}(1),cos:c(10.000000000123),cosh:l(1),coshPf:function(e){return(H.exp(e)+1/H.exp(e))/2}(1),tan:u(-1e300),tanh:d(1),tanhPf:function(e){return(H.exp(2)-1)/(H.exp(2)+1)}(1),exp:f(1),expm1:p(1),expm1Pf:function(e){return H.exp(e)-1}(1),log1p:m(10),log1pPf:function(e){return H.log(11)}(10),powPI:function(e){return H.pow(H.PI,e)}(-100)}}var Nr=`mmMwWLliI0fiflO&1`,Pr={default:[],apple:[{font:`-apple-system-body`}],serif:[{fontFamily:`serif`}],sans:[{fontFamily:`sans-serif`}],mono:[{fontFamily:`monospace`}],min:[{fontSize:`1px`}],system:[{fontFamily:`system-ui`}]};function Fr(){return Ir(function(e,t){for(var n={},r={},i=0,a=Object.keys(Pr);i<a.length;i++){var o=a[i],s=Pr[o],c=s[0],l=c===void 0?{}:c,u=s[1],d=u===void 0?Nr:u,f=e.createElement(`span`);f.textContent=d,f.style.whiteSpace=`nowrap`;for(var p=0,m=Object.keys(l);p<m.length;p++){var h=m[p],g=l[h];g!==void 0&&(f.style[h]=g)}n[o]=f,t.append(e.createElement(`br`),f)}for(var _=0,v=Object.keys(Pr);_<v.length;_++){var o=v[_];r[o]=n[o].getBoundingClientRect().width}return r})}function Ir(e,t){return t===void 0&&(t=4e3),_n(function(n,r){var i=r.document,a=i.body,o=a.style;o.width=`${t}px`,o.webkitTextSizeAdjust=o.textSizeAdjust=`none`,Xt()?a.style.zoom=`${1/r.devicePixelRatio}`:V()&&(a.style.zoom=`reset`);var s=i.createElement(`div`);return s.textContent=_t([],Array(t/20|0),!0).map(function(){return`word`}).join(` `),a.appendChild(s),e(i,a)},`<!doctype html><html><head><meta name="viewport" content="width=device-width, initial-scale=1">`)}function Lr(){return navigator.pdfViewerEnabled}function Rr(){var e=/* @__PURE__ */ new Float32Array(1),t=new Uint8Array(e.buffer);return e[0]=1/0,e[0]-=e[0],t[3]}function zr(){var e=window.ApplePaySession;if(typeof e?.canMakePayments!=`function`)return-1;if(Br())return-3;try{return+!!e.canMakePayments()}catch(e){return Vr(e)}}var Br=bn;function Vr(e){if(e instanceof Error&&e.name===`InvalidAccessError`&&/\bfrom\b.*\binsecure\b/i.test(e.message))return-2;throw e}function Hr(){var e=document.createElement(`a`),t=e.attributionSourceId??e.attributionsourceid;return t===void 0?void 0:String(t)}var Ur=-1,Wr=-2,Gr=/* @__PURE__ */ 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]),Kr=/* @__PURE__ */ new Set([34047,35723,36063,34852,34853,34854,34229,36392,36795,38449]),qr=[`FRAGMENT_SHADER`,`VERTEX_SHADER`],Jr=[`LOW_FLOAT`,`MEDIUM_FLOAT`,`HIGH_FLOAT`,`LOW_INT`,`MEDIUM_INT`,`HIGH_INT`],Yr=`WEBGL_debug_renderer_info`,Xr=`WEBGL_polygon_mode`;function Zr(e){var t=e.cache,n=$r(t);if(!n)return Ur;if(!ai(n))return Wr;var r=ri()?null:n.getExtension(Yr);return{version:n.getParameter(n.VERSION)?.toString()||``,vendor:n.getParameter(n.VENDOR)?.toString()||``,vendorUnmasked:r?n.getParameter(r.UNMASKED_VENDOR_WEBGL)?.toString():``,renderer:n.getParameter(n.RENDERER)?.toString()||``,rendererUnmasked:r?n.getParameter(r.UNMASKED_RENDERER_WEBGL)?.toString():``,shadingLanguageVersion:n.getParameter(n.SHADING_LANGUAGE_VERSION)?.toString()||``}}function Qr(e){var t=e.cache,n=$r(t);if(!n)return Ur;if(!ai(n))return Wr;var r=n.getSupportedExtensions(),i=n.getContextAttributes(),a=[],o=[],s=[],c=[],l=[];if(i)for(var u=0,d=Object.keys(i);u<d.length;u++){var f=d[u];o.push(`${f}=${i[f]}`)}for(var p=ti(n),m=0,h=p;m<h.length;m++){var g=h[m],_=n[g];s.push(`${g}=${_}${Gr.has(_)?`=${n.getParameter(_)}`:``}`)}if(r)for(var v=0,y=r;v<y.length;v++){var b=y[v];if(!(b===Yr&&ri()||b===Xr&&ii())){var x=n.getExtension(b);if(!x)a.push(b);else for(var S=0,C=ti(x);S<C.length;S++){var g=C[S],_=x[g];c.push(`${g}=${_}${Kr.has(_)?`=${n.getParameter(_)}`:``}`)}}}for(var w=0,T=qr;w<T.length;w++)for(var E=T[w],ee=0,D=Jr;ee<D.length;ee++){var te=D[ee],ne=ei(n,E,te);l.push(`${E}.${te}=${ne.join(`,`)}`)}return c.sort(),s.sort(),{contextAttributes:o,parameters:s,shaderPrecisions:l,extensions:r,extensionParameters:c,unsupportedExtensions:a}}function $r(e){if(e.webgl)return e.webgl.context;var t=document.createElement(`canvas`),n;t.addEventListener(`webglCreateContextError`,function(){n=void 0});for(var r=0,i=[`webgl`,`experimental-webgl`];r<i.length;r++){var a=i[r];try{n=t.getContext(a)}catch{}if(n)break}return e.webgl={context:n},n}function ei(e,t,n){var r=e.getShaderPrecisionFormat(e[t],e[n]);return r?[r.rangeMin,r.rangeMax,r.precision]:[]}function ti(e){return Object.keys(e.__proto__).filter(ni)}function ni(e){return typeof e==`string`&&!e.match(/[^A-Z0-9_x]/)}function ri(){return $t()}function ii(){return Xt()||V()}function ai(e){return typeof e.getParameter==`function`}function oi(){if(!(cn()||V()))return-2;if(!window.AudioContext)return-1;var e=new AudioContext().baseLatency;return e==null?-1:isFinite(e)?e:-3}function si(){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 ci={fonts:Tn,domBlockers:fr,fontPreferences:Fr,audio:un,screenFrame:Xn,canvas:Dn,osCpu:Rn,languages:zn,colorDepth:Bn,deviceMemory:Vn,screenResolution:Hn,hardwareConcurrency:$n,timezone:er,sessionStorage:nr,localStorage:rr,indexedDB:ir,openDatabase:ar,cpuClass:or,platform:sr,plugins:En,touchSupport:Ln,vendor:cr,vendorFlavors:lr,cookiesEnabled:ur,colorGamut:_r,invertedColors:vr,forcedColors:br,monochrome:Cr,contrast:wr,reducedMotion:Er,reducedTransparency:Or,hdr:Ar,math:Mr,pdfViewerEnabled:Lr,architecture:Rr,applePay:zr,privateClickMeasurement:Hr,audioBaseLatency:oi,dateTimeLocale:si,webGlBasics:Zr,webGlExtensions:Qr};function li(e){return qt(ci,e,[])}var ui=`$ if upgrade to Pro: https://fpjs.dev/pro`;function di(e){var t=fi(e),n=pi(t);return{score:t,comment:ui.replace(/\$/g,`${n}`)}}function fi(e){if(cn())return .4;if(V())return Zt()&&!(rn()&&Qt())?.5:.3;var t=`value`in e.platform?e.platform.value:``;return/^Win/.test(t)?.6:/^Mac/.test(t)?.5:.7}function pi(e){return kt(.99+.01*e,1e-4)}function mi(e){for(var t=``,n=0,r=Object.keys(e).sort();n<r.length;n++){var i=r[n],a=e[i],o=`error`in a?`error`:JSON.stringify(a.value);t+=`${t?`|`:``}${i.replace(/([:|\\])/g,`\\$1`)}:${o}`}return t}function hi(e){return JSON.stringify(e,function(e,t){return t instanceof Error?Ut(t):t},2)}function gi(e){return Ht(mi(e))}function _i(e){var t;return{get visitorId(){return t===void 0&&(t=gi(this.components)),t},set visitorId(e){t=e},confidence:di(e),components:e,version:vt}}function vi(e){return e===void 0&&(e=50),xt(e,e*2)}function yi(e,t){return{get:function(n){return N(this,void 0,void 0,function(){var r,i;return P(this,function(a){switch(a.label){case 0:return[4,e()];case 1:return r=a.sent(),i=_i(r),t||n?.debug,[2,i]}})})}}}function bi(){if(!(window.__fpjs_d_m||Math.random()>=.001))try{var e=new XMLHttpRequest;e.open(`get`,`https://m1.openfpcdn.io/fingerprintjs/v${vt}/npm-monitoring`,!0),e.send()}catch{}}function xi(e){return e===void 0&&(e={}),N(this,void 0,void 0,function(){var t,n,r;return P(this,function(i){switch(i.label){case 0:return(e.monitoring??!0)&&bi(),t=e.delayFallback,n=e.debug,[4,vi(t)];case 1:return i.sent(),r=li({cache:{},debug:n}),[2,yi(r,n)]}})})}var Si={load:xi,hashComponents:gi,componentsToDebugString:hi};function Ci(e){return e.preview?`include`:`same-origin`}function wi(e){return e.sessionToken?{"x-widget-session-token":e.sessionToken}:{}}function Ti(e,t){return t.configChannel===`draft`?`${e}${e.includes(`?`)?`&`:`?`}configChannel=draft`:e}var Ei=class{baseUrl;options;sessionToken;sessionTokenExpiresAt;constructor(e,t={}){this.baseUrl=e,this.options=t}get credentials(){return Ci(this.options)}channel(e){return Ti(e,this.options)}authHeaders(){return{"Content-Type":`application/json`,...wi({sessionToken:this.sessionToken})}}getSessionToken(){return this.sessionToken}hasValidSessionToken(){return!!this.sessionToken&&!!this.sessionTokenExpiresAt&&this.sessionTokenExpiresAt-6e4>Date.now()}async establishSession(e,t,n){if(!t)return!1;try{let r=await fetch(this.channel(`${this.baseUrl}/v1/widget/session`),{method:`POST`,credentials:this.credentials,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentId:e,tenantId:t,turnstileToken:n})});if(!r.ok)return!1;let i=await r.json();if(!i.success||typeof i.data?.token!=`string`)return!1;this.sessionToken=i.data.token;let a=typeof i.data.expiresIn==`number`?i.data.expiresIn:0;return this.sessionTokenExpiresAt=Date.now()+a*1e3,!0}catch{return!1}}async validateWidget(e,t){if(!t)return{valid:!1,error:`Widget is not configured: tenantId is required`};try{let n=new URLSearchParams({agentId:e,tenantId:t}),r=await fetch(this.channel(`${this.baseUrl}/v1/widget/validate?${n}`),{credentials:this.credentials}),i=await r.json();if(r.ok&&i.success)return{valid:!0,agentId:i.data.agentId,tenantId:i.data.tenantId};let a=i?.code===`AGENT_DISABLED`?`AGENT_DISABLED`:r.status===404?`AGENT_NOT_FOUND`:void 0;return{valid:!1,error:i.error??`Widget configuration is invalid (${r.status})`,...a?{code:a}:{}}}catch{return{valid:!1,error:`Unable to reach the KlicForge API to validate widget configuration`}}}async chat(e){let t=await fetch(this.channel(`${this.baseUrl}/v1/agents/${encodeURIComponent(e.agentId)}/responses`),{method:`POST`,credentials:this.credentials,headers:this.authHeaders(),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 Error(`API error: ${t.status} ${t.statusText}`);let n=await t.json();if(!n.success)throw Error(n.error??`Unknown API error`);return{content:n.data?.text??``,sessionId:n.data?.sessionId,images:n.data?.images,documents:n.data?.documents,queued:!!n.data?.queued,controlMode:n.data?.controlMode}}async fetchSessionMessages(e,t){try{let n=t?`?tenantId=${encodeURIComponent(t)}`:``,r=await fetch(`${this.baseUrl}/v1/sessions/${encodeURIComponent(e)}/messages${n}`,{credentials:this.credentials});if(r.status===410||!r.ok)return null;let i=await r.json();return i.success?i.data?.messages??null:null}catch{return null}}async uploadImage(e,t,n,r,i){let a=await fetch(this.channel(`${this.baseUrl}/v1/upload`),{method:`POST`,credentials:this.credentials,headers:this.authHeaders(),body:JSON.stringify({file:e,mimeType:t,fileName:n,agentId:r,tenantId:i})});if(!a.ok)throw Error(`Upload error: ${a.status} ${a.statusText}`);let o=await a.json();if(!o.success)throw Error(o.error??`Upload failed`);return{url:o.data.url}}async uploadFile(e,t,n,r,i){let a=await fetch(this.channel(`${this.baseUrl}/v1/upload`),{method:`POST`,credentials:this.credentials,headers:this.authHeaders(),body:JSON.stringify({file:e,mimeType:t,fileName:n,agentId:r,tenantId:i,kind:`file`})});if(!a.ok)throw Error(`Upload error: ${a.status} ${a.statusText}`);let o=await a.json();if(!o.success)throw Error(o.error??`Upload failed`);return{url:o.data.url}}async uploadVoiceNote(e,t,n,r,i){let a=await fetch(this.channel(`${this.baseUrl}/v1/upload`),{method:`POST`,credentials:this.credentials,headers:this.authHeaders(),body:JSON.stringify({file:e,mimeType:t,fileName:n,agentId:r,tenantId:i,kind:`audio`})});if(!a.ok)throw Error(`Upload error: ${a.status} ${a.statusText}`);let o=await a.json();if(!o.success)throw Error(o.error??`Upload failed`);return{url:o.data.url}}async fetchWidgetConfig(e,t){try{let n=t?`?tenantId=${encodeURIComponent(t)}`:``,r=await fetch(this.channel(`${this.baseUrl}/v1/agents/${encodeURIComponent(e)}/widget-config${n}`),{credentials:this.credentials});if(!r.ok)return null;let i=await r.json();return i.success?i.data:null}catch{return null}}async endSession(e,t,n,r,i,a){let o=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:n,fingerprint:r,externalId:i,skipMemory:a})});if(!o.ok)throw Error(`Failed to end session: ${o.status} ${o.statusText}`);let s=await o.json();if(!s.success)throw Error(s.error??`Failed to end session`)}};async function*Di(e,t){if(!e.body)return;let n=e.body.getReader(),r=new TextDecoder,i=``,a=()=>{if(!t)return n.read();let e;return Promise.race([n.read(),new Promise((n,r)=>{e=setTimeout(()=>r(/* @__PURE__ */ Error(`Stream timed out — no data received for ${t}ms`)),t)})]).finally(()=>clearTimeout(e))};for(;;){let{value:e,done:t}=await a();if(t)break;i+=r.decode(e,{stream:!0});let n=i.lastIndexOf(`
|
|
5
5
|
`);if(n===-1)continue;let o=i.slice(0,n);i=i.slice(n+1);for(let e of o.split(`
|
|
6
|
-
`)){let t=e.trim();if(!t.startsWith(`data:`))continue;let n=t.slice(5).trim();n&&(yield n)}}}var
|
|
6
|
+
`)){let t=e.trim();if(!t.startsWith(`data:`))continue;let n=t.slice(5).trim();n&&(yield n)}}}var Oi=12e4;async function ki(e,t,n,r={}){let i=``,a=!1;try{let o=await fetch(Ti(`${e}/v1/agents/${encodeURIComponent(t.agentId)}/responses:stream`,r),{method:`POST`,credentials:Ci(r),headers:{"Content-Type":`application/json`,...wi(r)},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(!o.ok||!o.body){let e=`${o.status} ${o.statusText}`;try{let t=await o.json();t.error&&(e=t.error)}catch{}throw Object.assign(Error(e),{status:o.status})}let s=o.headers.get(`x-session-id`);s&&n.onSession&&n.onSession(s);let c=o.headers.get(`x-run-id`);c&&n.onRunId&&(a=!0,n.onRunId(c));let l=e=>{if(e===`[DONE]`)return n.onEnd(i),!0;try{let t=JSON.parse(e);if(!a&&typeof t.runId==`string`&&n.onRunId&&(a=!0,n.onRunId(t.runId)),t.type===`session`){let e=t.sessionId;return e&&n.onSession&&n.onSession(e),!1}if(t.type===`done`||t.type===`stop`)return n.onEnd(i),!0;if(t.type===`error`)throw Error(t.message??`Stream error`);if(t.type===`images`){let e=t.images;return e&&n.onImages&&n.onImages(e),!1}if(t.type===`documents`){let e=t.documents;return e&&n.onDocuments&&n.onDocuments(e),!1}if(t.type===`voice_transcript`){let e=t.transcript;return e&&n.onVoiceTranscript&&n.onVoiceTranscript(e),!1}if(t.type===`control_mode`){let e=t.mode,r=!!t.queued;return e&&n.onControlMode&&n.onControlMode(e,r),r?(n.onEnd(i),!0):!1}if(t.type===`tool_calls_started`){let e=t.toolNames??[];return i.length>0&&!i.endsWith(`
|
|
7
7
|
|
|
8
8
|
`)&&(i=i.replace(/\s+$/,``)+`
|
|
9
9
|
|
|
10
10
|
`,n.onDelta(`
|
|
11
11
|
|
|
12
|
-
`,i)),n.onToolCallsStarted?.(e,t.activityMode),!1}if(t.type===`assistant_ack`){let e=t.text;return e&&n.onAck&&n.onAck(e),!1}if(t.type===`progress`){let e=t.stage,r=t.text,i=t.mode,a=t.timestamp;return e&&r&&n.onProgress&&n.onProgress(e,r,i,a),!1}if(t.type===`tool_start`){let e=t.toolId,r=t.text,i=t.toolName,a=t.mode,o=t.timestamp;return e&&r&&n.onToolStart&&n.onToolStart(e,r,i,a,o),!1}if(t.type===`tool_complete`){let e=t.toolId,r=t.text,i=t.durationMs,a=t.ok;return e&&r&&n.onToolComplete&&n.onToolComplete(e,r,i??0,a),!1}if(t.type===`model_start`||t.type===`final_meta`){if(t.type===`final_meta`&&n.onFinalMeta){let e=t.metrics;n.onFinalMeta(e??{},{mode:t.mode,collapseAfterFinal:t.collapseAfterFinal})}return!1}let r=
|
|
12
|
+
`,i)),n.onToolCallsStarted?.(e,t.activityMode),!1}if(t.type===`assistant_ack`){let e=t.text;return e&&n.onAck&&n.onAck(e),!1}if(t.type===`progress`){let e=t.stage,r=t.text,i=t.mode,a=t.timestamp;return e&&r&&n.onProgress&&n.onProgress(e,r,i,a),!1}if(t.type===`tool_start`){let e=t.toolId,r=t.text,i=t.toolName,a=t.mode,o=t.timestamp;return e&&r&&n.onToolStart&&n.onToolStart(e,r,i,a,o),!1}if(t.type===`tool_complete`){let e=t.toolId,r=t.text,i=t.durationMs,a=t.ok;return e&&r&&n.onToolComplete&&n.onToolComplete(e,r,i??0,a),!1}if(t.type===`model_start`||t.type===`final_meta`){if(t.type===`final_meta`&&n.onFinalMeta){let e=t.metrics;n.onFinalMeta(e??{},{mode:t.mode,collapseAfterFinal:t.collapseAfterFinal})}return!1}let r=Ai(t);r&&(i+=r,n.onDelta(r,i))}catch(e){if(!(e instanceof SyntaxError))throw e}return!1};for await(let e of Di(o,Oi))if(l(e))break;n.onEnd(i)}catch(e){n.onError(e instanceof Error?e:Error(String(e)))}}function Ai(e){let t=e.choices;if(Array.isArray(t)&&t.length>0){let e=t[0]?.delta,n=e?.content??e?.text??``;if(n)return n}let n=e.delta;if(n){let e=n.content??n.text??``;if(e)return e}return e.response||(e.text??e.content??``)}function ji(e,t,n){let r=t*2**(e-1),i=Math.min(r,n),a=i*.3;return Math.floor(i-a+a*2*Math.random())}async function Mi(e,t,n,r={}){let i=await fetch(`${e}/v1/sessions/${encodeURIComponent(t)}/runs/${encodeURIComponent(n)}`,{credentials:r.preview?`include`:`same-origin`});if(!i.ok)throw Error(`Failed to fetch run ${n}: ${i.status}`);let a=await i.json();if(!a.success||!a.data)throw Error(a.error??`Failed to fetch run ${n}`);return a.data}async function Ni(e,t,n,r={}){let i=r.maxAttempts??3,a;for(let o=1;o<=i;o++){if(o>1){let e=ji(o-1,500,4e3);await new Promise(t=>setTimeout(t,e))}try{let a=await Mi(e,t,n,r);if(a.status!==`running`||o===i)return a}catch(e){if(a=e instanceof Error?e:Error(String(e)),o===i)throw a}}throw a??/* @__PURE__ */ Error(`Failed to fetch run ${n}`)}var Pi=15e3,Fi,Ii,Li,Ri,zi=[];function Bi(){Ri||(Ri=e=>{if(!Fi||e.source!==Fi.contentWindow||Li&&e.origin!==Li)return;let t=e.data;t&&typeof t.type==`string`&&(t.type===`turnstile-token`&&typeof t.token==`string`?zi.shift()?.resolve(t.token):t.type===`turnstile-error`&&zi.shift()?.reject(Error(t.message??`Turnstile verification failed`)))},window.addEventListener(`message`,Ri))}function Vi(){Fi?.remove(),Fi=void 0,Ii=void 0}function Hi(e){if(Fi&&Ii)return Ii;if(typeof window>`u`||typeof document>`u`)return Promise.reject(/* @__PURE__ */ Error(`Turnstile requires a browser environment`));Bi(),Li=new URL(e).origin;let t=document.createElement(`iframe`);return t.src=`${e.replace(/\/$/,``)}/v1/widget/turnstile-challenge`,t.style.display=`none`,t.setAttribute(`aria-hidden`,`true`),t.sandbox.add(`allow-scripts`,`allow-same-origin`),Ii=new Promise((e,n)=>{let r=setTimeout(()=>{window.removeEventListener(`message`,i),n(/* @__PURE__ */ Error(`Turnstile challenge page failed to load`))},Pi);function i(n){n.source===t.contentWindow&&n.data?.type===`turnstile-ready`&&(clearTimeout(r),window.removeEventListener(`message`,i),e())}window.addEventListener(`message`,i)}).catch(e=>{throw Vi(),e}),Fi=t,document.body.appendChild(t),Ii}async function Ui(e){if(await Hi(e),!Fi?.contentWindow)throw Error(`Turnstile challenge frame unavailable`);let t=Fi.contentWindow,n=Li;return new Promise((e,r)=>{let i={resolve:t=>{clearTimeout(a),e(t)},reject:e=>{clearTimeout(a),r(e)}},a=setTimeout(()=>{let e=zi.indexOf(i);e!==-1&&zi.splice(e,1),r(/* @__PURE__ */ Error(`Turnstile verification timed out`))},Pi);zi.push(i),t.postMessage({type:`turnstile-solve`},n)})}var Wi=class{listeners=/* @__PURE__ */ new Map;on(e,t){this.listeners.has(e)||this.listeners.set(e,/* @__PURE__ */ new Set),this.listeners.get(e).add(t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(...e){let[t,n]=e;this.listeners.get(t)?.forEach(e=>e(n))}removeAllListeners(){this.listeners.clear()}},Gi=`agentforge`;function Ki(e){return`${Gi}:session:${e}`}function qi(e){try{return sessionStorage.getItem(Ki(e))??void 0}catch{return}}function Ji(e,t){try{sessionStorage.setItem(Ki(e),t)}catch{}}function Yi(e){try{sessionStorage.removeItem(Ki(e))}catch{}}function Xi(e,t,n){return e.map(e=>{if(e.status!==`active`||e.stage===`calling_tool`)return e;let r=n!==void 0&&e.serverTsMs!==void 0&&Number.isFinite(n)&&Number.isFinite(e.serverTsMs)&&n>=e.serverTsMs?n-e.serverTsMs:void 0;return{...e,status:`done`,durationMs:e.durationMs??r??(e.startedAtMs?t-e.startedAtMs:void 0)}})}function Zi(e){let t=Date.now();return e.map(e=>e.status===`active`?{...e,status:`done`,durationMs:e.durationMs??(e.startedAtMs?t-e.startedAtMs:void 0)}:e)}function Qi(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`;let t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return n>0?`${t}m ${n}s`:`${t}m`}var $i=`[Voice note] `;function ea(e,t){let n=t?.trim();return n?`${$i}${e}\n\n${n}`:`${$i}${e}`}function ta(e){if(!e.startsWith(`[Voice note] `))return null;let t=e.slice(13),n=t.indexOf(`
|
|
13
13
|
|
|
14
|
-
`);return n===-1?{transcript:t,rest:``}:{transcript:t.slice(0,n),rest:t.slice(n+2)}}function ra(){return`msg-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`}var ia=2e3,aa=class{hostConfig;onStateChange;sessionTokenPromise;config;apiClient;state;fingerprint;eventSource=null;emitter;constructor(e,t,n){this.hostConfig=t,this.onStateChange=n,this.config=e,this.apiClient=new Di(e.apiBaseUrl,{preview:e.preview,configChannel:e.configChannel}),this.emitter=new Gi,this.initializeFingerprint();let r=e.sessionId??Ji(e.agentId);e.sessionId&&Yi(e.agentId,e.sessionId);let i=e.mode===`inline`;this.state={isOpen:i,messages:[],isLoading:!1,error:null,sessionId:r,initStatus:`validating`,initError:null},i&&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{let e=await(await Ci.load()).get();this.fingerprint=e.visitorId}catch{this.fingerprint=void 0}}getState(){return{...this.state,messages:[...this.state.messages]}}setOpen(e){e?(this.ensureSessionToken(),this.openWithGreeting()):this.setState({isOpen:!1})}openWithGreeting(){this.state.initStatus===`error`||this.state.initStatus===`disabled`||this.setState({isOpen:!0})}async hydrate(){let 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){let e=await this.apiClient.fetchWidgetConfig(this.config.agentId,this.config.tenantId);e&&(this.config=ht(this.hostConfig,e),this.onStateChange(this.getState(),this.config))}if(this.setState({initStatus:`ready`}),!this.state.sessionId)return;this.openEventStream();let t=await this.apiClient.fetchSessionMessages(this.state.sessionId,this.config.tenantId);if(t===null){this.handleSessionExpired();return}if(t.length===0)return;let n=t.map(e=>{let t=e.direction===`human`,n=e.role===`user`,r=n?(e.media??[]).map(e=>({url:e.url,mimeType:e.mimeType,fileName:e.fileName,kind:e.mimeType.startsWith(`image/`)?`image`:e.mimeType.startsWith(`audio/`)?`audio`:`file`})):void 0;return{id:ra(),role:e.role,content:e.content,images:!n&&e.images&&e.images.length>0?e.images:void 0,uploadedAttachments:r&&r.length>0?r:void 0,uploadedImageUrl:e.imageUrl||void 0,createdAt:e.createdAt??new Date().toISOString(),status:`sent`,...t?{isHuman:!0,senderDisplay:e.senderDisplay??null}:{}}});this.setState({messages:[...this.state.messages,...n]})}openEventStream(){if(typeof EventSource>`u`||!this.state.sessionId||this.eventSource)return;let e=`${this.config.apiBaseUrl.replace(/\/$/,``)}/v1/sessions/${encodeURIComponent(this.state.sessionId)}/events`,t=new EventSource(e);t.onmessage=e=>{try{let t=JSON.parse(e.data);if(t.type===`control_mode`){let e=t.mode;this.setState({controlMode:e}),this.emitter.emit(`control_mode_changed`,{mode:e});return}if(t.type===`execution_state`){let e=t.state;e===`ai_thinking`||e===`ai_streaming`||e===`tool_running`?this.setState({isLoading:!0}):e===`idle`&&this.setState({isLoading:!1});return}if(t.type===`message`&&t.message&&typeof t.message==`object`){let e=t.message;if(typeof e.content!=`string`||e.id&&this.state.messages.some(t=>t.id===e.id))return;if(e.direction===`human`){let t={id:e.id??ra(),role:`assistant`,content:e.content,createdAt:e.createdAt??new Date().toISOString(),status:`sent`,isHuman:!0,senderDisplay:e.senderDisplay??null};this.setState({messages:[...this.state.messages,t],isLoading:!1}),this.emitter.emit(`message:received`,t);return}if(e.direction===`ai`){let t={id:e.id??ra(),role:`assistant`,content:e.content,createdAt:e.createdAt??new Date().toISOString(),status:`sent`};this.setState({messages:[...this.state.messages,t],isLoading:!1}),this.emitter.emit(`message:received`,t);return}}}catch{}},t.onerror=()=>{},this.eventSource=t}closeEventStream(){this.eventSource&&=(this.eventSource.close(),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(n=>n.id===e?{...n,...t}:n)},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{}Xi(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(){Xi(this.config.agentId),this.closeEventStream(),this.setState({sessionId:void 0,controlMode:void 0})}async sendMessage(e,t){let n=!!e.trim()||t&&t.length>0;if(this.state.isLoading||!n||this.state.initStatus!==`ready`)return;let r=[];if(t&&t.length>0)for(let e of t)try{let t=await sa(e.file);if(e.kind===`image`){let n=await this.apiClient.uploadImage(t,e.file.type,e.file.name,this.config.agentId,this.config.tenantId);r.push({url:n.url,mimeType:e.file.type,fileName:e.file.name,kind:`image`})}else if(e.kind===`audio`){let n=await this.apiClient.uploadVoiceNote(t,e.file.type||`audio/webm`,e.file.name,this.config.agentId,this.config.tenantId);r.push({url:n.url,mimeType:e.file.type||`audio/webm`,fileName:e.file.name,durationMs:e.durationMs,kind:`audio`})}else{let n=await this.apiClient.uploadFile(t,e.file.type||`application/octet-stream`,e.file.name,this.config.agentId,this.config.tenantId);r.push({url:n.url,mimeType:e.file.type||`application/octet-stream`,fileName:e.file.name,kind:`file`})}}catch(e){let t=e instanceof Error?e.message:`Attachment upload failed`;this.setState({error:t});return}let i=r.filter(e=>e.kind===`image`),a={id:ra(),role:`user`,content:e.trim(),uploadedImageUrl:i[0]?.url,uploadedAttachments:r.length>0?r:void 0,createdAt:new Date().toISOString(),status:`sent`},o=!this.state.messages.some(e=>e.role===`user`);this.setState({messages:[...this.state.messages,a],isLoading:!0,error:null}),this.emitter.emit(`message:sent`,a),o&&this.emitter.emit(`conversation:started`,{sessionId:this.state.sessionId});let s=r.length>0?r:void 0;this.config.streaming?await this.sendStreaming(e.trim(),void 0,s):await this.sendNonStreaming(e.trim(),void 0,s)}ensureSessionToken(){return!this.config.turnstileSiteKey||this.apiClient.hasValidSessionToken()?Promise.resolve():(this.sessionTokenPromise??=(async()=>{try{let e=await Wi(this.config.apiBaseUrl);await this.apiClient.establishSession(this.config.agentId,this.config.tenantId,e)}catch{}finally{this.sessionTokenPromise=void 0}})(),this.sessionTokenPromise)}async awaitSessionToken(){if(!this.config.turnstileSiteKey||this.apiClient.hasValidSessionToken())return;let e;await Promise.race([this.ensureSessionToken(),new Promise(t=>{e=setTimeout(t,ia)})]).finally(()=>clearTimeout(e))}async sendNonStreaming(e,t,n,r=!1){await this.awaitSessionToken();try{let r=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:n});if(r.queued&&r.controlMode===`human`){this.setState({isLoading:!1,controlMode:`human_takeover`,...r.sessionId?{sessionId:r.sessionId}:{}}),r.sessionId&&(Yi(this.config.agentId,r.sessionId),this.openEventStream());return}let i={id:ra(),role:`assistant`,content:r.content,images:r.images,documents:r.documents,createdAt:new Date().toISOString(),status:`sent`};this.setState({messages:[...this.state.messages,i],isLoading:!1,...r.sessionId?{sessionId:r.sessionId}:{}}),r.sessionId&&(Yi(this.config.agentId,r.sessionId),this.openEventStream()),this.emitter.emit(`message:received`,i)}catch(i){let a=i instanceof Error?i.message:`Failed to send message`;if(!r&&a.includes(`410`))return this.handleSessionExpired(),this.sendNonStreaming(e,t,n,!0);this.setState({isLoading:!1,error:a}),this.emitter.emit(`message:error`,{error:a,message:null}),this.reportError(a)}}async sendStreaming(e,t,n,r=!1){await this.awaitSessionToken();let i=ra(),a={id:i,role:`assistant`,content:``,createdAt:new Date().toISOString(),status:`streaming`};this.setState({messages:[...this.state.messages,a]}),this.emitter.emit(`stream:start`);let o=!1,s=!1,c=null,l=null,u=Date.now(),d=null;await Ai(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:n},{onSession:e=>{this.setState({sessionId:e}),Yi(this.config.agentId,e),this.openEventStream()},onRunId:e=>{this.updateMessage(i,{runId:e})},onImages:e=>{this.updateMessage(i,{images:e})},onDocuments:e=>{this.updateMessage(i,{documents:e})},onVoiceTranscript:e=>{let t=[...this.state.messages].reverse().find(e=>e.role===`user`);t&&this.updateMessage(t.id,{content:ta(e,t.content)})},onToolCallsStarted:(e,t)=>{t&&c===null&&(c=t),d=null,this.updateMessage(i,{answerStartedAtMs:null}),(t??c)!==`off`&&this.updateMessage(i,{toolStatus:oa(e)})},onAck:e=>{this.updateMessage(i,{ackText:e})},onProgress:(e,t,n,r)=>{let a=this.state.messages.find(e=>e.id===i)?.progressEvents??[],o=Date.now(),s=r?Date.parse(r):NaN,l=Number.isNaN(s)?void 0:s;n&&c===null&&(c=n,this.updateMessage(i,{turnMeta:{totalMs:null,collapseAfterFinal:null,mode:n}})),this.updateMessage(i,{progressEvents:[...Zi(a,o,l),{stage:e,text:t,timestamp:new Date().toISOString(),status:`active`,startedAtMs:o,serverTsMs:l}]})},onToolStart:(e,t,n,r,a)=>{let o=this.state.messages.find(e=>e.id===i)?.progressEvents??[],s=Date.now(),l=a?Date.parse(a):NaN,u=Number.isNaN(l)?void 0:l;r&&c===null&&(c=r,this.updateMessage(i,{turnMeta:{totalMs:null,collapseAfterFinal:null,mode:r}})),this.updateMessage(i,{progressEvents:[...Zi(o,s,u),{stage:`calling_tool`,toolId:e,toolName:n,text:t,timestamp:new Date().toISOString(),status:`active`,startedAtMs:s,serverTsMs:u}]})},onToolComplete:(e,t,n,r)=>{let a=this.state.messages.find(e=>e.id===i)?.progressEvents??[];this.updateMessage(i,{progressEvents:a.map(i=>i.stage===`calling_tool`&&i.status===`active`&&i.toolId===e?{...i,status:`done`,text:t,durationMs:n,ok:r}:i)})},onFinalMeta:(e,t)=>{c=t?.mode??c,l=t?.collapseAfterFinal??null},onDelta:(e,t)=>{e.trim()&&d===null&&(d=Date.now(),this.updateMessage(i,{answerStartedAtMs:d})),t.trim()&&(this.updateMessage(i,{content:t,toolStatus:void 0}),this.emitter.emit(`stream:delta`,{delta:e,accumulated:t}))},onEnd:e=>{if(s){this.setState({messages:this.state.messages.filter(e=>e.id!==i),isLoading:!1,controlMode:`human_takeover`}),this.emitter.emit(`stream:end`,{content:``});return}let t=this.state.messages.find(e=>e.id===i),n=c===`detailed`,r=n||c===`standard`;this.updateMessage(i,{content:e,status:`sent`,toolStatus:void 0,progressEvents:n&&t?.progressEvents?.length?Qi(t.progressEvents):void 0,progressCollapsed:n?l??!0:void 0,turnMeta:r?{totalMs:(d??Date.now())-u,collapseAfterFinal:l,mode:c}:void 0}),this.setState({isLoading:!1}),this.emitter.emit(`stream:end`,{content:e});let a=this.state.messages.find(e=>e.id===i);a&&this.emitter.emit(`message:received`,a)},onControlMode:(e,t)=>{t&&e===`human`&&(s=!0)},onError:e=>{if(!r&&e.status===410){o=!0,this.setState({messages:this.state.messages.filter(e=>e.id!==i),isLoading:!1});return}let t=t=>{let n=this.state.messages.find(e=>e.id===i)?.content??``;this.updateMessage(i,{content:n||t,status:`error`}),this.setState({isLoading:!1,error:t}),this.emitter.emit(`message:error`,{error:t,message:null}),this.reportError(t,{stack:e.stack})},n=e=>{this.updateMessage(i,{content:e,status:`sent`,toolStatus:void 0,progressEvents:void 0}),this.setState({isLoading:!1}),this.emitter.emit(`stream:end`,{content:e});let t=this.state.messages.find(e=>e.id===i);t&&this.emitter.emit(`message:received`,t)},a=this.state.messages.find(e=>e.id===i)?.runId,s=this.state.sessionId;if(a&&s){Pi(this.config.apiBaseUrl,s,a,{preview:this.config.preview}).then(r=>{r.status===`done`&&r.finalText?n(r.finalText):t(r.errorMessage||e.message||`Something went wrong. Please try again.`)}).catch(()=>t(e.message||`Something went wrong. Please try again.`));return}t(e.message||`Something went wrong. Please try again.`)}},{preview:this.config.preview,configChannel:this.config.configChannel,sessionToken:this.apiClient.getSessionToken()}),o&&(this.handleSessionExpired(),await this.sendStreaming(e,t,n,!0))}};function oa(e){let t=e[0];if(!t)return`Working...`;let n=t.indexOf(`.`);return n>0?`Using ${t.slice(0,n).replace(/_/g,` `)}: ${t.slice(n+1).replace(/_/g,` `)}${e.length>1?` +${e.length-1}`:``}`:`Using ${t.replace(/_/g,` `)}`}function sa(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result;t(e.split(`,`)[1]??``)},r.onerror=()=>n(Error(`Failed to read file`)),r.readAsDataURL(e)})}function ca(e){let t=document.createElement(`div`);t.setAttribute(`data-agentkit-widget`,``),e.appendChild(t);let n=t.attachShadow({mode:`open`}),r=document.createElement(`style`);n.appendChild(r);let i=document.createElement(`div`);return i.style.cssText=`display: contents;`,n.appendChild(i),{host:t,shadowRoot:n,styleSlot:r,mountPoint:i}}function la(e,t){e.textContent=t}function ua(e){e.remove()}function da(e){document.body?document.body.appendChild(e):document.addEventListener(`DOMContentLoaded`,()=>document.body.appendChild(e),{once:!0})}function fa(){let 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(`; `),da(e),e}function pa(e){getComputedStyle(e).position===`static`&&(e.style.position=`relative`);let 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 ma(e){return e.setAttribute(`data-agentkit-root`,`inline`),getComputedStyle(e).position===`static`&&(e.style.position=`relative`),e}function ha(e){e.remove()}function ga(e){e.removeAttribute(`data-agentkit-root`)}function _a(e,t,n,r,i){let a=e.mode===`inline`,o=!1,s=a&&i?ma(i):!a&&i?pa(i):fa(),c=ca(s);la(c.styleSlot,r);let l=new aa(e,t,(e,t)=>{o||u.update(e,t)}),u=n(c.mountPoint,e,l.getState(),{onOpen:()=>d.open(),onClose:()=>d.close(),onSendMessage:(e,t)=>{l.sendMessage(e,t)},onReset:()=>{l.resetConversation()}});l.hydrate(),setTimeout(()=>{o||l.emitter.emit(`ready`,l.getState())},0);let d={open(){o||(l.setOpen(!0),l.emitter.emit(`open`))},close(){o||(l.setOpen(!1),l.emitter.emit(`close`))},toggle(){l.getState().isOpen?d.close():d.open()},async sendMessage(e,t){await l.sendMessage(e,t)},reset(){o||(l.resetConversation(),l.emitter.emit(`reset`))},destroy(){o||(o=!0,l.closeEventStream(),u.destroy(),ua(c.host),a&&i?ga(i):ha(s),l.emitter.emit(`destroy`),l.emitter.removeAllListeners())},on(e,t){l.emitter.on(e,t)},off(e,t){l.emitter.off(e,t)},getState(){return l.getState()}};return d}var va=new Map,ya=0;function ba(e){let t=`agentkit-widget-${++ya}`,n=e.destroy.bind(e);return e.destroy=()=>{va.delete(t),n()},va.set(t,e),t}function xa(e,t,n){let r={...e,mode:`floating`},i=_a(ht(r),r,t,n);return ba(i),i}function Sa(e,t,n,r){let i={...t,mode:`inline`},a=_a(ht(i),i,n,r,e);return ba(a),a}function Ca(e){e?va.get(e)?.destroy():(va.forEach(e=>e.destroy()),va.clear())}var wa,U,Ta,Ea,Da,Oa,ka,Aa,ja,Ma,Na,Pa,Fa,Ia,La={},Ra=[],za=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Ba=Array.isArray;function W(e,t){for(var n in t)e[n]=t[n];return e}function Va(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Ha(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?wa.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return Ua(e,o,r,i,null)}function Ua(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Ta,__i:-1,__u:0};return i==null&&U.vnode!=null&&U.vnode(a),a}function G(e){return e.children}function K(e,t){this.props=e,this.context=t}function Wa(e,t){if(t==null)return e.__?Wa(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?Wa(e):null}function Ga(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=W({},t);a.__v=t.__v+1,U.vnode&&U.vnode(a),ro(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??Wa(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,ao(r,a,i),t.__e=t.__=null,a.__e!=n&&Ka(a)}}function Ka(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),Ka(e)}function qa(e){(!e.__d&&(e.__d=!0)&&Ea.push(e)&&!Ja.__r++||Da!=U.debounceRendering)&&((Da=U.debounceRendering)||Oa)(Ja)}function Ja(){try{for(var e,t=1;Ea.length;)Ea.length>t&&Ea.sort(ka),e=Ea.shift(),t=Ea.length,Ga(e)}finally{Ea.length=Ja.__r=0}}function Ya(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,v=r&&r.__k||Ra,y=t.length;for(c=Xa(n,t,v,c,y),d=0;d<y;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&v[p.__i]||La,p.__i=d,g=ro(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&co(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),(_=!!(4&p.__u))||f.__k===p.__k?(c=Za(p,c,e,_),_&&f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function Xa(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=Ua(null,o,null,null,null):Ba(o)?o=e.__k[a]=Ua(G,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=Ua(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=$a(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=Wa(s)),lo(s,s));return r}function Za(e,t,n,r){var i,a;if(typeof e.type==`function`){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=Za(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=Wa(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Qa(e,t){return t||=[],e==null||typeof e==`boolean`||(Ba(e)?e.some(function(e){Qa(e,t)}):t.push(e)),t}function $a(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function eo(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||za.test(t)?n:n+`px`}function to(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||eo(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||eo(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(Na,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[Ma]=r[Ma]:(n[Ma]=Pa,e.addEventListener(t,a?Ia:Fa,a)):e.removeEventListener(t,a?Ia:Fa,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function no(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[ja]==null)t[ja]=Pa++;else if(t[ja]<n[Ma])return;return n(U.event?U.event(t):t)}}}function ro(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),a=[s=t.__e=n.__e]),(u=U.__b)&&u(t);n:if(typeof T==`function`)try{if(_=t.props,v=T.prototype&&T.prototype.render,y=(u=T.contextType)&&r[u.__c],b=u?y?y.props.value:u.__:r,n.__c?g=(d=t.__c=n.__c).__=d.__E:(v?t.__c=d=new T(_,b):(t.__c=d=new K(_,b),d.constructor=T,d.render=uo),y&&y.sub(d),d.state||={},d.__n=r,f=d.__d=!0,d.__h=[],d._sb=[]),v&&d.__s==null&&(d.__s=d.state),v&&T.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=W({},d.__s)),W(d.__s,T.getDerivedStateFromProps(_,d.__s))),p=d.props,m=d.state,d.__v=t,f)v&&T.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),v&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(v&&T.getDerivedStateFromProps==null&&_!==p&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(_,b),t.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&!1===d.shouldComponentUpdate(_,d.__s,b)){t.__v!=n.__v&&(d.props=_,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),Ra.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&o.push(d);break n}d.componentWillUpdate!=null&&d.componentWillUpdate(_,d.__s,b),v&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(p,m,h)})}if(d.context=b,d.props=_,d.__P=e,d.__e=!1,x=U.__r,S=0,v)d.state=d.__s,d.__d=!1,x&&x(t),u=d.render(d.props,d.state,d.context),Ra.push.apply(d.__h,d._sb),d._sb=[];else do d.__d=!1,x&&x(t),u=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++S<25);d.state=d.__s,d.getChildContext!=null&&(r=W(W({},r),d.getChildContext())),v&&!f&&d.getSnapshotBeforeUpdate!=null&&(h=d.getSnapshotBeforeUpdate(p,m)),C=u!=null&&u.type===G&&u.key==null?oo(u.props.children):u,s=Ya(e,Ba(C)?C:[C],t,n,r,i,a,o,s,c,l),d.base=t.__e,t.__u&=-161,d.__h.length&&o.push(d),g&&(d.__E=d.__=null)}catch(e){if(t.__v=null,c||a!=null)if(e.then){for(t.__u|=c?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(w=a.length;w--;)Va(a[w]);io(t)}else t.__e=n.__e,t.__k=n.__k,e.then||io(t);U.__e(e,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=so(n.__e,t,n,r,i,a,o,c,l);return(u=U.diffed)&&u(t),128&t.__u?void 0:s}function io(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(io))}function ao(e,t,n){for(var r=0;r<n.length;r++)co(n[r],n[++r],n[++r]);U.__c&&U.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){U.__e(e,t.__v)}})}function oo(e){return typeof e!=`object`||!e||e.__b>0?e:Ba(e)?e.map(oo):e.constructor===void 0?W({},e):null}function so(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h,g=n.props||La,_=t.props,v=t.type;if(v==`svg`?i=`http://www.w3.org/2000/svg`:v==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(l=0;l<a.length;l++)if((p=a[l])&&`setAttribute`in p==!!v&&(v?p.localName==v:p.nodeType==3)){e=p,a[l]=null;break}}if(e==null){if(v==null)return document.createTextNode(_);e=document.createElementNS(i,v,_.is&&_),s&&=(U.__m&&U.__m(t,a),!1),a=null}if(v==null)g===_||s&&e.data==_||(e.data=_);else{if(a=v==`textarea`&&_.defaultValue!=null?null:a&&wa.call(e.childNodes),!s&&a!=null)for(g={},l=0;l<e.attributes.length;l++)g[(p=e.attributes[l]).name]=p.value;for(l in g)p=g[l],l==`dangerouslySetInnerHTML`?d=p:l==`children`||l in _||l==`value`&&`defaultValue`in _||l==`checked`&&`defaultChecked`in _||to(e,l,null,p,i);for(l in _)p=_[l],l==`children`?f=p:l==`dangerouslySetInnerHTML`?u=p:l==`value`?m=p:l==`checked`?h=p:s&&typeof p!=`function`||g[l]===p||to(e,l,p,g[l],i);if(u)s||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=``),Ya(t.type==`template`?e.content:e,Ba(f)?f:[f],t,n,r,v==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&Wa(n,0),s,c),a!=null)for(l=a.length;l--;)Va(a[l]);s&&v!=`textarea`||(l=`value`,v==`progress`&&m==null?e.removeAttribute(`value`):m!=null&&(m!==e[l]||v==`progress`&&!m||v==`option`&&m!=g[l])&&to(e,l,m,g[l],i),l=`checked`,h!=null&&h!=e[l]&&to(e,l,h,g[l],i))}return e}function co(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){U.__e(e,n)}}function lo(e,t,n){var r,i;if(U.unmount&&U.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||co(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){U.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&lo(r[i],t,n||typeof e.type!=`function`);n||Va(e.__e),e.__c=e.__=e.__e=void 0}function uo(e,t,n){return this.constructor(e,n)}function fo(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),U.__&&U.__(e,t),i=(r=typeof n==`function`)?null:n&&n.__k||t.__k,a=[],o=[],ro(t,e=(!r&&n||t).__k=Ha(G,null,[e]),i||La,La,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?wa.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),ao(a,e,o)}wa=Ra.slice,U={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},Ta=0,K.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=W({},this.state);typeof e==`function`&&(e=e(W({},n),this.props)),e&&W(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),qa(this))},K.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),qa(this))},K.prototype.render=G,Ea=[],Oa=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ka=function(e,t){return e.__v.__b-t.__v.__b},Ja.__r=0,Aa=Math.random().toString(8),ja=`__d`+Aa,Ma=`__a`+Aa,Na=/(PointerCapture)$|Capture$/i,Pa=0,Fa=no(!1),Ia=no(!0);var po,q,mo,ho,go=0,_o=[],J=U,vo=J.__b,yo=J.__r,bo=J.diffed,xo=J.__c,So=J.unmount,Co=J.__;function wo(e,t){J.__h&&J.__h(q,e,go||t),go=0;var n=q.__H||={__:[],__h:[]};return e>=n.__.length&&n.__.push({}),n.__[e]}function Y(e){return go=1,To(Po,e)}function To(e,t,n){var r=wo(po++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Po(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=q,!q.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.some(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a&&a.call(this,e,t,n)||o};q.__f=!0;var a=q.shouldComponentUpdate,o=q.componentWillUpdate;q.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},q.shouldComponentUpdate=i}return r.__N||r.__}function X(e,t){var n=wo(po++,3);!J.__s&&No(n.__H,t)&&(n.__=e,n.u=t,q.__H.__h.push(n))}function Z(e){return go=5,Eo(function(){return{current:e}},[])}function Eo(e,t){var n=wo(po++,7);return No(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Do(e,t){return go=8,Eo(function(){return e},t)}function Oo(){for(var e;e=_o.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(jo),t.__h.some(Mo),t.__h=[]}catch(n){t.__h=[],J.__e(n,e.__v)}}}J.__b=function(e){q=null,vo&&vo(e)},J.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Co&&Co(e,t)},J.__r=function(e){yo&&yo(e),po=0;var t=(q=e.__c).__H;t&&(mo===q?(t.__h=[],q.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(jo),t.__h.some(Mo),t.__h=[],po=0)),mo=q},J.diffed=function(e){bo&&bo(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(_o.push(t)!==1&&ho===J.requestAnimationFrame||((ho=J.requestAnimationFrame)||Ao)(Oo)),t.__H.__.some(function(e){e.u&&(e.__H=e.u),e.u=void 0})),mo=q=null},J.__c=function(e,t){t.some(function(e){try{e.__h.some(jo),e.__h=e.__h.filter(function(e){return!e.__||Mo(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],J.__e(n,e.__v)}}),xo&&xo(e,t)},J.unmount=function(e){So&&So(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{jo(e)}catch(e){t=e}}),n.__H=void 0,t&&J.__e(t,n.__v))};var ko=typeof requestAnimationFrame==`function`;function Ao(e){var t,n=function(){clearTimeout(r),ko&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ko&&(t=requestAnimationFrame(n))}function jo(e){var t=q,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),q=t}function Mo(e){var t=q;e.__c=e.__(),q=t}function No(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Po(e,t){return typeof t==`function`?t(e):t}function Fo(e,t){for(var n in t)e[n]=t[n];return e}function Io(e,t){for(var n in e)if(n!==`__source`&&!(n in t))return!0;for(var r in t)if(r!==`__source`&&e[r]!==t[r])return!0;return!1}function Lo(e,t){this.props=e,this.context=t}(Lo.prototype=new K).isPureReactComponent=!0,Lo.prototype.shouldComponentUpdate=function(e,t){return Io(this.props,e)||Io(this.state,t)};var Ro=U.__b;U.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Ro&&Ro(e)},typeof Symbol<`u`&&Symbol.for;var zo=U.__e;U.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e??(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}zo(e,t,n,r)};var Bo=U.unmount;function Vo(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){typeof e.__c==`function`&&e.__c()}),e.__c.__H=null),(e=Fo({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return Vo(e,t,n)})),e}function Ho(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return Ho(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function Uo(){this.__u=0,this.o=null,this.__b=null}function Wo(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function Go(){this.i=null,this.l=null}U.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Bo&&Bo(e)},(Uo.prototype=new K).__c=function(e,t){var n=t.__c,r=this;r.o??=[],r.o.push(n);var i=Wo(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(c):c())};n.__R=o;var s=n.__P;n.__P=null;var c=function(){if(!--r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=Ho(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.__P=s,t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},Uo.prototype.componentWillUnmount=function(){this.o=[]},Uo.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement(`div`),r=this.__v.__k[0].__c;this.__v.__k[0]=Vo(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&Ha(G,null,e.fallback);return i&&(i.__u&=-33),[Ha(G,null,t.__a?null:e.children),i]};var Ko=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==`t`||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};(Go.prototype=new K).__a=function(e){var t=this,n=Wo(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),Ko(t,e,r)):i()};n?n(a):a()}},Go.prototype.render=function(e){this.i=null,this.l=new Map;var t=Qa(e.children);e.revealOrder&&e.revealOrder[0]===`b`&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},Go.prototype.componentDidUpdate=Go.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Ko(e,n,t)})};var qo=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.element`)||60103,Jo=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Yo=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Xo=/[A-Z0-9]/g,Zo=typeof document<`u`,Qo=function(e){return(typeof Symbol<`u`&&typeof Symbol()==`symbol`?/fil|che|rad/:/fil|che|ra/).test(e)};function $o(e,t,n){return t.__k??(t.textContent=``),fo(e,t),typeof n==`function`&&n(),e?e.__c:null}K.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(K.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var es=U.event;U.event=function(e){return es&&(e=es(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var ts={configurable:!0,get:function(){return this.class}},ns=U.vnode;U.vnode=function(e){typeof e.type==`string`&&function(e){var t=e.props,n=e.type,r={},i=n.indexOf(`-`)==-1;for(var a in t){var o=t[a];if(!(a===`value`&&`defaultValue`in t&&o==null||Zo&&a===`children`&&n===`noscript`||a===`class`||a===`className`)){var s=a.toLowerCase();a===`defaultValue`&&`value`in t&&t.value==null?a=`value`:a===`download`&&!0===o?o=``:s===`translate`&&o===`no`?o=!1:s[0]===`o`&&s[1]===`n`?s===`ondoubleclick`?a=`ondblclick`:s!==`onchange`||n!==`input`&&n!==`textarea`||Qo(t.type)?s===`onfocus`?a=`onfocusin`:s===`onblur`?a=`onfocusout`:Yo.test(a)&&(a=s):s=a=`oninput`:i&&Jo.test(a)?a=a.replace(Xo,`-$&`).toLowerCase():o===null&&(o=void 0),s===`oninput`&&r[a=s]&&(a=`oninputCapture`),r[a]=o}}n==`select`&&(r.multiple&&Array.isArray(r.value)&&(r.value=Qa(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),r.defaultValue!=null&&(r.value=Qa(t.children).forEach(function(e){e.props.selected=r.multiple?r.defaultValue.indexOf(e.props.value)!=-1:r.defaultValue==e.props.value}))),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,"className",ts)):t.className&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=qo,ns&&ns(e)};var rs=U.__r;U.__r=function(e){rs&&rs(e),e.__c};var is=U.diffed;U.diffed=function(e){is&&is(e);var t=e.props,n=e.__e;n!=null&&e.type===`textarea`&&`value`in t&&t.value!==n.value&&(n.value=t.value==null?``:t.value)};function as(e){return!!e.__k&&(fo(null,e),!0)}function os(e){return{render:function(t){$o(t,e)},unmount:function(){as(e)}}}function ss(e){let{theme:t}=e,n=[`--ak-accent: ${t.accentColor}`,`--ak-font: ${t.fontFamily}`,`--ak-radius: ${t.borderRadius}`];return n.push(`--ak-accent-hover: color-mix(in srgb, ${t.accentColor} 85%, black)`),`:host { ${n.join(`; `)} }`}function cs(e){return e===`system`?window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:e}var ls=`
|
|
14
|
+
`);return n===-1?{transcript:t,rest:``}:{transcript:t.slice(0,n),rest:t.slice(n+2)}}function na(){return`msg-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`}var ra=2e3,ia=class{hostConfig;onStateChange;sessionTokenPromise;config;apiClient;state;fingerprint;eventSource=null;emitter;constructor(e,t,n){this.hostConfig=t,this.onStateChange=n,this.config=e,this.apiClient=new Ei(e.apiBaseUrl,{preview:e.preview,configChannel:e.configChannel}),this.emitter=new Wi,this.initializeFingerprint();let r=e.sessionId??qi(e.agentId);e.sessionId&&Ji(e.agentId,e.sessionId);let i=e.mode===`inline`;this.state={isOpen:i,messages:[],isLoading:!1,error:null,sessionId:r,initStatus:`validating`,initError:null},i&&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{let e=await(await Si.load()).get();this.fingerprint=e.visitorId}catch{this.fingerprint=void 0}}getState(){return{...this.state,messages:[...this.state.messages]}}setOpen(e){e?(this.ensureSessionToken(),this.openWithGreeting()):this.setState({isOpen:!1})}openWithGreeting(){this.state.initStatus!==`error`&&this.state.initStatus!==`disabled`&&this.setState({isOpen:!0})}async hydrate(){let 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){let e=await this.apiClient.fetchWidgetConfig(this.config.agentId,this.config.tenantId);e&&(this.config=mt(this.hostConfig,e),this.onStateChange(this.getState(),this.config))}if(this.setState({initStatus:`ready`}),!this.state.sessionId)return;this.openEventStream();let t=await this.apiClient.fetchSessionMessages(this.state.sessionId,this.config.tenantId);if(t===null){this.handleSessionExpired();return}if(t.length===0)return;let n=t.map(e=>{let t=e.direction===`human`,n=e.role===`user`,r=n?(e.media??[]).map(e=>({url:e.url,mimeType:e.mimeType,fileName:e.fileName,kind:e.mimeType.startsWith(`image/`)?`image`:e.mimeType.startsWith(`audio/`)?`audio`:`file`})):void 0;return{id:na(),role:e.role,content:e.content,images:!n&&e.images&&e.images.length>0?e.images:void 0,uploadedAttachments:r&&r.length>0?r:void 0,uploadedImageUrl:e.imageUrl||void 0,createdAt:e.createdAt??(/* @__PURE__ */ new Date()).toISOString(),status:`sent`,...t?{isHuman:!0,senderDisplay:e.senderDisplay??null}:{}}});this.setState({messages:[...this.state.messages,...n]})}openEventStream(){if(typeof EventSource>`u`||!this.state.sessionId||this.eventSource)return;let e=`${this.config.apiBaseUrl.replace(/\/$/,``)}/v1/sessions/${encodeURIComponent(this.state.sessionId)}/events`,t=new EventSource(e);t.onmessage=e=>{try{let t=JSON.parse(e.data);if(t.type===`control_mode`){let e=t.mode;this.setState({controlMode:e}),this.emitter.emit(`control_mode_changed`,{mode:e});return}if(t.type===`execution_state`){let e=t.state;e===`ai_thinking`||e===`ai_streaming`||e===`tool_running`?this.setState({isLoading:!0}):e===`idle`&&this.setState({isLoading:!1});return}if(t.type===`message`&&t.message&&typeof t.message==`object`){let e=t.message;if(typeof e.content!=`string`||e.id&&this.state.messages.some(t=>t.id===e.id))return;if(e.direction===`human`){let t={id:e.id??na(),role:`assistant`,content:e.content,createdAt:e.createdAt??(/* @__PURE__ */ new Date()).toISOString(),status:`sent`,isHuman:!0,senderDisplay:e.senderDisplay??null};this.setState({messages:[...this.state.messages,t],isLoading:!1}),this.emitter.emit(`message:received`,t);return}if(e.direction===`ai`){let t={id:e.id??na(),role:`assistant`,content:e.content,createdAt:e.createdAt??(/* @__PURE__ */ new Date()).toISOString(),status:`sent`};this.setState({messages:[...this.state.messages,t],isLoading:!1}),this.emitter.emit(`message:received`,t);return}}}catch{}},t.onerror=()=>{},this.eventSource=t}closeEventStream(){this.eventSource&&=(this.eventSource.close(),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(n=>n.id===e?{...n,...t}:n)},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{}Yi(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(){Yi(this.config.agentId),this.closeEventStream(),this.setState({sessionId:void 0,controlMode:void 0})}async sendMessage(e,t){let n=!!e.trim()||t&&t.length>0;if(this.state.isLoading||!n||this.state.initStatus!==`ready`)return;let r=[];if(t&&t.length>0)for(let e of t)try{let t=await oa(e.file);if(e.kind===`image`){let n=await this.apiClient.uploadImage(t,e.file.type,e.file.name,this.config.agentId,this.config.tenantId);r.push({url:n.url,mimeType:e.file.type,fileName:e.file.name,kind:`image`})}else if(e.kind===`audio`){let n=await this.apiClient.uploadVoiceNote(t,e.file.type||`audio/webm`,e.file.name,this.config.agentId,this.config.tenantId);r.push({url:n.url,mimeType:e.file.type||`audio/webm`,fileName:e.file.name,durationMs:e.durationMs,kind:`audio`})}else{let n=await this.apiClient.uploadFile(t,e.file.type||`application/octet-stream`,e.file.name,this.config.agentId,this.config.tenantId);r.push({url:n.url,mimeType:e.file.type||`application/octet-stream`,fileName:e.file.name,kind:`file`})}}catch(e){let t=e instanceof Error?e.message:`Attachment upload failed`;this.setState({error:t});return}let i=r.filter(e=>e.kind===`image`),a={id:na(),role:`user`,content:e.trim(),uploadedImageUrl:i[0]?.url,uploadedAttachments:r.length>0?r:void 0,createdAt:(/* @__PURE__ */ new Date()).toISOString(),status:`sent`},o=!this.state.messages.some(e=>e.role===`user`);this.setState({messages:[...this.state.messages,a],isLoading:!0,error:null}),this.emitter.emit(`message:sent`,a),o&&this.emitter.emit(`conversation:started`,{sessionId:this.state.sessionId});let s=r.length>0?r:void 0;this.config.streaming?await this.sendStreaming(e.trim(),void 0,s):await this.sendNonStreaming(e.trim(),void 0,s)}ensureSessionToken(){return!this.config.turnstileSiteKey||this.apiClient.hasValidSessionToken()?Promise.resolve():(this.sessionTokenPromise??=(async()=>{try{let e=await Ui(this.config.apiBaseUrl);await this.apiClient.establishSession(this.config.agentId,this.config.tenantId,e)}catch{}finally{this.sessionTokenPromise=void 0}})(),this.sessionTokenPromise)}async awaitSessionToken(){if(!this.config.turnstileSiteKey||this.apiClient.hasValidSessionToken())return;let e;await Promise.race([this.ensureSessionToken(),new Promise(t=>{e=setTimeout(t,ra)})]).finally(()=>clearTimeout(e))}async sendNonStreaming(e,t,n,r=!1){await this.awaitSessionToken();try{let r=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:n});if(r.queued&&r.controlMode===`human`){this.setState({isLoading:!1,controlMode:`human_takeover`,...r.sessionId?{sessionId:r.sessionId}:{}}),r.sessionId&&(Ji(this.config.agentId,r.sessionId),this.openEventStream());return}let i={id:na(),role:`assistant`,content:r.content,images:r.images,documents:r.documents,createdAt:(/* @__PURE__ */ new Date()).toISOString(),status:`sent`};this.setState({messages:[...this.state.messages,i],isLoading:!1,...r.sessionId?{sessionId:r.sessionId}:{}}),r.sessionId&&(Ji(this.config.agentId,r.sessionId),this.openEventStream()),this.emitter.emit(`message:received`,i)}catch(i){let a=i instanceof Error?i.message:`Failed to send message`;if(!r&&a.includes(`410`))return this.handleSessionExpired(),this.sendNonStreaming(e,t,n,!0);this.setState({isLoading:!1,error:a}),this.emitter.emit(`message:error`,{error:a,message:null}),this.reportError(a)}}async sendStreaming(e,t,n,r=!1){await this.awaitSessionToken();let i=na(),a={id:i,role:`assistant`,content:``,createdAt:(/* @__PURE__ */ new Date()).toISOString(),status:`streaming`};this.setState({messages:[...this.state.messages,a]}),this.emitter.emit(`stream:start`);let o=!1,s=!1,c=null,l=null,u=Date.now(),d=null;await ki(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:n},{onSession:e=>{this.setState({sessionId:e}),Ji(this.config.agentId,e),this.openEventStream()},onRunId:e=>{this.updateMessage(i,{runId:e})},onImages:e=>{this.updateMessage(i,{images:e})},onDocuments:e=>{this.updateMessage(i,{documents:e})},onVoiceTranscript:e=>{let t=[...this.state.messages].reverse().find(e=>e.role===`user`);t&&this.updateMessage(t.id,{content:ea(e,t.content)})},onToolCallsStarted:(e,t)=>{t&&c===null&&(c=t),d=null,this.updateMessage(i,{answerStartedAtMs:null}),(t??c)!==`off`&&this.updateMessage(i,{toolStatus:aa(e)})},onAck:e=>{this.updateMessage(i,{ackText:e})},onProgress:(e,t,n,r)=>{let a=this.state.messages.find(e=>e.id===i)?.progressEvents??[],o=Date.now(),s=r?Date.parse(r):NaN,l=Number.isNaN(s)?void 0:s;n&&c===null&&(c=n,this.updateMessage(i,{turnMeta:{totalMs:null,collapseAfterFinal:null,mode:n}})),this.updateMessage(i,{progressEvents:[...Xi(a,o,l),{stage:e,text:t,timestamp:(/* @__PURE__ */ new Date()).toISOString(),status:`active`,startedAtMs:o,serverTsMs:l}]})},onToolStart:(e,t,n,r,a)=>{let o=this.state.messages.find(e=>e.id===i)?.progressEvents??[],s=Date.now(),l=a?Date.parse(a):NaN,u=Number.isNaN(l)?void 0:l;r&&c===null&&(c=r,this.updateMessage(i,{turnMeta:{totalMs:null,collapseAfterFinal:null,mode:r}})),this.updateMessage(i,{progressEvents:[...Xi(o,s,u),{stage:`calling_tool`,toolId:e,toolName:n,text:t,timestamp:(/* @__PURE__ */ new Date()).toISOString(),status:`active`,startedAtMs:s,serverTsMs:u}]})},onToolComplete:(e,t,n,r)=>{let a=this.state.messages.find(e=>e.id===i)?.progressEvents??[];this.updateMessage(i,{progressEvents:a.map(i=>i.stage===`calling_tool`&&i.status===`active`&&i.toolId===e?{...i,status:`done`,text:t,durationMs:n,ok:r}:i)})},onFinalMeta:(e,t)=>{c=t?.mode??c,l=t?.collapseAfterFinal??null},onDelta:(e,t)=>{e.trim()&&d===null&&(d=Date.now(),this.updateMessage(i,{answerStartedAtMs:d})),t.trim()&&(this.updateMessage(i,{content:t,toolStatus:void 0}),this.emitter.emit(`stream:delta`,{delta:e,accumulated:t}))},onEnd:e=>{if(s){this.setState({messages:this.state.messages.filter(e=>e.id!==i),isLoading:!1,controlMode:`human_takeover`}),this.emitter.emit(`stream:end`,{content:``});return}let t=this.state.messages.find(e=>e.id===i),n=c===`detailed`,r=n||c===`standard`;this.updateMessage(i,{content:e,status:`sent`,toolStatus:void 0,progressEvents:n&&t?.progressEvents?.length?Zi(t.progressEvents):void 0,progressCollapsed:n?l??!0:void 0,turnMeta:r?{totalMs:(d??Date.now())-u,collapseAfterFinal:l,mode:c}:void 0}),this.setState({isLoading:!1}),this.emitter.emit(`stream:end`,{content:e});let a=this.state.messages.find(e=>e.id===i);a&&this.emitter.emit(`message:received`,a)},onControlMode:(e,t)=>{t&&e===`human`&&(s=!0)},onError:e=>{if(!r&&e.status===410){o=!0,this.setState({messages:this.state.messages.filter(e=>e.id!==i),isLoading:!1});return}let t=t=>{let n=this.state.messages.find(e=>e.id===i)?.content??``;this.updateMessage(i,{content:n||t,status:`error`}),this.setState({isLoading:!1,error:t}),this.emitter.emit(`message:error`,{error:t,message:null}),this.reportError(t,{stack:e.stack})},n=e=>{this.updateMessage(i,{content:e,status:`sent`,toolStatus:void 0,progressEvents:void 0}),this.setState({isLoading:!1}),this.emitter.emit(`stream:end`,{content:e});let t=this.state.messages.find(e=>e.id===i);t&&this.emitter.emit(`message:received`,t)},a=this.state.messages.find(e=>e.id===i)?.runId,s=this.state.sessionId;a&&s?Ni(this.config.apiBaseUrl,s,a,{preview:this.config.preview}).then(r=>{r.status===`done`&&r.finalText?n(r.finalText):t(r.errorMessage||e.message||`Something went wrong. Please try again.`)}).catch(()=>t(e.message||`Something went wrong. Please try again.`)):t(e.message||`Something went wrong. Please try again.`)}},{preview:this.config.preview,configChannel:this.config.configChannel,sessionToken:this.apiClient.getSessionToken()}),o&&(this.handleSessionExpired(),await this.sendStreaming(e,t,n,!0))}};function aa(e){let t=e[0];if(!t)return`Working...`;let n=t.indexOf(`.`);return n>0?`Using ${t.slice(0,n).replace(/_/g,` `)}: ${t.slice(n+1).replace(/_/g,` `)}${e.length>1?` +${e.length-1}`:``}`:`Using ${t.replace(/_/g,` `)}`}function oa(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result;t(e.split(`,`)[1]??``)},r.onerror=()=>n(/* @__PURE__ */ Error(`Failed to read file`)),r.readAsDataURL(e)})}function sa(e){let t=document.createElement(`div`);t.setAttribute(`data-agentkit-widget`,``),e.appendChild(t);let n=t.attachShadow({mode:`open`}),r=document.createElement(`style`);n.appendChild(r);let i=document.createElement(`div`);return i.style.cssText=`display: contents;`,n.appendChild(i),{host:t,shadowRoot:n,styleSlot:r,mountPoint:i}}function ca(e,t){e.textContent=t}function la(e){e.remove()}function ua(e){document.body?document.body.appendChild(e):document.addEventListener(`DOMContentLoaded`,()=>document.body.appendChild(e),{once:!0})}function da(){let 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`,ua(e),e}function fa(e){getComputedStyle(e).position===`static`&&(e.style.position=`relative`);let 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`,e.appendChild(t),t}function pa(e){return e.setAttribute(`data-agentkit-root`,`inline`),getComputedStyle(e).position===`static`&&(e.style.position=`relative`),e}function ma(e){e.remove()}function ha(e){e.removeAttribute(`data-agentkit-root`)}function ga(e,t,n,r,i){let a=e.mode===`inline`,o=!1,s=a&&i?pa(i):!a&&i?fa(i):da(),c=sa(s);ca(c.styleSlot,r);let l=new ia(e,t,(e,t)=>{o||u.update(e,t)}),u=n(c.mountPoint,e,l.getState(),{onOpen:()=>d.open(),onClose:()=>d.close(),onSendMessage:(e,t)=>{l.sendMessage(e,t)},onReset:()=>{l.resetConversation()}});l.hydrate(),setTimeout(()=>{o||l.emitter.emit(`ready`,l.getState())},0);let d={open(){o||(l.setOpen(!0),l.emitter.emit(`open`))},close(){o||(l.setOpen(!1),l.emitter.emit(`close`))},toggle(){l.getState().isOpen?d.close():d.open()},async sendMessage(e,t){await l.sendMessage(e,t)},reset(){o||(l.resetConversation(),l.emitter.emit(`reset`))},destroy(){o||(o=!0,l.closeEventStream(),u.destroy(),la(c.host),a&&i?ha(i):ma(s),l.emitter.emit(`destroy`),l.emitter.removeAllListeners())},on(e,t){l.emitter.on(e,t)},off(e,t){l.emitter.off(e,t)},getState(){return l.getState()}};return d}var _a=/* @__PURE__ */ new Map,va=0;function ya(e){let t=`agentkit-widget-${++va}`,n=e.destroy.bind(e);return e.destroy=()=>{_a.delete(t),n()},_a.set(t,e),t}function ba(e,t,n){let r={...e,mode:`floating`},i=ga(mt(r),r,t,n);return ya(i),i}function xa(e,t,n,r){let i={...t,mode:`inline`},a=ga(mt(i),i,n,r,e);return ya(a),a}function Sa(e){e?_a.get(e)?.destroy():(_a.forEach(e=>e.destroy()),_a.clear())}var Ca,W,wa,Ta,Ea,Da,Oa,ka,Aa,ja,Ma,Na,Pa,Fa,Ia={},La=[],Ra=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,za=Array.isArray;function G(e,t){for(var n in t)e[n]=t[n];return e}function Ba(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Va(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?Ca.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return Ha(e,o,r,i,null)}function Ha(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++wa,__i:-1,__u:0};return i==null&&W.vnode!=null&&W.vnode(a),a}function K(e){return e.children}function Ua(e,t){this.props=e,this.context=t}function Wa(e,t){if(t==null)return e.__?Wa(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?Wa(e):null}function Ga(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=G({},t);a.__v=t.__v+1,W.vnode&&W.vnode(a),ro(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??Wa(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,ao(r,a,i),t.__e=t.__=null,a.__e!=n&&Ka(a)}}function Ka(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),Ka(e)}function qa(e){(!e.__d&&(e.__d=!0)&&Ta.push(e)&&!Ja.__r++||Ea!=W.debounceRendering)&&((Ea=W.debounceRendering)||Da)(Ja)}function Ja(){try{for(var e,t=1;Ta.length;)Ta.length>t&&Ta.sort(Oa),e=Ta.shift(),t=Ta.length,Ga(e)}finally{Ta.length=Ja.__r=0}}function Ya(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,v=r&&r.__k||La,y=t.length;for(c=Xa(n,t,v,c,y),d=0;d<y;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&v[p.__i]||Ia,p.__i=d,g=ro(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&co(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),(_=!!(4&p.__u))||f.__k===p.__k?(c=Za(p,c,e,_),_&&f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function Xa(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=Ha(null,o,null,null,null):za(o)?o=e.__k[a]=Ha(K,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=Ha(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=$a(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=Wa(s)),lo(s,s));return r}function Za(e,t,n,r){var i,a;if(typeof e.type==`function`){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=Za(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=Wa(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Qa(e,t){return t||=[],e==null||typeof e==`boolean`||(za(e)?e.some(function(e){Qa(e,t)}):t.push(e)),t}function $a(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function eo(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||Ra.test(t)?n:n+`px`}function to(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||eo(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||eo(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(Ma,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[ja]=r[ja]:(n[ja]=Na,e.addEventListener(t,a?Fa:Pa,a)):e.removeEventListener(t,a?Fa:Pa,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function no(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[Aa]==null)t[Aa]=Na++;else if(t[Aa]<n[ja])return;return n(W.event?W.event(t):t)}}}function ro(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),a=[s=t.__e=n.__e]),(u=W.__b)&&u(t);n:if(typeof E==`function`){d=o.length;try{if(v=t.props,y=E.prototype&&E.prototype.render,b=(u=E.contextType)&&r[u.__c],x=u?b?b.props.value:u.__:r,n.__c?_=(f=t.__c=n.__c).__=f.__E:(y?t.__c=f=new E(v,x):(t.__c=f=new Ua(v,x),f.constructor=E,f.render=uo),b&&b.sub(f),f.state||(f.state={}),f.__n=r,p=f.__d=!0,f.__h=[],f._sb=[]),y&&f.__s==null&&(f.__s=f.state),y&&E.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=G({},f.__s)),G(f.__s,E.getDerivedStateFromProps(v,f.__s))),m=f.props,h=f.state,f.__v=t,p)y&&E.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),y&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(y&&E.getDerivedStateFromProps==null&&v!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(v,x),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(v,f.__s,x)){t.__v!=n.__v&&(f.props=v,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),La.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&o.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(v,f.__s,x),y&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,h,g)})}if(f.context=x,f.props=v,f.__P=e,f.__e=!1,S=W.__r,C=0,y)f.state=f.__s,f.__d=!1,S&&S(t),u=f.render(f.props,f.state,f.context),La.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,S&&S(t),u=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++C<25);f.state=f.__s,f.getChildContext!=null&&(r=G(G({},r),f.getChildContext())),y&&!p&&f.getSnapshotBeforeUpdate!=null&&(g=f.getSnapshotBeforeUpdate(m,h)),w=u!=null&&u.type===K&&u.key==null?oo(u.props.children):u,s=Ya(e,za(w)?w:[w],t,n,r,i,a,o,s,c,l),f.base=t.__e,t.__u&=-161,f.__h.length&&o.push(f),_&&(f.__E=f.__=null)}catch(e){if(o.length=d,t.__v=null,c||a!=null){if(e.then){for(t.__u|=c?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a!=null&&(a[a.indexOf(s)]=null),t.__e=s}else if(a!=null)for(T=a.length;T--;)Ba(a[T])}else t.__e=n.__e;t.__k??=n.__k||[],e.then||io(t),W.__e(e,t,n)}}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=so(n.__e,t,n,r,i,a,o,c,l);return(u=W.diffed)&&u(t),128&t.__u?void 0:s}function io(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(io))}function ao(e,t,n){for(var r=0;r<n.length;r++)co(n[r],n[++r],n[++r]);W.__c&&W.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){W.__e(e,t.__v)}})}function oo(e){return typeof e!=`object`||!e||e.__b>0?e:za(e)?e.map(oo):e.constructor===void 0?G({},e):null}function so(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h,g=n.props||Ia,_=t.props,v=t.type;if(v==`svg`?i=`http://www.w3.org/2000/svg`:v==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(l=0;l<a.length;l++)if((p=a[l])&&`setAttribute`in p==!!v&&(v?p.localName==v:p.nodeType==3)){e=p,a[l]=null;break}}if(e==null){if(v==null)return document.createTextNode(_);e=document.createElementNS(i,v,_.is&&_),s&&=(W.__m&&W.__m(t,a),!1),a=null}if(v==null)g===_||s&&e.data==_||(e.data=_);else{if(a=v==`textarea`&&_.defaultValue!=null?null:a&&Ca.call(e.childNodes),!s&&a!=null)for(g={},l=0;l<e.attributes.length;l++)g[(p=e.attributes[l]).name]=p.value;for(l in g)p=g[l],l==`dangerouslySetInnerHTML`?d=p:l==`children`||l in _||l==`value`&&`defaultValue`in _||l==`checked`&&`defaultChecked`in _||to(e,l,null,p,i);for(l in _)p=_[l],l==`children`?f=p:l==`dangerouslySetInnerHTML`?u=p:l==`value`?m=p:l==`checked`?h=p:s&&typeof p!=`function`||g[l]===p||to(e,l,p,g[l],i);if(u)s||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=``),Ya(t.type==`template`?e.content:e,za(f)?f:[f],t,n,r,v==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&Wa(n,0),s,c),a!=null)for(l=a.length;l--;)Ba(a[l]);s&&v!=`textarea`||(l=`value`,v==`progress`&&m==null?e.removeAttribute(`value`):m!=null&&(m!==e[l]||v==`progress`&&!m||v==`option`&&m!=g[l])&&to(e,l,m,g[l],i),l=`checked`,h!=null&&h!=e[l]&&to(e,l,h,g[l],i))}return e}function co(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){W.__e(e,n)}}function lo(e,t,n){var r,i;if(W.unmount&&W.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||co(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){W.__e(e,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&lo(r[i],t,n||typeof e.type!=`function`);n||Ba(e.__e),e.__c=e.__=e.__e=void 0}function uo(e,t,n){return this.constructor(e,n)}function fo(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),W.__&&W.__(e,t),i=(r=typeof n==`function`)?null:n&&n.__k||t.__k,a=[],o=[],ro(t,e=(!r&&n||t).__k=Va(K,null,[e]),i||Ia,Ia,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Ca.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),ao(a,e,o),e.props.children=null}Ca=La.slice,W={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},wa=0,Ua.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=G({},this.state);typeof e==`function`&&(e=e(G({},n),this.props)),e&&G(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),qa(this))},Ua.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),qa(this))},Ua.prototype.render=K,Ta=[],Da=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Oa=function(e,t){return e.__v.__b-t.__v.__b},Ja.__r=0,ka=Math.random().toString(8),Aa=`__d`+ka,ja=`__a`+ka,Ma=/(PointerCapture)$|Capture$/i,Na=0,Pa=no(!1),Fa=no(!0);var po,q,mo,ho,go=0,_o=[],J=W,vo=J.__b,yo=J.__r,bo=J.diffed,xo=J.__c,So=J.unmount,Co=J.__;function wo(e,t){J.__h&&J.__h(q,e,go||t),go=0;var n=q.__H||(q.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Y(e){return go=1,To(Po,e)}function To(e,t,n){var r=wo(po++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Po(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=q,!q.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};q.__f=!0;var a=q.shouldComponentUpdate,o=q.componentWillUpdate;q.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},q.shouldComponentUpdate=i}return r.__N||r.__}function X(e,t){var n=wo(po++,3);!J.__s&&No(n.__H,t)&&(n.__=e,n.u=t,q.__H.__h.push(n))}function Z(e){return go=5,Eo(function(){return{current:e}},[])}function Eo(e,t){var n=wo(po++,7);return No(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Do(e,t){return go=8,Eo(function(){return e},t)}function Oo(){for(var e;e=_o.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(jo),t.__h.some(Mo),t.__h=[]}catch(n){t.__h=[],J.__e(n,e.__v)}}}J.__b=function(e){q=null,vo&&vo(e)},J.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Co&&Co(e,t)},J.__r=function(e){yo&&yo(e),po=0;var t=(q=e.__c).__H;t&&(mo===q?(t.__h=[],q.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(jo),t.__h.some(Mo),t.__h=[],po=0)),mo=q},J.diffed=function(e){bo&&bo(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(_o.push(t)!==1&&ho===J.requestAnimationFrame||((ho=J.requestAnimationFrame)||Ao)(Oo)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),mo=q=null},J.__c=function(e,t){t.some(function(e){try{e.__h.some(jo),e.__h=e.__h.filter(function(e){return!e.__||Mo(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],J.__e(n,e.__v)}}),xo&&xo(e,t)},J.unmount=function(e){So&&So(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{jo(e)}catch(e){t=e}}),n.__H=void 0,t&&J.__e(t,n.__v))};var ko=typeof requestAnimationFrame==`function`;function Ao(e){var t,n=function(){clearTimeout(r),ko&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ko&&(t=requestAnimationFrame(n))}function jo(e){var t=q,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),q=t}function Mo(e){var t=q;e.__c=e.__(),q=t}function No(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Po(e,t){return typeof t==`function`?t(e):t}function Fo(e,t){for(var n in t)e[n]=t[n];return e}function Io(e,t){for(var n in e)if(n!==`__source`&&!(n in t))return!0;for(var r in t)if(r!==`__source`&&e[r]!==t[r])return!0;return!1}function Lo(e,t){this.props=e,this.context=t}(Lo.prototype=new Ua).isPureReactComponent=!0,Lo.prototype.shouldComponentUpdate=function(e,t){return Io(this.props,e)||Io(this.state,t)};var Ro=W.__b;W.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Ro&&Ro(e)},typeof Symbol<`u`&&Symbol.for;var zo=W.__e;W.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e??(t.__e=n.__e,t.__k=n.__k||[]),i.__c(e,t)}zo(e,t,n,r)};var Bo=W.unmount;function Vo(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){typeof e.__c==`function`&&e.__c()}),e.__c.__H=null),(e=Fo({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return Vo(e,t,n)})),e}function Ho(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return Ho(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function Uo(){this.__u=0,this.o=null,this.__b=null}function Wo(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function Go(){this.i=null,this.l=null}W.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Bo&&Bo(e)},(Uo.prototype=new Ua).__c=function(e,t){var n=t.__c,r=this;r.o??=[],r.o.push(n);var i=Wo(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(c):c())};n.__R=o;var s=n.__P;n.__P=null;var c=function(){if(!--r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=Ho(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.__P=s,t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},Uo.prototype.componentWillUnmount=function(){this.o=[]},Uo.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement(`div`),r=this.__v.__k[0].__c;this.__v.__k[0]=Vo(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&Va(K,null,e.fallback);return i&&(i.__u&=-33),[Va(K,null,t.__a?null:e.children),i]};var Ko=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==`t`||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};(Go.prototype=new Ua).__a=function(e){var t=this,n=Wo(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),Ko(t,e,r)):i()};n?n(a):a()}},Go.prototype.render=function(e){this.i=null,this.l=/* @__PURE__ */ new Map;var t=Qa(e.children);e.revealOrder&&e.revealOrder[0]===`b`&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},Go.prototype.componentDidUpdate=Go.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Ko(e,n,t)})};var qo=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.element`)||60103,Jo=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Yo=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Xo=/[A-Z0-9]/g,Zo=typeof document<`u`,Qo=function(e){return(typeof Symbol<`u`&&typeof Symbol()==`symbol`?/fil|che|rad/:/fil|che|ra/).test(e)};function $o(e,t,n){return t.__k??(t.textContent=``),fo(e,t),typeof n==`function`&&n(),e?e.__c:null}Ua.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(Ua.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var es=W.event;W.event=function(e){return es&&(e=es(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var ts={configurable:!0,get:function(){return this.class}},ns=W.vnode;W.vnode=function(e){typeof e.type==`string`&&function(e){var t=e.props,n=e.type,r={},i=n.indexOf(`-`)==-1;for(var a in t){var o=t[a];if(!(a===`value`&&`defaultValue`in t&&o==null||Zo&&a===`children`&&n===`noscript`||a===`class`||a===`className`)){var s=a.toLowerCase();a===`defaultValue`&&`value`in t&&t.value==null?a=`value`:a===`download`&&!0===o?o=``:s===`translate`&&o===`no`?o=!1:s[0]===`o`&&s[1]===`n`?s===`ondoubleclick`?a=`ondblclick`:s!==`onchange`||n!==`input`&&n!==`textarea`||Qo(t.type)?s===`onfocus`?a=`onfocusin`:s===`onblur`?a=`onfocusout`:Yo.test(a)&&(a=s):s=a=`oninput`:i&&Jo.test(a)?a=a.replace(Xo,`-$&`).toLowerCase():o===null&&(o=void 0),s===`oninput`&&r[a=s]&&(a=`oninputCapture`),r[a]=o}}n==`select`&&(r.multiple&&Array.isArray(r.value)&&(r.value=Qa(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),r.defaultValue!=null&&(r.value=Qa(t.children).forEach(function(e){e.props.selected=r.multiple?r.defaultValue.indexOf(e.props.value)!=-1:r.defaultValue==e.props.value}))),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,"className",ts)):t.className&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=qo,ns&&ns(e)};var rs=W.__r;W.__r=function(e){rs&&rs(e),e.__c};var is=W.diffed;W.diffed=function(e){is&&is(e);var t=e.props,n=e.__e;n!=null&&e.type===`textarea`&&`value`in t&&t.value!==n.value&&(n.value=t.value==null?``:t.value)};function as(e){return!!e.__k&&(fo(null,e),!0)}function os(e){return{render:function(t){$o(t,e)},unmount:function(){as(e)}}}function ss(e){let{theme:t}=e,n=[`--ak-accent: ${t.accentColor}`,`--ak-font: ${t.fontFamily}`,`--ak-radius: ${t.borderRadius}`];return n.push(`--ak-accent-hover: color-mix(in srgb, ${t.accentColor} 85%, black)`),`:host { ${n.join(`; `)} }`}function cs(e){return e===`system`?window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:e}var ls=`
|
|
15
15
|
*, *::before, *::after {
|
|
16
16
|
box-sizing: border-box;
|
|
17
17
|
margin: 0;
|
|
@@ -19,20 +19,33 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
:host {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
--ak-
|
|
26
|
-
--ak-
|
|
27
|
-
--ak-
|
|
28
|
-
--ak-
|
|
22
|
+
/* Neutral and status defaults are copied from packages/design-tokens/tokens.css (light
|
|
23
|
+
:root / dark .dark) — the widget is CDN-bundled, so they stay literals here.
|
|
24
|
+
__tests__/design-token-parity.test.ts fails when the two drift. */
|
|
25
|
+
--ak-accent: #4f46e5; /* --primary (white text 6.3:1) */
|
|
26
|
+
--ak-accent-hover: #4338ca; /* --primary-hover */
|
|
27
|
+
--ak-bg: #ffffff; /* --surface */
|
|
28
|
+
--ak-surface: #f7f8fa; /* --bg */
|
|
29
|
+
--ak-text: #0e1220; /* --fg */
|
|
30
|
+
--ak-text-muted: #525c70; /* --fg-muted */
|
|
31
|
+
--ak-border: #e3e6ec; /* --border */
|
|
32
|
+
--ak-border-strong: #818a9d; /* --border-strong */
|
|
33
|
+
--ak-hover: rgb(14 18 32 / 0.04); /* --hover */
|
|
29
34
|
--ak-user-bg: var(--ak-accent);
|
|
30
35
|
--ak-user-text: #ffffff;
|
|
31
|
-
--ak-bot-bg: #
|
|
32
|
-
--ak-bot-text: #
|
|
33
|
-
--ak-
|
|
34
|
-
--ak-
|
|
35
|
-
--ak-
|
|
36
|
+
--ak-bot-bg: #eef0f4; /* --surface-muted */
|
|
37
|
+
--ak-bot-text: #0e1220; /* --fg */
|
|
38
|
+
--ak-success: #0a9466; /* --success */
|
|
39
|
+
--ak-warning: #d98a0b; /* --warning */
|
|
40
|
+
--ak-warning-fg: #8a4b06; /* --warning-fg */
|
|
41
|
+
--ak-warning-soft: #fdf3e2; /* --warning-soft */
|
|
42
|
+
--ak-danger: #c4302b; /* --danger */
|
|
43
|
+
--ak-danger-fg: #b4232b; /* --danger-fg */
|
|
44
|
+
--ak-danger-soft: #fdeced; /* --danger-soft */
|
|
45
|
+
--ak-danger-border: color-mix(in srgb, var(--ak-danger) 35%, transparent);
|
|
46
|
+
--ak-maintenance-fg: var(--ak-warning-fg);
|
|
47
|
+
--ak-maintenance-bg: var(--ak-warning-soft);
|
|
48
|
+
--ak-maintenance-halo: var(--ak-warning);
|
|
36
49
|
--ak-font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
37
50
|
--ak-radius: 12px;
|
|
38
51
|
/* Chat surface texture — scattered line doodles, tiled. Neutral stroke (not accent-tinted)
|
|
@@ -50,21 +63,27 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
50
63
|
}
|
|
51
64
|
|
|
52
65
|
/* Dark mode — set data-theme="dark" on the shadow host element.
|
|
53
|
-
|
|
66
|
+
Values from tokens.css .dark (see the :host note above). */
|
|
54
67
|
:host([data-theme="dark"]) {
|
|
55
|
-
--ak-bg: #
|
|
56
|
-
--ak-surface: #
|
|
57
|
-
--ak-text: #
|
|
58
|
-
--ak-text-muted: #
|
|
59
|
-
--ak-border: #
|
|
60
|
-
--ak-
|
|
61
|
-
--ak-
|
|
68
|
+
--ak-bg: #111521; /* --surface — panel */
|
|
69
|
+
--ak-surface: #171c2a; /* --surface-raised — inputs, insets lift off the panel */
|
|
70
|
+
--ak-text: #eef0f6; /* --fg */
|
|
71
|
+
--ak-text-muted: #a3acbd; /* --fg-muted */
|
|
72
|
+
--ak-border: #232a3a; /* --border */
|
|
73
|
+
--ak-border-strong: #5f687c; /* --border-strong */
|
|
74
|
+
--ak-hover: rgb(255 255 255 / 0.05); /* --hover */
|
|
75
|
+
--ak-bot-bg: #20263a; /* --surface-muted — assistant bubble */
|
|
76
|
+
--ak-bot-text: #eef0f6; /* --fg */
|
|
77
|
+
--ak-success: #2fbf87;
|
|
78
|
+
--ak-warning: #e5a43a;
|
|
79
|
+
--ak-warning-fg: #f2bd5c;
|
|
80
|
+
--ak-warning-soft: #2c2110;
|
|
81
|
+
--ak-danger: #d93a3f;
|
|
82
|
+
--ak-danger-fg: #ff8a8f;
|
|
83
|
+
--ak-danger-soft: #331417;
|
|
62
84
|
/* Same doodle tile, white stroke — dark surfaces need ~1.5x the alpha to read the same */
|
|
63
85
|
--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");
|
|
64
86
|
--ak-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.4);
|
|
65
|
-
--ak-maintenance-fg: #fde68a;
|
|
66
|
-
--ak-maintenance-bg: rgba(253, 230, 138, 0.06);
|
|
67
|
-
--ak-maintenance-halo: #f59e0b;
|
|
68
87
|
}
|
|
69
88
|
|
|
70
89
|
/* ── Floating layout ─────────────────────────────────────────── */
|
|
@@ -102,14 +121,14 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
102
121
|
align-items: center;
|
|
103
122
|
justify-content: center;
|
|
104
123
|
color: white;
|
|
105
|
-
box-shadow: 0 4px 16px
|
|
124
|
+
box-shadow: 0 4px 16px color-mix(in srgb, var(--ak-accent) 45%, transparent);
|
|
106
125
|
transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
|
|
107
126
|
flex-shrink: 0;
|
|
108
127
|
}
|
|
109
128
|
.ak-launcher:hover {
|
|
110
129
|
background: var(--ak-accent-hover);
|
|
111
130
|
transform: scale(1.08);
|
|
112
|
-
box-shadow: 0 6px 24px
|
|
131
|
+
box-shadow: 0 6px 24px color-mix(in srgb, var(--ak-accent) 55%, transparent);
|
|
113
132
|
}
|
|
114
133
|
.ak-launcher:active {
|
|
115
134
|
transform: scale(0.95);
|
|
@@ -211,6 +230,7 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
211
230
|
width: 8px;
|
|
212
231
|
height: 8px;
|
|
213
232
|
border-radius: 50%;
|
|
233
|
+
/* Not --ak-success: this dot sits on the accent fill, where the token green is too dark. */
|
|
214
234
|
background: #4ade80;
|
|
215
235
|
flex-shrink: 0;
|
|
216
236
|
}
|
|
@@ -564,9 +584,9 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
564
584
|
border: 1px solid var(--ak-border);
|
|
565
585
|
}
|
|
566
586
|
.ak-message--error .ak-message__bubble {
|
|
567
|
-
background:
|
|
568
|
-
color:
|
|
569
|
-
border-color:
|
|
587
|
+
background: var(--ak-danger-soft);
|
|
588
|
+
color: var(--ak-danger-fg);
|
|
589
|
+
border-color: var(--ak-danger-border);
|
|
570
590
|
}
|
|
571
591
|
.ak-message--operator .ak-message__bubble--operator {
|
|
572
592
|
background: color-mix(in srgb, var(--ak-accent) 8%, var(--ak-bot-bg));
|
|
@@ -698,7 +718,7 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
698
718
|
.ak-gallery {
|
|
699
719
|
position: relative;
|
|
700
720
|
width: 100%;
|
|
701
|
-
background:
|
|
721
|
+
background: var(--ak-bg);
|
|
702
722
|
overflow: hidden;
|
|
703
723
|
}
|
|
704
724
|
|
|
@@ -709,13 +729,13 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
709
729
|
}
|
|
710
730
|
.ak-gallery--single .ak-gallery__cell--hero {
|
|
711
731
|
display: block;
|
|
712
|
-
background:
|
|
732
|
+
background: var(--ak-bg);
|
|
713
733
|
}
|
|
714
734
|
.ak-gallery__img--contain {
|
|
715
735
|
width: 100%;
|
|
716
736
|
max-height: 320px;
|
|
717
737
|
object-fit: contain;
|
|
718
|
-
background:
|
|
738
|
+
background: var(--ak-bg);
|
|
719
739
|
display: block;
|
|
720
740
|
}
|
|
721
741
|
|
|
@@ -724,7 +744,7 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
724
744
|
display: grid;
|
|
725
745
|
grid-template-columns: 1fr 1fr;
|
|
726
746
|
gap: 2px;
|
|
727
|
-
background:
|
|
747
|
+
background: var(--ak-border);
|
|
728
748
|
}
|
|
729
749
|
|
|
730
750
|
/* 3-up: big left + 2 stacked right; container holds aspect */
|
|
@@ -732,7 +752,7 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
732
752
|
display: grid;
|
|
733
753
|
grid-template-columns: 2fr 1fr;
|
|
734
754
|
gap: 2px;
|
|
735
|
-
background:
|
|
755
|
+
background: var(--ak-border);
|
|
736
756
|
aspect-ratio: 4 / 3;
|
|
737
757
|
}
|
|
738
758
|
.ak-gallery--three > .ak-gallery__cell {
|
|
@@ -750,14 +770,14 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
750
770
|
display: grid;
|
|
751
771
|
grid-template-columns: 1fr 1fr;
|
|
752
772
|
gap: 2px;
|
|
753
|
-
background:
|
|
773
|
+
background: var(--ak-border);
|
|
754
774
|
}
|
|
755
775
|
|
|
756
776
|
.ak-gallery__cell {
|
|
757
777
|
position: relative;
|
|
758
778
|
display: block;
|
|
759
779
|
overflow: hidden;
|
|
760
|
-
background:
|
|
780
|
+
background: var(--ak-surface);
|
|
761
781
|
aspect-ratio: 1 / 1;
|
|
762
782
|
line-height: 0;
|
|
763
783
|
text-decoration: none;
|
|
@@ -784,7 +804,7 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
784
804
|
}
|
|
785
805
|
|
|
786
806
|
.ak-gallery__cell:focus-visible {
|
|
787
|
-
outline: 2px solid var(--ak-
|
|
807
|
+
outline: 2px solid var(--ak-accent);
|
|
788
808
|
outline-offset: -2px;
|
|
789
809
|
}
|
|
790
810
|
|
|
@@ -819,21 +839,21 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
819
839
|
gap: 10px;
|
|
820
840
|
padding: 8px 10px;
|
|
821
841
|
background: var(--ak-surface);
|
|
822
|
-
border: 1px solid var(--ak-border
|
|
842
|
+
border: 1px solid var(--ak-border);
|
|
823
843
|
border-radius: 12px;
|
|
824
844
|
text-decoration: none;
|
|
825
|
-
color: var(--ak-text
|
|
845
|
+
color: var(--ak-text);
|
|
826
846
|
transition: border-color 0.15s, box-shadow 0.15s;
|
|
827
847
|
max-width: 100%;
|
|
828
848
|
}
|
|
829
849
|
|
|
830
850
|
.ak-file-chip:hover {
|
|
831
|
-
border-color:
|
|
851
|
+
border-color: var(--ak-border-strong);
|
|
832
852
|
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
|
|
833
853
|
}
|
|
834
854
|
|
|
835
855
|
.ak-file-chip:focus-visible {
|
|
836
|
-
outline: 2px solid var(--ak-
|
|
856
|
+
outline: 2px solid var(--ak-accent);
|
|
837
857
|
outline-offset: 2px;
|
|
838
858
|
}
|
|
839
859
|
|
|
@@ -863,7 +883,7 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
863
883
|
.ak-file-chip__name {
|
|
864
884
|
font-size: 13px;
|
|
865
885
|
font-weight: 500;
|
|
866
|
-
color: var(--ak-text
|
|
886
|
+
color: var(--ak-text);
|
|
867
887
|
white-space: nowrap;
|
|
868
888
|
overflow: hidden;
|
|
869
889
|
text-overflow: ellipsis;
|
|
@@ -874,7 +894,7 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
874
894
|
font-size: 10px;
|
|
875
895
|
font-weight: 600;
|
|
876
896
|
letter-spacing: 0.05em;
|
|
877
|
-
color:
|
|
897
|
+
color: var(--ak-text-muted);
|
|
878
898
|
margin-top: 2px;
|
|
879
899
|
}
|
|
880
900
|
|
|
@@ -891,7 +911,7 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
891
911
|
gap: 6px;
|
|
892
912
|
padding: 8px 10px;
|
|
893
913
|
background: var(--ak-surface);
|
|
894
|
-
border: 1px solid var(--ak-border
|
|
914
|
+
border: 1px solid var(--ak-border);
|
|
895
915
|
border-radius: 12px;
|
|
896
916
|
max-width: 100%;
|
|
897
917
|
}
|
|
@@ -1028,11 +1048,11 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
1028
1048
|
cursor: zoom-in;
|
|
1029
1049
|
font: inherit;
|
|
1030
1050
|
color: inherit;
|
|
1031
|
-
background:
|
|
1051
|
+
background: var(--ak-surface);
|
|
1032
1052
|
}
|
|
1033
1053
|
|
|
1034
1054
|
.ak-gallery__cell:focus-visible {
|
|
1035
|
-
outline: 2px solid var(--ak-
|
|
1055
|
+
outline: 2px solid var(--ak-accent);
|
|
1036
1056
|
outline-offset: -2px;
|
|
1037
1057
|
}
|
|
1038
1058
|
|
|
@@ -1145,54 +1165,78 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
1145
1165
|
display: none;
|
|
1146
1166
|
}
|
|
1147
1167
|
|
|
1148
|
-
/*
|
|
1168
|
+
/* Composer card — the dashboard ChatComposer layout: the message row (text, mic at its
|
|
1169
|
+
right edge) over a divider and a toolbar (+ … send), both on the same side padding.
|
|
1170
|
+
The + and mic glyphs (20px in a 32px box) are pulled flush with the text edges. */
|
|
1149
1171
|
.ak-composer__input-wrap {
|
|
1150
1172
|
display: flex;
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
border:
|
|
1155
|
-
|
|
1156
|
-
padding: 5px 5px 5px 6px;
|
|
1173
|
+
flex-direction: column;
|
|
1174
|
+
background: var(--ak-bg);
|
|
1175
|
+
border: 1px solid color-mix(in srgb, var(--ak-border-strong) 40%, transparent);
|
|
1176
|
+
border-radius: 16px;
|
|
1177
|
+
box-shadow: 0 1px 3px rgba(14, 18, 32, 0.06), 0 1px 2px rgba(14, 18, 32, 0.04);
|
|
1157
1178
|
transition: border-color 0.15s;
|
|
1158
1179
|
}
|
|
1159
1180
|
.ak-composer__input-wrap:focus-within {
|
|
1160
1181
|
border-color: var(--ak-accent);
|
|
1161
1182
|
}
|
|
1183
|
+
.ak-composer__row {
|
|
1184
|
+
display: flex;
|
|
1185
|
+
align-items: flex-start;
|
|
1186
|
+
gap: 8px;
|
|
1187
|
+
padding: 10px 12px 8px;
|
|
1188
|
+
}
|
|
1189
|
+
.ak-composer__toolbar {
|
|
1190
|
+
display: flex;
|
|
1191
|
+
align-items: center;
|
|
1192
|
+
gap: 6px;
|
|
1193
|
+
padding: 8px 12px;
|
|
1194
|
+
border-top: 1px solid var(--ak-border);
|
|
1195
|
+
}
|
|
1162
1196
|
|
|
1163
1197
|
/* Attach button wrapper */
|
|
1164
1198
|
.ak-composer__attach-wrap {
|
|
1165
1199
|
flex-shrink: 0;
|
|
1200
|
+
margin-left: -6px;
|
|
1166
1201
|
}
|
|
1167
1202
|
|
|
1168
|
-
/* "+"
|
|
1169
|
-
.ak-composer__attach
|
|
1170
|
-
|
|
1171
|
-
|
|
1203
|
+
/* Icon controls ("+" and mic): borderless, a hover fill rather than an outline */
|
|
1204
|
+
.ak-composer__attach,
|
|
1205
|
+
.ak-composer__mic {
|
|
1206
|
+
width: 32px;
|
|
1207
|
+
height: 32px;
|
|
1172
1208
|
border-radius: 8px;
|
|
1173
|
-
background:
|
|
1174
|
-
border:
|
|
1209
|
+
background: transparent;
|
|
1210
|
+
border: none;
|
|
1175
1211
|
cursor: pointer;
|
|
1176
1212
|
display: flex;
|
|
1177
1213
|
align-items: center;
|
|
1178
1214
|
justify-content: center;
|
|
1179
1215
|
color: var(--ak-text-muted);
|
|
1180
|
-
transition: color 0.15s,
|
|
1216
|
+
transition: color 0.15s, background 0.15s;
|
|
1181
1217
|
flex-shrink: 0;
|
|
1182
1218
|
}
|
|
1183
|
-
.ak-composer__attach:hover:not(:disabled)
|
|
1184
|
-
|
|
1185
|
-
border-color: var(--ak-accent);
|
|
1186
|
-
}
|
|
1219
|
+
.ak-composer__attach:hover:not(:disabled),
|
|
1220
|
+
.ak-composer__mic:hover:not(:disabled),
|
|
1187
1221
|
.ak-composer__attach--open {
|
|
1188
|
-
color: var(--ak-
|
|
1189
|
-
|
|
1190
|
-
|
|
1222
|
+
color: var(--ak-text);
|
|
1223
|
+
background: var(--ak-hover);
|
|
1224
|
+
}
|
|
1225
|
+
.ak-composer__attach:focus-visible,
|
|
1226
|
+
.ak-composer__mic:focus-visible,
|
|
1227
|
+
.ak-composer__send:focus-visible {
|
|
1228
|
+
outline: 2px solid var(--ak-accent);
|
|
1229
|
+
outline-offset: 2px;
|
|
1191
1230
|
}
|
|
1192
|
-
.ak-composer__attach:disabled
|
|
1231
|
+
.ak-composer__attach:disabled,
|
|
1232
|
+
.ak-composer__mic:disabled {
|
|
1193
1233
|
opacity: 0.4;
|
|
1194
1234
|
cursor: not-allowed;
|
|
1195
1235
|
}
|
|
1236
|
+
/* Flush right, and -4px vertically so the 32px box doesn't grow the 24px text row */
|
|
1237
|
+
.ak-composer__mic {
|
|
1238
|
+
margin: -4px -6px -4px 0;
|
|
1239
|
+
}
|
|
1196
1240
|
|
|
1197
1241
|
/* Attachment submenu — floats above the composer, positioned relative to .ak-composer */
|
|
1198
1242
|
.ak-composer__attach-menu {
|
|
@@ -1233,20 +1277,20 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
1233
1277
|
cursor: not-allowed;
|
|
1234
1278
|
}
|
|
1235
1279
|
|
|
1236
|
-
/* Textarea — borderless, transparent,
|
|
1280
|
+
/* Textarea — borderless, transparent, fills the message row */
|
|
1237
1281
|
.ak-composer__input {
|
|
1238
1282
|
flex: 1;
|
|
1239
|
-
padding:
|
|
1283
|
+
padding: 0;
|
|
1240
1284
|
border: none;
|
|
1241
1285
|
border-radius: 0;
|
|
1242
1286
|
background: transparent;
|
|
1243
1287
|
color: var(--ak-text);
|
|
1244
1288
|
font-family: var(--ak-font);
|
|
1245
1289
|
font-size: 16px; /* iOS zooms the page when a focused input is under 16px */
|
|
1246
|
-
line-height: 1.
|
|
1290
|
+
line-height: 1.5;
|
|
1247
1291
|
resize: none;
|
|
1248
1292
|
outline: none;
|
|
1249
|
-
min-height:
|
|
1293
|
+
min-height: 24px;
|
|
1250
1294
|
max-height: 110px;
|
|
1251
1295
|
overflow-y: auto;
|
|
1252
1296
|
}
|
|
@@ -1254,37 +1298,13 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
1254
1298
|
color: var(--ak-text-muted);
|
|
1255
1299
|
}
|
|
1256
1300
|
|
|
1257
|
-
/* Mic button — square with rounded corners, sibling of the "+" attach button */
|
|
1258
|
-
.ak-composer__mic {
|
|
1259
|
-
width: 28px;
|
|
1260
|
-
height: 28px;
|
|
1261
|
-
border-radius: 8px;
|
|
1262
|
-
background: var(--ak-bg);
|
|
1263
|
-
border: 1px solid var(--ak-border);
|
|
1264
|
-
cursor: pointer;
|
|
1265
|
-
display: flex;
|
|
1266
|
-
align-items: center;
|
|
1267
|
-
justify-content: center;
|
|
1268
|
-
color: var(--ak-text-muted);
|
|
1269
|
-
transition: color 0.15s, border-color 0.15s, background 0.15s;
|
|
1270
|
-
flex-shrink: 0;
|
|
1271
|
-
}
|
|
1272
|
-
.ak-composer__mic:hover:not(:disabled) {
|
|
1273
|
-
color: var(--ak-accent);
|
|
1274
|
-
border-color: var(--ak-accent);
|
|
1275
|
-
}
|
|
1276
|
-
.ak-composer__mic:disabled {
|
|
1277
|
-
opacity: 0.4;
|
|
1278
|
-
cursor: not-allowed;
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
1301
|
/* Recording bar — replaces the input row while a voice note is being recorded */
|
|
1282
1302
|
.ak-composer__recording {
|
|
1283
1303
|
display: flex;
|
|
1284
1304
|
align-items: center;
|
|
1285
1305
|
gap: 10px;
|
|
1286
1306
|
flex: 1;
|
|
1287
|
-
padding:
|
|
1307
|
+
padding: 8px 12px;
|
|
1288
1308
|
}
|
|
1289
1309
|
.ak-composer__recording-timer {
|
|
1290
1310
|
display: flex;
|
|
@@ -1300,7 +1320,7 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
1300
1320
|
width: 8px;
|
|
1301
1321
|
height: 8px;
|
|
1302
1322
|
border-radius: 50%;
|
|
1303
|
-
background:
|
|
1323
|
+
background: var(--ak-danger);
|
|
1304
1324
|
animation: ak-recording-pulse 1.4s ease-in-out infinite;
|
|
1305
1325
|
}
|
|
1306
1326
|
@keyframes ak-recording-pulse {
|
|
@@ -1314,8 +1334,8 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
1314
1334
|
}
|
|
1315
1335
|
.ak-composer__recording-cancel,
|
|
1316
1336
|
.ak-composer__recording-stop {
|
|
1317
|
-
width:
|
|
1318
|
-
height:
|
|
1337
|
+
width: 32px;
|
|
1338
|
+
height: 32px;
|
|
1319
1339
|
border-radius: 8px;
|
|
1320
1340
|
border: none;
|
|
1321
1341
|
cursor: pointer;
|
|
@@ -1331,7 +1351,7 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
1331
1351
|
}
|
|
1332
1352
|
.ak-composer__recording-cancel:hover {
|
|
1333
1353
|
color: var(--ak-text);
|
|
1334
|
-
background: var(--ak-
|
|
1354
|
+
background: var(--ak-hover);
|
|
1335
1355
|
}
|
|
1336
1356
|
.ak-composer__recording-stop {
|
|
1337
1357
|
background: var(--ak-accent);
|
|
@@ -1341,10 +1361,11 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
1341
1361
|
background: var(--ak-accent-hover);
|
|
1342
1362
|
}
|
|
1343
1363
|
|
|
1344
|
-
/* Send button — square
|
|
1364
|
+
/* Send button — rounded square at the toolbar's right end */
|
|
1345
1365
|
.ak-composer__send {
|
|
1346
|
-
width:
|
|
1347
|
-
height:
|
|
1366
|
+
width: 32px;
|
|
1367
|
+
height: 32px;
|
|
1368
|
+
margin-left: auto;
|
|
1348
1369
|
border-radius: 8px;
|
|
1349
1370
|
background: var(--ak-accent);
|
|
1350
1371
|
border: none;
|
|
@@ -1353,14 +1374,16 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
1353
1374
|
align-items: center;
|
|
1354
1375
|
justify-content: center;
|
|
1355
1376
|
color: white;
|
|
1356
|
-
transition: background 0.15s,
|
|
1377
|
+
transition: background 0.15s, color 0.15s;
|
|
1357
1378
|
flex-shrink: 0;
|
|
1358
1379
|
}
|
|
1359
1380
|
.ak-composer__send:hover:not(:disabled) {
|
|
1360
1381
|
background: var(--ak-accent-hover);
|
|
1361
1382
|
}
|
|
1383
|
+
/* Disabled sits on the muted fill rather than a faded accent, so it stays visible on dark */
|
|
1362
1384
|
.ak-composer__send:disabled {
|
|
1363
|
-
|
|
1385
|
+
background: var(--ak-bot-bg);
|
|
1386
|
+
color: var(--ak-text-muted);
|
|
1364
1387
|
cursor: not-allowed;
|
|
1365
1388
|
}
|
|
1366
1389
|
|
|
@@ -1703,10 +1726,10 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
1703
1726
|
/* ── Error banner ────────────────────────────────────────────── */
|
|
1704
1727
|
.ak-error {
|
|
1705
1728
|
padding: 12px 16px;
|
|
1706
|
-
background:
|
|
1707
|
-
color:
|
|
1729
|
+
background: var(--ak-danger-soft);
|
|
1730
|
+
color: var(--ak-danger-fg);
|
|
1708
1731
|
font-size: 13px;
|
|
1709
|
-
border-top: 1px solid
|
|
1732
|
+
border-top: 1px solid var(--ak-danger-border);
|
|
1710
1733
|
text-align: left;
|
|
1711
1734
|
flex-shrink: 0;
|
|
1712
1735
|
display: flex;
|
|
@@ -1748,9 +1771,9 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
1748
1771
|
|
|
1749
1772
|
/* Specific styling for origin restriction errors */
|
|
1750
1773
|
.ak-error--origin {
|
|
1751
|
-
background:
|
|
1752
|
-
color:
|
|
1753
|
-
border-top: 1px solid
|
|
1774
|
+
background: var(--ak-warning-soft); /* warning, not danger: less alarming */
|
|
1775
|
+
color: var(--ak-warning-fg);
|
|
1776
|
+
border-top: 1px solid var(--ak-warning);
|
|
1754
1777
|
}
|
|
1755
1778
|
|
|
1756
1779
|
/* ── Agent status indicator ──────────────────────────────────── */
|
|
@@ -1770,7 +1793,7 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
1770
1793
|
}
|
|
1771
1794
|
.ak-agent-status__icon {
|
|
1772
1795
|
flex-shrink: 0;
|
|
1773
|
-
color: var(--ak-
|
|
1796
|
+
color: var(--ak-accent);
|
|
1774
1797
|
animation: ak-sparkle-pulse 2.5s ease-in-out infinite;
|
|
1775
1798
|
}
|
|
1776
1799
|
.ak-agent-status__text {
|
|
@@ -1807,7 +1830,7 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
1807
1830
|
.ak-progress__label {
|
|
1808
1831
|
font-weight: 600;
|
|
1809
1832
|
font-size: 0.78rem;
|
|
1810
|
-
color: var(--ak-
|
|
1833
|
+
color: var(--ak-accent);
|
|
1811
1834
|
}
|
|
1812
1835
|
.ak-progress__toggle {
|
|
1813
1836
|
display: inline-flex;
|
|
@@ -1904,7 +1927,7 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
1904
1927
|
opacity: 0.55;
|
|
1905
1928
|
}
|
|
1906
1929
|
.ak-progress__step-icon--fail {
|
|
1907
|
-
color:
|
|
1930
|
+
color: var(--ak-danger);
|
|
1908
1931
|
opacity: 0.9;
|
|
1909
1932
|
}
|
|
1910
1933
|
/* Post-turn summary row ("Worked for Ns · N steps") */
|
|
@@ -1935,7 +1958,7 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
1935
1958
|
width: 11px;
|
|
1936
1959
|
height: 11px;
|
|
1937
1960
|
border: 1.5px solid var(--ak-border);
|
|
1938
|
-
border-top-color: var(--ak-
|
|
1961
|
+
border-top-color: var(--ak-accent);
|
|
1939
1962
|
border-radius: 50%;
|
|
1940
1963
|
flex-shrink: 0;
|
|
1941
1964
|
animation: ak-spin 0.7s linear infinite;
|
|
@@ -2033,10 +2056,10 @@ ${a}:`;for(var o=0,s=e[a];o<s.length;o++){var c=s[o];n+=`
|
|
|
2033
2056
|
display: none;
|
|
2034
2057
|
}
|
|
2035
2058
|
}
|
|
2036
|
-
`,us=0;Array.isArray;function Q(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--us,__i:-1,__u:0,__source:i,__self:a};if(typeof e==`function`&&(o=e.defaultProps))for(s in o)c[s]===void 0&&(c[s]=o[s]);return
|
|
2059
|
+
`,us=0;Array.isArray;function Q(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--us,__i:-1,__u:0,__source:i,__self:a};if(typeof e==`function`&&(o=e.defaultProps))for(s in o)c[s]===void 0&&(c[s]=o[s]);return W.vnode&&W.vnode(l),l}function ds(){return/* @__PURE__ */ Q(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ Q(`rect`,{x:`3`,y:`11`,width:`18`,height:`10`,rx:`2`}),/* @__PURE__ */ Q(`circle`,{cx:`12`,cy:`5`,r:`2`}),/* @__PURE__ */ Q(`path`,{d:`M12 7v4`}),/* @__PURE__ */ Q(`line`,{x1:`8`,y1:`16`,x2:`8`,y2:`16`}),/* @__PURE__ */ Q(`line`,{x1:`16`,y1:`16`,x2:`16`,y2:`16`})]})}function fs(){return/* @__PURE__ */ Q(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,children:[/* @__PURE__ */ Q(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),/* @__PURE__ */ Q(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})}function ps(){return/* @__PURE__ */ Q(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ Q(`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}),/* @__PURE__ */ Q(`path`,{d:`M3 3v5h5`})]})}function ms({title:e,subtitle:t,avatarUrl:n,onClose:r,onReset:i,hideClose:a=!1}){let[o,s]=Y(!1);return/* @__PURE__ */ Q(`div`,{className:`ak-header${o?` ak-header--confirming`:``}`,children:[/* @__PURE__ */ Q(`div`,{className:`ak-header__row`,children:[n?/* @__PURE__ */ Q(`img`,{src:n,alt:``,className:`ak-header__avatar`,"aria-hidden":`true`}):/* @__PURE__ */ Q(`span`,{className:`ak-header__bot-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ Q(ds,{})}),/* @__PURE__ */ Q(`div`,{className:`ak-header__title-group`,children:[/* @__PURE__ */ Q(`span`,{className:`ak-header__title`,children:e}),t&&/* @__PURE__ */ Q(`span`,{className:`ak-header__subtitle`,children:t})]}),/* @__PURE__ */ Q(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[/* @__PURE__ */ Q(`span`,{className:`ak-header__status`,"aria-hidden":`true`}),i&&/* @__PURE__ */ Q(`button`,{className:`ak-header__button${o?` ak-header__button--active`:``}`,onClick:()=>s(!0),"aria-label":`New conversation`,type:`button`,title:`Start a new conversation (Retains current conversation to memory)`,children:/* @__PURE__ */ Q(ps,{})}),!a&&/* @__PURE__ */ Q(`button`,{className:`ak-header__close`,onClick:r,"aria-label":`Close chat`,type:`button`,children:/* @__PURE__ */ Q(fs,{})})]})]}),o&&/* @__PURE__ */ Q(`div`,{className:`ak-header__confirm`,role:`alert`,children:[/* @__PURE__ */ Q(`div`,{className:`ak-header__confirm-text`,children:[/* @__PURE__ */ Q(`span`,{className:`ak-header__confirm-title`,children:`End this conversation?`}),/* @__PURE__ */ Q(`span`,{className:`ak-header__confirm-sub`,children:`All messages will be removed`})]}),/* @__PURE__ */ Q(`div`,{className:`ak-header__confirm-actions`,children:[/* @__PURE__ */ Q(`button`,{className:`ak-header__confirm-cancel`,type:`button`,onClick:()=>s(!1),children:`Cancel`}),/* @__PURE__ */ Q(`button`,{className:`ak-header__confirm-ok`,type:`button`,onClick:()=>{i?.(),s(!1)},children:`End chat`})]})]})]})}function hs(e){if(!e)return null;let t=e.trim();if(!t)return null;if(/^(\/|\.{1,2}\/|#|\?)/.test(t))return t;let n=/^([a-z][a-z0-9+.-]*):/i.exec(t)?.[1]?.toLowerCase();return n?[`http`,`https`,`mailto`,`tel`].includes(n)?t:null:t}function gs(e){return 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(/\$\$(?!\d)[\s\S]+?\$\$/g,``).replace(/\$(?![\s\d])([^$\n]+?)(?<!\s)\$(?!\d)/g,`$1`).replace(/\x00DOLLAR\x00/g,`$`).replace(/\\[a-zA-Z]+\*?/g,``).replace(/\n{3,}/g,`
|
|
2037
2060
|
|
|
2038
|
-
`)}function _s(e){let[,t]=Y(0);X(()=>{if(!e)return;let n=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(n)},[e])}var vs=800;function ys({up:e}){return Q(`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:Q(`polyline`,{points:e?`18 15 12 9 6 15`:`6 9 12 15 18 9`})})}function bs({event:e,active:t}){return t?Q(`span`,{className:`ak-progress__spinner`,"aria-hidden":`true`}):Q(`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?Q(G,{children:[Q(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),Q(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]}):Q(`polyline`,{points:`20 6 9 17 4 12`})})}function xs({events:e,live:t,answerStartedAtMs:n}){_s(t&&!n&&e.some(e=>e.status===`active`));let r=n??Date.now(),i=e[0]?.startedAtMs,a=e.reduce((e,t,n)=>t.status===`active`?n:e,-1);return Q(`ul`,{className:`ak-progress__steps`,role:`list`,children:e.map((e,n)=>{let o=t&&e.status===`active`,s=o&&n===a?$i(i?r-i:void 0):o?null:$i(e.durationMs);return Q(`li`,{className:o?`ak-progress__step ak-progress__step--active`:`ak-progress__step`,children:[Q(bs,{event:e,active:o}),Q(`span`,{className:`ak-progress__step-text`,children:e.text}),s&&Q(`span`,{className:`ak-progress__step-dur`,children:[`· `,s]})]},`${e.toolId??e.stage}-${n}`)})})}function Ss({events:e,answerStartedAtMs:t}){let[n,r]=Y(0),i=Math.min(n,e.length-1),a=i<e.length-1;X(()=>{if(!a)return;let t=setTimeout(()=>r(t=>Math.min(t+1,e.length-1)),vs);return()=>clearTimeout(t)},[a,i,e.length]);let o=e[i],s=!a&&o.status===`done`;_s(!s&&!t);let c=e[0]?.startedAtMs,l=s?null:$i(c?(t??Date.now())-c:void 0);return Q(`ul`,{className:`ak-progress__list`,role:`list`,children:Q(`li`,{className:`ak-progress__item ak-progress__item--active`,children:[s?Q(bs,{event:o,active:!1}):Q(`span`,{className:`ak-progress__spinner`,"aria-hidden":`true`}),Q(`span`,{className:`ak-progress__text`,children:o.text}),l&&Q(`span`,{className:`ak-progress__step-dur`,children:[`· `,l]})]})})}function Cs({ackText:e,events:t=[],collapsed:n=!0,isComplete:r=!1,turnMeta:i,answerStartedAtMs:a}){let[o,s]=Y(!n);X(()=>{r&&s(!n)},[r]);let c=i?.mode;if(!r)return t.length===0?e?Q(`ul`,{className:`ak-progress__list`,role:`list`,children:Q(`li`,{className:`ak-progress__item ak-progress__item--active`,children:[Q(`span`,{className:`ak-progress__spinner`,"aria-hidden":`true`}),Q(`span`,{className:`ak-progress__text`,children:e})]})}):null:c===`detailed`?Q(xs,{events:t,live:!0,answerStartedAtMs:a}):Q(Ss,{events:t,answerStartedAtMs:a});let l=$i(i?.totalMs),u=l?`Worked for ${l}`:`Finished working`;return c===`detailed`&&t.length>0?Q(`div`,{className:`ak-progress`,children:[Q(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`ak-progress__summary`,"aria-expanded":o,"aria-label":o?`Hide working steps`:`Show working steps`,children:[Q(bs,{event:{stage:``,text:``,timestamp:``,status:`done`},active:!1}),Q(`span`,{children:u}),Q(`span`,{className:`ak-progress__step-dur`,children:[`· `,t.length,` step`,t.length===1?``:`s`]}),Q(ys,{up:o})]}),o&&Q(xs,{events:t,live:!1})]}):c===`standard`&&i?Q(`div`,{className:`ak-progress`,children:Q(`p`,{className:`ak-progress__summary ak-progress__summary--static`,children:[Q(bs,{event:{stage:``,text:``,timestamp:``,status:`done`},active:!1}),Q(`span`,{children:u})]})}):null}function ws(){return Q(`svg`,{className:`ak-agent-status__icon`,width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:Q(`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 Ts({status:e}){return Q(`div`,{className:`ak-agent-status`,role:`status`,"aria-live":`polite`,children:[Q(ws,{}),Q(`span`,{className:`ak-agent-status__text`,children:e})]})}function Es({messageId:e,images:t,onCellClick:n}){if(t.length===0)return null;let r=t.length;if(r===1){let e=t[0];return Q(`div`,{className:`ak-gallery ak-gallery--single`,children:[Q(`button`,{type:`button`,onClick:()=>n(0),className:`ak-gallery__cell ak-gallery__cell--hero`,"aria-label":`Open image preview`,children:Q(`img`,{src:e.src,alt:e.alt,className:`ak-gallery__img ak-gallery__img--contain`})}),Q(`a`,{href:hs(e.downloadHref)??void 0,download:!0,className:`ak-message__image-dl-icon`,title:`Download image`,onClick:e=>e.stopPropagation(),children:Q(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[Q(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),Q(`polyline`,{points:`7 10 12 15 17 10`}),Q(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]})})]})}if(r===2)return Q(`div`,{className:`ak-gallery ak-gallery--two`,children:t.map((t,r)=>Q(Ds,{src:t.src,alt:t.alt,onClick:()=>n(r)},t.key??`${e}-${r}`))});if(r===3)return Q(`div`,{className:`ak-gallery ak-gallery--three`,children:[Q(Ds,{src:t[0].src,alt:t[0].alt,onClick:()=>n(0)},t[0].key??`${e}-0`),Q(`div`,{className:`ak-gallery__col`,children:[Q(Ds,{src:t[1].src,alt:t[1].alt,onClick:()=>n(1)},t[1].key??`${e}-1`),Q(Ds,{src:t[2].src,alt:t[2].alt,onClick:()=>n(2)},t[2].key??`${e}-2`)]})]});let i=t.slice(0,4),a=r>4?r-4:0;return Q(`div`,{className:`ak-gallery ak-gallery--grid`,children:i.map((t,r)=>{let o=r===i.length-1;return Q(Ds,{src:t.src,alt:t.alt,overlayCount:o&&a>0?a:0,onClick:()=>n(r)},t.key??`${e}-${r}`)})})}function Ds({src:e,alt:t,overlayCount:n=0,onClick:r}){return Q(`button`,{type:`button`,onClick:r,className:`ak-gallery__cell`,"aria-label":`Open image preview`,children:[Q(`img`,{src:e,alt:t,className:`ak-gallery__img`,loading:`lazy`}),n>0&&Q(`span`,{className:`ak-gallery__overlay`,children:[`+`,n]})]})}function Os({images:e,index:t,onClose:n,onIndexChange:r}){let i=t!==null,a=i&&t!==null?Math.min(Math.max(0,t),e.length-1):0,o=i?e[a]:null;return X(()=>{if(!i)return;let t=t=>{t.key===`Escape`?(t.stopPropagation(),n()):t.key===`ArrowLeft`&&e.length>1?(t.preventDefault(),r((a-1+e.length)%e.length)):t.key===`ArrowRight`&&e.length>1&&(t.preventDefault(),r((a+1)%e.length))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[i,a,e.length,n,r]),!i||!o?null:Q(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Image preview`,className:`ak-lightbox`,onClick:n,children:[Q(`div`,{className:`ak-lightbox__toolbar`,onClick:e=>e.stopPropagation(),children:[e.length>1&&Q(`span`,{className:`ak-lightbox__counter`,children:[a+1,` / `,e.length]}),Q(`a`,{href:hs(o.downloadHref)??void 0,download:!0,target:`_blank`,rel:`noopener noreferrer`,className:`ak-lightbox__btn`,title:`Download image`,"aria-label":`Download image`,children:Q(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[Q(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),Q(`polyline`,{points:`7 10 12 15 17 10`}),Q(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]})}),Q(`button`,{type:`button`,onClick:n,className:`ak-lightbox__btn`,title:`Close`,"aria-label":`Close image preview`,children:Q(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[Q(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),Q(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]}),e.length>1&&Q(G,{children:[Q(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r((a-1+e.length)%e.length)},className:`ak-lightbox__nav ak-lightbox__nav--prev`,"aria-label":`Previous image`,children:Q(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:Q(`polyline`,{points:`15 18 9 12 15 6`})})}),Q(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r((a+1)%e.length)},className:`ak-lightbox__nav ak-lightbox__nav--next`,"aria-label":`Next image`,children:Q(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:Q(`polyline`,{points:`9 18 15 12 9 6`})})})]}),Q(`img`,{src:o.src,alt:o.alt??`Image preview`,className:`ak-lightbox__img`,onClick:e=>e.stopPropagation()})]})}function ks({url:e,mimeType:t,fileName:n}){let r=(()=>{if(n)return n;try{let t=new URL(e).pathname.split(`/`);return(t[t.length-1]||`attachment`).replace(/^\d{10,}-/,``)}catch{return`attachment`}})(),i=r.split(`.`).pop()?.toUpperCase()??``,a=t===`application/pdf`||i===`PDF`?{variant:`pdf`,label:`PDF`}:t===`text/csv`||i===`CSV`?{variant:`csv`,label:`CSV`}:t===`text/markdown`||i===`MD`?{variant:`md`,label:`MD`}:t===`text/plain`||i===`TXT`?{variant:`txt`,label:`TXT`}:{variant:`default`,label:i||`FILE`};return Q(`a`,{href:hs(e)??void 0,target:`_blank`,rel:`noopener noreferrer`,className:`ak-file-chip`,title:r,children:[Q(`span`,{className:`ak-file-chip__icon ak-file-chip__icon--${a.variant}`,"aria-hidden":!0,children:Q(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[Q(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),Q(`polyline`,{points:`14 2 14 8 20 8`})]})}),Q(`span`,{className:`ak-file-chip__body`,children:[Q(`span`,{className:`ak-file-chip__name`,children:r}),Q(`span`,{className:`ak-file-chip__label`,children:a.label})]})]})}function As({url:e,mimeType:t,transcript:n}){return Q(`div`,{className:`ak-audio-chip`,children:[Q(`audio`,{controls:!0,src:e,className:`ak-audio-chip__player`,"aria-label":`Voice note`,children:Q(`source`,{src:e,type:t})}),n&&Q(`p`,{className:`ak-audio-chip__transcript`,children:n})]})}function js(e){try{return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}catch{return``}}var Ms=/(`[^`\n]+`|\*\*[^*\n]+\*\*|\*[^*\n]+\*|!\[[^\]\n]*\]\([^)\n]+\)|\[[^\]\n]+\]\([^)\n]+\))/g;function $(e){let t=[],n=0,r=0;Ms.lastIndex=0;let i;for(;(i=Ms.exec(e))!==null;){i.index>n&&t.push(e.slice(n,i.index));let a=i[0];if(a.startsWith("`"))t.push(Q(`code`,{className:`ak-md-ic`,children:a.slice(1,-1)},r++));else if(a.startsWith(`**`))t.push(Q(`strong`,{children:a.slice(2,-2)},r++));else if(a.startsWith(`*`))t.push(Q(`em`,{children:a.slice(1,-1)},r++));else if(a.startsWith(`![`)){let e=a.match(/!\[([^\]]*)\]\(([^)]+)\)/),n=hs(e?.[2]);e&&n?t.push(Q(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,children:e[1]||`image`},r++)):e&&t.push(e[1]||`image`)}else{let e=a.match(/\[(.+?)\]\((.+?)\)/),n=hs(e?.[2]);e&&n?t.push(Q(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,children:e[1]},r++)):e?t.push(e[1]):t.push(a)}n=i.index+a.length}return n<e.length&&t.push(e.slice(n)),t}function Ns(e){e=gs(e);let t=e.split(`
|
|
2039
|
-
`),n=[],r=0,i=0;for(;r<t.length;){let e=t[r],a=e.match(/^(\s*)```/);if(a){let o=a[1],s=e.trimStart().match(/^```(\w+)?\s*$/)?.[1]||``,c=[];for(r++;r<t.length&&!t[r].trimStart().startsWith("```");)c.push(t[r].startsWith(o)?t[r].slice(o.length):t[r]),r++;r<t.length&&t[r].trimStart().startsWith("```")&&r++,n.push(Q(`div`,{className:`ak-md-pre-wrap`,children:[s
|
|
2040
|
-
`)})})]},i++));continue}let o=e.match(/^(#{1,6})(\s+.*)?$/);if(o){let e=o[1].length,t=o[2]?$(o[2].trim()):``;e===1?n.push(Q(`h1`,{className:`ak-md-h1`,children:t},i++)):e===2?n.push(Q(`h2`,{className:`ak-md-h2`,children:t},i++)):e===3?n.push(Q(`h3`,{className:`ak-md-h3`,children:t},i++)):e===4?n.push(Q(`h4`,{className:`ak-md-h4`,children:t},i++)):e===5?n.push(Q(`h5`,{className:`ak-md-h5`,children:t},i++)):n.push(Q(`h6`,{className:`ak-md-h6`,children:t},i++)),r++;continue}if(/^[-*_]{3,}$/.test(e.trim())){n.push(Q(`hr`,{className:`ak-md-hr`},i++)),r++;continue}if(/^[-*+]\s/.test(e)){let e=[],a=r;for(;a<t.length&&(/^[-*+]\s/.test(t[a])||t[a].trim()===``);){if(t[a].trim()===``){a++;continue}let n=t[a].length-t[a].trimStart().length,r=t[a].replace(/^[-*+]\s+/,``),i=[],o=[],s=a+1;for(;s<t.length&&s<a+20;){let e=t[s];if(e.length-e.trimStart().length>n&&e.trim()!==``){let t=e.trim();/^[-*+]\s/.test(t)?i.push(Q(`li`,{children:$(t.replace(/^[-*+]\s+/,``))},`nested-${s}`)):o.push(Q(`p`,{style:{margin:`0.2em 0 0`},children:$(t)},`cont-${s}`)),s++}else break}let c=o.length>0||i.length>0?Q(G,{children:[$(r),o,i.length>0&&Q(`ul`,{style:{margin:`0.2em 0 0`,paddingLeft:`1.2em`},children:i})]}):$(r);e.push(Q(`li`,{children:c},`item-${a}`)),a=s}n.push(Q(`ul`,{className:`ak-md-ul`,children:e},i++)),r=a;continue}if(/^\d+\.\s/.test(e)){let e=[],a=r;for(;a<t.length&&(/^\d+\.\s/.test(t[a])||t[a].trim()===``);){if(t[a].trim()===``){a++;continue}let n=t[a].length-t[a].trimStart().length,r=t[a].replace(/^\d+\.\s+/,``),i=[],o=[],s=a+1;for(;s<t.length&&s<a+20;){let e=t[s];if(e.length-e.trimStart().length>n&&e.trim()!==``){let t=e.trim();/^\d+\.\s/.test(t)?i.push(Q(`li`,{children:$(t.replace(/^\d+\.\s+/,``))},`nested-order-${s}`)):/^[-*+]\s/.test(t)?i.push(Q(`li`,{children:$(t.replace(/^[-*+]\s+/,``))},`nested-unorder-${s}`)):o.push(Q(`p`,{style:{margin:`0.2em 0 0`},children:$(t)},`cont-${s}`)),s++}else break}let c=o.length>0||i.length>0?Q(G,{children:[$(r),o,i.length>0&&Q(`ol`,{style:{margin:`0.2em 0 0`,paddingLeft:`1.2em`},children:i})]}):$(r);e.push(Q(`li`,{children:c},`order-item-${a}`)),a=s}n.push(Q(`ol`,{className:`ak-md-ol`,children:e},i++)),r=a;continue}if(e.trim()===``){r++;continue}if(e.includes(`|`)&&r+1<t.length&&t[r+1].includes(`|`)){let a=t[r+1];if(/^\s*\|?[\s:|*-]+\|[\s:|*-|]+\|?[\s:|*-]*$/.test(a)){let o=e.split(`|`).map(e=>e.trim()).filter(e=>e.length>0),s=a.split(`|`).map(e=>{let t=e.trim();return t.startsWith(`:`)&&t.endsWith(`:`)?`center`:t.endsWith(`:`)?`right`:(t.startsWith(`:`),`left`)}).filter((e,t)=>t>0&&t<=o.length),c=[],l=r+2;for(;l<t.length&&t[l].includes(`|`)&&t[l].trim()!==``;){let e=t[l].split(`|`).map(e=>e.trim()).filter(e=>e.length>0);if(e.length>0)c.push(e),l++;else break}n.push(Q(`table`,{className:`ak-md-table`,children:[Q(`thead`,{children:Q(`tr`,{children:o.map((e,t)=>Q(`th`,{style:{textAlign:s[t]||`left`},className:`ak-md-th`,children:$(e)},`th-${t}`))})}),Q(`tbody`,{children:c.map((e,t)=>Q(`tr`,{children:o.map((n,r)=>Q(`td`,{style:{textAlign:s[r]||`left`},className:`ak-md-td`,children:e[r]?$(e[r]):``},`td-${t}-${r}`))},`tr-${t}`))})]},i++)),r=l;continue}}let s=[];for(;r<t.length&&t[r].trim()!==``&&!t[r].startsWith(`#`)&&!/^\s*```/.test(t[r])&&!/^[-*+]\s/.test(t[r])&&!/^\d+\.\s/.test(t[r])&&!/^[-*_]{3,}$/.test(t[r].trim());)s.push(t[r]),r++;if(s.length>0){let e=[];s.forEach((t,n)=>{e.push(...$(t)),n<s.length-1&&e.push(Q(`br`,{},`br-${n}`))}),n.push(Q(`p`,{className:`ak-md-p`,children:e},i++))}}return Q(G,{children:n})}function Ps({message:e}){let[t,n]=Y(null),[r,i]=Y(null),a=e.role===`user`,o=e.status===`error`,s=e.status===`streaming`,c=!!(e.images&&e.images.length>0),l=!!(e.documents&&e.documents.length>0),u=(()=>{if(!a)return[];let t=(e.uploadedAttachments??[]).filter(e=>e.kind===`image`).map(e=>({url:e.url,mimeType:e.mimeType,fileName:e.fileName}));return t.length>0?t:e.uploadedImageUrl?[{url:e.uploadedImageUrl,mimeType:`image/jpeg`}]:[]})(),d=a?(e.uploadedAttachments??[]).filter(e=>e.kind===`file`):[],f=a?(e.uploadedAttachments??[]).filter(e=>e.kind===`audio`):[],p=u.length>0,m=d.length>0,h=f.length>0,g=c||p,_=a&&h?na(e.content):null,v=_?_.rest:e.content,y=!!e.progressEvents&&e.progressEvents.length>0,b=s&&!e.content&&!e.toolStatus&&!y,x=!a&&!o,S=!!e.isHuman&&!a,C=a?`ak-message--user`:o?`ak-message--assistant ak-message--error`:S?`ak-message--assistant ak-message--operator`:`ak-message--assistant`,w=[`ak-message__bubble`,x?`ak-message__bubble--md`:``,g?`ak-message__bubble--has-image`:``,S?`ak-message__bubble--operator`:``].filter(Boolean).join(` `),T=S?e.senderDisplay?.trim()||`Operator`:null,ee=T?T.charAt(0).toUpperCase():``,te=Q(`div`,{className:w,children:[p&&Q(Es,{messageId:`${e.id}-up`,images:u.map(e=>({src:e.url,alt:e.fileName??`Uploaded image`,downloadHref:e.url})),onCellClick:e=>n(e)}),m&&Q(`div`,{className:`ak-message__files`,children:d.map((t,n)=>Q(ks,{url:t.url,mimeType:t.mimeType,fileName:t.fileName},`${e.id}-up-file-${n}`))}),h&&Q(`div`,{className:`ak-message__files`,children:f.map((t,n)=>Q(As,{url:t.url,mimeType:t.mimeType,transcript:n===0?_?.transcript??null:null},`${e.id}-up-audio-${n}`))}),c&&Q(Es,{messageId:`${e.id}-asst`,images:e.images.map((e,t)=>{let n=e.url??(e.base64?`data:${e.mimeType};base64,${e.base64}`:null);return n?{src:n,alt:`Generated image`,downloadHref:e.url??n,key:`gen-${t}`}:null}).filter(e=>e!==null),onCellClick:e=>i(e)}),l&&Q(`div`,{className:`ak-message__files`,children:e.documents.map((t,n)=>t.url?Q(ks,{url:t.url,mimeType:t.mimeType,fileName:t.fileName},`${e.id}-asst-doc-${n}`):null)}),v&&Q(`div`,{className:g?`ak-message__image-caption`:void 0,children:[x?Ns(v):v,s&&Q(`span`,{className:`ak-cursor`,"aria-hidden":`true`,children:[Q(`span`,{className:`ak-cursor__dot`}),Q(`span`,{className:`ak-cursor__dot`}),Q(`span`,{className:`ak-cursor__dot`})]})]}),Q(`span`,{className:`ak-message__time`,children:js(e.createdAt)})]}),E=!!e.content||g||m||l||!s&&!e.toolStatus;return Q(`div`,{className:`ak-message ${C}`,children:[!a&&(e.ackText||e.progressEvents&&e.progressEvents.length>0||e.turnMeta)&&Q(Cs,{ackText:e.ackText,events:e.progressEvents,collapsed:e.progressCollapsed,isComplete:!s,turnMeta:e.turnMeta,answerStartedAtMs:e.answerStartedAtMs}),b&&Q(`div`,{className:`ak-typing-row`,role:`status`,"aria-label":`Assistant is typing`,children:[Q(`span`,{className:`ak-typing-row__dot`}),Q(`span`,{className:`ak-typing-row__dot`}),Q(`span`,{className:`ak-typing-row__dot`})]}),!a&&e.toolStatus&&!(e.progressEvents&&e.progressEvents.length>0)&&Q(Ts,{status:e.toolStatus}),S&&Q(`span`,{className:`ak-message__sender-label`,children:[Q(`span`,{className:`ak-message__operator-avatar`,"aria-hidden":`true`,children:ee}),Q(`span`,{className:`ak-message__operator-name`,children:T})]}),E&&te,u.length>0&&Q(Os,{images:u.map(e=>({src:e.url,alt:e.fileName??`Uploaded image`,downloadHref:e.url})),index:t,onClose:()=>n(null),onIndexChange:n}),c&&Q(Os,{images:e.images.map(e=>{let t=e.url??(e.base64?`data:${e.mimeType};base64,${e.base64}`:null);return t?{src:t,alt:`Generated image`,downloadHref:e.url??t}:null}).filter(e=>e!==null),index:r,onClose:()=>i(null),onIndexChange:i})]})}function Fs(){return Q(`div`,{className:`ak-typing`,"aria-label":`Assistant is typing`,children:[Q(`span`,{className:`ak-typing__dot`}),Q(`span`,{className:`ak-typing__dot`}),Q(`span`,{className:`ak-typing__dot`})]})}function Is(e,t){let n=[],r=null;for(let i of e){if(i.role===`assistant`){let e=!!i.isHuman;r!==null&&r!==e&&n.push({kind:`divider`,id:`divider-${i.id}`,label:e?`${i.senderDisplay?.trim()||t} joined the chat`:`${t} left — AI is back`}),r=e}n.push({kind:`message`,message:i})}return n}function Ls({messages:e,isLoading:t,operatorFallbackLabel:n=`Operator`}){let r=Z(null),i=Z(null),a=Z(!0),o=Eo(()=>Is(e,n),[e,n]);return X(()=>{if(!(r.current?.parentElement??r.current))return;let e=e=>{a.current=e.scrollHeight-e.scrollTop-e.clientHeight<120},t=r.current;for(;t&&getComputedStyle(t).overflowY===`visible`;)t=t.parentElement;if(!t)return;let n=()=>e(t);return t.addEventListener(`scroll`,n,{passive:!0}),()=>t.removeEventListener(`scroll`,n)},[]),X(()=>{e[e.length-1]?.role===`user`&&(a.current=!0),a.current&&i.current?.scrollIntoView({behavior:`smooth`})},[e]),X(()=>{a.current&&i.current?.scrollIntoView({behavior:`smooth`})},[t,e.find(e=>e.status===`streaming`)?.content??``]),Q(`div`,{ref:r,className:`ak-messages`,role:`log`,"aria-live":`polite`,"aria-label":`Conversation`,children:[o.map(e=>e.kind===`divider`?Q(`div`,{className:`ak-handoff-divider`,role:`separator`,children:Q(`span`,{className:`ak-handoff-divider__label`,children:e.label})},e.id):Q(Ps,{message:e.message},e.message.id)),t&&!e.some(e=>e.status===`streaming`)&&Q(Fs,{}),Q(`div`,{ref:i})]})}function Rs(){return Q(`svg`,{width:`30`,height:`30`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[Q(`rect`,{x:`3`,y:`11`,width:`18`,height:`10`,rx:`2`}),Q(`circle`,{cx:`12`,cy:`5`,r:`2`}),Q(`path`,{d:`M12 7v4`}),Q(`line`,{x1:`8`,y1:`16`,x2:`8`,y2:`16`}),Q(`line`,{x1:`16`,y1:`16`,x2:`16`,y2:`16`})]})}function zs({title:e,description:t,suggestedQuestions:n,avatarUrl:r,onSelect:i}){let a=(n??[]).filter(e=>(e.title??``).trim().length>0);return Q(`div`,{className:`ak-empty-state`,"aria-label":`Start a conversation`,children:[Q(`div`,{className:`ak-empty-state__glow`,"aria-hidden":`true`}),Q(`div`,{className:`ak-empty-state__body`,children:[Q(`div`,{className:`ak-empty-state__avatar`,children:r?Q(`img`,{src:r,alt:``,className:`ak-empty-state__avatar-img`,"aria-hidden":`true`}):Q(`span`,{className:`ak-empty-state__bot-icon`,"aria-hidden":`true`,children:Q(Rs,{})})}),Q(`p`,{className:`ak-empty-state__title`,children:e}),t&&Q(`p`,{className:`ak-empty-state__description`,children:t})]}),a.length>0&&Q(`div`,{className:`ak-empty-state__suggestions`,children:a.map((e,t)=>Q(`button`,{className:`ak-empty-state__suggestion`,onClick:()=>i?.(e.prompt??e.title),type:`button`,children:[Q(`span`,{className:`ak-empty-state__suggestion-title`,children:e.title}),e.description&&Q(`span`,{className:`ak-empty-state__suggestion-desc`,children:e.description})]},t))})]})}var Bs=`https://klicforge.ai/privacy-policy`,Vs=`https://klicforge.ai/terms-of-service`;function Hs(){return Q(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[Q(`line`,{x1:`22`,y1:`2`,x2:`11`,y2:`13`}),Q(`polygon`,{points:`22 2 15 22 11 13 2 9 22 2`})]})}function Us(){return Q(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,children:[Q(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),Q(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]})}function Ws(){return Q(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[Q(`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`}),Q(`circle`,{cx:`12`,cy:`13`,r:`4`})]})}function Gs(){return Q(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[Q(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),Q(`polyline`,{points:`14 2 14 8 20 8`})]})}function Ks(){return Q(`svg`,{width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[Q(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),Q(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})}function qs(){return Q(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[Q(`path`,{d:`M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z`}),Q(`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`}),Q(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`23`}),Q(`line`,{x1:`8`,y1:`23`,x2:`16`,y2:`23`})]})}function Js(){return Q(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`currentColor`,children:Q(`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`})})}var Ys=[`application/pdf`,`text/markdown`,`text/plain`,`text/csv`],Xs=[`.pdf`,`.md`,`.txt`,`.csv`],Zs=[...Xs,...Ys].join(`,`),Qs=[`image/jpeg`,`image/png`,`image/gif`,`image/webp`],$s=Qs.join(`,`),ec=[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg;codecs=opus`];function tc(){return typeof MediaRecorder>`u`?null:ec.find(e=>MediaRecorder.isTypeSupported(e))??null}function nc(e){return e.includes(`mp4`)?`mp4`:e.includes(`ogg`)?`ogg`:`webm`}function rc(e){let t=Math.floor(e/1e3),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,`0`)}`}function ic(e){if(Ys.includes(e.type))return!0;let t=e.name.toLowerCase();return Xs.some(e=>t.endsWith(e))}function ac(e){return Qs.includes(e.type)}function oc({onSend:e,disabled:t=!1,placeholder:n=`Type a message…`,photoSendingEnabled:r=!1,fileUploadEnabled:i=!1,voiceNoteEnabled:a=!1,voiceNoteMaxDurationSec:o=120,attachmentMaxCount:s=5,attachmentMaxFileSizeMb:c=1,onRecordingError:l}){let[u,d]=Y(``),[f,p]=Y([]),[m,h]=Y(new Map),[g,_]=Y(!1),[v,y]=Y(!1),[b,x]=Y(0),S=Z(null),C=Z(null),w=Z(null),T=Z(null),ee=Z(null),te=Z(null),E=Z(null),ne=Z([]),re=Z(null),ie=Z(0),ae=Z(null),oe=Z(!1),se=Z(!1),ce=Z(u);ce.current=u;let le=Z(f);le.current=f;let ue=Z(t);ue.current=t;let de=r||i,fe=Eo(()=>c*1024*1024,[c]),pe=a&&typeof window<`u`&&typeof MediaRecorder<`u`&&!!navigator.mediaDevices?.getUserMedia;X(()=>()=>{m.forEach(e=>URL.revokeObjectURL(e))},[]);let me=Z(null);X(()=>{if(t)return;let e=me.current;me.current=t,!(e===null&&typeof window<`u`&&window.matchMedia?.(`(pointer: coarse)`).matches)&&S.current?.focus()},[t]);let he=Z(!1);X(()=>{v?te.current?.focus():he.current&&!ue.current&&S.current?.focus(),he.current=v},[v]);let ge=Do(e=>{if(!g)return;let t=e.composedPath?e.composedPath():[],n=!!T.current&&t.includes(T.current),r=!!ee.current&&t.includes(ee.current);!n&&!r&&_(!1)},[g]);X(()=>{if(g)return document.addEventListener(`click`,ge),()=>document.removeEventListener(`click`,ge)},[g,ge]),X(()=>{de||_(!1)},[de]);function _e(){m.forEach(e=>URL.revokeObjectURL(e)),h(new Map),p([]),C.current&&(C.current.value=``),w.current&&(w.current.value=``)}function ve(e){p(t=>{let n=t[e];if(n){let e=m.get(n.file);e&&(URL.revokeObjectURL(e),h(e=>{let t=new Map(e);return t.delete(n.file),t}))}return t.filter((t,n)=>n!==e)})}function ye(){let n=u.trim();!n&&f.length===0||t||(e(n,f),d(``),_e(),S.current&&(S.current.style.height=`auto`))}let be=Do(()=>{re.current?.getTracks().forEach(e=>e.stop()),re.current=null},[]);X(()=>()=>{ae.current&&clearInterval(ae.current),E.current&&E.current.state!==`inactive`&&(oe.current=!0,E.current.stop()),be()},[be]);async function xe(){if(!pe||v||se.current||t)return;if(f.length>=s){l?.(`Only ${s} attachments can be sent at once`);return}let n=tc();if(!n){l?.(`Voice recording is not supported in this browser`);return}se.current=!0;let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{se.current=!1,l?.(`Microphone access was denied`);return}se.current=!1,re.current=r,ne.current=[],oe.current=!1;let i=new MediaRecorder(r,{mimeType:n});i.ondataavailable=e=>{e.data.size>0&&ne.current.push(e.data)},i.onstop=()=>{be();let t=oe.current,r=Date.now()-ie.current,i=new Blob(ne.current,{type:n});if(ne.current=[],t||r<300||ue.current)return;let a=new File([i],`voice-note.${nc(n)}`,{type:n}),o=ce.current.trim(),c=[...le.current,{file:a,kind:`audio`,durationMs:r}];if(c.length>s){l?.(`Only ${s} attachments can be sent at once`);return}e(o,c),d(``),_e(),S.current&&(S.current.style.height=`auto`)},E.current=i,ie.current=Date.now(),x(0),i.start(),y(!0),ae.current=setInterval(()=>{let e=Date.now()-ie.current;x(e),e>=o*1e3&&Se(!1)},250)}function Se(e){ae.current&&=(clearInterval(ae.current),null),oe.current=e,E.current&&E.current.state!==`inactive`&&E.current.stop(),y(!1),x(0)}function Ce(e){e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ye())}function we(e){let t=e.currentTarget;d(t.value),t.style.height=`auto`,t.style.height=`${t.scrollHeight}px`}function Te(e,t){if(e.length===0)return;let n=[],r=[];for(let i of e){if(t===`image`&&!ac(i)){r.push(`${i.name} (image type not supported)`);continue}if(t===`file`&&!ic(i)){r.push(`${i.name} (file type not supported)`);continue}if(i.size>fe){r.push(`${i.name} (over ${c} MB)`);continue}n.push({file:i,kind:t})}p(e=>{let t=[...e,...n],i=t.slice(0,s);return t.length>s&&r.push(`max ${s} attachments allowed`),h(e=>{let t=new Map(e);for(let e of i)e.kind===`image`&&!t.has(e.file)&&t.set(e.file,URL.createObjectURL(e.file));return t}),i}),r.length>0&&alert(`Some attachments were not added:\n• ${r.join(`
|
|
2041
|
-
• `)}`)}function Ee(e){let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,Te(t,`image`)}function De(e){let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,Te(t,`file`)}function Oe(){_(!1),C.current?.click()}function ke(){_(!1),w.current?.click()}let Ae=!t&&(!!u.trim()||f.length>0);return Q(`div`,{className:`ak-composer`,children:[de&&g&&Q(`div`,{ref:T,className:`ak-composer__attach-menu`,role:`menu`,children:[r&&Q(`button`,{className:`ak-composer__attach-menu-item`,onClick:Oe,type:`button`,role:`menuitem`,disabled:t,children:[Q(Ws,{}),Q(`span`,{children:`Photo`})]}),i&&Q(`button`,{className:`ak-composer__attach-menu-item`,onClick:ke,type:`button`,role:`menuitem`,disabled:t,children:[Q(Gs,{}),Q(`span`,{children:`File`})]})]}),f.length>0&&Q(`div`,{className:`ak-composer__attachments`,role:`list`,children:f.map((e,n)=>{let r=`${e.file.name}-${n}`;if(e.kind===`image`){let i=m.get(e.file);return Q(`div`,{className:`ak-composer__preview-wrap`,role:`listitem`,children:[i&&Q(`img`,{src:i,alt:e.file.name,className:`ak-composer__preview-img`}),Q(`button`,{className:`ak-composer__preview-remove`,onClick:()=>ve(n),type:`button`,"aria-label":`Remove ${e.file.name}`,disabled:t,children:Q(Ks,{})})]},r)}return Q(`span`,{className:`ak-composer__file-chip`,role:`listitem`,children:[Q(Gs,{}),Q(`span`,{className:`ak-composer__file-chip-name`,title:e.file.name,children:e.file.name}),Q(`button`,{className:`ak-composer__file-chip-remove`,onClick:()=>ve(n),type:`button`,"aria-label":`Remove ${e.file.name}`,disabled:t,children:Q(Ks,{})})]},r)})}),de&&Q(G,{children:[r&&Q(`input`,{ref:C,type:`file`,multiple:!0,accept:$s,className:`ak-composer__file-input`,onChange:Ee,disabled:t,"aria-label":`Attach images`}),i&&Q(`input`,{ref:w,type:`file`,multiple:!0,accept:Zs,className:`ak-composer__file-input`,onChange:De,disabled:t,"aria-label":`Attach files`})]}),Q(`div`,{className:`ak-composer__input-wrap`,children:v?Q(`div`,{className:`ak-composer__recording`,children:[Q(`button`,{className:`ak-composer__recording-cancel`,onClick:()=>Se(!0),"aria-label":`Cancel recording`,type:`button`,children:Q(Ks,{})}),Q(`span`,{className:`ak-composer__recording-timer`,children:[Q(`span`,{className:`ak-composer__recording-dot`}),rc(b)]}),Q(`button`,{ref:te,className:`ak-composer__recording-stop`,onClick:()=>Se(!1),"aria-label":`Stop recording`,type:`button`,children:Q(Js,{})})]}):Q(G,{children:[de&&Q(`div`,{className:`ak-composer__attach-wrap`,children:Q(`button`,{ref:ee,className:`ak-composer__attach${g?` ak-composer__attach--open`:``}`,onClick:()=>_(e=>!e),disabled:t,"aria-label":`Attachment options`,"aria-haspopup":`true`,"aria-expanded":g,type:`button`,children:Q(Us,{})})}),pe&&Q(`button`,{className:`ak-composer__mic`,onClick:()=>void xe(),disabled:t||f.length>=s,"aria-label":f.length>=s?`Only ${s} attachments can be sent at once`:`Record a voice note`,title:f.length>=s?`Only ${s} attachments can be sent at once`:`Record a voice note`,type:`button`,children:Q(qs,{})}),Q(`textarea`,{ref:S,className:`ak-composer__input`,value:u,onInput:we,onKeyDown:Ce,placeholder:n,disabled:t,rows:1,"aria-label":`Message input`}),Q(`button`,{className:`ak-composer__send`,onClick:ye,disabled:!Ae,"aria-label":`Send message`,type:`button`,children:Q(Hs,{})})]})}),Q(`p`,{className:`ak-composer__disclaimer`,children:[`By chatting you agree to our`,` `,Q(`a`,{href:Bs,target:`_blank`,rel:`noopener noreferrer`,children:`Privacy Policy`}),` `,`and`,` `,Q(`a`,{href:Vs,target:`_blank`,rel:`noopener noreferrer`,children:`Terms of Service`}),`. `,`AI can make mistakes. Verify important information.`]})]})}function sc({message:e}){return e.includes(`Origin not allowed`)?Q(`div`,{className:`ak-error ak-error--origin`,role:`alert`,children:[Q(`div`,{className:`ak-error__icon`,children:`🔒`}),Q(`div`,{className:`ak-error__content`,children:[Q(`h3`,{className:`ak-error__title`,children:`Access Restricted`}),Q(`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.`})]})]}):Q(`div`,{className:`ak-error`,role:`alert`,children:[Q(`div`,{className:`ak-error__icon`,children:`⚠️`}),Q(`div`,{className:`ak-error__content`,children:Q(`p`,{className:`ak-error__message`,children:e})})]})}function cc(){return Q(`svg`,{width:`28`,height:`28`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[Q(`circle`,{cx:`12`,cy:`12`,r:`9`}),Q(`path`,{d:`M12 7v5l3 2`})]})}function lc(){return Q(`div`,{className:`ak-maintenance`,role:`status`,"aria-live":`polite`,children:[Q(`div`,{className:`ak-maintenance__halo`,"aria-hidden":`true`}),Q(`div`,{className:`ak-maintenance__icon`,children:Q(cc,{})}),Q(`p`,{className:`ak-maintenance__title`,children:`Under maintenance`}),Q(`p`,{className:`ak-maintenance__description`,children:`This assistant is temporarily unavailable. Please check back in a little while.`})]})}function uc(){return Q(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,className:`ak-branding__logo`,children:[Q(`rect`,{width:`24`,height:`24`,rx:`5`,fill:`currentColor`}),Q(`path`,{d:`M12 5L7 13h3.5v6l6.5-9H13.5V5z`,fill:`white`})]})}function dc(){return Q(`div`,{className:`ak-branding`,children:[Q(uc,{}),Q(`span`,{className:`ak-branding__label`,children:`Powered by`}),Q(`span`,{className:`ak-branding__name`,children:`KlicForge`})]})}function fc({config:e,messages:t,isLoading:n,error:r,isInline:i,initStatus:a,initError:o,callbacks:s}){let[c,l]=Y(null);return Q(`div`,{className:i?`ak-shell-wrap`:`ak-shell-wrap ak-shell-enter`,children:[Q(`div`,{className:i?`ak-shell ak-shell--inline`:`ak-shell ak-shell--floating`,role:`dialog`,"aria-label":e.title,children:[Q(ms,{title:e.title,subtitle:e.subtitle,avatarUrl:e.avatarUrl,onClose:s.onClose,onReset:a===`ready`?s.onReset:void 0,hideClose:i}),a===`validating`&&Q(`div`,{className:`ak-init-status`,children:Q(`div`,{className:`ak-init-spinner`,"aria-label":`Connecting…`})}),a===`error`&&Q(`div`,{className:`ak-init-status ak-init-status--error`,children:Q(sc,{message:o??`Widget configuration is invalid.`})}),a===`disabled`&&Q(`div`,{className:`ak-init-status ak-init-status--maintenance`,children:Q(lc,{})}),a===`ready`&&Q(G,{children:[t.length===0?Q(zs,{title:e.title,description:e.description??e.subtitle,suggestedQuestions:e.suggestedQuestions,avatarUrl:e.avatarUrl,onSelect:e=>s.onSendMessage(e,[])}):Q(Ls,{messages:t,isLoading:n}),(r||c)&&Q(sc,{message:r??c}),Q(oc,{onSend:(e,t)=>{l(null),s.onSendMessage(e,t)},onRecordingError:l,disabled:n,placeholder:`Type a message…`,photoSendingEnabled:e.photoSendingEnabled,fileUploadEnabled:e.fileUploadEnabled,voiceNoteEnabled:e.voiceNoteEnabled,voiceNoteMaxDurationSec:e.voiceNoteMaxDurationSec,attachmentMaxCount:e.attachmentMaxCount,attachmentMaxFileSizeMb:e.attachmentMaxFileSizeMb})]})]}),!i&&Q(dc,{})]})}function pc(){return Q(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:Q(`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 mc(){return Q(`svg`,{width:`22`,height:`22`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:Q(`polyline`,{points:`6,9 12,15 18,9`})})}function hc({isOpen:e,onClick:t,avatarUrl:n,ariaLabel:r=`Toggle chat`}){let i=!e&&!!n;return Q(`button`,{className:`ak-launcher${i?` ak-launcher--avatar`:``}`,onClick:t,"aria-label":r,"aria-expanded":e,type:`button`,children:e?Q(mc,{}):i?Q(`img`,{src:n,alt:``,className:`ak-launcher__avatar-img`,"aria-hidden":`true`}):Q(pc,{})})}function gc({config:e,state:t,callbacks:n}){let r=e.mode===`inline`,i=Z(null);return X(()=>{let t=i.current?.getRootNode()?.host;if(!t)return;let n=cs(e.theme.mode);t.setAttribute(`data-theme`,n)},[e.theme.mode]),X(()=>{if(r)return;let e=i.current?.getRootNode()?.host;e&&(t.isOpen?e.setAttribute(`data-open`,``):e.removeAttribute(`data-open`))},[r,t.isOpen]),t.initStatus===`disabled`&&!r?null:r?Q(`div`,{ref:i,className:`ak-inline`,children:Q(fc,{config:e,messages:t.messages,isLoading:t.isLoading,error:t.error,isInline:!0,initStatus:t.initStatus,initError:t.initError,callbacks:n})}):Q(`div`,{ref:i,className:`ak-floating`,children:[t.isOpen&&Q(fc,{config:e,messages:t.messages,isLoading:t.isLoading,error:t.error,isInline:!1,initStatus:t.initStatus,initError:t.initError,callbacks:n}),Q(hc,{isOpen:t.isOpen,onClick:t.isOpen?n.onClose:n.onOpen,avatarUrl:e.avatarUrl})]})}var _c=(e,t,n,r)=>{let i=os(e);return i.render(Ha(gc,{config:t,state:n,callbacks:r})),{update(e,t){i.render(Ha(gc,{config:t,state:e,callbacks:r}))},destroy(){setTimeout(()=>{i.unmount()},0)}}};function vc(e){return ls+`
|
|
2042
|
-
`+ss(e)}function yc(e,t){return vc(
|
|
2061
|
+
`)}function _s(e){let[,t]=Y(0);X(()=>{if(!e)return;let n=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(n)},[e])}var vs=800;function ys({up:e}){return/* @__PURE__ */ Q(`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:/* @__PURE__ */ Q(`polyline`,{points:e?`18 15 12 9 6 15`:`6 9 12 15 18 9`})})}function bs({event:e,active:t}){return t?/* @__PURE__ */ Q(`span`,{className:`ak-progress__spinner`,"aria-hidden":`true`}):/* @__PURE__ */ Q(`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?/* @__PURE__ */ Q(K,{children:[/* @__PURE__ */ Q(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),/* @__PURE__ */ Q(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]}):/* @__PURE__ */ Q(`polyline`,{points:`20 6 9 17 4 12`})})}function xs({events:e,live:t,answerStartedAtMs:n}){_s(t&&!n&&e.some(e=>e.status===`active`));let r=n??Date.now(),i=e[0]?.startedAtMs,a=e.reduce((e,t,n)=>t.status===`active`?n:e,-1);return/* @__PURE__ */ Q(`ul`,{className:`ak-progress__steps`,role:`list`,children:e.map((e,n)=>{let o=t&&e.status===`active`,s=o&&n===a?Qi(i?r-i:void 0):o?null:Qi(e.durationMs);return/* @__PURE__ */ Q(`li`,{className:o?`ak-progress__step ak-progress__step--active`:`ak-progress__step`,children:[/* @__PURE__ */ Q(bs,{event:e,active:o}),/* @__PURE__ */ Q(`span`,{className:`ak-progress__step-text`,children:e.text}),s&&/* @__PURE__ */ Q(`span`,{className:`ak-progress__step-dur`,children:[`· `,s]})]},`${e.toolId??e.stage}-${n}`)})})}function Ss({events:e,answerStartedAtMs:t}){let[n,r]=Y(0),i=Math.min(n,e.length-1),a=i<e.length-1;X(()=>{if(!a)return;let t=setTimeout(()=>r(t=>Math.min(t+1,e.length-1)),vs);return()=>clearTimeout(t)},[a,i,e.length]);let o=e[i],s=!a&&o.status===`done`;_s(!s&&!t);let c=e[0]?.startedAtMs,l=s?null:Qi(c?(t??Date.now())-c:void 0);return/* @__PURE__ */ Q(`ul`,{className:`ak-progress__list`,role:`list`,children:/* @__PURE__ */ Q(`li`,{className:`ak-progress__item ak-progress__item--active`,children:[s?/* @__PURE__ */ Q(bs,{event:o,active:!1}):/* @__PURE__ */ Q(`span`,{className:`ak-progress__spinner`,"aria-hidden":`true`}),/* @__PURE__ */ Q(`span`,{className:`ak-progress__text`,children:o.text}),l&&/* @__PURE__ */ Q(`span`,{className:`ak-progress__step-dur`,children:[`· `,l]})]})})}function Cs({ackText:e,events:t=[],collapsed:n=!0,isComplete:r=!1,turnMeta:i,answerStartedAtMs:a}){let[o,s]=Y(!n);X(()=>{r&&s(!n)},[r]);let c=i?.mode;if(!r)return t.length===0?e?/* @__PURE__ */ Q(`ul`,{className:`ak-progress__list`,role:`list`,children:/* @__PURE__ */ Q(`li`,{className:`ak-progress__item ak-progress__item--active`,children:[/* @__PURE__ */ Q(`span`,{className:`ak-progress__spinner`,"aria-hidden":`true`}),/* @__PURE__ */ Q(`span`,{className:`ak-progress__text`,children:e})]})}):null:c===`detailed`?/* @__PURE__ */ Q(xs,{events:t,live:!0,answerStartedAtMs:a}):/* @__PURE__ */ Q(Ss,{events:t,answerStartedAtMs:a});let l=Qi(i?.totalMs),u=l?`Worked for ${l}`:`Finished working`;return c===`detailed`&&t.length>0?/* @__PURE__ */ Q(`div`,{className:`ak-progress`,children:[/* @__PURE__ */ Q(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`ak-progress__summary`,"aria-expanded":o,"aria-label":o?`Hide working steps`:`Show working steps`,children:[/* @__PURE__ */ Q(bs,{event:{stage:``,text:``,timestamp:``,status:`done`},active:!1}),/* @__PURE__ */ Q(`span`,{children:u}),/* @__PURE__ */ Q(`span`,{className:`ak-progress__step-dur`,children:[`· `,t.length,` step`,t.length===1?``:`s`]}),/* @__PURE__ */ Q(ys,{up:o})]}),o&&/* @__PURE__ */ Q(xs,{events:t,live:!1})]}):c===`standard`&&i?/* @__PURE__ */ Q(`div`,{className:`ak-progress`,children:/* @__PURE__ */ Q(`p`,{className:`ak-progress__summary ak-progress__summary--static`,children:[/* @__PURE__ */ Q(bs,{event:{stage:``,text:``,timestamp:``,status:`done`},active:!1}),/* @__PURE__ */ Q(`span`,{children:u})]})}):null}function ws(){return/* @__PURE__ */ Q(`svg`,{className:`ak-agent-status__icon`,width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:/* @__PURE__ */ Q(`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 Ts({status:e}){return/* @__PURE__ */ Q(`div`,{className:`ak-agent-status`,role:`status`,"aria-live":`polite`,children:[/* @__PURE__ */ Q(ws,{}),/* @__PURE__ */ Q(`span`,{className:`ak-agent-status__text`,children:e})]})}function Es({messageId:e,images:t,onCellClick:n}){if(t.length===0)return null;let r=t.length;if(r===1){let e=t[0];return/* @__PURE__ */ Q(`div`,{className:`ak-gallery ak-gallery--single`,children:[/* @__PURE__ */ Q(`button`,{type:`button`,onClick:()=>n(0),className:`ak-gallery__cell ak-gallery__cell--hero`,"aria-label":`Open image preview`,children:/* @__PURE__ */ Q(`img`,{src:e.src,alt:e.alt,className:`ak-gallery__img ak-gallery__img--contain`})}),/* @__PURE__ */ Q(`a`,{href:hs(e.downloadHref)??void 0,download:!0,className:`ak-message__image-dl-icon`,title:`Download image`,onClick:e=>e.stopPropagation(),children:/* @__PURE__ */ Q(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ Q(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),/* @__PURE__ */ Q(`polyline`,{points:`7 10 12 15 17 10`}),/* @__PURE__ */ Q(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]})})]})}if(r===2)return/* @__PURE__ */ Q(`div`,{className:`ak-gallery ak-gallery--two`,children:t.map((t,r)=>/* @__PURE__ */ Q(Ds,{src:t.src,alt:t.alt,onClick:()=>n(r)},t.key??`${e}-${r}`))});if(r===3)return/* @__PURE__ */ Q(`div`,{className:`ak-gallery ak-gallery--three`,children:[/* @__PURE__ */ Q(Ds,{src:t[0].src,alt:t[0].alt,onClick:()=>n(0)},t[0].key??`${e}-0`),/* @__PURE__ */ Q(`div`,{className:`ak-gallery__col`,children:[/* @__PURE__ */ Q(Ds,{src:t[1].src,alt:t[1].alt,onClick:()=>n(1)},t[1].key??`${e}-1`),/* @__PURE__ */ Q(Ds,{src:t[2].src,alt:t[2].alt,onClick:()=>n(2)},t[2].key??`${e}-2`)]})]});let i=t.slice(0,4),a=r>4?r-4:0;return/* @__PURE__ */ Q(`div`,{className:`ak-gallery ak-gallery--grid`,children:i.map((t,r)=>{let o=r===i.length-1;return/* @__PURE__ */ Q(Ds,{src:t.src,alt:t.alt,overlayCount:o&&a>0?a:0,onClick:()=>n(r)},t.key??`${e}-${r}`)})})}function Ds({src:e,alt:t,overlayCount:n=0,onClick:r}){return/* @__PURE__ */ Q(`button`,{type:`button`,onClick:r,className:`ak-gallery__cell`,"aria-label":`Open image preview`,children:[/* @__PURE__ */ Q(`img`,{src:e,alt:t,className:`ak-gallery__img`,loading:`lazy`}),n>0&&/* @__PURE__ */ Q(`span`,{className:`ak-gallery__overlay`,children:[`+`,n]})]})}function Os({images:e,index:t,onClose:n,onIndexChange:r}){let i=t!==null,a=i&&t!==null?Math.min(Math.max(0,t),e.length-1):0,o=i?e[a]:null;return X(()=>{if(!i)return;let t=t=>{t.key===`Escape`?(t.stopPropagation(),n()):t.key===`ArrowLeft`&&e.length>1?(t.preventDefault(),r((a-1+e.length)%e.length)):t.key===`ArrowRight`&&e.length>1&&(t.preventDefault(),r((a+1)%e.length))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[i,a,e.length,n,r]),!i||!o?null:/* @__PURE__ */ Q(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Image preview`,className:`ak-lightbox`,onClick:n,children:[/* @__PURE__ */ Q(`div`,{className:`ak-lightbox__toolbar`,onClick:e=>e.stopPropagation(),children:[e.length>1&&/* @__PURE__ */ Q(`span`,{className:`ak-lightbox__counter`,children:[a+1,` / `,e.length]}),/* @__PURE__ */ Q(`a`,{href:hs(o.downloadHref)??void 0,download:!0,target:`_blank`,rel:`noopener noreferrer`,className:`ak-lightbox__btn`,title:`Download image`,"aria-label":`Download image`,children:/* @__PURE__ */ Q(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ Q(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),/* @__PURE__ */ Q(`polyline`,{points:`7 10 12 15 17 10`}),/* @__PURE__ */ Q(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]})}),/* @__PURE__ */ Q(`button`,{type:`button`,onClick:n,className:`ak-lightbox__btn`,title:`Close`,"aria-label":`Close image preview`,children:/* @__PURE__ */ Q(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ Q(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),/* @__PURE__ */ Q(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]}),e.length>1&&/* @__PURE__ */ Q(K,{children:[/* @__PURE__ */ Q(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r((a-1+e.length)%e.length)},className:`ak-lightbox__nav ak-lightbox__nav--prev`,"aria-label":`Previous image`,children:/* @__PURE__ */ Q(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:/* @__PURE__ */ Q(`polyline`,{points:`15 18 9 12 15 6`})})}),/* @__PURE__ */ Q(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r((a+1)%e.length)},className:`ak-lightbox__nav ak-lightbox__nav--next`,"aria-label":`Next image`,children:/* @__PURE__ */ Q(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:/* @__PURE__ */ Q(`polyline`,{points:`9 18 15 12 9 6`})})})]}),/* @__PURE__ */ Q(`img`,{src:o.src,alt:o.alt??`Image preview`,className:`ak-lightbox__img`,onClick:e=>e.stopPropagation()})]})}function ks({url:e,mimeType:t,fileName:n}){let r=(()=>{if(n)return n;try{let t=new URL(e).pathname.split(`/`);return(t[t.length-1]||`attachment`).replace(/^\d{10,}-/,``)}catch{return`attachment`}})(),i=r.split(`.`).pop()?.toUpperCase()??``,a=t===`application/pdf`||i===`PDF`?{variant:`pdf`,label:`PDF`}:t===`text/csv`||i===`CSV`?{variant:`csv`,label:`CSV`}:t===`text/markdown`||i===`MD`?{variant:`md`,label:`MD`}:t===`text/plain`||i===`TXT`?{variant:`txt`,label:`TXT`}:{variant:`default`,label:i||`FILE`};return/* @__PURE__ */ Q(`a`,{href:hs(e)??void 0,target:`_blank`,rel:`noopener noreferrer`,className:`ak-file-chip`,title:r,children:[/* @__PURE__ */ Q(`span`,{className:`ak-file-chip__icon ak-file-chip__icon--${a.variant}`,"aria-hidden":!0,children:/* @__PURE__ */ Q(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ Q(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),/* @__PURE__ */ Q(`polyline`,{points:`14 2 14 8 20 8`})]})}),/* @__PURE__ */ Q(`span`,{className:`ak-file-chip__body`,children:[/* @__PURE__ */ Q(`span`,{className:`ak-file-chip__name`,children:r}),/* @__PURE__ */ Q(`span`,{className:`ak-file-chip__label`,children:a.label})]})]})}function As({url:e,mimeType:t,transcript:n}){return/* @__PURE__ */ Q(`div`,{className:`ak-audio-chip`,children:[/* @__PURE__ */ Q(`audio`,{controls:!0,src:e,className:`ak-audio-chip__player`,"aria-label":`Voice note`,children:/* @__PURE__ */ Q(`source`,{src:e,type:t})}),n&&/* @__PURE__ */ Q(`p`,{className:`ak-audio-chip__transcript`,children:n})]})}function js(e){try{return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}catch{return``}}var Ms=/(`[^`\n]+`|\*\*[^*\n]+\*\*|\*[^*\n]+\*|!\[[^\]\n]*\]\([^)\n]+\)|\[[^\]\n]+\]\([^)\n]+\))/g;function $(e){let t=[],n=0,r=0;Ms.lastIndex=0;let i;for(;(i=Ms.exec(e))!==null;){i.index>n&&t.push(e.slice(n,i.index));let a=i[0];if(a.startsWith("`"))t.push(/* @__PURE__ */ Q(`code`,{className:`ak-md-ic`,children:a.slice(1,-1)},r++));else if(a.startsWith(`**`))t.push(/* @__PURE__ */ Q(`strong`,{children:a.slice(2,-2)},r++));else if(a.startsWith(`*`))t.push(/* @__PURE__ */ Q(`em`,{children:a.slice(1,-1)},r++));else if(a.startsWith(`![`)){let e=a.match(/!\[([^\]]*)\]\(([^)]+)\)/),n=hs(e?.[2]);e&&n?t.push(/* @__PURE__ */ Q(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,children:e[1]||`image`},r++)):e&&t.push(e[1]||`image`)}else{let e=a.match(/\[(.+?)\]\((.+?)\)/),n=hs(e?.[2]);e&&n?t.push(/* @__PURE__ */ Q(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,children:e[1]},r++)):e?t.push(e[1]):t.push(a)}n=i.index+a.length}return n<e.length&&t.push(e.slice(n)),t}function Ns(e){e=gs(e);let t=e.split(`
|
|
2062
|
+
`),n=[],r=0,i=0;for(;r<t.length;){let e=t[r],a=e.match(/^(\s*)```/);if(a){let o=a[1],s=e.trimStart().match(/^```(\w+)?\s*$/)?.[1]||``,c=[];for(r++;r<t.length&&!t[r].trimStart().startsWith("```");)c.push(t[r].startsWith(o)?t[r].slice(o.length):t[r]),r++;r<t.length&&t[r].trimStart().startsWith("```")&&r++,n.push(/* @__PURE__ */ Q(`div`,{className:`ak-md-pre-wrap`,children:[s&&/* @__PURE__ */ Q(`span`,{className:`ak-md-pre-lang`,children:s}),/* @__PURE__ */ Q(`pre`,{className:`ak-md-pre${s?` ak-md-pre--${s}`:``}`,children:/* @__PURE__ */ Q(`code`,{className:`ak-md-code`,children:c.join(`
|
|
2063
|
+
`)})})]},i++));continue}let o=e.match(/^(#{1,6})(\s+.*)?$/);if(o){let e=o[1].length,t=o[2]?$(o[2].trim()):``;e===1?n.push(/* @__PURE__ */ Q(`h1`,{className:`ak-md-h1`,children:t},i++)):e===2?n.push(/* @__PURE__ */ Q(`h2`,{className:`ak-md-h2`,children:t},i++)):e===3?n.push(/* @__PURE__ */ Q(`h3`,{className:`ak-md-h3`,children:t},i++)):e===4?n.push(/* @__PURE__ */ Q(`h4`,{className:`ak-md-h4`,children:t},i++)):e===5?n.push(/* @__PURE__ */ Q(`h5`,{className:`ak-md-h5`,children:t},i++)):n.push(/* @__PURE__ */ Q(`h6`,{className:`ak-md-h6`,children:t},i++)),r++;continue}if(/^[-*_]{3,}$/.test(e.trim())){n.push(/* @__PURE__ */ Q(`hr`,{className:`ak-md-hr`},i++)),r++;continue}if(/^[-*+]\s/.test(e)){let e=[],a=r;for(;a<t.length&&(/^[-*+]\s/.test(t[a])||t[a].trim()===``);){if(t[a].trim()===``){a++;continue}let n=t[a].length-t[a].trimStart().length,r=t[a].replace(/^[-*+]\s+/,``),i=[],o=[],s=a+1;for(;s<t.length&&s<a+20;){let e=t[s];if(e.length-e.trimStart().length>n&&e.trim()!==``){let t=e.trim();/^[-*+]\s/.test(t)?i.push(/* @__PURE__ */ Q(`li`,{children:$(t.replace(/^[-*+]\s+/,``))},`nested-${s}`)):o.push(/* @__PURE__ */ Q(`p`,{style:{margin:`0.2em 0 0`},children:$(t)},`cont-${s}`)),s++}else break}let c=o.length>0||i.length>0?/* @__PURE__ */ Q(K,{children:[$(r),o,i.length>0&&/* @__PURE__ */ Q(`ul`,{style:{margin:`0.2em 0 0`,paddingLeft:`1.2em`},children:i})]}):$(r);e.push(/* @__PURE__ */ Q(`li`,{children:c},`item-${a}`)),a=s}n.push(/* @__PURE__ */ Q(`ul`,{className:`ak-md-ul`,children:e},i++)),r=a;continue}if(/^\d+\.\s/.test(e)){let e=[],a=r;for(;a<t.length&&(/^\d+\.\s/.test(t[a])||t[a].trim()===``);){if(t[a].trim()===``){a++;continue}let n=t[a].length-t[a].trimStart().length,r=t[a].replace(/^\d+\.\s+/,``),i=[],o=[],s=a+1;for(;s<t.length&&s<a+20;){let e=t[s];if(e.length-e.trimStart().length>n&&e.trim()!==``){let t=e.trim();/^\d+\.\s/.test(t)?i.push(/* @__PURE__ */ Q(`li`,{children:$(t.replace(/^\d+\.\s+/,``))},`nested-order-${s}`)):/^[-*+]\s/.test(t)?i.push(/* @__PURE__ */ Q(`li`,{children:$(t.replace(/^[-*+]\s+/,``))},`nested-unorder-${s}`)):o.push(/* @__PURE__ */ Q(`p`,{style:{margin:`0.2em 0 0`},children:$(t)},`cont-${s}`)),s++}else break}let c=o.length>0||i.length>0?/* @__PURE__ */ Q(K,{children:[$(r),o,i.length>0&&/* @__PURE__ */ Q(`ol`,{style:{margin:`0.2em 0 0`,paddingLeft:`1.2em`},children:i})]}):$(r);e.push(/* @__PURE__ */ Q(`li`,{children:c},`order-item-${a}`)),a=s}n.push(/* @__PURE__ */ Q(`ol`,{className:`ak-md-ol`,children:e},i++)),r=a;continue}if(e.trim()===``){r++;continue}if(e.includes(`|`)&&r+1<t.length&&t[r+1].includes(`|`)){let a=t[r+1];if(/^\s*\|?[\s:|*-]+\|[\s:|*-|]+\|?[\s:|*-]*$/.test(a)){let o=e.split(`|`).map(e=>e.trim()).filter(e=>e.length>0),s=a.split(`|`).map(e=>{let t=e.trim();return t.startsWith(`:`)&&t.endsWith(`:`)?`center`:t.endsWith(`:`)?`right`:(t.startsWith(`:`),`left`)}).filter((e,t)=>t>0&&t<=o.length),c=[],l=r+2;for(;l<t.length&&t[l].includes(`|`)&&t[l].trim()!==``;){let e=t[l].split(`|`).map(e=>e.trim()).filter(e=>e.length>0);if(e.length>0)c.push(e),l++;else break}n.push(/* @__PURE__ */ Q(`table`,{className:`ak-md-table`,children:[/* @__PURE__ */ Q(`thead`,{children:/* @__PURE__ */ Q(`tr`,{children:o.map((e,t)=>/* @__PURE__ */ Q(`th`,{style:{textAlign:s[t]||`left`},className:`ak-md-th`,children:$(e)},`th-${t}`))})}),/* @__PURE__ */ Q(`tbody`,{children:c.map((e,t)=>/* @__PURE__ */ Q(`tr`,{children:o.map((n,r)=>/* @__PURE__ */ Q(`td`,{style:{textAlign:s[r]||`left`},className:`ak-md-td`,children:e[r]?$(e[r]):``},`td-${t}-${r}`))},`tr-${t}`))})]},i++)),r=l;continue}}let s=[];for(;r<t.length&&t[r].trim()!==``&&!t[r].startsWith(`#`)&&!/^\s*```/.test(t[r])&&!/^[-*+]\s/.test(t[r])&&!/^\d+\.\s/.test(t[r])&&!/^[-*_]{3,}$/.test(t[r].trim());)s.push(t[r]),r++;if(s.length>0){let e=[];s.forEach((t,n)=>{e.push(...$(t)),n<s.length-1&&e.push(/* @__PURE__ */ Q(`br`,{},`br-${n}`))}),n.push(/* @__PURE__ */ Q(`p`,{className:`ak-md-p`,children:e},i++))}}return/* @__PURE__ */ Q(K,{children:n})}function Ps({message:e}){let[t,n]=Y(null),[r,i]=Y(null),a=e.role===`user`,o=e.status===`error`,s=e.status===`streaming`,c=!!(e.images&&e.images.length>0),l=!!(e.documents&&e.documents.length>0),u=(()=>{if(!a)return[];let t=(e.uploadedAttachments??[]).filter(e=>e.kind===`image`).map(e=>({url:e.url,mimeType:e.mimeType,fileName:e.fileName}));return t.length>0?t:e.uploadedImageUrl?[{url:e.uploadedImageUrl,mimeType:`image/jpeg`}]:[]})(),d=a?(e.uploadedAttachments??[]).filter(e=>e.kind===`file`):[],f=a?(e.uploadedAttachments??[]).filter(e=>e.kind===`audio`):[],p=u.length>0,m=d.length>0,h=f.length>0,g=c||p,_=a&&h?ta(e.content):null,v=_?_.rest:e.content,y=!!e.progressEvents&&e.progressEvents.length>0,b=s&&!e.content&&!e.toolStatus&&!y,x=!a&&!o,S=!!e.isHuman&&!a,C=a?`ak-message--user`:o?`ak-message--assistant ak-message--error`:S?`ak-message--assistant ak-message--operator`:`ak-message--assistant`,w=[`ak-message__bubble`,x?`ak-message__bubble--md`:``,g?`ak-message__bubble--has-image`:``,S?`ak-message__bubble--operator`:``].filter(Boolean).join(` `),T=S?e.senderDisplay?.trim()||`Operator`:null,E=T?T.charAt(0).toUpperCase():``,ee=/* @__PURE__ */ Q(`div`,{className:w,children:[p&&/* @__PURE__ */ Q(Es,{messageId:`${e.id}-up`,images:u.map(e=>({src:e.url,alt:e.fileName??`Uploaded image`,downloadHref:e.url})),onCellClick:e=>n(e)}),m&&/* @__PURE__ */ Q(`div`,{className:`ak-message__files`,children:d.map((t,n)=>/* @__PURE__ */ Q(ks,{url:t.url,mimeType:t.mimeType,fileName:t.fileName},`${e.id}-up-file-${n}`))}),h&&/* @__PURE__ */ Q(`div`,{className:`ak-message__files`,children:f.map((t,n)=>/* @__PURE__ */ Q(As,{url:t.url,mimeType:t.mimeType,transcript:n===0?_?.transcript??null:null},`${e.id}-up-audio-${n}`))}),c&&/* @__PURE__ */ Q(Es,{messageId:`${e.id}-asst`,images:e.images.map((e,t)=>{let n=e.url??(e.base64?`data:${e.mimeType};base64,${e.base64}`:null);return n?{src:n,alt:`Generated image`,downloadHref:e.url??n,key:`gen-${t}`}:null}).filter(e=>e!==null),onCellClick:e=>i(e)}),l&&/* @__PURE__ */ Q(`div`,{className:`ak-message__files`,children:e.documents.map((t,n)=>t.url?/* @__PURE__ */ Q(ks,{url:t.url,mimeType:t.mimeType,fileName:t.fileName},`${e.id}-asst-doc-${n}`):null)}),v&&/* @__PURE__ */ Q(`div`,{className:g?`ak-message__image-caption`:void 0,children:[x?Ns(v):v,s&&/* @__PURE__ */ Q(`span`,{className:`ak-cursor`,"aria-hidden":`true`,children:[/* @__PURE__ */ Q(`span`,{className:`ak-cursor__dot`}),/* @__PURE__ */ Q(`span`,{className:`ak-cursor__dot`}),/* @__PURE__ */ Q(`span`,{className:`ak-cursor__dot`})]})]}),/* @__PURE__ */ Q(`span`,{className:`ak-message__time`,children:js(e.createdAt)})]}),D=!!e.content||g||m||l||!s&&!e.toolStatus;return/* @__PURE__ */ Q(`div`,{className:`ak-message ${C}`,children:[!a&&(e.ackText||e.progressEvents&&e.progressEvents.length>0||e.turnMeta)&&/* @__PURE__ */ Q(Cs,{ackText:e.ackText,events:e.progressEvents,collapsed:e.progressCollapsed,isComplete:!s,turnMeta:e.turnMeta,answerStartedAtMs:e.answerStartedAtMs}),b&&/* @__PURE__ */ Q(`div`,{className:`ak-typing-row`,role:`status`,"aria-label":`Assistant is typing`,children:[/* @__PURE__ */ Q(`span`,{className:`ak-typing-row__dot`}),/* @__PURE__ */ Q(`span`,{className:`ak-typing-row__dot`}),/* @__PURE__ */ Q(`span`,{className:`ak-typing-row__dot`})]}),!a&&e.toolStatus&&!(e.progressEvents&&e.progressEvents.length>0)&&/* @__PURE__ */ Q(Ts,{status:e.toolStatus}),S&&/* @__PURE__ */ Q(`span`,{className:`ak-message__sender-label`,children:[/* @__PURE__ */ Q(`span`,{className:`ak-message__operator-avatar`,"aria-hidden":`true`,children:E}),/* @__PURE__ */ Q(`span`,{className:`ak-message__operator-name`,children:T})]}),D&&ee,u.length>0&&/* @__PURE__ */ Q(Os,{images:u.map(e=>({src:e.url,alt:e.fileName??`Uploaded image`,downloadHref:e.url})),index:t,onClose:()=>n(null),onIndexChange:n}),c&&/* @__PURE__ */ Q(Os,{images:e.images.map(e=>{let t=e.url??(e.base64?`data:${e.mimeType};base64,${e.base64}`:null);return t?{src:t,alt:`Generated image`,downloadHref:e.url??t}:null}).filter(e=>e!==null),index:r,onClose:()=>i(null),onIndexChange:i})]})}function Fs(){return/* @__PURE__ */ Q(`div`,{className:`ak-typing`,"aria-label":`Assistant is typing`,children:[/* @__PURE__ */ Q(`span`,{className:`ak-typing__dot`}),/* @__PURE__ */ Q(`span`,{className:`ak-typing__dot`}),/* @__PURE__ */ Q(`span`,{className:`ak-typing__dot`})]})}function Is(e,t){let n=[],r=null;for(let i of e){if(i.role===`assistant`){let e=!!i.isHuman;r!==null&&r!==e&&n.push({kind:`divider`,id:`divider-${i.id}`,label:e?`${i.senderDisplay?.trim()||t} joined the chat`:`${t} left — AI is back`}),r=e}n.push({kind:`message`,message:i})}return n}function Ls({messages:e,isLoading:t,operatorFallbackLabel:n=`Operator`}){let r=Z(null),i=Z(null),a=Z(!0),o=Eo(()=>Is(e,n),[e,n]);return X(()=>{if(!(r.current?.parentElement??r.current))return;let e=e=>{a.current=e.scrollHeight-e.scrollTop-e.clientHeight<120},t=r.current;for(;t&&getComputedStyle(t).overflowY===`visible`;)t=t.parentElement;if(!t)return;let n=()=>e(t);return t.addEventListener(`scroll`,n,{passive:!0}),()=>t.removeEventListener(`scroll`,n)},[]),X(()=>{e[e.length-1]?.role===`user`&&(a.current=!0),a.current&&i.current?.scrollIntoView({behavior:`smooth`})},[e]),X(()=>{a.current&&i.current?.scrollIntoView({behavior:`smooth`})},[t,e.find(e=>e.status===`streaming`)?.content??``]),/* @__PURE__ */ Q(`div`,{ref:r,className:`ak-messages`,role:`log`,"aria-live":`polite`,"aria-label":`Conversation`,children:[o.map(e=>e.kind===`divider`?/* @__PURE__ */ Q(`div`,{className:`ak-handoff-divider`,role:`separator`,children:/* @__PURE__ */ Q(`span`,{className:`ak-handoff-divider__label`,children:e.label})},e.id):/* @__PURE__ */ Q(Ps,{message:e.message},e.message.id)),t&&!e.some(e=>e.status===`streaming`)&&/* @__PURE__ */ Q(Fs,{}),/* @__PURE__ */ Q(`div`,{ref:i})]})}function Rs(){return/* @__PURE__ */ Q(`svg`,{width:`30`,height:`30`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[/* @__PURE__ */ Q(`rect`,{x:`3`,y:`11`,width:`18`,height:`10`,rx:`2`}),/* @__PURE__ */ Q(`circle`,{cx:`12`,cy:`5`,r:`2`}),/* @__PURE__ */ Q(`path`,{d:`M12 7v4`}),/* @__PURE__ */ Q(`line`,{x1:`8`,y1:`16`,x2:`8`,y2:`16`}),/* @__PURE__ */ Q(`line`,{x1:`16`,y1:`16`,x2:`16`,y2:`16`})]})}function zs({title:e,description:t,suggestedQuestions:n,avatarUrl:r,onSelect:i}){let a=(n??[]).filter(e=>(e.title??``).trim().length>0);return/* @__PURE__ */ Q(`div`,{className:`ak-empty-state`,"aria-label":`Start a conversation`,children:[/* @__PURE__ */ Q(`div`,{className:`ak-empty-state__glow`,"aria-hidden":`true`}),/* @__PURE__ */ Q(`div`,{className:`ak-empty-state__body`,children:[/* @__PURE__ */ Q(`div`,{className:`ak-empty-state__avatar`,children:r?/* @__PURE__ */ Q(`img`,{src:r,alt:``,className:`ak-empty-state__avatar-img`,"aria-hidden":`true`}):/* @__PURE__ */ Q(`span`,{className:`ak-empty-state__bot-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ Q(Rs,{})})}),/* @__PURE__ */ Q(`p`,{className:`ak-empty-state__title`,children:e}),t&&/* @__PURE__ */ Q(`p`,{className:`ak-empty-state__description`,children:t})]}),a.length>0&&/* @__PURE__ */ Q(`div`,{className:`ak-empty-state__suggestions`,children:a.map((e,t)=>/* @__PURE__ */ Q(`button`,{className:`ak-empty-state__suggestion`,onClick:()=>i?.(e.prompt??e.title),type:`button`,children:[/* @__PURE__ */ Q(`span`,{className:`ak-empty-state__suggestion-title`,children:e.title}),e.description&&/* @__PURE__ */ Q(`span`,{className:`ak-empty-state__suggestion-desc`,children:e.description})]},t))})]})}var Bs=`https://klicforge.ai/privacy-policy`,Vs=`https://klicforge.ai/terms-of-service`;function Hs(){return/* @__PURE__ */ Q(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ Q(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`5`}),/* @__PURE__ */ Q(`polyline`,{points:`5 12 12 5 19 12`})]})}function Us(){return/* @__PURE__ */ Q(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[/* @__PURE__ */ Q(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),/* @__PURE__ */ Q(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]})}function Ws(){return/* @__PURE__ */ Q(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ Q(`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`}),/* @__PURE__ */ Q(`circle`,{cx:`12`,cy:`13`,r:`4`})]})}function Gs(){return/* @__PURE__ */ Q(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ Q(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),/* @__PURE__ */ Q(`polyline`,{points:`14 2 14 8 20 8`})]})}function Ks(){return/* @__PURE__ */ Q(`svg`,{width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ Q(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),/* @__PURE__ */ Q(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})}function qs(){return/* @__PURE__ */ Q(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ Q(`path`,{d:`M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z`}),/* @__PURE__ */ Q(`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`}),/* @__PURE__ */ Q(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`23`}),/* @__PURE__ */ Q(`line`,{x1:`8`,y1:`23`,x2:`16`,y2:`23`})]})}function Js(){return/* @__PURE__ */ Q(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`currentColor`,children:/* @__PURE__ */ Q(`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`})})}var Ys=[`application/pdf`,`text/markdown`,`text/plain`,`text/csv`],Xs=[`.pdf`,`.md`,`.txt`,`.csv`],Zs=[...Xs,...Ys].join(`,`),Qs=[`image/jpeg`,`image/png`,`image/gif`,`image/webp`],$s=Qs.join(`,`),ec=[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg;codecs=opus`];function tc(){return typeof MediaRecorder>`u`?null:ec.find(e=>MediaRecorder.isTypeSupported(e))??null}function nc(e){return e.includes(`mp4`)?`mp4`:e.includes(`ogg`)?`ogg`:`webm`}function rc(e){let t=Math.floor(e/1e3),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,`0`)}`}function ic(e){if(Ys.includes(e.type))return!0;let t=e.name.toLowerCase();return Xs.some(e=>t.endsWith(e))}function ac(e){return Qs.includes(e.type)}function oc({onSend:e,disabled:t=!1,placeholder:n=`Type a message…`,photoSendingEnabled:r=!1,fileUploadEnabled:i=!1,voiceNoteEnabled:a=!1,voiceNoteMaxDurationSec:o=120,attachmentMaxCount:s=5,attachmentMaxFileSizeMb:c=1,onRecordingError:l}){let[u,d]=Y(``),[f,p]=Y([]),[m,h]=Y(/* @__PURE__ */ new Map),[g,_]=Y(!1),[v,y]=Y(!1),[b,x]=Y(0),S=Z(null),C=Z(null),w=Z(null),T=Z(null),E=Z(null),ee=Z(null),D=Z(null),te=Z([]),ne=Z(null),re=Z(0),ie=Z(null),ae=Z(!1),oe=Z(!1),se=Z(u);se.current=u;let ce=Z(f);ce.current=f;let le=Z(t);le.current=t;let ue=r||i,de=Eo(()=>c*1024*1024,[c]),fe=a&&typeof window<`u`&&typeof MediaRecorder<`u`&&!!navigator.mediaDevices?.getUserMedia;X(()=>()=>{m.forEach(e=>URL.revokeObjectURL(e))},[]);let pe=Z(null);X(()=>{if(t)return;let e=pe.current;pe.current=t,e===null&&typeof window<`u`&&window.matchMedia?.(`(pointer: coarse)`).matches||S.current?.focus()},[t]);let me=Z(!1);X(()=>{v?ee.current?.focus():me.current&&!le.current&&S.current?.focus(),me.current=v},[v]);let he=Do(e=>{if(!g)return;let t=e.composedPath?e.composedPath():[],n=!!T.current&&t.includes(T.current),r=!!E.current&&t.includes(E.current);!n&&!r&&_(!1)},[g]);X(()=>{if(g)return document.addEventListener(`click`,he),()=>document.removeEventListener(`click`,he)},[g,he]),X(()=>{ue||_(!1)},[ue]);function ge(){m.forEach(e=>URL.revokeObjectURL(e)),h(/* @__PURE__ */ new Map),p([]),C.current&&(C.current.value=``),w.current&&(w.current.value=``)}function _e(e){p(t=>{let n=t[e];if(n){let e=m.get(n.file);e&&(URL.revokeObjectURL(e),h(e=>{let t=new Map(e);return t.delete(n.file),t}))}return t.filter((t,n)=>n!==e)})}function ve(){let n=u.trim();!n&&f.length===0||t||(e(n,f),d(``),ge(),S.current&&(S.current.style.height=`auto`))}let ye=Do(()=>{ne.current?.getTracks().forEach(e=>e.stop()),ne.current=null},[]);X(()=>()=>{ie.current&&clearInterval(ie.current),D.current&&D.current.state!==`inactive`&&(ae.current=!0,D.current.stop()),ye()},[ye]);async function be(){if(!fe||v||oe.current||t)return;if(f.length>=s){l?.(`Only ${s} attachments can be sent at once`);return}let n=tc();if(!n){l?.(`Voice recording is not supported in this browser`);return}oe.current=!0;let r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{oe.current=!1,l?.(`Microphone access was denied`);return}oe.current=!1,ne.current=r,te.current=[],ae.current=!1;let i=new MediaRecorder(r,{mimeType:n});i.ondataavailable=e=>{e.data.size>0&&te.current.push(e.data)},i.onstop=()=>{ye();let t=ae.current,r=Date.now()-re.current,i=new Blob(te.current,{type:n});if(te.current=[],t||r<300||le.current)return;let a=new File([i],`voice-note.${nc(n)}`,{type:n}),o=se.current.trim(),c=[...ce.current,{file:a,kind:`audio`,durationMs:r}];c.length>s?l?.(`Only ${s} attachments can be sent at once`):(e(o,c),d(``),ge(),S.current&&(S.current.style.height=`auto`))},D.current=i,re.current=Date.now(),x(0),i.start(),y(!0),ie.current=setInterval(()=>{let e=Date.now()-re.current;x(e),e>=o*1e3&&xe(!1)},250)}function xe(e){ie.current&&=(clearInterval(ie.current),null),ae.current=e,D.current&&D.current.state!==`inactive`&&D.current.stop(),y(!1),x(0)}function Se(e){e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ve())}function Ce(e){let t=e.currentTarget;d(t.value),t.style.height=`auto`,t.style.height=`${t.scrollHeight}px`}function we(e,t){if(e.length===0)return;let n=[],r=[];for(let i of e)t===`image`&&!ac(i)?r.push(`${i.name} (image type not supported)`):t===`file`&&!ic(i)?r.push(`${i.name} (file type not supported)`):i.size>de?r.push(`${i.name} (over ${c} MB)`):n.push({file:i,kind:t});p(e=>{let t=[...e,...n],i=t.slice(0,s);return t.length>s&&r.push(`max ${s} attachments allowed`),h(e=>{let t=new Map(e);for(let e of i)e.kind===`image`&&!t.has(e.file)&&t.set(e.file,URL.createObjectURL(e.file));return t}),i}),r.length>0&&alert(`Some attachments were not added:\n• ${r.join(`
|
|
2064
|
+
• `)}`)}function Te(e){let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,we(t,`image`)}function Ee(e){let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,we(t,`file`)}function De(){_(!1),C.current?.click()}function Oe(){_(!1),w.current?.click()}let ke=!t&&(!!u.trim()||f.length>0);return/* @__PURE__ */ Q(`div`,{className:`ak-composer`,children:[ue&&g&&/* @__PURE__ */ Q(`div`,{ref:T,className:`ak-composer__attach-menu`,role:`menu`,children:[r&&/* @__PURE__ */ Q(`button`,{className:`ak-composer__attach-menu-item`,onClick:De,type:`button`,role:`menuitem`,disabled:t,children:[/* @__PURE__ */ Q(Ws,{}),/* @__PURE__ */ Q(`span`,{children:`Photo`})]}),i&&/* @__PURE__ */ Q(`button`,{className:`ak-composer__attach-menu-item`,onClick:Oe,type:`button`,role:`menuitem`,disabled:t,children:[/* @__PURE__ */ Q(Gs,{}),/* @__PURE__ */ Q(`span`,{children:`File`})]})]}),f.length>0&&/* @__PURE__ */ Q(`div`,{className:`ak-composer__attachments`,role:`list`,children:f.map((e,n)=>{let r=`${e.file.name}-${n}`;if(e.kind===`image`){let i=m.get(e.file);return/* @__PURE__ */ Q(`div`,{className:`ak-composer__preview-wrap`,role:`listitem`,children:[i&&/* @__PURE__ */ Q(`img`,{src:i,alt:e.file.name,className:`ak-composer__preview-img`}),/* @__PURE__ */ Q(`button`,{className:`ak-composer__preview-remove`,onClick:()=>_e(n),type:`button`,"aria-label":`Remove ${e.file.name}`,disabled:t,children:/* @__PURE__ */ Q(Ks,{})})]},r)}return/* @__PURE__ */ Q(`span`,{className:`ak-composer__file-chip`,role:`listitem`,children:[/* @__PURE__ */ Q(Gs,{}),/* @__PURE__ */ Q(`span`,{className:`ak-composer__file-chip-name`,title:e.file.name,children:e.file.name}),/* @__PURE__ */ Q(`button`,{className:`ak-composer__file-chip-remove`,onClick:()=>_e(n),type:`button`,"aria-label":`Remove ${e.file.name}`,disabled:t,children:/* @__PURE__ */ Q(Ks,{})})]},r)})}),ue&&/* @__PURE__ */ Q(K,{children:[r&&/* @__PURE__ */ Q(`input`,{ref:C,type:`file`,multiple:!0,accept:$s,className:`ak-composer__file-input`,onChange:Te,disabled:t,"aria-label":`Attach images`}),i&&/* @__PURE__ */ Q(`input`,{ref:w,type:`file`,multiple:!0,accept:Zs,className:`ak-composer__file-input`,onChange:Ee,disabled:t,"aria-label":`Attach files`})]}),/* @__PURE__ */ Q(`div`,{className:`ak-composer__input-wrap`,children:v?/* @__PURE__ */ Q(`div`,{className:`ak-composer__recording`,children:[/* @__PURE__ */ Q(`button`,{className:`ak-composer__recording-cancel`,onClick:()=>xe(!0),"aria-label":`Cancel recording`,type:`button`,children:/* @__PURE__ */ Q(Ks,{})}),/* @__PURE__ */ Q(`span`,{className:`ak-composer__recording-timer`,children:[/* @__PURE__ */ Q(`span`,{className:`ak-composer__recording-dot`}),rc(b)]}),/* @__PURE__ */ Q(`button`,{ref:ee,className:`ak-composer__recording-stop`,onClick:()=>xe(!1),"aria-label":`Stop recording`,type:`button`,children:/* @__PURE__ */ Q(Js,{})})]}):/* @__PURE__ */ Q(K,{children:[/* @__PURE__ */ Q(`div`,{className:`ak-composer__row`,children:[/* @__PURE__ */ Q(`textarea`,{ref:S,className:`ak-composer__input`,value:u,onInput:Ce,onKeyDown:Se,placeholder:n,disabled:t,rows:1,"aria-label":`Message input`}),fe&&/* @__PURE__ */ Q(`button`,{className:`ak-composer__mic`,onClick:()=>void be(),disabled:t||f.length>=s,"aria-label":f.length>=s?`Only ${s} attachments can be sent at once`:`Record a voice note`,title:f.length>=s?`Only ${s} attachments can be sent at once`:`Record a voice note`,type:`button`,children:/* @__PURE__ */ Q(qs,{})})]}),/* @__PURE__ */ Q(`div`,{className:`ak-composer__toolbar`,children:[ue&&/* @__PURE__ */ Q(`div`,{className:`ak-composer__attach-wrap`,children:/* @__PURE__ */ Q(`button`,{ref:E,className:`ak-composer__attach${g?` ak-composer__attach--open`:``}`,onClick:()=>_(e=>!e),disabled:t,"aria-label":`Attachment options`,"aria-haspopup":`true`,"aria-expanded":g,type:`button`,children:/* @__PURE__ */ Q(Us,{})})}),/* @__PURE__ */ Q(`button`,{className:`ak-composer__send`,onClick:ve,disabled:!ke,"aria-label":`Send message`,type:`button`,children:/* @__PURE__ */ Q(Hs,{})})]})]})}),/* @__PURE__ */ Q(`p`,{className:`ak-composer__disclaimer`,children:[`By chatting you agree to our`,` `,/* @__PURE__ */ Q(`a`,{href:Bs,target:`_blank`,rel:`noopener noreferrer`,children:`Privacy Policy`}),` `,`and`,` `,/* @__PURE__ */ Q(`a`,{href:Vs,target:`_blank`,rel:`noopener noreferrer`,children:`Terms of Service`}),`. `,`AI can make mistakes. Verify important information.`]})]})}function sc({message:e}){return e.includes(`Origin not allowed`)?/* @__PURE__ */ Q(`div`,{className:`ak-error ak-error--origin`,role:`alert`,children:[/* @__PURE__ */ Q(`div`,{className:`ak-error__icon`,children:`🔒`}),/* @__PURE__ */ Q(`div`,{className:`ak-error__content`,children:[/* @__PURE__ */ Q(`h3`,{className:`ak-error__title`,children:`Access Restricted`}),/* @__PURE__ */ Q(`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.`})]})]}):/* @__PURE__ */ Q(`div`,{className:`ak-error`,role:`alert`,children:[/* @__PURE__ */ Q(`div`,{className:`ak-error__icon`,children:`⚠️`}),/* @__PURE__ */ Q(`div`,{className:`ak-error__content`,children:/* @__PURE__ */ Q(`p`,{className:`ak-error__message`,children:e})})]})}function cc(){return/* @__PURE__ */ Q(`svg`,{width:`28`,height:`28`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[/* @__PURE__ */ Q(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ Q(`path`,{d:`M12 7v5l3 2`})]})}function lc(){return/* @__PURE__ */ Q(`div`,{className:`ak-maintenance`,role:`status`,"aria-live":`polite`,children:[/* @__PURE__ */ Q(`div`,{className:`ak-maintenance__halo`,"aria-hidden":`true`}),/* @__PURE__ */ Q(`div`,{className:`ak-maintenance__icon`,children:/* @__PURE__ */ Q(cc,{})}),/* @__PURE__ */ Q(`p`,{className:`ak-maintenance__title`,children:`Under maintenance`}),/* @__PURE__ */ Q(`p`,{className:`ak-maintenance__description`,children:`This assistant is temporarily unavailable. Please check back in a little while.`})]})}function uc(){return/* @__PURE__ */ Q(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,className:`ak-branding__logo`,children:[/* @__PURE__ */ Q(`rect`,{width:`24`,height:`24`,rx:`5`,fill:`currentColor`}),/* @__PURE__ */ Q(`path`,{d:`M12 5L7 13h3.5v6l6.5-9H13.5V5z`,fill:`white`})]})}function dc(){return/* @__PURE__ */ Q(`div`,{className:`ak-branding`,children:[/* @__PURE__ */ Q(uc,{}),/* @__PURE__ */ Q(`span`,{className:`ak-branding__label`,children:`Powered by`}),/* @__PURE__ */ Q(`span`,{className:`ak-branding__name`,children:`KlicForge`})]})}function fc({config:e,messages:t,isLoading:n,error:r,isInline:i,initStatus:a,initError:o,callbacks:s}){let[c,l]=Y(null);return/* @__PURE__ */ Q(`div`,{className:i?`ak-shell-wrap`:`ak-shell-wrap ak-shell-enter`,children:[/* @__PURE__ */ Q(`div`,{className:i?`ak-shell ak-shell--inline`:`ak-shell ak-shell--floating`,role:`dialog`,"aria-label":e.title,children:[/* @__PURE__ */ Q(ms,{title:e.title,subtitle:e.subtitle,avatarUrl:e.avatarUrl,onClose:s.onClose,onReset:a===`ready`?s.onReset:void 0,hideClose:i}),a===`validating`&&/* @__PURE__ */ Q(`div`,{className:`ak-init-status`,children:/* @__PURE__ */ Q(`div`,{className:`ak-init-spinner`,"aria-label":`Connecting…`})}),a===`error`&&/* @__PURE__ */ Q(`div`,{className:`ak-init-status ak-init-status--error`,children:/* @__PURE__ */ Q(sc,{message:o??`Widget configuration is invalid.`})}),a===`disabled`&&/* @__PURE__ */ Q(`div`,{className:`ak-init-status ak-init-status--maintenance`,children:/* @__PURE__ */ Q(lc,{})}),a===`ready`&&/* @__PURE__ */ Q(K,{children:[t.length===0?/* @__PURE__ */ Q(zs,{title:e.title,description:e.description??e.subtitle,suggestedQuestions:e.suggestedQuestions,avatarUrl:e.avatarUrl,onSelect:e=>s.onSendMessage(e,[])}):/* @__PURE__ */ Q(Ls,{messages:t,isLoading:n}),(r||c)&&/* @__PURE__ */ Q(sc,{message:r??c}),/* @__PURE__ */ Q(oc,{onSend:(e,t)=>{l(null),s.onSendMessage(e,t)},onRecordingError:l,disabled:n,placeholder:`Type a message…`,photoSendingEnabled:e.photoSendingEnabled,fileUploadEnabled:e.fileUploadEnabled,voiceNoteEnabled:e.voiceNoteEnabled,voiceNoteMaxDurationSec:e.voiceNoteMaxDurationSec,attachmentMaxCount:e.attachmentMaxCount,attachmentMaxFileSizeMb:e.attachmentMaxFileSizeMb})]})]}),!i&&/* @__PURE__ */ Q(dc,{})]})}function pc(){return/* @__PURE__ */ Q(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:/* @__PURE__ */ Q(`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 mc(){return/* @__PURE__ */ Q(`svg`,{width:`22`,height:`22`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:/* @__PURE__ */ Q(`polyline`,{points:`6,9 12,15 18,9`})})}function hc({isOpen:e,onClick:t,avatarUrl:n,ariaLabel:r=`Toggle chat`}){let i=!e&&!!n;return/* @__PURE__ */ Q(`button`,{className:`ak-launcher${i?` ak-launcher--avatar`:``}`,onClick:t,"aria-label":r,"aria-expanded":e,type:`button`,children:e?/* @__PURE__ */ Q(mc,{}):i?/* @__PURE__ */ Q(`img`,{src:n,alt:``,className:`ak-launcher__avatar-img`,"aria-hidden":`true`}):/* @__PURE__ */ Q(pc,{})})}function gc({config:e,state:t,callbacks:n}){let r=e.mode===`inline`,i=Z(null);return X(()=>{let t=i.current?.getRootNode()?.host;if(!t)return;let n=cs(e.theme.mode);t.setAttribute(`data-theme`,n)},[e.theme.mode]),X(()=>{if(r)return;let e=i.current?.getRootNode()?.host;e&&(t.isOpen?e.setAttribute(`data-open`,``):e.removeAttribute(`data-open`))},[r,t.isOpen]),t.initStatus===`disabled`&&!r?null:r?/* @__PURE__ */ Q(`div`,{ref:i,className:`ak-inline`,children:/* @__PURE__ */ Q(fc,{config:e,messages:t.messages,isLoading:t.isLoading,error:t.error,isInline:!0,initStatus:t.initStatus,initError:t.initError,callbacks:n})}):/* @__PURE__ */ Q(`div`,{ref:i,className:`ak-floating`,children:[t.isOpen&&/* @__PURE__ */ Q(fc,{config:e,messages:t.messages,isLoading:t.isLoading,error:t.error,isInline:!1,initStatus:t.initStatus,initError:t.initError,callbacks:n}),/* @__PURE__ */ Q(hc,{isOpen:t.isOpen,onClick:t.isOpen?n.onClose:n.onOpen,avatarUrl:e.avatarUrl})]})}var _c=(e,t,n,r)=>{let i=os(e);return i.render(Va(gc,{config:t,state:n,callbacks:r})),{update(e,t){i.render(Va(gc,{config:t,state:e,callbacks:r}))},destroy(){setTimeout(()=>{i.unmount()},0)}}};function vc(e){return ls+`
|
|
2065
|
+
`+ss(e)}function yc(e,t){return vc(mt({...e,mode:t}))}function bc(e,t=_c,n){return ba(e,t,n??yc(e,`floating`))}function xc(e,t,n=_c,r){return xa(e,t,n,r??yc(t,`inline`))}function Sc(e){Sa(e)}var Cc={init:bc,mount:xc,destroy:Sc};window.AgentKit=Cc;export{Cc as AgentKit};
|