@rubytech/taskmaster 1.0.22 → 1.0.24

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.
@@ -1,21 +1,21 @@
1
- (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&s(r)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();const Uc="modulepreload",Wc=function(e,t){return new URL(e,t).href},jo={},$e=function(t,n,s){let i=Promise.resolve();if(n&&n.length>0){let c=function(u){return Promise.all(u.map(p=>Promise.resolve(p).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const r=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),a=l?.nonce||l?.getAttribute("nonce");i=c(n.map(u=>{if(u=Wc(u,s),u in jo)return;jo[u]=!0;const p=u.endsWith(".css"),m=p?'[rel="stylesheet"]':"";if(s)for(let w=r.length-1;w>=0;w--){const x=r[w];if(x.href===u&&(!p||x.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${m}`))return;const v=document.createElement("link");if(v.rel=p?"stylesheet":Uc,p||(v.as="script"),v.crossOrigin="",v.href=u,a&&v.setAttribute("nonce",a),document.head.appendChild(v),p)return new Promise((w,x)=>{v.addEventListener("load",w),v.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${u}`)))})}))}function o(r){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=r,window.dispatchEvent(l),!l.defaultPrevented)throw r}return i.then(r=>{for(const l of r||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})};const Rn=globalThis,Ii=Rn.ShadowRoot&&(Rn.ShadyCSS===void 0||Rn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ni=Symbol(),Ho=new WeakMap;let va=class{constructor(t,n,s){if(this._$cssResult$=!0,s!==Ni)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=n}get styleSheet(){let t=this.o;const n=this.t;if(Ii&&t===void 0){const s=n!==void 0&&n.length===1;s&&(t=Ho.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&Ho.set(n,t))}return t}toString(){return this.cssText}};const Kc=e=>new va(typeof e=="string"?e:e+"",void 0,Ni),zc=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((s,i,o)=>s+(r=>{if(r._$cssResult$===!0)return r.cssText;if(typeof r=="number")return r;throw Error("Value passed to 'css' function must be a 'css' function result: "+r+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[o+1],e[0]);return new va(n,e,Ni)},jc=(e,t)=>{if(Ii)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const s=document.createElement("style"),i=Rn.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=n.cssText,e.appendChild(s)}},qo=Ii?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const s of t.cssRules)n+=s.cssText;return Kc(n)})(e):e;const{is:Hc,defineProperty:qc,getOwnPropertyDescriptor:Gc,getOwnPropertyNames:Vc,getOwnPropertySymbols:Qc,getPrototypeOf:Yc}=Object,ts=globalThis,Go=ts.trustedTypes,Xc=Go?Go.emptyScript:"",Zc=ts.reactiveElementPolyfillSupport,jt=(e,t)=>e,Fn={toAttribute(e,t){switch(t){case Boolean:e=e?Xc:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},Oi=(e,t)=>!Hc(e,t),Vo={attribute:!0,type:String,converter:Fn,reflect:!1,useDefault:!1,hasChanged:Oi};Symbol.metadata??=Symbol("metadata"),ts.litPropertyMetadata??=new WeakMap;let pt=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,n=Vo){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(t,n),!n.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,n);i!==void 0&&qc(this.prototype,t,i)}}static getPropertyDescriptor(t,n,s){const{get:i,set:o}=Gc(this.prototype,t)??{get(){return this[n]},set(r){this[n]=r}};return{get:i,set(r){const l=i?.call(this);o?.call(this,r),this.requestUpdate(t,l,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Vo}static _$Ei(){if(this.hasOwnProperty(jt("elementProperties")))return;const t=Yc(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(jt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(jt("properties"))){const n=this.properties,s=[...Vc(n),...Qc(n)];for(const i of s)this.createProperty(i,n[i])}const t=this[Symbol.metadata];if(t!==null){const n=litPropertyMetadata.get(t);if(n!==void 0)for(const[s,i]of n)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[n,s]of this.elementProperties){const i=this._$Eu(n,s);i!==void 0&&this._$Eh.set(i,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const n=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)n.unshift(qo(i))}else t!==void 0&&n.push(qo(t));return n}static _$Eu(t,n){const s=n.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,n=this.constructor.elementProperties;for(const s of n.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return jc(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,n,s){this._$AK(t,s)}_$ET(t,n){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const o=(s.converter?.toAttribute!==void 0?s.converter:Fn).toAttribute(n,s.type);this._$Em=t,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(t,n){const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const o=s.getPropertyOptions(i),r=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:Fn;this._$Em=i;const l=r.fromAttribute(n,o.type);this[i]=l??this._$Ej?.get(i)??l,this._$Em=null}}requestUpdate(t,n,s,i=!1,o){if(t!==void 0){const r=this.constructor;if(i===!1&&(o=this[t]),s??=r.getPropertyOptions(t),!((s.hasChanged??Oi)(o,n)||s.useDefault&&s.reflect&&o===this._$Ej?.get(t)&&!this.hasAttribute(r._$Eu(t,s))))return;this.C(t,n,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,n,{useDefault:s,reflect:i,wrapped:o},r){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??n??this[t]),o!==!0||r!==void 0)||(this._$AL.has(t)||(this.hasUpdated||s||(n=void 0),this._$AL.set(t,n)),i===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[i,o]of this._$Ep)this[i]=o;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[i,o]of s){const{wrapped:r}=o,l=this[i];r!==!0||this._$AL.has(i)||l===void 0||this.C(i,void 0,o,l)}}let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),this._$EO?.forEach(s=>s.hostUpdate?.()),this.update(n)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(n)}willUpdate(t){}_$AE(t){this._$EO?.forEach(n=>n.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(n=>this._$ET(n,this[n])),this._$EM()}updated(t){}firstUpdated(t){}};pt.elementStyles=[],pt.shadowRootOptions={mode:"open"},pt[jt("elementProperties")]=new Map,pt[jt("finalized")]=new Map,Zc?.({ReactiveElement:pt}),(ts.reactiveElementVersions??=[]).push("2.1.2");const Di=globalThis,Qo=e=>e,Un=Di.trustedTypes,Yo=Un?Un.createPolicy("lit-html",{createHTML:e=>e}):void 0,ba="$lit$",Re=`lit$${Math.random().toFixed(9).slice(2)}$`,wa="?"+Re,Jc=`<${wa}>`,Ve=document,Yt=()=>Ve.createComment(""),Xt=e=>e===null||typeof e!="object"&&typeof e!="function",Bi=Array.isArray,eu=e=>Bi(e)||typeof e?.[Symbol.iterator]=="function",_s=`[
1
+ (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&s(r)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();const Uc="modulepreload",Wc=function(e,t){return new URL(e,t).href},jo={},$e=function(t,n,s){let i=Promise.resolve();if(n&&n.length>0){let c=function(u){return Promise.all(u.map(p=>Promise.resolve(p).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const r=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),a=l?.nonce||l?.getAttribute("nonce");i=c(n.map(u=>{if(u=Wc(u,s),u in jo)return;jo[u]=!0;const p=u.endsWith(".css"),m=p?'[rel="stylesheet"]':"";if(s)for(let w=r.length-1;w>=0;w--){const x=r[w];if(x.href===u&&(!p||x.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${m}`))return;const v=document.createElement("link");if(v.rel=p?"stylesheet":Uc,p||(v.as="script"),v.crossOrigin="",v.href=u,a&&v.setAttribute("nonce",a),document.head.appendChild(v),p)return new Promise((w,x)=>{v.addEventListener("load",w),v.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${u}`)))})}))}function o(r){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=r,window.dispatchEvent(l),!l.defaultPrevented)throw r}return i.then(r=>{for(const l of r||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})};const Rn=globalThis,Ii=Rn.ShadowRoot&&(Rn.ShadyCSS===void 0||Rn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ni=Symbol(),Ho=new WeakMap;let ba=class{constructor(t,n,s){if(this._$cssResult$=!0,s!==Ni)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=n}get styleSheet(){let t=this.o;const n=this.t;if(Ii&&t===void 0){const s=n!==void 0&&n.length===1;s&&(t=Ho.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&Ho.set(n,t))}return t}toString(){return this.cssText}};const Kc=e=>new ba(typeof e=="string"?e:e+"",void 0,Ni),zc=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((s,i,o)=>s+(r=>{if(r._$cssResult$===!0)return r.cssText;if(typeof r=="number")return r;throw Error("Value passed to 'css' function must be a 'css' function result: "+r+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[o+1],e[0]);return new ba(n,e,Ni)},jc=(e,t)=>{if(Ii)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const s=document.createElement("style"),i=Rn.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=n.cssText,e.appendChild(s)}},qo=Ii?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const s of t.cssRules)n+=s.cssText;return Kc(n)})(e):e;const{is:Hc,defineProperty:qc,getOwnPropertyDescriptor:Gc,getOwnPropertyNames:Vc,getOwnPropertySymbols:Qc,getPrototypeOf:Yc}=Object,ts=globalThis,Go=ts.trustedTypes,Xc=Go?Go.emptyScript:"",Zc=ts.reactiveElementPolyfillSupport,jt=(e,t)=>e,Fn={toAttribute(e,t){switch(t){case Boolean:e=e?Xc:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},Oi=(e,t)=>!Hc(e,t),Vo={attribute:!0,type:String,converter:Fn,reflect:!1,useDefault:!1,hasChanged:Oi};Symbol.metadata??=Symbol("metadata"),ts.litPropertyMetadata??=new WeakMap;let pt=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,n=Vo){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(t,n),!n.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,n);i!==void 0&&qc(this.prototype,t,i)}}static getPropertyDescriptor(t,n,s){const{get:i,set:o}=Gc(this.prototype,t)??{get(){return this[n]},set(r){this[n]=r}};return{get:i,set(r){const l=i?.call(this);o?.call(this,r),this.requestUpdate(t,l,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Vo}static _$Ei(){if(this.hasOwnProperty(jt("elementProperties")))return;const t=Yc(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(jt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(jt("properties"))){const n=this.properties,s=[...Vc(n),...Qc(n)];for(const i of s)this.createProperty(i,n[i])}const t=this[Symbol.metadata];if(t!==null){const n=litPropertyMetadata.get(t);if(n!==void 0)for(const[s,i]of n)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[n,s]of this.elementProperties){const i=this._$Eu(n,s);i!==void 0&&this._$Eh.set(i,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const n=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)n.unshift(qo(i))}else t!==void 0&&n.push(qo(t));return n}static _$Eu(t,n){const s=n.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,n=this.constructor.elementProperties;for(const s of n.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return jc(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,n,s){this._$AK(t,s)}_$ET(t,n){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const o=(s.converter?.toAttribute!==void 0?s.converter:Fn).toAttribute(n,s.type);this._$Em=t,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(t,n){const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const o=s.getPropertyOptions(i),r=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:Fn;this._$Em=i;const l=r.fromAttribute(n,o.type);this[i]=l??this._$Ej?.get(i)??l,this._$Em=null}}requestUpdate(t,n,s,i=!1,o){if(t!==void 0){const r=this.constructor;if(i===!1&&(o=this[t]),s??=r.getPropertyOptions(t),!((s.hasChanged??Oi)(o,n)||s.useDefault&&s.reflect&&o===this._$Ej?.get(t)&&!this.hasAttribute(r._$Eu(t,s))))return;this.C(t,n,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,n,{useDefault:s,reflect:i,wrapped:o},r){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??n??this[t]),o!==!0||r!==void 0)||(this._$AL.has(t)||(this.hasUpdated||s||(n=void 0),this._$AL.set(t,n)),i===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[i,o]of this._$Ep)this[i]=o;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[i,o]of s){const{wrapped:r}=o,l=this[i];r!==!0||this._$AL.has(i)||l===void 0||this.C(i,void 0,o,l)}}let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),this._$EO?.forEach(s=>s.hostUpdate?.()),this.update(n)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(n)}willUpdate(t){}_$AE(t){this._$EO?.forEach(n=>n.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(n=>this._$ET(n,this[n])),this._$EM()}updated(t){}firstUpdated(t){}};pt.elementStyles=[],pt.shadowRootOptions={mode:"open"},pt[jt("elementProperties")]=new Map,pt[jt("finalized")]=new Map,Zc?.({ReactiveElement:pt}),(ts.reactiveElementVersions??=[]).push("2.1.2");const Di=globalThis,Qo=e=>e,Un=Di.trustedTypes,Yo=Un?Un.createPolicy("lit-html",{createHTML:e=>e}):void 0,wa="$lit$",Re=`lit$${Math.random().toFixed(9).slice(2)}$`,ka="?"+Re,Jc=`<${ka}>`,Ve=document,Yt=()=>Ve.createComment(""),Xt=e=>e===null||typeof e!="object"&&typeof e!="function",Bi=Array.isArray,eu=e=>Bi(e)||typeof e?.[Symbol.iterator]=="function",_s=`[
2
2
  \f\r]`,Mt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Xo=/-->/g,Zo=/>/g,ze=RegExp(`>|${_s}(?:([^\\s"'>=/]+)(${_s}*=${_s}*(?:[^
3
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Jo=/'/g,er=/"/g,ka=/^(?:script|style|textarea|title)$/i,tu=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),d=tu(1),Ne=Symbol.for("lit-noChange"),b=Symbol.for("lit-nothing"),tr=new WeakMap,qe=Ve.createTreeWalker(Ve,129);function Sa(e,t){if(!Bi(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Yo!==void 0?Yo.createHTML(t):t}const nu=(e,t)=>{const n=e.length-1,s=[];let i,o=t===2?"<svg>":t===3?"<math>":"",r=Mt;for(let l=0;l<n;l++){const a=e[l];let c,u,p=-1,m=0;for(;m<a.length&&(r.lastIndex=m,u=r.exec(a),u!==null);)m=r.lastIndex,r===Mt?u[1]==="!--"?r=Xo:u[1]!==void 0?r=Zo:u[2]!==void 0?(ka.test(u[2])&&(i=RegExp("</"+u[2],"g")),r=ze):u[3]!==void 0&&(r=ze):r===ze?u[0]===">"?(r=i??Mt,p=-1):u[1]===void 0?p=-2:(p=r.lastIndex-u[2].length,c=u[1],r=u[3]===void 0?ze:u[3]==='"'?er:Jo):r===er||r===Jo?r=ze:r===Xo||r===Zo?r=Mt:(r=ze,i=void 0);const v=r===ze&&e[l+1].startsWith("/>")?" ":"";o+=r===Mt?a+Jc:p>=0?(s.push(c),a.slice(0,p)+ba+a.slice(p)+Re+v):a+Re+(p===-2?l:v)}return[Sa(e,o+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};let ri=class Aa{constructor({strings:t,_$litType$:n},s){let i;this.parts=[];let o=0,r=0;const l=t.length-1,a=this.parts,[c,u]=nu(t,n);if(this.el=Aa.createElement(c,s),qe.currentNode=this.el.content,n===2||n===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=qe.nextNode())!==null&&a.length<l;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(ba)){const m=u[r++],v=i.getAttribute(p).split(Re),w=/([.?@])?(.*)/.exec(m);a.push({type:1,index:o,name:w[2],strings:v,ctor:w[1]==="."?iu:w[1]==="?"?ou:w[1]==="@"?ru:ss}),i.removeAttribute(p)}else p.startsWith(Re)&&(a.push({type:6,index:o}),i.removeAttribute(p));if(ka.test(i.tagName)){const p=i.textContent.split(Re),m=p.length-1;if(m>0){i.textContent=Un?Un.emptyScript:"";for(let v=0;v<m;v++)i.append(p[v],Yt()),qe.nextNode(),a.push({type:2,index:++o});i.append(p[m],Yt())}}}else if(i.nodeType===8)if(i.data===wa)a.push({type:2,index:o});else{let p=-1;for(;(p=i.data.indexOf(Re,p+1))!==-1;)a.push({type:7,index:o}),p+=Re.length-1}o++}}static createElement(t,n){const s=Ve.createElement("template");return s.innerHTML=t,s}};function vt(e,t,n=e,s){if(t===Ne)return t;let i=s!==void 0?n._$Co?.[s]:n._$Cl;const o=Xt(t)?void 0:t._$litDirective$;return i?.constructor!==o&&(i?._$AO?.(!1),o===void 0?i=void 0:(i=new o(e),i._$AT(e,n,s)),s!==void 0?(n._$Co??=[])[s]=i:n._$Cl=i),i!==void 0&&(t=vt(e,i._$AS(e,t.values),i,s)),t}class su{constructor(t,n){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:n},parts:s}=this._$AD,i=(t?.creationScope??Ve).importNode(n,!0);qe.currentNode=i;let o=qe.nextNode(),r=0,l=0,a=s[0];for(;a!==void 0;){if(r===a.index){let c;a.type===2?c=new ns(o,o.nextSibling,this,t):a.type===1?c=new a.ctor(o,a.name,a.strings,this,t):a.type===6&&(c=new au(o,this,t)),this._$AV.push(c),a=s[++l]}r!==a?.index&&(o=qe.nextNode(),r++)}return qe.currentNode=Ve,i}p(t){let n=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,n),n+=s.strings.length-2):s._$AI(t[n])),n++}}let ns=class xa{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,n,s,i){this.type=2,this._$AH=b,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&t?.nodeType===11&&(t=n.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,n=this){t=vt(this,t,n),Xt(t)?t===b||t==null||t===""?(this._$AH!==b&&this._$AR(),this._$AH=b):t!==this._$AH&&t!==Ne&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):eu(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==b&&Xt(this._$AH)?this._$AA.nextSibling.data=t:this.T(Ve.createTextNode(t)),this._$AH=t}$(t){const{values:n,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=ri.createElement(Sa(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(n);else{const o=new su(i,this),r=o.u(this.options);o.p(n),this.T(r),this._$AH=o}}_$AC(t){let n=tr.get(t.strings);return n===void 0&&tr.set(t.strings,n=new ri(t)),n}k(t){Bi(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let s,i=0;for(const o of t)i===n.length?n.push(s=new xa(this.O(Yt()),this.O(Yt()),this,this.options)):s=n[i],s._$AI(o),i++;i<n.length&&(this._$AR(s&&s._$AB.nextSibling,i),n.length=i)}_$AR(t=this._$AA.nextSibling,n){for(this._$AP?.(!1,!0,n);t!==this._$AB;){const s=Qo(t).nextSibling;Qo(t).remove(),t=s}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}};class ss{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,s,i,o){this.type=1,this._$AH=b,this._$AN=void 0,this.element=t,this.name=n,this._$AM=i,this.options=o,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=b}_$AI(t,n=this,s,i){const o=this.strings;let r=!1;if(o===void 0)t=vt(this,t,n,0),r=!Xt(t)||t!==this._$AH&&t!==Ne,r&&(this._$AH=t);else{const l=t;let a,c;for(t=o[0],a=0;a<o.length-1;a++)c=vt(this,l[s+a],n,a),c===Ne&&(c=this._$AH[a]),r||=!Xt(c)||c!==this._$AH[a],c===b?t=b:t!==b&&(t+=(c??"")+o[a+1]),this._$AH[a]=c}r&&!i&&this.j(t)}j(t){t===b?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let iu=class extends ss{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===b?void 0:t}},ou=class extends ss{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==b)}},ru=class extends ss{constructor(t,n,s,i,o){super(t,n,s,i,o),this.type=5}_$AI(t,n=this){if((t=vt(this,t,n,0)??b)===Ne)return;const s=this._$AH,i=t===b&&s!==b||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,o=t!==b&&(s===b||i);i&&this.element.removeEventListener(this.name,this,s),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},au=class{constructor(t,n,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){vt(this,t)}};const lu={I:ns},cu=Di.litHtmlPolyfillSupport;cu?.(ri,ns),(Di.litHtmlVersions??=[]).push("3.3.2");const uu=(e,t,n)=>{const s=n?.renderBefore??t;let i=s._$litPart$;if(i===void 0){const o=n?.renderBefore??null;s._$litPart$=i=new ns(t.insertBefore(Yt(),o),o,void 0,n??{})}return i._$AI(e),i};const Fi=globalThis;let mt=class extends pt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=uu(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Ne}};mt._$litElement$=!0,mt.finalized=!0,Fi.litElementHydrateSupport?.({LitElement:mt});const du=Fi.litElementPolyfillSupport;du?.({LitElement:mt});(Fi.litElementVersions??=[]).push("4.2.2");const $a=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const pu={attribute:!0,type:String,converter:Fn,reflect:!1,hasChanged:Oi},hu=(e=pu,t,n)=>{const{kind:s,metadata:i}=n;let o=globalThis.litPropertyMetadata.get(i);if(o===void 0&&globalThis.litPropertyMetadata.set(i,o=new Map),s==="setter"&&((e=Object.create(e)).wrapped=!0),o.set(n.name,e),s==="accessor"){const{name:r}=n;return{set(l){const a=t.get.call(this);t.set.call(this,l),this.requestUpdate(r,a,e,!0,l)},init(l){return l!==void 0&&this.C(r,void 0,e,l),l}}}if(s==="setter"){const{name:r}=n;return function(l){const a=this[r];t.call(this,l),this.requestUpdate(r,a,e,!0,l)}}throw Error("Unsupported decorator location: "+s)};function is(e){return(t,n)=>typeof n=="object"?hu(e,t,n):((s,i,o)=>{const r=i.hasOwnProperty(o);return i.constructor.createProperty(o,s),r?Object.getOwnPropertyDescriptor(i,o):void 0})(e,t,n)}function g(e){return is({...e,state:!0,attribute:!1})}const fu=50,gu=200,mu="Assistant";function nr(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function ai(e){const t=nr(e?.name,fu)??mu,n=nr(e?.avatar??void 0,gu)??null;return{agentId:typeof e?.agentId=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function yu(){return ai(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const Wn="taskmaster.control.settings.v1",Ea="taskmaster.account.settings.";function Ht(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const dt={gatewayUrl:Ht(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},Le={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function vu(){try{const e=localStorage.getItem(Wn);if(!e)return{...dt,gatewayUrl:Ht()};const t=JSON.parse(e);return{gatewayUrl:typeof t.gatewayUrl=="string"&&t.gatewayUrl.trim()?t.gatewayUrl.trim():Ht(),token:typeof t.token=="string"?t.token:dt.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:dt.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:dt.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:dt.navGroupsCollapsed}}catch{return{...dt,gatewayUrl:Ht()}}}function bu(e){if(!e)return{...Le};try{const t=localStorage.getItem(Ea+e);if(!t)return{...Le};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():Le.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||Le.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:Le.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:Le.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:Le.splitRatio}}catch{return{...Le}}}let Kn=null;function sr(e){Kn=e}function Ms(){return{...vu(),...bu(Kn)}}function wu(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(Wn,JSON.stringify(t)),Kn){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(Ea+Kn,JSON.stringify(n))}}(function(){try{const t=localStorage.getItem(Wn);if(!t)return;const n=JSON.parse(t);if(!("sessionKey"in n))return;const s={gatewayUrl:typeof n.gatewayUrl=="string"?n.gatewayUrl:Ht(),token:typeof n.token=="string"?n.token:"",theme:n.theme==="light"||n.theme==="dark"||n.theme==="system"?n.theme:"system",navCollapsed:typeof n.navCollapsed=="boolean"?n.navCollapsed:!1,navGroupsCollapsed:typeof n.navGroupsCollapsed=="object"&&n.navGroupsCollapsed!==null?n.navGroupsCollapsed:{}};localStorage.setItem(Wn,JSON.stringify(s))}catch{}})();function Ta(e){const t=(e??"").trim();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const s=n[1]?.trim(),i=n.slice(2).join(":");return!s||!i?null:{agentId:s,rest:i}}const ku=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,bn=/<\s*\/?\s*final\b[^>]*>/gi,ir=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function Su(e,t){return e.trimStart()}function Au(e,t){if(!e||!ku.test(e))return e;let n=e;bn.test(n)?(bn.lastIndex=0,n=n.replace(bn,"")):bn.lastIndex=0,ir.lastIndex=0;let s="",i=0,o=!1;for(const r of n.matchAll(ir)){const l=r.index??0,a=r[1]==="/";o?a&&(o=!1):(s+=n.slice(i,l),a||(o=!0)),i=l+r[0].length}return s+=n.slice(i),Su(s)}function Ca(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString()}function os(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0)return"just now";const n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const s=Math.round(n/60);if(s<60)return`${s}m ago`;const i=Math.round(s/60);return i<48?`${i}h ago`:`${Math.round(i/24)}d ago`}function _a(e){if(!e&&e!==0)return"n/a";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const s=Math.round(n/60);return s<48?`${s}h`:`${Math.round(s/24)}d`}function xu(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Ma(e,t){return e.length<=t?{text:e,truncated:!1,total:e.length}:{text:e.slice(0,Math.max(0,t)),truncated:!0,total:e.length}}function zn(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Ps(e){return Au(e)}const $u=/^\[([^\]]+)\]\s*/,Eu=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Ls=new WeakMap,Rs=new WeakMap;function Tu(e){return/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}Z\b/.test(e)||/\d{4}-\d{2}-\d{2} \d{2}:\d{2}\b/.test(e)?!0:Eu.some(t=>e.startsWith(`${t} `))}function Is(e){const t=e.match($u);if(!t)return e;const n=t[1]??"";return Tu(n)?e.slice(t[0].length):e}function jn(e){const t=e,n=typeof t.role=="string"?t.role:"",s=t.content;if(typeof s=="string")return n==="assistant"?Ps(s):Is(s);if(Array.isArray(s)){const i=s.map(o=>{const r=o;return r.type==="text"&&typeof r.text=="string"?r.text:null}).filter(o=>typeof o=="string");if(i.length>0){const o=i.join(`
4
- `);return n==="assistant"?Ps(o):Is(o)}}return typeof t.text=="string"?n==="assistant"?Ps(t.text):Is(t.text):null}function Pa(e){if(!e||typeof e!="object")return jn(e);const t=e;if(Ls.has(t))return Ls.get(t)??null;const n=jn(e);return Ls.set(t,n),n}function or(e){const n=e.content,s=[];if(Array.isArray(n))for(const l of n){const a=l;if(a.type==="thinking"&&typeof a.thinking=="string"){const c=a.thinking.trim();c&&s.push(c)}}if(s.length>0)return s.join(`
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Jo=/'/g,er=/"/g,Sa=/^(?:script|style|textarea|title)$/i,tu=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),d=tu(1),Ne=Symbol.for("lit-noChange"),b=Symbol.for("lit-nothing"),tr=new WeakMap,qe=Ve.createTreeWalker(Ve,129);function Aa(e,t){if(!Bi(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Yo!==void 0?Yo.createHTML(t):t}const nu=(e,t)=>{const n=e.length-1,s=[];let i,o=t===2?"<svg>":t===3?"<math>":"",r=Mt;for(let l=0;l<n;l++){const a=e[l];let c,u,p=-1,m=0;for(;m<a.length&&(r.lastIndex=m,u=r.exec(a),u!==null);)m=r.lastIndex,r===Mt?u[1]==="!--"?r=Xo:u[1]!==void 0?r=Zo:u[2]!==void 0?(Sa.test(u[2])&&(i=RegExp("</"+u[2],"g")),r=ze):u[3]!==void 0&&(r=ze):r===ze?u[0]===">"?(r=i??Mt,p=-1):u[1]===void 0?p=-2:(p=r.lastIndex-u[2].length,c=u[1],r=u[3]===void 0?ze:u[3]==='"'?er:Jo):r===er||r===Jo?r=ze:r===Xo||r===Zo?r=Mt:(r=ze,i=void 0);const v=r===ze&&e[l+1].startsWith("/>")?" ":"";o+=r===Mt?a+Jc:p>=0?(s.push(c),a.slice(0,p)+wa+a.slice(p)+Re+v):a+Re+(p===-2?l:v)}return[Aa(e,o+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};let ri=class xa{constructor({strings:t,_$litType$:n},s){let i;this.parts=[];let o=0,r=0;const l=t.length-1,a=this.parts,[c,u]=nu(t,n);if(this.el=xa.createElement(c,s),qe.currentNode=this.el.content,n===2||n===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=qe.nextNode())!==null&&a.length<l;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(wa)){const m=u[r++],v=i.getAttribute(p).split(Re),w=/([.?@])?(.*)/.exec(m);a.push({type:1,index:o,name:w[2],strings:v,ctor:w[1]==="."?iu:w[1]==="?"?ou:w[1]==="@"?ru:ss}),i.removeAttribute(p)}else p.startsWith(Re)&&(a.push({type:6,index:o}),i.removeAttribute(p));if(Sa.test(i.tagName)){const p=i.textContent.split(Re),m=p.length-1;if(m>0){i.textContent=Un?Un.emptyScript:"";for(let v=0;v<m;v++)i.append(p[v],Yt()),qe.nextNode(),a.push({type:2,index:++o});i.append(p[m],Yt())}}}else if(i.nodeType===8)if(i.data===ka)a.push({type:2,index:o});else{let p=-1;for(;(p=i.data.indexOf(Re,p+1))!==-1;)a.push({type:7,index:o}),p+=Re.length-1}o++}}static createElement(t,n){const s=Ve.createElement("template");return s.innerHTML=t,s}};function vt(e,t,n=e,s){if(t===Ne)return t;let i=s!==void 0?n._$Co?.[s]:n._$Cl;const o=Xt(t)?void 0:t._$litDirective$;return i?.constructor!==o&&(i?._$AO?.(!1),o===void 0?i=void 0:(i=new o(e),i._$AT(e,n,s)),s!==void 0?(n._$Co??=[])[s]=i:n._$Cl=i),i!==void 0&&(t=vt(e,i._$AS(e,t.values),i,s)),t}class su{constructor(t,n){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:n},parts:s}=this._$AD,i=(t?.creationScope??Ve).importNode(n,!0);qe.currentNode=i;let o=qe.nextNode(),r=0,l=0,a=s[0];for(;a!==void 0;){if(r===a.index){let c;a.type===2?c=new ns(o,o.nextSibling,this,t):a.type===1?c=new a.ctor(o,a.name,a.strings,this,t):a.type===6&&(c=new au(o,this,t)),this._$AV.push(c),a=s[++l]}r!==a?.index&&(o=qe.nextNode(),r++)}return qe.currentNode=Ve,i}p(t){let n=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,n),n+=s.strings.length-2):s._$AI(t[n])),n++}}let ns=class $a{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,n,s,i){this.type=2,this._$AH=b,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&t?.nodeType===11&&(t=n.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,n=this){t=vt(this,t,n),Xt(t)?t===b||t==null||t===""?(this._$AH!==b&&this._$AR(),this._$AH=b):t!==this._$AH&&t!==Ne&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):eu(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==b&&Xt(this._$AH)?this._$AA.nextSibling.data=t:this.T(Ve.createTextNode(t)),this._$AH=t}$(t){const{values:n,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=ri.createElement(Aa(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(n);else{const o=new su(i,this),r=o.u(this.options);o.p(n),this.T(r),this._$AH=o}}_$AC(t){let n=tr.get(t.strings);return n===void 0&&tr.set(t.strings,n=new ri(t)),n}k(t){Bi(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let s,i=0;for(const o of t)i===n.length?n.push(s=new $a(this.O(Yt()),this.O(Yt()),this,this.options)):s=n[i],s._$AI(o),i++;i<n.length&&(this._$AR(s&&s._$AB.nextSibling,i),n.length=i)}_$AR(t=this._$AA.nextSibling,n){for(this._$AP?.(!1,!0,n);t!==this._$AB;){const s=Qo(t).nextSibling;Qo(t).remove(),t=s}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}};class ss{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,s,i,o){this.type=1,this._$AH=b,this._$AN=void 0,this.element=t,this.name=n,this._$AM=i,this.options=o,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=b}_$AI(t,n=this,s,i){const o=this.strings;let r=!1;if(o===void 0)t=vt(this,t,n,0),r=!Xt(t)||t!==this._$AH&&t!==Ne,r&&(this._$AH=t);else{const l=t;let a,c;for(t=o[0],a=0;a<o.length-1;a++)c=vt(this,l[s+a],n,a),c===Ne&&(c=this._$AH[a]),r||=!Xt(c)||c!==this._$AH[a],c===b?t=b:t!==b&&(t+=(c??"")+o[a+1]),this._$AH[a]=c}r&&!i&&this.j(t)}j(t){t===b?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let iu=class extends ss{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===b?void 0:t}},ou=class extends ss{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==b)}},ru=class extends ss{constructor(t,n,s,i,o){super(t,n,s,i,o),this.type=5}_$AI(t,n=this){if((t=vt(this,t,n,0)??b)===Ne)return;const s=this._$AH,i=t===b&&s!==b||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,o=t!==b&&(s===b||i);i&&this.element.removeEventListener(this.name,this,s),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},au=class{constructor(t,n,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){vt(this,t)}};const lu={I:ns},cu=Di.litHtmlPolyfillSupport;cu?.(ri,ns),(Di.litHtmlVersions??=[]).push("3.3.2");const uu=(e,t,n)=>{const s=n?.renderBefore??t;let i=s._$litPart$;if(i===void 0){const o=n?.renderBefore??null;s._$litPart$=i=new ns(t.insertBefore(Yt(),o),o,void 0,n??{})}return i._$AI(e),i};const Fi=globalThis;let mt=class extends pt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=uu(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Ne}};mt._$litElement$=!0,mt.finalized=!0,Fi.litElementHydrateSupport?.({LitElement:mt});const du=Fi.litElementPolyfillSupport;du?.({LitElement:mt});(Fi.litElementVersions??=[]).push("4.2.2");const Ea=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const pu={attribute:!0,type:String,converter:Fn,reflect:!1,hasChanged:Oi},hu=(e=pu,t,n)=>{const{kind:s,metadata:i}=n;let o=globalThis.litPropertyMetadata.get(i);if(o===void 0&&globalThis.litPropertyMetadata.set(i,o=new Map),s==="setter"&&((e=Object.create(e)).wrapped=!0),o.set(n.name,e),s==="accessor"){const{name:r}=n;return{set(l){const a=t.get.call(this);t.set.call(this,l),this.requestUpdate(r,a,e,!0,l)},init(l){return l!==void 0&&this.C(r,void 0,e,l),l}}}if(s==="setter"){const{name:r}=n;return function(l){const a=this[r];t.call(this,l),this.requestUpdate(r,a,e,!0,l)}}throw Error("Unsupported decorator location: "+s)};function is(e){return(t,n)=>typeof n=="object"?hu(e,t,n):((s,i,o)=>{const r=i.hasOwnProperty(o);return i.constructor.createProperty(o,s),r?Object.getOwnPropertyDescriptor(i,o):void 0})(e,t,n)}function g(e){return is({...e,state:!0,attribute:!1})}const fu=50,gu=200,mu="Assistant";function nr(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function ai(e){const t=nr(e?.name,fu)??mu,n=nr(e?.avatar??void 0,gu)??null;return{agentId:typeof e?.agentId=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function yu(){return ai(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const Wn="taskmaster.control.settings.v1",Ta="taskmaster.account.settings.";function Ht(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const dt={gatewayUrl:Ht(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},Le={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function vu(){try{const e=localStorage.getItem(Wn);if(!e)return{...dt,gatewayUrl:Ht()};const t=JSON.parse(e);return{gatewayUrl:typeof t.gatewayUrl=="string"&&t.gatewayUrl.trim()?t.gatewayUrl.trim():Ht(),token:typeof t.token=="string"?t.token:dt.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:dt.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:dt.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:dt.navGroupsCollapsed}}catch{return{...dt,gatewayUrl:Ht()}}}function bu(e){if(!e)return{...Le};try{const t=localStorage.getItem(Ta+e);if(!t)return{...Le};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():Le.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||Le.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:Le.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:Le.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:Le.splitRatio}}catch{return{...Le}}}let Kn=null;function sr(e){Kn=e}function Ms(){return{...vu(),...bu(Kn)}}function wu(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(Wn,JSON.stringify(t)),Kn){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(Ta+Kn,JSON.stringify(n))}}(function(){try{const t=localStorage.getItem(Wn);if(!t)return;const n=JSON.parse(t);if(!("sessionKey"in n))return;const s={gatewayUrl:typeof n.gatewayUrl=="string"?n.gatewayUrl:Ht(),token:typeof n.token=="string"?n.token:"",theme:n.theme==="light"||n.theme==="dark"||n.theme==="system"?n.theme:"system",navCollapsed:typeof n.navCollapsed=="boolean"?n.navCollapsed:!1,navGroupsCollapsed:typeof n.navGroupsCollapsed=="object"&&n.navGroupsCollapsed!==null?n.navGroupsCollapsed:{}};localStorage.setItem(Wn,JSON.stringify(s))}catch{}})();function Ca(e){const t=(e??"").trim();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const s=n[1]?.trim(),i=n.slice(2).join(":");return!s||!i?null:{agentId:s,rest:i}}const ku=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,bn=/<\s*\/?\s*final\b[^>]*>/gi,ir=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function Su(e,t){return e.trimStart()}function Au(e,t){if(!e||!ku.test(e))return e;let n=e;bn.test(n)?(bn.lastIndex=0,n=n.replace(bn,"")):bn.lastIndex=0,ir.lastIndex=0;let s="",i=0,o=!1;for(const r of n.matchAll(ir)){const l=r.index??0,a=r[1]==="/";o?a&&(o=!1):(s+=n.slice(i,l),a||(o=!0)),i=l+r[0].length}return s+=n.slice(i),Su(s)}function _a(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString()}function os(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0)return"just now";const n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const s=Math.round(n/60);if(s<60)return`${s}m ago`;const i=Math.round(s/60);return i<48?`${i}h ago`:`${Math.round(i/24)}d ago`}function Ma(e){if(!e&&e!==0)return"n/a";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const s=Math.round(n/60);return s<48?`${s}h`:`${Math.round(s/24)}d`}function xu(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Pa(e,t){return e.length<=t?{text:e,truncated:!1,total:e.length}:{text:e.slice(0,Math.max(0,t)),truncated:!0,total:e.length}}function zn(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Ps(e){return Au(e)}const $u=/^\[([^\]]+)\]\s*/,Eu=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Ls=new WeakMap,Rs=new WeakMap;function Tu(e){return/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}Z\b/.test(e)||/\d{4}-\d{2}-\d{2} \d{2}:\d{2}\b/.test(e)?!0:Eu.some(t=>e.startsWith(`${t} `))}function Is(e){const t=e.match($u);if(!t)return e;const n=t[1]??"";return Tu(n)?e.slice(t[0].length):e}function jn(e){const t=e,n=typeof t.role=="string"?t.role:"",s=t.content;if(typeof s=="string")return n==="assistant"?Ps(s):Is(s);if(Array.isArray(s)){const i=s.map(o=>{const r=o;return r.type==="text"&&typeof r.text=="string"?r.text:null}).filter(o=>typeof o=="string");if(i.length>0){const o=i.join(`
4
+ `);return n==="assistant"?Ps(o):Is(o)}}return typeof t.text=="string"?n==="assistant"?Ps(t.text):Is(t.text):null}function La(e){if(!e||typeof e!="object")return jn(e);const t=e;if(Ls.has(t))return Ls.get(t)??null;const n=jn(e);return Ls.set(t,n),n}function or(e){const n=e.content,s=[];if(Array.isArray(n))for(const l of n){const a=l;if(a.type==="thinking"&&typeof a.thinking=="string"){const c=a.thinking.trim();c&&s.push(c)}}if(s.length>0)return s.join(`
5
5
  `);const i=_u(e);if(!i)return null;const r=[...i.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(l=>(l[1]??"").trim()).filter(Boolean);return r.length>0?r.join(`
6
6
  `):null}function Cu(e){if(!e||typeof e!="object")return or(e);const t=e;if(Rs.has(t))return Rs.get(t)??null;const n=or(e);return Rs.set(t,n),n}function _u(e){const t=e,n=t.content;if(typeof n=="string")return n;if(Array.isArray(n)){const s=n.map(i=>{const o=i;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(i=>typeof i=="string");if(s.length>0)return s.join(`
7
7
  `)}return typeof t.text=="string"?t.text:null}function Mu(e){const t=e.trim();if(!t)return"";const n=t.split(/\r?\n/).map(s=>s.trim()).filter(Boolean).map(s=>`_${s}_`);return n.length?["_Reasoning:_",...n].join(`
8
- `):""}const Pu=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,Lu=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,Ru=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,Iu=/^A new session was started via \/new or \/reset\./;function Nu(e){const t=e,n=typeof t.role=="string"?t.role:"";let s="";typeof t.content=="string"?s=t.content:Array.isArray(t.content)?s=t.content.filter(o=>typeof o=="object"&&o!==null).map(o=>o.text??"").join(" "):typeof t.text=="string"&&(s=t.text);const i=s.trim();return i?!!(n==="user"&&Pu.test(i)||n==="assistant"&&Lu.test(i)||n==="user"&&Iu.test(i)||n==="assistant"&&Ru.test(i)):!1}function Ou(e){return e.filter(t=>!Nu(t))}function La(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const s=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",i=t.content,o=Array.isArray(i)?i:null,r=Array.isArray(o)&&o.some(p=>{const v=String(p.type??"").toLowerCase();return v==="toolresult"||v==="tool_result"}),l=typeof t.toolName=="string"||typeof t.tool_name=="string";(s||r||l)&&(n="toolResult");let a=[];typeof t.content=="string"?a=[{type:"text",text:t.content}]:Array.isArray(t.content)?a=t.content.map(p=>({type:p.type||"text",text:p.text,name:p.name,args:p.args||p.arguments})):typeof t.text=="string"&&(a=[{type:"text",text:t.text}]);const c=typeof t.timestamp=="number"?t.timestamp:Date.now(),u=typeof t.id=="string"?t.id:void 0;return{role:n,content:a,timestamp:c,id:u}}function Ra(e){const t=e.toLowerCase();return e==="user"||e==="User"?e:e==="assistant"?"assistant":e==="system"?"system":t==="toolresult"||t==="tool_result"||t==="tool"||t==="function"?"tool":e}function Ia(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function rr(e){e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,"0");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Du(){const e=new Uint8Array(16),t=Date.now();for(let n=0;n<e.length;n++)e[n]=Math.floor(Math.random()*256);return e[0]^=t&255,e[1]^=t>>>8&255,e[2]^=t>>>16&255,e[3]^=t>>>24&255,e}function Ui(e=globalThis.crypto){if(e&&typeof e.randomUUID=="function")return e.randomUUID();if(e&&typeof e.getRandomValues=="function"){const t=new Uint8Array(16);return e.getRandomValues(t),rr(t)}return rr(Du())}async function Ce(e){if(!(!e.client||!e.connected)){e.chatLoading=!0,e.lastError=null;try{const t=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:200}),n=Array.isArray(t.messages)?t.messages:[];e.chatMessages=Ou(n),e.chatThinkingLevel=t.thinkingLevel??null,e.chatModelProvider=typeof t.modelProvider=="string"?t.modelProvider:null,e.chatModel=typeof t.model=="string"?t.model:null,e.chatVerboseLevel=typeof t.verboseLevel=="string"?t.verboseLevel:null,e.chatFillerEnabled=typeof t.fillerEnabled=="boolean"?t.fillerEnabled:null}catch(t){e.lastError=String(t)}finally{e.chatLoading=!1}}}function Bu(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function Na(e,t,n){if(!e.client||!e.connected)return!1;const s=t.trim(),i=n&&n.length>0;if(!s&&!i)return!1;const o=Date.now(),r=(n??[]).filter(v=>!v.fileName),l=(n??[]).filter(v=>v.fileName),a=[],c=l.map(v=>v.fileName).filter(Boolean);if(c.length>0){const v=s?`${c.join(", ")}
8
+ `):""}const Pu=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,Lu=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,Ru=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,Iu=/^A new session was started via \/new or \/reset\./;function Nu(e){const t=e,n=typeof t.role=="string"?t.role:"";let s="";typeof t.content=="string"?s=t.content:Array.isArray(t.content)?s=t.content.filter(o=>typeof o=="object"&&o!==null).map(o=>o.text??"").join(" "):typeof t.text=="string"&&(s=t.text);const i=s.trim();return i?!!(n==="user"&&Pu.test(i)||n==="assistant"&&Lu.test(i)||n==="user"&&Iu.test(i)||n==="assistant"&&Ru.test(i)):!1}function Ou(e){return e.filter(t=>!Nu(t))}function Ra(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const s=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",i=t.content,o=Array.isArray(i)?i:null,r=Array.isArray(o)&&o.some(p=>{const v=String(p.type??"").toLowerCase();return v==="toolresult"||v==="tool_result"}),l=typeof t.toolName=="string"||typeof t.tool_name=="string";(s||r||l)&&(n="toolResult");let a=[];typeof t.content=="string"?a=[{type:"text",text:t.content}]:Array.isArray(t.content)?a=t.content.map(p=>({type:p.type||"text",text:p.text,name:p.name,args:p.args||p.arguments})):typeof t.text=="string"&&(a=[{type:"text",text:t.text}]);const c=typeof t.timestamp=="number"?t.timestamp:Date.now(),u=typeof t.id=="string"?t.id:void 0;return{role:n,content:a,timestamp:c,id:u}}function Ia(e){const t=e.toLowerCase();return e==="user"||e==="User"?e:e==="assistant"?"assistant":e==="system"?"system":t==="toolresult"||t==="tool_result"||t==="tool"||t==="function"?"tool":e}function Na(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function rr(e){e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,"0");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Du(){const e=new Uint8Array(16),t=Date.now();for(let n=0;n<e.length;n++)e[n]=Math.floor(Math.random()*256);return e[0]^=t&255,e[1]^=t>>>8&255,e[2]^=t>>>16&255,e[3]^=t>>>24&255,e}function Ui(e=globalThis.crypto){if(e&&typeof e.randomUUID=="function")return e.randomUUID();if(e&&typeof e.getRandomValues=="function"){const t=new Uint8Array(16);return e.getRandomValues(t),rr(t)}return rr(Du())}async function Ce(e){if(!(!e.client||!e.connected)){e.chatLoading=!0,e.lastError=null;try{const t=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:200}),n=Array.isArray(t.messages)?t.messages:[];e.chatMessages=Ou(n),e.chatThinkingLevel=t.thinkingLevel??null,e.chatModelProvider=typeof t.modelProvider=="string"?t.modelProvider:null,e.chatModel=typeof t.model=="string"?t.model:null,e.chatVerboseLevel=typeof t.verboseLevel=="string"?t.verboseLevel:null,e.chatFillerEnabled=typeof t.fillerEnabled=="boolean"?t.fillerEnabled:null}catch(t){e.lastError=String(t)}finally{e.chatLoading=!1}}}function Bu(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function Oa(e,t,n){if(!e.client||!e.connected)return!1;const s=t.trim(),i=n&&n.length>0;if(!s&&!i)return!1;const o=Date.now(),r=(n??[]).filter(v=>!v.fileName),l=(n??[]).filter(v=>v.fileName),a=[],c=l.map(v=>v.fileName).filter(Boolean);if(c.length>0){const v=s?`${c.join(", ")}
9
9
 
10
- ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text:s});for(const v of r)a.push({type:"image",source:{type:"base64",media_type:v.mimeType,data:v.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:a,timestamp:o}],e.chatSending=!0,e.lastError=null;const u=Ui();e.chatRunId=u,e.chatStream="",e.chatStreamStartedAt=o;const p=[...r,...l],m=p.length>0?p.map(v=>{if(v.textContent)return{type:"document",mimeType:v.mimeType||"text/plain",fileName:v.fileName,content:btoa(unescape(encodeURIComponent(v.textContent)))};const w=Bu(v.dataUrl);return w?{type:v.fileName?"document":"image",mimeType:w.mimeType,fileName:v.fileName,content:w.content}:null}).filter(v=>v!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:s,deliver:!1,idempotencyKey:u,attachments:m}),!0}catch(v){const w=String(v);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=w,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+w}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function Oa(e){if(!e.client||!e.connected)return!1;const t=e.chatRunId;try{return await e.client.request("chat.abort",t?{sessionKey:e.sessionKey,runId:t}:{sessionKey:e.sessionKey}),!0}catch(n){return e.lastError=String(n),!1}}function Da(e,t){if(!t||t.sessionKey!==e.sessionKey)return null;if(t.runId&&e.chatRunId&&t.runId!==e.chatRunId)return t.state==="final"?"final":null;if(t.state==="block"){const n=jn(t.message);return typeof n=="string"&&n.trim()&&(e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:n.trim()}],timestamp:Date.now(),filler:!0}]),"block"}else if(t.state==="delta"){const n=jn(t.message);if(typeof n=="string"){if(n.trim()==="NO_REPLY")return null;const s=e.chatStream??"";(!s||n.length>=s.length)&&(e.chatStream=n)}}else t.state==="final"||t.state==="aborted"?(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null):t.state==="error"&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.lastError=t.errorMessage??"chat error");return t.state}const Fu=Object.freeze(Object.defineProperty({__proto__:null,abortChatRun:Oa,handleChatEvent:Da,loadChatHistory:Ce,sendChatMessage:Na},Symbol.toStringTag,{value:"Module"}));async function Wi(e){if(!(!e.client||!e.connected)&&!e.sessionsLoading){e.sessionsLoading=!0,e.sessionsError=null;try{const t={includeGlobal:e.sessionsIncludeGlobal??!0,includeUnknown:e.sessionsIncludeUnknown??!1},n=zn(e.sessionsFilterActive??"",0),s=zn(e.sessionsFilterLimit??"",0);n>0&&(t.activeMinutes=n),s>0&&(t.limit=s);const i=await e.client.request("sessions.list",t);i&&(e.sessionsResult=i)}catch(t){e.sessionsError=String(t)}finally{e.sessionsLoading=!1}}}async function wn(e,t,n){if(!e.client||!e.connected)return;const s={key:t};"label"in n&&(s.label=n.label),"thinkingLevel"in n&&(s.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(s.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(s.reasoningLevel=n.reasoningLevel),"model"in n&&(s.model=n.model),"fillerEnabled"in n&&(s.fillerEnabled=n.fillerEnabled);try{await e.client.request("sessions.patch",s),await Wi(e)}catch(i){e.sessionsError=String(i)}}const ar=50,Uu=80,Wu=12e4;function Ku(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.text=="string")return t.text;const n=t.content;if(!Array.isArray(n))return null;const s=n.map(i=>{if(!i||typeof i!="object")return null;const o=i;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(i=>!!i);return s.length===0?null:s.join(`
11
- `)}function lr(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=Ku(e);let n;if(typeof e=="string")n=e;else if(t)n=t;else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}const s=Ma(n,Wu);return s.truncated?`${s.text}
10
+ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text:s});for(const v of r)a.push({type:"image",source:{type:"base64",media_type:v.mimeType,data:v.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:a,timestamp:o}],e.chatSending=!0,e.lastError=null;const u=Ui();e.chatRunId=u,e.chatStream="",e.chatStreamStartedAt=o;const p=[...r,...l],m=p.length>0?p.map(v=>{if(v.textContent)return{type:"document",mimeType:v.mimeType||"text/plain",fileName:v.fileName,content:btoa(unescape(encodeURIComponent(v.textContent)))};const w=Bu(v.dataUrl);return w?{type:v.fileName?"document":"image",mimeType:w.mimeType,fileName:v.fileName,content:w.content}:null}).filter(v=>v!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:s,deliver:!1,idempotencyKey:u,attachments:m}),!0}catch(v){const w=String(v);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=w,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+w}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function Da(e){if(!e.client||!e.connected)return!1;const t=e.chatRunId;try{return await e.client.request("chat.abort",t?{sessionKey:e.sessionKey,runId:t}:{sessionKey:e.sessionKey}),!0}catch(n){return e.lastError=String(n),!1}}function Ba(e,t){if(!t||t.sessionKey!==e.sessionKey)return null;if(t.runId&&e.chatRunId&&t.runId!==e.chatRunId)return t.state==="final"?"final":null;if(t.state==="block"){const n=jn(t.message);return typeof n=="string"&&n.trim()&&(e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:n.trim()}],timestamp:Date.now(),filler:!0}]),"block"}else if(t.state==="delta"){const n=jn(t.message);if(typeof n=="string"){if(n.trim()==="NO_REPLY")return null;const s=e.chatStream??"";(!s||n.length>=s.length)&&(e.chatStream=n)}}else t.state==="final"||t.state==="aborted"?(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null):t.state==="error"&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.lastError=t.errorMessage??"chat error");return t.state}const Fu=Object.freeze(Object.defineProperty({__proto__:null,abortChatRun:Da,handleChatEvent:Ba,loadChatHistory:Ce,sendChatMessage:Oa},Symbol.toStringTag,{value:"Module"}));async function Wi(e){if(!(!e.client||!e.connected)&&!e.sessionsLoading){e.sessionsLoading=!0,e.sessionsError=null;try{const t={includeGlobal:e.sessionsIncludeGlobal??!0,includeUnknown:e.sessionsIncludeUnknown??!1},n=zn(e.sessionsFilterActive??"",0),s=zn(e.sessionsFilterLimit??"",0);n>0&&(t.activeMinutes=n),s>0&&(t.limit=s);const i=await e.client.request("sessions.list",t);i&&(e.sessionsResult=i)}catch(t){e.sessionsError=String(t)}finally{e.sessionsLoading=!1}}}async function wn(e,t,n){if(!e.client||!e.connected)return;const s={key:t};"label"in n&&(s.label=n.label),"thinkingLevel"in n&&(s.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(s.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(s.reasoningLevel=n.reasoningLevel),"model"in n&&(s.model=n.model),"fillerEnabled"in n&&(s.fillerEnabled=n.fillerEnabled);try{await e.client.request("sessions.patch",s),await Wi(e)}catch(i){e.sessionsError=String(i)}}const ar=50,Uu=80,Wu=12e4;function Ku(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.text=="string")return t.text;const n=t.content;if(!Array.isArray(n))return null;const s=n.map(i=>{if(!i||typeof i!="object")return null;const o=i;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(i=>!!i);return s.length===0?null:s.join(`
11
+ `)}function lr(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=Ku(e);let n;if(typeof e=="string")n=e;else if(t)n=t;else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}const s=Pa(n,Wu);return s.truncated?`${s.text}
12
12
 
13
- … truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function zu(e){const t=[];return t.push({type:"toolcall",name:e.name,arguments:e.args??{}}),e.output&&t.push({type:"toolresult",name:e.name,text:e.output}),{role:"assistant",toolCallId:e.toolCallId,runId:e.runId,content:t,timestamp:e.startedAt}}function ju(e){if(e.toolStreamOrder.length<=ar)return;const t=e.toolStreamOrder.length-ar,n=e.toolStreamOrder.splice(0,t);for(const s of n)e.toolStreamById.delete(s)}function Hu(e){e.chatToolMessages=e.toolStreamOrder.map(t=>e.toolStreamById.get(t)?.message).filter(t=>!!t)}function li(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),Hu(e)}function qu(e,t=!1){if(t){li(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>li(e),Uu))}function Ki(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],li(e)}const Gu=5e3;function Vu(e,t){const n=t.data??{},s=typeof n.phase=="string"?n.phase:"";e.compactionClearTimer!=null&&(window.clearTimeout(e.compactionClearTimer),e.compactionClearTimer=null),s==="start"?e.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null}:s==="end"&&(e.compactionStatus={active:!1,startedAt:e.compactionStatus?.startedAt??null,completedAt:Date.now()},e.compactionClearTimer=window.setTimeout(()=>{e.compactionStatus=null,e.compactionClearTimer=null},Gu))}function Qu(e,t){if(!t)return;if(t.stream==="compaction"){Vu(e,t);return}if(t.stream!=="tool")return;const n=typeof t.sessionKey=="string"?t.sessionKey:void 0;if(n&&n!==e.sessionKey||!n&&e.chatRunId&&t.runId!==e.chatRunId||e.chatRunId&&t.runId!==e.chatRunId||!e.chatRunId)return;const s=t.data??{},i=typeof s.toolCallId=="string"?s.toolCallId:"";if(!i)return;const o=typeof s.name=="string"?s.name:"tool",r=typeof s.phase=="string"?s.phase:"",l=r==="start"?s.args:void 0,a=r==="update"?lr(s.partialResult):r==="result"?lr(s.result):void 0,c=Date.now();let u=e.toolStreamById.get(i);u?(u.name=o,l!==void 0&&(u.args=l),a!==void 0&&(u.output=a),u.updatedAt=c):(u={toolCallId:i,runId:t.runId,sessionKey:n,name:o,args:l,output:a,startedAt:typeof t.ts=="number"?t.ts:c,updatedAt:c,message:{}},e.toolStreamById.set(i,u),e.toolStreamOrder.push(i)),u.message=zu(u),ju(e),qu(e,r==="result")}function en(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=()=>{const s=e.querySelector(".chat-thread");if(s){const i=getComputedStyle(s).overflowY;if(i==="auto"||i==="scroll"||s.scrollHeight-s.clientHeight>1)return s}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{e.chatScrollFrame=requestAnimationFrame(()=>{e.chatScrollFrame=null;const s=n();if(!s)return;const i=s.scrollHeight-s.scrollTop-s.clientHeight;if(!(t||e.chatUserNearBottom||i<200))return;t&&(e.chatHasAutoScrolled=!0),s.scrollTop=s.scrollHeight,e.chatUserNearBottom=!0;const r=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{e.chatScrollTimeout=null;const l=n();if(!l)return;const a=l.scrollHeight-l.scrollTop-l.clientHeight;(t||e.chatUserNearBottom||a<200)&&(l.scrollTop=l.scrollHeight,e.chatUserNearBottom=!0)},r)})})}function Ba(e,t=!1){e.logsScrollFrame&&cancelAnimationFrame(e.logsScrollFrame),e.updateComplete.then(()=>{e.logsScrollFrame=requestAnimationFrame(()=>{e.logsScrollFrame=null;const n=e.querySelector(".log-stream");!n||!(t||n.scrollTop<80)||(n.scrollTop=0)})})}function Yu(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=s<200}function Xu(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function Zu(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function Ju(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function ed(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
13
+ … truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function zu(e){const t=[];return t.push({type:"toolcall",name:e.name,arguments:e.args??{}}),e.output&&t.push({type:"toolresult",name:e.name,text:e.output}),{role:"assistant",toolCallId:e.toolCallId,runId:e.runId,content:t,timestamp:e.startedAt}}function ju(e){if(e.toolStreamOrder.length<=ar)return;const t=e.toolStreamOrder.length-ar,n=e.toolStreamOrder.splice(0,t);for(const s of n)e.toolStreamById.delete(s)}function Hu(e){e.chatToolMessages=e.toolStreamOrder.map(t=>e.toolStreamById.get(t)?.message).filter(t=>!!t)}function li(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),Hu(e)}function qu(e,t=!1){if(t){li(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>li(e),Uu))}function Ki(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],li(e)}const Gu=5e3;function Vu(e,t){const n=t.data??{},s=typeof n.phase=="string"?n.phase:"";e.compactionClearTimer!=null&&(window.clearTimeout(e.compactionClearTimer),e.compactionClearTimer=null),s==="start"?e.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null}:s==="end"&&(e.compactionStatus={active:!1,startedAt:e.compactionStatus?.startedAt??null,completedAt:Date.now()},e.compactionClearTimer=window.setTimeout(()=>{e.compactionStatus=null,e.compactionClearTimer=null},Gu))}function Qu(e,t){if(!t)return;if(t.stream==="compaction"){Vu(e,t);return}if(t.stream!=="tool")return;const n=typeof t.sessionKey=="string"?t.sessionKey:void 0;if(n&&n!==e.sessionKey||!n&&e.chatRunId&&t.runId!==e.chatRunId||e.chatRunId&&t.runId!==e.chatRunId||!e.chatRunId)return;const s=t.data??{},i=typeof s.toolCallId=="string"?s.toolCallId:"";if(!i)return;const o=typeof s.name=="string"?s.name:"tool",r=typeof s.phase=="string"?s.phase:"",l=r==="start"?s.args:void 0,a=r==="update"?lr(s.partialResult):r==="result"?lr(s.result):void 0,c=Date.now();let u=e.toolStreamById.get(i);u?(u.name=o,l!==void 0&&(u.args=l),a!==void 0&&(u.output=a),u.updatedAt=c):(u={toolCallId:i,runId:t.runId,sessionKey:n,name:o,args:l,output:a,startedAt:typeof t.ts=="number"?t.ts:c,updatedAt:c,message:{}},e.toolStreamById.set(i,u),e.toolStreamOrder.push(i)),u.message=zu(u),ju(e),qu(e,r==="result")}function en(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=()=>{const s=e.querySelector(".chat-thread");if(s){const i=getComputedStyle(s).overflowY;if(i==="auto"||i==="scroll"||s.scrollHeight-s.clientHeight>1)return s}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{e.chatScrollFrame=requestAnimationFrame(()=>{e.chatScrollFrame=null;const s=n();if(!s)return;const i=s.scrollHeight-s.scrollTop-s.clientHeight;if(!(t||e.chatUserNearBottom||i<200))return;t&&(e.chatHasAutoScrolled=!0),s.scrollTop=s.scrollHeight,e.chatUserNearBottom=!0;const r=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{e.chatScrollTimeout=null;const l=n();if(!l)return;const a=l.scrollHeight-l.scrollTop-l.clientHeight;(t||e.chatUserNearBottom||a<200)&&(l.scrollTop=l.scrollHeight,e.chatUserNearBottom=!0)},r)})})}function Fa(e,t=!1){e.logsScrollFrame&&cancelAnimationFrame(e.logsScrollFrame),e.updateComplete.then(()=>{e.logsScrollFrame=requestAnimationFrame(()=>{e.logsScrollFrame=null;const n=e.querySelector(".log-stream");!n||!(t||n.scrollTop<80)||(n.scrollTop=0)})})}function Yu(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=s<200}function Xu(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function Zu(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function Ju(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function ed(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
14
14
  `)}
15
15
  `],{type:"text/plain"}),s=URL.createObjectURL(n),i=document.createElement("a"),o=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");i.href=s,i.download=`taskmaster-logs-${t}-${o}.log`,i.click(),URL.revokeObjectURL(s)}function td(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
16
16
  `)}
17
17
  `],{type:"text/plain"}),s=URL.createObjectURL(n),i=document.createElement("a"),o=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");i.href=s,i.download=`taskmaster-session-logs-${t}-${o}.log`,i.click(),URL.revokeObjectURL(s)}function nd(e){if(typeof ResizeObserver>"u")return;const t=e.querySelector(".topbar");if(!t)return;const n=()=>{const{height:s}=t.getBoundingClientRect();e.style.setProperty("--topbar-height",`${s}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}function Oe(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Qe(e){return`${JSON.stringify(e,null,2).trimEnd()}
18
- `}function Fa(e,t,n){if(t.length===0)return;let s=e;for(let o=0;o<t.length-1;o+=1){const r=t[o],l=t[o+1];if(typeof r=="number"){if(!Array.isArray(s))return;s[r]==null&&(s[r]=typeof l=="number"?[]:{}),s=s[r]}else{if(typeof s!="object"||s==null)return;const a=s;a[r]==null&&(a[r]=typeof l=="number"?[]:{}),s=a[r]}}const i=t[t.length-1];if(typeof i=="number"){Array.isArray(s)&&(s[i]=n);return}typeof s=="object"&&s!=null&&(s[i]=n)}async function we(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});id(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function Ua(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});sd(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function sd(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function id(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?Qe(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=Qe(e.configForm):e.configRaw=n,e.configValid=typeof t.valid=="boolean"?t.valid:null,e.configIssues=Array.isArray(t.issues)?t.issues:[],e.configFormDirty||(e.configForm=Oe(t.config??{}),e.configFormOriginal=Oe(t.config??{}),e.configRawOriginal=n)}async function od(e){if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const t=e.configFormMode==="form"&&e.configForm?Qe(e.configForm):e.configRaw,n=e.configSnapshot?.hash;if(!n){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:t,baseHash:n}),e.configFormDirty=!1,await we(e)}catch(t){e.lastError=String(t)}finally{e.configSaving=!1}}}async function tn(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("cron.status",{});e.cronStatus=t}catch(t){e.cronError=String(t)}}async function rs(e){if(!(!e.client||!e.connected)&&!e.cronLoading){e.cronLoading=!0,e.cronError=null;try{const t={includeDisabled:!0};Array.isArray(e.workspaceAgentIds)&&e.workspaceAgentIds.length>0&&(t.agentIds=e.workspaceAgentIds);const n=await e.client.request("cron.list",t);e.cronJobs=Array.isArray(n.jobs)?n.jobs:[]}catch(t){e.cronError=String(t)}finally{e.cronLoading=!1}}}function rd(e){if(e.scheduleKind==="at"){const n=Date.parse(e.scheduleAt);if(!Number.isFinite(n))throw new Error("Invalid run time.");return{kind:"at",atMs:n}}if(e.scheduleKind==="every"){const n=zn(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const s=e.everyUnit;return{kind:"every",everyMs:n*(s==="minutes"?6e4:s==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function ad(e){if(e.payloadKind==="systemEvent"){const i=e.payloadText.trim();if(!i)throw new Error("System event text required.");return{kind:"systemEvent",text:i}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t};e.deliver&&(n.deliver=!0),e.channel&&(n.channel=e.channel),e.to.trim()&&(n.to=e.to.trim());const s=zn(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function ld(e){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const t=rd(e.cronForm),n=ad(e.cronForm),s=e.cronForm.agentId.trim(),i=e.cronForm.accountId?.trim(),o={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,accountId:i||void 0,enabled:e.cronForm.enabled,schedule:t,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:n,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!o.name)throw new Error("Name required.");await e.client.request("cron.add",o),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await rs(e),await tn(e)}catch(t){e.cronError=String(t)}finally{e.cronBusy=!1}}}async function cd(e,t,n){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.update",{id:t.id,patch:{enabled:n}}),await rs(e),await tn(e)}catch(s){e.cronError=String(s)}finally{e.cronBusy=!1}}}async function ud(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await ci(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function dd(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.remove",{id:t.id}),e.cronRunsJobId===t.id&&(e.cronRunsJobId=null,e.cronRuns=[]),await rs(e),await tn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function ci(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("cron.runs",{id:t,limit:50});e.cronRunsJobId=t,e.cronRuns=Array.isArray(n.entries)?n.entries:[]}catch(n){e.cronError=String(n)}}async function z(e,t){if(!(!e.client||!e.connected)&&!e.channelsLoading){e.channelsLoading=!0,e.channelsError=null;try{const n=await e.client.request("channels.status",{probe:t,timeoutMs:8e3});e.channelsSnapshot=n,e.channelsLastSuccess=Date.now()}catch(n){e.channelsError=String(n)}finally{e.channelsLoading=!1}}}async function zi(e,t,n){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0,e.whatsappActiveQrAccountId=n??null;try{const s=await e.client.request("web.login.start",{force:t,timeoutMs:3e4,accountId:n});e.whatsappLoginMessage=s.message??null,e.whatsappLoginQrDataUrl=s.qrDataUrl??null,e.whatsappLoginConnected=null}catch(s){e.whatsappLoginMessage=String(s),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function Wa(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{const n=await e.client.request("web.login.wait",{timeoutMs:12e4,accountId:t});e.whatsappLoginMessage=n.message??null,e.whatsappLoginConnected=n.connected??null,n.connected&&(e.whatsappLoginQrDataUrl=null,e.whatsappActiveQrAccountId=null,e.whatsappPairedPhone=n.selfPhone??null)}catch(n){e.whatsappLoginMessage=String(n),e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function Ka(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t}),e.whatsappLoginMessage="Logged out.",e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null}catch(n){e.whatsappLoginMessage=String(n)}finally{e.whatsappBusy=!1}}}async function za(e,t){if(!e.client||!e.connected||e.whatsappAccountSaving)return;const n=t.trim();if(!n){e.whatsappAccountError="Account name is required.";return}const s=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");if(!s){e.whatsappAccountError="Invalid account name.";return}e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const i=await e.client.request("config.get",{});e.configSnapshot=i;const o=Oe(i.config??{});(!o.channels||typeof o.channels!="object")&&(o.channels={});const r=o.channels;(!r.whatsapp||typeof r.whatsapp!="object")&&(r.whatsapp={});const l=r.whatsapp;(!l.accounts||typeof l.accounts!="object")&&(l.accounts={});const a=l.accounts;if(a[s]){e.whatsappAccountError=`Account "${s}" already exists.`;return}a[s]={name:n,provider:"baileys"};const c=i.hash;if(!c){e.whatsappAccountError="Config hash missing; reload and retry.";return}const u=Qe(o);await e.client.request("config.set",{raw:u,baseHash:c}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await z(e,!0),await zi(e,!0,s)}catch(i){e.whatsappAccountError=String(i)}finally{e.whatsappAccountSaving=!1}}async function ja(e,t){if(!(!e.client||!e.connected)&&!e.whatsappAccountSaving){e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const s=Oe(n.config??{}),r=s.channels?.whatsapp?.accounts;if(!r){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(r).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!r[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete r[t],Array.isArray(s.bindings)&&(s.bindings=s.bindings.filter(u=>{const p=u.match;return!p||p.channel!=="whatsapp"?!0:p.accountId!==t}));const a=n.hash;if(!a){e.whatsappAccountError="Config hash missing; reload and retry.";return}const c=Qe(s);await e.client.request("config.set",{raw:c,baseHash:a}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await z(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const pd=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:za,loadChannels:z,logoutWhatsApp:Ka,removeWhatsAppAccount:ja,startWhatsAppLogin:zi,waitWhatsAppLogin:Wa},Symbol.toStringTag,{value:"Module"}));async function ji(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,s,i]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const o=s;e.debugModels=Array.isArray(o?.models)?o?.models:[],e.debugHeartbeat=i}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}const hd=2e3,fd=new Set(["trace","debug","info","warn","error","fatal"]);function gd(e){if(typeof e!="string")return null;const t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;try{const n=JSON.parse(t);return!n||typeof n!="object"?null:n}catch{return null}}function md(e){if(typeof e!="string")return null;const t=e.toLowerCase();return fd.has(t)?t:null}function yd(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,s=typeof t.time=="string"?t.time:typeof n?.date=="string"?n?.date:null,i=md(n?.logLevelName??n?.level),o=typeof t[0]=="string"?t[0]:typeof n?.name=="string"?n?.name:null,r=gd(o);let l=null;r&&(typeof r.subsystem=="string"?l=r.subsystem:typeof r.module=="string"&&(l=r.module)),!l&&o&&o.length<120&&(l=o);let a=null;return typeof t[1]=="string"?a=t[1]:!r&&typeof t[0]=="string"?a=t[0]:typeof t.message=="string"&&(a=t.message),{raw:e,time:s,level:i,subsystem:l,message:a??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function qt(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!t?.quiet)){t?.quiet||(e.logsLoading=!0),e.logsError=null;try{const s=await e.client.request("logs.tail",{cursor:t?.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),o=(Array.isArray(s.lines)?s.lines.filter(l=>typeof l=="string"):[]).map(yd),r=!!(t?.reset||s.reset||e.logsCursor==null);e.logsEntries=r?o:[...e.logsEntries,...o].slice(-hd),typeof s.cursor=="number"&&(e.logsCursor=s.cursor),typeof s.file=="string"&&(e.logsFile=s.file),e.logsTruncated=!!s.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t?.quiet||(e.logsLoading=!1)}}}const Ha={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:ee,n:In,Gx:cr,Gy:ur,a:Ns,d:Os,h:vd}=Ha,Ye=32,Hi=64,bd=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},Q=(e="")=>{const t=new Error(e);throw bd(t,Q),t},wd=e=>typeof e=="bigint",kd=e=>typeof e=="string",Sd=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",Be=(e,t,n="")=>{const s=Sd(e),i=e?.length,o=t!==void 0;if(!s||o&&i!==t){const r=n&&`"${n}" `,l=o?` of length ${t}`:"",a=s?`length=${i}`:`type=${typeof e}`;Q(r+"expected Uint8Array"+l+", got "+a)}return e},as=e=>new Uint8Array(e),qa=e=>Uint8Array.from(e),Ga=(e,t)=>e.toString(16).padStart(t,"0"),Va=e=>Array.from(Be(e)).map(t=>Ga(t,2)).join(""),xe={_0:48,_9:57,A:65,F:70,a:97,f:102},dr=e=>{if(e>=xe._0&&e<=xe._9)return e-xe._0;if(e>=xe.A&&e<=xe.F)return e-(xe.A-10);if(e>=xe.a&&e<=xe.f)return e-(xe.a-10)},Qa=e=>{const t="hex invalid";if(!kd(e))return Q(t);const n=e.length,s=n/2;if(n%2)return Q(t);const i=as(s);for(let o=0,r=0;o<s;o++,r+=2){const l=dr(e.charCodeAt(r)),a=dr(e.charCodeAt(r+1));if(l===void 0||a===void 0)return Q(t);i[o]=l*16+a}return i},Ya=()=>globalThis?.crypto,Ad=()=>Ya()?.subtle??Q("crypto.subtle must be defined, consider polyfill"),Zt=(...e)=>{const t=as(e.reduce((s,i)=>s+Be(i).length,0));let n=0;return e.forEach(s=>{t.set(s,n),n+=s.length}),t},xd=(e=Ye)=>Ya().getRandomValues(as(e)),Hn=BigInt,He=(e,t,n,s="bad number: out of range")=>wd(e)&&t<=e&&e<n?e:Q(s),$=(e,t=ee)=>{const n=e%t;return n>=0n?n:t+n},Xa=e=>$(e,In),$d=(e,t)=>{(e===0n||t<=0n)&&Q("no inverse n="+e+" mod="+t);let n=$(e,t),s=t,i=0n,o=1n;for(;n!==0n;){const r=s/n,l=s%n,a=i-o*r;s=n,n=l,i=o,o=a}return s===1n?$(i,t):Q("no inverse")},Ed=e=>{const t=tl[e];return typeof t!="function"&&Q("hashes."+e+" not set"),t},Ds=e=>e instanceof ae?e:Q("Point expected"),ui=2n**256n;class ae{static BASE;static ZERO;X;Y;Z;T;constructor(t,n,s,i){const o=ui;this.X=He(t,0n,o),this.Y=He(n,0n,o),this.Z=He(s,1n,o),this.T=He(i,0n,o),Object.freeze(this)}static CURVE(){return Ha}static fromAffine(t){return new ae(t.x,t.y,1n,$(t.x*t.y))}static fromBytes(t,n=!1){const s=Os,i=qa(Be(t,Ye)),o=t[31];i[31]=o&-129;const r=Ja(i);He(r,0n,n?ui:ee);const a=$(r*r),c=$(a-1n),u=$(s*a+1n);let{isValid:p,value:m}=Cd(c,u);p||Q("bad point: y not sqrt");const v=(m&1n)===1n,w=(o&128)!==0;return!n&&m===0n&&w&&Q("bad point: x==0, isLastByteOdd"),w!==v&&(m=$(-m)),new ae(m,r,1n,$(m*r))}static fromHex(t,n){return ae.fromBytes(Qa(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=Ns,n=Os,s=this;if(s.is0())return Q("bad point: ZERO");const{X:i,Y:o,Z:r,T:l}=s,a=$(i*i),c=$(o*o),u=$(r*r),p=$(u*u),m=$(a*t),v=$(u*$(m+c)),w=$(p+$(n*$(a*c)));if(v!==w)return Q("bad point: equation left != right (1)");const x=$(i*o),_=$(r*l);return x!==_?Q("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:s,Z:i}=this,{X:o,Y:r,Z:l}=Ds(t),a=$(n*l),c=$(o*i),u=$(s*l),p=$(r*i);return a===c&&u===p}is0(){return this.equals(ft)}negate(){return new ae($(-this.X),this.Y,this.Z,$(-this.T))}double(){const{X:t,Y:n,Z:s}=this,i=Ns,o=$(t*t),r=$(n*n),l=$(2n*$(s*s)),a=$(i*o),c=t+n,u=$($(c*c)-o-r),p=a+r,m=p-l,v=a-r,w=$(u*m),x=$(p*v),_=$(u*v),j=$(m*p);return new ae(w,x,j,_)}add(t){const{X:n,Y:s,Z:i,T:o}=this,{X:r,Y:l,Z:a,T:c}=Ds(t),u=Ns,p=Os,m=$(n*r),v=$(s*l),w=$(o*p*c),x=$(i*a),_=$((n+s)*(r+l)-m-v),j=$(x-w),C=$(x+w),L=$(v-u*m),I=$(_*j),B=$(C*L),ue=$(_*L),it=$(j*C);return new ae(I,B,it,ue)}subtract(t){return this.add(Ds(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return ft;if(He(t,1n,In),t===1n)return this;if(this.equals(Xe))return Fd(t).p;let s=ft,i=Xe;for(let o=this;t>0n;o=o.double(),t>>=1n)t&1n?s=s.add(o):n&&(i=i.add(o));return s}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:s}=this;if(this.equals(ft))return{x:0n,y:1n};const i=$d(s,ee);$(s*i)!==1n&&Q("invalid inverse");const o=$(t*i),r=$(n*i);return{x:o,y:r}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),s=Za(n);return s[31]|=t&1n?128:0,s}toHex(){return Va(this.toBytes())}clearCofactor(){return this.multiply(Hn(vd),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(In/2n,!1).double();return In%2n&&(t=t.add(this)),t.is0()}}const Xe=new ae(cr,ur,1n,$(cr*ur)),ft=new ae(0n,1n,1n,0n);ae.BASE=Xe;ae.ZERO=ft;const Za=e=>Qa(Ga(He(e,0n,ui),Hi)).reverse(),Ja=e=>Hn("0x"+Va(qa(Be(e)).reverse())),ye=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=ee;return n},Td=e=>{const n=e*e%ee*e%ee,s=ye(n,2n)*n%ee,i=ye(s,1n)*e%ee,o=ye(i,5n)*i%ee,r=ye(o,10n)*o%ee,l=ye(r,20n)*r%ee,a=ye(l,40n)*l%ee,c=ye(a,80n)*a%ee,u=ye(c,80n)*a%ee,p=ye(u,10n)*o%ee;return{pow_p_5_8:ye(p,2n)*e%ee,b2:n}},pr=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Cd=(e,t)=>{const n=$(t*t*t),s=$(n*n*t),i=Td(e*s).pow_p_5_8;let o=$(e*n*i);const r=$(t*o*o),l=o,a=$(o*pr),c=r===e,u=r===$(-e),p=r===$(-e*pr);return c&&(o=l),(u||p)&&(o=a),($(o)&1n)===1n&&(o=$(-o)),{isValid:c||u,value:o}},di=e=>Xa(Ja(e)),qi=(...e)=>tl.sha512Async(Zt(...e)),_d=(...e)=>Ed("sha512")(Zt(...e)),el=e=>{const t=e.slice(0,Ye);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(Ye,Hi),s=di(t),i=Xe.multiply(s),o=i.toBytes();return{head:t,prefix:n,scalar:s,point:i,pointBytes:o}},Gi=e=>qi(Be(e,Ye)).then(el),Md=e=>el(_d(Be(e,Ye))),Pd=e=>Gi(e).then(t=>t.pointBytes),Ld=e=>qi(e.hashable).then(e.finish),Rd=(e,t,n)=>{const{pointBytes:s,scalar:i}=e,o=di(t),r=Xe.multiply(o).toBytes();return{hashable:Zt(r,s,n),finish:c=>{const u=Xa(o+di(c)*i);return Be(Zt(r,Za(u)),Hi)}}},Id=async(e,t)=>{const n=Be(e),s=await Gi(t),i=await qi(s.prefix,n);return Ld(Rd(s,i,n))},tl={sha512Async:async e=>{const t=Ad(),n=Zt(e);return as(await t.digest("SHA-512",n.buffer))},sha512:void 0},Nd=(e=xd(Ye))=>e,Od={getExtendedPublicKeyAsync:Gi,getExtendedPublicKey:Md,randomSecretKey:Nd},qn=8,Dd=256,nl=Math.ceil(Dd/qn)+1,pi=2**(qn-1),Bd=()=>{const e=[];let t=Xe,n=t;for(let s=0;s<nl;s++){n=t,e.push(n);for(let i=1;i<pi;i++)n=n.add(t),e.push(n);t=n.double()}return e};let hr;const fr=(e,t)=>{const n=t.negate();return e?n:t},Fd=e=>{const t=hr||(hr=Bd());let n=ft,s=Xe;const i=2**qn,o=i,r=Hn(i-1),l=Hn(qn);for(let a=0;a<nl;a++){let c=Number(e&r);e>>=l,c>pi&&(c-=o,e+=1n);const u=a*pi,p=u,m=u+Math.abs(c)-1,v=a%2!==0,w=c<0;c===0?s=s.add(fr(v,t[p])):n=n.add(fr(w,t[m]))}return e!==0n&&Q("invalid wnaf"),{p:n,f:s}},Bs="taskmaster-device-identity-v1";function hi(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replaceAll("+","-").replaceAll("/","_").replace(/=+$/g,"")}function sl(e){const t=e.replaceAll("-","+").replaceAll("_","/"),n=t+"=".repeat((4-t.length%4)%4),s=atob(n),i=new Uint8Array(s.length);for(let o=0;o<s.length;o+=1)i[o]=s.charCodeAt(o);return i}function Ud(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function il(e){const t=await crypto.subtle.digest("SHA-256",e);return Ud(new Uint8Array(t))}async function Wd(){const e=Od.randomSecretKey(),t=await Pd(e);return{deviceId:await il(t),publicKey:hi(t),privateKey:hi(e)}}async function Kd(){try{const n=localStorage.getItem(Bs);if(n){const s=JSON.parse(n);if(s?.version===1&&typeof s.deviceId=="string"&&typeof s.publicKey=="string"&&typeof s.privateKey=="string"){const i=await il(sl(s.publicKey));if(i!==s.deviceId){const o={...s,deviceId:i};return localStorage.setItem(Bs,JSON.stringify(o)),{deviceId:i,publicKey:s.publicKey,privateKey:s.privateKey}}return{deviceId:s.deviceId,publicKey:s.publicKey,privateKey:s.privateKey}}}}catch{}const e=await Wd(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Bs,JSON.stringify(t)),e}async function zd(e,t){const n=sl(e),s=new TextEncoder().encode(t),i=await Id(s,n);return hi(i)}const ol="taskmaster.device.auth.v1";function Vi(e){return e.trim()}function jd(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const s=n.trim();s&&t.add(s)}return[...t].sort()}function Qi(){try{const e=window.localStorage.getItem(ol);if(!e)return null;const t=JSON.parse(e);return!t||t.version!==1||!t.deviceId||typeof t.deviceId!="string"||!t.tokens||typeof t.tokens!="object"?null:t}catch{return null}}function rl(e){try{window.localStorage.setItem(ol,JSON.stringify(e))}catch{}}function Hd(e){const t=Qi();if(!t||t.deviceId!==e.deviceId)return null;const n=Vi(e.role),s=t.tokens[n];return!s||typeof s.token!="string"?null:s}function qd(e){const t=Vi(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},s=Qi();s&&s.deviceId===e.deviceId&&(n.tokens={...s.tokens});const i={token:e.token,role:t,scopes:jd(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=i,rl(n),i}function Gd(e){const t=Qi();if(!t||t.deviceId!==e.deviceId)return;const n=Vi(e.role);if(!t.tokens[n])return;const s={...t,tokens:{...t.tokens}};delete s.tokens[n],rl(s)}async function Yi(e,t){if(!(!e.client||!e.connected)&&!e.devicesLoading){e.devicesLoading=!0,t?.quiet||(e.devicesError=null);try{const n=await e.client.request("device.pair.list",{});e.devicesList={pending:Array.isArray(n?.pending)?n.pending:[],paired:Array.isArray(n?.paired)?n.paired:[]}}catch(n){t?.quiet||(e.devicesError=String(n))}finally{e.devicesLoading=!1}}}async function Xi(e,t){if(!(!e.client||!e.connected)&&!e.nodesLoading){e.nodesLoading=!0,t?.quiet||(e.lastError=null);try{const n=await e.client.request("node.list",{});e.nodes=Array.isArray(n.nodes)?n.nodes:[]}catch(n){t?.quiet||(e.lastError=String(n))}finally{e.nodesLoading=!1}}}function Vd(e){return{method:"exec.approvals.get",params:{}}}async function Qd(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=Vd(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const s=await e.client.request(n.method,n.params);Yd(e,s)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function Yd(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=Oe(t.file??{}))}async function al(e){if(!(!e.client||!e.connected)&&!e.presenceLoading){e.presenceLoading=!0,e.presenceError=null,e.presenceStatus=null;try{const t=await e.client.request("system-presence",{});Array.isArray(t)?(e.presenceEntries=t,e.presenceStatus=t.length===0?"No instances yet.":null):(e.presenceEntries=[],e.presenceStatus="No presence payload.")}catch(t){e.presenceError=String(t)}finally{e.presenceLoading=!1}}}function bt(e,t,n){if(!t.trim())return;const s={...e.skillMessages};n?s[t]=n:delete s[t],e.skillMessages=s}function ls(e){return e instanceof Error?e.message:String(e)}async function wt(e,t){if(t?.clearMessages&&Object.keys(e.skillMessages).length>0&&(e.skillMessages={}),!(!e.client||!e.connected)&&!e.skillsLoading){e.skillsLoading=!0,e.skillsError=null;try{const n=await e.client.request("skills.status",{});n&&(e.skillsReport=n)}catch(n){e.skillsError=ls(n)}finally{e.skillsLoading=!1}}}function Xd(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Zd(e,t,n){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.update",{skillKey:t,enabled:n}),await wt(e),bt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(s){const i=ls(s);e.skillsError=i,bt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Jd(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const n=e.skillEdits[t]??"";await e.client.request("skills.update",{skillKey:t,apiKey:n}),await wt(e),bt(e,t,{kind:"success",message:"API key saved"})}catch(n){const s=ls(n);e.skillsError=s,bt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function ep(e,t,n,s){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const i=await e.client.request("skills.install",{name:n,installId:s,timeoutMs:12e4});await wt(e),bt(e,t,{kind:"success",message:i?.message??"Installed"})}catch(i){const o=ls(i);e.skillsError=o,bt(e,t,{kind:"error",message:o})}finally{e.skillsBusyKey=null}}}const ll={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},cl=new Map(Object.entries(ll).map(([e,t])=>[t,e]));function cs(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function Jt(e){if(!e)return"/";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t}function tp(e,t=""){const n=cs(t),s=ll[e];return n?`${n}${s}`:s}function ul(e,t=""){const n=cs(t);let s=e||"/";n&&(s===n?s="/":s.startsWith(`${n}/`)&&(s=s.slice(n.length)));let i=Jt(s).toLowerCase();return i.endsWith("/index.html")&&(i="/"),i==="/"?"chat":cl.get(i)??null}function np(e){let t=Jt(e);if(t.endsWith("/index.html")&&(t=Jt(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let s=0;s<n.length;s++){const i=`/${n.slice(s).join("/")}`.toLowerCase();if(cl.has(i)){const o=n.slice(0,s);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function sp(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Zi(e){return e==="system"?sp():e}const kn=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,ip=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,Sn=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},op=({nextTheme:e,applyTheme:t,context:n,currentTheme:s})=>{if(s===e)return;const i=globalThis.document??null;if(!i){t();return}const o=i.documentElement,r=i,l=ip();if(!!r.startViewTransition&&!l){let c=.5,u=.5;if(n?.pointerClientX!==void 0&&n?.pointerClientY!==void 0&&typeof window<"u")c=kn(n.pointerClientX/window.innerWidth),u=kn(n.pointerClientY/window.innerHeight);else if(n?.element){const p=n.element.getBoundingClientRect();p.width>0&&p.height>0&&typeof window<"u"&&(c=kn((p.left+p.width/2)/window.innerWidth),u=kn((p.top+p.height/2)/window.innerHeight))}o.style.setProperty("--theme-switch-x",`${c*100}%`),o.style.setProperty("--theme-switch-y",`${u*100}%`),o.classList.add("theme-transition");try{const p=r.startViewTransition?.(()=>{t()});p?.finished?p.finished.finally(()=>Sn(o)):Sn(o)}catch{Sn(o),t()}return}t(),Sn(o)},rp=2e3;async function gt(e,t){if(!(!e.client||!e.connected)&&!(e.sessionLogsLoading&&!t?.quiet)){t?.quiet||(e.sessionLogsLoading=!0),e.sessionLogsError=null;try{const s=await e.client.request("sessions.transcript",{cursors:t?.reset?void 0:e.sessionLogsCursors,limit:200,maxBytesPerFile:e.sessionLogsFull?25e4:5e4,...e.sessionLogsFull?{full:!0}:{}}),i=Array.isArray(s.entries)?s.entries:[],o=!!(t?.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=o?i:[...e.sessionLogsEntries,...i].slice(-rp),s.cursors&&(e.sessionLogsCursors=s.cursors),Array.isArray(s.agents)&&(e.sessionLogsAgents=s.agents),e.sessionLogsLastFetchAt=Date.now()}catch(n){e.sessionLogsError=String(n)}finally{t?.quiet||(e.sessionLogsLoading=!1)}}}const ap=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:gt},Symbol.toStringTag,{value:"Module"}));function lp(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{Xi(e,{quiet:!0})},5e3))}function cp(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function Ji(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&qt(e,{quiet:!0})},2e3))}function eo(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function to(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{e.tab!=="logs"||e.logsSubTab!=="session"||gt(e,{quiet:!0})},2e3))}function no(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function so(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&ji(e)},3e3))}function io(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Ie(e,t){const n={...t,lastActiveSessionKey:t.lastActiveSessionKey?.trim()||t.sessionKey.trim()||"main"};e.settings=n,wu(n),t.theme!==e.theme&&(e.theme=t.theme,us(e,Zi(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function dl(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&Ie(e,{...e.settings,lastActiveSessionKey:n})}function up(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),s=t.get("password"),i=t.get("session"),o=t.get("gatewayUrl");let r=!1;if(n!=null){const a=n.trim();a&&a!==e.settings.token&&Ie(e,{...e.settings,token:a}),t.delete("token"),r=!0}if(s!=null){const a=s.trim();a&&(e.password=a),t.delete("password"),r=!0}if(i!=null){const a=i.trim();a&&(e.sessionKey=a,Ie(e,{...e.settings,sessionKey:a,lastActiveSessionKey:a}))}if(o!=null){const a=o.trim();a&&a!==e.settings.gatewayUrl&&Ie(e,{...e.settings,gatewayUrl:a}),t.delete("gatewayUrl"),r=!0}if(!r)return;const l=new URL(window.location.href);l.search=t.toString(),window.history.replaceState({},"",l.toString())}function dp(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?to(e):Ji(e):(eo(e),no(e)),t==="debug"?so(e):io(e),oo(e),hl(e,t,!1)}function pp(e,t,n){op({nextTheme:t,applyTheme:()=>{e.theme=t,Ie(e,{...e.settings,theme:t}),us(e,Zi(t))},context:n,currentTheme:e.theme})}async function oo(e){if(e.tab==="overview"&&await fl(e),e.tab==="channels"&&await bp(e),e.tab==="instances"&&await al(e),e.tab==="cron"&&await ro(e),e.tab==="skills"&&await wt(e),e.tab==="nodes"&&(await Xi(e),await Yi(e),await we(e),await Qd(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await xp(e),en(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await Ua(e),await we(e)),e.tab==="debug"&&(await ji(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await $e(async()=>{const{loadSessionLogs:s}=await Promise.resolve().then(()=>ap);return{loadSessionLogs:s}},void 0,import.meta.url);await n(e,{reset:!0})}else await qt(e,{reset:!0});Ba(e,!0)}}function hp(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?cs(e):np(window.location.pathname)}function fp(e){e.theme=e.settings.theme??"system",us(e,Zi(e.theme))}function us(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function gp(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;if(e.themeMedia=window.matchMedia("(prefers-color-scheme: dark)"),e.themeMediaHandler=n=>{e.theme==="system"&&us(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function mp(e){if(!e.themeMedia||!e.themeMediaHandler)return;if(typeof e.themeMedia.removeEventListener=="function"){e.themeMedia.removeEventListener("change",e.themeMediaHandler);return}e.themeMedia.removeListener(e.themeMediaHandler),e.themeMedia=null,e.themeMediaHandler=null}function yp(e,t){if(typeof window>"u")return;const n=ul(window.location.pathname,e.basePath)??"chat";pl(e,n),hl(e,n,t)}function vp(e){if(typeof window>"u")return;const t=ul(window.location.pathname,e.basePath);if(!t)return;const s=new URL(window.location.href).searchParams.get("session")?.trim();s&&(e.sessionKey=s,Ie(e,{...e.settings,sessionKey:s,lastActiveSessionKey:s})),pl(e,t)}function pl(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?to(e):Ji(e):(eo(e),no(e)),t==="debug"?so(e):io(e),e.connected&&oo(e)}function hl(e,t,n){if(typeof window>"u")return;const s=Jt(tp(t,e.basePath)),i=Jt(window.location.pathname),o=new URL(window.location.href);t==="chat"&&e.sessionKey?o.searchParams.set("session",e.sessionKey):o.searchParams.delete("session"),i!==s&&(o.pathname=s),n?window.history.replaceState({},"",o.toString()):window.history.pushState({},"",o.toString())}async function fl(e){await Promise.all([z(e,!1),al(e),Wi(e),tn(e),ji(e)])}async function bp(e){await Promise.all([z(e,!0),Ua(e),we(e)])}async function ro(e){await Promise.all([z(e,!1),tn(e),rs(e)])}function gl(e){return e.chatSending||!!e.chatRunId}function wp(e){const t=e.trim();if(!t)return!1;const n=t.toLowerCase();return n==="/stop"?!0:n==="stop"||n==="esc"||n==="abort"||n==="wait"||n==="exit"}async function ml(e){e.connected&&(e.chatMessage="",await Oa(e))}function kp(e,t,n){const s=t.trim(),i=!!(n&&n.length>0);!s&&!i||(e.chatQueue=[...e.chatQueue,{id:Ui(),text:s,createdAt:Date.now(),attachments:i?n?.map(o=>({...o})):void 0}],en(e))}async function yl(e,t,n){Ki(e);const s=await Na(e,t,n?.attachments);return!s&&n?.previousDraft!=null&&(e.chatMessage=n.previousDraft),!s&&n?.previousAttachments&&(e.chatAttachments=n.previousAttachments),s&&dl(e,e.sessionKey),s&&n?.restoreDraft&&n.previousDraft?.trim()&&(e.chatMessage=n.previousDraft),s&&n?.restoreAttachments&&n.previousAttachments?.length&&(e.chatAttachments=n.previousAttachments),en(e),s&&!e.chatRunId&&vl(e),s}async function vl(e){if(!e.connected||gl(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await yl(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function Sp(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function Ap(e,t,n){if(!e.connected)return;const s=e.chatMessage,i=(t??e.chatMessage).trim(),o=e.chatAttachments??[],r=t==null?o:[],l=r.length>0;if(!(!i&&!l)){if(wp(i)){await ml(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[]),gl(e)){kp(e,i,r);return}await yl(e,i,{previousDraft:t==null?s:void 0,restoreDraft:!!(t&&n?.restoreDraft),attachments:l?r:void 0,previousAttachments:t==null?o:void 0,restoreAttachments:!!(t&&n?.restoreDraft)})}}async function xp(e){await Promise.all([Ce(e),Wi(e),fi(e)]),en(e,!0)}const $p=vl;function Ep(e){const t=Ta(e.sessionKey);return t?.agentId?t.agentId:e.hello?.snapshot?.sessionDefaults?.defaultAgentId?.trim()||"main"}function Tp(e,t){const n=cs(e),s=encodeURIComponent(t);return n?`${n}/avatar/${s}?meta=1`:`/avatar/${s}?meta=1`}async function fi(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=Ep(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=Tp(e.basePath,t);try{const s=await fetch(n,{method:"GET"});if(!s.ok){e.chatAvatarUrl=null;return}const i=await s.json(),o=typeof i.avatarUrl=="string"?i.avatarUrl.trim():"";e.chatAvatarUrl=o||null}catch{e.chatAvatarUrl=null}}const N={messageSquare:d`<svg viewBox="0 0 24 24"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>`,barChart:d`<svg viewBox="0 0 24 24"><line x1="12" x2="12" y1="20" y2="10"/><line x1="18" x2="18" y1="20" y2="4"/><line x1="6" x2="6" y1="20" y2="16"/></svg>`,link:d`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,radio:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="2"/><path d="M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"/></svg>`,fileText:d`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><line x1="16" x2="8" y1="13" y2="13"/><line x1="16" x2="8" y1="17" y2="17"/><line x1="10" x2="8" y1="9" y2="9"/></svg>`,zap:d`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:d`<svg viewBox="0 0 24 24"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>`,settings:d`<svg viewBox="0 0 24 24"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>`,bug:d`<svg viewBox="0 0 24 24"><path d="m8 2 1.88 1.88"/><path d="M14.12 3.88 16 2"/><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"/><path d="M12 20v-9"/><path d="M6.53 9C4.6 8.8 3 7.1 3 5"/><path d="M6 13H2"/><path d="M3 21c0-2.1 1.7-3.9 3.8-4"/><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"/><path d="M22 13h-4"/><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4"/></svg>`,scrollText:d`<svg viewBox="0 0 24 24"><path d="M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/><path d="M15 8h-5"/><path d="M15 12h-5"/></svg>`,folder:d`<svg viewBox="0 0 24 24"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg>`,users:d`<svg viewBox="0 0 24 24"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>`,menu:d`<svg viewBox="0 0 24 24"><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/></svg>`,x:d`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:d`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:d`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,search:d`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:d`<svg viewBox="0 0 24 24"><path d="M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"/><path d="M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"/><path d="M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"/><path d="M17.599 6.5a3 3 0 0 0 .399-1.375"/><path d="M6.003 5.125A3 3 0 0 0 6.401 6.5"/><path d="M3.477 10.896a4 4 0 0 1 .585-.396"/><path d="M19.938 10.5a4 4 0 0 1 .585.396"/><path d="M6 18a4 4 0 0 1-1.967-.516"/><path d="M19.967 17.484A4 4 0 0 1 18 18"/></svg>`,book:d`<svg viewBox="0 0 24 24"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/></svg>`,loader:d`<svg viewBox="0 0 24 24"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>`,rotateCw:d`<svg viewBox="0 0 24 24"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/></svg>`,download:d`<svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`,wrench:d`<svg viewBox="0 0 24 24"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg>`,fileCode:d`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><path d="m10 13-2 2 2 2"/><path d="m14 17 2-2-2-2"/></svg>`,edit:d`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,penLine:d`<svg viewBox="0 0 24 24"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>`,paperclip:d`<svg viewBox="0 0 24 24"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`,globe:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>`,image:d`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>`,smartphone:d`<svg viewBox="0 0 24 24"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>`,plug:d`<svg viewBox="0 0 24 24"><path d="M12 22v-5"/><path d="M9 8V2"/><path d="M15 8V2"/><path d="M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z"/></svg>`,circle:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,puzzle:d`<svg viewBox="0 0 24 24"><path d="M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.076.874.54 1.02 1.02a2.5 2.5 0 1 0 3.237-3.237c-.48-.146-.944-.505-1.02-1.02a.98.98 0 0 1 .303-.917l1.526-1.526A2.402 2.402 0 0 1 11.998 2c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.236 3.236c-.464.18-.894.527-.967 1.02Z"/></svg>`,info:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>`,send:d`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>`,slidersHorizontal:d`<svg viewBox="0 0 24 24"><line x1="21" x2="14" y1="4" y2="4"/><line x1="10" x2="3" y1="4" y2="4"/><line x1="21" x2="12" y1="12" y2="12"/><line x1="8" x2="3" y1="12" y2="12"/><line x1="21" x2="16" y1="20" y2="20"/><line x1="12" x2="3" y1="20" y2="20"/><line x1="14" x2="14" y1="2" y2="6"/><line x1="8" x2="8" y1="10" y2="14"/><line x1="16" x2="16" y1="18" y2="22"/></svg>`,square:d`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:d`<svg viewBox="0 0 24 24"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>`,eyeOff:d`<svg viewBox="0 0 24 24"><path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,trash:d`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,chevronDown:d`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:d`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/></svg>`},Cp="Taskmaster",_p="/taskmaster-icon.png",bl="#00d4ff";let An=null;function De(){return An||(An={name:window.__TASKMASTER_BRAND_NAME__||Cp,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||_p,accentColor:window.__TASKMASTER_ACCENT_COLOR__||bl},An)}function Mp(e){const t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);return t?`${parseInt(t[1],16)}, ${parseInt(t[2],16)}, ${parseInt(t[3],16)}`:null}function Pp(e){if(e===bl)return;const t=Mp(e);if(!t)return;const n=document.documentElement;n.style.setProperty("--accent",e),n.style.setProperty("--accent-hover",e),n.style.setProperty("--accent-muted",e),n.style.setProperty("--primary",e),n.style.setProperty("--ring",e),n.style.setProperty("--accent-subtle",`rgba(${t}, 0.15)`),n.style.setProperty("--accent-glow",`rgba(${t}, 0.25)`),n.style.setProperty("--tasker-orange",e),n.style.setProperty("--tasker-orange-hover",e),n.style.setProperty("--tasker-orange-glow",`rgba(${t}, 0.25)`)}const Lp=d`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>`;let gr=!1;function Rp(){gr||(gr=!0,document.addEventListener("click",e=>{const t=document.getElementById("nav-burger-toggle");!t?.checked||t.closest(".setup-header")?.contains(e.target)||(t.checked=!1)}))}function tt(e,t){const n=(a,c)=>a===e?d`<span class="sp-page-nav-current">${a}</span>`:d`<a href=${c}>${a}</a>`,s=d`
18
+ `}function Ua(e,t,n){if(t.length===0)return;let s=e;for(let o=0;o<t.length-1;o+=1){const r=t[o],l=t[o+1];if(typeof r=="number"){if(!Array.isArray(s))return;s[r]==null&&(s[r]=typeof l=="number"?[]:{}),s=s[r]}else{if(typeof s!="object"||s==null)return;const a=s;a[r]==null&&(a[r]=typeof l=="number"?[]:{}),s=a[r]}}const i=t[t.length-1];if(typeof i=="number"){Array.isArray(s)&&(s[i]=n);return}typeof s=="object"&&s!=null&&(s[i]=n)}async function we(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});id(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function Wa(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});sd(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function sd(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function id(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?Qe(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=Qe(e.configForm):e.configRaw=n,e.configValid=typeof t.valid=="boolean"?t.valid:null,e.configIssues=Array.isArray(t.issues)?t.issues:[],e.configFormDirty||(e.configForm=Oe(t.config??{}),e.configFormOriginal=Oe(t.config??{}),e.configRawOriginal=n)}async function od(e){if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const t=e.configFormMode==="form"&&e.configForm?Qe(e.configForm):e.configRaw,n=e.configSnapshot?.hash;if(!n){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:t,baseHash:n}),e.configFormDirty=!1,await we(e)}catch(t){e.lastError=String(t)}finally{e.configSaving=!1}}}async function tn(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("cron.status",{});e.cronStatus=t}catch(t){e.cronError=String(t)}}async function rs(e){if(!(!e.client||!e.connected)&&!e.cronLoading){e.cronLoading=!0,e.cronError=null;try{const t={includeDisabled:!0};Array.isArray(e.workspaceAgentIds)&&e.workspaceAgentIds.length>0&&(t.agentIds=e.workspaceAgentIds);const n=await e.client.request("cron.list",t);e.cronJobs=Array.isArray(n.jobs)?n.jobs:[]}catch(t){e.cronError=String(t)}finally{e.cronLoading=!1}}}function rd(e){if(e.scheduleKind==="at"){const n=Date.parse(e.scheduleAt);if(!Number.isFinite(n))throw new Error("Invalid run time.");return{kind:"at",atMs:n}}if(e.scheduleKind==="every"){const n=zn(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const s=e.everyUnit;return{kind:"every",everyMs:n*(s==="minutes"?6e4:s==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function ad(e){if(e.payloadKind==="systemEvent"){const i=e.payloadText.trim();if(!i)throw new Error("System event text required.");return{kind:"systemEvent",text:i}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t};e.deliver&&(n.deliver=!0),e.channel&&(n.channel=e.channel),e.to.trim()&&(n.to=e.to.trim());const s=zn(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function ld(e){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const t=rd(e.cronForm),n=ad(e.cronForm),s=e.cronForm.agentId.trim(),i=e.cronForm.accountId?.trim(),o={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,accountId:i||void 0,enabled:e.cronForm.enabled,schedule:t,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:n,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!o.name)throw new Error("Name required.");await e.client.request("cron.add",o),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await rs(e),await tn(e)}catch(t){e.cronError=String(t)}finally{e.cronBusy=!1}}}async function cd(e,t,n){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.update",{id:t.id,patch:{enabled:n}}),await rs(e),await tn(e)}catch(s){e.cronError=String(s)}finally{e.cronBusy=!1}}}async function ud(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await ci(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function dd(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.remove",{id:t.id}),e.cronRunsJobId===t.id&&(e.cronRunsJobId=null,e.cronRuns=[]),await rs(e),await tn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function ci(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("cron.runs",{id:t,limit:50});e.cronRunsJobId=t,e.cronRuns=Array.isArray(n.entries)?n.entries:[]}catch(n){e.cronError=String(n)}}async function z(e,t){if(!(!e.client||!e.connected)&&!e.channelsLoading){e.channelsLoading=!0,e.channelsError=null;try{const n=await e.client.request("channels.status",{probe:t,timeoutMs:8e3});e.channelsSnapshot=n,e.channelsLastSuccess=Date.now()}catch(n){e.channelsError=String(n)}finally{e.channelsLoading=!1}}}async function zi(e,t,n){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0,e.whatsappActiveQrAccountId=n??null;try{const s=await e.client.request("web.login.start",{force:t,timeoutMs:3e4,accountId:n});e.whatsappLoginMessage=s.message??null,e.whatsappLoginQrDataUrl=s.qrDataUrl??null,e.whatsappLoginConnected=null}catch(s){e.whatsappLoginMessage=String(s),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function Ka(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{const n=await e.client.request("web.login.wait",{timeoutMs:12e4,accountId:t});e.whatsappLoginMessage=n.message??null,e.whatsappLoginConnected=n.connected??null,n.connected&&(e.whatsappLoginQrDataUrl=null,e.whatsappActiveQrAccountId=null,e.whatsappPairedPhone=n.selfPhone??null)}catch(n){e.whatsappLoginMessage=String(n),e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function za(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t}),e.whatsappLoginMessage="Logged out.",e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null}catch(n){e.whatsappLoginMessage=String(n)}finally{e.whatsappBusy=!1}}}async function ja(e,t){if(!e.client||!e.connected||e.whatsappAccountSaving)return;const n=t.trim();if(!n){e.whatsappAccountError="Account name is required.";return}const s=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");if(!s){e.whatsappAccountError="Invalid account name.";return}e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const i=await e.client.request("config.get",{});e.configSnapshot=i;const o=Oe(i.config??{});(!o.channels||typeof o.channels!="object")&&(o.channels={});const r=o.channels;(!r.whatsapp||typeof r.whatsapp!="object")&&(r.whatsapp={});const l=r.whatsapp;(!l.accounts||typeof l.accounts!="object")&&(l.accounts={});const a=l.accounts;if(a[s]){e.whatsappAccountError=`Account "${s}" already exists.`;return}a[s]={name:n,provider:"baileys"};const c=i.hash;if(!c){e.whatsappAccountError="Config hash missing; reload and retry.";return}const u=Qe(o);await e.client.request("config.set",{raw:u,baseHash:c}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await z(e,!0),await zi(e,!0,s)}catch(i){e.whatsappAccountError=String(i)}finally{e.whatsappAccountSaving=!1}}async function Ha(e,t){if(!(!e.client||!e.connected)&&!e.whatsappAccountSaving){e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const s=Oe(n.config??{}),r=s.channels?.whatsapp?.accounts;if(!r){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(r).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!r[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete r[t],Array.isArray(s.bindings)&&(s.bindings=s.bindings.filter(u=>{const p=u.match;return!p||p.channel!=="whatsapp"?!0:p.accountId!==t}));const a=n.hash;if(!a){e.whatsappAccountError="Config hash missing; reload and retry.";return}const c=Qe(s);await e.client.request("config.set",{raw:c,baseHash:a}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await z(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const pd=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:ja,loadChannels:z,logoutWhatsApp:za,removeWhatsAppAccount:Ha,startWhatsAppLogin:zi,waitWhatsAppLogin:Ka},Symbol.toStringTag,{value:"Module"}));async function ji(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,s,i]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const o=s;e.debugModels=Array.isArray(o?.models)?o?.models:[],e.debugHeartbeat=i}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}const hd=2e3,fd=new Set(["trace","debug","info","warn","error","fatal"]);function gd(e){if(typeof e!="string")return null;const t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;try{const n=JSON.parse(t);return!n||typeof n!="object"?null:n}catch{return null}}function md(e){if(typeof e!="string")return null;const t=e.toLowerCase();return fd.has(t)?t:null}function yd(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,s=typeof t.time=="string"?t.time:typeof n?.date=="string"?n?.date:null,i=md(n?.logLevelName??n?.level),o=typeof t[0]=="string"?t[0]:typeof n?.name=="string"?n?.name:null,r=gd(o);let l=null;r&&(typeof r.subsystem=="string"?l=r.subsystem:typeof r.module=="string"&&(l=r.module)),!l&&o&&o.length<120&&(l=o);let a=null;return typeof t[1]=="string"?a=t[1]:!r&&typeof t[0]=="string"?a=t[0]:typeof t.message=="string"&&(a=t.message),{raw:e,time:s,level:i,subsystem:l,message:a??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function qt(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!t?.quiet)){t?.quiet||(e.logsLoading=!0),e.logsError=null;try{const s=await e.client.request("logs.tail",{cursor:t?.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),o=(Array.isArray(s.lines)?s.lines.filter(l=>typeof l=="string"):[]).map(yd),r=!!(t?.reset||s.reset||e.logsCursor==null);e.logsEntries=r?o:[...e.logsEntries,...o].slice(-hd),typeof s.cursor=="number"&&(e.logsCursor=s.cursor),typeof s.file=="string"&&(e.logsFile=s.file),e.logsTruncated=!!s.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t?.quiet||(e.logsLoading=!1)}}}const qa={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:ee,n:In,Gx:cr,Gy:ur,a:Ns,d:Os,h:vd}=qa,Ye=32,Hi=64,bd=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},Q=(e="")=>{const t=new Error(e);throw bd(t,Q),t},wd=e=>typeof e=="bigint",kd=e=>typeof e=="string",Sd=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",Be=(e,t,n="")=>{const s=Sd(e),i=e?.length,o=t!==void 0;if(!s||o&&i!==t){const r=n&&`"${n}" `,l=o?` of length ${t}`:"",a=s?`length=${i}`:`type=${typeof e}`;Q(r+"expected Uint8Array"+l+", got "+a)}return e},as=e=>new Uint8Array(e),Ga=e=>Uint8Array.from(e),Va=(e,t)=>e.toString(16).padStart(t,"0"),Qa=e=>Array.from(Be(e)).map(t=>Va(t,2)).join(""),xe={_0:48,_9:57,A:65,F:70,a:97,f:102},dr=e=>{if(e>=xe._0&&e<=xe._9)return e-xe._0;if(e>=xe.A&&e<=xe.F)return e-(xe.A-10);if(e>=xe.a&&e<=xe.f)return e-(xe.a-10)},Ya=e=>{const t="hex invalid";if(!kd(e))return Q(t);const n=e.length,s=n/2;if(n%2)return Q(t);const i=as(s);for(let o=0,r=0;o<s;o++,r+=2){const l=dr(e.charCodeAt(r)),a=dr(e.charCodeAt(r+1));if(l===void 0||a===void 0)return Q(t);i[o]=l*16+a}return i},Xa=()=>globalThis?.crypto,Ad=()=>Xa()?.subtle??Q("crypto.subtle must be defined, consider polyfill"),Zt=(...e)=>{const t=as(e.reduce((s,i)=>s+Be(i).length,0));let n=0;return e.forEach(s=>{t.set(s,n),n+=s.length}),t},xd=(e=Ye)=>Xa().getRandomValues(as(e)),Hn=BigInt,He=(e,t,n,s="bad number: out of range")=>wd(e)&&t<=e&&e<n?e:Q(s),$=(e,t=ee)=>{const n=e%t;return n>=0n?n:t+n},Za=e=>$(e,In),$d=(e,t)=>{(e===0n||t<=0n)&&Q("no inverse n="+e+" mod="+t);let n=$(e,t),s=t,i=0n,o=1n;for(;n!==0n;){const r=s/n,l=s%n,a=i-o*r;s=n,n=l,i=o,o=a}return s===1n?$(i,t):Q("no inverse")},Ed=e=>{const t=nl[e];return typeof t!="function"&&Q("hashes."+e+" not set"),t},Ds=e=>e instanceof ae?e:Q("Point expected"),ui=2n**256n;class ae{static BASE;static ZERO;X;Y;Z;T;constructor(t,n,s,i){const o=ui;this.X=He(t,0n,o),this.Y=He(n,0n,o),this.Z=He(s,1n,o),this.T=He(i,0n,o),Object.freeze(this)}static CURVE(){return qa}static fromAffine(t){return new ae(t.x,t.y,1n,$(t.x*t.y))}static fromBytes(t,n=!1){const s=Os,i=Ga(Be(t,Ye)),o=t[31];i[31]=o&-129;const r=el(i);He(r,0n,n?ui:ee);const a=$(r*r),c=$(a-1n),u=$(s*a+1n);let{isValid:p,value:m}=Cd(c,u);p||Q("bad point: y not sqrt");const v=(m&1n)===1n,w=(o&128)!==0;return!n&&m===0n&&w&&Q("bad point: x==0, isLastByteOdd"),w!==v&&(m=$(-m)),new ae(m,r,1n,$(m*r))}static fromHex(t,n){return ae.fromBytes(Ya(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=Ns,n=Os,s=this;if(s.is0())return Q("bad point: ZERO");const{X:i,Y:o,Z:r,T:l}=s,a=$(i*i),c=$(o*o),u=$(r*r),p=$(u*u),m=$(a*t),v=$(u*$(m+c)),w=$(p+$(n*$(a*c)));if(v!==w)return Q("bad point: equation left != right (1)");const x=$(i*o),_=$(r*l);return x!==_?Q("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:s,Z:i}=this,{X:o,Y:r,Z:l}=Ds(t),a=$(n*l),c=$(o*i),u=$(s*l),p=$(r*i);return a===c&&u===p}is0(){return this.equals(ft)}negate(){return new ae($(-this.X),this.Y,this.Z,$(-this.T))}double(){const{X:t,Y:n,Z:s}=this,i=Ns,o=$(t*t),r=$(n*n),l=$(2n*$(s*s)),a=$(i*o),c=t+n,u=$($(c*c)-o-r),p=a+r,m=p-l,v=a-r,w=$(u*m),x=$(p*v),_=$(u*v),j=$(m*p);return new ae(w,x,j,_)}add(t){const{X:n,Y:s,Z:i,T:o}=this,{X:r,Y:l,Z:a,T:c}=Ds(t),u=Ns,p=Os,m=$(n*r),v=$(s*l),w=$(o*p*c),x=$(i*a),_=$((n+s)*(r+l)-m-v),j=$(x-w),C=$(x+w),L=$(v-u*m),I=$(_*j),B=$(C*L),ue=$(_*L),it=$(j*C);return new ae(I,B,it,ue)}subtract(t){return this.add(Ds(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return ft;if(He(t,1n,In),t===1n)return this;if(this.equals(Xe))return Fd(t).p;let s=ft,i=Xe;for(let o=this;t>0n;o=o.double(),t>>=1n)t&1n?s=s.add(o):n&&(i=i.add(o));return s}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:s}=this;if(this.equals(ft))return{x:0n,y:1n};const i=$d(s,ee);$(s*i)!==1n&&Q("invalid inverse");const o=$(t*i),r=$(n*i);return{x:o,y:r}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),s=Ja(n);return s[31]|=t&1n?128:0,s}toHex(){return Qa(this.toBytes())}clearCofactor(){return this.multiply(Hn(vd),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(In/2n,!1).double();return In%2n&&(t=t.add(this)),t.is0()}}const Xe=new ae(cr,ur,1n,$(cr*ur)),ft=new ae(0n,1n,1n,0n);ae.BASE=Xe;ae.ZERO=ft;const Ja=e=>Ya(Va(He(e,0n,ui),Hi)).reverse(),el=e=>Hn("0x"+Qa(Ga(Be(e)).reverse())),ye=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=ee;return n},Td=e=>{const n=e*e%ee*e%ee,s=ye(n,2n)*n%ee,i=ye(s,1n)*e%ee,o=ye(i,5n)*i%ee,r=ye(o,10n)*o%ee,l=ye(r,20n)*r%ee,a=ye(l,40n)*l%ee,c=ye(a,80n)*a%ee,u=ye(c,80n)*a%ee,p=ye(u,10n)*o%ee;return{pow_p_5_8:ye(p,2n)*e%ee,b2:n}},pr=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Cd=(e,t)=>{const n=$(t*t*t),s=$(n*n*t),i=Td(e*s).pow_p_5_8;let o=$(e*n*i);const r=$(t*o*o),l=o,a=$(o*pr),c=r===e,u=r===$(-e),p=r===$(-e*pr);return c&&(o=l),(u||p)&&(o=a),($(o)&1n)===1n&&(o=$(-o)),{isValid:c||u,value:o}},di=e=>Za(el(e)),qi=(...e)=>nl.sha512Async(Zt(...e)),_d=(...e)=>Ed("sha512")(Zt(...e)),tl=e=>{const t=e.slice(0,Ye);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(Ye,Hi),s=di(t),i=Xe.multiply(s),o=i.toBytes();return{head:t,prefix:n,scalar:s,point:i,pointBytes:o}},Gi=e=>qi(Be(e,Ye)).then(tl),Md=e=>tl(_d(Be(e,Ye))),Pd=e=>Gi(e).then(t=>t.pointBytes),Ld=e=>qi(e.hashable).then(e.finish),Rd=(e,t,n)=>{const{pointBytes:s,scalar:i}=e,o=di(t),r=Xe.multiply(o).toBytes();return{hashable:Zt(r,s,n),finish:c=>{const u=Za(o+di(c)*i);return Be(Zt(r,Ja(u)),Hi)}}},Id=async(e,t)=>{const n=Be(e),s=await Gi(t),i=await qi(s.prefix,n);return Ld(Rd(s,i,n))},nl={sha512Async:async e=>{const t=Ad(),n=Zt(e);return as(await t.digest("SHA-512",n.buffer))},sha512:void 0},Nd=(e=xd(Ye))=>e,Od={getExtendedPublicKeyAsync:Gi,getExtendedPublicKey:Md,randomSecretKey:Nd},qn=8,Dd=256,sl=Math.ceil(Dd/qn)+1,pi=2**(qn-1),Bd=()=>{const e=[];let t=Xe,n=t;for(let s=0;s<sl;s++){n=t,e.push(n);for(let i=1;i<pi;i++)n=n.add(t),e.push(n);t=n.double()}return e};let hr;const fr=(e,t)=>{const n=t.negate();return e?n:t},Fd=e=>{const t=hr||(hr=Bd());let n=ft,s=Xe;const i=2**qn,o=i,r=Hn(i-1),l=Hn(qn);for(let a=0;a<sl;a++){let c=Number(e&r);e>>=l,c>pi&&(c-=o,e+=1n);const u=a*pi,p=u,m=u+Math.abs(c)-1,v=a%2!==0,w=c<0;c===0?s=s.add(fr(v,t[p])):n=n.add(fr(w,t[m]))}return e!==0n&&Q("invalid wnaf"),{p:n,f:s}},Bs="taskmaster-device-identity-v1";function hi(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replaceAll("+","-").replaceAll("/","_").replace(/=+$/g,"")}function il(e){const t=e.replaceAll("-","+").replaceAll("_","/"),n=t+"=".repeat((4-t.length%4)%4),s=atob(n),i=new Uint8Array(s.length);for(let o=0;o<s.length;o+=1)i[o]=s.charCodeAt(o);return i}function Ud(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function ol(e){const t=await crypto.subtle.digest("SHA-256",e);return Ud(new Uint8Array(t))}async function Wd(){const e=Od.randomSecretKey(),t=await Pd(e);return{deviceId:await ol(t),publicKey:hi(t),privateKey:hi(e)}}async function Kd(){try{const n=localStorage.getItem(Bs);if(n){const s=JSON.parse(n);if(s?.version===1&&typeof s.deviceId=="string"&&typeof s.publicKey=="string"&&typeof s.privateKey=="string"){const i=await ol(il(s.publicKey));if(i!==s.deviceId){const o={...s,deviceId:i};return localStorage.setItem(Bs,JSON.stringify(o)),{deviceId:i,publicKey:s.publicKey,privateKey:s.privateKey}}return{deviceId:s.deviceId,publicKey:s.publicKey,privateKey:s.privateKey}}}}catch{}const e=await Wd(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Bs,JSON.stringify(t)),e}async function zd(e,t){const n=il(e),s=new TextEncoder().encode(t),i=await Id(s,n);return hi(i)}const rl="taskmaster.device.auth.v1";function Vi(e){return e.trim()}function jd(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const s=n.trim();s&&t.add(s)}return[...t].sort()}function Qi(){try{const e=window.localStorage.getItem(rl);if(!e)return null;const t=JSON.parse(e);return!t||t.version!==1||!t.deviceId||typeof t.deviceId!="string"||!t.tokens||typeof t.tokens!="object"?null:t}catch{return null}}function al(e){try{window.localStorage.setItem(rl,JSON.stringify(e))}catch{}}function Hd(e){const t=Qi();if(!t||t.deviceId!==e.deviceId)return null;const n=Vi(e.role),s=t.tokens[n];return!s||typeof s.token!="string"?null:s}function qd(e){const t=Vi(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},s=Qi();s&&s.deviceId===e.deviceId&&(n.tokens={...s.tokens});const i={token:e.token,role:t,scopes:jd(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=i,al(n),i}function Gd(e){const t=Qi();if(!t||t.deviceId!==e.deviceId)return;const n=Vi(e.role);if(!t.tokens[n])return;const s={...t,tokens:{...t.tokens}};delete s.tokens[n],al(s)}async function Yi(e,t){if(!(!e.client||!e.connected)&&!e.devicesLoading){e.devicesLoading=!0,t?.quiet||(e.devicesError=null);try{const n=await e.client.request("device.pair.list",{});e.devicesList={pending:Array.isArray(n?.pending)?n.pending:[],paired:Array.isArray(n?.paired)?n.paired:[]}}catch(n){t?.quiet||(e.devicesError=String(n))}finally{e.devicesLoading=!1}}}async function Xi(e,t){if(!(!e.client||!e.connected)&&!e.nodesLoading){e.nodesLoading=!0,t?.quiet||(e.lastError=null);try{const n=await e.client.request("node.list",{});e.nodes=Array.isArray(n.nodes)?n.nodes:[]}catch(n){t?.quiet||(e.lastError=String(n))}finally{e.nodesLoading=!1}}}function Vd(e){return{method:"exec.approvals.get",params:{}}}async function Qd(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=Vd(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const s=await e.client.request(n.method,n.params);Yd(e,s)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function Yd(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=Oe(t.file??{}))}async function ll(e){if(!(!e.client||!e.connected)&&!e.presenceLoading){e.presenceLoading=!0,e.presenceError=null,e.presenceStatus=null;try{const t=await e.client.request("system-presence",{});Array.isArray(t)?(e.presenceEntries=t,e.presenceStatus=t.length===0?"No instances yet.":null):(e.presenceEntries=[],e.presenceStatus="No presence payload.")}catch(t){e.presenceError=String(t)}finally{e.presenceLoading=!1}}}function bt(e,t,n){if(!t.trim())return;const s={...e.skillMessages};n?s[t]=n:delete s[t],e.skillMessages=s}function ls(e){return e instanceof Error?e.message:String(e)}async function wt(e,t){if(t?.clearMessages&&Object.keys(e.skillMessages).length>0&&(e.skillMessages={}),!(!e.client||!e.connected)&&!e.skillsLoading){e.skillsLoading=!0,e.skillsError=null;try{const n=await e.client.request("skills.status",{});n&&(e.skillsReport=n)}catch(n){e.skillsError=ls(n)}finally{e.skillsLoading=!1}}}function Xd(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Zd(e,t,n){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.update",{skillKey:t,enabled:n}),await wt(e),bt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(s){const i=ls(s);e.skillsError=i,bt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Jd(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const n=e.skillEdits[t]??"";await e.client.request("skills.update",{skillKey:t,apiKey:n}),await wt(e),bt(e,t,{kind:"success",message:"API key saved"})}catch(n){const s=ls(n);e.skillsError=s,bt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function ep(e,t,n,s){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const i=await e.client.request("skills.install",{name:n,installId:s,timeoutMs:12e4});await wt(e),bt(e,t,{kind:"success",message:i?.message??"Installed"})}catch(i){const o=ls(i);e.skillsError=o,bt(e,t,{kind:"error",message:o})}finally{e.skillsBusyKey=null}}}const cl={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},ul=new Map(Object.entries(cl).map(([e,t])=>[t,e]));function cs(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function Jt(e){if(!e)return"/";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t}function tp(e,t=""){const n=cs(t),s=cl[e];return n?`${n}${s}`:s}function dl(e,t=""){const n=cs(t);let s=e||"/";n&&(s===n?s="/":s.startsWith(`${n}/`)&&(s=s.slice(n.length)));let i=Jt(s).toLowerCase();return i.endsWith("/index.html")&&(i="/"),i==="/"?"chat":ul.get(i)??null}function np(e){let t=Jt(e);if(t.endsWith("/index.html")&&(t=Jt(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let s=0;s<n.length;s++){const i=`/${n.slice(s).join("/")}`.toLowerCase();if(ul.has(i)){const o=n.slice(0,s);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function sp(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Zi(e){return e==="system"?sp():e}const kn=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,ip=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,Sn=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},op=({nextTheme:e,applyTheme:t,context:n,currentTheme:s})=>{if(s===e)return;const i=globalThis.document??null;if(!i){t();return}const o=i.documentElement,r=i,l=ip();if(!!r.startViewTransition&&!l){let c=.5,u=.5;if(n?.pointerClientX!==void 0&&n?.pointerClientY!==void 0&&typeof window<"u")c=kn(n.pointerClientX/window.innerWidth),u=kn(n.pointerClientY/window.innerHeight);else if(n?.element){const p=n.element.getBoundingClientRect();p.width>0&&p.height>0&&typeof window<"u"&&(c=kn((p.left+p.width/2)/window.innerWidth),u=kn((p.top+p.height/2)/window.innerHeight))}o.style.setProperty("--theme-switch-x",`${c*100}%`),o.style.setProperty("--theme-switch-y",`${u*100}%`),o.classList.add("theme-transition");try{const p=r.startViewTransition?.(()=>{t()});p?.finished?p.finished.finally(()=>Sn(o)):Sn(o)}catch{Sn(o),t()}return}t(),Sn(o)},rp=2e3;async function gt(e,t){if(!(!e.client||!e.connected)&&!(e.sessionLogsLoading&&!t?.quiet)){t?.quiet||(e.sessionLogsLoading=!0),e.sessionLogsError=null;try{const s=await e.client.request("sessions.transcript",{cursors:t?.reset?void 0:e.sessionLogsCursors,limit:200,maxBytesPerFile:e.sessionLogsFull?25e4:5e4,...e.sessionLogsFull?{full:!0}:{}}),i=Array.isArray(s.entries)?s.entries:[],o=!!(t?.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=o?i:[...e.sessionLogsEntries,...i].slice(-rp),s.cursors&&(e.sessionLogsCursors=s.cursors),Array.isArray(s.agents)&&(e.sessionLogsAgents=s.agents),e.sessionLogsLastFetchAt=Date.now()}catch(n){e.sessionLogsError=String(n)}finally{t?.quiet||(e.sessionLogsLoading=!1)}}}const ap=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:gt},Symbol.toStringTag,{value:"Module"}));function lp(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{Xi(e,{quiet:!0})},5e3))}function cp(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function Ji(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&qt(e,{quiet:!0})},2e3))}function eo(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function to(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{e.tab!=="logs"||e.logsSubTab!=="session"||gt(e,{quiet:!0})},2e3))}function no(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function so(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&ji(e)},3e3))}function io(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function Ie(e,t){const n={...t,lastActiveSessionKey:t.lastActiveSessionKey?.trim()||t.sessionKey.trim()||"main"};e.settings=n,wu(n),t.theme!==e.theme&&(e.theme=t.theme,us(e,Zi(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function pl(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&Ie(e,{...e.settings,lastActiveSessionKey:n})}function up(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),s=t.get("password"),i=t.get("session"),o=t.get("gatewayUrl");let r=!1;if(n!=null){const a=n.trim();a&&a!==e.settings.token&&Ie(e,{...e.settings,token:a}),t.delete("token"),r=!0}if(s!=null){const a=s.trim();a&&(e.password=a),t.delete("password"),r=!0}if(i!=null){const a=i.trim();a&&(e.sessionKey=a,Ie(e,{...e.settings,sessionKey:a,lastActiveSessionKey:a}))}if(o!=null){const a=o.trim();a&&a!==e.settings.gatewayUrl&&Ie(e,{...e.settings,gatewayUrl:a}),t.delete("gatewayUrl"),r=!0}if(!r)return;const l=new URL(window.location.href);l.search=t.toString(),window.history.replaceState({},"",l.toString())}function dp(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?to(e):Ji(e):(eo(e),no(e)),t==="debug"?so(e):io(e),oo(e),fl(e,t,!1)}function pp(e,t,n){op({nextTheme:t,applyTheme:()=>{e.theme=t,Ie(e,{...e.settings,theme:t}),us(e,Zi(t))},context:n,currentTheme:e.theme})}async function oo(e){if(e.tab==="overview"&&await gl(e),e.tab==="channels"&&await bp(e),e.tab==="instances"&&await ll(e),e.tab==="cron"&&await ro(e),e.tab==="skills"&&await wt(e),e.tab==="nodes"&&(await Xi(e),await Yi(e),await we(e),await Qd(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await xp(e),en(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await Wa(e),await we(e)),e.tab==="debug"&&(await ji(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await $e(async()=>{const{loadSessionLogs:s}=await Promise.resolve().then(()=>ap);return{loadSessionLogs:s}},void 0,import.meta.url);await n(e,{reset:!0})}else await qt(e,{reset:!0});Fa(e,!0)}}function hp(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?cs(e):np(window.location.pathname)}function fp(e){e.theme=e.settings.theme??"system",us(e,Zi(e.theme))}function us(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function gp(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;if(e.themeMedia=window.matchMedia("(prefers-color-scheme: dark)"),e.themeMediaHandler=n=>{e.theme==="system"&&us(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function mp(e){if(!e.themeMedia||!e.themeMediaHandler)return;if(typeof e.themeMedia.removeEventListener=="function"){e.themeMedia.removeEventListener("change",e.themeMediaHandler);return}e.themeMedia.removeListener(e.themeMediaHandler),e.themeMedia=null,e.themeMediaHandler=null}function yp(e,t){if(typeof window>"u")return;const n=dl(window.location.pathname,e.basePath)??"chat";hl(e,n),fl(e,n,t)}function vp(e){if(typeof window>"u")return;const t=dl(window.location.pathname,e.basePath);if(!t)return;const s=new URL(window.location.href).searchParams.get("session")?.trim();s&&(e.sessionKey=s,Ie(e,{...e.settings,sessionKey:s,lastActiveSessionKey:s})),hl(e,t)}function hl(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?to(e):Ji(e):(eo(e),no(e)),t==="debug"?so(e):io(e),e.connected&&oo(e)}function fl(e,t,n){if(typeof window>"u")return;const s=Jt(tp(t,e.basePath)),i=Jt(window.location.pathname),o=new URL(window.location.href);t==="chat"&&e.sessionKey?o.searchParams.set("session",e.sessionKey):o.searchParams.delete("session"),i!==s&&(o.pathname=s),n?window.history.replaceState({},"",o.toString()):window.history.pushState({},"",o.toString())}async function gl(e){await Promise.all([z(e,!1),ll(e),Wi(e),tn(e),ji(e)])}async function bp(e){await Promise.all([z(e,!0),Wa(e),we(e)])}async function ro(e){await Promise.all([z(e,!1),tn(e),rs(e)])}function ml(e){return e.chatSending||!!e.chatRunId}function wp(e){const t=e.trim();if(!t)return!1;const n=t.toLowerCase();return n==="/stop"?!0:n==="stop"||n==="esc"||n==="abort"||n==="wait"||n==="exit"}async function yl(e){e.connected&&(e.chatMessage="",await Da(e))}function kp(e,t,n){const s=t.trim(),i=!!(n&&n.length>0);!s&&!i||(e.chatQueue=[...e.chatQueue,{id:Ui(),text:s,createdAt:Date.now(),attachments:i?n?.map(o=>({...o})):void 0}],en(e))}async function vl(e,t,n){Ki(e);const s=await Oa(e,t,n?.attachments);return!s&&n?.previousDraft!=null&&(e.chatMessage=n.previousDraft),!s&&n?.previousAttachments&&(e.chatAttachments=n.previousAttachments),s&&pl(e,e.sessionKey),s&&n?.restoreDraft&&n.previousDraft?.trim()&&(e.chatMessage=n.previousDraft),s&&n?.restoreAttachments&&n.previousAttachments?.length&&(e.chatAttachments=n.previousAttachments),en(e),s&&!e.chatRunId&&bl(e),s}async function bl(e){if(!e.connected||ml(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await vl(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function Sp(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function Ap(e,t,n){if(!e.connected)return;const s=e.chatMessage,i=(t??e.chatMessage).trim(),o=e.chatAttachments??[],r=t==null?o:[],l=r.length>0;if(!(!i&&!l)){if(wp(i)){await yl(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[]),ml(e)){kp(e,i,r);return}await vl(e,i,{previousDraft:t==null?s:void 0,restoreDraft:!!(t&&n?.restoreDraft),attachments:l?r:void 0,previousAttachments:t==null?o:void 0,restoreAttachments:!!(t&&n?.restoreDraft)})}}async function xp(e){await Promise.all([Ce(e),Wi(e),fi(e)]),en(e,!0)}const $p=bl;function Ep(e){const t=Ca(e.sessionKey);return t?.agentId?t.agentId:e.hello?.snapshot?.sessionDefaults?.defaultAgentId?.trim()||"main"}function Tp(e,t){const n=cs(e),s=encodeURIComponent(t);return n?`${n}/avatar/${s}?meta=1`:`/avatar/${s}?meta=1`}async function fi(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=Ep(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=Tp(e.basePath,t);try{const s=await fetch(n,{method:"GET"});if(!s.ok){e.chatAvatarUrl=null;return}const i=await s.json(),o=typeof i.avatarUrl=="string"?i.avatarUrl.trim():"";e.chatAvatarUrl=o||null}catch{e.chatAvatarUrl=null}}const N={messageSquare:d`<svg viewBox="0 0 24 24"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>`,barChart:d`<svg viewBox="0 0 24 24"><line x1="12" x2="12" y1="20" y2="10"/><line x1="18" x2="18" y1="20" y2="4"/><line x1="6" x2="6" y1="20" y2="16"/></svg>`,link:d`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,radio:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="2"/><path d="M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"/></svg>`,fileText:d`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><line x1="16" x2="8" y1="13" y2="13"/><line x1="16" x2="8" y1="17" y2="17"/><line x1="10" x2="8" y1="9" y2="9"/></svg>`,zap:d`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:d`<svg viewBox="0 0 24 24"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>`,settings:d`<svg viewBox="0 0 24 24"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>`,bug:d`<svg viewBox="0 0 24 24"><path d="m8 2 1.88 1.88"/><path d="M14.12 3.88 16 2"/><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"/><path d="M12 20v-9"/><path d="M6.53 9C4.6 8.8 3 7.1 3 5"/><path d="M6 13H2"/><path d="M3 21c0-2.1 1.7-3.9 3.8-4"/><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"/><path d="M22 13h-4"/><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4"/></svg>`,scrollText:d`<svg viewBox="0 0 24 24"><path d="M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/><path d="M15 8h-5"/><path d="M15 12h-5"/></svg>`,folder:d`<svg viewBox="0 0 24 24"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg>`,users:d`<svg viewBox="0 0 24 24"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>`,menu:d`<svg viewBox="0 0 24 24"><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/></svg>`,x:d`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:d`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:d`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,search:d`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:d`<svg viewBox="0 0 24 24"><path d="M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"/><path d="M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"/><path d="M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"/><path d="M17.599 6.5a3 3 0 0 0 .399-1.375"/><path d="M6.003 5.125A3 3 0 0 0 6.401 6.5"/><path d="M3.477 10.896a4 4 0 0 1 .585-.396"/><path d="M19.938 10.5a4 4 0 0 1 .585.396"/><path d="M6 18a4 4 0 0 1-1.967-.516"/><path d="M19.967 17.484A4 4 0 0 1 18 18"/></svg>`,book:d`<svg viewBox="0 0 24 24"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/></svg>`,loader:d`<svg viewBox="0 0 24 24"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>`,rotateCw:d`<svg viewBox="0 0 24 24"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/></svg>`,download:d`<svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`,wrench:d`<svg viewBox="0 0 24 24"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg>`,fileCode:d`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><path d="m10 13-2 2 2 2"/><path d="m14 17 2-2-2-2"/></svg>`,edit:d`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,penLine:d`<svg viewBox="0 0 24 24"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>`,paperclip:d`<svg viewBox="0 0 24 24"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`,globe:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>`,image:d`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>`,smartphone:d`<svg viewBox="0 0 24 24"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>`,plug:d`<svg viewBox="0 0 24 24"><path d="M12 22v-5"/><path d="M9 8V2"/><path d="M15 8V2"/><path d="M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z"/></svg>`,circle:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,puzzle:d`<svg viewBox="0 0 24 24"><path d="M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.076.874.54 1.02 1.02a2.5 2.5 0 1 0 3.237-3.237c-.48-.146-.944-.505-1.02-1.02a.98.98 0 0 1 .303-.917l1.526-1.526A2.402 2.402 0 0 1 11.998 2c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.236 3.236c-.464.18-.894.527-.967 1.02Z"/></svg>`,info:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>`,send:d`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:d`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>`,slidersHorizontal:d`<svg viewBox="0 0 24 24"><line x1="21" x2="14" y1="4" y2="4"/><line x1="10" x2="3" y1="4" y2="4"/><line x1="21" x2="12" y1="12" y2="12"/><line x1="8" x2="3" y1="12" y2="12"/><line x1="21" x2="16" y1="20" y2="20"/><line x1="12" x2="3" y1="20" y2="20"/><line x1="14" x2="14" y1="2" y2="6"/><line x1="8" x2="8" y1="10" y2="14"/><line x1="16" x2="16" y1="18" y2="22"/></svg>`,square:d`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:d`<svg viewBox="0 0 24 24"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>`,eyeOff:d`<svg viewBox="0 0 24 24"><path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,trash:d`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,chevronDown:d`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:d`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/></svg>`},Cp="Taskmaster",_p="/taskmaster-icon.png",wl="#00d4ff";let An=null;function De(){return An||(An={name:window.__TASKMASTER_BRAND_NAME__||Cp,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||_p,accentColor:window.__TASKMASTER_ACCENT_COLOR__||wl},An)}function Mp(e){const t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);return t?`${parseInt(t[1],16)}, ${parseInt(t[2],16)}, ${parseInt(t[3],16)}`:null}function Pp(e){if(e===wl)return;const t=Mp(e);if(!t)return;const n=document.documentElement;n.style.setProperty("--accent",e),n.style.setProperty("--accent-hover",e),n.style.setProperty("--accent-muted",e),n.style.setProperty("--primary",e),n.style.setProperty("--ring",e),n.style.setProperty("--accent-subtle",`rgba(${t}, 0.15)`),n.style.setProperty("--accent-glow",`rgba(${t}, 0.25)`),n.style.setProperty("--tasker-orange",e),n.style.setProperty("--tasker-orange-hover",e),n.style.setProperty("--tasker-orange-glow",`rgba(${t}, 0.25)`)}const Lp=d`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>`;let gr=!1;function Rp(){gr||(gr=!0,document.addEventListener("click",e=>{const t=document.getElementById("nav-burger-toggle");!t?.checked||t.closest(".setup-header")?.contains(e.target)||(t.checked=!1)}))}function tt(e,t){const n=(a,c)=>a===e?d`<span class="sp-page-nav-current">${a}</span>`:d`<a href=${c}>${a}</a>`,s=d`
19
19
  ${n("Setup","/setup")}
20
20
  ${n("Chat","/chat")}
21
21
  ${n("Admins","/admins")}
@@ -143,7 +143,7 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
143
143
  <p>Connecting to gateway...</p>
144
144
  </div>
145
145
  </div>
146
- `}const Gn="application/x-taskmaster-file-path";function wl(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function kl(e){const t=e.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function Op(e,t,n){e.preventDefault(),e.stopPropagation(),e.currentTarget.classList.remove("sp-drop-target");const s=e.dataTransfer?.getData(Gn);if(s){kl(s)!==t&&n.onMoveToDir(s,t);return}const i=e.dataTransfer?.files;if(i&&i.length>0){const o=Array.from(i).filter(r=>r.name.toLowerCase().endsWith(".md"));o.length>0&&n.onUpload(t,o)}}function Sl(e,t,n){const s=e.type==="directory"||e.type==="symlink"&&e.children!=null,i=t.expandedDirs.has(e.path),o=t.selectedPaths.has(e.path),r=n*20+12;return s?d`
146
+ `}const Gn="application/x-taskmaster-file-path";function kl(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Sl(e){const t=e.split("/");return t.length>1?t.slice(0,-1).join("/"):"."}function Op(e,t,n){e.preventDefault(),e.stopPropagation(),e.currentTarget.classList.remove("sp-drop-target");const s=e.dataTransfer?.getData(Gn);if(s){Sl(s)!==t&&n.onMoveToDir(s,t);return}const i=e.dataTransfer?.files;if(i&&i.length>0){const o=Array.from(i).filter(r=>r.name.toLowerCase().endsWith(".md"));o.length>0&&n.onUpload(t,o)}}function Al(e,t,n){const s=e.type==="directory"||e.type==="symlink"&&e.children!=null,i=t.expandedDirs.has(e.path),o=t.selectedPaths.has(e.path),r=n*20+12;return s?d`
147
147
  <div
148
148
  class="sp-tree-item sp-tree-dir ${i?"expanded":""}"
149
149
  style="padding-left: ${r}px;"
@@ -156,7 +156,7 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
156
156
  <span class="sp-tree-icon">${N.folder}</span>
157
157
  <span class="sp-tree-name">${e.name}</span>
158
158
  </div>
159
- ${i&&e.children?e.children.map(l=>Sl(l,t,n+1)):b}
159
+ ${i&&e.children?e.children.map(l=>Al(l,t,n+1)):b}
160
160
  `:d`
161
161
  <div
162
162
  class="sp-tree-item sp-tree-file ${o?"selected":""}"
@@ -167,7 +167,7 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
167
167
  >
168
168
  <span class="sp-tree-icon">${N.fileText}</span>
169
169
  <span class="sp-tree-name">${e.name}</span>
170
- <span class="sp-tree-size">${wl(e.size)}</span>
170
+ <span class="sp-tree-size">${kl(e.size)}</span>
171
171
  </div>
172
172
  `}function Dp(e){const t=e.selectedPaths.size;return t<2?b:d`
173
173
  <div class="sp-bulk-actions">
@@ -190,7 +190,7 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
190
190
  <div>
191
191
  <strong>${t}</strong>
192
192
  <div class="sp-file-preview-meta">
193
- ${e.selectedPath}${e.previewSize!=null?` — ${wl(e.previewSize)}`:""}
193
+ ${e.selectedPath}${e.previewSize!=null?` — ${kl(e.previewSize)}`:""}
194
194
  </div>
195
195
  </div>
196
196
  <div class="sp-file-actions">
@@ -261,9 +261,9 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
261
261
  <div
262
262
  class="sp-file-tree"
263
263
  @dragover=${n=>{n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(Gn)?"move":"copy")}}
264
- @drop=${n=>{n.preventDefault();const s=n.dataTransfer?.getData(Gn);if(s){kl(s)!=="."&&e.onMoveToDir(s,".");return}const i=n.dataTransfer?.files;if(i&&i.length>0){const o=Array.from(i).filter(r=>r.name.toLowerCase().endsWith(".md"));o.length>0&&e.onUpload(t,o)}}}
264
+ @drop=${n=>{n.preventDefault();const s=n.dataTransfer?.getData(Gn);if(s){Sl(s)!=="."&&e.onMoveToDir(s,".");return}const i=n.dataTransfer?.files;if(i&&i.length>0){const o=Array.from(i).filter(r=>r.name.toLowerCase().endsWith(".md"));o.length>0&&e.onUpload(t,o)}}}
265
265
  >
266
- ${e.tree.length===0&&!e.loading?d`<div style="padding: 24px; color: var(--tasker-muted-grey); text-align: center;">No files found. Drop .md files here to upload.</div>`:e.tree.map(n=>Sl(n,e,0))}
266
+ ${e.tree.length===0&&!e.loading?d`<div style="padding: 24px; color: var(--tasker-muted-grey); text-align: center;">No files found. Drop .md files here to upload.</div>`:e.tree.map(n=>Al(n,e,0))}
267
267
  </div>
268
268
 
269
269
  ${Dp(e)}
@@ -952,7 +952,6 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
952
952
  </div>
953
953
  </div>
954
954
  `}function xr(e){const t=e.updateAvailable===null?"unknown":e.updateAvailable?"partial":"good",n=e.updateAvailable&&e.latestVersion?`v${e.currentVersion} → v${e.latestVersion}`:e.currentVersion?`v${e.currentVersion}`:"Unknown",s=e.updateChecking||e.updateRunning;return d`
955
- ${Yp(e)}
956
955
  <div class="setup-status-item">
957
956
  ${le(t)}
958
957
  <div class="setup-status-info">
@@ -980,32 +979,47 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
980
979
  </button>
981
980
  `}
982
981
  </div>
983
- ${Qp(e)}
984
- `}function Qp(e){return!e.updateRunning||e.updateProgressSteps.length===0?b:d`
985
- <div class="setup-update-progress">
986
- ${e.updateProgressSteps.map(t=>d`
987
- <div class="setup-update-step ${t.status}">
988
- <span class="setup-update-step-icon">
989
- ${t.status==="running"?d`<span class="setup-update-spinner"></span>`:t.status==="done"?d`<span class="setup-update-check">&#10003;</span>`:d`<span class="setup-update-cross">&#10007;</span>`}
990
- </span>
991
- <span class="setup-update-step-name">${t.name}</span>
992
- ${t.durationMs!=null?d`<span class="setup-update-step-time">${Al(t.durationMs)}</span>`:b}
993
- </div>
994
- `)}
995
- ${e.updateMessage?d`<div class="setup-update-status">${e.updateMessage}</div>`:b}
996
- </div>
997
- `}function Yp(e){const t=e.updateLastResult;if(!t)return b;const n=t.status==="ok",s=n?"setup-update-banner success":"setup-update-banner error";let i;if(n){const r=t.before?.version,l=t.after?.version??t.currentVersion;i=r?`Updated: v${r} → v${l}`:`Updated to v${l}`}else i=`Update failed: ${t.reason??t.failedStep?.name??"unknown error"}`;const o=t.durationMs!=null?Al(t.durationMs):null;return d`
998
- <div class="${s}">
999
- <div class="setup-update-banner-content">
1000
- <span class="setup-update-banner-icon">${n?"&#10003;":"&#10007;"}</span>
1001
- <span class="setup-update-banner-text">
1002
- ${i}
1003
- ${o?d` <span class="setup-update-banner-duration">(${o})</span>`:b}
1004
- </span>
982
+ `}function Qp(e){const t=e.updateRunning,n=e.updateLastResult;if(!t&&!n)return b;if(t)return d`
983
+ <div class="setup-info-overlay">
984
+ <div class="setup-info-card" style="max-width: 400px;">
985
+ <h3>Software Update</h3>
986
+ ${e.updateProgressSteps.length>0?d`
987
+ <div class="setup-update-progress">
988
+ ${e.updateProgressSteps.map(s=>d`
989
+ <div class="setup-update-step ${s.status}">
990
+ <span class="setup-update-step-icon">
991
+ ${s.status==="running"?d`<span class="setup-update-spinner"></span>`:s.status==="done"?d`<span class="setup-update-check">&#10003;</span>`:d`<span class="setup-update-cross">&#10007;</span>`}
992
+ </span>
993
+ <span class="setup-update-step-name">${s.name}</span>
994
+ ${s.durationMs!=null?d`<span class="setup-update-step-time">${$r(s.durationMs)}</span>`:b}
995
+ </div>
996
+ `)}
997
+ </div>
998
+ `:d`<div class="setup-spinner" style="margin: 16px auto;"></div>`}
999
+ ${e.updateMessage?d`<p style="text-align: center; color: var(--tasker-text-grey); font-size: 13px; margin: 12px 0 0;">${e.updateMessage}</p>`:b}
1000
+ </div>
1001
+ </div>
1002
+ `;if(n){const s=n.status==="ok";let i;if(s){const r=n.before?.version,l=n.after?.version??n.currentVersion;i=r?`v${r} → v${l}`:`Updated to v${l}`}else i=n.reason??n.failedStep?.name??"unknown error";const o=n.durationMs!=null?$r(n.durationMs):null;return d`
1003
+ <div class="setup-info-overlay" @click=${r=>{r.target.classList.contains("setup-info-overlay")&&e.onUpdateDismissResult()}}>
1004
+ <div class="setup-info-card" style="max-width: 360px; text-align: center;">
1005
+ <div style="font-size: 40px; margin-bottom: 8px;">${s?"✓":"✗"}</div>
1006
+ <h3 style="color: ${s?"#22c55e":"#ef4444"};">
1007
+ ${s?"Update Complete":"Update Failed"}
1008
+ </h3>
1009
+ <p style="color: var(--tasker-text-grey); font-size: 14px; margin: 8px 0;">
1010
+ ${i}
1011
+ </p>
1012
+ ${o?d`<p style="color: rgba(255,255,255,0.3); font-size: 12px; margin: 4px 0 0;">${o}</p>`:b}
1013
+ <button
1014
+ class="setup-button secondary"
1015
+ style="margin-top: 20px; width: 100%; padding: 10px;"
1016
+ @click=${e.onUpdateDismissResult}
1017
+ >
1018
+ Close
1019
+ </button>
1020
+ </div>
1005
1021
  </div>
1006
- <button class="setup-update-banner-dismiss" @click=${e.onUpdateDismissResult} title="Dismiss">&times;</button>
1007
- </div>
1008
- `}function Al(e){if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return s>0?`${n}m ${s}s`:`${n}m`}function Xp(e){const t=e.accountHasPin;return d`
1022
+ `}return b}function $r(e){if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return s>0?`${n}m ${s}s`:`${n}m`}function Yp(e){const t=e.accountHasPin;return d`
1009
1023
  <div class="setup-status-item">
1010
1024
  ${le(t?"good":"bad")}
1011
1025
  <div class="setup-status-info">
@@ -1017,7 +1031,7 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
1017
1031
  @click=${()=>e.onAccountPinModalOpen()}
1018
1032
  >${t?"Change":"Set PIN"}</button>
1019
1033
  </div>
1020
- `}function Zp(e){if(!e.accountPinModalOpen)return b;const t=e.accountHasPin,n=e.accountPinBusy;let s="",i="",o="";const r=c=>u=>{const p=u.target;p.value=p.value.replace(/\D/g,"").slice(0,6),c(p.value)},l=(c,u)=>{let p=c.querySelector(".pin-modal-validation");p||(p=document.createElement("p"),p.className="login-error pin-modal-validation",c.querySelector("button[type=submit]")?.before(p)),p.textContent=u},a=c=>{c.preventDefault();const u=c.target;if(!n){if(t&&!s){l(u,"Enter your current PIN");return}if(!i){l(u,"Enter a new PIN");return}if(!o){l(u,"Confirm your new PIN");return}if(i!==o){l(u,"PINs do not match");return}if(i.length<4){l(u,"PIN must be 4–6 digits");return}e.onAccountPinSave(t?s:null,i)}};return d`
1034
+ `}function Xp(e){if(!e.accountPinModalOpen)return b;const t=e.accountHasPin,n=e.accountPinBusy;let s="",i="",o="";const r=c=>u=>{const p=u.target;p.value=p.value.replace(/\D/g,"").slice(0,6),c(p.value)},l=(c,u)=>{let p=c.querySelector(".pin-modal-validation");p||(p=document.createElement("p"),p.className="login-error pin-modal-validation",c.querySelector("button[type=submit]")?.before(p)),p.textContent=u},a=c=>{c.preventDefault();const u=c.target;if(!n){if(t&&!s){l(u,"Enter your current PIN");return}if(!i){l(u,"Enter a new PIN");return}if(!o){l(u,"Confirm your new PIN");return}if(i!==o){l(u,"PINs do not match");return}if(i.length<4){l(u,"PIN must be 4–6 digits");return}e.onAccountPinSave(t?s:null,i)}};return d`
1021
1035
  <div class="setup-info-overlay" @click=${c=>{c.target.classList.contains("setup-info-overlay")&&e.onAccountPinModalClose()}}>
1022
1036
  <div class="setup-info-card" style="max-width: 340px;">
1023
1037
  <div class="setup-info-header">
@@ -1074,7 +1088,7 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
1074
1088
  </form>
1075
1089
  </div>
1076
1090
  </div>
1077
- `}function $r(e){if(!e.addingWorkspace)return b;const{workspaceSaving:t}=e;return d`
1091
+ `}function Er(e){if(!e.addingWorkspace)return b;const{workspaceSaving:t}=e;return d`
1078
1092
  <div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 16px;">
1079
1093
  <div class="setup-add-account">
1080
1094
  <strong>New Account</strong>
@@ -1127,7 +1141,7 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
1127
1141
  </div>
1128
1142
  </div>
1129
1143
  </div>
1130
- `}function Er(e){const t=xt(e);return!t||t.isDefault?b:e.workspaceRemoveConfirm===t.name?d`
1144
+ `}function Tr(e){const t=xt(e);return!t||t.isDefault?b:e.workspaceRemoveConfirm===t.name?d`
1131
1145
  <div style="margin-top: 16px; border-top: 1px solid var(--tasker-border, rgba(255,255,255,0.1)); padding-top: 12px;">
1132
1146
  <div style="font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
1133
1147
  <span style="color: var(--tasker-danger, #ef4444);">Remove "${t.displayName??t.name}" and its WhatsApp account?</span>
@@ -1156,7 +1170,7 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
1156
1170
  @click=${s=>{s.preventDefault(),e.onSetWorkspaceRemoveConfirm(t.name)}}
1157
1171
  >Remove Account</a>
1158
1172
  </p>
1159
- `}function Jp(e){const{whatsappBusy:t,whatsappLoginMessage:n,whatsappLoginQrDataUrl:s,whatsappLoginConnected:i,whatsappChannelStatus:o}=e;if(s)return d`
1173
+ `}function Zp(e){const{whatsappBusy:t,whatsappLoginMessage:n,whatsappLoginQrDataUrl:s,whatsappLoginConnected:i,whatsappChannelStatus:o}=e;if(s)return d`
1160
1174
  <div class="setup-container">
1161
1175
  <div class="setup-card">
1162
1176
  <h1>Scan with WhatsApp</h1>
@@ -1200,14 +1214,14 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
1200
1214
  ${wr(e)}
1201
1215
  ${kr(e)}
1202
1216
  ${Sr(e)}
1203
- ${Xp(e)}
1217
+ ${Yp(e)}
1204
1218
  ${xr(e)}
1205
1219
  </div>
1206
1220
 
1207
- ${Zp(e)}
1221
+ ${Xp(e)}
1208
1222
  ${Ar(e)}
1209
- ${$r(e)}
1210
1223
  ${Er(e)}
1224
+ ${Tr(e)}
1211
1225
  ${e.workspacesError?d`<p class="setup-error" style="margin-top: 8px;">${e.workspacesError}</p>`:b}
1212
1226
  </div>
1213
1227
  </div>
@@ -1225,8 +1239,8 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
1225
1239
  </div>
1226
1240
 
1227
1241
  ${Ar(e)}
1228
- ${$r(e)}
1229
1242
  ${Er(e)}
1243
+ ${Tr(e)}
1230
1244
  ${e.workspacesError?d`<p class="setup-error" style="margin-top: 8px;">${e.workspacesError}</p>`:b}
1231
1245
  </div>
1232
1246
  </div>
@@ -1271,14 +1285,14 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
1271
1285
  </button>
1272
1286
  </div>
1273
1287
  </div>
1274
- `}function eh(e){const{connected:t,currentStep:n}=e;if(!t)return d`
1288
+ `}function Jp(e){const{connected:t,currentStep:n}=e;if(!t){const o=e.updateRunning;return d`
1275
1289
  <div class="setup-container">
1276
1290
  <div class="setup-card">
1277
1291
  <div class="setup-spinner"></div>
1278
- <p>Connecting to gateway...</p>
1292
+ <p>${o?"Restarting gateway after update…":"Connecting to gateway..."}</p>
1279
1293
  </div>
1280
1294
  </div>
1281
- `;let s;switch(n){case"license":s=mr(e);break;case"auth":s=Kp(e);break;case"whatsapp":case"complete":s=Jp(e);break;default:s=mr(e)}const i=tt("Setup",e.wsProps);return d`${s}${Wp(e)}${Gp(e)}${qp(e)}${i}`}function th(e,t){const n=e.paired?"Paired phone (used to link WhatsApp)":"Admin access via WhatsApp DM";return d`
1295
+ `}let s;switch(n){case"license":s=mr(e);break;case"auth":s=Kp(e);break;case"whatsapp":case"complete":s=Zp(e);break;default:s=mr(e)}const i=tt("Setup",e.wsProps);return d`${s}${Wp(e)}${Gp(e)}${qp(e)}${Qp(e)}${i}`}function eh(e,t){const n=e.paired?"Paired phone (used to link WhatsApp)":"Admin access via WhatsApp DM";return d`
1282
1296
  <div class="sp-list-item">
1283
1297
  <div class="sp-list-item-main">
1284
1298
  <div class="sp-list-item-title">${e.phone}</div>
@@ -1293,7 +1307,7 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
1293
1307
  Remove
1294
1308
  </button>`}
1295
1309
  </div>
1296
- `}function nh(e){if(!e.connected)return d`
1310
+ `}function th(e){if(!e.connected)return d`
1297
1311
  <div class="setup-container">
1298
1312
  <div class="setup-card">
1299
1313
  <div class="setup-spinner"></div>
@@ -1342,7 +1356,7 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
1342
1356
  </form>
1343
1357
 
1344
1358
  <div class="sp-list" style="margin-top: 20px;">
1345
- ${e.phones.length===0?d`<div class="sp-list-empty">No admin phones configured yet.</div>`:e.phones.map(n=>th(n,e))}
1359
+ ${e.phones.length===0?d`<div class="sp-list-empty">No admin phones configured yet.</div>`:e.phones.map(n=>eh(n,e))}
1346
1360
  </div>
1347
1361
 
1348
1362
  <div class="setup-hint" style="margin-top: 20px; padding: 14px; background: rgba(0, 0, 0, 0.2); border-radius: 8px; text-align: left;">
@@ -1353,7 +1367,7 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
1353
1367
 
1354
1368
  </div>
1355
1369
  </div>
1356
- `}function sh(e){return Object.keys(e.fields).length}function ih(e,t){const n=Object.entries(e.fields);return d`
1370
+ `}function nh(e){return Object.keys(e.fields).length}function sh(e,t){const n=Object.entries(e.fields);return d`
1357
1371
  <div class="customers-record-fields">
1358
1372
  ${n.length===0?d`<div style="color: rgba(255,255,255,0.4); font-size: 13px; margin-top: 12px;">No fields yet. Add one below.</div>`:n.map(([s,i])=>d`
1359
1373
  <div class="customers-field-row">
@@ -1400,7 +1414,7 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
1400
1414
  </button>
1401
1415
  </div>
1402
1416
  </div>
1403
- `}function oh(e,t){const n=t.editingId===e.id,s=sh(e),i=s===0?"No fields":`${s} field${s>1?"s":""}`;return d`
1417
+ `}function ih(e,t){const n=t.editingId===e.id,s=nh(e),i=s===0?"No fields":`${s} field${s>1?"s":""}`;return d`
1404
1418
  <div class="customers-record">
1405
1419
  <div
1406
1420
  class="customers-record-header"
@@ -1412,9 +1426,9 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
1412
1426
  </div>
1413
1427
  <span class="customers-record-meta">${i}</span>
1414
1428
  </div>
1415
- ${n?ih(e,t):b}
1429
+ ${n?sh(e,t):b}
1416
1430
  </div>
1417
- `}function rh(e){if(!e.connected)return d`
1431
+ `}function oh(e){if(!e.connected)return d`
1418
1432
  <div class="setup-container">
1419
1433
  <div class="setup-card">
1420
1434
  <div class="setup-spinner"></div>
@@ -1510,7 +1524,7 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
1510
1524
  <div style="margin-top: 16px;">
1511
1525
  ${e.records.length===0?d`<div class="customers-empty">
1512
1526
  ${e.searchQuery.trim()?`No records matching "${e.searchQuery}".`:"No customer records yet. Add one to get started."}
1513
- </div>`:e.records.map(s=>oh(s,e))}
1527
+ </div>`:e.records.map(s=>ih(s,e))}
1514
1528
  </div>
1515
1529
 
1516
1530
  <div class="setup-hint" style="margin-top: 20px; padding: 14px; background: rgba(0, 0, 0, 0.2); border-radius: 8px; text-align: left;">
@@ -1521,12 +1535,12 @@ ${s}`:c.join(", ");a.push({type:"text",text:v})}else s&&a.push({type:"text",text
1521
1535
  </div>
1522
1536
  </div>
1523
1537
  </div>
1524
- `}const xl={CHILD:2},$l=e=>(...t)=>({_$litDirective$:e,values:t});let El=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,s){this._$Ct=t,this._$AM=n,this._$Ci=s}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}};const{I:ah}=lu,Tr=e=>e,Cr=()=>document.createComment(""),Pt=(e,t,n)=>{const s=e._$AA.parentNode,i=t===void 0?e._$AB:t._$AA;if(n===void 0){const o=s.insertBefore(Cr(),i),r=s.insertBefore(Cr(),i);n=new ah(o,r,e,e.options)}else{const o=n._$AB.nextSibling,r=n._$AM,l=r!==e;if(l){let a;n._$AQ?.(e),n._$AM=e,n._$AP!==void 0&&(a=e._$AU)!==r._$AU&&n._$AP(a)}if(o!==i||l){let a=n._$AA;for(;a!==o;){const c=Tr(a).nextSibling;Tr(s).insertBefore(a,i),a=c}}}return n},je=(e,t,n=e)=>(e._$AI(t,n),e),lh={},ch=(e,t=lh)=>e._$AH=t,uh=e=>e._$AH,Fs=e=>{e._$AR(),e._$AA.remove()};const _r=(e,t,n)=>{const s=new Map;for(let i=t;i<=n;i++)s.set(e[i],i);return s},dh=$l(class extends El{constructor(e){if(super(e),e.type!==xl.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let s;n===void 0?n=t:t!==void 0&&(s=t);const i=[],o=[];let r=0;for(const l of e)i[r]=s?s(l,r):r,o[r]=n(l,r),r++;return{values:o,keys:i}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,s]){const i=uh(e),{values:o,keys:r}=this.dt(t,n,s);if(!Array.isArray(i))return this.ut=r,o;const l=this.ut??=[],a=[];let c,u,p=0,m=i.length-1,v=0,w=o.length-1;for(;p<=m&&v<=w;)if(i[p]===null)p++;else if(i[m]===null)m--;else if(l[p]===r[v])a[v]=je(i[p],o[v]),p++,v++;else if(l[m]===r[w])a[w]=je(i[m],o[w]),m--,w--;else if(l[p]===r[w])a[w]=je(i[p],o[w]),Pt(e,a[w+1],i[p]),p++,w--;else if(l[m]===r[v])a[v]=je(i[m],o[v]),Pt(e,i[p],i[m]),m--,v++;else if(c===void 0&&(c=_r(r,v,w),u=_r(l,p,m)),c.has(l[p]))if(c.has(l[m])){const x=u.get(r[v]),_=x!==void 0?i[x]:null;if(_===null){const j=Pt(e,i[p]);je(j,o[v]),a[v]=j}else a[v]=je(_,o[v]),Pt(e,i[p],_),i[x]=null;v++}else Fs(i[m]),m--;else Fs(i[p]),p++;for(;v<=w;){const x=Pt(e,a[w+1]);je(x,o[v]),a[v++]=x}for(;p<=m;){const x=i[p++];x!==null&&Fs(x)}return this.ut=r,ch(e,a),Ne}});class gi extends El{constructor(t){if(super(t),this.it=b,t.type!==xl.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===b||t==null)return this._t=void 0,this.it=t;if(t===Ne)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const n=[t];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}}gi.directiveName="unsafeHTML",gi.resultType=1;const mi=$l(gi);const{entries:Tl,setPrototypeOf:Mr,isFrozen:ph,getPrototypeOf:hh,getOwnPropertyDescriptor:fh}=Object;let{freeze:ie,seal:ce,create:yi}=Object,{apply:vi,construct:bi}=typeof Reflect<"u"&&Reflect;ie||(ie=function(t){return t});ce||(ce=function(t){return t});vi||(vi=function(t,n){for(var s=arguments.length,i=new Array(s>2?s-2:0),o=2;o<s;o++)i[o-2]=arguments[o];return t.apply(n,i)});bi||(bi=function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return new t(...s)});const xn=oe(Array.prototype.forEach),gh=oe(Array.prototype.lastIndexOf),Pr=oe(Array.prototype.pop),Lt=oe(Array.prototype.push),mh=oe(Array.prototype.splice),Nn=oe(String.prototype.toLowerCase),Us=oe(String.prototype.toString),Ws=oe(String.prototype.match),Rt=oe(String.prototype.replace),yh=oe(String.prototype.indexOf),vh=oe(String.prototype.trim),de=oe(Object.prototype.hasOwnProperty),ne=oe(RegExp.prototype.test),It=bh(TypeError);function oe(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return vi(e,t,s)}}function bh(e){return function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return bi(e,n)}}function R(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Nn;Mr&&Mr(e,null);let s=t.length;for(;s--;){let i=t[s];if(typeof i=="string"){const o=n(i);o!==i&&(ph(t)||(t[s]=o),i=o)}e[i]=!0}return e}function wh(e){for(let t=0;t<e.length;t++)de(e,t)||(e[t]=null);return e}function be(e){const t=yi(null);for(const[n,s]of Tl(e))de(e,n)&&(Array.isArray(s)?t[n]=wh(s):s&&typeof s=="object"&&s.constructor===Object?t[n]=be(s):t[n]=s);return t}function Nt(e,t){for(;e!==null;){const s=fh(e,t);if(s){if(s.get)return oe(s.get);if(typeof s.value=="function")return oe(s.value)}e=hh(e)}function n(){return null}return n}const Lr=ie(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ks=ie(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),zs=ie(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),kh=ie(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),js=ie(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Sh=ie(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Rr=ie(["#text"]),Ir=ie(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Hs=ie(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Nr=ie(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),$n=ie(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ah=ce(/\{\{[\w\W]*|[\w\W]*\}\}/gm),xh=ce(/<%[\w\W]*|[\w\W]*%>/gm),$h=ce(/\$\{[\w\W]*/gm),Eh=ce(/^data-[\-\w.\u00B7-\uFFFF]+$/),Th=ce(/^aria-[\-\w]+$/),Cl=ce(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ch=ce(/^(?:\w+script|data):/i),_h=ce(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),_l=ce(/^html$/i),Mh=ce(/^[a-z][.\w]*(-[.\w]+)+$/i);var Or=Object.freeze({__proto__:null,ARIA_ATTR:Th,ATTR_WHITESPACE:_h,CUSTOM_ELEMENT:Mh,DATA_ATTR:Eh,DOCTYPE_NAME:_l,ERB_EXPR:xh,IS_ALLOWED_URI:Cl,IS_SCRIPT_OR_DATA:Ch,MUSTACHE_EXPR:Ah,TMPLIT_EXPR:$h});const Ot={element:1,text:3,progressingInstruction:7,comment:8,document:9},Ph=function(){return typeof window>"u"?null:window},Lh=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let s=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(s=n.getAttribute(i));const o="dompurify"+(s?"#"+s:"");try{return t.createPolicy(o,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Dr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ml(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ph();const t=T=>Ml(T);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==Ot.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const s=n,i=s.currentScript,{DocumentFragment:o,HTMLTemplateElement:r,Node:l,Element:a,NodeFilter:c,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:m,trustedTypes:v}=e,w=a.prototype,x=Nt(w,"cloneNode"),_=Nt(w,"remove"),j=Nt(w,"nextSibling"),C=Nt(w,"childNodes"),L=Nt(w,"parentNode");if(typeof r=="function"){const T=n.createElement("template");T.content&&T.content.ownerDocument&&(n=T.content.ownerDocument)}let I,B="";const{implementation:ue,createNodeIterator:it,createDocumentFragment:gs,getElementsByTagName:ms}=n,{importNode:an}=s;let Y=Dr();t.isSupported=typeof Tl=="function"&&typeof L=="function"&&ue&&ue.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Et,ERB_EXPR:ot,TMPLIT_EXPR:Ue,DATA_ATTR:ys,ARIA_ATTR:vs,IS_SCRIPT_OR_DATA:bs,ATTR_WHITESPACE:ln,CUSTOM_ELEMENT:ws}=Or;let{IS_ALLOWED_URI:cn}=Or,H=null;const un=R({},[...Lr,...Ks,...zs,...js,...Rr]);let q=null;const dn=R({},[...Ir,...Hs,...Nr,...$n]);let W=Object.seal(yi(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),We=null,Tt=null;const Me=Object.seal(yi(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let pn=!0,k=!0,A=!1,M=!0,P=!1,K=!0,F=!1,te=!1,Pe=!1,rt=!1,hn=!1,fn=!1,To=!0,Co=!1;const Lc="user-content-";let ks=!0,Ct=!1,at={},ge=null;const Ss=R({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let _o=null;const Mo=R({},["audio","video","img","source","image","track"]);let As=null;const Po=R({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),gn="http://www.w3.org/1998/Math/MathML",mn="http://www.w3.org/2000/svg",ke="http://www.w3.org/1999/xhtml";let lt=ke,xs=!1,$s=null;const Rc=R({},[gn,mn,ke],Us);let yn=R({},["mi","mo","mn","ms","mtext"]),vn=R({},["annotation-xml"]);const Ic=R({},["title","style","font","a","script"]);let _t=null;const Nc=["application/xhtml+xml","text/html"],Oc="text/html";let V=null,ct=null;const Dc=n.createElement("form"),Lo=function(y){return y instanceof RegExp||y instanceof Function},Es=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(ct&&ct===y)){if((!y||typeof y!="object")&&(y={}),y=be(y),_t=Nc.indexOf(y.PARSER_MEDIA_TYPE)===-1?Oc:y.PARSER_MEDIA_TYPE,V=_t==="application/xhtml+xml"?Us:Nn,H=de(y,"ALLOWED_TAGS")?R({},y.ALLOWED_TAGS,V):un,q=de(y,"ALLOWED_ATTR")?R({},y.ALLOWED_ATTR,V):dn,$s=de(y,"ALLOWED_NAMESPACES")?R({},y.ALLOWED_NAMESPACES,Us):Rc,As=de(y,"ADD_URI_SAFE_ATTR")?R(be(Po),y.ADD_URI_SAFE_ATTR,V):Po,_o=de(y,"ADD_DATA_URI_TAGS")?R(be(Mo),y.ADD_DATA_URI_TAGS,V):Mo,ge=de(y,"FORBID_CONTENTS")?R({},y.FORBID_CONTENTS,V):Ss,We=de(y,"FORBID_TAGS")?R({},y.FORBID_TAGS,V):be({}),Tt=de(y,"FORBID_ATTR")?R({},y.FORBID_ATTR,V):be({}),at=de(y,"USE_PROFILES")?y.USE_PROFILES:!1,pn=y.ALLOW_ARIA_ATTR!==!1,k=y.ALLOW_DATA_ATTR!==!1,A=y.ALLOW_UNKNOWN_PROTOCOLS||!1,M=y.ALLOW_SELF_CLOSE_IN_ATTR!==!1,P=y.SAFE_FOR_TEMPLATES||!1,K=y.SAFE_FOR_XML!==!1,F=y.WHOLE_DOCUMENT||!1,rt=y.RETURN_DOM||!1,hn=y.RETURN_DOM_FRAGMENT||!1,fn=y.RETURN_TRUSTED_TYPE||!1,Pe=y.FORCE_BODY||!1,To=y.SANITIZE_DOM!==!1,Co=y.SANITIZE_NAMED_PROPS||!1,ks=y.KEEP_CONTENT!==!1,Ct=y.IN_PLACE||!1,cn=y.ALLOWED_URI_REGEXP||Cl,lt=y.NAMESPACE||ke,yn=y.MATHML_TEXT_INTEGRATION_POINTS||yn,vn=y.HTML_INTEGRATION_POINTS||vn,W=y.CUSTOM_ELEMENT_HANDLING||{},y.CUSTOM_ELEMENT_HANDLING&&Lo(y.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(W.tagNameCheck=y.CUSTOM_ELEMENT_HANDLING.tagNameCheck),y.CUSTOM_ELEMENT_HANDLING&&Lo(y.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(W.attributeNameCheck=y.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),y.CUSTOM_ELEMENT_HANDLING&&typeof y.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(W.allowCustomizedBuiltInElements=y.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),P&&(k=!1),hn&&(rt=!0),at&&(H=R({},Rr),q=[],at.html===!0&&(R(H,Lr),R(q,Ir)),at.svg===!0&&(R(H,Ks),R(q,Hs),R(q,$n)),at.svgFilters===!0&&(R(H,zs),R(q,Hs),R(q,$n)),at.mathMl===!0&&(R(H,js),R(q,Nr),R(q,$n))),y.ADD_TAGS&&(typeof y.ADD_TAGS=="function"?Me.tagCheck=y.ADD_TAGS:(H===un&&(H=be(H)),R(H,y.ADD_TAGS,V))),y.ADD_ATTR&&(typeof y.ADD_ATTR=="function"?Me.attributeCheck=y.ADD_ATTR:(q===dn&&(q=be(q)),R(q,y.ADD_ATTR,V))),y.ADD_URI_SAFE_ATTR&&R(As,y.ADD_URI_SAFE_ATTR,V),y.FORBID_CONTENTS&&(ge===Ss&&(ge=be(ge)),R(ge,y.FORBID_CONTENTS,V)),y.ADD_FORBID_CONTENTS&&(ge===Ss&&(ge=be(ge)),R(ge,y.ADD_FORBID_CONTENTS,V)),ks&&(H["#text"]=!0),F&&R(H,["html","head","body"]),H.table&&(R(H,["tbody"]),delete We.tbody),y.TRUSTED_TYPES_POLICY){if(typeof y.TRUSTED_TYPES_POLICY.createHTML!="function")throw It('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof y.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw It('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');I=y.TRUSTED_TYPES_POLICY,B=I.createHTML("")}else I===void 0&&(I=Lh(v,i)),I!==null&&typeof B=="string"&&(B=I.createHTML(""));ie&&ie(y),ct=y}},Ro=R({},[...Ks,...zs,...kh]),Io=R({},[...js,...Sh]),Bc=function(y){let S=L(y);(!S||!S.tagName)&&(S={namespaceURI:lt,tagName:"template"});const E=Nn(y.tagName),U=Nn(S.tagName);return $s[y.namespaceURI]?y.namespaceURI===mn?S.namespaceURI===ke?E==="svg":S.namespaceURI===gn?E==="svg"&&(U==="annotation-xml"||yn[U]):!!Ro[E]:y.namespaceURI===gn?S.namespaceURI===ke?E==="math":S.namespaceURI===mn?E==="math"&&vn[U]:!!Io[E]:y.namespaceURI===ke?S.namespaceURI===mn&&!vn[U]||S.namespaceURI===gn&&!yn[U]?!1:!Io[E]&&(Ic[E]||!Ro[E]):!!(_t==="application/xhtml+xml"&&$s[y.namespaceURI]):!1},me=function(y){Lt(t.removed,{element:y});try{L(y).removeChild(y)}catch{_(y)}},Ke=function(y,S){try{Lt(t.removed,{attribute:S.getAttributeNode(y),from:S})}catch{Lt(t.removed,{attribute:null,from:S})}if(S.removeAttribute(y),y==="is")if(rt||hn)try{me(S)}catch{}else try{S.setAttribute(y,"")}catch{}},No=function(y){let S=null,E=null;if(Pe)y="<remove></remove>"+y;else{const G=Ws(y,/^[\r\n\t ]+/);E=G&&G[0]}_t==="application/xhtml+xml"&&lt===ke&&(y='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+y+"</body></html>");const U=I?I.createHTML(y):y;if(lt===ke)try{S=new m().parseFromString(U,_t)}catch{}if(!S||!S.documentElement){S=ue.createDocument(lt,"template",null);try{S.documentElement.innerHTML=xs?B:U}catch{}}const Z=S.body||S.documentElement;return y&&E&&Z.insertBefore(n.createTextNode(E),Z.childNodes[0]||null),lt===ke?ms.call(S,F?"html":"body")[0]:F?S.documentElement:Z},Oo=function(y){return it.call(y.ownerDocument||y,y,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Ts=function(y){return y instanceof p&&(typeof y.nodeName!="string"||typeof y.textContent!="string"||typeof y.removeChild!="function"||!(y.attributes instanceof u)||typeof y.removeAttribute!="function"||typeof y.setAttribute!="function"||typeof y.namespaceURI!="string"||typeof y.insertBefore!="function"||typeof y.hasChildNodes!="function")},Do=function(y){return typeof l=="function"&&y instanceof l};function Se(T,y,S){xn(T,E=>{E.call(t,y,S,ct)})}const Bo=function(y){let S=null;if(Se(Y.beforeSanitizeElements,y,null),Ts(y))return me(y),!0;const E=V(y.nodeName);if(Se(Y.uponSanitizeElement,y,{tagName:E,allowedTags:H}),K&&y.hasChildNodes()&&!Do(y.firstElementChild)&&ne(/<[/\w!]/g,y.innerHTML)&&ne(/<[/\w!]/g,y.textContent)||y.nodeType===Ot.progressingInstruction||K&&y.nodeType===Ot.comment&&ne(/<[/\w]/g,y.data))return me(y),!0;if(!(Me.tagCheck instanceof Function&&Me.tagCheck(E))&&(!H[E]||We[E])){if(!We[E]&&Uo(E)&&(W.tagNameCheck instanceof RegExp&&ne(W.tagNameCheck,E)||W.tagNameCheck instanceof Function&&W.tagNameCheck(E)))return!1;if(ks&&!ge[E]){const U=L(y)||y.parentNode,Z=C(y)||y.childNodes;if(Z&&U){const G=Z.length;for(let re=G-1;re>=0;--re){const Ae=x(Z[re],!0);Ae.__removalCount=(y.__removalCount||0)+1,U.insertBefore(Ae,j(y))}}}return me(y),!0}return y instanceof a&&!Bc(y)||(E==="noscript"||E==="noembed"||E==="noframes")&&ne(/<\/no(script|embed|frames)/i,y.innerHTML)?(me(y),!0):(P&&y.nodeType===Ot.text&&(S=y.textContent,xn([Et,ot,Ue],U=>{S=Rt(S,U," ")}),y.textContent!==S&&(Lt(t.removed,{element:y.cloneNode()}),y.textContent=S)),Se(Y.afterSanitizeElements,y,null),!1)},Fo=function(y,S,E){if(To&&(S==="id"||S==="name")&&(E in n||E in Dc))return!1;if(!(k&&!Tt[S]&&ne(ys,S))){if(!(pn&&ne(vs,S))){if(!(Me.attributeCheck instanceof Function&&Me.attributeCheck(S,y))){if(!q[S]||Tt[S]){if(!(Uo(y)&&(W.tagNameCheck instanceof RegExp&&ne(W.tagNameCheck,y)||W.tagNameCheck instanceof Function&&W.tagNameCheck(y))&&(W.attributeNameCheck instanceof RegExp&&ne(W.attributeNameCheck,S)||W.attributeNameCheck instanceof Function&&W.attributeNameCheck(S,y))||S==="is"&&W.allowCustomizedBuiltInElements&&(W.tagNameCheck instanceof RegExp&&ne(W.tagNameCheck,E)||W.tagNameCheck instanceof Function&&W.tagNameCheck(E))))return!1}else if(!As[S]){if(!ne(cn,Rt(E,ln,""))){if(!((S==="src"||S==="xlink:href"||S==="href")&&y!=="script"&&yh(E,"data:")===0&&_o[y])){if(!(A&&!ne(bs,Rt(E,ln,"")))){if(E)return!1}}}}}}}return!0},Uo=function(y){return y!=="annotation-xml"&&Ws(y,ws)},Wo=function(y){Se(Y.beforeSanitizeAttributes,y,null);const{attributes:S}=y;if(!S||Ts(y))return;const E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:q,forceKeepAttr:void 0};let U=S.length;for(;U--;){const Z=S[U],{name:G,namespaceURI:re,value:Ae}=Z,ut=V(G),Cs=Ae;let X=G==="value"?Cs:vh(Cs);if(E.attrName=ut,E.attrValue=X,E.keepAttr=!0,E.forceKeepAttr=void 0,Se(Y.uponSanitizeAttribute,y,E),X=E.attrValue,Co&&(ut==="id"||ut==="name")&&(Ke(G,y),X=Lc+X),K&&ne(/((--!?|])>)|<\/(style|title|textarea)/i,X)){Ke(G,y);continue}if(ut==="attributename"&&Ws(X,"href")){Ke(G,y);continue}if(E.forceKeepAttr)continue;if(!E.keepAttr){Ke(G,y);continue}if(!M&&ne(/\/>/i,X)){Ke(G,y);continue}P&&xn([Et,ot,Ue],zo=>{X=Rt(X,zo," ")});const Ko=V(y.nodeName);if(!Fo(Ko,ut,X)){Ke(G,y);continue}if(I&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!re)switch(v.getAttributeType(Ko,ut)){case"TrustedHTML":{X=I.createHTML(X);break}case"TrustedScriptURL":{X=I.createScriptURL(X);break}}if(X!==Cs)try{re?y.setAttributeNS(re,G,X):y.setAttribute(G,X),Ts(y)?me(y):Pr(t.removed)}catch{Ke(G,y)}}Se(Y.afterSanitizeAttributes,y,null)},Fc=function T(y){let S=null;const E=Oo(y);for(Se(Y.beforeSanitizeShadowDOM,y,null);S=E.nextNode();)Se(Y.uponSanitizeShadowNode,S,null),Bo(S),Wo(S),S.content instanceof o&&T(S.content);Se(Y.afterSanitizeShadowDOM,y,null)};return t.sanitize=function(T){let y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},S=null,E=null,U=null,Z=null;if(xs=!T,xs&&(T="<!-->"),typeof T!="string"&&!Do(T))if(typeof T.toString=="function"){if(T=T.toString(),typeof T!="string")throw It("dirty is not a string, aborting")}else throw It("toString is not a function");if(!t.isSupported)return T;if(te||Es(y),t.removed=[],typeof T=="string"&&(Ct=!1),Ct){if(T.nodeName){const Ae=V(T.nodeName);if(!H[Ae]||We[Ae])throw It("root node is forbidden and cannot be sanitized in-place")}}else if(T instanceof l)S=No("<!---->"),E=S.ownerDocument.importNode(T,!0),E.nodeType===Ot.element&&E.nodeName==="BODY"||E.nodeName==="HTML"?S=E:S.appendChild(E);else{if(!rt&&!P&&!F&&T.indexOf("<")===-1)return I&&fn?I.createHTML(T):T;if(S=No(T),!S)return rt?null:fn?B:""}S&&Pe&&me(S.firstChild);const G=Oo(Ct?T:S);for(;U=G.nextNode();)Bo(U),Wo(U),U.content instanceof o&&Fc(U.content);if(Ct)return T;if(rt){if(hn)for(Z=gs.call(S.ownerDocument);S.firstChild;)Z.appendChild(S.firstChild);else Z=S;return(q.shadowroot||q.shadowrootmode)&&(Z=an.call(s,Z,!0)),Z}let re=F?S.outerHTML:S.innerHTML;return F&&H["!doctype"]&&S.ownerDocument&&S.ownerDocument.doctype&&S.ownerDocument.doctype.name&&ne(_l,S.ownerDocument.doctype.name)&&(re="<!DOCTYPE "+S.ownerDocument.doctype.name+`>
1525
- `+re),P&&xn([Et,ot,Ue],Ae=>{re=Rt(re,Ae," ")}),I&&fn?I.createHTML(re):re},t.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Es(T),te=!0},t.clearConfig=function(){ct=null,te=!1},t.isValidAttribute=function(T,y,S){ct||Es({});const E=V(T),U=V(y);return Fo(E,U,S)},t.addHook=function(T,y){typeof y=="function"&&Lt(Y[T],y)},t.removeHook=function(T,y){if(y!==void 0){const S=gh(Y[T],y);return S===-1?void 0:mh(Y[T],S,1)[0]}return Pr(Y[T])},t.removeHooks=function(T){Y[T]=[]},t.removeAllHooks=function(){Y=Dr()},t}var wi=Ml();function co(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var nt=co();function Pl(e){nt=e}var Gt={exec:()=>null};function O(e,t=""){let n=typeof e=="string"?e:e.source,s={replace:(i,o)=>{let r=typeof o=="string"?o:o.source;return r=r.replace(se.caret,"$1"),n=n.replace(i,r),s},getRegex:()=>new RegExp(n,t)};return s}var Rh=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),se={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},Ih=/^(?:[ \t]*(?:\n|$))+/,Nh=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Oh=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,nn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Dh=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,uo=/(?:[*+-]|\d{1,9}[.)])/,Ll=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Rl=O(Ll).replace(/bull/g,uo).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Bh=O(Ll).replace(/bull/g,uo).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),po=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Fh=/^[^\n]+/,ho=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Uh=O(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ho).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Wh=O(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,uo).getRegex(),ds="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",fo=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Kh=O("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",fo).replace("tag",ds).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Il=O(po).replace("hr",nn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ds).getRegex(),zh=O(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Il).getRegex(),go={blockquote:zh,code:Nh,def:Uh,fences:Oh,heading:Dh,hr:nn,html:Kh,lheading:Rl,list:Wh,newline:Ih,paragraph:Il,table:Gt,text:Fh},Br=O("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",nn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ds).getRegex(),jh={...go,lheading:Bh,table:Br,paragraph:O(po).replace("hr",nn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Br).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ds).getRegex()},Hh={...go,html:O(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",fo).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Gt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:O(po).replace("hr",nn).replace("heading",` *#{1,6} *[^
1526
- ]`).replace("lheading",Rl).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},qh=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Gh=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Nl=/^( {2,}|\\)\n(?!\s*$)/,Vh=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ps=/[\p{P}\p{S}]/u,mo=/[\s\p{P}\p{S}]/u,Ol=/[^\s\p{P}\p{S}]/u,Qh=O(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,mo).getRegex(),Dl=/(?!~)[\p{P}\p{S}]/u,Yh=/(?!~)[\s\p{P}\p{S}]/u,Xh=/(?:[^\s\p{P}\p{S}]|~)/u,Zh=O(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Rh?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Bl=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Jh=O(Bl,"u").replace(/punct/g,ps).getRegex(),ef=O(Bl,"u").replace(/punct/g,Dl).getRegex(),Fl="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",tf=O(Fl,"gu").replace(/notPunctSpace/g,Ol).replace(/punctSpace/g,mo).replace(/punct/g,ps).getRegex(),nf=O(Fl,"gu").replace(/notPunctSpace/g,Xh).replace(/punctSpace/g,Yh).replace(/punct/g,Dl).getRegex(),sf=O("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ol).replace(/punctSpace/g,mo).replace(/punct/g,ps).getRegex(),of=O(/\\(punct)/,"gu").replace(/punct/g,ps).getRegex(),rf=O(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),af=O(fo).replace("(?:-->|$)","-->").getRegex(),lf=O("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",af).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Vn=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,cf=O(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Vn).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ul=O(/^!?\[(label)\]\[(ref)\]/).replace("label",Vn).replace("ref",ho).getRegex(),Wl=O(/^!?\[(ref)\](?:\[\])?/).replace("ref",ho).getRegex(),uf=O("reflink|nolink(?!\\()","g").replace("reflink",Ul).replace("nolink",Wl).getRegex(),Fr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,yo={_backpedal:Gt,anyPunctuation:of,autolink:rf,blockSkip:Zh,br:Nl,code:Gh,del:Gt,emStrongLDelim:Jh,emStrongRDelimAst:tf,emStrongRDelimUnd:sf,escape:qh,link:cf,nolink:Wl,punctuation:Qh,reflink:Ul,reflinkSearch:uf,tag:lf,text:Vh,url:Gt},df={...yo,link:O(/^!?\[(label)\]\((.*?)\)/).replace("label",Vn).getRegex(),reflink:O(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Vn).getRegex()},ki={...yo,emStrongRDelimAst:nf,emStrongLDelim:ef,url:O(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Fr).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:O(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Fr).getRegex()},pf={...ki,br:O(Nl).replace("{2,}","*").getRegex(),text:O(ki.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},En={normal:go,gfm:jh,pedantic:Hh},Dt={normal:yo,gfm:ki,breaks:pf,pedantic:df},hf={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ur=e=>hf[e];function Ee(e,t){if(t){if(se.escapeTest.test(e))return e.replace(se.escapeReplace,Ur)}else if(se.escapeTestNoEncode.test(e))return e.replace(se.escapeReplaceNoEncode,Ur);return e}function Wr(e){try{e=encodeURI(e).replace(se.percentDecode,"%")}catch{return null}return e}function Kr(e,t){let n=e.replace(se.findPipe,(o,r,l)=>{let a=!1,c=r;for(;--c>=0&&l[c]==="\\";)a=!a;return a?"|":" |"}),s=n.split(se.splitPipe),i=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;i<s.length;i++)s[i]=s[i].trim().replace(se.slashPipe,"|");return s}function Bt(e,t,n){let s=e.length;if(s===0)return"";let i=0;for(;i<s&&e.charAt(s-i-1)===t;)i++;return e.slice(0,s-i)}function ff(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let s=0;s<e.length;s++)if(e[s]==="\\")s++;else if(e[s]===t[0])n++;else if(e[s]===t[1]&&(n--,n<0))return s;return n>0?-2:-1}function zr(e,t,n,s,i){let o=t.href,r=t.title||null,l=e[1].replace(i.other.outputLinkReplace,"$1");s.state.inLink=!0;let a={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:r,text:l,tokens:s.inlineTokens(l)};return s.state.inLink=!1,a}function gf(e,t,n){let s=e.match(n.other.indentCodeCompensation);if(s===null)return t;let i=s[1];return t.split(`
1538
+ `}const xl={CHILD:2},$l=e=>(...t)=>({_$litDirective$:e,values:t});let El=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,s){this._$Ct=t,this._$AM=n,this._$Ci=s}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}};const{I:rh}=lu,Cr=e=>e,_r=()=>document.createComment(""),Pt=(e,t,n)=>{const s=e._$AA.parentNode,i=t===void 0?e._$AB:t._$AA;if(n===void 0){const o=s.insertBefore(_r(),i),r=s.insertBefore(_r(),i);n=new rh(o,r,e,e.options)}else{const o=n._$AB.nextSibling,r=n._$AM,l=r!==e;if(l){let a;n._$AQ?.(e),n._$AM=e,n._$AP!==void 0&&(a=e._$AU)!==r._$AU&&n._$AP(a)}if(o!==i||l){let a=n._$AA;for(;a!==o;){const c=Cr(a).nextSibling;Cr(s).insertBefore(a,i),a=c}}}return n},je=(e,t,n=e)=>(e._$AI(t,n),e),ah={},lh=(e,t=ah)=>e._$AH=t,ch=e=>e._$AH,Fs=e=>{e._$AR(),e._$AA.remove()};const Mr=(e,t,n)=>{const s=new Map;for(let i=t;i<=n;i++)s.set(e[i],i);return s},uh=$l(class extends El{constructor(e){if(super(e),e.type!==xl.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let s;n===void 0?n=t:t!==void 0&&(s=t);const i=[],o=[];let r=0;for(const l of e)i[r]=s?s(l,r):r,o[r]=n(l,r),r++;return{values:o,keys:i}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,s]){const i=ch(e),{values:o,keys:r}=this.dt(t,n,s);if(!Array.isArray(i))return this.ut=r,o;const l=this.ut??=[],a=[];let c,u,p=0,m=i.length-1,v=0,w=o.length-1;for(;p<=m&&v<=w;)if(i[p]===null)p++;else if(i[m]===null)m--;else if(l[p]===r[v])a[v]=je(i[p],o[v]),p++,v++;else if(l[m]===r[w])a[w]=je(i[m],o[w]),m--,w--;else if(l[p]===r[w])a[w]=je(i[p],o[w]),Pt(e,a[w+1],i[p]),p++,w--;else if(l[m]===r[v])a[v]=je(i[m],o[v]),Pt(e,i[p],i[m]),m--,v++;else if(c===void 0&&(c=Mr(r,v,w),u=Mr(l,p,m)),c.has(l[p]))if(c.has(l[m])){const x=u.get(r[v]),_=x!==void 0?i[x]:null;if(_===null){const j=Pt(e,i[p]);je(j,o[v]),a[v]=j}else a[v]=je(_,o[v]),Pt(e,i[p],_),i[x]=null;v++}else Fs(i[m]),m--;else Fs(i[p]),p++;for(;v<=w;){const x=Pt(e,a[w+1]);je(x,o[v]),a[v++]=x}for(;p<=m;){const x=i[p++];x!==null&&Fs(x)}return this.ut=r,lh(e,a),Ne}});class gi extends El{constructor(t){if(super(t),this.it=b,t.type!==xl.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===b||t==null)return this._t=void 0,this.it=t;if(t===Ne)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const n=[t];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}}gi.directiveName="unsafeHTML",gi.resultType=1;const mi=$l(gi);const{entries:Tl,setPrototypeOf:Pr,isFrozen:dh,getPrototypeOf:ph,getOwnPropertyDescriptor:hh}=Object;let{freeze:ie,seal:ce,create:yi}=Object,{apply:vi,construct:bi}=typeof Reflect<"u"&&Reflect;ie||(ie=function(t){return t});ce||(ce=function(t){return t});vi||(vi=function(t,n){for(var s=arguments.length,i=new Array(s>2?s-2:0),o=2;o<s;o++)i[o-2]=arguments[o];return t.apply(n,i)});bi||(bi=function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return new t(...s)});const xn=oe(Array.prototype.forEach),fh=oe(Array.prototype.lastIndexOf),Lr=oe(Array.prototype.pop),Lt=oe(Array.prototype.push),gh=oe(Array.prototype.splice),Nn=oe(String.prototype.toLowerCase),Us=oe(String.prototype.toString),Ws=oe(String.prototype.match),Rt=oe(String.prototype.replace),mh=oe(String.prototype.indexOf),yh=oe(String.prototype.trim),de=oe(Object.prototype.hasOwnProperty),ne=oe(RegExp.prototype.test),It=vh(TypeError);function oe(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return vi(e,t,s)}}function vh(e){return function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return bi(e,n)}}function R(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Nn;Pr&&Pr(e,null);let s=t.length;for(;s--;){let i=t[s];if(typeof i=="string"){const o=n(i);o!==i&&(dh(t)||(t[s]=o),i=o)}e[i]=!0}return e}function bh(e){for(let t=0;t<e.length;t++)de(e,t)||(e[t]=null);return e}function be(e){const t=yi(null);for(const[n,s]of Tl(e))de(e,n)&&(Array.isArray(s)?t[n]=bh(s):s&&typeof s=="object"&&s.constructor===Object?t[n]=be(s):t[n]=s);return t}function Nt(e,t){for(;e!==null;){const s=hh(e,t);if(s){if(s.get)return oe(s.get);if(typeof s.value=="function")return oe(s.value)}e=ph(e)}function n(){return null}return n}const Rr=ie(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ks=ie(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),zs=ie(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),wh=ie(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),js=ie(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),kh=ie(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ir=ie(["#text"]),Nr=ie(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Hs=ie(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Or=ie(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),$n=ie(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Sh=ce(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Ah=ce(/<%[\w\W]*|[\w\W]*%>/gm),xh=ce(/\$\{[\w\W]*/gm),$h=ce(/^data-[\-\w.\u00B7-\uFFFF]+$/),Eh=ce(/^aria-[\-\w]+$/),Cl=ce(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Th=ce(/^(?:\w+script|data):/i),Ch=ce(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),_l=ce(/^html$/i),_h=ce(/^[a-z][.\w]*(-[.\w]+)+$/i);var Dr=Object.freeze({__proto__:null,ARIA_ATTR:Eh,ATTR_WHITESPACE:Ch,CUSTOM_ELEMENT:_h,DATA_ATTR:$h,DOCTYPE_NAME:_l,ERB_EXPR:Ah,IS_ALLOWED_URI:Cl,IS_SCRIPT_OR_DATA:Th,MUSTACHE_EXPR:Sh,TMPLIT_EXPR:xh});const Ot={element:1,text:3,progressingInstruction:7,comment:8,document:9},Mh=function(){return typeof window>"u"?null:window},Ph=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let s=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(s=n.getAttribute(i));const o="dompurify"+(s?"#"+s:"");try{return t.createPolicy(o,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Br=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ml(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Mh();const t=T=>Ml(T);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==Ot.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const s=n,i=s.currentScript,{DocumentFragment:o,HTMLTemplateElement:r,Node:l,Element:a,NodeFilter:c,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:m,trustedTypes:v}=e,w=a.prototype,x=Nt(w,"cloneNode"),_=Nt(w,"remove"),j=Nt(w,"nextSibling"),C=Nt(w,"childNodes"),L=Nt(w,"parentNode");if(typeof r=="function"){const T=n.createElement("template");T.content&&T.content.ownerDocument&&(n=T.content.ownerDocument)}let I,B="";const{implementation:ue,createNodeIterator:it,createDocumentFragment:gs,getElementsByTagName:ms}=n,{importNode:an}=s;let Y=Br();t.isSupported=typeof Tl=="function"&&typeof L=="function"&&ue&&ue.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Et,ERB_EXPR:ot,TMPLIT_EXPR:Ue,DATA_ATTR:ys,ARIA_ATTR:vs,IS_SCRIPT_OR_DATA:bs,ATTR_WHITESPACE:ln,CUSTOM_ELEMENT:ws}=Dr;let{IS_ALLOWED_URI:cn}=Dr,H=null;const un=R({},[...Rr,...Ks,...zs,...js,...Ir]);let q=null;const dn=R({},[...Nr,...Hs,...Or,...$n]);let W=Object.seal(yi(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),We=null,Tt=null;const Me=Object.seal(yi(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let pn=!0,k=!0,A=!1,M=!0,P=!1,K=!0,F=!1,te=!1,Pe=!1,rt=!1,hn=!1,fn=!1,To=!0,Co=!1;const Lc="user-content-";let ks=!0,Ct=!1,at={},ge=null;const Ss=R({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let _o=null;const Mo=R({},["audio","video","img","source","image","track"]);let As=null;const Po=R({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),gn="http://www.w3.org/1998/Math/MathML",mn="http://www.w3.org/2000/svg",ke="http://www.w3.org/1999/xhtml";let lt=ke,xs=!1,$s=null;const Rc=R({},[gn,mn,ke],Us);let yn=R({},["mi","mo","mn","ms","mtext"]),vn=R({},["annotation-xml"]);const Ic=R({},["title","style","font","a","script"]);let _t=null;const Nc=["application/xhtml+xml","text/html"],Oc="text/html";let V=null,ct=null;const Dc=n.createElement("form"),Lo=function(y){return y instanceof RegExp||y instanceof Function},Es=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(ct&&ct===y)){if((!y||typeof y!="object")&&(y={}),y=be(y),_t=Nc.indexOf(y.PARSER_MEDIA_TYPE)===-1?Oc:y.PARSER_MEDIA_TYPE,V=_t==="application/xhtml+xml"?Us:Nn,H=de(y,"ALLOWED_TAGS")?R({},y.ALLOWED_TAGS,V):un,q=de(y,"ALLOWED_ATTR")?R({},y.ALLOWED_ATTR,V):dn,$s=de(y,"ALLOWED_NAMESPACES")?R({},y.ALLOWED_NAMESPACES,Us):Rc,As=de(y,"ADD_URI_SAFE_ATTR")?R(be(Po),y.ADD_URI_SAFE_ATTR,V):Po,_o=de(y,"ADD_DATA_URI_TAGS")?R(be(Mo),y.ADD_DATA_URI_TAGS,V):Mo,ge=de(y,"FORBID_CONTENTS")?R({},y.FORBID_CONTENTS,V):Ss,We=de(y,"FORBID_TAGS")?R({},y.FORBID_TAGS,V):be({}),Tt=de(y,"FORBID_ATTR")?R({},y.FORBID_ATTR,V):be({}),at=de(y,"USE_PROFILES")?y.USE_PROFILES:!1,pn=y.ALLOW_ARIA_ATTR!==!1,k=y.ALLOW_DATA_ATTR!==!1,A=y.ALLOW_UNKNOWN_PROTOCOLS||!1,M=y.ALLOW_SELF_CLOSE_IN_ATTR!==!1,P=y.SAFE_FOR_TEMPLATES||!1,K=y.SAFE_FOR_XML!==!1,F=y.WHOLE_DOCUMENT||!1,rt=y.RETURN_DOM||!1,hn=y.RETURN_DOM_FRAGMENT||!1,fn=y.RETURN_TRUSTED_TYPE||!1,Pe=y.FORCE_BODY||!1,To=y.SANITIZE_DOM!==!1,Co=y.SANITIZE_NAMED_PROPS||!1,ks=y.KEEP_CONTENT!==!1,Ct=y.IN_PLACE||!1,cn=y.ALLOWED_URI_REGEXP||Cl,lt=y.NAMESPACE||ke,yn=y.MATHML_TEXT_INTEGRATION_POINTS||yn,vn=y.HTML_INTEGRATION_POINTS||vn,W=y.CUSTOM_ELEMENT_HANDLING||{},y.CUSTOM_ELEMENT_HANDLING&&Lo(y.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(W.tagNameCheck=y.CUSTOM_ELEMENT_HANDLING.tagNameCheck),y.CUSTOM_ELEMENT_HANDLING&&Lo(y.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(W.attributeNameCheck=y.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),y.CUSTOM_ELEMENT_HANDLING&&typeof y.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(W.allowCustomizedBuiltInElements=y.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),P&&(k=!1),hn&&(rt=!0),at&&(H=R({},Ir),q=[],at.html===!0&&(R(H,Rr),R(q,Nr)),at.svg===!0&&(R(H,Ks),R(q,Hs),R(q,$n)),at.svgFilters===!0&&(R(H,zs),R(q,Hs),R(q,$n)),at.mathMl===!0&&(R(H,js),R(q,Or),R(q,$n))),y.ADD_TAGS&&(typeof y.ADD_TAGS=="function"?Me.tagCheck=y.ADD_TAGS:(H===un&&(H=be(H)),R(H,y.ADD_TAGS,V))),y.ADD_ATTR&&(typeof y.ADD_ATTR=="function"?Me.attributeCheck=y.ADD_ATTR:(q===dn&&(q=be(q)),R(q,y.ADD_ATTR,V))),y.ADD_URI_SAFE_ATTR&&R(As,y.ADD_URI_SAFE_ATTR,V),y.FORBID_CONTENTS&&(ge===Ss&&(ge=be(ge)),R(ge,y.FORBID_CONTENTS,V)),y.ADD_FORBID_CONTENTS&&(ge===Ss&&(ge=be(ge)),R(ge,y.ADD_FORBID_CONTENTS,V)),ks&&(H["#text"]=!0),F&&R(H,["html","head","body"]),H.table&&(R(H,["tbody"]),delete We.tbody),y.TRUSTED_TYPES_POLICY){if(typeof y.TRUSTED_TYPES_POLICY.createHTML!="function")throw It('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof y.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw It('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');I=y.TRUSTED_TYPES_POLICY,B=I.createHTML("")}else I===void 0&&(I=Ph(v,i)),I!==null&&typeof B=="string"&&(B=I.createHTML(""));ie&&ie(y),ct=y}},Ro=R({},[...Ks,...zs,...wh]),Io=R({},[...js,...kh]),Bc=function(y){let S=L(y);(!S||!S.tagName)&&(S={namespaceURI:lt,tagName:"template"});const E=Nn(y.tagName),U=Nn(S.tagName);return $s[y.namespaceURI]?y.namespaceURI===mn?S.namespaceURI===ke?E==="svg":S.namespaceURI===gn?E==="svg"&&(U==="annotation-xml"||yn[U]):!!Ro[E]:y.namespaceURI===gn?S.namespaceURI===ke?E==="math":S.namespaceURI===mn?E==="math"&&vn[U]:!!Io[E]:y.namespaceURI===ke?S.namespaceURI===mn&&!vn[U]||S.namespaceURI===gn&&!yn[U]?!1:!Io[E]&&(Ic[E]||!Ro[E]):!!(_t==="application/xhtml+xml"&&$s[y.namespaceURI]):!1},me=function(y){Lt(t.removed,{element:y});try{L(y).removeChild(y)}catch{_(y)}},Ke=function(y,S){try{Lt(t.removed,{attribute:S.getAttributeNode(y),from:S})}catch{Lt(t.removed,{attribute:null,from:S})}if(S.removeAttribute(y),y==="is")if(rt||hn)try{me(S)}catch{}else try{S.setAttribute(y,"")}catch{}},No=function(y){let S=null,E=null;if(Pe)y="<remove></remove>"+y;else{const G=Ws(y,/^[\r\n\t ]+/);E=G&&G[0]}_t==="application/xhtml+xml"&&lt===ke&&(y='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+y+"</body></html>");const U=I?I.createHTML(y):y;if(lt===ke)try{S=new m().parseFromString(U,_t)}catch{}if(!S||!S.documentElement){S=ue.createDocument(lt,"template",null);try{S.documentElement.innerHTML=xs?B:U}catch{}}const Z=S.body||S.documentElement;return y&&E&&Z.insertBefore(n.createTextNode(E),Z.childNodes[0]||null),lt===ke?ms.call(S,F?"html":"body")[0]:F?S.documentElement:Z},Oo=function(y){return it.call(y.ownerDocument||y,y,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Ts=function(y){return y instanceof p&&(typeof y.nodeName!="string"||typeof y.textContent!="string"||typeof y.removeChild!="function"||!(y.attributes instanceof u)||typeof y.removeAttribute!="function"||typeof y.setAttribute!="function"||typeof y.namespaceURI!="string"||typeof y.insertBefore!="function"||typeof y.hasChildNodes!="function")},Do=function(y){return typeof l=="function"&&y instanceof l};function Se(T,y,S){xn(T,E=>{E.call(t,y,S,ct)})}const Bo=function(y){let S=null;if(Se(Y.beforeSanitizeElements,y,null),Ts(y))return me(y),!0;const E=V(y.nodeName);if(Se(Y.uponSanitizeElement,y,{tagName:E,allowedTags:H}),K&&y.hasChildNodes()&&!Do(y.firstElementChild)&&ne(/<[/\w!]/g,y.innerHTML)&&ne(/<[/\w!]/g,y.textContent)||y.nodeType===Ot.progressingInstruction||K&&y.nodeType===Ot.comment&&ne(/<[/\w]/g,y.data))return me(y),!0;if(!(Me.tagCheck instanceof Function&&Me.tagCheck(E))&&(!H[E]||We[E])){if(!We[E]&&Uo(E)&&(W.tagNameCheck instanceof RegExp&&ne(W.tagNameCheck,E)||W.tagNameCheck instanceof Function&&W.tagNameCheck(E)))return!1;if(ks&&!ge[E]){const U=L(y)||y.parentNode,Z=C(y)||y.childNodes;if(Z&&U){const G=Z.length;for(let re=G-1;re>=0;--re){const Ae=x(Z[re],!0);Ae.__removalCount=(y.__removalCount||0)+1,U.insertBefore(Ae,j(y))}}}return me(y),!0}return y instanceof a&&!Bc(y)||(E==="noscript"||E==="noembed"||E==="noframes")&&ne(/<\/no(script|embed|frames)/i,y.innerHTML)?(me(y),!0):(P&&y.nodeType===Ot.text&&(S=y.textContent,xn([Et,ot,Ue],U=>{S=Rt(S,U," ")}),y.textContent!==S&&(Lt(t.removed,{element:y.cloneNode()}),y.textContent=S)),Se(Y.afterSanitizeElements,y,null),!1)},Fo=function(y,S,E){if(To&&(S==="id"||S==="name")&&(E in n||E in Dc))return!1;if(!(k&&!Tt[S]&&ne(ys,S))){if(!(pn&&ne(vs,S))){if(!(Me.attributeCheck instanceof Function&&Me.attributeCheck(S,y))){if(!q[S]||Tt[S]){if(!(Uo(y)&&(W.tagNameCheck instanceof RegExp&&ne(W.tagNameCheck,y)||W.tagNameCheck instanceof Function&&W.tagNameCheck(y))&&(W.attributeNameCheck instanceof RegExp&&ne(W.attributeNameCheck,S)||W.attributeNameCheck instanceof Function&&W.attributeNameCheck(S,y))||S==="is"&&W.allowCustomizedBuiltInElements&&(W.tagNameCheck instanceof RegExp&&ne(W.tagNameCheck,E)||W.tagNameCheck instanceof Function&&W.tagNameCheck(E))))return!1}else if(!As[S]){if(!ne(cn,Rt(E,ln,""))){if(!((S==="src"||S==="xlink:href"||S==="href")&&y!=="script"&&mh(E,"data:")===0&&_o[y])){if(!(A&&!ne(bs,Rt(E,ln,"")))){if(E)return!1}}}}}}}return!0},Uo=function(y){return y!=="annotation-xml"&&Ws(y,ws)},Wo=function(y){Se(Y.beforeSanitizeAttributes,y,null);const{attributes:S}=y;if(!S||Ts(y))return;const E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:q,forceKeepAttr:void 0};let U=S.length;for(;U--;){const Z=S[U],{name:G,namespaceURI:re,value:Ae}=Z,ut=V(G),Cs=Ae;let X=G==="value"?Cs:yh(Cs);if(E.attrName=ut,E.attrValue=X,E.keepAttr=!0,E.forceKeepAttr=void 0,Se(Y.uponSanitizeAttribute,y,E),X=E.attrValue,Co&&(ut==="id"||ut==="name")&&(Ke(G,y),X=Lc+X),K&&ne(/((--!?|])>)|<\/(style|title|textarea)/i,X)){Ke(G,y);continue}if(ut==="attributename"&&Ws(X,"href")){Ke(G,y);continue}if(E.forceKeepAttr)continue;if(!E.keepAttr){Ke(G,y);continue}if(!M&&ne(/\/>/i,X)){Ke(G,y);continue}P&&xn([Et,ot,Ue],zo=>{X=Rt(X,zo," ")});const Ko=V(y.nodeName);if(!Fo(Ko,ut,X)){Ke(G,y);continue}if(I&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!re)switch(v.getAttributeType(Ko,ut)){case"TrustedHTML":{X=I.createHTML(X);break}case"TrustedScriptURL":{X=I.createScriptURL(X);break}}if(X!==Cs)try{re?y.setAttributeNS(re,G,X):y.setAttribute(G,X),Ts(y)?me(y):Lr(t.removed)}catch{Ke(G,y)}}Se(Y.afterSanitizeAttributes,y,null)},Fc=function T(y){let S=null;const E=Oo(y);for(Se(Y.beforeSanitizeShadowDOM,y,null);S=E.nextNode();)Se(Y.uponSanitizeShadowNode,S,null),Bo(S),Wo(S),S.content instanceof o&&T(S.content);Se(Y.afterSanitizeShadowDOM,y,null)};return t.sanitize=function(T){let y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},S=null,E=null,U=null,Z=null;if(xs=!T,xs&&(T="<!-->"),typeof T!="string"&&!Do(T))if(typeof T.toString=="function"){if(T=T.toString(),typeof T!="string")throw It("dirty is not a string, aborting")}else throw It("toString is not a function");if(!t.isSupported)return T;if(te||Es(y),t.removed=[],typeof T=="string"&&(Ct=!1),Ct){if(T.nodeName){const Ae=V(T.nodeName);if(!H[Ae]||We[Ae])throw It("root node is forbidden and cannot be sanitized in-place")}}else if(T instanceof l)S=No("<!---->"),E=S.ownerDocument.importNode(T,!0),E.nodeType===Ot.element&&E.nodeName==="BODY"||E.nodeName==="HTML"?S=E:S.appendChild(E);else{if(!rt&&!P&&!F&&T.indexOf("<")===-1)return I&&fn?I.createHTML(T):T;if(S=No(T),!S)return rt?null:fn?B:""}S&&Pe&&me(S.firstChild);const G=Oo(Ct?T:S);for(;U=G.nextNode();)Bo(U),Wo(U),U.content instanceof o&&Fc(U.content);if(Ct)return T;if(rt){if(hn)for(Z=gs.call(S.ownerDocument);S.firstChild;)Z.appendChild(S.firstChild);else Z=S;return(q.shadowroot||q.shadowrootmode)&&(Z=an.call(s,Z,!0)),Z}let re=F?S.outerHTML:S.innerHTML;return F&&H["!doctype"]&&S.ownerDocument&&S.ownerDocument.doctype&&S.ownerDocument.doctype.name&&ne(_l,S.ownerDocument.doctype.name)&&(re="<!DOCTYPE "+S.ownerDocument.doctype.name+`>
1539
+ `+re),P&&xn([Et,ot,Ue],Ae=>{re=Rt(re,Ae," ")}),I&&fn?I.createHTML(re):re},t.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Es(T),te=!0},t.clearConfig=function(){ct=null,te=!1},t.isValidAttribute=function(T,y,S){ct||Es({});const E=V(T),U=V(y);return Fo(E,U,S)},t.addHook=function(T,y){typeof y=="function"&&Lt(Y[T],y)},t.removeHook=function(T,y){if(y!==void 0){const S=fh(Y[T],y);return S===-1?void 0:gh(Y[T],S,1)[0]}return Lr(Y[T])},t.removeHooks=function(T){Y[T]=[]},t.removeAllHooks=function(){Y=Br()},t}var wi=Ml();function co(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var nt=co();function Pl(e){nt=e}var Gt={exec:()=>null};function O(e,t=""){let n=typeof e=="string"?e:e.source,s={replace:(i,o)=>{let r=typeof o=="string"?o:o.source;return r=r.replace(se.caret,"$1"),n=n.replace(i,r),s},getRegex:()=>new RegExp(n,t)};return s}var Lh=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),se={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},Rh=/^(?:[ \t]*(?:\n|$))+/,Ih=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Nh=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,nn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Oh=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,uo=/(?:[*+-]|\d{1,9}[.)])/,Ll=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Rl=O(Ll).replace(/bull/g,uo).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Dh=O(Ll).replace(/bull/g,uo).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),po=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Bh=/^[^\n]+/,ho=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Fh=O(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ho).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Uh=O(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,uo).getRegex(),ds="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",fo=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Wh=O("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",fo).replace("tag",ds).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Il=O(po).replace("hr",nn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ds).getRegex(),Kh=O(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Il).getRegex(),go={blockquote:Kh,code:Ih,def:Fh,fences:Nh,heading:Oh,hr:nn,html:Wh,lheading:Rl,list:Uh,newline:Rh,paragraph:Il,table:Gt,text:Bh},Fr=O("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",nn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ds).getRegex(),zh={...go,lheading:Dh,table:Fr,paragraph:O(po).replace("hr",nn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Fr).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ds).getRegex()},jh={...go,html:O(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",fo).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Gt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:O(po).replace("hr",nn).replace("heading",` *#{1,6} *[^
1540
+ ]`).replace("lheading",Rl).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Hh=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,qh=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Nl=/^( {2,}|\\)\n(?!\s*$)/,Gh=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ps=/[\p{P}\p{S}]/u,mo=/[\s\p{P}\p{S}]/u,Ol=/[^\s\p{P}\p{S}]/u,Vh=O(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,mo).getRegex(),Dl=/(?!~)[\p{P}\p{S}]/u,Qh=/(?!~)[\s\p{P}\p{S}]/u,Yh=/(?:[^\s\p{P}\p{S}]|~)/u,Xh=O(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Lh?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Bl=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Zh=O(Bl,"u").replace(/punct/g,ps).getRegex(),Jh=O(Bl,"u").replace(/punct/g,Dl).getRegex(),Fl="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ef=O(Fl,"gu").replace(/notPunctSpace/g,Ol).replace(/punctSpace/g,mo).replace(/punct/g,ps).getRegex(),tf=O(Fl,"gu").replace(/notPunctSpace/g,Yh).replace(/punctSpace/g,Qh).replace(/punct/g,Dl).getRegex(),nf=O("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ol).replace(/punctSpace/g,mo).replace(/punct/g,ps).getRegex(),sf=O(/\\(punct)/,"gu").replace(/punct/g,ps).getRegex(),of=O(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),rf=O(fo).replace("(?:-->|$)","-->").getRegex(),af=O("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",rf).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Vn=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,lf=O(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Vn).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ul=O(/^!?\[(label)\]\[(ref)\]/).replace("label",Vn).replace("ref",ho).getRegex(),Wl=O(/^!?\[(ref)\](?:\[\])?/).replace("ref",ho).getRegex(),cf=O("reflink|nolink(?!\\()","g").replace("reflink",Ul).replace("nolink",Wl).getRegex(),Ur=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,yo={_backpedal:Gt,anyPunctuation:sf,autolink:of,blockSkip:Xh,br:Nl,code:qh,del:Gt,emStrongLDelim:Zh,emStrongRDelimAst:ef,emStrongRDelimUnd:nf,escape:Hh,link:lf,nolink:Wl,punctuation:Vh,reflink:Ul,reflinkSearch:cf,tag:af,text:Gh,url:Gt},uf={...yo,link:O(/^!?\[(label)\]\((.*?)\)/).replace("label",Vn).getRegex(),reflink:O(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Vn).getRegex()},ki={...yo,emStrongRDelimAst:tf,emStrongLDelim:Jh,url:O(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ur).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:O(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Ur).getRegex()},df={...ki,br:O(Nl).replace("{2,}","*").getRegex(),text:O(ki.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},En={normal:go,gfm:zh,pedantic:jh},Dt={normal:yo,gfm:ki,breaks:df,pedantic:uf},pf={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Wr=e=>pf[e];function Ee(e,t){if(t){if(se.escapeTest.test(e))return e.replace(se.escapeReplace,Wr)}else if(se.escapeTestNoEncode.test(e))return e.replace(se.escapeReplaceNoEncode,Wr);return e}function Kr(e){try{e=encodeURI(e).replace(se.percentDecode,"%")}catch{return null}return e}function zr(e,t){let n=e.replace(se.findPipe,(o,r,l)=>{let a=!1,c=r;for(;--c>=0&&l[c]==="\\";)a=!a;return a?"|":" |"}),s=n.split(se.splitPipe),i=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;i<s.length;i++)s[i]=s[i].trim().replace(se.slashPipe,"|");return s}function Bt(e,t,n){let s=e.length;if(s===0)return"";let i=0;for(;i<s&&e.charAt(s-i-1)===t;)i++;return e.slice(0,s-i)}function hf(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let s=0;s<e.length;s++)if(e[s]==="\\")s++;else if(e[s]===t[0])n++;else if(e[s]===t[1]&&(n--,n<0))return s;return n>0?-2:-1}function jr(e,t,n,s,i){let o=t.href,r=t.title||null,l=e[1].replace(i.other.outputLinkReplace,"$1");s.state.inLink=!0;let a={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:r,text:l,tokens:s.inlineTokens(l)};return s.state.inLink=!1,a}function ff(e,t,n){let s=e.match(n.other.indentCodeCompensation);if(s===null)return t;let i=s[1];return t.split(`
1527
1541
  `).map(o=>{let r=o.match(n.other.beginningSpace);if(r===null)return o;let[l]=r;return l.length>=i.length?o.slice(i.length):o}).join(`
1528
1542
  `)}var Qn=class{options;rules;lexer;constructor(e){this.options=e||nt}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Bt(n,`
1529
- `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=gf(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let s=Bt(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Bt(t[0],`
1543
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=ff(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let s=Bt(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Bt(t[0],`
1530
1544
  `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Bt(t[0],`
1531
1545
  `).split(`
1532
1546
  `),s="",i="",o=[];for(;n.length>0;){let r=!1,l=[],a;for(a=0;a<n.length;a++)if(this.rules.other.blockquoteStart.test(n[a]))l.push(n[a]),r=!0;else if(!r)l.push(n[a]);else break;n=n.slice(a);let c=l.join(`
@@ -1545,9 +1559,9 @@ ${u}`:u;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
1545
1559
  `,1)[0],B;if(m=I,this.options.pedantic?(m=m.replace(this.rules.other.listReplaceNesting," "),B=m):B=m.replace(this.rules.other.tabCharGlobal," "),j.test(m)||C.test(m)||L.test(m)||x.test(m)||_.test(m))break;if(B.search(this.rules.other.nonSpaceChar)>=w||!m.trim())u+=`
1546
1560
  `+B.slice(w);else{if(v||p.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||j.test(p)||C.test(p)||_.test(p))break;u+=`
1547
1561
  `+m}!v&&!m.trim()&&(v=!0),c+=I+`
1548
- `,e=e.substring(I.length+1),p=B.slice(w)}}i.loose||(r?i.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(r=!0)),i.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),i.raw+=c}let l=i.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let a of i.items){if(this.lexer.state.top=!1,a.tokens=this.lexer.blockTokens(a.text,[]),a.task){if(a.text=a.text.replace(this.rules.other.listReplaceTask,""),a.tokens[0]?.type==="text"||a.tokens[0]?.type==="paragraph"){a.tokens[0].raw=a.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),a.tokens[0].text=a.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let u=this.lexer.inlineQueue.length-1;u>=0;u--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)){this.lexer.inlineQueue[u].src=this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask,"");break}}let c=this.rules.other.listTaskCheckbox.exec(a.raw);if(c){let u={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};a.checked=u.checked,i.loose?a.tokens[0]&&["paragraph","text"].includes(a.tokens[0].type)&&"tokens"in a.tokens[0]&&a.tokens[0].tokens?(a.tokens[0].raw=u.raw+a.tokens[0].raw,a.tokens[0].text=u.raw+a.tokens[0].text,a.tokens[0].tokens.unshift(u)):a.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):a.tokens.unshift(u)}}if(!i.loose){let c=a.tokens.filter(p=>p.type==="space"),u=c.length>0&&c.some(p=>this.rules.other.anyLine.test(p.raw));i.loose=u}}if(i.loose)for(let a of i.items){a.loose=!0;for(let c of a.tokens)c.type==="text"&&(c.type="paragraph")}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:s,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Kr(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
1549
- `):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(let r of s)this.rules.other.tableAlignRight.test(r)?o.align.push("right"):this.rules.other.tableAlignCenter.test(r)?o.align.push("center"):this.rules.other.tableAlignLeft.test(r)?o.align.push("left"):o.align.push(null);for(let r=0;r<n.length;r++)o.header.push({text:n[r],tokens:this.lexer.inline(n[r]),header:!0,align:o.align[r]});for(let r of i)o.rows.push(Kr(r,o.header.length).map((l,a)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:o.align[a]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
1550
- `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=Bt(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=ff(t[2],"()");if(o===-2)return;if(o>-1){let r=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,r).trim(),t[3]=""}}let s=t[2],i="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(s);o&&(s=o[1],i=o[3])}else i=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),zr(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[s.toLowerCase()];if(!i){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return zr(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!(!s||s[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[2])||!n||this.rules.inline.punctuation.exec(n))){let i=[...s[0]].length-1,o,r,l=i,a=0,c=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+i);(s=c.exec(t))!=null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o)continue;if(r=[...o].length,s[3]||s[4]){l+=r;continue}else if((s[5]||s[6])&&i%3&&!((i+r)%3)){a+=r;continue}if(l-=r,l>0)continue;r=Math.min(r,r+l+a);let u=[...s[0]][0].length,p=e.slice(0,i+s.index+u+r);if(Math.min(i,r)%2){let v=p.slice(1,-1);return{type:"em",raw:p,text:v,tokens:this.lexer.inlineTokens(v)}}let m=p.slice(2,-2);return{type:"strong",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,s;return t[2]==="@"?(n=t[1],s="mailto:"+n):(n=t[1],s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,s;if(t[2]==="@")n=t[0],s="mailto:"+n;else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},pe=class Si{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||nt,this.options.tokenizer=this.options.tokenizer||new Qn,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:se,block:En.normal,inline:Dt.normal};this.options.pedantic?(n.block=En.pedantic,n.inline=Dt.pedantic):this.options.gfm&&(n.block=En.gfm,this.options.breaks?n.inline=Dt.breaks:n.inline=Dt.gfm),this.tokenizer.rules=n}static get rules(){return{block:En,inline:Dt}}static lex(t,n){return new Si(n).lex(t)}static lexInline(t,n){return new Si(n).inlineTokens(t)}lex(t){t=t.replace(se.carriageReturn,`
1562
+ `,e=e.substring(I.length+1),p=B.slice(w)}}i.loose||(r?i.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(r=!0)),i.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),i.raw+=c}let l=i.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let a of i.items){if(this.lexer.state.top=!1,a.tokens=this.lexer.blockTokens(a.text,[]),a.task){if(a.text=a.text.replace(this.rules.other.listReplaceTask,""),a.tokens[0]?.type==="text"||a.tokens[0]?.type==="paragraph"){a.tokens[0].raw=a.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),a.tokens[0].text=a.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let u=this.lexer.inlineQueue.length-1;u>=0;u--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)){this.lexer.inlineQueue[u].src=this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask,"");break}}let c=this.rules.other.listTaskCheckbox.exec(a.raw);if(c){let u={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};a.checked=u.checked,i.loose?a.tokens[0]&&["paragraph","text"].includes(a.tokens[0].type)&&"tokens"in a.tokens[0]&&a.tokens[0].tokens?(a.tokens[0].raw=u.raw+a.tokens[0].raw,a.tokens[0].text=u.raw+a.tokens[0].text,a.tokens[0].tokens.unshift(u)):a.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):a.tokens.unshift(u)}}if(!i.loose){let c=a.tokens.filter(p=>p.type==="space"),u=c.length>0&&c.some(p=>this.rules.other.anyLine.test(p.raw));i.loose=u}}if(i.loose)for(let a of i.items){a.loose=!0;for(let c of a.tokens)c.type==="text"&&(c.type="paragraph")}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:s,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=zr(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
1563
+ `):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(let r of s)this.rules.other.tableAlignRight.test(r)?o.align.push("right"):this.rules.other.tableAlignCenter.test(r)?o.align.push("center"):this.rules.other.tableAlignLeft.test(r)?o.align.push("left"):o.align.push(null);for(let r=0;r<n.length;r++)o.header.push({text:n[r],tokens:this.lexer.inline(n[r]),header:!0,align:o.align[r]});for(let r of i)o.rows.push(zr(r,o.header.length).map((l,a)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:o.align[a]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
1564
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=Bt(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=hf(t[2],"()");if(o===-2)return;if(o>-1){let r=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,r).trim(),t[3]=""}}let s=t[2],i="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(s);o&&(s=o[1],i=o[3])}else i=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),jr(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[s.toLowerCase()];if(!i){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return jr(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!(!s||s[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[2])||!n||this.rules.inline.punctuation.exec(n))){let i=[...s[0]].length-1,o,r,l=i,a=0,c=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+i);(s=c.exec(t))!=null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o)continue;if(r=[...o].length,s[3]||s[4]){l+=r;continue}else if((s[5]||s[6])&&i%3&&!((i+r)%3)){a+=r;continue}if(l-=r,l>0)continue;r=Math.min(r,r+l+a);let u=[...s[0]][0].length,p=e.slice(0,i+s.index+u+r);if(Math.min(i,r)%2){let v=p.slice(1,-1);return{type:"em",raw:p,text:v,tokens:this.lexer.inlineTokens(v)}}let m=p.slice(2,-2);return{type:"strong",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,s;return t[2]==="@"?(n=t[1],s="mailto:"+n):(n=t[1],s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,s;if(t[2]==="@")n=t[0],s="mailto:"+n;else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},pe=class Si{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||nt,this.options.tokenizer=this.options.tokenizer||new Qn,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:se,block:En.normal,inline:Dt.normal};this.options.pedantic?(n.block=En.pedantic,n.inline=Dt.pedantic):this.options.gfm&&(n.block=En.gfm,this.options.breaks?n.inline=Dt.breaks:n.inline=Dt.gfm),this.tokenizer.rules=n}static get rules(){return{block:En,inline:Dt}}static lex(t,n){return new Si(n).lex(t)}static lexInline(t,n){return new Si(n).inlineTokens(t)}lex(t){t=t.replace(se.carriageReturn,`
1551
1565
  `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let s=this.inlineQueue[n];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],s=!1){for(this.options.pedantic&&(t=t.replace(se.tabCharGlobal," ").replace(se.spaceLine,""));t;){let i;if(this.options.extensions?.block?.some(r=>(i=r.call({lexer:this},t,n))?(t=t.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.space(t)){t=t.substring(i.raw.length);let r=n.at(-1);i.raw.length===1&&r!==void 0?r.raw+=`
1552
1566
  `:n.push(i);continue}if(i=this.tokenizer.code(t)){t=t.substring(i.raw.length);let r=n.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=(r.raw.endsWith(`
1553
1567
  `)?"":`
@@ -1579,23 +1593,23 @@ ${this.parser.parse(e)}</blockquote>
1579
1593
  `}tablerow({text:e}){return`<tr>
1580
1594
  ${e}</tr>
1581
1595
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
1582
- `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Ee(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),i=Wr(e);if(i===null)return s;e=i;let o='<a href="'+e+'"';return t&&(o+=' title="'+Ee(t)+'"'),o+=">"+s+"</a>",o}image({href:e,title:t,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let i=Wr(e);if(i===null)return Ee(n);e=i;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${Ee(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Ee(e.text)}},vo=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},he=class Ai{options;renderer;textRenderer;constructor(t){this.options=t||nt,this.options.renderer=this.options.renderer||new Yn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new vo}static parse(t,n){return new Ai(n).parse(t)}static parseInline(t,n){return new Ai(n).parseInline(t)}parse(t){let n="";for(let s=0;s<t.length;s++){let i=t[s];if(this.options.extensions?.renderers?.[i.type]){let r=i,l=this.options.extensions.renderers[r.type].call({parser:this},r);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(r.type)){n+=l||"";continue}}let o=i;switch(o.type){case"space":{n+=this.renderer.space(o);break}case"hr":{n+=this.renderer.hr(o);break}case"heading":{n+=this.renderer.heading(o);break}case"code":{n+=this.renderer.code(o);break}case"table":{n+=this.renderer.table(o);break}case"blockquote":{n+=this.renderer.blockquote(o);break}case"list":{n+=this.renderer.list(o);break}case"checkbox":{n+=this.renderer.checkbox(o);break}case"html":{n+=this.renderer.html(o);break}case"def":{n+=this.renderer.def(o);break}case"paragraph":{n+=this.renderer.paragraph(o);break}case"text":{n+=this.renderer.text(o);break}default:{let r='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(r),"";throw new Error(r)}}}return n}parseInline(t,n=this.renderer){let s="";for(let i=0;i<t.length;i++){let o=t[i];if(this.options.extensions?.renderers?.[o.type]){let l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){s+=l||"";continue}}let r=o;switch(r.type){case"escape":{s+=n.text(r);break}case"html":{s+=n.html(r);break}case"link":{s+=n.link(r);break}case"image":{s+=n.image(r);break}case"checkbox":{s+=n.checkbox(r);break}case"strong":{s+=n.strong(r);break}case"em":{s+=n.em(r);break}case"codespan":{s+=n.codespan(r);break}case"br":{s+=n.br(r);break}case"del":{s+=n.del(r);break}case"text":{s+=n.text(r);break}default:{let l='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return s}},Wt=class{options;block;constructor(e){this.options=e||nt}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?pe.lex:pe.lexInline}provideParser(){return this.block?he.parse:he.parseInline}},mf=class{defaults=co();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=he;Renderer=Yn;TextRenderer=vo;Lexer=pe;Tokenizer=Qn;Hooks=Wt;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let s of e)switch(n=n.concat(t.call(this,s)),s.type){case"table":{let i=s;for(let o of i.header)n=n.concat(this.walkTokens(o.tokens,t));for(let o of i.rows)for(let r of o)n=n.concat(this.walkTokens(r.tokens,t));break}case"list":{let i=s;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=s;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(o=>{let r=i[o].flat(1/0);n=n.concat(this.walkTokens(r,t))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let o=t.renderers[i.name];o?t.renderers[i.name]=function(...r){let l=i.renderer.apply(this,r);return l===!1&&(l=o.apply(this,r)),l}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[i.level];o?o.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),s.extensions=t),n.renderer){let i=this.defaults.renderer||new Yn(this.defaults);for(let o in n.renderer){if(!(o in i))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let r=o,l=n.renderer[r],a=i[r];i[r]=(...c)=>{let u=l.apply(i,c);return u===!1&&(u=a.apply(i,c)),u||""}}s.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new Qn(this.defaults);for(let o in n.tokenizer){if(!(o in i))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let r=o,l=n.tokenizer[r],a=i[r];i[r]=(...c)=>{let u=l.apply(i,c);return u===!1&&(u=a.apply(i,c)),u}}s.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new Wt;for(let o in n.hooks){if(!(o in i))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let r=o,l=n.hooks[r],a=i[r];Wt.passThroughHooks.has(o)?i[r]=c=>{if(this.defaults.async&&Wt.passThroughHooksRespectAsync.has(o))return(async()=>{let p=await l.call(i,c);return a.call(i,p)})();let u=l.call(i,c);return a.call(i,u)}:i[r]=(...c)=>{if(this.defaults.async)return(async()=>{let p=await l.apply(i,c);return p===!1&&(p=await a.apply(i,c)),p})();let u=l.apply(i,c);return u===!1&&(u=a.apply(i,c)),u}}s.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,o=n.walkTokens;s.walkTokens=function(r){let l=[];return l.push(o.call(this,r)),i&&(l=l.concat(i.call(this,r))),l}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return pe.lex(e,t??this.defaults)}parser(e,t){return he.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let s={...n},i={...this.defaults,...s},o=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&s.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let r=i.hooks?await i.hooks.preprocess(t):t,l=await(i.hooks?await i.hooks.provideLexer():e?pe.lex:pe.lexInline)(r,i),a=i.hooks?await i.hooks.processAllTokens(l):l;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let c=await(i.hooks?await i.hooks.provideParser():e?he.parse:he.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(c):c})().catch(o);try{i.hooks&&(t=i.hooks.preprocess(t));let r=(i.hooks?i.hooks.provideLexer():e?pe.lex:pe.lexInline)(t,i);i.hooks&&(r=i.hooks.processAllTokens(r)),i.walkTokens&&this.walkTokens(r,i.walkTokens);let l=(i.hooks?i.hooks.provideParser():e?he.parse:he.parseInline)(r,i);return i.hooks&&(l=i.hooks.postprocess(l)),l}catch(r){return o(r)}}}onError(e,t){return n=>{if(n.message+=`
1583
- Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+Ee(n.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}},Ze=new mf;function D(e,t){return Ze.parse(e,t)}D.options=D.setOptions=function(e){return Ze.setOptions(e),D.defaults=Ze.defaults,Pl(D.defaults),D};D.getDefaults=co;D.defaults=nt;D.use=function(...e){return Ze.use(...e),D.defaults=Ze.defaults,Pl(D.defaults),D};D.walkTokens=function(e,t){return Ze.walkTokens(e,t)};D.parseInline=Ze.parseInline;D.Parser=he;D.parser=he.parse;D.Renderer=Yn;D.TextRenderer=vo;D.Lexer=pe;D.lexer=pe.lex;D.Tokenizer=Qn;D.Hooks=Wt;D.parse=D;D.options;D.setOptions;D.use;D.walkTokens;D.parseInline;he.parse;pe.lex;D.setOptions({gfm:!0,breaks:!0,mangle:!1});const jr=["a","b","blockquote","br","code","del","em","h1","h2","h3","h4","hr","i","li","ol","p","pre","strong","table","tbody","td","th","thead","tr","ul"],Hr=["class","href","rel","target","title","start"];let qr=!1;const yf=14e4,vf=4e4,bf=200,qs=5e4,Ge=new Map;function wf(e){const t=Ge.get(e);return t===void 0?null:(Ge.delete(e),Ge.set(e,t),t)}function Gr(e,t){if(Ge.set(e,t),Ge.size<=bf)return;const n=Ge.keys().next().value;n&&Ge.delete(n)}function kf(){qr||(qr=!0,wi.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function xi(e){const t=e.trim();if(!t)return"";if(kf(),t.length<=qs){const r=wf(t);if(r!==null)return r}const n=Ma(t,yf),s=n.truncated?`
1596
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Ee(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),i=Kr(e);if(i===null)return s;e=i;let o='<a href="'+e+'"';return t&&(o+=' title="'+Ee(t)+'"'),o+=">"+s+"</a>",o}image({href:e,title:t,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let i=Kr(e);if(i===null)return Ee(n);e=i;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${Ee(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Ee(e.text)}},vo=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},he=class Ai{options;renderer;textRenderer;constructor(t){this.options=t||nt,this.options.renderer=this.options.renderer||new Yn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new vo}static parse(t,n){return new Ai(n).parse(t)}static parseInline(t,n){return new Ai(n).parseInline(t)}parse(t){let n="";for(let s=0;s<t.length;s++){let i=t[s];if(this.options.extensions?.renderers?.[i.type]){let r=i,l=this.options.extensions.renderers[r.type].call({parser:this},r);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(r.type)){n+=l||"";continue}}let o=i;switch(o.type){case"space":{n+=this.renderer.space(o);break}case"hr":{n+=this.renderer.hr(o);break}case"heading":{n+=this.renderer.heading(o);break}case"code":{n+=this.renderer.code(o);break}case"table":{n+=this.renderer.table(o);break}case"blockquote":{n+=this.renderer.blockquote(o);break}case"list":{n+=this.renderer.list(o);break}case"checkbox":{n+=this.renderer.checkbox(o);break}case"html":{n+=this.renderer.html(o);break}case"def":{n+=this.renderer.def(o);break}case"paragraph":{n+=this.renderer.paragraph(o);break}case"text":{n+=this.renderer.text(o);break}default:{let r='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(r),"";throw new Error(r)}}}return n}parseInline(t,n=this.renderer){let s="";for(let i=0;i<t.length;i++){let o=t[i];if(this.options.extensions?.renderers?.[o.type]){let l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){s+=l||"";continue}}let r=o;switch(r.type){case"escape":{s+=n.text(r);break}case"html":{s+=n.html(r);break}case"link":{s+=n.link(r);break}case"image":{s+=n.image(r);break}case"checkbox":{s+=n.checkbox(r);break}case"strong":{s+=n.strong(r);break}case"em":{s+=n.em(r);break}case"codespan":{s+=n.codespan(r);break}case"br":{s+=n.br(r);break}case"del":{s+=n.del(r);break}case"text":{s+=n.text(r);break}default:{let l='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return s}},Wt=class{options;block;constructor(e){this.options=e||nt}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?pe.lex:pe.lexInline}provideParser(){return this.block?he.parse:he.parseInline}},gf=class{defaults=co();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=he;Renderer=Yn;TextRenderer=vo;Lexer=pe;Tokenizer=Qn;Hooks=Wt;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let s of e)switch(n=n.concat(t.call(this,s)),s.type){case"table":{let i=s;for(let o of i.header)n=n.concat(this.walkTokens(o.tokens,t));for(let o of i.rows)for(let r of o)n=n.concat(this.walkTokens(r.tokens,t));break}case"list":{let i=s;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=s;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(o=>{let r=i[o].flat(1/0);n=n.concat(this.walkTokens(r,t))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let o=t.renderers[i.name];o?t.renderers[i.name]=function(...r){let l=i.renderer.apply(this,r);return l===!1&&(l=o.apply(this,r)),l}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[i.level];o?o.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),s.extensions=t),n.renderer){let i=this.defaults.renderer||new Yn(this.defaults);for(let o in n.renderer){if(!(o in i))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let r=o,l=n.renderer[r],a=i[r];i[r]=(...c)=>{let u=l.apply(i,c);return u===!1&&(u=a.apply(i,c)),u||""}}s.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new Qn(this.defaults);for(let o in n.tokenizer){if(!(o in i))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let r=o,l=n.tokenizer[r],a=i[r];i[r]=(...c)=>{let u=l.apply(i,c);return u===!1&&(u=a.apply(i,c)),u}}s.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new Wt;for(let o in n.hooks){if(!(o in i))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let r=o,l=n.hooks[r],a=i[r];Wt.passThroughHooks.has(o)?i[r]=c=>{if(this.defaults.async&&Wt.passThroughHooksRespectAsync.has(o))return(async()=>{let p=await l.call(i,c);return a.call(i,p)})();let u=l.call(i,c);return a.call(i,u)}:i[r]=(...c)=>{if(this.defaults.async)return(async()=>{let p=await l.apply(i,c);return p===!1&&(p=await a.apply(i,c)),p})();let u=l.apply(i,c);return u===!1&&(u=a.apply(i,c)),u}}s.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,o=n.walkTokens;s.walkTokens=function(r){let l=[];return l.push(o.call(this,r)),i&&(l=l.concat(i.call(this,r))),l}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return pe.lex(e,t??this.defaults)}parser(e,t){return he.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let s={...n},i={...this.defaults,...s},o=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&s.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let r=i.hooks?await i.hooks.preprocess(t):t,l=await(i.hooks?await i.hooks.provideLexer():e?pe.lex:pe.lexInline)(r,i),a=i.hooks?await i.hooks.processAllTokens(l):l;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let c=await(i.hooks?await i.hooks.provideParser():e?he.parse:he.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(c):c})().catch(o);try{i.hooks&&(t=i.hooks.preprocess(t));let r=(i.hooks?i.hooks.provideLexer():e?pe.lex:pe.lexInline)(t,i);i.hooks&&(r=i.hooks.processAllTokens(r)),i.walkTokens&&this.walkTokens(r,i.walkTokens);let l=(i.hooks?i.hooks.provideParser():e?he.parse:he.parseInline)(r,i);return i.hooks&&(l=i.hooks.postprocess(l)),l}catch(r){return o(r)}}}onError(e,t){return n=>{if(n.message+=`
1597
+ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+Ee(n.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}},Ze=new gf;function D(e,t){return Ze.parse(e,t)}D.options=D.setOptions=function(e){return Ze.setOptions(e),D.defaults=Ze.defaults,Pl(D.defaults),D};D.getDefaults=co;D.defaults=nt;D.use=function(...e){return Ze.use(...e),D.defaults=Ze.defaults,Pl(D.defaults),D};D.walkTokens=function(e,t){return Ze.walkTokens(e,t)};D.parseInline=Ze.parseInline;D.Parser=he;D.parser=he.parse;D.Renderer=Yn;D.TextRenderer=vo;D.Lexer=pe;D.lexer=pe.lex;D.Tokenizer=Qn;D.Hooks=Wt;D.parse=D;D.options;D.setOptions;D.use;D.walkTokens;D.parseInline;he.parse;pe.lex;D.setOptions({gfm:!0,breaks:!0,mangle:!1});const Hr=["a","b","blockquote","br","code","del","em","h1","h2","h3","h4","hr","i","li","ol","p","pre","strong","table","tbody","td","th","thead","tr","ul"],qr=["class","href","rel","target","title","start"];let Gr=!1;const mf=14e4,yf=4e4,vf=200,qs=5e4,Ge=new Map;function bf(e){const t=Ge.get(e);return t===void 0?null:(Ge.delete(e),Ge.set(e,t),t)}function Vr(e,t){if(Ge.set(e,t),Ge.size<=vf)return;const n=Ge.keys().next().value;n&&Ge.delete(n)}function wf(){Gr||(Gr=!0,wi.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function xi(e){const t=e.trim();if(!t)return"";if(wf(),t.length<=qs){const r=bf(t);if(r!==null)return r}const n=Pa(t,mf),s=n.truncated?`
1584
1598
 
1585
- … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>vf){const l=`<pre class="code-block">${Sf(`${n.text}${s}`)}</pre>`,a=wi.sanitize(l,{ALLOWED_TAGS:jr,ALLOWED_ATTR:Hr});return t.length<=qs&&Gr(t,a),a}const i=D.parse(`${n.text}${s}`),o=wi.sanitize(i,{ALLOWED_TAGS:jr,ALLOWED_ATTR:Hr});return t.length<=qs&&Gr(t,o),o}function Sf(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const Af=1500,xf=2e3,Kl="Copy as markdown",$f="Copied",Ef="Copy failed";async function Tf(e){if(!e)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{try{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch{return!1}}}function Tn(e,t){e.title=t,e.setAttribute("aria-label",t)}function Cf(e){const t=e.label??Kl;return d`
1599
+ … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>yf){const l=`<pre class="code-block">${kf(`${n.text}${s}`)}</pre>`,a=wi.sanitize(l,{ALLOWED_TAGS:Hr,ALLOWED_ATTR:qr});return t.length<=qs&&Vr(t,a),a}const i=D.parse(`${n.text}${s}`),o=wi.sanitize(i,{ALLOWED_TAGS:Hr,ALLOWED_ATTR:qr});return t.length<=qs&&Vr(t,o),o}function kf(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const Sf=1500,Af=2e3,Kl="Copy as markdown",xf="Copied",$f="Copy failed";async function Ef(e){if(!e)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{try{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch{return!1}}}function Tn(e,t){e.title=t,e.setAttribute("aria-label",t)}function Tf(e){const t=e.label??Kl;return d`
1586
1600
  <button
1587
1601
  class="chat-copy-btn"
1588
1602
  type="button"
1589
1603
  title=${t}
1590
1604
  aria-label=${t}
1591
- @click=${async n=>{const s=n.currentTarget;if(s?.querySelector(".chat-copy-btn__icon"),!s||s.dataset.copying==="1")return;s.dataset.copying="1",s.setAttribute("aria-busy","true"),s.disabled=!0;const i=await Tf(e.text());if(s.isConnected){if(delete s.dataset.copying,s.removeAttribute("aria-busy"),s.disabled=!1,!i){s.dataset.error="1",Tn(s,Ef),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.error,Tn(s,t))},xf);return}s.dataset.copied="1",Tn(s,$f),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.copied,Tn(s,t))},Af)}}}
1605
+ @click=${async n=>{const s=n.currentTarget;if(s?.querySelector(".chat-copy-btn__icon"),!s||s.dataset.copying==="1")return;s.dataset.copying="1",s.setAttribute("aria-busy","true"),s.disabled=!0;const i=await Ef(e.text());if(s.isConnected){if(delete s.dataset.copying,s.removeAttribute("aria-busy"),s.disabled=!1,!i){s.dataset.error="1",Tn(s,$f),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.error,Tn(s,t))},Af);return}s.dataset.copied="1",Tn(s,xf),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.copied,Tn(s,t))},Sf)}}}
1592
1606
  >
1593
1607
  <span class="chat-copy-btn__icon" aria-hidden="true">
1594
1608
  <span class="chat-copy-btn__icon-copy">${N.copy}</span>
1595
1609
  <span class="chat-copy-btn__icon-check">${N.check}</span>
1596
1610
  </span>
1597
1611
  </button>
1598
- `}function _f(e){return Cf({text:()=>e,label:Kl})}function Mf(e){const t=e,n=Pf(t.content),s=[];for(const i of n){const o=String(i.type??"").toLowerCase();(["toolcall","tool_call","tooluse","tool_use"].includes(o)||typeof i.name=="string"&&i.arguments!=null)&&s.push({kind:"call",name:i.name??"tool",args:Lf(i.arguments??i.args)})}for(const i of n){const o=String(i.type??"").toLowerCase();if(o!=="toolresult"&&o!=="tool_result")continue;const r=Rf(i),l=typeof i.name=="string"?i.name:"tool";s.push({kind:"result",name:l,text:r})}if(Ia(e)&&!s.some(i=>i.kind==="result")){const i=typeof t.toolName=="string"&&t.toolName||typeof t.tool_name=="string"&&t.tool_name||"tool",o=Pa(e)??void 0;s.push({kind:"result",name:i,text:o})}return s}function Pf(e){return Array.isArray(e)?e.filter(Boolean):[]}function Lf(e){if(typeof e!="string")return e;const t=e.trim();if(!t||!t.startsWith("{")&&!t.startsWith("["))return e;try{return JSON.parse(t)}catch{return e}}function Rf(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}function If(e){const n=e.content,s=[];if(Array.isArray(n))for(const i of n){if(typeof i!="object"||i===null)continue;const o=i;if(o.type==="image"){const r=o.source;if(r?.type==="base64"&&typeof r.data=="string"){const l=r.data,a=r.media_type||"image/png",c=l.startsWith("data:")?l:`data:${a};base64,${l}`;s.push({url:c})}else typeof o.url=="string"&&s.push({url:o.url})}else if(o.type==="image_url"){const r=o.image_url;typeof r?.url=="string"&&s.push({url:r.url})}}return s}function Nf(e){return d`
1612
+ `}function Cf(e){return Tf({text:()=>e,label:Kl})}function _f(e){const t=e,n=Mf(t.content),s=[];for(const i of n){const o=String(i.type??"").toLowerCase();(["toolcall","tool_call","tooluse","tool_use"].includes(o)||typeof i.name=="string"&&i.arguments!=null)&&s.push({kind:"call",name:i.name??"tool",args:Pf(i.arguments??i.args)})}for(const i of n){const o=String(i.type??"").toLowerCase();if(o!=="toolresult"&&o!=="tool_result")continue;const r=Lf(i),l=typeof i.name=="string"?i.name:"tool";s.push({kind:"result",name:l,text:r})}if(Na(e)&&!s.some(i=>i.kind==="result")){const i=typeof t.toolName=="string"&&t.toolName||typeof t.tool_name=="string"&&t.tool_name||"tool",o=La(e)??void 0;s.push({kind:"result",name:i,text:o})}return s}function Mf(e){return Array.isArray(e)?e.filter(Boolean):[]}function Pf(e){if(typeof e!="string")return e;const t=e.trim();if(!t||!t.startsWith("{")&&!t.startsWith("["))return e;try{return JSON.parse(t)}catch{return e}}function Lf(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}function Rf(e){const n=e.content,s=[];if(Array.isArray(n))for(const i of n){if(typeof i!="object"||i===null)continue;const o=i;if(o.type==="image"){const r=o.source;if(r?.type==="base64"&&typeof r.data=="string"){const l=r.data,a=r.media_type||"image/png",c=l.startsWith("data:")?l:`data:${a};base64,${l}`;s.push({url:c})}else typeof o.url=="string"&&s.push({url:o.url})}else if(o.type==="image_url"){const r=o.image_url;typeof r?.url=="string"&&s.push({url:r.url})}}return s}function If(e){return d`
1599
1613
  <div class="chat-group assistant">
1600
1614
  <div class="chat-group-messages">
1601
1615
  <div class="chat-bubble chat-reading-indicator" aria-hidden="true">
@@ -1605,13 +1619,13 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
1605
1619
  </div>
1606
1620
  </div>
1607
1621
  </div>
1608
- `}function Of(e,t,n,s){return d`
1622
+ `}function Nf(e,t,n,s){return d`
1609
1623
  <div class="chat-group assistant">
1610
1624
  <div class="chat-group-messages">
1611
1625
  ${zl({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!1,showReasoning:!1})}
1612
1626
  </div>
1613
1627
  </div>
1614
- `}function Df(e,t){const n=Ra(e.role),s=n==="user"?"user":n==="assistant"?"assistant":"other",i=new Date(e.timestamp).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return d`
1628
+ `}function Of(e,t){const n=Ia(e.role),s=n==="user"?"user":n==="assistant"?"assistant":"other",i=new Date(e.timestamp).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return d`
1615
1629
  <div class="chat-group ${s}">
1616
1630
  <div class="chat-group-messages">
1617
1631
  ${e.messages.map((o,r)=>zl(o.message,{isStreaming:e.isStreaming&&r===e.messages.length-1,showReasoning:t.showReasoning}))}
@@ -1620,7 +1634,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
1620
1634
  </div>
1621
1635
  </div>
1622
1636
  </div>
1623
- `}function Bf(e){return e.length===0?b:d`
1637
+ `}function Df(e){return e.length===0?b:d`
1624
1638
  <div class="chat-message-images">
1625
1639
  ${e.map(t=>d`
1626
1640
  <img
@@ -1631,14 +1645,14 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
1631
1645
  />
1632
1646
  `)}
1633
1647
  </div>
1634
- `}function zl(e,t,n){const s=e,i=typeof s.role=="string"?s.role:"unknown",o=Ia(e)||i.toLowerCase()==="toolresult"||i.toLowerCase()==="tool_result"||typeof s.toolCallId=="string"||typeof s.tool_call_id=="string",l=Mf(e).length>0,a=If(e),c=a.length>0,u=Pa(e),p=t.showReasoning&&i==="assistant"?Cu(e):null,m=u?.trim()?u:null,v=p?Mu(p):null,w=m,x=(i==="assistant"||i==="user")&&!!w?.trim(),_=["chat-bubble",x?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!w&&(l||o)||!w&&!c?b:d`
1648
+ `}function zl(e,t,n){const s=e,i=typeof s.role=="string"?s.role:"unknown",o=Na(e)||i.toLowerCase()==="toolresult"||i.toLowerCase()==="tool_result"||typeof s.toolCallId=="string"||typeof s.tool_call_id=="string",l=_f(e).length>0,a=Rf(e),c=a.length>0,u=La(e),p=t.showReasoning&&i==="assistant"?Cu(e):null,m=u?.trim()?u:null,v=p?Mu(p):null,w=m,x=(i==="assistant"||i==="user")&&!!w?.trim(),_=["chat-bubble",x?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!w&&(l||o)||!w&&!c?b:d`
1635
1649
  <div class="${_}">
1636
- ${x?_f(w):b}
1637
- ${Bf(a)}
1650
+ ${x?Cf(w):b}
1651
+ ${Df(a)}
1638
1652
  ${v?d`<div class="chat-thinking">${mi(xi(v))}</div>`:b}
1639
1653
  ${w?d`<div class="chat-text">${mi(xi(w))}</div>`:b}
1640
1654
  </div>
1641
- `}function Ff(e){return d`
1655
+ `}function Bf(e){return d`
1642
1656
  <div class="sidebar-panel">
1643
1657
  <div class="sidebar-header">
1644
1658
  <div class="sidebar-title">Tool Output</div>
@@ -1655,7 +1669,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
1655
1669
  `:e.content?d`<div class="sidebar-markdown">${mi(xi(e.content))}</div>`:d`<div class="muted">No content available</div>`}
1656
1670
  </div>
1657
1671
  </div>
1658
- `}var Uf=Object.defineProperty,Wf=Object.getOwnPropertyDescriptor,hs=(e,t,n,s)=>{for(var i=s>1?void 0:s?Wf(t,n):t,o=e.length-1,r;o>=0;o--)(r=e[o])&&(i=(s?r(t,n,i):r(i))||i);return s&&i&&Uf(t,n,i),i};let kt=class extends mt{constructor(){super(...arguments),this.splitRatio=.6,this.minRatio=.4,this.maxRatio=.7,this.isDragging=!1,this.startX=0,this.startRatio=0,this.handleMouseDown=e=>{this.isDragging=!0,this.startX=e.clientX,this.startRatio=this.splitRatio,this.classList.add("dragging"),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),e.preventDefault()},this.handleMouseMove=e=>{if(!this.isDragging)return;const t=this.parentElement;if(!t)return;const n=t.getBoundingClientRect().width,i=(e.clientX-this.startX)/n;let o=this.startRatio+i;o=Math.max(this.minRatio,Math.min(this.maxRatio,o)),this.dispatchEvent(new CustomEvent("resize",{detail:{splitRatio:o},bubbles:!0,composed:!0}))},this.handleMouseUp=()=>{this.isDragging=!1,this.classList.remove("dragging"),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}render(){return d``}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this.handleMouseDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}};kt.styles=zc`
1672
+ `}var Ff=Object.defineProperty,Uf=Object.getOwnPropertyDescriptor,hs=(e,t,n,s)=>{for(var i=s>1?void 0:s?Uf(t,n):t,o=e.length-1,r;o>=0;o--)(r=e[o])&&(i=(s?r(t,n,i):r(i))||i);return s&&i&&Ff(t,n,i),i};let kt=class extends mt{constructor(){super(...arguments),this.splitRatio=.6,this.minRatio=.4,this.maxRatio=.7,this.isDragging=!1,this.startX=0,this.startRatio=0,this.handleMouseDown=e=>{this.isDragging=!0,this.startX=e.clientX,this.startRatio=this.splitRatio,this.classList.add("dragging"),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),e.preventDefault()},this.handleMouseMove=e=>{if(!this.isDragging)return;const t=this.parentElement;if(!t)return;const n=t.getBoundingClientRect().width,i=(e.clientX-this.startX)/n;let o=this.startRatio+i;o=Math.max(this.minRatio,Math.min(this.maxRatio,o)),this.dispatchEvent(new CustomEvent("resize",{detail:{splitRatio:o},bubbles:!0,composed:!0}))},this.handleMouseUp=()=>{this.isDragging=!1,this.classList.remove("dragging"),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}render(){return d``}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this.handleMouseDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}};kt.styles=zc`
1659
1673
  :host {
1660
1674
  width: 4px;
1661
1675
  cursor: col-resize;
@@ -1681,21 +1695,21 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
1681
1695
  :host(.dragging) {
1682
1696
  background: var(--accent, #007bff);
1683
1697
  }
1684
- `;hs([is({type:Number})],kt.prototype,"splitRatio",2);hs([is({type:Number})],kt.prototype,"minRatio",2);hs([is({type:Number})],kt.prototype,"maxRatio",2);kt=hs([$a("resizable-divider")],kt);function Cn(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function Gs(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const Kf=1,zf=1,st="emoji",St="keyvalue",bo="favorites",jf="tokens",jl="tokens",Hf="unicode",Hl="count",qf="group",Gf="order",ql="group-order",$i="eTag",Xn="url",Vr="skinTone",$t="readonly",wo="readwrite",Gl="skinUnicodes",Vf="skinUnicodes",Qf="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Yf="en";function Xf(e,t){const n=new Set,s=[];for(const i of e){const o=t(i);n.has(o)||(n.add(o),s.push(i))}return s}function Qr(e){return Xf(e,t=>t.unicode)}function Zf(e){function t(n,s,i){const o=s?e.createObjectStore(n,{keyPath:s}):e.createObjectStore(n);if(i)for(const[r,[l,a]]of Object.entries(i))o.createIndex(r,l,{multiEntry:a});return o}t(St),t(st,Hf,{[jl]:[jf,!0],[ql]:[[qf,Gf]],[Gl]:[Vf,!0]}),t(bo,void 0,{[Hl]:[""]})}const Ei={},On={},Zn={};function Vl(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function Jf(e){const t=await new Promise((n,s)=>{const i=indexedDB.open(e,Kf);Ei[e]=i,i.onupgradeneeded=o=>{o.oldVersion<zf&&Zf(i.result)},Vl(n,s,i)});return t.onclose=()=>ko(e),t}function eg(e){return On[e]||(On[e]=Jf(e)),On[e]}function _e(e,t,n,s){return new Promise((i,o)=>{const r=e.transaction(t,n,{durability:"relaxed"}),l=typeof t=="string"?r.objectStore(t):t.map(c=>r.objectStore(c));let a;s(l,r,c=>{a=c}),r.oncomplete=()=>i(a),r.onerror=()=>o(r.error)})}function ko(e){const t=Ei[e],n=t&&t.result;if(n){n.close();const s=Zn[e];if(s)for(const i of s)i()}delete Ei[e],delete On[e],delete Zn[e]}function tg(e){return new Promise((t,n)=>{ko(e);const s=indexedDB.deleteDatabase(e);Vl(t,n,s)})}function ng(e,t){let n=Zn[e];n||(n=Zn[e]=[]),n.push(t)}const sg=new Set([":D","XD",":'D","O:)",":X",":P",";P","XP",":L",":Z",":j","8D","XO","8)",":B",":O",":S",":'o","Dx","X(","D:",":C",">0)",":3","</3","<3","\\M/",":E","8#"]);function yt(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||sg.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const ig=2;function Ql(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=ig)}function og(e){return e.map(({annotation:n,emoticon:s,group:i,order:o,shortcodes:r,skins:l,tags:a,emoji:c,version:u})=>{const p=[...new Set(Ql([...(r||[]).map(yt).flat(),...(a||[]).map(yt).flat(),...yt(n),s]))].sort(),m={annotation:n,group:i,order:o,tags:a,tokens:p,unicode:c,version:u};if(s&&(m.emoticon=s),r&&(m.shortcodes=r),l){m.skinTones=[],m.skinUnicodes=[],m.skinVersions=[];for(const{tone:v,emoji:w,version:x}of l)m.skinTones.push(v),m.skinUnicodes.push(w),m.skinVersions.push(x)}return m})}function Yl(e,t,n,s){e[t](n).onsuccess=i=>s&&s(i.target.result)}function Je(e,t,n){Yl(e,"get",t,n)}function Xl(e,t,n){Yl(e,"getAll",t,n)}function So(e){e.commit&&e.commit()}function rg(e,t){let n=e[0];for(let s=1;s<e.length;s++){const i=e[s];t(n)>t(i)&&(n=i)}return n}function Zl(e,t){const n=rg(e,i=>i.length),s=[];for(const i of n)e.some(o=>o.findIndex(r=>t(r)===t(i))===-1)||s.push(i);return s}async function ag(e){return!await Ao(e,St,Xn)}async function lg(e,t,n){const[s,i]=await Promise.all([$i,Xn].map(o=>Ao(e,St,o)));return s===n&&i===t}async function cg(e,t){return _e(e,st,$t,(s,i,o)=>{let r;const l=()=>{s.getAll(r&&IDBKeyRange.lowerBound(r,!0),50).onsuccess=a=>{const c=a.target.result;for(const u of c)if(r=u.unicode,t(u))return o(u);if(c.length<50)return o();l()}};l()})}async function Jl(e,t,n,s){{const i=og(t);await _e(e,[st,St],wo,([o,r],l)=>{let a,c,u=0;function p(){++u===2&&m()}function m(){if(!(a===s&&c===n)){o.clear();for(const v of i)o.put(v);r.put(s,$i),r.put(n,Xn),So(l)}}Je(r,$i,v=>{a=v,p()}),Je(r,Xn,v=>{c=v,p()})})}}async function ug(e,t){return _e(e,st,$t,(n,s,i)=>{const o=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);Xl(n.index(ql),o,i)})}async function ec(e,t){const n=Ql(yt(t));return n.length?_e(e,st,$t,(s,i,o)=>{const r=[],l=()=>{r.length===n.length&&a()},a=()=>{const c=Zl(r,u=>u.unicode);o(c.sort((u,p)=>u.order<p.order?-1:1))};for(let c=0;c<n.length;c++){const u=n[c],p=c===n.length-1?IDBKeyRange.bound(u,u+"￿",!1,!0):IDBKeyRange.only(u);Xl(s.index(jl),p,m=>{r.push(m),l()})}}):[]}async function dg(e,t){const n=await ec(e,t);return n.length?n.filter(s=>(s.shortcodes||[]).map(o=>o.toLowerCase()).includes(t.toLowerCase()))[0]||null:await cg(e,i=>(i.shortcodes||[]).includes(t.toLowerCase()))||null}async function pg(e,t){return _e(e,st,$t,(n,s,i)=>Je(n,t,o=>{if(o)return i(o);Je(n.index(Gl),t,r=>i(r||null))}))}function Ao(e,t,n){return _e(e,t,$t,(s,i,o)=>Je(s,n,o))}function hg(e,t,n,s){return _e(e,t,wo,(i,o)=>{i.put(s,n),So(o)})}function fg(e,t){return _e(e,bo,wo,(n,s)=>Je(n,t,i=>{n.put((i||0)+1,t),So(s)}))}function gg(e,t,n){return n===0?[]:_e(e,[bo,st],$t,([s,i],o,r)=>{const l=[];s.index(Hl).openCursor(void 0,"prev").onsuccess=a=>{const c=a.target.result;if(!c)return r(l);function u(v){if(l.push(v),l.length===n)return r(l);c.continue()}const p=c.primaryKey,m=t.byName(p);if(m)return u(m);Je(i,p,v=>{if(v)return u(v);c.continue()})}})}const _n="";function mg(e,t){const n=new Map;for(const i of e){const o=t(i);for(const r of o){let l=n;for(let c=0;c<r.length;c++){const u=r.charAt(c);let p=l.get(u);p||(p=new Map,l.set(u,p)),l=p}let a=l.get(_n);a||(a=[],l.set(_n,a)),a.push(i)}}return(i,o)=>{let r=n;for(let c=0;c<i.length;c++){const u=i.charAt(c),p=r.get(u);if(p)r=p;else return[]}if(o)return r.get(_n)||[];const l=[],a=[r];for(;a.length;){const u=[...a.shift().entries()].sort((p,m)=>p[0]<m[0]?-1:1);for(const[p,m]of u)p===_n?l.push(...m):a.push(m)}return l}}const yg=["name","url"];function vg(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||yg.some(s=>!(s in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function Yr(e){vg(e);const t=(m,v)=>m.name.toLowerCase()<v.name.toLowerCase()?-1:1,n=e.sort(t),i=mg(e,m=>{const v=new Set;if(m.shortcodes)for(const w of m.shortcodes)for(const x of yt(w))v.add(x);return v}),o=m=>i(m,!0),r=m=>i(m,!1),l=m=>{const v=yt(m),w=v.map((x,_)=>(_<v.length-1?o:r)(x));return Zl(w,x=>x.name).sort(t)},a=new Map,c=new Map;for(const m of e){c.set(m.name.toLowerCase(),m);for(const v of m.shortcodes||[])a.set(v.toLowerCase(),m)}return{all:n,search:l,byShortcode:m=>a.get(m.toLowerCase()),byName:m=>c.get(m.toLowerCase())}}const bg=typeof wrappedJSObject<"u";function Ft(e){if(!e)return e;if(bg&&(e=structuredClone(e)),delete e.tokens,e.skinTones){const t=e.skinTones.length;e.skins=Array(t);for(let n=0;n<t;n++)e.skins[n]={tone:e.skinTones[n],unicode:e.skinUnicodes[n],version:e.skinVersions[n]};delete e.skinTones,delete e.skinUnicodes,delete e.skinVersions}return e}function tc(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const wg=["annotation","emoji","group","order","version"];function kg(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||wg.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function nc(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function Sg(e){const t=await fetch(e,{method:"HEAD"});nc(t,e);const n=t.headers.get("etag");return tc(n),n}async function Ti(e){const t=await fetch(e);nc(t,e);const n=t.headers.get("etag");tc(n);const s=await t.json();return kg(s),[n,s]}function Ag(e){for(var t="",n=new Uint8Array(e),s=n.byteLength,i=-1;++i<s;)t+=String.fromCharCode(n[i]);return t}function xg(e){for(var t=e.length,n=new ArrayBuffer(t),s=new Uint8Array(n),i=-1;++i<t;)s[i]=e.charCodeAt(i);return n}async function sc(e){const t=JSON.stringify(e);let n=xg(t);const s=await crypto.subtle.digest("SHA-1",n),i=Ag(s);return btoa(i)}async function $g(e,t){let n,s=await Sg(t);if(!s){const i=await Ti(t);s=i[0],n=i[1],s||(s=await sc(n))}await lg(e,t,s)||(n||(n=(await Ti(t))[1]),await Jl(e,n,t,s))}async function Eg(e,t){let[n,s]=await Ti(t);n||(n=await sc(s)),await Jl(e,s,t,n)}async function Tg(e,t){try{await $g(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class Cg{constructor({dataSource:t=Qf,locale:n=Yf,customEmoji:s=[]}={}){this.dataSource=t,this.locale=n,this._dbName=`emoji-picker-element-${this.locale}`,this._db=void 0,this._lazyUpdate=void 0,this._custom=Yr(s),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await eg(this._dbName);ng(this._dbName,this._clear);const n=this.dataSource;await ag(t)?await Eg(t,n):this._lazyUpdate=Tg(t,n)}async ready(){const t=async()=>(this._ready||(this._ready=this._init()),this._ready);await t(),this._db||await t()}async getEmojiByGroup(t){return Gs(t),await this.ready(),Qr(await ug(this._db,t)).map(Ft)}async getEmojiBySearchQuery(t){Cn(t),await this.ready();const n=this._custom.search(t),s=Qr(await ec(this._db,t)).map(Ft);return[...n,...s]}async getEmojiByShortcode(t){Cn(t),await this.ready();const n=this._custom.byShortcode(t);return n||Ft(await dg(this._db,t))}async getEmojiByUnicodeOrName(t){Cn(t),await this.ready();const n=this._custom.byName(t);return n||Ft(await pg(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await Ao(this._db,St,Vr)||0}async setPreferredSkinTone(t){return Gs(t),await this.ready(),hg(this._db,St,Vr,t)}async incrementFavoriteEmojiCount(t){return Cn(t),await this.ready(),fg(this._db,t)}async getTopFavoriteEmoji(t){return Gs(t),await this.ready(),(await gg(this._db,this._custom,t)).map(Ft)}set customEmoji(t){this._custom=Yr(t)}get customEmoji(){return this._custom.all}async _shutdown(){await this.ready();try{await this._lazyUpdate}catch{}}_clear(){this._db=this._ready=this._lazyUpdate=void 0}async close(){await this._shutdown(),await ko(this._dbName)}async delete(){await this._shutdown(),await tg(this._dbName)}}const Ci=[[-1,"✨","custom"],[0,"😀","smileys-emotion"],[1,"👋","people-body"],[3,"🐱","animals-nature"],[4,"🍎","food-drink"],[5,"🏠️","travel-places"],[6,"⚽","activities"],[7,"📝","objects"],[8,"⛔️","symbols"],[9,"🏁","flags"]].map(([e,t,n])=>({id:e,emoji:t,name:n})),Vs=Ci.slice(1),_g=2,Xr=6,ic=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function Zr(e){return e.unicode.includes("‍")}const Mg={"🫪":17,"🫩":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱‍♀️":4,"🤣":3,"👁️‍🗨️":2,"😀":1,"😐️":.7,"😃":.6},Pg=1e3,Lg="🖐️",Rg=8,Ig=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],oc='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',Ng=(e,t)=>e<t?-1:e>t?1:0,Jr=(e,t)=>{const n=document.createElement("canvas");n.width=n.height=1;const s=n.getContext("2d",{willReadFrequently:!0});return s.textBaseline="top",s.font=`100px ${oc}`,s.fillStyle=t,s.scale(.01,.01),s.fillText(e,0,0),s.getImageData(0,0,1,1).data},Og=(e,t)=>{const n=[...e].join(","),s=[...t].join(",");return n===s&&!n.startsWith("0,0,0,")};function Dg(e){const t=Jr(e,"#000"),n=Jr(e,"#fff");return t&&n&&Og(t,n)}function Bg(){const e=Object.entries(Mg);try{for(const[t,n]of e)if(Dg(t))return n}catch{}return e[0][1]}let Qs;const Ys=()=>(Qs||(Qs=new Promise(e=>ic(()=>e(Bg())))),Qs),_i=new Map,Fg="️",Ug="\uD83C",Wg="‍",Kg=127995,zg=57339;function jg(e,t){if(t===0)return e;const n=e.indexOf(Wg);return n!==-1?e.substring(0,n)+String.fromCodePoint(Kg+t-1)+e.substring(n):(e.endsWith(Fg)&&(e=e.substring(0,e.length-1)),e+Ug+String.fromCodePoint(zg+t-1))}function ve(e){e.preventDefault(),e.stopPropagation()}function Xs(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function rc(e,t){const n=new Set,s=[];for(const i of e){const o=t(i);n.has(o)||(n.add(o),s.push(i))}return s}function Hg(e,t){const n=s=>{const i={};for(const o of s)typeof o.tone=="number"&&o.version<=t&&(i[o.tone]=o.unicode);return i};return e.map(({unicode:s,skins:i,shortcodes:o,url:r,name:l,category:a,annotation:c})=>({unicode:s,name:l,shortcodes:o,url:r,category:a,annotation:c,id:s||l,skins:i&&n(i)}))}const Dn=requestAnimationFrame;let qg=typeof ResizeObserver=="function";function Gg(e,t,n){let s;qg?(s=new ResizeObserver(n),s.observe(e)):Dn(n),t.addEventListener("abort",()=>{s&&s.disconnect()})}function ea(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let Zs;function Vg(e,t,n){let s=!0,i=!1;for(const o of e){const r=n(o);if(!r)continue;const l=ea(r);l===0&&(i=!0),typeof Zs>"u"&&(Zs=ea(t));const a=l/1.8<Zs;_i.set(o.unicode,a),a||(s=!1)}return i&&console.warn(`Emoji support detection failed - emoji character is 0 width.
1698
+ `;hs([is({type:Number})],kt.prototype,"splitRatio",2);hs([is({type:Number})],kt.prototype,"minRatio",2);hs([is({type:Number})],kt.prototype,"maxRatio",2);kt=hs([Ea("resizable-divider")],kt);function Cn(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function Gs(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const Wf=1,Kf=1,st="emoji",St="keyvalue",bo="favorites",zf="tokens",jl="tokens",jf="unicode",Hl="count",Hf="group",qf="order",ql="group-order",$i="eTag",Xn="url",Qr="skinTone",$t="readonly",wo="readwrite",Gl="skinUnicodes",Gf="skinUnicodes",Vf="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Qf="en";function Yf(e,t){const n=new Set,s=[];for(const i of e){const o=t(i);n.has(o)||(n.add(o),s.push(i))}return s}function Yr(e){return Yf(e,t=>t.unicode)}function Xf(e){function t(n,s,i){const o=s?e.createObjectStore(n,{keyPath:s}):e.createObjectStore(n);if(i)for(const[r,[l,a]]of Object.entries(i))o.createIndex(r,l,{multiEntry:a});return o}t(St),t(st,jf,{[jl]:[zf,!0],[ql]:[[Hf,qf]],[Gl]:[Gf,!0]}),t(bo,void 0,{[Hl]:[""]})}const Ei={},On={},Zn={};function Vl(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function Zf(e){const t=await new Promise((n,s)=>{const i=indexedDB.open(e,Wf);Ei[e]=i,i.onupgradeneeded=o=>{o.oldVersion<Kf&&Xf(i.result)},Vl(n,s,i)});return t.onclose=()=>ko(e),t}function Jf(e){return On[e]||(On[e]=Zf(e)),On[e]}function _e(e,t,n,s){return new Promise((i,o)=>{const r=e.transaction(t,n,{durability:"relaxed"}),l=typeof t=="string"?r.objectStore(t):t.map(c=>r.objectStore(c));let a;s(l,r,c=>{a=c}),r.oncomplete=()=>i(a),r.onerror=()=>o(r.error)})}function ko(e){const t=Ei[e],n=t&&t.result;if(n){n.close();const s=Zn[e];if(s)for(const i of s)i()}delete Ei[e],delete On[e],delete Zn[e]}function eg(e){return new Promise((t,n)=>{ko(e);const s=indexedDB.deleteDatabase(e);Vl(t,n,s)})}function tg(e,t){let n=Zn[e];n||(n=Zn[e]=[]),n.push(t)}const ng=new Set([":D","XD",":'D","O:)",":X",":P",";P","XP",":L",":Z",":j","8D","XO","8)",":B",":O",":S",":'o","Dx","X(","D:",":C",">0)",":3","</3","<3","\\M/",":E","8#"]);function yt(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||ng.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const sg=2;function Ql(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=sg)}function ig(e){return e.map(({annotation:n,emoticon:s,group:i,order:o,shortcodes:r,skins:l,tags:a,emoji:c,version:u})=>{const p=[...new Set(Ql([...(r||[]).map(yt).flat(),...(a||[]).map(yt).flat(),...yt(n),s]))].sort(),m={annotation:n,group:i,order:o,tags:a,tokens:p,unicode:c,version:u};if(s&&(m.emoticon=s),r&&(m.shortcodes=r),l){m.skinTones=[],m.skinUnicodes=[],m.skinVersions=[];for(const{tone:v,emoji:w,version:x}of l)m.skinTones.push(v),m.skinUnicodes.push(w),m.skinVersions.push(x)}return m})}function Yl(e,t,n,s){e[t](n).onsuccess=i=>s&&s(i.target.result)}function Je(e,t,n){Yl(e,"get",t,n)}function Xl(e,t,n){Yl(e,"getAll",t,n)}function So(e){e.commit&&e.commit()}function og(e,t){let n=e[0];for(let s=1;s<e.length;s++){const i=e[s];t(n)>t(i)&&(n=i)}return n}function Zl(e,t){const n=og(e,i=>i.length),s=[];for(const i of n)e.some(o=>o.findIndex(r=>t(r)===t(i))===-1)||s.push(i);return s}async function rg(e){return!await Ao(e,St,Xn)}async function ag(e,t,n){const[s,i]=await Promise.all([$i,Xn].map(o=>Ao(e,St,o)));return s===n&&i===t}async function lg(e,t){return _e(e,st,$t,(s,i,o)=>{let r;const l=()=>{s.getAll(r&&IDBKeyRange.lowerBound(r,!0),50).onsuccess=a=>{const c=a.target.result;for(const u of c)if(r=u.unicode,t(u))return o(u);if(c.length<50)return o();l()}};l()})}async function Jl(e,t,n,s){{const i=ig(t);await _e(e,[st,St],wo,([o,r],l)=>{let a,c,u=0;function p(){++u===2&&m()}function m(){if(!(a===s&&c===n)){o.clear();for(const v of i)o.put(v);r.put(s,$i),r.put(n,Xn),So(l)}}Je(r,$i,v=>{a=v,p()}),Je(r,Xn,v=>{c=v,p()})})}}async function cg(e,t){return _e(e,st,$t,(n,s,i)=>{const o=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);Xl(n.index(ql),o,i)})}async function ec(e,t){const n=Ql(yt(t));return n.length?_e(e,st,$t,(s,i,o)=>{const r=[],l=()=>{r.length===n.length&&a()},a=()=>{const c=Zl(r,u=>u.unicode);o(c.sort((u,p)=>u.order<p.order?-1:1))};for(let c=0;c<n.length;c++){const u=n[c],p=c===n.length-1?IDBKeyRange.bound(u,u+"￿",!1,!0):IDBKeyRange.only(u);Xl(s.index(jl),p,m=>{r.push(m),l()})}}):[]}async function ug(e,t){const n=await ec(e,t);return n.length?n.filter(s=>(s.shortcodes||[]).map(o=>o.toLowerCase()).includes(t.toLowerCase()))[0]||null:await lg(e,i=>(i.shortcodes||[]).includes(t.toLowerCase()))||null}async function dg(e,t){return _e(e,st,$t,(n,s,i)=>Je(n,t,o=>{if(o)return i(o);Je(n.index(Gl),t,r=>i(r||null))}))}function Ao(e,t,n){return _e(e,t,$t,(s,i,o)=>Je(s,n,o))}function pg(e,t,n,s){return _e(e,t,wo,(i,o)=>{i.put(s,n),So(o)})}function hg(e,t){return _e(e,bo,wo,(n,s)=>Je(n,t,i=>{n.put((i||0)+1,t),So(s)}))}function fg(e,t,n){return n===0?[]:_e(e,[bo,st],$t,([s,i],o,r)=>{const l=[];s.index(Hl).openCursor(void 0,"prev").onsuccess=a=>{const c=a.target.result;if(!c)return r(l);function u(v){if(l.push(v),l.length===n)return r(l);c.continue()}const p=c.primaryKey,m=t.byName(p);if(m)return u(m);Je(i,p,v=>{if(v)return u(v);c.continue()})}})}const _n="";function gg(e,t){const n=new Map;for(const i of e){const o=t(i);for(const r of o){let l=n;for(let c=0;c<r.length;c++){const u=r.charAt(c);let p=l.get(u);p||(p=new Map,l.set(u,p)),l=p}let a=l.get(_n);a||(a=[],l.set(_n,a)),a.push(i)}}return(i,o)=>{let r=n;for(let c=0;c<i.length;c++){const u=i.charAt(c),p=r.get(u);if(p)r=p;else return[]}if(o)return r.get(_n)||[];const l=[],a=[r];for(;a.length;){const u=[...a.shift().entries()].sort((p,m)=>p[0]<m[0]?-1:1);for(const[p,m]of u)p===_n?l.push(...m):a.push(m)}return l}}const mg=["name","url"];function yg(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||mg.some(s=>!(s in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function Xr(e){yg(e);const t=(m,v)=>m.name.toLowerCase()<v.name.toLowerCase()?-1:1,n=e.sort(t),i=gg(e,m=>{const v=new Set;if(m.shortcodes)for(const w of m.shortcodes)for(const x of yt(w))v.add(x);return v}),o=m=>i(m,!0),r=m=>i(m,!1),l=m=>{const v=yt(m),w=v.map((x,_)=>(_<v.length-1?o:r)(x));return Zl(w,x=>x.name).sort(t)},a=new Map,c=new Map;for(const m of e){c.set(m.name.toLowerCase(),m);for(const v of m.shortcodes||[])a.set(v.toLowerCase(),m)}return{all:n,search:l,byShortcode:m=>a.get(m.toLowerCase()),byName:m=>c.get(m.toLowerCase())}}const vg=typeof wrappedJSObject<"u";function Ft(e){if(!e)return e;if(vg&&(e=structuredClone(e)),delete e.tokens,e.skinTones){const t=e.skinTones.length;e.skins=Array(t);for(let n=0;n<t;n++)e.skins[n]={tone:e.skinTones[n],unicode:e.skinUnicodes[n],version:e.skinVersions[n]};delete e.skinTones,delete e.skinUnicodes,delete e.skinVersions}return e}function tc(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const bg=["annotation","emoji","group","order","version"];function wg(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||bg.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function nc(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function kg(e){const t=await fetch(e,{method:"HEAD"});nc(t,e);const n=t.headers.get("etag");return tc(n),n}async function Ti(e){const t=await fetch(e);nc(t,e);const n=t.headers.get("etag");tc(n);const s=await t.json();return wg(s),[n,s]}function Sg(e){for(var t="",n=new Uint8Array(e),s=n.byteLength,i=-1;++i<s;)t+=String.fromCharCode(n[i]);return t}function Ag(e){for(var t=e.length,n=new ArrayBuffer(t),s=new Uint8Array(n),i=-1;++i<t;)s[i]=e.charCodeAt(i);return n}async function sc(e){const t=JSON.stringify(e);let n=Ag(t);const s=await crypto.subtle.digest("SHA-1",n),i=Sg(s);return btoa(i)}async function xg(e,t){let n,s=await kg(t);if(!s){const i=await Ti(t);s=i[0],n=i[1],s||(s=await sc(n))}await ag(e,t,s)||(n||(n=(await Ti(t))[1]),await Jl(e,n,t,s))}async function $g(e,t){let[n,s]=await Ti(t);n||(n=await sc(s)),await Jl(e,s,t,n)}async function Eg(e,t){try{await xg(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class Tg{constructor({dataSource:t=Vf,locale:n=Qf,customEmoji:s=[]}={}){this.dataSource=t,this.locale=n,this._dbName=`emoji-picker-element-${this.locale}`,this._db=void 0,this._lazyUpdate=void 0,this._custom=Xr(s),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await Jf(this._dbName);tg(this._dbName,this._clear);const n=this.dataSource;await rg(t)?await $g(t,n):this._lazyUpdate=Eg(t,n)}async ready(){const t=async()=>(this._ready||(this._ready=this._init()),this._ready);await t(),this._db||await t()}async getEmojiByGroup(t){return Gs(t),await this.ready(),Yr(await cg(this._db,t)).map(Ft)}async getEmojiBySearchQuery(t){Cn(t),await this.ready();const n=this._custom.search(t),s=Yr(await ec(this._db,t)).map(Ft);return[...n,...s]}async getEmojiByShortcode(t){Cn(t),await this.ready();const n=this._custom.byShortcode(t);return n||Ft(await ug(this._db,t))}async getEmojiByUnicodeOrName(t){Cn(t),await this.ready();const n=this._custom.byName(t);return n||Ft(await dg(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await Ao(this._db,St,Qr)||0}async setPreferredSkinTone(t){return Gs(t),await this.ready(),pg(this._db,St,Qr,t)}async incrementFavoriteEmojiCount(t){return Cn(t),await this.ready(),hg(this._db,t)}async getTopFavoriteEmoji(t){return Gs(t),await this.ready(),(await fg(this._db,this._custom,t)).map(Ft)}set customEmoji(t){this._custom=Xr(t)}get customEmoji(){return this._custom.all}async _shutdown(){await this.ready();try{await this._lazyUpdate}catch{}}_clear(){this._db=this._ready=this._lazyUpdate=void 0}async close(){await this._shutdown(),await ko(this._dbName)}async delete(){await this._shutdown(),await eg(this._dbName)}}const Ci=[[-1,"✨","custom"],[0,"😀","smileys-emotion"],[1,"👋","people-body"],[3,"🐱","animals-nature"],[4,"🍎","food-drink"],[5,"🏠️","travel-places"],[6,"⚽","activities"],[7,"📝","objects"],[8,"⛔️","symbols"],[9,"🏁","flags"]].map(([e,t,n])=>({id:e,emoji:t,name:n})),Vs=Ci.slice(1),Cg=2,Zr=6,ic=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function Jr(e){return e.unicode.includes("‍")}const _g={"🫪":17,"🫩":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱‍♀️":4,"🤣":3,"👁️‍🗨️":2,"😀":1,"😐️":.7,"😃":.6},Mg=1e3,Pg="🖐️",Lg=8,Rg=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],oc='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',Ig=(e,t)=>e<t?-1:e>t?1:0,ea=(e,t)=>{const n=document.createElement("canvas");n.width=n.height=1;const s=n.getContext("2d",{willReadFrequently:!0});return s.textBaseline="top",s.font=`100px ${oc}`,s.fillStyle=t,s.scale(.01,.01),s.fillText(e,0,0),s.getImageData(0,0,1,1).data},Ng=(e,t)=>{const n=[...e].join(","),s=[...t].join(",");return n===s&&!n.startsWith("0,0,0,")};function Og(e){const t=ea(e,"#000"),n=ea(e,"#fff");return t&&n&&Ng(t,n)}function Dg(){const e=Object.entries(_g);try{for(const[t,n]of e)if(Og(t))return n}catch{}return e[0][1]}let Qs;const Ys=()=>(Qs||(Qs=new Promise(e=>ic(()=>e(Dg())))),Qs),_i=new Map,Bg="️",Fg="\uD83C",Ug="‍",Wg=127995,Kg=57339;function zg(e,t){if(t===0)return e;const n=e.indexOf(Ug);return n!==-1?e.substring(0,n)+String.fromCodePoint(Wg+t-1)+e.substring(n):(e.endsWith(Bg)&&(e=e.substring(0,e.length-1)),e+Fg+String.fromCodePoint(Kg+t-1))}function ve(e){e.preventDefault(),e.stopPropagation()}function Xs(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function rc(e,t){const n=new Set,s=[];for(const i of e){const o=t(i);n.has(o)||(n.add(o),s.push(i))}return s}function jg(e,t){const n=s=>{const i={};for(const o of s)typeof o.tone=="number"&&o.version<=t&&(i[o.tone]=o.unicode);return i};return e.map(({unicode:s,skins:i,shortcodes:o,url:r,name:l,category:a,annotation:c})=>({unicode:s,name:l,shortcodes:o,url:r,category:a,annotation:c,id:s||l,skins:i&&n(i)}))}const Dn=requestAnimationFrame;let Hg=typeof ResizeObserver=="function";function qg(e,t,n){let s;Hg?(s=new ResizeObserver(n),s.observe(e)):Dn(n),t.addEventListener("abort",()=>{s&&s.disconnect()})}function ta(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let Zs;function Gg(e,t,n){let s=!0,i=!1;for(const o of e){const r=n(o);if(!r)continue;const l=ta(r);l===0&&(i=!0),typeof Zs>"u"&&(Zs=ta(t));const a=l/1.8<Zs;_i.set(o.unicode,a),a||(s=!1)}return i&&console.warn(`Emoji support detection failed - emoji character is 0 width.
1685
1699
  This is likely due to using \`display:none\` which is unsupported.
1686
1700
  If this is a Jest/Vitest environment, you can ignore this warning.
1687
- For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),s}function Qg(e){return rc(e,t=>t)}function Yg(e){e&&(e.scrollTop=0)}function Vt(e,t,n){let s=e.get(t);return s||(s=n(),e.set(t,s)),s}function ta(e){return""+e}function Xg(e){const t=document.createElement("template");return t.innerHTML=e,t}const Zg=new WeakMap,Jg=new WeakMap,em=Symbol("un-keyed"),tm="replaceChildren"in Element.prototype;function nm(e,t){tm?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function sm(e,t){let n=e.firstChild,s=0;for(;n;){if(t[s]!==n)return!0;n=n.nextSibling,s++}return s!==t.length}function im(e,t){const{targetNode:n}=t;let{targetParentNode:s}=t,i=!1;s?i=sm(s,e):(i=!0,t.targetNode=void 0,t.targetParentNode=s=n.parentNode),i&&nm(s,e)}function om(e,t){for(const n of t){const{targetNode:s,currentExpression:i,binding:{expressionIndex:o,attributeName:r,attributeValuePre:l,attributeValuePost:a}}=n,c=e[o];if(i!==c)if(n.currentExpression=c,r)if(c===null)s.removeAttribute(r);else{const u=l+ta(c)+a;s.setAttribute(r,u)}else{let u;Array.isArray(c)?im(c,n):c instanceof Element?(u=c,s.replaceWith(u)):s.nodeValue=ta(c),u&&(n.targetNode=u)}}}function rm(e){let t="",n=!1,s=!1,i=-1;const o=new Map,r=[];let l=0;for(let c=0,u=e.length;c<u;c++){const p=e[c];if(t+=p.slice(l),c===u-1)break;for(let C=0;C<p.length;C++)switch(p.charAt(C)){case"<":{p.charAt(C+1)==="/"?r.pop():(n=!0,r.push(++i));break}case">":{n=!1,s=!1;break}case"=":{s=!0;break}}const m=r[r.length-1],v=Vt(o,m,()=>[]);let w,x,_;if(s){const C=/(\S+)="?([^"=]*)$/.exec(p);w=C[1],x=C[2];const L=/^([^">]*)("?)/.exec(e[c+1]);_=L[1],t=t.slice(0,-1*C[0].length),l=L[0].length}else l=0;const j={attributeName:w,attributeValuePre:x,attributeValuePost:_,expressionIndex:c};v.push(j),!n&&!s&&(t+=" ")}return{template:Xg(t),elementsToBindings:o}}function na(e,t,n){for(let s=0;s<e.length;s++){const i=e[s],o=i.attributeName?t:t.firstChild,r={binding:i,targetNode:o,targetParentNode:void 0,currentExpression:void 0};n.push(r)}}function am(e,t){const n=[];let s;if(t.size===1&&(s=t.get(0)))na(s,e,n);else{const i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,r=-1;do{const l=t.get(++r);l&&na(l,o,n)}while(o=i.nextNode())}return n}function lm(e){const{template:t,elementsToBindings:n}=Vt(Zg,e,()=>rm(e)),s=t.cloneNode(!0).content.firstElementChild,i=am(s,n);return function(r){return om(r,i),s}}function cm(e){const t=Vt(Jg,e,()=>new Map);let n=em;function s(o,...r){const l=Vt(t,o,()=>new Map);return Vt(l,n,()=>lm(o))(r)}function i(o,r,l){return o.map((a,c)=>{const u=n;n=l(a);try{return r(a,c)}finally{n=u}})}return{map:i,html:s}}function um(e,t,n,s,i,o,r,l,a){const{labelWithSkin:c,titleForEmoji:u,unicodeWithSkin:p}=n,{html:m,map:v}=cm(t);function w(C,L,I){return v(C,(B,ue)=>m`<button role="${L?"option":"menuitem"}" aria-selected="${L?ue===t.activeSearchItem:null}" aria-label="${c(B,t.currentSkinTone)}" title="${u(B)}" class="${"emoji"+(L&&ue===t.activeSearchItem?" active":"")+(B.unicode?"":" custom-emoji")}" id="${`${I}-${B.id}`}" style="${B.unicode?null:`--custom-emoji-background: url(${JSON.stringify(B.url)})`}">${B.unicode?p(B,t.currentSkinTone):""}</button>`,B=>`${I}-${B.id}`)}const _=m`<section data-ref="rootElement" class="picker" aria-label="${t.i18n.regionLabel}" style="${t.pickerStyle||""}"><div class="pad-top"></div><div class="search-row"><div class="search-wrapper"><input id="search" class="search" type="search" role="combobox" enterkeyhint="search" placeholder="${t.i18n.searchLabel}" autocapitalize="none" autocomplete="off" spellcheck="true" aria-expanded="${!!(t.searchMode&&t.currentEmojis.length)}" aria-controls="search-results" aria-describedby="search-description" aria-autocomplete="list" aria-activedescendant="${t.activeSearchItemId?`emo-${t.activeSearchItemId}`:null}" data-ref="searchElement" data-on-input="onSearchInput" data-on-keydown="onSearchKeydown"><label class="sr-only" for="search">${t.i18n.searchLabel}</label> <span id="search-description" class="sr-only">${t.i18n.searchDescription}</span></div><div class="skintone-button-wrapper ${t.skinTonePickerExpandedAfterAnimation?"expanded":""}"><button id="skintone-button" class="emoji ${t.skinTonePickerExpanded?"hide-focus":""}" aria-label="${t.skinToneButtonLabel}" title="${t.skinToneButtonLabel}" aria-describedby="skintone-description" aria-haspopup="listbox" aria-expanded="${t.skinTonePickerExpanded}" aria-controls="skintone-list" data-on-click="onClickSkinToneButton">${t.skinToneButtonText||""}</button></div><span id="skintone-description" class="sr-only">${t.i18n.skinToneDescription}</span><div data-ref="skinToneDropdown" id="skintone-list" class="skintone-list hide-focus ${t.skinTonePickerExpanded?"":"hidden no-animate"}" style="transform:translateY(${t.skinTonePickerExpanded?0:"calc(-1 * var(--num-skintones) * var(--total-emoji-size))"})" role="listbox" aria-label="${t.i18n.skinTonesLabel}" aria-activedescendant="skintone-${t.activeSkinTone}" aria-hidden="${!t.skinTonePickerExpanded}" tabIndex="-1" data-on-focusout="onSkinToneOptionsFocusOut" data-on-click="onSkinToneOptionsClick" data-on-keydown="onSkinToneOptionsKeydown" data-on-keyup="onSkinToneOptionsKeyup">${v(t.skinTones,(C,L)=>m`<div id="skintone-${L}" class="emoji ${L===t.activeSkinTone?"active":""}" aria-selected="${L===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[L]}" aria-label="${t.i18n.skinTones[L]}">${C}</div>`,C=>C)}</div></div><div class="nav" role="tablist" style="grid-template-columns:repeat(${t.groups.length},1fr)" aria-label="${t.i18n.categoriesLabel}" data-on-keydown="onNavKeydown" data-on-click="onNavClick">${v(t.groups,C=>m`<button role="tab" class="nav-button" aria-controls="tab-${C.id}" aria-label="${t.i18n.categories[C.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===C.id}" title="${t.i18n.categories[C.name]}" data-group-id="${C.id}"><div class="nav-emoji emoji">${C.emoji}</div></button>`,C=>C.id)}</div><div class="indicator-wrapper"><div class="indicator" style="transform:translateX(${(t.isRtl?-1:1)*t.currentGroupIndex*100}%)"></div></div><div class="message ${t.message?"":"gone"}" role="alert" aria-live="polite">${t.message||""}</div><div data-ref="tabpanelElement" class="tabpanel ${!t.databaseLoaded||t.message?"gone":""}" role="${t.searchMode?"region":"tabpanel"}" aria-label="${t.searchMode?t.i18n.searchResultsLabel:t.i18n.categories[t.currentGroup.name]}" id="${t.searchMode?null:`tab-${t.currentGroup.id}`}" tabIndex="0" data-on-click="onEmojiClick"><div data-action="calculateEmojiGridStyle">${v(t.currentEmojisWithCategories,(C,L)=>m`<div><div id="menu-label-${L}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:C.category?C.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${L!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(C.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${L}" id="${t.searchMode?"search-results":null}">${w(C.emojis,t.searchMode,"emo")}</div></div>`,C=>C.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${w(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,j=(C,L)=>{for(const I of e.querySelectorAll(`[${C}]`))L(I,I.getAttribute(C))};if(a){e.appendChild(_);for(const C of["click","focusout","input","keydown","keyup"])j(`data-on-${C}`,(L,I)=>{L.addEventListener(C,s[I])});j("data-ref",(C,L)=>{o[L]=C}),r.addEventListener("abort",()=>{e.removeChild(_)})}j("data-action",(C,L)=>{let I=l.get(L);I||l.set(L,I=new WeakSet),I.has(C)||(I.add(C),i[L](C))})}const Jn=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function dm(e){let t=!1,n;const s=new Map,i=new Set;let o;const r=()=>{if(t)return;const c=[...i];i.clear();try{for(const u of c)u()}finally{o=!1,i.size&&(o=!0,Jn(r))}},l=new Proxy({},{get(c,u){if(n){let p=s.get(u);p||(p=new Set,s.set(u,p)),p.add(n)}return c[u]},set(c,u,p){if(c[u]!==p){c[u]=p;const m=s.get(u);if(m){for(const v of m)i.add(v);o||(o=!0,Jn(r))}}return!0}}),a=c=>{const u=()=>{const p=n;n=u;try{return c()}finally{n=p}};return u()};return e.addEventListener("abort",()=>{t=!0}),{state:l,createEffect:a}}function Js(e,t,n){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(!n(e[s],t[s]))return!1;return!0}const sa=new WeakMap;function pm(e,t,n){{const s=e.closest(".tabpanel");let i=sa.get(s);i||(i=new IntersectionObserver(n,{root:s,rootMargin:"50% 0px 50% 0px",threshold:0}),sa.set(s,i),t.addEventListener("abort",()=>{i.disconnect()})),i.observe(e)}}const ei=[],{assign:Mn}=Object;function hm(e,t){const n={},s=new AbortController,i=s.signal,{state:o,createEffect:r}=dm(i),l=new Map;Mn(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),Mn(o,t),Mn(o,{initialLoad:!0,currentEmojis:[],currentEmojisWithCategories:[],rawSearchText:"",searchText:"",searchMode:!1,activeSearchItem:-1,message:void 0,skinTonePickerExpanded:!1,skinTonePickerExpandedAfterAnimation:!1,currentSkinTone:0,activeSkinTone:0,skinToneButtonText:void 0,pickerStyle:void 0,skinToneButtonLabel:"",skinTones:[],currentFavorites:[],defaultFavoriteEmojis:void 0,numColumns:Rg,isRtl:!1,currentGroupIndex:0,groups:Vs,databaseLoaded:!1,activeSearchItemId:void 0}),r(()=>{o.currentGroup!==o.groups[o.currentGroupIndex]&&(o.currentGroup=o.groups[o.currentGroupIndex])});const a=k=>{e.getElementById(k).focus()},c=k=>e.getElementById(`emo-${k.id}`),u=(k,A)=>{n.rootElement.dispatchEvent(new CustomEvent(k,{detail:A,bubbles:!0,composed:!0}))},p=(k,A)=>k.id===A.id,m=(k,A)=>{const{category:M,emojis:P}=k,{category:K,emojis:F}=A;return M!==K?!1:Js(P,F,p)},v=k=>{Js(o.currentEmojis,k,p)||(o.currentEmojis=k)},w=k=>{o.searchMode!==k&&(o.searchMode=k)},x=k=>{Js(o.currentEmojisWithCategories,k,m)||(o.currentEmojisWithCategories=k)},_=(k,A)=>A&&k.skins&&k.skins[A]||k.unicode,L={labelWithSkin:(k,A)=>Qg([k.name||_(k,A),k.annotation,...k.shortcodes||ei].filter(Boolean)).join(", "),titleForEmoji:k=>k.annotation||(k.shortcodes||ei).join(", "),unicodeWithSkin:_},I={onClickSkinToneButton:W,onEmojiClick:un,onNavClick:ln,onNavKeydown:ws,onSearchKeydown:bs,onSkinToneOptionsClick:dn,onSkinToneOptionsFocusOut:Me,onSkinToneOptionsKeydown:We,onSkinToneOptionsKeyup:Tt,onSearchInput:pn},B={calculateEmojiGridStyle:gs,updateOnIntersection:ms};let ue=!0;r(()=>{um(e,o,L,I,B,n,i,l,ue),ue=!1}),o.emojiVersion||Ys().then(k=>{k||(o.message=o.i18n.emojiUnsupportedMessage)}),r(()=>{async function k(){let A=!1;const M=setTimeout(()=>{A=!0,o.message=o.i18n.loadingMessage},Pg);try{await o.database.ready(),o.databaseLoaded=!0}catch(P){console.error(P),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(M),A&&(A=!1,o.message="")}}o.database&&k()}),r(()=>{o.pickerStyle=`
1701
+ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),s}function Vg(e){return rc(e,t=>t)}function Qg(e){e&&(e.scrollTop=0)}function Vt(e,t,n){let s=e.get(t);return s||(s=n(),e.set(t,s)),s}function na(e){return""+e}function Yg(e){const t=document.createElement("template");return t.innerHTML=e,t}const Xg=new WeakMap,Zg=new WeakMap,Jg=Symbol("un-keyed"),em="replaceChildren"in Element.prototype;function tm(e,t){em?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function nm(e,t){let n=e.firstChild,s=0;for(;n;){if(t[s]!==n)return!0;n=n.nextSibling,s++}return s!==t.length}function sm(e,t){const{targetNode:n}=t;let{targetParentNode:s}=t,i=!1;s?i=nm(s,e):(i=!0,t.targetNode=void 0,t.targetParentNode=s=n.parentNode),i&&tm(s,e)}function im(e,t){for(const n of t){const{targetNode:s,currentExpression:i,binding:{expressionIndex:o,attributeName:r,attributeValuePre:l,attributeValuePost:a}}=n,c=e[o];if(i!==c)if(n.currentExpression=c,r)if(c===null)s.removeAttribute(r);else{const u=l+na(c)+a;s.setAttribute(r,u)}else{let u;Array.isArray(c)?sm(c,n):c instanceof Element?(u=c,s.replaceWith(u)):s.nodeValue=na(c),u&&(n.targetNode=u)}}}function om(e){let t="",n=!1,s=!1,i=-1;const o=new Map,r=[];let l=0;for(let c=0,u=e.length;c<u;c++){const p=e[c];if(t+=p.slice(l),c===u-1)break;for(let C=0;C<p.length;C++)switch(p.charAt(C)){case"<":{p.charAt(C+1)==="/"?r.pop():(n=!0,r.push(++i));break}case">":{n=!1,s=!1;break}case"=":{s=!0;break}}const m=r[r.length-1],v=Vt(o,m,()=>[]);let w,x,_;if(s){const C=/(\S+)="?([^"=]*)$/.exec(p);w=C[1],x=C[2];const L=/^([^">]*)("?)/.exec(e[c+1]);_=L[1],t=t.slice(0,-1*C[0].length),l=L[0].length}else l=0;const j={attributeName:w,attributeValuePre:x,attributeValuePost:_,expressionIndex:c};v.push(j),!n&&!s&&(t+=" ")}return{template:Yg(t),elementsToBindings:o}}function sa(e,t,n){for(let s=0;s<e.length;s++){const i=e[s],o=i.attributeName?t:t.firstChild,r={binding:i,targetNode:o,targetParentNode:void 0,currentExpression:void 0};n.push(r)}}function rm(e,t){const n=[];let s;if(t.size===1&&(s=t.get(0)))sa(s,e,n);else{const i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,r=-1;do{const l=t.get(++r);l&&sa(l,o,n)}while(o=i.nextNode())}return n}function am(e){const{template:t,elementsToBindings:n}=Vt(Xg,e,()=>om(e)),s=t.cloneNode(!0).content.firstElementChild,i=rm(s,n);return function(r){return im(r,i),s}}function lm(e){const t=Vt(Zg,e,()=>new Map);let n=Jg;function s(o,...r){const l=Vt(t,o,()=>new Map);return Vt(l,n,()=>am(o))(r)}function i(o,r,l){return o.map((a,c)=>{const u=n;n=l(a);try{return r(a,c)}finally{n=u}})}return{map:i,html:s}}function cm(e,t,n,s,i,o,r,l,a){const{labelWithSkin:c,titleForEmoji:u,unicodeWithSkin:p}=n,{html:m,map:v}=lm(t);function w(C,L,I){return v(C,(B,ue)=>m`<button role="${L?"option":"menuitem"}" aria-selected="${L?ue===t.activeSearchItem:null}" aria-label="${c(B,t.currentSkinTone)}" title="${u(B)}" class="${"emoji"+(L&&ue===t.activeSearchItem?" active":"")+(B.unicode?"":" custom-emoji")}" id="${`${I}-${B.id}`}" style="${B.unicode?null:`--custom-emoji-background: url(${JSON.stringify(B.url)})`}">${B.unicode?p(B,t.currentSkinTone):""}</button>`,B=>`${I}-${B.id}`)}const _=m`<section data-ref="rootElement" class="picker" aria-label="${t.i18n.regionLabel}" style="${t.pickerStyle||""}"><div class="pad-top"></div><div class="search-row"><div class="search-wrapper"><input id="search" class="search" type="search" role="combobox" enterkeyhint="search" placeholder="${t.i18n.searchLabel}" autocapitalize="none" autocomplete="off" spellcheck="true" aria-expanded="${!!(t.searchMode&&t.currentEmojis.length)}" aria-controls="search-results" aria-describedby="search-description" aria-autocomplete="list" aria-activedescendant="${t.activeSearchItemId?`emo-${t.activeSearchItemId}`:null}" data-ref="searchElement" data-on-input="onSearchInput" data-on-keydown="onSearchKeydown"><label class="sr-only" for="search">${t.i18n.searchLabel}</label> <span id="search-description" class="sr-only">${t.i18n.searchDescription}</span></div><div class="skintone-button-wrapper ${t.skinTonePickerExpandedAfterAnimation?"expanded":""}"><button id="skintone-button" class="emoji ${t.skinTonePickerExpanded?"hide-focus":""}" aria-label="${t.skinToneButtonLabel}" title="${t.skinToneButtonLabel}" aria-describedby="skintone-description" aria-haspopup="listbox" aria-expanded="${t.skinTonePickerExpanded}" aria-controls="skintone-list" data-on-click="onClickSkinToneButton">${t.skinToneButtonText||""}</button></div><span id="skintone-description" class="sr-only">${t.i18n.skinToneDescription}</span><div data-ref="skinToneDropdown" id="skintone-list" class="skintone-list hide-focus ${t.skinTonePickerExpanded?"":"hidden no-animate"}" style="transform:translateY(${t.skinTonePickerExpanded?0:"calc(-1 * var(--num-skintones) * var(--total-emoji-size))"})" role="listbox" aria-label="${t.i18n.skinTonesLabel}" aria-activedescendant="skintone-${t.activeSkinTone}" aria-hidden="${!t.skinTonePickerExpanded}" tabIndex="-1" data-on-focusout="onSkinToneOptionsFocusOut" data-on-click="onSkinToneOptionsClick" data-on-keydown="onSkinToneOptionsKeydown" data-on-keyup="onSkinToneOptionsKeyup">${v(t.skinTones,(C,L)=>m`<div id="skintone-${L}" class="emoji ${L===t.activeSkinTone?"active":""}" aria-selected="${L===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[L]}" aria-label="${t.i18n.skinTones[L]}">${C}</div>`,C=>C)}</div></div><div class="nav" role="tablist" style="grid-template-columns:repeat(${t.groups.length},1fr)" aria-label="${t.i18n.categoriesLabel}" data-on-keydown="onNavKeydown" data-on-click="onNavClick">${v(t.groups,C=>m`<button role="tab" class="nav-button" aria-controls="tab-${C.id}" aria-label="${t.i18n.categories[C.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===C.id}" title="${t.i18n.categories[C.name]}" data-group-id="${C.id}"><div class="nav-emoji emoji">${C.emoji}</div></button>`,C=>C.id)}</div><div class="indicator-wrapper"><div class="indicator" style="transform:translateX(${(t.isRtl?-1:1)*t.currentGroupIndex*100}%)"></div></div><div class="message ${t.message?"":"gone"}" role="alert" aria-live="polite">${t.message||""}</div><div data-ref="tabpanelElement" class="tabpanel ${!t.databaseLoaded||t.message?"gone":""}" role="${t.searchMode?"region":"tabpanel"}" aria-label="${t.searchMode?t.i18n.searchResultsLabel:t.i18n.categories[t.currentGroup.name]}" id="${t.searchMode?null:`tab-${t.currentGroup.id}`}" tabIndex="0" data-on-click="onEmojiClick"><div data-action="calculateEmojiGridStyle">${v(t.currentEmojisWithCategories,(C,L)=>m`<div><div id="menu-label-${L}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:C.category?C.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${L!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(C.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${L}" id="${t.searchMode?"search-results":null}">${w(C.emojis,t.searchMode,"emo")}</div></div>`,C=>C.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${w(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,j=(C,L)=>{for(const I of e.querySelectorAll(`[${C}]`))L(I,I.getAttribute(C))};if(a){e.appendChild(_);for(const C of["click","focusout","input","keydown","keyup"])j(`data-on-${C}`,(L,I)=>{L.addEventListener(C,s[I])});j("data-ref",(C,L)=>{o[L]=C}),r.addEventListener("abort",()=>{e.removeChild(_)})}j("data-action",(C,L)=>{let I=l.get(L);I||l.set(L,I=new WeakSet),I.has(C)||(I.add(C),i[L](C))})}const Jn=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function um(e){let t=!1,n;const s=new Map,i=new Set;let o;const r=()=>{if(t)return;const c=[...i];i.clear();try{for(const u of c)u()}finally{o=!1,i.size&&(o=!0,Jn(r))}},l=new Proxy({},{get(c,u){if(n){let p=s.get(u);p||(p=new Set,s.set(u,p)),p.add(n)}return c[u]},set(c,u,p){if(c[u]!==p){c[u]=p;const m=s.get(u);if(m){for(const v of m)i.add(v);o||(o=!0,Jn(r))}}return!0}}),a=c=>{const u=()=>{const p=n;n=u;try{return c()}finally{n=p}};return u()};return e.addEventListener("abort",()=>{t=!0}),{state:l,createEffect:a}}function Js(e,t,n){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(!n(e[s],t[s]))return!1;return!0}const ia=new WeakMap;function dm(e,t,n){{const s=e.closest(".tabpanel");let i=ia.get(s);i||(i=new IntersectionObserver(n,{root:s,rootMargin:"50% 0px 50% 0px",threshold:0}),ia.set(s,i),t.addEventListener("abort",()=>{i.disconnect()})),i.observe(e)}}const ei=[],{assign:Mn}=Object;function pm(e,t){const n={},s=new AbortController,i=s.signal,{state:o,createEffect:r}=um(i),l=new Map;Mn(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),Mn(o,t),Mn(o,{initialLoad:!0,currentEmojis:[],currentEmojisWithCategories:[],rawSearchText:"",searchText:"",searchMode:!1,activeSearchItem:-1,message:void 0,skinTonePickerExpanded:!1,skinTonePickerExpandedAfterAnimation:!1,currentSkinTone:0,activeSkinTone:0,skinToneButtonText:void 0,pickerStyle:void 0,skinToneButtonLabel:"",skinTones:[],currentFavorites:[],defaultFavoriteEmojis:void 0,numColumns:Lg,isRtl:!1,currentGroupIndex:0,groups:Vs,databaseLoaded:!1,activeSearchItemId:void 0}),r(()=>{o.currentGroup!==o.groups[o.currentGroupIndex]&&(o.currentGroup=o.groups[o.currentGroupIndex])});const a=k=>{e.getElementById(k).focus()},c=k=>e.getElementById(`emo-${k.id}`),u=(k,A)=>{n.rootElement.dispatchEvent(new CustomEvent(k,{detail:A,bubbles:!0,composed:!0}))},p=(k,A)=>k.id===A.id,m=(k,A)=>{const{category:M,emojis:P}=k,{category:K,emojis:F}=A;return M!==K?!1:Js(P,F,p)},v=k=>{Js(o.currentEmojis,k,p)||(o.currentEmojis=k)},w=k=>{o.searchMode!==k&&(o.searchMode=k)},x=k=>{Js(o.currentEmojisWithCategories,k,m)||(o.currentEmojisWithCategories=k)},_=(k,A)=>A&&k.skins&&k.skins[A]||k.unicode,L={labelWithSkin:(k,A)=>Vg([k.name||_(k,A),k.annotation,...k.shortcodes||ei].filter(Boolean)).join(", "),titleForEmoji:k=>k.annotation||(k.shortcodes||ei).join(", "),unicodeWithSkin:_},I={onClickSkinToneButton:W,onEmojiClick:un,onNavClick:ln,onNavKeydown:ws,onSearchKeydown:bs,onSkinToneOptionsClick:dn,onSkinToneOptionsFocusOut:Me,onSkinToneOptionsKeydown:We,onSkinToneOptionsKeyup:Tt,onSearchInput:pn},B={calculateEmojiGridStyle:gs,updateOnIntersection:ms};let ue=!0;r(()=>{cm(e,o,L,I,B,n,i,l,ue),ue=!1}),o.emojiVersion||Ys().then(k=>{k||(o.message=o.i18n.emojiUnsupportedMessage)}),r(()=>{async function k(){let A=!1;const M=setTimeout(()=>{A=!0,o.message=o.i18n.loadingMessage},Mg);try{await o.database.ready(),o.databaseLoaded=!0}catch(P){console.error(P),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(M),A&&(A=!1,o.message="")}}o.database&&k()}),r(()=>{o.pickerStyle=`
1688
1702
  --num-groups: ${o.groups.length};
1689
1703
  --indicator-opacity: ${o.searchMode?0:1};
1690
- --num-skintones: ${Xr};`}),r(()=>{o.customEmoji&&o.database&&it()}),r(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==Ci&&(o.groups=Ci):o.groups!==Vs&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=Vs)}),r(()=>{async function k(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}k()}),r(()=>{o.skinTones=Array(Xr).fill().map((k,A)=>jg(o.skinToneEmoji,A))}),r(()=>{o.skinToneButtonText=o.skinTones[o.currentSkinTone]}),r(()=>{o.skinToneButtonLabel=o.i18n.skinToneLabel.replace("{skinTone}",o.i18n.skinTones[o.currentSkinTone])}),r(()=>{async function k(){const{database:A}=o,M=(await Promise.all(Ig.map(P=>A.getEmojiByUnicodeOrName(P)))).filter(Boolean);o.defaultFavoriteEmojis=M}o.databaseLoaded&&k()});function it(){const{customEmoji:k,database:A}=o,M=k||ei;A.customEmoji!==M&&(A.customEmoji=M)}r(()=>{async function k(){it();const{database:A,defaultFavoriteEmojis:M,numColumns:P}=o,K=await A.getTopFavoriteEmoji(P),F=await Ue(rc([...K,...M],te=>te.unicode||te.name).slice(0,P));o.currentFavorites=F}o.databaseLoaded&&o.defaultFavoriteEmojis&&k()});function gs(k){Gg(k,i,()=>{{const A=getComputedStyle(n.rootElement),M=parseInt(A.getPropertyValue("--num-columns"),10),P=A.getPropertyValue("direction")==="rtl";o.numColumns=M,o.isRtl=P}})}function ms(k){pm(k,i,A=>{for(const{target:M,isIntersecting:P}of A)M.classList.toggle("onscreen",P)})}r(()=>{async function k(){const{searchText:A,currentGroup:M,databaseLoaded:P,customEmoji:K}=o;if(!P)o.currentEmojis=[],o.searchMode=!1;else if(A.length>=_g){const F=await vs(A);o.searchText===A&&(v(F),w(!0))}else{const{id:F}=M;if(F!==-1||K&&K.length){const te=await ys(F);o.currentGroup.id===F&&(v(te),w(!1))}}}k()});const an=()=>{Dn(()=>Yg(n.tabpanelElement))};r(()=>{const{currentEmojis:k,emojiVersion:A}=o,M=k.filter(P=>P.unicode).filter(P=>Zr(P)&&!_i.has(P.unicode));if(!A&&M.length)v(k),Dn(()=>Y(M));else{const P=A?k:k.filter(Et);v(P),an()}});function Y(k){Vg(k,n.baselineEmoji,c)?an():o.currentEmojis=[...o.currentEmojis]}function Et(k){return!k.unicode||!Zr(k)||_i.get(k.unicode)}async function ot(k){const A=o.emojiVersion||await Ys();return k.filter(({version:M})=>!M||M<=A)}async function Ue(k){return Hg(k,o.emojiVersion||await Ys())}async function ys(k){const A=k===-1?o.customEmoji:await o.database.getEmojiByGroup(k);return Ue(await ot(A))}async function vs(k){return Ue(await ot(await o.database.getEmojiBySearchQuery(k)))}r(()=>{}),r(()=>{function k(){const{searchMode:M,currentEmojis:P}=o;if(M)return[{category:"",emojis:P}];const K=new Map;for(const F of P){const te=F.category||"";let Pe=K.get(te);Pe||(Pe=[],K.set(te,Pe)),Pe.push(F)}return[...K.entries()].map(([F,te])=>({category:F,emojis:te})).sort((F,te)=>o.customCategorySorting(F.category,te.category))}const A=k();x(A)}),r(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),r(()=>{const{rawSearchText:k}=o;ic(()=>{o.searchText=(k||"").trim(),o.activeSearchItem=-1})});function bs(k){if(!o.searchMode||!o.currentEmojis.length)return;const A=M=>{ve(k),o.activeSearchItem=Xs(M,o.activeSearchItem,o.currentEmojis)};switch(k.key){case"ArrowDown":return A(!1);case"ArrowUp":return A(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return ve(k),H(o.currentEmojis[o.activeSearchItem].id)}}function ln(k){const{target:A}=k,M=A.closest(".nav-button");if(!M)return;const P=parseInt(M.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(K=>K.id===P)}function ws(k){const{target:A,key:M}=k,P=K=>{K&&(ve(k),K.focus())};switch(M){case"ArrowLeft":return P(A.previousElementSibling);case"ArrowRight":return P(A.nextElementSibling);case"Home":return P(A.parentElement.firstElementChild);case"End":return P(A.parentElement.lastElementChild)}}async function cn(k){const A=await o.database.getEmojiByUnicodeOrName(k),M=[...o.currentEmojis,...o.currentFavorites].find(K=>K.id===k),P=M.unicode&&_(M,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(k),{emoji:A,skinTone:o.currentSkinTone,...P&&{unicode:P},...M.name&&{name:M.name}}}async function H(k){const A=cn(k);u("emoji-click-sync",A),u("emoji-click",await A)}function un(k){const{target:A}=k;if(!A.classList.contains("emoji"))return;ve(k);const M=A.id.substring(4);H(M)}function q(k){o.currentSkinTone=k,o.skinTonePickerExpanded=!1,a("skintone-button"),u("skin-tone-change",{skinTone:k}),o.database.setPreferredSkinTone(k)}function dn(k){const{target:{id:A}}=k,M=A&&A.match(/^skintone-(\d)/);if(!M)return;ve(k);const P=parseInt(M[1],10);q(P)}function W(k){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(ve(k),Dn(()=>a("skintone-list")))}r(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function We(k){if(!o.skinTonePickerExpanded)return;const A=async M=>{ve(k),o.activeSkinTone=M};switch(k.key){case"ArrowUp":return A(Xs(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return A(Xs(!1,o.activeSkinTone,o.skinTones));case"Home":return A(0);case"End":return A(o.skinTones.length-1);case"Enter":return ve(k),q(o.activeSkinTone);case"Escape":return ve(k),o.skinTonePickerExpanded=!1,a("skintone-button")}}function Tt(k){if(o.skinTonePickerExpanded&&k.key===" ")return ve(k),q(o.activeSkinTone)}async function Me(k){const{relatedTarget:A}=k;(!A||A.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function pn(k){o.rawSearchText=k.target.value}return{$set(k){Mn(o,k)},$destroy(){s.abort()}}}const fm="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",gm="en";var mm={categoriesLabel:"Categories",emojiUnsupportedMessage:"Your browser does not support color emoji.",favoritesLabel:"Favorites",loadingMessage:"Loading…",networkErrorMessage:"Could not load emoji.",regionLabel:"Emoji picker",searchDescription:"When search results are available, press up or down to select and enter to choose.",searchLabel:"Search",searchResultsLabel:"Search results",skinToneDescription:"When expanded, press up or down to select and enter to choose.",skinToneLabel:"Choose a skin tone (currently {skinTone})",skinTonesLabel:"Skin tones",skinTones:["Default","Light","Medium-Light","Medium","Medium-Dark","Dark"],categories:{custom:"Custom","smileys-emotion":"Smileys and emoticons","people-body":"People and body","animals-nature":"Animals and nature","food-drink":"Food and drink","travel-places":"Travel and places",activities:"Activities",objects:"Objects",symbols:"Symbols",flags:"Flags"}},ym=':host{--emoji-size:1.375rem;--emoji-padding:0.5rem;--category-emoji-size:var(--emoji-size);--category-emoji-padding:var(--emoji-padding);--indicator-height:3px;--input-border-radius:0.5rem;--input-border-size:1px;--input-font-size:1rem;--input-line-height:1.5;--input-padding:0.25rem;--num-columns:8;--outline-size:2px;--border-size:1px;--border-radius:0;--skintone-border-radius:1rem;--category-font-size:1rem;display:flex;width:min-content;height:400px}:host,:host(.light){color-scheme:light;--background:#fff;--border-color:#e0e0e0;--indicator-color:#385ac1;--input-border-color:#999;--input-font-color:#111;--input-placeholder-color:#999;--outline-color:#999;--category-font-color:#111;--button-active-background:#e6e6e6;--button-hover-background:#d9d9d9}:host(.dark){color-scheme:dark;--background:#222;--border-color:#444;--indicator-color:#5373ec;--input-border-color:#ccc;--input-font-color:#efefef;--input-placeholder-color:#ccc;--outline-color:#fff;--category-font-color:#efefef;--button-active-background:#555555;--button-hover-background:#484848}@media (prefers-color-scheme:dark){:host{color-scheme:dark;--background:#222;--border-color:#444;--indicator-color:#5373ec;--input-border-color:#ccc;--input-font-color:#efefef;--input-placeholder-color:#ccc;--outline-color:#fff;--category-font-color:#efefef;--button-active-background:#555555;--button-hover-background:#484848}}:host([hidden]){display:none}button{margin:0;padding:0;border:0;background:0 0;box-shadow:none;-webkit-tap-highlight-color:transparent}button::-moz-focus-inner{border:0}input{padding:0;margin:0;line-height:1.15;font-family:inherit}input[type=search]{-webkit-appearance:none}:focus{outline:var(--outline-color) solid var(--outline-size);outline-offset:calc(-1*var(--outline-size))}:host([data-js-focus-visible]) :focus:not([data-focus-visible-added]){outline:0}:focus:not(:focus-visible){outline:0}.hide-focus{outline:0}*{box-sizing:border-box}.picker{contain:content;display:flex;flex-direction:column;background:var(--background);border:var(--border-size) solid var(--border-color);border-radius:var(--border-radius);width:100%;height:100%;overflow:hidden;--total-emoji-size:calc(var(--emoji-size) + (2 * var(--emoji-padding)));--total-category-emoji-size:calc(var(--category-emoji-size) + (2 * var(--category-emoji-padding)))}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.hidden{opacity:0;pointer-events:none}.abs-pos{position:absolute;left:0;top:0}.gone{display:none!important}.skintone-button-wrapper,.skintone-list{background:var(--background);z-index:3}.skintone-button-wrapper.expanded{z-index:1}.skintone-list{position:absolute;inset-inline-end:0;top:0;z-index:2;overflow:visible;border-bottom:var(--border-size) solid var(--border-color);border-radius:0 0 var(--skintone-border-radius) var(--skintone-border-radius);will-change:transform;transition:transform .2s ease-in-out;transform-origin:center 0}@media (prefers-reduced-motion:reduce){.skintone-list{transition-duration:.001s}}@supports not (inset-inline-end:0){.skintone-list{right:0}}.skintone-list.no-animate{transition:none}.tabpanel{overflow-y:auto;scrollbar-gutter:stable;-webkit-overflow-scrolling:touch;will-change:transform;min-height:0;flex:1;contain:content}.emoji-menu{display:grid;grid-template-columns:repeat(var(--num-columns),var(--total-emoji-size));justify-content:space-around;align-items:flex-start;width:100%}.emoji-menu.visibility-auto{content-visibility:auto;contain-intrinsic-size:calc(var(--num-columns)*var(--total-emoji-size)) calc(var(--num-rows)*var(--total-emoji-size))}.category{padding:var(--emoji-padding);font-size:var(--category-font-size);color:var(--category-font-color)}.emoji,button.emoji{font-size:var(--emoji-size);display:flex;align-items:center;justify-content:center;border-radius:100%;height:var(--total-emoji-size);width:var(--total-emoji-size);line-height:1;overflow:hidden;font-family:var(--emoji-font-family);cursor:pointer}@media (hover:hover) and (pointer:fine){.emoji:hover,button.emoji:hover{background:var(--button-hover-background)}}.emoji.active,.emoji:active,button.emoji.active,button.emoji:active{background:var(--button-active-background)}.onscreen .custom-emoji::after{content:"";width:var(--emoji-size);height:var(--emoji-size);background-repeat:no-repeat;background-position:center center;background-size:contain;background-image:var(--custom-emoji-background)}.nav,.nav-button{align-items:center}.nav{display:grid;justify-content:space-between;contain:content}.nav-button{display:flex;justify-content:center}.nav-emoji{font-size:var(--category-emoji-size);width:var(--total-category-emoji-size);height:var(--total-category-emoji-size)}.indicator-wrapper{display:flex;border-bottom:1px solid var(--border-color)}.indicator{width:calc(100%/var(--num-groups));height:var(--indicator-height);opacity:var(--indicator-opacity);background-color:var(--indicator-color);will-change:transform,opacity;transition:opacity .1s linear,transform .25s ease-in-out}@media (prefers-reduced-motion:reduce){.indicator{will-change:opacity;transition:opacity .1s linear}}.pad-top,input.search{background:var(--background);width:100%}.pad-top{height:var(--emoji-padding);z-index:3}.search-row{display:flex;align-items:center;position:relative;padding-inline-start:var(--emoji-padding);padding-bottom:var(--emoji-padding)}.search-wrapper{flex:1;min-width:0}input.search{padding:var(--input-padding);border-radius:var(--input-border-radius);border:var(--input-border-size) solid var(--input-border-color);color:var(--input-font-color);font-size:var(--input-font-size);line-height:var(--input-line-height)}input.search::placeholder{color:var(--input-placeholder-color)}.favorites{overflow-y:auto;scrollbar-gutter:stable;display:flex;flex-direction:row;border-top:var(--border-size) solid var(--border-color);contain:content}.message{padding:var(--emoji-padding)}';const ac=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],vm=`:host{--emoji-font-family:${oc}}`;class xo extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=ym+vm,this.shadowRoot.appendChild(n),this._ctx={locale:gm,dataSource:fm,skinToneEmoji:Lg,customCategorySorting:Ng,customEmoji:null,i18n:mm,emojiVersion:null,...t};for(const s of ac)s!=="database"&&Object.prototype.hasOwnProperty.call(this,s)&&(this._ctx[s]=this[s],delete this[s]);this._dbFlush()}connectedCallback(){ia(this),this._cmp||(this._cmp=hm(this.shadowRoot,this._ctx))}disconnectedCallback(){ia(this),Jn(()=>{if(!this.isConnected&&this._cmp){this._cmp.$destroy(),this._cmp=void 0;const{database:t}=this._ctx;t.close().catch(n=>console.error(n))}})}static get observedAttributes(){return["locale","data-source","skin-tone-emoji","emoji-version"]}attributeChangedCallback(t,n,s){this._set(t.replace(/-([a-z])/g,(i,o)=>o.toUpperCase()),t==="emoji-version"?parseFloat(s):s)}_set(t,n){this._ctx[t]=n,this._cmp&&this._cmp.$set({[t]:n}),["locale","dataSource"].includes(t)&&this._dbFlush()}_dbCreate(){const{locale:t,dataSource:n,database:s}=this._ctx;(!s||s.locale!==t||s.dataSource!==n)&&this._set("database",new Cg({locale:t,dataSource:n}))}_dbFlush(){Jn(()=>this._dbCreate())}}const lc={};for(const e of ac)lc[e]={get(){return e==="database"&&this._dbCreate(),this._ctx[e]},set(t){if(e==="database")throw new Error("database is read-only");this._set(e,t)}};Object.defineProperties(xo.prototype,lc);function ia(e){e instanceof xo||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",xo);function bm(e){e.style.height="0";const t=Math.max(e.scrollHeight,44);e.style.height=`${t}px`,e.style.overflowY=e.scrollHeight>e.offsetHeight?"auto":"hidden"}function oa(e){e.style.height="44px",e.style.overflowY="hidden"}const wm=5e3;function km(e){return e?e.active?d`
1704
+ --num-skintones: ${Zr};`}),r(()=>{o.customEmoji&&o.database&&it()}),r(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==Ci&&(o.groups=Ci):o.groups!==Vs&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=Vs)}),r(()=>{async function k(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}k()}),r(()=>{o.skinTones=Array(Zr).fill().map((k,A)=>zg(o.skinToneEmoji,A))}),r(()=>{o.skinToneButtonText=o.skinTones[o.currentSkinTone]}),r(()=>{o.skinToneButtonLabel=o.i18n.skinToneLabel.replace("{skinTone}",o.i18n.skinTones[o.currentSkinTone])}),r(()=>{async function k(){const{database:A}=o,M=(await Promise.all(Rg.map(P=>A.getEmojiByUnicodeOrName(P)))).filter(Boolean);o.defaultFavoriteEmojis=M}o.databaseLoaded&&k()});function it(){const{customEmoji:k,database:A}=o,M=k||ei;A.customEmoji!==M&&(A.customEmoji=M)}r(()=>{async function k(){it();const{database:A,defaultFavoriteEmojis:M,numColumns:P}=o,K=await A.getTopFavoriteEmoji(P),F=await Ue(rc([...K,...M],te=>te.unicode||te.name).slice(0,P));o.currentFavorites=F}o.databaseLoaded&&o.defaultFavoriteEmojis&&k()});function gs(k){qg(k,i,()=>{{const A=getComputedStyle(n.rootElement),M=parseInt(A.getPropertyValue("--num-columns"),10),P=A.getPropertyValue("direction")==="rtl";o.numColumns=M,o.isRtl=P}})}function ms(k){dm(k,i,A=>{for(const{target:M,isIntersecting:P}of A)M.classList.toggle("onscreen",P)})}r(()=>{async function k(){const{searchText:A,currentGroup:M,databaseLoaded:P,customEmoji:K}=o;if(!P)o.currentEmojis=[],o.searchMode=!1;else if(A.length>=Cg){const F=await vs(A);o.searchText===A&&(v(F),w(!0))}else{const{id:F}=M;if(F!==-1||K&&K.length){const te=await ys(F);o.currentGroup.id===F&&(v(te),w(!1))}}}k()});const an=()=>{Dn(()=>Qg(n.tabpanelElement))};r(()=>{const{currentEmojis:k,emojiVersion:A}=o,M=k.filter(P=>P.unicode).filter(P=>Jr(P)&&!_i.has(P.unicode));if(!A&&M.length)v(k),Dn(()=>Y(M));else{const P=A?k:k.filter(Et);v(P),an()}});function Y(k){Gg(k,n.baselineEmoji,c)?an():o.currentEmojis=[...o.currentEmojis]}function Et(k){return!k.unicode||!Jr(k)||_i.get(k.unicode)}async function ot(k){const A=o.emojiVersion||await Ys();return k.filter(({version:M})=>!M||M<=A)}async function Ue(k){return jg(k,o.emojiVersion||await Ys())}async function ys(k){const A=k===-1?o.customEmoji:await o.database.getEmojiByGroup(k);return Ue(await ot(A))}async function vs(k){return Ue(await ot(await o.database.getEmojiBySearchQuery(k)))}r(()=>{}),r(()=>{function k(){const{searchMode:M,currentEmojis:P}=o;if(M)return[{category:"",emojis:P}];const K=new Map;for(const F of P){const te=F.category||"";let Pe=K.get(te);Pe||(Pe=[],K.set(te,Pe)),Pe.push(F)}return[...K.entries()].map(([F,te])=>({category:F,emojis:te})).sort((F,te)=>o.customCategorySorting(F.category,te.category))}const A=k();x(A)}),r(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),r(()=>{const{rawSearchText:k}=o;ic(()=>{o.searchText=(k||"").trim(),o.activeSearchItem=-1})});function bs(k){if(!o.searchMode||!o.currentEmojis.length)return;const A=M=>{ve(k),o.activeSearchItem=Xs(M,o.activeSearchItem,o.currentEmojis)};switch(k.key){case"ArrowDown":return A(!1);case"ArrowUp":return A(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return ve(k),H(o.currentEmojis[o.activeSearchItem].id)}}function ln(k){const{target:A}=k,M=A.closest(".nav-button");if(!M)return;const P=parseInt(M.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(K=>K.id===P)}function ws(k){const{target:A,key:M}=k,P=K=>{K&&(ve(k),K.focus())};switch(M){case"ArrowLeft":return P(A.previousElementSibling);case"ArrowRight":return P(A.nextElementSibling);case"Home":return P(A.parentElement.firstElementChild);case"End":return P(A.parentElement.lastElementChild)}}async function cn(k){const A=await o.database.getEmojiByUnicodeOrName(k),M=[...o.currentEmojis,...o.currentFavorites].find(K=>K.id===k),P=M.unicode&&_(M,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(k),{emoji:A,skinTone:o.currentSkinTone,...P&&{unicode:P},...M.name&&{name:M.name}}}async function H(k){const A=cn(k);u("emoji-click-sync",A),u("emoji-click",await A)}function un(k){const{target:A}=k;if(!A.classList.contains("emoji"))return;ve(k);const M=A.id.substring(4);H(M)}function q(k){o.currentSkinTone=k,o.skinTonePickerExpanded=!1,a("skintone-button"),u("skin-tone-change",{skinTone:k}),o.database.setPreferredSkinTone(k)}function dn(k){const{target:{id:A}}=k,M=A&&A.match(/^skintone-(\d)/);if(!M)return;ve(k);const P=parseInt(M[1],10);q(P)}function W(k){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(ve(k),Dn(()=>a("skintone-list")))}r(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function We(k){if(!o.skinTonePickerExpanded)return;const A=async M=>{ve(k),o.activeSkinTone=M};switch(k.key){case"ArrowUp":return A(Xs(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return A(Xs(!1,o.activeSkinTone,o.skinTones));case"Home":return A(0);case"End":return A(o.skinTones.length-1);case"Enter":return ve(k),q(o.activeSkinTone);case"Escape":return ve(k),o.skinTonePickerExpanded=!1,a("skintone-button")}}function Tt(k){if(o.skinTonePickerExpanded&&k.key===" ")return ve(k),q(o.activeSkinTone)}async function Me(k){const{relatedTarget:A}=k;(!A||A.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function pn(k){o.rawSearchText=k.target.value}return{$set(k){Mn(o,k)},$destroy(){s.abort()}}}const hm="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",fm="en";var gm={categoriesLabel:"Categories",emojiUnsupportedMessage:"Your browser does not support color emoji.",favoritesLabel:"Favorites",loadingMessage:"Loading…",networkErrorMessage:"Could not load emoji.",regionLabel:"Emoji picker",searchDescription:"When search results are available, press up or down to select and enter to choose.",searchLabel:"Search",searchResultsLabel:"Search results",skinToneDescription:"When expanded, press up or down to select and enter to choose.",skinToneLabel:"Choose a skin tone (currently {skinTone})",skinTonesLabel:"Skin tones",skinTones:["Default","Light","Medium-Light","Medium","Medium-Dark","Dark"],categories:{custom:"Custom","smileys-emotion":"Smileys and emoticons","people-body":"People and body","animals-nature":"Animals and nature","food-drink":"Food and drink","travel-places":"Travel and places",activities:"Activities",objects:"Objects",symbols:"Symbols",flags:"Flags"}},mm=':host{--emoji-size:1.375rem;--emoji-padding:0.5rem;--category-emoji-size:var(--emoji-size);--category-emoji-padding:var(--emoji-padding);--indicator-height:3px;--input-border-radius:0.5rem;--input-border-size:1px;--input-font-size:1rem;--input-line-height:1.5;--input-padding:0.25rem;--num-columns:8;--outline-size:2px;--border-size:1px;--border-radius:0;--skintone-border-radius:1rem;--category-font-size:1rem;display:flex;width:min-content;height:400px}:host,:host(.light){color-scheme:light;--background:#fff;--border-color:#e0e0e0;--indicator-color:#385ac1;--input-border-color:#999;--input-font-color:#111;--input-placeholder-color:#999;--outline-color:#999;--category-font-color:#111;--button-active-background:#e6e6e6;--button-hover-background:#d9d9d9}:host(.dark){color-scheme:dark;--background:#222;--border-color:#444;--indicator-color:#5373ec;--input-border-color:#ccc;--input-font-color:#efefef;--input-placeholder-color:#ccc;--outline-color:#fff;--category-font-color:#efefef;--button-active-background:#555555;--button-hover-background:#484848}@media (prefers-color-scheme:dark){:host{color-scheme:dark;--background:#222;--border-color:#444;--indicator-color:#5373ec;--input-border-color:#ccc;--input-font-color:#efefef;--input-placeholder-color:#ccc;--outline-color:#fff;--category-font-color:#efefef;--button-active-background:#555555;--button-hover-background:#484848}}:host([hidden]){display:none}button{margin:0;padding:0;border:0;background:0 0;box-shadow:none;-webkit-tap-highlight-color:transparent}button::-moz-focus-inner{border:0}input{padding:0;margin:0;line-height:1.15;font-family:inherit}input[type=search]{-webkit-appearance:none}:focus{outline:var(--outline-color) solid var(--outline-size);outline-offset:calc(-1*var(--outline-size))}:host([data-js-focus-visible]) :focus:not([data-focus-visible-added]){outline:0}:focus:not(:focus-visible){outline:0}.hide-focus{outline:0}*{box-sizing:border-box}.picker{contain:content;display:flex;flex-direction:column;background:var(--background);border:var(--border-size) solid var(--border-color);border-radius:var(--border-radius);width:100%;height:100%;overflow:hidden;--total-emoji-size:calc(var(--emoji-size) + (2 * var(--emoji-padding)));--total-category-emoji-size:calc(var(--category-emoji-size) + (2 * var(--category-emoji-padding)))}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.hidden{opacity:0;pointer-events:none}.abs-pos{position:absolute;left:0;top:0}.gone{display:none!important}.skintone-button-wrapper,.skintone-list{background:var(--background);z-index:3}.skintone-button-wrapper.expanded{z-index:1}.skintone-list{position:absolute;inset-inline-end:0;top:0;z-index:2;overflow:visible;border-bottom:var(--border-size) solid var(--border-color);border-radius:0 0 var(--skintone-border-radius) var(--skintone-border-radius);will-change:transform;transition:transform .2s ease-in-out;transform-origin:center 0}@media (prefers-reduced-motion:reduce){.skintone-list{transition-duration:.001s}}@supports not (inset-inline-end:0){.skintone-list{right:0}}.skintone-list.no-animate{transition:none}.tabpanel{overflow-y:auto;scrollbar-gutter:stable;-webkit-overflow-scrolling:touch;will-change:transform;min-height:0;flex:1;contain:content}.emoji-menu{display:grid;grid-template-columns:repeat(var(--num-columns),var(--total-emoji-size));justify-content:space-around;align-items:flex-start;width:100%}.emoji-menu.visibility-auto{content-visibility:auto;contain-intrinsic-size:calc(var(--num-columns)*var(--total-emoji-size)) calc(var(--num-rows)*var(--total-emoji-size))}.category{padding:var(--emoji-padding);font-size:var(--category-font-size);color:var(--category-font-color)}.emoji,button.emoji{font-size:var(--emoji-size);display:flex;align-items:center;justify-content:center;border-radius:100%;height:var(--total-emoji-size);width:var(--total-emoji-size);line-height:1;overflow:hidden;font-family:var(--emoji-font-family);cursor:pointer}@media (hover:hover) and (pointer:fine){.emoji:hover,button.emoji:hover{background:var(--button-hover-background)}}.emoji.active,.emoji:active,button.emoji.active,button.emoji:active{background:var(--button-active-background)}.onscreen .custom-emoji::after{content:"";width:var(--emoji-size);height:var(--emoji-size);background-repeat:no-repeat;background-position:center center;background-size:contain;background-image:var(--custom-emoji-background)}.nav,.nav-button{align-items:center}.nav{display:grid;justify-content:space-between;contain:content}.nav-button{display:flex;justify-content:center}.nav-emoji{font-size:var(--category-emoji-size);width:var(--total-category-emoji-size);height:var(--total-category-emoji-size)}.indicator-wrapper{display:flex;border-bottom:1px solid var(--border-color)}.indicator{width:calc(100%/var(--num-groups));height:var(--indicator-height);opacity:var(--indicator-opacity);background-color:var(--indicator-color);will-change:transform,opacity;transition:opacity .1s linear,transform .25s ease-in-out}@media (prefers-reduced-motion:reduce){.indicator{will-change:opacity;transition:opacity .1s linear}}.pad-top,input.search{background:var(--background);width:100%}.pad-top{height:var(--emoji-padding);z-index:3}.search-row{display:flex;align-items:center;position:relative;padding-inline-start:var(--emoji-padding);padding-bottom:var(--emoji-padding)}.search-wrapper{flex:1;min-width:0}input.search{padding:var(--input-padding);border-radius:var(--input-border-radius);border:var(--input-border-size) solid var(--input-border-color);color:var(--input-font-color);font-size:var(--input-font-size);line-height:var(--input-line-height)}input.search::placeholder{color:var(--input-placeholder-color)}.favorites{overflow-y:auto;scrollbar-gutter:stable;display:flex;flex-direction:row;border-top:var(--border-size) solid var(--border-color);contain:content}.message{padding:var(--emoji-padding)}';const ac=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],ym=`:host{--emoji-font-family:${oc}}`;class xo extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=mm+ym,this.shadowRoot.appendChild(n),this._ctx={locale:fm,dataSource:hm,skinToneEmoji:Pg,customCategorySorting:Ig,customEmoji:null,i18n:gm,emojiVersion:null,...t};for(const s of ac)s!=="database"&&Object.prototype.hasOwnProperty.call(this,s)&&(this._ctx[s]=this[s],delete this[s]);this._dbFlush()}connectedCallback(){oa(this),this._cmp||(this._cmp=pm(this.shadowRoot,this._ctx))}disconnectedCallback(){oa(this),Jn(()=>{if(!this.isConnected&&this._cmp){this._cmp.$destroy(),this._cmp=void 0;const{database:t}=this._ctx;t.close().catch(n=>console.error(n))}})}static get observedAttributes(){return["locale","data-source","skin-tone-emoji","emoji-version"]}attributeChangedCallback(t,n,s){this._set(t.replace(/-([a-z])/g,(i,o)=>o.toUpperCase()),t==="emoji-version"?parseFloat(s):s)}_set(t,n){this._ctx[t]=n,this._cmp&&this._cmp.$set({[t]:n}),["locale","dataSource"].includes(t)&&this._dbFlush()}_dbCreate(){const{locale:t,dataSource:n,database:s}=this._ctx;(!s||s.locale!==t||s.dataSource!==n)&&this._set("database",new Tg({locale:t,dataSource:n}))}_dbFlush(){Jn(()=>this._dbCreate())}}const lc={};for(const e of ac)lc[e]={get(){return e==="database"&&this._dbCreate(),this._ctx[e]},set(t){if(e==="database")throw new Error("database is read-only");this._set(e,t)}};Object.defineProperties(xo.prototype,lc);function oa(e){e instanceof xo||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",xo);function vm(e){e.style.height="0";const t=Math.max(e.scrollHeight,44);e.style.height=`${t}px`,e.style.overflowY=e.scrollHeight>e.offsetHeight?"auto":"hidden"}function ra(e){e.style.height="44px",e.style.overflowY="hidden"}const bm=5e3;function wm(e){return e?e.active?d`
1691
1705
  <div class="callout info compaction-indicator compaction-indicator--active">
1692
1706
  ${N.loader} Compacting context...
1693
1707
  </div>
1694
- `:e.completedAt&&Date.now()-e.completedAt<wm?d`
1708
+ `:e.completedAt&&Date.now()-e.completedAt<bm?d`
1695
1709
  <div class="callout success compaction-indicator compaction-indicator--complete">
1696
1710
  ${N.check} Context compacted
1697
1711
  </div>
1698
- `:b:b}const Kt=5*1024*1024;function zt(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function ht(e,t){let n=e.closest(".chat")?.querySelector(".chat-attachment-error");if(!n){n=document.createElement("div"),n.className="callout danger chat-attachment-error",n.style.cssText="margin: 8px 4px; animation: fade-in 200ms ease-out;";const s=e.closest(".chat")?.querySelector(".chat-compose");s?.parentElement?.insertBefore(n,s)}n.textContent=t,setTimeout(()=>n?.remove(),4e3)}const Sm=/\.(md|txt|csv|json|xml|html|css|js|ts|py|sh|yaml|yml|toml|ini|cfg|log|sql)$/i;function Am(e){return e.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.name)}function xm(e){return e.type.startsWith("text/")||e.type==="application/json"||e.type==="application/xml"||Sm.test(e.name)}function $m(e){return e.type==="application/pdf"||/\.pdf$/i.test(e.name)}function Em(e){return e.type.startsWith("video/")||/\.(mp4|webm|mov|avi|mkv|m4v)$/i.test(e.name)}function Tm(e,t){e.preventDefault(),e.stopPropagation();const n=e.currentTarget;n.classList.remove("chat--dragover");const s=e.dataTransfer?.files;if(!(!s||s.length===0))for(let i=0;i<s.length;i++){const o=s[i];if(Am(o)){if(!t.onAttachmentsChange)continue;if(o.size>Kt){ht(n,`Image too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{const l=r.result,a={id:zt(),dataUrl:l,mimeType:o.type},c=t.attachments??[];t.onAttachmentsChange?.([...c,a])},r.readAsDataURL(o)}else if(xm(o)){if(!t.onAttachmentsChange)continue;if(o.size>Kt){ht(n,`File too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{const l=r.result,a={id:zt(),dataUrl:"",mimeType:o.type||"text/plain",fileName:o.name,textContent:l},c=t.attachments??[];t.onAttachmentsChange?.([...c,a])},r.readAsText(o)}else if($m(o)){if(!t.onAttachmentsChange)continue;if(o.size>Kt){ht(n,`PDF too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{const l=r.result,a={id:zt(),dataUrl:l,mimeType:"application/pdf",fileName:o.name},c=t.attachments??[];t.onAttachmentsChange?.([...c,a])},r.readAsDataURL(o)}else if(Em(o)){if(!t.onAttachmentsChange)continue;if(o.size>Kt){ht(n,`Video too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{const l=r.result,a={id:zt(),dataUrl:l,mimeType:o.type||"video/mp4",fileName:o.name},c=t.attachments??[];t.onAttachmentsChange?.([...c,a])},r.readAsDataURL(o)}else ht(n,`Unsupported file type: ${o.name}. Use the Files page to upload to workspace.`)}}function Cm(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),e.currentTarget.classList.add("chat--dragover")}function _m(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&t.classList.remove("chat--dragover")}function Mm(e,t){const n=e.clipboardData?.items;if(!n||!t.onAttachmentsChange)return;const s=[];for(let i=0;i<n.length;i++){const o=n[i];(o.type.startsWith("image/")||o.type.startsWith("video/"))&&s.push(o)}if(s.length!==0){e.preventDefault();for(const i of s){const o=i.getAsFile();if(!o)continue;const r=o.type.startsWith("video/")?"Video":"Image";if(o.size>Kt){const a=e.target?.closest?.(".chat")??document.querySelector(".chat");a&&ht(a,`${r} too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const l=new FileReader;l.onload=()=>{const a=l.result,c=o.type.startsWith("video/"),u={id:zt(),dataUrl:a,mimeType:o.type,fileName:c?o.name||"video.mp4":void 0},p=t.attachments??[];t.onAttachmentsChange?.([...p,u])},l.readAsDataURL(o)}}}function Pm(e){const t=e.currentTarget,s=t.closest(".chat-compose")?.querySelector(".emoji-picker-popup");if(!s)return;const i=s.classList.toggle("active");if(t.classList.toggle("active",i),i){const o=r=>{s.contains(r.target)||t.contains(r.target)||(s.classList.remove("active"),t.classList.remove("active"),document.removeEventListener("click",o,!0))};requestAnimationFrame(()=>document.addEventListener("click",o,!0))}}function Lm(e,t){const s=e.detail?.unicode;if(!s)return;const i=e.currentTarget.closest(".chat-compose"),o=i?.querySelector("textarea");if(!o)return;const r=o.selectionStart??t.draft.length,l=o.selectionEnd??r,a=t.draft.slice(0,r),c=t.draft.slice(l);t.onDraftChange(a+s+c);const u=i?.querySelector(".emoji-picker-popup"),p=i?.querySelector(".chat-compose__emoji");u?.classList.remove("active"),p?.classList.remove("active"),requestAnimationFrame(()=>{o.focus();const m=r+s.length;o.setSelectionRange(m,m)})}function Rm(e){const t=e.attachments??[];return t.length===0?b:d`
1712
+ `:b:b}const Kt=5*1024*1024;function zt(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function ht(e,t){let n=e.closest(".chat")?.querySelector(".chat-attachment-error");if(!n){n=document.createElement("div"),n.className="callout danger chat-attachment-error",n.style.cssText="margin: 8px 4px; animation: fade-in 200ms ease-out;";const s=e.closest(".chat")?.querySelector(".chat-compose");s?.parentElement?.insertBefore(n,s)}n.textContent=t,setTimeout(()=>n?.remove(),4e3)}const km=/\.(md|txt|csv|json|xml|html|css|js|ts|py|sh|yaml|yml|toml|ini|cfg|log|sql)$/i;function Sm(e){return e.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.name)}function Am(e){return e.type.startsWith("text/")||e.type==="application/json"||e.type==="application/xml"||km.test(e.name)}function xm(e){return e.type==="application/pdf"||/\.pdf$/i.test(e.name)}function $m(e){return e.type.startsWith("video/")||/\.(mp4|webm|mov|avi|mkv|m4v)$/i.test(e.name)}function Em(e,t){e.preventDefault(),e.stopPropagation();const n=e.currentTarget;n.classList.remove("chat--dragover");const s=e.dataTransfer?.files;if(!(!s||s.length===0))for(let i=0;i<s.length;i++){const o=s[i];if(Sm(o)){if(!t.onAttachmentsChange)continue;if(o.size>Kt){ht(n,`Image too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{const l=r.result,a={id:zt(),dataUrl:l,mimeType:o.type},c=t.attachments??[];t.onAttachmentsChange?.([...c,a])},r.readAsDataURL(o)}else if(Am(o)){if(!t.onAttachmentsChange)continue;if(o.size>Kt){ht(n,`File too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{const l=r.result,a={id:zt(),dataUrl:"",mimeType:o.type||"text/plain",fileName:o.name,textContent:l},c=t.attachments??[];t.onAttachmentsChange?.([...c,a])},r.readAsText(o)}else if(xm(o)){if(!t.onAttachmentsChange)continue;if(o.size>Kt){ht(n,`PDF too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{const l=r.result,a={id:zt(),dataUrl:l,mimeType:"application/pdf",fileName:o.name},c=t.attachments??[];t.onAttachmentsChange?.([...c,a])},r.readAsDataURL(o)}else if($m(o)){if(!t.onAttachmentsChange)continue;if(o.size>Kt){ht(n,`Video too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{const l=r.result,a={id:zt(),dataUrl:l,mimeType:o.type||"video/mp4",fileName:o.name},c=t.attachments??[];t.onAttachmentsChange?.([...c,a])},r.readAsDataURL(o)}else ht(n,`Unsupported file type: ${o.name}. Use the Files page to upload to workspace.`)}}function Tm(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),e.currentTarget.classList.add("chat--dragover")}function Cm(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&t.classList.remove("chat--dragover")}function _m(e,t){const n=e.clipboardData?.items;if(!n||!t.onAttachmentsChange)return;const s=[];for(let i=0;i<n.length;i++){const o=n[i];(o.type.startsWith("image/")||o.type.startsWith("video/"))&&s.push(o)}if(s.length!==0){e.preventDefault();for(const i of s){const o=i.getAsFile();if(!o)continue;const r=o.type.startsWith("video/")?"Video":"Image";if(o.size>Kt){const a=e.target?.closest?.(".chat")??document.querySelector(".chat");a&&ht(a,`${r} too large (${(o.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const l=new FileReader;l.onload=()=>{const a=l.result,c=o.type.startsWith("video/"),u={id:zt(),dataUrl:a,mimeType:o.type,fileName:c?o.name||"video.mp4":void 0},p=t.attachments??[];t.onAttachmentsChange?.([...p,u])},l.readAsDataURL(o)}}}function Mm(e){const t=e.currentTarget,s=t.closest(".chat-compose")?.querySelector(".emoji-picker-popup");if(!s)return;const i=s.classList.toggle("active");if(t.classList.toggle("active",i),i){const o=r=>{s.contains(r.target)||t.contains(r.target)||(s.classList.remove("active"),t.classList.remove("active"),document.removeEventListener("click",o,!0))};requestAnimationFrame(()=>document.addEventListener("click",o,!0))}}function Pm(e,t){const s=e.detail?.unicode;if(!s)return;const i=e.currentTarget.closest(".chat-compose"),o=i?.querySelector("textarea");if(!o)return;const r=o.selectionStart??t.draft.length,l=o.selectionEnd??r,a=t.draft.slice(0,r),c=t.draft.slice(l);t.onDraftChange(a+s+c);const u=i?.querySelector(".emoji-picker-popup"),p=i?.querySelector(".chat-compose__emoji");u?.classList.remove("active"),p?.classList.remove("active"),requestAnimationFrame(()=>{o.focus();const m=r+s.length;o.setSelectionRange(m,m)})}function Lm(e){const t=e.attachments??[];return t.length===0?b:d`
1699
1713
  <div class="chat-attachments">
1700
1714
  ${t.map(n=>n.fileName?d`
1701
1715
  <div class="chat-attachment chat-attachment--file">
@@ -1728,7 +1742,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
1728
1742
  </div>
1729
1743
  `)}
1730
1744
  </div>
1731
- `}function Im(e){const t=e.connected,n=e.sending||e.stream!==null,s=!!(e.canAbort&&e.onAbort),o=e.sessions?.sessions?.find(m=>m.key===e.sessionKey)?.reasoningLevel??"off",r=e.showThinking&&o!=="off";e.assistantName,e.assistantAvatar??e.assistantAvatarUrl;const l=(e.attachments?.length??0)>0,a=e.connected?l?"Add a message...":"Message...":"Connecting…",c=e.splitRatio??.6,u=!!(e.sidebarOpen&&e.onCloseSidebar),p=d`
1745
+ `}function Rm(e){const t=e.connected,n=e.sending||e.stream!==null,s=!!(e.canAbort&&e.onAbort),o=e.sessions?.sessions?.find(m=>m.key===e.sessionKey)?.reasoningLevel??"off",r=e.showThinking&&o!=="off";e.assistantName,e.assistantAvatar??e.assistantAvatarUrl;const l=(e.attachments?.length??0)>0,a=e.connected?l?"Add a message...":"Message...":"Connecting…",c=e.splitRatio??.6,u=!!(e.sidebarOpen&&e.onCloseSidebar),p=d`
1732
1746
  <div
1733
1747
  class="chat-thread"
1734
1748
  role="log"
@@ -1736,20 +1750,20 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
1736
1750
  @scroll=${e.onChatScroll}
1737
1751
  >
1738
1752
  ${e.loading?d`<div class="muted">Loading chat…</div>`:b}
1739
- ${dh(Wm(e),m=>m.key,m=>m.kind==="reading-indicator"?Nf():m.kind==="stream"?Of(m.text,m.startedAt,e.onOpenSidebar):m.kind==="group"?Df(m,{onOpenSidebar:e.onOpenSidebar,showReasoning:r,assistantName:e.assistantName}):b)}
1753
+ ${uh(Um(e),m=>m.key,m=>m.kind==="reading-indicator"?If():m.kind==="stream"?Nf(m.text,m.startedAt,e.onOpenSidebar):m.kind==="group"?Of(m,{onOpenSidebar:e.onOpenSidebar,showReasoning:r,assistantName:e.assistantName}):b)}
1740
1754
  </div>
1741
1755
  `;return d`
1742
1756
  <section
1743
1757
  class="card chat"
1744
- @drop=${m=>Tm(m,e)}
1745
- @dragover=${Cm}
1746
- @dragleave=${_m}
1758
+ @drop=${m=>Em(m,e)}
1759
+ @dragover=${Tm}
1760
+ @dragleave=${Cm}
1747
1761
  >
1748
1762
  ${e.disabledReason?d`<div class="callout">${e.disabledReason}</div>`:b}
1749
1763
 
1750
1764
  ${e.error?d`<div class="callout danger">${e.error}</div>`:b}
1751
1765
 
1752
- ${km(e.compactionStatus)}
1766
+ ${wm(e.compactionStatus)}
1753
1767
 
1754
1768
  ${e.focusMode?d`
1755
1769
  <button
@@ -1790,7 +1804,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
1790
1804
  @resize=${m=>e.onSplitRatioChange?.(m.detail.splitRatio)}
1791
1805
  ></resizable-divider>
1792
1806
  <div class="chat-sidebar">
1793
- ${Ff({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
1807
+ ${Bf({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
1794
1808
  ${e.sidebarContent}
1795
1809
  \`\`\``)}})}
1796
1810
  </div>
@@ -1798,12 +1812,12 @@ ${e.sidebarContent}
1798
1812
  </div>
1799
1813
 
1800
1814
  <div class="chat-compose">
1801
- ${Rm(e)}
1815
+ ${Lm(e)}
1802
1816
  <div class="chat-compose__row">
1803
1817
  <button
1804
1818
  class="chat-compose__emoji"
1805
1819
  type="button"
1806
- @click=${Pm}
1820
+ @click=${Mm}
1807
1821
  aria-label="Emoji"
1808
1822
  title="Emoji"
1809
1823
  >
@@ -1814,9 +1828,9 @@ ${e.sidebarContent}
1814
1828
  <textarea
1815
1829
  .value=${e.draft}
1816
1830
  ?disabled=${!e.connected}
1817
- @keydown=${m=>{m.key==="Enter"&&(m.isComposing||m.keyCode===229||m.shiftKey||e.connected&&(m.preventDefault(),t&&(e.onSend(),oa(m.target))))}}
1818
- @input=${m=>{const v=m.target;e.onDraftChange(v.value),bm(v)}}
1819
- @paste=${m=>Mm(m,e)}
1831
+ @keydown=${m=>{m.key==="Enter"&&(m.isComposing||m.keyCode===229||m.shiftKey||e.connected&&(m.preventDefault(),t&&(e.onSend(),ra(m.target))))}}
1832
+ @input=${m=>{const v=m.target;e.onDraftChange(v.value),vm(v)}}
1833
+ @paste=${m=>_m(m,e)}
1820
1834
  placeholder=${a}
1821
1835
  ></textarea>
1822
1836
  </label>
@@ -1833,7 +1847,7 @@ ${e.sidebarContent}
1833
1847
  <button
1834
1848
  class="btn btn--icon chat-compose__send primary"
1835
1849
  ?disabled=${!e.connected}
1836
- @click=${m=>{e.onSend();const v=m.target.closest(".chat-compose")?.querySelector("textarea");v&&oa(v)}}
1850
+ @click=${m=>{e.onSend();const v=m.target.closest(".chat-compose")?.querySelector("textarea");v&&ra(v)}}
1837
1851
  aria-label="${n?"Queue":"Send"}"
1838
1852
  title="${n?"Queue message":"Send (Enter)"}"
1839
1853
  >
@@ -1842,13 +1856,13 @@ ${e.sidebarContent}
1842
1856
  </div>
1843
1857
  <div class="emoji-picker-popup">
1844
1858
  <emoji-picker
1845
- @emoji-click=${m=>Lm(m,e)}
1859
+ @emoji-click=${m=>Pm(m,e)}
1846
1860
  ></emoji-picker>
1847
1861
  </div>
1848
- ${Fm(e)}
1862
+ ${Bm(e)}
1849
1863
  </div>
1850
1864
  </section>
1851
- `}const Nm=[{id:"claude-opus-4-6",shortName:"Opus",description:"Most capable"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet",description:"Fast & capable"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku",description:"Fastest"}];function Om(e){const t=new Set(e.filter(n=>n.provider==="anthropic").map(n=>n.id));return Nm.filter(n=>t.has(n.id)).map(n=>({key:`anthropic/${n.id}`,...n}))}const Dm=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function Bm(e){const t=e.currentTarget,n=t.closest(".chat-model-bar")?.querySelector(".chat-settings-menu");if(!n)return;const s=n.classList.contains("active");if(document.querySelectorAll(".chat-settings-menu.active").forEach(i=>i.classList.remove("active")),!s){n.classList.add("active");const i=o=>{!n.contains(o.target)&&o.target!==t&&!t.contains(o.target)&&(n.classList.remove("active"),document.removeEventListener("click",i))};requestAnimationFrame(()=>document.addEventListener("click",i))}}function Fm(e){if(!e.connected)return b;const t=e.modelCatalog??[],n=Om(t);if(n.length===0)return b;const s=e.modelProvider&&e.model?`${e.modelProvider}/${e.model}`:null,i=e.thinkingLevel??"off",o=e.verboseLevel==="on"||e.verboseLevel==="full",r=e.fillerEnabled===!0;return d`
1865
+ `}const Im=[{id:"claude-opus-4-6",shortName:"Opus",description:"Most capable"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet",description:"Fast & capable"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku",description:"Fastest"}];function Nm(e){const t=new Set(e.filter(n=>n.provider==="anthropic").map(n=>n.id));return Im.filter(n=>t.has(n.id)).map(n=>({key:`anthropic/${n.id}`,...n}))}const Om=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function Dm(e){const t=e.currentTarget,n=t.closest(".chat-model-bar")?.querySelector(".chat-settings-menu");if(!n)return;const s=n.classList.contains("active");if(document.querySelectorAll(".chat-settings-menu.active").forEach(i=>i.classList.remove("active")),!s){n.classList.add("active");const i=o=>{!n.contains(o.target)&&o.target!==t&&!t.contains(o.target)&&(n.classList.remove("active"),document.removeEventListener("click",i))};requestAnimationFrame(()=>document.addEventListener("click",i))}}function Bm(e){if(!e.connected)return b;const t=e.modelCatalog??[],n=Nm(t);if(n.length===0)return b;const s=e.modelProvider&&e.model?`${e.modelProvider}/${e.model}`:null,i=e.thinkingLevel??"off",o=e.verboseLevel==="on"||e.verboseLevel==="full",r=e.fillerEnabled===!0;return d`
1852
1866
  <div class="chat-model-bar">
1853
1867
  <div class="chat-model-bar__select">
1854
1868
  <select
@@ -1869,7 +1883,7 @@ ${e.sidebarContent}
1869
1883
  .value=${i}
1870
1884
  @change=${l=>{const a=l.target.value;e.onThinkingLevelChange&&e.onThinkingLevelChange(a)}}
1871
1885
  >
1872
- ${Dm.map(l=>d`
1886
+ ${Om.map(l=>d`
1873
1887
  <option value=${l.value} ?selected=${l.value===i}>
1874
1888
  Thinking: ${l.label}
1875
1889
  </option>
@@ -1879,7 +1893,7 @@ ${e.sidebarContent}
1879
1893
  <button
1880
1894
  class="chat-model-bar__settings-btn"
1881
1895
  type="button"
1882
- @click=${Bm}
1896
+ @click=${Dm}
1883
1897
  aria-label="Message settings"
1884
1898
  title="Message settings"
1885
1899
  >
@@ -1906,13 +1920,13 @@ ${e.sidebarContent}
1906
1920
  </label>
1907
1921
  </div>
1908
1922
  </div>
1909
- `}const ra=200;function Um(e){const t=[];let n=null;for(const s of e){if(s.kind!=="message"){n&&(t.push(n),n=null),t.push(s);continue}const i=La(s.message),o=Ra(i.role),r=i.timestamp||Date.now();!n||n.role!==o?(n&&t.push(n),n={kind:"group",key:`group:${o}:${s.key}`,role:o,messages:[{message:s.message,key:s.key}],timestamp:r,isStreaming:!1}):n.messages.push({message:s.message,key:s.key})}return n&&t.push(n),t}function Wm(e){const t=[],n=Array.isArray(e.messages)?e.messages:[],s=Array.isArray(e.toolMessages)?e.toolMessages:[],i=e.showThinking||e.verboseLevel==="on"||e.verboseLevel==="full",o=Math.max(0,n.length-ra);o>0&&t.push({kind:"message",key:"chat:history:notice",message:{role:"system",content:`Showing last ${ra} messages (${o} hidden).`,timestamp:Date.now()}});for(let r=o;r<n.length;r++){const l=n[r],a=La(l);!i&&a.role.toLowerCase()==="toolresult"||t.push({kind:"message",key:aa(l,r),message:l})}if(i)for(let r=0;r<s.length;r++)t.push({kind:"message",key:aa(s[r],r+n.length),message:s[r]});if(e.stream!==null){const r=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:r,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:r})}for(const r of e.queue){const l=r.attachments?.filter(c=>c.fileName).map(c=>c.fileName)??[],a=l.length>0?r.text?`${l.join(", ")}
1923
+ `}const aa=200;function Fm(e){const t=[];let n=null;for(const s of e){if(s.kind!=="message"){n&&(t.push(n),n=null),t.push(s);continue}const i=Ra(s.message),o=Ia(i.role),r=i.timestamp||Date.now();!n||n.role!==o?(n&&t.push(n),n={kind:"group",key:`group:${o}:${s.key}`,role:o,messages:[{message:s.message,key:s.key}],timestamp:r,isStreaming:!1}):n.messages.push({message:s.message,key:s.key})}return n&&t.push(n),t}function Um(e){const t=[],n=Array.isArray(e.messages)?e.messages:[],s=Array.isArray(e.toolMessages)?e.toolMessages:[],i=e.showThinking||e.verboseLevel==="on"||e.verboseLevel==="full",o=Math.max(0,n.length-aa);o>0&&t.push({kind:"message",key:"chat:history:notice",message:{role:"system",content:`Showing last ${aa} messages (${o} hidden).`,timestamp:Date.now()}});for(let r=o;r<n.length;r++){const l=n[r],a=Ra(l);!i&&a.role.toLowerCase()==="toolresult"||t.push({kind:"message",key:la(l,r),message:l})}if(i)for(let r=0;r<s.length;r++)t.push({kind:"message",key:la(s[r],r+n.length),message:s[r]});if(e.stream!==null){const r=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:r,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:r})}for(const r of e.queue){const l=r.attachments?.filter(c=>c.fileName).map(c=>c.fileName)??[],a=l.length>0?r.text?`${l.join(", ")}
1910
1924
 
1911
- ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,message:{role:"user",content:[{type:"text",text:a}],timestamp:r.createdAt}})}return Um(t)}function aa(e,t){const n=e,s=typeof n.toolCallId=="string"?n.toolCallId:"";if(s)return`tool:${s}`;const i=typeof n.id=="string"?n.id:"";if(i)return`msg:${i}`;const o=typeof n.messageId=="string"?n.messageId:"";if(o)return`msg:${o}`;const r=typeof n.timestamp=="number"?n.timestamp:null,l=typeof n.role=="string"?n.role:"unknown";return r!=null?`msg:${l}:${r}:${t}`:`msg:${l}:${t}`}function Km(e){return e.connected?d`
1925
+ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,message:{role:"user",content:[{type:"text",text:a}],timestamp:r.createdAt}})}return Fm(t)}function la(e,t){const n=e,s=typeof n.toolCallId=="string"?n.toolCallId:"";if(s)return`tool:${s}`;const i=typeof n.id=="string"?n.id:"";if(i)return`msg:${i}`;const o=typeof n.messageId=="string"?n.messageId:"";if(o)return`msg:${o}`;const r=typeof n.timestamp=="number"?n.timestamp:null,l=typeof n.role=="string"?n.role:"unknown";return r!=null?`msg:${l}:${r}:${t}`:`msg:${l}:${t}`}function Wm(e){return e.connected?d`
1912
1926
  <div class="setup-container setup-container--full chat-page">
1913
1927
  ${tt("Chat",e.wsProps)}
1914
1928
  <div class="chat-viewport">
1915
- ${Im(e)}
1929
+ ${Rm(e)}
1916
1930
  </div>
1917
1931
  </div>
1918
1932
  `:d`
@@ -1922,12 +1936,12 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
1922
1936
  <p>Connecting to gateway...</p>
1923
1937
  </div>
1924
1938
  </div>
1925
- `}function zm(e){return e?`${Ca(e)} (${os(e)})`:"n/a"}function cc(e){const t=e.state??{},n=t.lastStatus??"n/a",s=t.lastRunAtMs?os(t.lastRunAtMs):"never";return`${n} · last ${s}`}function uc(e){const t=e.schedule;return t.kind==="at"?`One-time: ${Ca(t.atMs)}`:t.kind==="every"?`Every ${_a(t.everyMs)}`:`Schedule: ${t.expr}${t.tz?` (${t.tz})`:""}`}function jm(e,t=!0){const n=e.payload;return n.kind==="systemEvent"?`Task: ${t&&n.text.length>60?`${n.text.slice(0,57)}…`:n.text}`:`Message: ${t&&n.message.length>60?`${n.message.slice(0,57)}…`:n.message}`}function la(e){const t=e.payload;if(t.kind!=="agentTurn")return null;const n=t.channel??t.provider,s=t.to;if(!s&&!n)return null;const i=[];return s&&i.push(s),n&&n!=="last"&&i.push(`via ${n}`),i.join(" ")||null}function Hm(e){const t=["last",...e.channels.filter(Boolean)],n=e.form.channel?.trim();n&&!t.includes(n)&&t.push(n);const s=new Set;return t.filter(i=>s.has(i)?!1:(s.add(i),!0))}function qm(e,t){if(t==="last")return"last";const n=e.channelMeta?.find(s=>s.id===t);return n?.label?n.label:e.channelLabels?.[t]??t}function Gm(e){return e||"Default"}const ca=d`<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>`,Vm=d`<svg viewBox="0 0 24 24"><rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/></svg>`,Qm=d`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,dc=d`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,Ym=d`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`;function ua(e){const t=e.detailJobId?e.jobs.find(n=>n.id===e.detailJobId)??null:null;return d`
1939
+ `}function Km(e){return e?`${_a(e)} (${os(e)})`:"n/a"}function cc(e){const t=e.state??{},n=t.lastStatus??"n/a",s=t.lastRunAtMs?os(t.lastRunAtMs):"never";return`${n} · last ${s}`}function uc(e){const t=e.schedule;return t.kind==="at"?`One-time: ${_a(t.atMs)}`:t.kind==="every"?`Every ${Ma(t.everyMs)}`:`Schedule: ${t.expr}${t.tz?` (${t.tz})`:""}`}function zm(e,t=!0){const n=e.payload;return n.kind==="systemEvent"?`Task: ${t&&n.text.length>60?`${n.text.slice(0,57)}…`:n.text}`:`Message: ${t&&n.message.length>60?`${n.message.slice(0,57)}…`:n.message}`}function ca(e){const t=e.payload;if(t.kind!=="agentTurn")return null;const n=t.channel??t.provider,s=t.to;if(!s&&!n)return null;const i=[];return s&&i.push(s),n&&n!=="last"&&i.push(`via ${n}`),i.join(" ")||null}function jm(e){const t=["last",...e.channels.filter(Boolean)],n=e.form.channel?.trim();n&&!t.includes(n)&&t.push(n);const s=new Set;return t.filter(i=>s.has(i)?!1:(s.add(i),!0))}function Hm(e,t){if(t==="last")return"last";const n=e.channelMeta?.find(s=>s.id===t);return n?.label?n.label:e.channelLabels?.[t]??t}function qm(e){return e||"Default"}const ua=d`<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>`,Gm=d`<svg viewBox="0 0 24 24"><rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/></svg>`,Vm=d`<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>`,dc=d`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,Qm=d`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`;function da(e){const t=e.detailJobId?e.jobs.find(n=>n.id===e.detailJobId)??null:null;return d`
1940
+ ${Ym(e)}
1926
1941
  ${Xm(e)}
1927
- ${Zm(e)}
1928
- ${e.newEventModalOpen?ey(e):b}
1929
- ${t?ny(t,e):b}
1930
- `}function Xm(e){const t=e.status,n=t?.enabled??!1,s=t?.jobs??0,i=t?.nextWakeAtMs;return d`
1942
+ ${e.newEventModalOpen?Jm(e):b}
1943
+ ${t?ty(t,e):b}
1944
+ `}function Ym(e){const t=e.status,n=t?.enabled??!1,s=t?.jobs??0,i=t?.nextWakeAtMs;return d`
1931
1945
  <div class="event-status-bar">
1932
1946
  <div class="event-status-bar__info">
1933
1947
  <span class="statusDot ${n?"ok":""}"></span>
@@ -1949,14 +1963,14 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
1949
1963
  ${e.error?d`<span class="muted">${e.error}</span>`:b}
1950
1964
  </div>
1951
1965
  <button class="btn primary btn--sm" @click=${e.onNewEventModalOpen}>
1952
- ${Ym} New Event
1966
+ ${Qm} New Event
1953
1967
  </button>
1954
1968
  </div>
1955
- `}function Zm(e){return e.jobs.length===0?d`<div class="muted" style="padding: 20px 0;">No events yet. Create one to get started.</div>`:d`
1969
+ `}function Xm(e){return e.jobs.length===0?d`<div class="muted" style="padding: 20px 0;">No events yet. Create one to get started.</div>`:d`
1956
1970
  <div class="event-grid">
1957
- ${e.jobs.map(t=>Jm(t,e))}
1971
+ ${e.jobs.map(t=>Zm(t,e))}
1958
1972
  </div>
1959
- `}function Jm(e,t){return d`
1973
+ `}function Zm(e,t){return d`
1960
1974
  <div
1961
1975
  class="event-card ${e.enabled?"":"disabled"}"
1962
1976
  @click=${()=>t.onDetailOpen(e)}
@@ -1968,8 +1982,8 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
1968
1982
  </span>
1969
1983
  </div>
1970
1984
  <div class="event-card__schedule">${uc(e)}</div>
1971
- ${e.agentId?d`<div class="event-card__agent">${Gm(e.agentId)}</div>`:b}
1972
- ${la(e)?d`<div class="event-card__agent muted" style="font-size: 11px;">\u2192 ${la(e)}</div>`:b}
1985
+ ${e.agentId?d`<div class="event-card__agent">${qm(e.agentId)}</div>`:b}
1986
+ ${ca(e)?d`<div class="event-card__agent muted" style="font-size: 11px;">\u2192 ${ca(e)}</div>`:b}
1973
1987
  <div class="event-card__footer">
1974
1988
  <div class="event-card__status">
1975
1989
  <span class="muted" style="font-size: 11px;">${cc(e)}</span>
@@ -1981,7 +1995,7 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
1981
1995
  ?disabled=${t.busy}
1982
1996
  @click=${()=>t.onToggle(e,!e.enabled)}
1983
1997
  >
1984
- ${e.enabled?Vm:ca}
1998
+ ${e.enabled?Gm:ua}
1985
1999
  </button>
1986
2000
  <button
1987
2001
  class="btn-icon"
@@ -1989,7 +2003,7 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
1989
2003
  ?disabled=${t.busy}
1990
2004
  @click=${()=>t.onRun(e)}
1991
2005
  >
1992
- ${ca}
2006
+ ${ua}
1993
2007
  </button>
1994
2008
  <button
1995
2009
  class="btn-icon danger"
@@ -1997,12 +2011,12 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
1997
2011
  ?disabled=${t.busy}
1998
2012
  @click=${()=>t.onRemove(e)}
1999
2013
  >
2000
- ${Qm}
2014
+ ${Vm}
2001
2015
  </button>
2002
2016
  </div>
2003
2017
  </div>
2004
2018
  </div>
2005
- `}function ey(e){const t=Hm(e);return d`
2019
+ `}function Jm(e){const t=jm(e);return d`
2006
2020
  <div class="event-modal-overlay" @click=${e.onNewEventModalClose}>
2007
2021
  <div class="event-modal" @click=${n=>n.stopPropagation()}>
2008
2022
  <div class="event-modal__header">
@@ -2060,7 +2074,7 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2060
2074
  </label>
2061
2075
  </div>
2062
2076
 
2063
- ${ty(e)}
2077
+ ${ey(e)}
2064
2078
 
2065
2079
  <div class="form-grid" style="margin-top: 12px;">
2066
2080
  <label class="field">
@@ -2122,7 +2136,7 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2122
2136
  @change=${n=>e.onFormChange({channel:n.target.value})}
2123
2137
  >
2124
2138
  ${t.map(n=>d`<option value=${n}>
2125
- ${qm(e,n)}
2139
+ ${Hm(e,n)}
2126
2140
  </option>`)}
2127
2141
  </select>
2128
2142
  </label>
@@ -2161,7 +2175,7 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2161
2175
  </div>
2162
2176
  </div>
2163
2177
  </div>
2164
- `}function ty(e){const t=e.form;return t.scheduleKind==="at"?d`
2178
+ `}function ey(e){const t=e.form;return t.scheduleKind==="at"?d`
2165
2179
  <label class="field" style="margin-top: 12px;">
2166
2180
  <span>Run at</span>
2167
2181
  <input
@@ -2210,7 +2224,7 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2210
2224
  />
2211
2225
  </label>
2212
2226
  </div>
2213
- `}function ny(e,t){return d`
2227
+ `}function ty(e,t){return d`
2214
2228
  <div class="event-modal-overlay" @click=${t.onDetailClose}>
2215
2229
  <div class="event-modal" @click=${n=>n.stopPropagation()}>
2216
2230
  <div class="event-modal__header">
@@ -2255,7 +2269,7 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2255
2269
  </div>
2256
2270
  <div class="event-detail-row" style="flex-direction: column; align-items: stretch; gap: 4px;">
2257
2271
  <span class="event-detail-label">Action</span>
2258
- <span class="event-detail-value" style="text-align: left; white-space: pre-wrap; font-size: 12px; color: var(--muted); line-height: 1.5;">${jm(e,!1)}</span>
2272
+ <span class="event-detail-value" style="text-align: left; white-space: pre-wrap; font-size: 12px; color: var(--muted); line-height: 1.5;">${zm(e,!1)}</span>
2259
2273
  </div>
2260
2274
  ${e.payload.kind==="agentTurn"&&e.payload.to?d`
2261
2275
  <div class="event-detail-row">
@@ -2285,7 +2299,7 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2285
2299
  ${e.state?.nextRunAtMs?d`
2286
2300
  <div class="event-detail-row">
2287
2301
  <span class="event-detail-label">Next run</span>
2288
- <span class="event-detail-value">${zm(e.state.nextRunAtMs)}</span>
2302
+ <span class="event-detail-value">${Km(e.state.nextRunAtMs)}</span>
2289
2303
  </div>
2290
2304
  `:b}
2291
2305
  </div>
@@ -2296,7 +2310,7 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2296
2310
  </div>
2297
2311
  ${t.runs.length===0?d`<div class="muted" style="font-size: 13px;">No runs recorded yet.</div>`:d`
2298
2312
  <div class="list">
2299
- ${[...t.runs].sort((n,s)=>s.ts-n.ts).map(n=>iy(n))}
2313
+ ${[...t.runs].sort((n,s)=>s.ts-n.ts).map(n=>sy(n))}
2300
2314
  </div>
2301
2315
  `}
2302
2316
  </div>
@@ -2326,14 +2340,14 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2326
2340
  </div>
2327
2341
  </div>
2328
2342
  </div>
2329
- `}function sy(e){const t=e.toLowerCase();return t==="ok"||t==="success"?"chip chip-ok":t==="error"||t==="fail"||t==="failed"?"chip chip-warn":"chip"}function iy(e){return d`
2343
+ `}function ny(e){const t=e.toLowerCase();return t==="ok"||t==="success"?"chip chip-ok":t==="error"||t==="fail"||t==="failed"?"chip chip-warn":"chip"}function sy(e){return d`
2330
2344
  <div class="list-item" style="grid-template-columns: 1fr; gap: 6px;">
2331
2345
  <div style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
2332
- <span class=${sy(e.status)} style="font-size: 11px; padding: 2px 8px;">
2346
+ <span class=${ny(e.status)} style="font-size: 11px; padding: 2px 8px;">
2333
2347
  ${e.status}
2334
2348
  </span>
2335
2349
  <span class="muted" style="font-size: 12px;">${os(e.ts)}</span>
2336
- <span class="muted" style="font-size: 12px;">${_a(e.durationMs)}</span>
2350
+ <span class="muted" style="font-size: 12px;">${Ma(e.durationMs)}</span>
2337
2351
  </div>
2338
2352
  ${e.summary?d`<div class="muted" style="font-size: 12px;">${e.summary}</div>`:b}
2339
2353
  ${e.error?d`
@@ -2343,7 +2357,7 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2343
2357
  </details>
2344
2358
  `:b}
2345
2359
  </div>
2346
- `}function oy(e){const t=e.report?.skills??[],n=e.filter.trim().toLowerCase(),s=n?t.filter(i=>[i.name,i.description,i.source].join(" ").toLowerCase().includes(n)):t;return d`
2360
+ `}function iy(e){const t=e.report?.skills??[],n=e.filter.trim().toLowerCase(),s=n?t.filter(i=>[i.name,i.description,i.source].join(" ").toLowerCase().includes(n)):t;return d`
2347
2361
  <section class="card">
2348
2362
  <div class="row" style="justify-content: space-between;">
2349
2363
  <div>
@@ -2371,11 +2385,11 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2371
2385
 
2372
2386
  ${s.length===0?d`<div class="muted" style="margin-top: 16px;">No skills found.</div>`:d`
2373
2387
  <div class="list" style="margin-top: 16px;">
2374
- ${s.map(i=>ry(i,e))}
2388
+ ${s.map(i=>oy(i,e))}
2375
2389
  </div>
2376
2390
  `}
2377
2391
  </section>
2378
- `}function ry(e,t){const n=t.busyKey===e.skillKey,s=t.edits[e.skillKey]??"",i=t.messages[e.skillKey]??null,o=e.install.length>0&&e.missing.bins.length>0,r=[...e.missing.bins.map(a=>`bin:${a}`),...e.missing.env.map(a=>`env:${a}`),...e.missing.config.map(a=>`config:${a}`),...e.missing.os.map(a=>`os:${a}`)],l=[];return e.disabled&&l.push("disabled"),e.blockedByAllowlist&&l.push("blocked by allowlist"),d`
2392
+ `}function oy(e,t){const n=t.busyKey===e.skillKey,s=t.edits[e.skillKey]??"",i=t.messages[e.skillKey]??null,o=e.install.length>0&&e.missing.bins.length>0,r=[...e.missing.bins.map(a=>`bin:${a}`),...e.missing.env.map(a=>`env:${a}`),...e.missing.config.map(a=>`config:${a}`),...e.missing.os.map(a=>`os:${a}`)],l=[];return e.disabled&&l.push("disabled"),e.blockedByAllowlist&&l.push("blocked by allowlist"),d`
2379
2393
  <div class="list-item">
2380
2394
  <div class="list-main">
2381
2395
  <div class="list-title">
@@ -2443,7 +2457,7 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2443
2457
  `:b}
2444
2458
  </div>
2445
2459
  </div>
2446
- `}const da=["user","assistant","tool","thinking","error"],pa={user:"User",assistant:"Assistant",tool:"Tool",thinking:"Thinking",error:"Error",system:"System"};function ay(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function ly(e){return e.split(":").slice(2).join(":")||e}function cy(e,t){return t?[e.content,e.agentId,e.sessionKey,e.toolName].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function uy(e,t=500){return e.length<=t?e:e.slice(0,t)+"..."}function dy(e){const t=e.filterText.trim().toLowerCase();da.some(s=>!e.typeFilters[s]),e.agents.some(s=>!e.agentFilters[s]);const n=e.entries.filter(s=>!e.typeFilters[s.type]||e.agents.length>0&&!(e.agentFilters[s.agentId]??!0)?!1:cy(s,t));return d`
2460
+ `}const pa=["user","assistant","tool","thinking","error"],ha={user:"User",assistant:"Assistant",tool:"Tool",thinking:"Thinking",error:"Error",system:"System"};function ry(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function ay(e){return e.split(":").slice(2).join(":")||e}function ly(e,t){return t?[e.content,e.agentId,e.sessionKey,e.toolName].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function cy(e,t=500){return e.length<=t?e:e.slice(0,t)+"..."}function uy(e){const t=e.filterText.trim().toLowerCase();pa.some(s=>!e.typeFilters[s]),e.agents.some(s=>!e.agentFilters[s]);const n=e.entries.filter(s=>!e.typeFilters[s.type]||e.agents.length>0&&!(e.agentFilters[s.agentId]??!0)?!1:ly(s,t));return d`
2447
2461
  <div>
2448
2462
  <div class="filters" style="margin-top: 14px;">
2449
2463
  <label class="field" style="min-width: 220px;">
@@ -2457,14 +2471,14 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2457
2471
  </div>
2458
2472
 
2459
2473
  <div class="chip-row" style="margin-top: 12px;">
2460
- ${da.map(s=>d`
2474
+ ${pa.map(s=>d`
2461
2475
  <label class="chip session-log-chip ${s}">
2462
2476
  <input
2463
2477
  type="checkbox"
2464
2478
  .checked=${e.typeFilters[s]}
2465
2479
  @change=${i=>e.onTypeToggle(s,i.target.checked)}
2466
2480
  />
2467
- <span>${pa[s]}</span>
2481
+ <span>${ha[s]}</span>
2468
2482
  </label>
2469
2483
  `)}
2470
2484
  </div>
@@ -2504,19 +2518,19 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2504
2518
  ${n.length===0?d`<div class="muted" style="padding: 12px;">No session log entries.</div>`:n.map(s=>d`
2505
2519
  <div class="log-row session-entry ${s.type}">
2506
2520
  <div class="log-row-header">
2507
- <span class="log-time mono">${ay(s.timestamp)}</span>
2508
- <span class="session-log-type ${s.type}">${pa[s.type]}</span>
2521
+ <span class="log-time mono">${ry(s.timestamp)}</span>
2522
+ <span class="session-log-type ${s.type}">${ha[s.type]}</span>
2509
2523
  <span class="log-subsystem mono">${s.agentId}</span>
2510
- <span class="session-label mono">${ly(s.sessionKey)}</span>
2524
+ <span class="session-label mono">${ay(s.sessionKey)}</span>
2511
2525
  ${s.toolName?d`<span class="session-tool mono">${s.toolName}</span>`:b}
2512
2526
  ${s.model?d`<span class="session-model mono">${s.model}</span>`:b}
2513
2527
  </div>
2514
- <div class="log-message mono">${e.full?s.content:uy(s.content)}</div>
2528
+ <div class="log-message mono">${e.full?s.content:cy(s.content)}</div>
2515
2529
  </div>
2516
2530
  `)}
2517
2531
  </div>
2518
2532
  </div>
2519
- `}const Mi=["trace","debug","info","warn","error","fatal"];function py(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function pc(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function hy(e){return d`
2533
+ `}const Mi=["trace","debug","info","warn","error","fatal"];function dy(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function pc(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function py(e){return d`
2520
2534
  <section class="card">
2521
2535
  <div class="row" style="justify-content: space-between;">
2522
2536
  <div>
@@ -2561,9 +2575,9 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2561
2575
  </button>
2562
2576
  </div>
2563
2577
 
2564
- ${e.logsSubTab==="session"?dy(e.sessionLogsProps):fy(e)}
2578
+ ${e.logsSubTab==="session"?uy(e.sessionLogsProps):hy(e)}
2565
2579
  </section>
2566
- `}function fy(e){const t=e.filterText.trim().toLowerCase();Mi.some(s=>!e.levelFilters[s]);const n=e.entries.filter(s=>s.level&&!e.levelFilters[s.level]?!1:pc(s,t));return d`
2580
+ `}function hy(e){const t=e.filterText.trim().toLowerCase();Mi.some(s=>!e.levelFilters[s]);const n=e.entries.filter(s=>s.level&&!e.levelFilters[s.level]?!1:pc(s,t));return d`
2567
2581
  <div class="filters" style="margin-top: 14px;">
2568
2582
  <label class="field" style="min-width: 220px;">
2569
2583
  <span>Filter</span>
@@ -2606,7 +2620,7 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2606
2620
  ${n.length===0?d`<div class="muted" style="padding: 12px;">No log entries.</div>`:[...n].reverse().map(s=>d`
2607
2621
  <div class="log-row">
2608
2622
  <div class="log-row-header">
2609
- <span class="log-time mono">${py(s.time)}</span>
2623
+ <span class="log-time mono">${dy(s.time)}</span>
2610
2624
  <span class="log-level ${s.level??""}">${s.level??""}</span>
2611
2625
  <span class="log-subsystem mono">${s.subsystem??""}</span>
2612
2626
  </div>
@@ -2614,13 +2628,13 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2614
2628
  </div>
2615
2629
  `)}
2616
2630
  </div>
2617
- `}const gy=[{id:"cron",label:"Events"},{id:"skills",label:"Skills"},{id:"logs",label:"Logs"}];function my(e){switch(e.activeTab){case"cron":return ua(e.cronProps);case"skills":return oy(e.skillsProps);case"logs":return hy(e.logsProps);default:return ua(e.cronProps)}}function yy(e){return e.connected?d`
2631
+ `}const fy=[{id:"cron",label:"Events"},{id:"skills",label:"Skills"},{id:"logs",label:"Logs"}];function gy(e){switch(e.activeTab){case"cron":return da(e.cronProps);case"skills":return iy(e.skillsProps);case"logs":return py(e.logsProps);default:return da(e.cronProps)}}function my(e){return e.connected?d`
2618
2632
  <div class="setup-container">
2619
2633
  ${tt("Advanced",e.wsProps)}
2620
2634
  <div class="setup-card sp-card-advanced" style="text-align: left;">
2621
2635
  <h1>Advanced</h1>
2622
2636
  <div class="sp-tabs">
2623
- ${gy.map(t=>d`
2637
+ ${fy.map(t=>d`
2624
2638
  <button
2625
2639
  class="sp-tab ${e.activeTab===t.id?"active":""}"
2626
2640
  @click=${()=>e.onTabChange(t.id)}
@@ -2629,7 +2643,7 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2629
2643
  </button>
2630
2644
  `)}
2631
2645
  </div>
2632
- ${my(e)}
2646
+ ${gy(e)}
2633
2647
  </div>
2634
2648
  </div>
2635
2649
  `:d`
@@ -2639,7 +2653,7 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2639
2653
  <p>Connecting to gateway...</p>
2640
2654
  </div>
2641
2655
  </div>
2642
- `}function ha(e){if(!e.show)return b;const t=De(),n=e.isFirstTime,s=e.changePinMode===!0&&!n,i=e.changePinBusy===!0;let o=e.accounts.length>0?e.accounts[0].id:"";const r=m=>{o=m.target.value;const v=m.target.closest(".login-card")?.querySelector(".login-change-pin");v&&(v.style.display=o==="__master__"?"":"none")},l=m=>v=>{const w=v.target;w.value=w.value.replace(/\D/g,"").slice(0,6),m(w.value)},a=!n&&e.accounts.length>1?d`
2656
+ `}function fa(e){if(!e.show)return b;const t=De(),n=e.isFirstTime,s=e.changePinMode===!0&&!n,i=e.changePinBusy===!0;let o=e.accounts.length>0?e.accounts[0].id:"";const r=m=>{o=m.target.value;const v=m.target.closest(".login-card")?.querySelector(".login-change-pin");v&&(v.style.display=o==="__master__"?"":"none")},l=m=>v=>{const w=v.target;w.value=w.value.replace(/\D/g,"").slice(0,6),m(w.value)},a=!n&&e.accounts.length>1?d`
2643
2657
  <select
2644
2658
  class="login-account-select"
2645
2659
  @change=${r}
@@ -2763,7 +2777,7 @@ ${r.text}`:l.join(", "):r.text;t.push({kind:"message",key:`queue:${r.id}`,messag
2763
2777
  </p>`:b}
2764
2778
  </div>
2765
2779
  </div>
2766
- `}const $o="taskmaster-access-session",hc={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function fc(){try{return localStorage.getItem($o)}catch{return null}}function gc(e){try{localStorage.setItem($o,e)}catch{}}function vy(){try{localStorage.removeItem($o)}catch{}}async function fa(e){if(e.client)try{const t=fc(),n=await e.client.request("access.status",{token:t});e.accessState={...e.accessState,checked:!0,hasPins:n.hasPins,hasMasterPin:n.hasMasterPin,accounts:n.accounts??[],authenticated:n.authenticated,workspace:n.workspace,master:n.master,error:null}}catch{e.accessState={...e.accessState,checked:!0,hasPins:!1,hasMasterPin:!1,accounts:[],authenticated:!0,error:null}}}async function by(e,t,n){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const s=await e.client.request("access.verify",{account:t,pin:n});s.ok&&s.token?(gc(s.token),e.accessState={...e.accessState,authenticated:!0,workspace:s.workspace??null,master:s.master??!1,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:s.message??"Incorrect PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to verify PIN"}}}}async function wy(e,t){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const n=await e.client.request("access.setMasterPin",{pin:t});n.ok&&n.token?(gc(n.token),e.accessState={...e.accessState,checked:!0,hasPins:!0,hasMasterPin:!0,authenticated:!0,workspace:null,master:!0,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:"Failed to set PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to set PIN"}}}}async function ky(e,t,n){if(!e.client)return!1;try{return(await e.client.request("access.setAccountPin",{workspace:t,pin:n})).ok}catch{return!1}}async function Sy(e){const t=fc();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}vy(),e.accessState={...hc,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}async function Pi(e){return(await e.request("apikeys.list")).providers??[]}async function ga(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function Ay(e,t){await e.request("apikeys.remove",{provider:t})}class xy{constructor(){this.canvas=null,this.ctx=null,this.img=new Image,this.pendingFrame=null,this.rafId=null,this.deviceWidth=1280,this.deviceHeight=720,this.lastMouseMoveAt=0,this.MOUSE_THROTTLE_MS=30}attach(t){this.canvas=t,this.ctx=t.getContext("2d")}detach(){this.rafId!=null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.canvas=null,this.ctx=null,this.pendingFrame=null}updateFrame(t,n){n?.deviceWidth&&(this.deviceWidth=n.deviceWidth),n?.deviceHeight&&(this.deviceHeight=n.deviceHeight),this.pendingFrame=t,this.rafId==null&&(this.rafId=requestAnimationFrame(()=>this.renderFrame()))}renderFrame(){this.rafId=null;const t=this.pendingFrame;!t||!this.canvas||!this.ctx||(this.pendingFrame=null,this.img.onload=()=>{!this.canvas||!this.ctx||((this.canvas.width!==this.img.width||this.canvas.height!==this.img.height)&&(this.canvas.width=this.img.width,this.canvas.height=this.img.height),this.ctx.drawImage(this.img,0,0))},this.img.src=`data:image/jpeg;base64,${t}`)}translateCoordinates(t,n){if(!this.canvas)return{x:t,y:n};const s=this.canvas.getBoundingClientRect(),i=this.canvas.width/s.width,o=this.canvas.height/s.height,r=this.deviceWidth/this.canvas.width,l=this.deviceHeight/this.canvas.height;return{x:Math.round(t*i*r),y:Math.round(n*o*l)}}shouldThrottleMouseMove(){const t=performance.now();return t-this.lastMouseMoveAt<this.MOUSE_THROTTLE_MS?!0:(this.lastMouseMoveAt=t,!1)}getDeviceDimensions(){return{width:this.deviceWidth,height:this.deviceHeight}}}let ti=null;function Bn(){return ti||(ti=new xy),ti}function Eo(e){return e instanceof Error?e.message:String(e)}async function $y(e){if(!(!e.client||!e.connected)){e.browserLoading=!0,e.browserError=null;try{(await e.client.request("browser.screencast.start",{quality:60,maxWidth:1280,maxHeight:720}))?.ok&&(e.browserScreencastActive=!0)}catch(t){e.browserError=Eo(t)}finally{e.browserLoading=!1}}}async function Ey(e){if(!(!e.client||!e.connected)){e.browserLoading=!0;try{await e.client.request("browser.screencast.stop",{}),e.browserScreencastActive=!1,e.browserScreencastFrame=null,e.browserScreencastMetadata=null}catch(t){e.browserError=Eo(t)}finally{e.browserLoading=!1}}}async function ni(e,t,n,s,i){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"mouse",action:t,x:n,y:s,button:i??"left",clickCount:t==="mousePressed"?1:0})}catch{}}async function si(e,t,n,s){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"key",action:t,key:n,...s?.text?{text:s.text}:{},...s?.code?{code:s.code}:{},...s?.modifiers?{modifiers:s.modifiers}:{}})}catch{}}async function Ty(e){if(!(!e.client||!e.connected))try{await e.client.request("browser.handoff.complete",{}),e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}catch(t){e.browserError=Eo(t)}}function Cy(e){e.browserInputMode=!e.browserInputMode}function _y(e,t){if(!t?.data)return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,Bn().updateFrame(t.data,t.metadata)}function My(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function Py(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}function Fe(e){return e instanceof Error?e.message:String(e)}let Pn=null;function sn(e,t){Pn&&clearTimeout(Pn),e.filesMessage={kind:"success",text:t},Pn=setTimeout(()=>{e.filesMessage=null,Pn=null},3e3)}async function on(e,t){if(!(!e.client||!e.connected)){if(!t){e.filesTree=[],e.filesRoot="";return}if(!e.filesLoading){e.filesLoading=!0,e.filesError=null;try{const n={};t&&(n.agentId=t);const s=await e.client.request("files.tree",n);s?.tree&&(e.filesTree=s.tree,e.filesRoot=s.root??"")}catch(n){e.filesError=Fe(n)}finally{e.filesLoading=!1}}}}async function Ly(e,t,n){e.filesSelectedPaths=new Set([t]),await mc(e,t,n)}async function Ry(e,t,n){const s=new Set(e.filesSelectedPaths);if(s.has(t)?s.delete(t):s.add(t),e.filesSelectedPaths=s,s.size===1){const i=[...s][0];await mc(e,i,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function Iy(e,t){if(!e.client||!e.connected)return;const n=[...e.filesSelectedPaths];if(n.length===0)return;let s=0,i="";for(const o of n)try{await yc(e,o,t),s++}catch(r){i=Fe(r)}i?e.filesMessage={kind:"error",text:`${s} downloaded, error: ${i}`}:sn(e,`${s} file${s!==1?"s":""} downloaded`)}async function Ny(e,t,n,s){const i=t.split("/").pop()??t,o=n==="."?i:`${n}/${i}`;o!==t&&await vc(e,t,o,s)}async function mc(e,t,n){if(!(!e.client||!e.connected)){e.filesSelectedPath=t,e.filesPreviewLoading=!0,e.filesPreviewContent=null,e.filesPreviewBinary=!1,e.filesPreviewSize=null;try{const s={path:t};n&&(s.agentId=n);const i=await e.client.request("files.read",s);e.filesPreviewContent=i?.content??null,e.filesPreviewBinary=i?.binary??!1,e.filesPreviewSize=i?.size??null}catch(s){e.filesError=Fe(s)}finally{e.filesPreviewLoading=!1}}}async function yc(e,t,n){if(!(!e.client||!e.connected))try{const s={path:t};n&&(s.agentId=n);const i=await e.client.request("files.download",s);if(!i?.base64){e.filesMessage={kind:"error",text:"Download failed: no data"};return}const o=Uint8Array.from(atob(i.base64),c=>c.charCodeAt(0)),r=new Blob([o]),l=URL.createObjectURL(r),a=document.createElement("a");a.href=l,a.download=i.name??t.split("/").pop()??"download",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(l)}catch(s){e.filesMessage={kind:"error",text:Fe(s)}}}async function Oy(e,t,n,s){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let i=0,o="";for(const r of n)try{const l=await r.arrayBuffer(),a=btoa(new Uint8Array(l).reduce((u,p)=>u+String.fromCharCode(p),"")),c={path:t,name:r.name,data:a};s&&(c.agentId=s),await e.client.request("files.upload",c),i++}catch(l){o=Fe(l)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:i>0?`${i} uploaded, error: ${o}`:o}:sn(e,`${i} file${i!==1?"s":""} uploaded`),await on(e,s)}async function Dy(e,t,n){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const s={path:t};n&&(s.agentId=n),await e.client.request("files.delete",s),sn(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await on(e,n)}catch(s){e.filesMessage={kind:"error",text:Fe(s)}}}}async function vc(e,t,n,s){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const i={from:t,to:n};s&&(i.agentId=s),await e.client.request("files.move",i),sn(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await on(e,s)}catch(i){e.filesMessage={kind:"error",text:Fe(i)}}}}async function bc(e,t){if(!(!e.client||!e.connected))try{const n={};t&&(n.agentId=t);const s=await e.client.request("memory.status",n);s?.ok&&(e.filesMemoryStatus={dirty:s.dirty??!1,files:s.files??0,chunks:s.chunks??0})}catch{}}async function By(e,t){if(!(!e.client||!e.connected)&&!e.filesReindexBusy){e.filesReindexBusy=!0,e.filesMessage=null;try{const n={force:!0};t&&(n.agentId=t);const s=await e.client.request("memory.reindex",n),i=s?.files??0,o=s?.chunks??0;sn(e,`Re-indexed: ${i} files, ${o} chunks`),await bc(e,t)}catch(n){e.filesMessage={kind:"error",text:Fe(n)}}finally{e.filesReindexBusy=!1}}}function Fy(e,t){const n=new Set(e.filesExpandedDirs);n.has(t)?n.delete(t):n.add(t),e.filesExpandedDirs=n}function Uy(e,t="admin"){if(!e)return[];const n=e.bindings;if(!Array.isArray(n))return[];const s=[];for(const i of n){if(!i||typeof i!="object"||i.agentId!==t)continue;const o=i.match;if(!o||typeof o!="object"||(o.channel??"").toLowerCase()!=="whatsapp")continue;const l=o.peer;if(!l||typeof l!="object"||l.kind!=="dm")continue;const a=l.id??"";a&&s.push({phone:a,paired:i.meta?.paired===!0})}return s.sort((i,o)=>i.paired&&!o.paired?-1:!i.paired&&o.paired?1:0),s}function wc(e,t,n="admin",s){const i=new Map,o=new Map;for(const a of e){if(!a||typeof a!="object"||a.agentId!==n)continue;const c=a.match;if(!c||typeof c!="object"||(c.channel??"").toLowerCase()!=="whatsapp")continue;const p=c.peer;if(!p||typeof p!="object"||p.kind!=="dm")continue;const m=p.id??"";m&&(a.meta&&i.set(m,a.meta),c.accountId&&o.set(m,c.accountId))}const r=e.filter(a=>{if(!a||typeof a!="object"||a.agentId!==n)return!0;const c=a.match;if(!c||typeof c!="object"||(c.channel??"").toLowerCase()!=="whatsapp")return!0;const p=c.peer;return!p||typeof p!="object"?!0:p.kind!=="dm"}),l=t.map(a=>{const c=s??o.get(a.phone),u={channel:"whatsapp",peer:{kind:"dm",id:a.phone}};c&&(u.accountId=c);const p={agentId:n,match:u},m=i.get(a.phone);return m?p.meta=m:a.paired&&(p.meta={paired:!0}),p});return[...r,...l]}async function fs(e,t){if(!e.client||!e.connected)return;if(!t){e.adminPhones=[];return}if(e.adminsLoading)return;e.adminsLoading=!0,e.adminsError=null;const n=t;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const i=s.config;e.configForm=Oe(i??{}),e.adminPhones=Uy(i,n),e.configFormDirty=!1}catch(s){e.adminsError=String(s)}finally{e.adminsLoading=!1}}async function kc(e,t,n,s){if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const i=n;let o=t.trim();if(!o){e.adminsError="Phone number is required";return}if(o.startsWith("+")||(o="+"+o),!/^\+[1-9]\d{6,14}$/.test(o)){e.adminsError="Invalid phone number format. Use E.164 format (e.g., +14155552671)";return}if(e.adminPhones.some(r=>r.phone===o)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const r=Oe(e.configForm??e.configSnapshot?.config??{}),l=r.bindings??[],a=[...e.adminPhones,{phone:o}],c=wc(l,a,i,s);Fa(r,["bindings"],c);const u=e.configSnapshot?.hash;if(!u){e.adminsError="Config hash missing; reload and retry.";return}const p=Qe(r);await e.client.request("config.set",{raw:p,baseHash:u}),await fs(e,n)}catch(r){e.adminsError=String(r)}finally{e.adminsSaving=!1}}async function Sc(e,t,n,s){if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const i=n;if(e.adminPhones.find(r=>r.phone===t)?.paired){e.adminsError="Cannot remove the paired phone. Unlink WhatsApp first.";return}e.adminsSaving=!0,e.adminsError=null;try{const r=Oe(e.configForm??e.configSnapshot?.config??{}),l=r.bindings??[],a=e.adminPhones.filter(m=>m.phone!==t),c=wc(l,a,i,s);Fa(r,["bindings"],c);const u=e.configSnapshot?.hash;if(!u){e.adminsError="Config hash missing; reload and retry.";return}const p=Qe(r);await e.client.request("config.set",{raw:p,baseHash:u}),await fs(e,n)}catch(r){e.adminsError=String(r)}finally{e.adminsSaving=!1}}const Wy=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:kc,loadAdmins:fs,removeAdmin:Sc},Symbol.toStringTag,{value:"Module"}));async function et(e,t){if(!(!e.client||!e.connected)){if(!t){e.customersRecords=[];return}if(!e.customersLoading){e.customersLoading=!0,e.customersError=null;try{const n=e.customersSearchQuery.trim(),s=n?await e.client.request("records.search",{query:n,workspace:t}):await e.client.request("records.list",{workspace:t});e.customersRecords=s.records??[]}catch(n){e.customersError=String(n)}finally{e.customersLoading=!1}}}}async function Ac(e,t,n,s){if(!e.client||!e.connected||e.customersSaving)return;let i=t.trim();const o=n.trim();if(!i){e.customersError="Phone number is required";return}if(!o){e.customersError="Name is required";return}if(i.startsWith("+")||(i="+"+i),!/^\+[1-9]\d{6,14}$/.test(i)){e.customersError="Invalid phone number format. Use E.164 (e.g. +447490553305)";return}e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.set",{id:i,name:o,fields:{},workspace:s}),e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName="",await et(e,s)}catch(r){e.customersError=String(r)}finally{e.customersSaving=!1}}async function xc(e,t,n){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.delete",{id:t}),e.customersEditingId===t&&(e.customersEditingId=null),await et(e,n)}catch(s){e.customersError=String(s)}finally{e.customersSaving=!1}}}async function $c(e,t,n,s,i){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.setField",{id:t,key:n,value:s}),await et(e,i)}catch(o){e.customersError=String(o)}finally{e.customersSaving=!1}}}async function Ec(e,t,n,s){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.deleteField",{id:t,key:n}),await et(e,s)}catch(i){e.customersError=String(i)}finally{e.customersSaving=!1}}}const Ky=Object.freeze(Object.defineProperty({__proto__:null,addCustomer:Ac,deleteCustomer:xc,deleteCustomerField:Ec,loadCustomers:et,setCustomerField:$c},Symbol.toStringTag,{value:"Module"}));function Ut(e){if(e.workspaces.length!==0)return{workspaces:e.workspaces,selectedWorkspace:e.selectedWorkspace,onWorkspaceSelect:t=>e.handleWorkspaceSelect(t),hasPins:e.accessState.hasPins,isMaster:e.accessState.master,onLogout:()=>e.handleLogout()}}function zy(e){if(e.workspaces.length!==0)return{workspaces:e.workspaces,selectedWorkspace:e.selectedWorkspace,onWorkspaceSelect:t=>e.handleWorkspaceSelect(t),onAddAccount:()=>{e.addingWorkspace=!0},hasPins:e.accessState.hasPins,isMaster:e.accessState.master,onLogout:()=>e.handleLogout()}}function jy(e){const t=J(e);return t?t.agents.find(s=>s.id.endsWith("-admin")||s.id==="admin")?.id:void 0}function Hy(e){return J(e)?.whatsappAccountId??void 0}function qy(e){const t=J(e);if(t)return t.agents[0]?.id}function Gy(e){return e.selectedWorkspace??void 0}function J(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const Vy=/^data:/i,Qy=/^https?:\/\//i;function Yy(e){const t=e.agentsList?.agents??[],s=Ta(e.sessionKey)?.agentId??e.agentsList?.defaultId??"main",o=t.find(l=>l.id===s)?.identity,r=o?.avatarUrl??o?.avatar;if(r)return Vy.test(r)||Qy.test(r)?r:o?.avatarUrl}function Xy(e){if(!e)return null;const t=e.channelAccounts?.whatsapp;if(!t||t.length===0)return null;const n=t[0];return{running:n.running??!1,connected:n.connected??!1,linked:n.linked??!1,lastError:n.lastError}}function Zy(e){if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=e.channelAccounts?.imessage;if(!t||t.length===0)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const n=t[0],s=n.running??!1,i=n.probe,o=i!=null?i.ok===!0:s;return{configured:n.configured??!1,running:s,connected:o,lastError:n.lastError??null,selfChatMode:n.mode==="self-chat"||!!n.selfChatMode,dmPolicy:n.dmPolicy??null,cliPath:n.cliPath??null}}function Jy(e){const t=e.configSnapshot?.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const s=n.find(r=>r.match?.channel==="imessage"&&r.meta?.imessageOwner);if(!s)return null;const i=s.agentId;for(const r of e.workspaces)if(r.agents.some(l=>l.id===i))return r.name;if(i==="admin"||i==="public")return e.workspaces.find(l=>l.isDefault)?.name??null;const o=i.replace(/-(admin|public)$/,"");return o!==i?e.workspaces.find(l=>l.name===o)?.name??null:null}function ev(e){if(e.connected&&e.accessState.checked){const{accessState:t}=e;if(t.hasPins&&!t.authenticated)return ha({show:!0,isFirstTime:!1,accounts:t.accounts,error:t.error,busy:t.busy,onSubmit:(n,s)=>{s!=null&&e.handlePinSubmit(n,s)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(n,s,i)=>e.handleChangePin(n,s,i)});if(!t.hasMasterPin&&!t.authenticated&&e.setup)return ha({show:!0,isFirstTime:!0,accounts:[],error:t.error,busy:t.busy,onSubmit:n=>e.handleSetMasterPin(n)});if(!t.hasMasterPin&&!t.authenticated&&!e.setup)return window.location.href="/setup",b}if(e.setup){const t=Xy(e.channelsSnapshot),n=e.channelsSnapshot?.channelAccounts?.whatsapp??[],s=Zy(e.channelsSnapshot),i=Jy(e);return eh({connected:e.connected,assistantName:e.assistantName,currentStep:e.setupStep,licenseKey:e.licenseKey,licenseBusy:e.licenseBusy,licenseValid:e.licenseValid,licenseMessage:e.licenseMessage,licenseTier:e.licenseTier,licenseDeviceId:e.licenseDeviceId,licenseStoredKey:e.licenseStoredKey,onLicenseKeyChange:o=>e.handleLicenseKeyChange(o),onLicenseActivate:()=>e.handleLicenseActivate(),onLicenseRemove:async()=>{await e.handleLicenseRemove(),e.licenseRemoveConfirm=!1},licenseRemoveConfirm:e.licenseRemoveConfirm,onLicenseRemoveConfirm:()=>{e.licenseRemoveConfirm=!0},onLicenseRemoveCancel:()=>{e.licenseRemoveConfirm=!1},authConnected:e.authConnected,authBusy:e.authBusy,authMessage:e.authMessage,authUrl:e.authUrl,authCodeInput:e.authCodeInput,authExpiresIn:e.authExpiresIn,whatsappBusy:e.whatsappBusy,whatsappLoginMessage:e.whatsappLoginMessage,whatsappLoginQrDataUrl:e.whatsappLoginQrDataUrl,whatsappLoginConnected:e.whatsappLoginConnected,whatsappChannelStatus:t,whatsappAccounts:n,whatsappActiveQrAccountId:e.whatsappActiveQrAccountId,whatsappAccountSaving:e.whatsappAccountSaving,gatewayHealthy:e.gatewayHealthy,gatewayHealthLoading:e.gatewayHealthLoading,gatewayHealthMessage:e.gatewayHealthMessage,gatewayRestartBusy:e.gatewayRestartBusy,updateAvailable:e.updateAvailable,currentVersion:e.currentVersion,latestVersion:e.latestVersion,updateChecking:e.updateChecking,updateRunning:e.updateRunning,updateMessage:e.updateMessage,updateProgressSteps:e.updateProgressSteps,updateLastResult:e.updateLastResult,onUpdateCheck:()=>e.handleUpdateCheck(),onUpdateRun:()=>e.handleUpdateRun(),onUpdateDismissResult:()=>e.handleUpdateDismissResult(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:o=>e.handleAuthSubmitCode(o),onAuthCodeChange:o=>e.handleAuthCodeChange(o),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async o=>{await e.handleWhatsAppStart(!0,o),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(o),await z(e,!0),e.requestUpdate())},onWhatsAppReset:async o=>{await e.handleWhatsAppLogout(o),await e.handleWhatsAppStart(!0,o),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(o),await z(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await z(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),z(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:o=>e.handleRemoveWhatsAppAccount(o),workspaces:e.workspaces,workspacesLoading:e.workspacesLoading,workspacesError:e.workspacesError,addingWorkspace:e.addingWorkspace,newWorkspaceName:e.newWorkspaceName,newWorkspacePath:e.newWorkspacePath,workspaceSaving:e.workspaceSaving,workspaceRemoveConfirm:e.workspaceRemoveConfirm,newWorkspacePin:e.newWorkspacePin,onSetNewWorkspacePin:o=>{e.newWorkspacePin=o},onWorkspaceCreate:async(o,r)=>{const l=e.newWorkspacePin;await e.handleWorkspaceCreate(o,r),l.match(/^\d{4,6}$/)&&(await ky(e,o,l),e.newWorkspacePin="")},onWorkspaceRemove:o=>e.handleWorkspaceRemove(o),onSetAddingWorkspace:o=>{e.addingWorkspace=o},onSetNewWorkspaceName:o=>{e.newWorkspaceName=o},onSetNewWorkspacePath:o=>{e.newWorkspacePath=o},onSetWorkspaceRemoveConfirm:o=>{e.workspaceRemoveConfirm=o},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(o,r)=>e.handleWorkspaceRename(o,r),whatsappDmPolicy:(()=>{const r=J(e)?.whatsappAccountId;return(r?n.find(a=>a.accountId===r):n[0])?.dmPolicy??null})(),onWhatsAppDmToggle:async()=>{const r=J(e)?.whatsappAccountId,l=r?n.find(p=>p.accountId===r):n[0];if(!l)return;const c=l.dmPolicy!=null&&l.dmPolicy!=="disabled"?"disabled":"open",u=c==="open"?{dmPolicy:c,allowFrom:["*"]}:{dmPolicy:c};try{const p=await e.client.request("config.get"),x=(p.config?.channels?.whatsapp?.accounts??{})[l.accountId]?{channels:{whatsapp:{accounts:{[l.accountId]:u}}}}:{channels:{whatsapp:u}};await e.client.request("config.patch",{raw:JSON.stringify(x),baseHash:p.hash,note:`WhatsApp DM policy → ${c}`,skipRestart:!0}),await z(e,!1)}catch(p){console.error("DM toggle failed:",p)}},whatsappModel:(()=>{const o=J(e);if(!o)return null;const r=o.agents.find(p=>p.id.endsWith("-public")||p.id==="public");if(!r)return null;const a=e.configSnapshot?.config?.agents?.list;if(!Array.isArray(a))return null;const c=a.find(p=>p.id===r.id);return c?.model&&(typeof c.model=="string"?c.model:c.model.primary)?.trim()||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async o=>{const r=J(e);if(!r)return;const l=r.agents.find(a=>a.id.endsWith("-public")||a.id==="public");if(l)try{const a=await e.client.request("config.get"),u=a.config?.agents??{},p=Array.isArray(u.list)?[...u.list]:[],m=p.findIndex(w=>w.id===l.id);if(o)m>=0?p[m]={...p[m],model:o}:p.push({id:l.id,model:o});else if(m>=0){const{model:w,...x}=p[m];Object.keys(x).length<=1?p.splice(m,1):p[m]=x}const v=p.length>0?{agents:{list:p}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(v),baseHash:a.hash,note:`Public agent model → ${o||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(a){console.error("Model change failed:",a)}},whatsappThinkingLevel:(()=>{const o=J(e);if(!o)return null;const r=o.agents.find(u=>u.id.endsWith("-public")||u.id==="public");if(!r)return null;const a=e.configSnapshot?.config?.agents?.list;return Array.isArray(a)&&a.find(u=>u.id===r.id)?.thinkingLevel?.trim()||null})(),onWhatsAppThinkingChange:async o=>{const r=J(e);if(!r)return;const l=r.agents.find(a=>a.id.endsWith("-public")||a.id==="public");if(l)try{const a=await e.client.request("config.get"),u=a.config?.agents??{},p=Array.isArray(u.list)?[...u.list]:[],m=p.findIndex(x=>x.id===l.id),v=o==="off"?void 0:o;if(v)m>=0?p[m]={...p[m],thinkingLevel:v}:p.push({id:l.id,thinkingLevel:v});else if(m>=0){const{thinkingLevel:x,..._}=p[m];Object.keys(_).length<=1?p.splice(m,1):p[m]=_}const w=p.length>0?{agents:{list:p}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(w),baseHash:a.hash,note:`Public agent thinking → ${v||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(a){console.error("Thinking change failed:",a)}},whatsappGroupPolicy:(()=>{const r=e.configSnapshot?.config?.channels?.whatsapp,a=J(e)?.whatsappAccountId,c=r?.accounts??{};return(a?c[a]:void 0)?.groupPolicy??r?.groupPolicy??"allowlist"})(),whatsappGroupRequireMention:(()=>{const r=e.configSnapshot?.config?.channels?.whatsapp,a=J(e)?.whatsappAccountId,c=r?.accounts??{};return((a?c[a]:void 0)?.groups??r?.groups??{})["*"]?.requireMention!==!1})(),onWhatsAppGroupToggle:async()=>{const r=J(e)?.whatsappAccountId;try{const l=await e.client.request("config.get"),c=l.config?.channels?.whatsapp??{},u=c.accounts??{},p=r?u[r]:void 0,m=p?.groupPolicy??c.groupPolicy??"allowlist",v=m==="disabled"||m==="allowlist",w=v?"open":"disabled",x=v?{"*":{}}:void 0,_={groupPolicy:w};x&&(_.groups=x);const j=p?{channels:{whatsapp:{accounts:{[r]:_}}}}:{channels:{whatsapp:_}};await e.client.request("config.patch",{raw:JSON.stringify(j),baseHash:l.hash,note:`WhatsApp groups → ${w}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(l){console.error("Group toggle failed:",l)}},onWhatsAppGroupMentionChange:async o=>{const l=J(e)?.whatsappAccountId;try{const a=await e.client.request("config.get"),p=(a.config?.channels?.whatsapp??{}).accounts??{},m=l?p[l]:void 0,v={"*":{requireMention:o}},w=m?{channels:{whatsapp:{accounts:{[l]:{groups:v}}}}}:{channels:{whatsapp:{groups:v}}};await e.client.request("config.patch",{raw:JSON.stringify(w),baseHash:a.hash,note:`WhatsApp group mention → ${o?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(a){console.error("Group mention change failed:",a)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:s.configured,imessageRunning:s.running,imessageConnected:s.connected,imessageLastError:s.lastError,imessageSelfChatMode:s.selfChatMode,imessageCliPath:s.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:i,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const o=await e.client.request("config.get"),l=o.config?.bindings??[],a=J(e),u=a?.agents.find(w=>w.id.endsWith("-admin")||w.id==="admin")?.id??"admin",p=l.filter(w=>w.match?.channel!=="imessage"),m=[{agentId:u,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],v=[...p,...m];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:v}),baseHash:o.hash,note:"Enable iMessage (self-chat) for "+(a?.name??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([z(e,!0),we(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await z(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const o=await e.client.request("config.get"),a=(o.config?.bindings??[]).filter(c=>c.match?.channel!=="imessage");await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:a}),baseHash:o.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([z(e,!0),we(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const o=await e.client.request("config.get"),l=o.config?.bindings??[],a=J(e),u=a?.agents.find(v=>v.id.endsWith("-admin")||v.id==="admin")?.id??"admin",p=l.filter(v=>v.match?.channel!=="imessage"),m=[{agentId:u,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:[...p,...m]}),baseHash:o.hash,note:"Reassign iMessage to "+(a?.name??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([z(e,!0),we(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:o=>{e.infoModalOpen=o},onInfoModalClose:()=>{e.infoModalOpen=null},isMaster:e.accessState.master,apiKeyProviders:e.apiKeyProviders,apiKeyModalOpen:e.apiKeyModalOpen,apiKeyBusy:e.apiKeyBusy,apiKeyError:e.apiKeyError,apiKeySuccess:e.apiKeySuccess,onApiKeyModalOpen:()=>{e.apiKeyModalOpen=!0,e.apiKeyError=null,e.apiKeySuccess=null},onApiKeyModalClose:()=>{e.apiKeyModalOpen=!1,e.apiKeyError=null,e.apiKeySuccess=null},onApiKeySave:async(o,r)=>{e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await ga(e.client,o,r),e.apiKeySuccess=`${o} key saved`;try{e.apiKeyProviders=await Pi(e.client)}catch{}o==="anthropic"&&await e.handleAuthStatusCheck()}catch(l){e.apiKeyError=l instanceof Error?l.message:"Failed to save key"}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async o=>{e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Ay(e.client,o),e.apiKeySuccess=`${o} key removed`;try{e.apiKeyProviders=await Pi(e.client)}catch{}}catch(r){e.apiKeyError=r instanceof Error?r.message:"Failed to remove key"}finally{e.apiKeyBusy=!1}},authApiKeyMode:e.authApiKeyMode,authApiKeyInput:e.authApiKeyInput,authApiKeyBusy:e.authApiKeyBusy,authApiKeyError:e.authApiKeyError,onAuthApiKeyToggle:()=>{e.authApiKeyMode=!e.authApiKeyMode,e.authApiKeyError=null},onAuthApiKeyChange:o=>{e.authApiKeyInput=o},onAuthApiKeySubmit:async()=>{const o=e.authApiKeyInput.trim();if(o){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await ga(e.client,"anthropic",o),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(r){e.authApiKeyError=r instanceof Error?r.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{const o=e.selectedWorkspace??e.workspaces[0]?.name;return o?e.accessState.accounts.some(r=>r.id===o):!1})(),accountPinModalOpen:e.accountPinModalOpen,accountPinBusy:e.accountPinBusy,accountPinError:e.accountPinError,accountPinSuccess:e.accountPinSuccess,onAccountPinModalOpen:()=>{e.accountPinModalOpen=!0,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinModalClose:()=>{e.accountPinModalOpen=!1,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinSave:(o,r)=>{const l=e.selectedWorkspace??e.workspaces[0]?.name;l&&e.handleAccountPinSave(l,o,r)},wsProps:zy(e)})}if(e.filesPage){const t=qy(e);return Up({connected:e.connected,wsProps:Ut(e),loading:e.filesLoading,tree:e.filesTree,root:e.filesRoot,error:e.filesError,selectedPath:e.filesSelectedPath,selectedPaths:e.filesSelectedPaths,previewContent:e.filesPreviewContent,previewLoading:e.filesPreviewLoading,previewBinary:e.filesPreviewBinary,previewSize:e.filesPreviewSize,expandedDirs:e.filesExpandedDirs,message:e.filesMessage,uploadBusy:e.filesUploadBusy,reindexBusy:e.filesReindexBusy,memoryStatus:e.filesMemoryStatus,onRefresh:()=>on(e,t),onReindex:()=>By(e,t),onSelectFile:n=>Ly(e,n,t),onToggleSelectFile:n=>Ry(e,n,t),onToggleDir:n=>Fy(e,n),onUpload:(n,s)=>Oy(e,n,s,t),onDownload:n=>yc(e,n,t),onBulkDownload:()=>Iy(e,t),onDelete:n=>Dy(e,n,t),onMove:(n,s)=>vc(e,n,s,t),onMoveToDir:(n,s)=>Ny(e,n,s,t)})}if(e.browserPage)return Np({connected:e.connected,active:e.browserScreencastActive,loading:e.browserLoading,error:e.browserError,inputMode:e.browserInputMode,handoffPending:e.browserHandoffPending,handoffReason:e.browserHandoffReason,onStart:()=>$y(e),onStop:()=>Ey(e),onToggleInput:()=>Cy(e),onCompleteHandoff:()=>Ty(e),onCanvasMouseDown:t=>{const s=t.target.getBoundingClientRect(),o=Bn().translateCoordinates(t.clientX-s.left,t.clientY-s.top);ni(e,"mousePressed",o.x,o.y,t.button===2?"right":t.button===1?"middle":"left")},onCanvasMouseUp:t=>{const s=t.target.getBoundingClientRect(),o=Bn().translateCoordinates(t.clientX-s.left,t.clientY-s.top);ni(e,"mouseReleased",o.x,o.y)},onCanvasMouseMove:t=>{const n=Bn();if(n.shouldThrottleMouseMove())return;const i=t.target.getBoundingClientRect(),o=n.translateCoordinates(t.clientX-i.left,t.clientY-i.top);ni(e,"mouseMoved",o.x,o.y)},onCanvasKeyDown:t=>{let n=0;t.altKey&&(n|=1),t.ctrlKey&&(n|=2),t.metaKey&&(n|=4),t.shiftKey&&(n|=8),si(e,"keyDown",t.key,{code:t.code,modifiers:n||void 0}),t.key.length===1&&si(e,"char",t.key,{text:t.key})},onCanvasKeyUp:t=>{si(e,"keyUp",t.key,{code:t.code})}});if(e.adminsPage){const t=jy(e),n=Hy(e);return nh({connected:e.connected,wsProps:Ut(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>fs(e,t),onAdd:s=>{kc(e,s,t,n).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:s=>Sc(e,s,t,n),onNewPhoneChange:s=>e.handleAdminsNewPhoneChange(s)})}if(e.customersPage){const t=Gy(e);return rh({connected:e.connected,wsProps:Ut(e),loading:e.customersLoading,saving:e.customersSaving,records:e.customersRecords,error:e.customersError,searchQuery:e.customersSearchQuery,editingId:e.customersEditingId,showAddForm:e.customersShowAddForm,newRecordPhone:e.customersNewPhone,newRecordName:e.customersNewName,onSearch:n=>e.customersSearchQuery=n,onSearchSubmit:()=>et(e,t),onAdd:(n,s)=>Ac(e,n,s,t),onDelete:n=>xc(e,n,t),onSetField:(n,s,i)=>$c(e,n,s,i,t),onDeleteField:(n,s)=>Ec(e,n,s,t),onToggleExpand:n=>{e.customersEditingId=e.customersEditingId===n?null:n},onShowAddForm:()=>e.customersShowAddForm=!0,onCancelAddForm:()=>{e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName=""},onNewRecordPhoneChange:n=>e.handleCustomersNewPhoneChange(n),onNewRecordNameChange:n=>e.handleCustomersNewNameChange(n),onRefresh:()=>et(e,t)})}if(e.chatPage){const t=e.connected?null:"Disconnected from gateway.",n=Yy(e),s=e.chatAvatarUrl??n??null;return Km({connected:e.connected,wsProps:Ut(e),sessionKey:e.sessionKey,onSessionKeyChange:i=>{e.sessionKey=i,e.chatMessage="",e.chatAttachments=[],e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:i,lastActiveSessionKey:i}),e.loadAssistantIdentity(),Ce(e),fi(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:i=>{wn(e,e.sessionKey,{model:i}).then(()=>{Ce(e)})},onThinkingLevelChange:i=>{wn(e,e.sessionKey,{thinkingLevel:i==="off"?null:i}).then(()=>{Ce(e)})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,onVerboseChange:i=>{wn(e,e.sessionKey,{verboseLevel:i==="off"?null:i}).then(()=>{Ce(e)})},onFillerChange:i=>{wn(e,e.sessionKey,{fillerEnabled:i}).then(()=>{Ce(e)})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:s,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,disabledReason:t,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>(e.resetToolStream(),Promise.all([Ce(e),fi(e)])),onToggleFocusMode:()=>{},onChatScroll:i=>e.handleChatScroll(i),nearBottom:e.chatUserNearBottom,onDraftChange:i=>e.chatMessage=i,attachments:e.chatAttachments,onAttachmentsChange:i=>e.chatAttachments=i,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:i=>e.removeQueuedMessage(i),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:i=>e.handleOpenSidebar(i),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:i=>e.handleSplitRatioChange(i),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?yy({connected:e.connected,wsProps:Ut(e),activeTab:e.advancedTab,onTabChange:t=>{e.advancedTab=t,t==="cron"&&e.loadCron(),t==="skills"&&wt(e,{clearMessages:!0}),t==="logs"&&(e.logsSubTab==="session"?gt(e,{reset:!0}):qt(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:e.channelsSnapshot?.channelMeta?.length?e.channelsSnapshot.channelMeta.map(t=>t.id):e.channelsSnapshot?.channelOrder??[],channelLabels:e.channelsSnapshot?.channelLabels??{},channelMeta:e.channelsSnapshot?.channelMeta??[],agentIds:J(e)?.agents?.map(n=>n.id)??[],runsJobId:e.cronRunsJobId,runs:e.cronRuns,newEventModalOpen:e.cronNewEventModal,onNewEventModalOpen:()=>{e.cronNewEventModal=!0},onNewEventModalClose:()=>{e.cronNewEventModal=!1},detailJobId:e.cronDetailJobId,onDetailOpen:t=>{e.cronDetailJobId=t.id,ci(e,t.id)},onDetailClose:()=>{e.cronDetailJobId=null},onFormChange:t=>e.cronForm={...e.cronForm,...t},onRefresh:()=>e.loadCron(),onAdd:()=>{ld(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(t,n)=>cd(e,t,n),onRun:t=>ud(e,t),onRemove:t=>dd(e,t),onLoadRuns:t=>ci(e,t)},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,onFilterChange:t=>e.skillsFilter=t,onRefresh:()=>wt(e,{clearMessages:!0}),onToggle:(t,n)=>Zd(e,t,n),onEdit:(t,n)=>Xd(e,t,n),onSaveKey:t=>Jd(e,t),onInstall:(t,n,s)=>ep(e,t,n,s)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:t=>{e.logsSubTab=t,t==="session"?gt(e,{reset:!0}):qt(e,{reset:!0})},sessionLogsProps:{loading:e.sessionLogsLoading,error:e.sessionLogsError,entries:e.sessionLogsEntries,agents:e.sessionLogsAgents,filterText:e.sessionLogsFilterText,typeFilters:e.sessionLogsTypeFilters,agentFilters:e.sessionLogsAgentFilters,autoFollow:e.sessionLogsAutoFollow,full:e.sessionLogsFull,onFilterTextChange:t=>e.sessionLogsFilterText=t,onTypeToggle:(t,n)=>{const s=e;s.sessionLogsTypeFilters={...s.sessionLogsTypeFilters,[t]:n}},onAgentToggle:(t,n)=>{const s=e;s.sessionLogsAgentFilters={...s.sessionLogsAgentFilters,[t]:n}},onToggleAutoFollow:t=>e.sessionLogsAutoFollow=t,onToggleFull:t=>{e.sessionLogsFull=t,gt(e,{reset:!0})},onRefresh:()=>{gt(e,{reset:!0})},onExport:(t,n)=>e.exportSessionLogs(t,n),onScroll:t=>e.handleSessionLogsScroll(t)},loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,truncated:e.logsTruncated,onFilterTextChange:t=>e.logsFilterText=t,onLevelToggle:(t,n)=>{e.logsLevelFilters={...e.logsLevelFilters,[t]:n}},onToggleAutoFollow:t=>e.logsAutoFollow=t,onRefresh:()=>qt(e,{reset:!0}),onExport:(t,n)=>e.exportSessionLogs(t,n),onScroll:t=>e.handleLogsScroll(t)}}):(window.location.replace("/chat"),d``)}const tv={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},nv={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",to:"",timeoutSeconds:"",postToMainPrefix:""};async function sv(e){if(!(!e.client||!e.connected)&&!e.agentsLoading){e.agentsLoading=!0,e.agentsError=null;try{const t=await e.client.request("agents.list",{});t&&(e.agentsList=t)}catch(t){e.agentsError=String(t)}finally{e.agentsLoading=!1}}}async function rn(e){if(!(!e.client||!e.connected)&&!e.workspacesLoading){e.workspacesLoading=!0,e.workspacesError=null;try{const t=await e.client.request("workspaces.list",{});e.workspaces=t.workspaces}catch(t){e.workspacesError=String(t)}finally{e.workspacesLoading=!1}}}async function iv(e,t){if(!e.client||!e.connected||e.workspaceSaving)return;const n=t.name.trim();if(!n){e.workspacesError="Account name is required.";return}e.workspaceSaving=!0,e.workspacesError=null;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const i=s.hash;if(!i){e.workspacesError="Config hash missing; reload and retry.";return}const o={name:n,baseHash:i,whatsappAccountName:n};t.workspacePath?.trim()&&(o.workspaceDir=t.workspacePath.trim());const r=await e.client.request("workspaces.create",o);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await rn(e),t.onCreated?.(r)}catch(s){e.workspacesError=String(s)}finally{e.workspaceSaving=!1}}async function ov(e,t){if(!(!e.client||!e.connected)&&!e.workspaceSaving){e.workspaceSaving=!0,e.workspacesError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const s=n.hash;if(!s){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.remove",{name:t,baseHash:s}),e.workspaceRemoveConfirm=null,await rn(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function rv(e,t,n){if(!(!e.client||!e.connected)){e.workspacesError=null;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const i=s.hash;if(!i){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.rename",{name:t,displayName:n,baseHash:i}),await rn(e)}catch(s){e.workspacesError=String(s)}}}const Ln=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:iv,loadWorkspaces:rn,removeWorkspace:ov,renameWorkspace:rv},Symbol.toStringTag,{value:"Module"})),Tc={WEBCHAT_UI:"webchat-ui",CONTROL_UI:"taskmaster-control-ui",SETUP_UI:"setup-ui",WEBCHAT:"webchat",CLI:"cli",GATEWAY_CLIENT:"gateway-client",MACOS_APP:"taskmaster-macos",IOS_APP:"taskmaster-ios",ANDROID_APP:"taskmaster-android",NODE_HOST:"node-host",TEST:"test",FINGERPRINT:"fingerprint",PROBE:"taskmaster-probe"},ma=Tc,Li={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(Tc));new Set(Object.values(Li));function av(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),s=e.token??"",i=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),s];return t==="v2"&&i.push(e.nonce??""),i.join("|")}const lv=4008;class cv{constructor(t){this.opts=t,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800}start(){this.closed=!1,this.connect()}stop(){this.closed=!0,this.ws?.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){return this.ws?.readyState===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.onopen=()=>this.queueConnect(),this.ws.onmessage=t=>this.handleMessage(String(t.data??"")),this.ws.onclose=t=>{const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),this.opts.onClose?.({code:t.code,reason:n}),this.scheduleReconnect()},this.ws.onerror=()=>{})}scheduleReconnect(){if(this.closed)return;const t=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),t)}flushPending(t){for(const[,n]of this.pending)n.reject(t);this.pending.clear()}async sendConnect(){if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=typeof crypto<"u"&&!!crypto.subtle,n=["operator.admin","operator.approvals","operator.pairing"],s="operator";let i=null,o=!1,r=this.opts.token;if(t){i=await Kd();const u=Hd({deviceId:i.deviceId,role:s})?.token;r=u??this.opts.token,o=!!(u&&this.opts.token)}const l=r||this.opts.password?{token:r,password:this.opts.password}:void 0;let a;if(t&&i){const u=Date.now(),p=this.connectNonce??void 0,m=av({deviceId:i.deviceId,clientId:this.opts.clientName??ma.CONTROL_UI,clientMode:this.opts.mode??Li.WEBCHAT,role:s,scopes:n,signedAtMs:u,token:r??null,nonce:p}),v=await zd(i.privateKey,m);a={id:i.deviceId,publicKey:i.publicKey,signature:v,signedAt:u,nonce:p}}const c={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??ma.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Li.WEBCHAT,instanceId:this.opts.instanceId},role:s,scopes:n,device:a,caps:[],auth:l,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",c).then(u=>{u?.auth?.deviceToken&&i&&qd({deviceId:i.deviceId,role:u.auth.role??s,token:u.auth.deviceToken,scopes:u.auth.scopes??[]}),this.backoffMs=800,this.opts.onHello?.(u)}).catch(()=>{o&&i&&Gd({deviceId:i.deviceId,role:s}),this.ws?.close(lv,"connect failed")})}handleMessage(t){let n;try{n=JSON.parse(t)}catch{return}const s=n;if(s.type==="event"){const i=n;if(i.event==="connect.challenge"){const r=i.payload,l=r&&typeof r.nonce=="string"?r.nonce:null;l&&(this.connectNonce=l,this.sendConnect());return}const o=typeof i.seq=="number"?i.seq:null;o!==null&&(this.lastSeq!==null&&o>this.lastSeq+1&&this.opts.onGap?.({expected:this.lastSeq+1,received:o}),this.lastSeq=o);try{this.opts.onEvent?.(i)}catch(r){console.error("[gateway] event handler error:",r)}return}if(s.type==="res"){const i=n,o=this.pending.get(i.id);if(!o)return;this.pending.delete(i.id),i.ok?o.resolve(i.payload):o.reject(new Error(i.error?.message??"request failed"));return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const s=Ui(),i={type:"req",id:s,method:t,params:n},o=new Promise((r,l)=>{this.pending.set(s,{resolve:a=>r(a),reject:l})});return this.ws.send(JSON.stringify(i)),o}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function Ri(e){return typeof e=="object"&&e!==null}function uv(e){if(!Ri(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Ri(n))return null;const s=typeof n.command=="string"?n.command.trim():"";if(!s)return null;const i=typeof e.createdAtMs=="number"?e.createdAtMs:0,o=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!i||!o?null:{id:t,request:{command:s,cwd:typeof n.cwd=="string"?n.cwd:null,host:typeof n.host=="string"?n.host:null,security:typeof n.security=="string"?n.security:null,ask:typeof n.ask=="string"?n.ask:null,agentId:typeof n.agentId=="string"?n.agentId:null,resolvedPath:typeof n.resolvedPath=="string"?n.resolvedPath:null,sessionKey:typeof n.sessionKey=="string"?n.sessionKey:null},createdAtMs:i,expiresAtMs:o}}function dv(e){if(!Ri(e))return null;const t=typeof e.id=="string"?e.id.trim():"";return t?{id:t,decision:typeof e.decision=="string"?e.decision:null,resolvedBy:typeof e.resolvedBy=="string"?e.resolvedBy:null,ts:typeof e.ts=="number"?e.ts:null}:null}function Cc(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function pv(e,t){const n=Cc(e).filter(s=>s.id!==t.id);return n.push(t),n}function ya(e,t){return Cc(e).filter(n=>n.id!==t)}async function _c(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),s=n?{sessionKey:n}:{};try{const i=await e.client.request("agent.identity.get",s);if(!i)return;const o=ai(i);e.assistantName=o.name,e.assistantAvatar=o.avatar,e.assistantAgentId=o.agentId??null}catch{}}const es="taskmaster_update_pending";async function hv(e){if(!(!e.client||!e.connected)&&!e.updateChecking){e.updateChecking=!0,e.updateMessage=null,e.requestUpdate?.();try{const t=await e.client.request("update.status",{});e.currentVersion=t.current,e.latestVersion=t.latest,e.updateAvailable=t.updateAvailable,e.updateMessage=t.updateAvailable?`v${t.latest} available`:"Up to date"}catch(t){e.updateMessage=`Check failed: ${String(t)}`,e.updateAvailable=null}finally{e.updateChecking=!1,e.requestUpdate?.()}}}async function fv(e){if(!(!e.client||e.updateRunning)){e.updateRunning=!0,e.updateMessage="Starting update...",e.updateProgressSteps=[],e.updateLastResult=null,e.requestUpdate?.();try{localStorage.setItem(es,String(Date.now()))}catch{}try{const t=await e.client.request("update.run",{restartDelayMs:2e3,note:"Update from setup page"});if(t.ok&&t.result.status==="ok")e.updateMessage="Updated — restarting gateway...",e.requestUpdate?.();else if(t.ok&&t.result.status==="skipped")Qt(),e.updateMessage=t.result.reason||"Update skipped",e.updateRunning=!1,e.requestUpdate?.();else throw Qt(),new Error(t.result.reason||"Update failed")}catch(t){Qt(),e.updateMessage=`Update failed: ${String(t)}`,e.updateRunning=!1,e.updateProgressSteps=[],e.requestUpdate?.()}}}function gv(e,t){const n=t.phase;if(n==="step-start"){const s=t.name,i=t.index,o=t.total;e.updateMessage=`Updating: ${s} (${i+1}/${o})`;const r=e.updateProgressSteps.find(l=>l.index===i);r?(r.status="running",r.name=s):e.updateProgressSteps=[...e.updateProgressSteps,{name:s,index:i,total:o,status:"running"}],e.requestUpdate?.()}else if(n==="step-done"){const s=t.name,i=t.index,o=t.total,r=t.ok,l=t.durationMs,a=e.updateProgressSteps.find(c=>c.index===i);a?(a.status=r?"done":"failed",a.durationMs=l):e.updateProgressSteps=[...e.updateProgressSteps,{name:s,index:i,total:o,status:r?"done":"failed",durationMs:l}],e.updateMessage=r?`Updating: ${s} done (${i+1}/${o})`:`Update step failed: ${s}`,e.requestUpdate?.()}else if(n==="complete"){if(t.status==="ok")e.updateMessage="Update complete — restarting gateway...";else{const i=t.reason;e.updateMessage=i?`Update failed: ${i}`:"Update failed",e.updateRunning=!1,Qt()}e.requestUpdate?.()}}async function mv(e){if(!e.client||!e.connected)return;const t=vv();Qt();try{const n=await e.client.request("update.lastResult",{});if(!n.ok||!n.result)return;const s=5*6e4,i=Date.now()-n.result.ts<s;if(!t&&!i)return;if(e.updateLastResult=n.result,e.currentVersion=n.result.currentVersion,e.updateAvailable=!1,n.result.status==="ok"){const o=n.result.before?.version,r=n.result.after?.version??n.result.currentVersion;e.updateMessage=o?`Updated: v${o} → v${r}`:`Updated to v${r}`}else{const o=n.result.reason??n.result.failedStep?.name??"unknown error";e.updateMessage=`Update failed: ${o}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],e.requestUpdate?.()}}function yv(e){e.updateLastResult=null,e.requestUpdate?.()}function vv(){try{const e=localStorage.getItem(es);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(es),!1):!0:!1}catch{return!1}}function Qt(){try{localStorage.removeItem(es)}catch{}}function ii(e,t){const n=(e??"").trim(),s=t.mainSessionKey?.trim();if(!s)return n;if(!n)return s;const i=t.mainKey?.trim()||"main",o=t.defaultAgentId?.trim();return n==="main"||n===i||o&&(n===`agent:${o}:main`||n===`agent:${o}:${i}`)?s:n}function bv(e,t){if(!t?.mainSessionKey)return;const n=ii(e.sessionKey,t),s=ii(e.settings.sessionKey,t),i=ii(e.settings.lastActiveSessionKey,t),o=n||s||e.sessionKey,r={...e.settings,sessionKey:s||o,lastActiveSessionKey:i||o},l=r.sessionKey!==e.settings.sessionKey||r.lastActiveSessionKey!==e.settings.lastActiveSessionKey;o!==e.sessionKey&&(e.sessionKey=o),l&&Ie(e,r)}function Te(e){e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;const t=e.setup||e.filesPage||e.browserPage?"setup-ui":"taskmaster-control-ui";e.client?.stop(),e.client=new cv({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:t,mode:"webchat",onHello:n=>{e.connected=!0,e.lastError=null,e.hello=n,Sv(e,n),e.handleAccessCheck(),mv(e),_c(e),sv(e),(e.chatPage||e.setup)&&Av(e),Xi(e,{quiet:!0}),Yi(e,{quiet:!0}),rn(e).then(()=>{e.initWorkspaceSelection()}),e.setup&&(we(e),xv(e)),oo(e)},onClose:({code:n,reason:s})=>{e.connected=!1,n!==1012&&(e.lastError=`disconnected (${n}): ${s||"no reason"}`)},onEvent:n=>wv(e,n),onGap:({expected:n,received:s})=>{e.lastError=`event gap detected (expected seq ${n}, got ${s}); refresh recommended`}}),e.client.start()}function wv(e,t){try{kv(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function kv(e,t){if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),e.tab==="debug"&&(e.eventLog=e.eventLogBuffer),t.event==="agent"){if(e.onboarding)return;Qu(e,t.payload);return}if(t.event==="chat"){const n=t.payload;n?.sessionKey&&dl(e,n.sessionKey);const s=Da(e,n);(s==="final"||s==="error"||s==="aborted")&&(Ki(e),$p(e)),s==="final"&&Ce(e);return}if(t.event==="presence"){const n=t.payload;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"&&e.tab==="cron"&&ro(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&Yi(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=uv(t.payload);if(n){e.execApprovalQueue=pv(e.execApprovalQueue,n),e.execApprovalError=null;const s=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=ya(e.execApprovalQueue,n.id)},s)}return}if(t.event==="browser.screencast.frame"){_y(e,t.payload);return}if(t.event==="browser.handoff"){My(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){Py(e);return}if(t.event==="exec.approval.resolved"){const n=dv(t.payload);n&&(e.execApprovalQueue=ya(e.execApprovalQueue,n.id));return}if(t.event==="update.progress"){gv(e,t.payload);return}}function Sv(e,t){const n=t.snapshot;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n?.health&&(e.debugHealth=n.health),n?.sessionDefaults&&bv(e,n.sessionDefaults)}async function Av(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("models.list",{});Array.isArray(t?.models)&&(e.chatModelCatalog=t.models)}catch{}}async function xv(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await Pi(e.client)}catch{}}function $v(e){e.basePath=hp();const t=De();if(Pp(t.accentColor),window.scrollTo(0,0),e.setup){document.title=`${t.name} Setup`,Te(e);return}if(e.filesPage){document.title=`${t.name} Files`,Te(e);return}if(e.browserPage){document.title=`${t.name} Browser`,Te(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,Te(e);return}if(e.customersPage){document.title=`${t.name} Customers`,Te(e);return}if(e.chatPage){document.title=`${t.name} Chat`,Te(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,Te(e);return}yp(e,!0),fp(e),gp(e),window.addEventListener("popstate",e.popStateHandler),up(e),Te(e),lp(e),e.tab==="logs"&&(e.logsSubTab==="session"?to(e):Ji(e)),e.tab==="debug"&&so(e)}function Ev(e){nd(e)}function Tv(e){window.removeEventListener("popstate",e.popStateHandler),cp(e),eo(e),no(e),io(e),mp(e),e.topbarObserver?.disconnect(),e.topbarObserver=null}function Cv(e,t){if(e.filesPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleFilesLoad&&e.handleFilesLoad(),e.adminsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdminsLoad&&e.handleAdminsLoad(),e.customersPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleCustomersLoad&&e.handleCustomersLoad(),e.chatPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleChatLoad&&e.handleChatLoad(),e.advancedPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdvancedLoad&&e.handleAdvancedLoad(),e.setup&&e.connected){const n=t.has("connected")&&t.get("connected")===!1;n&&e.handleLicenseStatusCheck&&e.licenseValid===null&&!e.licenseBusy&&e.handleLicenseStatusCheck(),n&&e.handleUpdateCheck&&e.handleUpdateCheck();const s=t.has("setupStep")&&e.setupStep==="auth";(n||s)&&e.setupStep==="auth"&&(e.authConnected===!0?e.setupStep="whatsapp":e.handleAuthStatusCheck&&e.authConnected===null&&!e.authBusy&&e.handleAuthStatusCheck()),e.setupStep==="whatsapp"&&t.has("setupStep")&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(o=>{e.channelsSnapshot=o,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1})),t.has("whatsappLoginConnected")&&e.whatsappLoginConnected===!0&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(i=>{e.channelsSnapshot=i,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1}))}if(e.tab==="chat"&&!e.advancedPage&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),s=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;en(e,n||s||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&Ba(e,t.has("tab")||t.has("logsAutoFollow"))}function _v(e){const t={name:e?.name??"",displayName:e?.displayName??"",about:e?.about??"",picture:e?.picture??"",banner:e?.banner??"",website:e?.website??"",nip05:e?.nip05??"",lud16:e?.lud16??""};return{values:t,original:{...t},saving:!1,importing:!1,error:null,success:null,fieldErrors:{},showAdvanced:!!(e?.banner||e?.website||e?.nip05||e?.lud16)}}async function Mv(e,t,n){await zi(e,t,n),await z(e,!0)}async function Pv(e,t){await Wa(e,t),await z(e,!0)}async function Lv(e,t){await Ka(e,t),await z(e,!0)}async function Rv(e,t){await za(e,t)}async function Iv(e,t){await ja(e,t)}async function Nv(e){await od(e),await we(e),await z(e,!0)}async function Ov(e){await we(e),await z(e,!0)}function Dv(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[s,...i]=n.split(":");if(!s||i.length===0)continue;const o=s.trim(),r=i.join(":").trim();o&&r&&(t[o]=r)}return t}function Mc(e){return(e.channelsSnapshot?.channelAccounts?.nostr??[])[0]?.accountId??e.nostrProfileAccountId??"default"}function Pc(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function Bv(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=_v(n??void 0)}function Fv(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function Uv(e,t,n){const s=e.nostrProfileFormState;s&&(e.nostrProfileFormState={...s,values:{...s.values,[t]:n},fieldErrors:{...s.fieldErrors,[t]:""}})}function Wv(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function Kv(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Mc(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const s=await fetch(Pc(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const o=i?.error??`Profile update failed (${s.status})`;e.nostrProfileFormState={...t,saving:!1,error:o,success:null,fieldErrors:Dv(i?.details)};return}if(!i.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await z(e,!0)}catch(s){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(s)}`,success:null}}}async function zv(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Mc(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const s=await fetch(Pc(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const a=i?.error??`Profile import failed (${s.status})`;e.nostrProfileFormState={...t,importing:!1,error:a,success:null};return}const o=i.merged??i.imported??null,r=o?{...t.values,...o}:t.values,l=!!(r.banner||r.website||r.nip05||r.lud16);e.nostrProfileFormState={...t,importing:!1,values:r,error:null,success:i.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:l},i.saved&&await z(e,!0)}catch(s){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(s)}`,success:null}}}async function jv(e){if(e.client){e.authBusy=!0,e.authMessage=null;try{const t=await e.client.request("auth.status",{});e.authConnected=t.connected,e.authExpiresIn=t.expiresIn??null,e.authMessage=t.message??null,t.connected&&(e.setupStep="whatsapp")}catch(t){e.authConnected=!1,e.authMessage=t instanceof Error?t.message:"Failed to check auth status"}finally{e.authBusy=!1}}}async function Hv(e){if(e.client){e.authBusy=!0,e.authMessage=null,e.authUrl=null,e.authConnected=null;try{const t=await e.client.request("auth.oauth.start",{provider:"anthropic"});e.authUrl=t.authUrl,e.authMessage=t.message??"Sign in with your Claude Pro account"}catch(t){e.authConnected=!1,e.authMessage=t instanceof Error?t.message:"Failed to start auth flow"}finally{e.authBusy=!1}}}async function qv(e,t){if(e.client){e.authBusy=!0,e.authMessage="Verifying code...";try{await e.client.request("auth.oauth.code",{code:t});const n=await e.client.request("auth.oauth.wait",{timeoutMs:3e4});n.connected?(e.authConnected=!0,e.authMessage=n.message??"Connected to Claude!",e.authUrl=null,e.authCodeInput="",setTimeout(()=>{e.setupStep="whatsapp"},1500)):e.authMessage=n.message??"Still waiting for authorization..."}catch(n){e.authConnected=!1,e.authMessage=n instanceof Error?n.message:"Verification failed"}finally{e.authBusy=!1}}}function Gv(e,t){e.authCodeInput=t}function Vv(e){e.setupStep="whatsapp"}async function Qv(e){if(e.client){e.licenseBusy=!0,e.licenseMessage=null;try{const t=await e.client.request("license.status",{});e.licenseDeviceId=t.deviceId??null,e.licenseStoredKey=t.key??null,t.licensed?(e.licenseValid=!0,e.licenseTier=t.tier??null,e.setupStep="auth"):(e.licenseValid=null,e.setupStep="license")}catch(t){const n=t instanceof Error?t.message:String(t);n.includes("unknown method")?(e.licenseValid=!0,e.setupStep="auth"):(e.licenseValid=null,e.licenseMessage=n,e.setupStep="license")}finally{e.licenseBusy=!1}}}async function Yv(e){if(e.client&&e.licenseKey.trim()){e.licenseBusy=!0,e.licenseMessage=null,e.licenseValid=null;try{const t=await e.client.request("license.activate",{key:e.licenseKey.trim()});t.valid?(e.licenseValid=!0,e.licenseMessage=t.message??"License activated",e.licenseTier=t.tier??null,setTimeout(()=>{e.setupStep="auth"},1500)):(e.licenseValid=!1,e.licenseMessage=t.message??"Invalid license key")}catch(t){e.licenseValid=!1,e.licenseMessage=t instanceof Error?t.message:"Activation failed"}finally{e.licenseBusy=!1}}}async function Xv(e){if(e.client){e.licenseBusy=!0;try{await e.client.request("license.remove",{}),e.licenseValid=null,e.licenseKey="",e.licenseTier=null,e.licenseMessage=null,e.setupStep="license"}catch(t){e.licenseMessage=t instanceof Error?t.message:"Failed to remove license"}finally{e.licenseBusy=!1}}}function Zv(e,t){e.licenseKey=t}async function Jv(e){if(!(!e.client||!e.connected)&&!e.gatewayHealthLoading){e.gatewayHealthLoading=!0,e.requestUpdate?.();try{const t=await e.client.request("health",{probe:!0});e.gatewayHealthy=t.ok===!0,e.gatewayHealthMessage=t.ok?`Healthy${t.durationMs?` (${t.durationMs}ms)`:""}`:"Unhealthy"}catch(t){e.gatewayHealthy=!1,e.gatewayHealthMessage=`Error: ${String(t)}`}finally{e.gatewayHealthLoading=!1,e.requestUpdate?.()}}}async function eb(e){if(!(!e.client||e.gatewayRestartBusy)){e.gatewayRestartBusy=!0,e.gatewayHealthMessage="Restarting...",e.requestUpdate?.();try{const t=await e.client.request("gateway.restart",{reason:"Manual restart from setup page",delayMs:1e3});if(t.ok&&t.restart?.ok)e.gatewayHealthMessage="Restarting...",setTimeout(()=>{window.location.reload()},3e3);else throw new Error("Restart not scheduled")}catch(t){e.gatewayHealthMessage=`Restart failed: ${String(t)}`,e.gatewayRestartBusy=!1,e.requestUpdate?.()}}}var tb=Object.defineProperty,nb=Object.getOwnPropertyDescriptor,f=(e,t,n,s)=>{for(var i=s>1?void 0:s?nb(t,n):t,o=e.length-1,r;o>=0;o--)(r=e[o])&&(i=(s?r(t,n,i):r(i))||i);return s&&i&&tb(t,n,i),i};const oi=yu();function sb(){if(!window.location.search)return!1;const t=new URLSearchParams(window.location.search).get("onboarding");if(!t)return!1;const n=t.trim().toLowerCase();return n==="1"||n==="true"||n==="yes"||n==="on"}function ib(){const e=window.location.pathname;if(e==="/setup"||e.endsWith("/setup"))return!0;if(!window.location.search)return!1;const n=new URLSearchParams(window.location.search).get("setup");if(!n)return!1;const s=n.trim().toLowerCase();return s==="1"||s==="true"||s==="yes"||s==="on"}function ob(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function rb(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function ab(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function lb(){const e=window.location.pathname;return e==="/customers"||e.endsWith("/customers")}function cb(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function ub(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let h=class extends mt{constructor(){super(...arguments),this.settings=Ms(),this.password="",this.tab="chat",this.onboarding=sb(),this.setup=ib(),this.filesPage=ob(),this.browserPage=rb(),this.adminsPage=ab(),this.customersPage=lb(),this.chatPage=cb(),this.advancedPage=ub(),this.advancedTab="cron",this.connected=!1,this.accessState=hc,this.theme=this.settings.theme??"system",this.themeResolved="dark",this.hello=null,this.lastError=null,this.eventLog=[],this.eventLogBuffer=[],this.toolStreamSyncTimer=null,this.sidebarCloseTimer=null,this.assistantName=oi.name,this.assistantAvatar=oi.avatar,this.assistantAgentId=oi.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatToolMessages=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.chatModelProvider=null,this.chatModel=null,this.chatModelCatalog=[],this.chatVerboseLevel=null,this.chatFillerEnabled=null,this.chatQueue=[],this.chatAttachments=[],this.sidebarOpen=!1,this.sidebarContent=null,this.sidebarError=null,this.splitRatio=this.settings.splitRatio,this.nodesLoading=!1,this.nodes=[],this.devicesLoading=!1,this.devicesError=null,this.devicesList=null,this.execApprovalsLoading=!1,this.execApprovalsSaving=!1,this.execApprovalsDirty=!1,this.execApprovalsSnapshot=null,this.execApprovalsForm=null,this.execApprovalsSelectedAgent=null,this.execApprovalsTarget="gateway",this.execApprovalsTargetNodeId=null,this.execApprovalQueue=[],this.execApprovalBusy=!1,this.execApprovalError=null,this.configLoading=!1,this.configRaw=`{
2780
+ `}const $o="taskmaster-access-session",hc={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function fc(){try{return localStorage.getItem($o)}catch{return null}}function gc(e){try{localStorage.setItem($o,e)}catch{}}function yy(){try{localStorage.removeItem($o)}catch{}}async function ga(e){if(e.client)try{const t=fc(),n=await e.client.request("access.status",{token:t});e.accessState={...e.accessState,checked:!0,hasPins:n.hasPins,hasMasterPin:n.hasMasterPin,accounts:n.accounts??[],authenticated:n.authenticated,workspace:n.workspace,master:n.master,error:null}}catch{e.accessState={...e.accessState,checked:!0,hasPins:!1,hasMasterPin:!1,accounts:[],authenticated:!0,error:null}}}async function vy(e,t,n){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const s=await e.client.request("access.verify",{account:t,pin:n});s.ok&&s.token?(gc(s.token),e.accessState={...e.accessState,authenticated:!0,workspace:s.workspace??null,master:s.master??!1,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:s.message??"Incorrect PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to verify PIN"}}}}async function by(e,t){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const n=await e.client.request("access.setMasterPin",{pin:t});n.ok&&n.token?(gc(n.token),e.accessState={...e.accessState,checked:!0,hasPins:!0,hasMasterPin:!0,authenticated:!0,workspace:null,master:!0,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:"Failed to set PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to set PIN"}}}}async function wy(e,t,n){if(!e.client)return!1;try{return(await e.client.request("access.setAccountPin",{workspace:t,pin:n})).ok}catch{return!1}}async function ky(e){const t=fc();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}yy(),e.accessState={...hc,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}async function Pi(e){return(await e.request("apikeys.list")).providers??[]}async function ma(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function Sy(e,t){await e.request("apikeys.remove",{provider:t})}class Ay{constructor(){this.canvas=null,this.ctx=null,this.img=new Image,this.pendingFrame=null,this.rafId=null,this.deviceWidth=1280,this.deviceHeight=720,this.lastMouseMoveAt=0,this.MOUSE_THROTTLE_MS=30}attach(t){this.canvas=t,this.ctx=t.getContext("2d")}detach(){this.rafId!=null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.canvas=null,this.ctx=null,this.pendingFrame=null}updateFrame(t,n){n?.deviceWidth&&(this.deviceWidth=n.deviceWidth),n?.deviceHeight&&(this.deviceHeight=n.deviceHeight),this.pendingFrame=t,this.rafId==null&&(this.rafId=requestAnimationFrame(()=>this.renderFrame()))}renderFrame(){this.rafId=null;const t=this.pendingFrame;!t||!this.canvas||!this.ctx||(this.pendingFrame=null,this.img.onload=()=>{!this.canvas||!this.ctx||((this.canvas.width!==this.img.width||this.canvas.height!==this.img.height)&&(this.canvas.width=this.img.width,this.canvas.height=this.img.height),this.ctx.drawImage(this.img,0,0))},this.img.src=`data:image/jpeg;base64,${t}`)}translateCoordinates(t,n){if(!this.canvas)return{x:t,y:n};const s=this.canvas.getBoundingClientRect(),i=this.canvas.width/s.width,o=this.canvas.height/s.height,r=this.deviceWidth/this.canvas.width,l=this.deviceHeight/this.canvas.height;return{x:Math.round(t*i*r),y:Math.round(n*o*l)}}shouldThrottleMouseMove(){const t=performance.now();return t-this.lastMouseMoveAt<this.MOUSE_THROTTLE_MS?!0:(this.lastMouseMoveAt=t,!1)}getDeviceDimensions(){return{width:this.deviceWidth,height:this.deviceHeight}}}let ti=null;function Bn(){return ti||(ti=new Ay),ti}function Eo(e){return e instanceof Error?e.message:String(e)}async function xy(e){if(!(!e.client||!e.connected)){e.browserLoading=!0,e.browserError=null;try{(await e.client.request("browser.screencast.start",{quality:60,maxWidth:1280,maxHeight:720}))?.ok&&(e.browserScreencastActive=!0)}catch(t){e.browserError=Eo(t)}finally{e.browserLoading=!1}}}async function $y(e){if(!(!e.client||!e.connected)){e.browserLoading=!0;try{await e.client.request("browser.screencast.stop",{}),e.browserScreencastActive=!1,e.browserScreencastFrame=null,e.browserScreencastMetadata=null}catch(t){e.browserError=Eo(t)}finally{e.browserLoading=!1}}}async function ni(e,t,n,s,i){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"mouse",action:t,x:n,y:s,button:i??"left",clickCount:t==="mousePressed"?1:0})}catch{}}async function si(e,t,n,s){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"key",action:t,key:n,...s?.text?{text:s.text}:{},...s?.code?{code:s.code}:{},...s?.modifiers?{modifiers:s.modifiers}:{}})}catch{}}async function Ey(e){if(!(!e.client||!e.connected))try{await e.client.request("browser.handoff.complete",{}),e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}catch(t){e.browserError=Eo(t)}}function Ty(e){e.browserInputMode=!e.browserInputMode}function Cy(e,t){if(!t?.data)return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,Bn().updateFrame(t.data,t.metadata)}function _y(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function My(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}function Fe(e){return e instanceof Error?e.message:String(e)}let Pn=null;function sn(e,t){Pn&&clearTimeout(Pn),e.filesMessage={kind:"success",text:t},Pn=setTimeout(()=>{e.filesMessage=null,Pn=null},3e3)}async function on(e,t){if(!(!e.client||!e.connected)){if(!t){e.filesTree=[],e.filesRoot="";return}if(!e.filesLoading){e.filesLoading=!0,e.filesError=null;try{const n={};t&&(n.agentId=t);const s=await e.client.request("files.tree",n);s?.tree&&(e.filesTree=s.tree,e.filesRoot=s.root??"")}catch(n){e.filesError=Fe(n)}finally{e.filesLoading=!1}}}}async function Py(e,t,n){e.filesSelectedPaths=new Set([t]),await mc(e,t,n)}async function Ly(e,t,n){const s=new Set(e.filesSelectedPaths);if(s.has(t)?s.delete(t):s.add(t),e.filesSelectedPaths=s,s.size===1){const i=[...s][0];await mc(e,i,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function Ry(e,t){if(!e.client||!e.connected)return;const n=[...e.filesSelectedPaths];if(n.length===0)return;let s=0,i="";for(const o of n)try{await yc(e,o,t),s++}catch(r){i=Fe(r)}i?e.filesMessage={kind:"error",text:`${s} downloaded, error: ${i}`}:sn(e,`${s} file${s!==1?"s":""} downloaded`)}async function Iy(e,t,n,s){const i=t.split("/").pop()??t,o=n==="."?i:`${n}/${i}`;o!==t&&await vc(e,t,o,s)}async function mc(e,t,n){if(!(!e.client||!e.connected)){e.filesSelectedPath=t,e.filesPreviewLoading=!0,e.filesPreviewContent=null,e.filesPreviewBinary=!1,e.filesPreviewSize=null;try{const s={path:t};n&&(s.agentId=n);const i=await e.client.request("files.read",s);e.filesPreviewContent=i?.content??null,e.filesPreviewBinary=i?.binary??!1,e.filesPreviewSize=i?.size??null}catch(s){e.filesError=Fe(s)}finally{e.filesPreviewLoading=!1}}}async function yc(e,t,n){if(!(!e.client||!e.connected))try{const s={path:t};n&&(s.agentId=n);const i=await e.client.request("files.download",s);if(!i?.base64){e.filesMessage={kind:"error",text:"Download failed: no data"};return}const o=Uint8Array.from(atob(i.base64),c=>c.charCodeAt(0)),r=new Blob([o]),l=URL.createObjectURL(r),a=document.createElement("a");a.href=l,a.download=i.name??t.split("/").pop()??"download",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(l)}catch(s){e.filesMessage={kind:"error",text:Fe(s)}}}async function Ny(e,t,n,s){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let i=0,o="";for(const r of n)try{const l=await r.arrayBuffer(),a=btoa(new Uint8Array(l).reduce((u,p)=>u+String.fromCharCode(p),"")),c={path:t,name:r.name,data:a};s&&(c.agentId=s),await e.client.request("files.upload",c),i++}catch(l){o=Fe(l)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:i>0?`${i} uploaded, error: ${o}`:o}:sn(e,`${i} file${i!==1?"s":""} uploaded`),await on(e,s)}async function Oy(e,t,n){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const s={path:t};n&&(s.agentId=n),await e.client.request("files.delete",s),sn(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await on(e,n)}catch(s){e.filesMessage={kind:"error",text:Fe(s)}}}}async function vc(e,t,n,s){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const i={from:t,to:n};s&&(i.agentId=s),await e.client.request("files.move",i),sn(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await on(e,s)}catch(i){e.filesMessage={kind:"error",text:Fe(i)}}}}async function bc(e,t){if(!(!e.client||!e.connected))try{const n={};t&&(n.agentId=t);const s=await e.client.request("memory.status",n);s?.ok&&(e.filesMemoryStatus={dirty:s.dirty??!1,files:s.files??0,chunks:s.chunks??0})}catch{}}async function Dy(e,t){if(!(!e.client||!e.connected)&&!e.filesReindexBusy){e.filesReindexBusy=!0,e.filesMessage=null;try{const n={force:!0};t&&(n.agentId=t);const s=await e.client.request("memory.reindex",n),i=s?.files??0,o=s?.chunks??0;sn(e,`Re-indexed: ${i} files, ${o} chunks`),await bc(e,t)}catch(n){e.filesMessage={kind:"error",text:Fe(n)}}finally{e.filesReindexBusy=!1}}}function By(e,t){const n=new Set(e.filesExpandedDirs);n.has(t)?n.delete(t):n.add(t),e.filesExpandedDirs=n}function Fy(e,t="admin"){if(!e)return[];const n=e.bindings;if(!Array.isArray(n))return[];const s=[];for(const i of n){if(!i||typeof i!="object"||i.agentId!==t)continue;const o=i.match;if(!o||typeof o!="object"||(o.channel??"").toLowerCase()!=="whatsapp")continue;const l=o.peer;if(!l||typeof l!="object"||l.kind!=="dm")continue;const a=l.id??"";a&&s.push({phone:a,paired:i.meta?.paired===!0})}return s.sort((i,o)=>i.paired&&!o.paired?-1:!i.paired&&o.paired?1:0),s}function wc(e,t,n="admin",s){const i=new Map,o=new Map;for(const a of e){if(!a||typeof a!="object"||a.agentId!==n)continue;const c=a.match;if(!c||typeof c!="object"||(c.channel??"").toLowerCase()!=="whatsapp")continue;const p=c.peer;if(!p||typeof p!="object"||p.kind!=="dm")continue;const m=p.id??"";m&&(a.meta&&i.set(m,a.meta),c.accountId&&o.set(m,c.accountId))}const r=e.filter(a=>{if(!a||typeof a!="object"||a.agentId!==n)return!0;const c=a.match;if(!c||typeof c!="object"||(c.channel??"").toLowerCase()!=="whatsapp")return!0;const p=c.peer;return!p||typeof p!="object"?!0:p.kind!=="dm"}),l=t.map(a=>{const c=s??o.get(a.phone),u={channel:"whatsapp",peer:{kind:"dm",id:a.phone}};c&&(u.accountId=c);const p={agentId:n,match:u},m=i.get(a.phone);return m?p.meta=m:a.paired&&(p.meta={paired:!0}),p});return[...r,...l]}async function fs(e,t){if(!e.client||!e.connected)return;if(!t){e.adminPhones=[];return}if(e.adminsLoading)return;e.adminsLoading=!0,e.adminsError=null;const n=t;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const i=s.config;e.configForm=Oe(i??{}),e.adminPhones=Fy(i,n),e.configFormDirty=!1}catch(s){e.adminsError=String(s)}finally{e.adminsLoading=!1}}async function kc(e,t,n,s){if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const i=n;let o=t.trim();if(!o){e.adminsError="Phone number is required";return}if(o.startsWith("+")||(o="+"+o),!/^\+[1-9]\d{6,14}$/.test(o)){e.adminsError="Invalid phone number format. Use E.164 format (e.g., +14155552671)";return}if(e.adminPhones.some(r=>r.phone===o)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const r=Oe(e.configForm??e.configSnapshot?.config??{}),l=r.bindings??[],a=[...e.adminPhones,{phone:o}],c=wc(l,a,i,s);Ua(r,["bindings"],c);const u=e.configSnapshot?.hash;if(!u){e.adminsError="Config hash missing; reload and retry.";return}const p=Qe(r);await e.client.request("config.set",{raw:p,baseHash:u}),await fs(e,n)}catch(r){e.adminsError=String(r)}finally{e.adminsSaving=!1}}async function Sc(e,t,n,s){if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const i=n;if(e.adminPhones.find(r=>r.phone===t)?.paired){e.adminsError="Cannot remove the paired phone. Unlink WhatsApp first.";return}e.adminsSaving=!0,e.adminsError=null;try{const r=Oe(e.configForm??e.configSnapshot?.config??{}),l=r.bindings??[],a=e.adminPhones.filter(m=>m.phone!==t),c=wc(l,a,i,s);Ua(r,["bindings"],c);const u=e.configSnapshot?.hash;if(!u){e.adminsError="Config hash missing; reload and retry.";return}const p=Qe(r);await e.client.request("config.set",{raw:p,baseHash:u}),await fs(e,n)}catch(r){e.adminsError=String(r)}finally{e.adminsSaving=!1}}const Uy=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:kc,loadAdmins:fs,removeAdmin:Sc},Symbol.toStringTag,{value:"Module"}));async function et(e,t){if(!(!e.client||!e.connected)){if(!t){e.customersRecords=[];return}if(!e.customersLoading){e.customersLoading=!0,e.customersError=null;try{const n=e.customersSearchQuery.trim(),s=n?await e.client.request("records.search",{query:n,workspace:t}):await e.client.request("records.list",{workspace:t});e.customersRecords=s.records??[]}catch(n){e.customersError=String(n)}finally{e.customersLoading=!1}}}}async function Ac(e,t,n,s){if(!e.client||!e.connected||e.customersSaving)return;let i=t.trim();const o=n.trim();if(!i){e.customersError="Phone number is required";return}if(!o){e.customersError="Name is required";return}if(i.startsWith("+")||(i="+"+i),!/^\+[1-9]\d{6,14}$/.test(i)){e.customersError="Invalid phone number format. Use E.164 (e.g. +447490553305)";return}e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.set",{id:i,name:o,fields:{},workspace:s}),e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName="",await et(e,s)}catch(r){e.customersError=String(r)}finally{e.customersSaving=!1}}async function xc(e,t,n){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.delete",{id:t}),e.customersEditingId===t&&(e.customersEditingId=null),await et(e,n)}catch(s){e.customersError=String(s)}finally{e.customersSaving=!1}}}async function $c(e,t,n,s,i){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.setField",{id:t,key:n,value:s}),await et(e,i)}catch(o){e.customersError=String(o)}finally{e.customersSaving=!1}}}async function Ec(e,t,n,s){if(!(!e.client||!e.connected)&&!e.customersSaving){e.customersSaving=!0,e.customersError=null;try{await e.client.request("records.deleteField",{id:t,key:n}),await et(e,s)}catch(i){e.customersError=String(i)}finally{e.customersSaving=!1}}}const Wy=Object.freeze(Object.defineProperty({__proto__:null,addCustomer:Ac,deleteCustomer:xc,deleteCustomerField:Ec,loadCustomers:et,setCustomerField:$c},Symbol.toStringTag,{value:"Module"}));function Ut(e){if(e.workspaces.length!==0)return{workspaces:e.workspaces,selectedWorkspace:e.selectedWorkspace,onWorkspaceSelect:t=>e.handleWorkspaceSelect(t),hasPins:e.accessState.hasPins,isMaster:e.accessState.master,onLogout:()=>e.handleLogout()}}function Ky(e){if(e.workspaces.length!==0)return{workspaces:e.workspaces,selectedWorkspace:e.selectedWorkspace,onWorkspaceSelect:t=>e.handleWorkspaceSelect(t),onAddAccount:()=>{e.addingWorkspace=!0},hasPins:e.accessState.hasPins,isMaster:e.accessState.master,onLogout:()=>e.handleLogout()}}function zy(e){const t=J(e);return t?t.agents.find(s=>s.id.endsWith("-admin")||s.id==="admin")?.id:void 0}function jy(e){return J(e)?.whatsappAccountId??void 0}function Hy(e){const t=J(e);if(t)return t.agents[0]?.id}function qy(e){return e.selectedWorkspace??void 0}function J(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const Gy=/^data:/i,Vy=/^https?:\/\//i;function Qy(e){const t=e.agentsList?.agents??[],s=Ca(e.sessionKey)?.agentId??e.agentsList?.defaultId??"main",o=t.find(l=>l.id===s)?.identity,r=o?.avatarUrl??o?.avatar;if(r)return Gy.test(r)||Vy.test(r)?r:o?.avatarUrl}function Yy(e){if(!e)return null;const t=e.channelAccounts?.whatsapp;if(!t||t.length===0)return null;const n=t[0];return{running:n.running??!1,connected:n.connected??!1,linked:n.linked??!1,lastError:n.lastError}}function Xy(e){if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=e.channelAccounts?.imessage;if(!t||t.length===0)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const n=t[0],s=n.running??!1,i=n.probe,o=i!=null?i.ok===!0:s;return{configured:n.configured??!1,running:s,connected:o,lastError:n.lastError??null,selfChatMode:n.mode==="self-chat"||!!n.selfChatMode,dmPolicy:n.dmPolicy??null,cliPath:n.cliPath??null}}function Zy(e){const t=e.configSnapshot?.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const s=n.find(r=>r.match?.channel==="imessage"&&r.meta?.imessageOwner);if(!s)return null;const i=s.agentId;for(const r of e.workspaces)if(r.agents.some(l=>l.id===i))return r.name;if(i==="admin"||i==="public")return e.workspaces.find(l=>l.isDefault)?.name??null;const o=i.replace(/-(admin|public)$/,"");return o!==i?e.workspaces.find(l=>l.name===o)?.name??null:null}function Jy(e){if(e.connected&&e.accessState.checked){const{accessState:t}=e;if(t.hasPins&&!t.authenticated)return fa({show:!0,isFirstTime:!1,accounts:t.accounts,error:t.error,busy:t.busy,onSubmit:(n,s)=>{s!=null&&e.handlePinSubmit(n,s)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(n,s,i)=>e.handleChangePin(n,s,i)});if(!t.hasMasterPin&&!t.authenticated&&e.setup)return fa({show:!0,isFirstTime:!0,accounts:[],error:t.error,busy:t.busy,onSubmit:n=>e.handleSetMasterPin(n)});if(!t.hasMasterPin&&!t.authenticated&&!e.setup)return window.location.href="/setup",b}if(e.setup){const t=Yy(e.channelsSnapshot),n=e.channelsSnapshot?.channelAccounts?.whatsapp??[],s=Xy(e.channelsSnapshot),i=Zy(e);return Jp({connected:e.connected,assistantName:e.assistantName,currentStep:e.setupStep,licenseKey:e.licenseKey,licenseBusy:e.licenseBusy,licenseValid:e.licenseValid,licenseMessage:e.licenseMessage,licenseTier:e.licenseTier,licenseDeviceId:e.licenseDeviceId,licenseStoredKey:e.licenseStoredKey,onLicenseKeyChange:o=>e.handleLicenseKeyChange(o),onLicenseActivate:()=>e.handleLicenseActivate(),onLicenseRemove:async()=>{await e.handleLicenseRemove(),e.licenseRemoveConfirm=!1},licenseRemoveConfirm:e.licenseRemoveConfirm,onLicenseRemoveConfirm:()=>{e.licenseRemoveConfirm=!0},onLicenseRemoveCancel:()=>{e.licenseRemoveConfirm=!1},authConnected:e.authConnected,authBusy:e.authBusy,authMessage:e.authMessage,authUrl:e.authUrl,authCodeInput:e.authCodeInput,authExpiresIn:e.authExpiresIn,whatsappBusy:e.whatsappBusy,whatsappLoginMessage:e.whatsappLoginMessage,whatsappLoginQrDataUrl:e.whatsappLoginQrDataUrl,whatsappLoginConnected:e.whatsappLoginConnected,whatsappChannelStatus:t,whatsappAccounts:n,whatsappActiveQrAccountId:e.whatsappActiveQrAccountId,whatsappAccountSaving:e.whatsappAccountSaving,gatewayHealthy:e.gatewayHealthy,gatewayHealthLoading:e.gatewayHealthLoading,gatewayHealthMessage:e.gatewayHealthMessage,gatewayRestartBusy:e.gatewayRestartBusy,updateAvailable:e.updateAvailable,currentVersion:e.currentVersion,latestVersion:e.latestVersion,updateChecking:e.updateChecking,updateRunning:e.updateRunning,updateMessage:e.updateMessage,updateProgressSteps:e.updateProgressSteps,updateLastResult:e.updateLastResult,onUpdateCheck:()=>e.handleUpdateCheck(),onUpdateRun:()=>e.handleUpdateRun(),onUpdateDismissResult:()=>e.handleUpdateDismissResult(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:o=>e.handleAuthSubmitCode(o),onAuthCodeChange:o=>e.handleAuthCodeChange(o),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async o=>{await e.handleWhatsAppStart(!0,o),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(o),await z(e,!0),e.requestUpdate())},onWhatsAppReset:async o=>{await e.handleWhatsAppLogout(o),await e.handleWhatsAppStart(!0,o),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(o),await z(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await z(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),z(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:o=>e.handleRemoveWhatsAppAccount(o),workspaces:e.workspaces,workspacesLoading:e.workspacesLoading,workspacesError:e.workspacesError,addingWorkspace:e.addingWorkspace,newWorkspaceName:e.newWorkspaceName,newWorkspacePath:e.newWorkspacePath,workspaceSaving:e.workspaceSaving,workspaceRemoveConfirm:e.workspaceRemoveConfirm,newWorkspacePin:e.newWorkspacePin,onSetNewWorkspacePin:o=>{e.newWorkspacePin=o},onWorkspaceCreate:async(o,r)=>{const l=e.newWorkspacePin;await e.handleWorkspaceCreate(o,r),l.match(/^\d{4,6}$/)&&(await wy(e,o,l),e.newWorkspacePin="")},onWorkspaceRemove:o=>e.handleWorkspaceRemove(o),onSetAddingWorkspace:o=>{e.addingWorkspace=o},onSetNewWorkspaceName:o=>{e.newWorkspaceName=o},onSetNewWorkspacePath:o=>{e.newWorkspacePath=o},onSetWorkspaceRemoveConfirm:o=>{e.workspaceRemoveConfirm=o},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(o,r)=>e.handleWorkspaceRename(o,r),whatsappDmPolicy:(()=>{const r=J(e)?.whatsappAccountId;return(r?n.find(a=>a.accountId===r):n[0])?.dmPolicy??null})(),onWhatsAppDmToggle:async()=>{const r=J(e)?.whatsappAccountId,l=r?n.find(p=>p.accountId===r):n[0];if(!l)return;const c=l.dmPolicy!=null&&l.dmPolicy!=="disabled"?"disabled":"open",u=c==="open"?{dmPolicy:c,allowFrom:["*"]}:{dmPolicy:c};try{const p=await e.client.request("config.get"),x=(p.config?.channels?.whatsapp?.accounts??{})[l.accountId]?{channels:{whatsapp:{accounts:{[l.accountId]:u}}}}:{channels:{whatsapp:u}};await e.client.request("config.patch",{raw:JSON.stringify(x),baseHash:p.hash,note:`WhatsApp DM policy → ${c}`,skipRestart:!0}),await z(e,!1)}catch(p){console.error("DM toggle failed:",p)}},whatsappModel:(()=>{const o=J(e);if(!o)return null;const r=o.agents.find(p=>p.id.endsWith("-public")||p.id==="public");if(!r)return null;const a=e.configSnapshot?.config?.agents?.list;if(!Array.isArray(a))return null;const c=a.find(p=>p.id===r.id);return c?.model&&(typeof c.model=="string"?c.model:c.model.primary)?.trim()||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async o=>{const r=J(e);if(!r)return;const l=r.agents.find(a=>a.id.endsWith("-public")||a.id==="public");if(l)try{const a=await e.client.request("config.get"),u=a.config?.agents??{},p=Array.isArray(u.list)?[...u.list]:[],m=p.findIndex(w=>w.id===l.id);if(o)m>=0?p[m]={...p[m],model:o}:p.push({id:l.id,model:o});else if(m>=0){const{model:w,...x}=p[m];Object.keys(x).length<=1?p.splice(m,1):p[m]=x}const v=p.length>0?{agents:{list:p}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(v),baseHash:a.hash,note:`Public agent model → ${o||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(a){console.error("Model change failed:",a)}},whatsappThinkingLevel:(()=>{const o=J(e);if(!o)return null;const r=o.agents.find(u=>u.id.endsWith("-public")||u.id==="public");if(!r)return null;const a=e.configSnapshot?.config?.agents?.list;return Array.isArray(a)&&a.find(u=>u.id===r.id)?.thinkingLevel?.trim()||null})(),onWhatsAppThinkingChange:async o=>{const r=J(e);if(!r)return;const l=r.agents.find(a=>a.id.endsWith("-public")||a.id==="public");if(l)try{const a=await e.client.request("config.get"),u=a.config?.agents??{},p=Array.isArray(u.list)?[...u.list]:[],m=p.findIndex(x=>x.id===l.id),v=o==="off"?void 0:o;if(v)m>=0?p[m]={...p[m],thinkingLevel:v}:p.push({id:l.id,thinkingLevel:v});else if(m>=0){const{thinkingLevel:x,..._}=p[m];Object.keys(_).length<=1?p.splice(m,1):p[m]=_}const w=p.length>0?{agents:{list:p}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(w),baseHash:a.hash,note:`Public agent thinking → ${v||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(a){console.error("Thinking change failed:",a)}},whatsappGroupPolicy:(()=>{const r=e.configSnapshot?.config?.channels?.whatsapp,a=J(e)?.whatsappAccountId,c=r?.accounts??{};return(a?c[a]:void 0)?.groupPolicy??r?.groupPolicy??"allowlist"})(),whatsappGroupRequireMention:(()=>{const r=e.configSnapshot?.config?.channels?.whatsapp,a=J(e)?.whatsappAccountId,c=r?.accounts??{};return((a?c[a]:void 0)?.groups??r?.groups??{})["*"]?.requireMention!==!1})(),onWhatsAppGroupToggle:async()=>{const r=J(e)?.whatsappAccountId;try{const l=await e.client.request("config.get"),c=l.config?.channels?.whatsapp??{},u=c.accounts??{},p=r?u[r]:void 0,m=p?.groupPolicy??c.groupPolicy??"allowlist",v=m==="disabled"||m==="allowlist",w=v?"open":"disabled",x=v?{"*":{}}:void 0,_={groupPolicy:w};x&&(_.groups=x);const j=p?{channels:{whatsapp:{accounts:{[r]:_}}}}:{channels:{whatsapp:_}};await e.client.request("config.patch",{raw:JSON.stringify(j),baseHash:l.hash,note:`WhatsApp groups → ${w}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(l){console.error("Group toggle failed:",l)}},onWhatsAppGroupMentionChange:async o=>{const l=J(e)?.whatsappAccountId;try{const a=await e.client.request("config.get"),p=(a.config?.channels?.whatsapp??{}).accounts??{},m=l?p[l]:void 0,v={"*":{requireMention:o}},w=m?{channels:{whatsapp:{accounts:{[l]:{groups:v}}}}}:{channels:{whatsapp:{groups:v}}};await e.client.request("config.patch",{raw:JSON.stringify(w),baseHash:a.hash,note:`WhatsApp group mention → ${o?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(a){console.error("Group mention change failed:",a)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:s.configured,imessageRunning:s.running,imessageConnected:s.connected,imessageLastError:s.lastError,imessageSelfChatMode:s.selfChatMode,imessageCliPath:s.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:i,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const o=await e.client.request("config.get"),l=o.config?.bindings??[],a=J(e),u=a?.agents.find(w=>w.id.endsWith("-admin")||w.id==="admin")?.id??"admin",p=l.filter(w=>w.match?.channel!=="imessage"),m=[{agentId:u,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],v=[...p,...m];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:v}),baseHash:o.hash,note:"Enable iMessage (self-chat) for "+(a?.name??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([z(e,!0),we(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await z(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const o=await e.client.request("config.get"),a=(o.config?.bindings??[]).filter(c=>c.match?.channel!=="imessage");await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:a}),baseHash:o.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([z(e,!0),we(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const o=await e.client.request("config.get"),l=o.config?.bindings??[],a=J(e),u=a?.agents.find(v=>v.id.endsWith("-admin")||v.id==="admin")?.id??"admin",p=l.filter(v=>v.match?.channel!=="imessage"),m=[{agentId:u,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:[...p,...m]}),baseHash:o.hash,note:"Reassign iMessage to "+(a?.name??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([z(e,!0),we(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:o=>{e.infoModalOpen=o},onInfoModalClose:()=>{e.infoModalOpen=null},isMaster:e.accessState.master,apiKeyProviders:e.apiKeyProviders,apiKeyModalOpen:e.apiKeyModalOpen,apiKeyBusy:e.apiKeyBusy,apiKeyError:e.apiKeyError,apiKeySuccess:e.apiKeySuccess,onApiKeyModalOpen:()=>{e.apiKeyModalOpen=!0,e.apiKeyError=null,e.apiKeySuccess=null},onApiKeyModalClose:()=>{e.apiKeyModalOpen=!1,e.apiKeyError=null,e.apiKeySuccess=null},onApiKeySave:async(o,r)=>{e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await ma(e.client,o,r),e.apiKeySuccess=`${o} key saved`;try{e.apiKeyProviders=await Pi(e.client)}catch{}o==="anthropic"&&await e.handleAuthStatusCheck()}catch(l){e.apiKeyError=l instanceof Error?l.message:"Failed to save key"}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async o=>{e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await Sy(e.client,o),e.apiKeySuccess=`${o} key removed`;try{e.apiKeyProviders=await Pi(e.client)}catch{}}catch(r){e.apiKeyError=r instanceof Error?r.message:"Failed to remove key"}finally{e.apiKeyBusy=!1}},authApiKeyMode:e.authApiKeyMode,authApiKeyInput:e.authApiKeyInput,authApiKeyBusy:e.authApiKeyBusy,authApiKeyError:e.authApiKeyError,onAuthApiKeyToggle:()=>{e.authApiKeyMode=!e.authApiKeyMode,e.authApiKeyError=null},onAuthApiKeyChange:o=>{e.authApiKeyInput=o},onAuthApiKeySubmit:async()=>{const o=e.authApiKeyInput.trim();if(o){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await ma(e.client,"anthropic",o),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(r){e.authApiKeyError=r instanceof Error?r.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{const o=e.selectedWorkspace??e.workspaces[0]?.name;return o?e.accessState.accounts.some(r=>r.id===o):!1})(),accountPinModalOpen:e.accountPinModalOpen,accountPinBusy:e.accountPinBusy,accountPinError:e.accountPinError,accountPinSuccess:e.accountPinSuccess,onAccountPinModalOpen:()=>{e.accountPinModalOpen=!0,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinModalClose:()=>{e.accountPinModalOpen=!1,e.accountPinError=null,e.accountPinSuccess=null},onAccountPinSave:(o,r)=>{const l=e.selectedWorkspace??e.workspaces[0]?.name;l&&e.handleAccountPinSave(l,o,r)},wsProps:Ky(e)})}if(e.filesPage){const t=Hy(e);return Up({connected:e.connected,wsProps:Ut(e),loading:e.filesLoading,tree:e.filesTree,root:e.filesRoot,error:e.filesError,selectedPath:e.filesSelectedPath,selectedPaths:e.filesSelectedPaths,previewContent:e.filesPreviewContent,previewLoading:e.filesPreviewLoading,previewBinary:e.filesPreviewBinary,previewSize:e.filesPreviewSize,expandedDirs:e.filesExpandedDirs,message:e.filesMessage,uploadBusy:e.filesUploadBusy,reindexBusy:e.filesReindexBusy,memoryStatus:e.filesMemoryStatus,onRefresh:()=>on(e,t),onReindex:()=>Dy(e,t),onSelectFile:n=>Py(e,n,t),onToggleSelectFile:n=>Ly(e,n,t),onToggleDir:n=>By(e,n),onUpload:(n,s)=>Ny(e,n,s,t),onDownload:n=>yc(e,n,t),onBulkDownload:()=>Ry(e,t),onDelete:n=>Oy(e,n,t),onMove:(n,s)=>vc(e,n,s,t),onMoveToDir:(n,s)=>Iy(e,n,s,t)})}if(e.browserPage)return Np({connected:e.connected,active:e.browserScreencastActive,loading:e.browserLoading,error:e.browserError,inputMode:e.browserInputMode,handoffPending:e.browserHandoffPending,handoffReason:e.browserHandoffReason,onStart:()=>xy(e),onStop:()=>$y(e),onToggleInput:()=>Ty(e),onCompleteHandoff:()=>Ey(e),onCanvasMouseDown:t=>{const s=t.target.getBoundingClientRect(),o=Bn().translateCoordinates(t.clientX-s.left,t.clientY-s.top);ni(e,"mousePressed",o.x,o.y,t.button===2?"right":t.button===1?"middle":"left")},onCanvasMouseUp:t=>{const s=t.target.getBoundingClientRect(),o=Bn().translateCoordinates(t.clientX-s.left,t.clientY-s.top);ni(e,"mouseReleased",o.x,o.y)},onCanvasMouseMove:t=>{const n=Bn();if(n.shouldThrottleMouseMove())return;const i=t.target.getBoundingClientRect(),o=n.translateCoordinates(t.clientX-i.left,t.clientY-i.top);ni(e,"mouseMoved",o.x,o.y)},onCanvasKeyDown:t=>{let n=0;t.altKey&&(n|=1),t.ctrlKey&&(n|=2),t.metaKey&&(n|=4),t.shiftKey&&(n|=8),si(e,"keyDown",t.key,{code:t.code,modifiers:n||void 0}),t.key.length===1&&si(e,"char",t.key,{text:t.key})},onCanvasKeyUp:t=>{si(e,"keyUp",t.key,{code:t.code})}});if(e.adminsPage){const t=zy(e),n=jy(e);return th({connected:e.connected,wsProps:Ut(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>fs(e,t),onAdd:s=>{kc(e,s,t,n).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:s=>Sc(e,s,t,n),onNewPhoneChange:s=>e.handleAdminsNewPhoneChange(s)})}if(e.customersPage){const t=qy(e);return oh({connected:e.connected,wsProps:Ut(e),loading:e.customersLoading,saving:e.customersSaving,records:e.customersRecords,error:e.customersError,searchQuery:e.customersSearchQuery,editingId:e.customersEditingId,showAddForm:e.customersShowAddForm,newRecordPhone:e.customersNewPhone,newRecordName:e.customersNewName,onSearch:n=>e.customersSearchQuery=n,onSearchSubmit:()=>et(e,t),onAdd:(n,s)=>Ac(e,n,s,t),onDelete:n=>xc(e,n,t),onSetField:(n,s,i)=>$c(e,n,s,i,t),onDeleteField:(n,s)=>Ec(e,n,s,t),onToggleExpand:n=>{e.customersEditingId=e.customersEditingId===n?null:n},onShowAddForm:()=>e.customersShowAddForm=!0,onCancelAddForm:()=>{e.customersShowAddForm=!1,e.customersNewPhone="",e.customersNewName=""},onNewRecordPhoneChange:n=>e.handleCustomersNewPhoneChange(n),onNewRecordNameChange:n=>e.handleCustomersNewNameChange(n),onRefresh:()=>et(e,t)})}if(e.chatPage){const t=e.connected?null:"Disconnected from gateway.",n=Qy(e),s=e.chatAvatarUrl??n??null;return Wm({connected:e.connected,wsProps:Ut(e),sessionKey:e.sessionKey,onSessionKeyChange:i=>{e.sessionKey=i,e.chatMessage="",e.chatAttachments=[],e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:i,lastActiveSessionKey:i}),e.loadAssistantIdentity(),Ce(e),fi(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:i=>{wn(e,e.sessionKey,{model:i}).then(()=>{Ce(e)})},onThinkingLevelChange:i=>{wn(e,e.sessionKey,{thinkingLevel:i==="off"?null:i}).then(()=>{Ce(e)})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,onVerboseChange:i=>{wn(e,e.sessionKey,{verboseLevel:i==="off"?null:i}).then(()=>{Ce(e)})},onFillerChange:i=>{wn(e,e.sessionKey,{fillerEnabled:i}).then(()=>{Ce(e)})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:s,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,disabledReason:t,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>(e.resetToolStream(),Promise.all([Ce(e),fi(e)])),onToggleFocusMode:()=>{},onChatScroll:i=>e.handleChatScroll(i),nearBottom:e.chatUserNearBottom,onDraftChange:i=>e.chatMessage=i,attachments:e.chatAttachments,onAttachmentsChange:i=>e.chatAttachments=i,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:i=>e.removeQueuedMessage(i),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:i=>e.handleOpenSidebar(i),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:i=>e.handleSplitRatioChange(i),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?my({connected:e.connected,wsProps:Ut(e),activeTab:e.advancedTab,onTabChange:t=>{e.advancedTab=t,t==="cron"&&e.loadCron(),t==="skills"&&wt(e,{clearMessages:!0}),t==="logs"&&(e.logsSubTab==="session"?gt(e,{reset:!0}):qt(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:e.channelsSnapshot?.channelMeta?.length?e.channelsSnapshot.channelMeta.map(t=>t.id):e.channelsSnapshot?.channelOrder??[],channelLabels:e.channelsSnapshot?.channelLabels??{},channelMeta:e.channelsSnapshot?.channelMeta??[],agentIds:J(e)?.agents?.map(n=>n.id)??[],runsJobId:e.cronRunsJobId,runs:e.cronRuns,newEventModalOpen:e.cronNewEventModal,onNewEventModalOpen:()=>{e.cronNewEventModal=!0},onNewEventModalClose:()=>{e.cronNewEventModal=!1},detailJobId:e.cronDetailJobId,onDetailOpen:t=>{e.cronDetailJobId=t.id,ci(e,t.id)},onDetailClose:()=>{e.cronDetailJobId=null},onFormChange:t=>e.cronForm={...e.cronForm,...t},onRefresh:()=>e.loadCron(),onAdd:()=>{ld(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(t,n)=>cd(e,t,n),onRun:t=>ud(e,t),onRemove:t=>dd(e,t),onLoadRuns:t=>ci(e,t)},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,onFilterChange:t=>e.skillsFilter=t,onRefresh:()=>wt(e,{clearMessages:!0}),onToggle:(t,n)=>Zd(e,t,n),onEdit:(t,n)=>Xd(e,t,n),onSaveKey:t=>Jd(e,t),onInstall:(t,n,s)=>ep(e,t,n,s)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:t=>{e.logsSubTab=t,t==="session"?gt(e,{reset:!0}):qt(e,{reset:!0})},sessionLogsProps:{loading:e.sessionLogsLoading,error:e.sessionLogsError,entries:e.sessionLogsEntries,agents:e.sessionLogsAgents,filterText:e.sessionLogsFilterText,typeFilters:e.sessionLogsTypeFilters,agentFilters:e.sessionLogsAgentFilters,autoFollow:e.sessionLogsAutoFollow,full:e.sessionLogsFull,onFilterTextChange:t=>e.sessionLogsFilterText=t,onTypeToggle:(t,n)=>{const s=e;s.sessionLogsTypeFilters={...s.sessionLogsTypeFilters,[t]:n}},onAgentToggle:(t,n)=>{const s=e;s.sessionLogsAgentFilters={...s.sessionLogsAgentFilters,[t]:n}},onToggleAutoFollow:t=>e.sessionLogsAutoFollow=t,onToggleFull:t=>{e.sessionLogsFull=t,gt(e,{reset:!0})},onRefresh:()=>{gt(e,{reset:!0})},onExport:(t,n)=>e.exportSessionLogs(t,n),onScroll:t=>e.handleSessionLogsScroll(t)},loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,truncated:e.logsTruncated,onFilterTextChange:t=>e.logsFilterText=t,onLevelToggle:(t,n)=>{e.logsLevelFilters={...e.logsLevelFilters,[t]:n}},onToggleAutoFollow:t=>e.logsAutoFollow=t,onRefresh:()=>qt(e,{reset:!0}),onExport:(t,n)=>e.exportSessionLogs(t,n),onScroll:t=>e.handleLogsScroll(t)}}):(window.location.replace("/chat"),d``)}const ev={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},tv={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",to:"",timeoutSeconds:"",postToMainPrefix:""};async function nv(e){if(!(!e.client||!e.connected)&&!e.agentsLoading){e.agentsLoading=!0,e.agentsError=null;try{const t=await e.client.request("agents.list",{});t&&(e.agentsList=t)}catch(t){e.agentsError=String(t)}finally{e.agentsLoading=!1}}}async function rn(e){if(!(!e.client||!e.connected)&&!e.workspacesLoading){e.workspacesLoading=!0,e.workspacesError=null;try{const t=await e.client.request("workspaces.list",{});e.workspaces=t.workspaces}catch(t){e.workspacesError=String(t)}finally{e.workspacesLoading=!1}}}async function sv(e,t){if(!e.client||!e.connected||e.workspaceSaving)return;const n=t.name.trim();if(!n){e.workspacesError="Account name is required.";return}e.workspaceSaving=!0,e.workspacesError=null;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const i=s.hash;if(!i){e.workspacesError="Config hash missing; reload and retry.";return}const o={name:n,baseHash:i,whatsappAccountName:n};t.workspacePath?.trim()&&(o.workspaceDir=t.workspacePath.trim());const r=await e.client.request("workspaces.create",o);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await rn(e),t.onCreated?.(r)}catch(s){e.workspacesError=String(s)}finally{e.workspaceSaving=!1}}async function iv(e,t){if(!(!e.client||!e.connected)&&!e.workspaceSaving){e.workspaceSaving=!0,e.workspacesError=null;try{const n=await e.client.request("config.get",{});e.configSnapshot=n;const s=n.hash;if(!s){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.remove",{name:t,baseHash:s}),e.workspaceRemoveConfirm=null,await rn(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function ov(e,t,n){if(!(!e.client||!e.connected)){e.workspacesError=null;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const i=s.hash;if(!i){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.rename",{name:t,displayName:n,baseHash:i}),await rn(e)}catch(s){e.workspacesError=String(s)}}}const Ln=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:sv,loadWorkspaces:rn,removeWorkspace:iv,renameWorkspace:ov},Symbol.toStringTag,{value:"Module"})),Tc={WEBCHAT_UI:"webchat-ui",CONTROL_UI:"taskmaster-control-ui",SETUP_UI:"setup-ui",WEBCHAT:"webchat",CLI:"cli",GATEWAY_CLIENT:"gateway-client",MACOS_APP:"taskmaster-macos",IOS_APP:"taskmaster-ios",ANDROID_APP:"taskmaster-android",NODE_HOST:"node-host",TEST:"test",FINGERPRINT:"fingerprint",PROBE:"taskmaster-probe"},ya=Tc,Li={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(Tc));new Set(Object.values(Li));function rv(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),s=e.token??"",i=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),s];return t==="v2"&&i.push(e.nonce??""),i.join("|")}const av=4008;class lv{constructor(t){this.opts=t,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800}start(){this.closed=!1,this.connect()}stop(){this.closed=!0,this.ws?.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){return this.ws?.readyState===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.onopen=()=>this.queueConnect(),this.ws.onmessage=t=>this.handleMessage(String(t.data??"")),this.ws.onclose=t=>{const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),this.opts.onClose?.({code:t.code,reason:n}),this.scheduleReconnect()},this.ws.onerror=()=>{})}scheduleReconnect(){if(this.closed)return;const t=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),t)}flushPending(t){for(const[,n]of this.pending)n.reject(t);this.pending.clear()}async sendConnect(){if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=typeof crypto<"u"&&!!crypto.subtle,n=["operator.admin","operator.approvals","operator.pairing"],s="operator";let i=null,o=!1,r=this.opts.token;if(t){i=await Kd();const u=Hd({deviceId:i.deviceId,role:s})?.token;r=u??this.opts.token,o=!!(u&&this.opts.token)}const l=r||this.opts.password?{token:r,password:this.opts.password}:void 0;let a;if(t&&i){const u=Date.now(),p=this.connectNonce??void 0,m=rv({deviceId:i.deviceId,clientId:this.opts.clientName??ya.CONTROL_UI,clientMode:this.opts.mode??Li.WEBCHAT,role:s,scopes:n,signedAtMs:u,token:r??null,nonce:p}),v=await zd(i.privateKey,m);a={id:i.deviceId,publicKey:i.publicKey,signature:v,signedAt:u,nonce:p}}const c={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??ya.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Li.WEBCHAT,instanceId:this.opts.instanceId},role:s,scopes:n,device:a,caps:[],auth:l,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",c).then(u=>{u?.auth?.deviceToken&&i&&qd({deviceId:i.deviceId,role:u.auth.role??s,token:u.auth.deviceToken,scopes:u.auth.scopes??[]}),this.backoffMs=800,this.opts.onHello?.(u)}).catch(()=>{o&&i&&Gd({deviceId:i.deviceId,role:s}),this.ws?.close(av,"connect failed")})}handleMessage(t){let n;try{n=JSON.parse(t)}catch{return}const s=n;if(s.type==="event"){const i=n;if(i.event==="connect.challenge"){const r=i.payload,l=r&&typeof r.nonce=="string"?r.nonce:null;l&&(this.connectNonce=l,this.sendConnect());return}const o=typeof i.seq=="number"?i.seq:null;o!==null&&(this.lastSeq!==null&&o>this.lastSeq+1&&this.opts.onGap?.({expected:this.lastSeq+1,received:o}),this.lastSeq=o);try{this.opts.onEvent?.(i)}catch(r){console.error("[gateway] event handler error:",r)}return}if(s.type==="res"){const i=n,o=this.pending.get(i.id);if(!o)return;this.pending.delete(i.id),i.ok?o.resolve(i.payload):o.reject(new Error(i.error?.message??"request failed"));return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const s=Ui(),i={type:"req",id:s,method:t,params:n},o=new Promise((r,l)=>{this.pending.set(s,{resolve:a=>r(a),reject:l})});return this.ws.send(JSON.stringify(i)),o}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function Ri(e){return typeof e=="object"&&e!==null}function cv(e){if(!Ri(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Ri(n))return null;const s=typeof n.command=="string"?n.command.trim():"";if(!s)return null;const i=typeof e.createdAtMs=="number"?e.createdAtMs:0,o=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!i||!o?null:{id:t,request:{command:s,cwd:typeof n.cwd=="string"?n.cwd:null,host:typeof n.host=="string"?n.host:null,security:typeof n.security=="string"?n.security:null,ask:typeof n.ask=="string"?n.ask:null,agentId:typeof n.agentId=="string"?n.agentId:null,resolvedPath:typeof n.resolvedPath=="string"?n.resolvedPath:null,sessionKey:typeof n.sessionKey=="string"?n.sessionKey:null},createdAtMs:i,expiresAtMs:o}}function uv(e){if(!Ri(e))return null;const t=typeof e.id=="string"?e.id.trim():"";return t?{id:t,decision:typeof e.decision=="string"?e.decision:null,resolvedBy:typeof e.resolvedBy=="string"?e.resolvedBy:null,ts:typeof e.ts=="number"?e.ts:null}:null}function Cc(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function dv(e,t){const n=Cc(e).filter(s=>s.id!==t.id);return n.push(t),n}function va(e,t){return Cc(e).filter(n=>n.id!==t)}async function _c(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),s=n?{sessionKey:n}:{};try{const i=await e.client.request("agent.identity.get",s);if(!i)return;const o=ai(i);e.assistantName=o.name,e.assistantAvatar=o.avatar,e.assistantAgentId=o.agentId??null}catch{}}const es="taskmaster_update_pending";async function pv(e){if(!(!e.client||!e.connected)&&!e.updateChecking){e.updateChecking=!0,e.updateMessage=null,e.requestUpdate?.();try{const t=await e.client.request("update.status",{});e.currentVersion=t.current,e.latestVersion=t.latest,e.updateAvailable=t.updateAvailable,e.updateMessage=t.updateAvailable?`v${t.latest} available`:"Up to date"}catch(t){e.updateMessage=`Check failed: ${String(t)}`,e.updateAvailable=null}finally{e.updateChecking=!1,e.requestUpdate?.()}}}async function hv(e){if(!(!e.client||e.updateRunning)){e.updateRunning=!0,e.updateMessage="Starting update...",e.updateProgressSteps=[],e.updateLastResult=null,e.requestUpdate?.();try{localStorage.setItem(es,String(Date.now()))}catch{}try{const t=await e.client.request("update.run",{restartDelayMs:2e3,note:"Update from setup page"});if(t.ok&&t.result.status==="ok")e.updateMessage="Updated — restarting gateway...",e.requestUpdate?.();else if(t.ok&&t.result.status==="skipped")Qt(),e.updateMessage=t.result.reason||"Update skipped",e.updateRunning=!1,e.requestUpdate?.();else throw Qt(),new Error(t.result.reason||"Update failed")}catch(t){Qt(),e.updateMessage=`Update failed: ${String(t)}`,e.updateRunning=!1,e.updateProgressSteps=[],e.requestUpdate?.()}}}function fv(e,t){const n=t.phase;if(n==="step-start"){const s=t.name,i=t.index,o=t.total;e.updateMessage=`Updating: ${s} (${i+1}/${o})`;const r=e.updateProgressSteps.find(l=>l.index===i);r?(r.status="running",r.name=s):e.updateProgressSteps=[...e.updateProgressSteps,{name:s,index:i,total:o,status:"running"}],e.requestUpdate?.()}else if(n==="step-done"){const s=t.name,i=t.index,o=t.total,r=t.ok,l=t.durationMs,a=e.updateProgressSteps.find(c=>c.index===i);a?(a.status=r?"done":"failed",a.durationMs=l):e.updateProgressSteps=[...e.updateProgressSteps,{name:s,index:i,total:o,status:r?"done":"failed",durationMs:l}],e.updateMessage=r?`Updating: ${s} done (${i+1}/${o})`:`Update step failed: ${s}`,e.requestUpdate?.()}else if(n==="complete"){if(t.status==="ok")e.updateMessage="Update complete — restarting gateway...";else{const i=t.reason;e.updateMessage=i?`Update failed: ${i}`:"Update failed",e.updateRunning=!1,Qt()}e.requestUpdate?.()}}async function gv(e){if(!e.client||!e.connected)return;const t=yv();Qt();try{const n=await e.client.request("update.lastResult",{});if(!n.ok||!n.result)return;const s=5*6e4,i=Date.now()-n.result.ts<s;if(!t&&!i)return;if(e.updateLastResult=n.result,e.currentVersion=n.result.currentVersion,e.updateAvailable=!1,n.result.status==="ok"){const o=n.result.before?.version,r=n.result.after?.version??n.result.currentVersion;e.updateMessage=o?`Updated: v${o} → v${r}`:`Updated to v${r}`}else{const o=n.result.reason??n.result.failedStep?.name??"unknown error";e.updateMessage=`Update failed: ${o}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],e.requestUpdate?.()}}function mv(e){e.updateLastResult=null,e.requestUpdate?.()}function yv(){try{const e=localStorage.getItem(es);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(es),!1):!0:!1}catch{return!1}}function Qt(){try{localStorage.removeItem(es)}catch{}}function ii(e,t){const n=(e??"").trim(),s=t.mainSessionKey?.trim();if(!s)return n;if(!n)return s;const i=t.mainKey?.trim()||"main",o=t.defaultAgentId?.trim();return n==="main"||n===i||o&&(n===`agent:${o}:main`||n===`agent:${o}:${i}`)?s:n}function vv(e,t){if(!t?.mainSessionKey)return;const n=ii(e.sessionKey,t),s=ii(e.settings.sessionKey,t),i=ii(e.settings.lastActiveSessionKey,t),o=n||s||e.sessionKey,r={...e.settings,sessionKey:s||o,lastActiveSessionKey:i||o},l=r.sessionKey!==e.settings.sessionKey||r.lastActiveSessionKey!==e.settings.lastActiveSessionKey;o!==e.sessionKey&&(e.sessionKey=o),l&&Ie(e,r)}function Te(e){e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;const t=e.setup||e.filesPage||e.browserPage?"setup-ui":"taskmaster-control-ui";e.client?.stop(),e.client=new lv({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:t,mode:"webchat",onHello:n=>{e.connected=!0,e.lastError=null,e.hello=n,kv(e,n),e.handleAccessCheck(),gv(e),_c(e),nv(e),(e.chatPage||e.setup)&&Sv(e),Xi(e,{quiet:!0}),Yi(e,{quiet:!0}),rn(e).then(()=>{e.initWorkspaceSelection()}),e.setup&&(we(e),Av(e)),oo(e)},onClose:({code:n,reason:s})=>{e.connected=!1,n!==1012&&(e.lastError=`disconnected (${n}): ${s||"no reason"}`)},onEvent:n=>bv(e,n),onGap:({expected:n,received:s})=>{e.lastError=`event gap detected (expected seq ${n}, got ${s}); refresh recommended`}}),e.client.start()}function bv(e,t){try{wv(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function wv(e,t){if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),e.tab==="debug"&&(e.eventLog=e.eventLogBuffer),t.event==="agent"){if(e.onboarding)return;Qu(e,t.payload);return}if(t.event==="chat"){const n=t.payload;n?.sessionKey&&pl(e,n.sessionKey);const s=Ba(e,n);(s==="final"||s==="error"||s==="aborted")&&(Ki(e),$p(e)),s==="final"&&Ce(e);return}if(t.event==="presence"){const n=t.payload;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"&&e.tab==="cron"&&ro(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&Yi(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=cv(t.payload);if(n){e.execApprovalQueue=dv(e.execApprovalQueue,n),e.execApprovalError=null;const s=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=va(e.execApprovalQueue,n.id)},s)}return}if(t.event==="browser.screencast.frame"){Cy(e,t.payload);return}if(t.event==="browser.handoff"){_y(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){My(e);return}if(t.event==="exec.approval.resolved"){const n=uv(t.payload);n&&(e.execApprovalQueue=va(e.execApprovalQueue,n.id));return}if(t.event==="update.progress"){fv(e,t.payload);return}}function kv(e,t){const n=t.snapshot;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n?.health&&(e.debugHealth=n.health),n?.sessionDefaults&&vv(e,n.sessionDefaults)}async function Sv(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("models.list",{});Array.isArray(t?.models)&&(e.chatModelCatalog=t.models)}catch{}}async function Av(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await Pi(e.client)}catch{}}function xv(e){e.basePath=hp();const t=De();if(Pp(t.accentColor),window.scrollTo(0,0),e.setup){document.title=`${t.name} Setup`,Te(e);return}if(e.filesPage){document.title=`${t.name} Files`,Te(e);return}if(e.browserPage){document.title=`${t.name} Browser`,Te(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,Te(e);return}if(e.customersPage){document.title=`${t.name} Customers`,Te(e);return}if(e.chatPage){document.title=`${t.name} Chat`,Te(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,Te(e);return}yp(e,!0),fp(e),gp(e),window.addEventListener("popstate",e.popStateHandler),up(e),Te(e),lp(e),e.tab==="logs"&&(e.logsSubTab==="session"?to(e):Ji(e)),e.tab==="debug"&&so(e)}function $v(e){nd(e)}function Ev(e){window.removeEventListener("popstate",e.popStateHandler),cp(e),eo(e),no(e),io(e),mp(e),e.topbarObserver?.disconnect(),e.topbarObserver=null}function Tv(e,t){if(e.filesPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleFilesLoad&&e.handleFilesLoad(),e.adminsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdminsLoad&&e.handleAdminsLoad(),e.customersPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleCustomersLoad&&e.handleCustomersLoad(),e.chatPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleChatLoad&&e.handleChatLoad(),e.advancedPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleAdvancedLoad&&e.handleAdvancedLoad(),e.setup&&e.connected){const n=t.has("connected")&&t.get("connected")===!1;n&&e.handleLicenseStatusCheck&&e.licenseValid===null&&!e.licenseBusy&&e.handleLicenseStatusCheck(),n&&e.handleUpdateCheck&&e.handleUpdateCheck();const s=t.has("setupStep")&&e.setupStep==="auth";(n||s)&&e.setupStep==="auth"&&(e.authConnected===!0?e.setupStep="whatsapp":e.handleAuthStatusCheck&&e.authConnected===null&&!e.authBusy&&e.handleAuthStatusCheck()),e.setupStep==="whatsapp"&&t.has("setupStep")&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(o=>{e.channelsSnapshot=o,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1})),t.has("whatsappLoginConnected")&&e.whatsappLoginConnected===!0&&e.client&&!e.channelsLoading&&(e.channelsLoading=!0,e.client.request("channels.status",{probe:!0,timeoutMs:8e3}).then(i=>{e.channelsSnapshot=i,e.channelsLoading=!1}).catch(()=>{e.channelsLoading=!1}))}if(e.tab==="chat"&&!e.advancedPage&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),s=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;en(e,n||s||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&Fa(e,t.has("tab")||t.has("logsAutoFollow"))}function Cv(e){const t={name:e?.name??"",displayName:e?.displayName??"",about:e?.about??"",picture:e?.picture??"",banner:e?.banner??"",website:e?.website??"",nip05:e?.nip05??"",lud16:e?.lud16??""};return{values:t,original:{...t},saving:!1,importing:!1,error:null,success:null,fieldErrors:{},showAdvanced:!!(e?.banner||e?.website||e?.nip05||e?.lud16)}}async function _v(e,t,n){await zi(e,t,n),await z(e,!0)}async function Mv(e,t){await Ka(e,t),await z(e,!0)}async function Pv(e,t){await za(e,t),await z(e,!0)}async function Lv(e,t){await ja(e,t)}async function Rv(e,t){await Ha(e,t)}async function Iv(e){await od(e),await we(e),await z(e,!0)}async function Nv(e){await we(e),await z(e,!0)}function Ov(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[s,...i]=n.split(":");if(!s||i.length===0)continue;const o=s.trim(),r=i.join(":").trim();o&&r&&(t[o]=r)}return t}function Mc(e){return(e.channelsSnapshot?.channelAccounts?.nostr??[])[0]?.accountId??e.nostrProfileAccountId??"default"}function Pc(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function Dv(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=Cv(n??void 0)}function Bv(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function Fv(e,t,n){const s=e.nostrProfileFormState;s&&(e.nostrProfileFormState={...s,values:{...s.values,[t]:n},fieldErrors:{...s.fieldErrors,[t]:""}})}function Uv(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function Wv(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Mc(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const s=await fetch(Pc(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const o=i?.error??`Profile update failed (${s.status})`;e.nostrProfileFormState={...t,saving:!1,error:o,success:null,fieldErrors:Ov(i?.details)};return}if(!i.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await z(e,!0)}catch(s){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(s)}`,success:null}}}async function Kv(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Mc(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const s=await fetch(Pc(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const a=i?.error??`Profile import failed (${s.status})`;e.nostrProfileFormState={...t,importing:!1,error:a,success:null};return}const o=i.merged??i.imported??null,r=o?{...t.values,...o}:t.values,l=!!(r.banner||r.website||r.nip05||r.lud16);e.nostrProfileFormState={...t,importing:!1,values:r,error:null,success:i.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:l},i.saved&&await z(e,!0)}catch(s){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(s)}`,success:null}}}async function zv(e){if(e.client){e.authBusy=!0,e.authMessage=null;try{const t=await e.client.request("auth.status",{});e.authConnected=t.connected,e.authExpiresIn=t.expiresIn??null,e.authMessage=t.message??null,t.connected&&(e.setupStep="whatsapp")}catch(t){e.authConnected=!1,e.authMessage=t instanceof Error?t.message:"Failed to check auth status"}finally{e.authBusy=!1}}}async function jv(e){if(e.client){e.authBusy=!0,e.authMessage=null,e.authUrl=null,e.authConnected=null;try{const t=await e.client.request("auth.oauth.start",{provider:"anthropic"});e.authUrl=t.authUrl,e.authMessage=t.message??"Sign in with your Claude Pro account"}catch(t){e.authConnected=!1,e.authMessage=t instanceof Error?t.message:"Failed to start auth flow"}finally{e.authBusy=!1}}}async function Hv(e,t){if(e.client){e.authBusy=!0,e.authMessage="Verifying code...";try{await e.client.request("auth.oauth.code",{code:t});const n=await e.client.request("auth.oauth.wait",{timeoutMs:3e4});n.connected?(e.authConnected=!0,e.authMessage=n.message??"Connected to Claude!",e.authUrl=null,e.authCodeInput="",setTimeout(()=>{e.setupStep="whatsapp"},1500)):e.authMessage=n.message??"Still waiting for authorization..."}catch(n){e.authConnected=!1,e.authMessage=n instanceof Error?n.message:"Verification failed"}finally{e.authBusy=!1}}}function qv(e,t){e.authCodeInput=t}function Gv(e){e.setupStep="whatsapp"}async function Vv(e){if(e.client){e.licenseBusy=!0,e.licenseMessage=null;try{const t=await e.client.request("license.status",{});e.licenseDeviceId=t.deviceId??null,e.licenseStoredKey=t.key??null,t.licensed?(e.licenseValid=!0,e.licenseTier=t.tier??null,e.setupStep="auth"):(e.licenseValid=null,e.setupStep="license")}catch(t){const n=t instanceof Error?t.message:String(t);n.includes("unknown method")?(e.licenseValid=!0,e.setupStep="auth"):(e.licenseValid=null,e.licenseMessage=n,e.setupStep="license")}finally{e.licenseBusy=!1}}}async function Qv(e){if(e.client&&e.licenseKey.trim()){e.licenseBusy=!0,e.licenseMessage=null,e.licenseValid=null;try{const t=await e.client.request("license.activate",{key:e.licenseKey.trim()});t.valid?(e.licenseValid=!0,e.licenseMessage=t.message??"License activated",e.licenseTier=t.tier??null,setTimeout(()=>{e.setupStep="auth"},1500)):(e.licenseValid=!1,e.licenseMessage=t.message??"Invalid license key")}catch(t){e.licenseValid=!1,e.licenseMessage=t instanceof Error?t.message:"Activation failed"}finally{e.licenseBusy=!1}}}async function Yv(e){if(e.client){e.licenseBusy=!0;try{await e.client.request("license.remove",{}),e.licenseValid=null,e.licenseKey="",e.licenseTier=null,e.licenseMessage=null,e.setupStep="license"}catch(t){e.licenseMessage=t instanceof Error?t.message:"Failed to remove license"}finally{e.licenseBusy=!1}}}function Xv(e,t){e.licenseKey=t}async function Zv(e){if(!(!e.client||!e.connected)&&!e.gatewayHealthLoading){e.gatewayHealthLoading=!0,e.requestUpdate?.();try{const t=await e.client.request("health",{probe:!0});e.gatewayHealthy=t.ok===!0,e.gatewayHealthMessage=t.ok?`Healthy${t.durationMs?` (${t.durationMs}ms)`:""}`:"Unhealthy"}catch(t){e.gatewayHealthy=!1,e.gatewayHealthMessage=`Error: ${String(t)}`}finally{e.gatewayHealthLoading=!1,e.requestUpdate?.()}}}async function Jv(e){if(!(!e.client||e.gatewayRestartBusy)){e.gatewayRestartBusy=!0,e.gatewayHealthMessage="Restarting...",e.requestUpdate?.();try{const t=await e.client.request("gateway.restart",{reason:"Manual restart from setup page",delayMs:1e3});if(t.ok&&t.restart?.ok)e.gatewayHealthMessage="Restarting...",setTimeout(()=>{window.location.reload()},3e3);else throw new Error("Restart not scheduled")}catch(t){e.gatewayHealthMessage=`Restart failed: ${String(t)}`,e.gatewayRestartBusy=!1,e.requestUpdate?.()}}}var eb=Object.defineProperty,tb=Object.getOwnPropertyDescriptor,f=(e,t,n,s)=>{for(var i=s>1?void 0:s?tb(t,n):t,o=e.length-1,r;o>=0;o--)(r=e[o])&&(i=(s?r(t,n,i):r(i))||i);return s&&i&&eb(t,n,i),i};const oi=yu();function nb(){if(!window.location.search)return!1;const t=new URLSearchParams(window.location.search).get("onboarding");if(!t)return!1;const n=t.trim().toLowerCase();return n==="1"||n==="true"||n==="yes"||n==="on"}function sb(){const e=window.location.pathname;if(e==="/setup"||e.endsWith("/setup"))return!0;if(!window.location.search)return!1;const n=new URLSearchParams(window.location.search).get("setup");if(!n)return!1;const s=n.trim().toLowerCase();return s==="1"||s==="true"||s==="yes"||s==="on"}function ib(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function ob(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function rb(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function ab(){const e=window.location.pathname;return e==="/customers"||e.endsWith("/customers")}function lb(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function cb(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let h=class extends mt{constructor(){super(...arguments),this.settings=Ms(),this.password="",this.tab="chat",this.onboarding=nb(),this.setup=sb(),this.filesPage=ib(),this.browserPage=ob(),this.adminsPage=rb(),this.customersPage=ab(),this.chatPage=lb(),this.advancedPage=cb(),this.advancedTab="cron",this.connected=!1,this.accessState=hc,this.theme=this.settings.theme??"system",this.themeResolved="dark",this.hello=null,this.lastError=null,this.eventLog=[],this.eventLogBuffer=[],this.toolStreamSyncTimer=null,this.sidebarCloseTimer=null,this.assistantName=oi.name,this.assistantAvatar=oi.avatar,this.assistantAgentId=oi.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatToolMessages=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.chatModelProvider=null,this.chatModel=null,this.chatModelCatalog=[],this.chatVerboseLevel=null,this.chatFillerEnabled=null,this.chatQueue=[],this.chatAttachments=[],this.sidebarOpen=!1,this.sidebarContent=null,this.sidebarError=null,this.splitRatio=this.settings.splitRatio,this.nodesLoading=!1,this.nodes=[],this.devicesLoading=!1,this.devicesError=null,this.devicesList=null,this.execApprovalsLoading=!1,this.execApprovalsSaving=!1,this.execApprovalsDirty=!1,this.execApprovalsSnapshot=null,this.execApprovalsForm=null,this.execApprovalsSelectedAgent=null,this.execApprovalsTarget="gateway",this.execApprovalsTargetNodeId=null,this.execApprovalQueue=[],this.execApprovalBusy=!1,this.execApprovalError=null,this.configLoading=!1,this.configRaw=`{
2767
2781
  }
2768
- `,this.configRawOriginal="",this.configValid=null,this.configIssues=[],this.configSaving=!1,this.configApplying=!1,this.updateRunning=!1,this.applySessionKey=this.settings.lastActiveSessionKey,this.configSnapshot=null,this.configSchema=null,this.configSchemaVersion=null,this.configSchemaLoading=!1,this.configUiHints={},this.configForm=null,this.configFormOriginal=null,this.configFormDirty=!1,this.configFormMode="form",this.configSearchQuery="",this.configActiveSection=null,this.configActiveSubsection=null,this.channelsLoading=!1,this.channelsSnapshot=null,this.channelsError=null,this.channelsLastSuccess=null,this.whatsappLoginMessage=null,this.whatsappLoginQrDataUrl=null,this.whatsappLoginConnected=null,this.whatsappBusy=!1,this.whatsappActiveQrAccountId=null,this.whatsappPairedPhone=null,this.addingWhatsAppAccount=!1,this.newWhatsAppAccountName="",this.whatsappAccountError=null,this.whatsappAccountSaving=!1,this.whatsappSettingsOpen=!1,this.licenseKey="",this.licenseBusy=!1,this.licenseValid=null,this.licenseMessage=null,this.licenseTier=null,this.licenseDeviceId=null,this.licenseStoredKey=null,this.licenseRemoveConfirm=!1,this.authConnected=null,this.authBusy=!1,this.authMessage=null,this.authUrl=null,this.authCodeInput="",this.authExpiresIn=null,this.setupStep="license",this.gatewayHealthy=null,this.gatewayHealthLoading=!1,this.gatewayHealthMessage=null,this.gatewayRestartBusy=!1,this.updateAvailable=null,this.currentVersion=null,this.latestVersion=null,this.updateChecking=!1,this.updateMessage=null,this.updateProgressSteps=[],this.updateLastResult=null,this.nostrProfileFormState=null,this.nostrProfileAccountId=null,this.presenceLoading=!1,this.presenceEntries=[],this.presenceError=null,this.presenceStatus=null,this.agentsLoading=!1,this.agentsList=null,this.agentsError=null,this.sessionsLoading=!1,this.sessionsResult=null,this.sessionsError=null,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...nv},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=null,this.browserScreencastActive=!1,this.browserScreencastFrame=null,this.browserScreencastMetadata=null,this.browserHandoffPending=!1,this.browserHandoffReason=null,this.browserHandoffId=null,this.browserInputMode=!1,this.browserLoading=!1,this.browserError=null,this.filesLoading=!1,this.filesTree=[],this.filesRoot="",this.filesError=null,this.filesSelectedPath=null,this.filesSelectedPaths=new Set,this.filesPreviewContent=null,this.filesPreviewLoading=!1,this.filesPreviewBinary=!1,this.filesPreviewSize=null,this.filesExpandedDirs=new Set,this.filesMessage=null,this.filesUploadBusy=!1,this.filesReindexBusy=!1,this.filesMemoryStatus=null,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.adminsLoading=!1,this.adminPhones=[],this.adminsError=null,this.adminsSaving=!1,this.adminsNewPhone="",this.customersLoading=!1,this.customersSaving=!1,this.customersRecords=[],this.customersError=null,this.customersSearchQuery="",this.customersEditingId=null,this.customersShowAddForm=!1,this.customersNewPhone="",this.customersNewName="",this.imessageEnableConfirm=!1,this.imessageEnabling=!1,this.infoModalOpen=null,this.workspaces=[],this.workspacesLoading=!1,this.workspacesError=null,this.selectedWorkspace=null,this.addingWorkspace=!1,this.newWorkspaceName="",this.newWorkspacePath="",this.newWorkspacePin="",this.accountPinModalOpen=!1,this.accountPinBusy=!1,this.accountPinError=null,this.accountPinSuccess=null,this.apiKeyProviders=[],this.apiKeyModalOpen=!1,this.apiKeyBusy=!1,this.apiKeyError=null,this.apiKeySuccess=null,this.authApiKeyMode=!1,this.authApiKeyInput="",this.authApiKeyBusy=!1,this.authApiKeyError=null,this.pinChanging=null,this.pinChangeBusy=!1,this.pinChangeError=null,this.loginChangePinMode=!1,this.changePinBusy=!1,this.changePinError=null,this.changePinSuccess=null,this.workspaceSaving=!1,this.workspaceRemoveConfirm=null,this.renamingWorkspace=!1,this.renameWorkspaceName="",this.debugLoading=!1,this.debugStatus=null,this.debugHealth=null,this.debugModels=[],this.debugHeartbeat=null,this.debugCallMethod="",this.debugCallParams="{}",this.debugCallResult=null,this.debugCallError=null,this.logsLoading=!1,this.logsError=null,this.logsFile=null,this.logsEntries=[],this.logsFilterText="",this.logsLevelFilters={...tv},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.logsSubTab="session",this.sessionLogsLoading=!1,this.sessionLogsError=null,this.sessionLogsEntries=[],this.sessionLogsFilterText="",this.sessionLogsTypeFilters={user:!0,assistant:!0,tool:!0,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.sessionLogsFull=!1,this.sessionLogsCursors={},this.sessionLogsLastFetchAt=null,this.sessionLogsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.nodesPollInterval=null,this.logsPollInterval=null,this.sessionLogsPollInterval=null,this.debugPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>vp(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),$v(this)}firstUpdated(){Ev(this)}disconnectedCallback(){Tv(this),super.disconnectedCallback()}updated(e){Cv(this,e)}connect(){Te(this)}handleChatScroll(e){Yu(this,e)}handleLogsScroll(e){Xu(this,e)}handleSessionLogsScroll(e){Zu(this,e)}exportLogs(e,t){ed(e,t)}exportSessionLogs(e,t){td(e,t)}resetToolStream(){Ki(this)}resetChatScroll(){Ju(this)}async loadAssistantIdentity(){await _c(this)}applySettings(e){Ie(this,e)}setTab(e){dp(this,e)}setTheme(e,t){pp(this,e,t)}async loadOverview(){await fl(this)}async loadCron(){const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=e?.agents?.map(t=>t.id)??void 0,this.cronForm={...this.cronForm,accountId:e?.whatsappAccountId??void 0},await ro(this)}async handleAbortChat(){await ml(this)}removeQueuedMessage(e){Sp(this,e)}async handleSendChat(e,t){await Ap(this,e,t)}async handleWhatsAppStart(e,t){await Mv(this,e,t)}async handleWhatsAppWait(e){await Pv(this,e)}async handleWhatsAppLogout(e){await Lv(this,e)}async handleAddWhatsAppAccount(e){await Rv(this,e)}async handleRemoveWhatsAppAccount(e){await Iv(this,e)}async handleAccessCheck(){await fa(this)}async handlePinSubmit(e,t){await by(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await wy(this,e)}async handleLogout(){await Sy(this)}toggleChangePinMode(){this.loginChangePinMode=!this.loginChangePinMode,this.changePinError=null,this.changePinSuccess=null}async handleChangePin(e,t,n){if(this.client){this.changePinBusy=!0,this.changePinError=null,this.changePinSuccess=null;try{const s=await this.client.request("access.verify",{account:e,pin:t});if(!s.ok){this.changePinError=s.message??"Incorrect current PIN",this.changePinBusy=!1;return}e==="__master__"?await this.client.request("access.setMasterPin",{pin:n}):await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.changePinSuccess="PIN changed successfully",this.changePinBusy=!1,setTimeout(()=>{this.loginChangePinMode=!1,this.changePinSuccess=null},2e3)}catch{this.changePinError="Failed to change PIN",this.changePinBusy=!1}}}async handleAccountPinSave(e,t,n){if(this.client){this.accountPinBusy=!0,this.accountPinError=null,this.accountPinSuccess=null;try{if(t!==null){const s=await this.client.request("access.verify",{account:e,pin:t});if(!s.ok){this.accountPinError=s.message??"Incorrect current PIN",this.accountPinBusy=!1;return}}await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.accountPinSuccess="PIN saved",this.accountPinBusy=!1,await fa(this),setTimeout(()=>{this.accountPinModalOpen=!1,this.accountPinSuccess=null,this.accountPinError=null},1500)}catch{this.accountPinError="Failed to save PIN",this.accountPinBusy=!1}}}async handleLicenseStatusCheck(){await Qv(this)}async handleLicenseActivate(){await Yv(this)}async handleLicenseRemove(){await Xv(this)}handleLicenseKeyChange(e){Zv(this,e)}async handleAuthStatusCheck(){await jv(this)}async handleAuthStart(){await Hv(this)}async handleAuthSubmitCode(e){await qv(this,e)}handleAuthCodeChange(e){Gv(this,e)}handleSkipToWhatsApp(){Vv(this)}async handleGatewayHealthCheck(){await Jv(this)}async handleGatewayRestart(){await eb(this)}async handleUpdateCheck(){await hv(this)}async handleUpdateRun(){await fv(this)}handleUpdateDismissResult(){yv(this)}handleFilesLoad(){const e=this.resolveFilesAgentId();on(this,e),bc(this,e)}handleAdminsLoad(){const e=this.resolveAdminAgentId();$e(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>Wy);return{loadAdmins:t}},void 0,import.meta.url).then(({loadAdmins:t})=>{t(this,e)})}resolveAdminAgentId(){const e=this.getSelectedWorkspaceInfo();return e?e.agents.find(n=>n.id.endsWith("-admin")||n.id==="admin")?.id:void 0}resolveFilesAgentId(){const e=this.getSelectedWorkspaceInfo();if(e)return e.agents[0]?.id}handleChatLoad(){const e=this.resolveAdminAgentId();if(e){const t=`agent:${e}:main`;t!==this.sessionKey&&(this.sessionKey=t,this.chatMessages=[],this.chatStream=null,this.chatRunId=null,this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}$e(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>Fu);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this)})}handleAdvancedLoad(){this.loadCron()}async handleChannelConfigSave(){await Nv(this)}async handleChannelConfigReload(){await Ov(this)}handleNostrProfileEdit(e,t){Bv(this,e,t)}handleNostrProfileCancel(){Fv(this)}handleNostrProfileFieldChange(e,t){Uv(this,e,t)}async handleNostrProfileSave(){await Kv(this)}async handleNostrProfileImport(){await zv(this)}handleNostrProfileToggleAdvanced(){Wv(this)}async handleExecApprovalDecision(e){const t=this.execApprovalQueue[0];if(!(!t||!this.client||this.execApprovalBusy)){this.execApprovalBusy=!0,this.execApprovalError=null;try{await this.client.request("exec.approval.resolve",{id:t.id,decision:e}),this.execApprovalQueue=this.execApprovalQueue.filter(n=>n.id!==t.id)}catch(n){this.execApprovalError=`Exec approval failed: ${String(n)}`}finally{this.execApprovalBusy=!1}}}handleOpenSidebar(e){this.sidebarCloseTimer!=null&&(window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=null),this.sidebarContent=e,this.sidebarError=null,this.sidebarOpen=!0}handleCloseSidebar(){this.sidebarOpen=!1,this.sidebarCloseTimer!=null&&window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=window.setTimeout(()=>{this.sidebarOpen||(this.sidebarContent=null,this.sidebarError=null,this.sidebarCloseTimer=null)},200)}handleSplitRatioChange(e){const t=Math.max(.4,Math.min(.7,e));this.splitRatio=t,this.applySettings({...this.settings,splitRatio:t})}handleAdminsNewPhoneChange(e){this.adminsNewPhone=e,this.adminsError&&(this.adminsError=null)}handleCustomersLoad(){const e=this.selectedWorkspace??void 0;$e(async()=>{const{loadCustomers:t}=await Promise.resolve().then(()=>Ky);return{loadCustomers:t}},void 0,import.meta.url).then(({loadCustomers:t})=>{t(this,e)})}handleCustomersNewPhoneChange(e){this.customersNewPhone=e,this.customersError&&(this.customersError=null)}handleCustomersNewNameChange(e){this.customersNewName=e,this.customersError&&(this.customersError=null)}async handleWorkspacesLoad(){const{loadWorkspaces:e}=await $e(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>Ln);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await $e(async()=>{const{createWorkspace:i}=await Promise.resolve().then(()=>Ln);return{createWorkspace:i}},void 0,import.meta.url),{loadChannels:s}=await $e(async()=>{const{loadChannels:i}=await Promise.resolve().then(()=>pd);return{loadChannels:i}},void 0,import.meta.url);await n(this,{name:e,workspacePath:t,onCreated:i=>{if(!i.whatsappAccountId)return;const o=i.whatsappAccountId;this.handleWorkspaceSelect(e),setTimeout(async()=>{try{await s(this,!0),await this.handleWhatsAppStart(!0,o),this.whatsappLoginQrDataUrl&&(await this.handleWhatsAppWait(o),await s(this,!0),await this.handleWorkspacesLoad())}catch{}this.requestUpdate()},3e3)}})}async handleWorkspaceRemove(e){const{removeWorkspace:t}=await $e(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>Ln);return{removeWorkspace:n}},void 0,import.meta.url);await t(this,e)}handleWorkspaceRenameStart(){const e=this.getSelectedWorkspaceInfo();this.renameWorkspaceName=e?.displayName??e?.name??"",this.renamingWorkspace=!0}handleWorkspaceRenameCancel(){this.renamingWorkspace=!1,this.renameWorkspaceName=""}async handleWorkspaceRename(e,t){const{renameWorkspace:n}=await $e(async()=>{const{renameWorkspace:s}=await Promise.resolve().then(()=>Ln);return{renameWorkspace:s}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){this.selectedWorkspace=e,localStorage.setItem("taskmaster-selected-workspace",e),sr(e),this.settings=Ms(),this.chatMessage="",this.chatAttachments=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.chatQueue=[],this.lastError=null,this.reloadCurrentPageData()}getSelectedWorkspaceInfo(){return this.selectedWorkspace?this.workspaces.find(e=>e.name===this.selectedWorkspace)??null:null}reloadCurrentPageData(){this.adminsPage?this.handleAdminsLoad():this.customersPage?this.handleCustomersLoad():this.filesPage?this.handleFilesLoad():this.chatPage?this.handleChatLoad():this.advancedPage&&this.handleAdvancedLoad()}initWorkspaceSelection(){if(this.workspaces.length===0)return;const e=localStorage.getItem("taskmaster-selected-workspace"),t=e?this.workspaces.find(n=>n.name===e):null;if(t)this.selectedWorkspace=t.name;else{const n=this.workspaces.find(s=>s.isDefault)??this.workspaces[0];this.selectedWorkspace=n.name,localStorage.setItem("taskmaster-selected-workspace",n.name)}sr(this.selectedWorkspace),this.settings=Ms(),this.reloadCurrentPageData()}render(){return ev(this)}};f([g()],h.prototype,"settings",2);f([g()],h.prototype,"password",2);f([g()],h.prototype,"tab",2);f([g()],h.prototype,"onboarding",2);f([g()],h.prototype,"setup",2);f([g()],h.prototype,"filesPage",2);f([g()],h.prototype,"browserPage",2);f([g()],h.prototype,"adminsPage",2);f([g()],h.prototype,"customersPage",2);f([g()],h.prototype,"chatPage",2);f([g()],h.prototype,"advancedPage",2);f([g()],h.prototype,"advancedTab",2);f([g()],h.prototype,"connected",2);f([g()],h.prototype,"accessState",2);f([g()],h.prototype,"theme",2);f([g()],h.prototype,"themeResolved",2);f([g()],h.prototype,"hello",2);f([g()],h.prototype,"lastError",2);f([g()],h.prototype,"eventLog",2);f([g()],h.prototype,"assistantName",2);f([g()],h.prototype,"assistantAvatar",2);f([g()],h.prototype,"assistantAgentId",2);f([g()],h.prototype,"sessionKey",2);f([g()],h.prototype,"chatLoading",2);f([g()],h.prototype,"chatSending",2);f([g()],h.prototype,"chatMessage",2);f([g()],h.prototype,"chatMessages",2);f([g()],h.prototype,"chatToolMessages",2);f([g()],h.prototype,"chatStream",2);f([g()],h.prototype,"chatStreamStartedAt",2);f([g()],h.prototype,"chatRunId",2);f([g()],h.prototype,"compactionStatus",2);f([g()],h.prototype,"chatAvatarUrl",2);f([g()],h.prototype,"chatThinkingLevel",2);f([g()],h.prototype,"chatModelProvider",2);f([g()],h.prototype,"chatModel",2);f([g()],h.prototype,"chatModelCatalog",2);f([g()],h.prototype,"chatVerboseLevel",2);f([g()],h.prototype,"chatFillerEnabled",2);f([g()],h.prototype,"chatQueue",2);f([g()],h.prototype,"chatAttachments",2);f([g()],h.prototype,"sidebarOpen",2);f([g()],h.prototype,"sidebarContent",2);f([g()],h.prototype,"sidebarError",2);f([g()],h.prototype,"splitRatio",2);f([g()],h.prototype,"nodesLoading",2);f([g()],h.prototype,"nodes",2);f([g()],h.prototype,"devicesLoading",2);f([g()],h.prototype,"devicesError",2);f([g()],h.prototype,"devicesList",2);f([g()],h.prototype,"execApprovalsLoading",2);f([g()],h.prototype,"execApprovalsSaving",2);f([g()],h.prototype,"execApprovalsDirty",2);f([g()],h.prototype,"execApprovalsSnapshot",2);f([g()],h.prototype,"execApprovalsForm",2);f([g()],h.prototype,"execApprovalsSelectedAgent",2);f([g()],h.prototype,"execApprovalsTarget",2);f([g()],h.prototype,"execApprovalsTargetNodeId",2);f([g()],h.prototype,"execApprovalQueue",2);f([g()],h.prototype,"execApprovalBusy",2);f([g()],h.prototype,"execApprovalError",2);f([g()],h.prototype,"configLoading",2);f([g()],h.prototype,"configRaw",2);f([g()],h.prototype,"configRawOriginal",2);f([g()],h.prototype,"configValid",2);f([g()],h.prototype,"configIssues",2);f([g()],h.prototype,"configSaving",2);f([g()],h.prototype,"configApplying",2);f([g()],h.prototype,"updateRunning",2);f([g()],h.prototype,"applySessionKey",2);f([g()],h.prototype,"configSnapshot",2);f([g()],h.prototype,"configSchema",2);f([g()],h.prototype,"configSchemaVersion",2);f([g()],h.prototype,"configSchemaLoading",2);f([g()],h.prototype,"configUiHints",2);f([g()],h.prototype,"configForm",2);f([g()],h.prototype,"configFormOriginal",2);f([g()],h.prototype,"configFormDirty",2);f([g()],h.prototype,"configFormMode",2);f([g()],h.prototype,"configSearchQuery",2);f([g()],h.prototype,"configActiveSection",2);f([g()],h.prototype,"configActiveSubsection",2);f([g()],h.prototype,"channelsLoading",2);f([g()],h.prototype,"channelsSnapshot",2);f([g()],h.prototype,"channelsError",2);f([g()],h.prototype,"channelsLastSuccess",2);f([g()],h.prototype,"whatsappLoginMessage",2);f([g()],h.prototype,"whatsappLoginQrDataUrl",2);f([g()],h.prototype,"whatsappLoginConnected",2);f([g()],h.prototype,"whatsappBusy",2);f([g()],h.prototype,"whatsappActiveQrAccountId",2);f([g()],h.prototype,"whatsappPairedPhone",2);f([g()],h.prototype,"addingWhatsAppAccount",2);f([g()],h.prototype,"newWhatsAppAccountName",2);f([g()],h.prototype,"whatsappAccountError",2);f([g()],h.prototype,"whatsappAccountSaving",2);f([g()],h.prototype,"whatsappSettingsOpen",2);f([g()],h.prototype,"licenseKey",2);f([g()],h.prototype,"licenseBusy",2);f([g()],h.prototype,"licenseValid",2);f([g()],h.prototype,"licenseMessage",2);f([g()],h.prototype,"licenseTier",2);f([g()],h.prototype,"licenseDeviceId",2);f([g()],h.prototype,"licenseStoredKey",2);f([g()],h.prototype,"licenseRemoveConfirm",2);f([g()],h.prototype,"authConnected",2);f([g()],h.prototype,"authBusy",2);f([g()],h.prototype,"authMessage",2);f([g()],h.prototype,"authUrl",2);f([g()],h.prototype,"authCodeInput",2);f([g()],h.prototype,"authExpiresIn",2);f([g()],h.prototype,"setupStep",2);f([g()],h.prototype,"gatewayHealthy",2);f([g()],h.prototype,"gatewayHealthLoading",2);f([g()],h.prototype,"gatewayHealthMessage",2);f([g()],h.prototype,"gatewayRestartBusy",2);f([g()],h.prototype,"updateAvailable",2);f([g()],h.prototype,"currentVersion",2);f([g()],h.prototype,"latestVersion",2);f([g()],h.prototype,"updateChecking",2);f([g()],h.prototype,"updateMessage",2);f([g()],h.prototype,"updateProgressSteps",2);f([g()],h.prototype,"updateLastResult",2);f([g()],h.prototype,"nostrProfileFormState",2);f([g()],h.prototype,"nostrProfileAccountId",2);f([g()],h.prototype,"presenceLoading",2);f([g()],h.prototype,"presenceEntries",2);f([g()],h.prototype,"presenceError",2);f([g()],h.prototype,"presenceStatus",2);f([g()],h.prototype,"agentsLoading",2);f([g()],h.prototype,"agentsList",2);f([g()],h.prototype,"agentsError",2);f([g()],h.prototype,"sessionsLoading",2);f([g()],h.prototype,"sessionsResult",2);f([g()],h.prototype,"sessionsError",2);f([g()],h.prototype,"cronLoading",2);f([g()],h.prototype,"cronJobs",2);f([g()],h.prototype,"cronStatus",2);f([g()],h.prototype,"cronError",2);f([g()],h.prototype,"cronForm",2);f([g()],h.prototype,"cronRunsJobId",2);f([g()],h.prototype,"cronRuns",2);f([g()],h.prototype,"cronBusy",2);f([g()],h.prototype,"cronNewEventModal",2);f([g()],h.prototype,"cronDetailJobId",2);f([g()],h.prototype,"browserScreencastActive",2);f([g()],h.prototype,"browserScreencastFrame",2);f([g()],h.prototype,"browserScreencastMetadata",2);f([g()],h.prototype,"browserHandoffPending",2);f([g()],h.prototype,"browserHandoffReason",2);f([g()],h.prototype,"browserHandoffId",2);f([g()],h.prototype,"browserInputMode",2);f([g()],h.prototype,"browserLoading",2);f([g()],h.prototype,"browserError",2);f([g()],h.prototype,"filesLoading",2);f([g()],h.prototype,"filesTree",2);f([g()],h.prototype,"filesRoot",2);f([g()],h.prototype,"filesError",2);f([g()],h.prototype,"filesSelectedPath",2);f([g()],h.prototype,"filesSelectedPaths",2);f([g()],h.prototype,"filesPreviewContent",2);f([g()],h.prototype,"filesPreviewLoading",2);f([g()],h.prototype,"filesPreviewBinary",2);f([g()],h.prototype,"filesPreviewSize",2);f([g()],h.prototype,"filesExpandedDirs",2);f([g()],h.prototype,"filesMessage",2);f([g()],h.prototype,"filesUploadBusy",2);f([g()],h.prototype,"filesReindexBusy",2);f([g()],h.prototype,"filesMemoryStatus",2);f([g()],h.prototype,"skillsLoading",2);f([g()],h.prototype,"skillsReport",2);f([g()],h.prototype,"skillsError",2);f([g()],h.prototype,"skillsFilter",2);f([g()],h.prototype,"skillEdits",2);f([g()],h.prototype,"skillsBusyKey",2);f([g()],h.prototype,"skillMessages",2);f([g()],h.prototype,"adminsLoading",2);f([g()],h.prototype,"adminPhones",2);f([g()],h.prototype,"adminsError",2);f([g()],h.prototype,"adminsSaving",2);f([g()],h.prototype,"adminsNewPhone",2);f([g()],h.prototype,"customersLoading",2);f([g()],h.prototype,"customersSaving",2);f([g()],h.prototype,"customersRecords",2);f([g()],h.prototype,"customersError",2);f([g()],h.prototype,"customersSearchQuery",2);f([g()],h.prototype,"customersEditingId",2);f([g()],h.prototype,"customersShowAddForm",2);f([g()],h.prototype,"customersNewPhone",2);f([g()],h.prototype,"customersNewName",2);f([g()],h.prototype,"imessageEnableConfirm",2);f([g()],h.prototype,"imessageEnabling",2);f([g()],h.prototype,"infoModalOpen",2);f([g()],h.prototype,"workspaces",2);f([g()],h.prototype,"workspacesLoading",2);f([g()],h.prototype,"workspacesError",2);f([g()],h.prototype,"selectedWorkspace",2);f([g()],h.prototype,"addingWorkspace",2);f([g()],h.prototype,"newWorkspaceName",2);f([g()],h.prototype,"newWorkspacePath",2);f([g()],h.prototype,"newWorkspacePin",2);f([g()],h.prototype,"accountPinModalOpen",2);f([g()],h.prototype,"accountPinBusy",2);f([g()],h.prototype,"accountPinError",2);f([g()],h.prototype,"accountPinSuccess",2);f([g()],h.prototype,"apiKeyProviders",2);f([g()],h.prototype,"apiKeyModalOpen",2);f([g()],h.prototype,"apiKeyBusy",2);f([g()],h.prototype,"apiKeyError",2);f([g()],h.prototype,"apiKeySuccess",2);f([g()],h.prototype,"authApiKeyMode",2);f([g()],h.prototype,"authApiKeyInput",2);f([g()],h.prototype,"authApiKeyBusy",2);f([g()],h.prototype,"authApiKeyError",2);f([g()],h.prototype,"pinChanging",2);f([g()],h.prototype,"pinChangeBusy",2);f([g()],h.prototype,"pinChangeError",2);f([g()],h.prototype,"loginChangePinMode",2);f([g()],h.prototype,"changePinBusy",2);f([g()],h.prototype,"changePinError",2);f([g()],h.prototype,"changePinSuccess",2);f([g()],h.prototype,"workspaceSaving",2);f([g()],h.prototype,"workspaceRemoveConfirm",2);f([g()],h.prototype,"renamingWorkspace",2);f([g()],h.prototype,"renameWorkspaceName",2);f([g()],h.prototype,"debugLoading",2);f([g()],h.prototype,"debugStatus",2);f([g()],h.prototype,"debugHealth",2);f([g()],h.prototype,"debugModels",2);f([g()],h.prototype,"debugHeartbeat",2);f([g()],h.prototype,"debugCallMethod",2);f([g()],h.prototype,"debugCallParams",2);f([g()],h.prototype,"debugCallResult",2);f([g()],h.prototype,"debugCallError",2);f([g()],h.prototype,"logsLoading",2);f([g()],h.prototype,"logsError",2);f([g()],h.prototype,"logsFile",2);f([g()],h.prototype,"logsEntries",2);f([g()],h.prototype,"logsFilterText",2);f([g()],h.prototype,"logsLevelFilters",2);f([g()],h.prototype,"logsAutoFollow",2);f([g()],h.prototype,"logsTruncated",2);f([g()],h.prototype,"logsCursor",2);f([g()],h.prototype,"logsLastFetchAt",2);f([g()],h.prototype,"logsLimit",2);f([g()],h.prototype,"logsMaxBytes",2);f([g()],h.prototype,"logsAtBottom",2);f([g()],h.prototype,"logsSubTab",2);f([g()],h.prototype,"sessionLogsLoading",2);f([g()],h.prototype,"sessionLogsError",2);f([g()],h.prototype,"sessionLogsEntries",2);f([g()],h.prototype,"sessionLogsFilterText",2);f([g()],h.prototype,"sessionLogsTypeFilters",2);f([g()],h.prototype,"sessionLogsAgentFilters",2);f([g()],h.prototype,"sessionLogsAgents",2);f([g()],h.prototype,"sessionLogsAutoFollow",2);f([g()],h.prototype,"sessionLogsFull",2);f([g()],h.prototype,"sessionLogsCursors",2);f([g()],h.prototype,"sessionLogsLastFetchAt",2);f([g()],h.prototype,"sessionLogsAtBottom",2);f([g()],h.prototype,"chatUserNearBottom",2);h=f([$a("taskmaster-app")],h);
2769
- //# sourceMappingURL=index-CII8VIT3.js.map
2782
+ `,this.configRawOriginal="",this.configValid=null,this.configIssues=[],this.configSaving=!1,this.configApplying=!1,this.updateRunning=!1,this.applySessionKey=this.settings.lastActiveSessionKey,this.configSnapshot=null,this.configSchema=null,this.configSchemaVersion=null,this.configSchemaLoading=!1,this.configUiHints={},this.configForm=null,this.configFormOriginal=null,this.configFormDirty=!1,this.configFormMode="form",this.configSearchQuery="",this.configActiveSection=null,this.configActiveSubsection=null,this.channelsLoading=!1,this.channelsSnapshot=null,this.channelsError=null,this.channelsLastSuccess=null,this.whatsappLoginMessage=null,this.whatsappLoginQrDataUrl=null,this.whatsappLoginConnected=null,this.whatsappBusy=!1,this.whatsappActiveQrAccountId=null,this.whatsappPairedPhone=null,this.addingWhatsAppAccount=!1,this.newWhatsAppAccountName="",this.whatsappAccountError=null,this.whatsappAccountSaving=!1,this.whatsappSettingsOpen=!1,this.licenseKey="",this.licenseBusy=!1,this.licenseValid=null,this.licenseMessage=null,this.licenseTier=null,this.licenseDeviceId=null,this.licenseStoredKey=null,this.licenseRemoveConfirm=!1,this.authConnected=null,this.authBusy=!1,this.authMessage=null,this.authUrl=null,this.authCodeInput="",this.authExpiresIn=null,this.setupStep="license",this.gatewayHealthy=null,this.gatewayHealthLoading=!1,this.gatewayHealthMessage=null,this.gatewayRestartBusy=!1,this.updateAvailable=null,this.currentVersion=null,this.latestVersion=null,this.updateChecking=!1,this.updateMessage=null,this.updateProgressSteps=[],this.updateLastResult=null,this.nostrProfileFormState=null,this.nostrProfileAccountId=null,this.presenceLoading=!1,this.presenceEntries=[],this.presenceError=null,this.presenceStatus=null,this.agentsLoading=!1,this.agentsList=null,this.agentsError=null,this.sessionsLoading=!1,this.sessionsResult=null,this.sessionsError=null,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...tv},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=null,this.browserScreencastActive=!1,this.browserScreencastFrame=null,this.browserScreencastMetadata=null,this.browserHandoffPending=!1,this.browserHandoffReason=null,this.browserHandoffId=null,this.browserInputMode=!1,this.browserLoading=!1,this.browserError=null,this.filesLoading=!1,this.filesTree=[],this.filesRoot="",this.filesError=null,this.filesSelectedPath=null,this.filesSelectedPaths=new Set,this.filesPreviewContent=null,this.filesPreviewLoading=!1,this.filesPreviewBinary=!1,this.filesPreviewSize=null,this.filesExpandedDirs=new Set,this.filesMessage=null,this.filesUploadBusy=!1,this.filesReindexBusy=!1,this.filesMemoryStatus=null,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.adminsLoading=!1,this.adminPhones=[],this.adminsError=null,this.adminsSaving=!1,this.adminsNewPhone="",this.customersLoading=!1,this.customersSaving=!1,this.customersRecords=[],this.customersError=null,this.customersSearchQuery="",this.customersEditingId=null,this.customersShowAddForm=!1,this.customersNewPhone="",this.customersNewName="",this.imessageEnableConfirm=!1,this.imessageEnabling=!1,this.infoModalOpen=null,this.workspaces=[],this.workspacesLoading=!1,this.workspacesError=null,this.selectedWorkspace=null,this.addingWorkspace=!1,this.newWorkspaceName="",this.newWorkspacePath="",this.newWorkspacePin="",this.accountPinModalOpen=!1,this.accountPinBusy=!1,this.accountPinError=null,this.accountPinSuccess=null,this.apiKeyProviders=[],this.apiKeyModalOpen=!1,this.apiKeyBusy=!1,this.apiKeyError=null,this.apiKeySuccess=null,this.authApiKeyMode=!1,this.authApiKeyInput="",this.authApiKeyBusy=!1,this.authApiKeyError=null,this.pinChanging=null,this.pinChangeBusy=!1,this.pinChangeError=null,this.loginChangePinMode=!1,this.changePinBusy=!1,this.changePinError=null,this.changePinSuccess=null,this.workspaceSaving=!1,this.workspaceRemoveConfirm=null,this.renamingWorkspace=!1,this.renameWorkspaceName="",this.debugLoading=!1,this.debugStatus=null,this.debugHealth=null,this.debugModels=[],this.debugHeartbeat=null,this.debugCallMethod="",this.debugCallParams="{}",this.debugCallResult=null,this.debugCallError=null,this.logsLoading=!1,this.logsError=null,this.logsFile=null,this.logsEntries=[],this.logsFilterText="",this.logsLevelFilters={...ev},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.logsSubTab="session",this.sessionLogsLoading=!1,this.sessionLogsError=null,this.sessionLogsEntries=[],this.sessionLogsFilterText="",this.sessionLogsTypeFilters={user:!0,assistant:!0,tool:!0,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.sessionLogsFull=!1,this.sessionLogsCursors={},this.sessionLogsLastFetchAt=null,this.sessionLogsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.nodesPollInterval=null,this.logsPollInterval=null,this.sessionLogsPollInterval=null,this.debugPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>vp(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),xv(this)}firstUpdated(){$v(this)}disconnectedCallback(){Ev(this),super.disconnectedCallback()}updated(e){Tv(this,e)}connect(){Te(this)}handleChatScroll(e){Yu(this,e)}handleLogsScroll(e){Xu(this,e)}handleSessionLogsScroll(e){Zu(this,e)}exportLogs(e,t){ed(e,t)}exportSessionLogs(e,t){td(e,t)}resetToolStream(){Ki(this)}resetChatScroll(){Ju(this)}async loadAssistantIdentity(){await _c(this)}applySettings(e){Ie(this,e)}setTab(e){dp(this,e)}setTheme(e,t){pp(this,e,t)}async loadOverview(){await gl(this)}async loadCron(){const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=e?.agents?.map(t=>t.id)??void 0,this.cronForm={...this.cronForm,accountId:e?.whatsappAccountId??void 0},await ro(this)}async handleAbortChat(){await yl(this)}removeQueuedMessage(e){Sp(this,e)}async handleSendChat(e,t){await Ap(this,e,t)}async handleWhatsAppStart(e,t){await _v(this,e,t)}async handleWhatsAppWait(e){await Mv(this,e)}async handleWhatsAppLogout(e){await Pv(this,e)}async handleAddWhatsAppAccount(e){await Lv(this,e)}async handleRemoveWhatsAppAccount(e){await Rv(this,e)}async handleAccessCheck(){await ga(this)}async handlePinSubmit(e,t){await vy(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await by(this,e)}async handleLogout(){await ky(this)}toggleChangePinMode(){this.loginChangePinMode=!this.loginChangePinMode,this.changePinError=null,this.changePinSuccess=null}async handleChangePin(e,t,n){if(this.client){this.changePinBusy=!0,this.changePinError=null,this.changePinSuccess=null;try{const s=await this.client.request("access.verify",{account:e,pin:t});if(!s.ok){this.changePinError=s.message??"Incorrect current PIN",this.changePinBusy=!1;return}e==="__master__"?await this.client.request("access.setMasterPin",{pin:n}):await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.changePinSuccess="PIN changed successfully",this.changePinBusy=!1,setTimeout(()=>{this.loginChangePinMode=!1,this.changePinSuccess=null},2e3)}catch{this.changePinError="Failed to change PIN",this.changePinBusy=!1}}}async handleAccountPinSave(e,t,n){if(this.client){this.accountPinBusy=!0,this.accountPinError=null,this.accountPinSuccess=null;try{if(t!==null){const s=await this.client.request("access.verify",{account:e,pin:t});if(!s.ok){this.accountPinError=s.message??"Incorrect current PIN",this.accountPinBusy=!1;return}}await this.client.request("access.setAccountPin",{workspace:e,pin:n}),this.accountPinSuccess="PIN saved",this.accountPinBusy=!1,await ga(this),setTimeout(()=>{this.accountPinModalOpen=!1,this.accountPinSuccess=null,this.accountPinError=null},1500)}catch{this.accountPinError="Failed to save PIN",this.accountPinBusy=!1}}}async handleLicenseStatusCheck(){await Vv(this)}async handleLicenseActivate(){await Qv(this)}async handleLicenseRemove(){await Yv(this)}handleLicenseKeyChange(e){Xv(this,e)}async handleAuthStatusCheck(){await zv(this)}async handleAuthStart(){await jv(this)}async handleAuthSubmitCode(e){await Hv(this,e)}handleAuthCodeChange(e){qv(this,e)}handleSkipToWhatsApp(){Gv(this)}async handleGatewayHealthCheck(){await Zv(this)}async handleGatewayRestart(){await Jv(this)}async handleUpdateCheck(){await pv(this)}async handleUpdateRun(){await hv(this)}handleUpdateDismissResult(){mv(this)}handleFilesLoad(){const e=this.resolveFilesAgentId();on(this,e),bc(this,e)}handleAdminsLoad(){const e=this.resolveAdminAgentId();$e(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>Uy);return{loadAdmins:t}},void 0,import.meta.url).then(({loadAdmins:t})=>{t(this,e)})}resolveAdminAgentId(){const e=this.getSelectedWorkspaceInfo();return e?e.agents.find(n=>n.id.endsWith("-admin")||n.id==="admin")?.id:void 0}resolveFilesAgentId(){const e=this.getSelectedWorkspaceInfo();if(e)return e.agents[0]?.id}handleChatLoad(){const e=this.resolveAdminAgentId();if(e){const t=`agent:${e}:main`;t!==this.sessionKey&&(this.sessionKey=t,this.chatMessages=[],this.chatStream=null,this.chatRunId=null,this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}$e(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>Fu);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this)})}handleAdvancedLoad(){this.loadCron()}async handleChannelConfigSave(){await Iv(this)}async handleChannelConfigReload(){await Nv(this)}handleNostrProfileEdit(e,t){Dv(this,e,t)}handleNostrProfileCancel(){Bv(this)}handleNostrProfileFieldChange(e,t){Fv(this,e,t)}async handleNostrProfileSave(){await Wv(this)}async handleNostrProfileImport(){await Kv(this)}handleNostrProfileToggleAdvanced(){Uv(this)}async handleExecApprovalDecision(e){const t=this.execApprovalQueue[0];if(!(!t||!this.client||this.execApprovalBusy)){this.execApprovalBusy=!0,this.execApprovalError=null;try{await this.client.request("exec.approval.resolve",{id:t.id,decision:e}),this.execApprovalQueue=this.execApprovalQueue.filter(n=>n.id!==t.id)}catch(n){this.execApprovalError=`Exec approval failed: ${String(n)}`}finally{this.execApprovalBusy=!1}}}handleOpenSidebar(e){this.sidebarCloseTimer!=null&&(window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=null),this.sidebarContent=e,this.sidebarError=null,this.sidebarOpen=!0}handleCloseSidebar(){this.sidebarOpen=!1,this.sidebarCloseTimer!=null&&window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=window.setTimeout(()=>{this.sidebarOpen||(this.sidebarContent=null,this.sidebarError=null,this.sidebarCloseTimer=null)},200)}handleSplitRatioChange(e){const t=Math.max(.4,Math.min(.7,e));this.splitRatio=t,this.applySettings({...this.settings,splitRatio:t})}handleAdminsNewPhoneChange(e){this.adminsNewPhone=e,this.adminsError&&(this.adminsError=null)}handleCustomersLoad(){const e=this.selectedWorkspace??void 0;$e(async()=>{const{loadCustomers:t}=await Promise.resolve().then(()=>Wy);return{loadCustomers:t}},void 0,import.meta.url).then(({loadCustomers:t})=>{t(this,e)})}handleCustomersNewPhoneChange(e){this.customersNewPhone=e,this.customersError&&(this.customersError=null)}handleCustomersNewNameChange(e){this.customersNewName=e,this.customersError&&(this.customersError=null)}async handleWorkspacesLoad(){const{loadWorkspaces:e}=await $e(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>Ln);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await $e(async()=>{const{createWorkspace:i}=await Promise.resolve().then(()=>Ln);return{createWorkspace:i}},void 0,import.meta.url),{loadChannels:s}=await $e(async()=>{const{loadChannels:i}=await Promise.resolve().then(()=>pd);return{loadChannels:i}},void 0,import.meta.url);await n(this,{name:e,workspacePath:t,onCreated:i=>{if(!i.whatsappAccountId)return;const o=i.whatsappAccountId;this.handleWorkspaceSelect(e),setTimeout(async()=>{try{await s(this,!0),await this.handleWhatsAppStart(!0,o),this.whatsappLoginQrDataUrl&&(await this.handleWhatsAppWait(o),await s(this,!0),await this.handleWorkspacesLoad())}catch{}this.requestUpdate()},3e3)}})}async handleWorkspaceRemove(e){const{removeWorkspace:t}=await $e(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>Ln);return{removeWorkspace:n}},void 0,import.meta.url);await t(this,e)}handleWorkspaceRenameStart(){const e=this.getSelectedWorkspaceInfo();this.renameWorkspaceName=e?.displayName??e?.name??"",this.renamingWorkspace=!0}handleWorkspaceRenameCancel(){this.renamingWorkspace=!1,this.renameWorkspaceName=""}async handleWorkspaceRename(e,t){const{renameWorkspace:n}=await $e(async()=>{const{renameWorkspace:s}=await Promise.resolve().then(()=>Ln);return{renameWorkspace:s}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){this.selectedWorkspace=e,localStorage.setItem("taskmaster-selected-workspace",e),sr(e),this.settings=Ms(),this.chatMessage="",this.chatAttachments=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.chatQueue=[],this.lastError=null,this.reloadCurrentPageData()}getSelectedWorkspaceInfo(){return this.selectedWorkspace?this.workspaces.find(e=>e.name===this.selectedWorkspace)??null:null}reloadCurrentPageData(){this.adminsPage?this.handleAdminsLoad():this.customersPage?this.handleCustomersLoad():this.filesPage?this.handleFilesLoad():this.chatPage?this.handleChatLoad():this.advancedPage&&this.handleAdvancedLoad()}initWorkspaceSelection(){if(this.workspaces.length===0)return;const e=localStorage.getItem("taskmaster-selected-workspace"),t=e?this.workspaces.find(n=>n.name===e):null;if(t)this.selectedWorkspace=t.name;else{const n=this.workspaces.find(s=>s.isDefault)??this.workspaces[0];this.selectedWorkspace=n.name,localStorage.setItem("taskmaster-selected-workspace",n.name)}sr(this.selectedWorkspace),this.settings=Ms(),this.reloadCurrentPageData()}render(){return Jy(this)}};f([g()],h.prototype,"settings",2);f([g()],h.prototype,"password",2);f([g()],h.prototype,"tab",2);f([g()],h.prototype,"onboarding",2);f([g()],h.prototype,"setup",2);f([g()],h.prototype,"filesPage",2);f([g()],h.prototype,"browserPage",2);f([g()],h.prototype,"adminsPage",2);f([g()],h.prototype,"customersPage",2);f([g()],h.prototype,"chatPage",2);f([g()],h.prototype,"advancedPage",2);f([g()],h.prototype,"advancedTab",2);f([g()],h.prototype,"connected",2);f([g()],h.prototype,"accessState",2);f([g()],h.prototype,"theme",2);f([g()],h.prototype,"themeResolved",2);f([g()],h.prototype,"hello",2);f([g()],h.prototype,"lastError",2);f([g()],h.prototype,"eventLog",2);f([g()],h.prototype,"assistantName",2);f([g()],h.prototype,"assistantAvatar",2);f([g()],h.prototype,"assistantAgentId",2);f([g()],h.prototype,"sessionKey",2);f([g()],h.prototype,"chatLoading",2);f([g()],h.prototype,"chatSending",2);f([g()],h.prototype,"chatMessage",2);f([g()],h.prototype,"chatMessages",2);f([g()],h.prototype,"chatToolMessages",2);f([g()],h.prototype,"chatStream",2);f([g()],h.prototype,"chatStreamStartedAt",2);f([g()],h.prototype,"chatRunId",2);f([g()],h.prototype,"compactionStatus",2);f([g()],h.prototype,"chatAvatarUrl",2);f([g()],h.prototype,"chatThinkingLevel",2);f([g()],h.prototype,"chatModelProvider",2);f([g()],h.prototype,"chatModel",2);f([g()],h.prototype,"chatModelCatalog",2);f([g()],h.prototype,"chatVerboseLevel",2);f([g()],h.prototype,"chatFillerEnabled",2);f([g()],h.prototype,"chatQueue",2);f([g()],h.prototype,"chatAttachments",2);f([g()],h.prototype,"sidebarOpen",2);f([g()],h.prototype,"sidebarContent",2);f([g()],h.prototype,"sidebarError",2);f([g()],h.prototype,"splitRatio",2);f([g()],h.prototype,"nodesLoading",2);f([g()],h.prototype,"nodes",2);f([g()],h.prototype,"devicesLoading",2);f([g()],h.prototype,"devicesError",2);f([g()],h.prototype,"devicesList",2);f([g()],h.prototype,"execApprovalsLoading",2);f([g()],h.prototype,"execApprovalsSaving",2);f([g()],h.prototype,"execApprovalsDirty",2);f([g()],h.prototype,"execApprovalsSnapshot",2);f([g()],h.prototype,"execApprovalsForm",2);f([g()],h.prototype,"execApprovalsSelectedAgent",2);f([g()],h.prototype,"execApprovalsTarget",2);f([g()],h.prototype,"execApprovalsTargetNodeId",2);f([g()],h.prototype,"execApprovalQueue",2);f([g()],h.prototype,"execApprovalBusy",2);f([g()],h.prototype,"execApprovalError",2);f([g()],h.prototype,"configLoading",2);f([g()],h.prototype,"configRaw",2);f([g()],h.prototype,"configRawOriginal",2);f([g()],h.prototype,"configValid",2);f([g()],h.prototype,"configIssues",2);f([g()],h.prototype,"configSaving",2);f([g()],h.prototype,"configApplying",2);f([g()],h.prototype,"updateRunning",2);f([g()],h.prototype,"applySessionKey",2);f([g()],h.prototype,"configSnapshot",2);f([g()],h.prototype,"configSchema",2);f([g()],h.prototype,"configSchemaVersion",2);f([g()],h.prototype,"configSchemaLoading",2);f([g()],h.prototype,"configUiHints",2);f([g()],h.prototype,"configForm",2);f([g()],h.prototype,"configFormOriginal",2);f([g()],h.prototype,"configFormDirty",2);f([g()],h.prototype,"configFormMode",2);f([g()],h.prototype,"configSearchQuery",2);f([g()],h.prototype,"configActiveSection",2);f([g()],h.prototype,"configActiveSubsection",2);f([g()],h.prototype,"channelsLoading",2);f([g()],h.prototype,"channelsSnapshot",2);f([g()],h.prototype,"channelsError",2);f([g()],h.prototype,"channelsLastSuccess",2);f([g()],h.prototype,"whatsappLoginMessage",2);f([g()],h.prototype,"whatsappLoginQrDataUrl",2);f([g()],h.prototype,"whatsappLoginConnected",2);f([g()],h.prototype,"whatsappBusy",2);f([g()],h.prototype,"whatsappActiveQrAccountId",2);f([g()],h.prototype,"whatsappPairedPhone",2);f([g()],h.prototype,"addingWhatsAppAccount",2);f([g()],h.prototype,"newWhatsAppAccountName",2);f([g()],h.prototype,"whatsappAccountError",2);f([g()],h.prototype,"whatsappAccountSaving",2);f([g()],h.prototype,"whatsappSettingsOpen",2);f([g()],h.prototype,"licenseKey",2);f([g()],h.prototype,"licenseBusy",2);f([g()],h.prototype,"licenseValid",2);f([g()],h.prototype,"licenseMessage",2);f([g()],h.prototype,"licenseTier",2);f([g()],h.prototype,"licenseDeviceId",2);f([g()],h.prototype,"licenseStoredKey",2);f([g()],h.prototype,"licenseRemoveConfirm",2);f([g()],h.prototype,"authConnected",2);f([g()],h.prototype,"authBusy",2);f([g()],h.prototype,"authMessage",2);f([g()],h.prototype,"authUrl",2);f([g()],h.prototype,"authCodeInput",2);f([g()],h.prototype,"authExpiresIn",2);f([g()],h.prototype,"setupStep",2);f([g()],h.prototype,"gatewayHealthy",2);f([g()],h.prototype,"gatewayHealthLoading",2);f([g()],h.prototype,"gatewayHealthMessage",2);f([g()],h.prototype,"gatewayRestartBusy",2);f([g()],h.prototype,"updateAvailable",2);f([g()],h.prototype,"currentVersion",2);f([g()],h.prototype,"latestVersion",2);f([g()],h.prototype,"updateChecking",2);f([g()],h.prototype,"updateMessage",2);f([g()],h.prototype,"updateProgressSteps",2);f([g()],h.prototype,"updateLastResult",2);f([g()],h.prototype,"nostrProfileFormState",2);f([g()],h.prototype,"nostrProfileAccountId",2);f([g()],h.prototype,"presenceLoading",2);f([g()],h.prototype,"presenceEntries",2);f([g()],h.prototype,"presenceError",2);f([g()],h.prototype,"presenceStatus",2);f([g()],h.prototype,"agentsLoading",2);f([g()],h.prototype,"agentsList",2);f([g()],h.prototype,"agentsError",2);f([g()],h.prototype,"sessionsLoading",2);f([g()],h.prototype,"sessionsResult",2);f([g()],h.prototype,"sessionsError",2);f([g()],h.prototype,"cronLoading",2);f([g()],h.prototype,"cronJobs",2);f([g()],h.prototype,"cronStatus",2);f([g()],h.prototype,"cronError",2);f([g()],h.prototype,"cronForm",2);f([g()],h.prototype,"cronRunsJobId",2);f([g()],h.prototype,"cronRuns",2);f([g()],h.prototype,"cronBusy",2);f([g()],h.prototype,"cronNewEventModal",2);f([g()],h.prototype,"cronDetailJobId",2);f([g()],h.prototype,"browserScreencastActive",2);f([g()],h.prototype,"browserScreencastFrame",2);f([g()],h.prototype,"browserScreencastMetadata",2);f([g()],h.prototype,"browserHandoffPending",2);f([g()],h.prototype,"browserHandoffReason",2);f([g()],h.prototype,"browserHandoffId",2);f([g()],h.prototype,"browserInputMode",2);f([g()],h.prototype,"browserLoading",2);f([g()],h.prototype,"browserError",2);f([g()],h.prototype,"filesLoading",2);f([g()],h.prototype,"filesTree",2);f([g()],h.prototype,"filesRoot",2);f([g()],h.prototype,"filesError",2);f([g()],h.prototype,"filesSelectedPath",2);f([g()],h.prototype,"filesSelectedPaths",2);f([g()],h.prototype,"filesPreviewContent",2);f([g()],h.prototype,"filesPreviewLoading",2);f([g()],h.prototype,"filesPreviewBinary",2);f([g()],h.prototype,"filesPreviewSize",2);f([g()],h.prototype,"filesExpandedDirs",2);f([g()],h.prototype,"filesMessage",2);f([g()],h.prototype,"filesUploadBusy",2);f([g()],h.prototype,"filesReindexBusy",2);f([g()],h.prototype,"filesMemoryStatus",2);f([g()],h.prototype,"skillsLoading",2);f([g()],h.prototype,"skillsReport",2);f([g()],h.prototype,"skillsError",2);f([g()],h.prototype,"skillsFilter",2);f([g()],h.prototype,"skillEdits",2);f([g()],h.prototype,"skillsBusyKey",2);f([g()],h.prototype,"skillMessages",2);f([g()],h.prototype,"adminsLoading",2);f([g()],h.prototype,"adminPhones",2);f([g()],h.prototype,"adminsError",2);f([g()],h.prototype,"adminsSaving",2);f([g()],h.prototype,"adminsNewPhone",2);f([g()],h.prototype,"customersLoading",2);f([g()],h.prototype,"customersSaving",2);f([g()],h.prototype,"customersRecords",2);f([g()],h.prototype,"customersError",2);f([g()],h.prototype,"customersSearchQuery",2);f([g()],h.prototype,"customersEditingId",2);f([g()],h.prototype,"customersShowAddForm",2);f([g()],h.prototype,"customersNewPhone",2);f([g()],h.prototype,"customersNewName",2);f([g()],h.prototype,"imessageEnableConfirm",2);f([g()],h.prototype,"imessageEnabling",2);f([g()],h.prototype,"infoModalOpen",2);f([g()],h.prototype,"workspaces",2);f([g()],h.prototype,"workspacesLoading",2);f([g()],h.prototype,"workspacesError",2);f([g()],h.prototype,"selectedWorkspace",2);f([g()],h.prototype,"addingWorkspace",2);f([g()],h.prototype,"newWorkspaceName",2);f([g()],h.prototype,"newWorkspacePath",2);f([g()],h.prototype,"newWorkspacePin",2);f([g()],h.prototype,"accountPinModalOpen",2);f([g()],h.prototype,"accountPinBusy",2);f([g()],h.prototype,"accountPinError",2);f([g()],h.prototype,"accountPinSuccess",2);f([g()],h.prototype,"apiKeyProviders",2);f([g()],h.prototype,"apiKeyModalOpen",2);f([g()],h.prototype,"apiKeyBusy",2);f([g()],h.prototype,"apiKeyError",2);f([g()],h.prototype,"apiKeySuccess",2);f([g()],h.prototype,"authApiKeyMode",2);f([g()],h.prototype,"authApiKeyInput",2);f([g()],h.prototype,"authApiKeyBusy",2);f([g()],h.prototype,"authApiKeyError",2);f([g()],h.prototype,"pinChanging",2);f([g()],h.prototype,"pinChangeBusy",2);f([g()],h.prototype,"pinChangeError",2);f([g()],h.prototype,"loginChangePinMode",2);f([g()],h.prototype,"changePinBusy",2);f([g()],h.prototype,"changePinError",2);f([g()],h.prototype,"changePinSuccess",2);f([g()],h.prototype,"workspaceSaving",2);f([g()],h.prototype,"workspaceRemoveConfirm",2);f([g()],h.prototype,"renamingWorkspace",2);f([g()],h.prototype,"renameWorkspaceName",2);f([g()],h.prototype,"debugLoading",2);f([g()],h.prototype,"debugStatus",2);f([g()],h.prototype,"debugHealth",2);f([g()],h.prototype,"debugModels",2);f([g()],h.prototype,"debugHeartbeat",2);f([g()],h.prototype,"debugCallMethod",2);f([g()],h.prototype,"debugCallParams",2);f([g()],h.prototype,"debugCallResult",2);f([g()],h.prototype,"debugCallError",2);f([g()],h.prototype,"logsLoading",2);f([g()],h.prototype,"logsError",2);f([g()],h.prototype,"logsFile",2);f([g()],h.prototype,"logsEntries",2);f([g()],h.prototype,"logsFilterText",2);f([g()],h.prototype,"logsLevelFilters",2);f([g()],h.prototype,"logsAutoFollow",2);f([g()],h.prototype,"logsTruncated",2);f([g()],h.prototype,"logsCursor",2);f([g()],h.prototype,"logsLastFetchAt",2);f([g()],h.prototype,"logsLimit",2);f([g()],h.prototype,"logsMaxBytes",2);f([g()],h.prototype,"logsAtBottom",2);f([g()],h.prototype,"logsSubTab",2);f([g()],h.prototype,"sessionLogsLoading",2);f([g()],h.prototype,"sessionLogsError",2);f([g()],h.prototype,"sessionLogsEntries",2);f([g()],h.prototype,"sessionLogsFilterText",2);f([g()],h.prototype,"sessionLogsTypeFilters",2);f([g()],h.prototype,"sessionLogsAgentFilters",2);f([g()],h.prototype,"sessionLogsAgents",2);f([g()],h.prototype,"sessionLogsAutoFollow",2);f([g()],h.prototype,"sessionLogsFull",2);f([g()],h.prototype,"sessionLogsCursors",2);f([g()],h.prototype,"sessionLogsLastFetchAt",2);f([g()],h.prototype,"sessionLogsAtBottom",2);f([g()],h.prototype,"chatUserNearBottom",2);h=f([Ea("taskmaster-app")],h);
2783
+ //# sourceMappingURL=index-CkajwbDA.js.map