@rubytech/taskmaster 1.12.0 → 1.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/taskmaster-tools.js +5 -3
- package/dist/agents/tool-policy.js +1 -1
- package/dist/agents/tools/authorize-admin-tool.js +58 -17
- package/dist/agents/tools/bootstrap-tool.js +51 -0
- package/dist/agents/tools/cron-tool.js +20 -7
- package/dist/build-info.json +3 -3
- package/dist/commands/agents.config.js +1 -0
- package/dist/config/zod-schema.js +18 -0
- package/dist/control-ui/assets/{index-DpMaqt-b.js → index-CP9IoaZp.js} +110 -97
- package/dist/control-ui/assets/index-CP9IoaZp.js.map +1 -0
- package/dist/control-ui/index.html +1 -1
- package/dist/gateway/control-ui.js +24 -9
- package/dist/gateway/protocol/schema/cron.js +8 -0
- package/dist/gateway/public-chat/deliver-email.js +5 -5
- package/dist/gateway/public-chat/deliver-otp.js +3 -3
- package/dist/gateway/public-chat/deliver-sms.js +5 -1
- package/dist/gateway/public-chat-api.js +26 -11
- package/dist/gateway/server-channels.js +6 -2
- package/dist/gateway/server-methods/cron.js +32 -0
- package/dist/gateway/server-methods/public-chat.js +4 -2
- package/dist/gateway/server-methods/tailscale.js +9 -0
- package/dist/gateway/server-methods/workspaces.js +52 -0
- package/dist/web/auto-reply/monitor.js +3 -0
- package/package.json +1 -1
- package/skills/tailscale/SKILL.md +37 -9
- package/templates/beagle-taxi/agents/admin/AGENTS.md +25 -0
- package/templates/beagle-taxi/agents/admin/IDENTITY.md +9 -0
- package/templates/beagle-taxi/agents/admin/SOUL.md +31 -0
- package/templates/beagle-taxi/agents/public/AGENTS.md +54 -0
- package/templates/beagle-taxi/agents/public/IDENTITY.md +10 -0
- package/templates/beagle-taxi/agents/public/SOUL.md +32 -0
- package/templates/beagle-taxi/memory/public/knowledge-base.md +177 -0
- package/templates/beagle-taxi/skills/beagle-taxi/SKILL.md +44 -0
- package/templates/customer/agents/admin/BOOTSTRAP.md +2 -2
- package/templates/education-hero/agents/admin/BOOTSTRAP.md +2 -2
- package/templates/maxy/agents/admin/BOOTSTRAP.md +2 -3
- package/templates/taskmaster/agents/admin/BOOTSTRAP.md +2 -2
- package/templates/tradesupport/agents/admin/BOOTSTRAP.md +2 -2
- package/dist/control-ui/assets/index-DpMaqt-b.js.map +0 -1
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var Bu=Object.defineProperty;var Nu=(e,t,n)=>t in e?Bu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var q=(e,t,n)=>Nu(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const Ou="modulepreload",Fu=function(e,t){return new URL(e,t).href},ir={},le=function(t,n,i){let s=Promise.resolve();if(n&&n.length>0){let c=function(h){return Promise.all(h.map(d=>Promise.resolve(d).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};const a=document.getElementsByTagName("link"),r=document.querySelector("meta[property=csp-nonce]"),l=(r==null?void 0:r.nonce)||(r==null?void 0:r.getAttribute("nonce"));s=c(n.map(h=>{if(h=Fu(h,i),h in ir)return;ir[h]=!0;const d=h.endsWith(".css"),p=d?'[rel="stylesheet"]':"";if(i)for(let S=a.length-1;S>=0;S--){const x=a[S];if(x.href===h&&(!d||x.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${p}`))return;const v=document.createElement("link");if(v.rel=d?"stylesheet":Ou,d||(v.as="script"),v.crossOrigin="",v.href=h,l&&v.setAttribute("nonce",l),document.head.appendChild(v),d)return new Promise((S,x)=>{v.addEventListener("load",S),v.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(a){const r=new Event("vite:preloadError",{cancelable:!0});if(r.payload=a,window.dispatchEvent(r),!r.defaultPrevented)throw a}return s.then(a=>{for(const r of a||[])r.status==="rejected"&&o(r.reason);return t().catch(o)})};const Si=globalThis,Ho=Si.ShadowRoot&&(Si.ShadyCSS===void 0||Si.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,jo=Symbol(),sr=new WeakMap;let Rl=class{constructor(t,n,i){if(this._$cssResult$=!0,i!==jo)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(Ho&&t===void 0){const i=n!==void 0&&n.length===1;i&&(t=sr.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&sr.set(n,t))}return t}toString(){return this.cssText}};const Uu=e=>new Rl(typeof e=="string"?e:e+"",void 0,jo),Wu=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((i,s,o)=>i+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[o+1],e[0]);return new Rl(n,e,jo)},Ku=(e,t)=>{if(Ho)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const i=document.createElement("style"),s=Si.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=n.cssText,e.appendChild(i)}},or=Ho?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const i of t.cssRules)n+=i.cssText;return Uu(n)})(e):e;const{is:zu,defineProperty:qu,getOwnPropertyDescriptor:Hu,getOwnPropertyNames:ju,getOwnPropertySymbols:Gu,getPrototypeOf:Vu}=Object,at=globalThis,ar=at.trustedTypes,Qu=ar?ar.emptyScript:"",Ts=at.reactiveElementPolyfillSupport,Cn=(e,t)=>e,Ii={toAttribute(e,t){switch(t){case Boolean:e=e?Qu: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}},Go=(e,t)=>!zu(e,t),rr={attribute:!0,type:String,converter:Ii,reflect:!1,useDefault:!1,hasChanged:Go};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),at.litPropertyMetadata??(at.litPropertyMetadata=new WeakMap);let qt=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,n=rr){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 i=Symbol(),s=this.getPropertyDescriptor(t,i,n);s!==void 0&&qu(this.prototype,t,s)}}static getPropertyDescriptor(t,n,i){const{get:s,set:o}=Hu(this.prototype,t)??{get(){return this[n]},set(a){this[n]=a}};return{get:s,set(a){const r=s==null?void 0:s.call(this);o==null||o.call(this,a),this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??rr}static _$Ei(){if(this.hasOwnProperty(Cn("elementProperties")))return;const t=Vu(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Cn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Cn("properties"))){const n=this.properties,i=[...ju(n),...Gu(n)];for(const s of i)this.createProperty(s,n[s])}const t=this[Symbol.metadata];if(t!==null){const n=litPropertyMetadata.get(t);if(n!==void 0)for(const[i,s]of n)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[n,i]of this.elementProperties){const s=this._$Eu(n,i);s!==void 0&&this._$Eh.set(s,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const n=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)n.unshift(or(s))}else t!==void 0&&n.push(or(t));return n}static _$Eu(t,n){const i=n.attribute;return i===!1?void 0:typeof i=="string"?i: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(){var t;this._$ES=new Promise(n=>this.enableUpdating=n),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(n=>n(this))}addController(t){var n;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((n=t.hostConnected)==null||n.call(t))}removeController(t){var n;(n=this._$EO)==null||n.delete(t)}_$E_(){const t=new Map,n=this.constructor.elementProperties;for(const i of n.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Ku(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(n=>{var i;return(i=n.hostConnected)==null?void 0:i.call(n)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(n=>{var i;return(i=n.hostDisconnected)==null?void 0:i.call(n)})}attributeChangedCallback(t,n,i){this._$AK(t,i)}_$ET(t,n){var o;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const a=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:Ii).toAttribute(n,i.type);this._$Em=t,a==null?this.removeAttribute(s):this.setAttribute(s,a),this._$Em=null}}_$AK(t,n){var o,a;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const r=i.getPropertyOptions(s),l=typeof r.converter=="function"?{fromAttribute:r.converter}:((o=r.converter)==null?void 0:o.fromAttribute)!==void 0?r.converter:Ii;this._$Em=s;const c=l.fromAttribute(n,r.type);this[s]=c??((a=this._$Ej)==null?void 0:a.get(s))??c,this._$Em=null}}requestUpdate(t,n,i,s=!1,o){var a;if(t!==void 0){const r=this.constructor;if(s===!1&&(o=this[t]),i??(i=r.getPropertyOptions(t)),!((i.hasChanged??Go)(o,n)||i.useDefault&&i.reflect&&o===((a=this._$Ej)==null?void 0:a.get(t))&&!this.hasAttribute(r._$Eu(t,i))))return;this.C(t,n,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,n,{useDefault:i,reflect:s,wrapped:o},a){i&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,a??n??this[t]),o!==!0||a!==void 0)||(this._$AL.has(t)||(this.hasUpdated||i||(n=void 0),this._$AL.set(t,n)),s===!0&&this._$Em!==t&&(this._$Eq??(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(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[o,a]of this._$Ep)this[o]=a;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,a]of s){const{wrapped:r}=a,l=this[o];r!==!0||this._$AL.has(o)||l===void 0||this.C(o,void 0,a,l)}}let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),(i=this._$EO)==null||i.forEach(s=>{var o;return(o=s.hostUpdate)==null?void 0:o.call(s)}),this.update(n)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(n)}willUpdate(t){}_$AE(t){var n;(n=this._$EO)==null||n.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),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=this._$Eq.forEach(n=>this._$ET(n,this[n]))),this._$EM()}updated(t){}firstUpdated(t){}};qt.elementStyles=[],qt.shadowRootOptions={mode:"open"},qt[Cn("elementProperties")]=new Map,qt[Cn("finalized")]=new Map,Ts==null||Ts({ReactiveElement:qt}),(at.reactiveElementVersions??(at.reactiveElementVersions=[])).push("2.1.2");const En=globalThis,lr=e=>e,Li=En.trustedTypes,cr=Li?Li.createPolicy("lit-html",{createHTML:e=>e}):void 0,Dl="$lit$",ot=`lit$${Math.random().toFixed(9).slice(2)}$`,Bl="?"+ot,Ju=`<${Bl}>`,Ct=document,Fn=()=>Ct.createComment(""),Un=e=>e===null||typeof e!="object"&&typeof e!="function",Vo=Array.isArray,Yu=e=>Vo(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",_s=`[
|
|
1
|
+
var Bu=Object.defineProperty;var Nu=(e,t,n)=>t in e?Bu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var q=(e,t,n)=>Nu(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const Ou="modulepreload",Fu=function(e,t){return new URL(e,t).href},ir={},le=function(t,n,i){let s=Promise.resolve();if(n&&n.length>0){let c=function(h){return Promise.all(h.map(d=>Promise.resolve(d).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};const a=document.getElementsByTagName("link"),r=document.querySelector("meta[property=csp-nonce]"),l=(r==null?void 0:r.nonce)||(r==null?void 0:r.getAttribute("nonce"));s=c(n.map(h=>{if(h=Fu(h,i),h in ir)return;ir[h]=!0;const d=h.endsWith(".css"),p=d?'[rel="stylesheet"]':"";if(i)for(let $=a.length-1;$>=0;$--){const S=a[$];if(S.href===h&&(!d||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${p}`))return;const g=document.createElement("link");if(g.rel=d?"stylesheet":Ou,d||(g.as="script"),g.crossOrigin="",g.href=h,l&&g.setAttribute("nonce",l),document.head.appendChild(g),d)return new Promise(($,S)=>{g.addEventListener("load",$),g.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(a){const r=new Event("vite:preloadError",{cancelable:!0});if(r.payload=a,window.dispatchEvent(r),!r.defaultPrevented)throw a}return s.then(a=>{for(const r of a||[])r.status==="rejected"&&o(r.reason);return t().catch(o)})};const Si=globalThis,Ho=Si.ShadowRoot&&(Si.ShadyCSS===void 0||Si.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,jo=Symbol(),sr=new WeakMap;let Rl=class{constructor(t,n,i){if(this._$cssResult$=!0,i!==jo)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(Ho&&t===void 0){const i=n!==void 0&&n.length===1;i&&(t=sr.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&sr.set(n,t))}return t}toString(){return this.cssText}};const Uu=e=>new Rl(typeof e=="string"?e:e+"",void 0,jo),Wu=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((i,s,o)=>i+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[o+1],e[0]);return new Rl(n,e,jo)},Ku=(e,t)=>{if(Ho)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const i=document.createElement("style"),s=Si.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=n.cssText,e.appendChild(i)}},or=Ho?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const i of t.cssRules)n+=i.cssText;return Uu(n)})(e):e;const{is:zu,defineProperty:qu,getOwnPropertyDescriptor:Hu,getOwnPropertyNames:ju,getOwnPropertySymbols:Gu,getPrototypeOf:Vu}=Object,at=globalThis,ar=at.trustedTypes,Qu=ar?ar.emptyScript:"",Ts=at.reactiveElementPolyfillSupport,Cn=(e,t)=>e,Ii={toAttribute(e,t){switch(t){case Boolean:e=e?Qu: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}},Go=(e,t)=>!zu(e,t),rr={attribute:!0,type:String,converter:Ii,reflect:!1,useDefault:!1,hasChanged:Go};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),at.litPropertyMetadata??(at.litPropertyMetadata=new WeakMap);let qt=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,n=rr){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 i=Symbol(),s=this.getPropertyDescriptor(t,i,n);s!==void 0&&qu(this.prototype,t,s)}}static getPropertyDescriptor(t,n,i){const{get:s,set:o}=Hu(this.prototype,t)??{get(){return this[n]},set(a){this[n]=a}};return{get:s,set(a){const r=s==null?void 0:s.call(this);o==null||o.call(this,a),this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??rr}static _$Ei(){if(this.hasOwnProperty(Cn("elementProperties")))return;const t=Vu(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Cn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Cn("properties"))){const n=this.properties,i=[...ju(n),...Gu(n)];for(const s of i)this.createProperty(s,n[s])}const t=this[Symbol.metadata];if(t!==null){const n=litPropertyMetadata.get(t);if(n!==void 0)for(const[i,s]of n)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[n,i]of this.elementProperties){const s=this._$Eu(n,i);s!==void 0&&this._$Eh.set(s,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const n=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)n.unshift(or(s))}else t!==void 0&&n.push(or(t));return n}static _$Eu(t,n){const i=n.attribute;return i===!1?void 0:typeof i=="string"?i: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(){var t;this._$ES=new Promise(n=>this.enableUpdating=n),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(n=>n(this))}addController(t){var n;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((n=t.hostConnected)==null||n.call(t))}removeController(t){var n;(n=this._$EO)==null||n.delete(t)}_$E_(){const t=new Map,n=this.constructor.elementProperties;for(const i of n.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Ku(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(n=>{var i;return(i=n.hostConnected)==null?void 0:i.call(n)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(n=>{var i;return(i=n.hostDisconnected)==null?void 0:i.call(n)})}attributeChangedCallback(t,n,i){this._$AK(t,i)}_$ET(t,n){var o;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const a=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:Ii).toAttribute(n,i.type);this._$Em=t,a==null?this.removeAttribute(s):this.setAttribute(s,a),this._$Em=null}}_$AK(t,n){var o,a;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const r=i.getPropertyOptions(s),l=typeof r.converter=="function"?{fromAttribute:r.converter}:((o=r.converter)==null?void 0:o.fromAttribute)!==void 0?r.converter:Ii;this._$Em=s;const c=l.fromAttribute(n,r.type);this[s]=c??((a=this._$Ej)==null?void 0:a.get(s))??c,this._$Em=null}}requestUpdate(t,n,i,s=!1,o){var a;if(t!==void 0){const r=this.constructor;if(s===!1&&(o=this[t]),i??(i=r.getPropertyOptions(t)),!((i.hasChanged??Go)(o,n)||i.useDefault&&i.reflect&&o===((a=this._$Ej)==null?void 0:a.get(t))&&!this.hasAttribute(r._$Eu(t,i))))return;this.C(t,n,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,n,{useDefault:i,reflect:s,wrapped:o},a){i&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,a??n??this[t]),o!==!0||a!==void 0)||(this._$AL.has(t)||(this.hasUpdated||i||(n=void 0),this._$AL.set(t,n)),s===!0&&this._$Em!==t&&(this._$Eq??(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(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[o,a]of this._$Ep)this[o]=a;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,a]of s){const{wrapped:r}=a,l=this[o];r!==!0||this._$AL.has(o)||l===void 0||this.C(o,void 0,a,l)}}let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),(i=this._$EO)==null||i.forEach(s=>{var o;return(o=s.hostUpdate)==null?void 0:o.call(s)}),this.update(n)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(n)}willUpdate(t){}_$AE(t){var n;(n=this._$EO)==null||n.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),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=this._$Eq.forEach(n=>this._$ET(n,this[n]))),this._$EM()}updated(t){}firstUpdated(t){}};qt.elementStyles=[],qt.shadowRootOptions={mode:"open"},qt[Cn("elementProperties")]=new Map,qt[Cn("finalized")]=new Map,Ts==null||Ts({ReactiveElement:qt}),(at.reactiveElementVersions??(at.reactiveElementVersions=[])).push("2.1.2");const En=globalThis,lr=e=>e,Li=En.trustedTypes,cr=Li?Li.createPolicy("lit-html",{createHTML:e=>e}):void 0,Dl="$lit$",ot=`lit$${Math.random().toFixed(9).slice(2)}$`,Bl="?"+ot,Ju=`<${Bl}>`,Ct=document,Fn=()=>Ct.createComment(""),Un=e=>e===null||typeof e!="object"&&typeof e!="function",Vo=Array.isArray,Yu=e=>Vo(e)||typeof(e==null?void 0:e[Symbol.iterator])=="function",_s=`[
|
|
2
2
|
\f\r]`,hn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,dr=/-->/g,ur=/>/g,ft=RegExp(`>|${_s}(?:([^\\s"'>=/]+)(${_s}*=${_s}*(?:[^
|
|
3
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),pr=/'/g,hr=/"/g,Nl=/^(?:script|style|textarea|title)$/i,Xu=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),u=Xu(1),lt=Symbol.for("lit-noChange"),w=Symbol.for("lit-nothing"),fr=new WeakMap,bt=Ct.createTreeWalker(Ct,129);function Ol(e,t){if(!Vo(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return cr!==void 0?cr.createHTML(t):t}const Zu=(e,t)=>{const n=e.length-1,i=[];let s,o=t===2?"<svg>":t===3?"<math>":"",a=hn;for(let r=0;r<n;r++){const l=e[r];let c,h,d=-1,p=0;for(;p<l.length&&(a.lastIndex=p,h=a.exec(l),h!==null);)p=a.lastIndex,a===hn?h[1]==="!--"?a=dr:h[1]!==void 0?a=ur:h[2]!==void 0?(Nl.test(h[2])&&(s=RegExp("</"+h[2],"g")),a=ft):h[3]!==void 0&&(a=ft):a===ft?h[0]===">"?(a=s??hn,d=-1):h[1]===void 0?d=-2:(d=a.lastIndex-h[2].length,c=h[1],a=h[3]===void 0?ft:h[3]==='"'?hr:pr):a===hr||a===pr?a=ft:a===dr||a===ur?a=hn:(a=ft,s=void 0);const v=a===ft&&e[r+1].startsWith("/>")?" ":"";o+=a===hn?l+Ju:d>=0?(i.push(c),l.slice(0,d)+Dl+l.slice(d)+ot+v):l+ot+(d===-2?r:v)}return[Ol(e,o+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let mo=class Fl{constructor({strings:t,_$litType$:n},i){let s;this.parts=[];let o=0,a=0;const r=t.length-1,l=this.parts,[c,h]=Zu(t,n);if(this.el=Fl.createElement(c,i),bt.currentNode=this.el.content,n===2||n===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(s=bt.nextNode())!==null&&l.length<r;){if(s.nodeType===1){if(s.hasAttributes())for(const d of s.getAttributeNames())if(d.endsWith(Dl)){const p=h[a++],v=s.getAttribute(d).split(ot),S=/([.?@])?(.*)/.exec(p);l.push({type:1,index:o,name:S[2],strings:v,ctor:S[1]==="."?tp:S[1]==="?"?np:S[1]==="@"?ip:ns}),s.removeAttribute(d)}else d.startsWith(ot)&&(l.push({type:6,index:o}),s.removeAttribute(d));if(Nl.test(s.tagName)){const d=s.textContent.split(ot),p=d.length-1;if(p>0){s.textContent=Li?Li.emptyScript:"";for(let v=0;v<p;v++)s.append(d[v],Fn()),bt.nextNode(),l.push({type:2,index:++o});s.append(d[p],Fn())}}}else if(s.nodeType===8)if(s.data===Bl)l.push({type:2,index:o});else{let d=-1;for(;(d=s.data.indexOf(ot,d+1))!==-1;)l.push({type:7,index:o}),d+=ot.length-1}o++}}static createElement(t,n){const i=Ct.createElement("template");return i.innerHTML=t,i}};function Jt(e,t,n=e,i){var a,r;if(t===lt)return t;let s=i!==void 0?(a=n._$Co)==null?void 0:a[i]:n._$Cl;const o=Un(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((r=s==null?void 0:s._$AO)==null||r.call(s,!1),o===void 0?s=void 0:(s=new o(e),s._$AT(e,n,i)),i!==void 0?(n._$Co??(n._$Co=[]))[i]=s:n._$Cl=s),s!==void 0&&(t=Jt(e,s._$AS(e,t.values),s,i)),t}class ep{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:i}=this._$AD,s=((t==null?void 0:t.creationScope)??Ct).importNode(n,!0);bt.currentNode=s;let o=bt.nextNode(),a=0,r=0,l=i[0];for(;l!==void 0;){if(a===l.index){let c;l.type===2?c=new ts(o,o.nextSibling,this,t):l.type===1?c=new l.ctor(o,l.name,l.strings,this,t):l.type===6&&(c=new sp(o,this,t)),this._$AV.push(c),l=i[++r]}a!==(l==null?void 0:l.index)&&(o=bt.nextNode(),a++)}return bt.currentNode=Ct,s}p(t){let n=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,n),n+=i.strings.length-2):i._$AI(t[n])),n++}}let ts=class Ul{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,n,i,s){this.type=2,this._$AH=w,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=n.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,n=this){t=Jt(this,t,n),Un(t)?t===w||t==null||t===""?(this._$AH!==w&&this._$AR(),this._$AH=w):t!==this._$AH&&t!==lt&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Yu(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!==w&&Un(this._$AH)?this._$AA.nextSibling.data=t:this.T(Ct.createTextNode(t)),this._$AH=t}$(t){var o;const{values:n,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=mo.createElement(Ol(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(n);else{const a=new ep(s,this),r=a.u(this.options);a.p(n),this.T(r),this._$AH=a}}_$AC(t){let n=fr.get(t.strings);return n===void 0&&fr.set(t.strings,n=new mo(t)),n}k(t){Vo(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let i,s=0;for(const o of t)s===n.length?n.push(i=new Ul(this.O(Fn()),this.O(Fn()),this,this.options)):i=n[s],i._$AI(o),s++;s<n.length&&(this._$AR(i&&i._$AB.nextSibling,s),n.length=s)}_$AR(t=this._$AA.nextSibling,n){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,n);t!==this._$AB;){const s=lr(t).nextSibling;lr(t).remove(),t=s}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class ns{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,i,s,o){this.type=1,this._$AH=w,this._$AN=void 0,this.element=t,this.name=n,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=w}_$AI(t,n=this,i,s){const o=this.strings;let a=!1;if(o===void 0)t=Jt(this,t,n,0),a=!Un(t)||t!==this._$AH&&t!==lt,a&&(this._$AH=t);else{const r=t;let l,c;for(t=o[0],l=0;l<o.length-1;l++)c=Jt(this,r[i+l],n,l),c===lt&&(c=this._$AH[l]),a||(a=!Un(c)||c!==this._$AH[l]),c===w?t=w:t!==w&&(t+=(c??"")+o[l+1]),this._$AH[l]=c}a&&!s&&this.j(t)}j(t){t===w?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let tp=class extends ns{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===w?void 0:t}},np=class extends ns{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==w)}},ip=class extends ns{constructor(t,n,i,s,o){super(t,n,i,s,o),this.type=5}_$AI(t,n=this){if((t=Jt(this,t,n,0)??w)===lt)return;const i=this._$AH,s=t===w&&i!==w||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==w&&(i===w||s);s&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var n;typeof this._$AH=="function"?this._$AH.call(((n=this.options)==null?void 0:n.host)??this.element,t):this._$AH.handleEvent(t)}},sp=class{constructor(t,n,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){Jt(this,t)}};const op={I:ts},Ms=En.litHtmlPolyfillSupport;Ms==null||Ms(mo,ts),(En.litHtmlVersions??(En.litHtmlVersions=[])).push("3.3.2");const ap=(e,t,n)=>{const i=(n==null?void 0:n.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const o=(n==null?void 0:n.renderBefore)??null;i._$litPart$=s=new ts(t.insertBefore(Fn(),o),o,void 0,n??{})}return s._$AI(e),s};const xt=globalThis;let Gt=class extends qt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var n;const t=super.createRenderRoot();return(n=this.renderOptions).renderBefore??(n.renderBefore=t.firstChild),t}update(t){const n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=ap(n,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return lt}};var Ll;Gt._$litElement$=!0,Gt.finalized=!0,(Ll=xt.litElementHydrateSupport)==null||Ll.call(xt,{LitElement:Gt});const Ps=xt.litElementPolyfillSupport;Ps==null||Ps({LitElement:Gt});(xt.litElementVersions??(xt.litElementVersions=[])).push("4.2.2");const Wl=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const rp={attribute:!0,type:String,converter:Ii,reflect:!1,hasChanged:Go},lp=(e=rp,t,n)=>{const{kind:i,metadata:s}=n;let o=globalThis.litPropertyMetadata.get(s);if(o===void 0&&globalThis.litPropertyMetadata.set(s,o=new Map),i==="setter"&&((e=Object.create(e)).wrapped=!0),o.set(n.name,e),i==="accessor"){const{name:a}=n;return{set(r){const l=t.get.call(this);t.set.call(this,r),this.requestUpdate(a,l,e,!0,r)},init(r){return r!==void 0&&this.C(a,void 0,e,r),r}}}if(i==="setter"){const{name:a}=n;return function(r){const l=this[a];t.call(this,r),this.requestUpdate(a,l,e,!0,r)}}throw Error("Unsupported decorator location: "+i)};function is(e){return(t,n)=>typeof n=="object"?lp(e,t,n):((i,s,o)=>{const a=s.hasOwnProperty(o);return s.constructor.createProperty(o,i),a?Object.getOwnPropertyDescriptor(s,o):void 0})(e,t,n)}function y(e){return is({...e,state:!0,attribute:!1})}const cp=50,dp=200,up="Assistant";function gr(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function yo(e){const t=gr(e==null?void 0:e.name,cp)??up,n=gr((e==null?void 0:e.avatar)??void 0,dp)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function pp(){return yo(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const hp="Taskmaster",fp="/taskmaster-icon.png",gp="#00d4ff",mp="";let ai=null;function Ye(){return ai||(ai={name:window.__TASKMASTER_BRAND_NAME__||hp,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||fp,accentColor:window.__TASKMASTER_ACCENT_COLOR__||gp,backgroundColor:window.__TASKMASTER_BACKGROUND_COLOR__||mp},ai)}function Be(){return window.__TASKMASTER_WORKSPACE_BRANDS__??{}}function Kl(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 yp(e){const t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!t)return 0;const[n,i,s]=[t[1],t[2],t[3]].map(o=>{const a=parseInt(o,16)/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)});return .2126*n+.7152*i+.0722*s}function zl(e){const t=Kl(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 i=yp(e)>.4?"#111111":"#ffffff";n.style.setProperty("--accent-foreground",i),n.style.setProperty("--primary-foreground",i)}function ri(e,t,n){const i=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e),s=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t);if(!i||!s)return e;const o=(c,h)=>Math.round(parseInt(i[c],16)*(1-n)+parseInt(s[h],16)*n),a=o(1,1),r=o(2,2),l=o(3,3);return`#${a.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}`}const fn={"--bg":"#12141a","--bg-muted":"#262a35","--card":"#181b22","--secondary":"#1e2028"};function ql(e){const t=document.documentElement;if(!e){for(const[i,s]of Object.entries(fn))t.style.setProperty(i,s);t.style.removeProperty("--brand-bg"),t.style.removeProperty("--brand-bg-subtle"),t.style.removeProperty("--brand-bg-card");return}const n=Kl(e);n&&(t.style.setProperty("--bg",ri(fn["--bg"],e,.08)),t.style.setProperty("--bg-muted",ri(fn["--bg-muted"],e,.1)),t.style.setProperty("--card",ri(fn["--card"],e,.12)),t.style.setProperty("--secondary",ri(fn["--secondary"],e,.1)),t.style.setProperty("--brand-bg",e),t.style.setProperty("--brand-bg-subtle",`rgba(${n}, 0.08)`),t.style.setProperty("--brand-bg-card",`rgba(${n}, 0.12)`))}function Tn(e){const t=Ye(),n=Be(),i=e?n[e]:void 0,s=(i==null?void 0:i.accentColor)??t.accentColor;zl(s);const o=(i==null?void 0:i.backgroundColor)??t.backgroundColor;ql(o)}const Ri="taskmaster.control.settings.v1",Hl="taskmaster.account.settings.";function _n(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const Kt={gatewayUrl:_n(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},it={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function vp(){try{const e=localStorage.getItem(Ri);if(!e)return{...Kt,gatewayUrl:_n()};const t=JSON.parse(e);return{gatewayUrl:typeof t.gatewayUrl=="string"&&t.gatewayUrl.trim()?t.gatewayUrl.trim():_n(),token:typeof t.token=="string"?t.token:Kt.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:Kt.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:Kt.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:Kt.navGroupsCollapsed}}catch{return{...Kt,gatewayUrl:_n()}}}function bp(e){if(!e)return{...it};try{const t=localStorage.getItem(Hl+e);if(!t)return{...it};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():it.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||it.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:it.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:it.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:it.splitRatio}}catch{return{...it}}}let Di=null;function mr(e){Di=e}function Is(){return{...vp(),...bp(Di)}}function wp(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(Ri,JSON.stringify(t)),Di){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(Hl+Di,JSON.stringify(n))}}const kp="taskmaster.draft.";function Qo(e,t){return kp+e+"."+t}function Wn(e,t,n){try{const i=Qo(e,t);n?localStorage.setItem(i,n):localStorage.removeItem(i)}catch{}}function Kn(e,t){try{return localStorage.getItem(Qo(e,t))??""}catch{return""}}function $p(e,t){try{localStorage.removeItem(Qo(e,t))}catch{}}let wt=null,Se=null;function yr(e,t,n){Se={workspace:e,sessionKey:t,text:n},wt!=null&&clearTimeout(wt),wt=setTimeout(()=>{Se&&Wn(Se.workspace,Se.sessionKey,Se.text),Se=null,wt=null},300)}function vo(){wt!=null&&clearTimeout(wt),wt=null,Se&&(Wn(Se.workspace,Se.sessionKey,Se.text),Se=null)}(function(){try{const t=localStorage.getItem(Ri);if(!t)return;const n=JSON.parse(t);if(!("sessionKey"in n))return;const i={gatewayUrl:typeof n.gatewayUrl=="string"?n.gatewayUrl:_n(),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(Ri,JSON.stringify(i))}catch{}})();function jl(e){var o;const t=(e??"").trim();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const i=(o=n[1])==null?void 0:o.trim(),s=n.slice(2).join(":");return!i||!s?null:{agentId:i,rest:s}}const xp=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,li=/<\s*\/?\s*final\b[^>]*>/gi,vr=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function Sp(e,t){return e.trimStart()}function Ap(e,t){if(!e||!xp.test(e))return e;let n=e;li.test(n)?(li.lastIndex=0,n=n.replace(li,"")):li.lastIndex=0,vr.lastIndex=0;let i="",s=0,o=!1;for(const a of n.matchAll(vr)){const r=a.index??0,l=a[1]==="/";o?l&&(o=!1):(i+=n.slice(s,r),l||(o=!0)),s=r+a[0].length}return i+=n.slice(s),Sp(i)}function Gl(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function ss(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0){const a=-t,r=Math.round(a/1e3);if(r<60)return`in ${r}s`;const l=Math.round(r/60);if(l<60)return`in ${l}m`;const c=Math.round(l/60);return c<48?`in ${c}h`:`in ${Math.round(c/24)}d`}const n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const i=Math.round(n/60);if(i<60)return`${i}m ago`;const s=Math.round(i/60);return s<48?`${s}h ago`:`${Math.round(s/24)}d ago`}function Jo(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 i=Math.round(n/60);return i<48?`${i}h`:`${Math.round(i/24)}d`}function Cp(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Vl(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 Bi(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Ls(e){return Ap(e)}const Ep=/^\[([^\]]+)\]\s*/,Tp=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Rs=new WeakMap,Ds=new WeakMap;function _p(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:Tp.some(t=>e.startsWith(`${t} `))}function Bs(e){const t=e.match(Ep);if(!t)return e;const n=t[1]??"";return _p(n)?e.slice(t[0].length):e}function Mn(e){const t=e,n=typeof t.role=="string"?t.role:"",i=t.content;if(typeof i=="string")return n==="assistant"?Ls(i):Bs(i);if(Array.isArray(i)){const s=i.map(o=>{const a=o;return a.type==="text"&&typeof a.text=="string"?a.text:null}).filter(o=>typeof o=="string");if(s.length>0){const o=s.join(`
|
|
3
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),pr=/'/g,hr=/"/g,Nl=/^(?:script|style|textarea|title)$/i,Xu=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),u=Xu(1),lt=Symbol.for("lit-noChange"),w=Symbol.for("lit-nothing"),fr=new WeakMap,bt=Ct.createTreeWalker(Ct,129);function Ol(e,t){if(!Vo(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return cr!==void 0?cr.createHTML(t):t}const Zu=(e,t)=>{const n=e.length-1,i=[];let s,o=t===2?"<svg>":t===3?"<math>":"",a=hn;for(let r=0;r<n;r++){const l=e[r];let c,h,d=-1,p=0;for(;p<l.length&&(a.lastIndex=p,h=a.exec(l),h!==null);)p=a.lastIndex,a===hn?h[1]==="!--"?a=dr:h[1]!==void 0?a=ur:h[2]!==void 0?(Nl.test(h[2])&&(s=RegExp("</"+h[2],"g")),a=ft):h[3]!==void 0&&(a=ft):a===ft?h[0]===">"?(a=s??hn,d=-1):h[1]===void 0?d=-2:(d=a.lastIndex-h[2].length,c=h[1],a=h[3]===void 0?ft:h[3]==='"'?hr:pr):a===hr||a===pr?a=ft:a===dr||a===ur?a=hn:(a=ft,s=void 0);const g=a===ft&&e[r+1].startsWith("/>")?" ":"";o+=a===hn?l+Ju:d>=0?(i.push(c),l.slice(0,d)+Dl+l.slice(d)+ot+g):l+ot+(d===-2?r:g)}return[Ol(e,o+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let mo=class Fl{constructor({strings:t,_$litType$:n},i){let s;this.parts=[];let o=0,a=0;const r=t.length-1,l=this.parts,[c,h]=Zu(t,n);if(this.el=Fl.createElement(c,i),bt.currentNode=this.el.content,n===2||n===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(s=bt.nextNode())!==null&&l.length<r;){if(s.nodeType===1){if(s.hasAttributes())for(const d of s.getAttributeNames())if(d.endsWith(Dl)){const p=h[a++],g=s.getAttribute(d).split(ot),$=/([.?@])?(.*)/.exec(p);l.push({type:1,index:o,name:$[2],strings:g,ctor:$[1]==="."?tp:$[1]==="?"?np:$[1]==="@"?ip:ns}),s.removeAttribute(d)}else d.startsWith(ot)&&(l.push({type:6,index:o}),s.removeAttribute(d));if(Nl.test(s.tagName)){const d=s.textContent.split(ot),p=d.length-1;if(p>0){s.textContent=Li?Li.emptyScript:"";for(let g=0;g<p;g++)s.append(d[g],Fn()),bt.nextNode(),l.push({type:2,index:++o});s.append(d[p],Fn())}}}else if(s.nodeType===8)if(s.data===Bl)l.push({type:2,index:o});else{let d=-1;for(;(d=s.data.indexOf(ot,d+1))!==-1;)l.push({type:7,index:o}),d+=ot.length-1}o++}}static createElement(t,n){const i=Ct.createElement("template");return i.innerHTML=t,i}};function Jt(e,t,n=e,i){var a,r;if(t===lt)return t;let s=i!==void 0?(a=n._$Co)==null?void 0:a[i]:n._$Cl;const o=Un(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((r=s==null?void 0:s._$AO)==null||r.call(s,!1),o===void 0?s=void 0:(s=new o(e),s._$AT(e,n,i)),i!==void 0?(n._$Co??(n._$Co=[]))[i]=s:n._$Cl=s),s!==void 0&&(t=Jt(e,s._$AS(e,t.values),s,i)),t}class ep{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:i}=this._$AD,s=((t==null?void 0:t.creationScope)??Ct).importNode(n,!0);bt.currentNode=s;let o=bt.nextNode(),a=0,r=0,l=i[0];for(;l!==void 0;){if(a===l.index){let c;l.type===2?c=new ts(o,o.nextSibling,this,t):l.type===1?c=new l.ctor(o,l.name,l.strings,this,t):l.type===6&&(c=new sp(o,this,t)),this._$AV.push(c),l=i[++r]}a!==(l==null?void 0:l.index)&&(o=bt.nextNode(),a++)}return bt.currentNode=Ct,s}p(t){let n=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,n),n+=i.strings.length-2):i._$AI(t[n])),n++}}let ts=class Ul{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,n,i,s){this.type=2,this._$AH=w,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=n.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,n=this){t=Jt(this,t,n),Un(t)?t===w||t==null||t===""?(this._$AH!==w&&this._$AR(),this._$AH=w):t!==this._$AH&&t!==lt&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Yu(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!==w&&Un(this._$AH)?this._$AA.nextSibling.data=t:this.T(Ct.createTextNode(t)),this._$AH=t}$(t){var o;const{values:n,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=mo.createElement(Ol(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(n);else{const a=new ep(s,this),r=a.u(this.options);a.p(n),this.T(r),this._$AH=a}}_$AC(t){let n=fr.get(t.strings);return n===void 0&&fr.set(t.strings,n=new mo(t)),n}k(t){Vo(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let i,s=0;for(const o of t)s===n.length?n.push(i=new Ul(this.O(Fn()),this.O(Fn()),this,this.options)):i=n[s],i._$AI(o),s++;s<n.length&&(this._$AR(i&&i._$AB.nextSibling,s),n.length=s)}_$AR(t=this._$AA.nextSibling,n){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,n);t!==this._$AB;){const s=lr(t).nextSibling;lr(t).remove(),t=s}}setConnected(t){var n;this._$AM===void 0&&(this._$Cv=t,(n=this._$AP)==null||n.call(this,t))}};class ns{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,i,s,o){this.type=1,this._$AH=w,this._$AN=void 0,this.element=t,this.name=n,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=w}_$AI(t,n=this,i,s){const o=this.strings;let a=!1;if(o===void 0)t=Jt(this,t,n,0),a=!Un(t)||t!==this._$AH&&t!==lt,a&&(this._$AH=t);else{const r=t;let l,c;for(t=o[0],l=0;l<o.length-1;l++)c=Jt(this,r[i+l],n,l),c===lt&&(c=this._$AH[l]),a||(a=!Un(c)||c!==this._$AH[l]),c===w?t=w:t!==w&&(t+=(c??"")+o[l+1]),this._$AH[l]=c}a&&!s&&this.j(t)}j(t){t===w?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let tp=class extends ns{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===w?void 0:t}},np=class extends ns{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==w)}},ip=class extends ns{constructor(t,n,i,s,o){super(t,n,i,s,o),this.type=5}_$AI(t,n=this){if((t=Jt(this,t,n,0)??w)===lt)return;const i=this._$AH,s=t===w&&i!==w||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==w&&(i===w||s);s&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var n;typeof this._$AH=="function"?this._$AH.call(((n=this.options)==null?void 0:n.host)??this.element,t):this._$AH.handleEvent(t)}},sp=class{constructor(t,n,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){Jt(this,t)}};const op={I:ts},Ms=En.litHtmlPolyfillSupport;Ms==null||Ms(mo,ts),(En.litHtmlVersions??(En.litHtmlVersions=[])).push("3.3.2");const ap=(e,t,n)=>{const i=(n==null?void 0:n.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const o=(n==null?void 0:n.renderBefore)??null;i._$litPart$=s=new ts(t.insertBefore(Fn(),o),o,void 0,n??{})}return s._$AI(e),s};const $t=globalThis;let Gt=class extends qt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var n;const t=super.createRenderRoot();return(n=this.renderOptions).renderBefore??(n.renderBefore=t.firstChild),t}update(t){const n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=ap(n,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return lt}};var Ll;Gt._$litElement$=!0,Gt.finalized=!0,(Ll=$t.litElementHydrateSupport)==null||Ll.call($t,{LitElement:Gt});const Ps=$t.litElementPolyfillSupport;Ps==null||Ps({LitElement:Gt});($t.litElementVersions??($t.litElementVersions=[])).push("4.2.2");const Wl=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const rp={attribute:!0,type:String,converter:Ii,reflect:!1,hasChanged:Go},lp=(e=rp,t,n)=>{const{kind:i,metadata:s}=n;let o=globalThis.litPropertyMetadata.get(s);if(o===void 0&&globalThis.litPropertyMetadata.set(s,o=new Map),i==="setter"&&((e=Object.create(e)).wrapped=!0),o.set(n.name,e),i==="accessor"){const{name:a}=n;return{set(r){const l=t.get.call(this);t.set.call(this,r),this.requestUpdate(a,l,e,!0,r)},init(r){return r!==void 0&&this.C(a,void 0,e,r),r}}}if(i==="setter"){const{name:a}=n;return function(r){const l=this[a];t.call(this,r),this.requestUpdate(a,l,e,!0,r)}}throw Error("Unsupported decorator location: "+i)};function is(e){return(t,n)=>typeof n=="object"?lp(e,t,n):((i,s,o)=>{const a=s.hasOwnProperty(o);return s.constructor.createProperty(o,i),a?Object.getOwnPropertyDescriptor(s,o):void 0})(e,t,n)}function v(e){return is({...e,state:!0,attribute:!1})}const cp=50,dp=200,up="Assistant";function gr(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function yo(e){const t=gr(e==null?void 0:e.name,cp)??up,n=gr((e==null?void 0:e.avatar)??void 0,dp)??null;return{agentId:typeof(e==null?void 0:e.agentId)=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function pp(){return yo(typeof window>"u"?{}:{name:window.__TASKMASTER_ASSISTANT_NAME__,avatar:window.__TASKMASTER_ASSISTANT_AVATAR__})}const hp="Taskmaster",fp="/taskmaster-icon.png",gp="#00d4ff",mp="";let ai=null;function Ye(){return ai||(ai={name:window.__TASKMASTER_BRAND_NAME__||hp,iconUrl:window.__TASKMASTER_BRAND_ICON_URL__||fp,accentColor:window.__TASKMASTER_ACCENT_COLOR__||gp,backgroundColor:window.__TASKMASTER_BACKGROUND_COLOR__||mp},ai)}function Be(){return window.__TASKMASTER_WORKSPACE_BRANDS__??{}}function Kl(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 yp(e){const t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!t)return 0;const[n,i,s]=[t[1],t[2],t[3]].map(o=>{const a=parseInt(o,16)/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)});return .2126*n+.7152*i+.0722*s}function zl(e){const t=Kl(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 i=yp(e)>.4?"#111111":"#ffffff";n.style.setProperty("--accent-foreground",i),n.style.setProperty("--primary-foreground",i)}function ri(e,t,n){const i=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e),s=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t);if(!i||!s)return e;const o=(c,h)=>Math.round(parseInt(i[c],16)*(1-n)+parseInt(s[h],16)*n),a=o(1,1),r=o(2,2),l=o(3,3);return`#${a.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}`}const fn={"--bg":"#12141a","--bg-muted":"#262a35","--card":"#181b22","--secondary":"#1e2028"};function ql(e){const t=document.documentElement;if(!e){for(const[i,s]of Object.entries(fn))t.style.setProperty(i,s);t.style.removeProperty("--brand-bg"),t.style.removeProperty("--brand-bg-subtle"),t.style.removeProperty("--brand-bg-card");return}const n=Kl(e);n&&(t.style.setProperty("--bg",ri(fn["--bg"],e,.08)),t.style.setProperty("--bg-muted",ri(fn["--bg-muted"],e,.1)),t.style.setProperty("--card",ri(fn["--card"],e,.12)),t.style.setProperty("--secondary",ri(fn["--secondary"],e,.1)),t.style.setProperty("--brand-bg",e),t.style.setProperty("--brand-bg-subtle",`rgba(${n}, 0.08)`),t.style.setProperty("--brand-bg-card",`rgba(${n}, 0.12)`))}function Tn(e){const t=Ye(),n=Be(),i=e?n[e]:void 0,s=(i==null?void 0:i.accentColor)??t.accentColor;zl(s);const o=(i==null?void 0:i.backgroundColor)??t.backgroundColor;ql(o)}const Ri="taskmaster.control.settings.v1",Hl="taskmaster.account.settings.";function _n(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}`}const Kt={gatewayUrl:_n(),token:"",theme:"system",navCollapsed:!1,navGroupsCollapsed:{}},it={sessionKey:"main",lastActiveSessionKey:"main",chatFocusMode:!1,chatShowThinking:!1,splitRatio:.6};function vp(){try{const e=localStorage.getItem(Ri);if(!e)return{...Kt,gatewayUrl:_n()};const t=JSON.parse(e);return{gatewayUrl:typeof t.gatewayUrl=="string"&&t.gatewayUrl.trim()?t.gatewayUrl.trim():_n(),token:typeof t.token=="string"?t.token:Kt.token,theme:t.theme==="light"||t.theme==="dark"||t.theme==="system"?t.theme:Kt.theme,navCollapsed:typeof t.navCollapsed=="boolean"?t.navCollapsed:Kt.navCollapsed,navGroupsCollapsed:typeof t.navGroupsCollapsed=="object"&&t.navGroupsCollapsed!==null?t.navGroupsCollapsed:Kt.navGroupsCollapsed}}catch{return{...Kt,gatewayUrl:_n()}}}function bp(e){if(!e)return{...it};try{const t=localStorage.getItem(Hl+e);if(!t)return{...it};const n=JSON.parse(t);return{sessionKey:typeof n.sessionKey=="string"&&n.sessionKey.trim()?n.sessionKey.trim():it.sessionKey,lastActiveSessionKey:typeof n.lastActiveSessionKey=="string"&&n.lastActiveSessionKey.trim()?n.lastActiveSessionKey.trim():typeof n.sessionKey=="string"&&n.sessionKey.trim()||it.lastActiveSessionKey,chatFocusMode:typeof n.chatFocusMode=="boolean"?n.chatFocusMode:it.chatFocusMode,chatShowThinking:typeof n.chatShowThinking=="boolean"?n.chatShowThinking:it.chatShowThinking,splitRatio:typeof n.splitRatio=="number"&&n.splitRatio>=.4&&n.splitRatio<=.7?n.splitRatio:it.splitRatio}}catch{return{...it}}}let Di=null;function mr(e){Di=e}function Is(){return{...vp(),...bp(Di)}}function wp(e){const t={gatewayUrl:e.gatewayUrl,token:e.token,theme:e.theme,navCollapsed:e.navCollapsed,navGroupsCollapsed:e.navGroupsCollapsed};if(localStorage.setItem(Ri,JSON.stringify(t)),Di){const n={sessionKey:e.sessionKey,lastActiveSessionKey:e.lastActiveSessionKey,chatFocusMode:e.chatFocusMode,chatShowThinking:e.chatShowThinking,splitRatio:e.splitRatio};localStorage.setItem(Hl+Di,JSON.stringify(n))}}const kp="taskmaster.draft.";function Qo(e,t){return kp+e+"."+t}function Wn(e,t,n){try{const i=Qo(e,t);n?localStorage.setItem(i,n):localStorage.removeItem(i)}catch{}}function Kn(e,t){try{return localStorage.getItem(Qo(e,t))??""}catch{return""}}function xp(e,t){try{localStorage.removeItem(Qo(e,t))}catch{}}let wt=null,Se=null;function yr(e,t,n){Se={workspace:e,sessionKey:t,text:n},wt!=null&&clearTimeout(wt),wt=setTimeout(()=>{Se&&Wn(Se.workspace,Se.sessionKey,Se.text),Se=null,wt=null},300)}function vo(){wt!=null&&clearTimeout(wt),wt=null,Se&&(Wn(Se.workspace,Se.sessionKey,Se.text),Se=null)}(function(){try{const t=localStorage.getItem(Ri);if(!t)return;const n=JSON.parse(t);if(!("sessionKey"in n))return;const i={gatewayUrl:typeof n.gatewayUrl=="string"?n.gatewayUrl:_n(),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(Ri,JSON.stringify(i))}catch{}})();function jl(e){var o;const t=(e??"").trim();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const i=(o=n[1])==null?void 0:o.trim(),s=n.slice(2).join(":");return!i||!s?null:{agentId:i,rest:s}}const $p=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,li=/<\s*\/?\s*final\b[^>]*>/gi,vr=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function Sp(e,t){return e.trimStart()}function Ap(e,t){if(!e||!$p.test(e))return e;let n=e;li.test(n)?(li.lastIndex=0,n=n.replace(li,"")):li.lastIndex=0,vr.lastIndex=0;let i="",s=0,o=!1;for(const a of n.matchAll(vr)){const r=a.index??0,l=a[1]==="/";o?l&&(o=!1):(i+=n.slice(s,r),l||(o=!0)),s=r+a[0].length}return i+=n.slice(s),Sp(i)}function Gl(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"})}function ss(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0){const a=-t,r=Math.round(a/1e3);if(r<60)return`in ${r}s`;const l=Math.round(r/60);if(l<60)return`in ${l}m`;const c=Math.round(l/60);return c<48?`in ${c}h`:`in ${Math.round(c/24)}d`}const n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const i=Math.round(n/60);if(i<60)return`${i}m ago`;const s=Math.round(i/60);return s<48?`${s}h ago`:`${Math.round(s/24)}d ago`}function Jo(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 i=Math.round(n/60);return i<48?`${i}h`:`${Math.round(i/24)}d`}function Cp(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Vl(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 Bi(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Ls(e){return Ap(e)}const Ep=/^\[([^\]]+)\]\s*/,Tp=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Rs=new WeakMap,Ds=new WeakMap;function _p(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:Tp.some(t=>e.startsWith(`${t} `))}function Bs(e){const t=e.match(Ep);if(!t)return e;const n=t[1]??"";return _p(n)?e.slice(t[0].length):e}function Mn(e){const t=e,n=typeof t.role=="string"?t.role:"",i=t.content;if(typeof i=="string")return n==="assistant"?Ls(i):Bs(i);if(Array.isArray(i)){const s=i.map(o=>{const a=o;return a.type==="text"&&typeof a.text=="string"?a.text:null}).filter(o=>typeof o=="string");if(s.length>0){const o=s.join(`
|
|
4
4
|
`);return n==="assistant"?Ls(o):Bs(o)}}return typeof t.text=="string"?n==="assistant"?Ls(t.text):Bs(t.text):null}function Ql(e){if(!e||typeof e!="object")return Mn(e);const t=e;if(Rs.has(t))return Rs.get(t)??null;const n=Mn(e);return Rs.set(t,n),n}function br(e){const n=e.content,i=[];if(Array.isArray(n))for(const r of n){const l=r;if(l.type==="thinking"&&typeof l.thinking=="string"){const c=l.thinking.trim();c&&i.push(c)}}if(i.length>0)return i.join(`
|
|
5
5
|
`);const s=Pp(e);if(!s)return null;const a=[...s.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(r=>(r[1]??"").trim()).filter(Boolean);return a.length>0?a.join(`
|
|
6
6
|
`):null}function Mp(e){if(!e||typeof e!="object")return br(e);const t=e;if(Ds.has(t))return Ds.get(t)??null;const n=br(e);return Ds.set(t,n),n}function Pp(e){const t=e,n=t.content;if(typeof n=="string")return n;if(Array.isArray(n)){const i=n.map(s=>{const o=s;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(s=>typeof s=="string");if(i.length>0)return i.join(`
|
|
7
7
|
`)}return typeof t.text=="string"?t.text:null}function Ip(e){const t=e.trim();if(!t)return"";const n=t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean).map(i=>`_${i}_`);return n.length?["_Reasoning:_",...n].join(`
|
|
8
|
-
`):""}const Lp=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,Rp=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,Dp=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,Bp=/^A new session was started via \/new or \/reset\./;function Np(e){const t=e,n=typeof t.role=="string"?t.role:"";let i="";typeof t.content=="string"?i=t.content:Array.isArray(t.content)?i=t.content.filter(o=>typeof o=="object"&&o!==null).map(o=>o.text??"").join(" "):typeof t.text=="string"&&(i=t.text);const s=i.trim();return s?!!(n==="user"&&Lp.test(s)||n==="assistant"&&Rp.test(s)||n==="user"&&Bp.test(s)||n==="assistant"&&Dp.test(s)):!1}function Jl(e){return e.filter(t=>!Np(t))}function Yl(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const i=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",s=t.content,o=Array.isArray(s)?s:null,a=Array.isArray(o)&&o.some(d=>{const
|
|
8
|
+
`):""}const Lp=/Read HEARTBEAT\.md if it exists|reply HEARTBEAT_OK/i,Rp=/^[\s*`_]*HEARTBEAT_OK[\s*`_]*$/i,Dp=/^[\s*`_]*NO_REPLY[\s*`_]*$/i,Bp=/^A new session was started via \/new or \/reset\./;function Np(e){const t=e,n=typeof t.role=="string"?t.role:"";let i="";typeof t.content=="string"?i=t.content:Array.isArray(t.content)?i=t.content.filter(o=>typeof o=="object"&&o!==null).map(o=>o.text??"").join(" "):typeof t.text=="string"&&(i=t.text);const s=i.trim();return s?!!(n==="user"&&Lp.test(s)||n==="assistant"&&Rp.test(s)||n==="user"&&Bp.test(s)||n==="assistant"&&Dp.test(s)):!1}function Jl(e){return e.filter(t=>!Np(t))}function Yl(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const i=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",s=t.content,o=Array.isArray(s)?s:null,a=Array.isArray(o)&&o.some(d=>{const g=String(d.type??"").toLowerCase();return g==="toolresult"||g==="tool_result"}),r=typeof t.toolName=="string"||typeof t.tool_name=="string";(i||a||r)&&(n="toolResult");let l=[];typeof t.content=="string"?l=[{type:"text",text:t.content}]:Array.isArray(t.content)?l=t.content.map(d=>({type:d.type||"text",text:d.text,name:d.name,args:d.args||d.arguments})):typeof t.text=="string"&&(l=[{type:"text",text:t.text}]);const c=typeof t.timestamp=="number"?t.timestamp:Date.now(),h=typeof t.id=="string"?t.id:void 0;return{role:n,content:l,timestamp:c,id:h}}function Xl(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 Zl(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}function wr(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 Op(){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 os(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),wr(t)}return wr(Op())}const Fe=50;async function Oe(e,t){if(!e.client||!e.connected)return;e.chatLoading=!0,e.lastError=null;const n=(t==null?void 0:t.limit)??Fe;try{const i=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:n}),s=Array.isArray(i.messages)?i.messages:[],o=typeof i.totalMessages=="number"?i.totalMessages:s.length,a=Jl(s);e.chatMessages=a,e.chatHistoryTotal=o,e.chatHistoryHasMore=o>s.length,e.chatThinkingLevel=i.thinkingLevel??null,e.chatModelProvider=typeof i.modelProvider=="string"?i.modelProvider:null,e.chatModel=typeof i.model=="string"?i.model:null,e.chatVerboseLevel=typeof i.verboseLevel=="string"?i.verboseLevel:null,e.chatFillerEnabled=typeof i.fillerEnabled=="boolean"?i.fillerEnabled:null}catch(i){e.lastError=String(i)}finally{e.chatLoading=!1}}async function Fp(e){if(!e.client||!e.connected||e.chatLoadingOlder||!e.chatHistoryHasMore)return!1;e.chatLoadingOlder=!0;try{const t=e.chatMessages.length,n=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:Fe,offset:t}),i=Array.isArray(n.messages)?n.messages:[],s=typeof n.totalMessages=="number"?n.totalMessages:0;if(i.length===0)return e.chatHistoryHasMore=!1,!1;const o=Jl(i);return e.chatMessages=[...o,...e.chatMessages],e.chatHistoryTotal=s,e.chatHistoryHasMore=s>t+i.length,!0}catch(t){return e.lastError=String(t),!1}finally{e.chatLoadingOlder=!1}}function Up(e){const t=/^data:(.+?);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function ec(e,t,n){if(e.chatSuggestions=[],!e.client||!e.connected)return!1;const i=t.trim(),s=n&&n.length>0;if(!i&&!s)return!1;const o=Date.now(),a=(n??[]).filter(g=>!g.fileName),r=(n??[]).filter(g=>g.fileName),l=[],c=r.map(g=>g.fileName).filter(Boolean);if(c.length>0){const g=i?`${c.join(", ")}
|
|
9
9
|
|
|
10
|
-
${i}`:c.join(", ");l.push({type:"text",text:
|
|
10
|
+
${i}`:c.join(", ");l.push({type:"text",text:g})}else i&&l.push({type:"text",text:i});for(const g of a)l.push({type:"image",source:{type:"base64",media_type:g.mimeType,data:g.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:l,timestamp:o}],e.chatSending=!0,e.lastError=null;const h=os();e.chatRunId=h,e.chatStream="",e.chatStreamStartedAt=o;const d=[...a,...r],p=d.length>0?d.map(g=>{if(g.textContent)return{type:"document",mimeType:g.mimeType||"text/plain",fileName:g.fileName,content:btoa(unescape(encodeURIComponent(g.textContent)))};const $=Up(g.dataUrl);return $?{type:g.fileName?"document":"image",mimeType:$.mimeType,fileName:g.fileName,content:$.content}:null}).filter(g=>g!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:i,deliver:!1,idempotencyKey:h,attachments:p}),!0}catch(g){const $=String(g);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=$,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+$}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function tc(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 nc(e,t){var n,i;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==="working"){const o=(t.message?(n=Mn(t.message))==null?void 0:n.trim():void 0)||((i=e.chatStream)==null?void 0:i.trim());if(o)if(!e.chatInterimText)e.chatInterimText=o;else{const a=o.trim(),r=e.chatInterimText.trim();a===r||r.endsWith(a)||(a.startsWith(r)?e.chatInterimText=o:e.chatInterimText=`${e.chatInterimText}
|
|
11
11
|
|
|
12
12
|
${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.message);return typeof s=="string"&&s.trim()&&(e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:s.trim()}],timestamp:Date.now(),filler:!0}]),"block"}else if(t.state==="delta"){e.chatSuggestions=[];const s=Mn(t.message);if(typeof s=="string"){if(s.trim()==="NO_REPLY")return null;const o=e.chatStream??"";(!o||s.length>=o.length)&&(e.chatStream=s)}}else t.state==="final"||t.state==="aborted"?(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.chatInterimText=null):t.state==="error"&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.chatInterimText=null,e.lastError=t.errorMessage??"chat error");return t.state}const Ni=Object.freeze(Object.defineProperty({__proto__:null,CHAT_PAGE_SIZE:Fe,abortChatRun:tc,handleChatEvent:nc,loadChatHistory:Oe,loadOlderChatHistory:Fp,sendChatMessage:ec},Symbol.toStringTag,{value:"Module"}));async function Yo(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=Bi(e.sessionsFilterActive??"",0),i=Bi(e.sessionsFilterLimit??"",0);n>0&&(t.activeMinutes=n),i>0&&(t.limit=i);const s=await e.client.request("sessions.list",t);s&&(e.sessionsResult=s)}catch(t){e.sessionsError=String(t)}finally{e.sessionsLoading=!1}}}async function ci(e,t,n){if(!e.client||!e.connected)return;const i={key:t};"label"in n&&(i.label=n.label),"thinkingLevel"in n&&(i.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(i.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(i.reasoningLevel=n.reasoningLevel),"model"in n&&(i.model=n.model),"fillerEnabled"in n&&(i.fillerEnabled=n.fillerEnabled);try{await e.client.request("sessions.patch",i),await Yo(e)}catch(s){e.sessionsError=String(s)}}const kr=50,Wp=80,Kp=12e4;function zp(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 i=n.map(s=>{if(!s||typeof s!="object")return null;const o=s;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(s=>!!s);return i.length===0?null:i.join(`
|
|
13
|
-
`)}function
|
|
13
|
+
`)}function xr(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=zp(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 i=Vl(n,Kp);return i.truncated?`${i.text}
|
|
14
14
|
|
|
15
|
-
… truncated (${i.total} chars, showing first ${i.text.length}).`:i.text}function qp(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 Hp(e){if(e.toolStreamOrder.length<=kr)return;const t=e.toolStreamOrder.length-kr,n=e.toolStreamOrder.splice(0,t);for(const i of n)e.toolStreamById.delete(i)}function jp(e){e.chatToolMessages=e.toolStreamOrder.map(t=>{var n;return(n=e.toolStreamById.get(t))==null?void 0:n.message}).filter(t=>!!t)}function bo(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),jp(e)}function Gp(e,t=!1){if(t){bo(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>bo(e),Wp))}function Xo(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],bo(e)}const Vp=5e3;function Qp(e,t){var s;const n=t.data??{},i=typeof n.phase=="string"?n.phase:"";e.compactionClearTimer!=null&&(window.clearTimeout(e.compactionClearTimer),e.compactionClearTimer=null),i==="start"?e.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null}:i==="end"&&(e.compactionStatus={active:!1,startedAt:((s=e.compactionStatus)==null?void 0:s.startedAt)??null,completedAt:Date.now()},e.compactionClearTimer=window.setTimeout(()=>{e.compactionStatus=null,e.compactionClearTimer=null},Vp))}function Jp(e,t){if(!t)return;if(t.stream==="compaction"){Qp(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 i=t.data??{},s=typeof i.toolCallId=="string"?i.toolCallId:"";if(!s)return;const o=typeof i.name=="string"?i.name:"tool",a=typeof i.phase=="string"?i.phase:"",r=a==="start"?i.args:void 0,l=a==="update"
|
|
15
|
+
… truncated (${i.total} chars, showing first ${i.text.length}).`:i.text}function qp(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 Hp(e){if(e.toolStreamOrder.length<=kr)return;const t=e.toolStreamOrder.length-kr,n=e.toolStreamOrder.splice(0,t);for(const i of n)e.toolStreamById.delete(i)}function jp(e){e.chatToolMessages=e.toolStreamOrder.map(t=>{var n;return(n=e.toolStreamById.get(t))==null?void 0:n.message}).filter(t=>!!t)}function bo(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),jp(e)}function Gp(e,t=!1){if(t){bo(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>bo(e),Wp))}function Xo(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],bo(e)}const Vp=5e3;function Qp(e,t){var s;const n=t.data??{},i=typeof n.phase=="string"?n.phase:"";e.compactionClearTimer!=null&&(window.clearTimeout(e.compactionClearTimer),e.compactionClearTimer=null),i==="start"?e.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null}:i==="end"&&(e.compactionStatus={active:!1,startedAt:((s=e.compactionStatus)==null?void 0:s.startedAt)??null,completedAt:Date.now()},e.compactionClearTimer=window.setTimeout(()=>{e.compactionStatus=null,e.compactionClearTimer=null},Vp))}function Jp(e,t){if(!t)return;if(t.stream==="compaction"){Qp(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 i=t.data??{},s=typeof i.toolCallId=="string"?i.toolCallId:"";if(!s)return;const o=typeof i.name=="string"?i.name:"tool",a=typeof i.phase=="string"?i.phase:"",r=a==="start"?i.args:void 0,l=a==="update"?xr(i.partialResult):a==="result"?xr(i.result):void 0,c=Date.now();let h=e.toolStreamById.get(s);h?(h.name=o,r!==void 0&&(h.args=r),l!==void 0&&(h.output=l),h.updatedAt=c):(h={toolCallId:s,runId:t.runId,sessionKey:n,name:o,args:r,output:l,startedAt:typeof t.ts=="number"?t.ts:c,updatedAt:c,message:{}},e.toolStreamById.set(s,h),e.toolStreamOrder.push(s)),h.message=qp(h),Hp(e),Gp(e,a==="result")}let di=0;function nn(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=++di,i=()=>{const s=e.querySelector(".chat-thread");if(s){const o=getComputedStyle(s).overflowY;if(o==="auto"||o==="scroll"||s.scrollHeight-s.clientHeight>1)return s}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{n===di&&(e.chatScrollFrame=requestAnimationFrame(()=>{if(e.chatScrollFrame=null,n!==di)return;const s=i();if(!s)return;const o=s.scrollHeight-s.scrollTop-s.clientHeight;if(!(t||e.chatUserNearBottom||o<200))return;t&&(e.chatHasAutoScrolled=!0),s.scrollTop=s.scrollHeight,e.chatUserNearBottom=!0;const r=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{if(e.chatScrollTimeout=null,n!==di)return;const l=i();if(!l)return;const c=l.scrollHeight-l.scrollTop-l.clientHeight;(t||e.chatUserNearBottom||c<200)&&(l.scrollTop=l.scrollHeight,e.chatUserNearBottom=!0)},r)}))})}function ic(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 Yp(e,t){const n=t.currentTarget;if(!n)return;const i=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=i<200,n.scrollTop<100&&e.onLoadOlder&&e.onLoadOlder()}function Xp(e){const t=e.querySelector(".chat-thread");if(!t)return null;const n=t.scrollHeight,i=t.scrollTop;return()=>{const s=t.scrollHeight-n;t.scrollTop=i+s}}function Zp(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function eh(e,t){const n=t.currentTarget;n&&(e.logsAtBottom=n.scrollTop<80)}function th(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function nh(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
|
|
16
16
|
`)}
|
|
17
17
|
`],{type:"text/plain"}),i=URL.createObjectURL(n),s=document.createElement("a"),o=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");s.href=i,s.download=`taskmaster-logs-${t}-${o}.log`,s.click(),URL.revokeObjectURL(i)}function ih(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
|
|
18
18
|
`)}
|
|
19
19
|
`],{type:"text/plain"}),i=URL.createObjectURL(n),s=document.createElement("a"),o=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");s.href=i,s.download=`taskmaster-session-logs-${t}-${o}.log`,s.click(),URL.revokeObjectURL(i)}function sh(e){if(typeof ResizeObserver>"u")return;const t=e.querySelector(".topbar");if(!t)return;const n=()=>{const{height:i}=t.getBoundingClientRect();e.style.setProperty("--topbar-height",`${i}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}function ct(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Et(e){return`${JSON.stringify(e,null,2).trimEnd()}
|
|
20
|
-
`}function sc(e,t,n){if(t.length===0)return;let i=e;for(let o=0;o<t.length-1;o+=1){const a=t[o],r=t[o+1];if(typeof a=="number"){if(!Array.isArray(i))return;i[a]==null&&(i[a]=typeof r=="number"?[]:{}),i=i[a]}else{if(typeof i!="object"||i==null)return;const l=i;l[a]==null&&(l[a]=typeof r=="number"?[]:{}),i=l[a]}}const s=t[t.length-1];if(typeof s=="number"){Array.isArray(i)&&(i[s]=n);return}typeof i=="object"&&i!=null&&(i[s]=n)}async function Ue(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});ah(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function oc(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});oh(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function oh(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function ah(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?Et(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=Et(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=ct(t.config??{}),e.configFormOriginal=ct(t.config??{}),e.configRawOriginal=n)}async function rh(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?Et(e.configForm):e.configRaw,i=(t=e.configSnapshot)==null?void 0:t.hash;if(!i){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:n,baseHash:i}),e.configFormDirty=!1,await Ue(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function sn(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 jn(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 ac(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=Bi(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const i=e.everyUnit;return{kind:"every",everyMs:n*(i==="minutes"?6e4:i==="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 rc(e){if(e.payloadKind==="systemEvent"){const o=e.payloadText.trim();if(!o)throw new Error("System event text required.");return{kind:"systemEvent",text:o}}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);const i=[];e.toAdmins&&i.push("admins");for(const o of e.recipients){const a=o.trim();a&&i.push(a)}i.length>0&&(n.to=i.join(","));const s=Bi(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function lh(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=ac(e.cronForm),i=rc(e.cronForm),s=e.cronForm.agentId.trim(),o=(t=e.cronForm.accountId)==null?void 0:t.trim(),a={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,accountId:o||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:i,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!a.name)throw new Error("Name required.");await e.client.request("cron.add",a),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await jn(e),await sn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function ch(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 jn(e),await sn(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function dh(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null,e.cronRunModalJobId=t.id,e.cronRunModalJobName=t.name||"Untitled",e.cronRunResult=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await wo(e,t.id)}catch(n){e.cronError=String(n),e.cronRunResult={status:"error",error:String(n)}}finally{e.cronBusy=!1}}}function uh(e,t){e.cronRunModalJobId&&t.jobId===e.cronRunModalJobId&&t.action==="finished"&&(e.cronRunResult={status:t.status??"unknown",durationMs:t.durationMs,summary:t.summary,error:t.error})}async function ph(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 jn(e),await sn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}function hh(e){var n;const t={name:e.name||"",description:e.description||"",agentId:e.agentId||"",enabled:e.enabled,scheduleKind:e.schedule.kind,scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"",cronTz:"",sessionTarget:e.sessionTarget||"main",wakeMode:e.wakeMode||"next-heartbeat",payloadKind:e.payload.kind,payloadText:"",deliver:!1,channel:"last",recipients:[],toAdmins:!1,timeoutSeconds:"",postToMainPrefix:""};if(e.schedule.kind==="at"){const i=new Date(e.schedule.atMs),s=o=>String(o).padStart(2,"0");t.scheduleAt=`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}T${s(i.getHours())}:${s(i.getMinutes())}`}else if(e.schedule.kind==="every"){const i=e.schedule.everyMs;i%864e5===0?(t.everyAmount=String(i/864e5),t.everyUnit="days"):i%36e5===0?(t.everyAmount=String(i/36e5),t.everyUnit="hours"):(t.everyAmount=String(i/6e4),t.everyUnit="minutes")}else e.schedule.kind==="cron"&&(t.cronExpr=e.schedule.expr,t.cronTz=e.schedule.tz||"");if(e.payload.kind==="systemEvent")t.payloadText=e.payload.text;else if(e.payload.kind==="agentTurn"){t.payloadText=e.payload.message,t.deliver=e.payload.deliver??!1,t.timeoutSeconds=e.payload.timeoutSeconds?String(e.payload.timeoutSeconds):"";const i=e.payload.channel??e.payload.provider;t.channel=i||"last";const s=e.payload.to||"";if(s){const o=s.split(",").map(a=>a.trim()).filter(Boolean);t.toAdmins=o.some(a=>a.toLowerCase()==="admins"),t.recipients=o.filter(a=>a.toLowerCase()!=="admins")}}return(n=e.isolation)!=null&&n.postToMainPrefix&&(t.postToMainPrefix=e.isolation.postToMainPrefix),t}async function fh(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=ac(e.cronForm),i=rc(e.cronForm),s={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:e.cronForm.agentId.trim()||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:i};if(e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?s.isolation={postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:s.isolation=void 0,!s.name)throw new Error("Name required.");await e.client.request("cron.update",{id:t,patch:s}),await jn(e),await sn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function wo(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 ee(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 Zo(e,t,n){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0,e.whatsappActiveQrAccountId=n??null;try{const i=await e.client.request("web.login.start",{force:t,timeoutMs:3e4,accountId:n});e.whatsappLoginMessage=i.message??null,e.whatsappLoginQrDataUrl=i.qrDataUrl??null,e.whatsappLoginConnected=null}catch(i){e.whatsappLoginMessage=String(i),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function lc(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 cc(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 dc(e,t){if(!e.client||!e.connected||e.whatsappAccountSaving)return;const n=t.trim();if(!n){e.whatsappAccountError="Account name is required.";return}const i=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");if(!i){e.whatsappAccountError="Invalid account name.";return}e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const o=ct(s.config??{});(!o.channels||typeof o.channels!="object")&&(o.channels={});const a=o.channels;(!a.whatsapp||typeof a.whatsapp!="object")&&(a.whatsapp={});const r=a.whatsapp;(!r.accounts||typeof r.accounts!="object")&&(r.accounts={});const l=r.accounts;if(l[i]){e.whatsappAccountError=`Account "${i}" already exists.`;return}l[i]={name:n,provider:"baileys"};const c=s.hash;if(!c){e.whatsappAccountError="Config hash missing; reload and retry.";return}const h=Et(o);await e.client.request("config.set",{raw:h,baseHash:c}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await ee(e,!0),await Zo(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function uc(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 i=ct(n.config??{}),s=i.channels,o=s==null?void 0:s.whatsapp,a=o==null?void 0:o.accounts;if(!a){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(a).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!a[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete a[t],Array.isArray(i.bindings)&&(i.bindings=i.bindings.filter(h=>{const d=h.match;return!d||d.channel!=="whatsapp"?!0:d.accountId!==t}));const l=n.hash;if(!l){e.whatsappAccountError="Config hash missing; reload and retry.";return}const c=Et(i);await e.client.request("config.set",{raw:c,baseHash:l}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await ee(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const gh=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:dc,loadChannels:ee,logoutWhatsApp:cc,removeWhatsAppAccount:uc,startWhatsAppLogin:Zo,waitWhatsAppLogin:lc},Symbol.toStringTag,{value:"Module"}));async function ea(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,i,s]=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=i;e.debugModels=Array.isArray(o==null?void 0:o.models)?o==null?void 0:o.models:[],e.debugHeartbeat=s}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}const mh=2e3,yh=new Set(["trace","debug","info","warn","error","fatal"]);function vh(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 bh(e){if(typeof e!="string")return null;const t=e.toLowerCase();return yh.has(t)?t:null}function pc(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,i=typeof t.time=="string"?t.time:typeof(n==null?void 0:n.date)=="string"?n==null?void 0:n.date:null,s=bh((n==null?void 0:n.logLevelName)??(n==null?void 0:n.level)),o=typeof t[0]=="string"?t[0]:typeof(n==null?void 0:n.name)=="string"?n==null?void 0:n.name:null,a=vh(o);let r=null;a&&(typeof a.subsystem=="string"?r=a.subsystem:typeof a.module=="string"&&(r=a.module)),!r&&o&&o.length<120&&(r=o);let l=null;return typeof t[1]=="string"?l=t[1]:!a&&typeof t[0]=="string"?l=t[0]:typeof t.message=="string"&&(l=t.message),{raw:e,time:i,level:s,subsystem:r,message:l??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Vt(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.logsLoading=!0),e.logsError=null;try{const i=await e.client.request("logs.tail",{cursor:t!=null&&t.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),o=(Array.isArray(i.lines)?i.lines.filter(r=>typeof r=="string"):[]).map(pc),a=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=a?o:[...e.logsEntries,...o].slice(-mh),typeof i.cursor=="number"&&(e.logsCursor=i.cursor),typeof i.file=="string"&&(e.logsFile=i.file),e.logsTruncated=!!i.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t!=null&&t.quiet||(e.logsLoading=!1)}}}const wh=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:Vt,parseLogLine:pc},Symbol.toStringTag,{value:"Module"}));const hc={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:pe,n:Ai,Gx:xr,Gy:Sr,a:Ns,d:Os,h:kh}=hc,Tt=32,ta=64,$h=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},ae=(e="")=>{const t=new Error(e);throw $h(t,ae),t},xh=e=>typeof e=="bigint",Sh=e=>typeof e=="string",Ah=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",ut=(e,t,n="")=>{const i=Ah(e),s=e==null?void 0:e.length,o=t!==void 0;if(!i||o&&s!==t){const a=n&&`"${n}" `,r=o?` of length ${t}`:"",l=i?`length=${s}`:`type=${typeof e}`;ae(a+"expected Uint8Array"+r+", got "+l)}return e},as=e=>new Uint8Array(e),fc=e=>Uint8Array.from(e),gc=(e,t)=>e.toString(16).padStart(t,"0"),mc=e=>Array.from(ut(e)).map(t=>gc(t,2)).join(""),je={_0:48,_9:57,A:65,F:70,a:97,f:102},Ar=e=>{if(e>=je._0&&e<=je._9)return e-je._0;if(e>=je.A&&e<=je.F)return e-(je.A-10);if(e>=je.a&&e<=je.f)return e-(je.a-10)},yc=e=>{const t="hex invalid";if(!Sh(e))return ae(t);const n=e.length,i=n/2;if(n%2)return ae(t);const s=as(i);for(let o=0,a=0;o<i;o++,a+=2){const r=Ar(e.charCodeAt(a)),l=Ar(e.charCodeAt(a+1));if(r===void 0||l===void 0)return ae(t);s[o]=r*16+l}return s},vc=()=>globalThis==null?void 0:globalThis.crypto,Ch=()=>{var e;return((e=vc())==null?void 0:e.subtle)??ae("crypto.subtle must be defined, consider polyfill")},zn=(...e)=>{const t=as(e.reduce((i,s)=>i+ut(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},Eh=(e=Tt)=>vc().getRandomValues(as(e)),Oi=BigInt,yt=(e,t,n,i="bad number: out of range")=>xh(e)&&t<=e&&e<n?e:ae(i),D=(e,t=pe)=>{const n=e%t;return n>=0n?n:t+n},bc=e=>D(e,Ai),Th=(e,t)=>{(e===0n||t<=0n)&&ae("no inverse n="+e+" mod="+t);let n=D(e,t),i=t,s=0n,o=1n;for(;n!==0n;){const a=i/n,r=i%n,l=s-o*a;i=n,n=r,s=o,o=l}return i===1n?D(s,t):ae("no inverse")},_h=e=>{const t=xc[e];return typeof t!="function"&&ae("hashes."+e+" not set"),t},Fs=e=>e instanceof _t?e:ae("Point expected"),ko=2n**256n,Ne=class Ne{constructor(t,n,i,s){q(this,"X");q(this,"Y");q(this,"Z");q(this,"T");const o=ko;this.X=yt(t,0n,o),this.Y=yt(n,0n,o),this.Z=yt(i,1n,o),this.T=yt(s,0n,o),Object.freeze(this)}static CURVE(){return hc}static fromAffine(t){return new Ne(t.x,t.y,1n,D(t.x*t.y))}static fromBytes(t,n=!1){const i=Os,s=fc(ut(t,Tt)),o=t[31];s[31]=o&-129;const a=kc(s);yt(a,0n,n?ko:pe);const l=D(a*a),c=D(l-1n),h=D(i*l+1n);let{isValid:d,value:p}=Ph(c,h);d||ae("bad point: y not sqrt");const v=(p&1n)===1n,S=(o&128)!==0;return!n&&p===0n&&S&&ae("bad point: x==0, isLastByteOdd"),S!==v&&(p=D(-p)),new Ne(p,a,1n,D(p*a))}static fromHex(t,n){return Ne.fromBytes(yc(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=Ns,n=Os,i=this;if(i.is0())return ae("bad point: ZERO");const{X:s,Y:o,Z:a,T:r}=i,l=D(s*s),c=D(o*o),h=D(a*a),d=D(h*h),p=D(l*t),v=D(h*D(p+c)),S=D(d+D(n*D(l*c)));if(v!==S)return ae("bad point: equation left != right (1)");const x=D(s*o),T=D(a*r);return x!==T?ae("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:o,Y:a,Z:r}=Fs(t),l=D(n*r),c=D(o*s),h=D(i*r),d=D(a*s);return l===c&&h===d}is0(){return this.equals(jt)}negate(){return new Ne(D(-this.X),this.Y,this.Z,D(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=Ns,o=D(t*t),a=D(n*n),r=D(2n*D(i*i)),l=D(s*o),c=t+n,h=D(D(c*c)-o-a),d=l+a,p=d-r,v=l-a,S=D(h*p),x=D(d*v),T=D(h*v),f=D(p*d);return new Ne(S,x,f,T)}add(t){const{X:n,Y:i,Z:s,T:o}=this,{X:a,Y:r,Z:l,T:c}=Fs(t),h=Ns,d=Os,p=D(n*a),v=D(i*r),S=D(o*d*c),x=D(s*l),T=D((n+i)*(a+r)-p-v),f=D(x-S),b=D(x+S),k=D(v-h*p),A=D(T*f),E=D(b*k),M=D(T*k),P=D(f*b);return new Ne(A,E,P,M)}subtract(t){return this.add(Fs(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return jt;if(yt(t,1n,Ai),t===1n)return this;if(this.equals(Mt))return Kh(t).p;let i=jt,s=Mt;for(let o=this;t>0n;o=o.double(),t>>=1n)t&1n?i=i.add(o):n&&(s=s.add(o));return i}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:i}=this;if(this.equals(jt))return{x:0n,y:1n};const s=Th(i,pe);D(i*s)!==1n&&ae("invalid inverse");const o=D(t*s),a=D(n*s);return{x:o,y:a}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),i=wc(n);return i[31]|=t&1n?128:0,i}toHex(){return mc(this.toBytes())}clearCofactor(){return this.multiply(Oi(kh),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Ai/2n,!1).double();return Ai%2n&&(t=t.add(this)),t.is0()}};q(Ne,"BASE"),q(Ne,"ZERO");let _t=Ne;const Mt=new _t(xr,Sr,1n,D(xr*Sr)),jt=new _t(0n,1n,1n,0n);_t.BASE=Mt;_t.ZERO=jt;const wc=e=>yc(gc(yt(e,0n,ko),ta)).reverse(),kc=e=>Oi("0x"+mc(fc(ut(e)).reverse())),Ie=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=pe;return n},Mh=e=>{const n=e*e%pe*e%pe,i=Ie(n,2n)*n%pe,s=Ie(i,1n)*e%pe,o=Ie(s,5n)*s%pe,a=Ie(o,10n)*o%pe,r=Ie(a,20n)*a%pe,l=Ie(r,40n)*r%pe,c=Ie(l,80n)*l%pe,h=Ie(c,80n)*l%pe,d=Ie(h,10n)*o%pe;return{pow_p_5_8:Ie(d,2n)*e%pe,b2:n}},Cr=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Ph=(e,t)=>{const n=D(t*t*t),i=D(n*n*t),s=Mh(e*i).pow_p_5_8;let o=D(e*n*s);const a=D(t*o*o),r=o,l=D(o*Cr),c=a===e,h=a===D(-e),d=a===D(-e*Cr);return c&&(o=r),(h||d)&&(o=l),(D(o)&1n)===1n&&(o=D(-o)),{isValid:c||h,value:o}},$o=e=>bc(kc(e)),na=(...e)=>xc.sha512Async(zn(...e)),Ih=(...e)=>_h("sha512")(zn(...e)),$c=e=>{const t=e.slice(0,Tt);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(Tt,ta),i=$o(t),s=Mt.multiply(i),o=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:o}},ia=e=>na(ut(e,Tt)).then($c),Lh=e=>$c(Ih(ut(e,Tt))),Rh=e=>ia(e).then(t=>t.pointBytes),Dh=e=>na(e.hashable).then(e.finish),Bh=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,o=$o(t),a=Mt.multiply(o).toBytes();return{hashable:zn(a,i,n),finish:c=>{const h=bc(o+$o(c)*s);return ut(zn(a,wc(h)),ta)}}},Nh=async(e,t)=>{const n=ut(e),i=await ia(t),s=await na(i.prefix,n);return Dh(Bh(i,s,n))},xc={sha512Async:async e=>{const t=Ch(),n=zn(e);return as(await t.digest("SHA-512",n.buffer))},sha512:void 0},Oh=(e=Eh(Tt))=>e,Fh={getExtendedPublicKeyAsync:ia,getExtendedPublicKey:Lh,randomSecretKey:Oh},Fi=8,Uh=256,Sc=Math.ceil(Uh/Fi)+1,xo=2**(Fi-1),Wh=()=>{const e=[];let t=Mt,n=t;for(let i=0;i<Sc;i++){n=t,e.push(n);for(let s=1;s<xo;s++)n=n.add(t),e.push(n);t=n.double()}return e};let Er;const Tr=(e,t)=>{const n=t.negate();return e?n:t},Kh=e=>{const t=Er||(Er=Wh());let n=jt,i=Mt;const s=2**Fi,o=s,a=Oi(s-1),r=Oi(Fi);for(let l=0;l<Sc;l++){let c=Number(e&a);e>>=r,c>xo&&(c-=o,e+=1n);const h=l*xo,d=h,p=h+Math.abs(c)-1,v=l%2!==0,S=c<0;c===0?i=i.add(Tr(v,t[d])):n=n.add(Tr(S,t[p]))}return e!==0n&&ae("invalid wnaf"),{p:n,f:i}},Us="taskmaster-device-identity-v1";function So(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Ac(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),i=atob(n),s=new Uint8Array(i.length);for(let o=0;o<i.length;o+=1)s[o]=i.charCodeAt(o);return s}function zh(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Cc(e){const t=await crypto.subtle.digest("SHA-256",e);return zh(new Uint8Array(t))}async function qh(){const e=Fh.randomSecretKey(),t=await Rh(e);return{deviceId:await Cc(t),publicKey:So(t),privateKey:So(e)}}async function Hh(){try{const n=localStorage.getItem(Us);if(n){const i=JSON.parse(n);if((i==null?void 0:i.version)===1&&typeof i.deviceId=="string"&&typeof i.publicKey=="string"&&typeof i.privateKey=="string"){const s=await Cc(Ac(i.publicKey));if(s!==i.deviceId){const o={...i,deviceId:s};return localStorage.setItem(Us,JSON.stringify(o)),{deviceId:s,publicKey:i.publicKey,privateKey:i.privateKey}}return{deviceId:i.deviceId,publicKey:i.publicKey,privateKey:i.privateKey}}}}catch{}const e=await qh(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Us,JSON.stringify(t)),e}async function jh(e,t){const n=Ac(e),i=new TextEncoder().encode(t),s=await Nh(i,n);return So(s)}const Ec="taskmaster.device.auth.v1";function sa(e){return e.trim()}function Gh(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const i=n.trim();i&&t.add(i)}return[...t].sort()}function oa(){try{const e=window.localStorage.getItem(Ec);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 Tc(e){try{window.localStorage.setItem(Ec,JSON.stringify(e))}catch{}}function Vh(e){const t=oa();if(!t||t.deviceId!==e.deviceId)return null;const n=sa(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function Qh(e){const t=sa(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=oa();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:Gh(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,Tc(n),s}function Jh(e){const t=oa();if(!t||t.deviceId!==e.deviceId)return;const n=sa(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],Tc(i)}async function aa(e,t){if(!(!e.client||!e.connected)&&!e.devicesLoading){e.devicesLoading=!0,t!=null&&t.quiet||(e.devicesError=null);try{const n=await e.client.request("device.pair.list",{});e.devicesList={pending:Array.isArray(n==null?void 0:n.pending)?n.pending:[],paired:Array.isArray(n==null?void 0:n.paired)?n.paired:[]}}catch(n){t!=null&&t.quiet||(e.devicesError=String(n))}finally{e.devicesLoading=!1}}}async function ra(e,t){if(!(!e.client||!e.connected)&&!e.nodesLoading){e.nodesLoading=!0,t!=null&&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!=null&&t.quiet||(e.lastError=String(n))}finally{e.nodesLoading=!1}}}function Yh(e){return{method:"exec.approvals.get",params:{}}}async function Xh(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=Yh(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);Zh(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function Zh(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=ct(t.file??{}))}async function _c(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 dt(e,t,n){if(!t.trim())return;const i={...e.skillMessages};n?i[t]=n:delete i[t],e.skillMessages=i}function Ze(e){return e instanceof Error?e.message:String(e)}function qn(){return{name:"",skillContent:"",references:[]}}async function Xe(e,t){if(t!=null&&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=Ze(n)}finally{e.skillsLoading=!1}}}function Mc(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Pc(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 Xe(e),dt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=Ze(i);e.skillsError=s,dt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function Ic(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 Xe(e),dt(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=Ze(n);e.skillsError=i,dt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Lc(e,t,n,i){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const s=await e.client.request("skills.install",{name:n,installId:i,timeoutMs:12e4});await Xe(e),dt(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const o=Ze(s);e.skillsError=o,dt(e,t,{kind:"error",message:o})}finally{e.skillsBusyKey=null}}}async function Rc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("skills.read",{name:t});n&&(e.skillDetail=n,e.skillDetailTab="SKILL.md")}catch(n){e.skillsError=Ze(n)}}function Dc(e){e.skillDetail=null,e.skillDetailTab=""}function Bc(e,t){e.skillDetailTab=t}async function Nc(e){if(e.skillAddModal=!0,e.skillAddForm=qn(),e.skillAddFormSource="draft",e.skillEditTab="SKILL.md",e.skillDrafts=[],!(!e.client||!e.connected))try{const t=await e.client.request("skills.drafts",{});t&&(e.skillDrafts=t.drafts)}catch{}}function Oc(e){e.skillAddModal=!1,e.skillAddForm=qn(),e.skillAddFormSource="draft",e.skillEditTab="SKILL.md",e.skillDrafts=[]}function Fc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n}))},e.skillAddFormSource="draft"}async function Uc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n}))},e.skillAddFormSource="installed",await la(e)}async function la(e){if(!e.client||!e.connected)return;const t=e.skillAddForm;if(!(!t.name.trim()||!t.skillContent.trim())){e.skillsBusyKey="__add__",e.skillsError=null;try{const n=t.references.filter(s=>s.name.trim()&&s.content.trim()).map(s=>({name:s.name.trim(),content:s.content})),i=t.name.trim();e.skillAddFormSource==="installed"?(await e.client.request("skills.create",{name:i,skillContent:t.skillContent,references:n.length>0?n:void 0}),e.skillAddModal=!1,e.skillAddForm=qn(),e.skillAddFormSource="draft",e.skillDrafts=[],await Xe(e),dt(e,i,{kind:"success",message:"Skill saved — active on next message"})):(await e.client.request("skills.saveDraft",{name:i,skillContent:t.skillContent,references:n.length>0?n:void 0}),e.skillAddModal=!1,e.skillAddForm=qn(),e.skillAddFormSource="draft",e.skillDrafts=[],dt(e,i,{kind:"success",message:"Draft saved"}))}catch(n){e.skillsError=Ze(n)}finally{e.skillsBusyKey=null}}}async function Wc(e,t){if(!(!e.client||!e.connected))try{await e.client.request("skills.deleteDraft",{name:t}),e.skillDrafts=e.skillDrafts.filter(n=>n.name!==t)}catch(n){e.skillsError=Ze(n)}}async function Kc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("skills.read",{name:t});if(!n)return;e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i}))},e.skillAddFormSource="installed",e.skillAddModal=!0,e.skillDrafts=[]}catch(n){e.skillsError=Ze(n)}}function zc(e,t){const n=e.skillDetail;n&&(e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i}))},e.skillAddFormSource="installed",e.skillEditTab=t&&t!=="SKILL.md"?t:"SKILL.md",e.skillDetail=null,e.skillDetailTab="",e.skillAddModal=!0,e.skillDrafts=[])}function qc(e,t,n){e.skillAddForm={...e.skillAddForm,references:e.skillAddForm.references.map(i=>i.name===t?{...i,content:n}:i)}}function Hc(e,t){e.skillEditTab=t}async function jc(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.delete",{name:t}),await Xe(e)}catch(n){e.skillsError=Ze(n)}finally{e.skillsBusyKey=null}}}const ef=Object.freeze(Object.defineProperty({__proto__:null,closeAddSkillModal:Oc,closeSkillDetail:Dc,deleteDraft:Wc,deleteSkill:jc,editDetailSkill:zc,editSkill:Kc,emptyAddForm:qn,importDraft:Fc,installDraft:Uc,installSkill:Lc,loadSkills:Xe,openAddSkillModal:Nc,saveNewSkill:la,saveSkillApiKey:Ic,setEditTab:Hc,setSkillDetailTab:Bc,updateFormReference:qc,updateSkillEdit:Mc,updateSkillEnabled:Pc,viewSkillDetail:Rc},Symbol.toStringTag,{value:"Module"})),Gc={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},Vc=new Map(Object.entries(Gc).map(([e,t])=>[t,e]));function rs(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function Hn(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 tf(e,t=""){const n=rs(t),i=Gc[e];return n?`${n}${i}`:i}function Qc(e,t=""){const n=rs(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=Hn(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":Vc.get(s)??null}function nf(e){let t=Hn(e);if(t.endsWith("/index.html")&&(t=Hn(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let i=0;i<n.length;i++){const s=`/${n.slice(i).join("/")}`.toLowerCase();if(Vc.has(s)){const o=n.slice(0,i);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function sf(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function ca(e){return e==="system"?sf():e}const ui=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,of=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,pi=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},af=({nextTheme:e,applyTheme:t,context:n,currentTheme:i})=>{var c;if(i===e)return;const s=globalThis.document??null;if(!s){t();return}const o=s.documentElement,a=s,r=of();if(!!a.startViewTransition&&!r){let h=.5,d=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")h=ui(n.pointerClientX/window.innerWidth),d=ui(n.pointerClientY/window.innerHeight);else if(n!=null&&n.element){const p=n.element.getBoundingClientRect();p.width>0&&p.height>0&&typeof window<"u"&&(h=ui((p.left+p.width/2)/window.innerWidth),d=ui((p.top+p.height/2)/window.innerHeight))}o.style.setProperty("--theme-switch-x",`${h*100}%`),o.style.setProperty("--theme-switch-y",`${d*100}%`),o.classList.add("theme-transition");try{const p=(c=a.startViewTransition)==null?void 0:c.call(a,()=>{t()});p!=null&&p.finished?p.finished.finally(()=>pi(o)):pi(o)}catch{pi(o),t()}return}t(),pi(o)},rf=2e3;async function Pn(e,t){if(!(!e.client||!e.connected)&&!(e.sessionLogsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.sessionLogsLoading=!0),e.sessionLogsError=null;try{const n={cursors:t!=null&&t.reset?void 0:e.sessionLogsCursors,limit:500};Array.isArray(e.workspaceAgentIds)&&e.workspaceAgentIds.length>0&&(n.agents=e.workspaceAgentIds);const s=await e.client.request("sessions.transcript",n),o=Array.isArray(s.entries)?s.entries:[],a=!!(t!=null&&t.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=a?o:[...e.sessionLogsEntries,...o].slice(-rf),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!=null&&t.quiet||(e.sessionLogsLoading=!1)}}}const Jc=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:Pn},Symbol.toStringTag,{value:"Module"}));async function Yc(e,t){if(!(!e.client||!e.connected))try{const n={},i=await e.client.request("memory.audit",n);i!=null&&i.ok&&(e.auditEntries=i.entries??[])}catch{}}async function lf(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function We(e){return e instanceof Error?e.message:String(e)}let hi=null;function on(e,t){hi&&clearTimeout(hi),e.filesMessage={kind:"success",text:t},hi=setTimeout(()=>{e.filesMessage=null,hi=null},3e3)}async function an(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 i=await e.client.request("files.tree",n);i!=null&&i.tree&&(e.filesTree=i.tree,e.filesRoot=i.root??"")}catch(n){e.filesError=We(n)}finally{e.filesLoading=!1}}}}async function cf(e,t,n){e.filesSelectedPaths=new Set([t]),await Xc(e,t,n)}async function df(e,t,n){const i=new Set(e.filesSelectedPaths);if(i.has(t)?i.delete(t):i.add(t),e.filesSelectedPaths=i,i.size===1){const s=[...i][0];await Xc(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function uf(e,t){if(!e.client||!e.connected)return;const n=[...e.filesSelectedPaths];if(n.length===0)return;let i=0,s="";for(const o of n)try{await Zc(e,o,t),i++}catch(a){s=We(a)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:on(e,`${i} file${i!==1?"s":""} downloaded`)}async function pf(e,t,n,i){const s=t.split("/").pop()??t,o=n==="."?s:`${n}/${s}`;o!==t&&await mf(e,t,o,i)}async function Xc(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 i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.read",i);e.filesPreviewContent=(s==null?void 0:s.content)??null,e.filesPreviewBinary=(s==null?void 0:s.binary)??!1,e.filesPreviewSize=(s==null?void 0:s.size)??null}catch(i){e.filesError=We(i)}finally{e.filesPreviewLoading=!1}}}async function Zc(e,t,n){if(!(!e.client||!e.connected))try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.download",i);if(!(s!=null&&s.base64)){e.filesMessage={kind:"error",text:"Download failed: no data"};return}const o=Uint8Array.from(atob(s.base64),c=>c.charCodeAt(0)),a=new Blob([o]),r=URL.createObjectURL(a),l=document.createElement("a");l.href=r,l.download=s.name??t.split("/").pop()??"download",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(r)}catch(i){e.filesMessage={kind:"error",text:We(i)}}}async function hf(e,t,n,i){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let s=0,o="";for(const a of n)try{const r=await a.arrayBuffer(),l=btoa(new Uint8Array(r).reduce((h,d)=>h+String.fromCharCode(d),"")),c={path:t,name:a.name,data:l};i&&(c.agentId=i),await e.client.request("files.upload",c),s++}catch(r){o=We(r)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${o}`:o}:on(e,`${s} file${s!==1?"s":""} uploaded`),await an(e,i)}async function ff(e,t,n,i){if(!e.client||!e.connected)return;e.filesMessage=null;const s=t==="."?n:`${t}/${n}`;try{const o={path:s};i&&(o.agentId=i),await e.client.request("files.mkdir",o),on(e,`Created ${s}`),await an(e,i),e.filesExpandedDirs=new Set([...e.filesExpandedDirs,s]),e.filesCurrentDir=s}catch(o){e.filesMessage={kind:"error",text:We(o)}}}async function gf(e,t,n){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const i={path:t};n&&(i.agentId=n),await e.client.request("files.delete",i),on(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await an(e,n)}catch(i){e.filesMessage={kind:"error",text:We(i)}}}}async function mf(e,t,n,i){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const s={from:t,to:n};i&&(s.agentId=i),await e.client.request("files.move",s),on(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await an(e,i)}catch(s){e.filesMessage={kind:"error",text:We(s)}}}}async function ls(e,t){if(!(!e.client||!e.connected))try{const n={};t&&(n.agentId=t);const i=await e.client.request("memory.status",n);i!=null&&i.ok&&(e.filesMemoryStatus={dirty:i.dirty??!1,syncing:i.syncing,syncProgress:i.syncProgress,files:i.files??0,chunks:i.chunks??0,model:i.model,embeddingState:i.embeddingState})}catch{}}async function yf(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 i=await e.client.request("memory.reindex",n),s=(i==null?void 0:i.files)??0,o=(i==null?void 0:i.chunks)??0;on(e,`Re-indexed: ${s} files, ${o} chunks`),await ls(e,t)}catch(n){e.filesMessage={kind:"error",text:We(n)}}finally{e.filesReindexBusy=!1}}}function vf(e,t){const n=new Set(e.filesExpandedDirs);n.has(t)?n.delete(t):n.add(t),e.filesExpandedDirs=n,e.filesCurrentDir=t}async function bf(e,t,n){if(!(!e.client||!e.connected)){if(!t.trim()){e.filesSearchResults=null;return}e.filesSearchLoading=!0,e.filesSearchResults=null;try{const i={query:t.trim(),maxResults:20};n&&(i.agentId=n);const s=await e.client.request("memory.search",i);e.filesSearchResults=(s==null?void 0:s.results)??[]}catch(i){e.filesMessage={kind:"error",text:We(i)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function wf(e){e.filesSearchQuery="",e.filesSearchResults=null}function kf(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{ra(e,{quiet:!0})},5e3))}function $f(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function da(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Vt(e,{quiet:!0})},2e3))}function ua(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function pa(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{!(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")||e.logsSubTab!=="session"||Pn(e,{quiet:!0})},2e3))}function ha(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function fa(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&ea(e)},3e3))}function ga(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function xf(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{Yc(e)},3e4))}function Sf(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function Af(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{const t=e;t.filesPage&&ls(t,t.filesResolvedAgentId)},3e3))}function Cf(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function rt(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,wp(n),t.theme!==e.theme&&(e.theme=t.theme,cs(e,ca(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function ed(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&rt(e,{...e.settings,lastActiveSessionKey:n})}function Ef(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),i=t.get("password"),s=t.get("session"),o=t.get("gatewayUrl");let a=!1;if(n!=null){const l=n.trim();l&&l!==e.settings.token&&rt(e,{...e.settings,token:l}),t.delete("token"),a=!0}if(i!=null){const l=i.trim();l&&(e.password=l),t.delete("password"),a=!0}if(s!=null){const l=s.trim();l&&(e.sessionKey=l,rt(e,{...e.settings,sessionKey:l,lastActiveSessionKey:l}))}if(o!=null){const l=o.trim();l&&l!==e.settings.gatewayUrl&&rt(e,{...e.settings,gatewayUrl:l}),t.delete("gatewayUrl"),a=!0}if(!a)return;const r=new URL(window.location.href);r.search=t.toString(),window.history.replaceState({},"",r.toString())}function Tf(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?pa(e):da(e):(ua(e),ha(e)),t==="debug"?fa(e):ga(e),Ui(e),nd(e,t,!1)}function _f(e,t,n){af({nextTheme:t,applyTheme:()=>{e.theme=t,rt(e,{...e.settings,theme:t}),cs(e,ca(t))},context:n,currentTheme:e.theme})}async function Ui(e){if(e.tab==="overview"&&await id(e),e.tab==="channels"&&await Bf(e),e.tab==="instances"&&await _c(e),e.tab==="cron"&&await ma(e),e.tab==="skills"&&await Xe(e),e.tab==="nodes"&&(await ra(e),await aa(e),await Ue(e),await Xh(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await Wf(e),nn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await oc(e),await Ue(e)),e.tab==="debug"&&(await ea(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await le(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>Jc);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await Vt(e,{reset:!0});ic(e,!0)}}function Mf(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?rs(e):nf(window.location.pathname)}function Pf(e){e.theme=e.settings.theme??"system",cs(e,ca(e.theme))}function cs(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function If(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"&&cs(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Lf(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 Rf(e,t){if(typeof window>"u")return;const n=Qc(window.location.pathname,e.basePath)??"chat";td(e,n),nd(e,n,t)}function Df(e){var s;if(typeof window>"u")return;const t=Qc(window.location.pathname,e.basePath);if(!t)return;const i=(s=new URL(window.location.href).searchParams.get("session"))==null?void 0:s.trim();i&&(e.sessionKey=i,rt(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),td(e,t)}function td(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?pa(e):da(e):(ua(e),ha(e)),t==="debug"?fa(e):ga(e),e.connected&&Ui(e)}function nd(e,t,n){if(typeof window>"u")return;const i=Hn(tf(t,e.basePath)),s=Hn(window.location.pathname),o=new URL(window.location.href);t==="chat"&&e.sessionKey?o.searchParams.set("session",e.sessionKey):o.searchParams.delete("session"),s!==i&&(o.pathname=i),n?window.history.replaceState({},"",o.toString()):window.history.pushState({},"",o.toString())}async function id(e){await Promise.all([ee(e,!1),_c(e),Yo(e),sn(e),ea(e)])}async function Bf(e){await Promise.all([ee(e,!0),oc(e),Ue(e)])}async function ma(e){await Promise.all([ee(e,!1),sn(e),jn(e)])}function sd(e){return e.chatSending||!!e.chatRunId}function Nf(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 od(e){e.connected&&(e.chatMessage="",await tc(e))}function Of(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:os(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(o=>({...o})):void 0}],nn(e))}async function ad(e,t,n){var s,o;Xo(e);const i=await ec(e,t,n==null?void 0:n.attachments);return!i&&(n==null?void 0:n.previousDraft)!=null&&(e.chatMessage=n.previousDraft),!i&&(n!=null&&n.previousAttachments)&&(e.chatAttachments=n.previousAttachments),i&&ed(e,e.sessionKey),i&&(n!=null&&n.restoreDraft)&&((s=n.previousDraft)!=null&&s.trim())&&(e.chatMessage=n.previousDraft),i&&(n!=null&&n.restoreAttachments)&&((o=n.previousAttachments)!=null&&o.length)&&(e.chatAttachments=n.previousAttachments),nn(e),i&&!e.chatRunId&&rd(e),i}async function rd(e){if(!e.connected||sd(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await ad(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function Ff(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function Uf(e,t,n){if(!e.connected)return;const i=e.chatMessage,s=(t??e.chatMessage).trim(),o=e.chatAttachments??[],a=t==null?o:[],r=a.length>0;if(!(!s&&!r)){if(Nf(s)){await od(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[],$p(e.selectedWorkspace??"",e.sessionKey)),sd(e)){Of(e,s,a);return}await ad(e,s,{previousDraft:t==null?i:void 0,restoreDraft:!!(t&&(n!=null&&n.restoreDraft)),attachments:r?a:void 0,previousAttachments:t==null?o:void 0,restoreAttachments:!!(t&&(n!=null&&n.restoreDraft))})}}async function Wf(e){var i;const t=e,n=Math.max((((i=t.chatMessages)==null?void 0:i.length)??0)+10,Fe);await Promise.all([Oe(t,{limit:n}),Yo(t),Ao(e)]),nn(e,!0)}const Kf=rd;function zf(e){var s,o,a;const t=jl(e.sessionKey);if(t!=null&&t.agentId)return t.agentId;const n=(s=e.hello)==null?void 0:s.snapshot;return((a=(o=n==null?void 0:n.sessionDefaults)==null?void 0:o.defaultAgentId)==null?void 0:a.trim())||"main"}function qf(e,t){const n=rs(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function Ao(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=zf(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=qf(e.basePath,t);try{const i=await fetch(n,{method:"GET"});if(!i.ok){e.chatAvatarUrl=null;return}const s=await i.json(),o=typeof s.avatarUrl=="string"?s.avatarUrl.trim():"";e.chatAvatarUrl=o||null}catch{e.chatAvatarUrl=null}}const L={messageSquare:u`<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:u`<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:u`<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>`,unlink:u`<svg viewBox="0 0 24 24"><path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"/><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"/><line x1="8" x2="8" y1="2" y2="5"/><line x1="2" x2="5" y1="8" y2="8"/><line x1="16" x2="16" y1="19" y2="22"/><line x1="19" x2="22" y1="16" y2="16"/></svg>`,radio:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:u`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:u`<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:u`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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>`,globeOff:u`<svg viewBox="0 0 24 24"><path d="M21.54 15H17"/><path d="M7 3.34V5a3 3 0 0 0 3 3 2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17"/><path d="M11 21.95V18a2 2 0 0 0-2-2 2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05"/><circle cx="12" cy="12" r="10"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,image:u`<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:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,circleCheck:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>`,puzzle:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:u`<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:u`<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:u`<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>`,mic:u`<svg viewBox="0 0 24 24"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" x2="12" y1="19" y2="22"/></svg>`,chevronDown:u`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:u`<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>`,wifi:u`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M2 8.82a15 15 0 0 1 20 0"/><path d="M5 12.859a10 10 0 0 1 14 0"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/></svg>`,wifiOff:u`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/><path d="M5 12.859a10 10 0 0 1 5.17-2.69"/><path d="M13.41 10.28a10 10 0 0 1 5.59 2.58"/><path d="M2 8.82a15 15 0 0 1 4.17-2.65"/><path d="M10.66 5c4.01-.36 8.14.9 11.34 3.76"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,power:u`<svg viewBox="0 0 24 24"><path d="M18.36 6.64a9 9 0 1 1-12.73 0"/><line x1="12" x2="12" y1="2" y2="12"/></svg>`,powerOff:u`<svg viewBox="0 0 24 24"><path d="M18.36 6.64A9 9 0 0 1 20.77 15"/><path d="M6.16 6.16a9 9 0 1 0 12.68 12.68"/><path d="M12 2v4"/><path d="m2 2 20 20"/></svg>`},Hf=u`<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>`,jf=u`<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"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path><path d="M13.73 21a2 2 0 0 1-3.46 0"></path></svg>`,Gf=u`<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"><path d="M18.36 6.64a9 9 0 1 1-12.73 0"></path><line x1="12" y1="2" x2="12" y2="12"></line></svg>`;let _r=!1;function Vf(){_r||(_r=!0,document.addEventListener("click",e=>{const t=document.getElementById("nav-burger-toggle");if(!(t!=null&&t.checked))return;const n=t.closest(".setup-header");n!=null&&n.contains(e.target)||(t.checked=!1)}))}function Rt(e,t){var d;const n=(p,v)=>p===e?u`<span class="sp-page-nav-current">${p}</span>`:u`<a href=${v}>${p}</a>`,i=u`
|
|
20
|
+
`}function sc(e,t,n){if(t.length===0)return;let i=e;for(let o=0;o<t.length-1;o+=1){const a=t[o],r=t[o+1];if(typeof a=="number"){if(!Array.isArray(i))return;i[a]==null&&(i[a]=typeof r=="number"?[]:{}),i=i[a]}else{if(typeof i!="object"||i==null)return;const l=i;l[a]==null&&(l[a]=typeof r=="number"?[]:{}),i=l[a]}}const s=t[t.length-1];if(typeof s=="number"){Array.isArray(i)&&(i[s]=n);return}typeof i=="object"&&i!=null&&(i[s]=n)}async function Ue(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});ah(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function oc(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});oh(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function oh(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function ah(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?Et(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=Et(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=ct(t.config??{}),e.configFormOriginal=ct(t.config??{}),e.configRawOriginal=n)}async function rh(e){var t;if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const n=e.configFormMode==="form"&&e.configForm?Et(e.configForm):e.configRaw,i=(t=e.configSnapshot)==null?void 0:t.hash;if(!i){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:n,baseHash:i}),e.configFormDirty=!1,await Ue(e)}catch(n){e.lastError=String(n)}finally{e.configSaving=!1}}}async function sn(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 jn(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),e.accountId&&(t.accountId=e.accountId);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 ac(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=Bi(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const i=e.everyUnit;return{kind:"every",everyMs:n*(i==="minutes"?6e4:i==="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 rc(e){if(e.payloadKind==="systemEvent"){const o=e.payloadText.trim();if(!o)throw new Error("System event text required.");return{kind:"systemEvent",text:o}}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);const i=[];e.toAdmins&&i.push("admins");for(const o of e.recipients){const a=o.trim();a&&i.push(a)}i.length>0&&(n.to=i.join(","));const s=Bi(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function lh(e){var t;if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=ac(e.cronForm),i=rc(e.cronForm),s=e.cronForm.agentId.trim(),o=(t=e.cronForm.accountId)==null?void 0:t.trim(),a={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,accountId:o||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:i,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!a.name)throw new Error("Name required.");await e.client.request("cron.add",a),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await jn(e),await sn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function ch(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 jn(e),await sn(e)}catch(i){e.cronError=String(i)}finally{e.cronBusy=!1}}}async function dh(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null,e.cronRunModalJobId=t.id,e.cronRunModalJobName=t.name||"Untitled",e.cronRunResult=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await wo(e,t.id)}catch(n){e.cronError=String(n),e.cronRunResult={status:"error",error:String(n)}}finally{e.cronBusy=!1}}}function uh(e,t){e.cronRunModalJobId&&t.jobId===e.cronRunModalJobId&&t.action==="finished"&&(e.cronRunResult={status:t.status??"unknown",durationMs:t.durationMs,summary:t.summary,error:t.error})}async function ph(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 jn(e),await sn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}function hh(e){var n;const t={name:e.name||"",description:e.description||"",agentId:e.agentId||"",enabled:e.enabled,scheduleKind:e.schedule.kind,scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"",cronTz:"",sessionTarget:e.sessionTarget||"main",wakeMode:e.wakeMode||"next-heartbeat",payloadKind:e.payload.kind,payloadText:"",deliver:!1,channel:"last",recipients:[],toAdmins:!1,timeoutSeconds:"",postToMainPrefix:""};if(e.schedule.kind==="at"){const i=new Date(e.schedule.atMs),s=o=>String(o).padStart(2,"0");t.scheduleAt=`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}T${s(i.getHours())}:${s(i.getMinutes())}`}else if(e.schedule.kind==="every"){const i=e.schedule.everyMs;i%864e5===0?(t.everyAmount=String(i/864e5),t.everyUnit="days"):i%36e5===0?(t.everyAmount=String(i/36e5),t.everyUnit="hours"):(t.everyAmount=String(i/6e4),t.everyUnit="minutes")}else e.schedule.kind==="cron"&&(t.cronExpr=e.schedule.expr,t.cronTz=e.schedule.tz||"");if(e.payload.kind==="systemEvent")t.payloadText=e.payload.text;else if(e.payload.kind==="agentTurn"){t.payloadText=e.payload.message,t.deliver=e.payload.deliver??!1,t.timeoutSeconds=e.payload.timeoutSeconds?String(e.payload.timeoutSeconds):"";const i=e.payload.channel??e.payload.provider;t.channel=i||"last";const s=e.payload.to||"";if(s){const o=s.split(",").map(a=>a.trim()).filter(Boolean);t.toAdmins=o.some(a=>a.toLowerCase()==="admins"),t.recipients=o.filter(a=>a.toLowerCase()!=="admins")}}return(n=e.isolation)!=null&&n.postToMainPrefix&&(t.postToMainPrefix=e.isolation.postToMainPrefix),t}async function fh(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const n=ac(e.cronForm),i=rc(e.cronForm),s={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:e.cronForm.agentId.trim()||void 0,enabled:e.cronForm.enabled,schedule:n,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:i};if(e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?s.isolation={postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:s.isolation=void 0,!s.name)throw new Error("Name required.");await e.client.request("cron.update",{id:t,patch:s}),await jn(e),await sn(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function wo(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 ee(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 Zo(e,t,n){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0,e.whatsappActiveQrAccountId=n??null;try{const i=await e.client.request("web.login.start",{force:t,timeoutMs:3e4,accountId:n});e.whatsappLoginMessage=i.message??null,e.whatsappLoginQrDataUrl=i.qrDataUrl??null,e.whatsappLoginConnected=null}catch(i){e.whatsappLoginMessage=String(i),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function lc(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 cc(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 dc(e,t){if(!e.client||!e.connected||e.whatsappAccountSaving)return;const n=t.trim();if(!n){e.whatsappAccountError="Account name is required.";return}const i=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");if(!i){e.whatsappAccountError="Invalid account name.";return}e.whatsappAccountSaving=!0,e.whatsappAccountError=null;try{const s=await e.client.request("config.get",{});e.configSnapshot=s;const o=ct(s.config??{});(!o.channels||typeof o.channels!="object")&&(o.channels={});const a=o.channels;(!a.whatsapp||typeof a.whatsapp!="object")&&(a.whatsapp={});const r=a.whatsapp;(!r.accounts||typeof r.accounts!="object")&&(r.accounts={});const l=r.accounts;if(l[i]){e.whatsappAccountError=`Account "${i}" already exists.`;return}l[i]={name:n,provider:"baileys"};const c=s.hash;if(!c){e.whatsappAccountError="Config hash missing; reload and retry.";return}const h=Et(o);await e.client.request("config.set",{raw:h,baseHash:c}),e.addingWhatsAppAccount=!1,e.newWhatsAppAccountName="",await ee(e,!0),await Zo(e,!0,i)}catch(s){e.whatsappAccountError=String(s)}finally{e.whatsappAccountSaving=!1}}async function uc(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 i=ct(n.config??{}),s=i.channels,o=s==null?void 0:s.whatsapp,a=o==null?void 0:o.accounts;if(!a){e.whatsappAccountError="No accounts found in config.";return}if(Object.keys(a).length<=1){e.whatsappAccountError="Cannot remove the last account.";return}if(!a[t]){e.whatsappAccountError=`Account "${t}" not found.`;return}try{await e.client.request("channels.logout",{channel:"whatsapp",accountId:t})}catch{}delete a[t],Array.isArray(i.bindings)&&(i.bindings=i.bindings.filter(h=>{const d=h.match;return!d||d.channel!=="whatsapp"?!0:d.accountId!==t}));const l=n.hash;if(!l){e.whatsappAccountError="Config hash missing; reload and retry.";return}const c=Et(i);await e.client.request("config.set",{raw:c,baseHash:l}),e.whatsappActiveQrAccountId===t&&(e.whatsappActiveQrAccountId=null,e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null),await ee(e,!0)}catch(n){e.whatsappAccountError=String(n)}finally{e.whatsappAccountSaving=!1}}}const gh=Object.freeze(Object.defineProperty({__proto__:null,addWhatsAppAccount:dc,loadChannels:ee,logoutWhatsApp:cc,removeWhatsAppAccount:uc,startWhatsAppLogin:Zo,waitWhatsAppLogin:lc},Symbol.toStringTag,{value:"Module"}));async function ea(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,i,s]=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=i;e.debugModels=Array.isArray(o==null?void 0:o.models)?o==null?void 0:o.models:[],e.debugHeartbeat=s}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}const mh=2e3,yh=new Set(["trace","debug","info","warn","error","fatal"]);function vh(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 bh(e){if(typeof e!="string")return null;const t=e.toLowerCase();return yh.has(t)?t:null}function pc(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,i=typeof t.time=="string"?t.time:typeof(n==null?void 0:n.date)=="string"?n==null?void 0:n.date:null,s=bh((n==null?void 0:n.logLevelName)??(n==null?void 0:n.level)),o=typeof t[0]=="string"?t[0]:typeof(n==null?void 0:n.name)=="string"?n==null?void 0:n.name:null,a=vh(o);let r=null;a&&(typeof a.subsystem=="string"?r=a.subsystem:typeof a.module=="string"&&(r=a.module)),!r&&o&&o.length<120&&(r=o);let l=null;return typeof t[1]=="string"?l=t[1]:!a&&typeof t[0]=="string"?l=t[0]:typeof t.message=="string"&&(l=t.message),{raw:e,time:i,level:s,subsystem:r,message:l??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Vt(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.logsLoading=!0),e.logsError=null;try{const i=await e.client.request("logs.tail",{cursor:t!=null&&t.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),o=(Array.isArray(i.lines)?i.lines.filter(r=>typeof r=="string"):[]).map(pc),a=!!(t!=null&&t.reset||i.reset||e.logsCursor==null);e.logsEntries=a?o:[...e.logsEntries,...o].slice(-mh),typeof i.cursor=="number"&&(e.logsCursor=i.cursor),typeof i.file=="string"&&(e.logsFile=i.file),e.logsTruncated=!!i.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t!=null&&t.quiet||(e.logsLoading=!1)}}}const wh=Object.freeze(Object.defineProperty({__proto__:null,loadLogs:Vt,parseLogLine:pc},Symbol.toStringTag,{value:"Module"}));const hc={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:pe,n:Ai,Gx:$r,Gy:Sr,a:Ns,d:Os,h:kh}=hc,Tt=32,ta=64,xh=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},ae=(e="")=>{const t=new Error(e);throw xh(t,ae),t},$h=e=>typeof e=="bigint",Sh=e=>typeof e=="string",Ah=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",ut=(e,t,n="")=>{const i=Ah(e),s=e==null?void 0:e.length,o=t!==void 0;if(!i||o&&s!==t){const a=n&&`"${n}" `,r=o?` of length ${t}`:"",l=i?`length=${s}`:`type=${typeof e}`;ae(a+"expected Uint8Array"+r+", got "+l)}return e},as=e=>new Uint8Array(e),fc=e=>Uint8Array.from(e),gc=(e,t)=>e.toString(16).padStart(t,"0"),mc=e=>Array.from(ut(e)).map(t=>gc(t,2)).join(""),je={_0:48,_9:57,A:65,F:70,a:97,f:102},Ar=e=>{if(e>=je._0&&e<=je._9)return e-je._0;if(e>=je.A&&e<=je.F)return e-(je.A-10);if(e>=je.a&&e<=je.f)return e-(je.a-10)},yc=e=>{const t="hex invalid";if(!Sh(e))return ae(t);const n=e.length,i=n/2;if(n%2)return ae(t);const s=as(i);for(let o=0,a=0;o<i;o++,a+=2){const r=Ar(e.charCodeAt(a)),l=Ar(e.charCodeAt(a+1));if(r===void 0||l===void 0)return ae(t);s[o]=r*16+l}return s},vc=()=>globalThis==null?void 0:globalThis.crypto,Ch=()=>{var e;return((e=vc())==null?void 0:e.subtle)??ae("crypto.subtle must be defined, consider polyfill")},zn=(...e)=>{const t=as(e.reduce((i,s)=>i+ut(s).length,0));let n=0;return e.forEach(i=>{t.set(i,n),n+=i.length}),t},Eh=(e=Tt)=>vc().getRandomValues(as(e)),Oi=BigInt,yt=(e,t,n,i="bad number: out of range")=>$h(e)&&t<=e&&e<n?e:ae(i),D=(e,t=pe)=>{const n=e%t;return n>=0n?n:t+n},bc=e=>D(e,Ai),Th=(e,t)=>{(e===0n||t<=0n)&&ae("no inverse n="+e+" mod="+t);let n=D(e,t),i=t,s=0n,o=1n;for(;n!==0n;){const a=i/n,r=i%n,l=s-o*a;i=n,n=r,s=o,o=l}return i===1n?D(s,t):ae("no inverse")},_h=e=>{const t=$c[e];return typeof t!="function"&&ae("hashes."+e+" not set"),t},Fs=e=>e instanceof _t?e:ae("Point expected"),ko=2n**256n,Ne=class Ne{constructor(t,n,i,s){q(this,"X");q(this,"Y");q(this,"Z");q(this,"T");const o=ko;this.X=yt(t,0n,o),this.Y=yt(n,0n,o),this.Z=yt(i,1n,o),this.T=yt(s,0n,o),Object.freeze(this)}static CURVE(){return hc}static fromAffine(t){return new Ne(t.x,t.y,1n,D(t.x*t.y))}static fromBytes(t,n=!1){const i=Os,s=fc(ut(t,Tt)),o=t[31];s[31]=o&-129;const a=kc(s);yt(a,0n,n?ko:pe);const l=D(a*a),c=D(l-1n),h=D(i*l+1n);let{isValid:d,value:p}=Ph(c,h);d||ae("bad point: y not sqrt");const g=(p&1n)===1n,$=(o&128)!==0;return!n&&p===0n&&$&&ae("bad point: x==0, isLastByteOdd"),$!==g&&(p=D(-p)),new Ne(p,a,1n,D(p*a))}static fromHex(t,n){return Ne.fromBytes(yc(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=Ns,n=Os,i=this;if(i.is0())return ae("bad point: ZERO");const{X:s,Y:o,Z:a,T:r}=i,l=D(s*s),c=D(o*o),h=D(a*a),d=D(h*h),p=D(l*t),g=D(h*D(p+c)),$=D(d+D(n*D(l*c)));if(g!==$)return ae("bad point: equation left != right (1)");const S=D(s*o),T=D(a*r);return S!==T?ae("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:i,Z:s}=this,{X:o,Y:a,Z:r}=Fs(t),l=D(n*r),c=D(o*s),h=D(i*r),d=D(a*s);return l===c&&h===d}is0(){return this.equals(jt)}negate(){return new Ne(D(-this.X),this.Y,this.Z,D(-this.T))}double(){const{X:t,Y:n,Z:i}=this,s=Ns,o=D(t*t),a=D(n*n),r=D(2n*D(i*i)),l=D(s*o),c=t+n,h=D(D(c*c)-o-a),d=l+a,p=d-r,g=l-a,$=D(h*p),S=D(d*g),T=D(h*g),f=D(p*d);return new Ne($,S,f,T)}add(t){const{X:n,Y:i,Z:s,T:o}=this,{X:a,Y:r,Z:l,T:c}=Fs(t),h=Ns,d=Os,p=D(n*a),g=D(i*r),$=D(o*d*c),S=D(s*l),T=D((n+i)*(a+r)-p-g),f=D(S-$),b=D(S+$),k=D(g-h*p),A=D(T*f),E=D(b*k),M=D(T*k),P=D(f*b);return new Ne(A,E,P,M)}subtract(t){return this.add(Fs(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return jt;if(yt(t,1n,Ai),t===1n)return this;if(this.equals(Mt))return Kh(t).p;let i=jt,s=Mt;for(let o=this;t>0n;o=o.double(),t>>=1n)t&1n?i=i.add(o):n&&(s=s.add(o));return i}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:i}=this;if(this.equals(jt))return{x:0n,y:1n};const s=Th(i,pe);D(i*s)!==1n&&ae("invalid inverse");const o=D(t*s),a=D(n*s);return{x:o,y:a}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),i=wc(n);return i[31]|=t&1n?128:0,i}toHex(){return mc(this.toBytes())}clearCofactor(){return this.multiply(Oi(kh),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Ai/2n,!1).double();return Ai%2n&&(t=t.add(this)),t.is0()}};q(Ne,"BASE"),q(Ne,"ZERO");let _t=Ne;const Mt=new _t($r,Sr,1n,D($r*Sr)),jt=new _t(0n,1n,1n,0n);_t.BASE=Mt;_t.ZERO=jt;const wc=e=>yc(gc(yt(e,0n,ko),ta)).reverse(),kc=e=>Oi("0x"+mc(fc(ut(e)).reverse())),Ie=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=pe;return n},Mh=e=>{const n=e*e%pe*e%pe,i=Ie(n,2n)*n%pe,s=Ie(i,1n)*e%pe,o=Ie(s,5n)*s%pe,a=Ie(o,10n)*o%pe,r=Ie(a,20n)*a%pe,l=Ie(r,40n)*r%pe,c=Ie(l,80n)*l%pe,h=Ie(c,80n)*l%pe,d=Ie(h,10n)*o%pe;return{pow_p_5_8:Ie(d,2n)*e%pe,b2:n}},Cr=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Ph=(e,t)=>{const n=D(t*t*t),i=D(n*n*t),s=Mh(e*i).pow_p_5_8;let o=D(e*n*s);const a=D(t*o*o),r=o,l=D(o*Cr),c=a===e,h=a===D(-e),d=a===D(-e*Cr);return c&&(o=r),(h||d)&&(o=l),(D(o)&1n)===1n&&(o=D(-o)),{isValid:c||h,value:o}},xo=e=>bc(kc(e)),na=(...e)=>$c.sha512Async(zn(...e)),Ih=(...e)=>_h("sha512")(zn(...e)),xc=e=>{const t=e.slice(0,Tt);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(Tt,ta),i=xo(t),s=Mt.multiply(i),o=s.toBytes();return{head:t,prefix:n,scalar:i,point:s,pointBytes:o}},ia=e=>na(ut(e,Tt)).then(xc),Lh=e=>xc(Ih(ut(e,Tt))),Rh=e=>ia(e).then(t=>t.pointBytes),Dh=e=>na(e.hashable).then(e.finish),Bh=(e,t,n)=>{const{pointBytes:i,scalar:s}=e,o=xo(t),a=Mt.multiply(o).toBytes();return{hashable:zn(a,i,n),finish:c=>{const h=bc(o+xo(c)*s);return ut(zn(a,wc(h)),ta)}}},Nh=async(e,t)=>{const n=ut(e),i=await ia(t),s=await na(i.prefix,n);return Dh(Bh(i,s,n))},$c={sha512Async:async e=>{const t=Ch(),n=zn(e);return as(await t.digest("SHA-512",n.buffer))},sha512:void 0},Oh=(e=Eh(Tt))=>e,Fh={getExtendedPublicKeyAsync:ia,getExtendedPublicKey:Lh,randomSecretKey:Oh},Fi=8,Uh=256,Sc=Math.ceil(Uh/Fi)+1,$o=2**(Fi-1),Wh=()=>{const e=[];let t=Mt,n=t;for(let i=0;i<Sc;i++){n=t,e.push(n);for(let s=1;s<$o;s++)n=n.add(t),e.push(n);t=n.double()}return e};let Er;const Tr=(e,t)=>{const n=t.negate();return e?n:t},Kh=e=>{const t=Er||(Er=Wh());let n=jt,i=Mt;const s=2**Fi,o=s,a=Oi(s-1),r=Oi(Fi);for(let l=0;l<Sc;l++){let c=Number(e&a);e>>=r,c>$o&&(c-=o,e+=1n);const h=l*$o,d=h,p=h+Math.abs(c)-1,g=l%2!==0,$=c<0;c===0?i=i.add(Tr(g,t[d])):n=n.add(Tr($,t[p]))}return e!==0n&&ae("invalid wnaf"),{p:n,f:i}},Us="taskmaster-device-identity-v1";function So(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Ac(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),i=atob(n),s=new Uint8Array(i.length);for(let o=0;o<i.length;o+=1)s[o]=i.charCodeAt(o);return s}function zh(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Cc(e){const t=await crypto.subtle.digest("SHA-256",e);return zh(new Uint8Array(t))}async function qh(){const e=Fh.randomSecretKey(),t=await Rh(e);return{deviceId:await Cc(t),publicKey:So(t),privateKey:So(e)}}async function Hh(){try{const n=localStorage.getItem(Us);if(n){const i=JSON.parse(n);if((i==null?void 0:i.version)===1&&typeof i.deviceId=="string"&&typeof i.publicKey=="string"&&typeof i.privateKey=="string"){const s=await Cc(Ac(i.publicKey));if(s!==i.deviceId){const o={...i,deviceId:s};return localStorage.setItem(Us,JSON.stringify(o)),{deviceId:s,publicKey:i.publicKey,privateKey:i.privateKey}}return{deviceId:i.deviceId,publicKey:i.publicKey,privateKey:i.privateKey}}}}catch{}const e=await qh(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Us,JSON.stringify(t)),e}async function jh(e,t){const n=Ac(e),i=new TextEncoder().encode(t),s=await Nh(i,n);return So(s)}const Ec="taskmaster.device.auth.v1";function sa(e){return e.trim()}function Gh(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const i=n.trim();i&&t.add(i)}return[...t].sort()}function oa(){try{const e=window.localStorage.getItem(Ec);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 Tc(e){try{window.localStorage.setItem(Ec,JSON.stringify(e))}catch{}}function Vh(e){const t=oa();if(!t||t.deviceId!==e.deviceId)return null;const n=sa(e.role),i=t.tokens[n];return!i||typeof i.token!="string"?null:i}function Qh(e){const t=sa(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},i=oa();i&&i.deviceId===e.deviceId&&(n.tokens={...i.tokens});const s={token:e.token,role:t,scopes:Gh(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=s,Tc(n),s}function Jh(e){const t=oa();if(!t||t.deviceId!==e.deviceId)return;const n=sa(e.role);if(!t.tokens[n])return;const i={...t,tokens:{...t.tokens}};delete i.tokens[n],Tc(i)}async function aa(e,t){if(!(!e.client||!e.connected)&&!e.devicesLoading){e.devicesLoading=!0,t!=null&&t.quiet||(e.devicesError=null);try{const n=await e.client.request("device.pair.list",{});e.devicesList={pending:Array.isArray(n==null?void 0:n.pending)?n.pending:[],paired:Array.isArray(n==null?void 0:n.paired)?n.paired:[]}}catch(n){t!=null&&t.quiet||(e.devicesError=String(n))}finally{e.devicesLoading=!1}}}async function ra(e,t){if(!(!e.client||!e.connected)&&!e.nodesLoading){e.nodesLoading=!0,t!=null&&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!=null&&t.quiet||(e.lastError=String(n))}finally{e.nodesLoading=!1}}}function Yh(e){return{method:"exec.approvals.get",params:{}}}async function Xh(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=Yh(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const i=await e.client.request(n.method,n.params);Zh(e,i)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function Zh(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=ct(t.file??{}))}async function _c(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 dt(e,t,n){if(!t.trim())return;const i={...e.skillMessages};n?i[t]=n:delete i[t],e.skillMessages=i}function Ze(e){return e instanceof Error?e.message:String(e)}function qn(){return{name:"",skillContent:"",references:[]}}async function Xe(e,t){if(t!=null&&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=Ze(n)}finally{e.skillsLoading=!1}}}function Mc(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Pc(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 Xe(e),dt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(i){const s=Ze(i);e.skillsError=s,dt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function Ic(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 Xe(e),dt(e,t,{kind:"success",message:"API key saved"})}catch(n){const i=Ze(n);e.skillsError=i,dt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Lc(e,t,n,i){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const s=await e.client.request("skills.install",{name:n,installId:i,timeoutMs:12e4});await Xe(e),dt(e,t,{kind:"success",message:(s==null?void 0:s.message)??"Installed"})}catch(s){const o=Ze(s);e.skillsError=o,dt(e,t,{kind:"error",message:o})}finally{e.skillsBusyKey=null}}}async function Rc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("skills.read",{name:t});n&&(e.skillDetail=n,e.skillDetailTab="SKILL.md")}catch(n){e.skillsError=Ze(n)}}function Dc(e){e.skillDetail=null,e.skillDetailTab=""}function Bc(e,t){e.skillDetailTab=t}async function Nc(e){if(e.skillAddModal=!0,e.skillAddForm=qn(),e.skillAddFormSource="draft",e.skillEditTab="SKILL.md",e.skillDrafts=[],!(!e.client||!e.connected))try{const t=await e.client.request("skills.drafts",{});t&&(e.skillDrafts=t.drafts)}catch{}}function Oc(e){e.skillAddModal=!1,e.skillAddForm=qn(),e.skillAddFormSource="draft",e.skillEditTab="SKILL.md",e.skillDrafts=[]}function Fc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n}))},e.skillAddFormSource="draft"}async function Uc(e,t){e.skillAddForm={name:t.name,skillContent:t.skillContent,references:t.references.map(n=>({...n}))},e.skillAddFormSource="installed",await la(e)}async function la(e){if(!e.client||!e.connected)return;const t=e.skillAddForm;if(!(!t.name.trim()||!t.skillContent.trim())){e.skillsBusyKey="__add__",e.skillsError=null;try{const n=t.references.filter(s=>s.name.trim()&&s.content.trim()).map(s=>({name:s.name.trim(),content:s.content})),i=t.name.trim();e.skillAddFormSource==="installed"?(await e.client.request("skills.create",{name:i,skillContent:t.skillContent,references:n.length>0?n:void 0}),e.skillAddModal=!1,e.skillAddForm=qn(),e.skillAddFormSource="draft",e.skillDrafts=[],await Xe(e),dt(e,i,{kind:"success",message:"Skill saved — active on next message"})):(await e.client.request("skills.saveDraft",{name:i,skillContent:t.skillContent,references:n.length>0?n:void 0}),e.skillAddModal=!1,e.skillAddForm=qn(),e.skillAddFormSource="draft",e.skillDrafts=[],dt(e,i,{kind:"success",message:"Draft saved"}))}catch(n){e.skillsError=Ze(n)}finally{e.skillsBusyKey=null}}}async function Wc(e,t){if(!(!e.client||!e.connected))try{await e.client.request("skills.deleteDraft",{name:t}),e.skillDrafts=e.skillDrafts.filter(n=>n.name!==t)}catch(n){e.skillsError=Ze(n)}}async function Kc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("skills.read",{name:t});if(!n)return;e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i}))},e.skillAddFormSource="installed",e.skillAddModal=!0,e.skillDrafts=[]}catch(n){e.skillsError=Ze(n)}}function zc(e,t){const n=e.skillDetail;n&&(e.skillAddForm={name:n.name,skillContent:n.content,references:n.references.map(i=>({...i}))},e.skillAddFormSource="installed",e.skillEditTab=t&&t!=="SKILL.md"?t:"SKILL.md",e.skillDetail=null,e.skillDetailTab="",e.skillAddModal=!0,e.skillDrafts=[])}function qc(e,t,n){e.skillAddForm={...e.skillAddForm,references:e.skillAddForm.references.map(i=>i.name===t?{...i,content:n}:i)}}function Hc(e,t){e.skillEditTab=t}async function jc(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.delete",{name:t}),await Xe(e)}catch(n){e.skillsError=Ze(n)}finally{e.skillsBusyKey=null}}}const ef=Object.freeze(Object.defineProperty({__proto__:null,closeAddSkillModal:Oc,closeSkillDetail:Dc,deleteDraft:Wc,deleteSkill:jc,editDetailSkill:zc,editSkill:Kc,emptyAddForm:qn,importDraft:Fc,installDraft:Uc,installSkill:Lc,loadSkills:Xe,openAddSkillModal:Nc,saveNewSkill:la,saveSkillApiKey:Ic,setEditTab:Hc,setSkillDetailTab:Bc,updateFormReference:qc,updateSkillEdit:Mc,updateSkillEnabled:Pc,viewSkillDetail:Rc},Symbol.toStringTag,{value:"Module"})),Gc={overview:"/overview",channels:"/channels",instances:"/instances",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",admins:"/admins",config:"/config",debug:"/debug",logs:"/logs"},Vc=new Map(Object.entries(Gc).map(([e,t])=>[t,e]));function rs(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function Hn(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 tf(e,t=""){const n=rs(t),i=Gc[e];return n?`${n}${i}`:i}function Qc(e,t=""){const n=rs(t);let i=e||"/";n&&(i===n?i="/":i.startsWith(`${n}/`)&&(i=i.slice(n.length)));let s=Hn(i).toLowerCase();return s.endsWith("/index.html")&&(s="/"),s==="/"?"chat":Vc.get(s)??null}function nf(e){let t=Hn(e);if(t.endsWith("/index.html")&&(t=Hn(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let i=0;i<n.length;i++){const s=`/${n.slice(i).join("/")}`.toLowerCase();if(Vc.has(s)){const o=n.slice(0,i);return o.length?`/${o.join("/")}`:""}}return`/${n.join("/")}`}function sf(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function ca(e){return e==="system"?sf():e}const ui=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,of=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,pi=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},af=({nextTheme:e,applyTheme:t,context:n,currentTheme:i})=>{var c;if(i===e)return;const s=globalThis.document??null;if(!s){t();return}const o=s.documentElement,a=s,r=of();if(!!a.startViewTransition&&!r){let h=.5,d=.5;if((n==null?void 0:n.pointerClientX)!==void 0&&(n==null?void 0:n.pointerClientY)!==void 0&&typeof window<"u")h=ui(n.pointerClientX/window.innerWidth),d=ui(n.pointerClientY/window.innerHeight);else if(n!=null&&n.element){const p=n.element.getBoundingClientRect();p.width>0&&p.height>0&&typeof window<"u"&&(h=ui((p.left+p.width/2)/window.innerWidth),d=ui((p.top+p.height/2)/window.innerHeight))}o.style.setProperty("--theme-switch-x",`${h*100}%`),o.style.setProperty("--theme-switch-y",`${d*100}%`),o.classList.add("theme-transition");try{const p=(c=a.startViewTransition)==null?void 0:c.call(a,()=>{t()});p!=null&&p.finished?p.finished.finally(()=>pi(o)):pi(o)}catch{pi(o),t()}return}t(),pi(o)},rf=2e3;async function Pn(e,t){if(!(!e.client||!e.connected)&&!(e.sessionLogsLoading&&!(t!=null&&t.quiet))){t!=null&&t.quiet||(e.sessionLogsLoading=!0),e.sessionLogsError=null;try{const n={cursors:t!=null&&t.reset?void 0:e.sessionLogsCursors,limit:500};Array.isArray(e.workspaceAgentIds)&&e.workspaceAgentIds.length>0&&(n.agents=e.workspaceAgentIds);const s=await e.client.request("sessions.transcript",n),o=Array.isArray(s.entries)?s.entries:[],a=!!(t!=null&&t.reset||Object.keys(e.sessionLogsCursors).length===0);e.sessionLogsEntries=a?o:[...e.sessionLogsEntries,...o].slice(-rf),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!=null&&t.quiet||(e.sessionLogsLoading=!1)}}}const Jc=Object.freeze(Object.defineProperty({__proto__:null,loadSessionLogs:Pn},Symbol.toStringTag,{value:"Module"}));async function Yc(e,t){if(!(!e.client||!e.connected))try{const n={},i=await e.client.request("memory.audit",n);i!=null&&i.ok&&(e.auditEntries=i.entries??[])}catch{}}async function lf(e,t){if(!(!e.client||!e.connected))try{const n={};await e.client.request("memory.auditClear",n),e.auditEntries=[]}catch{}}function We(e){return e instanceof Error?e.message:String(e)}let hi=null;function on(e,t){hi&&clearTimeout(hi),e.filesMessage={kind:"success",text:t},hi=setTimeout(()=>{e.filesMessage=null,hi=null},3e3)}async function an(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 i=await e.client.request("files.tree",n);i!=null&&i.tree&&(e.filesTree=i.tree,e.filesRoot=i.root??"")}catch(n){e.filesError=We(n)}finally{e.filesLoading=!1}}}}async function cf(e,t,n){e.filesSelectedPaths=new Set([t]),await Xc(e,t,n)}async function df(e,t,n){const i=new Set(e.filesSelectedPaths);if(i.has(t)?i.delete(t):i.add(t),e.filesSelectedPaths=i,i.size===1){const s=[...i][0];await Xc(e,s,n)}else e.filesSelectedPath=null,e.filesPreviewContent=null,e.filesPreviewSize=null,e.filesPreviewBinary=!1}async function uf(e,t){if(!e.client||!e.connected)return;const n=[...e.filesSelectedPaths];if(n.length===0)return;let i=0,s="";for(const o of n)try{await Zc(e,o,t),i++}catch(a){s=We(a)}s?e.filesMessage={kind:"error",text:`${i} downloaded, error: ${s}`}:on(e,`${i} file${i!==1?"s":""} downloaded`)}async function pf(e,t,n,i){const s=t.split("/").pop()??t,o=n==="."?s:`${n}/${s}`;o!==t&&await mf(e,t,o,i)}async function Xc(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 i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.read",i);e.filesPreviewContent=(s==null?void 0:s.content)??null,e.filesPreviewBinary=(s==null?void 0:s.binary)??!1,e.filesPreviewSize=(s==null?void 0:s.size)??null}catch(i){e.filesError=We(i)}finally{e.filesPreviewLoading=!1}}}async function Zc(e,t,n){if(!(!e.client||!e.connected))try{const i={path:t};n&&(i.agentId=n);const s=await e.client.request("files.download",i);if(!(s!=null&&s.base64)){e.filesMessage={kind:"error",text:"Download failed: no data"};return}const o=Uint8Array.from(atob(s.base64),c=>c.charCodeAt(0)),a=new Blob([o]),r=URL.createObjectURL(a),l=document.createElement("a");l.href=r,l.download=s.name??t.split("/").pop()??"download",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(r)}catch(i){e.filesMessage={kind:"error",text:We(i)}}}async function hf(e,t,n,i){if(!e.client||!e.connected)return;e.filesUploadBusy=!0,e.filesMessage=null;let s=0,o="";for(const a of n)try{const r=await a.arrayBuffer(),l=btoa(new Uint8Array(r).reduce((h,d)=>h+String.fromCharCode(d),"")),c={path:t,name:a.name,data:l};i&&(c.agentId=i),await e.client.request("files.upload",c),s++}catch(r){o=We(r)}e.filesUploadBusy=!1,o?e.filesMessage={kind:"error",text:s>0?`${s} uploaded, error: ${o}`:o}:on(e,`${s} file${s!==1?"s":""} uploaded`),await an(e,i)}async function ff(e,t,n,i){if(!e.client||!e.connected)return;e.filesMessage=null;const s=t==="."?n:`${t}/${n}`;try{const o={path:s};i&&(o.agentId=i),await e.client.request("files.mkdir",o),on(e,`Created ${s}`),await an(e,i),e.filesExpandedDirs=new Set([...e.filesExpandedDirs,s]),e.filesCurrentDir=s}catch(o){e.filesMessage={kind:"error",text:We(o)}}}async function gf(e,t,n){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const i={path:t};n&&(i.agentId=n),await e.client.request("files.delete",i),on(e,"File deleted"),e.filesSelectedPath===t&&(e.filesSelectedPath=null,e.filesPreviewContent=null),await an(e,n)}catch(i){e.filesMessage={kind:"error",text:We(i)}}}}async function mf(e,t,n,i){if(!(!e.client||!e.connected)){e.filesMessage=null;try{const s={from:t,to:n};i&&(s.agentId=i),await e.client.request("files.move",s),on(e,"File moved"),e.filesSelectedPath===t&&(e.filesSelectedPath=n),await an(e,i)}catch(s){e.filesMessage={kind:"error",text:We(s)}}}}async function ls(e,t){if(!(!e.client||!e.connected))try{const n={};t&&(n.agentId=t);const i=await e.client.request("memory.status",n);i!=null&&i.ok&&(e.filesMemoryStatus={dirty:i.dirty??!1,syncing:i.syncing,syncProgress:i.syncProgress,files:i.files??0,chunks:i.chunks??0,model:i.model,embeddingState:i.embeddingState})}catch{}}async function yf(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 i=await e.client.request("memory.reindex",n),s=(i==null?void 0:i.files)??0,o=(i==null?void 0:i.chunks)??0;on(e,`Re-indexed: ${s} files, ${o} chunks`),await ls(e,t)}catch(n){e.filesMessage={kind:"error",text:We(n)}}finally{e.filesReindexBusy=!1}}}function vf(e,t){const n=new Set(e.filesExpandedDirs);n.has(t)?n.delete(t):n.add(t),e.filesExpandedDirs=n,e.filesCurrentDir=t}async function bf(e,t,n){if(!(!e.client||!e.connected)){if(!t.trim()){e.filesSearchResults=null;return}e.filesSearchLoading=!0,e.filesSearchResults=null;try{const i={query:t.trim(),maxResults:20};n&&(i.agentId=n);const s=await e.client.request("memory.search",i);e.filesSearchResults=(s==null?void 0:s.results)??[]}catch(i){e.filesMessage={kind:"error",text:We(i)},e.filesSearchResults=null}finally{e.filesSearchLoading=!1}}}function wf(e){e.filesSearchQuery="",e.filesSearchResults=null}function kf(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{ra(e,{quiet:!0})},5e3))}function xf(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function da(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Vt(e,{quiet:!0})},2e3))}function ua(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function pa(e){e.sessionLogsPollInterval==null&&(e.sessionLogsPollInterval=window.setInterval(()=>{!(e.advancedPage?e.advancedTab==="logs":e.tab==="logs")||e.logsSubTab!=="session"||Pn(e,{quiet:!0})},2e3))}function ha(e){e.sessionLogsPollInterval!=null&&(clearInterval(e.sessionLogsPollInterval),e.sessionLogsPollInterval=null)}function fa(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&ea(e)},3e3))}function ga(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function $f(e){e.auditPollInterval==null&&(e.auditPollInterval=window.setInterval(()=>{Yc(e)},3e4))}function Sf(e){e.auditPollInterval!=null&&(clearInterval(e.auditPollInterval),e.auditPollInterval=null)}function Af(e){e.memoryStatusPollInterval==null&&(e.memoryStatusPollInterval=window.setInterval(()=>{const t=e;t.filesPage&&ls(t,t.filesResolvedAgentId)},3e3))}function Cf(e){e.memoryStatusPollInterval!=null&&(clearInterval(e.memoryStatusPollInterval),e.memoryStatusPollInterval=null)}function rt(e,t){var i;const n={...t,lastActiveSessionKey:((i=t.lastActiveSessionKey)==null?void 0:i.trim())||t.sessionKey.trim()||"main"};e.settings=n,wp(n),t.theme!==e.theme&&(e.theme=t.theme,cs(e,ca(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function ed(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&rt(e,{...e.settings,lastActiveSessionKey:n})}function Ef(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),i=t.get("password"),s=t.get("session"),o=t.get("gatewayUrl");let a=!1;if(n!=null){const l=n.trim();l&&l!==e.settings.token&&rt(e,{...e.settings,token:l}),t.delete("token"),a=!0}if(i!=null){const l=i.trim();l&&(e.password=l),t.delete("password"),a=!0}if(s!=null){const l=s.trim();l&&(e.sessionKey=l,rt(e,{...e.settings,sessionKey:l,lastActiveSessionKey:l}))}if(o!=null){const l=o.trim();l&&l!==e.settings.gatewayUrl&&rt(e,{...e.settings,gatewayUrl:l}),t.delete("gatewayUrl"),a=!0}if(!a)return;const r=new URL(window.location.href);r.search=t.toString(),window.history.replaceState({},"",r.toString())}function Tf(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?pa(e):da(e):(ua(e),ha(e)),t==="debug"?fa(e):ga(e),Ui(e),nd(e,t,!1)}function _f(e,t,n){af({nextTheme:t,applyTheme:()=>{e.theme=t,rt(e,{...e.settings,theme:t}),cs(e,ca(t))},context:n,currentTheme:e.theme})}async function Ui(e){if(e.tab==="overview"&&await id(e),e.tab==="channels"&&await Bf(e),e.tab==="instances"&&await _c(e),e.tab==="cron"&&await ma(e),e.tab==="skills"&&await Xe(e),e.tab==="nodes"&&(await ra(e),await aa(e),await Ue(e),await Xh(e)),e.tab==="chat"&&!e.advancedPage&&!e.chatPage&&(await Wf(e),nn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await oc(e),await Ue(e)),e.tab==="debug"&&(await ea(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"){if(e.logsAtBottom=!0,e.logsSubTab==="session"){const{loadSessionLogs:n}=await le(async()=>{const{loadSessionLogs:i}=await Promise.resolve().then(()=>Jc);return{loadSessionLogs:i}},void 0,import.meta.url);await n(e,{reset:!0})}else await Vt(e,{reset:!0});ic(e,!0)}}function Mf(){if(typeof window>"u")return"";const e=window.__TASKMASTER_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?rs(e):nf(window.location.pathname)}function Pf(e){e.theme=e.settings.theme??"system",cs(e,ca(e.theme))}function cs(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function If(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"&&cs(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function Lf(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 Rf(e,t){if(typeof window>"u")return;const n=Qc(window.location.pathname,e.basePath)??"chat";td(e,n),nd(e,n,t)}function Df(e){var s;if(typeof window>"u")return;const t=Qc(window.location.pathname,e.basePath);if(!t)return;const i=(s=new URL(window.location.href).searchParams.get("session"))==null?void 0:s.trim();i&&(e.sessionKey=i,rt(e,{...e.settings,sessionKey:i,lastActiveSessionKey:i})),td(e,t)}function td(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?e.logsSubTab==="session"?pa(e):da(e):(ua(e),ha(e)),t==="debug"?fa(e):ga(e),e.connected&&Ui(e)}function nd(e,t,n){if(typeof window>"u")return;const i=Hn(tf(t,e.basePath)),s=Hn(window.location.pathname),o=new URL(window.location.href);t==="chat"&&e.sessionKey?o.searchParams.set("session",e.sessionKey):o.searchParams.delete("session"),s!==i&&(o.pathname=i),n?window.history.replaceState({},"",o.toString()):window.history.pushState({},"",o.toString())}async function id(e){await Promise.all([ee(e,!1),_c(e),Yo(e),sn(e),ea(e)])}async function Bf(e){await Promise.all([ee(e,!0),oc(e),Ue(e)])}async function ma(e){await Promise.all([ee(e,!1),sn(e),jn(e)])}function sd(e){return e.chatSending||!!e.chatRunId}function Nf(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 od(e){e.connected&&(e.chatMessage="",await tc(e))}function Of(e,t,n){const i=t.trim(),s=!!(n&&n.length>0);!i&&!s||(e.chatQueue=[...e.chatQueue,{id:os(),text:i,createdAt:Date.now(),attachments:s?n==null?void 0:n.map(o=>({...o})):void 0}],nn(e))}async function ad(e,t,n){var s,o;Xo(e);const i=await ec(e,t,n==null?void 0:n.attachments);return!i&&(n==null?void 0:n.previousDraft)!=null&&(e.chatMessage=n.previousDraft),!i&&(n!=null&&n.previousAttachments)&&(e.chatAttachments=n.previousAttachments),i&&ed(e,e.sessionKey),i&&(n!=null&&n.restoreDraft)&&((s=n.previousDraft)!=null&&s.trim())&&(e.chatMessage=n.previousDraft),i&&(n!=null&&n.restoreAttachments)&&((o=n.previousAttachments)!=null&&o.length)&&(e.chatAttachments=n.previousAttachments),nn(e),i&&!e.chatRunId&&rd(e),i}async function rd(e){if(!e.connected||sd(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await ad(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function Ff(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function Uf(e,t,n){if(!e.connected)return;const i=e.chatMessage,s=(t??e.chatMessage).trim(),o=e.chatAttachments??[],a=t==null?o:[],r=a.length>0;if(!(!s&&!r)){if(Nf(s)){await od(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[],xp(e.selectedWorkspace??"",e.sessionKey)),sd(e)){Of(e,s,a);return}await ad(e,s,{previousDraft:t==null?i:void 0,restoreDraft:!!(t&&(n!=null&&n.restoreDraft)),attachments:r?a:void 0,previousAttachments:t==null?o:void 0,restoreAttachments:!!(t&&(n!=null&&n.restoreDraft))})}}async function Wf(e){var i;const t=e,n=Math.max((((i=t.chatMessages)==null?void 0:i.length)??0)+10,Fe);await Promise.all([Oe(t,{limit:n}),Yo(t),Ao(e)]),nn(e,!0)}const Kf=rd;function zf(e){var s,o,a;const t=jl(e.sessionKey);if(t!=null&&t.agentId)return t.agentId;const n=(s=e.hello)==null?void 0:s.snapshot;return((a=(o=n==null?void 0:n.sessionDefaults)==null?void 0:o.defaultAgentId)==null?void 0:a.trim())||"main"}function qf(e,t){const n=rs(e),i=encodeURIComponent(t);return n?`${n}/avatar/${i}?meta=1`:`/avatar/${i}?meta=1`}async function Ao(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=zf(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=qf(e.basePath,t);try{const i=await fetch(n,{method:"GET"});if(!i.ok){e.chatAvatarUrl=null;return}const s=await i.json(),o=typeof s.avatarUrl=="string"?s.avatarUrl.trim():"";e.chatAvatarUrl=o||null}catch{e.chatAvatarUrl=null}}const L={messageSquare:u`<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:u`<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:u`<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>`,unlink:u`<svg viewBox="0 0 24 24"><path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"/><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"/><line x1="8" x2="8" y1="2" y2="5"/><line x1="2" x2="5" y1="8" y2="8"/><line x1="16" x2="16" y1="19" y2="22"/><line x1="19" x2="22" y1="16" y2="16"/></svg>`,radio:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:u`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:u`<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:u`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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:u`<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>`,globeOff:u`<svg viewBox="0 0 24 24"><path d="M21.54 15H17"/><path d="M7 3.34V5a3 3 0 0 0 3 3 2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17"/><path d="M11 21.95V18a2 2 0 0 0-2-2 2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05"/><circle cx="12" cy="12" r="10"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,image:u`<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:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,circleCheck:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,circleX:u`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>`,puzzle:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>`,smile:u`<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:u`<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:u`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" rx="2"/></svg>`,eye:u`<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:u`<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:u`<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>`,mic:u`<svg viewBox="0 0 24 24"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" x2="12" y1="19" y2="22"/></svg>`,chevronDown:u`<svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,film:u`<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>`,wifi:u`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M2 8.82a15 15 0 0 1 20 0"/><path d="M5 12.859a10 10 0 0 1 14 0"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/></svg>`,wifiOff:u`<svg viewBox="0 0 24 24"><path d="M12 20h.01"/><path d="M8.5 16.429a5 5 0 0 1 7 0"/><path d="M5 12.859a10 10 0 0 1 5.17-2.69"/><path d="M13.41 10.28a10 10 0 0 1 5.59 2.58"/><path d="M2 8.82a15 15 0 0 1 4.17-2.65"/><path d="M10.66 5c4.01-.36 8.14.9 11.34 3.76"/><line x1="2" x2="22" y1="2" y2="22"/></svg>`,power:u`<svg viewBox="0 0 24 24"><path d="M18.36 6.64a9 9 0 1 1-12.73 0"/><line x1="12" x2="12" y1="2" y2="12"/></svg>`,powerOff:u`<svg viewBox="0 0 24 24"><path d="M18.36 6.64A9 9 0 0 1 20.77 15"/><path d="M6.16 6.16a9 9 0 1 0 12.68 12.68"/><path d="M12 2v4"/><path d="m2 2 20 20"/></svg>`},Hf=u`<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>`,jf=u`<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"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path><path d="M13.73 21a2 2 0 0 1-3.46 0"></path></svg>`,Gf=u`<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"><path d="M18.36 6.64a9 9 0 1 1-12.73 0"></path><line x1="12" y1="2" x2="12" y2="12"></line></svg>`;let _r=!1;function Vf(){_r||(_r=!0,document.addEventListener("click",e=>{const t=document.getElementById("nav-burger-toggle");if(!(t!=null&&t.checked))return;const n=t.closest(".setup-header");n!=null&&n.contains(e.target)||(t.checked=!1)}))}function Rt(e,t){var d;const n=(p,g)=>p===e?u`<span class="sp-page-nav-current">${p}</span>`:u`<a href=${g}>${p}</a>`,i=u`
|
|
21
21
|
${n("Setup","/setup")}
|
|
22
22
|
${n("Chat","/chat")}
|
|
23
23
|
${n("Admins","/admins")}
|
|
@@ -436,7 +436,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
436
436
|
>${r}</a>
|
|
437
437
|
<button class="setup-info-btn" title="Copy URL" @click=${async l=>{const c=l.currentTarget;try{await navigator.clipboard.writeText(r)}catch{const h=document.createElement("textarea");h.value=r,h.style.position="fixed",h.style.opacity="0",document.body.appendChild(h),h.select(),document.execCommand("copy"),document.body.removeChild(h)}c.classList.add("copied"),setTimeout(()=>c.classList.remove("copied"),1500)}}>${L.copy}</button>
|
|
438
438
|
</div>
|
|
439
|
-
`}break}case"public-chat":{if(t="Public Chat",n=[{label:"Status",value:e.publicChatEnabled?"Enabled":"Disabled"},{label:"What",value:"A chat widget anyone can use to message your business from a web browser"},{label:"Requires",value:"Remote Access with internet access enabled — this gives your device a public URL that visitors can reach"},{label:"Access mode",value
|
|
439
|
+
`}break}case"public-chat":{if(t="Public Chat",n=[{label:"Status",value:e.publicChatEnabled?"Enabled":"Disabled"},{label:"What",value:"A chat widget anyone can use to message your business from a web browser"},{label:"Requires",value:"Remote Access with internet access enabled — this gives your device a public URL that visitors can reach"},{label:"Access mode",value:xg[e.publicChatAuthMode]??"Open access"},{label:"WhatsApp",value:"Sends verification codes via WhatsApp. Requires a connected WhatsApp account."},{label:"SMS",value:"Sends verification codes via text message. Uses Brevo — same API key as email. Requires prepaid SMS credits in your Brevo account."},{label:"Email",value:"Sends verification codes via email. Uses Brevo (free, 300 emails/day). Sender address is auto-detected from your verified sender in Brevo."},{label:"Provider",value:"SMS and email both use Brevo — one API key, configured in API Keys above. WhatsApp uses your connected account."}],e.publicChatEnabled&&e.publicChatFullUrl){const o=e.publicChatFullUrl;i=u`
|
|
440
440
|
${e.publicChatQrDataUrl?u`<div style="text-align: center; padding: 12px 0;">
|
|
441
441
|
<img src=${e.publicChatQrDataUrl} alt="QR code for public chat URL" style="width: 180px; height: 180px; image-rendering: pixelated; border-radius: 8px;" />
|
|
442
442
|
</div>`:w}
|
|
@@ -837,16 +837,16 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
837
837
|
</div>
|
|
838
838
|
`:w}
|
|
839
839
|
</div>
|
|
840
|
-
`}const hg=[{id:"claude-opus-4-6",shortName:"Opus"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku"}],fg="anthropic/claude-sonnet-4-5-20250929",gg=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function mg(e){var
|
|
840
|
+
`}const hg=[{id:"claude-opus-4-6",shortName:"Opus"},{id:"claude-sonnet-4-5-20250929",shortName:"Sonnet"},{id:"claude-haiku-4-5-20251001",shortName:"Haiku"}],fg="anthropic/claude-sonnet-4-5-20250929",gg=[{value:"off",label:"Off"},{value:"minimal",label:"Minimal"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}];function mg(e){var S,T;if(!e.whatsappSettingsOpen)return w;const t=rn(e);if(!t)return w;const n=ba(t,e);if(!n)return w;const i=n.running&&n.connected,s=!n.provider||n.provider==="baileys",o=t.whatsappAccountId??(t.isDefault&&e.whatsappAccounts.length===1?(S=e.whatsappAccounts[0])==null?void 0:S.accountId:void 0),a=()=>e.onWhatsAppSettingsClose(),r=e.whatsappModelCatalog??[],l=new Set(r.filter(f=>f.provider==="anthropic").map(f=>f.id)),c=hg.filter(f=>l.has(f.id)),h=e.whatsappModel??fg,d=e.whatsappThinkingLevel??"off",p="display: flex; justify-content: space-between; font-size: 13px;",g="color: var(--tasker-text-grey);",$="color: var(--tasker-white); text-align: right;";return u`
|
|
841
841
|
<div class="setup-info-overlay" @click=${f=>{f.target.classList.contains("setup-info-overlay")&&a()}}>
|
|
842
842
|
<div class="setup-info-card" style="max-width: 360px;">
|
|
843
843
|
<h3>WhatsApp</h3>
|
|
844
844
|
<div style="display: flex; flex-direction: column; gap: 8px; margin-top: 12px;">
|
|
845
|
-
<div style="${p}"><span style="${
|
|
846
|
-
<div style="${p}"><span style="${
|
|
847
|
-
<div style="${p}"><span style="${
|
|
848
|
-
<div style="${p}"><span style="${
|
|
849
|
-
${n.lastError?u`<div style="${p}"><span style="${
|
|
845
|
+
<div style="${p}"><span style="${g}">Account</span><span style="${$}">${n.name||n.accountId||"Default"}</span></div>
|
|
846
|
+
<div style="${p}"><span style="${g}">Phone</span><span style="${$}">${((T=n.self)==null?void 0:T.e164)||"Not paired"}</span></div>
|
|
847
|
+
<div style="${p}"><span style="${g}">Connected</span><span style="${$}">${i?"Yes":"No"}</span></div>
|
|
848
|
+
<div style="${p}"><span style="${g}">Linked</span><span style="${$}">${n.linked?"Yes":"No"}</span></div>
|
|
849
|
+
${n.lastError?u`<div style="${p}"><span style="${g}">Error</span><span style="${$}; color: #ef4444;">${wa(n.lastError)}</span></div>`:w}
|
|
850
850
|
</div>
|
|
851
851
|
${s&&o?u`
|
|
852
852
|
<div style="border-top: 1px solid rgba(255,255,255,0.08); margin: 16px 0 12px;"></div>
|
|
@@ -1074,16 +1074,16 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
1074
1074
|
</div>
|
|
1075
1075
|
</div>
|
|
1076
1076
|
${wg(e)}
|
|
1077
|
-
`}function wg(e){if(!e.apiKeyModalOpen)return w;const t=e.apiKeyProviders,n={};for(const c of t)c.key&&(n[c.id]=c.key);const i=(c,h)=>{const d=h==null?void 0:h.closest(".setup-apikey-input"),p=d==null?void 0:d.querySelector("input"),
|
|
1077
|
+
`}function wg(e){if(!e.apiKeyModalOpen)return w;const t=e.apiKeyProviders,n={};for(const c of t)c.key&&(n[c.id]=c.key);const i=(c,h)=>{const d=h==null?void 0:h.closest(".setup-apikey-input"),p=d==null?void 0:d.querySelector("input"),g=p==null?void 0:p.value.trim();!g||g===n[c]||e.onApiKeySave(c,g)},s=c=>{const h=c.currentTarget,d=h.closest(".setup-apikey-input"),p=d==null?void 0:d.querySelector("input");if(!p)return;const g=p.type==="text";p.type=g?"password":"text",h.classList.toggle("active",!g)},o=(c,h)=>{const d=h.target,p=d.closest(".setup-apikey-input"),g=d.value.trim(),$=g.length>0&&g!==n[c],S=p==null?void 0:p.querySelector(".setup-apikey-save");S&&(S.style.display=$?"":"none");const T=p==null?void 0:p.querySelector(".setup-apikey-eye");T&&(T.style.display=g.length>0?"":"none")},a=t.filter(c=>c.primary),r=t.filter(c=>!c.primary),l=c=>{const h=e.apiKeySavingProvider===c.id&&e.apiKeyBusy,d=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key saved`,p=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} key removed`,g=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} disabled`,$=!e.apiKeyBusy&&e.apiKeySuccess===`${c.id} enabled`;return u`
|
|
1078
1078
|
<div class="setup-apikey-row ${c.disabled?"disabled":""}">
|
|
1079
1079
|
<div class="setup-apikey-info">
|
|
1080
1080
|
<strong>${c.name}</strong>
|
|
1081
1081
|
<span class="setup-apikey-category">${c.category}</span>
|
|
1082
1082
|
${d?u`<span class="setup-apikey-badge saved">Saved</span>`:w}
|
|
1083
1083
|
${p?u`<span class="setup-apikey-badge removed">Removed</span>`:w}
|
|
1084
|
-
${
|
|
1085
|
-
${
|
|
1086
|
-
${c.disabled
|
|
1084
|
+
${g?u`<span class="setup-apikey-badge removed">Disabled</span>`:w}
|
|
1085
|
+
${$?u`<span class="setup-apikey-badge saved">Enabled</span>`:w}
|
|
1086
|
+
${c.disabled&&!$?u`<span class="setup-apikey-badge apikey-disabled">Off</span>`:w}
|
|
1087
1087
|
</div>
|
|
1088
1088
|
<div class="setup-apikey-input">
|
|
1089
1089
|
<input
|
|
@@ -1091,8 +1091,8 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
1091
1091
|
.value=${c.key??""}
|
|
1092
1092
|
placeholder="Enter key"
|
|
1093
1093
|
?disabled=${e.apiKeyBusy||c.disabled}
|
|
1094
|
-
@input=${
|
|
1095
|
-
@keydown=${
|
|
1094
|
+
@input=${S=>o(c.id,S)}
|
|
1095
|
+
@keydown=${S=>{S.key==="Enter"&&i(c.id,S.target)}}
|
|
1096
1096
|
/>
|
|
1097
1097
|
<button
|
|
1098
1098
|
class="setup-apikey-icon-btn setup-apikey-eye"
|
|
@@ -1104,7 +1104,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
1104
1104
|
class="setup-apikey-save setup-button"
|
|
1105
1105
|
style="display: none;"
|
|
1106
1106
|
?disabled=${e.apiKeyBusy}
|
|
1107
|
-
@click=${
|
|
1107
|
+
@click=${S=>i(c.id,S.currentTarget)}
|
|
1108
1108
|
>Save</button>`}
|
|
1109
1109
|
${c.hasKey&&!h?u`
|
|
1110
1110
|
<button
|
|
@@ -1166,7 +1166,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
1166
1166
|
</button>
|
|
1167
1167
|
`}
|
|
1168
1168
|
</div>
|
|
1169
|
-
`}const
|
|
1169
|
+
`}const xg={anonymous:"Open access",verified:"Phone OTP",choice:"Visitor chooses"};function $g(e){const t=e.publicChatEnabled;return u`
|
|
1170
1170
|
<div class="setup-status-item">
|
|
1171
1171
|
${Q(t?"good":"unknown")}
|
|
1172
1172
|
<div class="setup-status-info">
|
|
@@ -1186,8 +1186,8 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
1186
1186
|
@click=${e.onPublicChatToggle}
|
|
1187
1187
|
>${t?L.powerOff:L.power}</button>
|
|
1188
1188
|
</div>
|
|
1189
|
-
`}function Sg(e){if(!e.publicChatSettingsOpen)return w;const t=()=>e.onPublicChatSettingsClose(),n=!!e.publicChatGreeting,i=e.publicChatAuthMode==="verified"||e.publicChatAuthMode==="choice",s=e.publicChatVerifyMethods.length>0?e.publicChatVerifyMethods:["whatsapp","sms"],o=s.includes("whatsapp"),a=s.includes("sms"),r=s.includes("email");return u`
|
|
1190
|
-
<div class="setup-info-overlay" @click=${
|
|
1189
|
+
`}function Sg(e){var c,h;if(!e.publicChatSettingsOpen)return w;const t=()=>e.onPublicChatSettingsClose(),n=!!e.publicChatGreeting,i=e.publicChatAuthMode==="verified"||e.publicChatAuthMode==="choice",s=e.publicChatVerifyMethods.length>0?e.publicChatVerifyMethods:["whatsapp","sms"],o=s.includes("whatsapp"),a=s.includes("sms"),r=s.includes("email"),l=!!((c=e.whatsappChannelStatus)!=null&&c.running&&((h=e.whatsappChannelStatus)!=null&&h.connected));return u`
|
|
1190
|
+
<div class="setup-info-overlay" @click=${d=>{d.target.classList.contains("setup-info-overlay")&&t()}}>
|
|
1191
1191
|
<div class="setup-info-card" style="max-width: 380px; max-height: 80vh; overflow-y: auto;">
|
|
1192
1192
|
<h3 style="margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between;">
|
|
1193
1193
|
Public Chat
|
|
@@ -1206,7 +1206,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
1206
1206
|
class="setup-select-sm"
|
|
1207
1207
|
style="width: 100%;"
|
|
1208
1208
|
?disabled=${e.publicChatBusy}
|
|
1209
|
-
@change=${
|
|
1209
|
+
@change=${d=>{const p=d.target.value;e.onPublicChatAuthModeChange(p)}}
|
|
1210
1210
|
>
|
|
1211
1211
|
<option value="anonymous" ?selected=${e.publicChatAuthMode==="anonymous"}>Open access</option>
|
|
1212
1212
|
<option value="verified" ?selected=${e.publicChatAuthMode==="verified"}>Identity verification</option>
|
|
@@ -1241,7 +1241,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
1241
1241
|
style="width: 100%; margin-top: 8px; font-size: 12px; padding: 8px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.2); color: var(--tasker-white); resize: vertical; min-height: 60px; font-family: inherit; box-sizing: border-box;"
|
|
1242
1242
|
?disabled=${e.publicChatGreetingBusy}
|
|
1243
1243
|
.value=${e.publicChatGreetingBusy?"Generating...":e.publicChatGreeting}
|
|
1244
|
-
@blur=${
|
|
1244
|
+
@blur=${d=>{const p=d.target.value.trim();p&&p!==e.publicChatGreeting&&e.onPublicChatGreetingSave(p)}}
|
|
1245
1245
|
></textarea>
|
|
1246
1246
|
`:u`
|
|
1247
1247
|
<div style="font-size: 12px; color: var(--tasker-text-grey); opacity: 0.7; margin-top: 4px;">
|
|
@@ -1257,17 +1257,19 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
1257
1257
|
<div>
|
|
1258
1258
|
<div style="font-size: 13px; color: var(--tasker-white); margin-bottom: 6px;">Verification methods</div>
|
|
1259
1259
|
<div style="display: flex; flex-direction: column; gap: 8px; text-align: left;">
|
|
1260
|
-
<label style="display: flex; align-items: flex-start; gap: 6px; cursor: pointer;">
|
|
1260
|
+
<label style="display: flex; align-items: flex-start; gap: 6px; ${l?"cursor: pointer;":"cursor: not-allowed; opacity: 0.5;"}">
|
|
1261
1261
|
<input
|
|
1262
1262
|
type="checkbox"
|
|
1263
|
-
.checked=${o}
|
|
1264
|
-
?disabled=${e.publicChatEmailBusy||!a&&!r&&o}
|
|
1265
|
-
@change=${
|
|
1263
|
+
.checked=${o&&l}
|
|
1264
|
+
?disabled=${!l||e.publicChatEmailBusy||!a&&!r&&o}
|
|
1265
|
+
@change=${d=>{const g=d.target.checked?[...s.filter($=>$!=="whatsapp"),"whatsapp"]:s.filter($=>$!=="whatsapp");g.length>0&&e.onPublicChatEmailSave(e.publicChatEmailFrom,g)}}
|
|
1266
1266
|
style="accent-color: #22c55e; margin-top: 2px;"
|
|
1267
1267
|
/>
|
|
1268
1268
|
<div>
|
|
1269
1269
|
<span style="font-size: 12px; color: var(--tasker-white);">WhatsApp</span>
|
|
1270
|
-
<div style="font-size: 11px; color: var(--tasker-text-grey); opacity: 0.7;">
|
|
1270
|
+
<div style="font-size: 11px; color: var(--tasker-text-grey); opacity: 0.7;">
|
|
1271
|
+
${l?"Phone OTP via WhatsApp":"No WhatsApp account connected on this account"}
|
|
1272
|
+
</div>
|
|
1271
1273
|
</div>
|
|
1272
1274
|
</label>
|
|
1273
1275
|
<label style="display: flex; align-items: flex-start; gap: 6px; cursor: pointer;">
|
|
@@ -1275,7 +1277,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
1275
1277
|
type="checkbox"
|
|
1276
1278
|
.checked=${a}
|
|
1277
1279
|
?disabled=${e.publicChatEmailBusy||!o&&!r&&a}
|
|
1278
|
-
@change=${
|
|
1280
|
+
@change=${d=>{const g=d.target.checked?[...s.filter($=>$!=="sms"),"sms"]:s.filter($=>$!=="sms");g.length>0&&e.onPublicChatEmailSave(e.publicChatEmailFrom,g)}}
|
|
1279
1281
|
style="accent-color: #22c55e; margin-top: 2px;"
|
|
1280
1282
|
/>
|
|
1281
1283
|
<div>
|
|
@@ -1288,7 +1290,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
1288
1290
|
type="checkbox"
|
|
1289
1291
|
.checked=${r}
|
|
1290
1292
|
?disabled=${e.publicChatEmailBusy||!o&&!a&&r}
|
|
1291
|
-
@change=${
|
|
1293
|
+
@change=${d=>{const g=d.target.checked?[...s.filter($=>$!=="email"),"email"]:s.filter($=>$!=="email");g.length>0&&e.onPublicChatEmailSave(e.publicChatEmailFrom,g)}}
|
|
1292
1294
|
style="accent-color: #22c55e; margin-top: 2px;"
|
|
1293
1295
|
/>
|
|
1294
1296
|
<div>
|
|
@@ -1536,8 +1538,8 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
1536
1538
|
@click=${e.onTailscaleEnable}
|
|
1537
1539
|
>${n?"...":"Connect"}</button>
|
|
1538
1540
|
</div>
|
|
1539
|
-
`;if(!t.serveEnabled)return u`
|
|
1540
|
-
<div class="setup-status-item">
|
|
1541
|
+
`;if(!t.serveEnabled){const a=e.tailscaleServeEnableUrl;return u`
|
|
1542
|
+
<div class="setup-status-item" style="flex-wrap: wrap;">
|
|
1541
1543
|
${Q("partial")}
|
|
1542
1544
|
<div class="setup-status-info">
|
|
1543
1545
|
<strong>Remote Access</strong>
|
|
@@ -1550,8 +1552,19 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
1550
1552
|
?disabled=${n}
|
|
1551
1553
|
@click=${e.onTailscaleServeEnable}
|
|
1552
1554
|
>${L.power}</button>
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
+
${a?u`<div style="flex-basis: 100%; padding-top: 6px;">
|
|
1556
|
+
<p style="margin: 0 0 4px; font-size: 13px; color: #f59e0b;">
|
|
1557
|
+
Serve must be enabled on your Tailscale account first.
|
|
1558
|
+
</p>
|
|
1559
|
+
<a
|
|
1560
|
+
href="${a}"
|
|
1561
|
+
target="_blank"
|
|
1562
|
+
rel="noopener"
|
|
1563
|
+
style="color: var(--tasker-link, #60a5fa); font-size: 13px; word-break: break-all;"
|
|
1564
|
+
>Open Tailscale admin to enable Serve →</a>
|
|
1565
|
+
</div>`:e.tailscaleError?u`<p style="flex-basis: 100%; margin: 6px 0 0; font-size: 13px; color: #ef4444;">${e.tailscaleError}</p>`:w}
|
|
1566
|
+
</div>
|
|
1567
|
+
`}if(!t.serveActive)return u`
|
|
1555
1568
|
<div class="setup-status-item" style="flex-wrap: wrap;">
|
|
1556
1569
|
${Q("bad")}
|
|
1557
1570
|
<div class="setup-status-info">
|
|
@@ -2162,7 +2175,7 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
2162
2175
|
${e.serverPlatform==="darwin"?yg(e):w}
|
|
2163
2176
|
${Dg(e)}
|
|
2164
2177
|
${kg(e)}
|
|
2165
|
-
${
|
|
2178
|
+
${$g(e)}
|
|
2166
2179
|
${Cg(e)}
|
|
2167
2180
|
${_g(e)}
|
|
2168
2181
|
${Ig(e)}
|
|
@@ -2576,33 +2589,33 @@ ${o}`)}return e.chatStream="","working"}else if(t.state==="block"){const s=Mn(t.
|
|
|
2576
2589
|
|
|
2577
2590
|
${i?jg(i,e):w}
|
|
2578
2591
|
${s?Gg(s,e):w}
|
|
2579
|
-
`}const pd={CHILD:2},hd=e=>(...t)=>({_$litDirective$:e,values:t});let fd=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,i){this._$Ct=t,this._$AM=n,this._$Ci=i}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}};const{I:Yg}=op,Lr=e=>e,Rr=()=>document.createComment(""),gn=(e,t,n)=>{var o;const i=e._$AA.parentNode,s=t===void 0?e._$AB:t._$AA;if(n===void 0){const a=i.insertBefore(Rr(),s),r=i.insertBefore(Rr(),s);n=new Yg(a,r,e,e.options)}else{const a=n._$AB.nextSibling,r=n._$AM,l=r!==e;if(l){let c;(o=n._$AQ)==null||o.call(n,e),n._$AM=e,n._$AP!==void 0&&(c=e._$AU)!==r._$AU&&n._$AP(c)}if(a!==s||l){let c=n._$AA;for(;c!==a;){const h=Lr(c).nextSibling;Lr(i).insertBefore(c,s),c=h}}}return n},mt=(e,t,n=e)=>(e._$AI(t,n),e),Xg={},Zg=(e,t=Xg)=>e._$AH=t,em=e=>e._$AH,Ws=e=>{e._$AR(),e._$AA.remove()};const Dr=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},tm=hd(class extends fd{constructor(e){if(super(e),e.type!==pd.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let i;n===void 0?n=t:t!==void 0&&(i=t);const s=[],o=[];let a=0;for(const r of e)s[a]=i?i(r,a):a,o[a]=n(r,a),a++;return{values:o,keys:s}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,i]){const s=em(e),{values:o,keys:a}=this.dt(t,n,i);if(!Array.isArray(s))return this.ut=a,o;const r=this.ut??(this.ut=[]),l=[];let c,h,d=0,p=s.length-1,v=0,S=o.length-1;for(;d<=p&&v<=S;)if(s[d]===null)d++;else if(s[p]===null)p--;else if(r[d]===a[v])l[v]=mt(s[d],o[v]),d++,v++;else if(r[p]===a[S])l[S]=mt(s[p],o[S]),p--,S--;else if(r[d]===a[S])l[S]=mt(s[d],o[S]),gn(e,l[S+1],s[d]),d++,S--;else if(r[p]===a[v])l[v]=mt(s[p],o[v]),gn(e,s[d],s[p]),p--,v++;else if(c===void 0&&(c=Dr(a,v,S),h=Dr(r,d,p)),c.has(r[d]))if(c.has(r[p])){const x=h.get(a[v]),T=x!==void 0?s[x]:null;if(T===null){const f=gn(e,s[d]);mt(f,o[v]),l[v]=f}else l[v]=mt(T,o[v]),gn(e,s[d],T),s[x]=null;v++}else Ws(s[p]),p--;else Ws(s[d]),d++;for(;v<=S;){const x=gn(e,l[S+1]);mt(x,o[v]),l[v++]=x}for(;d<=p;){const x=s[d++];x!==null&&Ws(x)}return this.ut=a,Zg(e,l),lt}});class Eo extends fd{constructor(t){if(super(t),this.it=w,t.type!==pd.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===w||t==null)return this._t=void 0,this.it=t;if(t===lt)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:[]}}}Eo.directiveName="unsafeHTML",Eo.resultType=1;const zi=hd(Eo);const{entries:gd,setPrototypeOf:Br,isFrozen:nm,getPrototypeOf:im,getOwnPropertyDescriptor:sm}=Object;let{freeze:ye,seal:$e,create:To}=Object,{apply:_o,construct:Mo}=typeof Reflect<"u"&&Reflect;ye||(ye=function(t){return t});$e||($e=function(t){return t});_o||(_o=function(t,n){for(var i=arguments.length,s=new Array(i>2?i-2:0),o=2;o<i;o++)s[o-2]=arguments[o];return t.apply(n,s)});Mo||(Mo=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return new t(...i)});const fi=ve(Array.prototype.forEach),om=ve(Array.prototype.lastIndexOf),Nr=ve(Array.prototype.pop),mn=ve(Array.prototype.push),am=ve(Array.prototype.splice),Ci=ve(String.prototype.toLowerCase),Ks=ve(String.prototype.toString),zs=ve(String.prototype.match),yn=ve(String.prototype.replace),rm=ve(String.prototype.indexOf),lm=ve(String.prototype.trim),xe=ve(Object.prototype.hasOwnProperty),ge=ve(RegExp.prototype.test),vn=cm(TypeError);function ve(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return _o(e,t,i)}}function cm(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return Mo(e,n)}}function K(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ci;Br&&Br(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const o=n(s);o!==s&&(nm(t)||(t[i]=o),s=o)}e[s]=!0}return e}function dm(e){for(let t=0;t<e.length;t++)xe(e,t)||(e[t]=null);return e}function Re(e){const t=To(null);for(const[n,i]of gd(e))xe(e,n)&&(Array.isArray(i)?t[n]=dm(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=Re(i):t[n]=i);return t}function bn(e,t){for(;e!==null;){const i=sm(e,t);if(i){if(i.get)return ve(i.get);if(typeof i.value=="function")return ve(i.value)}e=im(e)}function n(){return null}return n}const Or=ye(["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"]),qs=ye(["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"]),Hs=ye(["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"]),um=ye(["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=ye(["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"]),pm=ye(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Fr=ye(["#text"]),Ur=ye(["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"]),Gs=ye(["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"]),Wr=ye(["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"]),gi=ye(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),hm=$e(/\{\{[\w\W]*|[\w\W]*\}\}/gm),fm=$e(/<%[\w\W]*|[\w\W]*%>/gm),gm=$e(/\$\{[\w\W]*/gm),mm=$e(/^data-[\-\w.\u00B7-\uFFFF]+$/),ym=$e(/^aria-[\-\w]+$/),md=$e(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),vm=$e(/^(?:\w+script|data):/i),bm=$e(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),yd=$e(/^html$/i),wm=$e(/^[a-z][.\w]*(-[.\w]+)+$/i);var Kr=Object.freeze({__proto__:null,ARIA_ATTR:ym,ATTR_WHITESPACE:bm,CUSTOM_ELEMENT:wm,DATA_ATTR:mm,DOCTYPE_NAME:yd,ERB_EXPR:fm,IS_ALLOWED_URI:md,IS_SCRIPT_OR_DATA:vm,MUSTACHE_EXPR:hm,TMPLIT_EXPR:gm});const wn={element:1,text:3,progressingInstruction:7,comment:8,document:9},km=function(){return typeof window>"u"?null:window},$m=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(i=n.getAttribute(s));const o="dompurify"+(i?"#"+i:"");try{return t.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},zr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function vd(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:km();const t=N=>vd(N);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==wn.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const i=n,s=i.currentScript,{DocumentFragment:o,HTMLTemplateElement:a,Node:r,Element:l,NodeFilter:c,NamedNodeMap:h=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:p,trustedTypes:v}=e,S=l.prototype,x=bn(S,"cloneNode"),T=bn(S,"remove"),f=bn(S,"nextSibling"),b=bn(S,"childNodes"),k=bn(S,"parentNode");if(typeof a=="function"){const N=n.createElement("template");N.content&&N.content.ownerDocument&&(n=N.content.ownerDocument)}let A,E="";const{implementation:M,createNodeIterator:P,createDocumentFragment:R,getElementsByTagName:F}=n,{importNode:H}=i;let z=zr();t.isSupported=typeof gd=="function"&&typeof k=="function"&&M&&M.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ke,ERB_EXPR:_e,TMPLIT_EXPR:Ke,DATA_ATTR:ms,ARIA_ATTR:ys,IS_SCRIPT_OR_DATA:vs,ATTR_WHITESPACE:Qn,CUSTOM_ELEMENT:bs}=Kr;let{IS_ALLOWED_URI:Jn}=Kr,te=null;const Yn=K({},[...Or,...qs,...Hs,...js,...Fr]);let ne=null;const Xn=K({},[...Ur,...Gs,...Wr,...gi]);let X=Object.seal(To(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}})),pt=null,dn=null;const tt=Object.seal(To(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Zn=!0,C=!0,I=!1,U=!0,W=!1,Z=!0,J=!1,fe=!1,nt=!1,Nt=!1,ei=!1,ti=!1,Ua=!0,Wa=!1;const Tu="user-content-";let ws=!0,un=!1,Ot={},Me=null;const ks=K({},["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 Ka=null;const za=K({},["audio","video","img","source","image","track"]);let $s=null;const qa=K({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ni="http://www.w3.org/1998/Math/MathML",ii="http://www.w3.org/2000/svg",ze="http://www.w3.org/1999/xhtml";let Ft=ze,xs=!1,Ss=null;const _u=K({},[ni,ii,ze],Ks);let si=K({},["mi","mo","mn","ms","mtext"]),oi=K({},["annotation-xml"]);const Mu=K({},["title","style","font","a","script"]);let pn=null;const Pu=["application/xhtml+xml","text/html"],Iu="text/html";let oe=null,Ut=null;const Lu=n.createElement("form"),Ha=function($){return $ instanceof RegExp||$ instanceof Function},As=function(){let $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ut&&Ut===$)){if((!$||typeof $!="object")&&($={}),$=Re($),pn=Pu.indexOf($.PARSER_MEDIA_TYPE)===-1?Iu:$.PARSER_MEDIA_TYPE,oe=pn==="application/xhtml+xml"?Ks:Ci,te=xe($,"ALLOWED_TAGS")?K({},$.ALLOWED_TAGS,oe):Yn,ne=xe($,"ALLOWED_ATTR")?K({},$.ALLOWED_ATTR,oe):Xn,Ss=xe($,"ALLOWED_NAMESPACES")?K({},$.ALLOWED_NAMESPACES,Ks):_u,$s=xe($,"ADD_URI_SAFE_ATTR")?K(Re(qa),$.ADD_URI_SAFE_ATTR,oe):qa,Ka=xe($,"ADD_DATA_URI_TAGS")?K(Re(za),$.ADD_DATA_URI_TAGS,oe):za,Me=xe($,"FORBID_CONTENTS")?K({},$.FORBID_CONTENTS,oe):ks,pt=xe($,"FORBID_TAGS")?K({},$.FORBID_TAGS,oe):Re({}),dn=xe($,"FORBID_ATTR")?K({},$.FORBID_ATTR,oe):Re({}),Ot=xe($,"USE_PROFILES")?$.USE_PROFILES:!1,Zn=$.ALLOW_ARIA_ATTR!==!1,C=$.ALLOW_DATA_ATTR!==!1,I=$.ALLOW_UNKNOWN_PROTOCOLS||!1,U=$.ALLOW_SELF_CLOSE_IN_ATTR!==!1,W=$.SAFE_FOR_TEMPLATES||!1,Z=$.SAFE_FOR_XML!==!1,J=$.WHOLE_DOCUMENT||!1,Nt=$.RETURN_DOM||!1,ei=$.RETURN_DOM_FRAGMENT||!1,ti=$.RETURN_TRUSTED_TYPE||!1,nt=$.FORCE_BODY||!1,Ua=$.SANITIZE_DOM!==!1,Wa=$.SANITIZE_NAMED_PROPS||!1,ws=$.KEEP_CONTENT!==!1,un=$.IN_PLACE||!1,Jn=$.ALLOWED_URI_REGEXP||md,Ft=$.NAMESPACE||ze,si=$.MATHML_TEXT_INTEGRATION_POINTS||si,oi=$.HTML_INTEGRATION_POINTS||oi,X=$.CUSTOM_ELEMENT_HANDLING||{},$.CUSTOM_ELEMENT_HANDLING&&Ha($.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(X.tagNameCheck=$.CUSTOM_ELEMENT_HANDLING.tagNameCheck),$.CUSTOM_ELEMENT_HANDLING&&Ha($.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(X.attributeNameCheck=$.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),$.CUSTOM_ELEMENT_HANDLING&&typeof $.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(X.allowCustomizedBuiltInElements=$.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),W&&(C=!1),ei&&(Nt=!0),Ot&&(te=K({},Fr),ne=[],Ot.html===!0&&(K(te,Or),K(ne,Ur)),Ot.svg===!0&&(K(te,qs),K(ne,Gs),K(ne,gi)),Ot.svgFilters===!0&&(K(te,Hs),K(ne,Gs),K(ne,gi)),Ot.mathMl===!0&&(K(te,js),K(ne,Wr),K(ne,gi))),$.ADD_TAGS&&(typeof $.ADD_TAGS=="function"?tt.tagCheck=$.ADD_TAGS:(te===Yn&&(te=Re(te)),K(te,$.ADD_TAGS,oe))),$.ADD_ATTR&&(typeof $.ADD_ATTR=="function"?tt.attributeCheck=$.ADD_ATTR:(ne===Xn&&(ne=Re(ne)),K(ne,$.ADD_ATTR,oe))),$.ADD_URI_SAFE_ATTR&&K($s,$.ADD_URI_SAFE_ATTR,oe),$.FORBID_CONTENTS&&(Me===ks&&(Me=Re(Me)),K(Me,$.FORBID_CONTENTS,oe)),$.ADD_FORBID_CONTENTS&&(Me===ks&&(Me=Re(Me)),K(Me,$.ADD_FORBID_CONTENTS,oe)),ws&&(te["#text"]=!0),J&&K(te,["html","head","body"]),te.table&&(K(te,["tbody"]),delete pt.tbody),$.TRUSTED_TYPES_POLICY){if(typeof $.TRUSTED_TYPES_POLICY.createHTML!="function")throw vn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof $.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw vn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');A=$.TRUSTED_TYPES_POLICY,E=A.createHTML("")}else A===void 0&&(A=$m(v,s)),A!==null&&typeof E=="string"&&(E=A.createHTML(""));ye&&ye($),Ut=$}},ja=K({},[...qs,...Hs,...um]),Ga=K({},[...js,...pm]),Ru=function($){let _=k($);(!_||!_.tagName)&&(_={namespaceURI:Ft,tagName:"template"});const B=Ci($.tagName),Y=Ci(_.tagName);return Ss[$.namespaceURI]?$.namespaceURI===ii?_.namespaceURI===ze?B==="svg":_.namespaceURI===ni?B==="svg"&&(Y==="annotation-xml"||si[Y]):!!ja[B]:$.namespaceURI===ni?_.namespaceURI===ze?B==="math":_.namespaceURI===ii?B==="math"&&oi[Y]:!!Ga[B]:$.namespaceURI===ze?_.namespaceURI===ii&&!oi[Y]||_.namespaceURI===ni&&!si[Y]?!1:!Ga[B]&&(Mu[B]||!ja[B]):!!(pn==="application/xhtml+xml"&&Ss[$.namespaceURI]):!1},Pe=function($){mn(t.removed,{element:$});try{k($).removeChild($)}catch{T($)}},ht=function($,_){try{mn(t.removed,{attribute:_.getAttributeNode($),from:_})}catch{mn(t.removed,{attribute:null,from:_})}if(_.removeAttribute($),$==="is")if(Nt||ei)try{Pe(_)}catch{}else try{_.setAttribute($,"")}catch{}},Va=function($){let _=null,B=null;if(nt)$="<remove></remove>"+$;else{const se=zs($,/^[\r\n\t ]+/);B=se&&se[0]}pn==="application/xhtml+xml"&&Ft===ze&&($='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+$+"</body></html>");const Y=A?A.createHTML($):$;if(Ft===ze)try{_=new p().parseFromString(Y,pn)}catch{}if(!_||!_.documentElement){_=M.createDocument(Ft,"template",null);try{_.documentElement.innerHTML=xs?E:Y}catch{}}const de=_.body||_.documentElement;return $&&B&&de.insertBefore(n.createTextNode(B),de.childNodes[0]||null),Ft===ze?F.call(_,J?"html":"body")[0]:J?_.documentElement:de},Qa=function($){return P.call($.ownerDocument||$,$,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Cs=function($){return $ instanceof d&&(typeof $.nodeName!="string"||typeof $.textContent!="string"||typeof $.removeChild!="function"||!($.attributes instanceof h)||typeof $.removeAttribute!="function"||typeof $.setAttribute!="function"||typeof $.namespaceURI!="string"||typeof $.insertBefore!="function"||typeof $.hasChildNodes!="function")},Ja=function($){return typeof r=="function"&&$ instanceof r};function qe(N,$,_){fi(N,B=>{B.call(t,$,_,Ut)})}const Ya=function($){let _=null;if(qe(z.beforeSanitizeElements,$,null),Cs($))return Pe($),!0;const B=oe($.nodeName);if(qe(z.uponSanitizeElement,$,{tagName:B,allowedTags:te}),Z&&$.hasChildNodes()&&!Ja($.firstElementChild)&&ge(/<[/\w!]/g,$.innerHTML)&&ge(/<[/\w!]/g,$.textContent)||$.nodeType===wn.progressingInstruction||Z&&$.nodeType===wn.comment&&ge(/<[/\w]/g,$.data))return Pe($),!0;if(!(tt.tagCheck instanceof Function&&tt.tagCheck(B))&&(!te[B]||pt[B])){if(!pt[B]&&Za(B)&&(X.tagNameCheck instanceof RegExp&&ge(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B)))return!1;if(ws&&!Me[B]){const Y=k($)||$.parentNode,de=b($)||$.childNodes;if(de&&Y){const se=de.length;for(let be=se-1;be>=0;--be){const He=x(de[be],!0);He.__removalCount=($.__removalCount||0)+1,Y.insertBefore(He,f($))}}}return Pe($),!0}return $ instanceof l&&!Ru($)||(B==="noscript"||B==="noembed"||B==="noframes")&&ge(/<\/no(script|embed|frames)/i,$.innerHTML)?(Pe($),!0):(W&&$.nodeType===wn.text&&(_=$.textContent,fi([ke,_e,Ke],Y=>{_=yn(_,Y," ")}),$.textContent!==_&&(mn(t.removed,{element:$.cloneNode()}),$.textContent=_)),qe(z.afterSanitizeElements,$,null),!1)},Xa=function($,_,B){if(Ua&&(_==="id"||_==="name")&&(B in n||B in Lu))return!1;if(!(C&&!dn[_]&&ge(ms,_))){if(!(Zn&&ge(ys,_))){if(!(tt.attributeCheck instanceof Function&&tt.attributeCheck(_,$))){if(!ne[_]||dn[_]){if(!(Za($)&&(X.tagNameCheck instanceof RegExp&&ge(X.tagNameCheck,$)||X.tagNameCheck instanceof Function&&X.tagNameCheck($))&&(X.attributeNameCheck instanceof RegExp&&ge(X.attributeNameCheck,_)||X.attributeNameCheck instanceof Function&&X.attributeNameCheck(_,$))||_==="is"&&X.allowCustomizedBuiltInElements&&(X.tagNameCheck instanceof RegExp&&ge(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B))))return!1}else if(!$s[_]){if(!ge(Jn,yn(B,Qn,""))){if(!((_==="src"||_==="xlink:href"||_==="href")&&$!=="script"&&rm(B,"data:")===0&&Ka[$])){if(!(I&&!ge(vs,yn(B,Qn,"")))){if(B)return!1}}}}}}}return!0},Za=function($){return $!=="annotation-xml"&&zs($,bs)},er=function($){qe(z.beforeSanitizeAttributes,$,null);const{attributes:_}=$;if(!_||Cs($))return;const B={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ne,forceKeepAttr:void 0};let Y=_.length;for(;Y--;){const de=_[Y],{name:se,namespaceURI:be,value:He}=de,Wt=oe(se),Es=He;let re=se==="value"?Es:lm(Es);if(B.attrName=Wt,B.attrValue=re,B.keepAttr=!0,B.forceKeepAttr=void 0,qe(z.uponSanitizeAttribute,$,B),re=B.attrValue,Wa&&(Wt==="id"||Wt==="name")&&(ht(se,$),re=Tu+re),Z&&ge(/((--!?|])>)|<\/(style|title|textarea)/i,re)){ht(se,$);continue}if(Wt==="attributename"&&zs(re,"href")){ht(se,$);continue}if(B.forceKeepAttr)continue;if(!B.keepAttr){ht(se,$);continue}if(!U&&ge(/\/>/i,re)){ht(se,$);continue}W&&fi([ke,_e,Ke],nr=>{re=yn(re,nr," ")});const tr=oe($.nodeName);if(!Xa(tr,Wt,re)){ht(se,$);continue}if(A&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!be)switch(v.getAttributeType(tr,Wt)){case"TrustedHTML":{re=A.createHTML(re);break}case"TrustedScriptURL":{re=A.createScriptURL(re);break}}if(re!==Es)try{be?$.setAttributeNS(be,se,re):$.setAttribute(se,re),Cs($)?Pe($):Nr(t.removed)}catch{ht(se,$)}}qe(z.afterSanitizeAttributes,$,null)},Du=function N($){let _=null;const B=Qa($);for(qe(z.beforeSanitizeShadowDOM,$,null);_=B.nextNode();)qe(z.uponSanitizeShadowNode,_,null),Ya(_),er(_),_.content instanceof o&&N(_.content);qe(z.afterSanitizeShadowDOM,$,null)};return t.sanitize=function(N){let $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},_=null,B=null,Y=null,de=null;if(xs=!N,xs&&(N="<!-->"),typeof N!="string"&&!Ja(N))if(typeof N.toString=="function"){if(N=N.toString(),typeof N!="string")throw vn("dirty is not a string, aborting")}else throw vn("toString is not a function");if(!t.isSupported)return N;if(fe||As($),t.removed=[],typeof N=="string"&&(un=!1),un){if(N.nodeName){const He=oe(N.nodeName);if(!te[He]||pt[He])throw vn("root node is forbidden and cannot be sanitized in-place")}}else if(N instanceof r)_=Va("<!---->"),B=_.ownerDocument.importNode(N,!0),B.nodeType===wn.element&&B.nodeName==="BODY"||B.nodeName==="HTML"?_=B:_.appendChild(B);else{if(!Nt&&!W&&!J&&N.indexOf("<")===-1)return A&&ti?A.createHTML(N):N;if(_=Va(N),!_)return Nt?null:ti?E:""}_&&nt&&Pe(_.firstChild);const se=Qa(un?N:_);for(;Y=se.nextNode();)Ya(Y),er(Y),Y.content instanceof o&&Du(Y.content);if(un)return N;if(Nt){if(ei)for(de=R.call(_.ownerDocument);_.firstChild;)de.appendChild(_.firstChild);else de=_;return(ne.shadowroot||ne.shadowrootmode)&&(de=H.call(i,de,!0)),de}let be=J?_.outerHTML:_.innerHTML;return J&&te["!doctype"]&&_.ownerDocument&&_.ownerDocument.doctype&&_.ownerDocument.doctype.name&&ge(yd,_.ownerDocument.doctype.name)&&(be="<!DOCTYPE "+_.ownerDocument.doctype.name+`>
|
|
2580
|
-
`+be),W&&fi([ke,_e,Ke],He=>{be=yn(be,He," ")}),A&&ti?A.createHTML(be):be},t.setConfig=function(){let N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};As(N),fe=!0},t.clearConfig=function(){Ut=null,fe=!1},t.isValidAttribute=function(N
|
|
2581
|
-
]`).replace("lheading",kd).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Bm=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Nm=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)
|
|
2592
|
+
`}const pd={CHILD:2},hd=e=>(...t)=>({_$litDirective$:e,values:t});let fd=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,i){this._$Ct=t,this._$AM=n,this._$Ci=i}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}};const{I:Yg}=op,Lr=e=>e,Rr=()=>document.createComment(""),gn=(e,t,n)=>{var o;const i=e._$AA.parentNode,s=t===void 0?e._$AB:t._$AA;if(n===void 0){const a=i.insertBefore(Rr(),s),r=i.insertBefore(Rr(),s);n=new Yg(a,r,e,e.options)}else{const a=n._$AB.nextSibling,r=n._$AM,l=r!==e;if(l){let c;(o=n._$AQ)==null||o.call(n,e),n._$AM=e,n._$AP!==void 0&&(c=e._$AU)!==r._$AU&&n._$AP(c)}if(a!==s||l){let c=n._$AA;for(;c!==a;){const h=Lr(c).nextSibling;Lr(i).insertBefore(c,s),c=h}}}return n},mt=(e,t,n=e)=>(e._$AI(t,n),e),Xg={},Zg=(e,t=Xg)=>e._$AH=t,em=e=>e._$AH,Ws=e=>{e._$AR(),e._$AA.remove()};const Dr=(e,t,n)=>{const i=new Map;for(let s=t;s<=n;s++)i.set(e[s],s);return i},tm=hd(class extends fd{constructor(e){if(super(e),e.type!==pd.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let i;n===void 0?n=t:t!==void 0&&(i=t);const s=[],o=[];let a=0;for(const r of e)s[a]=i?i(r,a):a,o[a]=n(r,a),a++;return{values:o,keys:s}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,i]){const s=em(e),{values:o,keys:a}=this.dt(t,n,i);if(!Array.isArray(s))return this.ut=a,o;const r=this.ut??(this.ut=[]),l=[];let c,h,d=0,p=s.length-1,g=0,$=o.length-1;for(;d<=p&&g<=$;)if(s[d]===null)d++;else if(s[p]===null)p--;else if(r[d]===a[g])l[g]=mt(s[d],o[g]),d++,g++;else if(r[p]===a[$])l[$]=mt(s[p],o[$]),p--,$--;else if(r[d]===a[$])l[$]=mt(s[d],o[$]),gn(e,l[$+1],s[d]),d++,$--;else if(r[p]===a[g])l[g]=mt(s[p],o[g]),gn(e,s[d],s[p]),p--,g++;else if(c===void 0&&(c=Dr(a,g,$),h=Dr(r,d,p)),c.has(r[d]))if(c.has(r[p])){const S=h.get(a[g]),T=S!==void 0?s[S]:null;if(T===null){const f=gn(e,s[d]);mt(f,o[g]),l[g]=f}else l[g]=mt(T,o[g]),gn(e,s[d],T),s[S]=null;g++}else Ws(s[p]),p--;else Ws(s[d]),d++;for(;g<=$;){const S=gn(e,l[$+1]);mt(S,o[g]),l[g++]=S}for(;d<=p;){const S=s[d++];S!==null&&Ws(S)}return this.ut=a,Zg(e,l),lt}});class Eo extends fd{constructor(t){if(super(t),this.it=w,t.type!==pd.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===w||t==null)return this._t=void 0,this.it=t;if(t===lt)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:[]}}}Eo.directiveName="unsafeHTML",Eo.resultType=1;const zi=hd(Eo);const{entries:gd,setPrototypeOf:Br,isFrozen:nm,getPrototypeOf:im,getOwnPropertyDescriptor:sm}=Object;let{freeze:ye,seal:xe,create:To}=Object,{apply:_o,construct:Mo}=typeof Reflect<"u"&&Reflect;ye||(ye=function(t){return t});xe||(xe=function(t){return t});_o||(_o=function(t,n){for(var i=arguments.length,s=new Array(i>2?i-2:0),o=2;o<i;o++)s[o-2]=arguments[o];return t.apply(n,s)});Mo||(Mo=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return new t(...i)});const fi=ve(Array.prototype.forEach),om=ve(Array.prototype.lastIndexOf),Nr=ve(Array.prototype.pop),mn=ve(Array.prototype.push),am=ve(Array.prototype.splice),Ci=ve(String.prototype.toLowerCase),Ks=ve(String.prototype.toString),zs=ve(String.prototype.match),yn=ve(String.prototype.replace),rm=ve(String.prototype.indexOf),lm=ve(String.prototype.trim),$e=ve(Object.prototype.hasOwnProperty),ge=ve(RegExp.prototype.test),vn=cm(TypeError);function ve(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return _o(e,t,i)}}function cm(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return Mo(e,n)}}function K(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ci;Br&&Br(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const o=n(s);o!==s&&(nm(t)||(t[i]=o),s=o)}e[s]=!0}return e}function dm(e){for(let t=0;t<e.length;t++)$e(e,t)||(e[t]=null);return e}function Re(e){const t=To(null);for(const[n,i]of gd(e))$e(e,n)&&(Array.isArray(i)?t[n]=dm(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=Re(i):t[n]=i);return t}function bn(e,t){for(;e!==null;){const i=sm(e,t);if(i){if(i.get)return ve(i.get);if(typeof i.value=="function")return ve(i.value)}e=im(e)}function n(){return null}return n}const Or=ye(["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"]),qs=ye(["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"]),Hs=ye(["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"]),um=ye(["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=ye(["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"]),pm=ye(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Fr=ye(["#text"]),Ur=ye(["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"]),Gs=ye(["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"]),Wr=ye(["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"]),gi=ye(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),hm=xe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),fm=xe(/<%[\w\W]*|[\w\W]*%>/gm),gm=xe(/\$\{[\w\W]*/gm),mm=xe(/^data-[\-\w.\u00B7-\uFFFF]+$/),ym=xe(/^aria-[\-\w]+$/),md=xe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),vm=xe(/^(?:\w+script|data):/i),bm=xe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),yd=xe(/^html$/i),wm=xe(/^[a-z][.\w]*(-[.\w]+)+$/i);var Kr=Object.freeze({__proto__:null,ARIA_ATTR:ym,ATTR_WHITESPACE:bm,CUSTOM_ELEMENT:wm,DATA_ATTR:mm,DOCTYPE_NAME:yd,ERB_EXPR:fm,IS_ALLOWED_URI:md,IS_SCRIPT_OR_DATA:vm,MUSTACHE_EXPR:hm,TMPLIT_EXPR:gm});const wn={element:1,text:3,progressingInstruction:7,comment:8,document:9},km=function(){return typeof window>"u"?null:window},xm=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(i=n.getAttribute(s));const o="dompurify"+(i?"#"+i:"");try{return t.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},zr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function vd(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:km();const t=N=>vd(N);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==wn.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const i=n,s=i.currentScript,{DocumentFragment:o,HTMLTemplateElement:a,Node:r,Element:l,NodeFilter:c,NamedNodeMap:h=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:p,trustedTypes:g}=e,$=l.prototype,S=bn($,"cloneNode"),T=bn($,"remove"),f=bn($,"nextSibling"),b=bn($,"childNodes"),k=bn($,"parentNode");if(typeof a=="function"){const N=n.createElement("template");N.content&&N.content.ownerDocument&&(n=N.content.ownerDocument)}let A,E="";const{implementation:M,createNodeIterator:P,createDocumentFragment:R,getElementsByTagName:F}=n,{importNode:H}=i;let z=zr();t.isSupported=typeof gd=="function"&&typeof k=="function"&&M&&M.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ke,ERB_EXPR:_e,TMPLIT_EXPR:Ke,DATA_ATTR:ms,ARIA_ATTR:ys,IS_SCRIPT_OR_DATA:vs,ATTR_WHITESPACE:Qn,CUSTOM_ELEMENT:bs}=Kr;let{IS_ALLOWED_URI:Jn}=Kr,te=null;const Yn=K({},[...Or,...qs,...Hs,...js,...Fr]);let ne=null;const Xn=K({},[...Ur,...Gs,...Wr,...gi]);let X=Object.seal(To(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}})),pt=null,dn=null;const tt=Object.seal(To(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Zn=!0,C=!0,I=!1,U=!0,W=!1,Z=!0,J=!1,fe=!1,nt=!1,Nt=!1,ei=!1,ti=!1,Ua=!0,Wa=!1;const Tu="user-content-";let ws=!0,un=!1,Ot={},Me=null;const ks=K({},["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 Ka=null;const za=K({},["audio","video","img","source","image","track"]);let xs=null;const qa=K({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ni="http://www.w3.org/1998/Math/MathML",ii="http://www.w3.org/2000/svg",ze="http://www.w3.org/1999/xhtml";let Ft=ze,$s=!1,Ss=null;const _u=K({},[ni,ii,ze],Ks);let si=K({},["mi","mo","mn","ms","mtext"]),oi=K({},["annotation-xml"]);const Mu=K({},["title","style","font","a","script"]);let pn=null;const Pu=["application/xhtml+xml","text/html"],Iu="text/html";let oe=null,Ut=null;const Lu=n.createElement("form"),Ha=function(x){return x instanceof RegExp||x instanceof Function},As=function(){let x=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ut&&Ut===x)){if((!x||typeof x!="object")&&(x={}),x=Re(x),pn=Pu.indexOf(x.PARSER_MEDIA_TYPE)===-1?Iu:x.PARSER_MEDIA_TYPE,oe=pn==="application/xhtml+xml"?Ks:Ci,te=$e(x,"ALLOWED_TAGS")?K({},x.ALLOWED_TAGS,oe):Yn,ne=$e(x,"ALLOWED_ATTR")?K({},x.ALLOWED_ATTR,oe):Xn,Ss=$e(x,"ALLOWED_NAMESPACES")?K({},x.ALLOWED_NAMESPACES,Ks):_u,xs=$e(x,"ADD_URI_SAFE_ATTR")?K(Re(qa),x.ADD_URI_SAFE_ATTR,oe):qa,Ka=$e(x,"ADD_DATA_URI_TAGS")?K(Re(za),x.ADD_DATA_URI_TAGS,oe):za,Me=$e(x,"FORBID_CONTENTS")?K({},x.FORBID_CONTENTS,oe):ks,pt=$e(x,"FORBID_TAGS")?K({},x.FORBID_TAGS,oe):Re({}),dn=$e(x,"FORBID_ATTR")?K({},x.FORBID_ATTR,oe):Re({}),Ot=$e(x,"USE_PROFILES")?x.USE_PROFILES:!1,Zn=x.ALLOW_ARIA_ATTR!==!1,C=x.ALLOW_DATA_ATTR!==!1,I=x.ALLOW_UNKNOWN_PROTOCOLS||!1,U=x.ALLOW_SELF_CLOSE_IN_ATTR!==!1,W=x.SAFE_FOR_TEMPLATES||!1,Z=x.SAFE_FOR_XML!==!1,J=x.WHOLE_DOCUMENT||!1,Nt=x.RETURN_DOM||!1,ei=x.RETURN_DOM_FRAGMENT||!1,ti=x.RETURN_TRUSTED_TYPE||!1,nt=x.FORCE_BODY||!1,Ua=x.SANITIZE_DOM!==!1,Wa=x.SANITIZE_NAMED_PROPS||!1,ws=x.KEEP_CONTENT!==!1,un=x.IN_PLACE||!1,Jn=x.ALLOWED_URI_REGEXP||md,Ft=x.NAMESPACE||ze,si=x.MATHML_TEXT_INTEGRATION_POINTS||si,oi=x.HTML_INTEGRATION_POINTS||oi,X=x.CUSTOM_ELEMENT_HANDLING||{},x.CUSTOM_ELEMENT_HANDLING&&Ha(x.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(X.tagNameCheck=x.CUSTOM_ELEMENT_HANDLING.tagNameCheck),x.CUSTOM_ELEMENT_HANDLING&&Ha(x.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(X.attributeNameCheck=x.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),x.CUSTOM_ELEMENT_HANDLING&&typeof x.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(X.allowCustomizedBuiltInElements=x.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),W&&(C=!1),ei&&(Nt=!0),Ot&&(te=K({},Fr),ne=[],Ot.html===!0&&(K(te,Or),K(ne,Ur)),Ot.svg===!0&&(K(te,qs),K(ne,Gs),K(ne,gi)),Ot.svgFilters===!0&&(K(te,Hs),K(ne,Gs),K(ne,gi)),Ot.mathMl===!0&&(K(te,js),K(ne,Wr),K(ne,gi))),x.ADD_TAGS&&(typeof x.ADD_TAGS=="function"?tt.tagCheck=x.ADD_TAGS:(te===Yn&&(te=Re(te)),K(te,x.ADD_TAGS,oe))),x.ADD_ATTR&&(typeof x.ADD_ATTR=="function"?tt.attributeCheck=x.ADD_ATTR:(ne===Xn&&(ne=Re(ne)),K(ne,x.ADD_ATTR,oe))),x.ADD_URI_SAFE_ATTR&&K(xs,x.ADD_URI_SAFE_ATTR,oe),x.FORBID_CONTENTS&&(Me===ks&&(Me=Re(Me)),K(Me,x.FORBID_CONTENTS,oe)),x.ADD_FORBID_CONTENTS&&(Me===ks&&(Me=Re(Me)),K(Me,x.ADD_FORBID_CONTENTS,oe)),ws&&(te["#text"]=!0),J&&K(te,["html","head","body"]),te.table&&(K(te,["tbody"]),delete pt.tbody),x.TRUSTED_TYPES_POLICY){if(typeof x.TRUSTED_TYPES_POLICY.createHTML!="function")throw vn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof x.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw vn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');A=x.TRUSTED_TYPES_POLICY,E=A.createHTML("")}else A===void 0&&(A=xm(g,s)),A!==null&&typeof E=="string"&&(E=A.createHTML(""));ye&&ye(x),Ut=x}},ja=K({},[...qs,...Hs,...um]),Ga=K({},[...js,...pm]),Ru=function(x){let _=k(x);(!_||!_.tagName)&&(_={namespaceURI:Ft,tagName:"template"});const B=Ci(x.tagName),Y=Ci(_.tagName);return Ss[x.namespaceURI]?x.namespaceURI===ii?_.namespaceURI===ze?B==="svg":_.namespaceURI===ni?B==="svg"&&(Y==="annotation-xml"||si[Y]):!!ja[B]:x.namespaceURI===ni?_.namespaceURI===ze?B==="math":_.namespaceURI===ii?B==="math"&&oi[Y]:!!Ga[B]:x.namespaceURI===ze?_.namespaceURI===ii&&!oi[Y]||_.namespaceURI===ni&&!si[Y]?!1:!Ga[B]&&(Mu[B]||!ja[B]):!!(pn==="application/xhtml+xml"&&Ss[x.namespaceURI]):!1},Pe=function(x){mn(t.removed,{element:x});try{k(x).removeChild(x)}catch{T(x)}},ht=function(x,_){try{mn(t.removed,{attribute:_.getAttributeNode(x),from:_})}catch{mn(t.removed,{attribute:null,from:_})}if(_.removeAttribute(x),x==="is")if(Nt||ei)try{Pe(_)}catch{}else try{_.setAttribute(x,"")}catch{}},Va=function(x){let _=null,B=null;if(nt)x="<remove></remove>"+x;else{const se=zs(x,/^[\r\n\t ]+/);B=se&&se[0]}pn==="application/xhtml+xml"&&Ft===ze&&(x='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+x+"</body></html>");const Y=A?A.createHTML(x):x;if(Ft===ze)try{_=new p().parseFromString(Y,pn)}catch{}if(!_||!_.documentElement){_=M.createDocument(Ft,"template",null);try{_.documentElement.innerHTML=$s?E:Y}catch{}}const de=_.body||_.documentElement;return x&&B&&de.insertBefore(n.createTextNode(B),de.childNodes[0]||null),Ft===ze?F.call(_,J?"html":"body")[0]:J?_.documentElement:de},Qa=function(x){return P.call(x.ownerDocument||x,x,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Cs=function(x){return x instanceof d&&(typeof x.nodeName!="string"||typeof x.textContent!="string"||typeof x.removeChild!="function"||!(x.attributes instanceof h)||typeof x.removeAttribute!="function"||typeof x.setAttribute!="function"||typeof x.namespaceURI!="string"||typeof x.insertBefore!="function"||typeof x.hasChildNodes!="function")},Ja=function(x){return typeof r=="function"&&x instanceof r};function qe(N,x,_){fi(N,B=>{B.call(t,x,_,Ut)})}const Ya=function(x){let _=null;if(qe(z.beforeSanitizeElements,x,null),Cs(x))return Pe(x),!0;const B=oe(x.nodeName);if(qe(z.uponSanitizeElement,x,{tagName:B,allowedTags:te}),Z&&x.hasChildNodes()&&!Ja(x.firstElementChild)&&ge(/<[/\w!]/g,x.innerHTML)&&ge(/<[/\w!]/g,x.textContent)||x.nodeType===wn.progressingInstruction||Z&&x.nodeType===wn.comment&&ge(/<[/\w]/g,x.data))return Pe(x),!0;if(!(tt.tagCheck instanceof Function&&tt.tagCheck(B))&&(!te[B]||pt[B])){if(!pt[B]&&Za(B)&&(X.tagNameCheck instanceof RegExp&&ge(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B)))return!1;if(ws&&!Me[B]){const Y=k(x)||x.parentNode,de=b(x)||x.childNodes;if(de&&Y){const se=de.length;for(let be=se-1;be>=0;--be){const He=S(de[be],!0);He.__removalCount=(x.__removalCount||0)+1,Y.insertBefore(He,f(x))}}}return Pe(x),!0}return x instanceof l&&!Ru(x)||(B==="noscript"||B==="noembed"||B==="noframes")&&ge(/<\/no(script|embed|frames)/i,x.innerHTML)?(Pe(x),!0):(W&&x.nodeType===wn.text&&(_=x.textContent,fi([ke,_e,Ke],Y=>{_=yn(_,Y," ")}),x.textContent!==_&&(mn(t.removed,{element:x.cloneNode()}),x.textContent=_)),qe(z.afterSanitizeElements,x,null),!1)},Xa=function(x,_,B){if(Ua&&(_==="id"||_==="name")&&(B in n||B in Lu))return!1;if(!(C&&!dn[_]&&ge(ms,_))){if(!(Zn&&ge(ys,_))){if(!(tt.attributeCheck instanceof Function&&tt.attributeCheck(_,x))){if(!ne[_]||dn[_]){if(!(Za(x)&&(X.tagNameCheck instanceof RegExp&&ge(X.tagNameCheck,x)||X.tagNameCheck instanceof Function&&X.tagNameCheck(x))&&(X.attributeNameCheck instanceof RegExp&&ge(X.attributeNameCheck,_)||X.attributeNameCheck instanceof Function&&X.attributeNameCheck(_,x))||_==="is"&&X.allowCustomizedBuiltInElements&&(X.tagNameCheck instanceof RegExp&&ge(X.tagNameCheck,B)||X.tagNameCheck instanceof Function&&X.tagNameCheck(B))))return!1}else if(!xs[_]){if(!ge(Jn,yn(B,Qn,""))){if(!((_==="src"||_==="xlink:href"||_==="href")&&x!=="script"&&rm(B,"data:")===0&&Ka[x])){if(!(I&&!ge(vs,yn(B,Qn,"")))){if(B)return!1}}}}}}}return!0},Za=function(x){return x!=="annotation-xml"&&zs(x,bs)},er=function(x){qe(z.beforeSanitizeAttributes,x,null);const{attributes:_}=x;if(!_||Cs(x))return;const B={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ne,forceKeepAttr:void 0};let Y=_.length;for(;Y--;){const de=_[Y],{name:se,namespaceURI:be,value:He}=de,Wt=oe(se),Es=He;let re=se==="value"?Es:lm(Es);if(B.attrName=Wt,B.attrValue=re,B.keepAttr=!0,B.forceKeepAttr=void 0,qe(z.uponSanitizeAttribute,x,B),re=B.attrValue,Wa&&(Wt==="id"||Wt==="name")&&(ht(se,x),re=Tu+re),Z&&ge(/((--!?|])>)|<\/(style|title|textarea)/i,re)){ht(se,x);continue}if(Wt==="attributename"&&zs(re,"href")){ht(se,x);continue}if(B.forceKeepAttr)continue;if(!B.keepAttr){ht(se,x);continue}if(!U&&ge(/\/>/i,re)){ht(se,x);continue}W&&fi([ke,_e,Ke],nr=>{re=yn(re,nr," ")});const tr=oe(x.nodeName);if(!Xa(tr,Wt,re)){ht(se,x);continue}if(A&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!be)switch(g.getAttributeType(tr,Wt)){case"TrustedHTML":{re=A.createHTML(re);break}case"TrustedScriptURL":{re=A.createScriptURL(re);break}}if(re!==Es)try{be?x.setAttributeNS(be,se,re):x.setAttribute(se,re),Cs(x)?Pe(x):Nr(t.removed)}catch{ht(se,x)}}qe(z.afterSanitizeAttributes,x,null)},Du=function N(x){let _=null;const B=Qa(x);for(qe(z.beforeSanitizeShadowDOM,x,null);_=B.nextNode();)qe(z.uponSanitizeShadowNode,_,null),Ya(_),er(_),_.content instanceof o&&N(_.content);qe(z.afterSanitizeShadowDOM,x,null)};return t.sanitize=function(N){let x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},_=null,B=null,Y=null,de=null;if($s=!N,$s&&(N="<!-->"),typeof N!="string"&&!Ja(N))if(typeof N.toString=="function"){if(N=N.toString(),typeof N!="string")throw vn("dirty is not a string, aborting")}else throw vn("toString is not a function");if(!t.isSupported)return N;if(fe||As(x),t.removed=[],typeof N=="string"&&(un=!1),un){if(N.nodeName){const He=oe(N.nodeName);if(!te[He]||pt[He])throw vn("root node is forbidden and cannot be sanitized in-place")}}else if(N instanceof r)_=Va("<!---->"),B=_.ownerDocument.importNode(N,!0),B.nodeType===wn.element&&B.nodeName==="BODY"||B.nodeName==="HTML"?_=B:_.appendChild(B);else{if(!Nt&&!W&&!J&&N.indexOf("<")===-1)return A&&ti?A.createHTML(N):N;if(_=Va(N),!_)return Nt?null:ti?E:""}_&&nt&&Pe(_.firstChild);const se=Qa(un?N:_);for(;Y=se.nextNode();)Ya(Y),er(Y),Y.content instanceof o&&Du(Y.content);if(un)return N;if(Nt){if(ei)for(de=R.call(_.ownerDocument);_.firstChild;)de.appendChild(_.firstChild);else de=_;return(ne.shadowroot||ne.shadowrootmode)&&(de=H.call(i,de,!0)),de}let be=J?_.outerHTML:_.innerHTML;return J&&te["!doctype"]&&_.ownerDocument&&_.ownerDocument.doctype&&_.ownerDocument.doctype.name&&ge(yd,_.ownerDocument.doctype.name)&&(be="<!DOCTYPE "+_.ownerDocument.doctype.name+`>
|
|
2593
|
+
`+be),W&&fi([ke,_e,Ke],He=>{be=yn(be,He," ")}),A&&ti?A.createHTML(be):be},t.setConfig=function(){let N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};As(N),fe=!0},t.clearConfig=function(){Ut=null,fe=!1},t.isValidAttribute=function(N,x,_){Ut||As({});const B=oe(N),Y=oe(x);return Xa(B,Y,_)},t.addHook=function(N,x){typeof x=="function"&&mn(z[N],x)},t.removeHook=function(N,x){if(x!==void 0){const _=om(z[N],x);return _===-1?void 0:am(z[N],_,1)[0]}return Nr(z[N])},t.removeHooks=function(N){z[N]=[]},t.removeAllHooks=function(){z=zr()},t}var Po=vd();function xa(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Dt=xa();function bd(e){Dt=e}var In={exec:()=>null};function j(e,t=""){let n=typeof e=="string"?e:e.source,i={replace:(s,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(me.caret,"$1"),n=n.replace(s,a),i},getRegex:()=>new RegExp(n,t)};return i}var $m=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),me={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")},Sm=/^(?:[ \t]*(?:\n|$))+/,Am=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Cm=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Gn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Em=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,$a=/(?:[*+-]|\d{1,9}[.)])/,wd=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,kd=j(wd).replace(/bull/g,$a).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(),Tm=j(wd).replace(/bull/g,$a).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(),Sa=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,_m=/^[^\n]+/,Aa=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Mm=j(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Aa).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Pm=j(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,$a).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",Ca=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Im=j("^ {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",Ca).replace("tag",ds).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),xd=j(Sa).replace("hr",Gn).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(),Lm=j(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",xd).getRegex(),Ea={blockquote:Lm,code:Am,def:Mm,fences:Cm,heading:Em,hr:Gn,html:Im,lheading:kd,list:Pm,newline:Sm,paragraph:xd,table:In,text:_m},qr=j("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Gn).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(),Rm={...Ea,lheading:Tm,table:qr,paragraph:j(Sa).replace("hr",Gn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",qr).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()},Dm={...Ea,html:j(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ca).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:In,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:j(Sa).replace("hr",Gn).replace("heading",` *#{1,6} *[^
|
|
2594
|
+
]`).replace("lheading",kd).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Bm=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Nm=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,$d=/^( {2,}|\\)\n(?!\s*$)/,Om=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,us=/[\p{P}\p{S}]/u,Ta=/[\s\p{P}\p{S}]/u,Sd=/[^\s\p{P}\p{S}]/u,Fm=j(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ta).getRegex(),Ad=/(?!~)[\p{P}\p{S}]/u,Um=/(?!~)[\s\p{P}\p{S}]/u,Wm=/(?:[^\s\p{P}\p{S}]|~)/u,Km=j(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",$m?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Cd=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,zm=j(Cd,"u").replace(/punct/g,us).getRegex(),qm=j(Cd,"u").replace(/punct/g,Ad).getRegex(),Ed="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Hm=j(Ed,"gu").replace(/notPunctSpace/g,Sd).replace(/punctSpace/g,Ta).replace(/punct/g,us).getRegex(),jm=j(Ed,"gu").replace(/notPunctSpace/g,Wm).replace(/punctSpace/g,Um).replace(/punct/g,Ad).getRegex(),Gm=j("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Sd).replace(/punctSpace/g,Ta).replace(/punct/g,us).getRegex(),Vm=j(/\\(punct)/,"gu").replace(/punct/g,us).getRegex(),Qm=j(/^<(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(),Jm=j(Ca).replace("(?:-->|$)","-->").getRegex(),Ym=j("^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",Jm).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),qi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Xm=j(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",qi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Td=j(/^!?\[(label)\]\[(ref)\]/).replace("label",qi).replace("ref",Aa).getRegex(),_d=j(/^!?\[(ref)\](?:\[\])?/).replace("ref",Aa).getRegex(),Zm=j("reflink|nolink(?!\\()","g").replace("reflink",Td).replace("nolink",_d).getRegex(),Hr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,_a={_backpedal:In,anyPunctuation:Vm,autolink:Qm,blockSkip:Km,br:$d,code:Nm,del:In,emStrongLDelim:zm,emStrongRDelimAst:Hm,emStrongRDelimUnd:Gm,escape:Bm,link:Xm,nolink:_d,punctuation:Fm,reflink:Td,reflinkSearch:Zm,tag:Ym,text:Om,url:In},ey={..._a,link:j(/^!?\[(label)\]\((.*?)\)/).replace("label",qi).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",qi).getRegex()},Io={..._a,emStrongRDelimAst:jm,emStrongLDelim:qm,url:j(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Hr).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:j(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Hr).getRegex()},ty={...Io,br:j($d).replace("{2,}","*").getRegex(),text:j(Io.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},mi={normal:Ea,gfm:Rm,pedantic:Dm},kn={normal:_a,gfm:Io,breaks:ty,pedantic:ey},ny={"&":"&","<":"<",">":">",'"':""","'":"'"},jr=e=>ny[e];function Ve(e,t){if(t){if(me.escapeTest.test(e))return e.replace(me.escapeReplace,jr)}else if(me.escapeTestNoEncode.test(e))return e.replace(me.escapeReplaceNoEncode,jr);return e}function Gr(e){try{e=encodeURI(e).replace(me.percentDecode,"%")}catch{return null}return e}function Vr(e,t){var o;let n=e.replace(me.findPipe,(a,r,l)=>{let c=!1,h=r;for(;--h>=0&&l[h]==="\\";)c=!c;return c?"|":" |"}),i=n.split(me.splitPipe),s=0;if(i[0].trim()||i.shift(),i.length>0&&!((o=i.at(-1))!=null&&o.trim())&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;s<i.length;s++)i[s]=i[s].trim().replace(me.slashPipe,"|");return i}function xn(e,t,n){let i=e.length;if(i===0)return"";let s=0;for(;s<i&&e.charAt(i-s-1)===t;)s++;return e.slice(0,i-s)}function iy(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let i=0;i<e.length;i++)if(e[i]==="\\")i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}function Qr(e,t,n,i,s){let o=t.href,a=t.title||null,r=e[1].replace(s.other.outputLinkReplace,"$1");i.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:a,text:r,tokens:i.inlineTokens(r)};return i.state.inLink=!1,l}function sy(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(i===null)return t;let s=i[1];return t.split(`
|
|
2582
2595
|
`).map(o=>{let a=o.match(n.other.beginningSpace);if(a===null)return o;let[r]=a;return r.length>=s.length?o.slice(s.length):o}).join(`
|
|
2583
|
-
`)}var Hi=class{constructor(e){q(this,"options");q(this,"rules");q(this,"lexer");this.options=e||Dt}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
|
|
2584
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],i=sy(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:i}}}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 i
|
|
2585
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n
|
|
2596
|
+
`)}var Hi=class{constructor(e){q(this,"options");q(this,"rules");q(this,"lexer");this.options=e||Dt}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:xn(n,`
|
|
2597
|
+
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],i=sy(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:i}}}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 i=xn(n,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(n=i.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:xn(t[0],`
|
|
2598
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=xn(t[0],`
|
|
2586
2599
|
`).split(`
|
|
2587
2600
|
`),i="",s="",o=[];for(;n.length>0;){let a=!1,r=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))r.push(n[l]),a=!0;else if(!a)r.push(n[l]);else break;n=n.slice(l);let c=r.join(`
|
|
2588
2601
|
`),h=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
2589
2602
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");i=i?`${i}
|
|
2590
2603
|
${c}`:c,s=s?`${s}
|
|
2591
|
-
${h}`:h;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,o,!0),this.lexer.state.top=d,n.length===0)break;let p=o.at(-1);if((p==null?void 0:p.type)==="code")break;if((p==null?void 0:p.type)==="blockquote"){let
|
|
2604
|
+
${h}`:h;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,o,!0),this.lexer.state.top=d,n.length===0)break;let p=o.at(-1);if((p==null?void 0:p.type)==="code")break;if((p==null?void 0:p.type)==="blockquote"){let g=p,$=g.raw+`
|
|
2592
2605
|
`+n.join(`
|
|
2593
|
-
`),
|
|
2606
|
+
`),S=this.blockquote($);o[o.length-1]=S,i=i.substring(0,i.length-g.raw.length)+S.raw,s=s.substring(0,s.length-g.text.length)+S.text;break}else if((p==null?void 0:p.type)==="list"){let g=p,$=g.raw+`
|
|
2594
2607
|
`+n.join(`
|
|
2595
|
-
`),
|
|
2596
|
-
`);continue}}return{type:"blockquote",raw:i,tokens:o,text:s}}}list(e){var n,i;let t=this.rules.block.list.exec(e);if(t){let s=t[1].trim(),o=s.length>1,a={type:"list",raw:"",ordered:o,start:o?+s.slice(0,-1):"",loose:!1,items:[]};s=o?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=o?s:"[*+-]");let r=this.rules.other.listItemRegex(s),l=!1;for(;e;){let h=!1,d="",p="";if(!(t=r.exec(e))||this.rules.block.hr.test(e))break;d=t[0],e=e.substring(d.length);let
|
|
2597
|
-
`,1)[0].replace(this.rules.other.listReplaceTabs,f=>" ".repeat(3*f.length))
|
|
2598
|
-
`,1)[0],
|
|
2599
|
-
`,e=e.substring(
|
|
2600
|
-
`,1)[0],P;if(
|
|
2601
|
-
`+P.slice(T);else{if(
|
|
2602
|
-
|
|
2603
|
-
`,e=e.substring(M.length+1),
|
|
2608
|
+
`),S=this.list($);o[o.length-1]=S,i=i.substring(0,i.length-p.raw.length)+S.raw,s=s.substring(0,s.length-g.raw.length)+S.raw,n=$.substring(o.at(-1).raw.length).split(`
|
|
2609
|
+
`);continue}}return{type:"blockquote",raw:i,tokens:o,text:s}}}list(e){var n,i;let t=this.rules.block.list.exec(e);if(t){let s=t[1].trim(),o=s.length>1,a={type:"list",raw:"",ordered:o,start:o?+s.slice(0,-1):"",loose:!1,items:[]};s=o?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=o?s:"[*+-]");let r=this.rules.other.listItemRegex(s),l=!1;for(;e;){let h=!1,d="",p="";if(!(t=r.exec(e))||this.rules.block.hr.test(e))break;d=t[0],e=e.substring(d.length);let g=t[2].split(`
|
|
2610
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,f=>" ".repeat(3*f.length)),$=e.split(`
|
|
2611
|
+
`,1)[0],S=!g.trim(),T=0;if(this.options.pedantic?(T=2,p=g.trimStart()):S?T=t[1].length+1:(T=t[2].search(this.rules.other.nonSpaceChar),T=T>4?1:T,p=g.slice(T),T+=t[1].length),S&&this.rules.other.blankLine.test($)&&(d+=$+`
|
|
2612
|
+
`,e=e.substring($.length+1),h=!0),!h){let f=this.rules.other.nextBulletRegex(T),b=this.rules.other.hrRegex(T),k=this.rules.other.fencesBeginRegex(T),A=this.rules.other.headingBeginRegex(T),E=this.rules.other.htmlBeginRegex(T);for(;e;){let M=e.split(`
|
|
2613
|
+
`,1)[0],P;if($=M,this.options.pedantic?($=$.replace(this.rules.other.listReplaceNesting," "),P=$):P=$.replace(this.rules.other.tabCharGlobal," "),k.test($)||A.test($)||E.test($)||f.test($)||b.test($))break;if(P.search(this.rules.other.nonSpaceChar)>=T||!$.trim())p+=`
|
|
2614
|
+
`+P.slice(T);else{if(S||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||k.test(g)||A.test(g)||b.test(g))break;p+=`
|
|
2615
|
+
`+$}!S&&!$.trim()&&(S=!0),d+=M+`
|
|
2616
|
+
`,e=e.substring(M.length+1),g=P.slice(T)}}a.loose||(l?a.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(l=!0)),a.items.push({type:"list_item",raw:d,task:!!this.options.gfm&&this.rules.other.listIsTask.test(p),loose:!1,text:p,tokens:[]}),a.raw+=d}let c=a.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;a.raw=a.raw.trimEnd();for(let h of a.items){if(this.lexer.state.top=!1,h.tokens=this.lexer.blockTokens(h.text,[]),h.task){if(h.text=h.text.replace(this.rules.other.listReplaceTask,""),((n=h.tokens[0])==null?void 0:n.type)==="text"||((i=h.tokens[0])==null?void 0:i.type)==="paragraph"){h.tokens[0].raw=h.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),h.tokens[0].text=h.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let p=this.lexer.inlineQueue.length-1;p>=0;p--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[p].src)){this.lexer.inlineQueue[p].src=this.lexer.inlineQueue[p].src.replace(this.rules.other.listReplaceTask,"");break}}let d=this.rules.other.listTaskCheckbox.exec(h.raw);if(d){let p={type:"checkbox",raw:d[0]+" ",checked:d[0]!=="[ ]"};h.checked=p.checked,a.loose?h.tokens[0]&&["paragraph","text"].includes(h.tokens[0].type)&&"tokens"in h.tokens[0]&&h.tokens[0].tokens?(h.tokens[0].raw=p.raw+h.tokens[0].raw,h.tokens[0].text=p.raw+h.tokens[0].text,h.tokens[0].tokens.unshift(p)):h.tokens.unshift({type:"paragraph",raw:p.raw,text:p.raw,tokens:[p]}):h.tokens.unshift(p)}}if(!a.loose){let d=h.tokens.filter(g=>g.type==="space"),p=d.length>0&&d.some(g=>this.rules.other.anyLine.test(g.raw));a.loose=p}}if(a.loose)for(let h of a.items){h.loose=!0;for(let d of h.tokens)d.type==="text"&&(d.type="paragraph")}return a}}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," "),i=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=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:i,title:s}}}table(e){var a;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Vr(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(a=t[3])!=null&&a.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
2604
2617
|
`):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(let r of i)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 s)o.rows.push(Vr(r,o.header.length).map((l,c)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:o.align[c]})));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)===`
|
|
2605
|
-
`?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
|
|
2618
|
+
`?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=xn(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=iy(t[2],"()");if(o===-2)return;if(o>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let i=t[2],s="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(i);o&&(i=o[1],s=o[3])}else s=t[3]?t[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?i=i.slice(1):i=i.slice(1,-1)),Qr(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.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 i=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=t[i.toLowerCase()];if(!s){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return Qr(n,s,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[2])||!n||this.rules.inline.punctuation.exec(n))){let s=[...i[0]].length-1,o,a,r=s,l=0,c=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+s);(i=c.exec(t))!=null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o)continue;if(a=[...o].length,i[3]||i[4]){r+=a;continue}else if((i[5]||i[6])&&s%3&&!((s+a)%3)){l+=a;continue}if(r-=a,r>0)continue;a=Math.min(a,a+r+l);let h=[...i[0]][0].length,d=e.slice(0,s+i.index+h+a);if(Math.min(s,a)%2){let g=d.slice(1,-1);return{type:"em",raw:d,text:g,tokens:this.lexer.inlineTokens(g)}}let p=d.slice(2,-2);return{type:"strong",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return i&&s&&(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,i;return t[2]==="@"?(n=t[1],i="mailto:"+n):(n=t[1],i=n),{type:"link",raw:t[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let i,s;if(t[2]==="@")i=t[0],s="mailto:"+i;else{let o;do o=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(o!==t[0]);i=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}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}}}},Ae=class Lo{constructor(t){q(this,"tokens");q(this,"options");q(this,"state");q(this,"inlineQueue");q(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Dt,this.options.tokenizer=this.options.tokenizer||new Hi,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:me,block:mi.normal,inline:kn.normal};this.options.pedantic?(n.block=mi.pedantic,n.inline=kn.pedantic):this.options.gfm&&(n.block=mi.gfm,this.options.breaks?n.inline=kn.breaks:n.inline=kn.gfm),this.tokenizer.rules=n}static get rules(){return{block:mi,inline:kn}}static lex(t,n){return new Lo(n).lex(t)}static lexInline(t,n){return new Lo(n).inlineTokens(t)}lex(t){t=t.replace(me.carriageReturn,`
|
|
2606
2619
|
`),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let i=this.inlineQueue[n];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],i=!1){var s,o,a;for(this.options.pedantic&&(t=t.replace(me.tabCharGlobal," ").replace(me.spaceLine,""));t;){let r;if((o=(s=this.options.extensions)==null?void 0:s.block)!=null&&o.some(c=>(r=c.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))continue;if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length);let c=n.at(-1);r.raw.length===1&&c!==void 0?c.raw+=`
|
|
2607
2620
|
`:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
2608
2621
|
`)?"":`
|
|
@@ -2616,7 +2629,7 @@ ${h}`:h;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
2616
2629
|
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(r),i=l.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
2617
2630
|
`)?"":`
|
|
2618
2631
|
`)+r.raw,c.text+=`
|
|
2619
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(r);continue}if(t){let c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var l,c,h,d,p;let i=t,s=null;if(this.tokens.links){let
|
|
2632
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(r);continue}if(t){let c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var l,c,h,d,p;let i=t,s=null;if(this.tokens.links){let g=Object.keys(this.tokens.links);if(g.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)g.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,s.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)o=s[2]?s[2].length:0,i=i.slice(0,s.index+o)+"["+"a".repeat(s[0].length-o-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=((c=(l=this.options.hooks)==null?void 0:l.emStrongMask)==null?void 0:c.call({lexer:this},i))??i;let a=!1,r="";for(;t;){a||(r=""),a=!1;let g;if((d=(h=this.options.extensions)==null?void 0:h.inline)!=null&&d.some(S=>(g=S.call({lexer:this},t,n))?(t=t.substring(g.raw.length),n.push(g),!0):!1))continue;if(g=this.tokenizer.escape(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.tag(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.link(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(g.raw.length);let S=n.at(-1);g.type==="text"&&(S==null?void 0:S.type)==="text"?(S.raw+=g.raw,S.text+=g.text):n.push(g);continue}if(g=this.tokenizer.emStrong(t,i,r)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.codespan(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.br(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.del(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.autolink(t)){t=t.substring(g.raw.length),n.push(g);continue}if(!this.state.inLink&&(g=this.tokenizer.url(t))){t=t.substring(g.raw.length),n.push(g);continue}let $=t;if((p=this.options.extensions)!=null&&p.startInline){let S=1/0,T=t.slice(1),f;this.options.extensions.startInline.forEach(b=>{f=b.call({lexer:this},T),typeof f=="number"&&f>=0&&(S=Math.min(S,f))}),S<1/0&&S>=0&&($=t.substring(0,S+1))}if(g=this.tokenizer.inlineText($)){t=t.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(r=g.raw.slice(-1)),a=!0;let S=n.at(-1);(S==null?void 0:S.type)==="text"?(S.raw+=g.raw,S.text+=g.text):n.push(g);continue}if(t){let S="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(S);break}else throw new Error(S)}}return n}},ji=class{constructor(e){q(this,"options");q(this,"parser");this.options=e||Dt}space(e){return""}code({text:e,lang:t,escaped:n}){var o;let i=(o=(t||"").match(me.notSpaceStart))==null?void 0:o[0],s=e.replace(me.endingNewline,"")+`
|
|
2620
2633
|
`;return i?'<pre><code class="language-'+Ve(i)+'">'+(n?s:Ve(s,!0))+`</code></pre>
|
|
2621
2634
|
`:"<pre><code>"+(n?s:Ve(s,!0))+`</code></pre>
|
|
2622
2635
|
`}blockquote({tokens:e}){return`<blockquote>
|
|
@@ -2634,8 +2647,8 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
2634
2647
|
`}tablerow({text:e}){return`<tr>
|
|
2635
2648
|
${e}</tr>
|
|
2636
2649
|
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
2637
|
-
`}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>${Ve(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 i=this.parser.parseInline(n),s=Gr(e);if(s===null)return i;e=s;let o='<a href="'+e+'"';return t&&(o+=' title="'+Ve(t)+'"'),o+=">"+i+"</a>",o}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let s=Gr(e);if(s===null)return Ve(n);e=s;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${Ve(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Ve(e.text)}},Ma=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}},Ce=class Ro{constructor(t){q(this,"options");q(this,"renderer");q(this,"textRenderer");this.options=t||Dt,this.options.renderer=this.options.renderer||new ji,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ma}static parse(t,n){return new Ro(n).parse(t)}static parseInline(t,n){return new Ro(n).parseInline(t)}parse(t){var i,s;let n="";for(let o=0;o<t.length;o++){let a=t[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let l=a,c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){n+=c||"";continue}}let r=a;switch(r.type){case"space":{n+=this.renderer.space(r);break}case"hr":{n+=this.renderer.hr(r);break}case"heading":{n+=this.renderer.heading(r);break}case"code":{n+=this.renderer.code(r);break}case"table":{n+=this.renderer.table(r);break}case"blockquote":{n+=this.renderer.blockquote(r);break}case"list":{n+=this.renderer.list(r);break}case"checkbox":{n+=this.renderer.checkbox(r);break}case"html":{n+=this.renderer.html(r);break}case"def":{n+=this.renderer.def(r);break}case"paragraph":{n+=this.renderer.paragraph(r);break}case"text":{n+=this.renderer.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 n}parseInline(t,n=this.renderer){var s,o;let i="";for(let a=0;a<t.length;a++){let r=t[a];if((o=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&o[r.type]){let c=this.options.extensions.renderers[r.type].call({parser:this},r);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){i+=c||"";continue}}let l=r;switch(l.type){case"escape":{i+=n.text(l);break}case"html":{i+=n.html(l);break}case"link":{i+=n.link(l);break}case"image":{i+=n.image(l);break}case"checkbox":{i+=n.checkbox(l);break}case"strong":{i+=n.strong(l);break}case"em":{i+=n.em(l);break}case"codespan":{i+=n.codespan(l);break}case"br":{i+=n.br(l);break}case"del":{i+=n.del(l);break}case"text":{i+=n.text(l);break}default:{let c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return i}},
|
|
2638
|
-
Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+Ve(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}}},Pt=new oy;function V(e,t){return Pt.parse(e,t)}V.options=V.setOptions=function(e){return Pt.setOptions(e),V.defaults=Pt.defaults,bd(V.defaults),V};V.getDefaults
|
|
2650
|
+
`}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>${Ve(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 i=this.parser.parseInline(n),s=Gr(e);if(s===null)return i;e=s;let o='<a href="'+e+'"';return t&&(o+=' title="'+Ve(t)+'"'),o+=">"+i+"</a>",o}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let s=Gr(e);if(s===null)return Ve(n);e=s;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${Ve(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Ve(e.text)}},Ma=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}},Ce=class Ro{constructor(t){q(this,"options");q(this,"renderer");q(this,"textRenderer");this.options=t||Dt,this.options.renderer=this.options.renderer||new ji,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ma}static parse(t,n){return new Ro(n).parse(t)}static parseInline(t,n){return new Ro(n).parseInline(t)}parse(t){var i,s;let n="";for(let o=0;o<t.length;o++){let a=t[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[a.type]){let l=a,c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){n+=c||"";continue}}let r=a;switch(r.type){case"space":{n+=this.renderer.space(r);break}case"hr":{n+=this.renderer.hr(r);break}case"heading":{n+=this.renderer.heading(r);break}case"code":{n+=this.renderer.code(r);break}case"table":{n+=this.renderer.table(r);break}case"blockquote":{n+=this.renderer.blockquote(r);break}case"list":{n+=this.renderer.list(r);break}case"checkbox":{n+=this.renderer.checkbox(r);break}case"html":{n+=this.renderer.html(r);break}case"def":{n+=this.renderer.def(r);break}case"paragraph":{n+=this.renderer.paragraph(r);break}case"text":{n+=this.renderer.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 n}parseInline(t,n=this.renderer){var s,o;let i="";for(let a=0;a<t.length;a++){let r=t[a];if((o=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&o[r.type]){let c=this.options.extensions.renderers[r.type].call({parser:this},r);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){i+=c||"";continue}}let l=r;switch(l.type){case"escape":{i+=n.text(l);break}case"html":{i+=n.html(l);break}case"link":{i+=n.link(l);break}case"image":{i+=n.image(l);break}case"checkbox":{i+=n.checkbox(l);break}case"strong":{i+=n.strong(l);break}case"em":{i+=n.em(l);break}case"codespan":{i+=n.codespan(l);break}case"br":{i+=n.br(l);break}case"del":{i+=n.del(l);break}case"text":{i+=n.text(l);break}default:{let c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return i}},$i,An=($i=class{constructor(e){q(this,"options");q(this,"block");this.options=e||Dt}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Ae.lex:Ae.lexInline}provideParser(){return this.block?Ce.parse:Ce.parseInline}},q($i,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),q($i,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),$i),oy=class{constructor(...e){q(this,"defaults",xa());q(this,"options",this.setOptions);q(this,"parse",this.parseMarkdown(!0));q(this,"parseInline",this.parseMarkdown(!1));q(this,"Parser",Ce);q(this,"Renderer",ji);q(this,"TextRenderer",Ma);q(this,"Lexer",Ae);q(this,"Tokenizer",Hi);q(this,"Hooks",An);this.use(...e)}walkTokens(e,t){var i,s;let n=[];for(let o of e)switch(n=n.concat(t.call(this,o)),o.type){case"table":{let a=o;for(let r of a.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of a.rows)for(let l of r)n=n.concat(this.walkTokens(l.tokens,t));break}case"list":{let a=o;n=n.concat(this.walkTokens(a.items,t));break}default:{let a=o;(s=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&s[a.type]?this.defaults.extensions.childTokens[a.type].forEach(r=>{let l=a[r].flat(1/0);n=n.concat(this.walkTokens(l,t))}):a.tokens&&(n=n.concat(this.walkTokens(a.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let i={...n};if(i.async=this.defaults.async||i.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let o=t.renderers[s.name];o?t.renderers[s.name]=function(...a){let r=s.renderer.apply(this,a);return r===!1&&(r=o.apply(this,a)),r}:t.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[s.level];o?o.unshift(s.tokenizer):t[s.level]=[s.tokenizer],s.start&&(s.level==="block"?t.startBlock?t.startBlock.push(s.start):t.startBlock=[s.start]:s.level==="inline"&&(t.startInline?t.startInline.push(s.start):t.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(t.childTokens[s.name]=s.childTokens)}),i.extensions=t),n.renderer){let s=this.defaults.renderer||new ji(this.defaults);for(let o in n.renderer){if(!(o in s))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let a=o,r=n.renderer[a],l=s[a];s[a]=(...c)=>{let h=r.apply(s,c);return h===!1&&(h=l.apply(s,c)),h||""}}i.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new Hi(this.defaults);for(let o in n.tokenizer){if(!(o in s))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let a=o,r=n.tokenizer[a],l=s[a];s[a]=(...c)=>{let h=r.apply(s,c);return h===!1&&(h=l.apply(s,c)),h}}i.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new An;for(let o in n.hooks){if(!(o in s))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let a=o,r=n.hooks[a],l=s[a];An.passThroughHooks.has(o)?s[a]=c=>{if(this.defaults.async&&An.passThroughHooksRespectAsync.has(o))return(async()=>{let d=await r.call(s,c);return l.call(s,d)})();let h=r.call(s,c);return l.call(s,h)}:s[a]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await r.apply(s,c);return d===!1&&(d=await l.apply(s,c)),d})();let h=r.apply(s,c);return h===!1&&(h=l.apply(s,c)),h}}i.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,o=n.walkTokens;i.walkTokens=function(a){let r=[];return r.push(o.call(this,a)),s&&(r=r.concat(s.call(this,a))),r}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ae.lex(e,t??this.defaults)}parser(e,t){return Ce.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},s={...this.defaults,...i},o=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&i.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(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let a=s.hooks?await s.hooks.preprocess(t):t,r=await(s.hooks?await s.hooks.provideLexer():e?Ae.lex:Ae.lexInline)(a,s),l=s.hooks?await s.hooks.processAllTokens(r):r;s.walkTokens&&await Promise.all(this.walkTokens(l,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser():e?Ce.parse:Ce.parseInline)(l,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(o);try{s.hooks&&(t=s.hooks.preprocess(t));let a=(s.hooks?s.hooks.provideLexer():e?Ae.lex:Ae.lexInline)(t,s);s.hooks&&(a=s.hooks.processAllTokens(a)),s.walkTokens&&this.walkTokens(a,s.walkTokens);let r=(s.hooks?s.hooks.provideParser():e?Ce.parse:Ce.parseInline)(a,s);return s.hooks&&(r=s.hooks.postprocess(r)),r}catch(a){return o(a)}}}onError(e,t){return n=>{if(n.message+=`
|
|
2651
|
+
Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+Ve(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}}},Pt=new oy;function V(e,t){return Pt.parse(e,t)}V.options=V.setOptions=function(e){return Pt.setOptions(e),V.defaults=Pt.defaults,bd(V.defaults),V};V.getDefaults=xa;V.defaults=Dt;V.use=function(...e){return Pt.use(...e),V.defaults=Pt.defaults,bd(V.defaults),V};V.walkTokens=function(e,t){return Pt.walkTokens(e,t)};V.parseInline=Pt.parseInline;V.Parser=Ce;V.parser=Ce.parse;V.Renderer=ji;V.TextRenderer=Ma;V.Lexer=Ae;V.lexer=Ae.lex;V.Tokenizer=Hi;V.Hooks=An;V.parse=V;V.options;V.setOptions;V.use;V.walkTokens;V.parseInline;Ce.parse;Ae.lex;V.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"],Yr=["class","href","rel","target","title","start"];let Xr=!1;const ay=14e4,ry=4e4,ly=200,Vs=5e4,kt=new Map;function cy(e){const t=kt.get(e);return t===void 0?null:(kt.delete(e),kt.set(e,t),t)}function Zr(e,t){if(kt.set(e,t),kt.size<=ly)return;const n=kt.keys().next().value;n&&kt.delete(n)}function dy(){Xr||(Xr=!0,Po.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function Gi(e){const t=e.trim();if(!t)return"";if(dy(),t.length<=Vs){const a=cy(t);if(a!==null)return a}const n=Vl(t,ay),i=n.truncated?`
|
|
2639
2652
|
|
|
2640
2653
|
… truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>ry){const r=`<pre class="code-block">${uy(`${n.text}${i}`)}</pre>`,l=Po.sanitize(r,{ALLOWED_TAGS:Jr,ALLOWED_ATTR:Yr});return t.length<=Vs&&Zr(t,l),l}const s=V.parse(`${n.text}${i}`),o=Po.sanitize(s,{ALLOWED_TAGS:Jr,ALLOWED_ATTR:Yr});return t.length<=Vs&&Zr(t,o),o}function uy(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const py=1500,hy=2e3,Md="Copy as markdown",fy="Copied",gy="Copy failed";async function my(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 yi(e,t){e.title=t,e.setAttribute("aria-label",t)}function yy(e){const t=e.label??Md;return u`
|
|
2641
2654
|
<button
|
|
@@ -2650,7 +2663,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
|
|
|
2650
2663
|
<span class="chat-copy-btn__icon-check">${L.check}</span>
|
|
2651
2664
|
</span>
|
|
2652
2665
|
</button>
|
|
2653
|
-
`}function vy(e){return yy({text:()=>e,label:Md})}function by(e){const t=e,n=wy(t.content),i=[];for(const s of n){const o=String(s.type??"").toLowerCase();(["toolcall","tool_call","tooluse","tool_use"].includes(o)||typeof s.name=="string"&&s.arguments!=null)&&i.push({kind:"call",name:s.name??"tool",args:ky(s.arguments??s.args)})}for(const s of n){const o=String(s.type??"").toLowerCase();if(o!=="toolresult"&&o!=="tool_result")continue;const a
|
|
2666
|
+
`}function vy(e){return yy({text:()=>e,label:Md})}function by(e){const t=e,n=wy(t.content),i=[];for(const s of n){const o=String(s.type??"").toLowerCase();(["toolcall","tool_call","tooluse","tool_use"].includes(o)||typeof s.name=="string"&&s.arguments!=null)&&i.push({kind:"call",name:s.name??"tool",args:ky(s.arguments??s.args)})}for(const s of n){const o=String(s.type??"").toLowerCase();if(o!=="toolresult"&&o!=="tool_result")continue;const a=xy(s),r=typeof s.name=="string"?s.name:"tool";i.push({kind:"result",name:r,text:a})}if(Zl(e)&&!i.some(s=>s.kind==="result")){const s=typeof t.toolName=="string"&&t.toolName||typeof t.tool_name=="string"&&t.tool_name||"tool",o=Ql(e)??void 0;i.push({kind:"result",name:s,text:o})}return i}function wy(e){return Array.isArray(e)?e.filter(Boolean):[]}function ky(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 xy(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}const Qs=40,Js=new Map;async function $y(e){const t=Js.get(e);if(t)return t;try{const n=new(window.AudioContext||window.webkitAudioContext),s=await(await fetch(e)).arrayBuffer(),a=(await n.decodeAudioData(s)).getChannelData(0),r=Math.floor(a.length/Qs),l=[];for(let d=0;d<Qs;d++){let p=0;const g=d*r,$=Math.min(g+r,a.length);for(let S=g;S<$;S++){const T=Math.abs(a[S]);T>p&&(p=T)}l.push(p)}const c=Math.max(...l,.01),h=l.map(d=>Math.max(d/c,.08));return Js.set(e,h),n.close(),h}catch{const n=Array.from(e).reduce((s,o)=>(s<<5)-s+o.charCodeAt(0)|0,0),i=[];for(let s=0;s<Qs;s++){const o=Math.abs((n*(s+1)*9301+49297)%233280/233280);i.push(.15+o*.85)}return Js.set(e,i),i}}const Ys=[1,1.5,2],Vi=new Map;function Sy(e){let t=Vi.get(e);if(t)return t;const n=new Audio;return n.preload="metadata",n.src=e,t={audio:n,playing:!1,currentTime:0,duration:0,speed:1,waveform:[]},Vi.set(e,t),$y(e).then(i=>{t.waveform=i,Pd(e)}),t}const Ln="http://www.w3.org/2000/svg";function Ay(){const e=document.createElementNS(Ln,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor");const t=document.createElementNS(Ln,"polygon");return t.setAttribute("points","6,3 20,12 6,21"),e.appendChild(t),e}function Cy(){const e=document.createElementNS(Ln,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor");const t=document.createElementNS(Ln,"rect");t.setAttribute("x","5"),t.setAttribute("y","3"),t.setAttribute("width","4"),t.setAttribute("height","18"),t.setAttribute("rx","1");const n=document.createElementNS(Ln,"rect");return n.setAttribute("x","15"),n.setAttribute("y","3"),n.setAttribute("width","4"),n.setAttribute("height","18"),n.setAttribute("rx","1"),e.append(t,n),e}function Ht(e){return document.querySelector(`.vnp[data-url="${CSS.escape(e)}"]`)}function Pd(e){const t=Ht(e);if(!t)return;const n=Vi.get(e);if(!n||n.waveform.length===0)return;const i=t.querySelector(".vnp__waveform");if(i){if(i.children.length===0){const s=document.createDocumentFragment();for(const o of n.waveform){const a=document.createElement("span");a.className="vnp__bar",a.style.height=`${Math.round(o*100)}%`,s.appendChild(a)}i.appendChild(s)}Rn(t,n)}}function Rn(e,t){const n=t.duration>0?t.currentTime/t.duration:0,i=e.querySelectorAll(".vnp__bar"),s=i.length;i.forEach((a,r)=>{a.classList.toggle("vnp__bar--active",r/s<n)});const o=e.querySelector(".vnp__time");o&&(o.textContent=t.playing||t.currentTime>0?Qi(t.currentTime):Qi(t.duration))}function Xs(e,t){const n=e.querySelector(".vnp__play");if(!n)return;const i=n.querySelector("svg"),s=t?Cy():Ay();i?n.replaceChild(s,i):n.appendChild(s)}function Qi(e){if(!isFinite(e)||e<0)return"0:00";const t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${n.toString().padStart(2,"0")}`}const el=new Set;function Ey(e){if(el.has(e))return;el.add(e);const t=Vi.get(e);if(!t)return;const{audio:n}=t;n.addEventListener("loadedmetadata",()=>{t.duration=n.duration;const i=Ht(e);i&&Rn(i,t)}),n.addEventListener("timeupdate",()=>{t.currentTime=n.currentTime;const i=Ht(e);i&&Rn(i,t)}),n.addEventListener("ended",()=>{t.playing=!1,n.currentTime=0,t.currentTime=0;const i=Ht(e);i&&(Rn(i,t),Xs(i,!1))}),n.addEventListener("pause",()=>{t.playing=!1;const i=Ht(e);i&&Xs(i,!1)}),n.addEventListener("play",()=>{t.playing=!0;const i=Ht(e);i&&Xs(i,!0)})}function Ty(e,t){const n=Sy(e);Ey(e);const i=r=>{r.stopPropagation(),n.playing?n.audio.pause():n.audio.play()},s=r=>{r.stopPropagation();const l=Ys.indexOf(n.speed),c=Ys[(l+1)%Ys.length];n.speed=c,n.audio.playbackRate=c;const h=r.target.closest(".vnp__speed");h&&(h.textContent=`${c}×`)},o=r=>{r.stopPropagation();const l=r.target.closest(".vnp__waveform");if(!l)return;const c=l.getBoundingClientRect(),h=Math.max(0,Math.min(1,(r.clientX-c.left)/c.width));if(n.duration>0){n.audio.currentTime=h*n.duration,n.currentTime=n.audio.currentTime;const d=l.closest(".vnp");d&&Rn(d,n)}},a=n.playing||n.currentTime>0?Qi(n.currentTime):Qi(n.duration);return queueMicrotask(()=>Pd(e)),u`
|
|
2654
2667
|
<div class="vnp" data-url=${e} @click=${r=>r.stopPropagation()}>
|
|
2655
2668
|
<button class="vnp__play" @click=${i} aria-label=${n.playing?"Pause":"Play"}>
|
|
2656
2669
|
${n.playing?My():_y()}
|
|
@@ -2739,12 +2752,12 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
|
|
|
2739
2752
|
<span class="chat-file-card__icon">${Ly(e.mimeType)}</span>
|
|
2740
2753
|
<span class="chat-file-card__name">${e.name}</span>
|
|
2741
2754
|
</a>
|
|
2742
|
-
`}function Id(e,t,n){const i=e,s=typeof i.role=="string"?i.role:"unknown",o=Zl(e)||s.toLowerCase()==="toolresult"||s.toLowerCase()==="tool_result"||typeof i.toolCallId=="string"||typeof i.tool_call_id=="string",r=by(e).length>0,l=Py(e),c=l.length>0,h=Iy(e),d=h.length>0,p=Ql(e),
|
|
2755
|
+
`}function Id(e,t,n){const i=e,s=typeof i.role=="string"?i.role:"unknown",o=Zl(e)||s.toLowerCase()==="toolresult"||s.toLowerCase()==="tool_result"||typeof i.toolCallId=="string"||typeof i.tool_call_id=="string",r=by(e).length>0,l=Py(e),c=l.length>0,h=Iy(e),d=h.length>0,p=Ql(e),g=t.showReasoning&&s==="assistant"?Mp(e):null,$=p!=null&&p.trim()?p:null,S=g?Ip(g):null,T=$,f=(s==="assistant"||s==="user")&&!!(T!=null&&T.trim()),b=["chat-bubble",f?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!T&&(r||o)||!T&&!c&&!d?w:u`
|
|
2743
2756
|
<div class="${b}">
|
|
2744
2757
|
${f?vy(T):w}
|
|
2745
2758
|
${Oy(l)}
|
|
2746
2759
|
${Fy(h)}
|
|
2747
|
-
${
|
|
2760
|
+
${S?u`<div class="chat-thinking">${zi(Gi(S))}</div>`:w}
|
|
2748
2761
|
${T?u`<div class="chat-text">${zi(Gi(T))}</div>`:w}
|
|
2749
2762
|
</div>
|
|
2750
2763
|
`}const O={active:!1,mode:"tap",startTime:0,elapsed:0,mediaRecorder:null,audioChunks:[],stream:null,timerId:null,startX:0,cancelled:!1};let G=null,St=null,At=!1;function tl(e){const t=Math.floor(e/60),n=e%60;return`${t}:${n.toString().padStart(2,"0")}`}function vt(){if(O.timerId&&(clearInterval(O.timerId),O.timerId=null),O.stream){for(const e of O.stream.getTracks())e.stop();O.stream=null}St&&(clearTimeout(St),St=null),Ji(),O.mediaRecorder=null,O.audioChunks=[],O.active=!1,O.cancelled=!1,At=!1}async function Ld(e){var t;try{if(!((t=navigator.mediaDevices)!=null&&t.getUserMedia))return console.warn("[voice] getUserMedia unavailable (requires secure context)"),vt(),!1;const n=await navigator.mediaDevices.getUserMedia({audio:!0});O.stream=n;const i=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":MediaRecorder.isTypeSupported("audio/mp4")?"audio/mp4":"",s=i?new MediaRecorder(n,{mimeType:i}):new MediaRecorder(n);return O.mediaRecorder=s,O.audioChunks=[],O.mode=e,O.startTime=Date.now(),O.elapsed=0,O.active=!0,O.cancelled=!1,s.ondataavailable=o=>{o.data.size>0&&O.audioChunks.push(o.data)},s.onstop=()=>{if(O.cancelled){vt(),G==null||G.onRequestRender();return}const o=new Blob(O.audioChunks,{type:s.mimeType});if(o.size===0){vt(),G==null||G.onRequestRender();return}const a=new FileReader;a.onload=()=>{const r=a.result,l=s.mimeType.includes("mp4")?"m4a":"webm",c={id:os(),dataUrl:r,mimeType:s.mimeType||"audio/webm",fileName:`voice-note-${Date.now()}.${l}`};vt(),G==null||G.onSend(c),G==null||G.onRequestRender()},a.onerror=()=>{vt(),G==null||G.onRequestRender()},a.readAsDataURL(o)},s.start(250),O.timerId=setInterval(()=>{O.elapsed=Math.floor((Date.now()-O.startTime)/1e3),G==null||G.onRequestRender()},1e3),G==null||G.onRequestRender(),!0}catch(n){return console.warn("[voice] startRecording failed:",n),vt(),!1}}function Rd(){!O.active||!O.mediaRecorder||(O.cancelled=!1,O.mediaRecorder.state==="recording"&&O.mediaRecorder.stop())}function Dd(){!O.active||!O.mediaRecorder||(O.cancelled=!0,O.mediaRecorder.state==="recording"?O.mediaRecorder.stop():(vt(),G==null||G.onRequestRender()))}function zy(){document.addEventListener("pointerup",Bd)}function Ji(){document.removeEventListener("pointerup",Bd)}function Bd(e){if(!At&&!O.active){Ji();return}if(At=!1,Ji(),St&&(clearTimeout(St),St=null,!O.active)){Ld("tap");return}O.active&&O.mode==="hold"&&(O.cancelled?Dd():Rd()),e.preventDefault()}function qy(e){O.active||(At=!0,O.startX=e.clientX,zy(),St=setTimeout(async()=>{if(!At)return;await Ld("hold")||(At=!1,Ji())},300))}function nl(e){if(!O.active||O.mode!=="hold"||!At)return;const t=O.startX-e.clientX;t>80?(O.cancelled=!0,G==null||G.onRequestRender()):O.cancelled&&t<=60&&(O.cancelled=!1,G==null||G.onRequestRender())}function Hy(){return O.active}function jy(e){G=e}function Gy(e){return u`
|
|
@@ -2833,13 +2846,13 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
|
|
|
2833
2846
|
:host(.dragging) {
|
|
2834
2847
|
background: var(--accent, #007bff);
|
|
2835
2848
|
}
|
|
2836
|
-
`;ps([is({type:Number})],Yt.prototype,"splitRatio",2);ps([is({type:Number})],Yt.prototype,"minRatio",2);ps([is({type:Number})],Yt.prototype,"maxRatio",2);Yt=ps([Wl("resizable-divider")],Yt);function vi(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function Zs(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const Xy=1,Zy=1,Bt="emoji",Xt="keyvalue",Pa="favorites",ev="tokens",Nd="tokens",tv="unicode",Od="count",nv="group",iv="order",Fd="group-order",Do="eTag",Yi="url",il="skinTone",ln="readonly",Ia="readwrite",Ud="skinUnicodes",sv="skinUnicodes",ov="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",av="en";function rv(e,t){const n=new Set,i=[];for(const s of e){const o=t(s);n.has(o)||(n.add(o),i.push(s))}return i}function sl(e){return rv(e,t=>t.unicode)}function lv(e){function t(n,i,s){const o=i?e.createObjectStore(n,{keyPath:i}):e.createObjectStore(n);if(s)for(const[a,[r,l]]of Object.entries(s))o.createIndex(a,r,{multiEntry:l});return o}t(Xt),t(Bt,tv,{[Nd]:[ev,!0],[Fd]:[[nv,iv]],[Ud]:[sv,!0]}),t(Pa,void 0,{[Od]:[""]})}const Bo={},Ei={},Xi={};function Wd(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function cv(e){const t=await new Promise((n,i)=>{const s=indexedDB.open(e,Xy);Bo[e]=s,s.onupgradeneeded=o=>{o.oldVersion<Zy&&lv(s.result)},Wd(n,i,s)});return t.onclose=()=>La(e),t}function dv(e){return Ei[e]||(Ei[e]=cv(e)),Ei[e]}function et(e,t,n,i){return new Promise((s,o)=>{const a=e.transaction(t,n,{durability:"relaxed"}),r=typeof t=="string"?a.objectStore(t):t.map(c=>a.objectStore(c));let l;i(r,a,c=>{l=c}),a.oncomplete=()=>s(l),a.onerror=()=>o(a.error)})}function La(e){const t=Bo[e],n=t&&t.result;if(n){n.close();const i=Xi[e];if(i)for(const s of i)s()}delete Bo[e],delete Ei[e],delete Xi[e]}function uv(e){return new Promise((t,n)=>{La(e);const i=indexedDB.deleteDatabase(e);Wd(t,n,i)})}function pv(e,t){let n=Xi[e];n||(n=Xi[e]=[]),n.push(t)}const hv=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 Qt(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||hv.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const fv=2;function Kd(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=fv)}function gv(e){return e.map(({annotation:n,emoticon:i,group:s,order:o,shortcodes:a,skins:r,tags:l,emoji:c,version:h})=>{const d=[...new Set(Kd([...(a||[]).map(Qt).flat(),...(l||[]).map(Qt).flat(),...Qt(n),i]))].sort(),p={annotation:n,group:s,order:o,tags:l,tokens:d,unicode:c,version:h};if(i&&(p.emoticon=i),a&&(p.shortcodes=a),r){p.skinTones=[],p.skinUnicodes=[],p.skinVersions=[];for(const{tone:v,emoji:S,version:x}of r)p.skinTones.push(v),p.skinUnicodes.push(S),p.skinVersions.push(x)}return p})}function zd(e,t,n,i){e[t](n).onsuccess=s=>i&&i(s.target.result)}function It(e,t,n){zd(e,"get",t,n)}function qd(e,t,n){zd(e,"getAll",t,n)}function Ra(e){e.commit&&e.commit()}function mv(e,t){let n=e[0];for(let i=1;i<e.length;i++){const s=e[i];t(n)>t(s)&&(n=s)}return n}function Hd(e,t){const n=mv(e,s=>s.length),i=[];for(const s of n)e.some(o=>o.findIndex(a=>t(a)===t(s))===-1)||i.push(s);return i}async function yv(e){return!await Da(e,Xt,Yi)}async function vv(e,t,n){const[i,s]=await Promise.all([Do,Yi].map(o=>Da(e,Xt,o)));return i===n&&s===t}async function bv(e,t){return et(e,Bt,ln,(i,s,o)=>{let a;const r=()=>{i.getAll(a&&IDBKeyRange.lowerBound(a,!0),50).onsuccess=l=>{const c=l.target.result;for(const h of c)if(a=h.unicode,t(h))return o(h);if(c.length<50)return o();r()}};r()})}async function jd(e,t,n,i){{const s=gv(t);await et(e,[Bt,Xt],Ia,([o,a],r)=>{let l,c,h=0;function d(){++h===2&&p()}function p(){if(!(l===i&&c===n)){o.clear();for(const v of s)o.put(v);a.put(i,Do),a.put(n,Yi),Ra(r)}}It(a,Do,v=>{l=v,d()}),It(a,Yi,v=>{c=v,d()})})}}async function wv(e,t){return et(e,Bt,ln,(n,i,s)=>{const o=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);qd(n.index(Fd),o,s)})}async function Gd(e,t){const n=Kd(Qt(t));return n.length?et(e,Bt,ln,(i,s,o)=>{const a=[],r=()=>{a.length===n.length&&l()},l=()=>{const c=Hd(a,h=>h.unicode);o(c.sort((h,d)=>h.order<d.order?-1:1))};for(let c=0;c<n.length;c++){const h=n[c],d=c===n.length-1?IDBKeyRange.bound(h,h+"",!1,!0):IDBKeyRange.only(h);qd(i.index(Nd),d,p=>{a.push(p),r()})}}):[]}async function kv(e,t){const n=await Gd(e,t);return n.length?n.filter(i=>(i.shortcodes||[]).map(o=>o.toLowerCase()).includes(t.toLowerCase()))[0]||null:await bv(e,s=>(s.shortcodes||[]).includes(t.toLowerCase()))||null}async function $v(e,t){return et(e,Bt,ln,(n,i,s)=>It(n,t,o=>{if(o)return s(o);It(n.index(Ud),t,a=>s(a||null))}))}function Da(e,t,n){return et(e,t,ln,(i,s,o)=>It(i,n,o))}function xv(e,t,n,i){return et(e,t,Ia,(s,o)=>{s.put(i,n),Ra(o)})}function Sv(e,t){return et(e,Pa,Ia,(n,i)=>It(n,t,s=>{n.put((s||0)+1,t),Ra(i)}))}function Av(e,t,n){return n===0?[]:et(e,[Pa,Bt],ln,([i,s],o,a)=>{const r=[];i.index(Od).openCursor(void 0,"prev").onsuccess=l=>{const c=l.target.result;if(!c)return a(r);function h(v){if(r.push(v),r.length===n)return a(r);c.continue()}const d=c.primaryKey,p=t.byName(d);if(p)return h(p);It(s,d,v=>{if(v)return h(v);c.continue()})}})}const bi="";function Cv(e,t){const n=new Map;for(const s of e){const o=t(s);for(const a of o){let r=n;for(let c=0;c<a.length;c++){const h=a.charAt(c);let d=r.get(h);d||(d=new Map,r.set(h,d)),r=d}let l=r.get(bi);l||(l=[],r.set(bi,l)),l.push(s)}}return(s,o)=>{let a=n;for(let c=0;c<s.length;c++){const h=s.charAt(c),d=a.get(h);if(d)a=d;else return[]}if(o)return a.get(bi)||[];const r=[],l=[a];for(;l.length;){const h=[...l.shift().entries()].sort((d,p)=>d[0]<p[0]?-1:1);for(const[d,p]of h)d===bi?r.push(...p):l.push(p)}return r}}const Ev=["name","url"];function Tv(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||Ev.some(i=>!(i in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function ol(e){Tv(e);const t=(p,v)=>p.name.toLowerCase()<v.name.toLowerCase()?-1:1,n=e.sort(t),s=Cv(e,p=>{const v=new Set;if(p.shortcodes)for(const S of p.shortcodes)for(const x of Qt(S))v.add(x);return v}),o=p=>s(p,!0),a=p=>s(p,!1),r=p=>{const v=Qt(p),S=v.map((x,T)=>(T<v.length-1?o:a)(x));return Hd(S,x=>x.name).sort(t)},l=new Map,c=new Map;for(const p of e){c.set(p.name.toLowerCase(),p);for(const v of p.shortcodes||[])l.set(v.toLowerCase(),p)}return{all:n,search:r,byShortcode:p=>l.get(p.toLowerCase()),byName:p=>c.get(p.toLowerCase())}}const _v=typeof wrappedJSObject<"u";function xn(e){if(!e)return e;if(_v&&(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 Vd(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const Mv=["annotation","emoji","group","order","version"];function Pv(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||Mv.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function Qd(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function Iv(e){const t=await fetch(e,{method:"HEAD"});Qd(t,e);const n=t.headers.get("etag");return Vd(n),n}async function No(e){const t=await fetch(e);Qd(t,e);const n=t.headers.get("etag");Vd(n);const i=await t.json();return Pv(i),[n,i]}function Lv(e){for(var t="",n=new Uint8Array(e),i=n.byteLength,s=-1;++s<i;)t+=String.fromCharCode(n[s]);return t}function Rv(e){for(var t=e.length,n=new ArrayBuffer(t),i=new Uint8Array(n),s=-1;++s<t;)i[s]=e.charCodeAt(s);return n}async function Jd(e){const t=JSON.stringify(e);let n=Rv(t);const i=await crypto.subtle.digest("SHA-1",n),s=Lv(i);return btoa(s)}async function Dv(e,t){let n,i=await Iv(t);if(!i){const s=await No(t);i=s[0],n=s[1],i||(i=await Jd(n))}await vv(e,t,i)||(n||(n=(await No(t))[1]),await jd(e,n,t,i))}async function Bv(e,t){let[n,i]=await No(t);n||(n=await Jd(i)),await jd(e,i,t,n)}async function Nv(e,t){try{await Dv(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class Ov{constructor({dataSource:t=ov,locale:n=av,customEmoji:i=[]}={}){this.dataSource=t,this.locale=n,this._dbName=`emoji-picker-element-${this.locale}`,this._db=void 0,this._lazyUpdate=void 0,this._custom=ol(i),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await dv(this._dbName);pv(this._dbName,this._clear);const n=this.dataSource;await yv(t)?await Bv(t,n):this._lazyUpdate=Nv(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 Zs(t),await this.ready(),sl(await wv(this._db,t)).map(xn)}async getEmojiBySearchQuery(t){vi(t),await this.ready();const n=this._custom.search(t),i=sl(await Gd(this._db,t)).map(xn);return[...n,...i]}async getEmojiByShortcode(t){vi(t),await this.ready();const n=this._custom.byShortcode(t);return n||xn(await kv(this._db,t))}async getEmojiByUnicodeOrName(t){vi(t),await this.ready();const n=this._custom.byName(t);return n||xn(await $v(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await Da(this._db,Xt,il)||0}async setPreferredSkinTone(t){return Zs(t),await this.ready(),xv(this._db,Xt,il,t)}async incrementFavoriteEmojiCount(t){return vi(t),await this.ready(),Sv(this._db,t)}async getTopFavoriteEmoji(t){return Zs(t),await this.ready(),(await Av(this._db,this._custom,t)).map(xn)}set customEmoji(t){this._custom=ol(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 La(this._dbName)}async delete(){await this._shutdown(),await uv(this._dbName)}}const Oo=[[-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})),eo=Oo.slice(1),Fv=2,al=6,Yd=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function rl(e){return e.unicode.includes("")}const Uv={"":17,"":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱♀️":4,"🤣":3,"👁️🗨️":2,"😀":1,"😐️":.7,"😃":.6},Wv=1e3,Kv="🖐️",zv=8,qv=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],Xd='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',Hv=(e,t)=>e<t?-1:e>t?1:0,ll=(e,t)=>{const n=document.createElement("canvas");n.width=n.height=1;const i=n.getContext("2d",{willReadFrequently:!0});return i.textBaseline="top",i.font=`100px ${Xd}`,i.fillStyle=t,i.scale(.01,.01),i.fillText(e,0,0),i.getImageData(0,0,1,1).data},jv=(e,t)=>{const n=[...e].join(","),i=[...t].join(",");return n===i&&!n.startsWith("0,0,0,")};function Gv(e){const t=ll(e,"#000"),n=ll(e,"#fff");return t&&n&&jv(t,n)}function Vv(){const e=Object.entries(Uv);try{for(const[t,n]of e)if(Gv(t))return n}catch{}return e[0][1]}let to;const no=()=>(to||(to=new Promise(e=>Yd(()=>e(Vv())))),to),Fo=new Map,Qv="️",Jv="\uD83C",Yv="",Xv=127995,Zv=57339;function eb(e,t){if(t===0)return e;const n=e.indexOf(Yv);return n!==-1?e.substring(0,n)+String.fromCodePoint(Xv+t-1)+e.substring(n):(e.endsWith(Qv)&&(e=e.substring(0,e.length-1)),e+Jv+String.fromCodePoint(Zv+t-1))}function Le(e){e.preventDefault(),e.stopPropagation()}function io(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function Zd(e,t){const n=new Set,i=[];for(const s of e){const o=t(s);n.has(o)||(n.add(o),i.push(s))}return i}function tb(e,t){const n=i=>{const s={};for(const o of i)typeof o.tone=="number"&&o.version<=t&&(s[o.tone]=o.unicode);return s};return e.map(({unicode:i,skins:s,shortcodes:o,url:a,name:r,category:l,annotation:c})=>({unicode:i,name:r,shortcodes:o,url:a,category:l,annotation:c,id:i||r,skins:s&&n(s)}))}const Ti=requestAnimationFrame;let nb=typeof ResizeObserver=="function";function ib(e,t,n){let i;nb?(i=new ResizeObserver(n),i.observe(e)):Ti(n),t.addEventListener("abort",()=>{i&&i.disconnect()})}function cl(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let so;function sb(e,t,n){let i=!0,s=!1;for(const o of e){const a=n(o);if(!a)continue;const r=cl(a);r===0&&(s=!0),typeof so>"u"&&(so=cl(t));const l=r/1.8<so;Fo.set(o.unicode,l),l||(i=!1)}return s&&console.warn(`Emoji support detection failed - emoji character is 0 width.
|
|
2849
|
+
`;ps([is({type:Number})],Yt.prototype,"splitRatio",2);ps([is({type:Number})],Yt.prototype,"minRatio",2);ps([is({type:Number})],Yt.prototype,"maxRatio",2);Yt=ps([Wl("resizable-divider")],Yt);function vi(e){if(typeof e!="string"||!e)throw new Error("expected a non-empty string, got: "+e)}function Zs(e){if(typeof e!="number")throw new Error("expected a number, got: "+e)}const Xy=1,Zy=1,Bt="emoji",Xt="keyvalue",Pa="favorites",ev="tokens",Nd="tokens",tv="unicode",Od="count",nv="group",iv="order",Fd="group-order",Do="eTag",Yi="url",il="skinTone",ln="readonly",Ia="readwrite",Ud="skinUnicodes",sv="skinUnicodes",ov="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",av="en";function rv(e,t){const n=new Set,i=[];for(const s of e){const o=t(s);n.has(o)||(n.add(o),i.push(s))}return i}function sl(e){return rv(e,t=>t.unicode)}function lv(e){function t(n,i,s){const o=i?e.createObjectStore(n,{keyPath:i}):e.createObjectStore(n);if(s)for(const[a,[r,l]]of Object.entries(s))o.createIndex(a,r,{multiEntry:l});return o}t(Xt),t(Bt,tv,{[Nd]:[ev,!0],[Fd]:[[nv,iv]],[Ud]:[sv,!0]}),t(Pa,void 0,{[Od]:[""]})}const Bo={},Ei={},Xi={};function Wd(e,t,n){n.onerror=()=>t(n.error),n.onblocked=()=>t(new Error("IDB blocked")),n.onsuccess=()=>e(n.result)}async function cv(e){const t=await new Promise((n,i)=>{const s=indexedDB.open(e,Xy);Bo[e]=s,s.onupgradeneeded=o=>{o.oldVersion<Zy&&lv(s.result)},Wd(n,i,s)});return t.onclose=()=>La(e),t}function dv(e){return Ei[e]||(Ei[e]=cv(e)),Ei[e]}function et(e,t,n,i){return new Promise((s,o)=>{const a=e.transaction(t,n,{durability:"relaxed"}),r=typeof t=="string"?a.objectStore(t):t.map(c=>a.objectStore(c));let l;i(r,a,c=>{l=c}),a.oncomplete=()=>s(l),a.onerror=()=>o(a.error)})}function La(e){const t=Bo[e],n=t&&t.result;if(n){n.close();const i=Xi[e];if(i)for(const s of i)s()}delete Bo[e],delete Ei[e],delete Xi[e]}function uv(e){return new Promise((t,n)=>{La(e);const i=indexedDB.deleteDatabase(e);Wd(t,n,i)})}function pv(e,t){let n=Xi[e];n||(n=Xi[e]=[]),n.push(t)}const hv=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 Qt(e){return e.split(/[\s_]+/).map(t=>!t.match(/\w/)||hv.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const fv=2;function Kd(e){return e.filter(Boolean).map(t=>t.toLowerCase()).filter(t=>t.length>=fv)}function gv(e){return e.map(({annotation:n,emoticon:i,group:s,order:o,shortcodes:a,skins:r,tags:l,emoji:c,version:h})=>{const d=[...new Set(Kd([...(a||[]).map(Qt).flat(),...(l||[]).map(Qt).flat(),...Qt(n),i]))].sort(),p={annotation:n,group:s,order:o,tags:l,tokens:d,unicode:c,version:h};if(i&&(p.emoticon=i),a&&(p.shortcodes=a),r){p.skinTones=[],p.skinUnicodes=[],p.skinVersions=[];for(const{tone:g,emoji:$,version:S}of r)p.skinTones.push(g),p.skinUnicodes.push($),p.skinVersions.push(S)}return p})}function zd(e,t,n,i){e[t](n).onsuccess=s=>i&&i(s.target.result)}function It(e,t,n){zd(e,"get",t,n)}function qd(e,t,n){zd(e,"getAll",t,n)}function Ra(e){e.commit&&e.commit()}function mv(e,t){let n=e[0];for(let i=1;i<e.length;i++){const s=e[i];t(n)>t(s)&&(n=s)}return n}function Hd(e,t){const n=mv(e,s=>s.length),i=[];for(const s of n)e.some(o=>o.findIndex(a=>t(a)===t(s))===-1)||i.push(s);return i}async function yv(e){return!await Da(e,Xt,Yi)}async function vv(e,t,n){const[i,s]=await Promise.all([Do,Yi].map(o=>Da(e,Xt,o)));return i===n&&s===t}async function bv(e,t){return et(e,Bt,ln,(i,s,o)=>{let a;const r=()=>{i.getAll(a&&IDBKeyRange.lowerBound(a,!0),50).onsuccess=l=>{const c=l.target.result;for(const h of c)if(a=h.unicode,t(h))return o(h);if(c.length<50)return o();r()}};r()})}async function jd(e,t,n,i){{const s=gv(t);await et(e,[Bt,Xt],Ia,([o,a],r)=>{let l,c,h=0;function d(){++h===2&&p()}function p(){if(!(l===i&&c===n)){o.clear();for(const g of s)o.put(g);a.put(i,Do),a.put(n,Yi),Ra(r)}}It(a,Do,g=>{l=g,d()}),It(a,Yi,g=>{c=g,d()})})}}async function wv(e,t){return et(e,Bt,ln,(n,i,s)=>{const o=IDBKeyRange.bound([t,0],[t+1,0],!1,!0);qd(n.index(Fd),o,s)})}async function Gd(e,t){const n=Kd(Qt(t));return n.length?et(e,Bt,ln,(i,s,o)=>{const a=[],r=()=>{a.length===n.length&&l()},l=()=>{const c=Hd(a,h=>h.unicode);o(c.sort((h,d)=>h.order<d.order?-1:1))};for(let c=0;c<n.length;c++){const h=n[c],d=c===n.length-1?IDBKeyRange.bound(h,h+"",!1,!0):IDBKeyRange.only(h);qd(i.index(Nd),d,p=>{a.push(p),r()})}}):[]}async function kv(e,t){const n=await Gd(e,t);return n.length?n.filter(i=>(i.shortcodes||[]).map(o=>o.toLowerCase()).includes(t.toLowerCase()))[0]||null:await bv(e,s=>(s.shortcodes||[]).includes(t.toLowerCase()))||null}async function xv(e,t){return et(e,Bt,ln,(n,i,s)=>It(n,t,o=>{if(o)return s(o);It(n.index(Ud),t,a=>s(a||null))}))}function Da(e,t,n){return et(e,t,ln,(i,s,o)=>It(i,n,o))}function $v(e,t,n,i){return et(e,t,Ia,(s,o)=>{s.put(i,n),Ra(o)})}function Sv(e,t){return et(e,Pa,Ia,(n,i)=>It(n,t,s=>{n.put((s||0)+1,t),Ra(i)}))}function Av(e,t,n){return n===0?[]:et(e,[Pa,Bt],ln,([i,s],o,a)=>{const r=[];i.index(Od).openCursor(void 0,"prev").onsuccess=l=>{const c=l.target.result;if(!c)return a(r);function h(g){if(r.push(g),r.length===n)return a(r);c.continue()}const d=c.primaryKey,p=t.byName(d);if(p)return h(p);It(s,d,g=>{if(g)return h(g);c.continue()})}})}const bi="";function Cv(e,t){const n=new Map;for(const s of e){const o=t(s);for(const a of o){let r=n;for(let c=0;c<a.length;c++){const h=a.charAt(c);let d=r.get(h);d||(d=new Map,r.set(h,d)),r=d}let l=r.get(bi);l||(l=[],r.set(bi,l)),l.push(s)}}return(s,o)=>{let a=n;for(let c=0;c<s.length;c++){const h=s.charAt(c),d=a.get(h);if(d)a=d;else return[]}if(o)return a.get(bi)||[];const r=[],l=[a];for(;l.length;){const h=[...l.shift().entries()].sort((d,p)=>d[0]<p[0]?-1:1);for(const[d,p]of h)d===bi?r.push(...p):l.push(p)}return r}}const Ev=["name","url"];function Tv(e){const t=e&&Array.isArray(e),n=t&&e.length&&(!e[0]||Ev.some(i=>!(i in e[0])));if(!t||n)throw new Error("Custom emojis are in the wrong format")}function ol(e){Tv(e);const t=(p,g)=>p.name.toLowerCase()<g.name.toLowerCase()?-1:1,n=e.sort(t),s=Cv(e,p=>{const g=new Set;if(p.shortcodes)for(const $ of p.shortcodes)for(const S of Qt($))g.add(S);return g}),o=p=>s(p,!0),a=p=>s(p,!1),r=p=>{const g=Qt(p),$=g.map((S,T)=>(T<g.length-1?o:a)(S));return Hd($,S=>S.name).sort(t)},l=new Map,c=new Map;for(const p of e){c.set(p.name.toLowerCase(),p);for(const g of p.shortcodes||[])l.set(g.toLowerCase(),p)}return{all:n,search:r,byShortcode:p=>l.get(p.toLowerCase()),byName:p=>c.get(p.toLowerCase())}}const _v=typeof wrappedJSObject<"u";function $n(e){if(!e)return e;if(_v&&(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 Vd(e){e||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const Mv=["annotation","emoji","group","order","version"];function Pv(e){if(!e||!Array.isArray(e)||!e[0]||typeof e[0]!="object"||Mv.some(t=>!(t in e[0])))throw new Error("Emoji data is in the wrong format")}function Qd(e,t){if(Math.floor(e.status/100)!==2)throw new Error("Failed to fetch: "+t+": "+e.status)}async function Iv(e){const t=await fetch(e,{method:"HEAD"});Qd(t,e);const n=t.headers.get("etag");return Vd(n),n}async function No(e){const t=await fetch(e);Qd(t,e);const n=t.headers.get("etag");Vd(n);const i=await t.json();return Pv(i),[n,i]}function Lv(e){for(var t="",n=new Uint8Array(e),i=n.byteLength,s=-1;++s<i;)t+=String.fromCharCode(n[s]);return t}function Rv(e){for(var t=e.length,n=new ArrayBuffer(t),i=new Uint8Array(n),s=-1;++s<t;)i[s]=e.charCodeAt(s);return n}async function Jd(e){const t=JSON.stringify(e);let n=Rv(t);const i=await crypto.subtle.digest("SHA-1",n),s=Lv(i);return btoa(s)}async function Dv(e,t){let n,i=await Iv(t);if(!i){const s=await No(t);i=s[0],n=s[1],i||(i=await Jd(n))}await vv(e,t,i)||(n||(n=(await No(t))[1]),await jd(e,n,t,i))}async function Bv(e,t){let[n,i]=await No(t);n||(n=await Jd(i)),await jd(e,i,t,n)}async function Nv(e,t){try{await Dv(e,t)}catch(n){if(n.name!=="InvalidStateError")throw n}}class Ov{constructor({dataSource:t=ov,locale:n=av,customEmoji:i=[]}={}){this.dataSource=t,this.locale=n,this._dbName=`emoji-picker-element-${this.locale}`,this._db=void 0,this._lazyUpdate=void 0,this._custom=ol(i),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const t=this._db=await dv(this._dbName);pv(this._dbName,this._clear);const n=this.dataSource;await yv(t)?await Bv(t,n):this._lazyUpdate=Nv(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 Zs(t),await this.ready(),sl(await wv(this._db,t)).map($n)}async getEmojiBySearchQuery(t){vi(t),await this.ready();const n=this._custom.search(t),i=sl(await Gd(this._db,t)).map($n);return[...n,...i]}async getEmojiByShortcode(t){vi(t),await this.ready();const n=this._custom.byShortcode(t);return n||$n(await kv(this._db,t))}async getEmojiByUnicodeOrName(t){vi(t),await this.ready();const n=this._custom.byName(t);return n||$n(await xv(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await Da(this._db,Xt,il)||0}async setPreferredSkinTone(t){return Zs(t),await this.ready(),$v(this._db,Xt,il,t)}async incrementFavoriteEmojiCount(t){return vi(t),await this.ready(),Sv(this._db,t)}async getTopFavoriteEmoji(t){return Zs(t),await this.ready(),(await Av(this._db,this._custom,t)).map($n)}set customEmoji(t){this._custom=ol(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 La(this._dbName)}async delete(){await this._shutdown(),await uv(this._dbName)}}const Oo=[[-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})),eo=Oo.slice(1),Fv=2,al=6,Yd=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function rl(e){return e.unicode.includes("")}const Uv={"":17,"":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱♀️":4,"🤣":3,"👁️🗨️":2,"😀":1,"😐️":.7,"😃":.6},Wv=1e3,Kv="🖐️",zv=8,qv=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],Xd='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',Hv=(e,t)=>e<t?-1:e>t?1:0,ll=(e,t)=>{const n=document.createElement("canvas");n.width=n.height=1;const i=n.getContext("2d",{willReadFrequently:!0});return i.textBaseline="top",i.font=`100px ${Xd}`,i.fillStyle=t,i.scale(.01,.01),i.fillText(e,0,0),i.getImageData(0,0,1,1).data},jv=(e,t)=>{const n=[...e].join(","),i=[...t].join(",");return n===i&&!n.startsWith("0,0,0,")};function Gv(e){const t=ll(e,"#000"),n=ll(e,"#fff");return t&&n&&jv(t,n)}function Vv(){const e=Object.entries(Uv);try{for(const[t,n]of e)if(Gv(t))return n}catch{}return e[0][1]}let to;const no=()=>(to||(to=new Promise(e=>Yd(()=>e(Vv())))),to),Fo=new Map,Qv="️",Jv="\uD83C",Yv="",Xv=127995,Zv=57339;function eb(e,t){if(t===0)return e;const n=e.indexOf(Yv);return n!==-1?e.substring(0,n)+String.fromCodePoint(Xv+t-1)+e.substring(n):(e.endsWith(Qv)&&(e=e.substring(0,e.length-1)),e+Jv+String.fromCodePoint(Zv+t-1))}function Le(e){e.preventDefault(),e.stopPropagation()}function io(e,t,n){return t+=e?-1:1,t<0?t=n.length-1:t>=n.length&&(t=0),t}function Zd(e,t){const n=new Set,i=[];for(const s of e){const o=t(s);n.has(o)||(n.add(o),i.push(s))}return i}function tb(e,t){const n=i=>{const s={};for(const o of i)typeof o.tone=="number"&&o.version<=t&&(s[o.tone]=o.unicode);return s};return e.map(({unicode:i,skins:s,shortcodes:o,url:a,name:r,category:l,annotation:c})=>({unicode:i,name:r,shortcodes:o,url:a,category:l,annotation:c,id:i||r,skins:s&&n(s)}))}const Ti=requestAnimationFrame;let nb=typeof ResizeObserver=="function";function ib(e,t,n){let i;nb?(i=new ResizeObserver(n),i.observe(e)):Ti(n),t.addEventListener("abort",()=>{i&&i.disconnect()})}function cl(e){{const t=document.createRange();return t.selectNode(e.firstChild),t.getBoundingClientRect().width}}let so;function sb(e,t,n){let i=!0,s=!1;for(const o of e){const a=n(o);if(!a)continue;const r=cl(a);r===0&&(s=!0),typeof so>"u"&&(so=cl(t));const l=r/1.8<so;Fo.set(o.unicode,l),l||(i=!1)}return s&&console.warn(`Emoji support detection failed - emoji character is 0 width.
|
|
2837
2850
|
This is likely due to using \`display:none\` which is unsupported.
|
|
2838
2851
|
If this is a Jest/Vitest environment, you can ignore this warning.
|
|
2839
|
-
For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function ob(e){return Zd(e,t=>t)}function ab(e){e&&(e.scrollTop=0)}function Dn(e,t,n){let i=e.get(t);return i||(i=n(),e.set(t,i)),i}function dl(e){return""+e}function rb(e){const t=document.createElement("template");return t.innerHTML=e,t}const lb=new WeakMap,cb=new WeakMap,db=Symbol("un-keyed"),ub="replaceChildren"in Element.prototype;function pb(e,t){ub?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function hb(e,t){let n=e.firstChild,i=0;for(;n;){if(t[i]!==n)return!0;n=n.nextSibling,i++}return i!==t.length}function fb(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=hb(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&pb(i,e)}function gb(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:o,attributeName:a,attributeValuePre:r,attributeValuePost:l}}=n,c=e[o];if(s!==c)if(n.currentExpression=c,a)if(c===null)i.removeAttribute(a);else{const h=r+dl(c)+l;i.setAttribute(a,h)}else{let h;Array.isArray(c)?fb(c,n):c instanceof Element?(h=c,i.replaceWith(h)):i.nodeValue=dl(c),h&&(n.targetNode=h)}}}function mb(e){let t="",n=!1,i=!1,s=-1;const o=new Map,a=[];let r=0;for(let c=0,h=e.length;c<h;c++){const d=e[c];if(t+=d.slice(r),c===h-1)break;for(let b=0;b<d.length;b++)switch(d.charAt(b)){case"<":{d.charAt(b+1)==="/"?a.pop():(n=!0,a.push(++s));break}case">":{n=!1,i=!1;break}case"=":{i=!0;break}}const p=a[a.length-1],v=Dn(o,p,()=>[]);let S,x,T;if(i){const b=/(\S+)="?([^"=]*)$/.exec(d);S=b[1],x=b[2];const k=/^([^">]*)("?)/.exec(e[c+1]);T=k[1],t=t.slice(0,-1*b[0].length),r=k[0].length}else r=0;const f={attributeName:S,attributeValuePre:x,attributeValuePost:T,expressionIndex:c};v.push(f),!n&&!i&&(t+=" ")}return{template:rb(t),elementsToBindings:o}}function ul(e,t,n){for(let i=0;i<e.length;i++){const s=e[i],o=s.attributeName?t:t.firstChild,a={binding:s,targetNode:o,targetParentNode:void 0,currentExpression:void 0};n.push(a)}}function yb(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))ul(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,a=-1;do{const r=t.get(++a);r&&ul(r,o,n)}while(o=s.nextNode())}return n}function vb(e){const{template:t,elementsToBindings:n}=Dn(lb,e,()=>mb(e)),i=t.cloneNode(!0).content.firstElementChild,s=yb(i,n);return function(a){return gb(a,s),i}}function bb(e){const t=Dn(cb,e,()=>new Map);let n=db;function i(o,...a){const r=Dn(t,o,()=>new Map);return Dn(r,n,()=>vb(o))(a)}function s(o,a,r){return o.map((l,c)=>{const h=n;n=r(l);try{return a(l,c)}finally{n=h}})}return{map:s,html:i}}function wb(e,t,n,i,s,o,a,r,l){const{labelWithSkin:c,titleForEmoji:h,unicodeWithSkin:d}=n,{html:p,map:v}=bb(t);function S(b,k,A){return v(b,(E,M)=>p`<button role="${k?"option":"menuitem"}" aria-selected="${k?M===t.activeSearchItem:null}" aria-label="${c(E,t.currentSkinTone)}" title="${h(E)}" class="${"emoji"+(k&&M===t.activeSearchItem?" active":"")+(E.unicode?"":" custom-emoji")}" id="${`${A}-${E.id}`}" style="${E.unicode?null:`--custom-emoji-background: url(${JSON.stringify(E.url)})`}">${E.unicode?d(E,t.currentSkinTone):""}</button>`,E=>`${A}-${E.id}`)}const T=p`<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,(b,k)=>p`<div id="skintone-${k}" class="emoji ${k===t.activeSkinTone?"active":""}" aria-selected="${k===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[k]}" aria-label="${t.i18n.skinTones[k]}">${b}</div>`,b=>b)}</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,b=>p`<button role="tab" class="nav-button" aria-controls="tab-${b.id}" aria-label="${t.i18n.categories[b.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===b.id}" title="${t.i18n.categories[b.name]}" data-group-id="${b.id}"><div class="nav-emoji emoji">${b.emoji}</div></button>`,b=>b.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,(b,k)=>p`<div><div id="menu-label-${k}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:b.category?b.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${k!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(b.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${k}" id="${t.searchMode?"search-results":null}">${S(b.emojis,t.searchMode,"emo")}</div></div>`,b=>b.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${S(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,f=(b,k)=>{for(const A of e.querySelectorAll(`[${b}]`))k(A,A.getAttribute(b))};if(l){e.appendChild(T);for(const b of["click","focusout","input","keydown","keyup"])f(`data-on-${b}`,(k,A)=>{k.addEventListener(b,i[A])});f("data-ref",(b,k)=>{o[k]=b}),a.addEventListener("abort",()=>{e.removeChild(T)})}f("data-action",(b,k)=>{let A=r.get(k);A||r.set(k,A=new WeakSet),A.has(b)||(A.add(b),s[k](b))})}const Zi=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function kb(e){let t=!1,n;const i=new Map,s=new Set;let o;const a=()=>{if(t)return;const c=[...s];s.clear();try{for(const h of c)h()}finally{o=!1,s.size&&(o=!0,Zi(a))}},r=new Proxy({},{get(c,h){if(n){let d=i.get(h);d||(d=new Set,i.set(h,d)),d.add(n)}return c[h]},set(c,h,d){if(c[h]!==d){c[h]=d;const p=i.get(h);if(p){for(const v of p)s.add(v);o||(o=!0,Zi(a))}}return!0}}),l=c=>{const h=()=>{const d=n;n=h;try{return c()}finally{n=d}};return h()};return e.addEventListener("abort",()=>{t=!0}),{state:r,createEffect:l}}function oo(e,t,n){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}const pl=new WeakMap;function $b(e,t,n){{const i=e.closest(".tabpanel");let s=pl.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),pl.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const ao=[],{assign:wi}=Object;function xb(e,t){const n={},i=new AbortController,s=i.signal,{state:o,createEffect:a}=kb(s),r=new Map;wi(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),wi(o,t),wi(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:zv,isRtl:!1,currentGroupIndex:0,groups:eo,databaseLoaded:!1,activeSearchItemId:void 0}),a(()=>{o.currentGroup!==o.groups[o.currentGroupIndex]&&(o.currentGroup=o.groups[o.currentGroupIndex])});const l=C=>{e.getElementById(C).focus()},c=C=>e.getElementById(`emo-${C.id}`),h=(C,I)=>{n.rootElement.dispatchEvent(new CustomEvent(C,{detail:I,bubbles:!0,composed:!0}))},d=(C,I)=>C.id===I.id,p=(C,I)=>{const{category:U,emojis:W}=C,{category:Z,emojis:J}=I;return U!==Z?!1:oo(W,J,d)},v=C=>{oo(o.currentEmojis,C,d)||(o.currentEmojis=C)},S=C=>{o.searchMode!==C&&(o.searchMode=C)},x=C=>{oo(o.currentEmojisWithCategories,C,p)||(o.currentEmojisWithCategories=C)},T=(C,I)=>I&&C.skins&&C.skins[I]||C.unicode,k={labelWithSkin:(C,I)=>ob([C.name||T(C,I),C.annotation,...C.shortcodes||ao].filter(Boolean)).join(", "),titleForEmoji:C=>C.annotation||(C.shortcodes||ao).join(", "),unicodeWithSkin:T},A={onClickSkinToneButton:X,onEmojiClick:Yn,onNavClick:Qn,onNavKeydown:bs,onSearchKeydown:vs,onSkinToneOptionsClick:Xn,onSkinToneOptionsFocusOut:tt,onSkinToneOptionsKeydown:pt,onSkinToneOptionsKeyup:dn,onSearchInput:Zn},E={calculateEmojiGridStyle:R,updateOnIntersection:F};let M=!0;a(()=>{wb(e,o,k,A,E,n,s,r,M),M=!1}),o.emojiVersion||no().then(C=>{C||(o.message=o.i18n.emojiUnsupportedMessage)}),a(()=>{async function C(){let I=!1;const U=setTimeout(()=>{I=!0,o.message=o.i18n.loadingMessage},Wv);try{await o.database.ready(),o.databaseLoaded=!0}catch(W){console.error(W),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(U),I&&(I=!1,o.message="")}}o.database&&C()}),a(()=>{o.pickerStyle=`
|
|
2852
|
+
For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`),i}function ob(e){return Zd(e,t=>t)}function ab(e){e&&(e.scrollTop=0)}function Dn(e,t,n){let i=e.get(t);return i||(i=n(),e.set(t,i)),i}function dl(e){return""+e}function rb(e){const t=document.createElement("template");return t.innerHTML=e,t}const lb=new WeakMap,cb=new WeakMap,db=Symbol("un-keyed"),ub="replaceChildren"in Element.prototype;function pb(e,t){ub?e.replaceChildren(...t):(e.innerHTML="",e.append(...t))}function hb(e,t){let n=e.firstChild,i=0;for(;n;){if(t[i]!==n)return!0;n=n.nextSibling,i++}return i!==t.length}function fb(e,t){const{targetNode:n}=t;let{targetParentNode:i}=t,s=!1;i?s=hb(i,e):(s=!0,t.targetNode=void 0,t.targetParentNode=i=n.parentNode),s&&pb(i,e)}function gb(e,t){for(const n of t){const{targetNode:i,currentExpression:s,binding:{expressionIndex:o,attributeName:a,attributeValuePre:r,attributeValuePost:l}}=n,c=e[o];if(s!==c)if(n.currentExpression=c,a)if(c===null)i.removeAttribute(a);else{const h=r+dl(c)+l;i.setAttribute(a,h)}else{let h;Array.isArray(c)?fb(c,n):c instanceof Element?(h=c,i.replaceWith(h)):i.nodeValue=dl(c),h&&(n.targetNode=h)}}}function mb(e){let t="",n=!1,i=!1,s=-1;const o=new Map,a=[];let r=0;for(let c=0,h=e.length;c<h;c++){const d=e[c];if(t+=d.slice(r),c===h-1)break;for(let b=0;b<d.length;b++)switch(d.charAt(b)){case"<":{d.charAt(b+1)==="/"?a.pop():(n=!0,a.push(++s));break}case">":{n=!1,i=!1;break}case"=":{i=!0;break}}const p=a[a.length-1],g=Dn(o,p,()=>[]);let $,S,T;if(i){const b=/(\S+)="?([^"=]*)$/.exec(d);$=b[1],S=b[2];const k=/^([^">]*)("?)/.exec(e[c+1]);T=k[1],t=t.slice(0,-1*b[0].length),r=k[0].length}else r=0;const f={attributeName:$,attributeValuePre:S,attributeValuePost:T,expressionIndex:c};g.push(f),!n&&!i&&(t+=" ")}return{template:rb(t),elementsToBindings:o}}function ul(e,t,n){for(let i=0;i<e.length;i++){const s=e[i],o=s.attributeName?t:t.firstChild,a={binding:s,targetNode:o,targetParentNode:void 0,currentExpression:void 0};n.push(a)}}function yb(e,t){const n=[];let i;if(t.size===1&&(i=t.get(0)))ul(i,e,n);else{const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e,a=-1;do{const r=t.get(++a);r&&ul(r,o,n)}while(o=s.nextNode())}return n}function vb(e){const{template:t,elementsToBindings:n}=Dn(lb,e,()=>mb(e)),i=t.cloneNode(!0).content.firstElementChild,s=yb(i,n);return function(a){return gb(a,s),i}}function bb(e){const t=Dn(cb,e,()=>new Map);let n=db;function i(o,...a){const r=Dn(t,o,()=>new Map);return Dn(r,n,()=>vb(o))(a)}function s(o,a,r){return o.map((l,c)=>{const h=n;n=r(l);try{return a(l,c)}finally{n=h}})}return{map:s,html:i}}function wb(e,t,n,i,s,o,a,r,l){const{labelWithSkin:c,titleForEmoji:h,unicodeWithSkin:d}=n,{html:p,map:g}=bb(t);function $(b,k,A){return g(b,(E,M)=>p`<button role="${k?"option":"menuitem"}" aria-selected="${k?M===t.activeSearchItem:null}" aria-label="${c(E,t.currentSkinTone)}" title="${h(E)}" class="${"emoji"+(k&&M===t.activeSearchItem?" active":"")+(E.unicode?"":" custom-emoji")}" id="${`${A}-${E.id}`}" style="${E.unicode?null:`--custom-emoji-background: url(${JSON.stringify(E.url)})`}">${E.unicode?d(E,t.currentSkinTone):""}</button>`,E=>`${A}-${E.id}`)}const T=p`<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">${g(t.skinTones,(b,k)=>p`<div id="skintone-${k}" class="emoji ${k===t.activeSkinTone?"active":""}" aria-selected="${k===t.activeSkinTone}" role="option" title="${t.i18n.skinTones[k]}" aria-label="${t.i18n.skinTones[k]}">${b}</div>`,b=>b)}</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">${g(t.groups,b=>p`<button role="tab" class="nav-button" aria-controls="tab-${b.id}" aria-label="${t.i18n.categories[b.name]}" aria-selected="${!t.searchMode&&t.currentGroup.id===b.id}" title="${t.i18n.categories[b.name]}" data-group-id="${b.id}"><div class="nav-emoji emoji">${b.emoji}</div></button>`,b=>b.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">${g(t.currentEmojisWithCategories,(b,k)=>p`<div><div id="menu-label-${k}" class="category ${t.currentEmojisWithCategories.length===1&&t.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${t.searchMode?t.i18n.searchResultsLabel:b.category?b.category:t.currentEmojisWithCategories.length>1?t.i18n.categories.custom:t.i18n.categories[t.currentGroup.name]}</div><div class="emoji-menu ${k!==0&&!t.searchMode&&t.currentGroup.id===-1?"visibility-auto":""}" style="${`--num-rows: ${Math.ceil(b.emojis.length/t.numColumns)}`}" data-action="updateOnIntersection" role="${t.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${k}" id="${t.searchMode?"search-results":null}">${$(b.emojis,t.searchMode,"emo")}</div></div>`,b=>b.category)}</div></div><div class="favorites onscreen emoji-menu ${t.message?"gone":""}" role="menu" aria-label="${t.i18n.favoritesLabel}" data-on-click="onEmojiClick">${$(t.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`,f=(b,k)=>{for(const A of e.querySelectorAll(`[${b}]`))k(A,A.getAttribute(b))};if(l){e.appendChild(T);for(const b of["click","focusout","input","keydown","keyup"])f(`data-on-${b}`,(k,A)=>{k.addEventListener(b,i[A])});f("data-ref",(b,k)=>{o[k]=b}),a.addEventListener("abort",()=>{e.removeChild(T)})}f("data-action",(b,k)=>{let A=r.get(k);A||r.set(k,A=new WeakSet),A.has(b)||(A.add(b),s[k](b))})}const Zi=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function kb(e){let t=!1,n;const i=new Map,s=new Set;let o;const a=()=>{if(t)return;const c=[...s];s.clear();try{for(const h of c)h()}finally{o=!1,s.size&&(o=!0,Zi(a))}},r=new Proxy({},{get(c,h){if(n){let d=i.get(h);d||(d=new Set,i.set(h,d)),d.add(n)}return c[h]},set(c,h,d){if(c[h]!==d){c[h]=d;const p=i.get(h);if(p){for(const g of p)s.add(g);o||(o=!0,Zi(a))}}return!0}}),l=c=>{const h=()=>{const d=n;n=h;try{return c()}finally{n=d}};return h()};return e.addEventListener("abort",()=>{t=!0}),{state:r,createEffect:l}}function oo(e,t,n){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}const pl=new WeakMap;function xb(e,t,n){{const i=e.closest(".tabpanel");let s=pl.get(i);s||(s=new IntersectionObserver(n,{root:i,rootMargin:"50% 0px 50% 0px",threshold:0}),pl.set(i,s),t.addEventListener("abort",()=>{s.disconnect()})),s.observe(e)}}const ao=[],{assign:wi}=Object;function $b(e,t){const n={},i=new AbortController,s=i.signal,{state:o,createEffect:a}=kb(s),r=new Map;wi(o,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),wi(o,t),wi(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:zv,isRtl:!1,currentGroupIndex:0,groups:eo,databaseLoaded:!1,activeSearchItemId:void 0}),a(()=>{o.currentGroup!==o.groups[o.currentGroupIndex]&&(o.currentGroup=o.groups[o.currentGroupIndex])});const l=C=>{e.getElementById(C).focus()},c=C=>e.getElementById(`emo-${C.id}`),h=(C,I)=>{n.rootElement.dispatchEvent(new CustomEvent(C,{detail:I,bubbles:!0,composed:!0}))},d=(C,I)=>C.id===I.id,p=(C,I)=>{const{category:U,emojis:W}=C,{category:Z,emojis:J}=I;return U!==Z?!1:oo(W,J,d)},g=C=>{oo(o.currentEmojis,C,d)||(o.currentEmojis=C)},$=C=>{o.searchMode!==C&&(o.searchMode=C)},S=C=>{oo(o.currentEmojisWithCategories,C,p)||(o.currentEmojisWithCategories=C)},T=(C,I)=>I&&C.skins&&C.skins[I]||C.unicode,k={labelWithSkin:(C,I)=>ob([C.name||T(C,I),C.annotation,...C.shortcodes||ao].filter(Boolean)).join(", "),titleForEmoji:C=>C.annotation||(C.shortcodes||ao).join(", "),unicodeWithSkin:T},A={onClickSkinToneButton:X,onEmojiClick:Yn,onNavClick:Qn,onNavKeydown:bs,onSearchKeydown:vs,onSkinToneOptionsClick:Xn,onSkinToneOptionsFocusOut:tt,onSkinToneOptionsKeydown:pt,onSkinToneOptionsKeyup:dn,onSearchInput:Zn},E={calculateEmojiGridStyle:R,updateOnIntersection:F};let M=!0;a(()=>{wb(e,o,k,A,E,n,s,r,M),M=!1}),o.emojiVersion||no().then(C=>{C||(o.message=o.i18n.emojiUnsupportedMessage)}),a(()=>{async function C(){let I=!1;const U=setTimeout(()=>{I=!0,o.message=o.i18n.loadingMessage},Wv);try{await o.database.ready(),o.databaseLoaded=!0}catch(W){console.error(W),o.message=o.i18n.networkErrorMessage}finally{clearTimeout(U),I&&(I=!1,o.message="")}}o.database&&C()}),a(()=>{o.pickerStyle=`
|
|
2840
2853
|
--num-groups: ${o.groups.length};
|
|
2841
2854
|
--indicator-opacity: ${o.searchMode?0:1};
|
|
2842
|
-
--num-skintones: ${al};`}),a(()=>{o.customEmoji&&o.database&&P()}),a(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==Oo&&(o.groups=Oo):o.groups!==eo&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=eo)}),a(()=>{async function C(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}C()}),a(()=>{o.skinTones=Array(al).fill().map((C,I)=>eb(o.skinToneEmoji,I))}),a(()=>{o.skinToneButtonText=o.skinTones[o.currentSkinTone]}),a(()=>{o.skinToneButtonLabel=o.i18n.skinToneLabel.replace("{skinTone}",o.i18n.skinTones[o.currentSkinTone])}),a(()=>{async function C(){const{database:I}=o,U=(await Promise.all(qv.map(W=>I.getEmojiByUnicodeOrName(W)))).filter(Boolean);o.defaultFavoriteEmojis=U}o.databaseLoaded&&C()});function P(){const{customEmoji:C,database:I}=o,U=C||ao;I.customEmoji!==U&&(I.customEmoji=U)}a(()=>{async function C(){P();const{database:I,defaultFavoriteEmojis:U,numColumns:W}=o,Z=await I.getTopFavoriteEmoji(W),J=await Ke(Zd([...Z,...U],fe=>fe.unicode||fe.name).slice(0,W));o.currentFavorites=J}o.databaseLoaded&&o.defaultFavoriteEmojis&&C()});function R(C){ib(C,s,()=>{{const I=getComputedStyle(n.rootElement),U=parseInt(I.getPropertyValue("--num-columns"),10),W=I.getPropertyValue("direction")==="rtl";o.numColumns=U,o.isRtl=W}})}function F(C){$b(C,s,I=>{for(const{target:U,isIntersecting:W}of I)U.classList.toggle("onscreen",W)})}a(()=>{async function C(){const{searchText:I,currentGroup:U,databaseLoaded:W,customEmoji:Z}=o;if(!W)o.currentEmojis=[],o.searchMode=!1;else if(I.length>=Fv){const J=await ys(I);o.searchText===I&&(v(J),S(!0))}else{const{id:J}=U;if(J!==-1||Z&&Z.length){const fe=await ms(J);o.currentGroup.id===J&&(v(fe),S(!1))}}}C()});const H=()=>{Ti(()=>ab(n.tabpanelElement))};a(()=>{const{currentEmojis:C,emojiVersion:I}=o,U=C.filter(W=>W.unicode).filter(W=>rl(W)&&!Fo.has(W.unicode));if(!I&&U.length)v(C),Ti(()=>z(U));else{const W=I?C:C.filter(ke);v(W),H()}});function z(C){sb(C,n.baselineEmoji,c)?H():o.currentEmojis=[...o.currentEmojis]}function ke(C){return!C.unicode||!rl(C)||Fo.get(C.unicode)}async function _e(C){const I=o.emojiVersion||await no();return C.filter(({version:U})=>!U||U<=I)}async function Ke(C){return tb(C,o.emojiVersion||await no())}async function ms(C){const I=C===-1?o.customEmoji:await o.database.getEmojiByGroup(C);return Ke(await _e(I))}async function ys(C){return Ke(await _e(await o.database.getEmojiBySearchQuery(C)))}a(()=>{}),a(()=>{function C(){const{searchMode:U,currentEmojis:W}=o;if(U)return[{category:"",emojis:W}];const Z=new Map;for(const J of W){const fe=J.category||"";let nt=Z.get(fe);nt||(nt=[],Z.set(fe,nt)),nt.push(J)}return[...Z.entries()].map(([J,fe])=>({category:J,emojis:fe})).sort((J,fe)=>o.customCategorySorting(J.category,fe.category))}const I=C();x(I)}),a(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),a(()=>{const{rawSearchText:C}=o;Yd(()=>{o.searchText=(C||"").trim(),o.activeSearchItem=-1})});function vs(C){if(!o.searchMode||!o.currentEmojis.length)return;const I=U=>{Le(C),o.activeSearchItem=io(U,o.activeSearchItem,o.currentEmojis)};switch(C.key){case"ArrowDown":return I(!1);case"ArrowUp":return I(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return Le(C),te(o.currentEmojis[o.activeSearchItem].id)}}function Qn(C){const{target:I}=C,U=I.closest(".nav-button");if(!U)return;const W=parseInt(U.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(Z=>Z.id===W)}function bs(C){const{target:I,key:U}=C,W=Z=>{Z&&(Le(C),Z.focus())};switch(U){case"ArrowLeft":return W(I.previousElementSibling);case"ArrowRight":return W(I.nextElementSibling);case"Home":return W(I.parentElement.firstElementChild);case"End":return W(I.parentElement.lastElementChild)}}async function Jn(C){const I=await o.database.getEmojiByUnicodeOrName(C),U=[...o.currentEmojis,...o.currentFavorites].find(Z=>Z.id===C),W=U.unicode&&T(U,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(C),{emoji:I,skinTone:o.currentSkinTone,...W&&{unicode:W},...U.name&&{name:U.name}}}async function te(C){const I=Jn(C);h("emoji-click-sync",I),h("emoji-click",await I)}function Yn(C){const{target:I}=C;if(!I.classList.contains("emoji"))return;Le(C);const U=I.id.substring(4);te(U)}function ne(C){o.currentSkinTone=C,o.skinTonePickerExpanded=!1,l("skintone-button"),h("skin-tone-change",{skinTone:C}),o.database.setPreferredSkinTone(C)}function Xn(C){const{target:{id:I}}=C,U=I&&I.match(/^skintone-(\d)/);if(!U)return;Le(C);const W=parseInt(U[1],10);ne(W)}function X(C){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(Le(C),Ti(()=>l("skintone-list")))}a(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function pt(C){if(!o.skinTonePickerExpanded)return;const I=async U=>{Le(C),o.activeSkinTone=U};switch(C.key){case"ArrowUp":return I(io(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return I(io(!1,o.activeSkinTone,o.skinTones));case"Home":return I(0);case"End":return I(o.skinTones.length-1);case"Enter":return Le(C),ne(o.activeSkinTone);case"Escape":return Le(C),o.skinTonePickerExpanded=!1,l("skintone-button")}}function dn(C){if(o.skinTonePickerExpanded&&C.key===" ")return Le(C),ne(o.activeSkinTone)}async function tt(C){const{relatedTarget:I}=C;(!I||I.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function Zn(C){o.rawSearchText=C.target.value}return{$set(C){wi(o,C)},$destroy(){i.abort()}}}const Sb="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Ab="en";var Cb={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"}},Eb=':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 eu=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],Tb=`:host{--emoji-font-family:${Xd}}`;class Ba extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=Eb+Tb,this.shadowRoot.appendChild(n),this._ctx={locale:Ab,dataSource:Sb,skinToneEmoji:Kv,customCategorySorting:Hv,customEmoji:null,i18n:Cb,emojiVersion:null,...t};for(const i of eu)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){hl(this),this._cmp||(this._cmp=xb(this.shadowRoot,this._ctx))}disconnectedCallback(){hl(this),Zi(()=>{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,i){this._set(t.replace(/-([a-z])/g,(s,o)=>o.toUpperCase()),t==="emoji-version"?parseFloat(i):i)}_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:i}=this._ctx;(!i||i.locale!==t||i.dataSource!==n)&&this._set("database",new Ov({locale:t,dataSource:n}))}_dbFlush(){Zi(()=>this._dbCreate())}}const tu={};for(const e of eu)tu[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(Ba.prototype,tu);function hl(e){e instanceof Ba||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Ba);function _b(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 fl(e){e.style.height="44px",e.style.overflowY="hidden"}const Mb=5e3;function Pb(e){return e?e.active?u`
|
|
2855
|
+
--num-skintones: ${al};`}),a(()=>{o.customEmoji&&o.database&&P()}),a(()=>{o.customEmoji&&o.customEmoji.length?o.groups!==Oo&&(o.groups=Oo):o.groups!==eo&&(o.currentGroupIndex&&o.currentGroupIndex--,o.groups=eo)}),a(()=>{async function C(){o.databaseLoaded&&(o.currentSkinTone=await o.database.getPreferredSkinTone())}C()}),a(()=>{o.skinTones=Array(al).fill().map((C,I)=>eb(o.skinToneEmoji,I))}),a(()=>{o.skinToneButtonText=o.skinTones[o.currentSkinTone]}),a(()=>{o.skinToneButtonLabel=o.i18n.skinToneLabel.replace("{skinTone}",o.i18n.skinTones[o.currentSkinTone])}),a(()=>{async function C(){const{database:I}=o,U=(await Promise.all(qv.map(W=>I.getEmojiByUnicodeOrName(W)))).filter(Boolean);o.defaultFavoriteEmojis=U}o.databaseLoaded&&C()});function P(){const{customEmoji:C,database:I}=o,U=C||ao;I.customEmoji!==U&&(I.customEmoji=U)}a(()=>{async function C(){P();const{database:I,defaultFavoriteEmojis:U,numColumns:W}=o,Z=await I.getTopFavoriteEmoji(W),J=await Ke(Zd([...Z,...U],fe=>fe.unicode||fe.name).slice(0,W));o.currentFavorites=J}o.databaseLoaded&&o.defaultFavoriteEmojis&&C()});function R(C){ib(C,s,()=>{{const I=getComputedStyle(n.rootElement),U=parseInt(I.getPropertyValue("--num-columns"),10),W=I.getPropertyValue("direction")==="rtl";o.numColumns=U,o.isRtl=W}})}function F(C){xb(C,s,I=>{for(const{target:U,isIntersecting:W}of I)U.classList.toggle("onscreen",W)})}a(()=>{async function C(){const{searchText:I,currentGroup:U,databaseLoaded:W,customEmoji:Z}=o;if(!W)o.currentEmojis=[],o.searchMode=!1;else if(I.length>=Fv){const J=await ys(I);o.searchText===I&&(g(J),$(!0))}else{const{id:J}=U;if(J!==-1||Z&&Z.length){const fe=await ms(J);o.currentGroup.id===J&&(g(fe),$(!1))}}}C()});const H=()=>{Ti(()=>ab(n.tabpanelElement))};a(()=>{const{currentEmojis:C,emojiVersion:I}=o,U=C.filter(W=>W.unicode).filter(W=>rl(W)&&!Fo.has(W.unicode));if(!I&&U.length)g(C),Ti(()=>z(U));else{const W=I?C:C.filter(ke);g(W),H()}});function z(C){sb(C,n.baselineEmoji,c)?H():o.currentEmojis=[...o.currentEmojis]}function ke(C){return!C.unicode||!rl(C)||Fo.get(C.unicode)}async function _e(C){const I=o.emojiVersion||await no();return C.filter(({version:U})=>!U||U<=I)}async function Ke(C){return tb(C,o.emojiVersion||await no())}async function ms(C){const I=C===-1?o.customEmoji:await o.database.getEmojiByGroup(C);return Ke(await _e(I))}async function ys(C){return Ke(await _e(await o.database.getEmojiBySearchQuery(C)))}a(()=>{}),a(()=>{function C(){const{searchMode:U,currentEmojis:W}=o;if(U)return[{category:"",emojis:W}];const Z=new Map;for(const J of W){const fe=J.category||"";let nt=Z.get(fe);nt||(nt=[],Z.set(fe,nt)),nt.push(J)}return[...Z.entries()].map(([J,fe])=>({category:J,emojis:fe})).sort((J,fe)=>o.customCategorySorting(J.category,fe.category))}const I=C();S(I)}),a(()=>{o.activeSearchItemId=o.activeSearchItem!==-1&&o.currentEmojis[o.activeSearchItem].id}),a(()=>{const{rawSearchText:C}=o;Yd(()=>{o.searchText=(C||"").trim(),o.activeSearchItem=-1})});function vs(C){if(!o.searchMode||!o.currentEmojis.length)return;const I=U=>{Le(C),o.activeSearchItem=io(U,o.activeSearchItem,o.currentEmojis)};switch(C.key){case"ArrowDown":return I(!1);case"ArrowUp":return I(!0);case"Enter":if(o.activeSearchItem===-1)o.activeSearchItem=0;else return Le(C),te(o.currentEmojis[o.activeSearchItem].id)}}function Qn(C){const{target:I}=C,U=I.closest(".nav-button");if(!U)return;const W=parseInt(U.dataset.groupId,10);n.searchElement.value="",o.rawSearchText="",o.searchText="",o.activeSearchItem=-1,o.currentGroupIndex=o.groups.findIndex(Z=>Z.id===W)}function bs(C){const{target:I,key:U}=C,W=Z=>{Z&&(Le(C),Z.focus())};switch(U){case"ArrowLeft":return W(I.previousElementSibling);case"ArrowRight":return W(I.nextElementSibling);case"Home":return W(I.parentElement.firstElementChild);case"End":return W(I.parentElement.lastElementChild)}}async function Jn(C){const I=await o.database.getEmojiByUnicodeOrName(C),U=[...o.currentEmojis,...o.currentFavorites].find(Z=>Z.id===C),W=U.unicode&&T(U,o.currentSkinTone);return await o.database.incrementFavoriteEmojiCount(C),{emoji:I,skinTone:o.currentSkinTone,...W&&{unicode:W},...U.name&&{name:U.name}}}async function te(C){const I=Jn(C);h("emoji-click-sync",I),h("emoji-click",await I)}function Yn(C){const{target:I}=C;if(!I.classList.contains("emoji"))return;Le(C);const U=I.id.substring(4);te(U)}function ne(C){o.currentSkinTone=C,o.skinTonePickerExpanded=!1,l("skintone-button"),h("skin-tone-change",{skinTone:C}),o.database.setPreferredSkinTone(C)}function Xn(C){const{target:{id:I}}=C,U=I&&I.match(/^skintone-(\d)/);if(!U)return;Le(C);const W=parseInt(U[1],10);ne(W)}function X(C){o.skinTonePickerExpanded=!o.skinTonePickerExpanded,o.activeSkinTone=o.currentSkinTone,o.skinTonePickerExpanded&&(Le(C),Ti(()=>l("skintone-list")))}a(()=>{o.skinTonePickerExpanded?n.skinToneDropdown.addEventListener("transitionend",()=>{o.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):o.skinTonePickerExpandedAfterAnimation=!1});function pt(C){if(!o.skinTonePickerExpanded)return;const I=async U=>{Le(C),o.activeSkinTone=U};switch(C.key){case"ArrowUp":return I(io(!0,o.activeSkinTone,o.skinTones));case"ArrowDown":return I(io(!1,o.activeSkinTone,o.skinTones));case"Home":return I(0);case"End":return I(o.skinTones.length-1);case"Enter":return Le(C),ne(o.activeSkinTone);case"Escape":return Le(C),o.skinTonePickerExpanded=!1,l("skintone-button")}}function dn(C){if(o.skinTonePickerExpanded&&C.key===" ")return Le(C),ne(o.activeSkinTone)}async function tt(C){const{relatedTarget:I}=C;(!I||I.id!=="skintone-list")&&(o.skinTonePickerExpanded=!1)}function Zn(C){o.rawSearchText=C.target.value}return{$set(C){wi(o,C)},$destroy(){i.abort()}}}const Sb="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Ab="en";var Cb={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"}},Eb=':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 eu=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],Tb=`:host{--emoji-font-family:${Xd}}`;class Ba extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=Eb+Tb,this.shadowRoot.appendChild(n),this._ctx={locale:Ab,dataSource:Sb,skinToneEmoji:Kv,customCategorySorting:Hv,customEmoji:null,i18n:Cb,emojiVersion:null,...t};for(const i of eu)i!=="database"&&Object.prototype.hasOwnProperty.call(this,i)&&(this._ctx[i]=this[i],delete this[i]);this._dbFlush()}connectedCallback(){hl(this),this._cmp||(this._cmp=$b(this.shadowRoot,this._ctx))}disconnectedCallback(){hl(this),Zi(()=>{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,i){this._set(t.replace(/-([a-z])/g,(s,o)=>o.toUpperCase()),t==="emoji-version"?parseFloat(i):i)}_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:i}=this._ctx;(!i||i.locale!==t||i.dataSource!==n)&&this._set("database",new Ov({locale:t,dataSource:n}))}_dbFlush(){Zi(()=>this._dbCreate())}}const tu={};for(const e of eu)tu[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(Ba.prototype,tu);function hl(e){e instanceof Ba||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Ba);function _b(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 fl(e){e.style.height="44px",e.style.overflowY="hidden"}const Mb=5e3;function Pb(e){return e?e.active?u`
|
|
2843
2856
|
<div class="callout info compaction-indicator compaction-indicator--active">
|
|
2844
2857
|
${L.loader} Compacting context...
|
|
2845
2858
|
</div>
|
|
@@ -2847,7 +2860,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
|
|
|
2847
2860
|
<div class="callout success compaction-indicator compaction-indicator--complete">
|
|
2848
2861
|
${L.check} Context compacted
|
|
2849
2862
|
</div>
|
|
2850
|
-
`:w:w}const Qe=5*1024*1024;function Je(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Te(e,t){var i,s,o;let n=(i=e.closest(".chat"))==null?void 0:i.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 a=(s=e.closest(".chat"))==null?void 0:s.querySelector(".chat-compose");(o=a==null?void 0:a.parentElement)==null||o.insertBefore(n,a)}n.textContent=t,setTimeout(()=>n==null?void 0:n.remove(),4e3)}const Ib=/\.(md|txt|csv|json|xml|html|css|js|ts|py|sh|yaml|yml|toml|ini|cfg|log|sql)$/i;function nu(e){return e.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.name)}function iu(e){return e.type.startsWith("text/")||e.type==="application/json"||e.type==="application/xml"||Ib.test(e.name)}function su(e){return e.type==="application/pdf"||/\.pdf$/i.test(e.name)}function ou(e){return e.type.startsWith("video/")||/\.(mp4|webm|mov|avi|mkv|m4v)$/i.test(e.name)}function Lb(e,t){if(!t.onAttachmentsChange)return;const n=document.querySelector(".chat");if(nu(e)){if(e.size>Qe){n&&Te(n,`Image too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Je(),dataUrl:i.result,mimeType:e.type};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(iu(e)){if(e.size>Qe){n&&Te(n,`File too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Je(),dataUrl:"",mimeType:e.type||"text/plain",fileName:e.name,textContent:i.result};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsText(e)}else if(su(e)){if(e.size>Qe){n&&Te(n,`PDF too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Je(),dataUrl:i.result,mimeType:"application/pdf",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(ou(e)){if(e.size>Qe){n&&Te(n,`Video too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Je(),dataUrl:i.result,mimeType:e.type||"video/mp4",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else n&&Te(n,`Unsupported file type: ${e.name}. Use the Files page to upload to workspace.`)}function Rb(e,t){var s;e.preventDefault(),e.stopPropagation();const n=e.currentTarget;n.classList.remove("chat--dragover");const i=(s=e.dataTransfer)==null?void 0:s.files;if(!(!i||i.length===0))for(let o=0;o<i.length;o++){const a=i[o];if(nu(a)){if(!t.onAttachmentsChange)continue;if(a.size>Qe){Te(n,`Image too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const l=r.result,c={id:Je(),dataUrl:l,mimeType:a.type},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsDataURL(a)}else if(iu(a)){if(!t.onAttachmentsChange)continue;if(a.size>Qe){Te(n,`File too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const l=r.result,c={id:Je(),dataUrl:"",mimeType:a.type||"text/plain",fileName:a.name,textContent:l},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsText(a)}else if(su(a)){if(!t.onAttachmentsChange)continue;if(a.size>Qe){Te(n,`PDF too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const l=r.result,c={id:Je(),dataUrl:l,mimeType:"application/pdf",fileName:a.name},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsDataURL(a)}else if(ou(a)){if(!t.onAttachmentsChange)continue;if(a.size>Qe){Te(n,`Video too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const l=r.result,c={id:Je(),dataUrl:l,mimeType:a.type||"video/mp4",fileName:a.name},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsDataURL(a)}else Te(n,`Unsupported file type: ${a.name}. Use the Files page to upload to workspace.`)}}function Db(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),e.currentTarget.classList.add("chat--dragover")}function Bb(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&t.classList.remove("chat--dragover")}function Nb(e,t){var s,o,a;const n=(s=e.clipboardData)==null?void 0:s.items;if(!n||!t.onAttachmentsChange)return;const i=[];for(let r=0;r<n.length;r++){const l=n[r];(l.type.startsWith("image/")||l.type.startsWith("video/"))&&i.push(l)}if(i.length!==0){e.preventDefault();for(const r of i){const l=r.getAsFile();if(!l)continue;const c=l.type.startsWith("video/")?"Video":"Image";if(l.size>Qe){const d=((a=(o=e.target)==null?void 0:o.closest)==null?void 0:a.call(o,".chat"))??document.querySelector(".chat");d&&Te(d,`${c} too large (${(l.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const h=new FileReader;h.onload=()=>{var
|
|
2863
|
+
`:w:w}const Qe=5*1024*1024;function Je(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Te(e,t){var i,s,o;let n=(i=e.closest(".chat"))==null?void 0:i.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 a=(s=e.closest(".chat"))==null?void 0:s.querySelector(".chat-compose");(o=a==null?void 0:a.parentElement)==null||o.insertBefore(n,a)}n.textContent=t,setTimeout(()=>n==null?void 0:n.remove(),4e3)}const Ib=/\.(md|txt|csv|json|xml|html|css|js|ts|py|sh|yaml|yml|toml|ini|cfg|log|sql)$/i;function nu(e){return e.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.name)}function iu(e){return e.type.startsWith("text/")||e.type==="application/json"||e.type==="application/xml"||Ib.test(e.name)}function su(e){return e.type==="application/pdf"||/\.pdf$/i.test(e.name)}function ou(e){return e.type.startsWith("video/")||/\.(mp4|webm|mov|avi|mkv|m4v)$/i.test(e.name)}function Lb(e,t){if(!t.onAttachmentsChange)return;const n=document.querySelector(".chat");if(nu(e)){if(e.size>Qe){n&&Te(n,`Image too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Je(),dataUrl:i.result,mimeType:e.type};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(iu(e)){if(e.size>Qe){n&&Te(n,`File too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Je(),dataUrl:"",mimeType:e.type||"text/plain",fileName:e.name,textContent:i.result};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsText(e)}else if(su(e)){if(e.size>Qe){n&&Te(n,`PDF too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Je(),dataUrl:i.result,mimeType:"application/pdf",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else if(ou(e)){if(e.size>Qe){n&&Te(n,`Video too large (${(e.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);return}const i=new FileReader;i.onload=()=>{var o;const s={id:Je(),dataUrl:i.result,mimeType:e.type||"video/mp4",fileName:e.name};(o=t.onAttachmentsChange)==null||o.call(t,[...t.attachments??[],s])},i.readAsDataURL(e)}else n&&Te(n,`Unsupported file type: ${e.name}. Use the Files page to upload to workspace.`)}function Rb(e,t){var s;e.preventDefault(),e.stopPropagation();const n=e.currentTarget;n.classList.remove("chat--dragover");const i=(s=e.dataTransfer)==null?void 0:s.files;if(!(!i||i.length===0))for(let o=0;o<i.length;o++){const a=i[o];if(nu(a)){if(!t.onAttachmentsChange)continue;if(a.size>Qe){Te(n,`Image too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const l=r.result,c={id:Je(),dataUrl:l,mimeType:a.type},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsDataURL(a)}else if(iu(a)){if(!t.onAttachmentsChange)continue;if(a.size>Qe){Te(n,`File too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const l=r.result,c={id:Je(),dataUrl:"",mimeType:a.type||"text/plain",fileName:a.name,textContent:l},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsText(a)}else if(su(a)){if(!t.onAttachmentsChange)continue;if(a.size>Qe){Te(n,`PDF too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const l=r.result,c={id:Je(),dataUrl:l,mimeType:"application/pdf",fileName:a.name},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsDataURL(a)}else if(ou(a)){if(!t.onAttachmentsChange)continue;if(a.size>Qe){Te(n,`Video too large (${(a.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const r=new FileReader;r.onload=()=>{var d;const l=r.result,c={id:Je(),dataUrl:l,mimeType:a.type||"video/mp4",fileName:a.name},h=t.attachments??[];(d=t.onAttachmentsChange)==null||d.call(t,[...h,c])},r.readAsDataURL(a)}else Te(n,`Unsupported file type: ${a.name}. Use the Files page to upload to workspace.`)}}function Db(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),e.currentTarget.classList.add("chat--dragover")}function Bb(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&t.classList.remove("chat--dragover")}function Nb(e,t){var s,o,a;const n=(s=e.clipboardData)==null?void 0:s.items;if(!n||!t.onAttachmentsChange)return;const i=[];for(let r=0;r<n.length;r++){const l=n[r];(l.type.startsWith("image/")||l.type.startsWith("video/"))&&i.push(l)}if(i.length!==0){e.preventDefault();for(const r of i){const l=r.getAsFile();if(!l)continue;const c=l.type.startsWith("video/")?"Video":"Image";if(l.size>Qe){const d=((a=(o=e.target)==null?void 0:o.closest)==null?void 0:a.call(o,".chat"))??document.querySelector(".chat");d&&Te(d,`${c} too large (${(l.size/1024/1024).toFixed(1)} MB). Maximum is 5 MB.`);continue}const h=new FileReader;h.onload=()=>{var S;const d=h.result,p=l.type.startsWith("video/"),g={id:Je(),dataUrl:d,mimeType:l.type,fileName:p?l.name||"video.mp4":void 0},$=t.attachments??[];(S=t.onAttachmentsChange)==null||S.call(t,[...$,g])},h.readAsDataURL(l)}}}function Ob(e){const t=e.currentTarget,n=t.closest(".chat-compose"),i=n==null?void 0:n.querySelector(".emoji-picker-popup");if(!i)return;const s=i.classList.toggle("active");if(t.classList.toggle("active",s),s){const o=a=>{i.contains(a.target)||t.contains(a.target)||(i.classList.remove("active"),t.classList.remove("active"),document.removeEventListener("click",o,!0))};requestAnimationFrame(()=>document.addEventListener("click",o,!0))}}function Fb(e,t){const n=e.detail,i=n==null?void 0:n.unicode;if(!i)return;const s=e.currentTarget.closest(".chat-compose"),o=s==null?void 0:s.querySelector("textarea");if(!o)return;const a=o.selectionStart??t.draft.length,r=o.selectionEnd??a,l=t.draft.slice(0,a),c=t.draft.slice(r);t.onDraftChange(l+i+c);const h=s==null?void 0:s.querySelector(".emoji-picker-popup"),d=s==null?void 0:s.querySelector(".chat-compose__emoji");h==null||h.classList.remove("active"),d==null||d.classList.remove("active"),requestAnimationFrame(()=>{o.focus();const p=a+i.length;o.setSelectionRange(p,p)})}function Ub(e){const t=e.attachments??[];return t.length===0?w:u`
|
|
2851
2864
|
<div class="chat-attachments">
|
|
2852
2865
|
${t.map(n=>{var i;return n.fileName?u`
|
|
2853
2866
|
<div class="chat-attachment chat-attachment--file">
|
|
@@ -2880,7 +2893,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
|
|
|
2880
2893
|
</div>
|
|
2881
2894
|
`})}
|
|
2882
2895
|
</div>
|
|
2883
|
-
`}function au(e){var S,
|
|
2896
|
+
`}function au(e){var $,S,T;const t=e.connected,n=e.sending||e.stream!==null,i=!!(e.canAbort&&e.onAbort),s=(S=($=e.sessions)==null?void 0:$.sessions)==null?void 0:S.find(f=>f.key===e.sessionKey),o=(s==null?void 0:s.reasoningLevel)??"off",a=e.showThinking&&o!=="off";e.assistantName,e.assistantAvatar??e.assistantAvatarUrl;const r=(((T=e.attachments)==null?void 0:T.length)??0)>0,l=e.connected?r?"Add a message...":"Message...":"Connecting…";jy({onSend:f=>{e.onAttachmentsChange&&e.onAttachmentsChange([...e.attachments??[],f]),requestAnimationFrame(()=>e.onSend())},onRequestRender:()=>{var f;(f=e.requestUpdate)==null||f.call(e)}});const c=Hy(),h=!c&&!e.draft.trim()&&!r&&!n,d=e.splitRatio??.6,p=!!(e.sidebarOpen&&e.onCloseSidebar),g=u`
|
|
2884
2897
|
<div
|
|
2885
2898
|
class="chat-thread"
|
|
2886
2899
|
role="log"
|
|
@@ -2925,7 +2938,7 @@ For details see: https://github.com/nolanlawson/emoji-picker-element/issues/514`
|
|
|
2925
2938
|
class="chat-main"
|
|
2926
2939
|
style="flex: ${p?`0 0 ${d*100}%`:"1 1 100%"}"
|
|
2927
2940
|
>
|
|
2928
|
-
${
|
|
2941
|
+
${g}
|
|
2929
2942
|
${e.nearBottom===!1?u`
|
|
2930
2943
|
<button
|
|
2931
2944
|
class="chat-scroll-bottom"
|
|
@@ -3094,7 +3107,7 @@ ${e.sidebarContent}
|
|
|
3094
3107
|
</label>
|
|
3095
3108
|
</div>
|
|
3096
3109
|
</div>
|
|
3097
|
-
`}function jb(e){const t=[];let n=null;for(const i of e){if(i.kind!=="message"){n&&(t.push(n),n=null),t.push(i);continue}const s=Yl(i.message),o=Xl(s.role),a=s.timestamp||Date.now();!n||n.role!==o?(n&&t.push(n),n={kind:"group",key:`group:${o}:${i.key}`,role:o,messages:[{message:i.message,key:i.key}],timestamp:a,isStreaming:!1}):n.messages.push({message:i.message,key:i.key})}return n&&t.push(n),t}function Gb(e){var o;const t=[],n=Array.isArray(e.messages)?e.messages:[],i=Array.isArray(e.toolMessages)?e.toolMessages:[],s=e.showThinking||e.verboseLevel==="on"||e.verboseLevel==="full";for(let a=0;a<n.length;a++){const r=n[a],l=Yl(r);if(!s&&l.role.toLowerCase()==="toolresult"){const c=r,d=(Array.isArray(c.content)?c.content:[]).filter(p=>{const
|
|
3110
|
+
`}function jb(e){const t=[];let n=null;for(const i of e){if(i.kind!=="message"){n&&(t.push(n),n=null),t.push(i);continue}const s=Yl(i.message),o=Xl(s.role),a=s.timestamp||Date.now();!n||n.role!==o?(n&&t.push(n),n={kind:"group",key:`group:${o}:${i.key}`,role:o,messages:[{message:i.message,key:i.key}],timestamp:a,isStreaming:!1}):n.messages.push({message:i.message,key:i.key})}return n&&t.push(n),t}function Gb(e){var o;const t=[],n=Array.isArray(e.messages)?e.messages:[],i=Array.isArray(e.toolMessages)?e.toolMessages:[],s=e.showThinking||e.verboseLevel==="on"||e.verboseLevel==="full";for(let a=0;a<n.length;a++){const r=n[a],l=Yl(r);if(!s&&l.role.toLowerCase()==="toolresult"){const c=r,d=(Array.isArray(c.content)?c.content:[]).filter(p=>{const g=p.type;return g==="image"||g==="file"});d.length>0&&t.push({kind:"message",key:ro(r,a),message:{role:"assistant",content:d,timestamp:l.timestamp}});continue}t.push({kind:"message",key:ro(r,a),message:r})}if(s)for(let a=0;a<i.length;a++)t.push({kind:"message",key:ro(i[a],a+n.length),message:i[a]});if(e.interimText&&t.push({kind:"interim",key:"interim:thinking",text:e.interimText}),e.stream!==null){const a=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:a,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:a})}for(const a of e.queue){const r=((o=a.attachments)==null?void 0:o.filter(c=>c.fileName).map(c=>c.fileName))??[],l=r.length>0?a.text?`${r.join(", ")}
|
|
3098
3111
|
|
|
3099
3112
|
${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,message:{role:"user",content:[{type:"text",text:l}],timestamp:a.createdAt}})}return jb(t)}function ro(e,t){const n=e,i=typeof n.toolCallId=="string"?n.toolCallId:"";if(i)return`tool:${i}`;const s=typeof n.id=="string"?n.id:"";if(s)return`msg:${s}`;const o=typeof n.messageId=="string"?n.messageId:"";if(o)return`msg:${o}`;const a=typeof n.timestamp=="number"?n.timestamp:null,r=typeof n.role=="string"?n.role:"unknown";return a!=null?`msg:${r}:${a}:${t}`:`msg:${r}:${t}`}const Vb=u`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>`;function Qb(e){if(!e.connected)return u`
|
|
3100
3113
|
<div class="setup-container">
|
|
@@ -3117,7 +3130,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
3117
3130
|
${au(e)}
|
|
3118
3131
|
</div>
|
|
3119
3132
|
</div>
|
|
3120
|
-
`}function Jb(e){return e?`${Gl(e)} (${ss(e)})`:"n/a"}function ru(e){const t=e.state??{},n=t.lastStatus??"n/a",i=t.lastRunAtMs?ss(t.lastRunAtMs):"never";return`${n} · last ${i}`}function lu(e){const t=e.schedule;return t.kind==="at"?`One-time: ${Gl(t.atMs)}`:t.kind==="every"?`Every ${Jo(t.everyMs)}`:Yb(t.expr,t.tz)}function Yb(e,t){const n=e.trim().split(/\s+/);if(n.length!==5)return e;const[i,s,o,a,r]=n,l=t?` (${t.replace(/^.*\//,"").replace(/_/g," ")})`:"",c=(
|
|
3133
|
+
`}function Jb(e){return e?`${Gl(e)} (${ss(e)})`:"n/a"}function ru(e){const t=e.state??{},n=t.lastStatus??"n/a",i=t.lastRunAtMs?ss(t.lastRunAtMs):"never";return`${n} · last ${i}`}function lu(e){const t=e.schedule;return t.kind==="at"?`One-time: ${Gl(t.atMs)}`:t.kind==="every"?`Every ${Jo(t.everyMs)}`:Yb(t.expr,t.tz)}function Yb(e,t){const n=e.trim().split(/\s+/);if(n.length!==5)return e;const[i,s,o,a,r]=n,l=t?` (${t.replace(/^.*\//,"").replace(/_/g," ")})`:"",c=(S,T)=>new Date(2e3,0,1,S,T).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),h=/^\d{1,2}$/.test(i)?parseInt(i,10):null,d=gl(s);if(h===null||!d)return`${e}${t?` (${t})`:""}`;const p=d.map(S=>c(S,h)),g=p.length<=3?p.join(" & "):`${p.slice(0,-1).join(", ")} & ${p[p.length-1]}`,$=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];if(o==="*"&&a==="*"){if(r==="*")return`Daily at ${g}${l}`;if(r==="1-5")return`Weekdays at ${g}${l}`;if(r==="0,6"||r==="6,0")return`Weekends at ${g}${l}`;const S=gl(r);if(S)return`${S.map(f=>$[f%7]??String(f)).join(", ")} at ${g}${l}`}return`${e}${t?` (${t})`:""}`}function gl(e){if(e==="*")return null;if(/^\d+(,\d+)*$/.test(e))return e.split(",").map(Number);if(/^\d+-\d+$/.test(e)){const[t,n]=e.split("-").map(Number);if(t>n)return null;const i=[];for(let s=t;s<=n;s++)i.push(s);return i}return null}function Xb(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 ml(e){const t=e.payload;if(t.kind!=="agentTurn")return null;const n=t.channel??t.provider,i=t.to;if(!i&&!n)return null;const s=[];if(i){const a=i.split(",").map(r=>r.trim()).filter(Boolean).map(r=>r.toLowerCase()==="admins"?"All admins":r);s.push(a.join(", "))}return n&&n!=="last"&&s.push(`via ${n}`),s.join(" ")||null}let we=null;function Zb(e){var s;const t=["last",...e.channels.filter(Boolean)],n=(s=e.form.channel)==null?void 0:s.trim();n&&!t.includes(n)&&t.push(n);const i=new Set;return t.filter(o=>i.has(o)?!1:(i.add(o),!0))}function ew(e,t){var i,s;if(t==="last")return"last";const n=(i=e.channelMeta)==null?void 0:i.find(o=>o.id===t);return n!=null&&n.label?n.label:((s=e.channelLabels)==null?void 0:s[t])??t}function tw(e){return e.split(",").map(n=>n.trim()).filter(Boolean).map(n=>n.toLowerCase()==="admins"?"All admins":n).join(", ")}function nw(e){return e||"Default"}const iw=u`<svg viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>`,sw=u`<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>`,ow=u`<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>`,hs=u`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,aw=u`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,cu=u`<svg viewBox="0 0 24 24"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`,rw=u`<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>`;function yl(e){const t=e.detailJobId?e.jobs.find(i=>i.id===e.detailJobId)??null:null,n=e.newEventModalOpen||!!e.editJobId;return u`
|
|
3121
3134
|
${lw(e)}
|
|
3122
3135
|
${cw(e)}
|
|
3123
3136
|
${n?uw(e):w}
|
|
@@ -3795,14 +3808,14 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
3795
3808
|
<button class="event-modal__close" @click=${e.onAddClose}>×</button>
|
|
3796
3809
|
</div>
|
|
3797
3810
|
|
|
3798
|
-
${i
|
|
3811
|
+
${i?xw(e,n):t?$w(e,n):u`
|
|
3799
3812
|
<div class="muted" style="text-align: center; padding: 32px 16px;">
|
|
3800
3813
|
No drafts available. Ask your assistant to create a skill and it will appear here.
|
|
3801
3814
|
</div>
|
|
3802
3815
|
`}
|
|
3803
3816
|
</div>
|
|
3804
3817
|
</div>
|
|
3805
|
-
`}function
|
|
3818
|
+
`}function xw(e,t){const n=e.addForm,s=e.formSource==="installed"?"Save Skill":"Save Draft",o=n.references.length>0,a=e.editTab||"SKILL.md",r=n.references.find(c=>c.name===a),l=c=>u`
|
|
3806
3819
|
<button
|
|
3807
3820
|
class="chip ${c===a?"chip-ok":""}"
|
|
3808
3821
|
style="cursor: pointer; border: none; background: ${c===a?"var(--accent, #3b82f6)":"var(--bg-hover, rgba(255,255,255,0.06))"}; color: ${c===a?"#fff":"var(--text)"}; padding: 4px 10px; border-radius: 4px; font-size: 12px;"
|
|
@@ -3853,7 +3866,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
3853
3866
|
${t?"Saving…":s}
|
|
3854
3867
|
</button>
|
|
3855
3868
|
</div>
|
|
3856
|
-
`}function
|
|
3869
|
+
`}function $w(e,t){return u`
|
|
3857
3870
|
<div class="card-sub" style="margin-bottom: 16px;">
|
|
3858
3871
|
Skills prepared by your assistant. Review, install, or delete.
|
|
3859
3872
|
</div>
|
|
@@ -4085,19 +4098,19 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
4085
4098
|
<p>Connecting to gateway...</p>
|
|
4086
4099
|
</div>
|
|
4087
4100
|
</div>
|
|
4088
|
-
`}function wl(e){if(!e.show)return w;const t=Ye(),n=e.isFirstTime,i=e.changePinMode===!0&&!n,s=e.changePinBusy===!0;let o=e.accounts.length>0?e.accounts[0].id:"";const a=
|
|
4101
|
+
`}function wl(e){if(!e.show)return w;const t=Ye(),n=e.isFirstTime,i=e.changePinMode===!0&&!n,s=e.changePinBusy===!0;let o=e.accounts.length>0?e.accounts[0].id:"";const a=g=>{var S;o=g.target.value;const $=(S=g.target.closest(".login-card"))==null?void 0:S.querySelector(".login-change-pin");$&&($.style.display=o==="__master__"?"":"none")},r=g=>$=>{const S=$.target;S.value=S.value.replace(/\D/g,"").slice(0,6),g(S.value)},l=g=>{const $=g.currentTarget,S=$.closest(".login-pin-wrapper"),T=S==null?void 0:S.querySelector("input");if(!T)return;const f=T.type==="text";T.type=f?"password":"text",$.classList.toggle("active",!f)},c=!n&&e.accounts.length>1?u`
|
|
4089
4102
|
<select
|
|
4090
4103
|
class="login-account-select"
|
|
4091
4104
|
@change=${a}
|
|
4092
4105
|
?disabled=${e.busy||s}
|
|
4093
4106
|
>
|
|
4094
|
-
${e.accounts.map((
|
|
4095
|
-
<option value=${
|
|
4096
|
-
${
|
|
4107
|
+
${e.accounts.map((g,$)=>u`
|
|
4108
|
+
<option value=${g.id} ?selected=${$===0}>
|
|
4109
|
+
${g.displayName}
|
|
4097
4110
|
</option>
|
|
4098
4111
|
`)}
|
|
4099
4112
|
</select>
|
|
4100
|
-
`:w;if(i){let
|
|
4113
|
+
`:w;if(i){let g="",$="",S="";const T=f=>{var b;f.preventDefault(),!s&&(!g||!$||!S||$===S&&o&&((b=e.onChangePin)==null||b.call(e,o,g,$)))};return u`
|
|
4101
4114
|
<div class="login-overlay">
|
|
4102
4115
|
<div class="login-card">
|
|
4103
4116
|
<img class="login-logo" src="${t.iconUrl}" alt="${t.name}" />
|
|
@@ -4115,7 +4128,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
4115
4128
|
maxlength="6"
|
|
4116
4129
|
placeholder="Current PIN"
|
|
4117
4130
|
?disabled=${s}
|
|
4118
|
-
@input=${r(f=>{
|
|
4131
|
+
@input=${r(f=>{g=f})}
|
|
4119
4132
|
autofocus
|
|
4120
4133
|
/>
|
|
4121
4134
|
<button class="login-pin-toggle" type="button" @click=${l}>
|
|
@@ -4133,7 +4146,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
4133
4146
|
maxlength="6"
|
|
4134
4147
|
placeholder="New PIN (4-6 digits)"
|
|
4135
4148
|
?disabled=${s}
|
|
4136
|
-
@input=${r(f=>{
|
|
4149
|
+
@input=${r(f=>{$=f})}
|
|
4137
4150
|
/>
|
|
4138
4151
|
<button class="login-pin-toggle" type="button" @click=${l}>
|
|
4139
4152
|
<span class="pin-eye-show">${L.eye}</span>
|
|
@@ -4150,7 +4163,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
4150
4163
|
maxlength="6"
|
|
4151
4164
|
placeholder="Confirm new PIN"
|
|
4152
4165
|
?disabled=${s}
|
|
4153
|
-
@input=${r(f=>{
|
|
4166
|
+
@input=${r(f=>{S=f})}
|
|
4154
4167
|
/>
|
|
4155
4168
|
<button class="login-pin-toggle" type="button" @click=${l}>
|
|
4156
4169
|
<span class="pin-eye-show">${L.eye}</span>
|
|
@@ -4174,7 +4187,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
4174
4187
|
</p>
|
|
4175
4188
|
</div>
|
|
4176
4189
|
</div>
|
|
4177
|
-
`}let h="",d="";const p=
|
|
4190
|
+
`}let h="",d="";const p=g=>{if(g.preventDefault(),!e.busy)if(n){if(!h||!d||h!==d)return;e.onSubmit(h)}else{if(!h||!o)return;e.onSubmit(o,h)}};return u`
|
|
4178
4191
|
<div class="login-overlay">
|
|
4179
4192
|
<div class="login-card">
|
|
4180
4193
|
<img class="login-logo" src="${t.iconUrl}" alt="${t.name}" />
|
|
@@ -4194,7 +4207,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
4194
4207
|
maxlength="6"
|
|
4195
4208
|
placeholder="${n?"Choose a 4-6 digit PIN":"PIN"}"
|
|
4196
4209
|
?disabled=${e.busy}
|
|
4197
|
-
@input=${r(
|
|
4210
|
+
@input=${r(g=>{h=g})}
|
|
4198
4211
|
autofocus
|
|
4199
4212
|
/>
|
|
4200
4213
|
<button class="login-pin-toggle" type="button" @click=${l}>
|
|
@@ -4213,7 +4226,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
4213
4226
|
maxlength="6"
|
|
4214
4227
|
placeholder="Confirm PIN"
|
|
4215
4228
|
?disabled=${e.busy}
|
|
4216
|
-
@input=${r(
|
|
4229
|
+
@input=${r(g=>{d=g})}
|
|
4217
4230
|
/>
|
|
4218
4231
|
<button class="login-pin-toggle" type="button" @click=${l}>
|
|
4219
4232
|
<span class="pin-eye-show">${L.eye}</span>
|
|
@@ -4230,11 +4243,11 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
4230
4243
|
${e.busy?u`<span class="login-spinner"></span>`:n?"Set PIN":"Unlock"}
|
|
4231
4244
|
</button>
|
|
4232
4245
|
</form>
|
|
4233
|
-
${n?u`<p class="login-hint">This PIN protects all accounts on this device. You'll need it every time you open the dashboard.</p>`:e.accounts.some(
|
|
4246
|
+
${n?u`<p class="login-hint">This PIN protects all accounts on this device. You'll need it every time you open the dashboard.</p>`:e.accounts.some(g=>g.id==="__master__")?u`<p class="login-hint login-change-pin" style="margin-top: 16px;${o!=="__master__"?" display: none;":""}">
|
|
4234
4247
|
<a
|
|
4235
4248
|
class="login-link"
|
|
4236
4249
|
href="#"
|
|
4237
|
-
@click=${
|
|
4250
|
+
@click=${g=>{var $;g.preventDefault(),($=e.onToggleChangePinMode)==null||$.call(e)}}
|
|
4238
4251
|
>Change PIN</a>
|
|
4239
4252
|
</p>`:w}
|
|
4240
4253
|
</div>
|
|
@@ -4255,7 +4268,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
4255
4268
|
${au(t)}
|
|
4256
4269
|
</div>
|
|
4257
4270
|
</div>
|
|
4258
|
-
`}async function Ow(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 Vn(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 Fw(e,t){var i,s;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 o=await e.client.request("config.get",{});e.configSnapshot=o;const a=o.hash;if(!a){e.workspacesError="Config hash missing; reload and retry.";return}const r={name:n,baseHash:a,whatsappAccountName:n};(i=t.workspacePath)!=null&&i.trim()&&(r.workspaceDir=t.workspacePath.trim());const l=await e.client.request("workspaces.create",r);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await Vn(e),(s=t.onCreated)==null||s.call(t,l)}catch(o){e.workspacesError=String(o)}finally{e.workspaceSaving=!1}}async function Uw(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 i=n.hash;if(!i){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.remove",{name:t,baseHash:i}),e.workspaceRemoveConfirm=null,await Vn(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function Ww(e,t,n){if(!(!e.client||!e.connected)){e.workspacesError=null;try{const i=await e.client.request("config.get",{});e.configSnapshot=i;const s=i.hash;if(!s){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.rename",{name:t,displayName:n,baseHash:s}),await Vn(e)}catch(i){e.workspacesError=String(i)}}}const ki=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:Fw,loadWorkspaces:Vn,removeWorkspace:Uw,renameWorkspace:Ww},Symbol.toStringTag,{value:"Module"})),pu={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",PUBLIC_CHAT:"public-chat"},kl=pu,Wo={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(pu));new Set(Object.values(Wo));function Kw(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),i=e.token??"",s=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),i];return t==="v2"&&s.push(e.nonce??""),s.join("|")}const zw=4008;class qw{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(){var t;this.closed=!0,(t=this.ws)==null||t.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){var t;return((t=this.ws)==null?void 0:t.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=>{var i,s;const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),(s=(i=this.opts).onClose)==null||s.call(i,{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(){var d;if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=this.opts.role??"operator",n=this.opts.scopes??["operator.admin","operator.approvals","operator.pairing"],s=!(t!=="operator")&&typeof crypto<"u"&&!!crypto.subtle;let o=null,a=!1,r=this.opts.token;if(s){o=await Hh();const p=(d=Vh({deviceId:o.deviceId,role:t}))==null?void 0:d.token;r=p??this.opts.token,a=!!(p&&this.opts.token)}const l=r||this.opts.password?{token:r,password:this.opts.password}:void 0;let c;if(s&&o){const p=Date.now(),v=this.connectNonce??void 0,S=Kw({deviceId:o.deviceId,clientId:this.opts.clientName??kl.CONTROL_UI,clientMode:this.opts.mode??Wo.WEBCHAT,role:t,scopes:n,signedAtMs:p,token:r??null,nonce:v}),x=await jh(o.privateKey,S);c={id:o.deviceId,publicKey:o.publicKey,signature:x,signedAt:p,nonce:v}}const h={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??kl.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Wo.WEBCHAT,instanceId:this.opts.instanceId},role:t,scopes:n,device:c,caps:[],auth:l,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",h).then(p=>{var v,S,x;(v=p==null?void 0:p.auth)!=null&&v.deviceToken&&o&&Qh({deviceId:o.deviceId,role:p.auth.role??t,token:p.auth.deviceToken,scopes:p.auth.scopes??[]}),this.backoffMs=800,(x=(S=this.opts).onHello)==null||x.call(S,p)}).catch(()=>{var p;a&&o&&Jh({deviceId:o.deviceId,role:t}),(p=this.ws)==null||p.close(zw,"connect failed")})}handleMessage(t){var s,o,a,r,l,c;let n;try{n=JSON.parse(t)}catch{return}const i=n;if(i.type==="event"){const h=n;if(h.event==="connect.challenge"){const p=h.payload,v=p&&typeof p.nonce=="string"?p.nonce:null;v&&(this.connectNonce=v,this.sendConnect());return}const d=typeof h.seq=="number"?h.seq:null;d!==null&&(this.lastSeq!==null&&d>this.lastSeq+1&&((o=(s=this.opts).onGap)==null||o.call(s,{expected:this.lastSeq+1,received:d})),this.lastSeq=d);try{(r=(a=this.opts).onEvent)==null||r.call(a,h)}catch(p){console.error("[gateway] event handler error:",p)}return}if(i.type==="res"){const h=n,d=this.pending.get(h.id);if(!d)return;if(this.pending.delete(h.id),h.ok)d.resolve(h.payload);else{const p=new Error(((l=h.error)==null?void 0:l.message)??"request failed");p.payload=h.payload,p.details=(c=h.error)==null?void 0:c.details,d.reject(p)}return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const i=os(),s={type:"req",id:i,method:t,params:n},o=new Promise((a,r)=>{this.pending.set(i,{resolve:l=>a(l),reject:r})});return this.ws.send(JSON.stringify(s)),o}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function Ko(e){return typeof e=="object"&&e!==null}function Hw(e){if(!Ko(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Ko(n))return null;const i=typeof n.command=="string"?n.command.trim():"";if(!i)return null;const s=typeof e.createdAtMs=="number"?e.createdAtMs:0,o=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!s||!o?null:{id:t,request:{command:i,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:s,expiresAtMs:o}}function jw(e){if(!Ko(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 hu(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Gw(e,t){const n=hu(e).filter(i=>i.id!==t.id);return n.push(t),n}function $l(e,t){return hu(e).filter(n=>n.id!==t)}class Vw{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){if(n!=null&&n.deviceWidth&&(this.deviceWidth=n.deviceWidth),n!=null&&n.deviceHeight&&(this.deviceHeight=n.deviceHeight),this.pendingFrame=t,!this.canvas){const i=document.getElementById("browser-screencast-canvas");i&&this.attach(i)}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 i=this.canvas.getBoundingClientRect(),s=this.canvas.width/i.width,o=this.canvas.height/i.height,a=this.deviceWidth/this.canvas.width,r=this.deviceHeight/this.canvas.height;return{x:Math.round(t*s*a),y:Math.round(n*o*r)}}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 lo=null;function Bn(){return lo||(lo=new Vw),lo}function Na(e){return e instanceof Error?e.message:String(e)}async function Qw(e){if(!e.client){console.error("[browser] startScreencast: no client"),e.browserError="Not connected to gateway";return}if(!e.connected){console.error("[browser] startScreencast: client exists but not connected"),e.browserError="Not connected to gateway";return}console.log("[browser] startScreencast: sending request"),e.browserLoading=!0,e.browserError=null;try{const t=await e.client.request("browser.screencast.start",{quality:60,maxWidth:1280,maxHeight:720});console.log("[browser] startScreencast response:",t),t!=null&&t.ok?e.browserScreencastActive=!0:(console.warn("[browser] startScreencast: response did not have ok=true",t),e.browserError="Screencast start failed (no ok in response)")}catch(t){console.error("[browser] startScreencast error:",t),e.browserError=Na(t)}finally{e.browserLoading=!1}}async function Jw(e){if(!(!e.client||!e.connected)){e.browserLoading=!0,e.browserFullscreen=!1;try{await e.client.request("browser.screencast.stop",{}),e.browserScreencastActive=!1,e.browserScreencastFrame=null,e.browserScreencastMetadata=null}catch(t){e.browserError=Na(t)}finally{e.browserLoading=!1}}}async function co(e,t,n,i,s){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"mouse",action:t,x:n,y:i,button:s??"left",clickCount:t==="mousePressed"?1:0})}catch{}}async function uo(e,t,n,i){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"key",action:t,key:n,...i!=null&&i.text?{text:i.text}:{},...i!=null&&i.code?{code:i.code}:{},...i!=null&&i.modifiers?{modifiers:i.modifiers}:{}})}catch{}}async function Yw(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=Na(t)}}function Xw(e){e.browserInputMode=!e.browserInputMode}function Zw(e){e.browserFullscreen=!e.browserFullscreen,Bn().detach()}function ek(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,Bn().updateFrame(t.data,t.metadata)}function tk(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function nk(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}async function zo(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),i=n?{sessionKey:n}:{};try{const s=await e.client.request("agent.identity.get",i);if(!s)return;const o=yo(s);e.assistantName=o.name,e.assistantAvatar=o.avatar,e.assistantAgentId=o.agentId??null}catch{}}async function _i(e){return(await e.request("apikeys.list")).providers??[]}async function xl(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function ik(e,t){await e.request("apikeys.remove",{provider:t})}async function sk(e,t,n){await e.request("apikeys.disable",{provider:t,disabled:n})}const es="taskmaster_update_pending";async function fu(e){var t,n;if(!(!e.client||!e.connected)&&!e.updateChecking){e.updateChecking=!0,e.updateMessage=null,(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("update.status",{});e.currentVersion=i.current,e.latestVersion=i.latest,e.updateAvailable=i.updateAvailable,e.updateMessage=i.updateAvailable?`v${i.latest} available`:"Up to date"}catch(i){e.updateMessage=`Check failed: ${String(i)}`,e.updateAvailable=null}finally{e.updateChecking=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function ok(e){var t,n,i,s;if(!(!e.client||e.updateRunning)){e.updateRunning=!0,e.updateMessage="Starting update...",e.updateProgressSteps=[],e.updateLastResult=null,(t=e.requestUpdate)==null||t.call(e);try{localStorage.setItem(es,String(Date.now())),localStorage.removeItem(Oa)}catch{}try{const o=await e.client.request("update.run",{restartDelayMs:2e3,note:"Update from setup page"});if(o.ok&&o.result.status==="ok")e.updateMessage="Updated — restarting gateway...",(n=e.requestUpdate)==null||n.call(e);else if(o.ok&&o.result.status==="skipped")Nn(),e.updateMessage=o.result.reason||"Update skipped",e.updateRunning=!1,(i=e.requestUpdate)==null||i.call(e);else throw Nn(),new Error(o.result.reason||"Update failed")}catch(o){Nn(),e.updateMessage=`Update failed: ${String(o)}`,e.updateRunning=!1,e.updateProgressSteps=[],(s=e.requestUpdate)==null||s.call(e)}}}function ak(e,t){var i,s,o;const n=t.phase;if(n==="step-start"){const a=t.name,r=t.index,l=t.total;e.updateMessage=`Updating: ${a} (${r+1}/${l})`;const c=e.updateProgressSteps.find(h=>h.index===r);c?(c.status="running",c.name=a):e.updateProgressSteps=[...e.updateProgressSteps,{name:a,index:r,total:l,status:"running"}],(i=e.requestUpdate)==null||i.call(e)}else if(n==="step-done"){const a=t.name,r=t.index,l=t.total,c=t.ok,h=t.durationMs,d=e.updateProgressSteps.find(v=>v.index===r);d?(d.status=c?"done":"failed",d.durationMs=h):e.updateProgressSteps=[...e.updateProgressSteps,{name:a,index:r,total:l,status:c?"done":"failed",durationMs:h}];const p=!c&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=c?`Updating: ${a} done (${r+1}/${l})`:`Update step failed: ${a}${p}`,(s=e.requestUpdate)==null||s.call(e)}else if(n==="complete"){if(t.status==="ok")e.updateMessage="Update complete — restarting gateway...";else{const r=t.reason;e.updateMessage=r?`Update failed: ${r}`:"Update failed",e.updateRunning=!1,Nn()}(o=e.requestUpdate)==null||o.call(e)}}async function rk(e){var n,i,s,o;if(!e.client||!e.connected)return;const t=ck();Nn();try{const a=await e.client.request("update.lastResult",{});if(!a.ok||!a.result)return;const r=5*6e4,l=Date.now()-a.result.ts<r;if(!t&&!l||dk(a.result.ts))return;e.updateLastResult=a.result;const c=(n=a.result.after)==null?void 0:n.version;if(a.result.status==="ok"&&c&&(e.currentVersion=c),e.updateAvailable=!1,a.result.status==="ok"){const h=(i=a.result.before)==null?void 0:i.version,d=c??a.result.currentVersion;e.updateMessage=h?`Updated: v${h} → v${d}`:`Updated to v${d}`}else{const h=a.result.reason??((s=a.result.failedStep)==null?void 0:s.name)??"unknown error";e.updateMessage=`Update failed: ${h}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],(o=e.requestUpdate)==null||o.call(e)}}const Oa="taskmaster_update_dismissed";function lk(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(Oa,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function ck(){try{const e=localStorage.getItem(es);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(es),!1):!0:!1}catch{return!1}}function Nn(){try{localStorage.removeItem(es)}catch{}}function dk(e){try{const t=localStorage.getItem(Oa);return t?Number(t)>=e:!1}catch{return!1}}function po(e,t){var r,l,c;const n=(e??"").trim(),i=(r=t.mainSessionKey)==null?void 0:r.trim();if(!i)return n;if(!n)return i;const s=((l=t.mainKey)==null?void 0:l.trim())||"main",o=(c=t.defaultAgentId)==null?void 0:c.trim();return n==="main"||n===s||o&&(n===`agent:${o}:main`||n===`agent:${o}:${s}`)?i:n}function uk(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=po(e.sessionKey,t),i=po(e.settings.sessionKey,t),s=po(e.settings.lastActiveSessionKey,t),o=n||i||e.sessionKey,a={...e.settings,sessionKey:i||o,lastActiveSessionKey:s||o},r=a.sessionKey!==e.settings.sessionKey||a.lastActiveSessionKey!==e.settings.lastActiveSessionKey;o!==e.sessionKey&&(e.sessionKey=o),r&&rt(e,a)}function De(e){var s;e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;const t=!!e.publicChat,n=e.setup||e.filesPage||e.browserPage||e.chatPage||e.adminsPage||e.contactsPage||e.advancedPage,i=t?"public-chat":n?"setup-ui":"taskmaster-control-ui";(s=e.client)==null||s.stop(),e.client=new qw({url:e.settings.gatewayUrl,token:t?void 0:e.settings.token.trim()?e.settings.token:void 0,password:t?void 0:e.password.trim()?e.password:void 0,clientName:i,mode:"webchat",role:t?"public":void 0,scopes:t?[]:void 0,onHello:o=>{var a;if(e.connected=!0,e.lastError=null,e.hello=o,t){Sl(e,o),zo(e),(((a=e.publicChatConfig)==null?void 0:a.auth)??"anonymous")==="anonymous"&&bk(e);return}Ki()&&(va(),e.uninstallDone=!1),Sl(e,o),e.handleAccessCheck(),rk(e).then(()=>{fu(e)}),zo(e),Ow(e),(e.chatPage||e.setup)&&fk(e),ra(e,{quiet:!0}),aa(e,{quiet:!0}),Vn(e).then(()=>{e.initWorkspaceSelection()}),e.startEmbeddingPoll(),(e.setup||e.chatPage)&&Ue(e),e.setup&&(gk(e),mk(e),yk(e),vk(e)),Ui(e)},onClose:({code:o,reason:a})=>{e.connected=!1,o!==1012&&(e.lastError=`disconnected (${o}): ${a||"no reason"}`)},onEvent:o=>pk(e,o),onGap:({expected:o,received:a})=>{console.warn(`[gateway] event gap: expected seq ${o}, got ${a}`),Ui(e)}}),e.client.start()}function pk(e,t){try{hk(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function hk(e,t){var n;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;Jp(e,t.payload);return}if(t.event==="chat"){const i=t.payload;i!=null&&i.sessionKey&&ed(e,i.sessionKey);const s=nc(e,i);if((s==="final"||s==="error"||s==="aborted")&&(Xo(e),Kf(e)),s==="final"){const o=e,a=Math.max((((n=o.chatMessages)==null?void 0:n.length)??0)+10,Fe);Oe(o,{limit:a})}return}if(t.event==="suggestions"){const i=t.payload;(i==null?void 0:i.sessionKey)===e.sessionKey&&Array.isArray(i.suggestions)&&i.suggestions.length>0&&(e.chatSuggestions=i.suggestions);return}if(t.event==="presence"){const i=t.payload;i!=null&&i.presence&&Array.isArray(i.presence)&&(e.presenceEntries=i.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"){const i=t.payload;i&&uh(e,i),e.tab==="cron"&&ma(e)}if((t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&aa(e,{quiet:!0}),t.event==="exec.approval.requested"){const i=Hw(t.payload);if(i){e.execApprovalQueue=Gw(e.execApprovalQueue,i),e.execApprovalError=null;const s=Math.max(0,i.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=$l(e.execApprovalQueue,i.id)},s)}return}if(t.event==="browser.screencast.frame"){ek(e,t.payload);return}if(t.event==="browser.handoff"){tk(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){nk(e);return}if(t.event==="exec.approval.resolved"){const i=jw(t.payload);i&&(e.execApprovalQueue=$l(e.execApprovalQueue,i.id));return}if(t.event==="update.progress"){ak(e,t.payload);return}}function Sl(e,t){const n=t.snapshot;n!=null&&n.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n!=null&&n.health&&(e.debugHealth=n.health),n!=null&&n.sessionDefaults&&uk(e,n.sessionDefaults)}async function fk(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("models.list",{});Array.isArray(t==null?void 0:t.models)&&(e.chatModelCatalog=t.models)}catch{}}async function gk(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await _i(e.client)}catch{}}async function mk(e){if(!(!e.client||!e.connected))try{e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null}catch{}}async function yk(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("wifi.status");if(e.wifiStatus=t,t!=null&&t.connected&&t.signal==null)try{const[n,i]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(e.wifiStatus=i,i.signal==null&&n.networks){const s=n.networks.find(o=>o.active);s&&(e.wifiStatus={...i,signal:s.signal})}}catch{}}catch{}}async function vk(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("network.status");e.networkPort=t.port,e.networkHostname=t.hostname,e.networkPortInput=String(t.port),e.networkHostnameInput=t.hostname}catch{}}const Al="taskmaster_public_id";function gu(e=30){var s;const t=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(`${Al}=`));if(t)return t.split("=")[1];const n=`anon-${((s=crypto.randomUUID)==null?void 0:s.call(crypto))??Math.random().toString(36).slice(2)}`,i=new Date(Date.now()+e*864e5).toUTCString();return document.cookie=`${Al}=${n}; path=/; expires=${i}; SameSite=Lax`,n}async function bk(e){var n,i,s;if(!e.client||!e.connected)return;const t=gu((n=e.publicChatConfig)==null?void 0:n.cookieTtlDays);try{const o=(i=e.publicChatConfig)==null?void 0:i.accountId,a=await e.client.request("public.session",{cookieId:t,accountId:o});if(a!=null&&a.sessionKey){e.publicChatSessionKey=a.sessionKey,e.sessionKey=a.sessionKey,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready";const r=((s=e.publicChatConfig)==null?void 0:s.accountId)??"";e.chatMessage=Kn(r,a.sessionKey),Oe(e)}}catch(o){console.error("[public-chat] failed to resolve anonymous session:",o),e.lastError="Failed to start chat session"}}let he=!1,ie=null,Zt="",en="",tn="",fs="",cn="phone",On="";function mu(e){return e.replace(/[\s\-()]/g,"")}function st(){he=!1,ie=null,Zt="",en="",tn="",fs="",cn="phone",On=""}async function wk(e){if(!e.client||!e.connected)return;const t=gu(e.cookieTtlDays);try{const n=await e.client.request("public.session",{cookieId:t,accountId:e.accountId});n!=null&&n.sessionKey&&e.onAuthenticated(n.sessionKey)}catch(n){ie=n instanceof Error?n.message:"Failed to start session",e.requestUpdate()}}async function Cl(e){if(!e.client||he)return;const t=mu(Zt);if(!t){ie="Please enter your phone number",e.requestUpdate();return}he=!0,ie=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{phone:t,name:tn.trim()||void 0,accountId:e.accountId,channel:On||void 0});n!=null&&n.ok?(fs=n.channel??"",cn="phone",e.onAuthStepChange("otp")):ie=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){ie=n instanceof Error?n.message:"Failed to send verification code"}finally{he=!1,e.requestUpdate()}}async function El(e){if(!e.client||he)return;const t=en.trim().toLowerCase();if(!t||!t.includes("@")){ie="Please enter a valid email address",e.requestUpdate();return}he=!0,ie=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{identifier:t,accountId:e.accountId});n!=null&&n.ok?(fs=n.channel??"email",cn="email",e.onAuthStepChange("otp")):ie=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){ie=n instanceof Error?n.message:"Failed to send verification code"}finally{he=!1,e.requestUpdate()}}async function Tl(e,t){if(!(!e.client||he)){if(!t.trim()){ie="Please enter the verification code",e.requestUpdate();return}he=!0,ie=null,e.requestUpdate();try{const n=cn==="email"?en.trim().toLowerCase():mu(Zt),i=await e.client.request("public.otp.verify",{identifier:n,code:t.trim(),accountId:e.accountId});i!=null&&i.ok&&i.sessionKey?(st(),e.onAuthenticated(i.sessionKey)):ie=(i==null?void 0:i.error)??"Invalid verification code"}catch(n){ie=n instanceof Error?n.message:"Verification failed"}finally{he=!1,e.requestUpdate()}}}function Ge(e){return w}function $i(e){return u`
|
|
4271
|
+
`}async function Ow(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 Vn(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 Fw(e,t){var i,s;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 o=await e.client.request("config.get",{});e.configSnapshot=o;const a=o.hash;if(!a){e.workspacesError="Config hash missing; reload and retry.";return}const r={name:n,baseHash:a,whatsappAccountName:n};(i=t.workspacePath)!=null&&i.trim()&&(r.workspaceDir=t.workspacePath.trim());const l=await e.client.request("workspaces.create",r);e.addingWorkspace=!1,e.newWorkspaceName="",e.newWorkspacePath="",await Vn(e),(s=t.onCreated)==null||s.call(t,l)}catch(o){e.workspacesError=String(o)}finally{e.workspaceSaving=!1}}async function Uw(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 i=n.hash;if(!i){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.remove",{name:t,baseHash:i}),e.workspaceRemoveConfirm=null,await Vn(e)}catch(n){e.workspacesError=String(n)}finally{e.workspaceSaving=!1}}}async function Ww(e,t,n){if(!(!e.client||!e.connected)){e.workspacesError=null;try{const i=await e.client.request("config.get",{});e.configSnapshot=i;const s=i.hash;if(!s){e.workspacesError="Config hash missing; reload and retry.";return}await e.client.request("workspaces.rename",{name:t,displayName:n,baseHash:s}),await Vn(e)}catch(i){e.workspacesError=String(i)}}}const ki=Object.freeze(Object.defineProperty({__proto__:null,createWorkspace:Fw,loadWorkspaces:Vn,removeWorkspace:Uw,renameWorkspace:Ww},Symbol.toStringTag,{value:"Module"})),pu={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",PUBLIC_CHAT:"public-chat"},kl=pu,Wo={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(pu));new Set(Object.values(Wo));function Kw(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),i=e.token??"",s=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),i];return t==="v2"&&s.push(e.nonce??""),s.join("|")}const zw=4008;class qw{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(){var t;this.closed=!0,(t=this.ws)==null||t.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){var t;return((t=this.ws)==null?void 0:t.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=>{var i,s;const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),(s=(i=this.opts).onClose)==null||s.call(i,{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(){var d;if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=this.opts.role??"operator",n=this.opts.scopes??["operator.admin","operator.approvals","operator.pairing"],s=!(t!=="operator")&&typeof crypto<"u"&&!!crypto.subtle;let o=null,a=!1,r=this.opts.token;if(s){o=await Hh();const p=(d=Vh({deviceId:o.deviceId,role:t}))==null?void 0:d.token;r=p??this.opts.token,a=!!(p&&this.opts.token)}const l=r||this.opts.password?{token:r,password:this.opts.password}:void 0;let c;if(s&&o){const p=Date.now(),g=this.connectNonce??void 0,$=Kw({deviceId:o.deviceId,clientId:this.opts.clientName??kl.CONTROL_UI,clientMode:this.opts.mode??Wo.WEBCHAT,role:t,scopes:n,signedAtMs:p,token:r??null,nonce:g}),S=await jh(o.privateKey,$);c={id:o.deviceId,publicKey:o.publicKey,signature:S,signedAt:p,nonce:g}}const h={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??kl.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Wo.WEBCHAT,instanceId:this.opts.instanceId},role:t,scopes:n,device:c,caps:[],auth:l,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",h).then(p=>{var g,$,S;(g=p==null?void 0:p.auth)!=null&&g.deviceToken&&o&&Qh({deviceId:o.deviceId,role:p.auth.role??t,token:p.auth.deviceToken,scopes:p.auth.scopes??[]}),this.backoffMs=800,(S=($=this.opts).onHello)==null||S.call($,p)}).catch(()=>{var p;a&&o&&Jh({deviceId:o.deviceId,role:t}),(p=this.ws)==null||p.close(zw,"connect failed")})}handleMessage(t){var s,o,a,r,l,c;let n;try{n=JSON.parse(t)}catch{return}const i=n;if(i.type==="event"){const h=n;if(h.event==="connect.challenge"){const p=h.payload,g=p&&typeof p.nonce=="string"?p.nonce:null;g&&(this.connectNonce=g,this.sendConnect());return}const d=typeof h.seq=="number"?h.seq:null;d!==null&&(this.lastSeq!==null&&d>this.lastSeq+1&&((o=(s=this.opts).onGap)==null||o.call(s,{expected:this.lastSeq+1,received:d})),this.lastSeq=d);try{(r=(a=this.opts).onEvent)==null||r.call(a,h)}catch(p){console.error("[gateway] event handler error:",p)}return}if(i.type==="res"){const h=n,d=this.pending.get(h.id);if(!d)return;if(this.pending.delete(h.id),h.ok)d.resolve(h.payload);else{const p=new Error(((l=h.error)==null?void 0:l.message)??"request failed");p.payload=h.payload,p.details=(c=h.error)==null?void 0:c.details,d.reject(p)}return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const i=os(),s={type:"req",id:i,method:t,params:n},o=new Promise((a,r)=>{this.pending.set(i,{resolve:l=>a(l),reject:r})});return this.ws.send(JSON.stringify(s)),o}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function Ko(e){return typeof e=="object"&&e!==null}function Hw(e){if(!Ko(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Ko(n))return null;const i=typeof n.command=="string"?n.command.trim():"";if(!i)return null;const s=typeof e.createdAtMs=="number"?e.createdAtMs:0,o=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!s||!o?null:{id:t,request:{command:i,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:s,expiresAtMs:o}}function jw(e){if(!Ko(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 hu(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Gw(e,t){const n=hu(e).filter(i=>i.id!==t.id);return n.push(t),n}function xl(e,t){return hu(e).filter(n=>n.id!==t)}class Vw{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){if(n!=null&&n.deviceWidth&&(this.deviceWidth=n.deviceWidth),n!=null&&n.deviceHeight&&(this.deviceHeight=n.deviceHeight),this.pendingFrame=t,!this.canvas){const i=document.getElementById("browser-screencast-canvas");i&&this.attach(i)}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 i=this.canvas.getBoundingClientRect(),s=this.canvas.width/i.width,o=this.canvas.height/i.height,a=this.deviceWidth/this.canvas.width,r=this.deviceHeight/this.canvas.height;return{x:Math.round(t*s*a),y:Math.round(n*o*r)}}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 lo=null;function Bn(){return lo||(lo=new Vw),lo}function Na(e){return e instanceof Error?e.message:String(e)}async function Qw(e){if(!e.client){console.error("[browser] startScreencast: no client"),e.browserError="Not connected to gateway";return}if(!e.connected){console.error("[browser] startScreencast: client exists but not connected"),e.browserError="Not connected to gateway";return}console.log("[browser] startScreencast: sending request"),e.browserLoading=!0,e.browserError=null;try{const t=await e.client.request("browser.screencast.start",{quality:60,maxWidth:1280,maxHeight:720});console.log("[browser] startScreencast response:",t),t!=null&&t.ok?e.browserScreencastActive=!0:(console.warn("[browser] startScreencast: response did not have ok=true",t),e.browserError="Screencast start failed (no ok in response)")}catch(t){console.error("[browser] startScreencast error:",t),e.browserError=Na(t)}finally{e.browserLoading=!1}}async function Jw(e){if(!(!e.client||!e.connected)){e.browserLoading=!0,e.browserFullscreen=!1;try{await e.client.request("browser.screencast.stop",{}),e.browserScreencastActive=!1,e.browserScreencastFrame=null,e.browserScreencastMetadata=null}catch(t){e.browserError=Na(t)}finally{e.browserLoading=!1}}}async function co(e,t,n,i,s){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"mouse",action:t,x:n,y:i,button:s??"left",clickCount:t==="mousePressed"?1:0})}catch{}}async function uo(e,t,n,i){if(!(!e.client||!e.connected||!e.browserInputMode))try{await e.client.request("browser.screencast.input",{type:"key",action:t,key:n,...i!=null&&i.text?{text:i.text}:{},...i!=null&&i.code?{code:i.code}:{},...i!=null&&i.modifiers?{modifiers:i.modifiers}:{}})}catch{}}async function Yw(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=Na(t)}}function Xw(e){e.browserInputMode=!e.browserInputMode}function Zw(e){e.browserFullscreen=!e.browserFullscreen,Bn().detach()}function ek(e,t){if(!(t!=null&&t.data))return;e.browserScreencastFrame=t.data,e.browserScreencastMetadata=t.metadata??null,Bn().updateFrame(t.data,t.metadata)}function tk(e,t){t&&(e.browserHandoffPending=!0,e.browserHandoffReason=t.reason??"Action required",e.browserHandoffId=t.id??null)}function nk(e){e.browserHandoffPending=!1,e.browserHandoffReason=null,e.browserHandoffId=null}async function zo(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),i=n?{sessionKey:n}:{};try{const s=await e.client.request("agent.identity.get",i);if(!s)return;const o=yo(s);e.assistantName=o.name,e.assistantAvatar=o.avatar,e.assistantAgentId=o.agentId??null}catch{}}async function _i(e){return(await e.request("apikeys.list")).providers??[]}async function $l(e,t,n){await e.request("apikeys.set",{provider:t,apiKey:n})}async function ik(e,t){await e.request("apikeys.remove",{provider:t})}async function sk(e,t,n){await e.request("apikeys.disable",{provider:t,disabled:n})}const es="taskmaster_update_pending";async function fu(e){var t,n;if(!(!e.client||!e.connected)&&!e.updateChecking){e.updateChecking=!0,e.updateMessage=null,(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("update.status",{});e.currentVersion=i.current,e.latestVersion=i.latest,e.updateAvailable=i.updateAvailable,e.updateMessage=i.updateAvailable?`v${i.latest} available`:"Up to date"}catch(i){e.updateMessage=`Check failed: ${String(i)}`,e.updateAvailable=null}finally{e.updateChecking=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function ok(e){var t,n,i,s;if(!(!e.client||e.updateRunning)){e.updateRunning=!0,e.updateMessage="Starting update...",e.updateProgressSteps=[],e.updateLastResult=null,(t=e.requestUpdate)==null||t.call(e);try{localStorage.setItem(es,String(Date.now())),localStorage.removeItem(Oa)}catch{}try{const o=await e.client.request("update.run",{restartDelayMs:2e3,note:"Update from setup page"});if(o.ok&&o.result.status==="ok")e.updateMessage="Updated — restarting gateway...",(n=e.requestUpdate)==null||n.call(e);else if(o.ok&&o.result.status==="skipped")Nn(),e.updateMessage=o.result.reason||"Update skipped",e.updateRunning=!1,(i=e.requestUpdate)==null||i.call(e);else throw Nn(),new Error(o.result.reason||"Update failed")}catch(o){Nn(),e.updateMessage=`Update failed: ${String(o)}`,e.updateRunning=!1,e.updateProgressSteps=[],(s=e.requestUpdate)==null||s.call(e)}}}function ak(e,t){var i,s,o;const n=t.phase;if(n==="step-start"){const a=t.name,r=t.index,l=t.total;e.updateMessage=`Updating: ${a} (${r+1}/${l})`;const c=e.updateProgressSteps.find(h=>h.index===r);c?(c.status="running",c.name=a):e.updateProgressSteps=[...e.updateProgressSteps,{name:a,index:r,total:l,status:"running"}],(i=e.requestUpdate)==null||i.call(e)}else if(n==="step-done"){const a=t.name,r=t.index,l=t.total,c=t.ok,h=t.durationMs,d=e.updateProgressSteps.find(g=>g.index===r);d?(d.status=c?"done":"failed",d.durationMs=h):e.updateProgressSteps=[...e.updateProgressSteps,{name:a,index:r,total:l,status:c?"done":"failed",durationMs:h}];const p=!c&&t.error?`: ${t.error.slice(0,200)}`:"";e.updateMessage=c?`Updating: ${a} done (${r+1}/${l})`:`Update step failed: ${a}${p}`,(s=e.requestUpdate)==null||s.call(e)}else if(n==="complete"){if(t.status==="ok")e.updateMessage="Update complete — restarting gateway...";else{const r=t.reason;e.updateMessage=r?`Update failed: ${r}`:"Update failed",e.updateRunning=!1,Nn()}(o=e.requestUpdate)==null||o.call(e)}}async function rk(e){var n,i,s,o;if(!e.client||!e.connected)return;const t=ck();Nn();try{const a=await e.client.request("update.lastResult",{});if(!a.ok||!a.result)return;const r=5*6e4,l=Date.now()-a.result.ts<r;if(!t&&!l||dk(a.result.ts))return;e.updateLastResult=a.result;const c=(n=a.result.after)==null?void 0:n.version;if(a.result.status==="ok"&&c&&(e.currentVersion=c),e.updateAvailable=!1,a.result.status==="ok"){const h=(i=a.result.before)==null?void 0:i.version,d=c??a.result.currentVersion;e.updateMessage=h?`Updated: v${h} → v${d}`:`Updated to v${d}`}else{const h=a.result.reason??((s=a.result.failedStep)==null?void 0:s.name)??"unknown error";e.updateMessage=`Update failed: ${h}`}}catch{}finally{e.updateRunning=!1,e.updateProgressSteps=[],(o=e.requestUpdate)==null||o.call(e)}}const Oa="taskmaster_update_dismissed";function lk(e){var t;e.updateLastResult=null,e.updateMessage=null;try{localStorage.setItem(Oa,String(Date.now()))}catch{}(t=e.requestUpdate)==null||t.call(e)}function ck(){try{const e=localStorage.getItem(es);return e?Date.now()-Number(e)>30*6e4?(localStorage.removeItem(es),!1):!0:!1}catch{return!1}}function Nn(){try{localStorage.removeItem(es)}catch{}}function dk(e){try{const t=localStorage.getItem(Oa);return t?Number(t)>=e:!1}catch{return!1}}function po(e,t){var r,l,c;const n=(e??"").trim(),i=(r=t.mainSessionKey)==null?void 0:r.trim();if(!i)return n;if(!n)return i;const s=((l=t.mainKey)==null?void 0:l.trim())||"main",o=(c=t.defaultAgentId)==null?void 0:c.trim();return n==="main"||n===s||o&&(n===`agent:${o}:main`||n===`agent:${o}:${s}`)?i:n}function uk(e,t){if(!(t!=null&&t.mainSessionKey))return;const n=po(e.sessionKey,t),i=po(e.settings.sessionKey,t),s=po(e.settings.lastActiveSessionKey,t),o=n||i||e.sessionKey,a={...e.settings,sessionKey:i||o,lastActiveSessionKey:s||o},r=a.sessionKey!==e.settings.sessionKey||a.lastActiveSessionKey!==e.settings.lastActiveSessionKey;o!==e.sessionKey&&(e.sessionKey=o),r&&rt(e,a)}function De(e){var s;e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null;const t=!!e.publicChat,n=e.setup||e.filesPage||e.browserPage||e.chatPage||e.adminsPage||e.contactsPage||e.advancedPage,i=t?"public-chat":n?"setup-ui":"taskmaster-control-ui";(s=e.client)==null||s.stop(),e.client=new qw({url:e.settings.gatewayUrl,token:t?void 0:e.settings.token.trim()?e.settings.token:void 0,password:t?void 0:e.password.trim()?e.password:void 0,clientName:i,mode:"webchat",role:t?"public":void 0,scopes:t?[]:void 0,onHello:o=>{var a;if(e.connected=!0,e.lastError=null,e.hello=o,t){Sl(e,o),zo(e),(((a=e.publicChatConfig)==null?void 0:a.auth)??"anonymous")==="anonymous"&&bk(e);return}Ki()&&(va(),e.uninstallDone=!1),Sl(e,o),e.handleAccessCheck(),rk(e).then(()=>{fu(e)}),zo(e),Ow(e),(e.chatPage||e.setup)&&fk(e),ra(e,{quiet:!0}),aa(e,{quiet:!0}),Vn(e).then(()=>{e.initWorkspaceSelection()}),e.startEmbeddingPoll(),(e.setup||e.chatPage)&&Ue(e),e.setup&&(gk(e),mk(e),yk(e),vk(e)),Ui(e)},onClose:({code:o,reason:a})=>{e.connected=!1,o!==1012&&(e.lastError=`disconnected (${o}): ${a||"no reason"}`)},onEvent:o=>pk(e,o),onGap:({expected:o,received:a})=>{console.warn(`[gateway] event gap: expected seq ${o}, got ${a}`),Ui(e)}}),e.client.start()}function pk(e,t){try{hk(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function hk(e,t){var n;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;Jp(e,t.payload);return}if(t.event==="chat"){const i=t.payload;i!=null&&i.sessionKey&&ed(e,i.sessionKey);const s=nc(e,i);if((s==="final"||s==="error"||s==="aborted")&&(Xo(e),Kf(e)),s==="final"){const o=e,a=Math.max((((n=o.chatMessages)==null?void 0:n.length)??0)+10,Fe);Oe(o,{limit:a})}return}if(t.event==="suggestions"){const i=t.payload;(i==null?void 0:i.sessionKey)===e.sessionKey&&Array.isArray(i.suggestions)&&i.suggestions.length>0&&(e.chatSuggestions=i.suggestions);return}if(t.event==="presence"){const i=t.payload;i!=null&&i.presence&&Array.isArray(i.presence)&&(e.presenceEntries=i.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"){const i=t.payload;i&&uh(e,i),e.tab==="cron"&&ma(e)}if((t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&aa(e,{quiet:!0}),t.event==="exec.approval.requested"){const i=Hw(t.payload);if(i){e.execApprovalQueue=Gw(e.execApprovalQueue,i),e.execApprovalError=null;const s=Math.max(0,i.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=xl(e.execApprovalQueue,i.id)},s)}return}if(t.event==="browser.screencast.frame"){ek(e,t.payload);return}if(t.event==="browser.handoff"){tk(e,t.payload),e.browserPage||(window.location.href="/browser");return}if(t.event==="browser.handoff.resolved"){nk(e);return}if(t.event==="exec.approval.resolved"){const i=jw(t.payload);i&&(e.execApprovalQueue=xl(e.execApprovalQueue,i.id));return}if(t.event==="update.progress"){ak(e,t.payload);return}}function Sl(e,t){const n=t.snapshot;n!=null&&n.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n!=null&&n.health&&(e.debugHealth=n.health),n!=null&&n.sessionDefaults&&uk(e,n.sessionDefaults)}async function fk(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("models.list",{});Array.isArray(t==null?void 0:t.models)&&(e.chatModelCatalog=t.models)}catch{}}async function gk(e){if(!(!e.client||!e.connected))try{e.apiKeyProviders=await _i(e.client)}catch{}}async function mk(e){if(!(!e.client||!e.connected))try{e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null}catch{}}async function yk(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("wifi.status");if(e.wifiStatus=t,t!=null&&t.connected&&t.signal==null)try{const[n,i]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(e.wifiStatus=i,i.signal==null&&n.networks){const s=n.networks.find(o=>o.active);s&&(e.wifiStatus={...i,signal:s.signal})}}catch{}}catch{}}async function vk(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("network.status");e.networkPort=t.port,e.networkHostname=t.hostname,e.networkPortInput=String(t.port),e.networkHostnameInput=t.hostname}catch{}}const Al="taskmaster_public_id";function gu(e=30){var s;const t=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(`${Al}=`));if(t)return t.split("=")[1];const n=`anon-${((s=crypto.randomUUID)==null?void 0:s.call(crypto))??Math.random().toString(36).slice(2)}`,i=new Date(Date.now()+e*864e5).toUTCString();return document.cookie=`${Al}=${n}; path=/; expires=${i}; SameSite=Lax`,n}async function bk(e){var n,i,s;if(!e.client||!e.connected)return;const t=gu((n=e.publicChatConfig)==null?void 0:n.cookieTtlDays);try{const o=(i=e.publicChatConfig)==null?void 0:i.accountId,a=await e.client.request("public.session",{cookieId:t,accountId:o});if(a!=null&&a.sessionKey){e.publicChatSessionKey=a.sessionKey,e.sessionKey=a.sessionKey,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready";const r=((s=e.publicChatConfig)==null?void 0:s.accountId)??"";e.chatMessage=Kn(r,a.sessionKey),Oe(e)}}catch(o){console.error("[public-chat] failed to resolve anonymous session:",o),e.lastError="Failed to start chat session"}}let he=!1,ie=null,Zt="",en="",tn="",fs="",cn="phone",On="";function mu(e){return e.replace(/[\s\-()]/g,"")}function st(){he=!1,ie=null,Zt="",en="",tn="",fs="",cn="phone",On=""}async function wk(e){if(!e.client||!e.connected)return;const t=gu(e.cookieTtlDays);try{const n=await e.client.request("public.session",{cookieId:t,accountId:e.accountId});n!=null&&n.sessionKey&&e.onAuthenticated(n.sessionKey)}catch(n){ie=n instanceof Error?n.message:"Failed to start session",e.requestUpdate()}}async function Cl(e){if(!e.client||he)return;const t=mu(Zt);if(!t){ie="Please enter your phone number",e.requestUpdate();return}he=!0,ie=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{phone:t,name:tn.trim()||void 0,accountId:e.accountId,channel:On||void 0});n!=null&&n.ok?(fs=n.channel??"",cn="phone",e.onAuthStepChange("otp")):ie=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){ie=n instanceof Error?n.message:"Failed to send verification code"}finally{he=!1,e.requestUpdate()}}async function El(e){if(!e.client||he)return;const t=en.trim().toLowerCase();if(!t||!t.includes("@")){ie="Please enter a valid email address",e.requestUpdate();return}he=!0,ie=null,e.requestUpdate();try{const n=await e.client.request("public.otp.request",{identifier:t,accountId:e.accountId});n!=null&&n.ok?(fs=n.channel??"email",cn="email",e.onAuthStepChange("otp")):ie=(n==null?void 0:n.error)??"Failed to send verification code"}catch(n){ie=n instanceof Error?n.message:"Failed to send verification code"}finally{he=!1,e.requestUpdate()}}async function Tl(e,t){if(!(!e.client||he)){if(!t.trim()){ie="Please enter the verification code",e.requestUpdate();return}he=!0,ie=null,e.requestUpdate();try{const n=cn==="email"?en.trim().toLowerCase():mu(Zt),i=await e.client.request("public.otp.verify",{identifier:n,code:t.trim(),accountId:e.accountId});i!=null&&i.ok&&i.sessionKey?(st(),e.onAuthenticated(i.sessionKey)):ie=(i==null?void 0:i.error)??"Invalid verification code"}catch(n){ie=n instanceof Error?n.message:"Verification failed"}finally{he=!1,e.requestUpdate()}}}function Ge(e){return w}function xi(e){return u`
|
|
4259
4272
|
<div class="public-auth__form">
|
|
4260
4273
|
<label class="field public-auth__field">
|
|
4261
4274
|
<span>Your name (optional)</span>
|
|
@@ -4393,7 +4406,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
4393
4406
|
${Ge()}
|
|
4394
4407
|
<h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
|
|
4395
4408
|
<p class="public-auth__subtitle">Verify your phone number to get started.</p>
|
|
4396
|
-
${
|
|
4409
|
+
${xi(e)}
|
|
4397
4410
|
${p?u`
|
|
4398
4411
|
<button class="btn public-auth__btn public-auth__btn--link"
|
|
4399
4412
|
@click=${()=>{st(),e.onAuthStepChange("email")}}>
|
|
@@ -4408,7 +4421,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
4408
4421
|
${Ge()}
|
|
4409
4422
|
<h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
|
|
4410
4423
|
<p class="public-auth__subtitle">Authenticate to get started.</p>
|
|
4411
|
-
${
|
|
4424
|
+
${xi(e)}
|
|
4412
4425
|
<button class="btn public-auth__btn public-auth__btn--link"
|
|
4413
4426
|
@click=${()=>{st(),e.onAuthStepChange("email")}}>
|
|
4414
4427
|
Use email instead
|
|
@@ -4430,16 +4443,16 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
4430
4443
|
${Ge()}
|
|
4431
4444
|
<h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
|
|
4432
4445
|
<p class="public-auth__subtitle">Verify your phone number to get started.</p>
|
|
4433
|
-
${
|
|
4446
|
+
${xi(e)}
|
|
4434
4447
|
</div>
|
|
4435
4448
|
</div>
|
|
4436
|
-
`}const s=e.verifyMethods??["whatsapp","sms"],o=
|
|
4449
|
+
`}const s=e.verifyMethods??["whatsapp","sms"],o=s.includes("whatsapp")&&(!e.otpChannels||e.otpChannels.includes("whatsapp")),a=s.includes("sms"),r=s.includes("email"),c=o||a||s.includes("phone")||r;if(n==="phone"||n==="email"||n==="otp"){const h=n==="email"||n==="otp"&&cn==="email",p=h?"Verify your email address to continue your conversation across devices.":`Verify your phone number to receive a code via ${h?"email":On==="sms"?"SMS":"WhatsApp"}.`;return u`
|
|
4437
4450
|
<div class="setup-container">
|
|
4438
4451
|
<div class="public-auth">
|
|
4439
4452
|
${Ge()}
|
|
4440
4453
|
<h2 class="public-auth__title">Chat with ${e.assistantName}</h2>
|
|
4441
4454
|
<p class="public-auth__subtitle">${p}</p>
|
|
4442
|
-
${n==="otp"?_l(e):n==="email"?ho(e)
|
|
4455
|
+
${n==="otp"?_l(e):n==="email"?ho(e):xi(e)}
|
|
4443
4456
|
${n!=="otp"?u`
|
|
4444
4457
|
<button class="btn public-auth__btn public-auth__btn--link"
|
|
4445
4458
|
@click=${()=>{st(),e.onAuthStepChange("idle")}}>
|
|
@@ -4493,7 +4506,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
4493
4506
|
`:w}
|
|
4494
4507
|
</div>
|
|
4495
4508
|
</div>
|
|
4496
|
-
`}const Fa="taskmaster-access-session",yu={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function vu(){try{return localStorage.getItem(Fa)}catch{return null}}function bu(e){try{localStorage.setItem(Fa,e)}catch{}}function $k(){try{localStorage.removeItem(Fa)}catch{}}async function Ml(e){if(e.client)try{const t=vu(),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 xk(e,t,n){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const i=await e.client.request("access.verify",{account:t,pin:n});i.ok&&i.token?(bu(i.token),e.accessState={...e.accessState,authenticated:!0,workspace:i.workspace??null,master:i.master??!1,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:i.message??"Incorrect PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to verify PIN"}}}}async function Sk(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?(bu(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 Ak(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 Ck(e){const t=vu();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}$k(),e.accessState={...yu,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}function Ek(e,t="admin"){var s;if(!e)return[];const n=e.bindings;if(!Array.isArray(n))return[];const i=[];for(const o of n){if(!o||typeof o!="object"||o.agentId!==t&&o.agentId!=="management")continue;const a=o.match;if(!a||typeof a!="object"||(a.channel??"").toLowerCase()!=="whatsapp")continue;const l=a.peer;if(!l||typeof l!="object"||l.kind!=="dm")continue;const c=l.id??"";c&&i.push({phone:c,paired:((s=o.meta)==null?void 0:s.paired)===!0})}return i.sort((o,a)=>o.paired&&!a.paired?-1:!o.paired&&a.paired?1:0),i}function wu(e,t,n="admin",i){const s=c=>c===n||c==="management",o=new Map,a=new Map;for(const c of e){if(!c||typeof c!="object"||!s(c.agentId))continue;const h=c.match;if(!h||typeof h!="object"||(h.channel??"").toLowerCase()!=="whatsapp")continue;const p=h.peer;if(!p||typeof p!="object"||p.kind!=="dm")continue;const v=p.id??"";v&&(c.meta&&o.set(v,c.meta),h.accountId&&a.set(v,h.accountId))}const r=e.filter(c=>{if(!c||typeof c!="object"||!s(c.agentId))return!0;const h=c.match;if(!h||typeof h!="object"||(h.channel??"").toLowerCase()!=="whatsapp")return!0;const p=h.peer;return!p||typeof p!="object"?!0:p.kind!=="dm"}),l=t.map(c=>{const h=i??a.get(c.phone),d={channel:"whatsapp",peer:{kind:"dm",id:c.phone}};h&&(d.accountId=h);const p={agentId:n,match:d},v=o.get(c.phone);return v?p.meta=v:c.paired&&(p.meta={paired:!0}),p});return[...r,...l]}async function gs(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 i=await e.client.request("config.get",{});e.configSnapshot=i;const s=i.config;e.configForm=ct(s??{}),e.adminPhones=Ek(s,n),e.configFormDirty=!1}catch(i){e.adminsError=String(i)}finally{e.adminsLoading=!1}}async function ku(e,t,n,i){var a,r;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n;let o=t.replace(/[\s\-\(\)]/g,"");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. Use international format (e.g., +44 7504 472444)";return}if(e.adminPhones.some(l=>l.phone===o)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const l=ct(e.configForm??((a=e.configSnapshot)==null?void 0:a.config)??{}),c=l.bindings??[],h=[...e.adminPhones,{phone:o}],d=wu(c,h,s,i);sc(l,["bindings"],d);const p=(r=e.configSnapshot)==null?void 0:r.hash;if(!p){e.adminsError="Config hash missing; reload and retry.";return}const v=Et(l);await e.client.request("config.set",{raw:v,baseHash:p}),await gs(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}async function $u(e,t,n,i){var a,r;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n,o=e.adminPhones.find(l=>l.phone===t);if(o!=null&&o.paired){e.adminsError="Cannot remove the paired phone. Unlink WhatsApp first.";return}e.adminsSaving=!0,e.adminsError=null;try{const l=ct(e.configForm??((a=e.configSnapshot)==null?void 0:a.config)??{}),c=l.bindings??[],h=e.adminPhones.filter(S=>S.phone!==t),d=wu(c,h,s,i);sc(l,["bindings"],d);const p=(r=e.configSnapshot)==null?void 0:r.hash;if(!p){e.adminsError="Config hash missing; reload and retry.";return}const v=Et(l);await e.client.request("config.set",{raw:v,baseHash:p}),await gs(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}const Tk=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:ku,loadAdmins:gs,removeAdmin:$u},Symbol.toStringTag,{value:"Module"}));async function Lt(e,t){if(!(!e.client||!e.connected)){if(!t){e.contactsRecords=[];return}if(!e.contactsLoading){e.contactsLoading=!0,e.contactsError=null;try{const n=e.contactsSearchQuery.trim(),i=n?await e.client.request("records.search",{query:n,workspace:t}):await e.client.request("records.list",{workspace:t});e.contactsRecords=i.records??[]}catch(n){e.contactsError=String(n)}finally{e.contactsLoading=!1}}}}async function xu(e,t,n,i){if(!e.client||!e.connected||e.contactsSaving)return;let s=t.replace(/[\s\-\(\)]/g,"");const o=n.trim();if(!s){e.contactsError="Phone number is required";return}if(!o){e.contactsError="Name is required";return}if(s.startsWith("+")||(s="+"+s),!/^\+[1-9]\d{6,14}$/.test(s)){e.contactsError="Invalid phone number. Use international format (e.g., +44 7490 553305)";return}e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.set",{id:s,name:o,fields:{},workspace:i}),e.contactsShowAddForm=!1,e.contactsNewPhone="",e.contactsNewName="",await Lt(e,i)}catch(a){e.contactsError=String(a)}finally{e.contactsSaving=!1}}async function Su(e,t,n){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.delete",{id:t}),e.contactsEditingId===t&&(e.contactsEditingId=null),await Lt(e,n)}catch(i){e.contactsError=String(i)}finally{e.contactsSaving=!1}}}async function qo(e,t,n,i,s){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.setField",{id:t,key:n,value:i}),await Lt(e,s)}catch(o){e.contactsError=String(o)}finally{e.contactsSaving=!1}}}async function Au(e,t,n,i){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.deleteField",{id:t,key:n}),await Lt(e,i)}catch(s){e.contactsError=String(s)}finally{e.contactsSaving=!1}}}const _k=Object.freeze(Object.defineProperty({__proto__:null,addContact:xu,deleteContact:Su,deleteContactField:Au,loadContacts:Lt,setContactField:qo},Symbol.toStringTag,{value:"Module"}));let $t=null,Mi=null,Pi=null;const fo=[[0,"Checking Tailscale service..."],[5,"Starting login..."],[15,"Requesting authentication link..."],[40,"Setting up secure connection..."],[70,"Almost ready..."]];function zt(){$t&&(clearInterval($t),$t=null),Mi&&(clearInterval(Mi),Mi=null),Pi&&(clearTimeout(Pi),Pi=null)}function Sn(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(),auditCount:e.auditEntries.length,onAuditClick:()=>{e.auditModalOpen=!0},onRestartGateway:()=>e.handleGatewayRestart()}}function Mk(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(),auditCount:e.auditEntries.length,onAuditClick:()=>{e.auditModalOpen=!0},onRestartGateway:()=>e.handleGatewayRestart()}}function Pk(e){const t=ue(e);if(!t)return;const n=t.agents.find(i=>i.id.endsWith("-admin")||i.id==="admin");return n==null?void 0:n.id}function Ik(e){const t=ue(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function Lk(e){var i;const t=ue(e);if(!t)return;const n=t.agents.find(s=>s.id.endsWith("-admin")||s.id==="admin");return(n==null?void 0:n.id)??((i=t.agents[0])==null?void 0:i.id)}function Rk(e){return e.selectedWorkspace??void 0}function ue(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const Dk=/^data:/i,Bk=/^https?:\/\//i;function Pl(e){var r,l;const t=((r=e.agentsList)==null?void 0:r.agents)??[],n=jl(e.sessionKey),i=(n==null?void 0:n.agentId)??((l=e.agentsList)==null?void 0:l.defaultId)??"main",s=t.find(c=>c.id===i),o=s==null?void 0:s.identity,a=(o==null?void 0:o.avatarUrl)??(o==null?void 0:o.avatar);if(a)return Dk.test(a)||Bk.test(a)?a:o==null?void 0:o.avatarUrl}function Nk(e){var i;if(!e)return null;const t=(i=e.channelAccounts)==null?void 0:i.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 Ok(e){var a;if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=(a=e.channelAccounts)==null?void 0:a.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],i=n.running??!1,s=n.probe,o=s!=null?s.ok===!0:i;return{configured:n.configured??!1,running:i,connected:o,lastError:n.lastError??null,selfChatMode:n.mode==="self-chat"||!!n.selfChatMode,dmPolicy:n.dmPolicy??null,cliPath:n.cliPath??null}}function Fk(e){var a;const t=(a=e.configSnapshot)==null?void 0:a.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const i=n.find(r=>{var l,c;return((l=r.match)==null?void 0:l.channel)==="imessage"&&((c=r.meta)==null?void 0:c.imessageOwner)});if(!i)return null;const s=i.agentId;for(const r of e.workspaces)if(r.agents.some(l=>l.id===s))return r.name;if(s==="admin"||s==="public"){const r=e.workspaces.find(l=>l.isDefault);return(r==null?void 0:r.name)??null}const o=s.replace(/-(admin|public)$/,"");if(o!==s){const r=e.workspaces.find(l=>l.name===o);return(r==null?void 0:r.name)??null}return null}function Uk(e){var t,n,i,s,o,a,r,l,c,h;if(e.embeddingDownloading&&!e.publicChat)return u`
|
|
4509
|
+
`}const Fa="taskmaster-access-session",yu={checked:!1,hasPins:!1,hasMasterPin:!1,authenticated:!1,workspace:null,master:!1,accounts:[],error:null,busy:!1};function vu(){try{return localStorage.getItem(Fa)}catch{return null}}function bu(e){try{localStorage.setItem(Fa,e)}catch{}}function xk(){try{localStorage.removeItem(Fa)}catch{}}async function Ml(e){if(e.client)try{const t=vu(),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 $k(e,t,n){if(e.client){e.accessState={...e.accessState,busy:!0,error:null};try{const i=await e.client.request("access.verify",{account:t,pin:n});i.ok&&i.token?(bu(i.token),e.accessState={...e.accessState,authenticated:!0,workspace:i.workspace??null,master:i.master??!1,busy:!1,error:null}):e.accessState={...e.accessState,busy:!1,error:i.message??"Incorrect PIN"}}catch{e.accessState={...e.accessState,busy:!1,error:"Failed to verify PIN"}}}}async function Sk(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?(bu(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 Ak(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 Ck(e){const t=vu();if(e.client&&t)try{await e.client.request("access.logout",{token:t})}catch{}xk(),e.accessState={...yu,checked:!0,hasPins:!0,hasMasterPin:e.accessState.hasMasterPin,accounts:e.accessState.accounts}}function Ek(e,t="admin"){var s;if(!e)return[];const n=e.bindings;if(!Array.isArray(n))return[];const i=[];for(const o of n){if(!o||typeof o!="object"||o.agentId!==t&&o.agentId!=="management")continue;const a=o.match;if(!a||typeof a!="object"||(a.channel??"").toLowerCase()!=="whatsapp")continue;const l=a.peer;if(!l||typeof l!="object"||l.kind!=="dm")continue;const c=l.id??"";c&&i.push({phone:c,paired:((s=o.meta)==null?void 0:s.paired)===!0})}return i.sort((o,a)=>o.paired&&!a.paired?-1:!o.paired&&a.paired?1:0),i}function wu(e,t,n="admin",i){const s=c=>c===n||c==="management",o=new Map,a=new Map;for(const c of e){if(!c||typeof c!="object"||!s(c.agentId))continue;const h=c.match;if(!h||typeof h!="object"||(h.channel??"").toLowerCase()!=="whatsapp")continue;const p=h.peer;if(!p||typeof p!="object"||p.kind!=="dm")continue;const g=p.id??"";g&&(c.meta&&o.set(g,c.meta),h.accountId&&a.set(g,h.accountId))}const r=e.filter(c=>{if(!c||typeof c!="object"||!s(c.agentId))return!0;const h=c.match;if(!h||typeof h!="object"||(h.channel??"").toLowerCase()!=="whatsapp")return!0;const p=h.peer;return!p||typeof p!="object"?!0:p.kind!=="dm"}),l=t.map(c=>{const h=i??a.get(c.phone),d={channel:"whatsapp",peer:{kind:"dm",id:c.phone}};h&&(d.accountId=h);const p={agentId:n,match:d},g=o.get(c.phone);return g?p.meta=g:c.paired&&(p.meta={paired:!0}),p});return[...r,...l]}async function gs(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 i=await e.client.request("config.get",{});e.configSnapshot=i;const s=i.config;e.configForm=ct(s??{}),e.adminPhones=Ek(s,n),e.configFormDirty=!1}catch(i){e.adminsError=String(i)}finally{e.adminsLoading=!1}}async function ku(e,t,n,i){var a,r;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n;let o=t.replace(/[\s\-\(\)]/g,"");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. Use international format (e.g., +44 7504 472444)";return}if(e.adminPhones.some(l=>l.phone===o)){e.adminsError="Phone number already exists";return}e.adminsSaving=!0,e.adminsError=null;try{const l=ct(e.configForm??((a=e.configSnapshot)==null?void 0:a.config)??{}),c=l.bindings??[],h=[...e.adminPhones,{phone:o}],d=wu(c,h,s,i);sc(l,["bindings"],d);const p=(r=e.configSnapshot)==null?void 0:r.hash;if(!p){e.adminsError="Config hash missing; reload and retry.";return}const g=Et(l);await e.client.request("config.set",{raw:g,baseHash:p}),await gs(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}async function xu(e,t,n,i){var a,r;if(!e.client||!e.connected)return;if(!n){e.adminsError="No business selected.";return}if(e.adminsSaving)return;const s=n,o=e.adminPhones.find(l=>l.phone===t);if(o!=null&&o.paired){e.adminsError="Cannot remove the paired phone. Unlink WhatsApp first.";return}e.adminsSaving=!0,e.adminsError=null;try{const l=ct(e.configForm??((a=e.configSnapshot)==null?void 0:a.config)??{}),c=l.bindings??[],h=e.adminPhones.filter($=>$.phone!==t),d=wu(c,h,s,i);sc(l,["bindings"],d);const p=(r=e.configSnapshot)==null?void 0:r.hash;if(!p){e.adminsError="Config hash missing; reload and retry.";return}const g=Et(l);await e.client.request("config.set",{raw:g,baseHash:p}),await gs(e,n)}catch(l){e.adminsError=String(l)}finally{e.adminsSaving=!1}}const Tk=Object.freeze(Object.defineProperty({__proto__:null,addAdmin:ku,loadAdmins:gs,removeAdmin:xu},Symbol.toStringTag,{value:"Module"}));async function Lt(e,t){if(!(!e.client||!e.connected)){if(!t){e.contactsRecords=[];return}if(!e.contactsLoading){e.contactsLoading=!0,e.contactsError=null;try{const n=e.contactsSearchQuery.trim(),i=n?await e.client.request("records.search",{query:n,workspace:t}):await e.client.request("records.list",{workspace:t});e.contactsRecords=i.records??[]}catch(n){e.contactsError=String(n)}finally{e.contactsLoading=!1}}}}async function $u(e,t,n,i){if(!e.client||!e.connected||e.contactsSaving)return;let s=t.replace(/[\s\-\(\)]/g,"");const o=n.trim();if(!s){e.contactsError="Phone number is required";return}if(!o){e.contactsError="Name is required";return}if(s.startsWith("+")||(s="+"+s),!/^\+[1-9]\d{6,14}$/.test(s)){e.contactsError="Invalid phone number. Use international format (e.g., +44 7490 553305)";return}e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.set",{id:s,name:o,fields:{},workspace:i}),e.contactsShowAddForm=!1,e.contactsNewPhone="",e.contactsNewName="",await Lt(e,i)}catch(a){e.contactsError=String(a)}finally{e.contactsSaving=!1}}async function Su(e,t,n){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.delete",{id:t}),e.contactsEditingId===t&&(e.contactsEditingId=null),await Lt(e,n)}catch(i){e.contactsError=String(i)}finally{e.contactsSaving=!1}}}async function qo(e,t,n,i,s){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.setField",{id:t,key:n,value:i}),await Lt(e,s)}catch(o){e.contactsError=String(o)}finally{e.contactsSaving=!1}}}async function Au(e,t,n,i){if(!(!e.client||!e.connected)&&!e.contactsSaving){e.contactsSaving=!0,e.contactsError=null;try{await e.client.request("records.deleteField",{id:t,key:n}),await Lt(e,i)}catch(s){e.contactsError=String(s)}finally{e.contactsSaving=!1}}}const _k=Object.freeze(Object.defineProperty({__proto__:null,addContact:$u,deleteContact:Su,deleteContactField:Au,loadContacts:Lt,setContactField:qo},Symbol.toStringTag,{value:"Module"}));let xt=null,Mi=null,Pi=null;const fo=[[0,"Checking Tailscale service..."],[5,"Starting login..."],[15,"Requesting authentication link..."],[40,"Setting up secure connection..."],[70,"Almost ready..."]];function zt(){xt&&(clearInterval(xt),xt=null),Mi&&(clearInterval(Mi),Mi=null),Pi&&(clearTimeout(Pi),Pi=null)}function Sn(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(),auditCount:e.auditEntries.length,onAuditClick:()=>{e.auditModalOpen=!0},onRestartGateway:()=>e.handleGatewayRestart()}}function Mk(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(),auditCount:e.auditEntries.length,onAuditClick:()=>{e.auditModalOpen=!0},onRestartGateway:()=>e.handleGatewayRestart()}}function Pk(e){const t=ue(e);if(!t)return;const n=t.agents.find(i=>i.id.endsWith("-admin")||i.id==="admin");return n==null?void 0:n.id}function Ik(e){const t=ue(e);return(t==null?void 0:t.whatsappAccountId)??void 0}function Lk(e){var i;const t=ue(e);if(!t)return;const n=t.agents.find(s=>s.id.endsWith("-admin")||s.id==="admin");return(n==null?void 0:n.id)??((i=t.agents[0])==null?void 0:i.id)}function Rk(e){return e.selectedWorkspace??void 0}function ue(e){return e.selectedWorkspace?e.workspaces.find(t=>t.name===e.selectedWorkspace)??null:null}const Dk=/^data:/i,Bk=/^https?:\/\//i;function Pl(e){var r,l;const t=((r=e.agentsList)==null?void 0:r.agents)??[],n=jl(e.sessionKey),i=(n==null?void 0:n.agentId)??((l=e.agentsList)==null?void 0:l.defaultId)??"main",s=t.find(c=>c.id===i),o=s==null?void 0:s.identity,a=(o==null?void 0:o.avatarUrl)??(o==null?void 0:o.avatar);if(a)return Dk.test(a)||Bk.test(a)?a:o==null?void 0:o.avatarUrl}function Nk(e){var i;if(!e)return null;const t=(i=e.channelAccounts)==null?void 0:i.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 Ok(e){var a;if(!e)return{configured:!1,running:!1,connected:!1,lastError:null,selfChatMode:!1,dmPolicy:null,cliPath:null};const t=(a=e.channelAccounts)==null?void 0:a.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],i=n.running??!1,s=n.probe,o=s!=null?s.ok===!0:i;return{configured:n.configured??!1,running:i,connected:o,lastError:n.lastError??null,selfChatMode:n.mode==="self-chat"||!!n.selfChatMode,dmPolicy:n.dmPolicy??null,cliPath:n.cliPath??null}}function Fk(e){var a;const t=(a=e.configSnapshot)==null?void 0:a.config;if(!t)return null;const n=t.bindings;if(!Array.isArray(n))return null;const i=n.find(r=>{var l,c;return((l=r.match)==null?void 0:l.channel)==="imessage"&&((c=r.meta)==null?void 0:c.imessageOwner)});if(!i)return null;const s=i.agentId;for(const r of e.workspaces)if(r.agents.some(l=>l.id===s))return r.name;if(s==="admin"||s==="public"){const r=e.workspaces.find(l=>l.isDefault);return(r==null?void 0:r.name)??null}const o=s.replace(/-(admin|public)$/,"");if(o!==s){const r=e.workspaces.find(l=>l.name===o);return(r==null?void 0:r.name)??null}return null}function Uk(e){var t,n,i,s,o,a,r,l,c,h;if(e.embeddingDownloading&&!e.publicChat)return u`
|
|
4497
4510
|
<div class="setup-container">
|
|
4498
4511
|
<div class="setup-card" style="text-align:center; max-width:420px;">
|
|
4499
4512
|
<div class="setup-spinner"></div>
|
|
@@ -4514,7 +4527,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
4514
4527
|
<p>Connecting...</p>
|
|
4515
4528
|
</div>
|
|
4516
4529
|
</div>
|
|
4517
|
-
`;if(!e.publicChatAuthenticated)return kk({authMode:e.publicChatConfig.auth??"anonymous",authStep:e.publicChatAuthStep,connected:e.connected,client:e.client,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,accountId:e.publicChatConfig.accountId,cookieTtlDays:e.publicChatConfig.cookieTtlDays,otpChannels:e.publicChatConfig.otpChannels,verifyMethods:e.publicChatConfig.verifyMethods,onAuthenticated:S=>{var T;e.publicChatSessionKey=S,e.sessionKey=S,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready";const x=((T=e.publicChatConfig)==null?void 0:T.accountId)??"";e.chatMessage=Kn(x,S),le(async()=>{const{loadChatHistory:f}=await Promise.resolve().then(()=>Ni);return{loadChatHistory:f}},void 0,import.meta.url).then(({loadChatHistory:f})=>{f(e)})},onAuthStepChange:S=>{e.publicChatAuthStep=S},requestUpdate:()=>{e.requestUpdate()}});const d=(t=e.publicChatConfig)==null?void 0:t.greeting,p=e.chatMessages,v=!e.chatLoading&&d?[{role:"assistant",content:[{type:"text",text:d}],timestamp:0},...Array.isArray(p)?p:[]]:p;return Nw({connected:e.connected,sessionKey:e.sessionKey,loading:e.chatLoading,sending:e.chatSending,messages:v,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,assistantAvatarUrl:e.chatAvatarUrl??Pl(e)??null,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,canAbort:!!e.chatRunId,disabledReason:e.connected?null:"Disconnected.",error:e.lastError,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,suggestions:e.chatSuggestions,onSuggestionClick:S=>{e.chatMessage=S,e.chatSuggestions=[],e.handleSendChat()},onRefresh:()=>(e.resetToolStream(),le(async()=>{const{loadChatHistory:S}=await Promise.resolve().then(()=>Ni);return{loadChatHistory:S}},void 0,import.meta.url).then(({loadChatHistory:S})=>{S(e)})),onDraftChange:S=>{var T;e.chatMessage=S;const x=((T=e.publicChatConfig)==null?void 0:T.accountId)??"";yr(x,e.sessionKey,S)},requestUpdate:()=>e.requestUpdate(),attachments:e.chatAttachments,onAttachmentsChange:S=>e.chatAttachments=S,onSend:()=>e.handleSendChat(),onAbort:()=>{e.handleAbortChat()},onQueueRemove:S=>e.removeQueuedMessage(S),onChatScroll:S=>e.handleChatScroll(S),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()}})}if(e.connected&&e.accessState.checked){const{accessState:d}=e;if(d.hasPins&&!d.authenticated)return wl({show:!0,isFirstTime:!1,accounts:d.accounts,error:d.error,busy:d.busy,onSubmit:(p,v)=>{v!=null&&e.handlePinSubmit(p,v)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(p,v,S)=>e.handleChangePin(p,v,S)});if(!d.hasMasterPin&&!d.authenticated&&e.setup)return wl({show:!0,isFirstTime:!0,accounts:[],error:d.error,busy:d.busy,onSubmit:p=>e.handleSetMasterPin(p)});if(!d.hasMasterPin&&!d.authenticated&&!e.setup)return window.location.href="/setup",w}if(e.setup){const d=Nk(e.channelsSnapshot),p=((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.whatsapp)??[],v=Ok(e.channelsSnapshot),S=Fk(e),x=async()=>{e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null},T=()=>{const f=Date.now();e.tailscaleConnectProgress=0,e.tailscaleConnectMessage=fo[0][1],e.tailscaleConnectSuccess=!1,e.tailscaleError=null,zt(),$t=setInterval(()=>{const b=(Date.now()-f)/1e3,k=Math.min(95,95*(1-Math.exp(-b/30)));e.tailscaleConnectProgress=Math.round(k);let A=fo[0][1];for(const[E,M]of fo)b>=E&&(A=M);e.tailscaleConnectMessage=A},500)};return Kg({connected:e.connected,serverPlatform:((o=(s=e.hello)==null?void 0:s.server)==null?void 0:o.platform)??null,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:f=>e.handleLicenseKeyChange(f),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:d,whatsappAccounts:p,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(),uninstallConfirm:e.uninstallConfirm,uninstallBusy:e.uninstallBusy,uninstallDone:e.uninstallDone,uninstallError:e.uninstallError,uninstallConfirmText:e.uninstallConfirmText,onUninstallConfirm:()=>e.handleUninstallConfirm(),onUninstallCancel:()=>e.handleUninstallCancel(),onUninstallConfirmTextChange:f=>e.handleUninstallConfirmTextChange(f),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:f=>e.handleAuthSubmitCode(f),onAuthCodeChange:f=>e.handleAuthCodeChange(f),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async f=>{await e.handleWhatsAppStart(!0,f),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(f),await ee(e,!0),e.requestUpdate())},onWhatsAppUnlink:async f=>{await e.handleWhatsAppLogout(f)},onWhatsAppReset:async f=>{await e.handleWhatsAppLogout(f),await e.handleWhatsAppStart(!0,f),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(f),await ee(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await ee(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),ee(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:f=>e.handleRemoveWhatsAppAccount(f),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:f=>{e.newWorkspacePin=f},onWorkspaceCreate:async(f,b)=>{const k=e.newWorkspacePin;await e.handleWorkspaceCreate(f,b),k.match(/^\d{4,6}$/)&&(await Ak(e,f,k),e.newWorkspacePin="")},onWorkspaceRemove:f=>e.handleWorkspaceRemove(f),onSetAddingWorkspace:f=>{e.addingWorkspace=f},onSetNewWorkspaceName:f=>{e.newWorkspaceName=f},onSetNewWorkspacePath:f=>{e.newWorkspacePath=f},onSetWorkspaceRemoveConfirm:f=>{e.workspaceRemoveConfirm=f},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(f,b)=>e.handleWorkspaceRename(f,b),whatsappDmPolicy:(()=>{const f=ue(e),b=f==null?void 0:f.whatsappAccountId,k=b?p.find(A=>A.accountId===b):p[0];return(k==null?void 0:k.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var P;const f=ue(e),b=f==null?void 0:f.whatsappAccountId,k=b?p.find(R=>R.accountId===b):p[0];if(!k)return;const E=k.dmPolicy!=null&&k.dmPolicy!=="disabled"?"disabled":"open",M=E==="open"?{dmPolicy:E,allowFrom:["*"]}:{dmPolicy:E};try{const R=await e.client.request("config.get"),F=R.config,H=(P=F==null?void 0:F.channels)==null?void 0:P.whatsapp,ke=((H==null?void 0:H.accounts)??{})[k.accountId]?{channels:{whatsapp:{accounts:{[k.accountId]:M}}}}:{channels:{whatsapp:M}};await e.client.request("config.patch",{raw:JSON.stringify(ke),baseHash:R.hash,note:`WhatsApp DM policy → ${E}`,skipRestart:!0}),await ee(e,!1)}catch(R){console.error("DM toggle failed:",R)}},whatsappModel:(()=>{var P,R;const f=ue(e);if(!f)return null;const b=f.agents.find(F=>F.id.endsWith("-public")||F.id==="public");if(!b)return null;const k=(P=e.configSnapshot)==null?void 0:P.config,A=(R=k==null?void 0:k.agents)==null?void 0:R.list;if(!Array.isArray(A))return null;const E=A.find(F=>F.id===b.id);if(!(E!=null&&E.model))return null;const M=typeof E.model=="string"?E.model:E.model.primary;return(M==null?void 0:M.trim())||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async f=>{const b=ue(e);if(!b)return;const k=b.agents.find(A=>A.id.endsWith("-public")||A.id==="public");if(k)try{const A=await e.client.request("config.get"),E=A.config,M=(E==null?void 0:E.agents)??{},P=Array.isArray(M.list)?[...M.list]:[],R=P.findIndex(H=>H.id===k.id);if(f)R>=0?P[R]={...P[R],model:f}:P.push({id:k.id,model:f});else if(R>=0){const{model:H,...z}=P[R];Object.keys(z).length<=1?P.splice(R,1):P[R]=z}const F=P.length>0?{agents:{list:P}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(F),baseHash:A.hash,note:`Public agent model → ${f||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Model change failed:",A)}},whatsappThinkingLevel:(()=>{var M,P,R;const f=ue(e);if(!f)return null;const b=f.agents.find(F=>F.id.endsWith("-public")||F.id==="public");if(!b)return null;const k=(M=e.configSnapshot)==null?void 0:M.config,A=(P=k==null?void 0:k.agents)==null?void 0:P.list;if(!Array.isArray(A))return null;const E=A.find(F=>F.id===b.id);return((R=E==null?void 0:E.thinkingLevel)==null?void 0:R.trim())||null})(),onWhatsAppThinkingChange:async f=>{const b=ue(e);if(!b)return;const k=b.agents.find(A=>A.id.endsWith("-public")||A.id==="public");if(k)try{const A=await e.client.request("config.get"),E=A.config,M=(E==null?void 0:E.agents)??{},P=Array.isArray(M.list)?[...M.list]:[],R=P.findIndex(z=>z.id===k.id),F=f==="off"?void 0:f;if(F)R>=0?P[R]={...P[R],thinkingLevel:F}:P.push({id:k.id,thinkingLevel:F});else if(R>=0){const{thinkingLevel:z,...ke}=P[R];Object.keys(ke).length<=1?P.splice(R,1):P[R]=ke}const H=P.length>0?{agents:{list:P}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(H),baseHash:A.hash,note:`Public agent thinking → ${F||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Thinking change failed:",A)}},whatsappGroupPolicy:(()=>{var R,F;const f=(R=e.configSnapshot)==null?void 0:R.config,b=(F=f==null?void 0:f.channels)==null?void 0:F.whatsapp,k=ue(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},M=A?E[A]:void 0;return(M==null?void 0:M.groupPolicy)??(b==null?void 0:b.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var F,H;const f=(F=e.configSnapshot)==null?void 0:F.config,b=(H=f==null?void 0:f.channels)==null?void 0:H.whatsapp,k=ue(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},M=A?E[A]:void 0,R=((M==null?void 0:M.groups)??(b==null?void 0:b.groups)??{})["*"];return(R==null?void 0:R.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var k;const f=ue(e),b=f==null?void 0:f.whatsappAccountId;try{const A=await e.client.request("config.get"),E=A.config,M=((k=E==null?void 0:E.channels)==null?void 0:k.whatsapp)??{},P=M.accounts??{},R=b?P[b]:void 0,F=(R==null?void 0:R.groupPolicy)??M.groupPolicy??"allowlist",H=F==="disabled"||F==="allowlist",z=H?"open":"disabled",ke=H?{"*":{}}:void 0,_e={groupPolicy:z};ke&&(_e.groups=ke);const Ke=R?{channels:{whatsapp:{accounts:{[b]:_e}}}}:{channels:{whatsapp:_e}};await e.client.request("config.patch",{raw:JSON.stringify(Ke),baseHash:A.hash,note:`WhatsApp groups → ${z}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Group toggle failed:",A)}},onWhatsAppGroupMentionChange:async f=>{var A;const b=ue(e),k=b==null?void 0:b.whatsappAccountId;try{const E=await e.client.request("config.get"),M=E.config,R=(((A=M==null?void 0:M.channels)==null?void 0:A.whatsapp)??{}).accounts??{},F=k?R[k]:void 0,H={"*":{requireMention:f}},z=F?{channels:{whatsapp:{accounts:{[k]:{groups:H}}}}}:{channels:{whatsapp:{groups:H}}};await e.client.request("config.patch",{raw:JSON.stringify(z),baseHash:E.hash,note:`WhatsApp group mention → ${f?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(E){console.error("Group mention change failed:",E)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:v.configured,imessageRunning:v.running,imessageConnected:v.connected,imessageLastError:v.lastError,imessageSelfChatMode:v.selfChatMode,imessageCliPath:v.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:S,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),b=f.config,k=(b==null?void 0:b.bindings)??[],A=ue(e),E=A==null?void 0:A.agents.find(H=>H.id.endsWith("-admin")||H.id==="admin"),M=(E==null?void 0:E.id)??"admin",P=k.filter(H=>{var z;return((z=H.match)==null?void 0:z.channel)!=="imessage"}),R=[{agentId:M,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],F=[...P,...R];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:F}),baseHash:f.hash,note:"Enable iMessage (self-chat) for "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),Ue(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await ee(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),b=f.config,A=((b==null?void 0:b.bindings)??[]).filter(E=>{var M;return((M=E.match)==null?void 0:M.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:A}),baseHash:f.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),Ue(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),b=f.config,k=(b==null?void 0:b.bindings)??[],A=ue(e),E=A==null?void 0:A.agents.find(F=>F.id.endsWith("-admin")||F.id==="admin"),M=(E==null?void 0:E.id)??"admin",P=k.filter(F=>{var H;return((H=F.match)==null?void 0:H.channel)!=="imessage"}),R=[{agentId:M,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,...R]}),baseHash:f.hash,note:"Reassign iMessage to "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),Ue(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:f=>{var b,k,A,E;if(e.infoModalOpen=f,f==="remote-access"){const M=((b=e.tailscaleStatus)==null?void 0:b.tailnetUrl)??((k=e.tailscaleStatus)!=null&&k.hostname?`https://${e.tailscaleStatus.hostname}`:null);M&&!e.remoteAccessQrDataUrl&&e.client.request("qr.generate",{url:M}).then(P=>{e.remoteAccessQrDataUrl=(P==null?void 0:P.dataUrl)??null}).catch(()=>{})}else if(f==="public-chat"){const M=((A=e.tailscaleStatus)==null?void 0:A.publicUrl)??((E=e.tailscaleStatus)==null?void 0:E.tailnetUrl)??null,P=e.selectedWorkspace??null;if(M&&P){const R=`${M}/public/chat/${encodeURIComponent(P)}`;e.publicChatQrDataUrl||e.client.request("qr.generate",{url:R}).then(F=>{e.publicChatQrDataUrl=(F==null?void 0:F.dataUrl)??null}).catch(()=>{})}}},onInfoModalClose:()=>{e.infoModalOpen=null},remoteAccessQrDataUrl:e.remoteAccessQrDataUrl??null,publicChatQrDataUrl:e.publicChatQrDataUrl??null,publicChatFullUrl:(()=>{var k,A;const f=((k=e.tailscaleStatus)==null?void 0:k.publicUrl)??((A=e.tailscaleStatus)==null?void 0:A.tailnetUrl)??null,b=e.selectedWorkspace??null;return!f||!b?null:`${f}/public/chat/${encodeURIComponent(b)}`})(),isMaster:e.accessState.master,apiKeyProviders:e.apiKeyProviders,apiKeyModalOpen:e.apiKeyModalOpen,apiKeyBusy:e.apiKeyBusy,apiKeyError:e.apiKeyError,apiKeySuccess:e.apiKeySuccess,apiKeySavingProvider:e.apiKeySavingProvider,onApiKeyModalOpen:()=>{e.apiKeyModalOpen=!0,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeyModalClose:()=>{e.apiKeyModalOpen=!1,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeySave:async(f,b)=>{e.apiKeySavingProvider=f,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await xl(e.client,f,b);const k=`${f} key saved`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}f==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===k&&(e.apiKeySuccess=null)},2500)}catch(k){e.apiKeyError=k instanceof Error?k.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async f=>{e.apiKeySavingProvider=f,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await ik(e.client,f);const b=`${f} key removed`;e.apiKeySuccess=b,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===b&&(e.apiKeySuccess=null)},2500)}catch(b){e.apiKeyError=b instanceof Error?b.message:"Failed to remove key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyDisable:async(f,b)=>{e.apiKeySavingProvider=f,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await sk(e.client,f,b);const k=`${f} ${b?"disabled":"enabled"}`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===k&&(e.apiKeySuccess=null)},2500)}catch(k){e.apiKeyError=k instanceof Error?k.message:`Failed to ${b?"disable":"enable"} key`,e.apiKeySavingProvider=null}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:f=>{e.authApiKeyInput=f},onAuthApiKeySubmit:async()=>{const f=e.authApiKeyInput.trim();if(f){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await xl(e.client,"anthropic",f),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(b){e.authApiKeyError=b instanceof Error?b.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var b;const f=e.selectedWorkspace??((b=e.workspaces[0])==null?void 0:b.name);return f?e.accessState.accounts.some(k=>k.id===f):!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:(f,b)=>{var A;const k=e.selectedWorkspace??((A=e.workspaces[0])==null?void 0:A.name);k&&e.handleAccountPinSave(k,f,b)},publicChatAccountId:e.selectedWorkspace??null,publicChatSettingsOpen:e.publicChatSettingsOpen,onPublicChatSettingsOpen:()=>{e.publicChatSettingsOpen=!0},onPublicChatSettingsClose:()=>{e.publicChatSettingsOpen=!1},publicChatWidgetModalOpen:e.publicChatWidgetModalOpen,onPublicChatWidgetModalOpen:()=>{e.publicChatWidgetModalOpen=!0},onPublicChatWidgetModalClose:()=>{e.publicChatWidgetModalOpen=!1},publicChatEnabled:(()=>{var k;const f=(k=e.configSnapshot)==null?void 0:k.config,b=f==null?void 0:f.publicChat;return(b==null?void 0:b.enabled)===!0})(),publicChatAuthMode:(()=>{var A;const f=(A=e.configSnapshot)==null?void 0:A.config,b=f==null?void 0:f.publicChat,k=b==null?void 0:b.auth;return k==="verified"||k==="choice"?k:"anonymous"})(),publicChatGreeting:(()=>{var E;const f=(E=e.configSnapshot)==null?void 0:E.config,b=f==null?void 0:f.publicChat,k=b==null?void 0:b.greetings,A=e.selectedWorkspace??"";return(A&&(k==null?void 0:k[A]))??""})(),publicChatGreetingBusy:e.publicChatGreetingBusy,onPublicChatGreetingToggle:async()=>{var b;if(e.publicChatGreetingBusy)return;const f=e.selectedWorkspace??"";if(f){e.publicChatGreetingBusy=!0;try{const k=await e.client.request("config.get"),A=k.config,E=(b=A==null?void 0:A.publicChat)==null?void 0:b.greetings;if(E==null?void 0:E[f]){const P={publicChat:{greetings:{[f]:null}}};await e.client.request("config.patch",{raw:JSON.stringify(P),baseHash:k.hash,note:`Public chat greeting → disabled (${f})`,skipRestart:!0})}else{const P=await e.client.request("public.greeting.generate",{accountId:f});if(P!=null&&P.ok&&P.greeting){const R=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[f]:P.greeting}}}),baseHash:R.hash,note:`Public chat greeting → enabled (${f})`,skipRestart:!0})}}e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat greeting toggle failed:",k)}finally{e.publicChatGreetingBusy=!1}}},onPublicChatGreetingSave:async f=>{const b=e.selectedWorkspace??"";if(b)try{const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[b]:f}}}),baseHash:k.hash,note:`Public chat greeting text updated (${b})`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat greeting save failed:",k)}},onPublicChatGreetingRegenerate:async()=>{if(e.publicChatGreetingBusy)return;const f=e.selectedWorkspace??"";if(f){e.publicChatGreetingBusy=!0;try{const b=await e.client.request("public.greeting.generate",{accountId:f});if(b!=null&&b.ok&&b.greeting){const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[f]:b.greeting}}}),baseHash:k.hash,note:`Public chat greeting regenerated (${f})`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}}catch(b){console.error("Public chat greeting regeneration failed:",b)}finally{e.publicChatGreetingBusy=!1}}},publicChatBusy:e.publicChatToggleBusy,onPublicChatToggle:async()=>{var f;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get"),k=b.config,A=((f=k==null?void 0:k.publicChat)==null?void 0:f.enabled)===!0;await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{enabled:!A}}),baseHash:b.hash,note:`Public chat → ${A?"disabled":"enabled"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get"),e.publicChatQrDataUrl=null}catch(b){console.error("Public chat toggle failed:",b)}finally{e.publicChatToggleBusy=!1}}},onPublicChatAuthModeChange:async f=>{if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{auth:f}}),baseHash:b.hash,note:`Public chat auth → ${f}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(b){console.error("Public chat auth mode change failed:",b)}finally{e.publicChatToggleBusy=!1}}},publicChatEmailFrom:(()=>{var k,A;const f=(k=e.configSnapshot)==null?void 0:k.config,b=(A=f==null?void 0:f.publicChat)==null?void 0:A.email;return(b==null?void 0:b.from)??""})(),publicChatEmailBusy:e.publicChatEmailBusy,publicChatVerifyMethods:(()=>{var A;const f=(A=e.configSnapshot)==null?void 0:A.config,b=f==null?void 0:f.publicChat,k=b==null?void 0:b.verifyMethods;return Array.isArray(k)?k:["whatsapp","sms"]})(),onPublicChatEmailSave:async(f,b)=>{if(!e.publicChatEmailBusy){e.publicChatEmailBusy=!0;try{const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{email:{from:f||void 0},verifyMethods:b}}),baseHash:k.hash,note:"Update email verification settings for public chat",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Email verification save failed:",k)}finally{e.publicChatEmailBusy=!1}}},brandAccentColor:(()=>{var k;const f=e.selectedWorkspace;return f?((k=Be()[f])==null?void 0:k.accentColor)??"":""})(),brandBackgroundColor:(()=>{var k;const f=e.selectedWorkspace;return f?((k=Be()[f])==null?void 0:k.backgroundColor)??"":""})(),brandHasLogo:(()=>{var k;const f=e.selectedWorkspace;return f?!!((k=Be()[f])!=null&&k.logoUrl):!1})(),brandingBusy:e.brandingBusy,brandingExpanded:e.brandingExpanded,onBrandingToggle:()=>{e.brandingExpanded=!e.brandingExpanded},onBrandAccentColorChange:async f=>{var k;const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const A=await e.client.request("config.get"),E=A.config,M=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=M.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...M,brand:{...P,accentColor:f}}}}),baseHash:A.hash,note:`Brand accent → ${f}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const R=Be();R[b]||(R[b]={}),R[b].accentColor=f,Tn(b)}catch(A){console.error("Brand accent change failed:",A)}finally{e.brandingBusy=!1}}},onBrandBackgroundColorChange:async f=>{var k;const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const A=await e.client.request("config.get"),E=A.config,M=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=M.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...M,brand:{...P,backgroundColor:f}}}}),baseHash:A.hash,note:`Brand background → ${f}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const R=Be();R[b]||(R[b]={}),R[b].backgroundColor=f,Tn(b)}catch(A){console.error("Brand background change failed:",A)}finally{e.brandingBusy=!1}}},onBrandLogoUpload:async f=>{const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const k=await f.arrayBuffer(),A=new Uint8Array(k);let E="";for(let R=0;R<A.length;R++)E+=String.fromCharCode(A[R]);const M=btoa(E);await e.client.request("brand.uploadLogo",{workspace:b,data:M,mimeType:f.type});const P=Be();P[b]||(P[b]={}),P[b].logoUrl=`/brand-logo/${encodeURIComponent(b)}`}catch(k){console.error("Brand logo upload failed:",k)}finally{e.brandingBusy=!1}}},onBrandLogoRemove:async()=>{const f=e.selectedWorkspace;if(!(!f||e.brandingBusy)){e.brandingBusy=!0;try{await e.client.request("brand.removeLogo",{workspace:f});const b=Be();b[f]&&delete b[f].logoUrl}catch(b){console.error("Brand logo remove failed:",b)}finally{e.brandingBusy=!1}}},onBrandReset:async()=>{var b;const f=e.selectedWorkspace;if(!(!f||e.brandingBusy)){e.brandingBusy=!0;try{const k=await e.client.request("config.get"),A=k.config,E=((b=A==null?void 0:A.workspaces)==null?void 0:b[f])??{},{brand:M,...P}=E;await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[f]:{...P,brand:null}}}),baseHash:k.hash,note:"Brand reset to defaults",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");try{await e.client.request("brand.removeLogo",{workspace:f})}catch{}const R=Be();delete R[f],Tn(f)}catch(k){console.error("Brand reset failed:",k)}finally{e.brandingBusy=!1}}},tailscaleStatus:e.tailscaleStatus,tailscaleBusy:e.tailscaleBusy,tailscaleAuthUrl:e.tailscaleAuthUrl,tailscaleError:e.tailscaleError,tailscaleFunnelEnableUrl:e.tailscaleFunnelEnableUrl,tailscaleDisableConfirm:e.tailscaleDisableConfirm,tailscaleConnectProgress:e.tailscaleConnectProgress,tailscaleConnectMessage:e.tailscaleConnectMessage,tailscaleConnectSuccess:e.tailscaleConnectSuccess,onTailscaleEnable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleAuthUrl=null,T();try{const f=await e.client.request("tailscale.enable");f.authUrl?($t&&(clearInterval($t),$t=null),e.tailscaleConnectProgress=100,e.tailscaleConnectMessage="Waiting for authentication...",e.tailscaleAuthUrl=f.authUrl,Mi=setInterval(async()=>{try{const b=await e.client.request("tailscale.status");e.tailscaleStatus=b,e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,b.loggedIn&&(zt(),e.tailscaleAuthUrl=null,e.tailscaleConnectSuccess=!0,e.tailscaleConnectMessage="Connected!",setTimeout(()=>{e.tailscaleConnectSuccess=!1,e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1},1500))}catch{}},3e3),Pi=setTimeout(()=>{zt(),e.tailscaleBusy&&(e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)},3e5)):f.alreadyLoggedIn?(zt(),e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1):(zt(),e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)}catch(f){console.error("Tailscale enable failed:",f),zt(),e.tailscaleError=f.message||"Failed to enable Remote Access",e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1}}},onTailscaleErrorDismiss:()=>{e.tailscaleError=null},onTailscaleServeEnable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null;try{await e.client.request("tailscale.serve.enable"),await x()}catch(f){console.error("Tailscale serve enable failed:",f),e.tailscaleError=f.message||"Failed to enable Remote Access"}finally{e.tailscaleBusy=!1}}},onTailscaleServeDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.serve.disable"),await x()}catch(f){console.error("Tailscale serve disable failed:",f)}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelEnable:async()=>{var f;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleFunnelEnableUrl=null;try{await e.client.request("tailscale.funnel.enable"),await x()}catch(b){console.error("Tailscale funnel enable failed:",b);const k=b;(f=k.payload)!=null&&f.enableUrl&&(e.tailscaleFunnelEnableUrl=k.payload.enableUrl),e.tailscaleError=k.message||"Failed to enable Funnel"}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.funnel.disable"),await x()}catch(f){console.error("Tailscale funnel disable failed:",f)}finally{e.tailscaleBusy=!1}}},onTailscaleDisableConfirmToggle:()=>{e.tailscaleDisableConfirm=!e.tailscaleDisableConfirm},wifiModalOpen:e.wifiModalOpen,onWifiModalToggle:()=>{e.wifiModalOpen=!e.wifiModalOpen,e.wifiModalOpen||(e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null)},wifiStatus:e.wifiStatus,wifiNetworks:e.wifiNetworks,wifiBusy:e.wifiBusy,wifiError:e.wifiError,wifiPassword:e.wifiPassword,wifiSelectedSsid:e.wifiSelectedSsid,onWifiScan:async()=>{var f;if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{const[b,k]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(e.wifiNetworks=b.networks,k.connected&&k.signal==null&&((f=b.networks)!=null&&f.length)){const A=b.networks.find(E=>E.active)||b.networks.find(E=>E.ssid===k.ssid);A&&(k.signal=A.signal)}e.wifiStatus=k}catch(b){console.error("WiFi scan failed:",b),e.wifiError=b.message||"Failed to scan networks"}finally{e.wifiBusy=!1}}},onWifiConnect:async()=>{var b;if(e.wifiBusy||!e.wifiSelectedSsid)return;const f=e.wifiSelectedSsid;e.wifiBusy=!0,e.wifiError=null;try{const k=await e.client.request("wifi.connect",{ssid:f,password:e.wifiPassword});e.wifiPassword="",e.wifiSelectedSsid=null,e.wifiNetworks=[],e.wifiStatus={available:!0,connected:k.connected,ssid:k.ssid,signal:null,ip:k.ip,savedSsid:k.ssid,autoconnect:!0},e.wifiBusy=!1;try{const[A,E]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(E.connected&&E.signal==null&&((b=A.networks)!=null&&b.length)){const M=A.networks.find(P=>P.active)||A.networks.find(P=>P.ssid===E.ssid);M&&(E.signal=M.signal)}e.wifiStatus=E}catch{}}catch(k){console.error("WiFi connect failed:",k),e.wifiError=k.message||"Failed to connect",e.wifiBusy=!1}},onWifiDisconnect:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.disconnect"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const f=await e.client.request("wifi.status");e.wifiStatus=f}catch(f){console.error("WiFi disconnect failed:",f),e.wifiError=f.message||"Failed to disconnect"}finally{e.wifiBusy=!1}}},onWifiForget:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.forget"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const f=await e.client.request("wifi.status");e.wifiStatus=f}catch(f){console.error("WiFi forget failed:",f),e.wifiError=f.message||"Failed to forget network"}finally{e.wifiBusy=!1}}},onWifiDismiss:()=>{e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null},onWifiSelectSsid:f=>{e.wifiSelectedSsid=f,e.wifiPassword="",e.wifiError=null},onWifiPasswordChange:f=>{e.wifiPassword=f},networkPort:e.networkPort,networkHostname:e.networkHostname,networkPortInput:e.networkPortInput,networkHostnameInput:e.networkHostnameInput,networkModalOpen:e.networkModalOpen,networkBusy:e.networkBusy,networkError:e.networkError,networkSuccess:e.networkSuccess,onNetworkModalToggle:()=>{e.networkModalOpen=!e.networkModalOpen,e.networkModalOpen&&(e.networkPortInput=String(e.networkPort??""),e.networkHostnameInput=e.networkHostname,e.networkError=null,e.networkSuccess=null)},onNetworkPortChange:f=>{e.networkPortInput=f,e.networkError=null,e.networkSuccess=null},onNetworkHostnameChange:f=>{e.networkHostnameInput=f,e.networkError=null,e.networkSuccess=null},onNetworkSave:async()=>{if(e.networkBusy)return;e.networkBusy=!0,e.networkError=null,e.networkSuccess=null;const f=e.networkPortInput.trim(),b=Number.parseInt(f,10),k=e.networkHostnameInput.trim();if(!f||!Number.isFinite(b)||b<1024||b>65535){e.networkError="Port must be a number between 1024 and 65535",e.networkBusy=!1;return}const A=b!==e.networkPort,E=k!==e.networkHostname;if(!A&&!E){e.networkBusy=!1;return}try{E&&await e.client.request("network.setHostname",{hostname:k});const M={};A&&(M.gateway={port:b}),E&&(M.discovery={bonjourHostname:k});const P=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify(M),baseHash:P.hash,note:[A?`Port → ${b}`:null,E?`Hostname → ${k}`:null].filter(Boolean).join(", "),restartDelayMs:2e3}),e.networkSuccess="Saved — redirecting...";const R=window.location.protocol,F=E?`${k}.local`:window.location.hostname,H=A?b:e.networkPort,z=`${R}//${F}:${H}/setup`;setTimeout(()=>{window.location.href=z},1500)}catch(M){console.error("Network save failed:",M),e.networkError=M.message||"Failed to save network settings",e.networkBusy=!1}},wsProps:Mk(e)})}if(e.filesPage){const d=Lk(e);return ig({connected:e.connected,wsProps:Sn(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,currentDir:e.filesCurrentDir,message:e.filesMessage,uploadBusy:e.filesUploadBusy,reindexBusy:e.filesReindexBusy,memoryStatus:e.filesMemoryStatus,onRefresh:()=>{an(e,d),ls(e,d)},onReindex:()=>yf(e,d),onSelectFile:p=>{e.filesPendingDeletePath=null,cf(e,p,d)},onToggleSelectFile:p=>df(e,p,d),onToggleDir:p=>vf(e,p),onUpload:(p,v)=>hf(e,p,v,d),onNewFolder:(p,v)=>ff(e,p,v,d),onDownload:p=>Zc(e,p,d),onBulkDownload:()=>uf(e,d),onDelete:p=>{e.filesPendingDeletePath=null,gf(e,p,d)},pendingDeletePath:e.filesPendingDeletePath,onArmDelete:p=>{e.filesPendingDeletePath=p||null},onMoveToDir:(p,v)=>pf(e,p,v,d),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:p=>{const v=e.filesSearchAgentId??d;bf(e,p,v)},onSearchAgentChange:p=>{e.filesSearchAgentId=p},onSearchClear:()=>{wf(e)},onSearchQueryChange:p=>{e.filesSearchQuery=p}})}if(e.browserPage)return Yf({connected:e.connected,active:e.browserScreencastActive,loading:e.browserLoading,error:e.browserError,inputMode:e.browserInputMode,fullscreen:e.browserFullscreen,handoffPending:e.browserHandoffPending,handoffReason:e.browserHandoffReason,onStart:()=>Qw(e),onStop:()=>Jw(e),onToggleInput:()=>Xw(e),onToggleFullscreen:()=>Zw(e),onCompleteHandoff:()=>Yw(e),onCanvasMouseDown:d=>{const v=d.target.getBoundingClientRect(),x=Bn().translateCoordinates(d.clientX-v.left,d.clientY-v.top);co(e,"mousePressed",x.x,x.y,d.button===2?"right":d.button===1?"middle":"left")},onCanvasMouseUp:d=>{const v=d.target.getBoundingClientRect(),x=Bn().translateCoordinates(d.clientX-v.left,d.clientY-v.top);co(e,"mouseReleased",x.x,x.y)},onCanvasMouseMove:d=>{const p=Bn();if(p.shouldThrottleMouseMove())return;const S=d.target.getBoundingClientRect(),x=p.translateCoordinates(d.clientX-S.left,d.clientY-S.top);co(e,"mouseMoved",x.x,x.y)},onCanvasKeyDown:d=>{let p=0;d.altKey&&(p|=1),d.ctrlKey&&(p|=2),d.metaKey&&(p|=4),d.shiftKey&&(p|=8),uo(e,"keyDown",d.key,{code:d.code,modifiers:p||void 0}),d.key.length===1&&uo(e,"char",d.key,{text:d.key})},onCanvasKeyUp:d=>{uo(e,"keyUp",d.key,{code:d.code})}});if(e.adminsPage){const d=Pk(e),p=Ik(e);return qg({connected:e.connected,wsProps:Sn(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>gs(e,d),onAdd:v=>{ku(e,v,d,p).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:v=>$u(e,v,d,p),onNewPhoneChange:v=>e.handleAdminsNewPhoneChange(v)})}if(e.contactsPage){const d=Rk(e);return Jg({connected:e.connected,wsProps:Sn(e),loading:e.contactsLoading,saving:e.contactsSaving,records:e.contactsRecords,error:e.contactsError,searchQuery:e.contactsSearchQuery,editingId:e.contactsEditingId,showAddForm:e.contactsShowAddForm,newRecordPhone:e.contactsNewPhone,newRecordName:e.contactsNewName,deleteConfirmId:e.contactsDeleteConfirmId,addFieldForId:e.contactsAddFieldForId,addFieldKey:e.contactsAddFieldKey,addFieldValue:e.contactsAddFieldValue,onSearch:p=>e.contactsSearchQuery=p,onSearchSubmit:()=>Lt(e,d),onAdd:(p,v)=>xu(e,p,v,d),onDelete:p=>Su(e,p,d),onSetField:(p,v,S)=>qo(e,p,v,S,d),onDeleteField:(p,v)=>Au(e,p,v,d),onToggleExpand:p=>{e.contactsEditingId=e.contactsEditingId===p?null:p},onShowAddForm:()=>e.contactsShowAddForm=!0,onCancelAddForm:()=>{e.contactsShowAddForm=!1,e.contactsNewPhone="",e.contactsNewName=""},onNewRecordPhoneChange:p=>e.handleContactsNewPhoneChange(p),onNewRecordNameChange:p=>e.handleContactsNewNameChange(p),onRefresh:()=>Lt(e,d),onDeleteConfirmOpen:p=>e.contactsDeleteConfirmId=p,onDeleteConfirmClose:()=>e.contactsDeleteConfirmId=null,onAddFieldOpen:p=>{e.contactsAddFieldForId=p,e.contactsAddFieldKey="",e.contactsAddFieldValue=""},onAddFieldClose:()=>{e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue=""},onAddFieldKeyChange:p=>e.contactsAddFieldKey=p,onAddFieldValueChange:p=>e.contactsAddFieldValue=p,onAddFieldSubmit:()=>{const p=e.contactsAddFieldForId,v=e.contactsAddFieldKey.trim();!p||!v||(qo(e,p,v,e.contactsAddFieldValue,d),e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue="")}})}if(e.chatPage){const d=e.connected?null:"Disconnected from gateway.",p=Pl(e),v=e.chatAvatarUrl??p??null,S=(()=>{var f;const x=(f=e.configSnapshot)==null?void 0:f.config,T=x==null?void 0:x.publicChat;return(T==null?void 0:T.enabled)===!0})();return Qb({connected:e.connected,wsProps:Sn(e),publicChatEnabled:S,publicChatAccountId:e.selectedWorkspace??void 0,sessionKey:e.sessionKey,onSessionKeyChange:x=>{const T=e.selectedWorkspace??"";vo(),Wn(T,e.sessionKey,e.chatMessage),e.sessionKey=x,e.chatMessage=Kn(T,x),e.chatAttachments=[],e.chatStream=null,e.chatInterimText=null,e.chatSuggestions=[],e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:x,lastActiveSessionKey:x}),e.loadAssistantIdentity(),Oe(e),Ao(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:x=>{const T=Math.max(e.chatMessages.length+10,Fe);ci(e,e.sessionKey,{model:x}).then(()=>{Oe(e,{limit:T})})},onThinkingLevelChange:x=>{const T=Math.max(e.chatMessages.length+10,Fe);ci(e,e.sessionKey,{thinkingLevel:x==="off"?null:x}).then(()=>{Oe(e,{limit:T})})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,suggestions:e.chatSuggestions,onSuggestionClick:x=>{e.chatMessage=x,e.chatSuggestions=[],e.handleSendChat()},onVerboseChange:x=>{const T=Math.max(e.chatMessages.length+10,Fe);ci(e,e.sessionKey,{verboseLevel:x==="off"?null:x}).then(()=>{Oe(e,{limit:T})})},onFillerChange:x=>{const T=Math.max(e.chatMessages.length+10,Fe);ci(e,e.sessionKey,{fillerEnabled:x}).then(()=>{Oe(e,{limit:T})})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:v,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,disabledReason:d,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>{e.resetToolStream();const x=Math.max(e.chatMessages.length+10,Fe);return Promise.all([Oe(e,{limit:x}),Ao(e)])},onToggleFocusMode:()=>{},onChatScroll:x=>e.handleChatScroll(x),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()},onDraftChange:x=>{e.chatMessage=x,yr(e.selectedWorkspace??"",e.sessionKey,x)},requestUpdate:()=>e.requestUpdate(),attachments:e.chatAttachments,onAttachmentsChange:x=>e.chatAttachments=x,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:x=>e.removeQueuedMessage(x),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:x=>e.handleOpenSidebar(x),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:x=>e.handleSplitRatioChange(x),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?Bw({connected:e.connected,wsProps:Sn(e),activeTab:e.advancedTab,onTabChange:d=>{e.advancedTab=d,d==="cron"&&e.loadCron(),d==="skills"&&Xe(e,{clearMessages:!0}),d==="logs"&&(e.logsSubTab==="session"?Pn(e,{reset:!0}):Vt(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(r=(a=e.channelsSnapshot)==null?void 0:a.channelMeta)!=null&&r.length?e.channelsSnapshot.channelMeta.map(d=>d.id):((l=e.channelsSnapshot)==null?void 0:l.channelOrder)??[],channelLabels:((c=e.channelsSnapshot)==null?void 0:c.channelLabels)??{},channelMeta:((h=e.channelsSnapshot)==null?void 0:h.channelMeta)??[],agentIds:(()=>{var p;const d=ue(e);return((p=d==null?void 0:d.agents)==null?void 0:p.map(v=>v.id))??[]})(),runsJobId:e.cronRunsJobId,runs:e.cronRuns,newEventModalOpen:e.cronNewEventModal,onNewEventModalOpen:()=>{e.cronNewEventModal=!0},onNewEventModalClose:()=>{e.cronNewEventModal=!1,e.cronEditJobId=null},detailJobId:e.cronDetailJobId,editJobId:e.cronEditJobId,onDetailOpen:d=>{e.cronDetailJobId=d.id,wo(e,d.id)},onDetailClose:()=>{e.cronDetailJobId=null},onEdit:d=>{e.cronForm=hh(d),e.cronEditJobId=d.id,e.cronDetailJobId=null},onEditSave:()=>{const d=e.cronEditJobId;d&&fh(e,d).then(()=>{e.cronEditJobId=null})},onFormChange:d=>e.cronForm={...e.cronForm,...d},onRefresh:()=>e.loadCron(),onAdd:()=>{lh(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(d,p)=>ch(e,d,p),onRun:d=>dh(e,d),onRemove:d=>{e.cronPendingDeleteId=null,ph(e,d)},pendingDeleteId:e.cronPendingDeleteId,onArmDelete:d=>{e.cronPendingDeleteId=d||null},onLoadRuns:d=>wo(e,d),runModalJobId:e.cronRunModalJobId,runModalJobName:e.cronRunModalJobName,runResult:e.cronRunResult,onRunModalClose:()=>{e.cronRunModalJobId=null,e.cronRunModalJobName="",e.cronRunResult=null}},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,typeFilter:e.skillsTypeFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,detail:e.skillDetail,detailTab:e.skillDetailTab,addModal:e.skillAddModal,addForm:e.skillAddForm,formSource:e.skillAddFormSource,editTab:e.skillEditTab,drafts:e.skillDrafts,onFilterChange:d=>e.skillsFilter=d,onTypeFilterChange:d=>e.skillsTypeFilter=d,onRefresh:()=>Xe(e,{clearMessages:!0}),onToggle:(d,p)=>Pc(e,d,p),onEdit:(d,p)=>Mc(e,d,p),onSaveKey:d=>Ic(e,d),onInstall:(d,p,v)=>Lc(e,d,p,v),onViewDetail:d=>Rc(e,d),onDetailClose:()=>Dc(e),onDetailTab:d=>Bc(e,d),onAddOpen:()=>Nc(e),onAddClose:()=>Oc(e),onImportDraft:d=>Fc(e,d),onInstallDraft:d=>Uc(e,d),onDeleteDraft:d=>Wc(e,d),onAddSave:()=>la(e),onAddFormUpdate:(d,p)=>{e.skillAddForm={...e.skillAddForm,[d]:p}},onDelete:d=>jc(e,d),onEditSkill:d=>Kc(e,d),onEditDetail:d=>zc(e,d),onRefUpdate:(d,p)=>qc(e,d,p),onEditTab:d=>Hc(e,d)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:d=>{e.logsSubTab=d,d==="session"?Pn(e,{reset:!0}):Vt(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,chipsExpanded:e.sessionLogsChipsExpanded,expandedIds:e.sessionLogsExpandedIds,onFilterTextChange:d=>e.sessionLogsFilterText=d,onTypeToggle:(d,p)=>{const v=e;v.sessionLogsTypeFilters={...v.sessionLogsTypeFilters,[d]:p}},onAgentToggle:(d,p)=>{const v=e;v.sessionLogsAgentFilters={...v.sessionLogsAgentFilters,[d]:p}},onToggleAutoFollow:d=>e.sessionLogsAutoFollow=d,onToggleChips:()=>{const d=e;d.sessionLogsChipsExpanded=!d.sessionLogsChipsExpanded},onToggleExpand:d=>{const p=e,v=new Set(p.sessionLogsExpandedIds);v.has(d)?v.delete(d):v.add(d),p.sessionLogsExpandedIds=v,p.requestUpdate()},onRefresh:()=>{Pn(e,{reset:!0})},onExport:(d,p)=>e.exportSessionLogs(d,p),onScroll:d=>e.handleSessionLogsScroll(d)},loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,chipsExpanded:e.logsChipsExpanded,truncated:e.logsTruncated,onFilterTextChange:d=>e.logsFilterText=d,onLevelToggle:(d,p)=>{e.logsLevelFilters={...e.logsLevelFilters,[d]:p}},onToggleAutoFollow:d=>e.logsAutoFollow=d,onToggleChips:()=>{const d=e;d.logsChipsExpanded=!d.logsChipsExpanded},onRefresh:()=>Vt(e,{reset:!0}),onExport:(d,p)=>e.exportSessionLogs(d,p),onScroll:d=>e.handleLogsScroll(d)}}):(window.location.replace("/chat"),u``)}function Wk(e){const t=new Date(e),n=t.toLocaleDateString("en-GB",{day:"2-digit",month:"short"}),i=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${n} ${i}`}function Il(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function Kk(e,t,n){return u`
|
|
4530
|
+
`;if(!e.publicChatAuthenticated)return kk({authMode:e.publicChatConfig.auth??"anonymous",authStep:e.publicChatAuthStep,connected:e.connected,client:e.client,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,accountId:e.publicChatConfig.accountId,cookieTtlDays:e.publicChatConfig.cookieTtlDays,otpChannels:e.publicChatConfig.otpChannels,verifyMethods:e.publicChatConfig.verifyMethods,onAuthenticated:$=>{var T;e.publicChatSessionKey=$,e.sessionKey=$,e.publicChatAuthenticated=!0,e.publicChatAuthStep="ready";const S=((T=e.publicChatConfig)==null?void 0:T.accountId)??"";e.chatMessage=Kn(S,$),le(async()=>{const{loadChatHistory:f}=await Promise.resolve().then(()=>Ni);return{loadChatHistory:f}},void 0,import.meta.url).then(({loadChatHistory:f})=>{f(e)})},onAuthStepChange:$=>{e.publicChatAuthStep=$},requestUpdate:()=>{e.requestUpdate()}});const d=(t=e.publicChatConfig)==null?void 0:t.greeting,p=e.chatMessages,g=!e.chatLoading&&d?[{role:"assistant",content:[{type:"text",text:d}],timestamp:0},...Array.isArray(p)?p:[]]:p;return Nw({connected:e.connected,sessionKey:e.sessionKey,loading:e.chatLoading,sending:e.chatSending,messages:g,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,assistantAvatarUrl:e.chatAvatarUrl??Pl(e)??null,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,canAbort:!!e.chatRunId,disabledReason:e.connected?null:"Disconnected.",error:e.lastError,assistantName:e.assistantName,assistantAvatar:e.assistantAvatar,suggestions:e.chatSuggestions,onSuggestionClick:$=>{e.chatMessage=$,e.chatSuggestions=[],e.handleSendChat()},onRefresh:()=>(e.resetToolStream(),le(async()=>{const{loadChatHistory:$}=await Promise.resolve().then(()=>Ni);return{loadChatHistory:$}},void 0,import.meta.url).then(({loadChatHistory:$})=>{$(e)})),onDraftChange:$=>{var T;e.chatMessage=$;const S=((T=e.publicChatConfig)==null?void 0:T.accountId)??"";yr(S,e.sessionKey,$)},requestUpdate:()=>e.requestUpdate(),attachments:e.chatAttachments,onAttachmentsChange:$=>e.chatAttachments=$,onSend:()=>e.handleSendChat(),onAbort:()=>{e.handleAbortChat()},onQueueRemove:$=>e.removeQueuedMessage($),onChatScroll:$=>e.handleChatScroll($),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()}})}if(e.connected&&e.accessState.checked){const{accessState:d}=e;if(d.hasPins&&!d.authenticated)return wl({show:!0,isFirstTime:!1,accounts:d.accounts,error:d.error,busy:d.busy,onSubmit:(p,g)=>{g!=null&&e.handlePinSubmit(p,g)},changePinMode:e.loginChangePinMode,onToggleChangePinMode:()=>e.toggleChangePinMode(),changePinBusy:e.changePinBusy,changePinError:e.changePinError,changePinSuccess:e.changePinSuccess,onChangePin:(p,g,$)=>e.handleChangePin(p,g,$)});if(!d.hasMasterPin&&!d.authenticated&&e.setup)return wl({show:!0,isFirstTime:!0,accounts:[],error:d.error,busy:d.busy,onSubmit:p=>e.handleSetMasterPin(p)});if(!d.hasMasterPin&&!d.authenticated&&!e.setup)return window.location.href="/setup",w}if(e.setup){const d=Nk(e.channelsSnapshot),p=((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.whatsapp)??[],g=Ok(e.channelsSnapshot),$=Fk(e),S=async()=>{e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null},T=()=>{const f=Date.now();e.tailscaleConnectProgress=0,e.tailscaleConnectMessage=fo[0][1],e.tailscaleConnectSuccess=!1,e.tailscaleError=null,zt(),xt=setInterval(()=>{const b=(Date.now()-f)/1e3,k=Math.min(95,95*(1-Math.exp(-b/30)));e.tailscaleConnectProgress=Math.round(k);let A=fo[0][1];for(const[E,M]of fo)b>=E&&(A=M);e.tailscaleConnectMessage=A},500)};return Kg({connected:e.connected,serverPlatform:((o=(s=e.hello)==null?void 0:s.server)==null?void 0:o.platform)??null,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:f=>e.handleLicenseKeyChange(f),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:d,whatsappAccounts:p,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(),uninstallConfirm:e.uninstallConfirm,uninstallBusy:e.uninstallBusy,uninstallDone:e.uninstallDone,uninstallError:e.uninstallError,uninstallConfirmText:e.uninstallConfirmText,onUninstallConfirm:()=>e.handleUninstallConfirm(),onUninstallCancel:()=>e.handleUninstallCancel(),onUninstallConfirmTextChange:f=>e.handleUninstallConfirmTextChange(f),onUninstallRun:()=>e.handleUninstallRun(),onUninstallDismiss:()=>e.handleUninstallDismiss(),onStartAuth:()=>e.handleAuthStart(),onSubmitAuthCode:f=>e.handleAuthSubmitCode(f),onAuthCodeChange:f=>e.handleAuthCodeChange(f),onSkipToWhatsApp:()=>e.handleSkipToWhatsApp(),onWhatsAppRelink:async f=>{await e.handleWhatsAppStart(!0,f),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(f),await ee(e,!0),e.requestUpdate())},onWhatsAppUnlink:async f=>{await e.handleWhatsAppLogout(f)},onWhatsAppReset:async f=>{await e.handleWhatsAppLogout(f),await e.handleWhatsAppStart(!0,f),e.whatsappLoginQrDataUrl&&(await e.handleWhatsAppWait(f),await ee(e,!0),e.requestUpdate())},onRefreshStatus:async()=>{await ee(e,!0),await e.handleGatewayHealthCheck()},onWhatsAppBack:()=>{e.whatsappLoginQrDataUrl=null,e.whatsappLoginMessage=null,e.whatsappLoginConnected=null,e.whatsappActiveQrAccountId=null,e.requestUpdate(),ee(e,!0)},onRestartGateway:()=>e.handleGatewayRestart(),onRemoveWhatsAppAccount:f=>e.handleRemoveWhatsAppAccount(f),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:f=>{e.newWorkspacePin=f},onWorkspaceCreate:async(f,b)=>{const k=e.newWorkspacePin;await e.handleWorkspaceCreate(f,b),k.match(/^\d{4,6}$/)&&(await Ak(e,f,k),e.newWorkspacePin="")},onWorkspaceRemove:f=>e.handleWorkspaceRemove(f),onSetAddingWorkspace:f=>{e.addingWorkspace=f},onSetNewWorkspaceName:f=>{e.newWorkspaceName=f},onSetNewWorkspacePath:f=>{e.newWorkspacePath=f},onSetWorkspaceRemoveConfirm:f=>{e.workspaceRemoveConfirm=f},renamingWorkspace:e.renamingWorkspace,renameWorkspaceName:e.renameWorkspaceName,onWorkspaceRenameStart:()=>e.handleWorkspaceRenameStart(),onWorkspaceRenameCancel:()=>e.handleWorkspaceRenameCancel(),onWorkspaceRename:(f,b)=>e.handleWorkspaceRename(f,b),whatsappDmPolicy:(()=>{const f=ue(e),b=f==null?void 0:f.whatsappAccountId,k=b?p.find(A=>A.accountId===b):p[0];return(k==null?void 0:k.dmPolicy)??null})(),onWhatsAppDmToggle:async()=>{var P;const f=ue(e),b=f==null?void 0:f.whatsappAccountId,k=b?p.find(R=>R.accountId===b):p[0];if(!k)return;const E=k.dmPolicy!=null&&k.dmPolicy!=="disabled"?"disabled":"open",M=E==="open"?{dmPolicy:E,allowFrom:["*"]}:{dmPolicy:E};try{const R=await e.client.request("config.get"),F=R.config,H=(P=F==null?void 0:F.channels)==null?void 0:P.whatsapp,ke=((H==null?void 0:H.accounts)??{})[k.accountId]?{channels:{whatsapp:{accounts:{[k.accountId]:M}}}}:{channels:{whatsapp:M}};await e.client.request("config.patch",{raw:JSON.stringify(ke),baseHash:R.hash,note:`WhatsApp DM policy → ${E}`,skipRestart:!0}),await ee(e,!1)}catch(R){console.error("DM toggle failed:",R)}},whatsappModel:(()=>{var P,R;const f=ue(e);if(!f)return null;const b=f.agents.find(F=>F.id.endsWith("-public")||F.id==="public");if(!b)return null;const k=(P=e.configSnapshot)==null?void 0:P.config,A=(R=k==null?void 0:k.agents)==null?void 0:R.list;if(!Array.isArray(A))return null;const E=A.find(F=>F.id===b.id);if(!(E!=null&&E.model))return null;const M=typeof E.model=="string"?E.model:E.model.primary;return(M==null?void 0:M.trim())||null})(),whatsappModelCatalog:e.chatModelCatalog??[],onWhatsAppModelChange:async f=>{const b=ue(e);if(!b)return;const k=b.agents.find(A=>A.id.endsWith("-public")||A.id==="public");if(k)try{const A=await e.client.request("config.get"),E=A.config,M=(E==null?void 0:E.agents)??{},P=Array.isArray(M.list)?[...M.list]:[],R=P.findIndex(H=>H.id===k.id);if(f)R>=0?P[R]={...P[R],model:f}:P.push({id:k.id,model:f});else if(R>=0){const{model:H,...z}=P[R];Object.keys(z).length<=1?P.splice(R,1):P[R]=z}const F=P.length>0?{agents:{list:P}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(F),baseHash:A.hash,note:`Public agent model → ${f||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Model change failed:",A)}},whatsappThinkingLevel:(()=>{var M,P,R;const f=ue(e);if(!f)return null;const b=f.agents.find(F=>F.id.endsWith("-public")||F.id==="public");if(!b)return null;const k=(M=e.configSnapshot)==null?void 0:M.config,A=(P=k==null?void 0:k.agents)==null?void 0:P.list;if(!Array.isArray(A))return null;const E=A.find(F=>F.id===b.id);return((R=E==null?void 0:E.thinkingLevel)==null?void 0:R.trim())||null})(),onWhatsAppThinkingChange:async f=>{const b=ue(e);if(!b)return;const k=b.agents.find(A=>A.id.endsWith("-public")||A.id==="public");if(k)try{const A=await e.client.request("config.get"),E=A.config,M=(E==null?void 0:E.agents)??{},P=Array.isArray(M.list)?[...M.list]:[],R=P.findIndex(z=>z.id===k.id),F=f==="off"?void 0:f;if(F)R>=0?P[R]={...P[R],thinkingLevel:F}:P.push({id:k.id,thinkingLevel:F});else if(R>=0){const{thinkingLevel:z,...ke}=P[R];Object.keys(ke).length<=1?P.splice(R,1):P[R]=ke}const H=P.length>0?{agents:{list:P}}:{agents:{list:null}};await e.client.request("config.patch",{raw:JSON.stringify(H),baseHash:A.hash,note:`Public agent thinking → ${F||"default"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Thinking change failed:",A)}},whatsappGroupPolicy:(()=>{var R,F;const f=(R=e.configSnapshot)==null?void 0:R.config,b=(F=f==null?void 0:f.channels)==null?void 0:F.whatsapp,k=ue(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},M=A?E[A]:void 0;return(M==null?void 0:M.groupPolicy)??(b==null?void 0:b.groupPolicy)??"allowlist"})(),whatsappGroupRequireMention:(()=>{var F,H;const f=(F=e.configSnapshot)==null?void 0:F.config,b=(H=f==null?void 0:f.channels)==null?void 0:H.whatsapp,k=ue(e),A=k==null?void 0:k.whatsappAccountId,E=(b==null?void 0:b.accounts)??{},M=A?E[A]:void 0,R=((M==null?void 0:M.groups)??(b==null?void 0:b.groups)??{})["*"];return(R==null?void 0:R.requireMention)!==!1})(),onWhatsAppGroupToggle:async()=>{var k;const f=ue(e),b=f==null?void 0:f.whatsappAccountId;try{const A=await e.client.request("config.get"),E=A.config,M=((k=E==null?void 0:E.channels)==null?void 0:k.whatsapp)??{},P=M.accounts??{},R=b?P[b]:void 0,F=(R==null?void 0:R.groupPolicy)??M.groupPolicy??"allowlist",H=F==="disabled"||F==="allowlist",z=H?"open":"disabled",ke=H?{"*":{}}:void 0,_e={groupPolicy:z};ke&&(_e.groups=ke);const Ke=R?{channels:{whatsapp:{accounts:{[b]:_e}}}}:{channels:{whatsapp:_e}};await e.client.request("config.patch",{raw:JSON.stringify(Ke),baseHash:A.hash,note:`WhatsApp groups → ${z}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Group toggle failed:",A)}},onWhatsAppGroupMentionChange:async f=>{var A;const b=ue(e),k=b==null?void 0:b.whatsappAccountId;try{const E=await e.client.request("config.get"),M=E.config,R=(((A=M==null?void 0:M.channels)==null?void 0:A.whatsapp)??{}).accounts??{},F=k?R[k]:void 0,H={"*":{requireMention:f}},z=F?{channels:{whatsapp:{accounts:{[k]:{groups:H}}}}}:{channels:{whatsapp:{groups:H}}};await e.client.request("config.patch",{raw:JSON.stringify(z),baseHash:E.hash,note:`WhatsApp group mention → ${f?"when mentioned":"always"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(E){console.error("Group mention change failed:",E)}},whatsappSettingsOpen:e.whatsappSettingsOpen??!1,onWhatsAppSettingsOpen:()=>{e.whatsappSettingsOpen=!0},onWhatsAppSettingsClose:()=>{e.whatsappSettingsOpen=!1},imessageConfigured:g.configured,imessageRunning:g.running,imessageConnected:g.connected,imessageLastError:g.lastError,imessageSelfChatMode:g.selfChatMode,imessageCliPath:g.cliPath,imessageEnabling:e.imessageEnabling,imessageEnableConfirm:e.imessageEnableConfirm,imessageOwnerWorkspace:$,onIMessageEnable:()=>{e.imessageEnableConfirm=!0},onIMessageEnableConfirm:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),b=f.config,k=(b==null?void 0:b.bindings)??[],A=ue(e),E=A==null?void 0:A.agents.find(H=>H.id.endsWith("-admin")||H.id==="admin"),M=(E==null?void 0:E.id)??"admin",P=k.filter(H=>{var z;return((z=H.match)==null?void 0:z.channel)!=="imessage"}),R=[{agentId:M,match:{channel:"imessage",peer:{kind:"dm",id:"__self__"}},meta:{imessageOwner:!0}}],F=[...P,...R];await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!0,dmPolicy:"disabled",allowFrom:["*"]}},bindings:F}),baseHash:f.hash,note:"Enable iMessage (self-chat) for "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),Ue(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageEnableCancel:()=>{e.imessageEnableConfirm=!1},onIMessageProbe:async()=>{e.imessageEnabling=!0,e.requestUpdate();try{await ee(e,!0)}finally{e.imessageEnabling=!1}},onIMessageDisconnect:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),b=f.config,A=((b==null?void 0:b.bindings)??[]).filter(E=>{var M;return((M=E.match)==null?void 0:M.channel)!=="imessage"});await e.client.request("config.patch",{raw:JSON.stringify({channels:{imessage:{selfChatMode:!1,dmPolicy:"disabled"}},bindings:A}),baseHash:f.hash,note:"Disconnect iMessage"}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),Ue(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},onIMessageReassign:async()=>{e.imessageEnabling=!0;try{const f=await e.client.request("config.get"),b=f.config,k=(b==null?void 0:b.bindings)??[],A=ue(e),E=A==null?void 0:A.agents.find(F=>F.id.endsWith("-admin")||F.id==="admin"),M=(E==null?void 0:E.id)??"admin",P=k.filter(F=>{var H;return((H=F.match)==null?void 0:H.channel)!=="imessage"}),R=[{agentId:M,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,...R]}),baseHash:f.hash,note:"Reassign iMessage to "+((A==null?void 0:A.name)??"default")}),e.imessageEnableConfirm=!1,setTimeout(()=>{Promise.all([ee(e,!0),Ue(e)]).then(()=>{e.imessageEnabling=!1})},3e3)}catch{e.imessageEnabling=!1}},infoModalOpen:e.infoModalOpen,onInfoModalOpen:f=>{var b,k,A,E;if(e.infoModalOpen=f,f==="remote-access"){const M=((b=e.tailscaleStatus)==null?void 0:b.tailnetUrl)??((k=e.tailscaleStatus)!=null&&k.hostname?`https://${e.tailscaleStatus.hostname}`:null);M&&!e.remoteAccessQrDataUrl&&e.client.request("qr.generate",{url:M}).then(P=>{e.remoteAccessQrDataUrl=(P==null?void 0:P.dataUrl)??null}).catch(()=>{})}else if(f==="public-chat"){const M=((A=e.tailscaleStatus)==null?void 0:A.publicUrl)??((E=e.tailscaleStatus)==null?void 0:E.tailnetUrl)??null,P=e.selectedWorkspace??null;if(M&&P){const R=`${M}/public/chat/${encodeURIComponent(P)}`;e.publicChatQrDataUrl||e.client.request("qr.generate",{url:R}).then(F=>{e.publicChatQrDataUrl=(F==null?void 0:F.dataUrl)??null}).catch(()=>{})}}},onInfoModalClose:()=>{e.infoModalOpen=null},remoteAccessQrDataUrl:e.remoteAccessQrDataUrl??null,publicChatQrDataUrl:e.publicChatQrDataUrl??null,publicChatFullUrl:(()=>{var k,A;const f=((k=e.tailscaleStatus)==null?void 0:k.publicUrl)??((A=e.tailscaleStatus)==null?void 0:A.tailnetUrl)??null,b=e.selectedWorkspace??null;return!f||!b?null:`${f}/public/chat/${encodeURIComponent(b)}`})(),isMaster:e.accessState.master,apiKeyProviders:e.apiKeyProviders,apiKeyModalOpen:e.apiKeyModalOpen,apiKeyBusy:e.apiKeyBusy,apiKeyError:e.apiKeyError,apiKeySuccess:e.apiKeySuccess,apiKeySavingProvider:e.apiKeySavingProvider,onApiKeyModalOpen:()=>{e.apiKeyModalOpen=!0,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeyModalClose:()=>{e.apiKeyModalOpen=!1,e.apiKeyError=null,e.apiKeySuccess=null,e.apiKeySavingProvider=null},onApiKeySave:async(f,b)=>{e.apiKeySavingProvider=f,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await $l(e.client,f,b);const k=`${f} key saved`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}f==="anthropic"&&await e.handleAuthStatusCheck(),setTimeout(()=>{e.apiKeySuccess===k&&(e.apiKeySuccess=null)},2500)}catch(k){e.apiKeyError=k instanceof Error?k.message:"Failed to save key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyRemove:async f=>{e.apiKeySavingProvider=f,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await ik(e.client,f);const b=`${f} key removed`;e.apiKeySuccess=b,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===b&&(e.apiKeySuccess=null)},2500)}catch(b){e.apiKeyError=b instanceof Error?b.message:"Failed to remove key",e.apiKeySavingProvider=null}finally{e.apiKeyBusy=!1}},onApiKeyDisable:async(f,b)=>{e.apiKeySavingProvider=f,e.apiKeyBusy=!0,e.apiKeyError=null,e.apiKeySuccess=null;try{await sk(e.client,f,b);const k=`${f} ${b?"disabled":"enabled"}`;e.apiKeySuccess=k,e.apiKeySavingProvider=null;try{e.apiKeyProviders=await _i(e.client)}catch{}setTimeout(()=>{e.apiKeySuccess===k&&(e.apiKeySuccess=null)},2500)}catch(k){e.apiKeyError=k instanceof Error?k.message:`Failed to ${b?"disable":"enable"} key`,e.apiKeySavingProvider=null}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:f=>{e.authApiKeyInput=f},onAuthApiKeySubmit:async()=>{const f=e.authApiKeyInput.trim();if(f){e.authApiKeyBusy=!0,e.authApiKeyError=null;try{await $l(e.client,"anthropic",f),await e.handleAuthStatusCheck(),e.authApiKeyMode=!1,e.authApiKeyInput=""}catch(b){e.authApiKeyError=b instanceof Error?b.message:"Failed to save API key"}finally{e.authApiKeyBusy=!1}}},accountHasPin:(()=>{var b;const f=e.selectedWorkspace??((b=e.workspaces[0])==null?void 0:b.name);return f?e.accessState.accounts.some(k=>k.id===f):!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:(f,b)=>{var A;const k=e.selectedWorkspace??((A=e.workspaces[0])==null?void 0:A.name);k&&e.handleAccountPinSave(k,f,b)},publicChatAccountId:e.selectedWorkspace??null,publicChatSettingsOpen:e.publicChatSettingsOpen,onPublicChatSettingsOpen:()=>{e.publicChatSettingsOpen=!0},onPublicChatSettingsClose:()=>{e.publicChatSettingsOpen=!1},publicChatWidgetModalOpen:e.publicChatWidgetModalOpen,onPublicChatWidgetModalOpen:()=>{e.publicChatWidgetModalOpen=!0},onPublicChatWidgetModalClose:()=>{e.publicChatWidgetModalOpen=!1},publicChatEnabled:(()=>{var k;const f=(k=e.configSnapshot)==null?void 0:k.config,b=f==null?void 0:f.publicChat;return(b==null?void 0:b.enabled)===!0})(),publicChatAuthMode:(()=>{var M,P;const f=(M=e.configSnapshot)==null?void 0:M.config,b=f==null?void 0:f.publicChat,k=e.selectedWorkspace??"",A=b==null?void 0:b.accountSettings,E=((P=A==null?void 0:A[k])==null?void 0:P.auth)??(b==null?void 0:b.auth);return E==="verified"||E==="choice"?E:"anonymous"})(),publicChatGreeting:(()=>{var E;const f=(E=e.configSnapshot)==null?void 0:E.config,b=f==null?void 0:f.publicChat,k=b==null?void 0:b.greetings,A=e.selectedWorkspace??"";return(A&&(k==null?void 0:k[A]))??""})(),publicChatGreetingBusy:e.publicChatGreetingBusy,onPublicChatGreetingToggle:async()=>{var b;if(e.publicChatGreetingBusy)return;const f=e.selectedWorkspace??"";if(f){e.publicChatGreetingBusy=!0;try{const k=await e.client.request("config.get"),A=k.config,E=(b=A==null?void 0:A.publicChat)==null?void 0:b.greetings;if(E==null?void 0:E[f]){const P={publicChat:{greetings:{[f]:null}}};await e.client.request("config.patch",{raw:JSON.stringify(P),baseHash:k.hash,note:`Public chat greeting → disabled (${f})`,skipRestart:!0})}else{const P=await e.client.request("public.greeting.generate",{accountId:f});if(P!=null&&P.ok&&P.greeting){const R=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[f]:P.greeting}}}),baseHash:R.hash,note:`Public chat greeting → enabled (${f})`,skipRestart:!0})}}e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat greeting toggle failed:",k)}finally{e.publicChatGreetingBusy=!1}}},onPublicChatGreetingSave:async f=>{const b=e.selectedWorkspace??"";if(b)try{const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[b]:f}}}),baseHash:k.hash,note:`Public chat greeting text updated (${b})`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat greeting save failed:",k)}},onPublicChatGreetingRegenerate:async()=>{if(e.publicChatGreetingBusy)return;const f=e.selectedWorkspace??"";if(f){e.publicChatGreetingBusy=!0;try{const b=await e.client.request("public.greeting.generate",{accountId:f});if(b!=null&&b.ok&&b.greeting){const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{greetings:{[f]:b.greeting}}}),baseHash:k.hash,note:`Public chat greeting regenerated (${f})`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}}catch(b){console.error("Public chat greeting regeneration failed:",b)}finally{e.publicChatGreetingBusy=!1}}},publicChatBusy:e.publicChatToggleBusy,onPublicChatToggle:async()=>{var f;if(!e.publicChatToggleBusy){e.publicChatToggleBusy=!0;try{const b=await e.client.request("config.get"),k=b.config,A=((f=k==null?void 0:k.publicChat)==null?void 0:f.enabled)===!0;await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{enabled:!A}}),baseHash:b.hash,note:`Public chat → ${A?"disabled":"enabled"}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get"),e.publicChatQrDataUrl=null}catch(b){console.error("Public chat toggle failed:",b)}finally{e.publicChatToggleBusy=!1}}},onPublicChatAuthModeChange:async f=>{if(e.publicChatToggleBusy)return;const b=e.selectedWorkspace??"";if(b){e.publicChatToggleBusy=!0;try{const k=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{accountSettings:{[b]:{auth:f}}}}),baseHash:k.hash,note:`Public chat auth → ${f}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(k){console.error("Public chat auth mode change failed:",k)}finally{e.publicChatToggleBusy=!1}}},publicChatEmailFrom:(()=>{var k,A;const f=(k=e.configSnapshot)==null?void 0:k.config,b=(A=f==null?void 0:f.publicChat)==null?void 0:A.email;return(b==null?void 0:b.from)??""})(),publicChatEmailBusy:e.publicChatEmailBusy,publicChatVerifyMethods:(()=>{var M,P;const f=(M=e.configSnapshot)==null?void 0:M.config,b=f==null?void 0:f.publicChat,k=e.selectedWorkspace??"",A=b==null?void 0:b.accountSettings,E=((P=A==null?void 0:A[k])==null?void 0:P.verifyMethods)??(b==null?void 0:b.verifyMethods);return Array.isArray(E)?E:["whatsapp","sms"]})(),onPublicChatEmailSave:async(f,b)=>{if(e.publicChatEmailBusy)return;const k=e.selectedWorkspace??"";if(k){e.publicChatEmailBusy=!0;try{const A=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify({publicChat:{email:{from:f||void 0},accountSettings:{[k]:{verifyMethods:b}}}}),baseHash:A.hash,note:"Update email verification settings for public chat",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get")}catch(A){console.error("Email verification save failed:",A)}finally{e.publicChatEmailBusy=!1}}},brandAccentColor:(()=>{var k;const f=e.selectedWorkspace;return f?((k=Be()[f])==null?void 0:k.accentColor)??"":""})(),brandBackgroundColor:(()=>{var k;const f=e.selectedWorkspace;return f?((k=Be()[f])==null?void 0:k.backgroundColor)??"":""})(),brandHasLogo:(()=>{var k;const f=e.selectedWorkspace;return f?!!((k=Be()[f])!=null&&k.logoUrl):!1})(),brandingBusy:e.brandingBusy,brandingExpanded:e.brandingExpanded,onBrandingToggle:()=>{e.brandingExpanded=!e.brandingExpanded},onBrandAccentColorChange:async f=>{var k;const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const A=await e.client.request("config.get"),E=A.config,M=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=M.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...M,brand:{...P,accentColor:f}}}}),baseHash:A.hash,note:`Brand accent → ${f}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const R=Be();R[b]||(R[b]={}),R[b].accentColor=f,Tn(b)}catch(A){console.error("Brand accent change failed:",A)}finally{e.brandingBusy=!1}}},onBrandBackgroundColorChange:async f=>{var k;const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const A=await e.client.request("config.get"),E=A.config,M=((k=E==null?void 0:E.workspaces)==null?void 0:k[b])??{},P=M.brand??{};await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[b]:{...M,brand:{...P,backgroundColor:f}}}}),baseHash:A.hash,note:`Brand background → ${f}`,skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");const R=Be();R[b]||(R[b]={}),R[b].backgroundColor=f,Tn(b)}catch(A){console.error("Brand background change failed:",A)}finally{e.brandingBusy=!1}}},onBrandLogoUpload:async f=>{const b=e.selectedWorkspace;if(!(!b||e.brandingBusy)){e.brandingBusy=!0;try{const k=await f.arrayBuffer(),A=new Uint8Array(k);let E="";for(let R=0;R<A.length;R++)E+=String.fromCharCode(A[R]);const M=btoa(E);await e.client.request("brand.uploadLogo",{workspace:b,data:M,mimeType:f.type});const P=Be();P[b]||(P[b]={}),P[b].logoUrl=`/brand-logo/${encodeURIComponent(b)}`}catch(k){console.error("Brand logo upload failed:",k)}finally{e.brandingBusy=!1}}},onBrandLogoRemove:async()=>{const f=e.selectedWorkspace;if(!(!f||e.brandingBusy)){e.brandingBusy=!0;try{await e.client.request("brand.removeLogo",{workspace:f});const b=Be();b[f]&&delete b[f].logoUrl}catch(b){console.error("Brand logo remove failed:",b)}finally{e.brandingBusy=!1}}},onBrandReset:async()=>{var b;const f=e.selectedWorkspace;if(!(!f||e.brandingBusy)){e.brandingBusy=!0;try{const k=await e.client.request("config.get"),A=k.config,E=((b=A==null?void 0:A.workspaces)==null?void 0:b[f])??{},{brand:M,...P}=E;await e.client.request("config.patch",{raw:JSON.stringify({workspaces:{[f]:{...P,brand:null}}}),baseHash:k.hash,note:"Brand reset to defaults",skipRestart:!0}),e.configSnapshot=await e.client.request("config.get");try{await e.client.request("brand.removeLogo",{workspace:f})}catch{}const R=Be();delete R[f],Tn(f)}catch(k){console.error("Brand reset failed:",k)}finally{e.brandingBusy=!1}}},tailscaleStatus:e.tailscaleStatus,tailscaleBusy:e.tailscaleBusy,tailscaleAuthUrl:e.tailscaleAuthUrl,tailscaleError:e.tailscaleError,tailscaleServeEnableUrl:e.tailscaleServeEnableUrl,tailscaleFunnelEnableUrl:e.tailscaleFunnelEnableUrl,tailscaleDisableConfirm:e.tailscaleDisableConfirm,tailscaleConnectProgress:e.tailscaleConnectProgress,tailscaleConnectMessage:e.tailscaleConnectMessage,tailscaleConnectSuccess:e.tailscaleConnectSuccess,onTailscaleEnable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleAuthUrl=null,T();try{const f=await e.client.request("tailscale.enable");f.authUrl?(xt&&(clearInterval(xt),xt=null),e.tailscaleConnectProgress=100,e.tailscaleConnectMessage="Waiting for authentication...",e.tailscaleAuthUrl=f.authUrl,Mi=setInterval(async()=>{try{const b=await e.client.request("tailscale.status");e.tailscaleStatus=b,e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,b.loggedIn&&(zt(),e.tailscaleAuthUrl=null,e.tailscaleConnectSuccess=!0,e.tailscaleConnectMessage="Connected!",setTimeout(()=>{e.tailscaleConnectSuccess=!1,e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1},1500))}catch{}},3e3),Pi=setTimeout(()=>{zt(),e.tailscaleBusy&&(e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)},3e5)):f.alreadyLoggedIn?(zt(),e.tailscaleStatus=await e.client.request("tailscale.status"),e.remoteAccessQrDataUrl=null,e.publicChatQrDataUrl=null,e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1):(zt(),e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1)}catch(f){console.error("Tailscale enable failed:",f),zt(),e.tailscaleError=f.message||"Failed to enable Remote Access",e.tailscaleConnectProgress=0,e.tailscaleConnectMessage="",e.tailscaleBusy=!1}}},onTailscaleErrorDismiss:()=>{e.tailscaleError=null},onTailscaleServeEnable:async()=>{var f;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleServeEnableUrl=null;try{await e.client.request("tailscale.serve.enable"),await S()}catch(b){console.error("Tailscale serve enable failed:",b);const k=b;(f=k.payload)!=null&&f.enableUrl&&(e.tailscaleServeEnableUrl=k.payload.enableUrl),e.tailscaleError=k.message||"Failed to enable Remote Access"}finally{e.tailscaleBusy=!1}}},onTailscaleServeDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.serve.disable"),await S()}catch(f){console.error("Tailscale serve disable failed:",f)}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelEnable:async()=>{var f;if(!e.tailscaleBusy){e.tailscaleBusy=!0,e.tailscaleError=null,e.tailscaleFunnelEnableUrl=null;try{await e.client.request("tailscale.funnel.enable"),await S()}catch(b){console.error("Tailscale funnel enable failed:",b);const k=b;(f=k.payload)!=null&&f.enableUrl&&(e.tailscaleFunnelEnableUrl=k.payload.enableUrl),e.tailscaleError=k.message||"Failed to enable Funnel"}finally{e.tailscaleBusy=!1}}},onTailscaleFunnelDisable:async()=>{if(!e.tailscaleBusy){e.tailscaleBusy=!0;try{await e.client.request("tailscale.funnel.disable"),await S()}catch(f){console.error("Tailscale funnel disable failed:",f)}finally{e.tailscaleBusy=!1}}},onTailscaleDisableConfirmToggle:()=>{e.tailscaleDisableConfirm=!e.tailscaleDisableConfirm},wifiModalOpen:e.wifiModalOpen,onWifiModalToggle:()=>{e.wifiModalOpen=!e.wifiModalOpen,e.wifiModalOpen||(e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null)},wifiStatus:e.wifiStatus,wifiNetworks:e.wifiNetworks,wifiBusy:e.wifiBusy,wifiError:e.wifiError,wifiPassword:e.wifiPassword,wifiSelectedSsid:e.wifiSelectedSsid,onWifiScan:async()=>{var f;if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{const[b,k]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(e.wifiNetworks=b.networks,k.connected&&k.signal==null&&((f=b.networks)!=null&&f.length)){const A=b.networks.find(E=>E.active)||b.networks.find(E=>E.ssid===k.ssid);A&&(k.signal=A.signal)}e.wifiStatus=k}catch(b){console.error("WiFi scan failed:",b),e.wifiError=b.message||"Failed to scan networks"}finally{e.wifiBusy=!1}}},onWifiConnect:async()=>{var b;if(e.wifiBusy||!e.wifiSelectedSsid)return;const f=e.wifiSelectedSsid;e.wifiBusy=!0,e.wifiError=null;try{const k=await e.client.request("wifi.connect",{ssid:f,password:e.wifiPassword});e.wifiPassword="",e.wifiSelectedSsid=null,e.wifiNetworks=[],e.wifiStatus={available:!0,connected:k.connected,ssid:k.ssid,signal:null,ip:k.ip,savedSsid:k.ssid,autoconnect:!0},e.wifiBusy=!1;try{const[A,E]=await Promise.all([e.client.request("wifi.scan"),e.client.request("wifi.status")]);if(E.connected&&E.signal==null&&((b=A.networks)!=null&&b.length)){const M=A.networks.find(P=>P.active)||A.networks.find(P=>P.ssid===E.ssid);M&&(E.signal=M.signal)}e.wifiStatus=E}catch{}}catch(k){console.error("WiFi connect failed:",k),e.wifiError=k.message||"Failed to connect",e.wifiBusy=!1}},onWifiDisconnect:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.disconnect"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const f=await e.client.request("wifi.status");e.wifiStatus=f}catch(f){console.error("WiFi disconnect failed:",f),e.wifiError=f.message||"Failed to disconnect"}finally{e.wifiBusy=!1}}},onWifiForget:async()=>{if(!e.wifiBusy){e.wifiBusy=!0,e.wifiError=null;try{await e.client.request("wifi.forget"),e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="";const f=await e.client.request("wifi.status");e.wifiStatus=f}catch(f){console.error("WiFi forget failed:",f),e.wifiError=f.message||"Failed to forget network"}finally{e.wifiBusy=!1}}},onWifiDismiss:()=>{e.wifiNetworks=[],e.wifiSelectedSsid=null,e.wifiPassword="",e.wifiError=null},onWifiSelectSsid:f=>{e.wifiSelectedSsid=f,e.wifiPassword="",e.wifiError=null},onWifiPasswordChange:f=>{e.wifiPassword=f},networkPort:e.networkPort,networkHostname:e.networkHostname,networkPortInput:e.networkPortInput,networkHostnameInput:e.networkHostnameInput,networkModalOpen:e.networkModalOpen,networkBusy:e.networkBusy,networkError:e.networkError,networkSuccess:e.networkSuccess,onNetworkModalToggle:()=>{e.networkModalOpen=!e.networkModalOpen,e.networkModalOpen&&(e.networkPortInput=String(e.networkPort??""),e.networkHostnameInput=e.networkHostname,e.networkError=null,e.networkSuccess=null)},onNetworkPortChange:f=>{e.networkPortInput=f,e.networkError=null,e.networkSuccess=null},onNetworkHostnameChange:f=>{e.networkHostnameInput=f,e.networkError=null,e.networkSuccess=null},onNetworkSave:async()=>{if(e.networkBusy)return;e.networkBusy=!0,e.networkError=null,e.networkSuccess=null;const f=e.networkPortInput.trim(),b=Number.parseInt(f,10),k=e.networkHostnameInput.trim();if(!f||!Number.isFinite(b)||b<1024||b>65535){e.networkError="Port must be a number between 1024 and 65535",e.networkBusy=!1;return}const A=b!==e.networkPort,E=k!==e.networkHostname;if(!A&&!E){e.networkBusy=!1;return}try{E&&await e.client.request("network.setHostname",{hostname:k});const M={};A&&(M.gateway={port:b}),E&&(M.discovery={bonjourHostname:k});const P=await e.client.request("config.get");await e.client.request("config.patch",{raw:JSON.stringify(M),baseHash:P.hash,note:[A?`Port → ${b}`:null,E?`Hostname → ${k}`:null].filter(Boolean).join(", "),restartDelayMs:2e3}),e.networkSuccess="Saved — redirecting...";const R=window.location.protocol,F=E?`${k}.local`:window.location.hostname,H=A?b:e.networkPort,z=`${R}//${F}:${H}/setup`;setTimeout(()=>{window.location.href=z},1500)}catch(M){console.error("Network save failed:",M),e.networkError=M.message||"Failed to save network settings",e.networkBusy=!1}},wsProps:Mk(e)})}if(e.filesPage){const d=Lk(e);return ig({connected:e.connected,wsProps:Sn(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,currentDir:e.filesCurrentDir,message:e.filesMessage,uploadBusy:e.filesUploadBusy,reindexBusy:e.filesReindexBusy,memoryStatus:e.filesMemoryStatus,onRefresh:()=>{an(e,d),ls(e,d)},onReindex:()=>yf(e,d),onSelectFile:p=>{e.filesPendingDeletePath=null,cf(e,p,d)},onToggleSelectFile:p=>df(e,p,d),onToggleDir:p=>vf(e,p),onUpload:(p,g)=>hf(e,p,g,d),onNewFolder:(p,g)=>ff(e,p,g,d),onDownload:p=>Zc(e,p,d),onBulkDownload:()=>uf(e,d),onDelete:p=>{e.filesPendingDeletePath=null,gf(e,p,d)},pendingDeletePath:e.filesPendingDeletePath,onArmDelete:p=>{e.filesPendingDeletePath=p||null},onMoveToDir:(p,g)=>pf(e,p,g,d),searchQuery:e.filesSearchQuery,searchResults:e.filesSearchResults,searchLoading:e.filesSearchLoading,searchAgentId:e.filesSearchAgentId,agentIds:e.workspaceAgentIds??[],onSearch:p=>{const g=e.filesSearchAgentId??d;bf(e,p,g)},onSearchAgentChange:p=>{e.filesSearchAgentId=p},onSearchClear:()=>{wf(e)},onSearchQueryChange:p=>{e.filesSearchQuery=p}})}if(e.browserPage)return Yf({connected:e.connected,active:e.browserScreencastActive,loading:e.browserLoading,error:e.browserError,inputMode:e.browserInputMode,fullscreen:e.browserFullscreen,handoffPending:e.browserHandoffPending,handoffReason:e.browserHandoffReason,onStart:()=>Qw(e),onStop:()=>Jw(e),onToggleInput:()=>Xw(e),onToggleFullscreen:()=>Zw(e),onCompleteHandoff:()=>Yw(e),onCanvasMouseDown:d=>{const g=d.target.getBoundingClientRect(),S=Bn().translateCoordinates(d.clientX-g.left,d.clientY-g.top);co(e,"mousePressed",S.x,S.y,d.button===2?"right":d.button===1?"middle":"left")},onCanvasMouseUp:d=>{const g=d.target.getBoundingClientRect(),S=Bn().translateCoordinates(d.clientX-g.left,d.clientY-g.top);co(e,"mouseReleased",S.x,S.y)},onCanvasMouseMove:d=>{const p=Bn();if(p.shouldThrottleMouseMove())return;const $=d.target.getBoundingClientRect(),S=p.translateCoordinates(d.clientX-$.left,d.clientY-$.top);co(e,"mouseMoved",S.x,S.y)},onCanvasKeyDown:d=>{let p=0;d.altKey&&(p|=1),d.ctrlKey&&(p|=2),d.metaKey&&(p|=4),d.shiftKey&&(p|=8),uo(e,"keyDown",d.key,{code:d.code,modifiers:p||void 0}),d.key.length===1&&uo(e,"char",d.key,{text:d.key})},onCanvasKeyUp:d=>{uo(e,"keyUp",d.key,{code:d.code})}});if(e.adminsPage){const d=Pk(e),p=Ik(e);return qg({connected:e.connected,wsProps:Sn(e),loading:e.adminsLoading,saving:e.adminsSaving,phones:e.adminPhones,error:e.adminsError,newPhone:e.adminsNewPhone,onRefresh:()=>gs(e,d),onAdd:g=>{ku(e,g,d,p).then(()=>{e.adminsError||(e.adminsNewPhone="")})},onRemove:g=>xu(e,g,d,p),onNewPhoneChange:g=>e.handleAdminsNewPhoneChange(g)})}if(e.contactsPage){const d=Rk(e);return Jg({connected:e.connected,wsProps:Sn(e),loading:e.contactsLoading,saving:e.contactsSaving,records:e.contactsRecords,error:e.contactsError,searchQuery:e.contactsSearchQuery,editingId:e.contactsEditingId,showAddForm:e.contactsShowAddForm,newRecordPhone:e.contactsNewPhone,newRecordName:e.contactsNewName,deleteConfirmId:e.contactsDeleteConfirmId,addFieldForId:e.contactsAddFieldForId,addFieldKey:e.contactsAddFieldKey,addFieldValue:e.contactsAddFieldValue,onSearch:p=>e.contactsSearchQuery=p,onSearchSubmit:()=>Lt(e,d),onAdd:(p,g)=>$u(e,p,g,d),onDelete:p=>Su(e,p,d),onSetField:(p,g,$)=>qo(e,p,g,$,d),onDeleteField:(p,g)=>Au(e,p,g,d),onToggleExpand:p=>{e.contactsEditingId=e.contactsEditingId===p?null:p},onShowAddForm:()=>e.contactsShowAddForm=!0,onCancelAddForm:()=>{e.contactsShowAddForm=!1,e.contactsNewPhone="",e.contactsNewName=""},onNewRecordPhoneChange:p=>e.handleContactsNewPhoneChange(p),onNewRecordNameChange:p=>e.handleContactsNewNameChange(p),onRefresh:()=>Lt(e,d),onDeleteConfirmOpen:p=>e.contactsDeleteConfirmId=p,onDeleteConfirmClose:()=>e.contactsDeleteConfirmId=null,onAddFieldOpen:p=>{e.contactsAddFieldForId=p,e.contactsAddFieldKey="",e.contactsAddFieldValue=""},onAddFieldClose:()=>{e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue=""},onAddFieldKeyChange:p=>e.contactsAddFieldKey=p,onAddFieldValueChange:p=>e.contactsAddFieldValue=p,onAddFieldSubmit:()=>{const p=e.contactsAddFieldForId,g=e.contactsAddFieldKey.trim();!p||!g||(qo(e,p,g,e.contactsAddFieldValue,d),e.contactsAddFieldForId=null,e.contactsAddFieldKey="",e.contactsAddFieldValue="")}})}if(e.chatPage){const d=e.connected?null:"Disconnected from gateway.",p=Pl(e),g=e.chatAvatarUrl??p??null,$=(()=>{var f;const S=(f=e.configSnapshot)==null?void 0:f.config,T=S==null?void 0:S.publicChat;return(T==null?void 0:T.enabled)===!0})();return Qb({connected:e.connected,wsProps:Sn(e),publicChatEnabled:$,publicChatAccountId:e.selectedWorkspace??void 0,sessionKey:e.sessionKey,onSessionKeyChange:S=>{const T=e.selectedWorkspace??"";vo(),Wn(T,e.sessionKey,e.chatMessage),e.sessionKey=S,e.chatMessage=Kn(T,S),e.chatAttachments=[],e.chatStream=null,e.chatInterimText=null,e.chatSuggestions=[],e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:S,lastActiveSessionKey:S}),e.loadAssistantIdentity(),Oe(e),Ao(e)},thinkingLevel:e.chatThinkingLevel,showThinking:e.settings.chatShowThinking??!1,modelProvider:e.chatModelProvider,model:e.chatModel,modelCatalog:e.chatModelCatalog,onModelChange:S=>{const T=Math.max(e.chatMessages.length+10,Fe);ci(e,e.sessionKey,{model:S}).then(()=>{Oe(e,{limit:T})})},onThinkingLevelChange:S=>{const T=Math.max(e.chatMessages.length+10,Fe);ci(e,e.sessionKey,{thinkingLevel:S==="off"?null:S}).then(()=>{Oe(e,{limit:T})})},verboseLevel:e.chatVerboseLevel,fillerEnabled:e.chatFillerEnabled,suggestions:e.chatSuggestions,onSuggestionClick:S=>{e.chatMessage=S,e.chatSuggestions=[],e.handleSendChat()},onVerboseChange:S=>{const T=Math.max(e.chatMessages.length+10,Fe);ci(e,e.sessionKey,{verboseLevel:S==="off"?null:S}).then(()=>{Oe(e,{limit:T})})},onFillerChange:S=>{const T=Math.max(e.chatMessages.length+10,Fe);ci(e,e.sessionKey,{fillerEnabled:S}).then(()=>{Oe(e,{limit:T})})},loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:g,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,interimText:e.chatInterimText,draft:e.chatMessage,queue:e.chatQueue,canSend:e.connected,disabledReason:d,error:e.lastError,sessions:e.sessionsResult,focusMode:!1,onRefresh:()=>{e.resetToolStream();const S=Math.max(e.chatMessages.length+10,Fe);return Promise.all([Oe(e,{limit:S}),Ao(e)])},onToggleFocusMode:()=>{},onChatScroll:S=>e.handleChatScroll(S),nearBottom:e.chatUserNearBottom,hasMore:e.chatHistoryHasMore,loadingOlder:e.chatLoadingOlder,onLoadOlder:()=>{e.handleLoadOlderChat()},onDraftChange:S=>{e.chatMessage=S,yr(e.selectedWorkspace??"",e.sessionKey,S)},requestUpdate:()=>e.requestUpdate(),attachments:e.chatAttachments,onAttachmentsChange:S=>e.chatAttachments=S,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:S=>e.removeQueuedMessage(S),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:S=>e.handleOpenSidebar(S),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:S=>e.handleSplitRatioChange(S),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar})}return e.advancedPage?Bw({connected:e.connected,wsProps:Sn(e),activeTab:e.advancedTab,onTabChange:d=>{e.advancedTab=d,d==="cron"&&e.loadCron(),d==="skills"&&Xe(e,{clearMessages:!0}),d==="logs"&&(e.logsSubTab==="session"?Pn(e,{reset:!0}):Vt(e,{reset:!0}))},cronProps:{loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:(r=(a=e.channelsSnapshot)==null?void 0:a.channelMeta)!=null&&r.length?e.channelsSnapshot.channelMeta.map(d=>d.id):((l=e.channelsSnapshot)==null?void 0:l.channelOrder)??[],channelLabels:((c=e.channelsSnapshot)==null?void 0:c.channelLabels)??{},channelMeta:((h=e.channelsSnapshot)==null?void 0:h.channelMeta)??[],agentIds:(()=>{var p;const d=ue(e);return((p=d==null?void 0:d.agents)==null?void 0:p.map(g=>g.id))??[]})(),runsJobId:e.cronRunsJobId,runs:e.cronRuns,newEventModalOpen:e.cronNewEventModal,onNewEventModalOpen:()=>{e.cronNewEventModal=!0},onNewEventModalClose:()=>{e.cronNewEventModal=!1,e.cronEditJobId=null},detailJobId:e.cronDetailJobId,editJobId:e.cronEditJobId,onDetailOpen:d=>{e.cronDetailJobId=d.id,wo(e,d.id)},onDetailClose:()=>{e.cronDetailJobId=null},onEdit:d=>{e.cronForm=hh(d),e.cronEditJobId=d.id,e.cronDetailJobId=null},onEditSave:()=>{const d=e.cronEditJobId;d&&fh(e,d).then(()=>{e.cronEditJobId=null})},onFormChange:d=>e.cronForm={...e.cronForm,...d},onRefresh:()=>e.loadCron(),onAdd:()=>{lh(e).then(()=>{e.cronNewEventModal=!1})},onToggle:(d,p)=>ch(e,d,p),onRun:d=>dh(e,d),onRemove:d=>{e.cronPendingDeleteId=null,ph(e,d)},pendingDeleteId:e.cronPendingDeleteId,onArmDelete:d=>{e.cronPendingDeleteId=d||null},onLoadRuns:d=>wo(e,d),runModalJobId:e.cronRunModalJobId,runModalJobName:e.cronRunModalJobName,runResult:e.cronRunResult,onRunModalClose:()=>{e.cronRunModalJobId=null,e.cronRunModalJobName="",e.cronRunResult=null}},skillsProps:{loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,typeFilter:e.skillsTypeFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,detail:e.skillDetail,detailTab:e.skillDetailTab,addModal:e.skillAddModal,addForm:e.skillAddForm,formSource:e.skillAddFormSource,editTab:e.skillEditTab,drafts:e.skillDrafts,onFilterChange:d=>e.skillsFilter=d,onTypeFilterChange:d=>e.skillsTypeFilter=d,onRefresh:()=>Xe(e,{clearMessages:!0}),onToggle:(d,p)=>Pc(e,d,p),onEdit:(d,p)=>Mc(e,d,p),onSaveKey:d=>Ic(e,d),onInstall:(d,p,g)=>Lc(e,d,p,g),onViewDetail:d=>Rc(e,d),onDetailClose:()=>Dc(e),onDetailTab:d=>Bc(e,d),onAddOpen:()=>Nc(e),onAddClose:()=>Oc(e),onImportDraft:d=>Fc(e,d),onInstallDraft:d=>Uc(e,d),onDeleteDraft:d=>Wc(e,d),onAddSave:()=>la(e),onAddFormUpdate:(d,p)=>{e.skillAddForm={...e.skillAddForm,[d]:p}},onDelete:d=>jc(e,d),onEditSkill:d=>Kc(e,d),onEditDetail:d=>zc(e,d),onRefUpdate:(d,p)=>qc(e,d,p),onEditTab:d=>Hc(e,d)},logsProps:{logsSubTab:e.logsSubTab,onSubTabChange:d=>{e.logsSubTab=d,d==="session"?Pn(e,{reset:!0}):Vt(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,chipsExpanded:e.sessionLogsChipsExpanded,expandedIds:e.sessionLogsExpandedIds,onFilterTextChange:d=>e.sessionLogsFilterText=d,onTypeToggle:(d,p)=>{const g=e;g.sessionLogsTypeFilters={...g.sessionLogsTypeFilters,[d]:p}},onAgentToggle:(d,p)=>{const g=e;g.sessionLogsAgentFilters={...g.sessionLogsAgentFilters,[d]:p}},onToggleAutoFollow:d=>e.sessionLogsAutoFollow=d,onToggleChips:()=>{const d=e;d.sessionLogsChipsExpanded=!d.sessionLogsChipsExpanded},onToggleExpand:d=>{const p=e,g=new Set(p.sessionLogsExpandedIds);g.has(d)?g.delete(d):g.add(d),p.sessionLogsExpandedIds=g,p.requestUpdate()},onRefresh:()=>{Pn(e,{reset:!0})},onExport:(d,p)=>e.exportSessionLogs(d,p),onScroll:d=>e.handleSessionLogsScroll(d)},loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,chipsExpanded:e.logsChipsExpanded,truncated:e.logsTruncated,onFilterTextChange:d=>e.logsFilterText=d,onLevelToggle:(d,p)=>{e.logsLevelFilters={...e.logsLevelFilters,[d]:p}},onToggleAutoFollow:d=>e.logsAutoFollow=d,onToggleChips:()=>{const d=e;d.logsChipsExpanded=!d.logsChipsExpanded},onRefresh:()=>Vt(e,{reset:!0}),onExport:(d,p)=>e.exportSessionLogs(d,p),onScroll:d=>e.handleLogsScroll(d)}}):(window.location.replace("/chat"),u``)}function Wk(e){const t=new Date(e),n=t.toLocaleDateString("en-GB",{day:"2-digit",month:"short"}),i=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return`${n} ${i}`}function Il(e){return e.startsWith("memory/public/")?"public":e.startsWith("memory/shared/")?"shared":"other"}function Kk(e,t,n){return u`
|
|
4518
4531
|
<div class="audit-modal-overlay" @click=${s=>{s.target.classList.contains("audit-modal-overlay")&&n()}}>
|
|
4519
4532
|
<div class="audit-modal-card">
|
|
4520
4533
|
<div class="audit-modal-header">
|
|
@@ -4546,7 +4559,7 @@ ${a.text}`:r.join(", "):a.text;t.push({kind:"message",key:`queue:${a.id}`,messag
|
|
|
4546
4559
|
`}
|
|
4547
4560
|
</div>
|
|
4548
4561
|
</div>
|
|
4549
|
-
`}const zk={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},qk={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",recipients:[],toAdmins:!1,timeoutSeconds:"",postToMainPrefix:""};function Hk(e){e.basePath=Mf();const t=Ye();if(zl(t.accentColor),ql(t.backgroundColor),window.scrollTo(0,0),xf(e),e.publicChat){const n=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__,i=(n==null?void 0:n.accountId)??"",s=i?i.charAt(0).toUpperCase()+i.slice(1):"Assistant";document.title=`Chat with ${s}`,De(e);return}if(e.setup){document.title=`${t.name} Setup`,De(e);return}if(e.filesPage){document.title=`${t.name} Files`,Af(e),De(e);return}if(e.browserPage){document.title=`${t.name} Browser`,De(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,De(e);return}if(e.contactsPage){document.title=`${t.name} Contacts`,De(e);return}if(e.chatPage){document.title=`${t.name} Chat`,De(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,De(e);return}Rf(e,!0),Pf(e),If(e),window.addEventListener("popstate",e.popStateHandler),Ef(e),De(e),kf(e),e.tab==="logs"&&(e.logsSubTab==="session"?pa(e):da(e)),e.tab==="debug"&&fa(e)}function jk(e){sh(e)}function Gk(e){var t;window.removeEventListener("popstate",e.popStateHandler),$f(e),ua(e),ha(e),ga(e),Sf(e),Cf(e),Lf(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function Vk(e,t){if(!e.publicChat){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.contactsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleContactsLoad&&e.handleContactsLoad(),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 i=t.has("setupStep")&&e.setupStep==="auth";(n||i)&&e.setupStep==="auth"&&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(s=>{e.channelsSnapshot=s,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"),i=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;nn(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&ic(e,t.has("tab")||t.has("logsAutoFollow"))}}function Qk(e){const t={name:(e==null?void 0:e.name)??"",displayName:(e==null?void 0:e.displayName)??"",about:(e==null?void 0:e.about)??"",picture:(e==null?void 0:e.picture)??"",banner:(e==null?void 0:e.banner)??"",website:(e==null?void 0:e.website)??"",nip05:(e==null?void 0:e.nip05)??"",lud16:(e==null?void 0:e.lud16)??""};return{values:t,original:{...t},saving:!1,importing:!1,error:null,success:null,fieldErrors:{},showAdvanced:!!(e!=null&&e.banner||e!=null&&e.website||e!=null&&e.nip05||e!=null&&e.lud16)}}async function Jk(e,t,n){await Zo(e,t,n),await ee(e,!0)}async function Yk(e,t){await lc(e,t),await ee(e,!0)}async function Xk(e,t){await cc(e,t),await ee(e,!0)}async function Zk(e,t){await dc(e,t)}async function e0(e,t){await uc(e,t)}async function t0(e){await rh(e),await Ue(e),await ee(e,!0)}async function n0(e){await Ue(e),await ee(e,!0)}function i0(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[i,...s]=n.split(":");if(!i||s.length===0)continue;const o=i.trim(),a=s.join(":").trim();o&&a&&(t[o]=a)}return t}function Cu(e){var n,i,s;return((s=(((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.nostr)??[])[0])==null?void 0:s.accountId)??e.nostrProfileAccountId??"default"}function Eu(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function s0(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=Qk(n??void 0)}function o0(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function a0(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function r0(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function l0(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Cu(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(Eu(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const o=(s==null?void 0:s.error)??`Profile update failed (${i.status})`;e.nostrProfileFormState={...t,saving:!1,error:o,success:null,fieldErrors:i0(s==null?void 0:s.details)};return}if(!s.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 ee(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function c0(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Cu(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(Eu(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const l=(s==null?void 0:s.error)??`Profile import failed (${i.status})`;e.nostrProfileFormState={...t,importing:!1,error:l,success:null};return}const o=s.merged??s.imported??null,a=o?{...t.values,...o}:t.values,r=!!(a.banner||a.website||a.nip05||a.lud16);e.nostrProfileFormState={...t,importing:!1,values:a,error:null,success:s.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:r},s.saved&&await ee(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function d0(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 u0(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 p0(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=""):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 h0(e,t){e.authCodeInput=t}function f0(e){e.setupStep="whatsapp"}async function g0(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 m0(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 y0(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 v0(e,t){e.licenseKey=t}async function b0(e){var t,n;if(!(!e.client||!e.connected)&&!e.gatewayHealthLoading){e.gatewayHealthLoading=!0,(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("health",{probe:!0});e.gatewayHealthy=i.ok===!0,e.gatewayHealthMessage=i.ok?`Healthy${i.durationMs?` (${i.durationMs}ms)`:""}`:"Unhealthy"}catch(i){e.gatewayHealthy=!1,e.gatewayHealthMessage=`Error: ${String(i)}`}finally{e.gatewayHealthLoading=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function w0(e){var t,n,i;if(!(!e.client||e.gatewayRestartBusy)){e.gatewayRestartBusy=!0,e.gatewayHealthMessage="Restarting...",(t=e.requestUpdate)==null||t.call(e);try{const s=await e.client.request("gateway.restart",{reason:"Manual restart from setup page",delayMs:1e3});if(s.ok&&((n=s.restart)!=null&&n.ok))e.gatewayHealthMessage="Restarting...",setTimeout(()=>{window.location.reload()},3e3);else throw new Error("Restart not scheduled")}catch(s){e.gatewayHealthMessage=`Restart failed: ${String(s)}`,e.gatewayRestartBusy=!1,(i=e.requestUpdate)==null||i.call(e)}}}var k0=Object.defineProperty,$0=Object.getOwnPropertyDescriptor,m=(e,t,n,i)=>{for(var s=i>1?void 0:i?$0(t,n):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(s=(i?a(t,n,s):a(s))||s);return i&&s&&k0(t,n,s),s};const go=pp();function x0(){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 S0(){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 i=n.trim().toLowerCase();return i==="1"||i==="true"||i==="yes"||i==="on"}function A0(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function C0(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function E0(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function T0(){const e=window.location.pathname;return e==="/contacts"||e.endsWith("/contacts")}function _0(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function M0(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let g=class extends Gt{constructor(){super(...arguments),this.settings=Is(),this.password="",this.tab="chat",this.onboarding=x0(),this.setup=S0(),this.filesPage=A0(),this.browserPage=C0(),this.adminsPage=E0(),this.contactsPage=T0(),this.chatPage=_0(),this.advancedPage=M0(),this.advancedTab="cron",this.publicChat=!!window.__TASKMASTER_PUBLIC_CHAT__,this.publicChatConfig=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__??{},this.publicChatSessionKey=null,this.publicChatAuthenticated=!1,this.publicChatAuthStep="idle",this.connected=!1,this.accessState=yu,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=go.name,this.assistantAvatar=go.avatar,this.assistantAgentId=go.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatHistoryTotal=0,this.chatHistoryHasMore=!1,this.chatLoadingOlder=!1,this.chatToolMessages=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestions=[],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=`{
|
|
4562
|
+
`}const zk={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},qk={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",recipients:[],toAdmins:!1,timeoutSeconds:"",postToMainPrefix:""};function Hk(e){e.basePath=Mf();const t=Ye();zl(t.accentColor),ql(t.backgroundColor);const n=document.querySelector('link[rel="icon"]');if(n&&(n.href=t.iconUrl),window.scrollTo(0,0),$f(e),e.publicChat){const i=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__,s=(i==null?void 0:i.accountId)??"",o=s?s.charAt(0).toUpperCase()+s.slice(1):"Assistant";document.title=`Chat with ${o}`,De(e);return}if(e.setup){document.title=`${t.name} Setup`,De(e);return}if(e.filesPage){document.title=`${t.name} Files`,Af(e),De(e);return}if(e.browserPage){document.title=`${t.name} Browser`,De(e);return}if(e.adminsPage){document.title=`${t.name} Admins`,De(e);return}if(e.contactsPage){document.title=`${t.name} Contacts`,De(e);return}if(e.chatPage){document.title=`${t.name} Chat`,De(e);return}if(e.advancedPage){document.title=`${t.name} Advanced`,De(e);return}Rf(e,!0),Pf(e),If(e),window.addEventListener("popstate",e.popStateHandler),Ef(e),De(e),kf(e),e.tab==="logs"&&(e.logsSubTab==="session"?pa(e):da(e)),e.tab==="debug"&&fa(e)}function jk(e){sh(e)}function Gk(e){var t;window.removeEventListener("popstate",e.popStateHandler),xf(e),ua(e),ha(e),ga(e),Sf(e),Cf(e),Lf(e),(t=e.topbarObserver)==null||t.disconnect(),e.topbarObserver=null}function Vk(e,t){if(!e.publicChat){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.contactsPage&&e.connected&&t.has("connected")&&t.get("connected")===!1&&e.handleContactsLoad&&e.handleContactsLoad(),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 i=t.has("setupStep")&&e.setupStep==="auth";(n||i)&&e.setupStep==="auth"&&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(s=>{e.channelsSnapshot=s,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"),i=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;nn(e,n||i||!e.chatHasAutoScrolled)}e.tab==="logs"&&!e.advancedPage&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&ic(e,t.has("tab")||t.has("logsAutoFollow"))}}function Qk(e){const t={name:(e==null?void 0:e.name)??"",displayName:(e==null?void 0:e.displayName)??"",about:(e==null?void 0:e.about)??"",picture:(e==null?void 0:e.picture)??"",banner:(e==null?void 0:e.banner)??"",website:(e==null?void 0:e.website)??"",nip05:(e==null?void 0:e.nip05)??"",lud16:(e==null?void 0:e.lud16)??""};return{values:t,original:{...t},saving:!1,importing:!1,error:null,success:null,fieldErrors:{},showAdvanced:!!(e!=null&&e.banner||e!=null&&e.website||e!=null&&e.nip05||e!=null&&e.lud16)}}async function Jk(e,t,n){await Zo(e,t,n),await ee(e,!0)}async function Yk(e,t){await lc(e,t),await ee(e,!0)}async function Xk(e,t){await cc(e,t),await ee(e,!0)}async function Zk(e,t){await dc(e,t)}async function e0(e,t){await uc(e,t)}async function t0(e){await rh(e),await Ue(e),await ee(e,!0)}async function n0(e){await Ue(e),await ee(e,!0)}function i0(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[i,...s]=n.split(":");if(!i||s.length===0)continue;const o=i.trim(),a=s.join(":").trim();o&&a&&(t[o]=a)}return t}function Cu(e){var n,i,s;return((s=(((i=(n=e.channelsSnapshot)==null?void 0:n.channelAccounts)==null?void 0:i.nostr)??[])[0])==null?void 0:s.accountId)??e.nostrProfileAccountId??"default"}function Eu(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function s0(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=Qk(n??void 0)}function o0(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function a0(e,t,n){const i=e.nostrProfileFormState;i&&(e.nostrProfileFormState={...i,values:{...i.values,[t]:n},fieldErrors:{...i.fieldErrors,[t]:""}})}function r0(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function l0(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Cu(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const i=await fetch(Eu(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const o=(s==null?void 0:s.error)??`Profile update failed (${i.status})`;e.nostrProfileFormState={...t,saving:!1,error:o,success:null,fieldErrors:i0(s==null?void 0:s.details)};return}if(!s.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 ee(e,!0)}catch(i){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(i)}`,success:null}}}async function c0(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Cu(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const i=await fetch(Eu(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),s=await i.json().catch(()=>null);if(!i.ok||(s==null?void 0:s.ok)===!1||!s){const l=(s==null?void 0:s.error)??`Profile import failed (${i.status})`;e.nostrProfileFormState={...t,importing:!1,error:l,success:null};return}const o=s.merged??s.imported??null,a=o?{...t.values,...o}:t.values,r=!!(a.banner||a.website||a.nip05||a.lud16);e.nostrProfileFormState={...t,importing:!1,values:a,error:null,success:s.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:r},s.saved&&await ee(e,!0)}catch(i){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(i)}`,success:null}}}async function d0(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 u0(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 p0(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=""):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 h0(e,t){e.authCodeInput=t}function f0(e){e.setupStep="whatsapp"}async function g0(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 m0(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 y0(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 v0(e,t){e.licenseKey=t}async function b0(e){var t,n;if(!(!e.client||!e.connected)&&!e.gatewayHealthLoading){e.gatewayHealthLoading=!0,(t=e.requestUpdate)==null||t.call(e);try{const i=await e.client.request("health",{probe:!0});e.gatewayHealthy=i.ok===!0,e.gatewayHealthMessage=i.ok?`Healthy${i.durationMs?` (${i.durationMs}ms)`:""}`:"Unhealthy"}catch(i){e.gatewayHealthy=!1,e.gatewayHealthMessage=`Error: ${String(i)}`}finally{e.gatewayHealthLoading=!1,(n=e.requestUpdate)==null||n.call(e)}}}async function w0(e){var t,n,i;if(!(!e.client||e.gatewayRestartBusy)){e.gatewayRestartBusy=!0,e.gatewayHealthMessage="Restarting...",(t=e.requestUpdate)==null||t.call(e);try{const s=await e.client.request("gateway.restart",{reason:"Manual restart from setup page",delayMs:1e3});if(s.ok&&((n=s.restart)!=null&&n.ok))e.gatewayHealthMessage="Restarting...",setTimeout(()=>{window.location.reload()},3e3);else throw new Error("Restart not scheduled")}catch(s){e.gatewayHealthMessage=`Restart failed: ${String(s)}`,e.gatewayRestartBusy=!1,(i=e.requestUpdate)==null||i.call(e)}}}var k0=Object.defineProperty,x0=Object.getOwnPropertyDescriptor,y=(e,t,n,i)=>{for(var s=i>1?void 0:i?x0(t,n):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(s=(i?a(t,n,s):a(s))||s);return i&&s&&k0(t,n,s),s};const go=pp();function $0(){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 S0(){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 i=n.trim().toLowerCase();return i==="1"||i==="true"||i==="yes"||i==="on"}function A0(){const e=window.location.pathname;return e==="/files"||e.endsWith("/files")}function C0(){const e=window.location.pathname;return e==="/browser"||e.endsWith("/browser")}function E0(){const e=window.location.pathname;return e==="/admins"||e.endsWith("/admins")}function T0(){const e=window.location.pathname;return e==="/contacts"||e.endsWith("/contacts")}function _0(){const e=window.location.pathname;return e==="/chat"||e.endsWith("/chat")}function M0(){const e=window.location.pathname;return e==="/advanced"||e.endsWith("/advanced")}let m=class extends Gt{constructor(){super(...arguments),this.settings=Is(),this.password="",this.tab="chat",this.onboarding=$0(),this.setup=S0(),this.filesPage=A0(),this.browserPage=C0(),this.adminsPage=E0(),this.contactsPage=T0(),this.chatPage=_0(),this.advancedPage=M0(),this.advancedTab="cron",this.publicChat=!!window.__TASKMASTER_PUBLIC_CHAT__,this.publicChatConfig=window.__TASKMASTER_PUBLIC_CHAT_CONFIG__??{},this.publicChatSessionKey=null,this.publicChatAuthenticated=!1,this.publicChatAuthStep="idle",this.connected=!1,this.accessState=yu,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=go.name,this.assistantAvatar=go.avatar,this.assistantAgentId=go.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatHistoryTotal=0,this.chatHistoryHasMore=!1,this.chatLoadingOlder=!1,this.chatToolMessages=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestions=[],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=`{
|
|
4550
4563
|
}
|
|
4551
|
-
`,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.publicChatToggleBusy=!1,this.publicChatGreetingBusy=!1,this.publicChatEmailBusy=!1,this.publicChatSettingsOpen=!1,this.publicChatWidgetModalOpen=!1,this.brandingBusy=!1,this.brandingExpanded=!1,this.tailscaleStatus=null,this.tailscaleBusy=!1,this.tailscaleAuthUrl=null,this.tailscaleError=null,this.tailscaleFunnelEnableUrl=null,this.tailscaleDisableConfirm=!1,this.tailscaleConnectProgress=0,this.tailscaleConnectMessage="",this.tailscaleConnectSuccess=!1,this.wifiStatus=null,this.wifiNetworks=[],this.wifiBusy=!1,this.wifiError=null,this.wifiPassword="",this.wifiSelectedSsid=null,this.networkPort=null,this.networkHostname="",this.networkPortInput="",this.networkHostnameInput="",this.networkModalOpen=!1,this.networkBusy=!1,this.networkError=null,this.networkSuccess=null,this.wifiModalOpen=!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.uninstallConfirm=!1,this.uninstallBusy=!1,this.uninstallDone=!1,this.uninstallError=null,this.uninstallConfirmText="",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={...qk},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=null,this.cronEditJobId=null,this.cronPendingDeleteId=null,this.cronRunModalJobId=null,this.cronRunModalJobName="",this.cronRunResult=null,this.browserScreencastActive=!1,this.browserScreencastFrame=null,this.browserScreencastMetadata=null,this.browserHandoffPending=!1,this.browserHandoffReason=null,this.browserHandoffId=null,this.browserInputMode=!1,this.browserFullscreen=!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.filesCurrentDir=".",this.filesPendingDeletePath=null,this.filesMessage=null,this.filesUploadBusy=!1,this.filesReindexBusy=!1,this.filesMemoryStatus=null,this.embeddingDownloading=!1,this.embeddingPollTimer=null,this.filesSearchQuery="",this.filesSearchResults=null,this.filesSearchLoading=!1,this.filesSearchAgentId=null,this.filesResolvedAgentId=void 0,this.auditEntries=[],this.auditLoading=!1,this.auditModalOpen=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillsTypeFilter="all",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.skillDetail=null,this.skillDetailTab="",this.skillAddModal=!1,this.skillAddForm={name:"",skillContent:"",references:[]},this.skillAddFormSource="draft",this.skillEditTab="SKILL.md",this.skillDrafts=[],this.adminsLoading=!1,this.adminPhones=[],this.adminsError=null,this.adminsSaving=!1,this.adminsNewPhone="",this.contactsLoading=!1,this.contactsSaving=!1,this.contactsRecords=[],this.contactsError=null,this.contactsSearchQuery="",this.contactsEditingId=null,this.contactsShowAddForm=!1,this.contactsNewPhone="",this.contactsNewName="",this.contactsDeleteConfirmId=null,this.contactsAddFieldForId=null,this.contactsAddFieldKey="",this.contactsAddFieldValue="",this.imessageEnableConfirm=!1,this.imessageEnabling=!1,this.infoModalOpen=null,this.remoteAccessQrDataUrl=null,this.publicChatQrDataUrl=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.apiKeySavingProvider=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={...zk},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.logsChipsExpanded=!1,this.sessionLogsLoading=!1,this.sessionLogsError=null,this.sessionLogsEntries=[],this.sessionLogsFilterText="",this.sessionLogsTypeFilters={user:!0,assistant:!0,tool:!0,tool_call:!0,tool_result:!0,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.sessionLogsChipsExpanded=!1,this.sessionLogsExpandedIds=new Set,this.sessionLogsCursors={},this.sessionLogsLastFetchAt=null,this.sessionLogsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.onLoadOlder=()=>this.handleLoadOlderChat(),this.nodesPollInterval=null,this.logsPollInterval=null,this.sessionLogsPollInterval=null,this.debugPollInterval=null,this.auditPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>Df(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null,this._beforeUnloadHandler=()=>{var t;vo();const e=this.selectedWorkspace??((t=this.publicChatConfig)==null?void 0:t.accountId)??"";e&&Wn(e,this.sessionKey,this.chatMessage)}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),Hk(this),window.addEventListener("beforeunload",this._beforeUnloadHandler)}firstUpdated(){jk(this)}disconnectedCallback(){window.removeEventListener("beforeunload",this._beforeUnloadHandler),this.stopEmbeddingPoll(),Gk(this),super.disconnectedCallback()}startEmbeddingPoll(){if(this.embeddingPollTimer!=null)return;const e=async()=>{if(!(!this.client||!this.connected)){try{const t=await this.client.request("memory.status",{});if((t==null?void 0:t.embeddingState)==="downloading")this.embeddingDownloading=!0;else{this.embeddingDownloading&&(this.embeddingDownloading=!1),this.stopEmbeddingPoll();return}}catch{this.embeddingDownloading=!1,this.stopEmbeddingPoll();return}this.embeddingPollTimer=window.setTimeout(e,3e3)}};e()}stopEmbeddingPoll(){this.embeddingPollTimer!=null&&(window.clearTimeout(this.embeddingPollTimer),this.embeddingPollTimer=null)}updated(e){Vk(this,e)}connect(){De(this)}handleChatScroll(e){Yp(this,e)}handleLogsScroll(e){Zp(this,e)}handleSessionLogsScroll(e){eh(this,e)}exportLogs(e,t){nh(e,t)}exportSessionLogs(e,t){ih(e,t)}resetToolStream(){Xo(this)}resetChatScroll(){th(this)}async loadAssistantIdentity(){await zo(this)}applySettings(e){rt(this,e)}setTab(e){Tf(this,e)}setTheme(e,t){_f(this,e,t)}async loadOverview(){await id(this)}async loadCron(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.cronForm={...this.cronForm,accountId:(e==null?void 0:e.whatsappAccountId)??void 0},await ma(this)}async handleAbortChat(){await od(this)}removeQueuedMessage(e){Ff(this,e)}async handleSendChat(e,t){await Uf(this,e,t)}async handleWhatsAppStart(e,t){await Jk(this,e,t)}async handleWhatsAppWait(e){await Yk(this,e)}async handleWhatsAppLogout(e){await Xk(this,e)}async handleAddWhatsAppAccount(e){await Zk(this,e)}async handleRemoveWhatsAppAccount(e){await e0(this,e)}async handleAccessCheck(){await Ml(this)}async handlePinSubmit(e,t){await xk(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await Sk(this,e)}async handleLogout(){await Ck(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 i=await this.client.request("access.verify",{account:e,pin:t});if(!i.ok){this.changePinError=i.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 i=await this.client.request("access.verify",{account:e,pin:t});if(!i.ok){this.accountPinError=i.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 Ml(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 g0(this)}async handleLicenseActivate(){await m0(this)}async handleLicenseRemove(){await y0(this)}handleLicenseKeyChange(e){v0(this,e)}async handleAuthStatusCheck(){await d0(this)}async handleAuthStart(){await u0(this)}async handleAuthSubmitCode(e){await p0(this,e)}handleAuthCodeChange(e){h0(this,e)}handleSkipToWhatsApp(){f0(this)}async handleGatewayHealthCheck(){await b0(this)}async handleGatewayRestart(){await w0(this)}async handleUpdateCheck(){await fu(this)}async handleUpdateRun(){await ok(this)}handleUpdateDismissResult(){lk(this)}handleUninstallConfirm(){this.uninstallConfirm=!0,this.uninstallConfirmText=""}handleUninstallCancel(){this.uninstallConfirm=!1,this.uninstallConfirmText="",this.uninstallError=null}handleUninstallConfirmTextChange(e){this.uninstallConfirmText=e}async handleUninstallRun(){const{runUninstall:e}=await le(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Mr);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){le(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Mr);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await Yc(this)}async clearAudit(){await lf(this),this.auditModalOpen=!1}handleFilesLoad(){var n;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((n=e==null?void 0:e.agents)==null?void 0:n.map(i=>i.id))??void 0;const t=this.resolveFilesAgentId();this.filesResolvedAgentId=t,an(this,t),ls(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();le(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>Tk);return{loadAdmins:t}},void 0,import.meta.url).then(({loadAdmins:t})=>{t(this,e)})}resolveAdminAgentId(){const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(n=>n.id.endsWith("-admin")||n.id==="admin");return t==null?void 0:t.id}resolveFilesAgentId(){var n;const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(i=>i.id.endsWith("-admin")||i.id==="admin");return(t==null?void 0:t.id)??((n=e.agents[0])==null?void 0:n.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.chatInterimText=null,this.chatRunId=null,this.chatSuggestions=[],this.resetChatScroll(),this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}le(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>Ni);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this).then(()=>{nn(this,!0)})})}async handleLoadOlderChat(){if(this.chatLoadingOlder||!this.chatHistoryHasMore)return;const e=Xp(this),{loadOlderChatHistory:t}=await le(async()=>{const{loadOlderChatHistory:i}=await Promise.resolve().then(()=>Ni);return{loadOlderChatHistory:i}},void 0,import.meta.url);await t(this)&&e&&(await this.updateComplete,e())}handleAdvancedLoad(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.sessionLogsEntries=[],this.sessionLogsCursors={},this.sessionLogsAgents=[],this.advancedTab==="cron"&&this.loadCron(),this.advancedTab==="logs"&&(this.logsSubTab==="session"?le(async()=>{const{loadSessionLogs:n}=await Promise.resolve().then(()=>Jc);return{loadSessionLogs:n}},void 0,import.meta.url).then(({loadSessionLogs:n})=>{n(this,{reset:!0})}):le(async()=>{const{loadLogs:n}=await Promise.resolve().then(()=>wh);return{loadLogs:n}},void 0,import.meta.url).then(({loadLogs:n})=>{n(this,{reset:!0})})),this.advancedTab==="skills"&&le(async()=>{const{loadSkills:n}=await Promise.resolve().then(()=>ef);return{loadSkills:n}},void 0,import.meta.url).then(({loadSkills:n})=>{n(this,{clearMessages:!0})})}async handleChannelConfigSave(){await t0(this)}async handleChannelConfigReload(){await n0(this)}handleNostrProfileEdit(e,t){s0(this,e,t)}handleNostrProfileCancel(){o0(this)}handleNostrProfileFieldChange(e,t){a0(this,e,t)}async handleNostrProfileSave(){await l0(this)}async handleNostrProfileImport(){await c0(this)}handleNostrProfileToggleAdvanced(){r0(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)}handleContactsLoad(){const e=this.selectedWorkspace??void 0;le(async()=>{const{loadContacts:t}=await Promise.resolve().then(()=>_k);return{loadContacts:t}},void 0,import.meta.url).then(({loadContacts:t})=>{t(this,e)})}handleContactsNewPhoneChange(e){this.contactsNewPhone=e,this.contactsError&&(this.contactsError=null)}handleContactsNewNameChange(e){this.contactsNewName=e,this.contactsError&&(this.contactsError=null)}async handleWorkspacesLoad(){const{loadWorkspaces:e}=await le(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>ki);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await le(async()=>{const{createWorkspace:s}=await Promise.resolve().then(()=>ki);return{createWorkspace:s}},void 0,import.meta.url),{loadChannels:i}=await le(async()=>{const{loadChannels:s}=await Promise.resolve().then(()=>gh);return{loadChannels:s}},void 0,import.meta.url);await n(this,{name:e,workspacePath:t,onCreated:s=>{if(!s.whatsappAccountId)return;const o=s.whatsappAccountId;this.handleWorkspaceSelect(e),setTimeout(async()=>{try{await i(this,!0),await this.handleWhatsAppStart(!0,o),this.whatsappLoginQrDataUrl&&(await this.handleWhatsAppWait(o),await i(this,!0),await this.handleWorkspacesLoad())}catch{}this.requestUpdate()},3e3)}})}async handleWorkspaceRemove(e){const{removeWorkspace:t}=await le(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>ki);return{removeWorkspace:n}},void 0,import.meta.url);await t(this,e)}handleWorkspaceRenameStart(){const e=this.getSelectedWorkspaceInfo();this.renameWorkspaceName=(e==null?void 0:e.displayName)??(e==null?void 0:e.name)??"",this.renamingWorkspace=!0}handleWorkspaceRenameCancel(){this.renamingWorkspace=!1,this.renameWorkspaceName=""}async handleWorkspaceRename(e,t){const{renameWorkspace:n}=await le(async()=>{const{renameWorkspace:i}=await Promise.resolve().then(()=>ki);return{renameWorkspace:i}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){vo(),this.selectedWorkspace&&Wn(this.selectedWorkspace,this.sessionKey,this.chatMessage),this.selectedWorkspace=e,this.publicChatQrDataUrl=null,localStorage.setItem("taskmaster-selected-workspace",e),Tn(e),mr(e),this.settings=Is(),this.chatMessage=Kn(e,this.settings.sessionKey),this.chatAttachments=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestions=[],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.loadAuditEntries(),this.adminsPage?this.handleAdminsLoad():this.contactsPage?this.handleContactsLoad():this.filesPage?this.handleFilesLoad():this.chatPage?this.handleChatLoad():this.advancedPage&&this.handleAdvancedLoad()}initWorkspaceSelection(){if(this.workspaces.length===0){this.reloadCurrentPageData();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(i=>i.isDefault)??this.workspaces[0];this.selectedWorkspace=n.name,localStorage.setItem("taskmaster-selected-workspace",n.name)}Tn(this.selectedWorkspace),mr(this.selectedWorkspace),this.settings=Is(),this.chatMessage=Kn(this.selectedWorkspace,this.settings.sessionKey),this.reloadCurrentPageData()}render(){return u`${Uk(this)}${this.auditModalOpen?Kk(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):w}`}};m([y()],g.prototype,"settings",2);m([y()],g.prototype,"password",2);m([y()],g.prototype,"tab",2);m([y()],g.prototype,"onboarding",2);m([y()],g.prototype,"setup",2);m([y()],g.prototype,"filesPage",2);m([y()],g.prototype,"browserPage",2);m([y()],g.prototype,"adminsPage",2);m([y()],g.prototype,"contactsPage",2);m([y()],g.prototype,"chatPage",2);m([y()],g.prototype,"advancedPage",2);m([y()],g.prototype,"advancedTab",2);m([y()],g.prototype,"publicChat",2);m([y()],g.prototype,"publicChatConfig",2);m([y()],g.prototype,"publicChatSessionKey",2);m([y()],g.prototype,"publicChatAuthenticated",2);m([y()],g.prototype,"publicChatAuthStep",2);m([y()],g.prototype,"connected",2);m([y()],g.prototype,"accessState",2);m([y()],g.prototype,"theme",2);m([y()],g.prototype,"themeResolved",2);m([y()],g.prototype,"hello",2);m([y()],g.prototype,"lastError",2);m([y()],g.prototype,"eventLog",2);m([y()],g.prototype,"assistantName",2);m([y()],g.prototype,"assistantAvatar",2);m([y()],g.prototype,"assistantAgentId",2);m([y()],g.prototype,"sessionKey",2);m([y()],g.prototype,"chatLoading",2);m([y()],g.prototype,"chatSending",2);m([y()],g.prototype,"chatMessage",2);m([y()],g.prototype,"chatMessages",2);m([y()],g.prototype,"chatHistoryTotal",2);m([y()],g.prototype,"chatHistoryHasMore",2);m([y()],g.prototype,"chatLoadingOlder",2);m([y()],g.prototype,"chatToolMessages",2);m([y()],g.prototype,"chatStream",2);m([y()],g.prototype,"chatInterimText",2);m([y()],g.prototype,"chatSuggestions",2);m([y()],g.prototype,"chatStreamStartedAt",2);m([y()],g.prototype,"chatRunId",2);m([y()],g.prototype,"compactionStatus",2);m([y()],g.prototype,"chatAvatarUrl",2);m([y()],g.prototype,"chatThinkingLevel",2);m([y()],g.prototype,"chatModelProvider",2);m([y()],g.prototype,"chatModel",2);m([y()],g.prototype,"chatModelCatalog",2);m([y()],g.prototype,"chatVerboseLevel",2);m([y()],g.prototype,"chatFillerEnabled",2);m([y()],g.prototype,"chatQueue",2);m([y()],g.prototype,"chatAttachments",2);m([y()],g.prototype,"sidebarOpen",2);m([y()],g.prototype,"sidebarContent",2);m([y()],g.prototype,"sidebarError",2);m([y()],g.prototype,"splitRatio",2);m([y()],g.prototype,"nodesLoading",2);m([y()],g.prototype,"nodes",2);m([y()],g.prototype,"devicesLoading",2);m([y()],g.prototype,"devicesError",2);m([y()],g.prototype,"devicesList",2);m([y()],g.prototype,"execApprovalsLoading",2);m([y()],g.prototype,"execApprovalsSaving",2);m([y()],g.prototype,"execApprovalsDirty",2);m([y()],g.prototype,"execApprovalsSnapshot",2);m([y()],g.prototype,"execApprovalsForm",2);m([y()],g.prototype,"execApprovalsSelectedAgent",2);m([y()],g.prototype,"execApprovalsTarget",2);m([y()],g.prototype,"execApprovalsTargetNodeId",2);m([y()],g.prototype,"execApprovalQueue",2);m([y()],g.prototype,"execApprovalBusy",2);m([y()],g.prototype,"execApprovalError",2);m([y()],g.prototype,"configLoading",2);m([y()],g.prototype,"configRaw",2);m([y()],g.prototype,"configRawOriginal",2);m([y()],g.prototype,"configValid",2);m([y()],g.prototype,"configIssues",2);m([y()],g.prototype,"configSaving",2);m([y()],g.prototype,"configApplying",2);m([y()],g.prototype,"updateRunning",2);m([y()],g.prototype,"applySessionKey",2);m([y()],g.prototype,"configSnapshot",2);m([y()],g.prototype,"configSchema",2);m([y()],g.prototype,"configSchemaVersion",2);m([y()],g.prototype,"configSchemaLoading",2);m([y()],g.prototype,"configUiHints",2);m([y()],g.prototype,"configForm",2);m([y()],g.prototype,"configFormOriginal",2);m([y()],g.prototype,"configFormDirty",2);m([y()],g.prototype,"configFormMode",2);m([y()],g.prototype,"configSearchQuery",2);m([y()],g.prototype,"configActiveSection",2);m([y()],g.prototype,"configActiveSubsection",2);m([y()],g.prototype,"channelsLoading",2);m([y()],g.prototype,"channelsSnapshot",2);m([y()],g.prototype,"channelsError",2);m([y()],g.prototype,"channelsLastSuccess",2);m([y()],g.prototype,"whatsappLoginMessage",2);m([y()],g.prototype,"whatsappLoginQrDataUrl",2);m([y()],g.prototype,"whatsappLoginConnected",2);m([y()],g.prototype,"whatsappBusy",2);m([y()],g.prototype,"whatsappActiveQrAccountId",2);m([y()],g.prototype,"whatsappPairedPhone",2);m([y()],g.prototype,"addingWhatsAppAccount",2);m([y()],g.prototype,"newWhatsAppAccountName",2);m([y()],g.prototype,"whatsappAccountError",2);m([y()],g.prototype,"whatsappAccountSaving",2);m([y()],g.prototype,"whatsappSettingsOpen",2);m([y()],g.prototype,"publicChatToggleBusy",2);m([y()],g.prototype,"publicChatGreetingBusy",2);m([y()],g.prototype,"publicChatEmailBusy",2);m([y()],g.prototype,"publicChatSettingsOpen",2);m([y()],g.prototype,"publicChatWidgetModalOpen",2);m([y()],g.prototype,"brandingBusy",2);m([y()],g.prototype,"brandingExpanded",2);m([y()],g.prototype,"tailscaleStatus",2);m([y()],g.prototype,"tailscaleBusy",2);m([y()],g.prototype,"tailscaleAuthUrl",2);m([y()],g.prototype,"tailscaleError",2);m([y()],g.prototype,"tailscaleFunnelEnableUrl",2);m([y()],g.prototype,"tailscaleDisableConfirm",2);m([y()],g.prototype,"tailscaleConnectProgress",2);m([y()],g.prototype,"tailscaleConnectMessage",2);m([y()],g.prototype,"tailscaleConnectSuccess",2);m([y()],g.prototype,"wifiStatus",2);m([y()],g.prototype,"wifiNetworks",2);m([y()],g.prototype,"wifiBusy",2);m([y()],g.prototype,"wifiError",2);m([y()],g.prototype,"wifiPassword",2);m([y()],g.prototype,"wifiSelectedSsid",2);m([y()],g.prototype,"networkPort",2);m([y()],g.prototype,"networkHostname",2);m([y()],g.prototype,"networkPortInput",2);m([y()],g.prototype,"networkHostnameInput",2);m([y()],g.prototype,"networkModalOpen",2);m([y()],g.prototype,"networkBusy",2);m([y()],g.prototype,"networkError",2);m([y()],g.prototype,"networkSuccess",2);m([y()],g.prototype,"wifiModalOpen",2);m([y()],g.prototype,"licenseKey",2);m([y()],g.prototype,"licenseBusy",2);m([y()],g.prototype,"licenseValid",2);m([y()],g.prototype,"licenseMessage",2);m([y()],g.prototype,"licenseTier",2);m([y()],g.prototype,"licenseDeviceId",2);m([y()],g.prototype,"licenseStoredKey",2);m([y()],g.prototype,"licenseRemoveConfirm",2);m([y()],g.prototype,"authConnected",2);m([y()],g.prototype,"authBusy",2);m([y()],g.prototype,"authMessage",2);m([y()],g.prototype,"authUrl",2);m([y()],g.prototype,"authCodeInput",2);m([y()],g.prototype,"authExpiresIn",2);m([y()],g.prototype,"setupStep",2);m([y()],g.prototype,"gatewayHealthy",2);m([y()],g.prototype,"gatewayHealthLoading",2);m([y()],g.prototype,"gatewayHealthMessage",2);m([y()],g.prototype,"gatewayRestartBusy",2);m([y()],g.prototype,"updateAvailable",2);m([y()],g.prototype,"currentVersion",2);m([y()],g.prototype,"latestVersion",2);m([y()],g.prototype,"updateChecking",2);m([y()],g.prototype,"updateMessage",2);m([y()],g.prototype,"updateProgressSteps",2);m([y()],g.prototype,"updateLastResult",2);m([y()],g.prototype,"uninstallConfirm",2);m([y()],g.prototype,"uninstallBusy",2);m([y()],g.prototype,"uninstallDone",2);m([y()],g.prototype,"uninstallError",2);m([y()],g.prototype,"uninstallConfirmText",2);m([y()],g.prototype,"nostrProfileFormState",2);m([y()],g.prototype,"nostrProfileAccountId",2);m([y()],g.prototype,"presenceLoading",2);m([y()],g.prototype,"presenceEntries",2);m([y()],g.prototype,"presenceError",2);m([y()],g.prototype,"presenceStatus",2);m([y()],g.prototype,"agentsLoading",2);m([y()],g.prototype,"agentsList",2);m([y()],g.prototype,"agentsError",2);m([y()],g.prototype,"sessionsLoading",2);m([y()],g.prototype,"sessionsResult",2);m([y()],g.prototype,"sessionsError",2);m([y()],g.prototype,"cronLoading",2);m([y()],g.prototype,"cronJobs",2);m([y()],g.prototype,"cronStatus",2);m([y()],g.prototype,"cronError",2);m([y()],g.prototype,"cronForm",2);m([y()],g.prototype,"cronRunsJobId",2);m([y()],g.prototype,"cronRuns",2);m([y()],g.prototype,"cronBusy",2);m([y()],g.prototype,"cronNewEventModal",2);m([y()],g.prototype,"cronDetailJobId",2);m([y()],g.prototype,"cronEditJobId",2);m([y()],g.prototype,"cronPendingDeleteId",2);m([y()],g.prototype,"cronRunModalJobId",2);m([y()],g.prototype,"cronRunModalJobName",2);m([y()],g.prototype,"cronRunResult",2);m([y()],g.prototype,"browserScreencastActive",2);m([y()],g.prototype,"browserScreencastFrame",2);m([y()],g.prototype,"browserScreencastMetadata",2);m([y()],g.prototype,"browserHandoffPending",2);m([y()],g.prototype,"browserHandoffReason",2);m([y()],g.prototype,"browserHandoffId",2);m([y()],g.prototype,"browserInputMode",2);m([y()],g.prototype,"browserFullscreen",2);m([y()],g.prototype,"browserLoading",2);m([y()],g.prototype,"browserError",2);m([y()],g.prototype,"filesLoading",2);m([y()],g.prototype,"filesTree",2);m([y()],g.prototype,"filesRoot",2);m([y()],g.prototype,"filesError",2);m([y()],g.prototype,"filesSelectedPath",2);m([y()],g.prototype,"filesSelectedPaths",2);m([y()],g.prototype,"filesPreviewContent",2);m([y()],g.prototype,"filesPreviewLoading",2);m([y()],g.prototype,"filesPreviewBinary",2);m([y()],g.prototype,"filesPreviewSize",2);m([y()],g.prototype,"filesExpandedDirs",2);m([y()],g.prototype,"filesCurrentDir",2);m([y()],g.prototype,"filesPendingDeletePath",2);m([y()],g.prototype,"filesMessage",2);m([y()],g.prototype,"filesUploadBusy",2);m([y()],g.prototype,"filesReindexBusy",2);m([y()],g.prototype,"filesMemoryStatus",2);m([y()],g.prototype,"embeddingDownloading",2);m([y()],g.prototype,"filesSearchQuery",2);m([y()],g.prototype,"filesSearchResults",2);m([y()],g.prototype,"filesSearchLoading",2);m([y()],g.prototype,"filesSearchAgentId",2);m([y()],g.prototype,"auditEntries",2);m([y()],g.prototype,"auditLoading",2);m([y()],g.prototype,"auditModalOpen",2);m([y()],g.prototype,"skillsLoading",2);m([y()],g.prototype,"skillsReport",2);m([y()],g.prototype,"skillsError",2);m([y()],g.prototype,"skillsFilter",2);m([y()],g.prototype,"skillsTypeFilter",2);m([y()],g.prototype,"skillEdits",2);m([y()],g.prototype,"skillsBusyKey",2);m([y()],g.prototype,"skillMessages",2);m([y()],g.prototype,"skillDetail",2);m([y()],g.prototype,"skillDetailTab",2);m([y()],g.prototype,"skillAddModal",2);m([y()],g.prototype,"skillAddForm",2);m([y()],g.prototype,"skillAddFormSource",2);m([y()],g.prototype,"skillEditTab",2);m([y()],g.prototype,"skillDrafts",2);m([y()],g.prototype,"adminsLoading",2);m([y()],g.prototype,"adminPhones",2);m([y()],g.prototype,"adminsError",2);m([y()],g.prototype,"adminsSaving",2);m([y()],g.prototype,"adminsNewPhone",2);m([y()],g.prototype,"contactsLoading",2);m([y()],g.prototype,"contactsSaving",2);m([y()],g.prototype,"contactsRecords",2);m([y()],g.prototype,"contactsError",2);m([y()],g.prototype,"contactsSearchQuery",2);m([y()],g.prototype,"contactsEditingId",2);m([y()],g.prototype,"contactsShowAddForm",2);m([y()],g.prototype,"contactsNewPhone",2);m([y()],g.prototype,"contactsNewName",2);m([y()],g.prototype,"contactsDeleteConfirmId",2);m([y()],g.prototype,"contactsAddFieldForId",2);m([y()],g.prototype,"contactsAddFieldKey",2);m([y()],g.prototype,"contactsAddFieldValue",2);m([y()],g.prototype,"imessageEnableConfirm",2);m([y()],g.prototype,"imessageEnabling",2);m([y()],g.prototype,"infoModalOpen",2);m([y()],g.prototype,"remoteAccessQrDataUrl",2);m([y()],g.prototype,"publicChatQrDataUrl",2);m([y()],g.prototype,"workspaces",2);m([y()],g.prototype,"workspacesLoading",2);m([y()],g.prototype,"workspacesError",2);m([y()],g.prototype,"selectedWorkspace",2);m([y()],g.prototype,"addingWorkspace",2);m([y()],g.prototype,"newWorkspaceName",2);m([y()],g.prototype,"newWorkspacePath",2);m([y()],g.prototype,"newWorkspacePin",2);m([y()],g.prototype,"accountPinModalOpen",2);m([y()],g.prototype,"accountPinBusy",2);m([y()],g.prototype,"accountPinError",2);m([y()],g.prototype,"accountPinSuccess",2);m([y()],g.prototype,"apiKeyProviders",2);m([y()],g.prototype,"apiKeyModalOpen",2);m([y()],g.prototype,"apiKeyBusy",2);m([y()],g.prototype,"apiKeyError",2);m([y()],g.prototype,"apiKeySuccess",2);m([y()],g.prototype,"apiKeySavingProvider",2);m([y()],g.prototype,"authApiKeyMode",2);m([y()],g.prototype,"authApiKeyInput",2);m([y()],g.prototype,"authApiKeyBusy",2);m([y()],g.prototype,"authApiKeyError",2);m([y()],g.prototype,"pinChanging",2);m([y()],g.prototype,"pinChangeBusy",2);m([y()],g.prototype,"pinChangeError",2);m([y()],g.prototype,"loginChangePinMode",2);m([y()],g.prototype,"changePinBusy",2);m([y()],g.prototype,"changePinError",2);m([y()],g.prototype,"changePinSuccess",2);m([y()],g.prototype,"workspaceSaving",2);m([y()],g.prototype,"workspaceRemoveConfirm",2);m([y()],g.prototype,"renamingWorkspace",2);m([y()],g.prototype,"renameWorkspaceName",2);m([y()],g.prototype,"debugLoading",2);m([y()],g.prototype,"debugStatus",2);m([y()],g.prototype,"debugHealth",2);m([y()],g.prototype,"debugModels",2);m([y()],g.prototype,"debugHeartbeat",2);m([y()],g.prototype,"debugCallMethod",2);m([y()],g.prototype,"debugCallParams",2);m([y()],g.prototype,"debugCallResult",2);m([y()],g.prototype,"debugCallError",2);m([y()],g.prototype,"logsLoading",2);m([y()],g.prototype,"logsError",2);m([y()],g.prototype,"logsFile",2);m([y()],g.prototype,"logsEntries",2);m([y()],g.prototype,"logsFilterText",2);m([y()],g.prototype,"logsLevelFilters",2);m([y()],g.prototype,"logsAutoFollow",2);m([y()],g.prototype,"logsTruncated",2);m([y()],g.prototype,"logsCursor",2);m([y()],g.prototype,"logsLastFetchAt",2);m([y()],g.prototype,"logsLimit",2);m([y()],g.prototype,"logsMaxBytes",2);m([y()],g.prototype,"logsAtBottom",2);m([y()],g.prototype,"logsSubTab",2);m([y()],g.prototype,"logsChipsExpanded",2);m([y()],g.prototype,"sessionLogsLoading",2);m([y()],g.prototype,"sessionLogsError",2);m([y()],g.prototype,"sessionLogsEntries",2);m([y()],g.prototype,"sessionLogsFilterText",2);m([y()],g.prototype,"sessionLogsTypeFilters",2);m([y()],g.prototype,"sessionLogsAgentFilters",2);m([y()],g.prototype,"sessionLogsAgents",2);m([y()],g.prototype,"sessionLogsAutoFollow",2);m([y()],g.prototype,"sessionLogsChipsExpanded",2);m([y()],g.prototype,"sessionLogsCursors",2);m([y()],g.prototype,"sessionLogsLastFetchAt",2);m([y()],g.prototype,"sessionLogsAtBottom",2);m([y()],g.prototype,"chatUserNearBottom",2);g=m([Wl("taskmaster-app")],g);
|
|
4552
|
-
//# sourceMappingURL=index-
|
|
4564
|
+
`,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.publicChatToggleBusy=!1,this.publicChatGreetingBusy=!1,this.publicChatEmailBusy=!1,this.publicChatSettingsOpen=!1,this.publicChatWidgetModalOpen=!1,this.brandingBusy=!1,this.brandingExpanded=!1,this.tailscaleStatus=null,this.tailscaleBusy=!1,this.tailscaleAuthUrl=null,this.tailscaleError=null,this.tailscaleServeEnableUrl=null,this.tailscaleFunnelEnableUrl=null,this.tailscaleDisableConfirm=!1,this.tailscaleConnectProgress=0,this.tailscaleConnectMessage="",this.tailscaleConnectSuccess=!1,this.wifiStatus=null,this.wifiNetworks=[],this.wifiBusy=!1,this.wifiError=null,this.wifiPassword="",this.wifiSelectedSsid=null,this.networkPort=null,this.networkHostname="",this.networkPortInput="",this.networkHostnameInput="",this.networkModalOpen=!1,this.networkBusy=!1,this.networkError=null,this.networkSuccess=null,this.wifiModalOpen=!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.uninstallConfirm=!1,this.uninstallBusy=!1,this.uninstallDone=!1,this.uninstallError=null,this.uninstallConfirmText="",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={...qk},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.cronNewEventModal=!1,this.cronDetailJobId=null,this.cronEditJobId=null,this.cronPendingDeleteId=null,this.cronRunModalJobId=null,this.cronRunModalJobName="",this.cronRunResult=null,this.browserScreencastActive=!1,this.browserScreencastFrame=null,this.browserScreencastMetadata=null,this.browserHandoffPending=!1,this.browserHandoffReason=null,this.browserHandoffId=null,this.browserInputMode=!1,this.browserFullscreen=!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.filesCurrentDir=".",this.filesPendingDeletePath=null,this.filesMessage=null,this.filesUploadBusy=!1,this.filesReindexBusy=!1,this.filesMemoryStatus=null,this.embeddingDownloading=!1,this.embeddingPollTimer=null,this.filesSearchQuery="",this.filesSearchResults=null,this.filesSearchLoading=!1,this.filesSearchAgentId=null,this.filesResolvedAgentId=void 0,this.auditEntries=[],this.auditLoading=!1,this.auditModalOpen=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillsTypeFilter="all",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.skillDetail=null,this.skillDetailTab="",this.skillAddModal=!1,this.skillAddForm={name:"",skillContent:"",references:[]},this.skillAddFormSource="draft",this.skillEditTab="SKILL.md",this.skillDrafts=[],this.adminsLoading=!1,this.adminPhones=[],this.adminsError=null,this.adminsSaving=!1,this.adminsNewPhone="",this.contactsLoading=!1,this.contactsSaving=!1,this.contactsRecords=[],this.contactsError=null,this.contactsSearchQuery="",this.contactsEditingId=null,this.contactsShowAddForm=!1,this.contactsNewPhone="",this.contactsNewName="",this.contactsDeleteConfirmId=null,this.contactsAddFieldForId=null,this.contactsAddFieldKey="",this.contactsAddFieldValue="",this.imessageEnableConfirm=!1,this.imessageEnabling=!1,this.infoModalOpen=null,this.remoteAccessQrDataUrl=null,this.publicChatQrDataUrl=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.apiKeySavingProvider=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={...zk},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.logsChipsExpanded=!1,this.sessionLogsLoading=!1,this.sessionLogsError=null,this.sessionLogsEntries=[],this.sessionLogsFilterText="",this.sessionLogsTypeFilters={user:!0,assistant:!0,tool:!0,tool_call:!0,tool_result:!0,thinking:!0,error:!0,system:!0},this.sessionLogsAgentFilters={},this.sessionLogsAgents=[],this.sessionLogsAutoFollow=!0,this.sessionLogsChipsExpanded=!1,this.sessionLogsExpandedIds=new Set,this.sessionLogsCursors={},this.sessionLogsLastFetchAt=null,this.sessionLogsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.onLoadOlder=()=>this.handleLoadOlderChat(),this.nodesPollInterval=null,this.logsPollInterval=null,this.sessionLogsPollInterval=null,this.debugPollInterval=null,this.auditPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>Df(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null,this._beforeUnloadHandler=()=>{var t;vo();const e=this.selectedWorkspace??((t=this.publicChatConfig)==null?void 0:t.accountId)??"";e&&Wn(e,this.sessionKey,this.chatMessage)}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),Hk(this),window.addEventListener("beforeunload",this._beforeUnloadHandler)}firstUpdated(){jk(this)}disconnectedCallback(){window.removeEventListener("beforeunload",this._beforeUnloadHandler),this.stopEmbeddingPoll(),Gk(this),super.disconnectedCallback()}startEmbeddingPoll(){if(this.embeddingPollTimer!=null)return;const e=async()=>{if(!(!this.client||!this.connected)){try{const t=await this.client.request("memory.status",{});if((t==null?void 0:t.embeddingState)==="downloading")this.embeddingDownloading=!0;else{this.embeddingDownloading&&(this.embeddingDownloading=!1),this.stopEmbeddingPoll();return}}catch{this.embeddingDownloading=!1,this.stopEmbeddingPoll();return}this.embeddingPollTimer=window.setTimeout(e,3e3)}};e()}stopEmbeddingPoll(){this.embeddingPollTimer!=null&&(window.clearTimeout(this.embeddingPollTimer),this.embeddingPollTimer=null)}updated(e){Vk(this,e)}connect(){De(this)}handleChatScroll(e){Yp(this,e)}handleLogsScroll(e){Zp(this,e)}handleSessionLogsScroll(e){eh(this,e)}exportLogs(e,t){nh(e,t)}exportSessionLogs(e,t){ih(e,t)}resetToolStream(){Xo(this)}resetChatScroll(){th(this)}async loadAssistantIdentity(){await zo(this)}applySettings(e){rt(this,e)}setTab(e){Tf(this,e)}setTheme(e,t){_f(this,e,t)}async loadOverview(){await id(this)}async loadCron(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.accountId=(e==null?void 0:e.whatsappAccountId)??void 0,this.cronForm={...this.cronForm,accountId:(e==null?void 0:e.whatsappAccountId)??void 0},await ma(this)}async handleAbortChat(){await od(this)}removeQueuedMessage(e){Ff(this,e)}async handleSendChat(e,t){await Uf(this,e,t)}async handleWhatsAppStart(e,t){await Jk(this,e,t)}async handleWhatsAppWait(e){await Yk(this,e)}async handleWhatsAppLogout(e){await Xk(this,e)}async handleAddWhatsAppAccount(e){await Zk(this,e)}async handleRemoveWhatsAppAccount(e){await e0(this,e)}async handleAccessCheck(){await Ml(this)}async handlePinSubmit(e,t){await $k(this,e,t),this.accessState.authenticated&&this.accessState.workspace&&this.handleWorkspaceSelect(this.accessState.workspace)}async handleSetMasterPin(e){await Sk(this,e)}async handleLogout(){await Ck(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 i=await this.client.request("access.verify",{account:e,pin:t});if(!i.ok){this.changePinError=i.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 i=await this.client.request("access.verify",{account:e,pin:t});if(!i.ok){this.accountPinError=i.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 Ml(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 g0(this)}async handleLicenseActivate(){await m0(this)}async handleLicenseRemove(){await y0(this)}handleLicenseKeyChange(e){v0(this,e)}async handleAuthStatusCheck(){await d0(this)}async handleAuthStart(){await u0(this)}async handleAuthSubmitCode(e){await p0(this,e)}handleAuthCodeChange(e){h0(this,e)}handleSkipToWhatsApp(){f0(this)}async handleGatewayHealthCheck(){await b0(this)}async handleGatewayRestart(){await w0(this)}async handleUpdateCheck(){await fu(this)}async handleUpdateRun(){await ok(this)}handleUpdateDismissResult(){lk(this)}handleUninstallConfirm(){this.uninstallConfirm=!0,this.uninstallConfirmText=""}handleUninstallCancel(){this.uninstallConfirm=!1,this.uninstallConfirmText="",this.uninstallError=null}handleUninstallConfirmTextChange(e){this.uninstallConfirmText=e}async handleUninstallRun(){const{runUninstall:e}=await le(async()=>{const{runUninstall:t}=await Promise.resolve().then(()=>Mr);return{runUninstall:t}},void 0,import.meta.url);await e(this)}handleUninstallDismiss(){le(async()=>{const{clearUninstallDone:e}=await Promise.resolve().then(()=>Mr);return{clearUninstallDone:e}},void 0,import.meta.url).then(({clearUninstallDone:e})=>{e()}),this.uninstallDone=!1,this.uninstallConfirm=!1,this.uninstallConfirmText=""}async loadAuditEntries(){await Yc(this)}async clearAudit(){await lf(this),this.auditModalOpen=!1}handleFilesLoad(){var n;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((n=e==null?void 0:e.agents)==null?void 0:n.map(i=>i.id))??void 0;const t=this.resolveFilesAgentId();this.filesResolvedAgentId=t,an(this,t),ls(this,t)}handleAdminsLoad(){const e=this.resolveAdminAgentId();le(async()=>{const{loadAdmins:t}=await Promise.resolve().then(()=>Tk);return{loadAdmins:t}},void 0,import.meta.url).then(({loadAdmins:t})=>{t(this,e)})}resolveAdminAgentId(){const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(n=>n.id.endsWith("-admin")||n.id==="admin");return t==null?void 0:t.id}resolveFilesAgentId(){var n;const e=this.getSelectedWorkspaceInfo();if(!e)return;const t=e.agents.find(i=>i.id.endsWith("-admin")||i.id==="admin");return(t==null?void 0:t.id)??((n=e.agents[0])==null?void 0:n.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.chatInterimText=null,this.chatRunId=null,this.chatSuggestions=[],this.resetChatScroll(),this.applySettings({...this.settings,sessionKey:t,lastActiveSessionKey:t}),this.loadAssistantIdentity())}le(async()=>{const{loadChatHistory:t}=await Promise.resolve().then(()=>Ni);return{loadChatHistory:t}},void 0,import.meta.url).then(({loadChatHistory:t})=>{t(this).then(()=>{nn(this,!0)})})}async handleLoadOlderChat(){if(this.chatLoadingOlder||!this.chatHistoryHasMore)return;const e=Xp(this),{loadOlderChatHistory:t}=await le(async()=>{const{loadOlderChatHistory:i}=await Promise.resolve().then(()=>Ni);return{loadOlderChatHistory:i}},void 0,import.meta.url);await t(this)&&e&&(await this.updateComplete,e())}handleAdvancedLoad(){var t;const e=this.getSelectedWorkspaceInfo();this.workspaceAgentIds=((t=e==null?void 0:e.agents)==null?void 0:t.map(n=>n.id))??void 0,this.sessionLogsEntries=[],this.sessionLogsCursors={},this.sessionLogsAgents=[],this.advancedTab==="cron"&&this.loadCron(),this.advancedTab==="logs"&&(this.logsSubTab==="session"?le(async()=>{const{loadSessionLogs:n}=await Promise.resolve().then(()=>Jc);return{loadSessionLogs:n}},void 0,import.meta.url).then(({loadSessionLogs:n})=>{n(this,{reset:!0})}):le(async()=>{const{loadLogs:n}=await Promise.resolve().then(()=>wh);return{loadLogs:n}},void 0,import.meta.url).then(({loadLogs:n})=>{n(this,{reset:!0})})),this.advancedTab==="skills"&&le(async()=>{const{loadSkills:n}=await Promise.resolve().then(()=>ef);return{loadSkills:n}},void 0,import.meta.url).then(({loadSkills:n})=>{n(this,{clearMessages:!0})})}async handleChannelConfigSave(){await t0(this)}async handleChannelConfigReload(){await n0(this)}handleNostrProfileEdit(e,t){s0(this,e,t)}handleNostrProfileCancel(){o0(this)}handleNostrProfileFieldChange(e,t){a0(this,e,t)}async handleNostrProfileSave(){await l0(this)}async handleNostrProfileImport(){await c0(this)}handleNostrProfileToggleAdvanced(){r0(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)}handleContactsLoad(){const e=this.selectedWorkspace??void 0;le(async()=>{const{loadContacts:t}=await Promise.resolve().then(()=>_k);return{loadContacts:t}},void 0,import.meta.url).then(({loadContacts:t})=>{t(this,e)})}handleContactsNewPhoneChange(e){this.contactsNewPhone=e,this.contactsError&&(this.contactsError=null)}handleContactsNewNameChange(e){this.contactsNewName=e,this.contactsError&&(this.contactsError=null)}async handleWorkspacesLoad(){const{loadWorkspaces:e}=await le(async()=>{const{loadWorkspaces:t}=await Promise.resolve().then(()=>ki);return{loadWorkspaces:t}},void 0,import.meta.url);await e(this)}async handleWorkspaceCreate(e,t){const{createWorkspace:n}=await le(async()=>{const{createWorkspace:s}=await Promise.resolve().then(()=>ki);return{createWorkspace:s}},void 0,import.meta.url),{loadChannels:i}=await le(async()=>{const{loadChannels:s}=await Promise.resolve().then(()=>gh);return{loadChannels:s}},void 0,import.meta.url);await n(this,{name:e,workspacePath:t,onCreated:s=>{if(!s.whatsappAccountId)return;const o=s.whatsappAccountId;this.handleWorkspaceSelect(e),setTimeout(async()=>{try{await i(this,!0),await this.handleWhatsAppStart(!0,o),this.whatsappLoginQrDataUrl&&(await this.handleWhatsAppWait(o),await i(this,!0),await this.handleWorkspacesLoad())}catch{}this.requestUpdate()},3e3)}})}async handleWorkspaceRemove(e){const{removeWorkspace:t}=await le(async()=>{const{removeWorkspace:n}=await Promise.resolve().then(()=>ki);return{removeWorkspace:n}},void 0,import.meta.url);await t(this,e)}handleWorkspaceRenameStart(){const e=this.getSelectedWorkspaceInfo();this.renameWorkspaceName=(e==null?void 0:e.displayName)??(e==null?void 0:e.name)??"",this.renamingWorkspace=!0}handleWorkspaceRenameCancel(){this.renamingWorkspace=!1,this.renameWorkspaceName=""}async handleWorkspaceRename(e,t){const{renameWorkspace:n}=await le(async()=>{const{renameWorkspace:i}=await Promise.resolve().then(()=>ki);return{renameWorkspace:i}},void 0,import.meta.url);await n(this,e,t),this.renamingWorkspace=!1,this.renameWorkspaceName=""}handleWorkspaceSelect(e){vo(),this.selectedWorkspace&&Wn(this.selectedWorkspace,this.sessionKey,this.chatMessage),this.selectedWorkspace=e,this.publicChatQrDataUrl=null,localStorage.setItem("taskmaster-selected-workspace",e),Tn(e),mr(e),this.settings=Is(),this.chatMessage=Kn(e,this.settings.sessionKey),this.chatAttachments=[],this.chatStream=null,this.chatInterimText=null,this.chatSuggestions=[],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.loadAuditEntries(),this.adminsPage?this.handleAdminsLoad():this.contactsPage?this.handleContactsLoad():this.filesPage?this.handleFilesLoad():this.chatPage?this.handleChatLoad():this.advancedPage&&this.handleAdvancedLoad()}initWorkspaceSelection(){if(this.workspaces.length===0){this.reloadCurrentPageData();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(i=>i.isDefault)??this.workspaces[0];this.selectedWorkspace=n.name,localStorage.setItem("taskmaster-selected-workspace",n.name)}Tn(this.selectedWorkspace),mr(this.selectedWorkspace),this.settings=Is(),this.chatMessage=Kn(this.selectedWorkspace,this.settings.sessionKey),this.reloadCurrentPageData()}render(){return u`${Uk(this)}${this.auditModalOpen?Kk(this.auditEntries,()=>this.clearAudit(),()=>{this.auditModalOpen=!1}):w}`}};y([v()],m.prototype,"settings",2);y([v()],m.prototype,"password",2);y([v()],m.prototype,"tab",2);y([v()],m.prototype,"onboarding",2);y([v()],m.prototype,"setup",2);y([v()],m.prototype,"filesPage",2);y([v()],m.prototype,"browserPage",2);y([v()],m.prototype,"adminsPage",2);y([v()],m.prototype,"contactsPage",2);y([v()],m.prototype,"chatPage",2);y([v()],m.prototype,"advancedPage",2);y([v()],m.prototype,"advancedTab",2);y([v()],m.prototype,"publicChat",2);y([v()],m.prototype,"publicChatConfig",2);y([v()],m.prototype,"publicChatSessionKey",2);y([v()],m.prototype,"publicChatAuthenticated",2);y([v()],m.prototype,"publicChatAuthStep",2);y([v()],m.prototype,"connected",2);y([v()],m.prototype,"accessState",2);y([v()],m.prototype,"theme",2);y([v()],m.prototype,"themeResolved",2);y([v()],m.prototype,"hello",2);y([v()],m.prototype,"lastError",2);y([v()],m.prototype,"eventLog",2);y([v()],m.prototype,"assistantName",2);y([v()],m.prototype,"assistantAvatar",2);y([v()],m.prototype,"assistantAgentId",2);y([v()],m.prototype,"sessionKey",2);y([v()],m.prototype,"chatLoading",2);y([v()],m.prototype,"chatSending",2);y([v()],m.prototype,"chatMessage",2);y([v()],m.prototype,"chatMessages",2);y([v()],m.prototype,"chatHistoryTotal",2);y([v()],m.prototype,"chatHistoryHasMore",2);y([v()],m.prototype,"chatLoadingOlder",2);y([v()],m.prototype,"chatToolMessages",2);y([v()],m.prototype,"chatStream",2);y([v()],m.prototype,"chatInterimText",2);y([v()],m.prototype,"chatSuggestions",2);y([v()],m.prototype,"chatStreamStartedAt",2);y([v()],m.prototype,"chatRunId",2);y([v()],m.prototype,"compactionStatus",2);y([v()],m.prototype,"chatAvatarUrl",2);y([v()],m.prototype,"chatThinkingLevel",2);y([v()],m.prototype,"chatModelProvider",2);y([v()],m.prototype,"chatModel",2);y([v()],m.prototype,"chatModelCatalog",2);y([v()],m.prototype,"chatVerboseLevel",2);y([v()],m.prototype,"chatFillerEnabled",2);y([v()],m.prototype,"chatQueue",2);y([v()],m.prototype,"chatAttachments",2);y([v()],m.prototype,"sidebarOpen",2);y([v()],m.prototype,"sidebarContent",2);y([v()],m.prototype,"sidebarError",2);y([v()],m.prototype,"splitRatio",2);y([v()],m.prototype,"nodesLoading",2);y([v()],m.prototype,"nodes",2);y([v()],m.prototype,"devicesLoading",2);y([v()],m.prototype,"devicesError",2);y([v()],m.prototype,"devicesList",2);y([v()],m.prototype,"execApprovalsLoading",2);y([v()],m.prototype,"execApprovalsSaving",2);y([v()],m.prototype,"execApprovalsDirty",2);y([v()],m.prototype,"execApprovalsSnapshot",2);y([v()],m.prototype,"execApprovalsForm",2);y([v()],m.prototype,"execApprovalsSelectedAgent",2);y([v()],m.prototype,"execApprovalsTarget",2);y([v()],m.prototype,"execApprovalsTargetNodeId",2);y([v()],m.prototype,"execApprovalQueue",2);y([v()],m.prototype,"execApprovalBusy",2);y([v()],m.prototype,"execApprovalError",2);y([v()],m.prototype,"configLoading",2);y([v()],m.prototype,"configRaw",2);y([v()],m.prototype,"configRawOriginal",2);y([v()],m.prototype,"configValid",2);y([v()],m.prototype,"configIssues",2);y([v()],m.prototype,"configSaving",2);y([v()],m.prototype,"configApplying",2);y([v()],m.prototype,"updateRunning",2);y([v()],m.prototype,"applySessionKey",2);y([v()],m.prototype,"configSnapshot",2);y([v()],m.prototype,"configSchema",2);y([v()],m.prototype,"configSchemaVersion",2);y([v()],m.prototype,"configSchemaLoading",2);y([v()],m.prototype,"configUiHints",2);y([v()],m.prototype,"configForm",2);y([v()],m.prototype,"configFormOriginal",2);y([v()],m.prototype,"configFormDirty",2);y([v()],m.prototype,"configFormMode",2);y([v()],m.prototype,"configSearchQuery",2);y([v()],m.prototype,"configActiveSection",2);y([v()],m.prototype,"configActiveSubsection",2);y([v()],m.prototype,"channelsLoading",2);y([v()],m.prototype,"channelsSnapshot",2);y([v()],m.prototype,"channelsError",2);y([v()],m.prototype,"channelsLastSuccess",2);y([v()],m.prototype,"whatsappLoginMessage",2);y([v()],m.prototype,"whatsappLoginQrDataUrl",2);y([v()],m.prototype,"whatsappLoginConnected",2);y([v()],m.prototype,"whatsappBusy",2);y([v()],m.prototype,"whatsappActiveQrAccountId",2);y([v()],m.prototype,"whatsappPairedPhone",2);y([v()],m.prototype,"addingWhatsAppAccount",2);y([v()],m.prototype,"newWhatsAppAccountName",2);y([v()],m.prototype,"whatsappAccountError",2);y([v()],m.prototype,"whatsappAccountSaving",2);y([v()],m.prototype,"whatsappSettingsOpen",2);y([v()],m.prototype,"publicChatToggleBusy",2);y([v()],m.prototype,"publicChatGreetingBusy",2);y([v()],m.prototype,"publicChatEmailBusy",2);y([v()],m.prototype,"publicChatSettingsOpen",2);y([v()],m.prototype,"publicChatWidgetModalOpen",2);y([v()],m.prototype,"brandingBusy",2);y([v()],m.prototype,"brandingExpanded",2);y([v()],m.prototype,"tailscaleStatus",2);y([v()],m.prototype,"tailscaleBusy",2);y([v()],m.prototype,"tailscaleAuthUrl",2);y([v()],m.prototype,"tailscaleError",2);y([v()],m.prototype,"tailscaleServeEnableUrl",2);y([v()],m.prototype,"tailscaleFunnelEnableUrl",2);y([v()],m.prototype,"tailscaleDisableConfirm",2);y([v()],m.prototype,"tailscaleConnectProgress",2);y([v()],m.prototype,"tailscaleConnectMessage",2);y([v()],m.prototype,"tailscaleConnectSuccess",2);y([v()],m.prototype,"wifiStatus",2);y([v()],m.prototype,"wifiNetworks",2);y([v()],m.prototype,"wifiBusy",2);y([v()],m.prototype,"wifiError",2);y([v()],m.prototype,"wifiPassword",2);y([v()],m.prototype,"wifiSelectedSsid",2);y([v()],m.prototype,"networkPort",2);y([v()],m.prototype,"networkHostname",2);y([v()],m.prototype,"networkPortInput",2);y([v()],m.prototype,"networkHostnameInput",2);y([v()],m.prototype,"networkModalOpen",2);y([v()],m.prototype,"networkBusy",2);y([v()],m.prototype,"networkError",2);y([v()],m.prototype,"networkSuccess",2);y([v()],m.prototype,"wifiModalOpen",2);y([v()],m.prototype,"licenseKey",2);y([v()],m.prototype,"licenseBusy",2);y([v()],m.prototype,"licenseValid",2);y([v()],m.prototype,"licenseMessage",2);y([v()],m.prototype,"licenseTier",2);y([v()],m.prototype,"licenseDeviceId",2);y([v()],m.prototype,"licenseStoredKey",2);y([v()],m.prototype,"licenseRemoveConfirm",2);y([v()],m.prototype,"authConnected",2);y([v()],m.prototype,"authBusy",2);y([v()],m.prototype,"authMessage",2);y([v()],m.prototype,"authUrl",2);y([v()],m.prototype,"authCodeInput",2);y([v()],m.prototype,"authExpiresIn",2);y([v()],m.prototype,"setupStep",2);y([v()],m.prototype,"gatewayHealthy",2);y([v()],m.prototype,"gatewayHealthLoading",2);y([v()],m.prototype,"gatewayHealthMessage",2);y([v()],m.prototype,"gatewayRestartBusy",2);y([v()],m.prototype,"updateAvailable",2);y([v()],m.prototype,"currentVersion",2);y([v()],m.prototype,"latestVersion",2);y([v()],m.prototype,"updateChecking",2);y([v()],m.prototype,"updateMessage",2);y([v()],m.prototype,"updateProgressSteps",2);y([v()],m.prototype,"updateLastResult",2);y([v()],m.prototype,"uninstallConfirm",2);y([v()],m.prototype,"uninstallBusy",2);y([v()],m.prototype,"uninstallDone",2);y([v()],m.prototype,"uninstallError",2);y([v()],m.prototype,"uninstallConfirmText",2);y([v()],m.prototype,"nostrProfileFormState",2);y([v()],m.prototype,"nostrProfileAccountId",2);y([v()],m.prototype,"presenceLoading",2);y([v()],m.prototype,"presenceEntries",2);y([v()],m.prototype,"presenceError",2);y([v()],m.prototype,"presenceStatus",2);y([v()],m.prototype,"agentsLoading",2);y([v()],m.prototype,"agentsList",2);y([v()],m.prototype,"agentsError",2);y([v()],m.prototype,"sessionsLoading",2);y([v()],m.prototype,"sessionsResult",2);y([v()],m.prototype,"sessionsError",2);y([v()],m.prototype,"cronLoading",2);y([v()],m.prototype,"cronJobs",2);y([v()],m.prototype,"cronStatus",2);y([v()],m.prototype,"cronError",2);y([v()],m.prototype,"cronForm",2);y([v()],m.prototype,"cronRunsJobId",2);y([v()],m.prototype,"cronRuns",2);y([v()],m.prototype,"cronBusy",2);y([v()],m.prototype,"cronNewEventModal",2);y([v()],m.prototype,"cronDetailJobId",2);y([v()],m.prototype,"cronEditJobId",2);y([v()],m.prototype,"cronPendingDeleteId",2);y([v()],m.prototype,"cronRunModalJobId",2);y([v()],m.prototype,"cronRunModalJobName",2);y([v()],m.prototype,"cronRunResult",2);y([v()],m.prototype,"browserScreencastActive",2);y([v()],m.prototype,"browserScreencastFrame",2);y([v()],m.prototype,"browserScreencastMetadata",2);y([v()],m.prototype,"browserHandoffPending",2);y([v()],m.prototype,"browserHandoffReason",2);y([v()],m.prototype,"browserHandoffId",2);y([v()],m.prototype,"browserInputMode",2);y([v()],m.prototype,"browserFullscreen",2);y([v()],m.prototype,"browserLoading",2);y([v()],m.prototype,"browserError",2);y([v()],m.prototype,"filesLoading",2);y([v()],m.prototype,"filesTree",2);y([v()],m.prototype,"filesRoot",2);y([v()],m.prototype,"filesError",2);y([v()],m.prototype,"filesSelectedPath",2);y([v()],m.prototype,"filesSelectedPaths",2);y([v()],m.prototype,"filesPreviewContent",2);y([v()],m.prototype,"filesPreviewLoading",2);y([v()],m.prototype,"filesPreviewBinary",2);y([v()],m.prototype,"filesPreviewSize",2);y([v()],m.prototype,"filesExpandedDirs",2);y([v()],m.prototype,"filesCurrentDir",2);y([v()],m.prototype,"filesPendingDeletePath",2);y([v()],m.prototype,"filesMessage",2);y([v()],m.prototype,"filesUploadBusy",2);y([v()],m.prototype,"filesReindexBusy",2);y([v()],m.prototype,"filesMemoryStatus",2);y([v()],m.prototype,"embeddingDownloading",2);y([v()],m.prototype,"filesSearchQuery",2);y([v()],m.prototype,"filesSearchResults",2);y([v()],m.prototype,"filesSearchLoading",2);y([v()],m.prototype,"filesSearchAgentId",2);y([v()],m.prototype,"auditEntries",2);y([v()],m.prototype,"auditLoading",2);y([v()],m.prototype,"auditModalOpen",2);y([v()],m.prototype,"skillsLoading",2);y([v()],m.prototype,"skillsReport",2);y([v()],m.prototype,"skillsError",2);y([v()],m.prototype,"skillsFilter",2);y([v()],m.prototype,"skillsTypeFilter",2);y([v()],m.prototype,"skillEdits",2);y([v()],m.prototype,"skillsBusyKey",2);y([v()],m.prototype,"skillMessages",2);y([v()],m.prototype,"skillDetail",2);y([v()],m.prototype,"skillDetailTab",2);y([v()],m.prototype,"skillAddModal",2);y([v()],m.prototype,"skillAddForm",2);y([v()],m.prototype,"skillAddFormSource",2);y([v()],m.prototype,"skillEditTab",2);y([v()],m.prototype,"skillDrafts",2);y([v()],m.prototype,"adminsLoading",2);y([v()],m.prototype,"adminPhones",2);y([v()],m.prototype,"adminsError",2);y([v()],m.prototype,"adminsSaving",2);y([v()],m.prototype,"adminsNewPhone",2);y([v()],m.prototype,"contactsLoading",2);y([v()],m.prototype,"contactsSaving",2);y([v()],m.prototype,"contactsRecords",2);y([v()],m.prototype,"contactsError",2);y([v()],m.prototype,"contactsSearchQuery",2);y([v()],m.prototype,"contactsEditingId",2);y([v()],m.prototype,"contactsShowAddForm",2);y([v()],m.prototype,"contactsNewPhone",2);y([v()],m.prototype,"contactsNewName",2);y([v()],m.prototype,"contactsDeleteConfirmId",2);y([v()],m.prototype,"contactsAddFieldForId",2);y([v()],m.prototype,"contactsAddFieldKey",2);y([v()],m.prototype,"contactsAddFieldValue",2);y([v()],m.prototype,"imessageEnableConfirm",2);y([v()],m.prototype,"imessageEnabling",2);y([v()],m.prototype,"infoModalOpen",2);y([v()],m.prototype,"remoteAccessQrDataUrl",2);y([v()],m.prototype,"publicChatQrDataUrl",2);y([v()],m.prototype,"workspaces",2);y([v()],m.prototype,"workspacesLoading",2);y([v()],m.prototype,"workspacesError",2);y([v()],m.prototype,"selectedWorkspace",2);y([v()],m.prototype,"addingWorkspace",2);y([v()],m.prototype,"newWorkspaceName",2);y([v()],m.prototype,"newWorkspacePath",2);y([v()],m.prototype,"newWorkspacePin",2);y([v()],m.prototype,"accountPinModalOpen",2);y([v()],m.prototype,"accountPinBusy",2);y([v()],m.prototype,"accountPinError",2);y([v()],m.prototype,"accountPinSuccess",2);y([v()],m.prototype,"apiKeyProviders",2);y([v()],m.prototype,"apiKeyModalOpen",2);y([v()],m.prototype,"apiKeyBusy",2);y([v()],m.prototype,"apiKeyError",2);y([v()],m.prototype,"apiKeySuccess",2);y([v()],m.prototype,"apiKeySavingProvider",2);y([v()],m.prototype,"authApiKeyMode",2);y([v()],m.prototype,"authApiKeyInput",2);y([v()],m.prototype,"authApiKeyBusy",2);y([v()],m.prototype,"authApiKeyError",2);y([v()],m.prototype,"pinChanging",2);y([v()],m.prototype,"pinChangeBusy",2);y([v()],m.prototype,"pinChangeError",2);y([v()],m.prototype,"loginChangePinMode",2);y([v()],m.prototype,"changePinBusy",2);y([v()],m.prototype,"changePinError",2);y([v()],m.prototype,"changePinSuccess",2);y([v()],m.prototype,"workspaceSaving",2);y([v()],m.prototype,"workspaceRemoveConfirm",2);y([v()],m.prototype,"renamingWorkspace",2);y([v()],m.prototype,"renameWorkspaceName",2);y([v()],m.prototype,"debugLoading",2);y([v()],m.prototype,"debugStatus",2);y([v()],m.prototype,"debugHealth",2);y([v()],m.prototype,"debugModels",2);y([v()],m.prototype,"debugHeartbeat",2);y([v()],m.prototype,"debugCallMethod",2);y([v()],m.prototype,"debugCallParams",2);y([v()],m.prototype,"debugCallResult",2);y([v()],m.prototype,"debugCallError",2);y([v()],m.prototype,"logsLoading",2);y([v()],m.prototype,"logsError",2);y([v()],m.prototype,"logsFile",2);y([v()],m.prototype,"logsEntries",2);y([v()],m.prototype,"logsFilterText",2);y([v()],m.prototype,"logsLevelFilters",2);y([v()],m.prototype,"logsAutoFollow",2);y([v()],m.prototype,"logsTruncated",2);y([v()],m.prototype,"logsCursor",2);y([v()],m.prototype,"logsLastFetchAt",2);y([v()],m.prototype,"logsLimit",2);y([v()],m.prototype,"logsMaxBytes",2);y([v()],m.prototype,"logsAtBottom",2);y([v()],m.prototype,"logsSubTab",2);y([v()],m.prototype,"logsChipsExpanded",2);y([v()],m.prototype,"sessionLogsLoading",2);y([v()],m.prototype,"sessionLogsError",2);y([v()],m.prototype,"sessionLogsEntries",2);y([v()],m.prototype,"sessionLogsFilterText",2);y([v()],m.prototype,"sessionLogsTypeFilters",2);y([v()],m.prototype,"sessionLogsAgentFilters",2);y([v()],m.prototype,"sessionLogsAgents",2);y([v()],m.prototype,"sessionLogsAutoFollow",2);y([v()],m.prototype,"sessionLogsChipsExpanded",2);y([v()],m.prototype,"sessionLogsCursors",2);y([v()],m.prototype,"sessionLogsLastFetchAt",2);y([v()],m.prototype,"sessionLogsAtBottom",2);y([v()],m.prototype,"chatUserNearBottom",2);m=y([Wl("taskmaster-app")],m);
|
|
4565
|
+
//# sourceMappingURL=index-CP9IoaZp.js.map
|