@bymos/agentkit-sdk 0.3.3 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs CHANGED
@@ -1,9 +1,15 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let Hr=require("preact/compat/client"),E=require("preact/compat"),c=require("preact/jsx-runtime");var N;(function(e){e.assertEqual=a=>{};function t(a){}e.assertIs=t;function r(a){throw new Error}e.assertNever=r,e.arrayToEnum=a=>{const i={};for(const s of a)i[s]=s;return i},e.getValidEnumValues=a=>{const i=e.objectKeys(a).filter(o=>typeof a[a[o]]!="number"),s={};for(const o of i)s[o]=a[o];return e.objectValues(s)},e.objectValues=a=>e.objectKeys(a).map(function(i){return a[i]}),e.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const i=[];for(const s in a)Object.prototype.hasOwnProperty.call(a,s)&&i.push(s);return i},e.find=(a,i)=>{for(const s of a)if(i(s))return s},e.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function n(a,i=" | "){return a.map(s=>typeof s=="string"?`'${s}'`:s).join(i)}e.joinValues=n,e.jsonStringifyReplacer=(a,i)=>typeof i=="bigint"?i.toString():i})(N||(N={}));var Mt;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Mt||(Mt={}));var v=N.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),oe=e=>{switch(typeof e){case"undefined":return v.undefined;case"string":return v.string;case"number":return Number.isNaN(e)?v.nan:v.number;case"boolean":return v.boolean;case"function":return v.function;case"bigint":return v.bigint;case"symbol":return v.symbol;case"object":return Array.isArray(e)?v.array:e===null?v.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?v.promise:typeof Map<"u"&&e instanceof Map?v.map:typeof Set<"u"&&e instanceof Set?v.set:typeof Date<"u"&&e instanceof Date?v.date:v.object;default:return v.unknown}},f=N.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"]),J=class Kt extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){const r=t||function(i){return i.message},n={_errors:[]},a=i=>{for(const s of i.issues)if(s.code==="invalid_union")s.unionErrors.map(a);else if(s.code==="invalid_return_type")a(s.returnTypeError);else if(s.code==="invalid_arguments")a(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let o=n,d=0;for(;d<s.path.length;){const l=s.path[d];d!==s.path.length-1?o[l]=o[l]||{_errors:[]}:(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(s))),o=o[l],d++}}};return a(this),n}static assert(t){if(!(t instanceof Kt))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,N.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){const r={},n=[];for(const a of this.issues)if(a.path.length>0){const i=a.path[0];r[i]=r[i]||[],r[i].push(t(a))}else n.push(t(a));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};J.create=e=>new J(e);var Se=(e,t)=>{let r;switch(e.code){case f.invalid_type:e.received===v.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case f.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,N.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:r=`Unrecognized key(s) in object: ${N.joinValues(e.keys,", ")}`;break;case f.invalid_union:r="Invalid input";break;case f.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${N.joinValues(e.options)}`;break;case f.invalid_enum_value:r=`Invalid enum value. Expected ${N.joinValues(e.options)}, received '${e.received}'`;break;case f.invalid_arguments:r="Invalid function arguments";break;case f.invalid_return_type:r="Invalid function return type";break;case f.invalid_date:r="Invalid date";break;case f.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:N.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case f.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case f.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case f.custom:r="Invalid input";break;case f.invalid_intersection_types:r="Intersection results could not be merged";break;case f.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case f.not_finite:r="Number must be finite";break;default:r=t.defaultError,N.assertNever(e)}return{message:r}},Xr=Se;function at(){return Xr}var it=e=>{const{data:t,path:r,errorMaps:n,issueData:a}=e,i=[...r,...a.path||[]],s={...a,path:i};if(a.message!==void 0)return{...a,path:i,message:a.message};let o="";const d=n.filter(l=>!!l).slice().reverse();for(const l of d)o=l(s,{data:t,defaultError:o}).message;return{...a,path:i,message:o}};function p(e,t){const r=at(),n=it({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Se?void 0:Se].filter(a=>!!a)});e.common.issues.push(n)}var z=class er{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){const n=[];for(const a of r){if(a.status==="aborted")return _;a.status==="dirty"&&t.dirty(),n.push(a.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){const n=[];for(const a of r){const i=await a.key,s=await a.value;n.push({key:i,value:s})}return er.mergeObjectSync(t,n)}static mergeObjectSync(t,r){const n={};for(const a of r){const{key:i,value:s}=a;if(i.status==="aborted"||s.status==="aborted")return _;i.status==="dirty"&&t.dirty(),s.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof s.value<"u"||a.alwaysSet)&&(n[i.value]=s.value)}return{status:t.value,value:n}}},_=Object.freeze({status:"aborted"}),be=e=>({status:"dirty",value:e}),F=e=>({status:"valid",value:e}),Ot=e=>e.status==="aborted",Vt=e=>e.status==="dirty",ye=e=>e.status==="valid",Pe=e=>typeof Promise<"u"&&e instanceof Promise,k;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(k||(k={}));var Q=class{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Pt=(e,t)=>{if(ye(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){return this._error?this._error:(this._error=new J(e.common.issues),this._error)}}};function j(e){if(!e)return{};const{errorMap:t,invalid_type_error:r,required_error:n,description:a}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:a}:{errorMap:(s,o)=>{const{message:d}=e;return s.code==="invalid_enum_value"?{message:d??o.defaultError}:typeof o.data>"u"?{message:d??n??o.defaultError}:s.code!=="invalid_type"?{message:o.defaultError}:{message:d??r??o.defaultError}},description:a}}var I=class{get description(){return this._def.description}_getType(e){return oe(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:oe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new z,ctx:{common:e.parent.common,data:e.data,parsedType:oe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Pe(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){const r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:oe(e)};return Pt(r,this._parseSync({data:e,path:r.path,parent:r}))}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:oe(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:t});return ye(r)?{value:r.value}:{issues:t.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(r=>ye(r)?{value:r.value}:{issues:t.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:oe(e)},n=this._parse({data:e,path:r.path,parent:r});return Pt(r,await(Pe(n)?n:Promise.resolve(n)))}refine(e,t){const r=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const i=e(n),s=()=>a.addIssue({code:f.custom,...r(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(o=>o?!0:(s(),!1)):i?!0:(s(),!1)})}refinement(e,t){return this._refinement((r,n)=>e(r)?!0:(n.addIssue(typeof t=="function"?t(r,n):t),!1))}_refinement(e){return new ae({schema:this,typeName:w.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return ne.create(this,this._def)}nullable(){return ue.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return xe.create(this)}promise(){return je.create(this,this._def)}or(e){return De.create([this,e],this._def)}and(e){return $e.create(this,e,this._def)}transform(e){return new ae({...j(this._def),schema:this,typeName:w.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ye({...j(this._def),innerType:this,defaultValue:t,typeName:w.ZodDefault})}brand(){return new or({typeName:w.ZodBranded,type:this,...j(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new He({...j(this._def),innerType:this,catchValue:t,typeName:w.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return cr.create(this,e)}readonly(){return Xe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Jr=/^c[^\s-]{8,}$/i,Qr=/^[0-9a-z]+$/,qr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Kr=/^[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,en=/^[a-z0-9_-]{21}$/i,tn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,rn=/^[-+]?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)?)??$/,nn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,an="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ke,sn=/^(?:(?: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])$/,on=/^(?:(?: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])$/,cn=/^(([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]))$/,dn=/^(([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])$/,ln=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,un=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,tr="((\\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])))",hn=new RegExp(`^${tr}$`);function rr(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function fn(e){return new RegExp(`^${rr(e)}$`)}function mn(e){let t=`${tr}T${rr(e)}`;const r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function pn(e,t){return!!((t==="v4"||!t)&&sn.test(e)||(t==="v6"||!t)&&cn.test(e))}function gn(e,t){if(!tn.test(e))return!1;try{const[r]=e.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),a=JSON.parse(atob(n));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||t&&a.alg!==t)}catch{return!1}}function vn(e,t){return!!((t==="v4"||!t)&&on.test(e)||(t==="v6"||!t)&&dn.test(e))}var Fe=class _e extends I{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==v.string){const a=this._getOrReturnCtx(t);return p(a,{code:f.invalid_type,expected:v.string,received:a.parsedType}),_}const r=new z;let n;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(n=this._getOrReturnCtx(t,n),p(n,{code:f.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")t.data.length>a.value&&(n=this._getOrReturnCtx(t,n),p(n,{code:f.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const i=t.data.length>a.value,s=t.data.length<a.value;(i||s)&&(n=this._getOrReturnCtx(t,n),i?p(n,{code:f.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&p(n,{code:f.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")nn.test(t.data)||(n=this._getOrReturnCtx(t,n),p(n,{validation:"email",code:f.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")Ke||(Ke=new RegExp(an,"u")),Ke.test(t.data)||(n=this._getOrReturnCtx(t,n),p(n,{validation:"emoji",code:f.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")Kr.test(t.data)||(n=this._getOrReturnCtx(t,n),p(n,{validation:"uuid",code:f.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")en.test(t.data)||(n=this._getOrReturnCtx(t,n),p(n,{validation:"nanoid",code:f.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")Jr.test(t.data)||(n=this._getOrReturnCtx(t,n),p(n,{validation:"cuid",code:f.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")Qr.test(t.data)||(n=this._getOrReturnCtx(t,n),p(n,{validation:"cuid2",code:f.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")qr.test(t.data)||(n=this._getOrReturnCtx(t,n),p(n,{validation:"ulid",code:f.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{n=this._getOrReturnCtx(t,n),p(n,{validation:"url",code:f.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(n=this._getOrReturnCtx(t,n),p(n,{validation:"regex",code:f.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(t,n),p(n,{code:f.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(n=this._getOrReturnCtx(t,n),p(n,{code:f.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(n=this._getOrReturnCtx(t,n),p(n,{code:f.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?mn(a).test(t.data)||(n=this._getOrReturnCtx(t,n),p(n,{code:f.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?hn.test(t.data)||(n=this._getOrReturnCtx(t,n),p(n,{code:f.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?fn(a).test(t.data)||(n=this._getOrReturnCtx(t,n),p(n,{code:f.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?rn.test(t.data)||(n=this._getOrReturnCtx(t,n),p(n,{validation:"duration",code:f.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?pn(t.data,a.version)||(n=this._getOrReturnCtx(t,n),p(n,{validation:"ip",code:f.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?gn(t.data,a.alg)||(n=this._getOrReturnCtx(t,n),p(n,{validation:"jwt",code:f.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?vn(t.data,a.version)||(n=this._getOrReturnCtx(t,n),p(n,{validation:"cidr",code:f.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?ln.test(t.data)||(n=this._getOrReturnCtx(t,n),p(n,{validation:"base64",code:f.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?un.test(t.data)||(n=this._getOrReturnCtx(t,n),p(n,{validation:"base64url",code:f.invalid_string,message:a.message}),r.dirty()):N.assertNever(a);return{status:r.value,value:t.data}}_regex(t,r,n){return this.refinement(a=>t.test(a),{validation:r,code:f.invalid_string,...k.errToObj(n)})}_addCheck(t){return new _e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...k.errToObj(t)})}url(t){return this._addCheck({kind:"url",...k.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...k.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...k.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...k.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...k.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...k.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...k.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...k.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...k.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...k.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...k.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...k.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...k.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...k.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...k.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...k.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...k.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...k.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...k.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...k.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...k.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...k.errToObj(r)})}nonempty(t){return this.min(1,k.errToObj(t))}trim(){return new _e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new _e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new _e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Fe.create=e=>new Fe({checks:[],typeName:w.ZodString,coerce:e?.coerce??!1,...j(e)});function kn(e,t){const r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,a=r>n?r:n;return Number.parseInt(e.toFixed(a).replace(".",""))%Number.parseInt(t.toFixed(a).replace(".",""))/10**a}var st=class ot extends I{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)!==v.number){const a=this._getOrReturnCtx(t);return p(a,{code:f.invalid_type,expected:v.number,received:a.parsedType}),_}let r;const n=new z;for(const a of this._def.checks)a.kind==="int"?N.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),p(r,{code:f.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),p(r,{code:f.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),p(r,{code:f.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?kn(t.data,a.value)!==0&&(r=this._getOrReturnCtx(t,r),p(r,{code:f.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),p(r,{code:f.not_finite,message:a.message}),n.dirty()):N.assertNever(a);return{status:n.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,k.toString(r))}gt(t,r){return this.setLimit("min",t,!1,k.toString(r))}lte(t,r){return this.setLimit("max",t,!0,k.toString(r))}lt(t,r){return this.setLimit("max",t,!1,k.toString(r))}setLimit(t,r,n,a){return new ot({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:k.toString(a)}]})}_addCheck(t){return new ot({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:k.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:k.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:k.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:k.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:k.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:k.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:k.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:k.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:k.toString(t)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&N.isInteger(t.value))}get isFinite(){let t=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};st.create=e=>new st({checks:[],typeName:w.ZodNumber,coerce:e?.coerce||!1,...j(e)});var ct=class dt extends I{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)!==v.bigint)return this._getInvalidInput(t);let r;const n=new z;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),p(r,{code:f.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),p(r,{code:f.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),p(r,{code:f.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):N.assertNever(a);return{status:n.value,value:t.data}}_getInvalidInput(t){const r=this._getOrReturnCtx(t);return p(r,{code:f.invalid_type,expected:v.bigint,received:r.parsedType}),_}gte(t,r){return this.setLimit("min",t,!0,k.toString(r))}gt(t,r){return this.setLimit("min",t,!1,k.toString(r))}lte(t,r){return this.setLimit("max",t,!0,k.toString(r))}lt(t,r){return this.setLimit("max",t,!1,k.toString(r))}setLimit(t,r,n,a){return new dt({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:k.toString(a)}]})}_addCheck(t){return new dt({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:k.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:k.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:k.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:k.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:k.toString(r)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};ct.create=e=>new ct({checks:[],typeName:w.ZodBigInt,coerce:e?.coerce??!1,...j(e)});var lt=class extends I{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==v.boolean){const t=this._getOrReturnCtx(e);return p(t,{code:f.invalid_type,expected:v.boolean,received:t.parsedType}),_}return F(e.data)}};lt.create=e=>new lt({typeName:w.ZodBoolean,coerce:e?.coerce||!1,...j(e)});var ut=class nr extends I{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==v.date){const a=this._getOrReturnCtx(t);return p(a,{code:f.invalid_type,expected:v.date,received:a.parsedType}),_}if(Number.isNaN(t.data.getTime()))return p(this._getOrReturnCtx(t),{code:f.invalid_date}),_;const r=new z;let n;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(n=this._getOrReturnCtx(t,n),p(n,{code:f.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(n=this._getOrReturnCtx(t,n),p(n,{code:f.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):N.assertNever(a);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new nr({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:k.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:k.toString(r)})}get minDate(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};ut.create=e=>new ut({checks:[],coerce:e?.coerce||!1,typeName:w.ZodDate,...j(e)});var ht=class extends I{_parse(e){if(this._getType(e)!==v.symbol){const t=this._getOrReturnCtx(e);return p(t,{code:f.invalid_type,expected:v.symbol,received:t.parsedType}),_}return F(e.data)}};ht.create=e=>new ht({typeName:w.ZodSymbol,...j(e)});var We=class extends I{_parse(e){if(this._getType(e)!==v.undefined){const t=this._getOrReturnCtx(e);return p(t,{code:f.invalid_type,expected:v.undefined,received:t.parsedType}),_}return F(e.data)}};We.create=e=>new We({typeName:w.ZodUndefined,...j(e)});var ze=class extends I{_parse(e){if(this._getType(e)!==v.null){const t=this._getOrReturnCtx(e);return p(t,{code:f.invalid_type,expected:v.null,received:t.parsedType}),_}return F(e.data)}};ze.create=e=>new ze({typeName:w.ZodNull,...j(e)});var ft=class extends I{constructor(){super(...arguments),this._any=!0}_parse(e){return F(e.data)}};ft.create=e=>new ft({typeName:w.ZodAny,...j(e)});var ve=class extends I{constructor(){super(...arguments),this._unknown=!0}_parse(e){return F(e.data)}};ve.create=e=>new ve({typeName:w.ZodUnknown,...j(e)});var ce=class extends I{_parse(e){const t=this._getOrReturnCtx(e);return p(t,{code:f.invalid_type,expected:v.never,received:t.parsedType}),_}};ce.create=e=>new ce({typeName:w.ZodNever,...j(e)});var mt=class extends I{_parse(e){if(this._getType(e)!==v.undefined){const t=this._getOrReturnCtx(e);return p(t,{code:f.invalid_type,expected:v.void,received:t.parsedType}),_}return F(e.data)}};mt.create=e=>new mt({typeName:w.ZodVoid,...j(e)});var xe=class Me extends I{_parse(t){const{ctx:r,status:n}=this._processInputParams(t),a=this._def;if(r.parsedType!==v.array)return p(r,{code:f.invalid_type,expected:v.array,received:r.parsedType}),_;if(a.exactLength!==null){const s=r.data.length>a.exactLength.value,o=r.data.length<a.exactLength.value;(s||o)&&(p(r,{code:s?f.too_big:f.too_small,minimum:o?a.exactLength.value:void 0,maximum:s?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(a.minLength!==null&&r.data.length<a.minLength.value&&(p(r,{code:f.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),a.maxLength!==null&&r.data.length>a.maxLength.value&&(p(r,{code:f.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,o)=>a.type._parseAsync(new Q(r,s,r.path,o)))).then(s=>z.mergeArray(n,s));const i=[...r.data].map((s,o)=>a.type._parseSync(new Q(r,s,r.path,o)));return z.mergeArray(n,i)}get element(){return this._def.type}min(t,r){return new Me({...this._def,minLength:{value:t,message:k.toString(r)}})}max(t,r){return new Me({...this._def,maxLength:{value:t,message:k.toString(r)}})}length(t,r){return new Me({...this._def,exactLength:{value:t,message:k.toString(r)}})}nonempty(t){return this.min(1,t)}};xe.create=(e,t)=>new xe({type:e,minLength:null,maxLength:null,exactLength:null,typeName:w.ZodArray,...j(t)});function ge(e){if(e instanceof Y){const t={};for(const r in e.shape){const n=e.shape[r];t[r]=ne.create(ge(n))}return new Y({...e._def,shape:()=>t})}else return e instanceof xe?new xe({...e._def,type:ge(e.element)}):e instanceof ne?ne.create(ge(e.unwrap())):e instanceof ue?ue.create(ge(e.unwrap())):e instanceof le?le.create(e.items.map(t=>ge(t))):e}var Y=class B extends I{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape();return this._cached={shape:t,keys:N.objectKeys(t)},this._cached}_parse(t){if(this._getType(t)!==v.object){const d=this._getOrReturnCtx(t);return p(d,{code:f.invalid_type,expected:v.object,received:d.parsedType}),_}const{status:r,ctx:n}=this._processInputParams(t),{shape:a,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof ce&&this._def.unknownKeys==="strip"))for(const d in n.data)i.includes(d)||s.push(d);const o=[];for(const d of i){const l=a[d],u=n.data[d];o.push({key:{status:"valid",value:d},value:l._parse(new Q(n,u,n.path,d)),alwaysSet:d in n.data})}if(this._def.catchall instanceof ce){const d=this._def.unknownKeys;if(d==="passthrough")for(const l of s)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(d==="strict")s.length>0&&(p(n,{code:f.unrecognized_keys,keys:s}),r.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const l of s){const u=n.data[l];o.push({key:{status:"valid",value:l},value:d._parse(new Q(n,u,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const d=[];for(const l of o){const u=await l.key,h=await l.value;d.push({key:u,value:h,alwaysSet:l.alwaysSet})}return d}).then(d=>z.mergeObjectSync(r,d)):z.mergeObjectSync(r,o)}get shape(){return this._def.shape()}strict(t){return k.errToObj,new B({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{const a=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:k.errToObj(t).message??a}:{message:a}}}:{}})}strip(){return new B({...this._def,unknownKeys:"strip"})}passthrough(){return new B({...this._def,unknownKeys:"passthrough"})}extend(t){return new B({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new B({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:w.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new B({...this._def,catchall:t})}pick(t){const r={};for(const n of N.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new B({...this._def,shape:()=>r})}omit(t){const r={};for(const n of N.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new B({...this._def,shape:()=>r})}deepPartial(){return ge(this)}partial(t){const r={};for(const n of N.objectKeys(this.shape)){const a=this.shape[n];t&&!t[n]?r[n]=a:r[n]=a.optional()}return new B({...this._def,shape:()=>r})}required(t){const r={};for(const n of N.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof ne;)a=a._def.innerType;r[n]=a}return new B({...this._def,shape:()=>r})}keyof(){return sr(N.objectKeys(this.shape))}};Y.create=(e,t)=>new Y({shape:()=>e,unknownKeys:"strip",catchall:ce.create(),typeName:w.ZodObject,...j(t)});Y.strictCreate=(e,t)=>new Y({shape:()=>e,unknownKeys:"strict",catchall:ce.create(),typeName:w.ZodObject,...j(t)});Y.lazycreate=(e,t)=>new Y({shape:e,unknownKeys:"strip",catchall:ce.create(),typeName:w.ZodObject,...j(t)});var De=class extends I{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function n(a){for(const s of a)if(s.result.status==="valid")return s.result;for(const s of a)if(s.result.status==="dirty")return t.common.issues.push(...s.ctx.common.issues),s.result;const i=a.map(s=>new J(s.ctx.common.issues));return p(t,{code:f.invalid_union,unionErrors:i}),_}if(t.common.async)return Promise.all(r.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a;const i=[];for(const o of r){const d={...t,common:{...t.common,issues:[]},parent:null},l=o._parseSync({data:t.data,path:t.path,parent:d});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const s=i.map(o=>new J(o));return p(t,{code:f.invalid_union,unionErrors:s}),_}}get options(){return this._def.options}};De.create=(e,t)=>new De({options:e,typeName:w.ZodUnion,...j(t)});var te=e=>e instanceof Ue?te(e.schema):e instanceof ae?te(e.innerType()):e instanceof Be?[e.value]:e instanceof Qe?e.options:e instanceof Ge?N.objectValues(e.enum):e instanceof Ye?te(e._def.innerType):e instanceof We?[void 0]:e instanceof ze?[null]:e instanceof ne?[void 0,...te(e.unwrap())]:e instanceof ue?[null,...te(e.unwrap())]:e instanceof or||e instanceof Xe?te(e.unwrap()):e instanceof He?te(e._def.innerType):[],yn=class ar extends I{_parse(t){const{ctx:r}=this._processInputParams(t);if(r.parsedType!==v.object)return p(r,{code:f.invalid_type,expected:v.object,received:r.parsedType}),_;const n=this.discriminator,a=r.data[n],i=this.optionsMap.get(a);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(p(r,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),_)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){const a=new Map;for(const i of r){const s=te(i.shape[t]);if(!s.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const o of s){if(a.has(o))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(o)}`);a.set(o,i)}}return new ar({typeName:w.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:a,...j(n)})}};function pt(e,t){const r=oe(e),n=oe(t);if(e===t)return{valid:!0,data:e};if(r===v.object&&n===v.object){const a=N.objectKeys(t),i=N.objectKeys(e).filter(o=>a.indexOf(o)!==-1),s={...e,...t};for(const o of i){const d=pt(e[o],t[o]);if(!d.valid)return{valid:!1};s[o]=d.data}return{valid:!0,data:s}}else if(r===v.array&&n===v.array){if(e.length!==t.length)return{valid:!1};const a=[];for(let i=0;i<e.length;i++){const s=e[i],o=t[i],d=pt(s,o);if(!d.valid)return{valid:!1};a.push(d.data)}return{valid:!0,data:a}}else return r===v.date&&n===v.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var $e=class extends I{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=(a,i)=>{if(Ot(a)||Ot(i))return _;const s=pt(a.value,i.value);return s.valid?((Vt(a)||Vt(i))&&t.dirty(),{status:t.value,value:s.data}):(p(r,{code:f.invalid_intersection_types}),_)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};$e.create=(e,t,r)=>new $e({left:e,right:t,typeName:w.ZodIntersection,...j(r)});var le=class ir extends I{_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==v.array)return p(n,{code:f.invalid_type,expected:v.array,received:n.parsedType}),_;if(n.data.length<this._def.items.length)return p(n,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),_;!this._def.rest&&n.data.length>this._def.items.length&&(p(n,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const a=[...n.data].map((i,s)=>{const o=this._def.items[s]||this._def.rest;return o?o._parse(new Q(n,i,n.path,s)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>z.mergeArray(r,i)):z.mergeArray(r,a)}get items(){return this._def.items}rest(t){return new ir({...this._def,rest:t})}};le.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new le({items:e,typeName:w.ZodTuple,rest:null,...j(t)})};var xn=class gt extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==v.object)return p(n,{code:f.invalid_type,expected:v.object,received:n.parsedType}),_;const a=[],i=this._def.keyType,s=this._def.valueType;for(const o in n.data)a.push({key:i._parse(new Q(n,o,n.path,o)),value:s._parse(new Q(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?z.mergeObjectAsync(r,a):z.mergeObjectSync(r,a)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof I?new gt({keyType:t,valueType:r,typeName:w.ZodRecord,...j(n)}):new gt({keyType:Fe.create(),valueType:t,typeName:w.ZodRecord,...j(r)})}},vt=class extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.map)return p(r,{code:f.invalid_type,expected:v.map,received:r.parsedType}),_;const n=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([s,o],d)=>({key:n._parse(new Q(r,s,r.path,[d,"key"])),value:a._parse(new Q(r,o,r.path,[d,"value"]))}));if(r.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const o of i){const d=await o.key,l=await o.value;if(d.status==="aborted"||l.status==="aborted")return _;(d.status==="dirty"||l.status==="dirty")&&t.dirty(),s.set(d.value,l.value)}return{status:t.value,value:s}})}else{const s=new Map;for(const o of i){const d=o.key,l=o.value;if(d.status==="aborted"||l.status==="aborted")return _;(d.status==="dirty"||l.status==="dirty")&&t.dirty(),s.set(d.value,l.value)}return{status:t.value,value:s}}}};vt.create=(e,t,r)=>new vt({valueType:t,keyType:e,typeName:w.ZodMap,...j(r)});var kt=class yt extends I{_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==v.set)return p(n,{code:f.invalid_type,expected:v.set,received:n.parsedType}),_;const a=this._def;a.minSize!==null&&n.data.size<a.minSize.value&&(p(n,{code:f.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),r.dirty()),a.maxSize!==null&&n.data.size>a.maxSize.value&&(p(n,{code:f.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),r.dirty());const i=this._def.valueType;function s(d){const l=new Set;for(const u of d){if(u.status==="aborted")return _;u.status==="dirty"&&r.dirty(),l.add(u.value)}return{status:r.value,value:l}}const o=[...n.data.values()].map((d,l)=>i._parse(new Q(n,d,n.path,l)));return n.common.async?Promise.all(o).then(d=>s(d)):s(o)}min(t,r){return new yt({...this._def,minSize:{value:t,message:k.toString(r)}})}max(t,r){return new yt({...this._def,maxSize:{value:t,message:k.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};kt.create=(e,t)=>new kt({valueType:e,minSize:null,maxSize:null,typeName:w.ZodSet,...j(t)});var bn=class Oe extends I{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:r}=this._processInputParams(t);if(r.parsedType!==v.function)return p(r,{code:f.invalid_type,expected:v.function,received:r.parsedType}),_;function n(o,d){return it({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,at(),Se].filter(l=>!!l),issueData:{code:f.invalid_arguments,argumentsError:d}})}function a(o,d){return it({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,at(),Se].filter(l=>!!l),issueData:{code:f.invalid_return_type,returnTypeError:d}})}const i={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof je){const o=this;return F(async function(...d){const l=new J([]),u=await o._def.args.parseAsync(d,i).catch(m=>{throw l.addIssue(n(d,m)),l}),h=await Reflect.apply(s,this,u);return await o._def.returns._def.type.parseAsync(h,i).catch(m=>{throw l.addIssue(a(h,m)),l})})}else{const o=this;return F(function(...d){const l=o._def.args.safeParse(d,i);if(!l.success)throw new J([n(d,l.error)]);const u=Reflect.apply(s,this,l.data),h=o._def.returns.safeParse(u,i);if(!h.success)throw new J([a(u,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new Oe({...this._def,args:le.create(t).rest(ve.create())})}returns(t){return new Oe({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new Oe({args:t||le.create([]).rest(ve.create()),returns:r||ve.create(),typeName:w.ZodFunction,...j(n)})}},Ue=class extends I{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Ue.create=(e,t)=>new Ue({getter:e,typeName:w.ZodLazy,...j(t)});var Be=class extends I{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return p(t,{received:t.data,code:f.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:e.data}}get value(){return this._def.value}};Be.create=(e,t)=>new Be({value:e,typeName:w.ZodLiteral,...j(t)});function sr(e,t){return new Qe({values:e,typeName:w.ZodEnum,...j(t)})}var Qe=class xt extends I{_parse(t){if(typeof t.data!="string"){const r=this._getOrReturnCtx(t),n=this._def.values;return p(r,{expected:N.joinValues(n),received:r.parsedType,code:f.invalid_type}),_}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const r=this._getOrReturnCtx(t),n=this._def.values;return p(r,{received:r.data,code:f.invalid_enum_value,options:n}),_}return F(t.data)}get options(){return this._def.values}get enum(){const t={};for(const r of this._def.values)t[r]=r;return t}get Values(){const t={};for(const r of this._def.values)t[r]=r;return t}get Enum(){const t={};for(const r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return xt.create(t,{...this._def,...r})}exclude(t,r=this._def){return xt.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};Qe.create=sr;var Ge=class extends I{_parse(e){const t=N.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==v.string&&r.parsedType!==v.number){const n=N.objectValues(t);return p(r,{expected:N.joinValues(n),received:r.parsedType,code:f.invalid_type}),_}if(this._cache||(this._cache=new Set(N.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const n=N.objectValues(t);return p(r,{received:r.data,code:f.invalid_enum_value,options:n}),_}return F(e.data)}get enum(){return this._def.values}};Ge.create=(e,t)=>new Ge({values:e,typeName:w.ZodNativeEnum,...j(t)});var je=class extends I{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);return t.parsedType!==v.promise&&t.common.async===!1?(p(t,{code:f.invalid_type,expected:v.promise,received:t.parsedType}),_):F((t.parsedType===v.promise?t.data:Promise.resolve(t.data)).then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}};je.create=(e,t)=>new je({type:e,typeName:w.ZodPromise,...j(t)});var ae=class extends I{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===w.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{p(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const i=n.transform(r.data,a);if(r.common.async)return Promise.resolve(i).then(async s=>{if(t.value==="aborted")return _;const o=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return o.status==="aborted"?_:o.status==="dirty"||t.value==="dirty"?be(o.value):o});{if(t.value==="aborted")return _;const s=this._def.schema._parseSync({data:i,path:r.path,parent:r});return s.status==="aborted"?_:s.status==="dirty"||t.value==="dirty"?be(s.value):s}}if(n.type==="refinement"){const i=s=>{const o=n.refinement(s,a);if(r.common.async)return Promise.resolve(o);if(o instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){const s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?_:(s.status==="dirty"&&t.dirty(),i(s.value),{status:t.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?_:(s.status==="dirty"&&t.dirty(),i(s.value).then(()=>({status:t.value,value:s.value}))))}if(n.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!ye(i))return _;const s=n.transform(i.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>ye(i)?Promise.resolve(n.transform(i.value,a)).then(s=>({status:t.value,value:s})):_);N.assertNever(n)}};ae.create=(e,t,r)=>new ae({schema:e,typeName:w.ZodEffects,effect:t,...j(r)});ae.createWithPreprocess=(e,t,r)=>new ae({schema:t,effect:{type:"preprocess",transform:e},typeName:w.ZodEffects,...j(r)});var ne=class extends I{_parse(e){return this._getType(e)===v.undefined?F(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ne.create=(e,t)=>new ne({innerType:e,typeName:w.ZodOptional,...j(t)});var ue=class extends I{_parse(e){return this._getType(e)===v.null?F(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ue.create=(e,t)=>new ue({innerType:e,typeName:w.ZodNullable,...j(t)});var Ye=class extends I{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===v.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Ye.create=(e,t)=>new Ye({innerType:e,typeName:w.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...j(t)});var He=class extends I{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Pe(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new J(r.common.issues)},input:r.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new J(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};He.create=(e,t)=>new He({innerType:e,typeName:w.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...j(t)});var bt=class extends I{_parse(e){if(this._getType(e)!==v.nan){const t=this._getOrReturnCtx(e);return p(t,{code:f.invalid_type,expected:v.nan,received:t.parsedType}),_}return{status:"valid",value:e.data}}};bt.create=e=>new bt({typeName:w.ZodNaN,...j(e)});var or=class extends I{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}},cr=class dr extends I{_parse(t){const{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?_:i.status==="dirty"?(r.dirty(),be(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?_:a.status==="dirty"?(r.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(t,r){return new dr({in:t,out:r,typeName:w.ZodPipeline})}},Xe=class extends I{_parse(e){const t=this._def.innerType._parse(e),r=n=>(ye(n)&&(n.value=Object.freeze(n.value)),n);return Pe(t)?t.then(n=>r(n)):r(t)}unwrap(){return this._def.innerType}};Xe.create=(e,t)=>new Xe({innerType:e,typeName:w.ZodReadonly,...j(t)});var ys={object:Y.lazycreate},w;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(w||(w={}));var M=Fe.create,xs=st.create,bs=bt.create,_s=ct.create,et=lt.create,ws=ut.create,Ss=ht.create,js=We.create,Cs=ze.create,Is=ft.create,_n=ve.create,Ns=ce.create,Ts=mt.create,Ls=xe.create,Tt=Y.create,As=Y.strictCreate,Es=De.create,Rs=yn.create,Zs=$e.create,Ms=le.create,wn=xn.create,Os=vt.create,Vs=kt.create,Ps=bn.create,Fs=Ue.create,Ws=Be.create,lr=Qe.create,zs=Ge.create,Ds=je.create,$s=ae.create,Us=ne.create,Bs=ue.create,Gs=ae.createWithPreprocess,Ys=cr.create,Sn=Tt({mode:lr(["light","dark","system"]).optional(),accentColor:M().optional(),fontFamily:M().optional(),borderRadius:M().optional()}),jn=Tt({externalId:M().optional(),authId:M().optional(),name:M().optional(),email:M().optional()}),ur=Tt({agentId:M().min(1,"agentId is required"),apiBaseUrl:M().url("apiBaseUrl must be a valid URL"),tenantId:M().optional(),user:jn.optional(),sessionId:M().optional(),mode:lr(["floating","inline"]).optional(),title:M().optional(),subtitle:M().optional(),description:M().optional(),greeting:M().optional(),avatarUrl:M().optional(),privacyPolicyUrl:M().optional(),termsOfServiceUrl:M().optional(),streaming:et().optional(),preview:et().optional(),skipServerConfigFetch:et().optional(),metadata:wn(_n()).optional(),theme:Sn.optional()}),Cn=ur.omit({agentId:!0,apiBaseUrl:!0}).partial(),de={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 qe(e,t){ur.parse(e);let r;const n=t?{...t}:void 0;n&&typeof n.theme=="object"&&n.theme!==null?(r=n.theme,delete n.theme):n&&typeof n.theme=="string"&&(r={mode:n.theme},delete n.theme);const a=n?Cn.passthrough().safeParse(n).data:void 0,i=a?hr(a,e):e,s={mode:i.theme?.mode??r?.mode??de.theme.mode,accentColor:i.theme?.accentColor??r?.accentColor??de.theme.accentColor,fontFamily:i.theme?.fontFamily??r?.fontFamily??de.theme.fontFamily,borderRadius:i.theme?.borderRadius??r?.borderRadius??de.theme.borderRadius};return{agentId:i.agentId,apiBaseUrl:i.apiBaseUrl.replace(/\/$/,""),tenantId:i.tenantId,user:{externalId:i.user?.externalId,authId:i.user?.authId,name:i.user?.name,email:i.user?.email},sessionId:i.sessionId,mode:i.mode??de.mode,title:i.title??de.title,subtitle:i.subtitle,description:i.description,greeting:i.greeting,avatarUrl:i.avatarUrl,privacyPolicyUrl:i.privacyPolicyUrl,termsOfServiceUrl:i.termsOfServiceUrl,streaming:i.streaming??de.streaming,preview:i.preview===!0,skipServerConfigFetch:i.skipServerConfigFetch===!0,metadata:i.metadata??{},theme:s,thinkingEnabled:a?.thinkingEnabled===!0,thinkingViewable:a?.thinkingViewable===!0,photoSendingEnabled:a?.photoSendingEnabled===!0}}function hr(e,t){const r={...e};for(const n of Object.keys(t)){const a=t[n];a!=null&&(typeof a=="object"&&!Array.isArray(a)&&r[n]!==null&&typeof r[n]=="object"?r[n]=hr(r[n],a):r[n]=a)}return r}var _t=function(){return _t=Object.assign||function(t){for(var r,n=1,a=arguments.length;n<a;n++){r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},_t.apply(this,arguments)};function q(e,t,r,n){function a(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function o(u){try{l(n.next(u))}catch(h){s(h)}}function d(u){try{l(n.throw(u))}catch(h){s(h)}}function l(u){u.done?i(u.value):a(u.value).then(o,d)}l((n=n.apply(e,t||[])).next())})}function K(e,t){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,a,i,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(u){return d([l,u])}}function d(l){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(r=0)),r;)try{if(n=1,a&&(i=l[0]&2?a.return:l[0]?a.throw||((i=a.return)&&i.call(a),0):a.next)&&!(i=i.call(a,l[1])).done)return i;switch(a=0,i&&(l=[l[0]&2,i.value]),l[0]){case 0:case 1:i=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,a=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!(i=i.length>0&&i[i.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]<i[3])){r.label=l[1];break}if(l[0]===6&&r.label<i[1]){r.label=i[1],i=l;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(l);break}i[2]&&r.ops.pop(),r.trys.pop();continue}l=t.call(e,r)}catch(u){l=[6,u],a=0}finally{n=i=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function fr(e,t,r){if(r||arguments.length===2)for(var n=0,a=t.length,i;n<a;n++)(i||!(n in t))&&(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))}var mr="4.6.2";function Je(e,t){return new Promise(function(r){return setTimeout(r,e,t)})}function In(){return new Promise(function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})}function Nn(e,t){t===void 0&&(t=1/0);var r=window.requestIdleCallback;return r?new Promise(function(n){return r.call(window,function(){return n()},{timeout:t})}):Je(Math.min(e,t))}function pr(e){return!!e&&typeof e.then=="function"}function Ft(e,t){try{var r=e();pr(r)?r.then(function(n){return t(!0,n)},function(n){return t(!1,n)}):t(!0,r)}catch(n){t(!1,n)}}function Wt(e,t,r){return r===void 0&&(r=16),q(this,void 0,void 0,function(){var n,a,i,s;return K(this,function(o){switch(o.label){case 0:n=Array(e.length),a=Date.now(),i=0,o.label=1;case 1:return i<e.length?(n[i]=t(e[i],i),s=Date.now(),s>=a+r?(a=s,[4,In()]):[3,3]):[3,4];case 2:o.sent(),o.label=3;case 3:return++i,[3,1];case 4:return[2,n]}})})}function Ce(e){return e.then(void 0,function(){}),e}function Tn(e,t){for(var r=0,n=e.length;r<n;++r)if(e[r]===t)return!0;return!1}function Ln(e,t){return!Tn(e,t)}function Lt(e){return parseInt(e)}function G(e){return parseFloat(e)}function re(e,t){return typeof e=="number"&&isNaN(e)?t:e}function P(e){return e.reduce(function(t,r){return t+(r?1:0)},0)}function gr(e,t){if(t===void 0&&(t=1),Math.abs(t)>=1)return Math.round(e/t)*t;var r=1/t;return Math.round(e*r)/r}function An(e){for(var t,r,n="Unexpected syntax '".concat(e,"'"),a=/^\s*([a-z-]*)(.*)$/i.exec(e),i=a[1]||void 0,s={},o=/([.:#][\w-]+|\[.+?\])/gi,d=function(m,g){s[m]=s[m]||[],s[m].push(g)};;){var l=o.exec(a[2]);if(!l)break;var u=l[0];switch(u[0]){case".":d("class",u.slice(1));break;case"#":d("id",u.slice(1));break;case"[":var h=/^\[([\w-]+)([~|^$*]?=("(.*?)"|([\w-]+)))?(\s+[is])?\]$/.exec(u);if(h)d(h[1],(r=(t=h[4])!==null&&t!==void 0?t:h[5])!==null&&r!==void 0?r:"");else throw new Error(n);break;default:throw new Error(n)}}return[i,s]}function En(e){for(var t=new Uint8Array(e.length),r=0;r<e.length;r++){var n=e.charCodeAt(r);if(n>127)return new TextEncoder().encode(e);t[r]=n}return t}function se(e,t){var r=e[0]>>>16,n=e[0]&65535,a=e[1]>>>16,i=e[1]&65535,s=t[0]>>>16,o=t[0]&65535,d=t[1]>>>16,l=t[1]&65535,u=0,h=0,m=0,g=0;g+=i+l,m+=g>>>16,g&=65535,m+=a+d,h+=m>>>16,m&=65535,h+=n+o,u+=h>>>16,h&=65535,u+=r+s,u&=65535,e[0]=u<<16|h,e[1]=m<<16|g}function $(e,t){var r=e[0]>>>16,n=e[0]&65535,a=e[1]>>>16,i=e[1]&65535,s=t[0]>>>16,o=t[0]&65535,d=t[1]>>>16,l=t[1]&65535,u=0,h=0,m=0,g=0;g+=i*l,m+=g>>>16,g&=65535,m+=a*l,h+=m>>>16,m&=65535,m+=i*d,h+=m>>>16,m&=65535,h+=n*l,u+=h>>>16,h&=65535,h+=a*d,u+=h>>>16,h&=65535,h+=i*o,u+=h>>>16,h&=65535,u+=r*l+n*d+a*o+i*s,u&=65535,e[0]=u<<16|h,e[1]=m<<16|g}function he(e,t){var r=e[0];t%=64,t===32?(e[0]=e[1],e[1]=r):t<32?(e[0]=r<<t|e[1]>>>32-t,e[1]=e[1]<<t|r>>>32-t):(t-=32,e[0]=e[1]<<t|r>>>32-t,e[1]=r<<t|e[1]>>>32-t)}function W(e,t){t%=64,t!==0&&(t<32?(e[0]=e[1]>>>32-t,e[1]=e[1]<<t):(e[0]=e[1]<<t-32,e[1]=0))}function A(e,t){e[0]^=t[0],e[1]^=t[1]}var Rn=[4283543511,3981806797],Zn=[3301882366,444984403];function zt(e){var t=[0,e[0]>>>1];A(e,t),$(e,Rn),t[1]=e[0]>>>1,A(e,t),$(e,Zn),t[1]=e[0]>>>1,A(e,t)}var Re=[2277735313,289559509],Ze=[1291169091,658871167],Dt=[0,5],Mn=[0,1390208809],On=[0,944331445];function Vn(e,t){var r=En(e);t=t||0;var n=[0,r.length],a=n[1]%16,i=n[1]-a,s=[0,t],o=[0,t],d=[0,0],l=[0,0],u;for(u=0;u<i;u=u+16)d[0]=r[u+4]|r[u+5]<<8|r[u+6]<<16|r[u+7]<<24,d[1]=r[u]|r[u+1]<<8|r[u+2]<<16|r[u+3]<<24,l[0]=r[u+12]|r[u+13]<<8|r[u+14]<<16|r[u+15]<<24,l[1]=r[u+8]|r[u+9]<<8|r[u+10]<<16|r[u+11]<<24,$(d,Re),he(d,31),$(d,Ze),A(s,d),he(s,27),se(s,o),$(s,Dt),se(s,Mn),$(l,Ze),he(l,33),$(l,Re),A(o,l),he(o,31),se(o,s),$(o,Dt),se(o,On);d[0]=0,d[1]=0,l[0]=0,l[1]=0;var h=[0,0];switch(a){case 15:h[1]=r[u+14],W(h,48),A(l,h);case 14:h[1]=r[u+13],W(h,40),A(l,h);case 13:h[1]=r[u+12],W(h,32),A(l,h);case 12:h[1]=r[u+11],W(h,24),A(l,h);case 11:h[1]=r[u+10],W(h,16),A(l,h);case 10:h[1]=r[u+9],W(h,8),A(l,h);case 9:h[1]=r[u+8],A(l,h),$(l,Ze),he(l,33),$(l,Re),A(o,l);case 8:h[1]=r[u+7],W(h,56),A(d,h);case 7:h[1]=r[u+6],W(h,48),A(d,h);case 6:h[1]=r[u+5],W(h,40),A(d,h);case 5:h[1]=r[u+4],W(h,32),A(d,h);case 4:h[1]=r[u+3],W(h,24),A(d,h);case 3:h[1]=r[u+2],W(h,16),A(d,h);case 2:h[1]=r[u+1],W(h,8),A(d,h);case 1:h[1]=r[u],A(d,h),$(d,Re),he(d,31),$(d,Ze),A(s,d)}return A(s,n),A(o,n),se(s,o),se(o,s),zt(s),zt(o),se(s,o),se(o,s),("00000000"+(s[0]>>>0).toString(16)).slice(-8)+("00000000"+(s[1]>>>0).toString(16)).slice(-8)+("00000000"+(o[0]>>>0).toString(16)).slice(-8)+("00000000"+(o[1]>>>0).toString(16)).slice(-8)}function Pn(e){var t;return _t({name:e.name,message:e.message,stack:(t=e.stack)===null||t===void 0?void 0:t.split(`
2
- `)},e)}function Fn(e){return/^function\s.*?\{\s*\[native code]\s*}$/.test(String(e))}function Wn(e){return typeof e!="function"}function zn(e,t){var r=Ce(new Promise(function(n){var a=Date.now();Ft(e.bind(null,t),function(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];var o=Date.now()-a;if(!i[0])return n(function(){return{error:i[1],duration:o}});var d=i[1];if(Wn(d))return n(function(){return{value:d,duration:o}});n(function(){return new Promise(function(l){var u=Date.now();Ft(d,function(){for(var h=[],m=0;m<arguments.length;m++)h[m]=arguments[m];var g=o+Date.now()-u;if(!h[0])return l({error:h[1],duration:g});l({value:h[1],duration:g})})})})})}));return function(){return r.then(function(a){return a()})}}function Dn(e,t,r,n){var a=Object.keys(e).filter(function(s){return Ln(r,s)}),i=Ce(Wt(a,function(s){return zn(e[s],t)},n));return function(){return q(this,void 0,void 0,function(){var o,d,l,u,h;return K(this,function(m){switch(m.label){case 0:return[4,i];case 1:return o=m.sent(),[4,Wt(o,function(g){return Ce(g())},n)];case 2:return d=m.sent(),[4,Promise.all(d)];case 3:for(l=m.sent(),u={},h=0;h<a.length;++h)u[a[h]]=l[h];return[2,u]}})})}}function vr(){var e=window,t=navigator;return P(["MSCSSMatrix"in e,"msSetImmediate"in e,"msIndexedDB"in e,"msMaxTouchPoints"in t,"msPointerEnabled"in t])>=4}function $n(){var e=window,t=navigator;return P(["msWriteProfilerMark"in e,"MSStream"in e,"msLaunchUri"in t,"msSaveBlob"in t])>=3&&!vr()}function Ie(){var e=window,t=navigator;return P(["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 H(){var e=window,t=navigator;return P(["ApplePayError"in e,"CSSPrimitiveValue"in e,"Counter"in e,t.vendor.indexOf("Apple")===0,"RGBColor"in e,"WebKitMediaKeys"in e])>=4}function At(){var e=window,t=e.HTMLElement,r=e.Document;return P(["safari"in e,!("ongestureend"in e),!("TouchEvent"in e),!("orientation"in e),t&&!("autocapitalize"in t.prototype),r&&"pointerLockElement"in r.prototype])>=4}function Ne(){var e=window;return Fn(e.print)&&String(e.browser)==="[object WebPageNamespace]"}function kr(){var e,t,r=window;return P(["buildID"in navigator,"MozAppearance"in((t=(e=document.documentElement)===null||e===void 0?void 0:e.style)!==null&&t!==void 0?t:{}),"onmozfullscreenchange"in r,"mozInnerScreenX"in r,"CSSMozDocumentRule"in r,"CanvasCaptureMediaStream"in r])>=4}function Un(){var e=window;return P([!("MediaSettingsRange"in e),"RTCEncodedAudioFrame"in e,""+e.Intl=="[object Intl]",""+e.Reflect=="[object Reflect]"])>=3}function Bn(){var e=window,t=e.URLPattern;return P(["union"in Set.prototype,"Iterator"in e,t&&"hasRegExpGroups"in t.prototype,"RGB8"in WebGLRenderingContext.prototype])>=3}function Gn(){var e=window;return P(["DOMRectList"in e,"RTCPeerConnectionIceEvent"in e,"SVGGeometryElement"in e,"ontransitioncancel"in e])>=3}function Te(){var e=window,t=navigator,r=e.CSS,n=e.HTMLButtonElement;return P([!("getStorageUpdates"in t),n&&"popover"in n.prototype,"CSSCounterStyleRule"in e,r.supports("font-size-adjust: ex-height 0.5"),r.supports("text-transform: full-width")])>=4}function Yn(){if(navigator.platform==="iPad")return!0;var e=screen,t=e.width/e.height;return P(["MediaSource"in window,!!Element.prototype.webkitRequestFullscreen,t>.65&&t<1.53])>=2}function Hn(){var e=document;return e.fullscreenElement||e.msFullscreenElement||e.mozFullScreenElement||e.webkitFullscreenElement||null}function Xn(){var e=document;return(e.exitFullscreen||e.msExitFullscreen||e.mozCancelFullScreen||e.webkitExitFullscreen).call(e)}function Et(){var e=Ie(),t=kr(),r=window,n=navigator,a="connection";return e?P([!("SharedWorker"in r),n[a]&&"ontypechange"in n[a],!("sinkId"in new Audio)])>=2:t?P(["onorientationchange"in r,"orientation"in r,/android/i.test(n.appVersion)])>=2:!1}function Jn(){var e=navigator,t=window,r=Audio.prototype,n=t.visualViewport;return P(["srLatency"in r,"srChannelCount"in r,"devicePosture"in e,n&&"segments"in n,"getTextInformation"in Image.prototype])>=3}function Qn(){return ea()?-4:qn()}function qn(){var e=window,t=e.OfflineAudioContext||e.webkitOfflineAudioContext;if(!t)return-2;if(Kn())return-1;var r=4500,n=new t(1,5e3,44100),a=n.createOscillator();a.type="triangle",a.frequency.value=1e4;var i=n.createDynamicsCompressor();i.threshold.value=-50,i.knee.value=40,i.ratio.value=12,i.attack.value=0,i.release.value=.25,a.connect(i),i.connect(n.destination),a.start(0);var s=ta(n),o=s[0],d=s[1],l=Ce(o.then(function(u){return ra(u.getChannelData(0).subarray(r))},function(u){if(u.name==="timeout"||u.name==="suspended")return-3;throw u}));return function(){return d(),l}}function Kn(){return H()&&!At()&&!Gn()}function ea(){return H()&&Te()&&Ne()||Ie()&&Jn()&&Bn()}function ta(e){var t=3,r=500,n=500,a=5e3,i=function(){};return[new Promise(function(s,o){var d=!1,l=0,u=0;e.oncomplete=function(g){return s(g.renderedBuffer)};var h=function(){setTimeout(function(){return o($t("timeout"))},Math.min(n,u+a-Date.now()))},m=function(){try{var g=e.startRendering();switch(pr(g)&&Ce(g),e.state){case"running":u=Date.now(),d&&h();break;case"suspended":document.hidden||l++,d&&l>=t?o($t("suspended")):setTimeout(m,r);break}}catch(y){o(y)}};m(),i=function(){d||(d=!0,u>0&&h())}}),i]}function ra(e){for(var t=0,r=0;r<e.length;++r)t+=Math.abs(e[r]);return t}function $t(e){var t=new Error(e);return t.name=e,t}function yr(e,t,r){var n,a,i;return r===void 0&&(r=50),q(this,void 0,void 0,function(){var s,o;return K(this,function(d){switch(d.label){case 0:s=document,d.label=1;case 1:return s.body?[3,3]:[4,Je(r)];case 2:return d.sent(),[3,1];case 3:o=s.createElement("iframe"),d.label=4;case 4:return d.trys.push([4,,10,11]),[4,new Promise(function(l,u){var h=!1,m=function(){h=!0,l()},g=function(S){h=!0,u(S)};o.onload=m,o.onerror=g;var y=o.style;y.setProperty("display","block","important"),y.position="absolute",y.top="0",y.left="0",y.visibility="hidden",t&&"srcdoc"in o?o.srcdoc=t:o.src="about:blank",s.body.appendChild(o);var x=function(){var S,b;h||(((b=(S=o.contentWindow)===null||S===void 0?void 0:S.document)===null||b===void 0?void 0:b.readyState)==="complete"?m():setTimeout(x,10))};x()})];case 5:d.sent(),d.label=6;case 6:return!((a=(n=o.contentWindow)===null||n===void 0?void 0:n.document)===null||a===void 0)&&a.body?[3,8]:[4,Je(r)];case 7:return d.sent(),[3,6];case 8:return[4,e(o,o.contentWindow)];case 9:return[2,d.sent()];case 10:return(i=o.parentNode)===null||i===void 0||i.removeChild(o),[7];case 11:return[2]}})})}function na(e){for(var t=An(e),r=t[0],n=t[1],a=document.createElement(r??"div"),i=0,s=Object.keys(n);i<s.length;i++){var o=s[i],d=n[o].join(" ");o==="style"?aa(a.style,d):a.setAttribute(o,d)}return a}function aa(e,t){for(var r=0,n=t.split(";");r<n.length;r++){var a=n[r],i=/^\s*([\w-]+)\s*:\s*(.+?)(\s*!([\w-]+))?\s*$/.exec(a);if(i){var s=i[1],o=i[2],d=i[4];e.setProperty(s,o,d||"")}}}function ia(){for(var e=window;;){var t=e.parent;if(!t||t===e)return!1;try{if(t.location.origin!==e.location.origin)return!0}catch(r){if(r instanceof Error&&r.name==="SecurityError")return!0;throw r}e=t}}var sa="mmMwWLliI0O&1",oa="48px",fe=["monospace","sans-serif","serif"],Ut=["sans-serif-thin","ARNO PRO","Agency FB","Arabic Typesetting","Arial Unicode MS","AvantGarde Bk BT","BankGothic Md BT","Batang","Bitstream Vera Sans Mono","Calibri","Century","Century Gothic","Clarendon","EUROSTILE","Franklin Gothic","Futura Bk BT","Futura Md BT","GOTHAM","Gill Sans","HELV","Haettenschweiler","Helvetica Neue","Humanst521 BT","Leelawadee","Letter Gothic","Levenim MT","Lucida Bright","Lucida Sans","Menlo","MS Mincho","MS Outlook","MS Reference Specialty","MS UI Gothic","MT Extra","MYRIAD PRO","Marlett","Meiryo UI","Microsoft Uighur","Minion Pro","Monotype Corsiva","PMingLiU","Pristina","SCRIPTINA","Segoe UI Light","Serifa","SimHei","Small Fonts","Staccato222 BT","TRAJAN PRO","Univers CE 55 Medium","Vrinda","ZWAdobeF"];function ca(){var e=this;return yr(function(t,r){var n=r.document;return q(e,void 0,void 0,function(){var a,i,s,o,d,l,u,h,m,g,y,x;return K(this,function(S){for(a=n.body,a.style.fontSize=oa,i=n.createElement("div"),i.style.setProperty("visibility","hidden","important"),s={},o={},d=function(b){var C=n.createElement("span"),R=C.style;return R.position="absolute",R.top="0",R.left="0",R.fontFamily=b,C.textContent=sa,i.appendChild(C),C},l=function(b,C){return d("'".concat(b,"',").concat(C))},u=function(){return fe.map(d)},h=function(){for(var b={},C=function(X){b[X]=fe.map(function(ie){return l(X,ie)})},R=0,D=Ut;R<D.length;R++){var ee=D[R];C(ee)}return b},m=function(b){return fe.some(function(C,R){return b[R].offsetWidth!==s[C]||b[R].offsetHeight!==o[C]})},g=u(),y=h(),a.appendChild(i),x=0;x<fe.length;x++)s[fe[x]]=g[x].offsetWidth,o[fe[x]]=g[x].offsetHeight;return[2,Ut.filter(function(b){return m(y[b])})]})})})}function da(){var e=navigator.plugins;if(e){for(var t=[],r=0;r<e.length;++r){var n=e[r];if(n){for(var a=[],i=0;i<n.length;++i){var s=n[i];a.push({type:s.type,suffixes:s.suffixes})}t.push({name:n.name,description:n.description,mimeTypes:a})}}return t}}function la(){return ua(ka())}function ua(e){var t,r=!1,n,a,i=ha(),s=i[0],o=i[1];return fa(s,o)?(r=ma(o),e?n=a="skipped":(t=pa(s,o),n=t[0],a=t[1])):n=a="unsupported",{winding:r,geometry:n,text:a}}function ha(){var e=document.createElement("canvas");return e.width=1,e.height=1,[e,e.getContext("2d")]}function fa(e,t){return!!(t&&e.toDataURL)}function ma(e){return e.rect(0,0,10,10),e.rect(2,2,6,6),!e.isPointInPath(5,5,"evenodd")}function pa(e,t){ga(e,t);var r=tt(e);return r!==tt(e)?["unstable","unstable"]:(va(e,t),[tt(e),r])}function ga(e,t){e.width=240,e.height=60,t.textBaseline="alphabetic",t.fillStyle="#f60",t.fillRect(100,1,62,20),t.fillStyle="#069",t.font='11pt "Times New Roman"';var r="Cwm fjordbank gly ".concat("😃");t.fillText(r,2,15),t.fillStyle="rgba(102, 204, 0, 0.2)",t.font="18pt Arial",t.fillText(r,4,45)}function va(e,t){e.width=122,e.height=110,t.globalCompositeOperation="multiply";for(var r=0,n=[["#f2f",40,40],["#2ff",80,40],["#ff2",60,80]];r<n.length;r++){var a=n[r],i=a[0],s=a[1],o=a[2];t.fillStyle=i,t.beginPath(),t.arc(s,o,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 tt(e){return e.toDataURL()}function ka(){return H()&&Te()&&Ne()}function ya(){var e=navigator,t=0,r;e.maxTouchPoints!==void 0?t=Lt(e.maxTouchPoints):e.msMaxTouchPoints!==void 0&&(t=e.msMaxTouchPoints);try{document.createEvent("TouchEvent"),r=!0}catch{r=!1}var n="ontouchstart"in window;return{maxTouchPoints:t,touchEvent:r,touchStart:n}}function xa(){return navigator.oscpu}function ba(){var e=navigator,t=[],r=e.language||e.userLanguage||e.browserLanguage||e.systemLanguage;if(r!==void 0&&t.push([r]),Array.isArray(e.languages))Ie()&&Un()||t.push(e.languages);else if(typeof e.languages=="string"){var n=e.languages;n&&t.push(n.split(","))}return t}function _a(){return window.screen.colorDepth}function wa(){return re(G(navigator.deviceMemory),void 0)}function Sa(){if(!(H()&&Te()&&Ne()))return ja()}function ja(){var e=screen,t=function(n){return re(Lt(n),null)},r=[t(e.width),t(e.height)];return r.sort().reverse(),r}var Ca=2500,Ia=10,Ve,rt;function Na(){if(rt===void 0){var e=function(){var t=wt();St(t)?rt=setTimeout(e,Ca):(Ve=t,rt=void 0)};e()}}function Ta(){var e=this;return Na(),function(){return q(e,void 0,void 0,function(){var t;return K(this,function(r){switch(r.label){case 0:return t=wt(),St(t)?Ve?[2,fr([],Ve,!0)]:Hn()?[4,Xn()]:[3,2]:[3,2];case 1:r.sent(),t=wt(),r.label=2;case 2:return St(t)||(Ve=t),[2,t]}})})}}function La(){var e=this;if(H()&&Te()&&Ne())return function(){return Promise.resolve(void 0)};var t=Ta();return function(){return q(e,void 0,void 0,function(){var r,n;return K(this,function(a){switch(a.label){case 0:return[4,t()];case 1:return r=a.sent(),n=function(i){return i===null?null:gr(i,Ia)},[2,[n(r[0]),n(r[1]),n(r[2]),n(r[3])]]}})})}}function wt(){var e=screen;return[re(G(e.availTop),null),re(G(e.width)-G(e.availWidth)-re(G(e.availLeft),0),null),re(G(e.height)-G(e.availHeight)-re(G(e.availTop),0),null),re(G(e.availLeft),null)]}function St(e){for(var t=0;t<4;++t)if(e[t])return!1;return!0}function Aa(){return re(Lt(navigator.hardwareConcurrency),void 0)}function Ea(){var e,t=(e=window.Intl)===null||e===void 0?void 0:e.DateTimeFormat;if(t){var r=new t().resolvedOptions().timeZone;if(r)return r}var n=-Ra();return"UTC".concat(n>=0?"+":"").concat(n)}function Ra(){var e=new Date().getFullYear();return Math.max(G(new Date(e,0,1).getTimezoneOffset()),G(new Date(e,6,1).getTimezoneOffset()))}function Za(){try{return!!window.sessionStorage}catch{return!0}}function Ma(){try{return!!window.localStorage}catch{return!0}}function Oa(){if(!(vr()||$n()))try{return!!window.indexedDB}catch{return!0}}function Va(){return!!window.openDatabase}function Pa(){return navigator.cpuClass}function Fa(){var e=navigator.platform;return e==="MacIntel"&&H()&&!At()?Yn()?"iPad":"iPhone":e}function Wa(){return navigator.vendor||""}function za(){for(var e=[],t=0,r=["chrome","safari","__crWeb","__gCrWeb","yandex","__yb","__ybro","__firefox__","__edgeTrackingPreventionStatistics","webkit","oprt","samsungAr","ucweb","UCShellJava","puffinDevice"];t<r.length;t++){var n=r[t],a=window[n];a&&typeof a=="object"&&e.push(n)}return e.sort()}function Da(){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 $a(){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 Ua(e){var t=(e===void 0?{}:e).debug;return q(this,void 0,void 0,function(){var r,n,a,i,s,o;return K(this,function(d){switch(d.label){case 0:return Ba()?(r=$a(),n=Object.keys(r),a=(o=[]).concat.apply(o,n.map(function(l){return r[l]})),[4,Ga(a)]):[2,void 0];case 1:return i=d.sent(),t&&Ya(r,i),s=n.filter(function(l){var u=r[l];return P(u.map(function(h){return i[h]}))>u.length*.6}),s.sort(),[2,s]}})})}function Ba(){return H()||Et()}function Ga(e){var t;return q(this,void 0,void 0,function(){var r,n,a,i,d,s,o,d;return K(this,function(l){switch(l.label){case 0:for(r=document,n=r.createElement("div"),a=new Array(e.length),i={},Bt(n),d=0;d<e.length;++d)s=na(e[d]),s.tagName==="DIALOG"&&s.show(),o=r.createElement("div"),Bt(o),o.appendChild(s),n.appendChild(o),a[d]=s;l.label=1;case 1:return r.body?[3,3]:[4,Je(50)];case 2:return l.sent(),[3,1];case 3:r.body.appendChild(n);try{for(d=0;d<e.length;++d)a[d].offsetParent||(i[e[d]]=!0)}finally{(t=n.parentNode)===null||t===void 0||t.removeChild(n)}return[2,i]}})})}function Bt(e){e.style.setProperty("visibility","hidden","important"),e.style.setProperty("display","block","important")}function Ya(e,t){for(var r="DOM blockers debug:\n```",n=0,a=Object.keys(e);n<a.length;n++){var i=a[n];r+=`
3
- `.concat(i,":");for(var s=0,o=e[i];s<o.length;s++){var d=o[s];r+=`
4
- `.concat(t[d]?"🚫":"➡️"," ").concat(d)}}}function Ha(){for(var e=0,t=["rec2020","p3","srgb"];e<t.length;e++){var r=t[e];if(matchMedia("(color-gamut: ".concat(r,")")).matches)return r}}function Xa(){if(Gt("inverted"))return!0;if(Gt("none"))return!1}function Gt(e){return matchMedia("(inverted-colors: ".concat(e,")")).matches}function Ja(){if(Yt("active"))return!0;if(Yt("none"))return!1}function Yt(e){return matchMedia("(forced-colors: ".concat(e,")")).matches}var Qa=100;function qa(){if(matchMedia("(min-monochrome: 0)").matches){for(var e=0;e<=Qa;++e)if(matchMedia("(max-monochrome: ".concat(e,")")).matches)return e;throw new Error("Too high value")}}function Ka(){if(me("no-preference"))return 0;if(me("high")||me("more"))return 1;if(me("low")||me("less"))return-1;if(me("forced"))return 10}function me(e){return matchMedia("(prefers-contrast: ".concat(e,")")).matches}function ei(){if(Ht("reduce"))return!0;if(Ht("no-preference"))return!1}function Ht(e){return matchMedia("(prefers-reduced-motion: ".concat(e,")")).matches}function ti(){if(Xt("reduce"))return!0;if(Xt("no-preference"))return!1}function Xt(e){return matchMedia("(prefers-reduced-transparency: ".concat(e,")")).matches}function ri(){if(Jt("high"))return!0;if(Jt("standard"))return!1}function Jt(e){return matchMedia("(dynamic-range: ".concat(e,")")).matches}var L=Math,V=function(){return 0};function ni(){var e=L.acos||V,t=L.acosh||V,r=L.asin||V,n=L.asinh||V,a=L.atanh||V,i=L.atan||V,s=L.sin||V,o=L.sinh||V,d=L.cos||V,l=L.cosh||V,u=L.tan||V,h=L.tanh||V,m=L.exp||V,g=L.expm1||V,y=L.log1p||V,x=function(T){return L.pow(L.PI,T)},S=function(T){return L.log(T+L.sqrt(T*T-1))},b=function(T){return L.log(T+L.sqrt(T*T+1))},C=function(T){return L.log((1+T)/(1-T))/2},R=function(T){return L.exp(T)-1/L.exp(T)/2},D=function(T){return(L.exp(T)+1/L.exp(T))/2},ee=function(T){return L.exp(T)-1},X=function(T){return(L.exp(2*T)-1)/(L.exp(2*T)+1)},ie=function(T){return L.log(1+T)};return{acos:e(.12312423423423424),acosh:t(1e308),acoshPf:S(1e154),asin:r(.12312423423423424),asinh:n(1),asinhPf:b(1),atanh:a(.5),atanhPf:C(.5),atan:i(.5),sin:s(-1e300),sinh:o(1),sinhPf:R(1),cos:d(10.000000000123),cosh:l(1),coshPf:D(1),tan:u(-1e300),tanh:h(1),tanhPf:X(1),exp:m(1),expm1:g(1),expm1Pf:ee(1),log1p:y(10),log1pPf:ie(10),powPI:x(-100)}}var ai="mmMwWLliI0fiflO&1",nt={default:[],apple:[{font:"-apple-system-body"}],serif:[{fontFamily:"serif"}],sans:[{fontFamily:"sans-serif"}],mono:[{fontFamily:"monospace"}],min:[{fontSize:"1px"}],system:[{fontFamily:"system-ui"}]};function ii(){return si(function(e,t){for(var r={},n={},a=0,i=Object.keys(nt);a<i.length;a++){var s=i[a],o=nt[s],d=o[0],l=d===void 0?{}:d,u=o[1],h=u===void 0?ai:u,m=e.createElement("span");m.textContent=h,m.style.whiteSpace="nowrap";for(var g=0,y=Object.keys(l);g<y.length;g++){var x=y[g],S=l[x];S!==void 0&&(m.style[x]=S)}r[s]=m,t.append(e.createElement("br"),m)}for(var b=0,C=Object.keys(nt);b<C.length;b++){var s=C[b];n[s]=r[s].getBoundingClientRect().width}return n})}function si(e,t){return t===void 0&&(t=4e3),yr(function(r,n){var a=n.document,i=a.body,s=i.style;s.width="".concat(t,"px"),s.webkitTextSizeAdjust=s.textSizeAdjust="none",Ie()?i.style.zoom="".concat(1/n.devicePixelRatio):H()&&(i.style.zoom="reset");var o=a.createElement("div");return o.textContent=fr([],Array(t/20<<0),!0).map(function(){return"word"}).join(" "),i.appendChild(o),e(a,i)},'<!doctype html><html><head><meta name="viewport" content="width=device-width, initial-scale=1">')}function oi(){return navigator.pdfViewerEnabled}function ci(){var e=new Float32Array(1),t=new Uint8Array(e.buffer);return e[0]=1/0,e[0]=e[0]-e[0],t[3]}function di(){var e=window.ApplePaySession;if(typeof e?.canMakePayments!="function")return-1;if(li())return-3;try{return e.canMakePayments()?1:0}catch(t){return ui(t)}}var li=ia;function ui(e){if(e instanceof Error&&e.name==="InvalidAccessError"&&/\bfrom\b.*\binsecure\b/i.test(e.message))return-2;throw e}function hi(){var e,t=document.createElement("a"),r=(e=t.attributionSourceId)!==null&&e!==void 0?e:t.attributionsourceid;return r===void 0?void 0:String(r)}var xr=-1,br=-2,fi=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]),mi=new Set([34047,35723,36063,34852,34853,34854,34229,36392,36795,38449]),pi=["FRAGMENT_SHADER","VERTEX_SHADER"],gi=["LOW_FLOAT","MEDIUM_FLOAT","HIGH_FLOAT","LOW_INT","MEDIUM_INT","HIGH_INT"],_r="WEBGL_debug_renderer_info",vi="WEBGL_polygon_mode";function ki(e){var t,r,n,a,i,s,o=e.cache,d=wr(o);if(!d)return xr;if(!jr(d))return br;var l=Sr()?null:d.getExtension(_r);return{version:((t=d.getParameter(d.VERSION))===null||t===void 0?void 0:t.toString())||"",vendor:((r=d.getParameter(d.VENDOR))===null||r===void 0?void 0:r.toString())||"",vendorUnmasked:l?(n=d.getParameter(l.UNMASKED_VENDOR_WEBGL))===null||n===void 0?void 0:n.toString():"",renderer:((a=d.getParameter(d.RENDERER))===null||a===void 0?void 0:a.toString())||"",rendererUnmasked:l?(i=d.getParameter(l.UNMASKED_RENDERER_WEBGL))===null||i===void 0?void 0:i.toString():"",shadingLanguageVersion:((s=d.getParameter(d.SHADING_LANGUAGE_VERSION))===null||s===void 0?void 0:s.toString())||""}}function yi(e){var t=e.cache,r=wr(t);if(!r)return xr;if(!jr(r))return br;var n=r.getSupportedExtensions(),a=r.getContextAttributes(),i=[],s=[],o=[],d=[],l=[];if(a)for(var u=0,h=Object.keys(a);u<h.length;u++){var m=h[u];s.push("".concat(m,"=").concat(a[m]))}for(var g=Qt(r),y=0,x=g;y<x.length;y++){var S=x[y],b=r[S];o.push("".concat(S,"=").concat(b).concat(fi.has(b)?"=".concat(r.getParameter(b)):""))}if(n)for(var C=0,R=n;C<R.length;C++){var D=R[C];if(!(D===_r&&Sr()||D===vi&&_i())){var ee=r.getExtension(D);if(!ee){i.push(D);continue}for(var X=0,ie=Qt(ee);X<ie.length;X++){var S=ie[X],b=ee[S];d.push("".concat(S,"=").concat(b).concat(mi.has(b)?"=".concat(r.getParameter(b)):""))}}}for(var T=0,Le=pi;T<Le.length;T++)for(var Z=Le[T],O=0,Ae=gi;O<Ae.length;O++){var Ee=Ae[O],Yr=xi(r,Z,Ee);l.push("".concat(Z,".").concat(Ee,"=").concat(Yr.join(",")))}return d.sort(),o.sort(),{contextAttributes:s,parameters:o,shaderPrecisions:l,extensions:n,extensionParameters:d,unsupportedExtensions:i}}function wr(e){if(e.webgl)return e.webgl.context;var t=document.createElement("canvas"),r;t.addEventListener("webglCreateContextError",function(){r=void 0});for(var n=0,a=["webgl","experimental-webgl"];n<a.length;n++){var i=a[n];try{r=t.getContext(i)}catch{}if(r)break}return e.webgl={context:r},r}function xi(e,t,r){var n=e.getShaderPrecisionFormat(e[t],e[r]);return n?[n.rangeMin,n.rangeMax,n.precision]:[]}function Qt(e){return Object.keys(e.__proto__).filter(bi)}function bi(e){return typeof e=="string"&&!e.match(/[^A-Z0-9_x]/)}function Sr(){return kr()}function _i(){return Ie()||H()}function jr(e){return typeof e.getParameter=="function"}function wi(){if(!(Et()||H()))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 ji={fonts:ca,domBlockers:Ua,fontPreferences:ii,audio:Qn,screenFrame:La,canvas:la,osCpu:xa,languages:ba,colorDepth:_a,deviceMemory:wa,screenResolution:Sa,hardwareConcurrency:Aa,timezone:Ea,sessionStorage:Za,localStorage:Ma,indexedDB:Oa,openDatabase:Va,cpuClass:Pa,platform:Fa,plugins:da,touchSupport:ya,vendor:Wa,vendorFlavors:za,cookiesEnabled:Da,colorGamut:Ha,invertedColors:Xa,forcedColors:Ja,monochrome:qa,contrast:Ka,reducedMotion:ei,reducedTransparency:ti,hdr:ri,math:ni,pdfViewerEnabled:oi,architecture:ci,applePay:di,privateClickMeasurement:hi,audioBaseLatency:wi,dateTimeLocale:Si,webGlBasics:ki,webGlExtensions:yi};function Ci(e){return Dn(ji,e,[])}var Ii="$ if upgrade to Pro: https://fpjs.dev/pro";function Ni(e){var t=Ti(e),r=Li(t);return{score:t,comment:Ii.replace(/\$/g,"".concat(r))}}function Ti(e){if(Et())return .4;if(H())return At()&&!(Te()&&Ne())?.5:.3;var t="value"in e.platform?e.platform.value:"";return/^Win/.test(t)?.6:/^Mac/.test(t)?.5:.7}function Li(e){return gr(.99+.01*e,1e-4)}function Ai(e){for(var t="",r=0,n=Object.keys(e).sort();r<n.length;r++){var a=n[r],i=e[a],s="error"in i?"error":JSON.stringify(i.value);t+="".concat(t?"|":"").concat(a.replace(/([:|\\])/g,"\\$1"),":").concat(s)}return t}function Ei(e){return JSON.stringify(e,function(t,r){return r instanceof Error?Pn(r):r},2)}function Cr(e){return Vn(Ai(e))}function Ri(e){var t;return{get visitorId(){return t===void 0&&(t=Cr(this.components)),t},set visitorId(r){t=r},confidence:Ni(e),components:e,version:mr}}function Zi(e){return e===void 0&&(e=50),Nn(e,e*2)}function Mi(e,t){var r=Date.now();return{get:function(n){return q(this,void 0,void 0,function(){var a,i,s;return K(this,function(o){switch(o.label){case 0:return a=Date.now(),[4,e()];case 1:return i=o.sent(),s=Ri(i),t||n?.debug,[2,s]}})})}}}function Oi(){if(!(window.__fpjs_d_m||Math.random()>=.001))try{var e=new XMLHttpRequest;e.open("get","https://m1.openfpcdn.io/fingerprintjs/v".concat(mr,"/npm-monitoring"),!0),e.send()}catch{}}function Vi(e){var t;return e===void 0&&(e={}),q(this,void 0,void 0,function(){var r,n,a;return K(this,function(i){switch(i.label){case 0:return(!((t=e.monitoring)!==null&&t!==void 0)||t)&&Oi(),r=e.delayFallback,n=e.debug,[4,Zi(r)];case 1:return i.sent(),a=Ci({cache:{},debug:n}),[2,Mi(a,n)]}})})}var Pi={load:Vi,hashComponents:Cr,componentsToDebugString:Ei},Ir=class{constructor(e,t={}){this.baseUrl=e,this.options=t}get credentials(){return this.options.preview?"include":"same-origin"}async validateWidget(e,t){if(!t)return{valid:!1,error:"Widget is not configured: tenantId is required"};try{const r=new URLSearchParams({agentId:e,tenantId:t}),n=await fetch(`${this.baseUrl}/v1/widget/validate?${r}`,{credentials:this.credentials}),a=await n.json();if(n.ok&&a.success)return{valid:!0,agentId:a.data.agentId,tenantId:a.data.tenantId};const i=a?.code==="AGENT_DISABLED"?"AGENT_DISABLED":n.status===404?"AGENT_NOT_FOUND":void 0;return{valid:!1,error:a.error??`Widget configuration is invalid (${n.status})`,...i?{code:i}:{}}}catch{return{valid:!1,error:"Unable to reach the AgentForge API to validate widget configuration"}}}async chat(e){const t=await fetch(`${this.baseUrl}/v1/agents/${encodeURIComponent(e.agentId)}/responses`,{method:"POST",credentials:this.credentials,headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e.message,sessionId:e.sessionId,tenantId:e.tenantId,externalId:e.externalId,name:e.name,email:e.email,authId:e.authId,fingerprint:e.fingerprint,metadata:e.metadata,imageUrl:e.imageUrl})});if(!t.ok)throw new Error(`API error: ${t.status} ${t.statusText}`);const r=await t.json();if(!r.success)throw new Error(r.error??"Unknown API error");return{content:r.data?.text??"",sessionId:r.data?.sessionId,images:r.data?.images,queued:!!r.data?.queued,controlMode:r.data?.controlMode}}async fetchSessionMessages(e,t){try{const r=t?`?tenantId=${encodeURIComponent(t)}`:"",n=await fetch(`${this.baseUrl}/v1/sessions/${encodeURIComponent(e)}/messages${r}`,{credentials:this.credentials});if(n.status===410||!n.ok)return null;const a=await n.json();return a.success?a.data?.messages??null:null}catch{return null}}async uploadImage(e,t,r,n,a){const i=await fetch(`${this.baseUrl}/v1/upload`,{method:"POST",credentials:this.credentials,headers:{"Content-Type":"application/json"},body:JSON.stringify({file:e,mimeType:t,fileName:r,agentId:n,tenantId:a})});if(!i.ok)throw new Error(`Upload error: ${i.status} ${i.statusText}`);const s=await i.json();if(!s.success)throw new Error(s.error??"Upload failed");return{url:s.data.url}}async fetchWidgetConfig(e,t){try{const r=t?`?tenantId=${encodeURIComponent(t)}`:"",n=await fetch(`${this.baseUrl}/v1/agents/${encodeURIComponent(e)}/widget-config${r}`,{credentials:this.credentials});if(!n.ok)return null;const a=await n.json();return a.success?a.data:null}catch{return null}}async endSession(e,t,r,n,a){const i=await fetch(`${this.baseUrl}/v1/sessions/${encodeURIComponent(e)}/end`,{method:"POST",credentials:this.credentials,headers:{"Content-Type":"application/json"},body:JSON.stringify({tenantId:t,agentId:r,fingerprint:n,externalId:a})});if(!i.ok)throw new Error(`Failed to end session: ${i.status} ${i.statusText}`);const s=await i.json();if(!s.success)throw new Error(s.error??"Failed to end session")}},Fi=12e4;function Wi(e){return Promise.race([e.read(),new Promise((t,r)=>setTimeout(()=>r(new Error("Stream timed out — no data received for 120s")),Fi))])}async function Nr(e,t,r,n={}){let a="",i="";try{const s=await fetch(`${e}/v1/agents/${encodeURIComponent(t.agentId)}/responses:stream`,{method:"POST",credentials:n.preview?"include":"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t.message,sessionId:t.sessionId,tenantId:t.tenantId,externalId:t.externalId,name:t.name,email:t.email,authId:t.authId,fingerprint:t.fingerprint,metadata:t.metadata,imageUrl:t.imageUrl})});if(!s.ok||!s.body){let m=`${s.status} ${s.statusText}`;try{const g=await s.json();g.error&&(m=g.error)}catch{}throw new Error(m)}const o=s.headers.get("x-session-id");o&&r.onSession&&r.onSession(o);const d=s.body.getReader(),l=new TextDecoder;let u="";const h=m=>{if(!m.startsWith("data: "))return!1;const g=m.slice(6).trim();if(!g)return!1;if(g==="[DONE]")return r.onEnd(a),!0;try{const y=JSON.parse(g);if(y.type==="session"){const S=y.sessionId;return S&&r.onSession&&r.onSession(S),!1}if(y.type==="done"||y.type==="stop")return r.onEnd(a),!0;if(y.type==="error")throw new Error(y.message??"Stream error");if(y.type==="images"){const S=y.images;return S&&r.onImages&&r.onImages(S),!1}if(y.type==="control_mode"){const S=y.mode,b=!!y.queued;return S&&r.onControlMode&&r.onControlMode(S,b),b?(r.onEnd(a),!0):!1}if(y.type==="thinking_chunk"){const S=y.content;return S&&r.onThinkingDelta&&(i+=S,r.onThinkingDelta(S,i)),!1}const x=zi(y);x&&(a+=x,r.onDelta(x,a))}catch(y){if(!(y instanceof SyntaxError))throw y}return!1};e:for(;;){const{done:m,value:g}=await Wi(d);if(m)break;u+=l.decode(g,{stream:!0});const y=u.lastIndexOf(`
5
- `);if(y===-1)continue;const x=u.slice(0,y);u=u.slice(y+1);for(const S of x.split(`
6
- `))if(h(S))break e}r.onEnd(a)}catch(s){r.onError(s instanceof Error?s:new Error(String(s)))}}function zi(e){const t=e.choices;if(Array.isArray(t)&&t.length>0){const a=t[0]?.delta,i=a?.content??a?.text??"";if(i)return i}const r=e.delta;if(r){const a=r.content??r.text??"";if(a)return a}const n=e.response;return n||(e.text??e.content??"")}var Tr=class{listeners=new Map;on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(...e){const[t,r]=e;this.listeners.get(t)?.forEach(n=>n(r))}removeAllListeners(){this.listeners.clear()}},Di="agentforge";function Rt(e){return`${Di}:session:${e}`}function Lr(e){try{return sessionStorage.getItem(Rt(e))??void 0}catch{return}}function we(e,t){try{sessionStorage.setItem(Rt(e),t)}catch{}}function jt(e){try{sessionStorage.removeItem(Rt(e))}catch{}}function pe(){return`msg-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`}var Ar=class{config;apiClient;state;fingerprint;eventSource=null;emitter;constructor(e,t,r){this.hostConfig=t,this.onStateChange=r,this.config=e,this.apiClient=new Ir(e.apiBaseUrl,{preview:e.preview}),this.emitter=new Tr,this.initializeFingerprint();const n=e.sessionId??Lr(e.agentId);e.sessionId&&we(e.agentId,e.sessionId);const a=e.mode==="inline";this.state={isOpen:a,messages:[],isLoading:!1,error:null,sessionId:n,initStatus:"validating",initError:null},a&&queueMicrotask(()=>this.openWithGreeting())}async initializeFingerprint(){try{this.fingerprint=(await(await Pi.load()).get()).visitorId}catch{this.fingerprint=void 0}}getState(){return{...this.state,messages:[...this.state.messages]}}setOpen(e){e?this.openWithGreeting():this.setState({isOpen:!1})}openWithGreeting(){this.state.initStatus==="error"||this.state.initStatus==="disabled"||this.setState({isOpen:!0})}async hydrate(){const e=await this.apiClient.validateWidget(this.config.agentId,this.config.tenantId);if(!e.valid){if(e.code==="AGENT_DISABLED"){this.setState({initStatus:"disabled",initError:null});return}this.setState({initStatus:"error",initError:e.error});return}if(!this.config.skipServerConfigFetch){const n=await this.apiClient.fetchWidgetConfig(this.config.agentId,this.config.tenantId);n&&(this.config=qe(this.hostConfig,n),this.onStateChange(this.getState(),this.config))}if(this.setState({initStatus:"ready"}),!this.state.sessionId)return;this.openEventStream();const t=await this.apiClient.fetchSessionMessages(this.state.sessionId,this.config.tenantId);if(t===null){this.handleSessionExpired();return}if(t.length===0)return;const r=t.map(n=>{const a=n.direction==="human";return{id:pe(),role:n.role,content:n.content,images:n.images&&n.images.length>0?n.images:void 0,uploadedImageUrl:n.imageUrl||void 0,createdAt:n.createdAt??new Date().toISOString(),status:"sent",...a?{isHuman:!0,senderDisplay:n.senderDisplay??null}:{}}});this.setState({messages:[...this.state.messages,...r]})}openEventStream(){if(typeof EventSource>"u"||!this.state.sessionId||this.eventSource)return;const e=`${this.config.apiBaseUrl.replace(/\/$/,"")}/v1/sessions/${encodeURIComponent(this.state.sessionId)}/events`,t=new EventSource(e);t.onmessage=r=>{try{const n=JSON.parse(r.data);if(n.type==="control_mode"){const a=n.mode;this.setState({controlMode:a}),this.emitter.emit("control_mode_changed",{mode:a});return}if(n.type==="execution_state"){const a=n.state;a==="ai_thinking"||a==="ai_streaming"||a==="tool_running"?this.setState({isLoading:!0}):a==="idle"&&this.setState({isLoading:!1});return}if(n.type==="message"&&n.message&&typeof n.message=="object"){const a=n.message;if(typeof a.content!="string"||a.id&&this.state.messages.some(i=>i.id===a.id))return;if(a.direction==="human"){const i={id:a.id??pe(),role:"assistant",content:a.content,createdAt:a.createdAt??new Date().toISOString(),status:"sent",isHuman:!0,senderDisplay:a.senderDisplay??null};this.setState({messages:[...this.state.messages,i],isLoading:!1}),this.emitter.emit("message:received",i);return}if(a.direction==="ai"){const i={id:a.id??pe(),role:"assistant",content:a.content,createdAt:a.createdAt??new Date().toISOString(),status:"sent"};this.setState({messages:[...this.state.messages,i],isLoading:!1}),this.emitter.emit("message:received",i);return}}}catch{}},t.onerror=()=>{},this.eventSource=t}closeEventStream(){this.eventSource&&(this.eventSource.close(),this.eventSource=null)}setState(e){this.state={...this.state,...e},this.onStateChange(this.getState(),this.config)}updateMessage(e,t){this.state={...this.state,messages:this.state.messages.map(r=>r.id===e?{...r,...t}:r)},this.onStateChange(this.getState(),this.config)}async resetConversation(){if(this.state.sessionId)try{await this.apiClient.endSession(this.state.sessionId,this.config.tenantId,this.config.agentId,this.fingerprint,this.config.user.externalId)}catch{}jt(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(){jt(this.config.agentId),this.closeEventStream(),this.setState({sessionId:void 0,controlMode:void 0})}async sendMessage(e,t){if(this.state.isLoading||!e.trim()&&!t||this.state.initStatus!=="ready")return;let r;if(t)try{const i=await $i(t);r=(await this.apiClient.uploadImage(i,t.type,t.name,this.config.agentId,this.config.tenantId)).url}catch(i){const s=i instanceof Error?i.message:"Image upload failed";this.setState({error:s});return}const n={id:pe(),role:"user",content:e.trim(),uploadedImageUrl:r,createdAt:new Date().toISOString(),status:"sent"},a=!this.state.messages.some(i=>i.role==="user");this.setState({messages:[...this.state.messages,n],isLoading:!0,error:null}),this.emitter.emit("message:sent",n),a&&this.emitter.emit("conversation:started",{sessionId:this.state.sessionId}),this.config.streaming?await this.sendStreaming(e.trim(),r):await this.sendNonStreaming(e.trim(),r)}async sendNonStreaming(e,t,r=!1){try{const n=await this.apiClient.chat({agentId:this.config.agentId,message:e,sessionId:this.state.sessionId,tenantId:this.config.tenantId,externalId:this.config.user.externalId,name:this.config.user.name,email:this.config.user.email,authId:this.config.user.authId,fingerprint:this.fingerprint,metadata:this.config.metadata,imageUrl:t});if(n.queued&&n.controlMode==="human"){this.setState({isLoading:!1,controlMode:"human_takeover",...n.sessionId?{sessionId:n.sessionId}:{}}),n.sessionId&&(we(this.config.agentId,n.sessionId),this.openEventStream());return}const a={id:pe(),role:"assistant",content:n.content,images:n.images,createdAt:new Date().toISOString(),status:"sent"};this.setState({messages:[...this.state.messages,a],isLoading:!1,...n.sessionId?{sessionId:n.sessionId}:{}}),n.sessionId&&(we(this.config.agentId,n.sessionId),this.openEventStream()),this.emitter.emit("message:received",a)}catch(n){const a=n instanceof Error?n.message:"Failed to send message";if(!r&&a.includes("410"))return this.handleSessionExpired(),this.sendNonStreaming(e,t,!0);this.setState({isLoading:!1,error:a}),this.emitter.emit("message:error",{error:a,message:null})}}async sendStreaming(e,t,r=!1){const n=pe(),a={id:n,role:"assistant",content:"",createdAt:new Date().toISOString(),status:"streaming",isThinking:this.config.thinkingEnabled?!0:void 0};this.setState({messages:[...this.state.messages,a]}),this.emitter.emit("stream:start");let i=!1,s=!1;await Nr(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},{onSession:o=>{this.setState({sessionId:o}),we(this.config.agentId,o),this.openEventStream()},onImages:o=>{this.updateMessage(n,{images:o})},onThinkingDelta:(o,d)=>{this.updateMessage(n,{thinking:d,isThinking:!0}),this.emitter.emit("thinking:delta",{delta:o,accumulated:d})},onDelta:(o,d)=>{this.updateMessage(n,{content:d,isThinking:!1}),this.emitter.emit("stream:delta",{delta:o,accumulated:d})},onEnd:o=>{if(s){this.setState({messages:this.state.messages.filter(l=>l.id!==n),isLoading:!1,controlMode:"human_takeover"}),this.emitter.emit("stream:end",{content:""});return}this.updateMessage(n,{content:o,status:"sent",isThinking:!1}),this.setState({isLoading:!1}),this.emitter.emit("stream:end",{content:o});const d=this.state.messages.find(l=>l.id===n);d&&(d.thinking&&this.emitter.emit("thinking:end",{content:d.thinking}),this.emitter.emit("message:received",d))},onControlMode:(o,d)=>{d&&o==="human"&&(s=!0)},onError:o=>{if(!r&&o.message.includes("410")){i=!0,this.setState({messages:this.state.messages.filter(u=>u.id!==n),isLoading:!1});return}const d=this.state.messages.find(u=>u.id===n)?.content??"",l=o.message||"Something went wrong. Please try again.";this.updateMessage(n,{content:d||l,status:"error"}),this.setState({isLoading:!1,error:l}),this.emitter.emit("message:error",{error:o.message,message:null})}},{preview:this.config.preview}),i&&(this.handleSessionExpired(),await this.sendStreaming(e,t,!0))}};function $i(e){return new Promise((t,r)=>{const n=new FileReader;n.onload=()=>{const a=n.result;t(a.split(",")[1]??"")},n.onerror=()=>r(new Error("Failed to read file")),n.readAsDataURL(e)})}function Er(e){const t=document.createElement("div");t.setAttribute("data-agentkit-widget",""),e.appendChild(t);const r=t.attachShadow({mode:"open"}),n=document.createElement("style");r.appendChild(n);const a=document.createElement("div");return a.style.cssText="display: contents;",r.appendChild(a),{host:t,shadowRoot:r,styleSlot:n,mountPoint:a}}function Rr(e,t){e.textContent=t}function Zr(e){e.remove()}function Mr(){const e=document.createElement("div");return e.setAttribute("data-agentkit-root","floating"),e.style.cssText=["position: fixed","bottom: 24px","right: 24px","z-index: 2147483647","pointer-events: none"].join("; "),document.body.appendChild(e),e}function Ui(e){getComputedStyle(e).position==="static"&&(e.style.position="relative");const t=document.createElement("div");return t.setAttribute("data-agentkit-root","floating"),t.style.cssText=["position: absolute","bottom: 24px","right: 24px","z-index: 2147483647","pointer-events: none"].join("; "),e.appendChild(t),t}function Or(e){return e.setAttribute("data-agentkit-root","inline"),getComputedStyle(e).position==="static"&&(e.style.position="relative"),e}function Bi(e){e.remove()}function Gi(e){e.removeAttribute("data-agentkit-root")}function Zt(e,t,r,n,a){const i=e.mode==="inline";let s=!1;const o=i&&a?Or(a):!i&&a?Ui(a):Mr(),d=Er(o);Rr(d.styleSlot,n);const l=new Ar(e,t,(m,g)=>{s||u.update(m,g)}),u=r(d.mountPoint,e,l.getState(),{onOpen:()=>h.open(),onClose:()=>h.close(),onSendMessage:(m,g)=>{l.sendMessage(m,g)},onReset:()=>{l.resetConversation()}});l.hydrate(),setTimeout(()=>{s||l.emitter.emit("ready",l.getState())},0);const h={open(){s||(l.setOpen(!0),l.emitter.emit("open"))},close(){s||(l.setOpen(!1),l.emitter.emit("close"))},toggle(){l.getState().isOpen?h.close():h.open()},async sendMessage(m,g){await l.sendMessage(m,g)},reset(){s||(l.resetConversation(),l.emitter.emit("reset"))},destroy(){s||(s=!0,u.destroy(),Zr(d.host),i&&a?Gi(a):Bi(o),l.emitter.emit("destroy"),l.emitter.removeAllListeners())},on(m,g){l.emitter.on(m,g)},off(m,g){l.emitter.off(m,g)},getState(){return l.getState()}};return h}var ke=new Map,Yi=0;function Vr(e){const t=`agentkit-widget-${++Yi}`,r=e.destroy.bind(e);return e.destroy=()=>{ke.delete(t),r()},ke.set(t,e),t}function Hi(e,t,r){const n={...e,mode:"floating"},a=Zt(qe(n),n,t,r);return Vr(a),a}function Xi(e,t,r,n){const a={...t,mode:"inline"},i=Zt(qe(a),a,r,n,e);return Vr(i),i}function Ji(e){e?ke.get(e)?.destroy():(ke.forEach(t=>t.destroy()),ke.clear())}function Qi(){return Array.from(ke.keys())}function Pr(e){const{theme:t}=e,r=[`--ak-accent: ${t.accentColor}`,`--ak-font: ${t.fontFamily}`,`--ak-radius: ${t.borderRadius}`];return r.push(`--ak-accent-hover: color-mix(in srgb, ${t.accentColor} 85%, black)`),`:host { ${r.join("; ")} }`}function Fr(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Wr=`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let va=require("preact/compat/client"),A=require("preact/compat"),o=require("preact/jsx-runtime");var E;(function(e){e.assertEqual=n=>{};function t(n){}e.assertIs=t;function r(n){throw new Error}e.assertNever=r,e.arrayToEnum=n=>{const i={};for(const s of n)i[s]=s;return i},e.getValidEnumValues=n=>{const i=e.objectKeys(n).filter(c=>typeof n[n[c]]!="number"),s={};for(const c of i)s[c]=n[c];return e.objectValues(s)},e.objectValues=n=>e.objectKeys(n).map(function(i){return n[i]}),e.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const i=[];for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&i.push(s);return i},e.find=(n,i)=>{for(const s of n)if(i(s))return s},e.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function a(n,i=" | "){return n.map(s=>typeof s=="string"?`'${s}'`:s).join(i)}e.joinValues=a,e.jsonStringifyReplacer=(n,i)=>typeof i=="bigint"?i.toString():i})(E||(E={}));var Gt;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Gt||(Gt={}));var x=E.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ue=e=>{switch(typeof e){case"undefined":return x.undefined;case"string":return x.string;case"number":return Number.isNaN(e)?x.nan:x.number;case"boolean":return x.boolean;case"function":return x.function;case"bigint":return x.bigint;case"symbol":return x.symbol;case"object":return Array.isArray(e)?x.array:e===null?x.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?x.promise:typeof Map<"u"&&e instanceof Map?x.map:typeof Set<"u"&&e instanceof Set?x.set:typeof Date<"u"&&e instanceof Date?x.date:x.object;default:return x.unknown}},f=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"]),te=class pr extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){const r=t||function(i){return i.message},a={_errors:[]},n=i=>{for(const s of i.issues)if(s.code==="invalid_union")s.unionErrors.map(n);else if(s.code==="invalid_return_type")n(s.returnTypeError);else if(s.code==="invalid_arguments")n(s.argumentsError);else if(s.path.length===0)a._errors.push(r(s));else{let c=a,l=0;for(;l<s.path.length;){const d=s.path[l];l!==s.path.length-1?c[d]=c[d]||{_errors:[]}:(c[d]=c[d]||{_errors:[]},c[d]._errors.push(r(s))),c=c[d],l++}}};return n(this),a}static assert(t){if(!(t instanceof pr))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,E.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){const r={},a=[];for(const n of this.issues)if(n.path.length>0){const i=n.path[0];r[i]=r[i]||[],r[i].push(t(n))}else a.push(t(n));return{formErrors:a,fieldErrors:r}}get formErrors(){return this.flatten()}};te.create=e=>new te(e);var Ae=(e,t)=>{let r;switch(e.code){case f.invalid_type:e.received===x.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case f.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,E.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:r=`Unrecognized key(s) in object: ${E.joinValues(e.keys,", ")}`;break;case f.invalid_union:r="Invalid input";break;case f.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${E.joinValues(e.options)}`;break;case f.invalid_enum_value:r=`Invalid enum value. Expected ${E.joinValues(e.options)}, received '${e.received}'`;break;case f.invalid_arguments:r="Invalid function arguments";break;case f.invalid_return_type:r="Invalid function return type";break;case f.invalid_date:r="Invalid date";break;case f.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:E.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case f.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case f.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case f.custom:r="Invalid input";break;case f.invalid_intersection_types:r="Intersection results could not be merged";break;case f.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case f.not_finite:r="Number must be finite";break;default:r=t.defaultError,E.assertNever(e)}return{message:r}},ka=Ae;function pt(){return ka}var mt=e=>{const{data:t,path:r,errorMaps:a,issueData:n}=e,i=[...r,...n.path||[]],s={...n,path:i};if(n.message!==void 0)return{...n,path:i,message:n.message};let c="";const l=a.filter(d=>!!d).slice().reverse();for(const d of l)c=d(s,{data:t,defaultError:c}).message;return{...n,path:i,message:c}};function v(e,t){const r=pt(),a=mt({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Ae?void 0:Ae].filter(n=>!!n)});e.common.issues.push(a)}var Y=class mr{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){const a=[];for(const n of r){if(n.status==="aborted")return w;n.status==="dirty"&&t.dirty(),a.push(n.value)}return{status:t.value,value:a}}static async mergeObjectAsync(t,r){const a=[];for(const n of r){const i=await n.key,s=await n.value;a.push({key:i,value:s})}return mr.mergeObjectSync(t,a)}static mergeObjectSync(t,r){const a={};for(const n of r){const{key:i,value:s}=n;if(i.status==="aborted"||s.status==="aborted")return w;i.status==="dirty"&&t.dirty(),s.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof s.value<"u"||n.alwaysSet)&&(a[i.value]=s.value)}return{status:t.value,value:a}}},w=Object.freeze({status:"aborted"}),Te=e=>({status:"dirty",value:e}),D=e=>({status:"valid",value:e}),Ht=e=>e.status==="aborted",Yt=e=>e.status==="dirty",je=e=>e.status==="valid",He=e=>typeof Promise<"u"&&e instanceof Promise,_;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(_||(_={}));var re=class{constructor(e,t,r,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Xt=(e,t)=>{if(je(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new te(e.common.issues);return this._error=r,this._error}}};function I(e){if(!e)return{};const{errorMap:t,invalid_type_error:r,required_error:a,description:n}=e;if(t&&(r||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:n}:{errorMap:(s,c)=>{const{message:l}=e;return s.code==="invalid_enum_value"?{message:l??c.defaultError}:typeof c.data>"u"?{message:l??a??c.defaultError}:s.code!=="invalid_type"?{message:c.defaultError}:{message:l??r??c.defaultError}},description:n}}var L=class{get description(){return this._def.description}_getType(e){return ue(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ue(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Y,ctx:{common:e.parent.common,data:e.data,parsedType:ue(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(He(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){const r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ue(e)};return Xt(r,this._parseSync({data:e,path:r.path,parent:r}))}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ue(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:t});return je(r)?{value:r.value}:{issues:t.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(r=>je(r)?{value:r.value}:{issues:t.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ue(e)},a=this._parse({data:e,path:r.path,parent:r});return Xt(r,await(He(a)?a:Promise.resolve(a)))}refine(e,t){const r=a=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(a):t;return this._refinement((a,n)=>{const i=e(a),s=()=>n.addIssue({code:f.custom,...r(a)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(s(),!1)):i?!0:(s(),!1)})}refinement(e,t){return this._refinement((r,a)=>e(r)?!0:(a.addIssue(typeof t=="function"?t(r,a):t),!1))}_refinement(e){return new le({schema:this,typeName:j.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return oe.create(this,this._def)}nullable(){return me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Se.create(this)}promise(){return Me.create(this,this._def)}or(e){return Qe.create([this,e],this._def)}and(e){return Ke.create(this,e,this._def)}transform(e){return new le({...I(this._def),schema:this,typeName:j.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new rt({...I(this._def),innerType:this,defaultValue:t,typeName:j.ZodDefault})}brand(){return new _r({typeName:j.ZodBranded,type:this,...I(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new at({...I(this._def),innerType:this,catchValue:t,typeName:j.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return wr.create(this,e)}readonly(){return nt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},xa=/^c[^\s-]{8,}$/i,ba=/^[0-9a-z]+$/,ya=/^[0-9A-HJKMNP-TV-Z]{26}$/i,_a=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,wa=/^[a-z0-9_-]{21}$/i,ja=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Sa=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ca=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ia="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ct,Na=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ta=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,La=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Ea=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Aa=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ma=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,gr="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Ra=new RegExp(`^${gr}$`);function vr(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function Za(e){return new RegExp(`^${vr(e)}$`)}function Oa(e){let t=`${gr}T${vr(e)}`;const r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function Fa(e,t){return!!((t==="v4"||!t)&&Na.test(e)||(t==="v6"||!t)&&La.test(e))}function Pa(e,t){if(!ja.test(e))return!1;try{const[r]=e.split(".");if(!r)return!1;const a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(a));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||t&&n.alg!==t)}catch{return!1}}function Va(e,t){return!!((t==="v4"||!t)&&Ta.test(e)||(t==="v6"||!t)&&Ea.test(e))}var Ye=class Le extends L{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==x.string){const n=this._getOrReturnCtx(t);return v(n,{code:f.invalid_type,expected:x.string,received:n.parsedType}),w}const r=new Y;let a;for(const n of this._def.checks)if(n.kind==="min")t.data.length<n.value&&(a=this._getOrReturnCtx(t,a),v(a,{code:f.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind==="max")t.data.length>n.value&&(a=this._getOrReturnCtx(t,a),v(a,{code:f.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind==="length"){const i=t.data.length>n.value,s=t.data.length<n.value;(i||s)&&(a=this._getOrReturnCtx(t,a),i?v(a,{code:f.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):s&&v(a,{code:f.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),r.dirty())}else if(n.kind==="email")Ca.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"email",code:f.invalid_string,message:n.message}),r.dirty());else if(n.kind==="emoji")ct||(ct=new RegExp(Ia,"u")),ct.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"emoji",code:f.invalid_string,message:n.message}),r.dirty());else if(n.kind==="uuid")_a.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"uuid",code:f.invalid_string,message:n.message}),r.dirty());else if(n.kind==="nanoid")wa.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"nanoid",code:f.invalid_string,message:n.message}),r.dirty());else if(n.kind==="cuid")xa.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"cuid",code:f.invalid_string,message:n.message}),r.dirty());else if(n.kind==="cuid2")ba.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"cuid2",code:f.invalid_string,message:n.message}),r.dirty());else if(n.kind==="ulid")ya.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"ulid",code:f.invalid_string,message:n.message}),r.dirty());else if(n.kind==="url")try{new URL(t.data)}catch{a=this._getOrReturnCtx(t,a),v(a,{validation:"url",code:f.invalid_string,message:n.message}),r.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"regex",code:f.invalid_string,message:n.message}),r.dirty())):n.kind==="trim"?t.data=t.data.trim():n.kind==="includes"?t.data.includes(n.value,n.position)||(a=this._getOrReturnCtx(t,a),v(a,{code:f.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),r.dirty()):n.kind==="toLowerCase"?t.data=t.data.toLowerCase():n.kind==="toUpperCase"?t.data=t.data.toUpperCase():n.kind==="startsWith"?t.data.startsWith(n.value)||(a=this._getOrReturnCtx(t,a),v(a,{code:f.invalid_string,validation:{startsWith:n.value},message:n.message}),r.dirty()):n.kind==="endsWith"?t.data.endsWith(n.value)||(a=this._getOrReturnCtx(t,a),v(a,{code:f.invalid_string,validation:{endsWith:n.value},message:n.message}),r.dirty()):n.kind==="datetime"?Oa(n).test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{code:f.invalid_string,validation:"datetime",message:n.message}),r.dirty()):n.kind==="date"?Ra.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{code:f.invalid_string,validation:"date",message:n.message}),r.dirty()):n.kind==="time"?Za(n).test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{code:f.invalid_string,validation:"time",message:n.message}),r.dirty()):n.kind==="duration"?Sa.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"duration",code:f.invalid_string,message:n.message}),r.dirty()):n.kind==="ip"?Fa(t.data,n.version)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"ip",code:f.invalid_string,message:n.message}),r.dirty()):n.kind==="jwt"?Pa(t.data,n.alg)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"jwt",code:f.invalid_string,message:n.message}),r.dirty()):n.kind==="cidr"?Va(t.data,n.version)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"cidr",code:f.invalid_string,message:n.message}),r.dirty()):n.kind==="base64"?Aa.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"base64",code:f.invalid_string,message:n.message}),r.dirty()):n.kind==="base64url"?Ma.test(t.data)||(a=this._getOrReturnCtx(t,a),v(a,{validation:"base64url",code:f.invalid_string,message:n.message}),r.dirty()):E.assertNever(n);return{status:r.value,value:t.data}}_regex(t,r,a){return this.refinement(n=>t.test(n),{validation:r,code:f.invalid_string,..._.errToObj(a)})}_addCheck(t){return new Le({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",..._.errToObj(t)})}url(t){return this._addCheck({kind:"url",..._.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",..._.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",..._.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",..._.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",..._.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",..._.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",..._.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",..._.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",..._.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",..._.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",..._.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",..._.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,..._.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,..._.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",..._.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,..._.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,..._.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,..._.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,..._.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,..._.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,..._.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,..._.errToObj(r)})}nonempty(t){return this.min(1,_.errToObj(t))}trim(){return new Le({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Le({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Le({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Ye.create=e=>new Ye({checks:[],typeName:j.ZodString,coerce:e?.coerce??!1,...I(e)});function Wa(e,t){const r=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,n=r>a?r:a;return Number.parseInt(e.toFixed(n).replace(".",""))%Number.parseInt(t.toFixed(n).replace(".",""))/10**n}var gt=class vt extends L{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==x.number){const n=this._getOrReturnCtx(t);return v(n,{code:f.invalid_type,expected:x.number,received:n.parsedType}),w}let r;const a=new Y;for(const n of this._def.checks)n.kind==="int"?E.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),v(r,{code:f.invalid_type,expected:"integer",received:"float",message:n.message}),a.dirty()):n.kind==="min"?(n.inclusive?t.data<n.value:t.data<=n.value)&&(r=this._getOrReturnCtx(t,r),v(r,{code:f.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind==="max"?(n.inclusive?t.data>n.value:t.data>=n.value)&&(r=this._getOrReturnCtx(t,r),v(r,{code:f.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind==="multipleOf"?Wa(t.data,n.value)!==0&&(r=this._getOrReturnCtx(t,r),v(r,{code:f.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):n.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),v(r,{code:f.not_finite,message:n.message}),a.dirty()):E.assertNever(n);return{status:a.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,_.toString(r))}gt(t,r){return this.setLimit("min",t,!1,_.toString(r))}lte(t,r){return this.setLimit("max",t,!0,_.toString(r))}lt(t,r){return this.setLimit("max",t,!1,_.toString(r))}setLimit(t,r,a,n){return new vt({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:_.toString(n)}]})}_addCheck(t){return new vt({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:_.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:_.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:_.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_.toString(t)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&E.isInteger(t.value))}get isFinite(){let t=null,r=null;for(const a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(r===null||a.value>r)&&(r=a.value):a.kind==="max"&&(t===null||a.value<t)&&(t=a.value)}return Number.isFinite(r)&&Number.isFinite(t)}};gt.create=e=>new gt({checks:[],typeName:j.ZodNumber,coerce:e?.coerce||!1,...I(e)});var kt=class xt extends L{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==x.bigint)return this._getInvalidInput(t);let r;const a=new Y;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?t.data<n.value:t.data<=n.value)&&(r=this._getOrReturnCtx(t,r),v(r,{code:f.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty()):n.kind==="max"?(n.inclusive?t.data>n.value:t.data>=n.value)&&(r=this._getOrReturnCtx(t,r),v(r,{code:f.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty()):n.kind==="multipleOf"?t.data%n.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),v(r,{code:f.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):E.assertNever(n);return{status:a.value,value:t.data}}_getInvalidInput(t){const r=this._getOrReturnCtx(t);return v(r,{code:f.invalid_type,expected:x.bigint,received:r.parsedType}),w}gte(t,r){return this.setLimit("min",t,!0,_.toString(r))}gt(t,r){return this.setLimit("min",t,!1,_.toString(r))}lte(t,r){return this.setLimit("max",t,!0,_.toString(r))}lt(t,r){return this.setLimit("max",t,!1,_.toString(r))}setLimit(t,r,a,n){return new xt({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:_.toString(n)}]})}_addCheck(t){return new xt({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:_.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:_.toString(r)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};kt.create=e=>new kt({checks:[],typeName:j.ZodBigInt,coerce:e?.coerce??!1,...I(e)});var bt=class extends L{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==x.boolean){const t=this._getOrReturnCtx(e);return v(t,{code:f.invalid_type,expected:x.boolean,received:t.parsedType}),w}return D(e.data)}};bt.create=e=>new bt({typeName:j.ZodBoolean,coerce:e?.coerce||!1,...I(e)});var yt=class kr extends L{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==x.date){const n=this._getOrReturnCtx(t);return v(n,{code:f.invalid_type,expected:x.date,received:n.parsedType}),w}if(Number.isNaN(t.data.getTime()))return v(this._getOrReturnCtx(t),{code:f.invalid_date}),w;const r=new Y;let a;for(const n of this._def.checks)n.kind==="min"?t.data.getTime()<n.value&&(a=this._getOrReturnCtx(t,a),v(a,{code:f.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),r.dirty()):n.kind==="max"?t.data.getTime()>n.value&&(a=this._getOrReturnCtx(t,a),v(a,{code:f.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),r.dirty()):E.assertNever(n);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new kr({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:_.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:_.toString(r)})}get minDate(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};yt.create=e=>new yt({checks:[],coerce:e?.coerce||!1,typeName:j.ZodDate,...I(e)});var _t=class extends L{_parse(e){if(this._getType(e)!==x.symbol){const t=this._getOrReturnCtx(e);return v(t,{code:f.invalid_type,expected:x.symbol,received:t.parsedType}),w}return D(e.data)}};_t.create=e=>new _t({typeName:j.ZodSymbol,...I(e)});var Xe=class extends L{_parse(e){if(this._getType(e)!==x.undefined){const t=this._getOrReturnCtx(e);return v(t,{code:f.invalid_type,expected:x.undefined,received:t.parsedType}),w}return D(e.data)}};Xe.create=e=>new Xe({typeName:j.ZodUndefined,...I(e)});var Je=class extends L{_parse(e){if(this._getType(e)!==x.null){const t=this._getOrReturnCtx(e);return v(t,{code:f.invalid_type,expected:x.null,received:t.parsedType}),w}return D(e.data)}};Je.create=e=>new Je({typeName:j.ZodNull,...I(e)});var wt=class extends L{constructor(){super(...arguments),this._any=!0}_parse(e){return D(e.data)}};wt.create=e=>new wt({typeName:j.ZodAny,...I(e)});var _e=class extends L{constructor(){super(...arguments),this._unknown=!0}_parse(e){return D(e.data)}};_e.create=e=>new _e({typeName:j.ZodUnknown,...I(e)});var he=class extends L{_parse(e){const t=this._getOrReturnCtx(e);return v(t,{code:f.invalid_type,expected:x.never,received:t.parsedType}),w}};he.create=e=>new he({typeName:j.ZodNever,...I(e)});var jt=class extends L{_parse(e){if(this._getType(e)!==x.undefined){const t=this._getOrReturnCtx(e);return v(t,{code:f.invalid_type,expected:x.void,received:t.parsedType}),w}return D(e.data)}};jt.create=e=>new jt({typeName:j.ZodVoid,...I(e)});var Se=class Ue extends L{_parse(t){const{ctx:r,status:a}=this._processInputParams(t),n=this._def;if(r.parsedType!==x.array)return v(r,{code:f.invalid_type,expected:x.array,received:r.parsedType}),w;if(n.exactLength!==null){const s=r.data.length>n.exactLength.value,c=r.data.length<n.exactLength.value;(s||c)&&(v(r,{code:s?f.too_big:f.too_small,minimum:c?n.exactLength.value:void 0,maximum:s?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),a.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(v(r,{code:f.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),a.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(v(r,{code:f.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),a.dirty()),r.common.async)return Promise.all([...r.data].map((s,c)=>n.type._parseAsync(new re(r,s,r.path,c)))).then(s=>Y.mergeArray(a,s));const i=[...r.data].map((s,c)=>n.type._parseSync(new re(r,s,r.path,c)));return Y.mergeArray(a,i)}get element(){return this._def.type}min(t,r){return new Ue({...this._def,minLength:{value:t,message:_.toString(r)}})}max(t,r){return new Ue({...this._def,maxLength:{value:t,message:_.toString(r)}})}length(t,r){return new Ue({...this._def,exactLength:{value:t,message:_.toString(r)}})}nonempty(t){return this.min(1,t)}};Se.create=(e,t)=>new Se({type:e,minLength:null,maxLength:null,exactLength:null,typeName:j.ZodArray,...I(t)});function ye(e){if(e instanceof q){const t={};for(const r in e.shape){const a=e.shape[r];t[r]=oe.create(ye(a))}return new q({...e._def,shape:()=>t})}else return e instanceof Se?new Se({...e._def,type:ye(e.element)}):e instanceof oe?oe.create(ye(e.unwrap())):e instanceof me?me.create(ye(e.unwrap())):e instanceof pe?pe.create(e.items.map(t=>ye(t))):e}var q=class Q extends L{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),r=E.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==x.object){const l=this._getOrReturnCtx(t);return v(l,{code:f.invalid_type,expected:x.object,received:l.parsedType}),w}const{status:r,ctx:a}=this._processInputParams(t),{shape:n,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof he&&this._def.unknownKeys==="strip"))for(const l in a.data)i.includes(l)||s.push(l);const c=[];for(const l of i){const d=n[l],u=a.data[l];c.push({key:{status:"valid",value:l},value:d._parse(new re(a,u,a.path,l)),alwaysSet:l in a.data})}if(this._def.catchall instanceof he){const l=this._def.unknownKeys;if(l==="passthrough")for(const d of s)c.push({key:{status:"valid",value:d},value:{status:"valid",value:a.data[d]}});else if(l==="strict")s.length>0&&(v(a,{code:f.unrecognized_keys,keys:s}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const d of s){const u=a.data[d];c.push({key:{status:"valid",value:d},value:l._parse(new re(a,u,a.path,d)),alwaysSet:d in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const l=[];for(const d of c){const u=await d.key,h=await d.value;l.push({key:u,value:h,alwaysSet:d.alwaysSet})}return l}).then(l=>Y.mergeObjectSync(r,l)):Y.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(t){return _.errToObj,new Q({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,a)=>{const n=this._def.errorMap?.(r,a).message??a.defaultError;return r.code==="unrecognized_keys"?{message:_.errToObj(t).message??n}:{message:n}}}:{}})}strip(){return new Q({...this._def,unknownKeys:"strip"})}passthrough(){return new Q({...this._def,unknownKeys:"passthrough"})}extend(t){return new Q({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Q({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:j.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new Q({...this._def,catchall:t})}pick(t){const r={};for(const a of E.objectKeys(t))t[a]&&this.shape[a]&&(r[a]=this.shape[a]);return new Q({...this._def,shape:()=>r})}omit(t){const r={};for(const a of E.objectKeys(this.shape))t[a]||(r[a]=this.shape[a]);return new Q({...this._def,shape:()=>r})}deepPartial(){return ye(this)}partial(t){const r={};for(const a of E.objectKeys(this.shape)){const n=this.shape[a];t&&!t[a]?r[a]=n:r[a]=n.optional()}return new Q({...this._def,shape:()=>r})}required(t){const r={};for(const a of E.objectKeys(this.shape))if(t&&!t[a])r[a]=this.shape[a];else{let n=this.shape[a];for(;n instanceof oe;)n=n._def.innerType;r[a]=n}return new Q({...this._def,shape:()=>r})}keyof(){return yr(E.objectKeys(this.shape))}};q.create=(e,t)=>new q({shape:()=>e,unknownKeys:"strip",catchall:he.create(),typeName:j.ZodObject,...I(t)});q.strictCreate=(e,t)=>new q({shape:()=>e,unknownKeys:"strict",catchall:he.create(),typeName:j.ZodObject,...I(t)});q.lazycreate=(e,t)=>new q({shape:e,unknownKeys:"strip",catchall:he.create(),typeName:j.ZodObject,...I(t)});var Qe=class extends L{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function a(n){for(const s of n)if(s.result.status==="valid")return s.result;for(const s of n)if(s.result.status==="dirty")return t.common.issues.push(...s.ctx.common.issues),s.result;const i=n.map(s=>new te(s.ctx.common.issues));return v(t,{code:f.invalid_union,unionErrors:i}),w}if(t.common.async)return Promise.all(r.map(async n=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await n._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(a);{let n;const i=[];for(const c of r){const l={...t,common:{...t.common,issues:[]},parent:null},d=c._parseSync({data:t.data,path:t.path,parent:l});if(d.status==="valid")return d;d.status==="dirty"&&!n&&(n={result:d,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;const s=i.map(c=>new te(c));return v(t,{code:f.invalid_union,unionErrors:s}),w}}get options(){return this._def.options}};Qe.create=(e,t)=>new Qe({options:e,typeName:j.ZodUnion,...I(t)});var ie=e=>e instanceof qe?ie(e.schema):e instanceof le?ie(e.innerType()):e instanceof et?[e.value]:e instanceof st?e.options:e instanceof tt?E.objectValues(e.enum):e instanceof rt?ie(e._def.innerType):e instanceof Xe?[void 0]:e instanceof Je?[null]:e instanceof oe?[void 0,...ie(e.unwrap())]:e instanceof me?[null,...ie(e.unwrap())]:e instanceof _r||e instanceof nt?ie(e.unwrap()):e instanceof at?ie(e._def.innerType):[],$a=class xr extends L{_parse(t){const{ctx:r}=this._processInputParams(t);if(r.parsedType!==x.object)return v(r,{code:f.invalid_type,expected:x.object,received:r.parsedType}),w;const a=this.discriminator,n=r.data[a],i=this.optionsMap.get(n);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(v(r,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),w)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,a){const n=new Map;for(const i of r){const s=ie(i.shape[t]);if(!s.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const c of s){if(n.has(c))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(c)}`);n.set(c,i)}}return new xr({typeName:j.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:n,...I(a)})}};function St(e,t){const r=ue(e),a=ue(t);if(e===t)return{valid:!0,data:e};if(r===x.object&&a===x.object){const n=E.objectKeys(t),i=E.objectKeys(e).filter(c=>n.indexOf(c)!==-1),s={...e,...t};for(const c of i){const l=St(e[c],t[c]);if(!l.valid)return{valid:!1};s[c]=l.data}return{valid:!0,data:s}}else if(r===x.array&&a===x.array){if(e.length!==t.length)return{valid:!1};const n=[];for(let i=0;i<e.length;i++){const s=e[i],c=t[i],l=St(s,c);if(!l.valid)return{valid:!1};n.push(l.data)}return{valid:!0,data:n}}else return r===x.date&&a===x.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Ke=class extends L{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),a=(n,i)=>{if(Ht(n)||Ht(i))return w;const s=St(n.value,i.value);return s.valid?((Yt(n)||Yt(i))&&t.dirty(),{status:t.value,value:s.data}):(v(r,{code:f.invalid_intersection_types}),w)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([n,i])=>a(n,i)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};Ke.create=(e,t,r)=>new Ke({left:e,right:t,typeName:j.ZodIntersection,...I(r)});var pe=class br extends L{_parse(t){const{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==x.array)return v(a,{code:f.invalid_type,expected:x.array,received:a.parsedType}),w;if(a.data.length<this._def.items.length)return v(a,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),w;!this._def.rest&&a.data.length>this._def.items.length&&(v(a,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const n=[...a.data].map((i,s)=>{const c=this._def.items[s]||this._def.rest;return c?c._parse(new re(a,i,a.path,s)):null}).filter(i=>!!i);return a.common.async?Promise.all(n).then(i=>Y.mergeArray(r,i)):Y.mergeArray(r,n)}get items(){return this._def.items}rest(t){return new br({...this._def,rest:t})}};pe.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new pe({items:e,typeName:j.ZodTuple,rest:null,...I(t)})};var za=class Ct extends L{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==x.object)return v(a,{code:f.invalid_type,expected:x.object,received:a.parsedType}),w;const n=[],i=this._def.keyType,s=this._def.valueType;for(const c in a.data)n.push({key:i._parse(new re(a,c,a.path,c)),value:s._parse(new re(a,a.data[c],a.path,c)),alwaysSet:c in a.data});return a.common.async?Y.mergeObjectAsync(r,n):Y.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(t,r,a){return r instanceof L?new Ct({keyType:t,valueType:r,typeName:j.ZodRecord,...I(a)}):new Ct({keyType:Ye.create(),valueType:t,typeName:j.ZodRecord,...I(r)})}},It=class extends L{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==x.map)return v(r,{code:f.invalid_type,expected:x.map,received:r.parsedType}),w;const a=this._def.keyType,n=this._def.valueType,i=[...r.data.entries()].map(([s,c],l)=>({key:a._parse(new re(r,s,r.path,[l,"key"])),value:n._parse(new re(r,c,r.path,[l,"value"]))}));if(r.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,d=await c.value;if(l.status==="aborted"||d.status==="aborted")return w;(l.status==="dirty"||d.status==="dirty")&&t.dirty(),s.set(l.value,d.value)}return{status:t.value,value:s}})}else{const s=new Map;for(const c of i){const l=c.key,d=c.value;if(l.status==="aborted"||d.status==="aborted")return w;(l.status==="dirty"||d.status==="dirty")&&t.dirty(),s.set(l.value,d.value)}return{status:t.value,value:s}}}};It.create=(e,t,r)=>new It({valueType:t,keyType:e,typeName:j.ZodMap,...I(r)});var Nt=class Tt extends L{_parse(t){const{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==x.set)return v(a,{code:f.invalid_type,expected:x.set,received:a.parsedType}),w;const n=this._def;n.minSize!==null&&a.data.size<n.minSize.value&&(v(a,{code:f.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&a.data.size>n.maxSize.value&&(v(a,{code:f.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());const i=this._def.valueType;function s(l){const d=new Set;for(const u of l){if(u.status==="aborted")return w;u.status==="dirty"&&r.dirty(),d.add(u.value)}return{status:r.value,value:d}}const c=[...a.data.values()].map((l,d)=>i._parse(new re(a,l,a.path,d)));return a.common.async?Promise.all(c).then(l=>s(l)):s(c)}min(t,r){return new Tt({...this._def,minSize:{value:t,message:_.toString(r)}})}max(t,r){return new Tt({...this._def,maxSize:{value:t,message:_.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};Nt.create=(e,t)=>new Nt({valueType:e,minSize:null,maxSize:null,typeName:j.ZodSet,...I(t)});var Da=class Be extends L{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:r}=this._processInputParams(t);if(r.parsedType!==x.function)return v(r,{code:f.invalid_type,expected:x.function,received:r.parsedType}),w;function a(c,l){return mt({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,pt(),Ae].filter(d=>!!d),issueData:{code:f.invalid_arguments,argumentsError:l}})}function n(c,l){return mt({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,pt(),Ae].filter(d=>!!d),issueData:{code:f.invalid_return_type,returnTypeError:l}})}const i={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof Me){const c=this;return D(async function(...l){const d=new te([]),u=await c._def.args.parseAsync(l,i).catch(p=>{throw d.addIssue(a(l,p)),d}),h=await Reflect.apply(s,this,u);return await c._def.returns._def.type.parseAsync(h,i).catch(p=>{throw d.addIssue(n(h,p)),d})})}else{const c=this;return D(function(...l){const d=c._def.args.safeParse(l,i);if(!d.success)throw new te([a(l,d.error)]);const u=Reflect.apply(s,this,d.data),h=c._def.returns.safeParse(u,i);if(!h.success)throw new te([n(u,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new Be({...this._def,args:pe.create(t).rest(_e.create())})}returns(t){return new Be({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,a){return new Be({args:t||pe.create([]).rest(_e.create()),returns:r||_e.create(),typeName:j.ZodFunction,...I(a)})}},qe=class extends L{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};qe.create=(e,t)=>new qe({getter:e,typeName:j.ZodLazy,...I(t)});var et=class extends L{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return v(t,{received:t.data,code:f.invalid_literal,expected:this._def.value}),w}return{status:"valid",value:e.data}}get value(){return this._def.value}};et.create=(e,t)=>new et({value:e,typeName:j.ZodLiteral,...I(t)});function yr(e,t){return new st({values:e,typeName:j.ZodEnum,...I(t)})}var st=class Lt extends L{_parse(t){if(typeof t.data!="string"){const r=this._getOrReturnCtx(t),a=this._def.values;return v(r,{expected:E.joinValues(a),received:r.parsedType,code:f.invalid_type}),w}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const r=this._getOrReturnCtx(t),a=this._def.values;return v(r,{received:r.data,code:f.invalid_enum_value,options:a}),w}return D(t.data)}get options(){return this._def.values}get enum(){const t={};for(const r of this._def.values)t[r]=r;return t}get Values(){const t={};for(const r of this._def.values)t[r]=r;return t}get Enum(){const t={};for(const r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return Lt.create(t,{...this._def,...r})}exclude(t,r=this._def){return Lt.create(this.options.filter(a=>!t.includes(a)),{...this._def,...r})}};st.create=yr;var tt=class extends L{_parse(e){const t=E.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==x.string&&r.parsedType!==x.number){const a=E.objectValues(t);return v(r,{expected:E.joinValues(a),received:r.parsedType,code:f.invalid_type}),w}if(this._cache||(this._cache=new Set(E.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=E.objectValues(t);return v(r,{received:r.data,code:f.invalid_enum_value,options:a}),w}return D(e.data)}get enum(){return this._def.values}};tt.create=(e,t)=>new tt({values:e,typeName:j.ZodNativeEnum,...I(t)});var Me=class extends L{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);return t.parsedType!==x.promise&&t.common.async===!1?(v(t,{code:f.invalid_type,expected:x.promise,received:t.parsedType}),w):D((t.parsedType===x.promise?t.data:Promise.resolve(t.data)).then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Me.create=(e,t)=>new Me({type:e,typeName:j.ZodPromise,...I(t)});var le=class extends L{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===j.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),a=this._def.effect||null,n={addIssue:i=>{v(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(n.addIssue=n.addIssue.bind(n),a.type==="preprocess"){const i=a.transform(r.data,n);if(r.common.async)return Promise.resolve(i).then(async s=>{if(t.value==="aborted")return w;const c=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return c.status==="aborted"?w:c.status==="dirty"||t.value==="dirty"?Te(c.value):c});{if(t.value==="aborted")return w;const s=this._def.schema._parseSync({data:i,path:r.path,parent:r});return s.status==="aborted"?w:s.status==="dirty"||t.value==="dirty"?Te(s.value):s}}if(a.type==="refinement"){const i=s=>{const c=a.refinement(s,n);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){const s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?w:(s.status==="dirty"&&t.dirty(),i(s.value),{status:t.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?w:(s.status==="dirty"&&t.dirty(),i(s.value).then(()=>({status:t.value,value:s.value}))))}if(a.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!je(i))return w;const s=a.transform(i.value,n);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>je(i)?Promise.resolve(a.transform(i.value,n)).then(s=>({status:t.value,value:s})):w);E.assertNever(a)}};le.create=(e,t,r)=>new le({schema:e,typeName:j.ZodEffects,effect:t,...I(r)});le.createWithPreprocess=(e,t,r)=>new le({schema:t,effect:{type:"preprocess",transform:e},typeName:j.ZodEffects,...I(r)});var oe=class extends L{_parse(e){return this._getType(e)===x.undefined?D(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};oe.create=(e,t)=>new oe({innerType:e,typeName:j.ZodOptional,...I(t)});var me=class extends L{_parse(e){return this._getType(e)===x.null?D(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};me.create=(e,t)=>new me({innerType:e,typeName:j.ZodNullable,...I(t)});var rt=class extends L{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===x.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};rt.create=(e,t)=>new rt({innerType:e,typeName:j.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...I(t)});var at=class extends L{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return He(a)?a.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new te(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new te(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};at.create=(e,t)=>new at({innerType:e,typeName:j.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...I(t)});var Et=class extends L{_parse(e){if(this._getType(e)!==x.nan){const t=this._getOrReturnCtx(e);return v(t,{code:f.invalid_type,expected:x.nan,received:t.parsedType}),w}return{status:"valid",value:e.data}}};Et.create=e=>new Et({typeName:j.ZodNaN,...I(e)});var _r=class extends L{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}},wr=class jr extends L{_parse(t){const{status:r,ctx:a}=this._processInputParams(t);if(a.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?w:i.status==="dirty"?(r.dirty(),Te(i.value)):this._def.out._parseAsync({data:i.value,path:a.path,parent:a})})();{const n=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return n.status==="aborted"?w:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:a.path,parent:a})}}static create(t,r){return new jr({in:t,out:r,typeName:j.ZodPipeline})}},nt=class extends L{_parse(e){const t=this._def.innerType._parse(e),r=a=>(je(a)&&(a.value=Object.freeze(a.value)),a);return He(t)?t.then(a=>r(a)):r(t)}unwrap(){return this._def.innerType}};nt.create=(e,t)=>new nt({innerType:e,typeName:j.ZodReadonly,...I(t)});var Js={object:q.lazycreate},j;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(j||(j={}));var F=Ye.create,Qs=gt.create,Ks=Et.create,qs=kt.create,dt=bt.create,eo=yt.create,to=_t.create,ro=Xe.create,ao=Je.create,no=wt.create,Ua=_e.create,io=he.create,so=jt.create,oo=Se.create,Vt=q.create,lo=q.strictCreate,co=Qe.create,uo=$a.create,ho=Ke.create,fo=pe.create,Ba=za.create,po=It.create,mo=Nt.create,go=Da.create,vo=qe.create,ko=et.create,Sr=st.create,xo=tt.create,bo=Me.create,yo=le.create,_o=oe.create,wo=me.create,jo=le.createWithPreprocess,So=wr.create,Ga=Vt({mode:Sr(["light","dark","system"]).optional(),accentColor:F().optional(),fontFamily:F().optional(),borderRadius:F().optional()}),Ha=Vt({externalId:F().optional(),authId:F().optional(),name:F().optional(),email:F().optional()}),Cr=Vt({agentId:F().min(1,"agentId is required"),apiBaseUrl:F().url("apiBaseUrl must be a valid URL"),tenantId:F().optional(),user:Ha.optional(),sessionId:F().optional(),mode:Sr(["floating","inline"]).optional(),title:F().optional(),subtitle:F().optional(),description:F().optional(),greeting:F().optional(),avatarUrl:F().optional(),privacyPolicyUrl:F().optional(),termsOfServiceUrl:F().optional(),streaming:dt().optional(),preview:dt().optional(),skipServerConfigFetch:dt().optional(),metadata:Ba(Ua()).optional(),theme:Ga.optional()}),Ya=Cr.omit({agentId:!0,apiBaseUrl:!0}).partial(),fe={mode:"floating",streaming:!0,title:"AI Assistant",theme:{mode:"light",accentColor:"#6366f1",fontFamily:"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",borderRadius:"12px"}};function ot(e,t){Cr.parse(e);let r;const a=t?{...t}:void 0;a&&typeof a.theme=="object"&&a.theme!==null?(r=a.theme,delete a.theme):a&&typeof a.theme=="string"&&(r={mode:a.theme},delete a.theme);const n=a?Ya.passthrough().safeParse(a).data:void 0,i=n?Ir(n,e):e,s={mode:i.theme?.mode??r?.mode??fe.theme.mode,accentColor:i.theme?.accentColor??r?.accentColor??fe.theme.accentColor,fontFamily:i.theme?.fontFamily??r?.fontFamily??fe.theme.fontFamily,borderRadius:i.theme?.borderRadius??r?.borderRadius??fe.theme.borderRadius};return{agentId:i.agentId,apiBaseUrl:i.apiBaseUrl.replace(/\/$/,""),tenantId:i.tenantId,user:{externalId:i.user?.externalId,authId:i.user?.authId,name:i.user?.name,email:i.user?.email},sessionId:i.sessionId,mode:i.mode??fe.mode,title:i.title??fe.title,subtitle:i.subtitle,description:i.description,greeting:i.greeting,avatarUrl:i.avatarUrl,privacyPolicyUrl:i.privacyPolicyUrl,termsOfServiceUrl:i.termsOfServiceUrl,streaming:i.streaming??fe.streaming,preview:i.preview===!0,skipServerConfigFetch:i.skipServerConfigFetch===!0,metadata:i.metadata??{},theme:s,thinkingEnabled:n?.thinkingEnabled===!0,thinkingViewable:n?.thinkingViewable===!0,photoSendingEnabled:n?.photoSendingEnabled===!0,fileUploadEnabled:n?.fileUploadEnabled===!0,attachmentMaxCount:(()=>{const c=n?.attachmentMaxCount;return typeof c=="number"&&Number.isFinite(c)?c:5})(),attachmentMaxFileSizeMb:(()=>{const c=n?.attachmentMaxFileSizeMb;return typeof c=="number"&&Number.isFinite(c)?c:1})()}}function Ir(e,t){const r={...e};for(const a of Object.keys(t)){const n=t[a];n!=null&&(typeof n=="object"&&!Array.isArray(n)&&r[a]!==null&&typeof r[a]=="object"?r[a]=Ir(r[a],n):r[a]=n)}return r}var At=function(){return At=Object.assign||function(t){for(var r,a=1,n=arguments.length;a<n;a++){r=arguments[a];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},At.apply(this,arguments)};function ae(e,t,r,a){function n(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function c(u){try{d(a.next(u))}catch(h){s(h)}}function l(u){try{d(a.throw(u))}catch(h){s(h)}}function d(u){u.done?i(u.value):n(u.value).then(c,l)}d((a=a.apply(e,t||[])).next())})}function ne(e,t){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},a,n,i,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=c(0),s.throw=c(1),s.return=c(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(d){return function(u){return l([d,u])}}function l(d){if(a)throw new TypeError("Generator is already executing.");for(;s&&(s=0,d[0]&&(r=0)),r;)try{if(a=1,n&&(i=d[0]&2?n.return:d[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,d[1])).done)return i;switch(n=0,i&&(d=[d[0]&2,i.value]),d[0]){case 0:case 1:i=d;break;case 4:return r.label++,{value:d[1],done:!1};case 5:r.label++,n=d[1],d=[0];continue;case 7:d=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!(i=i.length>0&&i[i.length-1])&&(d[0]===6||d[0]===2)){r=0;continue}if(d[0]===3&&(!i||d[1]>i[0]&&d[1]<i[3])){r.label=d[1];break}if(d[0]===6&&r.label<i[1]){r.label=i[1],i=d;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(d);break}i[2]&&r.ops.pop(),r.trys.pop();continue}d=t.call(e,r)}catch(u){d=[6,u],n=0}finally{a=i=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}function Nr(e,t,r){if(r||arguments.length===2)for(var a=0,n=t.length,i;a<n;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))}var Tr="4.6.2";function it(e,t){return new Promise(function(r){return setTimeout(r,e,t)})}function Xa(){return new Promise(function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})}function Ja(e,t){t===void 0&&(t=1/0);var r=window.requestIdleCallback;return r?new Promise(function(a){return r.call(window,function(){return a()},{timeout:t})}):it(Math.min(e,t))}function Lr(e){return!!e&&typeof e.then=="function"}function Jt(e,t){try{var r=e();Lr(r)?r.then(function(a){return t(!0,a)},function(a){return t(!1,a)}):t(!0,r)}catch(a){t(!1,a)}}function Qt(e,t,r){return r===void 0&&(r=16),ae(this,void 0,void 0,function(){var a,n,i,s;return ne(this,function(c){switch(c.label){case 0:a=Array(e.length),n=Date.now(),i=0,c.label=1;case 1:return i<e.length?(a[i]=t(e[i],i),s=Date.now(),s>=n+r?(n=s,[4,Xa()]):[3,3]):[3,4];case 2:c.sent(),c.label=3;case 3:return++i,[3,1];case 4:return[2,a]}})})}function Re(e){return e.then(void 0,function(){}),e}function Qa(e,t){for(var r=0,a=e.length;r<a;++r)if(e[r]===t)return!0;return!1}function Ka(e,t){return!Qa(e,t)}function Wt(e){return parseInt(e)}function K(e){return parseFloat(e)}function se(e,t){return typeof e=="number"&&isNaN(e)?t:e}function z(e){return e.reduce(function(t,r){return t+(r?1:0)},0)}function Er(e,t){if(t===void 0&&(t=1),Math.abs(t)>=1)return Math.round(e/t)*t;var r=1/t;return Math.round(e*r)/r}function qa(e){for(var t,r,a="Unexpected syntax '".concat(e,"'"),n=/^\s*([a-z-]*)(.*)$/i.exec(e),i=n[1]||void 0,s={},c=/([.:#][\w-]+|\[.+?\])/gi,l=function(p,g){s[p]=s[p]||[],s[p].push(g)};;){var d=c.exec(n[2]);if(!d)break;var u=d[0];switch(u[0]){case".":l("class",u.slice(1));break;case"#":l("id",u.slice(1));break;case"[":var h=/^\[([\w-]+)([~|^$*]?=("(.*?)"|([\w-]+)))?(\s+[is])?\]$/.exec(u);if(h)l(h[1],(r=(t=h[4])!==null&&t!==void 0?t:h[5])!==null&&r!==void 0?r:"");else throw new Error(a);break;default:throw new Error(a)}}return[i,s]}function en(e){for(var t=new Uint8Array(e.length),r=0;r<e.length;r++){var a=e.charCodeAt(r);if(a>127)return new TextEncoder().encode(e);t[r]=a}return t}function de(e,t){var r=e[0]>>>16,a=e[0]&65535,n=e[1]>>>16,i=e[1]&65535,s=t[0]>>>16,c=t[0]&65535,l=t[1]>>>16,d=t[1]&65535,u=0,h=0,p=0,g=0;g+=i+d,p+=g>>>16,g&=65535,p+=n+l,h+=p>>>16,p&=65535,h+=a+c,u+=h>>>16,h&=65535,u+=r+s,u&=65535,e[0]=u<<16|h,e[1]=p<<16|g}function X(e,t){var r=e[0]>>>16,a=e[0]&65535,n=e[1]>>>16,i=e[1]&65535,s=t[0]>>>16,c=t[0]&65535,l=t[1]>>>16,d=t[1]&65535,u=0,h=0,p=0,g=0;g+=i*d,p+=g>>>16,g&=65535,p+=n*d,h+=p>>>16,p&=65535,p+=i*l,h+=p>>>16,p&=65535,h+=a*d,u+=h>>>16,h&=65535,h+=n*l,u+=h>>>16,h&=65535,h+=i*c,u+=h>>>16,h&=65535,u+=r*d+a*l+n*c+i*s,u&=65535,e[0]=u<<16|h,e[1]=p<<16|g}function ve(e,t){var r=e[0];t%=64,t===32?(e[0]=e[1],e[1]=r):t<32?(e[0]=r<<t|e[1]>>>32-t,e[1]=e[1]<<t|r>>>32-t):(t-=32,e[0]=e[1]<<t|r>>>32-t,e[1]=r<<t|e[1]>>>32-t)}function G(e,t){t%=64,t!==0&&(t<32?(e[0]=e[1]>>>32-t,e[1]=e[1]<<t):(e[0]=e[1]<<t-32,e[1]=0))}function Z(e,t){e[0]^=t[0],e[1]^=t[1]}var tn=[4283543511,3981806797],rn=[3301882366,444984403];function Kt(e){var t=[0,e[0]>>>1];Z(e,t),X(e,tn),t[1]=e[0]>>>1,Z(e,t),X(e,rn),t[1]=e[0]>>>1,Z(e,t)}var ze=[2277735313,289559509],De=[1291169091,658871167],qt=[0,5],an=[0,1390208809],nn=[0,944331445];function sn(e,t){var r=en(e);t=t||0;var a=[0,r.length],n=a[1]%16,i=a[1]-n,s=[0,t],c=[0,t],l=[0,0],d=[0,0],u;for(u=0;u<i;u=u+16)l[0]=r[u+4]|r[u+5]<<8|r[u+6]<<16|r[u+7]<<24,l[1]=r[u]|r[u+1]<<8|r[u+2]<<16|r[u+3]<<24,d[0]=r[u+12]|r[u+13]<<8|r[u+14]<<16|r[u+15]<<24,d[1]=r[u+8]|r[u+9]<<8|r[u+10]<<16|r[u+11]<<24,X(l,ze),ve(l,31),X(l,De),Z(s,l),ve(s,27),de(s,c),X(s,qt),de(s,an),X(d,De),ve(d,33),X(d,ze),Z(c,d),ve(c,31),de(c,s),X(c,qt),de(c,nn);l[0]=0,l[1]=0,d[0]=0,d[1]=0;var h=[0,0];switch(n){case 15:h[1]=r[u+14],G(h,48),Z(d,h);case 14:h[1]=r[u+13],G(h,40),Z(d,h);case 13:h[1]=r[u+12],G(h,32),Z(d,h);case 12:h[1]=r[u+11],G(h,24),Z(d,h);case 11:h[1]=r[u+10],G(h,16),Z(d,h);case 10:h[1]=r[u+9],G(h,8),Z(d,h);case 9:h[1]=r[u+8],Z(d,h),X(d,De),ve(d,33),X(d,ze),Z(c,d);case 8:h[1]=r[u+7],G(h,56),Z(l,h);case 7:h[1]=r[u+6],G(h,48),Z(l,h);case 6:h[1]=r[u+5],G(h,40),Z(l,h);case 5:h[1]=r[u+4],G(h,32),Z(l,h);case 4:h[1]=r[u+3],G(h,24),Z(l,h);case 3:h[1]=r[u+2],G(h,16),Z(l,h);case 2:h[1]=r[u+1],G(h,8),Z(l,h);case 1:h[1]=r[u],Z(l,h),X(l,ze),ve(l,31),X(l,De),Z(s,l)}return Z(s,a),Z(c,a),de(s,c),de(c,s),Kt(s),Kt(c),de(s,c),de(c,s),("00000000"+(s[0]>>>0).toString(16)).slice(-8)+("00000000"+(s[1]>>>0).toString(16)).slice(-8)+("00000000"+(c[0]>>>0).toString(16)).slice(-8)+("00000000"+(c[1]>>>0).toString(16)).slice(-8)}function on(e){var t;return At({name:e.name,message:e.message,stack:(t=e.stack)===null||t===void 0?void 0:t.split(`
2
+ `)},e)}function ln(e){return/^function\s.*?\{\s*\[native code]\s*}$/.test(String(e))}function cn(e){return typeof e!="function"}function dn(e,t){var r=Re(new Promise(function(a){var n=Date.now();Jt(e.bind(null,t),function(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];var c=Date.now()-n;if(!i[0])return a(function(){return{error:i[1],duration:c}});var l=i[1];if(cn(l))return a(function(){return{value:l,duration:c}});a(function(){return new Promise(function(d){var u=Date.now();Jt(l,function(){for(var h=[],p=0;p<arguments.length;p++)h[p]=arguments[p];var g=c+Date.now()-u;if(!h[0])return d({error:h[1],duration:g});d({value:h[1],duration:g})})})})})}));return function(){return r.then(function(n){return n()})}}function un(e,t,r,a){var n=Object.keys(e).filter(function(s){return Ka(r,s)}),i=Re(Qt(n,function(s){return dn(e[s],t)},a));return function(){return ae(this,void 0,void 0,function(){var c,l,d,u,h;return ne(this,function(p){switch(p.label){case 0:return[4,i];case 1:return c=p.sent(),[4,Qt(c,function(g){return Re(g())},a)];case 2:return l=p.sent(),[4,Promise.all(l)];case 3:for(d=p.sent(),u={},h=0;h<n.length;++h)u[n[h]]=d[h];return[2,u]}})})}}function Ar(){var e=window,t=navigator;return z(["MSCSSMatrix"in e,"msSetImmediate"in e,"msIndexedDB"in e,"msMaxTouchPoints"in t,"msPointerEnabled"in t])>=4}function hn(){var e=window,t=navigator;return z(["msWriteProfilerMark"in e,"MSStream"in e,"msLaunchUri"in t,"msSaveBlob"in t])>=3&&!Ar()}function Ze(){var e=window,t=navigator;return z(["webkitPersistentStorage"in t,"webkitTemporaryStorage"in t,(t.vendor||"").indexOf("Google")===0,"webkitResolveLocalFileSystemURL"in e,"BatteryManager"in e,"webkitMediaStream"in e,"webkitSpeechGrammar"in e])>=5}function ee(){var e=window,t=navigator;return z(["ApplePayError"in e,"CSSPrimitiveValue"in e,"Counter"in e,t.vendor.indexOf("Apple")===0,"RGBColor"in e,"WebKitMediaKeys"in e])>=4}function $t(){var e=window,t=e.HTMLElement,r=e.Document;return z(["safari"in e,!("ongestureend"in e),!("TouchEvent"in e),!("orientation"in e),t&&!("autocapitalize"in t.prototype),r&&"pointerLockElement"in r.prototype])>=4}function Oe(){var e=window;return ln(e.print)&&String(e.browser)==="[object WebPageNamespace]"}function Mr(){var e,t,r=window;return z(["buildID"in navigator,"MozAppearance"in((t=(e=document.documentElement)===null||e===void 0?void 0:e.style)!==null&&t!==void 0?t:{}),"onmozfullscreenchange"in r,"mozInnerScreenX"in r,"CSSMozDocumentRule"in r,"CanvasCaptureMediaStream"in r])>=4}function fn(){var e=window;return z([!("MediaSettingsRange"in e),"RTCEncodedAudioFrame"in e,""+e.Intl=="[object Intl]",""+e.Reflect=="[object Reflect]"])>=3}function pn(){var e=window,t=e.URLPattern;return z(["union"in Set.prototype,"Iterator"in e,t&&"hasRegExpGroups"in t.prototype,"RGB8"in WebGLRenderingContext.prototype])>=3}function mn(){var e=window;return z(["DOMRectList"in e,"RTCPeerConnectionIceEvent"in e,"SVGGeometryElement"in e,"ontransitioncancel"in e])>=3}function Fe(){var e=window,t=navigator,r=e.CSS,a=e.HTMLButtonElement;return z([!("getStorageUpdates"in t),a&&"popover"in a.prototype,"CSSCounterStyleRule"in e,r.supports("font-size-adjust: ex-height 0.5"),r.supports("text-transform: full-width")])>=4}function gn(){if(navigator.platform==="iPad")return!0;var e=screen,t=e.width/e.height;return z(["MediaSource"in window,!!Element.prototype.webkitRequestFullscreen,t>.65&&t<1.53])>=2}function vn(){var e=document;return e.fullscreenElement||e.msFullscreenElement||e.mozFullScreenElement||e.webkitFullscreenElement||null}function kn(){var e=document;return(e.exitFullscreen||e.msExitFullscreen||e.mozCancelFullScreen||e.webkitExitFullscreen).call(e)}function zt(){var e=Ze(),t=Mr(),r=window,a=navigator,n="connection";return e?z([!("SharedWorker"in r),a[n]&&"ontypechange"in a[n],!("sinkId"in new Audio)])>=2:t?z(["onorientationchange"in r,"orientation"in r,/android/i.test(a.appVersion)])>=2:!1}function xn(){var e=navigator,t=window,r=Audio.prototype,a=t.visualViewport;return z(["srLatency"in r,"srChannelCount"in r,"devicePosture"in e,a&&"segments"in a,"getTextInformation"in Image.prototype])>=3}function bn(){return wn()?-4:yn()}function yn(){var e=window,t=e.OfflineAudioContext||e.webkitOfflineAudioContext;if(!t)return-2;if(_n())return-1;var r=4500,a=new t(1,5e3,44100),n=a.createOscillator();n.type="triangle",n.frequency.value=1e4;var i=a.createDynamicsCompressor();i.threshold.value=-50,i.knee.value=40,i.ratio.value=12,i.attack.value=0,i.release.value=.25,n.connect(i),i.connect(a.destination),n.start(0);var s=jn(a),c=s[0],l=s[1],d=Re(c.then(function(u){return Sn(u.getChannelData(0).subarray(r))},function(u){if(u.name==="timeout"||u.name==="suspended")return-3;throw u}));return function(){return l(),d}}function _n(){return ee()&&!$t()&&!mn()}function wn(){return ee()&&Fe()&&Oe()||Ze()&&xn()&&pn()}function jn(e){var t=3,r=500,a=500,n=5e3,i=function(){};return[new Promise(function(s,c){var l=!1,d=0,u=0;e.oncomplete=function(g){return s(g.renderedBuffer)};var h=function(){setTimeout(function(){return c(er("timeout"))},Math.min(a,u+n-Date.now()))},p=function(){try{var g=e.startRendering();switch(Lr(g)&&Re(g),e.state){case"running":u=Date.now(),l&&h();break;case"suspended":document.hidden||d++,l&&d>=t?c(er("suspended")):setTimeout(p,r);break}}catch(m){c(m)}};p(),i=function(){l||(l=!0,u>0&&h())}}),i]}function Sn(e){for(var t=0,r=0;r<e.length;++r)t+=Math.abs(e[r]);return t}function er(e){var t=new Error(e);return t.name=e,t}function Rr(e,t,r){var a,n,i;return r===void 0&&(r=50),ae(this,void 0,void 0,function(){var s,c;return ne(this,function(l){switch(l.label){case 0:s=document,l.label=1;case 1:return s.body?[3,3]:[4,it(r)];case 2:return l.sent(),[3,1];case 3:c=s.createElement("iframe"),l.label=4;case 4:return l.trys.push([4,,10,11]),[4,new Promise(function(d,u){var h=!1,p=function(){h=!0,d()},g=function(b){h=!0,u(b)};c.onload=p,c.onerror=g;var m=c.style;m.setProperty("display","block","important"),m.position="absolute",m.top="0",m.left="0",m.visibility="hidden",t&&"srcdoc"in c?c.srcdoc=t:c.src="about:blank",s.body.appendChild(c);var k=function(){var b,y;h||(((y=(b=c.contentWindow)===null||b===void 0?void 0:b.document)===null||y===void 0?void 0:y.readyState)==="complete"?p():setTimeout(k,10))};k()})];case 5:l.sent(),l.label=6;case 6:return!((n=(a=c.contentWindow)===null||a===void 0?void 0:a.document)===null||n===void 0)&&n.body?[3,8]:[4,it(r)];case 7:return l.sent(),[3,6];case 8:return[4,e(c,c.contentWindow)];case 9:return[2,l.sent()];case 10:return(i=c.parentNode)===null||i===void 0||i.removeChild(c),[7];case 11:return[2]}})})}function Cn(e){for(var t=qa(e),r=t[0],a=t[1],n=document.createElement(r??"div"),i=0,s=Object.keys(a);i<s.length;i++){var c=s[i],l=a[c].join(" ");c==="style"?In(n.style,l):n.setAttribute(c,l)}return n}function In(e,t){for(var r=0,a=t.split(";");r<a.length;r++){var n=a[r],i=/^\s*([\w-]+)\s*:\s*(.+?)(\s*!([\w-]+))?\s*$/.exec(n);if(i){var s=i[1],c=i[2],l=i[4];e.setProperty(s,c,l||"")}}}function Nn(){for(var e=window;;){var t=e.parent;if(!t||t===e)return!1;try{if(t.location.origin!==e.location.origin)return!0}catch(r){if(r instanceof Error&&r.name==="SecurityError")return!0;throw r}e=t}}var Tn="mmMwWLliI0O&1",Ln="48px",ke=["monospace","sans-serif","serif"],tr=["sans-serif-thin","ARNO PRO","Agency FB","Arabic Typesetting","Arial Unicode MS","AvantGarde Bk BT","BankGothic Md BT","Batang","Bitstream Vera Sans Mono","Calibri","Century","Century Gothic","Clarendon","EUROSTILE","Franklin Gothic","Futura Bk BT","Futura Md BT","GOTHAM","Gill Sans","HELV","Haettenschweiler","Helvetica Neue","Humanst521 BT","Leelawadee","Letter Gothic","Levenim MT","Lucida Bright","Lucida Sans","Menlo","MS Mincho","MS Outlook","MS Reference Specialty","MS UI Gothic","MT Extra","MYRIAD PRO","Marlett","Meiryo UI","Microsoft Uighur","Minion Pro","Monotype Corsiva","PMingLiU","Pristina","SCRIPTINA","Segoe UI Light","Serifa","SimHei","Small Fonts","Staccato222 BT","TRAJAN PRO","Univers CE 55 Medium","Vrinda","ZWAdobeF"];function En(){var e=this;return Rr(function(t,r){var a=r.document;return ae(e,void 0,void 0,function(){var n,i,s,c,l,d,u,h,p,g,m,k;return ne(this,function(b){for(n=a.body,n.style.fontSize=Ln,i=a.createElement("div"),i.style.setProperty("visibility","hidden","important"),s={},c={},l=function(y){var N=a.createElement("span"),R=N.style;return R.position="absolute",R.top="0",R.left="0",R.fontFamily=y,N.textContent=Tn,i.appendChild(N),N},d=function(y,N){return l("'".concat(y,"',").concat(N))},u=function(){return ke.map(l)},h=function(){for(var y={},N=function(V){y[V]=ke.map(function(C){return d(V,C)})},R=0,P=tr;R<P.length;R++){var U=P[R];N(U)}return y},p=function(y){return ke.some(function(N,R){return y[R].offsetWidth!==s[N]||y[R].offsetHeight!==c[N]})},g=u(),m=h(),n.appendChild(i),k=0;k<ke.length;k++)s[ke[k]]=g[k].offsetWidth,c[ke[k]]=g[k].offsetHeight;return[2,tr.filter(function(y){return p(m[y])})]})})})}function An(){var e=navigator.plugins;if(e){for(var t=[],r=0;r<e.length;++r){var a=e[r];if(a){for(var n=[],i=0;i<a.length;++i){var s=a[i];n.push({type:s.type,suffixes:s.suffixes})}t.push({name:a.name,description:a.description,mimeTypes:n})}}return t}}function Mn(){return Rn($n())}function Rn(e){var t,r=!1,a,n,i=Zn(),s=i[0],c=i[1];return On(s,c)?(r=Fn(c),e?a=n="skipped":(t=Pn(s,c),a=t[0],n=t[1])):a=n="unsupported",{winding:r,geometry:a,text:n}}function Zn(){var e=document.createElement("canvas");return e.width=1,e.height=1,[e,e.getContext("2d")]}function On(e,t){return!!(t&&e.toDataURL)}function Fn(e){return e.rect(0,0,10,10),e.rect(2,2,6,6),!e.isPointInPath(5,5,"evenodd")}function Pn(e,t){Vn(e,t);var r=ut(e);return r!==ut(e)?["unstable","unstable"]:(Wn(e,t),[ut(e),r])}function Vn(e,t){e.width=240,e.height=60,t.textBaseline="alphabetic",t.fillStyle="#f60",t.fillRect(100,1,62,20),t.fillStyle="#069",t.font='11pt "Times New Roman"';var r="Cwm fjordbank gly ".concat("😃");t.fillText(r,2,15),t.fillStyle="rgba(102, 204, 0, 0.2)",t.font="18pt Arial",t.fillText(r,4,45)}function Wn(e,t){e.width=122,e.height=110,t.globalCompositeOperation="multiply";for(var r=0,a=[["#f2f",40,40],["#2ff",80,40],["#ff2",60,80]];r<a.length;r++){var n=a[r],i=n[0],s=n[1],c=n[2];t.fillStyle=i,t.beginPath(),t.arc(s,c,40,0,Math.PI*2,!0),t.closePath(),t.fill()}t.fillStyle="#f9c",t.arc(60,60,60,0,Math.PI*2,!0),t.arc(60,60,20,0,Math.PI*2,!0),t.fill("evenodd")}function ut(e){return e.toDataURL()}function $n(){return ee()&&Fe()&&Oe()}function zn(){var e=navigator,t=0,r;e.maxTouchPoints!==void 0?t=Wt(e.maxTouchPoints):e.msMaxTouchPoints!==void 0&&(t=e.msMaxTouchPoints);try{document.createEvent("TouchEvent"),r=!0}catch{r=!1}var a="ontouchstart"in window;return{maxTouchPoints:t,touchEvent:r,touchStart:a}}function Dn(){return navigator.oscpu}function Un(){var e=navigator,t=[],r=e.language||e.userLanguage||e.browserLanguage||e.systemLanguage;if(r!==void 0&&t.push([r]),Array.isArray(e.languages))Ze()&&fn()||t.push(e.languages);else if(typeof e.languages=="string"){var a=e.languages;a&&t.push(a.split(","))}return t}function Bn(){return window.screen.colorDepth}function Gn(){return se(K(navigator.deviceMemory),void 0)}function Hn(){if(!(ee()&&Fe()&&Oe()))return Yn()}function Yn(){var e=screen,t=function(a){return se(Wt(a),null)},r=[t(e.width),t(e.height)];return r.sort().reverse(),r}var Xn=2500,Jn=10,Ge,ht;function Qn(){if(ht===void 0){var e=function(){var t=Mt();Rt(t)?ht=setTimeout(e,Xn):(Ge=t,ht=void 0)};e()}}function Kn(){var e=this;return Qn(),function(){return ae(e,void 0,void 0,function(){var t;return ne(this,function(r){switch(r.label){case 0:return t=Mt(),Rt(t)?Ge?[2,Nr([],Ge,!0)]:vn()?[4,kn()]:[3,2]:[3,2];case 1:r.sent(),t=Mt(),r.label=2;case 2:return Rt(t)||(Ge=t),[2,t]}})})}}function qn(){var e=this;if(ee()&&Fe()&&Oe())return function(){return Promise.resolve(void 0)};var t=Kn();return function(){return ae(e,void 0,void 0,function(){var r,a;return ne(this,function(n){switch(n.label){case 0:return[4,t()];case 1:return r=n.sent(),a=function(i){return i===null?null:Er(i,Jn)},[2,[a(r[0]),a(r[1]),a(r[2]),a(r[3])]]}})})}}function Mt(){var e=screen;return[se(K(e.availTop),null),se(K(e.width)-K(e.availWidth)-se(K(e.availLeft),0),null),se(K(e.height)-K(e.availHeight)-se(K(e.availTop),0),null),se(K(e.availLeft),null)]}function Rt(e){for(var t=0;t<4;++t)if(e[t])return!1;return!0}function ei(){return se(Wt(navigator.hardwareConcurrency),void 0)}function ti(){var e,t=(e=window.Intl)===null||e===void 0?void 0:e.DateTimeFormat;if(t){var r=new t().resolvedOptions().timeZone;if(r)return r}var a=-ri();return"UTC".concat(a>=0?"+":"").concat(a)}function ri(){var e=new Date().getFullYear();return Math.max(K(new Date(e,0,1).getTimezoneOffset()),K(new Date(e,6,1).getTimezoneOffset()))}function ai(){try{return!!window.sessionStorage}catch{return!0}}function ni(){try{return!!window.localStorage}catch{return!0}}function ii(){if(!(Ar()||hn()))try{return!!window.indexedDB}catch{return!0}}function si(){return!!window.openDatabase}function oi(){return navigator.cpuClass}function li(){var e=navigator.platform;return e==="MacIntel"&&ee()&&!$t()?gn()?"iPad":"iPhone":e}function ci(){return navigator.vendor||""}function di(){for(var e=[],t=0,r=["chrome","safari","__crWeb","__gCrWeb","yandex","__yb","__ybro","__firefox__","__edgeTrackingPreventionStatistics","webkit","oprt","samsungAr","ucweb","UCShellJava","puffinDevice"];t<r.length;t++){var a=r[t],n=window[a];n&&typeof n=="object"&&e.push(a)}return e.sort()}function ui(){var e=document;try{e.cookie="cookietest=1; SameSite=Strict;";var t=e.cookie.indexOf("cookietest=")!==-1;return e.cookie="cookietest=1; SameSite=Strict; expires=Thu, 01-Jan-1970 00:00:01 GMT",t}catch{return!1}}function hi(){var e=atob;return{abpIndo:["#Iklan-Melayang","#Kolom-Iklan-728","#SidebarIklan-wrapper",'[title="ALIENBOLA" i]',e("I0JveC1CYW5uZXItYWRz")],abpvn:[".quangcao","#mobileCatfish",e("LmNsb3NlLWFkcw=="),'[id^="bn_bottom_fixed_"]',"#pmadv"],adBlockFinland:[".mainostila",e("LnNwb25zb3JpdA=="),".ylamainos",e("YVtocmVmKj0iL2NsaWNrdGhyZ2guYXNwPyJd"),e("YVtocmVmXj0iaHR0cHM6Ly9hcHAucmVhZHBlYWsuY29tL2FkcyJd")],adBlockPersian:["#navbar_notice_50",".kadr",'TABLE[width="140px"]',"#divAgahi",e("YVtocmVmXj0iaHR0cDovL2cxLnYuZndtcm0ubmV0L2FkLyJd")],adBlockWarningRemoval:["#adblock-honeypot",".adblocker-root",".wp_adblock_detect",e("LmhlYWRlci1ibG9ja2VkLWFk"),e("I2FkX2Jsb2NrZXI=")],adGuardAnnoyances:[".hs-sosyal","#cookieconsentdiv",'div[class^="app_gdpr"]',".as-oil",'[data-cypress="soft-push-notification-modal"]'],adGuardBase:[".BetterJsPopOverlay",e("I2FkXzMwMFgyNTA="),e("I2Jhbm5lcmZsb2F0MjI="),e("I2NhbXBhaWduLWJhbm5lcg=="),e("I0FkLUNvbnRlbnQ=")],adGuardChinese:[e("LlppX2FkX2FfSA=="),e("YVtocmVmKj0iLmh0aGJldDM0LmNvbSJd"),"#widget-quan",e("YVtocmVmKj0iLzg0OTkyMDIwLnh5eiJd"),e("YVtocmVmKj0iLjE5NTZobC5jb20vIl0=")],adGuardFrench:["#pavePub",e("LmFkLWRlc2t0b3AtcmVjdGFuZ2xl"),".mobile_adhesion",".widgetadv",e("LmFkc19iYW4=")],adGuardGerman:['aside[data-portal-id="leaderboard"]'],adGuardJapanese:["#kauli_yad_1",e("YVtocmVmXj0iaHR0cDovL2FkMi50cmFmZmljZ2F0ZS5uZXQvIl0="),e("Ll9wb3BJbl9pbmZpbml0ZV9hZA=="),e("LmFkZ29vZ2xl"),e("Ll9faXNib29zdFJldHVybkFk")],adGuardMobile:[e("YW1wLWF1dG8tYWRz"),e("LmFtcF9hZA=="),'amp-embed[type="24smi"]',"#mgid_iframe1",e("I2FkX2ludmlld19hcmVh")],adGuardRussian:[e("YVtocmVmXj0iaHR0cHM6Ly9hZC5sZXRtZWFkcy5jb20vIl0="),e("LnJlY2xhbWE="),'div[id^="smi2adblock"]',e("ZGl2W2lkXj0iQWRGb3hfYmFubmVyXyJd"),"#psyduckpockeball"],adGuardSocial:[e("YVtocmVmXj0iLy93d3cuc3R1bWJsZXVwb24uY29tL3N1Ym1pdD91cmw9Il0="),e("YVtocmVmXj0iLy90ZWxlZ3JhbS5tZS9zaGFyZS91cmw/Il0="),".etsy-tweet","#inlineShare",".popup-social"],adGuardSpanishPortuguese:["#barraPublicidade","#Publicidade","#publiEspecial","#queTooltip",".cnt-publi"],adGuardTrackingProtection:["#qoo-counter",e("YVtocmVmXj0iaHR0cDovL2NsaWNrLmhvdGxvZy5ydS8iXQ=="),e("YVtocmVmXj0iaHR0cDovL2hpdGNvdW50ZXIucnUvdG9wL3N0YXQucGhwIl0="),e("YVtocmVmXj0iaHR0cDovL3RvcC5tYWlsLnJ1L2p1bXAiXQ=="),"#top100counter"],adGuardTurkish:["#backkapat",e("I3Jla2xhbWk="),e("YVtocmVmXj0iaHR0cDovL2Fkc2Vydi5vbnRlay5jb20udHIvIl0="),e("YVtocmVmXj0iaHR0cDovL2l6bGVuemkuY29tL2NhbXBhaWduLyJd"),e("YVtocmVmXj0iaHR0cDovL3d3dy5pbnN0YWxsYWRzLm5ldC8iXQ==")],bulgarian:[e("dGQjZnJlZW5ldF90YWJsZV9hZHM="),"#ea_intext_div",".lapni-pop-over","#xenium_hot_offers"],easyList:[".yb-floorad",e("LndpZGdldF9wb19hZHNfd2lkZ2V0"),e("LnRyYWZmaWNqdW5reS1hZA=="),".textad_headline",e("LnNwb25zb3JlZC10ZXh0LWxpbmtz")],easyListChina:[e("LmFwcGd1aWRlLXdyYXBbb25jbGljayo9ImJjZWJvcy5jb20iXQ=="),e("LmZyb250cGFnZUFkdk0="),"#taotaole","#aafoot.top_box",".cfa_popup"],easyListCookie:[".ezmob-footer",".cc-CookieWarning","[data-cookie-number]",e("LmF3LWNvb2tpZS1iYW5uZXI="),".sygnal24-gdpr-modal-wrap"],easyListCzechSlovak:["#onlajny-stickers",e("I3Jla2xhbW5pLWJveA=="),e("LnJla2xhbWEtbWVnYWJvYXJk"),".sklik",e("W2lkXj0ic2tsaWtSZWtsYW1hIl0=")],easyListDutch:[e("I2FkdmVydGVudGll"),e("I3ZpcEFkbWFya3RCYW5uZXJCbG9jaw=="),".adstekst",e("YVtocmVmXj0iaHR0cHM6Ly94bHR1YmUubmwvY2xpY2svIl0="),"#semilo-lrectangle"],easyListGermany:["#SSpotIMPopSlider",e("LnNwb25zb3JsaW5rZ3J1ZW4="),e("I3dlcmJ1bmdza3k="),e("I3Jla2xhbWUtcmVjaHRzLW1pdHRl"),e("YVtocmVmXj0iaHR0cHM6Ly9iZDc0Mi5jb20vIl0=")],easyListItaly:[e("LmJveF9hZHZfYW5udW5jaQ=="),".sb-box-pubbliredazionale",e("YVtocmVmXj0iaHR0cDovL2FmZmlsaWF6aW9uaWFkcy5zbmFpLml0LyJd"),e("YVtocmVmXj0iaHR0cHM6Ly9hZHNlcnZlci5odG1sLml0LyJd"),e("YVtocmVmXj0iaHR0cHM6Ly9hZmZpbGlhemlvbmlhZHMuc25haS5pdC8iXQ==")],easyListLithuania:[e("LnJla2xhbW9zX3RhcnBhcw=="),e("LnJla2xhbW9zX251b3JvZG9z"),e("aW1nW2FsdD0iUmVrbGFtaW5pcyBza3lkZWxpcyJd"),e("aW1nW2FsdD0iRGVkaWt1b3RpLmx0IHNlcnZlcmlhaSJd"),e("aW1nW2FsdD0iSG9zdGluZ2FzIFNlcnZlcmlhaS5sdCJd")],estonian:[e("QVtocmVmKj0iaHR0cDovL3BheTRyZXN1bHRzMjQuZXUiXQ==")],fanboyAnnoyances:["#ac-lre-player",".navigate-to-top","#subscribe_popup",".newsletter_holder","#back-top"],fanboyAntiFacebook:[".util-bar-module-firefly-visible"],fanboyEnhancedTrackers:[".open.pushModal","#issuem-leaky-paywall-articles-zero-remaining-nag","#sovrn_container",'div[class$="-hide"][zoompage-fontsize][style="display: block;"]',".BlockNag__Card"],fanboySocial:["#FollowUs","#meteored_share","#social_follow",".article-sharer",".community__social-desc"],frellwitSwedish:[e("YVtocmVmKj0iY2FzaW5vcHJvLnNlIl1bdGFyZ2V0PSJfYmxhbmsiXQ=="),e("YVtocmVmKj0iZG9rdG9yLXNlLm9uZWxpbmsubWUiXQ=="),"article.category-samarbete",e("ZGl2LmhvbGlkQWRz"),"ul.adsmodern"],greekAdBlock:[e("QVtocmVmKj0iYWRtYW4ub3RlbmV0LmdyL2NsaWNrPyJd"),e("QVtocmVmKj0iaHR0cDovL2F4aWFiYW5uZXJzLmV4b2R1cy5nci8iXQ=="),e("QVtocmVmKj0iaHR0cDovL2ludGVyYWN0aXZlLmZvcnRobmV0LmdyL2NsaWNrPyJd"),"DIV.agores300","TABLE.advright"],hungarian:["#cemp_doboz",".optimonk-iframe-container",e("LmFkX19tYWlu"),e("W2NsYXNzKj0iR29vZ2xlQWRzIl0="),"#hirdetesek_box"],iDontCareAboutCookies:['.alert-info[data-block-track*="CookieNotice"]',".ModuleTemplateCookieIndicator",".o--cookies--container","#cookies-policy-sticky","#stickyCookieBar"],icelandicAbp:[e("QVtocmVmXj0iL2ZyYW1ld29yay9yZXNvdXJjZXMvZm9ybXMvYWRzLmFzcHgiXQ==")],latvian:[e("YVtocmVmPSJodHRwOi8vd3d3LnNhbGlkemluaS5sdi8iXVtzdHlsZT0iZGlzcGxheTogYmxvY2s7IHdpZHRoOiAxMjBweDsgaGVpZ2h0OiA0MHB4OyBvdmVyZmxvdzogaGlkZGVuOyBwb3NpdGlvbjogcmVsYXRpdmU7Il0="),e("YVtocmVmPSJodHRwOi8vd3d3LnNhbGlkemluaS5sdi8iXVtzdHlsZT0iZGlzcGxheTogYmxvY2s7IHdpZHRoOiA4OHB4OyBoZWlnaHQ6IDMxcHg7IG92ZXJmbG93OiBoaWRkZW47IHBvc2l0aW9uOiByZWxhdGl2ZTsiXQ==")],listKr:[e("YVtocmVmKj0iLy9hZC5wbGFuYnBsdXMuY28ua3IvIl0="),e("I2xpdmVyZUFkV3JhcHBlcg=="),e("YVtocmVmKj0iLy9hZHYuaW1hZHJlcC5jby5rci8iXQ=="),e("aW5zLmZhc3R2aWV3LWFk"),".revenue_unit_item.dable"],listeAr:[e("LmdlbWluaUxCMUFk"),".right-and-left-sponsers",e("YVtocmVmKj0iLmFmbGFtLmluZm8iXQ=="),e("YVtocmVmKj0iYm9vcmFxLm9yZyJd"),e("YVtocmVmKj0iZHViaXp6bGUuY29tL2FyLz91dG1fc291cmNlPSJd")],listeFr:[e("YVtocmVmXj0iaHR0cDovL3Byb21vLnZhZG9yLmNvbS8iXQ=="),e("I2FkY29udGFpbmVyX3JlY2hlcmNoZQ=="),e("YVtocmVmKj0id2Vib3JhbWEuZnIvZmNnaS1iaW4vIl0="),".site-pub-interstitiel",'div[id^="crt-"][data-criteo-id]'],officialPolish:["#ceneo-placeholder-ceneo-12",e("W2hyZWZePSJodHRwczovL2FmZi5zZW5kaHViLnBsLyJd"),e("YVtocmVmXj0iaHR0cDovL2Fkdm1hbmFnZXIudGVjaGZ1bi5wbC9yZWRpcmVjdC8iXQ=="),e("YVtocmVmXj0iaHR0cDovL3d3dy50cml6ZXIucGwvP3V0bV9zb3VyY2UiXQ=="),e("ZGl2I3NrYXBpZWNfYWQ=")],ro:[e("YVtocmVmXj0iLy9hZmZ0cmsuYWx0ZXgucm8vQ291bnRlci9DbGljayJd"),e("YVtocmVmXj0iaHR0cHM6Ly9ibGFja2ZyaWRheXNhbGVzLnJvL3Ryay9zaG9wLyJd"),e("YVtocmVmXj0iaHR0cHM6Ly9ldmVudC4ycGVyZm9ybWFudC5jb20vZXZlbnRzL2NsaWNrIl0="),e("YVtocmVmXj0iaHR0cHM6Ly9sLnByb2ZpdHNoYXJlLnJvLyJd"),'a[href^="/url/"]'],ruAd:[e("YVtocmVmKj0iLy9mZWJyYXJlLnJ1LyJd"),e("YVtocmVmKj0iLy91dGltZy5ydS8iXQ=="),e("YVtocmVmKj0iOi8vY2hpa2lkaWtpLnJ1Il0="),"#pgeldiz",".yandex-rtb-block"],thaiAds:["a[href*=macau-uta-popup]",e("I2Fkcy1nb29nbGUtbWlkZGxlX3JlY3RhbmdsZS1ncm91cA=="),e("LmFkczMwMHM="),".bumq",".img-kosana"],webAnnoyancesUltralist:["#mod-social-share-2","#social-tools",e("LmN0cGwtZnVsbGJhbm5lcg=="),".zergnet-recommend",".yt.btn-link.btn-md.btn"]}}function fi(e){var t=(e===void 0?{}:e).debug;return ae(this,void 0,void 0,function(){var r,a,n,i,s,c;return ne(this,function(l){switch(l.label){case 0:return pi()?(r=hi(),a=Object.keys(r),n=(c=[]).concat.apply(c,a.map(function(d){return r[d]})),[4,mi(n)]):[2,void 0];case 1:return i=l.sent(),t&&gi(r,i),s=a.filter(function(d){var u=r[d];return z(u.map(function(h){return i[h]}))>u.length*.6}),s.sort(),[2,s]}})})}function pi(){return ee()||zt()}function mi(e){var t;return ae(this,void 0,void 0,function(){var r,a,n,i,l,s,c,l;return ne(this,function(d){switch(d.label){case 0:for(r=document,a=r.createElement("div"),n=new Array(e.length),i={},rr(a),l=0;l<e.length;++l)s=Cn(e[l]),s.tagName==="DIALOG"&&s.show(),c=r.createElement("div"),rr(c),c.appendChild(s),a.appendChild(c),n[l]=s;d.label=1;case 1:return r.body?[3,3]:[4,it(50)];case 2:return d.sent(),[3,1];case 3:r.body.appendChild(a);try{for(l=0;l<e.length;++l)n[l].offsetParent||(i[e[l]]=!0)}finally{(t=a.parentNode)===null||t===void 0||t.removeChild(a)}return[2,i]}})})}function rr(e){e.style.setProperty("visibility","hidden","important"),e.style.setProperty("display","block","important")}function gi(e,t){for(var r="DOM blockers debug:\n```",a=0,n=Object.keys(e);a<n.length;a++){var i=n[a];r+=`
3
+ `.concat(i,":");for(var s=0,c=e[i];s<c.length;s++){var l=c[s];r+=`
4
+ `.concat(t[l]?"🚫":"➡️"," ").concat(l)}}}function vi(){for(var e=0,t=["rec2020","p3","srgb"];e<t.length;e++){var r=t[e];if(matchMedia("(color-gamut: ".concat(r,")")).matches)return r}}function ki(){if(ar("inverted"))return!0;if(ar("none"))return!1}function ar(e){return matchMedia("(inverted-colors: ".concat(e,")")).matches}function xi(){if(nr("active"))return!0;if(nr("none"))return!1}function nr(e){return matchMedia("(forced-colors: ".concat(e,")")).matches}var bi=100;function yi(){if(matchMedia("(min-monochrome: 0)").matches){for(var e=0;e<=bi;++e)if(matchMedia("(max-monochrome: ".concat(e,")")).matches)return e;throw new Error("Too high value")}}function _i(){if(xe("no-preference"))return 0;if(xe("high")||xe("more"))return 1;if(xe("low")||xe("less"))return-1;if(xe("forced"))return 10}function xe(e){return matchMedia("(prefers-contrast: ".concat(e,")")).matches}function wi(){if(ir("reduce"))return!0;if(ir("no-preference"))return!1}function ir(e){return matchMedia("(prefers-reduced-motion: ".concat(e,")")).matches}function ji(){if(sr("reduce"))return!0;if(sr("no-preference"))return!1}function sr(e){return matchMedia("(prefers-reduced-transparency: ".concat(e,")")).matches}function Si(){if(or("high"))return!0;if(or("standard"))return!1}function or(e){return matchMedia("(dynamic-range: ".concat(e,")")).matches}var M=Math,$=function(){return 0};function Ci(){var e=M.acos||$,t=M.acosh||$,r=M.asin||$,a=M.asinh||$,n=M.atanh||$,i=M.atan||$,s=M.sin||$,c=M.sinh||$,l=M.cos||$,d=M.cosh||$,u=M.tan||$,h=M.tanh||$,p=M.exp||$,g=M.expm1||$,m=M.log1p||$,k=function(S){return M.pow(M.PI,S)},b=function(S){return M.log(S+M.sqrt(S*S-1))},y=function(S){return M.log(S+M.sqrt(S*S+1))},N=function(S){return M.log((1+S)/(1-S))/2},R=function(S){return M.exp(S)-1/M.exp(S)/2},P=function(S){return(M.exp(S)+1/M.exp(S))/2},U=function(S){return M.exp(S)-1},V=function(S){return(M.exp(2*S)-1)/(M.exp(2*S)+1)},C=function(S){return M.log(1+S)};return{acos:e(.12312423423423424),acosh:t(1e308),acoshPf:b(1e154),asin:r(.12312423423423424),asinh:a(1),asinhPf:y(1),atanh:n(.5),atanhPf:N(.5),atan:i(.5),sin:s(-1e300),sinh:c(1),sinhPf:R(1),cos:l(10.000000000123),cosh:d(1),coshPf:P(1),tan:u(-1e300),tanh:h(1),tanhPf:V(1),exp:p(1),expm1:g(1),expm1Pf:U(1),log1p:m(10),log1pPf:C(10),powPI:k(-100)}}var Ii="mmMwWLliI0fiflO&1",ft={default:[],apple:[{font:"-apple-system-body"}],serif:[{fontFamily:"serif"}],sans:[{fontFamily:"sans-serif"}],mono:[{fontFamily:"monospace"}],min:[{fontSize:"1px"}],system:[{fontFamily:"system-ui"}]};function Ni(){return Ti(function(e,t){for(var r={},a={},n=0,i=Object.keys(ft);n<i.length;n++){var s=i[n],c=ft[s],l=c[0],d=l===void 0?{}:l,u=c[1],h=u===void 0?Ii:u,p=e.createElement("span");p.textContent=h,p.style.whiteSpace="nowrap";for(var g=0,m=Object.keys(d);g<m.length;g++){var k=m[g],b=d[k];b!==void 0&&(p.style[k]=b)}r[s]=p,t.append(e.createElement("br"),p)}for(var y=0,N=Object.keys(ft);y<N.length;y++){var s=N[y];a[s]=r[s].getBoundingClientRect().width}return a})}function Ti(e,t){return t===void 0&&(t=4e3),Rr(function(r,a){var n=a.document,i=n.body,s=i.style;s.width="".concat(t,"px"),s.webkitTextSizeAdjust=s.textSizeAdjust="none",Ze()?i.style.zoom="".concat(1/a.devicePixelRatio):ee()&&(i.style.zoom="reset");var c=n.createElement("div");return c.textContent=Nr([],Array(t/20<<0),!0).map(function(){return"word"}).join(" "),i.appendChild(c),e(n,i)},'<!doctype html><html><head><meta name="viewport" content="width=device-width, initial-scale=1">')}function Li(){return navigator.pdfViewerEnabled}function Ei(){var e=new Float32Array(1),t=new Uint8Array(e.buffer);return e[0]=1/0,e[0]=e[0]-e[0],t[3]}function Ai(){var e=window.ApplePaySession;if(typeof e?.canMakePayments!="function")return-1;if(Mi())return-3;try{return e.canMakePayments()?1:0}catch(t){return Ri(t)}}var Mi=Nn;function Ri(e){if(e instanceof Error&&e.name==="InvalidAccessError"&&/\bfrom\b.*\binsecure\b/i.test(e.message))return-2;throw e}function Zi(){var e,t=document.createElement("a"),r=(e=t.attributionSourceId)!==null&&e!==void 0?e:t.attributionsourceid;return r===void 0?void 0:String(r)}var Zr=-1,Or=-2,Oi=new Set([10752,2849,2884,2885,2886,2928,2929,2930,2931,2932,2960,2961,2962,2963,2964,2965,2966,2967,2968,2978,3024,3042,3088,3089,3106,3107,32773,32777,32777,32823,32824,32936,32937,32938,32939,32968,32969,32970,32971,3317,33170,3333,3379,3386,33901,33902,34016,34024,34076,3408,3410,3411,3412,3413,3414,3415,34467,34816,34817,34818,34819,34877,34921,34930,35660,35661,35724,35738,35739,36003,36004,36005,36347,36348,36349,37440,37441,37443,7936,7937,7938]),Fi=new Set([34047,35723,36063,34852,34853,34854,34229,36392,36795,38449]),Pi=["FRAGMENT_SHADER","VERTEX_SHADER"],Vi=["LOW_FLOAT","MEDIUM_FLOAT","HIGH_FLOAT","LOW_INT","MEDIUM_INT","HIGH_INT"],Fr="WEBGL_debug_renderer_info",Wi="WEBGL_polygon_mode";function $i(e){var t,r,a,n,i,s,c=e.cache,l=Pr(c);if(!l)return Zr;if(!Wr(l))return Or;var d=Vr()?null:l.getExtension(Fr);return{version:((t=l.getParameter(l.VERSION))===null||t===void 0?void 0:t.toString())||"",vendor:((r=l.getParameter(l.VENDOR))===null||r===void 0?void 0:r.toString())||"",vendorUnmasked:d?(a=l.getParameter(d.UNMASKED_VENDOR_WEBGL))===null||a===void 0?void 0:a.toString():"",renderer:((n=l.getParameter(l.RENDERER))===null||n===void 0?void 0:n.toString())||"",rendererUnmasked:d?(i=l.getParameter(d.UNMASKED_RENDERER_WEBGL))===null||i===void 0?void 0:i.toString():"",shadingLanguageVersion:((s=l.getParameter(l.SHADING_LANGUAGE_VERSION))===null||s===void 0?void 0:s.toString())||""}}function zi(e){var t=e.cache,r=Pr(t);if(!r)return Zr;if(!Wr(r))return Or;var a=r.getSupportedExtensions(),n=r.getContextAttributes(),i=[],s=[],c=[],l=[],d=[];if(n)for(var u=0,h=Object.keys(n);u<h.length;u++){var p=h[u];s.push("".concat(p,"=").concat(n[p]))}for(var g=lr(r),m=0,k=g;m<k.length;m++){var b=k[m],y=r[b];c.push("".concat(b,"=").concat(y).concat(Oi.has(y)?"=".concat(r.getParameter(y)):""))}if(a)for(var N=0,R=a;N<R.length;N++){var P=R[N];if(!(P===Fr&&Vr()||P===Wi&&Bi())){var U=r.getExtension(P);if(!U){i.push(P);continue}for(var V=0,C=lr(U);V<C.length;V++){var b=C[V],y=U[b];l.push("".concat(b,"=").concat(y).concat(Fi.has(y)?"=".concat(r.getParameter(y)):""))}}}for(var S=0,ce=Pi;S<ce.length;S++)for(var Ce=ce[S],ge=0,Pe=Vi;ge<Pe.length;ge++){var Ve=Pe[ge],We=Di(r,Ce,Ve);d.push("".concat(Ce,".").concat(Ve,"=").concat(We.join(",")))}return l.sort(),c.sort(),{contextAttributes:s,parameters:c,shaderPrecisions:d,extensions:a,extensionParameters:l,unsupportedExtensions:i}}function Pr(e){if(e.webgl)return e.webgl.context;var t=document.createElement("canvas"),r;t.addEventListener("webglCreateContextError",function(){r=void 0});for(var a=0,n=["webgl","experimental-webgl"];a<n.length;a++){var i=n[a];try{r=t.getContext(i)}catch{}if(r)break}return e.webgl={context:r},r}function Di(e,t,r){var a=e.getShaderPrecisionFormat(e[t],e[r]);return a?[a.rangeMin,a.rangeMax,a.precision]:[]}function lr(e){return Object.keys(e.__proto__).filter(Ui)}function Ui(e){return typeof e=="string"&&!e.match(/[^A-Z0-9_x]/)}function Vr(){return Mr()}function Bi(){return Ze()||ee()}function Wr(e){return typeof e.getParameter=="function"}function Gi(){if(!(zt()||ee()))return-2;if(!window.AudioContext)return-1;var e=new AudioContext().baseLatency;return e==null?-1:isFinite(e)?e:-3}function Hi(){if(!window.Intl)return-1;var e=window.Intl.DateTimeFormat;if(!e)return-2;var t=e().resolvedOptions().locale;return!t&&t!==""?-3:t}var Yi={fonts:En,domBlockers:fi,fontPreferences:Ni,audio:bn,screenFrame:qn,canvas:Mn,osCpu:Dn,languages:Un,colorDepth:Bn,deviceMemory:Gn,screenResolution:Hn,hardwareConcurrency:ei,timezone:ti,sessionStorage:ai,localStorage:ni,indexedDB:ii,openDatabase:si,cpuClass:oi,platform:li,plugins:An,touchSupport:zn,vendor:ci,vendorFlavors:di,cookiesEnabled:ui,colorGamut:vi,invertedColors:ki,forcedColors:xi,monochrome:yi,contrast:_i,reducedMotion:wi,reducedTransparency:ji,hdr:Si,math:Ci,pdfViewerEnabled:Li,architecture:Ei,applePay:Ai,privateClickMeasurement:Zi,audioBaseLatency:Gi,dateTimeLocale:Hi,webGlBasics:$i,webGlExtensions:zi};function Xi(e){return un(Yi,e,[])}var Ji="$ if upgrade to Pro: https://fpjs.dev/pro";function Qi(e){var t=Ki(e),r=qi(t);return{score:t,comment:Ji.replace(/\$/g,"".concat(r))}}function Ki(e){if(zt())return .4;if(ee())return $t()&&!(Fe()&&Oe())?.5:.3;var t="value"in e.platform?e.platform.value:"";return/^Win/.test(t)?.6:/^Mac/.test(t)?.5:.7}function qi(e){return Er(.99+.01*e,1e-4)}function es(e){for(var t="",r=0,a=Object.keys(e).sort();r<a.length;r++){var n=a[r],i=e[n],s="error"in i?"error":JSON.stringify(i.value);t+="".concat(t?"|":"").concat(n.replace(/([:|\\])/g,"\\$1"),":").concat(s)}return t}function ts(e){return JSON.stringify(e,function(t,r){return r instanceof Error?on(r):r},2)}function $r(e){return sn(es(e))}function rs(e){var t;return{get visitorId(){return t===void 0&&(t=$r(this.components)),t},set visitorId(r){t=r},confidence:Qi(e),components:e,version:Tr}}function as(e){return e===void 0&&(e=50),Ja(e,e*2)}function ns(e,t){var r=Date.now();return{get:function(a){return ae(this,void 0,void 0,function(){var n,i,s;return ne(this,function(c){switch(c.label){case 0:return n=Date.now(),[4,e()];case 1:return i=c.sent(),s=rs(i),t||a?.debug,[2,s]}})})}}}function is(){if(!(window.__fpjs_d_m||Math.random()>=.001))try{var e=new XMLHttpRequest;e.open("get","https://m1.openfpcdn.io/fingerprintjs/v".concat(Tr,"/npm-monitoring"),!0),e.send()}catch{}}function ss(e){var t;return e===void 0&&(e={}),ae(this,void 0,void 0,function(){var r,a,n;return ne(this,function(i){switch(i.label){case 0:return(!((t=e.monitoring)!==null&&t!==void 0)||t)&&is(),r=e.delayFallback,a=e.debug,[4,as(r)];case 1:return i.sent(),n=Xi({cache:{},debug:a}),[2,ns(n,a)]}})})}var os={load:ss,hashComponents:$r,componentsToDebugString:ts},zr=class{baseUrl;options;constructor(e,t={}){this.baseUrl=e,this.options=t}get credentials(){return this.options.preview?"include":"same-origin"}async validateWidget(e,t){if(!t)return{valid:!1,error:"Widget is not configured: tenantId is required"};try{const r=new URLSearchParams({agentId:e,tenantId:t}),a=await fetch(`${this.baseUrl}/v1/widget/validate?${r}`,{credentials:this.credentials}),n=await a.json();if(a.ok&&n.success)return{valid:!0,agentId:n.data.agentId,tenantId:n.data.tenantId};const i=n?.code==="AGENT_DISABLED"?"AGENT_DISABLED":a.status===404?"AGENT_NOT_FOUND":void 0;return{valid:!1,error:n.error??`Widget configuration is invalid (${a.status})`,...i?{code:i}:{}}}catch{return{valid:!1,error:"Unable to reach the KlicForge API to validate widget configuration"}}}async chat(e){const t=await fetch(`${this.baseUrl}/v1/agents/${encodeURIComponent(e.agentId)}/responses`,{method:"POST",credentials:this.credentials,headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e.message,sessionId:e.sessionId,tenantId:e.tenantId,externalId:e.externalId,name:e.name,email:e.email,authId:e.authId,fingerprint:e.fingerprint,metadata:e.metadata,imageUrl:e.imageUrl,attachments:e.attachments})});if(!t.ok)throw new Error(`API error: ${t.status} ${t.statusText}`);const r=await t.json();if(!r.success)throw new Error(r.error??"Unknown API error");return{content:r.data?.text??"",sessionId:r.data?.sessionId,images:r.data?.images,queued:!!r.data?.queued,controlMode:r.data?.controlMode}}async fetchSessionMessages(e,t){try{const r=t?`?tenantId=${encodeURIComponent(t)}`:"",a=await fetch(`${this.baseUrl}/v1/sessions/${encodeURIComponent(e)}/messages${r}`,{credentials:this.credentials});if(a.status===410||!a.ok)return null;const n=await a.json();return n.success?n.data?.messages??null:null}catch{return null}}async uploadImage(e,t,r,a,n){const i=await fetch(`${this.baseUrl}/v1/upload`,{method:"POST",credentials:this.credentials,headers:{"Content-Type":"application/json"},body:JSON.stringify({file:e,mimeType:t,fileName:r,agentId:a,tenantId:n})});if(!i.ok)throw new Error(`Upload error: ${i.status} ${i.statusText}`);const s=await i.json();if(!s.success)throw new Error(s.error??"Upload failed");return{url:s.data.url}}async uploadFile(e,t,r,a,n){const i=await fetch(`${this.baseUrl}/v1/upload`,{method:"POST",credentials:this.credentials,headers:{"Content-Type":"application/json"},body:JSON.stringify({file:e,mimeType:t,fileName:r,agentId:a,tenantId:n,kind:"file"})});if(!i.ok)throw new Error(`Upload error: ${i.status} ${i.statusText}`);const s=await i.json();if(!s.success)throw new Error(s.error??"Upload failed");return{url:s.data.url}}async fetchWidgetConfig(e,t){try{const r=t?`?tenantId=${encodeURIComponent(t)}`:"",a=await fetch(`${this.baseUrl}/v1/agents/${encodeURIComponent(e)}/widget-config${r}`,{credentials:this.credentials});if(!a.ok)return null;const n=await a.json();return n.success?n.data:null}catch{return null}}async endSession(e,t,r,a,n){const i=await fetch(`${this.baseUrl}/v1/sessions/${encodeURIComponent(e)}/end`,{method:"POST",credentials:this.credentials,headers:{"Content-Type":"application/json"},body:JSON.stringify({tenantId:t,agentId:r,fingerprint:a,externalId:n})});if(!i.ok)throw new Error(`Failed to end session: ${i.status} ${i.statusText}`);const s=await i.json();if(!s.success)throw new Error(s.error??"Failed to end session")}},ls=12e4;function cs(e){return Promise.race([e.read(),new Promise((t,r)=>setTimeout(()=>r(new Error("Stream timed out — no data received for 120s")),ls))])}async function Dr(e,t,r,a={}){let n="",i="";try{const s=await fetch(`${e}/v1/agents/${encodeURIComponent(t.agentId)}/responses:stream`,{method:"POST",credentials:a.preview?"include":"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t.message,sessionId:t.sessionId,tenantId:t.tenantId,externalId:t.externalId,name:t.name,email:t.email,authId:t.authId,fingerprint:t.fingerprint,metadata:t.metadata,imageUrl:t.imageUrl,attachments:t.attachments})});if(!s.ok||!s.body){let p=`${s.status} ${s.statusText}`;try{const g=await s.json();g.error&&(p=g.error)}catch{}throw new Error(p)}const c=s.headers.get("x-session-id");c&&r.onSession&&r.onSession(c);const l=s.body.getReader(),d=new TextDecoder;let u="";const h=p=>{if(!p.startsWith("data: "))return!1;const g=p.slice(6).trim();if(!g)return!1;if(g==="[DONE]")return r.onEnd(n),!0;try{const m=JSON.parse(g);if(m.type==="session"){const b=m.sessionId;return b&&r.onSession&&r.onSession(b),!1}if(m.type==="done"||m.type==="stop")return r.onEnd(n),!0;if(m.type==="error")throw new Error(m.message??"Stream error");if(m.type==="images"){const b=m.images;return b&&r.onImages&&r.onImages(b),!1}if(m.type==="control_mode"){const b=m.mode,y=!!m.queued;return b&&r.onControlMode&&r.onControlMode(b,y),y?(r.onEnd(n),!0):!1}if(m.type==="thinking_chunk"){const b=m.content;return b&&r.onThinkingDelta&&(i+=b,r.onThinkingDelta(b,i)),!1}if(m.type==="tool_calls_started"){const b=m.toolNames??[];return n.length>0&&!n.endsWith(`
5
+
6
+ `)&&(n=n.replace(/\s+$/,"")+`
7
+
8
+ `,r.onDelta(`
9
+
10
+ `,n)),r.onToolCallsStarted?.(b),!1}if(m.type==="assistant_ack"){const b=m.text;return b&&r.onAck&&r.onAck(b),!1}if(m.type==="progress"){const b=m.stage,y=m.text;return b&&y&&r.onProgress&&r.onProgress(b,y),!1}if(m.type==="tool_start"){const b=m.toolId,y=m.text;return b&&y&&r.onToolStart&&r.onToolStart(b,y),!1}if(m.type==="tool_complete"){const b=m.toolId,y=m.text,N=m.durationMs;return b&&y&&r.onToolComplete&&r.onToolComplete(b,y,N??0),!1}if(m.type==="model_start"||m.type==="final_meta"){if(m.type==="final_meta"&&r.onFinalMeta){const b=m.metrics;r.onFinalMeta(b??{})}return!1}const k=ds(m);k&&(n+=k,r.onDelta(k,n))}catch(m){if(!(m instanceof SyntaxError))throw m}return!1};e:for(;;){const{done:p,value:g}=await cs(l);if(p)break;u+=d.decode(g,{stream:!0});const m=u.lastIndexOf(`
11
+ `);if(m===-1)continue;const k=u.slice(0,m);u=u.slice(m+1);for(const b of k.split(`
12
+ `))if(h(b))break e}r.onEnd(n)}catch(s){r.onError(s instanceof Error?s:new Error(String(s)))}}function ds(e){const t=e.choices;if(Array.isArray(t)&&t.length>0){const n=t[0]?.delta,i=n?.content??n?.text??"";if(i)return i}const r=e.delta;if(r){const n=r.content??r.text??"";if(n)return n}const a=e.response;return a||(e.text??e.content??"")}var Ur=class{listeners=new Map;on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(...e){const[t,r]=e;this.listeners.get(t)?.forEach(a=>a(r))}removeAllListeners(){this.listeners.clear()}},us="agentforge";function Dt(e){return`${us}:session:${e}`}function Br(e){try{return sessionStorage.getItem(Dt(e))??void 0}catch{return}}function Ee(e,t){try{sessionStorage.setItem(Dt(e),t)}catch{}}function Zt(e){try{sessionStorage.removeItem(Dt(e))}catch{}}function be(){return`msg-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`}var Gr=class{hostConfig;onStateChange;config;apiClient;state;fingerprint;eventSource=null;emitter;constructor(e,t,r){this.hostConfig=t,this.onStateChange=r,this.config=e,this.apiClient=new zr(e.apiBaseUrl,{preview:e.preview}),this.emitter=new Ur,this.initializeFingerprint();const a=e.sessionId??Br(e.agentId);e.sessionId&&Ee(e.agentId,e.sessionId);const n=e.mode==="inline";this.state={isOpen:n,messages:[],isLoading:!1,error:null,sessionId:a,initStatus:"validating",initError:null},n&&queueMicrotask(()=>this.openWithGreeting())}async initializeFingerprint(){try{const e=await(await os.load()).get();this.fingerprint=e.visitorId}catch{this.fingerprint=void 0}}getState(){return{...this.state,messages:[...this.state.messages]}}setOpen(e){e?this.openWithGreeting():this.setState({isOpen:!1})}openWithGreeting(){this.state.initStatus==="error"||this.state.initStatus==="disabled"||this.setState({isOpen:!0})}async hydrate(){const e=await this.apiClient.validateWidget(this.config.agentId,this.config.tenantId);if(!e.valid){if(e.code==="AGENT_DISABLED"){this.setState({initStatus:"disabled",initError:null});return}this.setState({initStatus:"error",initError:e.error});return}if(!this.config.skipServerConfigFetch){const a=await this.apiClient.fetchWidgetConfig(this.config.agentId,this.config.tenantId);a&&(this.config=ot(this.hostConfig,a),this.onStateChange(this.getState(),this.config))}if(this.setState({initStatus:"ready"}),!this.state.sessionId)return;this.openEventStream();const t=await this.apiClient.fetchSessionMessages(this.state.sessionId,this.config.tenantId);if(t===null){this.handleSessionExpired();return}if(t.length===0)return;const r=t.map(a=>{const n=a.direction==="human";return{id:be(),role:a.role,content:a.content,images:a.images&&a.images.length>0?a.images:void 0,uploadedImageUrl:a.imageUrl||void 0,createdAt:a.createdAt??new Date().toISOString(),status:"sent",...n?{isHuman:!0,senderDisplay:a.senderDisplay??null}:{}}});this.setState({messages:[...this.state.messages,...r]})}openEventStream(){if(typeof EventSource>"u"||!this.state.sessionId||this.eventSource)return;const e=`${this.config.apiBaseUrl.replace(/\/$/,"")}/v1/sessions/${encodeURIComponent(this.state.sessionId)}/events`,t=new EventSource(e);t.onmessage=r=>{try{const a=JSON.parse(r.data);if(a.type==="control_mode"){const n=a.mode;this.setState({controlMode:n}),this.emitter.emit("control_mode_changed",{mode:n});return}if(a.type==="execution_state"){const n=a.state;n==="ai_thinking"||n==="ai_streaming"||n==="tool_running"?this.setState({isLoading:!0}):n==="idle"&&this.setState({isLoading:!1});return}if(a.type==="message"&&a.message&&typeof a.message=="object"){const n=a.message;if(typeof n.content!="string"||n.id&&this.state.messages.some(i=>i.id===n.id))return;if(n.direction==="human"){const i={id:n.id??be(),role:"assistant",content:n.content,createdAt:n.createdAt??new Date().toISOString(),status:"sent",isHuman:!0,senderDisplay:n.senderDisplay??null};this.setState({messages:[...this.state.messages,i],isLoading:!1}),this.emitter.emit("message:received",i);return}if(n.direction==="ai"){const i={id:n.id??be(),role:"assistant",content:n.content,createdAt:n.createdAt??new Date().toISOString(),status:"sent"};this.setState({messages:[...this.state.messages,i],isLoading:!1}),this.emitter.emit("message:received",i);return}}}catch{}},t.onerror=()=>{},this.eventSource=t}closeEventStream(){this.eventSource&&(this.eventSource.close(),this.eventSource=null)}setState(e){this.state={...this.state,...e},this.onStateChange(this.getState(),this.config)}updateMessage(e,t){this.state={...this.state,messages:this.state.messages.map(r=>r.id===e?{...r,...t}:r)},this.onStateChange(this.getState(),this.config)}async resetConversation(){if(this.state.sessionId)try{await this.apiClient.endSession(this.state.sessionId,this.config.tenantId,this.config.agentId,this.fingerprint,this.config.user.externalId)}catch{}Zt(this.config.agentId),this.closeEventStream(),this.setState({sessionId:void 0,messages:[],isLoading:!1,error:null,controlMode:void 0}),this.emitter.emit("reset",void 0),this.state.isOpen&&this.openWithGreeting()}handleSessionExpired(){Zt(this.config.agentId),this.closeEventStream(),this.setState({sessionId:void 0,controlMode:void 0})}async sendMessage(e,t){const r=!!e.trim()||t&&t.length>0;if(this.state.isLoading||!r||this.state.initStatus!=="ready")return;const a=[];if(t&&t.length>0)for(const l of t)try{const d=await fs(l.file);if(l.kind==="image"){const u=await this.apiClient.uploadImage(d,l.file.type,l.file.name,this.config.agentId,this.config.tenantId);a.push({url:u.url,mimeType:l.file.type,fileName:l.file.name,kind:"image"})}else{const u=await this.apiClient.uploadFile(d,l.file.type||"application/octet-stream",l.file.name,this.config.agentId,this.config.tenantId);a.push({url:u.url,mimeType:l.file.type||"application/octet-stream",fileName:l.file.name,kind:"file"})}}catch(d){const u=d instanceof Error?d.message:"Attachment upload failed";this.setState({error:u});return}const n=a.filter(l=>l.kind==="image"),i={id:be(),role:"user",content:e.trim(),uploadedImageUrl:n[0]?.url,uploadedAttachments:a.length>0?a:void 0,createdAt:new Date().toISOString(),status:"sent"},s=!this.state.messages.some(l=>l.role==="user");this.setState({messages:[...this.state.messages,i],isLoading:!0,error:null}),this.emitter.emit("message:sent",i),s&&this.emitter.emit("conversation:started",{sessionId:this.state.sessionId});const c=a.length>0?a:void 0;this.config.streaming?await this.sendStreaming(e.trim(),void 0,c):await this.sendNonStreaming(e.trim(),void 0,c)}async sendNonStreaming(e,t,r,a=!1){try{const n=await this.apiClient.chat({agentId:this.config.agentId,message:e,sessionId:this.state.sessionId,tenantId:this.config.tenantId,externalId:this.config.user.externalId,name:this.config.user.name,email:this.config.user.email,authId:this.config.user.authId,fingerprint:this.fingerprint,metadata:this.config.metadata,imageUrl:t,attachments:r});if(n.queued&&n.controlMode==="human"){this.setState({isLoading:!1,controlMode:"human_takeover",...n.sessionId?{sessionId:n.sessionId}:{}}),n.sessionId&&(Ee(this.config.agentId,n.sessionId),this.openEventStream());return}const i={id:be(),role:"assistant",content:n.content,images:n.images,createdAt:new Date().toISOString(),status:"sent"};this.setState({messages:[...this.state.messages,i],isLoading:!1,...n.sessionId?{sessionId:n.sessionId}:{}}),n.sessionId&&(Ee(this.config.agentId,n.sessionId),this.openEventStream()),this.emitter.emit("message:received",i)}catch(n){const i=n instanceof Error?n.message:"Failed to send message";if(!a&&i.includes("410"))return this.handleSessionExpired(),this.sendNonStreaming(e,t,r,!0);this.setState({isLoading:!1,error:i}),this.emitter.emit("message:error",{error:i,message:null})}}async sendStreaming(e,t,r,a=!1){const n=be(),i={id:n,role:"assistant",content:"",createdAt:new Date().toISOString(),status:"streaming",isThinking:this.config.thinkingEnabled?!0:void 0,toolStatus:this.config.thinkingEnabled?void 0:"Thinking..."};this.setState({messages:[...this.state.messages,i]}),this.emitter.emit("stream:start");let s=!1,c=!1;await Dr(this.config.apiBaseUrl,{agentId:this.config.agentId,message:e,sessionId:this.state.sessionId,tenantId:this.config.tenantId,externalId:this.config.user.externalId,name:this.config.user.name,email:this.config.user.email,authId:this.config.user.authId,fingerprint:this.fingerprint,metadata:this.config.metadata,imageUrl:t,attachments:r},{onSession:l=>{this.setState({sessionId:l}),Ee(this.config.agentId,l),this.openEventStream()},onImages:l=>{this.updateMessage(n,{images:l})},onThinkingDelta:(l,d)=>{this.updateMessage(n,{thinking:d,isThinking:!0}),this.emitter.emit("thinking:delta",{delta:l,accumulated:d})},onToolCallsStarted:l=>{this.updateMessage(n,{isThinking:!1,toolStatus:hs(l)})},onAck:l=>{this.updateMessage(n,{ackText:l})},onProgress:(l,d)=>{const u=this.state.messages.find(h=>h.id===n)?.progressEvents??[];this.updateMessage(n,{progressEvents:[...u.map(h=>({...h,status:"done"})),{stage:l,text:d,timestamp:new Date().toISOString(),status:"active"}]})},onToolStart:(l,d)=>{const u=this.state.messages.find(h=>h.id===n)?.progressEvents??[];this.updateMessage(n,{progressEvents:[...u.map(h=>({...h,status:"done"})),{stage:l,text:d,timestamp:new Date().toISOString(),status:"active"}]})},onToolComplete:(l,d,u)=>{const h=[...this.state.messages.find(g=>g.id===n)?.progressEvents??[]];let p=-1;for(let g=h.length-1;g>=0;g--)if(h[g].stage===l&&h[g].status==="active"){p=g;break}p>=0&&(h[p]={...h[p],status:"done",text:u>0?`${d} (${u}ms)`:d}),this.updateMessage(n,{progressEvents:h})},onFinalMeta:()=>{setTimeout(()=>{this.updateMessage(n,{progressCollapsed:!0})},2e3)},onDelta:(l,d)=>{d.trim()&&(this.updateMessage(n,{content:d,isThinking:!1,toolStatus:void 0}),this.emitter.emit("stream:delta",{delta:l,accumulated:d}))},onEnd:l=>{if(c){this.setState({messages:this.state.messages.filter(h=>h.id!==n),isLoading:!1,controlMode:"human_takeover"}),this.emitter.emit("stream:end",{content:""});return}const d=this.state.messages.find(h=>h.id===n);this.updateMessage(n,{content:l,status:"sent",isThinking:!1,toolStatus:void 0,progressEvents:d?.progressEvents?.map(h=>({...h,status:"done"}))}),this.setState({isLoading:!1}),this.emitter.emit("stream:end",{content:l});const u=this.state.messages.find(h=>h.id===n);u&&(u.thinking&&this.emitter.emit("thinking:end",{content:u.thinking}),this.emitter.emit("message:received",u))},onControlMode:(l,d)=>{d&&l==="human"&&(c=!0)},onError:l=>{if(!a&&l.message.includes("410")){s=!0,this.setState({messages:this.state.messages.filter(h=>h.id!==n),isLoading:!1});return}const d=this.state.messages.find(h=>h.id===n)?.content??"",u=l.message||"Something went wrong. Please try again.";this.updateMessage(n,{content:d||u,status:"error"}),this.setState({isLoading:!1,error:u}),this.emitter.emit("message:error",{error:l.message,message:null})}},{preview:this.config.preview}),s&&(this.handleSessionExpired(),await this.sendStreaming(e,t,r,!0))}};function hs(e){const t=e[0];if(!t)return"Working...";const r=t.indexOf(".");return r>0?`Using ${t.slice(0,r).replace(/_/g," ")}: ${t.slice(r+1).replace(/_/g," ")}${e.length>1?` +${e.length-1}`:""}`:`Using ${t.replace(/_/g," ")}`}function fs(e){return new Promise((t,r)=>{const a=new FileReader;a.onload=()=>{const n=a.result;t(n.split(",")[1]??"")},a.onerror=()=>r(new Error("Failed to read file")),a.readAsDataURL(e)})}function Hr(e){const t=document.createElement("div");t.setAttribute("data-agentkit-widget",""),e.appendChild(t);const r=t.attachShadow({mode:"open"}),a=document.createElement("style");r.appendChild(a);const n=document.createElement("div");return n.style.cssText="display: contents;",r.appendChild(n),{host:t,shadowRoot:r,styleSlot:a,mountPoint:n}}function Yr(e,t){e.textContent=t}function Xr(e){e.remove()}function Jr(){const e=document.createElement("div");return e.setAttribute("data-agentkit-root","floating"),e.style.cssText=["position: fixed","bottom: 24px","right: 24px","z-index: 2147483647","pointer-events: none"].join("; "),document.body.appendChild(e),e}function ps(e){getComputedStyle(e).position==="static"&&(e.style.position="relative");const t=document.createElement("div");return t.setAttribute("data-agentkit-root","floating"),t.style.cssText=["position: absolute","bottom: 24px","right: 24px","z-index: 2147483647","pointer-events: none"].join("; "),e.appendChild(t),t}function Qr(e){return e.setAttribute("data-agentkit-root","inline"),getComputedStyle(e).position==="static"&&(e.style.position="relative"),e}function ms(e){e.remove()}function gs(e){e.removeAttribute("data-agentkit-root")}function Ut(e,t,r,a,n){const i=e.mode==="inline";let s=!1;const c=i&&n?Qr(n):!i&&n?ps(n):Jr(),l=Hr(c);Yr(l.styleSlot,a);const d=new Gr(e,t,(p,g)=>{s||u.update(p,g)}),u=r(l.mountPoint,e,d.getState(),{onOpen:()=>h.open(),onClose:()=>h.close(),onSendMessage:(p,g)=>{d.sendMessage(p,g)},onReset:()=>{d.resetConversation()}});d.hydrate(),setTimeout(()=>{s||d.emitter.emit("ready",d.getState())},0);const h={open(){s||(d.setOpen(!0),d.emitter.emit("open"))},close(){s||(d.setOpen(!1),d.emitter.emit("close"))},toggle(){d.getState().isOpen?h.close():h.open()},async sendMessage(p,g){await d.sendMessage(p,g)},reset(){s||(d.resetConversation(),d.emitter.emit("reset"))},destroy(){s||(s=!0,u.destroy(),Xr(l.host),i&&n?gs(n):ms(c),d.emitter.emit("destroy"),d.emitter.removeAllListeners())},on(p,g){d.emitter.on(p,g)},off(p,g){d.emitter.off(p,g)},getState(){return d.getState()}};return h}var we=new Map,vs=0;function Kr(e){const t=`agentkit-widget-${++vs}`,r=e.destroy.bind(e);return e.destroy=()=>{we.delete(t),r()},we.set(t,e),t}function ks(e,t,r){const a={...e,mode:"floating"},n=Ut(ot(a),a,t,r);return Kr(n),n}function xs(e,t,r,a){const n={...t,mode:"inline"},i=Ut(ot(n),n,r,a,e);return Kr(i),i}function bs(e){e?we.get(e)?.destroy():(we.forEach(t=>t.destroy()),we.clear())}function ys(){return Array.from(we.keys())}function qr(e){const{theme:t}=e,r=[`--ak-accent: ${t.accentColor}`,`--ak-font: ${t.fontFamily}`,`--ak-radius: ${t.borderRadius}`];return r.push(`--ak-accent-hover: color-mix(in srgb, ${t.accentColor} 85%, black)`),`:host { ${r.join("; ")} }`}function ea(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var ta=`
7
13
  *, *::before, *::after {
8
14
  box-sizing: border-box;
9
15
  margin: 0;
@@ -33,15 +39,17 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let Hr=requir
33
39
  -webkit-font-smoothing: antialiased;
34
40
  }
35
41
 
36
- /* Dark mode — set data-theme="dark" on the shadow host element */
42
+ /* Dark mode — set data-theme="dark" on the shadow host element.
43
+ Slate palette, aligned with the KlicForge dashboard dark tokens. */
37
44
  :host([data-theme="dark"]) {
38
- --ak-bg: #1f2937;
39
- --ak-surface: #111827;
40
- --ak-text: #f9fafb;
41
- --ak-text-muted: #9ca3af;
42
- --ak-border: #374151;
43
- --ak-bot-bg: #374151;
44
- --ak-bot-text: #f9fafb;
45
+ --ak-bg: #0f172a; /* slate-900 — panel surface */
46
+ --ak-surface: #1e293b; /* slate-800 — inputs, insets (lift off panel) */
47
+ --ak-text: #f1f5f9; /* slate-100 */
48
+ --ak-text-muted: #94a3b8;/* slate-400 */
49
+ --ak-border: #334155; /* slate-700 */
50
+ --ak-bot-bg: #1e293b; /* slate-800 — assistant bubble */
51
+ --ak-bot-text: #f1f5f9; /* slate-100 */
52
+ --ak-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.4);
45
53
  --ak-maintenance-fg: #fde68a;
46
54
  --ak-maintenance-bg: rgba(253, 230, 138, 0.06);
47
55
  --ak-maintenance-halo: #f59e0b;
@@ -67,7 +75,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let Hr=requir
67
75
  width: 100%;
68
76
  height: 100%;
69
77
  min-height: 400px;
70
- max-height: 600px; /* Add max height for reasonable bounds */
78
+ max-height: 100%;
71
79
  }
72
80
 
73
81
  /* ── Launcher button ─────────────────────────────────────────── */
@@ -135,12 +143,22 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let Hr=requir
135
143
  width: 100%;
136
144
  height: 100%;
137
145
  min-height: 400px;
138
- max-height: 600px; /* Match the container's max height */
139
- border-radius: var(--ak-radius);
140
- box-shadow: var(--ak-shadow);
146
+ max-height: 100%;
147
+ border-radius: 0;
148
+ box-shadow: none;
149
+ border: none;
141
150
  display: flex;
142
151
  flex-direction: column;
143
152
  }
153
+ /* Inline shell-wrap fills its container and suppresses the duplicate widget header
154
+ (the sidebar already renders its own header and close button). */
155
+ .ak-inline .ak-shell-wrap {
156
+ width: 100%;
157
+ height: 100%;
158
+ }
159
+ .ak-inline .ak-header {
160
+ display: none;
161
+ }
144
162
  .ak-shell-enter {
145
163
  animation: ak-panel-in 0.2s ease-out;
146
164
  }
@@ -632,6 +650,318 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let Hr=requir
632
650
  filter: brightness(0.93);
633
651
  }
634
652
 
653
+ /* ── Image gallery (count-aware layouts) ───────────────────────────────── */
654
+ .ak-gallery {
655
+ position: relative;
656
+ width: 100%;
657
+ background: #ffffff;
658
+ overflow: hidden;
659
+ }
660
+
661
+ /* Single hero: natural aspect, contained inside a white frame so transparent
662
+ * product PNGs read clearly. Caps at 320px tall to keep bubble compact. */
663
+ .ak-gallery--single {
664
+ line-height: 0;
665
+ }
666
+ .ak-gallery--single .ak-gallery__cell--hero {
667
+ display: block;
668
+ background: #ffffff;
669
+ }
670
+ .ak-gallery__img--contain {
671
+ width: 100%;
672
+ max-height: 320px;
673
+ object-fit: contain;
674
+ background: #ffffff;
675
+ display: block;
676
+ }
677
+
678
+ /* 2-up: side-by-side squares, gap-1 */
679
+ .ak-gallery--two {
680
+ display: grid;
681
+ grid-template-columns: 1fr 1fr;
682
+ gap: 2px;
683
+ background: #e2e8f0;
684
+ }
685
+
686
+ /* 3-up: big left + 2 stacked right; container holds aspect */
687
+ .ak-gallery--three {
688
+ display: grid;
689
+ grid-template-columns: 2fr 1fr;
690
+ gap: 2px;
691
+ background: #e2e8f0;
692
+ aspect-ratio: 4 / 3;
693
+ }
694
+ .ak-gallery--three > .ak-gallery__cell {
695
+ aspect-ratio: auto;
696
+ height: 100%;
697
+ }
698
+ .ak-gallery--three .ak-gallery__col {
699
+ display: grid;
700
+ grid-template-rows: 1fr 1fr;
701
+ gap: 2px;
702
+ }
703
+
704
+ /* 4-up (and 5+): 2x2 grid */
705
+ .ak-gallery--grid {
706
+ display: grid;
707
+ grid-template-columns: 1fr 1fr;
708
+ gap: 2px;
709
+ background: #e2e8f0;
710
+ }
711
+
712
+ .ak-gallery__cell {
713
+ position: relative;
714
+ display: block;
715
+ overflow: hidden;
716
+ background: #f8fafc;
717
+ aspect-ratio: 1 / 1;
718
+ line-height: 0;
719
+ text-decoration: none;
720
+ }
721
+
722
+ /* Override aspect-ratio for the 3-up layout's column cells (they take parent height) */
723
+ .ak-gallery--three .ak-gallery__col .ak-gallery__cell {
724
+ aspect-ratio: auto;
725
+ height: 100%;
726
+ width: 100%;
727
+ }
728
+
729
+ .ak-gallery__img {
730
+ width: 100%;
731
+ height: 100%;
732
+ object-fit: cover;
733
+ display: block;
734
+ transition: transform 0.2s ease-out, filter 0.2s;
735
+ }
736
+
737
+ .ak-gallery__cell:hover .ak-gallery__img {
738
+ transform: scale(1.04);
739
+ filter: brightness(0.97);
740
+ }
741
+
742
+ .ak-gallery__cell:focus-visible {
743
+ outline: 2px solid var(--ak-primary, #6366f1);
744
+ outline-offset: -2px;
745
+ }
746
+
747
+ .ak-gallery__overlay {
748
+ position: absolute;
749
+ inset: 0;
750
+ display: flex;
751
+ align-items: center;
752
+ justify-content: center;
753
+ background: rgba(15, 23, 42, 0.6);
754
+ color: #ffffff;
755
+ font-size: 22px;
756
+ font-weight: 600;
757
+ letter-spacing: -0.01em;
758
+ pointer-events: none;
759
+ }
760
+
761
+ /* ── File chips (user-uploaded .pdf/.md/.txt/.csv) ─────────────────────── */
762
+ .ak-message__files {
763
+ display: flex;
764
+ flex-direction: column;
765
+ gap: 6px;
766
+ padding: 10px 12px 4px;
767
+ }
768
+ .ak-message__bubble--has-image .ak-message__files {
769
+ padding: 8px 8px 4px;
770
+ }
771
+
772
+ .ak-file-chip {
773
+ display: inline-flex;
774
+ align-items: center;
775
+ gap: 10px;
776
+ padding: 8px 10px;
777
+ background: var(--ak-surface);
778
+ border: 1px solid var(--ak-border, #e2e8f0);
779
+ border-radius: 12px;
780
+ text-decoration: none;
781
+ color: var(--ak-text, #0f172a);
782
+ transition: border-color 0.15s, box-shadow 0.15s;
783
+ max-width: 100%;
784
+ }
785
+
786
+ .ak-file-chip:hover {
787
+ border-color: #cbd5e1;
788
+ box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
789
+ }
790
+
791
+ .ak-file-chip:focus-visible {
792
+ outline: 2px solid var(--ak-primary, #6366f1);
793
+ outline-offset: 2px;
794
+ }
795
+
796
+ .ak-file-chip__icon {
797
+ flex-shrink: 0;
798
+ width: 34px;
799
+ height: 34px;
800
+ display: flex;
801
+ align-items: center;
802
+ justify-content: center;
803
+ border-radius: 8px;
804
+ }
805
+
806
+ .ak-file-chip__icon--pdf { background: #fff1f2; color: #e11d48; }
807
+ .ak-file-chip__icon--csv { background: #ecfdf5; color: #059669; }
808
+ .ak-file-chip__icon--md { background: #f5f3ff; color: #7c3aed; }
809
+ .ak-file-chip__icon--txt { background: #f1f5f9; color: #475569; }
810
+ .ak-file-chip__icon--default { background: #eef2ff; color: #4f46e5; }
811
+
812
+ .ak-file-chip__body {
813
+ display: flex;
814
+ flex-direction: column;
815
+ min-width: 0;
816
+ line-height: 1.2;
817
+ }
818
+
819
+ .ak-file-chip__name {
820
+ font-size: 13px;
821
+ font-weight: 500;
822
+ color: var(--ak-text, #0f172a);
823
+ white-space: nowrap;
824
+ overflow: hidden;
825
+ text-overflow: ellipsis;
826
+ max-width: 220px;
827
+ }
828
+
829
+ .ak-file-chip__label {
830
+ font-size: 10px;
831
+ font-weight: 600;
832
+ letter-spacing: 0.05em;
833
+ color: #64748b;
834
+ margin-top: 2px;
835
+ }
836
+
837
+ /* In user-side bubble (dark primary background), invert chip surface for legibility */
838
+ .ak-message--user .ak-file-chip {
839
+ background: rgba(255, 255, 255, 0.96);
840
+ border-color: transparent;
841
+ }
842
+
843
+ /* ── Lightbox (image preview modal) ────────────────────────────────────── */
844
+ .ak-lightbox {
845
+ position: fixed;
846
+ inset: 0;
847
+ z-index: 2147483600; /* near max int — sits above any host-page content */
848
+ display: flex;
849
+ align-items: center;
850
+ justify-content: center;
851
+ padding: 24px;
852
+ background: rgba(15, 23, 42, 0.85);
853
+ backdrop-filter: blur(6px);
854
+ -webkit-backdrop-filter: blur(6px);
855
+ animation: ak-lightbox-in 0.12s ease-out;
856
+ }
857
+
858
+ @keyframes ak-lightbox-in {
859
+ from { opacity: 0; }
860
+ to { opacity: 1; }
861
+ }
862
+
863
+ .ak-lightbox__img {
864
+ max-width: 92vw;
865
+ max-height: 88vh;
866
+ border-radius: 8px;
867
+ box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
868
+ user-select: none;
869
+ display: block;
870
+ }
871
+
872
+ .ak-lightbox__toolbar {
873
+ position: absolute;
874
+ top: 16px;
875
+ right: 16px;
876
+ display: flex;
877
+ align-items: center;
878
+ gap: 8px;
879
+ }
880
+
881
+ .ak-lightbox__counter {
882
+ display: inline-flex;
883
+ align-items: center;
884
+ height: 28px;
885
+ padding: 0 12px;
886
+ border-radius: 999px;
887
+ background: rgba(255, 255, 255, 0.12);
888
+ color: #ffffff;
889
+ font-size: 12px;
890
+ font-weight: 500;
891
+ font-variant-numeric: tabular-nums;
892
+ }
893
+
894
+ .ak-lightbox__btn {
895
+ display: flex;
896
+ align-items: center;
897
+ justify-content: center;
898
+ width: 36px;
899
+ height: 36px;
900
+ border: none;
901
+ border-radius: 999px;
902
+ background: rgba(255, 255, 255, 0.12);
903
+ color: #ffffff;
904
+ cursor: pointer;
905
+ transition: background 0.15s;
906
+ text-decoration: none;
907
+ padding: 0;
908
+ }
909
+
910
+ .ak-lightbox__btn:hover {
911
+ background: rgba(255, 255, 255, 0.22);
912
+ }
913
+
914
+ .ak-lightbox__btn:focus-visible {
915
+ outline: 2px solid rgba(255, 255, 255, 0.8);
916
+ outline-offset: 2px;
917
+ }
918
+
919
+ .ak-lightbox__nav {
920
+ position: absolute;
921
+ top: 50%;
922
+ transform: translateY(-50%);
923
+ display: flex;
924
+ align-items: center;
925
+ justify-content: center;
926
+ width: 44px;
927
+ height: 44px;
928
+ border: none;
929
+ border-radius: 999px;
930
+ background: rgba(255, 255, 255, 0.12);
931
+ color: #ffffff;
932
+ cursor: pointer;
933
+ transition: background 0.15s;
934
+ padding: 0;
935
+ }
936
+
937
+ .ak-lightbox__nav:hover {
938
+ background: rgba(255, 255, 255, 0.22);
939
+ }
940
+
941
+ .ak-lightbox__nav--prev { left: 16px; }
942
+ .ak-lightbox__nav--next { right: 16px; }
943
+
944
+ .ak-lightbox__nav:focus-visible {
945
+ outline: 2px solid rgba(255, 255, 255, 0.8);
946
+ outline-offset: 2px;
947
+ }
948
+
949
+ /* Gallery cells must be styled as plain buttons (we converted from <a>) */
950
+ .ak-gallery__cell {
951
+ border: none;
952
+ padding: 0;
953
+ margin: 0;
954
+ cursor: zoom-in;
955
+ font: inherit;
956
+ color: inherit;
957
+ background: #f8fafc;
958
+ }
959
+
960
+ .ak-gallery__cell:focus-visible {
961
+ outline: 2px solid var(--ak-primary, #6366f1);
962
+ outline-offset: -2px;
963
+ }
964
+
635
965
  /* Faint download icon — always present, top-right corner of the image */
636
966
  .ak-message__image-dl-icon {
637
967
  position: absolute;
@@ -1043,6 +1373,42 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let Hr=requir
1043
1373
  .ak-message--user .ak-message__bubble--md a {
1044
1374
  color: rgba(255, 255, 255, 0.9);
1045
1375
  }
1376
+ .ak-message__bubble--md .ak-md-table {
1377
+ width: 100%;
1378
+ border-collapse: collapse;
1379
+ margin: 0.4em 0;
1380
+ font-size: 0.95em;
1381
+ line-height: 1.5;
1382
+ }
1383
+ .ak-message__bubble--md .ak-md-th {
1384
+ padding: 8px 10px;
1385
+ text-align: left;
1386
+ border-bottom: 2px solid var(--ak-accent) !important;
1387
+ background: color-mix(in srgb, var(--ak-accent) 8%, transparent) !important;
1388
+ font-weight: 600;
1389
+ color: var(--ak-text) !important;
1390
+ }
1391
+ .ak-message--user .ak-message__bubble--md .ak-md-th {
1392
+ border-bottom-color: rgba(255, 255, 255, 0.5) !important;
1393
+ background: rgba(0, 0, 0, 0.25) !important;
1394
+ color: #ffffff !important;
1395
+ font-weight: 700;
1396
+ }
1397
+ .ak-message__bubble--md .ak-md-td {
1398
+ padding: 6px 10px;
1399
+ border-bottom: 1px solid var(--ak-border) !important;
1400
+ color: var(--ak-text) !important;
1401
+ }
1402
+ .ak-message__bubble--md tr:nth-child(even) .ak-md-td {
1403
+ background: color-mix(in srgb, var(--ak-surface), transparent 40%) !important;
1404
+ }
1405
+ .ak-message--user .ak-message__bubble--md .ak-md-td {
1406
+ color: #ffffff !important;
1407
+ border-bottom-color: rgba(255, 255, 255, 0.25) !important;
1408
+ }
1409
+ .ak-message--user .ak-message__bubble--md tr:nth-child(even) .ak-md-td {
1410
+ background: rgba(0, 0, 0, 0.15) !important;
1411
+ }
1046
1412
 
1047
1413
  /* ── Composer disclaimer ─────────────────────────────────────── */
1048
1414
  .ak-composer__disclaimer {
@@ -1253,6 +1619,140 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let Hr=requir
1253
1619
  line-height: 1.5;
1254
1620
  }
1255
1621
 
1622
+ /* ── Agent status indicator ──────────────────────────────────── */
1623
+ .ak-agent-status {
1624
+ display: inline-flex;
1625
+ align-items: center;
1626
+ gap: 7px;
1627
+ margin-bottom: 4px;
1628
+ padding: 6px 12px;
1629
+ border-radius: 14px;
1630
+ background: var(--ak-bot-bg);
1631
+ border: 1px solid var(--ak-border);
1632
+ color: var(--ak-bot-text);
1633
+ font-size: 0.8rem;
1634
+ font-style: italic;
1635
+ opacity: 0.8;
1636
+ animation: ak-msg-in 0.15s ease-out;
1637
+ }
1638
+ .ak-agent-status__icon {
1639
+ flex-shrink: 0;
1640
+ color: var(--ak-primary, #6366f1);
1641
+ animation: ak-sparkle-pulse 2.5s ease-in-out infinite;
1642
+ }
1643
+ .ak-agent-status__text {
1644
+ line-height: 1;
1645
+ }
1646
+ @keyframes ak-sparkle-pulse {
1647
+ 0%, 100% { opacity: 1; transform: scale(1) rotate(0deg); }
1648
+ 50% { opacity: 0.45; transform: scale(0.85) rotate(15deg); }
1649
+ }
1650
+
1651
+ /* ── Progress block (tool execution / streaming chain) ───────── */
1652
+ .ak-progress {
1653
+ margin-bottom: 4px;
1654
+ max-width: 80%;
1655
+ }
1656
+ .ak-progress__block {
1657
+ display: inline-flex;
1658
+ flex-direction: column;
1659
+ gap: 3px;
1660
+ padding: 6px 12px;
1661
+ border-radius: 14px;
1662
+ background: var(--ak-bot-bg);
1663
+ border: 1px solid var(--ak-border);
1664
+ font-size: 0.8rem;
1665
+ color: var(--ak-bot-text);
1666
+ opacity: 0.85;
1667
+ animation: ak-msg-in 0.15s ease-out;
1668
+ }
1669
+ .ak-progress__header {
1670
+ display: flex;
1671
+ align-items: center;
1672
+ gap: 8px;
1673
+ }
1674
+ .ak-progress__label {
1675
+ font-weight: 600;
1676
+ font-size: 0.78rem;
1677
+ color: var(--ak-primary, #6366f1);
1678
+ }
1679
+ .ak-progress__toggle {
1680
+ display: inline-flex;
1681
+ align-items: center;
1682
+ gap: 3px;
1683
+ padding: 1px 7px;
1684
+ border: 1px solid var(--ak-border);
1685
+ border-radius: 8px;
1686
+ background: transparent;
1687
+ color: var(--ak-bot-text);
1688
+ font-size: 0.72rem;
1689
+ cursor: pointer;
1690
+ opacity: 0.65;
1691
+ transition: opacity 0.15s;
1692
+ }
1693
+ .ak-progress__toggle:hover { opacity: 0.9; }
1694
+ .ak-progress__toggle--collapsed {
1695
+ display: inline-flex;
1696
+ align-items: center;
1697
+ gap: 5px;
1698
+ padding: 5px 10px;
1699
+ border: 1px solid var(--ak-border);
1700
+ border-radius: 12px;
1701
+ background: transparent;
1702
+ color: var(--ak-bot-text);
1703
+ font-size: 0.78rem;
1704
+ cursor: pointer;
1705
+ opacity: 0.55;
1706
+ transition: opacity 0.15s;
1707
+ margin-bottom: 4px;
1708
+ }
1709
+ .ak-progress__toggle--collapsed:hover { opacity: 0.85; }
1710
+ .ak-progress__text {
1711
+ font-size: 0.78rem;
1712
+ color: var(--ak-bot-text);
1713
+ opacity: 0.75;
1714
+ line-height: 1.4;
1715
+ margin: 0;
1716
+ }
1717
+ /* Active streaming state */
1718
+ .ak-progress__list {
1719
+ list-style: none;
1720
+ margin: 0 0 4px;
1721
+ padding: 0;
1722
+ }
1723
+ .ak-progress__item {
1724
+ display: flex;
1725
+ align-items: center;
1726
+ gap: 7px;
1727
+ padding: 6px 12px;
1728
+ border-radius: 14px;
1729
+ background: var(--ak-bot-bg);
1730
+ border: 1px solid var(--ak-border);
1731
+ font-size: 0.8rem;
1732
+ color: var(--ak-bot-text);
1733
+ font-style: italic;
1734
+ opacity: 0.8;
1735
+ animation: ak-msg-in 0.15s ease-out;
1736
+ }
1737
+ .ak-progress__item--active {
1738
+ /* inherits base .ak-progress__item; subtle pulse to signal in-flight */
1739
+ animation: ak-msg-in 0.15s ease-out, ak-active-pulse 2s ease-in-out infinite;
1740
+ }
1741
+ @keyframes ak-active-pulse {
1742
+ 0%, 100% { opacity: 0.8; }
1743
+ 50% { opacity: 1; }
1744
+ }
1745
+ .ak-progress__spinner {
1746
+ display: inline-block;
1747
+ width: 11px;
1748
+ height: 11px;
1749
+ border: 1.5px solid var(--ak-border);
1750
+ border-top-color: var(--ak-primary, #6366f1);
1751
+ border-radius: 50%;
1752
+ flex-shrink: 0;
1753
+ animation: ak-spin 0.7s linear infinite;
1754
+ }
1755
+
1256
1756
  /* ── Powered by hanging tab ──────────────────────────────────── */
1257
1757
  .ak-branding {
1258
1758
  display: inline-flex;
@@ -1285,9 +1785,11 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let Hr=requir
1285
1785
  opacity: 0.75;
1286
1786
  letter-spacing: -0.01em;
1287
1787
  }
1288
- `;function qi(){return(0,c.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),(0,c.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,c.jsx)("path",{d:"M12 7v4"}),(0,c.jsx)("line",{x1:"8",y1:"16",x2:"8",y2:"16"}),(0,c.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"16"})]})}function Ki(){return(0,c.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[(0,c.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,c.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function es(){return(0,c.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,c.jsx)("path",{d:"M3 3v5h5"})]})}function zr({title:e,subtitle:t,avatarUrl:r,onClose:n,onReset:a,hideClose:i=!1}){const[s,o]=(0,E.useState)(!1);return(0,c.jsxs)("div",{className:`ak-header${s?" ak-header--confirming":""}`,children:[(0,c.jsxs)("div",{className:"ak-header__row",children:[r?(0,c.jsx)("img",{src:r,alt:"",className:"ak-header__avatar","aria-hidden":"true"}):(0,c.jsx)("span",{className:"ak-header__bot-icon","aria-hidden":"true",children:(0,c.jsx)(qi,{})}),(0,c.jsxs)("div",{className:"ak-header__title-group",children:[(0,c.jsx)("span",{className:"ak-header__title",children:e}),t&&(0,c.jsx)("span",{className:"ak-header__subtitle",children:t})]}),(0,c.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,c.jsx)("span",{className:"ak-header__status","aria-hidden":"true"}),a&&(0,c.jsx)("button",{className:`ak-header__button${s?" ak-header__button--active":""}`,onClick:()=>o(!0),"aria-label":"New conversation",type:"button",title:"Start a new conversation (Retains current conversation to memory)",children:(0,c.jsx)(es,{})}),!i&&(0,c.jsx)("button",{className:"ak-header__close",onClick:n,"aria-label":"Close chat",type:"button",children:(0,c.jsx)(Ki,{})})]})]}),s&&(0,c.jsxs)("div",{className:"ak-header__confirm",role:"alert",children:[(0,c.jsxs)("div",{className:"ak-header__confirm-text",children:[(0,c.jsx)("span",{className:"ak-header__confirm-title",children:"End this conversation?"}),(0,c.jsx)("span",{className:"ak-header__confirm-sub",children:"All messages will be removed"})]}),(0,c.jsxs)("div",{className:"ak-header__confirm-actions",children:[(0,c.jsx)("button",{className:"ak-header__confirm-cancel",type:"button",onClick:()=>o(!1),children:"Cancel"}),(0,c.jsx)("button",{className:"ak-header__confirm-ok",type:"button",onClick:()=>{a?.(),o(!1)},children:"End chat"})]})]})]})}function ts({thinking:e,isThinking:t,thinkingViewable:r}){const[n,a]=(0,E.useState)(!1);return!t&&!e?null:t?(0,c.jsx)("div",{className:"ak-thinking",children:(0,c.jsxs)("div",{className:"ak-thinking__indicator",children:[(0,c.jsx)("span",{className:"ak-thinking__label",children:"Thinking"}),(0,c.jsxs)("span",{className:"ak-cursor","aria-hidden":"true",children:[(0,c.jsx)("span",{className:"ak-cursor__dot"}),(0,c.jsx)("span",{className:"ak-cursor__dot"}),(0,c.jsx)("span",{className:"ak-cursor__dot"})]})]})}):!r||!e?null:(0,c.jsxs)("div",{className:"ak-thinking ak-thinking--done",children:[(0,c.jsxs)("button",{className:"ak-thinking__toggle",onClick:()=>a(i=>!i),"aria-expanded":n,type:"button",children:[(0,c.jsx)("svg",{className:`ak-thinking__chevron${n?" ak-thinking__chevron--open":""}`,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,c.jsx)("polyline",{points:"6 9 12 15 18 9"})}),(0,c.jsx)("span",{children:"Thought for a moment"})]}),n&&(0,c.jsx)("div",{className:"ak-thinking__content",children:e})]})}function rs(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}var qt=/(`[^`\n]+`|\*\*[^*\n]+\*\*|\*[^*\n]+\*|!\[[^\]\n]*\]\([^)\n]+\)|\[[^\]\n]+\]\([^)\n]+\))/g;function U(e){const t=[];let r=0,n=0;qt.lastIndex=0;let a;for(;(a=qt.exec(e))!==null;){a.index>r&&t.push(e.slice(r,a.index));const i=a[0];if(i.startsWith("`"))t.push((0,c.jsx)("code",{className:"ak-md-ic",children:i.slice(1,-1)},n++));else if(i.startsWith("**"))t.push((0,c.jsx)("strong",{children:i.slice(2,-2)},n++));else if(i.startsWith("*"))t.push((0,c.jsx)("em",{children:i.slice(1,-1)},n++));else if(i.startsWith("![")){const s=i.match(/!\[([^\]]*)\]\(([^)]+)\)/);s&&t.push((0,c.jsx)("a",{href:s[2],target:"_blank",rel:"noopener noreferrer",children:s[1]||"image"},n++))}else{const s=i.match(/\[(.+?)\]\((.+?)\)/);s?t.push((0,c.jsx)("a",{href:s[2],target:"_blank",rel:"noopener noreferrer",children:s[1]},n++)):t.push(i)}r=a.index+i.length}return r<e.length&&t.push(e.slice(r)),t}function ns(e){e=e.replace(/\\text\{([^}]*)\}/g,"$1").replace(/\\implies/g,"→").replace(/\\Rightarrow/g,"⟹").replace(/\\times/g,"×").replace(/\\div/g,"÷").replace(/\\cdot/g,"·").replace(/\\quad/g," ").replace(/\\qquad/g," ").replace(/\\leq/g,"≤").replace(/\\geq/g,"≥").replace(/\\neq/g,"≠").replace(/\\approx/g,"≈").replace(/\\infty/g,"∞").replace(/\\\((.+?)\\\)/gs,"$1").replace(/\\\[[\s\S]+?\\\]/g,"").replace(/\\\$/g,"\0DOLLAR\0").replace(/\$\$[\s\S]+?\$\$/g,"").replace(/\$([^$]+)\$/g,"$1").replace(/\x00DOLLAR\x00/g,"$").replace(/\\[a-zA-Z]+\*?/g,"").replace(/\n{3,}/g,`
1788
+ `;function _s(){return(0,o.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),(0,o.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,o.jsx)("path",{d:"M12 7v4"}),(0,o.jsx)("line",{x1:"8",y1:"16",x2:"8",y2:"16"}),(0,o.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"16"})]})}function ws(){return(0,o.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[(0,o.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,o.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function js(){return(0,o.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,o.jsx)("path",{d:"M3 3v5h5"})]})}function ra({title:e,subtitle:t,avatarUrl:r,onClose:a,onReset:n,hideClose:i=!1}){const[s,c]=(0,A.useState)(!1);return(0,o.jsxs)("div",{className:`ak-header${s?" ak-header--confirming":""}`,children:[(0,o.jsxs)("div",{className:"ak-header__row",children:[r?(0,o.jsx)("img",{src:r,alt:"",className:"ak-header__avatar","aria-hidden":"true"}):(0,o.jsx)("span",{className:"ak-header__bot-icon","aria-hidden":"true",children:(0,o.jsx)(_s,{})}),(0,o.jsxs)("div",{className:"ak-header__title-group",children:[(0,o.jsx)("span",{className:"ak-header__title",children:e}),t&&(0,o.jsx)("span",{className:"ak-header__subtitle",children:t})]}),(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,o.jsx)("span",{className:"ak-header__status","aria-hidden":"true"}),n&&(0,o.jsx)("button",{className:`ak-header__button${s?" ak-header__button--active":""}`,onClick:()=>c(!0),"aria-label":"New conversation",type:"button",title:"Start a new conversation (Retains current conversation to memory)",children:(0,o.jsx)(js,{})}),!i&&(0,o.jsx)("button",{className:"ak-header__close",onClick:a,"aria-label":"Close chat",type:"button",children:(0,o.jsx)(ws,{})})]})]}),s&&(0,o.jsxs)("div",{className:"ak-header__confirm",role:"alert",children:[(0,o.jsxs)("div",{className:"ak-header__confirm-text",children:[(0,o.jsx)("span",{className:"ak-header__confirm-title",children:"End this conversation?"}),(0,o.jsx)("span",{className:"ak-header__confirm-sub",children:"All messages will be removed"})]}),(0,o.jsxs)("div",{className:"ak-header__confirm-actions",children:[(0,o.jsx)("button",{className:"ak-header__confirm-cancel",type:"button",onClick:()=>c(!1),children:"Cancel"}),(0,o.jsx)("button",{className:"ak-header__confirm-ok",type:"button",onClick:()=>{n?.(),c(!1)},children:"End chat"})]})]})]})}function Ss({ackText:e,events:t=[],collapsed:r=!1,onToggle:a,isComplete:n=!1}){const[i,s]=(0,A.useState)(!1),c=t[t.length-1]?.text??e;if(!c)return null;const l=a?r:i,d=a??(()=>s(u=>!u));return n&&l?(0,o.jsxs)("button",{type:"button",onClick:d,className:"ak-progress__toggle ak-progress__toggle--collapsed","aria-label":"Show working details",children:[(0,o.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,o.jsx)("polyline",{points:"6 9 12 15 18 9"})}),"Show working details"]}):n?(0,o.jsx)("div",{className:"ak-progress",children:(0,o.jsxs)("div",{className:"ak-progress__block",children:[(0,o.jsxs)("div",{className:"ak-progress__header",children:[(0,o.jsx)("span",{className:"ak-progress__label",children:"Done"}),(0,o.jsxs)("button",{type:"button",onClick:d,className:"ak-progress__toggle","aria-label":"Hide working details",children:[(0,o.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,o.jsx)("polyline",{points:"18 15 12 9 6 15"})}),"Hide"]})]}),(0,o.jsx)("p",{className:"ak-progress__text",children:c})]})}):(0,o.jsx)("ul",{className:"ak-progress__list",role:"list",children:(0,o.jsxs)("li",{className:"ak-progress__item ak-progress__item--active",children:[(0,o.jsx)("span",{className:"ak-progress__spinner","aria-hidden":"true"}),(0,o.jsx)("span",{className:"ak-progress__text",children:c})]})})}function Cs({thinking:e,isThinking:t,thinkingViewable:r}){const[a,n]=(0,A.useState)(!1);return!t&&!e?null:t?(0,o.jsx)("div",{className:"ak-thinking",children:(0,o.jsxs)("div",{className:"ak-thinking__indicator",children:[(0,o.jsx)("span",{className:"ak-thinking__label",children:"Thinking"}),(0,o.jsxs)("span",{className:"ak-cursor","aria-hidden":"true",children:[(0,o.jsx)("span",{className:"ak-cursor__dot"}),(0,o.jsx)("span",{className:"ak-cursor__dot"}),(0,o.jsx)("span",{className:"ak-cursor__dot"})]})]})}):!r||!e?null:(0,o.jsxs)("div",{className:"ak-thinking ak-thinking--done",children:[(0,o.jsxs)("button",{className:"ak-thinking__toggle",onClick:()=>n(i=>!i),"aria-expanded":a,type:"button",children:[(0,o.jsx)("svg",{className:`ak-thinking__chevron${a?" ak-thinking__chevron--open":""}`,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,o.jsx)("polyline",{points:"6 9 12 15 18 9"})}),(0,o.jsx)("span",{children:"Thought for a moment"})]}),a&&(0,o.jsx)("div",{className:"ak-thinking__content",children:e})]})}function Is(){return(0,o.jsx)("svg",{className:"ak-agent-status__icon",width:"13",height:"13",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{d:"M12 2C12 2 12.7 8.1 14.5 9.5C16.3 10.9 22 12 22 12C22 12 16.3 13.1 14.5 14.5C12.7 15.9 12 22 12 22C12 22 11.3 15.9 9.5 14.5C7.7 13.1 2 12 2 12C2 12 7.7 10.9 9.5 9.5C11.3 8.1 12 2 12 2Z"})})}function Ns({status:e}){return(0,o.jsxs)("div",{className:"ak-agent-status",role:"status","aria-live":"polite",children:[(0,o.jsx)(Is,{}),(0,o.jsx)("span",{className:"ak-agent-status__text",children:e})]})}function cr({messageId:e,images:t,onCellClick:r}){if(t.length===0)return null;const a=t.length;if(a===1){const s=t[0];return(0,o.jsxs)("div",{className:"ak-gallery ak-gallery--single",children:[(0,o.jsx)("button",{type:"button",onClick:()=>r(0),className:"ak-gallery__cell ak-gallery__cell--hero","aria-label":"Open image preview",children:(0,o.jsx)("img",{src:s.src,alt:s.alt,className:"ak-gallery__img ak-gallery__img--contain"})}),(0,o.jsx)("a",{href:s.downloadHref,download:!0,className:"ak-message__image-dl-icon",title:"Download image",onClick:c=>c.stopPropagation(),children:(0,o.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,o.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,o.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})})]})}if(a===2)return(0,o.jsx)("div",{className:"ak-gallery ak-gallery--two",children:t.map((s,c)=>(0,o.jsx)(Ne,{src:s.src,alt:s.alt,onClick:()=>r(c)},s.key??`${e}-${c}`))});if(a===3)return(0,o.jsxs)("div",{className:"ak-gallery ak-gallery--three",children:[(0,o.jsx)(Ne,{src:t[0].src,alt:t[0].alt,onClick:()=>r(0)},t[0].key??`${e}-0`),(0,o.jsxs)("div",{className:"ak-gallery__col",children:[(0,o.jsx)(Ne,{src:t[1].src,alt:t[1].alt,onClick:()=>r(1)},t[1].key??`${e}-1`),(0,o.jsx)(Ne,{src:t[2].src,alt:t[2].alt,onClick:()=>r(2)},t[2].key??`${e}-2`)]})]});const n=t.slice(0,4),i=a>4?a-4:0;return(0,o.jsx)("div",{className:"ak-gallery ak-gallery--grid",children:n.map((s,c)=>{const l=c===n.length-1;return(0,o.jsx)(Ne,{src:s.src,alt:s.alt,overlayCount:l&&i>0?i:0,onClick:()=>r(c)},s.key??`${e}-${c}`)})})}function Ne({src:e,alt:t,overlayCount:r=0,onClick:a}){return(0,o.jsxs)("button",{type:"button",onClick:a,className:"ak-gallery__cell","aria-label":"Open image preview",children:[(0,o.jsx)("img",{src:e,alt:t,className:"ak-gallery__img",loading:"lazy"}),r>0&&(0,o.jsxs)("span",{className:"ak-gallery__overlay",children:["+",r]})]})}function dr({images:e,index:t,onClose:r,onIndexChange:a}){const n=t!==null,i=n&&t!==null?Math.min(Math.max(0,t),e.length-1):0,s=n?e[i]:null;return(0,A.useEffect)(()=>{if(!n)return;const c=l=>{l.key==="Escape"?(l.stopPropagation(),r()):l.key==="ArrowLeft"&&e.length>1?(l.preventDefault(),a((i-1+e.length)%e.length)):l.key==="ArrowRight"&&e.length>1&&(l.preventDefault(),a((i+1)%e.length))};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[n,i,e.length,r,a]),!n||!s?null:(0,o.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":"Image preview",className:"ak-lightbox",onClick:r,children:[(0,o.jsxs)("div",{className:"ak-lightbox__toolbar",onClick:c=>c.stopPropagation(),children:[e.length>1&&(0,o.jsxs)("span",{className:"ak-lightbox__counter",children:[i+1," / ",e.length]}),(0,o.jsx)("a",{href:s.downloadHref,download:!0,target:"_blank",rel:"noopener noreferrer",className:"ak-lightbox__btn",title:"Download image","aria-label":"Download image",children:(0,o.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,o.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,o.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),(0,o.jsx)("button",{type:"button",onClick:r,className:"ak-lightbox__btn",title:"Close","aria-label":"Close image preview",children:(0,o.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,o.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.length>1&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("button",{type:"button",onClick:c=>{c.stopPropagation(),a((i-1+e.length)%e.length)},className:"ak-lightbox__nav ak-lightbox__nav--prev","aria-label":"Previous image",children:(0,o.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,o.jsx)("polyline",{points:"15 18 9 12 15 6"})})}),(0,o.jsx)("button",{type:"button",onClick:c=>{c.stopPropagation(),a((i+1)%e.length)},className:"ak-lightbox__nav ak-lightbox__nav--next","aria-label":"Next image",children:(0,o.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,o.jsx)("polyline",{points:"9 18 15 12 9 6"})})})]}),(0,o.jsx)("img",{src:s.src,alt:s.alt??"Image preview",className:"ak-lightbox__img",onClick:c=>c.stopPropagation()})]})}function Ts({url:e,mimeType:t,fileName:r}){const a=(()=>{if(r)return r;try{const s=new URL(e).pathname.split("/");return(s[s.length-1]||"attachment").replace(/^\d{10,}-/,"")}catch{return"attachment"}})(),n=a.split(".").pop()?.toUpperCase()??"",i=t==="application/pdf"||n==="PDF"?{variant:"pdf",label:"PDF"}:t==="text/csv"||n==="CSV"?{variant:"csv",label:"CSV"}:t==="text/markdown"||n==="MD"?{variant:"md",label:"MD"}:t==="text/plain"||n==="TXT"?{variant:"txt",label:"TXT"}:{variant:"default",label:n||"FILE"};return(0,o.jsxs)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"ak-file-chip",title:a,children:[(0,o.jsx)("span",{className:`ak-file-chip__icon ak-file-chip__icon--${i.variant}`,"aria-hidden":!0,children:(0,o.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,o.jsx)("polyline",{points:"14 2 14 8 20 8"})]})}),(0,o.jsxs)("span",{className:"ak-file-chip__body",children:[(0,o.jsx)("span",{className:"ak-file-chip__name",children:a}),(0,o.jsx)("span",{className:"ak-file-chip__label",children:i.label})]})]})}function Ls(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}var ur=/(`[^`\n]+`|\*\*[^*\n]+\*\*|\*[^*\n]+\*|!\[[^\]\n]*\]\([^)\n]+\)|\[[^\]\n]+\]\([^)\n]+\))/g;function H(e){const t=[];let r=0,a=0;ur.lastIndex=0;let n;for(;(n=ur.exec(e))!==null;){n.index>r&&t.push(e.slice(r,n.index));const i=n[0];if(i.startsWith("`"))t.push((0,o.jsx)("code",{className:"ak-md-ic",children:i.slice(1,-1)},a++));else if(i.startsWith("**"))t.push((0,o.jsx)("strong",{children:i.slice(2,-2)},a++));else if(i.startsWith("*"))t.push((0,o.jsx)("em",{children:i.slice(1,-1)},a++));else if(i.startsWith("![")){const s=i.match(/!\[([^\]]*)\]\(([^)]+)\)/);s&&t.push((0,o.jsx)("a",{href:s[2],target:"_blank",rel:"noopener noreferrer",children:s[1]||"image"},a++))}else{const s=i.match(/\[(.+?)\]\((.+?)\)/);s?t.push((0,o.jsx)("a",{href:s[2],target:"_blank",rel:"noopener noreferrer",children:s[1]},a++)):t.push(i)}r=n.index+i.length}return r<e.length&&t.push(e.slice(r)),t}function Es(e){e=e.replace(/\\text\{([^}]*)\}/g,"$1").replace(/\\implies/g,"→").replace(/\\Rightarrow/g,"⟹").replace(/\\times/g,"×").replace(/\\div/g,"÷").replace(/\\cdot/g,"·").replace(/\\quad/g," ").replace(/\\qquad/g," ").replace(/\\leq/g,"≤").replace(/\\geq/g,"≥").replace(/\\neq/g,"≠").replace(/\\approx/g,"≈").replace(/\\infty/g,"∞").replace(/\\\((.+?)\\\)/gs,"$1").replace(/\\\[[\s\S]+?\\\]/g,"").replace(/\\\$/g,"\0DOLLAR\0").replace(/\$\$[\s\S]+?\$\$/g,"").replace(/\$([^$]+)\$/g,"$1").replace(/\x00DOLLAR\x00/g,"$").replace(/\\[a-zA-Z]+\*?/g,"").replace(/\n{3,}/g,`
1289
1789
 
1290
1790
  `);const t=e.split(`
1291
- `),r=[];let n=0,a=0;for(;n<t.length;){const i=t[n],s=i.match(/^(\s*)```/);if(s){const l=s[1],u=i.trimStart().match(/^```(\w+)?\s*$/)?.[1]||"",h=[];for(n++;n<t.length&&!t[n].trimStart().startsWith("```");)h.push(t[n].startsWith(l)?t[n].slice(l.length):t[n]),n++;n<t.length&&t[n].trimStart().startsWith("```")&&n++,r.push((0,c.jsxs)("div",{className:"ak-md-pre-wrap",children:[u&&(0,c.jsx)("span",{className:"ak-md-pre-lang",children:u}),(0,c.jsx)("pre",{className:`ak-md-pre${u?` ak-md-pre--${u}`:""}`,children:(0,c.jsx)("code",{className:"ak-md-code",children:h.join(`
1292
- `)})})]},a++));continue}const o=i.match(/^(#{1,6})(\s+.*)?$/);if(o){const l=o[1].length,u=o[2]?U(o[2].trim()):"";l===1?r.push((0,c.jsx)("h1",{className:"ak-md-h1",children:u},a++)):l===2?r.push((0,c.jsx)("h2",{className:"ak-md-h2",children:u},a++)):l===3?r.push((0,c.jsx)("h3",{className:"ak-md-h3",children:u},a++)):l===4?r.push((0,c.jsx)("h4",{className:"ak-md-h4",children:u},a++)):l===5?r.push((0,c.jsx)("h5",{className:"ak-md-h5",children:u},a++)):r.push((0,c.jsx)("h6",{className:"ak-md-h6",children:u},a++)),n++;continue}if(/^[-*_]{3,}$/.test(i.trim())){r.push((0,c.jsx)("hr",{className:"ak-md-hr"},a++)),n++;continue}if(/^[-*+]\s/.test(i)){const l=[];let u=n;for(;u<t.length&&(/^[-*+]\s/.test(t[u])||t[u].trim()==="");){if(t[u].trim()===""){u++;continue}const h=t[u].length-t[u].trimStart().length,m=t[u].replace(/^[-*+]\s+/,""),g=[],y=[];let x=u+1;for(;x<t.length&&x<u+20;){const b=t[x];if(b.length-b.trimStart().length>h&&b.trim()!==""){const C=b.trim();/^[-*+]\s/.test(C)?g.push((0,c.jsx)("li",{children:U(C.replace(/^[-*+]\s+/,""))},`nested-${x}`)):y.push((0,c.jsx)("p",{style:{margin:"0.2em 0 0"},children:U(C)},`cont-${x}`)),x++}else break}const S=y.length>0||g.length>0?(0,c.jsxs)(c.Fragment,{children:[U(m),y,g.length>0&&(0,c.jsx)("ul",{style:{margin:"0.2em 0 0",paddingLeft:"1.2em"},children:g})]}):U(m);l.push((0,c.jsx)("li",{children:S},`item-${u}`)),u=x}r.push((0,c.jsx)("ul",{className:"ak-md-ul",children:l},a++)),n=u;continue}if(/^\d+\.\s/.test(i)){const l=[];let u=n;for(;u<t.length&&(/^\d+\.\s/.test(t[u])||t[u].trim()==="");){if(t[u].trim()===""){u++;continue}const h=t[u].length-t[u].trimStart().length,m=t[u].replace(/^\d+\.\s+/,""),g=[],y=[];let x=u+1;for(;x<t.length&&x<u+20;){const b=t[x];if(b.length-b.trimStart().length>h&&b.trim()!==""){const C=b.trim();/^\d+\.\s/.test(C)?g.push((0,c.jsx)("li",{children:U(C.replace(/^\d+\.\s+/,""))},`nested-order-${x}`)):/^[-*+]\s/.test(C)?g.push((0,c.jsx)("li",{children:U(C.replace(/^[-*+]\s+/,""))},`nested-unorder-${x}`)):y.push((0,c.jsx)("p",{style:{margin:"0.2em 0 0"},children:U(C)},`cont-${x}`)),x++}else break}const S=y.length>0||g.length>0?(0,c.jsxs)(c.Fragment,{children:[U(m),y,g.length>0&&(0,c.jsx)("ol",{style:{margin:"0.2em 0 0",paddingLeft:"1.2em"},children:g})]}):U(m);l.push((0,c.jsx)("li",{children:S},`order-item-${u}`)),u=x}r.push((0,c.jsx)("ol",{className:"ak-md-ol",children:l},a++)),n=u;continue}if(i.trim()===""){n++;continue}const d=[];for(;n<t.length&&t[n].trim()!==""&&!t[n].startsWith("#")&&!/^\s*```/.test(t[n])&&!/^[-*+]\s/.test(t[n])&&!/^\d+\.\s/.test(t[n])&&!/^[-*_]{3,}$/.test(t[n].trim());)d.push(t[n]),n++;if(d.length>0){const l=[];d.forEach((u,h)=>{l.push(...U(u)),h<d.length-1&&l.push((0,c.jsx)("br",{},`br-${h}`))}),r.push((0,c.jsx)("p",{className:"ak-md-p",children:l},a++))}}return(0,c.jsx)(c.Fragment,{children:r})}function Dr({message:e,thinkingViewable:t=!1}){const r=e.role==="user",n=e.status==="error",a=e.status==="streaming",i=!!(e.images&&e.images.length>0),s=!!(r&&e.uploadedImageUrl),o=i||s,d=!r&&!n,l=!!e.isHuman&&!r,u=r?"ak-message--user":n?"ak-message--assistant ak-message--error":l?"ak-message--assistant ak-message--operator":"ak-message--assistant",h=["ak-message__bubble",d?"ak-message__bubble--md":"",o?"ak-message__bubble--has-image":"",l?"ak-message__bubble--operator":""].filter(Boolean).join(" "),m=l?e.senderDisplay?.trim()||"Operator":null,g=m?m.charAt(0).toUpperCase():"",y=(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)("div",{className:h,children:[s&&(0,c.jsx)("div",{className:"ak-message__images",children:(0,c.jsxs)("div",{className:"ak-message__image-wrap",children:[(0,c.jsx)("a",{href:e.uploadedImageUrl,className:"ak-message__image-link",children:(0,c.jsx)("img",{src:e.uploadedImageUrl,alt:"Uploaded image",className:"ak-message__image"})}),(0,c.jsx)("a",{href:e.uploadedImageUrl,download:!0,className:"ak-message__image-dl-icon",title:"Download image",onClick:S=>S.stopPropagation(),children:(0,c.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,c.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,c.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})})]})}),i&&(0,c.jsx)("div",{className:"ak-message__images",children:e.images.map((S,b)=>{const C=S.url??(S.base64?`data:${S.mimeType};base64,${S.base64}`:null);return C?(0,c.jsxs)("div",{className:"ak-message__image-wrap",children:[(0,c.jsx)("a",{href:C,className:"ak-message__image-link",children:(0,c.jsx)("img",{src:C,alt:"Generated image",className:"ak-message__image"})}),(0,c.jsx)("a",{href:C,download:!0,className:"ak-message__image-dl-icon",title:"Download image",onClick:R=>R.stopPropagation(),children:(0,c.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,c.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,c.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})})]},`${e.id}-img-${b}`):null})}),(e.content||a&&!e.isThinking)&&(0,c.jsxs)("div",{className:o?"ak-message__image-caption":void 0,children:[d?ns(e.content):e.content,a&&!e.isThinking&&(0,c.jsxs)("span",{className:"ak-cursor","aria-hidden":"true",children:[(0,c.jsx)("span",{className:"ak-cursor__dot"}),(0,c.jsx)("span",{className:"ak-cursor__dot"}),(0,c.jsx)("span",{className:"ak-cursor__dot"})]})]})]}),(0,c.jsx)("span",{className:"ak-message__time",children:rs(e.createdAt)})]}),x=!e.isThinking||!!e.content;return(0,c.jsxs)("div",{className:`ak-message ${u}`,children:[!r&&(0,c.jsx)(ts,{thinking:e.thinking,isThinking:e.isThinking??!1,thinkingViewable:t}),l&&(0,c.jsxs)("span",{className:"ak-message__sender-label",children:[(0,c.jsx)("span",{className:"ak-message__operator-avatar","aria-hidden":"true",children:g}),(0,c.jsx)("span",{className:"ak-message__operator-name",children:m})]}),x&&y]})}function $r(){return(0,c.jsxs)("div",{className:"ak-typing","aria-label":"Assistant is typing",children:[(0,c.jsx)("span",{className:"ak-typing__dot"}),(0,c.jsx)("span",{className:"ak-typing__dot"}),(0,c.jsx)("span",{className:"ak-typing__dot"})]})}function as(e,t){const r=[];let n=null;for(const a of e){if(a.role==="assistant"){const i=!!a.isHuman;n!==null&&n!==i&&r.push({kind:"divider",id:`divider-${a.id}`,label:i?`${a.senderDisplay?.trim()||t} joined the chat`:`${t} left — AI is back`}),n=i}r.push({kind:"message",message:a})}return r}function Ur({messages:e,isLoading:t,thinkingViewable:r,operatorFallbackLabel:n="Operator"}){const a=(0,E.useRef)(null),i=(0,E.useMemo)(()=>as(e,n),[e,n]),s=e.find(d=>d.status==="streaming")?.content??"",o=e.find(d=>d.isThinking)?.thinking??"";return(0,E.useEffect)(()=>{a.current?.scrollIntoView({behavior:"smooth"})},[e.length,t,s,o]),(0,c.jsxs)("div",{className:"ak-messages",role:"log","aria-live":"polite","aria-label":"Conversation",children:[i.map(d=>d.kind==="divider"?(0,c.jsx)("div",{className:"ak-handoff-divider",role:"separator",children:(0,c.jsx)("span",{className:"ak-handoff-divider__label",children:d.label})},d.id):(0,c.jsx)(Dr,{message:d.message,thinkingViewable:r},d.message.id)),t&&!e.some(d=>d.status==="streaming")&&(0,c.jsx)($r,{}),(0,c.jsx)("div",{ref:a})]})}function is(){return(0,c.jsxs)("svg",{width:"30",height:"30",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,c.jsx)("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),(0,c.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,c.jsx)("path",{d:"M12 7v4"}),(0,c.jsx)("line",{x1:"8",y1:"16",x2:"8",y2:"16"}),(0,c.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"16"})]})}function ss({title:e,description:t,greeting:r,avatarUrl:n}){return(0,c.jsxs)("div",{className:"ak-empty-state","aria-label":"Start a conversation",children:[(0,c.jsx)("div",{className:"ak-empty-state__glow","aria-hidden":"true"}),(0,c.jsxs)("div",{className:"ak-empty-state__body",children:[(0,c.jsx)("div",{className:"ak-empty-state__avatar",children:n?(0,c.jsx)("img",{src:n,alt:"",className:"ak-empty-state__avatar-img","aria-hidden":"true"}):(0,c.jsx)("span",{className:"ak-empty-state__bot-icon","aria-hidden":"true",children:(0,c.jsx)(is,{})})}),(0,c.jsx)("p",{className:"ak-empty-state__title",children:e}),t&&(0,c.jsx)("p",{className:"ak-empty-state__description",children:t})]}),r&&(0,c.jsxs)("div",{className:"ak-empty-state__quote",children:[(0,c.jsx)("span",{className:"ak-empty-state__quote-mark","aria-hidden":"true",children:'"'}),(0,c.jsx)("p",{className:"ak-empty-state__quote-text",children:r})]})]})}function os(){return(0,c.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,c.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function cs(){return(0,c.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[(0,c.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,c.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function ds(){return(0,c.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("path",{d:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"}),(0,c.jsx)("circle",{cx:"12",cy:"13",r:"4"})]})}function ls(){return(0,c.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,c.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Br({onSend:e,disabled:t=!1,placeholder:r="Type a message…",privacyPolicyUrl:n,termsOfServiceUrl:a,photoSendingEnabled:i=!1}){const[s,o]=(0,E.useState)(""),[d,l]=(0,E.useState)(null),[u,h]=(0,E.useState)(null),[m,g]=(0,E.useState)(!1),y=(0,E.useRef)(null),x=(0,E.useRef)(null),S=(0,E.useRef)(null),b=(0,E.useRef)(null);(0,E.useEffect)(()=>()=>{u&&URL.revokeObjectURL(u)},[u]),(0,E.useEffect)(()=>{t||y.current?.focus()},[t]);const C=(0,E.useCallback)(Z=>{if(!m)return;const O=Z.composedPath?Z.composedPath():[],Ae=!!S.current&&O.includes(S.current),Ee=!!b.current&&O.includes(b.current);!Ae&&!Ee&&g(!1)},[m]);(0,E.useEffect)(()=>{if(m)return document.addEventListener("click",C),()=>document.removeEventListener("click",C)},[m,C]),(0,E.useEffect)(()=>{i||g(!1)},[i]);function R(){l(null),u&&URL.revokeObjectURL(u),h(null),x.current&&(x.current.value="")}function D(){const Z=s.trim();!Z&&!d||t||(e(Z,d??void 0),o(""),R(),y.current&&(y.current.style.height="auto"))}function ee(Z){Z.key==="Enter"&&!Z.shiftKey&&(Z.preventDefault(),D())}function X(Z){const O=Z.currentTarget;o(O.value),O.style.height="auto",O.style.height=`${O.scrollHeight}px`}function ie(Z){const O=Z.currentTarget.files?.[0];if(O){if(O.size>5*1024*1024){alert("Image must be smaller than 5 MB."),Z.currentTarget.value="";return}u&&URL.revokeObjectURL(u),l(O),h(URL.createObjectURL(O))}}function T(){g(!1),x.current?.click()}const Le=!t&&(!!s.trim()||!!d);return(0,c.jsxs)("div",{className:"ak-composer",children:[i&&m&&(0,c.jsx)("div",{ref:S,className:"ak-composer__attach-menu",role:"menu",children:(0,c.jsxs)("button",{className:"ak-composer__attach-menu-item",onClick:T,type:"button",role:"menuitem",disabled:t,children:[(0,c.jsx)(ds,{}),(0,c.jsx)("span",{children:"Photo"})]})}),u&&(0,c.jsx)("div",{className:"ak-composer__preview",children:(0,c.jsxs)("div",{className:"ak-composer__preview-wrap",children:[(0,c.jsx)("img",{src:u,alt:"Selected",className:"ak-composer__preview-img"}),(0,c.jsx)("button",{className:"ak-composer__preview-remove",onClick:R,type:"button","aria-label":"Remove image",disabled:t,children:(0,c.jsx)(ls,{})})]})}),(0,c.jsxs)("div",{className:"ak-composer__input-wrap",children:[i&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("input",{ref:x,type:"file",accept:"image/jpeg,image/png,image/gif,image/webp",className:"ak-composer__file-input",onChange:ie,disabled:t,"aria-label":"Attach image"}),(0,c.jsx)("div",{className:"ak-composer__attach-wrap",children:(0,c.jsx)("button",{ref:b,className:`ak-composer__attach${m?" ak-composer__attach--open":""}`,onClick:()=>g(Z=>!Z),disabled:t,"aria-label":"Attachment options","aria-haspopup":"true","aria-expanded":m,type:"button",children:(0,c.jsx)(cs,{})})})]}),(0,c.jsx)("textarea",{ref:y,className:"ak-composer__input",value:s,onInput:X,onKeyDown:ee,placeholder:r,disabled:t,rows:1,"aria-label":"Message input"}),(0,c.jsx)("button",{className:"ak-composer__send",onClick:D,disabled:!Le,"aria-label":"Send message",type:"button",children:(0,c.jsx)(os,{})})]}),(0,c.jsxs)("p",{className:"ak-composer__disclaimer",children:[(n||a)&&(0,c.jsxs)(c.Fragment,{children:["By chatting you agree to our"," ",n?(0,c.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:"Privacy Policy"}):"Privacy Policy",a&&(0,c.jsxs)(c.Fragment,{children:[" ","and"," ",(0,c.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:"Terms of Service"})]}),". "]}),"AI can make mistakes. Verify important information."]})]})}function Ct({message:e}){return e.includes("Origin not allowed")?(0,c.jsxs)("div",{className:"ak-error ak-error--origin",role:"alert",children:[(0,c.jsx)("div",{className:"ak-error__icon",children:"🔒"}),(0,c.jsxs)("div",{className:"ak-error__content",children:[(0,c.jsx)("h3",{className:"ak-error__title",children:"Access Restricted"}),(0,c.jsx)("p",{className:"ak-error__description",children:"This widget has been restricted to specific websites only. Contact the website administrator if you believe this is an error."})]})]}):(0,c.jsxs)("div",{className:"ak-error",role:"alert",children:[(0,c.jsx)("div",{className:"ak-error__icon",children:"⚠️"}),(0,c.jsx)("div",{className:"ak-error__content",children:(0,c.jsx)("p",{className:"ak-error__message",children:e})})]})}function us(){return(0,c.jsxs)("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,c.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,c.jsx)("path",{d:"M12 7v5l3 2"})]})}function hs(){return(0,c.jsxs)("div",{className:"ak-maintenance",role:"status","aria-live":"polite",children:[(0,c.jsx)("div",{className:"ak-maintenance__halo","aria-hidden":"true"}),(0,c.jsx)("div",{className:"ak-maintenance__icon",children:(0,c.jsx)(us,{})}),(0,c.jsx)("p",{className:"ak-maintenance__title",children:"Under maintenance"}),(0,c.jsx)("p",{className:"ak-maintenance__description",children:"This assistant is temporarily unavailable. Please check back in a little while."})]})}function fs(){return(0,c.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"ak-branding__logo",children:[(0,c.jsx)("rect",{width:"24",height:"24",rx:"5",fill:"currentColor"}),(0,c.jsx)("path",{d:"M12 5L7 13h3.5v6l6.5-9H13.5V5z",fill:"white"})]})}function ms(){return(0,c.jsxs)("div",{className:"ak-branding",children:[(0,c.jsx)(fs,{}),(0,c.jsx)("span",{className:"ak-branding__label",children:"Powered by"}),(0,c.jsx)("span",{className:"ak-branding__name",children:"AgentForge"})]})}function It({config:e,messages:t,isLoading:r,error:n,isInline:a,initStatus:i,initError:s,callbacks:o}){return(0,c.jsxs)("div",{className:a?"ak-shell-wrap":"ak-shell-wrap ak-shell-enter",children:[(0,c.jsxs)("div",{className:a?"ak-shell ak-shell--inline":"ak-shell ak-shell--floating",role:"dialog","aria-label":e.title,children:[(0,c.jsx)(zr,{title:e.title,subtitle:e.subtitle,avatarUrl:e.avatarUrl,onClose:o.onClose,onReset:i==="ready"?o.onReset:void 0,hideClose:!0}),i==="validating"&&(0,c.jsx)("div",{className:"ak-init-status",children:(0,c.jsx)("div",{className:"ak-init-spinner","aria-label":"Connecting…"})}),i==="error"&&(0,c.jsx)("div",{className:"ak-init-status ak-init-status--error",children:(0,c.jsx)(Ct,{message:s??"Widget configuration is invalid."})}),i==="disabled"&&(0,c.jsx)("div",{className:"ak-init-status ak-init-status--maintenance",children:(0,c.jsx)(hs,{})}),i==="ready"&&(0,c.jsxs)(c.Fragment,{children:[t.length===0?(0,c.jsx)(ss,{title:e.title,description:e.description??e.subtitle,greeting:e.greeting,avatarUrl:e.avatarUrl}):(0,c.jsx)(Ur,{messages:t,isLoading:r,thinkingViewable:e.thinkingViewable}),n&&(0,c.jsx)(Ct,{message:n}),(0,c.jsx)(Br,{onSend:o.onSendMessage,disabled:r,placeholder:"Type a message…",privacyPolicyUrl:e.privacyPolicyUrl,termsOfServiceUrl:e.termsOfServiceUrl,photoSendingEnabled:e.photoSendingEnabled})]})]}),!a&&(0,c.jsx)(ms,{})]})}function ps(){return(0,c.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,c.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function gs(){return(0,c.jsx)("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,c.jsx)("polyline",{points:"6,9 12,15 18,9"})})}function Gr({isOpen:e,onClick:t,avatarUrl:r,ariaLabel:n="Toggle chat"}){const a=!e&&!!r;return(0,c.jsx)("button",{className:`ak-launcher${a?" ak-launcher--avatar":""}`,onClick:t,"aria-label":n,"aria-expanded":e,type:"button",children:e?(0,c.jsx)(gs,{}):a?(0,c.jsx)("img",{src:r,alt:"",className:"ak-launcher__avatar-img","aria-hidden":"true"}):(0,c.jsx)(ps,{})})}function Nt({config:e,state:t,callbacks:r}){const n=e.mode==="inline",a=(0,E.useRef)(null);return(0,E.useEffect)(()=>{const i=a.current?.getRootNode()?.host;if(!i)return;const s=Fr(e.theme.mode);i.setAttribute("data-theme",s)},[e.theme.mode]),n?(0,c.jsx)("div",{ref:a,className:"ak-inline",children:(0,c.jsx)(It,{config:e,messages:t.messages,isLoading:t.isLoading,error:t.error,isInline:!0,initStatus:t.initStatus,initError:t.initError,callbacks:r})}):(0,c.jsxs)("div",{ref:a,className:"ak-floating",children:[t.isOpen&&(0,c.jsx)(It,{config:e,messages:t.messages,isLoading:t.isLoading,error:t.error,isInline:!1,initStatus:t.initStatus,initError:t.initError,callbacks:r}),(0,c.jsx)(Gr,{isOpen:t.isOpen,onClick:t.isOpen?r.onClose:r.onOpen,avatarUrl:e.avatarUrl})]})}var vs=(e,t,r,n)=>{const a=(0,Hr.createRoot)(e);return a.render((0,E.createElement)(Nt,{config:t,state:r,callbacks:n})),{update(i,s){a.render((0,E.createElement)(Nt,{config:s,state:i,callbacks:n}))},destroy(){setTimeout(()=>{a.unmount()},0)}}};function ks(e){return Wr+`
1293
- `+Pr(e)}exports.ApiClient=Ir;exports.Composer=Br;exports.ErrorState=Ct;exports.EventEmitter=Tr;exports.Header=zr;exports.Launcher=Gr;exports.MessageBubble=Dr;exports.MessageList=Ur;exports.TypingIndicator=$r;exports.WidgetApp=Nt;exports.WidgetClient=Ar;exports.WidgetShell=It;exports.buildThemeVars=Pr;exports.buildWidgetCSS=ks;exports.clearSession=jt;exports.createFloatingContainer=Mr;exports.createShadowHost=Er;exports.createWidget=Zt;exports.destroyWidget=Ji;exports.getSessionId=Lr;exports.init=Hi;exports.injectStyles=Rr;exports.listWidgets=Qi;exports.mount=Xi;exports.normalizeConfig=qe;exports.prepareInlineContainer=Or;exports.removeShadowHost=Zr;exports.renderWidget=vs;exports.resolveThemeMode=Fr;exports.setSessionId=we;exports.streamChat=Nr;exports.widgetCSS=Wr;
1791
+ `),r=[];let a=0,n=0;for(;a<t.length;){const i=t[a],s=i.match(/^(\s*)```/);if(s){const d=s[1],u=i.trimStart().match(/^```(\w+)?\s*$/)?.[1]||"",h=[];for(a++;a<t.length&&!t[a].trimStart().startsWith("```");)h.push(t[a].startsWith(d)?t[a].slice(d.length):t[a]),a++;a<t.length&&t[a].trimStart().startsWith("```")&&a++,r.push((0,o.jsxs)("div",{className:"ak-md-pre-wrap",children:[u&&(0,o.jsx)("span",{className:"ak-md-pre-lang",children:u}),(0,o.jsx)("pre",{className:`ak-md-pre${u?` ak-md-pre--${u}`:""}`,children:(0,o.jsx)("code",{className:"ak-md-code",children:h.join(`
1792
+ `)})})]},n++));continue}const c=i.match(/^(#{1,6})(\s+.*)?$/);if(c){const d=c[1].length,u=c[2]?H(c[2].trim()):"";d===1?r.push((0,o.jsx)("h1",{className:"ak-md-h1",children:u},n++)):d===2?r.push((0,o.jsx)("h2",{className:"ak-md-h2",children:u},n++)):d===3?r.push((0,o.jsx)("h3",{className:"ak-md-h3",children:u},n++)):d===4?r.push((0,o.jsx)("h4",{className:"ak-md-h4",children:u},n++)):d===5?r.push((0,o.jsx)("h5",{className:"ak-md-h5",children:u},n++)):r.push((0,o.jsx)("h6",{className:"ak-md-h6",children:u},n++)),a++;continue}if(/^[-*_]{3,}$/.test(i.trim())){r.push((0,o.jsx)("hr",{className:"ak-md-hr"},n++)),a++;continue}if(/^[-*+]\s/.test(i)){const d=[];let u=a;for(;u<t.length&&(/^[-*+]\s/.test(t[u])||t[u].trim()==="");){if(t[u].trim()===""){u++;continue}const h=t[u].length-t[u].trimStart().length,p=t[u].replace(/^[-*+]\s+/,""),g=[],m=[];let k=u+1;for(;k<t.length&&k<u+20;){const y=t[k];if(y.length-y.trimStart().length>h&&y.trim()!==""){const N=y.trim();/^[-*+]\s/.test(N)?g.push((0,o.jsx)("li",{children:H(N.replace(/^[-*+]\s+/,""))},`nested-${k}`)):m.push((0,o.jsx)("p",{style:{margin:"0.2em 0 0"},children:H(N)},`cont-${k}`)),k++}else break}const b=m.length>0||g.length>0?(0,o.jsxs)(o.Fragment,{children:[H(p),m,g.length>0&&(0,o.jsx)("ul",{style:{margin:"0.2em 0 0",paddingLeft:"1.2em"},children:g})]}):H(p);d.push((0,o.jsx)("li",{children:b},`item-${u}`)),u=k}r.push((0,o.jsx)("ul",{className:"ak-md-ul",children:d},n++)),a=u;continue}if(/^\d+\.\s/.test(i)){const d=[];let u=a;for(;u<t.length&&(/^\d+\.\s/.test(t[u])||t[u].trim()==="");){if(t[u].trim()===""){u++;continue}const h=t[u].length-t[u].trimStart().length,p=t[u].replace(/^\d+\.\s+/,""),g=[],m=[];let k=u+1;for(;k<t.length&&k<u+20;){const y=t[k];if(y.length-y.trimStart().length>h&&y.trim()!==""){const N=y.trim();/^\d+\.\s/.test(N)?g.push((0,o.jsx)("li",{children:H(N.replace(/^\d+\.\s+/,""))},`nested-order-${k}`)):/^[-*+]\s/.test(N)?g.push((0,o.jsx)("li",{children:H(N.replace(/^[-*+]\s+/,""))},`nested-unorder-${k}`)):m.push((0,o.jsx)("p",{style:{margin:"0.2em 0 0"},children:H(N)},`cont-${k}`)),k++}else break}const b=m.length>0||g.length>0?(0,o.jsxs)(o.Fragment,{children:[H(p),m,g.length>0&&(0,o.jsx)("ol",{style:{margin:"0.2em 0 0",paddingLeft:"1.2em"},children:g})]}):H(p);d.push((0,o.jsx)("li",{children:b},`order-item-${u}`)),u=k}r.push((0,o.jsx)("ol",{className:"ak-md-ol",children:d},n++)),a=u;continue}if(i.trim()===""){a++;continue}if(i.includes("|")&&a+1<t.length&&t[a+1].includes("|")){const d=t[a+1];if(/^\s*\|?[\s:|*-]+\|[\s:|*-|]+\|?[\s:|*-]*$/.test(d)){const u=i.split("|").map(m=>m.trim()).filter(m=>m.length>0),h=d.split("|").map(m=>{const k=m.trim();return k.startsWith(":")&&k.endsWith(":")?"center":k.endsWith(":")?"right":(k.startsWith(":"),"left")}).filter((m,k)=>k>0&&k<=u.length),p=[];let g=a+2;for(;g<t.length&&t[g].includes("|")&&t[g].trim()!=="";){const m=t[g].split("|").map(k=>k.trim()).filter(k=>k.length>0);if(m.length>0)p.push(m),g++;else break}r.push((0,o.jsxs)("table",{className:"ak-md-table",children:[(0,o.jsx)("thead",{children:(0,o.jsx)("tr",{children:u.map((m,k)=>(0,o.jsx)("th",{style:{textAlign:h[k]||"left"},className:"ak-md-th",children:H(m)},`th-${k}`))})}),(0,o.jsx)("tbody",{children:p.map((m,k)=>(0,o.jsx)("tr",{children:u.map((b,y)=>(0,o.jsx)("td",{style:{textAlign:h[y]||"left"},className:"ak-md-td",children:m[y]?H(m[y]):""},`td-${k}-${y}`))},`tr-${k}`))})]},n++)),a=g;continue}}const l=[];for(;a<t.length&&t[a].trim()!==""&&!t[a].startsWith("#")&&!/^\s*```/.test(t[a])&&!/^[-*+]\s/.test(t[a])&&!/^\d+\.\s/.test(t[a])&&!/^[-*_]{3,}$/.test(t[a].trim());)l.push(t[a]),a++;if(l.length>0){const d=[];l.forEach((u,h)=>{d.push(...H(u)),h<l.length-1&&d.push((0,o.jsx)("br",{},`br-${h}`))}),r.push((0,o.jsx)("p",{className:"ak-md-p",children:d},n++))}}return(0,o.jsx)(o.Fragment,{children:r})}function aa({message:e,thinkingViewable:t=!1}){const[r,a]=(0,A.useState)(null),[n,i]=(0,A.useState)(null),s=e.role==="user",c=e.status==="error",l=e.status==="streaming",d=!!(e.images&&e.images.length>0),u=(()=>{if(!s)return[];const C=(e.uploadedAttachments??[]).filter(S=>S.kind==="image").map(S=>({url:S.url,mimeType:S.mimeType,fileName:S.fileName}));return C.length>0?C:e.uploadedImageUrl?[{url:e.uploadedImageUrl,mimeType:"image/jpeg"}]:[]})(),h=s?(e.uploadedAttachments??[]).filter(C=>C.kind==="file"):[],p=u.length>0,g=h.length>0,m=d||p,k=!s&&!c,b=!!e.isHuman&&!s,y=s?"ak-message--user":c?"ak-message--assistant ak-message--error":b?"ak-message--assistant ak-message--operator":"ak-message--assistant",N=["ak-message__bubble",k?"ak-message__bubble--md":"",m?"ak-message__bubble--has-image":"",b?"ak-message__bubble--operator":""].filter(Boolean).join(" "),R=b?e.senderDisplay?.trim()||"Operator":null,P=R?R.charAt(0).toUpperCase():"",U=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:N,children:[p&&(0,o.jsx)(cr,{messageId:`${e.id}-up`,images:u.map(C=>({src:C.url,alt:C.fileName??"Uploaded image",downloadHref:C.url})),onCellClick:C=>a(C)}),g&&(0,o.jsx)("div",{className:"ak-message__files",children:h.map((C,S)=>(0,o.jsx)(Ts,{url:C.url,mimeType:C.mimeType,fileName:C.fileName},`${e.id}-up-file-${S}`))}),d&&(0,o.jsx)(cr,{messageId:`${e.id}-asst`,images:e.images.map((C,S)=>{const ce=C.url??(C.base64?`data:${C.mimeType};base64,${C.base64}`:null);return ce?{src:ce,alt:"Generated image",downloadHref:C.url??ce,key:`gen-${S}`}:null}).filter(C=>C!==null),onCellClick:C=>i(C)}),(e.content||l&&!e.isThinking&&!e.toolStatus)&&(0,o.jsxs)("div",{className:m?"ak-message__image-caption":void 0,children:[k?Es(e.content):e.content,l&&!e.isThinking&&!e.toolStatus&&(0,o.jsxs)("span",{className:"ak-cursor","aria-hidden":"true",children:[(0,o.jsx)("span",{className:"ak-cursor__dot"}),(0,o.jsx)("span",{className:"ak-cursor__dot"}),(0,o.jsx)("span",{className:"ak-cursor__dot"})]})]})]}),(0,o.jsx)("span",{className:"ak-message__time",children:Ls(e.createdAt)})]}),V=!!e.content||!e.isThinking&&!e.toolStatus;return(0,o.jsxs)("div",{className:`ak-message ${y}`,children:[!s&&(e.ackText||e.progressEvents&&e.progressEvents.length>0)&&(0,o.jsx)(Ss,{ackText:e.ackText,events:e.progressEvents,collapsed:e.progressCollapsed,isComplete:!l}),!s&&(0,o.jsx)(Cs,{thinking:e.thinking,isThinking:e.isThinking??!1,thinkingViewable:t}),!s&&e.toolStatus&&!(e.progressEvents&&e.progressEvents.length>0)&&(0,o.jsx)(Ns,{status:e.toolStatus}),b&&(0,o.jsxs)("span",{className:"ak-message__sender-label",children:[(0,o.jsx)("span",{className:"ak-message__operator-avatar","aria-hidden":"true",children:P}),(0,o.jsx)("span",{className:"ak-message__operator-name",children:R})]}),V&&U,u.length>0&&(0,o.jsx)(dr,{images:u.map(C=>({src:C.url,alt:C.fileName??"Uploaded image",downloadHref:C.url})),index:r,onClose:()=>a(null),onIndexChange:a}),d&&(0,o.jsx)(dr,{images:e.images.map(C=>{const S=C.url??(C.base64?`data:${C.mimeType};base64,${C.base64}`:null);return S?{src:S,alt:"Generated image",downloadHref:C.url??S}:null}).filter(C=>C!==null),index:n,onClose:()=>i(null),onIndexChange:i})]})}function na(){return(0,o.jsxs)("div",{className:"ak-typing","aria-label":"Assistant is typing",children:[(0,o.jsx)("span",{className:"ak-typing__dot"}),(0,o.jsx)("span",{className:"ak-typing__dot"}),(0,o.jsx)("span",{className:"ak-typing__dot"})]})}function As(e,t){const r=[];let a=null;for(const n of e){if(n.role==="assistant"){const i=!!n.isHuman;a!==null&&a!==i&&r.push({kind:"divider",id:`divider-${n.id}`,label:i?`${n.senderDisplay?.trim()||t} joined the chat`:`${t} left — AI is back`}),a=i}r.push({kind:"message",message:n})}return r}function ia({messages:e,isLoading:t,thinkingViewable:r,operatorFallbackLabel:a="Operator"}){const n=(0,A.useRef)(null),i=(0,A.useRef)(null),s=(0,A.useRef)(!0),c=(0,A.useMemo)(()=>As(e,a),[e,a]);return(0,A.useEffect)(()=>{if(!(n.current?.parentElement??n.current))return;const l=h=>{s.current=h.scrollHeight-h.scrollTop-h.clientHeight<120};let d=n.current;for(;d&&getComputedStyle(d).overflowY==="visible";)d=d.parentElement;if(!d)return;const u=()=>l(d);return d.addEventListener("scroll",u,{passive:!0}),()=>d.removeEventListener("scroll",u)},[]),(0,A.useEffect)(()=>{e[e.length-1]?.role==="user"&&(s.current=!0),s.current&&i.current?.scrollIntoView({behavior:"smooth"})},[e]),(0,A.useEffect)(()=>{s.current&&i.current?.scrollIntoView({behavior:"smooth"})},[t,e.find(l=>l.status==="streaming")?.content??"",e.find(l=>l.isThinking)?.thinking??""]),(0,o.jsxs)("div",{ref:n,className:"ak-messages",role:"log","aria-live":"polite","aria-label":"Conversation",children:[c.map(l=>l.kind==="divider"?(0,o.jsx)("div",{className:"ak-handoff-divider",role:"separator",children:(0,o.jsx)("span",{className:"ak-handoff-divider__label",children:l.label})},l.id):(0,o.jsx)(aa,{message:l.message,thinkingViewable:r},l.message.id)),t&&!e.some(l=>l.status==="streaming")&&(0,o.jsx)(na,{}),(0,o.jsx)("div",{ref:i})]})}function Ms(){return(0,o.jsxs)("svg",{width:"30",height:"30",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,o.jsx)("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),(0,o.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,o.jsx)("path",{d:"M12 7v4"}),(0,o.jsx)("line",{x1:"8",y1:"16",x2:"8",y2:"16"}),(0,o.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"16"})]})}function Rs({title:e,description:t,greeting:r,avatarUrl:a}){return(0,o.jsxs)("div",{className:"ak-empty-state","aria-label":"Start a conversation",children:[(0,o.jsx)("div",{className:"ak-empty-state__glow","aria-hidden":"true"}),(0,o.jsxs)("div",{className:"ak-empty-state__body",children:[(0,o.jsx)("div",{className:"ak-empty-state__avatar",children:a?(0,o.jsx)("img",{src:a,alt:"",className:"ak-empty-state__avatar-img","aria-hidden":"true"}):(0,o.jsx)("span",{className:"ak-empty-state__bot-icon","aria-hidden":"true",children:(0,o.jsx)(Ms,{})})}),(0,o.jsx)("p",{className:"ak-empty-state__title",children:e}),t&&(0,o.jsx)("p",{className:"ak-empty-state__description",children:t})]}),r&&(0,o.jsxs)("div",{className:"ak-empty-state__quote",children:[(0,o.jsx)("span",{className:"ak-empty-state__quote-mark","aria-hidden":"true",children:'"'}),(0,o.jsx)("p",{className:"ak-empty-state__quote-text",children:r})]})]})}function Zs(){return(0,o.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,o.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function Os(){return(0,o.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[(0,o.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,o.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function Fs(){return(0,o.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("path",{d:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"}),(0,o.jsx)("circle",{cx:"12",cy:"13",r:"4"})]})}function hr(){return(0,o.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,o.jsx)("polyline",{points:"14 2 14 8 20 8"})]})}function fr(){return(0,o.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,o.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}var sa=["application/pdf","text/markdown","text/plain","text/csv"],oa=[".pdf",".md",".txt",".csv"],Ps=[...oa,...sa].join(","),la=["image/jpeg","image/png","image/gif","image/webp"],Vs=la.join(",");function Ws(e){if(sa.includes(e.type))return!0;const t=e.name.toLowerCase();return oa.some(r=>t.endsWith(r))}function $s(e){return la.includes(e.type)}function ca({onSend:e,disabled:t=!1,placeholder:r="Type a message…",privacyPolicyUrl:a,termsOfServiceUrl:n,photoSendingEnabled:i=!1,fileUploadEnabled:s=!1,attachmentMaxCount:c=5,attachmentMaxFileSizeMb:l=1}){const[d,u]=(0,A.useState)(""),[h,p]=(0,A.useState)([]),[g,m]=(0,A.useState)(new Map),[k,b]=(0,A.useState)(!1),y=(0,A.useRef)(null),N=(0,A.useRef)(null),R=(0,A.useRef)(null),P=(0,A.useRef)(null),U=(0,A.useRef)(null),V=i||s,C=(0,A.useMemo)(()=>l*1024*1024,[l]);(0,A.useEffect)(()=>()=>{g.forEach(T=>URL.revokeObjectURL(T))},[]),(0,A.useEffect)(()=>{t||y.current?.focus()},[t]);const S=(0,A.useCallback)(T=>{if(!k)return;const O=T.composedPath?T.composedPath():[],J=!!P.current&&O.includes(P.current),W=!!U.current&&O.includes(U.current);!J&&!W&&b(!1)},[k]);(0,A.useEffect)(()=>{if(k)return document.addEventListener("click",S),()=>document.removeEventListener("click",S)},[k,S]),(0,A.useEffect)(()=>{V||b(!1)},[V]);function ce(){g.forEach(T=>URL.revokeObjectURL(T)),m(new Map),p([]),N.current&&(N.current.value=""),R.current&&(R.current.value="")}function Ce(T){p(O=>{const J=O[T];if(J){const W=g.get(J.file);W&&(URL.revokeObjectURL(W),m(B=>{const Ie=new Map(B);return Ie.delete(J.file),Ie}))}return O.filter((W,B)=>B!==T)})}function ge(){const T=d.trim();!T&&h.length===0||t||(e(T,h),u(""),ce(),y.current&&(y.current.style.height="auto"))}function Pe(T){T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),ge())}function Ve(T){const O=T.currentTarget;u(O.value),O.style.height="auto",O.style.height=`${O.scrollHeight}px`}function We(T,O){if(T.length===0)return;const J=[],W=[];for(const B of T){if(O==="image"&&!$s(B)){W.push(`${B.name} (image type not supported)`);continue}if(O==="file"&&!Ws(B)){W.push(`${B.name} (file type not supported)`);continue}if(B.size>C){W.push(`${B.name} (over ${l} MB)`);continue}J.push({file:B,kind:O})}p(B=>{const Ie=[...B,...J],Bt=Ie.slice(0,c);return Ie.length>c&&W.push(`max ${c} attachments allowed`),m(ga=>{const lt=new Map(ga);for(const $e of Bt)$e.kind==="image"&&!lt.has($e.file)&&lt.set($e.file,URL.createObjectURL($e.file));return lt}),Bt}),W.length>0&&alert(`Some attachments were not added:
1793
+ • ${W.join(`
1794
+ • `)}`)}function ua(T){const O=Array.from(T.currentTarget.files??[]);T.currentTarget.value="",We(O,"image")}function ha(T){const O=Array.from(T.currentTarget.files??[]);T.currentTarget.value="",We(O,"file")}function fa(){b(!1),N.current?.click()}function pa(){b(!1),R.current?.click()}const ma=!t&&(!!d.trim()||h.length>0);return(0,o.jsxs)("div",{className:"ak-composer",children:[V&&k&&(0,o.jsxs)("div",{ref:P,className:"ak-composer__attach-menu",role:"menu",children:[i&&(0,o.jsxs)("button",{className:"ak-composer__attach-menu-item",onClick:fa,type:"button",role:"menuitem",disabled:t,children:[(0,o.jsx)(Fs,{}),(0,o.jsx)("span",{children:"Photo"})]}),s&&(0,o.jsxs)("button",{className:"ak-composer__attach-menu-item",onClick:pa,type:"button",role:"menuitem",disabled:t,children:[(0,o.jsx)(hr,{}),(0,o.jsx)("span",{children:"File"})]})]}),h.length>0&&(0,o.jsx)("div",{className:"ak-composer__attachments",role:"list",children:h.map((T,O)=>{const J=`${T.file.name}-${O}`;if(T.kind==="image"){const W=g.get(T.file);return(0,o.jsxs)("div",{className:"ak-composer__preview-wrap",role:"listitem",children:[W&&(0,o.jsx)("img",{src:W,alt:T.file.name,className:"ak-composer__preview-img"}),(0,o.jsx)("button",{className:"ak-composer__preview-remove",onClick:()=>Ce(O),type:"button","aria-label":`Remove ${T.file.name}`,disabled:t,children:(0,o.jsx)(fr,{})})]},J)}return(0,o.jsxs)("span",{className:"ak-composer__file-chip",role:"listitem",children:[(0,o.jsx)(hr,{}),(0,o.jsx)("span",{className:"ak-composer__file-chip-name",title:T.file.name,children:T.file.name}),(0,o.jsx)("button",{className:"ak-composer__file-chip-remove",onClick:()=>Ce(O),type:"button","aria-label":`Remove ${T.file.name}`,disabled:t,children:(0,o.jsx)(fr,{})})]},J)})}),(0,o.jsxs)("div",{className:"ak-composer__input-wrap",children:[V&&(0,o.jsxs)(o.Fragment,{children:[i&&(0,o.jsx)("input",{ref:N,type:"file",multiple:!0,accept:Vs,className:"ak-composer__file-input",onChange:ua,disabled:t,"aria-label":"Attach images"}),s&&(0,o.jsx)("input",{ref:R,type:"file",multiple:!0,accept:Ps,className:"ak-composer__file-input",onChange:ha,disabled:t,"aria-label":"Attach files"}),(0,o.jsx)("div",{className:"ak-composer__attach-wrap",children:(0,o.jsx)("button",{ref:U,className:`ak-composer__attach${k?" ak-composer__attach--open":""}`,onClick:()=>b(T=>!T),disabled:t,"aria-label":"Attachment options","aria-haspopup":"true","aria-expanded":k,type:"button",children:(0,o.jsx)(Os,{})})})]}),(0,o.jsx)("textarea",{ref:y,className:"ak-composer__input",value:d,onInput:Ve,onKeyDown:Pe,placeholder:r,disabled:t,rows:1,"aria-label":"Message input"}),(0,o.jsx)("button",{className:"ak-composer__send",onClick:ge,disabled:!ma,"aria-label":"Send message",type:"button",children:(0,o.jsx)(Zs,{})})]}),(0,o.jsxs)("p",{className:"ak-composer__disclaimer",children:[(a||n)&&(0,o.jsxs)(o.Fragment,{children:["By chatting you agree to our"," ",a?(0,o.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:"Privacy Policy"}):"Privacy Policy",n&&(0,o.jsxs)(o.Fragment,{children:[" ","and"," ",(0,o.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:"Terms of Service"})]}),". "]}),"AI can make mistakes. Verify important information."]})]})}function Ot({message:e}){return e.includes("Origin not allowed")?(0,o.jsxs)("div",{className:"ak-error ak-error--origin",role:"alert",children:[(0,o.jsx)("div",{className:"ak-error__icon",children:"🔒"}),(0,o.jsxs)("div",{className:"ak-error__content",children:[(0,o.jsx)("h3",{className:"ak-error__title",children:"Access Restricted"}),(0,o.jsx)("p",{className:"ak-error__description",children:"This widget has been restricted to specific websites only. Contact the website administrator if you believe this is an error."})]})]}):(0,o.jsxs)("div",{className:"ak-error",role:"alert",children:[(0,o.jsx)("div",{className:"ak-error__icon",children:"⚠️"}),(0,o.jsx)("div",{className:"ak-error__content",children:(0,o.jsx)("p",{className:"ak-error__message",children:e})})]})}function zs(){return(0,o.jsxs)("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,o.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,o.jsx)("path",{d:"M12 7v5l3 2"})]})}function Ds(){return(0,o.jsxs)("div",{className:"ak-maintenance",role:"status","aria-live":"polite",children:[(0,o.jsx)("div",{className:"ak-maintenance__halo","aria-hidden":"true"}),(0,o.jsx)("div",{className:"ak-maintenance__icon",children:(0,o.jsx)(zs,{})}),(0,o.jsx)("p",{className:"ak-maintenance__title",children:"Under maintenance"}),(0,o.jsx)("p",{className:"ak-maintenance__description",children:"This assistant is temporarily unavailable. Please check back in a little while."})]})}function Us(){return(0,o.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"ak-branding__logo",children:[(0,o.jsx)("rect",{width:"24",height:"24",rx:"5",fill:"currentColor"}),(0,o.jsx)("path",{d:"M12 5L7 13h3.5v6l6.5-9H13.5V5z",fill:"white"})]})}function Bs(){return(0,o.jsxs)("div",{className:"ak-branding",children:[(0,o.jsx)(Us,{}),(0,o.jsx)("span",{className:"ak-branding__label",children:"Powered by"}),(0,o.jsx)("span",{className:"ak-branding__name",children:"KlicForge"})]})}function Ft({config:e,messages:t,isLoading:r,error:a,isInline:n,initStatus:i,initError:s,callbacks:c}){return(0,o.jsxs)("div",{className:n?"ak-shell-wrap":"ak-shell-wrap ak-shell-enter",children:[(0,o.jsxs)("div",{className:n?"ak-shell ak-shell--inline":"ak-shell ak-shell--floating",role:"dialog","aria-label":e.title,children:[(0,o.jsx)(ra,{title:e.title,subtitle:e.subtitle,avatarUrl:e.avatarUrl,onClose:c.onClose,onReset:i==="ready"?c.onReset:void 0,hideClose:!0}),i==="validating"&&(0,o.jsx)("div",{className:"ak-init-status",children:(0,o.jsx)("div",{className:"ak-init-spinner","aria-label":"Connecting…"})}),i==="error"&&(0,o.jsx)("div",{className:"ak-init-status ak-init-status--error",children:(0,o.jsx)(Ot,{message:s??"Widget configuration is invalid."})}),i==="disabled"&&(0,o.jsx)("div",{className:"ak-init-status ak-init-status--maintenance",children:(0,o.jsx)(Ds,{})}),i==="ready"&&(0,o.jsxs)(o.Fragment,{children:[t.length===0?(0,o.jsx)(Rs,{title:e.title,description:e.description??e.subtitle,greeting:e.greeting,avatarUrl:e.avatarUrl}):(0,o.jsx)(ia,{messages:t,isLoading:r,thinkingViewable:e.thinkingViewable}),a&&(0,o.jsx)(Ot,{message:a}),(0,o.jsx)(ca,{onSend:c.onSendMessage,disabled:r,placeholder:"Type a message…",privacyPolicyUrl:e.privacyPolicyUrl,termsOfServiceUrl:e.termsOfServiceUrl,photoSendingEnabled:e.photoSendingEnabled,fileUploadEnabled:e.fileUploadEnabled,attachmentMaxCount:e.attachmentMaxCount,attachmentMaxFileSizeMb:e.attachmentMaxFileSizeMb})]})]}),!n&&(0,o.jsx)(Bs,{})]})}function Gs(){return(0,o.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,o.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function Hs(){return(0,o.jsx)("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,o.jsx)("polyline",{points:"6,9 12,15 18,9"})})}function da({isOpen:e,onClick:t,avatarUrl:r,ariaLabel:a="Toggle chat"}){const n=!e&&!!r;return(0,o.jsx)("button",{className:`ak-launcher${n?" ak-launcher--avatar":""}`,onClick:t,"aria-label":a,"aria-expanded":e,type:"button",children:e?(0,o.jsx)(Hs,{}):n?(0,o.jsx)("img",{src:r,alt:"",className:"ak-launcher__avatar-img","aria-hidden":"true"}):(0,o.jsx)(Gs,{})})}function Pt({config:e,state:t,callbacks:r}){const a=e.mode==="inline",n=(0,A.useRef)(null);return(0,A.useEffect)(()=>{const i=n.current?.getRootNode()?.host;if(!i)return;const s=ea(e.theme.mode);i.setAttribute("data-theme",s)},[e.theme.mode]),a?(0,o.jsx)("div",{ref:n,className:"ak-inline",children:(0,o.jsx)(Ft,{config:e,messages:t.messages,isLoading:t.isLoading,error:t.error,isInline:!0,initStatus:t.initStatus,initError:t.initError,callbacks:r})}):(0,o.jsxs)("div",{ref:n,className:"ak-floating",children:[t.isOpen&&(0,o.jsx)(Ft,{config:e,messages:t.messages,isLoading:t.isLoading,error:t.error,isInline:!1,initStatus:t.initStatus,initError:t.initError,callbacks:r}),(0,o.jsx)(da,{isOpen:t.isOpen,onClick:t.isOpen?r.onClose:r.onOpen,avatarUrl:e.avatarUrl})]})}var Ys=(e,t,r,a)=>{const n=(0,va.createRoot)(e);return n.render((0,A.createElement)(Pt,{config:t,state:r,callbacks:a})),{update(i,s){n.render((0,A.createElement)(Pt,{config:s,state:i,callbacks:a}))},destroy(){setTimeout(()=>{n.unmount()},0)}}};function Xs(e){return ta+`
1795
+ `+qr(e)}exports.ApiClient=zr;exports.Composer=ca;exports.ErrorState=Ot;exports.EventEmitter=Ur;exports.Header=ra;exports.Launcher=da;exports.MessageBubble=aa;exports.MessageList=ia;exports.TypingIndicator=na;exports.WidgetApp=Pt;exports.WidgetClient=Gr;exports.WidgetShell=Ft;exports.buildThemeVars=qr;exports.buildWidgetCSS=Xs;exports.clearSession=Zt;exports.createFloatingContainer=Jr;exports.createShadowHost=Hr;exports.createWidget=Ut;exports.destroyWidget=bs;exports.getSessionId=Br;exports.init=ks;exports.injectStyles=Yr;exports.listWidgets=ys;exports.mount=xs;exports.normalizeConfig=ot;exports.prepareInlineContainer=Qr;exports.removeShadowHost=Xr;exports.renderWidget=Ys;exports.resolveThemeMode=ea;exports.setSessionId=Ee;exports.streamChat=Dr;exports.widgetCSS=ta;